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:
authorCampbell Barton <ideasman42@gmail.com>2017-10-09 12:49:27 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-10-09 12:49:27 +0300
commita5b4b0f21c1ae8c96e4fea9abdcfac2fab1cf300 (patch)
tree0658d8bdfb8ec03652aa04f82ee8a4d243ec6370
parentd68f698cf0321477c0734474150eb4bc43c4e85f (diff)
parentabcda06934aba054de8540b66b13c2bbc5f8f515 (diff)
Merge branch '28' into custom-manipulatorscustom-manipulators
-rw-r--r--.gitignore9
-rw-r--r--CMakeLists.txt88
-rw-r--r--GNUmakefile45
-rw-r--r--build_files/build_environment/CMakeLists.txt132
-rw-r--r--build_files/build_environment/cmake/alembic.cmake75
-rw-r--r--build_files/build_environment/cmake/blendthumb.cmake61
-rw-r--r--build_files/build_environment/cmake/blosc.cmake43
-rw-r--r--build_files/build_environment/cmake/boost.cmake107
-rw-r--r--build_files/build_environment/cmake/clang.cmake51
-rw-r--r--build_files/build_environment/cmake/clew.cmake28
-rw-r--r--build_files/build_environment/cmake/cuew.cmake29
-rw-r--r--build_files/build_environment/cmake/faad.cmake35
-rw-r--r--build_files/build_environment/cmake/ffmpeg.cmake119
-rw-r--r--build_files/build_environment/cmake/fftw.cmake40
-rw-r--r--build_files/build_environment/cmake/flac.cmake32
-rw-r--r--build_files/build_environment/cmake/flexbison.cmake31
-rw-r--r--build_files/build_environment/cmake/freeglut.cmake35
-rw-r--r--build_files/build_environment/cmake/freetype.cmake28
-rw-r--r--build_files/build_environment/cmake/glew.cmake32
-rw-r--r--build_files/build_environment/cmake/glfw.cmake28
-rw-r--r--build_files/build_environment/cmake/harvest.cmake279
-rw-r--r--build_files/build_environment/cmake/hdf5.cmake42
-rw-r--r--build_files/build_environment/cmake/hidapi.cmake29
-rw-r--r--build_files/build_environment/cmake/iconv.cmake34
-rw-r--r--build_files/build_environment/cmake/ilmbase.cmake35
-rw-r--r--build_files/build_environment/cmake/jemalloc.cmake28
-rw-r--r--build_files/build_environment/cmake/jpeg.cmake65
-rw-r--r--build_files/build_environment/cmake/lame.cmake47
-rw-r--r--build_files/build_environment/cmake/lapack.cmake43
-rw-r--r--build_files/build_environment/cmake/llvm.cmake61
-rw-r--r--build_files/build_environment/cmake/numpy.cmake57
-rw-r--r--build_files/build_environment/cmake/ogg.cmake32
-rw-r--r--build_files/build_environment/cmake/openal.cmake42
-rw-r--r--build_files/build_environment/cmake/opencollada.cmake37
-rw-r--r--build_files/build_environment/cmake/opencolorio.cmake70
-rw-r--r--build_files/build_environment/cmake/openexr.cmake41
-rw-r--r--build_files/build_environment/cmake/openimageio.cmake132
-rw-r--r--build_files/build_environment/cmake/openjpeg.cmake57
-rw-r--r--build_files/build_environment/cmake/opensubdiv.cmake71
-rw-r--r--build_files/build_environment/cmake/openvdb.cmake71
-rw-r--r--build_files/build_environment/cmake/options.cmake210
-rw-r--r--build_files/build_environment/cmake/orc.cmake32
-rw-r--r--build_files/build_environment/cmake/osl.cmake87
-rw-r--r--build_files/build_environment/cmake/png.cmake41
-rw-r--r--build_files/build_environment/cmake/pthreads.cmake45
-rw-r--r--build_files/build_environment/cmake/python.cmake138
-rw-r--r--build_files/build_environment/cmake/python_site_packages.cmake38
-rw-r--r--build_files/build_environment/cmake/schroedinger.cmake45
-rw-r--r--build_files/build_environment/cmake/sdl.cmake39
-rw-r--r--build_files/build_environment/cmake/setup_mingw32.cmake219
-rw-r--r--build_files/build_environment/cmake/setup_mingw64.cmake219
-rw-r--r--build_files/build_environment/cmake/sndfile.cmake55
-rw-r--r--build_files/build_environment/cmake/spnav.cmake28
-rw-r--r--build_files/build_environment/cmake/tbb.cmake36
-rw-r--r--build_files/build_environment/cmake/theora.cmake40
-rw-r--r--build_files/build_environment/cmake/tiff.cmake44
-rw-r--r--build_files/build_environment/cmake/versions.cmake250
-rw-r--r--build_files/build_environment/cmake/vorbis.cmake38
-rw-r--r--build_files/build_environment/cmake/vpx.cmake60
-rw-r--r--build_files/build_environment/cmake/webp.cmake50
-rw-r--r--build_files/build_environment/cmake/x264.cmake40
-rw-r--r--build_files/build_environment/cmake/xml2.cmake36
-rw-r--r--build_files/build_environment/cmake/xvidcore.cmake44
-rw-r--r--build_files/build_environment/cmake/zlib.cmake33
-rw-r--r--build_files/build_environment/cmake/zlib_mingw.cmake40
-rwxr-xr-xbuild_files/build_environment/install_deps.sh66
-rw-r--r--build_files/build_environment/patches/alembic.diff35
-rw-r--r--build_files/build_environment/patches/blosc.diff33
-rw-r--r--build_files/build_environment/patches/clang.diff127
-rw-r--r--build_files/build_environment/patches/cmake/modules/FindBlosc.cmake73
-rw-r--r--build_files/build_environment/patches/cmake/modules/FindCppUnit.cmake73
-rw-r--r--build_files/build_environment/patches/cmake/modules/FindIlmBase.cmake260
-rw-r--r--build_files/build_environment/patches/cmake/modules/FindLogC4Plus.cmake73
-rw-r--r--build_files/build_environment/patches/cmake/modules/FindOpenEXR.cmake244
-rw-r--r--build_files/build_environment/patches/cmake/modules/FindTBB.cmake73
-rw-r--r--build_files/build_environment/patches/cmake/modules/SelectLibraryConfigurations.cmake82
-rw-r--r--build_files/build_environment/patches/cmakelists_glew.txt2
-rw-r--r--build_files/build_environment/patches/cmakelists_hidapi.txt20
-rw-r--r--build_files/build_environment/patches/cmakelists_openvdb.txt398
-rw-r--r--build_files/build_environment/patches/cmakelists_tbb.txt196
-rw-r--r--build_files/build_environment/patches/cuew.diff26
-rw-r--r--build_files/build_environment/patches/distutildebugflags.diff11
-rw-r--r--build_files/build_environment/patches/ffmpeg.diff32
-rw-r--r--build_files/build_environment/patches/fftw3.diff25
-rw-r--r--build_files/build_environment/patches/hdf5.diff11
-rw-r--r--build_files/build_environment/patches/hidapi.diff15
-rw-r--r--build_files/build_environment/patches/install_deps_llvm.diff (renamed from build_files/build_environment/install_deps_patches/llvm.patch)0
-rw-r--r--build_files/build_environment/patches/install_deps_osl.diff (renamed from build_files/build_environment/install_deps_patches/osl.patch)0
-rw-r--r--build_files/build_environment/patches/libfaad.diff10
-rw-r--r--build_files/build_environment/patches/llvm-alloca-fix.diff111
-rw-r--r--build_files/build_environment/patches/ming32sh.cmd7
-rw-r--r--build_files/build_environment/patches/ming64sh.cmd7
-rw-r--r--build_files/build_environment/patches/numpy.diff23
-rw-r--r--build_files/build_environment/patches/opencollada.diff32
-rw-r--r--build_files/build_environment/patches/opencolorio.diff21
-rw-r--r--build_files/build_environment/patches/openexr.diff33
-rw-r--r--build_files/build_environment/patches/openimageio_gdi.diff26
-rw-r--r--build_files/build_environment/patches/openimageio_idiff.diff13
-rw-r--r--build_files/build_environment/patches/openimageio_staticexr.diff11
-rw-r--r--build_files/build_environment/patches/opensubdiv.diff16
-rw-r--r--build_files/build_environment/patches/openvdb.diff11
-rw-r--r--build_files/build_environment/patches/openvdb_vc2013.diff35
-rw-r--r--build_files/build_environment/patches/osl.diff12
-rw-r--r--build_files/build_environment/patches/osl_simd_oiio.diff14
-rw-r--r--build_files/build_environment/patches/pthreads.diff13
-rw-r--r--build_files/build_environment/patches/pyshell.diff12
-rw-r--r--build_files/build_environment/patches/python.diff82
-rw-r--r--build_files/build_environment/patches/python_apple.diff25
-rw-r--r--build_files/build_environment/patches/python_runtime_vc2013.diff29
-rw-r--r--build_files/build_environment/patches/schroedinger.diff54
-rw-r--r--build_files/build_environment/patches/sdl.diff50
-rw-r--r--build_files/build_environment/patches/semi.txt1
-rw-r--r--build_files/build_environment/patches/sndfile.diff42
-rw-r--r--build_files/build_environment/windows/build_deps.cmd122
-rw-r--r--build_files/build_environment/windows/buildall.cmd10
-rw-r--r--build_files/build_environment/windows/nuke.cmd52
-rw-r--r--build_files/buildbot/config/blender_linux.cmake4
-rw-r--r--build_files/buildbot/master.cfg24
-rw-r--r--build_files/buildbot/slave_compile.py11
-rw-r--r--build_files/buildbot/slave_pack.py8
-rw-r--r--build_files/cmake/Modules/FindPythonLibsUnix.cmake11
-rw-r--r--build_files/cmake/Modules/FindSndFile.cmake40
-rwxr-xr-xbuild_files/cmake/cmake_consistency_check.py4
-rw-r--r--build_files/cmake/config/blender_full.cmake2
-rw-r--r--build_files/cmake/config/blender_lite.cmake4
-rw-r--r--build_files/cmake/config/blender_release.cmake2
-rw-r--r--build_files/cmake/macros.cmake21
-rw-r--r--build_files/cmake/platform/platform_apple.cmake78
-rw-r--r--build_files/cmake/platform/platform_apple_xcode.cmake26
-rw-r--r--build_files/cmake/platform/platform_unix.cmake6
-rw-r--r--build_files/cmake/platform/platform_win32.cmake10
-rw-r--r--build_files/cmake/platform/platform_win32_msvc.cmake7
-rwxr-xr-xbuild_files/cmake/project_info.py6
-rwxr-xr-xbuild_files/utils/build_tgz.sh6
-rw-r--r--doc/doxygen/Doxyfile2
-rw-r--r--doc/doxygen/doxygen.source.h3
-rw-r--r--doc/guides/python-dev-guide.txt170
-rw-r--r--doc/python_api/examples/bmesh.ops.1.py2
-rw-r--r--doc/python_api/rst/bge_types/bge.types.BL_ShapeActionActuator.rst4
-rw-r--r--doc/python_api/rst/change_log.rst5651
-rw-r--r--doc/python_api/sphinx_doc_gen.py29
-rw-r--r--extern/CMakeLists.txt5
-rw-r--r--extern/audaspace/AUTHORS16
-rw-r--r--extern/audaspace/CHANGES115
-rw-r--r--extern/audaspace/CMakeLists.txt986
-rw-r--r--extern/audaspace/INSTALL107
-rw-r--r--extern/audaspace/LICENSE202
-rw-r--r--extern/audaspace/README.md47
-rw-r--r--extern/audaspace/bindings/C/AUD_Device.cpp336
-rw-r--r--extern/audaspace/bindings/C/AUD_Device.h258
-rw-r--r--extern/audaspace/bindings/C/AUD_DynamicMusic.cpp144
-rw-r--r--extern/audaspace/bindings/C/AUD_DynamicMusic.h145
-rw-r--r--extern/audaspace/bindings/C/AUD_HRTF.cpp50
-rw-r--r--extern/audaspace/bindings/C/AUD_HRTF.h48
-rw-r--r--extern/audaspace/bindings/C/AUD_Handle.cpp384
-rw-r--r--extern/audaspace/bindings/C/AUD_Handle.h308
-rw-r--r--extern/audaspace/bindings/C/AUD_ImpulseResponse.cpp44
-rw-r--r--extern/audaspace/bindings/C/AUD_ImpulseResponse.h40
-rw-r--r--extern/audaspace/bindings/C/AUD_PlaybackManager.cpp94
-rw-r--r--extern/audaspace/bindings/C/AUD_PlaybackManager.h103
-rw-r--r--extern/audaspace/bindings/C/AUD_Sequence.cpp315
-rw-r--r--extern/audaspace/bindings/C/AUD_Sequence.h338
-rw-r--r--extern/audaspace/bindings/C/AUD_Sound.cpp709
-rw-r--r--extern/audaspace/bindings/C/AUD_Sound.h370
-rw-r--r--extern/audaspace/bindings/C/AUD_Source.cpp84
-rw-r--r--extern/audaspace/bindings/C/AUD_Source.h84
-rw-r--r--extern/audaspace/bindings/C/AUD_Special.cpp420
-rw-r--r--extern/audaspace/bindings/C/AUD_Special.h138
-rw-r--r--extern/audaspace/bindings/C/AUD_ThreadPool.cpp42
-rw-r--r--extern/audaspace/bindings/C/AUD_ThreadPool.h40
-rw-r--r--extern/audaspace/bindings/C/AUD_Types.h179
-rw-r--r--extern/audaspace/bindings/doc/conf.py.in261
-rw-r--r--extern/audaspace/bindings/doc/device.rst7
-rw-r--r--extern/audaspace/bindings/doc/handle.rst7
-rw-r--r--extern/audaspace/bindings/doc/index.rst35
-rw-r--r--extern/audaspace/bindings/doc/sequence.rst7
-rw-r--r--extern/audaspace/bindings/doc/sequence_entry.rst7
-rw-r--r--extern/audaspace/bindings/doc/sound.rst7
-rw-r--r--extern/audaspace/bindings/doc/tutorials.rst166
-rw-r--r--extern/audaspace/bindings/python/PyAPI.cpp231
-rw-r--r--extern/audaspace/bindings/python/PyAPI.h45
-rw-r--r--extern/audaspace/bindings/python/PyDevice.cpp785
-rw-r--r--extern/audaspace/bindings/python/PyDevice.h33
-rw-r--r--extern/audaspace/bindings/python/PyDynamicMusic.cpp467
-rw-r--r--extern/audaspace/bindings/python/PyDynamicMusic.h33
-rw-r--r--extern/audaspace/bindings/python/PyHRTF.cpp247
-rw-r--r--extern/audaspace/bindings/python/PyHRTF.h33
-rw-r--r--extern/audaspace/bindings/python/PyHandle.cpp1126
-rw-r--r--extern/audaspace/bindings/python/PyHandle.h33
-rw-r--r--extern/audaspace/bindings/python/PyImpulseResponse.cpp137
-rw-r--r--extern/audaspace/bindings/python/PyImpulseResponse.h33
-rw-r--r--extern/audaspace/bindings/python/PyPlaybackManager.cpp389
-rw-r--r--extern/audaspace/bindings/python/PyPlaybackManager.h33
-rw-r--r--extern/audaspace/bindings/python/PySequence.cpp655
-rw-r--r--extern/audaspace/bindings/python/PySequence.h33
-rw-r--r--extern/audaspace/bindings/python/PySequenceEntry.cpp740
-rw-r--r--extern/audaspace/bindings/python/PySequenceEntry.h33
-rw-r--r--extern/audaspace/bindings/python/PySound.cpp1966
-rw-r--r--extern/audaspace/bindings/python/PySound.h33
-rw-r--r--extern/audaspace/bindings/python/PySource.cpp260
-rw-r--r--extern/audaspace/bindings/python/PySource.h33
-rw-r--r--extern/audaspace/bindings/python/PyThreadPool.cpp134
-rw-r--r--extern/audaspace/bindings/python/PyThreadPool.h33
-rw-r--r--extern/audaspace/bindings/python/examples/binaural.py13
-rw-r--r--extern/audaspace/bindings/python/examples/convolution.py10
-rw-r--r--extern/audaspace/bindings/python/examples/dynamicmusic.py20
-rw-r--r--extern/audaspace/bindings/python/examples/playbackmanager.py27
-rw-r--r--extern/audaspace/bindings/python/examples/player.py7
-rw-r--r--extern/audaspace/bindings/python/examples/randomSounds.py21
-rw-r--r--extern/audaspace/bindings/python/examples/simple.py7
-rw-r--r--extern/audaspace/bindings/python/examples/siren.py19
-rw-r--r--extern/audaspace/bindings/python/examples/siren2.py23
-rw-r--r--extern/audaspace/bindings/python/examples/tetris.py66
-rw-r--r--extern/audaspace/bindings/python/examples/tetris2.py64
-rw-r--r--extern/audaspace/bindings/python/examples/tetris3.py63
-rw-r--r--extern/audaspace/bindings/python/setup.py.in61
-rw-r--r--extern/audaspace/blender_config.cmake26
-rw-r--r--extern/audaspace/config/Audaspace.h.in131
-rw-r--r--extern/audaspace/include/Exception.h185
-rw-r--r--extern/audaspace/include/IReader.h (renamed from intern/audaspace/intern/AUD_IReader.h)57
-rw-r--r--extern/audaspace/include/ISound.h57
-rw-r--r--extern/audaspace/include/devices/DefaultSynchronizer.h44
-rw-r--r--extern/audaspace/include/devices/DeviceManager.h129
-rw-r--r--extern/audaspace/include/devices/I3DDevice.h142
-rw-r--r--extern/audaspace/include/devices/I3DHandle.h (renamed from intern/audaspace/intern/AUD_I3DHandle.h)110
-rw-r--r--extern/audaspace/include/devices/IDevice.h123
-rw-r--r--extern/audaspace/include/devices/IDeviceFactory.h72
-rw-r--r--extern/audaspace/include/devices/IHandle.h (renamed from intern/audaspace/intern/AUD_IHandle.h)80
-rw-r--r--extern/audaspace/include/devices/ISynchronizer.h92
-rw-r--r--extern/audaspace/include/devices/NULLDevice.h96
-rw-r--r--extern/audaspace/include/devices/ReadDevice.h82
-rw-r--r--extern/audaspace/include/devices/SoftwareDevice.h (renamed from intern/audaspace/intern/AUD_SoftwareDevice.h)194
-rw-r--r--extern/audaspace/include/file/File.h74
-rw-r--r--extern/audaspace/include/file/FileManager.h95
-rw-r--r--extern/audaspace/include/file/FileWriter.h78
-rw-r--r--extern/audaspace/include/file/IFileInput.h60
-rw-r--r--extern/audaspace/include/file/IFileOutput.h52
-rw-r--r--extern/audaspace/include/file/IWriter.h89
-rw-r--r--extern/audaspace/include/fx/ADSR.h121
-rw-r--r--extern/audaspace/include/fx/ADSRReader.h101
-rw-r--r--extern/audaspace/include/fx/Accumulator.h79
-rw-r--r--extern/audaspace/include/fx/BaseIIRFilterReader.h (renamed from intern/audaspace/FX/AUD_BaseIIRFilterReader.h)70
-rw-r--r--extern/audaspace/include/fx/BinauralReader.h223
-rw-r--r--extern/audaspace/include/fx/BinauralSound.h119
-rw-r--r--extern/audaspace/include/fx/Butterworth.h48
-rw-r--r--extern/audaspace/include/fx/ButterworthCalculator.h55
-rw-r--r--extern/audaspace/include/fx/CallbackIIRFilterReader.h88
-rw-r--r--extern/audaspace/include/fx/Convolver.h177
-rw-r--r--extern/audaspace/include/fx/ConvolverReader.h198
-rw-r--r--extern/audaspace/include/fx/ConvolverSound.h100
-rw-r--r--extern/audaspace/include/fx/Delay.h60
-rw-r--r--extern/audaspace/include/fx/DelayReader.h63
-rw-r--r--extern/audaspace/include/fx/DynamicIIRFilter.h54
-rw-r--r--extern/audaspace/include/fx/DynamicIIRFilterReader.h60
-rw-r--r--extern/audaspace/include/fx/DynamicMusic.h235
-rw-r--r--extern/audaspace/include/fx/Effect.h76
-rw-r--r--extern/audaspace/include/fx/EffectReader.h68
-rw-r--r--extern/audaspace/include/fx/Envelope.h93
-rw-r--r--extern/audaspace/include/fx/FFTConvolver.h196
-rw-r--r--extern/audaspace/include/fx/Fader.h87
-rw-r--r--extern/audaspace/include/fx/FaderReader.h77
-rw-r--r--extern/audaspace/include/fx/HRTF.h108
-rw-r--r--extern/audaspace/include/fx/HRTFLoader.h99
-rw-r--r--extern/audaspace/include/fx/Highpass.h49
-rw-r--r--extern/audaspace/include/fx/HighpassCalculator.h61
-rw-r--r--extern/audaspace/include/fx/IDynamicIIRFilterCalculator.h50
-rw-r--r--extern/audaspace/include/fx/IIRFilter.h63
-rw-r--r--extern/audaspace/include/fx/IIRFilterReader.h70
-rw-r--r--extern/audaspace/include/fx/ImpulseResponse.h108
-rw-r--r--extern/audaspace/include/fx/Limiter.h73
-rw-r--r--extern/audaspace/include/fx/LimiterReader.h65
-rw-r--r--extern/audaspace/include/fx/Loop.h62
-rw-r--r--extern/audaspace/include/fx/LoopReader.h65
-rw-r--r--extern/audaspace/include/fx/Lowpass.h49
-rw-r--r--extern/audaspace/include/fx/LowpassCalculator.h61
-rw-r--r--extern/audaspace/include/fx/MutableReader.h71
-rw-r--r--extern/audaspace/include/fx/MutableSound.h58
-rw-r--r--extern/audaspace/include/fx/Pitch.h55
-rw-r--r--extern/audaspace/include/fx/PitchReader.h67
-rw-r--r--extern/audaspace/include/fx/PlaybackCategory.h127
-rw-r--r--extern/audaspace/include/fx/PlaybackManager.h156
-rw-r--r--extern/audaspace/include/fx/Reverse.h50
-rw-r--r--extern/audaspace/include/fx/ReverseReader.h65
-rw-r--r--extern/audaspace/include/fx/SoundList.h110
-rw-r--r--extern/audaspace/include/fx/Source.h109
-rw-r--r--extern/audaspace/include/fx/Sum.h49
-rw-r--r--extern/audaspace/include/fx/Threshold.h78
-rw-r--r--extern/audaspace/include/fx/Volume.h63
-rw-r--r--extern/audaspace/include/fx/VolumeReader.h70
-rw-r--r--extern/audaspace/include/fx/VolumeSound.h74
-rw-r--r--extern/audaspace/include/fx/VolumeStorage.h71
-rw-r--r--extern/audaspace/include/generator/Sawtooth.h66
-rw-r--r--extern/audaspace/include/generator/SawtoothReader.h86
-rw-r--r--extern/audaspace/include/generator/Silence.h48
-rw-r--r--extern/audaspace/include/generator/SilenceReader.h59
-rw-r--r--extern/audaspace/include/generator/Sine.h67
-rw-r--r--extern/audaspace/include/generator/SineReader.h77
-rw-r--r--extern/audaspace/include/generator/Square.h67
-rw-r--r--extern/audaspace/include/generator/SquareReader.h86
-rw-r--r--extern/audaspace/include/generator/Triangle.h67
-rw-r--r--extern/audaspace/include/generator/TriangleReader.h86
-rw-r--r--extern/audaspace/include/plugin/PluginManager.h81
-rw-r--r--extern/audaspace/include/respec/ChannelMapper.h51
-rw-r--r--extern/audaspace/include/respec/ChannelMapperReader.h151
-rw-r--r--extern/audaspace/include/respec/Converter.h51
-rw-r--r--extern/audaspace/include/respec/ConverterFunctions.h377
-rw-r--r--extern/audaspace/include/respec/ConverterReader.h67
-rw-r--r--extern/audaspace/include/respec/JOSResample.h50
-rw-r--r--extern/audaspace/include/respec/JOSResampleReader.h129
-rw-r--r--extern/audaspace/include/respec/LinearResample.h50
-rw-r--r--extern/audaspace/include/respec/LinearResampleReader.h80
-rw-r--r--extern/audaspace/include/respec/Mixer.h123
-rw-r--r--extern/audaspace/include/respec/ResampleReader.h61
-rw-r--r--extern/audaspace/include/respec/Specification.h138
-rw-r--r--extern/audaspace/include/respec/SpecsChanger.h74
-rw-r--r--extern/audaspace/include/sequence/AnimateableProperty.h129
-rw-r--r--extern/audaspace/include/sequence/Double.h60
-rw-r--r--extern/audaspace/include/sequence/DoubleReader.h77
-rw-r--r--extern/audaspace/include/sequence/PingPong.h50
-rw-r--r--extern/audaspace/include/sequence/Sequence.h (renamed from intern/audaspace/intern/AUD_SequencerFactory.h)114
-rw-r--r--extern/audaspace/include/sequence/SequenceData.h (renamed from intern/audaspace/intern/AUD_Sequencer.h)115
-rw-r--r--extern/audaspace/include/sequence/SequenceEntry.h (renamed from intern/audaspace/intern/AUD_SequencerEntry.h)116
-rw-r--r--extern/audaspace/include/sequence/SequenceReader.h94
-rw-r--r--extern/audaspace/include/sequence/Superpose.h62
-rw-r--r--extern/audaspace/include/sequence/SuperposeReader.h79
-rw-r--r--extern/audaspace/include/util/Barrier.h78
-rw-r--r--extern/audaspace/include/util/Buffer.h87
-rw-r--r--extern/audaspace/include/util/BufferReader.h76
-rw-r--r--extern/audaspace/include/util/FFTPlan.h120
-rw-r--r--extern/audaspace/include/util/ILockable.h46
-rw-r--r--extern/audaspace/include/util/Math3D.h (renamed from intern/audaspace/intern/AUD_3DMath.h)102
-rw-r--r--extern/audaspace/include/util/StreamBuffer.h85
-rw-r--r--extern/audaspace/include/util/ThreadPool.h119
-rw-r--r--extern/audaspace/plugins/ffmpeg/FFMPEG.cpp63
-rw-r--r--extern/audaspace/plugins/ffmpeg/FFMPEG.h60
-rw-r--r--extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp397
-rw-r--r--extern/audaspace/plugins/ffmpeg/FFMPEGReader.h184
-rw-r--r--extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp427
-rw-r--r--extern/audaspace/plugins/ffmpeg/FFMPEGWriter.h145
-rw-r--r--extern/audaspace/plugins/jack/JackDevice.cpp385
-rw-r--r--extern/audaspace/plugins/jack/JackDevice.h (renamed from intern/audaspace/jack/AUD_JackDevice.h)115
-rw-r--r--extern/audaspace/plugins/jack/JackLibrary.cpp59
-rw-r--r--extern/audaspace/plugins/jack/JackLibrary.h48
-rw-r--r--extern/audaspace/plugins/jack/JackSymbols.h45
-rw-r--r--extern/audaspace/plugins/jack/JackSynchronizer.cpp58
-rw-r--r--extern/audaspace/plugins/jack/JackSynchronizer.h59
-rw-r--r--extern/audaspace/plugins/libsndfile/SndFile.cpp62
-rw-r--r--extern/audaspace/plugins/libsndfile/SndFile.h60
-rw-r--r--extern/audaspace/plugins/libsndfile/SndFileReader.cpp161
-rw-r--r--extern/audaspace/plugins/libsndfile/SndFileReader.h125
-rw-r--r--extern/audaspace/plugins/libsndfile/SndFileWriter.cpp128
-rw-r--r--extern/audaspace/plugins/libsndfile/SndFileWriter.h84
-rw-r--r--extern/audaspace/plugins/openal/OpenALDevice.cpp1490
-rw-r--r--extern/audaspace/plugins/openal/OpenALDevice.h (renamed from intern/audaspace/OpenAL/AUD_OpenALDevice.h)198
-rw-r--r--extern/audaspace/plugins/openal/OpenALReader.cpp96
-rw-r--r--extern/audaspace/plugins/openal/OpenALReader.h83
-rw-r--r--extern/audaspace/plugins/sdl/SDLDevice.cpp156
-rw-r--r--extern/audaspace/plugins/sdl/SDLDevice.h82
-rw-r--r--extern/audaspace/src/Exception.cpp110
-rw-r--r--extern/audaspace/src/devices/DefaultSynchronizer.cpp49
-rw-r--r--extern/audaspace/src/devices/DeviceManager.cpp117
-rw-r--r--extern/audaspace/src/devices/NULLDevice.cpp193
-rw-r--r--extern/audaspace/src/devices/ReadDevice.cpp69
-rw-r--r--extern/audaspace/src/devices/SoftwareDevice.cpp989
-rw-r--r--extern/audaspace/src/file/File.cpp45
-rw-r--r--extern/audaspace/src/file/FileManager.cpp88
-rw-r--r--extern/audaspace/src/file/FileWriter.cpp95
-rw-r--r--extern/audaspace/src/fx/ADSR.cpp73
-rw-r--r--extern/audaspace/src/fx/ADSRReader.cpp115
-rw-r--r--extern/audaspace/src/fx/Accumulator.cpp54
-rw-r--r--extern/audaspace/src/fx/BaseIIRFilterReader.cpp125
-rw-r--r--extern/audaspace/src/fx/BinauralReader.cpp255
-rw-r--r--extern/audaspace/src/fx/BinauralSound.cpp60
-rw-r--r--extern/audaspace/src/fx/Butterworth.cpp28
-rw-r--r--extern/audaspace/src/fx/ButterworthCalculator.cpp54
-rw-r--r--extern/audaspace/src/fx/CallbackIIRFilterReader.cpp38
-rw-r--r--extern/audaspace/src/fx/Convolver.cpp156
-rw-r--r--extern/audaspace/src/fx/ConvolverReader.cpp203
-rw-r--r--extern/audaspace/src/fx/ConvolverSound.cpp50
-rw-r--r--extern/audaspace/src/fx/Delay.cpp38
-rw-r--r--extern/audaspace/src/fx/DelayReader.cpp87
-rw-r--r--extern/audaspace/src/fx/DynamicIIRFilter.cpp35
-rw-r--r--extern/audaspace/src/fx/DynamicIIRFilterReader.cpp36
-rw-r--r--extern/audaspace/src/fx/DynamicMusic.cpp346
-rw-r--r--extern/audaspace/src/fx/Effect.cpp35
-rw-r--r--extern/audaspace/src/fx/EffectReader.cpp60
-rw-r--r--extern/audaspace/src/fx/Envelope.cpp71
-rw-r--r--extern/audaspace/src/fx/FFTConvolver.cpp214
-rw-r--r--extern/audaspace/src/fx/Fader.cpp49
-rw-r--r--extern/audaspace/src/fx/FaderReader.cpp76
-rw-r--r--extern/audaspace/src/fx/HRTF.cpp122
-rw-r--r--extern/audaspace/src/fx/HRTFLoaderUnix.cpp89
-rw-r--r--extern/audaspace/src/fx/HRTFLoaderWindows.cpp93
-rw-r--r--extern/audaspace/src/fx/Highpass.cpp28
-rw-r--r--extern/audaspace/src/fx/HighpassCalculator.cpp43
-rw-r--r--extern/audaspace/src/fx/IIRFilter.cpp32
-rw-r--r--extern/audaspace/src/fx/IIRFilterReader.cpp53
-rw-r--r--extern/audaspace/src/fx/ImpulseResponse.cpp97
-rw-r--r--extern/audaspace/src/fx/Limiter.cpp45
-rw-r--r--extern/audaspace/src/fx/LimiterReader.cpp (renamed from intern/audaspace/FX/AUD_LimiterReader.cpp)70
-rw-r--r--extern/audaspace/src/fx/Loop.cpp38
-rw-r--r--extern/audaspace/src/fx/LoopReader.cpp91
-rw-r--r--extern/audaspace/src/fx/Lowpass.cpp27
-rw-r--r--extern/audaspace/src/fx/LowpassCalculator.cpp43
-rw-r--r--extern/audaspace/src/fx/MutableReader.cpp64
-rw-r--r--extern/audaspace/src/fx/MutableSound.cpp35
-rw-r--r--extern/audaspace/src/fx/Pitch.cpp33
-rw-r--r--extern/audaspace/src/fx/PitchReader.cpp44
-rw-r--r--extern/audaspace/src/fx/PlaybackCategory.cpp144
-rw-r--r--extern/audaspace/src/fx/PlaybackManager.cpp186
-rw-r--r--extern/audaspace/src/fx/Reverse.cpp32
-rw-r--r--extern/audaspace/src/fx/ReverseReader.cpp88
-rw-r--r--extern/audaspace/src/fx/SoundList.cpp84
-rw-r--r--extern/audaspace/src/fx/Source.cpp71
-rw-r--r--extern/audaspace/src/fx/Sum.cpp36
-rw-r--r--extern/audaspace/src/fx/Threshold.cpp54
-rw-r--r--extern/audaspace/src/fx/Volume.cpp41
-rw-r--r--extern/audaspace/src/fx/VolumeReader.cpp60
-rw-r--r--extern/audaspace/src/fx/VolumeSound.cpp45
-rw-r--r--extern/audaspace/src/fx/VolumeStorage.cpp39
-rw-r--r--extern/audaspace/src/generator/Sawtooth.cpp38
-rw-r--r--extern/audaspace/src/generator/SawtoothReader.cpp83
-rw-r--r--extern/audaspace/src/generator/Silence.cpp31
-rw-r--r--extern/audaspace/src/generator/SilenceReader.cpp63
-rw-r--r--extern/audaspace/src/generator/Sine.cpp38
-rw-r--r--extern/audaspace/src/generator/SineReader.cpp75
-rw-r--r--extern/audaspace/src/generator/Square.cpp38
-rw-r--r--extern/audaspace/src/generator/SquareReader.cpp83
-rw-r--r--extern/audaspace/src/generator/Triangle.cpp38
-rw-r--r--extern/audaspace/src/generator/TriangleReader.cpp83
-rw-r--r--extern/audaspace/src/plugin/PluginManagerUnix.cpp.in98
-rw-r--r--extern/audaspace/src/plugin/PluginManagerWindows.cpp.in101
-rw-r--r--extern/audaspace/src/respec/ChannelMapper.cpp35
-rw-r--r--extern/audaspace/src/respec/ChannelMapperReader.cpp379
-rw-r--r--extern/audaspace/src/respec/Converter.cpp38
-rw-r--r--extern/audaspace/src/respec/ConverterFunctions.cpp464
-rw-r--r--extern/audaspace/src/respec/ConverterReader.cpp68
-rw-r--r--extern/audaspace/src/respec/JOSResample.cpp33
-rw-r--r--extern/audaspace/src/respec/JOSResampleReader.cpp (renamed from intern/audaspace/intern/AUD_JOSResampleReader.cpp)159
-rw-r--r--extern/audaspace/src/respec/JOSResampleReaderCoeff.cpp (renamed from intern/audaspace/intern/AUD_JOSResampleReaderCoeff.cpp)48
-rw-r--r--extern/audaspace/src/respec/LinearResample.cpp32
-rw-r--r--extern/audaspace/src/respec/LinearResampleReader.cpp174
-rw-r--r--extern/audaspace/src/respec/Mixer.cpp112
-rw-r--r--extern/audaspace/src/respec/ResampleReader.cpp36
-rw-r--r--extern/audaspace/src/respec/SpecsChanger.cpp42
-rw-r--r--extern/audaspace/src/sequence/AnimateableProperty.cpp217
-rw-r--r--extern/audaspace/src/sequence/Double.cpp35
-rw-r--r--extern/audaspace/src/sequence/DoubleReader.cpp102
-rw-r--r--extern/audaspace/src/sequence/PingPong.cpp36
-rw-r--r--extern/audaspace/src/sequence/Sequence.cpp113
-rw-r--r--extern/audaspace/src/sequence/SequenceData.cpp172
-rw-r--r--extern/audaspace/src/sequence/SequenceEntry.cpp256
-rw-r--r--extern/audaspace/src/sequence/SequenceHandle.cpp (renamed from intern/audaspace/intern/AUD_SequencerHandle.cpp)96
-rw-r--r--extern/audaspace/src/sequence/SequenceHandle.h (renamed from intern/audaspace/intern/AUD_SequencerHandle.h)71
-rw-r--r--extern/audaspace/src/sequence/SequenceReader.cpp198
-rw-r--r--extern/audaspace/src/sequence/Superpose.cpp35
-rw-r--r--extern/audaspace/src/sequence/SuperposeReader.cpp95
-rw-r--r--extern/audaspace/src/util/Barrier.cpp42
-rw-r--r--extern/audaspace/src/util/Buffer.cpp72
-rw-r--r--extern/audaspace/src/util/BufferReader.cpp80
-rw-r--r--extern/audaspace/src/util/FFTPlan.cpp66
-rw-r--r--extern/audaspace/src/util/StreamBuffer.cpp83
-rw-r--r--extern/audaspace/src/util/ThreadPool.cpp60
-rw-r--r--extern/carve/carve-capi.cc17
-rw-r--r--extern/carve/carve-util.cc99
-rw-r--r--extern/carve/carve-util.h12
-rw-r--r--extern/cuew/README.blender2
-rw-r--r--extern/cuew/include/cuew.h177
-rw-r--r--extern/cuew/src/cuew.c25
-rw-r--r--extern/curve_fit_nd/intern/curve_fit_cubic_refit.c4
-rw-r--r--intern/atomic/atomic_ops.h3
-rw-r--r--intern/atomic/intern/atomic_ops_ext.h23
-rw-r--r--intern/atomic/intern/atomic_ops_utils.h11
-rw-r--r--intern/audaspace/CMakeLists.txt304
-rw-r--r--intern/audaspace/COPYING339
-rw-r--r--intern/audaspace/FX/AUD_AccumulatorFactory.cpp64
-rw-r--r--intern/audaspace/FX/AUD_AccumulatorFactory.h69
-rw-r--r--intern/audaspace/FX/AUD_BandpassCalculator.cpp5
-rw-r--r--intern/audaspace/FX/AUD_BandpassCalculator.h10
-rw-r--r--intern/audaspace/FX/AUD_BaseIIRFilterReader.cpp137
-rw-r--r--intern/audaspace/FX/AUD_ButterworthCalculator.cpp38
-rw-r--r--intern/audaspace/FX/AUD_ButterworthCalculator.h20
-rw-r--r--intern/audaspace/FX/AUD_ButterworthFactory.cpp39
-rw-r--r--intern/audaspace/FX/AUD_ButterworthFactory.h54
-rw-r--r--intern/audaspace/FX/AUD_CallbackIIRFilterReader.cpp51
-rw-r--r--intern/audaspace/FX/AUD_CallbackIIRFilterReader.h87
-rw-r--r--intern/audaspace/FX/AUD_DelayFactory.cpp48
-rw-r--r--intern/audaspace/FX/AUD_DelayFactory.h66
-rw-r--r--intern/audaspace/FX/AUD_DelayReader.cpp96
-rw-r--r--intern/audaspace/FX/AUD_DelayReader.h70
-rw-r--r--intern/audaspace/FX/AUD_DoubleFactory.cpp44
-rw-r--r--intern/audaspace/FX/AUD_DoubleFactory.h66
-rw-r--r--intern/audaspace/FX/AUD_DoubleReader.cpp112
-rw-r--r--intern/audaspace/FX/AUD_DoubleReader.h84
-rw-r--r--intern/audaspace/FX/AUD_DynamicIIRFilterFactory.cpp44
-rw-r--r--intern/audaspace/FX/AUD_DynamicIIRFilterFactory.h58
-rw-r--r--intern/audaspace/FX/AUD_DynamicIIRFilterReader.cpp44
-rw-r--r--intern/audaspace/FX/AUD_DynamicIIRFilterReader.h54
-rw-r--r--intern/audaspace/FX/AUD_EffectFactory.cpp45
-rw-r--r--intern/audaspace/FX/AUD_EffectFactory.h82
-rw-r--r--intern/audaspace/FX/AUD_EffectReader.cpp69
-rw-r--r--intern/audaspace/FX/AUD_EffectReader.h74
-rw-r--r--intern/audaspace/FX/AUD_EnvelopeFactory.cpp82
-rw-r--r--intern/audaspace/FX/AUD_EnvelopeFactory.h85
-rw-r--r--intern/audaspace/FX/AUD_FaderFactory.cpp60
-rw-r--r--intern/audaspace/FX/AUD_FaderFactory.h92
-rw-r--r--intern/audaspace/FX/AUD_FaderReader.cpp86
-rw-r--r--intern/audaspace/FX/AUD_FaderReader.h76
-rw-r--r--intern/audaspace/FX/AUD_HighpassCalculator.cpp27
-rw-r--r--intern/audaspace/FX/AUD_HighpassCalculator.h25
-rw-r--r--intern/audaspace/FX/AUD_HighpassFactory.cpp39
-rw-r--r--intern/audaspace/FX/AUD_HighpassFactory.h55
-rw-r--r--intern/audaspace/FX/AUD_IDynamicIIRFilterCalculator.h56
-rw-r--r--intern/audaspace/FX/AUD_IIRFilterFactory.cpp43
-rw-r--r--intern/audaspace/FX/AUD_IIRFilterFactory.h71
-rw-r--r--intern/audaspace/FX/AUD_IIRFilterReader.cpp65
-rw-r--r--intern/audaspace/FX/AUD_IIRFilterReader.h73
-rw-r--r--intern/audaspace/FX/AUD_LimiterFactory.cpp55
-rw-r--r--intern/audaspace/FX/AUD_LimiterFactory.h79
-rw-r--r--intern/audaspace/FX/AUD_LimiterReader.h71
-rw-r--r--intern/audaspace/FX/AUD_LoopFactory.cpp47
-rw-r--r--intern/audaspace/FX/AUD_LoopFactory.h68
-rw-r--r--intern/audaspace/FX/AUD_LoopReader.cpp101
-rw-r--r--intern/audaspace/FX/AUD_LoopReader.h72
-rw-r--r--intern/audaspace/FX/AUD_LowpassCalculator.cpp27
-rw-r--r--intern/audaspace/FX/AUD_LowpassCalculator.h25
-rw-r--r--intern/audaspace/FX/AUD_LowpassFactory.cpp38
-rw-r--r--intern/audaspace/FX/AUD_LowpassFactory.h55
-rw-r--r--intern/audaspace/FX/AUD_PingPongFactory.cpp46
-rw-r--r--intern/audaspace/FX/AUD_PingPongFactory.h56
-rw-r--r--intern/audaspace/FX/AUD_PitchFactory.cpp43
-rw-r--r--intern/audaspace/FX/AUD_PitchFactory.h61
-rw-r--r--intern/audaspace/FX/AUD_PitchReader.cpp54
-rw-r--r--intern/audaspace/FX/AUD_PitchReader.h73
-rw-r--r--intern/audaspace/FX/AUD_RectifyFactory.cpp48
-rw-r--r--intern/audaspace/FX/AUD_RectifyFactory.h58
-rw-r--r--intern/audaspace/FX/AUD_ReverseFactory.cpp42
-rw-r--r--intern/audaspace/FX/AUD_ReverseFactory.h56
-rw-r--r--intern/audaspace/FX/AUD_ReverseReader.cpp105
-rw-r--r--intern/audaspace/FX/AUD_ReverseReader.h72
-rw-r--r--intern/audaspace/FX/AUD_SquareFactory.cpp66
-rw-r--r--intern/audaspace/FX/AUD_SquareFactory.h70
-rw-r--r--intern/audaspace/FX/AUD_SumFactory.cpp45
-rw-r--r--intern/audaspace/FX/AUD_SumFactory.h55
-rw-r--r--intern/audaspace/FX/AUD_SuperposeFactory.cpp44
-rw-r--r--intern/audaspace/FX/AUD_SuperposeFactory.h68
-rw-r--r--intern/audaspace/FX/AUD_SuperposeReader.cpp105
-rw-r--r--intern/audaspace/FX/AUD_SuperposeReader.h85
-rw-r--r--intern/audaspace/FX/AUD_VolumeFactory.cpp50
-rw-r--r--intern/audaspace/FX/AUD_VolumeFactory.h69
-rw-r--r--intern/audaspace/OpenAL/AUD_OpenALDevice.cpp1647
-rw-r--r--intern/audaspace/Python/AUD_PyAPI.cpp2922
-rw-r--r--intern/audaspace/Python/AUD_PyAPI.h74
-rw-r--r--intern/audaspace/SDL/AUD_SDLDevice.cpp97
-rw-r--r--intern/audaspace/SDL/AUD_SDLDevice.h86
-rw-r--r--intern/audaspace/SRC/AUD_SRCResampleFactory.cpp42
-rw-r--r--intern/audaspace/SRC/AUD_SRCResampleFactory.h57
-rw-r--r--intern/audaspace/SRC/AUD_SRCResampleReader.cpp150
-rw-r--r--intern/audaspace/SRC/AUD_SRCResampleReader.h103
-rw-r--r--intern/audaspace/ffmpeg/AUD_FFMPEGFactory.cpp55
-rw-r--r--intern/audaspace/ffmpeg/AUD_FFMPEGFactory.h78
-rw-r--r--intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp483
-rw-r--r--intern/audaspace/ffmpeg/AUD_FFMPEGReader.h169
-rw-r--r--intern/audaspace/ffmpeg/AUD_FFMPEGWriter.cpp395
-rw-r--r--intern/audaspace/ffmpeg/AUD_FFMPEGWriter.h160
-rw-r--r--intern/audaspace/fftw/AUD_BandPassFactory.cpp75
-rw-r--r--intern/audaspace/fftw/AUD_BandPassFactory.h92
-rw-r--r--intern/audaspace/fftw/AUD_BandPassReader.cpp127
-rw-r--r--intern/audaspace/fftw/AUD_BandPassReader.h102
-rw-r--r--intern/audaspace/intern/AUD_AnimateableProperty.cpp247
-rw-r--r--intern/audaspace/intern/AUD_AnimateableProperty.h128
-rw-r--r--intern/audaspace/intern/AUD_Buffer.cpp80
-rw-r--r--intern/audaspace/intern/AUD_Buffer.h93
-rw-r--r--intern/audaspace/intern/AUD_BufferReader.cpp90
-rw-r--r--intern/audaspace/intern/AUD_BufferReader.h81
-rw-r--r--intern/audaspace/intern/AUD_C-API.cpp1323
-rw-r--r--intern/audaspace/intern/AUD_C-API.h822
-rw-r--r--intern/audaspace/intern/AUD_ChannelMapperFactory.cpp45
-rw-r--r--intern/audaspace/intern/AUD_ChannelMapperFactory.h57
-rw-r--r--intern/audaspace/intern/AUD_ChannelMapperReader.cpp378
-rw-r--r--intern/audaspace/intern/AUD_ChannelMapperReader.h136
-rw-r--r--intern/audaspace/intern/AUD_ConverterFactory.cpp47
-rw-r--r--intern/audaspace/intern/AUD_ConverterFactory.h57
-rw-r--r--intern/audaspace/intern/AUD_ConverterFunctions.cpp472
-rw-r--r--intern/audaspace/intern/AUD_ConverterFunctions.h128
-rw-r--r--intern/audaspace/intern/AUD_ConverterReader.cpp77
-rw-r--r--intern/audaspace/intern/AUD_ConverterReader.h73
-rw-r--r--intern/audaspace/intern/AUD_FileFactory.cpp84
-rw-r--r--intern/audaspace/intern/AUD_FileFactory.h76
-rw-r--r--intern/audaspace/intern/AUD_FileWriter.cpp131
-rw-r--r--intern/audaspace/intern/AUD_FileWriter.h82
-rw-r--r--intern/audaspace/intern/AUD_I3DDevice.h122
-rw-r--r--intern/audaspace/intern/AUD_IDevice.h120
-rw-r--r--intern/audaspace/intern/AUD_IFactory.h61
-rw-r--r--intern/audaspace/intern/AUD_ILockable.h21
-rw-r--r--intern/audaspace/intern/AUD_IWriter.h67
-rw-r--r--intern/audaspace/intern/AUD_JOSResampleFactory.cpp42
-rw-r--r--intern/audaspace/intern/AUD_JOSResampleFactory.h56
-rw-r--r--intern/audaspace/intern/AUD_JOSResampleReader.h135
-rw-r--r--intern/audaspace/intern/AUD_LinearResampleFactory.cpp42
-rw-r--r--intern/audaspace/intern/AUD_LinearResampleFactory.h56
-rw-r--r--intern/audaspace/intern/AUD_LinearResampleReader.cpp186
-rw-r--r--intern/audaspace/intern/AUD_LinearResampleReader.h86
-rw-r--r--intern/audaspace/intern/AUD_Mixer.cpp121
-rw-r--r--intern/audaspace/intern/AUD_Mixer.h114
-rw-r--r--intern/audaspace/intern/AUD_MixerFactory.cpp52
-rw-r--r--intern/audaspace/intern/AUD_MixerFactory.h79
-rw-r--r--intern/audaspace/intern/AUD_MutexLock.h24
-rw-r--r--intern/audaspace/intern/AUD_NULLDevice.cpp159
-rw-r--r--intern/audaspace/intern/AUD_NULLDevice.h84
-rw-r--r--intern/audaspace/intern/AUD_ReadDevice.cpp78
-rw-r--r--intern/audaspace/intern/AUD_ReadDevice.h88
-rw-r--r--intern/audaspace/intern/AUD_ResampleFactory.h37
-rw-r--r--intern/audaspace/intern/AUD_ResampleReader.cpp45
-rw-r--r--intern/audaspace/intern/AUD_ResampleReader.h66
-rw-r--r--intern/audaspace/intern/AUD_Sequencer.cpp177
-rw-r--r--intern/audaspace/intern/AUD_SequencerEntry.cpp319
-rw-r--r--intern/audaspace/intern/AUD_SequencerFactory.cpp123
-rw-r--r--intern/audaspace/intern/AUD_SequencerReader.cpp204
-rw-r--r--intern/audaspace/intern/AUD_SequencerReader.h99
-rw-r--r--intern/audaspace/intern/AUD_SilenceFactory.cpp41
-rw-r--r--intern/audaspace/intern/AUD_SilenceFactory.h54
-rw-r--r--intern/audaspace/intern/AUD_SilenceReader.cpp72
-rw-r--r--intern/audaspace/intern/AUD_SilenceReader.h66
-rw-r--r--intern/audaspace/intern/AUD_SinusFactory.cpp48
-rw-r--r--intern/audaspace/intern/AUD_SinusFactory.h72
-rw-r--r--intern/audaspace/intern/AUD_SinusReader.cpp83
-rw-r--r--intern/audaspace/intern/AUD_SinusReader.h78
-rw-r--r--intern/audaspace/intern/AUD_SoftwareDevice.cpp995
-rw-r--r--intern/audaspace/intern/AUD_Space.h257
-rw-r--r--intern/audaspace/intern/AUD_StreamBufferFactory.cpp76
-rw-r--r--intern/audaspace/intern/AUD_StreamBufferFactory.h71
-rw-r--r--intern/audaspace/jack/AUD_JackDevice.cpp348
-rw-r--r--intern/audaspace/jack/AUD_JackLibrary.cpp128
-rw-r--r--intern/audaspace/jack/AUD_JackLibrary.h104
-rw-r--r--intern/audaspace/sndfile/AUD_SndFileFactory.cpp52
-rw-r--r--intern/audaspace/sndfile/AUD_SndFileFactory.h76
-rw-r--r--intern/audaspace/sndfile/AUD_SndFileReader.cpp171
-rw-r--r--intern/audaspace/sndfile/AUD_SndFileReader.h128
-rw-r--r--intern/audaspace/sndfile/AUD_SndFileWriter.cpp139
-rw-r--r--intern/audaspace/sndfile/AUD_SndFileWriter.h86
-rw-r--r--intern/cycles/CMakeLists.txt86
-rw-r--r--intern/cycles/blender/addon/presets.py3
-rw-r--r--intern/cycles/blender/addon/properties.py33
-rw-r--r--intern/cycles/blender/addon/ui.py221
-rw-r--r--intern/cycles/blender/addon/version_update.py13
-rw-r--r--intern/cycles/blender/blender_camera.cpp11
-rw-r--r--intern/cycles/blender/blender_curves.cpp8
-rw-r--r--intern/cycles/blender/blender_mesh.cpp67
-rw-r--r--intern/cycles/blender/blender_object.cpp67
-rw-r--r--intern/cycles/blender/blender_python.cpp3
-rw-r--r--intern/cycles/blender/blender_session.cpp42
-rw-r--r--intern/cycles/blender/blender_session.h10
-rw-r--r--intern/cycles/blender/blender_shader.cpp72
-rw-r--r--intern/cycles/blender/blender_sync.cpp14
-rw-r--r--intern/cycles/blender/blender_sync.h2
-rw-r--r--intern/cycles/blender/blender_texture.cpp3
-rw-r--r--intern/cycles/blender/blender_texture.h2
-rw-r--r--intern/cycles/blender/blender_util.h7
-rw-r--r--intern/cycles/bvh/bvh.cpp8
-rw-r--r--intern/cycles/bvh/bvh2.cpp4
-rw-r--r--intern/cycles/bvh/bvh4.cpp28
-rw-r--r--intern/cycles/bvh/bvh_build.cpp14
-rw-r--r--intern/cycles/bvh/bvh_node.cpp11
-rw-r--r--intern/cycles/bvh/bvh_node.h1
-rw-r--r--intern/cycles/device/CMakeLists.txt2
-rw-r--r--intern/cycles/device/device.cpp2
-rw-r--r--intern/cycles/device/device.h2
-rw-r--r--intern/cycles/device/device_cpu.cpp40
-rw-r--r--intern/cycles/device/device_cuda.cpp351
-rw-r--r--intern/cycles/device/device_memory.h6
-rw-r--r--intern/cycles/device/device_multi.cpp2
-rw-r--r--intern/cycles/device/device_network.cpp7
-rw-r--r--intern/cycles/device/device_network.h8
-rw-r--r--intern/cycles/device/device_opencl.cpp29
-rw-r--r--intern/cycles/device/device_split_kernel.h3
-rw-r--r--intern/cycles/device/device_task.cpp2
-rw-r--r--intern/cycles/device/device_task.h2
-rw-r--r--intern/cycles/device/opencl/memory_manager.cpp253
-rw-r--r--intern/cycles/device/opencl/memory_manager.h105
-rw-r--r--intern/cycles/device/opencl/opencl.h70
-rw-r--r--intern/cycles/device/opencl/opencl_base.cpp209
-rw-r--r--intern/cycles/device/opencl/opencl_mega.cpp9
-rw-r--r--intern/cycles/device/opencl/opencl_split.cpp44
-rw-r--r--intern/cycles/device/opencl/opencl_util.cpp14
-rw-r--r--intern/cycles/kernel/CMakeLists.txt23
-rw-r--r--intern/cycles/kernel/bvh/bvh.h12
-rw-r--r--intern/cycles/kernel/bvh/bvh_nodes.h26
-rw-r--r--intern/cycles/kernel/bvh/bvh_shadow_all.h71
-rw-r--r--intern/cycles/kernel/bvh/bvh_traversal.h60
-rw-r--r--intern/cycles/kernel/bvh/qbvh_nodes.h8
-rw-r--r--intern/cycles/kernel/bvh/qbvh_shadow_all.h65
-rw-r--r--intern/cycles/kernel/bvh/qbvh_traversal.h54
-rw-r--r--intern/cycles/kernel/closure/bsdf.h5
-rw-r--r--intern/cycles/kernel/closure/bsdf_microfacet_multi.h23
-rw-r--r--intern/cycles/kernel/closure/bsdf_microfacet_multi_impl.h25
-rw-r--r--intern/cycles/kernel/closure/bsdf_principled_diffuse.h8
-rw-r--r--intern/cycles/kernel/closure/bssrdf.h5
-rw-r--r--intern/cycles/kernel/filter/filter_features_sse.h80
-rw-r--r--intern/cycles/kernel/filter/filter_nlm_cpu.h18
-rw-r--r--intern/cycles/kernel/filter/filter_prefilter.h114
-rw-r--r--intern/cycles/kernel/filter/filter_transform_sse.h16
-rw-r--r--intern/cycles/kernel/geom/geom.h1
-rw-r--r--intern/cycles/kernel/geom/geom_curve.h904
-rw-r--r--intern/cycles/kernel/geom/geom_curve_intersect.h934
-rw-r--r--intern/cycles/kernel/geom/geom_object.h5
-rw-r--r--intern/cycles/kernel/geom/geom_volume.h8
-rw-r--r--intern/cycles/kernel/kernel_accumulate.h349
-rw-r--r--intern/cycles/kernel/kernel_bake.h166
-rw-r--r--intern/cycles/kernel/kernel_compat_cuda.h13
-rw-r--r--intern/cycles/kernel/kernel_compat_opencl.h6
-rw-r--r--intern/cycles/kernel/kernel_debug.h56
-rw-r--r--intern/cycles/kernel/kernel_emission.h10
-rw-r--r--intern/cycles/kernel/kernel_globals.h68
-rw-r--r--intern/cycles/kernel/kernel_image_opencl.h66
-rw-r--r--intern/cycles/kernel/kernel_light.h302
-rw-r--r--intern/cycles/kernel/kernel_montecarlo.h9
-rw-r--r--intern/cycles/kernel/kernel_passes.h286
-rw-r--r--intern/cycles/kernel/kernel_path.h960
-rw-r--r--intern/cycles/kernel/kernel_path_branched.h231
-rw-r--r--intern/cycles/kernel/kernel_path_common.h13
-rw-r--r--intern/cycles/kernel/kernel_path_state.h78
-rw-r--r--intern/cycles/kernel/kernel_path_subsurface.h63
-rw-r--r--intern/cycles/kernel/kernel_path_surface.h55
-rw-r--r--intern/cycles/kernel/kernel_path_volume.h80
-rw-r--r--intern/cycles/kernel/kernel_random.h313
-rw-r--r--intern/cycles/kernel/kernel_shader.h232
-rw-r--r--intern/cycles/kernel/kernel_shadow.h185
-rw-r--r--intern/cycles/kernel/kernel_subsurface.h127
-rw-r--r--intern/cycles/kernel/kernel_textures.h181
-rw-r--r--intern/cycles/kernel/kernel_types.h185
-rw-r--r--intern/cycles/kernel/kernel_volume.h32
-rw-r--r--intern/cycles/kernel/kernel_work_stealing.h114
-rw-r--r--intern/cycles/kernel/kernels/cpu/filter_cpu.h6
-rw-r--r--intern/cycles/kernel/kernels/cpu/filter_cpu_impl.h12
-rw-r--r--intern/cycles/kernel/kernels/cpu/filter_sse41.cpp1
-rw-r--r--intern/cycles/kernel/kernels/cpu/kernel_cpu.h3
-rw-r--r--intern/cycles/kernel/kernels/cpu/kernel_cpu_impl.h17
-rw-r--r--intern/cycles/kernel/kernels/cuda/filter.cu12
-rw-r--r--intern/cycles/kernel/kernels/cuda/kernel.cu69
-rw-r--r--intern/cycles/kernel/kernels/cuda/kernel_config.h9
-rw-r--r--intern/cycles/kernel/kernels/cuda/kernel_split.cu6
-rw-r--r--intern/cycles/kernel/kernels/opencl/filter.cl14
-rw-r--r--intern/cycles/kernel/kernels/opencl/kernel.cl83
-rw-r--r--intern/cycles/kernel/kernels/opencl/kernel_data_init.cl13
-rw-r--r--intern/cycles/kernel/kernels/opencl/kernel_split.cl3
-rw-r--r--intern/cycles/kernel/kernels/opencl/kernel_split_function.h13
-rw-r--r--intern/cycles/kernel/osl/osl_closures.cpp4
-rw-r--r--intern/cycles/kernel/osl/osl_globals.h2
-rw-r--r--intern/cycles/kernel/osl/osl_services.cpp7
-rw-r--r--intern/cycles/kernel/osl/osl_shader.cpp28
-rw-r--r--intern/cycles/kernel/osl/osl_shader.h8
-rw-r--r--intern/cycles/kernel/shaders/node_principled_bsdf.osl4
-rw-r--r--intern/cycles/kernel/split/kernel_branched.h11
-rw-r--r--intern/cycles/kernel/split/kernel_buffer_update.h80
-rw-r--r--intern/cycles/kernel/split/kernel_data_init.h73
-rw-r--r--intern/cycles/kernel/split/kernel_direct_lighting.h12
-rw-r--r--intern/cycles/kernel/split/kernel_do_volume.h17
-rw-r--r--intern/cycles/kernel/split/kernel_holdout_emission_blurring_pathtermination_ao.h159
-rw-r--r--intern/cycles/kernel/split/kernel_indirect_background.h33
-rw-r--r--intern/cycles/kernel/split/kernel_indirect_subsurface.h1
-rw-r--r--intern/cycles/kernel/split/kernel_lamp_emission.h23
-rw-r--r--intern/cycles/kernel/split/kernel_next_iteration_setup.h5
-rw-r--r--intern/cycles/kernel/split/kernel_path_init.h60
-rw-r--r--intern/cycles/kernel/split/kernel_queue_enqueue.h3
-rw-r--r--intern/cycles/kernel/split/kernel_scene_intersect.h46
-rw-r--r--intern/cycles/kernel/split/kernel_shader_eval.h28
-rw-r--r--intern/cycles/kernel/split/kernel_shader_sort.h10
-rw-r--r--intern/cycles/kernel/split/kernel_shadow_blocked_ao.h7
-rw-r--r--intern/cycles/kernel/split/kernel_shadow_blocked_dl.h13
-rw-r--r--intern/cycles/kernel/split/kernel_split_common.h2
-rw-r--r--intern/cycles/kernel/split/kernel_split_data_types.h34
-rw-r--r--intern/cycles/kernel/split/kernel_subsurface_scatter.h35
-rw-r--r--intern/cycles/kernel/svm/svm_blackbody.h3
-rw-r--r--intern/cycles/kernel/svm/svm_closure.h9
-rw-r--r--intern/cycles/kernel/svm/svm_image.h190
-rw-r--r--intern/cycles/kernel/svm/svm_math_util.h107
-rw-r--r--intern/cycles/kernel/svm/svm_wavelength.h77
-rw-r--r--intern/cycles/render/bake.cpp1
-rw-r--r--intern/cycles/render/buffers.cpp16
-rw-r--r--intern/cycles/render/buffers.h4
-rw-r--r--intern/cycles/render/constant_fold.cpp8
-rw-r--r--intern/cycles/render/graph.cpp25
-rw-r--r--intern/cycles/render/graph.h3
-rw-r--r--intern/cycles/render/image.cpp228
-rw-r--r--intern/cycles/render/image.h37
-rw-r--r--intern/cycles/render/integrator.cpp22
-rw-r--r--intern/cycles/render/integrator.h3
-rw-r--r--intern/cycles/render/light.cpp9
-rw-r--r--intern/cycles/render/mesh.cpp11
-rw-r--r--intern/cycles/render/mesh_displace.cpp1
-rw-r--r--intern/cycles/render/nodes.cpp24
-rw-r--r--intern/cycles/render/nodes.h28
-rw-r--r--intern/cycles/render/object.cpp25
-rw-r--r--intern/cycles/render/object.h7
-rw-r--r--intern/cycles/render/osl.cpp35
-rw-r--r--intern/cycles/render/scene.cpp2
-rw-r--r--intern/cycles/render/scene.h7
-rw-r--r--intern/cycles/render/session.cpp15
-rw-r--r--intern/cycles/render/session.h3
-rw-r--r--intern/cycles/render/shader.cpp28
-rw-r--r--intern/cycles/render/shader.h9
-rw-r--r--intern/cycles/render/svm.cpp38
-rw-r--r--intern/cycles/render/svm.h3
-rw-r--r--intern/cycles/render/tile.cpp20
-rw-r--r--intern/cycles/render/tile.h3
-rw-r--r--intern/cycles/util/CMakeLists.txt1
-rw-r--r--intern/cycles/util/util_atomic.h10
-rw-r--r--intern/cycles/util/util_debug.cpp7
-rw-r--r--intern/cycles/util/util_debug.h7
-rw-r--r--intern/cycles/util/util_defines.h136
-rw-r--r--intern/cycles/util/util_logging.h16
-rw-r--r--intern/cycles/util/util_math.h12
-rw-r--r--intern/cycles/util/util_math_float3.h26
-rw-r--r--intern/cycles/util/util_math_float4.h109
-rw-r--r--intern/cycles/util/util_math_matrix.h56
-rw-r--r--intern/cycles/util/util_optimization.h55
-rw-r--r--intern/cycles/util/util_path.cpp213
-rw-r--r--intern/cycles/util/util_progress.h16
-rw-r--r--intern/cycles/util/util_simd.h184
-rw-r--r--intern/cycles/util/util_sseb.h3
-rw-r--r--intern/cycles/util/util_ssef.h3
-rw-r--r--intern/cycles/util/util_ssei.h9
-rw-r--r--intern/cycles/util/util_stats.h2
-rw-r--r--intern/cycles/util/util_task.cpp4
-rw-r--r--intern/cycles/util/util_time.h7
-rw-r--r--intern/cycles/util/util_types.h131
-rw-r--r--intern/elbeem/intern/isosurface.cpp33
-rw-r--r--intern/elbeem/intern/solver_util.cpp4
-rw-r--r--intern/gawain/CMakeLists.txt48
-rw-r--r--intern/gawain/gawain/gwn_attr_binding.h (renamed from intern/gawain/gawain/attrib_binding.h)4
-rw-r--r--intern/gawain/gawain/gwn_attr_binding_private.h (renamed from intern/gawain/gawain/attrib_binding_private.h)4
-rw-r--r--intern/gawain/gawain/gwn_batch.h (renamed from intern/gawain/gawain/batch.h)42
-rw-r--r--intern/gawain/gawain/gwn_buffer_id.h (renamed from intern/gawain/gawain/buffer_id.h)2
-rw-r--r--intern/gawain/gawain/gwn_common.h (renamed from intern/gawain/gawain/common.h)7
-rw-r--r--intern/gawain/gawain/gwn_element.h (renamed from intern/gawain/gawain/element.h)6
-rw-r--r--intern/gawain/gawain/gwn_imm_util.h (renamed from intern/gawain/gawain/imm_util.h)0
-rw-r--r--intern/gawain/gawain/gwn_immediate.h (renamed from intern/gawain/gawain/immediate.h)8
-rw-r--r--intern/gawain/gawain/gwn_primitive.h (renamed from intern/gawain/gawain/primitive.h)2
-rw-r--r--intern/gawain/gawain/gwn_primitive_private.h (renamed from intern/gawain/gawain/primitive_private.h)0
-rw-r--r--intern/gawain/gawain/gwn_shader_interface.h74
-rw-r--r--intern/gawain/gawain/gwn_vertex_buffer.h (renamed from intern/gawain/gawain/vertex_buffer.h)34
-rw-r--r--intern/gawain/gawain/gwn_vertex_format.h (renamed from intern/gawain/gawain/vertex_format.h)14
-rw-r--r--intern/gawain/gawain/gwn_vertex_format_private.h (renamed from intern/gawain/gawain/vertex_format_private.h)0
-rw-r--r--intern/gawain/gawain/shader_interface.h53
-rw-r--r--intern/gawain/src/gwn_attr_binding.c (renamed from intern/gawain/src/attrib_binding.c)4
-rw-r--r--intern/gawain/src/gwn_batch.c (renamed from intern/gawain/src/batch.c)75
-rw-r--r--intern/gawain/src/gwn_buffer_id.cpp (renamed from intern/gawain/src/buffer_id.cpp)2
-rw-r--r--intern/gawain/src/gwn_element.c (renamed from intern/gawain/src/element.c)4
-rw-r--r--intern/gawain/src/gwn_imm_util.c (renamed from intern/gawain/src/imm_util.c)4
-rw-r--r--intern/gawain/src/gwn_immediate.c (renamed from intern/gawain/src/immediate.c)12
-rw-r--r--intern/gawain/src/gwn_primitive.c (renamed from intern/gawain/src/primitive.c)4
-rw-r--r--intern/gawain/src/gwn_shader_interface.c311
-rw-r--r--intern/gawain/src/gwn_vertex_buffer.c (renamed from intern/gawain/src/vertex_buffer.c)45
-rw-r--r--intern/gawain/src/gwn_vertex_format.c (renamed from intern/gawain/src/vertex_format.c)14
-rw-r--r--intern/gawain/src/shader_interface.c311
-rw-r--r--intern/ghost/CMakeLists.txt4
-rw-r--r--intern/ghost/intern/GHOST_ContextGLX.cpp2
-rw-r--r--intern/ghost/intern/GHOST_ContextGLX.h2
-rw-r--r--intern/ghost/intern/GHOST_ContextWGL.cpp117
-rw-r--r--intern/ghost/intern/GHOST_ContextWGL.h14
-rw-r--r--intern/ghost/intern/GHOST_EventPrinter.cpp10
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.h5
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.mm93
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.cpp3
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp33
-rw-r--r--intern/ghost/intern/GHOST_WindowCocoa.h2
-rw-r--r--intern/ghost/intern/GHOST_WindowCocoa.mm140
-rw-r--r--intern/ghost/intern/GHOST_WindowWin32.cpp121
-rw-r--r--intern/ghost/intern/GHOST_WindowX11.cpp6
-rw-r--r--intern/guardedalloc/MEM_guardedalloc.h2
-rw-r--r--intern/guardedalloc/intern/mallocn_lockfree_impl.c7
-rw-r--r--intern/itasc/FixedObject.hpp2
-rw-r--r--intern/itasc/MovingFrame.cpp4
-rw-r--r--intern/itasc/MovingFrame.hpp10
-rw-r--r--intern/itasc/Scene.cpp4
-rw-r--r--intern/itasc/Scene.hpp2
-rw-r--r--intern/itasc/UncontrolledObject.hpp5
-rw-r--r--intern/itasc/WorldObject.hpp2
-rw-r--r--intern/itasc/kdl/tree.hpp2
-rw-r--r--intern/libmv/intern/track_region.cc2
-rw-r--r--intern/mikktspace/mikktspace.c271
-rw-r--r--intern/opencolorio/gpu_shader_display_transform.glsl14
-rw-r--r--intern/opencolorio/ocio_impl_glsl.cc50
-rw-r--r--intern/opensubdiv/opensubdiv_capi.cc64
-rw-r--r--intern/opensubdiv/opensubdiv_gpu_capi.cc2
-rw-r--r--intern/openvdb/intern/openvdb_writer.cc4
-rw-r--r--intern/string/intern/STR_String.cpp3
-rw-r--r--make.bat135
-rw-r--r--release/datafiles/splash.pngbin283527 -> 179886 bytes
-rw-r--r--release/datafiles/splash_2x.pngbin988186 -> 597581 bytes
-rw-r--r--release/scripts/freestyle/styles/apriori_and_causal_density.py4
-rw-r--r--release/scripts/freestyle/styles/cartoon.py2
-rw-r--r--release/scripts/freestyle/styles/external_contour_sketchy.py6
-rw-r--r--release/scripts/freestyle/styles/haloing.py8
-rw-r--r--release/scripts/freestyle/styles/invisible_lines.py2
-rw-r--r--release/scripts/freestyle/styles/long_anisotropically_dense.py8
-rw-r--r--release/scripts/freestyle/styles/multiple_parameterization.py2
-rw-r--r--release/scripts/freestyle/styles/nature.py2
-rw-r--r--release/scripts/freestyle/styles/near_lines.py2
-rw-r--r--release/scripts/freestyle/styles/qi1.py2
-rw-r--r--release/scripts/freestyle/styles/qi2.py2
-rw-r--r--release/scripts/freestyle/styles/sequentialsplit_sketchy.py2
-rw-r--r--release/scripts/freestyle/styles/sketchy_multiple_parameterization.py2
-rw-r--r--release/scripts/freestyle/styles/uniformpruning_zsort.py2
-rw-r--r--release/scripts/modules/bl_i18n_utils/bl_extract_messages.py3
-rw-r--r--release/scripts/modules/bl_i18n_utils/utils_spell_check.py4
-rw-r--r--release/scripts/modules/bl_previews_utils/bl_previews_render.py13
-rw-r--r--release/scripts/modules/bpy/utils/__init__.py125
-rw-r--r--release/scripts/modules/bpy_extras/anim_utils.py165
-rw-r--r--release/scripts/modules/bpy_extras/node_utils.py23
-rw-r--r--release/scripts/modules/bpy_types.py69
-rw-r--r--release/scripts/modules/keyingsets_utils.py2
-rw-r--r--release/scripts/modules/nodeitems_utils.py22
-rw-r--r--release/scripts/modules/rna_info.py91
-rw-r--r--release/scripts/modules/rna_keymap_ui.py1
-rw-r--r--release/scripts/presets/cycles/integrator/direct_light.py2
-rw-r--r--release/scripts/presets/cycles/integrator/full_global_illumination.py2
-rw-r--r--release/scripts/presets/cycles/integrator/limited_global_illumination.py2
-rw-r--r--release/scripts/presets/cycles/sampling/final.py22
-rw-r--r--release/scripts/presets/cycles/sampling/preview.py22
-rw-r--r--release/scripts/presets/ffmpeg/DVD_(note_colon__this_changes_render_resolution).py (renamed from release/scripts/presets/ffmpeg/DVD (note_colon_ this changes render resolution).py)0
-rw-r--r--release/scripts/presets/ffmpeg/h264_in_MP4.py (renamed from release/scripts/presets/ffmpeg/h264 in MP4.py)0
-rw-r--r--release/scripts/presets/ffmpeg/h264_in_Matroska.py (renamed from release/scripts/presets/ffmpeg/h264 in Matroska.py)0
-rw-r--r--release/scripts/presets/ffmpeg/h264_in_Matroska_for_scrubbing.py (renamed from release/scripts/presets/ffmpeg/h264 in Matroska for scrubbing.py)0
-rw-r--r--release/scripts/presets/interface_theme/dark_blue_gradient.xml2
-rw-r--r--release/scripts/presets/interface_theme/elsyiun.xml2
-rw-r--r--release/scripts/presets/interface_theme/flatty_light.xml69
-rw-r--r--release/scripts/presets/interface_theme/science_lab.xml2
-rw-r--r--release/scripts/startup/bl_operators/anim.py49
-rw-r--r--release/scripts/startup/bl_operators/clip.py11
-rw-r--r--release/scripts/startup/bl_operators/object_align.py5
-rw-r--r--release/scripts/startup/bl_operators/uvcalc_smart_project.py4
-rw-r--r--release/scripts/startup/bl_ui/properties_animviz.py10
-rw-r--r--release/scripts/startup/bl_ui/properties_constraint.py4
-rw-r--r--release/scripts/startup/bl_ui/properties_data_armature.py10
-rw-r--r--release/scripts/startup/bl_ui/properties_data_lamp.py51
-rw-r--r--release/scripts/startup/bl_ui/properties_data_lightprobe.py28
-rw-r--r--release/scripts/startup/bl_ui/properties_data_modifier.py32
-rw-r--r--release/scripts/startup/bl_ui/properties_freestyle.py4
-rw-r--r--release/scripts/startup/bl_ui/properties_game.py4
-rw-r--r--release/scripts/startup/bl_ui/properties_grease_pencil_common.py52
-rw-r--r--release/scripts/startup/bl_ui/properties_material.py45
-rw-r--r--release/scripts/startup/bl_ui/properties_object.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_paint_common.py4
-rw-r--r--release/scripts/startup/bl_ui/properties_particle.py6
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_common.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py10
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_softbody.py5
-rw-r--r--release/scripts/startup/bl_ui/properties_render.py276
-rw-r--r--release/scripts/startup/bl_ui/properties_render_layer.py254
-rw-r--r--release/scripts/startup/bl_ui/properties_world.py13
-rw-r--r--release/scripts/startup/bl_ui/space_clip.py6
-rw-r--r--release/scripts/startup/bl_ui/space_image.py8
-rw-r--r--release/scripts/startup/bl_ui/space_node.py10
-rw-r--r--release/scripts/startup/bl_ui/space_outliner.py2
-rw-r--r--release/scripts/startup/bl_ui/space_sequencer.py35
-rw-r--r--release/scripts/startup/bl_ui/space_userpref.py30
-rw-r--r--release/scripts/startup/bl_ui/space_view3d.py21
-rw-r--r--release/scripts/startup/bl_ui/space_view3d_toolbar.py140
-rw-r--r--release/scripts/startup/keyingsets_builtins.py2
-rw-r--r--release/scripts/startup/nodeitems_builtins.py49
-rw-r--r--release/scripts/templates_py/custom_nodes.py81
-rw-r--r--release/scripts/templates_py/gamelogic.py2
-rw-r--r--release/scripts/templates_py/manipulator_custom_geometry.py158
-rw-r--r--release/scripts/templates_py/manipulator_operator.py13
-rw-r--r--release/scripts/templates_py/manipulator_operator_target.py7
-rw-r--r--release/scripts/templates_py/manipulator_simple.py7
-rw-r--r--release/text/copyright.txt2
-rw-r--r--release/windows/blendthumb/CMakeLists.txt (renamed from source/blender/quicktime/CMakeLists.txt)52
-rw-r--r--release/windows/blendthumb/src/BlendThumb.def5
-rw-r--r--release/windows/blendthumb/src/BlendThumb.rc26
-rw-r--r--release/windows/blendthumb/src/BlenderThumb.cpp324
-rw-r--r--release/windows/blendthumb/src/Dll.cpp277
-rw-r--r--source/blender/CMakeLists.txt4
-rw-r--r--source/blender/alembic/intern/abc_camera.cc5
-rw-r--r--source/blender/alembic/intern/abc_camera.h3
-rw-r--r--source/blender/alembic/intern/abc_curves.cc5
-rw-r--r--source/blender/alembic/intern/abc_curves.h3
-rw-r--r--source/blender/alembic/intern/abc_customdata.cc48
-rw-r--r--source/blender/alembic/intern/abc_customdata.h3
-rw-r--r--source/blender/alembic/intern/abc_exporter.cc31
-rw-r--r--source/blender/alembic/intern/abc_exporter.h5
-rw-r--r--source/blender/alembic/intern/abc_hair.cc7
-rw-r--r--source/blender/alembic/intern/abc_hair.h3
-rw-r--r--source/blender/alembic/intern/abc_mesh.cc77
-rw-r--r--source/blender/alembic/intern/abc_mesh.h8
-rw-r--r--source/blender/alembic/intern/abc_nurbs.cc5
-rw-r--r--source/blender/alembic/intern/abc_nurbs.h3
-rw-r--r--source/blender/alembic/intern/abc_object.cc60
-rw-r--r--source/blender/alembic/intern/abc_object.h14
-rw-r--r--source/blender/alembic/intern/abc_points.cc6
-rw-r--r--source/blender/alembic/intern/abc_points.h3
-rw-r--r--source/blender/alembic/intern/abc_transform.cc5
-rw-r--r--source/blender/alembic/intern/abc_transform.h3
-rw-r--r--source/blender/alembic/intern/abc_util.cc6
-rw-r--r--source/blender/alembic/intern/alembic_capi.cc16
-rw-r--r--source/blender/blenfont/BLF_api.h2
-rw-r--r--source/blender/blenfont/intern/blf.c7
-rw-r--r--source/blender/blenkernel/BKE_DerivedMesh.h64
-rw-r--r--source/blender/blenkernel/BKE_action.h6
-rw-r--r--source/blender/blenkernel/BKE_anim.h9
-rw-r--r--source/blender/blenkernel/BKE_animsys.h10
-rw-r--r--source/blender/blenkernel/BKE_armature.h34
-rw-r--r--source/blender/blenkernel/BKE_blender.h1
-rw-r--r--source/blender/blenkernel/BKE_brush.h13
-rw-r--r--source/blender/blenkernel/BKE_cachefile.h2
-rw-r--r--source/blender/blenkernel/BKE_camera.h1
-rw-r--r--source/blender/blenkernel/BKE_cloth.h3
-rw-r--r--source/blender/blenkernel/BKE_constraint.h11
-rw-r--r--source/blender/blenkernel/BKE_context.h5
-rw-r--r--source/blender/blenkernel/BKE_crazyspace.h9
-rw-r--r--source/blender/blenkernel/BKE_curve.h24
-rw-r--r--source/blender/blenkernel/BKE_data_transfer.h8
-rw-r--r--source/blender/blenkernel/BKE_displist.h29
-rw-r--r--source/blender/blenkernel/BKE_dynamicpaint.h7
-rw-r--r--source/blender/blenkernel/BKE_editmesh.h4
-rw-r--r--source/blender/blenkernel/BKE_editmesh_tangent.h2
-rw-r--r--source/blender/blenkernel/BKE_effect.h8
-rw-r--r--source/blender/blenkernel/BKE_fluidsim.h3
-rw-r--r--source/blender/blenkernel/BKE_font.h1
-rw-r--r--source/blender/blenkernel/BKE_freestyle.h2
-rw-r--r--source/blender/blenkernel/BKE_global.h5
-rw-r--r--source/blender/blenkernel/BKE_gpencil.h1
-rw-r--r--source/blender/blenkernel/BKE_group.h3
-rw-r--r--source/blender/blenkernel/BKE_idprop.h4
-rw-r--r--source/blender/blenkernel/BKE_image.h2
-rw-r--r--source/blender/blenkernel/BKE_key.h1
-rw-r--r--source/blender/blenkernel/BKE_lamp.h1
-rw-r--r--source/blender/blenkernel/BKE_lattice.h14
-rw-r--r--source/blender/blenkernel/BKE_layer.h23
-rw-r--r--source/blender/blenkernel/BKE_library.h70
-rw-r--r--source/blender/blenkernel/BKE_library_query.h2
-rw-r--r--source/blender/blenkernel/BKE_library_remap.h5
-rw-r--r--source/blender/blenkernel/BKE_lightprobe.h3
-rw-r--r--source/blender/blenkernel/BKE_linestyle.h15
-rw-r--r--source/blender/blenkernel/BKE_mask.h8
-rw-r--r--source/blender/blenkernel/BKE_material.h7
-rw-r--r--source/blender/blenkernel/BKE_mball.h5
-rw-r--r--source/blender/blenkernel/BKE_mball_tessellate.h2
-rw-r--r--source/blender/blenkernel/BKE_mesh.h20
-rw-r--r--source/blender/blenkernel/BKE_mesh_tangent.h6
-rw-r--r--source/blender/blenkernel/BKE_modifier.h46
-rw-r--r--source/blender/blenkernel/BKE_movieclip.h1
-rw-r--r--source/blender/blenkernel/BKE_multires.h13
-rw-r--r--source/blender/blenkernel/BKE_node.h16
-rw-r--r--source/blender/blenkernel/BKE_object.h67
-rw-r--r--source/blender/blenkernel/BKE_paint.h48
-rw-r--r--source/blender/blenkernel/BKE_particle.h25
-rw-r--r--source/blender/blenkernel/BKE_pbvh.h23
-rw-r--r--source/blender/blenkernel/BKE_pointcache.h2
-rw-r--r--source/blender/blenkernel/BKE_rigidbody.h19
-rw-r--r--source/blender/blenkernel/BKE_sca.h14
-rw-r--r--source/blender/blenkernel/BKE_scene.h17
-rw-r--r--source/blender/blenkernel/BKE_screen.h3
-rw-r--r--source/blender/blenkernel/BKE_sequencer.h9
-rw-r--r--source/blender/blenkernel/BKE_smoke.h4
-rw-r--r--source/blender/blenkernel/BKE_softbody.h3
-rw-r--r--source/blender/blenkernel/BKE_sound.h10
-rw-r--r--source/blender/blenkernel/BKE_speaker.h1
-rw-r--r--source/blender/blenkernel/BKE_text.h1
-rw-r--r--source/blender/blenkernel/BKE_texture.h7
-rw-r--r--source/blender/blenkernel/BKE_tracking.h3
-rw-r--r--source/blender/blenkernel/BKE_world.h7
-rw-r--r--source/blender/blenkernel/CMakeLists.txt16
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c221
-rw-r--r--source/blender/blenkernel/intern/action.c100
-rw-r--r--source/blender/blenkernel/intern/anim.c10
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c32
-rw-r--r--source/blender/blenkernel/intern/appdir.c21
-rw-r--r--source/blender/blenkernel/intern/armature.c98
-rw-r--r--source/blender/blenkernel/intern/armature_update.c63
-rw-r--r--source/blender/blenkernel/intern/blender.c13
-rw-r--r--source/blender/blenkernel/intern/blender_copybuffer.c5
-rw-r--r--source/blender/blenkernel/intern/blendfile.c35
-rw-r--r--source/blender/blenkernel/intern/boids.c1
-rw-r--r--source/blender/blenkernel/intern/brush.c72
-rw-r--r--source/blender/blenkernel/intern/bvhutils.c13
-rw-r--r--source/blender/blenkernel/intern/cachefile.c30
-rw-r--r--source/blender/blenkernel/intern/camera.c25
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c35
-rw-r--r--source/blender/blenkernel/intern/cloth.c9
-rw-r--r--source/blender/blenkernel/intern/collection.c18
-rw-r--r--source/blender/blenkernel/intern/colortools.c2
-rw-r--r--source/blender/blenkernel/intern/constraint.c64
-rw-r--r--source/blender/blenkernel/intern/context.c28
-rw-r--r--source/blender/blenkernel/intern/crazyspace.c26
-rw-r--r--source/blender/blenkernel/intern/curve.c143
-rw-r--r--source/blender/blenkernel/intern/customdata.c18
-rw-r--r--source/blender/blenkernel/intern/data_transfer.c21
-rw-r--r--source/blender/blenkernel/intern/deform.c13
-rw-r--r--source/blender/blenkernel/intern/displist.c103
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c74
-rw-r--r--source/blender/blenkernel/intern/editderivedmesh.c27
-rw-r--r--source/blender/blenkernel/intern/editmesh_tangent.c61
-rw-r--r--source/blender/blenkernel/intern/effect.c54
-rw-r--r--source/blender/blenkernel/intern/fluidsim.c6
-rw-r--r--source/blender/blenkernel/intern/font.c19
-rw-r--r--source/blender/blenkernel/intern/freestyle.c18
-rw-r--r--source/blender/blenkernel/intern/gpencil.c81
-rw-r--r--source/blender/blenkernel/intern/group.c35
-rw-r--r--source/blender/blenkernel/intern/icons.c2
-rw-r--r--source/blender/blenkernel/intern/idprop.c70
-rw-r--r--source/blender/blenkernel/intern/image.c99
-rw-r--r--source/blender/blenkernel/intern/image_gen.c2
-rw-r--r--source/blender/blenkernel/intern/key.c56
-rw-r--r--source/blender/blenkernel/intern/lamp.c66
-rw-r--r--source/blender/blenkernel/intern/lattice.c72
-rw-r--r--source/blender/blenkernel/intern/layer.c127
-rw-r--r--source/blender/blenkernel/intern/library.c522
-rw-r--r--source/blender/blenkernel/intern/library_query.c3
-rw-r--r--source/blender/blenkernel/intern/library_remap.c132
-rw-r--r--source/blender/blenkernel/intern/lightprobe.c28
-rw-r--r--source/blender/blenkernel/intern/linestyle.c127
-rw-r--r--source/blender/blenkernel/intern/mask.c123
-rw-r--r--source/blender/blenkernel/intern/mask_evaluate.c111
-rw-r--r--source/blender/blenkernel/intern/material.c91
-rw-r--r--source/blender/blenkernel/intern/mball.c60
-rw-r--r--source/blender/blenkernel/intern/mball_tessellate.c8
-rw-r--r--source/blender/blenkernel/intern/mesh.c346
-rw-r--r--source/blender/blenkernel/intern/mesh_evaluate.c97
-rw-r--r--source/blender/blenkernel/intern/mesh_remap.c17
-rw-r--r--source/blender/blenkernel/intern/mesh_tangent.c74
-rw-r--r--source/blender/blenkernel/intern/modifier.c51
-rw-r--r--source/blender/blenkernel/intern/movieclip.c38
-rw-r--r--source/blender/blenkernel/intern/multires.c38
-rw-r--r--source/blender/blenkernel/intern/nla.c2
-rw-r--r--source/blender/blenkernel/intern/node.c366
-rw-r--r--source/blender/blenkernel/intern/object.c247
-rw-r--r--source/blender/blenkernel/intern/object_deform.c4
-rw-r--r--source/blender/blenkernel/intern/object_dupli.c57
-rw-r--r--source/blender/blenkernel/intern/object_update.c52
-rw-r--r--source/blender/blenkernel/intern/packedFile.c6
-rw-r--r--source/blender/blenkernel/intern/paint.c116
-rw-r--r--source/blender/blenkernel/intern/particle.c130
-rw-r--r--source/blender/blenkernel/intern/particle_child.c2
-rw-r--r--source/blender/blenkernel/intern/particle_distribute.c80
-rw-r--r--source/blender/blenkernel/intern/particle_system.c223
-rw-r--r--source/blender/blenkernel/intern/pbvh.c296
-rw-r--r--source/blender/blenkernel/intern/pbvh_bmesh.c125
-rw-r--r--source/blender/blenkernel/intern/pbvh_intern.h20
-rw-r--r--source/blender/blenkernel/intern/pointcache.c17
-rw-r--r--source/blender/blenkernel/intern/rigidbody.c125
-rw-r--r--source/blender/blenkernel/intern/sca.c32
-rw-r--r--source/blender/blenkernel/intern/scene.c612
-rw-r--r--source/blender/blenkernel/intern/screen.c32
-rw-r--r--source/blender/blenkernel/intern/seqeffects.c96
-rw-r--r--source/blender/blenkernel/intern/sequencer.c62
-rw-r--r--source/blender/blenkernel/intern/shrinkwrap.c12
-rw-r--r--source/blender/blenkernel/intern/smoke.c36
-rw-r--r--source/blender/blenkernel/intern/softbody.c54
-rw-r--r--source/blender/blenkernel/intern/sound.c68
-rw-r--r--source/blender/blenkernel/intern/speaker.c28
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c80
-rw-r--r--source/blender/blenkernel/intern/text.c72
-rw-r--r--source/blender/blenkernel/intern/texture.c104
-rw-r--r--source/blender/blenkernel/intern/tracking.c44
-rw-r--r--source/blender/blenkernel/intern/tracking_auto.c109
-rw-r--r--source/blender/blenkernel/intern/tracking_util.c148
-rw-r--r--source/blender/blenkernel/intern/unit.c11
-rw-r--r--source/blender/blenkernel/intern/workspace.c8
-rw-r--r--source/blender/blenkernel/intern/world.c65
-rw-r--r--source/blender/blenkernel/intern/writeavi.c14
-rw-r--r--source/blender/blenkernel/intern/writeffmpeg.c5
-rw-r--r--source/blender/blenkernel/tracking_private.h1
-rw-r--r--source/blender/blenlib/BLI_array.h5
-rw-r--r--source/blender/blenlib/BLI_compiler_compat.h7
-rw-r--r--source/blender/blenlib/BLI_dial.h4
-rw-r--r--source/blender/blenlib/BLI_fnmatch.h6
-rw-r--r--source/blender/blenlib/BLI_ghash.h4
-rw-r--r--source/blender/blenlib/BLI_kdtree.h4
-rw-r--r--source/blender/blenlib/BLI_math_base.h32
-rw-r--r--source/blender/blenlib/BLI_math_geom.h46
-rw-r--r--source/blender/blenlib/BLI_math_inline.h7
-rw-r--r--source/blender/blenlib/BLI_math_matrix.h64
-rw-r--r--source/blender/blenlib/BLI_math_vector.h2
-rw-r--r--source/blender/blenlib/BLI_memiter.h73
-rw-r--r--source/blender/blenlib/BLI_polyfill2d_beautify.h8
-rw-r--r--source/blender/blenlib/BLI_rand.h11
-rw-r--r--source/blender/blenlib/BLI_rect.h2
-rw-r--r--source/blender/blenlib/BLI_string_utils.h19
-rw-r--r--source/blender/blenlib/BLI_utildefines.h25
-rw-r--r--source/blender/blenlib/BLI_utildefines_iter.h52
-rw-r--r--source/blender/blenlib/BLI_utildefines_stack.h (renamed from source/blender/blenlib/BLI_stackdefines.h)8
-rw-r--r--source/blender/blenlib/BLI_utildefines_variadic.h50
-rw-r--r--source/blender/blenlib/BLI_vfontdata.h2
-rw-r--r--source/blender/blenlib/CMakeLists.txt6
-rw-r--r--source/blender/blenlib/intern/BLI_dial.c4
-rw-r--r--source/blender/blenlib/intern/BLI_ghash.c34
-rw-r--r--source/blender/blenlib/intern/BLI_kdtree.c120
-rw-r--r--source/blender/blenlib/intern/BLI_memiter.c357
-rw-r--r--source/blender/blenlib/intern/freetypefont.c30
-rw-r--r--source/blender/blenlib/intern/math_base_inline.c81
-rw-r--r--source/blender/blenlib/intern/math_geom.c230
-rw-r--r--source/blender/blenlib/intern/math_matrix.c47
-rw-r--r--source/blender/blenlib/intern/math_vector.c25
-rw-r--r--source/blender/blenlib/intern/noise.c10
-rw-r--r--source/blender/blenlib/intern/polyfill2d.c12
-rw-r--r--source/blender/blenlib/intern/polyfill2d_beautify.c56
-rw-r--r--source/blender/blenlib/intern/rand.c90
-rw-r--r--source/blender/blenlib/intern/rct.c38
-rw-r--r--source/blender/blenlib/intern/storage.c6
-rw-r--r--source/blender/blenlib/intern/string_utils.c88
-rw-r--r--source/blender/blenlib/intern/timecode.c10
-rw-r--r--source/blender/blenloader/CMakeLists.txt4
-rw-r--r--source/blender/blenloader/intern/readfile.c31
-rw-r--r--source/blender/blenloader/intern/versioning_270.c56
-rw-r--r--source/blender/blenloader/intern/versioning_280.c110
-rw-r--r--source/blender/blenloader/intern/versioning_defaults.c27
-rw-r--r--source/blender/blenloader/intern/versioning_legacy.c10
-rw-r--r--source/blender/blenloader/intern/writefile.c10
-rw-r--r--source/blender/blentranslation/CMakeLists.txt4
-rw-r--r--source/blender/blentranslation/msgfmt/msgfmt.c9
-rw-r--r--source/blender/bmesh/intern/bmesh_core.c5
-rw-r--r--source/blender/bmesh/intern/bmesh_edgeloop.c27
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh.c2
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh_conv.c190
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh_validate.c2
-rw-r--r--source/blender/bmesh/intern/bmesh_opdefines.c4
-rw-r--r--source/blender/bmesh/intern/bmesh_polygon.c146
-rw-r--r--source/blender/bmesh/intern/bmesh_polygon.h1
-rw-r--r--source/blender/bmesh/intern/bmesh_polygon_edgenet.c71
-rw-r--r--source/blender/bmesh/intern/bmesh_private.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_queries.c66
-rw-r--r--source/blender/bmesh/intern/bmesh_queries.h5
-rw-r--r--source/blender/bmesh/operators/bmo_bisect_plane.c2
-rw-r--r--source/blender/bmesh/operators/bmo_connect.c2
-rw-r--r--source/blender/bmesh/operators/bmo_create.c18
-rw-r--r--source/blender/bmesh/operators/bmo_offset_edgeloops.c2
-rw-r--r--source/blender/bmesh/operators/bmo_primitive.c18
-rw-r--r--source/blender/bmesh/operators/bmo_removedoubles.c101
-rw-r--r--source/blender/bmesh/operators/bmo_subdivide_edgering.c2
-rw-r--r--source/blender/bmesh/tools/bmesh_beautify.c9
-rw-r--r--source/blender/bmesh/tools/bmesh_bevel.c233
-rw-r--r--source/blender/bmesh/tools/bmesh_bisect_plane.c2
-rw-r--r--source/blender/bmesh/tools/bmesh_decimate_collapse.c2
-rw-r--r--source/blender/bmesh/tools/bmesh_intersect.c2
-rw-r--r--source/blender/bmesh/tools/bmesh_path.c47
-rw-r--r--source/blender/bmesh/tools/bmesh_path_region.c30
-rw-r--r--source/blender/collada/AnimationExporter.cpp47
-rw-r--r--source/blender/collada/AnimationExporter.h5
-rw-r--r--source/blender/collada/ArmatureExporter.cpp14
-rw-r--r--source/blender/collada/ArmatureExporter.h4
-rw-r--r--source/blender/collada/ControllerExporter.cpp11
-rw-r--r--source/blender/collada/ControllerExporter.h4
-rw-r--r--source/blender/collada/DocumentExporter.cpp19
-rw-r--r--source/blender/collada/DocumentExporter.h2
-rw-r--r--source/blender/collada/DocumentImporter.cpp6
-rw-r--r--source/blender/collada/GeometryExporter.cpp11
-rw-r--r--source/blender/collada/GeometryExporter.h5
-rw-r--r--source/blender/collada/SceneExporter.cpp16
-rw-r--r--source/blender/collada/SceneExporter.h6
-rw-r--r--source/blender/collada/TransformWriter.cpp3
-rw-r--r--source/blender/collada/TransformWriter.h3
-rw-r--r--source/blender/collada/collada.cpp5
-rw-r--r--source/blender/collada/collada.h4
-rw-r--r--source/blender/collada/collada_utils.cpp13
-rw-r--r--source/blender/collada/collada_utils.h4
-rw-r--r--source/blender/compositor/intern/COM_Debug.cpp4
-rw-r--r--source/blender/compositor/intern/COM_compositor.cpp16
-rw-r--r--source/blender/compositor/nodes/COM_CompositorNode.cpp1
-rw-r--r--source/blender/compositor/nodes/COM_RenderLayersNode.cpp173
-rw-r--r--source/blender/compositor/nodes/COM_RenderLayersNode.h12
-rw-r--r--source/blender/compositor/nodes/COM_ScaleNode.cpp19
-rw-r--r--source/blender/compositor/operations/COM_CompositorOperation.cpp5
-rw-r--r--source/blender/compositor/operations/COM_CompositorOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_GlareSimpleStarOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp77
-rw-r--r--source/blender/compositor/operations/COM_MovieClipAttributeOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersProg.cpp6
-rw-r--r--source/blender/compositor/operations/COM_ScaleOperation.cpp78
-rw-r--r--source/blender/compositor/operations/COM_ScaleOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp6
-rw-r--r--source/blender/datatoc/datatoc.c5
-rw-r--r--source/blender/depsgraph/DEG_depsgraph.h44
-rw-r--r--source/blender/depsgraph/DEG_depsgraph_build.h1
-rw-r--r--source/blender/depsgraph/DEG_depsgraph_query.h10
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder.cc10
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.cc441
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.h40
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes_layer.cc6
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc157
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc3
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.cc613
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.h4
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations_layer.cc2
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc33
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc4
-rw-r--r--source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc12
-rw-r--r--source/blender/depsgraph/intern/depsgraph.cc66
-rw-r--r--source/blender/depsgraph/intern/depsgraph.h10
-rw-r--r--source/blender/depsgraph/intern/depsgraph_build.cc30
-rw-r--r--source/blender/depsgraph/intern/depsgraph_debug.cc2
-rw-r--r--source/blender/depsgraph/intern/depsgraph_eval.cc15
-rw-r--r--source/blender/depsgraph/intern/depsgraph_intern.h22
-rw-r--r--source/blender/depsgraph/intern/depsgraph_query.cc85
-rw-r--r--source/blender/depsgraph/intern/depsgraph_tag.cc440
-rw-r--r--source/blender/depsgraph/intern/depsgraph_type_defines.cc33
-rw-r--r--source/blender/depsgraph/intern/depsgraph_types.h46
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval.cc4
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc461
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h35
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_flush.cc87
-rw-r--r--source/blender/depsgraph/intern/nodes/deg_node.cc73
-rw-r--r--source/blender/depsgraph/intern/nodes/deg_node.h2
-rw-r--r--source/blender/depsgraph/intern/nodes/deg_node_component.cc7
-rw-r--r--source/blender/depsgraph/intern/nodes/deg_node_component.h8
-rw-r--r--source/blender/depsgraph/intern/nodes/deg_node_operation.cc3
-rw-r--r--source/blender/depsgraph/intern/nodes/deg_node_operation.h10
-rw-r--r--source/blender/draw/CMakeLists.txt27
-rw-r--r--source/blender/draw/DRW_engine.h5
-rw-r--r--source/blender/draw/engines/basic/basic_engine.c38
-rw-r--r--source/blender/draw/engines/clay/clay_engine.c54
-rw-r--r--source/blender/draw/engines/eevee/eevee_data.c19
-rw-r--r--source/blender/draw/engines/eevee/eevee_effects.c1116
-rw-r--r--source/blender/draw/engines/eevee/eevee_engine.c251
-rw-r--r--source/blender/draw/engines/eevee/eevee_lightprobes.c597
-rw-r--r--source/blender/draw/engines/eevee/eevee_lights.c771
-rw-r--r--source/blender/draw/engines/eevee/eevee_lut.h11013
-rw-r--r--source/blender/draw/engines/eevee/eevee_materials.c1027
-rw-r--r--source/blender/draw/engines/eevee/eevee_private.h340
-rw-r--r--source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl428
-rw-r--r--source/blender/draw/engines/eevee/shaders/background_vert.glsl3
-rw-r--r--source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl476
-rw-r--r--source/blender/draw/engines/eevee/shaders/bsdf_direct_lib.glsl106
-rw-r--r--source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl38
-rw-r--r--source/blender/draw/engines/eevee/shaders/btdf_lut_frag.glsl59
-rw-r--r--source/blender/draw/engines/eevee/shaders/concentric_samples_lib.glsl267
-rw-r--r--source/blender/draw/engines/eevee/shaders/default_frag.glsl11
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_bloom_frag.glsl79
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl30
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_downsample_cube_frag.glsl30
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl37
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_gtao_frag.glsl69
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_minmaxz_frag.glsl71
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_motion_blur_frag.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl453
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl14
-rw-r--r--source/blender/draw/engines/eevee/shaders/irradiance_lib.glsl6
-rw-r--r--source/blender/draw/engines/eevee/shaders/lamps_lib.glsl301
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_frag.glsl11
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_vert.glsl14
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_geom.glsl11
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl3
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_grid_fill_frag.glsl20
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl254
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_frag.glsl23
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_vert.glsl12
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_planar_downsample_frag.glsl40
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_planar_downsample_geom.glsl24
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_planar_downsample_vert.glsl10
-rw-r--r--source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl1004
-rw-r--r--source/blender/draw/engines/eevee/shaders/ltc_lib.glsl10
-rw-r--r--source/blender/draw/engines/eevee/shaders/prepass_frag.glsl82
-rw-r--r--source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl230
-rw-r--r--source/blender/draw/engines/eevee/shaders/shadow_copy_frag.glsl210
-rw-r--r--source/blender/draw/engines/eevee/shaders/shadow_frag.glsl14
-rw-r--r--source/blender/draw/engines/eevee/shaders/shadow_geom.glsl35
-rw-r--r--source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl158
-rw-r--r--source/blender/draw/engines/eevee/shaders/shadow_store_geom.glsl23
-rw-r--r--source/blender/draw/engines/eevee/shaders/shadow_store_vert.glsl8
-rw-r--r--source/blender/draw/engines/eevee/shaders/shadow_vert.glsl18
-rw-r--r--source/blender/draw/engines/eevee/shaders/ssr_lib.glsl73
-rw-r--r--source/blender/draw/engines/eevee/shaders/volumetric_frag.glsl396
-rw-r--r--source/blender/draw/engines/external/external_engine.c5
-rw-r--r--source/blender/draw/intern/DRW_render.h47
-rw-r--r--source/blender/draw/intern/draw_cache.c377
-rw-r--r--source/blender/draw/intern/draw_cache.h19
-rw-r--r--source/blender/draw/intern/draw_cache_impl.h18
-rw-r--r--source/blender/draw/intern/draw_cache_impl_curve.c61
-rw-r--r--source/blender/draw/intern/draw_cache_impl_displist.c4
-rw-r--r--source/blender/draw/intern/draw_cache_impl_lattice.c99
-rw-r--r--source/blender/draw/intern/draw_cache_impl_mesh.c1561
-rw-r--r--source/blender/draw/intern/draw_cache_impl_particles.c187
-rw-r--r--source/blender/draw/intern/draw_common.c15
-rw-r--r--source/blender/draw/intern/draw_manager.c1015
-rw-r--r--source/blender/draw/intern/draw_manager_profiling.c242
-rw-r--r--source/blender/draw/intern/draw_manager_profiling.h43
-rw-r--r--source/blender/draw/intern/draw_view.c32
-rw-r--r--source/blender/draw/modes/edit_armature_mode.c12
-rw-r--r--source/blender/draw/modes/edit_curve_mode.c9
-rw-r--r--source/blender/draw/modes/edit_lattice_mode.c15
-rw-r--r--source/blender/draw/modes/edit_mesh_mode.c30
-rw-r--r--source/blender/draw/modes/edit_metaball_mode.c3
-rw-r--r--source/blender/draw/modes/edit_surface_mode.c3
-rw-r--r--source/blender/draw/modes/edit_text_mode.c3
-rw-r--r--source/blender/draw/modes/object_mode.c340
-rw-r--r--source/blender/draw/modes/paint_texture_mode.c69
-rw-r--r--source/blender/draw/modes/paint_vertex_mode.c24
-rw-r--r--source/blender/draw/modes/paint_weight_mode.c14
-rw-r--r--source/blender/draw/modes/particle_mode.c3
-rw-r--r--source/blender/draw/modes/pose_mode.c7
-rw-r--r--source/blender/draw/modes/sculpt_mode.c10
-rw-r--r--source/blender/draw/modes/shaders/common_fxaa_lib.glsl678
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_facedot_frag.glsl7
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_facedot_vert.glsl17
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl71
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_geom_edge.glsl10
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl26
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_mix_frag.glsl8
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl15
-rw-r--r--source/blender/draw/modes/shaders/object_grid_frag.glsl6
-rw-r--r--source/blender/draw/modes/shaders/object_lightprobe_grid_vert.glsl28
-rw-r--r--source/blender/draw/modes/shaders/object_outline_detect_frag.glsl42
-rw-r--r--source/blender/draw/modes/shaders/object_outline_expand_frag.glsl44
-rw-r--r--source/blender/draw/modes/shaders/object_outline_resolve_frag.glsl18
-rw-r--r--source/blender/draw/modes/shaders/object_particle_prim_vert.glsl14
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c4
-rw-r--r--source/blender/editors/animation/anim_filter.c4
-rw-r--r--source/blender/editors/animation/anim_markers.c10
-rw-r--r--source/blender/editors/animation/anim_ops.c6
-rw-r--r--source/blender/editors/animation/drivers.c7
-rw-r--r--source/blender/editors/animation/keyframes_draw.c2
-rw-r--r--source/blender/editors/animation/keyframes_general.c1
-rw-r--r--source/blender/editors/animation/keyframing.c51
-rw-r--r--source/blender/editors/animation/keyingsets.c2
-rw-r--r--source/blender/editors/armature/armature_edit.c30
-rw-r--r--source/blender/editors/armature/armature_relations.c4
-rw-r--r--source/blender/editors/armature/armature_select.c20
-rw-r--r--source/blender/editors/armature/armature_skinning.c17
-rw-r--r--source/blender/editors/armature/editarmature_sketch.c22
-rw-r--r--source/blender/editors/armature/pose_edit.c16
-rw-r--r--source/blender/editors/armature/pose_lib.c14
-rw-r--r--source/blender/editors/armature/pose_select.c2
-rw-r--r--source/blender/editors/armature/pose_slide.c51
-rw-r--r--source/blender/editors/armature/pose_transform.c16
-rw-r--r--source/blender/editors/armature/pose_utils.c7
-rw-r--r--source/blender/editors/curve/curve_intern.h2
-rw-r--r--source/blender/editors/curve/curve_ops.c3
-rw-r--r--source/blender/editors/curve/editcurve.c5
-rw-r--r--source/blender/editors/curve/editcurve_paint.c105
-rw-r--r--source/blender/editors/curve/editfont.c79
-rw-r--r--source/blender/editors/gpencil/drawgpencil.c8
-rw-r--r--source/blender/editors/gpencil/editaction_gpencil.c8
-rw-r--r--source/blender/editors/gpencil/gpencil_brush.c6
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c9
-rw-r--r--source/blender/editors/gpencil/gpencil_interpolate.c13
-rw-r--r--source/blender/editors/gpencil/gpencil_ops.c6
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c37
-rw-r--r--source/blender/editors/gpencil/gpencil_utils.c7
-rw-r--r--source/blender/editors/include/ED_anim_api.h11
-rw-r--r--source/blender/editors/include/ED_armature.h14
-rw-r--r--source/blender/editors/include/ED_manipulator_library.h46
-rw-r--r--source/blender/editors/include/ED_mesh.h25
-rw-r--r--source/blender/editors/include/ED_object.h4
-rw-r--r--source/blender/editors/include/ED_particle.h8
-rw-r--r--source/blender/editors/include/ED_screen.h2
-rw-r--r--source/blender/editors/include/ED_transform.h15
-rw-r--r--source/blender/editors/include/ED_transform_snap_object_context.h9
-rw-r--r--source/blender/editors/include/ED_view3d.h51
-rw-r--r--source/blender/editors/include/UI_interface.h12
-rw-r--r--source/blender/editors/include/UI_resources.h7
-rw-r--r--source/blender/editors/include/UI_view2d.h1
-rw-r--r--source/blender/editors/interface/interface.c60
-rw-r--r--source/blender/editors/interface/interface_draw.c28
-rw-r--r--source/blender/editors/interface/interface_eyedropper.c5
-rw-r--r--source/blender/editors/interface/interface_handlers.c172
-rw-r--r--source/blender/editors/interface/interface_intern.h4
-rw-r--r--source/blender/editors/interface/interface_layout.c43
-rw-r--r--source/blender/editors/interface/interface_ops.c73
-rw-r--r--source/blender/editors/interface/interface_panel.c20
-rw-r--r--source/blender/editors/interface/interface_regions.c14
-rw-r--r--source/blender/editors/interface/interface_templates.c22
-rw-r--r--source/blender/editors/interface/interface_utils.c13
-rw-r--r--source/blender/editors/interface/interface_widgets.c26
-rw-r--r--source/blender/editors/interface/resources.c51
-rw-r--r--source/blender/editors/interface/view2d.c10
-rw-r--r--source/blender/editors/io/CMakeLists.txt1
-rw-r--r--source/blender/editors/io/io_alembic.c18
-rw-r--r--source/blender/editors/io/io_cache.c32
-rw-r--r--source/blender/editors/io/io_collada.c8
-rw-r--r--source/blender/editors/manipulator_library/manipulator_draw_utils.c6
-rw-r--r--source/blender/editors/manipulator_library/manipulator_library_intern.h9
-rw-r--r--source/blender/editors/manipulator_library/manipulator_library_presets.c8
-rw-r--r--source/blender/editors/manipulator_library/manipulator_library_utils.c73
-rw-r--r--source/blender/editors/manipulator_library/manipulator_types/arrow2d_manipulator.c51
-rw-r--r--source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c87
-rw-r--r--source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c1213
-rw-r--r--source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c79
-rw-r--r--source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c211
-rw-r--r--source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c45
-rw-r--r--source/blender/editors/mask/mask_draw.c4
-rw-r--r--source/blender/editors/mask/mask_ops.c2
-rw-r--r--source/blender/editors/mesh/editface.c56
-rw-r--r--source/blender/editors/mesh/editmesh_add.c2
-rw-r--r--source/blender/editors/mesh/editmesh_bevel.c5
-rw-r--r--source/blender/editors/mesh/editmesh_bisect.c20
-rw-r--r--source/blender/editors/mesh/editmesh_extrude.c26
-rw-r--r--source/blender/editors/mesh/editmesh_knife.c21
-rw-r--r--source/blender/editors/mesh/editmesh_knife_project.c13
-rw-r--r--source/blender/editors/mesh/editmesh_loopcut.c15
-rw-r--r--source/blender/editors/mesh/editmesh_path.c16
-rw-r--r--source/blender/editors/mesh/editmesh_select.c116
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c20
-rw-r--r--source/blender/editors/mesh/editmesh_utils.c2
-rw-r--r--source/blender/editors/mesh/mesh_data.c16
-rw-r--r--source/blender/editors/mesh/mesh_navmesh.c5
-rw-r--r--source/blender/editors/mesh/meshtools.c74
-rw-r--r--source/blender/editors/metaball/mball_edit.c4
-rw-r--r--source/blender/editors/object/object_add.c188
-rw-r--r--source/blender/editors/object/object_bake.c4
-rw-r--r--source/blender/editors/object/object_bake_api.c22
-rw-r--r--source/blender/editors/object/object_constraint.c24
-rw-r--r--source/blender/editors/object/object_data_transfer.c19
-rw-r--r--source/blender/editors/object/object_edit.c50
-rw-r--r--source/blender/editors/object/object_facemap_ops.c2
-rw-r--r--source/blender/editors/object/object_group.c2
-rw-r--r--source/blender/editors/object/object_hook.c11
-rw-r--r--source/blender/editors/object/object_intern.h1
-rw-r--r--source/blender/editors/object/object_modifier.c54
-rw-r--r--source/blender/editors/object/object_ops.c1
-rw-r--r--source/blender/editors/object/object_relations.c56
-rw-r--r--source/blender/editors/object/object_select.c10
-rw-r--r--source/blender/editors/object/object_transform.c500
-rw-r--r--source/blender/editors/object/object_vgroup.c127
-rw-r--r--source/blender/editors/physics/dynamicpaint_ops.c10
-rw-r--r--source/blender/editors/physics/particle_edit.c199
-rw-r--r--source/blender/editors/physics/particle_object.c69
-rw-r--r--source/blender/editors/physics/physics_fluid.c26
-rw-r--r--source/blender/editors/physics/rigidbody_constraint.c4
-rw-r--r--source/blender/editors/render/CMakeLists.txt11
-rw-r--r--source/blender/editors/render/render_internal.c15
-rw-r--r--source/blender/editors/render/render_opengl.c50
-rw-r--r--source/blender/editors/render/render_preview.c28
-rw-r--r--source/blender/editors/render/render_shading.c14
-rw-r--r--source/blender/editors/render/render_update.c67
-rw-r--r--source/blender/editors/screen/area.c2
-rw-r--r--source/blender/editors/screen/screen_context.c29
-rw-r--r--source/blender/editors/screen/screen_edit.c46
-rw-r--r--source/blender/editors/screen/screen_ops.c33
-rw-r--r--source/blender/editors/screen/screendump.c4
-rw-r--r--source/blender/editors/screen/workspace_edit.c6
-rw-r--r--source/blender/editors/sculpt_paint/CMakeLists.txt4
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c26
-rw-r--r--source/blender/editors/sculpt_paint/paint_hide.c7
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c24
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_2d.c6
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c40
-rw-r--r--source/blender/editors/sculpt_paint/paint_intern.h60
-rw-r--r--source/blender/editors/sculpt_paint/paint_mask.c17
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c309
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c7
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c30
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c3591
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_color_ops.c575
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_color_utils.c649
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_proj.c30
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c869
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c311
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c922
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h230
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c12
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_uv.c2
-rw-r--r--source/blender/editors/sound/CMakeLists.txt2
-rw-r--r--source/blender/editors/sound/sound_ops.c2
-rw-r--r--source/blender/editors/space_action/action_edit.c2
-rw-r--r--source/blender/editors/space_action/action_select.c2
-rw-r--r--source/blender/editors/space_action/space_action.c8
-rw-r--r--source/blender/editors/space_buttons/buttons_context.c2
-rw-r--r--source/blender/editors/space_buttons/buttons_texture.c2
-rw-r--r--source/blender/editors/space_clip/clip_dopesheet_draw.c2
-rw-r--r--source/blender/editors/space_clip/clip_draw.c30
-rw-r--r--source/blender/editors/space_clip/clip_graph_draw.c2
-rw-r--r--source/blender/editors/space_clip/clip_ops.c2
-rw-r--r--source/blender/editors/space_clip/space_clip.c2
-rw-r--r--source/blender/editors/space_clip/tracking_ops_orient.c9
-rw-r--r--source/blender/editors/space_clip/tracking_ops_track.c8
-rw-r--r--source/blender/editors/space_console/console_intern.h2
-rw-r--r--source/blender/editors/space_file/file_draw.c4
-rw-r--r--source/blender/editors/space_file/file_ops.c1
-rw-r--r--source/blender/editors/space_file/filelist.c85
-rw-r--r--source/blender/editors/space_file/filelist.h3
-rw-r--r--source/blender/editors/space_file/space_file.c5
-rw-r--r--source/blender/editors/space_graph/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_graph/graph_draw.c16
-rw-r--r--source/blender/editors/space_graph/graph_edit.c8
-rw-r--r--source/blender/editors/space_graph/graph_ops.c2
-rw-r--r--source/blender/editors/space_image/image_draw.c8
-rw-r--r--source/blender/editors/space_image/image_edit.c2
-rw-r--r--source/blender/editors/space_image/image_ops.c30
-rw-r--r--source/blender/editors/space_image/space_image.c4
-rw-r--r--source/blender/editors/space_info/info_ops.c1
-rw-r--r--source/blender/editors/space_logic/logic_window.c2
-rw-r--r--source/blender/editors/space_nla/nla_draw.c109
-rw-r--r--source/blender/editors/space_nla/nla_edit.c4
-rw-r--r--source/blender/editors/space_node/drawnode.c11
-rw-r--r--source/blender/editors/space_node/node_draw.c4
-rw-r--r--source/blender/editors/space_node/node_edit.c6
-rw-r--r--source/blender/editors/space_node/node_group.c11
-rw-r--r--source/blender/editors/space_node/node_intern.h3
-rw-r--r--source/blender/editors/space_node/node_manipulators.c503
-rw-r--r--source/blender/editors/space_node/node_relationships.c13
-rw-r--r--source/blender/editors/space_node/node_templates.c5
-rw-r--r--source/blender/editors/space_node/space_node.c6
-rw-r--r--source/blender/editors/space_outliner/outliner_collections.c82
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c54
-rw-r--r--source/blender/editors/space_outliner/outliner_edit.c13
-rw-r--r--source/blender/editors/space_outliner/outliner_intern.h8
-rw-r--r--source/blender/editors/space_outliner/outliner_ops.c1
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c36
-rw-r--r--source/blender/editors/space_outliner/outliner_tree.c23
-rw-r--r--source/blender/editors/space_sequencer/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_sequencer/sequencer_add.c2
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c25
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c16
-rw-r--r--source/blender/editors/space_sequencer/space_sequencer.c1
-rw-r--r--source/blender/editors/space_text/text_draw.c2
-rw-r--r--source/blender/editors/space_text/text_format_pov.c912
-rw-r--r--source/blender/editors/space_text/text_format_pov_ini.c129
-rw-r--r--source/blender/editors/space_time/space_time.c6
-rw-r--r--source/blender/editors/space_view3d/CMakeLists.txt6
-rw-r--r--source/blender/editors/space_view3d/drawarmature.c134
-rw-r--r--source/blender/editors/space_view3d/drawobject.c405
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c58
-rw-r--r--source/blender/editors/space_view3d/view3d_buttons.c4
-rw-r--r--source/blender/editors/space_view3d/view3d_camera_control.c8
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c115
-rw-r--r--source/blender/editors/space_view3d/view3d_draw_legacy.c188
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c95
-rw-r--r--source/blender/editors/space_view3d/view3d_fly.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_header.c4
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h55
-rw-r--r--source/blender/editors/space_view3d/view3d_iterators.c27
-rw-r--r--source/blender/editors/space_view3d/view3d_manipulator_armature.c220
-rw-r--r--source/blender/editors/space_view3d/view3d_manipulator_camera.c (renamed from source/blender/editors/space_view3d/view3d_manipulators.c)321
-rw-r--r--source/blender/editors/space_view3d/view3d_manipulator_empty.c196
-rw-r--r--source/blender/editors/space_view3d/view3d_manipulator_forcefield.c118
-rw-r--r--source/blender/editors/space_view3d/view3d_manipulator_lamp.c289
-rw-r--r--source/blender/editors/space_view3d/view3d_ruler.c16
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c170
-rw-r--r--source/blender/editors/space_view3d/view3d_snap.c10
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c118
-rw-r--r--source/blender/editors/space_view3d/view3d_walk.c15
-rw-r--r--source/blender/editors/transform/transform.c92
-rw-r--r--source/blender/editors/transform/transform.h5
-rw-r--r--source/blender/editors/transform/transform_constraints.c9
-rw-r--r--source/blender/editors/transform/transform_conversions.c240
-rw-r--r--source/blender/editors/transform/transform_generics.c30
-rw-r--r--source/blender/editors/transform/transform_manipulator.c555
-rw-r--r--source/blender/editors/transform/transform_manipulator2d.c147
-rw-r--r--source/blender/editors/transform/transform_ops.c29
-rw-r--r--source/blender/editors/transform/transform_orientations.c48
-rw-r--r--source/blender/editors/transform/transform_snap.c19
-rw-r--r--source/blender/editors/transform/transform_snap_object.c1454
-rw-r--r--source/blender/editors/util/ed_util.c2
-rw-r--r--source/blender/editors/util/undo.c8
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c6
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c11
-rw-r--r--source/blender/editors/uvedit/uvedit_smart_stitch.c44
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp4
-rw-r--r--source/blender/gpu/CMakeLists.txt6
-rw-r--r--source/blender/gpu/GPU_batch.h8
-rw-r--r--source/blender/gpu/GPU_immediate.h8
-rw-r--r--source/blender/gpu/GPU_immediate_util.h31
-rw-r--r--source/blender/gpu/GPU_lamp.h2
-rw-r--r--source/blender/gpu/GPU_material.h25
-rw-r--r--source/blender/gpu/GPU_matrix.h16
-rw-r--r--source/blender/gpu/GPU_select.h3
-rw-r--r--source/blender/gpu/GPU_shader.h6
-rw-r--r--source/blender/gpu/GPU_texture.h4
-rw-r--r--source/blender/gpu/GPU_uniformbuffer.h14
-rw-r--r--source/blender/gpu/GPU_viewport.h3
-rw-r--r--source/blender/gpu/intern/gpu_batch.c20
-rw-r--r--source/blender/gpu/intern/gpu_buffers.c6
-rw-r--r--source/blender/gpu/intern/gpu_codegen.c293
-rw-r--r--source/blender/gpu/intern/gpu_codegen.h23
-rw-r--r--source/blender/gpu/intern/gpu_compositing.c10
-rw-r--r--source/blender/gpu/intern/gpu_draw.c13
-rw-r--r--source/blender/gpu/intern/gpu_framebuffer.c36
-rw-r--r--source/blender/gpu/intern/gpu_immediate_util.c118
-rw-r--r--source/blender/gpu/intern/gpu_lamp.c27
-rw-r--r--source/blender/gpu/intern/gpu_lamp_private.h2
-rw-r--r--source/blender/gpu/intern/gpu_material.c95
-rw-r--r--source/blender/gpu/intern/gpu_matrix.c51
-rw-r--r--source/blender/gpu/intern/gpu_select.c26
-rw-r--r--source/blender/gpu/intern/gpu_shader.c99
-rw-r--r--source/blender/gpu/intern/gpu_shader_private.h2
-rw-r--r--source/blender/gpu/intern/gpu_texture.c48
-rw-r--r--source/blender/gpu/intern/gpu_uniformbuffer.c287
-rw-r--r--source/blender/gpu/intern/gpu_viewport.c77
-rw-r--r--source/blender/gpu/shaders/gpu_shader_2D_line_dashed_frag.glsl44
-rw-r--r--source/blender/gpu/shaders/gpu_shader_2D_line_dashed_geom.glsl14
-rw-r--r--source/blender/gpu/shaders/gpu_shader_2D_line_dashed_uniform_color_vert.glsl21
-rw-r--r--source/blender/gpu/shaders/gpu_shader_2D_line_dashed_vert.glsl11
-rw-r--r--source/blender/gpu/shaders/gpu_shader_2D_line_dashed_width_geom.glsl59
-rw-r--r--source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_legacy_vert.glsl (renamed from source/blender/gpu/shaders/gpu_shader_3D_line_dashed_legacy_vert.glsl)12
-rw-r--r--source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_vert.glsl21
-rw-r--r--source/blender/gpu/shaders/gpu_shader_3D_line_dashed_vert.glsl11
-rw-r--r--source/blender/gpu/shaders/gpu_shader_instance_edges_variying_color_vert.glsl10
-rw-r--r--source/blender/gpu/shaders/gpu_shader_keyframe_diamond_vert.glsl2
-rw-r--r--source/blender/gpu/shaders/gpu_shader_material.glsl440
-rw-r--r--source/blender/gpu/shaders/gpu_shader_uniform_color_frag.glsl12
-rw-r--r--source/blender/ikplugin/BIK_api.h5
-rw-r--r--source/blender/ikplugin/intern/ikplugin_api.c8
-rw-r--r--source/blender/ikplugin/intern/ikplugin_api.h5
-rw-r--r--source/blender/ikplugin/intern/iksolver_plugin.c64
-rw-r--r--source/blender/ikplugin/intern/iksolver_plugin.h7
-rw-r--r--source/blender/ikplugin/intern/itasc_plugin.cpp42
-rw-r--r--source/blender/ikplugin/intern/itasc_plugin.h4
-rw-r--r--source/blender/imbuf/CMakeLists.txt10
-rw-r--r--source/blender/imbuf/IMB_imbuf.h1
-rw-r--r--source/blender/imbuf/IMB_imbuf_types.h1
-rw-r--r--source/blender/imbuf/intern/IMB_anim.h11
-rw-r--r--source/blender/imbuf/intern/anim_movie.c38
-rw-r--r--source/blender/imbuf/intern/colormanagement.c40
-rw-r--r--source/blender/imbuf/intern/filetype.c12
-rw-r--r--source/blender/imbuf/intern/iris.c350
-rw-r--r--source/blender/imbuf/intern/jp2.c2
-rw-r--r--source/blender/imbuf/intern/moviecache.c2
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_api.cpp2
-rw-r--r--source/blender/imbuf/intern/png.c2
-rw-r--r--source/blender/imbuf/intern/rectop.c49
-rw-r--r--source/blender/imbuf/intern/tiff.c43
-rw-r--r--source/blender/imbuf/intern/util.c39
-rw-r--r--source/blender/makesdna/DNA_ID.h18
-rw-r--r--source/blender/makesdna/DNA_action_types.h4
-rw-r--r--source/blender/makesdna/DNA_anim_types.h2
-rw-r--r--source/blender/makesdna/DNA_brush_types.h41
-rw-r--r--source/blender/makesdna/DNA_lamp_types.h9
-rw-r--r--source/blender/makesdna/DNA_layer_types.h1
-rw-r--r--source/blender/makesdna/DNA_material_types.h32
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h21
-rw-r--r--source/blender/makesdna/DNA_node_types.h14
-rw-r--r--source/blender/makesdna/DNA_object_types.h11
-rw-r--r--source/blender/makesdna/DNA_particle_types.h5
-rw-r--r--source/blender/makesdna/DNA_scene_types.h98
-rw-r--r--source/blender/makesdna/DNA_screen_types.h2
-rw-r--r--source/blender/makesdna/DNA_sequence_types.h2
-rw-r--r--source/blender/makesdna/DNA_space_types.h2
-rw-r--r--source/blender/makesdna/DNA_text_types.h2
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h140
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h5
-rw-r--r--source/blender/makesdna/intern/makesdna.c3
-rw-r--r--source/blender/makesrna/RNA_access.h12
-rw-r--r--source/blender/makesrna/RNA_define.h7
-rw-r--r--source/blender/makesrna/RNA_enum_types.h2
-rw-r--r--source/blender/makesrna/RNA_types.h4
-rw-r--r--source/blender/makesrna/intern/CMakeLists.txt12
-rw-r--r--source/blender/makesrna/intern/makesrna.c20
-rw-r--r--source/blender/makesrna/intern/rna_ID.c19
-rw-r--r--source/blender/makesrna/intern/rna_access.c104
-rw-r--r--source/blender/makesrna/intern/rna_animation.c10
-rw-r--r--source/blender/makesrna/intern/rna_armature.c2
-rw-r--r--source/blender/makesrna/intern/rna_brush.c41
-rw-r--r--source/blender/makesrna/intern/rna_context.c13
-rw-r--r--source/blender/makesrna/intern/rna_curve_api.c10
-rw-r--r--source/blender/makesrna/intern/rna_define.c159
-rw-r--r--source/blender/makesrna/intern/rna_depsgraph.c12
-rw-r--r--source/blender/makesrna/intern/rna_fcurve.c36
-rw-r--r--source/blender/makesrna/intern/rna_gpencil.c2
-rw-r--r--source/blender/makesrna/intern/rna_image.c2
-rw-r--r--source/blender/makesrna/intern/rna_image_api.c4
-rw-r--r--source/blender/makesrna/intern/rna_internal.h6
-rw-r--r--source/blender/makesrna/intern/rna_internal_types.h5
-rw-r--r--source/blender/makesrna/intern/rna_key.c2
-rw-r--r--source/blender/makesrna/intern/rna_lamp.c74
-rw-r--r--source/blender/makesrna/intern/rna_lattice_api.c8
-rw-r--r--source/blender/makesrna/intern/rna_lightprobe.c3
-rw-r--r--source/blender/makesrna/intern/rna_main_api.c127
-rw-r--r--source/blender/makesrna/intern/rna_material.c55
-rw-r--r--source/blender/makesrna/intern/rna_mesh.c228
-rw-r--r--source/blender/makesrna/intern/rna_mesh_api.c8
-rw-r--r--source/blender/makesrna/intern/rna_meta_api.c2
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c54
-rw-r--r--source/blender/makesrna/intern/rna_nla.c5
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c177
-rw-r--r--source/blender/makesrna/intern/rna_object.c75
-rw-r--r--source/blender/makesrna/intern/rna_object_api.c54
-rw-r--r--source/blender/makesrna/intern/rna_particle.c49
-rw-r--r--source/blender/makesrna/intern/rna_pose.c2
-rw-r--r--source/blender/makesrna/intern/rna_render.c42
-rw-r--r--source/blender/makesrna/intern/rna_rna.c54
-rw-r--r--source/blender/makesrna/intern/rna_scene.c611
-rw-r--r--source/blender/makesrna/intern/rna_scene_api.c8
-rw-r--r--source/blender/makesrna/intern/rna_sculpt_paint.c43
-rw-r--r--source/blender/makesrna/intern/rna_sequencer.c9
-rw-r--r--source/blender/makesrna/intern/rna_space.c29
-rw-r--r--source/blender/makesrna/intern/rna_space_api.c9
-rw-r--r--source/blender/makesrna/intern/rna_texture.c2
-rw-r--r--source/blender/makesrna/intern/rna_ui.c65
-rw-r--r--source/blender/makesrna/intern/rna_ui_api.c3
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c119
-rw-r--r--source/blender/makesrna/intern/rna_wm.c185
-rw-r--r--source/blender/makesrna/intern/rna_wm_api.c4
-rw-r--r--source/blender/makesrna/intern/rna_wm_manipulator.c289
-rw-r--r--source/blender/makesrna/intern/rna_wm_manipulator_api.c52
-rw-r--r--source/blender/modifiers/intern/MOD_armature.c18
-rw-r--r--source/blender/modifiers/intern/MOD_array.c10
-rw-r--r--source/blender/modifiers/intern/MOD_bevel.c18
-rw-r--r--source/blender/modifiers/intern/MOD_boolean.c39
-rw-r--r--source/blender/modifiers/intern/MOD_boolean_util.c3
-rw-r--r--source/blender/modifiers/intern/MOD_build.c6
-rw-r--r--source/blender/modifiers/intern/MOD_cast.c7
-rw-r--r--source/blender/modifiers/intern/MOD_cloth.c5
-rw-r--r--source/blender/modifiers/intern/MOD_collision.c9
-rw-r--r--source/blender/modifiers/intern/MOD_correctivesmooth.c4
-rw-r--r--source/blender/modifiers/intern/MOD_curve.c12
-rw-r--r--source/blender/modifiers/intern/MOD_datatransfer.c4
-rw-r--r--source/blender/modifiers/intern/MOD_decimate.c4
-rw-r--r--source/blender/modifiers/intern/MOD_displace.c12
-rw-r--r--source/blender/modifiers/intern/MOD_dynamicpaint.c9
-rw-r--r--source/blender/modifiers/intern/MOD_edgesplit.c4
-rw-r--r--source/blender/modifiers/intern/MOD_explode.c18
-rw-r--r--source/blender/modifiers/intern/MOD_fluidsim.c6
-rw-r--r--source/blender/modifiers/intern/MOD_hook.c5
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciandeform.c8
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciansmooth.c4
-rw-r--r--source/blender/modifiers/intern/MOD_lattice.c8
-rw-r--r--source/blender/modifiers/intern/MOD_mask.c6
-rw-r--r--source/blender/modifiers/intern/MOD_meshcache.c6
-rw-r--r--source/blender/modifiers/intern/MOD_meshcache_pc2.c2
-rw-r--r--source/blender/modifiers/intern/MOD_meshcache_util.c2
-rw-r--r--source/blender/modifiers/intern/MOD_meshdeform.c12
-rw-r--r--source/blender/modifiers/intern/MOD_meshsequencecache.c30
-rw-r--r--source/blender/modifiers/intern/MOD_mirror.c10
-rw-r--r--source/blender/modifiers/intern/MOD_multires.c6
-rw-r--r--source/blender/modifiers/intern/MOD_normal_edit.c3
-rw-r--r--source/blender/modifiers/intern/MOD_ocean.c6
-rw-r--r--source/blender/modifiers/intern/MOD_particleinstance.c7
-rw-r--r--source/blender/modifiers/intern/MOD_particlesystem.c6
-rw-r--r--source/blender/modifiers/intern/MOD_remesh.c5
-rw-r--r--source/blender/modifiers/intern/MOD_screw.c65
-rw-r--r--source/blender/modifiers/intern/MOD_shapekey.c16
-rw-r--r--source/blender/modifiers/intern/MOD_shrinkwrap.c7
-rw-r--r--source/blender/modifiers/intern/MOD_simpledeform.c8
-rw-r--r--source/blender/modifiers/intern/MOD_skin.c3
-rw-r--r--source/blender/modifiers/intern/MOD_smoke.c10
-rw-r--r--source/blender/modifiers/intern/MOD_smooth.c4
-rw-r--r--source/blender/modifiers/intern/MOD_softbody.c5
-rw-r--r--source/blender/modifiers/intern/MOD_solidify.c6
-rw-r--r--source/blender/modifiers/intern/MOD_subsurf.c16
-rw-r--r--source/blender/modifiers/intern/MOD_surface.c4
-rw-r--r--source/blender/modifiers/intern/MOD_surfacedeform.c8
-rw-r--r--source/blender/modifiers/intern/MOD_triangulate.c3
-rw-r--r--source/blender/modifiers/intern/MOD_uvproject.c4
-rw-r--r--source/blender/modifiers/intern/MOD_uvwarp.c4
-rw-r--r--source/blender/modifiers/intern/MOD_warp.c6
-rw-r--r--source/blender/modifiers/intern/MOD_wave.c12
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgedit.c11
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgmix.c12
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgproximity.c12
-rw-r--r--source/blender/modifiers/intern/MOD_wireframe.c3
-rw-r--r--source/blender/nodes/CMakeLists.txt2
-rw-r--r--source/blender/nodes/NOD_socket.h2
-rw-r--r--source/blender/nodes/NOD_static_types.h2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_image.c3
-rw-r--r--source/blender/nodes/intern/node_socket.c2
-rw-r--r--source/blender/nodes/shader/node_shader_tree.c49
-rw-r--r--source/blender/nodes/shader/node_shader_util.c2
-rw-r--r--source/blender/nodes/shader/node_shader_util.h1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_add_shader.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_attribute.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_background.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_brightness.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c8
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c8
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c8
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c8
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_hair.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c25
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c8
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c8
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c8
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bump.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_camera.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_curves.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_eevee_metallic.c88
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_eevee_specular.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_emission.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_fresnel.c23
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_gamma.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_geom.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_geometry.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_hueSatVal.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_invert.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_lamp.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_layer_weight.c23
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_light_falloff.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_light_path.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_mapping.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_math.c6
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_mixRgb.c3
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_mix_shader.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_normal.c6
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_object_info.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_output.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_output_eevee_material.c66
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_output_material.c8
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_output_world.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_particle_info.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_rgb.c6
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c8
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c8
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.c8
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_squeeze.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c8
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tangent.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_brick.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_checker.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_coord.c6
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_environment.c10
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_gradient.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_image.c8
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_magic.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_noise.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_sky.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_wave.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_texture.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_uvmap.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_valToRgb.c6
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_value.c6
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_vectMath.c6
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_volume_absorption.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_volume_scatter.c4
-rw-r--r--source/blender/nodes/texture/node_texture_tree.c2
-rw-r--r--source/blender/python/CMakeLists.txt1
-rw-r--r--source/blender/python/bmesh/bmesh_py_ops_call.c43
-rw-r--r--source/blender/python/bmesh/bmesh_py_types.c84
-rw-r--r--source/blender/python/bmesh/bmesh_py_types_customdata.c11
-rw-r--r--source/blender/python/bmesh/bmesh_py_types_meshdata.c11
-rw-r--r--source/blender/python/gawain/CMakeLists.txt47
-rw-r--r--source/blender/python/gawain/gwn_py_api.c63
-rw-r--r--source/blender/python/gawain/gwn_py_api.h30
-rw-r--r--source/blender/python/gawain/gwn_py_types.c823
-rw-r--r--source/blender/python/gawain/gwn_py_types.h67
-rw-r--r--source/blender/python/generic/bgl.c135
-rw-r--r--source/blender/python/generic/bpy_internal_import.c25
-rw-r--r--source/blender/python/generic/idprop_py_api.c6
-rw-r--r--source/blender/python/generic/py_capi_utils.c187
-rw-r--r--source/blender/python/generic/py_capi_utils.h43
-rw-r--r--source/blender/python/generic/python_utildefines.h6
-rw-r--r--source/blender/python/intern/CMakeLists.txt6
-rw-r--r--source/blender/python/intern/bpy.c27
-rw-r--r--source/blender/python/intern/bpy_app.c7
-rw-r--r--source/blender/python/intern/bpy_app_alembic.c6
-rw-r--r--source/blender/python/intern/bpy_app_build_options.c7
-rw-r--r--source/blender/python/intern/bpy_app_ffmpeg.c5
-rw-r--r--source/blender/python/intern/bpy_app_ocio.c7
-rw-r--r--source/blender/python/intern/bpy_app_oiio.c7
-rw-r--r--source/blender/python/intern/bpy_app_opensubdiv.c7
-rw-r--r--source/blender/python/intern/bpy_app_openvdb.c7
-rw-r--r--source/blender/python/intern/bpy_app_sdl.c6
-rw-r--r--source/blender/python/intern/bpy_interface.c3
-rw-r--r--source/blender/python/intern/bpy_library_load.c14
-rw-r--r--source/blender/python/intern/bpy_library_write.c21
-rw-r--r--source/blender/python/intern/bpy_manipulator_wrap.c43
-rw-r--r--source/blender/python/intern/bpy_operator.c2
-rw-r--r--source/blender/python/intern/bpy_operator_wrap.c10
-rw-r--r--source/blender/python/intern/bpy_props.c257
-rw-r--r--source/blender/python/intern/bpy_rna.c175
-rw-r--r--source/blender/python/intern/bpy_rna_array.c4
-rw-r--r--source/blender/python/intern/bpy_rna_driver.c10
-rw-r--r--source/blender/python/intern/bpy_rna_id_collection.c8
-rw-r--r--source/blender/python/intern/bpy_rna_manipulator.c266
-rw-r--r--source/blender/python/intern/bpy_util.h4
-rw-r--r--source/blender/python/intern/bpy_utils_units.c24
-rw-r--r--source/blender/python/intern/gpu.c21
-rw-r--r--source/blender/python/intern/gpu.h2
-rw-r--r--source/blender/python/intern/gpu_offscreen.c42
-rw-r--r--source/blender/python/intern/gpu_py_matrix.c552
-rw-r--r--source/blender/python/intern/gpu_py_select.c92
-rw-r--r--source/blender/python/mathutils/mathutils.c4
-rw-r--r--source/blender/python/mathutils/mathutils.h11
-rw-r--r--source/blender/python/mathutils/mathutils_Matrix.c67
-rw-r--r--source/blender/python/mathutils/mathutils_Matrix.h5
-rw-r--r--source/blender/python/mathutils/mathutils_Vector.c890
-rw-r--r--source/blender/python/mathutils/mathutils_bvhtree.c12
-rw-r--r--source/blender/python/mathutils/mathutils_geometry.c2
-rw-r--r--source/blender/quicktime/apple/qtkit_export.m884
-rw-r--r--source/blender/quicktime/apple/qtkit_import.m400
-rw-r--r--source/blender/quicktime/quicktime_export.h162
-rw-r--r--source/blender/quicktime/quicktime_import.h63
-rw-r--r--source/blender/render/CMakeLists.txt10
-rw-r--r--source/blender/render/extern/include/RE_engine.h2
-rw-r--r--source/blender/render/extern/include/RE_pipeline.h6
-rw-r--r--source/blender/render/extern/include/RE_render_ext.h7
-rw-r--r--source/blender/render/intern/include/render_types.h2
-rw-r--r--source/blender/render/intern/include/shading.h2
-rw-r--r--source/blender/render/intern/raytrace/rayobject_rtbuild.cpp12
-rw-r--r--source/blender/render/intern/raytrace/rayobject_rtbuild.h5
-rw-r--r--source/blender/render/intern/source/convertblender.c60
-rw-r--r--source/blender/render/intern/source/external_engine.c5
-rw-r--r--source/blender/render/intern/source/imagetexture.c4
-rw-r--r--source/blender/render/intern/source/initrender.c4
-rw-r--r--source/blender/render/intern/source/pipeline.c57
-rw-r--r--source/blender/render/intern/source/pointdensity.c54
-rw-r--r--source/blender/render/intern/source/rayshade.c41
-rw-r--r--source/blender/render/intern/source/render_texture.c8
-rw-r--r--source/blender/render/intern/source/shadeinput.c6
-rw-r--r--source/blender/render/intern/source/zbuf.c23
-rw-r--r--source/blender/windowmanager/CMakeLists.txt12
-rw-r--r--source/blender/windowmanager/WM_api.h10
-rw-r--r--source/blender/windowmanager/WM_types.h4
-rw-r--r--source/blender/windowmanager/intern/wm.c6
-rw-r--r--source/blender/windowmanager/intern/wm_draw.c25
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c283
-rw-r--r--source/blender/windowmanager/intern/wm_files.c147
-rw-r--r--source/blender/windowmanager/intern/wm_files_link.c9
-rw-r--r--source/blender/windowmanager/intern/wm_gesture.c21
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c8
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c102
-rw-r--r--source/blender/windowmanager/intern/wm_playanim.c15
-rw-r--r--source/blender/windowmanager/intern/wm_stereo.c14
-rw-r--r--source/blender/windowmanager/intern/wm_window.c41
-rw-r--r--source/blender/windowmanager/manipulators/WM_manipulator_api.h89
-rw-r--r--source/blender/windowmanager/manipulators/WM_manipulator_types.h219
-rw-r--r--source/blender/windowmanager/manipulators/intern/wm_manipulator.c279
-rw-r--r--source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c151
-rw-r--r--source/blender/windowmanager/manipulators/intern/wm_manipulator_group_type.c19
-rw-r--r--source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h40
-rw-r--r--source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c480
-rw-r--r--source/blender/windowmanager/manipulators/intern/wm_manipulator_target_props.c35
-rw-r--r--source/blender/windowmanager/manipulators/intern/wm_manipulator_type.c53
-rw-r--r--source/blender/windowmanager/manipulators/wm_manipulator_fn.h8
-rw-r--r--source/blender/windowmanager/manipulators/wm_manipulator_wmapi.h13
-rw-r--r--source/blender/windowmanager/wm_event_system.h5
-rw-r--r--source/blender/windowmanager/wm_files.h2
-rw-r--r--source/blenderplayer/CMakeLists.txt16
-rw-r--r--source/blenderplayer/bad_level_call_stubs/stubs.c48
-rw-r--r--source/creator/CMakeLists.txt61
-rw-r--r--source/creator/creator_args.c11
-rw-r--r--source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp2
-rw-r--r--source/gameengine/BlenderRoutines/CMakeLists.txt2
-rw-r--r--source/gameengine/Converter/BL_ArmatureObject.cpp3
-rw-r--r--source/gameengine/Converter/BL_BlenderDataConversion.cpp4
-rw-r--r--source/gameengine/Converter/BL_ModifierDeformer.cpp8
-rw-r--r--source/gameengine/Converter/CMakeLists.txt2
-rw-r--r--source/gameengine/Converter/KX_ConvertActuators.cpp2
-rw-r--r--source/gameengine/GameLogic/CMakeLists.txt3
-rw-r--r--source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp6
-rw-r--r--source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp2
-rw-r--r--source/gameengine/GamePlayer/ghost/CMakeLists.txt2
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Application.cpp2
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_ghost.cpp2
-rw-r--r--source/gameengine/Ketsji/CMakeLists.txt2
-rw-r--r--source/gameengine/Ketsji/KX_Camera.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_FontObject.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_NavMeshObject.cpp4
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.cpp5
-rw-r--r--source/gameengine/Ketsji/KX_SoundActuator.cpp12
-rw-r--r--source/gameengine/Ketsji/KX_SoundActuator.h4
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp1
-rw-r--r--source/gameengine/VideoTexture/FilterBase.cpp1
-rw-r--r--source/gameengine/VideoTexture/ImageBase.cpp1
-rw-r--r--tests/CMakeLists.txt5
-rw-r--r--tests/check_deprecated.py6
-rw-r--r--tests/gtests/alembic/CMakeLists.txt1
-rw-r--r--tests/gtests/alembic/abc_export_test.cc10
-rw-r--r--tests/gtests/blenlib/BLI_array_utils_test.cc2
-rw-r--r--tests/gtests/blenlib/BLI_kdopbvh_test.cc7
-rw-r--r--tests/gtests/blenlib/BLI_math_geom_test.cc2
-rw-r--r--tests/gtests/blenlib/BLI_memiter_test.cc206
-rw-r--r--tests/gtests/blenlib/BLI_polyfill2d_test.cc77
-rw-r--r--tests/gtests/blenlib/CMakeLists.txt30
-rw-r--r--tests/gtests/blenlib/stubs/bf_intern_eigen_stubs.h18
-rw-r--r--tests/python/CMakeLists.txt244
-rw-r--r--tests/python/batch_import.py6
-rw-r--r--tests/python/bl_alembic_import_test.py55
-rw-r--r--tests/python/bl_load_py_modules.py63
-rw-r--r--tests/python/bl_pyapi_bpy_utils_units.py19
-rw-r--r--tests/python/bl_run_operators.py6
-rwxr-xr-xtests/python/cycles_render_tests.py332
-rw-r--r--tests/python/render_layer/CMakeLists.txt2
-rw-r--r--tests/python/render_layer/render_layer_common.py9
-rw-r--r--tests/python/render_layer/test_evaluation_selectability_a.py1
-rw-r--r--tests/python/render_layer/test_evaluation_selectability_b.py1
-rw-r--r--tests/python/render_layer/test_evaluation_selectability_c.py1
-rw-r--r--tests/python/render_layer/test_evaluation_selectability_d.py1
-rw-r--r--tests/python/render_layer/test_evaluation_selectability_e.py1
-rw-r--r--tests/python/render_layer/test_evaluation_visibility_a.py1
-rw-r--r--tests/python/render_layer/test_evaluation_visibility_b.py1
-rw-r--r--tests/python/render_layer/test_evaluation_visibility_c.py1
-rw-r--r--tests/python/render_layer/test_evaluation_visibility_d.py1
-rw-r--r--tests/python/render_layer/test_evaluation_visibility_e.py1
-rw-r--r--tests/python/render_layer/test_evaluation_visibility_f.py1
-rw-r--r--tests/python/render_layer/test_object_copy.py1
-rw-r--r--tests/python/render_layer/test_object_link_b.py1
-rw-r--r--tests/python/render_layer/test_operator_context.py4
-rw-r--r--tests/python/render_layer/test_scene_copy_d.py2
-rw-r--r--tests/python/render_layer/test_scene_copy_f.py94
-rw-r--r--tests/python/render_layer/test_scene_delete.py39
2086 files changed, 118788 insertions, 52197 deletions
diff --git a/.gitignore b/.gitignore
index 977fd9c2627..814b7661bc6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,7 +21,6 @@ Desktop.ini
# commonly used paths in blender
/blender.bin
-/user-config.py
/BUILD_NOTES.txt
# local patches
@@ -34,8 +33,6 @@ Desktop.ini
/doc/python_api/sphinx-in/
/doc/python_api/sphinx-out/
/doc/python_api/rst/bmesh.ops.rst
-/doc/python_api/rst/in_menu.png
-/doc/python_api/rst/menu_id.png
-/doc/python_api/rst/op_prop.png
-/doc/python_api/rst/run_script.png
-/doc/python_api/rst/spacebar.png
+
+# in-source lib downloads
+/build_files/build_environment/downloads
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3da27fb52d5..6e6520cfdda 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -45,7 +45,7 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
endif()
endif()
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 3.5)
if(NOT EXECUTABLE_OUTPUT_PATH)
set(FIRST_RUN TRUE)
@@ -58,7 +58,9 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/build_files/cmake/Modules")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/build_files/cmake/platform")
# avoid having empty buildtype
-set(CMAKE_BUILD_TYPE_INIT "Release")
+if(NOT DEFINED CMAKE_BUILD_TYPE_INIT)
+ set(CMAKE_BUILD_TYPE_INIT "Release")
+endif()
# quiet output for Makefiles, 'make -s' helps too
# set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
@@ -289,7 +291,7 @@ if(WITH_X11)
endif()
if(UNIX AND NOT APPLE)
- option(WITH_SYSTEM_GLEW "Use GLEW OpenGL wrapper library provided by the operating system" ON)
+ option(WITH_SYSTEM_GLEW "Use GLEW OpenGL wrapper library provided by the operating system" OFF)
option(WITH_SYSTEM_GLES "Use OpenGL ES library provided by the operating system" ON)
else()
# not an option for other OS's
@@ -334,10 +336,6 @@ option(WITH_CODEC_SNDFILE "Enable libsndfile Support (http://www.mega-nerd
option(WITH_ALEMBIC "Enable Alembic Support" OFF)
option(WITH_ALEMBIC_HDF5 "Enable Legacy Alembic Support (not officially supported)" OFF)
-if(APPLE)
- option(WITH_CODEC_QUICKTIME "Enable Quicktime Support" OFF)
-endif()
-
# 3D format support
# Disable opencollada when we don't have precompiled libs
option(WITH_OPENCOLLADA "Enable OpenCollada Support (http://www.opencollada.org)" ${_init_OPENCOLLADA})
@@ -390,10 +388,14 @@ if(UNIX AND NOT APPLE)
endif()
option(WITH_PYTHON_INSTALL "Copy system python into the blender install folder" ON)
-if(WITH_PYTHON_INSTALL)
- option(WITH_PYTHON_INSTALL_NUMPY "Copy system numpy into the blender install folder" ON)
+if(WITH_PYTHON_INSTALL OR (WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE))
set(PYTHON_NUMPY_PATH "" CACHE PATH "Path to python site-packages or dist-packages containing 'numpy' module")
mark_as_advanced(PYTHON_NUMPY_PATH)
+ set(PYTHON_NUMPY_INCLUDE_DIRS ${PYTHON_NUMPY_PATH}/numpy/core/include CACHE PATH "Path to the include directory of the numpy module")
+ mark_as_advanced(PYTHON_NUMPY_INCLUDE_DIRS)
+endif()
+if(WITH_PYTHON_INSTALL)
+ option(WITH_PYTHON_INSTALL_NUMPY "Copy system numpy into the blender install folder" ON)
if(UNIX AND NOT APPLE)
option(WITH_PYTHON_INSTALL_REQUESTS "Copy system requests into the blender install folder" ON)
@@ -492,7 +494,12 @@ endif()
# Experimental support of C11 and C++11
#
# We default options to whatever default standard in the current compiler.
-if(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "6.0") AND (NOT WITH_CXX11))
+if(APPLE)
+ set(_c11_init ON)
+ set(_cxx11_init ON)
+ set(WITH_C11 ON)
+ set(WITH_CXX11 ON)
+elseif(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "6.0") AND (NOT WITH_CXX11))
set(_c11_init ON)
else()
set(_c11_init OFF)
@@ -573,6 +580,12 @@ if(NOT WITH_GAMEENGINE AND WITH_PLAYER)
message(FATAL_ERROR "WITH_PLAYER requires WITH_GAMEENGINE")
endif()
+if(NOT WITH_CXX11)
+ if(WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE)
+ message(FATAL_ERROR "WITH_AUDASPACE requires WITH_CXX11")
+ endif()
+endif()
+
if(NOT WITH_AUDASPACE)
if(WITH_OPENAL)
message(FATAL_ERROR "WITH_OPENAL requires WITH_AUDASPACE")
@@ -621,16 +634,11 @@ if(NOT WITH_BOOST)
endmacro()
set_and_warn(WITH_CYCLES OFF)
- set_and_warn(WITH_AUDASPACE OFF)
set_and_warn(WITH_INTERNATIONAL OFF)
set_and_warn(WITH_OPENVDB OFF)
set_and_warn(WITH_OPENCOLORIO OFF)
set_and_warn(WITH_MOD_BOOLEAN OFF)
-
- set_and_warn(WITH_OPENAL OFF) # depends on AUDASPACE
- set_and_warn(WITH_GAMEENGINE OFF) # depends on AUDASPACE
- set_and_warn(WITH_PLAYER OFF) # depends on GAMEENGINE
-elseif(WITH_CYCLES OR WITH_OPENIMAGEIO OR WITH_AUDASPACE OR WITH_INTERNATIONAL OR
+elseif(WITH_CYCLES OR WITH_OPENIMAGEIO OR WITH_INTERNATIONAL OR
WITH_OPENVDB OR WITH_OPENCOLORIO OR WITH_MOD_BOOLEAN)
# Keep enabled
else()
@@ -698,37 +706,12 @@ TEST_SHARED_PTR_SUPPORT()
TEST_UNORDERED_MAP_SUPPORT()
if(WITH_AUDASPACE)
- if(WITH_SYSTEM_AUDASPACE)
- set(AUDASPACE_DEFINITIONS
- -DWITH_AUDASPACE
- -DWITH_SYSTEM_AUDASPACE
- "-DAUD_DEVICE_H=<AUD_Device.h>"
- "-DAUD_SPECIAL_H=<AUD_Special.h>"
- "-DAUD_SOUND_H=<AUD_Sound.h>"
- "-DAUD_HANDLE_H=<AUD_Handle.h>"
- "-DAUD_SEQUENCE_H=<AUD_Sequence.h>"
- "-DAUD_TYPES_H=<AUD_Types.h>"
- "-DAUD_PYTHON_H=<python/PyAPI.h>"
- )
- else()
- set(AUDASPACE_C_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/intern/audaspace/intern")
- set(AUDASPACE_PY_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/intern/audaspace/intern")
- set(AUDASPACE_DEFINITIONS
- -DWITH_AUDASPACE
- "-DAUD_DEVICE_H=<AUD_C-API.h>"
- "-DAUD_SPECIAL_H=<AUD_C-API.h>"
- "-DAUD_SOUND_H=<AUD_C-API.h>"
- "-DAUD_HANDLE_H=<AUD_C-API.h>"
- "-DAUD_SEQUENCE_H=<AUD_C-API.h>"
- "-DAUD_TYPES_H=<AUD_Space.h>"
- )
+ if(NOT WITH_SYSTEM_AUDASPACE)
+ set(AUDASPACE_C_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/extern/audaspace/bindings/C" "${CMAKE_BINARY_DIR}/extern/audaspace")
+ set(AUDASPACE_PY_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/extern/audaspace/bindings")
endif()
endif()
-if(APPLE)
- apple_check_quicktime()
-endif()
-
#-----------------------------------------------------------------------------
# Check for valid directories
# ... a partial checkout may cause this.
@@ -1294,6 +1277,7 @@ if(CMAKE_COMPILER_IS_GNUCC)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_TYPE_LIMITS -Wtype-limits)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_FORMAT_SIGN -Wformat-signedness)
+ ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_RESTRICT -Wrestrict)
# gcc 4.2 gives annoying warnings on every file with this
if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3")
@@ -1335,6 +1319,7 @@ if(CMAKE_COMPILER_IS_GNUCC)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_WRITE_STRINGS -Wwrite-strings)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNDEF -Wundef)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_FORMAT_SIGN -Wformat-signedness)
+ ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_RESTRICT -Wrestrict)
# gcc 4.2 gives annoying warnings on every file with this
if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3")
@@ -1371,7 +1356,7 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
set(CMAKE_REQUIRED_FLAGS "-L${LIBDIR}/openmp/lib -liomp5") # these are only used for the checks
endif()
- # strange, clang complains these are not supported, but then yses them.
+ # strange, clang complains these are not supported, but then uses them.
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_RETURN_TYPE -Werror=return-type)
@@ -1445,6 +1430,7 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC")
"/wd4800" # forcing value to bool 'true' or 'false'
# errors:
"/we4013" # 'function' undefined; assuming extern returning int
+ "/we4133" # incompatible pointer types
"/we4431" # missing type specifier - int assumed
)
@@ -1467,10 +1453,15 @@ if(WITH_PYTHON)
)
endif()
- if(WIN32 OR APPLE)
+ if(WIN32)
# pass, we have this in an archive to extract
- elseif(WITH_PYTHON_INSTALL AND WITH_PYTHON_INSTALL_NUMPY)
- find_python_package(numpy)
+ elseif((WITH_PYTHON_INSTALL AND WITH_PYTHON_INSTALL_NUMPY) OR (WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE))
+ if(("${PYTHON_NUMPY_PATH}" STREQUAL "") OR (${PYTHON_NUMPY_PATH} MATCHES NOTFOUND))
+ find_python_package(numpy)
+ unset(PYTHON_NUMPY_INCLUDE_DIRS CACHE)
+ set(PYTHON_NUMPY_INCLUDE_DIRS ${PYTHON_NUMPY_PATH}/numpy/core/include CACHE PATH "Path to the include directory of the numpy module")
+ mark_as_advanced(PYTHON_NUMPY_INCLUDE_DIRS)
+ endif()
endif()
if(WIN32 OR APPLE)
@@ -1721,4 +1712,3 @@ endif()
if(0)
print_all_vars()
endif()
-
diff --git a/GNUmakefile b/GNUmakefile
index 7ee011911f8..1143ac6e1f1 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -43,6 +43,11 @@ ifndef BUILD_DIR
BUILD_DIR:=$(shell dirname "$(BLENDER_DIR)")/build_$(OS_NCASE)
endif
+# Dependencies DIR's
+DEPS_SOURCE_DIR:=$(BLENDER_DIR)/build_files/build_environment
+DEPS_BUILD_DIR:=$(BUILD_DIR)/deps
+DEPS_INSTALL_DIR:=$(shell dirname "$(BLENDER_DIR)")/lib/$(OS_NCASE)
+
# Allow to use alternative binary (pypy3, etc)
ifndef PYTHON
PYTHON:=python3
@@ -86,13 +91,7 @@ ifndef NPROCS
ifeq ($(OS), Linux)
NPROCS:=$(shell nproc)
endif
- ifeq ($(OS), Darwin)
- NPROCS:=$(shell sysctl -n hw.ncpu)
- endif
- ifeq ($(OS), FreeBSD)
- NPROCS:=$(shell sysctl -n hw.ncpu)
- endif
- ifeq ($(OS), NetBSD)
+ ifneq (,$(filter $(OS),Darwin FreeBSD NetBSD))
NPROCS:=$(shell sysctl -n hw.ncpu)
endif
endif
@@ -104,7 +103,7 @@ endif
CMAKE_CONFIG = cmake $(BUILD_CMAKE_ARGS) \
-H"$(BLENDER_DIR)" \
-B"$(BUILD_DIR)" \
- -DCMAKE_BUILD_TYPE:STRING=$(BUILD_TYPE)
+ -DCMAKE_BUILD_TYPE_INIT:STRING=$(BUILD_TYPE)
# -----------------------------------------------------------------------------
@@ -146,6 +145,27 @@ cycles: all
headless: all
bpy: all
+# -----------------------------------------------------------------------------
+# Build dependencies
+DEPS_TARGET = install
+ifneq "$(findstring clean, $(MAKECMDGOALS))" ""
+ DEPS_TARGET = clean
+endif
+
+deps: .FORCE
+ @echo
+ @echo Configuring dependencies in \"$(DEPS_BUILD_DIR)\"
+
+ @cmake -H"$(DEPS_SOURCE_DIR)" \
+ -B"$(DEPS_BUILD_DIR)" \
+ -DHARVEST_TARGET=$(DEPS_INSTALL_DIR)
+
+ @echo
+ @echo Building dependencies ...
+ $(MAKE) -C "$(DEPS_BUILD_DIR)" -s -j $(NPROCS) $(DEPS_TARGET)
+ @echo
+ @echo Dependencies successfully built and installed to $(DEPS_INSTALL_DIR).
+ @echo
# -----------------------------------------------------------------------------
# Configuration (save some cd'ing around)
@@ -164,6 +184,7 @@ help: .FORCE
@echo " * headless - build without an interface (renderfarm or server automation)"
@echo " * cycles - build Cycles standalone only, without Blender"
@echo " * bpy - build as a python module which can be loaded from python directly"
+ @echo " * deps - build library dependencies (intended only for platform maintainers)"
@echo ""
@echo " * config - run cmake configuration tool to set build options"
@echo ""
@@ -398,11 +419,17 @@ icons: .FORCE
"$(BLENDER_DIR)/release/datafiles/prvicons_update.py"
update: .FORCE
+ if [ "$(OS_NCASE)" == "darwin" ] && [ ! -d "../lib/$(OS_NCASE)" ]; then \
+ svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/$(OS_NCASE) ../lib/$(OS_NCASE) ; \
+ fi
if [ -d "../lib" ]; then \
+ svn cleanup ../lib/* ; \
svn update ../lib/* ; \
fi
git pull --rebase
- git submodule update --remote
+ git submodule update --init --recursive
+ git submodule foreach git checkout master
+ git submodule foreach git pull --rebase origin master
# -----------------------------------------------------------------------------
diff --git a/build_files/build_environment/CMakeLists.txt b/build_files/build_environment/CMakeLists.txt
new file mode 100644
index 00000000000..9f7eb3c2c50
--- /dev/null
+++ b/build_files/build_environment/CMakeLists.txt
@@ -0,0 +1,132 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+####################################################################################################
+#
+# This is a build system used by platform maintainers to build library dependencies on
+# Windows and macOS. There is some support for Linux as well, but not ready for releases.
+#
+# Windows and macOS users should download the precompiled libraries in lib/, Linux users
+# should run install_deps.sh for building dependencies.
+#
+# WINDOWS USAGE:
+# Don't call this cmake file your self, use build_deps.cmd
+# build_deps 2013 x64 / build_deps 2013 x86
+# build_deps 2015 x64 / build_deps 2015 x86
+#
+# MAC OS X USAGE:
+# Install with homebrew: brew install autoconf automake libtool yasm openssl xz
+# Run "make deps" from main Blender directory
+#
+# LINUX USAGE:
+# Install compiler, cmake, autoconf, automake, libtool, yasm
+# Run "make deps" from main Blender directory
+#
+####################################################################################################
+
+project("BlenderDependencies")
+cmake_minimum_required(VERSION 3.5)
+
+include(ExternalProject)
+include(cmake/options.cmake)
+include(cmake/versions.cmake)
+include(cmake/zlib.cmake)
+include(cmake/blendthumb.cmake)
+include(cmake/openal.cmake)
+include(cmake/png.cmake)
+include(cmake/jpeg.cmake)
+include(cmake/boost.cmake)
+include(cmake/blosc.cmake)
+include(cmake/pthreads.cmake)
+include(cmake/ilmbase.cmake)
+include(cmake/openexr.cmake)
+include(cmake/freetype.cmake)
+include(cmake/freeglut.cmake)
+include(cmake/glew.cmake)
+include(cmake/hdf5.cmake)
+include(cmake/alembic.cmake)
+include(cmake/glfw.cmake)
+include(cmake/clew.cmake)
+include(cmake/cuew.cmake)
+include(cmake/opensubdiv.cmake)
+include(cmake/sdl.cmake)
+include(cmake/opencollada.cmake)
+include(cmake/opencolorio.cmake)
+include(cmake/llvm.cmake)
+include(cmake/clang.cmake)
+include(cmake/openimageio.cmake)
+include(cmake/tiff.cmake)
+include(cmake/flexbison.cmake)
+include(cmake/osl.cmake)
+include(cmake/tbb.cmake)
+include(cmake/openvdb.cmake)
+include(cmake/python.cmake)
+include(cmake/python_site_packages.cmake)
+include(cmake/numpy.cmake)
+if (WITH_WEBP)
+ include(cmake/webp.cmake)
+endif()
+if(WIN32)
+ include(cmake/hidapi.cmake)
+endif()
+
+if(ENABLE_MINGW64)
+ if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
+ include(cmake/setup_mingw64.cmake)
+ else()
+ include(cmake/setup_mingw32.cmake)
+ endif()
+else()
+ set(mingw_LIBDIR ${LIBDIR})
+endif()
+
+if(NOT WIN32 OR ENABLE_MINGW64)
+ include(cmake/openjpeg.cmake)
+ if(BUILD_MODE STREQUAL Release)
+ if(WIN32)
+ include(cmake/zlib_mingw.cmake)
+ endif()
+ include(cmake/lame.cmake)
+ include(cmake/ogg.cmake)
+ include(cmake/vorbis.cmake)
+ include(cmake/theora.cmake)
+ include(cmake/vpx.cmake)
+ include(cmake/orc.cmake)
+ include(cmake/schroedinger.cmake)
+ include(cmake/x264.cmake)
+ include(cmake/xvidcore.cmake)
+ include(cmake/faad.cmake)
+ include(cmake/ffmpeg.cmake)
+ include(cmake/fftw.cmake)
+ include(cmake/sndfile.cmake)
+ if(WIN32)
+ include(cmake/iconv.cmake)
+ include(cmake/lapack.cmake)
+ endif()
+ if(UNIX)
+ include(cmake/flac.cmake)
+ if(NOT APPLE)
+ include(cmake/spnav.cmake)
+ include(cmake/jemalloc.cmake)
+ include(cmake/xml2.cmake)
+ endif()
+ endif()
+ endif()
+endif()
+
+include(cmake/harvest.cmake)
diff --git a/build_files/build_environment/cmake/alembic.cmake b/build_files/build_environment/cmake/alembic.cmake
new file mode 100644
index 00000000000..a49047ec102
--- /dev/null
+++ b/build_files/build_environment/cmake/alembic.cmake
@@ -0,0 +1,75 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+if(ALEMBIC_HDF5)
+ set(ALEMBIC_HDF5_HL)
+ # in debug mode we do not build HDF5_hdf5_hl_LIBRARY which makes cmake really
+ # unhappy, stub it with the debug mode lib. it's not linking it in at this
+ # point in time anyhow
+ if(BUILD_MODE STREQUAL Debug)
+ set(ALEMBIC_HDF5_HL -DHDF5_hdf5_hl_LIBRARY=${LIBDIR}/hdf5/lib/libhdf5_hl_D.${LIBEXT})
+ endif()
+endif()
+
+set(ALEMBIC_EXTRA_ARGS
+ -DBUILDSTATIC=ON
+ -DLINKSTATIC=ON
+ -DALEMBIC_LIB_USES_BOOST=ON
+ -DBoost_COMPILER:STRING=${BOOST_COMPILER_STRING}
+ -DBoost_USE_MULTITHREADED=ON
+ -DUSE_STATIC_BOOST=On
+ -DBoost_USE_STATIC_LIBS=ON
+ -DBoost_USE_STATIC_RUNTIME=ON
+ -DBoost_DEBUG=ON
+ -DBOOST_ROOT=${LIBDIR}/boost
+ -DBoost_NO_SYSTEM_PATHS=ON
+ -DILMBASE_ROOT=${LIBDIR}/ilmbase
+ -DALEMBIC_ILMBASE_INCLUDE_DIRECTORY=${LIBDIR}/ilmbase/include/OpenEXR
+ -DALEMBIC_ILMBASE_HALF_LIB=${LIBDIR}/ilmbase/lib/${LIBPREFIX}Half${LIBEXT}
+ -DALEMBIC_ILMBASE_IMATH_LIB=${LIBDIR}/ilmbase/lib/${LIBPREFIX}Imath-2_2${LIBEXT}
+ -DALEMBIC_ILMBASE_ILMTHREAD_LIB=${LIBDIR}/ilmbase/lib/${LIBPREFIX}IlmThread-2_2${LIBEXT}
+ -DALEMBIC_ILMBASE_IEX_LIB=${LIBDIR}/ilmbase/lib/${LIBPREFIX}Iex-2_2${LIBEXT}
+ -DUSE_PYILMBASE=0
+ -DUSE_PYALEMBIC=0
+ -DUSE_ARNOLD=0
+ -DUSE_MAYA=0
+ -DUSE_PRMAN=0
+ -DUSE_HDF5=Off
+ -DUSE_STATIC_HDF5=Off
+ -DHDF5_ROOT=${LIBDIR}/hdf5
+ -DUSE_TESTS=Off
+ -DALEMBIC_NO_OPENGL=1
+ -DUSE_BINARIES=ON
+ -DALEMBIC_ILMBASE_LINK_STATIC=On
+ -DALEMBIC_SHARED_LIBS=OFF
+ -DGLUT_INCLUDE_DIR=""
+ -DZLIB_LIBRARY=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY}
+ -DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include/
+ ${ALEMBIC_HDF5_HL}
+)
+
+ExternalProject_Add(external_alembic
+ URL ${ALEMBIC_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${ALEMBIC_MD5}
+ PREFIX ${BUILD_DIR}/alembic
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/alembic -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${ALEMBIC_EXTRA_ARGS}
+ INSTALL_DIR ${LIBDIR}/alembic
+)
+
+add_dependencies(external_alembic external_boost external_zlib external_ilmbase)
diff --git a/build_files/build_environment/cmake/blendthumb.cmake b/build_files/build_environment/cmake/blendthumb.cmake
new file mode 100644
index 00000000000..624869971c6
--- /dev/null
+++ b/build_files/build_environment/cmake/blendthumb.cmake
@@ -0,0 +1,61 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+if(BUILD_MODE STREQUAL Release)
+ if(WIN32)
+ set(THUMB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../release/windows/blendthumb)
+
+ ExternalProject_Add(external_zlib_32
+ URL ${ZLIB_URI}
+ CMAKE_GENERATOR ${GENERATOR_32}
+ URL_HASH MD5=${ZLIB_HASH}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ PREFIX ${BUILD_DIR}/zlib32
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/zlib32 ${DEFAULT_CMAKE_FLAGS}
+ INSTALL_DIR ${LIBDIR}/zlib32
+ )
+
+ ExternalProject_Add(external_zlib_64
+ URL ${ZLIB_URI}
+ CMAKE_GENERATOR ${GENERATOR_64}
+ URL_HASH MD5=${ZLIB_HASH}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ PREFIX ${BUILD_DIR}/zlib64
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/zlib64 ${DEFAULT_CMAKE_FLAGS}
+ INSTALL_DIR ${LIBDIR}/zlib64
+ )
+
+ ExternalProject_Add(external_blendthumb_32
+ CMAKE_GENERATOR ${GENERATOR_32}
+ SOURCE_DIR ${THUMB_DIR}
+ PREFIX ${BUILD_DIR}/blendthumb32
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/blendThumb32 ${DEFAULT_CMAKE_FLAGS} -DZLIB_INCLUDE=${LIBDIR}/zlib32/include -DZLIB_LIBS=${LIBDIR}/zlib32/lib/zlibstatic.lib
+ INSTALL_DIR ${LIBDIR}/blendthumb32
+ )
+ add_dependencies(external_blendthumb_32 external_zlib_32)
+
+ ExternalProject_Add(external_blendthumb_64
+ CMAKE_GENERATOR ${GENERATOR_64}
+ SOURCE_DIR ${THUMB_DIR}
+ PREFIX ${BUILD_DIR}/blendthumb64
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/blendThumb64 ${DEFAULT_CMAKE_FLAGS} -DZLIB_INCLUDE=${LIBDIR}/zlib64/include -DZLIB_LIBS=${LIBDIR}/zlib64/lib/zlibstatic.lib
+ INSTALL_DIR ${LIBDIR}/blendthumb64
+ )
+ add_dependencies(external_blendthumb_64 external_zlib_64)
+ endif()
+endif()
diff --git a/build_files/build_environment/cmake/blosc.cmake b/build_files/build_environment/cmake/blosc.cmake
new file mode 100644
index 00000000000..68df525b802
--- /dev/null
+++ b/build_files/build_environment/cmake/blosc.cmake
@@ -0,0 +1,43 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(BLOSC_EXTRA_ARGS
+ -DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include/
+ -DZLIB_LIBRARY=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY}
+ -DBUILD_TESTS=OFF
+ -DBUILD_BENCHMARKS=OFF
+ -DCMAKE_DEBUG_POSTFIX=_d
+ -DThreads_FOUND=1
+ -DPTHREAD_LIBS=${LIBDIR}/pthreads/lib/pthreadVC2.lib
+ -DPTHREAD_INCLUDE_DIR=${LIBDIR}/pthreads/inc
+)
+
+ExternalProject_Add(external_blosc
+ URL ${BLOSC_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${BLOSC_HASH}
+ PREFIX ${BUILD_DIR}/blosc
+ PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/blosc/src/external_blosc < ${PATCH_DIR}/blosc.diff
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/blosc ${DEFAULT_CMAKE_FLAGS} ${BLOSC_EXTRA_ARGS}
+ INSTALL_DIR ${LIBDIR}/blosc
+)
+
+add_dependencies(external_blosc external_zlib)
+if(WIN32)
+ add_dependencies(external_blosc external_pthreads)
+endif()
diff --git a/build_files/build_environment/cmake/boost.cmake b/build_files/build_environment/cmake/boost.cmake
new file mode 100644
index 00000000000..d98df30a38f
--- /dev/null
+++ b/build_files/build_environment/cmake/boost.cmake
@@ -0,0 +1,107 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+if(WIN32)
+ if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
+ set(PYTHON_ARCH x64)
+ set(PYTHON_ARCH2 win-AMD64)
+ set(PYTHON_OUTPUTDIR ${BUILD_DIR}/python/src/external_python/pcbuild/amd64/)
+ else()
+ set(PYTHON_ARCH x86)
+ set(PYTHON_ARCH2 win32)
+ set(PYTHON_OUTPUTDIR ${BUILD_DIR}/python/src/external_python/pcbuild/win32/)
+ endif()
+ if(MSVC12)
+ set(BOOST_TOOLSET toolset=msvc-12.0)
+ set(BOOST_COMPILER_STRING -vc120)
+ set(PYTHON_COMPILER_STRING v120)
+ endif()
+ if(MSVC14)
+ set(BOOST_TOOLSET toolset=msvc-14.0)
+ set(BOOST_COMPILER_STRING -vc140)
+ set(PYTHON_COMPILER_STRING v140)
+ endif()
+ set(JAM_FILE ${BUILD_DIR}/boost/src/external_boost/user-config.jam)
+ set(semi_path "${PATCH_DIR}/semi.txt")
+ FILE(TO_NATIVE_PATH ${semi_path} semi_path)
+ set(BOOST_CONFIGURE_COMMAND bootstrap.bat &&
+ echo using python : ${PYTHON_OUTPUTDIR}\\python.exe > "${JAM_FILE}" &&
+ echo. : ${BUILD_DIR}/python/src/external_python/include ${BUILD_DIR}/python/src/external_python/pc >> "${JAM_FILE}" &&
+ echo. : ${BUILD_DIR}/python/src/external_python/pcbuild >> "${JAM_FILE}" &&
+ type ${semi_path} >> "${JAM_FILE}"
+ )
+ set(BOOST_BUILD_COMMAND bjam)
+ #--user-config=user-config.jam
+ set(BOOST_BUILD_OPTIONS runtime-link=static )
+ #set(BOOST_WITH_PYTHON --with-python)
+ set(BOOST_HARVEST_CMD ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/boost/lib/ ${HARVEST_TARGET}/boost/lib/ )
+ if(BUILD_MODE STREQUAL Release)
+ set(BOOST_HARVEST_CMD ${BOOST_HARVEST_CMD} && ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/boost/include/boost-1_60/ ${HARVEST_TARGET}/boost/include/)
+ endif()
+
+elseif(APPLE)
+ set(BOOST_CONFIGURE_COMMAND ./bootstrap.sh)
+ set(BOOST_BUILD_COMMAND ./bjam)
+ set(BOOST_BUILD_OPTIONS toolset=clang cxxflags=${PLATFORM_CXXFLAGS} linkflags=${PLATFORM_LDFLAGS} --disable-icu boost.locale.icu=off)
+ set(BOOST_HARVEST_CMD echo .)
+else()
+ set(BOOST_HARVEST_CMD echo .)
+ set(BOOST_CONFIGURE_COMMAND ./bootstrap.sh)
+ set(BOOST_BUILD_COMMAND ./bjam)
+ set(BOOST_BUILD_OPTIONS cxxflags=${PLATFORM_CXXFLAGS} --disable-icu boost.locale.icu=off)
+endif()
+
+set(BOOST_OPTIONS
+ --with-filesystem
+ --with-locale
+ --with-thread
+ --with-regex
+ --with-system
+ --with-date_time
+ --with-wave
+ --with-atomic
+ --with-serialization
+ --with-program_options
+ --with-iostreams
+ ${BOOST_WITH_PYTHON}
+ ${BOOST_TOOLSET}
+)
+
+if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
+ set(BOOST_ADDRESS_MODEL 64)
+else()
+ set(BOOST_ADDRESS_MODEL 32)
+endif()
+
+string(TOLOWER ${BUILD_MODE} BOOST_BUILD_TYPE)
+
+ExternalProject_Add(external_boost
+ URL ${BOOST_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${BOOST_MD5}
+ PREFIX ${BUILD_DIR}/boost
+ UPDATE_COMMAND ""
+ CONFIGURE_COMMAND ${BOOST_CONFIGURE_COMMAND}
+ BUILD_COMMAND ${BOOST_BUILD_COMMAND} ${BOOST_BUILD_OPTIONS} -j${MAKE_THREADS} architecture=x86 address-model=${BOOST_ADDRESS_MODEL} variant=${BOOST_BUILD_TYPE} link=static threading=multi ${BOOST_OPTIONS} --prefix=${LIBDIR}/boost install
+ BUILD_IN_SOURCE 1
+ INSTALL_COMMAND "${BOOST_HARVEST_CMD}"
+)
+
+if(WIN32)
+ add_dependencies(external_boost Make_Python_Environment)
+endif()
diff --git a/build_files/build_environment/cmake/clang.cmake b/build_files/build_environment/cmake/clang.cmake
new file mode 100644
index 00000000000..2c7f271b5fc
--- /dev/null
+++ b/build_files/build_environment/cmake/clang.cmake
@@ -0,0 +1,51 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(CLANG_EXTRA_ARGS
+ -DCLANG_PATH_TO_LLVM_SOURCE=${BUILD_DIR}/ll/src/ll
+ -DCLANG_PATH_TO_LLVM_BUILD=${LIBDIR}/llvm
+ -DLLVM_USE_CRT_RELEASE=MT
+ -DLLVM_USE_CRT_DEBUG=MTd
+)
+ExternalProject_Add(external_clang
+ URL ${CLANG_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${CLANG_HASH}
+ PATCH_COMMAND ${PATCH_CMD} -p 2 -N -R -d ${BUILD_DIR}/clang/src/external_clang < ${PATCH_DIR}/clang.diff
+ PREFIX ${BUILD_DIR}/clang
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/clang ${DEFAULT_CMAKE_FLAGS} ${CLANG_EXTRA_ARGS}
+ INSTALL_DIR ${LIBDIR}/clang
+)
+
+if (MSVC)
+ if (BUILD_MODE STREQUAL Release)
+ set(CLANG_HARVEST_COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/clang/ ${HARVEST_TARGET}/llvm/ )
+ else()
+ set(CLANG_HARVEST_COMMAND
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/clang/lib/ ${HARVEST_TARGET}/llvm/debug/lib/ &&
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/clang/bin/ ${HARVEST_TARGET}/llvm/debug/bin/ &&
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/clang/include/ ${HARVEST_TARGET}/llvm/debug/include/
+ )
+ endif()
+ ExternalProject_Add_Step(external_clang after_install
+ COMMAND ${CLANG_HARVEST_COMMAND}
+ DEPENDEES mkdir update patch download configure build install
+ )
+endif()
+
+add_dependencies(external_clang ll)
diff --git a/build_files/build_environment/cmake/clew.cmake b/build_files/build_environment/cmake/clew.cmake
new file mode 100644
index 00000000000..0dcc1f24db7
--- /dev/null
+++ b/build_files/build_environment/cmake/clew.cmake
@@ -0,0 +1,28 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(CLEW_EXTRA_ARGS)
+
+ExternalProject_Add(external_clew
+ URL ${CLEW_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${CLEW_HASH}
+ PREFIX ${BUILD_DIR}/clew
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/clew -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${CLEW_EXTRA_ARGS}
+ INSTALL_DIR ${LIBDIR}/clew
+)
diff --git a/build_files/build_environment/cmake/cuew.cmake b/build_files/build_environment/cmake/cuew.cmake
new file mode 100644
index 00000000000..99b7bb5c06d
--- /dev/null
+++ b/build_files/build_environment/cmake/cuew.cmake
@@ -0,0 +1,29 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(CUEW_EXTRA_ARGS)
+
+ExternalProject_Add(external_cuew
+ URL ${CUEW_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${CUEW_HASH}
+ PREFIX ${BUILD_DIR}/cuew
+ PATCH_COMMAND ${PATCH_CMD} --verbose -p 0 -N -d ${BUILD_DIR}/cuew/src/external_cuew < ${PATCH_DIR}/cuew.diff
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/cuew -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${CUEW_EXTRA_ARGS}
+ INSTALL_DIR ${LIBDIR}/cuew
+)
diff --git a/build_files/build_environment/cmake/faad.cmake b/build_files/build_environment/cmake/faad.cmake
new file mode 100644
index 00000000000..3dd90971b84
--- /dev/null
+++ b/build_files/build_environment/cmake/faad.cmake
@@ -0,0 +1,35 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(FAAD_EXTRA_ARGS)
+
+ExternalProject_Add(external_faad
+ URL ${FAAD_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${FAAD_HASH}
+ PREFIX ${BUILD_DIR}/faad
+ PATCH_COMMAND ${PATCH_CMD} --verbose -p 0 -N -d ${BUILD_DIR}/faad/src/external_faad < ${PATCH_DIR}/libfaad.diff
+ CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/faad/src/external_faad/ && ${CONFIGURE_COMMAND} --disable-shared --enable-static --prefix=${LIBDIR}/faad
+ BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/faad/src/external_faad/ && make -j${MAKE_THREADS}
+ INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/faad/src/external_faad/ && make install
+ INSTALL_DIR ${LIBDIR}/faad
+)
+
+if(MSVC)
+ set_target_properties(external_faad PROPERTIES FOLDER Mingw)
+endif()
diff --git a/build_files/build_environment/cmake/ffmpeg.cmake b/build_files/build_environment/cmake/ffmpeg.cmake
new file mode 100644
index 00000000000..2a45849acf5
--- /dev/null
+++ b/build_files/build_environment/cmake/ffmpeg.cmake
@@ -0,0 +1,119 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(FFMPEG_CFLAGS "-I${mingw_LIBDIR}/lame/include -I${mingw_LIBDIR}/openjpeg/include/ -I${mingw_LIBDIR}/ogg/include -I${mingw_LIBDIR}/vorbis/include -I${mingw_LIBDIR}/theora/include -I${mingw_LIBDIR}/vpx/include -I${mingw_LIBDIR}/x264/include -I${mingw_LIBDIR}/xvidcore/include -I${mingw_LIBDIR}/dirac/include/dirac -I${mingw_LIBDIR}/schroedinger/include/schroedinger-1.0 -I${mingw_LIBDIR}/zlib/include")
+set(FFMPEG_LDFLAGS "-L${mingw_LIBDIR}/lame/lib -L${mingw_LIBDIR}/openjpeg/lib -L${mingw_LIBDIR}/ogg/lib -L${mingw_LIBDIR}/vorbis/lib -L${mingw_LIBDIR}/theora/lib -L${mingw_LIBDIR}/vpx/lib -L${mingw_LIBDIR}/x264/lib -L${mingw_LIBDIR}/xvidcore/lib -L${mingw_LIBDIR}/dirac/lib -L${mingw_LIBDIR}/schroedinger/lib -L${mingw_LIBDIR}/orc/lib -L${mingw_LIBDIR}/zlib/lib")
+set(FFMPEG_EXTRA_FLAGS --extra-cflags=${FFMPEG_CFLAGS} --extra-ldflags=${FFMPEG_LDFLAGS})
+set(FFMPEG_ENV PKG_CONFIG_PATH=${mingw_LIBDIR}/schroedinger/lib/pkgconfig:${mingw_LIBDIR}/orc/lib/pkgconfig:${mingw_LIBDIR}/x264/lib/pkgconfig:${mingw_LIBDIR})
+
+if(WIN32)
+ set(FFMPEG_ENV set ${FFMPEG_ENV} &&)
+ set(FFMPEG_EXTRA_FLAGS
+ ${FFMPEG_EXTRA_FLAGS}
+ --disable-static
+ --enable-shared
+ --enable-w32threads
+ --disable-pthreads
+ --enable-libopenjpeg
+ )
+else()
+ set(FFMPEG_EXTRA_FLAGS
+ ${FFMPEG_EXTRA_FLAGS}
+ --enable-static
+ --disable-shared
+ --enable-libopenjpeg)
+endif()
+
+if(APPLE)
+ set(FFMPEG_EXTRA_FLAGS
+ ${FFMPEG_EXTRA_FLAGS}
+ --target-os=darwin
+ )
+endif()
+
+ExternalProject_Add(external_ffmpeg
+ URL ${FFMPEG_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${FFMPEG_HASH}
+ PREFIX ${BUILD_DIR}/ffmpeg
+ CONFIGURE_COMMAND ${CONFIGURE_ENV_NO_PERL} &&
+ cd ${BUILD_DIR}/ffmpeg/src/external_ffmpeg/ &&
+ ${FFMPEG_ENV} ${CONFIGURE_COMMAND_NO_TARGET} ${FFMPEG_EXTRA_FLAGS}
+ --disable-lzma
+ --disable-avfilter
+ --disable-vdpau
+ --disable-bzlib
+ --disable-libgsm
+ --disable-libspeex
+ --enable-libvpx
+ --prefix=${LIBDIR}/ffmpeg
+ --enable-libschroedinger
+ --enable-libtheora
+ --enable-libvorbis
+ --enable-zlib
+ --enable-stripping
+ --enable-runtime-cpudetect
+ --disable-vaapi
+ --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-debug
+ --enable-optimizations
+ --disable-sse
+ --disable-ssse3
+ --enable-ffplay
+ --disable-openssl
+ --disable-securetransport
+ --disable-indev=avfoundation
+ --disable-indev=qtkit
+ --disable-sdl
+ --disable-gnutls
+ --disable-vda
+ --disable-videotoolbox
+ --disable-libxcb
+ --disable-xlib
+ --disable-audiotoolbox
+ --disable-cuvid
+ --disable-nvenc
+ --disable-indev=jack
+ --disable-indev=alsa
+ --disable-outdev=alsa
+ PATCH_COMMAND ${PATCH_CMD} --verbose -p 0 -N -d ${BUILD_DIR}/ffmpeg/src/external_ffmpeg < ${PATCH_DIR}/ffmpeg.diff
+ BUILD_COMMAND ${CONFIGURE_ENV_NO_PERL} && cd ${BUILD_DIR}/ffmpeg/src/external_ffmpeg/ && make -j${MAKE_THREADS}
+ INSTALL_COMMAND ${CONFIGURE_ENV_NO_PERL} && cd ${BUILD_DIR}/ffmpeg/src/external_ffmpeg/ && make install
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/ffmpeg ${DEFAULT_CMAKE_FLAGS}
+ INSTALL_DIR ${LIBDIR}/ffmpeg
+)
+
+if(MSVC)
+ set_target_properties(external_ffmpeg PROPERTIES FOLDER Mingw)
+endif(MSVC)
+
+add_dependencies(external_ffmpeg external_zlib external_faad external_openjpeg external_xvidcore external_x264 external_schroedinger external_vpx external_theora external_vorbis external_ogg external_lame)
+if(WIN32)
+ add_dependencies(external_ffmpeg external_zlib_mingw)
+endif()
diff --git a/build_files/build_environment/cmake/fftw.cmake b/build_files/build_environment/cmake/fftw.cmake
new file mode 100644
index 00000000000..e6e6165199c
--- /dev/null
+++ b/build_files/build_environment/cmake/fftw.cmake
@@ -0,0 +1,40 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(FFTW_EXTRA_ARGS)
+
+if(WIN32)
+ set(FFTW3_ENV set CFLAGS=-fno-stack-check -fno-stack-protector -mno-stack-arg-probe -fno-lto &&)
+ set(FFTW3_PATCH_COMMAND ${PATCH_CMD} --verbose -p 0 -N -d ${BUILD_DIR}/fftw3/src/external_fftw3 < ${PATCH_DIR}/fftw3.diff)
+endif()
+
+ExternalProject_Add(external_fftw3
+ URL ${FFTW_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${FFTW_HASH}
+ PREFIX ${BUILD_DIR}/fftw3
+ CONFIGURE_COMMAND ${CONFIGURE_ENV} && ${FFTW3_ENV} cd ${BUILD_DIR}/fftw3/src/external_fftw3/ && ${CONFIGURE_COMMAND} --enable-static --prefix=${mingw_LIBDIR}/fftw3
+ PATCH_COMMAND ${FFTW3_PATCH_COMMAND}
+ BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/fftw3/src/external_fftw3/ && make -j${MAKE_THREADS}
+ INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/fftw3/src/external_fftw3/ && make install
+ INSTALL_DIR ${LIBDIR}/fftw3
+)
+
+if(MSVC)
+ set_target_properties(external_fftw3 PROPERTIES FOLDER Mingw)
+endif(MSVC)
diff --git a/build_files/build_environment/cmake/flac.cmake b/build_files/build_environment/cmake/flac.cmake
new file mode 100644
index 00000000000..74d222632d0
--- /dev/null
+++ b/build_files/build_environment/cmake/flac.cmake
@@ -0,0 +1,32 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+ExternalProject_Add(external_flac
+ URL ${FLAC_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH SHA256=${FLAC_HASH}
+ PREFIX ${BUILD_DIR}/flac
+ CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/flac/src/external_flac/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/flac --disable-shared --enable-static
+ BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/flac/src/external_flac/ && make -j${MAKE_THREADS}
+ INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/flac/src/external_flac/ && make install
+ INSTALL_DIR ${LIBDIR}/flac
+)
+
+if(MSVC)
+ set_target_properties(external_flac PROPERTIES FOLDER Mingw)
+endif(MSVC)
diff --git a/build_files/build_environment/cmake/flexbison.cmake b/build_files/build_environment/cmake/flexbison.cmake
new file mode 100644
index 00000000000..f2908e1ce2c
--- /dev/null
+++ b/build_files/build_environment/cmake/flexbison.cmake
@@ -0,0 +1,31 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(FLEXBISON_EXTRA_ARGS)
+
+ExternalProject_Add(external_flexbison
+ URL ${FLEXBISON_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${FLEXBISON_HASH}
+ PREFIX ${BUILD_DIR}/flexbison
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/flexbison ${DEFAULT_CMAKE_FLAGS} ${FLEXBISON_EXTRA_ARGS}
+ CONFIGURE_COMMAND echo .
+ BUILD_COMMAND echo .
+ INSTALL_COMMAND COMMAND ${CMAKE_COMMAND} -E copy_directory ${BUILD_DIR}/flexbison/src/external_flexbison/ ${LIBDIR}/flexbison/
+ INSTALL_DIR ${LIBDIR}/flexbison
+)
diff --git a/build_files/build_environment/cmake/freeglut.cmake b/build_files/build_environment/cmake/freeglut.cmake
new file mode 100644
index 00000000000..043b382e8fd
--- /dev/null
+++ b/build_files/build_environment/cmake/freeglut.cmake
@@ -0,0 +1,35 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+if(WIN32)
+ if(BUILD_MODE STREQUAL Release)
+ set(FREEGLUT_EXTRA_ARGS
+ -DFREEGLUT_BUILD_SHARED_LIBS=Off
+ -DFREEGLUT_BUILD_STATIC_LIBS=On
+ )
+
+ ExternalProject_Add(external_freeglut
+ URL ${FREEGLUT_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${FREEGLUT_HASH}
+ PREFIX ${BUILD_DIR}/freeglut
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/freeglut ${DEFAULT_C_FLAGS} ${DEFAULT_CXX_FLAGS} ${FREEGLUT_EXTRA_ARGS}
+ INSTALL_DIR ${LIBDIR}/freeglut
+ )
+ endif()
+endif()
diff --git a/build_files/build_environment/cmake/freetype.cmake b/build_files/build_environment/cmake/freetype.cmake
new file mode 100644
index 00000000000..751b2b1f383
--- /dev/null
+++ b/build_files/build_environment/cmake/freetype.cmake
@@ -0,0 +1,28 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(FREETYPE_EXTRA_ARGS -DCMAKE_RELEASE_POSTFIX:STRING=2ST -DCMAKE_DEBUG_POSTFIX:STRING=2ST_d -DWITH_BZip2=OFF -DWITH_HarfBuzz=OFF)
+
+ExternalProject_Add(external_freetype
+ URL ${FREETYPE_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${FREETYPE_HASH}
+ PREFIX ${BUILD_DIR}/freetype
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/freetype ${DEFAULT_CMAKE_FLAGS} ${FREETYPE_EXTRA_ARGS}
+ INSTALL_DIR ${LIBDIR}/freetype
+)
diff --git a/build_files/build_environment/cmake/glew.cmake b/build_files/build_environment/cmake/glew.cmake
new file mode 100644
index 00000000000..b5d9e4d3310
--- /dev/null
+++ b/build_files/build_environment/cmake/glew.cmake
@@ -0,0 +1,32 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(GLEW_EXTRA_ARGS
+ -DBUILD_UTILS=Off
+ -DBUILD_SHARED_LIBS=Off
+)
+
+ExternalProject_Add(external_glew
+ URL ${GLEW_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${GLEW_HASH}
+ PATCH_COMMAND COMMAND ${CMAKE_COMMAND} -E copy ${PATCH_DIR}/cmakelists_glew.txt ${BUILD_DIR}/glew/src/external_glew/CMakeLists.txt
+ PREFIX ${BUILD_DIR}/glew
+ CMAKE_ARGS -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_INSTALL_PREFIX=${LIBDIR}/glew ${DEFAULT_CMAKE_FLAGS} ${GLEW_EXTRA_ARGS}
+ INSTALL_DIR ${LIBDIR}/glew
+)
diff --git a/build_files/build_environment/cmake/glfw.cmake b/build_files/build_environment/cmake/glfw.cmake
new file mode 100644
index 00000000000..ae80080525c
--- /dev/null
+++ b/build_files/build_environment/cmake/glfw.cmake
@@ -0,0 +1,28 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(GLFW_EXTRA_ARGS)
+
+ExternalProject_Add(external_glfw
+ URL ${GLFW_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${GLFW_HASH}
+ PREFIX ${BUILD_DIR}/glfw
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/glfw -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${GLFW_EXTRA_ARGS}
+ INSTALL_DIR ${LIBDIR}/glfw
+)
diff --git a/build_files/build_environment/cmake/harvest.cmake b/build_files/build_environment/cmake/harvest.cmake
new file mode 100644
index 00000000000..a430c4b33bf
--- /dev/null
+++ b/build_files/build_environment/cmake/harvest.cmake
@@ -0,0 +1,279 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+########################################################################
+# Copy all generated files to the proper strucure as blender prefers
+########################################################################
+
+if(NOT DEFINED HARVEST_TARGET)
+ set(HARVEST_TARGET ${CMAKE_CURRENT_SOURCE_DIR}/Harvest)
+endif()
+message("HARVEST_TARGET = ${HARVEST_TARGET}")
+
+if(WIN32)
+
+if(BUILD_MODE STREQUAL Release)
+ add_custom_target(Harvest_Release_Results
+ # Zlib Rename the lib file and copy the include/bin folders
+ COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/zlib/lib/zlibstatic.lib ${HARVEST_TARGET}/zlib/lib/libz_st.lib &&
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/zlib/include/ ${HARVEST_TARGET}/zlib/include/ &&
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/zlib/bin/ ${HARVEST_TARGET}/zlib/bin/ &&
+ # jpeg rename libfile + copy include
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/jpg/lib/jpeg-static.lib ${HARVEST_TARGET}/jpeg/lib/libjpeg.lib &&
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/jpg/include/ ${HARVEST_TARGET}/jpeg/include/ &&
+ # FreeType, straight up copy
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/freetype ${HARVEST_TARGET}/freetype &&
+ # pthreads, rename include dir
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/pthreads/inc/ ${HARVEST_TARGET}/pthreads/include/ &&
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/pthreads/lib/ ${HARVEST_TARGET}/pthreads/lib &&
+ # ffmpeg copy include+bin
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/ffmpeg/include ${HARVEST_TARGET}/ffmpeg/include &&
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/ffmpeg/bin ${HARVEST_TARGET}/ffmpeg/lib &&
+ # sdl merge bin/lib folder, copy include
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/sdl/include/sdl2 ${HARVEST_TARGET}/sdl/include &&
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/sdl/lib ${HARVEST_TARGET}/sdl/lib &&
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/sdl/bin ${HARVEST_TARGET}/sdl/lib &&
+ # openal
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/openal/lib/openal32.lib ${HARVEST_TARGET}/openal/lib/openal32.lib &&
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/openal/bin/openal32.dll ${HARVEST_TARGET}/openal/lib/openal32.dll &&
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openal/include/ ${HARVEST_TARGET}/openal/include/ &&
+ # OpenImageIO
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/OpenImageIO/include ${HARVEST_TARGET}/OpenImageIO/include &&
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/OpenImageIO/lib ${HARVEST_TARGET}/OpenImageIO/lib &&
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/OpenImageIO/bin/idiff.exe ${HARVEST_TARGET}/OpenImageIO/bin/idiff.exe &&
+ # openEXR
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/ilmbase ${HARVEST_TARGET}/openexr &&
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openexr/lib ${HARVEST_TARGET}/openexr/lib &&
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openexr/include ${HARVEST_TARGET}/openexr/include &&
+ # png
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/png/lib/libpng16_static.lib ${HARVEST_TARGET}/png/lib/libpng.lib &&
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/png/include/ ${HARVEST_TARGET}/png/include/ &&
+ # fftw3
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/fftw3/lib/libfftw3.a ${HARVEST_TARGET}/fftw3/lib/libfftw.lib &&
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/fftw3/include/fftw3.h ${HARVEST_TARGET}/fftw3/include/fftw3.h &&
+ # freeglut-> opengl
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/freeglut/lib/freeglut_static.lib ${HARVEST_TARGET}/opengl/lib/freeglut_static.lib &&
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/freeglut/include/ ${HARVEST_TARGET}/opengl/include/ &&
+ # glew-> opengl
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/glew/lib/libglew32.lib ${HARVEST_TARGET}/opengl/lib/glew.lib &&
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/glew/include/ ${HARVEST_TARGET}/opengl/include/ &&
+ # sndfile
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/sndfile/lib/libsndfile.dll.a ${HARVEST_TARGET}/sndfile/lib/libsndfile-1.lib &&
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/sndfile/bin/libsndfile-1.dll ${HARVEST_TARGET}/sndfile/lib/libsndfile-1.dll &&
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/sndfile/include/sndfile.h ${HARVEST_TARGET}/sndfile/include/sndfile.h &&
+ # tiff
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/tiff/lib/tiff.lib ${HARVEST_TARGET}/tiff/lib/libtiff.lib &&
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/tiff/include/ ${HARVEST_TARGET}/tiff/include/ &&
+ # iconv
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/iconv/lib/libiconv.a ${HARVEST_TARGET}/iconv/lib/iconv.lib &&
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/iconv/include/iconv.h ${HARVEST_TARGET}/iconv/include/iconv.h &&
+ # opencolorIO
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/OpenColorIO/ ${HARVEST_TARGET}/opencolorio &&
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/OpenColorIO/lib/OpenColorIO.dll ${HARVEST_TARGET}/opencolorio/bin/OpenColorIO.dll &&
+ # Osl
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/osl/ ${HARVEST_TARGET}/osl &&
+ # OpenVDB
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openVDB/ ${HARVEST_TARGET}/openVDB &&
+ # blosc
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/blosc/lib/libblosc.lib ${HARVEST_TARGET}/blosc/lib/libblosc.lib &&
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/blosc/include/ ${HARVEST_TARGET}/blosc/include/ &&
+ # tbb
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbb_static.lib ${HARVEST_TARGET}/tbb/lib/tbb.lib &&
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/tbb/include/ ${HARVEST_TARGET}/tbb/include/ &&
+ # opencollada
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/opencollada/ ${HARVEST_TARGET}/opencollada/ &&
+ # opensubdiv
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/opensubdiv ${HARVEST_TARGET}/opensubdiv &&
+ # python
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/python/ ${HARVEST_TARGET}/python/ &&
+ # alembic
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/alembic ${HARVEST_TARGET}/alembic &&
+ # hdf5
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/hdf5 ${HARVEST_TARGET}/hdf5 &&
+ # BlendThumb
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/BlendThumb64/bin/blendthumb.dll ${HARVEST_TARGET}/ThumbHandler/lib/BlendThumb64.dll &&
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/BlendThumb32/bin/blendthumb.dll ${HARVEST_TARGET}/ThumbHandler/lib/BlendThumb.dll &&
+ # python
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}.tar.gz ${HARVEST_TARGET}/Release/python${PYTHON_SHORT_VERSION_NO_DOTS}.tar.gz &&
+ # numpy
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}_numpy_${NUMPY_SHORT_VERSION}.tar.gz ${HARVEST_TARGET}/Release/python${PYTHON_SHORT_VERSION_NO_DOTS}_numpy_${NUMPY_SHORT_VERSION}.tar.gz &&
+ # hidapi
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/hidapi/ ${HARVEST_TARGET}/hidapi/ &&
+ # webp, straight up copy
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/webp ${HARVEST_TARGET}/webp
+ DEPENDS
+)
+endif(BUILD_MODE STREQUAL Release)
+
+if(BUILD_MODE STREQUAL Debug)
+ add_custom_target(Harvest_Debug_Results
+ # OpenImageIO
+ COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openimageio/lib/OpenImageIO.lib ${HARVEST_TARGET}/openimageio/lib/OpenImageIO_d.lib &&
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/openimageio/lib/OpenImageIO_Util.lib ${HARVEST_TARGET}/openimageio/lib/OpenImageIO_Util_d.lib &&
+ # ilmbase+openexr
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/ilmbase/lib/Half.lib ${HARVEST_TARGET}/openexr/lib/Half_d.lib &&
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/ilmbase/lib/Iex-2_2.lib ${HARVEST_TARGET}/openexr/lib/Iex-2_2_d.lib &&
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/ilmbase/lib/IexMath-2_2.lib ${HARVEST_TARGET}/openexr/lib/IexMath-2_2_d.lib &&
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/ilmbase/lib/IlmThread-2_2.lib ${HARVEST_TARGET}/openexr/lib/IlmThread-2_2_d.lib &&
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/ilmbase/lib/Imath-2_2.lib ${HARVEST_TARGET}/openexr/lib/Imath-2_2_d.lib &&
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/openexr/lib/IlmImf-2_2.lib ${HARVEST_TARGET}/openexr/lib/IlmImf-2_2_d.lib &&
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/openexr/lib/IlmImfUtil-2_2.lib ${HARVEST_TARGET}/openexr/lib/IlmImfUtil-2_2_d.lib &&
+ # opencollada
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencollada/lib/opencollada/buffer.lib ${HARVEST_TARGET}/opencollada/lib/opencollada/buffer_d.lib &&
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencollada/lib/opencollada/ftoa.lib ${HARVEST_TARGET}/opencollada/lib/opencollada/ftoa_d.lib &&
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencollada/lib/opencollada/GeneratedSaxParser.lib ${HARVEST_TARGET}/opencollada/lib/opencollada/GeneratedSaxParser_d.lib &&
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencollada/lib/opencollada/MathMLSolver.lib ${HARVEST_TARGET}/opencollada/lib/opencollada/MathMLSolver_d.lib &&
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencollada/lib/opencollada/OpenCOLLADABaseUtils.lib ${HARVEST_TARGET}/opencollada/lib/opencollada/OpenCOLLADABaseUtils_d.lib &&
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencollada/lib/opencollada/OpenCOLLADAFramework.lib ${HARVEST_TARGET}/opencollada/lib/opencollada/OpenCOLLADAFramework_d.lib &&
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencollada/lib/opencollada/OpenCOLLADASaxFrameworkLoader.lib ${HARVEST_TARGET}/opencollada/lib/opencollada/OpenCOLLADASaxFrameworkLoader_d.lib &&
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencollada/lib/opencollada/OpenCOLLADAStreamWriter.lib ${HARVEST_TARGET}/opencollada/lib/opencollada/OpenCOLLADAStreamWriter_d.lib &&
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencollada/lib/opencollada/pcre.lib ${HARVEST_TARGET}/opencollada/lib/opencollada/pcre_d.lib &&
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencollada/lib/opencollada/UTF.lib ${HARVEST_TARGET}/opencollada/lib/opencollada/UTF_d.lib &&
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencollada/lib/opencollada/xml.lib ${HARVEST_TARGET}/opencollada/lib/opencollada/xml_d.lib &&
+ # blosc
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/blosc/lib/libblosc_d.lib ${HARVEST_TARGET}/blosc/lib/libblosc_d.lib &&
+ # osl
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/lib/oslcomp.lib ${HARVEST_TARGET}/osl/lib/oslcomp_d.lib &&
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/lib/oslexec.lib ${HARVEST_TARGET}/osl/lib/oslexec_d.lib &&
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/lib/oslquery.lib ${HARVEST_TARGET}/osl/lib/oslquery_d.lib &&
+ # opensubdiv
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/opensubdiv/lib/osdCPU.lib ${HARVEST_TARGET}/opensubdiv/lib/osdCPU_d.lib &&
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/opensubdiv/lib/osdGPU.lib ${HARVEST_TARGET}/opensubdiv/lib/osdGPU_d.lib &&
+ # tbb
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbb_static.lib ${HARVEST_TARGET}/tbb/lib/tbb_debug.lib &&
+ # openvdb
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/openvdb/lib/openvdb.lib ${HARVEST_TARGET}/openvdb/lib/openvdb_d.lib &&
+ # python
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/python/ ${HARVEST_TARGET}/python/ &&
+ # alembic
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/alembic/lib/alembic.lib ${HARVEST_TARGET}/alembic/lib/alembic_d.lib &&
+ # hdf5
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/hdf5/lib ${HARVEST_TARGET}/hdf5/lib &&
+ # numpy
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}_numpy_${NUMPY_SHORT_VERSION}d.tar.gz ${HARVEST_TARGET}/Release/python${PYTHON_SHORT_VERSION_NO_DOTS}_numpy_${NUMPY_SHORT_VERSION}d.tar.gz &&
+ # python
+ ${CMAKE_COMMAND} -E copy ${LIBDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}_d.tar.gz ${HARVEST_TARGET}/Release/python${PYTHON_SHORT_VERSION_NO_DOTS}_d.tar.gz
+ DEPENDS Package_Python
+)
+endif(BUILD_MODE STREQUAL Debug)
+
+else(WIN32)
+
+function(harvest from to)
+ set(pattern "")
+ foreach(f ${ARGN})
+ set(pattern ${f})
+ endforeach()
+
+ if(pattern STREQUAL "")
+ get_filename_component(dirpath ${to} DIRECTORY)
+ get_filename_component(filename ${to} NAME)
+ install(
+ FILES ${LIBDIR}/${from}
+ DESTINATION ${HARVEST_TARGET}/${dirpath}
+ RENAME ${filename})
+ else()
+ install(
+ DIRECTORY ${LIBDIR}/${from}/
+ DESTINATION ${HARVEST_TARGET}/${to}
+ USE_SOURCE_PERMISSIONS
+ FILES_MATCHING PATTERN ${pattern}
+ PATTERN "pkgconfig" EXCLUDE
+ PATTERN "cmake" EXCLUDE
+ PATTERN "clang" EXCLUDE
+ PATTERN "__pycache__" EXCLUDE
+ PATTERN "tests" EXCLUDE)
+ endif()
+endfunction()
+
+harvest(alembic/include alembic/include "*.h")
+harvest(alembic/lib/libAlembic.a alembic/lib/libAlembic.a)
+harvest(alembic/bin alembic/bin "*")
+harvest(blosc/lib openvdb/lib "*.a")
+harvest(boost/include boost/include "*")
+harvest(boost/lib boost/lib "*.a")
+harvest(ffmpeg/include ffmpeg/include "*.h")
+harvest(ffmpeg/lib ffmpeg/lib "*.a")
+harvest(fftw3/include fftw3/include "*.h")
+harvest(fftw3/lib fftw3/lib "*.a")
+harvest(flac/lib sndfile/lib "libFLAC.a")
+harvest(freetype/include freetype/include "*.h")
+harvest(freetype/lib/libfreetype2ST.a freetype/lib/libfreetype.a)
+harvest(glew/include glew/include "*.h")
+harvest(glew/lib glew/lib "*.a")
+harvest(ilmbase openexr "*")
+harvest(ilmbase/include openexr/include "*.h")
+harvest(jemalloc/include jemalloc/include "*.h")
+harvest(jemalloc/lib jemalloc/lib "*.a")
+harvest(jpg/include jpeg/include "*.h")
+harvest(jpg/lib jpeg/lib "libjpeg.a")
+harvest(lame/lib ffmpeg/lib "*.a")
+harvest(llvm/bin llvm/bin "llvm-config")
+harvest(llvm/lib llvm/lib "libLLVM*.a")
+harvest(ogg/lib ffmpeg/lib "*.a")
+harvest(openal/include openal/include "*.h")
+if(UNIX AND NOT APPLE)
+ harvest(openal/lib openal/lib "*.a")
+endif()
+harvest(opencollada/include/opencollada opencollada/include "*.h")
+harvest(opencollada/lib/opencollada opencollada/lib "*.a")
+harvest(opencolorio/include opencolorio/include "*.h")
+harvest(opencolorio/lib opencolorio/lib "*.a")
+harvest(openexr/include openexr/include "*.h")
+harvest(openexr/lib openexr/lib "*.a")
+harvest(openimageio/bin openimageio/bin "idiff")
+harvest(openimageio/bin openimageio/bin "maketx")
+harvest(openimageio/bin openimageio/bin "oiiotool")
+harvest(openimageio/include openimageio/include "*")
+harvest(openimageio/lib openimageio/lib "*.a")
+harvest(openjpeg/include/openjpeg-1.5 openjpeg/include "*.h")
+harvest(openjpeg/lib openjpeg/lib "*.a")
+harvest(opensubdiv/include opensubdiv/include "*.h")
+harvest(opensubdiv/lib opensubdiv/lib "*.a")
+harvest(openvdb/include/openvdb/openvdb openvdb/include/openvdb "*.h")
+harvest(openvdb/lib openvdb/lib "*.a")
+harvest(orc/lib/liborc-0.4.a ffmpeg/lib/liborc.a)
+harvest(osl/bin osl/bin "oslc")
+harvest(osl/include osl/include "*.h")
+harvest(osl/lib osl/lib "*.a")
+harvest(osl/shaders osl/shaders "*.h")
+harvest(png/include png/include "*.h")
+harvest(png/lib png/lib "*.a")
+harvest(python/bin python/bin "python${PYTHON_SHORT_VERSION}m")
+harvest(python/include python/include "*h")
+harvest(python/lib python/lib "*")
+harvest(schroedinger/lib/libschroedinger-1.0.a ffmpeg/lib/libschroedinger.a)
+harvest(sdl/include/SDL2 sdl/include "*.h")
+harvest(sdl/lib sdl/lib "libSDL2.a")
+harvest(sndfile/include sndfile/include "*.h")
+harvest(sndfile/lib sndfile/lib "*.a")
+harvest(spnav/include spnav/include "*.h")
+harvest(spnav/lib spnav/lib "*.a")
+harvest(tbb/include tbb/include "*.h")
+harvest(tbb/lib/libtbb_static.a tbb/lib/libtbb.a)
+harvest(theora/lib ffmpeg/lib "*.a")
+harvest(tiff/include tiff/include "*.h")
+harvest(tiff/lib tiff/lib "*.a")
+harvest(vorbis/lib ffmpeg/lib "*.a")
+harvest(vpx/lib ffmpeg/lib "*.a")
+harvest(webp/lib ffmpeg/lib "*.a")
+harvest(x264/lib ffmpeg/lib "*.a")
+harvest(xml2/lib opencollada/lib "*.a")
+harvest(xvidcore/lib ffmpeg/lib "*.a")
+
+endif(WIN32)
diff --git a/build_files/build_environment/cmake/hdf5.cmake b/build_files/build_environment/cmake/hdf5.cmake
new file mode 100644
index 00000000000..09d40d0605f
--- /dev/null
+++ b/build_files/build_environment/cmake/hdf5.cmake
@@ -0,0 +1,42 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(HDF5_EXTRA_ARGS
+ -DHDF5_ENABLE_THREADSAFE=Off
+ -DHDF5_BUILD_CPP_LIB=Off
+ -DBUILD_TESTING=Off
+ -DHDF5_BUILD_TOOLS=Off
+ -DHDF5_BUILD_EXAMPLES=Off
+ -DHDF5_BUILD_HL_LIB=On
+ -DBUILD_STATIC_CRT_LIBS=On
+ -DBUILD_SHARED_LIBS=On
+)
+
+if(WIN32)
+ set(HDF5_PATCH ${PATCH_CMD} --verbose -p 0 -d ${BUILD_DIR}/hdf5/src/external_hdf5 < ${PATCH_DIR}/hdf5.diff)
+endif()
+
+ExternalProject_Add(external_hdf5
+ URL ${HDF5_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${HDF5_HASH}
+ PREFIX ${BUILD_DIR}/hdf5
+ PATCH_COMMAND ${HDF5_PATCH}
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/hdf5 ${HDF5_EXTRA_ARGS}
+ INSTALL_DIR ${LIBDIR}/hdf5
+)
diff --git a/build_files/build_environment/cmake/hidapi.cmake b/build_files/build_environment/cmake/hidapi.cmake
new file mode 100644
index 00000000000..cfa4cc53d2d
--- /dev/null
+++ b/build_files/build_environment/cmake/hidapi.cmake
@@ -0,0 +1,29 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(HIDAPI_EXTRA_ARGS)
+
+ExternalProject_Add(external_hidapi
+ URL ${HIDAPI_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${HIDAPI_HASH}
+ PREFIX ${BUILD_DIR}/hidapi
+ PATCH_COMMAND COMMAND ${CMAKE_COMMAND} -E copy ${PATCH_DIR}/cmakelists_hidapi.txt ${BUILD_DIR}/hidapi/src/external_hidapi/cmakelists.txt && ${PATCH_CMD} -p 0 -d ${BUILD_DIR}/hidapi/src/external_hidapi < ${PATCH_DIR}/hidapi.diff
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/hidapi -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${HIDAPI_EXTRA_ARGS}
+ INSTALL_DIR ${LIBDIR}/hidapi
+)
diff --git a/build_files/build_environment/cmake/iconv.cmake b/build_files/build_environment/cmake/iconv.cmake
new file mode 100644
index 00000000000..cd6cf9547df
--- /dev/null
+++ b/build_files/build_environment/cmake/iconv.cmake
@@ -0,0 +1,34 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(ICONV_EXTRA_ARGS)
+
+ExternalProject_Add(external_iconv
+ URL ${ICONV_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${ICONV_HASH}
+ PREFIX ${BUILD_DIR}/iconv
+ CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/iconv/src/external_iconv/ && ${CONFIGURE_COMMAND} --enable-static --prefix=${mingw_LIBDIR}/iconv
+ BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/iconv/src/external_iconv/ && make -j${MAKE_THREADS}
+ INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/iconv/src/external_iconv/ && make install
+ INSTALL_DIR ${LIBDIR}/iconv
+)
+
+if(MSVC)
+ set_target_properties(external_iconv PROPERTIES FOLDER Mingw)
+endif()
diff --git a/build_files/build_environment/cmake/ilmbase.cmake b/build_files/build_environment/cmake/ilmbase.cmake
new file mode 100644
index 00000000000..0639848346f
--- /dev/null
+++ b/build_files/build_environment/cmake/ilmbase.cmake
@@ -0,0 +1,35 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+if(WIN32)
+ set(ILMBASE_CMAKE_CXX_STANDARD_LIBRARIES "kernel32${LIBEXT} user32${LIBEXT} gdi32${LIBEXT} winspool${LIBEXT} shell32${LIBEXT} ole32${LIBEXT} oleaut32${LIBEXT} uuid${LIBEXT} comdlg32${LIBEXT} advapi32${LIBEXT} psapi${LIBEXT}")
+endif()
+
+set(ILMBASE_EXTRA_ARGS
+ -DBUILD_SHARED_LIBS=OFF
+ -DCMAKE_CXX_STANDARD_LIBRARIES=${ILMBASE_CMAKE_CXX_STANDARD_LIBRARIES}
+)
+
+ExternalProject_Add(external_ilmbase
+ URL ${ILMBASE_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${ILMBASE_HASH}
+ PREFIX ${BUILD_DIR}/ilmbase
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/ilmbase ${DEFAULT_CMAKE_FLAGS} ${ILMBASE_EXTRA_ARGS}
+ INSTALL_DIR ${LIBDIR}/openexr
+)
diff --git a/build_files/build_environment/cmake/jemalloc.cmake b/build_files/build_environment/cmake/jemalloc.cmake
new file mode 100644
index 00000000000..c39ba448917
--- /dev/null
+++ b/build_files/build_environment/cmake/jemalloc.cmake
@@ -0,0 +1,28 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+ExternalProject_Add(external_jemalloc
+ URL ${JEMALLOC_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${JEMALLOC_HASH}
+ PREFIX ${BUILD_DIR}/jemalloc
+ CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/jemalloc/src/external_jemalloc/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/jemalloc --disable-shared --enable-static --with-pic
+ BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/jemalloc/src/external_jemalloc/ && make -j${MAKE_THREADS}
+ INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/jemalloc/src/external_jemalloc/ && make install
+ INSTALL_DIR ${LIBDIR}/jemalloc
+)
diff --git a/build_files/build_environment/cmake/jpeg.cmake b/build_files/build_environment/cmake/jpeg.cmake
new file mode 100644
index 00000000000..1f2b04387f0
--- /dev/null
+++ b/build_files/build_environment/cmake/jpeg.cmake
@@ -0,0 +1,65 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+if(WIN32)
+ # cmake for windows
+ set(JPEG_EXTRA_ARGS -DWITH_JPEG8=ON -DCMAKE_DEBUG_POSTFIX=d)
+
+ ExternalProject_Add(external_jpeg
+ URL ${JPEG_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${JPEG_HASH}
+ PREFIX ${BUILD_DIR}/jpg
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/jpg ${DEFAULT_CMAKE_FLAGS} ${JPEG_EXTRA_ARGS}
+ INSTALL_DIR ${LIBDIR}/jpg
+ )
+
+ if(BUILD_MODE STREQUAL Debug)
+ ExternalProject_Add_Step(external_jpeg after_install
+ COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/jpg/lib/jpegd${LIBEXT} ${LIBDIR}/jpg/lib/jpeg${LIBEXT}
+ DEPENDEES install
+ )
+ endif()
+
+ if(BUILD_MODE STREQUAL Release)
+ set(JPEG_LIBRARY jpeg-static${LIBEXT})
+ else()
+ set(JPEG_LIBRARY jpeg-staticd${LIBEXT})
+ endif()
+else(WIN32)
+ # autoconf for unix
+ if(APPLE)
+ set(JPEG_EXTRA_ARGS --host x86_64-apple-darwin --with-jpeg8)
+ else()
+ set(JPEG_EXTRA_ARGS --with-jpeg8)
+ endif()
+
+ ExternalProject_Add(external_jpeg
+ URL ${JPEG_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${JPEG_HASH}
+ CONFIGURE_COMMAND ${CONFIGURE_ENV} && autoreconf -fiv && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/jpg NASM=yasm ${JPEG_EXTRA_ARGS}
+ BUILD_IN_SOURCE 1
+ BUILD_COMMAND ${CONFIGURE_ENV} && make install
+ PREFIX ${BUILD_DIR}/jpg
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/jpg ${DEFAULT_CMAKE_FLAGS} ${JPEG_EXTRA_ARGS}
+ INSTALL_DIR ${LIBDIR}/jpg
+ )
+
+ set(JPEG_LIBRARY libjpeg${LIBEXT})
+endif(WIN32)
diff --git a/build_files/build_environment/cmake/lame.cmake b/build_files/build_environment/cmake/lame.cmake
new file mode 100644
index 00000000000..a489b2302ce
--- /dev/null
+++ b/build_files/build_environment/cmake/lame.cmake
@@ -0,0 +1,47 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(LAME_EXTRA_ARGS)
+if(MSVC)
+ if("${CMAKE_SIZEOF_VOID_P}" EQUAL "4")
+ set(LAME_EXTRA_ARGS CFLAGS=-msse)
+ endif()
+endif()
+
+ExternalProject_Add(external_lame
+ URL ${LAME_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${LAME_HASH}
+ PREFIX ${BUILD_DIR}/lame
+ CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/lame/src/external_lame/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/lame --disable-shared --enable-static ${LAME_EXTRA_ARGS}
+ --enable-export=full
+ --with-fileio=sndfile
+ --without-vorbis
+ --with-pic
+ --disable-mp3x
+ --disable-mp3rtp
+ --disable-gtktest
+ --enable-export=full
+ BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/lame/src/external_lame/ && make -j${MAKE_THREADS}
+ INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/lame/src/external_lame/ && make install
+ INSTALL_DIR ${LIBDIR}/lame
+)
+
+if(MSVC)
+ set_target_properties(external_lame PROPERTIES FOLDER Mingw)
+endif()
diff --git a/build_files/build_environment/cmake/lapack.cmake b/build_files/build_environment/cmake/lapack.cmake
new file mode 100644
index 00000000000..3110503db52
--- /dev/null
+++ b/build_files/build_environment/cmake/lapack.cmake
@@ -0,0 +1,43 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(LAPACK_EXTRA_ARGS)
+
+if(WIN32)
+ if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
+ set(LAPACK_EXTRA_ARGS -G "MSYS Makefiles" -DCMAKE_Fortran_COMPILER=${DOWNLOAD_DIR}/mingw/mingw64/bin/gfortran.exe)
+ else()
+ set(LAPACK_EXTRA_ARGS -G "MSYS Makefiles" -DCMAKE_Fortran_COMPILER=${DOWNLOAD_DIR}/mingw/mingw32/bin/gfortran.exe)
+ endif()
+endif()
+
+ExternalProject_Add(external_lapack
+ URL ${LAPACK_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${LAPACK_HASH}
+ PREFIX ${BUILD_DIR}/lapack
+ CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/lapack/src/external_lapack/ && ${CMAKE_COMMAND} ${LAPACK_EXTRA_ARGS} -DBUILD_TESTING=Off -DCMAKE_INSTALL_PREFIX=${LIBDIR}/lapack .
+ BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/lapack/src/external_lapack/ && make -j${MAKE_THREADS}
+ INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/lapack/src/external_lapack/ && make install
+
+ INSTALL_DIR ${LIBDIR}/lapack
+)
+
+if(MSVC)
+ set_target_properties(external_lapack PROPERTIES FOLDER Mingw)
+endif()
diff --git a/build_files/build_environment/cmake/llvm.cmake b/build_files/build_environment/cmake/llvm.cmake
new file mode 100644
index 00000000000..f04fe609cb3
--- /dev/null
+++ b/build_files/build_environment/cmake/llvm.cmake
@@ -0,0 +1,61 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(LLVM_EXTRA_ARGS
+ -DLLVM_USE_CRT_RELEASE=MT
+ -DLLVM_USE_CRT_DEBUG=MTd
+ -DLLVM_INCLUDE_TESTS=OFF
+ -DLLVM_TARGETS_TO_BUILD=X86
+ -DLLVM_INCLUDE_EXAMPLES=OFF
+ -DLLVM_ENABLE_TERMINFO=OFF
+)
+
+if(WIN32)
+ set(LLVM_GENERATOR "NMake Makefiles")
+else()
+ set(LLVM_GENERATOR "Unix Makefiles")
+endif()
+
+# short project name due to long filename issues on windows
+ExternalProject_Add(ll
+ URL ${LLVM_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${LLVM_HASH}
+ CMAKE_GENERATOR ${LLVM_GENERATOR}
+ PREFIX ${BUILD_DIR}/ll
+ PATCH_COMMAND ${PATCH_CMD} -p 0 -d ${BUILD_DIR}/ll/src/ll < ${PATCH_DIR}/llvm-alloca-fix.diff
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/llvm ${DEFAULT_CMAKE_FLAGS} ${LLVM_EXTRA_ARGS}
+ INSTALL_DIR ${LIBDIR}/llvm
+)
+
+if (MSVC)
+ if (BUILD_MODE STREQUAL Release)
+ set(LLVM_HARVEST_COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/llvm/ ${HARVEST_TARGET}/llvm/ )
+ else()
+ set(LLVM_HARVEST_COMMAND
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/llvm/lib/ ${HARVEST_TARGET}/llvm/debug/lib/ &&
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/llvm/bin/ ${HARVEST_TARGET}/llvm/debug/bin/ &&
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/llvm/include/ ${HARVEST_TARGET}/llvm/debug/include/
+ )
+ endif()
+ ExternalProject_Add_Step(ll after_install
+ COMMAND ${LLVM_HARVEST_COMMAND}
+ DEPENDEES mkdir update patch download configure build install
+ )
+endif()
+
diff --git a/build_files/build_environment/cmake/numpy.cmake b/build_files/build_environment/cmake/numpy.cmake
new file mode 100644
index 00000000000..107947dabd3
--- /dev/null
+++ b/build_files/build_environment/cmake/numpy.cmake
@@ -0,0 +1,57 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+if(MSVC)
+ if(BUILD_MODE STREQUAL Debug)
+ set(NUMPY_DIR_POSTFIX -pydebug)
+ set(NUMPY_ARCHIVE_POSTFIX d)
+ set(NUMPY_BUILD_OPTION --debug)
+ else()
+ set(NUMPY_DIR_POSTFIX)
+ set(NUMPY_ARCHIVE_POSTFIX)
+ set(NUMPY_BUILD_OPTION)
+ endif(BUILD_MODE STREQUAL Debug)
+endif()
+
+set(NUMPY_POSTFIX)
+
+if(WIN32)
+ set(NUMPY_INSTALL
+ ${CMAKE_COMMAND} -E copy_directory "${BUILD_DIR}/python/src/external_python/run/lib/site-packages/numpy/core/include/numpy" "${LIBDIR}/python/include/python${PYTHON_SHORT_VERSION}/numpy" &&
+ ${CMAKE_COMMAND} -E chdir "${BUILD_DIR}/numpy/src/external_numpy/build/lib.${PYTHON_ARCH2}-${PYTHON_SHORT_VERSION}${NUMPY_DIR_POSTFIX}"
+ ${CMAKE_COMMAND} -E tar "cfvz" "${LIBDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}_numpy_${NUMPY_SHORT_VERSION}${NUMPY_ARCHIVE_POSTFIX}.tar.gz" "."
+ )
+ set(NUMPY_PATCH ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/numpy/src/external_numpy < ${PATCH_DIR}/numpy.diff )
+else()
+ set(NUMPY_INSTALL echo .)
+ set(NUMPY_PATCH echo .)
+endif()
+
+ExternalProject_Add(external_numpy
+ URL ${NUMPY_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${NUMPY_HASH}
+ PREFIX ${BUILD_DIR}/numpy
+ PATCH_COMMAND ${NUMPY_PATCH}
+ CONFIGURE_COMMAND ""
+ LOG_BUILD 1
+ BUILD_COMMAND ${PYTHON_BINARY} ${BUILD_DIR}/numpy/src/external_numpy/setup.py build ${NUMPY_BUILD_OPTION} install --old-and-unmanageable
+ INSTALL_COMMAND ${NUMPY_INSTALL}
+)
+
+add_dependencies(external_numpy Make_Python_Environment)
diff --git a/build_files/build_environment/cmake/ogg.cmake b/build_files/build_environment/cmake/ogg.cmake
new file mode 100644
index 00000000000..1f69cee0996
--- /dev/null
+++ b/build_files/build_environment/cmake/ogg.cmake
@@ -0,0 +1,32 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+ExternalProject_Add(external_ogg
+ URL ${OGG_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH SHA256=${OGG_HASH}
+ PREFIX ${BUILD_DIR}/ogg
+ CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/ogg/src/external_ogg/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/ogg --disable-shared --enable-static
+ BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/ogg/src/external_ogg/ && make -j${MAKE_THREADS}
+ INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/ogg/src/external_ogg/ && make install
+ INSTALL_DIR ${LIBDIR}/ogg
+)
+
+if(MSVC)
+ set_target_properties(external_ogg PROPERTIES FOLDER Mingw)
+endif()
diff --git a/build_files/build_environment/cmake/openal.cmake b/build_files/build_environment/cmake/openal.cmake
new file mode 100644
index 00000000000..d63c4443ca0
--- /dev/null
+++ b/build_files/build_environment/cmake/openal.cmake
@@ -0,0 +1,42 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+if(BUILD_MODE STREQUAL Release)
+ set(OPENAL_EXTRA_ARGS
+ -DALSOFT_UTILS=Off
+ -DALSOFT_NO_CONFIG_UTIL=On
+ -DALSOFT_EXAMPLES=Off
+ -DALSOFT_TESTS=Off
+ -DALSOFT_CONFIG=Off
+ -DALSOFT_HRTF_DEFS=Off
+ -DALSOFT_INSTALL=On
+ )
+
+ if(UNIX)
+ set(OPENAL_EXTRA_ARGS ${OPENAL_EXTRA_ARGS} -DLIBTYPE=STATIC)
+ endif()
+
+ ExternalProject_Add(external_openal
+ URL ${OPENAL_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${OPENAL_HASH}
+ PREFIX ${BUILD_DIR}/openal
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openal ${DEFAULT_CMAKE_FLAGS} ${OPENAL_EXTRA_ARGS}
+ INSTALL_DIR ${LIBDIR}/openal
+ )
+endif()
diff --git a/build_files/build_environment/cmake/opencollada.cmake b/build_files/build_environment/cmake/opencollada.cmake
new file mode 100644
index 00000000000..9b2a2d9dc4d
--- /dev/null
+++ b/build_files/build_environment/cmake/opencollada.cmake
@@ -0,0 +1,37 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+if(UNIX AND NOT APPLE)
+ set(OPENCOLLADA_EXTRA_ARGS
+ -DLIBXML2_INCLUDE_DIR=${LIBDIR}/xml2/include/libxml2
+ -DLIBXML2_LIBRARIES=${LIBDIR}/xml2/lib/libxml2.a)
+endif()
+
+ExternalProject_Add(external_opencollada
+ URL ${OPENCOLLADA_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${OPENCOLLADA_HASH}
+ PREFIX ${BUILD_DIR}/opencollada
+ PATCH_COMMAND ${PATCH_CMD} -p 1 -N -d ${BUILD_DIR}/opencollada/src/external_opencollada < ${PATCH_DIR}/opencollada.diff
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/opencollada ${DEFAULT_CMAKE_FLAGS} ${OPENCOLLADA_EXTRA_ARGS}
+ INSTALL_DIR ${LIBDIR}/opencollada
+)
+
+if(UNIX AND NOT APPLE)
+ add_dependencies(external_opencollada external_xml2)
+endif()
diff --git a/build_files/build_environment/cmake/opencolorio.cmake b/build_files/build_environment/cmake/opencolorio.cmake
new file mode 100644
index 00000000000..14fb62af672
--- /dev/null
+++ b/build_files/build_environment/cmake/opencolorio.cmake
@@ -0,0 +1,70 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(OPENCOLORIO_EXTRA_ARGS
+ -DBoost_COMPILER:STRING=${BOOST_COMPILER_STRING}
+ -DBoost_USE_MULTITHREADED=ON
+ -DBoost_USE_STATIC_LIBS=ON
+ -DBoost_USE_STATIC_RUNTIME=ON
+ -DBOOST_ROOT=${LIBDIR}/boost
+ -DBOOST_INCLUDEDIR=${LIBDIR}/boost/include/boost_1_60/boost
+ -DBoost_NO_SYSTEM_PATHS=ON
+ -DBoost_DEBUG=ON
+ -DBoost_MAJOR_VERSION=1
+ -DBoost_MINOR_VERSION=60
+ -DOCIO_BUILD_APPS=OFF
+ -DOCIO_BUILD_PYGLUE=OFF
+ -DOCIO_BUILD_NUKE=OFF
+)
+
+if(WIN32)
+ set(OPENCOLORIO_EXTRA_ARGS
+ ${OPENCOLORIO_EXTRA_ARGS}
+ -DOCIO_USE_BOOST_PTR=ON
+ -DOCIO_BUILD_STATIC=OFF
+ -DOCIO_BUILD_SHARED=ON
+ )
+else()
+ set(OPENCOLORIO_EXTRA_ARGS
+ ${OPENCOLORIO_EXTRA_ARGS}
+ -DOCIO_USE_BOOST_PTR=OFF
+ -DOCIO_BUILD_STATIC=ON
+ -DOCIO_BUILD_SHARED=OFF
+ )
+endif()
+
+ExternalProject_Add(external_opencolorio
+ URL ${OPENCOLORIO_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${OPENCOLORIO_HASH}
+ PREFIX ${BUILD_DIR}/opencolorio
+ PATCH_COMMAND ${PATCH_CMD} -p 0 -N -d ${BUILD_DIR}/opencolorio/src/external_opencolorio < ${PATCH_DIR}/opencolorio.diff
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/opencolorio ${DEFAULT_CMAKE_FLAGS} ${OPENCOLORIO_EXTRA_ARGS}
+ INSTALL_DIR ${LIBDIR}/opencolorio
+)
+
+if(NOT WIN32)
+ add_custom_command(
+ OUTPUT ${LIBDIR}/opencolorio/lib/libtinyxml.a
+ COMMAND cp ${BUILD_DIR}/opencolorio/src/external_opencolorio-build/ext/dist/lib/libtinyxml.a ${LIBDIR}/opencolorio/lib/libtinyxml.a
+ COMMAND cp ${BUILD_DIR}/opencolorio/src/external_opencolorio-build/ext/dist/lib/libyaml-cpp.a ${LIBDIR}/opencolorio/lib/libyaml-cpp.a
+ )
+ add_custom_target(external_opencolorio_extra ALL DEPENDS external_opencolorio ${LIBDIR}/opencolorio/lib/libtinyxml.a)
+endif()
+
+add_dependencies(external_opencolorio external_boost)
diff --git a/build_files/build_environment/cmake/openexr.cmake b/build_files/build_environment/cmake/openexr.cmake
new file mode 100644
index 00000000000..53a1bc4c146
--- /dev/null
+++ b/build_files/build_environment/cmake/openexr.cmake
@@ -0,0 +1,41 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+if(WIN32)
+ set(OPENEXR_CMAKE_CXX_STANDARD_LIBRARIES "kernel32${LIBEXT} user32${LIBEXT} gdi32${LIBEXT} winspool${LIBEXT} shell32${LIBEXT} ole32${LIBEXT} oleaut32${LIBEXT} uuid${LIBEXT} comdlg32${LIBEXT} advapi32${LIBEXT} psapi${LIBEXT}")
+endif()
+
+set(OPENEXR_EXTRA_ARGS
+ -DBUILD_SHARED_LIBS=OFF
+ -DCMAKE_CXX_STANDARD_LIBRARIES=${OPENEXR_CMAKE_CXX_STANDARD_LIBRARIES}
+ -DZLIB_LIBRARY=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY}
+ -DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include/
+ -DILMBASE_PACKAGE_PREFIX=${LIBDIR}/ilmbase
+)
+
+ExternalProject_Add(external_openexr
+ URL ${OPENEXR_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${OPENEXR_HASH}
+ PREFIX ${BUILD_DIR}/openexr
+ PATCH_COMMAND ${PATCH_CMD} -p 0 -d ${BUILD_DIR}/openexr/src/external_openexr < ${PATCH_DIR}/openexr.diff
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openexr ${DEFAULT_CMAKE_FLAGS} ${OPENEXR_EXTRA_ARGS}
+ INSTALL_DIR ${LIBDIR}/openexr
+)
+
+add_dependencies(external_openexr external_zlib external_ilmbase)
diff --git a/build_files/build_environment/cmake/openimageio.cmake b/build_files/build_environment/cmake/openimageio.cmake
new file mode 100644
index 00000000000..96b221388da
--- /dev/null
+++ b/build_files/build_environment/cmake/openimageio.cmake
@@ -0,0 +1,132 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+if(BUILD_MODE STREQUAL Release)
+ set(OIIO_TOOLS ON)
+else()
+ set(OIIO_TOOLS OFF)
+endif()
+
+if(UNIX AND NOT APPLE)
+ # This causes linking to static pthread libraries which gives link errors.
+ # Since we manually specify library paths it should static link other libs.
+ set(OPENIMAGEIO_LINKSTATIC -DLINKSTATIC=OFF)
+else()
+ set(OPENIMAGEIO_LINKSTATIC -DLINKSTATIC=ON)
+endif()
+
+if(WIN32)
+ set(PNG_LIBNAME libpng16_static${LIBEXT})
+ set(OIIO_SIMD_FLAGS -DUSE_SIMD=sse2 -DOPJ_STATIC=1)
+ set(OPENJPEG_POSTFIX _msvc)
+else()
+ set(PNG_LIBNAME libpng${LIBEXT})
+ set(OIIO_SIMD_FLAGS)
+endif()
+
+if (WITH_WEBP)
+ set(WEBP_ARGS -DWEBP_INCLUDE_DIR=${LIBDIR}/webp/include
+ -DWEBP_LIBRARY=${LIBDIR}/webp/lib/${LIBPREFIX}webp${LIBEXT} )
+ set(WEBP_DEP external_webp)
+endif()
+
+if (MSVC)
+set(OPENJPEG_FLAGS -DOPENJPEG_HOME=${LIBDIR}/openjpeg_msvc
+ -DOPENJPEG_INCLUDE_DIR=${LIBDIR}/openjpeg_msvc/include/openjpeg-${OPENJPEG_SHORT_VERSION}
+ -DOPENJPEG_LIBRARY=${LIBDIR}/openjpeg_msvc/lib/openjpeg${LIBEXT}
+ -DOPENJPEG_LIBRARY_DEBUG=${LIBDIR}/openjpeg_msvc/lib/openjpeg${LIBEXT}
+ )
+else()
+set(OPENJPEG_FLAGS -DOPENJPEG_INCLUDE_DIR=${LIBDIR}/openjpeg/include/openjpeg-${OPENJPEG_SHORT_VERSION}
+ -DOPENJPEG_LIBRARY=${LIBDIR}/openjpeg/lib/${OPENJPEG_LIBRARY}
+ )
+endif()
+
+set(OPENIMAGEIO_EXTRA_ARGS
+ -DBUILDSTATIC=ON
+ ${OPENIMAGEIO_LINKSTATIC}
+ -DOPENEXR_INCLUDE_DIR=${LIBDIR}/openexr/include/openexr/
+ -DOPENEXR_ILMIMF_LIBRARIES=${LIBDIR}/openexr/lib/IlmImf-2_2${LIBEXT}
+ -DBoost_COMPILER:STRING=${BOOST_COMPILER_STRING}
+ -DBoost_USE_MULTITHREADED=ON
+ -DBoost_USE_STATIC_LIBS=ON
+ -DBoost_USE_STATIC_RUNTIME=ON
+ -DBOOST_ROOT=${LIBDIR}/boost
+ -DBOOST_LIBRARYDIR=${LIBDIR}/boost/lib/
+ -DBoost_NO_SYSTEM_PATHS=ON
+ -OIIO_BUILD_CPP11=ON
+ -DUSE_OPENGL=OFF
+ -DUSE_TBB=OFF
+ -DUSE_FIELD3D=OFF
+ -DUSE_QT=OFF
+ -DUSE_PYTHON=OFF
+ -DUSE_GIF=OFF
+ -DUSE_OPENCV=OFF
+ -DUSE_OPENSSL=OFF
+ -DUSE_OPENJPEG=ON
+ -DUSE_FFMPEG=OFF
+ -DUSE_PTEX=OFF
+ -DUSE_FREETYPE=OFF
+ -DUSE_LIBRAW=OFF
+ -DUSE_PYTHON=OFF
+ -DUSE_PYTHON3=OFF
+ -DUSE_OCIO=OFF
+ -DOIIO_BUILD_TOOLS=${OIIO_TOOLS}
+ -DOIIO_BUILD_TESTS=OFF
+ -DBUILD_TESTING=OFF
+ -DZLIB_LIBRARY=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY}
+ -DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include
+ -DPNG_LIBRARY=${LIBDIR}/png/lib/${PNG_LIBNAME}
+ -DPNG_PNG_INCLUDE_DIR=${LIBDIR}/png/include
+ -DTIFF_LIBRARY=${LIBDIR}/tiff/lib/${LIBPREFIX}tiff${LIBEXT}
+ -DTIFF_INCLUDE_DIR=${LIBDIR}/tiff/include
+ -DJPEG_LIBRARY=${LIBDIR}/jpg/lib/${JPEG_LIBRARY}
+ -DJPEG_INCLUDE_DIR=${LIBDIR}/jpg/include
+ ${OPENJPEG_FLAGS}
+ -DOCIO_PATH=${LIBDIR}/opencolorio/
+ -DOpenEXR_USE_STATIC_LIBS=On
+ -DOPENEXR_HOME=${LIBDIR}/openexr/
+ -DILMBASE_INCLUDE_PATH=${LIBDIR}/ilmbase/
+ -DILMBASE_PACKAGE_PREFIX=${LIBDIR}/ilmbase/
+ -DILMBASE_INCLUDE_DIR=${LIBDIR}/ilmbase/include/
+ -DOPENEXR_HALF_LIBRARY=${LIBDIR}/ilmbase/lib/${LIBPREFIX}Half${LIBEXT}
+ -DOPENEXR_IMATH_LIBRARY=${LIBDIR}/ilmbase/lib/${LIBPREFIX}Imath-2_2${LIBEXT}
+ -DOPENEXR_ILMTHREAD_LIBRARY=${LIBDIR}/ilmbase/lib/${LIBPREFIX}IlmThread-2_2${LIBEXT}
+ -DOPENEXR_IEX_LIBRARY=${LIBDIR}/ilmbase/lib/${LIBPREFIX}Iex-2_2${LIBEXT}
+ -DOPENEXR_INCLUDE_DIR=${LIBDIR}/openexr/include/
+ -DOPENEXR_ILMIMF_LIBRARY=${LIBDIR}/openexr/lib/${LIBPREFIX}IlmImf-2_2${LIBEXT}
+ -DSTOP_ON_WARNING=OFF
+ ${WEBP_FLAGS}
+ ${OIIO_SIMD_FLAGS}
+)
+
+ExternalProject_Add(external_openimageio
+ URL ${OPENIMAGEIO_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${OPENIMAGEIO_HASH}
+ PREFIX ${BUILD_DIR}/openimageio
+ PATCH_COMMAND ${PATCH_CMD} -p 0 -N -d ${BUILD_DIR}/openimageio/src/external_openimageio/src/include < ${PATCH_DIR}/openimageio_gdi.diff &&
+ ${PATCH_CMD} -p 0 -N -d ${BUILD_DIR}/openimageio/src/external_openimageio/ < ${PATCH_DIR}/openimageio_staticexr.diff
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openimageio ${DEFAULT_CMAKE_FLAGS} ${OPENIMAGEIO_EXTRA_ARGS}
+ INSTALL_DIR ${LIBDIR}/openimageio
+)
+
+add_dependencies(external_openimageio external_png external_zlib external_ilmbase external_openexr external_jpeg external_boost external_tiff external_opencolorio external_openjpeg${OPENJPEG_POSTFIX} ${WEBP_DEP})
+if(NOT WIN32)
+ add_dependencies(external_openimageio external_opencolorio_extra)
+endif()
diff --git a/build_files/build_environment/cmake/openjpeg.cmake b/build_files/build_environment/cmake/openjpeg.cmake
new file mode 100644
index 00000000000..406badf31fe
--- /dev/null
+++ b/build_files/build_environment/cmake/openjpeg.cmake
@@ -0,0 +1,57 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+# Note the encoder/decoder may use png/tiff/lcms system libraries, but the
+# library itself does not depend on them, so should give no problems.
+
+set(OPENJPEG_EXTRA_ARGS -DBUILD_SHARED_LIBS=OFF)
+
+if(WIN32)
+ set(OPENJPEG_EXTRA_ARGS -G "MSYS Makefiles")
+else()
+ set(OPENJPEG_EXTRA_ARGS ${DEFAULT_CMAKE_FLAGS})
+endif()
+
+ExternalProject_Add(external_openjpeg
+ URL ${OPENJPEG_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH SHA256=${OPENJPEG_HASH}
+ PREFIX ${BUILD_DIR}/openjpeg
+ CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/openjpeg/src/external_openjpeg-build && ${CMAKE_COMMAND} ${OPENJPEG_EXTRA_ARGS} -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openjpeg -DBUILD_SHARED_LIBS=Off -DBUILD_THIRDPARTY=OFF ${BUILD_DIR}/openjpeg/src/external_openjpeg
+ BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/openjpeg/src/external_openjpeg-build/ && make -j${MAKE_THREADS}
+ INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/openjpeg/src/external_openjpeg-build/ && make install
+ INSTALL_DIR ${LIBDIR}/openjpeg
+)
+
+#on windows ffmpeg wants a mingw build, while oiio needs a msvc build
+if (MSVC)
+ set(OPENJPEG_EXTRA_ARGS ${DEFAULT_CMAKE_FLAGS})
+ExternalProject_Add(external_openjpeg_msvc
+ URL ${OPENJPEG_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH SHA256=${OPENJPEG_HASH}
+ PREFIX ${BUILD_DIR}/openjpeg_msvc
+ CMAKE_ARGS ${OPENJPEG_EXTRA_ARGS} -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openjpeg_msvc -DBUILD_SHARED_LIBS=Off -DBUILD_THIRDPARTY=OFF
+ INSTALL_DIR ${LIBDIR}/openjpeg_msvc
+)
+endif()
+
+ set(OPENJPEG_LIBRARY libopenjpeg${LIBEXT})
+if(MSVC)
+ set_target_properties(external_openjpeg PROPERTIES FOLDER Mingw)
+endif(MSVC)
diff --git a/build_files/build_environment/cmake/opensubdiv.cmake b/build_files/build_environment/cmake/opensubdiv.cmake
new file mode 100644
index 00000000000..5a3a4d142fa
--- /dev/null
+++ b/build_files/build_environment/cmake/opensubdiv.cmake
@@ -0,0 +1,71 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(OPENSUBDIV_EXTRA_ARGS
+ -DNO_EXAMPLES=ON
+ -DNO_REGRESSION=ON
+ -DNO_PYTHON=ON
+ -DNO_MAYA=ON
+ -DNO_PTEX=ON
+ -DNO_DOC=ON
+ -DNO_CLEW=OFF
+ -DNO_OPENCL=OFF
+ -DNO_TUTORIALS=ON
+ -DGLEW_INCLUDE_DIR=${LIBDIR}/glew/include
+ -DGLEW_LIBRARY=${LIBDIR}/glew/lib/libGLEW${LIBEXT}
+ -DGLFW_INCLUDE_DIR=${LIBDIR}/glfw/include
+ -DGLFW_LIBRARIES=${LIBDIR}/glfw/lib/glfw3${LIBEXT}
+)
+
+if(WIN32)
+ #no cuda support for vc15 yet
+ if(msvc15)
+ set(OPENSUBDIV_CUDA ON)
+ else()
+ set(OPENSUBDIV_CUDA ON)
+ endif()
+
+ set(OPENSUBDIV_EXTRA_ARGS
+ ${OPENSUBDIV_EXTRA_ARGS}
+ -DNO_CUDA=${OPENSUBDIV_CUDA}
+ -DCLEW_INCLUDE_DIR=${LIBDIR}/clew/include/cl
+ -DCLEW_LIBRARY=${LIBDIR}/clew/lib/clew${LIBEXT}
+ -DCUEW_INCLUDE_DIR=${LIBDIR}/cuew/include
+ -DCUEW_LIBRARY=${LIBDIR}/cuew/lib/cuew${LIBEXT}
+ -DCMAKE_EXE_LINKER_FLAGS_RELEASE=libcmt.lib
+ )
+else()
+ set(OPENSUBDIV_EXTRA_ARGS
+ ${OPENSUBDIV_EXTRA_ARGS}
+ -DNO_CUDA=ON
+ -DCUEW_INCLUDE_DIR=${LIBDIR}/cuew/include
+ -DCLEW_LIBRARY=${LIBDIR}/clew/lib/static/${LIBPREFIX}clew${LIBEXT}
+ )
+endif()
+
+ExternalProject_Add(external_opensubdiv
+ URL ${OPENSUBDIV_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${OPENSUBDIV_Hash}
+ PREFIX ${BUILD_DIR}/opensubdiv
+ PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/opensubdiv/src/external_opensubdiv < ${PATCH_DIR}/opensubdiv.diff
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/opensubdiv -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${OPENSUBDIV_EXTRA_ARGS}
+ INSTALL_DIR ${LIBDIR}/opensubdiv
+)
+
+add_dependencies(external_opensubdiv external_glew external_glfw external_clew external_cuew)
diff --git a/build_files/build_environment/cmake/openvdb.cmake b/build_files/build_environment/cmake/openvdb.cmake
new file mode 100644
index 00000000000..a71598c1a3b
--- /dev/null
+++ b/build_files/build_environment/cmake/openvdb.cmake
@@ -0,0 +1,71 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+if(BUILD_MODE STREQUAL Debug)
+ set(BLOSC_POST _d)
+endif()
+
+set(OPENVDB_EXTRA_ARGS
+ -DILMBASE_HOME=${LIBDIR}/ilmbase/
+ -DILMBASE_CUSTOM=ON
+ -DILMBASE_CUSTOM_LIBRARIES=Half;Imath-2_2;IlmThread-2_2;Iex-2_2
+ -DILMBASE_INCLUDE_DIR=${LIBDIR}/ilmbase/include/
+ -DILMBASE_HALF_LIBRARIES=${LIBDIR}/ilmbase/lib/Half${LIBEXT}
+ -DILMBASE_IMATH_LIBRARIES=${LIBDIR}/ilmbase/lib/${LIBPREFIX}Imath-2_2${LIBEXT}
+ -DILMBASE_ILMTHREAD_LIBRARIES=${LIBDIR}/ilmbase/lib/${LIBPREFIX}IlmThread-2_2${LIBEXT}
+ -DILMBASE_IEX_LIBRARIES=${LIBDIR}/ilmbase/lib/${LIBPREFIX}Iex-2_2${LIBEXT}
+ -DOPENEXR_HOME=${LIBDIR}/openexr/
+ -DOPENEXR_USE_STATIC_LIBS=ON
+ -DOPENEXR_CUSTOM=ON
+ -DOPENEXR_CUSTOM_LIBRARY=IlmImf-2_2
+ -DOPENEXR_INCLUDE_DIR=${LIBDIR}/openexr/include/
+ -DOPENEXR_ILMIMF_LIBRARIES=${LIBDIR}/openexr/lib/${LIBPREFIX}IlmImf-2_2${LIBEXT}
+ -DTBB_ROOT_DIR=${LIBDIR}/tbb/
+ -DTBB_INCLUDE_DIRS=${LIBDIR}/tbb/include
+ -DTBB_LIBRARY=${LIBDIR}/tbb/lib/tbb_static${LIBEXT}
+ -DBoost_COMPILER:STRING=${BOOST_COMPILER_STRING}
+ -DBoost_USE_MULTITHREADED=ON
+ -DBoost_USE_STATIC_LIBS=ON
+ -DBoost_USE_STATIC_RUNTIME=ON
+ -DBOOST_ROOT=${LIBDIR}/boost
+ -DBoost_NO_SYSTEM_PATHS=ON
+ -DZLIB_LIBRARY=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY}
+ -DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include/
+ -DWITH_BLOSC=ON
+ -DBLOSC_INCLUDE_DIR=${LIBDIR}/blosc/include/
+ -DBLOSC_LIBRARY=${LIBDIR}/blosc/lib/libblosc${BLOSC_POST}${LIBEXT}
+)
+
+set(OPENVDB_EXTRA_ARGS ${OPENVDB_EXTRA_ARGS})
+
+# CMake script for OpenVDB based on https://raw.githubusercontent.com/diekev/openvdb-cmake/master/CMakeLists.txt
+# can't be in external_openvdb because of how the includes are setup.
+
+ExternalProject_Add(openvdb
+ URL ${OPENVDB_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${OPENVDB_HASH}
+ PREFIX ${BUILD_DIR}/openvdb
+ PATCH_COMMAND COMMAND ${CMAKE_COMMAND} -E copy ${PATCH_DIR}/cmakelists_openvdb.txt ${BUILD_DIR}/openvdb/src/openvdb/CMakeLists.txt &&
+ ${CMAKE_COMMAND} -E copy_directory ${PATCH_DIR}/cmake/ ${BUILD_DIR}/openvdb/src/openvdb/cmake/ &&
+ ${PATCH_CMD} --verbose -p 0 -N -d ${BUILD_DIR}/openvdb/src/openvdb < ${PATCH_DIR}/openvdb_vc2013.diff
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openvdb ${DEFAULT_CMAKE_FLAGS} ${OPENVDB_EXTRA_ARGS}
+ INSTALL_DIR ${LIBDIR}/openvdb
+)
+
+add_dependencies(openvdb external_tbb external_boost external_ilmbase external_openexr external_zlib external_blosc)
diff --git a/build_files/build_environment/cmake/options.cmake b/build_files/build_environment/cmake/options.cmake
new file mode 100644
index 00000000000..9979a682614
--- /dev/null
+++ b/build_files/build_environment/cmake/options.cmake
@@ -0,0 +1,210 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+if(WIN32)
+ option(ENABLE_MINGW64 "Enable building of ffmpeg/iconv/libsndfile/lapack/fftw3 by installing mingw64" ON)
+endif()
+option(WITH_WEBP "Enable building of oiio with webp support" OFF)
+set(MAKE_THREADS 1 CACHE STRING "Number of threads to run make with")
+
+if(NOT BUILD_MODE)
+ set(BUILD_MODE "Release")
+ message(STATUS "Build type not specified: defaulting to a release build.")
+endif()
+Message("BuildMode = ${BUILD_MODE}")
+
+if(BUILD_MODE STREQUAL "Debug")
+ set(LIBDIR ${CMAKE_CURRENT_BINARY_DIR}/Debug)
+ELSE(BUILD_MODE STREQUAL "Debug")
+ set(LIBDIR ${CMAKE_CURRENT_BINARY_DIR}/Release)
+ENDIF(BUILD_MODE STREQUAL "Debug")
+
+option(DOWNLOAD_DIR "Path for downloaded files" ${CMAKE_CURRENT_SOURCE_DIR}/downloads)
+file(TO_CMAKE_PATH ${DOWNLOAD_DIR} DOWNLOAD_DIR)
+set(PATCH_DIR ${CMAKE_CURRENT_SOURCE_DIR}/patches)
+set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/build)
+
+message("LIBDIR = ${LIBDIR}")
+message("DOWNLOAD_DIR = ${DOWNLOAD_DIR}")
+message("PATCH_DIR = ${PATCH_DIR}")
+message("BUILD_DIR = ${BUILD_DIR}")
+
+if(WIN32)
+ if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
+ set(PATCH_CMD ${DOWNLOAD_DIR}/mingw/mingw64/msys/1.0/bin/patch.exe)
+ else()
+ set(PATCH_CMD ${DOWNLOAD_DIR}/mingw/mingw32/msys/1.0/bin/patch.exe)
+ endif()
+ set(LIBEXT ".lib")
+ set(LIBPREFIX "")
+
+ # For OIIO and OSL
+ set(COMMON_DEFINES /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS)
+
+ # TODO FIXME highly MSVC specific
+ if(WITH_OPTIMIZED_DEBUG)
+ set(BLENDER_CMAKE_C_FLAGS_DEBUG "/MTd /O2 /Ob2 /DNDEBUG /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
+ else()
+ set(BLENDER_CMAKE_C_FLAGS_DEBUG "/MTd /Zi /Ob0 /Od /RTC1 /D_DEBUG /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
+ endif()
+ set(BLENDER_CMAKE_C_FLAGS_MINSIZEREL "/MT /O1 /Ob1 /D NDEBUG /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
+ set(BLENDER_CMAKE_C_FLAGS_RELEASE "/MT /O2 /Ob2 /DNDEBUG /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
+ set(BLENDER_CMAKE_C_FLAGS_RELWITHDEBINFO "/MT /Zi /O2 /Ob1 /D NDEBUG /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
+
+ if(WITH_OPTIMIZED_DEBUG)
+ set(BLENDER_CMAKE_CXX_FLAGS_DEBUG "/MTd /O2 /Ob2 /D NDEBUG /D PLATFORM_WINDOWS /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
+ else()
+ set(BLENDER_CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /D PLATFORM_WINDOWS /MTd /Zi /Ob0 /Od /RTC1 /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
+ endif()
+ set(BLENDER_CMAKE_CXX_FLAGS_MINSIZEREL "/MT /O1 /Ob1 /D NDEBUG /D PLATFORM_WINDOWS /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
+ set(BLENDER_CMAKE_CXX_FLAGS_RELEASE "/MT /O2 /Ob2 /D NDEBUG /D PLATFORM_WINDOWS /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
+ set(BLENDER_CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MT /Zi /O2 /Ob1 /D NDEBUG /D PLATFORM_WINDOWS /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS")
+
+ set(PLATFORM_FLAGS)
+ set(PLATFORM_CXX_FLAGS)
+ set(PLATFORM_CMAKE_FLAGS)
+
+ if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
+ set(MINGW_PATH ${DOWNLOAD_DIR}/mingw/mingw64)
+ set(MINGW_SHELL ming64sh.cmd)
+ set(PERL_SHELL ${DOWNLOAD_DIR}/perl/portableshell.bat)
+ set(MINGW_HOST x86_64-w64-mingw32)
+ else()
+ set(MINGW_PATH ${DOWNLOAD_DIR}/mingw/mingw32)
+ set(MINGW_SHELL ming32sh.cmd)
+ set(PERL_SHELL ${DOWNLOAD_DIR}/perl32/portableshell.bat)
+ set(MINGW_HOST i686-w64-mingw32)
+ endif()
+
+ set(CONFIGURE_ENV
+ cd ${MINGW_PATH} &&
+ call ${MINGW_SHELL} &&
+ call ${PERL_SHELL} &&
+ set path &&
+ set CFLAGS=-g &&
+ set LDFLAGS=-Wl,--as-needed -static-libgcc
+ )
+
+ set(CONFIGURE_ENV_NO_PERL
+ cd ${MINGW_PATH} &&
+ call ${MINGW_SHELL} &&
+ set path &&
+ set CFLAGS=-g &&
+ set LDFLAGS=-Wl,--as-needed -static-libgcc
+ )
+
+ set(CONFIGURE_COMMAND sh ./configure)
+ set(CONFIGURE_COMMAND_NO_TARGET ${CONFIGURE_COMMAND})
+else()
+ set(PATCH_CMD patch)
+ set(LIBEXT ".a")
+ set(LIBPREFIX "lib")
+
+ if(APPLE)
+# Let's get the current Xcode dir, to support xcode-select
+ execute_process(
+ COMMAND xcode-select --print-path
+ OUTPUT_VARIABLE XCODE_DEV_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
+ set(OSX_ARCHITECTURES x86_64)
+ set(OSX_DEPLOYMENT_TARGET 10.9)
+ set(OSX_SDK_VERSION 10.12)
+ set(OSX_SYSROOT ${XCODE_DEV_PATH}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${OSX_SDK_VERSION}.sdk)
+
+ set(PLATFORM_CFLAGS "-isysroot ${OSX_SYSROOT} -mmacosx-version-min=${OSX_DEPLOYMENT_TARGET}")
+ set(PLATFORM_CXXFLAGS "-isysroot ${OSX_SYSROOT} -mmacosx-version-min=${OSX_DEPLOYMENT_TARGET} -std=c++11 -stdlib=libc++")
+ set(PLATFORM_LDFLAGS "-isysroot ${OSX_SYSROOT} -mmacosx-version-min=${OSX_DEPLOYMENT_TARGET}")
+ set(PLATFORM_BUILD_TARGET --build=x86_64-apple-darwin13.0.0) # OS X 10.9
+ set(PLATFORM_CMAKE_FLAGS
+ -DCMAKE_OSX_ARCHITECTURES:STRING=${OSX_ARCHITECTURES}
+ -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${OSX_DEPLOYMENT_TARGET}
+ -DCMAKE_OSX_SYSROOT:PATH=${OSX_SYSROOT}
+ )
+ else()
+ set(PLATFORM_CFLAGS "-fPIC")
+ set(PLATFORM_CXXFLAGS "-std=c++11 -fPIC")
+ set(PLATFORM_LDFLAGS)
+ set(PLATFORM_BUILD_TARGET)
+ set(PLATFORM_CMAKE_FLAGS)
+ endif()
+
+ if(WITH_OPTIMIZED_DEBUG)
+ set(BLENDER_CMAKE_C_FLAGS_DEBUG "-O2 -DNDEBUG")
+ else()
+ set(BLENDER_CMAKE_C_FLAGS_DEBUG "-g")
+ endif()
+ set(BLENDER_CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG")
+ set(BLENDER_CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
+ set(BLENDER_CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG")
+
+ if(WITH_OPTIMIZED_DEBUG)
+ set(BLENDER_CMAKE_CXX_FLAGS_DEBUG "-O2 -DNDEBUG ${PLATFORM_CXXFLAGS}")
+ else()
+ set(BLENDER_CMAKE_CXX_FLAGS_DEBUG "-g ${PLATFORM_CXXFLAGS}")
+ endif()
+
+ set(BLENDER_CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG ${PLATFORM_CXXFLAGS}")
+ set(BLENDER_CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG ${PLATFORM_CXXFLAGS}")
+ set(BLENDER_CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG ${PLATFORM_CXXFLAGS}")
+
+ set(CONFIGURE_ENV
+ export MACOSX_DEPLOYMENT_TARGET=${OSX_DEPLOYMENT_TARGET} &&
+ export CFLAGS=${PLATFORM_CFLAGS} &&
+ export CXXFLAGS=${PLATFORM_CXXFLAGS} &&
+ export LDFLAGS=${PLATFORM_LDFLAGS}
+ )
+ set(CONFIGURE_ENV_NO_PERL ${CONFIGURE_ENV})
+ set(CONFIGURE_COMMAND ./configure ${PLATFORM_BUILD_TARGET})
+ set(CONFIGURE_COMMAND_NO_TARGET ./configure)
+endif()
+
+set(DEFAULT_CMAKE_FLAGS
+ -DCMAKE_BUILD_TYPE=${BUILD_MODE}
+ -DCMAKE_C_FLAGS_DEBUG=${BLENDER_CMAKE_C_FLAGS_DEBUG}
+ -DCMAKE_C_FLAGS_MINSIZEREL=${BLENDER_CMAKE_C_FLAGS_MINSIZEREL}
+ -DCMAKE_C_FLAGS_RELEASE=${BLENDER_CMAKE_C_FLAGS_RELEASE}
+ -DCMAKE_C_FLAGS_RELWITHDEBINFO=${BLENDER_CMAKE_C_FLAGS_RELWITHDEBINFO}
+ -DCMAKE_CXX_FLAGS_DEBUG=${BLENDER_CMAKE_CXX_FLAGS_DEBUG}
+ -DCMAKE_CXX_FLAGS_MINSIZEREL=${BLENDER_CMAKE_CXX_FLAGS_MINSIZEREL}
+ -DCMAKE_CXX_FLAGS_RELEASE=${BLENDER_CMAKE_CXX_FLAGS_RELEASE}
+ -DCMAKE_CXX_FLAGS_RELWITHDEBINFO=${CMAKE_CXX_FLAGS_RELWITHDEBINFO}
+ ${PLATFORM_CMAKE_FLAGS}
+)
+
+if(WIN32)
+ #we need both flavors to build the thumbnail dlls
+ if(MSVC12)
+ set(GENERATOR_32 "Visual Studio 12 2013")
+ set(GENERATOR_64 "Visual Studio 12 2013 Win64")
+ elseif(MSVC14)
+ set(GENERATOR_32 "Visual Studio 14 2015")
+ set(GENERATOR_64 "Visual Studio 14 2015 Win64")
+ endif()
+endif()
+
+
+if(WIN32)
+ set(ZLIB_LIBRARY zlibstatic${LIBEXT})
+else()
+ set(ZLIB_LIBRARY libz${LIBEXT})
+endif()
+
+if(MSVC)
+ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
+endif()
+
+set(CMAKE_INSTALL_MESSAGE LAZY)
diff --git a/build_files/build_environment/cmake/orc.cmake b/build_files/build_environment/cmake/orc.cmake
new file mode 100644
index 00000000000..aac7884f49e
--- /dev/null
+++ b/build_files/build_environment/cmake/orc.cmake
@@ -0,0 +1,32 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+ExternalProject_Add(external_orc
+ URL ${ORC_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH SHA256=${ORC_HASH}
+ PREFIX ${BUILD_DIR}/orc
+ CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/orc/src/external_orc/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/orc --disable-shared --enable-static
+ BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/orc/src/external_orc/ && make -j${MAKE_THREADS}
+ INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/orc/src/external_orc/ && make install
+ INSTALL_DIR ${LIBDIR}/orc
+)
+
+if(MSVC)
+ set_target_properties(external_orc PROPERTIES FOLDER Mingw)
+endif()
diff --git a/build_files/build_environment/cmake/osl.cmake b/build_files/build_environment/cmake/osl.cmake
new file mode 100644
index 00000000000..5ddb981c604
--- /dev/null
+++ b/build_files/build_environment/cmake/osl.cmake
@@ -0,0 +1,87 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+if(WIN32)
+ set(OSL_CMAKE_CXX_STANDARD_LIBRARIES "kernel32${LIBEXT} user32${LIBEXT} gdi32${LIBEXT} winspool${LIBEXT} shell32${LIBEXT} ole32${LIBEXT} oleaut32${LIBEXT} uuid${LIBEXT} comdlg32${LIBEXT} advapi32${LIBEXT} psapi${LIBEXT}")
+ set(OSL_FLEX_BISON -DFLEX_EXECUTABLE=${LIBDIR}/flexbison/win_flex.exe -DFLEX_EXTRA_OPTIONS="--wincompat" -DBISON_EXECUTABLE=${LIBDIR}/flexbison/win_bison.exe)
+ set(OSL_OPENIMAGEIO_LIBRARY "${LIBDIR}/openimageio/lib/${LIBPREFIX}OpenImageIO${LIBEXT};${LIBDIR}/openimageio/lib/${LIBPREFIX}OpenImageIO_Util${LIBEXT};${LIBDIR}/png/lib/libpng16${LIBEXT};${LIBDIR}/jpg/lib/${LIBPREFIX}jpeg${LIBEXT};${LIBDIR}/tiff/lib/${LIBPREFIX}tiff${LIBEXT};${LIBDIR}/openexr/lib/${LIBPREFIX}IlmImf-2_2${LIBEXT}")
+ if("${CMAKE_SIZEOF_VOID_P}" EQUAL "4")
+ set(OSL_SIMD_FLAGS -DOIIO_NOSIMD=1 -DOIIO_SIMD=0)
+ else()
+ set(OSL_SIMD_FLAGS -DOIIO_NOSIMD=1 -DOIIO_SIMD=sse2)
+ endif()
+else()
+ set(OSL_CMAKE_CXX_STANDARD_LIBRARIES)
+ set(OSL_FLEX_BISON)
+ set(OSL_OPENIMAGEIO_LIBRARY "${LIBDIR}/openimageio/lib/${LIBPREFIX}OpenImageIO${LIBEXT};${LIBDIR}/openimageio/lib/${LIBPREFIX}OpenImageIO_Util${LIBEXT};${LIBDIR}/png/lib/${LIBPREFIX}png16${LIBEXT};${LIBDIR}/jpg/lib/${LIBPREFIX}jpeg${LIBEXT};${LIBDIR}/tiff/lib/${LIBPREFIX}tiff${LIBEXT};${LIBDIR}/openexr/lib/${LIBPREFIX}IlmImf-2_2${LIBEXT}")
+endif()
+
+set(OSL_ILMBASE_CUSTOM_LIBRARIES "${LIBDIR}/ilmbase/lib/Imath-2_2.lib^^${LIBDIR}/ilmbase/lib/Half.lib^^${LIBDIR}/ilmbase/lib/IlmThread-2_2.lib^^${LIBDIR}/ilmbase/lib/Iex-2_2.lib")
+set(OSL_LLVM_LIBRARY "${LIBDIR}/llvm/lib/LLVMAnalysis${LIBEXT};${LIBDIR}/llvm/lib/LLVMAsmParser${LIBEXT};${LIBDIR}/llvm/lib/LLVMAsmPrinter${LIBEXT};${LIBDIR}/llvm/lib/LLVMBitReader${LIBEXT};${LIBDIR}/llvm/lib/LLVMBitWriter${LIBEXT};${LIBDIR}/llvm/lib/LLVMCodeGen${LIBEXT};${LIBDIR}/llvm/lib/LLVMCore${LIBEXT};${LIBDIR}/llvm/lib/LLVMDebugInfo${LIBEXT};${LIBDIR}/llvm/lib/LLVMExecutionEngine${LIBEXT};${LIBDIR}/llvm/lib/LLVMInstCombine${LIBEXT};${LIBDIR}/llvm/lib/LLVMInstrumentation${LIBEXT};${LIBDIR}/llvm/lib/LLVMInterpreter${LIBEXT};${LIBDIR}/llvm/lib/LLVMJIT${LIBEXT};${LIBDIR}/llvm/lib/LLVMLinker${LIBEXT};${LIBDIR}/llvm/lib/LLVMMC${LIBEXT};${LIBDIR}/llvm/lib/LLVMMCDisassembler${LIBEXT};${LIBDIR}/llvm/lib/LLVMMCJIT${LIBEXT};${LIBDIR}/llvm/lib/LLVMMCParser${LIBEXT};${LIBDIR}/llvm/lib/LLVMObject${LIBEXT};${LIBDIR}/llvm/lib/LLVMRuntimeDyld${LIBEXT};${LIBDIR}/llvm/lib/LLVMScalarOpts${LIBEXT};${LIBDIR}/llvm/lib/LLVMSelectionDAG${LIBEXT};${LIBDIR}/llvm/lib/LLVMSupport${LIBEXT};${LIBDIR}/llvm/lib/LLVMTableGen${LIBEXT};${LIBDIR}/llvm/lib/LLVMTarget${LIBEXT};${LIBDIR}/llvm/lib/LLVMTransformUtils${LIBEXT};${LIBDIR}/llvm/lib/LLVMVectorize${LIBEXT};${LIBDIR}/llvm/lib/LLVMX86AsmParser${LIBEXT};${LIBDIR}/llvm/lib/LLVMX86AsmPrinter${LIBEXT};${LIBDIR}/llvm/lib/LLVMX86CodeGen${LIBEXT};${LIBDIR}/llvm/lib/LLVMX86Desc${LIBEXT};${LIBDIR}/llvm/lib/LLVMX86Disassembler${LIBEXT};${LIBDIR}/llvm/lib/LLVMX86Info${LIBEXT};${LIBDIR}/llvm/lib/LLVMX86Utils${LIBEXT};${LIBDIR}/llvm/lib/LLVMipa${LIBEXT};${LIBDIR}/llvm/lib/LLVMipo${LIBEXT}")
+
+set(OSL_EXTRA_ARGS
+ -DBoost_COMPILER:STRING=${BOOST_COMPILER_STRING}
+ -DBoost_USE_MULTITHREADED=ON
+ -DBoost_USE_STATIC_LIBS=ON
+ -DBoost_USE_STATIC_RUNTIME=ON
+ -DBOOST_ROOT=${LIBDIR}/boost
+ -DBOOST_LIBRARYDIR=${LIBDIR}/boost/lib/
+ -DBoost_NO_SYSTEM_PATHS=ON
+ -DLLVM_DIRECTORY=${LIBDIR}/llvm
+ -DLLVM_INCLUDES=${LIBDIR}/llvm/include
+ -DLLVM_LIB_DIR=${LIBDIR}/llvm/lib
+ -DLLVM_VERSION=3.4
+ -DLLVM_LIBRARY=${OSL_LLVM_LIBRARY}
+ -DOPENEXR_HOME=${LIBDIR}/openexr/
+ -DILMBASE_HOME=${LIBDIR}/ilmbase/
+ -DILMBASE_INCLUDE_DIR=${LIBDIR}/ilmbase/include/
+ -DOPENEXR_IMATH_LIBRARY=${LIBDIR}/ilmbase/lib/${LIBPREFIX}Imath-2_2${LIBEXT}
+ -DOPENEXR_ILMTHREAD_LIBRARY=${LIBDIR}/ilmbase/lib/${LIBPREFIX}IlmThread-2_2${LIBEXT}
+ -DOPENEXR_IEX_LIBRARY=${LIBDIR}/ilmbase/lib/${LIBPREFIX}Iex-2_2${LIBEXT}
+ -DOPENEXR_INCLUDE_DIR=${LIBDIR}/openexr/include/
+ -DOPENEXR_ILMIMF_LIBRARY=${LIBDIR}/openexr/lib/${LIBPREFIX}IlmImf-2_2${LIBEXT}
+ -DOSL_BUILD_TESTS=OFF
+ -DZLIB_LIBRARY=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY}
+ -DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include/
+ -DOPENIMAGEIOHOME=${LIBDIR}/openimageio/
+ -DOPENIMAGEIO_LIBRARY=${OSL_OPENIMAGEIO_LIBRARY}
+ -DOPENIMAGEIO_INCLUDES=${LIBDIR}/openimageio/include
+ ${OSL_FLEX_BISON}
+ -DCMAKE_CXX_STANDARD_LIBRARIES=${OSL_CMAKE_CXX_STANDARD_LIBRARIES}
+ -DBUILDSTATIC=ON
+ -DLINKSTATIC=ON
+ -DOSL_BUILD_PLUGINS=Off
+ -DSTOP_ON_WARNING=OFF
+ -DOSL_BUILD_CPP11=ON
+ -DUSE_LLVM_BITCODE=OFF
+ ${OSL_SIMD_FLAGS}
+)
+
+ExternalProject_Add(external_osl
+ URL ${OSL_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ LIST_SEPARATOR ^^
+ URL_HASH MD5=${OSL_HASH}
+ PREFIX ${BUILD_DIR}/osl
+ PATCH_COMMAND ${PATCH_CMD} -p 3 -d ${BUILD_DIR}/osl/src/external_osl < ${PATCH_DIR}/osl.diff &&
+ ${PATCH_CMD} -p 0 -d ${BUILD_DIR}/osl/src/external_osl < ${PATCH_DIR}/osl_simd_oiio.diff
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/osl -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${DEFAULT_CMAKE_FLAGS} ${OSL_EXTRA_ARGS}
+ INSTALL_DIR ${LIBDIR}/osl
+)
+
+add_dependencies(external_osl external_boost ll external_clang external_ilmbase external_openexr external_zlib external_flexbison external_openimageio)
diff --git a/build_files/build_environment/cmake/png.cmake b/build_files/build_environment/cmake/png.cmake
new file mode 100644
index 00000000000..8d6fee871f9
--- /dev/null
+++ b/build_files/build_environment/cmake/png.cmake
@@ -0,0 +1,41 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(PNG_EXTRA_ARGS
+ -DZLIB_LIBRARY=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY}
+ -DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include/
+ -DPNG_STATIC=ON
+)
+
+ExternalProject_Add(external_png
+ URL ${PNG_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${PNG_HASH}
+ PREFIX ${BUILD_DIR}/png
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/png ${DEFAULT_CMAKE_FLAGS} ${PNG_EXTRA_ARGS}
+ INSTALL_DIR ${LIBDIR}/png
+)
+
+add_dependencies(external_png external_zlib)
+
+if(BUILD_MODE STREQUAL Debug)
+ ExternalProject_Add_Step(external_png after_install
+ COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/png/lib/libpng16_staticd${LIBEXT} ${LIBDIR}/png/lib/libpng16${LIBEXT}
+ DEPENDEES install
+ )
+endif()
diff --git a/build_files/build_environment/cmake/pthreads.cmake b/build_files/build_environment/cmake/pthreads.cmake
new file mode 100644
index 00000000000..f4301b95f3a
--- /dev/null
+++ b/build_files/build_environment/cmake/pthreads.cmake
@@ -0,0 +1,45 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+if(WIN32)
+ set(PTHREAD_XCFLAGS /MD)
+
+ if(MSVC14) # vs2015 has timespec
+ set(PTHREAD_CPPFLAGS "/I. /DHAVE_PTW32_CONFIG_H /D_TIMESPEC_DEFINED ")
+ else() # everything before doesn't
+ set(PTHREAD_CPPFLAGS "/I. /DHAVE_PTW32_CONFIG_H ")
+ endif()
+
+ set(PTHREADS_BUILD cd ${BUILD_DIR}/pthreads/src/external_pthreads/ && cd && nmake VC /e CPPFLAGS=${PTHREAD_CPPFLAGS} /e XCFLAGS=${PTHREAD_XCFLAGS} /e XLIBS=/NODEFAULTLIB:msvcr)
+
+ ExternalProject_Add(external_pthreads
+ URL ${PTHREADS_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH SHA512=${PTHREADS_SHA512}
+ PREFIX ${BUILD_DIR}/pthreads
+ CONFIGURE_COMMAND echo .
+ PATCH_COMMAND ${PATCH_CMD} --verbose -p 0 -N -d ${BUILD_DIR}/pthreads/src/external_pthreads < ${PATCH_DIR}/pthreads.diff
+ BUILD_COMMAND ${PTHREADS_BUILD}
+ INSTALL_COMMAND COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/pthreads/src/external_pthreads/pthreadVC2.dll ${LIBDIR}/pthreads/lib/pthreadVC2.dll &&
+ ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/pthreads/src/external_pthreads/pthreadVC2${LIBEXT} ${LIBDIR}/pthreads/lib/pthreadVC2${LIBEXT} &&
+ ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/pthreads/src/external_pthreads/pthread.h ${LIBDIR}/pthreads/inc/pthread.h &&
+ ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/pthreads/src/external_pthreads/sched.h ${LIBDIR}/pthreads/inc/sched.h &&
+ ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/pthreads/src/external_pthreads/semaphore.h ${LIBDIR}/pthreads/inc/semaphore.h
+ INSTALL_DIR ${LIBDIR}/pthreads
+ )
+endif()
diff --git a/build_files/build_environment/cmake/python.cmake b/build_files/build_environment/cmake/python.cmake
new file mode 100644
index 00000000000..98d9d4ae63e
--- /dev/null
+++ b/build_files/build_environment/cmake/python.cmake
@@ -0,0 +1,138 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(PYTHON_POSTFIX)
+if(BUILD_MODE STREQUAL Debug)
+ set(PYTHON_POSTFIX _d)
+endif()
+
+if(WIN32)
+ set(PYTHON_BINARY ${BUILD_DIR}/python/src/external_python/run/python${PYTHON_POSTFIX}.exe)
+
+ macro(cmake_to_dos_path MsysPath ResultingPath)
+ string(REPLACE "/" "\\" ${ResultingPath} "${MsysPath}")
+ endmacro()
+
+ set(PYTHON_EXTERNALS_FOLDER ${BUILD_DIR}/python/src/external_python/externals)
+ set(DOWNLOADS_EXTERNALS_FOLDER ${DOWNLOAD_DIR}/externals)
+
+ cmake_to_dos_path(${PYTHON_EXTERNALS_FOLDER} PYTHON_EXTERNALS_FOLDER_DOS)
+ cmake_to_dos_path(${DOWNLOADS_EXTERNALS_FOLDER} DOWNLOADS_EXTERNALS_FOLDER_DOS)
+
+ message("Python externals = ${PYTHON_EXTERNALS_FOLDER}")
+ message("Python externals_dos = ${PYTHON_EXTERNALS_FOLDER_DOS}")
+ message("Python DOWNLOADS_EXTERNALS_FOLDER = ${DOWNLOADS_EXTERNALS_FOLDER}")
+ message("Python DOWNLOADS_EXTERNALS_FOLDER_DOS = ${DOWNLOADS_EXTERNALS_FOLDER_DOS}")
+
+ ExternalProject_Add(external_python
+ URL ${PYTHON_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${PYTHON_HASH}
+ PREFIX ${BUILD_DIR}/python
+ PATCH_COMMAND echo mklink /D "${PYTHON_EXTERNALS_FOLDER_DOS}" "${DOWNLOADS_EXTERNALS_FOLDER_DOS}" &&
+ mklink /D "${PYTHON_EXTERNALS_FOLDER_DOS}" "${DOWNLOADS_EXTERNALS_FOLDER_DOS}" &&
+ ${PATCH_CMD} --verbose -p 0 -d ${BUILD_DIR}/python/src/external_python < ${PATCH_DIR}/python.diff &&
+ ${PATCH_CMD} --verbose -p 0 -d ${BUILD_DIR}/python/src/external_python/pc < ${PATCH_DIR}/pyshell.diff
+ CONFIGURE_COMMAND ""
+ BUILD_COMMAND cd ${BUILD_DIR}/python/src/external_python/pcbuild/ && set IncludeTkinter=false && call build.bat -e -p ${PYTHON_ARCH} -c ${BUILD_MODE} -k ${PYTHON_COMPILER_STRING}
+ INSTALL_COMMAND COMMAND ${CMAKE_COMMAND} -E copy ${PYTHON_OUTPUTDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.dll ${LIBDIR}/python/lib/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.dll &&
+ ${CMAKE_COMMAND} -E copy ${PYTHON_OUTPUTDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.lib ${LIBDIR}/python/lib/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.lib &&
+ ${CMAKE_COMMAND} -E copy ${PYTHON_OUTPUTDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.exp ${LIBDIR}/python/lib/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.exp &&
+ ${CMAKE_COMMAND} -E copy_directory ${BUILD_DIR}/python/src/external_python/include ${LIBDIR}/python/include/Python${PYTHON_SHORT_VERSION} &&
+ ${CMAKE_COMMAND} -E copy "${BUILD_DIR}/python/src/external_python/PC/pyconfig.h" ${LIBDIR}/python/include/Python${PYTHON_SHORT_VERSION}/pyconfig.h
+ )
+ Message("PythinRedist = ${BUILD_DIR}/python/src/external_python/redist")
+ Message("POutput = ${PYTHON_OUTPUTDIR}")
+else()
+ if(APPLE)
+ # we need to manually add homebrew headers to get ssl module building
+ set(PYTHON_CFLAGS "-I/usr/local/opt/openssl/include -I${OSX_SYSROOT}/usr/include ${PLATFORM_CFLAGS}")
+ set(PYTHON_LDFLAGS "-L/usr/local/opt/openssl/lib ${PLATFORM_LDFLAGS}")
+ set(PYTHON_CONFIGURE_ENV ${CONFIGURE_ENV} && export CFLAGS=${PYTHON_CFLAGS} && export LDFLAGS=${PYTHON_LDFLAGS})
+ set(PYTHON_BINARY ${BUILD_DIR}/python/src/external_python/python.exe)
+ set(PYTHON_PATCH ${PATCH_CMD} --verbose -p 0 -d ${BUILD_DIR}/python/src/external_python < ${PATCH_DIR}/python_apple.diff)
+ else()
+ set(PYTHON_CONFIGURE_ENV ${CONFIGURE_ENV})
+ set(PYTHON_BINARY ${BUILD_DIR}/python/src/external_python/python)
+ endif()
+
+ ExternalProject_Add(external_python
+ URL ${PYTHON_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${PYTHON_HASH}
+ PREFIX ${BUILD_DIR}/python
+ PATCH_COMMAND ${PYTHON_PATCH}
+ CONFIGURE_COMMAND ${PYTHON_CONFIGURE_ENV} && cd ${BUILD_DIR}/python/src/external_python/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/python
+ BUILD_COMMAND ${PYTHON_CONFIGURE_ENV} && cd ${BUILD_DIR}/python/src/external_python/ && make -j${MAKE_THREADS}
+ INSTALL_COMMAND ${PYTHON_CONFIGURE_ENV} && cd ${BUILD_DIR}/python/src/external_python/ && make install
+ INSTALL_DIR ${LIBDIR}/python)
+
+ add_custom_target(Make_Python_Environment ALL DEPENDS external_python)
+endif()
+
+if(MSVC)
+ add_custom_command(
+ OUTPUT ${LIBDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.tar.gz
+ OUTPUT ${BUILD_DIR}/python/src/external_python/redist/bin/python${PYTHON_POSTFIX}.exe
+ COMMAND ${CMAKE_COMMAND} -E copy_directory ${BUILD_DIR}/python/src/external_python/lib ${BUILD_DIR}/python/src/external_python/redist/lib
+ COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/python${PYTHON_POSTFIX}.exe" ${BUILD_DIR}/python/src/external_python/redist/bin/python${PYTHON_POSTFIX}.exe
+ COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_bz2${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_bz2${PYTHON_POSTFIX}.pyd
+ COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_hashlib${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_hashlib${PYTHON_POSTFIX}.pyd
+ COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_lzma${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_lzma${PYTHON_POSTFIX}.pyd
+ COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_sqlite3${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_sqlite3${PYTHON_POSTFIX}.pyd
+ COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_ssl${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_ssl${PYTHON_POSTFIX}.pyd
+ COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/pyexpat${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/pyexpat${PYTHON_POSTFIX}.pyd
+ COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/select${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/select${PYTHON_POSTFIX}.pyd
+ COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/unicodedata${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/unicodedata${PYTHON_POSTFIX}.pyd
+ COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/winsound${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/winsound${PYTHON_POSTFIX}.pyd
+ COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_ctypes${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_ctypes${PYTHON_POSTFIX}.pyd
+ COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_ctypes_test${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_ctypes_test${PYTHON_POSTFIX}.pyd
+ COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_decimal${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_decimal${PYTHON_POSTFIX}.pyd
+ COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_elementtree${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_elementtree${PYTHON_POSTFIX}.pyd
+ COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_msi${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_msi${PYTHON_POSTFIX}.pyd
+ COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_multiprocessing${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_multiprocessing${PYTHON_POSTFIX}.pyd
+ COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_overlapped${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_overlapped${PYTHON_POSTFIX}.pyd
+ COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_socket${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_socket${PYTHON_POSTFIX}.pyd
+ COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_testbuffer${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_testbuffer${PYTHON_POSTFIX}.pyd
+ COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_testcapi${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_testcapi${PYTHON_POSTFIX}.pyd
+ COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_testimportmultiple${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_testimportmultiple${PYTHON_POSTFIX}.pyd
+ COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_testmultiphase${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_testmultiphase${PYTHON_POSTFIX}.pyd
+ COMMAND ${CMAKE_COMMAND} -E chdir "${BUILD_DIR}/python/src/external_python/redist" ${CMAKE_COMMAND} -E tar "cfvz" "${LIBDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.tar.gz" "."
+ )
+
+ add_custom_target(Package_Python ALL DEPENDS external_python ${LIBDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.tar.gz ${BUILD_DIR}/python/src/external_python/redist/bin/python${PYTHON_POSTFIX}.exe)
+
+ if(MSVC12)
+ set(PYTHON_DISTUTIL_PATCH ${PATCH_CMD} --verbose -p 0 -d ${BUILD_DIR}/python/src/external_python/run/lib/distutils < ${PATCH_DIR}/python_runtime_vc2013.diff)
+ else()
+ set(PYTHON_DISTUTIL_PATCH echo "No patch needed")
+ endif()
+
+ add_custom_command(OUTPUT ${BUILD_DIR}/python/src/external_python/run/python${PYTHON_POSTFIX}.exe
+ COMMAND ${CMAKE_COMMAND} -E copy_directory ${BUILD_DIR}/python/src/external_python/redist ${BUILD_DIR}/python/src/external_python/run
+ COMMAND ${CMAKE_COMMAND} -E copy_directory ${BUILD_DIR}/python/src/external_python/include ${BUILD_DIR}/python/src/external_python/run/include
+ COMMAND ${CMAKE_COMMAND} -E copy "${BUILD_DIR}/python/src/external_python/PC/pyconfig.h" ${BUILD_DIR}/python/src/external_python/run/include/pyconfig.h
+ COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.dll" ${BUILD_DIR}/python/src/external_python/run/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.dll
+ COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.lib" ${BUILD_DIR}/python/src/external_python/run/libs/python${PYTHON_SHORT_VERSION_NO_DOTS}.lib #missing postfix on purpose, distutils is not expecting it
+ COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.lib" ${BUILD_DIR}/python/src/external_python/run/libs/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.lib #other things like numpy still want it though.
+ COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/python${PYTHON_POSTFIX}.exe" ${BUILD_DIR}/python/src/external_python/run/python${PYTHON_POSTFIX}.exe
+ COMMAND ${BUILD_DIR}/python/src/external_python/run/python${PYTHON_POSTFIX}.exe -m ensurepip --upgrade
+ COMMAND ${PYTHON_DISTUTIL_PATCH}
+ )
+ add_custom_target(Make_Python_Environment ALL DEPENDS ${BUILD_DIR}/python/src/external_python/run/python${PYTHON_POSTFIX}.exe Package_Python)
+endif(MSVC)
diff --git a/build_files/build_environment/cmake/python_site_packages.cmake b/build_files/build_environment/cmake/python_site_packages.cmake
new file mode 100644
index 00000000000..530bae4c958
--- /dev/null
+++ b/build_files/build_environment/cmake/python_site_packages.cmake
@@ -0,0 +1,38 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+if(WIN32)
+ set(HARVEST_CMD cmd /C FOR /d /r ${BUILD_DIR}/python/src/external_python/run/lib/site-packages %d IN (__pycache__) DO @IF EXIST "%d" rd /s /q "%d" &&
+ ${CMAKE_COMMAND} -E copy_directory ${BUILD_DIR}/python/src/external_python/run/lib/site-packages/idna ${HARVEST_TARGET}/Release/site-packages/idna &&
+ ${CMAKE_COMMAND} -E copy_directory ${BUILD_DIR}/python/src/external_python/run/lib/site-packages/chardet ${HARVEST_TARGET}/Release/site-packages/chardet &&
+ ${CMAKE_COMMAND} -E copy_directory ${BUILD_DIR}/python/src/external_python/run/lib/site-packages/urllib3 ${HARVEST_TARGET}/Release/site-packages/urllib3 &&
+ ${CMAKE_COMMAND} -E copy_directory ${BUILD_DIR}/python/src/external_python/run/lib/site-packages/certifi ${HARVEST_TARGET}/Release/site-packages/certifi &&
+ ${CMAKE_COMMAND} -E copy_directory ${BUILD_DIR}/python/src/external_python/run/lib/site-packages/requests ${HARVEST_TARGET}/Release/site-packages/requests
+ )
+else()
+ set(HARVEST_CMD echo .)
+endif()
+
+ExternalProject_Add(external_python_site_packages
+ DOWNLOAD_COMMAND ""
+ CONFIGURE_COMMAND ""
+ BUILD_COMMAND ""
+ PREFIX ${BUILD_DIR}/site_packages
+ INSTALL_COMMAND ${PYTHON_BINARY} -m pip install idna==${IDNA_VERSION} chardet==${CHARDET_VERSION} urllib3==${URLLIB3_VERSION} certifi==${CERTIFI_VERSION} requests==${REQUESTS_VERSION} --no-binary :all: && ${HARVEST_CMD}
+)
+
+add_dependencies(external_python_site_packages Make_Python_Environment)
diff --git a/build_files/build_environment/cmake/schroedinger.cmake b/build_files/build_environment/cmake/schroedinger.cmake
new file mode 100644
index 00000000000..54a20db5b5e
--- /dev/null
+++ b/build_files/build_environment/cmake/schroedinger.cmake
@@ -0,0 +1,45 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+if(WIN32)
+ set(SCHROEDINGER_EXTRA_FLAGS "CFLAGS=-g -I./ -I${LIBDIR}/orc/include/orc-0.4" "LDFLAGS=-Wl,--as-needed -static-libgcc -L${LIBDIR}/orc/lib" ORC_CFLAGS=-I${LIBDIR}/orc/include/orc-0.4 ORC_LDFLAGS=-L${LIBDIR}/orc/lib ORC_LIBS=${LIBDIR}/orc/lib/liborc-0.4.a ORCC=${LIBDIR}/orc/bin/orcc.exe)
+else()
+ set(SCHROEDINGER_CFLAGS "${PLATFORM_CFLAGS} -I./ -I${LIBDIR}/orc/include/orc-0.4")
+ set(SCHROEDINGER_LDFLAGS "${PLATFORM_LDFLAGS} -L${LIBDIR}/orc/lib")
+ set(SCHROEDINGER_EXTRA_FLAGS CFLAGS=${SCHROEDINGER_CFLAGS} LDFLAGS=${SCHROEDINGER_LDFLAGS} ORC_CFLAGS=-I${LIBDIR}/orc/include/orc-0.4 ORC_LDFLAGS=-L${LIBDIR}/orc/lib ORCC=${LIBDIR}/orc/bin/orcc) # ORC_LIBS=${LIBDIR}/orc/lib/liborc-0.4.a
+endif()
+
+ExternalProject_Add(external_schroedinger
+ URL ${SCHROEDINGER_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH SHA256=${SCHROEDINGER_HASH}
+ PREFIX ${BUILD_DIR}/schroedinger
+ PATCH_COMMAND ${PATCH_CMD} --verbose -p 0 -N -d ${BUILD_DIR}/schroedinger/src/external_schroedinger < ${PATCH_DIR}/schroedinger.diff
+ CONFIGURE_COMMAND ${CONFIGURE_ENV} &&
+ cd ${BUILD_DIR}/schroedinger/src/external_schroedinger/ &&
+ ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/schroedinger --disable-shared --enable-static ${SCHROEDINGER_EXTRA_FLAGS}
+ BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/schroedinger/src/external_schroedinger/ && make -j${MAKE_THREADS}
+ INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/schroedinger/src/external_schroedinger/ && make install
+ INSTALL_DIR ${LIBDIR}/schroedinger
+)
+
+add_dependencies(external_schroedinger external_orc)
+
+if(MSVC)
+ set_target_properties(external_schroedinger PROPERTIES FOLDER Mingw)
+endif()
diff --git a/build_files/build_environment/cmake/sdl.cmake b/build_files/build_environment/cmake/sdl.cmake
new file mode 100644
index 00000000000..0fbfa078eb1
--- /dev/null
+++ b/build_files/build_environment/cmake/sdl.cmake
@@ -0,0 +1,39 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+if(WIN32)
+ set(SDL_EXTRA_ARGS
+ -DSDL_STATIC=Off
+ )
+else()
+ set(SDL_EXTRA_ARGS
+ -DSDL_STATIC=ON
+ -DSDL_SHARED=OFF
+ -DSDL_VIDEO=OFF
+ )
+endif()
+
+ExternalProject_Add(external_sdl
+ URL ${SDL_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${SDL_HASH}
+ PREFIX ${BUILD_DIR}/sdl
+ PATCH_COMMAND ${PATCH_CMD} -p 0 -N -d ${BUILD_DIR}/sdl/src/external_sdl < ${PATCH_DIR}/sdl.diff
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/sdl ${DEFAULT_CMAKE_FLAGS} ${SDL_EXTRA_ARGS}
+ INSTALL_DIR ${LIBDIR}/sdl
+)
diff --git a/build_files/build_environment/cmake/setup_mingw32.cmake b/build_files/build_environment/cmake/setup_mingw32.cmake
new file mode 100644
index 00000000000..f0d99356da0
--- /dev/null
+++ b/build_files/build_environment/cmake/setup_mingw32.cmake
@@ -0,0 +1,219 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+####################################################################################################################
+# Mingw32 Builds
+####################################################################################################################
+# This installs mingw32+msys to compile ffmpeg/iconv/libsndfile/lapack/fftw3
+####################################################################################################################
+
+message("LIBDIR = ${LIBDIR}")
+macro(cmake_to_msys_path MsysPath ResultingPath)
+ string(REPLACE ":" "" TmpPath "${MsysPath}")
+ string(SUBSTRING ${TmpPath} 0 1 Drive)
+ string(SUBSTRING ${TmpPath} 1 255 PathPart)
+ string(TOLOWER ${Drive} LowerDrive)
+ string(CONCAT ${ResultingPath} "/" ${LowerDrive} ${PathPart})
+endmacro()
+cmake_to_msys_path(${LIBDIR} mingw_LIBDIR)
+message("mingw_LIBDIR = ${mingw_LIBDIR}")
+
+message("Checking for mingw32")
+# download mingw32
+if(NOT EXISTS "${DOWNLOAD_DIR}/i686-w64-mingw32-gcc-4.8.0-win32_rubenvb.7z")
+ message("Downloading mingw32")
+ file(DOWNLOAD "https://nchc.dl.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/gcc-4.8-release/i686-w64-mingw32-gcc-4.8.0-win32_rubenvb.7z" "${DOWNLOAD_DIR}/i686-w64-mingw32-gcc-4.8.0-win32_rubenvb.7z")
+endif()
+
+# make mingw root directory
+if(NOT EXISTS "${DOWNLOAD_DIR}/mingw")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${DOWNLOAD_DIR}/mingw
+ WORKING_DIRECTORY ${DOWNLOAD_DIR}
+ )
+endif()
+
+# extract mingw32
+if((NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/mingw32env.cmd") AND (EXISTS "${DOWNLOAD_DIR}/i686-w64-mingw32-gcc-4.8.0-win32_rubenvb.7z"))
+ message("Extracting mingw32")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E tar jxf ${DOWNLOAD_DIR}/i686-w64-mingw32-gcc-4.8.0-win32_rubenvb.7z
+ WORKING_DIRECTORY ${DOWNLOAD_DIR}/mingw
+ )
+endif()
+
+message("Checking for pkg-config")
+if(NOT EXISTS "${DOWNLOAD_DIR}/pkg-config-lite-0.28-1_bin-win32.zip")
+ message("Downloading pkg-config")
+ file(DOWNLOAD "https://nchc.dl.sourceforge.net/project/pkgconfiglite/0.28-1/pkg-config-lite-0.28-1_bin-win32.zip" "${DOWNLOAD_DIR}/pkg-config-lite-0.28-1_bin-win32.zip")
+endif()
+
+# extract pkgconfig
+if((NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/pkg-config.exe") AND (EXISTS "${DOWNLOAD_DIR}/pkg-config-lite-0.28-1_bin-win32.zip"))
+ message("Extracting pkg-config")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E tar jxf "${DOWNLOAD_DIR}/pkg-config-lite-0.28-1_bin-win32.zip"
+ WORKING_DIRECTORY ${DOWNLOAD_DIR}/
+ )
+
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/pkg-config-lite-0.28-1/bin/pkg-config.exe" "${DOWNLOAD_DIR}/mingw/mingw32/bin/pkg-config.exe"
+ )
+
+endif()
+
+message("Checking for nasm")
+if(NOT EXISTS "${DOWNLOAD_DIR}/nasm-2.12.01-win32.zip")
+ message("Downloading nasm")
+ file(DOWNLOAD "http://www.nasm.us/pub/nasm/releasebuilds/2.12.01/win32/nasm-2.12.01-win32.zip" "${DOWNLOAD_DIR}/nasm-2.12.01-win32.zip")
+endif()
+
+# extract nasm
+if((NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/nasm.exe") AND (EXISTS "${DOWNLOAD_DIR}/nasm-2.12.01-win32.zip"))
+ message("Extracting nasm")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E tar jxf "${DOWNLOAD_DIR}/nasm-2.12.01-win32.zip"
+ WORKING_DIRECTORY ${DOWNLOAD_DIR}/
+ )
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/nasm-2.12.01/nasm.exe" "${DOWNLOAD_DIR}/mingw/mingw32/bin/nasm.exe"
+ )
+
+endif()
+
+message("Checking for mingwGet")
+if(NOT EXISTS "${DOWNLOAD_DIR}/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip")
+ message("Downloading mingw-get")
+ file(DOWNLOAD "https://nchc.dl.sourceforge.net/project/mingw/Installer/mingw-get/mingw-get-0.6.2-beta-20131004-1/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip" "${DOWNLOAD_DIR}/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip")
+endif()
+
+# extract mingw_get
+if((NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/mingw-get.exe") AND (EXISTS "${DOWNLOAD_DIR}/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip"))
+ message("Extracting mingw-get")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E tar jxf "${DOWNLOAD_DIR}/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip"
+ WORKING_DIRECTORY ${DOWNLOAD_DIR}/mingw/mingw32/
+ )
+endif()
+
+if((EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/mingw-get.exe") AND (NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/msys/1.0/bin/make.exe"))
+ message("Installing MSYS")
+ execute_process(
+ COMMAND ${DOWNLOAD_DIR}/mingw/mingw32/bin/mingw-get install msys msys-patch
+ WORKING_DIRECTORY ${DOWNLOAD_DIR}/mingw/mingw32/bin/
+ )
+endif()
+
+message("Checking for CoreUtils")
+# download old core_utils for pr.exe (ffmpeg needs it to build)
+if(NOT EXISTS "${DOWNLOAD_DIR}/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2")
+ message("Downloading CoreUtils 5.97")
+ file(DOWNLOAD "https://nchc.dl.sourceforge.net/project/mingw/MSYS/Base/msys-core/_obsolete/coreutils-5.97-MSYS-1.0.11-2/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2" "${DOWNLOAD_DIR}/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2")
+endif()
+
+if((EXISTS "${DOWNLOAD_DIR}/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2") AND (NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/msys/1.0/bin/pr.exe"))
+ message("Installing pr from CoreUtils 5.97")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${DOWNLOAD_DIR}/tmp_coreutils
+ WORKING_DIRECTORY ${DOWNLOAD_DIR}
+ )
+
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E tar jxf ${DOWNLOAD_DIR}/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2
+ WORKING_DIRECTORY ${DOWNLOAD_DIR}/tmp_coreutils/
+ )
+
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E copy ${DOWNLOAD_DIR}/tmp_coreutils/coreutils-5.97/bin/pr.exe "${DOWNLOAD_DIR}/mingw/mingw32/msys/1.0/bin/pr.exe"
+ WORKING_DIRECTORY ${DOWNLOAD_DIR}/tmp_coreutils/
+ )
+endif()
+
+if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/ming32sh.cmd")
+ message("Installing ming32sh.cmd")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E copy ${PATCH_DIR}/ming32sh.cmd ${DOWNLOAD_DIR}/mingw/mingw32/ming32sh.cmd
+ )
+endif()
+
+message("Checking for perl")
+# download perl for libvpx
+if(NOT EXISTS "${DOWNLOAD_DIR}/strawberry-perl-5.22.1.3-32bit-portable.zip")
+ message("Downloading perl")
+ file(DOWNLOAD "http://strawberryperl.com/download/5.22.1.3/strawberry-perl-5.22.1.3-32bit-portable.zip" "${DOWNLOAD_DIR}/strawberry-perl-5.22.1.3-32bit-portable.zip")
+endif()
+
+# make perl root directory
+if(NOT EXISTS "${DOWNLOAD_DIR}/perl32")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${DOWNLOAD_DIR}/perl32
+ WORKING_DIRECTORY ${DOWNLOAD_DIR}
+ )
+endif()
+
+# extract perl
+if((NOT EXISTS "${DOWNLOAD_DIR}/perl32/portable.perl") AND (EXISTS "${DOWNLOAD_DIR}/strawberry-perl-5.22.1.3-32bit-portable.zip"))
+ message("Extracting perl")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E tar jxf ${DOWNLOAD_DIR}/strawberry-perl-5.22.1.3-32bit-portable.zip
+ WORKING_DIRECTORY ${DOWNLOAD_DIR}/perl32
+ )
+endif()
+
+# get yasm for vpx
+if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/yasm.exe")
+ message("Downloading yasm")
+ file(DOWNLOAD "http://www.tortall.net/projects/yasm/releases/yasm-1.3.0-win32.exe" "${DOWNLOAD_DIR}/mingw/mingw32/bin/yasm.exe")
+endif()
+
+message("checking i686-w64-mingw32-strings")
+# copy strings.exe to i686-w64-mingw32-strings for x264
+if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-strings.exe")
+ message("fixing i686-w64-mingw32-strings.exe")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/mingw/mingw32/bin/strings.exe" "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-strings.exe"
+ )
+endif()
+
+message("checking i686-w64-mingw32-ar.exe")
+# copy ar.exe to i686-w64-mingw32-ar.exe for x264
+if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-ar.exe")
+ message("fixing i686-w64-mingw32-ar.exe")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/mingw/mingw32/bin/ar.exe" "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-ar.exe"
+ )
+endif()
+
+message("checking i686-w64-mingw32-strip.exe")
+# copy strip.exe to i686-w64-mingw32-strip.exe for x264
+if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-strip.exe")
+ message("fixing i686-w64-mingw32-strip.exe")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/mingw/mingw32/bin/strip.exe" "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-strip.exe"
+ )
+endif()
+
+message("checking i686-w64-mingw32-ranlib.exe")
+# copy ranlib.exe to i686-w64-mingw32-ranlib.exe for x264
+if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-ranlib.exe")
+ message("fixing i686-w64-mingw32-ranlib.exe")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/mingw/mingw32/bin/ranlib.exe" "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-ranlib.exe"
+ )
+endif()
+
diff --git a/build_files/build_environment/cmake/setup_mingw64.cmake b/build_files/build_environment/cmake/setup_mingw64.cmake
new file mode 100644
index 00000000000..14f75d410b4
--- /dev/null
+++ b/build_files/build_environment/cmake/setup_mingw64.cmake
@@ -0,0 +1,219 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+####################################################################################################################
+# Mingw64 Builds
+####################################################################################################################
+# This installs mingw64+msys to compile ffmpeg/iconv/libsndfile/lapack/fftw3
+####################################################################################################################
+
+message("LIBDIR = ${LIBDIR}")
+macro(cmake_to_msys_path MsysPath ResultingPath)
+ string(REPLACE ":" "" TmpPath "${MsysPath}")
+ string(SUBSTRING ${TmpPath} 0 1 Drive)
+ string(SUBSTRING ${TmpPath} 1 255 PathPart)
+ string(TOLOWER ${Drive} LowerDrive)
+ string(CONCAT ${ResultingPath} "/" ${LowerDrive} ${PathPart})
+endmacro()
+cmake_to_msys_path(${LIBDIR} mingw_LIBDIR)
+message("mingw_LIBDIR = ${mingw_LIBDIR}")
+
+message("Checking for mingw64")
+# download ming64
+if(NOT EXISTS "${DOWNLOAD_DIR}/x86_64-w64-mingw32-gcc-4.8.0-win64_rubenvb.7z")
+ message("Downloading mingw64")
+ file(DOWNLOAD "https://nchc.dl.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win64/Personal%20Builds/rubenvb/gcc-4.8-release/x86_64-w64-mingw32-gcc-4.8.0-win64_rubenvb.7z" "${DOWNLOAD_DIR}/x86_64-w64-mingw32-gcc-4.8.0-win64_rubenvb.7z")
+endif()
+
+# make mingw root directory
+if(NOT EXISTS "${DOWNLOAD_DIR}/mingw")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${DOWNLOAD_DIR}/mingw
+ WORKING_DIRECTORY ${DOWNLOAD_DIR}
+ )
+endif()
+
+# extract mingw64
+if((NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw64/mingw64env.cmd") AND (EXISTS "${DOWNLOAD_DIR}/x86_64-w64-mingw32-gcc-4.8.0-win64_rubenvb.7z"))
+ message("Extracting mingw64")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E tar jxf ${DOWNLOAD_DIR}/x86_64-w64-mingw32-gcc-4.8.0-win64_rubenvb.7z
+ WORKING_DIRECTORY ${DOWNLOAD_DIR}/mingw
+ )
+endif()
+
+message("Checking for pkg-config")
+if(NOT EXISTS "${DOWNLOAD_DIR}/pkg-config-lite-0.28-1_bin-win32.zip")
+ message("Downloading pkg-config")
+ file(DOWNLOAD "https://nchc.dl.sourceforge.net/project/pkgconfiglite/0.28-1/pkg-config-lite-0.28-1_bin-win32.zip" "${DOWNLOAD_DIR}/pkg-config-lite-0.28-1_bin-win32.zip")
+endif()
+
+# extract pkgconfig
+if((NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw64/bin/pkg-config.exe") AND (EXISTS "${DOWNLOAD_DIR}/pkg-config-lite-0.28-1_bin-win32.zip"))
+ message("Extracting pkg-config")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E tar jxf "${DOWNLOAD_DIR}/pkg-config-lite-0.28-1_bin-win32.zip"
+ WORKING_DIRECTORY ${DOWNLOAD_DIR}/
+ )
+
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/pkg-config-lite-0.28-1/bin/pkg-config.exe" "${DOWNLOAD_DIR}/mingw/mingw64/bin/pkg-config.exe"
+ )
+
+endif()
+
+message("Checking for nasm")
+if(NOT EXISTS "${DOWNLOAD_DIR}/nasm-2.12.01-win64.zip")
+ message("Downloading nasm")
+ file(DOWNLOAD "http://www.nasm.us/pub/nasm/releasebuilds/2.12.01/win64/nasm-2.12.01-win64.zip" "${DOWNLOAD_DIR}/nasm-2.12.01-win64.zip")
+endif()
+
+# extract nasm
+if((NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw64/bin/nasm.exe") AND (EXISTS "${DOWNLOAD_DIR}/nasm-2.12.01-win64.zip"))
+ message("Extracting nasm")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E tar jxf "${DOWNLOAD_DIR}/nasm-2.12.01-win64.zip"
+ WORKING_DIRECTORY ${DOWNLOAD_DIR}/
+ )
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/nasm-2.12.01/nasm.exe" "${DOWNLOAD_DIR}/mingw/mingw64/bin/nasm.exe"
+ )
+
+endif()
+
+message("Checking for mingwGet")
+if(NOT EXISTS "${DOWNLOAD_DIR}/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip")
+ message("Downloading mingw-get")
+ file(DOWNLOAD "https://nchc.dl.sourceforge.net/project/mingw/Installer/mingw-get/mingw-get-0.6.2-beta-20131004-1/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip" "${DOWNLOAD_DIR}/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip")
+endif()
+
+# extract mingw_get
+if((NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw64/bin/mingw-get.exe") AND (EXISTS "${DOWNLOAD_DIR}/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip"))
+ message("Extracting mingw-get")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E tar jxf "${DOWNLOAD_DIR}/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip"
+ WORKING_DIRECTORY ${DOWNLOAD_DIR}/mingw/mingw64/
+ )
+endif()
+
+if((EXISTS "${DOWNLOAD_DIR}/mingw/mingw64/bin/mingw-get.exe") AND (NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw64/msys/1.0/bin/make.exe"))
+ message("Installing MSYS")
+ execute_process(
+ COMMAND ${DOWNLOAD_DIR}/mingw/mingw64/bin/mingw-get install msys msys-patch
+ WORKING_DIRECTORY ${DOWNLOAD_DIR}/mingw/mingw64/bin/
+ )
+endif()
+
+message("Checking for CoreUtils")
+# download old core_utils for pr.exe (ffmpeg needs it to build)
+if(NOT EXISTS "${DOWNLOAD_DIR}/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2")
+ message("Downloading CoreUtils 5.97")
+ file(DOWNLOAD "https://nchc.dl.sourceforge.net/project/mingw/MSYS/Base/msys-core/_obsolete/coreutils-5.97-MSYS-1.0.11-2/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2" "${DOWNLOAD_DIR}/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2")
+endif()
+
+if((EXISTS "${DOWNLOAD_DIR}/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2") AND (NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw64/msys/1.0/bin/pr.exe"))
+ message("Installing pr from CoreUtils 5.97")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${DOWNLOAD_DIR}/tmp_coreutils
+ WORKING_DIRECTORY ${DOWNLOAD_DIR}
+ )
+
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E tar jxf ${DOWNLOAD_DIR}/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2
+ WORKING_DIRECTORY ${DOWNLOAD_DIR}/tmp_coreutils/
+ )
+
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E copy ${DOWNLOAD_DIR}/tmp_coreutils/coreutils-5.97/bin/pr.exe "${DOWNLOAD_DIR}/mingw/mingw64/msys/1.0/bin/pr.exe"
+ WORKING_DIRECTORY ${DOWNLOAD_DIR}/tmp_coreutils/
+ )
+endif()
+
+if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw64/ming64sh.cmd")
+ message("Installing ming64sh.cmd")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E copy ${PATCH_DIR}/ming64sh.cmd ${DOWNLOAD_DIR}/mingw/mingw64/ming64sh.cmd
+ )
+endif()
+
+message("Checking for perl")
+# download perl for libvpx
+if(NOT EXISTS "${DOWNLOAD_DIR}/strawberry-perl-5.22.1.3-64bit-portable.zip")
+ message("Downloading perl")
+ file(DOWNLOAD "http://strawberryperl.com/download/5.22.1.3/strawberry-perl-5.22.1.3-64bit-portable.zip" "${DOWNLOAD_DIR}/strawberry-perl-5.22.1.3-64bit-portable.zip")
+endif()
+
+# make perl root directory
+if(NOT EXISTS "${DOWNLOAD_DIR}/perl")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${DOWNLOAD_DIR}/perl
+ WORKING_DIRECTORY ${DOWNLOAD_DIR}
+ )
+endif()
+
+# extract perl
+if((NOT EXISTS "${DOWNLOAD_DIR}/perl/portable.perl") AND (EXISTS "${DOWNLOAD_DIR}/strawberry-perl-5.22.1.3-64bit-portable.zip"))
+ message("Extracting perl")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E tar jxf ${DOWNLOAD_DIR}/strawberry-perl-5.22.1.3-64bit-portable.zip
+ WORKING_DIRECTORY ${DOWNLOAD_DIR}/perl
+ )
+endif()
+
+# get yasm for vpx
+if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw64/bin/yasm.exe")
+ message("Downloading yasm")
+ file(DOWNLOAD "http://www.tortall.net/projects/yasm/releases/yasm-1.3.0-win64.exe" "${DOWNLOAD_DIR}/mingw/mingw64/bin/yasm.exe")
+endif()
+
+message("checking x86_64-w64-mingw32-strings.exe")
+# copy strings.exe to x86_64-w64-mingw32-strings.exe for x264
+if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw64/bin/x86_64-w64-mingw32-strings.exe")
+ message("fixing x86_64-w64-mingw32-strings.exe")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/mingw/mingw64/bin/strings.exe" "${DOWNLOAD_DIR}/mingw/mingw64/bin/x86_64-w64-mingw32-strings.exe"
+ )
+endif()
+
+message("checking x86_64-w64-mingw32-ar.exe")
+# copy ar.exe to x86_64-w64-mingw32-ar.exe for x264
+if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw64/bin/x86_64-w64-mingw32-ar.exe")
+ message("fixing x86_64-w64-mingw32-ar.exe")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/mingw/mingw64/bin/ar.exe" "${DOWNLOAD_DIR}/mingw/mingw64/bin/x86_64-w64-mingw32-ar.exe"
+ )
+endif()
+
+message("checking x86_64-w64-mingw32-strip.exe")
+# copy strip.exe to x86_64-w64-mingw32-strip.exe for x264
+if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw64/bin/x86_64-w64-mingw32-strip.exe")
+ message("fixing x86_64-w64-mingw32-strip.exe")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/mingw/mingw64/bin/strip.exe" "${DOWNLOAD_DIR}/mingw/mingw64/bin/x86_64-w64-mingw32-strip.exe"
+ )
+endif()
+
+message("checking x86_64-w64-mingw32-ranlib.exe")
+# copy ranlib.exe to x86_64-w64-mingw32-ranlib.exe for x264
+if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw64/bin/x86_64-w64-mingw32-ranlib.exe")
+ message("fixing x86_64-w64-mingw32-ranlib.exe")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/mingw/mingw64/bin/ranlib.exe" "${DOWNLOAD_DIR}/mingw/mingw64/bin/x86_64-w64-mingw32-ranlib.exe"
+ )
+endif()
+
diff --git a/build_files/build_environment/cmake/sndfile.cmake b/build_files/build_environment/cmake/sndfile.cmake
new file mode 100644
index 00000000000..ce10f07c133
--- /dev/null
+++ b/build_files/build_environment/cmake/sndfile.cmake
@@ -0,0 +1,55 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(SNDFILE_EXTRA_ARGS)
+set(SNDFILE_ENV PKG_CONFIG_PATH=${mingw_LIBDIR}/ogg/lib/pkgconfig:${mingw_LIBDIR}/vorbis/lib/pkgconfig:${mingw_LIBDIR}/flac/lib/pkgconfig:${mingw_LIBDIR})
+
+if(WIN32)
+ set(SNDFILE_ENV set ${SNDFILE_ENV} &&)
+ #shared for windows because static libs will drag in a libgcc dependency.
+ set(SNDFILE_OPTIONS --disable-static --enable-shared )
+else()
+ set(SNDFILE_OPTIONS --enable-static --disable-shared )
+endif()
+
+if(APPLE)
+ set(SNDFILE_PATCH_CMD ${PATCH_CMD} --verbose -p 0 -d ${BUILD_DIR}/sndfile/src/external_sndfile < ${PATCH_DIR}/sndfile.diff)
+else()
+ set(SNDFILE_PATCH_CMD)
+endif()
+
+ExternalProject_Add(external_sndfile
+ URL ${SNDFILE_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${SNDFILE_HASH}
+ PREFIX ${BUILD_DIR}/sndfile
+ PATCH_COMMAND ${SNDFILE_PATCH_CMD}
+ CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/sndfile/src/external_sndfile/ && ${SNDFILE_ENV} ${CONFIGURE_COMMAND} ${SNDFILE_OPTIONS} --prefix=${mingw_LIBDIR}/sndfile
+ BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/sndfile/src/external_sndfile/ && make -j${MAKE_THREADS}
+ INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/sndfile/src/external_sndfile/ && make install
+ INSTALL_DIR ${LIBDIR}/sndfile
+)
+
+if(MSVC)
+ set_target_properties(external_sndfile PROPERTIES FOLDER Mingw)
+endif()
+
+add_dependencies(external_sndfile external_ogg external_vorbis)
+if(UNIX)
+ add_dependencies(external_sndfile external_flac)
+endif()
diff --git a/build_files/build_environment/cmake/spnav.cmake b/build_files/build_environment/cmake/spnav.cmake
new file mode 100644
index 00000000000..0dec9799715
--- /dev/null
+++ b/build_files/build_environment/cmake/spnav.cmake
@@ -0,0 +1,28 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+ExternalProject_Add(external_spnav
+ URL ${SPNAV_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${SPNAV_HASH}
+ PREFIX ${BUILD_DIR}/spnav
+ CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/spnav/src/external_spnav/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/spnav --disable-shared --enable-static --with-pic
+ BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/spnav/src/external_spnav/ && make -j${MAKE_THREADS}
+ INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/spnav/src/external_spnav/ && make install
+ INSTALL_DIR ${LIBDIR}/spnav
+)
diff --git a/build_files/build_environment/cmake/tbb.cmake b/build_files/build_environment/cmake/tbb.cmake
new file mode 100644
index 00000000000..c4055d55648
--- /dev/null
+++ b/build_files/build_environment/cmake/tbb.cmake
@@ -0,0 +1,36 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(TBB_EXTRA_ARGS
+ -DTBB_BUILD_SHARED=Off
+ -DTBB_BUILD_TBBMALLOC=Off
+ -DTBB_BUILD_TBBMALLOC_PROXY=Off
+ -DTBB_BUILD_STATIC=On
+)
+
+# CMake script for TBB from https://github.com/wjakob/tbb/blob/master/CMakeLists.txt
+ExternalProject_Add(external_tbb
+ URL ${TBB_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${TBB_HASH}
+ PREFIX ${BUILD_DIR}/tbb
+ PATCH_COMMAND COMMAND ${CMAKE_COMMAND} -E copy ${PATCH_DIR}/cmakelists_tbb.txt ${BUILD_DIR}/tbb/src/external_tbb/CMakeLists.txt &&
+ ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/tbb/src/external_tbb/build/vs2010/version_string.ver ${BUILD_DIR}/tbb/src/external_tbb/src/tbb/version_string.ver
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/tbb ${DEFAULT_CMAKE_FLAGS} ${TBB_EXTRA_ARGS}
+ INSTALL_DIR ${LIBDIR}/tbb
+)
diff --git a/build_files/build_environment/cmake/theora.cmake b/build_files/build_environment/cmake/theora.cmake
new file mode 100644
index 00000000000..03aad42f2db
--- /dev/null
+++ b/build_files/build_environment/cmake/theora.cmake
@@ -0,0 +1,40 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+ExternalProject_Add(external_theora
+ URL ${THEORA_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH SHA256=${THEORA_HASH}
+ PREFIX ${BUILD_DIR}/theora
+ CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/theora/src/external_theora/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/theora
+ --disable-shared
+ --enable-static
+ --with-pic
+ --with-ogg=${LIBDIR}/ogg
+ --with-vorbis=${LIBDIR}/vorbis
+ --disable-examples
+ BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/theora/src/external_theora/ && make -j${MAKE_THREADS}
+ INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/theora/src/external_theora/ && make install
+ INSTALL_DIR ${LIBDIR}/theora
+)
+
+add_dependencies(external_theora external_vorbis external_ogg)
+
+if(MSVC)
+ set_target_properties(external_theora PROPERTIES FOLDER Mingw)
+endif()
diff --git a/build_files/build_environment/cmake/tiff.cmake b/build_files/build_environment/cmake/tiff.cmake
new file mode 100644
index 00000000000..2c01341eb21
--- /dev/null
+++ b/build_files/build_environment/cmake/tiff.cmake
@@ -0,0 +1,44 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(TIFF_EXTRA_ARGS
+ -DZLIB_LIBRARY=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY}
+ -DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include
+ -DPNG_STATIC=ON
+ -DBUILD_SHARED_LIBS=OFF
+ -Dlzma=OFF
+ -Djbig=OFF
+)
+
+ExternalProject_Add(external_tiff
+ URL ${TIFF_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${TIFF_HASH}
+ PREFIX ${BUILD_DIR}/tiff
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/tiff ${DEFAULT_CMAKE_FLAGS} ${TIFF_EXTRA_ARGS}
+ INSTALL_DIR ${LIBDIR}/tiff
+)
+
+add_dependencies(external_tiff external_zlib)
+
+if(BUILD_MODE STREQUAL Debug)
+ ExternalProject_Add_Step(external_tiff after_install
+ COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tiff/lib/tiffd${LIBEXT} ${LIBDIR}/tiff/lib/tiff${LIBEXT}
+ DEPENDEES install
+ )
+endif()
diff --git a/build_files/build_environment/cmake/versions.cmake b/build_files/build_environment/cmake/versions.cmake
new file mode 100644
index 00000000000..e53beeddf4a
--- /dev/null
+++ b/build_files/build_environment/cmake/versions.cmake
@@ -0,0 +1,250 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(ZLIB_VERSION 1.2.8)
+set(ZLIB_URI https://netcologne.dl.sourceforge.net/project/libpng/zlib/${ZLIB_VERSION}/zlib-${ZLIB_VERSION}.tar.gz)
+set(ZLIB_HASH 44d667c142d7cda120332623eab69f40)
+
+set(OPENAL_VERSION 1.17.2)
+set(OPENAL_URI http://kcat.strangesoft.net/openal-releases/openal-soft-${OPENAL_VERSION}.tar.bz2)
+set(OPENAL_HASH 1764e0d8fec499589b47ebc724e0913d)
+
+set(PNG_VERSION 1.6.21)
+set(PNG_URI http://prdownloads.sourceforge.net/libpng/libpng-${PNG_VERSION}.tar.gz)
+set(PNG_HASH aca36ec8e0a3b406a5912243bc243717)
+
+set(JPEG_VERSION 1.4.2)
+set(JPEG_URI https://github.com/libjpeg-turbo/libjpeg-turbo/archive/${JPEG_VERSION}.tar.gz)
+set(JPEG_HASH f9804884c1c41eb7f4febb9353a2cb27)
+
+set(BOOST_VERSION 1.60.0)
+set(BOOST_VERSION_NODOTS 1_60_0)
+set(BOOST_URI http://sourceforge.net/projects/boost/files/boost/${BOOST_VERSION}/boost_${BOOST_VERSION_NODOTS}.tar.bz2/download)
+set(BOOST_MD5 65a840e1a0b13a558ff19eeb2c4f0cbe)
+
+set(BLOSC_VERSION 1.7.1)
+set(BLOSC_URI https://github.com/Blosc/c-blosc/archive/v${BLOSC_VERSION}.zip)
+set(BLOSC_HASH ff5cc729a5a25934ef714217218eed26)
+
+set(PTHREADS_VERSION 2-9-1)
+set(PTHREADS_URI ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-${PTHREADS_VERSION}-release.tar.gz)
+set(PTHREADS_SHA512 9c06e85310766834370c3dceb83faafd397da18a32411ca7645c8eb6b9495fea54ca2872f4a3e8d83cb5fdc5dea7f3f0464be5bb9af3222a6534574a184bd551)
+
+set(ILMBASE_VERSION 2.2.0)
+set(ILMBASE_URI http://download.savannah.nongnu.org/releases/openexr/ilmbase-${ILMBASE_VERSION}.tar.gz)
+set(ILMBASE_HASH b540db502c5fa42078249f43d18a4652)
+
+set(OPENEXR_VERSION 2.2.0)
+set(OPENEXR_URI http://download.savannah.nongnu.org/releases/openexr/openexr-2.2.0.tar.gz)
+set(OPENEXR_HASH b64e931c82aa3790329c21418373db4e)
+
+set(FREETYPE_VERSION 263)
+set(FREETYPE_URI http://download.savannah.gnu.org/releases/freetype/ft${FREETYPE_VERSION}.zip)
+set(FREETYPE_HASH 0db2a43301572e5c2b4a0864f237aeeb)
+
+set(GLEW_VERSION 1.13.0)
+set(GLEW_URI http://prdownloads.sourceforge.net/glew/glew/${GLEW_VERSION}/glew-${GLEW_VERSION}.tgz)
+set(GLEW_HASH 7cbada3166d2aadfc4169c4283701066)
+
+set(FREEGLUT_VERSION 3.0.0)
+set(FREEGLUT_URI http://pilotfiber.dl.sourceforge.net/project/freeglut/freeglut/${FREEGLUT_VERSION}/freeglut-${FREEGLUT_VERSION}.tar.gz)
+set(FREEGLUT_HASH 90c3ca4dd9d51cf32276bc5344ec9754)
+
+set(HDF5_VERSION 1.8.17)
+set(HDF5_URI https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.8/hdf5-${HDF5_VERSION}/src/hdf5-${HDF5_VERSION}.tar.gz)
+set(HDF5_HASH 7d572f8f3b798a628b8245af0391a0ca)
+
+set(ALEMBIC_VERSION 1.7.1)
+set(ALEMBIC_URI https://github.com/alembic/alembic/archive/${ALEMBIC_VERSION}.zip)
+set(ALEMBIC_MD5 cf7705055501d5ea0cb8256866496f79)
+
+## hash is for 3.1.2
+set(GLFW_GIT_UID 30306e54705c3adae9fe082c816a3be71963485c)
+set(GLFW_URI https://github.com/glfw/glfw/archive/${GLFW_GIT_UID}.zip)
+set(GLFW_HASH 20cacb1613da7eeb092f3ac4f6b2b3d0)
+
+#latest uid in git as of 2016-04-01
+set(CLEW_GIT_UID 277db43f6cafe8b27c6f1055f69dc67da4aeb299)
+set(CLEW_URI https://github.com/OpenCLWrangler/clew/archive/${CLEW_GIT_UID}.zip)
+set(CLEW_HASH 2c699d10ed78362e71f56fae2a4c5f98)
+
+#latest uid in git as of 2016-04-01
+set(CUEW_GIT_UID 1744972026de9cf27c8a7dc39cf39cd83d5f922f)
+set(CUEW_URI https://github.com/CudaWrangler/cuew/archive/${CUEW_GIT_UID}.zip)
+set(CUEW_HASH 86760d62978ebfd96cd93f5aa1abaf4a)
+
+set(OPENSUBDIV_VERSION v3_1_1)
+set(OPENSUBDIV_Hash 25a9a6a94136b0eb85ce69e9c8cb6ab3)
+set(OPENSUBDIV_URI https://github.com/PixarAnimationStudios/OpenSubdiv/archive/${OPENSUBDIV_VERSION}.zip)
+
+set(SDL_VERSION 2.0.4)
+set(SDL_URI https://www.libsdl.org/release/SDL2-${SDL_VERSION}.tar.gz)
+set(SDL_HASH 44fc4a023349933e7f5d7a582f7b886e)
+
+set(OPENCOLLADA_VERSION v1.6.51)
+set(OPENCOLLADA_URI https://github.com/KhronosGroup/OpenCOLLADA/archive/${OPENCOLLADA_VERSION}.tar.gz)
+set(OPENCOLLADA_HASH 23db5087faed4bc4cc1dfe456c0d4701)
+
+set(OPENCOLORIO_URI https://github.com/imageworks/OpenColorIO/archive/6de971097c7f552300f669ed69ca0b6cf5a70843.zip)
+set(OPENCOLORIO_HASH c9de0fd98f26ce6f2e08d617ca68b8e4)
+
+set(LLVM_VERSION 3.4.2)
+set(LLVM_URI http://llvm.org/releases/${LLVM_VERSION}/llvm-${LLVM_VERSION}.src.tar.gz)
+set(LLVM_HASH a20669f75967440de949ac3b1bad439c)
+
+set(CLANG_URI http://llvm.org/releases/${LLVM_VERSION}/cfe-${LLVM_VERSION}.src.tar.gz)
+set(CLANG_HASH 87945973b7c73038871c5f849a818588)
+
+set(OPENIMAGEIO_VERSION 1.7.15)
+set(OPENIMAGEIO_URI https://github.com/OpenImageIO/oiio/archive/Release-${OPENIMAGEIO_VERSION}.zip)
+set(OPENIMAGEIO_HASH_178 e156e3669af0e1373142ab5e8f13de66)
+set(OPENIMAGEIO_HASH_179 4121cb0e0433bda6a7ef32c8628a149f)
+set(OPENIMAGEIO_HASH_1713 42a662775b834161ba88c6abdb299360)
+set(OPENIMAGEIO_HASH_1715 e2ece0f62c013d64c478f82265988b0b)
+set(OPENIMAGEIO_HASH ${OPENIMAGEIO_HASH_1715})
+
+
+set(TIFF_VERSION 4.0.6)
+set(TIFF_URI http://download.osgeo.org/libtiff/tiff-${TIFF_VERSION}.tar.gz)
+set(TIFF_HASH d1d2e940dea0b5ad435f21f03d96dd72)
+
+set(FLEXBISON_VERSION 2.5.5)
+set(FLEXBISON_URI http://prdownloads.sourceforge.net/winflexbison//win_flex_bison-2.5.5.zip)
+set(FLEXBISON_HASH d87a3938194520d904013abef3df10ce)
+
+set(OSL_VERSION 1.7.5)
+set(OSL_URI https://github.com/imageworks/OpenShadingLanguage/archive/Release-${OSL_VERSION}.zip)
+set(OSL_HASH 6924dd5d453159e7b6eb106a08c358cf)
+
+set(PYTHON_VERSION 3.6.2)
+set(PYTHON_SHORT_VERSION 3.6)
+set(PYTHON_SHORT_VERSION_NO_DOTS 36)
+set(PYTHON_URI https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz)
+set(PYTHON_HASH 2c68846471994897278364fc18730dd9)
+
+set(TBB_VERSION 44_20160128)
+set(TBB_URI https://www.threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb${TBB_VERSION}oss_src_0.tgz)
+set(TBB_HASH 9d8a4cdf43496f1b3f7c473a5248e5cc)
+
+set(OPENVDB_VERSION 3.1.0)
+set(OPENVDB_URI https://github.com/dreamworksanimation/openvdb/archive/v${OPENVDB_VERSION}.tar.gz)
+set(OPENVDB_HASH 30a7e9571a03ab7bcf1a39fb62aa436f)
+
+set(IDNA_VERSION 2.6)
+set(CHARDET_VERSION 3.0.2)
+set(URLLIB3_VERSION 1.22)
+set(CERTIFI_VERSION 2017.7.27.1)
+set(REQUESTS_VERSION 2.18.4)
+
+set(NUMPY_VERSION v1.13.1)
+set(NUMPY_SHORT_VERSION 1.13)
+set(NUMPY_URI https://pypi.python.org/packages/c0/3a/40967d9f5675fbb097ffec170f59c2ba19fc96373e73ad47c2cae9a30aed/numpy-1.13.1.zip)
+set(NUMPY_HASH 2c3c0f4edf720c3a7b525dacc825b9ae)
+
+set(LAME_VERSION 3.99.5)
+set(LAME_URI http://downloads.sourceforge.net/project/lame/lame/3.99/lame-${LAME_VERSION}.tar.gz)
+set(LAME_HASH 84835b313d4a8b68f5349816d33e07ce)
+
+set(OGG_VERSION 1.3.2)
+set(OGG_URI http://downloads.xiph.org/releases/ogg/libogg-${OGG_VERSION}.tar.gz)
+set(OGG_HASH e19ee34711d7af328cb26287f4137e70630e7261b17cbe3cd41011d73a654692)
+
+set(VORBIS_VERSION 1.3.5)
+set(VORBIS_URI http://downloads.xiph.org/releases/vorbis/libvorbis-${VORBIS_VERSION}.tar.gz)
+set(VORBIS_HASH 6efbcecdd3e5dfbf090341b485da9d176eb250d893e3eb378c428a2db38301ce)
+
+set(THEORA_VERSION 1.1.1)
+set(THEORA_URI http://downloads.xiph.org/releases/theora/libtheora-${THEORA_VERSION}.tar.bz2)
+set(THEORA_HASH b6ae1ee2fa3d42ac489287d3ec34c5885730b1296f0801ae577a35193d3affbc)
+
+set(FLAC_VERSION 1.3.1)
+set(FLAC_URI http://downloads.xiph.org/releases/flac/flac-${FLAC_VERSION}.tar.xz)
+set(FLAC_HASH 4773c0099dba767d963fd92143263be338c48702172e8754b9bc5103efe1c56c)
+
+set(VPX_VERSION 1.5.0)
+set(VPX_URI http://storage.googleapis.com/downloads.webmproject.org/releases/webm/libvpx-${VPX_VERSION}.tar.bz2)
+set(VPX_HASH 306d67908625675f8e188d37a81fbfafdf5068b09d9aa52702b6fbe601c76797)
+
+set(ORC_VERSION 0.4.25)
+set(ORC_URI https://gstreamer.freedesktop.org/src/orc/orc-${ORC_VERSION}.tar.xz)
+set(ORC_HASH c1b1d54a58f26d483f0b3881538984789fe5d5460ab8fab74a1cacbd3d1c53d1)
+
+set(SCHROEDINGER_VERSION 1.0.11)
+set(SCHROEDINGER_URI https://download.videolan.org/contrib/schroedinger/schroedinger-${SCHROEDINGER_VERSION}.tar.gz)
+set(SCHROEDINGER_HASH 1e572a0735b92aca5746c4528f9bebd35aa0ccf8619b22fa2756137a8cc9f912)
+
+set(X264_URI http://download.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20160401-2245-stable.tar.bz2)
+set(X264_HASH 1e9a7b835e80313aade53a9b6ff353e099de3856bf5f30a4d8dfc91281f786f5)
+
+set(XVIDCORE_VERSION 1.3.4)
+set(XVIDCORE_URI http://downloads.xvid.org/downloads/xvidcore-${XVIDCORE_VERSION}.tar.gz)
+set(XVIDCORE_HASH 4e9fd62728885855bc5007fe1be58df42e5e274497591fec37249e1052ae316f)
+
+#this has to be in sync with the version in blenders /extern folder
+set(OPENJPEG_VERSION 1.5.2)
+set(OPENJPEG_SHORT_VERSION 1.5)
+set(OPENJPEG_URI https://github.com/uclouvain/openjpeg/archive/version.${OPENJPEG_VERSION}.tar.gz)
+set(OPENJPEG_HASH 3734e95edd0bef6e056815591755efd822228dc3cd866894e00a2c929026b16d)
+
+set(FAAD_VERSION 2-2.7)
+set(FAAD_URI http://downloads.sourceforge.net/faac/faad${FAAD_VERSION}.tar.bz2)
+set(FAAD_HASH 4c332fa23febc0e4648064685a3d4332)
+
+set(FFMPEG_VERSION 3.2.1)
+set(FFMPEG_URI http://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.bz2)
+set(FFMPEG_HASH cede174178e61f882844f5870c35ce72)
+
+set(FFTW_VERSION 3.3.4)
+set(FFTW_URI http://www.fftw.org/fftw-${FFTW_VERSION}.tar.gz)
+set(FFTW_HASH 2edab8c06b24feeb3b82bbb3ebf3e7b3)
+
+set(ICONV_VERSION 1.14)
+set(ICONV_URI http://ftp.gnu.org/pub/gnu/libiconv/libiconv-${ICONV_VERSION}.tar.gz)
+set(ICONV_HASH e34509b1623cec449dfeb73d7ce9c6c6)
+
+set(LAPACK_VERSION 3.6.0)
+set(LAPACK_URI http://www.netlib.org/lapack/lapack-${LAPACK_VERSION}.tgz)
+set(LAPACK_HASH f2f6c67134e851fe189bb3ca1fbb5101)
+
+set(SNDFILE_VERSION 1.0.28)
+set(SNDFILE_URI http://www.mega-nerd.com/libsndfile/files/libsndfile-${SNDFILE_VERSION}.tar.gz)
+set(SNDFILE_HASH 646b5f98ce89ac60cdb060fcd398247c)
+
+#set(HIDAPI_VERSION 0.8.0-rc1)
+#set(HIDAPI_URI https://github.com/signal11/hidapi/archive/hidapi-${HIDAPI_VERSION}.tar.gz)
+#set(HIDAPI_HASH 069f9dd746edc37b6b6d0e3656f47199)
+
+set(HIDAPI_UID 89a6c75dc6f45ecabd4ddfbd2bf5ba6ad8ba38b5)
+set(HIDAPI_URI https://github.com/TheOnlyJoey/hidapi/archive/${HIDAPI_UID}.zip)
+set(HIDAPI_HASH b6e22f6b514f8bcf594989f20ffc46fb)
+
+set(WEBP_VERSION 0.5.1)
+set(WEBP_URI https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-${WEBP_VERSION}.tar.gz)
+set(WEBP_HASH 3d7db92ebba5b4f679413d25c6040881)
+
+set(SPNAV_VERSION 0.2.3)
+set(SPNAV_URI http://downloads.sourceforge.net/project/spacenav/spacenav%20library%20%28SDK%29/libspnav%20${SPNAV_VERSION}/libspnav-${SPNAV_VERSION}.tar.gz)
+set(SPNAV_HASH 44d840540d53326d4a119c0f1aa7bf0a)
+
+set(JEMALLOC_VERSION 5.0.1)
+set(JEMALLOC_URI https://github.com/jemalloc/jemalloc/releases/download/${JEMALLOC_VERSION}/jemalloc-${JEMALLOC_VERSION}.tar.bz2)
+set(JEMALLOC_HASH 507f7b6b882d868730d644510491d18f)
+
+set(XML2_VERSION 2.9.4)
+set(XML2_URI ftp://xmlsoft.org/libxml2/libxml2-${XML2_VERSION}.tar.gz)
+set(XML2_HASH ae249165c173b1ff386ee8ad676815f5)
diff --git a/build_files/build_environment/cmake/vorbis.cmake b/build_files/build_environment/cmake/vorbis.cmake
new file mode 100644
index 00000000000..d16c7c6a1bc
--- /dev/null
+++ b/build_files/build_environment/cmake/vorbis.cmake
@@ -0,0 +1,38 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+ExternalProject_Add(external_vorbis
+ URL ${VORBIS_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH SHA256=${VORBIS_HASH}
+ PREFIX ${BUILD_DIR}/vorbis
+ CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/vorbis/src/external_vorbis/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/vorbis
+ --disable-shared
+ --enable-static
+ --with-pic
+ --with-ogg=${LIBDIR}/ogg
+ BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/vorbis/src/external_vorbis/ && make -j${MAKE_THREADS}
+ INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/vorbis/src/external_vorbis/ && make install
+ INSTALL_DIR ${LIBDIR}/vorbis
+)
+
+add_dependencies(external_vorbis external_ogg)
+
+if(MSVC)
+ set_target_properties(external_vorbis PROPERTIES FOLDER Mingw)
+endif()
diff --git a/build_files/build_environment/cmake/vpx.cmake b/build_files/build_environment/cmake/vpx.cmake
new file mode 100644
index 00000000000..9d155be1c6c
--- /dev/null
+++ b/build_files/build_environment/cmake/vpx.cmake
@@ -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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+if(WIN32)
+ if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
+ set(VPX_EXTRA_FLAGS --target=x86_64-win64-gcc)
+ else()
+ set(VPX_EXTRA_FLAGS --target=x86-win32-gcc)
+ endif()
+else()
+ if(APPLE)
+ set(VPX_EXTRA_FLAGS --target=x86_64-darwin13-gcc)
+ else()
+ set(VPX_EXTRA_FLAGS --target=generic-gnu)
+ endif()
+endif()
+
+ExternalProject_Add(external_vpx
+ URL ${VPX_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH SHA256=${VPX_HASH}
+ PREFIX ${BUILD_DIR}/vpx
+ CONFIGURE_COMMAND ${CONFIGURE_ENV} &&
+ cd ${BUILD_DIR}/vpx/src/external_vpx/ &&
+ ${CONFIGURE_COMMAND_NO_TARGET} --prefix=${LIBDIR}/vpx
+ --disable-shared
+ --enable-static
+ --disable-install-bins
+ --disable-install-srcs
+ --disable-sse4_1
+ --disable-sse3
+ --disable-ssse3
+ --disable-avx
+ --disable-avx2
+ --disable-unit-tests
+ --disable-examples
+ ${VPX_EXTRA_FLAGS}
+ BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/vpx/src/external_vpx/ && make -j${MAKE_THREADS}
+ INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/vpx/src/external_vpx/ && make install
+ INSTALL_DIR ${LIBDIR}/vpx
+)
+
+if(MSVC)
+ set_target_properties(external_vpx PROPERTIES FOLDER Mingw)
+endif()
diff --git a/build_files/build_environment/cmake/webp.cmake b/build_files/build_environment/cmake/webp.cmake
new file mode 100644
index 00000000000..0504988a088
--- /dev/null
+++ b/build_files/build_environment/cmake/webp.cmake
@@ -0,0 +1,50 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+# Note the utility apps may use png/tiff/gif system libraries, but the
+# library itself does not depend on them, so should give no problems.
+
+set(WEBP_EXTRA_ARGS
+ -DWEBP_HAVE_SSE2=ON
+ -DWEBP_HAVE_SSE41=OFF
+ -DWEBP_HAVE_AVX2=OFF
+)
+
+if(WIN32)
+ set(WEBP_BUILD_DIR ${BUILD_MODE}/)
+else()
+ set(WEBP_BUILD_DIR)
+endif()
+
+ExternalProject_Add(external_webp
+ URL ${WEBP_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${WEBP_HASH}
+ PREFIX ${BUILD_DIR}/webp
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/webp -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${WEBP_EXTRA_ARGS}
+ INSTALL_COMMAND COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/webp/src/external_webp-build/${WEBP_BUILD_DIR}${LIBPREFIX}webp${LIBEXT} ${LIBDIR}/webp/lib/${LIBPREFIX}webp${LIBEXT} &&
+ ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/webp/src/external_webp/src/webp/decode.h ${LIBDIR}/webp/include/webp/decode.h &&
+ ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/webp/src/external_webp/src/webp/encode.h ${LIBDIR}/webp/include/webp/encode.h &&
+ ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/webp/src/external_webp/src/webp/demux.h ${LIBDIR}/webp/include/webp/demux.h &&
+ ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/webp/src/external_webp/src/webp/extras.h ${LIBDIR}/webp/include/webp/extras.h &&
+ ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/webp/src/external_webp/src/webp/format_constants.h ${LIBDIR}/webp/include/webp/format_constants.h &&
+ ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/webp/src/external_webp/src/webp/mux.h ${LIBDIR}/webp/include/webp/mux.h &&
+ ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/webp/src/external_webp/src/webp/mux_types.h ${LIBDIR}/webp/include/webp/mux_types.h &&
+ ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/webp/src/external_webp/src/webp/types.h ${LIBDIR}/webp/include/webp/types.h
+ INSTALL_DIR ${LIBDIR}/webp
+)
diff --git a/build_files/build_environment/cmake/x264.cmake b/build_files/build_environment/cmake/x264.cmake
new file mode 100644
index 00000000000..64029ca1b5e
--- /dev/null
+++ b/build_files/build_environment/cmake/x264.cmake
@@ -0,0 +1,40 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+if(WIN32)
+ set(X264_EXTRA_ARGS --enable-win32thread --cross-prefix=${MINGW_HOST}- --host=${MINGW_HOST})
+endif()
+
+ExternalProject_Add(external_x264
+ URL ${X264_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH SHA256=${X264_HASH}
+ PREFIX ${BUILD_DIR}/x264
+ CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/x264/src/external_x264/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/x264
+ --enable-static
+ --enable-pic
+ --disable-lavf
+ ${X264_EXTRA_ARGS}
+ BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/x264/src/external_x264/ && make -j${MAKE_THREADS}
+ INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/x264/src/external_x264/ && make install
+ INSTALL_DIR ${LIBDIR}/x264
+)
+
+if(MSVC)
+ set_target_properties(external_x264 PROPERTIES FOLDER Mingw)
+endif()
diff --git a/build_files/build_environment/cmake/xml2.cmake b/build_files/build_environment/cmake/xml2.cmake
new file mode 100644
index 00000000000..a8f87a67ad4
--- /dev/null
+++ b/build_files/build_environment/cmake/xml2.cmake
@@ -0,0 +1,36 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+ExternalProject_Add(external_xml2
+ URL ${XML2_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${XML2_HASH}
+ PREFIX ${BUILD_DIR}/xml2
+ CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/xml2/src/external_xml2/ && ${CONFIGURE_COMMAND}
+ --prefix=${LIBDIR}/xml2
+ --disable-shared
+ --enable-static
+ --with-pic
+ --with-python=no
+ --with-lzma=no
+ --with-zlib=no
+ --with-iconv=no
+ BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/xml2/src/external_xml2/ && make -j${MAKE_THREADS}
+ INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/xml2/src/external_xml2/ && make install
+ INSTALL_DIR ${LIBDIR}/xml2
+)
diff --git a/build_files/build_environment/cmake/xvidcore.cmake b/build_files/build_environment/cmake/xvidcore.cmake
new file mode 100644
index 00000000000..a341275ea47
--- /dev/null
+++ b/build_files/build_environment/cmake/xvidcore.cmake
@@ -0,0 +1,44 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+if(WIN32)
+ set(XVIDCORE_EXTRA_ARGS --host=${MINGW_HOST})
+endif()
+
+ExternalProject_Add(external_xvidcore
+ URL ${XVIDCORE_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH SHA256=${XVIDCORE_HASH}
+ PREFIX ${BUILD_DIR}/xvidcore
+ CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/xvidcore/src/external_xvidcore/build/generic && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/xvidcore ${XVIDCORE_EXTRA_ARGS}
+ BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/xvidcore/src/external_xvidcore/build/generic && make -j${MAKE_THREADS}
+ INSTALL_COMMAND ${CONFIGURE_ENV} &&
+ ${CMAKE_COMMAND} -E remove ${LIBDIR}/xvidcore/lib/* && # clean because re-installing fails otherwise
+ cd ${BUILD_DIR}/xvidcore/src/external_xvidcore/build/generic && make install
+ INSTALL_DIR ${LIBDIR}/xvidcore
+)
+
+ExternalProject_Add_Step(external_xvidcore after_install
+ COMMAND ${CMAKE_COMMAND} -E rename ${LIBDIR}/xvidcore/lib/xvidcore.a ${LIBDIR}/xvidcore/lib/libxvidcore.a || true
+ COMMAND ${CMAKE_COMMAND} -E remove ${LIBDIR}/xvidcore/lib/xvidcore.dll.a
+ DEPENDEES install
+)
+
+if(MSVC)
+ set_target_properties(external_xvidcore PROPERTIES FOLDER Mingw)
+endif()
diff --git a/build_files/build_environment/cmake/zlib.cmake b/build_files/build_environment/cmake/zlib.cmake
new file mode 100644
index 00000000000..3307cb1f167
--- /dev/null
+++ b/build_files/build_environment/cmake/zlib.cmake
@@ -0,0 +1,33 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+ExternalProject_Add(external_zlib
+ URL ${ZLIB_URI}
+ URL_HASH MD5=${ZLIB_HASH}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ PREFIX ${BUILD_DIR}/zlib
+ CMAKE_ARGS -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_INSTALL_PREFIX=${LIBDIR}/zlib ${DEFAULT_CMAKE_FLAGS}
+ INSTALL_DIR ${LIBDIR}/zlib
+)
+
+if(BUILD_MODE STREQUAL Debug)
+ ExternalProject_Add_Step(external_zlib after_install
+ COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/zlib/lib/zlibstaticd${LIBEXT} ${LIBDIR}/zlib/lib/${ZLIB_LIBRARY}
+ DEPENDEES install
+ )
+endif()
diff --git a/build_files/build_environment/cmake/zlib_mingw.cmake b/build_files/build_environment/cmake/zlib_mingw.cmake
new file mode 100644
index 00000000000..13345f29ffa
--- /dev/null
+++ b/build_files/build_environment/cmake/zlib_mingw.cmake
@@ -0,0 +1,40 @@
+# ***** 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+ExternalProject_Add(external_zlib_mingw
+ URL ${ZLIB_URI}
+ URL_HASH MD5=${ZLIB_HASH}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ PREFIX ${BUILD_DIR}/zlib_mingw
+ CONFIGURE_COMMAND echo .
+ BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/zlib_mingw/src/external_zlib_mingw/ && make -f win32/makefile.gcc -j${MAKE_THREADS}
+ INSTALL_COMMAND echo .
+ INSTALL_DIR ${LIBDIR}/zlib_mingw
+)
+
+if(BUILD_MODE STREQUAL Release)
+ ExternalProject_Add_Step(external_zlib_mingw after_install
+ COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/zlib_mingw/src/external_zlib_mingw/libz.a ${LIBDIR}/zlib/lib/z.lib
+ DEPENDEES install
+ )
+endif()
+
+if(MSVC)
+ set_target_properties(external_zlib_mingw PROPERTIES FOLDER Mingw)
+endif()
+
diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh
index cab67e68e0e..07ccf0cf3a6 100755
--- a/build_files/build_environment/install_deps.sh
+++ b/build_files/build_environment/install_deps.sh
@@ -26,7 +26,7 @@ ARGS=$( \
getopt \
-o s:i:t:h \
--long source:,install:,tmp:,info:,threads:,help,show-deps,no-sudo,no-build,no-confirm,\
-with-all,with-opencollada,\
+with-all,with-opencollada,with-jack,\
ver-ocio:,ver-oiio:,ver-llvm:,ver-osl:,ver-osd:,ver-openvdb:,\
force-all,force-python,force-numpy,force-boost,\
force-ocio,force-openexr,force-oiio,force-llvm,force-osl,force-osd,force-openvdb,\
@@ -113,6 +113,9 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
--with-opencollada
Build and install the OpenCOLLADA libraries.
+ --with-jack
+ Install the jack libraries.
+
--ver-ocio=<ver>
Force version of OCIO library.
@@ -284,13 +287,13 @@ NO_BUILD=false
NO_CONFIRM=false
USE_CXX11=true # Mandatory in blender2.8
-PYTHON_VERSION="3.5.3"
-PYTHON_VERSION_MIN="3.5"
+PYTHON_VERSION="3.6.2"
+PYTHON_VERSION_MIN="3.6"
PYTHON_FORCE_BUILD=false
PYTHON_FORCE_REBUILD=false
PYTHON_SKIP=false
-NUMPY_VERSION="1.10.1"
+NUMPY_VERSION="1.13.1"
NUMPY_VERSION_MIN="1.8"
NUMPY_FORCE_BUILD=false
NUMPY_FORCE_REBUILD=false
@@ -499,6 +502,9 @@ while true; do
--with-opencollada)
WITH_OPENCOLLADA=true; shift; continue
;;
+ --with-jack)
+ WITH_JACK=true; shift; continue;
+ ;;
--ver-ocio)
OCIO_VERSION="$2"
OCIO_VERSION_MIN=$OCIO_VERSION
@@ -702,6 +708,9 @@ done
if [ "$WITH_ALL" = true -a "$OPENCOLLADA_SKIP" = false ]; then
WITH_OPENCOLLADA=true
fi
+if [ "$WITH_ALL" = true ]; then
+ WITH_JACK=true
+fi
WARNING "****WARNING****"
@@ -722,7 +731,7 @@ PRINT ""
# This has to be done here, because user might force some versions...
PYTHON_SOURCE=( "https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz" )
-NUMPY_SOURCE=( "http://sourceforge.net/projects/numpy/files/NumPy/$NUMPY_VERSION/numpy-$NUMPY_VERSION.tar.gz" )
+NUMPY_SOURCE=( "https://github.com/numpy/numpy/releases/download/v$NUMPY_VERSION/numpy-$NUMPY_VERSION.tar.gz" )
_boost_version_nodots=`echo "$BOOST_VERSION" | sed -r 's/\./_/g'`
BOOST_SOURCE=( "http://sourceforge.net/projects/boost/files/boost/$BOOST_VERSION/boost_$_boost_version_nodots.tar.bz2/download" )
@@ -1143,7 +1152,7 @@ compile_Numpy() {
cd $_src
- $_python/bin/python3 setup.py install --prefix=$_inst
+ $_python/bin/python3 setup.py install --old-and-unmanageable --prefix=$_inst
if [ -d $_inst ]; then
# Can't use _create_inst_shortcut here...
@@ -1582,7 +1591,7 @@ compile_OIIO() {
fi
# To be changed each time we make edits that would modify the compiled result!
- oiio_magic=16
+ oiio_magic=17
_init_oiio
# Clean install if needed!
@@ -1646,6 +1655,9 @@ compile_OIIO() {
INFO "ILMBASE_HOME=$INST/openexr"
fi
+ # ptex is only needed when nicholas bishop is ready
+ cmake_d="$cmake_d -D USE_PTEX=OFF"
+
# Optional tests and cmd tools
cmake_d="$cmake_d -D USE_QT=OFF"
cmake_d="$cmake_d -D USE_PYTHON=OFF"
@@ -1757,7 +1769,7 @@ compile_LLVM() {
cd $_src
# XXX Ugly patching hack!
- patch -p1 -i "$SCRIPT_DIR/install_deps_patches/llvm.patch"
+ patch -p1 -i "$SCRIPT_DIR/patches/install_deps_llvm.diff"
cd $CWD
@@ -1863,7 +1875,7 @@ compile_OSL() {
git reset --hard
# XXX Ugly patching hack!
- patch -p1 -i "$SCRIPT_DIR/install_deps_patches/osl.patch"
+ patch -p1 -i "$SCRIPT_DIR/patches/install_deps_osl.diff"
fi
# Always refresh the whole build!
@@ -2644,7 +2656,7 @@ install_DEB() {
PRINT ""
fi
- if [ "$WITH_ALL" = true ]; then
+ if [ "$WITH_JACK" = true ]; then
_packages="$_packages libspnav-dev"
# Only install jack if jack2 is not already installed!
JACK="libjack-dev"
@@ -2661,10 +2673,10 @@ install_DEB() {
install_packages_DEB $_packages
PRINT""
- SNDFILE_DEV="libsndfile1-dev"
- check_package_DEB $SNDFILE_DEV
+ LIBSNDFILE_DEV="libsndfile1-dev"
+ check_package_DEB $LIBSNDFILE_DEV
if [ $? -eq 0 ]; then
- install_packages_DEB $SNDFILE_DEV
+ install_packages_DEB $LIBSNDFILE_DEV
fi
PRINT ""
@@ -3181,7 +3193,7 @@ install_RPM() {
if [ "$RPM" = "FEDORA" -o "$RPM" = "RHEL" ]; then
_packages="$_packages freetype-devel tbb-devel"
- if [ "$WITH_ALL" = true ]; then
+ if [ "$WITH_JACK" = true ]; then
_packages="$_packages jack-audio-connection-kit-devel"
fi
@@ -3259,10 +3271,10 @@ install_RPM() {
fi
PRINT""
- SNDFILE_DEV="libsndfile-devel"
- check_package_RPM $SNDFILE_DEV
+ LIBSNDFILE_DEV="libsndfile-devel"
+ check_package_RPM $LIBSNDFILE_DEV
if [ $? -eq 0 ]; then
- install_packages_RPM $SNDFILE_DEV
+ install_packages_RPM $LIBSNDFILE_DEV
fi
if [ "$WITH_ALL" = true ]; then
@@ -3655,17 +3667,21 @@ install_ARCH() {
THEORA_USE=true
if [ "$WITH_ALL" = true ]; then
- _packages="$_packages jack libspnav"
+ _packages="$_packages libspnav"
+ fi
+
+ if [ "$WITH_JACK" = true ]; then
+ _packages="$_packages jack"
fi
PRINT ""
install_packages_ARCH $_packages
PRINT""
- SNDFILE_DEV="libsndfile"
- check_package_ARCH $SNDFILE_DEV
+ LIBSNDFILE_DEV="libsndfile"
+ check_package_ARCH $LIBSNDFILE_DEV
if [ $? -eq 0 ]; then
- install_packages_ARCH $SNDFILE_DEV
+ install_packages_ARCH $LIBSNDFILE_DEV
fi
PRINT ""
@@ -4317,6 +4333,14 @@ print_info() {
_buildargs="$_buildargs $_1"
fi
+ if [ "$WITH_JACK" = true ]; then
+ _1="-D WITH_JACK=ON"
+ _2="-D WITH_JACK_DYNLOAD=ON"
+ PRINT " $_1"
+ PRINT " $_2"
+ _buildargs="$_buildargs $_1 $_2"
+ fi
+
if [ "$ALEMBIC_SKIP" = false ]; then
_1="-D WITH_ALEMBIC=ON"
PRINT " $_1"
diff --git a/build_files/build_environment/patches/alembic.diff b/build_files/build_environment/patches/alembic.diff
new file mode 100644
index 00000000000..f869858efb2
--- /dev/null
+++ b/build_files/build_environment/patches/alembic.diff
@@ -0,0 +1,35 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 3e09c57..26565ae 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -116,7 +116,7 @@ IF (NOT ${ALEMBIC_LIB_USES_TR1} AND NOT ${ALEMBIC_LIB_USES_BOOST})
+ INCLUDE(CheckCXXCompilerFlag)
+ CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
+ CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
+- IF (COMPILER_SUPPORTS_CXX1X)
++ IF (COMPILER_SUPPORTS_CXX11)
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+ ELSEIF (COMPILER_SUPPORTS_CXX0X)
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
+--- a/lib/Alembic/AbcCoreOgawa/StreamManager.cpp
++++ b/lib/Alembic/AbcCoreOgawa/StreamManager.cpp
+@@ -47,7 +47,18 @@
+ #define COMPARE_EXCHANGE( V, COMP, EXCH ) V.compare_exchange_weak( COMP, EXCH, std::memory_order_seq_cst, std::memory_order_seq_cst )
+ // Windows
+ #elif defined( _MSC_VER )
+-#define COMPARE_EXCHANGE( V, COMP, EXCH ) InterlockedCompareExhange64( &V, EXCH, COMP ) == COMP
++#define COMPARE_EXCHANGE( V, COMP, EXCH ) InterlockedCompareExchange64( &V, EXCH, COMP ) == COMP
++int ffsll(long long value)
++{
++ if (!value)
++ return 0;
++
++ for (int bit = 0; bit < 63; bit++)
++ {
++ if (value & (1 << bit))
++ return bit + 1;
++ }
++}
+ // gcc 4.8 and above not using C++11
+ #elif defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 8
+ #define COMPARE_EXCHANGE( V, COMP, EXCH ) __atomic_compare_exchange_n( &V, &COMP, EXCH, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST )
diff --git a/build_files/build_environment/patches/blosc.diff b/build_files/build_environment/patches/blosc.diff
new file mode 100644
index 00000000000..3bd6ef28144
--- /dev/null
+++ b/build_files/build_environment/patches/blosc.diff
@@ -0,0 +1,33 @@
+diff -Naur src/blosc/CMakeLists.txt external_blosc/blosc/CMakeLists.txt
+--- src/blosc/CMakeLists.txt 2016-02-03 10:26:28 -0700
++++ external_blosc/blosc/CMakeLists.txt 2017-03-03 09:03:31 -0700
+@@ -61,6 +61,8 @@
+ set(SOURCES ${SOURCES} win32/pthread.c)
+ else(NOT Threads_FOUND)
+ set(LIBS ${LIBS} ${CMAKE_THREAD_LIBS_INIT})
++ set(LIBS ${LIBS} ${PTHREAD_LIBS})
++ include_directories( ${PTHREAD_INCLUDE_DIR} )
+ endif(NOT Threads_FOUND)
+ else(WIN32)
+ find_package(Threads REQUIRED)
+diff -Naur src/blosc/blosc.c external_blosc/blosc/blosc.c
+--- src/blosc/blosc.c 2016-02-03 10:26:28 -0700
++++ external_blosc/blosc/blosc.c 2017-03-03 09:01:50 -0700
+@@ -49,12 +49,12 @@
+ #include <inttypes.h>
+ #endif /* _WIN32 */
+
+-#if defined(_WIN32) && !defined(__GNUC__)
+- #include "win32/pthread.h"
+- #include "win32/pthread.c"
+-#else
++//#if defined(_WIN32) && !defined(__GNUC__)
++// #include "win32/pthread.h"
++ //#include "win32/pthread.c"
++//#else
+ #include <pthread.h>
+-#endif
++//#endif
+
+ /* If C11 is supported, use it's built-in aligned allocation. */
+ #if __STDC_VERSION__ >= 201112L
diff --git a/build_files/build_environment/patches/clang.diff b/build_files/build_environment/patches/clang.diff
new file mode 100644
index 00000000000..724e92f8163
--- /dev/null
+++ b/build_files/build_environment/patches/clang.diff
@@ -0,0 +1,127 @@
+--- cfe/trunk/lib/Serialization/ASTWriter.cpp
++++ cfe/trunk/lib/Serialization/ASTWriter.cpp
+@@ -56,14 +56,14 @@
+ using namespace clang::serialization;
+
+ template <typename T, typename Allocator>
+-static StringRef bytes(const std::vector<T, Allocator> &v) {
++static StringRef data(const std::vector<T, Allocator> &v) {
+ if (v.empty()) return StringRef();
+ return StringRef(reinterpret_cast<const char*>(&v[0]),
+ sizeof(T) * v.size());
+ }
+
+ template <typename T>
+-static StringRef bytes(const SmallVectorImpl<T> &v) {
++static StringRef data(const SmallVectorImpl<T> &v) {
+ return StringRef(reinterpret_cast<const char*>(v.data()),
+ sizeof(T) * v.size());
+ }
+@@ -1385,7 +1385,7 @@
+ Record.push_back(INPUT_FILE_OFFSETS);
+ Record.push_back(InputFileOffsets.size());
+ Record.push_back(UserFilesNum);
+- Stream.EmitRecordWithBlob(OffsetsAbbrevCode, Record, bytes(InputFileOffsets));
++ Stream.EmitRecordWithBlob(OffsetsAbbrevCode, Record, data(InputFileOffsets));
+ }
+
+ //===----------------------------------------------------------------------===//
+@@ -1771,7 +1771,7 @@
+ Record.push_back(SOURCE_LOCATION_OFFSETS);
+ Record.push_back(SLocEntryOffsets.size());
+ Record.push_back(SourceMgr.getNextLocalOffset() - 1); // skip dummy
+- Stream.EmitRecordWithBlob(SLocOffsetsAbbrev, Record, bytes(SLocEntryOffsets));
++ Stream.EmitRecordWithBlob(SLocOffsetsAbbrev, Record, data(SLocEntryOffsets));
+
+ // Write the source location entry preloads array, telling the AST
+ // reader which source locations entries it should load eagerly.
+@@ -2087,7 +2087,7 @@
+ Record.push_back(MacroOffsets.size());
+ Record.push_back(FirstMacroID - NUM_PREDEF_MACRO_IDS);
+ Stream.EmitRecordWithBlob(MacroOffsetAbbrev, Record,
+- bytes(MacroOffsets));
++ data(MacroOffsets));
+ }
+
+ void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec) {
+@@ -2185,7 +2185,7 @@
+ Record.push_back(PPD_ENTITIES_OFFSETS);
+ Record.push_back(FirstPreprocessorEntityID - NUM_PREDEF_PP_ENTITY_IDS);
+ Stream.EmitRecordWithBlob(PPEOffsetAbbrev, Record,
+- bytes(PreprocessedEntityOffsets));
++ data(PreprocessedEntityOffsets));
+ }
+ }
+
+@@ -2548,7 +2548,7 @@
+ Record.push_back(CXX_BASE_SPECIFIER_OFFSETS);
+ Record.push_back(CXXBaseSpecifiersOffsets.size());
+ Stream.EmitRecordWithBlob(BaseSpecifierOffsetAbbrev, Record,
+- bytes(CXXBaseSpecifiersOffsets));
++ data(CXXBaseSpecifiersOffsets));
+ }
+
+ //===----------------------------------------------------------------------===//
+@@ -2623,7 +2623,7 @@
+ Decls.push_back(std::make_pair((*D)->getKind(), GetDeclRef(*D)));
+
+ ++NumLexicalDeclContexts;
+- Stream.EmitRecordWithBlob(DeclContextLexicalAbbrev, Record, bytes(Decls));
++ Stream.EmitRecordWithBlob(DeclContextLexicalAbbrev, Record, data(Decls));
+ return Offset;
+ }
+
+@@ -2642,7 +2642,7 @@
+ Record.push_back(TYPE_OFFSET);
+ Record.push_back(TypeOffsets.size());
+ Record.push_back(FirstTypeID - NUM_PREDEF_TYPE_IDS);
+- Stream.EmitRecordWithBlob(TypeOffsetAbbrev, Record, bytes(TypeOffsets));
++ Stream.EmitRecordWithBlob(TypeOffsetAbbrev, Record, data(TypeOffsets));
+
+ // Write the declaration offsets array
+ Abbrev = new BitCodeAbbrev();
+@@ -2655,7 +2655,7 @@
+ Record.push_back(DECL_OFFSET);
+ Record.push_back(DeclOffsets.size());
+ Record.push_back(FirstDeclID - NUM_PREDEF_DECL_IDS);
+- Stream.EmitRecordWithBlob(DeclOffsetAbbrev, Record, bytes(DeclOffsets));
++ Stream.EmitRecordWithBlob(DeclOffsetAbbrev, Record, data(DeclOffsets));
+ }
+
+ void ASTWriter::WriteFileDeclIDsMap() {
+@@ -2680,7 +2680,7 @@
+ unsigned AbbrevCode = Stream.EmitAbbrev(Abbrev);
+ Record.push_back(FILE_SORTED_DECLS);
+ Record.push_back(FileSortedIDs.size());
+- Stream.EmitRecordWithBlob(AbbrevCode, Record, bytes(FileSortedIDs));
++ Stream.EmitRecordWithBlob(AbbrevCode, Record, data(FileSortedIDs));
+ }
+
+ void ASTWriter::WriteComments() {
+@@ -2893,7 +2893,7 @@
+ Record.push_back(SelectorOffsets.size());
+ Record.push_back(FirstSelectorID - NUM_PREDEF_SELECTOR_IDS);
+ Stream.EmitRecordWithBlob(SelectorOffsetAbbrev, Record,
+- bytes(SelectorOffsets));
++ data(SelectorOffsets));
+ }
+ }
+
+@@ -3253,7 +3253,7 @@
+ Record.push_back(IdentifierOffsets.size());
+ Record.push_back(FirstIdentID - NUM_PREDEF_IDENT_IDS);
+ Stream.EmitRecordWithBlob(IdentifierOffsetAbbrev, Record,
+- bytes(IdentifierOffsets));
++ data(IdentifierOffsets));
+ }
+
+ //===----------------------------------------------------------------------===//
+@@ -4046,7 +4046,7 @@
+ Record.clear();
+ Record.push_back(TU_UPDATE_LEXICAL);
+ Stream.EmitRecordWithBlob(TuUpdateLexicalAbbrev, Record,
+- bytes(NewGlobalDecls));
++ data(NewGlobalDecls));
+
+ // And a visible updates block for the translation unit.
+ Abv = new llvm::BitCodeAbbrev();
diff --git a/build_files/build_environment/patches/cmake/modules/FindBlosc.cmake b/build_files/build_environment/patches/cmake/modules/FindBlosc.cmake
new file mode 100644
index 00000000000..d490b7a2ff3
--- /dev/null
+++ b/build_files/build_environment/patches/cmake/modules/FindBlosc.cmake
@@ -0,0 +1,73 @@
+# - Find BLOSC library
+# Find the native BLOSC includes and library
+# This module defines
+# BLOSC_INCLUDE_DIRS, where to find blosc.h, Set when
+# BLOSC is found.
+# BLOSC_LIBRARIES, libraries to link against to use BLOSC.
+# BLOSC_ROOT_DIR, The base directory to search for BLOSC.
+# This can also be an environment variable.
+# BLOSC_FOUND, If false, do not try to use BLOSC.
+#
+# also defined, but not for general use are
+# BLOSC_LIBRARY, where to find the BLOSC library.
+
+#=============================================================================
+# Copyright 2016 Blender Foundation.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+
+# If BLOSC_ROOT_DIR was defined in the environment, use it.
+IF(NOT BLOSC_ROOT_DIR AND NOT $ENV{BLOSC_ROOT_DIR} STREQUAL "")
+ SET(BLOSC_ROOT_DIR $ENV{BLOSC_ROOT_DIR})
+ENDIF()
+
+SET(_blosc_SEARCH_DIRS
+ ${BLOSC_ROOT_DIR}
+ /usr/local
+ /sw # Fink
+ /opt/local # DarwinPorts
+ /opt/csw # Blastwave
+ /opt/lib/blosc
+)
+
+FIND_PATH(BLOSC_INCLUDE_DIR
+ NAMES
+ blosc.h
+ HINTS
+ ${_blosc_SEARCH_DIRS}
+ PATH_SUFFIXES
+ include
+)
+
+FIND_LIBRARY(BLOSC_LIBRARY
+ NAMES
+ blosc
+ HINTS
+ ${_blosc_SEARCH_DIRS}
+ PATH_SUFFIXES
+ lib64 lib
+)
+
+# handle the QUIETLY and REQUIRED arguments and set BLOSC_FOUND to TRUE if
+# all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(BLOSC DEFAULT_MSG
+ BLOSC_LIBRARY BLOSC_INCLUDE_DIR)
+
+IF(BLOSC_FOUND)
+ SET(BLOSC_LIBRARIES ${BLOSC_LIBRARY})
+ SET(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIR})
+ELSE()
+ SET(BLOSC_FOUND FALSE)
+ENDIF()
+
+MARK_AS_ADVANCED(
+ BLOSC_INCLUDE_DIR
+ BLOSC_LIBRARY
+)
diff --git a/build_files/build_environment/patches/cmake/modules/FindCppUnit.cmake b/build_files/build_environment/patches/cmake/modules/FindCppUnit.cmake
new file mode 100644
index 00000000000..3dd480356af
--- /dev/null
+++ b/build_files/build_environment/patches/cmake/modules/FindCppUnit.cmake
@@ -0,0 +1,73 @@
+# - Find CPPUNIT library
+# Find the native CPPUNIT includes and library
+# This module defines
+# CPPUNIT_INCLUDE_DIRS, where to find cppunit.h, Set when
+# CPPUNIT is found.
+# CPPUNIT_LIBRARIES, libraries to link against to use CPPUNIT.
+# CPPUNIT_ROOT_DIR, The base directory to search for CPPUNIT.
+# This can also be an environment variable.
+# CPPUNIT_FOUND, If false, do not try to use CPPUNIT.
+#
+# also defined, but not for general use are
+# CPPUNIT_LIBRARY, where to find the CPPUNIT library.
+
+#=============================================================================
+# Copyright 2016 Blender Foundation.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+
+# If CPPUNIT_ROOT_DIR was defined in the environment, use it.
+IF(NOT CPPUNIT_ROOT_DIR AND NOT $ENV{CPPUNIT_ROOT_DIR} STREQUAL "")
+ SET(CPPUNIT_ROOT_DIR $ENV{CPPUNIT_ROOT_DIR})
+ENDIF()
+
+SET(_cppunit_SEARCH_DIRS
+ ${CPPUNIT_ROOT_DIR}
+ /usr/local
+ /sw # Fink
+ /opt/local # DarwinPorts
+ /opt/csw # Blastwave
+ /opt/lib/cppunit
+)
+
+FIND_PATH(CPPUNIT_INCLUDE_DIR
+ NAMES
+ cppunit/Test.h
+ HINTS
+ ${_cppunit_SEARCH_DIRS}
+ PATH_SUFFIXES
+ include
+)
+
+FIND_LIBRARY(CPPUNIT_LIBRARY
+ NAMES
+ cppunit
+ HINTS
+ ${_cppunit_SEARCH_DIRS}
+ PATH_SUFFIXES
+ lib64 lib
+)
+
+# handle the QUIETLY and REQUIRED arguments and set CPPUNIT_FOUND to TRUE if
+# all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(CPPUNIT DEFAULT_MSG
+ CPPUNIT_LIBRARY CPPUNIT_INCLUDE_DIR)
+
+IF(CPPUNIT_FOUND)
+ SET(CPPUNIT_LIBRARIES ${CPPUNIT_LIBRARY})
+ SET(CPPUNIT_INCLUDE_DIRS ${CPPUNIT_INCLUDE_DIR})
+ELSE()
+ SET(CPPUNIT_FOUND FALSE)
+ENDIF()
+
+MARK_AS_ADVANCED(
+ CPPUNIT_INCLUDE_DIR
+ CPPUNIT_LIBRARY
+)
diff --git a/build_files/build_environment/patches/cmake/modules/FindIlmBase.cmake b/build_files/build_environment/patches/cmake/modules/FindIlmBase.cmake
new file mode 100644
index 00000000000..f1a45228128
--- /dev/null
+++ b/build_files/build_environment/patches/cmake/modules/FindIlmBase.cmake
@@ -0,0 +1,260 @@
+# Module to find IlmBase
+#
+# This module will first look into the directories defined by the variables:
+# - ILMBASE_HOME, ILMBASE_VERSION, ILMBASE_LIB_AREA
+#
+# It also supports non-standard names for the library components.
+#
+# To use a custom IlmBase:
+# - Set the variable ILMBASE_CUSTOM to True
+# - Set the variable ILMBASE_CUSTOM_LIBRARIES to a list of the libraries to
+# use, e.g. "SpiImath SpiHalf SpiIlmThread SpiIex"
+# - Optionally set the variable ILMBASE_CUSTOM_INCLUDE_DIR to any
+# particularly weird place that the OpenEXR/*.h files may be found
+# - Optionally set the variable ILMBASE_CUSTOM_LIB_DIR to any
+# particularly weird place that the libraries files may be found
+#
+# This module defines the following variables:
+#
+# ILMBASE_INCLUDE_DIR - where to find half.h, IlmBaseConfig.h, etc.
+# ILMBASE_LIBRARIES - list of libraries to link against when using IlmBase.
+# ILMBASE_FOUND - True if IlmBase was found.
+
+# Other standarnd issue macros
+include (FindPackageHandleStandardArgs)
+include (FindPackageMessage)
+include (SelectLibraryConfigurations)
+
+
+if( ILMBASE_USE_STATIC_LIBS )
+ set( _ilmbase_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
+ if(WIN32)
+ set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
+ else()
+ set(CMAKE_FIND_LIBRARY_SUFFIXES .a )
+ endif()
+endif()
+
+# Macro to assemble a helper state variable
+macro (SET_STATE_VAR varname)
+ set (tmp_ilmbaselibs ${ILMBASE_CUSTOM_LIBRARIES})
+ separate_arguments (tmp_ilmbaselibs)
+ set (tmp_lst
+ ${ILMBASE_CUSTOM} | ${tmp_ilmbaselibs} |
+ ${ILMBASE_HOME} | ${ILMBASE_VERSION} | ${ILMBASE_LIB_AREA}
+ )
+ set (${varname} "${tmp_lst}")
+ unset (tmp_ilmbaselibs)
+ unset (tmp_lst)
+endmacro ()
+
+# To enforce that find_* functions do not use inadvertently existing versions
+if (ILMBASE_CUSTOM)
+ set (ILMBASE_FIND_OPTIONS "NO_DEFAULT_PATH")
+endif ()
+
+# Macro to search for an include directory
+macro (PREFIX_FIND_INCLUDE_DIR prefix includefile libpath_var)
+ string (TOUPPER ${prefix}_INCLUDE_DIR tmp_varname)
+ find_path(${tmp_varname} ${includefile}
+ HINTS ${${libpath_var}}
+ PATH_SUFFIXES include
+ ${ILMBASE_FIND_OPTIONS}
+ )
+ if (${tmp_varname})
+ mark_as_advanced (${tmp_varname})
+ endif ()
+ unset (tmp_varname)
+endmacro ()
+
+
+# Macro to search for the given library and adds the cached
+# variable names to the specified list
+macro (PREFIX_FIND_LIB prefix libname libpath_var liblist_var cachelist_var)
+ string (TOUPPER ${prefix}_${libname} tmp_prefix)
+ # Handle new library names for OpenEXR 2.1 build via cmake
+ string(REPLACE "." "_" _ILMBASE_VERSION ${ILMBASE_VERSION})
+ string(SUBSTRING ${_ILMBASE_VERSION} 0 3 _ILMBASE_VERSION )
+
+ find_library(${tmp_prefix}_LIBRARY_RELEASE
+ NAMES ${libname} ${libname}-${_ILMBASE_VERSION}
+ HINTS ${${libpath_var}}
+ PATH_SUFFIXES lib
+ ${ILMBASE_FIND_OPTIONS}
+ )
+ find_library(${tmp_prefix}_LIBRARY_DEBUG
+ NAMES ${libname}d ${libname}_d ${libname}debug ${libname}_debug
+ HINTS ${${libpath_var}}
+ PATH_SUFFIXES lib
+ ${ILMBASE_FIND_OPTIONS}
+ )
+ # Properly define ${tmp_prefix}_LIBRARY (cached) and ${tmp_prefix}_LIBRARIES
+ select_library_configurations (${tmp_prefix})
+ list (APPEND ${liblist_var} ${tmp_prefix}_LIBRARIES)
+
+ # Add to the list of variables which should be reset
+ list (APPEND ${cachelist_var}
+ ${tmp_prefix}_LIBRARY
+ ${tmp_prefix}_LIBRARY_RELEASE
+ ${tmp_prefix}_LIBRARY_DEBUG)
+ mark_as_advanced (
+ ${tmp_prefix}_LIBRARY
+ ${tmp_prefix}_LIBRARY_RELEASE
+ ${tmp_prefix}_LIBRARY_DEBUG)
+ unset (tmp_prefix)
+endmacro ()
+
+
+# Encode the current state of the external variables into a string
+SET_STATE_VAR (ILMBASE_CURRENT_STATE)
+
+# If the state has changed, clear the cached variables
+if (ILMBASE_CACHED_STATE AND
+ NOT ILMBASE_CACHED_STATE STREQUAL ILMBASE_CURRENT_STATE)
+
+ foreach (libvar ${ILMBASE_CACHED_VARS})
+ unset (${libvar} CACHE)
+ endforeach ()
+endif ()
+
+
+# Generic search paths
+set (IlmBase_generic_include_paths
+ ${ILMBASE_CUSTOM_INCLUDE_DIR}
+ /usr/include
+ /usr/include/${CMAKE_LIBRARY_ARCHITECTURE}
+ /usr/local/include
+ /sw/include
+ /opt/local/include)
+set (IlmBase_generic_library_paths
+ ${ILMBASE_CUSTOM_LIB_DIR}
+ /usr/lib
+ /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}
+ /usr/local/lib
+ /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}
+ /sw/lib
+ /opt/local/lib)
+
+# Search paths for the IlmBase files
+if (ILMBASE_HOME)
+ if (ILMBASE_VERSION)
+ set (IlmBase_include_paths
+ ${ILMBASE_HOME}/ilmbase-${ILMBASE_VERSION}/include
+ ${ILMBASE_HOME}/include/ilmbase-${ILMBASE_VERSION})
+ set (IlmBase_library_paths
+ ${ILMBASE_HOME}/ilmbase-${ILMBASE_VERSION}/lib
+ ${ILMBASE_HOME}/lib/ilmbase-${ILMBASE_VERSION})
+ endif()
+ list (APPEND IlmBase_include_paths ${ILMBASE_HOME}/include)
+ set (IlmBase_library_paths
+ ${ILMBASE_HOME}/lib
+ ${ILMBASE_HOME}/lib64
+ ${ILMBASE_LIB_AREA}
+ ${IlmBase_library_paths})
+endif ()
+list (APPEND IlmBase_include_paths ${IlmBase_generic_include_paths})
+list (APPEND IlmBase_library_paths ${IlmBase_generic_library_paths})
+
+# Locate the header files
+PREFIX_FIND_INCLUDE_DIR (IlmBase
+ OpenEXR/IlmBaseConfig.h IlmBase_include_paths)
+
+if (ILMBASE_INCLUDE_DIR)
+ # Get the version from config file, if not already set.
+ if (NOT ILMBASE_VERSION)
+ FILE(STRINGS "${ILMBASE_INCLUDE_DIR}/OpenEXR/IlmBaseConfig.h" ILMBASE_BUILD_SPECIFICATION
+ REGEX "^[ \t]*#define[ \t]+ILMBASE_VERSION_STRING[ \t]+\"[.0-9]+\".*$")
+
+ if(ILMBASE_BUILD_SPECIFICATION)
+ if (NOT IlmBase_FIND_QUIETLY)
+ message(STATUS "${ILMBASE_BUILD_SPECIFICATION}")
+ endif ()
+ string(REGEX REPLACE ".*#define[ \t]+ILMBASE_VERSION_STRING[ \t]+\"([.0-9]+)\".*"
+ "\\1" XYZ ${ILMBASE_BUILD_SPECIFICATION})
+ set("ILMBASE_VERSION" ${XYZ} CACHE STRING "Version of ILMBase lib")
+ else()
+ # Old versions (before 2.0?) do not have any version string, just assuming 2.0 should be fine though.
+ message(WARNING "Could not determine ILMBase library version, assuming 2.0.")
+ set("ILMBASE_VERSION" "2.0" CACHE STRING "Version of ILMBase lib")
+ endif()
+ endif()
+endif ()
+
+
+if (ILMBASE_CUSTOM)
+ if (NOT ILMBASE_CUSTOM_LIBRARIES)
+ message (FATAL_ERROR "Custom IlmBase libraries requested but ILMBASE_CUSTOM_LIBRARIES is not set.")
+ endif()
+ set (IlmBase_Libraries ${ILMBASE_CUSTOM_LIBRARIES})
+ separate_arguments(IlmBase_Libraries)
+else ()
+#elseif (${ILMBASE_VERSION} VERSION_LESS "2.1")
+ set (IlmBase_Libraries Half Iex Imath IlmThread)
+#else ()
+# string(REGEX REPLACE "([0-9]+)[.]([0-9]+).*" "\\1_\\2" _ilmbase_libs_ver ${ILMBASE_VERSION})
+# set (IlmBase_Libraries Half Iex-${_ilmbase_libs_ver} Imath-${_ilmbase_libs_ver} IlmThread-${_ilmbase_libs_ver})
+endif ()
+
+
+# Locate the IlmBase libraries
+set (IlmBase_libvars "")
+set (IlmBase_cachevars "")
+foreach (ilmbase_lib ${IlmBase_Libraries})
+ PREFIX_FIND_LIB (IlmBase ${ilmbase_lib}
+ IlmBase_library_paths IlmBase_libvars IlmBase_cachevars)
+endforeach ()
+# Create the list of variables that might need to be cleared
+set (ILMBASE_CACHED_VARS
+ ILMBASE_INCLUDE_DIR ${IlmBase_cachevars}
+ CACHE INTERNAL "Variables set by FindIlmBase.cmake" FORCE)
+
+# Store the current state so that variables might be cleared if required
+set (ILMBASE_CACHED_STATE ${ILMBASE_CURRENT_STATE}
+ CACHE INTERNAL "State last seen by FindIlmBase.cmake" FORCE)
+
+# Link with pthreads if required
+if (NOT WIN32 AND EXISTS ${ILMBASE_INCLUDE_DIR}/OpenEXR/IlmBaseConfig.h)
+ file (STRINGS ${ILMBASE_INCLUDE_DIR}/OpenEXR/IlmBaseConfig.h
+ ILMBASE_HAVE_PTHREAD
+ REGEX "^[ \\t]*#define[ \\t]+HAVE_PTHREAD[ \\t]1[ \\t]*\$"
+ )
+ if (ILMBASE_HAVE_PTHREAD)
+ find_package (Threads)
+ if (CMAKE_USE_PTHREADS_INIT)
+ set (ILMBASE_PTHREADS ${CMAKE_THREAD_LIBS_INIT})
+ endif ()
+ endif ()
+endif ()
+
+# Use the standard function to handle ILMBASE_FOUND
+FIND_PACKAGE_HANDLE_STANDARD_ARGS (IlmBase DEFAULT_MSG
+ ILMBASE_INCLUDE_DIR ${IlmBase_libvars})
+
+if (ILMBASE_FOUND)
+ set (ILMBASE_LIBRARIES "")
+ foreach (tmplib ${IlmBase_libvars})
+ list (APPEND ILMBASE_LIBRARIES ${${tmplib}})
+ endforeach ()
+ list (APPEND ILMBASE_LIBRARIES ${ILMBASE_PTHREADS})
+ if (NOT IlmBase_FIND_QUIETLY)
+ FIND_PACKAGE_MESSAGE (ILMBASE
+ "Found IlmBase: ${ILMBASE_LIBRARIES}"
+ "[${ILMBASE_INCLUDE_DIR}][${ILMBASE_LIBRARIES}][${ILMBASE_CURRENT_STATE}]"
+ )
+ endif ()
+endif ()
+
+# Restore the original find library ordering
+if( ILMBASE_USE_STATIC_LIBS )
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ${_ilmbase_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
+endif()
+
+# Unset the helper variables to avoid pollution
+unset (ILMBASE_CURRENT_STATE)
+unset (IlmBase_include_paths)
+unset (IlmBase_library_paths)
+unset (IlmBase_generic_include_paths)
+unset (IlmBase_generic_library_paths)
+unset (IlmBase_libvars)
+unset (IlmBase_cachevars)
+unset (ILMBASE_PTHREADS)
diff --git a/build_files/build_environment/patches/cmake/modules/FindLogC4Plus.cmake b/build_files/build_environment/patches/cmake/modules/FindLogC4Plus.cmake
new file mode 100644
index 00000000000..2002419cc75
--- /dev/null
+++ b/build_files/build_environment/patches/cmake/modules/FindLogC4Plus.cmake
@@ -0,0 +1,73 @@
+# - Find LOGC4PLUS library
+# Find the native LOGC4PLUS includes and library
+# This module defines
+# LOGC4PLUS_INCLUDE_DIRS, where to find logc4plus.h, Set when
+# LOGC4PLUS is found.
+# LOGC4PLUS_LIBRARIES, libraries to link against to use LOGC4PLUS.
+# LOGC4PLUS_ROOT_DIR, The base directory to search for LOGC4PLUS.
+# This can also be an environment variable.
+# LOGC4PLUS_FOUND, If false, do not try to use LOGC4PLUS.
+#
+# also defined, but not for general use are
+# LOGC4PLUS_LIBRARY, where to find the LOGC4PLUS library.
+
+#=============================================================================
+# Copyright 2016 Blender Foundation.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+
+# If LOGC4PLUS_ROOT_DIR was defined in the environment, use it.
+IF(NOT LOGC4PLUS_ROOT_DIR AND NOT $ENV{LOGC4PLUS_ROOT_DIR} STREQUAL "")
+ SET(LOGC4PLUS_ROOT_DIR $ENV{LOGC4PLUS_ROOT_DIR})
+ENDIF()
+
+SET(_logc4plus_SEARCH_DIRS
+ ${LOGC4PLUS_ROOT_DIR}
+ /usr/local
+ /sw # Fink
+ /opt/local # DarwinPorts
+ /opt/csw # Blastwave
+ /opt/lib/logc4plus
+)
+
+FIND_PATH(LOGC4PLUS_INCLUDE_DIR
+ NAMES
+ logc4plus.h
+ HINTS
+ ${_logc4plus_SEARCH_DIRS}
+ PATH_SUFFIXES
+ include
+)
+
+FIND_LIBRARY(LOGC4PLUS_LIBRARY
+ NAMES
+ logc4plus
+ HINTS
+ ${_logc4plus_SEARCH_DIRS}
+ PATH_SUFFIXES
+ lib64 lib
+ )
+
+# handle the QUIETLY and REQUIRED arguments and set LOGC4PLUS_FOUND to TRUE if
+# all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(LOGC4PLUS DEFAULT_MSG
+ LOGC4PLUS_LIBRARY LOGC4PLUS_INCLUDE_DIR)
+
+IF(LOGC4PLUS_FOUND)
+ SET(LOGC4PLUS_LIBRARIES ${LOGC4PLUS_LIBRARY})
+ SET(LOGC4PLUS_INCLUDE_DIRS ${LOGC4PLUS_INCLUDE_DIR})
+ELSE()
+ SET(LOGC4PLUS_LOGC4PLUS_FOUND FALSE)
+ENDIF()
+
+MARK_AS_ADVANCED(
+ LOGC4PLUS_INCLUDE_DIR
+ LOGC4PLUS_LIBRARY
+)
diff --git a/build_files/build_environment/patches/cmake/modules/FindOpenEXR.cmake b/build_files/build_environment/patches/cmake/modules/FindOpenEXR.cmake
new file mode 100644
index 00000000000..08d872445d7
--- /dev/null
+++ b/build_files/build_environment/patches/cmake/modules/FindOpenEXR.cmake
@@ -0,0 +1,244 @@
+# Module to find OpenEXR.
+#
+# This module will first look into the directories defined by the variables:
+# - OPENEXR_HOME, OPENEXR_VERSION, OPENEXR_LIB_AREA
+#
+# It also supports non-standard names for the library components.
+#
+# To use a custom OpenEXR
+# - Set the variable OPENEXR_CUSTOM to True
+# - Set the variable OPENEXR_CUSTOM_LIBRARY to the name of the library to
+# use, e.g. "SpiIlmImf"
+# - Optionally set the variable OPENEXR_CUSTOM_INCLUDE_DIR to any
+# particularly weird place that the OpenEXR/*.h files may be found
+# - Optionally set the variable OPENEXR_CUSTOM_LIB_DIR to any
+# particularly weird place that the libraries files may be found
+#
+# This module defines the following variables:
+#
+# OPENEXR_INCLUDE_DIR - where to find ImfRgbaFile.h, OpenEXRConfig, etc.
+# OPENEXR_LIBRARIES - list of libraries to link against when using OpenEXR.
+# This list does NOT include the IlmBase libraries.
+# These are defined by the FindIlmBase module.
+# OPENEXR_FOUND - True if OpenEXR was found.
+
+# Other standarnd issue macros
+include (SelectLibraryConfigurations)
+include (FindPackageHandleStandardArgs)
+include (FindPackageMessage)
+
+if( OPENEXR_USE_STATIC_LIBS )
+ set( _openexr_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
+ if(WIN32)
+ set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
+ else()
+ set(CMAKE_FIND_LIBRARY_SUFFIXES .a )
+ endif()
+endif()
+
+# Macro to assemble a helper state variable
+macro (SET_STATE_VAR varname)
+ set (tmp_lst
+ ${OPENEXR_CUSTOM} | ${OPENEXR_CUSTOM_LIBRARY} |
+ ${OPENEXR_HOME} | ${OPENEXR_VERSION} | ${OPENEXR_LIB_AREA}
+ )
+ set (${varname} "${tmp_lst}")
+ unset (tmp_lst)
+endmacro ()
+
+# To enforce that find_* functions do not use inadvertently existing versions
+if (OPENEXR_CUSTOM)
+ set (OPENEXR_FIND_OPTIONS "NO_DEFAULT_PATH")
+endif ()
+
+# Macro to search for an include directory
+macro (PREFIX_FIND_INCLUDE_DIR prefix includefile libpath_var)
+ string (TOUPPER ${prefix}_INCLUDE_DIR tmp_varname)
+ find_path(${tmp_varname} ${includefile}
+ HINTS ${${libpath_var}}
+ PATH_SUFFIXES include
+ ${OPENEXR_FIND_OPTIONS}
+ )
+ if (${tmp_varname})
+ mark_as_advanced (${tmp_varname})
+ endif ()
+ unset (tmp_varname)
+endmacro ()
+
+
+# Macro to search for the given library and adds the cached
+# variable names to the specified list
+macro (PREFIX_FIND_LIB prefix libname libpath_var liblist_var cachelist_var)
+ string (TOUPPER ${prefix}_${libname} tmp_prefix)
+ # Handle new library names for OpenEXR 2.1 build via cmake
+ string(REPLACE "." "_" _ILMBASE_VERSION ${ILMBASE_VERSION})
+ string(SUBSTRING ${_ILMBASE_VERSION} 0 3 _ILMBASE_VERSION )
+ find_library(${tmp_prefix}_LIBRARY_RELEASE
+ NAMES ${libname} ${libname}-${_ILMBASE_VERSION}
+ HINTS ${${libpath_var}}
+ PATH_SUFFIXES lib
+ ${OPENEXR_FIND_OPTIONS}
+ )
+ find_library(${tmp_prefix}_LIBRARY_DEBUG
+ NAMES ${libname}d ${libname}_d ${libname}debug ${libname}_debug
+ HINTS ${${libpath_var}}
+ PATH_SUFFIXES lib
+ ${OPENEXR_FIND_OPTIONS}
+ )
+ # Properly define ${tmp_prefix}_LIBRARY (cached) and ${tmp_prefix}_LIBRARIES
+ select_library_configurations (${tmp_prefix})
+ list (APPEND ${liblist_var} ${tmp_prefix}_LIBRARIES)
+
+ # Add to the list of variables which should be reset
+ list (APPEND ${cachelist_var}
+ ${tmp_prefix}_LIBRARY
+ ${tmp_prefix}_LIBRARY_RELEASE
+ ${tmp_prefix}_LIBRARY_DEBUG)
+ mark_as_advanced (
+ ${tmp_prefix}_LIBRARY
+ ${tmp_prefix}_LIBRARY_RELEASE
+ ${tmp_prefix}_LIBRARY_DEBUG)
+ unset (tmp_prefix)
+endmacro ()
+
+
+# Encode the current state of the external variables into a string
+SET_STATE_VAR (OPENEXR_CURRENT_STATE)
+
+# If the state has changed, clear the cached variables
+if (OPENEXR_CACHED_STATE AND
+ NOT OPENEXR_CACHED_STATE STREQUAL OPENEXR_CURRENT_STATE)
+ foreach (libvar ${OPENEXR_CACHED_VARS})
+ unset (${libvar} CACHE)
+ endforeach ()
+endif ()
+
+# Generic search paths
+set (OpenEXR_generic_include_paths
+ ${OPENEXR_CUSTOM_INCLUDE_DIR}
+ /usr/include
+ /usr/include/${CMAKE_LIBRARY_ARCHITECTURE}
+ /usr/local/include
+ /sw/include
+ /opt/local/include)
+set (OpenEXR_generic_library_paths
+ ${OPENEXR_CUSTOM_LIB_DIR}
+ /usr/lib
+ /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}
+ /usr/local/lib
+ /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}
+ /sw/lib
+ /opt/local/lib)
+
+# Search paths for the OpenEXR files
+if (OPENEXR_HOME)
+ set (OpenEXR_library_paths
+ ${OPENEXR_HOME}/lib
+ ${OPENEXR_HOME}/lib64)
+ if (OPENEXR_VERSION)
+ set (OpenEXR_include_paths
+ ${OPENEXR_HOME}/openexr-${OPENEXR_VERSION}/include
+ ${OPENEXR_HOME}/include/openexr-${OPENEXR_VERSION})
+ list (APPEND OpenEXR_library_paths
+ ${OPENEXR_HOME}/openexr-${OPENEXR_VERSION}/lib
+ ${OPENEXR_HOME}/lib/openexr-${OPENEXR_VERSION})
+ endif()
+ list (APPEND OpenEXR_include_paths ${OPENEXR_HOME}/include)
+ if (OPENEXR_LIB_AREA)
+ list (INSERT OpenEXR_library_paths 2 ${OPENEXR_LIB_AREA})
+ endif ()
+endif ()
+if (ILMBASE_HOME AND OPENEXR_VERSION)
+ list (APPEND OpenEXR_include_paths
+ ${ILMBASE_HOME}/include/openexr-${OPENEXR_VERSION})
+endif()
+list (APPEND OpenEXR_include_paths ${OpenEXR_generic_include_paths})
+list (APPEND OpenEXR_library_paths ${OpenEXR_generic_library_paths})
+
+# Locate the header files
+PREFIX_FIND_INCLUDE_DIR (OpenEXR
+ OpenEXR/ImfArray.h OpenEXR_include_paths)
+
+if (OPENEXR_INCLUDE_DIR)
+ # Get the version from config file, if not already set.
+ if (NOT OPENEXR_VERSION)
+ FILE(STRINGS "${OPENEXR_INCLUDE_DIR}/OpenEXR/OpenEXRConfig.h" OPENEXR_BUILD_SPECIFICATION
+ REGEX "^[ \t]*#define[ \t]+OPENEXR_VERSION_STRING[ \t]+\"[.0-9]+\".*$")
+
+ if(OPENEXR_BUILD_SPECIFICATION)
+ if (NOT OpenEXR_FIND_QUIETLY)
+ message(STATUS "${OPENEXR_BUILD_SPECIFICATION}")
+ endif ()
+ string(REGEX REPLACE ".*#define[ \t]+OPENEXR_VERSION_STRING[ \t]+\"([.0-9]+)\".*"
+ "\\1" XYZ ${OPENEXR_BUILD_SPECIFICATION})
+ set("OPENEXR_VERSION" ${XYZ} CACHE STRING "Version of OpenEXR lib")
+ else()
+ # Old versions (before 2.0?) do not have any version string, just assuming 2.0 should be fine though.
+ message(WARNING "Could not determine ILMBase library version, assuming 2.0.")
+ set("OPENEXR_VERSION" "2.0" CACHE STRING "Version of OpenEXR lib")
+ endif()
+ endif()
+endif ()
+
+if (OPENEXR_CUSTOM)
+ if (NOT OPENEXR_CUSTOM_LIBRARY)
+ message (FATAL_ERROR "Custom OpenEXR library requested but OPENEXR_CUSTOM_LIBRARY is not set.")
+ endif()
+ set (OpenEXR_Library ${OPENEXR_CUSTOM_LIBRARY})
+else ()
+#elseif (${OPENEXR_VERSION} VERSION_LESS "2.1")
+ set (OpenEXR_Library IlmImf)
+#else ()
+# string(REGEX REPLACE "([0-9]+)[.]([0-9]+).*" "\\1_\\2" _openexr_libs_ver ${OPENEXR_VERSION})
+# set (OpenEXR_Library IlmImf-${_openexr_libs_ver})
+endif ()
+
+# Locate the OpenEXR library
+set (OpenEXR_libvars "")
+set (OpenEXR_cachevars "")
+PREFIX_FIND_LIB (OpenEXR ${OpenEXR_Library}
+ OpenEXR_library_paths OpenEXR_libvars OpenEXR_cachevars)
+
+# Create the list of variables that might need to be cleared
+set (OPENEXR_CACHED_VARS
+ OPENEXR_INCLUDE_DIR ${OpenEXR_cachevars}
+ CACHE INTERNAL "Variables set by FindOpenEXR.cmake" FORCE)
+
+# Store the current state so that variables might be cleared if required
+set (OPENEXR_CACHED_STATE ${OPENEXR_CURRENT_STATE}
+ CACHE INTERNAL "State last seen by FindOpenEXR.cmake" FORCE)
+
+# Always link explicitly with zlib
+set (OPENEXR_ZLIB ${ZLIB_LIBRARIES})
+
+# Use the standard function to handle OPENEXR_FOUND
+FIND_PACKAGE_HANDLE_STANDARD_ARGS (OpenEXR DEFAULT_MSG
+ OPENEXR_INCLUDE_DIR ${OpenEXR_libvars})
+
+if (OPENEXR_FOUND)
+ set (OPENEXR_LIBRARIES "")
+ foreach (tmplib ${OpenEXR_libvars})
+ list (APPEND OPENEXR_LIBRARIES ${${tmplib}})
+ endforeach ()
+ list (APPEND OPENEXR_LIBRARIES ${ZLIB_LIBRARIES})
+ if (NOT OpenEXR_FIND_QUIETLY)
+ FIND_PACKAGE_MESSAGE (OPENEXR
+ "Found OpenEXR: ${OPENEXR_LIBRARIES}"
+ "[${OPENEXR_INCLUDE_DIR}][${OPENEXR_LIBRARIES}][${OPENEXR_CURRENT_STATE}]"
+ )
+ endif ()
+endif ()
+
+# Restore the original find library ordering
+if( OPENEXR_USE_STATIC_LIBS )
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ${_openexr_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
+endif()
+
+# Unset the helper variables to avoid pollution
+unset (OPENEXR_CURRENT_STATE)
+unset (OpenEXR_include_paths)
+unset (OpenEXR_library_paths)
+unset (OpenEXR_generic_include_paths)
+unset (OpenEXR_generic_library_paths)
+unset (OpenEXR_libvars)
+unset (OpenEXR_cachevars)
diff --git a/build_files/build_environment/patches/cmake/modules/FindTBB.cmake b/build_files/build_environment/patches/cmake/modules/FindTBB.cmake
new file mode 100644
index 00000000000..8a821f8092e
--- /dev/null
+++ b/build_files/build_environment/patches/cmake/modules/FindTBB.cmake
@@ -0,0 +1,73 @@
+# - Find TBB library
+# Find the native TBB includes and library
+# This module defines
+# TBB_INCLUDE_DIRS, where to find tbb.h, Set when
+# TBB is found.
+# TBB_LIBRARIES, libraries to link against to use TBB.
+# TBB_ROOT_DIR, The base directory to search for TBB.
+# This can also be an environment variable.
+# TBB_FOUND, If false, do not try to use TBB.
+#
+# also defined, but not for general use are
+# TBB_LIBRARY, where to find the TBB library.
+
+#=============================================================================
+# Copyright 2016 Blender Foundation.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+
+# If TBB_ROOT_DIR was defined in the environment, use it.
+IF(NOT TBB_ROOT_DIR AND NOT $ENV{TBB_ROOT_DIR} STREQUAL "")
+ SET(TBB_ROOT_DIR $ENV{TBB_ROOT_DIR})
+ENDIF()
+
+SET(_tbb_SEARCH_DIRS
+ ${TBB_ROOT_DIR}
+ /usr/local
+ /sw # Fink
+ /opt/local # DarwinPorts
+ /opt/csw # Blastwave
+ /opt/lib/tbb
+)
+
+FIND_PATH(TBB_INCLUDE_DIR
+ NAMES
+ tbb/tbb.h
+ HINTS
+ ${_tbb_SEARCH_DIRS}
+ PATH_SUFFIXES
+ include
+)
+
+FIND_LIBRARY(TBB_LIBRARY
+ NAMES
+ tbb
+ HINTS
+ ${_tbb_SEARCH_DIRS}
+ PATH_SUFFIXES
+ lib64 lib
+ )
+
+# handle the QUIETLY and REQUIRED arguments and set TBB_FOUND to TRUE if
+# all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(TBB DEFAULT_MSG
+ TBB_LIBRARY TBB_INCLUDE_DIR)
+
+IF(TBB_FOUND)
+ SET(TBB_LIBRARIES ${TBB_LIBRARY})
+ SET(TBB_INCLUDE_DIRS ${TBB_INCLUDE_DIR})
+ELSE()
+ SET(TBB_TBB_FOUND FALSE)
+ENDIF()
+
+MARK_AS_ADVANCED(
+ TBB_INCLUDE_DIR
+ TBB_LIBRARY
+)
diff --git a/build_files/build_environment/patches/cmake/modules/SelectLibraryConfigurations.cmake b/build_files/build_environment/patches/cmake/modules/SelectLibraryConfigurations.cmake
new file mode 100644
index 00000000000..51b4dda0653
--- /dev/null
+++ b/build_files/build_environment/patches/cmake/modules/SelectLibraryConfigurations.cmake
@@ -0,0 +1,82 @@
+# select_library_configurations( basename )
+#
+# This macro takes a library base name as an argument, and will choose good
+# values for basename_LIBRARY, basename_LIBRARIES, basename_LIBRARY_DEBUG, and
+# basename_LIBRARY_RELEASE depending on what has been found and set. If only
+# basename_LIBRARY_RELEASE is defined, basename_LIBRARY, basename_LIBRARY_DEBUG,
+# and basename_LIBRARY_RELEASE will be set to the release value. If only
+# basename_LIBRARY_DEBUG is defined, then basename_LIBRARY,
+# basename_LIBRARY_DEBUG and basename_LIBRARY_RELEASE will take the debug value.
+#
+# If the generator supports configuration types, then basename_LIBRARY and
+# basename_LIBRARIES will be set with debug and optimized flags specifying the
+# library to be used for the given configuration. If no build type has been set
+# or the generator in use does not support configuration types, then
+# basename_LIBRARY and basename_LIBRARIES will take only the release values.
+
+#=============================================================================
+# Copyright 2009 Kitware, Inc.
+# Copyright 2009 Will Dicharry <wdicharry@stellarscience.com>
+# Copyright 2005-2009 Kitware, Inc.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+# License text for the above reference.)
+
+# This macro was adapted from the FindQt4 CMake module and is maintained by Will
+# Dicharry <wdicharry@stellarscience.com>.
+
+# Utility macro to check if one variable exists while another doesn't, and set
+# one that doesn't exist to the one that exists.
+macro( _set_library_name basename GOOD BAD )
+ if( ${basename}_LIBRARY_${GOOD} AND NOT ${basename}_LIBRARY_${BAD} )
+ set( ${basename}_LIBRARY_${BAD} ${${basename}_LIBRARY_${GOOD}} )
+ set( ${basename}_LIBRARY ${${basename}_LIBRARY_${GOOD}} )
+ set( ${basename}_LIBRARIES ${${basename}_LIBRARY_${GOOD}} )
+ endif( ${basename}_LIBRARY_${GOOD} AND NOT ${basename}_LIBRARY_${BAD} )
+endmacro( _set_library_name )
+
+macro( select_library_configurations basename )
+ # if only the release version was found, set the debug to be the release
+ # version.
+ _set_library_name( ${basename} RELEASE DEBUG )
+ # if only the debug version was found, set the release value to be the
+ # debug value.
+ _set_library_name( ${basename} DEBUG RELEASE )
+ if (${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE )
+ # if the generator supports configuration types or CMAKE_BUILD_TYPE
+ # is set, then set optimized and debug options.
+ if( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE )
+ set( ${basename}_LIBRARY
+ optimized ${${basename}_LIBRARY_RELEASE}
+ debug ${${basename}_LIBRARY_DEBUG} )
+ set( ${basename}_LIBRARIES
+ optimized ${${basename}_LIBRARY_RELEASE}
+ debug ${${basename}_LIBRARY_DEBUG} )
+ else( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE )
+ # If there are no configuration types or build type, just use
+ # the release version
+ set( ${basename}_LIBRARY ${${basename}_LIBRARY_RELEASE} )
+ set( ${basename}_LIBRARIES ${${basename}_LIBRARY_RELEASE} )
+ endif( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE )
+ endif( ${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE )
+
+ set( ${basename}_LIBRARY ${${basename}_LIBRARY} CACHE FILEPATH
+ "The ${basename} library" )
+
+ if( ${basename}_LIBRARY )
+ set( ${basename}_FOUND TRUE )
+ endif( ${basename}_LIBRARY )
+
+ mark_as_advanced( ${basename}_LIBRARY
+ ${basename}_LIBRARY_RELEASE
+ ${basename}_LIBRARY_DEBUG
+ )
+endmacro( select_library_configurations )
+
diff --git a/build_files/build_environment/patches/cmakelists_glew.txt b/build_files/build_environment/patches/cmakelists_glew.txt
new file mode 100644
index 00000000000..ec36d4bde63
--- /dev/null
+++ b/build_files/build_environment/patches/cmakelists_glew.txt
@@ -0,0 +1,2 @@
+cmake_minimum_required (VERSION 2.4)
+add_subdirectory(build/cmake) \ No newline at end of file
diff --git a/build_files/build_environment/patches/cmakelists_hidapi.txt b/build_files/build_environment/patches/cmakelists_hidapi.txt
new file mode 100644
index 00000000000..239b9d88b16
--- /dev/null
+++ b/build_files/build_environment/patches/cmakelists_hidapi.txt
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 2.8)
+project(hidapi)
+
+set(SRC_FILES
+ windows/hid.c
+)
+
+set(HEADER_FILES
+ hidapi/hidapi.h
+)
+include_directories(hidapi)
+add_definitions(-DHID_API_STATIC)
+add_library(hidapi STATIC ${SRC_FILES} ${HEADER_FILES})
+
+install(TARGETS hidapi DESTINATION lib)
+
+INSTALL(FILES hidapi/hidapi.h
+ DESTINATION "include"
+ )
+
diff --git a/build_files/build_environment/patches/cmakelists_openvdb.txt b/build_files/build_environment/patches/cmakelists_openvdb.txt
new file mode 100644
index 00000000000..dd3e9c1a887
--- /dev/null
+++ b/build_files/build_environment/patches/cmakelists_openvdb.txt
@@ -0,0 +1,398 @@
+# --------------------------------------------------------------------------------
+
+cmake_minimum_required(VERSION 2.8)
+
+# --------------------------------------------------------------------------------
+
+project(OpenVDB)
+
+# --------------------------------------------------------------------------------
+
+set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
+
+# --------------------------------------------------------------------------------
+
+set(CMAKE_BUILD_TYPE_INIT "Release")
+
+# --------------------------------------------------------------------------------
+# Options
+
+option(WITH_BLOSC "Enable Blosc support for compression" OFF)
+option(WITH_LOGC4PLUS "Enable logging" OFF)
+option(WITH_OPENVDB_2_ABI "Enable building the library to be compability with the OpenVDB 2 ABI" OFF)
+option(WITH_PRINTER "Enable building the OpenVDB print executable" OFF)
+option(WITH_PYTHON "Enable building the OpenVDB python API" OFF)
+option(WITH_RENDERER "Enable building the OpenVDB render executable" OFF)
+option(WITH_UNITTEST "Enable building the unit tests" OFF)
+option(WITH_VIEWER "Enable building the OpenVDB viewer executable" OFF)
+
+# --------------------------------------------------------------------------------
+# Find packages
+#set(BOOST_LIBRARIES boost_iostreams boost_system boost_thread)
+
+find_package(IlmBase)
+find_package(OpenEXR)
+find_package(TBB)
+find_package(Boost)
+
+if(WITH_BLOSC)
+ find_package(Blosc)
+
+ if(NOT BLOSC_FOUND)
+ set(WITH_BLOSC OFF)
+ endif()
+endif()
+
+# todo
+if(WITH_VIEWER)
+ set(GLFW_INCLUDE_DIRS ${GLFW_INCLUDE_PATH})
+ set(GLFW_LIBRARY_DIRS ${GLFW_LIBRARY_PATH})
+endif()
+
+if(WITH_LOGC4PLUS)
+ find_package(LogC4Plus)
+
+ if(NOT LOGC4PLUS_FOUND)
+ set(WITH_LOGC4PLUS OFF)
+ endif()
+endif()
+
+# todo
+if(WITH_PYTHON)
+ set(PYTHON_INCLUDE_DIRS ${PYTHON_INCLUDE_PATH})
+ set(PYTHON_LIBRARY_DIRS ${PYTHON_LIBRARY_PATH})
+endif()
+
+if(WITH_UNITTEST)
+ find_package(CppUnit)
+
+ if(NOT CPPUNIT_FOUND)
+ set(WITH_UNITTEST OFF)
+ endif()
+endif()
+
+# --------------------------------------------------------------------------------
+
+message (STATUS "BOOST_ROOT ${BOOST_ROOT}")
+message (STATUS "Boost found ${Boost_FOUND} ")
+message (STATUS "Boost version ${Boost_VERSION}")
+message (STATUS "Boost include dirs ${Boost_INCLUDE_DIRS}")
+message (STATUS "Boost library dirs ${Boost_LIBRARY_DIRS}")
+message (STATUS "Boost libraries ${Boost_LIBRARIES}")
+
+message (STATUS "ILMBase found ${ILMBASE_FOUND} ")
+message (STATUS "ILMBase include dir ${ILMBASE_INCLUDE_DIR}")
+message (STATUS "ILMBase libraries ${ILMBASE_LIBRARIES}")
+
+message (STATUS "TBB found ${TBB_FOUND} ")
+message (STATUS "TBB include dir ${TBB_INCLUDE_DIR}")
+message (STATUS "TBB libraries ${TBB_LIBRARIES}")
+
+if(MSVC)
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj" )
+ set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /bigobj" )
+endif()
+
+set(OPENVDB_LIBRARIES ${BLOSC_LIBRARIES} ${BOOST_LIBRARIES} ${OPENEXR_LIBRARIES} ${ILMBASE_LIBRARIES} ${TBB_LIBRARIES} ${ZLIB_LIBRARY} )
+
+include_directories(. ${CMAKE_CURRENT_SOURCE_DIR}/../ ${Boost_INCLUDE_DIRS} ${ILMBASE_INCLUDE_DIR} ${OPENEXR_INCLUDE_DIR} ${TBB_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR})
+link_directories(${Boost_LIBRARY_DIRS} ${OPENEXR_LIBRARY_DIRS} ${TBB_INCLUDE_DIRS})
+add_definitions(-DNOMINMAX -D__TBB_NO_IMPLICIT_LINKAGE -DOPENVDB_STATICLIB -DOPENVDB_OPENEXR_STATICLIB)
+
+if(WITH_BLOSC)
+ add_definitions(-DOPENVDB_USE_BLOSC)
+ include_directories(${BLOSC_INCLUDE_DIRS})
+ link_directories(${BLOSC_LIBRARY_DIRS})
+endif()
+
+if(WITH_LOGC4PLUS)
+ add_definitions(-DOPENVDB_USE_LOG4CPLUS)
+ include_directories(${LOG4CPLUS_INCLUDE_DIRS})
+ link_directories(${LOG4CPLUS_LIBRARY_DIRS})
+endif()
+
+if(WITH_OPENVDB_2_ABI)
+ add_definitions(-DOPENVDB_2_ABI_COMPATIBLE)
+endif()
+
+# todo
+if(WITH_OPENVDB_USE_GLFW_3)
+ add_definitions(-DOPENVDB_USE_GLFW_3)
+endif()
+
+if(WITH_UNITTEST)
+ include_directories(${CPPUNIT_INCLUDE_DIRS})
+ link_directories(${CPPUNIT_LIBRARY_DIRS})
+endif()
+
+# --------------------------------------------------------------------------------
+
+set(SRC_FILES
+ openvdb/openvdb.cc
+ openvdb/io/Compression.cc
+ openvdb/io/File.cc
+ openvdb/io/Queue.cc
+ openvdb/io/Stream.cc
+ openvdb/io/TempFile.cc
+ openvdb/io/GridDescriptor.cc
+ openvdb/io/Archive.cc
+ openvdb/metadata/MetaMap.cc
+ openvdb/metadata/Metadata.cc
+ openvdb/math/Maps.cc
+ openvdb/math/Transform.cc
+ openvdb/math/QuantizedUnitVec.cc
+ openvdb/math/Proximity.cc
+ openvdb/Grid.cc
+ openvdb/util/Formats.cc
+ openvdb/util/Util.cc
+)
+
+set(HEADER_FILES
+ openvdb/openvdb.h
+ openvdb/version.h
+ openvdb/PlatformConfig.h
+ openvdb/Metadata.h
+ openvdb/Exceptions.h
+ openvdb/Grid.h
+ openvdb/Types.h
+ openvdb/Platform.h
+ openvdb/tree/ValueAccessor.h
+ openvdb/tree/NodeUnion.h
+ openvdb/tree/Tree.h
+ openvdb/tree/Iterator.h
+ openvdb/tree/LeafNodeBool.h
+ openvdb/tree/TreeIterator.h
+ openvdb/tree/LeafNode.h
+ openvdb/tree/NodeManager.h
+ openvdb/tree/LeafManager.h
+ openvdb/tree/InternalNode.h
+ openvdb/tree/RootNode.h
+ openvdb/tools/PointScatter.h
+ openvdb/tools/VolumeAdvect.h
+ openvdb/tools/LevelSetTracker.h
+ openvdb/tools/Composite.h
+ openvdb/tools/Morphology.h
+ openvdb/tools/ValueTransformer.h
+ openvdb/tools/ChangeBackground.h
+ openvdb/tools/GridTransformer.h
+ openvdb/tools/Prune.h
+ openvdb/tools/LevelSetUtil.h
+ openvdb/tools/VolumeToSpheres.h
+ openvdb/tools/LevelSetAdvect.h
+ openvdb/tools/Statistics.h
+ openvdb/tools/LevelSetMeasure.h
+ openvdb/tools/VectorTransformer.h
+ openvdb/tools/RayIntersector.h
+ openvdb/tools/PointPartitioner.h
+ openvdb/tools/Interpolation.h
+ openvdb/tools/VelocityFields.h
+ openvdb/tools/PointIndexGrid.h
+ openvdb/tools/LevelSetRebuild.h
+ openvdb/tools/Clip.h
+ openvdb/tools/SignedFloodFill.h
+ openvdb/tools/MeshToVolume.h
+ openvdb/tools/Dense.h
+ openvdb/tools/Filter.h
+ openvdb/tools/RayTracer.h
+ openvdb/tools/Diagnostics.h
+ openvdb/tools/VolumeToMesh.h
+ openvdb/tools/PoissonSolver.h
+ openvdb/tools/LevelSetFracture.h
+ openvdb/tools/GridOperators.h
+ openvdb/tools/DenseSparseTools.h
+ openvdb/tools/ParticlesToLevelSet.h
+ openvdb/tools/LevelSetSphere.h
+ openvdb/tools/LevelSetMorph.h
+ openvdb/tools/LevelSetFilter.h
+ openvdb/tools/PointAdvect.h
+ openvdb/io/Queue.h
+ openvdb/io/TempFile.h
+ openvdb/io/Stream.h
+ openvdb/io/GridDescriptor.h
+ openvdb/io/Archive.h
+ openvdb/io/io.h
+ openvdb/io/Compression.h
+ openvdb/io/File.h
+ openvdb/metadata/StringMetadata.h
+ openvdb/metadata/MetaMap.h
+ openvdb/metadata/Metadata.h
+ openvdb/math/DDA.h
+ openvdb/math/Vec2.h
+ openvdb/math/FiniteDifference.h
+ openvdb/math/Stencils.h
+ openvdb/math/BBox.h
+ openvdb/math/Mat3.h
+ openvdb/math/Mat.h
+ openvdb/math/Proximity.h
+ openvdb/math/Ray.h
+ openvdb/math/ConjGradient.h
+ openvdb/math/Quat.h
+ openvdb/math/Vec3.h
+ openvdb/math/Vec4.h
+ openvdb/math/QuantizedUnitVec.h
+ openvdb/math/Coord.h
+ openvdb/math/Operators.h
+ openvdb/math/Stats.h
+ openvdb/math/Math.h
+ openvdb/math/Tuple.h
+ openvdb/math/LegacyFrustum.h
+ openvdb/math/Mat4.h
+ openvdb/math/Maps.h
+ openvdb/math/Transform.h
+ openvdb/util/PagedArray.h
+ openvdb/util/CpuTimer.h
+ openvdb/util/Formats.h
+ openvdb/util/NullInterrupter.h
+ openvdb/util/Util.h
+ openvdb/util/Name.h
+ openvdb/util/MapsUtil.h
+ openvdb/util/NodeMasks.h
+ openvdb/util/logging.h
+)
+
+add_library(openvdb STATIC ${SRC_FILES} ${HEADER_FILES})
+
+# --------------------------------------------------------------------------------
+
+target_link_libraries(openvdb ${OPENVDB_LIBRARIES})
+
+set(OPENVDB_VERSION_MAJOR 3)
+set(OPENVDB_VERSION_MINOR 1)
+set(OPENVDB_VERSION_PATCH 0)
+set(OPENVDB_VERSION_STRING ${OPENVDB_VERSION_MAJOR}.${OPENVDB_VERSION_MINOR}.${OPENVDB_VERSION_PATCH})
+
+set_target_properties(openvdb PROPERTIES VERSION ${OPENVDB_VERSION_STRING} SOVERSION ${OPENVDB_VERSION_MAJOR})
+
+install(TARGETS openvdb DESTINATION lib)
+
+install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION include COMPONENT Development FILES_MATCHING PATTERN "*.h"
+ PATTERN ".git" EXCLUDE PATTERN "build" EXCLUDE PATTERN "cmake" EXCLUDE)
+
+# --------------------------------------------------------------------------------
+
+if(WITH_PRINTER)
+ set(PRINT_SRC
+ openvdb/cmd/openvdb_print/main.cc
+ )
+
+ add_executable(vdb_print ${PRINT_SRC})
+ target_link_libraries(vdb_print openvdb)
+ install(TARGETS vdb_print RUNTIME DESTINATION bin)
+endif()
+
+if(WITH_RENDER)
+ set(RENDER_SRC
+ openvdb/cmd/openvdb_render/main.cc
+ )
+
+ add_executable(vdb_render ${RENDER_SRC})
+ target_link_libraries(vdb_render openvdb)
+ install(TARGETS vdb_render RUNTIME DESTINATION bin)
+endif()
+
+# todo
+if(WITH_VIEWER)
+ set(VIEWER_SRC
+ openvdb/viewer/Camera.cc
+ openvdb/viewer/ClipBox.cc
+ openvdb/viewer/Font.cc
+ openvdb/viewer/RenderModules.cc
+ openvdb/viewer/Viewer.cc
+
+ openvdb/viewer/Camera.h
+ openvdb/viewer/ClipBox.h
+ openvdb/viewer/Font.h
+ openvdb/viewer/RenderModules.h
+ openvdb/viewer/Viewer.h
+ openvdb/cmd/openvdb_viewer/main.cc
+ )
+
+ include_directories(${GLFW_INCLUDE_DIRS})
+ link_directories(${GLFW_LIBRARY_DIRS})
+
+ add_executable(vdb_viewer ${VIEWER_SRC})
+ target_link_libraries(vdb_viewer openvdb)
+ install(TARGETS vdb_viewer RUNTIME DESTINATION bin)
+endif()
+
+# todo
+if(WITH_PYTHON)
+# add_library(pyopenvdb SHARED )
+endif()
+
+set(UNITTEST_SRC
+ openvdb/unittest/main.cc
+ openvdb/unittest/TestBBox.cc
+ openvdb/unittest/TestConjGradient.cc
+ openvdb/unittest/TestCoord.cc
+ openvdb/unittest/TestCpt.cc
+ openvdb/unittest/TestCurl.cc
+ openvdb/unittest/TestDense.cc
+ openvdb/unittest/TestDenseSparseTools.cc
+ openvdb/unittest/TestDiagnostics.cc
+ openvdb/unittest/TestDivergence.cc
+ openvdb/unittest/TestDoubleMetadata.cc
+ openvdb/unittest/TestExceptions.cc
+ openvdb/unittest/TestFile.cc
+ openvdb/unittest/TestFloatMetadata.cc
+ openvdb/unittest/TestGradient.cc
+ openvdb/unittest/TestGrid.cc
+ openvdb/unittest/TestGridBbox.cc
+ openvdb/unittest/TestGridDescriptor.cc
+ openvdb/unittest/TestGridIO.cc
+ openvdb/unittest/TestGridTransformer.cc
+ openvdb/unittest/TestInit.cc
+ openvdb/unittest/TestInt32Metadata.cc
+ openvdb/unittest/TestInt64Metadata.cc
+ openvdb/unittest/TestInternalOrigin.cc
+ openvdb/unittest/TestLaplacian.cc
+ openvdb/unittest/TestLeaf.cc
+ openvdb/unittest/TestLeafBool.cc
+ openvdb/unittest/TestLeafIO.cc
+ openvdb/unittest/TestLeafOrigin.cc
+ openvdb/unittest/TestLevelSetRayIntersector.cc
+ openvdb/unittest/TestLevelSetUtil.cc
+ openvdb/unittest/TestLinearInterp.cc
+ openvdb/unittest/TestMaps.cc
+ openvdb/unittest/TestMat4Metadata.cc
+ openvdb/unittest/TestMath.cc
+ openvdb/unittest/TestMeanCurvature.cc
+ openvdb/unittest/TestMeshToVolume.cc
+ openvdb/unittest/TestMetadata.cc
+ openvdb/unittest/TestMetadataIO.cc
+ openvdb/unittest/TestMetaMap.cc
+ openvdb/unittest/TestName.cc
+ openvdb/unittest/TestNodeIterator.cc
+ openvdb/unittest/TestNodeMask.cc
+ openvdb/unittest/TestParticlesToLevelSet.cc
+ openvdb/unittest/TestPointIndexGrid.cc
+ openvdb/unittest/TestPointPartitioner.cc
+ openvdb/unittest/TestPoissonSolver.cc
+ openvdb/unittest/TestPrePostAPI.cc
+ openvdb/unittest/TestQuadraticInterp.cc
+ openvdb/unittest/TestQuantizedUnitVec.cc
+ openvdb/unittest/TestQuat.cc
+ openvdb/unittest/TestRay.cc
+ openvdb/unittest/TestStats.cc
+ openvdb/unittest/TestStream.cc
+ openvdb/unittest/TestStringMetadata.cc
+ openvdb/unittest/TestTools.cc
+ openvdb/unittest/TestTransform.cc
+ openvdb/unittest/TestTree.cc
+ openvdb/unittest/TestTreeCombine.cc
+ openvdb/unittest/TestTreeGetSetValues.cc
+ openvdb/unittest/TestTreeIterators.cc
+ openvdb/unittest/TestTreeVisitor.cc
+ openvdb/unittest/TestUtil.cc
+ openvdb/unittest/TestValueAccessor.cc
+ openvdb/unittest/TestVec2Metadata.cc
+ openvdb/unittest/TestVec3Metadata.cc
+ openvdb/unittest/TestVolumeRayIntersector.cc
+ openvdb/unittest/TestVolumeToMesh.cc
+)
+
+# todo
+if(WITH_UNITTEST)
+ add_executable(test ${UNITTEST_SRC} ${HEADER_FILES})
+ target_link_libraries(test openvdb ${CPPUNIT_LIBRARIES})
+endif()
diff --git a/build_files/build_environment/patches/cmakelists_tbb.txt b/build_files/build_environment/patches/cmakelists_tbb.txt
new file mode 100644
index 00000000000..1be9ca25f6a
--- /dev/null
+++ b/build_files/build_environment/patches/cmakelists_tbb.txt
@@ -0,0 +1,196 @@
+cmake_minimum_required (VERSION 2.8)
+project(tbb CXX)
+
+if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
+ message(STATUS "Setting build type to 'Release' as none was specified.")
+ set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
+ set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
+ "MinSizeRel" "RelWithDebInfo")
+endif()
+
+include_directories(include src src/rml/include )
+
+option(TBB_BUILD_SHARED "Build TBB shared library" ON)
+option(TBB_BUILD_STATIC "Build TBB static library" ON)
+option(TBB_BUILD_TBBMALLOC "Build TBB malloc library" ON)
+option(TBB_BUILD_TBBMALLOC_PROXY "Build TBB malloc proxy library" ON)
+
+if(APPLE)
+ set(CMAKE_MACOSX_RPATH ON)
+endif()
+
+file(GLOB tbb_src "${CMAKE_CURRENT_SOURCE_DIR}/src/tbb/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/old/*.cpp")
+list(APPEND tbb_src ${CMAKE_CURRENT_SOURCE_DIR}/src/rml/client/rml_tbb.cpp)
+file(GLOB to_remove "${CMAKE_CURRENT_SOURCE_DIR}/src/old/test*.cpp")
+list(REMOVE_ITEM tbb_src ${to_remove})
+
+set(tbbmalloc_static_src
+ src/tbbmalloc/backend.cpp
+ src/tbbmalloc/large_objects.cpp
+ src/tbbmalloc/backref.cpp
+ src/tbbmalloc/tbbmalloc.cpp
+ src/tbbmalloc/frontend.cpp
+ src/tbb/itt_notify.cpp)
+
+set(tbbmalloc_src ${tbbmalloc_static_src})
+
+set(tbbmalloc_proxy_src
+ src/tbbmalloc/proxy.cpp
+ src/tbbmalloc/tbb_function_replacement.cpp)
+
+if (NOT APPLE)
+ add_definitions(-DDO_ITT_NOTIFY)
+else()
+ # Disable annoying "has no symbols" warnings
+ set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
+ set(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
+endif()
+
+if (UNIX)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -DUSE_PTHREAD")
+ if(NOT CMAKE_CXX_FLAGS MATCHES "-mno-rtm")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mrtm")
+ endif()
+ if (APPLE)
+ set(ARCH_PREFIX "mac")
+ else()
+ set(ARCH_PREFIX "lin")
+ endif()
+ if (CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(ARCH_PREFIX "${ARCH_PREFIX}64")
+ else()
+ set(ARCH_PREFIX "${ARCH_PREFIX}32")
+ endif()
+ set(ENABLE_RTTI "-frtti -fexceptions ")
+ set(DISABLE_RTTI "-fno-rtti -fno-exceptions ")
+elseif(WIN32)
+ cmake_minimum_required (VERSION 3.1)
+ enable_language(ASM_MASM)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GS- /Zc:wchar_t /Zc:forScope /DUSE_WINTHREAD")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CRT_SECURE_NO_DEPRECATE /D_WIN32_WINNT=0x0600 /volatile:iso")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267 /wd4800 /wd4146 /wd4244 /wd4018")
+
+ if (CMAKE_SIZEOF_VOID_P EQUAL 8)
+ list(APPEND tbb_src src/tbb/intel64-masm/atomic_support.asm
+ src/tbb/intel64-masm/itsx.asm src/tbb/intel64-masm/intel64_misc.asm)
+ list(APPEND tbbmalloc_src src/tbb/intel64-masm/atomic_support.asm)
+ set(CMAKE_ASM_MASM_FLAGS "/DEM64T=1")
+ set(ARCH_PREFIX "win64")
+ else()
+ list(APPEND tbb_src src/tbb/ia32-masm/atomic_support.asm
+ src/tbb/ia32-masm/itsx.asm src/tbb/ia32-masm/lock_byte.asm)
+ list(APPEND tbbmalloc_src src/tbb/ia32-masm/atomic_support.asm)
+ set(ARCH_PREFIX "win32")
+ endif()
+ set(ENABLE_RTTI "/EHsc /GR ")
+ set(DISABLE_RTTI "/EHs- /GR- ")
+endif()
+
+# Linker export definitions
+if (WIN32)
+ add_custom_command(OUTPUT tbb.def
+ COMMAND ${CMAKE_CXX_COMPILER} /TC /EP ${CMAKE_CURRENT_SOURCE_DIR}/src/tbb/${ARCH_PREFIX}-tbb-export.def -I ${CMAKE_CURRENT_SOURCE_DIR}/include > tbb.def
+ MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/src/tbb/${ARCH_PREFIX}-tbb-export.def
+ COMMENT "Preprocessing tbb.def"
+ )
+
+ add_custom_command(OUTPUT tbbmalloc.def
+ COMMAND ${CMAKE_CXX_COMPILER} /TC /EP ${CMAKE_CURRENT_SOURCE_DIR}/src/tbbmalloc/${ARCH_PREFIX}-tbbmalloc-export.def -I ${CMAKE_CURRENT_SOURCE_DIR}/include > tbbmalloc.def
+ MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/src/tbbmalloc/${ARCH_PREFIX}-tbbmalloc-export.def
+ COMMENT "Preprocessing tbbmalloc.def"
+ )
+else()
+ add_custom_command(OUTPUT tbb.def
+ COMMAND ${CMAKE_CXX_COMPILER} -xc++ -E ${CMAKE_CURRENT_SOURCE_DIR}/src/tbb/${ARCH_PREFIX}-tbb-export.def -I ${CMAKE_CURRENT_SOURCE_DIR}/include -o tbb.def
+ MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/src/tbb/${ARCH_PREFIX}-tbb-export.def
+ COMMENT "Preprocessing tbb.def"
+ )
+
+ add_custom_command(OUTPUT tbbmalloc.def
+ COMMAND ${CMAKE_CXX_COMPILER} -xc++ -E ${CMAKE_CURRENT_SOURCE_DIR}/src/tbbmalloc/${ARCH_PREFIX}-tbbmalloc-export.def -I ${CMAKE_CURRENT_SOURCE_DIR}/include -o tbbmalloc.def
+ MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/src/tbbmalloc/${ARCH_PREFIX}-tbbmalloc-export.def
+ COMMENT "Preprocessing tbbmalloc.def"
+ )
+endif()
+
+add_custom_target(tbb_def_files DEPENDS tbb.def tbbmalloc.def)
+
+# TBB library
+if (TBB_BUILD_STATIC)
+ add_library(tbb_static STATIC ${tbb_src})
+ set_property(TARGET tbb_static APPEND PROPERTY COMPILE_DEFINITIONS "__TBB_BUILD=1")
+ set_property(TARGET tbb_static APPEND PROPERTY COMPILE_DEFINITIONS "__TBB_SOURCE_DIRECTLY_INCLUDED=1")
+ set_property(TARGET tbb_static APPEND_STRING PROPERTY COMPILE_FLAGS ${ENABLE_RTTI})
+ install(TARGETS tbb_static ARCHIVE DESTINATION lib)
+endif()
+
+if (TBB_BUILD_SHARED)
+ add_library(tbb SHARED ${tbb_src})
+ set_property(TARGET tbb APPEND PROPERTY COMPILE_DEFINITIONS "__TBB_BUILD=1")
+ set_property(TARGET tbb APPEND_STRING PROPERTY COMPILE_FLAGS ${ENABLE_RTTI})
+ add_dependencies(tbb tbb_def_files)
+ if (APPLE)
+ set_property(TARGET tbb APPEND PROPERTY LINK_FLAGS "-Wl,-exported_symbols_list,${CMAKE_CURRENT_BINARY_DIR}/tbb.def")
+ elseif(UNIX)
+ set_property(TARGET tbb APPEND PROPERTY LINK_FLAGS "-Wl,-version-script,${CMAKE_CURRENT_BINARY_DIR}/tbb.def")
+ elseif(WIN32)
+ set_property(TARGET tbb APPEND PROPERTY LINK_FLAGS "/DEF:${CMAKE_CURRENT_BINARY_DIR}/tbb.def")
+ endif()
+ install(TARGETS tbb DESTINATION lib)
+endif()
+
+if(CMAKE_COMPILER_IS_GNUCC)
+ # Quench a warning on GCC
+ set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/src/tbb/governor.cpp COMPILE_FLAGS "-Wno-missing-field-initializers ")
+elseif(MSVC)
+ # Quench a warning on MSVC
+ set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/src/tbb/scheduler.cpp COMPILE_FLAGS "/wd4458 ")
+endif()
+
+if(TBB_BUILD_TBBMALLOC)
+ # TBB malloc library
+ if (TBB_BUILD_STATIC)
+ add_library(tbbmalloc_static STATIC ${tbbmalloc_static_src})
+ set_property(TARGET tbbmalloc_static APPEND PROPERTY COMPILE_DEFINITIONS "__TBBMALLOC_BUILD=1")
+ set_property(TARGET tbbmalloc_static APPEND_STRING PROPERTY COMPILE_FLAGS ${DISABLE_RTTI})
+ install(TARGETS tbbmalloc_static ARCHIVE DESTINATION lib)
+ endif()
+
+ if (TBB_BUILD_SHARED)
+ add_library(tbbmalloc SHARED ${tbbmalloc_src})
+ set_property(TARGET tbbmalloc APPEND PROPERTY COMPILE_DEFINITIONS "__TBBMALLOC_BUILD=1")
+ set_property(TARGET tbbmalloc APPEND_STRING PROPERTY COMPILE_FLAGS ${DISABLE_RTTI})
+ add_dependencies(tbbmalloc tbb_def_files)
+ if (APPLE)
+ set_property(TARGET tbbmalloc APPEND PROPERTY LINK_FLAGS "-Wl,-exported_symbols_list,${CMAKE_CURRENT_BINARY_DIR}/tbbmalloc.def")
+ elseif(UNIX)
+ set_property(TARGET tbbmalloc APPEND PROPERTY LINK_FLAGS "-Wl,-version-script,${CMAKE_CURRENT_BINARY_DIR}/tbbmalloc.def")
+ elseif(WIN32)
+ set_property(TARGET tbbmalloc APPEND PROPERTY LINK_FLAGS "/DEF:${CMAKE_CURRENT_BINARY_DIR}/tbbmalloc.def")
+ endif()
+ install(TARGETS tbbmalloc DESTINATION lib)
+ endif()
+endif()
+
+if(TBB_BUILD_TBBMALLOC_PROXY)
+ # TBB malloc proxy library
+ if (TBB_BUILD_STATIC)
+ add_library(tbbmalloc_proxy_static STATIC ${tbbmalloc_proxy_src})
+ set_property(TARGET tbbmalloc_proxy_static APPEND PROPERTY COMPILE_DEFINITIONS "__TBBMALLOC_BUILD=1")
+ set_property(TARGET tbbmalloc_proxy_static APPEND_STRING PROPERTY COMPILE_FLAGS ${DISABLE_RTTI})
+ link_libraries(tbbmalloc_proxy_static tbbmalloc)
+ install(TARGETS tbbmalloc_proxy_static ARCHIVE DESTINATION lib)
+ endif()
+
+ if (TBB_BUILD_SHARED)
+ add_library(tbbmalloc_proxy SHARED ${tbbmalloc_proxy_src})
+ set_property(TARGET tbbmalloc_proxy APPEND PROPERTY COMPILE_DEFINITIONS "__TBBMALLOC_BUILD=1")
+ set_property(TARGET tbbmalloc_proxy APPEND_STRING PROPERTY COMPILE_FLAGS ${DISABLE_RTTI})
+ link_libraries(tbbmalloc_proxy tbbmalloc)
+ install(TARGETS tbbmalloc_proxy DESTINATION lib)
+ endif()
+endif()
+
+install(DIRECTORY include/tbb DESTINATION include)
diff --git a/build_files/build_environment/patches/cuew.diff b/build_files/build_environment/patches/cuew.diff
new file mode 100644
index 00000000000..0363034cd93
--- /dev/null
+++ b/build_files/build_environment/patches/cuew.diff
@@ -0,0 +1,26 @@
+--- CmakeLists.txt.orig 2015-12-31 03:46:41 -0700
++++ CMakeLists.txt 2016-04-01 13:28:33 -0600
+@@ -22,3 +22,10 @@
+
+ add_executable(testcuew cuewTest/cuewTest.c include/cuew.h)
+ target_link_libraries(testcuew cuew ${CMAKE_DL_LIBS})
++
++install(TARGETS cuew
++ LIBRARY DESTINATION lib COMPONENT libraries
++ ARCHIVE DESTINATION lib/static COMPONENT libraries)
++
++INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/cuew.h
++ DESTINATION include/)
+\ No newline at end of file
+--- src/cuew.c 2016-04-01 13:41:43 -0600
++++ src/cuew.c 2016-04-01 13:41:11 -0600
+@@ -15,7 +15,9 @@
+ */
+
+ #ifdef _MSC_VER
++#if _MSC_VER < 1900
+ # define snprintf _snprintf
++#endif
+ # define popen _popen
+ # define pclose _pclose
+ # define _CRT_SECURE_NO_WARNINGS
diff --git a/build_files/build_environment/patches/distutildebugflags.diff b/build_files/build_environment/patches/distutildebugflags.diff
new file mode 100644
index 00000000000..3d6b688bc53
--- /dev/null
+++ b/build_files/build_environment/patches/distutildebugflags.diff
@@ -0,0 +1,11 @@
+--- _msvccompiler.py.orig 2017-01-17 00:57:48 -0700
++++ _msvccompiler.py 2017-05-20 09:47:26 -0600
+@@ -237,7 +237,7 @@
+ ldflags.extend(('/nodefaultlib:libucrt.lib', 'ucrt.lib'))
+
+ ldflags_debug = [
+- '/nologo', '/INCREMENTAL:NO', '/LTCG', '/DEBUG:FULL'
++ '/nologo', '/INCREMENTAL:NO', '/LTCG'
+ ]
+
+ self.ldflags_exe = [*ldflags, '/MANIFEST:EMBED,ID=1']
diff --git a/build_files/build_environment/patches/ffmpeg.diff b/build_files/build_environment/patches/ffmpeg.diff
new file mode 100644
index 00000000000..75fc6490031
--- /dev/null
+++ b/build_files/build_environment/patches/ffmpeg.diff
@@ -0,0 +1,32 @@
+--- libavutil/common.h 2016-02-14 19:29:42 -0700
++++ libavutil/common.h 2016-03-30 09:50:29 -0600
+@@ -99,6 +99,11 @@
+ #define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0)
+ #define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0]))
+
++//msvc helper
++#ifdef _MSC_VER
++#define inline __inline
++#endif
++
+ /* misc math functions */
+
+ #ifdef HAVE_AV_CONFIG_H
+--- configure 2016-11-26 03:12:05.000000000 +0100
++++ configure 2017-04-05 03:24:35.000000000 +0200
+@@ -1899,7 +1899,6 @@
+ access
+ aligned_malloc
+ arc4random
+- clock_gettime
+ closesocket
+ CommandLineToArgvW
+ CoTaskMemFree
+@@ -5494,7 +5493,6 @@
+
+ check_func access
+ check_func_headers stdlib.h arc4random
+-check_func_headers time.h clock_gettime || { check_func_headers time.h clock_gettime -lrt && add_extralibs -lrt && LIBRT="-lrt"; }
+ check_func fcntl
+ check_func fork
+ check_func gethrtime
diff --git a/build_files/build_environment/patches/fftw3.diff b/build_files/build_environment/patches/fftw3.diff
new file mode 100644
index 00000000000..48d88414045
--- /dev/null
+++ b/build_files/build_environment/patches/fftw3.diff
@@ -0,0 +1,25 @@
+--- config.h.in 2014-03-04 11:44:58 -0700
++++ config.h.in 2016-03-30 11:42:49 -0600
+@@ -142,9 +142,6 @@
+ /* Define to 1 if you have the `gethrtime' function. */
+ #undef HAVE_GETHRTIME
+
+-/* Define to 1 if you have the `gettimeofday' function. */
+-#undef HAVE_GETTIMEOFDAY
+-
+ /* Define to 1 if hrtime_t is defined in <sys/time.h> */
+ #undef HAVE_HRTIME_T
+
+--- kernel/assert.c 2014-03-04 11:41:03 -0700
++++ kernel/assert.c 2016-04-01 09:41:05 -0600
+@@ -24,8 +24,10 @@
+
+ void X(assertion_failed)(const char *s, int line, const char *file)
+ {
++#if 0
+ fflush(stdout);
+ fprintf(stderr, "fftw: %s:%d: assertion failed: %s\n", file, line, s);
++#endif
+ #ifdef HAVE_ABORT
+ abort();
+ #else
diff --git a/build_files/build_environment/patches/hdf5.diff b/build_files/build_environment/patches/hdf5.diff
new file mode 100644
index 00000000000..cb84625810d
--- /dev/null
+++ b/build_files/build_environment/patches/hdf5.diff
@@ -0,0 +1,11 @@
+--- UserMacros.cmake
++++ UserMacros.cmake
+@@ -16,6 +16,8 @@
+ if (BUILD_USER_DEFINED_LIBS)
+ MACRO_USER_DEFINED_LIBS ()
+ endif (BUILD_USER_DEFINED_LIBS)
++
++include(Config/cmake/usermacros/windows_mt.cmake)
+ #-----------------------------------------------------------------------------
+ #------------------- E X A M P L E E N D -----------------------------------
+ #-----------------------------------------------------------------------------
diff --git a/build_files/build_environment/patches/hidapi.diff b/build_files/build_environment/patches/hidapi.diff
new file mode 100644
index 00000000000..720a8ae5ae9
--- /dev/null
+++ b/build_files/build_environment/patches/hidapi.diff
@@ -0,0 +1,15 @@
+--- hidapi/hidapi.h 2011-10-25 20:58:16 -0600
++++ hidapi/hidapi.h 2016-11-01 12:05:58 -0600
+@@ -30,7 +30,11 @@
+ #include <wchar.h>
+
+ #ifdef _WIN32
+- #define HID_API_EXPORT __declspec(dllexport)
++ #ifdef HID_API_STATIC
++ #define HID_API_EXPORT
++ #else
++ #define HID_API_EXPORT __declspec(dllexport)
++ #endif
+ #define HID_API_CALL
+ #else
+ #define HID_API_EXPORT /**< API export macro */
diff --git a/build_files/build_environment/install_deps_patches/llvm.patch b/build_files/build_environment/patches/install_deps_llvm.diff
index 968f011e57c..968f011e57c 100644
--- a/build_files/build_environment/install_deps_patches/llvm.patch
+++ b/build_files/build_environment/patches/install_deps_llvm.diff
diff --git a/build_files/build_environment/install_deps_patches/osl.patch b/build_files/build_environment/patches/install_deps_osl.diff
index 3b52403f740..3b52403f740 100644
--- a/build_files/build_environment/install_deps_patches/osl.patch
+++ b/build_files/build_environment/patches/install_deps_osl.diff
diff --git a/build_files/build_environment/patches/libfaad.diff b/build_files/build_environment/patches/libfaad.diff
new file mode 100644
index 00000000000..37605b29cd9
--- /dev/null
+++ b/build_files/build_environment/patches/libfaad.diff
@@ -0,0 +1,10 @@
+--- frontend/main.c 2008-09-22 11:55:09 -0600
++++ frontend/main.c 2016-04-06 15:20:36 -0600
+@@ -31,7 +31,6 @@
+ #ifdef _WIN32
+ #define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+-#define off_t __int64
+ #else
+ #include <time.h>
+ #endif
diff --git a/build_files/build_environment/patches/llvm-alloca-fix.diff b/build_files/build_environment/patches/llvm-alloca-fix.diff
new file mode 100644
index 00000000000..5394a472167
--- /dev/null
+++ b/build_files/build_environment/patches/llvm-alloca-fix.diff
@@ -0,0 +1,111 @@
+Index: lib/Target/X86/X86ISelLowering.cpp
+===================================================================
+--- lib/Target/X86/X86ISelLowering.cpp 2014-04-11 23:04:44.000000000 +0200
++++ lib/Target/X86/X86ISelLowering.cpp (working copy)
+@@ -15493,12 +15493,36 @@
+ // non-trivial part is impdef of ESP.
+
+ if (Subtarget->isTargetWin64()) {
++ const char *StackProbeSymbol =
++ Subtarget->isTargetCygMing() ? "___chkstk" : "__chkstk";
++
++ MachineInstrBuilder MIB;
++
++ if (getTargetMachine().getCodeModel() == CodeModel::Large) {
++ // For large code model we need to do indirect call to __chkstk.
++
++ // R11 will be used to contain the address of __chkstk.
++ // R11 is a volotiale register and assumed to be destoyed by the callee,
++ // so there is no need to save and restore it.
++ BuildMI(*BB, MI, DL, TII->get(X86::MOV64ri), X86::R11)
++ .addExternalSymbol(StackProbeSymbol);
++ // Create a call to __chkstk function which address contained in R11.
++ MIB = BuildMI(*BB, MI, DL, TII->get(X86::CALL64r))
++ .addReg(X86::R11, RegState::Kill);
++
++ } else {
++
++ // For non-large code model we can do direct call to __chkstk.
++
++ MIB = BuildMI(*BB, MI, DL, TII->get(X86::W64ALLOCA))
++ .addExternalSymbol(StackProbeSymbol);
++ }
++
+ if (Subtarget->isTargetCygMing()) {
+ // ___chkstk(Mingw64):
+ // Clobbers R10, R11, RAX and EFLAGS.
+ // Updates RSP.
+- BuildMI(*BB, MI, DL, TII->get(X86::W64ALLOCA))
+- .addExternalSymbol("___chkstk")
++ MIB
+ .addReg(X86::RAX, RegState::Implicit)
+ .addReg(X86::RSP, RegState::Implicit)
+ .addReg(X86::RAX, RegState::Define | RegState::Implicit)
+@@ -15507,8 +15531,7 @@
+ } else {
+ // __chkstk(MSVCRT): does not update stack pointer.
+ // Clobbers R10, R11 and EFLAGS.
+- BuildMI(*BB, MI, DL, TII->get(X86::W64ALLOCA))
+- .addExternalSymbol("__chkstk")
++ MIB
+ .addReg(X86::RAX, RegState::Implicit)
+ .addReg(X86::EFLAGS, RegState::Define | RegState::Implicit);
+ // RAX has the offset to be subtracted from RSP.
+Index: lib/Target/X86/X86FrameLowering.cpp
+===================================================================
+--- lib/Target/X86/X86FrameLowering.cpp 2013-10-24 01:37:01.000000000 +0200
++++ lib/Target/X86/X86FrameLowering.cpp (working copy)
+@@ -635,25 +635,49 @@
+ .addReg(X86::EAX, RegState::Kill)
+ .setMIFlag(MachineInstr::FrameSetup);
+ }
++
++ MachineInstrBuilder MIB;
+
+ if (Is64Bit) {
++
+ // Handle the 64-bit Windows ABI case where we need to call __chkstk.
+ // Function prologue is responsible for adjusting the stack pointer.
+ BuildMI(MBB, MBBI, DL, TII.get(X86::MOV64ri), X86::RAX)
+ .addImm(NumBytes)
+ .setMIFlag(MachineInstr::FrameSetup);
++
++ if (TM.getCodeModel() == CodeModel::Large) {
++ // For large code model we need to do indirect call to __chkstk.
++
++
++ // R11 will be used to contain the address of __chkstk.
++ // R11 is a volotiale register and assumed to be destoyed by the callee,
++ // so there is no need to save and restore it.
++ BuildMI(MBB, MBBI, DL, TII.get(X86::MOV64ri), X86::R11)
++ .addExternalSymbol(StackProbeSymbol);
++ // Create a call to __chkstk function which address contained in R11.
++ MIB = BuildMI(MBB, MBBI, DL, TII.get(X86::CALL64r))
++ .addReg(X86::R11, RegState::Kill);
++ } else {
++
++ // For non-large code model we can do direct call to __chkstk.
++
++ MIB = BuildMI(MBB, MBBI, DL, TII.get(X86::W64ALLOCA))
++ .addExternalSymbol(StackProbeSymbol);
++ }
+ } else {
+ // Allocate NumBytes-4 bytes on stack in case of isEAXAlive.
+ // We'll also use 4 already allocated bytes for EAX.
+ BuildMI(MBB, MBBI, DL, TII.get(X86::MOV32ri), X86::EAX)
+ .addImm(isEAXAlive ? NumBytes - 4 : NumBytes)
+ .setMIFlag(MachineInstr::FrameSetup);
++
++ MIB = BuildMI(MBB, MBBI, DL, TII.get(X86::CALLpcrel32))
++ .addExternalSymbol(StackProbeSymbol);
+ }
+
+- BuildMI(MBB, MBBI, DL,
+- TII.get(Is64Bit ? X86::W64ALLOCA : X86::CALLpcrel32))
+- .addExternalSymbol(StackProbeSymbol)
+- .addReg(StackPtr, RegState::Define | RegState::Implicit)
++
++ MIB.addReg(StackPtr, RegState::Define | RegState::Implicit)
+ .addReg(X86::EFLAGS, RegState::Define | RegState::Implicit)
+ .setMIFlag(MachineInstr::FrameSetup);
+
diff --git a/build_files/build_environment/patches/ming32sh.cmd b/build_files/build_environment/patches/ming32sh.cmd
new file mode 100644
index 00000000000..3259d9d3714
--- /dev/null
+++ b/build_files/build_environment/patches/ming32sh.cmd
@@ -0,0 +1,7 @@
+@title MinGW-w64 32-bit GCC build environment
+
+@echo Setting up environment for MinGW-w64 GCC 32-bit...
+
+@set PATH=%CD%\bin;%CD%\msys\1.0\bin;%cd%\..\..\perl32\site\bin;%cd%\..\..\perl32\bin;%cd%\..\..\c\bin;%PATH%
+
+
diff --git a/build_files/build_environment/patches/ming64sh.cmd b/build_files/build_environment/patches/ming64sh.cmd
new file mode 100644
index 00000000000..18fea3829f3
--- /dev/null
+++ b/build_files/build_environment/patches/ming64sh.cmd
@@ -0,0 +1,7 @@
+@title MinGW-w64 64-bit GCC build environment
+
+@echo Setting up environment for MinGW-w64 GCC 64-bit...
+
+@set PATH=%CD%\bin;%CD%\msys\1.0\bin;%cd%\..\..\perl\site\bin;%cd%\..\..\perl\bin;%cd%\..\..\c\bin;%PATH%
+
+
diff --git a/build_files/build_environment/patches/numpy.diff b/build_files/build_environment/patches/numpy.diff
new file mode 100644
index 00000000000..c4c57222838
--- /dev/null
+++ b/build_files/build_environment/patches/numpy.diff
@@ -0,0 +1,23 @@
+diff -Naur numpy-1.11.1/numpy/distutils/ccompiler.py numpy-1.11.1/numpy/distutils/ccompiler.py
+--- numpy-1.11.1/numpy/distutils/ccompiler.py 2016-06-25 08:38:34 -0600
++++ numpy-1.11.1/numpy/distutils/ccompiler.py 2016-08-04 12:33:43 -0600
+@@ -29,6 +29,7 @@
+
+ # Using customized CCompiler.spawn.
+ def CCompiler_spawn(self, cmd, display=None):
++ cmd = quote_args(cmd)
+ """
+ Execute a command in a sub-process.
+
+diff -Naur numpy-1.11.1/numpy/distutils/misc_util.py numpy-1.11.1/numpy/distutils/misc_util.py
+--- numpy-1.11.1/numpy/distutils/misc_util.py 2016-06-25 08:38:34 -0600
++++ numpy-1.11.1/numpy/distutils/misc_util.py 2016-08-04 12:34:56 -0600
+@@ -116,7 +116,7 @@
+ args = list(args)
+ for i in range(len(args)):
+ a = args[i]
+- if ' ' in a and a[0] not in '"\'':
++ if ' ' in a and a[0] not in '"\'' and a[len(a)-1] not in '"\'':
+ args[i] = '"%s"' % (a)
+ return args
+
diff --git a/build_files/build_environment/patches/opencollada.diff b/build_files/build_environment/patches/opencollada.diff
new file mode 100644
index 00000000000..0c91b4151fe
--- /dev/null
+++ b/build_files/build_environment/patches/opencollada.diff
@@ -0,0 +1,32 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 3fc9be5..5112ce6 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -254,11 +254,11 @@
+ endif()
+
+ #adding PCRE
+-find_package(PCRE)
++#find_package(PCRE)
+ if (PCRE_FOUND)
+ message(STATUS "SUCCESSFUL: PCRE found")
+ else () # if pcre not found building its local copy from ./Externals
+- if (WIN32 OR APPLE)
++ if (1)
+ message("WARNING: Native PCRE not found, taking PCRE from ./Externals")
+ add_definitions(-DPCRE_STATIC)
+ add_subdirectory(${EXTERNAL_LIBRARIES}/pcre)
+diff --git a/DAEValidator/library/include/no_warning_begin.orig b/DAEValidator/library/include/no_warning_begin
+index 3fc9be5..5112ce6 100644
+--- a/DAEValidator/library/include/no_warning_begin.orig 2017-05-31 16:56:39 -0600
++++ b/DAEValidator/library/include/no_warning_begin 2017-06-07 10:18:45 -0600
+@@ -2,6 +2,9 @@
+ #if defined(_WIN32)
+ # pragma warning(push)
+ # pragma warning(disable:4668)
++# if _MSC_VER >=1900
++# pragma warning(disable:5031)
++# endif
+ # if defined(_MSC_VER) && defined(_DEBUG)
+ # pragma warning(disable:4548)
+ # endif
diff --git a/build_files/build_environment/patches/opencolorio.diff b/build_files/build_environment/patches/opencolorio.diff
new file mode 100644
index 00000000000..4e947d89097
--- /dev/null
+++ b/build_files/build_environment/patches/opencolorio.diff
@@ -0,0 +1,21 @@
+diff -ru ./CMakeLists.txt ./CMakeLists.txt
+--- ./CMakeLists.txt 2014-09-11 21:08:18.000000000 +0200
++++ ./CMakeLists.txt 2016-05-15 17:17:01.000000000 +0200
+@@ -186,7 +186,7 @@
+ PATCH_COMMAND patch -f -p1 < ${CMAKE_SOURCE_DIR}/ext/tinyxml_${TINYXML_VERSION}.patch
+ BINARY_DIR ext/build/tinyxml
+ INSTALL_DIR ext/dist
+- CMAKE_ARGS ${TINYXML_CMAKE_ARGS}
++ CMAKE_ARGS ${TINYXML_CMAKE_ARGS} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT} -DCMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG} -DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE} -DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG} -DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE} -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
+ )
+ if(WIN32)
+ set(TINYXML_STATIC_LIBRARIES ${PROJECT_BINARY_DIR}/ext/dist/lib/tinyxml.lib)
+@@ -254,7 +254,7 @@
+ BINARY_DIR ext/build/yaml-cpp
+ PATCH_COMMAND patch -p1 < ${CMAKE_SOURCE_DIR}/ext/yaml-cpp-${YAML_CPP_VERSION}.patch
+ INSTALL_DIR ext/dist
+- CMAKE_ARGS ${YAML_CPP_CMAKE_ARGS}
++ CMAKE_ARGS ${YAML_CPP_CMAKE_ARGS} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT} -DCMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG} -DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE} -DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG} -DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE} -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
+ )
+ set(YAML_CPP_INCLUDE_DIRS ${PROJECT_BINARY_DIR}/ext/dist/include)
+ set(YAML_CPP_LIBRARY_DIRS ${PROJECT_BINARY_DIR}/ext/dist/lib)
diff --git a/build_files/build_environment/patches/openexr.diff b/build_files/build_environment/patches/openexr.diff
new file mode 100644
index 00000000000..ec18751fe74
--- /dev/null
+++ b/build_files/build_environment/patches/openexr.diff
@@ -0,0 +1,33 @@
+--- IlmImf/CMakeLists.txt 2014-08-10 06:23:56.000000000 +0200
++++ IlmImf/CMakeLists.txt 2017-01-08 04:06:04.931723800 +0100
+@@ -8,8 +8,8 @@
+
+ TARGET_LINK_LIBRARIES ( b44ExpLogTable
+ Half
+- Iex${ILMBASE_LIBSUFFIX}
+ IlmThread${ILMBASE_LIBSUFFIX}
++ Iex${ILMBASE_LIBSUFFIX}
+ ${PTHREAD_LIB}
+ )
+
+@@ -25,8 +25,8 @@
+
+ TARGET_LINK_LIBRARIES ( dwaLookups
+ Half
+- Iex${ILMBASE_LIBSUFFIX}
+ IlmThread${ILMBASE_LIBSUFFIX}
++ Iex${ILMBASE_LIBSUFFIX}
+ ${PTHREAD_LIB}
+ )
+
+@@ -138,9 +138,9 @@
+
+ TARGET_LINK_LIBRARIES ( IlmImf
+ Half
+- Iex${ILMBASE_LIBSUFFIX}
+ Imath${ILMBASE_LIBSUFFIX}
+ IlmThread${ILMBASE_LIBSUFFIX}
++ Iex${ILMBASE_LIBSUFFIX}
+ ${PTHREAD_LIB} ${ZLIB_LIBRARIES}
+ )
+
diff --git a/build_files/build_environment/patches/openimageio_gdi.diff b/build_files/build_environment/patches/openimageio_gdi.diff
new file mode 100644
index 00000000000..af0c90638de
--- /dev/null
+++ b/build_files/build_environment/patches/openimageio_gdi.diff
@@ -0,0 +1,26 @@
+Index: OpenImageIO/osdep.h
+===================================================================
+--- OpenImageIO/osdep.h (revision 61595)
++++ OpenImageIO/osdep.h (working copy)
+@@ -34,6 +34,7 @@
+ # define WIN32_LEAN_AND_MEAN
+ # define VC_EXTRALEAN
+ # define NOMINMAX
++# define NOGDI
+ # include <windows.h>
+ #endif
+
+Index: OpenImageIO/platform.h
+===================================================================
+--- OpenImageIO/platform.h (revision 61595)
++++ OpenImageIO/platform.h (working copy)
+@@ -77,6 +77,9 @@
+ # ifndef NOMINMAX
+ # define NOMINMAX
+ # endif
++# ifndef NOGDI
++# define NOGDI
++# endif
+ # include <windows.h>
+ #endif
+
diff --git a/build_files/build_environment/patches/openimageio_idiff.diff b/build_files/build_environment/patches/openimageio_idiff.diff
new file mode 100644
index 00000000000..ae1884f76b5
--- /dev/null
+++ b/build_files/build_environment/patches/openimageio_idiff.diff
@@ -0,0 +1,13 @@
+--- idiff.cpp 2016-11-18 11:42:01 -0700
++++ idiff.cpp 2016-11-18 11:41:25 -0700
+@@ -308,8 +308,10 @@
+ // printed with three digit exponent. We change this behaviour to fit
+ // Linux way
+ #ifdef _MSC_VER
++#if _MSC_VER < 1900
+ _set_output_format(_TWO_DIGIT_EXPONENT);
+ #endif
++#endif
+ std::streamsize precis = std::cout.precision();
+ std::cout << " " << cr.nwarn << " pixels ("
+ << std::setprecision(3) << (100.0*cr.nwarn / npels)
diff --git a/build_files/build_environment/patches/openimageio_staticexr.diff b/build_files/build_environment/patches/openimageio_staticexr.diff
new file mode 100644
index 00000000000..e1f0f473057
--- /dev/null
+++ b/build_files/build_environment/patches/openimageio_staticexr.diff
@@ -0,0 +1,11 @@
+--- CMakeLists.txt 2016-11-01 01:03:44 -0600
++++ CMakeLists.txt 2016-12-01 09:20:12 -0700
+@@ -454,7 +454,7 @@
+ add_definitions (-D_CRT_NONSTDC_NO_WARNINGS)
+ add_definitions (-D_SCL_SECURE_NO_WARNINGS)
+ add_definitions (-DJAS_WIN_MSVC_BUILD)
+- add_definitions (-DOPENEXR_DLL)
++ add_definitions (-DOPJ_STATIC)
+ if (LINKSTATIC)
+ add_definitions (-DBoost_USE_STATIC_LIBS=1)
+ else ()
diff --git a/build_files/build_environment/patches/opensubdiv.diff b/build_files/build_environment/patches/opensubdiv.diff
new file mode 100644
index 00000000000..9e9cf7ad554
--- /dev/null
+++ b/build_files/build_environment/patches/opensubdiv.diff
@@ -0,0 +1,16 @@
+ opensubdiv/osd/d3d11VertexBuffer.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/opensubdiv/osd/d3d11VertexBuffer.cpp b/opensubdiv/osd/d3d11VertexBuffer.cpp
+index 603cbf4..07e7e0a 100644
+--- a/opensubdiv/osd/d3d11VertexBuffer.cpp
++++ b/opensubdiv/osd/d3d11VertexBuffer.cpp
+@@ -81,7 +81,7 @@ D3D11VertexBuffer::UpdateData(const float *src, int startVertex, int numVertices
+
+ deviceContext->Unmap(_uploadBuffer, 0);
+
+- D3D11_BOX srcBox = { 0, 0, 0, size, 1, 1 };
++ D3D11_BOX srcBox = { 0, 0, 0, (UINT) size, 1, 1 };
+ deviceContext->CopySubresourceRegion(_buffer, 0, 0, 0, 0,
+ _uploadBuffer, 0, &srcBox);
+ }
diff --git a/build_files/build_environment/patches/openvdb.diff b/build_files/build_environment/patches/openvdb.diff
new file mode 100644
index 00000000000..f3afa13ea17
--- /dev/null
+++ b/build_files/build_environment/patches/openvdb.diff
@@ -0,0 +1,11 @@
+diff -Naur k:\BlenderDev\lib\win64_vc12_Harvest\openVDB\/include/openvdb/math/Coord.h .\openVDB/include/openvdb/math/Coord.h
+--- k:\BlenderDev\lib\win64_vc12_Harvest\openVDB\/include/openvdb/math/Coord.h 2016-03-30 15:09:49 -0600
++++ .\openVDB/include/openvdb/math/Coord.h 2016-04-01 06:53:47 -0600
+@@ -34,6 +34,7 @@
+ #include <openvdb/Platform.h>
+ #include "Math.h"
+ #include "Vec3.h"
++#define NOMINMAX
+
+ namespace tbb { class split; } // forward declaration
+
diff --git a/build_files/build_environment/patches/openvdb_vc2013.diff b/build_files/build_environment/patches/openvdb_vc2013.diff
new file mode 100644
index 00000000000..7dc3e476297
--- /dev/null
+++ b/build_files/build_environment/patches/openvdb_vc2013.diff
@@ -0,0 +1,35 @@
+--- openvdb/tree/LeafNode.h 2015-10-01 15:55:33 -0600
++++ openvdb/tree/LeafNode.h 2016-03-26 13:12:22 -0600
+@@ -70,13 +70,14 @@
+ typedef boost::shared_ptr<LeafNode> Ptr;
+ typedef util::NodeMask<Log2Dim> NodeMaskType;
+
+- static const Index
+- LOG2DIM = Log2Dim, // needed by parent nodes
+- TOTAL = Log2Dim, // needed by parent nodes
+- DIM = 1 << TOTAL, // dimension along one coordinate direction
+- NUM_VALUES = 1 << 3 * Log2Dim,
+- NUM_VOXELS = NUM_VALUES, // total number of voxels represented by this node
+- SIZE = NUM_VALUES,
++ static const Index
++ LOG2DIM = Log2Dim, // needed by parent nodes
++ TOTAL = Log2Dim, // needed by parent nodes
++ DIM = 1 << TOTAL, // dimension along one coordinate direction
++ NUM_VALUES = 1 << 3 * Log2Dim,
++ NUM_VOXELS = NUM_VALUES; // total number of voxels represented by this node
++ static const Index
++ SIZE = NUM_VALUES,
+ LEVEL = 0; // level 0 = leaf
+
+ /// @brief ValueConverter<T>::Type is the type of a LeafNode having the same
+--- openvdb/PlatformConfig.h 2016-03-30 15:09:49 -0600
++++ openvdb/PlatformConfig.h 2016-04-01 07:00:38 -0600
+@@ -47,7 +47,7 @@
+ #if !defined(OPENVDB_OPENEXR_STATICLIB) && !defined(OPENEXR_DLL)
+ #define OPENEXR_DLL
+ #endif
+-
++ #define NOMINMAX
+ #endif // _WIN32
+
+ #endif // OPENVDB_PLATFORMCONFIG_HAS_BEEN_INCLUDED
diff --git a/build_files/build_environment/patches/osl.diff b/build_files/build_environment/patches/osl.diff
new file mode 100644
index 00000000000..fcb5ec4165f
--- /dev/null
+++ b/build_files/build_environment/patches/osl.diff
@@ -0,0 +1,12 @@
+diff -Naur osl/src/external_osl/src/cmake/flexbison.cmake osl_bak/src/external_osl/src/cmake/flexbison.cmake
+--- osl/src/external_osl//src/cmake/flexbison.cmake 2016-01-29 11:15:22 -0700
++++ osl_bak/src/external_osl/src/cmake/flexbison.cmake 2016-02-29 21:26:26 -0700
+@@ -77,7 +77,7 @@
+ DEPENDS ${${compiler_headers}}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
+ ADD_CUSTOM_COMMAND ( OUTPUT ${flexoutputcxx}
+- COMMAND ${FLEX_EXECUTABLE} -o ${flexoutputcxx} "${CMAKE_CURRENT_SOURCE_DIR}/${flexsrc}"
++ COMMAND ${FLEX_EXECUTABLE} ${FLEX_EXTRA_OPTIONS} -o ${flexoutputcxx} "${CMAKE_CURRENT_SOURCE_DIR}/${flexsrc}"
+ MAIN_DEPENDENCY ${flexsrc}
+ DEPENDS ${${compiler_headers}}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
diff --git a/build_files/build_environment/patches/osl_simd_oiio.diff b/build_files/build_environment/patches/osl_simd_oiio.diff
new file mode 100644
index 00000000000..5062a597167
--- /dev/null
+++ b/build_files/build_environment/patches/osl_simd_oiio.diff
@@ -0,0 +1,14 @@
+--- CMakeLists.txt 2016-10-31 16:48:19 -0600
++++ CMakeLists.txt 2017-04-10 10:38:48 -0600
+@@ -269,6 +269,11 @@
+ add_definitions ("-DOIIO_STATIC_BUILD=1")
+ endif ()
+
++set (OIIO_NOSIMD OFF CACHE BOOL "Disable simd support in oiio")
++if (OIIO_NOSIMD)
++ add_definitions ("-DOIIO_NO_SSE=1")
++endif ()
++
+ if (OSL_NO_DEFAULT_TEXTURESYSTEM)
+ add_definitions ("-DOSL_NO_DEFAULT_TEXTURESYSTEM=1")
+ endif ()
diff --git a/build_files/build_environment/patches/pthreads.diff b/build_files/build_environment/patches/pthreads.diff
new file mode 100644
index 00000000000..bbabfdc8925
--- /dev/null
+++ b/build_files/build_environment/patches/pthreads.diff
@@ -0,0 +1,13 @@
+--- pthread.h.orig 2012-05-26 22:16:45 -0600
++++ pthread.h 2016-04-01 09:20:36 -0600
+@@ -109,6 +109,10 @@
+ /* Include everything */
+ #endif
+
++#if _MSC_VER >= 1900
++# define HAVE_STRUCT_TIMESPEC 1
++#endif
++
+ #if defined(_UWIN)
+ # define HAVE_STRUCT_TIMESPEC 1
+ # define HAVE_SIGNAL_H 1
diff --git a/build_files/build_environment/patches/pyshell.diff b/build_files/build_environment/patches/pyshell.diff
new file mode 100644
index 00000000000..7ccffe4c040
--- /dev/null
+++ b/build_files/build_environment/patches/pyshell.diff
@@ -0,0 +1,12 @@
+--- pyshellext.cpp.orig 2017-01-17 00:57:53 -0700
++++ pyshellext.cpp 2017-05-20 15:21:51 -0600
+@@ -13,6 +13,9 @@
+ #include <strsafe.h>
+
+ #include "pyshellext_h.h"
++#if _MSC_VER < 1900
++#include "pyshellext_i.c"
++#endif
+
+ #define DDWM_UPDATEWINDOW (WM_USER+3)
+
diff --git a/build_files/build_environment/patches/python.diff b/build_files/build_environment/patches/python.diff
new file mode 100644
index 00000000000..9e7eccfafff
--- /dev/null
+++ b/build_files/build_environment/patches/python.diff
@@ -0,0 +1,82 @@
+--- Include/Python.h 2017-07-07 21:33:27 -0600
++++ Include/Python.h 2017-09-19 10:36:10 -0600
+@@ -2,6 +2,10 @@
+ #define Py_PYTHON_H
+ /* Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" { */
+
++#if _MSC_VER < 1900
++#define inline __inline
++#endif
++
+ /* Include nearly all Python header files */
+
+ #include "patchlevel.h"
+--- Include/pydtrace.h 2017-07-07 21:33:27 -0600
++++ Include/pydtrace.h 2017-09-19 10:32:31 -0600
+@@ -2,6 +2,11 @@
+
+ #ifndef Py_DTRACE_H
+ #define Py_DTRACE_H
++
++#if _MSC_VER < 1900
++#define inline __inline
++#endif
++
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+
+--- Modules/_blake2/impl/blake2.h 2017-07-07 21:33:27 -0600
++++ Modules/_blake2/impl/blake2.h 2017-09-19 10:22:41 -0600
+@@ -19,6 +19,10 @@
+ #include <stddef.h>
+ #include <stdint.h>
+
++#if _MSC_VER < 1900
++#define inline __inline
++#endif
++
+ #ifdef BLAKE2_NO_INLINE
+ #define BLAKE2_LOCAL_INLINE(type) static type
+ #endif
+
+--- pcbuild/build.bat 2016-05-21 09:53:55 -0600
++++ pcbuild/build.bat 2016-05-21 09:56:16 -0600
+@@ -59,6 +59,7 @@
+ if "%~1"=="-h" goto Usage
+ if "%~1"=="-c" (set conf=%2) & shift & shift & goto CheckOpts
+ if "%~1"=="-p" (set platf=%2) & shift & shift & goto CheckOpts
++if "%~1"=="-k" (set vs_toolset=%2) & shift & shift & goto CheckOpts
+ if "%~1"=="-r" (set target=Rebuild) & shift & goto CheckOpts
+ if "%~1"=="-t" (set target=%2) & shift & shift & goto CheckOpts
+ if "%~1"=="-d" (set conf=Debug) & shift & goto CheckOpts
+@@ -120,7 +120,7 @@
+
+ :Kill
+ echo on
+-%MSBUILD% "%dir%\pythoncore.vcxproj" /t:KillPython %verbose%^
++%MSBUILD% "%dir%\pythoncore.vcxproj" /t:KillPython %verbose% /p:PlatformToolset=%vs_toolset%^
+ /p:Configuration=%conf% /p:Platform=%platf%^
+ /p:KillPython=true
+
+@@ -130,7 +130,7 @@
+ rem batch is, shall we say, "lackluster"
+ echo on
+ %MSBUILD% "%dir%pcbuild.proj" /t:%target% %parallel% %verbose%^
+- /p:Configuration=%conf% /p:Platform=%platf%^
++ /p:Configuration=%conf% /p:Platform=%platf% /p:PlatformToolset=%vs_toolset%^
+ /p:IncludeExternals=%IncludeExternals%^
+ /p:IncludeSSL=%IncludeSSL% /p:IncludeTkinter=%IncludeTkinter%^
+ /p:UseTestMarker=%UseTestMarker%^
+
+--- pcbuild/sqlite3.vcxproj 2015-12-06 18:39:10 -0700
++++ pcbuild/sqlite3.vcxproj 2016-11-02 09:25:56 -0600
+@@ -43,7 +43,7 @@
+ <Import Project="python.props" />
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Label="Configuration">
+- <ConfigurationType>DynamicLibrary</ConfigurationType>
++ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>NotSet</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
diff --git a/build_files/build_environment/patches/python_apple.diff b/build_files/build_environment/patches/python_apple.diff
new file mode 100644
index 00000000000..34a7906ed6c
--- /dev/null
+++ b/build_files/build_environment/patches/python_apple.diff
@@ -0,0 +1,25 @@
+--- pyconfig.h.in 2017-09-19 14:41:01.000000000 +0300
++++ pyconfig.h.in 2017-09-19 14:43:18.000000000 +0300
+@@ -119,12 +119,6 @@
+ /* Define to 1 if you have the `clock' function. */
+ #undef HAVE_CLOCK
+
+-/* Define to 1 if you have the `clock_getres' function. */
+-#undef HAVE_CLOCK_GETRES
+-
+-/* Define to 1 if you have the `clock_gettime' function. */
+-#undef HAVE_CLOCK_GETTIME
+-
+ /* Define to 1 if you have the `clock_settime' function. */
+ #undef HAVE_CLOCK_SETTIME
+
+@@ -369,9 +363,6 @@
+ /* Define this if you have flockfile(), getc_unlocked(), and funlockfile() */
+ #undef HAVE_GETC_UNLOCKED
+
+-/* Define to 1 if you have the `getentropy' function. */
+-#undef HAVE_GETENTROPY
+-
+ /* Define to 1 if you have the `getgrouplist' function. */
+ #undef HAVE_GETGROUPLIST
+
diff --git a/build_files/build_environment/patches/python_runtime_vc2013.diff b/build_files/build_environment/patches/python_runtime_vc2013.diff
new file mode 100644
index 00000000000..186d2b36c07
--- /dev/null
+++ b/build_files/build_environment/patches/python_runtime_vc2013.diff
@@ -0,0 +1,29 @@
+--- _msvccompiler.py.orig 2017-05-20 19:31:45 -0600
++++ _msvccompiler.py 2017-06-10 10:05:38 -0600
+@@ -222,9 +222,9 @@
+ # use /MT[d] to build statically, then switch from libucrt[d].lib to ucrt[d].lib
+ # later to dynamically link to ucrtbase but not vcruntime.
+ self.compile_options = [
+- '/nologo', '/Ox', '/W3', '/GL', '/DNDEBUG'
++ '/nologo', '/Ox', '/W3', '/GL', '/DNDEBUG' , '/MD'
+ ]
+- self.compile_options.append('/MD' if self._vcruntime_redist else '/MT')
++ #self.compile_options.append('/MD' if self._vcruntime_redist else '/MT')
+
+ self.compile_options_debug = [
+ '/nologo', '/Od', '/MDd', '/Zi', '/W3', '/D_DEBUG'
+@@ -233,11 +233,11 @@
+ ldflags = [
+ '/nologo', '/INCREMENTAL:NO', '/LTCG'
+ ]
+- if not self._vcruntime_redist:
+- ldflags.extend(('/nodefaultlib:libucrt.lib', 'ucrt.lib'))
++ #if not self._vcruntime_redist:
++ # ldflags.extend(('/nodefaultlib:libucrt.lib', 'ucrt.lib'))
+
+ ldflags_debug = [
+- '/nologo', '/INCREMENTAL:NO', '/LTCG', '/DEBUG:FULL'
++ '/nologo', '/INCREMENTAL:NO', '/LTCG'
+ ]
+
+ self.ldflags_exe = [*ldflags, '/MANIFEST:EMBED,ID=1']
diff --git a/build_files/build_environment/patches/schroedinger.diff b/build_files/build_environment/patches/schroedinger.diff
new file mode 100644
index 00000000000..6acb35f2a7b
--- /dev/null
+++ b/build_files/build_environment/patches/schroedinger.diff
@@ -0,0 +1,54 @@
+--- configure.orig 2012-01-22 19:06:43 -0700
++++ configure 2016-04-06 20:00:50 -0600
+@@ -16492,10 +16492,10 @@
+ HAVE_ORC=yes
+ fi
+ if test "x${HAVE_ORC}" != xyes ; then
+- as_fn_error $? "orc-0.4 >= $ORC_VER is required" "$LINENO" 5
++ $as_echo "orc-0.4 >= $ORC_VER is required"
+ fi
+ SCHRO_PKG_DEPS="$SCHRO_PKG_DEPS orc-0.4 >= $ORC_VER"
+-ORCC=`$PKG_CONFIG --variable=orcc orc-0.4`
++#ORCC=`$PKG_CONFIG --variable=orcc orc-0.4`
+
+ if test "x$cross_compiling" != xyes; then
+ HAVE_ORCC_TRUE=
+--- Makefile.in 2012-01-22 18:06:42 -0700
++++ Makefile.in 2016-04-06 20:30:09 -0600
+@@ -291,7 +291,7 @@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+ AUTOMAKE_OPTIONS = foreign
+-SUBDIRS = schroedinger doc tools testsuite
++SUBDIRS = schroedinger doc tools
+ DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc
+ DIST_SUBDIRS = schroedinger doc tools testsuite
+ EXTRA_DIST = COPYING COPYING.GPL COPYING.LGPL COPYING.MIT COPYING.MPL \
+
+--- schroedinger.pc.in 2011-03-21 17:08:39 -0600
++++ schroedinger.pc.in 2016-04-08 13:30:42 -0600
+@@ -7,9 +7,9 @@
+
+ Name: schroedinger-@SCHRO_MAJORMINOR@
+ Description: Dirac codec library
+-Requires.private: @SCHRO_PKG_DEPS@
++Requires: @SCHRO_PKG_DEPS@
+ Version: @VERSION@
+-Libs: -L${libdir} -lschroedinger-@SCHRO_MAJORMINOR@
++Libs: -L${libdir} -lschroedinger-@SCHRO_MAJORMINOR@ -lorc-0.4
+ Libs.private: @PTHREAD_LIBS@ @LIBM@
+ Cflags: -I${includedir}
+
+--- ./schroedinger/schrodecoder.c 2012-01-23 00:38:57.000000000 +0100
++++ ./schroedinger/schrodecoder.c 2016-05-15 06:07:24.000000000 +0200
+@@ -70,8 +70,8 @@
+ };
+
+
+-int _schro_decode_prediction_only;
+-int _schro_telemetry;
++int _schro_decode_prediction_only = 0;
++int _schro_telemetry = 0;
+
+ static void schro_decoder_x_decode_motion (SchroAsyncStage * stage);
+ static void schro_decoder_x_render_motion (SchroAsyncStage * stage);
diff --git a/build_files/build_environment/patches/sdl.diff b/build_files/build_environment/patches/sdl.diff
new file mode 100644
index 00000000000..b309d0230f3
--- /dev/null
+++ b/build_files/build_environment/patches/sdl.diff
@@ -0,0 +1,50 @@
+diff -ru /Users/brecht/dev/lib/deps/Downloads/SDL2-2.0.4/src/video/SDL_video.c ./src/video/SDL_video.c
+--- /Users/brecht/dev/lib/deps/Downloads/SDL2-2.0.4/src/video/SDL_video.c 2016-01-02 20:56:31.000000000 +0100
++++ ./src/video/SDL_video.c 2016-05-15 02:58:27.000000000 +0200
+@@ -137,7 +137,7 @@
+
+ #define FULLSCREEN_MASK (SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_FULLSCREEN)
+
+-#ifdef __MACOSX__
++#if SDL_VIDEO_DRIVER_COCOA
+ /* Support for Mac OS X fullscreen spaces */
+ extern SDL_bool Cocoa_IsWindowInFullscreenSpace(SDL_Window * window);
+ extern SDL_bool Cocoa_SetWindowFullscreenSpace(SDL_Window * window, SDL_bool state);
+@@ -1141,7 +1141,7 @@
+ if ( window->is_hiding && fullscreen )
+ return 0;
+
+-#ifdef __MACOSX__
++#if SDL_VIDEO_DRIVER_COCOA
+ /* if the window is going away and no resolution change is necessary,
+ do nothing, or else we may trigger an ugly double-transition
+ */
+@@ -2365,7 +2365,7 @@
+ return SDL_FALSE;
+ }
+
+-#ifdef __MACOSX__
++#if SDL_VIDEO_DRIVER_COCOA
+ if (Cocoa_IsWindowInFullscreenSpace(window)) {
+ return SDL_FALSE;
+ }
+--- CMakeLists.txt.old 2016-01-02 12:56:31 -0700
++++ CMakeLists.txt 2016-10-03 11:24:24 -0600
+@@ -609,7 +609,7 @@
+ list(APPEND EXTRA_LIBS m)
+ endif()
+
+- check_library_exists(iconv iconv_open "" HAVE_LIBICONV)
++ #check_library_exists(iconv iconv_open "" HAVE_LIBICONV)
+ if(HAVE_LIBICONV)
+ list(APPEND EXTRA_LIBS iconv)
+ set(HAVE_ICONV 1)
+@@ -1455,7 +1455,7 @@
+ set(_INSTALL_LIBS "SDL2main")
+
+ if(SDL_SHARED)
+- add_library(SDL2 SHARED ${SOURCE_FILES})
++ add_library(SDL2 SHARED ${SOURCE_FILES} ${VERSION_SOURCES})
+ if(UNIX)
+ set_target_properties(SDL2 PROPERTIES
+ VERSION ${LT_VERSION}
diff --git a/build_files/build_environment/patches/semi.txt b/build_files/build_environment/patches/semi.txt
new file mode 100644
index 00000000000..092bc2b0412
--- /dev/null
+++ b/build_files/build_environment/patches/semi.txt
@@ -0,0 +1 @@
+;
diff --git a/build_files/build_environment/patches/sndfile.diff b/build_files/build_environment/patches/sndfile.diff
new file mode 100644
index 00000000000..ab43baa78df
--- /dev/null
+++ b/build_files/build_environment/patches/sndfile.diff
@@ -0,0 +1,42 @@
+--- src/Makefile.in 2017-09-26 01:28:47.000000000 +0300
++++ src/Makefile.in 2017-09-26 01:19:06.000000000 +0300
+@@ -513,7 +513,7 @@
+ libcommon_la_SOURCES = common.c file_io.c command.c pcm.c ulaw.c alaw.c \
+ float32.c double64.c ima_adpcm.c ms_adpcm.c gsm610.c dwvw.c vox_adpcm.c \
+ interleave.c strings.c dither.c cart.c broadcast.c audio_detect.c \
+- ima_oki_adpcm.c ima_oki_adpcm.h alac.c chunk.c ogg.c chanmap.c \
++ ima_oki_adpcm.c ima_oki_adpcm.h alac.c chunk.c ogg.c chanmap.c \
+ windows.c id3.c $(WIN_VERSION_FILE)
+
+
+@@ -719,10 +719,10 @@
+ $(AM_V_CCLD)$(LINK) $(GSM610_libgsm_la_OBJECTS) $(GSM610_libgsm_la_LIBADD) $(LIBS)
+
+ libcommon.la: $(libcommon_la_OBJECTS) $(libcommon_la_DEPENDENCIES) $(EXTRA_libcommon_la_DEPENDENCIES)
+- $(AM_V_CCLD)$(LINK) $(libcommon_la_OBJECTS) $(libcommon_la_LIBADD) $(LIBS)
++ $(AM_V_CCLD)$(LINK) $(libcommon_la_OBJECTS) $(libcommon_la_LIBADD) $(LIBS) $(EXTERNAL_XIPH_LIBS)
+
+ libsndfile.la: $(libsndfile_la_OBJECTS) $(libsndfile_la_DEPENDENCIES) $(EXTRA_libsndfile_la_DEPENDENCIES)
+- $(AM_V_CCLD)$(libsndfile_la_LINK) -rpath $(libdir) $(libsndfile_la_OBJECTS) $(libsndfile_la_LIBADD) $(LIBS)
++ $(AM_V_CCLD)$(libsndfile_la_LINK) -rpath $(libdir) $(libsndfile_la_OBJECTS) $(libsndfile_la_LIBADD) $(LIBS) $(EXTERNAL_XIPH_LIBS)
+
+ clean-checkPROGRAMS:
+ @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
+@@ -924,7 +924,7 @@
+ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsndfile_la_CPPFLAGS) $(CPPFLAGS) $(libsndfile_la_CFLAGS) $(CFLAGS) -c -o libsndfile_la-dwd.lo `test -f 'dwd.c' || echo '$(srcdir)/'`dwd.c
+
+ libsndfile_la-flac.lo: flac.c
+-@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsndfile_la_CPPFLAGS) $(CPPFLAGS) $(libsndfile_la_CFLAGS) $(CFLAGS) -MT libsndfile_la-flac.lo -MD -MP -MF $(DEPDIR)/libsndfile_la-flac.Tpo -c -o libsndfile_la-flac.lo `test -f 'flac.c' || echo '$(srcdir)/'`flac.c
++@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsndfile_la_CPPFLAGS) $(CPPFLAGS) $(libsndfile_la_CFLAGS) $(CFLAGS) $(EXTERNAL_XIPH_CFLAGS) -MT libsndfile_la-flac.lo -MD -MP -MF $(DEPDIR)/libsndfile_la-flac.Tpo -c -o libsndfile_la-flac.lo `test -f 'flac.c' || echo '$(srcdir)/'`flac.c
+ @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsndfile_la-flac.Tpo $(DEPDIR)/libsndfile_la-flac.Plo
+ @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='flac.c' object='libsndfile_la-flac.lo' libtool=yes @AMDEPBACKSLASH@
+ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@@ -1092,7 +1092,7 @@
+ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsndfile_la_CPPFLAGS) $(CPPFLAGS) $(libsndfile_la_CFLAGS) $(CFLAGS) -c -o libsndfile_la-rf64.lo `test -f 'rf64.c' || echo '$(srcdir)/'`rf64.c
+
+ libsndfile_la-ogg_vorbis.lo: ogg_vorbis.c
+-@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsndfile_la_CPPFLAGS) $(CPPFLAGS) $(libsndfile_la_CFLAGS) $(CFLAGS) -MT libsndfile_la-ogg_vorbis.lo -MD -MP -MF $(DEPDIR)/libsndfile_la-ogg_vorbis.Tpo -c -o libsndfile_la-ogg_vorbis.lo `test -f 'ogg_vorbis.c' || echo '$(srcdir)/'`ogg_vorbis.c
++@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsndfile_la_CPPFLAGS) $(CPPFLAGS) $(libsndfile_la_CFLAGS) $(CFLAGS) $(EXTERNAL_XIPH_CFLAGS) -MT libsndfile_la-ogg_vorbis.lo -MD -MP -MF $(DEPDIR)/libsndfile_la-ogg_vorbis.Tpo -c -o libsndfile_la-ogg_vorbis.lo `test -f 'ogg_vorbis.c' || echo '$(srcdir)/'`ogg_vorbis.c
+ @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsndfile_la-ogg_vorbis.Tpo $(DEPDIR)/libsndfile_la-ogg_vorbis.Plo
+ @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ogg_vorbis.c' object='libsndfile_la-ogg_vorbis.lo' libtool=yes @AMDEPBACKSLASH@
+ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
diff --git a/build_files/build_environment/windows/build_deps.cmd b/build_files/build_environment/windows/build_deps.cmd
new file mode 100644
index 00000000000..96280014df2
--- /dev/null
+++ b/build_files/build_environment/windows/build_deps.cmd
@@ -0,0 +1,122 @@
+@echo off
+if NOT "%1" == "" (
+ if "%1" == "2013" (
+ echo "Building for VS2013"
+ set VSVER=12.0
+ set VSVER_SHORT=12
+ set BuildDir=VS12
+ goto par2
+ )
+ if "%1" == "2015" (
+ echo "Building for VS2015"
+ set VSVER=14.0
+ set VSVER_SHORT=14
+ set BuildDir=VS14
+ goto par2
+ )
+)
+:usage
+
+Echo Usage build_deps 2013/2015 x64/x86
+goto exit
+:par2
+if NOT "%2" == "" (
+ if "%2" == "x86" (
+ echo "Building for x86"
+ set HARVESTROOT=Windows_vc
+ set ARCH=86
+ if "%1" == "2013" (
+ set CMAKE_BUILDER=Visual Studio 12 2013
+ )
+ if "%1" == "2015" (
+ set CMAKE_BUILDER=Visual Studio 14 2015
+ )
+ goto start
+ )
+ if "%2" == "x64" (
+ echo "Building for x64"
+ set HARVESTROOT=Win64_vc
+ set ARCH=64
+ if "%1" == "2013" (
+ set CMAKE_BUILDER=Visual Studio 12 2013 Win64
+ )
+ if "%1" == "2015" (
+ set CMAKE_BUILDER=Visual Studio 14 2015 Win64
+ )
+ goto start
+ )
+)
+goto usage
+
+:start
+setlocal ENABLEEXTENSIONS
+set CMAKE_DEBUG_OPTIONS=-DWITH_OPTIMIZED_DEBUG=On
+if "%3" == "debug" set CMAKE_DEBUG_OPTIONS=-DWITH_OPTIMIZED_DEBUG=Off
+
+set SOURCE_DIR=%~dp0\..
+set BUILD_DIR=%cd%\build
+set HARVEST_DIR=%BUILD_DIR%\output
+set STAGING=%BUILD_DIR%\S
+
+rem for python module build
+set MSSdk=1
+set DISTUTILS_USE_SDK=1
+rem for python externals source to be shared between the various archs and compilers
+mkdir %BUILD_DIR%\downloads\externals
+
+REM Detect MSVC Installation
+if DEFINED VisualStudioVersion goto msvc_detect_finally
+set VALUE_NAME=ProductDir
+REM Check 64 bits
+set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\%VSVER%\Setup\VC"
+for /F "usebackq skip=2 tokens=1-2*" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO set MSVC_VC_DIR=%%C
+if DEFINED MSVC_VC_DIR goto msvc_detect_finally
+REM Check 32 bits
+set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\%VSVER%\Setup\VC"
+for /F "usebackq skip=2 tokens=1-2*" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO set MSVC_VC_DIR=%%C
+if DEFINED MSVC_VC_DIR goto msvc_detect_finally
+:msvc_detect_finally
+if DEFINED MSVC_VC_DIR call "%MSVC_VC_DIR%\vcvarsall.bat"
+echo on
+
+REM Sanity Checks
+where /Q msbuild
+if %ERRORLEVEL% NEQ 0 (
+ echo Error: "MSBuild" command not in the PATH.
+ echo You must have MSVC installed and run this from the "Developer Command Prompt"
+ echo ^(available from Visual Studio's Start menu entry^), aborting!
+ goto EOF
+)
+where /Q cmake
+if %ERRORLEVEL% NEQ 0 (
+ echo Error: "CMake" command not in the PATH.
+ echo You must have CMake installed and added to your PATH, aborting!
+ goto EOF
+)
+
+set StatusFile=%BUILD_DIR%\%1_%2.log
+set path=%BUILD_DIR%\downloads\mingw\mingw64\msys\1.0\bin\;%BUILD_DIR%\downloads\nasm-2.12.01\;%path%
+mkdir %STAGING%\%BuildDir%%ARCH%R
+cd %Staging%\%BuildDir%%ARCH%R
+echo %DATE% %TIME% : Start > %StatusFile%
+cmake -G "%CMAKE_BUILDER%" %SOURCE_DIR% -DDOWNLOAD_DIR=%BUILD_DIR%/downloads -DBUILD_MODE=Release -DHARVEST_TARGET=%HARVEST_DIR%/%HARVESTROOT%%VSVER_SHORT%/
+echo %DATE% %TIME% : Release Configuration done >> %StatusFile%
+msbuild /m "ll.vcxproj" /p:Configuration=Release /fl /flp:logfile=BlenderDeps_llvm.log;Verbosity=normal
+msbuild /m "BlenderDependencies.sln" /p:Configuration=Release /fl /flp:logfile=BlenderDeps.log;Verbosity=minimal /verbosity:minimal
+echo %DATE% %TIME% : Release Build done >> %StatusFile%
+cmake --build . --target Harvest_Release_Results > Harvest_Release.txt
+echo %DATE% %TIME% : Release Harvest done >> %StatusFile%
+cd %BUILD_DIR%
+mkdir %STAGING%\%BuildDir%%ARCH%D
+cd %Staging%\%BuildDir%%ARCH%D
+cmake -G "%CMAKE_BUILDER%" %SOURCE_DIR% -DDOWNLOAD_DIR=%BUILD_DIR%/downloads -DCMAKE_BUILD_TYPE=Debug -DBUILD_MODE=Debug -DHARVEST_TARGET=%HARVEST_DIR%/%HARVESTROOT%%VSVER_SHORT%/ %CMAKE_DEBUG_OPTIONS%
+echo %DATE% %TIME% : Debug Configuration done >> %StatusFile%
+msbuild /m "ll.vcxproj" /p:Configuration=Debug /fl /flp:logfile=BlenderDeps_llvm.log;;Verbosity=normal
+msbuild /m "BlenderDependencies.sln" /p:Configuration=Debug /verbosity:n /fl /flp:logfile=BlenderDeps.log;;Verbosity=normal
+echo %DATE% %TIME% : Debug Build done >> %StatusFile%
+cmake --build . --target Harvest_Debug_Results> Harvest_Debug.txt
+echo %DATE% %TIME% : Debug Harvest done >> %StatusFile%
+cd %BUILD_DIR%
+
+:exit
+Echo .
diff --git a/build_files/build_environment/windows/buildall.cmd b/build_files/build_environment/windows/buildall.cmd
new file mode 100644
index 00000000000..480be8cde44
--- /dev/null
+++ b/build_files/build_environment/windows/buildall.cmd
@@ -0,0 +1,10 @@
+title building 1_4 - x86_2013
+call build_deps 2013 x86
+title building 2_4 - x86_2015
+call build_deps 2015 x86
+title building 3_4 - x64_2013
+call build_deps 2013 x64
+title building 4_4 - x64_2015
+call build_deps 2015 x64
+title done!
+echo done! \ No newline at end of file
diff --git a/build_files/build_environment/windows/nuke.cmd b/build_files/build_environment/windows/nuke.cmd
new file mode 100644
index 00000000000..68dbc8d1487
--- /dev/null
+++ b/build_files/build_environment/windows/nuke.cmd
@@ -0,0 +1,52 @@
+@echo off
+if "%1"=="" goto EOF:
+set ROOT=%~dp0\..\..\..\..\build_windows\deps
+
+set CurPath=%ROOT%\s\vs1264D\debug\%1\
+if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" )
+set CurPath=%ROOT%\s\vs1264D\build\%1\
+if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" )
+set CurPath=%ROOT%\s\vs1264R\release\%1\
+if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" )
+set CurPath=%ROOT%\s\vs1264R\build\%1\
+if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" )
+set CurPath=%ROOT%\output\win64_vc12\%1\
+if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" )
+
+set CurPath=%ROOT%\s\vs1464D\debug\%1\
+if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" )
+set CurPath=%ROOT%\s\vs1464D\build\%1\
+if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" )
+set CurPath=%ROOT%\s\vs1464R\release\%1\
+if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" )
+set CurPath=%ROOT%\s\vs1464R\build\%1\
+if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" )
+set CurPath=%ROOT%\output\win64_vc14\%1\
+if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" )
+
+set CurPath=%ROOT%\s\vs1286D\debug\%1\
+if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" )
+set CurPath=%ROOT%\s\vs1286D\build\%1\
+if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" )
+set CurPath=%ROOT%\s\vs1286R\release\%1\
+if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" )
+set CurPath=%ROOT%\s\vs1286R\build\%1\
+if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" )
+set CurPath=%ROOT%\output\windows_vc12\%1\
+if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" )
+
+set CurPath=%ROOT%\s\vs1486D\debug\%1\
+if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" )
+set CurPath=%ROOT%\s\vs1486D\build\%1\
+if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" )
+set CurPath=%ROOT%\s\vs1486R\release\%1\
+if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" )
+set CurPath=%ROOT%\s\vs1486R\build\%1\
+if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" )
+set CurPath=%ROOT%\output\windows_vc14\%1\
+if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" )
+
+
+:EOF
+
+
diff --git a/build_files/buildbot/config/blender_linux.cmake b/build_files/buildbot/config/blender_linux.cmake
index 56f18967300..53e841ba536 100644
--- a/build_files/buildbot/config/blender_linux.cmake
+++ b/build_files/buildbot/config/blender_linux.cmake
@@ -70,11 +70,11 @@ set(FFMPEG_LIBRARIES
)
# SndFile libraries
-set(SNDFILE_LIBRARY "/usr/lib/libsndfile.a;/usr/lib/libFLAC.a" CACHE STRING "" FORCE)
+set(SNDFILE_LIBRARY "/usr/lib${MULTILIB}/libsndfile.a;/usr/lib${MULTILIB}/libFLAC.a" CACHE STRING "" FORCE)
# OpenAL libraries
set(OPENAL_ROOT_DIR "/opt/lib/openal" CACHE STRING "" FORCE)
-set(OPENAL_INCLUDE_DIR "${OPENAL_ROOT_DIR}/include" CACHE STRING "" FORCE)
+set(OPENAL_INCLUDE_DIR "${OPENAL_ROOT_DIR}/include/AL" CACHE STRING "" FORCE)
set(OPENAL_LIBRARY
${OPENAL_ROOT_DIR}/lib/libopenal.a
${OPENAL_ROOT_DIR}/lib/libcommon.a
diff --git a/build_files/buildbot/master.cfg b/build_files/buildbot/master.cfg
index c650cb8c302..e3101430e50 100644
--- a/build_files/buildbot/master.cfg
+++ b/build_files/buildbot/master.cfg
@@ -245,10 +245,7 @@ def git_submodules_update():
def lib_svn_step(dir):
- name = "lib svn"
- if dir == "darwin":
- name = "C++11 lib svn"
- return SVN(name=name,
+ return SVN(name='lib svn',
baseURL='https://svn.blender.org/svnroot/bf-blender/%%BRANCH%%/lib/' + dir,
codebase='lib svn',
mode='update',
@@ -277,9 +274,6 @@ def generic_builder(id, libdir='', branch='', rsync=False):
f = BuildFactory()
if libdir != '':
f.addStep(lib_svn_step(libdir))
- # Special trick to make sure we always have all the libs.
- if libdir.startswith("darwin"):
- f.addStep(lib_svn_step("darwin"))
for submodule in ('blender-translations',
'blender-addons',
@@ -312,15 +306,13 @@ def generic_builder(id, libdir='', branch='', rsync=False):
# Builders
-add_builder(c, 'mac_x86_64_10_6_cmake', 'darwin-9.x.universal', generic_builder, hour=5)
-# add_builder(c, 'linux_glibc211_i686_cmake', '', generic_builder, hour=1)
-# add_builder(c, 'linux_glibc211_x86_64_cmake', '', generic_builder, hour=2)
-add_builder(c, 'linux_glibc219_i686_cmake', '', generic_builder, hour=3)
-add_builder(c, 'linux_glibc219_x86_64_cmake', '', generic_builder, hour=4)
-add_builder(c, 'win32_cmake_vc2013', 'windows_vc12', generic_builder, hour=3)
-add_builder(c, 'win64_cmake_vc2013', 'win64_vc12', generic_builder, hour=4)
-add_builder(c, 'win32_cmake_vc2015', 'windows_vc14', generic_builder, hour=5)
-add_builder(c, 'win64_cmake_vc2015', 'win64_vc14', generic_builder, hour=6)
+add_builder(c, 'mac_x86_64_10_9_cmake', 'darwin', generic_builder, hour=1)
+add_builder(c, 'linux_glibc219_i686_cmake', '', generic_builder, hour=2)
+add_builder(c, 'linux_glibc219_x86_64_cmake', '', generic_builder, hour=1)
+add_builder(c, 'win32_cmake_vc2013', 'windows_vc12', generic_builder, hour=1)
+add_builder(c, 'win64_cmake_vc2013', 'win64_vc12', generic_builder, hour=2)
+add_builder(c, 'win32_cmake_vc2015', 'windows_vc14', generic_builder, hour=3)
+add_builder(c, 'win64_cmake_vc2015', 'win64_vc14', generic_builder, hour=4)
# STATUS TARGETS
#
diff --git a/build_files/buildbot/slave_compile.py b/build_files/buildbot/slave_compile.py
index 0e264a752d5..1318cd26294 100644
--- a/build_files/buildbot/slave_compile.py
+++ b/build_files/buildbot/slave_compile.py
@@ -70,15 +70,12 @@ if 'cmake' in builder:
if builder.startswith('mac'):
# Set up OSX architecture
- if builder.endswith('x86_64_10_6_cmake'):
+ if builder.endswith('x86_64_10_9_cmake'):
cmake_extra_options.append('-DCMAKE_OSX_ARCHITECTURES:STRING=x86_64')
- cmake_extra_options.append('-DWITH_CODEC_QUICKTIME=OFF')
- cmake_extra_options.append('-DCMAKE_OSX_DEPLOYMENT_TARGET=10.6')
+ cmake_extra_options.append('-DCMAKE_OSX_DEPLOYMENT_TARGET=10.9')
cmake_extra_options.append('-DCUDA_HOST_COMPILER=/usr/local/cuda-hack/clang')
cmake_extra_options.append('-DCUDA_NVCC_EXECUTABLE=/usr/local/cuda-hack/nvcc')
-
-
elif builder.startswith('win'):
if builder.endswith('_vc2015'):
if builder.startswith('win64'):
@@ -112,8 +109,8 @@ if 'cmake' in builder:
chroot_name = 'buildbot_' + deb_name + '_i686'
cuda_chroot_name = 'buildbot_' + deb_name + '_x86_64'
targets = ['player', 'blender', 'cuda']
- cmake_extra_options.extend(["-DCMAKE_C_COMPILER=/usr/bin/gcc-6",
- "-DCMAKE_CXX_COMPILER=/usr/bin/g++-6"])
+ cmake_extra_options.extend(["-DCMAKE_C_COMPILER=/usr/bin/gcc-7",
+ "-DCMAKE_CXX_COMPILER=/usr/bin/g++-7"])
cmake_options.append("-C" + os.path.join(blender_dir, cmake_config_file))
diff --git a/build_files/buildbot/slave_pack.py b/build_files/buildbot/slave_pack.py
index 6929be85003..41841d809eb 100644
--- a/build_files/buildbot/slave_pack.py
+++ b/build_files/buildbot/slave_pack.py
@@ -101,13 +101,9 @@ if builder.find('cmake') != -1:
platform = builder.split('_')[0]
if platform == 'mac':
# Special exception for OSX
- platform = 'OSX-10.6-'
- if builder.endswith('x86_64_10_6_cmake'):
+ platform = 'OSX-10.9-'
+ if builder.endswith('x86_64_10_9_cmake'):
platform += 'x86_64'
- elif builder.endswith('i386_10_6_cmake'):
- platform += 'i386'
- elif builder.endswith('ppc_10_6_cmake'):
- platform += 'ppc'
if builder.endswith('vc2015'):
platform += "-vc14"
builderified_name = 'blender-{}-{}-{}'.format(blender_full_version, git_hash, platform)
diff --git a/build_files/cmake/Modules/FindPythonLibsUnix.cmake b/build_files/cmake/Modules/FindPythonLibsUnix.cmake
index 9d79bdd778d..493fb0df6a7 100644
--- a/build_files/cmake/Modules/FindPythonLibsUnix.cmake
+++ b/build_files/cmake/Modules/FindPythonLibsUnix.cmake
@@ -38,7 +38,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.5 CACHE STRING "Python Version (major and minor only)")
+SET(PYTHON_VERSION 3.6 CACHE STRING "Python Version (major and minor only)")
MARK_AS_ADVANCED(PYTHON_VERSION)
@@ -77,15 +77,12 @@ SET(_python_SEARCH_DIRS
# only search for the dirs if we havn't already
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
+ SET(_PYTHON_ABI_FLAGS_TEST
"m;mu;u; " # release
"dm;dmu;du;d" # debug
)
-
-
- FOREACH(_CURRENT_ABI_FLAGS ${_python_ABI_FLAGS})
+ FOREACH(_CURRENT_ABI_FLAGS ${_PYTHON_ABI_FLAGS_TEST})
#IF(CMAKE_BUILD_TYPE STREQUAL Debug)
# SET(_CURRENT_ABI_FLAGS "d${_CURRENT_ABI_FLAGS}")
#ENDIF()
@@ -170,7 +167,7 @@ IF((NOT _IS_INC_DEF) OR (NOT _IS_INC_CONF_DEF) OR (NOT _IS_LIB_DEF) OR (NOT _IS_
UNSET(_CURRENT_ABI_FLAGS)
UNSET(_CURRENT_PATH)
- UNSET(_python_ABI_FLAGS)
+ UNSET(_PYTHON_ABI_FLAGS_TEST)
ENDIF()
UNSET(_IS_INC_DEF)
diff --git a/build_files/cmake/Modules/FindSndFile.cmake b/build_files/cmake/Modules/FindSndFile.cmake
index 1b685eacfbd..dd1f560e61f 100644
--- a/build_files/cmake/Modules/FindSndFile.cmake
+++ b/build_files/cmake/Modules/FindSndFile.cmake
@@ -1,15 +1,15 @@
# - Find SndFile library
# Find the native SndFile includes and library
# This module defines
-# SNDFILE_INCLUDE_DIRS, where to find sndfile.h, Set when
-# SNDFILE_INCLUDE_DIR is found.
-# SNDFILE_LIBRARIES, libraries to link against to use SndFile.
-# SNDFILE_ROOT_DIR, The base directory to search for SndFile.
+# LIBSNDFILE_INCLUDE_DIRS, where to find sndfile.h, Set when
+# LIBSNDFILE_INCLUDE_DIR is found.
+# LIBSNDFILE_LIBRARIES, libraries to link against to use SndFile.
+# LIBSNDFILE_ROOT_DIR, The base directory to search for SndFile.
# This can also be an environment variable.
-# SNDFILE_FOUND, If false, do not try to use SndFile.
+# LIBSNDFILE_FOUND, If false, do not try to use SndFile.
#
# also defined, but not for general use are
-# SNDFILE_LIBRARY, where to find the SndFile library.
+# LIBSNDFILE_LIBRARY, where to find the SndFile library.
#=============================================================================
# Copyright 2011 Blender Foundation.
@@ -22,27 +22,27 @@
# See the License for more information.
#=============================================================================
-# If SNDFILE_ROOT_DIR was defined in the environment, use it.
-IF(NOT SNDFILE_ROOT_DIR AND NOT $ENV{SNDFILE_ROOT_DIR} STREQUAL "")
- SET(SNDFILE_ROOT_DIR $ENV{SNDFILE_ROOT_DIR})
+# If LIBSNDFILE_ROOT_DIR was defined in the environment, use it.
+IF(NOT LIBSNDFILE_ROOT_DIR AND NOT $ENV{LIBSNDFILE_ROOT_DIR} STREQUAL "")
+ SET(LIBSNDFILE_ROOT_DIR $ENV{LIBSNDFILE_ROOT_DIR})
ENDIF()
SET(_sndfile_SEARCH_DIRS
- ${SNDFILE_ROOT_DIR}
+ ${LIBSNDFILE_ROOT_DIR}
/usr/local
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
)
-FIND_PATH(SNDFILE_INCLUDE_DIR sndfile.h
+FIND_PATH(LIBSNDFILE_INCLUDE_DIR sndfile.h
HINTS
${_sndfile_SEARCH_DIRS}
PATH_SUFFIXES
include
)
-FIND_LIBRARY(SNDFILE_LIBRARY
+FIND_LIBRARY(LIBSNDFILE_LIBRARY
NAMES
sndfile
HINTS
@@ -51,18 +51,18 @@ FIND_LIBRARY(SNDFILE_LIBRARY
lib64 lib
)
-# handle the QUIETLY and REQUIRED arguments and set SNDFILE_FOUND to TRUE if
+# handle the QUIETLY and REQUIRED arguments and set LIBSNDFILE_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SndFile DEFAULT_MSG
- SNDFILE_LIBRARY SNDFILE_INCLUDE_DIR)
+ LIBSNDFILE_LIBRARY LIBSNDFILE_INCLUDE_DIR)
-IF(SNDFILE_FOUND)
- SET(SNDFILE_LIBRARIES ${SNDFILE_LIBRARY})
- SET(SNDFILE_INCLUDE_DIRS ${SNDFILE_INCLUDE_DIR})
-ENDIF(SNDFILE_FOUND)
+IF(LIBSNDFILE_FOUND)
+ SET(LIBSNDFILE_LIBRARIES ${LIBSNDFILE_LIBRARY})
+ SET(LIBSNDFILE_INCLUDE_DIRS ${LIBSNDFILE_INCLUDE_DIR})
+ENDIF(LIBSNDFILE_FOUND)
MARK_AS_ADVANCED(
- SNDFILE_INCLUDE_DIR
- SNDFILE_LIBRARY
+ LIBSNDFILE_INCLUDE_DIR
+ LIBSNDFILE_LIBRARY
)
diff --git a/build_files/cmake/cmake_consistency_check.py b/build_files/cmake/cmake_consistency_check.py
index 3d06790758a..443657532de 100755
--- a/build_files/cmake/cmake_consistency_check.py
+++ b/build_files/cmake/cmake_consistency_check.py
@@ -61,10 +61,8 @@ def replace_line(f, i, text, keep_indent=True):
def source_list(path, filename_check=None):
for dirpath, dirnames, filenames in os.walk(path):
-
# skip '.git'
- if dirpath.startswith("."):
- continue
+ dirnames[:] = [d for d in dirnames if not d.startswith(".")]
for filename in filenames:
if filename_check is None or filename_check(filename):
diff --git a/build_files/cmake/config/blender_full.cmake b/build_files/cmake/config/blender_full.cmake
index 62e2ce1636d..35eba1e6a41 100644
--- a/build_files/cmake/config/blender_full.cmake
+++ b/build_files/cmake/config/blender_full.cmake
@@ -66,9 +66,7 @@ elseif(WIN32)
set(WITH_OPENSUBDIV ON CACHE BOOL "" FORCE)
elseif(APPLE)
set(WITH_JACK ON CACHE BOOL "" FORCE)
- set(WITH_CODEC_QUICKTIME OFF CACHE BOOL "" FORCE)
set(WITH_OPENSUBDIV OFF CACHE BOOL "" FORCE)
# include("${CMAKE_CURRENT_SOURCE_DIR}/../platform/platform_apple_xcode.cmake")
-# apple_check_quicktime()
endif()
diff --git a/build_files/cmake/config/blender_lite.cmake b/build_files/cmake/config/blender_lite.cmake
index 537134eb357..98818d4ab50 100644
--- a/build_files/cmake/config/blender_lite.cmake
+++ b/build_files/cmake/config/blender_lite.cmake
@@ -56,7 +56,3 @@ set(WITH_SDL OFF CACHE BOOL "" FORCE)
set(WITH_X11_XINPUT OFF CACHE BOOL "" FORCE)
set(WITH_X11_XF86VMODE OFF CACHE BOOL "" FORCE)
-if(APPLE)
- set(WITH_CODEC_QUICKTIME OFF CACHE BOOL "" FORCE)
-endif()
-
diff --git a/build_files/cmake/config/blender_release.cmake b/build_files/cmake/config/blender_release.cmake
index 3e2e26e6a44..3cdbfdfcf3b 100644
--- a/build_files/cmake/config/blender_release.cmake
+++ b/build_files/cmake/config/blender_release.cmake
@@ -67,9 +67,7 @@ elseif(WIN32)
set(WITH_OPENSUBDIV ON CACHE BOOL "" FORCE)
elseif(APPLE)
set(WITH_JACK ON CACHE BOOL "" FORCE)
- set(WITH_CODEC_QUICKTIME OFF CACHE BOOL "" FORCE)
set(WITH_OPENSUBDIV OFF CACHE BOOL "" FORCE)
# include("${CMAKE_CURRENT_SOURCE_DIR}/../platform/platform_apple_xcode.cmake")
-# apple_check_quicktime()
endif()
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index 836fd5f1a6b..62caf31dfd6 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -318,7 +318,7 @@ function(SETUP_LIBDIRS)
link_directories(${JACK_LIBPATH})
endif()
if(WITH_CODEC_SNDFILE)
- link_directories(${SNDFILE_LIBPATH})
+ link_directories(${LIBSNDFILE_LIBPATH})
endif()
if(WITH_FFTW3)
link_directories(${FFTW3_LIBPATH})
@@ -398,14 +398,11 @@ function(setup_liblinks
target_link_libraries(${target} ${JACK_LIBRARIES})
endif()
if(WITH_CODEC_SNDFILE)
- target_link_libraries(${target} ${SNDFILE_LIBRARIES})
+ target_link_libraries(${target} ${LIBSNDFILE_LIBRARIES})
endif()
if(WITH_SDL AND NOT WITH_SDL_DYNLOAD)
target_link_libraries(${target} ${SDL_LIBRARY})
endif()
- if(WITH_CODEC_QUICKTIME)
- target_link_libraries(${target} ${QUICKTIME_LIBRARIES})
- endif()
if(WITH_IMAGE_TIFF)
target_link_libraries(${target} ${TIFF_LIBRARY})
endif()
@@ -549,6 +546,12 @@ function(SETUP_BLENDER_SORTED_LIBS)
endif()
endif()
+ if(WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE)
+ list(APPEND BLENDER_LINK_LIBS
+ audaspace
+ audaspace-py)
+ endif()
+
# Sort libraries
set(BLENDER_SORTED_LIBS
bf_windowmanager
@@ -599,6 +602,7 @@ function(SETUP_BLENDER_SORTED_LIBS)
bf_python
bf_python_ext
bf_python_mathutils
+ bf_python_gawain
bf_python_bmesh
bf_freestyle
bf_ikplugin
@@ -654,6 +658,8 @@ function(SETUP_BLENDER_SORTED_LIBS)
bf_blenfont
bf_blentranslation
bf_intern_audaspace
+ audaspace
+ audaspace-py
bf_intern_mikktspace
bf_intern_dualcon
bf_intern_cycles
@@ -721,10 +727,6 @@ function(SETUP_BLENDER_SORTED_LIBS)
list(APPEND BLENDER_SORTED_LIBS bf_intern_itasc)
endif()
- if(WITH_CODEC_QUICKTIME)
- list(APPEND BLENDER_SORTED_LIBS bf_quicktime)
- endif()
-
if(WITH_MOD_BOOLEAN)
list(APPEND BLENDER_SORTED_LIBS extern_carve)
endif()
@@ -1509,6 +1511,7 @@ function(find_python_package
NAMES
${package}
HINTS
+ "${PYTHON_LIBPATH}/"
"${PYTHON_LIBPATH}/python${PYTHON_VERSION}/"
"${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/"
PATH_SUFFIXES
diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake
index 5336024b75c..1494b296eb5 100644
--- a/build_files/cmake/platform/platform_apple.cmake
+++ b/build_files/cmake/platform/platform_apple.cmake
@@ -30,11 +30,7 @@ macro(find_package_wrapper)
endmacro()
if(NOT DEFINED LIBDIR)
- if(WITH_CXX11)
- set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin)
- else()
- set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-9.x.universal)
- endif()
+ set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin)
else()
message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}")
endif()
@@ -46,7 +42,7 @@ if(WITH_OPENAL)
find_package(OpenAL)
if(OPENAL_FOUND)
set(WITH_OPENAL ON)
- set(OPENAL_INCLUDE_DIR "${LIBDIR}/openal/include")
+ set(OPENAL_INCLUDE_DIR "${LIBDIR}/openal/include/AL")
else()
set(WITH_OPENAL OFF)
endif()
@@ -82,20 +78,20 @@ if(WITH_JACK)
endif()
if(WITH_CODEC_SNDFILE)
- set(SNDFILE ${LIBDIR}/sndfile)
- set(SNDFILE_INCLUDE_DIRS ${SNDFILE}/include)
- set(SNDFILE_LIBRARIES sndfile FLAC ogg vorbis vorbisenc)
- set(SNDFILE_LIBPATH ${SNDFILE}/lib ${LIBDIR}/ffmpeg/lib) # TODO, deprecate
+ set(LIBSNDFILE ${LIBDIR}/sndfile)
+ set(LIBSNDFILE_INCLUDE_DIRS ${LIBSNDFILE}/include)
+ set(LIBSNDFILE_LIBRARIES sndfile FLAC ogg vorbis vorbisenc)
+ set(LIBSNDFILE_LIBPATH ${LIBSNDFILE}/lib ${LIBDIR}/ffmpeg/lib) # TODO, deprecate
endif()
if(WITH_PYTHON)
# we use precompiled libraries for py 3.5 and up by default
- set(PYTHON_VERSION 3.5)
+ set(PYTHON_VERSION 3.6)
if(NOT WITH_PYTHON_MODULE AND NOT WITH_PYTHON_FRAMEWORK)
# normally cached but not since we include them with blender
set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}m")
set(PYTHON_EXECUTABLE "${LIBDIR}/python/bin/python${PYTHON_VERSION}m")
- set(PYTHON_LIBRARY python${PYTHON_VERSION}m)
+ set(PYTHON_LIBRARY ${LIBDIR}/python/lib/libpython${PYTHON_VERSION}m.a)
set(PYTHON_LIBPATH "${LIBDIR}/python/lib/python${PYTHON_VERSION}")
# set(PYTHON_LINKFLAGS "-u _PyMac_Error") # won't build with this enabled
else()
@@ -115,6 +111,9 @@ if(WITH_PYTHON)
set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
set(PYTHON_LIBRARIES "${PYTHON_LIBRARY}")
+ # needed for Audaspace, numpy is installed into python site-packages
+ set(NUMPY_INCLUDE_DIRS "${PYTHON_LIBPATH}/site-packages/numpy/core/include")
+
if(NOT EXISTS "${PYTHON_EXECUTABLE}")
message(FATAL_ERROR "Python executable missing: ${PYTHON_EXECUTABLE}")
endif()
@@ -143,11 +142,7 @@ if(WITH_IMAGE_OPENEXR)
set(OPENEXR ${LIBDIR}/openexr)
set(OPENEXR_INCLUDE_DIR ${OPENEXR}/include)
set(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIR} ${OPENEXR}/include/OpenEXR)
- if(WITH_CXX11)
- set(OPENEXR_POSTFIX -2_2)
- else()
- set(OPENEXR_POSTFIX)
- endif()
+ set(OPENEXR_POSTFIX -2_2)
set(OPENEXR_LIBRARIES
Iex${OPENEXR_POSTFIX}
Half
@@ -164,20 +159,16 @@ if(WITH_CODEC_FFMPEG)
avcodec avdevice avformat avutil
mp3lame swscale x264 xvidcore theora theoradec theoraenc vorbis vorbisenc vorbisfile ogg
)
- if(WITH_CXX11)
- set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} schroedinger orc vpx webp swresample)
- endif()
+ set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} schroedinger orc vpx webp swresample)
set(FFMPEG_LIBPATH ${FFMPEG}/lib)
endif()
if(WITH_OPENJPEG OR WITH_CODEC_FFMPEG)
# use openjpeg from libdir that is linked into ffmpeg
- if(WITH_CXX11)
- set(OPENJPEG ${LIBDIR}/openjpeg)
- set(WITH_SYSTEM_OPENJPEG ON)
- set(OPENJPEG_INCLUDE_DIRS ${OPENJPEG}/include)
- set(OPENJPEG_LIBRARIES ${OPENJPEG}/lib/libopenjpeg.a)
- endif()
+ set(OPENJPEG ${LIBDIR}/openjpeg)
+ set(WITH_SYSTEM_OPENJPEG ON)
+ set(OPENJPEG_INCLUDE_DIRS ${OPENJPEG}/include)
+ set(OPENJPEG_LIBRARIES ${OPENJPEG}/lib/libopenjpeg.a)
endif()
find_library(SYSTEMSTUBS_LIBRARY
@@ -194,19 +185,8 @@ set(PLATFORM_CFLAGS "-pipe -funsigned-char")
set(PLATFORM_LINKFLAGS
"-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio"
)
-if(WITH_CODEC_QUICKTIME)
- set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QTKit")
- if(CMAKE_OSX_ARCHITECTURES MATCHES i386)
- set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
- # libSDL still needs 32bit carbon quicktime
- endif()
-endif()
-if(WITH_CXX11)
- list(APPEND PLATFORM_LINKLIBS c++)
-else()
- list(APPEND PLATFORM_LINKLIBS stdc++)
-endif()
+list(APPEND PLATFORM_LINKLIBS c++)
if(WITH_JACK)
set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -F/Library/Frameworks -weak_framework jackmp")
@@ -257,11 +237,7 @@ if(WITH_SDL)
set(SDL_INCLUDE_DIR ${SDL}/include)
set(SDL_LIBRARY SDL2)
set(SDL_LIBPATH ${SDL}/lib)
- if(WITH_CXX11)
- set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework ForceFeedback")
- else()
- set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -lazy_framework ForceFeedback")
- endif()
+ set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework ForceFeedback")
endif()
set(PNG "${LIBDIR}/png")
@@ -282,11 +258,7 @@ endif()
if(WITH_BOOST)
set(BOOST ${LIBDIR}/boost)
set(BOOST_INCLUDE_DIR ${BOOST}/include)
- if(WITH_CXX11)
- set(BOOST_POSTFIX)
- else()
- set(BOOST_POSTFIX -mt)
- endif()
+ set(BOOST_POSTFIX)
set(BOOST_LIBRARIES
boost_date_time${BOOST_POSTFIX}
boost_filesystem${BOOST_POSTFIX}
@@ -323,9 +295,7 @@ if(WITH_OPENIMAGEIO)
${OPENEXR_LIBRARIES}
${ZLIB_LIBRARIES}
)
- if(WITH_CXX11)
- set(OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO_LIBRARIES} ${LIBDIR}/ffmpeg/lib/libwebp.a)
- endif()
+ set(OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO_LIBRARIES} ${LIBDIR}/ffmpeg/lib/libwebp.a)
set(OPENIMAGEIO_LIBPATH
${OPENIMAGEIO}/lib
${JPEG_LIBPATH}
@@ -463,10 +433,8 @@ set(PLATFORM_LINKFLAGS
"${PLATFORM_LINKFLAGS} -Xlinker -unexported_symbols_list -Xlinker ${CMAKE_SOURCE_DIR}/source/creator/osx_locals.map"
)
-if(WITH_CXX11)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
- set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -stdlib=libc++")
-endif()
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
+set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -stdlib=libc++")
# Suppress ranlib "has no symbols" warnings (workaround for T48250)
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
diff --git a/build_files/cmake/platform/platform_apple_xcode.cmake b/build_files/cmake/platform/platform_apple_xcode.cmake
index e76a7783939..8bb08b5a29f 100644
--- a/build_files/cmake/platform/platform_apple_xcode.cmake
+++ b/build_files/cmake/platform/platform_apple_xcode.cmake
@@ -101,21 +101,14 @@ if(OSX_SYSTEM MATCHES 10.9)
set(CMAKE_FIND_ROOT_PATH ${CMAKE_OSX_SYSROOT})
endif()
-if(WITH_CXX11)
- # 10.9 is our min. target, if you use higher sdk, weak linking happens
- if(CMAKE_OSX_DEPLOYMENT_TARGET)
- if(${CMAKE_OSX_DEPLOYMENT_TARGET} VERSION_LESS 10.9)
- message(STATUS "Setting deployment target to 10.9, lower versions are incompatible with WITH_CXX11")
- set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "" FORCE)
- endif()
- else()
+# 10.9 is our min. target, if you use higher sdk, weak linking happens
+if(CMAKE_OSX_DEPLOYMENT_TARGET)
+ if(${CMAKE_OSX_DEPLOYMENT_TARGET} VERSION_LESS 10.9)
+ message(STATUS "Setting deployment target to 10.9, lower versions are incompatible with WITH_CXX11")
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "" FORCE)
endif()
else()
- if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
- # 10.6 is our min. target, if you use higher sdk, weak linking happens
- set(CMAKE_OSX_DEPLOYMENT_TARGET "10.6" CACHE STRING "" FORCE)
- endif()
+ set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "" FORCE)
endif()
if(NOT ${CMAKE_GENERATOR} MATCHES "Xcode")
@@ -124,12 +117,3 @@ if(NOT ${CMAKE_GENERATOR} MATCHES "Xcode")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
add_definitions("-DMACOSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}")
endif()
-
-macro(apple_check_quicktime)
- # QuickTime framework is no longer available in SDK 10.12+
- if(WITH_CODEC_QUICKTIME AND ${OSX_SYSTEM} VERSION_GREATER 10.11)
- set(WITH_CODEC_QUICKTIME OFF CACHE BOOL "" FORCE)
- message(STATUS "QuickTime not supported by SDK ${OSX_SYSTEM}, disabling WITH_CODEC_QUICKTIME")
- endif()
-endmacro()
-
diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake
index 62e0caa7c43..3581fe64341 100644
--- a/build_files/cmake/platform/platform_unix.cmake
+++ b/build_files/cmake/platform/platform_unix.cmake
@@ -135,7 +135,7 @@ endif()
# Codecs
if(WITH_CODEC_SNDFILE)
find_package_wrapper(SndFile)
- if(NOT SNDFILE_FOUND)
+ if(NOT LIBSNDFILE_FOUND)
set(WITH_CODEC_SNDFILE OFF)
endif()
endif()
@@ -400,10 +400,6 @@ if(CMAKE_COMPILER_IS_GNUCC)
# CLang is the same as GCC for now.
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
-# Solaris CC
-elseif(CMAKE_C_COMPILER_ID MATCHES "SunPro")
- set(PLATFORM_CFLAGS "-pipe -features=extensions -fPIC -D__FUNCTION__=__func__")
-
# Intel C++ Compiler
elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
# think these next two are broken
diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake
index 2f5d41dac32..4d2342e490e 100644
--- a/build_files/cmake/platform/platform_win32.cmake
+++ b/build_files/cmake/platform/platform_win32.cmake
@@ -36,7 +36,7 @@ set(WINTAB_INC ${LIBDIR}/wintab/include)
if(WITH_OPENAL)
set(OPENAL ${LIBDIR}/openal)
set(OPENALDIR ${LIBDIR}/openal)
- set(OPENAL_INCLUDE_DIR ${OPENAL}/include)
+ set(OPENAL_INCLUDE_DIR ${OPENAL}/include/AL)
if(MSVC)
set(OPENAL_LIBRARY openal32)
else()
@@ -46,10 +46,10 @@ if(WITH_OPENAL)
endif()
if(WITH_CODEC_SNDFILE)
- set(SNDFILE ${LIBDIR}/sndfile)
- set(SNDFILE_INCLUDE_DIRS ${SNDFILE}/include)
- set(SNDFILE_LIBRARIES libsndfile-1)
- set(SNDFILE_LIBPATH ${SNDFILE}/lib) # TODO, deprecate
+ set(LIBSNDFILE ${LIBDIR}/sndfile)
+ set(LIBSNDFILE_INCLUDE_DIRS ${LIBSNDFILE}/include)
+ set(LIBSNDFILE_LIBRARIES libsndfile-1)
+ set(LIBSNDFILE_LIBPATH ${LIBSNDFILE}/lib) # TODO, deprecate
endif()
if(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
diff --git a/build_files/cmake/platform/platform_win32_msvc.cmake b/build_files/cmake/platform/platform_win32_msvc.cmake
index 3b417f79cbe..47dd0edc8ba 100644
--- a/build_files/cmake/platform/platform_win32_msvc.cmake
+++ b/build_files/cmake/platform/platform_win32_msvc.cmake
@@ -134,7 +134,10 @@ if(NOT DEFINED LIBDIR)
message(STATUS "32 bit compiler detected.")
set(LIBDIR_BASE "windows")
endif()
- if(MSVC_VERSION EQUAL 1910)
+ if(MSVC_VERSION EQUAL 1911)
+ message(STATUS "Visual Studio 2017 detected.")
+ set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc14)
+ elseif(MSVC_VERSION EQUAL 1910)
message(STATUS "Visual Studio 2017 detected.")
set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc14)
elseif(MSVC_VERSION EQUAL 1900)
@@ -299,7 +302,7 @@ if(WITH_JACK)
endif()
if(WITH_PYTHON)
- set(PYTHON_VERSION 3.5) # CACHE STRING)
+ set(PYTHON_VERSION 3.6) # CACHE STRING)
string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
# Use shared libs for vc2008 and vc2010 until we actually have vc2010 libs
diff --git a/build_files/cmake/project_info.py b/build_files/cmake/project_info.py
index 3ac4c4c9480..9b0905da030 100755
--- a/build_files/cmake/project_info.py
+++ b/build_files/cmake/project_info.py
@@ -84,10 +84,8 @@ def init(cmake_path):
def source_list(path, filename_check=None):
for dirpath, dirnames, filenames in os.walk(path):
-
- # skip '.svn'
- if dirpath.startswith("."):
- continue
+ # skip '.git'
+ dirnames[:] = [d for d in dirnames if not d.startswith(".")]
for filename in filenames:
filepath = join(dirpath, filename)
diff --git a/build_files/utils/build_tgz.sh b/build_files/utils/build_tgz.sh
index 865df277605..c568d17db1c 100755
--- a/build_files/utils/build_tgz.sh
+++ b/build_files/utils/build_tgz.sh
@@ -53,7 +53,11 @@ echo "OK"
# Create the tarball
cd "$blender_srcdir"
echo -n "Creating archive: \"$BASE_DIR/$TARBALL\" ..."
-GZIP=-9 tar --transform "s,^,blender-$VERSION/,g" -zcf "$BASE_DIR/$TARBALL" -T "$BASE_DIR/$MANIFEST"
+tar --transform "s,^,blender-$VERSION/,g" \
+ --use-compress-program="gzip --best" \
+ --create \
+ --file="$BASE_DIR/$TARBALL" \
+ --files-from="$BASE_DIR/$MANIFEST"
echo "OK"
diff --git a/doc/doxygen/Doxyfile b/doc/doxygen/Doxyfile
index 8b3a97816ba..a3ccf9227d3 100644
--- a/doc/doxygen/Doxyfile
+++ b/doc/doxygen/Doxyfile
@@ -38,7 +38,7 @@ PROJECT_NAME = Blender
# could be handy for archiving the generated documentation or if some version
# control system is used.
-PROJECT_NUMBER = "V2.8x"
+PROJECT_NUMBER = "V2.79"
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
diff --git a/doc/doxygen/doxygen.source.h b/doc/doxygen/doxygen.source.h
index 6f12991fb44..da58584ab36 100644
--- a/doc/doxygen/doxygen.source.h
+++ b/doc/doxygen/doxygen.source.h
@@ -160,9 +160,6 @@
* merged in docs.
*/
-/** \defgroup quicktime QuickTime
- * \ingroup blender
-
/** \defgroup gui GUI */
/** \defgroup wm Window Manager
diff --git a/doc/guides/python-dev-guide.txt b/doc/guides/python-dev-guide.txt
deleted file mode 100644
index 75c9ccb57e5..00000000000
--- a/doc/guides/python-dev-guide.txt
+++ /dev/null
@@ -1,170 +0,0 @@
-Simple Blender Python Developer's Guide
----------------------------------------
-
-This is an outline for a future guide yet to be written. It is meant for
-programmers wanting to understand and maybe help with the embedding of Python
-inside Blender.
-
-I - Introduction
-
-We could praise Python here for its many qualities, but it's probably better
-to just give some links:
-
-The main site is at www.python.org , with documentation at www.python.org/doc/
-
-Also worth of mention: it's an interpreted language and is available for
-many different systems. The download includes the interpreter, many modules
-(think libs), good documentation and some programs / examples. If you use
-linux, there's a high chance you already have Python installed, just try
-"man python".
-
-The reason for embedding a language environment inside Blender is to give
-users the ability to access the program's internal data and functionality.
-This can be used to import / export (from / to other 2d / 3d formats) or
-change the data (to create new objects procedurally, among many other
-interesting possibilities). Script writers (Blender Python programmers) can
-also expand Blender in new ways, adding new features on-the-fly, without having
-to recompile it. It is usually much easier and faster to write scripts in
-Python than to code the equivalent in C.
-
-II - Reference material:
-
-There are two important texts for us in the documentation that comes
-with Python ( docs also available online at www.python.org ):
-
-- Extending and Embedding (tutorial for C/C++ programmers)
-
-and specially
-
-- Python/C API.
-
-You can read the first one to get a feel for how things are done
-(reference counting is probably the most important part), but the second
-doc is a must. Specially useful as a fast reference is its Index, at letter
-P, where all commands are.
-
-Specially useful commands are Py_BuildValue and the family of parsing
-functions, PyArg_Parse* (PyArg_Parse(), PyArg_ParseTuple(),
-PyArg_ParseTupleAndKeywords()). Py_BuildValue is usually the best way to make
-Python Objects (the 'variables' that the Python Interpreter understands)
-out of C ones. The PyArg_Parse* functions do the opposite, they parse
-Python Objects to C variables.
-
-So, understand PyArg_Parse* functions, Py_BuildValue and reference
-counting. The first doc has a good discussion about them.
-
-- C knowledge is also necessary, of course, use your favorite resource.
-
-- The Blender 2.25 API documentation ( www.blender.org ) is, along with
-the source, our basic API ref.
-
-III - Directories
-
-The previous Blender Python API's are spread in blender/intern/python
-and the C part of the current one, bpython, is at
-blender/source/blender/bpython/, specially in intern/. The current
-solution is a Python wrapper on top of this bpython one, at
-blender/intern/python/modules/Blender/
-
-Note: since it's in Python, they needed the freeze Python utility, a
-process/program that creates stand-alone executables out of Python
-source files -- that is, it packs together an interpreter, the needed
-modules and the source of a Python program so that users of this program
-don't need to have the Python interpreter already installed in their
-machines to run the program -- Blender, in this case.
-
-The new implementation is pure C, so we won't need to "freeze" it.
-
-Another important dir for starters is blender/source/blender/makesdna,
-where the headers with Blender structs lie.
-
-IV - Experimental Python
-
-The new implementation, currently referred to as experimental python -
-exppython - was started by Michel Selten. He chose to solve the mess in
-Blender Python by starting over from scratch, in C, but keeping API
-compatibility with the current 2.25 API used by Blender.
-
-It is in blender/source/blender/python , more specifically inside
-api2_2x/
-
-To make it clear, exppython is the new implementation being worked on. It
-will possibly become the de-facto implementation in Blender 2.28, the next
-Blender version. Currently, Blender still comes with the same implementation
-found in the 2.25 version of the program. So we call that the 2.25
-implementation, or bpython.
-
-BPython had plenty of "macro magic", lot's of complicate #define's, etc.,
-since a lot of the embedding work is quite repetitive. But that makes it
-much harder for newbies to jump in and learn, so the new files in exppython
-avoid that.
-
-This means: Blender, Object, Camera, Lamp, Image, Text, Window modules
-(the files have the same names, ending obviously with .c and .h)
-
-To speed things up, some independent parts of bpython are being
-integrated directly into exppython. That already happened with Draw and
-BGL, both taken from opy_draw.c in the bpython/intern dir. The same is
-happening with NMesh (Mesh is written in Python and imports NMesh to
-extend / change its functionality).
-
-For a good example of dexterity with macros (cheers to the NaN
-programmer(s)!), look at BGL.[ch], the OpenGL API wrapper. The defines
-are in the header.
-
-Besides keeping compatibility with the 2.25 API, there are already some
-additions to exppython:
-
-- some modules have access to more variables than 2.25 had;
-- there are more method functions and the access is safer;
-- the file selector (or file browser, if you prefer) is back:
- It's now in the Window module, along with an image selector, too.
-- there are totally new modules, unavailable in 2.25:
- Fellow new developers joining our team are contributing new modules
- that have been requested by the community for a long time.
-
-
-V - Coding
-
-The Camera module is a good reference, since it is like most others, in
-terms of programming, but is smaller and simple. It's in Camera.c and
-Camera.h . To have it working, it was also necessary to include a line to
-the end of Blender.c (registering it as a Blender submodule) and another to
-modules.h (declaring its init and CreateObject method)
-
-Currently, one of our conventions is to prepend M_ to module functions,
-doc strings, etc. and C_ to the new types we had to create for Python,
-like C_Camera, C_Lamp, etc.
-
-If you look at Camera.[ch], you'll find code for creating the Camera
-module and the Camera "type", with all its methods and access policies.
-It's really a new type defined in Python, like PyInt or PyFloat,
-PyString, etc. In practice, it's a "thin" (because it doesn't make
-copies of the variables) wrapper for the Blender Camera Data Object.
-
-A note about Blender: objects in Blender share a common base, the
-Object, whose attributes are things like the matrix, the location, the
-rotation, the size, etc. A Camera is actually an Object of type Camera
-(which means that its "data" field points to a Camera Data obj) and a
-Camera Data object, which is the specific camera part of the object
-(attributes like lens, clip start, etc.). Same for other objects, like
-Lamp, Mesh, etc.
-
-That's why C_Camera is a wrapper for the Blender Camera **Data**
-object. The full wrapper is Object("Camera") linked with
-Camera("camera_name").
-
-How to write a new module for a simple object? Use Camera.[ch] as
-templates, check the specifics of your object in the makesdna dir
-(for example, the camera one is DNA_camera_types.h) and make the
-necessary changes.
-
-If you want to help exppython and in the process possibly learn more about
-embedding, the Python/C API and Blender internals, there's this mailing list:
-
-Bf-python mailing list
-Bf-python@blender.org
-http://www.blender.org/mailman/listinfo/bf-python
-
-There you can ask what hasn't been done yet, get help, make suggestions for
-new features we should consider, send bug reports, etc.
diff --git a/doc/python_api/examples/bmesh.ops.1.py b/doc/python_api/examples/bmesh.ops.1.py
index abce087ceb3..b307624467f 100644
--- a/doc/python_api/examples/bmesh.ops.1.py
+++ b/doc/python_api/examples/bmesh.ops.1.py
@@ -12,7 +12,7 @@ bm = bmesh.new()
bmesh.ops.create_circle(
bm,
cap_ends=False,
- diameter=0.2,
+ radius=0.2,
segments=8)
diff --git a/doc/python_api/rst/bge_types/bge.types.BL_ShapeActionActuator.rst b/doc/python_api/rst/bge_types/bge.types.BL_ShapeActionActuator.rst
index d08a761ed95..4bb3d273cb9 100644
--- a/doc/python_api/rst/bge_types/bge.types.BL_ShapeActionActuator.rst
+++ b/doc/python_api/rst/bge_types/bge.types.BL_ShapeActionActuator.rst
@@ -59,7 +59,7 @@ base class --- :class:`SCA_IActuator`
.. attribute:: mode
- The operation mode of the actuator. Can be one of :ref:`these constants<shape-action-actuator>`.
+ The operation mode of the actuator. Can be one of :ref:`these constants<action-actuator>`.
:type: integer
@@ -68,5 +68,3 @@ base class --- :class:`SCA_IActuator`
The name of the property that is set to the current frame number.
:type: string
-
-
diff --git a/doc/python_api/rst/change_log.rst b/doc/python_api/rst/change_log.rst
index 5a3bf2a6d8d..21c7cf96135 100644
--- a/doc/python_api/rst/change_log.rst
+++ b/doc/python_api/rst/change_log.rst
@@ -1,3 +1,5 @@
+:tocdepth: 2
+
Blender API Change Log
**********************
@@ -5648,3 +5650,5652 @@ Added
* :class:`bpy.types.SceneRenderLayer.freestyle_settings`
* :class:`bpy.types.SceneRenderLayer.use_freestyle`
+
+2.67 to 2.68
+============
+
+bpy.types.BlendDataTexts
+------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataTexts.load` (filepath, internal), *was (filepath)*
+
+bpy.types.DopeSheet
+-------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.DopeSheet.show_modifiers`
+
+bpy.types.Armature
+------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Armature.is_editmode`
+
+bpy.types.Curve
+---------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Curve.is_editmode`
+
+bpy.types.Lattice
+-----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Lattice.is_editmode`
+
+bpy.types.Mesh
+--------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Mesh.calc_smooth_groups`
+* :class:`bpy.types.Mesh.is_editmode`
+
+bpy.types.MetaBall
+------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MetaBall.is_editmode`
+
+bpy.types.ParticleSettings
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ParticleSettings.use_modifier_stack`
+
+bpy.types.WindowManager
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.WindowManager.popup_menu`
+* :class:`bpy.types.WindowManager.pupmenu_begin__internal`
+* :class:`bpy.types.WindowManager.pupmenu_end__internal`
+
+bpy.types.World
+---------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.World.cycles_visibility`
+
+bpy.types.MaskSpline
+--------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MaskSpline.points`
+
+bpy.types.MaskSplines
+---------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MaskSplines.new`
+* :class:`bpy.types.MaskSplines.remove`
+
+Removed
+^^^^^^^
+
+* **add**
+
+bpy.types.MeshPolygon
+---------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MeshPolygon.center`
+
+bpy.types.DecimateModifier
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.DecimateModifier.delimit`
+
+bpy.types.MovieTrackingSettings
+-------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MovieTrackingSettings.use_keyframe_selection`
+
+bpy.types.Node
+--------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Node.dimensions`
+
+bpy.types.NodeSocket
+--------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.NodeSocket.hide_value`
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.NodeSocket.draw` (context, layout, node, text), *was (context, layout, node)*
+
+bpy.types.NodeSocketStandard
+----------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.NodeSocketStandard.draw` (context, layout, node, text), *was (context, layout, node)*
+
+bpy.types.NodeSocketInterfaceStandard
+-------------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.NodeSocketInterfaceStandard.type`
+
+bpy.types.NodeTreeInputs
+------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.NodeTreeInputs.move`
+
+bpy.types.NodeTreeOutputs
+-------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.NodeTreeOutputs.move`
+
+bpy.types.CyclesMaterialSettings
+--------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CyclesMaterialSettings.use_transparent_shadow`
+
+bpy.types.CyclesRenderSettings
+------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CyclesRenderSettings.sampling_pattern`
+
+bpy.types.RenderEngine
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.RenderEngine.bl_use_exclude_layers`
+* :class:`bpy.types.RenderEngine.bl_use_save_buffers`
+
+bpy.types.SmokeDomainSettings
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SmokeDomainSettings.highres_sampling`
+
+Removed
+^^^^^^^
+
+* **use_smooth_emitter**
+
+bpy.types.SmokeFlowSettings
+---------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SmokeFlowSettings.particle_size`
+* :class:`bpy.types.SmokeFlowSettings.subframes`
+* :class:`bpy.types.SmokeFlowSettings.use_particle_size`
+
+bpy.types.SpaceProperties
+-------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SpaceProperties.use_limited_texture_context`
+
+bpy.types.SpaceView3D
+---------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SpaceView3D.transform_manipulators`
+
+Removed
+^^^^^^^
+
+* **use_manipulator_rotate**
+* **use_manipulator_scale**
+* **use_manipulator_translate**
+
+bpy.types.ThemeFontStyle
+------------------------
+
+Renamed
+^^^^^^^
+
+* **shadowalpha** -> :class:`bpy.types.ThemeFontStyle.shadow_alpha`
+* **shadowcolor** -> :class:`bpy.types.ThemeFontStyle.shadow_value`
+
+bpy.types.ThemeView3D
+---------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ThemeView3D.wire_edit`
+
+bpy.types.ToolSettings
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ToolSettings.vertex_group_subset`
+
+bpy.types.UserPreferences
+-------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.UserPreferences.autoexec_paths`
+
+2.68 to 2.69
+============
+
+bpy.types.ActionActuator
+------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ActionActuator.blend_mode`
+
+bpy.types.ColorManagedViewSettings
+----------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ColorManagedViewSettings.look`
+
+bpy.types.ShrinkwrapConstraint
+------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ShrinkwrapConstraint.project_axis`
+* :class:`bpy.types.ShrinkwrapConstraint.project_axis_space`
+* :class:`bpy.types.ShrinkwrapConstraint.project_limit`
+
+Removed
+^^^^^^^
+
+* **use_x**
+* **use_y**
+* **use_z**
+
+bpy.types.CurveMapping
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CurveMapping.initialize`
+
+bpy.types.DynamicPaintSurface
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.DynamicPaintSurface.wave_smoothness`
+
+bpy.types.Mesh
+--------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Mesh.calc_normals_split`
+* :class:`bpy.types.Mesh.free_normals_split`
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.Mesh.calc_smooth_groups` (use_bitflags), *was ()*
+
+bpy.types.Scene
+---------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Scene.frame_current_final`
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.Scene.collada_export` (filepath, apply_modifiers, export_mesh_type, selected, include_children, include_armatures, include_shapekeys, deform_bones_only, active_uv_only, include_uv_textures, include_material_textures, use_texture_copies, use_ngons, use_object_instantiation, sort_by_name, open_sim, export_transformation_type), *was (filepath, apply_modifiers, export_mesh_type, selected, include_children, include_armatures, include_shapekeys, deform_bones_only, active_uv_only, include_uv_textures, include_material_textures, use_texture_copies, use_ngons, use_object_instantiation, sort_by_name, second_life, export_transformation_type)*
+
+bpy.types.Text
+--------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Text.current_line_index`
+
+bpy.types.IDMaterials
+---------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.IDMaterials.clear`
+
+bpy.types.KeyMaps
+-----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.KeyMaps.remove`
+
+bpy.types.MaskParent
+--------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MaskParent.type`
+
+bpy.types.MeshLoop
+------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MeshLoop.normal`
+
+bpy.types.SimpleDeformModifier
+------------------------------
+
+Removed
+^^^^^^^
+
+* **use_relative**
+
+bpy.types.MovieTracking
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MovieTracking.plane_tracks`
+
+bpy.types.MovieTrackingObject
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MovieTrackingObject.plane_tracks`
+
+bpy.types.ShaderNodeMapping
+---------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ShaderNodeMapping.vector_type`
+
+bpy.types.ShaderNodeSubsurfaceScattering
+----------------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ShaderNodeSubsurfaceScattering.falloff`
+
+bpy.types.ShaderNodeTexSky
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ShaderNodeTexSky.ground_albedo`
+* :class:`bpy.types.ShaderNodeTexSky.sky_type`
+
+bpy.types.ParticleSystem
+------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.ParticleSystem.co_hair` (object, particle_no, step), *was (object, modifier, particle_no, step)*
+
+bpy.types.Property
+------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Property.is_argument_optional`
+
+bpy.types.CyclesCurveRenderSettings
+-----------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CyclesCurveRenderSettings.cull_backfacing`
+* :class:`bpy.types.CyclesCurveRenderSettings.shape`
+
+Removed
+^^^^^^^
+
+* **encasing_ratio**
+* **interpolation**
+* **line_method**
+* **normalmix**
+* **preset**
+* **segments**
+* **triangle_method**
+* **use_backfacing**
+* **use_encasing**
+* **use_joined**
+* **use_parents**
+* **use_smooth**
+* **use_tangent_normal**
+* **use_tangent_normal_correction**
+* **use_tangent_normal_geometry**
+
+bpy.types.CyclesRenderSettings
+------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CyclesRenderSettings.use_square_samples`
+
+bpy.types.RenderEngine
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.RenderEngine.bind_display_space_shader`
+* :class:`bpy.types.RenderEngine.support_display_space_shader`
+* :class:`bpy.types.RenderEngine.unbind_display_space_shader`
+
+bpy.types.RenderLayer
+---------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.RenderLayer.use_pass_subsurface_color`
+* :class:`bpy.types.RenderLayer.use_pass_subsurface_direct`
+* :class:`bpy.types.RenderLayer.use_pass_subsurface_indirect`
+
+bpy.types.SceneGameData
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SceneGameData.vsync`
+
+bpy.types.SceneRenderLayer
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SceneRenderLayer.use_pass_subsurface_color`
+* :class:`bpy.types.SceneRenderLayer.use_pass_subsurface_direct`
+* :class:`bpy.types.SceneRenderLayer.use_pass_subsurface_indirect`
+
+bpy.types.SpaceNodeEditor
+-------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SpaceNodeEditor.cursor_location_from_region`
+
+bpy.types.SpaceTextEditor
+-------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SpaceTextEditor.top`
+* :class:`bpy.types.SpaceTextEditor.visible_lines`
+
+bpy.types.SpaceView3D
+---------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SpaceView3D.show_occlude_wire`
+
+bpy.types.TexMapping
+--------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.TexMapping.vector_type`
+
+bpy.types.ThemeImageEditor
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ThemeImageEditor.uv_others`
+* :class:`bpy.types.ThemeImageEditor.uv_shadow`
+
+bpy.types.UILayout
+------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.UILayout.template_list` (listtype_name, list_id, dataptr, propname, active_dataptr, active_propname, rows, maxrows, type, columns), *was (listtype_name, list_id, dataptr, propname, active_dataptr, active_propname, rows, maxrows, type)*
+
+bpy.types.UIList
+----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.UIList.bitflag_filter_item`
+* :class:`bpy.types.UIList.draw_filter`
+* :class:`bpy.types.UIList.filter_items`
+* :class:`bpy.types.UIList.filter_name`
+* :class:`bpy.types.UIList.use_filter_invert`
+* :class:`bpy.types.UIList.use_filter_show`
+* :class:`bpy.types.UIList.use_filter_sort_alpha`
+* :class:`bpy.types.UIList.use_filter_sort_reverse`
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.UIList.draw_item` (context, layout, data, item, icon, active_data, active_property, index, flt_flag), *was (context, layout, data, item, icon, active_data, active_property, index)*
+
+bpy.types.UI_UL_list
+--------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.UI_UL_list.filter_items_by_name`
+* :class:`bpy.types.UI_UL_list.sort_items_by_name`
+* :class:`bpy.types.UI_UL_list.sort_items_helper`
+
+bpy.types.Window
+----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Window.cursor_modal_restore`
+* :class:`bpy.types.Window.cursor_modal_set`
+* :class:`bpy.types.Window.cursor_set`
+* :class:`bpy.types.Window.cursor_warp`
+
+2.69 to 2.70
+============
+
+bpy.types.BlendData
+-------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.BlendData.use_autopack`
+
+bpy.types.ClothSettings
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ClothSettings.sewing_force_max`
+* :class:`bpy.types.ClothSettings.shrink_max`
+* :class:`bpy.types.ClothSettings.shrink_min`
+* :class:`bpy.types.ClothSettings.use_sewing_springs`
+* :class:`bpy.types.ClothSettings.vertex_group_shrink`
+
+bpy.types.DupliObject
+---------------------
+
+Removed
+^^^^^^^
+
+* **matrix_original**
+
+bpy.types.FCurve
+----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.FCurve.update_autoflags`
+
+bpy.types.FModifierNoise
+------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.FModifierNoise.offset`
+
+bpy.types.FreestyleSettings
+---------------------------
+
+Removed
+^^^^^^^
+
+* **raycasting_algorithm**
+
+bpy.types.GameObjectSettings
+----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.GameObjectSettings.use_record_animation`
+
+bpy.types.Armature
+------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Armature.transform`
+
+bpy.types.Brush
+---------------
+
+Renamed
+^^^^^^^
+
+* **use_restore_mesh** -> :class:`bpy.types.Brush.use_drag_dot`
+
+bpy.types.Curve
+---------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Curve.transform`
+
+Removed
+^^^^^^^
+
+* **use_time_offset**
+
+bpy.types.Image
+---------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Image.filepath_from_user`
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.Image.gl_load` (frame, filter, mag), *was (filter, mag)*
+* :class:`bpy.types.Image.gl_touch` (frame, filter, mag), *was (filter, mag)*
+
+bpy.types.Lattice
+-----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Lattice.transform`
+
+bpy.types.Mesh
+--------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Mesh.calc_tangents`
+* :class:`bpy.types.Mesh.free_tangents`
+
+bpy.types.Object
+----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Object.image_user`
+* :class:`bpy.types.Object.lod_levels`
+
+bpy.types.ParticleSettings
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ParticleSettings.material_slot`
+
+bpy.types.Scene
+---------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Scene.lock_frame_selection_to_range`
+
+bpy.types.Texture
+-----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Texture.use_clamp`
+
+bpy.types.World
+---------------
+
+Removed
+^^^^^^^
+
+* **star_settings**
+
+bpy.types.MaskLayer
+-------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MaskLayer.use_fill_holes`
+* :class:`bpy.types.MaskLayer.use_fill_overlap`
+
+bpy.types.Menu
+--------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Menu.draw_collapsible`
+
+bpy.types.MeshLoop
+------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MeshLoop.bitangent`
+* :class:`bpy.types.MeshLoop.bitangent_sign`
+* :class:`bpy.types.MeshLoop.tangent`
+
+bpy.types.BevelModifier
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.BevelModifier.offset_type`
+* :class:`bpy.types.BevelModifier.profile`
+
+bpy.types.BuildModifier
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.BuildModifier.use_reverse`
+
+bpy.types.ScrewModifier
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ScrewModifier.use_stretch_u`
+* :class:`bpy.types.ScrewModifier.use_stretch_v`
+
+bpy.types.TriangulateModifier
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.TriangulateModifier.ngon_method`
+* :class:`bpy.types.TriangulateModifier.quad_method`
+
+Removed
+^^^^^^^
+
+* **use_beauty**
+
+bpy.types.MovieTrackingMarker
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MovieTrackingMarker.is_keyed`
+
+bpy.types.MovieTrackingPlaneTrack
+---------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MovieTrackingPlaneTrack.image`
+* :class:`bpy.types.MovieTrackingPlaneTrack.image_opacity`
+
+bpy.types.MovieTrackingSettings
+-------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MovieTrackingSettings.default_weight`
+* :class:`bpy.types.MovieTrackingSettings.show_extra_expanded`
+
+Removed
+^^^^^^^
+
+* **reconstruction_success_threshold**
+* **use_fallback_reconstruction**
+
+bpy.types.MovieTrackingTrack
+----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MovieTrackingTrack.offset`
+* :class:`bpy.types.MovieTrackingTrack.weight`
+
+bpy.types.Node
+--------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Node.draw_label`
+
+bpy.types.CompositorNodeDefocus
+-------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CompositorNodeDefocus.scene`
+
+bpy.types.CompositorNodeDespeckle
+---------------------------------
+
+Renamed
+^^^^^^^
+
+* **threshold_neighbour** -> :class:`bpy.types.CompositorNodeDespeckle.threshold_neighbor`
+
+bpy.types.ShaderNodeOutput
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ShaderNodeOutput.is_active_output`
+
+bpy.types.ShaderNodeOutputLamp
+------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ShaderNodeOutputLamp.is_active_output`
+
+bpy.types.ShaderNodeOutputMaterial
+----------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ShaderNodeOutputMaterial.is_active_output`
+
+bpy.types.ShaderNodeOutputWorld
+-------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ShaderNodeOutputWorld.is_active_output`
+
+bpy.types.NodeSocket
+--------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.NodeSocket.is_output`
+
+Removed
+^^^^^^^
+
+* **in_out**
+
+bpy.types.NodeSocketInterface
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.NodeSocketInterface.is_output`
+
+Removed
+^^^^^^^
+
+* **in_out**
+
+bpy.types.Paint
+---------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Paint.use_symmetry_feather`
+* :class:`bpy.types.Paint.use_symmetry_x`
+* :class:`bpy.types.Paint.use_symmetry_y`
+* :class:`bpy.types.Paint.use_symmetry_z`
+
+bpy.types.Sculpt
+----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Sculpt.detail_refine_method`
+* :class:`bpy.types.Sculpt.gravity`
+* :class:`bpy.types.Sculpt.gravity_object`
+
+Removed
+^^^^^^^
+
+* **use_edge_collapse**
+* **use_symmetry_feather**
+* **use_symmetry_x**
+* **use_symmetry_y**
+* **use_symmetry_z**
+
+bpy.types.VertexPaint
+---------------------
+
+Removed
+^^^^^^^
+
+* **use_all_faces**
+
+bpy.types.Panel
+---------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Panel.bl_category`
+* :class:`bpy.types.Panel.use_pin`
+
+bpy.types.CyclesRenderSettings
+------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CyclesRenderSettings.sample_clamp_direct`
+* :class:`bpy.types.CyclesRenderSettings.sample_clamp_indirect`
+* :class:`bpy.types.CyclesRenderSettings.volume_bounces`
+* :class:`bpy.types.CyclesRenderSettings.volume_homogeneous_sampling`
+* :class:`bpy.types.CyclesRenderSettings.volume_max_steps`
+* :class:`bpy.types.CyclesRenderSettings.volume_samples`
+* :class:`bpy.types.CyclesRenderSettings.volume_step_size`
+
+Removed
+^^^^^^^
+
+* **sample_clamp**
+
+bpy.types.CyclesWorldSettings
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CyclesWorldSettings.homogeneous_volume`
+
+bpy.types.RenderEngine
+----------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.RenderEngine.end_result` (result, cancel, do_merge_results), *was (result, cancel)*
+
+bpy.types.RenderSettings
+------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.RenderSettings.bake_user_scale`
+* :class:`bpy.types.RenderSettings.use_bake_user_scale`
+* :class:`bpy.types.RenderSettings.use_lock_interface`
+
+bpy.types.RigidBodyObject
+-------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.RigidBodyObject.mesh_source`
+* :class:`bpy.types.RigidBodyObject.use_deform`
+
+bpy.types.SceneRenderLayer
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SceneRenderLayer.pass_alpha_threshold`
+
+bpy.types.SculptToolCapabilities
+--------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SculptToolCapabilities.has_gravity`
+
+bpy.types.SpaceClipEditor
+-------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SpaceClipEditor.mask_overlay_mode`
+* :class:`bpy.types.SpaceClipEditor.show_graph_tracks_error`
+* :class:`bpy.types.SpaceClipEditor.show_mask_overlay`
+
+Renamed
+^^^^^^^
+
+* **show_graph_tracks** -> :class:`bpy.types.SpaceClipEditor.show_graph_tracks_motion`
+
+bpy.types.SpaceGraphEditor
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SpaceGraphEditor.use_auto_normalization`
+* :class:`bpy.types.SpaceGraphEditor.use_normalization`
+
+bpy.types.SpaceImageEditor
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SpaceImageEditor.mask_overlay_mode`
+* :class:`bpy.types.SpaceImageEditor.show_mask_overlay`
+
+bpy.types.SpaceNodeEditor
+-------------------------
+
+Removed
+^^^^^^^
+
+* **use_hidden_preview**
+
+bpy.types.SpaceView3D
+---------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SpaceView3D.show_textured_shadeless`
+
+bpy.types.TextCharacterFormat
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.TextCharacterFormat.material_index`
+
+bpy.types.ThemeDopeSheet
+------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ThemeDopeSheet.keyframe`
+* :class:`bpy.types.ThemeDopeSheet.keyframe_border`
+* :class:`bpy.types.ThemeDopeSheet.keyframe_border_selected`
+* :class:`bpy.types.ThemeDopeSheet.keyframe_breakdown`
+* :class:`bpy.types.ThemeDopeSheet.keyframe_breakdown_selected`
+* :class:`bpy.types.ThemeDopeSheet.keyframe_extreme`
+* :class:`bpy.types.ThemeDopeSheet.keyframe_extreme_selected`
+* :class:`bpy.types.ThemeDopeSheet.keyframe_jitter`
+* :class:`bpy.types.ThemeDopeSheet.keyframe_jitter_selected`
+* :class:`bpy.types.ThemeDopeSheet.keyframe_selected`
+
+bpy.types.ThemeImageEditor
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ThemeImageEditor.edge_select`
+* :class:`bpy.types.ThemeImageEditor.wire_edit`
+
+bpy.types.ThemeInfo
+-------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ThemeInfo.info_debug`
+* :class:`bpy.types.ThemeInfo.info_debug_text`
+* :class:`bpy.types.ThemeInfo.info_error`
+* :class:`bpy.types.ThemeInfo.info_error_text`
+* :class:`bpy.types.ThemeInfo.info_info`
+* :class:`bpy.types.ThemeInfo.info_info_text`
+* :class:`bpy.types.ThemeInfo.info_selected`
+* :class:`bpy.types.ThemeInfo.info_selected_text`
+* :class:`bpy.types.ThemeInfo.info_warning`
+* :class:`bpy.types.ThemeInfo.info_warning_text`
+
+bpy.types.ThemeNLAEditor
+------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ThemeNLAEditor.keyframe_border`
+* :class:`bpy.types.ThemeNLAEditor.keyframe_border_selected`
+
+bpy.types.ThemeNodeEditor
+-------------------------
+
+Removed
+^^^^^^^
+
+* **in_out_node**
+
+Renamed
+^^^^^^^
+
+* **operator_node** -> :class:`bpy.types.ThemeNodeEditor.color_node`
+* **operator_node** -> :class:`bpy.types.ThemeNodeEditor.filter_node`
+* **operator_node** -> :class:`bpy.types.ThemeNodeEditor.input_node`
+* **operator_node** -> :class:`bpy.types.ThemeNodeEditor.layout_node`
+* **operator_node** -> :class:`bpy.types.ThemeNodeEditor.output_node`
+* **operator_node** -> :class:`bpy.types.ThemeNodeEditor.pattern_node`
+* **operator_node** -> :class:`bpy.types.ThemeNodeEditor.script_node`
+* **operator_node** -> :class:`bpy.types.ThemeNodeEditor.shader_node`
+* **operator_node** -> :class:`bpy.types.ThemeNodeEditor.texture_node`
+* **operator_node** -> :class:`bpy.types.ThemeNodeEditor.vector_node`
+
+bpy.types.ThemeSpaceGeneric
+---------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ThemeSpaceGeneric.tab_active`
+* :class:`bpy.types.ThemeSpaceGeneric.tab_back`
+* :class:`bpy.types.ThemeSpaceGeneric.tab_inactive`
+* :class:`bpy.types.ThemeSpaceGeneric.tab_outline`
+
+bpy.types.ThemeSpaceGradient
+----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ThemeSpaceGradient.tab_active`
+* :class:`bpy.types.ThemeSpaceGradient.tab_back`
+* :class:`bpy.types.ThemeSpaceGradient.tab_inactive`
+* :class:`bpy.types.ThemeSpaceGradient.tab_outline`
+
+bpy.types.TimelineMarkers
+-------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.TimelineMarkers.new` (name, frame), *was (name)*
+
+bpy.types.UILayout
+------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.UILayout.prop` (data, property, text, text_ctxt, translate, icon, expand, slider, toggle, icon_only, event, full_event, emboss, index, icon_value), *was (data, property, text, text_ctxt, translate, icon, expand, slider, toggle, icon_only, event, full_event, emboss, index)*
+* :class:`bpy.types.UILayout.template_header` (), *was (menus)*
+
+bpy.types.UserPreferencesEdit
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.UserPreferencesEdit.grease_pencil_default_color`
+
+bpy.types.UserPreferencesInput
+------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.UserPreferencesInput.navigation_mode`
+* :class:`bpy.types.UserPreferencesInput.ndof_pan_yz_swap_axis`
+* :class:`bpy.types.UserPreferencesInput.ndof_rotx_invert_axis`
+* :class:`bpy.types.UserPreferencesInput.ndof_roty_invert_axis`
+* :class:`bpy.types.UserPreferencesInput.ndof_rotz_invert_axis`
+* :class:`bpy.types.UserPreferencesInput.ndof_view_navigate_method`
+* :class:`bpy.types.UserPreferencesInput.walk_navigation`
+
+Removed
+^^^^^^^
+
+* **ndof_roll_invert_axis**
+* **ndof_rotate_invert_axis**
+* **ndof_tilt_invert_axis**
+* **ndof_zoom_updown**
+
+2.70 to 2.71
+============
+
+bpy.types.Actuator
+------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Actuator.active`
+
+bpy.types.BlendDataLineStyles
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.BlendDataLineStyles.is_updated`
+
+bpy.types.TransformConstraint
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.TransformConstraint.from_max_x_rot`
+* :class:`bpy.types.TransformConstraint.from_max_x_scale`
+* :class:`bpy.types.TransformConstraint.from_max_y_rot`
+* :class:`bpy.types.TransformConstraint.from_max_y_scale`
+* :class:`bpy.types.TransformConstraint.from_max_z_rot`
+* :class:`bpy.types.TransformConstraint.from_max_z_scale`
+* :class:`bpy.types.TransformConstraint.from_min_x_rot`
+* :class:`bpy.types.TransformConstraint.from_min_x_scale`
+* :class:`bpy.types.TransformConstraint.from_min_y_rot`
+* :class:`bpy.types.TransformConstraint.from_min_y_scale`
+* :class:`bpy.types.TransformConstraint.from_min_z_rot`
+* :class:`bpy.types.TransformConstraint.from_min_z_scale`
+* :class:`bpy.types.TransformConstraint.to_max_x_rot`
+* :class:`bpy.types.TransformConstraint.to_max_x_scale`
+* :class:`bpy.types.TransformConstraint.to_max_y_rot`
+* :class:`bpy.types.TransformConstraint.to_max_y_scale`
+* :class:`bpy.types.TransformConstraint.to_max_z_rot`
+* :class:`bpy.types.TransformConstraint.to_max_z_scale`
+* :class:`bpy.types.TransformConstraint.to_min_x_rot`
+* :class:`bpy.types.TransformConstraint.to_min_x_scale`
+* :class:`bpy.types.TransformConstraint.to_min_y_rot`
+* :class:`bpy.types.TransformConstraint.to_min_y_scale`
+* :class:`bpy.types.TransformConstraint.to_min_z_rot`
+* :class:`bpy.types.TransformConstraint.to_min_z_scale`
+
+bpy.types.Controller
+--------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Controller.active`
+
+bpy.types.FCurve
+----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.FCurve.update`
+
+bpy.types.Brush
+---------------
+
+Removed
+^^^^^^^
+
+* **sculpt_stroke_method**
+
+bpy.types.Curve
+---------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Curve.bevel_factor_mapping_end`
+* :class:`bpy.types.Curve.bevel_factor_mapping_start`
+
+bpy.types.FreestyleLineStyle
+----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.FreestyleLineStyle.active_texture`
+* :class:`bpy.types.FreestyleLineStyle.active_texture_index`
+* :class:`bpy.types.FreestyleLineStyle.integration_type`
+* :class:`bpy.types.FreestyleLineStyle.node_tree`
+* :class:`bpy.types.FreestyleLineStyle.sort_key`
+* :class:`bpy.types.FreestyleLineStyle.sort_order`
+* :class:`bpy.types.FreestyleLineStyle.texture_slots`
+* :class:`bpy.types.FreestyleLineStyle.texture_spacing`
+* :class:`bpy.types.FreestyleLineStyle.use_nodes`
+* :class:`bpy.types.FreestyleLineStyle.use_sorting`
+* :class:`bpy.types.FreestyleLineStyle.use_texture`
+
+bpy.types.Material
+------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Material.use_cast_shadows`
+
+bpy.types.Mesh
+--------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Mesh.show_normal_loop`
+
+bpy.types.Object
+----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Object.cycles`
+
+bpy.types.Scene
+---------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Scene.show_keys_from_selected_only`
+
+bpy.types.Speaker
+-----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Speaker.relative`
+
+bpy.types.Keyframe
+------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Keyframe.amplitude`
+* :class:`bpy.types.Keyframe.back`
+* :class:`bpy.types.Keyframe.easing`
+* :class:`bpy.types.Keyframe.period`
+
+bpy.types.Linesets
+------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Linesets.new`
+* :class:`bpy.types.Linesets.remove`
+
+bpy.types.MaskSplinePoint
+-------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MaskSplinePoint.handle_left_type`
+* :class:`bpy.types.MaskSplinePoint.handle_right_type`
+* :class:`bpy.types.MaskSplinePoint.weight`
+
+bpy.types.MeshEdge
+------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MeshEdge.use_freestyle_mark`
+
+bpy.types.MeshPolygon
+---------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MeshPolygon.use_freestyle_mark`
+
+bpy.types.MeshTessFace
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MeshTessFace.split_normals`
+
+bpy.types.MovieTrackingCamera
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MovieTrackingCamera.distortion_model`
+* :class:`bpy.types.MovieTrackingCamera.division_k1`
+* :class:`bpy.types.MovieTrackingCamera.division_k2`
+
+bpy.types.ShaderNodeTexImage
+----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ShaderNodeTexImage.interpolation`
+
+bpy.types.PackedFile
+--------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.PackedFile.data`
+
+bpy.types.Sculpt
+----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Sculpt.constant_detail`
+* :class:`bpy.types.Sculpt.detail_type_method`
+
+bpy.types.CyclesRenderSettings
+------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CyclesRenderSettings.bake_type`
+* :class:`bpy.types.CyclesRenderSettings.sample_all_lights_direct`
+* :class:`bpy.types.CyclesRenderSettings.sample_all_lights_indirect`
+
+bpy.types.RenderEngine
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.RenderEngine.bake`
+* :class:`bpy.types.RenderEngine.frame_set`
+
+bpy.types.CYCLES
+----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CYCLES.bake`
+
+bpy.types.RenderSettings
+------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.RenderSettings.bake`
+
+bpy.types.Sensor
+----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Sensor.active`
+
+bpy.types.SequenceElements
+--------------------------
+
+Renamed
+^^^^^^^
+
+* **push** -> :class:`bpy.types.SequenceElements.append`
+
+bpy.types.SmokeDomainSettings
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SmokeDomainSettings.color_grid`
+* :class:`bpy.types.SmokeDomainSettings.density_grid`
+* :class:`bpy.types.SmokeDomainSettings.flame_grid`
+
+Removed
+^^^^^^^
+
+* **density**
+
+bpy.types.Space
+---------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Space.show_locked_time`
+
+bpy.types.SpaceTimeline
+-----------------------
+
+Removed
+^^^^^^^
+
+* **show_only_selected**
+
+bpy.types.SpaceView3D
+---------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SpaceView3D.region_quadviews`
+
+Removed
+^^^^^^^
+
+* **region_quadview**
+
+bpy.types.SpaceNodeEditorPath
+-----------------------------
+
+Renamed
+^^^^^^^
+
+* **push** -> :class:`bpy.types.SpaceNodeEditorPath.append`
+
+bpy.types.ThemeClipEditor
+-------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ThemeClipEditor.handle_align`
+* :class:`bpy.types.ThemeClipEditor.handle_auto`
+* :class:`bpy.types.ThemeClipEditor.handle_auto_clamped`
+* :class:`bpy.types.ThemeClipEditor.handle_free`
+* :class:`bpy.types.ThemeClipEditor.handle_sel_align`
+* :class:`bpy.types.ThemeClipEditor.handle_sel_auto`
+* :class:`bpy.types.ThemeClipEditor.handle_sel_auto_clamped`
+* :class:`bpy.types.ThemeClipEditor.handle_sel_free`
+
+bpy.types.ThemeImageEditor
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ThemeImageEditor.frame_current`
+* :class:`bpy.types.ThemeImageEditor.handle_align`
+* :class:`bpy.types.ThemeImageEditor.handle_auto`
+* :class:`bpy.types.ThemeImageEditor.handle_auto_clamped`
+* :class:`bpy.types.ThemeImageEditor.handle_free`
+* :class:`bpy.types.ThemeImageEditor.handle_sel_align`
+* :class:`bpy.types.ThemeImageEditor.handle_sel_auto`
+* :class:`bpy.types.ThemeImageEditor.handle_sel_auto_clamped`
+* :class:`bpy.types.ThemeImageEditor.handle_sel_free`
+
+bpy.types.ThemeView3D
+---------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ThemeView3D.view_overlay`
+
+bpy.types.UILayout
+------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.UILayout.template_preview` (id, show_buttons, parent, slot, preview_id), *was (id, show_buttons, parent, slot)*
+
+2.71 to 2.72
+============
+
+bpy.types.EditObjectActuator
+----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.EditObjectActuator.track_axis`
+* :class:`bpy.types.EditObjectActuator.up_axis`
+
+bpy.types.BlendData
+-------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.BlendData.version`
+
+bpy.types.BoneGroups
+--------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.BoneGroups.new`
+* :class:`bpy.types.BoneGroups.remove`
+
+bpy.types.BrushCapabilities
+---------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.BrushCapabilities.has_smooth_stroke`
+
+bpy.types.ColorRamp
+-------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ColorRamp.color_mode`
+* :class:`bpy.types.ColorRamp.hue_interpolation`
+
+bpy.types.ColorRampElement
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ColorRampElement.alpha`
+
+bpy.types.FollowTrackConstraint
+-------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.FollowTrackConstraint.use_undistorted_position`
+
+bpy.types.Event
+---------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Event.is_tablet`
+* :class:`bpy.types.Event.pressure`
+* :class:`bpy.types.Event.tilt`
+
+bpy.types.Brush
+---------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Brush.blur_kernel_radius`
+* :class:`bpy.types.Brush.blur_mode`
+* :class:`bpy.types.Brush.fill_threshold`
+* :class:`bpy.types.Brush.grad_spacing`
+* :class:`bpy.types.Brush.gradient`
+* :class:`bpy.types.Brush.gradient_fill_mode`
+* :class:`bpy.types.Brush.gradient_stroke_mode`
+* :class:`bpy.types.Brush.image_paint_capabilities`
+* :class:`bpy.types.Brush.paint_curve`
+* :class:`bpy.types.Brush.secondary_color`
+* :class:`bpy.types.Brush.sharp_threshold`
+* :class:`bpy.types.Brush.use_curve`
+* :class:`bpy.types.Brush.use_gradient`
+* :class:`bpy.types.Brush.use_line`
+* :class:`bpy.types.Brush.use_pressure_masking`
+
+Renamed
+^^^^^^^
+
+* **use_drag_dot** -> :class:`bpy.types.Brush.use_restore_mesh`
+
+bpy.types.Curve
+---------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Curve.validate_material_indices`
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.Curve.transform` (matrix, shape_keys), *was (matrix)*
+
+bpy.types.Lattice
+-----------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.Lattice.transform` (matrix, shape_keys), *was (matrix)*
+
+bpy.types.Library
+-----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Library.packed_file`
+
+bpy.types.Material
+------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Material.line_color`
+* :class:`bpy.types.Material.line_priority`
+* :class:`bpy.types.Material.paint_active_slot`
+* :class:`bpy.types.Material.paint_clone_slot`
+* :class:`bpy.types.Material.texture_paint_images`
+* :class:`bpy.types.Material.texture_paint_slots`
+
+bpy.types.Mesh
+--------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Mesh.validate_material_indices`
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.Mesh.transform` (matrix, shape_keys), *was (matrix)*
+
+bpy.types.WindowManager
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.WindowManager.piemenu_begin__internal`
+* :class:`bpy.types.WindowManager.piemenu_end__internal`
+* :class:`bpy.types.WindowManager.popup_menu_pie`
+
+bpy.types.BevelModifier
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.BevelModifier.material`
+
+bpy.types.HookModifier
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.HookModifier.center`
+
+bpy.types.SolidifyModifier
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SolidifyModifier.use_rim_only`
+
+bpy.types.ShaderNodeBsdfAnisotropic
+-----------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ShaderNodeBsdfAnisotropic.distribution`
+
+bpy.types.Paint
+---------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Paint.palette`
+
+bpy.types.ImagePaint
+--------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ImagePaint.canvas`
+* :class:`bpy.types.ImagePaint.clone_image`
+* :class:`bpy.types.ImagePaint.detect_data`
+* :class:`bpy.types.ImagePaint.missing_materials`
+* :class:`bpy.types.ImagePaint.missing_stencil`
+* :class:`bpy.types.ImagePaint.missing_texture`
+* :class:`bpy.types.ImagePaint.missing_uvs`
+* :class:`bpy.types.ImagePaint.mode`
+* :class:`bpy.types.ImagePaint.stencil_color`
+* :class:`bpy.types.ImagePaint.stencil_image`
+
+bpy.types.IMAGE_UV_sculpt
+-------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.IMAGE_UV_sculpt.prop_unified_color`
+* :class:`bpy.types.IMAGE_UV_sculpt.prop_unified_color_picker`
+
+bpy.types.CyclesCameraSettings
+------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CyclesCameraSettings.aperture_ratio`
+
+bpy.types.CyclesMaterialSettings
+--------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CyclesMaterialSettings.volume_sampling`
+
+bpy.types.CyclesRenderSettings
+------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CyclesRenderSettings.caustics_reflective`
+* :class:`bpy.types.CyclesRenderSettings.caustics_refractive`
+
+Removed
+^^^^^^^
+
+* **no_caustics**
+* **volume_homogeneous_sampling**
+
+bpy.types.CyclesVisibilitySettings
+----------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CyclesVisibilitySettings.scatter`
+
+bpy.types.CyclesWorldSettings
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CyclesWorldSettings.volume_sampling`
+
+bpy.types.OperatorStrokeElement
+-------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.OperatorStrokeElement.size`
+
+bpy.types.RenderEngine
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.RenderEngine.bl_use_texture_preview`
+* :class:`bpy.types.RenderEngine.layer_override`
+
+bpy.types.RenderSettings
+------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.RenderSettings.preview_start_resolution`
+* :class:`bpy.types.RenderSettings.use_render_cache`
+
+bpy.types.MouseSensor
+---------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MouseSensor.material`
+* :class:`bpy.types.MouseSensor.property`
+* :class:`bpy.types.MouseSensor.use_material`
+* :class:`bpy.types.MouseSensor.use_x_ray`
+
+bpy.types.SpaceUVEditor
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SpaceUVEditor.show_texpaint`
+
+bpy.types.ThemeImageEditor
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ThemeImageEditor.handle_vertex`
+* :class:`bpy.types.ThemeImageEditor.handle_vertex_select`
+* :class:`bpy.types.ThemeImageEditor.handle_vertex_size`
+* :class:`bpy.types.ThemeImageEditor.paint_curve_handle`
+* :class:`bpy.types.ThemeImageEditor.paint_curve_pivot`
+
+bpy.types.ThemeUserInterface
+----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ThemeUserInterface.wcol_pie_menu`
+
+bpy.types.ThemeView3D
+---------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ThemeView3D.paint_curve_handle`
+* :class:`bpy.types.ThemeView3D.paint_curve_pivot`
+* :class:`bpy.types.ThemeView3D.split_normal`
+
+bpy.types.UILayout
+------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.UILayout.menu_pie`
+* :class:`bpy.types.UILayout.template_palette`
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.UILayout.template_curve_mapping` (data, property, type, levels, brush, use_negative_slope), *was (data, property, type, levels, brush)*
+
+bpy.types.UnifiedPaintSettings
+------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.UnifiedPaintSettings.color`
+* :class:`bpy.types.UnifiedPaintSettings.secondary_color`
+* :class:`bpy.types.UnifiedPaintSettings.use_unified_color`
+
+bpy.types.UserPreferencesFilePaths
+----------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.UserPreferencesFilePaths.render_cache_directory`
+
+bpy.types.UserPreferencesSystem
+-------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.UserPreferencesSystem.font_path_ui`
+* :class:`bpy.types.UserPreferencesSystem.is_occlusion_query_supported`
+* :class:`bpy.types.UserPreferencesSystem.select_method`
+
+bpy.types.UserPreferencesView
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.UserPreferencesView.pie_animation_timeout`
+* :class:`bpy.types.UserPreferencesView.pie_initial_timeout`
+* :class:`bpy.types.UserPreferencesView.pie_menu_radius`
+* :class:`bpy.types.UserPreferencesView.pie_menu_threshold`
+
+2.72 to 2.73
+============
+
+bpy.types.ActionGroup
+---------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ActionGroup.is_custom_color_set`
+
+bpy.types.BoneGroup
+-------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.BoneGroup.is_custom_color_set`
+
+bpy.types.StretchToConstraint
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.StretchToConstraint.bulge_max`
+* :class:`bpy.types.StretchToConstraint.bulge_min`
+* :class:`bpy.types.StretchToConstraint.bulge_smooth`
+* :class:`bpy.types.StretchToConstraint.use_bulge_max`
+* :class:`bpy.types.StretchToConstraint.use_bulge_min`
+
+bpy.types.DopeSheet
+-------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.DopeSheet.show_gpencil`
+
+bpy.types.FreestyleSettings
+---------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.FreestyleSettings.use_view_map_cache`
+
+bpy.types.GPencilLayer
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.GPencilLayer.after_color`
+* :class:`bpy.types.GPencilLayer.before_color`
+* :class:`bpy.types.GPencilLayer.fill_alpha`
+* :class:`bpy.types.GPencilLayer.fill_color`
+* :class:`bpy.types.GPencilLayer.ghost_after_range`
+* :class:`bpy.types.GPencilLayer.ghost_before_range`
+* :class:`bpy.types.GPencilLayer.use_ghost_custom_colors`
+* :class:`bpy.types.GPencilLayer.use_volumetric_strokes`
+
+Removed
+^^^^^^^
+
+* **ghost_range_max**
+
+bpy.types.GPencilStroke
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.GPencilStroke.select`
+
+bpy.types.GPencilStrokePoint
+----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.GPencilStrokePoint.select`
+
+bpy.types.GreasePencilLayers
+----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.GreasePencilLayers.active_index`
+
+bpy.types.FreestyleLineStyle
+----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.FreestyleLineStyle.chain_count`
+* :class:`bpy.types.FreestyleLineStyle.use_chain_count`
+
+bpy.types.GreasePencil
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.GreasePencil.animation_data`
+* :class:`bpy.types.GreasePencil.use_stroke_edit_mode`
+
+bpy.types.Image
+---------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Image.generated_color`
+* :class:`bpy.types.Image.render_slots`
+
+Removed
+^^^^^^^
+
+* **render_slot**
+
+bpy.types.Scene
+---------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Scene.uvedit_aspect`
+
+bpy.types.CyclesLampSettings
+----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CyclesLampSettings.max_bounces`
+
+bpy.types.CyclesMaterialSettings
+--------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CyclesMaterialSettings.volume_interpolation`
+
+bpy.types.CyclesWorldSettings
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CyclesWorldSettings.volume_interpolation`
+
+bpy.types.RenderEngine
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.RenderEngine.error_set`
+
+bpy.types.RenderPass
+--------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.RenderPass.debug_type`
+
+bpy.types.SculptToolCapabilities
+--------------------------------
+
+Renamed
+^^^^^^^
+
+* **has_strength** -> :class:`bpy.types.SculptToolCapabilities.has_strength_pressure`
+
+bpy.types.SceneSequence
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SceneSequence.use_grease_pencil`
+
+bpy.types.SpaceSequenceEditor
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SpaceSequenceEditor.show_backdrop`
+* :class:`bpy.types.SpaceSequenceEditor.show_strip_offset`
+* :class:`bpy.types.SpaceSequenceEditor.waveform_draw_type`
+
+bpy.types.SpaceView3D
+---------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SpaceView3D.show_world`
+
+bpy.types.ThemeClipEditor
+-------------------------
+
+Removed
+^^^^^^^
+
+* **grid**
+
+bpy.types.ThemeNodeEditor
+-------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ThemeNodeEditor.wire_inner`
+
+bpy.types.ThemeUserInterface
+----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ThemeUserInterface.widget_emboss`
+
+bpy.types.ToolSettings
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ToolSettings.grease_pencil_source`
+
+bpy.types.UILayout
+------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.UILayout.operator` (operator, text, text_ctxt, translate, icon, emboss, icon_value), *was (operator, text, text_ctxt, translate, icon, emboss)*
+
+bpy.types.UserPreferencesSystem
+-------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.UserPreferencesSystem.virtual_pixel_mode`
+
+bpy.types.UserPreferencesView
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.UserPreferencesView.pie_menu_confirm`
+
+2.73 to 2.74
+============
+
+bpy.types.SteeringActuator
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SteeringActuator.lock_z_velocity`
+
+bpy.types.BackgroundImage
+-------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.BackgroundImage.rotation`
+* :class:`bpy.types.BackgroundImage.use_flip_x`
+* :class:`bpy.types.BackgroundImage.use_flip_y`
+
+bpy.types.BrushCapabilities
+---------------------------
+
+Removed
+^^^^^^^
+
+* **has_texture_angle**
+* **has_texture_angle_source**
+
+bpy.types.ClothCollisionSettings
+--------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ClothCollisionSettings.damping`
+
+bpy.types.ClothSettings
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ClothSettings.bending_damping`
+* :class:`bpy.types.ClothSettings.density_strength`
+* :class:`bpy.types.ClothSettings.density_target`
+* :class:`bpy.types.ClothSettings.voxel_cell_size`
+
+Removed
+^^^^^^^
+
+* **pre_roll**
+
+bpy.types.SplineIKConstraint
+----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SplineIKConstraint.bulge`
+* :class:`bpy.types.SplineIKConstraint.bulge_max`
+* :class:`bpy.types.SplineIKConstraint.bulge_min`
+* :class:`bpy.types.SplineIKConstraint.bulge_smooth`
+* :class:`bpy.types.SplineIKConstraint.use_bulge_max`
+* :class:`bpy.types.SplineIKConstraint.use_bulge_min`
+
+bpy.types.FCurve
+----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.FCurve.convert_to_keyframes`
+* :class:`bpy.types.FCurve.convert_to_samples`
+
+bpy.types.FileSelectParams
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.FileSelectParams.filter_search`
+
+bpy.types.GPencilLayer
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.GPencilLayer.is_fill_visible`
+* :class:`bpy.types.GPencilLayer.is_stroke_visible`
+
+bpy.types.Brush
+---------------
+
+Removed
+^^^^^^^
+
+* **texture_angle_source_no_random**
+* **texture_angle_source_random**
+* **use_rake**
+* **use_random_rotation**
+
+bpy.types.Camera
+----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Camera.gpu_dof`
+* :class:`bpy.types.Camera.show_safe_center`
+
+Renamed
+^^^^^^^
+
+* **show_title_safe** -> :class:`bpy.types.Camera.show_safe_areas`
+
+bpy.types.Image
+---------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Image.use_deinterlace`
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.Image.pack` (as_png, data, data_len), *was (as_png)*
+
+bpy.types.Key
+-------------
+
+Removed
+^^^^^^^
+
+* **slurph**
+
+bpy.types.Mesh
+--------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Mesh.create_normals_split`
+* :class:`bpy.types.Mesh.has_custom_normals`
+* :class:`bpy.types.Mesh.normals_split_custom_set`
+* :class:`bpy.types.Mesh.normals_split_custom_set_from_vertices`
+* :class:`bpy.types.Mesh.vertex_layers_float`
+* :class:`bpy.types.Mesh.vertex_layers_int`
+* :class:`bpy.types.Mesh.vertex_layers_string`
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.Mesh.calc_normals_split` (), *was (split_angle)*
+* :class:`bpy.types.Mesh.validate` (verbose, clean_customdata), *was (verbose)*
+
+bpy.types.Object
+----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Object.calc_matrix_camera`
+* :class:`bpy.types.Object.camera_fit_coords`
+
+bpy.types.ParticleSettings
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ParticleSettings.bending_random`
+* :class:`bpy.types.ParticleSettings.clump_curve`
+* :class:`bpy.types.ParticleSettings.clump_noise_size`
+* :class:`bpy.types.ParticleSettings.kink_amplitude_random`
+* :class:`bpy.types.ParticleSettings.kink_axis_random`
+* :class:`bpy.types.ParticleSettings.kink_extra_steps`
+* :class:`bpy.types.ParticleSettings.roughness_curve`
+* :class:`bpy.types.ParticleSettings.show_guide_hairs`
+* :class:`bpy.types.ParticleSettings.show_hair_grid`
+* :class:`bpy.types.ParticleSettings.use_clump_curve`
+* :class:`bpy.types.ParticleSettings.use_clump_noise`
+* :class:`bpy.types.ParticleSettings.use_roughness_curve`
+
+bpy.types.Scene
+---------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Scene.safe_areas`
+
+bpy.types.Screen
+----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Screen.use_follow`
+
+bpy.types.Sound
+---------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Sound.pack`
+* :class:`bpy.types.Sound.unpack`
+
+bpy.types.VectorFont
+--------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.VectorFont.pack`
+* :class:`bpy.types.VectorFont.unpack`
+
+bpy.types.KeyingSet
+-------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.KeyingSet.use_insertkey_needed`
+* :class:`bpy.types.KeyingSet.use_insertkey_override_needed`
+* :class:`bpy.types.KeyingSet.use_insertkey_override_visual`
+* :class:`bpy.types.KeyingSet.use_insertkey_override_xyz_to_rgb`
+* :class:`bpy.types.KeyingSet.use_insertkey_visual`
+* :class:`bpy.types.KeyingSet.use_insertkey_xyz_to_rgb`
+
+Removed
+^^^^^^^
+
+* **bl_options**
+
+bpy.types.KeyingSetPath
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.KeyingSetPath.use_insertkey_needed`
+* :class:`bpy.types.KeyingSetPath.use_insertkey_override_needed`
+* :class:`bpy.types.KeyingSetPath.use_insertkey_override_visual`
+* :class:`bpy.types.KeyingSetPath.use_insertkey_override_xyz_to_rgb`
+* :class:`bpy.types.KeyingSetPath.use_insertkey_visual`
+* :class:`bpy.types.KeyingSetPath.use_insertkey_xyz_to_rgb`
+
+Removed
+^^^^^^^
+
+* **bl_options**
+
+bpy.types.ClothModifier
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ClothModifier.hair_grid_max`
+* :class:`bpy.types.ClothModifier.hair_grid_min`
+* :class:`bpy.types.ClothModifier.hair_grid_resolution`
+* :class:`bpy.types.ClothModifier.solver_result`
+
+bpy.types.HookModifier
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.HookModifier.falloff_curve`
+* :class:`bpy.types.HookModifier.falloff_type`
+* :class:`bpy.types.HookModifier.use_falloff_uniform`
+
+Renamed
+^^^^^^^
+
+* **falloff** -> :class:`bpy.types.HookModifier.falloff_radius`
+* **force** -> :class:`bpy.types.HookModifier.strength`
+
+bpy.types.Node
+--------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Node.shading_compatibility`
+
+bpy.types.CompositorNodePlaneTrackDeform
+----------------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CompositorNodePlaneTrackDeform.motion_blur_samples`
+* :class:`bpy.types.CompositorNodePlaneTrackDeform.motion_blur_shutter`
+* :class:`bpy.types.CompositorNodePlaneTrackDeform.use_motion_blur`
+
+bpy.types.NodeFrame
+-------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.NodeFrame.text`
+
+bpy.types.ShaderNodeTexCoord
+----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ShaderNodeTexCoord.object`
+
+bpy.types.Paint
+---------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Paint.cavity_curve`
+* :class:`bpy.types.Paint.use_cavity`
+
+bpy.types.ImagePaint
+--------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ImagePaint.dither`
+
+bpy.types.ParticleEdit
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ParticleEdit.shape_object`
+
+bpy.types.CyclesCameraSettings
+------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CyclesCameraSettings.latitude_max`
+* :class:`bpy.types.CyclesCameraSettings.latitude_min`
+* :class:`bpy.types.CyclesCameraSettings.longitude_max`
+* :class:`bpy.types.CyclesCameraSettings.longitude_min`
+
+bpy.types.RegionView3D
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.RegionView3D.window_matrix`
+
+bpy.types.SequenceProxy
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SequenceProxy.use_overwrite`
+
+bpy.types.SpaceFileBrowser
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SpaceFileBrowser.bookmarks`
+* :class:`bpy.types.SpaceFileBrowser.bookmarks_active`
+* :class:`bpy.types.SpaceFileBrowser.recent_folders`
+* :class:`bpy.types.SpaceFileBrowser.recent_folders_active`
+* :class:`bpy.types.SpaceFileBrowser.system_bookmarks`
+* :class:`bpy.types.SpaceFileBrowser.system_bookmarks_active`
+* :class:`bpy.types.SpaceFileBrowser.system_folders`
+* :class:`bpy.types.SpaceFileBrowser.system_folders_active`
+
+bpy.types.SpaceOutliner
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SpaceOutliner.use_sort_alpha`
+
+bpy.types.SpaceSequenceEditor
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SpaceSequenceEditor.show_safe_areas`
+* :class:`bpy.types.SpaceSequenceEditor.show_safe_center`
+
+Removed
+^^^^^^^
+
+* **show_safe_margin**
+
+bpy.types.SpaceTextEditor
+-------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SpaceTextEditor.region_location_from_cursor`
+
+bpy.types.SpaceView3D
+---------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SpaceView3D.fx_settings`
+
+bpy.types.BrushTextureSlot
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.BrushTextureSlot.has_random_texture_angle`
+* :class:`bpy.types.BrushTextureSlot.has_texture_angle`
+* :class:`bpy.types.BrushTextureSlot.has_texture_angle_source`
+* :class:`bpy.types.BrushTextureSlot.random_angle`
+* :class:`bpy.types.BrushTextureSlot.use_rake`
+* :class:`bpy.types.BrushTextureSlot.use_random`
+
+bpy.types.ParticleSettingsTextureSlot
+-------------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ParticleSettingsTextureSlot.kink_amp_factor`
+* :class:`bpy.types.ParticleSettingsTextureSlot.kink_freq_factor`
+* :class:`bpy.types.ParticleSettingsTextureSlot.use_map_kink_amp`
+* :class:`bpy.types.ParticleSettingsTextureSlot.use_map_kink_freq`
+
+Removed
+^^^^^^^
+
+* **kink_factor**
+* **use_map_kink**
+
+bpy.types.ThemeClipEditor
+-------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ThemeClipEditor.gp_vertex`
+* :class:`bpy.types.ThemeClipEditor.gp_vertex_select`
+* :class:`bpy.types.ThemeClipEditor.gp_vertex_size`
+
+bpy.types.ThemeImageEditor
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ThemeImageEditor.gp_vertex`
+* :class:`bpy.types.ThemeImageEditor.gp_vertex_select`
+* :class:`bpy.types.ThemeImageEditor.gp_vertex_size`
+
+bpy.types.ThemeNodeEditor
+-------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ThemeNodeEditor.gp_vertex`
+* :class:`bpy.types.ThemeNodeEditor.gp_vertex_select`
+* :class:`bpy.types.ThemeNodeEditor.gp_vertex_size`
+
+bpy.types.ThemeSequenceEditor
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ThemeSequenceEditor.gp_vertex`
+* :class:`bpy.types.ThemeSequenceEditor.gp_vertex_select`
+* :class:`bpy.types.ThemeSequenceEditor.gp_vertex_size`
+
+bpy.types.ThemeTimeline
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ThemeTimeline.time_grease_pencil`
+* :class:`bpy.types.ThemeTimeline.time_keyframe`
+
+bpy.types.ThemeView3D
+---------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ThemeView3D.clipping_border_3d`
+* :class:`bpy.types.ThemeView3D.gp_vertex`
+* :class:`bpy.types.ThemeView3D.gp_vertex_select`
+* :class:`bpy.types.ThemeView3D.gp_vertex_size`
+
+bpy.types.UILayout
+------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.UILayout.template_list` (listtype_name, list_id, dataptr, propname, active_dataptr, active_propname, item_dyntip_propname, rows, maxrows, type, columns), *was (listtype_name, list_id, dataptr, propname, active_dataptr, active_propname, rows, maxrows, type, columns)*
+
+bpy.types.UserPreferencesSystem
+-------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.UserPreferencesSystem.pixel_size`
+
+bpy.types.UserPreferencesView
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.UserPreferencesView.use_gl_warn_support`
+
+bpy.types.VoxelData
+-------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.VoxelData.hair_data_type`
+
+2.74 to 2.75
+============
+
+bpy.types.BakePixel
+-------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.BakePixel.object_id`
+
+bpy.types.BlendData
+-------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.BlendData.palettes`
+
+bpy.types.BlendDataImages
+-------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataImages.new` (name, width, height, alpha, float_buffer, stereo3d), *was (name, width, height, alpha, float_buffer)*
+
+bpy.types.BlendDataSounds
+-------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.BlendDataSounds.load`
+* :class:`bpy.types.BlendDataSounds.remove`
+
+bpy.types.DopeSheet
+-------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.DopeSheet.filter_text`
+* :class:`bpy.types.DopeSheet.use_filter_text`
+
+bpy.types.FileSelectParams
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.FileSelectParams.thumbnail_size`
+
+bpy.types.GPUDOFSettings
+------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.GPUDOFSettings.blades`
+* :class:`bpy.types.GPUDOFSettings.is_hq_supported`
+* :class:`bpy.types.GPUDOFSettings.use_high_quality`
+
+bpy.types.Camera
+----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Camera.stereo`
+
+bpy.types.Image
+---------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Image.buffers_free`
+* :class:`bpy.types.Image.is_multiview`
+* :class:`bpy.types.Image.is_stereo_3d`
+* :class:`bpy.types.Image.packed_files`
+* :class:`bpy.types.Image.stereo_3d_format`
+* :class:`bpy.types.Image.use_multiview`
+* :class:`bpy.types.Image.views_format`
+
+bpy.types.SunLamp
+-----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SunLamp.show_shadow_box`
+
+bpy.types.Mesh
+--------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Mesh.vertex_paint_masks`
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.Mesh.calc_tessface` (free_mpoly), *was ()*
+
+bpy.types.Object
+----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Object.cache_release`
+* :class:`bpy.types.Object.shape_key_remove`
+
+bpy.types.Scene
+---------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Scene.depsgraph`
+
+bpy.types.ImageFormatSettings
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ImageFormatSettings.stereo_3d_format`
+* :class:`bpy.types.ImageFormatSettings.views_format`
+
+bpy.types.ImageUser
+-------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ImageUser.multilayer_view`
+
+Removed
+^^^^^^^
+
+* **multilayer_pass**
+
+bpy.types.LodLevel
+------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.LodLevel.object_hysteresis_percentage`
+* :class:`bpy.types.LodLevel.use_object_hysteresis`
+
+bpy.types.DecimateModifier
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.DecimateModifier.vertex_group_factor`
+
+bpy.types.CompositorNodeImage
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CompositorNodeImage.has_layers`
+* :class:`bpy.types.CompositorNodeImage.has_views`
+* :class:`bpy.types.CompositorNodeImage.view`
+
+bpy.types.TextureNodeImage
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.TextureNodeImage.image_user`
+
+bpy.types.Operator
+------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Operator.macros`
+* :class:`bpy.types.Operator.options`
+
+bpy.types.Sculpt
+----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Sculpt.detail_percent`
+
+bpy.types.PointCache
+--------------------
+
+Renamed
+^^^^^^^
+
+* **frames_skipped** -> :class:`bpy.types.PointCache.is_frame_skip`
+
+bpy.types.CyclesLampSettings
+----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CyclesLampSettings.is_portal`
+
+bpy.types.CyclesRenderSettings
+------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CyclesRenderSettings.use_animated_seed`
+
+bpy.types.Region
+----------------
+
+Removed
+^^^^^^^
+
+* **callback_add**
+
+bpy.types.RenderEngine
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.RenderEngine.active_view_set`
+* :class:`bpy.types.RenderEngine.bl_use_shading_nodes_custom`
+* :class:`bpy.types.RenderEngine.camera_model_matrix`
+* :class:`bpy.types.RenderEngine.camera_shift_x`
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.RenderEngine.bake` (scene, object, pass_type, object_id, pixel_array, num_pixels, depth, result), *was (scene, object, pass_type, pixel_array, num_pixels, depth, result)*
+* :class:`bpy.types.RenderEngine.begin_result` (x, y, w, h, layer, view), *was (x, y, w, h, layer)*
+
+bpy.types.CYCLES
+----------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.CYCLES.bake` (self, scene, obj, pass_type, object_id, pixel_array, num_pixels, depth, result), *was (self, scene, obj, pass_type, pixel_array, num_pixels, depth, result)*
+
+bpy.types.RenderLayer
+---------------------
+
+Removed
+^^^^^^^
+
+* **rect**
+
+bpy.types.RenderPass
+--------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.RenderPass.view_id`
+
+bpy.types.RenderResult
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.RenderResult.views`
+
+bpy.types.RenderSettings
+------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.RenderSettings.simplify_child_particles_render`
+* :class:`bpy.types.RenderSettings.simplify_subdivision_render`
+* :class:`bpy.types.RenderSettings.stereo_views`
+* :class:`bpy.types.RenderSettings.use_multiview`
+* :class:`bpy.types.RenderSettings.views`
+* :class:`bpy.types.RenderSettings.views_format`
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.RenderSettings.frame_path` (frame, preview, view), *was (frame)*
+
+bpy.types.SceneGameData
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SceneGameData.scene_hysteresis_percentage`
+* :class:`bpy.types.SceneGameData.use_scene_hysteresis`
+
+bpy.types.Sensor
+----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Sensor.tick_skip`
+
+Removed
+^^^^^^^
+
+* **frequency**
+
+bpy.types.EffectSequence
+------------------------
+
+Removed
+^^^^^^^
+
+* **use_proxy_custom_directory**
+* **use_proxy_custom_file**
+
+bpy.types.ImageSequence
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ImageSequence.stereo_3d_format`
+* :class:`bpy.types.ImageSequence.use_multiview`
+* :class:`bpy.types.ImageSequence.views_format`
+
+Removed
+^^^^^^^
+
+* **use_proxy_custom_directory**
+* **use_proxy_custom_file**
+
+bpy.types.MetaSequence
+----------------------
+
+Removed
+^^^^^^^
+
+* **use_proxy_custom_directory**
+* **use_proxy_custom_file**
+
+bpy.types.MovieSequence
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MovieSequence.stereo_3d_format`
+* :class:`bpy.types.MovieSequence.use_multiview`
+* :class:`bpy.types.MovieSequence.views_format`
+
+Removed
+^^^^^^^
+
+* **use_proxy_custom_directory**
+* **use_proxy_custom_file**
+
+bpy.types.SceneSequence
+-----------------------
+
+Removed
+^^^^^^^
+
+* **use_proxy_custom_directory**
+* **use_proxy_custom_file**
+
+bpy.types.SequenceEditor
+------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SequenceEditor.proxy_dir`
+* :class:`bpy.types.SequenceEditor.proxy_storage`
+
+bpy.types.SequenceProxy
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SequenceProxy.use_proxy_custom_directory`
+* :class:`bpy.types.SequenceProxy.use_proxy_custom_file`
+
+bpy.types.SpaceImageEditor
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SpaceImageEditor.show_stereo_3d`
+
+bpy.types.SpaceSequenceEditor
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SpaceSequenceEditor.show_metadata`
+
+bpy.types.SpaceView3D
+---------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SpaceView3D.show_stereo_3d_cameras`
+* :class:`bpy.types.SpaceView3D.show_stereo_3d_convergence_plane`
+* :class:`bpy.types.SpaceView3D.show_stereo_3d_volume`
+* :class:`bpy.types.SpaceView3D.stereo_3d_camera`
+* :class:`bpy.types.SpaceView3D.stereo_3d_convergence_plane_alpha`
+* :class:`bpy.types.SpaceView3D.stereo_3d_eye`
+* :class:`bpy.types.SpaceView3D.stereo_3d_volume_alpha`
+
+bpy.types.SpaceUVEditor
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SpaceUVEditor.show_metadata`
+
+bpy.types.ThemeImageEditor
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ThemeImageEditor.metadatabg`
+* :class:`bpy.types.ThemeImageEditor.metadatatext`
+
+bpy.types.ThemeSequenceEditor
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ThemeSequenceEditor.metadatabg`
+* :class:`bpy.types.ThemeSequenceEditor.metadatatext`
+
+bpy.types.ToolSettings
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ToolSettings.lock_markers`
+* :class:`bpy.types.ToolSettings.use_proportional_action`
+* :class:`bpy.types.ToolSettings.use_proportional_fcurve`
+
+bpy.types.UILayout
+------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.UILayout.template_image_stereo_3d`
+* :class:`bpy.types.UILayout.template_image_views`
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.UILayout.menu` (menu, text, text_ctxt, translate, icon, icon_value), *was (menu, text, text_ctxt, translate, icon)*
+* :class:`bpy.types.UILayout.template_icon_view` (data, property, show_labels), *was (data, property)*
+* :class:`bpy.types.UILayout.template_image` (data, property, image_user, compact, multiview), *was (data, property, image_user, compact)*
+
+bpy.types.UserPreferencesView
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.UserPreferencesView.view_frame_keyframes`
+* :class:`bpy.types.UserPreferencesView.view_frame_seconds`
+* :class:`bpy.types.UserPreferencesView.view_frame_type`
+
+bpy.types.Window
+----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Window.stereo_3d_display`
+
+2.75 to 2.76
+============
+
+bpy.types.ActionFCurves
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ActionFCurves.find`
+
+bpy.types.BlendDataBrushes
+--------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataBrushes.new` (name, mode), *was (name)*
+
+bpy.types.FileSelectParams
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.FileSelectParams.filter_id`
+* :class:`bpy.types.FileSelectParams.filter_id_category`
+* :class:`bpy.types.FileSelectParams.recursion_level`
+* :class:`bpy.types.FileSelectParams.use_filter_blendid`
+* :class:`bpy.types.FileSelectParams.use_library_browsing`
+
+bpy.types.GameObjectSettings
+----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.GameObjectSettings.angular_velocity_max`
+* :class:`bpy.types.GameObjectSettings.angular_velocity_min`
+
+bpy.types.ID
+------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ID.preview`
+
+bpy.types.Brush
+---------------
+
+Removed
+^^^^^^^
+
+* **use_wrap**
+
+bpy.types.ImagePreview
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ImagePreview.icon_pixels_float`
+* :class:`bpy.types.ImagePreview.image_pixels_float`
+
+bpy.types.ImageUser
+-------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ImageUser.multilayer_pass`
+
+bpy.types.BevelModifier
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.BevelModifier.loop_slide`
+
+bpy.types.SubsurfModifier
+-------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SubsurfModifier.use_opensubdiv`
+
+bpy.types.ShaderNodeTexImage
+----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ShaderNodeTexImage.extension`
+
+bpy.types.Paint
+---------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Paint.tile_offset`
+* :class:`bpy.types.Paint.tile_x`
+* :class:`bpy.types.Paint.tile_y`
+* :class:`bpy.types.Paint.tile_z`
+
+bpy.types.CyclesObjectBlurSettings
+----------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CyclesObjectBlurSettings.use_camera_cull`
+
+bpy.types.CyclesRenderSettings
+------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CyclesRenderSettings.camera_cull_margin`
+* :class:`bpy.types.CyclesRenderSettings.use_camera_cull`
+
+bpy.types.CyclesWorldSettings
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CyclesWorldSettings.max_bounces`
+
+bpy.types.RenderSettings
+------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.RenderSettings.use_stamp_strip_meta`
+
+bpy.types.SmokeDomainSettings
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SmokeDomainSettings.velocity_grid`
+
+bpy.types.SpaceClipEditor
+-------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SpaceClipEditor.show_metadata`
+
+bpy.types.SpaceNodeEditor
+-------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SpaceNodeEditor.insert_offset_direction`
+* :class:`bpy.types.SpaceNodeEditor.use_insert_offset`
+
+bpy.types.ToolSettings
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ToolSettings.use_snap_grid_absolute`
+
+bpy.types.UILayout
+------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.UILayout.template_icon_view` (data, property, show_labels, scale), *was (data, property, show_labels)*
+
+bpy.types.UserPreferencesEdit
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.UserPreferencesEdit.node_margin`
+
+bpy.types.UserPreferencesInput
+------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.UserPreferencesInput.ndof_deadzone`
+
+bpy.types.UserPreferencesSystem
+-------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.UserPreferencesSystem.opensubdiv_compute_type`
+
+2.76 to 2.77
+============
+
+bpy.types.AnimDataDrivers
+-------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.AnimDataDrivers.find`
+
+bpy.types.BakeSettings
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.BakeSettings.pass_filter`
+* :class:`bpy.types.BakeSettings.use_pass_ambient_occlusion`
+* :class:`bpy.types.BakeSettings.use_pass_color`
+* :class:`bpy.types.BakeSettings.use_pass_diffuse`
+* :class:`bpy.types.BakeSettings.use_pass_direct`
+* :class:`bpy.types.BakeSettings.use_pass_emit`
+* :class:`bpy.types.BakeSettings.use_pass_glossy`
+* :class:`bpy.types.BakeSettings.use_pass_indirect`
+* :class:`bpy.types.BakeSettings.use_pass_subsurface`
+* :class:`bpy.types.BakeSettings.use_pass_transmission`
+
+bpy.types.BlendData
+-------------------
+
+Removed
+^^^^^^^
+
+* **scripts**
+
+bpy.types.BlendDataFonts
+------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataFonts.load` (filepath, check_existing), *was (filepath)*
+
+bpy.types.BlendDataImages
+-------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataImages.load` (filepath, check_existing), *was (filepath)*
+
+bpy.types.BlendDataMasks
+------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.BlendDataMasks.is_updated`
+
+bpy.types.BlendDataMovieClips
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.BlendDataMovieClips.is_updated`
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataMovieClips.load` (filepath, check_existing), *was (filepath)*
+
+bpy.types.BlendDataSounds
+-------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataSounds.load` (filepath, check_existing), *was (filepath)*
+
+bpy.types.DopeSheet
+-------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.DopeSheet.show_gpencil_3d_only`
+
+bpy.types.FileSelectParams
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.FileSelectParams.display_size`
+
+Removed
+^^^^^^^
+
+* **thumbnail_size**
+
+bpy.types.GameObjectSettings
+----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.GameObjectSettings.jump_max`
+
+bpy.types.ID
+------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ID.user_of_id`
+
+bpy.types.Brush
+---------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Brush.rake_factor`
+
+bpy.types.FreestyleLineStyle
+----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.FreestyleLineStyle.animation_data`
+
+bpy.types.GreasePencil
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.GreasePencil.use_onion_skinning`
+
+Removed
+^^^^^^^
+
+* **draw_mode**
+* **use_stroke_endpoints**
+
+bpy.types.Object
+----------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.Object.closest_point_on_mesh` (origin, distance), *was (point, max_dist)*
+* :class:`bpy.types.Object.ray_cast` (origin, direction, distance), *was (start, end)*
+
+bpy.types.Scene
+---------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.Scene.ray_cast` (origin, direction, distance), *was (start, end)*
+
+bpy.types.ImageFormatSettings
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ImageFormatSettings.tiff_codec`
+
+bpy.types.ImagePackedFile
+-------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ImagePackedFile.save`
+
+bpy.types.DataTransferModifier
+------------------------------
+
+Removed
+^^^^^^^
+
+* **data_types_loops_uv**
+* **data_types_loops_vcol**
+* **data_types_verts_vgroup**
+
+bpy.types.DecimateModifier
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.DecimateModifier.symmetry_axis`
+* :class:`bpy.types.DecimateModifier.use_symmetry`
+
+bpy.types.Node
+--------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Node.insert_link`
+
+bpy.types.CompositorNodeBlur
+----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CompositorNodeBlur.use_extended_bounds`
+
+bpy.types.CompositorNodeBokehBlur
+---------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CompositorNodeBokehBlur.use_extended_bounds`
+
+bpy.types.CompositorNodeStabilize
+---------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CompositorNodeStabilize.invert`
+
+bpy.types.ShaderNodeTexEnvironment
+----------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ShaderNodeTexEnvironment.interpolation`
+
+bpy.types.ShaderNodeTexPointDensity
+-----------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ShaderNodeTexPointDensity.cache_point_density`
+* :class:`bpy.types.ShaderNodeTexPointDensity.calc_point_density_minmax`
+
+bpy.types.ShaderNodeTexWave
+---------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ShaderNodeTexWave.wave_profile`
+
+bpy.types.PoseBone
+------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.PoseBone.custom_shape_scale`
+* :class:`bpy.types.PoseBone.use_custom_shape_bone_size`
+
+bpy.types.EnumProperty
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.EnumProperty.enum_items_static`
+
+bpy.types.CyclesRenderSettings
+------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CyclesRenderSettings.debug_opencl_device_type`
+* :class:`bpy.types.CyclesRenderSettings.debug_opencl_kernel_type`
+* :class:`bpy.types.CyclesRenderSettings.debug_use_cpu_avx`
+* :class:`bpy.types.CyclesRenderSettings.debug_use_cpu_avx2`
+* :class:`bpy.types.CyclesRenderSettings.debug_use_cpu_sse2`
+* :class:`bpy.types.CyclesRenderSettings.debug_use_cpu_sse3`
+* :class:`bpy.types.CyclesRenderSettings.debug_use_cpu_sse41`
+* :class:`bpy.types.CyclesRenderSettings.debug_use_opencl_debug`
+* :class:`bpy.types.CyclesRenderSettings.debug_use_qbvh`
+* :class:`bpy.types.CyclesRenderSettings.motion_blur_position`
+* :class:`bpy.types.CyclesRenderSettings.pixel_filter_type`
+* :class:`bpy.types.CyclesRenderSettings.rolling_shutter_duration`
+* :class:`bpy.types.CyclesRenderSettings.rolling_shutter_type`
+
+Removed
+^^^^^^^
+
+* **use_cache**
+
+bpy.types.RenderEngine
+----------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.RenderEngine.bake` (scene, object, pass_type, pass_filter, object_id, pixel_array, num_pixels, depth, result), *was (scene, object, pass_type, object_id, pixel_array, num_pixels, depth, result)*
+
+bpy.types.CYCLES
+----------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.CYCLES.bake` (self, scene, obj, pass_type, pass_filter, object_id, pixel_array, num_pixels, depth, result), *was (self, scene, obj, pass_type, object_id, pixel_array, num_pixels, depth, result)*
+
+bpy.types.RenderLayer
+---------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.RenderLayer.use_ao`
+
+bpy.types.RenderSettings
+------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.RenderSettings.motion_blur_shutter_curve`
+
+Removed
+^^^^^^^
+
+* **use_free_unused_nodes**
+
+bpy.types.SceneRenderLayer
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SceneRenderLayer.use_ao`
+
+bpy.types.SculptToolCapabilities
+--------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SculptToolCapabilities.has_rake_factor`
+
+bpy.types.TextSequence
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.TextSequence.align_y`
+* :class:`bpy.types.TextSequence.wrap_width`
+
+Renamed
+^^^^^^^
+
+* **align** -> :class:`bpy.types.TextSequence.align_x`
+
+bpy.types.WipeSequence
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.WipeSequence.input_2`
+
+bpy.types.SceneSequence
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SceneSequence.use_sequence`
+
+bpy.types.SoundSequence
+-----------------------
+
+Removed
+^^^^^^^
+
+* **filepath**
+
+bpy.types.SequenceModifier
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SequenceModifier.mask_time`
+
+bpy.types.ShapeKey
+------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ShapeKey.normals_polygon_get`
+* :class:`bpy.types.ShapeKey.normals_split_get`
+* :class:`bpy.types.ShapeKey.normals_vertex_get`
+
+bpy.types.SmokeDomainSettings
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SmokeDomainSettings.cache_file_format`
+* :class:`bpy.types.SmokeDomainSettings.data_depth`
+* :class:`bpy.types.SmokeDomainSettings.openvdb_cache_compress_type`
+
+bpy.types.SpaceGraphEditor
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SpaceGraphEditor.cursor_position_x`
+
+bpy.types.ThemeSequenceEditor
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ThemeSequenceEditor.text_strip`
+
+bpy.types.ThemeView3D
+---------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ThemeView3D.text_grease_pencil`
+* :class:`bpy.types.ThemeView3D.text_keyframe`
+
+bpy.types.ToolSettings
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ToolSettings.gpencil_sculpt`
+* :class:`bpy.types.ToolSettings.gpencil_stroke_placement_image_editor`
+* :class:`bpy.types.ToolSettings.gpencil_stroke_placement_sequencer_preview`
+* :class:`bpy.types.ToolSettings.gpencil_stroke_placement_view2d`
+* :class:`bpy.types.ToolSettings.gpencil_stroke_placement_view3d`
+* :class:`bpy.types.ToolSettings.use_gpencil_additive_drawing`
+* :class:`bpy.types.ToolSettings.use_gpencil_stroke_endpoints`
+
+Renamed
+^^^^^^^
+
+* **use_grease_pencil_sessions** -> :class:`bpy.types.ToolSettings.use_gpencil_continuous_drawing`
+
+bpy.types.UserPreferencesSystem
+-------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.UserPreferencesSystem.font_path_ui_mono`
+
+Removed
+^^^^^^^
+
+* **is_occlusion_query_supported**
+* **use_vertex_buffer_objects**
+
+bpy.types.UserPreferencesView
+-----------------------------
+
+Removed
+^^^^^^^
+
+* **use_gl_warn_support**
+
+2.77 to 2.78
+============
+
+bpy.types.AnimData
+------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.AnimData.use_tweak_mode`
+
+bpy.types.BlendData
+-------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.BlendData.cache_files`
+* :class:`bpy.types.BlendData.paint_curves`
+
+bpy.types.BlendDataActions
+--------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataActions.remove` (action, do_unlink), *was (action)*
+
+bpy.types.BlendDataArmatures
+----------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataArmatures.remove` (armature, do_unlink), *was (armature)*
+
+bpy.types.BlendDataBrushes
+--------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataBrushes.remove` (brush, do_unlink), *was (brush)*
+
+bpy.types.BlendDataCameras
+--------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataCameras.remove` (camera, do_unlink), *was (camera)*
+
+bpy.types.BlendDataCurves
+-------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataCurves.remove` (curve, do_unlink), *was (curve)*
+
+bpy.types.BlendDataFonts
+------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataFonts.remove` (vfont, do_unlink), *was (vfont)*
+
+bpy.types.BlendDataGreasePencils
+--------------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataGreasePencils.remove` (grease_pencil, do_unlink), *was (grease_pencil)*
+
+bpy.types.BlendDataGroups
+-------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataGroups.remove` (group, do_unlink), *was (group)*
+
+bpy.types.BlendDataImages
+-------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataImages.remove` (image, do_unlink), *was (image)*
+
+bpy.types.BlendDataLamps
+------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataLamps.remove` (lamp, do_unlink), *was (lamp)*
+
+bpy.types.BlendDataLattices
+---------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataLattices.remove` (lattice, do_unlink), *was (lattice)*
+
+bpy.types.BlendDataLineStyles
+-----------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataLineStyles.remove` (linestyle, do_unlink), *was (linestyle)*
+
+bpy.types.BlendDataMasks
+------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataMasks.remove` (mask, do_unlink), *was (mask)*
+
+bpy.types.BlendDataMaterials
+----------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataMaterials.remove` (material, do_unlink), *was (material)*
+
+bpy.types.BlendDataMeshes
+-------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataMeshes.remove` (mesh, do_unlink), *was (mesh)*
+
+bpy.types.BlendDataMetaBalls
+----------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataMetaBalls.remove` (metaball, do_unlink), *was (metaball)*
+
+bpy.types.BlendDataMovieClips
+-----------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataMovieClips.remove` (clip, do_unlink), *was (clip)*
+
+bpy.types.BlendDataNodeTrees
+----------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataNodeTrees.remove` (tree, do_unlink), *was (tree)*
+
+bpy.types.BlendDataObjects
+--------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataObjects.remove` (object, do_unlink), *was (object)*
+
+bpy.types.BlendDataPalettes
+---------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataPalettes.remove` (palette, do_unlink), *was (palette)*
+
+bpy.types.BlendDataParticles
+----------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataParticles.remove` (particle, do_unlink), *was (particle)*
+
+bpy.types.BlendDataScenes
+-------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataScenes.remove` (scene, do_unlink), *was (scene)*
+
+bpy.types.BlendDataSounds
+-------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataSounds.remove` (sound, do_unlink), *was (sound)*
+
+bpy.types.BlendDataSpeakers
+---------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataSpeakers.remove` (speaker, do_unlink), *was (speaker)*
+
+bpy.types.BlendDataTexts
+------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataTexts.remove` (text, do_unlink), *was (text)*
+
+bpy.types.BlendDataTextures
+---------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataTextures.remove` (texture, do_unlink), *was (texture)*
+
+bpy.types.BlendDataWorlds
+-------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.BlendDataWorlds.remove` (world, do_unlink), *was (world)*
+
+bpy.types.Bone
+--------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Bone.bbone_curveinx`
+* :class:`bpy.types.Bone.bbone_curveiny`
+* :class:`bpy.types.Bone.bbone_curveoutx`
+* :class:`bpy.types.Bone.bbone_curveouty`
+* :class:`bpy.types.Bone.bbone_rollin`
+* :class:`bpy.types.Bone.bbone_rollout`
+* :class:`bpy.types.Bone.bbone_scalein`
+* :class:`bpy.types.Bone.bbone_scaleout`
+* :class:`bpy.types.Bone.use_endroll_as_inroll`
+
+bpy.types.CameraStereoData
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CameraStereoData.pole_merge_angle_from`
+* :class:`bpy.types.CameraStereoData.pole_merge_angle_to`
+* :class:`bpy.types.CameraStereoData.use_pole_merge`
+* :class:`bpy.types.CameraStereoData.use_spherical_stereo`
+
+bpy.types.ClothSettings
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ClothSettings.time_scale`
+* :class:`bpy.types.ClothSettings.use_dynamic_mesh`
+
+bpy.types.CopyLocationConstraint
+--------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CopyLocationConstraint.use_bbone_shape`
+
+bpy.types.CopyTransformsConstraint
+----------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CopyTransformsConstraint.use_bbone_shape`
+
+bpy.types.DampedTrackConstraint
+-------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.DampedTrackConstraint.use_bbone_shape`
+
+bpy.types.LimitDistanceConstraint
+---------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.LimitDistanceConstraint.use_bbone_shape`
+
+bpy.types.LockedTrackConstraint
+-------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.LockedTrackConstraint.use_bbone_shape`
+
+bpy.types.PivotConstraint
+-------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.PivotConstraint.use_bbone_shape`
+
+bpy.types.StretchToConstraint
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.StretchToConstraint.use_bbone_shape`
+
+bpy.types.TrackToConstraint
+---------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.TrackToConstraint.use_bbone_shape`
+
+bpy.types.DopeSheet
+-------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.DopeSheet.use_datablock_sort`
+* :class:`bpy.types.DopeSheet.use_multi_word_filter`
+
+bpy.types.Driver
+----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Driver.use_self`
+
+bpy.types.DriverVariable
+------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.DriverVariable.is_name_valid`
+
+bpy.types.EditBone
+------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.EditBone.bbone_curveinx`
+* :class:`bpy.types.EditBone.bbone_curveiny`
+* :class:`bpy.types.EditBone.bbone_curveoutx`
+* :class:`bpy.types.EditBone.bbone_curveouty`
+* :class:`bpy.types.EditBone.bbone_rollin`
+* :class:`bpy.types.EditBone.bbone_rollout`
+* :class:`bpy.types.EditBone.bbone_scalein`
+* :class:`bpy.types.EditBone.bbone_scaleout`
+* :class:`bpy.types.EditBone.use_endroll_as_inroll`
+
+bpy.types.FCurveKeyframePoints
+------------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.FCurveKeyframePoints.insert` (frame, value, options, keyframe_type), *was (frame, value, options)*
+
+bpy.types.GPencilLayer
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.GPencilLayer.is_parented`
+* :class:`bpy.types.GPencilLayer.matrix_inverse`
+* :class:`bpy.types.GPencilLayer.parent`
+* :class:`bpy.types.GPencilLayer.parent_bone`
+* :class:`bpy.types.GPencilLayer.parent_type`
+* :class:`bpy.types.GPencilLayer.tint_color`
+* :class:`bpy.types.GPencilLayer.tint_factor`
+* :class:`bpy.types.GPencilLayer.unlock_color`
+
+Removed
+^^^^^^^
+
+* **color**
+* **fill_alpha**
+* **fill_color**
+* **is_fill_visible**
+* **is_stroke_visible**
+
+Renamed
+^^^^^^^
+
+* **alpha** -> :class:`bpy.types.GPencilLayer.opacity`
+* **line_width** -> :class:`bpy.types.GPencilLayer.line_change`
+
+bpy.types.GPencilSculptSettings
+-------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.GPencilSculptSettings.affect_position`
+* :class:`bpy.types.GPencilSculptSettings.affect_strength`
+* :class:`bpy.types.GPencilSculptSettings.affect_thickness`
+* :class:`bpy.types.GPencilSculptSettings.selection_alpha`
+
+bpy.types.GPencilStroke
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.GPencilStroke.color`
+* :class:`bpy.types.GPencilStroke.colorname`
+* :class:`bpy.types.GPencilStroke.draw_cyclic`
+* :class:`bpy.types.GPencilStroke.line_width`
+* :class:`bpy.types.GPencilStroke.triangles`
+
+bpy.types.GPencilStrokePoint
+----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.GPencilStrokePoint.strength`
+
+bpy.types.GPencilStrokePoints
+-----------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.GPencilStrokePoints.add` (count, pressure, strength), *was (count)*
+
+bpy.types.GPencilStrokes
+------------------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.GPencilStrokes.new` (colorname), *was ()*
+
+bpy.types.ID
+------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ID.user_remap`
+
+bpy.types.TextCurve
+-------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.TextCurve.align_x`
+* :class:`bpy.types.TextCurve.align_y`
+
+Removed
+^^^^^^^
+
+* **align**
+
+bpy.types.GreasePencil
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.GreasePencil.palettes`
+* :class:`bpy.types.GreasePencil.show_stroke_direction`
+
+bpy.types.PointLamp
+-------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.PointLamp.constant_coefficient`
+* :class:`bpy.types.PointLamp.linear_coefficient`
+* :class:`bpy.types.PointLamp.quadratic_coefficient`
+
+bpy.types.SpotLamp
+------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SpotLamp.constant_coefficient`
+* :class:`bpy.types.SpotLamp.linear_coefficient`
+* :class:`bpy.types.SpotLamp.quadratic_coefficient`
+
+bpy.types.Library
+-----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Library.reload`
+
+bpy.types.Mesh
+--------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Mesh.flip_normals`
+* :class:`bpy.types.Mesh.split_faces`
+
+bpy.types.MovieClip
+-------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MovieClip.animation_data`
+
+bpy.types.ParticleSettings
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ParticleSettings.collision_group`
+
+bpy.types.Scene
+---------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Scene.alembic_export`
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.Scene.collada_export` (filepath, apply_modifiers, export_mesh_type, selected, include_children, include_armatures, include_shapekeys, deform_bones_only, active_uv_only, include_uv_textures, include_material_textures, use_texture_copies, use_ngons, use_object_instantiation, use_blender_profile, sort_by_name, open_sim, export_transformation_type), *was (filepath, apply_modifiers, export_mesh_type, selected, include_children, include_armatures, include_shapekeys, deform_bones_only, active_uv_only, include_uv_textures, include_material_textures, use_texture_copies, use_ngons, use_object_instantiation, sort_by_name, open_sim, export_transformation_type)*
+
+bpy.types.WholeCharacter
+------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.WholeCharacter.doBBone`
+
+bpy.types.MeshPolygon
+---------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MeshPolygon.flip`
+
+bpy.types.BooleanModifier
+-------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.BooleanModifier.double_threshold`
+* :class:`bpy.types.BooleanModifier.solver`
+
+bpy.types.HookModifier
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.HookModifier.matrix_inverse`
+
+bpy.types.NormalEditModifier
+----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.NormalEditModifier.mix_limit`
+
+bpy.types.ShrinkwrapModifier
+----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ShrinkwrapModifier.invert_vertex_group`
+
+bpy.types.SimpleDeformModifier
+------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SimpleDeformModifier.invert_vertex_group`
+
+bpy.types.MovieTrackingStabilization
+------------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MovieTrackingStabilization.active_rotation_track_index`
+* :class:`bpy.types.MovieTrackingStabilization.anchor_frame`
+* :class:`bpy.types.MovieTrackingStabilization.rotation_tracks`
+* :class:`bpy.types.MovieTrackingStabilization.show_tracks_expanded`
+* :class:`bpy.types.MovieTrackingStabilization.target_position`
+* :class:`bpy.types.MovieTrackingStabilization.target_rotation`
+* :class:`bpy.types.MovieTrackingStabilization.target_scale`
+* :class:`bpy.types.MovieTrackingStabilization.use_stabilize_scale`
+
+Removed
+^^^^^^^
+
+* **rotation_track**
+
+bpy.types.MovieTrackingTrack
+----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MovieTrackingTrack.weight_stab`
+
+bpy.types.CompositorNodeColorBalance
+------------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CompositorNodeColorBalance.offset_basis`
+
+bpy.types.ShaderNodeTexPointDensity
+-----------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ShaderNodeTexPointDensity.vertex_attribute_name`
+
+Renamed
+^^^^^^^
+
+* **color_source** -> :class:`bpy.types.ShaderNodeTexPointDensity.particle_color_source`
+* **color_source** -> :class:`bpy.types.ShaderNodeTexPointDensity.vertex_color_source`
+
+bpy.types.PointDensity
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.PointDensity.vertex_attribute_name`
+
+Renamed
+^^^^^^^
+
+* **color_source** -> :class:`bpy.types.PointDensity.particle_color_source`
+* **color_source** -> :class:`bpy.types.PointDensity.vertex_color_source`
+
+bpy.types.PoseBone
+------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.PoseBone.bbone_curveinx`
+* :class:`bpy.types.PoseBone.bbone_curveiny`
+* :class:`bpy.types.PoseBone.bbone_curveoutx`
+* :class:`bpy.types.PoseBone.bbone_curveouty`
+* :class:`bpy.types.PoseBone.bbone_custom_handle_end`
+* :class:`bpy.types.PoseBone.bbone_custom_handle_start`
+* :class:`bpy.types.PoseBone.bbone_rollin`
+* :class:`bpy.types.PoseBone.bbone_rollout`
+* :class:`bpy.types.PoseBone.bbone_scalein`
+* :class:`bpy.types.PoseBone.bbone_scaleout`
+* :class:`bpy.types.PoseBone.use_bbone_custom_handles`
+* :class:`bpy.types.PoseBone.use_bbone_relative_end_handle`
+* :class:`bpy.types.PoseBone.use_bbone_relative_start_handle`
+
+bpy.types.BoolProperty
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.BoolProperty.is_array`
+
+bpy.types.FloatProperty
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.FloatProperty.is_array`
+
+bpy.types.IntProperty
+---------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.IntProperty.is_array`
+
+bpy.types.CyclesMaterialSettings
+--------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CyclesMaterialSettings.displacement_method`
+
+bpy.types.CyclesMeshSettings
+----------------------------
+
+Removed
+^^^^^^^
+
+* **dicing_rate**
+* **displacement_method**
+* **use_subdivision**
+
+bpy.types.CyclesRenderSettings
+------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CyclesRenderSettings.debug_bvh_time_steps`
+* :class:`bpy.types.CyclesRenderSettings.debug_use_cuda_adaptive_compile`
+* :class:`bpy.types.CyclesRenderSettings.debug_use_hair_bvh`
+* :class:`bpy.types.CyclesRenderSettings.dicing_rate`
+* :class:`bpy.types.CyclesRenderSettings.distance_cull_margin`
+* :class:`bpy.types.CyclesRenderSettings.light_sampling_threshold`
+* :class:`bpy.types.CyclesRenderSettings.max_subdivisions`
+* :class:`bpy.types.CyclesRenderSettings.preview_dicing_rate`
+* :class:`bpy.types.CyclesRenderSettings.texture_limit`
+* :class:`bpy.types.CyclesRenderSettings.texture_limit_render`
+* :class:`bpy.types.CyclesRenderSettings.use_distance_cull`
+
+bpy.types.RenderEngine
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.RenderEngine.active_view_get`
+* :class:`bpy.types.RenderEngine.bl_use_spherical_stereo`
+* :class:`bpy.types.RenderEngine.use_spherical_stereo`
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.RenderEngine.camera_model_matrix` (camera, use_spherical_stereo, r_model_matrix), *was (camera, r_model_matrix)*
+* :class:`bpy.types.RenderEngine.camera_shift_x` (camera, use_spherical_stereo), *was (camera)*
+
+bpy.types.RenderSettings
+------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.RenderSettings.use_spherical_stereo`
+* :class:`bpy.types.RenderSettings.use_stamp_labels`
+* :class:`bpy.types.RenderSettings.use_stamp_memory`
+* :class:`bpy.types.RenderSettings.use_world_space_shading`
+
+bpy.types.SceneGameData
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SceneGameData.use_glsl_environment_lighting`
+
+bpy.types.SceneGameRecastData
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SceneGameRecastData.partitioning`
+
+bpy.types.TextSequence
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.TextSequence.color`
+* :class:`bpy.types.TextSequence.shadow_color`
+
+bpy.types.SmokeDomainSettings
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SmokeDomainSettings.heat_grid`
+
+bpy.types.SoftBodySettings
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SoftBodySettings.collision_group`
+
+bpy.types.SpaceNLA
+------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SpaceNLA.show_local_markers`
+
+bpy.types.ThemeDopeSheet
+------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ThemeDopeSheet.keyframe_scale_factor`
+
+bpy.types.ThemeFileBrowser
+--------------------------
+
+Removed
+^^^^^^^
+
+* **active_file**
+* **active_file_text**
+* **scroll_handle**
+* **scrollbar**
+* **space_list**
+
+bpy.types.ToolSettings
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ToolSettings.curve_paint_settings`
+* :class:`bpy.types.ToolSettings.gpencil_brushes`
+* :class:`bpy.types.ToolSettings.keyframe_type`
+* :class:`bpy.types.ToolSettings.use_gpencil_draw_onback`
+
+bpy.types.UILayout
+------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.UILayout.template_cache_file`
+
+bpy.types.UserPreferences
+-------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.UserPreferences.version`
+
+bpy.types.UserPreferencesEdit
+-----------------------------
+
+Removed
+^^^^^^^
+
+* **use_grease_pencil_smooth_stroke**
+
+bpy.types.UserPreferencesInput
+------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.UserPreferencesInput.use_ndof`
+
+bpy.types.UserPreferencesSystem
+-------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.UserPreferencesSystem.legacy_compute_device_type`
+
+Removed
+^^^^^^^
+
+* **compute_device**
+* **compute_device_type**
+
+2.78 to 2.79
+============
+
+bpy.types.DupliObject
+---------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.DupliObject.random_id`
+
+bpy.types.FFmpegSettings
+------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.FFmpegSettings.constant_rate_factor`
+* :class:`bpy.types.FFmpegSettings.ffmpeg_preset`
+* :class:`bpy.types.FFmpegSettings.max_b_frames`
+* :class:`bpy.types.FFmpegSettings.use_max_b_frames`
+
+bpy.types.FieldSettings
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.FieldSettings.use_gravity_falloff`
+
+bpy.types.GPencilLayer
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.GPencilLayer.use_ghosts_always`
+
+bpy.types.GPencilSculptSettings
+-------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.GPencilSculptSettings.lockaxis`
+
+bpy.types.Header
+----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Header.is_extended`
+
+bpy.types.ID
+------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ID.make_local`
+
+bpy.types.Mesh
+--------------
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.Mesh.split_faces` (free_loop_normals), *was ()*
+
+bpy.types.Scene
+---------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Scene.frame_float`
+* :class:`bpy.types.Scene.show_subframe`
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.Scene.alembic_export` (filepath, frame_start, frame_end, xform_samples, geom_samples, shutter_open, shutter_close, selected_only, uvs, normals, vcolors, apply_subdiv, flatten, visible_layers_only, renderable_only, face_sets, subdiv_schema, export_hair, export_particles, compression_type, packuv, scale, triangulate, quad_method, ngon_method), *was (filepath, frame_start, frame_end, xform_samples, geom_samples, shutter_open, shutter_close, selected_only, uvs, normals, vcolors, apply_subdiv, flatten, visible_layers_only, renderable_only, face_sets, subdiv_schema, compression_type, packuv, scale)*
+* :class:`bpy.types.Scene.collada_export` (filepath, apply_modifiers, export_mesh_type, selected, include_children, include_armatures, include_shapekeys, deform_bones_only, active_uv_only, export_texture_type, use_texture_copies, triangulate, use_object_instantiation, use_blender_profile, sort_by_name, export_transformation_type, open_sim, limit_precision, keep_bind_info), *was (filepath, apply_modifiers, export_mesh_type, selected, include_children, include_armatures, include_shapekeys, deform_bones_only, active_uv_only, include_uv_textures, include_material_textures, use_texture_copies, use_ngons, use_object_instantiation, use_blender_profile, sort_by_name, open_sim, export_transformation_type)*
+
+bpy.types.Macro
+---------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Macro.bl_undo_group`
+
+bpy.types.Menu
+--------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Menu.is_extended`
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.Menu.path_menu` (self, searchpaths, operator), *was (self, searchpaths, operator, props_default, filter_ext)*
+
+bpy.types.GPENCIL_PIE_sculpt
+----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.GPENCIL_PIE_sculpt.is_extended`
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.GPENCIL_PIE_sculpt.path_menu` (self, searchpaths, operator), *was (self, searchpaths, operator, props_default, filter_ext)*
+
+bpy.types.GPENCIL_PIE_settings_palette
+--------------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.GPENCIL_PIE_settings_palette.is_extended`
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.GPENCIL_PIE_settings_palette.path_menu` (self, searchpaths, operator), *was (self, searchpaths, operator, props_default, filter_ext)*
+
+bpy.types.GPENCIL_PIE_tool_palette
+----------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.GPENCIL_PIE_tool_palette.is_extended`
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.GPENCIL_PIE_tool_palette.path_menu` (self, searchpaths, operator), *was (self, searchpaths, operator, props_default, filter_ext)*
+
+bpy.types.GPENCIL_PIE_tools_more
+--------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.GPENCIL_PIE_tools_more.is_extended`
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.GPENCIL_PIE_tools_more.path_menu` (self, searchpaths, operator), *was (self, searchpaths, operator, props_default, filter_ext)*
+
+bpy.types.DisplaceModifier
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.DisplaceModifier.space`
+
+bpy.types.MirrorModifier
+------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MirrorModifier.mirror_offset_u`
+* :class:`bpy.types.MirrorModifier.mirror_offset_v`
+
+bpy.types.ScrewModifier
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ScrewModifier.merge_threshold`
+* :class:`bpy.types.ScrewModifier.use_merge_vertices`
+
+bpy.types.MotionPath
+--------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MotionPath.color`
+* :class:`bpy.types.MotionPath.line_thickness`
+* :class:`bpy.types.MotionPath.lines`
+* :class:`bpy.types.MotionPath.use_custom_color`
+
+bpy.types.CompositorNodeBrightContrast
+--------------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CompositorNodeBrightContrast.use_premultiply`
+
+bpy.types.CompositorNodeHueSat
+------------------------------
+
+Removed
+^^^^^^^
+
+* **color_hue**
+* **color_saturation**
+* **color_value**
+
+bpy.types.CompositorNodeSwitchView
+----------------------------------
+
+Removed
+^^^^^^^
+
+* **check**
+
+bpy.types.Operator
+------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Operator.bl_undo_group`
+* :class:`bpy.types.Operator.is_repeat`
+
+bpy.types.Sculpt
+----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Sculpt.constant_detail_resolution`
+
+Removed
+^^^^^^^
+
+* **constant_detail**
+
+bpy.types.Panel
+---------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.Panel.is_extended`
+
+bpy.types.IMAGE_UV_sculpt
+-------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.IMAGE_UV_sculpt.is_extended`
+
+bpy.types.IMAGE_UV_sculpt_curve
+-------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.IMAGE_UV_sculpt_curve.is_extended`
+
+bpy.types.CyclesObjectSettings
+------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CyclesObjectSettings.is_shadow_catcher`
+
+bpy.types.CyclesRenderSettings
+------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CyclesRenderSettings.ao_bounces`
+* :class:`bpy.types.CyclesRenderSettings.ao_bounces_render`
+* :class:`bpy.types.CyclesRenderSettings.debug_opencl_kernel_single_program`
+* :class:`bpy.types.CyclesRenderSettings.debug_opencl_mem_limit`
+* :class:`bpy.types.CyclesRenderSettings.debug_use_cpu_split_kernel`
+* :class:`bpy.types.CyclesRenderSettings.debug_use_cuda_split_kernel`
+
+bpy.types.PropertyGroupItem
+---------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.PropertyGroupItem.id`
+
+bpy.types.RenderEngine
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.RenderEngine.add_pass`
+* :class:`bpy.types.RenderEngine.register_pass`
+* :class:`bpy.types.RenderEngine.update_render_passes`
+
+Function Arguments
+^^^^^^^^^^^^^^^^^^
+
+* :class:`bpy.types.RenderEngine.end_result` (result, cancel, highlight, do_merge_results), *was (result, cancel, do_merge_results)*
+
+bpy.types.CYCLES
+----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CYCLES.update_render_passes`
+
+bpy.types.RenderPass
+--------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.RenderPass.fullname`
+
+Removed
+^^^^^^^
+
+* **debug_type**
+* **type**
+
+bpy.types.RenderPasses
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.RenderPasses.find_by_name`
+
+bpy.types.RenderSettings
+------------------------
+
+Removed
+^^^^^^^
+
+* **sequencer_gl_render**
+* **use_sequencer_gl_preview**
+
+bpy.types.RigidBodyConstraint
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.RigidBodyConstraint.spring_damping_ang_x`
+* :class:`bpy.types.RigidBodyConstraint.spring_damping_ang_y`
+* :class:`bpy.types.RigidBodyConstraint.spring_damping_ang_z`
+* :class:`bpy.types.RigidBodyConstraint.spring_stiffness_ang_x`
+* :class:`bpy.types.RigidBodyConstraint.spring_stiffness_ang_y`
+* :class:`bpy.types.RigidBodyConstraint.spring_stiffness_ang_z`
+* :class:`bpy.types.RigidBodyConstraint.use_spring_ang_x`
+* :class:`bpy.types.RigidBodyConstraint.use_spring_ang_y`
+* :class:`bpy.types.RigidBodyConstraint.use_spring_ang_z`
+
+bpy.types.SceneRenderLayer
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SceneRenderLayer.cycles`
+* :class:`bpy.types.SceneRenderLayer.update_render_passes`
+
+bpy.types.SmokeDomainSettings
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SmokeDomainSettings.axis_slice_method`
+* :class:`bpy.types.SmokeDomainSettings.coba_field`
+* :class:`bpy.types.SmokeDomainSettings.color_ramp`
+* :class:`bpy.types.SmokeDomainSettings.display_thickness`
+* :class:`bpy.types.SmokeDomainSettings.draw_velocity`
+* :class:`bpy.types.SmokeDomainSettings.slice_axis`
+* :class:`bpy.types.SmokeDomainSettings.slice_depth`
+* :class:`bpy.types.SmokeDomainSettings.slice_method`
+* :class:`bpy.types.SmokeDomainSettings.slice_per_voxel`
+* :class:`bpy.types.SmokeDomainSettings.use_color_ramp`
+* :class:`bpy.types.SmokeDomainSettings.vector_draw_type`
+* :class:`bpy.types.SmokeDomainSettings.vector_scale`
+
+bpy.types.SpaceNodeEditor
+-------------------------
+
+Removed
+^^^^^^^
+
+* **show_highlight**
+
+bpy.types.SpaceView3D
+---------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SpaceView3D.active_layer`
+
+bpy.types.SpaceUVEditor
+-----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SpaceUVEditor.other_uv_filter`
+
+bpy.types.ThemeGraphEditor
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ThemeGraphEditor.vertex_bevel`
+
+bpy.types.ThemeImageEditor
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ThemeImageEditor.vertex_bevel`
+
+bpy.types.ThemeView3D
+---------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ThemeView3D.edge_bevel`
+* :class:`bpy.types.ThemeView3D.vertex_bevel`
+
+bpy.types.ToolSettings
+----------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.ToolSettings.gpencil_interpolate`
+
+bpy.types.UIList
+----------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.UIList.is_extended`
+
+bpy.types.CLIP_UL_tracking_objects
+----------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.CLIP_UL_tracking_objects.is_extended`
+
+bpy.types.FILEBROWSER_UL_dir
+----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.FILEBROWSER_UL_dir.is_extended`
+
+bpy.types.GPENCIL_UL_brush
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.GPENCIL_UL_brush.is_extended`
+
+bpy.types.GPENCIL_UL_layer
+--------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.GPENCIL_UL_layer.is_extended`
+
+bpy.types.GPENCIL_UL_palettecolor
+---------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.GPENCIL_UL_palettecolor.is_extended`
+
+bpy.types.MASK_UL_layers
+------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MASK_UL_layers.is_extended`
+
+bpy.types.MATERIAL_UL_matslots
+------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MATERIAL_UL_matslots.is_extended`
+
+bpy.types.MESH_UL_shape_keys
+----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MESH_UL_shape_keys.is_extended`
+
+bpy.types.MESH_UL_uvmaps_vcols
+------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MESH_UL_uvmaps_vcols.is_extended`
+
+bpy.types.MESH_UL_vgroups
+-------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.MESH_UL_vgroups.is_extended`
+
+bpy.types.NODE_UL_interface_sockets
+-----------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.NODE_UL_interface_sockets.is_extended`
+
+bpy.types.PARTICLE_UL_particle_systems
+--------------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.PARTICLE_UL_particle_systems.is_extended`
+
+bpy.types.PHYSICS_UL_dynapaint_surfaces
+---------------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.PHYSICS_UL_dynapaint_surfaces.is_extended`
+
+bpy.types.RENDERLAYER_UL_linesets
+---------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.RENDERLAYER_UL_linesets.is_extended`
+
+bpy.types.RENDERLAYER_UL_renderlayers
+-------------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.RENDERLAYER_UL_renderlayers.is_extended`
+
+bpy.types.RENDERLAYER_UL_renderviews
+------------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.RENDERLAYER_UL_renderviews.is_extended`
+
+bpy.types.SCENE_UL_keying_set_paths
+-----------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.SCENE_UL_keying_set_paths.is_extended`
+
+bpy.types.TEXTURE_UL_texpaintslots
+----------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.TEXTURE_UL_texpaintslots.is_extended`
+
+bpy.types.TEXTURE_UL_texslots
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.TEXTURE_UL_texslots.is_extended`
+
+bpy.types.UI_UL_list
+--------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.UI_UL_list.is_extended`
+
+bpy.types.UserPreferences
+-------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.UserPreferences.app_template`
+
+bpy.types.UserPreferencesSystem
+-------------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.UserPreferencesSystem.use_select_pick_depth`
+
+Removed
+^^^^^^^
+
+* **use_textured_fonts**
+* **virtual_pixel_mode**
+
+bpy.types.UserPreferencesView
+-----------------------------
+
+Added
+^^^^^
+
+* :class:`bpy.types.UserPreferencesView.ui_line_width`
+* :class:`bpy.types.UserPreferencesView.ui_scale`
+* :class:`bpy.types.UserPreferencesView.use_cursor_lock_adjust`
diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py
index b3aebcf6188..75064f2c5ef 100644
--- a/doc/python_api/sphinx_doc_gen.py
+++ b/doc/python_api/sphinx_doc_gen.py
@@ -1013,9 +1013,9 @@ def pymodule2sphinx(basepath, module_name, module, title):
context_type_map = {
"active_base": ("ObjectBase", False),
"active_bone": ("EditBone", False),
+ "active_gpencil_brush": ("GPencilSculptBrush", False),
"active_gpencil_frame": ("GreasePencilLayer", True),
"active_gpencil_layer": ("GPencilLayer", True),
- "active_gpencil_brush": ("GPencilSculptBrush", False),
"active_gpencil_palette": ("GPencilPalette", True),
"active_gpencil_palettecolor": ("GPencilPaletteColor", True),
"active_node": ("Node", False),
@@ -1069,6 +1069,7 @@ context_type_map = {
"selected_bones": ("EditBone", True),
"selected_editable_bases": ("ObjectBase", True),
"selected_editable_bones": ("EditBone", True),
+ "selected_editable_fcurves": ("FCurce", True),
"selected_editable_objects": ("Object", True),
"selected_editable_sequences": ("Sequence", True),
"selected_nodes": ("Node", True),
@@ -1645,6 +1646,11 @@ def write_sphinx_conf_py(basepath):
fw("version = '%s - API'\n" % BLENDER_VERSION_DOTS)
fw("release = '%s - API'\n" % BLENDER_VERSION_DOTS)
+ # Quiet file not in table-of-contents warnings.
+ fw("exclude_patterns = [\n")
+ fw(" 'include__bmesh.rst',\n")
+ fw("]\n\n")
+
if ARGS.sphinx_theme != 'default':
fw("html_theme = '%s'\n" % ARGS.sphinx_theme)
@@ -1665,6 +1671,24 @@ def write_sphinx_conf_py(basepath):
fw("}\n\n")
fw("latex_documents = [ ('contents', 'contents.tex', 'Blender Index', 'Blender Foundation', 'manual'), ]\n")
+
+ # Workaround for useless links leading to compile errors
+ # See https://github.com/sphinx-doc/sphinx/issues/3866
+ fw(r"""
+from sphinx.domains.python import PythonDomain
+
+class PatchedPythonDomain(PythonDomain):
+ def resolve_xref(self, env, fromdocname, builder, typ, target, node, contnode):
+ if 'refspecific' in node:
+ del node['refspecific']
+ return super(PatchedPythonDomain, self).resolve_xref(
+ env, fromdocname, builder, typ, target, node, contnode)
+
+def setup(sphinx):
+ sphinx.override_domain(PatchedPythonDomain)
+""")
+ # end workaround
+
file.close()
@@ -1703,9 +1727,6 @@ def write_rst_contents(basepath):
for info, info_desc in INFO_DOCS:
fw(" %s <%s>\n\n" % (info_desc, info))
fw("\n")
- fw("- :ref:`Blender/Python Add-on Tutorial: a step by step guide on")
- fw(" how to write an add-on from scratch <blender_manual:advanced_scripting_addon_tutorial>`\n")
- fw("\n")
fw(title_string("Application Modules", "=", double=True))
fw(".. toctree::\n")
diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt
index f7e98525b8b..0e4853ee458 100644
--- a/extern/CMakeLists.txt
+++ b/extern/CMakeLists.txt
@@ -113,3 +113,8 @@ endif()
if(WITH_SDL AND WITH_SDL_DYNLOAD)
add_subdirectory(sdlew)
endif()
+
+if(WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE)
+ set(AUDASPACE_CMAKE_CFG ${CMAKE_CURRENT_SOURCE_DIR}/audaspace/blender_config.cmake)
+ add_subdirectory(audaspace)
+endif()
diff --git a/extern/audaspace/AUTHORS b/extern/audaspace/AUTHORS
new file mode 100644
index 00000000000..08007912102
--- /dev/null
+++ b/extern/audaspace/AUTHORS
@@ -0,0 +1,16 @@
+Main author: Jörg Müller <nexyon@gmail.com>
+
+Minor improvements have been done while audaspace was an internal part of Blender by
+
+- Campbell Barton (bug fixes and cleanup)
+- Brecht Van Lommel (bug fixes and cleanup)
+- Sergey Sharybin (bug fixes and cleanup)
+- Nathan Letwory (bug fixes and cleanup)
+- Peter Schlaile (ffmpeg)
+- Jens Verwiebe (jack on Apple)
+
+The first three of them were employed by the Blender Foundation during that time.
+
+Some features (random sounds, dynamic music, playback manager, convolution and HRTFs support) were added as part of the VALS (Virtual Alliances for Learning Society) project by
+
+- Juan Francisco Crespo Galán <dethon_5@outlook.com>
diff --git a/extern/audaspace/CHANGES b/extern/audaspace/CHANGES
new file mode 100644
index 00000000000..bd5acaa88fb
--- /dev/null
+++ b/extern/audaspace/CHANGES
@@ -0,0 +1,115 @@
+Audaspace 1.3
+=============
+
+- New features:
+ - linear interpolation for volume changes in the software mixer
+ - dynamic Loading for JACK
+- Bug fixes:
+ - renamed Jack to JACK
+ - C API was not working
+ - filter python API parameter check
+ - finding ffmpeg with pkgconfig
+
+64884a7 Windows fixes.
+53ba3e6 Implemented JACK dynamic loading.
+5ee0ee1 Continues last commit.
+c24b384 Trying to fix travis-ci python versioning once and for all (at least for python3).
+1fbf3bf Rename Jack => JACK where possible.
+6e4b31f Implemented linear interpolation for volume changes in the software mixer.
+817043c Fixing C API not working.
+c384daf Maybe travis-ci works now.
+aa7ddd7 Fix (hopefully) for previous commit.
+57c5dd7 Configure MACOSX_DEPLOYMENT_TARGET for travis-ci.
+7ae6ff9 Fix travis-ci python path.
+552fea4 Added posibillity to use math constants on MinGW
+c18ed59 Bugfix: incorrect parameter check in python API.
+6f048c3 CMake: fix finding ffmpeg with pkgconfig.
+
+Audaspace 1.2
+=============
+
+- New features:
+ - sound list
+ - random sounds
+ - dynamic music playing
+ - playback manager
+ - convolution/reverbation
+ - multi-threading
+ - binaural audio
+- API changes:
+ - changing default sample rate from 44.1 to 48 kHz
+- Bug fixes:
+ - several standard library fixes.
+- Bindings API:
+ - mixdown C API refactored
+- CMake/Building:
+ - assuring numpy is installed
+ - building the Python module on Mac OS X with CMake
+
+a6b6e70 Changing default sample rate from 44.1 to 48 kHz.
+20f0164 Bugfix: CMake custom command for python module on OS X.
+98679a2 Bugfix: using standard library (s)rand.
+5ab4fe7 Bugfix: first step in fixing the vector of array problem.
+e83f01d FFTW: trying to use complex to circumvent vector of array problem.
+093ebc0 Bugfix: abs -> std::fabs.
+328d7cc Bugfix: standard library include and call fixes.
+f78e330 Bugfix: using correct includes.
+64d7825 Behavior change: C API Mixdown
+749896b Merge pull request #3 from DethonUSAL/master
+6e9491c CMake: finding NumPy.
+
+Audaspace 1.1
+=============
+
+- Bug fixes:
+ - pkgconfig uses cmake configured library directory
+ - FFMPEG file writing crashed, also corrected pts for encoding
+ - silenced Doxygen warnings about undefined defines
+- C++ API:
+ - ResampleReader uses specs instead of sample rate
+- Bindings API:
+ - writing sounds to files
+ - reading sound data, specs and length
+ - resampling sounds
+- CMake/Building:
+ - first steps towards building for Mac
+ - windows builds copy dlls automatically
+- Python module:
+ - using distutils instead of setuptools
+ - added numpy as dependency
+- Documentation:
+ - added windows building and plugin documentation
+ - disabled html timestamps in doxygen
+ - updated sphinx template
+ - build binding documentation without installing the python module
+
+Detailed list of changes:
+
+326a300 Documentation: windows, dll copying now done automatically.
+54cac4f Windows: install dlls.
+65c2d78 Bindings: Sound length and specs properties.
+c38da70 Bindings API: adding resampling.
+374822f Documentation: Added windows and plugin documentation.
+a9dc5b9 Python module: add numpy as dependency.
+c933a02 C API: implement new API based on the python API.
+ac54c52 Python API: silence numpy warnings.
+c9491bb Python API: checking for a positive sample rate.
+4eb1fa8 Python API: reorder functions.
+ec7c00b Sphinx update and fixes.
+e16d979 FFMPEG: correct pts during encoding.
+7ab3935 Documentation: git path fix.
+28d77bb Python: use distutils directly instead of setuptools.
+1f43284 Silence doxygen warning about undefined defines.
+0d52458 CMake: improvements and fixes for building on Mac.
+37daedf FFMPEG: bugfixes for file writing.
+780ca2a ResampleReader API change
+4d9863d Python API: Optimization for cached sounds' data access.
+ea04fee Python API: read sound data and create sound buffers as well as getting the specs of a sound.
+335b293 Python sound writing API.
+36a7252 Pkgconfig: use cmake configured library directory.
+5503908 Doxygen: disable html timestamps.
+
+Initial Release of Audaspace 1.0
+================================
+
+Audaspace has been the internal audio library of blender since blender 2.5. It is now released as a standalone library to be used in other projects as well.
diff --git a/extern/audaspace/CMakeLists.txt b/extern/audaspace/CMakeLists.txt
new file mode 100644
index 00000000000..9e2921ef35a
--- /dev/null
+++ b/extern/audaspace/CMakeLists.txt
@@ -0,0 +1,986 @@
+################################################################################
+# Copyright 2009-2016 Jörg Müller
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+################################################################################
+
+cmake_minimum_required(VERSION 3.0)
+include(CMakeDependentOption)
+
+if(POLICY CMP0054)
+ cmake_policy(SET CMP0054 NEW)
+endif()
+
+project(audaspace)
+
+set(AUDASPACE_VERSION 1.3)
+set(AUDASPACE_LONG_VERSION ${AUDASPACE_VERSION}.0)
+
+if(DEFINED AUDASPACE_CMAKE_CFG)
+ include(${AUDASPACE_CMAKE_CFG})
+endif()
+
+if(NOT DEFINED AUDASPACE_STANDALONE)
+ set(AUDASPACE_STANDALONE TRUE)
+endif()
+
+# sources
+
+set(SRC
+ src/devices/DefaultSynchronizer.cpp
+ src/devices/DeviceManager.cpp
+ src/devices/NULLDevice.cpp
+ src/devices/ReadDevice.cpp
+ src/devices/SoftwareDevice.cpp
+ src/Exception.cpp
+ src/file/File.cpp
+ src/file/FileManager.cpp
+ src/file/FileWriter.cpp
+ src/fx/Accumulator.cpp
+ src/fx/ADSR.cpp
+ src/fx/ADSRReader.cpp
+ src/fx/BaseIIRFilterReader.cpp
+ src/fx/ButterworthCalculator.cpp
+ src/fx/Butterworth.cpp
+ src/fx/CallbackIIRFilterReader.cpp
+ src/fx/Delay.cpp
+ src/fx/DelayReader.cpp
+ src/fx/DynamicIIRFilter.cpp
+ src/fx/DynamicIIRFilterReader.cpp
+ src/fx/DynamicMusic.cpp
+ src/fx/Effect.cpp
+ src/fx/EffectReader.cpp
+ src/fx/Envelope.cpp
+ src/fx/Fader.cpp
+ src/fx/FaderReader.cpp
+ src/fx/HighpassCalculator.cpp
+ src/fx/Highpass.cpp
+ src/fx/IIRFilter.cpp
+ src/fx/IIRFilterReader.cpp
+ src/fx/Limiter.cpp
+ src/fx/LimiterReader.cpp
+ src/fx/Loop.cpp
+ src/fx/LoopReader.cpp
+ src/fx/LowpassCalculator.cpp
+ src/fx/Lowpass.cpp
+ src/fx/MutableReader.cpp
+ src/fx/MutableSound.cpp
+ src/fx/Pitch.cpp
+ src/fx/PitchReader.cpp
+ src/fx/PlaybackManager.cpp
+ src/fx/PlaybackCategory.cpp
+ src/fx/Reverse.cpp
+ src/fx/ReverseReader.cpp
+ src/fx/SoundList.cpp
+ src/fx/Source.cpp
+ src/fx/Sum.cpp
+ src/fx/Threshold.cpp
+ src/fx/Volume.cpp
+ src/fx/VolumeReader.cpp
+ src/fx/VolumeSound.cpp
+ src/fx/VolumeStorage.cpp
+ src/generator/Sawtooth.cpp
+ src/generator/SawtoothReader.cpp
+ src/generator/Silence.cpp
+ src/generator/SilenceReader.cpp
+ src/generator/Sine.cpp
+ src/generator/SineReader.cpp
+ src/generator/Square.cpp
+ src/generator/SquareReader.cpp
+ src/generator/Triangle.cpp
+ src/generator/TriangleReader.cpp
+ src/respec/ChannelMapper.cpp
+ src/respec/ChannelMapperReader.cpp
+ src/respec/Converter.cpp
+ src/respec/ConverterFunctions.cpp
+ src/respec/ConverterReader.cpp
+ src/respec/JOSResample.cpp
+ src/respec/JOSResampleReaderCoeff.cpp
+ src/respec/JOSResampleReader.cpp
+ src/respec/LinearResample.cpp
+ src/respec/LinearResampleReader.cpp
+ src/respec/Mixer.cpp
+ src/respec/ResampleReader.cpp
+ src/respec/SpecsChanger.cpp
+ src/sequence/AnimateableProperty.cpp
+ src/sequence/Double.cpp
+ src/sequence/DoubleReader.cpp
+ src/sequence/PingPong.cpp
+ src/sequence/Sequence.cpp
+ src/sequence/SequenceData.cpp
+ src/sequence/SequenceEntry.cpp
+ src/sequence/SequenceHandle.cpp
+ src/sequence/SequenceReader.cpp
+ src/sequence/Superpose.cpp
+ src/sequence/SuperposeReader.cpp
+ src/util/Barrier.cpp
+ src/util/Buffer.cpp
+ src/util/BufferReader.cpp
+ src/util/StreamBuffer.cpp
+ src/util/ThreadPool.cpp
+)
+
+set(PRIVATE_HDR
+ src/sequence/SequenceHandle.h
+)
+
+set(PUBLIC_HDR
+ include/devices/DefaultSynchronizer.h
+ include/devices/DeviceManager.h
+ include/devices/I3DDevice.h
+ include/devices/I3DHandle.h
+ include/devices/IDeviceFactory.h
+ include/devices/IDevice.h
+ include/devices/IHandle.h
+ include/devices/ISynchronizer.h
+ include/devices/NULLDevice.h
+ include/devices/ReadDevice.h
+ include/devices/SoftwareDevice.h
+ include/Exception.h
+ include/file/File.h
+ include/file/FileManager.h
+ include/file/FileWriter.h
+ include/file/IFileInput.h
+ include/file/IFileOutput.h
+ include/file/IWriter.h
+ include/fx/Accumulator.h
+ include/fx/ADSR.h
+ include/fx/ADSRReader.h
+ include/fx/BaseIIRFilterReader.h
+ include/fx/ButterworthCalculator.h
+ include/fx/Butterworth.h
+ include/fx/CallbackIIRFilterReader.h
+ include/fx/Delay.h
+ include/fx/DelayReader.h
+ include/fx/DynamicIIRFilter.h
+ include/fx/DynamicIIRFilterReader.h
+ include/fx/DynamicMusic.h
+ include/fx/Effect.h
+ include/fx/EffectReader.h
+ include/fx/Envelope.h
+ include/fx/Fader.h
+ include/fx/FaderReader.h
+ include/fx/HighpassCalculator.h
+ include/fx/Highpass.h
+ include/fx/IDynamicIIRFilterCalculator.h
+ include/fx/IIRFilter.h
+ include/fx/IIRFilterReader.h
+ include/fx/Limiter.h
+ include/fx/LimiterReader.h
+ include/fx/Loop.h
+ include/fx/LoopReader.h
+ include/fx/LowpassCalculator.h
+ include/fx/Lowpass.h
+ include/fx/MutableReader.h
+ include/fx/MutableSound.h
+ include/fx/Pitch.h
+ include/fx/PitchReader.h
+ include/fx/PlaybackManager.h
+ include/fx/PlaybackCategory.h
+ include/fx/Reverse.h
+ include/fx/ReverseReader.h
+ include/fx/SoundList.h
+ include/fx/Source.h
+ include/fx/Sum.h
+ include/fx/Threshold.h
+ include/fx/Volume.h
+ include/fx/VolumeReader.h
+ include/fx/VolumeSound.h
+ include/fx/VolumeStorage.h
+ include/generator/Sawtooth.h
+ include/generator/SawtoothReader.h
+ include/generator/Silence.h
+ include/generator/SilenceReader.h
+ include/generator/Sine.h
+ include/generator/SineReader.h
+ include/generator/Square.h
+ include/generator/SquareReader.h
+ include/generator/Triangle.h
+ include/generator/TriangleReader.h
+ include/IReader.h
+ include/ISound.h
+ include/plugin/PluginManager.h
+ include/respec/ChannelMapper.h
+ include/respec/ChannelMapperReader.h
+ include/respec/ConverterFunctions.h
+ include/respec/Converter.h
+ include/respec/ConverterReader.h
+ include/respec/JOSResample.h
+ include/respec/JOSResampleReader.h
+ include/respec/LinearResample.h
+ include/respec/LinearResampleReader.h
+ include/respec/Mixer.h
+ include/respec/ResampleReader.h
+ include/respec/Specification.h
+ include/respec/SpecsChanger.h
+ include/sequence/AnimateableProperty.h
+ include/sequence/Double.h
+ include/sequence/DoubleReader.h
+ include/sequence/PingPong.h
+ include/sequence/SequenceData.h
+ include/sequence/SequenceEntry.h
+ include/sequence/Sequence.h
+ include/sequence/SequenceReader.h
+ include/sequence/Superpose.h
+ include/sequence/SuperposeReader.h
+ include/util/Barrier.h
+ include/util/Buffer.h
+ include/util/BufferReader.h
+ include/util/ILockable.h
+ include/util/Math3D.h
+ include/util/StreamBuffer.h
+ include/util/ThreadPool.h
+)
+
+set(HDR ${PRIVATE_HDR} ${PUBLIC_HDR})
+
+set(INCLUDE ${CMAKE_CURRENT_BINARY_DIR} include)
+
+if(WIN32)
+ set(LIBRARIES)
+ if(AUDASPACE_STANDALONE)
+ set(DLLS)
+ set(LIBRARY_PATH "../lib" CACHE PATH "Path which contains the libraries.")
+ file(GLOB LIBRARY_DIRS ${LIBRARY_PATH}/*)
+ list(APPEND CMAKE_PREFIX_PATH ${LIBRARY_DIRS})
+ endif()
+else()
+ set(LIBRARIES ${CMAKE_DL_LIBS} -lpthread)
+endif()
+
+set(STATIC_PLUGINS "")
+
+# dependencies
+
+if(AUDASPACE_STANDALONE)
+ set(PACKAGE_OPTION QUIET)
+ list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")
+
+ option(BUILD_DEMOS "Build and install demos" TRUE)
+
+ option(SHARED_LIBRARY "Build Shared Library" TRUE)
+
+ option(WITH_C "Build C Module" TRUE)
+ option(WITH_DOCS "Build C++ HTML Documentation with Doxygen" TRUE)
+ option(WITH_FFMPEG "Build With FFMPEG" TRUE)
+ option(WITH_FFTW "Build With FFTW" TRUE)
+ option(WITH_JACK "Build With Plugin" TRUE)
+ option(WITH_LIBSNDFILE "Build With LibSndFile" TRUE)
+ option(WITH_OPENAL "Build With OpenAL" TRUE)
+ option(WITH_PYTHON "Build With Python Library" TRUE)
+ option(WITH_SDL "Build With SDL" TRUE)
+ option(WITH_STRICT_DEPENDENCIES "Error and abort instead of warning if a library is not found." FALSE)
+
+ if(WITH_STRICT_DEPENDENCIES)
+ set(PACKAGE_OPTION REQUIRED)
+ endif()
+endif()
+
+if(WIN32)
+ set(DEFAULT_PLUGIN_PATH "." CACHE STRING "Default plugin installation and loading path.")
+ set(DOCUMENTATION_INSTALL_PATH "doc" CACHE PATH "Path where the documentation is installed.")
+else()
+ set(DEFAULT_PLUGIN_PATH "${CMAKE_INSTALL_PREFIX}/share/audaspace/plugins" CACHE STRING "Default plugin installation and loading path.")
+ set(DOCUMENTATION_INSTALL_PATH "share/doc/audaspace" CACHE PATH "Path where the documentation is installed.")
+endif()
+
+if(AUDASPACE_STANDALONE)
+ cmake_dependent_option(SEPARATE_C "Build C Binding as separate library" TRUE "WITH_C" FALSE)
+ cmake_dependent_option(PLUGIN_FFMPEG "Build FFMPEG Plugin" TRUE "WITH_FFMPEG;SHARED_LIBRARY" FALSE)
+ cmake_dependent_option(PLUGIN_JACK "Build JACK Plugin" TRUE "WITH_JACK;SHARED_LIBRARY" FALSE)
+ cmake_dependent_option(PLUGIN_LIBSNDFILE "Build LibSndFile Plugin" TRUE "WITH_LIBSNDFILE;SHARED_LIBRARY" FALSE)
+ cmake_dependent_option(PLUGIN_OPENAL "Build OpenAL Plugin" TRUE "WITH_OPENAL;SHARED_LIBRARY" FALSE)
+ cmake_dependent_option(PLUGIN_SDL "Build SDL Plugin" TRUE "WITH_SDL;SHARED_LIBRARY" FALSE)
+ cmake_dependent_option(WITH_PYTHON_MODULE "Build Python Module" TRUE "WITH_PYTHON" FALSE)
+ cmake_dependent_option(USE_SDL2 "Use SDL2 instead of 1 if available" TRUE "WITH_SDL" FALSE)
+ cmake_dependent_option(DYNLOAD_JACK "Dynamically load JACK" FALSE "WITH_JACK" FALSE)
+ cmake_dependent_option(WITH_BINDING_DOCS "Build C/Python HTML Documentation with Sphinx" TRUE "WITH_PYTHON_MODULE" FALSE)
+endif()
+
+# compiler options
+
+if(AUDASPACE_STANDALONE)
+ if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
+ add_definitions(-std=c++11)
+ list(APPEND CMAKE_C_COMPILER_FLAGS "-fvisibility=hidden")
+ list(APPEND CMAKE_CXX_COMPILER_FLAGS "-fvisibility=hidden")
+ endif()
+
+ if(MSVC)
+ list(APPEND CMAKE_C_FLAGS_DEBUG "/Zi /Od")
+ list(APPEND CMAKE_CXX_FLAGS_DEBUG "/Zi /Od")
+ list(APPEND CMAKE_SHARED_LINKER_FLAGS_DEBUG "/DEBUG")
+ list(APPEND CMAKE_STATIC_LINKER_FLAGS_DEBUG "/DEBUG")
+ list(APPEND CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG")
+
+ if(SHARED_LIBRARY)
+ include(GenerateExportHeader)
+ endif()
+ endif()
+
+ if(APPLE AND NOT CMAKE_OSX_DEPLOYMENT_TARGET)
+ set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "" FORCE)
+ endif()
+endif()
+
+if(MSVC)
+ add_definitions(
+ /D_USE_MATH_DEFINES
+ /EHsc
+ /DNOMINMAX
+ /D_STDINT_H
+ )
+endif()
+
+# platform specific options
+
+if(MSYS OR MINGW)
+ add_definitions(-D_USE_MATH_DEFINES)
+endif()
+
+# C
+if(WITH_C)
+ set(C_SRC
+ bindings/C/AUD_ThreadPool.cpp
+ bindings/C/AUD_Source.cpp
+ bindings/C/AUD_Device.cpp
+ bindings/C/AUD_DynamicMusic.cpp
+ bindings/C/AUD_Handle.cpp
+ bindings/C/AUD_PlaybackManager.cpp
+ bindings/C/AUD_Sequence.cpp
+ bindings/C/AUD_Sound.cpp
+ bindings/C/AUD_Special.cpp
+ )
+ set(C_HDR
+ bindings/C/AUD_ThreadPool.h
+ bindings/C/AUD_Source.h
+ bindings/C/AUD_Device.h
+ bindings/C/AUD_DynamicMusic.h
+ bindings/C/AUD_Handle.h
+ bindings/C/AUD_PlaybackManager.h
+ bindings/C/AUD_Sequence.h
+ bindings/C/AUD_Sound.h
+ bindings/C/AUD_Special.h
+ bindings/C/AUD_Types.h
+ )
+
+if(WITH_FFTW)
+ list(APPEND C_SRC
+ bindings/C/AUD_HRTF.cpp
+ bindings/C/AUD_ImpulseResponse.cpp
+ )
+
+ list(APPEND C_HDR
+ bindings/C/AUD_HRTF.h
+ bindings/C/AUD_ImpulseResponse.h
+ )
+ endif()
+
+ if(NOT SEPARATE_C)
+ list(APPEND SRC ${C_SRC})
+ list(APPEND HDR ${C_HDR})
+ else()
+ set(AUDASPACE_C_LIBRARY -laudaspace-c)
+ endif()
+endif()
+
+# FFMPEG
+if(WITH_FFMPEG)
+ if(AUDASPACE_STANDALONE)
+ find_package(FFMPEG ${PACKAGE_OPTION})
+ endif()
+
+ if(FFMPEG_FOUND)
+ set(FFMPEG_SRC
+ plugins/ffmpeg/FFMPEG.cpp
+ plugins/ffmpeg/FFMPEGReader.cpp
+ plugins/ffmpeg/FFMPEGWriter.cpp
+ )
+ set(FFMPEG_HDR
+ plugins/ffmpeg/FFMPEG.h
+ plugins/ffmpeg/FFMPEGReader.h
+ plugins/ffmpeg/FFMPEGWriter.h
+ )
+
+ if(NOT PLUGIN_FFMPEG)
+ list(APPEND INCLUDE ${FFMPEG_INCLUDE_DIRS})
+ list(APPEND LIBRARIES ${FFMPEG_LIBRARIES})
+ list(APPEND SRC ${FFMPEG_SRC})
+ list(APPEND HDR ${FFMPEG_HDR})
+ list(APPEND STATIC_PLUGINS FFMPEG)
+ endif()
+
+ if(WIN32 AND AUDASPACE_STANDALONE)
+ file(GLOB FFMPEG_DLLS ${LIBRARY_PATH}/ffmpeg/bin/*.dll)
+ list(APPEND DLLS ${FFMPEG_DLLS})
+ endif()
+ else()
+ set(WITH_FFMPEG FALSE CACHE BOOL "Build With FFMPEG" FORCE)
+ message(WARNING "FFMPEG not found, plugin will not be built.")
+ endif()
+endif()
+
+# FFTW
+if(WITH_FFTW)
+ if(AUDASPACE_STANDALONE)
+ find_package(FFTW ${PACKAGE_OPTION})
+ endif()
+
+ if(FFTW_FOUND)
+ set(FFTW_SRC
+ src/fx/BinauralSound.cpp
+ src/fx/BinauralReader.cpp
+ src/fx/Convolver.cpp
+ src/fx/ConvolverReader.cpp
+ src/fx/ConvolverSound.cpp
+ src/fx/FFTConvolver.cpp
+ src/fx/HRTF.cpp
+ src/fx/ImpulseResponse.cpp
+ src/util/FFTPlan.cpp
+ )
+ set(FFTW_HDR
+ include/fx/BinauralSound.h
+ include/fx/BinauralReader.h
+ include/fx/Convolver.h
+ include/fx/ConvolverReader.h
+ include/fx/ConvolverSound.h
+ include/fx/FFTConvolver.h
+ include/fx/HRTF.h
+ include/fx/HRTFLoader.h
+ include/fx/ImpulseResponse.h
+ include/util/FFTPlan.h
+ )
+
+ add_definitions(-DWITH_CONVOLUTION)
+
+ list(APPEND INCLUDE ${FFTW_INCLUDE_DIR})
+ list(APPEND LIBRARIES ${FFTW_LIBRARY})
+
+ list(APPEND SRC ${FFTW_SRC})
+ list(APPEND HDR ${FFTW_HDR})
+
+ if(WIN32 AND AUDASPACE_STANDALONE)
+ file(GLOB FFTW_DLLS ${LIBRARY_PATH}/fftw/bin/*.dll)
+ list(APPEND DLLS ${FFTW_DLLS})
+ endif()
+ else()
+ set(WITH_FFTW FALSE CACHE BOOL "Build With FFTW" FORCE)
+ message(WARNING "FFTW not found, convolution functionality will not be built.")
+ endif()
+endif()
+
+# JACK
+if(WITH_JACK)
+ if(AUDASPACE_STANDALONE)
+ find_package(Jack ${PACKAGE_OPTION})
+ endif()
+
+ if(JACK_FOUND)
+ set(JACK_SRC
+ plugins/jack/JackDevice.cpp
+ plugins/jack/JackSynchronizer.cpp
+ plugins/jack/JackLibrary.cpp
+ )
+ set(JACK_HDR
+ plugins/jack/JackDevice.h
+ plugins/jack/JackSynchronizer.h
+ plugins/jack/JackLibrary.h
+ plugins/jack/JackSymbols.h
+ )
+
+ if(DYNLOAD_JACK)
+ add_definitions(-DDYNLOAD_JACK)
+ endif()
+
+ if(NOT PLUGIN_JACK)
+ list(APPEND INCLUDE ${JACK_INCLUDE_DIRS})
+ if(NOT DYNLOAD_JACK)
+ list(APPEND LIBRARIES ${JACK_LIBRARIES})
+ endif()
+ list(APPEND SRC ${JACK_SRC})
+ list(APPEND HDR ${JACK_HDR})
+ list(APPEND STATIC_PLUGINS JackDevice)
+ endif()
+
+ if(WIN32 AND AUDASPACE_STANDALONE)
+ file(GLOB JACK_DLLS ${LIBRARY_PATH}/jack/bin/*.dll)
+ list(APPEND DLLS ${JACK_DLLS})
+ endif()
+ else()
+ set(WITH_JACK FALSE CACHE BOOL "Build With JACK" FORCE)
+ message(WARNING "JACK not found, plugin will not be built.")
+ endif()
+endif()
+
+# LibSndFile
+if(WITH_LIBSNDFILE)
+ if(AUDASPACE_STANDALONE)
+ find_package(LibSndFile ${PACKAGE_OPTION})
+ endif()
+
+ if(LIBSNDFILE_FOUND)
+ set(LIBSNDFILE_SRC
+ plugins/libsndfile/SndFile.cpp
+ plugins/libsndfile/SndFileReader.cpp
+ plugins/libsndfile/SndFileWriter.cpp
+ )
+ set(LIBSNDFILE_HDR
+ plugins/libsndfile/SndFile.h
+ plugins/libsndfile/SndFileReader.h
+ plugins/libsndfile/SndFileWriter.h
+ )
+
+ if(NOT PLUGIN_LIBSNDFILE)
+ list(APPEND INCLUDE ${LIBSNDFILE_INCLUDE_DIRS})
+ list(APPEND LIBRARIES ${LIBSNDFILE_LIBRARIES})
+ list(APPEND SRC ${LIBSNDFILE_SRC})
+ list(APPEND HDR ${LIBSNDFILE_HDR})
+ list(APPEND STATIC_PLUGINS SndFile)
+ endif()
+
+ if(WIN32 AND AUDASPACE_STANDALONE)
+ file(GLOB LIBSNDFILE_DLLS ${LIBRARY_PATH}/libsndfile/bin/*.dll)
+ list(APPEND DLLS ${LIBSNDFILE_DLLS})
+ endif()
+ else()
+ set(WITH_LIBSNDFILE FALSE CACHE BOOL "Build With LibSndFile" FORCE)
+ message(WARNING "LibSndFile not found, plugin will not be built.")
+ endif()
+endif()
+
+# OpenAL
+if(WITH_OPENAL)
+ if(AUDASPACE_STANDALONE)
+ find_package(OpenAL ${PACKAGE_OPTION})
+ endif()
+
+ if(OPENAL_FOUND)
+ set(OPENAL_SRC
+ plugins/openal/OpenALDevice.cpp
+ plugins/openal/OpenALReader.cpp
+ )
+ set(OPENAL_HDR
+ plugins/openal/OpenALDevice.h
+ plugins/openal/OpenALReader.h
+ )
+
+ if(NOT PLUGIN_OPENAL)
+ list(APPEND INCLUDE ${OPENAL_INCLUDE_DIR})
+ list(APPEND LIBRARIES ${OPENAL_LIBRARY})
+ list(APPEND SRC ${OPENAL_SRC})
+ list(APPEND HDR ${OPENAL_HDR})
+ list(APPEND STATIC_PLUGINS OpenALDevice)
+ endif()
+
+ if(WIN32 AND AUDASPACE_STANDALONE)
+ file(GLOB OPENAL_DLLS ${LIBRARY_PATH}/OpenAL/bin/*.dll)
+ list(APPEND DLLS ${OPENAL_DLLS})
+ endif()
+ else()
+ set(WITH_OPENAL FALSE CACHE BOOL "Build With OpenAL" FORCE)
+ message(WARNING "OpenAL not found, plugin will not be built.")
+ endif()
+endif()
+
+# Python
+if(WITH_PYTHON)
+ if(AUDASPACE_STANDALONE)
+ find_package(PythonLibs 3.2 ${PACKAGE_OPTION})
+ find_package(NumPy ${PACKAGE_OPTION})
+ endif()
+
+ if(PYTHONLIBS_FOUND AND NUMPY_FOUND)
+ list(APPEND INCLUDE ${PYTHON_INCLUDE_DIRS} ${NUMPY_INCLUDE_DIRS})
+
+ if(WITH_PYTHON_MODULE)
+ find_package(PythonInterp 3.2 ${PACKAGE_OPTION})
+
+ if(NOT PYTHONINTERP_FOUND)
+ set(WITH_PYTHON_MODULE FALSE)
+ message(WARNING "Python interpreter not found, module will not be built.")
+ endif()
+ endif()
+
+ set(AUDASPACE_PY_LIBRARY -laudaspace-py)
+
+ if(WIN32 AND AUDASPACE_STANDALONE)
+ file(GLOB PYTHON_DLLS ${LIBRARY_PATH}/Python/bin/*.dll)
+ list(APPEND DLLS ${PYTHON_DLLS})
+ endif()
+ else()
+ set(WITH_PYTHON FALSE CACHE BOOL "Build With Python Library" FORCE)
+ message(WARNING "Python libraries not found, language binding will not be built.")
+ endif()
+endif()
+
+# SDL
+if(WITH_SDL)
+ if(AUDASPACE_STANDALONE)
+ if(USE_SDL2)
+ find_package(SDL2)
+ if(SDL2_FOUND)
+ set(SDL_INCLUDE_DIR ${SDL2_INCLUDE_DIR})
+ set(SDL_LIBRARY ${SDL2_LIBRARY})
+ set(SDL_FOUND TRUE)
+ else()
+ find_package(SDL ${PACKAGE_OPTION})
+ endif()
+ else()
+ find_package(SDL ${PACKAGE_OPTION})
+ endif()
+ endif()
+
+ if(SDL_FOUND)
+ set(SDL_SRC
+ plugins/sdl/SDLDevice.cpp
+ )
+ set(SDL_HDR
+ plugins/sdl/SDLDevice.h
+ )
+
+ if(NOT PLUGIN_SDL)
+ list(APPEND INCLUDE ${SDL_INCLUDE_DIR})
+ list(APPEND LIBRARIES ${SDL_LIBRARY})
+ list(APPEND SRC ${SDL_SRC})
+ list(APPEND HDR ${SDL_HDR})
+ list(APPEND STATIC_PLUGINS SDLDevice)
+ endif()
+
+ if(WIN32 AND AUDASPACE_STANDALONE)
+ file(GLOB SDL_DLLS ${LIBRARY_PATH}/sdl/bin/*.dll)
+ list(APPEND DLLS ${SDL_DLLS})
+ endif()
+ else()
+ set(WITH_SDL FALSE CACHE BOOL "Build With SDL" FORCE)
+ message(WARNING "SDL not found, plugin will not be built.")
+ endif()
+endif()
+
+# library configuration
+
+if(SHARED_LIBRARY)
+ set(AUD_LIBRARY_TYPE AUD_SHARED_LIBRARY)
+ set(LIBRARY_TYPE SHARED)
+ add_definitions(-DAUD_BUILD_SHARED_LIBRARY)
+else()
+ set(AUD_LIBRARY_TYPE AUD_STATIC_LIBRARY)
+ set(LIBRARY_TYPE STATIC)
+endif()
+
+# file configuration
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/Audaspace.h.in ${CMAKE_CURRENT_BINARY_DIR}/Audaspace.h ESCAPE_QUOTES @ONLY)
+
+list(APPEND HDR ${CMAKE_CURRENT_BINARY_DIR}/Audaspace.h)
+
+set(STATIC_PLUGIN_CLASSES "")
+set(STATIC_PLUGIN_REGISTERS "")
+
+foreach(PLUGIN ${STATIC_PLUGINS})
+ list(APPEND STATIC_PLUGIN_CLASSES "STATIC_PLUGIN_CLASS(" ${PLUGIN} ")\n")
+ list(APPEND STATIC_PLUGIN_REGISTERS "\tSTATIC_PLUGIN_REGISTER(" ${PLUGIN} ")\n")
+endforeach()
+
+string(CONCAT STATIC_PLUGIN_CLASSES ${STATIC_PLUGIN_CLASSES})
+string(CONCAT STATIC_PLUGIN_REGISTERS ${STATIC_PLUGIN_REGISTERS})
+
+if(WIN32)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/plugin/PluginManagerWindows.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/PluginManager.cpp ESCAPE_QUOTES @ONLY)
+ if(WITH_FFTW)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/fx/HRTFLoaderWindows.cpp ${CMAKE_CURRENT_BINARY_DIR}/HRTFLoader.cpp COPYONLY)
+ endif()
+else()
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/plugin/PluginManagerUnix.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/PluginManager.cpp ESCAPE_QUOTES @ONLY)
+ if(WITH_FFTW)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/fx/HRTFLoaderUnix.cpp ${CMAKE_CURRENT_BINARY_DIR}/HRTFLoader.cpp COPYONLY)
+ endif()
+endif()
+
+list(APPEND SRC ${CMAKE_CURRENT_BINARY_DIR}/PluginManager.cpp)
+if(WITH_FFTW)
+ list(APPEND SRC ${CMAKE_CURRENT_BINARY_DIR}/HRTFLoader.cpp)
+endif()
+
+# directories
+
+include_directories(${INCLUDE})
+link_directories()
+
+# install configuration
+
+if(WIN32)
+ set(BIN_DESTINATION ".")
+else()
+ set(BIN_DESTINATION "bin")
+endif()
+
+set(LIB_DESTINATION "lib${LIB_SUFFIX}")
+
+# library
+
+add_library(audaspace ${LIBRARY_TYPE} ${SRC} ${HDR})
+target_link_libraries(audaspace ${LIBRARIES})
+set_target_properties(audaspace PROPERTIES SOVERSION ${AUDASPACE_VERSION})
+
+if(AUDASPACE_STANDALONE)
+ install(TARGETS audaspace
+ RUNTIME DESTINATION ${BIN_DESTINATION}
+ LIBRARY DESTINATION ${LIB_DESTINATION}
+ ARCHIVE DESTINATION ${LIB_DESTINATION}
+ )
+
+ install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/ DESTINATION include/audaspace)
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Audaspace.h DESTINATION include/audaspace)
+
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/packages/pkgconfig/audaspace.pc.in ${CMAKE_CURRENT_BINARY_DIR}/audaspace.pc @ONLY)
+
+ if(NOT WIN32 AND NOT APPLE)
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/audaspace.pc DESTINATION "lib${LIB_SUFFIX}/pkgconfig")
+ endif()
+endif()
+
+# plugins
+
+if(WITH_FFMPEG AND PLUGIN_FFMPEG)
+ add_definitions(-DFFMPEG_PLUGIN)
+ include_directories(${INCLUDE} ${FFMPEG_INCLUDE_DIRS})
+ add_library(audffmpeg SHARED ${FFMPEG_SRC} ${FFMPEG_HDR} ${HDR})
+ target_link_libraries(audffmpeg audaspace ${FFMPEG_LIBRARIES})
+ set_target_properties(audffmpeg PROPERTIES SOVERSION ${AUDASPACE_VERSION})
+ install(TARGETS audffmpeg DESTINATION ${DEFAULT_PLUGIN_PATH})
+endif()
+
+if(WITH_JACK AND PLUGIN_JACK)
+ add_definitions(-DJACK_PLUGIN)
+ include_directories(${INCLUDE} ${JACK_INCLUDE_DIRS})
+ add_library(audjack SHARED ${JACK_SRC} ${JACK_HDR} ${HDR})
+ if(DYNLOAD_JACK)
+ target_link_libraries(audjack audaspace)
+ else()
+ target_link_libraries(audjack audaspace ${JACK_LIBRARIES})
+ endif()
+ set_target_properties(audjack PROPERTIES SOVERSION ${AUDASPACE_VERSION})
+ install(TARGETS audjack DESTINATION ${DEFAULT_PLUGIN_PATH})
+endif()
+
+if(WITH_LIBSNDFILE AND PLUGIN_LIBSNDFILE)
+ add_definitions(-DLIBSNDFILE_PLUGIN)
+ include_directories(${INCLUDE} ${LIBSNDFILE_INCLUDE_DIRS})
+ add_library(audlibsndfile SHARED ${LIBSNDFILE_SRC} ${LIBSNDFILE_HDR} ${HDR})
+ set_target_properties(audlibsndfile PROPERTIES SOVERSION ${AUDASPACE_VERSION})
+ target_link_libraries(audlibsndfile audaspace ${LIBSNDFILE_LIBRARIES})
+ install(TARGETS audlibsndfile DESTINATION ${DEFAULT_PLUGIN_PATH})
+endif()
+
+if(WITH_OPENAL AND PLUGIN_OPENAL)
+ add_definitions(-DOPENAL_PLUGIN)
+ include_directories(${INCLUDE} ${OPENAL_INCLUDE_DIR})
+ add_library(audopenal SHARED ${OPENAL_SRC} ${OPENAL_HDR} ${HDR})
+ set_target_properties(audopenal PROPERTIES SOVERSION ${AUDASPACE_VERSION})
+ target_link_libraries(audopenal audaspace ${OPENAL_LIBRARY})
+ install(TARGETS audopenal DESTINATION ${DEFAULT_PLUGIN_PATH})
+endif()
+
+if(WITH_SDL AND PLUGIN_SDL)
+ add_definitions(-DSDL_PLUGIN)
+ include_directories(${INCLUDE} ${SDL_INCLUDE_DIR})
+ add_library(audsdl SHARED ${SDL_SRC} ${SDL_HDR} ${HDR})
+ set_target_properties(audsdl PROPERTIES SOVERSION ${AUDASPACE_VERSION})
+ target_link_libraries(audsdl audaspace ${SDL_LIBRARY})
+ install(TARGETS audsdl DESTINATION ${DEFAULT_PLUGIN_PATH})
+endif()
+
+# dlls
+
+if(WIN32)
+ if(DLLS)
+ install(FILES ${DLLS} DESTINATION ${BIN_DESTINATION})
+ endif()
+endif()
+
+# demos
+
+if(BUILD_DEMOS)
+ include_directories(${INCLUDE})
+
+ set(DEMOS audaplay audaconvert audaremap signalgen randsounds dynamicmusic playbackmanager)
+
+ add_executable(audaplay demos/audaplay.cpp)
+ target_link_libraries(audaplay audaspace)
+
+ add_executable(audaconvert demos/audaconvert.cpp)
+ target_link_libraries(audaconvert audaspace)
+
+ add_executable(audaremap demos/audaremap.cpp)
+ target_link_libraries(audaremap audaspace)
+
+ add_executable(signalgen demos/signalgen.cpp)
+ target_link_libraries(signalgen audaspace)
+
+ add_executable(randsounds demos/randsounds.cpp)
+ target_link_libraries(randsounds audaspace)
+
+ add_executable(dynamicmusic demos/dynamicmusic.cpp)
+ target_link_libraries(dynamicmusic audaspace)
+
+ add_executable(playbackmanager demos/playbackmanager.cpp)
+ target_link_libraries(playbackmanager audaspace)
+
+ if(WITH_FFTW)
+ list(APPEND DEMOS convolution binaural)
+
+ add_executable(convolution demos/convolution.cpp)
+ target_link_libraries(convolution audaspace)
+
+ add_executable(binaural demos/binaural.cpp)
+ target_link_libraries(binaural audaspace)
+ endif()
+
+ if(WITH_OPENAL)
+ list(APPEND DEMOS openaldevices)
+
+ add_executable(openaldevices demos/openaldevices.cpp)
+ if(PLUGIN_OPENAL)
+ target_link_libraries(openaldevices audaspace audopenal)
+ else()
+ target_link_libraries(openaldevices audaspace)
+ endif()
+ endif()
+
+ install(TARGETS ${DEMOS}
+ RUNTIME DESTINATION ${BIN_DESTINATION}
+ LIBRARY DESTINATION ${LIB_DESTINATION}
+ ARCHIVE DESTINATION ${LIB_DESTINATION}
+ )
+endif()
+
+# bindings
+
+if(WITH_C)
+ if(SEPARATE_C)
+ add_library(audaspace-c ${LIBRARY_TYPE} ${C_SRC} ${C_HDR})
+ target_link_libraries(audaspace-c audaspace)
+ set_target_properties(audaspace-c PROPERTIES SOVERSION ${AUDASPACE_VERSION})
+ install(TARGETS audaspace-c
+ RUNTIME DESTINATION ${BIN_DESTINATION}
+ LIBRARY DESTINATION ${LIB_DESTINATION}
+ ARCHIVE DESTINATION ${LIB_DESTINATION}
+ )
+ endif()
+
+ if(AUDASPACE_STANDALONE)
+ install(FILES ${C_HDR} DESTINATION include/audaspace)
+ endif()
+endif()
+
+if(WITH_PYTHON)
+ set(PYTHON_SRC
+ bindings/python/PyAPI.cpp
+ bindings/python/PyDevice.cpp
+ bindings/python/PyDynamicMusic.cpp
+ bindings/python/PyHandle.cpp
+ bindings/python/PyPlaybackManager.cpp
+ bindings/python/PySequence.cpp
+ bindings/python/PySequenceEntry.cpp
+ bindings/python/PySound.cpp
+ bindings/python/PySource.cpp
+ bindings/python/PyThreadPool.cpp
+ )
+ set(PYTHON_HDR
+ bindings/python/PyAPI.h
+ bindings/python/PyDevice.h
+ bindings/python/PyDynamicMusic.h
+ bindings/python/PyHandle.h
+ bindings/python/PyPlaybackManager.h
+ bindings/python/PySequence.h
+ bindings/python/PySequenceEntry.h
+ bindings/python/PySound.h
+ bindings/python/PySource.h
+ bindings/python/PyThreadPool.h
+ )
+
+ if(WITH_FFTW)
+ list(APPEND PYTHON_SRC
+ bindings/python/PyHRTF.cpp
+ bindings/python/PyImpulseResponse.cpp
+ )
+ list(APPEND PYTHON_HDR
+ bindings/python/PyHRTF.h
+ bindings/python/PyImpulseResponse.h
+ )
+ endif()
+
+ add_library(audaspace-py ${LIBRARY_TYPE} ${PYTHON_SRC} ${PYTHON_HDR})
+ target_link_libraries(audaspace-py audaspace ${PYTHON_LIBRARIES})
+ set_target_properties(audaspace-py PROPERTIES SOVERSION ${AUDASPACE_VERSION})
+
+ if(AUDASPACE_STANDALONE)
+ install(TARGETS audaspace-py
+ RUNTIME DESTINATION ${BIN_DESTINATION}
+ LIBRARY DESTINATION ${LIB_DESTINATION}
+ ARCHIVE DESTINATION ${LIB_DESTINATION}
+ )
+
+ install(FILES ${PYTHON_HDR} DESTINATION include/audaspace/python)
+ endif()
+
+ if(WITH_PYTHON_MODULE)
+ set(PYTHON_SOURCE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bindings/python)
+ configure_file(${PYTHON_SOURCE_DIRECTORY}/setup.py.in ${CMAKE_CURRENT_BINARY_DIR}/setup.py ESCAPE_QUOTES @ONLY)
+
+ if(APPLE)
+ add_custom_command(OUTPUT build COMMAND MACOSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} ${PYTHON_EXECUTABLE} setup.py build DEPENDS ${PYTHON_SRC} ${PYTHON_HDR})
+ elseif(WIN32)
+ set(ENV{VS100COMNTOOLS} $ENV{VS120COMNTOOLS})
+ add_custom_command(OUTPUT build COMMAND ${PYTHON_EXECUTABLE} setup.py build DEPENDS ${PYTHON_SRC} ${PYTHON_HDR})
+ else()
+ add_custom_command(OUTPUT build COMMAND ${PYTHON_EXECUTABLE} setup.py build DEPENDS ${PYTHON_SRC} ${PYTHON_HDR})
+ endif()
+ add_custom_target(pythonmodule ALL DEPENDS build SOURCES ${PYTHON_SOURCE_DIRECTORY}/setup.py.in ${PYTHON_SRC} ${PYTHON_HDR})
+ add_dependencies(pythonmodule audaspace)
+
+ install(CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} setup.py install --root=\$ENV{DESTDIR} --prefix=${CMAKE_INSTALL_PREFIX})")
+ endif()
+endif()
+
+# docs
+
+if(WITH_DOCS)
+ find_package(Doxygen ${PACKAGE_OPTION})
+
+ if(DOXYGEN_FOUND AND DOXYGEN_DOT_FOUND)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
+
+ add_custom_target(audaspace_doc ALL ${DOXYGEN_EXECUTABLE} Doxyfile COMMENT "Building C++ HTML documentation with Doxygen.")
+ else()
+ set(WITH_DOCS FALSE CACHE BOOL "Build C++ HTML Documentation with Doxygen" FORCE)
+ message(WARNING "Doxygen (and/or dot) not found, documentation will not be built.")
+ endif()
+endif()
+
+if(WITH_BINDING_DOCS)
+ find_package(Sphinx ${PACKAGE_OPTION})
+
+ if(SPHINX_FOUND)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/bindings/doc/conf.py.in ${CMAKE_CURRENT_BINARY_DIR}/conf.py @ONLY)
+
+ add_custom_target(bindings_doc ALL COMMAND ${PYTHON_EXECUTABLE} setup.py --build-docs ${SPHINX_EXECUTABLE} -q -b html -c "${CMAKE_CURRENT_BINARY_DIR}" -d "${CMAKE_CURRENT_BINARY_DIR}/_doctrees" "${CMAKE_CURRENT_SOURCE_DIR}/bindings/doc" "${CMAKE_CURRENT_BINARY_DIR}/doc/bindings" DEPENDS pythonmodule COMMENT "Building C/Python HTML documentation with Sphinx.")
+ else()
+ set(WITH_BINDING_DOCS FALSE CACHE BOOL "Build C/Python HTML Documentation with Sphinx" FORCE)
+ message(WARNING "Sphinx not found, binding documentation will not be built.")
+ endif()
+endif()
+
+if(WITH_DOCS OR WITH_BINDING_DOCS)
+ install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/ DESTINATION ${DOCUMENTATION_INSTALL_PATH})
+endif()
diff --git a/extern/audaspace/INSTALL b/extern/audaspace/INSTALL
new file mode 100644
index 00000000000..c63206fb949
--- /dev/null
+++ b/extern/audaspace/INSTALL
@@ -0,0 +1,107 @@
+Audaspace Installation Guide
+============================
+
+This document guides through the building and installation of audaspace.
+
+The build system used to build audaspace is CMake and it allows very building the library for very different application scenarios from a very general shared library build with plugins that is suitable for system wide installations to building everything into a single static library to be linked into a standalone program.
+
+Build Dependencies
+------------------
+
+Audaspace is written in C++ 11 so a fairly recent compiler (g++ 4.8.2, clang 3.3, MSVC 2013) is needed to build it. The build system used is CMake and you need at least version 3.0. The following build dependencies are all optional, but without any it's neither possible to open sound files nor play back through the speakers. For windows a library folder called build-dependencies can be downloaded from https://github.com/audaspace/audaspace/releases.
+
+- OpenAL (input/output device)
+- SDL (output device)
+- Jack (output device)
+- libsndfile (file access)
+- ffmpeg (file access)
+- Python (language binding)
+
+Getting the Code
+----------------
+
+The audaspace source code or binary releases can be downloaded from https://github.com/audaspace/audaspace/releases.
+
+For the most recent version you can use git to get the source code.
+
+ git clone https://github.com/audaspace/audaspace.git
+
+Plugins
+-------
+
+Before diving into the exact build steps for each platform, we will have a look at plugins. There are so far two types of plugins: input and output plugins. Input plugins are for reading audio files in many different formats and output plugins are for output devices on different platforms. During the configuration audaspace's standard plugins can be enabled with their repsective `WITH_*` and `PLUGIN_*` configuration option. Plugins are built as shared libraries. By default audaspace looks in the `DEFAULT_PLUGIN_PATH` for shared libraries it can load. Building with a dependency (`WITH_*`) but without enabling the respective `PLUGIN_*` option will compile the plugin directly into the library, so the plugin always gets loaded when the plugins are initialised.
+
+Building for Linux
+------------------
+
+### Configuration ###
+
+It is highly recommended to build audaspace outside of the actual source code in a specific build directory.
+
+ mkdir build
+ cd build
+
+Configuration is then either done interactively by using ccmake
+
+ ccmake ../audaspace
+
+__or__ it can be done by defining variables directly during the run of cmake.
+
+ cmake ../build \
+ -DCMAKE_INSTALL_PREFIX:PATH=/usr \
+ -DCMAKE_BUILD_TYPE:STRING=Release \
+ -DBUILD_DEMOS:BOOL=TRUE \
+ -DSHARED_LIBRARY:BOOL=TRUE \
+ -DWITH_C:BOOL=TRUE \
+ -DWITH_FFMPEG:BOOL=TRUE \
+ -DWITH_JACK:BOOL=TRUE \
+ -DWITH_LIBSNDFILE:BOOL=TRUE \
+ -DWITH_OPENAL:BOOL=TRUE \
+ -DWITH_PYTHON:BOOL=TRUE \
+ -DWITH_SDL:BOOL=TRUE \
+ -DDEFAULT_PLUGIN_PATH:PATH=/usr/share/audaspace/plugins
+
+This specific configuration is recommended for a system wide installation of audaspace where all build dependencies are required.
+
+### Building ###
+
+After configuration the building is as easy as running
+
+ make
+
+### Installation ###
+
+Installation is then also simple using
+
+ make install
+
+### Using the library ###
+
+When audaspace is installed to the system, the required configuration for _pkgconfig_ is also installed and pkgconfig can then be used to compile projects with audaspace.
+
+It is also possible to build audaspace as a static library and use it directly in a project. For this the library has to be configured accordingly with ccmake and after building the resulting library file can be added to the project's build system.
+
+Building for Windows
+--------------------
+
+### Configuration ###
+
+Using cmake-gui select Visual Studio 2013 or 2015 for the architecture you want to build for and choose audaspace's source directory and a build directory. It is highly recommended to build audaspace outside of the source directory. During the first configuration cmake tries to find the dependencies. Dependencies that are not installed on the system are automatically disabled. To prevent this, enable `WITH_STRICT_DEPENDENCIES`. To use the build dependencies folder from the website, set the `LIBRARY_PATH` to point to the extracted directory. Also don't forget to set the `CMAKE_INSTALL_PREFIX` to a path where your user account can install to. Finally enable the dependencies that you want to use (`WITH_*`), configure and generate.
+
+### Building ###
+
+Open the project in Visual Studio and set the configuration to Release. Then you can simply hit the build button.
+
+### Installation ###
+
+To install audaspace to your target folder, build the INSTALL target.
+Note that if you don't use the libraries folder provided on the website, the INSTALL target might fail and you need to copy the files manually, including the dlls of the dependencies.
+
+### Using the library ###
+
+To use audaspace in your project, configure the include path and the libraries that you need, which you can find in the include and lib directories in your installation path.
+
+### Notes for plugins on windows ###
+
+- FFMPEG: Due to a problem with FFMPEG's 32 bit libraries, it is necessary to disable SAFESEH for the audffmpeg build target inside Visual Studio (Properties, Linker, Advanced). This has to be done after each generate step of CMake.
+- Jack: If no jack server is running on windows and your application or one of the demos tries to use the jack plugin, this adds a long delay to the device initialisation. In case you don't need jack, make sure to disable the plugin or for the prebuilt version of audaspace simply delete audjack.dll (and any files with jack in the name to clean up).
diff --git a/extern/audaspace/LICENSE b/extern/audaspace/LICENSE
new file mode 100644
index 00000000000..d6456956733
--- /dev/null
+++ b/extern/audaspace/LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/extern/audaspace/README.md b/extern/audaspace/README.md
new file mode 100644
index 00000000000..7fdd515ab67
--- /dev/null
+++ b/extern/audaspace/README.md
@@ -0,0 +1,47 @@
+audaspace
+=========
+
+Audaspace (pronounced "outer space") is a high level audio library written in C++ with language bindings for Python for example. It started out as the audio engine of the 3D modelling application Blender and is now released as a standalone library.
+
+Documentation and Community
+---------------------------
+
+The documentation including guides for building and installing, demos, tutorials as well as the API reference for C++, C and python can be found on https://audaspace.github.io.
+
+Bug reports and feature requests should go to the [issue tracker](https://github.com/audaspace/audaspace/issues).
+
+For any other discussions about audaspace there is a [mailing list](https://groups.google.com/forum/#!forum/audaspace) and there is also the IRC channel #audaspace on irc.freenode.net.
+
+Features
+--------
+
+The following (probably incomplete) features are supported by audaspace:
+
+* input/output devices
+ * input from microphones, line in, etc.
+ * output devices including 3D audio support
+* file reading/writing
+* filters like low-/highpass and effects like delay, reverse or fading
+* generators for simple waveforms like silence, sine and triangle
+* respecification - this term is used for changing stream parameters which are
+ * channel count - channel remapping
+ * sample format - the library internally uses 32 bit floats
+ * sample rate - resampling
+* simple (superposition, joining and ping-pong aka forward-reverse) and more complex (non-linear audio editing) sequencing of sounds
+
+License
+-------
+
+> Copyright © 2009-2015 Jörg Müller. All rights reserved.
+>
+> Licensed under the Apache License, Version 2.0 (the "License");
+> you may not use this file except in compliance with the License.
+> You may obtain a copy of the License at
+>
+> http://www.apache.org/licenses/LICENSE-2.0
+>
+> Unless required by applicable law or agreed to in writing, software
+> distributed under the License is distributed on an "AS IS" BASIS,
+> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+> See the License for the specific language governing permissions and
+> limitations under the License.
diff --git a/extern/audaspace/bindings/C/AUD_Device.cpp b/extern/audaspace/bindings/C/AUD_Device.cpp
new file mode 100644
index 00000000000..441f228deac
--- /dev/null
+++ b/extern/audaspace/bindings/C/AUD_Device.cpp
@@ -0,0 +1,336 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "devices/DeviceManager.h"
+#include "devices/I3DDevice.h"
+#include "devices/IDeviceFactory.h"
+#include "devices/ReadDevice.h"
+#include "Exception.h"
+
+#include <cassert>
+
+using namespace aud;
+
+#define AUD_CAPI_IMPLEMENTATION
+#include "AUD_Device.h"
+
+static inline aud::Specs convCToSpec(AUD_Specs specs)
+{
+ aud::Specs s;
+ s.channels = static_cast<Channels>(specs.channels);
+ s.rate = static_cast<SampleRate>(specs.rate);
+ return s;
+}
+
+static inline aud::DeviceSpecs convCToDSpec(AUD_DeviceSpecs specs)
+{
+ aud::DeviceSpecs s;
+ s.specs = convCToSpec(specs.specs);
+ s.format = static_cast<SampleFormat>(specs.format);
+ return s;
+}
+
+AUD_API AUD_Device* AUD_Device_open(const char* type, AUD_DeviceSpecs specs, int buffersize, const char* name)
+{
+ DeviceSpecs dspecs = convCToDSpec(specs);
+
+ if(dspecs.channels == CHANNELS_INVALID)
+ dspecs.channels = CHANNELS_STEREO;
+ if(dspecs.format == FORMAT_INVALID)
+ dspecs.format = FORMAT_FLOAT32;
+ if(dspecs.rate == RATE_INVALID)
+ dspecs.rate = RATE_48000;
+ if(buffersize < 128)
+ buffersize = AUD_DEFAULT_BUFFER_SIZE;
+ if(name == nullptr)
+ name = "";
+
+ try
+ {
+ if(!type)
+ {
+ auto device = DeviceManager::getDevice();
+ if(!device)
+ {
+ DeviceManager::openDefaultDevice();
+ device = DeviceManager::getDevice();
+ }
+ return new AUD_Device(device);
+ }
+
+ if(type == std::string("read"))
+ {
+ return new AUD_Device(new ReadDevice(dspecs));
+ }
+
+ std::shared_ptr<IDeviceFactory> factory;
+ if(!*type)
+ factory = DeviceManager::getDefaultDeviceFactory();
+ else
+ factory = DeviceManager::getDeviceFactory(type);
+
+ if(factory)
+ {
+ factory->setName(name);
+ factory->setSpecs(dspecs);
+ factory->setBufferSize(buffersize);
+ return new AUD_Device(factory->openDevice());
+ }
+ }
+ catch(Exception&)
+ {
+ }
+ return nullptr;
+}
+
+AUD_API void AUD_Device_lock(AUD_Device* device)
+{
+ auto dev = device ? *device : DeviceManager::getDevice();
+ dev->lock();
+}
+
+AUD_API AUD_Handle* AUD_Device_play(AUD_Device* device, AUD_Sound* sound, int keep)
+{
+ assert(sound);
+ auto dev = device ? *device : DeviceManager::getDevice();
+
+ try
+ {
+ AUD_Handle handle = dev->play(*sound, keep);
+ if(handle.get())
+ {
+ return new AUD_Handle(handle);
+ }
+ }
+ catch(Exception&)
+ {
+ }
+ return nullptr;
+}
+
+AUD_API void AUD_Device_stopAll(AUD_Device* device)
+{
+ auto dev = device ? *device : DeviceManager::getDevice();
+ dev->stopAll();
+}
+
+AUD_API void AUD_Device_unlock(AUD_Device* device)
+{
+ auto dev = device ? *device : DeviceManager::getDevice();
+ dev->unlock();
+}
+
+AUD_API AUD_Channels AUD_Device_getChannels(AUD_Device* device)
+{
+ auto dev = device ? *device : DeviceManager::getDevice();
+ return static_cast<AUD_Channels>(dev->getSpecs().channels);
+}
+
+AUD_API AUD_DistanceModel AUD_Device_getDistanceModel(AUD_Device* device)
+{
+ auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
+ return static_cast<AUD_DistanceModel>(dev->getDistanceModel());
+}
+
+AUD_API void AUD_Device_setDistanceModel(AUD_Device* device, AUD_DistanceModel value)
+{
+ auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
+ dev->setDistanceModel(static_cast<DistanceModel>(value));
+}
+
+AUD_API float AUD_Device_getDopplerFactor(AUD_Device* device)
+{
+ auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
+ return dev->getDopplerFactor();
+}
+
+AUD_API void AUD_Device_setDopplerFactor(AUD_Device* device, float value)
+{
+ auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
+ dev->setDopplerFactor(value);
+}
+
+AUD_API AUD_SampleFormat AUD_Device_getFormat(AUD_Device* device)
+{
+ auto dev = device ? *device : DeviceManager::getDevice();
+ return static_cast<AUD_SampleFormat>(dev->getSpecs().format);
+}
+
+AUD_API void AUD_Device_getListenerLocation(AUD_Device* device, float value[3])
+{
+ auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
+ Vector3 v = dev->getListenerLocation();
+ value[0] = v.x();
+ value[1] = v.y();
+ value[2] = v.z();
+}
+
+AUD_API void AUD_Device_setListenerLocation(AUD_Device* device, const float value[3])
+{
+ auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
+ Vector3 v(value[0], value[1], value[2]);
+ dev->setListenerLocation(v);
+}
+
+AUD_API void AUD_Device_getListenerOrientation(AUD_Device* device, float value[4])
+{
+ auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
+ Quaternion v = dev->getListenerOrientation();
+ value[0] = v.x();
+ value[1] = v.y();
+ value[2] = v.z();
+ value[3] = v.w();
+}
+
+AUD_API void AUD_Device_setListenerOrientation(AUD_Device* device, const float value[4])
+{
+ auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
+ Quaternion v(value[3], value[0], value[1], value[2]);
+ dev->setListenerOrientation(v);
+}
+
+AUD_API void AUD_Device_getListenerVelocity(AUD_Device* device, float value[3])
+{
+ auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
+ Vector3 v = dev->getListenerVelocity();
+ value[0] = v.x();
+ value[1] = v.y();
+ value[2] = v.z();
+}
+
+AUD_API void AUD_Device_setListenerVelocity(AUD_Device* device, const float value[3])
+{
+ auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
+ Vector3 v(value[0], value[1], value[2]);
+ dev->setListenerVelocity(v);
+}
+
+AUD_API double AUD_Device_getRate(AUD_Device* device)
+{
+ auto dev = device ? *device : DeviceManager::getDevice();
+ return dev->getSpecs().rate;
+}
+
+AUD_API float AUD_Device_getSpeedOfSound(AUD_Device* device)
+{
+ auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
+ return dev->getSpeedOfSound();
+}
+
+AUD_API void AUD_Device_setSpeedOfSound(AUD_Device* device, float value)
+{
+ auto dev = device ? std::dynamic_pointer_cast<I3DDevice>(*device) : DeviceManager::get3DDevice();
+ dev->setSpeedOfSound(value);
+}
+
+AUD_API float AUD_Device_getVolume(AUD_Device* device)
+{
+ auto dev = device ? *device : DeviceManager::getDevice();
+ return dev->getVolume();
+}
+
+AUD_API void AUD_Device_setVolume(AUD_Device* device, float value)
+{
+ auto dev = device ? *device : DeviceManager::getDevice();
+ dev->setVolume(value);
+}
+
+AUD_API int AUD_Device_read(AUD_Device* device, unsigned char* buffer, int length)
+{
+ assert(device);
+ assert(buffer);
+
+ auto readDevice = std::dynamic_pointer_cast<ReadDevice>(*device);
+ if(!readDevice)
+ return false;
+
+ try
+ {
+ return readDevice->read(buffer, length);
+ }
+ catch(Exception&)
+ {
+ return false;
+ }
+}
+
+AUD_API void AUD_Device_free(AUD_Device* device)
+{
+ assert(device);
+
+ try
+ {
+ delete device;
+ }
+ catch(Exception&)
+ {
+ }
+}
+
+AUD_API AUD_Device* AUD_Device_getCurrent()
+{
+ auto device = DeviceManager::getDevice();
+
+ if(!device)
+ return nullptr;
+
+ return new AUD_Device(device);
+}
+
+AUD_API void AUD_seekSynchronizer(AUD_Handle* handle, float time)
+{
+ auto synchronizer = DeviceManager::getDevice()->getSynchronizer();
+ if(synchronizer)
+ synchronizer->seek(*reinterpret_cast<std::shared_ptr<IHandle>*>(handle), time);
+}
+
+AUD_API float AUD_getSynchronizerPosition(AUD_Handle* handle)
+{
+ auto synchronizer = DeviceManager::getDevice()->getSynchronizer();
+ if(synchronizer)
+ return synchronizer->getPosition(*reinterpret_cast<std::shared_ptr<IHandle>*>(handle));
+ return (*reinterpret_cast<std::shared_ptr<IHandle>*>(handle))->getPosition();
+}
+
+AUD_API void AUD_playSynchronizer()
+{
+ auto synchronizer = DeviceManager::getDevice()->getSynchronizer();
+ if(synchronizer)
+ synchronizer->play();
+}
+
+AUD_API void AUD_stopSynchronizer()
+{
+ auto synchronizer = DeviceManager::getDevice()->getSynchronizer();
+ if(synchronizer)
+ synchronizer->stop();
+}
+
+AUD_API void AUD_setSynchronizerCallback(AUD_syncFunction function, void* data)
+{
+ auto synchronizer = DeviceManager::getDevice()->getSynchronizer();
+ if(synchronizer)
+ synchronizer->setSyncCallback(function, data);
+}
+
+AUD_API int AUD_isSynchronizerPlaying()
+{
+ auto synchronizer = DeviceManager::getDevice()->getSynchronizer();
+ if(synchronizer)
+ return synchronizer->isPlaying();
+ return false;
+}
+
diff --git a/extern/audaspace/bindings/C/AUD_Device.h b/extern/audaspace/bindings/C/AUD_Device.h
new file mode 100644
index 00000000000..0dfa21f0660
--- /dev/null
+++ b/extern/audaspace/bindings/C/AUD_Device.h
@@ -0,0 +1,258 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+#include "AUD_Types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/// Possible distance models for the 3D device.
+typedef enum
+{
+ AUD_DISTANCE_MODEL_INVALID = 0,
+ AUD_DISTANCE_MODEL_INVERSE,
+ AUD_DISTANCE_MODEL_INVERSE_CLAMPED,
+ AUD_DISTANCE_MODEL_LINEAR,
+ AUD_DISTANCE_MODEL_LINEAR_CLAMPED,
+ AUD_DISTANCE_MODEL_EXPONENT,
+ AUD_DISTANCE_MODEL_EXPONENT_CLAMPED
+} AUD_DistanceModel;
+
+typedef void (*AUD_syncFunction)(void*, int, float);
+
+/**
+ * Opens a new sound device.
+ * \param type The name of the device.
+ * Can be NULL to open the default device with default settings or return the handle to the already opened one.
+ * Can be "" to open the a default factory device with given settings.
+ * Can be "read" to open a readable device.
+ * \param specs Specification of the device parameters.
+ * \param buffersize Size of the mixing buffer.
+ * \param name Custom name of the device.
+ * \return A handle to the opened device or NULL on failure.
+ */
+extern AUD_API AUD_Device* AUD_Device_open(const char* type, AUD_DeviceSpecs specs, int buffersize, const char* name);
+
+/**
+ * Locks the playback device.
+ */
+extern AUD_API void AUD_Device_lock(AUD_Device* device);
+
+/**
+ * Plays back a sound file.
+ * \param sound The handle of the sound file.
+ * \param keep When keep is true the sound source will not be deleted but set to
+ * paused when its end has been reached.
+ * \return A handle to the played back sound.
+ */
+extern AUD_API AUD_Handle* AUD_Device_play(AUD_Device* device, AUD_Sound* sound, int keep);
+
+/**
+ * Stops all sounds playing.
+ */
+extern AUD_API void AUD_Device_stopAll(AUD_Device* device);
+
+/**
+ * Unlocks the device.
+ */
+extern AUD_API void AUD_Device_unlock(AUD_Device* device);
+
+/**
+ * Retrieves the channels of a device.
+ * param device The device to get the channels from.
+ * return The channels of the device.
+ */
+extern AUD_API AUD_Channels AUD_Device_getChannels(AUD_Device* device);
+
+/**
+ * Retrieves the distance model of a device.
+ * param device The device to get the distance model from.
+ * return The distance model of the device.
+ */
+extern AUD_API AUD_DistanceModel AUD_Device_getDistanceModel(AUD_Device* device);
+
+/**
+ * Sets the distance model of a device.
+ * param device The device to set the distance model from.
+ * param value The new distance model to set.
+ */
+extern AUD_API void AUD_Device_setDistanceModel(AUD_Device* device, AUD_DistanceModel value);
+
+/**
+ * Retrieves the doppler factor of a device.
+ * param device The device to get the doppler factor from.
+ * return The doppler factor of the device.
+ */
+extern AUD_API float AUD_Device_getDopplerFactor(AUD_Device* device);
+
+/**
+ * Sets the doppler factor of a device.
+ * param device The device to set the doppler factor from.
+ * param value The new doppler factor to set.
+ */
+extern AUD_API void AUD_Device_setDopplerFactor(AUD_Device* device, float value);
+
+/**
+ * Retrieves the format of a device.
+ * param device The device to get the format from.
+ * return The format of the device.
+ */
+extern AUD_API AUD_SampleFormat AUD_Device_getFormat(AUD_Device* device);
+
+/**
+ * Retrieves the listener location of a device.
+ * param device The device to get the listener location from.
+ * return The listener location of the device.
+ */
+extern AUD_API void AUD_Device_getListenerLocation(AUD_Device* device, float value[3]);
+
+/**
+ * Sets the listener location of a device.
+ * param device The device to set the listener location from.
+ * param value The new listener location to set.
+ */
+extern AUD_API void AUD_Device_setListenerLocation(AUD_Device* device, const float value[3]);
+
+/**
+ * Retrieves the listener orientation of a device.
+ * param device The device to get the listener orientation from.
+ * return The listener orientation of the device.
+ */
+extern AUD_API void AUD_Device_getListenerOrientation(AUD_Device* device, float value[4]);
+
+/**
+ * Sets the listener orientation of a device.
+ * param device The device to set the listener orientation from.
+ * param value The new listener orientation to set.
+ */
+extern AUD_API void AUD_Device_setListenerOrientation(AUD_Device* device, const float value[4]);
+
+/**
+ * Retrieves the listener velocity of a device.
+ * param device The device to get the listener velocity from.
+ * return The listener velocity of the device.
+ */
+extern AUD_API void AUD_Device_getListenerVelocity(AUD_Device* device, float value[3]);
+
+/**
+ * Sets the listener velocity of a device.
+ * param device The device to set the listener velocity from.
+ * param value The new listener velocity to set.
+ */
+extern AUD_API void AUD_Device_setListenerVelocity(AUD_Device* device, const float value[3]);
+
+/**
+ * Retrieves the rate of a device.
+ * param device The device to get the rate from.
+ * return The rate of the device.
+ */
+extern AUD_API double AUD_Device_getRate(AUD_Device* device);
+
+/**
+ * Retrieves the speed of sound of a device.
+ * param device The device to get the speed of sound from.
+ * return The speed of sound of the device.
+ */
+extern AUD_API float AUD_Device_getSpeedOfSound(AUD_Device* device);
+
+/**
+ * Sets the speed of sound of a device.
+ * param device The device to set the speed of sound from.
+ * param value The new speed of sound to set.
+ */
+extern AUD_API void AUD_Device_setSpeedOfSound(AUD_Device* device, float value);
+
+/**
+ * Retrieves the volume of a device.
+ * param device The device to get the volume from.
+ * return The volume of the device.
+ */
+extern AUD_API float AUD_Device_getVolume(AUD_Device* device);
+
+/**
+ * Sets the volume of a device.
+ * param device The device to set the volume from.
+ * param value The new volume to set.
+ */
+extern AUD_API void AUD_Device_setVolume(AUD_Device* device, float value);
+
+/**
+ * Reads the next samples into the supplied buffer.
+ * \param device The readable device.
+ * \param buffer The target buffer.
+ * \param length The length in samples to be filled.
+ * \return True if the reading succeeded, false if there are no sounds
+ * played back currently, in that case the buffer is filled with
+ * silence.
+ */
+extern AUD_API int AUD_Device_read(AUD_Device* device, unsigned char* buffer, int length);
+
+/**
+ * Closes a device. Handle becomes invalid afterwards.
+ * \param device The device to close.
+ */
+extern AUD_API void AUD_Device_free(AUD_Device* device);
+
+/**
+ * Retrieves the current device of the DeviceManager.
+ * \return A pointer to the current device, which needs to be freed with
+ * AUD_Device_free.
+ */
+extern AUD_API AUD_Device* AUD_Device_getCurrent();
+
+/**
+ * Seeks sequenced sound scene playback.
+ * \param handle Playback handle.
+ * \param time Time in seconds to seek to.
+ */
+extern AUD_API void AUD_seekSynchronizer(AUD_Handle* handle, float time);
+
+/**
+ * Returns the current sound scene playback time.
+ * \param handle Playback handle.
+ * \return The playback time in seconds.
+ */
+extern AUD_API float AUD_getSynchronizerPosition(AUD_Handle* handle);
+
+/**
+ * Starts the playback of jack transport if possible.
+ */
+extern AUD_API void AUD_playSynchronizer();
+
+/**
+ * Stops the playback of jack transport if possible.
+ */
+extern AUD_API void AUD_stopSynchronizer();
+
+/**
+ * Sets the sync callback for jack transport.
+ * \param function The callback function.
+ * \param data The data parameter for the callback.
+ */
+extern AUD_API void AUD_setSynchronizerCallback(AUD_syncFunction function, void* data);
+
+/**
+ * Returns whether jack transport is currently playing.
+ * \return Whether jack transport is currently playing.
+ */
+extern AUD_API int AUD_isSynchronizerPlaying();
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/extern/audaspace/bindings/C/AUD_DynamicMusic.cpp b/extern/audaspace/bindings/C/AUD_DynamicMusic.cpp
new file mode 100644
index 00000000000..bb7a129dde3
--- /dev/null
+++ b/extern/audaspace/bindings/C/AUD_DynamicMusic.cpp
@@ -0,0 +1,144 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "Exception.h"
+
+#include <cassert>
+
+using namespace aud;
+
+#define AUD_CAPI_IMPLEMENTATION
+#include "AUD_DynamicMusic.h"
+
+AUD_API AUD_DynamicMusic* AUD_DynamicMusic_create(AUD_Device* device)
+{
+ assert(device);
+
+ try
+ {
+ return new AUD_DynamicMusic(new DynamicMusic(*device));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+AUD_API void AUD_DynamicMusic_free(AUD_DynamicMusic* player)
+{
+ assert(player);
+ delete player;
+}
+
+AUD_API int AUD_DynamicMusic_addScene(AUD_DynamicMusic* player, AUD_Sound* scene)
+{
+ assert(player);
+ assert(scene);
+
+ return (*player)->addScene(*scene);
+}
+
+AUD_API int AUD_DynamicMusic_setSecene(AUD_DynamicMusic* player, int scene)
+{
+ assert(player);
+
+ return (*player)->changeScene(scene);
+}
+
+AUD_API int AUD_DynamicMusic_getScene(AUD_DynamicMusic* player)
+{
+ assert(player);
+
+ return (*player)->getScene();
+}
+
+AUD_API int AUD_DynamicMusic_addTransition(AUD_DynamicMusic* player, int ini, int end, AUD_Sound* transition)
+{
+ assert(player);
+ assert(transition);
+
+ return (*player)->addTransition(ini, end, *transition);
+}
+
+AUD_API void AUD_DynamicMusic_setFadeTime(AUD_DynamicMusic* player, float seconds)
+{
+ assert(player);
+
+ (*player)->setFadeTime(seconds);
+}
+
+AUD_API float AUD_DynamicMusic_getFadeTime(AUD_DynamicMusic* player)
+{
+ assert(player);
+
+ return (*player)->getFadeTime();
+}
+
+AUD_API int AUD_DynamicMusic_resume(AUD_DynamicMusic* player)
+{
+ assert(player);
+
+ return (*player)->resume();
+}
+
+AUD_API int AUD_DynamicMusic_pause(AUD_DynamicMusic* player)
+{
+ assert(player);
+
+ return (*player)->pause();
+}
+
+AUD_API int AUD_DynamicMusic_seek(AUD_DynamicMusic* player, float position)
+{
+ assert(player);
+
+ return (*player)->seek(position);
+}
+
+AUD_API float AUD_DynamicMusic_getPosition(AUD_DynamicMusic* player)
+{
+ assert(player);
+
+ return (*player)->getPosition();
+}
+
+AUD_API float AUD_DynamicMusic_getVolume(AUD_DynamicMusic* player)
+{
+ assert(player);
+
+ return (*player)->getVolume();
+}
+
+AUD_API int AUD_DynamicMusic_setVolume(AUD_DynamicMusic* player, float volume)
+{
+ assert(player);
+
+ return (*player)->setVolume(volume);
+}
+
+AUD_API AUD_Status AUD_DynamicMusic_getStatus(AUD_DynamicMusic* player)
+{
+ assert(player);
+
+ return static_cast<AUD_Status>((*player)->getStatus());
+}
+
+AUD_API int AUD_DynamicMusic_stop(AUD_DynamicMusic* player)
+{
+ assert(player);
+
+ return (*player)->stop();
+} \ No newline at end of file
diff --git a/extern/audaspace/bindings/C/AUD_DynamicMusic.h b/extern/audaspace/bindings/C/AUD_DynamicMusic.h
new file mode 100644
index 00000000000..c362479591e
--- /dev/null
+++ b/extern/audaspace/bindings/C/AUD_DynamicMusic.h
@@ -0,0 +1,145 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+#include "AUD_Types.h"
+#include "AUD_Handle.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+* Creates a new dynamic music player.
+* \param device The device that will be used to play sounds.
+* \return The new DynamicMusic object.
+*/
+extern AUD_API AUD_DynamicMusic* AUD_DynamicMusic_create(AUD_Device* device);
+
+/**
+* Deletes a dynamic music player.
+* \param player The DynamicMusic object to be deleted.
+*/
+extern AUD_API void AUD_DynamicMusic_free(AUD_DynamicMusic* player);
+
+/**
+* Adds a sound scene to a dynamic music player.
+* \param player The DynamicMusic object.
+* \param scene The sound to be added as a scene.
+* \return The index of the new scene.
+*/
+extern AUD_API int AUD_DynamicMusic_addScene(AUD_DynamicMusic* player, AUD_Sound* scene);
+
+/**
+* Changes the current sound scene of a dynamic music player.
+* \param player The DynamicMusic object.
+* \param scene The index of the scene to be played.
+* \return 0 if the target scene doesn't exist.
+*/
+extern AUD_API int AUD_DynamicMusic_setSecene(AUD_DynamicMusic* player, int scene);
+
+/**
+* Retrives the index of the current scene.
+* \param player The DynamicMusic object.
+* \return The index of the current scene.
+*/
+extern AUD_API int AUD_DynamicMusic_getScene(AUD_DynamicMusic* player);
+
+/**
+* Adds a new transition between two scenes.
+* \param player The DynamicMusic object.
+* \param ini The origin scene for the transition.
+* \param end The end scene for the transition.
+* \param transition A sound that will be used as transition between two scenes.
+* \return 0 if the ini or end scenes don't exist.
+*/
+extern AUD_API int AUD_DynamicMusic_addTransition(AUD_DynamicMusic* player, int ini, int end, AUD_Sound* transition);
+
+/**
+* Changes the fade time for the default transitions of a dynamic music player.
+* \param player The DynamicMusic object.
+* \param seconds The amount of secods that the crossfade transition will take.
+*/
+extern AUD_API void AUD_DynamicMusic_setFadeTime(AUD_DynamicMusic* player, float seconds);
+
+/**
+* Retrieves the fade time of a dynamic music player.
+* \param player The DynamicMusic object.
+* \return The fade time of the player.
+*/
+extern AUD_API float AUD_DynamicMusic_getFadeTime(AUD_DynamicMusic* player);
+
+/**
+* Resumes the current scene playback of a dynamic music player if it is paused.
+* \param player The DynamicMusic object.
+* \return 0 if the playback wasn't resumed.
+*/
+extern AUD_API int AUD_DynamicMusic_resume(AUD_DynamicMusic* player);
+
+/**
+* Pauses the current scene of a dynamic music player.
+* \param player The DynamicMusic object.
+* \return 0 if the playback wasn't paused.
+*/
+extern AUD_API int AUD_DynamicMusic_pause(AUD_DynamicMusic* player);
+
+/**
+* Seeks the current playing scene of a dynamic music player.
+* \param player The DynamicMusic object.
+* \param position The new position from which to play back, in seconds.
+* \return 0 if the seeking wasn't possible.
+*/
+extern AUD_API int AUD_DynamicMusic_seek(AUD_DynamicMusic* player, float position);
+
+/**
+* Retrieves the position of the current scene of a dynamic music player.
+* \param player The DynamicMusic object.
+* \return The position of the current playing scene.
+*/
+extern AUD_API float AUD_DynamicMusic_getPosition(AUD_DynamicMusic* player);
+
+/**
+* Retrieves the volume of the current scene of a dynamic music player.
+* \param player The DynamicMusic object.
+* \return The volume of the current playing scene.
+*/
+extern AUD_API float AUD_DynamicMusic_getVolume(AUD_DynamicMusic* player);
+
+/**
+* Changes the volume of the current scene in a dynamic music player.
+* \param player The DynamicMusic object.
+* \param 0 if the volume couldn't be changed.
+*/
+extern AUD_API int AUD_DynamicMusic_setVolume(AUD_DynamicMusic* player, float volume);
+
+/**
+* Retrieves the status of the current scene in a dynamic music player.
+* \param player The DynamicMusic object.
+* \return The Status of the current playing scene.
+*/
+extern AUD_API AUD_Status AUD_DynamicMusic_getStatus(AUD_DynamicMusic* player);
+
+/**
+* Stops the current scene of a dynamic music player.
+* \param player The DynamicMusic object.
+* \return 0 if the playback wasn't stopped.
+*/
+extern AUD_API int AUD_DynamicMusic_stop(AUD_DynamicMusic* player);
+
+#ifdef __cplusplus
+}
+#endif \ No newline at end of file
diff --git a/extern/audaspace/bindings/C/AUD_HRTF.cpp b/extern/audaspace/bindings/C/AUD_HRTF.cpp
new file mode 100644
index 00000000000..002c5d61ddd
--- /dev/null
+++ b/extern/audaspace/bindings/C/AUD_HRTF.cpp
@@ -0,0 +1,50 @@
+/*******************************************************************************
+* Copyright 2009-2015 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "Exception.h"
+
+#include <cassert>
+
+using namespace aud;
+
+#define AUD_CAPI_IMPLEMENTATION
+#include "AUD_HRTF.h"
+
+extern AUD_API AUD_HRTF* AUD_HRTF_create()
+{
+ try
+ {
+ return new AUD_HRTF(new HRTF());
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+extern AUD_API void AUD_HRTF_free(AUD_HRTF* hrtfs)
+{
+ assert(hrtfs);
+ delete hrtfs;
+}
+
+extern AUD_API void AUD_HRTF_addImpulseResponseFromSound(AUD_HRTF* hrtfs, AUD_Sound* sound, float azimuth, float elevation)
+{
+ assert(hrtfs);
+ assert(sound);
+
+ (*hrtfs)->addImpulseResponse(std::make_shared<StreamBuffer>(*sound), azimuth, elevation);
+} \ No newline at end of file
diff --git a/extern/audaspace/bindings/C/AUD_HRTF.h b/extern/audaspace/bindings/C/AUD_HRTF.h
new file mode 100644
index 00000000000..29dda371695
--- /dev/null
+++ b/extern/audaspace/bindings/C/AUD_HRTF.h
@@ -0,0 +1,48 @@
+/*******************************************************************************
+* Copyright 2009-2015 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+#include "AUD_Types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+* Creates a new HRTF object.
+* \return The new HRTF object.
+*/
+extern AUD_API AUD_HRTF* AUD_HRTF_create();
+
+/**
+* Deletes a HRTF object.
+* \param hrtfs The HRTF object to be deleted.
+*/
+extern AUD_API void AUD_HRTF_free(AUD_HRTF* hrtfs);
+
+/**
+* Adds a new impulse response to an HRTF object.
+* \param hrtfs The HRTF object.
+* \param sound A Sound object representing an HRTF.
+* \param azimuth The azimuth angle of the HRTF.
+* \param elevation The elevation angle of the HRTF.
+*/
+extern AUD_API void AUD_HRTF_addImpulseResponseFromSound(AUD_HRTF* hrtfs, AUD_Sound* sound, float azimuth, float elevation);
+
+#ifdef __cplusplus
+}
+#endif \ No newline at end of file
diff --git a/extern/audaspace/bindings/C/AUD_Handle.cpp b/extern/audaspace/bindings/C/AUD_Handle.cpp
new file mode 100644
index 00000000000..265c7bf08d2
--- /dev/null
+++ b/extern/audaspace/bindings/C/AUD_Handle.cpp
@@ -0,0 +1,384 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "devices/I3DHandle.h"
+#include "Exception.h"
+
+#include <cassert>
+
+using namespace aud;
+
+#define AUD_CAPI_IMPLEMENTATION
+#include "AUD_Handle.h"
+
+AUD_API int AUD_Handle_pause(AUD_Handle* handle)
+{
+ assert(handle);
+ return (*handle)->pause();
+}
+
+AUD_API int AUD_Handle_resume(AUD_Handle* handle)
+{
+ assert(handle);
+ return (*handle)->resume();
+}
+
+AUD_API int AUD_Handle_stop(AUD_Handle* handle)
+{
+ assert(handle);
+ int result = (*handle)->stop();
+ delete handle;
+ return result;
+}
+
+AUD_API float AUD_Handle_getAttenuation(AUD_Handle* handle)
+{
+ assert(handle);
+ std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
+
+ if(h.get())
+ return h->getAttenuation();
+ return 0.0f;
+}
+
+AUD_API int AUD_Handle_setAttenuation(AUD_Handle* handle, float value)
+{
+ assert(handle);
+ std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
+
+ if(h.get())
+ return h->setAttenuation(value);
+ return false;
+}
+
+AUD_API float AUD_Handle_getConeAngleInner(AUD_Handle* handle)
+{
+ assert(handle);
+ std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
+
+ if(h.get())
+ return h->getConeAngleInner();
+ return 0.0f;
+}
+
+AUD_API int AUD_Handle_setConeAngleInner(AUD_Handle* handle, float value)
+{
+ assert(handle);
+ std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
+
+ if(h.get())
+ return h->setConeAngleInner(value);
+ return false;
+}
+
+AUD_API float AUD_Handle_getConeAngleOuter(AUD_Handle* handle)
+{
+ assert(handle);
+ std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
+
+ if(h.get())
+ return h->getConeAngleOuter();
+ return 0.0f;
+}
+
+AUD_API int AUD_Handle_setConeAngleOuter(AUD_Handle* handle, float value)
+{
+ assert(handle);
+ std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
+
+ if(h.get())
+ return h->setConeAngleOuter(value);
+ return false;
+}
+
+AUD_API float AUD_Handle_getConeVolumeOuter(AUD_Handle* handle)
+{
+ assert(handle);
+ std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
+
+ if(h.get())
+ return h->getConeVolumeOuter();
+ return 0.0f;
+}
+
+AUD_API int AUD_Handle_setConeVolumeOuter(AUD_Handle* handle, float value)
+{
+ assert(handle);
+ std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
+
+ if(h.get())
+ return h->setConeVolumeOuter(value);
+ return false;
+}
+
+AUD_API float AUD_Handle_getDistanceMaximum(AUD_Handle* handle)
+{
+ assert(handle);
+ std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
+
+ if(h.get())
+ return h->getDistanceMaximum();
+ return 0.0f;
+}
+
+AUD_API int AUD_Handle_setDistanceMaximum(AUD_Handle* handle, float value)
+{
+ assert(handle);
+ std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
+
+ if(h.get())
+ return h->setDistanceMaximum(value);
+ return false;
+}
+
+AUD_API float AUD_Handle_getDistanceReference(AUD_Handle* handle)
+{
+ assert(handle);
+ std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
+
+ if(h.get())
+ return h->getDistanceReference();
+ return 0.0f;
+}
+
+AUD_API int AUD_Handle_setDistanceReference(AUD_Handle* handle, float value)
+{
+ assert(handle);
+ std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
+
+ if(h.get())
+ return h->setDistanceReference(value);
+ return false;
+}
+
+AUD_API int AUD_Handle_doesKeep(AUD_Handle* handle)
+{
+ assert(handle);
+ return (*handle)->getKeep();
+}
+
+AUD_API int AUD_Handle_setKeep(AUD_Handle* handle, int value)
+{
+ assert(handle);
+ return (*handle)->setKeep(value);
+}
+
+AUD_API int AUD_Handle_getLocation(AUD_Handle* handle, float value[3])
+{
+ assert(handle);
+ std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
+
+ if(h.get())
+ {
+ Vector3 v = h->getLocation();
+ value[0] = v.x();
+ value[1] = v.y();
+ value[2] = v.z();
+ return true;
+ }
+ return false;
+}
+
+AUD_API int AUD_Handle_setLocation(AUD_Handle* handle, const float value[3])
+{
+ assert(handle);
+ std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
+
+ if(h.get())
+ {
+ Vector3 v = Vector3(value[0], value[1], value[2]);
+ return h->setLocation(v);
+ }
+ return false;
+}
+
+AUD_API int AUD_Handle_getLoopCount(AUD_Handle* handle)
+{
+ assert(handle);
+ return (*handle)->getLoopCount();
+}
+
+AUD_API int AUD_Handle_setLoopCount(AUD_Handle* handle, int value)
+{
+ assert(handle);
+ return (*handle)->setLoopCount(value);
+}
+
+AUD_API int AUD_Handle_getOrientation(AUD_Handle* handle, float value[4])
+{
+ assert(handle);
+ std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
+
+ if(h.get())
+ {
+ Quaternion v = h->getOrientation();
+ value[0] = v.x();
+ value[1] = v.y();
+ value[2] = v.z();
+ value[3] = v.w();
+ return true;
+ }
+ return false;
+}
+
+AUD_API int AUD_Handle_setOrientation(AUD_Handle* handle, const float value[4])
+{
+ assert(handle);
+ std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
+
+ if(h.get())
+ {
+ Quaternion v(value[3], value[0], value[1], value[2]);
+ return h->setOrientation(v);
+ }
+ return false;
+}
+
+AUD_API float AUD_Handle_getPitch(AUD_Handle* handle)
+{
+ assert(handle);
+ return (*handle)->getPitch();
+}
+
+AUD_API int AUD_Handle_setPitch(AUD_Handle* handle, float value)
+{
+ assert(handle);
+ return (*handle)->setPitch(value);
+}
+
+AUD_API float AUD_Handle_getPosition(AUD_Handle* handle)
+{
+ assert(handle);
+ return (*handle)->getPosition();
+}
+
+AUD_API int AUD_Handle_setPosition(AUD_Handle* handle, float value)
+{
+ assert(handle);
+ return (*handle)->seek(value);
+}
+
+AUD_API int AUD_Handle_isRelative(AUD_Handle* handle)
+{
+ assert(handle);
+ std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
+
+ if(h.get())
+ return h->isRelative();
+ return true;
+}
+
+AUD_API int AUD_Handle_setRelative(AUD_Handle* handle, int value)
+{
+ assert(handle);
+ std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
+
+ if(h.get())
+ return h->setRelative(value);
+ return false;
+}
+
+AUD_API AUD_Status AUD_Handle_getStatus(AUD_Handle* handle)
+{
+ assert(handle);
+ return static_cast<AUD_Status>((*handle)->getStatus());
+}
+
+AUD_API int AUD_Handle_getVelocity(AUD_Handle* handle, float value[3])
+{
+ assert(handle);
+ std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
+
+ if(h.get())
+ {
+ Vector3 v = h->getVelocity();
+ value[0] = v.x();
+ value[1] = v.y();
+ value[2] = v.z();
+ return true;
+ }
+ return false;
+}
+
+AUD_API int AUD_Handle_setVelocity(AUD_Handle* handle, const float value[3])
+{
+ assert(handle);
+ std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
+
+ if(h.get())
+ {
+ Vector3 v = Vector3(value[0], value[1], value[2]);
+ return h->setVelocity(v);
+ }
+ return false;
+}
+
+AUD_API float AUD_Handle_getVolume(AUD_Handle* handle)
+{
+ assert(handle);
+ return (*handle)->getVolume();
+}
+
+AUD_API int AUD_Handle_setVolume(AUD_Handle* handle, float value)
+{
+ assert(handle);
+ return (*handle)->setVolume(value);
+}
+
+AUD_API float AUD_Handle_getVolumeMaximum(AUD_Handle* handle)
+{
+ assert(handle);
+ std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
+
+ if(h.get())
+ return h->getVolumeMaximum();
+ return 0.0f;
+}
+
+AUD_API int AUD_Handle_setVolumeMaximum(AUD_Handle* handle, float value)
+{
+ assert(handle);
+ std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
+
+ if(h.get())
+ return h->setVolumeMaximum(value);
+ return false;
+}
+
+AUD_API float AUD_Handle_getVolumeMinimum(AUD_Handle* handle)
+{
+ assert(handle);
+ std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
+
+ if(h.get())
+ return h->getVolumeMinimum();
+ return 0.0f;
+}
+
+AUD_API int AUD_Handle_setVolumeMinimum(AUD_Handle* handle, float value)
+{
+ assert(handle);
+ std::shared_ptr<I3DHandle> h = std::dynamic_pointer_cast<I3DHandle>(*handle);
+
+ if(h.get())
+ return h->setVolumeMinimum(value);
+ return false;
+}
+
+AUD_API void AUD_Handle_free(AUD_Handle* handle)
+{
+ delete handle;
+}
diff --git a/extern/audaspace/bindings/C/AUD_Handle.h b/extern/audaspace/bindings/C/AUD_Handle.h
new file mode 100644
index 00000000000..27cbd251de5
--- /dev/null
+++ b/extern/audaspace/bindings/C/AUD_Handle.h
@@ -0,0 +1,308 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+#include "AUD_Types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/// Status of a playback handle.
+typedef enum
+{
+ AUD_STATUS_INVALID = 0, /// Invalid handle. Maybe due to stopping.
+ AUD_STATUS_PLAYING, /// Sound is playing.
+ AUD_STATUS_PAUSED, /// Sound is being paused.
+ AUD_STATUS_STOPPED /// Sound is stopped but kept in the device.
+} AUD_Status;
+
+/**
+ * Pauses a played back sound.
+ * \param handle The handle to the sound.
+ * \return Whether the handle has been playing or not.
+ */
+extern AUD_API int AUD_Handle_pause(AUD_Handle* handle);
+
+/**
+ * Resumes a paused sound.
+ * \param handle The handle to the sound.
+ * \return Whether the handle has been paused or not.
+ */
+extern AUD_API int AUD_Handle_resume(AUD_Handle* handle);
+
+/**
+ * Stops a playing or paused sound.
+ * \param handle The handle to the sound.
+ * \return Whether the handle has been valid or not.
+ */
+extern AUD_API int AUD_Handle_stop(AUD_Handle* handle);
+
+/**
+ * Retrieves the attenuation of a handle.
+ * param handle The handle to get the attenuation from.
+ * return The attenuation of the handle.
+ */
+extern AUD_API float AUD_Handle_getAttenuation(AUD_Handle* handle);
+
+/**
+ * Sets the attenuation of a handle.
+ * param handle The handle to set the attenuation from.
+ * param value The new attenuation to set.
+ */
+extern AUD_API int AUD_Handle_setAttenuation(AUD_Handle* handle, float value);
+
+/**
+ * Retrieves the cone angle inner of a handle.
+ * param handle The handle to get the cone angle inner from.
+ * return The cone angle inner of the handle.
+ */
+extern AUD_API float AUD_Handle_getConeAngleInner(AUD_Handle* handle);
+
+/**
+ * Sets the cone angle inner of a handle.
+ * param handle The handle to set the cone angle inner from.
+ * param value The new cone angle inner to set.
+ */
+extern AUD_API int AUD_Handle_setConeAngleInner(AUD_Handle* handle, float value);
+
+/**
+ * Retrieves the cone angle outer of a handle.
+ * param handle The handle to get the cone angle outer from.
+ * return The cone angle outer of the handle.
+ */
+extern AUD_API float AUD_Handle_getConeAngleOuter(AUD_Handle* handle);
+
+/**
+ * Sets the cone angle outer of a handle.
+ * param handle The handle to set the cone angle outer from.
+ * param value The new cone angle outer to set.
+ */
+extern AUD_API int AUD_Handle_setConeAngleOuter(AUD_Handle* handle, float value);
+
+/**
+ * Retrieves the cone volume outer of a handle.
+ * param handle The handle to get the cone volume outer from.
+ * return The cone volume outer of the handle.
+ */
+extern AUD_API float AUD_Handle_getConeVolumeOuter(AUD_Handle* handle);
+
+/**
+ * Sets the cone volume outer of a handle.
+ * param handle The handle to set the cone volume outer from.
+ * param value The new cone volume outer to set.
+ */
+extern AUD_API int AUD_Handle_setConeVolumeOuter(AUD_Handle* handle, float value);
+
+/**
+ * Retrieves the distance maximum of a handle.
+ * param handle The handle to get the distance maximum from.
+ * return The distance maximum of the handle.
+ */
+extern AUD_API float AUD_Handle_getDistanceMaximum(AUD_Handle* handle);
+
+/**
+ * Sets the distance maximum of a handle.
+ * param handle The handle to set the distance maximum from.
+ * param value The new distance maximum to set.
+ */
+extern AUD_API int AUD_Handle_setDistanceMaximum(AUD_Handle* handle, float value);
+
+/**
+ * Retrieves the distance reference of a handle.
+ * param handle The handle to get the distance reference from.
+ * return The distance reference of the handle.
+ */
+extern AUD_API float AUD_Handle_getDistanceReference(AUD_Handle* handle);
+
+/**
+ * Sets the distance reference of a handle.
+ * param handle The handle to set the distance reference from.
+ * param value The new distance reference to set.
+ */
+extern AUD_API int AUD_Handle_setDistanceReference(AUD_Handle* handle, float value);
+
+/**
+ * Retrieves the keep of a handle.
+ * param handle The handle to get the keep from.
+ * return The keep of the handle.
+ */
+extern AUD_API int AUD_Handle_doesKeep(AUD_Handle* handle);
+
+/**
+ * Sets the keep of a handle.
+ * param handle The handle to set the keep from.
+ * param value The new keep to set.
+ */
+extern AUD_API int AUD_Handle_setKeep(AUD_Handle* handle, int value);
+
+/**
+ * Retrieves the location of a handle.
+ * param handle The handle to get the location from.
+ * return The location of the handle.
+ */
+extern AUD_API int AUD_Handle_getLocation(AUD_Handle* handle, float value[3]);
+
+/**
+ * Sets the location of a handle.
+ * param handle The handle to set the location from.
+ * param value The new location to set.
+ */
+extern AUD_API int AUD_Handle_setLocation(AUD_Handle* handle, const float value[3]);
+
+/**
+ * Retrieves the loop count of a handle.
+ * param handle The handle to get the loop count from.
+ * return The loop count of the handle.
+ */
+extern AUD_API int AUD_Handle_getLoopCount(AUD_Handle* handle);
+
+/**
+ * Sets the loop count of a handle.
+ * param handle The handle to set the loop count from.
+ * param value The new loop count to set.
+ */
+extern AUD_API int AUD_Handle_setLoopCount(AUD_Handle* handle, int value);
+
+/**
+ * Retrieves the orientation of a handle.
+ * param handle The handle to get the orientation from.
+ * return The orientation of the handle.
+ */
+extern AUD_API int AUD_Handle_getOrientation(AUD_Handle* handle, float value[4]);
+
+/**
+ * Sets the orientation of a handle.
+ * param handle The handle to set the orientation from.
+ * param value The new orientation to set.
+ */
+extern AUD_API int AUD_Handle_setOrientation(AUD_Handle* handle, const float value[4]);
+
+/**
+ * Retrieves the pitch of a handle.
+ * param handle The handle to get the pitch from.
+ * return The pitch of the handle.
+ */
+extern AUD_API float AUD_Handle_getPitch(AUD_Handle* handle);
+
+/**
+ * Sets the pitch of a handle.
+ * param handle The handle to set the pitch from.
+ * param value The new pitch to set.
+ */
+extern AUD_API int AUD_Handle_setPitch(AUD_Handle* handle, float value);
+
+/**
+ * Retrieves the position of a handle.
+ * param handle The handle to get the position from.
+ * return The position of the handle.
+ */
+extern AUD_API float AUD_Handle_getPosition(AUD_Handle* handle);
+
+/**
+ * Sets the position of a handle.
+ * param handle The handle to set the position from.
+ * param value The new position to set.
+ */
+extern AUD_API int AUD_Handle_setPosition(AUD_Handle* handle, float value);
+
+/**
+ * Retrieves the relative of a handle.
+ * param handle The handle to get the relative from.
+ * return The relative of the handle.
+ */
+extern AUD_API int AUD_Handle_isRelative(AUD_Handle* handle);
+
+/**
+ * Sets the relative of a handle.
+ * param handle The handle to set the relative from.
+ * param value The new relative to set.
+ */
+extern AUD_API int AUD_Handle_setRelative(AUD_Handle* handle, int value);
+
+/**
+ * Retrieves the status of a handle.
+ * param handle The handle to get the status from.
+ * return The status of the handle.
+ */
+extern AUD_API AUD_Status AUD_Handle_getStatus(AUD_Handle* handle);
+
+/**
+ * Retrieves the velocity of a handle.
+ * param handle The handle to get the velocity from.
+ * return The velocity of the handle.
+ */
+extern AUD_API int AUD_Handle_getVelocity(AUD_Handle* handle, float value[3]);
+
+/**
+ * Sets the velocity of a handle.
+ * param handle The handle to set the velocity from.
+ * param value The new velocity to set.
+ */
+extern AUD_API int AUD_Handle_setVelocity(AUD_Handle* handle, const float value[3]);
+
+/**
+ * Retrieves the volume of a handle.
+ * param handle The handle to get the volume from.
+ * return The volume of the handle.
+ */
+extern AUD_API float AUD_Handle_getVolume(AUD_Handle* handle);
+
+/**
+ * Sets the volume of a handle.
+ * param handle The handle to set the volume from.
+ * param value The new volume to set.
+ */
+extern AUD_API int AUD_Handle_setVolume(AUD_Handle* handle, float value);
+
+/**
+ * Retrieves the volume maximum of a handle.
+ * param handle The handle to get the volume maximum from.
+ * return The volume maximum of the handle.
+ */
+extern AUD_API float AUD_Handle_getVolumeMaximum(AUD_Handle* handle);
+
+/**
+ * Sets the volume maximum of a handle.
+ * param handle The handle to set the volume maximum from.
+ * param value The new volume maximum to set.
+ */
+extern AUD_API int AUD_Handle_setVolumeMaximum(AUD_Handle* handle, float value);
+
+/**
+ * Retrieves the volume minimum of a handle.
+ * param handle The handle to get the volume minimum from.
+ * return The volume minimum of the handle.
+ */
+extern AUD_API float AUD_Handle_getVolumeMinimum(AUD_Handle* handle);
+
+/**
+ * Sets the volume minimum of a handle.
+ * param handle The handle to set the volume minimum from.
+ * param value The new volume minimum to set.
+ */
+extern AUD_API int AUD_Handle_setVolumeMinimum(AUD_Handle* handle, float value);
+
+/**
+ * Frees a handle.
+ * \param channel Handle to free.
+ */
+extern AUD_API void AUD_Handle_free(AUD_Handle* channel);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/extern/audaspace/bindings/C/AUD_ImpulseResponse.cpp b/extern/audaspace/bindings/C/AUD_ImpulseResponse.cpp
new file mode 100644
index 00000000000..f3c28d4d660
--- /dev/null
+++ b/extern/audaspace/bindings/C/AUD_ImpulseResponse.cpp
@@ -0,0 +1,44 @@
+/*******************************************************************************
+* Copyright 2009-2015 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "Exception.h"
+
+#include <cassert>
+
+using namespace aud;
+
+#define AUD_CAPI_IMPLEMENTATION
+#include "AUD_ImpulseResponse.h"
+
+AUD_API AUD_ImpulseResponse* AUD_ImpulseResponse_create(AUD_Sound* sound)
+{
+ assert(sound);
+
+ try
+ {
+ return new AUD_ImpulseResponse(new ImpulseResponse(std::make_shared<StreamBuffer>(*sound)));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+AUD_API void AUD_ImpulseResponse_free(AUD_ImpulseResponse* filter)
+{
+ assert(filter);
+ delete filter;
+} \ No newline at end of file
diff --git a/extern/audaspace/bindings/C/AUD_ImpulseResponse.h b/extern/audaspace/bindings/C/AUD_ImpulseResponse.h
new file mode 100644
index 00000000000..dad2e87e899
--- /dev/null
+++ b/extern/audaspace/bindings/C/AUD_ImpulseResponse.h
@@ -0,0 +1,40 @@
+/*******************************************************************************
+* Copyright 2009-2015 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+#include "AUD_Types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+* Creates a new ImpulseResponse object.
+* \param sound A Sound object representing a impulse response.
+* \return The new ImpulseResponse object.
+*/
+extern AUD_API AUD_ImpulseResponse* AUD_ImpulseResponse_create(AUD_Sound* sound);
+
+/**
+* Deletes a ImpulseResponse object.
+* \param threadPool The ImpulseResponse object to be deleted.
+*/
+extern AUD_API void AUD_ImpulseResponse_free(AUD_ImpulseResponse* filter);
+
+#ifdef __cplusplus
+}
+#endif \ No newline at end of file
diff --git a/extern/audaspace/bindings/C/AUD_PlaybackManager.cpp b/extern/audaspace/bindings/C/AUD_PlaybackManager.cpp
new file mode 100644
index 00000000000..69ecb0987e1
--- /dev/null
+++ b/extern/audaspace/bindings/C/AUD_PlaybackManager.cpp
@@ -0,0 +1,94 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "Exception.h"
+
+#include <cassert>
+
+using namespace aud;
+
+#define AUD_CAPI_IMPLEMENTATION
+#include "AUD_PlaybackManager.h"
+
+AUD_API AUD_PlaybackManager* AUD_PlaybackManager_create(AUD_Device* device)
+{
+ assert(device);
+
+ try
+ {
+ return new AUD_PlaybackManager(new PlaybackManager(*device));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+AUD_API void AUD_PlaybackManager_free(AUD_PlaybackManager* manager)
+{
+ assert(manager);
+ delete manager;
+}
+
+AUD_API void AUD_PlaybackManager_play(AUD_PlaybackManager* manager, AUD_Sound* sound, unsigned int catKey)
+{
+ assert(manager);
+ assert(sound);
+
+ (*manager)->play(*sound, catKey);
+}
+
+AUD_API int AUD_PlaybackManager_resume(AUD_PlaybackManager* manager, unsigned int catKey)
+{
+ assert(manager);
+ return (*manager)->resume(catKey);
+}
+
+AUD_API int AUD_PlaybackManager_pause(AUD_PlaybackManager* manager, unsigned int catKey)
+{
+ assert(manager);
+ return (*manager)->pause(catKey);
+}
+
+AUD_API unsigned int AUD_PlaybackManager_addCategory(AUD_PlaybackManager* manager, float volume)
+{
+ assert(manager);
+ return (*manager)->addCategory(volume);
+}
+
+AUD_API float AUD_PlaybackManager_getVolume(AUD_PlaybackManager* manager, unsigned int catKey)
+{
+ assert(manager);
+ return (*manager)->getVolume(catKey);
+}
+
+AUD_API int AUD_PlaybackManager_setVolume(AUD_PlaybackManager* manager, float volume, unsigned int catKey)
+{
+ assert(manager);
+ return (*manager)->setVolume(volume, catKey);
+}
+
+AUD_API int AUD_PlaybackManager_stop(AUD_PlaybackManager* manager, unsigned int catKey)
+{
+ assert(manager);
+ return (*manager)->stop(catKey);
+}
+
+AUD_API void AUD_PlaybackManager_clean(AUD_PlaybackManager* manager)
+{
+ assert(manager);
+ (*manager)->clean();
+}
diff --git a/extern/audaspace/bindings/C/AUD_PlaybackManager.h b/extern/audaspace/bindings/C/AUD_PlaybackManager.h
new file mode 100644
index 00000000000..0fa8171599d
--- /dev/null
+++ b/extern/audaspace/bindings/C/AUD_PlaybackManager.h
@@ -0,0 +1,103 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+#include "AUD_Types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+* Creates a new PlaybackManager object.
+* \param device The device that will be used to play sounds.
+* \return The new PlaybackManager object.
+*/
+extern AUD_API AUD_PlaybackManager* AUD_PlaybackManager_create(AUD_Device* device);
+
+/**
+* Deletes a PlaybackManager object.
+* \param manager The PlaybackManager object to be deleted.
+*/
+extern AUD_API void AUD_PlaybackManager_free(AUD_PlaybackManager* manager);
+
+/**
+* Plays a sound through the playback manager, adding it into a category.
+* \param manager The PlaybackManager object.
+* \param sound The sound to be played.
+* \param catKey The key of the category into which the sound will be added. If it doesn't exist a new one will be creatd.
+*/
+extern AUD_API void AUD_PlaybackManager_play(AUD_PlaybackManager* manager, AUD_Sound* sound, unsigned int catKey);
+
+/**
+* Resumes the playback of all the paused sounds assigned to a category of a playback manager.
+* \param manager The PlaybackManager object.
+* \param catKey The key of the category.
+* \return 0 if the category doesn't exist.
+*/
+extern AUD_API int AUD_PlaybackManager_resume(AUD_PlaybackManager* manager, unsigned int catKey);
+
+/**
+* Pauses all the sounds assigned to a category of a playback manager.
+* \param manager The PlaybackManager object.
+* \param catKey The key of the category.
+* \return 0 if the category doesn't exist.
+*/
+extern AUD_API int AUD_PlaybackManager_pause(AUD_PlaybackManager* manager, unsigned int catKey);
+
+/**
+* Adds a new category with a custom volume.
+* \param manager The PlaybackManager object.
+* \param volume The volume value.
+* \return The key of the new category.
+*/
+extern AUD_API unsigned int AUD_PlaybackManager_addCategory(AUD_PlaybackManager* manager, float volume);
+
+/**
+* Retrieves the volume of a category of a playback manager.
+* \param manager The PlaybackManager object.
+* \param catKey The key of the category.
+* \return The volume of the category.
+*/
+extern AUD_API float AUD_PlaybackManager_getVolume(AUD_PlaybackManager* manager, unsigned int catKey);
+
+/**
+* Changes the voulume of a category of a playback manager.
+* \param manager The PlaybackManager object.
+* \param volume The new volume of the category.
+* \param catKey The key of the category.
+* \return 0 if the category doesn't exist.
+*/
+extern AUD_API int AUD_PlaybackManager_setVolume(AUD_PlaybackManager* manager, float volume, unsigned int catKey);
+
+/**
+* Stops all the sounds assigned to a category of a playback manager.
+* \param manager The PlaybackManager object.
+* \param catKey The key of the category.
+* \return 0 if the category doesn't exist.
+*/
+extern AUD_API int AUD_PlaybackManager_stop(AUD_PlaybackManager* manager, unsigned int catKey);
+
+/**
+* Cleans all the invalid handles in a playback manager
+* \param manager The PlaybackManager object.
+*/
+extern AUD_API void AUD_PlaybackManager_clean(AUD_PlaybackManager* manager);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/extern/audaspace/bindings/C/AUD_Sequence.cpp b/extern/audaspace/bindings/C/AUD_Sequence.cpp
new file mode 100644
index 00000000000..d278cb148a1
--- /dev/null
+++ b/extern/audaspace/bindings/C/AUD_Sequence.cpp
@@ -0,0 +1,315 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "devices/I3DDevice.h"
+#include "devices/DeviceManager.h"
+#include "sequence/Sequence.h"
+#include "Exception.h"
+
+#include <cassert>
+
+using namespace aud;
+
+#define AUD_CAPI_IMPLEMENTATION
+#include "AUD_Sequence.h"
+
+AUD_API AUD_Sound* AUD_Sequence_create(float fps, int muted)
+{
+ // specs are changed at a later point!
+ Specs specs;
+ specs.channels = CHANNELS_STEREO;
+ specs.rate = RATE_48000;
+ AUD_Sound* sequence = new AUD_Sound(std::shared_ptr<Sequence>(new Sequence(specs, fps, muted)));
+ return sequence;
+}
+
+AUD_API void AUD_Sequence_free(AUD_Sound* sequence)
+{
+ delete sequence;
+}
+
+AUD_API AUD_SequenceEntry* AUD_Sequence_add(AUD_Sound* sequence, AUD_Sound* sound, float begin, float end, float skip)
+{
+ if(!sound)
+ return new AUD_SequenceEntry(((Sequence *)sequence->get())->add(AUD_Sound(), begin, end, skip));
+ return new AUD_SequenceEntry(((Sequence *)sequence->get())->add(*sound, begin, end, skip));
+}
+
+AUD_API void AUD_Sequence_remove(AUD_Sound* sequence, AUD_SequenceEntry* entry)
+{
+ dynamic_cast<Sequence *>(sequence->get())->remove(*entry);
+ delete entry;
+}
+
+AUD_API void AUD_Sequence_setAnimationData(AUD_Sound* sequence, AUD_AnimateablePropertyType type, int frame, float* data, char animated)
+{
+ AnimateableProperty* prop = dynamic_cast<Sequence *>(sequence->get())->getAnimProperty(static_cast<AnimateablePropertyType>(type));
+ if(animated)
+ {
+ if(frame >= 0)
+ {
+ prop->write(data, frame, 1);
+ }
+ }
+ else
+ {
+ prop->write(data);
+ }
+}
+
+AUD_API AUD_DistanceModel AUD_Sequence_getDistanceModel(AUD_Sound* sequence)
+{
+ assert(sequence);
+ return static_cast<AUD_DistanceModel>(dynamic_cast<Sequence *>(sequence->get())->getDistanceModel());
+}
+
+AUD_API void AUD_Sequence_setDistanceModel(AUD_Sound* sequence, AUD_DistanceModel value)
+{
+ assert(sequence);
+ dynamic_cast<Sequence *>(sequence->get())->setDistanceModel(static_cast<DistanceModel>(value));
+}
+
+AUD_API float AUD_Sequence_getDopplerFactor(AUD_Sound* sequence)
+{
+ assert(sequence);
+ return dynamic_cast<Sequence *>(sequence->get())->getDopplerFactor();
+}
+
+AUD_API void AUD_Sequence_setDopplerFactor(AUD_Sound* sequence, float value)
+{
+ assert(sequence);
+ dynamic_cast<Sequence *>(sequence->get())->setDopplerFactor(value);
+}
+
+AUD_API float AUD_Sequence_getFPS(AUD_Sound* sequence)
+{
+ assert(sequence);
+ return dynamic_cast<Sequence *>(sequence->get())->getFPS();
+}
+
+AUD_API void AUD_Sequence_setFPS(AUD_Sound* sequence, float value)
+{
+ assert(sequence);
+ dynamic_cast<Sequence *>(sequence->get())->setFPS(value);
+}
+
+AUD_API int AUD_Sequence_isMuted(AUD_Sound* sequence)
+{
+ assert(sequence);
+ return dynamic_cast<Sequence *>(sequence->get())->isMuted();
+}
+
+AUD_API void AUD_Sequence_setMuted(AUD_Sound* sequence, int value)
+{
+ assert(sequence);
+ dynamic_cast<Sequence *>(sequence->get())->mute(value);
+}
+
+static inline AUD_Specs convSpecToC(aud::Specs specs)
+{
+ AUD_Specs s;
+ s.channels = static_cast<AUD_Channels>(specs.channels);
+ s.rate = static_cast<AUD_SampleRate>(specs.rate);
+ return s;
+}
+
+static inline aud::Specs convCToSpec(AUD_Specs specs)
+{
+ aud::Specs s;
+ s.channels = static_cast<Channels>(specs.channels);
+ s.rate = static_cast<SampleRate>(specs.rate);
+ return s;
+}
+
+AUD_API AUD_Specs AUD_Sequence_getSpecs(AUD_Sound* sequence)
+{
+ assert(sequence);
+ return convSpecToC(dynamic_cast<Sequence *>(sequence->get())->getSpecs());
+}
+
+AUD_API void AUD_Sequence_setSpecs(AUD_Sound* sequence, AUD_Specs value)
+{
+ assert(sequence);
+ dynamic_cast<Sequence *>(sequence->get())->setSpecs(convCToSpec(value));
+}
+
+AUD_API float AUD_Sequence_getSpeedOfSound(AUD_Sound* sequence)
+{
+ assert(sequence);
+ return dynamic_cast<Sequence *>(sequence->get())->getSpeedOfSound();
+}
+
+AUD_API void AUD_Sequence_setSpeedOfSound(AUD_Sound* sequence, float value)
+{
+ assert(sequence);
+ dynamic_cast<Sequence *>(sequence->get())->setSpeedOfSound(value);
+}
+
+
+
+AUD_API void AUD_SequenceEntry_move(AUD_SequenceEntry* entry, float begin, float end, float skip)
+{
+ (*entry)->move(begin, end, skip);
+}
+
+AUD_API void AUD_SequenceEntry_setAnimationData(AUD_SequenceEntry* entry, AUD_AnimateablePropertyType type, int frame, float* data, char animated)
+{
+ AnimateableProperty* prop = (*entry)->getAnimProperty(static_cast<AnimateablePropertyType>(type));
+ if(animated)
+ {
+ if(frame >= 0)
+ prop->write(data, frame, 1);
+ }
+ else
+ {
+ prop->write(data);
+ }
+}
+
+AUD_API float AUD_SequenceEntry_getAttenuation(AUD_SequenceEntry* sequence_entry)
+{
+ assert(sequence_entry);
+ return (*sequence_entry)->getAttenuation();
+}
+
+AUD_API void AUD_SequenceEntry_setAttenuation(AUD_SequenceEntry* sequence_entry, float value)
+{
+ assert(sequence_entry);
+ (*sequence_entry)->setAttenuation(value);
+}
+
+AUD_API float AUD_SequenceEntry_getConeAngleInner(AUD_SequenceEntry* sequence_entry)
+{
+ assert(sequence_entry);
+ return (*sequence_entry)->getConeAngleInner();
+}
+
+AUD_API void AUD_SequenceEntry_setConeAngleInner(AUD_SequenceEntry* sequence_entry, float value)
+{
+ assert(sequence_entry);
+ (*sequence_entry)->setConeAngleInner(value);
+}
+
+AUD_API float AUD_SequenceEntry_getConeAngleOuter(AUD_SequenceEntry* sequence_entry)
+{
+ assert(sequence_entry);
+ return (*sequence_entry)->getConeAngleOuter();
+}
+
+AUD_API void AUD_SequenceEntry_setConeAngleOuter(AUD_SequenceEntry* sequence_entry, float value)
+{
+ assert(sequence_entry);
+ (*sequence_entry)->setConeAngleOuter(value);
+}
+
+AUD_API float AUD_SequenceEntry_getConeVolumeOuter(AUD_SequenceEntry* sequence_entry)
+{
+ assert(sequence_entry);
+ return (*sequence_entry)->getConeVolumeOuter();
+}
+
+AUD_API void AUD_SequenceEntry_setConeVolumeOuter(AUD_SequenceEntry* sequence_entry, float value)
+{
+ assert(sequence_entry);
+ (*sequence_entry)->setConeVolumeOuter(value);
+}
+
+AUD_API float AUD_SequenceEntry_getDistanceMaximum(AUD_SequenceEntry* sequence_entry)
+{
+ assert(sequence_entry);
+ return (*sequence_entry)->getDistanceMaximum();
+}
+
+AUD_API void AUD_SequenceEntry_setDistanceMaximum(AUD_SequenceEntry* sequence_entry, float value)
+{
+ assert(sequence_entry);
+ (*sequence_entry)->setDistanceMaximum(value);
+}
+
+AUD_API float AUD_SequenceEntry_getDistanceReference(AUD_SequenceEntry* sequence_entry)
+{
+ assert(sequence_entry);
+ return (*sequence_entry)->getDistanceReference();
+}
+
+AUD_API void AUD_SequenceEntry_setDistanceReference(AUD_SequenceEntry* sequence_entry, float value)
+{
+ assert(sequence_entry);
+ (*sequence_entry)->setDistanceReference(value);
+}
+
+AUD_API int AUD_SequenceEntry_isMuted(AUD_SequenceEntry* sequence_entry)
+{
+ assert(sequence_entry);
+ return (*sequence_entry)->isMuted();
+}
+
+AUD_API void AUD_SequenceEntry_setMuted(AUD_SequenceEntry* sequence_entry, int value)
+{
+ assert(sequence_entry);
+ (*sequence_entry)->mute(value);
+}
+
+AUD_API int AUD_SequenceEntry_isRelative(AUD_SequenceEntry* sequence_entry)
+{
+ assert(sequence_entry);
+ return (*sequence_entry)->isRelative();
+}
+
+AUD_API void AUD_SequenceEntry_setRelative(AUD_SequenceEntry* sequence_entry, int value)
+{
+ assert(sequence_entry);
+ (*sequence_entry)->setRelative(value);
+}
+
+AUD_API AUD_Sound* AUD_SequenceEntry_getSound(AUD_SequenceEntry* sequence_entry)
+{
+ assert(sequence_entry);
+ return new std::shared_ptr<ISound>((*sequence_entry)->getSound());
+}
+
+AUD_API void AUD_SequenceEntry_setSound(AUD_SequenceEntry* sequence_entry, AUD_Sound* value)
+{
+ assert(sequence_entry);
+ if(value)
+ (*sequence_entry)->setSound(*value);
+ else
+ (*sequence_entry)->setSound(AUD_Sound());
+}
+
+AUD_API float AUD_SequenceEntry_getVolumeMaximum(AUD_SequenceEntry* sequence_entry)
+{
+ assert(sequence_entry);
+ return (*sequence_entry)->getVolumeMaximum();
+}
+
+AUD_API void AUD_SequenceEntry_setVolumeMaximum(AUD_SequenceEntry* sequence_entry, float value)
+{
+ assert(sequence_entry);
+ (*sequence_entry)->setVolumeMaximum(value);
+}
+
+AUD_API float AUD_SequenceEntry_getVolumeMinimum(AUD_SequenceEntry* sequence_entry)
+{
+ assert(sequence_entry);
+ return (*sequence_entry)->getVolumeMinimum();
+}
+
+AUD_API void AUD_SequenceEntry_setVolumeMinimum(AUD_SequenceEntry* sequence_entry, float value)
+{
+ assert(sequence_entry);
+ (*sequence_entry)->setVolumeMinimum(value);
+}
diff --git a/extern/audaspace/bindings/C/AUD_Sequence.h b/extern/audaspace/bindings/C/AUD_Sequence.h
new file mode 100644
index 00000000000..668960c7d50
--- /dev/null
+++ b/extern/audaspace/bindings/C/AUD_Sequence.h
@@ -0,0 +1,338 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+#include "AUD_Device.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/// Possible animatable properties for Sequence Factories and Entries.
+typedef enum
+{
+ AUD_AP_VOLUME,
+ AUD_AP_PANNING,
+ AUD_AP_PITCH,
+ AUD_AP_LOCATION,
+ AUD_AP_ORIENTATION
+} AUD_AnimateablePropertyType;
+
+/**
+ * Creates a new sequenced sound scene.
+ * \param fps The FPS of the scene.
+ * \param muted Whether the scene is muted.
+ * \return The new sound scene.
+ */
+extern AUD_API AUD_Sound* AUD_Sequence_create(float fps, int muted);
+
+/**
+ * Deletes a sound scene.
+ * \param sequence The sound scene.
+ */
+extern AUD_API void AUD_Sequence_free(AUD_Sound* sequence);
+
+/**
+ * Adds a new entry to the scene.
+ * \param sequence The sound 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.
+ */
+extern AUD_API AUD_SequenceEntry* AUD_Sequence_add(AUD_Sound* sequence, AUD_Sound* sound, float begin, float end, float skip);
+
+/**
+ * Removes an entry from the scene.
+ * \param sequence The sound scene.
+ * \param entry The entry to remove.
+ */
+extern AUD_API void AUD_Sequence_remove(AUD_Sound* sequence, AUD_SequenceEntry* entry);
+
+/**
+ * Writes animation data to a sequence.
+ * \param sequence The sound scene.
+ * \param type The type of animation data.
+ * \param frame The frame this data is for.
+ * \param data The data to write.
+ * \param animated Whether the attribute is animated.
+ */
+extern AUD_API void AUD_Sequence_setAnimationData(AUD_Sound* sequence, AUD_AnimateablePropertyType type, int frame, float* data, char animated);
+
+/**
+ * Retrieves the distance model of a sequence.
+ * param sequence The sequence to get the distance model from.
+ * return The distance model of the sequence.
+ */
+extern AUD_API AUD_DistanceModel AUD_Sequence_getDistanceModel(AUD_Sound* sequence);
+
+/**
+ * Sets the distance model of a sequence.
+ * param sequence The sequence to set the distance model from.
+ * param value The new distance model to set.
+ */
+extern AUD_API void AUD_Sequence_setDistanceModel(AUD_Sound* sequence, AUD_DistanceModel value);
+
+/**
+ * Retrieves the doppler factor of a sequence.
+ * param sequence The sequence to get the doppler factor from.
+ * return The doppler factor of the sequence.
+ */
+extern AUD_API float AUD_Sequence_getDopplerFactor(AUD_Sound* sequence);
+
+/**
+ * Sets the doppler factor of a sequence.
+ * param sequence The sequence to set the doppler factor from.
+ * param value The new doppler factor to set.
+ */
+extern AUD_API void AUD_Sequence_setDopplerFactor(AUD_Sound* sequence, float value);
+
+/**
+ * Retrieves the fps of a sequence.
+ * param sequence The sequence to get the fps from.
+ * return The fps of the sequence.
+ */
+extern AUD_API float AUD_Sequence_getFPS(AUD_Sound* sequence);
+
+/**
+ * Sets the fps of a sequence.
+ * param sequence The sequence to set the fps from.
+ * param value The new fps to set.
+ */
+extern AUD_API void AUD_Sequence_setFPS(AUD_Sound* sequence, float value);
+
+/**
+ * Retrieves the muted of a sequence.
+ * param sequence The sequence to get the muted from.
+ * return The muted of the sequence.
+ */
+extern AUD_API int AUD_Sequence_isMuted(AUD_Sound* sequence);
+
+/**
+ * Sets the muted of a sequence.
+ * param sequence The sequence to set the muted from.
+ * param value The new muted to set.
+ */
+extern AUD_API void AUD_Sequence_setMuted(AUD_Sound* sequence, int value);
+
+/**
+ * Retrieves the specs of a sequence.
+ * param sequence The sequence to get the specs from.
+ * return The specs of the sequence.
+ */
+extern AUD_API AUD_Specs AUD_Sequence_getSpecs(AUD_Sound* sequence);
+
+/**
+ * Sets the specs of a sequence.
+ * param sequence The sequence to set the specs from.
+ * param value The new specs to set.
+ */
+extern AUD_API void AUD_Sequence_setSpecs(AUD_Sound* sequence, AUD_Specs value);
+
+/**
+ * Retrieves the speed of sound of a sequence.
+ * param sequence The sequence to get the speed of sound from.
+ * return The speed of sound of the sequence.
+ */
+extern AUD_API float AUD_Sequence_getSpeedOfSound(AUD_Sound* sequence);
+
+/**
+ * Sets the speed of sound of a sequence.
+ * param sequence The sequence to set the speed of sound from.
+ * param value The new speed of sound to set.
+ */
+extern AUD_API void AUD_Sequence_setSpeedOfSound(AUD_Sound* sequence, float value);
+
+
+
+/**
+ * Moves the entry.
+ * \param entry The sequenced entry.
+ * \param begin The new start time.
+ * \param end The new end time or a negative value if unknown.
+ * \param skip How many seconds to skip at the beginning.
+ */
+extern AUD_API void AUD_SequenceEntry_move(AUD_SequenceEntry* entry, float begin, float end, float skip);
+
+/**
+ * Writes animation data to a sequenced entry.
+ * \param entry The sequenced entry.
+ * \param type The type of animation data.
+ * \param frame The frame this data is for.
+ * \param data The data to write.
+ * \param animated Whether the attribute is animated.
+ */
+extern AUD_API void AUD_SequenceEntry_setAnimationData(AUD_SequenceEntry* entry, AUD_AnimateablePropertyType type, int frame, float* data, char animated);
+
+/**
+ * Retrieves the attenuation of a sequence_entry.
+ * param sequence_entry The sequence_entry to get the attenuation from.
+ * return The attenuation of the sequence_entry.
+ */
+extern AUD_API float AUD_SequenceEntry_getAttenuation(AUD_SequenceEntry* sequence_entry);
+
+/**
+ * Sets the attenuation of a sequence_entry.
+ * param sequence_entry The sequence_entry to set the attenuation from.
+ * param value The new attenuation to set.
+ */
+extern AUD_API void AUD_SequenceEntry_setAttenuation(AUD_SequenceEntry* sequence_entry, float value);
+
+/**
+ * Retrieves the cone angle inner of a sequence_entry.
+ * param sequence_entry The sequence_entry to get the cone angle inner from.
+ * return The cone angle inner of the sequence_entry.
+ */
+extern AUD_API float AUD_SequenceEntry_getConeAngleInner(AUD_SequenceEntry* sequence_entry);
+
+/**
+ * Sets the cone angle inner of a sequence_entry.
+ * param sequence_entry The sequence_entry to set the cone angle inner from.
+ * param value The new cone angle inner to set.
+ */
+extern AUD_API void AUD_SequenceEntry_setConeAngleInner(AUD_SequenceEntry* sequence_entry, float value);
+
+/**
+ * Retrieves the cone angle outer of a sequence_entry.
+ * param sequence_entry The sequence_entry to get the cone angle outer from.
+ * return The cone angle outer of the sequence_entry.
+ */
+extern AUD_API float AUD_SequenceEntry_getConeAngleOuter(AUD_SequenceEntry* sequence_entry);
+
+/**
+ * Sets the cone angle outer of a sequence_entry.
+ * param sequence_entry The sequence_entry to set the cone angle outer from.
+ * param value The new cone angle outer to set.
+ */
+extern AUD_API void AUD_SequenceEntry_setConeAngleOuter(AUD_SequenceEntry* sequence_entry, float value);
+
+/**
+ * Retrieves the cone volume outer of a sequence_entry.
+ * param sequence_entry The sequence_entry to get the cone volume outer from.
+ * return The cone volume outer of the sequence_entry.
+ */
+extern AUD_API float AUD_SequenceEntry_getConeVolumeOuter(AUD_SequenceEntry* sequence_entry);
+
+/**
+ * Sets the cone volume outer of a sequence_entry.
+ * param sequence_entry The sequence_entry to set the cone volume outer from.
+ * param value The new cone volume outer to set.
+ */
+extern AUD_API void AUD_SequenceEntry_setConeVolumeOuter(AUD_SequenceEntry* sequence_entry, float value);
+
+/**
+ * Retrieves the distance maximum of a sequence_entry.
+ * param sequence_entry The sequence_entry to get the distance maximum from.
+ * return The distance maximum of the sequence_entry.
+ */
+extern AUD_API float AUD_SequenceEntry_getDistanceMaximum(AUD_SequenceEntry* sequence_entry);
+
+/**
+ * Sets the distance maximum of a sequence_entry.
+ * param sequence_entry The sequence_entry to set the distance maximum from.
+ * param value The new distance maximum to set.
+ */
+extern AUD_API void AUD_SequenceEntry_setDistanceMaximum(AUD_SequenceEntry* sequence_entry, float value);
+
+/**
+ * Retrieves the distance reference of a sequence_entry.
+ * param sequence_entry The sequence_entry to get the distance reference from.
+ * return The distance reference of the sequence_entry.
+ */
+extern AUD_API float AUD_SequenceEntry_getDistanceReference(AUD_SequenceEntry* sequence_entry);
+
+/**
+ * Sets the distance reference of a sequence_entry.
+ * param sequence_entry The sequence_entry to set the distance reference from.
+ * param value The new distance reference to set.
+ */
+extern AUD_API void AUD_SequenceEntry_setDistanceReference(AUD_SequenceEntry* sequence_entry, float value);
+
+/**
+ * Retrieves the muted of a sequence_entry.
+ * param sequence_entry The sequence_entry to get the muted from.
+ * return The muted of the sequence_entry.
+ */
+extern AUD_API int AUD_SequenceEntry_isMuted(AUD_SequenceEntry* sequence_entry);
+
+/**
+ * Sets the muted of a sequence_entry.
+ * param sequence_entry The sequence_entry to set the muted from.
+ * param value The new muted to set.
+ */
+extern AUD_API void AUD_SequenceEntry_setMuted(AUD_SequenceEntry* sequence_entry, int value);
+
+/**
+ * Retrieves the relative of a sequence_entry.
+ * param sequence_entry The sequence_entry to get the relative from.
+ * return The relative of the sequence_entry.
+ */
+extern AUD_API int AUD_SequenceEntry_isRelative(AUD_SequenceEntry* sequence_entry);
+
+/**
+ * Sets the relative of a sequence_entry.
+ * param sequence_entry The sequence_entry to set the relative from.
+ * param value The new relative to set.
+ */
+extern AUD_API void AUD_SequenceEntry_setRelative(AUD_SequenceEntry* sequence_entry, int value);
+
+/**
+ * Retrieves the sound of a sequence_entry.
+ * param sequence_entry The sequence_entry to get the sound from.
+ * return The sound of the sequence_entry.
+ */
+extern AUD_API AUD_Sound* AUD_SequenceEntry_getSound(AUD_SequenceEntry* sequence_entry);
+
+/**
+ * Sets the sound of a sequence_entry.
+ * param sequence_entry The sequence_entry to set the sound from.
+ * param value The new sound to set.
+ */
+extern AUD_API void AUD_SequenceEntry_setSound(AUD_SequenceEntry* sequence_entry, AUD_Sound* value);
+
+/**
+ * Retrieves the volume maximum of a sequence_entry.
+ * param sequence_entry The sequence_entry to get the volume maximum from.
+ * return The volume maximum of the sequence_entry.
+ */
+extern AUD_API float AUD_SequenceEntry_getVolumeMaximum(AUD_SequenceEntry* sequence_entry);
+
+/**
+ * Sets the volume maximum of a sequence_entry.
+ * param sequence_entry The sequence_entry to set the volume maximum from.
+ * param value The new volume maximum to set.
+ */
+extern AUD_API void AUD_SequenceEntry_setVolumeMaximum(AUD_SequenceEntry* sequence_entry, float value);
+
+/**
+ * Retrieves the volume minimum of a sequence_entry.
+ * param sequence_entry The sequence_entry to get the volume minimum from.
+ * return The volume minimum of the sequence_entry.
+ */
+extern AUD_API float AUD_SequenceEntry_getVolumeMinimum(AUD_SequenceEntry* sequence_entry);
+
+/**
+ * Sets the volume minimum of a sequence_entry.
+ * param sequence_entry The sequence_entry to set the volume minimum from.
+ * param value The new volume minimum to set.
+ */
+extern AUD_API void AUD_SequenceEntry_setVolumeMinimum(AUD_SequenceEntry* sequence_entry, float value);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/extern/audaspace/bindings/C/AUD_Sound.cpp b/extern/audaspace/bindings/C/AUD_Sound.cpp
new file mode 100644
index 00000000000..30860acde62
--- /dev/null
+++ b/extern/audaspace/bindings/C/AUD_Sound.cpp
@@ -0,0 +1,709 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "generator/Sawtooth.h"
+#include "generator/Sine.h"
+#include "generator/Silence.h"
+#include "generator/Square.h"
+#include "generator/Triangle.h"
+#include "file/File.h"
+#include "file/FileWriter.h"
+#include "util/StreamBuffer.h"
+#include "fx/Accumulator.h"
+#include "fx/ADSR.h"
+#include "fx/Delay.h"
+#include "fx/Envelope.h"
+#include "fx/Fader.h"
+#include "fx/Highpass.h"
+#include "fx/IIRFilter.h"
+#include "fx/Limiter.h"
+#include "fx/Loop.h"
+#include "fx/Lowpass.h"
+#include "fx/Pitch.h"
+#include "fx/Reverse.h"
+#include "fx/Sum.h"
+#include "fx/Threshold.h"
+#include "fx/Volume.h"
+#include "fx/SoundList.h"
+#include "fx/MutableSound.h"
+#include "sequence/Double.h"
+#include "sequence/Superpose.h"
+#include "sequence/PingPong.h"
+#include "respec/LinearResample.h"
+#include "respec/JOSResample.h"
+#include "respec/JOSResampleReader.h"
+#include "respec/ChannelMapper.h"
+#include "respec/ChannelMapperReader.h"
+#include "util/Buffer.h"
+#include "Exception.h"
+
+#ifdef WITH_CONVOLUTION
+#include "fx/BinauralSound.h"
+#include "fx/ConvolverSound.h"
+#endif
+
+#include <cassert>
+#include <cstring>
+
+using namespace aud;
+
+#define AUD_CAPI_IMPLEMENTATION
+#include "AUD_Sound.h"
+
+static inline AUD_Specs convSpecToC(aud::Specs specs)
+{
+ AUD_Specs s;
+ s.channels = static_cast<AUD_Channels>(specs.channels);
+ s.rate = static_cast<AUD_SampleRate>(specs.rate);
+ return s;
+}
+
+static inline aud::Specs convCToSpec(AUD_Specs specs)
+{
+ aud::Specs s;
+ s.channels = static_cast<Channels>(specs.channels);
+ s.rate = static_cast<SampleRate>(specs.rate);
+ return s;
+}
+
+AUD_API AUD_Specs AUD_Sound_getSpecs(AUD_Sound* sound)
+{
+ assert(sound);
+
+ return convSpecToC((*sound)->createReader()->getSpecs());
+}
+
+AUD_API int AUD_Sound_getLength(AUD_Sound* sound)
+{
+ assert(sound);
+
+ return (*sound)->createReader()->getLength();
+}
+
+AUD_API sample_t* AUD_Sound_data(AUD_Sound* sound, int* length, AUD_Specs* specs)
+{
+ assert(sound);
+ assert(length);
+ assert(specs);
+
+ auto stream_buffer = std::dynamic_pointer_cast<StreamBuffer>(*sound);
+ if(!stream_buffer)
+ stream_buffer = std::make_shared<StreamBuffer>(*sound);
+ *specs = convSpecToC(stream_buffer->getSpecs());
+ auto buffer = stream_buffer->getBuffer();
+
+ *length = buffer->getSize() / AUD_SAMPLE_SIZE((*specs));
+
+ sample_t* data = new sample_t[buffer->getSize()];
+
+ std::memcpy(data, buffer->getBuffer(), buffer->getSize());
+
+ return data;
+}
+
+AUD_API void AUD_Sound_freeData(sample_t* data)
+{
+ delete[] data;
+}
+
+AUD_API const char* AUD_Sound_write(AUD_Sound* sound, const char* filename, AUD_SampleRate rate, AUD_Channels channels, AUD_SampleFormat format, AUD_Container container, AUD_Codec codec, int bitrate, int buffersize)
+{
+ assert(sound);
+ assert(filename);
+
+ try
+ {
+ std::shared_ptr<IReader> reader = (*sound)->createReader();
+
+ DeviceSpecs specs;
+ specs.specs = reader->getSpecs();
+
+ if((rate != RATE_INVALID) && (specs.rate != rate))
+ {
+ specs.rate = rate;
+ reader = std::make_shared<JOSResampleReader>(reader, rate);
+ }
+
+ if((channels != AUD_CHANNELS_INVALID) && (specs.channels != static_cast<Channels>(channels)))
+ {
+ specs.channels = static_cast<Channels>(channels);
+ reader = std::make_shared<ChannelMapperReader>(reader, specs.channels);
+ }
+
+ if(format == AUD_FORMAT_INVALID)
+ format = AUD_FORMAT_S16;
+ specs.format = static_cast<SampleFormat>(format);
+
+ const char* invalid_container_error = "Container could not be determined from filename.";
+
+ if(container == AUD_CONTAINER_INVALID)
+ {
+ std::string path = filename;
+
+ if(path.length() < 4)
+ return invalid_container_error;
+
+ std::string extension = path.substr(path.length() - 4);
+
+ if(extension == ".ac3")
+ container = AUD_CONTAINER_AC3;
+ else if(extension == "flac")
+ container = AUD_CONTAINER_FLAC;
+ else if(extension == ".mkv")
+ container = AUD_CONTAINER_MATROSKA;
+ else if(extension == ".mp2")
+ container = AUD_CONTAINER_MP2;
+ else if(extension == ".mp3")
+ container = AUD_CONTAINER_MP3;
+ else if(extension == ".ogg")
+ container = AUD_CONTAINER_OGG;
+ else if(extension == ".wav")
+ container = AUD_CONTAINER_WAV;
+ else
+ return invalid_container_error;
+ }
+
+ if(codec == AUD_CODEC_INVALID)
+ {
+ switch(container)
+ {
+ case AUD_CONTAINER_AC3:
+ codec = AUD_CODEC_AC3;
+ break;
+ case AUD_CONTAINER_FLAC:
+ codec = AUD_CODEC_FLAC;
+ break;
+ case AUD_CONTAINER_MATROSKA:
+ codec = AUD_CODEC_OPUS;
+ break;
+ case AUD_CONTAINER_MP2:
+ codec = AUD_CODEC_MP2;
+ break;
+ case AUD_CONTAINER_MP3:
+ codec = AUD_CODEC_MP3;
+ break;
+ case AUD_CONTAINER_OGG:
+ codec = AUD_CODEC_VORBIS;
+ break;
+ case AUD_CONTAINER_WAV:
+ codec = AUD_CODEC_PCM;
+ break;
+ default:
+ return "Unknown container, cannot select default codec.";
+ }
+ }
+
+ if(buffersize <= 0)
+ buffersize = AUD_DEFAULT_BUFFER_SIZE;
+
+ std::shared_ptr<IWriter> writer = FileWriter::createWriter(filename, specs, static_cast<Container>(container), static_cast<Codec>(codec), bitrate);
+ FileWriter::writeReader(reader, writer, 0, buffersize);
+ }
+ catch(Exception& e)
+ {
+ return "An exception occured while writing.";
+ }
+
+ return nullptr;
+}
+
+AUD_API AUD_Sound* AUD_Sound_buffer(sample_t* data, int length, AUD_Specs specs)
+{
+ assert(data);
+
+ if(length <= 0 || specs.rate <= 0 || specs.channels <= 0)
+ {
+ return nullptr;
+ }
+
+ int size = length * AUD_SAMPLE_SIZE(specs);
+
+ std::shared_ptr<Buffer> buffer = std::make_shared<Buffer>(size);
+
+ std::memcpy(buffer->getBuffer(), data, size);
+
+ try
+ {
+ return new AUD_Sound(new StreamBuffer(buffer, convCToSpec(specs)));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+AUD_API AUD_Sound* AUD_Sound_bufferFile(unsigned char* buffer, int size)
+{
+ assert(buffer);
+ return new AUD_Sound(new File(buffer, size));
+}
+
+AUD_API AUD_Sound* AUD_Sound_cache(AUD_Sound* sound)
+{
+ assert(sound);
+
+ try
+ {
+ return new AUD_Sound(new StreamBuffer(*sound));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+AUD_API AUD_Sound* AUD_Sound_file(const char* filename)
+{
+ assert(filename);
+ return new AUD_Sound(new File(filename));
+}
+
+AUD_API AUD_Sound* AUD_Sound_sawtooth(float frequency, AUD_SampleRate rate)
+{
+ return new AUD_Sound(new Sawtooth(frequency, rate));
+}
+
+AUD_API AUD_Sound*AUD_Sound_silence()
+{
+ return new AUD_Sound(new Silence());
+}
+
+AUD_API AUD_Sound* AUD_Sound_sine(float frequency, AUD_SampleRate rate)
+{
+ return new AUD_Sound(new Sine(frequency, rate));
+}
+
+AUD_API AUD_Sound* AUD_Sound_square(float frequency, AUD_SampleRate rate)
+{
+ return new AUD_Sound(new Square(frequency, rate));
+}
+
+AUD_API AUD_Sound* AUD_Sound_triangle(float frequency, AUD_SampleRate rate)
+{
+ return new AUD_Sound(new Triangle(frequency, rate));
+}
+
+AUD_API AUD_Sound* AUD_Sound_accumulate(AUD_Sound* sound, int additive)
+{
+ assert(sound);
+
+ try
+ {
+ return new AUD_Sound(new Accumulator(*sound, additive));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+AUD_API AUD_Sound* AUD_Sound_ADSR(AUD_Sound* sound, float attack, float decay, float sustain, float release)
+{
+ assert(sound);
+
+ try
+ {
+ return new AUD_Sound(new ADSR(*sound, attack, decay, sustain, release));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+AUD_API AUD_Sound* AUD_Sound_delay(AUD_Sound* sound, float delay)
+{
+ assert(sound);
+
+ try
+ {
+ return new AUD_Sound(new Delay(*sound, delay));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+AUD_API AUD_Sound* AUD_Sound_envelope(AUD_Sound* sound, float attack, float release, float threshold, float arthreshold)
+{
+ assert(sound);
+
+ try
+ {
+ return new AUD_Sound(new Envelope(*sound, attack, release, threshold, arthreshold));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+AUD_API AUD_Sound* AUD_Sound_fadein(AUD_Sound* sound, float start, float length)
+{
+ assert(sound);
+
+ try
+ {
+ return new AUD_Sound(new Fader(*sound, FADE_IN, start, length));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+AUD_API AUD_Sound* AUD_Sound_fadeout(AUD_Sound* sound, float start, float length)
+{
+ assert(sound);
+
+ try
+ {
+ return new AUD_Sound(new Fader(*sound, FADE_OUT, start, length));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+AUD_API AUD_Sound* AUD_Sound_filter(AUD_Sound* sound, float* b, int b_length, float* a, int a_length)
+{
+ assert(sound);
+
+ try
+ {
+ std::vector<float> a_coeff, b_coeff;
+
+ if(b)
+ for(int i = 0; i < b_length; i++)
+ b_coeff.push_back(b[i]);
+
+ if(a)
+ {
+ for(int i = 0; i < a_length; i++)
+ a_coeff.push_back(a[i]);
+
+ if(*a == 0.0f)
+ a_coeff[0] = 1.0f;
+ }
+
+ return new AUD_Sound(new IIRFilter(*sound, b_coeff, a_coeff));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+AUD_API AUD_Sound* AUD_Sound_highpass(AUD_Sound* sound, float frequency, float Q)
+{
+ assert(sound);
+
+ try
+ {
+ return new AUD_Sound(new Highpass(*sound, frequency, Q));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+AUD_API AUD_Sound* AUD_Sound_limit(AUD_Sound* sound, float start, float end)
+{
+ assert(sound);
+
+ try
+ {
+ return new AUD_Sound(new Limiter(*sound, start, end));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+AUD_API AUD_Sound* AUD_Sound_loop(AUD_Sound* sound, int count)
+{
+ assert(sound);
+
+ try
+ {
+ return new AUD_Sound(new Loop(*sound, count));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+AUD_API AUD_Sound* AUD_Sound_lowpass(AUD_Sound* sound, float frequency, float Q)
+{
+ assert(sound);
+
+ try
+ {
+ return new AUD_Sound(new Lowpass(*sound, frequency, Q));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+AUD_API AUD_Sound* AUD_Sound_pitch(AUD_Sound* sound, float factor)
+{
+ assert(sound);
+
+ try
+ {
+ return new AUD_Sound(new Pitch(*sound, factor));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+AUD_API AUD_Sound* AUD_Sound_rechannel(AUD_Sound* sound, AUD_Channels channels)
+{
+ assert(sound);
+
+ try
+ {
+ DeviceSpecs specs;
+ specs.channels = static_cast<Channels>(channels);
+ specs.rate = RATE_INVALID;
+ specs.format = FORMAT_INVALID;
+ return new AUD_Sound(new ChannelMapper(*sound, specs));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+AUD_API AUD_Sound* AUD_Sound_resample(AUD_Sound* sound, AUD_SampleRate rate, bool high_quality)
+{
+ assert(sound);
+
+ try
+ {
+ DeviceSpecs specs;
+ specs.channels = CHANNELS_INVALID;
+ specs.rate = rate;
+ specs.format = FORMAT_INVALID;
+ if(high_quality)
+ return new AUD_Sound(new JOSResample(*sound, specs));
+ else
+ return new AUD_Sound(new LinearResample(*sound, specs));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+AUD_API AUD_Sound* AUD_Sound_reverse(AUD_Sound* sound)
+{
+ assert(sound);
+
+ try
+ {
+ return new AUD_Sound(new Reverse(*sound));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+AUD_API AUD_Sound* AUD_Sound_sum(AUD_Sound* sound)
+{
+ assert(sound);
+
+ try
+ {
+ return new AUD_Sound(new Sum(*sound));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+AUD_API AUD_Sound* AUD_Sound_threshold(AUD_Sound* sound, float threshold)
+{
+ assert(sound);
+
+ try
+ {
+ return new AUD_Sound(new Threshold(*sound, threshold));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+AUD_API AUD_Sound* AUD_Sound_volume(AUD_Sound* sound, float volume)
+{
+ assert(sound);
+
+ try
+ {
+ return new AUD_Sound(new Volume(*sound, volume));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+AUD_API AUD_Sound* AUD_Sound_join(AUD_Sound* first, AUD_Sound* second)
+{
+ assert(first);
+ assert(second);
+
+ try
+ {
+ return new AUD_Sound(new Double(*first, *second));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+AUD_API AUD_Sound* AUD_Sound_mix(AUD_Sound* first, AUD_Sound* second)
+{
+ assert(first);
+ assert(second);
+
+ try
+ {
+ return new AUD_Sound(new Superpose(*first, *second));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+AUD_API AUD_Sound* AUD_Sound_pingpong(AUD_Sound* sound)
+{
+ assert(sound);
+
+ try
+ {
+ return new AUD_Sound(new PingPong(*sound));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+AUD_API void AUD_Sound_free(AUD_Sound* sound)
+{
+ assert(sound);
+ delete sound;
+}
+
+AUD_API AUD_Sound* AUD_Sound_copy(AUD_Sound* sound)
+{
+ return new std::shared_ptr<ISound>(*sound);
+}
+
+AUD_API AUD_Sound* AUD_Sound_list(int random)
+{
+ try
+ {
+ return new AUD_Sound(new SoundList(random));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+AUD_API int AUD_SoundList_addSound(AUD_Sound* list, AUD_Sound* sound)
+{
+ assert(sound);
+ assert(list);
+
+ std::shared_ptr<SoundList> s = std::dynamic_pointer_cast<SoundList>(*list);
+ if(s.get())
+ {
+ s->addSound(*sound);
+ return 1;
+ }
+ else
+ return 0;
+
+}
+
+AUD_API AUD_Sound* AUD_Sound_mutable(AUD_Sound* sound)
+{
+ assert(sound);
+
+ try
+ {
+ return new AUD_Sound(new MutableSound(*sound));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+#ifdef WITH_CONVOLUTION
+
+AUD_API AUD_Sound* AUD_Sound_Convolver(AUD_Sound* sound, AUD_ImpulseResponse* filter, AUD_ThreadPool* threadPool)
+{
+ assert(sound);
+ assert(filter);
+ assert(threadPool);
+
+ try
+ {
+ return new AUD_Sound(new ConvolverSound(*sound, *filter, *threadPool));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+AUD_API AUD_Sound* AUD_Sound_Binaural(AUD_Sound* sound, AUD_HRTF* hrtfs, AUD_Source* source, AUD_ThreadPool* threadPool)
+{
+ assert(sound);
+ assert(hrtfs);
+ assert(source);
+ assert(threadPool);
+
+ try
+ {
+ return new AUD_Sound(new BinauralSound(*sound, *hrtfs, *source, *threadPool));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+#endif
diff --git a/extern/audaspace/bindings/C/AUD_Sound.h b/extern/audaspace/bindings/C/AUD_Sound.h
new file mode 100644
index 00000000000..b18e3c3a8eb
--- /dev/null
+++ b/extern/audaspace/bindings/C/AUD_Sound.h
@@ -0,0 +1,370 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+#include "AUD_Types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Retrieves the sample specification of the sound.
+ * \param sound The sound to retrieve from.
+ * \return The sample specification of the sound.
+ * \note This function creates a reader from the sound and deletes it again.
+ */
+extern AUD_API AUD_Specs AUD_Sound_getSpecs(AUD_Sound* sound);
+
+/**
+ * Retrieves the approximate length of the sound.
+ * \param sound The sound to retrieve from.
+ * \return The length of the sound in samples.
+ * \note This function creates a reader from the sound and deletes it again.
+ */
+extern AUD_API int AUD_getLength(AUD_Sound* sound);
+
+/**
+ * Reads a sound's samples into memory.
+ * \param sound The sound to read.
+ * \param length Pointer to store the length of memory read.
+ * \param specs Pointer to store the data's sample specification.
+ * \return A pointer to the sample data.
+ * \warning The data has to be freed with AUD_Sound_freeData.
+ */
+extern AUD_API sample_t* AUD_Sound_data(AUD_Sound* sound, int* length, AUD_Specs* specs);
+
+/**
+ * Frees a buffer previously allocated with AUD_Sound_data.
+ * \param data The buffer to be freed.
+ */
+extern AUD_API void AUD_Sound_freeData(sample_t* data);
+
+/**
+ * Writes the sound to a file.
+ * \param sound The sound to write.
+ * \param filename The path to write to..
+ * \param rate The sample rate to write with.
+ * \param channels The number of channels to write with.
+ * \param format The sample format to write with.
+ * \param container The container format for the file.
+ * \param codec The codec to use in the file.
+ * \param bitrate The bitrate to write with.
+ * \param buffersize The size of the writing buffer.
+ * \return A nullptr or an error message in case of error.
+ * \note Most parameters can be set to zero for default values.
+ */
+extern AUD_API const char* AUD_Sound_write(AUD_Sound* sound, const char* filename, AUD_SampleRate rate, AUD_Channels channels, AUD_SampleFormat format, AUD_Container container, AUD_Codec codec, int bitrate, int buffersize);
+
+/**
+ * Creates a sound from a data buffer.
+ * \param data The data as interleaved samples.
+ * \param length The data's length in samples.
+ * \param specs The data's sample specification.
+ * \return A handle of the sound.
+ * \note The data gets copied to an internal memory buffer.
+ * The pointer does not need to stay valid for the lifetime of the object.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_buffer(sample_t* data, int length, AUD_Specs specs);
+
+/**
+ * Loads a sound file from a memory buffer.
+ * \param buffer The buffer which contains the sound file.
+ * \param size The size of the buffer.
+ * \return A handle of the sound file.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_bufferFile(unsigned char* buffer, int size);
+
+/**
+ * Caches a sound into a memory buffer.
+ * \param sound The sound to cache.
+ * \return A handle of the cached sound.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_cache(AUD_Sound* sound);
+
+/**
+ * Loads a sound file.
+ * \param filename The filename of the sound file.
+ * \return A handle of the sound file.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_file(const char* filename);
+
+/**
+ * Creates a sawtooth sound.
+ * \param frequency The frequency of the generated sawtooth sound.
+ * \param rate The sample rate of the sawtooth sound.
+ * \return A handle of the sound.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_sawtooth(float frequency, AUD_SampleRate rate);
+
+/**
+ * Creates a quiet sound.
+ * \return A handle of the sound.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_silence();
+
+/**
+ * Creates a sine sound.
+ * \param frequency The frequency of the generated sine sound.
+ * \param rate The sample rate of the sine sound.
+ * \return A handle of the sound.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_sine(float frequency, AUD_SampleRate rate);
+
+/**
+ * Creates a square sound.
+ * \param frequency The frequency of the generated square sound.
+ * \param rate The sample rate of the square sound.
+ * \return A handle of the sound.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_square(float frequency, AUD_SampleRate rate);
+
+/**
+ * Creates a triangle sound.
+ * \param frequency The frequency of the generated triangle sound.
+ * \param rate The sample rate of the triangle sound.
+ * \return A handle of the sound.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_triangle(float frequency, AUD_SampleRate rate);
+
+/**
+ * Accumulates a sound by summing over positive input differences thus generating a monotonic sigal.
+ * If additivity is set to true negative input differences get added too, but positive ones with a factor of two.
+ * Note that with additivity the signal is not monotonic anymore.
+ * \param sound The sound to accumulate.
+ * \param additive Whether the accumulation should be additive or not.
+ * \return A handle of the accumulated sound.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_accumulate(AUD_Sound* sound, int additive);
+
+/**
+ * Attack-Decay-Sustain-Release envelopes the volume of a sound.
+ * Note: there is currently no way to trigger the release with this API.
+ * \param sound The sound to filter.
+ * \param attack The attack time in seconds.
+ * \param decay The decay time in seconds.
+ * \param sustain The sustain level.
+ * \param release The release time in seconds.
+ * \return A handle of the filtered sound.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_ADSR(AUD_Sound* sound, float attack, float decay, float sustain, float release);
+
+/**
+ * Delays a sound.
+ * \param sound The sound to dealy.
+ * \param delay The delay in seconds.
+ * \return A handle of the delayed sound.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_delay(AUD_Sound* sound, float delay);
+
+/**
+ * Envelopes a sound.
+ * \param sound The sound to envelope.
+ * \param attack The attack factor.
+ * \param release The release factor.
+ * \param threshold The general threshold value.
+ * \param arthreshold The attack/release threshold value.
+ * \return A handle of the enveloped sound.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_envelope(AUD_Sound* sound, float attack, float release, float threshold, float arthreshold);
+
+/**
+ * Fade in a sound.
+ * \param sound The sound to be fade in.
+ * \param start The time when the fading should start in seconds.
+ * \param length The duration of the fade in seconds.
+ * \return A handle of the faded sound.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_fadein(AUD_Sound* sound, float start, float length);
+
+/**
+ * Fade out a sound.
+ * \param sound The sound to be fade out.
+ * \param start The time when the fading should start in seconds.
+ * \param length The duration of the fade in seconds.
+ * \return A handle of the faded sound.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_fadeout(AUD_Sound* sound, float start, float length);
+
+/**
+ * Filter a sound.
+ * \param sound The sound to be filtered.
+ * \param b The nominator filter coefficients, may be NULL.
+ * \param b_length The length of the b array.
+ * \param a The denominator filter coefficients, may be NULL.
+ * \param a_length The length of the a array.
+ * \return A handle of the filtered sound.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_filter(AUD_Sound* sound, float* b, int b_length, float* a, int a_length);
+
+/**
+ * Highpass filters a sound.
+ * \param sound The sound to filter.
+ * \param frequency The filter cut-off frequency.
+ * \param Q The filter quality. If usunsure which value to use, pass 1.0f.
+ * \return A handle of the filtered sound.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_highpass(AUD_Sound* sound, float frequency, float Q);
+
+/**
+ * Limits a sound.
+ * \param sound The sound to limit.
+ * \param start The start time in seconds.
+ * \param end The stop time in seconds.
+ * \return A handle of the limited sound.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_limit(AUD_Sound* sound, float start, float end);
+
+/**
+ * Loops a sound.
+ * \param sound The sound to loop.
+ * \param count How often the sound should be looped. Negative values mean endlessly.
+ * \return A handle of the looped sound.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_loop(AUD_Sound* sound, int count);
+
+/**
+ * Lowpass filters a sound.
+ * \param sound The sound to filter.
+ * \param frequency The filter cut-off frequency.
+ * \param Q The filter quality. If usunsure which value to use, pass 1.0f.
+ * \return A handle of the filtered sound.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_lowpass(AUD_Sound* sound, float frequency, float Q);
+
+/**
+ * Changes the pitch of a sound.
+ * \param sound The sound to change.
+ * \param factor The factor to change the pitch with.
+ * \return A handle of the pitched sound.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_pitch(AUD_Sound* sound, float factor);
+
+/**
+ * Rechannels the sound.
+ * \param sound The sound to rechannel.
+ * \param channels The new channel configuration.
+ * \return The rechanneled sound.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_rechannel(AUD_Sound* sound, AUD_Channels channels);
+
+/**
+ * Resamples the sound.
+ * \param sound The sound to resample.
+ * \param rate The new sample rate.
+ * \param high_quality When true use a higher quality but slower resampler.
+ * \return The resampled sound.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_resample(AUD_Sound* sound, AUD_SampleRate rate, bool high_quality);
+
+/**
+ * Reverses a sound. Make sure the sound source can be reversed.
+ * \param sound The sound to reverse.
+ * \return A handle of the reversed sound.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_reverse(AUD_Sound* sound);
+
+/**
+ * Sums the samples of a sound.
+ * \param sound The sound to sum.
+ * \return A handle of the summed sound.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_sum(AUD_Sound* sound);
+
+/**
+ * Turns a sound into a square wave by thresholding.
+ * \param sound The sound to threshold.
+ * \param threshold Threshold value over which an amplitude counts non-zero.
+ * \return A handle of the thresholded sound.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_threshold(AUD_Sound* sound, float threshold);
+
+/**
+ * Changes the volume of a sound.
+ * \param sound The sound to change.
+ * \param volume The new volume of the sound. Should be in the range 0 to 1. Use higher values with caution.
+ * \return A handle of the amplified sound.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_volume(AUD_Sound* sound, float volume);
+
+/**
+ * Joins two sound, which means playing them one after the other.
+ * \param first The first sound.
+ * \param second The second sound.
+ * \return A handle of the joined sound.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_join(AUD_Sound* first, AUD_Sound* second);
+
+/**
+ * Mixes two sound, which means superposing the sound samples.
+ * \param first The first sound.
+ * \param second The second sound.
+ * \return A handle of the mixed sound.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_mix(AUD_Sound* first, AUD_Sound* second);
+
+/**
+ * Ping pongs a sound.
+ * \param sound The sound to ping pong.
+ * \return A handle of the ping pong sound.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_pingpong(AUD_Sound* sound);
+
+/**
+ * Unloads a sound of any type.
+ * \param sound The handle of the sound.
+ */
+extern AUD_API void AUD_Sound_free(AUD_Sound* sound);
+
+/**
+ * Copies a sound.
+ * \param sound Sound to copy.
+ * \return Copied sound.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_copy(AUD_Sound* sound);
+
+/**
+ * Creates an empty sound list that can contain several sounds.
+ * \param random A flag that indicates how the list will be played: Randomly or sequentially.
+ * if 0 the playback will be sequential, if not 0 the playback will be random.
+ * \return A handle of the sound list.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_list(int random);
+
+/**
+* Adds a new sound to a sound list.
+ * \param list The sound list in which the sound will be added.
+ * \param sound The sound that will be added to the list.
+ * \return 0 if the sound couldn't be added (the list parameter isn't a sound list).
+*/
+extern AUD_API int AUD_SoundList_addSound(AUD_Sound* list, AUD_Sound* sound);
+
+/**
+ * Creates a sound that will be restarted when sought backwards. If the original sound is a sound list, the playing sound can change.
+ * \param sound The handle of the sound.
+ * \return A handle of the mutable sound.
+*/
+extern AUD_API AUD_Sound* AUD_Sound_mutable(AUD_Sound* sound);
+
+#ifdef WITH_CONVOLUTION
+ extern AUD_API AUD_Sound* AUD_Sound_Convolver(AUD_Sound* sound, AUD_ImpulseResponse* filter, AUD_ThreadPool* threadPool);
+ extern AUD_API AUD_Sound* AUD_Sound_Binaural(AUD_Sound* sound, AUD_HRTF* hrtfs, AUD_Source* source, AUD_ThreadPool* threadPool);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/extern/audaspace/bindings/C/AUD_Source.cpp b/extern/audaspace/bindings/C/AUD_Source.cpp
new file mode 100644
index 00000000000..c4bf6fea6a1
--- /dev/null
+++ b/extern/audaspace/bindings/C/AUD_Source.cpp
@@ -0,0 +1,84 @@
+/*******************************************************************************
+* Copyright 2009-2015 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "Exception.h"
+
+#include <cassert>
+
+using namespace aud;
+
+#define AUD_CAPI_IMPLEMENTATION
+#include "AUD_Source.h"
+
+extern AUD_API AUD_Source* AUD_Source_create(float azimuth, float elevation, float distance)
+{
+ try
+ {
+ return new AUD_Source(new Source(azimuth, elevation, distance));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+extern AUD_API void AUD_Source_free(AUD_Source* source)
+{
+ assert(source);
+ delete source;
+}
+
+extern AUD_API float AUD_Source_getAzimuth(AUD_Source* source)
+{
+ assert(source);
+
+ return (*source)->getAzimuth();
+}
+
+extern AUD_API float AUD_Source_getElevation(AUD_Source* source)
+{
+ assert(source);
+
+ return (*source)->getElevation();
+}
+
+extern AUD_API float AUD_Source_getDistance(AUD_Source* source)
+{
+ assert(source);
+
+ return (*source)->getDistance();
+}
+
+extern AUD_API void AUD_Source_setAzimuth(AUD_Source* source, float azimuth)
+{
+ assert(source);
+
+ (*source)->setAzimuth(azimuth);
+}
+
+extern AUD_API void AUD_Source_setElevation(AUD_Source* source, float elevation)
+{
+ assert(source);
+
+ (*source)->setElevation(elevation);
+}
+
+extern AUD_API void AUD_Source_setDistance(AUD_Source* source, float distance)
+{
+ assert(source);
+
+ (*source)->setDistance(distance);
+} \ No newline at end of file
diff --git a/extern/audaspace/bindings/C/AUD_Source.h b/extern/audaspace/bindings/C/AUD_Source.h
new file mode 100644
index 00000000000..6ff045ec848
--- /dev/null
+++ b/extern/audaspace/bindings/C/AUD_Source.h
@@ -0,0 +1,84 @@
+/*******************************************************************************
+* Copyright 2009-2015 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+#include "AUD_Types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+* Creates a new Source object.
+* \param azimuth The azimuth angle.
+* \param elevation The elevation angle.
+* \param elevation The distance value. [0,1]
+* \return The new Source object.
+*/
+extern AUD_API AUD_Source* AUD_Source_create(float azimuth, float elevation, float distance);
+
+/**
+* Deletes a Source object.
+* \param source The Source object to be deleted.
+*/
+extern AUD_API void AUD_Source_free(AUD_Source* source);
+
+/**
+* Retrieves the azimuth angle of a Source object.
+* \param source The Source object.
+* \return The azimuth angle.
+*/
+extern AUD_API float AUD_Source_getAzimuth(AUD_Source* source);
+
+/**
+* Retrieves the elevation angle oa a Source object.
+* \param source The Source object.
+* \return The elevation angle.
+*/
+extern AUD_API float AUD_Source_getElevation(AUD_Source* source);
+
+/**
+* Retrieves the distance of a Source object. [0,1]
+* \param source The Source object.
+* \return The distance.
+*/
+extern AUD_API float AUD_Source_getDistance(AUD_Source* distance);
+
+/**
+* Changes the azimuth angle of a Source object.
+* \param source The Source object.
+* \param azimuth The azimuth angle.
+*/
+extern AUD_API void AUD_Source_setAzimuth(AUD_Source* source, float azimuth);
+
+/**
+* Changes the elevation angle of a Source object.
+* \param source The Source object.
+* \param elevation The elevation angle.
+*/
+extern AUD_API void AUD_Source_setElevation(AUD_Source* source, float elevation);
+
+/**
+* Changes the distance of a Source object. [0,1]
+* \param source The Source object.
+* \param distance The distance.
+*/
+extern AUD_API void AUD_Source_setDistance(AUD_Source* source, float distance);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/extern/audaspace/bindings/C/AUD_Special.cpp b/extern/audaspace/bindings/C/AUD_Special.cpp
new file mode 100644
index 00000000000..f8f46651231
--- /dev/null
+++ b/extern/audaspace/bindings/C/AUD_Special.cpp
@@ -0,0 +1,420 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "Exception.h"
+#include "IReader.h"
+#include "file/File.h"
+#include "respec/ChannelMapper.h"
+#include "fx/Lowpass.h"
+#include "fx/Highpass.h"
+#include "fx/Envelope.h"
+#include "respec/LinearResample.h"
+#include "fx/Threshold.h"
+#include "fx/Accumulator.h"
+#include "fx/Sum.h"
+#include "generator/Silence.h"
+#include "fx/Limiter.h"
+#include "devices/DeviceManager.h"
+#include "sequence/Sequence.h"
+#include "file/FileWriter.h"
+#include "devices/ReadDevice.h"
+#include "plugin/PluginManager.h"
+#include "devices/DeviceManager.h"
+#include "devices/IDeviceFactory.h"
+#include "devices/NULLDevice.h"
+
+#include <cassert>
+#include <cstring>
+#include <cmath>
+#include <sstream>
+
+using namespace aud;
+
+#define AUD_CAPI_IMPLEMENTATION
+#include "AUD_Special.h"
+
+static inline AUD_Specs convSpecToC(aud::Specs specs)
+{
+ AUD_Specs s;
+ s.channels = static_cast<AUD_Channels>(specs.channels);
+ s.rate = static_cast<AUD_SampleRate>(specs.rate);
+ return s;
+}
+
+static inline aud::Specs convCToSpec(AUD_Specs specs)
+{
+ aud::Specs s;
+ s.channels = static_cast<Channels>(specs.channels);
+ s.rate = static_cast<SampleRate>(specs.rate);
+ return s;
+}
+
+static inline AUD_DeviceSpecs convDSpecToC(aud::DeviceSpecs specs)
+{
+ AUD_DeviceSpecs s;
+ s.specs = convSpecToC(specs.specs);
+ s.format = static_cast<AUD_SampleFormat>(specs.format);
+ return s;
+}
+
+static inline aud::DeviceSpecs convCToDSpec(AUD_DeviceSpecs specs)
+{
+ aud::DeviceSpecs s;
+ s.specs = convCToSpec(specs.specs);
+ s.format = static_cast<SampleFormat>(specs.format);
+ return s;
+}
+
+AUD_API AUD_SoundInfo AUD_getInfo(AUD_Sound* sound)
+{
+ assert(sound);
+
+ AUD_SoundInfo info;
+ info.specs.channels = AUD_CHANNELS_INVALID;
+ info.specs.rate = AUD_RATE_INVALID;
+ info.length = 0.0f;
+
+ try
+ {
+ std::shared_ptr<IReader> reader = (*sound)->createReader();
+
+ if(reader.get())
+ {
+ info.specs = convSpecToC(reader->getSpecs());
+ info.length = reader->getLength() / (float) info.specs.rate;
+ }
+ }
+ catch(Exception&)
+ {
+ }
+
+ return info;
+}
+
+AUD_API float* AUD_readSoundBuffer(const char* filename, float low, float high,
+ float attack, float release, float threshold,
+ int accumulate, int additive, int square,
+ float sthreshold, double samplerate, int* length)
+{
+ Buffer buffer;
+ DeviceSpecs specs;
+ specs.channels = CHANNELS_MONO;
+ specs.rate = (SampleRate)samplerate;
+ std::shared_ptr<ISound> sound;
+
+ std::shared_ptr<ISound> file = std::shared_ptr<ISound>(new File(filename));
+
+ int position = 0;
+
+ try
+ {
+ std::shared_ptr<IReader> reader = file->createReader();
+
+ SampleRate rate = reader->getSpecs().rate;
+
+ sound = std::shared_ptr<ISound>(new ChannelMapper(file, specs));
+
+ if(high < rate)
+ sound = std::shared_ptr<ISound>(new Lowpass(sound, high));
+ if(low > 0)
+ sound = std::shared_ptr<ISound>(new Highpass(sound, low));
+
+ sound = std::shared_ptr<ISound>(new Envelope(sound, attack, release, threshold, 0.1f));
+ sound = std::shared_ptr<ISound>(new LinearResample(sound, specs));
+
+ if(square)
+ sound = std::shared_ptr<ISound>(new Threshold(sound, sthreshold));
+
+ if(accumulate)
+ sound = std::shared_ptr<ISound>(new Accumulator(sound, additive));
+ else if(additive)
+ sound = std::shared_ptr<ISound>(new Sum(sound));
+
+ reader = sound->createReader();
+
+ if(!reader.get())
+ return nullptr;
+
+ int len;
+ bool eos;
+ do
+ {
+ len = samplerate;
+ buffer.resize((position + len) * sizeof(float), true);
+ reader->read(len, eos, buffer.getBuffer() + position);
+ position += len;
+ } while(!eos);
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+
+ float * result = (float *)malloc(position * sizeof(float));
+ std::memcpy(result, buffer.getBuffer(), position * sizeof(float));
+ *length = position;
+ return result;
+}
+
+static void pauseSound(AUD_Handle* handle)
+{
+ assert(handle);
+ (*handle)->pause();
+}
+
+AUD_API AUD_Handle* AUD_pauseAfter(AUD_Handle* handle, float seconds)
+{
+ std::shared_ptr<ISound> silence = std::shared_ptr<ISound>(new Silence);
+ std::shared_ptr<ISound> limiter = std::shared_ptr<ISound>(new Limiter(silence, 0, seconds));
+
+ auto device = DeviceManager::getDevice();
+
+ std::lock_guard<ILockable> lock(*device);
+
+ try
+ {
+ AUD_Handle handle2 = device->play(limiter);
+ if(handle2.get())
+ {
+ handle2->setStopCallback((stopCallback)pauseSound, handle);
+ return new AUD_Handle(handle2);
+ }
+ }
+ catch(Exception&)
+ {
+ }
+
+ return nullptr;
+}
+
+AUD_API int AUD_readSound(AUD_Sound* sound, float* buffer, int length, int samples_per_second, short* interrupt)
+{
+ DeviceSpecs specs;
+ float* buf;
+ Buffer aBuffer;
+
+ specs.rate = RATE_INVALID;
+ specs.channels = CHANNELS_MONO;
+ specs.format = FORMAT_INVALID;
+
+ std::shared_ptr<IReader> reader = ChannelMapper(*sound, specs).createReader();
+
+ specs.specs = reader->getSpecs();
+ int len;
+ float samplejump = specs.rate / samples_per_second;
+ float min, max, power, overallmax;
+ bool eos;
+
+ overallmax = 0;
+
+ for(int i = 0; i < length; i++)
+ {
+ len = floor(samplejump * (i+1)) - floor(samplejump * i);
+
+ if(*interrupt)
+ return 0;
+
+ aBuffer.assureSize(len * AUD_SAMPLE_SIZE(specs));
+ buf = aBuffer.getBuffer();
+
+ reader->read(len, eos, buf);
+
+ max = min = *buf;
+ power = *buf * *buf;
+ for(int j = 1; j < len; j++)
+ {
+ if(buf[j] < min)
+ min = buf[j];
+ if(buf[j] > max)
+ max = buf[j];
+ power += buf[j] * buf[j];
+ }
+
+ buffer[i * 3] = min;
+ buffer[i * 3 + 1] = max;
+ buffer[i * 3 + 2] = sqrt(power) / len;
+
+ if(overallmax < max)
+ overallmax = max;
+ if(overallmax < -min)
+ overallmax = -min;
+
+ if(eos)
+ {
+ length = i;
+ break;
+ }
+ }
+
+ if(overallmax > 1.0f)
+ {
+ for(int i = 0; i < length * 3; i++)
+ {
+ buffer[i] /= overallmax;
+ }
+ }
+
+ return length;
+}
+
+AUD_API const char* AUD_mixdown(AUD_Sound* sound, unsigned int start, unsigned int length, unsigned int buffersize, const char* filename, AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate)
+{
+ try
+ {
+ Sequence* f = dynamic_cast<Sequence *>(sound->get());
+
+ f->setSpecs(convCToSpec(specs.specs));
+ std::shared_ptr<IReader> reader = f->createQualityReader();
+ reader->seek(start);
+ std::shared_ptr<IWriter> writer = FileWriter::createWriter(filename, convCToDSpec(specs), static_cast<Container>(format), static_cast<Codec>(codec), bitrate);
+ FileWriter::writeReader(reader, writer, length, buffersize);
+
+ return nullptr;
+ }
+ catch(Exception& e)
+ {
+ return e.getMessage().c_str();
+ }
+}
+
+AUD_API const char* AUD_mixdown_per_channel(AUD_Sound* sound, unsigned int start, unsigned int length, unsigned int buffersize, const char* filename, AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate)
+{
+ try
+ {
+ Sequence* f = dynamic_cast<Sequence *>(sound->get());
+
+ f->setSpecs(convCToSpec(specs.specs));
+
+ std::vector<std::shared_ptr<IWriter> > writers;
+
+ int channels = specs.channels;
+ specs.channels = AUD_CHANNELS_MONO;
+
+ for(int i = 0; i < channels; i++)
+ {
+ std::stringstream stream;
+ std::string fn = filename;
+ size_t index = fn.find_last_of('.');
+ size_t index_slash = fn.find_last_of('/');
+ size_t index_backslash = fn.find_last_of('\\');
+
+ if((index == std::string::npos) ||
+ ((index < index_slash) && (index_slash != std::string::npos)) ||
+ ((index < index_backslash) && (index_backslash != std::string::npos)))
+ {
+ stream << filename << "_" << (i + 1);
+ }
+ else
+ {
+ stream << fn.substr(0, index) << "_" << (i + 1) << fn.substr(index);
+ }
+ writers.push_back(FileWriter::createWriter(stream.str(), convCToDSpec(specs), static_cast<Container>(format), static_cast<Codec>(codec), bitrate));
+ }
+
+ std::shared_ptr<IReader> reader = f->createQualityReader();
+ reader->seek(start);
+ FileWriter::writeReader(reader, writers, length, buffersize);
+
+ return nullptr;
+ }
+ catch(Exception& e)
+ {
+ return e.getMessage().c_str();
+ }
+}
+
+AUD_API AUD_Device* AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound* sequencer, float volume, float start)
+{
+ try
+ {
+ ReadDevice* device = new ReadDevice(convCToDSpec(specs));
+ device->setQuality(true);
+ device->setVolume(volume);
+
+ Sequence* f = dynamic_cast<Sequence*>(sequencer->get());
+
+ f->setSpecs(convCToSpec(specs.specs));
+
+ AUD_Handle handle = device->play(f->createQualityReader());
+ if(handle.get())
+ {
+ handle->seek(start);
+ }
+
+ return new AUD_Device(device);
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+AUD_API void AUD_initOnce()
+{
+ PluginManager::loadPlugins();
+ NULLDevice::registerPlugin();
+}
+
+AUD_API void AUD_exitOnce()
+{
+}
+
+AUD_API AUD_Device* AUD_init(const char* device, AUD_DeviceSpecs specs, int buffersize, const char* name)
+{
+ try
+ {
+ std::shared_ptr<IDeviceFactory> factory = DeviceManager::getDeviceFactory(device);
+
+ if(factory)
+ {
+ factory->setName(name);
+ factory->setBufferSize(buffersize);
+ factory->setSpecs(convCToDSpec(specs));
+ auto device = factory->openDevice();
+ DeviceManager::setDevice(device);
+
+ return new AUD_Device(device);
+ }
+ }
+ catch(Exception&)
+ {
+ }
+ return nullptr;
+}
+
+AUD_API void AUD_exit(AUD_Device* device)
+{
+ delete device;
+ DeviceManager::releaseDevice();
+}
+
+
+AUD_API char** AUD_getDeviceNames()
+{
+ std::vector<std::string> v_names = DeviceManager::getAvailableDeviceNames();
+ char** names = (char**) malloc(sizeof(char*) * (v_names.size() + 1));
+
+ for(int i = 0; i < v_names.size(); i++)
+ {
+ std::string name = v_names[i];
+ names[i] = (char*) malloc(sizeof(char) * (name.length() + 1));
+ strcpy(names[i], name.c_str());
+ }
+
+ names[v_names.size()] = nullptr;
+
+ return names;
+}
diff --git a/extern/audaspace/bindings/C/AUD_Special.h b/extern/audaspace/bindings/C/AUD_Special.h
new file mode 100644
index 00000000000..ab79ae915a2
--- /dev/null
+++ b/extern/audaspace/bindings/C/AUD_Special.h
@@ -0,0 +1,138 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+#include "AUD_Types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Returns information about a sound.
+ * \param sound The sound to get the info about.
+ * \return The AUD_SoundInfo structure with filled in data.
+ */
+extern AUD_API AUD_SoundInfo AUD_getInfo(AUD_Sound* sound);
+
+/**
+ * Reads a sound file into a newly created float buffer.
+ * The sound is therefore bandpassed, rectified and resampled.
+ */
+extern AUD_API float* AUD_readSoundBuffer(const char* filename, float low, float high,
+ float attack, float release, float threshold,
+ int accumulate, int additive, int square,
+ float sthreshold, double samplerate,
+ int* length);
+
+/**
+ * Pauses a playing sound after a specific amount of time.
+ * \param handle The handle to the sound.
+ * \param seconds The time in seconds.
+ * \return The silence handle.
+ */
+extern AUD_API AUD_Handle* AUD_pauseAfter(AUD_Handle* handle, float seconds);
+
+/**
+ * Reads a sound into a buffer for drawing at a specific sampling rate.
+ * \param sound The sound to read.
+ * \param buffer The buffer to write to. Must have a size of 3*4*length.
+ * \param length How many samples to read from the sound.
+ * \param samples_per_second How many samples to read per second of the sound.
+ * \return How many samples really have been read. Always <= length.
+ */
+extern AUD_API int AUD_readSound(AUD_Sound* sound, float* buffer, int length, int samples_per_second, short* interrupt);
+
+/**
+ * Mixes a sound down into a file.
+ * \param sound The sound scene to mix down.
+ * \param start The start frame.
+ * \param length The count of frames to write.
+ * \param buffersize How many samples should be written at once.
+ * \param filename The file to write to.
+ * \param specs The file's audio specification.
+ * \param format The file's container format.
+ * \param codec The codec used for encoding the audio data.
+ * \param bitrate The bitrate for encoding.
+ * \return An error message or NULL in case of success.
+ */
+extern AUD_API const char* AUD_mixdown(AUD_Sound* sound, unsigned int start, unsigned int length,
+ unsigned int buffersize, const char* filename,
+ AUD_DeviceSpecs specs, AUD_Container format,
+ AUD_Codec codec, unsigned int bitrate);
+
+/**
+ * Mixes a sound down into multiple files.
+ * \param sound The sound scene to mix down.
+ * \param start The start frame.
+ * \param length The count of frames to write.
+ * \param buffersize How many samples should be written at once.
+ * \param filename The file to write to, the channel number and an underscore are added at the beginning.
+ * \param specs The file's audio specification.
+ * \param format The file's container format.
+ * \param codec The codec used for encoding the audio data.
+ * \param bitrate The bitrate for encoding.
+ * \return An error message or NULL in case of success.
+ */
+extern AUD_API const char* AUD_mixdown_per_channel(AUD_Sound* sound, unsigned int start, unsigned int length,
+ unsigned int buffersize, const char* filename,
+ AUD_DeviceSpecs specs, AUD_Container format,
+ AUD_Codec codec, unsigned int bitrate);
+
+/**
+ * Opens a read device and prepares it for mixdown of the sound scene.
+ * \param specs Output audio specifications.
+ * \param sequencer The sound scene to mix down.
+ * \param volume The overall mixdown volume.
+ * \param start The start time of the mixdown in the sound scene.
+ * \return The read device for the mixdown.
+ */
+extern AUD_API AUD_Device* AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound* sequencer, float volume, float start);
+
+/**
+ * Initializes audio routines (FFMPEG/JACK if it is enabled).
+ */
+extern AUD_API void AUD_initOnce();
+
+/**
+ * Unitinitializes an audio routines.
+ */
+extern AUD_API void AUD_exitOnce();
+
+/**
+ * Initializes an audio device.
+ * \param device The device type that should be used.
+ * \param specs The audio specification to be used.
+ * \param buffersize The buffersize for the device.
+ * \return Whether the device has been initialized.
+ */
+extern AUD_API AUD_Device* AUD_init(const char* device, AUD_DeviceSpecs specs, int buffersize, const char* name);
+
+/**
+ * Unitinitializes an audio device.
+ * \param device The device to free.
+ */
+extern AUD_API void AUD_exit(AUD_Device* device);
+
+/**
+ * Retrieves available devices. Note that all memory returned has to be freed!
+ */
+extern AUD_API char** AUD_getDeviceNames();
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/extern/audaspace/bindings/C/AUD_ThreadPool.cpp b/extern/audaspace/bindings/C/AUD_ThreadPool.cpp
new file mode 100644
index 00000000000..f22a904838b
--- /dev/null
+++ b/extern/audaspace/bindings/C/AUD_ThreadPool.cpp
@@ -0,0 +1,42 @@
+/*******************************************************************************
+* Copyright 2009-2015 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "Exception.h"
+
+#include <cassert>
+
+using namespace aud;
+
+#define AUD_CAPI_IMPLEMENTATION
+#include "AUD_ThreadPool.h"
+
+AUD_API AUD_ThreadPool* AUD_ThreadPool_create(int nThreads)
+{
+ try
+ {
+ return new AUD_ThreadPool(new ThreadPool(nThreads));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
+AUD_API void AUD_ThreadPool_free(AUD_ThreadPool* pool)
+{
+ assert(pool);
+ delete pool;
+} \ No newline at end of file
diff --git a/extern/audaspace/bindings/C/AUD_ThreadPool.h b/extern/audaspace/bindings/C/AUD_ThreadPool.h
new file mode 100644
index 00000000000..c1b2204a80a
--- /dev/null
+++ b/extern/audaspace/bindings/C/AUD_ThreadPool.h
@@ -0,0 +1,40 @@
+/*******************************************************************************
+* Copyright 2009-2015 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+#include "AUD_Types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+* Creates a new ThreadPool object.
+* \param nThreads The number of threads of the pool.
+* \return The new ThreadPool object.
+*/
+extern AUD_API AUD_ThreadPool* AUD_ThreadPool_create(int nThreads);
+
+/**
+* Deletes a ThreadPool object.
+* \param threadPool The ThreadPool object to be deleted.
+*/
+extern AUD_API void AUD_ThreadPool_free(AUD_ThreadPool* threadPool);
+
+#ifdef __cplusplus
+}
+#endif \ No newline at end of file
diff --git a/extern/audaspace/bindings/C/AUD_Types.h b/extern/audaspace/bindings/C/AUD_Types.h
new file mode 100644
index 00000000000..75e4ffae18c
--- /dev/null
+++ b/extern/audaspace/bindings/C/AUD_Types.h
@@ -0,0 +1,179 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+#include "Audaspace.h"
+
+#ifdef __cplusplus
+using namespace aud;
+#endif
+
+#ifdef AUD_CAPI_IMPLEMENTATION
+#include "ISound.h"
+#include "devices/IHandle.h"
+#include "devices/IDevice.h"
+#include "sequence/SequenceEntry.h"
+#include "fx/PlaybackManager.h"
+#include "fx/DynamicMusic.h"
+#include "fx/Source.h"
+#include "util/ThreadPool.h"
+#ifdef WITH_CONVOLUTION
+#include "fx/ImpulseResponse.h"
+#include "fx/HRTF.h"
+#endif
+
+typedef std::shared_ptr<aud::ISound> AUD_Sound;
+typedef std::shared_ptr<aud::IHandle> AUD_Handle;
+typedef std::shared_ptr<aud::IDevice> AUD_Device;
+typedef std::shared_ptr<aud::SequenceEntry> AUD_SequenceEntry;
+typedef std::shared_ptr<aud::PlaybackManager> AUD_PlaybackManager;
+typedef std::shared_ptr<aud::DynamicMusic> AUD_DynamicMusic;
+typedef std::shared_ptr<aud::ThreadPool> AUD_ThreadPool;
+typedef std::shared_ptr<aud::Source> AUD_Source;
+#ifdef WITH_CONVOLUTION
+typedef std::shared_ptr<aud::ImpulseResponse> AUD_ImpulseResponse;
+typedef std::shared_ptr<aud::HRTF> AUD_HRTF;
+#endif
+#else
+typedef void AUD_Sound;
+typedef void AUD_Handle;
+typedef void AUD_Device;
+typedef void AUD_SequenceEntry;
+typedef void AUD_PlaybackManager;
+typedef void AUD_DynamicMusic;
+typedef void AUD_ThreadPool;
+typedef void AUD_Source;
+#ifdef WITH_CONVOLUTION
+typedef void AUD_ImpulseResponse;
+typedef void AUD_HRTF;
+#endif
+#endif
+
+/// Container formats for writers.
+typedef enum
+{
+ AUD_CONTAINER_INVALID = 0,
+ AUD_CONTAINER_AC3,
+ AUD_CONTAINER_FLAC,
+ AUD_CONTAINER_MATROSKA,
+ AUD_CONTAINER_MP2,
+ AUD_CONTAINER_MP3,
+ AUD_CONTAINER_OGG,
+ AUD_CONTAINER_WAV
+} AUD_Container;
+
+/// Audio codecs for writers.
+typedef enum
+{
+ AUD_CODEC_INVALID = 0,
+ AUD_CODEC_AAC,
+ AUD_CODEC_AC3,
+ AUD_CODEC_FLAC,
+ AUD_CODEC_MP2,
+ AUD_CODEC_MP3,
+ AUD_CODEC_PCM,
+ AUD_CODEC_VORBIS,
+ AUD_CODEC_OPUS
+} AUD_Codec;
+
+/**
+ * The format of a sample.
+ * The last 4 bit save the byte count of the format.
+ */
+typedef enum
+{
+ AUD_FORMAT_INVALID = 0x00, /// Invalid sample format.
+ AUD_FORMAT_U8 = 0x01, /// 1 byte unsigned byte.
+ AUD_FORMAT_S16 = 0x12, /// 2 byte signed integer.
+ AUD_FORMAT_S24 = 0x13, /// 3 byte signed integer.
+ AUD_FORMAT_S32 = 0x14, /// 4 byte signed integer.
+ AUD_FORMAT_FLOAT32 = 0x24, /// 4 byte float.
+ AUD_FORMAT_FLOAT64 = 0x28 /// 8 byte float.
+} AUD_SampleFormat;
+
+/// The channel count.
+typedef enum
+{
+ AUD_CHANNELS_INVALID = 0, /// Invalid channel count.
+ AUD_CHANNELS_MONO = 1, /// Mono.
+ AUD_CHANNELS_STEREO = 2, /// Stereo.
+ AUD_CHANNELS_STEREO_LFE = 3, /// Stereo with LFE channel.
+ AUD_CHANNELS_SURROUND4 = 4, /// 4 channel surround sound.
+ AUD_CHANNELS_SURROUND5 = 5, /// 5 channel surround sound.
+ AUD_CHANNELS_SURROUND51 = 6, /// 5.1 surround sound.
+ AUD_CHANNELS_SURROUND61 = 7, /// 6.1 surround sound.
+ AUD_CHANNELS_SURROUND71 = 8 /// 7.1 surround sound.
+} AUD_Channels;
+
+/**
+ * The sample rate tells how many samples are played back within one second.
+ * Some exotic formats may use other sample rates than provided here.
+ */
+typedef enum
+{
+ AUD_RATE_INVALID = 0, /// Invalid sample rate.
+ AUD_RATE_8000 = 8000, /// 8000 Hz.
+ AUD_RATE_16000 = 16000, /// 16000 Hz.
+ AUD_RATE_11025 = 11025, /// 11025 Hz.
+ AUD_RATE_22050 = 22050, /// 22050 Hz.
+ AUD_RATE_32000 = 32000, /// 32000 Hz.
+ AUD_RATE_44100 = 44100, /// 44100 Hz.
+ AUD_RATE_48000 = 48000, /// 48000 Hz.
+ AUD_RATE_88200 = 88200, /// 88200 Hz.
+ AUD_RATE_96000 = 96000, /// 96000 Hz.
+ AUD_RATE_192000 = 192000 /// 192000 Hz.
+} AUD_DefaultSampleRate;
+
+/// Sample rate type.
+typedef double AUD_SampleRate;
+
+/// Specification of a sound source.
+typedef struct
+{
+ /// Sample rate in Hz.
+ AUD_SampleRate rate;
+
+ /// Channel count.
+ AUD_Channels channels;
+} AUD_Specs;
+
+/// Specification of a sound device.
+typedef struct
+{
+ /// Sample format.
+ AUD_SampleFormat format;
+
+ union
+ {
+ struct
+ {
+ /// Sample rate in Hz.
+ AUD_SampleRate rate;
+
+ /// Channel count.
+ AUD_Channels channels;
+ };
+ AUD_Specs specs;
+ };
+} AUD_DeviceSpecs;
+
+/// Sound information structure.
+typedef struct
+{
+ AUD_Specs specs;
+ float length;
+} AUD_SoundInfo;
diff --git a/extern/audaspace/bindings/doc/conf.py.in b/extern/audaspace/bindings/doc/conf.py.in
new file mode 100644
index 00000000000..e08efbcf7f6
--- /dev/null
+++ b/extern/audaspace/bindings/doc/conf.py.in
@@ -0,0 +1,261 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+#
+# audaspace documentation build configuration file, created by
+# sphinx-quickstart on Tue Sep 9 01:48:48 2014.
+#
+# This file is execfile()d with the current directory set to its
+# containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys
+import os
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#sys.path.insert(0, os.path.abspath('.'))
+
+# -- General configuration ------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
+# ones.
+extensions = [
+ 'sphinx.ext.autodoc',
+]
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = []
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = 'audaspace'
+copyright = '2009-2015, Jörg Müller'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '@AUDASPACE_VERSION@'
+# The full version, including alpha/beta/rc tags.
+release = '@AUDASPACE_LONG_VERSION@'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = []
+
+# The reST default role (used for this markup: `text`) to use for all
+# documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+# If true, keep warnings as "system message" paragraphs in the built documents.
+#keep_warnings = False
+
+
+# -- Options for HTML output ----------------------------------------------
+
+# The theme to use for HTML and HTML Help pages. See the documentation for
+# a list of builtin themes.
+html_theme = 'alabaster'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further. For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents. If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar. Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = []
+
+# Add any extra paths that contain custom files (such as robots.txt or
+# .htaccess) here, relative to this directory. These files are copied
+# directly to the root of the documentation.
+#html_extra_path = []
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_domain_indices = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+#html_show_copyright = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it. The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = None
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'audaspacedoc'
+
+
+# -- Options for LaTeX output ---------------------------------------------
+
+latex_elements = {
+# The paper size ('letterpaper' or 'a4paper').
+#'papersize': 'letterpaper',
+
+# The font size ('10pt', '11pt' or '12pt').
+#'pointsize': '10pt',
+
+# Additional stuff for the LaTeX preamble.
+#'preamble': '',
+}
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title,
+# author, documentclass [howto, manual, or own class]).
+latex_documents = [
+ ('index', 'audaspace.tex', 'audaspace Documentation',
+ 'Jörg Müller', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# If true, show page references after internal links.
+#latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#latex_show_urls = False
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_domain_indices = True
+
+
+# -- Options for manual page output ---------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+ ('index', 'audaspace', 'audaspace Documentation',
+ ['Jörg Müller'], 1)
+]
+
+# If true, show URL addresses after external links.
+#man_show_urls = False
+
+
+# -- Options for Texinfo output -------------------------------------------
+
+# Grouping the document tree into Texinfo files. List of tuples
+# (source start file, target name, title, author,
+# dir menu entry, description, category)
+texinfo_documents = [
+ ('index', 'audaspace', 'audaspace Documentation',
+ 'Jörg Müller', 'audaspace', 'One line description of project.',
+ 'Miscellaneous'),
+]
+
+# Documents to append as an appendix to all manuals.
+#texinfo_appendices = []
+
+# If false, no module index is generated.
+#texinfo_domain_indices = True
+
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
+#texinfo_show_urls = 'footnote'
+
+# If true, do not generate a @detailmenu in the "Top" node's menu.
+#texinfo_no_detailmenu = False
diff --git a/extern/audaspace/bindings/doc/device.rst b/extern/audaspace/bindings/doc/device.rst
new file mode 100644
index 00000000000..fd6b334022c
--- /dev/null
+++ b/extern/audaspace/bindings/doc/device.rst
@@ -0,0 +1,7 @@
+Device
+======
+
+.. currentmodule:: aud
+.. autoclass:: Device
+ :members:
+
diff --git a/extern/audaspace/bindings/doc/handle.rst b/extern/audaspace/bindings/doc/handle.rst
new file mode 100644
index 00000000000..aceedbca3a6
--- /dev/null
+++ b/extern/audaspace/bindings/doc/handle.rst
@@ -0,0 +1,7 @@
+Handle
+======
+
+.. currentmodule:: aud
+.. autoclass:: Handle
+ :members:
+
diff --git a/extern/audaspace/bindings/doc/index.rst b/extern/audaspace/bindings/doc/index.rst
new file mode 100644
index 00000000000..b8a26822949
--- /dev/null
+++ b/extern/audaspace/bindings/doc/index.rst
@@ -0,0 +1,35 @@
+.. audaspace documentation master file, created by
+ sphinx-quickstart on Tue Sep 9 01:48:48 2014.
+ You can adapt this file completely to your liking, but it should at least
+ contain the root `toctree` directive.
+
+Welcome to audaspace's documentation!
+=====================================
+
+.. automodule:: aud
+
+This documentation is valid for both the Python and C bindings of audaspace. If you are looking for installation instructions check the `C++ API documentation <../index.html>`_. As C is not an object oriented language everything is accessible via functions where the first paramter is always the object. For methods these are named as ``AUD_ClassName_method()`` and properties are accessed via ``AUD_ClassName_property_get/set()``. Python users simply ``import aud`` to access the library.
+
+.. toctree::
+ :maxdepth: 2
+
+ tutorials
+
+Classes:
+
+.. toctree::
+ :maxdepth: 2
+
+ device
+ sound
+ handle
+ sequence
+ sequence_entry
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
+
diff --git a/extern/audaspace/bindings/doc/sequence.rst b/extern/audaspace/bindings/doc/sequence.rst
new file mode 100644
index 00000000000..16fcb00f4dc
--- /dev/null
+++ b/extern/audaspace/bindings/doc/sequence.rst
@@ -0,0 +1,7 @@
+Sequence
+========
+
+.. currentmodule:: aud
+.. autoclass:: Sequence
+ :members:
+
diff --git a/extern/audaspace/bindings/doc/sequence_entry.rst b/extern/audaspace/bindings/doc/sequence_entry.rst
new file mode 100644
index 00000000000..0a3d83388e9
--- /dev/null
+++ b/extern/audaspace/bindings/doc/sequence_entry.rst
@@ -0,0 +1,7 @@
+Sequence Entry
+==============
+
+.. currentmodule:: aud
+.. autoclass:: SequenceEntry
+ :members:
+
diff --git a/extern/audaspace/bindings/doc/sound.rst b/extern/audaspace/bindings/doc/sound.rst
new file mode 100644
index 00000000000..2f14721cf3a
--- /dev/null
+++ b/extern/audaspace/bindings/doc/sound.rst
@@ -0,0 +1,7 @@
+Sound
+=====
+
+.. currentmodule:: aud
+.. autoclass:: Sound
+ :members:
+
diff --git a/extern/audaspace/bindings/doc/tutorials.rst b/extern/audaspace/bindings/doc/tutorials.rst
new file mode 100644
index 00000000000..55f51d9ee2f
--- /dev/null
+++ b/extern/audaspace/bindings/doc/tutorials.rst
@@ -0,0 +1,166 @@
+Tutorials
+=========
+
+Introduction
+------------
+
+The C and Python binding for audaspace were designed with simplicity in mind. This means however that to use the full capabilities of audaspace, there is no way around the C++ library.
+
+Simple Demo
+-----------
+
+The **simple.py** example program contains all the basic building blocks for an application using audaspace. These building blocks are basically the classes :class:`aud.Device`, :class:`aud.Sound` and :class:`aud.Handle`.
+
+We start with importing :mod:`aud` and :mod:`time` as the modules we need for our simple example.
+
+.. code-block:: python
+
+ #!/usr/bin/python
+ import aud, time
+
+The first step now is to open an output device and this can simply be done by allocating a :class:`aud.Device` object.
+
+.. code-block:: python
+
+ device = aud.Device()
+
+To create a sound we can choose to load one from a :func:`aud.Sound.file`, or we use one of our signal generators. We decide to do the latter and create a :func:`aud.Sound.sine` signal with a frequency of 440 Hz.
+
+.. code-block:: python
+
+ sine = aud.Sound.sine(440)
+
+.. note:: At this point nothing is playing back yet, :class:`aud.Sound` objects are just descriptions of sounds.
+
+However instead of a sine wave, we would like to have a square wave to produce a more retro gaming sound. We could of course use the :func:`aud.Sound.square` generator instead of sine, but we want to show how to apply effects, so we apply a :func:`aud.Sound.threshold` which makes a square wave out of our sine too, even if less efficient than directly generating the square wave.
+
+.. code-block:: python
+
+ square = sine.threshold()
+
+.. note:: The :class:`aud.Sound` class offers generator and effect functions.
+
+The we can play our sound by calling the :func:`aud.Device.play` method of our device. This method returns a :class:`aud.Handle` which is used to control the playback of the sound.
+
+.. code-block:: python
+
+ handle = device.play(square)
+
+Now if we do nothing else anymore the application will quit immediately, so we won't hear much of our square wave, so we decide to wait for three seconds before quitting the application by calling :func:`time.sleep`.
+
+.. code-block:: python
+
+ time.sleep(3)
+
+Audioplayer
+-----------
+
+Now that we know the basics of audaspace, we can build our own music player easily by just slightly changing the previous program. The **player.py** example does exactly that, let's have a short look at the differences:
+
+Instead of creating a sine signal and thresholding it, we in fact use the :func:`aud.Sound.file` function to load a sound from a file. The filename we pass is the first command line argument our application got.
+
+.. code-block:: python
+
+ sound = aud.Sound.file(sys.argv[1])
+
+When the sound gets played back we now want to wait until the whole file has been played, so we use the :data:`aud.Handle.status` property to determine whether the sound finished playing.
+
+.. code-block:: python
+
+ while handle.status:
+ time.sleep(0.1)
+
+We don't make any error checks if the user actually added a command line argument. As an exercise you could extend this program to play any number of command line supplied files in sequence.
+
+Siren
+-----
+
+Let's get a little bit more complex. The **siren.py** example plays a generated siren sound that circles around your head. Depending on how many speakers you have and if the output device used supports the speaker setup, you will hear this effect. With stereo speakers you should at least hear some left-right-panning.
+
+We start off again with importing the modules we need and we also define some properties of our siren sound. We want it to consist of two sine sounds with different frequencies. We define a length for the sine sounds and how long a fade in/out should take. We also know already how to open a device.
+
+.. code-block:: python
+
+ #!/usr/bin/python
+ import aud, math, time
+ length = 0.5
+ fadelength = 0.05
+
+ device = aud.Device()
+
+The next thing to do is to define our sine waves and apply all the required effects. As each of the effect functions returns the corresponding sound, we can easily chain those calls together.
+
+.. code-block:: python
+
+ high = aud.Sound.sine(880).limit(0, length).fadein(0, fadelength).fadeout(length - fadelength, length)
+ low = aud.Sound.sine(700).limit(0, length).fadein(0, fadelength).fadeout(length - fadelength, length).volume(0.6)
+
+The next step is to connect the two sines, which we do using the :func:`aud.Sound.join` function.
+
+.. code-block:: python
+
+ sound = high.join(low)
+
+The generated siren sound can now be played back and what we also do is to loop it. Therefore we set the :data:`aud.Handle.loop_count` to a negative value to loop forever.
+
+.. code-block:: python
+
+ handle = device.play(sound)
+ handle.loop_count = -1
+
+Now we use some timing code to make sure our demo runs for 10 seconds, but we also use the time to update the location of our playing sound, with the :data:`aud.Handle.location` property, which is a three dimensional vector. The trigonometic calculation based on the running time of the program keeps the sound on the XZ plane letting it follow a circle around us.
+
+.. code-block:: python
+
+ start = time.time()
+
+ while time.time() - start < 10:
+ angle = time.time() - start
+
+ handle.location = [math.sin(angle), 0, -math.cos(angle)]
+
+As an exercise you could try to let the sound come from the far left and go to the far right and a little bit in front of you within the 10 second runtime of the program. With this change you should be able to hear the volume of the sound change, depending on how far it is away from you. Updating the :data:`aud.Handle.velocity` property properly also enables the doppler effect. Compare your solution to the **siren2.py** demo.
+
+Tetris
+------
+
+The **tetris.py** demo application shows an even more complex application which generates retro tetris music. Looking at the source code there should be nothing new here, again the functions used from audaspace are the same as in the previous examples. In the :func:`parseNote` function all single notes get joined which leads to a very long chain of sounds. If you think of :func:`aud.Sound.join` as a function that creates a binary tree with the two joined sounds as leaves then the :func:`parseNote` function creates a very unbalanced tree.
+
+Insted we could rewrite the code to use two other classes: :class:`aud.Sequence` and :class:`aud.SequenceEntry` to sequence the notes. The **tetris2.py** application does exactly that. Before the while loop we add a variable that stores the current position in the score and create a new :class:`aud.Sequence` object.
+
+.. code-block:: python
+
+ position = 0
+ sequence = aud.Sequence()
+
+Then in the loop we can create the note simply by chaining the :func:`aud.Sound.square` generator and :func:`aud.Sound.fadein` and :func:`aud.Sound.fadeout` effects.
+
+.. code-block:: python
+
+ note = aud.Sound.square(freq, rate).fadein(0, fadelength).fadeout(length - fadelength, fadelength)
+
+Now instead of using :func:`aud.Sound.limit` and :func:`aud.Sound.join` we simply add the sound to the sequence.
+
+.. code-block:: python
+
+ entry = sequence.add(note, position, position + length, 0)
+
+The entry returned from the :func:`aud.Sequence.add` function is an object of the :class:`aud.SequenceEntry` class. We can use this entry to mute the note in case it's actually a pause.
+
+.. code-block:: python
+
+ if char == 'p':
+ entry.muted = True
+
+Lastly we have to update our position variable.
+
+.. code-block:: python
+
+ position += length
+
+Now in **tetris2.py** we used the :data:`aud.SequenceEntry.muted` property to show how the :class:`aud.SequenceEntry` class can be used, but it would actually be smarter to not even create a note for pauses and just skip them. You can try to implement this as an exercise and then check out the solution in **tetris3.py**.
+
+Conclusion
+----------
+
+We introduced all five currently available classes in the audaspace Python API. Of course all classes offer a lot more functions than have been used in these demo applications, check out the specific class documentation for more details.
diff --git a/extern/audaspace/bindings/python/PyAPI.cpp b/extern/audaspace/bindings/python/PyAPI.cpp
new file mode 100644
index 00000000000..cceadbc0992
--- /dev/null
+++ b/extern/audaspace/bindings/python/PyAPI.cpp
@@ -0,0 +1,231 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "PyAPI.h"
+#include "PySound.h"
+#include "PyHandle.h"
+#include "PyDevice.h"
+#include "PySequenceEntry.h"
+#include "PySequence.h"
+#include "PyPlaybackManager.h"
+#include "PyDynamicMusic.h"
+#include "PyThreadPool.h"
+#include "PySource.h"
+
+#ifdef WITH_CONVOLUTION
+#include "PyImpulseResponse.h"
+#include "PyHRTF.h"
+#endif
+
+#include "respec/Specification.h"
+#include "devices/IHandle.h"
+#include "devices/I3DDevice.h"
+#include "file/IWriter.h"
+#include "plugin/PluginManager.h"
+#include "sequence/AnimateableProperty.h"
+#include "ISound.h"
+
+#include <memory>
+
+#include <structmember.h>
+
+using namespace aud;
+
+// ====================================================================
+
+#define PY_MODULE_ADD_CONSTANT(module, name) PyModule_AddIntConstant(module, #name, name)
+
+// ====================================================================
+
+extern PyObject* AUDError;
+PyObject* AUDError = nullptr;
+
+// ====================================================================
+
+PyDoc_STRVAR(M_aud_doc,
+ "Audaspace (pronounced \"outer space\") is a high level audio library.");
+
+static struct PyModuleDef audmodule = {
+ PyModuleDef_HEAD_INIT,
+ "aud", /* name of module */
+ M_aud_doc, /* module documentation */
+ -1, /* size of per-interpreter state of the module,
+ or -1 if the module keeps state in global variables. */
+ nullptr, nullptr, nullptr, nullptr, nullptr
+};
+
+PyMODINIT_FUNC
+PyInit_aud()
+{
+ PyObject* module;
+
+ PluginManager::loadPlugins();
+
+ if(!initializeSound())
+ return nullptr;
+
+ if(!initializeDevice())
+ return nullptr;
+
+ if(!initializeHandle())
+ return nullptr;
+
+ if(!initializeSequenceEntry())
+ return nullptr;
+
+ if(!initializeSequence())
+ return nullptr;
+
+ if(!initializeDynamicMusic())
+ return nullptr;
+
+ if(!initializePlaybackManager())
+ return nullptr;
+
+ if(!initializeThreadPool())
+ return nullptr;
+
+ if(!initializeSource())
+ return nullptr;
+
+#ifdef WITH_CONVOLUTION
+ if(!initializeImpulseResponse())
+ return nullptr;
+
+ if(!initializeHRTF())
+ return nullptr;
+#endif
+
+ module = PyModule_Create(&audmodule);
+ if(module == nullptr)
+ return nullptr;
+
+ addSoundToModule(module);
+ addHandleToModule(module);
+ addDeviceToModule(module);
+ addSequenceEntryToModule(module);
+ addSequenceToModule(module);
+ addDynamicMusicToModule(module);
+ addPlaybackManagerToModule(module);
+ addThreadPoolToModule(module);
+ addSourceToModule(module);
+
+#ifdef WITH_CONVOLUTION
+ addImpulseResponseToModule(module);
+ addHRTFToModule(module);
+#endif
+
+ AUDError = PyErr_NewException("aud.error", nullptr, nullptr);
+ Py_INCREF(AUDError);
+ PyModule_AddObject(module, "error", AUDError);
+
+ // animatable property type constants
+ PY_MODULE_ADD_CONSTANT(module, AP_VOLUME);
+ PY_MODULE_ADD_CONSTANT(module, AP_PANNING);
+ PY_MODULE_ADD_CONSTANT(module, AP_PITCH);
+ PY_MODULE_ADD_CONSTANT(module, AP_LOCATION);
+ PY_MODULE_ADD_CONSTANT(module, AP_ORIENTATION);
+ // channels constants
+ PY_MODULE_ADD_CONSTANT(module, CHANNELS_INVALID);
+ PY_MODULE_ADD_CONSTANT(module, CHANNELS_MONO);
+ PY_MODULE_ADD_CONSTANT(module, CHANNELS_STEREO);
+ PY_MODULE_ADD_CONSTANT(module, CHANNELS_STEREO_LFE);
+ PY_MODULE_ADD_CONSTANT(module, CHANNELS_SURROUND4);
+ PY_MODULE_ADD_CONSTANT(module, CHANNELS_SURROUND5);
+ PY_MODULE_ADD_CONSTANT(module, CHANNELS_SURROUND51);
+ PY_MODULE_ADD_CONSTANT(module, CHANNELS_SURROUND61);
+ PY_MODULE_ADD_CONSTANT(module, CHANNELS_SURROUND71);
+ // codec constants
+ PY_MODULE_ADD_CONSTANT(module, CODEC_INVALID);
+ PY_MODULE_ADD_CONSTANT(module, CODEC_AAC);
+ PY_MODULE_ADD_CONSTANT(module, CODEC_AC3);
+ PY_MODULE_ADD_CONSTANT(module, CODEC_FLAC);
+ PY_MODULE_ADD_CONSTANT(module, CODEC_MP2);
+ PY_MODULE_ADD_CONSTANT(module, CODEC_MP3);
+ PY_MODULE_ADD_CONSTANT(module, CODEC_PCM);
+ PY_MODULE_ADD_CONSTANT(module, CODEC_VORBIS);
+ PY_MODULE_ADD_CONSTANT(module, CODEC_OPUS);
+ // container constants
+ PY_MODULE_ADD_CONSTANT(module, CONTAINER_INVALID);
+ PY_MODULE_ADD_CONSTANT(module, CONTAINER_AC3);
+ PY_MODULE_ADD_CONSTANT(module, CONTAINER_FLAC);
+ PY_MODULE_ADD_CONSTANT(module, CONTAINER_MATROSKA);
+ PY_MODULE_ADD_CONSTANT(module, CONTAINER_MP2);
+ PY_MODULE_ADD_CONSTANT(module, CONTAINER_MP3);
+ PY_MODULE_ADD_CONSTANT(module, CONTAINER_OGG);
+ PY_MODULE_ADD_CONSTANT(module, CONTAINER_WAV);
+ // distance model constants
+ PY_MODULE_ADD_CONSTANT(module, DISTANCE_MODEL_EXPONENT);
+ PY_MODULE_ADD_CONSTANT(module, DISTANCE_MODEL_EXPONENT_CLAMPED);
+ PY_MODULE_ADD_CONSTANT(module, DISTANCE_MODEL_INVERSE);
+ PY_MODULE_ADD_CONSTANT(module, DISTANCE_MODEL_INVERSE_CLAMPED);
+ PY_MODULE_ADD_CONSTANT(module, DISTANCE_MODEL_LINEAR);
+ PY_MODULE_ADD_CONSTANT(module, DISTANCE_MODEL_LINEAR_CLAMPED);
+ PY_MODULE_ADD_CONSTANT(module, DISTANCE_MODEL_INVALID);
+ // format constants
+ PY_MODULE_ADD_CONSTANT(module, FORMAT_INVALID);
+ PY_MODULE_ADD_CONSTANT(module, FORMAT_FLOAT32);
+ PY_MODULE_ADD_CONSTANT(module, FORMAT_FLOAT64);
+ PY_MODULE_ADD_CONSTANT(module, FORMAT_INVALID);
+ PY_MODULE_ADD_CONSTANT(module, FORMAT_S16);
+ PY_MODULE_ADD_CONSTANT(module, FORMAT_S24);
+ PY_MODULE_ADD_CONSTANT(module, FORMAT_S32);
+ PY_MODULE_ADD_CONSTANT(module, FORMAT_U8);
+ // rate constants
+ PY_MODULE_ADD_CONSTANT(module, RATE_INVALID);
+ PY_MODULE_ADD_CONSTANT(module, RATE_8000);
+ PY_MODULE_ADD_CONSTANT(module, RATE_16000);
+ PY_MODULE_ADD_CONSTANT(module, RATE_11025);
+ PY_MODULE_ADD_CONSTANT(module, RATE_22050);
+ PY_MODULE_ADD_CONSTANT(module, RATE_32000);
+ PY_MODULE_ADD_CONSTANT(module, RATE_44100);
+ PY_MODULE_ADD_CONSTANT(module, RATE_48000);
+ PY_MODULE_ADD_CONSTANT(module, RATE_88200);
+ PY_MODULE_ADD_CONSTANT(module, RATE_96000);
+ PY_MODULE_ADD_CONSTANT(module, RATE_192000);
+ // status constants
+ PY_MODULE_ADD_CONSTANT(module, STATUS_INVALID);
+ PY_MODULE_ADD_CONSTANT(module, STATUS_PAUSED);
+ PY_MODULE_ADD_CONSTANT(module, STATUS_PLAYING);
+ PY_MODULE_ADD_CONSTANT(module, STATUS_STOPPED);
+
+ return module;
+}
+
+AUD_API PyObject* AUD_getPythonSound(void* sound)
+{
+ if(sound)
+ {
+ Sound* object = (Sound*) Sound_empty();
+ if(object)
+ {
+ object->sound = new std::shared_ptr<ISound>(*reinterpret_cast<std::shared_ptr<ISound>*>(sound));
+ return (PyObject *) object;
+ }
+ }
+
+ return nullptr;
+}
+
+AUD_API void* AUD_getSoundFromPython(PyObject* object)
+{
+ Sound* sound = checkSound(object);
+
+ if(!sound)
+ return nullptr;
+
+ return new std::shared_ptr<ISound>(*reinterpret_cast<std::shared_ptr<ISound>*>(sound->sound));
+}
diff --git a/extern/audaspace/bindings/python/PyAPI.h b/extern/audaspace/bindings/python/PyAPI.h
new file mode 100644
index 00000000000..a413b4813d6
--- /dev/null
+++ b/extern/audaspace/bindings/python/PyAPI.h
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+#include <Python.h>
+#include "Audaspace.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+PyMODINIT_FUNC
+PyInit_aud();
+
+/**
+ * Retrieves the python factory of a sound.
+ * \param sound The sound factory.
+ * \return The python factory.
+ */
+extern AUD_API PyObject* AUD_getPythonSound(void* sound);
+
+/**
+ * Retrieves the sound factory of a python factory.
+ * \param sound The python factory.
+ * \return The sound factory.
+ */
+extern AUD_API void* AUD_getSoundFromPython(PyObject* object);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/extern/audaspace/bindings/python/PyDevice.cpp b/extern/audaspace/bindings/python/PyDevice.cpp
new file mode 100644
index 00000000000..a6beef57d83
--- /dev/null
+++ b/extern/audaspace/bindings/python/PyDevice.cpp
@@ -0,0 +1,785 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "PyDevice.h"
+
+#include "PySound.h"
+#include "PyHandle.h"
+
+#include "Exception.h"
+#include "devices/IDevice.h"
+#include "devices/I3DDevice.h"
+#include "devices/DeviceManager.h"
+#include "devices/IDeviceFactory.h"
+
+#include <structmember.h>
+
+using namespace aud;
+
+extern PyObject* AUDError;
+static const char* device_not_3d_error = "Device is not a 3D device!";
+
+// ====================================================================
+
+static void
+Device_dealloc(Device* self)
+{
+ if(self->device)
+ delete reinterpret_cast<std::shared_ptr<IDevice>*>(self->device);
+ Py_TYPE(self)->tp_free((PyObject *)self);
+}
+
+static PyObject *
+Device_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
+{
+ Device* self;
+
+ static const char* kwlist[] = {"type", "rate", "channels", "format", "buffer_size", "name", nullptr};
+ const char* device = nullptr;
+ double rate = RATE_48000;
+ int channels = CHANNELS_STEREO;
+ int format = FORMAT_FLOAT32;
+ int buffersize = AUD_DEFAULT_BUFFER_SIZE;
+ const char* name = "";
+
+ if(!PyArg_ParseTupleAndKeywords(args, kwds, "|sdiiis:Device", const_cast<char**>(kwlist),
+ &device, &rate, &channels, &format, &buffersize, &name))
+ return nullptr;
+
+ if(buffersize < 128)
+ {
+ PyErr_SetString(PyExc_ValueError, "buffer_size must be at least 128!");
+ return nullptr;
+ }
+
+ self = (Device*)type->tp_alloc(type, 0);
+
+ if(self != nullptr)
+ {
+ DeviceSpecs specs;
+ specs.channels = (Channels)channels;
+ specs.format = (SampleFormat)format;
+ specs.rate = (SampleRate)rate;
+
+ self->device = nullptr;
+
+ try
+ {
+ if(!device)
+ {
+ auto dev = DeviceManager::getDevice();
+ if(!dev)
+ {
+ DeviceManager::openDefaultDevice();
+ dev = DeviceManager::getDevice();
+ }
+ self->device = new std::shared_ptr<IDevice>(dev);
+ }
+ else
+ {
+ std::shared_ptr<IDeviceFactory> factory;
+ if(!*device)
+ factory = DeviceManager::getDefaultDeviceFactory();
+ else
+ factory = DeviceManager::getDeviceFactory(device);
+
+ if(factory)
+ {
+ factory->setName(name);
+ factory->setSpecs(specs);
+ factory->setBufferSize(buffersize);
+ self->device = new std::shared_ptr<IDevice>(factory->openDevice());
+ }
+ }
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(self);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+
+ if(!self->device)
+ {
+ Py_DECREF(self);
+ PyErr_SetString(AUDError, "Unsupported device type!");
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)self;
+}
+
+PyDoc_STRVAR(M_aud_Device_lock_doc,
+ "lock()\n\n"
+ "Locks the device so that it's guaranteed, that no samples are "
+ "read from the streams until :meth:`unlock` is called.\n"
+ "This is useful if you want to do start/stop/pause/resume some "
+ "sounds at the same time.\n\n"
+ ".. note:: The device has to be unlocked as often as locked to be "
+ "able to continue playback.\n\n"
+ ".. warning:: Make sure the time between locking and unlocking is "
+ "as short as possible to avoid clicks.");
+
+static PyObject *
+Device_lock(Device* self)
+{
+ try
+ {
+ (*reinterpret_cast<std::shared_ptr<IDevice>*>(self->device))->lock();
+ Py_RETURN_NONE;
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+PyDoc_STRVAR(M_aud_Device_play_doc,
+ "play(sound, keep=False)\n\n"
+ "Plays a sound.\n\n"
+ ":arg sound: The sound to play.\n"
+ ":type sound: :class:`Sound`\n"
+ ":arg keep: See :attr:`Handle.keep`.\n"
+ ":type keep: bool\n"
+ ":return: The playback handle with which playback can be "
+ "controlled with.\n"
+ ":rtype: :class:`Handle`");
+
+static PyObject *
+Device_play(Device* self, PyObject* args, PyObject* kwds)
+{
+ PyObject* object;
+ PyObject* keepo = nullptr;
+
+ bool keep = false;
+
+ static const char* kwlist[] = {"sound", "keep", nullptr};
+
+ if(!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:play", const_cast<char**>(kwlist), &object, &keepo))
+ return nullptr;
+
+ Sound* sound = checkSound(object);
+
+ if(!sound)
+ return nullptr;
+
+ if(keepo != nullptr)
+ {
+ if(!PyBool_Check(keepo))
+ {
+ PyErr_SetString(PyExc_TypeError, "keep is not a boolean!");
+ return nullptr;
+ }
+
+ keep = keepo == Py_True;
+ }
+
+ Handle* handle;
+
+ handle = (Handle*)Handle_empty();
+ if(handle != nullptr)
+ {
+ try
+ {
+ handle->handle = new std::shared_ptr<IHandle>((*reinterpret_cast<std::shared_ptr<IDevice>*>(self->device))->play(*reinterpret_cast<std::shared_ptr<ISound>*>(sound->sound), keep));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(handle);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)handle;
+}
+
+PyDoc_STRVAR(M_aud_Device_stopAll_doc,
+ "stopAll()\n\n"
+ "Stops all playing and paused sounds.");
+
+static PyObject *
+Device_stopAll(Device* self)
+{
+ try
+ {
+ (*reinterpret_cast<std::shared_ptr<IDevice>*>(self->device))->stopAll();
+ Py_RETURN_NONE;
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+PyDoc_STRVAR(M_aud_Device_unlock_doc,
+ "unlock()\n\n"
+ "Unlocks the device after a lock call, see :meth:`lock` for "
+ "details.");
+
+static PyObject *
+Device_unlock(Device* self)
+{
+ try
+ {
+ (*reinterpret_cast<std::shared_ptr<IDevice>*>(self->device))->unlock();
+ Py_RETURN_NONE;
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static PyMethodDef Device_methods[] = {
+ {"lock", (PyCFunction)Device_lock, METH_NOARGS,
+ M_aud_Device_lock_doc
+ },
+ {"play", (PyCFunction)Device_play, METH_VARARGS | METH_KEYWORDS,
+ M_aud_Device_play_doc
+ },
+ {"stopAll", (PyCFunction)Device_stopAll, METH_NOARGS,
+ M_aud_Device_stopAll_doc
+ },
+ {"unlock", (PyCFunction)Device_unlock, METH_NOARGS,
+ M_aud_Device_unlock_doc
+ },
+ {nullptr} /* Sentinel */
+};
+
+PyDoc_STRVAR(M_aud_Device_channels_doc,
+ "The channel count of the device.");
+
+static PyObject *
+Device_get_channels(Device* self, void* nothing)
+{
+ try
+ {
+ DeviceSpecs specs = (*reinterpret_cast<std::shared_ptr<IDevice>*>(self->device))->getSpecs();
+ return Py_BuildValue("i", specs.channels);
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+PyDoc_STRVAR(M_aud_Device_distance_model_doc,
+ "The distance model of the device.\n\n"
+ ".. seealso:: http://connect.creativelabs.com/openal/Documentation/OpenAL%201.1%20Specification.htm#_Toc199835864");
+
+static PyObject *
+Device_get_distance_model(Device* self, void* nothing)
+{
+ try
+ {
+ I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
+ if(device)
+ {
+ return Py_BuildValue("i", int(device->getDistanceModel()));
+ }
+ else
+ {
+ PyErr_SetString(AUDError, device_not_3d_error);
+ return nullptr;
+ }
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+Device_set_distance_model(Device* self, PyObject* args, void* nothing)
+{
+ int model;
+
+ if(!PyArg_Parse(args, "i:distance_model", &model))
+ return -1;
+
+ try
+ {
+ I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
+ if(device)
+ {
+ device->setDistanceModel(DistanceModel(model));
+ return 0;
+ }
+ else
+ PyErr_SetString(AUDError, device_not_3d_error);
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_Device_doppler_factor_doc,
+ "The doppler factor of the device.\n"
+ "This factor is a scaling factor for the velocity vectors in "
+ "doppler calculation. So a value bigger than 1 will exaggerate "
+ "the effect as it raises the velocity.");
+
+static PyObject *
+Device_get_doppler_factor(Device* self, void* nothing)
+{
+ try
+ {
+ I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
+ if(device)
+ {
+ return Py_BuildValue("f", device->getDopplerFactor());
+ }
+ else
+ {
+ PyErr_SetString(AUDError, device_not_3d_error);
+ return nullptr;
+ }
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+Device_set_doppler_factor(Device* self, PyObject* args, void* nothing)
+{
+ float factor;
+
+ if(!PyArg_Parse(args, "f:doppler_factor", &factor))
+ return -1;
+
+ try
+ {
+ I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
+ if(device)
+ {
+ device->setDopplerFactor(factor);
+ return 0;
+ }
+ else
+ PyErr_SetString(AUDError, device_not_3d_error);
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_Device_format_doc,
+ "The native sample format of the device.");
+
+static PyObject *
+Device_get_format(Device* self, void* nothing)
+{
+ try
+ {
+ DeviceSpecs specs = (*reinterpret_cast<std::shared_ptr<IDevice>*>(self->device))->getSpecs();
+ return Py_BuildValue("i", specs.format);
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+PyDoc_STRVAR(M_aud_Device_listener_location_doc,
+ "The listeners's location in 3D space, a 3D tuple of floats.");
+
+static PyObject *
+Device_get_listener_location(Device* self, void* nothing)
+{
+ try
+ {
+ I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
+ if(device)
+ {
+ Vector3 v = device->getListenerLocation();
+ return Py_BuildValue("(fff)", v.x(), v.y(), v.z());
+ }
+ else
+ {
+ PyErr_SetString(AUDError, device_not_3d_error);
+ }
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return nullptr;
+}
+
+static int
+Device_set_listener_location(Device* self, PyObject* args, void* nothing)
+{
+ float x, y, z;
+
+ if(!PyArg_Parse(args, "(fff):listener_location", &x, &y, &z))
+ return -1;
+
+ try
+ {
+ I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
+ if(device)
+ {
+ Vector3 location(x, y, z);
+ device->setListenerLocation(location);
+ return 0;
+ }
+ else
+ PyErr_SetString(AUDError, device_not_3d_error);
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_Device_listener_orientation_doc,
+ "The listener's orientation in 3D space as quaternion, a 4 float tuple.");
+
+static PyObject *
+Device_get_listener_orientation(Device* self, void* nothing)
+{
+ try
+ {
+ I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
+ if(device)
+ {
+ Quaternion o = device->getListenerOrientation();
+ return Py_BuildValue("(ffff)", o.w(), o.x(), o.y(), o.z());
+ }
+ else
+ {
+ PyErr_SetString(AUDError, device_not_3d_error);
+ }
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return nullptr;
+}
+
+static int
+Device_set_listener_orientation(Device* self, PyObject* args, void* nothing)
+{
+ float w, x, y, z;
+
+ if(!PyArg_Parse(args, "(ffff):listener_orientation", &w, &x, &y, &z))
+ return -1;
+
+ try
+ {
+ I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
+ if(device)
+ {
+ Quaternion orientation(w, x, y, z);
+ device->setListenerOrientation(orientation);
+ return 0;
+ }
+ else
+ PyErr_SetString(AUDError, device_not_3d_error);
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_Device_listener_velocity_doc,
+ "The listener's velocity in 3D space, a 3D tuple of floats.");
+
+static PyObject *
+Device_get_listener_velocity(Device* self, void* nothing)
+{
+ try
+ {
+ I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
+ if(device)
+ {
+ Vector3 v = device->getListenerVelocity();
+ return Py_BuildValue("(fff)", v.x(), v.y(), v.z());
+ }
+ else
+ {
+ PyErr_SetString(AUDError, device_not_3d_error);
+ }
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return nullptr;
+}
+
+static int
+Device_set_listener_velocity(Device* self, PyObject* args, void* nothing)
+{
+ float x, y, z;
+
+ if(!PyArg_Parse(args, "(fff):listener_velocity", &x, &y, &z))
+ return -1;
+
+ try
+ {
+ I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
+ if(device)
+ {
+ Vector3 velocity(x, y, z);
+ device->setListenerVelocity(velocity);
+ return 0;
+ }
+ else
+ PyErr_SetString(AUDError, device_not_3d_error);
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_Device_rate_doc,
+ "The sampling rate of the device in Hz.");
+
+static PyObject *
+Device_get_rate(Device* self, void* nothing)
+{
+ try
+ {
+ DeviceSpecs specs = (*reinterpret_cast<std::shared_ptr<IDevice>*>(self->device))->getSpecs();
+ return Py_BuildValue("d", specs.rate);
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+PyDoc_STRVAR(M_aud_Device_speed_of_sound_doc,
+ "The speed of sound of the device.\n"
+ "The speed of sound in air is typically 343.3 m/s.");
+
+static PyObject *
+Device_get_speed_of_sound(Device* self, void* nothing)
+{
+ try
+ {
+ I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
+ if(device)
+ {
+ return Py_BuildValue("f", device->getSpeedOfSound());
+ }
+ else
+ {
+ PyErr_SetString(AUDError, device_not_3d_error);
+ return nullptr;
+ }
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+Device_set_speed_of_sound(Device* self, PyObject* args, void* nothing)
+{
+ float speed;
+
+ if(!PyArg_Parse(args, "f:speed_of_sound", &speed))
+ return -1;
+
+ try
+ {
+ I3DDevice* device = dynamic_cast<I3DDevice*>(reinterpret_cast<std::shared_ptr<IDevice>*>(self->device)->get());
+ if(device)
+ {
+ device->setSpeedOfSound(speed);
+ return 0;
+ }
+ else
+ PyErr_SetString(AUDError, device_not_3d_error);
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_Device_volume_doc,
+ "The overall volume of the device.");
+
+static PyObject *
+Device_get_volume(Device* self, void* nothing)
+{
+ try
+ {
+ return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<IDevice>*>(self->device))->getVolume());
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+Device_set_volume(Device* self, PyObject* args, void* nothing)
+{
+ float volume;
+
+ if(!PyArg_Parse(args, "f:volume", &volume))
+ return -1;
+
+ try
+ {
+ (*reinterpret_cast<std::shared_ptr<IDevice>*>(self->device))->setVolume(volume);
+ return 0;
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return -1;
+ }
+}
+
+static PyGetSetDef Device_properties[] = {
+ {(char*)"channels", (getter)Device_get_channels, nullptr,
+ M_aud_Device_channels_doc, nullptr },
+ {(char*)"distance_model", (getter)Device_get_distance_model, (setter)Device_set_distance_model,
+ M_aud_Device_distance_model_doc, nullptr },
+ {(char*)"doppler_factor", (getter)Device_get_doppler_factor, (setter)Device_set_doppler_factor,
+ M_aud_Device_doppler_factor_doc, nullptr },
+ {(char*)"format", (getter)Device_get_format, nullptr,
+ M_aud_Device_format_doc, nullptr },
+ {(char*)"listener_location", (getter)Device_get_listener_location, (setter)Device_set_listener_location,
+ M_aud_Device_listener_location_doc, nullptr },
+ {(char*)"listener_orientation", (getter)Device_get_listener_orientation, (setter)Device_set_listener_orientation,
+ M_aud_Device_listener_orientation_doc, nullptr },
+ {(char*)"listener_velocity", (getter)Device_get_listener_velocity, (setter)Device_set_listener_velocity,
+ M_aud_Device_listener_velocity_doc, nullptr },
+ {(char*)"rate", (getter)Device_get_rate, nullptr,
+ M_aud_Device_rate_doc, nullptr },
+ {(char*)"speed_of_sound", (getter)Device_get_speed_of_sound, (setter)Device_set_speed_of_sound,
+ M_aud_Device_speed_of_sound_doc, nullptr },
+ {(char*)"volume", (getter)Device_get_volume, (setter)Device_set_volume,
+ M_aud_Device_volume_doc, nullptr },
+ {nullptr} /* Sentinel */
+};
+
+PyDoc_STRVAR(M_aud_Device_doc,
+ "Device objects represent an audio output backend like OpenAL or "
+ "SDL, but might also represent a file output or RAM buffer "
+ "output.");
+
+static PyTypeObject DeviceType = {
+ PyVarObject_HEAD_INIT(nullptr, 0)
+ "aud.Device", /* tp_name */
+ sizeof(Device), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)Device_dealloc,/* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_reserved */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ M_aud_Device_doc, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ Device_methods, /* tp_methods */
+ 0, /* tp_members */
+ Device_properties, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ Device_new, /* tp_new */
+};
+
+AUD_API PyObject* Device_empty()
+{
+ return DeviceType.tp_alloc(&DeviceType, 0);
+}
+
+
+AUD_API Device* checkDevice(PyObject* device)
+{
+ if(!PyObject_TypeCheck(device, &DeviceType))
+ {
+ PyErr_SetString(PyExc_TypeError, "Object is not of type Device!");
+ return nullptr;
+ }
+
+ return (Device*)device;
+}
+
+
+bool initializeDevice()
+{
+ return PyType_Ready(&DeviceType) >= 0;
+}
+
+
+void addDeviceToModule(PyObject* module)
+{
+ Py_INCREF(&DeviceType);
+ PyModule_AddObject(module, "Device", (PyObject *)&DeviceType);
+}
diff --git a/extern/audaspace/bindings/python/PyDevice.h b/extern/audaspace/bindings/python/PyDevice.h
new file mode 100644
index 00000000000..610b5b4cd23
--- /dev/null
+++ b/extern/audaspace/bindings/python/PyDevice.h
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+#include <Python.h>
+#include "Audaspace.h"
+
+typedef void Reference_IDevice;
+
+typedef struct {
+ PyObject_HEAD
+ Reference_IDevice* device;
+} Device;
+
+extern AUD_API PyObject* Device_empty();
+extern AUD_API Device* checkDevice(PyObject* device);
+
+bool initializeDevice();
+void addDeviceToModule(PyObject* module);
diff --git a/extern/audaspace/bindings/python/PyDynamicMusic.cpp b/extern/audaspace/bindings/python/PyDynamicMusic.cpp
new file mode 100644
index 00000000000..d49f73737c2
--- /dev/null
+++ b/extern/audaspace/bindings/python/PyDynamicMusic.cpp
@@ -0,0 +1,467 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "PyDynamicMusic.h"
+#include "PySound.h"
+#include "PyHandle.h"
+#include "PyDevice.h"
+
+#include "Exception.h"
+#include "fx/DynamicMusic.h"
+
+extern PyObject* AUDError;
+
+static PyObject *
+DynamicMusic_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
+{
+ DynamicMusicP* self = (DynamicMusicP*)type->tp_alloc(type, 0);
+
+ if(self != nullptr)
+ {
+ PyObject* object;
+ if(!PyArg_ParseTuple(args, "O:device", &object))
+ return nullptr;
+ Device* device = checkDevice(object);
+
+ try
+ {
+ self->dynamicMusic = new std::shared_ptr<aud::DynamicMusic>(new aud::DynamicMusic(*reinterpret_cast<std::shared_ptr<aud::IDevice>*>(device->device)));
+ }
+ catch(aud::Exception& e)
+ {
+ Py_DECREF(self);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)self;
+}
+
+static void
+DynamicMusic_dealloc(DynamicMusicP* self)
+{
+ if(self->dynamicMusic)
+ delete reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic);
+ Py_TYPE(self)->tp_free((PyObject *)self);
+}
+
+PyDoc_STRVAR(M_aud_DynamicMusic_addScene_doc,
+ "addScene(scene)\n\n"
+ "Adds a new scene.\n\n"
+ ":arg scene: The scene sound.\n"
+ ":type scene: :class:`Sound`\n"
+ ":return: The new scene id.\n"
+ ":rtype: int");
+
+static PyObject *
+DynamicMusic_addScene(DynamicMusicP* self, PyObject* args)
+{
+ PyObject* object;
+ if(!PyArg_Parse(args, "O:sound", &object))
+ return nullptr;
+
+ Sound* sound = checkSound(object);
+ if(!sound)
+ return nullptr;
+
+ try
+ {
+ return Py_BuildValue("i", (*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->addScene(*reinterpret_cast<std::shared_ptr<aud::ISound>*>(sound->sound)));
+ }
+ catch(aud::Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+PyDoc_STRVAR(M_aud_DynamicMusic_addTransition_doc,
+ "addTransition(ini, end, transition)\n\n"
+ "Adds a new scene.\n\n"
+ ":arg ini: the initial scene foor the transition.\n"
+ ":type ini: int\n"
+ ":arg end: The final scene for the transition.\n"
+ ":type end: int\n"
+ ":arg transition: The transition sound.\n"
+ ":type transition: :class:`Sound`\n"
+ ":return: false if the ini or end scenes don't exist, true othrwise.\n"
+ ":rtype: bool");
+
+static PyObject *
+DynamicMusic_addTransition(DynamicMusicP* self, PyObject* args)
+{
+ PyObject* object;
+ int ini, end;
+ if(!PyArg_ParseTuple(args, "iiO:sound", &ini, &end, &object))
+ return nullptr;
+ Sound* sound = checkSound(object);
+ if(!sound)
+ return nullptr;
+
+ try
+ {
+ (*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->addTransition(ini, end, *reinterpret_cast<std::shared_ptr<aud::ISound>*>(sound->sound));
+ Py_RETURN_NONE;
+ }
+ catch(aud::Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+PyDoc_STRVAR(M_aud_DynamicMusic_resume_doc,
+ "resume()\n\n"
+ "Resumes playback of the scene.\n\n"
+ ":return: Whether the action succeeded.\n"
+ ":rtype: bool");
+
+static PyObject *
+DynamicMusic_resume(DynamicMusicP* self)
+{
+ try
+ {
+ return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->resume());
+ }
+ catch(aud::Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+PyDoc_STRVAR(M_aud_DynamicMusic_pause_doc,
+ "pause()\n\n"
+ "Pauses playback of the scene.\n\n"
+ ":return: Whether the action succeeded.\n"
+ ":rtype: bool");
+
+static PyObject *
+DynamicMusic_pause(DynamicMusicP* self)
+{
+ try
+ {
+ return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->pause());
+ }
+ catch(aud::Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+PyDoc_STRVAR(M_aud_DynamicMusic_stop_doc,
+ "stop()\n\n"
+ "Stops playback of the scene.\n\n"
+ ":return: Whether the action succeeded.\n"
+ ":rtype: bool\n\n");
+
+static PyObject *
+DynamicMusic_stop(DynamicMusicP* self)
+{
+ try
+ {
+ return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->stop());
+ }
+ catch(aud::Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static PyMethodDef DynamicMusic_methods[] = {
+ { "addScene", (PyCFunction)DynamicMusic_addScene, METH_O,
+ M_aud_DynamicMusic_addScene_doc
+ },
+ { "addTransition", (PyCFunction)DynamicMusic_addTransition, METH_VARARGS,
+ M_aud_DynamicMusic_addTransition_doc
+ },
+ { "resume", (PyCFunction)DynamicMusic_resume, METH_NOARGS,
+ M_aud_DynamicMusic_resume_doc
+ },
+ { "pause", (PyCFunction)DynamicMusic_pause, METH_NOARGS,
+ M_aud_DynamicMusic_pause_doc
+ },
+ { "stop", (PyCFunction)DynamicMusic_stop, METH_NOARGS,
+ M_aud_DynamicMusic_stop_doc
+ },
+ { nullptr } /* Sentinel */
+};
+
+/////////////////////////////////////////////////////
+
+PyDoc_STRVAR(M_aud_DynamicMusic_status_doc,
+ "Whether the scene is playing, paused or stopped (=invalid).");
+
+static PyObject *
+DynamicMusic_get_status(DynamicMusicP* self, void* nothing)
+{
+ try
+ {
+ return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->getStatus());
+ }
+ catch(aud::Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+PyDoc_STRVAR(M_aud_DynamicMusic_position_doc,
+ "The playback position of the scene in seconds.");
+
+static int
+DynamicMusic_set_position(DynamicMusicP* self, PyObject* args, void* nothing)
+{
+ float position;
+
+ if(!PyArg_Parse(args, "f:position", &position))
+ return -1;
+
+ try
+ {
+ if((*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->seek(position))
+ return 0;
+ PyErr_SetString(AUDError, "Couldn't seek the sound!");
+ }
+ catch(aud::Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+static PyObject *
+DynamicMusic_get_position(DynamicMusicP* self, void* nothing)
+{
+ try
+ {
+ return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->getPosition());
+ }
+ catch(aud::Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+PyDoc_STRVAR(M_aud_DynamicMusic_fadeTime_doc,
+ "The length in seconds of the crossfade transition");
+
+static int
+DynamicMusic_set_fadeTime(DynamicMusicP* self, PyObject* args, void* nothing)
+{
+ float fadeTime;
+
+ if(!PyArg_Parse(args, "f:fadeTime", &fadeTime))
+ return -1;
+
+ try
+ {
+ (*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->setFadeTime(fadeTime);
+ return 0;
+ }
+ catch(aud::Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+static PyObject *
+DynamicMusic_get_fadeTime(DynamicMusicP* self, void* nothing)
+{
+ try
+ {
+ return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->getFadeTime());
+ }
+ catch(aud::Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+PyDoc_STRVAR(M_aud_DynamicMusic_scene_doc,
+ "The current scene");
+
+static int
+DynamicMusic_set_scene(DynamicMusicP* self, PyObject* args, void* nothing)
+{
+ int scene;
+
+ if(!PyArg_Parse(args, "i:scene", &scene))
+ return -1;
+
+ try
+ {
+ if((*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->changeScene(scene))
+ return 0;
+ PyErr_SetString(AUDError, "Couldn't change the scene!");
+ }
+ catch(aud::Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+static PyObject *
+DynamicMusic_get_scene(DynamicMusicP* self, void* nothing)
+{
+ try
+ {
+ return Py_BuildValue("i", (*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->getScene());
+ }
+ catch(aud::Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+PyDoc_STRVAR(M_aud_DynamicMusic_volume_doc,
+ "The volume of the scene.");
+
+static int
+DynamicMusic_set_volume(DynamicMusicP* self, PyObject* args, void* nothing)
+{
+ float volume;
+
+ if(!PyArg_Parse(args, "f:volume", &volume))
+ return -1;
+
+ try
+ {
+ if((*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->setVolume(volume))
+ return 0;
+ PyErr_SetString(AUDError, "Couldn't change the volume!");
+ }
+ catch(aud::Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+static PyObject *
+DynamicMusic_get_volume(DynamicMusicP* self, void* nothing)
+{
+ try
+ {
+ return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->getVolume());
+ }
+ catch(aud::Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static PyGetSetDef DynamicMusic_properties[] = {
+ { (char*)"status", (getter)DynamicMusic_get_status, nullptr,
+ M_aud_DynamicMusic_status_doc, nullptr },
+ { (char*)"position", (getter)DynamicMusic_get_position, (setter)DynamicMusic_set_position,
+ M_aud_DynamicMusic_position_doc, nullptr },
+ { (char*)"fadeTime", (getter)DynamicMusic_get_fadeTime, (setter)DynamicMusic_set_fadeTime,
+ M_aud_DynamicMusic_fadeTime_doc, nullptr },
+ { (char*)"scene", (getter)DynamicMusic_get_scene, (setter)DynamicMusic_set_scene,
+ M_aud_DynamicMusic_scene_doc, nullptr },
+ { (char*)"volume", (getter)DynamicMusic_get_volume, (setter)DynamicMusic_set_volume,
+ M_aud_DynamicMusic_volume_doc, nullptr },
+ { nullptr } /* Sentinel */
+};
+
+PyDoc_STRVAR(M_aud_DynamicMusic_doc,
+ "The DynamicMusic object allows to play music depending on a current scene, scene changes are managed by the class, with the possibility of custom transitions.\n"
+ "The default transition is a crossfade effect, and the default scene is silent and has id 0");
+
+PyTypeObject DynamicMusicType = {
+ PyVarObject_HEAD_INIT(nullptr, 0)
+ "aud.DynamicMusic", /* tp_name */
+ sizeof(DynamicMusicP), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)DynamicMusic_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_reserved */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ M_aud_DynamicMusic_doc, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ DynamicMusic_methods, /* tp_methods */
+ 0, /* tp_members */
+ DynamicMusic_properties, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ DynamicMusic_new, /* tp_new */
+};
+
+AUD_API PyObject* DynamicMusic_empty()
+{
+ return DynamicMusicType.tp_alloc(&DynamicMusicType, 0);
+}
+
+
+AUD_API DynamicMusicP* checkDynamicMusic(PyObject* dynamicMusic)
+{
+ if(!PyObject_TypeCheck(dynamicMusic, &DynamicMusicType))
+ {
+ PyErr_SetString(PyExc_TypeError, "Object is not of type DynamicMusic!");
+ return nullptr;
+ }
+
+ return (DynamicMusicP*)dynamicMusic;
+}
+
+
+bool initializeDynamicMusic()
+{
+ return PyType_Ready(&DynamicMusicType) >= 0;
+}
+
+
+void addDynamicMusicToModule(PyObject* module)
+{
+ Py_INCREF(&DynamicMusicType);
+ PyModule_AddObject(module, "DynamicMusic", (PyObject *)&DynamicMusicType);
+} \ No newline at end of file
diff --git a/extern/audaspace/bindings/python/PyDynamicMusic.h b/extern/audaspace/bindings/python/PyDynamicMusic.h
new file mode 100644
index 00000000000..f19de2d8c75
--- /dev/null
+++ b/extern/audaspace/bindings/python/PyDynamicMusic.h
@@ -0,0 +1,33 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+#include <Python.h>
+#include "Audaspace.h"
+
+typedef void Reference_DynamicMusic;
+
+typedef struct {
+ PyObject_HEAD
+ Reference_DynamicMusic* dynamicMusic;
+} DynamicMusicP;
+
+extern AUD_API PyObject* DynamicMusic_empty();
+extern AUD_API DynamicMusicP* checkDynamicMusic(PyObject* dynamicMusic);
+
+bool initializeDynamicMusic();
+void addDynamicMusicToModule(PyObject* module); \ No newline at end of file
diff --git a/extern/audaspace/bindings/python/PyHRTF.cpp b/extern/audaspace/bindings/python/PyHRTF.cpp
new file mode 100644
index 00000000000..2a5b6be624f
--- /dev/null
+++ b/extern/audaspace/bindings/python/PyHRTF.cpp
@@ -0,0 +1,247 @@
+/*******************************************************************************
+* Copyright 2009-2015 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "PyHRTF.h"
+#include "PySound.h"
+
+#include "Exception.h"
+#include "fx/HRTF.h"
+#include "fx/HRTFLoader.h"
+
+extern PyObject* AUDError;
+
+static PyObject *
+HRTF_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
+{
+ HRTFP* self = (HRTFP*)type->tp_alloc(type, 0);
+
+ if(self != nullptr)
+ {
+ try
+ {
+ self->hrtf = new std::shared_ptr<aud::HRTF>(new aud::HRTF());
+ }
+ catch(aud::Exception& e)
+ {
+ Py_DECREF(self);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)self;
+}
+
+static void
+HRTF_dealloc(HRTFP* self)
+{
+ if(self->hrtf)
+ delete reinterpret_cast<std::shared_ptr<aud::HRTF>*>(self->hrtf);
+ Py_TYPE(self)->tp_free((PyObject *)self);
+}
+
+PyDoc_STRVAR(M_aud_HRTF_addImpulseResponse_doc,
+ "addImpulseResponseFromSound(sound, azimuth, elevation)\n\n"
+ "Adds a new hrtf to the HRTF object\n\n"
+ ":arg sound: The sound that contains the hrtf.\n"
+ ":type sound: :class:`Sound`\n"
+ ":arg azimuth: The azimuth angle of the hrtf.\n"
+ ":type azimuth: float\n"
+ ":arg elevation: The elevation angle of the hrtf.\n"
+ ":type elevation: float\n"
+ ":return: Whether the action succeeded.\n"
+ ":rtype: bool");
+
+static PyObject *
+HRTF_addImpulseResponseFromSound(HRTFP* self, PyObject* args)
+{
+ PyObject* object;
+ float azimuth, elevation;
+
+ if(!PyArg_ParseTuple(args, "Off:hrtf", &object, &azimuth, &elevation))
+ return nullptr;
+
+ Sound* ir = checkSound(object);
+ if(!ir)
+ return nullptr;
+
+ try
+ {
+ return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<aud::HRTF>*>(self->hrtf))->addImpulseResponse(std::make_shared<aud::StreamBuffer>(*reinterpret_cast<std::shared_ptr<aud::ISound>*>(ir->sound)), azimuth, elevation));
+ }
+ catch(aud::Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+PyDoc_STRVAR(M_aud_HRTF_loadLeftHrtfSet_doc,
+ "loadLeftHrtfSet(extension, directory)\n\n"
+ "Loads all HRTFs from a directory.\n\n"
+ ":arg extension: The file extension of the hrtfs.\n"
+ ":type extension: string\n"
+ ":arg directory: The path to where the HRTF files are located.\n"
+ ":type extension: string\n"
+ ":return: The loaded :class:`HRTF` object.\n"
+ ":rtype: :class:`HRTF`\n\n");
+
+static PyObject *
+HRTF_loadLeftHrtfSet(PyTypeObject* type, PyObject* args)
+{
+ const char* dir = nullptr;
+ const char* ext = nullptr;
+
+ if(!PyArg_ParseTuple(args, "ss:hrtf", &ext, &dir))
+ return nullptr;
+
+ HRTFP* self;
+ self = (HRTFP*)type->tp_alloc(type, 0);
+
+ try
+ {
+ self->hrtf = new std::shared_ptr<aud::HRTF>(aud::HRTFLoader::loadLeftHRTFs(ext, dir));
+ }
+ catch(aud::Exception& e)
+ {
+ Py_DECREF(self);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ return (PyObject *)self;
+}
+
+PyDoc_STRVAR(M_aud_HRTF_loadRightHrtfSet_doc,
+ "loadLeftHrtfSet(extension, directory)\n\n"
+ "Loads all HRTFs from a directory.\n\n"
+ ":arg extension: The file extension of the hrtfs.\n"
+ ":type extension: string\n"
+ ":arg directory: The path to where the HRTF files are located.\n"
+ ":type extension: string\n"
+ ":return: The loaded :class:`HRTF` object.\n"
+ ":rtype: :class:`HRTF`\n\n");
+
+static PyObject *
+HRTF_loadRightHrtfSet(PyTypeObject* type, PyObject* args)
+{
+ const char* dir = nullptr;
+ const char* ext = nullptr;
+
+ if(!PyArg_ParseTuple(args, "ss:hrtf", &ext, &dir))
+ return nullptr;
+
+ HRTFP* self;
+ self = (HRTFP*)type->tp_alloc(type, 0);
+
+ try
+ {
+ self->hrtf = new std::shared_ptr<aud::HRTF>(aud::HRTFLoader::loadRightHRTFs(ext, dir));
+ }
+ catch(aud::Exception& e)
+ {
+ Py_DECREF(self);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ return (PyObject *)self;
+}
+
+static PyMethodDef HRTF_methods[] = {
+ { "addImpulseResponseFromSound", (PyCFunction)HRTF_addImpulseResponseFromSound, METH_VARARGS | METH_KEYWORDS,
+ M_aud_HRTF_addImpulseResponse_doc
+ },
+ { "loadLeftHrtfSet", (PyCFunction)HRTF_loadLeftHrtfSet, METH_VARARGS | METH_CLASS,
+ M_aud_HRTF_loadLeftHrtfSet_doc
+ },
+ { "loadRightHrtfSet", (PyCFunction)HRTF_loadRightHrtfSet, METH_VARARGS | METH_CLASS,
+ M_aud_HRTF_loadRightHrtfSet_doc
+ },
+ { nullptr } /* Sentinel */
+};
+
+PyDoc_STRVAR(M_aud_HRTF_doc,
+ "An HRTF object represents a set of head related transfer functions as impulse responses. It's used for binaural sound");
+
+PyTypeObject HRTFType = {
+ PyVarObject_HEAD_INIT(nullptr, 0)
+ "aud.HRTF", /* tp_name */
+ sizeof(HRTFP), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)HRTF_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_reserved */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ M_aud_HRTF_doc, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ HRTF_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ HRTF_new, /* tp_new */
+};
+
+AUD_API PyObject* HRTF_empty()
+{
+ return HRTFType.tp_alloc(&HRTFType, 0);
+}
+
+
+AUD_API HRTFP* checkHRTF(PyObject* hrtf)
+{
+ if(!PyObject_TypeCheck(hrtf, &HRTFType))
+ {
+ PyErr_SetString(PyExc_TypeError, "Object is not of type HRTF!");
+ return nullptr;
+ }
+
+ return (HRTFP*)hrtf;
+}
+
+
+bool initializeHRTF()
+{
+ return PyType_Ready(&HRTFType) >= 0;
+}
+
+
+void addHRTFToModule(PyObject* module)
+{
+ Py_INCREF(&HRTFType);
+ PyModule_AddObject(module, "HRTF", (PyObject *)&HRTFType);
+}
diff --git a/extern/audaspace/bindings/python/PyHRTF.h b/extern/audaspace/bindings/python/PyHRTF.h
new file mode 100644
index 00000000000..0445069929f
--- /dev/null
+++ b/extern/audaspace/bindings/python/PyHRTF.h
@@ -0,0 +1,33 @@
+/*******************************************************************************
+* Copyright 2009-2015 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+#include <Python.h>
+#include "Audaspace.h"
+
+typedef void Reference_HRTF;
+
+typedef struct {
+ PyObject_HEAD
+ Reference_HRTF* hrtf;
+} HRTFP;
+
+extern AUD_API PyObject* HRTF_empty();
+extern AUD_API HRTFP* checkHRTF(PyObject* hrtf);
+
+bool initializeHRTF();
+void addHRTFToModule(PyObject* module); \ No newline at end of file
diff --git a/extern/audaspace/bindings/python/PyHandle.cpp b/extern/audaspace/bindings/python/PyHandle.cpp
new file mode 100644
index 00000000000..7f7a7660049
--- /dev/null
+++ b/extern/audaspace/bindings/python/PyHandle.cpp
@@ -0,0 +1,1126 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "PyHandle.h"
+
+#include "devices/IHandle.h"
+#include "devices/I3DHandle.h"
+#include "Exception.h"
+
+#include <memory>
+
+#include <structmember.h>
+
+using namespace aud;
+
+extern PyObject* AUDError;
+static const char* device_not_3d_error = "Device is not a 3D device!";
+
+static void
+Handle_dealloc(Handle* self)
+{
+ if(self->handle)
+ delete reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle);
+ Py_TYPE(self)->tp_free((PyObject *)self);
+}
+
+PyDoc_STRVAR(M_aud_Handle_pause_doc,
+ "pause()\n\n"
+ "Pauses playback.\n\n"
+ ":return: Whether the action succeeded.\n"
+ ":rtype: bool");
+
+static PyObject *
+Handle_pause(Handle* self)
+{
+ try
+ {
+ return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle))->pause());
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+PyDoc_STRVAR(M_aud_Handle_resume_doc,
+ "resume()\n\n"
+ "Resumes playback.\n\n"
+ ":return: Whether the action succeeded.\n"
+ ":rtype: bool");
+
+static PyObject *
+Handle_resume(Handle* self)
+{
+ try
+ {
+ return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle))->resume());
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+PyDoc_STRVAR(M_aud_Handle_stop_doc,
+ "stop()\n\n"
+ "Stops playback.\n\n"
+ ":return: Whether the action succeeded.\n"
+ ":rtype: bool\n\n"
+ ".. note:: This makes the handle invalid.");
+
+static PyObject *
+Handle_stop(Handle* self)
+{
+ try
+ {
+ return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle))->stop());
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static PyMethodDef Handle_methods[] = {
+ {"pause", (PyCFunction)Handle_pause, METH_NOARGS,
+ M_aud_Handle_pause_doc
+ },
+ {"resume", (PyCFunction)Handle_resume, METH_NOARGS,
+ M_aud_Handle_resume_doc
+ },
+ {"stop", (PyCFunction)Handle_stop, METH_NOARGS,
+ M_aud_Handle_stop_doc
+ },
+ {nullptr} /* Sentinel */
+};
+
+PyDoc_STRVAR(M_aud_Handle_attenuation_doc,
+ "This factor is used for distance based attenuation of the "
+ "source.\n\n"
+ ".. seealso:: :attr:`Device.distance_model`");
+
+static PyObject *
+Handle_get_attenuation(Handle* self, void* nothing)
+{
+ try
+ {
+ I3DHandle* handle = dynamic_cast<I3DHandle*>(reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle)->get());
+ if(handle)
+ {
+ return Py_BuildValue("f", handle->getAttenuation());
+ }
+ else
+ {
+ PyErr_SetString(AUDError, device_not_3d_error);
+ return nullptr;
+ }
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+Handle_set_attenuation(Handle* self, PyObject* args, void* nothing)
+{
+ float factor;
+
+ if(!PyArg_Parse(args, "f:attenuation", &factor))
+ return -1;
+
+ try
+ {
+ I3DHandle* handle = dynamic_cast<I3DHandle*>(reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle)->get());
+ if(handle)
+ {
+ if(handle->setAttenuation(factor))
+ return 0;
+ PyErr_SetString(AUDError, "Couldn't set the attenuation!");
+ }
+ else
+ PyErr_SetString(AUDError, device_not_3d_error);
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_Handle_cone_angle_inner_doc,
+ "The opening angle of the inner cone of the source. If the cone "
+ "values of a source are set there are two (audible) cones with "
+ "the apex at the :attr:`location` of the source and with infinite "
+ "height, heading in the direction of the source's "
+ ":attr:`orientation`.\n"
+ "In the inner cone the volume is normal. Outside the outer cone "
+ "the volume will be :attr:`cone_volume_outer` and in the area "
+ "between the volume will be interpolated linearly.");
+
+static PyObject *
+Handle_get_cone_angle_inner(Handle* self, void* nothing)
+{
+ try
+ {
+ I3DHandle* handle = dynamic_cast<I3DHandle*>(reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle)->get());
+ if(handle)
+ {
+ return Py_BuildValue("f", handle->getConeAngleInner());
+ }
+ else
+ {
+ PyErr_SetString(AUDError, device_not_3d_error);
+ return nullptr;
+ }
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+Handle_set_cone_angle_inner(Handle* self, PyObject* args, void* nothing)
+{
+ float angle;
+
+ if(!PyArg_Parse(args, "f:cone_angle_inner", &angle))
+ return -1;
+
+ try
+ {
+ I3DHandle* handle = dynamic_cast<I3DHandle*>(reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle)->get());
+ if(handle)
+ {
+ if(handle->setConeAngleInner(angle))
+ return 0;
+ PyErr_SetString(AUDError, "Couldn't set the cone inner angle!");
+ }
+ else
+ PyErr_SetString(AUDError, device_not_3d_error);
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_Handle_cone_angle_outer_doc,
+ "The opening angle of the outer cone of the source.\n\n"
+ ".. seealso:: :attr:`cone_angle_inner`");
+
+static PyObject *
+Handle_get_cone_angle_outer(Handle* self, void* nothing)
+{
+ try
+ {
+ I3DHandle* handle = dynamic_cast<I3DHandle*>(reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle)->get());
+ if(handle)
+ {
+ return Py_BuildValue("f", handle->getConeAngleOuter());
+ }
+ else
+ {
+ PyErr_SetString(AUDError, device_not_3d_error);
+ return nullptr;
+ }
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+Handle_set_cone_angle_outer(Handle* self, PyObject* args, void* nothing)
+{
+ float angle;
+
+ if(!PyArg_Parse(args, "f:cone_angle_outer", &angle))
+ return -1;
+
+ try
+ {
+ I3DHandle* handle = dynamic_cast<I3DHandle*>(reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle)->get());
+ if(handle)
+ {
+ if(handle->setConeAngleOuter(angle))
+ return 0;
+ PyErr_SetString(AUDError, "Couldn't set the cone outer angle!");
+ }
+ else
+ PyErr_SetString(AUDError, device_not_3d_error);
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_Handle_cone_volume_outer_doc,
+ "The volume outside the outer cone of the source.\n\n"
+ ".. seealso:: :attr:`cone_angle_inner`");
+
+static PyObject *
+Handle_get_cone_volume_outer(Handle* self, void* nothing)
+{
+ try
+ {
+ I3DHandle* handle = dynamic_cast<I3DHandle*>(reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle)->get());
+ if(handle)
+ {
+ return Py_BuildValue("f", handle->getConeVolumeOuter());
+ }
+ else
+ {
+ PyErr_SetString(AUDError, device_not_3d_error);
+ return nullptr;
+ }
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+Handle_set_cone_volume_outer(Handle* self, PyObject* args, void* nothing)
+{
+ float volume;
+
+ if(!PyArg_Parse(args, "f:cone_volume_outer", &volume))
+ return -1;
+
+ try
+ {
+ I3DHandle* handle = dynamic_cast<I3DHandle*>(reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle)->get());
+ if(handle)
+ {
+ if(handle->setConeVolumeOuter(volume))
+ return 0;
+ PyErr_SetString(AUDError, "Couldn't set the cone outer volume!");
+ }
+ else
+ PyErr_SetString(AUDError, device_not_3d_error);
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_Handle_distance_maximum_doc,
+ "The maximum distance of the source.\n"
+ "If the listener is further away the source volume will be 0.\n\n"
+ ".. seealso:: :attr:`Device.distance_model`");
+
+static PyObject *
+Handle_get_distance_maximum(Handle* self, void* nothing)
+{
+ try
+ {
+ I3DHandle* handle = dynamic_cast<I3DHandle*>(reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle)->get());
+ if(handle)
+ {
+ return Py_BuildValue("f", handle->getDistanceMaximum());
+ }
+ else
+ {
+ PyErr_SetString(AUDError, device_not_3d_error);
+ return nullptr;
+ }
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+Handle_set_distance_maximum(Handle* self, PyObject* args, void* nothing)
+{
+ float distance;
+
+ if(!PyArg_Parse(args, "f:distance_maximum", &distance))
+ return -1;
+
+ try
+ {
+ I3DHandle* handle = dynamic_cast<I3DHandle*>(reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle)->get());
+ if(handle)
+ {
+ if(handle->setDistanceMaximum(distance))
+ return 0;
+ PyErr_SetString(AUDError, "Couldn't set the maximum distance!");
+ }
+ else
+ PyErr_SetString(AUDError, device_not_3d_error);
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_Handle_distance_reference_doc,
+ "The reference distance of the source.\n"
+ "At this distance the volume will be exactly :attr:`volume`.\n\n"
+ ".. seealso:: :attr:`Device.distance_model`");
+
+static PyObject *
+Handle_get_distance_reference(Handle* self, void* nothing)
+{
+ try
+ {
+ I3DHandle* handle = dynamic_cast<I3DHandle*>(reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle)->get());
+ if(handle)
+ {
+ return Py_BuildValue("f", handle->getDistanceReference());
+ }
+ else
+ {
+ PyErr_SetString(AUDError, device_not_3d_error);
+ return nullptr;
+ }
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+Handle_set_distance_reference(Handle* self, PyObject* args, void* nothing)
+{
+ float distance;
+
+ if(!PyArg_Parse(args, "f:distance_reference", &distance))
+ return -1;
+
+ try
+ {
+ I3DHandle* handle = dynamic_cast<I3DHandle*>(reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle)->get());
+ if(handle)
+ {
+ if(handle->setDistanceReference(distance))
+ return 0;
+ PyErr_SetString(AUDError, "Couldn't set the reference distance!");
+ }
+ else
+ PyErr_SetString(AUDError, device_not_3d_error);
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_Handle_keep_doc,
+ "Whether the sound should be kept paused in the device when its "
+ "end is reached.\n"
+ "This can be used to seek the sound to some position and start "
+ "playback again.\n\n"
+ ".. warning:: If this is set to true and you forget stopping this "
+ "equals a memory leak as the handle exists until the device is "
+ "destroyed.");
+
+static PyObject *
+Handle_get_keep(Handle* self, void* nothing)
+{
+ try
+ {
+ return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle))->getKeep());
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+Handle_set_keep(Handle* self, PyObject* args, void* nothing)
+{
+ if(!PyBool_Check(args))
+ {
+ PyErr_SetString(PyExc_TypeError, "keep is not a boolean!");
+ return -1;
+ }
+
+ bool keep = args == Py_True;
+
+ try
+ {
+ if((*reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle))->setKeep(keep))
+ return 0;
+ PyErr_SetString(AUDError, "Couldn't set keep of the sound!");
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_Handle_location_doc,
+ "The source's location in 3D space, a 3D tuple of floats.");
+
+static PyObject *
+Handle_get_location(Handle* self, void* nothing)
+{
+ try
+ {
+ I3DHandle* handle = dynamic_cast<I3DHandle*>(reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle)->get());
+ if(handle)
+ {
+ Vector3 v = handle->getLocation();
+ return Py_BuildValue("(fff)", v.x(), v.y(), v.z());
+ }
+ else
+ {
+ PyErr_SetString(AUDError, device_not_3d_error);
+ }
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return nullptr;
+}
+
+static int
+Handle_set_location(Handle* self, PyObject* args, void* nothing)
+{
+ float x, y, z;
+
+ if(!PyArg_Parse(args, "(fff):location", &x, &y, &z))
+ return -1;
+
+ try
+ {
+ I3DHandle* handle = dynamic_cast<I3DHandle*>(reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle)->get());
+ if(handle)
+ {
+ Vector3 location(x, y, z);
+ if(handle->setLocation(location))
+ return 0;
+ PyErr_SetString(AUDError, "Location couldn't be set!");
+ }
+ else
+ PyErr_SetString(AUDError, device_not_3d_error);
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_Handle_loop_count_doc,
+ "The (remaining) loop count of the sound. A negative value indicates infinity.");
+
+static PyObject *
+Handle_get_loop_count(Handle* self, void* nothing)
+{
+ try
+ {
+ return Py_BuildValue("i", (*reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle))->getLoopCount());
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+Handle_set_loop_count(Handle* self, PyObject* args, void* nothing)
+{
+ int loops;
+
+ if(!PyArg_Parse(args, "i:loop_count", &loops))
+ return -1;
+
+ try
+ {
+ if((*reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle))->setLoopCount(loops))
+ return 0;
+ PyErr_SetString(AUDError, "Couldn't set the loop count!");
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_Handle_orientation_doc,
+ "The source's orientation in 3D space as quaternion, a 4 float tuple.");
+
+static PyObject *
+Handle_get_orientation(Handle* self, void* nothing)
+{
+ try
+ {
+ I3DHandle* handle = dynamic_cast<I3DHandle*>(reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle)->get());
+ if(handle)
+ {
+ Quaternion o = handle->getOrientation();
+ return Py_BuildValue("(ffff)", o.w(), o.x(), o.y(), o.z());
+ }
+ else
+ {
+ PyErr_SetString(AUDError, device_not_3d_error);
+ }
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return nullptr;
+}
+
+static int
+Handle_set_orientation(Handle* self, PyObject* args, void* nothing)
+{
+ float w, x, y, z;
+
+ if(!PyArg_Parse(args, "(ffff):orientation", &w, &x, &y, &z))
+ return -1;
+
+ try
+ {
+ I3DHandle* handle = dynamic_cast<I3DHandle*>(reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle)->get());
+ if(handle)
+ {
+ Quaternion orientation(w, x, y, z);
+ if(handle->setOrientation(orientation))
+ return 0;
+ PyErr_SetString(AUDError, "Couldn't set the orientation!");
+ }
+ else
+ PyErr_SetString(AUDError, device_not_3d_error);
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_Handle_pitch_doc,
+ "The pitch of the sound.");
+
+static PyObject *
+Handle_get_pitch(Handle* self, void* nothing)
+{
+ try
+ {
+ return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle))->getPitch());
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+Handle_set_pitch(Handle* self, PyObject* args, void* nothing)
+{
+ float pitch;
+
+ if(!PyArg_Parse(args, "f:pitch", &pitch))
+ return -1;
+
+ try
+ {
+ if((*reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle))->setPitch(pitch))
+ return 0;
+ PyErr_SetString(AUDError, "Couldn't set the sound pitch!");
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_Handle_position_doc,
+ "The playback position of the sound in seconds.");
+
+static PyObject *
+Handle_get_position(Handle* self, void* nothing)
+{
+ try
+ {
+ return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle))->getPosition());
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+Handle_set_position(Handle* self, PyObject* args, void* nothing)
+{
+ float position;
+
+ if(!PyArg_Parse(args, "f:position", &position))
+ return -1;
+
+ try
+ {
+ if((*reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle))->seek(position))
+ return 0;
+ PyErr_SetString(AUDError, "Couldn't seek the sound!");
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_Handle_relative_doc,
+ "Whether the source's location, velocity and orientation is relative or absolute to the listener.");
+
+static PyObject *
+Handle_get_relative(Handle* self, void* nothing)
+{
+ try
+ {
+ I3DHandle* handle = dynamic_cast<I3DHandle*>(reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle)->get());
+ if(handle)
+ {
+ return PyBool_FromLong((long)handle->isRelative());
+ }
+ else
+ {
+ PyErr_SetString(AUDError, device_not_3d_error);
+ }
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return nullptr;
+}
+
+static int
+Handle_set_relative(Handle* self, PyObject* args, void* nothing)
+{
+ if(!PyBool_Check(args))
+ {
+ PyErr_SetString(PyExc_TypeError, "Value is not a boolean!");
+ return -1;
+ }
+
+ bool relative = (args == Py_True);
+
+ try
+ {
+ I3DHandle* handle = dynamic_cast<I3DHandle*>(reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle)->get());
+ if(handle)
+ {
+ if(handle->setRelative(relative))
+ return 0;
+ PyErr_SetString(AUDError, "Couldn't set the relativeness!");
+ }
+ else
+ PyErr_SetString(AUDError, device_not_3d_error);
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_Handle_status_doc,
+ "Whether the sound is playing, paused or stopped (=invalid).");
+
+static PyObject *
+Handle_get_status(Handle* self, void* nothing)
+{
+ try
+ {
+ return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle))->getStatus());
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+PyDoc_STRVAR(M_aud_Handle_velocity_doc,
+ "The source's velocity in 3D space, a 3D tuple of floats.");
+
+static PyObject *
+Handle_get_velocity(Handle* self, void* nothing)
+{
+ try
+ {
+ I3DHandle* handle = dynamic_cast<I3DHandle*>(reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle)->get());
+ if(handle)
+ {
+ Vector3 v = handle->getVelocity();
+ return Py_BuildValue("(fff)", v.x(), v.y(), v.z());
+ }
+ else
+ {
+ PyErr_SetString(AUDError, device_not_3d_error);
+ }
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return nullptr;
+}
+
+static int
+Handle_set_velocity(Handle* self, PyObject* args, void* nothing)
+{
+ float x, y, z;
+
+ if(!PyArg_Parse(args, "(fff):velocity", &x, &y, &z))
+ return -1;
+
+ try
+ {
+ I3DHandle* handle = dynamic_cast<I3DHandle*>(reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle)->get());
+ if(handle)
+ {
+ Vector3 velocity(x, y, z);
+ if(handle->setVelocity(velocity))
+ return 0;
+ PyErr_SetString(AUDError, "Couldn't set the velocity!");
+ }
+ else
+ PyErr_SetString(AUDError, device_not_3d_error);
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_Handle_volume_doc,
+ "The volume of the sound.");
+
+static PyObject *
+Handle_get_volume(Handle* self, void* nothing)
+{
+ try
+ {
+ return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle))->getVolume());
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+Handle_set_volume(Handle* self, PyObject* args, void* nothing)
+{
+ float volume;
+
+ if(!PyArg_Parse(args, "f:volume", &volume))
+ return -1;
+
+ try
+ {
+ if((*reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle))->setVolume(volume))
+ return 0;
+ PyErr_SetString(AUDError, "Couldn't set the sound volume!");
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_Handle_volume_maximum_doc,
+ "The maximum volume of the source.\n\n"
+ ".. seealso:: :attr:`Device.distance_model`");
+
+static PyObject *
+Handle_get_volume_maximum(Handle* self, void* nothing)
+{
+ try
+ {
+ I3DHandle* handle = dynamic_cast<I3DHandle*>(reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle)->get());
+ if(handle)
+ {
+ return Py_BuildValue("f", handle->getVolumeMaximum());
+ }
+ else
+ {
+ PyErr_SetString(AUDError, device_not_3d_error);
+ return nullptr;
+ }
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+Handle_set_volume_maximum(Handle* self, PyObject* args, void* nothing)
+{
+ float volume;
+
+ if(!PyArg_Parse(args, "f:volume_maximum", &volume))
+ return -1;
+
+ try
+ {
+ I3DHandle* handle = dynamic_cast<I3DHandle*>(reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle)->get());
+ if(handle)
+ {
+ if(handle->setVolumeMaximum(volume))
+ return 0;
+ PyErr_SetString(AUDError, "Couldn't set the maximum volume!");
+ }
+ else
+ PyErr_SetString(AUDError, device_not_3d_error);
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_Handle_volume_minimum_doc,
+ "The minimum volume of the source.\n\n"
+ ".. seealso:: :attr:`Device.distance_model`");
+
+static PyObject *
+Handle_get_volume_minimum(Handle* self, void* nothing)
+{
+ try
+ {
+ I3DHandle* handle = dynamic_cast<I3DHandle*>(reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle)->get());
+ if(handle)
+ {
+ return Py_BuildValue("f", handle->getVolumeMinimum());
+ }
+ else
+ {
+ PyErr_SetString(AUDError, device_not_3d_error);
+ return nullptr;
+ }
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+Handle_set_volume_minimum(Handle* self, PyObject* args, void* nothing)
+{
+ float volume;
+
+ if(!PyArg_Parse(args, "f:volume_minimum", &volume))
+ return -1;
+
+ try
+ {
+ I3DHandle* handle = dynamic_cast<I3DHandle*>(reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle)->get());
+ if(handle)
+ {
+ if(handle->setVolumeMinimum(volume))
+ return 0;
+ PyErr_SetString(AUDError, "Couldn't set the minimum volume!");
+ }
+ else
+ PyErr_SetString(AUDError, device_not_3d_error);
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+static PyGetSetDef Handle_properties[] = {
+ {(char*)"attenuation", (getter)Handle_get_attenuation, (setter)Handle_set_attenuation,
+ M_aud_Handle_attenuation_doc, nullptr },
+ {(char*)"cone_angle_inner", (getter)Handle_get_cone_angle_inner, (setter)Handle_set_cone_angle_inner,
+ M_aud_Handle_cone_angle_inner_doc, nullptr },
+ {(char*)"cone_angle_outer", (getter)Handle_get_cone_angle_outer, (setter)Handle_set_cone_angle_outer,
+ M_aud_Handle_cone_angle_outer_doc, nullptr },
+ {(char*)"cone_volume_outer", (getter)Handle_get_cone_volume_outer, (setter)Handle_set_cone_volume_outer,
+ M_aud_Handle_cone_volume_outer_doc, nullptr },
+ {(char*)"distance_maximum", (getter)Handle_get_distance_maximum, (setter)Handle_set_distance_maximum,
+ M_aud_Handle_distance_maximum_doc, nullptr },
+ {(char*)"distance_reference", (getter)Handle_get_distance_reference, (setter)Handle_set_distance_reference,
+ M_aud_Handle_distance_reference_doc, nullptr },
+ {(char*)"keep", (getter)Handle_get_keep, (setter)Handle_set_keep,
+ M_aud_Handle_keep_doc, nullptr },
+ {(char*)"location", (getter)Handle_get_location, (setter)Handle_set_location,
+ M_aud_Handle_location_doc, nullptr },
+ {(char*)"loop_count", (getter)Handle_get_loop_count, (setter)Handle_set_loop_count,
+ M_aud_Handle_loop_count_doc, nullptr },
+ {(char*)"orientation", (getter)Handle_get_orientation, (setter)Handle_set_orientation,
+ M_aud_Handle_orientation_doc, nullptr },
+ {(char*)"pitch", (getter)Handle_get_pitch, (setter)Handle_set_pitch,
+ M_aud_Handle_pitch_doc, nullptr },
+ {(char*)"position", (getter)Handle_get_position, (setter)Handle_set_position,
+ M_aud_Handle_position_doc, nullptr },
+ {(char*)"relative", (getter)Handle_get_relative, (setter)Handle_set_relative,
+ M_aud_Handle_relative_doc, nullptr },
+ {(char*)"status", (getter)Handle_get_status, nullptr,
+ M_aud_Handle_status_doc, nullptr },
+ {(char*)"velocity", (getter)Handle_get_velocity, (setter)Handle_set_velocity,
+ M_aud_Handle_velocity_doc, nullptr },
+ {(char*)"volume", (getter)Handle_get_volume, (setter)Handle_set_volume,
+ M_aud_Handle_volume_doc, nullptr },
+ {(char*)"volume_maximum", (getter)Handle_get_volume_maximum, (setter)Handle_set_volume_maximum,
+ M_aud_Handle_volume_maximum_doc, nullptr },
+ {(char*)"volume_minimum", (getter)Handle_get_volume_minimum, (setter)Handle_set_volume_minimum,
+ M_aud_Handle_volume_minimum_doc, nullptr },
+ {nullptr} /* Sentinel */
+};
+
+PyDoc_STRVAR(M_aud_Handle_doc,
+ "Handle objects are playback handles that can be used to control "
+ "playback of a sound. If a sound is played back multiple times "
+ "then there are as many handles.");
+
+static PyTypeObject HandleType = {
+ PyVarObject_HEAD_INIT(nullptr, 0)
+ "aud.Handle", /* tp_name */
+ sizeof(Handle), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)Handle_dealloc,/* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_reserved */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ M_aud_Handle_doc, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ Handle_methods, /* tp_methods */
+ 0, /* tp_members */
+ Handle_properties, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
+};
+
+
+AUD_API PyObject* Handle_empty()
+{
+ return HandleType.tp_alloc(&HandleType, 0);
+}
+
+
+AUD_API Handle*checkHandle(PyObject* handle)
+{
+ if(!PyObject_TypeCheck(handle, &HandleType))
+ {
+ PyErr_SetString(PyExc_TypeError, "Object is not of type Handle!");
+ return nullptr;
+ }
+
+ return (Handle*)handle;
+}
+
+
+bool initializeHandle()
+{
+ return PyType_Ready(&HandleType) >= 0;
+}
+
+
+void addHandleToModule(PyObject* module)
+{
+ Py_INCREF(&HandleType);
+ PyModule_AddObject(module, "Handle", (PyObject *)&HandleType);
+}
+
+
diff --git a/extern/audaspace/bindings/python/PyHandle.h b/extern/audaspace/bindings/python/PyHandle.h
new file mode 100644
index 00000000000..95006c88da7
--- /dev/null
+++ b/extern/audaspace/bindings/python/PyHandle.h
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+#include <Python.h>
+#include "Audaspace.h"
+
+typedef void Reference_IHandle;
+
+typedef struct {
+ PyObject_HEAD
+ Reference_IHandle* handle;
+} Handle;
+
+extern AUD_API PyObject* Handle_empty();
+extern AUD_API Handle* checkHandle(PyObject* handle);
+
+bool initializeHandle();
+void addHandleToModule(PyObject* module);
diff --git a/extern/audaspace/bindings/python/PyImpulseResponse.cpp b/extern/audaspace/bindings/python/PyImpulseResponse.cpp
new file mode 100644
index 00000000000..5200c938511
--- /dev/null
+++ b/extern/audaspace/bindings/python/PyImpulseResponse.cpp
@@ -0,0 +1,137 @@
+/*******************************************************************************
+* Copyright 2009-2015 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "PyImpulseResponse.h"
+#include "PySound.h"
+
+#include "Exception.h"
+#include "fx/ImpulseResponse.h"
+#include "util/StreamBuffer.h"
+
+extern PyObject* AUDError;
+
+static PyObject *
+ImpulseResponse_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
+{
+ ImpulseResponseP* self = (ImpulseResponseP*)type->tp_alloc(type, 0);
+
+ if(self != nullptr)
+ {
+ PyObject* object;
+ if(!PyArg_ParseTuple(args, "O:sound", &object))
+ return nullptr;
+ Sound* sound = checkSound(object);
+
+ try
+ {
+ self->impulseResponse = new std::shared_ptr<aud::ImpulseResponse>(new aud::ImpulseResponse(std::make_shared<aud::StreamBuffer>(*reinterpret_cast<std::shared_ptr<aud::ISound>*>(sound->sound))));
+ }
+ catch(aud::Exception& e)
+ {
+ Py_DECREF(self);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)self;
+}
+
+static void
+ImpulseResponse_dealloc(ImpulseResponseP* self)
+{
+ if(self->impulseResponse)
+ delete reinterpret_cast<std::shared_ptr<aud::ImpulseResponse>*>(self->impulseResponse);
+ Py_TYPE(self)->tp_free((PyObject *)self);
+}
+
+static PyMethodDef ImpulseResponse_methods[] = {
+ { nullptr } /* Sentinel */
+};
+
+PyDoc_STRVAR(M_aud_ImpulseResponse_doc,
+ "An ImpulseResponse object represents a filter with which to convolve a sound.");
+
+PyTypeObject ImpulseResponseType = {
+ PyVarObject_HEAD_INIT(nullptr, 0)
+ "aud.ImpulseResponse", /* tp_name */
+ sizeof(ImpulseResponseP), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)ImpulseResponse_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_reserved */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ M_aud_ImpulseResponse_doc, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ ImpulseResponse_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ ImpulseResponse_new, /* tp_new */
+};
+
+AUD_API PyObject* ImpulseResponse_empty()
+{
+ return ImpulseResponseType.tp_alloc(&ImpulseResponseType, 0);
+}
+
+
+AUD_API ImpulseResponseP* checkImpulseResponse(PyObject* impulseResponse)
+{
+ if(!PyObject_TypeCheck(impulseResponse, &ImpulseResponseType))
+ {
+ PyErr_SetString(PyExc_TypeError, "Object is not of type ImpulseResponse!");
+ return nullptr;
+ }
+
+ return (ImpulseResponseP*)impulseResponse;
+}
+
+
+bool initializeImpulseResponse()
+{
+ return PyType_Ready(&ImpulseResponseType) >= 0;
+}
+
+
+void addImpulseResponseToModule(PyObject* module)
+{
+ Py_INCREF(&ImpulseResponseType);
+ PyModule_AddObject(module, "ImpulseResponse", (PyObject *)&ImpulseResponseType);
+}
diff --git a/extern/audaspace/bindings/python/PyImpulseResponse.h b/extern/audaspace/bindings/python/PyImpulseResponse.h
new file mode 100644
index 00000000000..3e974c0701c
--- /dev/null
+++ b/extern/audaspace/bindings/python/PyImpulseResponse.h
@@ -0,0 +1,33 @@
+/*******************************************************************************
+* Copyright 2009-2015 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+#include <Python.h>
+#include "Audaspace.h"
+
+typedef void Reference_ImpulseResponse;
+
+typedef struct {
+ PyObject_HEAD
+ Reference_ImpulseResponse* impulseResponse;
+} ImpulseResponseP;
+
+extern AUD_API PyObject* ImpulseResponse_empty();
+extern AUD_API ImpulseResponseP* checkImpulseResponse(PyObject* impulseResponse);
+
+bool initializeImpulseResponse();
+void addImpulseResponseToModule(PyObject* module); \ No newline at end of file
diff --git a/extern/audaspace/bindings/python/PyPlaybackManager.cpp b/extern/audaspace/bindings/python/PyPlaybackManager.cpp
new file mode 100644
index 00000000000..9b6614cae9a
--- /dev/null
+++ b/extern/audaspace/bindings/python/PyPlaybackManager.cpp
@@ -0,0 +1,389 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "PyPlaybackManager.h"
+#include "PySound.h"
+#include "PyHandle.h"
+#include "PyDevice.h"
+
+#include "Exception.h"
+#include "fx/PlaybackManager.h"
+
+extern PyObject* AUDError;
+
+static PyObject *
+PlaybackManager_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
+{
+ PlaybackManagerP* self = (PlaybackManagerP*)type->tp_alloc(type, 0);
+
+ if(self != nullptr)
+ {
+ PyObject* object;
+ if(!PyArg_ParseTuple(args, "O:catKey", &object))
+ return nullptr;
+ Device* device = checkDevice(object);
+
+ try
+ {
+ self->playbackManager = new std::shared_ptr<aud::PlaybackManager>(new aud::PlaybackManager(*reinterpret_cast<std::shared_ptr<aud::IDevice>*>(device->device)));
+ }
+ catch(aud::Exception& e)
+ {
+ Py_DECREF(self);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)self;
+}
+
+static void
+PlaybackManager_dealloc(PlaybackManagerP* self)
+{
+ if(self->playbackManager)
+ delete reinterpret_cast<std::shared_ptr<aud::PlaybackManager>*>(self->playbackManager);
+ Py_TYPE(self)->tp_free((PyObject *)self);
+}
+
+PyDoc_STRVAR(M_aud_PlaybackManager_play_doc,
+ "setVolume(sound, catKey)\n\n"
+ "Plays a sound through the playback manager and assigns it to a category.\n\n"
+ ":arg sound: The sound to play.\n"
+ ":type sound: :class:`Sound`\n"
+ ":arg catKey: the key of the category in which the sound will be added, if it doesn't exist, a new one will be created.\n"
+ ":type catKey: int\n"
+ ":return: The playback handle with which playback can be controlled with.\n"
+ ":rtype: :class:`Handle`");
+
+static PyObject *
+PlaybackManager_play(PlaybackManagerP* self, PyObject* args)
+{
+ PyObject* object;
+ unsigned int cat;
+
+ if(!PyArg_ParseTuple(args, "OI:catKey", &object, &cat))
+ return nullptr;
+
+ Sound* sound = checkSound(object);
+ if(!sound)
+ return nullptr;
+
+ Handle* handle;
+
+ handle = (Handle*)Handle_empty();
+ if(handle != nullptr)
+ {
+ try
+ {
+ handle->handle = new std::shared_ptr<aud::IHandle>((*reinterpret_cast<std::shared_ptr<aud::PlaybackManager>*>(self->playbackManager))->play(*reinterpret_cast<std::shared_ptr<aud::ISound>*>(sound->sound), cat));
+ }
+ catch(aud::Exception& e)
+ {
+ Py_DECREF(handle);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)handle;
+}
+
+PyDoc_STRVAR(M_aud_PlaybackManager_resume_doc,
+ "resume(catKey)\n\n"
+ "Resumes playback of the catgory.\n\n"
+ ":arg catKey: the key of the category.\n"
+ ":type catKey: int\n"
+ ":return: Whether the action succeeded.\n"
+ ":rtype: bool");
+
+static PyObject *
+PlaybackManager_resume(PlaybackManagerP* self, PyObject* args)
+{
+ unsigned int cat;
+
+ if(!PyArg_ParseTuple(args, "I:catKey", &cat))
+ return nullptr;
+
+ try
+ {
+ return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<aud::PlaybackManager>*>(self->playbackManager))->resume(cat));
+ }
+ catch(aud::Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+PyDoc_STRVAR(M_aud_PlaybackManager_pause_doc,
+ "pause(catKey)\n\n"
+ "Pauses playback of the category.\n\n"
+ ":arg catKey: the key of the category.\n"
+ ":type catKey: int\n"
+ ":return: Whether the action succeeded.\n"
+ ":rtype: bool");
+
+static PyObject *
+PlaybackManager_pause(PlaybackManagerP* self, PyObject* args)
+{
+ unsigned int cat;
+
+ if(!PyArg_ParseTuple(args, "I:catKey", &cat))
+ return nullptr;
+
+ try
+ {
+ return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<aud::PlaybackManager>*>(self->playbackManager))->pause(cat));
+ }
+ catch(aud::Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+PyDoc_STRVAR(M_aud_PlaybackManager_add_category_doc,
+ "addCategory(volume)\n\n"
+ "Adds a category with a custom volume.\n\n"
+ ":arg volume: The volume for ther new category.\n"
+ ":type volume: float\n"
+ ":return: The key of the new category.\n"
+ ":rtype: int\n\n");
+
+static PyObject *
+PlaybackManager_add_category(PlaybackManagerP* self, PyObject* args)
+{
+ float vol;
+
+ if(!PyArg_ParseTuple(args, "f:volume", &vol))
+ return nullptr;
+
+ try
+ {
+ return Py_BuildValue("I", (*reinterpret_cast<std::shared_ptr<aud::PlaybackManager>*>(self->playbackManager))->addCategory(vol));
+ }
+ catch(aud::Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+PyDoc_STRVAR(M_aud_PlaybackManager_get_volume_doc,
+ "getVolume(catKey)\n\n"
+ "Retrieves the volume of a category.\n\n"
+ ":arg catKey: the key of the category.\n"
+ ":type catKey: int\n"
+ ":return: The volume of the cateogry.\n"
+ ":rtype: float\n\n");
+
+static PyObject *
+PlaybackManager_get_volume(PlaybackManagerP* self, PyObject* args)
+{
+ unsigned int cat;
+
+ if(!PyArg_ParseTuple(args, "I:catKey", &cat))
+ return nullptr;
+
+ try
+ {
+ return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<aud::PlaybackManager>*>(self->playbackManager))->getVolume(cat));
+ }
+ catch(aud::Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+PyDoc_STRVAR(M_aud_PlaybackManager_set_volume_doc,
+ "setVolume(volume, catKey)\n\n"
+ "Changes the volume of a category.\n\n"
+ ":arg volume: the new volume value.\n"
+ ":type volume: float\n"
+ ":arg catKey: the key of the category.\n"
+ ":type catKey: int\n"
+ ":return: Whether the action succeeded.\n"
+ ":rtype: int\n\n");
+
+static PyObject *
+PlaybackManager_set_volume(PlaybackManagerP* self, PyObject* args)
+{
+ float volume;
+ unsigned int cat;
+
+ if(!PyArg_ParseTuple(args, "fI:volume", &volume, &cat))
+ return nullptr;
+
+ try
+ {
+ return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<aud::PlaybackManager>*>(self->playbackManager))->setVolume(volume, cat));
+ }
+ catch(aud::Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+PyDoc_STRVAR(M_aud_PlaybackManager_stop_doc,
+ "stop(catKey)\n\n"
+ "Stops playback of the category.\n\n"
+ ":arg catKey: the key of the category.\n"
+ ":type catKey: int\n"
+ ":return: Whether the action succeeded.\n"
+ ":rtype: bool\n\n");
+
+static PyObject *
+PlaybackManager_stop(PlaybackManagerP* self, PyObject* args)
+{
+ unsigned int cat;
+
+ if(!PyArg_ParseTuple(args, "I:catKey", &cat))
+ return nullptr;
+
+ try
+ {
+ return PyBool_FromLong((long)(*reinterpret_cast<std::shared_ptr<aud::PlaybackManager>*>(self->playbackManager))->stop(cat));
+ }
+ catch(aud::Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+PyDoc_STRVAR(M_aud_PlaybackManager_clean_doc,
+ "clean()\n\n"
+ "Cleans all the invalid and finished sound from the playback manager.\n\n");
+
+static PyObject *
+PlaybackManager_clean(PlaybackManagerP* self)
+{
+ try
+ {
+ (*reinterpret_cast<std::shared_ptr<aud::PlaybackManager>*>(self->playbackManager))->clean();
+ Py_RETURN_NONE;
+ }
+ catch(aud::Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static PyMethodDef PlaybackManager_methods[] = {
+ { "play", (PyCFunction)PlaybackManager_play, METH_VARARGS | METH_KEYWORDS,
+ M_aud_PlaybackManager_play_doc
+ },
+ { "resume", (PyCFunction)PlaybackManager_resume, METH_VARARGS,
+ M_aud_PlaybackManager_resume_doc
+ },
+ { "pause", (PyCFunction)PlaybackManager_pause, METH_VARARGS,
+ M_aud_PlaybackManager_pause_doc
+ },
+ { "stop", (PyCFunction)PlaybackManager_stop, METH_VARARGS,
+ M_aud_PlaybackManager_stop_doc
+ },
+ { "addCategory", (PyCFunction)PlaybackManager_add_category, METH_VARARGS,
+ M_aud_PlaybackManager_add_category_doc
+ },
+ { "getVolume", (PyCFunction)PlaybackManager_get_volume, METH_VARARGS,
+ M_aud_PlaybackManager_get_volume_doc
+ },
+ { "setVolume", (PyCFunction)PlaybackManager_set_volume, METH_VARARGS,
+ M_aud_PlaybackManager_set_volume_doc
+ },
+ { "clean", (PyCFunction)PlaybackManager_clean, METH_NOARGS,
+ M_aud_PlaybackManager_clean_doc
+ },
+ { nullptr } /* Sentinel */
+};
+
+PyDoc_STRVAR(M_aud_PlaybackManager_doc,
+ "A PlabackManager object allows to easily control groups os sounds organized in categories.");
+
+PyTypeObject PlaybackManagerType = {
+ PyVarObject_HEAD_INIT(nullptr, 0)
+ "aud.PlaybackManager", /* tp_name */
+ sizeof(PlaybackManagerP), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)PlaybackManager_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_reserved */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ M_aud_PlaybackManager_doc, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ PlaybackManager_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ PlaybackManager_new, /* tp_new */
+};
+
+AUD_API PyObject* PlaybackManager_empty()
+{
+ return PlaybackManagerType.tp_alloc(&PlaybackManagerType, 0);
+}
+
+
+AUD_API PlaybackManagerP* checkPlaybackManager(PyObject* playbackManager)
+{
+ if(!PyObject_TypeCheck(playbackManager, &PlaybackManagerType))
+ {
+ PyErr_SetString(PyExc_TypeError, "Object is not of type PlaybackManager!");
+ return nullptr;
+ }
+
+ return (PlaybackManagerP*)playbackManager;
+}
+
+
+bool initializePlaybackManager()
+{
+ return PyType_Ready(&PlaybackManagerType) >= 0;
+}
+
+
+void addPlaybackManagerToModule(PyObject* module)
+{
+ Py_INCREF(&PlaybackManagerType);
+ PyModule_AddObject(module, "PlaybackManager", (PyObject *)&PlaybackManagerType);
+}
diff --git a/extern/audaspace/bindings/python/PyPlaybackManager.h b/extern/audaspace/bindings/python/PyPlaybackManager.h
new file mode 100644
index 00000000000..f26df1b32d0
--- /dev/null
+++ b/extern/audaspace/bindings/python/PyPlaybackManager.h
@@ -0,0 +1,33 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+#include <Python.h>
+#include "Audaspace.h"
+
+typedef void Reference_PlaybackManager;
+
+typedef struct {
+ PyObject_HEAD
+ Reference_PlaybackManager* playbackManager;
+} PlaybackManagerP;
+
+extern AUD_API PyObject* PlaybackManager_empty();
+extern AUD_API PlaybackManagerP* checkPlaybackManager(PyObject* playbackManager);
+
+bool initializePlaybackManager();
+void addPlaybackManagerToModule(PyObject* module); \ No newline at end of file
diff --git a/extern/audaspace/bindings/python/PySequence.cpp b/extern/audaspace/bindings/python/PySequence.cpp
new file mode 100644
index 00000000000..d4773c743ee
--- /dev/null
+++ b/extern/audaspace/bindings/python/PySequence.cpp
@@ -0,0 +1,655 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "PySequence.h"
+
+#include "PySound.h"
+#include "PySequenceEntry.h"
+
+#include "sequence/AnimateableProperty.h"
+#include "sequence/Sequence.h"
+#include "Exception.h"
+
+#include <vector>
+#include <structmember.h>
+
+using aud::Channels;
+using aud::DistanceModel;
+using aud::Exception;
+using aud::ISound;
+using aud::AnimateableProperty;
+using aud::AnimateablePropertyType;
+using aud::Specs;
+
+extern PyObject* AUDError;
+
+// ====================================================================
+
+static void
+Sequence_dealloc(Sequence* self)
+{
+ if(self->sequence)
+ delete reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence);
+ Py_TYPE(self)->tp_free((PyObject *)self);
+}
+
+static PyObject *
+Sequence_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
+{
+ Sequence* self;
+
+ int channels = aud::CHANNELS_STEREO;
+ double rate = aud::RATE_48000;
+ float fps = 30.0f;
+ bool muted = false;
+ PyObject* mutedo = nullptr;
+
+ self = (Sequence*)type->tp_alloc(type, 0);
+ if(self != nullptr)
+ {
+ static const char* kwlist[] = {"channels", "rate", "fps", "muted", nullptr};
+
+ if(!PyArg_ParseTupleAndKeywords(args, kwds, "|idfO:Sequence", const_cast<char**>(kwlist), &channels, &rate, &fps, &mutedo))
+ {
+ Py_DECREF(self);
+ return nullptr;
+ }
+
+ if(mutedo)
+ {
+ if(!PyBool_Check(mutedo))
+ {
+ PyErr_SetString(PyExc_TypeError, "muted is not a boolean!");
+ return nullptr;
+ }
+
+ muted = mutedo == Py_True;
+ }
+
+ aud::Specs specs;
+ specs.channels = static_cast<aud::Channels>(channels);
+ specs.rate = rate;
+
+ try
+ {
+ self->sequence = new std::shared_ptr<aud::Sequence>(new aud::Sequence(specs, fps, muted));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(self);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)self;
+}
+
+PyDoc_STRVAR(M_aud_Sequence_add_doc,
+ "add()\n\n"
+ "Adds a new entry to the scene.\n"
+ ":arg sound: The sound this entry should play.\n"
+ ":type sound: :class:`Sound`\n"
+ ":arg begin: The start time.\n"
+ ":type begin: float\n"
+ ":arg end: The end time or a negative value if determined by the sound.\n"
+ ":type end: float\n"
+ ":arg skip: How much seconds should be skipped at the beginning.\n"
+ ":type skip: float\n"
+ ":return: The entry added.\n"
+ ":rtype: :class:`SequenceEntry`");
+
+static PyObject *
+Sequence_add(Sequence* self, PyObject* args, PyObject* kwds)
+{
+ PyObject* object;
+ float begin;
+ float end = -1.0f;
+ float skip = 0.0f;
+
+ static const char* kwlist[] = {"sound", "begin", "end", "skip", nullptr};
+
+ if(!PyArg_ParseTupleAndKeywords(args, kwds, "Of|ff:add", const_cast<char**>(kwlist), &object, &begin, &end, &skip))
+ return nullptr;
+
+ Sound* sound = checkSound(object);
+
+ if(!sound)
+ return nullptr;
+
+ SequenceEntry* entry;
+
+ entry = (SequenceEntry*)SequenceEntry_empty();
+ if(entry != nullptr)
+ {
+ try
+ {
+ entry->entry = new std::shared_ptr<aud::SequenceEntry>((*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->add(*reinterpret_cast<std::shared_ptr<ISound>*>(sound->sound), begin, end, skip));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(entry);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)entry;
+}
+
+PyDoc_STRVAR(M_aud_Sequence_remove_doc,
+ "reomve()\n\n"
+ "Adds a new entry to the scene.\n"
+ ":arg entry: The entry to remove.\n"
+ ":type entry: :class:`SequenceEntry`\n");
+
+static PyObject *
+Sequence_remove(Sequence* self, PyObject* args)
+{
+ PyObject* object;
+
+ if(!PyArg_ParseTuple(args, "O:remove", &object))
+ return nullptr;
+
+ SequenceEntry* entry = checkSequenceEntry(object);
+
+ if(!entry)
+ return nullptr;
+
+ try
+ {
+ (*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->remove(*reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(entry->entry));
+ Py_RETURN_NONE;
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(entry);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+PyDoc_STRVAR(M_aud_Sequence_setAnimationData_doc,
+ "setAnimationData()\n\n"
+ "Writes animation data to a sequence.\n\n"
+ ":arg type: The type of animation data.\n"
+ ":type type: int\n"
+ ":arg frame: The frame this data is for.\n"
+ ":type frame: int\n"
+ ":arg data: The data to write.\n"
+ ":type data: sequence of float\n"
+ ":arg animated: Whether the attribute is animated.\n"
+ ":type animated: bool");
+
+static PyObject *
+Sequence_setAnimationData(Sequence* self, PyObject* args)
+{
+ int type, frame;
+ PyObject* py_data;
+ Py_ssize_t py_data_len;
+ PyObject* animatedo;
+ bool animated;
+
+ if(!PyArg_ParseTuple(args, "iiOO:setAnimationData", &type, &frame, &py_data, &animatedo))
+ return nullptr;
+
+ if(!PySequence_Check(py_data))
+ {
+ PyErr_SetString(PyExc_TypeError, "Parameter is not a sequence!");
+ return nullptr;
+ }
+
+ py_data_len= PySequence_Size(py_data);
+
+ std::vector<float> data;
+ data.resize(py_data_len);
+
+ PyObject* py_value;
+ float value;
+
+ for(Py_ssize_t i = 0; i < py_data_len; i++)
+ {
+ py_value = PySequence_GetItem(py_data, i);
+ value= (float)PyFloat_AsDouble(py_value);
+ Py_DECREF(py_value);
+
+ if(value == -1.0f && PyErr_Occurred()) {
+ return nullptr;
+ }
+
+ data.push_back(value);
+ }
+
+ if(!PyBool_Check(animatedo))
+ {
+ PyErr_SetString(PyExc_TypeError, "animated is not a boolean!");
+ return nullptr;
+ }
+
+ animated = animatedo == Py_True;
+
+ try
+ {
+ AnimateableProperty* prop = (*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->getAnimProperty(static_cast<AnimateablePropertyType>(type));
+
+ if(prop->getCount() != py_data_len)
+ {
+ PyErr_SetString(PyExc_ValueError, "the amount of floats doesn't fit the animated property");
+ return nullptr;
+ }
+
+ if(animated)
+ {
+ if(frame >= 0)
+ prop->write(&data[0], frame, 1);
+ }
+ else
+ {
+ prop->write(&data[0]);
+ }
+ Py_RETURN_NONE;
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static PyMethodDef Sequence_methods[] = {
+ {"add", (PyCFunction)Sequence_add, METH_VARARGS | METH_KEYWORDS,
+ M_aud_Sequence_add_doc
+ },
+ {"remove", (PyCFunction)Sequence_remove, METH_VARARGS,
+ M_aud_Sequence_remove_doc
+ },
+ {"setAnimationData", (PyCFunction)Sequence_setAnimationData, METH_VARARGS,
+ M_aud_Sequence_setAnimationData_doc
+ },
+ {nullptr} /* Sentinel */
+};
+
+PyDoc_STRVAR(M_aud_Sequence_channels_doc,
+ "The channel count of the sequence.");
+
+static PyObject *
+Sequence_get_channels(Sequence* self, void* nothing)
+{
+ try
+ {
+ Specs specs = (*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->getSpecs();
+ return Py_BuildValue("i", specs.channels);
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+Sequence_set_channels(Sequence* self, PyObject* args, void* nothing)
+{
+ int channels;
+
+ if(!PyArg_Parse(args, "i:channels", &channels))
+ return -1;
+
+ try
+ {
+ std::shared_ptr<aud::Sequence> sequence = *reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence);
+ Specs specs = sequence->getSpecs();
+ specs.channels = static_cast<Channels>(channels);
+ sequence->setSpecs(specs);
+ return 0;
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return -1;
+ }
+}
+
+PyDoc_STRVAR(M_aud_Sequence_distance_model_doc,
+ "The distance model of the sequence.\n\n"
+ ".. seealso:: http://connect.creativelabs.com/openal/Documentation/OpenAL%201.1%20Specification.htm#_Toc199835864");
+
+static PyObject *
+Sequence_get_distance_model(Sequence* self, void* nothing)
+{
+ try
+ {
+ return Py_BuildValue("i", (*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->getDistanceModel());
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+Sequence_set_distance_model(Sequence* self, PyObject* args, void* nothing)
+{
+ int distance_model;
+
+ if(!PyArg_Parse(args, "i:distance_model", &distance_model))
+ return -1;
+
+ try
+ {
+ (*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->setDistanceModel(static_cast<DistanceModel>(distance_model));
+ return 0;
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return -1;
+ }
+}
+
+PyDoc_STRVAR(M_aud_Sequence_doppler_factor_doc,
+ "The doppler factor of the sequence.\n"
+ "This factor is a scaling factor for the velocity vectors in "
+ "doppler calculation. So a value bigger than 1 will exaggerate "
+ "the effect as it raises the velocity.");
+
+static PyObject *
+Sequence_get_doppler_factor(Sequence* self, void* nothing)
+{
+ try
+ {
+ return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->getDopplerFactor());
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+Sequence_set_doppler_factor(Sequence* self, PyObject* args, void* nothing)
+{
+ float factor;
+
+ if(!PyArg_Parse(args, "f:doppler_factor", &factor))
+ return -1;
+
+ try
+ {
+ (*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->setDopplerFactor(factor);
+ return 0;
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return -1;
+ }
+}
+
+PyDoc_STRVAR(M_aud_Sequence_fps_doc,
+ "The listeners's location in 3D space, a 3D tuple of floats.");
+
+static PyObject *
+Sequence_get_fps(Sequence* self, void* nothing)
+{
+ try
+ {
+ return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->getFPS());
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+Sequence_set_fps(Sequence* self, PyObject* args, void* nothing)
+{
+ float fps;
+
+ if(!PyArg_Parse(args, "f:fps", &fps))
+ return -1;
+
+ try
+ {
+ (*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->setFPS(fps);
+ return 0;
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return -1;
+ }
+}
+
+PyDoc_STRVAR(M_aud_Sequence_muted_doc,
+ "Whether the whole sequence is muted.\n");
+
+static PyObject *
+Sequence_get_muted(Sequence* self, void* nothing)
+{
+ try
+ {
+ std::shared_ptr<aud::Sequence>* sequence = reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence);
+ return PyBool_FromLong((long)(*sequence)->isMuted());
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+Sequence_set_muted(Sequence* self, PyObject* args, void* nothing)
+{
+ if(!PyBool_Check(args))
+ {
+ PyErr_SetString(PyExc_TypeError, "muted is not a boolean!");
+ return -1;
+ }
+
+ bool muted = args == Py_True;
+
+ try
+ {
+ std::shared_ptr<aud::Sequence>* sequence = reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence);
+ (*sequence)->mute(muted);
+ return 0;
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_Sequence_rate_doc,
+ "The sampling rate of the sequence in Hz.");
+
+static PyObject *
+Sequence_get_rate(Sequence* self, void* nothing)
+{
+ try
+ {
+ Specs specs = (*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->getSpecs();
+ return Py_BuildValue("d", specs.rate);
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+Sequence_set_rate(Sequence* self, PyObject* args, void* nothing)
+{
+ double rate;
+
+ if(!PyArg_Parse(args, "d:rate", &rate))
+ return -1;
+
+ try
+ {
+ std::shared_ptr<aud::Sequence> sequence = *reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence);
+ Specs specs = sequence->getSpecs();
+ specs.rate = rate;
+ sequence->setSpecs(specs);
+ return 0;
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return -1;
+ }
+}
+
+PyDoc_STRVAR(M_aud_Sequence_speed_of_sound_doc,
+ "The speed of sound of the sequence.\n"
+ "The speed of sound in air is typically 343.3 m/s.");
+
+static PyObject *
+Sequence_get_speed_of_sound(Sequence* self, void* nothing)
+{
+ try
+ {
+ return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->getSpeedOfSound());
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+Sequence_set_speed_of_sound(Sequence* self, PyObject* args, void* nothing)
+{
+ float speed;
+
+ if(!PyArg_Parse(args, "f:speed_of_sound", &speed))
+ return -1;
+
+ try
+ {
+ (*reinterpret_cast<std::shared_ptr<aud::Sequence>*>(self->sequence))->setSpeedOfSound(speed);
+ return 0;
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return -1;
+ }
+}
+
+static PyGetSetDef Sequence_properties[] = {
+ {(char*)"channels", (getter)Sequence_get_channels, (setter)Sequence_set_channels,
+ M_aud_Sequence_channels_doc, nullptr },
+ {(char*)"distance_model", (getter)Sequence_get_distance_model, (setter)Sequence_set_distance_model,
+ M_aud_Sequence_distance_model_doc, nullptr },
+ {(char*)"doppler_factor", (getter)Sequence_get_doppler_factor, (setter)Sequence_set_doppler_factor,
+ M_aud_Sequence_doppler_factor_doc, nullptr },
+ {(char*)"fps", (getter)Sequence_get_fps, (setter)Sequence_set_fps,
+ M_aud_Sequence_fps_doc, nullptr },
+ {(char*)"muted", (getter)Sequence_get_muted, (setter)Sequence_set_muted,
+ M_aud_Sequence_muted_doc, nullptr },
+ {(char*)"rate", (getter)Sequence_get_rate, (setter)Sequence_set_rate,
+ M_aud_Sequence_rate_doc, nullptr },
+ {(char*)"speed_of_sound", (getter)Sequence_get_speed_of_sound, (setter)Sequence_set_speed_of_sound,
+ M_aud_Sequence_speed_of_sound_doc, nullptr },
+ {nullptr} /* Sentinel */
+};
+
+PyDoc_STRVAR(M_aud_Sequence_doc,
+ "This sound represents sequenced entries to play a sound scene.");
+
+extern PyTypeObject SoundType;
+
+static PyTypeObject SequenceType = {
+ PyVarObject_HEAD_INIT(nullptr, 0)
+ "aud.Sequence", /* tp_name */
+ sizeof(Sequence), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)Sequence_dealloc,/* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_reserved */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ M_aud_Sequence_doc, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ Sequence_methods, /* tp_methods */
+ 0, /* tp_members */
+ Sequence_properties, /* tp_getset */
+ &SoundType, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ Sequence_new, /* tp_new */
+};
+
+AUD_API PyObject* Sequence_empty()
+{
+ return SequenceType.tp_alloc(&SequenceType, 0);
+}
+
+
+AUD_API Sequence* checkSequence(PyObject* sequence)
+{
+ if(!PyObject_TypeCheck(sequence, &SequenceType))
+ {
+ PyErr_SetString(PyExc_TypeError, "Object is not of type Sequence!");
+ return nullptr;
+ }
+
+ return (Sequence*)sequence;
+}
+
+
+bool initializeSequence()
+{
+ return PyType_Ready(&SequenceType) >= 0;
+}
+
+
+void addSequenceToModule(PyObject* module)
+{
+ Py_INCREF(&SequenceType);
+ PyModule_AddObject(module, "Sequence", (PyObject *)&SequenceType);
+}
diff --git a/extern/audaspace/bindings/python/PySequence.h b/extern/audaspace/bindings/python/PySequence.h
new file mode 100644
index 00000000000..17855121dda
--- /dev/null
+++ b/extern/audaspace/bindings/python/PySequence.h
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+#include <Python.h>
+#include "Audaspace.h"
+
+typedef void Reference_Sequence;
+
+typedef struct {
+ PyObject_HEAD
+ Reference_Sequence* sequence;
+} Sequence;
+
+extern AUD_API PyObject* Sequence_empty();
+extern AUD_API Sequence* checkSequence(PyObject* sequence);
+
+bool initializeSequence();
+void addSequenceToModule(PyObject* module);
diff --git a/extern/audaspace/bindings/python/PySequenceEntry.cpp b/extern/audaspace/bindings/python/PySequenceEntry.cpp
new file mode 100644
index 00000000000..e6a034ed880
--- /dev/null
+++ b/extern/audaspace/bindings/python/PySequenceEntry.cpp
@@ -0,0 +1,740 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "PySequenceEntry.h"
+
+#include "PySound.h"
+
+#include "Exception.h"
+#include "sequence/AnimateableProperty.h"
+#include "sequence/SequenceEntry.h"
+
+#include <structmember.h>
+#include <vector>
+
+using aud::Exception;
+using aud::AnimateableProperty;
+using aud::AnimateablePropertyType;
+using aud::ISound;
+
+extern PyObject* AUDError;
+
+// ====================================================================
+
+static void
+SequenceEntry_dealloc(SequenceEntry* self)
+{
+ if(self->entry)
+ delete reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
+ Py_TYPE(self)->tp_free((PyObject *)self);
+}
+
+PyDoc_STRVAR(M_aud_SequenceEntry_move_doc,
+ "move()\n\n"
+ "Moves the entry.\n\n"
+ ":arg begin: The new start time.\n"
+ ":type begin: float\n"
+ ":arg end: The new end time or a negative value if unknown.\n"
+ ":type end: float\n"
+ ":arg skip: How many seconds to skip at the beginning.\n"
+ ":type skip: float\n");
+
+static PyObject *
+SequenceEntry_move(SequenceEntry* self, PyObject* args)
+{
+ float begin, end, skip;
+
+ if(!PyArg_ParseTuple(args, "fff:move", &begin, &end, &skip))
+ return nullptr;
+
+ try
+ {
+ (*reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry))->move(begin, end, skip);
+ Py_RETURN_NONE;
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+PyDoc_STRVAR(M_aud_SequenceEntry_setAnimationData_doc,
+ "setAnimationData()\n\n"
+ "Writes animation data to a sequenced entry.\n\n"
+ ":arg type: The type of animation data.\n"
+ ":type type: int\n"
+ ":arg frame: The frame this data is for.\n"
+ ":type frame: int\n"
+ ":arg data: The data to write.\n"
+ ":type data: sequence of float\n"
+ ":arg animated: Whether the attribute is animated.\n"
+ ":type animated: bool");
+
+static PyObject *
+SequenceEntry_setAnimationData(SequenceEntry* self, PyObject* args)
+{
+ int type, frame;
+ PyObject* py_data;
+ Py_ssize_t py_data_len;
+ PyObject* animatedo;
+ bool animated;
+
+ if(!PyArg_ParseTuple(args, "iiOO:setAnimationData", &type, &frame, &py_data, &animatedo))
+ return nullptr;
+
+ if(!PySequence_Check(py_data))
+ {
+ PyErr_SetString(PyExc_TypeError, "Parameter is not a sequence!");
+ return nullptr;
+ }
+
+ py_data_len= PySequence_Size(py_data);
+
+ std::vector<float> data;
+ data.resize(py_data_len);
+
+ PyObject* py_value;
+ float value;
+
+ for(Py_ssize_t i = 0; i < py_data_len; i++)
+ {
+ py_value = PySequence_GetItem(py_data, i);
+ value= (float)PyFloat_AsDouble(py_value);
+ Py_DECREF(py_value);
+
+ if(value == -1.0f && PyErr_Occurred()) {
+ return nullptr;
+ }
+
+ data.push_back(value);
+ }
+
+ if(!PyBool_Check(animatedo))
+ {
+ PyErr_SetString(PyExc_TypeError, "animated is not a boolean!");
+ return nullptr;
+ }
+
+ animated = animatedo == Py_True;
+
+ try
+ {
+ AnimateableProperty* prop = (*reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry))->getAnimProperty(static_cast<AnimateablePropertyType>(type));
+
+ if(prop->getCount() != py_data_len)
+ {
+ PyErr_SetString(PyExc_ValueError, "the amount of floats doesn't fit the animated property");
+ return nullptr;
+ }
+
+ if(animated)
+ {
+ if(frame >= 0)
+ prop->write(&data[0], frame, 1);
+ }
+ else
+ {
+ prop->write(&data[0]);
+ }
+ Py_RETURN_NONE;
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static PyMethodDef SequenceEntry_methods[] = {
+ {"move", (PyCFunction)SequenceEntry_move, METH_VARARGS,
+ M_aud_SequenceEntry_move_doc
+ },
+ {"setAnimationData", (PyCFunction)SequenceEntry_setAnimationData, METH_VARARGS,
+ M_aud_SequenceEntry_setAnimationData_doc
+ },
+ {nullptr} /* Sentinel */
+};
+
+PyDoc_STRVAR(M_aud_SequenceEntry_attenuation_doc,
+ "This factor is used for distance based attenuation of the "
+ "source.\n\n"
+ ".. seealso:: :attr:`Device.distance_model`");
+
+static PyObject *
+SequenceEntry_get_attenuation(SequenceEntry* self, void* nothing)
+{
+ try
+ {
+ std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
+ return Py_BuildValue("f", (*entry)->getAttenuation());
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+SequenceEntry_set_attenuation(SequenceEntry* self, PyObject* args, void* nothing)
+{
+ float factor;
+
+ if(!PyArg_Parse(args, "f:attenuation", &factor))
+ return -1;
+
+ try
+ {
+ std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
+ (*entry)->setAttenuation(factor);
+ return 0;
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_SequenceEntry_cone_angle_inner_doc,
+ "The opening angle of the inner cone of the source. If the cone "
+ "values of a source are set there are two (audible) cones with "
+ "the apex at the :attr:`location` of the source and with infinite "
+ "height, heading in the direction of the source's "
+ ":attr:`orientation`.\n"
+ "In the inner cone the volume is normal. Outside the outer cone "
+ "the volume will be :attr:`cone_volume_outer` and in the area "
+ "between the volume will be interpolated linearly.");
+
+static PyObject *
+SequenceEntry_get_cone_angle_inner(SequenceEntry* self, void* nothing)
+{
+ try
+ {
+ std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
+ return Py_BuildValue("f", (*entry)->getConeAngleInner());
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+SequenceEntry_set_cone_angle_inner(SequenceEntry* self, PyObject* args, void* nothing)
+{
+ float angle;
+
+ if(!PyArg_Parse(args, "f:cone_angle_inner", &angle))
+ return -1;
+
+ try
+ {
+ std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
+ (*entry)->setConeAngleInner(angle);
+ return 0;
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_SequenceEntry_cone_angle_outer_doc,
+ "The opening angle of the outer cone of the source.\n\n"
+ ".. seealso:: :attr:`cone_angle_inner`");
+
+static PyObject *
+SequenceEntry_get_cone_angle_outer(SequenceEntry* self, void* nothing)
+{
+ try
+ {
+ std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
+ return Py_BuildValue("f", (*entry)->getConeAngleOuter());
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+SequenceEntry_set_cone_angle_outer(SequenceEntry* self, PyObject* args, void* nothing)
+{
+ float angle;
+
+ if(!PyArg_Parse(args, "f:cone_angle_outer", &angle))
+ return -1;
+
+ try
+ {
+ std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
+ (*entry)->setConeAngleOuter(angle);
+ return 0;
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_SequenceEntry_cone_volume_outer_doc,
+ "The volume outside the outer cone of the source.\n\n"
+ ".. seealso:: :attr:`cone_angle_inner`");
+
+static PyObject *
+SequenceEntry_get_cone_volume_outer(SequenceEntry* self, void* nothing)
+{
+ try
+ {
+ std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
+ return Py_BuildValue("f", (*entry)->getConeVolumeOuter());
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+SequenceEntry_set_cone_volume_outer(SequenceEntry* self, PyObject* args, void* nothing)
+{
+ float volume;
+
+ if(!PyArg_Parse(args, "f:cone_volume_outer", &volume))
+ return -1;
+
+ try
+ {
+ std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
+ (*entry)->setConeVolumeOuter(volume);
+ return 0;
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_SequenceEntry_distance_maximum_doc,
+ "The maximum distance of the source.\n"
+ "If the listener is further away the source volume will be 0.\n\n"
+ ".. seealso:: :attr:`Device.distance_model`");
+
+static PyObject *
+SequenceEntry_get_distance_maximum(SequenceEntry* self, void* nothing)
+{
+ try
+ {
+ std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
+ return Py_BuildValue("f", (*entry)->getDistanceMaximum());
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+SequenceEntry_set_distance_maximum(SequenceEntry* self, PyObject* args, void* nothing)
+{
+ float distance;
+
+ if(!PyArg_Parse(args, "f:distance_maximum", &distance))
+ return -1;
+
+ try
+ {
+ std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
+ (*entry)->setDistanceMaximum(distance);
+ return 0;
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_SequenceEntry_distance_reference_doc,
+ "The reference distance of the source.\n"
+ "At this distance the volume will be exactly :attr:`volume`.\n\n"
+ ".. seealso:: :attr:`Device.distance_model`");
+
+static PyObject *
+SequenceEntry_get_distance_reference(SequenceEntry* self, void* nothing)
+{
+ try
+ {
+ std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
+ return Py_BuildValue("f", (*entry)->getDistanceReference());
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+SequenceEntry_set_distance_reference(SequenceEntry* self, PyObject* args, void* nothing)
+{
+ float distance;
+
+ if(!PyArg_Parse(args, "f:distance_reference", &distance))
+ return -1;
+
+ try
+ {
+ std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
+ (*entry)->setDistanceReference(distance);
+ return 0;
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_SequenceEntry_muted_doc,
+ "Whether the entry is muted.\n");
+
+static PyObject *
+SequenceEntry_get_muted(SequenceEntry* self, void* nothing)
+{
+ try
+ {
+ std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
+ return PyBool_FromLong((long)(*entry)->isMuted());
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+SequenceEntry_set_muted(SequenceEntry* self, PyObject* args, void* nothing)
+{
+ if(!PyBool_Check(args))
+ {
+ PyErr_SetString(PyExc_TypeError, "muted is not a boolean!");
+ return -1;
+ }
+
+ bool muted = args == Py_True;
+
+ try
+ {
+ std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
+ (*entry)->mute(muted);
+ return 0;
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_SequenceEntry_relative_doc,
+ "Whether the source's location, velocity and orientation is relative or absolute to the listener.");
+
+static PyObject *
+SequenceEntry_get_relative(SequenceEntry* self, void* nothing)
+{
+ try
+ {
+ std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
+ return PyBool_FromLong((long)(*entry)->isRelative());
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return nullptr;
+}
+
+static int
+SequenceEntry_set_relative(SequenceEntry* self, PyObject* args, void* nothing)
+{
+ if(!PyBool_Check(args))
+ {
+ PyErr_SetString(PyExc_TypeError, "Value is not a boolean!");
+ return -1;
+ }
+
+ bool relative = (args == Py_True);
+
+ try
+ {
+ std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
+ (*entry)->setRelative(relative);
+ return 0;
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_SequenceEntry_sound_doc,
+ "The sound the entry is representing and will be played in the sequence.");
+
+static PyObject *
+SequenceEntry_get_sound(SequenceEntry* self, void* nothing)
+{
+ try
+ {
+ std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
+ Sound* object = (Sound*) Sound_empty();
+ if(object)
+ {
+ object->sound = new std::shared_ptr<ISound>((*entry)->getSound());
+ return (PyObject *) object;
+ }
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return nullptr;
+}
+
+static int
+SequenceEntry_set_sound(SequenceEntry* self, PyObject* args, void* nothing)
+{
+ Sound* sound = checkSound(args);
+
+ if(!sound)
+ return -1;
+
+ try
+ {
+ std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
+ (*entry)->setSound(*reinterpret_cast<std::shared_ptr<ISound>*>(sound->sound));
+ return 0;
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_SequenceEntry_volume_maximum_doc,
+ "The maximum volume of the source.\n\n"
+ ".. seealso:: :attr:`Device.distance_model`");
+
+static PyObject *
+SequenceEntry_get_volume_maximum(SequenceEntry* self, void* nothing)
+{
+ try
+ {
+ std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
+ return Py_BuildValue("f", (*entry)->getVolumeMaximum());
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+SequenceEntry_set_volume_maximum(SequenceEntry* self, PyObject* args, void* nothing)
+{
+ float volume;
+
+ if(!PyArg_Parse(args, "f:volume_maximum", &volume))
+ return -1;
+
+ try
+ {
+ std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
+ (*entry)->setVolumeMaximum(volume);
+ return 0;
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+PyDoc_STRVAR(M_aud_SequenceEntry_volume_minimum_doc,
+ "The minimum volume of the source.\n\n"
+ ".. seealso:: :attr:`Device.distance_model`");
+
+static PyObject *
+SequenceEntry_get_volume_minimum(SequenceEntry* self, void* nothing)
+{
+ try
+ {
+ std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
+ return Py_BuildValue("f", (*entry)->getVolumeMinimum());
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static int
+SequenceEntry_set_volume_minimum(SequenceEntry* self, PyObject* args, void* nothing)
+{
+ float volume;
+
+ if(!PyArg_Parse(args, "f:volume_minimum", &volume))
+ return -1;
+
+ try
+ {
+ std::shared_ptr<aud::SequenceEntry>* entry = reinterpret_cast<std::shared_ptr<aud::SequenceEntry>*>(self->entry);
+ (*entry)->setVolumeMinimum(volume);
+ return 0;
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+static PyGetSetDef SequenceEntry_properties[] = {
+ {(char*)"attenuation", (getter)SequenceEntry_get_attenuation, (setter)SequenceEntry_set_attenuation,
+ M_aud_SequenceEntry_attenuation_doc, nullptr },
+ {(char*)"cone_angle_inner", (getter)SequenceEntry_get_cone_angle_inner, (setter)SequenceEntry_set_cone_angle_inner,
+ M_aud_SequenceEntry_cone_angle_inner_doc, nullptr },
+ {(char*)"cone_angle_outer", (getter)SequenceEntry_get_cone_angle_outer, (setter)SequenceEntry_set_cone_angle_outer,
+ M_aud_SequenceEntry_cone_angle_outer_doc, nullptr },
+ {(char*)"cone_volume_outer", (getter)SequenceEntry_get_cone_volume_outer, (setter)SequenceEntry_set_cone_volume_outer,
+ M_aud_SequenceEntry_cone_volume_outer_doc, nullptr },
+ {(char*)"distance_maximum", (getter)SequenceEntry_get_distance_maximum, (setter)SequenceEntry_set_distance_maximum,
+ M_aud_SequenceEntry_distance_maximum_doc, nullptr },
+ {(char*)"distance_reference", (getter)SequenceEntry_get_distance_reference, (setter)SequenceEntry_set_distance_reference,
+ M_aud_SequenceEntry_distance_reference_doc, nullptr },
+ {(char*)"muted", (getter)SequenceEntry_get_muted, (setter)SequenceEntry_set_muted,
+ M_aud_SequenceEntry_muted_doc, nullptr },
+ {(char*)"relative", (getter)SequenceEntry_get_relative, (setter)SequenceEntry_set_relative,
+ M_aud_SequenceEntry_relative_doc, nullptr },
+ {(char*)"sound", (getter)SequenceEntry_get_sound, (setter)SequenceEntry_set_sound,
+ M_aud_SequenceEntry_sound_doc, nullptr },
+ {(char*)"volume_maximum", (getter)SequenceEntry_get_volume_maximum, (setter)SequenceEntry_set_volume_maximum,
+ M_aud_SequenceEntry_volume_maximum_doc, nullptr },
+ {(char*)"volume_minimum", (getter)SequenceEntry_get_volume_minimum, (setter)SequenceEntry_set_volume_minimum,
+ M_aud_SequenceEntry_volume_minimum_doc, nullptr },
+ {nullptr} /* Sentinel */
+};
+
+PyDoc_STRVAR(M_aud_SequenceEntry_doc,
+ "SequenceEntry objects represent an entry of a sequenced sound.");
+
+static PyTypeObject SequenceEntryType = {
+ PyVarObject_HEAD_INIT(nullptr, 0)
+ "aud.SequenceEntry", /* tp_name */
+ sizeof(SequenceEntry), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)SequenceEntry_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_reserved */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ M_aud_SequenceEntry_doc, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ SequenceEntry_methods, /* tp_methods */
+ 0, /* tp_members */
+ SequenceEntry_properties, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
+};
+
+AUD_API PyObject* SequenceEntry_empty()
+{
+ return SequenceEntryType.tp_alloc(&SequenceEntryType, 0);
+}
+
+
+AUD_API SequenceEntry* checkSequenceEntry(PyObject* entry)
+{
+ if(!PyObject_TypeCheck(entry, &SequenceEntryType))
+ {
+ PyErr_SetString(PyExc_TypeError, "Object is not of type SequenceEntry!");
+ return nullptr;
+ }
+
+ return (SequenceEntry*)entry;
+}
+
+
+bool initializeSequenceEntry()
+{
+ return PyType_Ready(&SequenceEntryType) >= 0;
+}
+
+
+void addSequenceEntryToModule(PyObject* module)
+{
+ Py_INCREF(&SequenceEntryType);
+ PyModule_AddObject(module, "SequenceEntry", (PyObject *)&SequenceEntryType);
+}
diff --git a/extern/audaspace/bindings/python/PySequenceEntry.h b/extern/audaspace/bindings/python/PySequenceEntry.h
new file mode 100644
index 00000000000..7bb4ae4a281
--- /dev/null
+++ b/extern/audaspace/bindings/python/PySequenceEntry.h
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+#include <Python.h>
+#include "Audaspace.h"
+
+typedef void Reference_SequenceEntry;
+
+typedef struct {
+ PyObject_HEAD
+ Reference_SequenceEntry* entry;
+} SequenceEntry;
+
+extern AUD_API PyObject* SequenceEntry_empty();
+extern AUD_API SequenceEntry* checkSequenceEntry(PyObject* entry);
+
+bool initializeSequenceEntry();
+void addSequenceEntryToModule(PyObject* module);
diff --git a/extern/audaspace/bindings/python/PySound.cpp b/extern/audaspace/bindings/python/PySound.cpp
new file mode 100644
index 00000000000..2ab1974be49
--- /dev/null
+++ b/extern/audaspace/bindings/python/PySound.cpp
@@ -0,0 +1,1966 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "PySound.h"
+#include "PySource.h"
+#include "PyThreadPool.h"
+
+#ifdef WITH_CONVOLUTION
+#include "PyHRTF.h"
+#include "PyImpulseResponse.h"
+#endif
+
+#include "Exception.h"
+#include "file/File.h"
+#include "file/FileWriter.h"
+#include "util/StreamBuffer.h"
+#include "generator/Sawtooth.h"
+#include "generator/Silence.h"
+#include "generator/Sine.h"
+#include "generator/Square.h"
+#include "generator/Triangle.h"
+#include "fx/Accumulator.h"
+#include "fx/ADSR.h"
+#include "fx/Delay.h"
+#include "fx/Envelope.h"
+#include "fx/Fader.h"
+#include "fx/Highpass.h"
+#include "fx/IIRFilter.h"
+#include "fx/Limiter.h"
+#include "fx/Loop.h"
+#include "fx/Lowpass.h"
+#include "fx/MutableSound.h"
+#include "fx/Pitch.h"
+#include "fx/Reverse.h"
+#include "fx/SoundList.h"
+#include "fx/Sum.h"
+#include "fx/Threshold.h"
+#include "fx/Volume.h"
+#include "respec/ChannelMapper.h"
+#include "respec/ChannelMapperReader.h"
+#include "respec/LinearResample.h"
+#include "respec/JOSResample.h"
+#include "respec/JOSResampleReader.h"
+#include "sequence/Double.h"
+#include "sequence/PingPong.h"
+#include "sequence/Superpose.h"
+
+#ifdef WITH_CONVOLUTION
+#include "fx/BinauralSound.h"
+#include "fx/ConvolverSound.h"
+#endif
+
+#include <cstring>
+#include <structmember.h>
+#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
+#include <numpy/ndarrayobject.h>
+
+using namespace aud;
+
+extern PyObject* AUDError;
+
+static void
+Sound_dealloc(Sound* self)
+{
+ if(self->sound)
+ delete reinterpret_cast<std::shared_ptr<ISound>*>(self->sound);
+ Py_TYPE(self)->tp_free((PyObject *)self);
+}
+
+static PyObject *
+Sound_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
+{
+ Sound* self;
+
+ self = (Sound*)type->tp_alloc(type, 0);
+ if(self != nullptr)
+ {
+ static const char* kwlist[] = {"filename", nullptr};
+ const char* filename = nullptr;
+
+ if(!PyArg_ParseTupleAndKeywords(args, kwds, "s:Sound", const_cast<char**>(kwlist), &filename))
+ {
+ Py_DECREF(self);
+ return nullptr;
+ }
+
+ try
+ {
+ self->sound = new std::shared_ptr<ISound>(new File(filename));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(self);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)self;
+}
+
+PyDoc_STRVAR(M_aud_Sound_data_doc,
+ "data()\n\n"
+ "Retrieves the data of the sound as numpy array.\n\n"
+ ":return: A two dimensional numpy float array.\n"
+ ":rtype: :class:`numpy.ndarray`\n\n"
+ ".. note:: Best efficiency with cached sounds.");
+
+static PyObject *
+Sound_data(Sound* self)
+{
+ std::shared_ptr<ISound> sound = *reinterpret_cast<std::shared_ptr<ISound>*>(self->sound);
+
+ auto stream_buffer = std::dynamic_pointer_cast<StreamBuffer>(sound);
+ if(!stream_buffer)
+ stream_buffer = std::make_shared<StreamBuffer>(sound);
+ Specs specs = stream_buffer->getSpecs();
+ auto buffer = stream_buffer->getBuffer();
+
+ npy_intp dimensions[2];
+ dimensions[0] = buffer->getSize() / AUD_SAMPLE_SIZE(specs);
+ dimensions[1] = specs.channels;
+
+ PyArrayObject* array = reinterpret_cast<PyArrayObject*>(PyArray_SimpleNew(2, dimensions, NPY_FLOAT));
+
+ sample_t* data = reinterpret_cast<sample_t*>(PyArray_DATA(array));
+
+ std::memcpy(data, buffer->getBuffer(), buffer->getSize());
+
+ Py_INCREF(array);
+
+ return reinterpret_cast<PyObject*>(array);
+}
+
+PyDoc_STRVAR(M_aud_Sound_write_doc,
+ "write(filename, rate, channels, format, container, codec, bitrate, buffersize)\n\n"
+ "Writes the sound to a file.\n\n"
+ ":arg filename: The path to write to.\n"
+ ":type filename: string\n"
+ ":arg rate: The sample rate to write with.\n"
+ ":type rate: int\n"
+ ":arg channels: The number of channels to write with.\n"
+ ":type channels: int\n"
+ ":arg format: The sample format to write with.\n"
+ ":type format: int\n"
+ ":arg container: The container format for the file.\n"
+ ":type container: int\n"
+ ":arg codec: The codec to use in the file.\n"
+ ":type codec: int\n"
+ ":arg bitrate: The bitrate to write with.\n"
+ ":type bitrate: int\n"
+ ":arg buffersize: The size of the writing buffer.\n"
+ ":type buffersize: int\n");
+
+static PyObject *
+Sound_write(Sound* self, PyObject* args, PyObject* kwds)
+{
+ const char* filename = nullptr;
+ int rate = RATE_INVALID;
+ Channels channels = CHANNELS_INVALID;
+ SampleFormat format = FORMAT_INVALID;
+ Container container = CONTAINER_INVALID;
+ Codec codec = CODEC_INVALID;
+ int bitrate = 0;
+ int buffersize = 0;
+
+ static const char* kwlist[] = {"filename", "rate", "channels", "format", "container", "codec", "bitrate", "buffersize", nullptr};
+
+ if(!PyArg_ParseTupleAndKeywords(args, kwds, "s|iiiiiii:write", const_cast<char**>(kwlist), &filename, &rate, &channels, &format, &container, &codec, &bitrate, &buffersize))
+ return nullptr;
+
+ try
+ {
+ std::shared_ptr<IReader> reader = (*reinterpret_cast<std::shared_ptr<ISound>*>(self->sound))->createReader();
+
+ DeviceSpecs specs;
+ specs.specs = reader->getSpecs();
+
+ if((rate != RATE_INVALID) && (specs.rate != rate))
+ {
+ specs.rate = rate;
+ reader = std::make_shared<JOSResampleReader>(reader, rate);
+ }
+
+ if((channels != CHANNELS_INVALID) && (specs.channels != channels))
+ {
+ specs.channels = channels;
+ reader = std::make_shared<ChannelMapperReader>(reader, channels);
+ }
+
+ if(format == FORMAT_INVALID)
+ format = FORMAT_S16;
+ specs.format = format;
+
+ const char* invalid_container_error = "Container could not be determined from filename.";
+
+ if(container == CONTAINER_INVALID)
+ {
+ std::string path = filename;
+
+ if(path.length() < 4)
+ {
+ PyErr_SetString(AUDError, invalid_container_error);
+ return nullptr;
+ }
+
+ std::string extension = path.substr(path.length() - 4);
+
+ if(extension == ".ac3")
+ container = CONTAINER_AC3;
+ else if(extension == "flac")
+ container = CONTAINER_FLAC;
+ else if(extension == ".mkv")
+ container = CONTAINER_MATROSKA;
+ else if(extension == ".mp2")
+ container = CONTAINER_MP2;
+ else if(extension == ".mp3")
+ container = CONTAINER_MP3;
+ else if(extension == ".ogg")
+ container = CONTAINER_OGG;
+ else if(extension == ".wav")
+ container = CONTAINER_WAV;
+ else
+ {
+ PyErr_SetString(AUDError, invalid_container_error);
+ return nullptr;
+ }
+ }
+
+ if(codec == CODEC_INVALID)
+ {
+ switch(container)
+ {
+ case CONTAINER_AC3:
+ codec = CODEC_AC3;
+ break;
+ case CONTAINER_FLAC:
+ codec = CODEC_FLAC;
+ break;
+ case CONTAINER_MATROSKA:
+ codec = CODEC_OPUS;
+ break;
+ case CONTAINER_MP2:
+ codec = CODEC_MP2;
+ break;
+ case CONTAINER_MP3:
+ codec = CODEC_MP3;
+ break;
+ case CONTAINER_OGG:
+ codec = CODEC_VORBIS;
+ break;
+ case CONTAINER_WAV:
+ codec = CODEC_PCM;
+ break;
+ default:
+ PyErr_SetString(AUDError, "Unknown container, cannot select default codec.");
+ return nullptr;
+ }
+ }
+
+ if(buffersize <= 0)
+ buffersize = AUD_DEFAULT_BUFFER_SIZE;
+
+ std::shared_ptr<IWriter> writer = FileWriter::createWriter(filename, specs, container, codec, bitrate);
+ FileWriter::writeReader(reader, writer, 0, buffersize);
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+
+ Py_RETURN_NONE;
+}
+
+PyDoc_STRVAR(M_aud_Sound_buffer_doc,
+ "buffer(data, rate)\n\n"
+ "Creates a sound from a data buffer.\n\n"
+ ":arg data: The data as two dimensional numpy array.\n"
+ ":type data: numpy.ndarray\n"
+ ":arg rate: The sample rate.\n"
+ ":type rate: double\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`");
+
+static PyObject *
+Sound_buffer(PyTypeObject* type, PyObject* args)
+{
+ PyArrayObject* array = nullptr;
+ double rate = RATE_INVALID;
+
+ if(!PyArg_ParseTuple(args, "Od:buffer", &array, &rate))
+ return nullptr;
+
+ if((!PyObject_TypeCheck(reinterpret_cast<PyObject*>(array), &PyArray_Type)) || (PyArray_TYPE(array) != NPY_FLOAT))
+ {
+ PyErr_SetString(PyExc_TypeError, "The data needs to be supplied as float32 numpy array!");
+ return nullptr;
+ }
+
+ if(PyArray_NDIM(array) > 2)
+ {
+ PyErr_SetString(PyExc_TypeError, "The array needs to have one or two dimensions!");
+ return nullptr;
+ }
+
+ if(rate <= 0)
+ {
+ PyErr_SetString(PyExc_TypeError, "The sample rate has to be positive!");
+ return nullptr;
+ }
+
+ Specs specs;
+ specs.rate = rate;
+ specs.channels = CHANNELS_MONO;
+
+ if(PyArray_NDIM(array) == 2)
+ specs.channels = static_cast<Channels>(PyArray_DIM(array, 1));
+
+ int size = PyArray_DIM(array, 0) * AUD_SAMPLE_SIZE(specs);
+
+ std::shared_ptr<Buffer> buffer = std::make_shared<Buffer>(size);
+
+ std::memcpy(buffer->getBuffer(), PyArray_DATA(array), size);
+
+ Sound* self;
+
+ self = (Sound*)type->tp_alloc(type, 0);
+ if(self != nullptr)
+ {
+ try
+ {
+ self->sound = new std::shared_ptr<StreamBuffer>(new StreamBuffer(buffer, specs));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(self);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)self;
+}
+
+PyDoc_STRVAR(M_aud_Sound_cache_doc,
+ "cache()\n\n"
+ "Caches a sound into RAM.\n"
+ "This saves CPU usage needed for decoding and file access if the "
+ "underlying sound reads from a file on the harddisk, but it "
+ "consumes a lot of memory.\n\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`\n\n"
+ ".. note:: Only known-length factories can be buffered.\n\n"
+ ".. warning:: Raw PCM data needs a lot of space, only buffer "
+ "short factories.");
+
+static PyObject *
+Sound_cache(Sound* self)
+{
+ PyTypeObject* type = Py_TYPE(self);
+ Sound* parent = (Sound*)type->tp_alloc(type, 0);
+
+ if(parent != nullptr)
+ {
+ try
+ {
+ parent->sound = new std::shared_ptr<ISound>(new StreamBuffer(*reinterpret_cast<std::shared_ptr<ISound>*>(self->sound)));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(parent);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)parent;
+}
+
+PyDoc_STRVAR(M_aud_Sound_file_doc,
+ "file(filename)\n\n"
+ "Creates a sound object of a sound file.\n\n"
+ ":arg filename: Path of the file.\n"
+ ":type filename: string\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`\n\n"
+ ".. warning:: If the file doesn't exist or can't be read you will "
+ "not get an exception immediately, but when you try to start "
+ "playback of that sound.");
+
+static PyObject *
+Sound_file(PyTypeObject* type, PyObject* args)
+{
+ const char* filename = nullptr;
+
+ if(!PyArg_ParseTuple(args, "s:file", &filename))
+ return nullptr;
+
+ Sound* self;
+
+ self = (Sound*)type->tp_alloc(type, 0);
+ if(self != nullptr)
+ {
+ try
+ {
+ self->sound = new std::shared_ptr<ISound>(new File(filename));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(self);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)self;
+}
+
+PyDoc_STRVAR(M_aud_Sound_sawtooth_doc,
+ "sawtooth(frequency, rate=48000)\n\n"
+ "Creates a sawtooth sound which plays a sawtooth wave.\n\n"
+ ":arg frequency: The frequency of the sawtooth wave in Hz.\n"
+ ":type frequency: float\n"
+ ":arg rate: The sampling rate in Hz. It's recommended to set this "
+ "value to the playback device's samling rate to avoid resamping.\n"
+ ":type rate: int\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`");
+
+static PyObject *
+Sound_sawtooth(PyTypeObject* type, PyObject* args)
+{
+ float frequency;
+ double rate = 48000;
+
+ if(!PyArg_ParseTuple(args, "f|d:sawtooth", &frequency, &rate))
+ return nullptr;
+
+ Sound* self;
+
+ self = (Sound*)type->tp_alloc(type, 0);
+ if(self != nullptr)
+ {
+ try
+ {
+ self->sound = new std::shared_ptr<ISound>(new Sawtooth(frequency, (SampleRate)rate));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(self);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)self;
+}
+
+PyDoc_STRVAR(M_aud_Sound_silence_doc,
+ "silence()\n\n"
+ "Creates a silence sound which plays simple silence.\n\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`");
+
+static PyObject *
+Sound_silence(PyTypeObject* type)
+{
+ Sound* self;
+
+ self = (Sound*)type->tp_alloc(type, 0);
+ if(self != nullptr)
+ {
+ try
+ {
+ self->sound = new std::shared_ptr<ISound>(new Silence());
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(self);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)self;
+}
+
+PyDoc_STRVAR(M_aud_Sound_sine_doc,
+ "sine(frequency, rate=48000)\n\n"
+ "Creates a sine sound which plays a sine wave.\n\n"
+ ":arg frequency: The frequency of the sine wave in Hz.\n"
+ ":type frequency: float\n"
+ ":arg rate: The sampling rate in Hz. It's recommended to set this "
+ "value to the playback device's samling rate to avoid resamping.\n"
+ ":type rate: int\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`");
+
+static PyObject *
+Sound_sine(PyTypeObject* type, PyObject* args)
+{
+ float frequency;
+ double rate = 48000;
+
+ if(!PyArg_ParseTuple(args, "f|d:sine", &frequency, &rate))
+ return nullptr;
+
+ Sound* self;
+
+ self = (Sound*)type->tp_alloc(type, 0);
+ if(self != nullptr)
+ {
+ try
+ {
+ self->sound = new std::shared_ptr<ISound>(new Sine(frequency, (SampleRate)rate));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(self);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)self;
+}
+
+PyDoc_STRVAR(M_aud_Sound_square_doc,
+ "square(frequency, rate=48000)\n\n"
+ "Creates a square sound which plays a square wave.\n\n"
+ ":arg frequency: The frequency of the square wave in Hz.\n"
+ ":type frequency: float\n"
+ ":arg rate: The sampling rate in Hz. It's recommended to set this "
+ "value to the playback device's samling rate to avoid resamping.\n"
+ ":type rate: int\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`");
+
+static PyObject *
+Sound_square(PyTypeObject* type, PyObject* args)
+{
+ float frequency;
+ double rate = 48000;
+
+ if(!PyArg_ParseTuple(args, "f|d:square", &frequency, &rate))
+ return nullptr;
+
+ Sound* self;
+
+ self = (Sound*)type->tp_alloc(type, 0);
+ if(self != nullptr)
+ {
+ try
+ {
+ self->sound = new std::shared_ptr<ISound>(new Square(frequency, (SampleRate)rate));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(self);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)self;
+}
+
+PyDoc_STRVAR(M_aud_Sound_triangle_doc,
+ "triangle(frequency, rate=48000)\n\n"
+ "Creates a triangle sound which plays a triangle wave.\n\n"
+ ":arg frequency: The frequency of the triangle wave in Hz.\n"
+ ":type frequency: float\n"
+ ":arg rate: The sampling rate in Hz. It's recommended to set this "
+ "value to the playback device's samling rate to avoid resamping.\n"
+ ":type rate: int\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`");
+
+static PyObject *
+Sound_triangle(PyTypeObject* type, PyObject* args)
+{
+ float frequency;
+ double rate = 48000;
+
+ if(!PyArg_ParseTuple(args, "f|d:triangle", &frequency, &rate))
+ return nullptr;
+
+ Sound* self;
+
+ self = (Sound*)type->tp_alloc(type, 0);
+ if(self != nullptr)
+ {
+ try
+ {
+ self->sound = new std::shared_ptr<ISound>(new Triangle(frequency, (SampleRate)rate));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(self);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)self;
+}
+
+PyDoc_STRVAR(M_aud_Sound_accumulate_doc,
+ "accumulate(additive=False)\n\n"
+ "Accumulates a sound by summing over positive input differences thus generating a monotonic sigal. "
+ "If additivity is set to true negative input differences get added too, but positive ones with a factor of two. "
+ "Note that with additivity the signal is not monotonic anymore.\n\n"
+ ":arg additive: Whether the accumulation should be additive or not.\n"
+ ":type time: bool\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`");
+
+static PyObject *
+Sound_accumulate(Sound* self, PyObject* args)
+{
+ bool additive = false;
+ PyObject* additiveo;
+
+ if(!PyArg_ParseTuple(args, "|O:accumulate", &additiveo))
+ return nullptr;
+
+ PyTypeObject* type = Py_TYPE(self);
+ Sound* parent = (Sound*)type->tp_alloc(type, 0);
+
+ if(parent != nullptr)
+ {
+ if(additiveo != nullptr)
+ {
+ if(!PyBool_Check(additiveo))
+ {
+ PyErr_SetString(PyExc_TypeError, "additive is not a boolean!");
+ return nullptr;
+ }
+
+ additive = additiveo == Py_True;
+ }
+
+ try
+ {
+ parent->sound = new std::shared_ptr<ISound>(new Accumulator(*reinterpret_cast<std::shared_ptr<ISound>*>(self->sound), additive));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(parent);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)parent;
+}
+
+PyDoc_STRVAR(M_aud_Sound_ADSR_doc,
+ "ADSR(attack,decay,sustain,release)\n\n"
+ "Attack-Decay-Sustain-Release envelopes the volume of a sound. "
+ "Note: there is currently no way to trigger the release with this API.\n\n"
+ ":arg attack: The attack time in seconds.\n"
+ ":type attack: float\n"
+ ":arg decay: The decay time in seconds.\n"
+ ":type decay: float\n"
+ ":arg sustain: The sustain level.\n"
+ ":type sustain: float\n"
+ ":arg release: The release level.\n"
+ ":type release: float\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`");
+
+static PyObject *
+Sound_ADSR(Sound* self, PyObject* args)
+{
+ float attack, decay, sustain, release;
+
+ if(!PyArg_ParseTuple(args, "ffff:ADSR", &attack, &decay, &sustain, &release))
+ return nullptr;
+
+ PyTypeObject* type = Py_TYPE(self);
+ Sound* parent = (Sound*)type->tp_alloc(type, 0);
+
+ if(parent != nullptr)
+ {
+ try
+ {
+ parent->sound = new std::shared_ptr<ISound>(new ADSR(*reinterpret_cast<std::shared_ptr<ISound>*>(self->sound), attack, decay, sustain, release));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(parent);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)parent;
+}
+
+PyDoc_STRVAR(M_aud_Sound_delay_doc,
+ "delay(time)\n\n"
+ "Delays by playing adding silence in front of the other sound's "
+ "data.\n\n"
+ ":arg time: How many seconds of silence should be added before "
+ "the sound.\n"
+ ":type time: float\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`");
+
+static PyObject *
+Sound_delay(Sound* self, PyObject* args)
+{
+ float delay;
+
+ if(!PyArg_ParseTuple(args, "f:delay", &delay))
+ return nullptr;
+
+ PyTypeObject* type = Py_TYPE(self);
+ Sound* parent = (Sound*)type->tp_alloc(type, 0);
+
+ if(parent != nullptr)
+ {
+ try
+ {
+ parent->sound = new std::shared_ptr<ISound>(new Delay(*reinterpret_cast<std::shared_ptr<ISound>*>(self->sound), delay));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(parent);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)parent;
+}
+
+PyDoc_STRVAR(M_aud_Sound_envelope_doc,
+ "envelope(attack, release, threshold, arthreshold)\n\n"
+ "Delays by playing adding silence in front of the other sound's "
+ "data.\n\n"
+ ":arg attack: The attack factor.\n"
+ ":type attack: float\n"
+ ":arg release: The release factor.\n"
+ ":type release: float\n"
+ ":arg threshold: The general threshold value.\n"
+ ":type threshold: float\n"
+ ":arg arthreshold: The attack/release threshold value.\n"
+ ":type arthreshold: float\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`");
+
+static PyObject *
+Sound_envelope(Sound* self, PyObject* args)
+{
+ float attack, release, threshold, arthreshold;
+
+ if(!PyArg_ParseTuple(args, "ffff:envelope", &attack, &release, &threshold, &arthreshold))
+ return nullptr;
+
+ PyTypeObject* type = Py_TYPE(self);
+ Sound* parent = (Sound*)type->tp_alloc(type, 0);
+
+ if(parent != nullptr)
+ {
+ try
+ {
+ parent->sound = new std::shared_ptr<ISound>(new Envelope(*reinterpret_cast<std::shared_ptr<ISound>*>(self->sound), attack, release, threshold, arthreshold));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(parent);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)parent;
+}
+
+PyDoc_STRVAR(M_aud_Sound_fadein_doc,
+ "fadein(start, length)\n\n"
+ "Fades a sound in by raising the volume linearly in the given "
+ "time interval.\n\n"
+ ":arg start: Time in seconds when the fading should start.\n"
+ ":type start: float\n"
+ ":arg length: Time in seconds how long the fading should last.\n"
+ ":type length: float\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`\n\n"
+ ".. note:: Before the fade starts it plays silence.");
+
+static PyObject *
+Sound_fadein(Sound* self, PyObject* args)
+{
+ float start, length;
+
+ if(!PyArg_ParseTuple(args, "ff:fadein", &start, &length))
+ return nullptr;
+
+ PyTypeObject* type = Py_TYPE(self);
+ Sound* parent = (Sound*)type->tp_alloc(type, 0);
+
+ if(parent != nullptr)
+ {
+ try
+ {
+ parent->sound = new std::shared_ptr<ISound>(new Fader(*reinterpret_cast<std::shared_ptr<ISound>*>(self->sound), FADE_IN, start, length));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(parent);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)parent;
+}
+
+PyDoc_STRVAR(M_aud_Sound_fadeout_doc,
+ "fadeout(start, length)\n\n"
+ "Fades a sound in by lowering the volume linearly in the given "
+ "time interval.\n\n"
+ ":arg start: Time in seconds when the fading should start.\n"
+ ":type start: float\n"
+ ":arg length: Time in seconds how long the fading should last.\n"
+ ":type length: float\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`\n\n"
+ ".. note:: After the fade this sound plays silence, so that "
+ "the length of the sound is not altered.");
+
+static PyObject *
+Sound_fadeout(Sound* self, PyObject* args)
+{
+ float start, length;
+
+ if(!PyArg_ParseTuple(args, "ff:fadeout", &start, &length))
+ return nullptr;
+
+ PyTypeObject* type = Py_TYPE(self);
+ Sound* parent = (Sound*)type->tp_alloc(type, 0);
+
+ if(parent != nullptr)
+ {
+ try
+ {
+ parent->sound = new std::shared_ptr<ISound>(new Fader(*reinterpret_cast<std::shared_ptr<ISound>*>(self->sound), FADE_OUT, start, length));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(parent);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)parent;
+}
+
+PyDoc_STRVAR(M_aud_Sound_filter_doc,
+ "filter(b, a = (1))\n\n"
+ "Filters a sound with the supplied IIR filter coefficients.\n"
+ "Without the second parameter you'll get a FIR filter.\n"
+ "If the first value of the a sequence is 0 it will be set to 1 "
+ "automatically.\n"
+ "If the first value of the a sequence is neither 0 nor 1, all "
+ "filter coefficients will be scaled by this value so that it is 1 "
+ "in the end, you don't have to scale yourself.\n\n"
+ ":arg b: The nominator filter coefficients.\n"
+ ":type b: sequence of float\n"
+ ":arg a: The denominator filter coefficients.\n"
+ ":type a: sequence of float\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`");
+
+static PyObject *
+Sound_filter(Sound* self, PyObject* args)
+{
+ PyObject* py_b;
+ PyObject* py_a = nullptr;
+ Py_ssize_t py_a_len;
+ Py_ssize_t py_b_len;
+
+ if(!PyArg_ParseTuple(args, "O|O:filter", &py_b, &py_a))
+ return nullptr;
+
+ if(!PySequence_Check(py_b) || (py_a != nullptr && !PySequence_Check(py_a)))
+ {
+ PyErr_SetString(PyExc_TypeError, "Parameter is not a sequence!");
+ return nullptr;
+ }
+
+ py_a_len= py_a ? PySequence_Size(py_a) : 0;
+ py_b_len= PySequence_Size(py_b);
+
+ if(!py_b_len || ((py_a != nullptr) && !py_a_len))
+ {
+ PyErr_SetString(PyExc_ValueError, "The sequence has to contain at least one value!");
+ return nullptr;
+ }
+
+ std::vector<float> a, b;
+ PyObject* py_value;
+ float value;
+
+ for(Py_ssize_t i = 0; i < py_b_len; i++)
+ {
+ py_value = PySequence_GetItem(py_b, i);
+ value= (float)PyFloat_AsDouble(py_value);
+ Py_DECREF(py_value);
+
+ if(value == -1.0f && PyErr_Occurred()) {
+ return nullptr;
+ }
+
+ b.push_back(value);
+ }
+
+ if(py_a)
+ {
+ for(Py_ssize_t i = 0; i < py_a_len; i++)
+ {
+ py_value = PySequence_GetItem(py_a, i);
+ value= (float)PyFloat_AsDouble(py_value);
+ Py_DECREF(py_value);
+
+ if(value == -1.0f && PyErr_Occurred()) {
+ return nullptr;
+ }
+
+ a.push_back(value);
+ }
+
+ if(a[0] == 0)
+ a[0] = 1;
+ }
+ else
+ a.push_back(1);
+
+ PyTypeObject* type = Py_TYPE(self);
+ Sound* parent = (Sound*)type->tp_alloc(type, 0);
+
+ if(parent != nullptr)
+ {
+ try
+ {
+ parent->sound = new std::shared_ptr<ISound>(new IIRFilter(*reinterpret_cast<std::shared_ptr<ISound>*>(self->sound), b, a));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(parent);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)parent;
+}
+
+PyDoc_STRVAR(M_aud_Sound_highpass_doc,
+ "highpass(frequency, Q=0.5)\n\n"
+ "Creates a second order highpass filter based on the transfer "
+ "function H(s) = s^2 / (s^2 + s/Q + 1)\n\n"
+ ":arg frequency: The cut off trequency of the highpass.\n"
+ ":type frequency: float\n"
+ ":arg Q: Q factor of the lowpass.\n"
+ ":type Q: float\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`");
+
+static PyObject *
+Sound_highpass(Sound* self, PyObject* args)
+{
+ float frequency;
+ float Q = 0.5;
+
+ if(!PyArg_ParseTuple(args, "f|f:highpass", &frequency, &Q))
+ return nullptr;
+
+ PyTypeObject* type = Py_TYPE(self);
+ Sound* parent = (Sound*)type->tp_alloc(type, 0);
+
+ if(parent != nullptr)
+ {
+ try
+ {
+ parent->sound = new std::shared_ptr<ISound>(new Highpass(*reinterpret_cast<std::shared_ptr<ISound>*>(self->sound), frequency, Q));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(parent);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)parent;
+}
+
+PyDoc_STRVAR(M_aud_Sound_limit_doc,
+ "limit(start, end)\n\n"
+ "Limits a sound within a specific start and end time.\n\n"
+ ":arg start: Start time in seconds.\n"
+ ":type start: float\n"
+ ":arg end: End time in seconds.\n"
+ ":type end: float\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`");
+
+static PyObject *
+Sound_limit(Sound* self, PyObject* args)
+{
+ float start, end;
+
+ if(!PyArg_ParseTuple(args, "ff:limit", &start, &end))
+ return nullptr;
+
+ PyTypeObject* type = Py_TYPE(self);
+ Sound* parent = (Sound*)type->tp_alloc(type, 0);
+
+ if(parent != nullptr)
+ {
+ try
+ {
+ parent->sound = new std::shared_ptr<ISound>(new Limiter(*reinterpret_cast<std::shared_ptr<ISound>*>(self->sound), start, end));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(parent);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)parent;
+}
+
+PyDoc_STRVAR(M_aud_Sound_loop_doc,
+ "loop(count)\n\n"
+ "Loops a sound.\n\n"
+ ":arg count: How often the sound should be looped. "
+ "Negative values mean endlessly.\n"
+ ":type count: integer\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`\n\n"
+ ".. note:: This is a filter function, you might consider using "
+ ":attr:`Handle.loop_count` instead.");
+
+static PyObject *
+Sound_loop(Sound* self, PyObject* args)
+{
+ int loop;
+
+ if(!PyArg_ParseTuple(args, "i:loop", &loop))
+ return nullptr;
+
+ PyTypeObject* type = Py_TYPE(self);
+ Sound* parent = (Sound*)type->tp_alloc(type, 0);
+
+ if(parent != nullptr)
+ {
+ try
+ {
+ parent->sound = new std::shared_ptr<ISound>(new Loop(*reinterpret_cast<std::shared_ptr<ISound>*>(self->sound), loop));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(parent);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)parent;
+}
+
+PyDoc_STRVAR(M_aud_Sound_lowpass_doc,
+ "lowpass(frequency, Q=0.5)\n\n"
+ "Creates a second order lowpass filter based on the transfer "
+ "function H(s) = 1 / (s^2 + s/Q + 1)\n\n"
+ ":arg frequency: The cut off trequency of the lowpass.\n"
+ ":type frequency: float\n"
+ ":arg Q: Q factor of the lowpass.\n"
+ ":type Q: float\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`");
+
+static PyObject *
+Sound_lowpass(Sound* self, PyObject* args)
+{
+ float frequency;
+ float Q = 0.5;
+
+ if(!PyArg_ParseTuple(args, "f|f:lowpass", &frequency, &Q))
+ return nullptr;
+
+ PyTypeObject* type = Py_TYPE(self);
+ Sound* parent = (Sound*)type->tp_alloc(type, 0);
+
+ if(parent != nullptr)
+ {
+ try
+ {
+ parent->sound = new std::shared_ptr<ISound>(new Lowpass(*reinterpret_cast<std::shared_ptr<ISound>*>(self->sound), frequency, Q));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(parent);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)parent;
+}
+
+PyDoc_STRVAR(M_aud_Sound_pitch_doc,
+ "pitch(factor)\n\n"
+ "Changes the pitch of a sound with a specific factor.\n\n"
+ ":arg factor: The factor to change the pitch with.\n"
+ ":type factor: float\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`\n\n"
+ ".. note:: This is done by changing the sample rate of the "
+ "underlying sound, which has to be an integer, so the factor "
+ "value rounded and the factor may not be 100 % accurate.\n\n"
+ ".. note:: This is a filter function, you might consider using "
+ ":attr:`Handle.pitch` instead.");
+
+static PyObject *
+Sound_pitch(Sound* self, PyObject* args)
+{
+ float factor;
+
+ if(!PyArg_ParseTuple(args, "f:pitch", &factor))
+ return nullptr;
+
+ PyTypeObject* type = Py_TYPE(self);
+ Sound* parent = (Sound*)type->tp_alloc(type, 0);
+
+ if(parent != nullptr)
+ {
+ try
+ {
+ parent->sound = new std::shared_ptr<ISound>(new Pitch(*reinterpret_cast<std::shared_ptr<ISound>*>(self->sound), factor));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(parent);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)parent;
+}
+
+PyDoc_STRVAR(M_aud_Sound_rechannel_doc,
+ "rechannel(channels)\n\n"
+ "Rechannels the sound.\n\n"
+ ":arg channels: The new channel configuration.\n"
+ ":type channels: int\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`");
+
+static PyObject *
+Sound_rechannel(Sound* self, PyObject* args)
+{
+ int channels;
+
+ if(!PyArg_ParseTuple(args, "i:rechannel", &channels))
+ return nullptr;
+
+ PyTypeObject* type = Py_TYPE(self);
+ Sound* parent = (Sound*)type->tp_alloc(type, 0);
+
+ if(parent != nullptr)
+ {
+ try
+ {
+ DeviceSpecs specs;
+ specs.channels = static_cast<Channels>(channels);
+ specs.rate = RATE_INVALID;
+ specs.format = FORMAT_INVALID;
+ parent->sound = new std::shared_ptr<ISound>(new ChannelMapper(*reinterpret_cast<std::shared_ptr<ISound>*>(self->sound), specs));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(parent);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)parent;
+}
+
+PyDoc_STRVAR(M_aud_Sound_resample_doc,
+ "resample(rate, high_quality)\n\n"
+ "Resamples the sound.\n\n"
+ ":arg rate: The new sample rate.\n"
+ ":type rate: double\n"
+ ":arg high_quality: When true use a higher quality but slower resampler.\n"
+ ":type high_quality: bool\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`");
+
+static PyObject *
+Sound_resample(Sound* self, PyObject* args)
+{
+ double rate;
+ PyObject* high_qualityo;
+ bool high_quality = false;
+
+ if(!PyArg_ParseTuple(args, "d|O:resample", &rate, &high_qualityo))
+ return nullptr;
+
+ if(!PyBool_Check(high_qualityo))
+ {
+ PyErr_SetString(PyExc_TypeError, "high_quality is not a boolean!");
+ return nullptr;
+ }
+
+ high_quality = high_qualityo == Py_True;
+
+ PyTypeObject* type = Py_TYPE(self);
+ Sound* parent = (Sound*)type->tp_alloc(type, 0);
+
+ if(parent != nullptr)
+ {
+ try
+ {
+ DeviceSpecs specs;
+ specs.channels = CHANNELS_INVALID;
+ specs.rate = rate;
+ specs.format = FORMAT_INVALID;
+ if(high_quality)
+ parent->sound = new std::shared_ptr<ISound>(new JOSResample(*reinterpret_cast<std::shared_ptr<ISound>*>(self->sound), specs));
+ else
+ parent->sound = new std::shared_ptr<ISound>(new LinearResample(*reinterpret_cast<std::shared_ptr<ISound>*>(self->sound), specs));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(parent);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)parent;
+}
+
+PyDoc_STRVAR(M_aud_Sound_reverse_doc,
+ "reverse()\n\n"
+ "Plays a sound reversed.\n\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`\n\n"
+ ".. note:: The sound has to have a finite length and has to be "
+ "seekable. It's recommended to use this only with factories with "
+ "fast and accurate seeking, which is not true for encoded audio "
+ "files, such ones should be buffered using :meth:`cache` before "
+ "being played reversed.\n\n"
+ ".. warning:: If seeking is not accurate in the underlying sound "
+ "you'll likely hear skips/jumps/cracks.");
+
+static PyObject *
+Sound_reverse(Sound* self)
+{
+ PyTypeObject* type = Py_TYPE(self);
+ Sound* parent = (Sound*)type->tp_alloc(type, 0);
+
+ if(parent != nullptr)
+ {
+ try
+ {
+ parent->sound = new std::shared_ptr<ISound>(new Reverse(*reinterpret_cast<std::shared_ptr<ISound>*>(self->sound)));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(parent);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)parent;
+}
+
+PyDoc_STRVAR(M_aud_Sound_sum_doc,
+ "sum()\n\n"
+ "Sums the samples of a sound.\n\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`");
+
+static PyObject *
+Sound_sum(Sound* self)
+{
+ PyTypeObject* type = Py_TYPE(self);
+ Sound* parent = (Sound*)type->tp_alloc(type, 0);
+
+ if(parent != nullptr)
+ {
+ try
+ {
+ parent->sound = new std::shared_ptr<ISound>(new Sum(*reinterpret_cast<std::shared_ptr<ISound>*>(self->sound)));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(parent);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)parent;
+}
+
+PyDoc_STRVAR(M_aud_Sound_threshold_doc,
+ "threshold(threshold = 0)\n\n"
+ "Makes a threshold wave out of an audio wave by setting all samples "
+ "with a amplitude >= threshold to 1, all <= -threshold to -1 and "
+ "all between to 0.\n\n"
+ ":arg threshold: Threshold value over which an amplitude counts "
+ "non-zero.\n"
+ ":type threshold: float\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`");
+
+static PyObject *
+Sound_threshold(Sound* self, PyObject* args)
+{
+ float threshold = 0;
+
+ if(!PyArg_ParseTuple(args, "|f:threshold", &threshold))
+ return nullptr;
+
+ PyTypeObject* type = Py_TYPE(self);
+ Sound* parent = (Sound*)type->tp_alloc(type, 0);
+
+ if(parent != nullptr)
+ {
+ try
+ {
+ parent->sound = new std::shared_ptr<ISound>(new Threshold(*reinterpret_cast<std::shared_ptr<ISound>*>(self->sound), threshold));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(parent);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)parent;
+}
+
+PyDoc_STRVAR(M_aud_Sound_volume_doc,
+ "volume(volume)\n\n"
+ "Changes the volume of a sound.\n\n"
+ ":arg volume: The new volume..\n"
+ ":type volume: float\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`\n\n"
+ ".. note:: Should be in the range [0, 1] to avoid clipping.\n\n"
+ ".. note:: This is a filter function, you might consider using "
+ ":attr:`Handle.volume` instead.");
+
+static PyObject *
+Sound_volume(Sound* self, PyObject* args)
+{
+ float volume;
+
+ if(!PyArg_ParseTuple(args, "f:volume", &volume))
+ return nullptr;
+
+ PyTypeObject* type = Py_TYPE(self);
+ Sound* parent = (Sound*)type->tp_alloc(type, 0);
+
+ if(parent != nullptr)
+ {
+ try
+ {
+ parent->sound = new std::shared_ptr<ISound>(new Volume(*reinterpret_cast<std::shared_ptr<ISound>*>(self->sound), volume));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(parent);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)parent;
+}
+
+PyDoc_STRVAR(M_aud_Sound_join_doc,
+ "join(sound)\n\n"
+ "Plays two factories in sequence.\n\n"
+ ":arg sound: The sound to play second.\n"
+ ":type sound: :class:`Sound`\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`\n\n"
+ ".. note:: The two factories have to have the same specifications "
+ "(channels and samplerate).");
+
+static PyObject *
+Sound_join(Sound* self, PyObject* object)
+{
+ PyTypeObject* type = Py_TYPE(self);
+
+ if(!PyObject_TypeCheck(object, type))
+ {
+ PyErr_SetString(PyExc_TypeError, "Object has to be of type Sound!");
+ return nullptr;
+ }
+
+ Sound* parent;
+ Sound* child = (Sound*)object;
+
+ parent = (Sound*)type->tp_alloc(type, 0);
+ if(parent != nullptr)
+ {
+ try
+ {
+ parent->sound = new std::shared_ptr<ISound>(new Double(*reinterpret_cast<std::shared_ptr<ISound>*>(self->sound), *reinterpret_cast<std::shared_ptr<ISound>*>(child->sound)));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(parent);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)parent;
+}
+
+PyDoc_STRVAR(M_aud_Sound_mix_doc,
+ "mix(sound)\n\n"
+ "Mixes two factories.\n\n"
+ ":arg sound: The sound to mix over the other.\n"
+ ":type sound: :class:`Sound`\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`\n\n"
+ ".. note:: The two factories have to have the same specifications "
+ "(channels and samplerate).");
+
+static PyObject *
+Sound_mix(Sound* self, PyObject* object)
+{
+ PyTypeObject* type = Py_TYPE(self);
+
+ if(!PyObject_TypeCheck(object, type))
+ {
+ PyErr_SetString(PyExc_TypeError, "Object is not of type Sound!");
+ return nullptr;
+ }
+
+ Sound* parent = (Sound*)type->tp_alloc(type, 0);
+ Sound* child = (Sound*)object;
+
+ if(parent != nullptr)
+ {
+ try
+ {
+ parent->sound = new std::shared_ptr<ISound>(new Superpose(*reinterpret_cast<std::shared_ptr<ISound>*>(self->sound), *reinterpret_cast<std::shared_ptr<ISound>*>(child->sound)));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(parent);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)parent;
+}
+
+PyDoc_STRVAR(M_aud_Sound_pingpong_doc,
+ "pingpong()\n\n"
+ "Plays a sound forward and then backward.\n"
+ "This is like joining a sound with its reverse.\n\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`");
+
+static PyObject *
+Sound_pingpong(Sound* self)
+{
+ PyTypeObject* type = Py_TYPE(self);
+ Sound* parent = (Sound*)type->tp_alloc(type, 0);
+
+ if(parent != nullptr)
+ {
+ try
+ {
+ parent->sound = new std::shared_ptr<ISound>(new PingPong(*reinterpret_cast<std::shared_ptr<ISound>*>(self->sound)));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(parent);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)parent;
+}
+
+PyDoc_STRVAR(M_aud_Sound_list_doc,
+ "list()\n\n"
+ "Creates an empty sound list that can contain several sounds.\n\n"
+ ":arg random: wether the playback will be random or not.\n"
+ ":type random: int\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`");
+
+static PyObject *
+Sound_list(PyTypeObject* type, PyObject* args)
+{
+ int random;
+
+ if(!PyArg_ParseTuple(args, "i:random", &random))
+ return nullptr;
+
+ Sound* self;
+
+ self = (Sound*)type->tp_alloc(type, 0);
+ if(self != nullptr)
+ {
+ try
+ {
+ self->sound = new std::shared_ptr<ISound>(new SoundList(random));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(self);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)self;
+}
+
+PyDoc_STRVAR(M_aud_Sound_mutable_doc,
+ "mutable()\n\n"
+ "Creates a sound that will be restarted when sought backwards.\n"
+ "If the original sound is a sound list, the playing sound can change.\n\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`");
+
+static PyObject *
+Sound_mutable(Sound* self)
+{
+ PyTypeObject* type = Py_TYPE(self);
+ Sound* parent = (Sound*)type->tp_alloc(type, 0);
+
+ if(parent != nullptr)
+ {
+ try
+ {
+ parent->sound = new std::shared_ptr<ISound>(new MutableSound(*reinterpret_cast<std::shared_ptr<ISound>*>(self->sound)));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(parent);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)parent;
+}
+
+PyDoc_STRVAR(M_aud_Sound_list_addSound_doc,
+ "addSound(sound)\n\n"
+ "Adds a new sound to a sound list.\n\n"
+ ":arg sound: The sound that will be added to the list.\n"
+ ":type sound: :class:`Sound`\n\n"
+ ".. note:: You can only add a sound to a sound list.");
+
+static PyObject *
+Sound_list_addSound(Sound* self, PyObject* object)
+{
+ PyTypeObject* type = Py_TYPE(self);
+
+ if(!PyObject_TypeCheck(object, type))
+ {
+ PyErr_SetString(PyExc_TypeError, "Object has to be of type Sound!");
+ return nullptr;
+ }
+
+ Sound* child = (Sound*)object;
+ try
+ {
+ (*reinterpret_cast<std::shared_ptr<SoundList>*>(self->sound))->addSound(*reinterpret_cast<std::shared_ptr<ISound>*>(child->sound));
+ Py_RETURN_NONE;
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+#ifdef WITH_CONVOLUTION
+
+PyDoc_STRVAR(M_aud_Sound_convolver_doc,
+ "convolver()\n\n"
+ "Creates a sound that will apply convolution to another sound.\n\n"
+ ":arg impulseResponse: The filter with which convolve the sound.\n"
+ ":type impulseResponse: :class:`ImpulseResponse`\n"
+ ":arg threadPool: A thread pool used to parallelize convolution.\n"
+ ":type threadPool: :class:`ThreadPool`\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`");
+
+static PyObject *
+Sound_convolver(Sound* self, PyObject* args)
+{
+ PyTypeObject* type = Py_TYPE(self);
+
+ PyObject* object1;
+ PyObject* object2;
+
+ if(!PyArg_ParseTuple(args, "OO:convolver", &object1, &object2))
+ return nullptr;
+
+ ImpulseResponseP* filter = checkImpulseResponse(object1);
+ if(!filter)
+ return nullptr;
+
+ ThreadPoolP* threadPool = checkThreadPool(object2);
+ if(!threadPool)
+ return nullptr;
+
+ Sound* parent;
+ parent = (Sound*)type->tp_alloc(type, 0);
+
+ if(parent != nullptr)
+ {
+ try
+ {
+ parent->sound = new std::shared_ptr<ISound>(new ConvolverSound(*reinterpret_cast<std::shared_ptr<ISound>*>(self->sound), *reinterpret_cast<std::shared_ptr<ImpulseResponse>*>(filter->impulseResponse), *reinterpret_cast<std::shared_ptr<ThreadPool>*>(threadPool->threadPool)));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(parent);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)parent;
+}
+
+PyDoc_STRVAR(M_aud_Sound_binaural_doc,
+ "convolver()\n\n"
+ "Creates a binaural sound using another sound as source. The original sound must be mono\n\n"
+ ":arg hrtfs: An HRTF set.\n"
+ ":type hrtf: :class:`HRTF`\n"
+ ":arg source: An object representing the source position of the sound.\n"
+ ":type source: :class:`Source`\n"
+ ":arg threadPool: A thread pool used to parallelize convolution.\n"
+ ":type threadPool: :class:`ThreadPool`\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`");
+
+static PyObject *
+Sound_binaural(Sound* self, PyObject* args)
+{
+ PyTypeObject* type = Py_TYPE(self);
+
+ PyObject* object1;
+ PyObject* object2;
+ PyObject* object3;
+
+ if(!PyArg_ParseTuple(args, "OOO:binaural", &object1, &object2, &object3))
+ return nullptr;
+
+ HRTFP* hrtfs = checkHRTF(object1);
+ if(!hrtfs)
+ return nullptr;
+
+ SourceP* source = checkSource(object2);
+ if(!hrtfs)
+ return nullptr;
+
+ ThreadPoolP* threadPool = checkThreadPool(object3);
+ if(!threadPool)
+ return nullptr;
+
+ Sound* parent;
+ parent = (Sound*)type->tp_alloc(type, 0);
+
+ if(parent != nullptr)
+ {
+ try
+ {
+ parent->sound = new std::shared_ptr<ISound>(new BinauralSound(*reinterpret_cast<std::shared_ptr<ISound>*>(self->sound), *reinterpret_cast<std::shared_ptr<HRTF>*>(hrtfs->hrtf), *reinterpret_cast<std::shared_ptr<Source>*>(source->source), *reinterpret_cast<std::shared_ptr<ThreadPool>*>(threadPool->threadPool)));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(parent);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)parent;
+}
+
+#endif
+
+static PyMethodDef Sound_methods[] = {
+ {"data", (PyCFunction)Sound_data, METH_NOARGS,
+ M_aud_Sound_data_doc
+ },
+ {"write", (PyCFunction)Sound_write, METH_VARARGS | METH_KEYWORDS,
+ M_aud_Sound_write_doc
+ },
+ {"buffer", (PyCFunction)Sound_buffer, METH_VARARGS | METH_CLASS,
+ M_aud_Sound_buffer_doc
+ },
+ {"cache", (PyCFunction)Sound_cache, METH_NOARGS,
+ M_aud_Sound_cache_doc
+ },
+ {"file", (PyCFunction)Sound_file, METH_VARARGS | METH_CLASS,
+ M_aud_Sound_file_doc
+ },
+ {"sawtooth", (PyCFunction)Sound_sawtooth, METH_VARARGS | METH_CLASS,
+ M_aud_Sound_sawtooth_doc
+ },
+ {"silence", (PyCFunction)Sound_silence, METH_NOARGS | METH_CLASS,
+ M_aud_Sound_silence_doc
+ },
+ {"sine", (PyCFunction)Sound_sine, METH_VARARGS | METH_CLASS,
+ M_aud_Sound_sine_doc
+ },
+ {"square", (PyCFunction)Sound_square, METH_VARARGS | METH_CLASS,
+ M_aud_Sound_square_doc
+ },
+ {"triangle", (PyCFunction)Sound_triangle, METH_VARARGS | METH_CLASS,
+ M_aud_Sound_triangle_doc
+ },
+ {"accumulate", (PyCFunction)Sound_accumulate, METH_VARARGS,
+ M_aud_Sound_accumulate_doc
+ },
+ {"ADSR", (PyCFunction)Sound_ADSR, METH_VARARGS,
+ M_aud_Sound_ADSR_doc
+ },
+ {"delay", (PyCFunction)Sound_delay, METH_VARARGS,
+ M_aud_Sound_delay_doc
+ },
+ {"envelope", (PyCFunction)Sound_envelope, METH_VARARGS,
+ M_aud_Sound_envelope_doc
+ },
+ {"fadein", (PyCFunction)Sound_fadein, METH_VARARGS,
+ M_aud_Sound_fadein_doc
+ },
+ {"fadeout", (PyCFunction)Sound_fadeout, METH_VARARGS,
+ M_aud_Sound_fadeout_doc
+ },
+ {"filter", (PyCFunction)Sound_filter, METH_VARARGS,
+ M_aud_Sound_filter_doc
+ },
+ {"highpass", (PyCFunction)Sound_highpass, METH_VARARGS,
+ M_aud_Sound_highpass_doc
+ },
+ {"limit", (PyCFunction)Sound_limit, METH_VARARGS,
+ M_aud_Sound_limit_doc
+ },
+ {"loop", (PyCFunction)Sound_loop, METH_VARARGS,
+ M_aud_Sound_loop_doc
+ },
+ {"lowpass", (PyCFunction)Sound_lowpass, METH_VARARGS,
+ M_aud_Sound_lowpass_doc
+ },
+ {"pitch", (PyCFunction)Sound_pitch, METH_VARARGS,
+ M_aud_Sound_pitch_doc
+ },
+ {"rechannel", (PyCFunction)Sound_rechannel, METH_VARARGS,
+ M_aud_Sound_rechannel_doc
+ },
+ {"resample", (PyCFunction)Sound_resample, METH_VARARGS,
+ M_aud_Sound_resample_doc
+ },
+ {"reverse", (PyCFunction)Sound_reverse, METH_NOARGS,
+ M_aud_Sound_reverse_doc
+ },
+ {"sum", (PyCFunction)Sound_sum, METH_NOARGS,
+ M_aud_Sound_sum_doc
+ },
+ {"threshold", (PyCFunction)Sound_threshold, METH_VARARGS,
+ M_aud_Sound_threshold_doc
+ },
+ {"volume", (PyCFunction)Sound_volume, METH_VARARGS,
+ M_aud_Sound_volume_doc
+ },
+ {"join", (PyCFunction)Sound_join, METH_O,
+ M_aud_Sound_join_doc
+ },
+ {"mix", (PyCFunction)Sound_mix, METH_O,
+ M_aud_Sound_mix_doc
+ },
+ { "pingpong", (PyCFunction)Sound_pingpong, METH_NOARGS,
+ M_aud_Sound_pingpong_doc
+ },
+ { "list", (PyCFunction)Sound_list, METH_VARARGS | METH_CLASS,
+ M_aud_Sound_list_doc
+ },
+ { "mutable", (PyCFunction)Sound_mutable, METH_NOARGS,
+ M_aud_Sound_mutable_doc
+ },
+ { "addSound", (PyCFunction)Sound_list_addSound, METH_O,
+ M_aud_Sound_list_addSound_doc
+ },
+#ifdef WITH_CONVOLUTION
+ { "convolver", (PyCFunction)Sound_convolver, METH_VARARGS,
+ M_aud_Sound_convolver_doc
+ },
+ { "binaural", (PyCFunction)Sound_binaural, METH_VARARGS,
+ M_aud_Sound_binaural_doc
+ },
+#endif
+ {nullptr} /* Sentinel */
+};
+
+PyDoc_STRVAR(M_aud_Sound_specs_doc,
+ "The sample specification of the sound as a tuple with rate and channel count.");
+
+static PyObject *
+Sound_get_specs(Sound* self, void* nothing)
+{
+ try
+ {
+ Specs specs = (*reinterpret_cast<std::shared_ptr<ISound>*>(self->sound))->createReader()->getSpecs();
+ return Py_BuildValue("(di)", specs.rate, specs.channels);
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+PyDoc_STRVAR(M_aud_Sound_length_doc,
+ "The sample specification of the sound as a tuple with rate and channel count.");
+
+static PyObject *
+Sound_get_length(Sound* self, void* nothing)
+{
+ try
+ {
+ int length = (*reinterpret_cast<std::shared_ptr<ISound>*>(self->sound))->createReader()->getLength();
+ return Py_BuildValue("i", length);
+ }
+ catch(Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static PyGetSetDef Sound_properties[] = {
+ {(char*)"specs", (getter)Sound_get_specs, nullptr,
+ M_aud_Sound_specs_doc, nullptr },
+ {(char*)"length", (getter)Sound_get_length, nullptr,
+ M_aud_Sound_length_doc, nullptr },
+ {nullptr} /* Sentinel */
+};
+
+PyDoc_STRVAR(M_aud_Sound_doc,
+ "Sound objects are immutable and represent a sound that can be "
+ "played simultaneously multiple times. They are called factories "
+ "because they create reader objects internally that are used for "
+ "playback.");
+
+PyTypeObject SoundType = {
+ PyVarObject_HEAD_INIT(nullptr, 0)
+ "aud.Sound", /* tp_name */
+ sizeof(Sound), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)Sound_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_reserved */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ M_aud_Sound_doc, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ Sound_methods, /* tp_methods */
+ 0, /* tp_members */
+ Sound_properties, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ Sound_new, /* tp_new */
+};
+
+AUD_API PyObject* Sound_empty()
+{
+ return SoundType.tp_alloc(&SoundType, 0);
+}
+
+AUD_API Sound* checkSound(PyObject* sound)
+{
+ if(!PyObject_TypeCheck(sound, &SoundType))
+ {
+ PyErr_SetString(PyExc_TypeError, "Object is not of type Sound!");
+ return nullptr;
+ }
+
+ return (Sound*)sound;
+}
+
+
+bool initializeSound()
+{
+ import_array();
+
+ return PyType_Ready(&SoundType) >= 0;
+}
+
+
+void addSoundToModule(PyObject* module)
+{
+ Py_INCREF(&SoundType);
+ PyModule_AddObject(module, "Sound", (PyObject *)&SoundType);
+}
diff --git a/extern/audaspace/bindings/python/PySound.h b/extern/audaspace/bindings/python/PySound.h
new file mode 100644
index 00000000000..657bb2131e6
--- /dev/null
+++ b/extern/audaspace/bindings/python/PySound.h
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+#include <Python.h>
+#include "Audaspace.h"
+
+typedef void Reference_ISound;
+
+typedef struct {
+ PyObject_HEAD
+ Reference_ISound* sound;
+} Sound;
+
+extern AUD_API PyObject* Sound_empty();
+extern AUD_API Sound* checkSound(PyObject* sound);
+
+bool initializeSound();
+void addSoundToModule(PyObject* module);
diff --git a/extern/audaspace/bindings/python/PySource.cpp b/extern/audaspace/bindings/python/PySource.cpp
new file mode 100644
index 00000000000..a948cf46645
--- /dev/null
+++ b/extern/audaspace/bindings/python/PySource.cpp
@@ -0,0 +1,260 @@
+/*******************************************************************************
+* Copyright 2009-2015 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "PySource.h"
+
+#include "Exception.h"
+#include "fx/Source.h"
+
+#include <memory>
+
+extern PyObject* AUDError;
+
+static PyObject *
+Source_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
+{
+ SourceP* self = (SourceP*)type->tp_alloc(type, 0);
+
+ if(self != nullptr)
+ {
+ float azimuth, elevation, distance;
+ if(!PyArg_ParseTuple(args, "fff:angles", &azimuth, &elevation, &distance))
+ return nullptr;
+
+ try
+ {
+ self->source = new std::shared_ptr<aud::Source>(new aud::Source(azimuth, elevation, distance));
+ }
+ catch(aud::Exception& e)
+ {
+ Py_DECREF(self);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)self;
+}
+
+static void
+Source_dealloc(SourceP* self)
+{
+ if(self->source)
+ delete reinterpret_cast<std::shared_ptr<aud::Source>*>(self->source);
+ Py_TYPE(self)->tp_free((PyObject *)self);
+}
+
+static PyMethodDef Source_methods[] = {
+ { nullptr } /* Sentinel */
+};
+
+PyDoc_STRVAR(M_aud_Source_azimuth_doc,
+ "The azimuth angle.");
+
+static int
+Source_set_azimuth(SourceP* self, PyObject* args, void* nothing)
+{
+ float azimuth;
+
+ if(!PyArg_Parse(args, "f:azimuth", &azimuth))
+ return -1;
+
+ try
+ {
+ (*reinterpret_cast<std::shared_ptr<aud::Source>*>(self->source))->setAzimuth(azimuth);
+ return 0;
+ }
+ catch(aud::Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+static PyObject *
+Source_get_azimuth(SourceP* self, void* nothing)
+{
+ try
+ {
+ return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<aud::Source>*>(self->source))->getAzimuth());
+ }
+ catch(aud::Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+PyDoc_STRVAR(M_aud_Source_elevation_doc,
+ "The elevation angle.");
+
+static int
+Source_set_elevation(SourceP* self, PyObject* args, void* nothing)
+{
+ float elevation;
+
+ if(!PyArg_Parse(args, "f:elevation", &elevation))
+ return -1;
+
+ try
+ {
+ (*reinterpret_cast<std::shared_ptr<aud::Source>*>(self->source))->setElevation(elevation);
+ return 0;
+ }
+ catch(aud::Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+static PyObject *
+Source_get_elevation(SourceP* self, void* nothing)
+{
+ try
+ {
+ return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<aud::Source>*>(self->source))->getElevation());
+ }
+ catch(aud::Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+PyDoc_STRVAR(M_aud_Source_distance_doc,
+ "The distance value. 0 is min, 1 is max.");
+
+static int
+Source_set_distance(SourceP* self, PyObject* args, void* nothing)
+{
+ float distance;
+
+ if(!PyArg_Parse(args, "f:distance", &distance))
+ return -1;
+
+ try
+ {
+ (*reinterpret_cast<std::shared_ptr<aud::Source>*>(self->source))->setDistance(distance);
+ return 0;
+ }
+ catch(aud::Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ }
+
+ return -1;
+}
+
+static PyObject *
+Source_get_distance(SourceP* self, void* nothing)
+{
+ try
+ {
+ return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<aud::Source>*>(self->source))->getDistance());
+ }
+ catch(aud::Exception& e)
+ {
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+}
+
+static PyGetSetDef Source_properties[] = {
+ { (char*)"azimuth", (getter)Source_get_azimuth, (setter)Source_set_azimuth,
+ M_aud_Source_azimuth_doc, nullptr },
+ { (char*)"elevation", (getter)Source_get_elevation, (setter)Source_set_elevation,
+ M_aud_Source_elevation_doc, nullptr },
+ { (char*)"distance", (getter)Source_get_distance, (setter)Source_set_distance,
+ M_aud_Source_distance_doc, nullptr },
+ { nullptr } /* Sentinel */
+};
+
+PyDoc_STRVAR(M_aud_Source_doc,
+ "The source object represents the source position of a binaural sound.");
+
+PyTypeObject SourceType = {
+ PyVarObject_HEAD_INIT(nullptr, 0)
+ "aud.Source", /* tp_name */
+ sizeof(SourceP), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)Source_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_reserved */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ M_aud_Source_doc, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ Source_methods, /* tp_methods */
+ 0, /* tp_members */
+ Source_properties, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ Source_new, /* tp_new */
+};
+
+AUD_API PyObject* Source_empty()
+{
+ return SourceType.tp_alloc(&SourceType, 0);
+}
+
+
+AUD_API SourceP* checkSource(PyObject* source)
+{
+ if(!PyObject_TypeCheck(source, &SourceType))
+ {
+ PyErr_SetString(PyExc_TypeError, "Object is not of type Source!");
+ return nullptr;
+ }
+
+ return (SourceP*)source;
+}
+
+
+bool initializeSource()
+{
+ return PyType_Ready(&SourceType) >= 0;
+}
+
+
+void addSourceToModule(PyObject* module)
+{
+ Py_INCREF(&SourceType);
+ PyModule_AddObject(module, "Source", (PyObject *)&SourceType);
+}
diff --git a/extern/audaspace/bindings/python/PySource.h b/extern/audaspace/bindings/python/PySource.h
new file mode 100644
index 00000000000..19960d80901
--- /dev/null
+++ b/extern/audaspace/bindings/python/PySource.h
@@ -0,0 +1,33 @@
+/*******************************************************************************
+* Copyright 2009-2015 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+#include <Python.h>
+#include "Audaspace.h"
+
+typedef void Reference_Source;
+
+typedef struct {
+ PyObject_HEAD
+ Reference_Source* source;
+} SourceP;
+
+extern AUD_API PyObject* Source_empty();
+extern AUD_API SourceP* checkSource(PyObject* source);
+
+bool initializeSource();
+void addSourceToModule(PyObject* module); \ No newline at end of file
diff --git a/extern/audaspace/bindings/python/PyThreadPool.cpp b/extern/audaspace/bindings/python/PyThreadPool.cpp
new file mode 100644
index 00000000000..75811f08273
--- /dev/null
+++ b/extern/audaspace/bindings/python/PyThreadPool.cpp
@@ -0,0 +1,134 @@
+/*******************************************************************************
+* Copyright 2009-2015 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "PyThreadPool.h"
+
+#include "Exception.h"
+#include "util/ThreadPool.h"
+
+extern PyObject* AUDError;
+
+static PyObject *
+ThreadPool_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
+{
+ ThreadPoolP* self = (ThreadPoolP*)type->tp_alloc(type, 0);
+
+ if(self != nullptr)
+ {
+ unsigned int nThreads;
+ if(!PyArg_ParseTuple(args, "I:nThreads", &nThreads))
+ return nullptr;
+
+ try
+ {
+ self->threadPool = new std::shared_ptr<aud::ThreadPool>(new aud::ThreadPool(nThreads));
+ }
+ catch(aud::Exception& e)
+ {
+ Py_DECREF(self);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)self;
+}
+
+static void
+ThreadPool_dealloc(ThreadPoolP* self)
+{
+ if(self->threadPool)
+ delete reinterpret_cast<std::shared_ptr<aud::ThreadPool>*>(self->threadPool);
+ Py_TYPE(self)->tp_free((PyObject *)self);
+}
+
+static PyMethodDef ThreadPool_methods[] = {
+ { nullptr } /* Sentinel */
+};
+
+PyDoc_STRVAR(M_aud_ThreadPool_doc,
+ "A ThreadPool is used to parallelize convolution efficiently.");
+
+PyTypeObject ThreadPoolType = {
+ PyVarObject_HEAD_INIT(nullptr, 0)
+ "aud.ThreadPool", /* tp_name */
+ sizeof(ThreadPoolP), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)ThreadPool_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_reserved */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ M_aud_ThreadPool_doc, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ ThreadPool_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ ThreadPool_new, /* tp_new */
+};
+
+AUD_API PyObject* ThreadPool_empty()
+{
+ return ThreadPoolType.tp_alloc(&ThreadPoolType, 0);
+}
+
+
+AUD_API ThreadPoolP* checkThreadPool(PyObject* threadPool)
+{
+ if(!PyObject_TypeCheck(threadPool, &ThreadPoolType))
+ {
+ PyErr_SetString(PyExc_TypeError, "Object is not of type ThreadPool!");
+ return nullptr;
+ }
+
+ return (ThreadPoolP*)threadPool;
+}
+
+
+bool initializeThreadPool()
+{
+ return PyType_Ready(&ThreadPoolType) >= 0;
+}
+
+
+void addThreadPoolToModule(PyObject* module)
+{
+ Py_INCREF(&ThreadPoolType);
+ PyModule_AddObject(module, "ThreadPool", (PyObject *)&ThreadPoolType);
+}
diff --git a/extern/audaspace/bindings/python/PyThreadPool.h b/extern/audaspace/bindings/python/PyThreadPool.h
new file mode 100644
index 00000000000..e38d905f52a
--- /dev/null
+++ b/extern/audaspace/bindings/python/PyThreadPool.h
@@ -0,0 +1,33 @@
+/*******************************************************************************
+* Copyright 2009-2015 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+#include <Python.h>
+#include "Audaspace.h"
+
+typedef void Reference_ThreadPool;
+
+typedef struct {
+ PyObject_HEAD
+ Reference_ThreadPool* threadPool;
+} ThreadPoolP;
+
+extern AUD_API PyObject* ThreadPool_empty();
+extern AUD_API ThreadPoolP* checkThreadPool(PyObject* ThreadPool);
+
+bool initializeThreadPool();
+void addThreadPoolToModule(PyObject* module); \ No newline at end of file
diff --git a/extern/audaspace/bindings/python/examples/binaural.py b/extern/audaspace/bindings/python/examples/binaural.py
new file mode 100644
index 00000000000..e7a2f6cf6d9
--- /dev/null
+++ b/extern/audaspace/bindings/python/examples/binaural.py
@@ -0,0 +1,13 @@
+#!/usr/bin/python
+import aud, sys, time, multiprocessing
+device = aud.Device()
+hrtf = aud.HRTF().loadLeftHrtfSet(".wav", sys.argv[2])
+threadPool = aud.ThreadPool(multiprocessing.cpu_count())
+source = aud.Source(0, 0, 0)
+sound = aud.Sound.file(sys.argv[1]).rechannel(1).binaural(hrtf, source, threadPool)
+handle = device.play(sound)
+
+while handle.status:
+ source.azimuth += 1
+ print("Azimuth: " + str(source.azimuth))
+ time.sleep(0.1) \ No newline at end of file
diff --git a/extern/audaspace/bindings/python/examples/convolution.py b/extern/audaspace/bindings/python/examples/convolution.py
new file mode 100644
index 00000000000..4de25b0336a
--- /dev/null
+++ b/extern/audaspace/bindings/python/examples/convolution.py
@@ -0,0 +1,10 @@
+#!/usr/bin/python
+import aud, sys, time, multiprocessing
+device = aud.Device()
+ir = aud.ImpulseResponse(aud.Sound.file(sys.argv[2]))
+threadPool = aud.ThreadPool(multiprocessing.cpu_count())
+sound = aud.Sound.file(sys.argv[1]).convolver(ir, threadPool)
+handle = device.play(sound)
+handle.volume = 0.1
+while handle.status:
+ time.sleep(0.1) \ No newline at end of file
diff --git a/extern/audaspace/bindings/python/examples/dynamicmusic.py b/extern/audaspace/bindings/python/examples/dynamicmusic.py
new file mode 100644
index 00000000000..348e2496c0a
--- /dev/null
+++ b/extern/audaspace/bindings/python/examples/dynamicmusic.py
@@ -0,0 +1,20 @@
+import aud, sys, time
+
+device=aud.Device()
+dMusic = aud.DynamicMusic(device)
+sound1 = aud.Sound.file(sys.argv[1])
+sound2 = aud.Sound.file(sys.argv[2])
+effect = aud.Sound.file(sys.argv[3])
+
+dMusic.addScene(sound1)
+dMusic.addScene(sound2)
+dMusic.addTransition(1,2,effect)
+
+dMusic.fadeTime=3
+dMusic.volume=0.5
+
+dMusic.scene=1
+time.sleep(5)
+dMusic.scene=2
+
+time.sleep(500) \ No newline at end of file
diff --git a/extern/audaspace/bindings/python/examples/playbackmanager.py b/extern/audaspace/bindings/python/examples/playbackmanager.py
new file mode 100644
index 00000000000..2aa1c283545
--- /dev/null
+++ b/extern/audaspace/bindings/python/examples/playbackmanager.py
@@ -0,0 +1,27 @@
+import aud, sys, time
+
+device=aud.Device()
+manager = aud.PlaybackManager(device)
+sound1 = aud.Sound.file(sys.argv[1])
+sound2 = aud.Sound.file(sys.argv[2])
+sound3 = aud.Sound.file(sys.argv[3])
+sound4 = aud.Sound.file(sys.argv[4])
+
+manager.play(sound1, 0)
+manager.play(sound2, 0)
+manager.play(sound3, 1)
+manager.play(sound4, 1)
+
+manager.setVolume(0.2, 0)
+time.sleep(5)
+manager.setVolume(0.0, 1)
+time.sleep(5)
+manager.pause(0)
+time.sleep(5)
+manager.setVolume(0.5, 1)
+manager.setVolume(1.0, 0)
+time.sleep(5)
+manager.stop(1)
+manager.resume(0)
+
+time.sleep(500) \ No newline at end of file
diff --git a/extern/audaspace/bindings/python/examples/player.py b/extern/audaspace/bindings/python/examples/player.py
new file mode 100644
index 00000000000..8acf4ac833f
--- /dev/null
+++ b/extern/audaspace/bindings/python/examples/player.py
@@ -0,0 +1,7 @@
+#!/usr/bin/python
+import aud, sys, time
+device = aud.Device()
+sound = aud.Sound.file(sys.argv[1])
+handle = device.play(sound)
+while handle.status:
+ time.sleep(0.1)
diff --git a/extern/audaspace/bindings/python/examples/randomSounds.py b/extern/audaspace/bindings/python/examples/randomSounds.py
new file mode 100644
index 00000000000..113b0921f09
--- /dev/null
+++ b/extern/audaspace/bindings/python/examples/randomSounds.py
@@ -0,0 +1,21 @@
+import aud, sys, time
+
+device=aud.Device()
+sound1 = aud.Sound.file(sys.argv[1])
+sound2 = aud.Sound.file(sys.argv[2])
+sound3 = aud.Sound.file(sys.argv[3])
+sound4 = aud.Sound.file(sys.argv[4])
+list=aud.Sound.list(True)
+
+list.addSound(sound1)
+list.addSound(sound2)
+list.addSound(sound3)
+list.addSound(sound4)
+mutable=aud.Sound.mutable(list)
+
+device.lock()
+handle=device.play(mutable)
+handle.loop_count=2
+device.unlock()
+
+time.sleep(500) \ No newline at end of file
diff --git a/extern/audaspace/bindings/python/examples/simple.py b/extern/audaspace/bindings/python/examples/simple.py
new file mode 100644
index 00000000000..7aa45b41042
--- /dev/null
+++ b/extern/audaspace/bindings/python/examples/simple.py
@@ -0,0 +1,7 @@
+#!/usr/bin/python
+import aud, time
+device = aud.Device()
+sine = aud.Sound.sine(440)
+square = sine.threshold()
+handle = device.play(square)
+time.sleep(3)
diff --git a/extern/audaspace/bindings/python/examples/siren.py b/extern/audaspace/bindings/python/examples/siren.py
new file mode 100644
index 00000000000..071279b162d
--- /dev/null
+++ b/extern/audaspace/bindings/python/examples/siren.py
@@ -0,0 +1,19 @@
+#!/usr/bin/python
+import aud, math, time
+length = 0.5
+fadelength = 0.05
+
+device = aud.Device()
+high = aud.Sound.sine(880).limit(0, length).fadein(0, fadelength).fadeout(length - fadelength, length)
+low = aud.Sound.sine(700).limit(0, length).fadein(0, fadelength).fadeout(length - fadelength, length).volume(0.6)
+sound = high.join(low)
+handle = device.play(sound)
+handle.loop_count = -1
+
+start = time.time()
+
+while time.time() - start < 10:
+ angle = time.time() - start
+
+ handle.location = [math.sin(angle), 0, -math.cos(angle)]
+
diff --git a/extern/audaspace/bindings/python/examples/siren2.py b/extern/audaspace/bindings/python/examples/siren2.py
new file mode 100644
index 00000000000..35e1a600581
--- /dev/null
+++ b/extern/audaspace/bindings/python/examples/siren2.py
@@ -0,0 +1,23 @@
+#!/usr/bin/python
+import aud, math, time
+length = 0.5
+fadelength = 0.05
+runtime = 10
+distance = 100
+velocity = 2 * distance / runtime
+
+device = aud.Device()
+high = aud.Sound.sine(880).limit(0, length).fadein(0, fadelength).fadeout(length - fadelength, length)
+low = aud.Sound.sine(700).limit(0, length).fadein(0, fadelength).fadeout(length - fadelength, length).volume(0.6)
+sound = high.join(low)
+handle = device.play(sound)
+handle.loop_count = -1
+
+handle.velocity = [velocity, 0, 0]
+
+start = time.time()
+
+while time.time() - start < runtime:
+ location = -distance + velocity * (time.time() - start)
+
+ handle.location = [location, 10, 0]
diff --git a/extern/audaspace/bindings/python/examples/tetris.py b/extern/audaspace/bindings/python/examples/tetris.py
new file mode 100644
index 00000000000..236a6fa59c1
--- /dev/null
+++ b/extern/audaspace/bindings/python/examples/tetris.py
@@ -0,0 +1,66 @@
+#!/usr/bin/python
+import aud, math, time
+
+def parseNotes(notes, bpm, basefreq, rate = 44100,
+ notechars = "XXXCXDXEFXGXAXHcXdXefXgXaXhp"):
+ pos = 0
+ fadelength = 60/bpm/10
+ halfchars = "#b"
+ durationchars = "2345678"
+ sound = None
+
+ while pos < len(notes):
+ char = notes[pos]
+ mod = None
+ dur = 1
+ pos += 1
+ while pos < len(notes) and notes[pos] not in notechars:
+ if notes[pos] in halfchars:
+ mod = notes[pos]
+ elif notes[pos] in durationchars:
+ dur = notes[pos]
+ pos += 1
+
+ freq = notechars.find(char)
+ if mod == '#':
+ freq += 1
+ elif mod == 'b':
+ freq -= 1
+
+ freq = math.pow(2, freq/12)*basefreq
+ length = float(dur)*60/bpm
+
+ snd = aud.Sound.square(freq, rate)
+ if char == 'p':
+ snd = snd.volume(0)
+ snd = snd.limit(0, length)
+ snd = snd.fadein(0, fadelength)
+ snd = snd.fadeout(length - fadelength, fadelength)
+
+ if sound:
+ sound = sound.join(snd)
+ else:
+ sound = snd
+ return sound
+
+def tetris(bpm = 300, freq = 220, rate = 44100):
+ notes = "e2Hcd2cH A2Ace2dc H3cd2e2 c2A2A4 pd2fa2gf e3ce2dc H2Hcd2e2 c2A2A2p2"
+ s11 = parseNotes(notes, bpm, freq, rate)
+
+ notes = "e4c4 d4H4 c4A4 G#4p4 e4c4 d4H4 A2c2a4 g#4p4"
+ s12 = parseNotes(notes, bpm, freq, rate)
+
+ notes = "EeEeEeEe AaAaAaAa AbabAbabAbabAbab AaAaAAHC DdDdDdDd CcCcCcCc HhHhHhHh AaAaA2p2"
+ s21 = parseNotes(notes, bpm, freq, rate, notechars = "AXHCXDXEFXGXaXhcXdXefXgXp")
+
+ notes = "aeaeaeae g#dg#dg#dg#d aeaeaeae g#dg#dg#2p2 aeaeaeae g#dg#dg#dg#d aeaeaeae g#dg#dg#2p2"
+ s22 = parseNotes(notes, bpm, freq/2, rate)
+
+ return s11.join(s12).join(s11).volume(0.5).mix(s21.join(s22).join(s21).volume(0.3))
+
+if __name__ == "__main__":
+ dev = aud.Device()
+ handle = dev.play(tetris(300, 220, dev.rate))
+ while handle.status:
+ time.sleep(0.1)
+
diff --git a/extern/audaspace/bindings/python/examples/tetris2.py b/extern/audaspace/bindings/python/examples/tetris2.py
new file mode 100644
index 00000000000..08708581af6
--- /dev/null
+++ b/extern/audaspace/bindings/python/examples/tetris2.py
@@ -0,0 +1,64 @@
+#!/usr/bin/python
+import aud, math, time
+
+def parseNotes(notes, bpm, basefreq, rate = 44100,
+ notechars = "XXXCXDXEFXGXAXHcXdXefXgXaXhp"):
+ pos = 0
+ fadelength = 60/bpm/10
+ halfchars = "#b"
+ durationchars = "2345678"
+ position = 0
+ sequence = aud.Sequence()
+
+ while pos < len(notes):
+ char = notes[pos]
+ mod = None
+ dur = 1
+ pos += 1
+ while pos < len(notes) and notes[pos] not in notechars:
+ if notes[pos] in halfchars:
+ mod = notes[pos]
+ elif notes[pos] in durationchars:
+ dur = notes[pos]
+ pos += 1
+
+ freq = notechars.find(char)
+ if mod == '#':
+ freq += 1
+ elif mod == 'b':
+ freq -= 1
+
+ freq = math.pow(2, freq/12)*basefreq
+ length = float(dur)*60/bpm
+
+ note = aud.Sound.square(freq, rate).fadein(0, fadelength).fadeout(length - fadelength, fadelength)
+
+ entry = sequence.add(note, position, position + length, 0)
+ if char == 'p':
+ entry.muted = True
+
+ position += length
+
+ return sequence.limit(0, position)
+
+def tetris(bpm = 300, freq = 220, rate = 44100):
+ notes = "e2Hcd2cH A2Ace2dc H3cd2e2 c2A2A4 pd2fa2gf e3ce2dc H2Hcd2e2 c2A2A2p2"
+ s11 = parseNotes(notes, bpm, freq, rate)
+
+ notes = "e4c4 d4H4 c4A4 G#4p4 e4c4 d4H4 A2c2a4 g#4p4"
+ s12 = parseNotes(notes, bpm, freq, rate)
+
+ notes = "EeEeEeEe AaAaAaAa AbabAbabAbabAbab AaAaAAHC DdDdDdDd CcCcCcCc HhHhHhHh AaAaA2p2"
+ s21 = parseNotes(notes, bpm, freq, rate, notechars = "AXHCXDXEFXGXaXhcXdXefXgXp")
+
+ notes = "aeaeaeae g#dg#dg#dg#d aeaeaeae g#dg#dg#2p2 aeaeaeae g#dg#dg#dg#d aeaeaeae g#dg#dg#2p2"
+ s22 = parseNotes(notes, bpm, freq/2, rate)
+
+ return s11.join(s12).join(s11).volume(0.5).mix(s21.join(s22).join(s21).volume(0.3))
+
+if __name__ == "__main__":
+ dev = aud.Device()
+ handle = dev.play(tetris(300, 220, dev.rate))
+ while handle.status:
+ time.sleep(0.1)
+
diff --git a/extern/audaspace/bindings/python/examples/tetris3.py b/extern/audaspace/bindings/python/examples/tetris3.py
new file mode 100644
index 00000000000..aa66d5457d3
--- /dev/null
+++ b/extern/audaspace/bindings/python/examples/tetris3.py
@@ -0,0 +1,63 @@
+#!/usr/bin/python
+import aud, math, time
+
+def parseNotes(notes, bpm, basefreq, rate = 44100,
+ notechars = "XXXCXDXEFXGXAXHcXdXefXgXaXhp"):
+ pos = 0
+ fadelength = 60/bpm/10
+ halfchars = "#b"
+ durationchars = "2345678"
+ position = 0
+ sequence = aud.Sequence()
+
+ while pos < len(notes):
+ char = notes[pos]
+ mod = None
+ dur = 1
+ pos += 1
+ while pos < len(notes) and notes[pos] not in notechars:
+ if notes[pos] in halfchars:
+ mod = notes[pos]
+ elif notes[pos] in durationchars:
+ dur = notes[pos]
+ pos += 1
+
+ freq = notechars.find(char)
+ if mod == '#':
+ freq += 1
+ elif mod == 'b':
+ freq -= 1
+
+ freq = math.pow(2, freq/12)*basefreq
+ length = float(dur)*60/bpm
+
+ if char != 'p':
+ note = aud.Sound.square(freq, rate).fadein(0, fadelength).fadeout(length - fadelength, fadelength)
+
+ sequence.add(note, position, position + length, 0)
+
+ position += length
+
+ return sequence.limit(0, position)
+
+def tetris(bpm = 300, freq = 220, rate = 44100):
+ notes = "e2Hcd2cH A2Ace2dc H3cd2e2 c2A2A4 pd2fa2gf e3ce2dc H2Hcd2e2 c2A2A2p2"
+ s11 = parseNotes(notes, bpm, freq, rate)
+
+ notes = "e4c4 d4H4 c4A4 G#4p4 e4c4 d4H4 A2c2a4 g#4p4"
+ s12 = parseNotes(notes, bpm, freq, rate)
+
+ notes = "EeEeEeEe AaAaAaAa AbabAbabAbabAbab AaAaAAHC DdDdDdDd CcCcCcCc HhHhHhHh AaAaA2p2"
+ s21 = parseNotes(notes, bpm, freq, rate, notechars = "AXHCXDXEFXGXaXhcXdXefXgXp")
+
+ notes = "aeaeaeae g#dg#dg#dg#d aeaeaeae g#dg#dg#2p2 aeaeaeae g#dg#dg#dg#d aeaeaeae g#dg#dg#2p2"
+ s22 = parseNotes(notes, bpm, freq/2, rate)
+
+ return s11.join(s12).join(s11).volume(0.5).mix(s21.join(s22).join(s21).volume(0.3))
+
+if __name__ == "__main__":
+ dev = aud.Device()
+ handle = dev.play(tetris(300, 220, dev.rate))
+ while handle.status:
+ time.sleep(0.1)
+
diff --git a/extern/audaspace/bindings/python/setup.py.in b/extern/audaspace/bindings/python/setup.py.in
new file mode 100644
index 00000000000..add1a2d1475
--- /dev/null
+++ b/extern/audaspace/bindings/python/setup.py.in
@@ -0,0 +1,61 @@
+# -*- coding: utf-8 -*-
+
+import sys
+import os
+import codecs
+import numpy
+
+from distutils.core import setup, Extension
+
+if len(sys.argv) > 2 and sys.argv[1] == '--build-docs':
+ import subprocess
+ from distutils.core import Distribution
+ from distutils.command.build import build
+
+ dist = Distribution()
+ cmd = build(dist)
+ cmd.finalize_options()
+ #print(cmd.build_platlib)
+
+ os.environ['PYTHONPATH'] = os.path.join(os.getcwd(), cmd.build_platlib)
+ os.environ['LD_LIBRARY_PATH'] = os.getcwd()
+
+ ret = subprocess.call(sys.argv[2:])
+ sys.exit(ret)
+
+
+# the following line is not working due to https://bugs.python.org/issue9023
+#source_directory = os.path.relpath('@PYTHON_SOURCE_DIRECTORY@')
+source_directory = '@PYTHON_SOURCE_DIRECTORY@'
+
+extra_args = []
+
+if sys.platform == 'win32':
+ extra_args.append('/EHsc')
+ extra_args.append('/DAUD_BUILD_SHARED_LIBRARY')
+else:
+ extra_args.append('-std=c++11')
+
+audaspace = Extension(
+ 'aud',
+ include_dirs = ['@CMAKE_CURRENT_BINARY_DIR@', '@FFTW_INCLUDE_DIR@', os.path.join(source_directory, '../../include'), numpy.get_include()],
+ libraries = ['audaspace'],
+ library_dirs = ['.', 'Release', 'Debug'],
+ language = 'c++',
+ extra_compile_args = extra_args,
+ sources = [os.path.join(source_directory, file) for file in ['PyAPI.cpp', 'PyDevice.cpp', 'PyHandle.cpp', 'PySound.cpp', 'PySequenceEntry.cpp', 'PySequence.cpp', 'PyPlaybackManager.cpp', 'PyDynamicMusic.cpp', 'PyThreadPool.cpp', 'PySource.cpp'] + (['PyImpulseResponse.cpp', 'PyHRTF.cpp'] if '@WITH_FFTW@' == 'ON' else [])]
+)
+
+setup(
+ name = 'audaspace',
+ version = '@AUDASPACE_LONG_VERSION@',
+ description = 'Audaspace is a high level audio library.',
+ author = 'Jörg Müller',
+ author_email = 'nexyon@gmail.com',
+ url = 'https://github.com/audaspace/audaspace',
+ license = 'Apache License 2.0',
+ long_description = codecs.open(os.path.join(source_directory, '../../README.md'), 'r', 'utf-8').read(),
+ ext_modules = [audaspace],
+ headers = [os.path.join(source_directory, file) for file in ['PyAPI.h', 'PyDevice.h', 'PyHandle.h', 'PySound.h', 'PySequenceEntry.h', 'PySequence.h', 'PyPlaybackManager.h', 'PyDynamicMusic.h', 'PyThreadPool.h', 'PySource.h'] + (['PyImpulseResponse.h', 'PyHRTF.h'] if '@WITH_FFTW@' == 'ON' else [])] + ['Audaspace.h']
+)
+
diff --git a/extern/audaspace/blender_config.cmake b/extern/audaspace/blender_config.cmake
new file mode 100644
index 00000000000..5b5440920d0
--- /dev/null
+++ b/extern/audaspace/blender_config.cmake
@@ -0,0 +1,26 @@
+set(AUDASPACE_STANDALONE FALSE)
+set(BUILD_DEMOS FALSE)
+set(SHARED_LIBRARY FALSE)
+set(WITH_C TRUE)
+set(WITH_DOCS FALSE)
+set(WITH_FFMPEG ${WITH_CODEC_FFMPEG})
+set(WITH_FFTW FALSE)
+set(WITH_LIBSNDFILE ${WITH_CODEC_SNDFILE})
+set(SEPARATE_C FALSE)
+set(PLUGIN_FFMPEG FALSE)
+set(PLUGIN_JACK FALSE)
+set(PLUGIN_LIBSNDFILE FALSE)
+set(PLUGIN_OPENAL FALSE)
+set(PLUGIN_SDL FALSE)
+set(WITH_PYTHON_MODULE FALSE)
+set(DYNLOAD_JACK ${WITH_JACK_DYNLOAD})
+set(WITH_BINDING_DOCS FALSE)
+set(BLENDER_AUDASPACE TRUE)
+set(FFMPEG_FOUND ${WITH_CODEC_FFMPEG})
+set(JACK_FOUND ${WITH_JACK})
+set(LIBSNDFILE_FOUND ${WITH_CODEC_SNDFILE})
+set(OPENAL_FOUND ${WITH_OPENAL})
+set(PYTHONLIBS_FOUND TRUE)
+set(NUMPY_FOUND TRUE)
+set(NUMPY_INCLUDE_DIRS ${PYTHON_NUMPY_INCLUDE_DIRS})
+set(SDL_FOUND ${WITH_SDL})
diff --git a/extern/audaspace/config/Audaspace.h.in b/extern/audaspace/config/Audaspace.h.in
new file mode 100644
index 00000000000..3e6912727b8
--- /dev/null
+++ b/extern/audaspace/config/Audaspace.h.in
@@ -0,0 +1,131 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file Audaspace.h
+ * @ingroup general
+ * The main header file of the library defining the namespace and basic data types.
+ */
+
+/**
+ * \def AUD_API
+ * Used for exporting symbols in the shared library.
+ */
+
+/**
+ * \def AUD_PLUGIN_API
+ * Used for exporting symbols in the shared library.
+ */
+
+/**
+ * \def AUD_EXPORT_API
+ * Used for using exporting symbols of the shared library.
+ */
+
+/**
+ * \def AUD_USE_API
+ * Used for using exporting symbols of the shared library.
+ */
+
+/**
+ * \def AUD_LOCAL
+ * Used for hiding symbols from export in the shared library.
+ */
+
+// the following two defines and undefines are a hack to silence an error by doxygen
+
+/**
+ * \def AUD_SHARED_LIBRARY
+ * Defined when audaspace was built as a shared library.
+ */
+#define AUD_SHARED_LIBRARY
+#undef AUD_SHARED_LIBRARY
+
+/**
+ * \def AUD_STATIC_LIBRARY
+ * Defined when audaspace was built as a static library.
+ */
+ #define AUD_STATIC_LIBRARY
+ #undef AUD_STATIC_LIBRARY
+
+#define @AUD_LIBRARY_TYPE@
+
+#ifdef _MSC_VER
+ #define AUD_EXPORT_API __declspec(dllexport)
+ #define AUD_USE_API __declspec(dllimport)
+ #define AUD_LOCAL
+#else
+ #ifdef __GNUC__
+ #define AUD_EXPORT_API __attribute__((visibility ("default")))
+ #define AUD_USE_API AUD_EXPORT_API
+ #define AUD_LOCAL __attribute__((visibility ("hidden")))
+ #else
+ #define AUD_EXPORT_API
+ #define AUD_USE_API
+ #define AUD_LOCAL
+ #endif
+#endif
+
+#ifdef AUD_SHARED_LIBRARY
+ #ifdef AUD_BUILD_PLUGIN
+ #define AUD_API AUD_USE_API
+ #define AUD_PLUGIN_API AUD_EXPORT_API
+ #else
+ #ifdef AUD_BUILD_SHARED_LIBRARY
+ #define AUD_API AUD_EXPORT_API
+ #define AUD_PLUGIN_API AUD_EXPORT_API
+ #else
+ #define AUD_API AUD_USE_API
+ #define AUD_PLUGIN_API AUD_USE_API
+ #endif
+ #endif
+#else
+ #define AUD_API
+ #define AUD_PLUGIN_API
+#endif
+
+/// The default playback buffer size of a device.
+#define AUD_DEFAULT_BUFFER_SIZE 1024
+
+#ifdef __cplusplus
+
+/// Opens the audaspace namespace aud.
+#define AUD_NAMESPACE_BEGIN namespace aud {
+
+/// Closes the audaspace namespace aud.
+#define AUD_NAMESPACE_END }
+
+#else
+
+/// Opens the audaspace namespace aud.
+#define AUD_NAMESPACE_BEGIN
+
+/// Closes the audaspace namespace aud.
+#define AUD_NAMESPACE_END
+
+#endif
+
+AUD_NAMESPACE_BEGIN
+
+/// Sample type.(float samples)
+typedef float sample_t;
+
+/// Sample data type (format samples)
+typedef unsigned char data_t;
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/Exception.h b/extern/audaspace/include/Exception.h
new file mode 100644
index 00000000000..b102bfade63
--- /dev/null
+++ b/extern/audaspace/include/Exception.h
@@ -0,0 +1,185 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * \def AUD_NOEXCEPT
+ * Compatibility macro for noexcept.
+ */
+#ifdef _MSC_VER
+#define AUD_NOEXCEPT
+#else
+#define AUD_NOEXCEPT noexcept
+#endif
+
+/**
+ * @file Exception.h
+ * @ingroup general
+ * Defines the Exception class as well as the AUD_THROW macro for easy throwing.
+ */
+
+#include "Audaspace.h"
+
+#include <exception>
+#include <string>
+
+/// Throws a Exception with the provided error code.
+#define AUD_THROW(exception, message) { throw exception(message, __FILE__, __LINE__); }
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * The Exception class is the general exception base class.
+ */
+class AUD_API Exception : public std::exception
+{
+protected:
+ /// A message describing the problem.
+ const std::string m_message;
+
+ /// The source code file in which the exception was thrown.
+ const std::string m_file;
+
+ /// The source code line from which the exception was thrown.
+ const int m_line;
+
+ /**
+ * Copy constructor.
+ * @param exception The exception to be copied.
+ */
+ Exception(const Exception& exception);
+
+ /**
+ * Creates a new Exception object.
+ * @param message A message describing the problem.
+ * @param file The source code file in which the exception was thrown.
+ * @param line The source code line from which the exception was thrown.
+ */
+ Exception(std::string message, std::string file, int line);
+public:
+ /**
+ * Destroys the object.
+ */
+ virtual ~Exception() AUD_NOEXCEPT;
+
+ /**
+ * Returns the error message.
+ * @return A C string error message.
+ */
+ virtual const char* what() const AUD_NOEXCEPT;
+
+ /**
+ * Returns the error message plus file and line number for debugging purposes.
+ * @return The error message including debug information.
+ */
+ virtual std::string getDebugMessage() const;
+
+ /**
+ * Returns the error message.
+ * @return The error message as string.
+ */
+ const std::string& getMessage() const;
+
+ /**
+ * Returns the file in which the exception was thrown.
+ * @return The name of the file in which the exception was thrown.
+ */
+ const std::string& getFile() const;
+
+ /**
+ * Returns the line where the exception was originally thrown.
+ * @return The line of the source file where the exception was generated.
+ */
+ int getLine() const;
+};
+
+/**
+ * The FileException class is used for error cases in which files cannot
+ * be read or written due to unknown containers or codecs.
+ */
+class AUD_API FileException : public Exception
+{
+public:
+ /**
+ * Creates a new FileException object.
+ * @param message A message describing the problem.
+ * @param file The source code file in which the exception was thrown.
+ * @param line The source code line from which the exception was thrown.
+ */
+ FileException(std::string message, std::string file, int line);
+
+ /**
+ * Copy constructor.
+ * @param exception The exception to be copied.
+ */
+ FileException(const FileException& exception);
+
+ ~FileException() AUD_NOEXCEPT;
+};
+
+/**
+ * The DeviceException class is used for error cases in connection with
+ * devices, which usually happens when specific features or requests
+ * cannot be fulfilled by a device, for example when the device is opened.
+ */
+class AUD_API DeviceException : public Exception
+{
+public:
+ /**
+ * Creates a new DeviceException object.
+ * @param message A message describing the problem.
+ * @param file The source code file in which the exception was thrown.
+ * @param line The source code line from which the exception was thrown.
+ */
+ DeviceException(std::string message, std::string file, int line);
+
+ /**
+ * Copy constructor.
+ * @param exception The exception to be copied.
+ */
+ DeviceException(const DeviceException& exception);
+
+ ~DeviceException() AUD_NOEXCEPT;
+};
+
+/**
+ * The StateException class is used for error cases of sounds or readers
+ * with illegal states or requirements for states of dependent classes.
+ * It is used for example when an effect reader needs a specific
+ * specification from its input.
+ */
+class AUD_API StateException : public Exception
+{
+public:
+ /**
+ * Creates a new StateException object.
+ * @param message A message describing the problem.
+ * @param file The source code file in which the exception was thrown.
+ * @param line The source code line from which the exception was thrown.
+ */
+ StateException(std::string message, std::string file, int line);
+
+ /**
+ * Copy constructor.
+ * @param exception The exception to be copied.
+ */
+ StateException(const StateException& exception);
+
+ ~StateException() AUD_NOEXCEPT;
+};
+
+AUD_NAMESPACE_END
diff --git a/intern/audaspace/intern/AUD_IReader.h b/extern/audaspace/include/IReader.h
index c2c9e607b55..c29900ca579 100644
--- a/intern/audaspace/intern/AUD_IReader.h
+++ b/extern/audaspace/include/IReader.h
@@ -1,48 +1,43 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
*
- * Copyright 2009-2011 Jörg Hermann Müller
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * This file is part of AudaSpace.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * 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 *****
- */
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
-/** \file audaspace/intern/AUD_IReader.h
- * \ingroup audaspaceintern
- */
+#pragma once
+/**
+ * @file IReader.h
+ * @ingroup general
+ * The IReader interface.
+ */
-#ifndef __AUD_IREADER_H__
-#define __AUD_IREADER_H__
+#include "respec/Specification.h"
-#include "AUD_Space.h"
+AUD_NAMESPACE_BEGIN
/**
+ * @interface IReader
* This class represents a sound source as stream or as buffer which can be read
* for example by another reader, a device or whatever.
*/
-class AUD_IReader
+class AUD_API IReader
{
public:
/**
* Destroys the reader.
*/
- virtual ~AUD_IReader() {}
+ virtual ~IReader() {}
/**
* Tells whether the source provides seeking functionality or not.
@@ -77,9 +72,9 @@ public:
/**
* Returns the specification of the reader.
- * \return The AUD_Specs structure.
+ * \return The Specs structure.
*/
- virtual AUD_Specs getSpecs() const=0;
+ virtual Specs getSpecs() const=0;
/**
* Request to read the next length samples out of the source.
@@ -94,4 +89,4 @@ public:
virtual void read(int& length, bool& eos, sample_t* buffer)=0;
};
-#endif //__AUD_IREADER_H__
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/ISound.h b/extern/audaspace/include/ISound.h
new file mode 100644
index 00000000000..c28337e1b4e
--- /dev/null
+++ b/extern/audaspace/include/ISound.h
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file ISound.h
+ * @ingroup general
+ * The ISound interface.
+ */
+
+#include "Audaspace.h"
+
+#include <memory>
+
+AUD_NAMESPACE_BEGIN
+
+class IReader;
+
+/**
+ * @interface ISound
+ * 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
+ * of the respective sound source through the factory method createReader.
+ */
+class AUD_API ISound
+{
+public:
+ /**
+ * Destroys the sound.
+ */
+ virtual ~ISound() {}
+
+ /**
+ * Creates a reader for playback of the sound source.
+ * \return A pointer to an IReader object or nullptr if there has been an
+ * error.
+ * \exception Exception An exception may be thrown if there has been
+ * a more unexpected error during reader creation.
+ */
+ virtual std::shared_ptr<IReader> createReader()=0;
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/devices/DefaultSynchronizer.h b/extern/audaspace/include/devices/DefaultSynchronizer.h
new file mode 100644
index 00000000000..31f6c65219c
--- /dev/null
+++ b/extern/audaspace/include/devices/DefaultSynchronizer.h
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file DefaultSynchronizer.h
+ * @ingroup devices
+ * The DefaultSynchronizer class.
+ */
+
+#include "ISynchronizer.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This class is a default ISynchronizer implementation that actually does no
+ * synchronization and is intended for devices that don't support it.
+ */
+class AUD_API DefaultSynchronizer : public ISynchronizer
+{
+public:
+ virtual void seek(std::shared_ptr<IHandle> handle, float time);
+ virtual float getPosition(std::shared_ptr<IHandle> handle);
+ virtual void play();
+ virtual void stop();
+ virtual void setSyncCallback(syncFunction function, void* data);
+ virtual int isPlaying();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/devices/DeviceManager.h b/extern/audaspace/include/devices/DeviceManager.h
new file mode 100644
index 00000000000..27a546630e8
--- /dev/null
+++ b/extern/audaspace/include/devices/DeviceManager.h
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file DeviceManager.h
+ * @ingroup devices
+ * The DeviceManager class.
+ */
+
+#include "Audaspace.h"
+
+#include <memory>
+#include <vector>
+#include <unordered_map>
+
+AUD_NAMESPACE_BEGIN
+
+class IDevice;
+class IDeviceFactory;
+class I3DDevice;
+
+/**
+ * This class manages all device plugins and maintains a device if asked to do so.
+ *
+ * This enables applications to access their output device without having to carry
+ * it through the whole application.
+ */
+class AUD_API DeviceManager
+{
+private:
+ static std::unordered_map<std::string, std::shared_ptr<IDeviceFactory>> m_factories;
+
+ static std::shared_ptr<IDevice> m_device;
+
+ // delete copy constructor and operator=
+ DeviceManager(const DeviceManager&) = delete;
+ DeviceManager& operator=(const DeviceManager&) = delete;
+ DeviceManager() = delete;
+
+public:
+ /**
+ * Registers a device factory.
+ *
+ * This method is mostly used by plugin developers to add their device implementation
+ * for general use by the library end users.
+ * @param name A representative name for the device.
+ * @param factory The factory that creates the device.
+ */
+ static void registerDevice(std::string name, std::shared_ptr<IDeviceFactory> factory);
+
+ /**
+ * Returns the factory for a specific device.
+ * @param name The representative name of the device.
+ * @return The factory if it was found, or nullptr otherwise.
+ */
+ static std::shared_ptr<IDeviceFactory> getDeviceFactory(std::string name);
+
+ /**
+ * Returns the default device based on the priorities of the registered factories.
+ * @return The default device or nullptr if no factory has been registered.
+ */
+ static std::shared_ptr<IDeviceFactory> getDefaultDeviceFactory();
+
+
+ /**
+ * Sets a device that should be handled by the manager.
+ *
+ * If a device is currently being handled it will be released.
+ * @param device The device the manager should take care of.
+ */
+ static void setDevice(std::shared_ptr<IDevice> device);
+
+ /**
+ * Opens a device which will then be handled by the manager.
+ *
+ * If a device is currently being handled it will be released.
+ * @param name The representative name of the device.
+ */
+ static void openDevice(std::string name);
+
+ /**
+ * Opens the default device which will then be handled by the manager.
+ *
+ * The device to open is selected based on the priority of the registered factories.
+ * If a device is currently being handled it will be released.
+ */
+ static void openDefaultDevice();
+
+ /**
+ * Releases the currently handled device.
+ */
+ static void releaseDevice();
+
+ /**
+ * Returns the currently handled device.
+ * @return The handled device or nullptr if no device has been registered.
+ */
+ static std::shared_ptr<IDevice> getDevice();
+
+ /**
+ * Returns the currently handled 3D device.
+ * @return The handled device or nullptr if no device has been registered
+ * or the registered device is not an I3DDevice.
+ */
+ static std::shared_ptr<I3DDevice> get3DDevice();
+
+ /**
+ * Returns a list of available devices.
+ * @return A list of strings with the names of available devices.
+ */
+ static std::vector<std::string> getAvailableDeviceNames();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/devices/I3DDevice.h b/extern/audaspace/include/devices/I3DDevice.h
new file mode 100644
index 00000000000..f49bbcbb07e
--- /dev/null
+++ b/extern/audaspace/include/devices/I3DDevice.h
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file I3DDevice.h
+ * @ingroup devices
+ * Defines the I3DDevice interface as well as the different distance models.
+ */
+
+#include "util/Math3D.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * Possible distance models for the 3D device.
+ *
+ * The distance models supported are the same as documented in the [OpenAL Specification](http://openal.org/).
+ */
+enum DistanceModel
+{
+ DISTANCE_MODEL_INVALID = 0,
+ DISTANCE_MODEL_INVERSE,
+ DISTANCE_MODEL_INVERSE_CLAMPED,
+ DISTANCE_MODEL_LINEAR,
+ DISTANCE_MODEL_LINEAR_CLAMPED,
+ DISTANCE_MODEL_EXPONENT,
+ DISTANCE_MODEL_EXPONENT_CLAMPED
+};
+
+/**
+ * @interface I3DDevice
+ * The I3DDevice interface represents an output device for 3D sound.
+ *
+ * The interface has been modelled after the OpenAL 1.1 API,
+ * see the [OpenAL Specification](http://openal.org/) for lots of details.
+ */
+class AUD_API I3DDevice
+{
+public:
+ /**
+ * Retrieves the listener location.
+ * \return The listener location.
+ */
+ virtual Vector3 getListenerLocation() const=0;
+
+ /**
+ * Sets the listener location.
+ * \param location The new location.
+ * \note The location is not updated with the velocity and
+ * remains constant until the next call of this method.
+ */
+ virtual void setListenerLocation(const Vector3& location)=0;
+
+ /**
+ * Retrieves the listener velocity.
+ * \return The listener velocity.
+ */
+ virtual Vector3 getListenerVelocity() const=0;
+
+ /**
+ * Sets the listener velocity.
+ * \param velocity The new velocity.
+ * \note This velocity does not change the position of the listener
+ * over time, it is simply used for the calculation of the doppler effect.
+ */
+ virtual void setListenerVelocity(const Vector3& velocity)=0;
+
+ /**
+ * Retrieves the listener orientation.
+ * \return The listener orientation as quaternion.
+ */
+ virtual Quaternion getListenerOrientation() const=0;
+
+ /**
+ * Sets the listener orientation.
+ * \param orientation The new orientation as quaternion.
+ * \note The coordinate system used is right handed and the listener
+ * by default is oriented looking in the negative z direction with the
+ * positive y axis as up direction.
+ */
+ virtual void setListenerOrientation(const Quaternion& orientation)=0;
+
+
+ /**
+ * Retrieves the speed of sound.
+ * This value is needed for doppler effect calculation.
+ * \return The speed of sound.
+ */
+ virtual float getSpeedOfSound() const=0;
+
+ /**
+ * Sets the speed of sound.
+ * This value is needed for doppler effect calculation.
+ * \param speed The new speed of sound.
+ */
+ virtual void setSpeedOfSound(float speed)=0;
+
+ /**
+ * 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.
+ */
+ virtual float getDopplerFactor() const=0;
+
+ /**
+ * 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.
+ */
+ virtual void setDopplerFactor(float factor)=0;
+
+ /**
+ * Retrieves the distance model.
+ * \return The distance model.
+ */
+ virtual DistanceModel getDistanceModel() const=0;
+
+ /**
+ * Sets the distance model.
+ * \param model distance model.
+ */
+ virtual void setDistanceModel(DistanceModel model)=0;
+};
+
+AUD_NAMESPACE_END
diff --git a/intern/audaspace/intern/AUD_I3DHandle.h b/extern/audaspace/include/devices/I3DHandle.h
index 69ca985630a..2ff29f9bd21 100644
--- a/intern/audaspace/intern/AUD_I3DHandle.h
+++ b/extern/audaspace/include/devices/I3DHandle.h
@@ -1,87 +1,94 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
*
- * Copyright 2009-2011 Jörg Hermann Müller
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * This file is part of AudaSpace.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * 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 *****
- */
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
-/** \file audaspace/intern/AUD_I3DHandle.h
- * \ingroup audaspaceintern
- */
+#pragma once
+/**
+ * @file I3DHandle.h
+ * @ingroup devices
+ * The I3DHandle interface.
+ */
-#ifndef __AUD_I3DHANDLE_H__
-#define __AUD_I3DHANDLE_H__
+#include "util/Math3D.h"
-#include "AUD_Space.h"
-#include "AUD_3DMath.h"
+AUD_NAMESPACE_BEGIN
/**
- * This class represents a playback handle for 3D sources.
+ * @interface I3DHandle
+ * The I3DHandle interface represents a playback handle for 3D sources.
+ * If the playback IDevice class also implements the I3DDevice interface
+ * then all playback IHandle instances also implement this interface.
+ *
+ * The interface has been modelled after the OpenAL 1.1 API,
+ * see the [OpenAL Specification](http://openal.org/) for lots of details.
*/
-class AUD_I3DHandle
+class AUD_API I3DHandle
{
public:
/**
* Destroys the handle.
*/
- virtual ~AUD_I3DHandle() {}
+ virtual ~I3DHandle() {}
/**
- * Retrieves the location of a source.
+ * Retrieves the location of the source.
* \return The location.
*/
- virtual AUD_Vector3 getSourceLocation()=0;
+ virtual Vector3 getLocation()=0;
/**
- * Sets the location of a source.
+ * Sets the location of the source.
* \param location The new location.
* \return Whether the action succeeded.
+ * \note The location is not updated with the velocity and
+ * remains constant until the next call of this method.
*/
- virtual bool setSourceLocation(const AUD_Vector3& location)=0;
+ virtual bool setLocation(const Vector3& location)=0;
/**
- * Retrieves the velocity of a source.
+ * Retrieves the velocity of the source.
* \return The velocity.
*/
- virtual AUD_Vector3 getSourceVelocity()=0;
+ virtual Vector3 getVelocity()=0;
/**
- * Sets the velocity of a source.
+ * Sets the velocity of the source.
* \param velocity The new velocity.
* \return Whether the action succeeded.
+ * \note This velocity does not change the position of the listener
+ * over time, it is simply used for the calculation of the doppler effect.
*/
- virtual bool setSourceVelocity(const AUD_Vector3& velocity)=0;
+ virtual bool setVelocity(const Vector3& velocity)=0;
/**
- * Retrieves the orientation of a source.
+ * Retrieves the orientation of the source.
* \return The orientation as quaternion.
*/
- virtual AUD_Quaternion getSourceOrientation()=0;
+ virtual Quaternion getOrientation()=0;
/**
- * Sets the orientation of a source.
+ * Sets the orientation of the source.
* \param orientation The new orientation as quaternion.
* \return Whether the action succeeded.
+ * \note The coordinate system used is right handed and the source
+ * by default is oriented looking in the negative z direction with the
+ * positive y axis as up direction.
+ * \note This setting currently only affects sounds with non-default cone settings.
*/
- virtual bool setSourceOrientation(const AUD_Quaternion& orientation)=0;
+ virtual bool setOrientation(const Quaternion& orientation)=0;
/**
@@ -96,6 +103,7 @@ public:
* to the listener.
* \param relative Whether the source is relative.
* \return Whether the action succeeded.
+ * \note The default value is true as this setting is used to play sounds ordinarily without 3D.
*/
virtual bool setRelative(bool relative)=0;
@@ -170,28 +178,34 @@ public:
virtual bool setAttenuation(float factor)=0;
/**
- * Retrieves the outer angle of the cone of a source.
+ * Retrieves the outer opening angle of the cone of a source.
* \return The outer angle of the cone.
+ * \note This angle is defined in degrees.
*/
virtual float getConeAngleOuter()=0;
/**
- * Sets the outer angle of the cone of a source.
+ * Sets the outer opening angle of the cone of a source.
* \param angle The new outer angle of the cone.
* \return Whether the action succeeded.
+ * \note This angle is defined in degrees.
*/
virtual bool setConeAngleOuter(float angle)=0;
/**
- * Retrieves the inner angle of the cone of a source.
+ * Retrieves the inner opening angle of the cone of a source.
+ * The volume inside this cone is unaltered.
* \return The inner angle of the cone.
+ * \note This angle is defined in degrees.
*/
virtual float getConeAngleInner()=0;
/**
- * Sets the inner angle of the cone of a source.
+ * Sets the inner opening angle of the cone of a source.
+ * The volume inside this cone is unaltered.
* \param angle The new inner angle of the cone.
* \return Whether the action succeeded.
+ * \note This angle is defined in degrees.
*/
virtual bool setConeAngleInner(float angle)=0;
@@ -200,6 +214,7 @@ public:
* The volume between inner and outer angle is interpolated between inner
* volume and this value.
* \return The outer volume of the cone.
+ * \note The general volume of the handle still applies on top of this.
*/
virtual float getConeVolumeOuter()=0;
@@ -209,8 +224,9 @@ public:
* volume and this value.
* \param volume The new outer volume of the cone.
* \return Whether the action succeeded.
+ * \note The general volume of the handle still applies on top of this.
*/
virtual bool setConeVolumeOuter(float volume)=0;
};
-#endif //__AUD_I3DHANDLE_H__
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/devices/IDevice.h b/extern/audaspace/include/devices/IDevice.h
new file mode 100644
index 00000000000..92a85d900e2
--- /dev/null
+++ b/extern/audaspace/include/devices/IDevice.h
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file IDevice.h
+ * @ingroup devices
+ * The IDevice interface.
+ */
+
+#include "respec/Specification.h"
+#include "util/ILockable.h"
+
+#include <memory>
+
+AUD_NAMESPACE_BEGIN
+
+class IHandle;
+class IReader;
+class ISound;
+class ISynchronizer;
+
+/**
+ * @interface IDevice
+ * The IDevice interface represents an output device for sound sources.
+ * Output devices may be several backends such as plattform independand like
+ * SDL or OpenAL or plattform specific like ALSA, but they may also be
+ * files, RAM buffers or other types of streams.
+ * \warning Thread safety must be insured so that no reader is beeing called
+ * twice at the same time.
+ */
+class IDevice : public ILockable
+{
+public:
+ /**
+ * Destroys the device.
+ */
+ virtual ~IDevice() {}
+
+ /**
+ * Returns the specification of the device.
+ */
+ virtual DeviceSpecs getSpecs() const=0;
+
+ /**
+ * Plays a sound source.
+ * \param reader The reader to play.
+ * \param keep When keep is true the sound source will not be deleted but
+ * set to paused when its end has been reached.
+ * \return Returns a handle with which the playback can be controlled.
+ * This is nullptr if the sound couldn't be played back.
+ * \exception Exception Thrown if there's an unexpected (from the
+ * device side) error during creation of the reader.
+ */
+ virtual std::shared_ptr<IHandle> play(std::shared_ptr<IReader> reader, bool keep = false)=0;
+
+ /**
+ * Plays a sound source.
+ * \param sound The sound to create the reader for the sound source.
+ * \param keep When keep is true the sound source will not be deleted but
+ * set to paused when its end has been reached.
+ * \return Returns a handle with which the playback can be controlled.
+ * This is nullptr if the sound couldn't be played back.
+ * \exception Exception Thrown if there's an unexpected (from the
+ * device side) error during creation of the reader.
+ */
+ virtual std::shared_ptr<IHandle> play(std::shared_ptr<ISound> sound, bool keep = false)=0;
+
+ /**
+ * Stops all playing sounds.
+ */
+ virtual void stopAll()=0;
+
+ /**
+ * Locks the device.
+ * Used to make sure that between lock and unlock, no buffers are read, so
+ * that it is possible to start, resume, pause, stop or seek several
+ * playback handles simultaneously.
+ * \warning Make sure the locking time is as small as possible to avoid
+ * playback delays that result in unexpected noise and cracks.
+ */
+ virtual void lock()=0;
+
+ /**
+ * Unlocks the previously locked device.
+ */
+ virtual void unlock()=0;
+
+ /**
+ * Retrieves the overall device volume.
+ * \return The overall device volume.
+ */
+ virtual float getVolume() const=0;
+
+ /**
+ * Sets the overall device volume.
+ * \param volume The overall device volume.
+ */
+ virtual void setVolume(float volume)=0;
+
+ /**
+ * Retrieves the synchronizer for this device, which enables accurate synchronization
+ * between audio playback and video playback for example.
+ * @return The synchronizer which will be the DefaultSynchronizer if synchonization is not supported.
+ */
+ virtual ISynchronizer* getSynchronizer()=0;
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/devices/IDeviceFactory.h b/extern/audaspace/include/devices/IDeviceFactory.h
new file mode 100644
index 00000000000..6a0f4537b13
--- /dev/null
+++ b/extern/audaspace/include/devices/IDeviceFactory.h
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file IDeviceFactory.h
+ * @ingroup devices
+ * The IDeviceFactory interface.
+ */
+
+#include "respec/Specification.h"
+
+#include <memory>
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * @interface IDeviceFactory
+ * The IDeviceFactory interface opens an output device.
+ */
+class AUD_API IDeviceFactory
+{
+public:
+ /**
+ * Opens an audio device for playback.
+ * \exception Exception Thrown if the audio device cannot be opened.
+ */
+ virtual std::shared_ptr<IDevice> openDevice()=0;
+
+ /**
+ * Returns the priority of the device to be the default device for a system.
+ * The higher the priority the more likely it is for this device to be used as the default device.
+ * \return Priority to be the default device.
+ */
+ virtual int getPriority()=0;
+
+ /**
+ * Sets the wanted device specifications for opening the device.
+ * \param specs The wanted audio specification.
+ */
+ virtual void setSpecs(DeviceSpecs specs)=0;
+
+ /**
+ * Sets the size for the internal playback buffers.
+ * The bigger the buffersize, the less likely clicks happen,
+ * but the latency increases too.
+ * \param buffersize The size of the internal buffer.
+ */
+ virtual void setBufferSize(int buffersize)=0;
+
+ /**
+ * Sets a name for the device.
+ * \param name The internal name for the device.
+ */
+ virtual void setName(std::string name)=0;
+};
+
+AUD_NAMESPACE_END
diff --git a/intern/audaspace/intern/AUD_IHandle.h b/extern/audaspace/include/devices/IHandle.h
index c80fb4027b8..3f42fc33c3a 100644
--- a/intern/audaspace/intern/AUD_IHandle.h
+++ b/extern/audaspace/include/devices/IHandle.h
@@ -1,49 +1,57 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
*
- * Copyright 2009-2011 Jörg Hermann Müller
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * This file is part of AudaSpace.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * 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 *****
- */
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
-/** \file audaspace/intern/AUD_IHandle.h
- * \ingroup audaspaceintern
+/**
+ * @file IHandle.h
+ * @ingroup devices
+ * Defines the IHandle interface as well as possible states of the handle.
*/
-#ifndef __AUD_IHANDLE_H__
-#define __AUD_IHANDLE_H__
+#include "Audaspace.h"
-//#include "AUD_Space.h"
-//#include "AUD_Reference.h"
+AUD_NAMESPACE_BEGIN
+/// Status of a playback handle.
+enum Status
+{
+ STATUS_INVALID = 0, /// Invalid handle. Maybe due to stopping.
+ STATUS_PLAYING, /// Sound is playing.
+ STATUS_PAUSED, /// Sound is being paused.
+ STATUS_STOPPED /// Sound is stopped but kept in the device.
+};
+
+/**
+ * The stopCallback is called when a handle reaches the end of the stream and
+ * thus gets stopped. A user defined pointer is supplied to the callback.
+ */
typedef void (*stopCallback)(void*);
/**
- * This class represents a playback handles for specific devices.
+ * @interface IHandle
+ * The IHandle interface represents a playback handles of a specific device.
*/
-class AUD_IHandle
+class AUD_API IHandle
{
public:
/**
* Destroys the handle.
*/
- virtual ~AUD_IHandle() {}
+ virtual ~IHandle() {}
/**
* Pauses a played back sound.
@@ -109,15 +117,15 @@ public:
/**
* Returns the status of a played back sound.
* \return
- * - AUD_STATUS_INVALID if the sound has stopped or the handle is
+ * - STATUS_INVALID if the sound has stopped or the handle is
*. invalid
- * - AUD_STATUS_PLAYING if the sound is currently played back.
- * - AUD_STATUS_PAUSED if the sound is currently paused.
- * - AUD_STATUS_STOPPED if the sound finished playing and is still
+ * - STATUS_PLAYING if the sound is currently played back.
+ * - STATUS_PAUSED if the sound is currently paused.
+ * - STATUS_STOPPED if the sound finished playing and is still
* kept in the device.
- * \see AUD_Status
+ * \see Status
*/
- virtual AUD_Status getStatus()=0;
+ virtual Status getStatus()=0;
/**
* Retrieves the volume of a playing sound.
@@ -178,4 +186,4 @@ public:
virtual bool setStopCallback(stopCallback callback = 0, void* data = 0)=0;
};
-#endif //AUD_IHandle
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/devices/ISynchronizer.h b/extern/audaspace/include/devices/ISynchronizer.h
new file mode 100644
index 00000000000..6f14de59565
--- /dev/null
+++ b/extern/audaspace/include/devices/ISynchronizer.h
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file ISynchronizer.h
+ * @ingroup devices
+ * The ISynchronizer interface.
+ */
+
+#include "Audaspace.h"
+
+#include <memory>
+
+AUD_NAMESPACE_BEGIN
+
+class IHandle;
+
+/**
+ * @interface ISynchronizer
+ * This class enables global synchronization of several audio applications if supported.
+ * JACK for example supports synchronization through JACK Transport.
+ */
+class AUD_API ISynchronizer
+{
+public:
+ /**
+ * Destroys the synchronizer.
+ */
+ virtual ~ISynchronizer() {}
+
+ /**
+ * The syncFunction is called when a synchronization event happens.
+ * The function awaits three parameters. The first one is a user defined
+ * pointer, the second informs about whether playback is on and the third
+ * is the current playback time in seconds.
+ */
+ typedef void (*syncFunction)(void*, int, float);
+
+ /**
+ * Sets the playback position of a handle and the synchronizer to a specific time.
+ * @param handle The handle that should be synchronized/seeked.
+ * @param time The absolute time to synchronize to.
+ */
+ virtual void seek(std::shared_ptr<IHandle> handle, float time) = 0;
+
+ /**
+ * Retrieves the position of the synchronizer.
+ * @param handle The handle which is synchronized.
+ * @return The position in seconds.
+ */
+ virtual float getPosition(std::shared_ptr<IHandle> handle) = 0;
+
+ /**
+ * Starts the synchronizer playback.
+ */
+ virtual void play() = 0;
+
+ /**
+ * Stops the synchronizer playback.
+ */
+ virtual void stop() = 0;
+
+ /**
+ * Sets the callback function that is called when a synchronization event happens.
+ * @param function The function to be called.
+ * @param data User data to be passed to the callback.
+ */
+ virtual void setSyncCallback(syncFunction function, void* data) = 0;
+
+ /**
+ * Retrieves whether the synchronizer is playing back.
+ * @return Whether the synchronizer plays back.
+ */
+ virtual int isPlaying() = 0;
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/devices/NULLDevice.h b/extern/audaspace/include/devices/NULLDevice.h
new file mode 100644
index 00000000000..76211a799b9
--- /dev/null
+++ b/extern/audaspace/include/devices/NULLDevice.h
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file NULLDevice.h
+ * @ingroup devices
+ * The NULLDevice class.
+ */
+
+#include "devices/IDevice.h"
+#include "devices/IHandle.h"
+
+AUD_NAMESPACE_BEGIN
+
+class IReader;
+
+/**
+ * This device plays nothing.
+ * It is similar to the linux device /dev/null.
+ */
+class AUD_API NULLDevice : public IDevice
+{
+private:
+ class AUD_LOCAL NULLHandle : public IHandle
+ {
+ private:
+ // delete copy constructor and operator=
+ NULLHandle(const NULLHandle&) = delete;
+ NULLHandle& operator=(const NULLHandle&) = delete;
+
+ public:
+
+ NULLHandle();
+
+ virtual ~NULLHandle() {}
+ virtual bool pause();
+ virtual bool resume();
+ virtual bool stop();
+ virtual bool getKeep();
+ virtual bool setKeep(bool keep);
+ virtual bool seek(float position);
+ virtual float getPosition();
+ virtual Status getStatus();
+ virtual float getVolume();
+ virtual bool setVolume(float volume);
+ virtual float getPitch();
+ virtual bool setPitch(float pitch);
+ virtual int getLoopCount();
+ virtual bool setLoopCount(int count);
+ virtual bool setStopCallback(stopCallback callback = 0, void* data = 0);
+ };
+
+ // delete copy constructor and operator=
+ NULLDevice(const NULLDevice&) = delete;
+ NULLDevice& operator=(const NULLDevice&) = delete;
+
+public:
+ /**
+ * Creates a new NULLDevice.
+ */
+ NULLDevice();
+
+ virtual ~NULLDevice();
+
+ virtual DeviceSpecs getSpecs() const;
+ virtual std::shared_ptr<IHandle> play(std::shared_ptr<IReader> reader, bool keep = false);
+ virtual std::shared_ptr<IHandle> play(std::shared_ptr<ISound> sound, bool keep = false);
+ virtual void stopAll();
+ virtual void lock();
+ virtual void unlock();
+ virtual float getVolume() const;
+ virtual void setVolume(float volume);
+ virtual ISynchronizer* getSynchronizer();
+
+ /**
+ * Registers this plugin.
+ */
+ static void registerPlugin();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/devices/ReadDevice.h b/extern/audaspace/include/devices/ReadDevice.h
new file mode 100644
index 00000000000..b56bd8ce5c4
--- /dev/null
+++ b/extern/audaspace/include/devices/ReadDevice.h
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file ReadDevice.h
+ * @ingroup devices
+ * The ReadDevice class.
+ */
+
+#include "devices/SoftwareDevice.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This device enables to let the user read raw data out of it.
+ */
+class AUD_API ReadDevice : public SoftwareDevice
+{
+private:
+ /**
+ * Whether the device is currently playing back.
+ */
+ bool m_playing;
+
+ // delete copy constructor and operator=
+ ReadDevice(const ReadDevice&) = delete;
+ ReadDevice& operator=(const ReadDevice&) = delete;
+
+protected:
+ virtual void AUD_LOCAL playing(bool playing);
+
+public:
+ /**
+ * Creates a new read device.
+ * \param specs The wanted audio specification.
+ */
+ ReadDevice(DeviceSpecs specs);
+
+ /**
+ * Creates a new read device.
+ * \param specs The wanted audio specification.
+ */
+ ReadDevice(Specs specs);
+
+ /**
+ * Closes the device.
+ */
+ virtual ~ReadDevice();
+
+ /**
+ * Reads the next bytes into the supplied buffer.
+ * \param buffer The target buffer.
+ * \param length The length in samples to be filled.
+ * \return True if the reading succeeded, false if there are no sounds
+ * played back currently, in that case the buffer is filled with
+ * silence.
+ */
+ bool read(data_t* buffer, int length);
+
+ /**
+ * Changes the output specification.
+ * \param specs The new audio data specification.
+ */
+ void changeSpecs(Specs specs);
+};
+
+AUD_NAMESPACE_END
diff --git a/intern/audaspace/intern/AUD_SoftwareDevice.h b/extern/audaspace/include/devices/SoftwareDevice.h
index 54e49c87b27..8f3846394c6 100644
--- a/intern/audaspace/intern/AUD_SoftwareDevice.h
+++ b/extern/audaspace/include/devices/SoftwareDevice.h
@@ -1,74 +1,76 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
*
- * Copyright 2009-2011 Jörg Hermann Müller
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * This file is part of AudaSpace.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * 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 *****
- */
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
-/** \file audaspace/intern/AUD_SoftwareDevice.h
- * \ingroup audaspaceintern
+/**
+ * @file SoftwareDevice.h
+ * @ingroup devices
+ * The SoftwareDevice class.
*/
+#include "devices/IDevice.h"
+#include "devices/IHandle.h"
+#include "devices/I3DDevice.h"
+#include "devices/I3DHandle.h"
+#include "devices/DefaultSynchronizer.h"
+#include "util/Buffer.h"
-#ifndef __AUD_SOFTWAREDEVICE_H__
-#define __AUD_SOFTWAREDEVICE_H__
+#include <list>
+#include <mutex>
-#include "AUD_IDevice.h"
-#include "AUD_IHandle.h"
-#include "AUD_I3DDevice.h"
-#include "AUD_I3DHandle.h"
-#include "AUD_Mixer.h"
-#include "AUD_Buffer.h"
-#include "AUD_PitchReader.h"
-#include "AUD_ResampleReader.h"
-#include "AUD_ChannelMapperReader.h"
+AUD_NAMESPACE_BEGIN
-#include <list>
-#include <pthread.h>
+class Mixer;
+class PitchReader;
+class ResampleReader;
+class ChannelMapperReader;
/**
- * This device plays is a generic device with software mixing.
+ * The software device is a generic device with software mixing.
+ * It is a base class for all software mixing classes.
* Classes implementing this have to:
* - Implement the playing function.
* - Prepare the m_specs, m_mixer variables.
* - Call the create and destroy functions.
* - Call the mix function to retrieve their audio data.
*/
-class AUD_SoftwareDevice : public AUD_IDevice, public AUD_I3DDevice
+class AUD_API SoftwareDevice : public IDevice, public I3DDevice
{
protected:
/// Saves the data for playback.
- class AUD_SoftwareHandle : public AUD_IHandle, public AUD_I3DHandle
+ class AUD_API SoftwareHandle : public IHandle, public I3DHandle
{
+ private:
+ // delete copy constructor and operator=
+ SoftwareHandle(const SoftwareHandle&) = delete;
+ SoftwareHandle& operator=(const SoftwareHandle&) = delete;
+
public:
/// The reader source.
- boost::shared_ptr<AUD_IReader> m_reader;
+ std::shared_ptr<IReader> m_reader;
/// The pitch reader in between.
- boost::shared_ptr<AUD_PitchReader> m_pitch;
+ std::shared_ptr<PitchReader> m_pitch;
/// The resample reader in between.
- boost::shared_ptr<AUD_ResampleReader> m_resampler;
+ std::shared_ptr<ResampleReader> m_resampler;
/// The channel mapper reader in between.
- boost::shared_ptr<AUD_ChannelMapperReader> m_mapper;
+ std::shared_ptr<ChannelMapperReader> m_mapper;
/// Whether to keep the source if end of it is reached.
bool m_keep;
@@ -84,19 +86,21 @@ protected:
/// The calculated final volume of the source.
float m_volume;
+
+ /// The previous calculated final volume of the source.
float m_old_volume;
/// The loop count of the source.
int m_loopcount;
/// Location in 3D Space.
- AUD_Vector3 m_location;
+ Vector3 m_location;
/// Velocity in 3D Space.
- AUD_Vector3 m_velocity;
+ Vector3 m_velocity;
/// Orientation in 3D Space.
- AUD_Quaternion m_orientation;
+ Quaternion m_orientation;
/// Whether the position to the listener is relative or absolute
bool m_relative;
@@ -135,15 +139,19 @@ protected:
void* m_stop_data;
/// Current status of the handle
- AUD_Status m_status;
+ Status m_status;
/// Own device.
- AUD_SoftwareDevice* m_device;
+ SoftwareDevice* m_device;
+ /**
+ * This method is for internal use only.
+ * @param keep Whether the sound should be marked stopped or paused.
+ * @return Whether the action succeeded.
+ */
bool pause(bool keep);
public:
-
/**
* Creates a new software handle.
* \param device The device this handle is from.
@@ -153,7 +161,7 @@ protected:
* \param mapper The channel mapping reader.
* \param keep Whether to keep the handle when the sound ends.
*/
- 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);
+ SoftwareHandle(SoftwareDevice* device, std::shared_ptr<IReader> reader, std::shared_ptr<PitchReader> pitch, std::shared_ptr<ResampleReader> resampler, std::shared_ptr<ChannelMapperReader> mapper, bool keep);
/**
* Updates the handle's playback parameters.
@@ -162,11 +170,11 @@ protected:
/**
* Sets the audio output specification of the readers.
- * \param sepcs The output specification.
+ * \param specs The output specification.
*/
- void setSpecs(AUD_Specs specs);
+ void setSpecs(Specs specs);
- virtual ~AUD_SoftwareHandle() {}
+ virtual ~SoftwareHandle() {}
virtual bool pause();
virtual bool resume();
virtual bool stop();
@@ -174,7 +182,7 @@ protected:
virtual bool setKeep(bool keep);
virtual bool seek(float position);
virtual float getPosition();
- virtual AUD_Status getStatus();
+ virtual Status getStatus();
virtual float getVolume();
virtual bool setVolume(float volume);
virtual float getPitch();
@@ -183,12 +191,12 @@ protected:
virtual bool setLoopCount(int count);
virtual bool setStopCallback(stopCallback callback = 0, void* data = 0);
- virtual AUD_Vector3 getSourceLocation();
- virtual bool setSourceLocation(const AUD_Vector3& location);
- virtual AUD_Vector3 getSourceVelocity();
- virtual bool setSourceVelocity(const AUD_Vector3& velocity);
- virtual AUD_Quaternion getSourceOrientation();
- virtual bool setSourceOrientation(const AUD_Quaternion& orientation);
+ virtual Vector3 getLocation();
+ virtual bool setLocation(const Vector3& location);
+ virtual Vector3 getVelocity();
+ virtual bool setVelocity(const Vector3& velocity);
+ virtual Quaternion getOrientation();
+ virtual bool setOrientation(const Quaternion& orientation);
virtual bool isRelative();
virtual bool setRelative(bool relative);
virtual float getVolumeMaximum();
@@ -209,17 +217,15 @@ protected:
virtual bool setConeVolumeOuter(float volume);
};
- typedef std::list<boost::shared_ptr<AUD_SoftwareHandle> >::iterator AUD_HandleIterator;
-
/**
* The specification of the device.
*/
- AUD_DeviceSpecs m_specs;
+ DeviceSpecs m_specs;
/**
* The mixer.
*/
- boost::shared_ptr<AUD_Mixer> m_mixer;
+ std::shared_ptr<Mixer> m_mixer;
/**
* Whether to do high or low quality resampling.
@@ -251,25 +257,31 @@ protected:
/**
* Sets the audio output specification of the device.
- * \param sepcs The output specification.
+ * \param specs The output specification.
+ */
+ void setSpecs(Specs specs);
+
+ /**
+ * Empty default constructor. To setup the device call the function create()
+ * and to uninitialize call destroy().
*/
- void setSpecs(AUD_Specs specs);
+ SoftwareDevice();
private:
/**
* The reading buffer.
*/
- AUD_Buffer m_buffer;
+ Buffer m_buffer;
/**
* The list of sounds that are currently playing.
*/
- std::list<boost::shared_ptr<AUD_SoftwareHandle> > m_playingSounds;
+ std::list<std::shared_ptr<SoftwareHandle> > m_playingSounds;
/**
* The list of sounds that are currently paused.
*/
- std::list<boost::shared_ptr<AUD_SoftwareHandle> > m_pausedSounds;
+ std::list<std::shared_ptr<SoftwareHandle> > m_pausedSounds;
/**
* Whether there is currently playback.
@@ -279,7 +291,7 @@ private:
/**
* The mutex for locking.
*/
- pthread_mutex_t m_mutex;
+ std::recursive_mutex m_mutex;
/**
* The overall volume of the device.
@@ -287,13 +299,13 @@ private:
float m_volume;
/// Listener location.
- AUD_Vector3 m_location;
+ Vector3 m_location;
/// Listener velocity.
- AUD_Vector3 m_velocity;
+ Vector3 m_velocity;
/// Listener orientation.
- AUD_Quaternion m_orientation;
+ Quaternion m_orientation;
/// Speed of Sound.
float m_speed_of_sound;
@@ -302,11 +314,18 @@ private:
float m_doppler_factor;
/// Distance model.
- AUD_DistanceModel m_distance_model;
+ DistanceModel m_distance_model;
/// Rendering flags
int m_flags;
+ /// Synchronizer.
+ DefaultSynchronizer m_synchronizer;
+
+ // delete copy constructor and operator=
+ SoftwareDevice(const SoftwareDevice&) = delete;
+ SoftwareDevice& operator=(const SoftwareDevice&) = delete;
+
public:
/**
@@ -314,7 +333,7 @@ public:
* \param handle The handle to set the panning from.
* \param pan The new panning value, should be in the range [-2, 2].
*/
- static void setPanning(AUD_IHandle* handle, float pan);
+ static void setPanning(IHandle* handle, float pan);
/**
* Sets the resampling quality.
@@ -322,27 +341,28 @@ public:
*/
void setQuality(bool quality);
- virtual AUD_DeviceSpecs getSpecs() const;
- 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 DeviceSpecs getSpecs() const;
+ virtual std::shared_ptr<IHandle> play(std::shared_ptr<IReader> reader, bool keep = false);
+ virtual std::shared_ptr<IHandle> play(std::shared_ptr<ISound> sound, bool keep = false);
virtual void stopAll();
virtual void lock();
virtual void unlock();
virtual float getVolume() const;
virtual void setVolume(float volume);
-
- virtual AUD_Vector3 getListenerLocation() const;
- virtual void setListenerLocation(const AUD_Vector3& location);
- virtual AUD_Vector3 getListenerVelocity() const;
- virtual void setListenerVelocity(const AUD_Vector3& velocity);
- virtual AUD_Quaternion getListenerOrientation() const;
- virtual void setListenerOrientation(const AUD_Quaternion& orientation);
+ virtual ISynchronizer* getSynchronizer();
+
+ virtual Vector3 getListenerLocation() const;
+ virtual void setListenerLocation(const Vector3& location);
+ virtual Vector3 getListenerVelocity() const;
+ virtual void setListenerVelocity(const Vector3& velocity);
+ virtual Quaternion getListenerOrientation() const;
+ virtual void setListenerOrientation(const Quaternion& orientation);
virtual float getSpeedOfSound() const;
virtual void setSpeedOfSound(float speed);
virtual float getDopplerFactor() const;
virtual void setDopplerFactor(float factor);
- virtual AUD_DistanceModel getDistanceModel() const;
- virtual void setDistanceModel(AUD_DistanceModel model);
+ virtual DistanceModel getDistanceModel() const;
+ virtual void setDistanceModel(DistanceModel model);
};
-#endif //__AUD_SOFTWAREDEVICE_H__
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/file/File.h b/extern/audaspace/include/file/File.h
new file mode 100644
index 00000000000..24745a757e8
--- /dev/null
+++ b/extern/audaspace/include/file/File.h
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file File.h
+ * @ingroup file
+ * The File class.
+ */
+
+#include "ISound.h"
+
+#include <string>
+#include <memory>
+
+AUD_NAMESPACE_BEGIN
+
+class Buffer;
+
+/**
+ * The File sound tries to read a sound file via all available file inputs
+ * that have been registered in the FileManager class.
+ */
+class AUD_API File : public ISound
+{
+private:
+ /**
+ * The filename of the sound source file.
+ */
+ std::string m_filename;
+
+ /**
+ * The buffer to read from.
+ */
+ std::shared_ptr<Buffer> m_buffer;
+
+ // delete copy constructor and operator=
+ File(const File&) = delete;
+ File& operator=(const File&) = delete;
+
+public:
+ /**
+ * Creates a new sound.
+ * The file is read from the file system using the given path.
+ * \param filename The sound file path.
+ */
+ File(std::string filename);
+
+ /**
+ * Creates a new sound.
+ * The file is read from memory using the supplied buffer.
+ * \param buffer The buffer to read from.
+ * \param size The size of the buffer.
+ */
+ File(const data_t* buffer, int size);
+
+ virtual std::shared_ptr<IReader> createReader();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/file/FileManager.h b/extern/audaspace/include/file/FileManager.h
new file mode 100644
index 00000000000..03943ea8ae0
--- /dev/null
+++ b/extern/audaspace/include/file/FileManager.h
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file FileManager.h
+ * @ingroup file
+ * The FileManager class.
+ */
+
+#include "respec/Specification.h"
+#include "IWriter.h"
+
+#include <list>
+#include <memory>
+
+AUD_NAMESPACE_BEGIN
+
+class IFileInput;
+class IFileOutput;
+class IReader;
+class Buffer;
+
+/**
+ * The FileManager manages all file input and output plugins.
+ */
+class AUD_API FileManager
+{
+private:
+ static std::list<std::shared_ptr<IFileInput>>& inputs();
+ static std::list<std::shared_ptr<IFileOutput>>& outputs();
+
+ // delete copy constructor and operator=
+ FileManager(const FileManager&) = delete;
+ FileManager& operator=(const FileManager&) = delete;
+ FileManager() = delete;
+
+public:
+ /**
+ * Registers a file input used to create an IReader to read from a file.
+ * @param input The IFileInput to register.
+ */
+ static void registerInput(std::shared_ptr<IFileInput> input);
+
+ /**
+ * Registers a file output used to create an IWriter to write to a file.
+ * @param output The IFileOutput to register.
+ */
+ static void registerOutput(std::shared_ptr<IFileOutput> output);
+
+ /**
+ * Creates a file reader for the given filename if a registed IFileInput is able to read it.
+ * @param filename The path to the file.
+ * @return The reader created.
+ * @exception Exception If no file input can read the file an exception is thrown.
+ */
+ static std::shared_ptr<IReader> createReader(std::string filename);
+
+ /**
+ * Creates a file reader for the given buffer if a registed IFileInput is able to read it.
+ * @param buffer The buffer to read the file from.
+ * @return The reader created.
+ * @exception Exception If no file input can read the file an exception is thrown.
+ */
+ static std::shared_ptr<IReader> createReader(std::shared_ptr<Buffer> buffer);
+
+ /**
+ * Creates a file writer that writes a sound to the given file path.
+ * Existing files will be overwritten.
+ * @param filename The file path to write to.
+ * @param specs The output specification.
+ * @param format The container format for the file.
+ * @param codec The codec used inside the container.
+ * @param bitrate The bitrate to write with.
+ * @return A writer that creates the file.
+ * @exception Exception If no file output can write the file with the given specification an exception is thrown.
+ */
+ static std::shared_ptr<IWriter> createWriter(std::string filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/file/FileWriter.h b/extern/audaspace/include/file/FileWriter.h
new file mode 100644
index 00000000000..dac842f2a8f
--- /dev/null
+++ b/extern/audaspace/include/file/FileWriter.h
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file FileWriter.h
+ * @ingroup file
+ * The FileWriter class.
+ */
+
+#include "respec/Specification.h"
+#include "file/IWriter.h"
+
+#include <string>
+#include <vector>
+#include <memory>
+
+AUD_NAMESPACE_BEGIN
+
+class IReader;
+
+/**
+ * The FileWriter class is able to create IWriter classes as well as write readers to them.
+ */
+class AUD_API FileWriter
+{
+private:
+ // hide default constructor, copy constructor and operator=
+ FileWriter() = delete;
+ FileWriter(const FileWriter&) = delete;
+ FileWriter& operator=(const FileWriter&) = delete;
+
+public:
+ /**
+ * Creates a new IWriter.
+ * \param filename The file to write to.
+ * \param specs The file's audio specification.
+ * \param format The file's container format.
+ * \param codec The codec used for encoding the audio data.
+ * \param bitrate The bitrate for encoding.
+ * \return The writer to write data to.
+ */
+ static std::shared_ptr<IWriter> createWriter(std::string filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate);
+
+ /**
+ * Writes a reader to a writer.
+ * \param reader The reader to read from.
+ * \param writer The writer to write to.
+ * \param length How many samples should be transferred.
+ * \param buffersize How many samples should be transferred at once.
+ */
+ static void writeReader(std::shared_ptr<IReader> reader, std::shared_ptr<IWriter> writer, unsigned int length, unsigned int buffersize);
+
+ /**
+ * Writes a reader to several writers.
+ * \param reader The reader to read from.
+ * \param writers The writers to write to.
+ * \param length How many samples should be transferred.
+ * \param buffersize How many samples should be transferred at once.
+ */
+ static void writeReader(std::shared_ptr<IReader> reader, std::vector<std::shared_ptr<IWriter> >& writers, unsigned int length, unsigned int buffersize);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/file/IFileInput.h b/extern/audaspace/include/file/IFileInput.h
new file mode 100644
index 00000000000..bb016a88602
--- /dev/null
+++ b/extern/audaspace/include/file/IFileInput.h
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file IFileInput.h
+ * @ingroup file
+ * The IFileInput interface.
+ */
+
+#include "Audaspace.h"
+
+#include <memory>
+#include <string>
+
+AUD_NAMESPACE_BEGIN
+
+class IReader;
+class Buffer;
+
+/**
+ * @interface IFileInput
+ * The IFileInput interface represents a file input plugin that can create file
+ * input readers from filenames or buffers.
+ */
+class AUD_API IFileInput
+{
+public:
+ /**
+ * Creates a reader for a file to be read.
+ * \param filename Path to the file to be read.
+ * \return The reader that reads the file.
+ * \exception Exception Thrown if the file specified cannot be read.
+ */
+ virtual std::shared_ptr<IReader> createReader(std::string filename)=0;
+
+ /**
+ * Creates a reader for a file to be read from memory.
+ * \param buffer The in-memory file buffer.
+ * \return The reader that reads the file.
+ * \exception Exception Thrown if the file specified cannot be read.
+ */
+ virtual std::shared_ptr<IReader> createReader(std::shared_ptr<Buffer> buffer)=0;
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/file/IFileOutput.h b/extern/audaspace/include/file/IFileOutput.h
new file mode 100644
index 00000000000..5a6efacfe94
--- /dev/null
+++ b/extern/audaspace/include/file/IFileOutput.h
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file IFileOutput.h
+ * @ingroup file
+ * The IFileOutput interface.
+ */
+
+#include "file/IWriter.h"
+#include "respec/Specification.h"
+
+#include <memory>
+#include <string>
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * @interface IFileOutput
+ * The IFileOutput interface represents a file output plugin that can write files.
+ */
+class AUD_API IFileOutput
+{
+public:
+ /**
+ * Creates a new file writer.
+ * \param filename The path to the file to be written.
+ * \param specs The file's audio specification.
+ * \param format The file's container format.
+ * \param codec The codec used for encoding the audio data.
+ * \param bitrate The bitrate for encoding.
+ * \exception Exception Thrown if the file specified cannot be written.
+ */
+ virtual std::shared_ptr<IWriter> createWriter(std::string filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate)=0;
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/file/IWriter.h b/extern/audaspace/include/file/IWriter.h
new file mode 100644
index 00000000000..96decdda391
--- /dev/null
+++ b/extern/audaspace/include/file/IWriter.h
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file IWriter.h
+ * @ingroup file
+ * Defines the IWriter interface as well as Container and Codec types.
+ */
+
+#include "respec/Specification.h"
+
+AUD_NAMESPACE_BEGIN
+
+/// Container formats for writers.
+enum Container
+{
+ CONTAINER_INVALID = 0,
+ CONTAINER_AC3,
+ CONTAINER_FLAC,
+ CONTAINER_MATROSKA,
+ CONTAINER_MP2,
+ CONTAINER_MP3,
+ CONTAINER_OGG,
+ CONTAINER_WAV
+};
+
+/// Audio codecs for writers.
+enum Codec
+{
+ CODEC_INVALID = 0,
+ CODEC_AAC,
+ CODEC_AC3,
+ CODEC_FLAC,
+ CODEC_MP2,
+ CODEC_MP3,
+ CODEC_PCM,
+ CODEC_VORBIS,
+ CODEC_OPUS
+};
+
+/**
+ * @interface IWriter
+ * This class represents a sound sink where audio data can be written to.
+ */
+class AUD_API IWriter
+{
+public:
+ /**
+ * Destroys the writer.
+ */
+ virtual ~IWriter() {}
+
+ /**
+ * Returns how many samples have been written so far.
+ * \return The writing position as sample count. May be negative if unknown.
+ */
+ virtual int getPosition() const=0;
+
+ /**
+ * Returns the specification of the audio data being written into the sink.
+ * \return The DeviceSpecs structure.
+ * \note Regardless of the format the input still has to be float!
+ */
+ virtual DeviceSpecs getSpecs() const=0;
+
+ /**
+ * Request to write the next length samples out into the sink.
+ * \param length The count of samples to write.
+ * \param buffer The pointer to the buffer containing the data.
+ */
+ virtual void write(unsigned int length, sample_t* buffer)=0;
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/ADSR.h b/extern/audaspace/include/fx/ADSR.h
new file mode 100644
index 00000000000..c453f2477e1
--- /dev/null
+++ b/extern/audaspace/include/fx/ADSR.h
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file ADSR.h
+ * @ingroup fx
+ * The ADSR class.
+ */
+
+#include "fx/Effect.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * The ADSR effect implements the Attack-Delay-Sustain-Release behaviour of a sound.
+ */
+class AUD_API ADSR : public Effect
+{
+private:
+ /**
+ * Attack time.
+ */
+ float m_attack;
+
+ /**
+ * Decay time.
+ */
+ float m_decay;
+
+ /**
+ * Sustain level.
+ */
+ float m_sustain;
+
+ /**
+ * Release time.
+ */
+ float m_release;
+
+ // delete copy constructor and operator=
+ ADSR(const ADSR&) = delete;
+ ADSR& operator=(const ADSR&) = delete;
+
+public:
+ /**
+ * Creates a new ADSR object.
+ * @param sound The sound to apply this effect to.
+ * @param attack The attack time in seconds.
+ * @param decay The decay time in seconds.
+ * @param sustain The sustain level as linear volume.
+ * @param release The release time in seconds.
+ */
+ ADSR(std::shared_ptr<ISound> sound, float attack, float decay, float sustain, float release);
+
+ /**
+ * Returns the attack time.
+ * @return The attack time in seconds.
+ */
+ float getAttack() const;
+
+ /**
+ * Sets the attack time.
+ * @param attack The attack time in seconds.
+ */
+ void setAttack(float attack);
+
+ /**
+ * Returns the decay time.
+ * @return The decay time in seconds.
+ */
+ float getDecay() const;
+
+ /**
+ * Sets the decay time.
+ * @param decay The decay time in seconds.
+ */
+ void setDecay(float decay);
+
+ /**
+ * Returns the sustain level.
+ * @return The sustain level in linear volume.
+ */
+ float getSustain() const;
+
+ /**
+ * Sets the sustain level.
+ * @param sustain The sustain level in linear volume.
+ */
+ void setSustain(float sustain);
+
+ /**
+ * Returns the release time.
+ * @return The release time in seconds.
+ */
+ float getRelease() const;
+
+ /**
+ * Sets the release time.
+ * @param release The release time in seconds.
+ */
+ void setRelease(float release);
+
+ virtual std::shared_ptr<IReader> createReader();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/ADSRReader.h b/extern/audaspace/include/fx/ADSRReader.h
new file mode 100644
index 00000000000..a9ec076a1c5
--- /dev/null
+++ b/extern/audaspace/include/fx/ADSRReader.h
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file ADSRReader.h
+ * @ingroup fx
+ * The ADSRReader class.
+ */
+
+#include "fx/EffectReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This class is an ADSR filters.
+ */
+class AUD_API ADSRReader : public EffectReader
+{
+private:
+ enum ADSRState
+ {
+ ADSR_STATE_INVALID = 0, /// Invalid ADSR state or finished.
+ ADSR_STATE_ATTACK = 1, /// Initial attack state.
+ ADSR_STATE_DECAY = 2, /// Decay state.
+ ADSR_STATE_SUSTAIN = 3, /// Sustain state.
+ ADSR_STATE_RELEASE = 4 /// Release state.
+ };
+
+ /**
+ * Attack time.
+ */
+ float m_attack;
+
+ /**
+ * Decay time.
+ */
+ float m_decay;
+
+ /**
+ * Sustain level.
+ */
+ float m_sustain;
+
+ /**
+ * Release time.
+ */
+ float m_release;
+
+ /**
+ * Current state.
+ */
+ ADSRState m_state;
+
+ /**
+ * Current level.
+ */
+ float m_level;
+
+ // delete copy constructor and operator=
+ ADSRReader(const ADSRReader&) = delete;
+ ADSRReader& operator=(const ADSRReader&) = delete;
+
+ void AUD_LOCAL nextState(ADSRState state);
+
+public:
+ /**
+ * Creates a new ADSR reader.
+ * \param reader The reader to read from.
+ * \param attack The attack time in seconds.
+ * \param decay The decay time in seconds.
+ * \param sustain The sustain level, should be in range [0 - 1].
+ * \param release The release time in seconds.
+ */
+ ADSRReader(std::shared_ptr<IReader> reader, float attack, float decay, float sustain, float release);
+
+ virtual ~ADSRReader();
+
+ virtual void read(int& length, bool& eos, sample_t* buffer);
+
+ /**
+ * Triggers the release.
+ */
+ void release();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/Accumulator.h b/extern/audaspace/include/fx/Accumulator.h
new file mode 100644
index 00000000000..d0c635d663c
--- /dev/null
+++ b/extern/audaspace/include/fx/Accumulator.h
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file Accumulator.h
+ * @ingroup fx
+ * The Accumulator class.
+ */
+
+#include "fx/Effect.h"
+
+AUD_NAMESPACE_BEGIN
+
+class CallbackIIRFilterReader;
+
+/**
+ * This sound creates an accumulator reader.
+ *
+ * The accumulator adds the difference at the input to the last output in case
+ * it's positive. In additive mode it additionaly adds the difference always.
+ * So in case the difference is positive, it's added twice.
+ */
+class AUD_API Accumulator : public Effect
+{
+private:
+ /**
+ * Whether the accumulator is additive.
+ */
+ const bool m_additive;
+
+ // delete copy constructor and operator=
+ Accumulator(const Accumulator&) = delete;
+ Accumulator& operator=(const Accumulator&) = delete;
+
+public:
+ /**
+ * Creates a new accumulator sound.
+ * \param sound The input sound.
+ * \param additive Whether the accumulator is additive.
+ */
+ Accumulator(std::shared_ptr<ISound> sound, bool additive = false);
+
+ virtual std::shared_ptr<IReader> createReader();
+
+ /**
+ * The accumulatorFilterAdditive function implements the doFilterIIR callback
+ * for the additive accumulator filter.
+ * @param reader The CallbackIIRFilterReader that executes the callback.
+ * @param useless A user defined pointer that is not needed for this filter.
+ * @return The filtered sample.
+ */
+ static sample_t AUD_LOCAL accumulatorFilterAdditive(CallbackIIRFilterReader* reader, void* useless);
+
+ /**
+ * The accumulatorFilter function implements the doFilterIIR callback
+ * for the non-additive accumulator filter.
+ * @param reader The CallbackIIRFilterReader that executes the callback.
+ * @param useless A user defined pointer that is not needed for this filter.
+ * @return The filtered sample.
+ */
+ static sample_t AUD_LOCAL accumulatorFilter(CallbackIIRFilterReader* reader, void* useless);
+};
+
+AUD_NAMESPACE_END
diff --git a/intern/audaspace/FX/AUD_BaseIIRFilterReader.h b/extern/audaspace/include/fx/BaseIIRFilterReader.h
index fe0a8efce64..193b98578de 100644
--- a/intern/audaspace/FX/AUD_BaseIIRFilterReader.h
+++ b/extern/audaspace/include/fx/BaseIIRFilterReader.h
@@ -1,48 +1,41 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
*
- * Copyright 2009-2011 Jörg Hermann Müller
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * This file is part of AudaSpace.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * 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 *****
- */
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
-/** \file audaspace/FX/AUD_BaseIIRFilterReader.h
- * \ingroup audfx
- */
+#pragma once
+/**
+ * @file BaseIIRFilterReader.h
+ * @ingroup fx
+ * The BaseIIRFilterReader class.
+ */
-#ifndef __AUD_BASEIIRFILTERREADER_H__
-#define __AUD_BASEIIRFILTERREADER_H__
+#include "fx/EffectReader.h"
-#include "AUD_EffectReader.h"
-#include "AUD_Buffer.h"
+AUD_NAMESPACE_BEGIN
/**
* This class is a base class for infinite impulse response filters.
*/
-class AUD_BaseIIRFilterReader : public AUD_EffectReader
+class AUD_API BaseIIRFilterReader : public EffectReader
{
private:
/**
* Specs.
*/
- AUD_Specs m_specs;
+ Specs m_specs;
/**
* Length of input samples needed.
@@ -79,9 +72,9 @@ private:
*/
int m_channel;
- // hide copy constructor and operator=
- AUD_BaseIIRFilterReader(const AUD_BaseIIRFilterReader&);
- AUD_BaseIIRFilterReader& operator=(const AUD_BaseIIRFilterReader&);
+ // delete copy constructor and operator=
+ BaseIIRFilterReader(const BaseIIRFilterReader&) = delete;
+ BaseIIRFilterReader& operator=(const BaseIIRFilterReader&) = delete;
protected:
/**
@@ -90,8 +83,13 @@ protected:
* \param in The count of past input samples needed.
* \param out The count of past output samples needed.
*/
- AUD_BaseIIRFilterReader(boost::shared_ptr<AUD_IReader> reader, int in, int out);
+ BaseIIRFilterReader(std::shared_ptr<IReader> reader, int in, int out);
+ /**
+ * Sets the length for the required input and output samples of the IIR filter.
+ * @param in The amount of past input samples needed, including the current one.
+ * @param out The amount of past output samples needed.
+ */
void setLengths(int in, int out);
public:
@@ -115,7 +113,7 @@ public:
return m_y[(m_ypos + pos + m_ylen) % m_ylen * m_specs.channels + m_channel];
}
- virtual ~AUD_BaseIIRFilterReader();
+ virtual ~BaseIIRFilterReader();
virtual void read(int& length, bool& eos, sample_t* buffer);
@@ -129,7 +127,7 @@ public:
* Notifies the filter about a sample rate change.
* \param rate The new sample rate.
*/
- virtual void sampleRateChanged(AUD_SampleRate rate);
+ virtual void sampleRateChanged(SampleRate rate);
};
-#endif //__AUD_BASEIIRFILTERREADER_H__
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/BinauralReader.h b/extern/audaspace/include/fx/BinauralReader.h
new file mode 100644
index 00000000000..f5667a093f6
--- /dev/null
+++ b/extern/audaspace/include/fx/BinauralReader.h
@@ -0,0 +1,223 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+/**
+* @file BinauralReader.h
+* @ingroup fx
+* The BinauralReader class.
+*/
+
+#include "IReader.h"
+#include "ISound.h"
+#include "Convolver.h"
+#include "HRTF.h"
+#include "Source.h"
+#include "util/FFTPlan.h"
+#include "util/ThreadPool.h"
+
+#include <memory>
+#include <vector>
+#include <future>
+
+AUD_NAMESPACE_BEGIN
+
+/**
+* This class represents a reader for a sound that can sound different depending on its realtive position with the listener.
+*/
+class AUD_API BinauralReader : public IReader
+{
+private:
+ /**
+ * The current position.
+ */
+ int m_position;
+
+ /**
+ * The reader of the input sound.
+ */
+ std::shared_ptr<IReader> m_reader;
+
+ /**
+ * The HRTF set.
+ */
+ std::shared_ptr<HRTF> m_hrtfs;
+
+ /**
+ * A Source object that will be used to change the source position of the sound.
+ */
+ std::shared_ptr<Source> m_source;
+
+ /**
+ * The intended azimuth.
+ */
+ float m_Azimuth;
+
+ /**
+ * The intended elevation.
+ */
+ float m_Elevation;
+
+ /**
+ * The real azimuth being used.
+ */
+ float m_RealAzimuth;
+
+ /**
+ * The real elevation being used.
+ */
+ float m_RealElevation;
+
+ /**
+ * The FFT size, given by the FFTPlan.
+ */
+ int m_N;
+
+ /**
+ * The length of the impulse response fragments, m_N/2 will be used.
+ */
+ int m_M;
+
+ /**
+ * The max length of the input slices, m_N/2 will be used.
+ */
+ int m_L;
+
+ /**
+ * The array of convolvers that will be used, one per channel.
+ */
+ std::vector<std::unique_ptr<Convolver>> m_convolvers;
+
+ /**
+ * True if a transition is happening.
+ */
+ bool m_transition;
+
+ /**
+ * The position of the current transition (decreasing)
+ */
+ int m_transPos;
+
+ /**
+ * The output buffer in which the convolved data will be written and from which the reader will read.
+ */
+ sample_t* m_outBuffer;
+
+ /**
+ * The input buffer that will hold the data to be convolved.
+ */
+ sample_t* m_inBuffer;
+
+ /**
+ * Current position in which the m_outBuffer is being read.
+ */
+ int m_outBufferPos;
+
+ /**
+ * Length of rhe m_outBuffer.
+ */
+ int m_outBufLen;
+
+ /**
+ * Effective length of rhe m_outBuffer.
+ */
+ int m_eOutBufLen;
+
+ /**
+ * Flag indicating whether the end of the sound has been reached or not.
+ */
+ bool m_eosReader;
+
+ /**
+ * Flag indicating whether the end of the extra data generated in the convolution has been reached or not.
+ */
+ bool m_eosTail;
+
+ /**
+ * A vector of buffers (one per channel) on which the audio signal will be separated per channel so it can be convolved.
+ */
+ std::vector<sample_t*> m_vecOut;
+
+ /**
+ * A shared ptr to a thread pool.
+ */
+ std::shared_ptr<ThreadPool> m_threadPool;
+
+ /**
+ * Length of the input data to be used by the channel threads.
+ */
+ int m_lastLengthIn;
+
+ /**
+ * A vector of futures to sync tasks.
+ */
+ std::vector<std::future<int>> m_futures;
+
+ // delete copy constructor and operator=
+ BinauralReader(const BinauralReader&) = delete;
+ BinauralReader& operator=(const BinauralReader&) = delete;
+
+public:
+ /**
+ * Creates a new convolver reader.
+ * \param reader A reader of the input sound to be assigned to this reader. It must have one channel.
+ * \param hrtfs A shared pointer to an HRTF object that will be used to get a particular impulse response depending on the source.
+ * \param source A shared pointer to a Source object that will be used to change the source position of the sound.
+ * \param threadPool A shared pointer to a ThreadPool object with 1 or more threads.
+ * \param plan A shared pointer to and FFT plan that will be used for convolution.
+ * \exception Exception thrown if the specs of the HRTFs and the sound don't match or if the provided HRTF object is empty.
+ */
+ BinauralReader(std::shared_ptr<IReader> reader, std::shared_ptr<HRTF> hrtfs, std::shared_ptr<Source> source, std::shared_ptr<ThreadPool> threadPool, std::shared_ptr<FFTPlan> plan);
+ virtual ~BinauralReader();
+
+ virtual bool isSeekable() const;
+ virtual void seek(int position);
+ virtual int getLength() const;
+ virtual int getPosition() const;
+ virtual Specs getSpecs() const;
+ virtual void read(int& length, bool& eos, sample_t* buffer);
+
+private:
+ /**
+ * Joins several buffers (one per channel) into the m_outBuffer.
+ * \param start The starting position from which the m_outBuffer will be written.
+ * \param len The amout of samples that will be joined.
+ * \param nConvolvers The number of convolvers that have been used. Only use 2 or 4 as possible values.
+ If the value is 4 the result will be interpolated.
+ */
+ void joinByChannel(int start, int len, int nConvolvers);
+
+ /**
+ * Loads the m_outBuffer with data.
+ * \param nConvolvers The number of convolver objects that will be used. Only 2 or 4 should be used.
+ */
+ void loadBuffer(int nConvolvers);
+
+ /**
+ * The function that the threads will run. It will process a subset of channels.
+ * \param id An id number that will determine which subset of channels will be processed.
+ * \param input A flag that will indicate if thare is input data.
+ * -If true there is new input data.
+ * -If false there isn't new input data.
+ * \return The number of samples obtained.
+ */
+ int threadFunction(int id, bool input);
+
+ bool checkSource();
+};
+
+AUD_NAMESPACE_END \ No newline at end of file
diff --git a/extern/audaspace/include/fx/BinauralSound.h b/extern/audaspace/include/fx/BinauralSound.h
new file mode 100644
index 00000000000..733e111dc2b
--- /dev/null
+++ b/extern/audaspace/include/fx/BinauralSound.h
@@ -0,0 +1,119 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+/**
+* @file BinauralSound.h
+* @ingroup fx
+* The BinauralSound class.
+*/
+
+#include "ISound.h"
+#include "HRTF.h"
+#include "Source.h"
+#include "util/ThreadPool.h"
+#include "util/FFTPlan.h"
+
+#include <memory>
+#include <vector>
+
+AUD_NAMESPACE_BEGIN
+
+/**
+* This class represents a sound that can sound different depending on its realtive position with the listener.
+*/
+class AUD_API BinauralSound : public ISound
+{
+private:
+ /**
+ * A pointer to the imput sound.
+ */
+ std::shared_ptr<ISound> m_sound;
+
+ /**
+ * A pointer to an HRTF object with a collection of impulse responses.
+ */
+ std::shared_ptr<HRTF> m_hrtfs;
+
+ /**
+ * A pointer to a Source object which represents the source of the sound.
+ */
+ std::shared_ptr<Source> m_source;
+
+ /**
+ * A shared ptr to a thread pool.
+ */
+ std::shared_ptr<ThreadPool> m_threadPool;
+
+ /**
+ * A shared ponter to an FFT plan.
+ */
+ std::shared_ptr<FFTPlan> m_plan;
+
+ // delete copy constructor and operator=
+ BinauralSound(const BinauralSound&) = delete;
+ BinauralSound& operator=(const BinauralSound&) = delete;
+
+public:
+ /**
+ * Creates a new ConvolverSound.
+ * \param sound The sound that will be convolved. It must have only one channel.
+ * \param hrtfs The HRTF set that will be used.
+ * \param source A shared pointer to a Source object that contains the source of the sound.
+ * \param threadPool A shared pointer to a ThreadPool object with 1 or more threads.
+ * \param plan A shared pointer to a FFTPlan object that will be used for convolution.
+ * \warning The same FFTPlan object must be used to construct both this and the HRTF object provided.
+ */
+ BinauralSound(std::shared_ptr<ISound> sound, std::shared_ptr<HRTF> hrtfs, std::shared_ptr<Source> source, std::shared_ptr<ThreadPool> threadPool, std::shared_ptr<FFTPlan> plan);
+
+ /**
+ * Creates a new BinauralSound. A default FFT plan will be created.
+ * \param sound The sound that will be convolved. Must have only one channel.
+ * \param hrtfs The HRTF set that will be used.
+ * \param source A shared pointer to a Source object that contains the source of the sound.
+ * \param threadPool A shared pointer to a ThreadPool object with 1 or more threads.
+ * \warning To use this constructor no FFTPlan object must have been provided to the hrtfs.
+ */
+ BinauralSound(std::shared_ptr<ISound> sound, std::shared_ptr<HRTF> hrtfs, std::shared_ptr<Source> source, std::shared_ptr<ThreadPool> threadPool);
+
+ virtual std::shared_ptr<IReader> createReader();
+
+ /**
+ * Retrieves the HRTF set being used.
+ * \return A shared pointer to the current HRTF object being used.
+ */
+ std::shared_ptr<HRTF> getHRTFs();
+
+ /**
+ * Changes the set of HRTFs used for convolution, it'll only affect newly created readers.
+ * \param hrtfs A shared pointer to the new HRTF object.
+ */
+ void setHRTFs(std::shared_ptr<HRTF> hrtfs);
+
+ /**
+ * Retrieves the Source object being used.
+ * \return A shared pointer to the current Source object being used.
+ */
+ std::shared_ptr<Source> getSource();
+
+ /**
+ * Changes the Source object used to change the source position of the sound.
+ * \param source A shared pointer to the new Source object.
+ */
+ void setSource(std::shared_ptr<Source> source);
+};
+AUD_NAMESPACE_END \ No newline at end of file
diff --git a/extern/audaspace/include/fx/Butterworth.h b/extern/audaspace/include/fx/Butterworth.h
new file mode 100644
index 00000000000..db2ad743863
--- /dev/null
+++ b/extern/audaspace/include/fx/Butterworth.h
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file Butterworth.h
+ * @ingroup fx
+ * The Butterworth class.
+ */
+
+#include "fx/DynamicIIRFilter.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This sound creates a butterworth lowpass filter reader.
+ */
+class AUD_API Butterworth : public DynamicIIRFilter
+{
+private:
+ // delete copy constructor and operator=
+ Butterworth(const Butterworth&) = delete;
+ Butterworth& operator=(const Butterworth&) = delete;
+
+public:
+ /**
+ * Creates a new butterworth sound.
+ * \param sound The input sound.
+ * \param frequency The cutoff frequency.
+ */
+ Butterworth(std::shared_ptr<ISound> sound, float frequency);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/ButterworthCalculator.h b/extern/audaspace/include/fx/ButterworthCalculator.h
new file mode 100644
index 00000000000..f4d4894c8b8
--- /dev/null
+++ b/extern/audaspace/include/fx/ButterworthCalculator.h
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file ButterworthCalculator.h
+ * @ingroup fx
+ * The ButterworthCalculator class.
+ */
+
+#include "fx/IDynamicIIRFilterCalculator.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * The ButterworthCalculator class calculates fourth order Butterworth low pass
+ * filter coefficients for a dynamic DynamicIIRFilter.
+ */
+class AUD_LOCAL ButterworthCalculator : public IDynamicIIRFilterCalculator
+{
+private:
+ /**
+ * The attack value in seconds.
+ */
+ const float m_frequency;
+
+ // delete copy constructor and operator=
+ ButterworthCalculator(const ButterworthCalculator&) = delete;
+ ButterworthCalculator& operator=(const ButterworthCalculator&) = delete;
+
+public:
+ /**
+ * Creates a ButterworthCalculator object.
+ * @param frequency The cutoff frequency.
+ */
+ ButterworthCalculator(float frequency);
+
+ virtual void recalculateCoefficients(SampleRate rate, std::vector<float> &b, std::vector<float> &a);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/CallbackIIRFilterReader.h b/extern/audaspace/include/fx/CallbackIIRFilterReader.h
new file mode 100644
index 00000000000..f1dfab70d7f
--- /dev/null
+++ b/extern/audaspace/include/fx/CallbackIIRFilterReader.h
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file CallbackIIRFilterReader.h
+ * @ingroup fx
+ * The CallbackIIRFilterReader class.
+ */
+
+#include "fx/BaseIIRFilterReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+class CallbackIIRFilterReader;
+
+/**
+ * The doFilterIIR callback is executed when a new sample of a callback filter
+ * should be calculated. For sample access the CallbackIIRFilterReader is
+ * provided. Furthermore a user defined pointer is also handed to the callback.
+ */
+typedef sample_t (*doFilterIIR)(CallbackIIRFilterReader*, void*);
+
+/**
+ * The endFilterIIR callback is called when the callback filter is not needed
+ * anymore. The goal of this function should be to clean up the data behind the
+ * user supplied pointer which is handed to the callback.
+ */
+typedef void (*endFilterIIR)(void*);
+
+/**
+ * This class provides an interface for infinite impulse response filters via a
+ * callback filter function.
+ */
+class AUD_API CallbackIIRFilterReader : public BaseIIRFilterReader
+{
+private:
+ /**
+ * Filter function.
+ */
+ const doFilterIIR m_filter;
+
+ /**
+ * End filter function.
+ */
+ const endFilterIIR m_endFilter;
+
+ /**
+ * Data pointer.
+ */
+ void* m_data;
+
+ // delete copy constructor and operator=
+ CallbackIIRFilterReader(const CallbackIIRFilterReader&) = delete;
+ CallbackIIRFilterReader& operator=(const CallbackIIRFilterReader&) = delete;
+
+public:
+ /**
+ * Creates a new callback IIR filter reader.
+ * \param reader The reader to read from.
+ * \param in The count of past input samples needed.
+ * \param out The count of past output samples needed.
+ * \param doFilter The filter callback.
+ * \param endFilter The finishing callback.
+ * \param data Data pointer for the callbacks.
+ */
+ CallbackIIRFilterReader(std::shared_ptr<IReader> reader, int in, int out, doFilterIIR doFilter, endFilterIIR endFilter = 0, void* data = nullptr);
+
+ virtual ~CallbackIIRFilterReader();
+
+ virtual sample_t filter();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/Convolver.h b/extern/audaspace/include/fx/Convolver.h
new file mode 100644
index 00000000000..5ce134839f6
--- /dev/null
+++ b/extern/audaspace/include/fx/Convolver.h
@@ -0,0 +1,177 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+/**
+* @file Convolver.h
+* @ingroup fx
+* The Convolver class.
+*/
+
+#include "FFTConvolver.h"
+#include "util/ThreadPool.h"
+#include "util/FFTPlan.h"
+
+#include <memory>
+#include <vector>
+#include <mutex>
+#include <future>
+#include <atomic>
+#include <deque>
+
+AUD_NAMESPACE_BEGIN
+/**
+* This class allows to convolve a sound with a very large impulse response.
+*/
+class AUD_API Convolver
+{
+private:
+ /**
+ * The FFT size, must be at least M+L-1.
+ */
+ int m_N;
+
+ /**
+ * The length of the impulse response parts.
+ */
+ int m_M;
+
+ /**
+ * The max length of the input slices.
+ */
+ int m_L;
+
+ /**
+ * The impulse response divided in parts.
+ */
+ std::shared_ptr<std::vector<std::shared_ptr<std::vector<std::complex<sample_t>>>>> m_irBuffers;
+
+ /**
+ * Accumulation buffers for the threads.
+ */
+ std::vector<fftwf_complex*> m_threadAccBuffers;
+
+ /**
+ * A vector of FFTConvolvers used to calculate the partial convolutions.
+ */
+ std::vector<std::unique_ptr<FFTConvolver>> m_fftConvolvers;
+
+ /**
+ * The actual number of threads being used.
+ */
+ int m_numThreads;
+
+ /**
+ * A pool of threads that will be used for convolution.
+ */
+ std::shared_ptr<ThreadPool> m_threadPool;
+
+ /**
+ * A vector of futures used for thread sync
+ */
+ std::vector<std::future<bool>> m_futures;
+
+ /**
+ * A mutex for the sum of thread accumulators.
+ */
+ std::mutex m_sumMutex;
+
+ /**
+ * A flag to control thread execution when a reset is scheduled.
+ */
+ std::atomic_bool m_resetFlag;
+
+ /**
+ * Global accumulation buffer.
+ */
+ fftwf_complex* m_accBuffer;
+
+ /**
+ * Delay line.
+ */
+ std::deque<fftwf_complex*> m_delayLine;
+
+ /**
+ * The complete length of the impulse response.
+ */
+ int m_irLength;
+
+ /**
+ * Counter for the tail;
+ */
+ int m_tailCounter;
+
+ /**
+ * Flag end of sound;
+ */
+ bool m_eos;
+
+ // delete copy constructor and operator=
+ Convolver(const Convolver&) = delete;
+ Convolver& operator=(const Convolver&) = delete;
+
+public:
+
+ /**
+ * Creates a new FFTConvolver.
+ * \param ir A shared pointer to a vector with the data of the various impulse response parts in the frequency domain (see ImpulseResponse class for an easy way to obtain it).
+ * \param irLength The length of the full impulse response.
+ * \param threadPool A shared pointer to a ThreadPool object with 1 or more threads.
+ * \param plan A shared pointer to a FFT plan that will be used for convolution.
+ */
+ Convolver(std::shared_ptr<std::vector<std::shared_ptr<std::vector<std::complex<sample_t>>>>> ir, int irLength, std::shared_ptr<ThreadPool> threadPool, std::shared_ptr<FFTPlan> plan);
+
+ virtual ~Convolver();
+
+ /**
+ * Convolves the data that is provided with the inpulse response.
+ * Given a plan of size N, the amount of samples convolved by one call to this method will be N/2.
+ * \param[in] inBuffer A buffer with the input data to be convolved, nullptr if the source sound has ended (the convolved sound is larger than the source sound).
+ * \param[in] outBuffer A buffer in which the convolved data will be written. Its size must be at least N/2.
+ * \param[in,out] length The number of samples you wish to obtain. If an inBuffer is provided this argument must match its length.
+ * When this method returns, the value of length represents the number of samples written into the outBuffer.
+ * \param[out] eos True if the end of the sound is reached, false otherwise.
+ */
+ void getNext(sample_t* inBuffer, sample_t* outBuffer, int& length, bool& eos);
+
+ /**
+ * Resets all the internally stored data so the convolution of a new sound can be started.
+ */
+ void reset();
+
+ /**
+ * Retrieves the current impulse response being used.
+ * \return The current impulse response.
+ */
+ std::shared_ptr<std::vector<std::shared_ptr<std::vector<std::complex<sample_t>>>>> getImpulseResponse();
+
+ /**
+ * Changes the impulse response and resets the convolver.
+ * \param ir A shared pointer to a vector with the data of the various impulse response parts in the frequency domain (see ImpulseResponse class for an easy way to obtain it).
+ */
+ void setImpulseResponse(std::shared_ptr<std::vector<std::shared_ptr<std::vector<std::complex<sample_t>>>>> ir);
+
+private:
+
+ /**
+ * This function will be enqueued into the thread pool, and will process the input signal with a subset of the impulse response parts.
+ * \param id The id of the thread, starting with 0.
+ */
+ bool threadFunction(int id);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/ConvolverReader.h b/extern/audaspace/include/fx/ConvolverReader.h
new file mode 100644
index 00000000000..2ce917daec5
--- /dev/null
+++ b/extern/audaspace/include/fx/ConvolverReader.h
@@ -0,0 +1,198 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+/**
+* @file ConvolverReader.h
+* @ingroup fx
+* The ConvolverReader class.
+*/
+
+#include "IReader.h"
+#include "ISound.h"
+#include "Convolver.h"
+#include "ImpulseResponse.h"
+#include "util/FFTPlan.h"
+#include "util/ThreadPool.h"
+
+#include <memory>
+#include <vector>
+#include <future>
+
+AUD_NAMESPACE_BEGIN
+
+/**
+* This class represents a reader for a sound that can be modified depending on a given impulse response.
+*/
+class AUD_API ConvolverReader : public IReader
+{
+private:
+ /**
+ * The current position.
+ */
+ int m_position;
+
+ /**
+ * The reader of the input sound.
+ */
+ std::shared_ptr<IReader> m_reader;
+
+ /**
+ * The impulse response in the frequency domain.
+ */
+ std::shared_ptr<ImpulseResponse> m_ir;
+
+ /**
+ * The FFT size, given by the FFTPlan.
+ */
+ int m_N;
+
+ /**
+ * The length of the impulse response fragments, m_N/2 will be used.
+ */
+ int m_M;
+
+ /**
+ * The max length of the input slices, m_N/2 will be used.
+ */
+ int m_L;
+
+ /**
+ * The array of convolvers that will be used, one per channel.
+ */
+ std::vector<std::unique_ptr<Convolver>> m_convolvers;
+
+ /**
+ * The output buffer in which the convolved data will be written and from which the reader will read.
+ */
+ sample_t* m_outBuffer;
+
+ /**
+ * A vector of buffers (one per channel) on which the audio signal will be separated per channel so it can be convolved.
+ */
+ std::vector<sample_t*> m_vecInOut;
+
+ /**
+ * Current position in which the m_outBuffer is being read.
+ */
+ int m_outBufferPos;
+
+ /**
+ * Effective length of the m_outBuffer.
+ */
+ int m_eOutBufLen;
+
+ /**
+ * Real length of the m_outBuffer.
+ */
+ int m_outBufLen;
+
+ /**
+ * Flag indicating whether the end of the sound has been reached or not.
+ */
+ bool m_eosReader;
+
+ /**
+ * Flag indicating whether the end of the extra data generated in the convolution has been reached or not.
+ */
+ bool m_eosTail;
+
+ /**
+ * The number of channels of the sound to be convolved.
+ */
+ int m_inChannels;
+
+ /**
+ * The number of channels of the impulse response.
+ */
+ int m_irChannels;
+
+ /**
+ * The number of threads used for channels.
+ */
+ int m_nChannelThreads;
+
+ /**
+ * Length of the input data to be used by the channel threads.
+ */
+ int m_lastLengthIn;
+
+ /**
+ * A shared ptr to a thread pool.
+ */
+ std::shared_ptr<ThreadPool> m_threadPool;
+
+ /**
+ * A vector of futures to sync tasks.
+ */
+ std::vector<std::future<int>> m_futures;
+
+ // delete copy constructor and operator=
+ ConvolverReader(const ConvolverReader&) = delete;
+ ConvolverReader& operator=(const ConvolverReader&) = delete;
+
+public:
+ /**
+ * Creates a new convolver reader.
+ * \param reader A reader of the input sound to be assigned to this reader.
+ * \param ir A shared pointer to an impulseResponse object that will be used to convolve the sound.
+ * \param threadPool A shared pointer to a ThreadPool object with 1 or more threads.
+ * \param plan A shared pointer to and FFT plan that will be used for convolution.
+ * \exception Exception thrown if impulse response doesn't match the specs (number fo channels and rate) of the input reader.
+ */
+ ConvolverReader(std::shared_ptr<IReader> reader, std::shared_ptr<ImpulseResponse> ir, std::shared_ptr<ThreadPool> threadPool, std::shared_ptr<FFTPlan> plan);
+ virtual ~ConvolverReader();
+
+ virtual bool isSeekable() const;
+ virtual void seek(int position);
+ virtual int getLength() const;
+ virtual int getPosition() const;
+ virtual Specs getSpecs() const;
+ virtual void read(int& length, bool& eos, sample_t* buffer);
+
+private:
+ /**
+ * Divides a sound buffer in several buffers, one per channel.
+ * \param buffer The buffer that will be divided.
+ * \param len The length of the buffer.
+ */
+ void divideByChannel(const sample_t* buffer, int len);
+
+ /**
+ * Joins several buffers (one per channel) into the m_outBuffer.
+ * \param start The starting position from which the m_outBuffer will be written.
+ * \param len The amout of samples that will be joined.
+ */
+ void joinByChannel(int start, int len);
+
+ /**
+ * Loads the m_outBuffer with data.
+ */
+ void loadBuffer();
+
+ /**
+ * The function that the threads will run. It will process a subset of channels.
+ * \param id An id number that will determine which subset of channels will be processed.
+ * \param input A flag that will indicate if thare is input data.
+ * -If true there is new input data.
+ * -If false there isn't new input data.
+ * \return The number of samples obtained.
+ */
+ int threadFunction(int id, bool input);
+};
+
+AUD_NAMESPACE_END \ No newline at end of file
diff --git a/extern/audaspace/include/fx/ConvolverSound.h b/extern/audaspace/include/fx/ConvolverSound.h
new file mode 100644
index 00000000000..957e3b8af1c
--- /dev/null
+++ b/extern/audaspace/include/fx/ConvolverSound.h
@@ -0,0 +1,100 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+/**
+* @file ConvolverSound.h
+* @ingroup fx
+* The ConvolverSound class.
+*/
+
+#include "ISound.h"
+#include "ImpulseResponse.h"
+#include "util/ThreadPool.h"
+#include "util/FFTPlan.h"
+
+#include <memory>
+#include <vector>
+
+AUD_NAMESPACE_BEGIN
+
+/**
+* This class represents a sound that can be modified depending on a given impulse response.
+*/
+class AUD_API ConvolverSound : public ISound
+{
+private:
+ /**
+ * A pointer to the imput sound.
+ */
+ std::shared_ptr<ISound> m_sound;
+
+ /**
+ * A pointer to the impulse response.
+ */
+ std::shared_ptr<ImpulseResponse> m_impulseResponse;
+
+ /**
+ * A shared ptr to a thread pool.
+ */
+ std::shared_ptr<ThreadPool> m_threadPool;
+
+ /**
+ * A shared ponter to an FFT plan.
+ */
+ std::shared_ptr<FFTPlan> m_plan;
+
+ // delete copy constructor and operator=
+ ConvolverSound(const ConvolverSound&) = delete;
+ ConvolverSound& operator=(const ConvolverSound&) = delete;
+
+public:
+ /**
+ * Creates a new ConvolverSound.
+ * \param sound The sound that will be convolved.
+ * \param impulseResponse The impulse response sound.
+ * \param threadPool A shared pointer to a ThreadPool object with 1 or more threads.
+ * \param plan A shared pointer to a FFTPlan object that will be used for convolution.
+ * \warning The same FFTPlan object must be used to construct both this and the ImpulseResponse object provided.
+ */
+ ConvolverSound(std::shared_ptr<ISound> sound, std::shared_ptr<ImpulseResponse> impulseResponse, std::shared_ptr<ThreadPool> threadPool, std::shared_ptr<FFTPlan> plan);
+
+ /**
+ * Creates a new ConvolverSound. A default FFT plan will be created.
+ * \param sound The sound that will be convolved.
+ * \param impulseResponse The impulse response sound.
+ * \param threadPool A shared pointer to a ThreadPool object with 1 or more threads.
+ * \warning To use this constructor no FFTPlan object must have been provided to the inpulseResponse.
+ */
+ ConvolverSound(std::shared_ptr<ISound> sound, std::shared_ptr<ImpulseResponse> impulseResponse, std::shared_ptr<ThreadPool> threadPool);
+
+ virtual std::shared_ptr<IReader> createReader();
+
+ /**
+ * Retrieves the impulse response sound being used.
+ * \return A shared pointer to the current impulse response being used.
+ */
+ std::shared_ptr<ImpulseResponse> getImpulseResponse();
+
+ /**
+ * Changes the inpulse response used for convolution, it'll only affect newly created readers.
+ * \param impulseResponse A shared pointer to the new impulse response sound.
+ */
+ void setImpulseResponse(std::shared_ptr<ImpulseResponse> impulseResponse);
+};
+
+AUD_NAMESPACE_END \ No newline at end of file
diff --git a/extern/audaspace/include/fx/Delay.h b/extern/audaspace/include/fx/Delay.h
new file mode 100644
index 00000000000..d6ab93ca351
--- /dev/null
+++ b/extern/audaspace/include/fx/Delay.h
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file Delay.h
+ * @ingroup fx
+ * The Delay class.
+ */
+
+#include "fx/Effect.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This sound plays another sound delayed.
+ */
+class AUD_API Delay : public Effect
+{
+private:
+ /**
+ * The delay in samples.
+ */
+ const float m_delay;
+
+ // delete copy constructor and operator=
+ Delay(const Delay&) = delete;
+ Delay& operator=(const Delay&) = delete;
+
+public:
+ /**
+ * Creates a new delay sound.
+ * \param sound The input sound.
+ * \param delay The desired delay in seconds.
+ */
+ Delay(std::shared_ptr<ISound> sound, float delay = 0);
+
+ /**
+ * Returns the delay in seconds.
+ */
+ float getDelay() const;
+
+ virtual std::shared_ptr<IReader> createReader();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/DelayReader.h b/extern/audaspace/include/fx/DelayReader.h
new file mode 100644
index 00000000000..fe37e56d83e
--- /dev/null
+++ b/extern/audaspace/include/fx/DelayReader.h
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file DelayReader.h
+ * @ingroup fx
+ * The DelayReader class.
+ */
+
+#include "fx/EffectReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This class reads another reader and delays it.
+ */
+class AUD_API DelayReader : public EffectReader
+{
+private:
+ /**
+ * The delay level.
+ */
+ const int m_delay;
+
+ /**
+ * The remaining delay for playback.
+ */
+ int m_remdelay;
+
+ // delete copy constructor and operator=
+ DelayReader(const DelayReader&) = delete;
+ DelayReader& operator=(const DelayReader&) = delete;
+
+public:
+ /**
+ * Creates a new delay reader.
+ * \param reader The reader to read from.
+ * \param delay The delay in seconds.
+ */
+ DelayReader(std::shared_ptr<IReader> reader, float delay);
+
+ virtual void seek(int position);
+ virtual int getLength() const;
+ virtual int getPosition() const;
+ virtual void read(int& length, bool& eos, sample_t* buffer);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/DynamicIIRFilter.h b/extern/audaspace/include/fx/DynamicIIRFilter.h
new file mode 100644
index 00000000000..5528e7c7b9b
--- /dev/null
+++ b/extern/audaspace/include/fx/DynamicIIRFilter.h
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file DynamicIIRFilter.h
+ * @ingroup fx
+ * The DynamicIIRFilter class.
+ */
+
+#include "fx/Effect.h"
+
+AUD_NAMESPACE_BEGIN
+
+class IDynamicIIRFilterCalculator;
+
+/**
+ * This sound creates a IIR filter reader.
+ *
+ * This means that on sample rate change the filter recalculates its
+ * coefficients.
+ */
+class AUD_API DynamicIIRFilter : public Effect
+{
+protected:
+ /// The IDynamicIIRFilterCalculator that calculates the dynamic filter coefficients.
+ std::shared_ptr<IDynamicIIRFilterCalculator> m_calculator;
+
+public:
+ /**
+ * Creates a new Dynmic IIR filter sound.
+ * \param sound The input sound.
+ * \param calculator The calculator which recalculates the dynamic filter coefficients.
+ */
+ DynamicIIRFilter(std::shared_ptr<ISound> sound, std::shared_ptr<IDynamicIIRFilterCalculator> calculator);
+
+ virtual std::shared_ptr<IReader> createReader();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/DynamicIIRFilterReader.h b/extern/audaspace/include/fx/DynamicIIRFilterReader.h
new file mode 100644
index 00000000000..9e2267243ce
--- /dev/null
+++ b/extern/audaspace/include/fx/DynamicIIRFilterReader.h
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file DynamicIIRFilterReader.h
+ * @ingroup fx
+ * The DynamicIIRFilterReader class.
+ */
+
+#include "fx/IIRFilterReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+class IDynamicIIRFilterCalculator;
+
+/**
+ * This class is for dynamic infinite impulse response filters with simple
+ * coefficients that change depending on the sample rate.
+ */
+class AUD_API DynamicIIRFilterReader : public IIRFilterReader
+{
+private:
+ /**
+ * The sound for dynamically recalculating filter coefficients.
+ */
+ std::shared_ptr<IDynamicIIRFilterCalculator> m_calculator;
+
+public:
+ /**
+ * Creates a new DynamicIIRFilterReader.
+ * @param reader The reader the filter is applied on.
+ * @param calculator The IDynamicIIRFilterCalculator that recalculates the filter coefficients.
+ */
+ DynamicIIRFilterReader(std::shared_ptr<IReader> reader,
+ std::shared_ptr<IDynamicIIRFilterCalculator> calculator);
+
+ /**
+ * The function sampleRateChanged is called whenever the sample rate of the
+ * underlying reader changes and thus updates the filter coefficients.
+ * @param rate The new sample rate.
+ */
+ virtual void sampleRateChanged(SampleRate rate);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/DynamicMusic.h b/extern/audaspace/include/fx/DynamicMusic.h
new file mode 100644
index 00000000000..5d59f77401a
--- /dev/null
+++ b/extern/audaspace/include/fx/DynamicMusic.h
@@ -0,0 +1,235 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+/**
+* @file DynamicMusic.h
+* @ingroup fx
+* The DynamicMusic class.
+*/
+
+#include "devices/IHandle.h"
+#include "devices/IDevice.h"
+#include "ISound.h"
+
+#include <memory>
+#include <vector>
+#include <thread>
+#include <atomic>
+#include <condition_variable>
+#include <mutex>
+
+AUD_NAMESPACE_BEGIN
+
+/**
+* This class allows to play music depending on a current "scene", scene changes are managed by the class.
+* The default scene is silent and has id 0.
+*/
+class AUD_API DynamicMusic
+{
+private:
+ /**
+ * Matrix of pointers which will store the sounds of the scenes and the transitions between them.
+ */
+ std::vector<std::vector<std::shared_ptr<ISound>>> m_scenes;
+
+ /**
+ * Id of the current scene.
+ */
+ std::atomic_int m_id;
+
+ /**
+ * Length of the crossfade transition in seconds, used when no custom transition has been set.
+ */
+ float m_fadeTime;
+
+ /**
+ * Handle to the playback of the current scene.
+ */
+ std::shared_ptr<IHandle> m_currentHandle;
+
+ /**
+ * Handle used during transitions.
+ */
+ std::shared_ptr<IHandle> m_transitionHandle;
+
+ /**
+ * Device used for playback.
+ */
+ std::shared_ptr<IDevice> m_device;
+
+ /**
+ * Flag that is true when a transition is happening.
+ */
+ std::atomic_bool m_transitioning;
+
+ /**
+ * Flag that is true when the music is paused.
+ */
+ std::atomic_bool m_stopThread;
+
+ /**
+ * Id of the sound that will play with the next transition.
+ */
+ std::atomic_int m_soundTarget;
+
+ /**
+ * Volume of the scenes.
+ */
+ float m_volume;
+
+ /**
+ * A thread that manages the crossfade transition.
+ */
+ std::thread m_fadeThread;
+
+ // delete copy constructor and operator=
+ DynamicMusic(const DynamicMusic&) = delete;
+ DynamicMusic& operator=(const DynamicMusic&) = delete;
+
+public:
+ /**
+ * Creates a new dynamic music manager with the default silent scene (id: 0).
+ * \param device The device that will be used to play sounds.
+ */
+ DynamicMusic(std::shared_ptr<IDevice> device);
+
+ virtual ~DynamicMusic();
+
+ /**
+ * Adds a new scene to the manager.
+ * \param sound The sound that will play when the scene is selected with the changeScene().
+ * \return The identifier of the new scene.
+ */
+ int addScene(std::shared_ptr<ISound> sound);
+
+ /**
+ * Changes to another scene.
+ * \param id The id of the scene which should start playing the changeScene method.
+ * \return
+ * - true if the change has been scheduled succesfully.
+ * - false if there already is a transition in course or the scene selected doesnt exist.
+ */
+ bool changeScene(int id);
+
+ /**
+ * Retrieves the scene currently selected.
+ * \return The identifier of the current scene.
+ */
+ int getScene();
+
+ /**
+ * Adds a new transition between scenes
+ * \param init The id of the initial scene that will allow the transition to play.
+ * \param end The id if the target scene for the transition.
+ * \param sound The sound that will play when the scene changes from init to end.
+ * \return false if the init or end scenes don't exist.
+ */
+ bool addTransition(int init, int end, std::shared_ptr<ISound> sound);
+
+ /**
+ * Sets the length of the crossfade transition (default 1 second).
+ * \param seconds The time in seconds.
+ */
+ void setFadeTime(float seconds);
+
+ /**
+ * Gets the length of the crossfade transition (default 1 second).
+ * \return The length of the cressfade transition in seconds.
+ */
+ float getFadeTime();
+
+ /**
+ * Resumes a paused sound.
+ * \return
+ * - true if the sound has been resumed.
+ * - false if the sound isn't paused or the handle is invalid.
+ */
+ bool resume();
+
+ /**
+ * Pauses the current played back sound.
+ * \return
+ * - true if the sound has been paused.
+ * - false if the sound isn't playing back or the handle is invalid.
+ */
+ bool pause();
+
+ /**
+ * Seeks in the current played back sound.
+ * \param position The new position from where to play back, in seconds.
+ * \return
+ * - true if the handle is valid.
+ * - false if the handle is invalid.
+ * \warning Whether the seek works or not depends on the sound source.
+ */
+ bool seek(float position);
+
+ /**
+ * Retrieves the current playback position of a sound.
+ * \return The playback position in seconds, or 0.0 if the handle is
+ * invalid.
+ */
+ float getPosition();
+
+ /**
+ * Retrieves the volume of the scenes.
+ * \return The volume.
+ */
+ float getVolume();
+
+ /**
+ * Sets the volume for the scenes.
+ * \param volume The volume.
+ * \return
+ * - true if the handle is valid.
+ * - false if the handle is invalid.
+ */
+ bool setVolume(float volume);
+
+ /**
+ * Returns the status of the current played back sound.
+ * \return
+ * - STATUS_INVALID if the sound has stopped or the handle is
+ *. invalid
+ * - STATUS_PLAYING if the sound is currently played back.
+ * - STATUS_PAUSED if the sound is currently paused.
+ * - STATUS_STOPPED if the sound finished playing and is still
+ * kept in the device.
+ * \see Status
+ */
+ Status getStatus();
+
+ /**
+ * Stops any played back or paused sound and sets the dynamic music player to default silent state (scene 0)
+ * \return
+ * - true if the sound has been stopped.
+ * - false if the handle is invalid.
+ */
+ bool stop();
+
+ private:
+ //Callbacks used to schedule transitions after a sound ends.
+ static void transitionCallback(void* player);
+ static void sceneCallback(void* player);
+ //These functions can fade sounds in and out if used with a thread.
+ void crossfadeThread();
+ void fadeInThread();
+ void fadeOutThread();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/Effect.h b/extern/audaspace/include/fx/Effect.h
new file mode 100644
index 00000000000..471e37b5ecf
--- /dev/null
+++ b/extern/audaspace/include/fx/Effect.h
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file Effect.h
+ * @ingroup fx
+ * The Effect class.
+ */
+
+#include "ISound.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This sound is a base class for all effect factories that take one other
+ * sound as input.
+ */
+class AUD_API Effect : public ISound
+{
+private:
+ // delete copy constructor and operator=
+ Effect(const Effect&) = delete;
+ Effect& operator=(const Effect&) = delete;
+
+protected:
+ /**
+ * If there is no reader it is created out of this sound.
+ */
+ std::shared_ptr<ISound> m_sound;
+
+ /**
+ * Returns the reader created out of the sound.
+ * This method can be used for the createReader function of the implementing
+ * classes.
+ * \return The reader created out of the sound.
+ */
+ inline std::shared_ptr<IReader> getReader() const
+ {
+ return m_sound->createReader();
+ }
+
+public:
+ /**
+ * Creates a new sound.
+ * \param sound The input sound.
+ */
+ Effect(std::shared_ptr<ISound> sound);
+
+ /**
+ * Destroys the sound.
+ */
+ virtual ~Effect();
+
+ /**
+ * Returns the saved sound.
+ * \return The sound or nullptr if there has no sound been saved.
+ */
+ std::shared_ptr<ISound> getSound() const;
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/EffectReader.h b/extern/audaspace/include/fx/EffectReader.h
new file mode 100644
index 00000000000..85eff6a8ab9
--- /dev/null
+++ b/extern/audaspace/include/fx/EffectReader.h
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file EffectReader.h
+ * @ingroup fx
+ * The EffectReader class.
+ */
+
+#include "IReader.h"
+
+#include <memory>
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This reader is a base class for all effect readers that take one other reader
+ * as input.
+ */
+class AUD_API EffectReader : public IReader
+{
+private:
+ // delete copy constructor and operator=
+ EffectReader(const EffectReader&) = delete;
+ EffectReader& operator=(const EffectReader&) = delete;
+
+protected:
+ /**
+ * The reader to read from.
+ */
+ std::shared_ptr<IReader> m_reader;
+
+public:
+ /**
+ * Creates a new effect reader.
+ * \param reader The reader to read from.
+ */
+ EffectReader(std::shared_ptr<IReader> reader);
+
+ /**
+ * Destroys the reader.
+ */
+ virtual ~EffectReader();
+
+ virtual bool isSeekable() const;
+ virtual void seek(int position);
+ virtual int getLength() const;
+ virtual int getPosition() const;
+ virtual Specs getSpecs() const;
+ virtual void read(int& length, bool& eos, sample_t* buffer);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/Envelope.h b/extern/audaspace/include/fx/Envelope.h
new file mode 100644
index 00000000000..3d44e897b3a
--- /dev/null
+++ b/extern/audaspace/include/fx/Envelope.h
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file Envelope.h
+ * @ingroup fx
+ * The Envelope class.
+ */
+
+#include "fx/Effect.h"
+
+AUD_NAMESPACE_BEGIN
+
+class CallbackIIRFilterReader;
+struct EnvelopeParameters;
+
+/**
+ * This sound creates an envelope follower reader.
+ */
+class AUD_API Envelope : public Effect
+{
+private:
+ /**
+ * The attack value in seconds.
+ */
+ const float m_attack;
+
+ /**
+ * The release value in seconds.
+ */
+ const float m_release;
+
+ /**
+ * The threshold value.
+ */
+ const float m_threshold;
+
+ /**
+ * The attack/release threshold value.
+ */
+ const float m_arthreshold;
+
+ // delete copy constructor and operator=
+ Envelope(const Envelope&) = delete;
+ Envelope& operator=(const Envelope&) = delete;
+
+public:
+ /**
+ * Creates a new envelope sound.
+ * \param sound The input sound.
+ * \param attack The attack value in seconds.
+ * \param release The release value in seconds.
+ * \param threshold The threshold value.
+ * \param arthreshold The attack/release threshold value.
+ */
+ Envelope(std::shared_ptr<ISound> sound, float attack, float release,
+ float threshold, float arthreshold);
+
+ virtual std::shared_ptr<IReader> createReader();
+
+ /**
+ * The envelopeFilter function implements the doFilterIIR callback
+ * for the callback IIR filter.
+ * @param reader The CallbackIIRFilterReader that executes the callback.
+ * @param param The envelope parameters.
+ * @return The filtered sample.
+ */
+ static sample_t AUD_LOCAL envelopeFilter(CallbackIIRFilterReader* reader, EnvelopeParameters* param);
+
+ /**
+ * The endEnvelopeFilter function implements the endFilterIIR callback
+ * for the callback IIR filter.
+ * @param param The envelope parameters.
+ */
+ static void AUD_LOCAL endEnvelopeFilter(EnvelopeParameters* param);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/FFTConvolver.h b/extern/audaspace/include/fx/FFTConvolver.h
new file mode 100644
index 00000000000..62ce1cbf5ad
--- /dev/null
+++ b/extern/audaspace/include/fx/FFTConvolver.h
@@ -0,0 +1,196 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+/**
+* @file FFTConvolver.h
+* @ingroup fx
+* The FFTConvolver class.
+*/
+
+#include "IReader.h"
+#include "ISound.h"
+#include "util/FFTPlan.h"
+
+#include <memory>
+#include <vector>
+
+AUD_NAMESPACE_BEGIN
+/**
+* This class allows to easily convolve a sound using the Fourier transform.
+*/
+class AUD_API FFTConvolver
+{
+private:
+ /**
+ * A shared pointer to an FFT plan.
+ */
+ std::shared_ptr<FFTPlan> m_plan;
+
+ /**
+ * The FFT size, must be at least M+L-1.
+ */
+ int m_N;
+
+ /**
+ * The length of the impulse response.
+ */
+ int m_M;
+
+ /**
+ * The max length of the input slices.
+ */
+ int m_L;
+
+ /**
+ * The real length of the internal buffer in fftwf_complex elements.
+ */
+ int m_realBufLen;
+
+ /**
+ * The internal buffer for the FFTS.
+ */
+ std::complex<sample_t>* m_inBuffer;
+
+ /**
+ * A shift buffer for the FDL method
+ */
+ sample_t* m_shiftBuffer;
+
+ /**
+ * A buffer to store the extra data obtained after each partial convolution.
+ */
+ float* m_tail;
+
+ /**
+ * The provided impulse response.
+ */
+ std::shared_ptr<std::vector<std::complex<sample_t>>> m_irBuffer;
+
+ /**
+ * If the tail is being read, this marks the current position.
+ */
+ int m_tailPos;
+
+ // delete copy constructor and operator=
+ FFTConvolver(const FFTConvolver&) = delete;
+ FFTConvolver& operator=(const FFTConvolver&) = delete;
+
+public:
+ /**
+ * Creates a new FFTConvolver.
+ * \param ir A shared pointer to a vector with the impulse response data in the frequency domain (see ImpulseResponse class for an easy way to obtain it).
+ * \param plan A shared pointer to and FFT plan.
+ */
+ FFTConvolver(std::shared_ptr<std::vector<std::complex<sample_t>>> ir, std::shared_ptr<FFTPlan> plan);
+ virtual ~FFTConvolver();
+
+ /**
+ * Convolves the data that is provided with the inpulse response.
+ * \param[in] inBuffer A buffer with the input data to be convolved.
+ * \param[in] outBuffer A pointer to the buffer in which the convolution result will be written.
+ * \param[in,out] length The number of samples to be convolved (the length of both the inBuffer and the outBuffer).
+ * The convolution output should be larger than the input, but since this class uses the overlap
+ * add method, the extra length will be saved internally.
+ * It must be equal or lower than N/2 (N=size of the FFTPlan) or the call will fail, setting this variable to 0 since no data would be
+ * written in the outBuffer.
+ */
+ void getNext(const sample_t* inBuffer, sample_t* outBuffer, int& length);
+
+ /**
+ * Convolves the data that is provided with the inpulse response.
+ * \param[in] inBuffer A buffer with the input data to be convolved.
+ * \param[in] outBuffer A pointer to the buffer in which the convolution result will be written.
+ * \param[in,out] length The number of samples to be convolved (the length of both the inBuffer and the outBuffer).
+ * The convolution output should be larger than the input, but since this class uses the overlap
+ * add method, the extra length will be saved internally.
+ * It must be equal or lower than N/2 (N=size of the FFTPlan) or the call will fail, setting this variable to 0 since no data would be
+ * written in the outBuffer.
+ * \param[in] transformedData A pointer to a buffer in which the Fourier transform of the input will be written.
+ */
+ void getNext(const sample_t* inBuffer, sample_t* outBuffer, int& length, fftwf_complex* transformedData);
+
+ /**
+ * Convolves the data that is provided with the inpulse response.
+ * \param[in] inBuffer A buffer with the input data to be convolved. Its length must be N/2 + 1
+ * \param[in] outBuffer A pointer to the buffer in which the convolution result will be written.
+ * \param[in,out] length The number of samples to be convolved and the length of the outBuffer.
+ * The convolution output should be larger than the input, but since this class uses the overlap
+ * add method, the extra length will be saved internally.
+ * It must be equal or lower than N/2 (N=size of the FFTPlan) or the call will fail and set the value of length to 0 since no data would be
+ * written in the outBuffer.
+ */
+ void getNext(const fftwf_complex* inBuffer, sample_t* outBuffer, int& length);
+
+ /**
+ * Gets the internally stored extra data which is result of the convolution.
+ * \param[in,out] length The count of samples that should be read. Shall
+ * contain the real count of samples after reading, in case
+ * there were only fewer samples available.
+ * A smaller value also indicates the end of the data.
+ * \param[out] eos End of stream, whether the end is reached or not.
+ * \param[in] buffer The pointer to the buffer to read into.
+ */
+ void getTail(int& length, bool& eos, sample_t* buffer);
+
+ /**
+ * Resets the internally stored data so a new convolution can be started.
+ */
+ void clear();
+
+ /**
+ * Calculates the Inverse Fast Fourier Transform of the input array.
+ * \param[in] inBuffer A buffer with the input data to be transformed. Its length must be N/2 + 1
+ * \param[in] outBuffer A pointer to the buffer in which the transform result will be written.
+ * \param[in,out] length The number of samples to be transformed and the length of the outBuffer.
+ * It must be equal or lower than N, but tipically N/2 should be used (N=size of the FFTPlan) or the call will fail and the value
+ * of length will be setted to 0, since no data would be written in the outBuffer.
+ */
+ void IFFT_FDL(const fftwf_complex* inBuffer, sample_t* outBuffer, int& length);
+
+ /**
+ * Multiplicates a frequency domain input by the impulse response and accumulates the result to a buffer.
+ * \param[in] inBuffer A buffer of complex numbers, samples in the frequency domain, that will be multiplied by the impulse response. Its length must be N/2 + 1
+ * \param[in] accBuffer A pointer to the buffer into which the result of the multiplication will be summed. Its length must be N/2 + 1
+ */
+ void getNextFDL(const std::complex<sample_t>* inBuffer, std::complex<sample_t>* accBuffer);
+
+ /**
+ * Transforms an input array of real data to the frequency domain and multiplies it by the impulse response. The result is accumulated to a buffer.
+ * \param[in] inBuffer A buffer of real numbers, samples in the time domain, that will be multiplied by the impulse response.
+ * \param[in] accBuffer A pointer to the buffer into which the result of the multiplication will be summed. Its length must be N/2 + 1.
+ * \param[in,out] length The number of samples to be transformed and the length of the inBuffer.
+ * It must be equal or lower than N/2 (N=size of the FFTPlan) or the call will fail and the value
+ * of length will be setted to 0, since no data would be written in the outBuffer.
+ * \param[in] transformedData A pointer to a buffer in which the Fourier transform of the input will be written.
+ */
+ void getNextFDL(const sample_t* inBuffer, std::complex<sample_t>* accBuffer, int& length, fftwf_complex* transformedData);
+
+ /**
+ * Changes the impulse response and resets the FFTConvolver.
+ * \param ir A shared pointer to a vector with the data of the impulse response in the frequency domain.
+ */
+ void setImpulseResponse(std::shared_ptr<std::vector<std::complex<sample_t>>> ir);
+
+ /**
+ * Retrieves the current impulse response being used.
+ * \return The current impulse response.
+ */
+ std::shared_ptr<std::vector<std::complex<sample_t>>> getImpulseResponse();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/Fader.h b/extern/audaspace/include/fx/Fader.h
new file mode 100644
index 00000000000..63280aec292
--- /dev/null
+++ b/extern/audaspace/include/fx/Fader.h
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file Fader.h
+ * @ingroup fx
+ * The Fader class.
+ */
+
+#include "fx/Effect.h"
+#include "fx/FaderReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This sound fades another sound.
+ * If the fading type is FADE_IN, everything before the fading start will be
+ * silenced, for FADE_OUT that's true for everything after fading ends.
+ */
+class AUD_API Fader : public Effect
+{
+private:
+ /**
+ * The fading type.
+ */
+ const FadeType m_type;
+
+ /**
+ * The fading start.
+ */
+ const float m_start;
+
+ /**
+ * The fading length.
+ */
+ const float m_length;
+
+ // delete copy constructor and operator=
+ Fader(const Fader&) = delete;
+ Fader& operator=(const Fader&) = delete;
+
+public:
+ /**
+ * Creates a new fader sound.
+ * \param sound The input sound.
+ * \param type The fading type.
+ * \param start The time where fading should start in seconds.
+ * \param length How long fading should last in seconds.
+ */
+ Fader(std::shared_ptr<ISound> sound,
+ FadeType type = FADE_IN,
+ float start = 0.0f, float length = 1.0f);
+
+ /**
+ * Returns the fading type.
+ */
+ FadeType getType() const;
+
+ /**
+ * Returns the fading start.
+ */
+ float getStart() const;
+
+ /**
+ * Returns the fading length.
+ */
+ float getLength() const;
+
+ virtual std::shared_ptr<IReader> createReader();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/FaderReader.h b/extern/audaspace/include/fx/FaderReader.h
new file mode 100644
index 00000000000..99ea3d28938
--- /dev/null
+++ b/extern/audaspace/include/fx/FaderReader.h
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file FaderReader.h
+ * @ingroup fx
+ * Defines the FaderReader class as well as the two fading types.
+ */
+
+#include "fx/EffectReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+/// Fading types.
+enum FadeType
+{
+ FADE_IN,
+ FADE_OUT
+};
+
+/**
+ * This class fades another reader.
+ * If the fading type is FADE_IN, everything before the fading start will be
+ * silenced, for FADE_OUT that's true for everything after fading ends.
+ */
+class AUD_API FaderReader : public EffectReader
+{
+private:
+ /**
+ * The fading type.
+ */
+ const FadeType m_type;
+
+ /**
+ * The fading start.
+ */
+ const float m_start;
+
+ /**
+ * The fading length.
+ */
+ const float m_length;
+
+ // delete copy constructor and operator=
+ FaderReader(const FaderReader&) = delete;
+ FaderReader& operator=(const FaderReader&) = delete;
+
+public:
+ /**
+ * Creates a new fader reader.
+ * \param reader The reader that this effect is applied on.
+ * \param type The fading type.
+ * \param start The time where fading should start in seconds.
+ * \param length How long fading should last in seconds.
+ */
+ FaderReader(std::shared_ptr<IReader> reader, FadeType type,
+ float start,float length);
+
+ virtual void read(int& length, bool& eos, sample_t* buffer);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/HRTF.h b/extern/audaspace/include/fx/HRTF.h
new file mode 100644
index 00000000000..750d5f18991
--- /dev/null
+++ b/extern/audaspace/include/fx/HRTF.h
@@ -0,0 +1,108 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+/**
+* @file HRTF.h
+* @ingroup fx
+* The HRTF class.
+*/
+
+#include "util/StreamBuffer.h"
+#include "util/FFTPlan.h"
+#include "ImpulseResponse.h"
+
+#include <memory>
+#include <vector>
+#include <unordered_map>
+#include <utility>
+
+AUD_NAMESPACE_BEGIN
+
+/**
+* This class represents a complete set of HRTFs.
+*/
+class AUD_API HRTF
+{
+private:
+ /**
+ * An unordered map of unordered maps containing the ImpulseResponse objects of the HRTFs.
+ */
+ std::unordered_map<float, std::unordered_map<float, std::shared_ptr<ImpulseResponse>>> m_hrtfs;
+
+ /**
+ * The FFTPlan used to create the ImpulseResponses.
+ */
+ std::shared_ptr<FFTPlan> m_plan;
+
+ /**
+ * The specifications of the HRTFs.
+ */
+ Specs m_specs;
+
+ /**
+ * True if the HRTF object is empty.
+ */
+ bool m_empty;
+
+ // delete copy constructor and operator=
+ HRTF(const HRTF&) = delete;
+ HRTF& operator=(const HRTF&) = delete;
+
+public:
+ /**
+ * Creates a new empty HRTF object that will instance it own FFTPlan with default size.
+ */
+ HRTF();
+
+ /**
+ * Creates a new empty HRTF object.
+ * \param plan A shared pointer to a FFT plan used to transform the impulse responses added.
+ */
+ HRTF(std::shared_ptr<FFTPlan> plan);
+
+ /**
+ * Adds a new HRTF to the class.
+ * \param impulseResponse A shared pointer to an StreamBuffer with the HRTF.
+ * \param azimuth The azimuth angle of the HRTF. Interval [0,360).
+ * \param elevation The elevation angle of the HRTF.
+ * \return True if the impulse response was added successfully, false otherwise (the specs weren't correct).
+ */
+ bool addImpulseResponse(std::shared_ptr<StreamBuffer> impulseResponse, float azimuth, float elevation);
+
+ /**
+ * Retrieves a pair of HRTFs for a certain azimuth and elevation. If no exact match is found, the closest ones will be chosen (the elevation has priority over the azimuth).
+ * \param[in,out] azimuth The desired azimuth angle. If no exact match is found, the value of azimuth will represent the actual azimuth elevation of the chosen HRTF. Interval [0,360)
+ * \param[in,out] elevation The desired elevation angle. If no exact match is found, the value of elevation will represent the actual elevation angle of the chosen HRTF.
+ * \return A pair of shared pointers to ImpulseResponse objects containing the HRTFs for the left (first element) and right (second element) ears.
+ */
+ std::pair<std::shared_ptr<ImpulseResponse>, std::shared_ptr<ImpulseResponse>> getImpulseResponse(float &azimuth, float &elevation);
+
+ /**
+ * Retrieves the specs shared by all the HRTFs.
+ * \return The shared specs of all the HRTFs.
+ */
+ Specs getSpecs();
+
+ /**
+ * Retrieves the state of the HRTF object.
+ * \return True if it is empty, false otherwise.
+ */
+ bool isEmpty();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/HRTFLoader.h b/extern/audaspace/include/fx/HRTFLoader.h
new file mode 100644
index 00000000000..893184ae909
--- /dev/null
+++ b/extern/audaspace/include/fx/HRTFLoader.h
@@ -0,0 +1,99 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+/**
+* @file HRTFLoader.h
+* @ingroup fx
+* The HRTFLoader class.
+*/
+
+#include "Audaspace.h"
+#include "fx/HRTF.h"
+#include "util/FFTPlan.h"
+
+#include <string>
+#include <memory>
+
+AUD_NAMESPACE_BEGIN
+
+/**
+* This loader provides a method to load all the HRTFs in one directory, provided they follow the following naming scheme:
+* Example: L-10e210a.wav
+* The first character refers to the ear from which the HRTF was recorded: 'L' for a left ear and 'R' for a right ear.
+* Next is the elevation angle followed by the 'e' character. [-90, 90]
+* Then is the azimuth angle followed by the 'a' character. [0, 360)
+* For a sound source situated at the left of the listener the azimuth angle regarding the left ear is 90 while the angle regarding the right ear is 270.
+* KEMAR HRTFs use this naming scheme.
+*/
+class AUD_API HRTFLoader
+{
+private:
+ // delete normal constructor, copy constructor and operator=
+ HRTFLoader(const HRTFLoader&) = delete;
+ HRTFLoader& operator=(const HRTFLoader&) = delete;
+ HRTFLoader() = delete;
+
+public:
+ /**
+ * Loads all the left ear HRTFs in the directory.Onle one ear HRTFs for all azimuths [0,360) are needed for binaural sound.
+ * \param plan The plan that will be used to create the HRTF object.
+ * \param fileExtension The extension of the HRTF files.
+ * \param path The path to the folder containing the HRTFs.
+ * \return A shared pointer to a loaded HRTF object.
+ */
+ static std::shared_ptr<HRTF> loadLeftHRTFs(std::shared_ptr<FFTPlan> plan, const std::string& fileExtension, const std::string& path = "");
+
+ /**
+ * Loads all the right ear HRTFs in the directory. Onle one ear HRTFs for all azimuths [0,360) are needed for binaural sound.
+ * \param plan The plan that will be used to create the HRTF object.
+ * \param fileExtension The extension of the HRTF files.
+ * \param path The path to the folder containing the HRTFs.
+ * \return A shared pointer to a loaded HRTF object.
+ */
+ static std::shared_ptr<HRTF> loadRightHRTFs(std::shared_ptr<FFTPlan> plan, const std::string& fileExtension, const std::string& path = "");
+
+ /**
+ * Loads all the left ear HRTFs in the directory.Onle one ear HRTFs for all azimuths [0,360) are needed for binaural sound.
+ * \param fileExtension The extension of the HRTF files.
+ * \param path The path to the folder containing the HRTFs.
+ * \return A shared pointer to a loaded HRTF object.
+ */
+ static std::shared_ptr<HRTF> loadLeftHRTFs(const std::string& fileExtension, const std::string& path = "");
+
+ /**
+ * Loads all the right ear HRTFs in the directory. Onle one ear HRTFs for all azimuths [0,360) are needed for binaural sound.
+ * \param fileExtension The extension of the HRTF files.
+ * \param path The path to the folder containing the HRTFs.
+ * \return A shared pointer to a loaded HRTF object.
+ */
+ static std::shared_ptr<HRTF> loadRightHRTFs(const std::string& fileExtension, const std::string& path = "");
+
+
+private:
+
+ /**
+ * Loads all the HRTFs in the directory and subdirectories.
+ * \param hrtfs An HRTF object in which to load the HRTFs.
+ * \param ear 'L' to load left ear HRTFs, 'R' to load right ear HRTFs.
+ * \param fileExtension The extension of the HRTF files.
+ * \param path The path to the folder containing the HRTFs.
+ */
+ static void loadHRTFs(std::shared_ptr<HRTF>hrtfs, char ear, const std::string& fileExtension, const std::string& path = "");
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/Highpass.h b/extern/audaspace/include/fx/Highpass.h
new file mode 100644
index 00000000000..6bfb6d7885d
--- /dev/null
+++ b/extern/audaspace/include/fx/Highpass.h
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file Highpass.h
+ * @ingroup fx
+ * The Highpass class.
+ */
+
+#include "fx/DynamicIIRFilter.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This sound creates a highpass filter reader.
+ */
+class AUD_API Highpass : public DynamicIIRFilter
+{
+private:
+ // delete copy constructor and operator=
+ Highpass(const Highpass&) = delete;
+ Highpass& operator=(const Highpass&) = delete;
+
+public:
+ /**
+ * Creates a new highpass sound.
+ * \param sound The input sound.
+ * \param frequency The cutoff frequency.
+ * \param Q The Q factor.
+ */
+ Highpass(std::shared_ptr<ISound> sound, float frequency, float Q = 1.0f);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/HighpassCalculator.h b/extern/audaspace/include/fx/HighpassCalculator.h
new file mode 100644
index 00000000000..9306a3d20e5
--- /dev/null
+++ b/extern/audaspace/include/fx/HighpassCalculator.h
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file HighpassCalculator.h
+ * @ingroup fx
+ * The HighpassCalculator class.
+ */
+
+#include "fx/IDynamicIIRFilterCalculator.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * The HighpassCalculator class calculates high pass filter coefficients for a
+ * dynamic DynamicIIRFilter.
+ */
+class AUD_LOCAL HighpassCalculator : public IDynamicIIRFilterCalculator
+{
+private:
+ /**
+ * The cutoff frequency.
+ */
+ const float m_frequency;
+
+ /**
+ * The Q factor.
+ */
+ const float m_Q;
+
+ // delete copy constructor and operator=
+ HighpassCalculator(const HighpassCalculator&) = delete;
+ HighpassCalculator& operator=(const HighpassCalculator&) = delete;
+
+public:
+ /**
+ * Creates a HighpassCalculator object.
+ * @param frequency The cutoff frequency.
+ * @param Q The Q factor of the filter. If unsure, use 1.0 as default.
+ */
+ HighpassCalculator(float frequency, float Q);
+
+ virtual void recalculateCoefficients(SampleRate rate, std::vector<float> &b, std::vector<float> &a);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/IDynamicIIRFilterCalculator.h b/extern/audaspace/include/fx/IDynamicIIRFilterCalculator.h
new file mode 100644
index 00000000000..6c890b313b4
--- /dev/null
+++ b/extern/audaspace/include/fx/IDynamicIIRFilterCalculator.h
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file IDynamicIIRFilterCalculator.h
+ * @ingroup fx
+ * The IDynamicIIRFilterCalculator interface.
+ */
+
+#include "respec/Specification.h"
+
+#include <vector>
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * @interface IDynamicIIRFilterCalculator
+ * This interface calculates dynamic filter coefficients which depend on the
+ * sampling rate for DynamicIIRFilterReaders.
+ */
+class AUD_API IDynamicIIRFilterCalculator
+{
+public:
+ virtual ~IDynamicIIRFilterCalculator() {}
+
+ /**
+ * 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(SampleRate rate, std::vector<float>& b, std::vector<float>& a)=0;
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/IIRFilter.h b/extern/audaspace/include/fx/IIRFilter.h
new file mode 100644
index 00000000000..74099a30dc5
--- /dev/null
+++ b/extern/audaspace/include/fx/IIRFilter.h
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file IIRFilter.h
+ * @ingroup fx
+ * The IIRFilter class.
+ */
+
+#include "fx/Effect.h"
+
+#include <vector>
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This sound creates a IIR filter reader.
+ */
+class AUD_API IIRFilter : public Effect
+{
+private:
+ /**
+ * Output filter coefficients.
+ */
+ std::vector<float> m_a;
+
+ /**
+ * Input filter coefficients.
+ */
+ std::vector<float> m_b;
+
+ // delete copy constructor and operator=
+ IIRFilter(const IIRFilter&) = delete;
+ IIRFilter& operator=(const IIRFilter&) = delete;
+
+public:
+ /**
+ * Creates a new IIR filter sound.
+ * \param sound The input sound.
+ * \param b The input filter coefficients.
+ * \param a The output filter coefficients.
+ */
+ IIRFilter(std::shared_ptr<ISound> sound, const std::vector<float>& b, const std::vector<float>& a);
+
+ virtual std::shared_ptr<IReader> createReader();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/IIRFilterReader.h b/extern/audaspace/include/fx/IIRFilterReader.h
new file mode 100644
index 00000000000..34518ce69c6
--- /dev/null
+++ b/extern/audaspace/include/fx/IIRFilterReader.h
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file IIRFilterReader.h
+ * @ingroup fx
+ * The IIRFilterReader class.
+ */
+
+#include "fx/BaseIIRFilterReader.h"
+
+#include <vector>
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This class is for infinite impulse response filters with simple coefficients.
+ */
+class AUD_API IIRFilterReader : public BaseIIRFilterReader
+{
+private:
+ /**
+ * Output filter coefficients.
+ */
+ std::vector<float> m_a;
+
+ /**
+ * Input filter coefficients.
+ */
+ std::vector<float> m_b;
+
+ // delete copy constructor and operator=
+ IIRFilterReader(const IIRFilterReader&) = delete;
+ IIRFilterReader& operator=(const IIRFilterReader&) = delete;
+
+public:
+ /**
+ * Creates a new IIR filter reader.
+ * \param reader The reader to read from.
+ * \param b The input filter coefficients.
+ * \param a The output filter coefficients.
+ */
+ IIRFilterReader(std::shared_ptr<IReader> reader, const std::vector<float>& b, const std::vector<float>& a);
+
+ virtual sample_t filter();
+
+ /**
+ * Sets new filter coefficients.
+ * @param b The input filter coefficients.
+ * @param a The output filter coefficients.
+ */
+ void setCoefficients(const std::vector<float>& b, const std::vector<float>& a);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/ImpulseResponse.h b/extern/audaspace/include/fx/ImpulseResponse.h
new file mode 100644
index 00000000000..3cdb807ff99
--- /dev/null
+++ b/extern/audaspace/include/fx/ImpulseResponse.h
@@ -0,0 +1,108 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+/**
+* @file ImpulseResponse.h
+* @ingroup fx
+* The ImpulseResponse class.
+*/
+
+#include "util/StreamBuffer.h"
+#include "util/FFTPlan.h"
+#include "IReader.h"
+
+#include <memory>
+#include <vector>
+
+AUD_NAMESPACE_BEGIN
+
+/**
+* This class represents an impulse response that can be used in convolution.
+* When this class is instanced, the impulse response is divided in channels and those channels are divided in parts of N/2 samples (N being the size of the FFT plan used).
+* The main objetive of this class is to allow the reutilization of an impulse response in various sounds without having to process it more than one time.
+* \warning The size of the FFTPlan used to process the impulse response must be the same as the one used in the convolver classes.
+*/
+class AUD_API ImpulseResponse
+{
+private:
+ /**
+ * A tri-dimensional array (channels, parts, values) The impulse response is divided in channels and those channels are divided
+ * in parts of N/2 samples. Those parts are transformed to the frequency domain transform which generates uni-dimensional
+ * arrays of fftwtf_complex data (complex numbers).
+ */
+ std::vector<std::shared_ptr<std::vector<std::shared_ptr<std::vector<std::complex<sample_t>>>>>> m_processedIR;
+
+ /**
+ * The specification of the samples.
+ */
+ Specs m_specs;
+
+ /**
+ * The length of the impulse response.
+ */
+ int m_length;
+
+ // delete copy constructor and operator=
+ ImpulseResponse(const ImpulseResponse&) = delete;
+ ImpulseResponse& operator=(const ImpulseResponse&) = delete;
+
+public:
+ /**
+ * Creates a new ImpulseResponse object.
+ * The impulse response will be split and transformed to the frequency domain.
+ * \param impulseResponse The impulse response sound.
+ * \param plan A shared pointer to a FFT plan used to transform the impulse response.
+ */
+ ImpulseResponse(std::shared_ptr<StreamBuffer> impulseResponse, std::shared_ptr<FFTPlan> plan);
+
+ /**
+ * Creates a new ImpulseResponse object. This overload instances its own FFTPlan with default size.
+ * The impulse response will be split and transformed to the frequency domain.
+ * \param impulseResponse The impulse response sound.
+ */
+ ImpulseResponse(std::shared_ptr<StreamBuffer> impulseResponse);
+
+ /**
+ * Returns the specification of the impulse response.
+ * \return The specification of the impulse response.
+ */
+ Specs getSpecs();
+
+ /**
+ * Retrieves the length of the impulse response.
+ * \return The length of the impulse response.
+ */
+ int getLength();
+
+ /**
+ * Retrieves one channel of the impulse response.
+ * \param n The desired channel number (from 0 to channels-1).
+ * \return The desired channel of the impulse response.
+ */
+ std::shared_ptr<std::vector<std::shared_ptr<std::vector<std::complex<sample_t>>>>> getChannel(int n);
+
+private:
+ /**
+ * Processes the impulse response sound for its use in the convovler classes.
+ * \param A shared pointer to a reader of the desired sound.
+ * \param plan A shared pointer to a FFT plan used to transform the impulse response.
+ */
+ void processImpulseResponse(std::shared_ptr<IReader> reader, std::shared_ptr<FFTPlan> plan);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/Limiter.h b/extern/audaspace/include/fx/Limiter.h
new file mode 100644
index 00000000000..0b5451b4eed
--- /dev/null
+++ b/extern/audaspace/include/fx/Limiter.h
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file Limiter.h
+ * @ingroup fx
+ * The Limiter class.
+ */
+
+#include "fx/Effect.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This sound limits another sound in start and end time.
+ */
+class AUD_API Limiter : public Effect
+{
+private:
+ /**
+ * The start time.
+ */
+ const float m_start;
+
+ /**
+ * The end time.
+ */
+ const float m_end;
+
+ // delete copy constructor and operator=
+ Limiter(const Limiter&) = delete;
+ Limiter& operator=(const Limiter&) = delete;
+
+public:
+ /**
+ * Creates a new limiter sound.
+ * \param sound The input sound.
+ * \param start The desired start time.
+ * \param end The desired end time, a negative value signals that it should
+ * play to the end.
+ */
+ Limiter(std::shared_ptr<ISound> sound,
+ float start = 0, float end = -1);
+
+ /**
+ * Returns the start time.
+ */
+ float getStart() const;
+
+ /**
+ * Returns the end time.
+ */
+ float getEnd() const;
+
+ virtual std::shared_ptr<IReader> createReader();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/LimiterReader.h b/extern/audaspace/include/fx/LimiterReader.h
new file mode 100644
index 00000000000..49a07b5c29e
--- /dev/null
+++ b/extern/audaspace/include/fx/LimiterReader.h
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file LimiterReader.h
+ * @ingroup fx
+ * The LimiterReader class.
+ */
+
+#include "fx/EffectReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This reader limits another reader in start and end times.
+ */
+class AUD_API LimiterReader : public EffectReader
+{
+private:
+ /**
+ * The start sample: inclusive.
+ */
+ const float m_start;
+
+ /**
+ * The end sample: exlusive.
+ */
+ const float m_end;
+
+ // delete copy constructor and operator=
+ LimiterReader(const LimiterReader&) = delete;
+ LimiterReader& operator=(const LimiterReader&) = delete;
+
+public:
+ /**
+ * Creates a new limiter reader.
+ * \param reader The reader to read from.
+ * \param start The desired start time (inclusive).
+ * \param end The desired end time (sample exklusive), a negative value
+ * signals that it should play to the end.
+ */
+ LimiterReader(std::shared_ptr<IReader> reader, float start = 0, float end = -1);
+
+ virtual void seek(int position);
+ virtual int getLength() const;
+ virtual int getPosition() const;
+ virtual void read(int& length, bool& eos, sample_t* buffer);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/Loop.h b/extern/audaspace/include/fx/Loop.h
new file mode 100644
index 00000000000..c8ba7609f23
--- /dev/null
+++ b/extern/audaspace/include/fx/Loop.h
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file Loop.h
+ * @ingroup fx
+ * The Loop class.
+ */
+
+#include "fx/Effect.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This sound loops another sound.
+ * \note The reader has to be seekable.
+ */
+class AUD_API Loop : public Effect
+{
+private:
+ /**
+ * The loop count.
+ */
+ const int m_loop;
+
+ // delete copy constructor and operator=
+ Loop(const Loop&) = delete;
+ Loop& operator=(const Loop&) = delete;
+
+public:
+ /**
+ * Creates a new loop sound.
+ * \param sound The input sound.
+ * \param loop The desired loop count, negative values result in endless
+ * looping.
+ */
+ Loop(std::shared_ptr<ISound> sound, int loop = -1);
+
+ /**
+ * Returns the loop count.
+ */
+ int getLoop() const;
+
+ virtual std::shared_ptr<IReader> createReader();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/LoopReader.h b/extern/audaspace/include/fx/LoopReader.h
new file mode 100644
index 00000000000..72bb92c8b8f
--- /dev/null
+++ b/extern/audaspace/include/fx/LoopReader.h
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file LoopReader.h
+ * @ingroup fx
+ * The LoopReader class.
+ */
+
+#include "fx/EffectReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This class reads another reader and loops it.
+ * \note The other reader must be seekable.
+ */
+class AUD_API LoopReader : public EffectReader
+{
+private:
+ /**
+ * The loop count.
+ */
+ const int m_count;
+
+ /**
+ * The left loop count.
+ */
+ int m_left;
+
+ // delete copy constructor and operator=
+ LoopReader(const LoopReader&) = delete;
+ LoopReader& operator=(const LoopReader&) = delete;
+
+public:
+ /**
+ * Creates a new loop reader.
+ * \param reader The reader to read from.
+ * \param loop The desired loop count, negative values result in endless
+ * looping.
+ */
+ LoopReader(std::shared_ptr<IReader> reader, int loop);
+
+ virtual void seek(int position);
+ virtual int getLength() const;
+ virtual int getPosition() const;
+ virtual void read(int& length, bool& eos, sample_t* buffer);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/Lowpass.h b/extern/audaspace/include/fx/Lowpass.h
new file mode 100644
index 00000000000..c14e5e8e0e2
--- /dev/null
+++ b/extern/audaspace/include/fx/Lowpass.h
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file Lowpass.h
+ * @ingroup fx
+ * The Lowpass class.
+ */
+
+#include "fx/DynamicIIRFilter.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This sound creates a lowpass filter reader.
+ */
+class AUD_API Lowpass : public DynamicIIRFilter
+{
+private:
+ // delete copy constructor and operator=
+ Lowpass(const Lowpass&) = delete;
+ Lowpass& operator=(const Lowpass&) = delete;
+
+public:
+ /**
+ * Creates a new lowpass sound.
+ * \param sound The input sound.
+ * \param frequency The cutoff frequency.
+ * \param Q The Q factor.
+ */
+ Lowpass(std::shared_ptr<ISound> sound, float frequency, float Q = 1.0f);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/LowpassCalculator.h b/extern/audaspace/include/fx/LowpassCalculator.h
new file mode 100644
index 00000000000..477adfb5b5b
--- /dev/null
+++ b/extern/audaspace/include/fx/LowpassCalculator.h
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file LowpassCalculator.h
+ * @ingroup fx
+ * The LowpassCalculator class.
+ */
+
+#include "fx/IDynamicIIRFilterCalculator.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * The LowpassCalculator class calculates low pass filter coefficients for a
+ * dynamic DynamicIIRFilter.
+ */
+class AUD_LOCAL LowpassCalculator : public IDynamicIIRFilterCalculator
+{
+private:
+ /**
+ * The cutoff frequency.
+ */
+ const float m_frequency;
+
+ /**
+ * The Q factor.
+ */
+ const float m_Q;
+
+ // delete copy constructor and operator=
+ LowpassCalculator(const LowpassCalculator&) = delete;
+ LowpassCalculator& operator=(const LowpassCalculator&) = delete;
+
+public:
+ /**
+ * Creates a LowpassCalculator object.
+ * @param frequency The cutoff frequency.
+ * @param Q The Q factor of the filter. If unsure, use 1.0 as default.
+ */
+ LowpassCalculator(float frequency, float Q);
+
+ virtual void recalculateCoefficients(SampleRate rate, std::vector<float> &b, std::vector<float> &a);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/MutableReader.h b/extern/audaspace/include/fx/MutableReader.h
new file mode 100644
index 00000000000..217dd2aa5d4
--- /dev/null
+++ b/extern/audaspace/include/fx/MutableReader.h
@@ -0,0 +1,71 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+/**
+* @file MutableReader.h
+* @ingroup fx
+* The MutableReader class.
+*/
+
+#include "IReader.h"
+#include "ISound.h"
+
+#include <memory>
+
+AUD_NAMESPACE_BEGIN
+
+/**
+* This class represents a reader for a sound that can change with each playback. The change will occur when trying to seek backwards
+* If the sound doesn't support that, it will be restarted.
+* \warning Notice that if a SoundList object is assigned to several MutableReaders, sequential playback won't work correctly.
+* To prevent this the SoundList must be copied.
+*/
+class AUD_API MutableReader : public IReader
+{
+private:
+ /**
+ * The current reader.
+ */
+ std::shared_ptr<IReader> m_reader;
+
+ /**
+ * A sound from which to get the reader.
+ */
+ std::shared_ptr<ISound> m_sound;
+
+
+ // delete copy constructor and operator=
+ MutableReader(const MutableReader&) = delete;
+ MutableReader& operator=(const MutableReader&) = delete;
+
+public:
+ /**
+ * Creates a new mutable reader.
+ * \param sound A of sound you want to assign to this reader.
+ */
+ MutableReader(std::shared_ptr<ISound> sound);
+
+ virtual bool isSeekable() const;
+ virtual void seek(int position);
+ virtual int getLength() const;
+ virtual int getPosition() const;
+ virtual Specs getSpecs() const;
+ virtual void read(int& length, bool& eos, sample_t* buffer);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/MutableSound.h b/extern/audaspace/include/fx/MutableSound.h
new file mode 100644
index 00000000000..9b5aa95cf18
--- /dev/null
+++ b/extern/audaspace/include/fx/MutableSound.h
@@ -0,0 +1,58 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+/**
+* @file MutableSound.h
+* @ingroup fx
+* The MutableSound class.
+*/
+
+#include "ISound.h"
+
+#include <memory>
+
+AUD_NAMESPACE_BEGIN
+
+/**
+* Ths class allows to create MutableReaders for any sound.
+*/
+class AUD_API MutableSound : public ISound
+{
+private:
+ /**
+ * A pointer to a sound.
+ */
+ std::shared_ptr<ISound> m_sound;
+
+ // delete copy constructor and operator=
+ MutableSound(const MutableSound&) = delete;
+ MutableSound& operator=(const MutableSound&) = delete;
+
+public:
+ /**
+ * Creates a new MutableSound.
+ * \param sound The sound in which the MutabeReaders created with the createReader() method will be based.
+ * If shared pointer to a SoundList object is used in several mutable sounds the sequential
+ * playback will not work properly. A copy of the SoundList object must be made in this case.
+ */
+ MutableSound(std::shared_ptr<ISound> sound);
+
+ virtual std::shared_ptr<IReader> createReader();
+};
+
+AUD_NAMESPACE_END \ No newline at end of file
diff --git a/extern/audaspace/include/fx/Pitch.h b/extern/audaspace/include/fx/Pitch.h
new file mode 100644
index 00000000000..570366be549
--- /dev/null
+++ b/extern/audaspace/include/fx/Pitch.h
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file Pitch.h
+ * @ingroup fx
+ * The Pitch class.
+ */
+
+#include "fx/Effect.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This sound changes the pitch of another sound.
+ */
+class AUD_API Pitch : public Effect
+{
+private:
+ /**
+ * The pitch.
+ */
+ const float m_pitch;
+
+ // delete copy constructor and operator=
+ Pitch(const Pitch&) = delete;
+ Pitch& operator=(const Pitch&) = delete;
+
+public:
+ /**
+ * Creates a new pitch sound.
+ * \param sound The input sound.
+ * \param pitch The desired pitch.
+ */
+ Pitch(std::shared_ptr<ISound> sound, float pitch);
+
+ virtual std::shared_ptr<IReader> createReader();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/PitchReader.h b/extern/audaspace/include/fx/PitchReader.h
new file mode 100644
index 00000000000..c82f71b61bf
--- /dev/null
+++ b/extern/audaspace/include/fx/PitchReader.h
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file PitchReader.h
+ * @ingroup fx
+ * The PitchReader class.
+ */
+
+#include "fx/EffectReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This class reads another reader and changes it's pitch.
+ */
+class AUD_API PitchReader : public EffectReader
+{
+private:
+ /**
+ * The pitch level.
+ */
+ float m_pitch;
+
+ // delete copy constructor and operator=
+ PitchReader(const PitchReader&) = delete;
+ PitchReader& operator=(const PitchReader&) = delete;
+
+public:
+ /**
+ * Creates a new pitch reader.
+ * \param reader The reader to read from.
+ * \param pitch The pitch value.
+ */
+ PitchReader(std::shared_ptr<IReader> reader, float pitch);
+
+ virtual Specs getSpecs() const;
+
+ /**
+ * Retrieves the pitch.
+ * \return The current pitch value.
+ */
+ float getPitch() const;
+
+ /**
+ * Sets the pitch.
+ * \param pitch The new pitch value.
+ */
+ void setPitch(float pitch);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/PlaybackCategory.h b/extern/audaspace/include/fx/PlaybackCategory.h
new file mode 100644
index 00000000000..7721623359f
--- /dev/null
+++ b/extern/audaspace/include/fx/PlaybackCategory.h
@@ -0,0 +1,127 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+/**
+* @file PlaybackCategory.h
+* @ingroup fx
+* The PlaybackCategory class.
+*/
+
+#include "devices/IHandle.h"
+#include "devices/IDevice.h"
+#include "VolumeStorage.h"
+
+#include <unordered_map>
+#include <memory>
+
+AUD_NAMESPACE_BEGIN
+
+/**
+* This class represents a category of related sounds which are currently playing and allows to control them easily.
+*/
+class AUD_API PlaybackCategory
+{
+private:
+ /**
+ * Next handle ID to be assigned.
+ */
+ unsigned int m_currentID;
+
+ /**
+ * Vector of handles that belong to the category.
+ */
+ std::unordered_map<unsigned int, std::shared_ptr<IHandle>> m_handles;
+
+ /**
+ * Device that will play the sounds.
+ */
+ std::shared_ptr<IDevice> m_device;
+
+ /**
+ * Status of the category.
+ */
+ Status m_status;
+
+ /**
+ * Volume of all the sounds of the category.
+ */
+ std::shared_ptr<VolumeStorage> m_volumeStorage;
+
+ // delete copy constructor and operator=
+ PlaybackCategory(const PlaybackCategory&) = delete;
+ PlaybackCategory& operator=(const PlaybackCategory&) = delete;
+
+public:
+ /**
+ * Creates a new PlaybackCategory.
+ * \param device A shared pointer to the device which will be used for playback.
+ */
+ PlaybackCategory(std::shared_ptr<IDevice> device);
+ ~PlaybackCategory();
+
+ /**
+ * Plays a new sound in the category.
+ * \param sound The sound to be played.
+ * \return A handle for the playback. If the playback failed, nullptr will be returned.
+ */
+ std::shared_ptr<IHandle> play(std::shared_ptr<ISound> sound);
+
+ /**
+ * Resumes all the paused sounds of the category.
+ */
+ void resume();
+
+ /**
+ * Pauses all current played back sounds of the category.
+ */
+ void pause();
+
+ /**
+ * Retrieves the volume of the category.
+ * \return The volume.
+ */
+ float getVolume();
+
+ /**
+ * Sets the volume for the category.
+ * \param volume The volume.
+ */
+ void setVolume(float volume);
+
+ /**
+ * Stops all the playing back or paused sounds.
+ */
+ void stop();
+
+ /**
+ * Retrieves the shared volume of the category.
+ * \return A shared pointer to the VolumeStorage object that represents the shared volume of the category.
+ */
+ std::shared_ptr<VolumeStorage> getSharedVolume();
+
+ /**
+ * Cleans the category erasing all the invalid handles.
+ * Only needed if individual sounds are stopped with their handles.
+ */
+ void cleanHandles();
+
+private:
+ static void cleanHandleCallback(void* data);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/PlaybackManager.h b/extern/audaspace/include/fx/PlaybackManager.h
new file mode 100644
index 00000000000..f660568b8db
--- /dev/null
+++ b/extern/audaspace/include/fx/PlaybackManager.h
@@ -0,0 +1,156 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+/**
+* @file PlaybackManager.h
+* @ingroup fx
+* The PlaybackManager class.
+*/
+
+#include "PlaybackCategory.h"
+#include "devices/IDevice.h"
+#include "ISound.h"
+
+#include <unordered_map>
+#include <memory>
+
+AUD_NAMESPACE_BEGIN
+
+/**
+* This class allows to control groups of playing sounds easily.
+* The sounds are part of categories.
+*/
+class AUD_API PlaybackManager
+{
+private:
+ /**
+ * Unordered map of categories, each category has different name.
+ */
+ std::unordered_map<unsigned int, std::shared_ptr<PlaybackCategory>> m_categories;
+
+ /**
+ * Device used for playback.
+ */
+ std::shared_ptr<IDevice> m_device;
+
+ /**
+ * The current key used for new categories.
+ */
+ unsigned int m_currentKey;
+
+ // delete copy constructor and operator=
+ PlaybackManager(const PlaybackManager&) = delete;
+ PlaybackManager& operator=(const PlaybackManager&) = delete;
+
+public:
+ /**
+ * Creates a new PlaybackManager.
+ * \param device A shared pointer to the device which will be used for playback.
+ */
+ PlaybackManager(std::shared_ptr<IDevice> device);
+
+ /**
+ * Adds an existent category to the manager and returns a key to access it.
+ * \param category The category to be added.
+ * \return The category key.
+ */
+ unsigned int addCategory(std::shared_ptr<PlaybackCategory> category);
+
+ /**
+ * Adds an existent category to the manager and returns a key to access it.
+ * \param volume The volume of the new category.
+ * \return The category key.
+ */
+ unsigned int addCategory(float volume);
+
+ /**
+ * Plays a sound and adds it to a new or existent category.
+ * \param sound The sound to be played and added to a category.
+ * \param catKey Key of the category.
+ * \return The handle of the playback; nullptr if the sound couldn't be played.
+ */
+ std::shared_ptr<IHandle> play(std::shared_ptr<ISound> sound, unsigned int catKey);
+
+ /**
+ * Resumes all the paused sounds of a category.
+ * \param catKey Key of the category.
+ * \return
+ * - true if succesful.
+ * - false if the category doesn't exist.
+ */
+ bool resume(unsigned int catKey);
+
+ /**
+ * Pauses all current playing sounds of a category.
+ * \param catKey Key of the category.
+ * \return
+ * - true if succesful.
+ * - false if the category doesn't exist.
+ */
+ bool pause(unsigned int catKey);
+
+ /**
+ * Retrieves the volume of a category.
+ * \param catKey Key of the category.
+ * \return The volume value of the category. If the category doesn't exist it returns a negative number.
+ */
+ float getVolume(unsigned int catKey);
+
+ /**
+ * Sets the volume for a category.
+ * \param volume The volume.
+ * \param catKey Key of the category.
+ * \return
+ * - true if succesful.
+ * - false if the category doesn't exist.
+ */
+ bool setVolume(float volume, unsigned int catKey);
+
+ /**
+ * Stops and erases a category of sounds.
+ * \param catKey Key of the category.
+ * \return
+ * - true if succesful.
+ * - false if the category doesn't exist.
+ */
+ bool stop(unsigned int catKey);
+
+ /**
+ * Removes all the invalid handles of all the categories.
+ * Only needed if individual sounds are stopped with their handles.
+ */
+ void clean();
+
+ /**
+ * Removes all the invalid handles of a category.
+ * Only needed if individual sounds are stopped with their handles.
+ * \param catKey Key of the category.
+ * \return
+ * - true if succesful.
+ * - false if the category doesn't exist.
+ */
+ bool clean(unsigned int catKey);
+
+ /**
+ * Retrieves the device of the PlaybackManager.
+ * \return A shared pointer to the device used by the playback manager.
+ */
+ std::shared_ptr<IDevice> getDevice();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/Reverse.h b/extern/audaspace/include/fx/Reverse.h
new file mode 100644
index 00000000000..32227da977a
--- /dev/null
+++ b/extern/audaspace/include/fx/Reverse.h
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file Reverse.h
+ * @ingroup fx
+ * The Reverse class.
+ */
+
+#include "fx/Effect.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This sound reads another sound reverted.
+ * \note Readers from the underlying sound must be seekable.
+ */
+class AUD_API Reverse : public Effect
+{
+private:
+ // delete copy constructor and operator=
+ Reverse(const Reverse&) = delete;
+ Reverse& operator=(const Reverse&) = delete;
+
+public:
+ /**
+ * Creates a new reverse sound.
+ * \param sound The input sound.
+ */
+ Reverse(std::shared_ptr<ISound> sound);
+
+ virtual std::shared_ptr<IReader> createReader();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/ReverseReader.h b/extern/audaspace/include/fx/ReverseReader.h
new file mode 100644
index 00000000000..a02608e1378
--- /dev/null
+++ b/extern/audaspace/include/fx/ReverseReader.h
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file ReverseReader.h
+ * @ingroup fx
+ * The ReverseReader class.
+ */
+
+#include "fx/EffectReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This class reads another reader from back to front.
+ * \note The underlying reader must be seekable.
+ */
+class AUD_API ReverseReader : public EffectReader
+{
+private:
+ /**
+ * The sample count.
+ */
+ const int m_length;
+
+ /**
+ * The current position.
+ */
+ int m_position;
+
+ // delete copy constructor and operator=
+ ReverseReader(const ReverseReader&) = delete;
+ ReverseReader& operator=(const ReverseReader&) = delete;
+
+public:
+ /**
+ * Creates a new reverse reader.
+ * \param reader The reader to read from.
+ * \exception Exception Thrown if the reader specified has an
+ * undeterminable/infinite length or is not seekable.
+ */
+ ReverseReader(std::shared_ptr<IReader> reader);
+
+ virtual void seek(int position);
+ virtual int getLength() const;
+ virtual int getPosition() const;
+ virtual void read(int& length, bool& eos, sample_t* buffer);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/SoundList.h b/extern/audaspace/include/fx/SoundList.h
new file mode 100644
index 00000000000..ce3cb386969
--- /dev/null
+++ b/extern/audaspace/include/fx/SoundList.h
@@ -0,0 +1,110 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+/**
+* @file SoundList.h
+* @ingroup fx
+* The SoundList class.
+*/
+
+#include "ISound.h"
+
+#include <vector>
+#include <memory>
+#include <mutex>
+
+AUD_NAMESPACE_BEGIN
+
+/**
+* This class allows to have a list of sound that will play sequentially or randomly with each playback.
+*/
+class AUD_API SoundList : public ISound
+{
+private:
+ /**
+ * The list of sounds that will play.
+ */
+ std::vector<std::shared_ptr<ISound>> m_list;
+
+ /**
+ * Flag for random playback
+ */
+ bool m_random = false;
+
+ /**
+ * Current sound index. -1 if no reader has been created.
+ */
+ int m_index = -1;
+
+ /**
+ * Mutex to prevent multithreading crashes.
+ */
+ std::recursive_mutex m_mutex;
+
+ // delete copy constructor and operator=
+ SoundList(const SoundList&) = delete;
+ SoundList& operator=(const SoundList&) = delete;
+
+public:
+ /**
+ * Creates a new, empty sound list.
+ * Sounds must be added to the list using the addSound() method.
+ * \param random False if the sounds int he list must be played sequentially. True if random.
+ */
+ SoundList(bool random = false);
+
+ /**
+ * Creates a new sound list and initializes it.
+ * \param list A vector with sounds to initialize the list.
+ * \param random False if the sounds int he list must be played sequentially. True if random.
+ */
+ SoundList(std::vector<std::shared_ptr<ISound>>& list, bool random = false);
+
+ virtual std::shared_ptr<IReader> createReader();
+
+ /**
+ * Adds a sound to the list.
+ * The added sounds can be played sequentially or randomly dependig
+ * on the m_random flag
+ * \param sound A shared_ptr to the sound.
+ */
+ void addSound(std::shared_ptr<ISound> sound);
+
+ /**
+ * Sets the playback mode of the sound list.
+ * There are two posible modes, random and sequential.
+ * \param random True to activate the random mode, false to activate sequential mode.
+ */
+ void setRandomMode(bool random);
+
+ /**
+ * Returns the playback mode of the sound list.
+ * The two posible modes are random and sequential.
+ * \return True if the random mode is activated, false otherwise.
+ */
+ bool getRandomMode();
+
+ /**
+ * Returns the amount of sounds in the list.
+ * \return The amount of sounds in the list.
+ */
+ int getSize();
+
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/Source.h b/extern/audaspace/include/fx/Source.h
new file mode 100644
index 00000000000..84448aa669d
--- /dev/null
+++ b/extern/audaspace/include/fx/Source.h
@@ -0,0 +1,109 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+/**
+* @file Source.h
+* @ingroup fx
+* The Source class.
+*/
+
+#include "Audaspace.h"
+
+#include <atomic>
+
+AUD_NAMESPACE_BEGIN
+
+/**
+* This class stores the azimuth and elevation angles of a sound and allows to change them dynamically.
+* The azimuth angle goes clockwise. For a sound source situated at the right of the listener the azimuth angle is 90.
+*/
+class AUD_API Source
+{
+private:
+ /**
+ * Azimuth value.
+ */
+ std::atomic<float> m_azimuth;
+
+ /**
+ * Elevation value.
+ */
+ std::atomic<float> m_elevation;
+
+ /**
+ * Distance value. Between 0 and 1.
+ */
+ std::atomic<float> m_distance;
+
+ // delete copy constructor and operator=
+ Source(const Source&) = delete;
+ Source& operator=(const Source&) = delete;
+
+public:
+ /**
+ * Creates a Source instance with an initial value.
+ * \param azimuth The value of the azimuth.
+ * \param elevation The value of the elevation.
+ * \param distance The distance from the listener. Max distance is 1, min distance is 0.
+ */
+ Source(float azimuth, float elevation, float distance = 0.0);
+
+ /**
+ * Retrieves the current azimuth value.
+ * \return The current azimuth.
+ */
+ float getAzimuth();
+
+ /**
+ * Retrieves the current elevation value.
+ * \return The current elevation.
+ */
+ float getElevation();
+
+ /**
+ * Retrieves the current distance value.
+ * \return The current distance.
+ */
+ float getDistance();
+
+ /**
+ * Retrieves the current volume value based on the distance.
+ * \return The current volume based on the Distance.
+ */
+ float getVolume();
+
+ /**
+ * Changes the azimuth value.
+ * \param azimuth The new value for the azimuth.
+ */
+ void setAzimuth(float azimuth);
+
+ /**
+ * Changes the elevation value.
+ * \param elevation The new value for the elevation.
+ */
+ void setElevation(float elevation);
+
+ /**
+ * Changes the distance value.
+ * \param distance The new value for the distance. Max distance is 1, min distance is 0.
+ */
+ void setDistance(float distance);
+};
+
+AUD_NAMESPACE_END \ No newline at end of file
diff --git a/extern/audaspace/include/fx/Sum.h b/extern/audaspace/include/fx/Sum.h
new file mode 100644
index 00000000000..b590aa7fcd1
--- /dev/null
+++ b/extern/audaspace/include/fx/Sum.h
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file Sum.h
+ * @ingroup fx
+ * The Sum class.
+ */
+
+#include "fx/Effect.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This sound creates a sum reader.
+ */
+class AUD_API Sum : public Effect
+{
+private:
+ // delete copy constructor and operator=
+ Sum(const Sum&) = delete;
+ Sum& operator=(const Sum&) = delete;
+
+public:
+ /**
+ * Creates a new sum sound.
+ * \param sound The input sound.
+ */
+ Sum(std::shared_ptr<ISound> sound);
+
+ virtual std::shared_ptr<IReader> createReader();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/Threshold.h b/extern/audaspace/include/fx/Threshold.h
new file mode 100644
index 00000000000..10baef1714d
--- /dev/null
+++ b/extern/audaspace/include/fx/Threshold.h
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file Threshold.h
+ * @ingroup fx
+ * The Threshold class.
+ */
+
+#include "fx/Effect.h"
+
+AUD_NAMESPACE_BEGIN
+
+class CallbackIIRFilterReader;
+
+/**
+ * This sound Transforms any signal to a square signal by thresholding.
+ */
+class AUD_API Threshold : public Effect
+{
+private:
+ /**
+ * The threshold.
+ */
+ const float m_threshold;
+
+ // delete copy constructor and operator=
+ Threshold(const Threshold&) = delete;
+ Threshold& operator=(const Threshold&) = delete;
+
+public:
+ /**
+ * Creates a new threshold sound.
+ * \param sound The input sound.
+ * \param threshold The threshold.
+ */
+ Threshold(std::shared_ptr<ISound> sound, float threshold = 0.0f);
+
+ /**
+ * Returns the threshold.
+ */
+ float getThreshold() const;
+
+ virtual std::shared_ptr<IReader> createReader();
+
+ /**
+ * The thresholdFilter function implements the doFilterIIR callback
+ * for the callback IIR filter.
+ * @param reader The CallbackIIRFilterReader that executes the callback.
+ * @param threshold The threshold value.
+ * @return The filtered sample.
+ */
+ static sample_t AUD_LOCAL thresholdFilter(CallbackIIRFilterReader* reader, float* threshold);
+
+ /**
+ * The endThresholdFilter function implements the endFilterIIR callback
+ * for the callback IIR filter.
+ * @param threshold The threshold value.
+ */
+ static void AUD_LOCAL endThresholdFilter(float* threshold);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/Volume.h b/extern/audaspace/include/fx/Volume.h
new file mode 100644
index 00000000000..0e56e8efd9b
--- /dev/null
+++ b/extern/audaspace/include/fx/Volume.h
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file Volume.h
+ * @ingroup fx
+ * The Volume class.
+ */
+
+#include "fx/Effect.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This sound changes the volume of another sound.
+ * The set volume should be a value between 0.0 and 1.0, higher values at your
+ * own risk!
+ */
+class AUD_API Volume : public Effect
+{
+private:
+ /**
+ * The volume.
+ */
+ const float m_volume;
+
+ // delete copy constructor and operator=
+ Volume(const Volume&) = delete;
+ Volume& operator=(const Volume&) = delete;
+
+public:
+ /**
+ * Creates a new volume sound.
+ * \param sound The input sound.
+ * \param volume The desired volume.
+ */
+ Volume(std::shared_ptr<ISound> sound, float volume);
+
+ /**
+ * Returns the volume.
+ * \return The current volume.
+ */
+ float getVolume() const;
+
+ virtual std::shared_ptr<IReader> createReader();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/fx/VolumeReader.h b/extern/audaspace/include/fx/VolumeReader.h
new file mode 100644
index 00000000000..13b6845e931
--- /dev/null
+++ b/extern/audaspace/include/fx/VolumeReader.h
@@ -0,0 +1,70 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+/**
+* @file VolumeReader.h
+* @ingroup fx
+* The VolumeReader class.
+*/
+
+#include "IReader.h"
+#include "ISound.h"
+#include "VolumeStorage.h"
+
+#include <memory>
+
+AUD_NAMESPACE_BEGIN
+
+/**
+* This class represents a reader for a sound that has its own shared volume
+*/
+class AUD_API VolumeReader : public IReader
+{
+private:
+ /**
+ * The current reader.
+ */
+ std::shared_ptr<IReader> m_reader;
+
+ /**
+ * A sound from which to get the reader.
+ */
+ std::shared_ptr<VolumeStorage> m_volumeStorage;
+
+
+ // delete copy constructor and operator=
+ VolumeReader(const VolumeReader&) = delete;
+ VolumeReader& operator=(const VolumeReader&) = delete;
+
+public:
+ /**
+ * Creates a new volume reader.
+ * \param reader A reader of the sound to be assigned to this reader.
+ * \param volumeStorage A shared pointer to a VolumeStorage object.
+ */
+ VolumeReader(std::shared_ptr<IReader> reader, std::shared_ptr<VolumeStorage> volumeStorage);
+
+ virtual bool isSeekable() const;
+ virtual void seek(int position);
+ virtual int getLength() const;
+ virtual int getPosition() const;
+ virtual Specs getSpecs() const;
+ virtual void read(int& length, bool& eos, sample_t* buffer);
+};
+
+AUD_NAMESPACE_END \ No newline at end of file
diff --git a/extern/audaspace/include/fx/VolumeSound.h b/extern/audaspace/include/fx/VolumeSound.h
new file mode 100644
index 00000000000..0aeffd53e87
--- /dev/null
+++ b/extern/audaspace/include/fx/VolumeSound.h
@@ -0,0 +1,74 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+/**
+* @file VolumeSound.h
+* @ingroup fx
+* The VolumeSound class.
+*/
+
+#include "ISound.h"
+#include "VolumeStorage.h"
+#include <memory>
+
+AUD_NAMESPACE_BEGIN
+
+/**
+* This class allows to create a sound with its own volume.
+*/
+class AUD_API VolumeSound : public ISound
+{
+private:
+ /**
+ * A pointer to a sound.
+ */
+ std::shared_ptr<ISound> m_sound;
+
+ /**
+ * A pointer to the shared volume being used.
+ */
+ std::shared_ptr<VolumeStorage> m_volumeStorage;
+
+ // delete copy constructor and operator=
+ VolumeSound(const VolumeSound&) = delete;
+ VolumeSound& operator=(const VolumeSound&) = delete;
+
+public:
+ /**
+ * Creates a new VolumeSound.
+ * \param sound The sound in which shall have its own volume.
+ * \param volumeStorage A shared pointer to a VolumeStorage object. It allows to change the volume of various sound in one go.
+ */
+ VolumeSound(std::shared_ptr<ISound> sound, std::shared_ptr<VolumeStorage> volumeStorage);
+
+ virtual std::shared_ptr<IReader> createReader();
+
+ /**
+ * Retrieves the shared volume of this sound.
+ * \return A shared pointer to the VolumeStorage object that this sound is using.
+ */
+ std::shared_ptr<VolumeStorage> getSharedVolume();
+
+ /**
+ * Changes the shared volume of this sound, it'll only affect newly created readers.
+ * \param volumeStorage A shared pointer to the new VolumeStorage object.
+ */
+ void setSharedVolume(std::shared_ptr<VolumeStorage> volumeStorage);
+};
+
+AUD_NAMESPACE_END \ No newline at end of file
diff --git a/extern/audaspace/include/fx/VolumeStorage.h b/extern/audaspace/include/fx/VolumeStorage.h
new file mode 100644
index 00000000000..5088a5e2ba9
--- /dev/null
+++ b/extern/audaspace/include/fx/VolumeStorage.h
@@ -0,0 +1,71 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+/**
+* @file VolumeStorage.h
+* @ingroup fx
+* The VolumeStorage class.
+*/
+
+#include "Audaspace.h"
+
+#include <atomic>
+
+AUD_NAMESPACE_BEGIN
+
+/**
+* This class stores a volume value and allows to change if for a number of sounds in one go.
+*/
+class AUD_API VolumeStorage
+{
+private:
+ /**
+ * Volume value.
+ */
+ std::atomic<float> m_volume;
+
+ // delete copy constructor and operator=
+ VolumeStorage(const VolumeStorage&) = delete;
+ VolumeStorage& operator=(const VolumeStorage&) = delete;
+
+public:
+ /**
+ * Creates a new VolumeStorage instance with volume 1
+ */
+ VolumeStorage();
+
+ /**
+ * Creates a VolumeStorage instance with an initial value.
+ * \param volume The value of the volume.
+ */
+ VolumeStorage(float volume);
+
+ /**
+ * Retrieves the current volume value.
+ * \return The current volume.
+ */
+ float getVolume();
+
+ /**
+ * Changes the volume value.
+ * \param volume The new value for the volume.
+ */
+ void setVolume(float volume);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/generator/Sawtooth.h b/extern/audaspace/include/generator/Sawtooth.h
new file mode 100644
index 00000000000..68f56ae83fd
--- /dev/null
+++ b/extern/audaspace/include/generator/Sawtooth.h
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file Sawtooth.h
+ * @ingroup generator
+ * The Sawtooth class.
+ */
+
+#include "ISound.h"
+#include "respec/Specification.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This sound creates a reader that plays a sawtooth tone.
+ */
+class AUD_API Sawtooth : public ISound
+{
+private:
+ /**
+ * The frequence of the sawtooth wave.
+ */
+ const float m_frequency;
+
+ /**
+ * The target sample rate for output.
+ */
+ const SampleRate m_sampleRate;
+
+ // delete copy constructor and operator=
+ Sawtooth(const Sawtooth&) = delete;
+ Sawtooth& operator=(const Sawtooth&) = delete;
+
+public:
+ /**
+ * Creates a new sawtooth sound.
+ * \param frequency The desired frequency.
+ * \param sampleRate The target sample rate for playback.
+ */
+ Sawtooth(float frequency, SampleRate sampleRate = RATE_48000);
+
+ /**
+ * Returns the frequency of the sawtooth wave.
+ */
+ float getFrequency() const;
+
+ virtual std::shared_ptr<IReader> createReader();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/generator/SawtoothReader.h b/extern/audaspace/include/generator/SawtoothReader.h
new file mode 100644
index 00000000000..b4045eb8820
--- /dev/null
+++ b/extern/audaspace/include/generator/SawtoothReader.h
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file SawtoothReader.h
+ * @ingroup generator
+ * The SawtoothReader class.
+ */
+
+#include "IReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This class is used for sawtooth tone playback.
+ * The output format is in the 16 bit format and stereo, the sample rate can be
+ * specified.
+ * As the two channels both play the same the output could also be mono, but
+ * in most cases this will result in having to resample for output, so stereo
+ * sound is created directly.
+ */
+class AUD_API SawtoothReader : public IReader
+{
+private:
+ /**
+ * The frequency of the sine wave.
+ */
+ float m_frequency;
+
+ /**
+ * The current position in samples.
+ */
+ int m_position;
+
+ /**
+ * The value of the current sample.
+ */
+ float m_sample;
+
+ /**
+ * The sample rate for the output.
+ */
+ const SampleRate m_sampleRate;
+
+ // delete copy constructor and operator=
+ SawtoothReader(const SawtoothReader&) = delete;
+ SawtoothReader& operator=(const SawtoothReader&) = delete;
+
+public:
+ /**
+ * Creates a new reader.
+ * \param frequency The frequency of the sine wave.
+ * \param sampleRate The output sample rate.
+ */
+ SawtoothReader(float frequency, SampleRate sampleRate);
+
+ /**
+ * Sets the frequency of the wave.
+ * @param frequency The new frequency in Hertz.
+ */
+ void setFrequency(float frequency);
+
+ virtual bool isSeekable() const;
+ virtual void seek(int position);
+ virtual int getLength() const;
+ virtual int getPosition() const;
+ virtual Specs getSpecs() const;
+ virtual void read(int & length, bool &eos, sample_t* buffer);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/generator/Silence.h b/extern/audaspace/include/generator/Silence.h
new file mode 100644
index 00000000000..a35b83d37fc
--- /dev/null
+++ b/extern/audaspace/include/generator/Silence.h
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file Silence.h
+ * @ingroup generator
+ * The Silence class.
+ */
+
+#include "ISound.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This sound creates a reader that plays silence.
+ */
+class AUD_API Silence : public ISound
+{
+private:
+ // delete copy constructor and operator=
+ Silence(const Silence&) = delete;
+ Silence& operator=(const Silence&) = delete;
+
+public:
+ /**
+ * Creates a new silence sound.
+ */
+ Silence();
+
+ virtual std::shared_ptr<IReader> createReader();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/generator/SilenceReader.h b/extern/audaspace/include/generator/SilenceReader.h
new file mode 100644
index 00000000000..ecc0ce86da9
--- /dev/null
+++ b/extern/audaspace/include/generator/SilenceReader.h
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file SilenceReader.h
+ * @ingroup generator
+ * The SilenceReader class.
+ */
+
+#include "IReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This class is used for silence playback.
+ * The signal generated is 44.1kHz mono.
+ */
+class AUD_API SilenceReader : public IReader
+{
+private:
+ /**
+ * The current position in samples.
+ */
+ int m_position;
+
+ // delete copy constructor and operator=
+ SilenceReader(const SilenceReader&) = delete;
+ SilenceReader& operator=(const SilenceReader&) = delete;
+
+public:
+ /**
+ * Creates a new reader.
+ */
+ SilenceReader();
+
+ virtual bool isSeekable() const;
+ virtual void seek(int position);
+ virtual int getLength() const;
+ virtual int getPosition() const;
+ virtual Specs getSpecs() const;
+ virtual void read(int& length, bool& eos, sample_t* buffer);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/generator/Sine.h b/extern/audaspace/include/generator/Sine.h
new file mode 100644
index 00000000000..ee78fc7d06b
--- /dev/null
+++ b/extern/audaspace/include/generator/Sine.h
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file Sine.h
+ * @ingroup generator
+ * The Sine class.
+ */
+
+#include "ISound.h"
+#include "respec/Specification.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This sound creates a reader that plays a sine tone.
+ */
+class AUD_API Sine : public ISound
+{
+private:
+ /**
+ * The frequence of the sine wave.
+ */
+ const float m_frequency;
+
+ /**
+ * The target sample rate for output.
+ */
+ const SampleRate m_sampleRate;
+
+ // delete copy constructor and operator=
+ Sine(const Sine&) = delete;
+ Sine& operator=(const Sine&) = delete;
+
+public:
+ /**
+ * Creates a new sine sound.
+ * \param frequency The desired frequency.
+ * \param sampleRate The target sample rate for playback.
+ */
+ Sine(float frequency,
+ SampleRate sampleRate = RATE_48000);
+
+ /**
+ * Returns the frequency of the sine wave.
+ */
+ float getFrequency() const;
+
+ virtual std::shared_ptr<IReader> createReader();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/generator/SineReader.h b/extern/audaspace/include/generator/SineReader.h
new file mode 100644
index 00000000000..49cd571bc65
--- /dev/null
+++ b/extern/audaspace/include/generator/SineReader.h
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file SineReader.h
+ * @ingroup generator
+ * The SineReader class.
+ */
+
+#include "IReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This class is used for sine tone playback.
+ * The sample rate can be specified, the signal is mono.
+ */
+class AUD_API SineReader : public IReader
+{
+private:
+ /**
+ * The frequency of the sine wave.
+ */
+ float m_frequency;
+
+ /**
+ * The current position in samples.
+ */
+ int m_position;
+
+ /**
+ * The sample rate for the output.
+ */
+ const SampleRate m_sampleRate;
+
+ // delete copy constructor and operator=
+ SineReader(const SineReader&) = delete;
+ SineReader& operator=(const SineReader&) = delete;
+
+public:
+ /**
+ * Creates a new reader.
+ * \param frequency The frequency of the sine wave.
+ * \param sampleRate The output sample rate.
+ */
+ SineReader(float frequency, SampleRate sampleRate);
+
+ /**
+ * Sets the frequency of the wave.
+ * @param frequency The new frequency in Hertz.
+ */
+ void setFrequency(float frequency);
+
+ virtual bool isSeekable() const;
+ virtual void seek(int position);
+ virtual int getLength() const;
+ virtual int getPosition() const;
+ virtual Specs getSpecs() const;
+ virtual void read(int& length, bool& eos, sample_t* buffer);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/generator/Square.h b/extern/audaspace/include/generator/Square.h
new file mode 100644
index 00000000000..0ba27677a81
--- /dev/null
+++ b/extern/audaspace/include/generator/Square.h
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file Square.h
+ * @ingroup generator
+ * The Square class.
+ */
+
+#include "ISound.h"
+#include "respec/Specification.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This sound creates a reader that plays a square tone.
+ */
+class AUD_API Square : public ISound
+{
+private:
+ /**
+ * The frequence of the square wave.
+ */
+ const float m_frequency;
+
+ /**
+ * The target sample rate for output.
+ */
+ const SampleRate m_sampleRate;
+
+ // delete copy constructor and operator=
+ Square(const Square&) = delete;
+ Square& operator=(const Square&) = delete;
+
+public:
+ /**
+ * Creates a new square sound.
+ * \param frequency The desired frequency.
+ * \param sampleRate The target sample rate for playback.
+ */
+ Square(float frequency,
+ SampleRate sampleRate = RATE_48000);
+
+ /**
+ * Returns the frequency of the square wave.
+ */
+ float getFrequency() const;
+
+ virtual std::shared_ptr<IReader> createReader();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/generator/SquareReader.h b/extern/audaspace/include/generator/SquareReader.h
new file mode 100644
index 00000000000..53fc574c767
--- /dev/null
+++ b/extern/audaspace/include/generator/SquareReader.h
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file SquareReader.h
+ * @ingroup generator
+ * The SquareReader class.
+ */
+
+#include "IReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This class is used for square tone playback.
+ * The output format is in the 16 bit format and stereo, the sample rate can be
+ * specified.
+ * As the two channels both play the same the output could also be mono, but
+ * in most cases this will result in having to resample for output, so stereo
+ * sound is created directly.
+ */
+class AUD_API SquareReader : public IReader
+{
+private:
+ /**
+ * The frequency of the sine wave.
+ */
+ float m_frequency;
+
+ /**
+ * The current position in samples.
+ */
+ int m_position;
+
+ /**
+ * The value of the current sample.
+ */
+ float m_sample;
+
+ /**
+ * The sample rate for the output.
+ */
+ const SampleRate m_sampleRate;
+
+ // delete copy constructor and operator=
+ SquareReader(const SquareReader&) = delete;
+ SquareReader& operator=(const SquareReader&) = delete;
+
+public:
+ /**
+ * Creates a new reader.
+ * \param frequency The frequency of the sine wave.
+ * \param sampleRate The output sample rate.
+ */
+ SquareReader(float frequency, SampleRate sampleRate);
+
+ /**
+ * Sets the frequency of the wave.
+ * @param frequency The new frequency in Hertz.
+ */
+ void setFrequency(float frequency);
+
+ virtual bool isSeekable() const;
+ virtual void seek(int position);
+ virtual int getLength() const;
+ virtual int getPosition() const;
+ virtual Specs getSpecs() const;
+ virtual void read(int & length, bool &eos, sample_t* buffer);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/generator/Triangle.h b/extern/audaspace/include/generator/Triangle.h
new file mode 100644
index 00000000000..4f607fc23b5
--- /dev/null
+++ b/extern/audaspace/include/generator/Triangle.h
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file Triangle.h
+ * @ingroup generator
+ * The Triangle class.
+ */
+
+#include "ISound.h"
+#include "respec/Specification.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This sound creates a reader that plays a triangle tone.
+ */
+class AUD_API Triangle : public ISound
+{
+private:
+ /**
+ * The frequence of the triangle wave.
+ */
+ const float m_frequency;
+
+ /**
+ * The target sample rate for output.
+ */
+ const SampleRate m_sampleRate;
+
+ // delete copy constructor and operator=
+ Triangle(const Triangle&) = delete;
+ Triangle& operator=(const Triangle&) = delete;
+
+public:
+ /**
+ * Creates a new triangle sound.
+ * \param frequency The desired frequency.
+ * \param sampleRate The target sample rate for playback.
+ */
+ Triangle(float frequency,
+ SampleRate sampleRate = RATE_48000);
+
+ /**
+ * Returns the frequency of the triangle wave.
+ */
+ float getFrequency() const;
+
+ virtual std::shared_ptr<IReader> createReader();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/generator/TriangleReader.h b/extern/audaspace/include/generator/TriangleReader.h
new file mode 100644
index 00000000000..15079404b75
--- /dev/null
+++ b/extern/audaspace/include/generator/TriangleReader.h
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file TriangleReader.h
+ * @ingroup generator
+ * The TriangleReader class.
+ */
+
+#include "IReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This class is used for sawtooth tone playback.
+ * The output format is in the 16 bit format and stereo, the sample rate can be
+ * specified.
+ * As the two channels both play the same the output could also be mono, but
+ * in most cases this will result in having to resample for output, so stereo
+ * sound is created directly.
+ */
+class AUD_API TriangleReader : public IReader
+{
+private:
+ /**
+ * The frequency of the sine wave.
+ */
+ float m_frequency;
+
+ /**
+ * The current position in samples.
+ */
+ int m_position;
+
+ /**
+ * The value of the current sample.
+ */
+ float m_sample;
+
+ /**
+ * The sample rate for the output.
+ */
+ const SampleRate m_sampleRate;
+
+ // delete copy constructor and operator=
+ TriangleReader(const TriangleReader&) = delete;
+ TriangleReader& operator=(const TriangleReader&) = delete;
+
+public:
+ /**
+ * Creates a new reader.
+ * \param frequency The frequency of the sine wave.
+ * \param sampleRate The output sample rate.
+ */
+ TriangleReader(float frequency, SampleRate sampleRate);
+
+ /**
+ * Sets the frequency of the wave.
+ * @param frequency The new frequency in Hertz.
+ */
+ void setFrequency(float frequency);
+
+ virtual bool isSeekable() const;
+ virtual void seek(int position);
+ virtual int getLength() const;
+ virtual int getPosition() const;
+ virtual Specs getSpecs() const;
+ virtual void read(int & length, bool &eos, sample_t* buffer);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/plugin/PluginManager.h b/extern/audaspace/include/plugin/PluginManager.h
new file mode 100644
index 00000000000..af2f469c4ea
--- /dev/null
+++ b/extern/audaspace/include/plugin/PluginManager.h
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file PluginManager.h
+ * @ingroup plugin
+ * The PluginManager class.
+ */
+
+#include "Audaspace.h"
+
+#include <unordered_map>
+#include <string>
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This manager provides utilities for plugin loading.
+ */
+class AUD_API PluginManager
+{
+private:
+ static std::unordered_map<std::string, void*> m_plugins;
+
+ // delete copy constructor and operator=
+ PluginManager(const PluginManager&) = delete;
+ PluginManager& operator=(const PluginManager&) = delete;
+ PluginManager() = delete;
+
+public:
+ /**
+ * Opens a shared library.
+ * @param path The path to the file.
+ * @return A handle to the library or nullptr if opening failed.
+ */
+ static void* openLibrary(const std::string& path);
+
+ /**
+ * Looks up a symbol from an opened library.
+ * @param handle The handle to the opened library.
+ * @param name The name of the symbol to look up.
+ * @return The symbol or nullptr if the symbol was not found.
+ */
+ static void* lookupLibrary(void* handle, const std::string& name);
+
+ /**
+ * Closes an opened shared library.
+ * @param handle The handle to the library to be closed.
+ */
+ static void closeLibrary(void* handle);
+
+ /**
+ * Loads a plugin from a file.
+ * @param path The path to the file.
+ * @return Whether the file could successfully be loaded.
+ */
+ static bool loadPlugin(const std::string& path);
+
+ /**
+ * Loads all plugins found in a folder.
+ * @param path The path to the folder containing the plugins.
+ */
+ static void loadPlugins(const std::string& path = "");
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/respec/ChannelMapper.h b/extern/audaspace/include/respec/ChannelMapper.h
new file mode 100644
index 00000000000..5481a42c433
--- /dev/null
+++ b/extern/audaspace/include/respec/ChannelMapper.h
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file ChannelMapper.h
+ * @ingroup respec
+ * The ChannelMapper class.
+ */
+
+#include "respec/SpecsChanger.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This sound creates a reader that maps a sound source's channels to a
+ * specific output channel count.
+ */
+class AUD_API ChannelMapper : public SpecsChanger
+{
+private:
+ // delete copy constructor and operator=
+ ChannelMapper(const ChannelMapper&) = delete;
+ ChannelMapper& operator=(const ChannelMapper&) = delete;
+
+public:
+ /**
+ * Creates a new sound.
+ * \param sound The input sound.
+ * \param specs The target specifications.
+ */
+ ChannelMapper(std::shared_ptr<ISound> sound, DeviceSpecs specs);
+
+ virtual std::shared_ptr<IReader> createReader();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/respec/ChannelMapperReader.h b/extern/audaspace/include/respec/ChannelMapperReader.h
new file mode 100644
index 00000000000..00739ee995f
--- /dev/null
+++ b/extern/audaspace/include/respec/ChannelMapperReader.h
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file ChannelMapperReader.h
+ * @ingroup respec
+ * The ChannelMapperReader class.
+ */
+
+#include "fx/EffectReader.h"
+#include "util/Buffer.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This class maps a sound source's channels to a specific output channel count.
+ * \note The input sample format must be float.
+ */
+class AUD_API ChannelMapperReader : public EffectReader
+{
+private:
+ /**
+ * The sound reading buffer.
+ */
+ Buffer m_buffer;
+
+ /**
+ * The output specification.
+ */
+ Channels m_target_channels;
+
+ /**
+ * The channel count of the reader.
+ */
+ Channels m_source_channels;
+
+ /**
+ * The mapping specification.
+ */
+ float* m_mapping;
+
+ /**
+ * The size of the mapping.
+ */
+ int m_map_size;
+
+ /**
+ * The mono source angle.
+ */
+ float m_mono_angle;
+
+ static const Channel MONO_MAP[];
+ static const Channel STEREO_MAP[];
+ static const Channel STEREO_LFE_MAP[];
+ static const Channel SURROUND4_MAP[];
+ static const Channel SURROUND5_MAP[];
+ static const Channel SURROUND51_MAP[];
+ static const Channel SURROUND61_MAP[];
+ static const Channel SURROUND71_MAP[];
+ static const Channel* CHANNEL_MAPS[];
+
+ static const float MONO_ANGLES[];
+ static const float STEREO_ANGLES[];
+ static const float STEREO_LFE_ANGLES[];
+ static const float SURROUND4_ANGLES[];
+ static const float SURROUND5_ANGLES[];
+ static const float SURROUND51_ANGLES[];
+ static const float SURROUND61_ANGLES[];
+ static const float SURROUND71_ANGLES[];
+ static const float* CHANNEL_ANGLES[];
+
+ // delete copy constructor and operator=
+ ChannelMapperReader(const ChannelMapperReader&) = delete;
+ ChannelMapperReader& operator=(const ChannelMapperReader&) = delete;
+
+ /**
+ * Calculates the mapping matrix.
+ */
+ void AUD_LOCAL calculateMapping();
+
+ /**
+ * Calculates the distance between two angles.
+ */
+ float AUD_LOCAL angleDistance(float alpha, float beta);
+
+public:
+ /**
+ * Creates a channel mapper reader.
+ * \param reader The reader to map.
+ * \param channels The target channel count this reader should map to.
+ */
+ ChannelMapperReader(std::shared_ptr<IReader> reader, Channels channels);
+
+ /**
+ * Destroys the reader.
+ */
+ ~ChannelMapperReader();
+
+ /**
+ * Returns the channel configuration of the source reader.
+ * @return The channel configuration of the reader.
+ */
+ Channels getSourceChannels() const;
+
+ /**
+ * Returns the target channel configuration.
+ * Equals getSpecs().channels.
+ * @return The target channel configuration.
+ */
+ Channels getChannels() const;
+
+ /**
+ * Sets the requested channel output count.
+ * \param channels The channel output count.
+ */
+ void setChannels(Channels channels);
+
+ /**
+ * Returns the mapping of the source channel to the target channel.
+ * @param source The number of the source channel. Should be in the range [0, source channels).
+ * @param target The number of the target channel. Should be in the range [0, target channels).
+ * @return The mapping value which should be between 0.0 and 1.0. If source or target are out of range, NaN is returned.
+ */
+ float getMapping(int source, int target);
+
+ /**
+ * Sets the angle for mono sources.
+ * \param angle The angle for mono sources.
+ */
+ void setMonoAngle(float angle);
+
+ virtual Specs getSpecs() const;
+ virtual void read(int& length, bool& eos, sample_t* buffer);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/respec/Converter.h b/extern/audaspace/include/respec/Converter.h
new file mode 100644
index 00000000000..35664b28025
--- /dev/null
+++ b/extern/audaspace/include/respec/Converter.h
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file Converter.h
+ * @ingroup respec
+ * The Converter class.
+ */
+
+#include "respec/SpecsChanger.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This sound creates a converter reader that is able to convert from one
+ * audio format to another.
+ */
+class AUD_API Converter : public SpecsChanger
+{
+private:
+ // delete copy constructor and operator=
+ Converter(const Converter&) = delete;
+ Converter& operator=(const Converter&) = delete;
+
+public:
+ /**
+ * Creates a new sound.
+ * \param sound The input sound.
+ * \param specs The target specifications.
+ */
+ Converter(std::shared_ptr<ISound> sound, DeviceSpecs specs);
+
+ virtual std::shared_ptr<IReader> createReader();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/respec/ConverterFunctions.h b/extern/audaspace/include/respec/ConverterFunctions.h
new file mode 100644
index 00000000000..3cc4a713cc9
--- /dev/null
+++ b/extern/audaspace/include/respec/ConverterFunctions.h
@@ -0,0 +1,377 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file ConverterFunctions.h
+ * @ingroup respec
+ * Defines several conversion functions between different sample formats.
+ */
+
+#include "Audaspace.h"
+
+#include <cstring>
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * The function template for functions converting from one sample format
+ * to another, having the same parameter order as std::memcpy.
+ */
+typedef void (*convert_f)(data_t* target, data_t* source, int length);
+
+/**
+ * The copy conversion function simply calls std::memcpy.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+template <class T>
+void convert_copy(data_t* target, data_t* source, int length)
+{
+ std::memcpy(target, source, length*sizeof(T));
+}
+
+/**
+ * @brief Converts from FORMAT_U8 to FORMAT_S16.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_u8_s16(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_U8 to FORMAT_S24 big endian.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_u8_s24_be(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_U8 to FORMAT_S24 little endian.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_u8_s24_le(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_U8 to FORMAT_S32.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_u8_s32(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_U8 to FORMAT_FLOAT32.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_u8_float(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_U8 to FORMAT_FLOAT64.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_u8_double(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_S16 to FORMAT_U8.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_s16_u8(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_S16 to FORMAT_S24 big endian.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_s16_s24_be(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_S16 to FORMAT_S24 little endian.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_s16_s24_le(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_S16 to FORMAT_S32.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_s16_s32(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_S16 to FORMAT_FLOAT32.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_s16_float(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_S16 to FORMAT_FLOAT64.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_s16_double(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_S24 big endian to FORMAT_U8.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_s24_u8_be(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_S24 little endian to FORMAT_U8.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_s24_u8_le(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_S24 big endian to FORMAT_S16.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_s24_s16_be(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_S24 little endian to FORMAT_S16.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_s24_s16_le(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_S24 to FORMAT_S24 simply using std::memcpy.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_s24_s24(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_S24 big endian to FORMAT_S32.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_s24_s32_be(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_S24 little endian to FORMAT_S32.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_s24_s32_le(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_S24 big endian to FORMAT_FLOAT32.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_s24_float_be(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_S24 little endian to FORMAT_FLOAT32.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_s24_float_le(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_S24 big endian to FORMAT_FLOAT64.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_s24_double_be(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_S24 little endian to FORMAT_FLOAT64.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_s24_double_le(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_S32 to FORMAT_U8.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_s32_u8(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_S32 to FORMAT_S16.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_s32_s16(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_S32 to FORMAT_S24 big endian.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_s32_s24_be(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_S32 to FORMAT_S24 little endian.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_s32_s24_le(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_S32 to FORMAT_FLOAT32.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_s32_float(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_S32 to FORMAT_FLOAT64.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_s32_double(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_FLOAT32 to FORMAT_U8.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_float_u8(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_FLOAT32 to FORMAT_S16.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_float_s16(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_FLOAT32 to FORMAT_S24 big endian.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_float_s24_be(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_FLOAT32 to FORMAT_S24 little endian.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_float_s24_le(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_FLOAT32 to FORMAT_S32.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_float_s32(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_FLOAT32 to FORMAT_FLOAT64.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_float_double(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_FLOAT64 to FORMAT_U8.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_double_u8(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_FLOAT64 to FORMAT_S16.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_double_s16(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_FLOAT64 to FORMAT_S24 big endian.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_double_s24_be(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_FLOAT64 to FORMAT_S24 little endian.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_double_s24_le(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_FLOAT64 to FORMAT_S32.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_double_s32(data_t* target, data_t* source, int length);
+
+/**
+ * @brief Converts from FORMAT_FLOAT64 to FORMAT_FLOAT32.
+ * @param target The target buffer.
+ * @param source The source buffer.
+ * @param length The amount of samples to be converted.
+ */
+void AUD_API convert_double_float(data_t* target, data_t* source, int length);
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/respec/ConverterReader.h b/extern/audaspace/include/respec/ConverterReader.h
new file mode 100644
index 00000000000..c5ff6ded9ad
--- /dev/null
+++ b/extern/audaspace/include/respec/ConverterReader.h
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file ConverterReader.h
+ * @ingroup respec
+ * The ConverterReader class.
+ */
+
+#include "fx/EffectReader.h"
+#include "respec/ConverterFunctions.h"
+#include "util/Buffer.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This class converts a sound source from one to another format.
+ */
+class AUD_API ConverterReader : public EffectReader
+{
+private:
+ /**
+ * The sound output buffer.
+ */
+ Buffer m_buffer;
+
+ /**
+ * The target specification.
+ */
+ SampleFormat m_format;
+
+ /**
+ * Converter function.
+ */
+ convert_f m_convert;
+
+ // delete copy constructor and operator=
+ ConverterReader(const ConverterReader&) = delete;
+ ConverterReader& operator=(const ConverterReader&) = delete;
+
+public:
+ /**
+ * Creates a converter reader.
+ * \param reader The reader to convert.
+ * \param specs The target specification.
+ */
+ ConverterReader(std::shared_ptr<IReader> reader, DeviceSpecs specs);
+
+ virtual void read(int& length, bool& eos, sample_t* buffer);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/respec/JOSResample.h b/extern/audaspace/include/respec/JOSResample.h
new file mode 100644
index 00000000000..b1f4d757c3c
--- /dev/null
+++ b/extern/audaspace/include/respec/JOSResample.h
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file JOSResample.h
+ * @ingroup respec
+ * The JOSResample class.
+ */
+
+#include "respec/SpecsChanger.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This sound creates a resampling reader that does Julius O. Smith's resampling algorithm.
+ */
+class AUD_API JOSResample : public SpecsChanger
+{
+private:
+ // delete copy constructor and operator=
+ JOSResample(const JOSResample&) = delete;
+ JOSResample& operator=(const JOSResample&) = delete;
+
+public:
+ /**
+ * Creates a new sound.
+ * \param sound The input sound.
+ * \param specs The target specifications.
+ */
+ JOSResample(std::shared_ptr<ISound> sound, DeviceSpecs specs);
+
+ virtual std::shared_ptr<IReader> createReader();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/respec/JOSResampleReader.h b/extern/audaspace/include/respec/JOSResampleReader.h
new file mode 100644
index 00000000000..e9dd3b4220b
--- /dev/null
+++ b/extern/audaspace/include/respec/JOSResampleReader.h
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file JOSResampleReader.h
+ * @ingroup respec
+ * The JOSResampleReader class.
+ */
+
+#include "respec/ResampleReader.h"
+#include "util/Buffer.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This resampling reader uses Julius O. Smith's resampling algorithm.
+ */
+class AUD_API JOSResampleReader : public ResampleReader
+{
+private:
+ typedef void (JOSResampleReader::*resample_f)(double target_factor, int length, sample_t* buffer);
+
+ /**
+ * The half filter length.
+ */
+ static const int m_len;
+
+ /**
+ * The sample step size for the filter.
+ */
+ static const int m_L;
+
+ /**
+ * The filter coefficients.
+ */
+ static const float m_coeff[];
+
+ /**
+ * The reader channels.
+ */
+ Channels m_channels;
+
+ /**
+ * The sample position in the cache.
+ */
+ unsigned int m_n;
+
+ /**
+ * The subsample position in the cache.
+ */
+ double m_P;
+
+ /**
+ * The input data buffer.
+ */
+ Buffer m_buffer;
+
+ /**
+ * Double buffer for the sums.
+ */
+ Buffer m_sums;
+
+ /**
+ * How many samples in the cache are valid.
+ */
+ int m_cache_valid;
+
+ /**
+ * Resample function.
+ */
+ resample_f m_resample;
+
+ /**
+ * Last resampling factor.
+ */
+ double m_last_factor;
+
+ // delete copy constructor and operator=
+ JOSResampleReader(const JOSResampleReader&) = delete;
+ JOSResampleReader& operator=(const JOSResampleReader&) = delete;
+
+ /**
+ * Resets the resampler to its initial state.
+ */
+ void AUD_LOCAL reset();
+
+ /**
+ * Updates the buffer to be as small as possible for the coming reading.
+ * \param size The size of samples to be read.
+ * \param factor The next resampling factor.
+ * \param samplesize The size of a sample.
+ */
+ void AUD_LOCAL updateBuffer(int size, double factor, int samplesize);
+
+ void AUD_LOCAL resample(double target_factor, int length, sample_t* buffer);
+ void AUD_LOCAL resample_mono(double target_factor, int length, sample_t* buffer);
+ void AUD_LOCAL resample_stereo(double target_factor, int length, sample_t* buffer);
+
+public:
+ /**
+ * Creates a resampling reader.
+ * \param reader The reader to mix.
+ * \param rate The target sampling rate.
+ */
+ JOSResampleReader(std::shared_ptr<IReader> reader, SampleRate rate);
+
+ virtual void seek(int position);
+ virtual int getLength() const;
+ virtual int getPosition() const;
+ virtual Specs getSpecs() const;
+ virtual void read(int& length, bool& eos, sample_t* buffer);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/respec/LinearResample.h b/extern/audaspace/include/respec/LinearResample.h
new file mode 100644
index 00000000000..207cf2a6548
--- /dev/null
+++ b/extern/audaspace/include/respec/LinearResample.h
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file LinearResample.h
+ * @ingroup respec
+ * The LinearResample class.
+ */
+
+#include "respec/SpecsChanger.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This sound creates a resampling reader that does simple linear resampling.
+ */
+class AUD_API LinearResample : public SpecsChanger
+{
+private:
+ // delete copy constructor and operator=
+ LinearResample(const LinearResample&) = delete;
+ LinearResample& operator=(const LinearResample&) = delete;
+
+public:
+ /**
+ * Creates a new sound.
+ * \param sound The input sound.
+ * \param specs The target specifications.
+ */
+ LinearResample(std::shared_ptr<ISound> sound, DeviceSpecs specs);
+
+ virtual std::shared_ptr<IReader> createReader();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/respec/LinearResampleReader.h b/extern/audaspace/include/respec/LinearResampleReader.h
new file mode 100644
index 00000000000..aaf95672e55
--- /dev/null
+++ b/extern/audaspace/include/respec/LinearResampleReader.h
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file LinearResampleReader.h
+ * @ingroup respec
+ * The LinearResampleReader class.
+ */
+
+#include "respec/ResampleReader.h"
+#include "util/Buffer.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This resampling reader does simple first-order hold resampling.
+ */
+class AUD_API LinearResampleReader : public ResampleReader
+{
+private:
+ /**
+ * The reader channels.
+ */
+ Channels m_channels;
+
+ /**
+ * The position in the cache.
+ */
+ float m_cache_pos;
+
+ /**
+ * The sound output buffer.
+ */
+ Buffer m_buffer;
+
+ /**
+ * The input caching buffer.
+ */
+ Buffer m_cache;
+
+ /**
+ * Whether the cache contains valid data.
+ */
+ bool m_cache_ok;
+
+ // delete copy constructor and operator=
+ LinearResampleReader(const LinearResampleReader&) = delete;
+ LinearResampleReader& operator=(const LinearResampleReader&) = delete;
+
+public:
+ /**
+ * Creates a resampling reader.
+ * \param reader The reader to mix.
+ * \param rate The target sampling rate.
+ */
+ LinearResampleReader(std::shared_ptr<IReader> reader, SampleRate rate);
+
+ virtual void seek(int position);
+ virtual int getLength() const;
+ virtual int getPosition() const;
+ virtual Specs getSpecs() const;
+ virtual void read(int& length, bool& eos, sample_t* buffer);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/respec/Mixer.h b/extern/audaspace/include/respec/Mixer.h
new file mode 100644
index 00000000000..600467826cd
--- /dev/null
+++ b/extern/audaspace/include/respec/Mixer.h
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file Mixer.h
+ * @ingroup respec
+ * The Mixer class.
+ */
+
+#include "respec/Specification.h"
+#include "respec/ConverterFunctions.h"
+#include "util/Buffer.h"
+
+#include <memory>
+
+AUD_NAMESPACE_BEGIN
+
+class IReader;
+
+/**
+ * This abstract class is able to mix audiosignals with same channel count
+ * and sample rate and convert it to a specific output format.
+ */
+class AUD_API Mixer
+{
+private:
+ // delete copy constructor and operator=
+ Mixer(const Mixer&) = delete;
+ Mixer& operator=(const Mixer&) = delete;
+
+protected:
+ /**
+ * The output specification.
+ */
+ DeviceSpecs m_specs;
+
+ /**
+ * The length of the mixing buffer.
+ */
+ int m_length;
+
+ /**
+ * The mixing buffer.
+ */
+ Buffer m_buffer;
+
+ /**
+ * Converter function.
+ */
+ convert_f m_convert;
+
+public:
+ /**
+ * Creates the mixer.
+ */
+ Mixer(DeviceSpecs specs);
+
+ /**
+ * Destroys the mixer.
+ */
+ virtual ~Mixer() {}
+
+ /**
+ * Returns the target specification for superposing.
+ * \return The target specification.
+ */
+ DeviceSpecs getSpecs() const;
+
+ /**
+ * Sets the target specification for superposing.
+ * \param specs The target specification.
+ */
+ void setSpecs(Specs specs);
+
+ /**
+ * Mixes a buffer.
+ * \param buffer The buffer to superpose.
+ * \param start The start sample of the buffer.
+ * \param length The length of the buffer in samples.
+ * \param volume The mixing volume. Must be a value between 0.0 and 1.0.
+ */
+ void mix(sample_t* buffer, int start, int length, float volume);
+
+ /**
+ * Mixes a buffer with linear volume interpolation.
+ * \param buffer The buffer to superpose.
+ * \param start The start sample of the buffer.
+ * \param length The length of the buffer in samples.
+ * \param volume_to The target mixing volume. Must be a value between 0.0 and 1.0.
+ * \param volume_from The start mixing volume. Must be a value between 0.0 and 1.0.
+ */
+ void mix(sample_t* buffer, int start, int length, float volume_to, float volume_from);
+
+ /**
+ * Writes the mixing buffer into an output buffer.
+ * \param buffer The target buffer for superposing.
+ * \param volume The mixing volume. Must be a value between 0.0 and 1.0.
+ */
+ void read(data_t* buffer, float volume);
+
+ /**
+ * Clears the mixing buffer.
+ * \param length The length of the buffer in samples.
+ */
+ void clear(int length);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/respec/ResampleReader.h b/extern/audaspace/include/respec/ResampleReader.h
new file mode 100644
index 00000000000..b38a8d5eb18
--- /dev/null
+++ b/extern/audaspace/include/respec/ResampleReader.h
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file ResampleReader.h
+ * @ingroup respec
+ * The ResampleReader class.
+ */
+
+#include "fx/EffectReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This is the base class for all resampling readers.
+ */
+class AUD_API ResampleReader : public EffectReader
+{
+protected:
+ /**
+ * The target sampling rate.
+ */
+ SampleRate m_rate;
+
+ /**
+ * Creates a resampling reader.
+ * \param reader The reader to mix.
+ * \param rate The target sampling rate.
+ */
+ ResampleReader(std::shared_ptr<IReader> reader, SampleRate rate);
+
+public:
+ /**
+ * Sets the sample rate.
+ * \param rate The target sampling rate.
+ */
+ virtual void setRate(SampleRate rate);
+
+ /**
+ * Retrieves the sample rate.
+ * \return The target sampling rate.
+ */
+ virtual SampleRate getRate();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/respec/Specification.h b/extern/audaspace/include/respec/Specification.h
new file mode 100644
index 00000000000..efcbb4cabce
--- /dev/null
+++ b/extern/audaspace/include/respec/Specification.h
@@ -0,0 +1,138 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file Specification.h
+ * @ingroup respec
+ * Defines all important macros and basic data structures for stream format descriptions.
+ */
+
+#include "Audaspace.h"
+
+/// The size of a format in bytes.
+#define AUD_FORMAT_SIZE(format) (format & 0x0F)
+/// The size of a sample in the specified device format in bytes.
+#define AUD_DEVICE_SAMPLE_SIZE(specs) (specs.channels * (specs.format & 0x0F))
+/// The size of a sample in the specified format in bytes.
+#define AUD_SAMPLE_SIZE(specs) (specs.channels * sizeof(sample_t))
+
+/// Compares two audio data specifications.
+#define AUD_COMPARE_SPECS(s1, s2) ((s1.rate == s2.rate) && (s1.channels == s2.channels))
+
+/// Returns the bit for a channel mask.
+#define AUD_CHANNEL_BIT(channel) (0x01 << channel)
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * The format of a sample.
+ * The last 4 bit save the byte count of the format.
+ */
+enum SampleFormat
+{
+ FORMAT_INVALID = 0x00, /// Invalid sample format.
+ FORMAT_U8 = 0x01, /// 1 byte unsigned byte.
+ FORMAT_S16 = 0x12, /// 2 byte signed integer.
+ FORMAT_S24 = 0x13, /// 3 byte signed integer.
+ FORMAT_S32 = 0x14, /// 4 byte signed integer.
+ FORMAT_FLOAT32 = 0x24, /// 4 byte float.
+ FORMAT_FLOAT64 = 0x28 /// 8 byte float.
+};
+
+/// The channel count.
+enum Channels
+{
+ CHANNELS_INVALID = 0, /// Invalid channel count.
+ CHANNELS_MONO = 1, /// Mono.
+ CHANNELS_STEREO = 2, /// Stereo.
+ CHANNELS_STEREO_LFE = 3, /// Stereo with LFE channel.
+ CHANNELS_SURROUND4 = 4, /// 4 channel surround sound.
+ CHANNELS_SURROUND5 = 5, /// 5 channel surround sound.
+ CHANNELS_SURROUND51 = 6, /// 5.1 surround sound.
+ CHANNELS_SURROUND61 = 7, /// 6.1 surround sound.
+ CHANNELS_SURROUND71 = 8 /// 7.1 surround sound.
+};
+
+/// The channel names.
+enum Channel
+{
+ CHANNEL_FRONT_LEFT = 0,
+ CHANNEL_FRONT_RIGHT,
+ CHANNEL_FRONT_CENTER,
+ CHANNEL_LFE,
+ CHANNEL_REAR_LEFT,
+ CHANNEL_REAR_RIGHT,
+ CHANNEL_REAR_CENTER,
+ CHANNEL_SIDE_LEFT,
+ CHANNEL_SIDE_RIGHT,
+ CHANNEL_MAX
+};
+
+/**
+ * The sample rate tells how many samples are played back within one second.
+ * Some exotic formats may use other sample rates than provided here.
+ */
+enum DefaultSampleRate
+{
+ RATE_INVALID = 0, /// Invalid sample rate.
+ RATE_8000 = 8000, /// 8000 Hz.
+ RATE_16000 = 16000, /// 16000 Hz.
+ RATE_11025 = 11025, /// 11025 Hz.
+ RATE_22050 = 22050, /// 22050 Hz.
+ RATE_32000 = 32000, /// 32000 Hz.
+ RATE_44100 = 44100, /// 44100 Hz.
+ RATE_48000 = 48000, /// 48000 Hz.
+ RATE_88200 = 88200, /// 88200 Hz.
+ RATE_96000 = 96000, /// 96000 Hz.
+ RATE_192000 = 192000 /// 192000 Hz.
+};
+
+/// Sample rate type.
+typedef double SampleRate;
+
+/// Specification of a sound source.
+struct Specs
+{
+ /// Sample rate in Hz.
+ SampleRate rate;
+
+ /// Channel count.
+ Channels channels;
+};
+
+/// Specification of a sound device.
+struct DeviceSpecs
+{
+ /// Sample format.
+ SampleFormat format;
+
+ union
+ {
+ struct
+ {
+ /// Sample rate in Hz.
+ SampleRate rate;
+
+ /// Channel count.
+ Channels channels;
+ };
+ Specs specs;
+ };
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/respec/SpecsChanger.h b/extern/audaspace/include/respec/SpecsChanger.h
new file mode 100644
index 00000000000..2eb9f369497
--- /dev/null
+++ b/extern/audaspace/include/respec/SpecsChanger.h
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file SpecsChanger.h
+ * @ingroup respec
+ * The SpecsChanger class.
+ */
+
+#include "ISound.h"
+#include "respec/Specification.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This sound is a base class for all mixer factories.
+ */
+class AUD_API SpecsChanger : public ISound
+{
+protected:
+ /**
+ * The target specification for resampling.
+ */
+ const DeviceSpecs m_specs;
+
+ /**
+ * If there is no reader it is created out of this sound.
+ */
+ std::shared_ptr<ISound> m_sound;
+
+ /**
+ * Returns the reader created out of the sound.
+ * This method can be used for the createReader function of the implementing
+ * classes.
+ * \return The reader to mix.
+ */
+ std::shared_ptr<IReader> getReader() const;
+
+public:
+ /**
+ * Creates a new sound.
+ * \param sound The sound to create the readers to mix out of.
+ * \param specs The target specification.
+ */
+ SpecsChanger(std::shared_ptr<ISound> sound, DeviceSpecs specs);
+
+ /**
+ * Returns the target specification for resampling.
+ */
+ DeviceSpecs getSpecs() const;
+
+ /**
+ * Returns the saved sound.
+ * \return The sound.
+ */
+ std::shared_ptr<ISound> getSound() const;
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/sequence/AnimateableProperty.h b/extern/audaspace/include/sequence/AnimateableProperty.h
new file mode 100644
index 00000000000..2c3fcf23f8b
--- /dev/null
+++ b/extern/audaspace/include/sequence/AnimateableProperty.h
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file AnimateableProperty.h
+ * @ingroup sequence
+ * Defines the AnimateableProperty class as well as existing property types.
+ */
+
+#include "util/Buffer.h"
+#include "util/ILockable.h"
+
+#include <mutex>
+#include <list>
+
+AUD_NAMESPACE_BEGIN
+
+/// Possible animatable properties for Sequencer Factories and Entries.
+enum AnimateablePropertyType
+{
+ AP_VOLUME,
+ AP_PANNING,
+ AP_PITCH,
+ AP_LOCATION,
+ AP_ORIENTATION
+};
+
+/**
+ * This class saves animation data for float properties.
+ */
+class AUD_API AnimateableProperty : private Buffer
+{
+private:
+ struct Unknown {
+ int start;
+ int end;
+
+ Unknown(int start, int end) :
+ start(start), end(end) {}
+ };
+
+ /// The count of floats for a single property.
+ const int m_count;
+
+ /// Whether the property is animated or not.
+ bool m_isAnimated;
+
+ /// The mutex for locking.
+ std::recursive_mutex m_mutex;
+
+ /// The list of unknown buffer areas.
+ std::list<Unknown> m_unknown;
+
+ // delete copy constructor and operator=
+ AnimateableProperty(const AnimateableProperty&) = delete;
+ AnimateableProperty& operator=(const AnimateableProperty&) = delete;
+
+ void AUD_LOCAL updateUnknownCache(int start, int end);
+
+public:
+ /**
+ * Creates a new animateable property.
+ * \param count The count of floats for a single property.
+ */
+ AnimateableProperty(int count = 1);
+
+ /**
+ * Creates a new animateable property.
+ * \param count The count of floats for a single property.
+ * \param value The value that the property should get initialized with.
+ * All count floats will be initialized to the same value.
+ */
+ AnimateableProperty(int count, float value);
+
+ /**
+ * Destroys the animateable property.
+ */
+ ~AnimateableProperty();
+
+ /**
+ * Returns the count of floats for a single property.
+ * \return The count of floats stored per frame.
+ */
+ int getCount() const;
+
+ /**
+ * Writes the properties value and marks it non-animated.
+ * \param data The new value.
+ */
+ void write(const float* data);
+
+ /**
+ * Writes the properties value and marks it animated.
+ * \param data The new value.
+ * \param position The position in the animation in frames.
+ * \param count The count of frames to write.
+ */
+ void write(const float* data, int position, int count);
+
+ /**
+ * Reads the properties value.
+ * \param position The position in the animation in frames.
+ * \param[out] out Where to write the value to.
+ */
+ void read(float position, float* out);
+
+ /**
+ * Returns whether the property is animated.
+ * \return Whether the property is animated.
+ */
+ bool isAnimated() const;
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/sequence/Double.h b/extern/audaspace/include/sequence/Double.h
new file mode 100644
index 00000000000..dc40ae29e0d
--- /dev/null
+++ b/extern/audaspace/include/sequence/Double.h
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file Double.h
+ * @ingroup sequence
+ * The Double class.
+ */
+
+#include "ISound.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This sound plays two other factories behind each other.
+ */
+class AUD_API Double : public ISound
+{
+private:
+ /**
+ * First played sound.
+ */
+ std::shared_ptr<ISound> m_sound1;
+
+ /**
+ * Second played sound.
+ */
+ std::shared_ptr<ISound> m_sound2;
+
+ // delete copy constructor and operator=
+ Double(const Double&) = delete;
+ Double& operator=(const Double&) = delete;
+
+public:
+ /**
+ * Creates a new double sound.
+ * \param sound1 The first input sound.
+ * \param sound2 The second input sound.
+ */
+ Double(std::shared_ptr<ISound> sound1, std::shared_ptr<ISound> sound2);
+
+ virtual std::shared_ptr<IReader> createReader();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/sequence/DoubleReader.h b/extern/audaspace/include/sequence/DoubleReader.h
new file mode 100644
index 00000000000..012dcc8e832
--- /dev/null
+++ b/extern/audaspace/include/sequence/DoubleReader.h
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file DoubleReader.h
+ * @ingroup sequence
+ * The DoubleReader class.
+ */
+
+#include "IReader.h"
+
+#include <memory>
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This reader plays two readers sequently.
+ */
+class AUD_API DoubleReader : public IReader
+{
+private:
+ /**
+ * The first reader.
+ */
+ std::shared_ptr<IReader> m_reader1;
+
+ /**
+ * The second reader.
+ */
+ std::shared_ptr<IReader> m_reader2;
+
+ /**
+ * Whether we've reached the end of the first reader.
+ */
+ bool m_finished1;
+
+ // delete copy constructor and operator=
+ DoubleReader(const DoubleReader&) = delete;
+ DoubleReader& operator=(const DoubleReader&) = delete;
+
+public:
+ /**
+ * Creates a new double reader.
+ * \param reader1 The first reader to read from.
+ * \param reader2 The second reader to read from.
+ */
+ DoubleReader(std::shared_ptr<IReader> reader1, std::shared_ptr<IReader> reader2);
+
+ /**
+ * Destroys the reader.
+ */
+ virtual ~DoubleReader();
+
+ virtual bool isSeekable() const;
+ virtual void seek(int position);
+ virtual int getLength() const;
+ virtual int getPosition() const;
+ virtual Specs getSpecs() const;
+ virtual void read(int& length, bool& eos, sample_t* buffer);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/sequence/PingPong.h b/extern/audaspace/include/sequence/PingPong.h
new file mode 100644
index 00000000000..8b1bf792095
--- /dev/null
+++ b/extern/audaspace/include/sequence/PingPong.h
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file PingPong.h
+ * @ingroup sequence
+ * The PingPong class.
+ */
+
+#include "fx/Effect.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This sound plays another sound first normal, then reversed.
+ * \note Readers from the underlying sound must be reversable with seeking.
+ */
+class AUD_API PingPong : public Effect
+{
+private:
+ // delete copy constructor and operator=
+ PingPong(const PingPong&) = delete;
+ PingPong& operator=(const PingPong&) = delete;
+
+public:
+ /**
+ * Creates a new ping pong sound.
+ * \param sound The input sound.
+ */
+ PingPong(std::shared_ptr<ISound> sound);
+
+ virtual std::shared_ptr<IReader> createReader();
+};
+
+AUD_NAMESPACE_END
diff --git a/intern/audaspace/intern/AUD_SequencerFactory.h b/extern/audaspace/include/sequence/Sequence.h
index 3ef847d4b34..7005171e2c8 100644
--- a/intern/audaspace/intern/AUD_SequencerFactory.h
+++ b/extern/audaspace/include/sequence/Sequence.h
@@ -1,58 +1,52 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
*
- * Copyright 2009-2011 Jörg Hermann Müller
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * This file is part of AudaSpace.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * 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_SequencerFactory.h
- * \ingroup audaspaceintern
- */
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+#pragma once
-#ifndef __AUD_SEQUENCERFACTORY_H__
-#define __AUD_SEQUENCERFACTORY_H__
+/**
+ * @file Sequence.h
+ * @ingroup sequence
+ * The Sequence class.
+ */
-#include "AUD_IFactory.h"
-#include "AUD_AnimateableProperty.h"
-//#include "AUD_ILockable.h"
-#include "AUD_Sequencer.h"
+#include "ISound.h"
+#include "respec/Specification.h"
+#include "devices/I3DDevice.h"
+#include "sequence/AnimateableProperty.h"
#include <list>
-#include <pthread.h>
-class AUD_SequencerEntry;
+AUD_NAMESPACE_BEGIN
+
+class SequenceEntry;
+class SequenceData;
/**
- * This factory represents sequenced entries to play a sound scene.
+ * This sound represents sequenced entries to play a sound scene.
*/
-class AUD_SequencerFactory : public AUD_IFactory//, public AUD_ILockable
+class AUD_API Sequence : public ISound
{
- friend class AUD_SequencerReader;
+ friend class SequenceReader;
private:
/// The sequence.
- boost::shared_ptr<AUD_Sequencer> m_sequence;
+ std::shared_ptr<SequenceData> m_sequence;
- // hide copy constructor and operator=
- AUD_SequencerFactory(const AUD_SequencerFactory&);
- AUD_SequencerFactory& operator=(const AUD_SequencerFactory&);
+ // delete copy constructor and operator=
+ Sequence(const Sequence&) = delete;
+ Sequence& operator=(const Sequence&) = delete;
public:
/**
@@ -61,25 +55,25 @@ public:
* \param fps The FPS of the scene.
* \param muted Whether the whole scene is muted.
*/
- AUD_SequencerFactory(AUD_Specs specs, float fps, bool muted);
+ Sequence(Specs specs, float fps, bool muted);
-#if 0
/**
- * Locks the factory.
+ * Retrieves the audio output specification.
+ * \return The specification.
*/
- virtual void lock();
+ Specs getSpecs();
/**
- * Unlocks the previously locked factory.
+ * Sets the audio output specification.
+ * \param specs The new specification.
*/
- virtual void unlock();
-#endif
+ void setSpecs(Specs specs);
/**
- * Sets the audio output specification.
- * \param specs The new specification.
+ * Retrieves the scene's FPS.
+ * \return The scene's FPS.
*/
- void setSpecs(AUD_Specs specs);
+ float getFPS() const;
/**
* Sets the scene's FPS.
@@ -97,7 +91,7 @@ public:
* Retrieves the muting state of the scene.
* \return Whether the scene is muted.
*/
- bool getMute() const;
+ bool isMuted() const;
/**
* Retrieves the speed of sound.
@@ -133,21 +127,21 @@ public:
* Retrieves the distance model.
* \return The distance model.
*/
- AUD_DistanceModel getDistanceModel() const;
+ DistanceModel getDistanceModel() const;
/**
* Sets the distance model.
* \param model distance model.
*/
- void setDistanceModel(AUD_DistanceModel model);
+ void setDistanceModel(DistanceModel model);
/**
- * Retrieves one of the animated properties of the factory.
+ * Retrieves one of the animated properties of the sound.
* \param type Which animated property to retrieve.
* \return A pointer to the animated property, valid as long as the
- * factory is.
+ * sound is.
*/
- AUD_AnimateableProperty* getAnimProperty(AUD_AnimateablePropertyType type);
+ AnimateableProperty* getAnimProperty(AnimateablePropertyType type);
/**
* Adds a new entry to the scene.
@@ -157,21 +151,21 @@ public:
* \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);
+ std::shared_ptr<SequenceEntry> add(std::shared_ptr<ISound> 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);
+ void remove(std::shared_ptr<SequenceEntry> entry);
/**
* Creates a new reader with high quality resampling.
* \return The new reader.
*/
- boost::shared_ptr<AUD_IReader> createQualityReader();
+ std::shared_ptr<IReader> createQualityReader();
- virtual boost::shared_ptr<AUD_IReader> createReader();
+ virtual std::shared_ptr<IReader> createReader();
};
-#endif //__AUD_SEQUENCERFACTORY_H__
+AUD_NAMESPACE_END
diff --git a/intern/audaspace/intern/AUD_Sequencer.h b/extern/audaspace/include/sequence/SequenceData.h
index 1066eeae8e3..b3df0548a4d 100644
--- a/intern/audaspace/intern/AUD_Sequencer.h
+++ b/extern/audaspace/include/sequence/SequenceData.h
@@ -1,53 +1,50 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
*
- * Copyright 2009-2011 Jörg Hermann Müller
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * This file is part of AudaSpace.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * 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
- */
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+#pragma once
-#ifndef __AUD_SEQUENCER_H__
-#define __AUD_SEQUENCER_H__
+/**
+ * @file SequenceData.h
+ * @ingroup sequence
+ * The SequenceData class.
+ */
-#include "AUD_AnimateableProperty.h"
-#include "AUD_IFactory.h"
-#include "AUD_ILockable.h"
+#include "respec/Specification.h"
+#include "sequence/AnimateableProperty.h"
+#include "devices/I3DDevice.h"
+#include "util/ILockable.h"
#include <list>
-#include <pthread.h>
+#include <memory>
+#include <mutex>
-class AUD_SequencerEntry;
+AUD_NAMESPACE_BEGIN
+
+class SequenceEntry;
+class ISound;
/**
* This class represents sequenced entries to play a sound scene.
*/
-class AUD_Sequencer : public AUD_ILockable
+class AUD_API SequenceData : public ILockable
{
- friend class AUD_SequencerReader;
+ friend class SequenceReader;
private:
/// The target specification.
- AUD_Specs m_specs;
+ Specs m_specs;
/// The status of the sequence. Changes every time a non-animated parameter changes.
int m_status;
@@ -59,7 +56,7 @@ private:
int m_id;
/// The sequenced entries.
- std::list<boost::shared_ptr<AUD_SequencerEntry> > m_entries;
+ std::list<std::shared_ptr<SequenceEntry> > m_entries;
/// Whether the whole scene is muted.
bool m_muted;
@@ -74,23 +71,23 @@ private:
float m_doppler_factor;
/// Distance model.
- AUD_DistanceModel m_distance_model;
+ DistanceModel m_distance_model;
/// The animated volume.
- AUD_AnimateableProperty m_volume;
+ AnimateableProperty m_volume;
/// The animated listener location.
- AUD_AnimateableProperty m_location;
+ AnimateableProperty m_location;
/// The animated listener orientation.
- AUD_AnimateableProperty m_orientation;
+ AnimateableProperty m_orientation;
/// The mutex for locking.
- pthread_mutex_t m_mutex;
+ std::recursive_mutex m_mutex;
- // hide copy constructor and operator=
- AUD_Sequencer(const AUD_Sequencer&);
- AUD_Sequencer& operator=(const AUD_Sequencer&);
+ // delete copy constructor and operator=
+ SequenceData(const SequenceData&) = delete;
+ SequenceData& operator=(const SequenceData&) = delete;
public:
/**
@@ -99,8 +96,8 @@ public:
* \param fps The FPS of the scene.
* \param muted Whether the whole scene is muted.
*/
- AUD_Sequencer(AUD_Specs specs, float fps, bool muted);
- virtual ~AUD_Sequencer();
+ SequenceData(Specs specs, float fps, bool muted);
+ virtual ~SequenceData();
/**
* Locks the sequence.
@@ -113,10 +110,22 @@ public:
virtual void unlock();
/**
+ * Retrieves the audio output specification.
+ * \return The specification.
+ */
+ Specs getSpecs();
+
+ /**
* Sets the audio output specification.
* \param specs The new specification.
*/
- void setSpecs(AUD_Specs specs);
+ void setSpecs(Specs specs);
+
+ /**
+ * Retrieves the scene's FPS.
+ * \return The scene's FPS.
+ */
+ float getFPS() const;
/**
* Sets the scene's FPS.
@@ -134,7 +143,7 @@ public:
* Retrieves the muting state of the scene.
* \return Whether the scene is muted.
*/
- bool getMute() const;
+ bool isMuted() const;
/**
* Retrieves the speed of sound.
@@ -170,13 +179,13 @@ public:
* Retrieves the distance model.
* \return The distance model.
*/
- AUD_DistanceModel getDistanceModel() const;
+ DistanceModel getDistanceModel() const;
/**
* Sets the distance model.
* \param model distance model.
*/
- void setDistanceModel(AUD_DistanceModel model);
+ void setDistanceModel(DistanceModel model);
/**
* Retrieves one of the animated properties of the sequence.
@@ -184,7 +193,7 @@ public:
* \return A pointer to the animated property, valid as long as the
* sequence is.
*/
- AUD_AnimateableProperty* getAnimProperty(AUD_AnimateablePropertyType type);
+ AnimateableProperty* getAnimProperty(AnimateablePropertyType type);
/**
* Adds a new entry to the scene.
@@ -194,13 +203,13 @@ public:
* \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);
+ std::shared_ptr<SequenceEntry> add(std::shared_ptr<ISound> 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);
+ void remove(std::shared_ptr<SequenceEntry> entry);
};
-#endif //__AUD_SEQUENCER_H__
+AUD_NAMESPACE_END
diff --git a/intern/audaspace/intern/AUD_SequencerEntry.h b/extern/audaspace/include/sequence/SequenceEntry.h
index aa1edebfc2f..98f15faf7ff 100644
--- a/intern/audaspace/intern/AUD_SequencerEntry.h
+++ b/extern/audaspace/include/sequence/SequenceEntry.h
@@ -1,48 +1,43 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
*
- * Copyright 2009-2011 Jörg Hermann Müller
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * This file is part of AudaSpace.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * 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 *****
- */
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
-/** \file audaspace/intern/AUD_SequencerEntry.h
- * \ingroup audaspaceintern
+#pragma once
+
+/**
+ * @file SequenceEntry.h
+ * @ingroup sequence
+ * The SequenceEntry class.
*/
+#include "sequence/AnimateableProperty.h"
+#include "util/ILockable.h"
-#ifndef __AUD_SEQUENCERENTRY_H__
-#define __AUD_SEQUENCERENTRY_H__
+#include <mutex>
+#include <memory>
-#include "AUD_AnimateableProperty.h"
-#include "AUD_IFactory.h"
-#include "AUD_ILockable.h"
+AUD_NAMESPACE_BEGIN
-#include <pthread.h>
-#include <boost/shared_ptr.hpp>
+class ISound;
/**
- * This class represents a sequenced entry in a sequencer factory.
+ * This class represents a sequenced entry in a sequencer sound.
*/
-class AUD_SequencerEntry : public AUD_ILockable
+class AUD_API SequenceEntry : public ILockable
{
- friend class AUD_SequencerHandle;
+ friend class SequenceHandle;
private:
/// The status of the entry. Changes every time a non-animated parameter changes.
int m_status;
@@ -53,11 +48,11 @@ private:
/// The sound status, changed when the sound is changed.
int m_sound_status;
- /// The unique (regarding the factory) ID of the entry.
+ /// The unique (regarding the sound) ID of the entry.
int m_id;
/// The sound this entry plays.
- boost::shared_ptr<AUD_IFactory> m_sound;
+ std::shared_ptr<ISound> m_sound;
/// The begin time.
float m_begin;
@@ -99,22 +94,26 @@ private:
float m_cone_volume_outer;
/// The mutex for locking.
- pthread_mutex_t m_mutex;
+ std::recursive_mutex m_mutex;
/// The animated volume.
- AUD_AnimateableProperty m_volume;
+ AnimateableProperty m_volume;
/// The animated panning.
- AUD_AnimateableProperty m_panning;
+ AnimateableProperty m_panning;
/// The animated pitch.
- AUD_AnimateableProperty m_pitch;
+ AnimateableProperty m_pitch;
/// The animated location.
- AUD_AnimateableProperty m_location;
+ AnimateableProperty m_location;
/// The animated orientation.
- AUD_AnimateableProperty m_orientation;
+ AnimateableProperty m_orientation;
+
+ // delete copy constructor and operator=
+ SequenceEntry(const SequenceEntry&) = delete;
+ SequenceEntry& operator=(const SequenceEntry&) = delete;
public:
/**
@@ -125,8 +124,8 @@ public:
* \param skip How much seconds should be skipped at the beginning.
* \param id The ID of the entry.
*/
- AUD_SequencerEntry(boost::shared_ptr<AUD_IFactory> sound, float begin, float end, float skip, int id);
- virtual ~AUD_SequencerEntry();
+ SequenceEntry(std::shared_ptr<ISound> sound, float begin, float end, float skip, int id);
+ virtual ~SequenceEntry();
/**
* Locks the entry.
@@ -139,10 +138,16 @@ public:
virtual void unlock();
/**
+ * Retrieves the sound of the entry.
+ * \return The sound.
+ */
+ std::shared_ptr<ISound> getSound();
+
+ /**
* Sets the sound of the entry.
* \param sound The new sound.
*/
- void setSound(boost::shared_ptr<AUD_IFactory> sound);
+ void setSound(std::shared_ptr<ISound> sound);
/**
* Moves the entry.
@@ -153,6 +158,12 @@ public:
void move(float begin, float end, float skip);
/**
+ * Retrieves the muting state of the entry.
+ * \return Whether the entry should is muted or not.
+ */
+ bool isMuted();
+
+ /**
* Sets the muting state of the entry.
* \param mute Whether the entry should be muted or not.
*/
@@ -170,22 +181,7 @@ public:
* \return A pointer to the animated property, valid as long as the
* entry is.
*/
- AUD_AnimateableProperty* getAnimProperty(AUD_AnimateablePropertyType type);
-
- /**
- * Updates all non-animated parameters of the entry.
- * \param volume_max The maximum volume.
- * \param volume_min The minimum volume.
- * \param distance_max The maximum distance.
- * \param distance_reference The reference distance.
- * \param attenuation The attenuation.
- * \param cone_angle_outer The outer cone opening angle.
- * \param cone_angle_inner The inner cone opening angle.
- * \param cone_volume_outer The volume outside the outer cone.
- */
- void updateAll(float volume_max, float volume_min, float distance_max,
- float distance_reference, float attenuation, float cone_angle_outer,
- float cone_angle_inner, float cone_volume_outer);
+ AnimateableProperty* getAnimProperty(AnimateablePropertyType type);
/**
* Checks whether the source location, velocity and orientation are relative
@@ -316,4 +312,4 @@ public:
void setConeVolumeOuter(float volume);
};
-#endif //__AUD_SEQUENCERENTRY_H__
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/sequence/SequenceReader.h b/extern/audaspace/include/sequence/SequenceReader.h
new file mode 100644
index 00000000000..196d969e102
--- /dev/null
+++ b/extern/audaspace/include/sequence/SequenceReader.h
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file SequenceReader.h
+ * @ingroup sequence
+ * The SequenceReader class.
+ */
+
+#include "IReader.h"
+#include "devices/ReadDevice.h"
+
+AUD_NAMESPACE_BEGIN
+
+class SequenceHandle;
+class SequenceData;
+
+/**
+ * This reader plays back sequenced entries.
+ */
+class AUD_API SequenceReader : public IReader
+{
+private:
+ /**
+ * The current position.
+ */
+ int m_position;
+
+ /**
+ * The read device used to mix the sounds correctly.
+ */
+ ReadDevice m_device;
+
+ /**
+ * Saves the sequence the reader belongs to.
+ */
+ std::shared_ptr<SequenceData> m_sequence;
+
+ /**
+ * The list of playback handles for the entries.
+ */
+ std::list<std::shared_ptr<SequenceHandle> > m_handles;
+
+ /**
+ * Last status read from the sequence.
+ */
+ int m_status;
+
+ /**
+ * Last entry status read from the sequence.
+ */
+ int m_entry_status;
+
+ // delete copy constructor and operator=
+ SequenceReader(const SequenceReader&) = delete;
+ SequenceReader& operator=(const SequenceReader&) = delete;
+
+public:
+ /**
+ * Creates a resampling reader.
+ * \param sequence The sequence data.
+ * \param quality Whether a high quality resample should be used for resampling.
+ */
+ SequenceReader(std::shared_ptr<SequenceData> sequence, bool quality = false);
+
+ /**
+ * Destroys the reader.
+ */
+ ~SequenceReader();
+
+ virtual bool isSeekable() const;
+ virtual void seek(int position);
+ virtual int getLength() const;
+ virtual int getPosition() const;
+ virtual Specs getSpecs() const;
+ virtual void read(int& length, bool& eos, sample_t* buffer);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/sequence/Superpose.h b/extern/audaspace/include/sequence/Superpose.h
new file mode 100644
index 00000000000..2a3a6166b3b
--- /dev/null
+++ b/extern/audaspace/include/sequence/Superpose.h
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file Superpose.h
+ * @ingroup sequence
+ * The Superpose class.
+ */
+
+#include "ISound.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This sound mixes two other factories, playing them the same time.
+ * \note Readers from the underlying factories must have the same sample rate
+ * and channel count.
+ */
+class AUD_API Superpose : public ISound
+{
+private:
+ /**
+ * First played sound.
+ */
+ std::shared_ptr<ISound> m_sound1;
+
+ /**
+ * Second played sound.
+ */
+ std::shared_ptr<ISound> m_sound2;
+
+ // delete copy constructor and operator=
+ Superpose(const Superpose&) = delete;
+ Superpose& operator=(const Superpose&) = delete;
+
+public:
+ /**
+ * Creates a new superpose sound.
+ * \param sound1 The first input sound.
+ * \param sound2 The second input sound.
+ */
+ Superpose(std::shared_ptr<ISound> sound1, std::shared_ptr<ISound> sound2);
+
+ virtual std::shared_ptr<IReader> createReader();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/sequence/SuperposeReader.h b/extern/audaspace/include/sequence/SuperposeReader.h
new file mode 100644
index 00000000000..8bd38ade4c3
--- /dev/null
+++ b/extern/audaspace/include/sequence/SuperposeReader.h
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file SuperposeReader.h
+ * @ingroup sequence
+ * The SuperposeReader class.
+ */
+
+#include "IReader.h"
+#include "util/Buffer.h"
+
+#include <memory>
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This reader plays two readers with the same specs in parallel.
+ */
+class AUD_API SuperposeReader : public IReader
+{
+private:
+ /**
+ * The first reader.
+ */
+ std::shared_ptr<IReader> m_reader1;
+
+ /**
+ * The second reader.
+ */
+ std::shared_ptr<IReader> m_reader2;
+
+ /**
+ * Buffer used for mixing.
+ */
+ Buffer m_buffer;
+
+ // delete copy constructor and operator=
+ SuperposeReader(const SuperposeReader&) = delete;
+ SuperposeReader& operator=(const SuperposeReader&) = delete;
+
+public:
+ /**
+ * Creates a new superpose reader.
+ * \param reader1 The first reader to read from.
+ * \param reader2 The second reader to read from.
+ * \exception Exception Thrown if the specs from the readers differ.
+ */
+ SuperposeReader(std::shared_ptr<IReader> reader1, std::shared_ptr<IReader> reader2);
+
+ /**
+ * Destroys the reader.
+ */
+ virtual ~SuperposeReader();
+
+ virtual bool isSeekable() const;
+ virtual void seek(int position);
+ virtual int getLength() const;
+ virtual int getPosition() const;
+ virtual Specs getSpecs() const;
+ virtual void read(int& length, bool& eos, sample_t* buffer);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/util/Barrier.h b/extern/audaspace/include/util/Barrier.h
new file mode 100644
index 00000000000..d9e8bf07f82
--- /dev/null
+++ b/extern/audaspace/include/util/Barrier.h
@@ -0,0 +1,78 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+/**
+* @file Barrier.h
+* @ingroup util
+* The Barrier class.
+*/
+
+#include "Audaspace.h"
+
+#include <mutex>
+#include <condition_variable>
+
+AUD_NAMESPACE_BEGIN
+/**
+* This represents a barrier mechanism for thread sychronization.
+*/
+class Barrier
+{
+private:
+ /**
+ * A mutex needed to use a condition variable.
+ */
+ std::mutex m_mutex;
+
+ /**
+ * Condition varieble used to sync threads.
+ */
+ std::condition_variable m_condition;
+
+ /**
+ * Number of threads that need to reach the barrier for it to lift.
+ */
+ unsigned int m_threshold;
+
+ /**
+ * Conter that count from threshold to 0.
+ */
+ unsigned int m_count;
+
+ /**
+ * Variable used for predicate check in the condition variable wait.
+ */
+ unsigned int m_generation;
+
+ // delete copy constructor and operator=
+ Barrier(const Barrier&) = delete;
+ Barrier& operator=(const Barrier&) = delete;
+public:
+ /**
+ * Creates a new Barrier object.
+ * \param count the number of threads that need to reach the barrier for it to lift.
+ */
+ Barrier(unsigned int count);
+ virtual ~Barrier();
+
+ /**
+ * Makes the caller thread wait until enough threads are stopped by this method.
+ */
+ void wait();
+};
+AUD_NAMESPACE_END \ No newline at end of file
diff --git a/extern/audaspace/include/util/Buffer.h b/extern/audaspace/include/util/Buffer.h
new file mode 100644
index 00000000000..9934e53625e
--- /dev/null
+++ b/extern/audaspace/include/util/Buffer.h
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file Buffer.h
+ * @ingroup util
+ * The Buffer class.
+ */
+
+#include "Audaspace.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This class is a simple buffer in RAM which is 32 Byte aligned and provides
+ * resize functionality.
+ */
+class AUD_API Buffer
+{
+private:
+ /// The size of the buffer in bytes.
+ int m_size;
+
+ /// The pointer to the buffer memory.
+ data_t* m_buffer;
+
+ // delete copy constructor and operator=
+ Buffer(const Buffer&) = delete;
+ Buffer& operator=(const Buffer&) = delete;
+
+public:
+ /**
+ * Creates a new buffer.
+ * \param size The size of the buffer in bytes.
+ */
+ Buffer(int size = 0);
+
+ /**
+ * Destroys the buffer.
+ */
+ ~Buffer();
+
+ /**
+ * Returns the pointer to the buffer in memory.
+ */
+ sample_t* getBuffer() const;
+
+ /**
+ * Returns the size of the buffer in bytes.
+ */
+ int getSize() const;
+
+ /**
+ * Resizes the buffer.
+ * \param size The new size of the buffer, measured in bytes.
+ * \param keep Whether to keep the old data. If the new buffer is smaller,
+ * the data at the end will be lost.
+ */
+ void resize(int size, bool keep = false);
+
+ /**
+ * Makes sure the buffer has a minimum size.
+ * If size is >= current size, nothing will happen.
+ * Otherwise the buffer is resized with keep as parameter.
+ * \param size The new minimum size of the buffer, measured in bytes.
+ * \param keep Whether to keep the old data. If the new buffer is smaller,
+ * the data at the end will be lost.
+ */
+ void assureSize(int size, bool keep = false);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/util/BufferReader.h b/extern/audaspace/include/util/BufferReader.h
new file mode 100644
index 00000000000..b98313726bc
--- /dev/null
+++ b/extern/audaspace/include/util/BufferReader.h
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file BufferReader.h
+ * @ingroup util
+ * The BufferReader class.
+ */
+
+#include "IReader.h"
+
+#include <memory>
+
+AUD_NAMESPACE_BEGIN
+
+class Buffer;
+
+/**
+ * This class represents a simple reader from a buffer that exists in memory.
+ * \warning Notice that the buffer is not multi-threading ready, so changing the
+ * buffer while the reader is reading is potentially dangerous.
+ */
+class AUD_API BufferReader : public IReader
+{
+private:
+ /**
+ * The current position in the buffer.
+ */
+ int m_position;
+
+ /**
+ * The buffer that is read.
+ */
+ std::shared_ptr<Buffer> m_buffer;
+
+ /**
+ * The specification of the sample data in the buffer.
+ */
+ Specs m_specs;
+
+ // delete copy constructor and operator=
+ BufferReader(const BufferReader&) = delete;
+ BufferReader& operator=(const BufferReader&) = delete;
+
+public:
+ /**
+ * Creates a new buffer reader.
+ * \param buffer The buffer to read from.
+ * \param specs The specification of the sample data in the buffer.
+ */
+ BufferReader(std::shared_ptr<Buffer> buffer, Specs specs);
+
+ virtual bool isSeekable() const;
+ virtual void seek(int position);
+ virtual int getLength() const;
+ virtual int getPosition() const;
+ virtual Specs getSpecs() const;
+ virtual void read(int& length, bool& eos, sample_t* buffer);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/util/FFTPlan.h b/extern/audaspace/include/util/FFTPlan.h
new file mode 100644
index 00000000000..7d533ca8773
--- /dev/null
+++ b/extern/audaspace/include/util/FFTPlan.h
@@ -0,0 +1,120 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+/**
+* @file FFTPlan.h
+* @ingroup util
+* The FFTPlan class.
+*/
+
+#include <complex>
+#include <fftw3.h>
+#include "Audaspace.h"
+
+#include <memory>
+#include <vector>
+
+/**Default FFT size.*/
+#define DEFAULT_N 4096
+
+AUD_NAMESPACE_BEGIN
+
+/**
+* Thas class represents an plan object that allows to calculate FFTs and IFFTs.
+*/
+class AUD_API FFTPlan
+{
+private:
+ /**
+ * The size of the FFT plan.
+ */
+ int m_N;
+
+ /**
+ * The plan to transform the input to the frequency domain.
+ */
+ fftwf_plan m_fftPlanR2C;
+
+ /**
+ * The plan to transform the input to the time domain again.
+ */
+ fftwf_plan m_fftPlanC2R;
+
+ /**
+ * The size of a buffer for its use with the FFT plan (in bytes).
+ */
+ unsigned int m_bufferSize;
+
+ // delete copy constructor and operator=
+ FFTPlan(const FFTPlan&) = delete;
+ FFTPlan& operator=(const FFTPlan&) = delete;
+
+public:
+ /**
+ * Creates a new FFTPlan object with DEFAULT_N size (4096).
+ * \param measureTime The aproximate amount of seconds that FFTW will spend searching for the optimal plan,
+ * which means faster FFTs and IFFTs while using this plan. If measureTime is negative, it will take all the time it needs.
+ */
+ FFTPlan(double measureTime = 0);
+
+ /**
+ * Creates a new FFTPlan object with a custom size.
+ * \param n The size of the FFT plan. Values that are a power of two are faster.
+ * The useful range usually is between 2048 and 8192, but bigger values can be useful
+ * in certain situations (when using the StreamBuffer class per example).
+ * Generally, low values use more CPU power and are a bit faster than large ones,
+ * there is also a huge decrease in efficiency when n is lower than 2048.
+ * \param measureTime The aproximate amount of seconds that FFTW will spend searching for the optimal plan,
+ * which means faster FFTs while using this plan. If measureTime is negative, it will take all the time it needs.
+ */
+ FFTPlan(int n, double measureTime = 0);
+ ~FFTPlan();
+
+ /**
+ * Retrieves the size of the FFT plan.
+ * \return The size of the plan.
+ */
+ int getSize();
+
+ /**
+ * Calculates the FFT of an input buffer with the current plan.
+ * \param[in,out] buffer A buffer with the input data an in which the output data will be written.
+ */
+ void FFT(void* buffer);
+
+ /**
+ * Calculates the IFFT of an input buffer with the current plan.
+ * \param[in,out] buffer A buffer with the input data an in which the output data will be written.
+ */
+ void IFFT(void* buffer);
+
+ /**
+ * Reserves memory for a buffer that can be used for inplace transformations with this plan.
+ * \return A pointer to a buffer of size ((N/2)+1)*2*sizeof(fftwf_complex).
+ * \warning The returned buffer must be freed with the freeBuffer method of this class.
+ */
+ void* getBuffer();
+
+ /**
+ * Frees one of the buffers reserved with the getRealOnlyBuffer(), getComplexOnlyBuffer() or getInplaceBuffer() method.
+ * \param buffer A pointer to the buufer taht must be freed.
+ */
+ void freeBuffer(void* buffer);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/util/ILockable.h b/extern/audaspace/include/util/ILockable.h
new file mode 100644
index 00000000000..8300fbd2845
--- /dev/null
+++ b/extern/audaspace/include/util/ILockable.h
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file ILockable.h
+ * @ingroup util
+ * The ILockable interface.
+ */
+
+#include "Audaspace.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * @interface ILockable
+ * This class provides an interface for lockable objects.
+ */
+class AUD_API ILockable
+{
+public:
+ /**
+ * Locks the object.
+ */
+ virtual void lock()=0;
+ /**
+ * Unlocks the previously locked object.
+ */
+ virtual void unlock()=0;
+};
+
+AUD_NAMESPACE_END
diff --git a/intern/audaspace/intern/AUD_3DMath.h b/extern/audaspace/include/util/Math3D.h
index 1b109ebee1e..7ded12c1ba8 100644
--- a/intern/audaspace/intern/AUD_3DMath.h
+++ b/extern/audaspace/include/util/Math3D.h
@@ -1,42 +1,38 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
*
- * Copyright 2009-2011 Jörg Hermann Müller
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * This file is part of AudaSpace.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * 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 *****
- */
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
-/** \file audaspace/intern/AUD_3DMath.h
- * \ingroup audaspaceintern
- */
+#pragma once
+/**
+ * @file Math3D.h
+ * @ingroup util
+ * Defines the Vector3 and Quaternion classes.
+ */
-#ifndef __AUD_3DMATH_H__
-#define __AUD_3DMATH_H__
+#include "Audaspace.h"
#include <cmath>
#include <cstring>
+AUD_NAMESPACE_BEGIN
+
/**
* This class represents a 3 dimensional vector.
*/
-class AUD_Vector3
+class AUD_API Vector3
{
private:
/**
@@ -60,7 +56,7 @@ public:
* \param y The y component.
* \param z The z component.
*/
- inline AUD_Vector3(float x = 0, float y = 0, float z = 0) :
+ inline Vector3(float x = 0, float y = 0, float z = 0) :
m_x(x), m_y(y), m_z(z)
{
}
@@ -98,7 +94,7 @@ public:
*/
inline void get(float* destination) const
{
- memcpy(destination, m_v, sizeof(m_v));
+ std::memcpy(destination, m_v, sizeof(m_v));
}
/**
@@ -125,7 +121,7 @@ public:
*/
inline float length() const
{
- return sqrt(m_x*m_x + m_y*m_y + m_z*m_z);
+ return std::sqrt(m_x*m_x + m_y*m_y + m_z*m_z);
}
/**
@@ -133,11 +129,11 @@ public:
* \param op The second operand.
* \return The cross product of the two vectors.
*/
- inline AUD_Vector3 cross(const AUD_Vector3& op) const
+ inline Vector3 cross(const Vector3& op) const
{
- return AUD_Vector3(m_y * op.m_z - m_z * op.m_y,
- m_z * op.m_x - m_x * op.m_z,
- m_x * op.m_y - m_y * op.m_x);
+ return Vector3(m_y * op.m_z - m_z * op.m_y,
+ m_z * op.m_x - m_x * op.m_z,
+ m_x * op.m_y - m_y * op.m_x);
}
/**
@@ -145,7 +141,7 @@ public:
* \param op The second operand.
* \return The dot product of the two vectors.
*/
- inline float operator*(const AUD_Vector3& op) const
+ inline float operator*(const Vector3& op) const
{
return m_x * op.m_x + m_y * op.m_y + m_z * op.m_z;
}
@@ -155,9 +151,9 @@ public:
* \param op The second operand.
* \return The scaled vector.
*/
- inline AUD_Vector3 operator*(const float& op) const
+ inline Vector3 operator*(const float& op) const
{
- return AUD_Vector3(m_x * op, m_y * op, m_z * op);
+ return Vector3(m_x * op, m_y * op, m_z * op);
}
/**
@@ -165,9 +161,9 @@ public:
* \param op The second operand.
* \return The sum vector.
*/
- inline AUD_Vector3 operator+(const AUD_Vector3& op) const
+ inline Vector3 operator+(const Vector3& op) const
{
- return AUD_Vector3(m_x + op.m_x, m_y + op.m_y, m_z + op.m_z);
+ return Vector3(m_x + op.m_x, m_y + op.m_y, m_z + op.m_z);
}
/**
@@ -175,18 +171,18 @@ public:
* \param op The second operand.
* \return The difference vector.
*/
- inline AUD_Vector3 operator-(const AUD_Vector3& op) const
+ inline Vector3 operator-(const Vector3& op) const
{
- return AUD_Vector3(m_x - op.m_x, m_y - op.m_y, m_z - op.m_z);
+ return Vector3(m_x - op.m_x, m_y - op.m_y, m_z - op.m_z);
}
/**
* Negates the vector.
* \return The vector facing in the opposite direction.
*/
- inline AUD_Vector3 operator-() const
+ inline Vector3 operator-() const
{
- return AUD_Vector3(-m_x, -m_y, -m_z);
+ return Vector3(-m_x, -m_y, -m_z);
}
/**
@@ -194,7 +190,7 @@ public:
* \param op The second operand.
* \return The difference vector.
*/
- inline AUD_Vector3& operator-=(const AUD_Vector3& op)
+ inline Vector3& operator-=(const Vector3& op)
{
m_x -= op.m_x;
m_y -= op.m_y;
@@ -206,7 +202,7 @@ public:
/**
* This class represents a quaternion used for 3D rotations.
*/
-class AUD_Quaternion
+class AUD_API Quaternion
{
private:
/**
@@ -232,7 +228,7 @@ public:
* \param y The y component.
* \param z The z component.
*/
- inline AUD_Quaternion(float w = 1, float x = 0, float y = 0, float z = 0) :
+ inline Quaternion(float w = 1, float x = 0, float y = 0, float z = 0) :
m_w(w), m_x(x), m_y(y), m_z(z)
{
}
@@ -279,7 +275,7 @@ public:
*/
inline void get(float* destination) const
{
- memcpy(destination, m_v, sizeof(m_v));
+ std::memcpy(destination, m_v, sizeof(m_v));
}
/**
@@ -305,11 +301,11 @@ public:
* z axis vector.
* \return The negative z axis vector.
*/
- inline AUD_Vector3 getLookAt() const
+ inline Vector3 getLookAt() const
{
- return AUD_Vector3(-2 * (m_w * m_y + m_x * m_z),
- 2 * (m_x * m_w - m_z * m_y),
- 2 * (m_x * m_x + m_y * m_y) - 1);
+ return Vector3(-2 * (m_w * m_y + m_x * m_z),
+ 2 * (m_x * m_w - m_z * m_y),
+ 2 * (m_x * m_x + m_y * m_y) - 1);
}
/**
@@ -317,12 +313,12 @@ public:
* vector.
* \return The y axis vector.
*/
- inline AUD_Vector3 getUp() const
+ inline Vector3 getUp() const
{
- return AUD_Vector3(2 * (m_x * m_y - m_w * m_z),
+ return Vector3(2 * (m_x * m_y - m_w * m_z),
1 - 2 * (m_x * m_x + m_z * m_z),
2 * (m_w * m_x + m_y * m_z));
}
};
-#endif //__AUD_3DMATH_H__
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/util/StreamBuffer.h b/extern/audaspace/include/util/StreamBuffer.h
new file mode 100644
index 00000000000..8ec4cfcf46d
--- /dev/null
+++ b/extern/audaspace/include/util/StreamBuffer.h
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file StreamBuffer.h
+ * @ingroup util
+ * The StreamBuffer class.
+ */
+
+#include "ISound.h"
+#include "respec/Specification.h"
+
+AUD_NAMESPACE_BEGIN
+
+class Buffer;
+
+/**
+ * This sound creates a buffer out of a reader. This way normally streamed
+ * sound sources can be loaded into memory for buffered playback.
+ */
+class AUD_API StreamBuffer : public ISound
+{
+private:
+ /**
+ * The buffer that holds the audio data.
+ */
+ std::shared_ptr<Buffer> m_buffer;
+
+ /**
+ * The specification of the samples.
+ */
+ Specs m_specs;
+
+ // delete copy constructor and operator=
+ StreamBuffer(const StreamBuffer&) = delete;
+ StreamBuffer& operator=(const StreamBuffer&) = delete;
+
+public:
+ /**
+ * Creates the sound and reads the reader created by the sound supplied
+ * to the buffer.
+ * \param sound The sound that creates the reader for buffering.
+ * \exception Exception Thrown if the reader cannot be created.
+ */
+ StreamBuffer(std::shared_ptr<ISound> sound);
+
+ /**
+ * Creates the sound from an preexisting buffer.
+ * \param buffer The buffer to stream from.
+ * \param specs The specification of the data in the buffer.
+ * \exception Exception Thrown if the reader cannot be created.
+ */
+ StreamBuffer(std::shared_ptr<Buffer> buffer, Specs specs);
+
+ /**
+ * Returns the buffer to be streamed.
+ * @return The buffer to stream.
+ */
+ std::shared_ptr<Buffer> getBuffer();
+
+ /**
+ * Returns the specification of the buffer.
+ * @return The specification of the buffer.
+ */
+ Specs getSpecs();
+
+ virtual std::shared_ptr<IReader> createReader();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/util/ThreadPool.h b/extern/audaspace/include/util/ThreadPool.h
new file mode 100644
index 00000000000..24ec089d52c
--- /dev/null
+++ b/extern/audaspace/include/util/ThreadPool.h
@@ -0,0 +1,119 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#pragma once
+
+/**
+* @file ThreadPool.h
+* @ingroup util
+* The ThreadPool class.
+*/
+
+#include "Audaspace.h"
+
+#include <mutex>
+#include <condition_variable>
+#include <vector>
+#include <thread>
+#include <queue>
+#include <future>
+#include <functional>
+
+AUD_NAMESPACE_BEGIN
+/**
+* This represents pool of threads.
+*/
+class AUD_API ThreadPool
+{
+private:
+ /**
+ * A queue of tasks.
+ */
+ std::queue<std::function<void()>> m_queue;
+
+ /**
+ * A vector of thread objects.
+ */
+ std::vector<std::thread> m_threads;
+
+ /**
+ * A mutex for synchronization.
+ */
+ std::mutex m_mutex;
+
+ /**
+ * A condition variable used to stop the threads when there are no tasks.
+ */
+ std::condition_variable m_condition;
+
+ /**
+ * Stop flag.
+ */
+ bool m_stopFlag;
+
+ /**
+ * The number fo threads.
+ */
+ unsigned int m_numThreads;
+
+ // delete copy constructor and operator=
+ ThreadPool(const ThreadPool&) = delete;
+ ThreadPool& operator=(const ThreadPool&) = delete;
+public:
+ /**
+ * Creates a new ThreadPool object.
+ * \param count The number of threads of the pool. It must not be 0.
+ */
+ ThreadPool(unsigned int count);
+
+ virtual ~ThreadPool();
+
+ /**
+ * Enqueues a new task for the threads to realize.
+ * \param t A function that realices a task.
+ * \param args The arguments of the task.
+ * \return A future of the same type as the return type of the task.
+ */
+ template<class T, class... Args>
+ std::future<typename std::result_of<T(Args...)>::type> enqueue(T&& t, Args&&... args)
+ {
+ using pkgdTask = std::packaged_task<typename std::result_of<T(Args...)>::type()>;
+
+ std::shared_ptr<pkgdTask> task = std::make_shared<pkgdTask>(std::bind(std::forward<T>(t), std::forward<Args>(args)...));
+ auto result = task->get_future();
+
+ m_mutex.lock();
+ m_queue.emplace([task]() { (*task)(); });
+ m_mutex.unlock();
+
+ m_condition.notify_one();
+ return result;
+ }
+
+ /**
+ * Retrieves the number of threads of the pool.
+ * \return The number of threads.
+ */
+ unsigned int getNumOfThreads();
+
+private:
+
+ /**
+ * Worker thread function.
+ */
+ void threadFunction();
+};
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/plugins/ffmpeg/FFMPEG.cpp b/extern/audaspace/plugins/ffmpeg/FFMPEG.cpp
new file mode 100644
index 00000000000..7f9b762f816
--- /dev/null
+++ b/extern/audaspace/plugins/ffmpeg/FFMPEG.cpp
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "FFMPEG.h"
+#include "FFMPEGReader.h"
+#include "FFMPEGWriter.h"
+#include "file/FileManager.h"
+
+AUD_NAMESPACE_BEGIN
+
+FFMPEG::FFMPEG()
+{
+ av_register_all();
+}
+
+void FFMPEG::registerPlugin()
+{
+ std::shared_ptr<FFMPEG> plugin = std::shared_ptr<FFMPEG>(new FFMPEG);
+ FileManager::registerInput(plugin);
+ FileManager::registerOutput(plugin);
+}
+
+std::shared_ptr<IReader> FFMPEG::createReader(std::string filename)
+{
+ return std::shared_ptr<IReader>(new FFMPEGReader(filename));
+}
+
+std::shared_ptr<IReader> FFMPEG::createReader(std::shared_ptr<Buffer> buffer)
+{
+ return std::shared_ptr<IReader>(new FFMPEGReader(buffer));
+}
+
+std::shared_ptr<IWriter> FFMPEG::createWriter(std::string filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate)
+{
+ return std::shared_ptr<IWriter>(new FFMPEGWriter(filename, specs, format, codec, bitrate));
+}
+
+#ifdef FFMPEG_PLUGIN
+extern "C" AUD_PLUGIN_API void registerPlugin()
+{
+ FFMPEG::registerPlugin();
+}
+
+extern "C" AUD_PLUGIN_API const char* getName()
+{
+ return "FFMPEG";
+}
+#endif
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/plugins/ffmpeg/FFMPEG.h b/extern/audaspace/plugins/ffmpeg/FFMPEG.h
new file mode 100644
index 00000000000..108ba547e0f
--- /dev/null
+++ b/extern/audaspace/plugins/ffmpeg/FFMPEG.h
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+#ifdef FFMPEG_PLUGIN
+#define AUD_BUILD_PLUGIN
+#endif
+
+/**
+ * @file FFMPEG.h
+ * @ingroup plugin
+ * The FFMPEG class.
+ */
+
+#include "file/IFileInput.h"
+#include "file/IFileOutput.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This plugin class reads and writes sounds via ffmpeg.
+ */
+class AUD_PLUGIN_API FFMPEG : public IFileInput, public IFileOutput
+{
+private:
+ // delete copy constructor and operator=
+ FFMPEG(const FFMPEG&) = delete;
+ FFMPEG& operator=(const FFMPEG&) = delete;
+
+public:
+ /**
+ * Creates a new ffmpeg plugin.
+ */
+ FFMPEG();
+
+ /**
+ * Registers this plugin.
+ */
+ static void registerPlugin();
+
+ virtual std::shared_ptr<IReader> createReader(std::string filename);
+ virtual std::shared_ptr<IReader> createReader(std::shared_ptr<Buffer> buffer);
+ virtual std::shared_ptr<IWriter> createWriter(std::string filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp b/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp
new file mode 100644
index 00000000000..6b79cc5abfd
--- /dev/null
+++ b/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp
@@ -0,0 +1,397 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "FFMPEGReader.h"
+#include "Exception.h"
+
+#include <algorithm>
+
+extern "C" {
+#include <libavcodec/avcodec.h>
+#include <libavformat/avio.h>
+}
+
+AUD_NAMESPACE_BEGIN
+
+int FFMPEGReader::decode(AVPacket& packet, Buffer& buffer)
+{
+ AVFrame* frame = nullptr;
+ int got_frame;
+ int read_length;
+ uint8_t* orig_data = packet.data;
+ int orig_size = packet.size;
+
+ int buf_size = buffer.getSize();
+ int buf_pos = 0;
+
+ while(packet.size > 0)
+ {
+ got_frame = 0;
+
+ if(!frame)
+ frame = av_frame_alloc();
+ else
+ av_frame_unref(frame);
+
+ read_length = avcodec_decode_audio4(m_codecCtx, frame, &got_frame, &packet);
+ if(read_length < 0)
+ break;
+
+ if(got_frame)
+ {
+ int data_size = av_samples_get_buffer_size(nullptr, m_codecCtx->channels, frame->nb_samples, m_codecCtx->sample_fmt, 1);
+
+ if(buf_size - buf_pos < data_size)
+ {
+ buffer.resize(buf_size + data_size, true);
+ buf_size += data_size;
+ }
+
+ if(m_tointerleave)
+ {
+ int single_size = data_size / m_codecCtx->channels / frame->nb_samples;
+ for(int channel = 0; channel < m_codecCtx->channels; channel++)
+ {
+ for(int i = 0; i < frame->nb_samples; i++)
+ {
+ std::memcpy(((data_t*)buffer.getBuffer()) + buf_pos + ((m_codecCtx->channels * i) + channel) * single_size,
+ frame->data[channel] + i * single_size, single_size);
+ }
+ }
+ }
+ else
+ std::memcpy(((data_t*)buffer.getBuffer()) + buf_pos, frame->data[0], data_size);
+
+ buf_pos += data_size;
+ }
+ packet.size -= read_length;
+ packet.data += read_length;
+ }
+
+ packet.data = orig_data;
+ packet.size = orig_size;
+ av_free(frame);
+
+ return buf_pos;
+}
+
+void FFMPEGReader::init()
+{
+ m_position = 0;
+ m_pkgbuf_left = 0;
+
+ if(avformat_find_stream_info(m_formatCtx, nullptr) < 0)
+ AUD_THROW(FileException, "File couldn't be read, ffmpeg couldn't find the stream info.");
+
+ // find audio stream and codec
+ m_stream = -1;
+
+ for(unsigned int i = 0; i < m_formatCtx->nb_streams; i++)
+ {
+ if((m_formatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
+ && (m_stream < 0))
+ {
+ m_stream=i;
+ break;
+ }
+ }
+
+ if(m_stream == -1)
+ AUD_THROW(FileException, "File couldn't be read, no audio stream found by ffmpeg.");
+
+ m_codecCtx = m_formatCtx->streams[m_stream]->codec;
+
+ // get a decoder and open it
+ AVCodec* aCodec = avcodec_find_decoder(m_codecCtx->codec_id);
+ if(!aCodec)
+ AUD_THROW(FileException, "File couldn't be read, no decoder found with ffmpeg.");
+
+ if(avcodec_open2(m_codecCtx, aCodec, nullptr) < 0)
+ AUD_THROW(FileException, "File couldn't be read, ffmpeg codec couldn't be opened.");
+
+ m_specs.channels = (Channels) m_codecCtx->channels;
+ m_tointerleave = av_sample_fmt_is_planar(m_codecCtx->sample_fmt);
+
+ switch(av_get_packed_sample_fmt(m_codecCtx->sample_fmt))
+ {
+ case AV_SAMPLE_FMT_U8:
+ m_convert = convert_u8_float;
+ m_specs.format = FORMAT_U8;
+ break;
+ case AV_SAMPLE_FMT_S16:
+ m_convert = convert_s16_float;
+ m_specs.format = FORMAT_S16;
+ break;
+ case AV_SAMPLE_FMT_S32:
+ m_convert = convert_s32_float;
+ m_specs.format = FORMAT_S32;
+ break;
+ case AV_SAMPLE_FMT_FLT:
+ m_convert = convert_copy<float>;
+ m_specs.format = FORMAT_FLOAT32;
+ break;
+ case AV_SAMPLE_FMT_DBL:
+ m_convert = convert_double_float;
+ m_specs.format = FORMAT_FLOAT64;
+ break;
+ default:
+ AUD_THROW(FileException, "File couldn't be read, ffmpeg sample format unknown.");
+ }
+
+ m_specs.rate = (SampleRate) m_codecCtx->sample_rate;
+}
+
+FFMPEGReader::FFMPEGReader(std::string filename) :
+ m_pkgbuf(),
+ m_formatCtx(nullptr),
+ m_aviocontext(nullptr),
+ m_membuf(nullptr)
+{
+ // open file
+ if(avformat_open_input(&m_formatCtx, filename.c_str(), nullptr, nullptr)!=0)
+ AUD_THROW(FileException, "File couldn't be opened with ffmpeg.");
+
+ try
+ {
+ init();
+ }
+ catch(Exception&)
+ {
+ avformat_close_input(&m_formatCtx);
+ throw;
+ }
+}
+
+FFMPEGReader::FFMPEGReader(std::shared_ptr<Buffer> buffer) :
+ m_pkgbuf(),
+ m_membuffer(buffer),
+ m_membufferpos(0)
+{
+ m_membuf = reinterpret_cast<data_t*>(av_malloc(FF_MIN_BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE));
+
+ m_aviocontext = avio_alloc_context(m_membuf, FF_MIN_BUFFER_SIZE, 0, this, read_packet, nullptr, seek_packet);
+
+ if(!m_aviocontext)
+ {
+ av_free(m_aviocontext);
+ AUD_THROW(FileException, "Buffer reading context couldn't be created with ffmpeg.");
+ }
+
+ m_formatCtx = avformat_alloc_context();
+ m_formatCtx->pb = m_aviocontext;
+ if(avformat_open_input(&m_formatCtx, "", nullptr, nullptr)!=0)
+ {
+ av_free(m_aviocontext);
+ AUD_THROW(FileException, "Buffer couldn't be read with ffmpeg.");
+ }
+
+ try
+ {
+ init();
+ }
+ catch(Exception&)
+ {
+ avformat_close_input(&m_formatCtx);
+ av_free(m_aviocontext);
+ throw;
+ }
+}
+
+FFMPEGReader::~FFMPEGReader()
+{
+ avcodec_close(m_codecCtx);
+ avformat_close_input(&m_formatCtx);
+}
+
+int FFMPEGReader::read_packet(void* opaque, uint8_t* buf, int buf_size)
+{
+ FFMPEGReader* reader = reinterpret_cast<FFMPEGReader*>(opaque);
+
+ int size = std::min(buf_size, int(reader->m_membuffer->getSize() - reader->m_membufferpos));
+
+ if(size < 0)
+ return -1;
+
+ std::memcpy(buf, ((data_t*)reader->m_membuffer->getBuffer()) + reader->m_membufferpos, size);
+ reader->m_membufferpos += size;
+
+ return size;
+}
+
+int64_t FFMPEGReader::seek_packet(void* opaque, int64_t offset, int whence)
+{
+ FFMPEGReader* reader = reinterpret_cast<FFMPEGReader*>(opaque);
+
+ switch(whence)
+ {
+ case SEEK_SET:
+ reader->m_membufferpos = 0;
+ break;
+ case SEEK_END:
+ reader->m_membufferpos = reader->m_membuffer->getSize();
+ break;
+ case AVSEEK_SIZE:
+ return reader->m_membuffer->getSize();
+ }
+
+ return (reader->m_membufferpos += offset);
+}
+
+bool FFMPEGReader::isSeekable() const
+{
+ return true;
+}
+
+void FFMPEGReader::seek(int position)
+{
+ if(position >= 0)
+ {
+ uint64_t st_time = m_formatCtx->start_time;
+ uint64_t seek_pos = ((uint64_t)position) * ((uint64_t)AV_TIME_BASE) / ((uint64_t)m_specs.rate);
+
+ if(st_time != AV_NOPTS_VALUE) {
+ seek_pos += st_time;
+ }
+
+ double pts_time_base =
+ av_q2d(m_formatCtx->streams[m_stream]->time_base);
+ uint64_t pts_st_time =
+ ((st_time != AV_NOPTS_VALUE) ? st_time : 0)
+ / pts_time_base / (uint64_t) AV_TIME_BASE;
+
+ // a value < 0 tells us that seeking failed
+ if(av_seek_frame(m_formatCtx, -1, seek_pos,
+ AVSEEK_FLAG_BACKWARD | AVSEEK_FLAG_ANY) >= 0)
+ {
+ avcodec_flush_buffers(m_codecCtx);
+ m_position = position;
+
+ AVPacket packet;
+ bool search = true;
+
+ while(search && av_read_frame(m_formatCtx, &packet) >= 0)
+ {
+ // is it a frame from the audio stream?
+ if(packet.stream_index == m_stream)
+ {
+ // decode the package
+ m_pkgbuf_left = decode(packet, m_pkgbuf);
+ search = false;
+
+ // check position
+ if(packet.pts != AV_NOPTS_VALUE)
+ {
+ // calculate real position, and read to frame!
+ m_position = (packet.pts - pts_st_time) * pts_time_base * m_specs.rate;
+
+ if(m_position < position)
+ {
+ // read until we're at the right position
+ int length = AUD_DEFAULT_BUFFER_SIZE;
+ Buffer buffer(length * AUD_SAMPLE_SIZE(m_specs));
+ bool eos;
+ for(int len = position - m_position; len > 0; len -= AUD_DEFAULT_BUFFER_SIZE)
+ {
+ if(len < AUD_DEFAULT_BUFFER_SIZE)
+ length = len;
+ read(length, eos, buffer.getBuffer());
+ }
+ }
+ }
+ }
+ av_free_packet(&packet);
+ }
+ }
+ else
+ {
+ fprintf(stderr, "seeking failed!\n");
+ // Seeking failed, do nothing.
+ }
+ }
+}
+
+int FFMPEGReader::getLength() const
+{
+ // return approximated remaning size
+ return (int)((m_formatCtx->duration * m_codecCtx->sample_rate)
+ / AV_TIME_BASE)-m_position;
+}
+
+int FFMPEGReader::getPosition() const
+{
+ return m_position;
+}
+
+Specs FFMPEGReader::getSpecs() const
+{
+ return m_specs.specs;
+}
+
+void FFMPEGReader::read(int& length, bool& eos, sample_t* buffer)
+{
+ // read packages and decode them
+ AVPacket packet;
+ int data_size = 0;
+ int pkgbuf_pos;
+ int left = length;
+ int sample_size = AUD_DEVICE_SAMPLE_SIZE(m_specs);
+
+ sample_t* buf = buffer;
+ pkgbuf_pos = m_pkgbuf_left;
+ m_pkgbuf_left = 0;
+
+ // there may still be data in the buffer from the last call
+ if(pkgbuf_pos > 0)
+ {
+ data_size = std::min(pkgbuf_pos, left * sample_size);
+ m_convert((data_t*) buf, (data_t*) m_pkgbuf.getBuffer(), data_size / AUD_FORMAT_SIZE(m_specs.format));
+ buf += data_size / AUD_FORMAT_SIZE(m_specs.format);
+ left -= data_size/sample_size;
+ }
+
+ // for each frame read as long as there isn't enough data already
+ while((left > 0) && (av_read_frame(m_formatCtx, &packet) >= 0))
+ {
+ // is it a frame from the audio stream?
+ if(packet.stream_index == m_stream)
+ {
+ // decode the package
+ pkgbuf_pos = decode(packet, m_pkgbuf);
+
+ // copy to output buffer
+ data_size = std::min(pkgbuf_pos, left * sample_size);
+ m_convert((data_t*) buf, (data_t*) m_pkgbuf.getBuffer(), data_size / AUD_FORMAT_SIZE(m_specs.format));
+ buf += data_size / AUD_FORMAT_SIZE(m_specs.format);
+ left -= data_size/sample_size;
+ }
+ av_free_packet(&packet);
+ }
+ // read more data than necessary?
+ if(pkgbuf_pos > data_size)
+ {
+ m_pkgbuf_left = pkgbuf_pos-data_size;
+ memmove(m_pkgbuf.getBuffer(),
+ ((data_t*)m_pkgbuf.getBuffer())+data_size,
+ pkgbuf_pos-data_size);
+ }
+
+ if((eos = (left > 0)))
+ length -= left;
+
+ m_position += length;
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/plugins/ffmpeg/FFMPEGReader.h b/extern/audaspace/plugins/ffmpeg/FFMPEGReader.h
new file mode 100644
index 00000000000..e2ae959912d
--- /dev/null
+++ b/extern/audaspace/plugins/ffmpeg/FFMPEGReader.h
@@ -0,0 +1,184 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+#ifdef FFMPEG_PLUGIN
+#define AUD_BUILD_PLUGIN
+#endif
+
+/**
+ * @file FFMPEGReader.h
+ * @ingroup plugin
+ * The FFMPEGReader class.
+ */
+
+#include "respec/ConverterFunctions.h"
+#include "IReader.h"
+#include "util/Buffer.h"
+
+#include <string>
+#include <memory>
+
+struct AVCodecContext;
+extern "C" {
+#include <libavformat/avformat.h>
+}
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This class reads a sound file via ffmpeg.
+ * \warning Seeking may not be accurate! Moreover the position is updated after
+ * a buffer reading call. So calling getPosition right after seek
+ * normally results in a wrong value.
+ */
+class AUD_PLUGIN_API FFMPEGReader : public IReader
+{
+private:
+ /**
+ * The current position in samples.
+ */
+ int m_position;
+
+ /**
+ * The specification of the audio data.
+ */
+ DeviceSpecs m_specs;
+
+ /**
+ * The buffer for package reading.
+ */
+ Buffer m_pkgbuf;
+
+ /**
+ * The count of samples still available from the last read package.
+ */
+ int m_pkgbuf_left;
+
+ /**
+ * The AVFormatContext structure for using ffmpeg.
+ */
+ AVFormatContext* m_formatCtx;
+
+ /**
+ * The AVCodecContext structure for using ffmpeg.
+ */
+ AVCodecContext* m_codecCtx;
+
+ /**
+ * The AVIOContext to read the data from.
+ */
+ AVIOContext* m_aviocontext;
+
+ /**
+ * The stream ID in the file.
+ */
+ int m_stream;
+
+ /**
+ * Converter function.
+ */
+ convert_f m_convert;
+
+ /**
+ * The memory file to read from.
+ */
+ std::shared_ptr<Buffer> m_membuffer;
+
+ /**
+ * The buffer to read with.
+ */
+ data_t* m_membuf;
+
+ /**
+ * Reading position of the buffer.
+ */
+ int64_t m_membufferpos;
+
+ /**
+ * Whether the audio data has to be interleaved after reading.
+ */
+ bool m_tointerleave;
+
+ /**
+ * Decodes a packet into the given buffer.
+ * \param packet The AVPacket to decode.
+ * \param buffer The target buffer.
+ * \return The count of read bytes.
+ */
+ AUD_LOCAL int decode(AVPacket& packet, Buffer& buffer);
+
+ /**
+ * Initializes the object.
+ */
+ AUD_LOCAL void init();
+
+ // delete copy constructor and operator=
+ FFMPEGReader(const FFMPEGReader&) = delete;
+ FFMPEGReader& operator=(const FFMPEGReader&) = delete;
+
+public:
+ /**
+ * Creates a new reader.
+ * \param filename The path to the file to be read.
+ * \exception Exception Thrown if the file specified does not exist or
+ * cannot be read with ffmpeg.
+ */
+ FFMPEGReader(std::string filename);
+
+ /**
+ * Creates a new reader.
+ * \param buffer The buffer to read from.
+ * \exception Exception Thrown if the buffer specified cannot be read
+ * with ffmpeg.
+ */
+ FFMPEGReader(std::shared_ptr<Buffer> buffer);
+
+ /**
+ * Destroys the reader and closes the file.
+ */
+ virtual ~FFMPEGReader();
+
+ /**
+ * Reads data to a memory buffer.
+ * This function is used for avio only.
+ * @param opaque The FFMPEGReader.
+ * @param buf The buffer to read to.
+ * @param buf_size The size of the buffer.
+ * @return How many bytes have been read.
+ */
+ static int read_packet(void* opaque, uint8_t* buf, int buf_size);
+
+ /**
+ * Seeks within data.
+ * This function is used for avio only.
+ * @param opaque The FFMPEGReader.
+ * @param offset The byte offset to seek to.
+ * @param whence The seeking action.
+ * @return The current position or the size of the data if requested.
+ */
+ static int64_t seek_packet(void* opaque, int64_t offset, int whence);
+
+ virtual bool isSeekable() const;
+ virtual void seek(int position);
+ virtual int getLength() const;
+ virtual int getPosition() const;
+ virtual Specs getSpecs() const;
+ virtual void read(int& length, bool& eos, sample_t* buffer);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp b/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp
new file mode 100644
index 00000000000..f79f0f7fc6b
--- /dev/null
+++ b/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp
@@ -0,0 +1,427 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "FFMPEGWriter.h"
+#include "Exception.h"
+
+#include <algorithm>
+#include <cstring>
+
+extern "C" {
+#include <libavcodec/avcodec.h>
+#include <libavformat/avio.h>
+}
+
+AUD_NAMESPACE_BEGIN
+
+void FFMPEGWriter::encode()
+{
+ sample_t* data = m_input_buffer.getBuffer();
+
+ if(m_deinterleave)
+ {
+ m_deinterleave_buffer.assureSize(m_input_buffer.getSize());
+
+ sample_t* dbuf = m_deinterleave_buffer.getBuffer();
+ // deinterleave
+ int single_size = sizeof(sample_t);
+ for(int channel = 0; channel < m_specs.channels; channel++)
+ {
+ for(int i = 0; i < m_input_buffer.getSize() / AUD_SAMPLE_SIZE(m_specs); i++)
+ {
+ std::memcpy(((data_t*)dbuf) + (m_input_samples * channel + i) * single_size,
+ ((data_t*)data) + ((m_specs.channels * i) + channel) * single_size, single_size);
+ }
+ }
+
+ // convert first
+ if(m_input_size)
+ m_convert(reinterpret_cast<data_t*>(data), reinterpret_cast<data_t*>(dbuf), m_input_samples * m_specs.channels);
+ else
+ std::memcpy(data, dbuf, m_input_buffer.getSize());
+ }
+ else
+ // convert first
+ if(m_input_size)
+ m_convert(reinterpret_cast<data_t*>(data), reinterpret_cast<data_t*>(data), m_input_samples * m_specs.channels);
+
+ AVPacket packet;
+
+ packet.data = nullptr;
+ packet.size = 0;
+
+ av_init_packet(&packet);
+
+ AVFrame* frame = av_frame_alloc();
+ av_frame_unref(frame);
+ int got_packet;
+
+ frame->nb_samples = m_input_samples;
+ frame->format = m_codecCtx->sample_fmt;
+ frame->channel_layout = m_codecCtx->channel_layout;
+
+ if(avcodec_fill_audio_frame(frame, m_specs.channels, m_codecCtx->sample_fmt, reinterpret_cast<data_t*>(data), m_input_buffer.getSize(), 0) < 0)
+ AUD_THROW(FileException, "File couldn't be written, filling the audio frame failed with ffmpeg.");
+
+ AVRational sample_time = { 1, static_cast<int>(m_specs.rate) };
+ frame->pts = av_rescale_q(m_position - m_input_samples, m_codecCtx->time_base, sample_time);
+
+ if(avcodec_encode_audio2(m_codecCtx, &packet, frame, &got_packet))
+ {
+ av_frame_free(&frame);
+ AUD_THROW(FileException, "File couldn't be written, audio encoding failed with ffmpeg.");
+ }
+
+ if(got_packet)
+ {
+ packet.flags |= AV_PKT_FLAG_KEY;
+ packet.stream_index = m_stream->index;
+ if(av_write_frame(m_formatCtx, &packet) < 0)
+ {
+ av_free_packet(&packet);
+ av_frame_free(&frame);
+ AUD_THROW(FileException, "Frame couldn't be writen to the file with ffmpeg.");
+ }
+ av_free_packet(&packet);
+ }
+
+ av_frame_free(&frame);
+}
+
+void FFMPEGWriter::close()
+{
+ int got_packet = true;
+
+ while(got_packet)
+ {
+ AVPacket packet;
+
+ packet.data = nullptr;
+ packet.size = 0;
+
+ av_init_packet(&packet);
+
+ if(avcodec_encode_audio2(m_codecCtx, &packet, nullptr, &got_packet))
+ AUD_THROW(FileException, "File end couldn't be written, audio encoding failed with ffmpeg.");
+
+ if(got_packet)
+ {
+ packet.flags |= AV_PKT_FLAG_KEY;
+ packet.stream_index = m_stream->index;
+ if(av_write_frame(m_formatCtx, &packet))
+ {
+ av_free_packet(&packet);
+ AUD_THROW(FileException, "Final frames couldn't be writen to the file with ffmpeg.");
+ }
+ av_free_packet(&packet);
+ }
+ }
+}
+
+FFMPEGWriter::FFMPEGWriter(std::string filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate) :
+ m_position(0),
+ m_specs(specs),
+ m_input_samples(0),
+ m_deinterleave(false)
+{
+ static const char* formats[] = { nullptr, "ac3", "flac", "matroska", "mp2", "mp3", "ogg", "wav" };
+
+ if(avformat_alloc_output_context2(&m_formatCtx, nullptr, formats[format], filename.c_str()) < 0)
+ AUD_THROW(FileException, "File couldn't be written, format couldn't be found with ffmpeg.");
+
+ m_outputFmt = m_formatCtx->oformat;
+
+ if(!m_outputFmt) {
+ avformat_free_context(m_formatCtx);
+ AUD_THROW(FileException, "File couldn't be written, output format couldn't be found with ffmpeg.");
+ }
+
+ m_outputFmt->audio_codec = AV_CODEC_ID_NONE;
+
+ switch(codec)
+ {
+ case CODEC_AAC:
+ m_outputFmt->audio_codec = AV_CODEC_ID_AAC;
+ break;
+ case CODEC_AC3:
+ m_outputFmt->audio_codec = AV_CODEC_ID_AC3;
+ break;
+ case CODEC_FLAC:
+ m_outputFmt->audio_codec = AV_CODEC_ID_FLAC;
+ break;
+ case CODEC_MP2:
+ m_outputFmt->audio_codec = AV_CODEC_ID_MP2;
+ break;
+ case CODEC_MP3:
+ m_outputFmt->audio_codec = AV_CODEC_ID_MP3;
+ break;
+ case CODEC_OPUS:
+ m_outputFmt->audio_codec = AV_CODEC_ID_OPUS;
+ break;
+ case CODEC_PCM:
+ switch(specs.format)
+ {
+ case FORMAT_U8:
+ m_outputFmt->audio_codec = AV_CODEC_ID_PCM_U8;
+ break;
+ case FORMAT_S16:
+ m_outputFmt->audio_codec = AV_CODEC_ID_PCM_S16LE;
+ break;
+ case FORMAT_S24:
+ m_outputFmt->audio_codec = AV_CODEC_ID_PCM_S24LE;
+ break;
+ case FORMAT_S32:
+ m_outputFmt->audio_codec = AV_CODEC_ID_PCM_S32LE;
+ break;
+ case FORMAT_FLOAT32:
+ m_outputFmt->audio_codec = AV_CODEC_ID_PCM_F32LE;
+ break;
+ case FORMAT_FLOAT64:
+ m_outputFmt->audio_codec = AV_CODEC_ID_PCM_F64LE;
+ break;
+ default:
+ m_outputFmt->audio_codec = AV_CODEC_ID_NONE;
+ break;
+ }
+ break;
+ case CODEC_VORBIS:
+ m_outputFmt->audio_codec = AV_CODEC_ID_VORBIS;
+ break;
+ default:
+ m_outputFmt->audio_codec = AV_CODEC_ID_NONE;
+ break;
+ }
+
+ try
+ {
+ if(m_outputFmt->audio_codec == AV_CODEC_ID_NONE)
+ AUD_THROW(FileException, "File couldn't be written, audio codec not found with ffmpeg.");
+
+ AVCodec* codec = avcodec_find_encoder(m_outputFmt->audio_codec);
+ if(!codec)
+ AUD_THROW(FileException, "File couldn't be written, audio encoder couldn't be found with ffmpeg.");
+
+ m_stream = avformat_new_stream(m_formatCtx, codec);
+ if(!m_stream)
+ AUD_THROW(FileException, "File couldn't be written, stream creation failed with ffmpeg.");
+
+ m_stream->id = m_formatCtx->nb_streams - 1;
+
+ m_codecCtx = m_stream->codec;
+
+ switch(m_specs.format)
+ {
+ case FORMAT_U8:
+ m_convert = convert_float_u8;
+ m_codecCtx->sample_fmt = AV_SAMPLE_FMT_U8;
+ break;
+ case FORMAT_S16:
+ m_convert = convert_float_s16;
+ m_codecCtx->sample_fmt = AV_SAMPLE_FMT_S16;
+ break;
+ case FORMAT_S32:
+ m_convert = convert_float_s32;
+ m_codecCtx->sample_fmt = AV_SAMPLE_FMT_S32;
+ break;
+ case FORMAT_FLOAT64:
+ m_convert = convert_float_double;
+ m_codecCtx->sample_fmt = AV_SAMPLE_FMT_DBL;
+ break;
+ default:
+ m_convert = convert_copy<sample_t>;
+ m_codecCtx->sample_fmt = AV_SAMPLE_FMT_FLT;
+ break;
+ }
+
+ if(m_formatCtx->oformat->flags & AVFMT_GLOBALHEADER)
+ m_codecCtx->flags |= CODEC_FLAG_GLOBAL_HEADER;
+
+ bool format_supported = false;
+
+ for(int i = 0; codec->sample_fmts[i] != -1; i++)
+ {
+ if(av_get_alt_sample_fmt(codec->sample_fmts[i], false) == m_codecCtx->sample_fmt)
+ {
+ m_deinterleave = av_sample_fmt_is_planar(codec->sample_fmts[i]);
+ m_codecCtx->sample_fmt = codec->sample_fmts[i];
+ format_supported = true;
+ }
+ }
+
+ if(!format_supported)
+ {
+ int chosen_index = 0;
+ auto chosen = av_get_alt_sample_fmt(codec->sample_fmts[chosen_index], false);
+ for(int i = 1; codec->sample_fmts[i] != -1; i++)
+ {
+ auto fmt = av_get_alt_sample_fmt(codec->sample_fmts[i], false);
+ if((fmt > chosen && chosen < m_codecCtx->sample_fmt) || (fmt > m_codecCtx->sample_fmt && fmt < chosen))
+ {
+ chosen = fmt;
+ chosen_index = i;
+ }
+ }
+
+ m_codecCtx->sample_fmt = codec->sample_fmts[chosen_index];
+ m_deinterleave = av_sample_fmt_is_planar(m_codecCtx->sample_fmt);
+ switch(av_get_alt_sample_fmt(m_codecCtx->sample_fmt, false))
+ {
+ case AV_SAMPLE_FMT_U8:
+ specs.format = FORMAT_U8;
+ m_convert = convert_float_u8;
+ break;
+ case AV_SAMPLE_FMT_S16:
+ specs.format = FORMAT_S16;
+ m_convert = convert_float_s16;
+ break;
+ case AV_SAMPLE_FMT_S32:
+ specs.format = FORMAT_S32;
+ m_convert = convert_float_s32;
+ break;
+ case AV_SAMPLE_FMT_FLT:
+ specs.format = FORMAT_FLOAT32;
+ m_convert = convert_copy<sample_t>;
+ break;
+ case AV_SAMPLE_FMT_DBL:
+ specs.format = FORMAT_FLOAT64;
+ m_convert = convert_float_double;
+ break;
+ default:
+ AUD_THROW(FileException, "File couldn't be written, sample format not supported with ffmpeg.");
+ }
+ }
+
+ m_codecCtx->sample_rate = 0;
+
+ if(codec->supported_samplerates)
+ {
+ for(int i = 0; codec->supported_samplerates[i]; i++)
+ {
+ if(codec->supported_samplerates[i] == m_specs.rate)
+ {
+ m_codecCtx->sample_rate = codec->supported_samplerates[i];
+ break;
+ }
+ else if((codec->supported_samplerates[i] > m_codecCtx->sample_rate && m_specs.rate > m_codecCtx->sample_rate) ||
+ (codec->supported_samplerates[i] < m_codecCtx->sample_rate && m_specs.rate < codec->supported_samplerates[i]))
+ {
+ m_codecCtx->sample_rate = codec->supported_samplerates[i];
+ }
+ }
+ }
+
+ if(m_codecCtx->sample_rate == 0)
+ m_codecCtx->sample_rate = m_specs.rate;
+
+ m_specs.rate = m_codecCtx->sample_rate;
+
+ m_codecCtx->codec_id = m_outputFmt->audio_codec;
+ m_codecCtx->codec_type = AVMEDIA_TYPE_AUDIO;
+ m_codecCtx->bit_rate = bitrate;
+ m_codecCtx->channels = m_specs.channels;
+ m_stream->time_base.num = m_codecCtx->time_base.num = 1;
+ m_stream->time_base.den = m_codecCtx->time_base.den = m_codecCtx->sample_rate;
+
+ if(avcodec_open2(m_codecCtx, codec, nullptr) < 0)
+ AUD_THROW(FileException, "File couldn't be written, encoder couldn't be opened with ffmpeg.");
+
+ int samplesize = std::max(int(AUD_SAMPLE_SIZE(m_specs)), AUD_DEVICE_SAMPLE_SIZE(m_specs));
+
+ if((m_input_size = m_codecCtx->frame_size))
+ m_input_buffer.resize(m_input_size * samplesize);
+
+ if(avio_open(&m_formatCtx->pb, filename.c_str(), AVIO_FLAG_WRITE))
+ AUD_THROW(FileException, "File couldn't be written, file opening failed with ffmpeg.");
+
+ avformat_write_header(m_formatCtx, nullptr);
+ }
+ catch(Exception&)
+ {
+ avformat_free_context(m_formatCtx);
+ throw;
+ }
+}
+
+FFMPEGWriter::~FFMPEGWriter()
+{
+ // writte missing data
+ if(m_input_samples)
+ encode();
+
+ close();
+
+ av_write_trailer(m_formatCtx);
+
+ avcodec_close(m_codecCtx);
+
+ avio_close(m_formatCtx->pb);
+ avformat_free_context(m_formatCtx);
+}
+
+int FFMPEGWriter::getPosition() const
+{
+ return m_position;
+}
+
+DeviceSpecs FFMPEGWriter::getSpecs() const
+{
+ return m_specs;
+}
+
+void FFMPEGWriter::write(unsigned int length, sample_t* buffer)
+{
+ unsigned int samplesize = AUD_SAMPLE_SIZE(m_specs);
+
+ if(m_input_size)
+ {
+ sample_t* inbuf = m_input_buffer.getBuffer();
+
+ while(length)
+ {
+ unsigned int len = std::min(m_input_size - m_input_samples, length);
+
+ std::memcpy(inbuf + m_input_samples * m_specs.channels, buffer, len * samplesize);
+
+ buffer += len * m_specs.channels;
+ m_input_samples += len;
+ m_position += len;
+ length -= len;
+
+ if(m_input_samples == m_input_size)
+ {
+ encode();
+
+ m_input_samples = 0;
+ }
+ }
+ }
+ else // PCM data, can write directly!
+ {
+ int samplesize = AUD_SAMPLE_SIZE(m_specs);
+ m_input_buffer.assureSize(length * std::max(AUD_DEVICE_SAMPLE_SIZE(m_specs), samplesize));
+
+ sample_t* buf = m_input_buffer.getBuffer();
+ m_convert(reinterpret_cast<data_t*>(buf), reinterpret_cast<data_t*>(buffer), length * m_specs.channels);
+
+ m_input_samples = length;
+
+ m_position += length;
+
+ encode();
+ }
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.h b/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.h
new file mode 100644
index 00000000000..690185deb64
--- /dev/null
+++ b/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.h
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+#ifdef FFMPEG_PLUGIN
+#define AUD_BUILD_PLUGIN
+#endif
+
+/**
+ * @file FFMPEGWriter.h
+ * @ingroup plugin
+ * The FFMPEGWriter class.
+ */
+
+#include "respec/ConverterFunctions.h"
+#include "util/Buffer.h"
+#include "file/IWriter.h"
+
+#include <string>
+
+struct AVCodecContext;
+extern "C" {
+#include <libavformat/avformat.h>
+}
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This class writes a sound file via ffmpeg.
+ */
+class AUD_PLUGIN_API FFMPEGWriter : public IWriter
+{
+private:
+ /**
+ * The current position in samples.
+ */
+ int m_position;
+
+ /**
+ * The specification of the audio data.
+ */
+ DeviceSpecs m_specs;
+
+ /**
+ * The AVFormatContext structure for using ffmpeg.
+ */
+ AVFormatContext* m_formatCtx;
+
+ /**
+ * The AVCodecContext structure for using ffmpeg.
+ */
+ AVCodecContext* m_codecCtx;
+
+ /**
+ * The AVOutputFormat structure for using ffmpeg.
+ */
+ AVOutputFormat* m_outputFmt;
+
+ /**
+ * The AVStream structure for using ffmpeg.
+ */
+ AVStream* m_stream;
+
+ /**
+ * The input buffer for the format converted data before encoding.
+ */
+ Buffer m_input_buffer;
+
+ /**
+ * The buffer used for deinterleaving.
+ */
+ Buffer m_deinterleave_buffer;
+
+ /**
+ * The count of input samples we have so far.
+ */
+ unsigned int m_input_samples;
+
+ /**
+ * The count of input samples necessary to encode a packet.
+ */
+ unsigned int m_input_size;
+
+ /**
+ * Whether the ouput has to be deinterleaved before writing.
+ */
+ bool m_deinterleave;
+
+ /**
+ * Converter function.
+ */
+ convert_f m_convert;
+
+ // delete copy constructor and operator=
+ FFMPEGWriter(const FFMPEGWriter&) = delete;
+ FFMPEGWriter& operator=(const FFMPEGWriter&) = delete;
+
+ /**
+ * Encodes to the output buffer.
+ */
+ AUD_LOCAL void encode();
+
+ /**
+ * Finishes writing to the file.
+ */
+ AUD_LOCAL void close();
+
+public:
+ /**
+ * Creates a new writer.
+ * \param filename The path to the file to be read.
+ * \param specs The file's audio specification.
+ * \param format The file's container format.
+ * \param codec The codec used for encoding the audio data.
+ * \param bitrate The bitrate for encoding.
+ * \exception Exception Thrown if the file specified does not exist or
+ * cannot be read with ffmpeg.
+ */
+ FFMPEGWriter(std::string filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate);
+
+ /**
+ * Destroys the writer and closes the file.
+ */
+ virtual ~FFMPEGWriter();
+
+ virtual int getPosition() const;
+ virtual DeviceSpecs getSpecs() const;
+ virtual void write(unsigned int length, sample_t* buffer);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/plugins/jack/JackDevice.cpp b/extern/audaspace/plugins/jack/JackDevice.cpp
new file mode 100644
index 00000000000..1d238f74c3a
--- /dev/null
+++ b/extern/audaspace/plugins/jack/JackDevice.cpp
@@ -0,0 +1,385 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "JackDevice.h"
+#include "JackLibrary.h"
+#include "devices/DeviceManager.h"
+#include "devices/IDeviceFactory.h"
+#include "Exception.h"
+#include "IReader.h"
+
+#include <cstring>
+#include <algorithm>
+
+AUD_NAMESPACE_BEGIN
+
+void JackDevice::updateRingBuffers()
+{
+ size_t size, temp;
+ unsigned int samplesize = AUD_SAMPLE_SIZE(m_specs);
+ unsigned int i, j;
+ unsigned int channels = m_specs.channels;
+ sample_t* buffer = m_buffer.getBuffer();
+ float* deinterleave = m_deinterleavebuf.getBuffer();
+ jack_transport_state_t state;
+ jack_position_t position;
+
+ std::unique_lock<std::mutex> lock(m_mixingLock);
+
+ while(m_valid)
+ {
+ if(m_sync > 1)
+ {
+ if(m_syncFunc)
+ {
+ state = AUD_jack_transport_query(m_client, &position);
+ m_syncFunc(m_syncFuncData, state != JackTransportStopped, position.frame / (float) m_specs.rate);
+ }
+
+ for(i = 0; i < channels; i++)
+ AUD_jack_ringbuffer_reset(m_ringbuffers[i]);
+ }
+
+ size = AUD_jack_ringbuffer_write_space(m_ringbuffers[0]);
+ for(i = 1; i < channels; i++)
+ if((temp = AUD_jack_ringbuffer_write_space(m_ringbuffers[i])) < size)
+ size = temp;
+
+ while(size > samplesize)
+ {
+ size /= samplesize;
+ mix((data_t*)buffer, size);
+ for(i = 0; i < channels; i++)
+ {
+ for(j = 0; j < size; j++)
+ deinterleave[i * size + j] = buffer[i + j * channels];
+ AUD_jack_ringbuffer_write(m_ringbuffers[i], (char*)(deinterleave + i * size), size * sizeof(float));
+ }
+
+ size = AUD_jack_ringbuffer_write_space(m_ringbuffers[0]);
+ for(i = 1; i < channels; i++)
+ if((temp = AUD_jack_ringbuffer_write_space(m_ringbuffers[i])) < size)
+ size = temp;
+ }
+
+ if(m_sync > 1)
+ {
+ m_sync = 3;
+ }
+
+ m_mixingCondition.wait(lock);
+ }
+}
+
+int JackDevice::jack_mix(jack_nframes_t length, void* data)
+{
+ JackDevice* device = (JackDevice*)data;
+ unsigned int i;
+ int count = device->m_specs.channels;
+ char* buffer;
+
+ if(device->m_sync)
+ {
+ // play silence while syncing
+ for(unsigned int i = 0; i < count; i++)
+ std::memset(AUD_jack_port_get_buffer(device->m_ports[i], length), 0, length * sizeof(float));
+ }
+ else
+ {
+ size_t temp;
+ size_t readsamples = AUD_jack_ringbuffer_read_space(device->m_ringbuffers[0]);
+ for(i = 1; i < count; i++)
+ if((temp = AUD_jack_ringbuffer_read_space(device->m_ringbuffers[i])) < readsamples)
+ readsamples = temp;
+
+ readsamples = std::min(readsamples / sizeof(float), size_t(length));
+
+ for(unsigned int i = 0; i < count; i++)
+ {
+ buffer = (char*)AUD_jack_port_get_buffer(device->m_ports[i], length);
+ AUD_jack_ringbuffer_read(device->m_ringbuffers[i], buffer, readsamples * sizeof(float));
+ if(readsamples < length)
+ std::memset(buffer + readsamples * sizeof(float), 0, (length - readsamples) * sizeof(float));
+ }
+
+ if(device->m_mixingLock.try_lock())
+ {
+ device->m_mixingCondition.notify_all();
+ device->m_mixingLock.unlock();
+ }
+ }
+
+ return 0;
+}
+
+int JackDevice::jack_sync(jack_transport_state_t state, jack_position_t* pos, void* data)
+{
+ JackDevice* device = (JackDevice*)data;
+
+ if(state == JackTransportStopped)
+ return 1;
+
+ if(device->m_mixingLock.try_lock())
+ {
+ if(device->m_sync > 2)
+ {
+ if(device->m_sync == 3)
+ {
+ device->m_sync = 0;
+ device->m_mixingLock.unlock();
+ return 1;
+ }
+ }
+ else
+ {
+ device->m_sync = 2;
+ device->m_mixingCondition.notify_all();
+ }
+ device->m_mixingLock.unlock();
+ }
+ else if(!device->m_sync)
+ device->m_sync = 1;
+
+ return 0;
+}
+
+void JackDevice::jack_shutdown(void* data)
+{
+ JackDevice* device = (JackDevice*)data;
+ device->m_valid = false;
+}
+
+JackDevice::JackDevice(std::string name, DeviceSpecs specs, int buffersize) :
+ m_synchronizer(this)
+{
+ if(specs.channels == CHANNELS_INVALID)
+ specs.channels = CHANNELS_STEREO;
+
+ // jack uses floats
+ m_specs = specs;
+ m_specs.format = FORMAT_FLOAT32;
+
+ jack_options_t options = JackNullOption;
+ jack_status_t status;
+
+ // open client
+ m_client = AUD_jack_client_open(name.c_str(), options, &status);
+ if(m_client == nullptr)
+ AUD_THROW(DeviceException, "Connecting to the JACK server failed.");
+
+ // set callbacks
+ AUD_jack_set_process_callback(m_client, JackDevice::jack_mix, this);
+ AUD_jack_on_shutdown(m_client, JackDevice::jack_shutdown, this);
+ AUD_jack_set_sync_callback(m_client, JackDevice::jack_sync, this);
+
+ // register our output channels which are called ports in jack
+ m_ports = new jack_port_t*[m_specs.channels];
+
+ try
+ {
+ char portname[64];
+ for(int i = 0; i < m_specs.channels; i++)
+ {
+ sprintf(portname, "out %d", i+1);
+ m_ports[i] = AUD_jack_port_register(m_client, portname, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
+ if(m_ports[i] == nullptr)
+ AUD_THROW(DeviceException, "Registering output port with JACK failed.");
+ }
+ }
+ catch(Exception&)
+ {
+ AUD_jack_client_close(m_client);
+ delete[] m_ports;
+ throw;
+ }
+
+ m_specs.rate = (SampleRate)AUD_jack_get_sample_rate(m_client);
+
+ buffersize *= sizeof(sample_t);
+ m_ringbuffers = new jack_ringbuffer_t*[specs.channels];
+ for(unsigned int i = 0; i < specs.channels; i++)
+ m_ringbuffers[i] = AUD_jack_ringbuffer_create(buffersize);
+ buffersize *= specs.channels;
+ m_deinterleavebuf.resize(buffersize);
+ m_buffer.resize(buffersize);
+
+ create();
+
+ m_valid = true;
+ m_sync = 0;
+ m_syncFunc = nullptr;
+ m_nextState = m_state = AUD_jack_transport_query(m_client, nullptr);
+
+ // activate the client
+ if(AUD_jack_activate(m_client))
+ {
+ AUD_jack_client_close(m_client);
+ delete[] m_ports;
+ for(unsigned int i = 0; i < specs.channels; i++)
+ AUD_jack_ringbuffer_free(m_ringbuffers[i]);
+ delete[] m_ringbuffers;
+ destroy();
+
+ AUD_THROW(DeviceException, "Client activation with JACK failed.");
+ }
+
+ const char** ports = AUD_jack_get_ports(m_client, nullptr, nullptr,
+ JackPortIsPhysical | JackPortIsInput);
+ if(ports != nullptr)
+ {
+ for(int i = 0; i < m_specs.channels && ports[i]; i++)
+ AUD_jack_connect(m_client, AUD_jack_port_name(m_ports[i]), ports[i]);
+
+ AUD_jack_free(ports);
+ }
+
+ m_mixingThread = std::thread(&JackDevice::updateRingBuffers, this);
+}
+
+JackDevice::~JackDevice()
+{
+ if(m_valid)
+ AUD_jack_client_close(m_client);
+ m_valid = false;
+
+ delete[] m_ports;
+
+ m_mixingLock.lock();
+ m_mixingCondition.notify_all();
+ m_mixingLock.unlock();
+
+ m_mixingThread.join();
+
+ for(unsigned int i = 0; i < m_specs.channels; i++)
+ AUD_jack_ringbuffer_free(m_ringbuffers[i]);
+ delete[] m_ringbuffers;
+
+ destroy();
+}
+
+ISynchronizer* JackDevice::getSynchronizer()
+{
+ return &m_synchronizer;
+}
+
+void JackDevice::playing(bool playing)
+{
+ // Do nothing.
+}
+
+void JackDevice::startPlayback()
+{
+ AUD_jack_transport_start(m_client);
+ m_nextState = JackTransportRolling;
+}
+
+void JackDevice::stopPlayback()
+{
+ AUD_jack_transport_stop(m_client);
+ m_nextState = JackTransportStopped;
+}
+
+void JackDevice::seekPlayback(float time)
+{
+ if(time >= 0.0f)
+ AUD_jack_transport_locate(m_client, time * m_specs.rate);
+}
+
+void JackDevice::setSyncCallback(ISynchronizer::syncFunction sync, void* data)
+{
+ m_syncFunc = sync;
+ m_syncFuncData = data;
+}
+
+float JackDevice::getPlaybackPosition()
+{
+ jack_position_t position;
+ AUD_jack_transport_query(m_client, &position);
+ return position.frame / (float) m_specs.rate;
+}
+
+bool JackDevice::doesPlayback()
+{
+ jack_transport_state_t state = AUD_jack_transport_query(m_client, nullptr);
+
+ if(state != m_state)
+ m_nextState = m_state = state;
+
+ return m_nextState != JackTransportStopped;
+}
+
+class JackDeviceFactory : public IDeviceFactory
+{
+private:
+ DeviceSpecs m_specs;
+ int m_buffersize;
+ std::string m_name;
+
+public:
+ JackDeviceFactory() :
+ m_buffersize(AUD_DEFAULT_BUFFER_SIZE),
+ m_name("Audaspace")
+ {
+ m_specs.format = FORMAT_FLOAT32;
+ m_specs.channels = CHANNELS_STEREO;
+ m_specs.rate = RATE_48000;
+ }
+
+ virtual std::shared_ptr<IDevice> openDevice()
+ {
+ return std::shared_ptr<IDevice>(new JackDevice(m_name, m_specs, m_buffersize));
+ }
+
+ virtual int getPriority()
+ {
+ return 0;
+ }
+
+ virtual void setSpecs(DeviceSpecs specs)
+ {
+ m_specs = specs;
+ }
+
+ virtual void setBufferSize(int buffersize)
+ {
+ m_buffersize = buffersize;
+ }
+
+ virtual void setName(std::string name)
+ {
+ m_name = name;
+ }
+};
+
+void JackDevice::registerPlugin()
+{
+ if(loadJACK())
+ DeviceManager::registerDevice("JACK", std::shared_ptr<IDeviceFactory>(new JackDeviceFactory));
+}
+
+#ifdef JACK_PLUGIN
+extern "C" AUD_PLUGIN_API void registerPlugin()
+{
+ JackDevice::registerPlugin();
+}
+
+extern "C" AUD_PLUGIN_API const char* getName()
+{
+ return "JACK";
+}
+#endif
+
+AUD_NAMESPACE_END
diff --git a/intern/audaspace/jack/AUD_JackDevice.h b/extern/audaspace/plugins/jack/JackDevice.h
index ccf3bfd6341..72143eda149 100644
--- a/intern/audaspace/jack/AUD_JackDevice.h
+++ b/extern/audaspace/plugins/jack/JackDevice.h
@@ -1,49 +1,47 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
*
- * Copyright 2009-2011 Jörg Hermann Müller
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * This file is part of AudaSpace.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * 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 *****
- */
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
-/** \file audaspace/jack/AUD_JackDevice.h
- * \ingroup audjack
- */
+#pragma once
+#ifdef JACK_PLUGIN
+#define AUD_BUILD_PLUGIN
+#endif
-#ifndef __AUD_JACKDEVICE_H__
-#define __AUD_JACKDEVICE_H__
-
+/**
+ * @file JackDevice.h
+ * @ingroup plugin
+ * The JackDevice class.
+ */
-#include "AUD_SoftwareDevice.h"
-#include "AUD_Buffer.h"
+#include "JackSynchronizer.h"
+#include "devices/SoftwareDevice.h"
+#include "util/Buffer.h"
#include <string>
+#include <condition_variable>
+#include <thread>
+#include <jack/jack.h>
+#include <jack/ringbuffer.h>
-#include <AUD_JackLibrary.h>
-
-typedef void (*AUD_syncFunction)(void*, int, float);
+AUD_NAMESPACE_BEGIN
/**
* This device plays back through JACK.
*/
-class AUD_JackDevice : public AUD_SoftwareDevice
+class AUD_PLUGIN_API JackDevice : public SoftwareDevice
{
private:
/**
@@ -59,12 +57,12 @@ private:
/**
* The output buffer.
*/
- AUD_Buffer m_buffer;
+ Buffer m_buffer;
/**
* The deinterleaving buffer.
*/
- AUD_Buffer m_deinterleavebuf;
+ Buffer m_deinterleavebuf;
jack_ringbuffer_t** m_ringbuffers;
@@ -73,11 +71,14 @@ private:
*/
bool m_valid;
+ /// Synchronizer.
+ JackSynchronizer m_synchronizer;
+
/**
* Invalidates the jack device.
* \param data The jack device that gets invalidet by jack.
*/
- static void jack_shutdown(void *data);
+ AUD_LOCAL static void jack_shutdown(void* data);
/**
* Mixes the next bytes into the buffer.
@@ -85,9 +86,9 @@ private:
* \param data A pointer to the jack device.
* \return 0 what shows success.
*/
- static int jack_mix(jack_nframes_t length, void *data);
+ AUD_LOCAL static int jack_mix(jack_nframes_t length, void* data);
- static int jack_sync(jack_transport_state_t state, jack_position_t* pos, void* data);
+ AUD_LOCAL static int jack_sync(jack_transport_state_t state, jack_position_t* pos, void* data);
/**
* Next JACK Transport state (-1 if not expected to change).
@@ -107,7 +108,7 @@ private:
/**
* External syncronisation callback function.
*/
- AUD_syncFunction m_syncFunc;
+ ISynchronizer::syncFunction m_syncFunc;
/**
* Data for the sync function.
@@ -117,33 +118,26 @@ private:
/**
* The mixing thread.
*/
- pthread_t m_mixingThread;
+ std::thread m_mixingThread;
/**
* Mutex for mixing.
*/
- pthread_mutex_t m_mixingLock;
+ std::mutex m_mixingLock;
/**
* Condition for mixing.
*/
- pthread_cond_t m_mixingCondition;
-
- /**
- * Mixing thread function.
- * \param device The this pointer.
- * \return NULL.
- */
- static void* runMixingThread(void* device);
+ std::condition_variable m_mixingCondition;
/**
* Updates the ring buffers.
*/
- void updateRingBuffers();
+ AUD_LOCAL void updateRingBuffers();
- // hide copy constructor and operator=
- AUD_JackDevice(const AUD_JackDevice&);
- AUD_JackDevice& operator=(const AUD_JackDevice&);
+ // delete copy constructor and operator=
+ JackDevice(const JackDevice&) = delete;
+ JackDevice& operator=(const JackDevice&) = delete;
protected:
virtual void playing(bool playing);
@@ -155,14 +149,16 @@ public:
* \param specs The wanted audio specification, where only the channel count
* is important.
* \param buffersize The size of the internal buffer.
- * \exception AUD_Exception Thrown if the audio device cannot be opened.
+ * \exception Exception Thrown if the audio device cannot be opened.
*/
- AUD_JackDevice(std::string name, AUD_DeviceSpecs specs, int buffersize = AUD_DEFAULT_BUFFER_SIZE);
+ JackDevice(std::string name, DeviceSpecs specs, int buffersize = AUD_DEFAULT_BUFFER_SIZE);
/**
* Closes the JACK client.
*/
- virtual ~AUD_JackDevice();
+ virtual ~JackDevice();
+
+ virtual ISynchronizer* getSynchronizer();
/**
* Starts jack transport playback.
@@ -185,7 +181,7 @@ public:
* \param sync The callback function.
* \param data The data for the function.
*/
- void setSyncCallback(AUD_syncFunction sync, void* data);
+ void setSyncCallback(ISynchronizer::syncFunction sync, void* data);
/**
* Retrieves the jack transport playback time.
@@ -198,6 +194,11 @@ public:
* \return Whether jack transport plays back.
*/
bool doesPlayback();
+
+ /**
+ * Registers this plugin.
+ */
+ static void registerPlugin();
};
-#endif //__AUD_JACKDEVICE_H__
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/plugins/jack/JackLibrary.cpp b/extern/audaspace/plugins/jack/JackLibrary.cpp
new file mode 100644
index 00000000000..92462a34cca
--- /dev/null
+++ b/extern/audaspace/plugins/jack/JackLibrary.cpp
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#define JACK_LIBRARY_IMPLEMENTATION
+
+#include <string>
+#include <array>
+
+#include "JackLibrary.h"
+
+#ifdef DYNLOAD_JACK
+#include "plugin/PluginManager.h"
+#endif
+
+AUD_NAMESPACE_BEGIN
+
+bool loadJACK()
+{
+#ifdef DYNLOAD_JACK
+ std::array<const std::string, 5> names = {"libjack.so", "libjack.so.0", "libjack.so.1", "libjack.so.2", "libjack.dll"};
+
+ void* handle = nullptr;
+
+ for(auto& name : names)
+ {
+ handle = PluginManager::openLibrary(name);
+ if(handle)
+ break;
+ }
+
+ if (!handle)
+ return false;
+
+#define JACK_SYMBOL(sym) AUD_##sym = reinterpret_cast<decltype(&sym)>(PluginManager::lookupLibrary(handle, #sym))
+#else
+#define JACK_SYMBOL(sym) AUD_##sym = &sym
+#endif
+
+#include "JackSymbols.h"
+
+#undef JACK_SYMBOL
+
+ return AUD_jack_client_open != nullptr;
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/plugins/jack/JackLibrary.h b/extern/audaspace/plugins/jack/JackLibrary.h
new file mode 100644
index 00000000000..4e210852702
--- /dev/null
+++ b/extern/audaspace/plugins/jack/JackLibrary.h
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+#ifdef JACK_PLUGIN
+#define AUD_BUILD_PLUGIN
+#endif
+
+/**
+ * @file JackDevice.h
+ * @ingroup plugin
+ * The JackDevice class.
+ */
+
+#include "Audaspace.h"
+
+#include <jack/jack.h>
+#include <jack/ringbuffer.h>
+
+AUD_NAMESPACE_BEGIN
+
+#ifdef JACK_LIBRARY_IMPLEMENTATION
+#define JACK_SYMBOL(sym) decltype(&sym) AUD_##sym
+#else
+#define JACK_SYMBOL(sym) extern decltype(&sym) AUD_##sym
+#endif
+
+#include "JackSymbols.h"
+
+#undef JACK_SYMBOL
+
+bool loadJACK();
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/plugins/jack/JackSymbols.h b/extern/audaspace/plugins/jack/JackSymbols.h
new file mode 100644
index 00000000000..f8e22a7da34
--- /dev/null
+++ b/extern/audaspace/plugins/jack/JackSymbols.h
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+JACK_SYMBOL(jack_transport_query);
+JACK_SYMBOL(jack_transport_locate);
+
+JACK_SYMBOL(jack_transport_start);
+JACK_SYMBOL(jack_transport_stop);
+
+JACK_SYMBOL(jack_ringbuffer_reset);
+JACK_SYMBOL(jack_ringbuffer_write);
+JACK_SYMBOL(jack_ringbuffer_write_space);
+JACK_SYMBOL(jack_ringbuffer_write_advance);
+JACK_SYMBOL(jack_ringbuffer_read);
+JACK_SYMBOL(jack_ringbuffer_create);
+JACK_SYMBOL(jack_ringbuffer_free);
+JACK_SYMBOL(jack_ringbuffer_read_space);
+JACK_SYMBOL(jack_set_sync_callback);
+
+JACK_SYMBOL(jack_port_get_buffer);
+
+JACK_SYMBOL(jack_client_open);
+JACK_SYMBOL(jack_set_process_callback);
+JACK_SYMBOL(jack_on_shutdown);
+JACK_SYMBOL(jack_port_register);
+JACK_SYMBOL(jack_client_close);
+JACK_SYMBOL(jack_get_sample_rate);
+JACK_SYMBOL(jack_activate);
+JACK_SYMBOL(jack_get_ports);
+JACK_SYMBOL(jack_port_name);
+JACK_SYMBOL(jack_connect);
+JACK_SYMBOL(jack_free);
diff --git a/extern/audaspace/plugins/jack/JackSynchronizer.cpp b/extern/audaspace/plugins/jack/JackSynchronizer.cpp
new file mode 100644
index 00000000000..cd4c448786d
--- /dev/null
+++ b/extern/audaspace/plugins/jack/JackSynchronizer.cpp
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "JackSynchronizer.h"
+
+#include "JackDevice.h"
+
+AUD_NAMESPACE_BEGIN
+
+JackSynchronizer::JackSynchronizer(JackDevice* device) :
+ m_device(device)
+{
+}
+
+void JackSynchronizer::seek(std::shared_ptr<IHandle> handle, float time)
+{
+ m_device->seekPlayback(time);
+}
+
+float JackSynchronizer::getPosition(std::shared_ptr<IHandle> handle)
+{
+ return m_device->getPlaybackPosition();
+}
+
+void JackSynchronizer::play()
+{
+ m_device->startPlayback();
+}
+
+void JackSynchronizer::stop()
+{
+ m_device->stopPlayback();
+}
+
+void JackSynchronizer::setSyncCallback(ISynchronizer::syncFunction function, void* data)
+{
+ m_device->setSyncCallback(function, data);
+}
+
+int JackSynchronizer::isPlaying()
+{
+ return m_device->doesPlayback();
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/plugins/jack/JackSynchronizer.h b/extern/audaspace/plugins/jack/JackSynchronizer.h
new file mode 100644
index 00000000000..5c7341a7872
--- /dev/null
+++ b/extern/audaspace/plugins/jack/JackSynchronizer.h
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+#ifdef JACK_PLUGIN
+#define AUD_BUILD_PLUGIN
+#endif
+
+/**
+ * @file JackSynchronizer.h
+ * @ingroup plugin
+ * The JackSynchronizer class.
+ */
+
+#include "devices/ISynchronizer.h"
+
+AUD_NAMESPACE_BEGIN
+
+class JackDevice;
+
+/**
+ * This class is a Synchronizer implementation using JACK Transport.
+ */
+class AUD_PLUGIN_API JackSynchronizer : public ISynchronizer
+{
+private:
+ /// The device that is being synchronized.
+ JackDevice* m_device;
+
+public:
+ /**
+ * Creates a new JackSynchronizer.
+ * @param device The device that should be synchronized.
+ */
+ JackSynchronizer(JackDevice* device);
+
+ virtual void seek(std::shared_ptr<IHandle> handle, float time);
+ virtual float getPosition(std::shared_ptr<IHandle> handle);
+ virtual void play();
+ virtual void stop();
+ virtual void setSyncCallback(syncFunction function, void* data);
+ virtual int isPlaying();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/plugins/libsndfile/SndFile.cpp b/extern/audaspace/plugins/libsndfile/SndFile.cpp
new file mode 100644
index 00000000000..ba4ff24ad68
--- /dev/null
+++ b/extern/audaspace/plugins/libsndfile/SndFile.cpp
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "SndFile.h"
+#include "SndFileReader.h"
+#include "SndFileWriter.h"
+#include "file/FileManager.h"
+
+AUD_NAMESPACE_BEGIN
+
+SndFile::SndFile()
+{
+}
+
+void SndFile::registerPlugin()
+{
+ std::shared_ptr<SndFile> plugin = std::shared_ptr<SndFile>(new SndFile);
+ FileManager::registerInput(plugin);
+ FileManager::registerOutput(plugin);
+}
+
+std::shared_ptr<IReader> SndFile::createReader(std::string filename)
+{
+ return std::shared_ptr<IReader>(new SndFileReader(filename));
+}
+
+std::shared_ptr<IReader> SndFile::createReader(std::shared_ptr<Buffer> buffer)
+{
+ return std::shared_ptr<IReader>(new SndFileReader(buffer));
+}
+
+std::shared_ptr<IWriter> SndFile::createWriter(std::string filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate)
+{
+ return std::shared_ptr<IWriter>(new SndFileWriter(filename, specs, format, codec, bitrate));
+}
+
+#ifdef LIBSNDFILE_PLUGIN
+extern "C" AUD_PLUGIN_API void registerPlugin()
+{
+ SndFile::registerPlugin();
+}
+
+extern "C" AUD_PLUGIN_API const char* getName()
+{
+ return "LibSndFile";
+}
+#endif
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/plugins/libsndfile/SndFile.h b/extern/audaspace/plugins/libsndfile/SndFile.h
new file mode 100644
index 00000000000..61afed1d564
--- /dev/null
+++ b/extern/audaspace/plugins/libsndfile/SndFile.h
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+#ifdef LIBSNDFILE_PLUGIN
+#define AUD_BUILD_PLUGIN
+#endif
+
+/**
+ * @file SndFile.h
+ * @ingroup plugin
+ * The SndFile class.
+ */
+
+#include "file/IFileInput.h"
+#include "file/IFileOutput.h"
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This plugin class reads and writes sounds via libsndfile.
+ */
+class AUD_PLUGIN_API SndFile : public IFileInput, public IFileOutput
+{
+private:
+ // delete copy constructor and operator=
+ SndFile(const SndFile&) = delete;
+ SndFile& operator=(const SndFile&) = delete;
+
+public:
+ /**
+ * Creates a new libsndfile plugin.
+ */
+ SndFile();
+
+ /**
+ * Registers this plugin.
+ */
+ static void registerPlugin();
+
+ virtual std::shared_ptr<IReader> createReader(std::string filename);
+ virtual std::shared_ptr<IReader> createReader(std::shared_ptr<Buffer> buffer);
+ virtual std::shared_ptr<IWriter> createWriter(std::string filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/plugins/libsndfile/SndFileReader.cpp b/extern/audaspace/plugins/libsndfile/SndFileReader.cpp
new file mode 100644
index 00000000000..d2d89814c07
--- /dev/null
+++ b/extern/audaspace/plugins/libsndfile/SndFileReader.cpp
@@ -0,0 +1,161 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "SndFileReader.h"
+#include "util/Buffer.h"
+#include "Exception.h"
+
+#include <cstring>
+
+AUD_NAMESPACE_BEGIN
+
+sf_count_t SndFileReader::vio_get_filelen(void* user_data)
+{
+ SndFileReader* reader = (SndFileReader*)user_data;
+ return reader->m_membuffer->getSize();
+}
+
+sf_count_t SndFileReader::vio_seek(sf_count_t offset, int whence,
+ void* user_data)
+{
+ SndFileReader* reader = (SndFileReader*)user_data;
+
+ switch(whence)
+ {
+ case SEEK_SET:
+ reader->m_memoffset = offset;
+ break;
+ case SEEK_CUR:
+ reader->m_memoffset = reader->m_memoffset + offset;
+ break;
+ case SEEK_END:
+ reader->m_memoffset = reader->m_membuffer->getSize() + offset;
+ break;
+ }
+
+ return reader->m_memoffset;
+}
+
+sf_count_t SndFileReader::vio_read(void* ptr, sf_count_t count,
+ void* user_data)
+{
+ SndFileReader* reader = (SndFileReader*)user_data;
+
+ if(reader->m_memoffset + count > reader->m_membuffer->getSize())
+ count = reader->m_membuffer->getSize() - reader->m_memoffset;
+
+ std::memcpy(ptr, ((data_t*)reader->m_membuffer->getBuffer()) +
+ reader->m_memoffset, count);
+ reader->m_memoffset += count;
+
+ return count;
+}
+
+sf_count_t SndFileReader::vio_tell(void* user_data)
+{
+ SndFileReader* reader = (SndFileReader*)user_data;
+
+ return reader->m_memoffset;
+}
+
+SndFileReader::SndFileReader(std::string filename) :
+ m_position(0)
+{
+ SF_INFO sfinfo;
+
+ sfinfo.format = 0;
+ m_sndfile = sf_open(filename.c_str(), SFM_READ, &sfinfo);
+
+ if(!m_sndfile)
+ AUD_THROW(FileException, "The file couldn't be opened with libsndfile.");
+
+ m_specs.channels = (Channels) sfinfo.channels;
+ m_specs.rate = (SampleRate) sfinfo.samplerate;
+ m_length = sfinfo.frames;
+ m_seekable = sfinfo.seekable;
+}
+
+SndFileReader::SndFileReader(std::shared_ptr<Buffer> buffer) :
+ m_position(0),
+ m_membuffer(buffer),
+ m_memoffset(0)
+{
+ m_vio.get_filelen = vio_get_filelen;
+ m_vio.read = vio_read;
+ m_vio.seek = vio_seek;
+ m_vio.tell = vio_tell;
+ m_vio.write = nullptr;
+
+ SF_INFO sfinfo;
+
+ sfinfo.format = 0;
+ m_sndfile = sf_open_virtual(&m_vio, SFM_READ, &sfinfo, this);
+
+ if(!m_sndfile)
+ AUD_THROW(FileException, "The buffer couldn't be read with libsndfile.");
+
+ m_specs.channels = (Channels) sfinfo.channels;
+ m_specs.rate = (SampleRate) sfinfo.samplerate;
+ m_length = sfinfo.frames;
+ m_seekable = sfinfo.seekable;
+}
+
+SndFileReader::~SndFileReader()
+{
+ sf_close(m_sndfile);
+}
+
+bool SndFileReader::isSeekable() const
+{
+ return m_seekable;
+}
+
+void SndFileReader::seek(int position)
+{
+ if(m_seekable)
+ {
+ position = sf_seek(m_sndfile, position, SEEK_SET);
+ m_position = position;
+ }
+}
+
+int SndFileReader::getLength() const
+{
+ return m_length;
+}
+
+int SndFileReader::getPosition() const
+{
+ return m_position;
+}
+
+Specs SndFileReader::getSpecs() const
+{
+ return m_specs;
+}
+
+void SndFileReader::read(int& length, bool& eos, sample_t* buffer)
+{
+ int olen = length;
+
+ length = sf_readf_float(m_sndfile, buffer, length);
+
+ m_position += length;
+
+ eos = length < olen;
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/plugins/libsndfile/SndFileReader.h b/extern/audaspace/plugins/libsndfile/SndFileReader.h
new file mode 100644
index 00000000000..081c29c686c
--- /dev/null
+++ b/extern/audaspace/plugins/libsndfile/SndFileReader.h
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+#include "IReader.h"
+
+#ifdef LIBSNDFILE_PLUGIN
+#define AUD_BUILD_PLUGIN
+#endif
+
+/**
+ * @file SndFileReader.h
+ * @ingroup plugin
+ * The SndFileReader class.
+ */
+
+#include <string>
+#include <sndfile.h>
+#include <memory>
+
+AUD_NAMESPACE_BEGIN
+
+class Buffer;
+
+/**
+ * This class reads a sound file via libsndfile.
+ */
+class AUD_PLUGIN_API SndFileReader : public IReader
+{
+private:
+ /**
+ * The current position in samples.
+ */
+ int m_position;
+
+ /**
+ * The sample count in the file.
+ */
+ int m_length;
+
+ /**
+ * Whether the file is seekable.
+ */
+ bool m_seekable;
+
+ /**
+ * The specification of the audio data.
+ */
+ Specs m_specs;
+
+ /**
+ * The sndfile.
+ */
+ SNDFILE* m_sndfile;
+
+ /**
+ * The virtual IO structure for memory file reading.
+ */
+ SF_VIRTUAL_IO m_vio;
+
+ /**
+ * The pointer to the memory file.
+ */
+ std::shared_ptr<Buffer> m_membuffer;
+
+ /**
+ * The current reading pointer of the memory file.
+ */
+ int m_memoffset;
+
+ // Functions for libsndfile virtual IO functionality
+ AUD_LOCAL static sf_count_t vio_get_filelen(void* user_data);
+ AUD_LOCAL static sf_count_t vio_seek(sf_count_t offset, int whence, void* user_data);
+ AUD_LOCAL static sf_count_t vio_read(void* ptr, sf_count_t count, void* user_data);
+ AUD_LOCAL static sf_count_t vio_tell(void* user_data);
+
+ // delete copy constructor and operator=
+ SndFileReader(const SndFileReader&) = delete;
+ SndFileReader& operator=(const SndFileReader&) = delete;
+
+public:
+ /**
+ * Creates a new reader.
+ * \param filename The path to the file to be read.
+ * \exception Exception Thrown if the file specified does not exist or
+ * cannot be read with libsndfile.
+ */
+ SndFileReader(std::string filename);
+
+ /**
+ * Creates a new reader.
+ * \param buffer The buffer to read from.
+ * \exception Exception Thrown if the buffer specified cannot be read
+ * with libsndfile.
+ */
+ SndFileReader(std::shared_ptr<Buffer> buffer);
+
+ /**
+ * Destroys the reader and closes the file.
+ */
+ virtual ~SndFileReader();
+
+ virtual bool isSeekable() const;
+ virtual void seek(int position);
+ virtual int getLength() const;
+ virtual int getPosition() const;
+ virtual Specs getSpecs() const;
+ virtual void read(int& length, bool& eos, sample_t* buffer);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/plugins/libsndfile/SndFileWriter.cpp b/extern/audaspace/plugins/libsndfile/SndFileWriter.cpp
new file mode 100644
index 00000000000..d2ab117132d
--- /dev/null
+++ b/extern/audaspace/plugins/libsndfile/SndFileWriter.cpp
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "SndFileWriter.h"
+#include "Exception.h"
+
+#include <cstring>
+
+AUD_NAMESPACE_BEGIN
+
+SndFileWriter::SndFileWriter(std::string filename, DeviceSpecs specs,
+ Container format, Codec codec, unsigned int bitrate) :
+ m_position(0), m_specs(specs)
+{
+ SF_INFO sfinfo;
+
+ sfinfo.channels = specs.channels;
+ sfinfo.samplerate = int(specs.rate);
+
+ switch(format)
+ {
+ case CONTAINER_FLAC:
+ sfinfo.format = SF_FORMAT_FLAC;
+ switch(specs.format)
+ {
+ case FORMAT_S16:
+ sfinfo.format |= SF_FORMAT_PCM_16;
+ break;
+ case FORMAT_S24:
+ sfinfo.format |= SF_FORMAT_PCM_24;
+ break;
+ case FORMAT_S32:
+ sfinfo.format |= SF_FORMAT_PCM_32;
+ break;
+ case FORMAT_FLOAT32:
+ sfinfo.format |= SF_FORMAT_FLOAT;
+ break;
+ case FORMAT_FLOAT64:
+ sfinfo.format |= SF_FORMAT_DOUBLE;
+ break;
+ default:
+ sfinfo.format = 0;
+ break;
+ }
+ break;
+ case CONTAINER_OGG:
+ if(codec == CODEC_VORBIS)
+ sfinfo.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS;
+ else
+ sfinfo.format = 0;
+ break;
+ case CONTAINER_WAV:
+ sfinfo.format = SF_FORMAT_WAV;
+ switch(specs.format)
+ {
+ case FORMAT_U8:
+ sfinfo.format |= SF_FORMAT_PCM_U8;
+ break;
+ case FORMAT_S16:
+ sfinfo.format |= SF_FORMAT_PCM_16;
+ break;
+ case FORMAT_S24:
+ sfinfo.format |= SF_FORMAT_PCM_24;
+ break;
+ case FORMAT_S32:
+ sfinfo.format |= SF_FORMAT_PCM_32;
+ break;
+ case FORMAT_FLOAT32:
+ sfinfo.format |= SF_FORMAT_FLOAT;
+ break;
+ case FORMAT_FLOAT64:
+ sfinfo.format |= SF_FORMAT_DOUBLE;
+ break;
+ default:
+ sfinfo.format = 0;
+ break;
+ }
+ break;
+ default:
+ sfinfo.format = 0;
+ break;
+ }
+
+ if(sfinfo.format == 0)
+ AUD_THROW(FileException, "This format couldn't be written with libsndfile.");
+
+ m_sndfile = sf_open(filename.c_str(), SFM_WRITE, &sfinfo);
+
+ if(!m_sndfile)
+ AUD_THROW(FileException, "The file couldn't be written with libsndfile.");
+}
+
+SndFileWriter::~SndFileWriter()
+{
+ sf_close(m_sndfile);
+}
+
+int SndFileWriter::getPosition() const
+{
+ return m_position;
+}
+
+DeviceSpecs SndFileWriter::getSpecs() const
+{
+ return m_specs;
+}
+
+void SndFileWriter::write(unsigned int length, sample_t* buffer)
+{
+ length = sf_writef_float(m_sndfile, buffer, length);
+
+ m_position += length;
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/plugins/libsndfile/SndFileWriter.h b/extern/audaspace/plugins/libsndfile/SndFileWriter.h
new file mode 100644
index 00000000000..75d761f5163
--- /dev/null
+++ b/extern/audaspace/plugins/libsndfile/SndFileWriter.h
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+#ifdef LIBSNDFILE_PLUGIN
+#define AUD_BUILD_PLUGIN
+#endif
+
+/**
+ * @file SndFileWriter.h
+ * @ingroup plugin
+ * The SndFileWriter class.
+ */
+
+#include "file/IWriter.h"
+
+#include <string>
+#include <sndfile.h>
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This class writes a sound file via libsndfile.
+ */
+class AUD_PLUGIN_API SndFileWriter : public IWriter
+{
+private:
+ /**
+ * The current position in samples.
+ */
+ int m_position;
+
+ /**
+ * The specification of the audio data.
+ */
+ DeviceSpecs m_specs;
+
+ /**
+ * The sndfile.
+ */
+ SNDFILE* m_sndfile;
+
+ // delete copy constructor and operator=
+ SndFileWriter(const SndFileWriter&) = delete;
+ SndFileWriter& operator=(const SndFileWriter&) = delete;
+
+public:
+ /**
+ * Creates a new writer.
+ * \param filename The path to the file to be read.
+ * \param specs The file's audio specification.
+ * \param format The file's container format.
+ * \param codec The codec used for encoding the audio data.
+ * \param bitrate The bitrate for encoding.
+ * \exception Exception Thrown if the file specified cannot be written
+ * with libsndfile.
+ */
+ SndFileWriter(std::string filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate);
+
+ /**
+ * Destroys the writer and closes the file.
+ */
+ virtual ~SndFileWriter();
+
+ virtual int getPosition() const;
+ virtual DeviceSpecs getSpecs() const;
+ virtual void write(unsigned int length, sample_t* buffer);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/plugins/openal/OpenALDevice.cpp b/extern/audaspace/plugins/openal/OpenALDevice.cpp
new file mode 100644
index 00000000000..2a609789a6d
--- /dev/null
+++ b/extern/audaspace/plugins/openal/OpenALDevice.cpp
@@ -0,0 +1,1490 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "OpenALDevice.h"
+#include "devices/DeviceManager.h"
+#include "devices/IDeviceFactory.h"
+#include "respec/ConverterReader.h"
+#include "Exception.h"
+#include "ISound.h"
+
+#include <chrono>
+#include <cstring>
+#include <iostream>
+
+AUD_NAMESPACE_BEGIN
+
+/******************************************************************************/
+/*********************** OpenALHandle Handle Code *************************/
+/******************************************************************************/
+
+bool OpenALDevice::OpenALHandle::pause(bool keep)
+{
+ if(m_status)
+ {
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(m_status == STATUS_PLAYING)
+ {
+ for(auto it = m_device->m_playingSounds.begin(); it != m_device->m_playingSounds.end(); it++)
+ {
+ if(it->get() == this)
+ {
+ std::shared_ptr<OpenALHandle> This = *it;
+
+ m_device->m_playingSounds.erase(it);
+ m_device->m_pausedSounds.push_back(This);
+
+ alSourcePause(m_source);
+
+ m_status = keep ? STATUS_STOPPED : STATUS_PAUSED;
+
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
+OpenALDevice::OpenALHandle::OpenALHandle(OpenALDevice* device, ALenum format, std::shared_ptr<IReader> reader, bool keep) :
+ m_isBuffered(false), m_reader(reader), m_keep(keep), m_format(format),
+ m_eos(false), m_loopcount(0), m_stop(nullptr), m_stop_data(nullptr), m_status(STATUS_PLAYING),
+ m_device(device)
+{
+ DeviceSpecs specs = m_device->m_specs;
+ specs.specs = m_reader->getSpecs();
+
+ // OpenAL playback code
+ alGenBuffers(CYCLE_BUFFERS, m_buffers);
+ if(alGetError() != AL_NO_ERROR)
+ AUD_THROW(DeviceException, "Buffer generation failed while staring playback with OpenAL.");
+
+ try
+ {
+ m_device->m_buffer.assureSize(m_device->m_buffersize * AUD_DEVICE_SAMPLE_SIZE(specs));
+ int length;
+ bool eos;
+
+ for(m_current = 0; m_current < CYCLE_BUFFERS; m_current++)
+ {
+ length = m_device->m_buffersize;
+ reader->read(length, eos, m_device->m_buffer.getBuffer());
+
+ if(length == 0)
+ break;
+
+ alBufferData(m_buffers[m_current], m_format, m_device->m_buffer.getBuffer(), length * AUD_DEVICE_SAMPLE_SIZE(specs), specs.rate);
+
+ if(alGetError() != AL_NO_ERROR)
+ AUD_THROW(DeviceException, "Filling the buffer with data failed while starting playback with OpenAL.");
+ }
+
+ alGenSources(1, &m_source);
+ if(alGetError() != AL_NO_ERROR)
+ AUD_THROW(DeviceException, "Source generation failed while starting playback with OpenAL.");
+
+ try
+ {
+ alSourceQueueBuffers(m_source, m_current, m_buffers);
+ if(alGetError() != AL_NO_ERROR)
+ AUD_THROW(DeviceException, "Buffer queuing failed while starting playback with OpenAL.");
+ }
+ catch(Exception&)
+ {
+ alDeleteSources(1, &m_source);
+ throw;
+ }
+ }
+ catch(Exception&)
+ {
+ alDeleteBuffers(CYCLE_BUFFERS, m_buffers);
+ throw;
+ }
+ alSourcei(m_source, AL_SOURCE_RELATIVE, 1);
+}
+
+bool OpenALDevice::OpenALHandle::pause()
+{
+ return pause(false);
+}
+
+bool OpenALDevice::OpenALHandle::resume()
+{
+ if(m_status)
+ {
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(m_status == STATUS_PAUSED)
+ {
+ for(auto it = m_device->m_pausedSounds.begin(); it != m_device->m_pausedSounds.end(); it++)
+ {
+ if(it->get() == this)
+ {
+ std::shared_ptr<OpenALHandle> This = *it;
+
+ m_device->m_pausedSounds.erase(it);
+ m_device->m_playingSounds.push_back(This);
+
+ m_device->start();
+ m_status = STATUS_PLAYING;
+
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
+bool OpenALDevice::OpenALHandle::stop()
+{
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return false;
+
+ m_status = STATUS_INVALID;
+
+ alDeleteSources(1, &m_source);
+ if(!m_isBuffered)
+ alDeleteBuffers(CYCLE_BUFFERS, m_buffers);
+
+ for(auto it = m_device->m_playingSounds.begin(); it != m_device->m_playingSounds.end(); it++)
+ {
+ if(it->get() == this)
+ {
+ std::shared_ptr<OpenALHandle> This = *it;
+
+ m_device->m_playingSounds.erase(it);
+
+ return true;
+ }
+ }
+
+ for(auto it = m_device->m_pausedSounds.begin(); it != m_device->m_pausedSounds.end(); it++)
+ {
+ if(it->get() == this)
+ {
+ std::shared_ptr<OpenALHandle> This = *it;
+
+ m_device->m_pausedSounds.erase(it);
+
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool OpenALDevice::OpenALHandle::getKeep()
+{
+ if(m_status)
+ return m_keep;
+
+ return false;
+}
+
+bool OpenALDevice::OpenALHandle::setKeep(bool keep)
+{
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return false;
+
+ m_keep = keep;
+
+ return true;
+}
+
+bool OpenALDevice::OpenALHandle::seek(float position)
+{
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return false;
+
+ if(m_isBuffered)
+ alSourcef(m_source, AL_SEC_OFFSET, position);
+ else
+ {
+ m_reader->seek((int)(position * m_reader->getSpecs().rate));
+ m_eos = false;
+
+ ALint info;
+
+ alGetSourcei(m_source, AL_SOURCE_STATE, &info);
+
+ // we need to stop playing sounds as well to clear the buffers
+ // this might cause clicks, but fixes a bug regarding position determination
+ if(info == AL_PAUSED || info == AL_PLAYING)
+ alSourceStop(m_source);
+
+ alSourcei(m_source, AL_BUFFER, 0);
+
+ ALenum err;
+ if((err = alGetError()) == AL_NO_ERROR)
+ {
+ int length;
+ DeviceSpecs specs = m_device->m_specs;
+ specs.specs = m_reader->getSpecs();
+ m_device->m_buffer.assureSize(m_device->m_buffersize * AUD_DEVICE_SAMPLE_SIZE(specs));
+
+ for(m_current = 0; m_current < CYCLE_BUFFERS; m_current++)
+ {
+ length = m_device->m_buffersize;
+
+ m_reader->read(length, m_eos, m_device->m_buffer.getBuffer());
+
+ if(length == 0)
+ break;
+
+ alBufferData(m_buffers[m_current], m_format, m_device->m_buffer.getBuffer(), length * AUD_DEVICE_SAMPLE_SIZE(specs), specs.rate);
+
+ if(alGetError() != AL_NO_ERROR)
+ break;
+ }
+
+ if(m_loopcount != 0)
+ m_eos = false;
+
+ alSourceQueueBuffers(m_source, m_current, m_buffers);
+ }
+
+ alSourceRewind(m_source);
+ }
+
+ if(m_status == STATUS_STOPPED)
+ m_status = STATUS_PAUSED;
+
+ return true;
+}
+
+float OpenALDevice::OpenALHandle::getPosition()
+{
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return 0.0f;
+
+ float position = 0.0f;
+
+ alGetSourcef(m_source, AL_SEC_OFFSET, &position);
+
+ if(!m_isBuffered)
+ {
+ int queued;
+
+ // this usually always returns CYCLE_BUFFERS
+ alGetSourcei(m_source, AL_BUFFERS_QUEUED, &queued);
+
+ Specs specs = m_reader->getSpecs();
+ position += (m_reader->getPosition() - m_device->m_buffersize * queued) / (float)specs.rate;
+ }
+
+ return position;
+}
+
+Status OpenALDevice::OpenALHandle::getStatus()
+{
+ return m_status;
+}
+
+float OpenALDevice::OpenALHandle::getVolume()
+{
+ float result = std::numeric_limits<float>::quiet_NaN();
+
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return result;
+
+ alGetSourcef(m_source, AL_GAIN, &result);
+
+ return result;
+}
+
+bool OpenALDevice::OpenALHandle::setVolume(float volume)
+{
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return false;
+
+ if(volume >= 0.0f)
+ alSourcef(m_source, AL_GAIN, volume);
+
+ return true;
+}
+
+float OpenALDevice::OpenALHandle::getPitch()
+{
+ float result = std::numeric_limits<float>::quiet_NaN();
+
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return result;
+
+ alGetSourcef(m_source, AL_PITCH, &result);
+
+ return result;
+}
+
+bool OpenALDevice::OpenALHandle::setPitch(float pitch)
+{
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return false;
+
+ if(pitch > 0.0f)
+ alSourcef(m_source, AL_PITCH, pitch);
+
+ return true;
+}
+
+int OpenALDevice::OpenALHandle::getLoopCount()
+{
+ if(!m_status)
+ return 0;
+ return m_loopcount;
+}
+
+bool OpenALDevice::OpenALHandle::setLoopCount(int count)
+{
+ if(!m_status)
+ return false;
+
+ if(m_status == STATUS_STOPPED && (count > m_loopcount || count < 0))
+ m_status = STATUS_PAUSED;
+
+ m_loopcount = count;
+
+ return true;
+}
+
+bool OpenALDevice::OpenALHandle::setStopCallback(stopCallback callback, void* data)
+{
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return false;
+
+ m_stop = callback;
+ m_stop_data = data;
+
+ return true;
+}
+
+/******************************************************************************/
+/********************* OpenALHandle 3DHandle Code *************************/
+/******************************************************************************/
+
+Vector3 OpenALDevice::OpenALHandle::getLocation()
+{
+ Vector3 result = Vector3(0, 0, 0);
+
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return result;
+
+ ALfloat p[3];
+ alGetSourcefv(m_source, AL_POSITION, p);
+
+ result = Vector3(p[0], p[1], p[2]);
+
+ return result;
+}
+
+bool OpenALDevice::OpenALHandle::setLocation(const Vector3& location)
+{
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return false;
+
+ alSourcefv(m_source, AL_POSITION, (ALfloat*)location.get());
+
+ return true;
+}
+
+Vector3 OpenALDevice::OpenALHandle::getVelocity()
+{
+ Vector3 result = Vector3(0, 0, 0);
+
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return result;
+
+ ALfloat v[3];
+ alGetSourcefv(m_source, AL_VELOCITY, v);
+
+ result = Vector3(v[0], v[1], v[2]);
+
+ return result;
+}
+
+bool OpenALDevice::OpenALHandle::setVelocity(const Vector3& velocity)
+{
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return false;
+
+ alSourcefv(m_source, AL_VELOCITY, (ALfloat*)velocity.get());
+
+ return true;
+}
+
+Quaternion OpenALDevice::OpenALHandle::getOrientation()
+{
+ return m_orientation;
+}
+
+bool OpenALDevice::OpenALHandle::setOrientation(const Quaternion& orientation)
+{
+ ALfloat direction[3];
+ direction[0] = -2 * (orientation.w() * orientation.y() +
+ orientation.x() * orientation.z());
+ direction[1] = 2 * (orientation.x() * orientation.w() -
+ orientation.z() * orientation.y());
+ direction[2] = 2 * (orientation.x() * orientation.x() +
+ orientation.y() * orientation.y()) - 1;
+
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return false;
+
+ alSourcefv(m_source, AL_DIRECTION, direction);
+
+ m_orientation = orientation;
+
+ return true;
+}
+
+bool OpenALDevice::OpenALHandle::isRelative()
+{
+ int result;
+
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return false;
+
+ alGetSourcei(m_source, AL_SOURCE_RELATIVE, &result);
+
+ return result;
+}
+
+bool OpenALDevice::OpenALHandle::setRelative(bool relative)
+{
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return false;
+
+ alSourcei(m_source, AL_SOURCE_RELATIVE, relative);
+
+ return true;
+}
+
+float OpenALDevice::OpenALHandle::getVolumeMaximum()
+{
+ float result = std::numeric_limits<float>::quiet_NaN();
+
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return result;
+
+ alGetSourcef(m_source, AL_MAX_GAIN, &result);
+
+ return result;
+}
+
+bool OpenALDevice::OpenALHandle::setVolumeMaximum(float volume)
+{
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return false;
+
+ if(volume >= 0.0f && volume <= 1.0f)
+ alSourcef(m_source, AL_MAX_GAIN, volume);
+
+ return true;
+}
+
+float OpenALDevice::OpenALHandle::getVolumeMinimum()
+{
+ float result = std::numeric_limits<float>::quiet_NaN();
+
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return result;
+
+ alGetSourcef(m_source, AL_MIN_GAIN, &result);
+
+ return result;
+}
+
+bool OpenALDevice::OpenALHandle::setVolumeMinimum(float volume)
+{
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return false;
+
+ if(volume >= 0.0f && volume <= 1.0f)
+ alSourcef(m_source, AL_MIN_GAIN, volume);
+
+ return true;
+}
+
+float OpenALDevice::OpenALHandle::getDistanceMaximum()
+{
+ float result = std::numeric_limits<float>::quiet_NaN();
+
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return result;
+
+ alGetSourcef(m_source, AL_MAX_DISTANCE, &result);
+
+ return result;
+}
+
+bool OpenALDevice::OpenALHandle::setDistanceMaximum(float distance)
+{
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return false;
+
+ if(distance >= 0.0f)
+ alSourcef(m_source, AL_MAX_DISTANCE, distance);
+
+ return true;
+}
+
+float OpenALDevice::OpenALHandle::getDistanceReference()
+{
+ float result = std::numeric_limits<float>::quiet_NaN();
+
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return result;
+
+ alGetSourcef(m_source, AL_REFERENCE_DISTANCE, &result);
+
+ return result;
+}
+
+bool OpenALDevice::OpenALHandle::setDistanceReference(float distance)
+{
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return false;
+
+ if(distance >= 0.0f)
+ alSourcef(m_source, AL_REFERENCE_DISTANCE, distance);
+
+ return true;
+}
+
+float OpenALDevice::OpenALHandle::getAttenuation()
+{
+ float result = std::numeric_limits<float>::quiet_NaN();
+
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return result;
+
+ alGetSourcef(m_source, AL_ROLLOFF_FACTOR, &result);
+
+ return result;
+}
+
+bool OpenALDevice::OpenALHandle::setAttenuation(float factor)
+{
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return false;
+
+ if(factor >= 0.0f)
+ alSourcef(m_source, AL_ROLLOFF_FACTOR, factor);
+
+ return true;
+}
+
+float OpenALDevice::OpenALHandle::getConeAngleOuter()
+{
+ float result = std::numeric_limits<float>::quiet_NaN();
+
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return result;
+
+ alGetSourcef(m_source, AL_CONE_OUTER_ANGLE, &result);
+
+ return result;
+}
+
+bool OpenALDevice::OpenALHandle::setConeAngleOuter(float angle)
+{
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return false;
+
+ alSourcef(m_source, AL_CONE_OUTER_ANGLE, angle);
+
+ return true;
+}
+
+float OpenALDevice::OpenALHandle::getConeAngleInner()
+{
+ float result = std::numeric_limits<float>::quiet_NaN();
+
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return result;
+
+ alGetSourcef(m_source, AL_CONE_INNER_ANGLE, &result);
+
+ return result;
+}
+
+bool OpenALDevice::OpenALHandle::setConeAngleInner(float angle)
+{
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return false;
+
+ alSourcef(m_source, AL_CONE_INNER_ANGLE, angle);
+
+ return true;
+}
+
+float OpenALDevice::OpenALHandle::getConeVolumeOuter()
+{
+ float result = std::numeric_limits<float>::quiet_NaN();
+
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return result;
+
+ alGetSourcef(m_source, AL_CONE_OUTER_GAIN, &result);
+
+ return result;
+}
+
+bool OpenALDevice::OpenALHandle::setConeVolumeOuter(float volume)
+{
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return false;
+
+ if(volume >= 0.0f && volume <= 1.0f)
+ alSourcef(m_source, AL_CONE_OUTER_GAIN, volume);
+
+ return true;
+}
+
+/******************************************************************************/
+/**************************** Threading Code **********************************/
+/******************************************************************************/
+
+void OpenALDevice::start()
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ if(!m_playing)
+ {
+ if(m_thread.joinable())
+ m_thread.join();
+
+ m_thread = std::thread(&OpenALDevice::updateStreams, this);
+
+ m_playing = true;
+ }
+}
+
+void OpenALDevice::updateStreams()
+{
+ int length;
+
+ ALint info;
+ DeviceSpecs specs = m_specs;
+ ALCenum cerr;
+ std::list<std::shared_ptr<OpenALHandle> > stopSounds;
+ std::list<std::shared_ptr<OpenALHandle> > pauseSounds;
+
+ auto sleepDuration = std::chrono::milliseconds(20);
+
+ for(;;)
+ {
+ lock();
+
+ alcSuspendContext(m_context);
+ cerr = alcGetError(m_device);
+ if(cerr == ALC_NO_ERROR)
+ {
+ // for all sounds
+ for(auto& sound : m_playingSounds)
+ {
+ // is it a streamed sound?
+ if(!sound->m_isBuffered)
+ {
+ // check for buffer refilling
+ alGetSourcei(sound->m_source, AL_BUFFERS_PROCESSED, &info);
+
+ info += (OpenALHandle::CYCLE_BUFFERS - sound->m_current);
+
+ if(info)
+ {
+ specs.specs = sound->m_reader->getSpecs();
+ m_buffer.assureSize(m_buffersize * AUD_DEVICE_SAMPLE_SIZE(specs));
+
+ // for all empty buffers
+ while(info--)
+ {
+ // if there's still data to play back
+ if(!sound->m_eos)
+ {
+ // read data
+ length = m_buffersize;
+
+ try
+ {
+ sound->m_reader->read(length, sound->m_eos, m_buffer.getBuffer());
+
+ // looping necessary?
+ if(length == 0 && sound->m_loopcount)
+ {
+ if(sound->m_loopcount > 0)
+ sound->m_loopcount--;
+
+ sound->m_reader->seek(0);
+
+ length = m_buffersize;
+ sound->m_reader->read(length, sound->m_eos, m_buffer.getBuffer());
+ }
+ }
+ catch(Exception& e)
+ {
+ length = 0;
+ std::cerr << "Caught exception while reading sound data during playback with OpenAL: " << e.getMessage() << std::endl;
+ }
+
+ if(sound->m_loopcount != 0)
+ sound->m_eos = false;
+
+ // read nothing?
+ if(length == 0)
+ {
+ break;
+ }
+
+ ALuint buffer;
+
+ if(sound->m_current < OpenALHandle::CYCLE_BUFFERS)
+ buffer = sound->m_buffers[sound->m_current++];
+ else
+ alSourceUnqueueBuffers(sound->m_source, 1, &buffer);
+
+ ALenum err;
+ if((err = alGetError()) != AL_NO_ERROR)
+ {
+ sound->m_eos = true;
+ break;
+ }
+
+ // fill with new data
+ alBufferData(buffer, sound->m_format, m_buffer.getBuffer(), length * AUD_DEVICE_SAMPLE_SIZE(specs), specs.rate);
+
+ if((err = alGetError()) != AL_NO_ERROR)
+ {
+ sound->m_eos = true;
+ break;
+ }
+
+ // and queue again
+ alSourceQueueBuffers(sound->m_source, 1,&buffer);
+ if(alGetError() != AL_NO_ERROR)
+ {
+ sound->m_eos = true;
+ break;
+ }
+ }
+ else
+ break;
+ }
+ }
+ }
+
+ // check if the sound has been stopped
+ alGetSourcei(sound->m_source, AL_SOURCE_STATE, &info);
+
+ if(info != AL_PLAYING)
+ {
+ // if it really stopped
+ if(sound->m_eos && info != AL_INITIAL)
+ {
+ if(sound->m_stop)
+ sound->m_stop(sound->m_stop_data);
+
+ // pause or
+ if(sound->m_keep)
+ pauseSounds.push_back(sound);
+ // stop
+ else
+ stopSounds.push_back(sound);
+ }
+ // continue playing
+ else
+ alSourcePlay(sound->m_source);
+ }
+ }
+
+ for(auto& sound : pauseSounds)
+ sound->pause(true);
+
+ for(auto& sound : stopSounds)
+ sound->stop();
+
+ pauseSounds.clear();
+ stopSounds.clear();
+
+ alcProcessContext(m_context);
+ }
+
+ // stop thread
+ if(m_playingSounds.empty() || (cerr != ALC_NO_ERROR))
+ {
+ m_playing = false;
+ unlock();
+
+ return;
+ }
+
+ unlock();
+
+ std::this_thread::sleep_for(sleepDuration);
+ }
+}
+
+/******************************************************************************/
+/**************************** IDevice Code ************************************/
+/******************************************************************************/
+
+OpenALDevice::OpenALDevice(DeviceSpecs specs, int buffersize, std::string name) :
+ m_playing(false), m_buffersize(buffersize)
+{
+ // cannot determine how many channels or which format OpenAL uses, but
+ // it at least is able to play 16 bit stereo audio
+ specs.format = FORMAT_S16;
+
+ if(name.empty())
+ m_device = alcOpenDevice(nullptr);
+ else
+ m_device = alcOpenDevice(name.c_str());
+
+ if(!m_device)
+ AUD_THROW(DeviceException, "The audio device couldn't be opened with OpenAL.");
+
+ // at least try to set the frequency
+ ALCint attribs[] = { ALC_FREQUENCY, (ALCint)specs.rate, 0 };
+ ALCint* attributes = attribs;
+ if(specs.rate == RATE_INVALID)
+ attributes = nullptr;
+
+ m_context = alcCreateContext(m_device, attributes);
+ alcMakeContextCurrent(m_context);
+
+ alcGetIntegerv(m_device, ALC_FREQUENCY, 1, (ALCint*)&specs.rate);
+
+ // check for specific formats and channel counts to be played back
+ if(alIsExtensionPresent("AL_EXT_FLOAT32") == AL_TRUE)
+ specs.format = FORMAT_FLOAT32;
+
+ m_useMC = alIsExtensionPresent("AL_EXT_MCFORMATS") == AL_TRUE;
+
+ if((!m_useMC && specs.channels > CHANNELS_STEREO) ||
+ specs.channels == CHANNELS_STEREO_LFE ||
+ specs.channels == CHANNELS_SURROUND5)
+ specs.channels = CHANNELS_STEREO;
+
+ alGetError();
+ alcGetError(m_device);
+
+ m_specs = specs;
+}
+
+OpenALDevice::~OpenALDevice()
+{
+ lock();
+ alcSuspendContext(m_context);
+
+ while(!m_playingSounds.empty())
+ m_playingSounds.front()->stop();
+
+ while(!m_pausedSounds.empty())
+ m_pausedSounds.front()->stop();
+
+ alcProcessContext(m_context);
+
+ // wait for the thread to stop
+ unlock();
+ if(m_thread.joinable())
+ m_thread.join();
+
+ // quit OpenAL
+ alcMakeContextCurrent(nullptr);
+ alcDestroyContext(m_context);
+ alcCloseDevice(m_device);
+}
+
+DeviceSpecs OpenALDevice::getSpecs() const
+{
+ return m_specs;
+}
+
+bool OpenALDevice::getFormat(ALenum &format, Specs specs)
+{
+ bool valid = true;
+ format = 0;
+
+ switch(m_specs.format)
+ {
+ case FORMAT_S16:
+ switch(specs.channels)
+ {
+ case CHANNELS_MONO:
+ format = AL_FORMAT_MONO16;
+ break;
+ case CHANNELS_STEREO:
+ format = AL_FORMAT_STEREO16;
+ break;
+ case CHANNELS_SURROUND4:
+ if(m_useMC)
+ {
+ format = alGetEnumValue("AL_FORMAT_QUAD16");
+ break;
+ }
+ case CHANNELS_SURROUND51:
+ if(m_useMC)
+ {
+ format = alGetEnumValue("AL_FORMAT_51CHN16");
+ break;
+ }
+ case CHANNELS_SURROUND61:
+ if(m_useMC)
+ {
+ format = alGetEnumValue("AL_FORMAT_61CHN16");
+ break;
+ }
+ case CHANNELS_SURROUND71:
+ if(m_useMC)
+ {
+ format = alGetEnumValue("AL_FORMAT_71CHN16");
+ break;
+ }
+ default:
+ valid = false;
+ }
+ break;
+ case FORMAT_FLOAT32:
+ switch(specs.channels)
+ {
+ case CHANNELS_MONO:
+ format = alGetEnumValue("AL_FORMAT_MONO_FLOAT32");
+ break;
+ case CHANNELS_STEREO:
+ format = alGetEnumValue("AL_FORMAT_STEREO_FLOAT32");
+ break;
+ case CHANNELS_SURROUND4:
+ if(m_useMC)
+ {
+ format = alGetEnumValue("AL_FORMAT_QUAD32");
+ break;
+ }
+ case CHANNELS_SURROUND51:
+ if(m_useMC)
+ {
+ format = alGetEnumValue("AL_FORMAT_51CHN32");
+ break;
+ }
+ case CHANNELS_SURROUND61:
+ if(m_useMC)
+ {
+ format = alGetEnumValue("AL_FORMAT_61CHN32");
+ break;
+ }
+ case CHANNELS_SURROUND71:
+ if(m_useMC)
+ {
+ format = alGetEnumValue("AL_FORMAT_71CHN32");
+ break;
+ }
+ default:
+ valid = false;
+ }
+ break;
+ default:
+ valid = false;
+ }
+
+ if(!format)
+ valid = false;
+
+ return valid;
+}
+
+std::shared_ptr<IHandle> OpenALDevice::play(std::shared_ptr<IReader> reader, bool keep)
+{
+ Specs specs = reader->getSpecs();
+
+ // check format
+ if(specs.channels == CHANNELS_INVALID)
+ return std::shared_ptr<IHandle>();
+
+ if(m_specs.format != FORMAT_FLOAT32)
+ reader = std::shared_ptr<IReader>(new ConverterReader(reader, m_specs));
+
+ ALenum format;
+
+ if(!getFormat(format, specs))
+ return std::shared_ptr<IHandle>();
+
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ alcSuspendContext(m_context);
+
+ std::shared_ptr<OpenALDevice::OpenALHandle> sound;
+
+ try
+ {
+ // create the handle
+ sound = std::shared_ptr<OpenALDevice::OpenALHandle>(new OpenALDevice::OpenALHandle(this, format, reader, keep));
+ }
+ catch(Exception&)
+ {
+ alcProcessContext(m_context);
+ throw;
+ }
+
+ alcProcessContext(m_context);
+
+ // play sound
+ m_playingSounds.push_back(sound);
+
+ start();
+
+ return std::shared_ptr<IHandle>(sound);
+}
+
+std::shared_ptr<IHandle> OpenALDevice::play(std::shared_ptr<ISound> sound, bool keep)
+{
+ return play(sound->createReader(), keep);
+}
+
+void OpenALDevice::stopAll()
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ alcSuspendContext(m_context);
+
+ while(!m_playingSounds.empty())
+ m_playingSounds.front()->stop();
+
+ while(!m_pausedSounds.empty())
+ m_pausedSounds.front()->stop();
+
+ alcProcessContext(m_context);
+}
+
+void OpenALDevice::lock()
+{
+ m_mutex.lock();
+}
+
+void OpenALDevice::unlock()
+{
+ m_mutex.unlock();
+}
+
+float OpenALDevice::getVolume() const
+{
+ float result;
+
+ alGetListenerf(AL_GAIN, &result);
+ return result;
+}
+
+void OpenALDevice::setVolume(float volume)
+{
+ if(volume < 0.0f)
+ return;
+
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ alListenerf(AL_GAIN, volume);
+}
+
+ISynchronizer* OpenALDevice::getSynchronizer()
+{
+ return &m_synchronizer;
+}
+
+/******************************************************************************/
+/**************************** 3D Device Code **********************************/
+/******************************************************************************/
+
+Vector3 OpenALDevice::getListenerLocation() const
+{
+ ALfloat p[3];
+
+ alGetListenerfv(AL_POSITION, p);
+ return Vector3(p[0], p[1], p[2]);
+}
+
+void OpenALDevice::setListenerLocation(const Vector3& location)
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ alListenerfv(AL_POSITION, (ALfloat*)location.get());
+}
+
+Vector3 OpenALDevice::getListenerVelocity() const
+{
+ ALfloat v[3];
+
+ alGetListenerfv(AL_VELOCITY, v);
+ return Vector3(v[0], v[1], v[2]);
+}
+
+void OpenALDevice::setListenerVelocity(const Vector3& velocity)
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ alListenerfv(AL_VELOCITY, (ALfloat*)velocity.get());
+}
+
+Quaternion OpenALDevice::getListenerOrientation() const
+{
+ return m_orientation;
+}
+
+void OpenALDevice::setListenerOrientation(const Quaternion& orientation)
+{
+ ALfloat direction[6];
+
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ direction[0] = -2 * (orientation.w() * orientation.y() +
+ orientation.x() * orientation.z());
+ direction[1] = 2 * (orientation.x() * orientation.w() -
+ orientation.z() * orientation.y());
+ direction[2] = 2 * (orientation.x() * orientation.x() +
+ orientation.y() * orientation.y()) - 1;
+ direction[3] = 2 * (orientation.x() * orientation.y() -
+ orientation.w() * orientation.z());
+ direction[4] = 1 - 2 * (orientation.x() * orientation.x() +
+ orientation.z() * orientation.z());
+ direction[5] = 2 * (orientation.w() * orientation.x() +
+ orientation.y() * orientation.z());
+ alListenerfv(AL_ORIENTATION, direction);
+ m_orientation = orientation;
+}
+
+float OpenALDevice::getSpeedOfSound() const
+{
+ return alGetFloat(AL_SPEED_OF_SOUND);
+}
+
+void OpenALDevice::setSpeedOfSound(float speed)
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ alSpeedOfSound(speed);
+}
+
+float OpenALDevice::getDopplerFactor() const
+{
+ return alGetFloat(AL_DOPPLER_FACTOR);
+}
+
+void OpenALDevice::setDopplerFactor(float factor)
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ alDopplerFactor(factor);
+}
+
+DistanceModel OpenALDevice::getDistanceModel() const
+{
+ switch(alGetInteger(AL_DISTANCE_MODEL))
+ {
+ case AL_INVERSE_DISTANCE:
+ return DISTANCE_MODEL_INVERSE;
+ case AL_INVERSE_DISTANCE_CLAMPED:
+ return DISTANCE_MODEL_INVERSE_CLAMPED;
+ case AL_LINEAR_DISTANCE:
+ return DISTANCE_MODEL_LINEAR;
+ case AL_LINEAR_DISTANCE_CLAMPED:
+ return DISTANCE_MODEL_LINEAR_CLAMPED;
+ case AL_EXPONENT_DISTANCE:
+ return DISTANCE_MODEL_EXPONENT;
+ case AL_EXPONENT_DISTANCE_CLAMPED:
+ return DISTANCE_MODEL_EXPONENT_CLAMPED;
+ default:
+ return DISTANCE_MODEL_INVALID;
+ }
+}
+
+void OpenALDevice::setDistanceModel(DistanceModel model)
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ switch(model)
+ {
+ case DISTANCE_MODEL_INVERSE:
+ alDistanceModel(AL_INVERSE_DISTANCE);
+ break;
+ case DISTANCE_MODEL_INVERSE_CLAMPED:
+ alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED);
+ break;
+ case DISTANCE_MODEL_LINEAR:
+ alDistanceModel(AL_LINEAR_DISTANCE);
+ break;
+ case DISTANCE_MODEL_LINEAR_CLAMPED:
+ alDistanceModel(AL_LINEAR_DISTANCE_CLAMPED);
+ break;
+ case DISTANCE_MODEL_EXPONENT:
+ alDistanceModel(AL_EXPONENT_DISTANCE);
+ break;
+ case DISTANCE_MODEL_EXPONENT_CLAMPED:
+ alDistanceModel(AL_EXPONENT_DISTANCE_CLAMPED);
+ break;
+ default:
+ alDistanceModel(AL_NONE);
+ }
+}
+
+std::list<std::string> OpenALDevice::getDeviceNames()
+{
+ std::list<std::string> names;
+
+ if(alcIsExtensionPresent(nullptr, "ALC_ENUMERATION_EXT") == AL_TRUE)
+ {
+ ALCchar* devices = const_cast<ALCchar*>(alcGetString(nullptr, ALC_DEVICE_SPECIFIER));
+ std::string default_device = alcGetString(nullptr, ALC_DEFAULT_DEVICE_SPECIFIER);
+
+ while(*devices)
+ {
+ std::string device = devices;
+
+ if(device == default_device)
+ names.push_front(device);
+ else
+ names.push_back(device);
+
+ devices += strlen(devices) + 1;
+ }
+ }
+
+ return names;
+}
+
+class OpenALDeviceFactory : public IDeviceFactory
+{
+private:
+ DeviceSpecs m_specs;
+ int m_buffersize;
+ std::string m_name;
+
+public:
+ OpenALDeviceFactory(std::string name = "") :
+ m_buffersize(AUD_DEFAULT_BUFFER_SIZE),
+ m_name(name)
+ {
+ m_specs.format = FORMAT_FLOAT32;
+ m_specs.channels = CHANNELS_SURROUND51;
+ m_specs.rate = RATE_48000;
+ }
+
+ virtual std::shared_ptr<IDevice> openDevice()
+ {
+ return std::shared_ptr<IDevice>(new OpenALDevice(m_specs, m_buffersize, m_name));
+ }
+
+ virtual int getPriority()
+ {
+ return 1 << 10;
+ }
+
+ virtual void setSpecs(DeviceSpecs specs)
+ {
+ m_specs = specs;
+ }
+
+ virtual void setBufferSize(int buffersize)
+ {
+ m_buffersize = buffersize;
+ }
+
+ virtual void setName(std::string name)
+ {
+ }
+};
+
+void OpenALDevice::registerPlugin()
+{
+ auto names = OpenALDevice::getDeviceNames();
+ DeviceManager::registerDevice("OpenAL", std::shared_ptr<IDeviceFactory>(new OpenALDeviceFactory));
+ for(std::string &name : names)
+ {
+ DeviceManager::registerDevice("OpenAL - " + name, std::shared_ptr<IDeviceFactory>(new OpenALDeviceFactory(name)));
+ }
+}
+
+#ifdef OPENAL_PLUGIN
+extern "C" AUD_PLUGIN_API void registerPlugin()
+{
+ OpenALDevice::registerPlugin();
+}
+
+extern "C" AUD_PLUGIN_API const char* getName()
+{
+ return "OpenAL";
+}
+#endif
+
+AUD_NAMESPACE_END
diff --git a/intern/audaspace/OpenAL/AUD_OpenALDevice.h b/extern/audaspace/plugins/openal/OpenALDevice.h
index f0e47824967..b9b461a327c 100644
--- a/intern/audaspace/OpenAL/AUD_OpenALDevice.h
+++ b/extern/audaspace/plugins/openal/OpenALDevice.h
@@ -1,64 +1,66 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
*
- * Copyright 2009-2011 Jörg Hermann Müller
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * This file is part of AudaSpace.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * 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 *****
- */
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
-/** \file audaspace/OpenAL/AUD_OpenALDevice.h
- * \ingroup audopenal
- */
+#pragma once
+#ifdef OPENAL_PLUGIN
+#define AUD_BUILD_PLUGIN
+#endif
-#ifndef __AUD_OPENALDEVICE_H__
-#define __AUD_OPENALDEVICE_H__
+/**
+ * @file OpenALDevice.h
+ * @ingroup plugin
+ * The OpenALDevice class.
+ */
-#include "AUD_IDevice.h"
-#include "AUD_IHandle.h"
-#include "AUD_I3DDevice.h"
-#include "AUD_I3DHandle.h"
-#include "AUD_Buffer.h"
-//struct AUD_OpenALBufferedFactory;
+#include "devices/IDevice.h"
+#include "devices/IHandle.h"
+#include "devices/I3DDevice.h"
+#include "devices/I3DHandle.h"
+#include "devices/DefaultSynchronizer.h"
+#include "util/Buffer.h"
-#include <AL/al.h>
-#include <AL/alc.h>
+#include <al.h>
+#include <alc.h>
#include <list>
-#include <pthread.h>
+#include <mutex>
+#include <thread>
+#include <string>
+
+AUD_NAMESPACE_BEGIN
/**
* This device plays through OpenAL.
*/
-class AUD_OpenALDevice : public AUD_IDevice, public AUD_I3DDevice
+class AUD_PLUGIN_API OpenALDevice : public IDevice, public I3DDevice
{
private:
/// Saves the data for playback.
- class AUD_OpenALHandle : public AUD_IHandle, public AUD_I3DHandle
+ class OpenALHandle : public IHandle, public I3DHandle
{
- public:
+ private:
+ friend class OpenALDevice;
+
static const int CYCLE_BUFFERS = 3;
/// Whether it's a buffered or a streamed source.
bool m_isBuffered;
/// The reader source.
- boost::shared_ptr<AUD_IReader> m_reader;
+ std::shared_ptr<IReader> m_reader;
/// Whether to keep the source if end of it is reached.
bool m_keep;
@@ -88,15 +90,19 @@ private:
void* m_stop_data;
/// Orientation.
- AUD_Quaternion m_orientation;
+ Quaternion m_orientation;
/// Current status of the handle
- AUD_Status m_status;
+ Status m_status;
/// Own device.
- AUD_OpenALDevice* m_device;
+ OpenALDevice* m_device;
- bool pause(bool keep);
+ AUD_LOCAL bool pause(bool keep);
+
+ // delete copy constructor and operator=
+ OpenALHandle(const OpenALHandle&) = delete;
+ OpenALHandle& operator=(const OpenALHandle&) = delete;
public:
@@ -107,9 +113,9 @@ 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, boost::shared_ptr<AUD_IReader> reader, bool keep);
+ OpenALHandle(OpenALDevice* device, ALenum format, std::shared_ptr<IReader> reader, bool keep);
- virtual ~AUD_OpenALHandle() {}
+ virtual ~OpenALHandle() {}
virtual bool pause();
virtual bool resume();
virtual bool stop();
@@ -117,7 +123,7 @@ private:
virtual bool setKeep(bool keep);
virtual bool seek(float position);
virtual float getPosition();
- virtual AUD_Status getStatus();
+ virtual Status getStatus();
virtual float getVolume();
virtual bool setVolume(float volume);
virtual float getPitch();
@@ -126,12 +132,12 @@ private:
virtual bool setLoopCount(int count);
virtual bool setStopCallback(stopCallback callback = 0, void* data = 0);
- virtual AUD_Vector3 getSourceLocation();
- virtual bool setSourceLocation(const AUD_Vector3& location);
- virtual AUD_Vector3 getSourceVelocity();
- virtual bool setSourceVelocity(const AUD_Vector3& velocity);
- virtual AUD_Quaternion getSourceOrientation();
- virtual bool setSourceOrientation(const AUD_Quaternion& orientation);
+ virtual Vector3 getLocation();
+ virtual bool setLocation(const Vector3& location);
+ virtual Vector3 getVelocity();
+ virtual bool setVelocity(const Vector3& velocity);
+ virtual Quaternion getOrientation();
+ virtual bool setOrientation(const Quaternion& orientation);
virtual bool isRelative();
virtual bool setRelative(bool relative);
virtual float getVolumeMaximum();
@@ -152,8 +158,6 @@ private:
virtual bool setConeVolumeOuter(float volume);
};
- typedef std::list<boost::shared_ptr<AUD_OpenALHandle> >::iterator AUD_HandleIterator;
-
/**
* The OpenAL device handle.
*/
@@ -167,7 +171,7 @@ private:
/**
* The specification of the device.
*/
- AUD_DeviceSpecs m_specs;
+ DeviceSpecs m_specs;
/**
* Whether the device has the AL_EXT_MCFORMATS extension.
@@ -177,27 +181,22 @@ private:
/**
* The list of sounds that are currently playing.
*/
- std::list<boost::shared_ptr<AUD_OpenALHandle> > m_playingSounds;
+ std::list<std::shared_ptr<OpenALHandle> > m_playingSounds;
/**
* The list of sounds that are currently paused.
*/
- std::list<boost::shared_ptr<AUD_OpenALHandle> > m_pausedSounds;
-
- /**
- * The list of buffered factories.
- */
- //std::list<AUD_OpenALBufferedFactory*>* m_bufferedFactories;
+ std::list<std::shared_ptr<OpenALHandle> > m_pausedSounds;
/**
* The mutex for locking.
*/
- pthread_mutex_t m_mutex;
+ std::recursive_mutex m_mutex;
/**
* The streaming thread.
*/
- pthread_t m_thread;
+ std::thread m_thread;
/**
* The condition for streaming thread wakeup.
@@ -212,18 +211,26 @@ private:
/**
* Device buffer.
*/
- AUD_Buffer m_buffer;
+ Buffer m_buffer;
/**
* Orientation.
*/
- AUD_Quaternion m_orientation;
+ Quaternion m_orientation;
+
+ /// Synchronizer.
+ DefaultSynchronizer m_synchronizer;
/**
* Starts the streaming thread.
* \param Whether the previous thread should be joined.
*/
- void start(bool join = true);
+ AUD_LOCAL void start();
+
+ /**
+ * Streaming thread main function.
+ */
+ AUD_LOCAL void updateStreams();
/**
* Gets the format according to the specs.
@@ -231,52 +238,59 @@ private:
* \param specs The specs to read the channel count from.
* \return Whether the format is valid or not.
*/
- bool getFormat(ALenum &format, AUD_Specs specs);
+ AUD_LOCAL bool getFormat(ALenum &format, Specs specs);
- // hide copy constructor and operator=
- AUD_OpenALDevice(const AUD_OpenALDevice&);
- AUD_OpenALDevice& operator=(const AUD_OpenALDevice&);
+ // delete copy constructor and operator=
+ OpenALDevice(const OpenALDevice&) = delete;
+ OpenALDevice& operator=(const OpenALDevice&) = delete;
public:
/**
* Opens the OpenAL audio device for playback.
* \param specs The wanted audio specification.
* \param buffersize The size of the internal buffer.
+ * \param name The name of the device to be opened.
* \note The specification really used for opening the device may differ.
* \note The buffersize will be multiplicated by three for this device.
- * \exception AUD_Exception Thrown if the audio device cannot be opened.
- */
- AUD_OpenALDevice(AUD_DeviceSpecs specs,
- int buffersize = AUD_DEFAULT_BUFFER_SIZE);
-
- /**
- * Streaming thread main function.
+ * \exception DeviceException Thrown if the audio device cannot be opened.
*/
- void updateStreams();
+ OpenALDevice(DeviceSpecs specs, int buffersize = AUD_DEFAULT_BUFFER_SIZE, std::string name = "");
- virtual ~AUD_OpenALDevice();
+ virtual ~OpenALDevice();
- virtual AUD_DeviceSpecs getSpecs() const;
- 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 DeviceSpecs getSpecs() const;
+ virtual std::shared_ptr<IHandle> play(std::shared_ptr<IReader> reader, bool keep = false);
+ virtual std::shared_ptr<IHandle> play(std::shared_ptr<ISound> sound, bool keep = false);
virtual void stopAll();
virtual void lock();
virtual void unlock();
virtual float getVolume() const;
virtual void setVolume(float volume);
-
- virtual AUD_Vector3 getListenerLocation() const;
- virtual void setListenerLocation(const AUD_Vector3& location);
- virtual AUD_Vector3 getListenerVelocity() const;
- virtual void setListenerVelocity(const AUD_Vector3& velocity);
- virtual AUD_Quaternion getListenerOrientation() const;
- virtual void setListenerOrientation(const AUD_Quaternion& orientation);
+ virtual ISynchronizer* getSynchronizer();
+
+ virtual Vector3 getListenerLocation() const;
+ virtual void setListenerLocation(const Vector3& location);
+ virtual Vector3 getListenerVelocity() const;
+ virtual void setListenerVelocity(const Vector3& velocity);
+ virtual Quaternion getListenerOrientation() const;
+ virtual void setListenerOrientation(const Quaternion& orientation);
virtual float getSpeedOfSound() const;
virtual void setSpeedOfSound(float speed);
virtual float getDopplerFactor() const;
virtual void setDopplerFactor(float factor);
- virtual AUD_DistanceModel getDistanceModel() const;
- virtual void setDistanceModel(AUD_DistanceModel model);
+ virtual DistanceModel getDistanceModel() const;
+ virtual void setDistanceModel(DistanceModel model);
+
+ /**
+ * Retrieves a list of available hardware devices to open with OpenAL.
+ * @return The list of devices to open.
+ */
+ static std::list<std::string> getDeviceNames();
+
+ /**
+ * Registers this plugin.
+ */
+ static void registerPlugin();
};
-#endif //__AUD_OPENALDEVICE_H__
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/plugins/openal/OpenALReader.cpp b/extern/audaspace/plugins/openal/OpenALReader.cpp
new file mode 100644
index 00000000000..52356d4f7ec
--- /dev/null
+++ b/extern/audaspace/plugins/openal/OpenALReader.cpp
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "OpenALReader.h"
+#include "respec/ConverterFunctions.h"
+#include "Exception.h"
+
+#include <algorithm>
+#include <al.h>
+
+AUD_NAMESPACE_BEGIN
+
+OpenALReader::OpenALReader(Specs specs, int buffersize) :
+ m_specs(specs),
+ m_position(0),
+ m_device(nullptr)
+{
+ if((specs.channels != CHANNELS_MONO) && (specs.channels != CHANNELS_STEREO))
+ specs.channels = CHANNELS_MONO;
+
+ m_device = alcCaptureOpenDevice(nullptr, specs.rate,
+ specs.channels == CHANNELS_MONO ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16,
+ buffersize * specs.channels * 2);
+
+ if(!m_device)
+ AUD_THROW(DeviceException, "The capture device couldn't be opened with OpenAL.");
+
+ alcCaptureStart(m_device);
+}
+
+OpenALReader::~OpenALReader()
+{
+ if(m_device)
+ {
+ //alcCaptureStop(m_device);
+ alcCaptureCloseDevice(m_device);
+ }
+}
+
+bool OpenALReader::isSeekable() const
+{
+ return false;
+}
+
+void OpenALReader::seek(int position)
+{
+ m_position = position;
+}
+
+int OpenALReader::getLength() const
+{
+ int length;
+ alcGetIntegerv(m_device, ALC_CAPTURE_SAMPLES, 1, &length);
+ return length;
+}
+
+int OpenALReader::getPosition() const
+{
+ return m_position;
+}
+
+Specs OpenALReader::getSpecs() const
+{
+ return m_specs;
+}
+
+void OpenALReader::read(int & length, bool& eos, sample_t* buffer)
+{
+ int len = getLength();
+ length = std::min(length, len);
+
+ if(length > 0)
+ {
+ alcCaptureSamples(m_device, buffer, length);
+ convert_s16_float((data_t*)buffer, (data_t*)buffer, length * m_specs.channels);
+ }
+
+ eos = false;
+
+ m_position += length;
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/plugins/openal/OpenALReader.h b/extern/audaspace/plugins/openal/OpenALReader.h
new file mode 100644
index 00000000000..5d96ea9b027
--- /dev/null
+++ b/extern/audaspace/plugins/openal/OpenALReader.h
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+#ifdef OPENAL_PLUGIN
+#define AUD_BUILD_PLUGIN
+#endif
+
+/**
+ * @file OpenALReader.h
+ * @ingroup plugin
+ * The OpenALReader class.
+ */
+
+#include "IReader.h"
+
+#include <alc.h>
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This class is used for sine tone playback.
+ * The output format is in the 16 bit format and stereo, the sample rate can be
+ * specified.
+ * As the two channels both play the same the output could also be mono, but
+ * in most cases this will result in having to resample for output, so stereo
+ * sound is created directly.
+ */
+class AUD_PLUGIN_API OpenALReader : public IReader
+{
+private:
+ /**
+ * The specs of the reader.
+ */
+ Specs m_specs;
+
+ /**
+ * The current position in samples.
+ */
+ int m_position;
+
+ /**
+ * The capture device.
+ */
+ ALCdevice* m_device;
+
+ // delete copy constructor and operator=
+ OpenALReader(const OpenALReader&) = delete;
+ OpenALReader& operator=(const OpenALReader&) = delete;
+
+public:
+ /**
+ * Creates a new reader.
+ * \param specs The desired specification of the output samples.
+ * \param buffersize The buffer size used to read from the device.
+ */
+ OpenALReader(Specs specs, int buffersize = AUD_DEFAULT_BUFFER_SIZE);
+
+ virtual ~OpenALReader();
+
+ virtual bool isSeekable() const;
+ virtual void seek(int position);
+ virtual int getLength() const;
+ virtual int getPosition() const;
+ virtual Specs getSpecs() const;
+ virtual void read(int & length, bool& eos, sample_t* buffer);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/plugins/sdl/SDLDevice.cpp b/extern/audaspace/plugins/sdl/SDLDevice.cpp
new file mode 100644
index 00000000000..603e16001b8
--- /dev/null
+++ b/extern/audaspace/plugins/sdl/SDLDevice.cpp
@@ -0,0 +1,156 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "SDLDevice.h"
+#include "devices/DeviceManager.h"
+#include "devices/IDeviceFactory.h"
+#include "Exception.h"
+#include "IReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+void SDLDevice::SDL_mix(void* data, Uint8* buffer, int length)
+{
+ SDLDevice* device = (SDLDevice*)data;
+
+ if(!device->m_playback)
+ {
+ SDL_PauseAudio(1);
+
+ std::memset(buffer, 0, length);
+
+ return;
+ }
+
+ device->mix((data_t*)buffer, length / AUD_DEVICE_SAMPLE_SIZE(device->m_specs));
+}
+
+void SDLDevice::playing(bool playing)
+{
+ if(!m_playback)
+ SDL_PauseAudio(playing ? 0 : 1);
+
+ m_playback = playing;
+}
+
+SDLDevice::SDLDevice(DeviceSpecs specs, int buffersize) :
+ m_playback(false)
+{
+ if(specs.channels == CHANNELS_INVALID)
+ specs.channels = CHANNELS_STEREO;
+ if(specs.format == FORMAT_INVALID)
+ specs.format = FORMAT_S16;
+ if(specs.rate == RATE_INVALID)
+ specs.rate = RATE_48000;
+
+ m_specs = specs;
+
+ SDL_AudioSpec format, obtained;
+
+ format.freq = m_specs.rate;
+ if(m_specs.format == FORMAT_U8)
+ format.format = AUDIO_U8;
+ else
+ format.format = AUDIO_S16SYS;
+ format.channels = m_specs.channels;
+ format.samples = buffersize;
+ format.callback = SDLDevice::SDL_mix;
+ format.userdata = this;
+
+ if(SDL_OpenAudio(&format, &obtained) != 0)
+ AUD_THROW(DeviceException, "The audio device couldn't be opened with SDL.");
+
+ m_specs.rate = (SampleRate)obtained.freq;
+ m_specs.channels = (Channels)obtained.channels;
+ if(obtained.format == AUDIO_U8)
+ m_specs.format = FORMAT_U8;
+ else if(obtained.format == AUDIO_S16LSB || obtained.format == AUDIO_S16MSB)
+ m_specs.format = FORMAT_S16;
+ else
+ {
+ SDL_CloseAudio();
+ AUD_THROW(DeviceException, "The sample format obtained from SDL is not supported.");
+ }
+
+ create();
+}
+
+SDLDevice::~SDLDevice()
+{
+ SDL_PauseAudio(1);
+ SDL_CloseAudio();
+
+ destroy();
+}
+
+class SDLDeviceFactory : public IDeviceFactory
+{
+private:
+ DeviceSpecs m_specs;
+ int m_buffersize;
+
+public:
+ SDLDeviceFactory() :
+ m_buffersize(AUD_DEFAULT_BUFFER_SIZE)
+ {
+ m_specs.format = FORMAT_S16;
+ m_specs.channels = CHANNELS_STEREO;
+ m_specs.rate = RATE_48000;
+ }
+
+ virtual std::shared_ptr<IDevice> openDevice()
+ {
+ return std::shared_ptr<IDevice>(new SDLDevice(m_specs, m_buffersize));
+ }
+
+ virtual int getPriority()
+ {
+ return 1 << 5;
+ }
+
+ virtual void setSpecs(DeviceSpecs specs)
+ {
+ m_specs = specs;
+ }
+
+ virtual void setBufferSize(int buffersize)
+ {
+ m_buffersize = buffersize;
+ }
+
+ virtual void setName(std::string name)
+ {
+ }
+};
+
+void SDLDevice::registerPlugin()
+{
+ DeviceManager::registerDevice("SDL", std::shared_ptr<IDeviceFactory>(new SDLDeviceFactory));
+}
+
+#ifdef SDL_PLUGIN
+extern "C" AUD_PLUGIN_API void registerPlugin()
+{
+ SDLDevice::registerPlugin();
+}
+
+extern "C" AUD_PLUGIN_API const char* getName()
+{
+ return "SDL";
+}
+#endif
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/plugins/sdl/SDLDevice.h b/extern/audaspace/plugins/sdl/SDLDevice.h
new file mode 100644
index 00000000000..935732bb281
--- /dev/null
+++ b/extern/audaspace/plugins/sdl/SDLDevice.h
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+#ifdef SDL_PLUGIN
+#define AUD_BUILD_PLUGIN
+#endif
+
+/**
+ * @file SDLDevice.h
+ * @ingroup plugin
+ * The SDLDevice class.
+ */
+
+#include "devices/SoftwareDevice.h"
+
+#include <SDL.h>
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * This device plays back through SDL, the simple direct media layer.
+ */
+class AUD_PLUGIN_API SDLDevice : public SoftwareDevice
+{
+private:
+ /**
+ * Whether there is currently playback.
+ */
+ bool m_playback;
+
+ /**
+ * Mixes the next bytes into the buffer.
+ * \param data The SDL device.
+ * \param buffer The target buffer.
+ * \param length The length in bytes to be filled.
+ */
+ AUD_LOCAL static void SDL_mix(void* data, Uint8* buffer, int length);
+
+ // delete copy constructor and operator=
+ SDLDevice(const SDLDevice&) = delete;
+ SDLDevice& operator=(const SDLDevice&) = delete;
+
+protected:
+ virtual void playing(bool playing);
+
+public:
+ /**
+ * Opens the SDL audio device for playback.
+ * \param specs The wanted audio specification.
+ * \param buffersize The size of the internal buffer.
+ * \note The specification really used for opening the device may differ.
+ * \exception Exception Thrown if the audio device cannot be opened.
+ */
+ SDLDevice(DeviceSpecs specs, int buffersize = AUD_DEFAULT_BUFFER_SIZE);
+
+ /**
+ * Closes the SDL audio device.
+ */
+ virtual ~SDLDevice();
+
+ /**
+ * Registers this plugin.
+ */
+ static void registerPlugin();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/Exception.cpp b/extern/audaspace/src/Exception.cpp
new file mode 100644
index 00000000000..1c31cb29555
--- /dev/null
+++ b/extern/audaspace/src/Exception.cpp
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "Exception.h"
+
+#include <sstream>
+
+AUD_NAMESPACE_BEGIN
+
+Exception::Exception(const Exception& exception) :
+ Exception(exception.m_message, exception.m_file, exception.m_line)
+{
+}
+
+Exception::Exception(std::string message, std::string file, int line) :
+ m_message(message),
+ m_file(file),
+ m_line(line)
+{
+}
+
+Exception::~Exception() AUD_NOEXCEPT
+{
+}
+
+const char* Exception::what() const AUD_NOEXCEPT
+{
+ return m_message.c_str();
+}
+
+std::string Exception::getDebugMessage() const
+{
+ std::stringstream out;
+
+ out << m_message << " File " << m_file << ":" << m_line;
+
+ return out.str();
+}
+
+const std::string& Exception::getMessage() const
+{
+ return m_message;
+}
+
+const std::string& Exception::getFile() const
+{
+ return m_file;
+}
+
+int Exception::getLine() const
+{
+ return m_line;
+}
+
+FileException::FileException(std::string message, std::string file, int line) :
+ Exception(message, file, line)
+{
+}
+
+FileException::FileException(const FileException& exception) :
+ Exception(exception)
+{
+}
+
+FileException::~FileException() AUD_NOEXCEPT
+{
+}
+
+DeviceException::DeviceException(std::string message, std::string file, int line) :
+ Exception(message, file, line)
+{
+}
+
+DeviceException::DeviceException(const DeviceException& exception) :
+ Exception(exception)
+{
+}
+
+DeviceException::~DeviceException() AUD_NOEXCEPT
+{
+}
+
+StateException::StateException(std::string message, std::string file, int line) :
+ Exception(message, file, line)
+{
+}
+
+StateException::StateException(const StateException& exception) :
+ Exception(exception)
+{
+}
+
+StateException::~StateException() AUD_NOEXCEPT
+{
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/devices/DefaultSynchronizer.cpp b/extern/audaspace/src/devices/DefaultSynchronizer.cpp
new file mode 100644
index 00000000000..aa8945dadaa
--- /dev/null
+++ b/extern/audaspace/src/devices/DefaultSynchronizer.cpp
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "devices/DefaultSynchronizer.h"
+#include "devices/IHandle.h"
+
+AUD_NAMESPACE_BEGIN
+
+void DefaultSynchronizer::seek(std::shared_ptr<IHandle> handle, float time)
+{
+ handle->seek(time);
+}
+
+float DefaultSynchronizer::getPosition(std::shared_ptr<IHandle> handle)
+{
+ return handle->getPosition();
+}
+
+void DefaultSynchronizer::play()
+{
+}
+
+void DefaultSynchronizer::stop()
+{
+}
+
+void DefaultSynchronizer::setSyncCallback(ISynchronizer::syncFunction function, void* data)
+{
+}
+
+int DefaultSynchronizer::isPlaying()
+{
+ return -1;
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/devices/DeviceManager.cpp b/extern/audaspace/src/devices/DeviceManager.cpp
new file mode 100644
index 00000000000..2ebc3d58c86
--- /dev/null
+++ b/extern/audaspace/src/devices/DeviceManager.cpp
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "devices/DeviceManager.h"
+#include "devices/IDeviceFactory.h"
+#include "devices/IDevice.h"
+#include "devices/I3DDevice.h"
+
+#include <limits>
+#include <string>
+#include <algorithm>
+
+AUD_NAMESPACE_BEGIN
+
+std::unordered_map<std::string, std::shared_ptr<IDeviceFactory>> DeviceManager::m_factories;
+std::shared_ptr<IDevice> DeviceManager::m_device;
+
+void DeviceManager::registerDevice(std::string name, std::shared_ptr<IDeviceFactory> factory)
+{
+ m_factories[name] = factory;
+}
+
+std::shared_ptr<IDeviceFactory> DeviceManager::getDeviceFactory(std::string name)
+{
+ return m_factories[name];
+}
+
+std::shared_ptr<IDeviceFactory> DeviceManager::getDefaultDeviceFactory()
+{
+ int min = std::numeric_limits<int>::min();
+
+ std::shared_ptr<IDeviceFactory> result;
+
+ for(auto factory : m_factories)
+ {
+ if(factory.second->getPriority() >= min)
+ {
+ result = factory.second;
+ min = result->getPriority();
+ }
+ }
+
+ return result;
+}
+
+void DeviceManager::setDevice(std::shared_ptr<IDevice> device)
+{
+ m_device = device;
+}
+
+void DeviceManager::openDevice(std::string name)
+{
+ setDevice(getDeviceFactory(name)->openDevice());
+}
+
+void DeviceManager::openDefaultDevice()
+{
+ setDevice(getDefaultDeviceFactory()->openDevice());
+}
+
+void DeviceManager::releaseDevice()
+{
+ m_device = nullptr;
+}
+
+std::shared_ptr<IDevice> DeviceManager::getDevice()
+{
+ return m_device;
+}
+
+std::shared_ptr<I3DDevice> DeviceManager::get3DDevice()
+{
+ return std::dynamic_pointer_cast<I3DDevice>(m_device);
+}
+
+std::vector<std::string> DeviceManager::getAvailableDeviceNames()
+{
+ struct DeviceNamePriority {
+ std::string name;
+ int priority;
+ };
+
+ std::vector<DeviceNamePriority> devices;
+ devices.reserve(m_factories.size());
+
+ for(const auto& pair : m_factories)
+ devices.push_back({pair.first, pair.second->getPriority()});
+
+ auto sort = [](const DeviceNamePriority& lhs, const DeviceNamePriority& rhs){
+ return lhs.priority > rhs.priority;
+ };
+
+ std::sort(devices.begin(), devices.end(), sort);
+
+ std::vector<std::string> names;
+ names.reserve(devices.size());
+
+ for(const auto& device : devices)
+ names.push_back(device.name);
+
+ return names;
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/devices/NULLDevice.cpp b/extern/audaspace/src/devices/NULLDevice.cpp
new file mode 100644
index 00000000000..a82537f43b2
--- /dev/null
+++ b/extern/audaspace/src/devices/NULLDevice.cpp
@@ -0,0 +1,193 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "devices/NULLDevice.h"
+#include "devices/DeviceManager.h"
+#include "devices/IDeviceFactory.h"
+
+#include <limits>
+#include <string>
+
+AUD_NAMESPACE_BEGIN
+
+NULLDevice::NULLHandle::NULLHandle()
+{
+}
+
+bool NULLDevice::NULLHandle::pause()
+{
+ return false;
+}
+
+bool NULLDevice::NULLHandle::resume()
+{
+ return false;
+}
+
+bool NULLDevice::NULLHandle::stop()
+{
+ return false;
+}
+
+bool NULLDevice::NULLHandle::getKeep()
+{
+ return false;
+}
+
+bool NULLDevice::NULLHandle::setKeep(bool keep)
+{
+ return false;
+}
+
+bool NULLDevice::NULLHandle::seek(float position)
+{
+ return false;
+}
+
+float NULLDevice::NULLHandle::getPosition()
+{
+ return std::numeric_limits<float>::quiet_NaN();
+}
+
+Status NULLDevice::NULLHandle::getStatus()
+{
+ return STATUS_INVALID;
+}
+
+float NULLDevice::NULLHandle::getVolume()
+{
+ return std::numeric_limits<float>::quiet_NaN();
+}
+
+bool NULLDevice::NULLHandle::setVolume(float volume)
+{
+ return false;
+}
+
+float NULLDevice::NULLHandle::getPitch()
+{
+ return std::numeric_limits<float>::quiet_NaN();
+}
+
+bool NULLDevice::NULLHandle::setPitch(float pitch)
+{
+ return false;
+}
+
+int NULLDevice::NULLHandle::getLoopCount()
+{
+ return 0;
+}
+
+bool NULLDevice::NULLHandle::setLoopCount(int count)
+{
+ return false;
+}
+
+bool NULLDevice::NULLHandle::setStopCallback(stopCallback callback, void* data)
+{
+ return false;
+}
+
+NULLDevice::NULLDevice()
+{
+}
+
+NULLDevice::~NULLDevice()
+{
+}
+
+DeviceSpecs NULLDevice::getSpecs() const
+{
+ DeviceSpecs specs;
+ specs.channels = CHANNELS_INVALID;
+ specs.format = FORMAT_INVALID;
+ specs.rate = RATE_INVALID;
+ return specs;
+}
+
+std::shared_ptr<IHandle> NULLDevice::play(std::shared_ptr<IReader> reader, bool keep)
+{
+ return std::shared_ptr<IHandle>(new NULLHandle());
+}
+
+std::shared_ptr<IHandle> NULLDevice::play(std::shared_ptr<ISound> sound, bool keep)
+{
+ return std::shared_ptr<IHandle>(new NULLHandle());
+}
+
+void NULLDevice::stopAll()
+{
+}
+
+void NULLDevice::lock()
+{
+}
+
+void NULLDevice::unlock()
+{
+}
+
+float NULLDevice::getVolume() const
+{
+ return std::numeric_limits<float>::quiet_NaN();
+}
+
+void NULLDevice::setVolume(float volume)
+{
+}
+
+ISynchronizer* NULLDevice::getSynchronizer()
+{
+ return nullptr;
+}
+
+class NULLDeviceFactory : public IDeviceFactory
+{
+public:
+ NULLDeviceFactory()
+ {
+ }
+
+ virtual std::shared_ptr<IDevice> openDevice()
+ {
+ return std::shared_ptr<IDevice>(new NULLDevice());
+ }
+
+ virtual int getPriority()
+ {
+ return std::numeric_limits<int>::min();
+ }
+
+ virtual void setSpecs(DeviceSpecs specs)
+ {
+ }
+
+ virtual void setBufferSize(int buffersize)
+ {
+ }
+
+ virtual void setName(std::string name)
+ {
+ }
+};
+
+void NULLDevice::registerPlugin()
+{
+ DeviceManager::registerDevice("Null", std::shared_ptr<IDeviceFactory>(new NULLDeviceFactory));
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/devices/ReadDevice.cpp b/extern/audaspace/src/devices/ReadDevice.cpp
new file mode 100644
index 00000000000..487fee1f59a
--- /dev/null
+++ b/extern/audaspace/src/devices/ReadDevice.cpp
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "devices/ReadDevice.h"
+#include "IReader.h"
+
+#include <cstring>
+
+AUD_NAMESPACE_BEGIN
+
+ReadDevice::ReadDevice(DeviceSpecs specs) :
+ m_playing(false)
+{
+ m_specs = specs;
+
+ create();
+}
+
+ReadDevice::ReadDevice(Specs specs) :
+ m_playing(false)
+{
+ m_specs.specs = specs;
+ m_specs.format = FORMAT_FLOAT32;
+
+ create();
+}
+
+ReadDevice::~ReadDevice()
+{
+ destroy();
+}
+
+bool ReadDevice::read(data_t* buffer, int length)
+{
+ if(m_playing)
+ mix(buffer, length);
+ else
+ if(m_specs.format == FORMAT_U8)
+ std::memset(buffer, 0x80, length * AUD_DEVICE_SAMPLE_SIZE(m_specs));
+ else
+ std::memset(buffer, 0, length * AUD_DEVICE_SAMPLE_SIZE(m_specs));
+ return m_playing;
+}
+
+void ReadDevice::changeSpecs(Specs specs)
+{
+ if(!AUD_COMPARE_SPECS(specs, m_specs.specs))
+ setSpecs(specs);
+}
+
+void ReadDevice::playing(bool playing)
+{
+ m_playing = playing;
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/devices/SoftwareDevice.cpp b/extern/audaspace/src/devices/SoftwareDevice.cpp
new file mode 100644
index 00000000000..c944b9ed12d
--- /dev/null
+++ b/extern/audaspace/src/devices/SoftwareDevice.cpp
@@ -0,0 +1,989 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "devices/SoftwareDevice.h"
+#include "fx/PitchReader.h"
+#include "respec/ChannelMapperReader.h"
+#include "respec/JOSResampleReader.h"
+#include "respec/LinearResampleReader.h"
+#include "respec/Mixer.h"
+#include "Exception.h"
+#include "ISound.h"
+
+#include <algorithm>
+#include <cmath>
+#include <cstring>
+#include <iostream>
+#include <limits>
+#include <mutex>
+
+AUD_NAMESPACE_BEGIN
+
+enum RenderFlags
+{
+ RENDER_DISTANCE = 0x01,
+ RENDER_DOPPLER = 0x02,
+ RENDER_CONE = 0x04,
+ RENDER_VOLUME = 0x08
+};
+
+#define PITCH_MAX 10
+
+/******************************************************************************/
+/********************** SoftwareHandle Handle Code ************************/
+/******************************************************************************/
+
+bool SoftwareDevice::SoftwareHandle::pause(bool keep)
+{
+ if(m_status)
+ {
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(m_status == STATUS_PLAYING)
+ {
+ for(auto it = m_device->m_playingSounds.begin(); it != m_device->m_playingSounds.end(); it++)
+ {
+ if(it->get() == this)
+ {
+ std::shared_ptr<SoftwareHandle> This = *it;
+
+ m_device->m_playingSounds.erase(it);
+ m_device->m_pausedSounds.push_back(This);
+
+ if(m_device->m_playingSounds.empty())
+ m_device->playing(m_device->m_playback = false);
+
+ m_status = keep ? STATUS_STOPPED : STATUS_PAUSED;
+
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
+SoftwareDevice::SoftwareHandle::SoftwareHandle(SoftwareDevice* device, std::shared_ptr<IReader> reader, std::shared_ptr<PitchReader> pitch, std::shared_ptr<ResampleReader> resampler, std::shared_ptr<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_old_volume(0), 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),
+ m_flags(RENDER_CONE), m_stop(nullptr), m_stop_data(nullptr), m_status(STATUS_PLAYING), m_device(device)
+{
+}
+
+void SoftwareDevice::SoftwareHandle::update()
+{
+ int flags = 0;
+
+ m_old_volume = m_volume;
+
+ Vector3 SL;
+ if(m_relative)
+ SL = -m_location;
+ else
+ SL = m_device->m_location - m_location;
+ float distance = SL * SL;
+
+ if(distance > 0)
+ distance = sqrt(distance);
+ else
+ flags |= RENDER_DOPPLER | RENDER_DISTANCE;
+
+ if(m_pitch->getSpecs().channels != CHANNELS_MONO)
+ {
+ m_volume = m_user_volume;
+ m_pitch->setPitch(m_user_pitch);
+ return;
+ }
+
+ flags = ~(flags | m_flags | m_device->m_flags);
+
+ // Doppler and Pitch
+
+ if(flags & RENDER_DOPPLER)
+ {
+ float vls;
+ if(m_relative)
+ vls = 0;
+ else
+ vls = SL * m_device->m_velocity / distance;
+ float vss = SL * m_velocity / distance;
+ float max = m_device->m_speed_of_sound / m_device->m_doppler_factor;
+ if(vss >= max)
+ {
+ m_pitch->setPitch(PITCH_MAX);
+ }
+ else
+ {
+ if(vls > max)
+ vls = max;
+
+ m_pitch->setPitch((m_device->m_speed_of_sound - m_device->m_doppler_factor * vls) / (m_device->m_speed_of_sound - m_device->m_doppler_factor * vss) * m_user_pitch);
+ }
+ }
+ else
+ m_pitch->setPitch(m_user_pitch);
+
+ if(flags & RENDER_VOLUME)
+ {
+ // Distance
+
+ if(flags & RENDER_DISTANCE)
+ {
+ if(m_device->m_distance_model == DISTANCE_MODEL_INVERSE_CLAMPED ||
+ m_device->m_distance_model == DISTANCE_MODEL_LINEAR_CLAMPED ||
+ m_device->m_distance_model == DISTANCE_MODEL_EXPONENT_CLAMPED)
+ {
+ distance = std::max(std::min(m_distance_max, distance), m_distance_reference);
+ }
+
+ switch(m_device->m_distance_model)
+ {
+ case DISTANCE_MODEL_INVERSE:
+ case DISTANCE_MODEL_INVERSE_CLAMPED:
+ m_volume = m_distance_reference / (m_distance_reference + m_attenuation * (distance - m_distance_reference));
+ break;
+ case DISTANCE_MODEL_LINEAR:
+ case DISTANCE_MODEL_LINEAR_CLAMPED:
+ {
+ float temp = m_distance_max - m_distance_reference;
+ if(temp == 0)
+ {
+ if(distance > m_distance_reference)
+ m_volume = 0.0f;
+ else
+ m_volume = 1.0f;
+ }
+ else
+ m_volume = 1.0f - m_attenuation * (distance - m_distance_reference) / (m_distance_max - m_distance_reference);
+ break;
+ }
+ case DISTANCE_MODEL_EXPONENT:
+ case DISTANCE_MODEL_EXPONENT_CLAMPED:
+ if(m_distance_reference == 0)
+ m_volume = 0;
+ else
+ m_volume = std::pow(distance / m_distance_reference, -m_attenuation);
+ break;
+ default:
+ m_volume = 1.0f;
+ }
+ }
+ else
+ m_volume = 1.0f;
+
+ // Cone
+
+ if(flags & RENDER_CONE)
+ {
+ Vector3 SZ = m_orientation.getLookAt();
+
+ float phi = std::acos(float(SZ * SL / (SZ.length() * SL.length())));
+ float t = (phi - m_cone_angle_inner)/(m_cone_angle_outer - m_cone_angle_inner);
+
+ if(t > 0)
+ {
+ if(t > 1)
+ m_volume *= m_cone_volume_outer;
+ else
+ m_volume *= 1 + t * (m_cone_volume_outer - 1);
+ }
+ }
+
+ if(m_volume > m_volume_max)
+ m_volume = m_volume_max;
+ else if(m_volume < m_volume_min)
+ m_volume = m_volume_min;
+
+ // Volume
+
+ m_volume *= m_user_volume;
+ }
+
+ // 3D Cue
+
+ Quaternion orientation;
+
+ if(!m_relative)
+ orientation = m_device->m_orientation;
+
+ Vector3 Z = orientation.getLookAt();
+ Vector3 N = orientation.getUp();
+ Vector3 A = N * ((SL * N) / (N * N)) - SL;
+
+ float Asquare = A * A;
+
+ if(Asquare > 0)
+ {
+ float phi = std::acos(float(Z * A / (Z.length() * std::sqrt(Asquare))));
+ if(N.cross(Z) * A > 0)
+ phi = -phi;
+
+ m_mapper->setMonoAngle(phi);
+ }
+ else
+ m_mapper->setMonoAngle(m_relative ? m_user_pan * M_PI / 2.0 : 0);
+}
+
+void SoftwareDevice::SoftwareHandle::setSpecs(Specs specs)
+{
+ m_mapper->setChannels(specs.channels);
+ m_resampler->setRate(specs.rate);
+}
+
+bool SoftwareDevice::SoftwareHandle::pause()
+{
+ return pause(false);
+}
+
+bool SoftwareDevice::SoftwareHandle::resume()
+{
+ if(m_status)
+ {
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(m_status == STATUS_PAUSED)
+ {
+ for(auto it = m_device->m_pausedSounds.begin(); it != m_device->m_pausedSounds.end(); it++)
+ {
+ if(it->get() == this)
+ {
+ std::shared_ptr<SoftwareHandle> This = *it;
+
+ 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 = STATUS_PLAYING;
+
+ return true;
+ }
+ }
+ }
+
+ }
+
+ return false;
+}
+
+bool SoftwareDevice::SoftwareHandle::stop()
+{
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return false;
+
+ m_status = STATUS_INVALID;
+
+ for(auto it = m_device->m_playingSounds.begin(); it != m_device->m_playingSounds.end(); it++)
+ {
+ if(it->get() == this)
+ {
+ std::shared_ptr<SoftwareHandle> This = *it;
+
+ m_device->m_playingSounds.erase(it);
+
+ if(m_device->m_playingSounds.empty())
+ m_device->playing(m_device->m_playback = false);
+
+ return true;
+ }
+ }
+
+ for(auto it = m_device->m_pausedSounds.begin(); it != m_device->m_pausedSounds.end(); it++)
+ {
+ if(it->get() == this)
+ {
+ std::shared_ptr<SoftwareHandle> This = *it;
+
+ m_device->m_pausedSounds.erase(it);
+
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool SoftwareDevice::SoftwareHandle::getKeep()
+{
+ if(m_status)
+ return m_keep;
+
+ return false;
+}
+
+bool SoftwareDevice::SoftwareHandle::setKeep(bool keep)
+{
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return false;
+
+ m_keep = keep;
+
+ return true;
+}
+
+bool SoftwareDevice::SoftwareHandle::seek(float position)
+{
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return false;
+
+ m_pitch->setPitch(m_user_pitch);
+ m_reader->seek((int)(position * m_reader->getSpecs().rate));
+
+ if(m_status == STATUS_STOPPED)
+ m_status = STATUS_PAUSED;
+
+ return true;
+}
+
+float SoftwareDevice::SoftwareHandle::getPosition()
+{
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return 0.0f;
+
+ float position = m_reader->getPosition() / (float)m_device->m_specs.rate;
+
+ return position;
+}
+
+Status SoftwareDevice::SoftwareHandle::getStatus()
+{
+ return m_status;
+}
+
+float SoftwareDevice::SoftwareHandle::getVolume()
+{
+ return m_user_volume;
+}
+
+bool SoftwareDevice::SoftwareHandle::setVolume(float volume)
+{
+ if(!m_status)
+ return false;
+ m_user_volume = volume;
+
+ if(volume == 0)
+ {
+ m_old_volume = m_volume = volume;
+ m_flags |= RENDER_VOLUME;
+ }
+ else
+ m_flags &= ~RENDER_VOLUME;
+
+ return true;
+}
+
+float SoftwareDevice::SoftwareHandle::getPitch()
+{
+ return m_user_pitch;
+}
+
+bool SoftwareDevice::SoftwareHandle::setPitch(float pitch)
+{
+ if(!m_status)
+ return false;
+ if(pitch > 0.0f)
+ m_user_pitch = pitch;
+ return true;
+}
+
+int SoftwareDevice::SoftwareHandle::getLoopCount()
+{
+ if(!m_status)
+ return 0;
+ return m_loopcount;
+}
+
+bool SoftwareDevice::SoftwareHandle::setLoopCount(int count)
+{
+ if(!m_status)
+ return false;
+
+ if(m_status == STATUS_STOPPED && (count > m_loopcount || count < 0))
+ m_status = STATUS_PAUSED;
+
+ m_loopcount = count;
+
+ return true;
+}
+
+bool SoftwareDevice::SoftwareHandle::setStopCallback(stopCallback callback, void* data)
+{
+ if(!m_status)
+ return false;
+
+ std::lock_guard<ILockable> lock(*m_device);
+
+ if(!m_status)
+ return false;
+
+ m_stop = callback;
+ m_stop_data = data;
+
+ return true;
+}
+
+
+
+/******************************************************************************/
+/******************** SoftwareHandle 3DHandle Code ************************/
+/******************************************************************************/
+
+Vector3 SoftwareDevice::SoftwareHandle::getLocation()
+{
+ if(!m_status)
+ return Vector3();
+
+ return m_location;
+}
+
+bool SoftwareDevice::SoftwareHandle::setLocation(const Vector3& location)
+{
+ if(!m_status)
+ return false;
+
+ m_location = location;
+
+ return true;
+}
+
+Vector3 SoftwareDevice::SoftwareHandle::getVelocity()
+{
+ if(!m_status)
+ return Vector3();
+
+ return m_velocity;
+}
+
+bool SoftwareDevice::SoftwareHandle::setVelocity(const Vector3& velocity)
+{
+ if(!m_status)
+ return false;
+
+ m_velocity = velocity;
+
+ return true;
+}
+
+Quaternion SoftwareDevice::SoftwareHandle::getOrientation()
+{
+ if(!m_status)
+ return Quaternion();
+
+ return m_orientation;
+}
+
+bool SoftwareDevice::SoftwareHandle::setOrientation(const Quaternion& orientation)
+{
+ if(!m_status)
+ return false;
+
+ m_orientation = orientation;
+
+ return true;
+}
+
+bool SoftwareDevice::SoftwareHandle::isRelative()
+{
+ if(!m_status)
+ return false;
+
+ return m_relative;
+}
+
+bool SoftwareDevice::SoftwareHandle::setRelative(bool relative)
+{
+ if(!m_status)
+ return false;
+
+ m_relative = relative;
+
+ return true;
+}
+
+float SoftwareDevice::SoftwareHandle::getVolumeMaximum()
+{
+ if(!m_status)
+ return std::numeric_limits<float>::quiet_NaN();
+
+ return m_volume_max;
+}
+
+bool SoftwareDevice::SoftwareHandle::setVolumeMaximum(float volume)
+{
+ if(!m_status)
+ return false;
+
+ m_volume_max = volume;
+
+ return true;
+}
+
+float SoftwareDevice::SoftwareHandle::getVolumeMinimum()
+{
+ if(!m_status)
+ return std::numeric_limits<float>::quiet_NaN();
+
+ return m_volume_min;
+}
+
+bool SoftwareDevice::SoftwareHandle::setVolumeMinimum(float volume)
+{
+ if(!m_status)
+ return false;
+
+ m_volume_min = volume;
+
+ return true;
+}
+
+float SoftwareDevice::SoftwareHandle::getDistanceMaximum()
+{
+ if(!m_status)
+ return std::numeric_limits<float>::quiet_NaN();
+
+ return m_distance_max;
+}
+
+bool SoftwareDevice::SoftwareHandle::setDistanceMaximum(float distance)
+{
+ if(!m_status)
+ return false;
+
+ m_distance_max = distance;
+
+ return true;
+}
+
+float SoftwareDevice::SoftwareHandle::getDistanceReference()
+{
+ if(!m_status)
+ return std::numeric_limits<float>::quiet_NaN();
+
+ return m_distance_reference;
+}
+
+bool SoftwareDevice::SoftwareHandle::setDistanceReference(float distance)
+{
+ if(!m_status)
+ return false;
+
+ m_distance_reference = distance;
+
+ return true;
+}
+
+float SoftwareDevice::SoftwareHandle::getAttenuation()
+{
+ if(!m_status)
+ return std::numeric_limits<float>::quiet_NaN();
+
+ return m_attenuation;
+}
+
+bool SoftwareDevice::SoftwareHandle::setAttenuation(float factor)
+{
+ if(!m_status)
+ return false;
+
+ m_attenuation = factor;
+
+ if(factor == 0)
+ m_flags |= RENDER_DISTANCE;
+ else
+ m_flags &= ~RENDER_DISTANCE;
+
+ return true;
+}
+
+float SoftwareDevice::SoftwareHandle::getConeAngleOuter()
+{
+ if(!m_status)
+ return std::numeric_limits<float>::quiet_NaN();
+
+ return m_cone_angle_outer * 360.0f / M_PI;
+}
+
+bool SoftwareDevice::SoftwareHandle::setConeAngleOuter(float angle)
+{
+ if(!m_status)
+ return false;
+
+ m_cone_angle_outer = angle * M_PI / 360.0f;
+
+ return true;
+}
+
+float SoftwareDevice::SoftwareHandle::getConeAngleInner()
+{
+ if(!m_status)
+ return std::numeric_limits<float>::quiet_NaN();
+
+ return m_cone_angle_inner * 360.0f / M_PI;
+}
+
+bool SoftwareDevice::SoftwareHandle::setConeAngleInner(float angle)
+{
+ if(!m_status)
+ return false;
+
+ if(angle >= 360)
+ m_flags |= RENDER_CONE;
+ else
+ m_flags &= ~RENDER_CONE;
+
+ m_cone_angle_inner = angle * M_PI / 360.0f;
+
+ return true;
+}
+
+float SoftwareDevice::SoftwareHandle::getConeVolumeOuter()
+{
+ if(!m_status)
+ return std::numeric_limits<float>::quiet_NaN();
+
+ return m_cone_volume_outer;
+}
+
+bool SoftwareDevice::SoftwareHandle::setConeVolumeOuter(float volume)
+{
+ if(!m_status)
+ return false;
+
+ m_cone_volume_outer = volume;
+
+ return true;
+}
+
+/******************************************************************************/
+/**************************** IDevice Code ************************************/
+/******************************************************************************/
+
+void SoftwareDevice::create()
+{
+ m_playback = false;
+ m_volume = 1.0f;
+ m_mixer = std::shared_ptr<Mixer>(new Mixer(m_specs));
+ m_speed_of_sound = 343.3f;
+ m_doppler_factor = 1.0f;
+ m_distance_model = DISTANCE_MODEL_INVERSE_CLAMPED;
+ m_flags = 0;
+ m_quality = false;
+}
+
+void SoftwareDevice::destroy()
+{
+ if(m_playback)
+ playing(m_playback = false);
+
+ while(!m_playingSounds.empty())
+ m_playingSounds.front()->stop();
+
+ while(!m_pausedSounds.empty())
+ m_pausedSounds.front()->stop();
+}
+
+void SoftwareDevice::mix(data_t* buffer, int length)
+{
+ m_buffer.assureSize(length * AUD_SAMPLE_SIZE(m_specs));
+
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ {
+ std::shared_ptr<SoftwareDevice::SoftwareHandle> sound;
+ int len;
+ int pos;
+ bool eos;
+ std::list<std::shared_ptr<SoftwareDevice::SoftwareHandle> > stopSounds;
+ std::list<std::shared_ptr<SoftwareDevice::SoftwareHandle> > pauseSounds;
+ sample_t* buf = m_buffer.getBuffer();
+
+ m_mixer->clear(length);
+
+ // for all sounds
+ for(auto& sound : m_playingSounds)
+ {
+ // get the buffer from the source
+ pos = 0;
+ len = length;
+
+ // update 3D Info
+ sound->update();
+
+ try
+ {
+ sound->m_reader->read(len, eos, buf);
+
+ // in case of looping
+ while(pos + len < length && sound->m_loopcount && eos)
+ {
+ m_mixer->mix(buf, pos, len, sound->m_volume, sound->m_old_volume);
+
+ pos += len;
+
+ if(sound->m_loopcount > 0)
+ sound->m_loopcount--;
+
+ sound->m_reader->seek(0);
+
+ len = length - pos;
+ sound->m_reader->read(len, eos, buf);
+
+ // prevent endless loop
+ if(!len)
+ break;
+ }
+ }
+ catch(Exception& e)
+ {
+ len = 0;
+ std::cerr << "Caught exception while reading sound data during playback with software mixing: " << e.getMessage() << std::endl;
+ }
+
+ m_mixer->mix(buf, pos, len, sound->m_volume, sound->m_old_volume);
+
+ // in case the end of the sound is reached
+ if(eos && !sound->m_loopcount)
+ {
+ if(sound->m_stop)
+ sound->m_stop(sound->m_stop_data);
+
+ if(sound->m_keep)
+ pauseSounds.push_back(sound);
+ else
+ stopSounds.push_back(sound);
+ }
+ }
+
+ // superpose
+ m_mixer->read(buffer, m_volume);
+
+ // cleanup
+ for(auto& sound : pauseSounds)
+ sound->pause(true);
+
+ for(auto& sound : stopSounds)
+ sound->stop();
+
+ pauseSounds.clear();
+ stopSounds.clear();
+ }
+}
+
+void SoftwareDevice::setPanning(IHandle* handle, float pan)
+{
+ SoftwareDevice::SoftwareHandle* h = dynamic_cast<SoftwareDevice::SoftwareHandle*>(handle);
+ h->m_user_pan = pan;
+}
+
+void SoftwareDevice::setQuality(bool quality)
+{
+ m_quality = quality;
+}
+
+void SoftwareDevice::setSpecs(Specs specs)
+{
+ m_specs.specs = specs;
+ m_mixer->setSpecs(specs);
+
+ for(auto& sound : m_playingSounds)
+ {
+ sound->setSpecs(specs);
+ }
+}
+
+SoftwareDevice::SoftwareDevice()
+{
+}
+
+DeviceSpecs SoftwareDevice::getSpecs() const
+{
+ return m_specs;
+}
+
+std::shared_ptr<IHandle> SoftwareDevice::play(std::shared_ptr<IReader> reader, bool keep)
+{
+ // prepare the reader
+ // pitch
+
+ std::shared_ptr<PitchReader> pitch = std::shared_ptr<PitchReader>(new PitchReader(reader, 1));
+ reader = std::shared_ptr<IReader>(pitch);
+
+ std::shared_ptr<ResampleReader> resampler;
+
+ // resample
+ if(m_quality)
+ resampler = std::shared_ptr<ResampleReader>(new JOSResampleReader(reader, m_specs.rate));
+ else
+ resampler = std::shared_ptr<ResampleReader>(new LinearResampleReader(reader, m_specs.rate));
+ reader = std::shared_ptr<IReader>(resampler);
+
+ // rechannel
+ std::shared_ptr<ChannelMapperReader> mapper = std::shared_ptr<ChannelMapperReader>(new ChannelMapperReader(reader, m_specs.channels));
+ reader = std::shared_ptr<IReader>(mapper);
+
+ if(!reader.get())
+ return std::shared_ptr<IHandle>();
+
+ // play sound
+ std::shared_ptr<SoftwareDevice::SoftwareHandle> sound = std::shared_ptr<SoftwareDevice::SoftwareHandle>(new SoftwareDevice::SoftwareHandle(this, reader, pitch, resampler, mapper, keep));
+
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ m_playingSounds.push_back(sound);
+
+ if(!m_playback)
+ playing(m_playback = true);
+
+ return std::shared_ptr<IHandle>(sound);
+}
+
+std::shared_ptr<IHandle> SoftwareDevice::play(std::shared_ptr<ISound> sound, bool keep)
+{
+ return play(sound->createReader(), keep);
+}
+
+void SoftwareDevice::stopAll()
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ while(!m_playingSounds.empty())
+ m_playingSounds.front()->stop();
+
+ while(!m_pausedSounds.empty())
+ m_pausedSounds.front()->stop();
+}
+
+void SoftwareDevice::lock()
+{
+ m_mutex.lock();
+}
+
+void SoftwareDevice::unlock()
+{
+ m_mutex.unlock();
+}
+
+float SoftwareDevice::getVolume() const
+{
+ return m_volume;
+}
+
+void SoftwareDevice::setVolume(float volume)
+{
+ m_volume = volume;
+}
+
+ISynchronizer* SoftwareDevice::getSynchronizer()
+{
+ return &m_synchronizer;
+}
+
+/******************************************************************************/
+/**************************** 3D Device Code **********************************/
+/******************************************************************************/
+
+Vector3 SoftwareDevice::getListenerLocation() const
+{
+ return m_location;
+}
+
+void SoftwareDevice::setListenerLocation(const Vector3& location)
+{
+ m_location = location;
+}
+
+Vector3 SoftwareDevice::getListenerVelocity() const
+{
+ return m_velocity;
+}
+
+void SoftwareDevice::setListenerVelocity(const Vector3& velocity)
+{
+ m_velocity = velocity;
+}
+
+Quaternion SoftwareDevice::getListenerOrientation() const
+{
+ return m_orientation;
+}
+
+void SoftwareDevice::setListenerOrientation(const Quaternion& orientation)
+{
+ m_orientation = orientation;
+}
+
+float SoftwareDevice::getSpeedOfSound() const
+{
+ return m_speed_of_sound;
+}
+
+void SoftwareDevice::setSpeedOfSound(float speed)
+{
+ m_speed_of_sound = speed;
+}
+
+float SoftwareDevice::getDopplerFactor() const
+{
+ return m_doppler_factor;
+}
+
+void SoftwareDevice::setDopplerFactor(float factor)
+{
+ m_doppler_factor = factor;
+ if(factor == 0)
+ m_flags |= RENDER_DOPPLER;
+ else
+ m_flags &= ~RENDER_DOPPLER;
+}
+
+DistanceModel SoftwareDevice::getDistanceModel() const
+{
+ return m_distance_model;
+}
+
+void SoftwareDevice::setDistanceModel(DistanceModel model)
+{
+ m_distance_model = model;
+ if(model == DISTANCE_MODEL_INVALID)
+ m_flags |= RENDER_DISTANCE;
+ else
+ m_flags &= ~RENDER_DISTANCE;
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/file/File.cpp b/extern/audaspace/src/file/File.cpp
new file mode 100644
index 00000000000..0cdecb03657
--- /dev/null
+++ b/extern/audaspace/src/file/File.cpp
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "file/File.h"
+#include "file/FileManager.h"
+#include "util/Buffer.h"
+#include "Exception.h"
+
+#include <cstring>
+
+AUD_NAMESPACE_BEGIN
+
+File::File(std::string filename) :
+ m_filename(filename)
+{
+}
+
+File::File(const data_t* buffer, int size) :
+ m_buffer(new Buffer(size))
+{
+ std::memcpy(m_buffer->getBuffer(), buffer, size);
+}
+
+std::shared_ptr<IReader> File::createReader()
+{
+ if(m_buffer.get())
+ return FileManager::createReader(m_buffer);
+ else
+ return FileManager::createReader(m_filename);
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/file/FileManager.cpp b/extern/audaspace/src/file/FileManager.cpp
new file mode 100644
index 00000000000..f8ef8deb409
--- /dev/null
+++ b/extern/audaspace/src/file/FileManager.cpp
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "file/FileManager.h"
+#include "file/IFileInput.h"
+#include "file/IFileOutput.h"
+#include "Exception.h"
+
+AUD_NAMESPACE_BEGIN
+
+std::list<std::shared_ptr<IFileInput>>& FileManager::inputs()
+{
+ static std::list<std::shared_ptr<IFileInput>> inputs;
+ return inputs;
+}
+
+std::list<std::shared_ptr<IFileOutput>>& FileManager::outputs()
+{
+ static std::list<std::shared_ptr<IFileOutput>> outputs;
+ return outputs;
+}
+
+void FileManager::registerInput(std::shared_ptr<IFileInput> input)
+{
+ inputs().push_back(input);
+}
+
+void FileManager::registerOutput(std::shared_ptr<aud::IFileOutput> output)
+{
+ outputs().push_back(output);
+}
+
+std::shared_ptr<IReader> FileManager::createReader(std::string filename)
+{
+ for(std::shared_ptr<IFileInput> input : inputs())
+ {
+ try
+ {
+ return input->createReader(filename);
+ }
+ catch(Exception&) {}
+ }
+
+ AUD_THROW(FileException, "The file couldn't be read with any installed file reader.");
+}
+
+std::shared_ptr<IReader> FileManager::createReader(std::shared_ptr<Buffer> buffer)
+{
+ for(std::shared_ptr<IFileInput> input : inputs())
+ {
+ try
+ {
+ return input->createReader(buffer);
+ }
+ catch(Exception&) {}
+ }
+
+ AUD_THROW(FileException, "The file couldn't be read with any installed file reader.");
+}
+
+std::shared_ptr<IWriter> FileManager::createWriter(std::string filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate)
+{
+ for(std::shared_ptr<IFileOutput> output : outputs())
+ {
+ try
+ {
+ return output->createWriter(filename, specs, format, codec, bitrate);
+ }
+ catch(Exception&) {}
+ }
+
+ AUD_THROW(FileException, "The file couldn't be written with any installed writer.");
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/file/FileWriter.cpp b/extern/audaspace/src/file/FileWriter.cpp
new file mode 100644
index 00000000000..a6bb0f0049a
--- /dev/null
+++ b/extern/audaspace/src/file/FileWriter.cpp
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "file/FileWriter.h"
+#include "file/FileManager.h"
+#include "util/Buffer.h"
+#include "IReader.h"
+#include "Exception.h"
+
+AUD_NAMESPACE_BEGIN
+
+std::shared_ptr<IWriter> FileWriter::createWriter(std::string filename,DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate)
+{
+ return FileManager::createWriter(filename, specs, format, codec, bitrate);
+}
+
+void FileWriter::writeReader(std::shared_ptr<IReader> reader, std::shared_ptr<IWriter> writer, unsigned int length, unsigned int buffersize)
+{
+ Buffer buffer(buffersize * AUD_SAMPLE_SIZE(writer->getSpecs()));
+ sample_t* buf = buffer.getBuffer();
+
+ int len;
+ bool eos = false;
+ int channels = writer->getSpecs().channels;
+
+ for(unsigned int pos = 0; ((pos < length) || (length <= 0)) && !eos; pos += len)
+ {
+ len = buffersize;
+ if((len > length - pos) && (length > 0))
+ len = length - pos;
+ reader->read(len, eos, buf);
+
+ for(int i = 0; i < len * channels; i++)
+ {
+ // clamping!
+ if(buf[i] > 1)
+ buf[i] = 1;
+ else if(buf[i] < -1)
+ buf[i] = -1;
+ }
+
+ writer->write(len, buf);
+ }
+}
+
+void FileWriter::writeReader(std::shared_ptr<IReader> reader, std::vector<std::shared_ptr<IWriter> >& writers, unsigned int length, unsigned int buffersize)
+{
+ Buffer buffer(buffersize * AUD_SAMPLE_SIZE(reader->getSpecs()));
+ Buffer buffer2(buffersize * sizeof(sample_t));
+ sample_t* buf = buffer.getBuffer();
+ sample_t* buf2 = buffer2.getBuffer();
+
+ int len;
+ bool eos = false;
+ int channels = reader->getSpecs().channels;
+
+ for(unsigned int pos = 0; ((pos < length) || (length <= 0)) && !eos; pos += len)
+ {
+ len = buffersize;
+ if((len > length - pos) && (length > 0))
+ len = length - pos;
+ reader->read(len, eos, buf);
+
+ for(int channel = 0; channel < channels; channel++)
+ {
+ for(int i = 0; i < len; i++)
+ {
+ // clamping!
+ if(buf[i * channels + channel] > 1)
+ buf2[i] = 1;
+ else if(buf[i * channels + channel] < -1)
+ buf2[i] = -1;
+ else
+ buf2[i] = buf[i * channels + channel];
+ }
+
+ writers[channel]->write(len, buf2);
+ }
+ }
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/ADSR.cpp b/extern/audaspace/src/fx/ADSR.cpp
new file mode 100644
index 00000000000..f147affda72
--- /dev/null
+++ b/extern/audaspace/src/fx/ADSR.cpp
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/ADSR.h"
+#include "fx/ADSRReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+ADSR::ADSR(std::shared_ptr<ISound> sound, float attack, float decay, float sustain, float release) :
+ Effect(sound),
+ m_attack(attack), m_decay(decay), m_sustain(sustain), m_release(release)
+{
+}
+
+float ADSR::getAttack() const
+{
+ return m_attack;
+}
+
+void ADSR::setAttack(float attack)
+{
+ m_attack = attack;
+}
+
+float ADSR::getDecay() const
+{
+ return m_decay;
+}
+
+void ADSR::setDecay(float decay)
+{
+ m_decay = decay;
+}
+
+float ADSR::getSustain() const
+{
+ return m_sustain;
+}
+
+void ADSR::setSustain(float sustain)
+{
+ m_sustain = sustain;
+}
+
+float ADSR::getRelease() const
+{
+ return m_release;
+}
+
+void ADSR::setRelease(float release)
+{
+ m_release = release;
+}
+
+std::shared_ptr<IReader> ADSR::createReader()
+{
+ return std::shared_ptr<IReader>(new ADSRReader(getReader(), m_attack, m_decay, m_sustain, m_release));
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/ADSRReader.cpp b/extern/audaspace/src/fx/ADSRReader.cpp
new file mode 100644
index 00000000000..6499b55468e
--- /dev/null
+++ b/extern/audaspace/src/fx/ADSRReader.cpp
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/ADSRReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+ADSRReader::ADSRReader(std::shared_ptr<IReader> reader, float attack, float decay, float sustain, float release) :
+ EffectReader(reader),
+ m_attack(attack), m_decay(decay), m_sustain(sustain), m_release(release)
+{
+ nextState(ADSR_STATE_ATTACK);
+}
+
+ADSRReader::~ADSRReader()
+{
+}
+
+void ADSRReader::nextState(ADSRState state)
+{
+ m_state = state;
+
+ switch(m_state)
+ {
+ case ADSR_STATE_ATTACK:
+ m_level = 0;
+ if(m_attack <= 0)
+ {
+ nextState(ADSR_STATE_DECAY);
+ return;
+ }
+ return;
+ case ADSR_STATE_DECAY:
+ if(m_decay <= 0)
+ {
+ nextState(ADSR_STATE_SUSTAIN);
+ return;
+ }
+ if(m_level > 1.0)
+ m_level = 1 - (m_level - 1) * m_attack / m_decay * (1 - m_sustain);
+ if(m_level <= m_sustain)
+ nextState(ADSR_STATE_SUSTAIN);
+ break;
+ case ADSR_STATE_SUSTAIN:
+ m_level = m_sustain;
+ break;
+ case ADSR_STATE_RELEASE:
+ if(m_release <= 0)
+ {
+ nextState(ADSR_STATE_INVALID);
+ return;
+ }
+ break;
+ case ADSR_STATE_INVALID:
+ break;
+ }
+}
+
+void ADSRReader::read(int & length, bool &eos, sample_t* buffer)
+{
+ Specs specs = m_reader->getSpecs();
+ m_reader->read(length, eos, buffer);
+
+ for(int i = 0; i < length; i++)
+ {
+ for(int channel = 0; channel < specs.channels; channel++)
+ {
+ buffer[i * specs.channels + channel] *= m_level;
+ }
+
+ switch(m_state)
+ {
+ case ADSR_STATE_ATTACK:
+ m_level += 1 / m_attack / specs.rate;
+ if(m_level >= 1)
+ nextState(ADSR_STATE_DECAY);
+ break;
+ case ADSR_STATE_DECAY:
+ m_level -= (1 - m_sustain) / m_decay / specs.rate;
+ if(m_level <= m_sustain)
+ nextState(ADSR_STATE_SUSTAIN);
+ break;
+ case ADSR_STATE_SUSTAIN:
+ break;
+ case ADSR_STATE_RELEASE:
+ m_level -= m_sustain / m_release / specs.rate ;
+ if(m_level <= 0)
+ nextState(ADSR_STATE_INVALID);
+ break;
+ case ADSR_STATE_INVALID:
+ length = i;
+ return;
+ }
+ }
+}
+
+void ADSRReader::release()
+{
+ nextState(ADSR_STATE_RELEASE);
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/Accumulator.cpp b/extern/audaspace/src/fx/Accumulator.cpp
new file mode 100644
index 00000000000..ba8e6a2841e
--- /dev/null
+++ b/extern/audaspace/src/fx/Accumulator.cpp
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/Accumulator.h"
+#include "fx/CallbackIIRFilterReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+sample_t Accumulator::accumulatorFilterAdditive(CallbackIIRFilterReader* reader, void* useless)
+{
+ float in = reader->x(0);
+ float lastin = reader->x(-1);
+ float out = reader->y(-1) + in - lastin;
+ if(in > lastin)
+ out += in - lastin;
+ return out;
+}
+
+sample_t Accumulator::accumulatorFilter(CallbackIIRFilterReader* reader, void* useless)
+{
+ float in = reader->x(0);
+ float lastin = reader->x(-1);
+ float out = reader->y(-1);
+ if(in > lastin)
+ out += in - lastin;
+ return out;
+}
+
+Accumulator::Accumulator(std::shared_ptr<ISound> sound,
+ bool additive) :
+ Effect(sound),
+ m_additive(additive)
+{
+}
+
+std::shared_ptr<IReader> Accumulator::createReader()
+{
+ return std::shared_ptr<IReader>(new CallbackIIRFilterReader(getReader(), 2, 2, m_additive ? accumulatorFilterAdditive : accumulatorFilter));
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/BaseIIRFilterReader.cpp b/extern/audaspace/src/fx/BaseIIRFilterReader.cpp
new file mode 100644
index 00000000000..6505e5ea600
--- /dev/null
+++ b/extern/audaspace/src/fx/BaseIIRFilterReader.cpp
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/BaseIIRFilterReader.h"
+
+#include <cstring>
+
+AUD_NAMESPACE_BEGIN
+
+BaseIIRFilterReader::BaseIIRFilterReader(std::shared_ptr<IReader> reader, int in, int out) :
+ EffectReader(reader),
+ m_specs(reader->getSpecs()),
+ m_xlen(in), m_ylen(out),
+ m_xpos(0), m_ypos(0), m_channel(0)
+{
+ m_x = new sample_t[m_xlen * m_specs.channels];
+ m_y = new sample_t[m_ylen * m_specs.channels];
+
+ std::memset(m_x, 0, sizeof(sample_t) * m_xlen * m_specs.channels);
+ std::memset(m_y, 0, sizeof(sample_t) * m_ylen * m_specs.channels);
+}
+
+BaseIIRFilterReader::~BaseIIRFilterReader()
+{
+ delete[] m_x;
+ delete[] m_y;
+}
+
+void BaseIIRFilterReader::setLengths(int in, int out)
+{
+ if(in != m_xlen)
+ {
+ sample_t* xn = new sample_t[in * m_specs.channels];
+ std::memset(xn, 0, sizeof(sample_t) * in * m_specs.channels);
+
+ for(m_channel = 0; m_channel < m_specs.channels; m_channel++)
+ {
+ for(int i = 1; i <= in && i <= m_xlen; i++)
+ {
+ xn[(in - i) * m_specs.channels + m_channel] = x(-i);
+ }
+ }
+
+ delete[] m_x;
+ m_x = xn;
+ m_xpos = 0;
+ m_xlen = in;
+ }
+
+ if(out != m_ylen)
+ {
+ sample_t* yn = new sample_t[out * m_specs.channels];
+ std::memset(yn, 0, sizeof(sample_t) * out * m_specs.channels);
+
+ for(m_channel = 0; m_channel < m_specs.channels; m_channel++)
+ {
+ for(int i = 1; i <= out && i <= m_ylen; i++)
+ {
+ yn[(out - i) * m_specs.channels + m_channel] = y(-i);
+ }
+ }
+
+ delete[] m_y;
+ m_y = yn;
+ m_ypos = 0;
+ m_ylen = out;
+ }
+}
+
+void BaseIIRFilterReader::read(int& length, bool& eos, sample_t* buffer)
+{
+ Specs specs = m_reader->getSpecs();
+ if(specs.channels != m_specs.channels)
+ {
+ m_specs.channels = specs.channels;
+
+ delete[] m_x;
+ delete[] m_y;
+
+ m_x = new sample_t[m_xlen * m_specs.channels];
+ m_y = new sample_t[m_ylen * m_specs.channels];
+
+ std::memset(m_x, 0, sizeof(sample_t) * m_xlen * m_specs.channels);
+ std::memset(m_y, 0, sizeof(sample_t) * m_ylen * m_specs.channels);
+ }
+
+ if(specs.rate != m_specs.rate)
+ {
+ m_specs = specs;
+ sampleRateChanged(m_specs.rate);
+ }
+
+ m_reader->read(length, eos, buffer);
+
+ for(m_channel = 0; m_channel < m_specs.channels; m_channel++)
+ {
+ for(int i = 0; i < length; i++)
+ {
+ m_x[m_xpos * m_specs.channels + m_channel] = buffer[i * m_specs.channels + m_channel];
+ m_y[m_ypos * m_specs.channels + m_channel] = buffer[i * m_specs.channels + m_channel] = filter();
+
+ m_xpos = m_xlen ? (m_xpos + 1) % m_xlen : 0;
+ m_ypos = m_ylen ? (m_ypos + 1) % m_ylen : 0;
+ }
+ }
+}
+
+void BaseIIRFilterReader::sampleRateChanged(SampleRate rate)
+{
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/BinauralReader.cpp b/extern/audaspace/src/fx/BinauralReader.cpp
new file mode 100644
index 00000000000..2792adada8a
--- /dev/null
+++ b/extern/audaspace/src/fx/BinauralReader.cpp
@@ -0,0 +1,255 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "fx/BinauralReader.h"
+#include "Exception.h"
+
+#include <cstring>
+#include <cstdlib>
+#include <algorithm>
+
+#define NUM_OUTCHANNELS 2
+#define NUM_CONVOLVERS 4
+#define CROSSFADE_SAMPLES 1024
+
+AUD_NAMESPACE_BEGIN
+BinauralReader::BinauralReader(std::shared_ptr<IReader> reader, std::shared_ptr<HRTF> hrtfs, std::shared_ptr<Source> source, std::shared_ptr<ThreadPool> threadPool, std::shared_ptr<FFTPlan> plan) :
+ m_reader(reader), m_hrtfs(hrtfs), m_source(source), m_N(plan->getSize()), m_threadPool(threadPool), m_position(0), m_eosReader(false), m_eosTail(false), m_transition(false), m_transPos(CROSSFADE_SAMPLES*NUM_OUTCHANNELS)
+{
+ if(m_hrtfs->isEmpty())
+ AUD_THROW(StateException, "The provided HRTF object is empty");
+ if(m_reader->getSpecs().channels != 1)
+ AUD_THROW(StateException, "The sound must have only one channel");
+ if(m_reader->getSpecs().rate != m_hrtfs->getSpecs().rate)
+ AUD_THROW(StateException, "The sound and the HRTFs must have the same rate");
+ m_M = m_L = m_N / 2;
+
+ m_RealAzimuth = m_Azimuth = m_source->getAzimuth();
+ m_RealElevation = m_Elevation = m_source->getElevation();
+ auto irs = m_hrtfs->getImpulseResponse(m_RealAzimuth, m_RealElevation);
+ for(unsigned int i = 0; i < NUM_CONVOLVERS; i++)
+ if(i%NUM_OUTCHANNELS==0)
+ m_convolvers.push_back(std::unique_ptr<Convolver>(new Convolver(irs.first->getChannel(0), irs.first->getLength(), m_threadPool, plan)));
+ else
+ m_convolvers.push_back(std::unique_ptr<Convolver>(new Convolver(irs.second->getChannel(0), irs.second->getLength(), m_threadPool, plan)));
+ m_futures.resize(NUM_CONVOLVERS);
+
+ m_outBuffer = (sample_t*)std::malloc(m_L*NUM_OUTCHANNELS*sizeof(sample_t));
+ m_eOutBufLen = m_outBufLen = m_outBufferPos = m_L * NUM_OUTCHANNELS;
+ m_inBuffer = (sample_t*)std::malloc(m_L * sizeof(sample_t));
+ for(int i = 0; i < NUM_CONVOLVERS; i++)
+ m_vecOut.push_back((sample_t*)std::calloc(m_L, sizeof(sample_t)));
+}
+
+BinauralReader::~BinauralReader()
+{
+ std::free(m_outBuffer);
+ std::free(m_inBuffer);
+ for(int i = 0; i < m_vecOut.size(); i++)
+ std::free(m_vecOut[i]);
+}
+
+bool BinauralReader::isSeekable() const
+{
+ return m_reader->isSeekable();
+}
+
+void BinauralReader::seek(int position)
+{
+ m_position = position;
+ m_reader->seek(position);
+ for(int i = 0; i < NUM_CONVOLVERS; i++)
+ m_convolvers[i]->reset();
+ m_eosTail = false;
+ m_eosReader = false;
+ m_outBufferPos = m_eOutBufLen = m_outBufLen;
+ m_transition = false;
+ m_transPos = CROSSFADE_SAMPLES*NUM_OUTCHANNELS;
+}
+
+int BinauralReader::getLength() const
+{
+ return m_reader->getLength();
+}
+
+int BinauralReader::getPosition() const
+{
+ return m_position;
+}
+
+Specs BinauralReader::getSpecs() const
+{
+ Specs specs = m_reader->getSpecs();
+ specs.channels = CHANNELS_STEREO;
+ return specs;
+}
+
+void BinauralReader::read(int& length, bool& eos, sample_t* buffer)
+{
+ int samples = 0;
+ int iteration = 0;
+ if(length <= 0)
+ {
+ length = 0;
+ eos = (m_eosTail && m_outBufferPos >= m_eOutBufLen);
+ return;
+ }
+
+ eos = false;
+ int writePos = 0;
+ do
+ {
+ int bufRest = m_eOutBufLen - m_outBufferPos;
+ int writeLength = std::min((length*NUM_OUTCHANNELS) - writePos, m_eOutBufLen + bufRest);
+ if(bufRest < writeLength || (m_eOutBufLen == 0 && m_eosTail))
+ {
+ if(bufRest > 0)
+ std::memcpy(buffer + writePos, m_outBuffer + m_outBufferPos, bufRest*sizeof(sample_t));
+ if(!m_eosTail)
+ {
+ int n = NUM_OUTCHANNELS;
+ if(m_transition)
+ n = NUM_CONVOLVERS;
+ else if(checkSource())
+ n = NUM_CONVOLVERS;
+ loadBuffer(n);
+
+ int len = std::min(std::abs(writeLength - bufRest), m_eOutBufLen);
+ std::memcpy(buffer + writePos + bufRest, m_outBuffer, len*sizeof(sample_t));
+ samples += len;
+ m_outBufferPos = len;
+ writeLength = std::min((length*NUM_OUTCHANNELS) - writePos, m_eOutBufLen + bufRest);
+ }
+ else
+ {
+ m_outBufferPos += bufRest;
+ length = (writePos+bufRest) / NUM_OUTCHANNELS;
+ eos = true;
+ return;
+ }
+ }
+ else
+ {
+ std::memcpy(buffer + writePos, m_outBuffer + m_outBufferPos, writeLength*sizeof(sample_t));
+ m_outBufferPos += writeLength;
+ }
+ writePos += writeLength;
+ iteration++;
+ } while(writePos < length*NUM_OUTCHANNELS);
+ m_position += length;
+}
+
+bool BinauralReader::checkSource()
+{
+ if((m_Azimuth != m_source->getAzimuth() || m_Elevation != m_source->getElevation()) && (!m_eosReader && !m_eosTail))
+ {
+ float az = m_Azimuth = m_source->getAzimuth();
+ float el = m_Elevation = m_source->getElevation();
+ auto irs = m_hrtfs->getImpulseResponse(az, el);
+ if(az != m_RealAzimuth || el != m_RealElevation)
+ {
+ m_RealAzimuth = az;
+ m_RealElevation = el;
+ for(int i = 0; i < NUM_OUTCHANNELS; i++)
+ {
+ auto temp = std::move(m_convolvers[i]);
+ m_convolvers[i] = std::move(m_convolvers[i + NUM_OUTCHANNELS]);
+ m_convolvers[i + NUM_OUTCHANNELS] = std::move(temp);
+ }
+ for(int i = 0; i < NUM_OUTCHANNELS; i++)
+ if(i%NUM_OUTCHANNELS == 0)
+ m_convolvers[i]->setImpulseResponse(irs.first->getChannel(0));
+ else
+ m_convolvers[i]->setImpulseResponse(irs.second->getChannel(0));
+
+ m_transPos = CROSSFADE_SAMPLES*NUM_OUTCHANNELS;
+ m_transition = true;
+ return true;
+ }
+ }
+ return false;
+}
+
+void BinauralReader::loadBuffer(int nConvolvers)
+{
+ m_lastLengthIn = m_L;
+ m_reader->read(m_lastLengthIn, m_eosReader, m_inBuffer);
+ if(!m_eosReader || m_lastLengthIn > 0)
+ {
+ int len = m_lastLengthIn;
+ for(int i = 0; i < nConvolvers; i++)
+ m_futures[i] = m_threadPool->enqueue(&BinauralReader::threadFunction, this, i, true);
+ for(int i = 0; i < nConvolvers; i++)
+ len = m_futures[i].get();
+
+ joinByChannel(0, len, nConvolvers);
+ m_eOutBufLen = len*NUM_OUTCHANNELS;
+ }
+ else if(!m_eosTail)
+ {
+ int len = m_lastLengthIn = m_L;
+ for(int i = 0; i < nConvolvers; i++)
+ m_futures[i] = m_threadPool->enqueue(&BinauralReader::threadFunction, this, i, false);
+ for(int i = 0; i < nConvolvers; i++)
+ len = m_futures[i].get();
+
+ joinByChannel(0, len, nConvolvers);
+ m_eOutBufLen = len*NUM_OUTCHANNELS;
+ }
+}
+
+void BinauralReader::joinByChannel(int start, int len, int nConvolvers)
+{
+ int k = 0;
+ float vol = 0;
+ const int l = CROSSFADE_SAMPLES*NUM_OUTCHANNELS;
+ for(int i = 0; i < len*NUM_OUTCHANNELS; i += NUM_OUTCHANNELS)
+ {
+ if(m_transition)
+ {
+ vol = (m_transPos - i) / (float)l;
+ if(vol > 1.0f)
+ vol = 1.0f;
+ else if(vol < 0.0f)
+ vol = 0.0f;
+ }
+
+ for(int j = 0; j < NUM_OUTCHANNELS; j++)
+ m_outBuffer[i + j + start] = ((m_vecOut[j][k] * (1.0f - vol)) + (m_vecOut[j + NUM_OUTCHANNELS][k] * vol))*m_source->getVolume();
+ k++;
+ }
+ if(m_transition)
+ {
+ m_transPos -= len*NUM_OUTCHANNELS;
+ if(m_transPos <= 0)
+ {
+ m_transition = false;
+ m_transPos = l;
+ }
+ }
+}
+
+int BinauralReader::threadFunction(int id, bool input)
+{
+ int l = m_lastLengthIn;
+ if(input)
+ m_convolvers[id]->getNext(m_inBuffer, m_vecOut[id], l, m_eosTail);
+ else
+ m_convolvers[id]->getNext(nullptr, m_vecOut[id], l, m_eosTail);
+ return l;
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/BinauralSound.cpp b/extern/audaspace/src/fx/BinauralSound.cpp
new file mode 100644
index 00000000000..7b9508c9944
--- /dev/null
+++ b/extern/audaspace/src/fx/BinauralSound.cpp
@@ -0,0 +1,60 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "fx/BinauralSound.h"
+#include "fx/BinauralReader.h"
+#include "Exception.h"
+
+#include <cstring>
+
+AUD_NAMESPACE_BEGIN
+
+BinauralSound::BinauralSound(std::shared_ptr<ISound> sound, std::shared_ptr<HRTF> hrtfs, std::shared_ptr<Source> source, std::shared_ptr<ThreadPool> threadPool) :
+ BinauralSound(sound, hrtfs, source, threadPool, std::make_shared<FFTPlan>(0.0))
+{
+}
+
+BinauralSound::BinauralSound(std::shared_ptr<ISound> sound, std::shared_ptr<HRTF> hrtfs, std::shared_ptr<Source> source, std::shared_ptr<ThreadPool> threadPool, std::shared_ptr<FFTPlan> plan) :
+ m_sound(sound), m_hrtfs(hrtfs), m_source(source), m_threadPool(threadPool), m_plan(plan)
+{
+}
+
+std::shared_ptr<IReader> BinauralSound::createReader()
+{
+ return std::make_shared<BinauralReader>(m_sound->createReader(), m_hrtfs, m_source, m_threadPool, m_plan);
+}
+
+std::shared_ptr<HRTF> BinauralSound::getHRTFs()
+{
+ return m_hrtfs;
+}
+
+void BinauralSound::setHRTFs(std::shared_ptr<HRTF> hrtfs)
+{
+ m_hrtfs = hrtfs;
+}
+
+std::shared_ptr<Source> BinauralSound::getSource()
+{
+ return m_source;
+}
+
+void BinauralSound::setSource(std::shared_ptr<Source> source)
+{
+ m_source = source;
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/Butterworth.cpp b/extern/audaspace/src/fx/Butterworth.cpp
new file mode 100644
index 00000000000..1d86cd799b8
--- /dev/null
+++ b/extern/audaspace/src/fx/Butterworth.cpp
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/Butterworth.h"
+#include "fx/ButterworthCalculator.h"
+
+AUD_NAMESPACE_BEGIN
+
+Butterworth::Butterworth(std::shared_ptr<ISound> sound, float frequency) :
+ DynamicIIRFilter(sound, std::shared_ptr<IDynamicIIRFilterCalculator>(new ButterworthCalculator(frequency)))
+{
+}
+
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/ButterworthCalculator.cpp b/extern/audaspace/src/fx/ButterworthCalculator.cpp
new file mode 100644
index 00000000000..f249fd45f15
--- /dev/null
+++ b/extern/audaspace/src/fx/ButterworthCalculator.cpp
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/ButterworthCalculator.h"
+
+#include <cmath>
+
+#define BWPB41 0.76536686473
+#define BWPB42 1.84775906502
+
+AUD_NAMESPACE_BEGIN
+
+ButterworthCalculator::ButterworthCalculator(float frequency) :
+ m_frequency(frequency)
+{
+}
+
+void ButterworthCalculator::recalculateCoefficients(SampleRate rate, std::vector<float> &b, std::vector<float> &a)
+{
+ float omega = 2 * std::tan(m_frequency * M_PI / rate);
+ float o2 = omega * omega;
+ float o4 = o2 * o2;
+ float x1 = o2 + 2.0f * (float)BWPB41 * omega + 4.0f;
+ float x2 = o2 + 2.0f * (float)BWPB42 * omega + 4.0f;
+ float y1 = o2 - 2.0f * (float)BWPB41 * omega + 4.0f;
+ float y2 = o2 - 2.0f * (float)BWPB42 * omega + 4.0f;
+ float o228 = 2.0f * o2 - 8.0f;
+ float norm = x1 * x2;
+ a.push_back(1);
+ a.push_back((x1 + x2) * o228 / norm);
+ a.push_back((x1 * y2 + x2 * y1 + o228 * o228) / norm);
+ a.push_back((y1 + y2) * o228 / norm);
+ a.push_back(y1 * y2 / norm);
+ b.push_back(o4 / norm);
+ b.push_back(4 * o4 / norm);
+ b.push_back(6 * o4 / norm);
+ b.push_back(b[1]);
+ b.push_back(b[0]);
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/CallbackIIRFilterReader.cpp b/extern/audaspace/src/fx/CallbackIIRFilterReader.cpp
new file mode 100644
index 00000000000..f24b6b6c9ec
--- /dev/null
+++ b/extern/audaspace/src/fx/CallbackIIRFilterReader.cpp
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/CallbackIIRFilterReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+CallbackIIRFilterReader::CallbackIIRFilterReader(std::shared_ptr<IReader> reader, int in, int out, doFilterIIR doFilter, endFilterIIR endFilter, void* data) :
+ BaseIIRFilterReader(reader, in, out),
+ m_filter(doFilter), m_endFilter(endFilter), m_data(data)
+{
+}
+
+CallbackIIRFilterReader::~CallbackIIRFilterReader()
+{
+ if(m_endFilter)
+ m_endFilter(m_data);
+}
+
+sample_t CallbackIIRFilterReader::filter()
+{
+ return m_filter(this, m_data);
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/Convolver.cpp b/extern/audaspace/src/fx/Convolver.cpp
new file mode 100644
index 00000000000..24b205e9282
--- /dev/null
+++ b/extern/audaspace/src/fx/Convolver.cpp
@@ -0,0 +1,156 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "fx/Convolver.h"
+
+#include <cmath>
+#include <cstdlib>
+#include <algorithm>
+#include <cstring>
+
+AUD_NAMESPACE_BEGIN
+Convolver::Convolver(std::shared_ptr<std::vector<std::shared_ptr<std::vector<std::complex<sample_t>>>>> ir, int irLength, std::shared_ptr<ThreadPool> threadPool, std::shared_ptr<FFTPlan> plan) :
+ m_N(plan->getSize()), m_M(plan->getSize()/2), m_L(plan->getSize()/2), m_irBuffers(ir), m_irLength(irLength), m_threadPool(threadPool), m_numThreads(std::min(threadPool->getNumOfThreads(), static_cast<unsigned int>(m_irBuffers->size() - 1))), m_tailCounter(0), m_eos(false)
+
+{
+ m_resetFlag = false;
+ m_futures.resize(m_numThreads);
+ for(int i = 0; i < m_irBuffers->size(); i++)
+ {
+ m_fftConvolvers.push_back(std::unique_ptr<FFTConvolver>(new FFTConvolver((*m_irBuffers)[i], plan)));
+ m_delayLine.push_front((fftwf_complex*)std::calloc((m_N / 2) + 1, sizeof(fftwf_complex)));
+ }
+
+ m_accBuffer = (fftwf_complex*)std::calloc((m_N / 2) + 1, sizeof(fftwf_complex));
+ for(int i = 0; i < m_numThreads; i++)
+ m_threadAccBuffers.push_back((fftwf_complex*)std::calloc((m_N / 2) + 1, sizeof(fftwf_complex)));
+}
+
+Convolver::~Convolver()
+{
+ m_resetFlag = true;
+ for(auto &fut : m_futures)
+ if(fut.valid())
+ fut.get();
+
+ std::free(m_accBuffer);
+ for(auto buf : m_threadAccBuffers)
+ std::free(buf);
+ while(!m_delayLine.empty())
+ {
+ std::free(m_delayLine.front());
+ m_delayLine.pop_front();
+ }
+}
+
+void Convolver::getNext(sample_t* inBuffer, sample_t* outBuffer, int& length, bool& eos)
+{
+ if(length > m_L)
+ {
+ length = 0;
+ eos = m_eos;
+ return;
+ }
+ if(m_eos)
+ {
+ eos = m_eos;
+ length = 0;
+ return;
+ }
+
+ eos = false;
+ for(auto &fut : m_futures)
+ if(fut.valid())
+ fut.get();
+
+ if(inBuffer != nullptr)
+ m_fftConvolvers[0]->getNextFDL(inBuffer, reinterpret_cast<std::complex<sample_t>*>(m_accBuffer), length, m_delayLine[0]);
+ else
+ {
+ m_tailCounter++;
+ std::memset(outBuffer, 0, m_L*sizeof(sample_t));
+ m_fftConvolvers[0]->getNextFDL(outBuffer, reinterpret_cast<std::complex<sample_t>*>(m_accBuffer), length, m_delayLine[0]);
+ }
+ m_delayLine.push_front(m_delayLine.back());
+ m_delayLine.pop_back();
+ length = m_L;
+ m_fftConvolvers[0]->IFFT_FDL(m_accBuffer, outBuffer, length);
+ std::memset(m_accBuffer, 0, ((m_N / 2) + 1)*sizeof(fftwf_complex));
+
+ if(m_tailCounter >= m_delayLine.size() && inBuffer == nullptr)
+ {
+ eos = m_eos = true;
+ length = m_irLength%m_M;
+ if(length == 0)
+ length = m_M;
+ }
+ else
+ for(int i = 0; i < m_futures.size(); i++)
+ m_futures[i] = m_threadPool->enqueue(&Convolver::threadFunction, this, i);
+}
+
+void Convolver::reset()
+{
+ m_resetFlag = true;
+ for(auto &fut : m_futures)
+ if(fut.valid())
+ fut.get();
+
+ for(int i = 0; i < m_delayLine.size();i++)
+ std::memset(m_delayLine[i], 0, ((m_N / 2) + 1)*sizeof(fftwf_complex));
+ for(int i = 0; i < m_fftConvolvers.size(); i++)
+ m_fftConvolvers[i]->clear();
+ std::memset(m_accBuffer, 0, ((m_N / 2) + 1)*sizeof(fftwf_complex));
+ m_tailCounter = 0;
+ m_eos = false;
+ m_resetFlag = false;
+}
+
+std::shared_ptr<std::vector<std::shared_ptr<std::vector<std::complex<sample_t>>>>> Convolver::getImpulseResponse()
+{
+ return m_irBuffers;
+}
+
+void Convolver::setImpulseResponse(std::shared_ptr<std::vector<std::shared_ptr<std::vector<std::complex<sample_t>>>>> ir)
+{
+ reset();
+ m_irBuffers = ir;
+ for(int i = 0; i < m_irBuffers->size(); i++)
+ m_fftConvolvers[i]->setImpulseResponse((*m_irBuffers)[i]);
+}
+
+bool Convolver::threadFunction(int id)
+{
+ int total = m_irBuffers->size();
+ int share = std::ceil(((float)total - 1) / (float)m_numThreads);
+ int start = id*share + 1;
+ int end = std::min(start + share, total);
+
+ std::memset(m_threadAccBuffers[id], 0, ((m_N / 2) + 1)*sizeof(fftwf_complex));
+
+ for(int i = start; i < end && !m_resetFlag; i++)
+ m_fftConvolvers[i]->getNextFDL(reinterpret_cast<std::complex<sample_t>*>(m_delayLine[i]), reinterpret_cast<std::complex<sample_t>*>(m_threadAccBuffers[id]));
+
+ m_sumMutex.lock();
+ for(int i = 0; (i < m_N / 2 + 1) && !m_resetFlag; i++)
+ {
+ m_accBuffer[i][0] += m_threadAccBuffers[id][i][0];
+ m_accBuffer[i][1] += m_threadAccBuffers[id][i][1];
+ }
+ m_sumMutex.unlock();
+ return true;
+}
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/ConvolverReader.cpp b/extern/audaspace/src/fx/ConvolverReader.cpp
new file mode 100644
index 00000000000..d5d9050f9a1
--- /dev/null
+++ b/extern/audaspace/src/fx/ConvolverReader.cpp
@@ -0,0 +1,203 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "fx/ConvolverReader.h"
+#include "Exception.h"
+
+#include <cstring>
+#include <algorithm>
+#include <cmath>
+#include <cstdlib>
+
+AUD_NAMESPACE_BEGIN
+ConvolverReader::ConvolverReader(std::shared_ptr<IReader> reader, std::shared_ptr<ImpulseResponse> ir, std::shared_ptr<ThreadPool> threadPool, std::shared_ptr<FFTPlan> plan) :
+ m_reader(reader), m_ir(ir), m_N(plan->getSize()), m_eosReader(false), m_eosTail(false), m_inChannels(reader->getSpecs().channels), m_irChannels(ir->getSpecs().channels), m_threadPool(threadPool), m_position(0)
+{
+ m_nChannelThreads = std::min((int)threadPool->getNumOfThreads(), m_inChannels);
+ m_futures.resize(m_nChannelThreads);
+
+ int irLength = m_ir->getLength();
+ if(m_irChannels != 1 && m_irChannels != m_inChannels)
+ AUD_THROW(StateException, "The impulse response and the sound must either have the same amount of channels or the impulse response must be mono");
+ if(m_reader->getSpecs().rate != m_ir->getSpecs().rate)
+ AUD_THROW(StateException, "The sound and the impulse response. must have the same rate");
+
+ m_M = m_L = m_N / 2;
+
+ if(m_irChannels > 1)
+ for(int i = 0; i < m_inChannels; i++)
+ m_convolvers.push_back(std::unique_ptr<Convolver>(new Convolver(ir->getChannel(i), irLength, m_threadPool, plan)));
+ else
+ for(int i = 0; i < m_inChannels; i++)
+ m_convolvers.push_back(std::unique_ptr<Convolver>(new Convolver(ir->getChannel(0), irLength, m_threadPool, plan)));
+
+ for(int i = 0; i < m_inChannels; i++)
+ m_vecInOut.push_back((sample_t*)std::malloc(m_L*sizeof(sample_t)));
+ m_outBuffer = (sample_t*)std::malloc(m_L*m_inChannels*sizeof(sample_t));
+ m_outBufLen = m_eOutBufLen = m_outBufferPos = m_L*m_inChannels;
+}
+
+ConvolverReader::~ConvolverReader()
+{
+ std::free(m_outBuffer);
+ for(int i = 0; i < m_inChannels; i++)
+ std::free(m_vecInOut[i]);
+}
+
+bool ConvolverReader::isSeekable() const
+{
+ return m_reader->isSeekable();
+}
+
+void ConvolverReader::seek(int position)
+{
+ m_position = position;
+ m_reader->seek(position);
+ for(int i = 0; i < m_inChannels; i++)
+ m_convolvers[i]->reset();
+ m_eosTail = false;
+ m_eosReader = false;
+ m_outBufferPos = m_eOutBufLen = m_outBufLen;
+}
+
+int ConvolverReader::getLength() const
+{
+ return m_reader->getLength();
+}
+
+int ConvolverReader::getPosition() const
+{
+ return m_position;
+}
+
+Specs ConvolverReader::getSpecs() const
+{
+ return m_reader->getSpecs();
+}
+
+void ConvolverReader::read(int& length, bool& eos, sample_t* buffer)
+{
+ if(length <= 0)
+ {
+ length = 0;
+ eos = (m_eosTail && m_outBufferPos >= m_eOutBufLen);
+ return;
+ }
+ eos = false;
+ int writePos = 0;
+ do
+ {
+ int bufRest = m_eOutBufLen - m_outBufferPos;
+ int writeLength = std::min((length*m_inChannels) - writePos, m_eOutBufLen + bufRest);
+ if(bufRest < writeLength || (m_eOutBufLen == 0 && m_eosTail))
+ {
+ if(bufRest > 0)
+ std::memcpy(buffer + writePos, m_outBuffer + m_outBufferPos, bufRest*sizeof(sample_t));
+ if(!m_eosTail)
+ {
+ loadBuffer();
+ int len = std::min(std::abs(writeLength - bufRest), m_eOutBufLen);
+ std::memcpy(buffer + writePos + bufRest, m_outBuffer, len*sizeof(sample_t));
+ m_outBufferPos = len;
+ writeLength = std::min((length*m_inChannels) - writePos, m_eOutBufLen + bufRest);
+ }
+ else
+ {
+ m_outBufferPos += bufRest;
+ length = (writePos + bufRest) / m_inChannels;
+ eos = true;
+ return;
+ }
+ }
+ else
+ {
+ std::memcpy(buffer + writePos, m_outBuffer + m_outBufferPos, writeLength*sizeof(sample_t));
+ m_outBufferPos += writeLength;
+ }
+ writePos += writeLength;
+ } while(writePos < length*m_inChannels);
+ m_position += length;
+}
+
+void ConvolverReader::loadBuffer()
+{
+ m_lastLengthIn = m_L;
+ m_reader->read(m_lastLengthIn, m_eosReader, m_outBuffer);
+ if(!m_eosReader || m_lastLengthIn>0)
+ {
+ divideByChannel(m_outBuffer, m_lastLengthIn*m_inChannels);
+ int len = m_lastLengthIn;
+
+ for(int i = 0; i < m_futures.size(); i++)
+ m_futures[i] = m_threadPool->enqueue(&ConvolverReader::threadFunction, this, i, true);
+ for(auto &fut : m_futures)
+ len = fut.get();
+
+ joinByChannel(0, len);
+ m_eOutBufLen = len*m_inChannels;
+ }
+ else if(!m_eosTail)
+ {
+ int len = m_lastLengthIn = m_L;
+ for(int i = 0; i < m_futures.size(); i++)
+ m_futures[i] = m_threadPool->enqueue(&ConvolverReader::threadFunction, this, i, false);
+ for(auto &fut : m_futures)
+ len = fut.get();
+
+ joinByChannel(0, len);
+ m_eOutBufLen = len*m_inChannels;
+ }
+}
+
+void ConvolverReader::divideByChannel(const sample_t* buffer, int len)
+{
+ int k = 0;
+ for(int i = 0; i < len; i += m_inChannels)
+ {
+ for(int j = 0; j < m_inChannels; j++)
+ m_vecInOut[j][k] = buffer[i + j];
+ k++;
+ }
+}
+
+void ConvolverReader::joinByChannel(int start, int len)
+{
+ int k = 0;
+ for(int i = 0; i < len*m_inChannels; i += m_inChannels)
+ {
+ for(int j = 0; j < m_vecInOut.size(); j++)
+ m_outBuffer[i + j + start] = m_vecInOut[j][k];
+ k++;
+ }
+}
+
+int ConvolverReader::threadFunction(int id, bool input)
+{
+ int share = std::ceil((float)m_inChannels / (float)m_nChannelThreads);
+ int start = id*share;
+ int end = std::min(start + share, m_inChannels);
+
+ int l=m_lastLengthIn;
+ for(int i = start; i < end; i++)
+ if(input)
+ m_convolvers[i]->getNext(m_vecInOut[i], m_vecInOut[i], l, m_eosTail);
+ else
+ m_convolvers[i]->getNext(nullptr, m_vecInOut[i], l, m_eosTail);
+
+ return l;
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/ConvolverSound.cpp b/extern/audaspace/src/fx/ConvolverSound.cpp
new file mode 100644
index 00000000000..9bdf5a66652
--- /dev/null
+++ b/extern/audaspace/src/fx/ConvolverSound.cpp
@@ -0,0 +1,50 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "fx/ConvolverSound.h"
+#include "fx/ConvolverReader.h"
+#include "Exception.h"
+
+#include <cstring>
+
+AUD_NAMESPACE_BEGIN
+
+ConvolverSound::ConvolverSound(std::shared_ptr<ISound> sound, std::shared_ptr<ImpulseResponse> impulseResponse, std::shared_ptr<ThreadPool> threadPool) :
+ ConvolverSound(sound, impulseResponse, threadPool, std::make_shared<FFTPlan>(0.0))
+{
+}
+
+ConvolverSound::ConvolverSound(std::shared_ptr<ISound> sound, std::shared_ptr<ImpulseResponse> impulseResponse, std::shared_ptr<ThreadPool> threadPool, std::shared_ptr<FFTPlan> plan) :
+ m_sound(sound), m_impulseResponse(impulseResponse), m_threadPool(threadPool), m_plan(plan)
+{
+}
+
+std::shared_ptr<IReader> ConvolverSound::createReader()
+{
+ return std::make_shared<ConvolverReader>(m_sound->createReader(), m_impulseResponse, m_threadPool, m_plan);
+}
+
+std::shared_ptr<ImpulseResponse> ConvolverSound::getImpulseResponse()
+{
+ return m_impulseResponse;
+}
+
+void ConvolverSound::setImpulseResponse(std::shared_ptr<ImpulseResponse> impulseResponse)
+{
+ m_impulseResponse = impulseResponse;
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/Delay.cpp b/extern/audaspace/src/fx/Delay.cpp
new file mode 100644
index 00000000000..e2a82299bc0
--- /dev/null
+++ b/extern/audaspace/src/fx/Delay.cpp
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/Delay.h"
+#include "fx/DelayReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+Delay::Delay(std::shared_ptr<ISound> sound, float delay) :
+ Effect(sound),
+ m_delay(delay)
+{
+}
+
+float Delay::getDelay() const
+{
+ return m_delay;
+}
+
+std::shared_ptr<IReader> Delay::createReader()
+{
+ return std::shared_ptr<IReader>(new DelayReader(getReader(), m_delay));
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/DelayReader.cpp b/extern/audaspace/src/fx/DelayReader.cpp
new file mode 100644
index 00000000000..530aed69cba
--- /dev/null
+++ b/extern/audaspace/src/fx/DelayReader.cpp
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/DelayReader.h"
+
+#include <cstring>
+
+AUD_NAMESPACE_BEGIN
+
+DelayReader::DelayReader(std::shared_ptr<IReader> reader, float delay) :
+ EffectReader(reader),
+ m_delay(int((SampleRate)delay * reader->getSpecs().rate)),
+ m_remdelay(int((SampleRate)delay * reader->getSpecs().rate))
+{
+}
+
+void DelayReader::seek(int position)
+{
+ if(position < m_delay)
+ {
+ m_remdelay = m_delay - position;
+ m_reader->seek(0);
+ }
+ else
+ {
+ m_remdelay = 0;
+ m_reader->seek(position - m_delay);
+ }
+}
+
+int DelayReader::getLength() const
+{
+ int len = m_reader->getLength();
+ if(len < 0)
+ return len;
+ return len + m_delay;
+}
+
+int DelayReader::getPosition() const
+{
+ if(m_remdelay > 0)
+ return m_delay - m_remdelay;
+ return m_reader->getPosition() + m_delay;
+}
+
+void DelayReader::read(int& length, bool& eos, sample_t* buffer)
+{
+ if(m_remdelay > 0)
+ {
+ Specs specs = m_reader->getSpecs();
+ int samplesize = AUD_SAMPLE_SIZE(specs);
+
+ if(length > m_remdelay)
+ {
+ std::memset(buffer, 0, m_remdelay * samplesize);
+
+ int len = length - m_remdelay;
+ m_reader->read(len, eos, buffer + m_remdelay * specs.channels);
+
+ length = m_remdelay + len;
+
+ m_remdelay = 0;
+ }
+ else
+ {
+ std::memset(buffer, 0, length * samplesize);
+ m_remdelay -= length;
+ }
+ }
+ else
+ m_reader->read(length, eos, buffer);
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/DynamicIIRFilter.cpp b/extern/audaspace/src/fx/DynamicIIRFilter.cpp
new file mode 100644
index 00000000000..02a8b0b65ac
--- /dev/null
+++ b/extern/audaspace/src/fx/DynamicIIRFilter.cpp
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/DynamicIIRFilter.h"
+#include "fx/DynamicIIRFilterReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+DynamicIIRFilter::DynamicIIRFilter(std::shared_ptr<ISound> sound,
+ std::shared_ptr<IDynamicIIRFilterCalculator> calculator) :
+ Effect(sound),
+ m_calculator(calculator)
+{
+}
+
+std::shared_ptr<IReader> DynamicIIRFilter::createReader()
+{
+ return std::shared_ptr<IReader>(new DynamicIIRFilterReader(getReader(), m_calculator));
+}
+
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/DynamicIIRFilterReader.cpp b/extern/audaspace/src/fx/DynamicIIRFilterReader.cpp
new file mode 100644
index 00000000000..948b467aaa4
--- /dev/null
+++ b/extern/audaspace/src/fx/DynamicIIRFilterReader.cpp
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/DynamicIIRFilterReader.h"
+#include "fx/IDynamicIIRFilterCalculator.h"
+
+AUD_NAMESPACE_BEGIN
+
+DynamicIIRFilterReader::DynamicIIRFilterReader(std::shared_ptr<IReader> reader, std::shared_ptr<IDynamicIIRFilterCalculator> calculator) :
+ IIRFilterReader(reader, std::vector<float>(), std::vector<float>()),
+ m_calculator(calculator)
+{
+ sampleRateChanged(reader->getSpecs().rate);
+}
+
+void DynamicIIRFilterReader::sampleRateChanged(SampleRate rate)
+{
+ std::vector<float> a, b;
+ m_calculator->recalculateCoefficients(rate, b, a);
+ setCoefficients(b, a);
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/DynamicMusic.cpp b/extern/audaspace/src/fx/DynamicMusic.cpp
new file mode 100644
index 00000000000..b77cd749576
--- /dev/null
+++ b/extern/audaspace/src/fx/DynamicMusic.cpp
@@ -0,0 +1,346 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "fx/DynamicMusic.h"
+#include "generator/Silence.h"
+#include "fx/Fader.h"
+#include "fx/Limiter.h"
+
+#include <mutex>
+#include <condition_variable>
+
+AUD_NAMESPACE_BEGIN
+
+DynamicMusic::DynamicMusic(std::shared_ptr<IDevice> device) :
+m_device(device), m_fadeTime(1.0f)
+{
+ m_id = 0;
+ m_transitioning = false;
+ m_stopThread = false;
+ m_volume = m_device->getVolume();
+ m_scenes.push_back(std::vector<std::shared_ptr<ISound>>(1, nullptr));
+}
+
+DynamicMusic::~DynamicMusic()
+{
+ stop();
+}
+
+int DynamicMusic::addScene(std::shared_ptr<ISound> sound)
+{
+ std::vector<std::shared_ptr<ISound>> v;
+ m_scenes.push_back(v);
+ for(int i = 0; i < m_scenes.size()-1; i++)
+ m_scenes.back().push_back(nullptr);
+ for(int i = 0; i < m_scenes.size()-1; i++)
+ m_scenes[i].push_back(nullptr);
+ m_scenes.back().push_back(sound);
+
+ return m_scenes.size() - 1;
+}
+
+bool DynamicMusic::changeScene(int id)
+{
+ if(id >= m_scenes.size() || m_transitioning)
+ return false;
+ else
+ {
+ if(m_fadeThread.joinable())
+ m_fadeThread.join();
+ m_device->lock();
+ if(id == m_id)
+ {
+ m_currentHandle->setVolume(m_volume);
+ m_currentHandle->setLoopCount(-1);
+ }
+ else
+ {
+ m_soundTarget = id;
+ if(m_scenes[m_id][id] == nullptr)
+ {
+ m_stopThread = false;
+ if((m_scenes[m_id][m_id] != nullptr && m_currentHandle->getStatus() != STATUS_INVALID) || m_scenes[m_soundTarget][m_soundTarget] != nullptr)
+ {
+ m_transitioning = true;
+ if(m_scenes[m_id][m_id] == nullptr || m_currentHandle->getStatus() == STATUS_INVALID)
+ {
+ m_device->lock();
+ m_currentHandle = m_device->play(m_scenes[m_soundTarget][m_soundTarget]);
+ m_currentHandle->setVolume(0.0f);
+ m_currentHandle->setLoopCount(-1);
+ m_device->unlock();
+ m_fadeThread = std::thread(&DynamicMusic::fadeInThread, this);
+ }
+ else
+ {
+ if(m_scenes[m_soundTarget][m_soundTarget] != nullptr)
+ {
+ m_device->lock();
+ m_transitionHandle = m_currentHandle;
+ m_currentHandle = m_device->play(m_scenes[m_soundTarget][m_soundTarget]);
+ m_currentHandle->setVolume(0.0f);
+ m_currentHandle->setLoopCount(-1);
+ m_device->unlock();
+ m_fadeThread = std::thread(&DynamicMusic::crossfadeThread, this);
+ }
+ else
+ {
+ m_transitionHandle = m_currentHandle;
+ m_currentHandle = nullptr;
+ m_fadeThread = std::thread(&DynamicMusic::fadeOutThread, this);
+ }
+ }
+ }
+ }
+ else
+ {
+ if(m_scenes[m_id][m_id] == nullptr || m_currentHandle->getStatus() == STATUS_INVALID)
+ transitionCallback(this);
+ else
+ {
+ m_currentHandle->setLoopCount(0);
+ m_currentHandle->setStopCallback(transitionCallback, this);
+ }
+ }
+ }
+ m_device->unlock();
+ return true;
+ }
+}
+
+int DynamicMusic::getScene()
+{
+ return m_id;
+}
+
+bool DynamicMusic::addTransition(int init, int end, std::shared_ptr<ISound> sound)
+{
+ if(init != end && init < m_scenes.size() && end < m_scenes.size() && init >= 0 && end >= 0)
+ {
+ m_scenes[init][end] = sound;
+ return true;
+ }
+ return false;
+}
+
+void DynamicMusic::setFadeTime(float seconds)
+{
+ m_device->lock();
+ m_fadeTime = seconds;
+ m_device->unlock();
+}
+
+float DynamicMusic::getFadeTime()
+{
+ return m_fadeTime;
+}
+
+bool DynamicMusic::resume()
+{
+ bool result = false, resultTrans = false;
+
+ if(m_currentHandle != nullptr)
+ result = m_currentHandle->resume();
+ if(m_transitionHandle != nullptr)
+ resultTrans = m_transitionHandle->resume();
+
+ return result || resultTrans;
+}
+
+bool DynamicMusic::pause()
+{
+ bool result = false, resultTrans = false;
+
+ if(m_currentHandle != nullptr)
+ result = m_currentHandle->pause();
+ if(m_transitionHandle != nullptr)
+ resultTrans = m_transitionHandle->pause();
+
+ return result || resultTrans;
+}
+
+bool DynamicMusic::seek(float position)
+{
+ bool result;
+
+ if(m_currentHandle != nullptr)
+ {
+ result = m_currentHandle->seek(position);
+ if(m_transitionHandle != nullptr && result == true)
+ m_transitionHandle->stop();
+ }
+
+ return result;
+}
+
+float DynamicMusic::getPosition()
+{
+ float result = 0.0f;
+
+ if(m_currentHandle != nullptr)
+ result = m_currentHandle->getPosition();
+
+ return result;
+}
+
+float DynamicMusic::getVolume()
+{
+ return m_volume;
+}
+
+bool DynamicMusic::setVolume(float volume)
+{
+ m_volume = volume;
+ bool result = false, resultTrans = false;
+
+ if(m_currentHandle != nullptr)
+ result = m_currentHandle->setVolume(volume);
+ if(m_transitionHandle != nullptr)
+ {
+ m_device->lock();
+ if(volume<m_transitionHandle->getVolume())
+ resultTrans = m_transitionHandle->setVolume(0.0f);
+ m_device->unlock();
+ }
+ if(m_currentHandle == nullptr && m_transitionHandle == nullptr)
+ result = true;
+
+ return result || resultTrans;
+}
+
+Status DynamicMusic::getStatus()
+{
+ if(m_currentHandle != nullptr)
+ {
+ Status result = m_currentHandle->getStatus();
+ return result;
+ }
+ else
+ return STATUS_INVALID;
+}
+
+bool DynamicMusic::stop()
+{
+ m_stopThread = true;
+ bool result = false, resultTrans = false;
+
+ if(m_currentHandle != nullptr)
+ result = m_currentHandle->stop();
+ if(m_transitionHandle != nullptr)
+
+ resultTrans = m_transitionHandle->stop();
+
+ if(m_fadeThread.joinable())
+ m_fadeThread.join();
+ m_id = 0;
+
+ return result || resultTrans;
+}
+
+void DynamicMusic::transitionCallback(void* player)
+{
+ auto dat = reinterpret_cast<DynamicMusic*>(player);
+ dat->m_transitioning = true;
+ dat->m_device->lock();
+ dat->m_currentHandle = dat->m_device->play(dat->m_scenes[dat->m_id][dat->m_soundTarget]);
+ dat->m_currentHandle->setVolume(dat->m_volume);
+ if(dat->m_scenes[dat->m_soundTarget][dat->m_soundTarget] != nullptr)
+ dat->m_currentHandle->setStopCallback(sceneCallback, player);
+ dat->m_device->unlock();
+}
+
+void DynamicMusic::sceneCallback(void* player)
+{
+ auto dat = reinterpret_cast<DynamicMusic*>(player);
+ dat->m_device->lock();
+ dat->m_currentHandle = dat->m_device->play(dat->m_scenes[dat->m_soundTarget][dat->m_soundTarget]);
+ dat->m_currentHandle->setVolume(dat->m_volume);
+ dat->m_currentHandle->setLoopCount(-1);
+ dat->m_device->unlock();
+ dat->m_id = int(dat->m_soundTarget);
+ dat->m_soundTarget = -1;
+ dat->m_transitioning = false;
+}
+
+void DynamicMusic::crossfadeThread()
+{
+ float currentVol = m_transitionHandle->getVolume();
+ float nextVol = m_currentHandle->getVolume();
+ float increment;
+
+ while(nextVol < m_volume && !m_stopThread)
+ {
+ increment = (m_volume / (m_fadeTime * 1000)) * 20;
+ currentVol -= increment;
+ nextVol += increment;
+ if(currentVol < 0)
+ currentVol = 0;
+ if(nextVol > m_volume)
+ nextVol = m_volume;
+ m_transitionHandle->setVolume(currentVol);
+ m_currentHandle->setVolume(nextVol);
+ std::this_thread::sleep_for(std::chrono::milliseconds(20));
+ }
+ if(m_stopThread)
+ m_transitionHandle->setVolume(m_volume);
+
+ m_transitionHandle->stop();
+
+ m_id = int(m_soundTarget);
+ m_transitioning = false;
+}
+
+void DynamicMusic::fadeInThread()
+{
+ float nextVol = m_currentHandle->getVolume();
+ float increment;
+
+ while(nextVol < m_volume && !m_stopThread)
+ {
+ increment = (m_volume / (m_fadeTime * 1000)) * 20;
+ nextVol += increment;
+ if(nextVol > m_volume)
+ nextVol = m_volume;
+ m_currentHandle->setVolume(nextVol);
+ std::this_thread::sleep_for(std::chrono::milliseconds(20));
+ }
+ if(m_stopThread)
+ m_currentHandle->setVolume(m_volume);
+
+ m_id = int(m_soundTarget);
+ m_transitioning = false;
+}
+
+void DynamicMusic::fadeOutThread()
+{
+ float currentVol = m_transitionHandle->getVolume();
+ float increment;
+
+ while(currentVol > 0.0f && !m_stopThread)
+ {
+ increment = (m_volume / (m_fadeTime * 1000)) * 20;
+ currentVol -= increment;
+ if(currentVol < 0)
+ currentVol = 0;
+ m_transitionHandle->setVolume(currentVol);
+ std::this_thread::sleep_for(std::chrono::milliseconds(20));
+ }
+
+ m_transitionHandle->stop();
+ m_id = int(m_soundTarget);
+ m_transitioning = false;
+}
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/Effect.cpp b/extern/audaspace/src/fx/Effect.cpp
new file mode 100644
index 00000000000..af59ba440f9
--- /dev/null
+++ b/extern/audaspace/src/fx/Effect.cpp
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/Effect.h"
+
+AUD_NAMESPACE_BEGIN
+
+Effect::Effect(std::shared_ptr<ISound> sound)
+{
+ m_sound = sound;
+}
+
+Effect::~Effect()
+{
+}
+
+std::shared_ptr<ISound> Effect::getSound() const
+{
+ return m_sound;
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/EffectReader.cpp b/extern/audaspace/src/fx/EffectReader.cpp
new file mode 100644
index 00000000000..93a9d3cbf1c
--- /dev/null
+++ b/extern/audaspace/src/fx/EffectReader.cpp
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/EffectReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+EffectReader::EffectReader(std::shared_ptr<IReader> reader)
+{
+ m_reader = reader;
+}
+
+EffectReader::~EffectReader()
+{
+}
+
+bool EffectReader::isSeekable() const
+{
+ return m_reader->isSeekable();
+}
+
+void EffectReader::seek(int position)
+{
+ m_reader->seek(position);
+}
+
+int EffectReader::getLength() const
+{
+ return m_reader->getLength();
+}
+
+int EffectReader::getPosition() const
+{
+ return m_reader->getPosition();
+}
+
+Specs EffectReader::getSpecs() const
+{
+ return m_reader->getSpecs();
+}
+
+void EffectReader::read(int& length, bool& eos, sample_t* buffer)
+{
+ m_reader->read(length, eos, buffer);
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/Envelope.cpp b/extern/audaspace/src/fx/Envelope.cpp
new file mode 100644
index 00000000000..0637706c0a9
--- /dev/null
+++ b/extern/audaspace/src/fx/Envelope.cpp
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/Envelope.h"
+#include "fx/CallbackIIRFilterReader.h"
+
+#include <cmath>
+
+AUD_NAMESPACE_BEGIN
+
+struct EnvelopeParameters
+{
+ float attack;
+ float release;
+ float threshold;
+ float arthreshold;
+};
+
+sample_t Envelope::envelopeFilter(CallbackIIRFilterReader* reader, EnvelopeParameters* param)
+{
+ float in = std::fabs(reader->x(0));
+ float out = reader->y(-1);
+ if(in < param->threshold)
+ in = 0.0f;
+ return (in > out ? param->attack : param->release) * (out - in) + in;
+}
+
+void Envelope::endEnvelopeFilter(EnvelopeParameters* param)
+{
+ delete param;
+}
+
+Envelope::Envelope(std::shared_ptr<ISound> sound, float attack, float release, float threshold, float arthreshold) :
+ Effect(sound),
+ m_attack(attack),
+ m_release(release),
+ m_threshold(threshold),
+ m_arthreshold(arthreshold)
+{
+}
+
+std::shared_ptr<IReader> Envelope::createReader()
+{
+ std::shared_ptr<IReader> reader = getReader();
+
+ EnvelopeParameters* param = new EnvelopeParameters();
+ param->arthreshold = m_arthreshold;
+ param->attack = std::pow(m_arthreshold, 1.0f/(static_cast<float>(reader->getSpecs().rate) * m_attack));
+ param->release = std::pow(m_arthreshold, 1.0f/(static_cast<float>(reader->getSpecs().rate) * m_release));
+ param->threshold = m_threshold;
+
+ return std::shared_ptr<IReader>(new CallbackIIRFilterReader(reader, 1, 2,
+ (doFilterIIR) envelopeFilter,
+ (endFilterIIR) endEnvelopeFilter,
+ param));
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/FFTConvolver.cpp b/extern/audaspace/src/fx/FFTConvolver.cpp
new file mode 100644
index 00000000000..868a1ebbaf3
--- /dev/null
+++ b/extern/audaspace/src/fx/FFTConvolver.cpp
@@ -0,0 +1,214 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "fx/FFTConvolver.h"
+
+#include <cstring>
+#include <cstdlib>
+
+AUD_NAMESPACE_BEGIN
+
+FFTConvolver::FFTConvolver(std::shared_ptr<std::vector<std::complex<sample_t>>> ir, std::shared_ptr<FFTPlan> plan) :
+ m_plan(plan), m_N(plan->getSize()), m_M(plan->getSize()/2), m_L(plan->getSize()/2), m_tailPos(0), m_irBuffer(ir)
+{
+ m_tail = (float*)calloc(m_M - 1, sizeof(float));
+ m_realBufLen = ((m_N / 2) + 1) * 2;
+ m_inBuffer = nullptr;
+ m_shiftBuffer = (sample_t*)std::calloc(m_N, sizeof(sample_t));
+}
+
+FFTConvolver::~FFTConvolver()
+{
+ std::free(m_tail);
+ std::free(m_shiftBuffer);
+ if(m_inBuffer != nullptr)
+ m_plan->freeBuffer(m_inBuffer);
+}
+
+void FFTConvolver::getNext(const sample_t* inBuffer, sample_t* outBuffer, int& length)
+{
+ if(length > m_L || length <= 0)
+ {
+ length = 0;
+ return;
+ }
+ if(m_inBuffer == nullptr)
+ m_inBuffer = reinterpret_cast<std::complex<sample_t>*>(m_plan->getBuffer());
+
+ std::memset(m_inBuffer, 0, m_realBufLen * sizeof(fftwf_complex));
+ std::memcpy(m_inBuffer, inBuffer, length*sizeof(sample_t));
+
+ m_plan->FFT(m_inBuffer);
+ for(int i = 0; i < m_realBufLen / 2; i++)
+ {
+ m_inBuffer[i] = m_inBuffer[i] * (*m_irBuffer)[i] / sample_t(m_N);
+ }
+ m_plan->IFFT(m_inBuffer);
+
+ for(int i = 0; i < m_M - 1; i++)
+ ((float*)m_inBuffer)[i] += m_tail[i];
+
+ for(int i = 0; i < m_M - 1; i++)
+ m_tail[i] = ((float*)m_inBuffer)[i + length];
+
+ std::memcpy(outBuffer, m_inBuffer, length * sizeof(sample_t));
+}
+
+void FFTConvolver::getNext(const sample_t* inBuffer, sample_t* outBuffer, int& length, fftwf_complex* transformedData)
+{
+ if(length > m_L || length <= 0)
+ {
+ length = 0;
+ return;
+ }
+ if(m_inBuffer == nullptr)
+ m_inBuffer = reinterpret_cast<std::complex<sample_t>*>(m_plan->getBuffer());
+
+ std::memset(m_inBuffer, 0, m_realBufLen * sizeof(fftwf_complex));
+ std::memcpy(m_inBuffer, inBuffer, length*sizeof(sample_t));
+
+ m_plan->FFT(m_inBuffer);
+ std::memcpy(transformedData, m_inBuffer, (m_realBufLen / 2)*sizeof(fftwf_complex));
+ for(int i = 0; i < m_realBufLen / 2; i++)
+ {
+ m_inBuffer[i] = m_inBuffer[i] * (*m_irBuffer)[i] / sample_t(m_N);
+ }
+ m_plan->IFFT(m_inBuffer);
+
+ for(int i = 0; i < m_M - 1; i++)
+ ((float*)m_inBuffer)[i] += m_tail[i];
+
+ for(int i = 0; i < m_M - 1; i++)
+ m_tail[i] = ((float*)m_inBuffer)[i + length];
+
+ std::memcpy(outBuffer, m_inBuffer, length * sizeof(sample_t));
+}
+
+void FFTConvolver::getNext(const fftwf_complex* inBuffer, sample_t* outBuffer, int& length)
+{
+ if(length > m_L || length <= 0)
+ {
+ length = 0;
+ return;
+ }
+ if(m_inBuffer == nullptr)
+ m_inBuffer = reinterpret_cast<std::complex<sample_t>*>(m_plan->getBuffer());
+
+ std::memset(m_inBuffer, 0, m_realBufLen * sizeof(fftwf_complex));
+ for(int i = 0; i < m_realBufLen / 2; i++)
+ {
+ m_inBuffer[i] = m_inBuffer[i] * (*m_irBuffer)[i] / sample_t(m_N);
+ }
+ m_plan->IFFT(m_inBuffer);
+
+ for(int i = 0; i < m_M - 1; i++)
+ ((float*)m_inBuffer)[i] += m_tail[i];
+
+ for(int i = 0; i < m_M - 1; i++)
+ m_tail[i] = ((float*)m_inBuffer)[i + length];
+
+ std::memcpy(outBuffer, m_inBuffer, length * sizeof(sample_t));
+}
+
+void FFTConvolver::getTail(int& length, bool& eos, sample_t* buffer)
+{
+ if(length <= 0)
+ {
+ length = 0;
+ eos = m_tailPos >= m_M - 1;
+ return;
+ }
+
+ eos = false;
+ if(m_tailPos + length > m_M - 1)
+ {
+ length = m_M - 1 - m_tailPos;
+ if(length < 0)
+ length = 0;
+ eos = true;
+ m_tailPos = m_M - 1;
+ }
+ else
+ m_tailPos += length;
+ std::memcpy(buffer, m_tail, length*sizeof(sample_t));
+}
+
+void FFTConvolver::clear()
+{
+ std::memset(m_shiftBuffer, 0, m_N * sizeof(sample_t));
+ std::memset(m_tail, 0, m_M - 1);
+}
+
+void FFTConvolver::IFFT_FDL(const fftwf_complex* inBuffer, sample_t* outBuffer, int& length)
+{
+ if(length > m_L || length <= 0)
+ {
+ length = 0;
+ return;
+ }
+ if(m_inBuffer == nullptr)
+ m_inBuffer = reinterpret_cast<std::complex<sample_t>*>(m_plan->getBuffer());
+
+ std::memset(m_inBuffer, 0, m_realBufLen * sizeof(fftwf_complex));
+ std::memcpy(m_inBuffer, inBuffer, (m_realBufLen / 2)*sizeof(fftwf_complex));
+ m_plan->IFFT(m_inBuffer);
+ std::memcpy(outBuffer, ((sample_t*)m_inBuffer)+m_L, length*sizeof(sample_t));
+}
+
+void FFTConvolver::getNextFDL(const std::complex<sample_t>* inBuffer, std::complex<sample_t>* accBuffer)
+{
+ for(int i = 0; i < m_realBufLen / 2; i++)
+ {
+ accBuffer[i] += (inBuffer[i] * (*m_irBuffer)[i]) / sample_t(m_N);
+ }
+}
+
+void FFTConvolver::getNextFDL(const sample_t* inBuffer, std::complex<sample_t>* accBuffer, int& length, fftwf_complex* transformedData)
+{
+ if(length > m_L || length <= 0)
+ {
+ length = 0;
+ return;
+ }
+ if(m_inBuffer == nullptr)
+ m_inBuffer = reinterpret_cast<std::complex<sample_t>*>(m_plan->getBuffer());
+
+ std::memcpy(m_shiftBuffer, m_shiftBuffer + m_L, m_L*sizeof(sample_t));
+ std::memcpy(m_shiftBuffer + m_L, inBuffer, length*sizeof(sample_t));
+
+ std::memset(m_inBuffer, 0, m_realBufLen * sizeof(fftwf_complex));
+ std::memcpy(m_inBuffer, m_shiftBuffer, (m_L+length)*sizeof(sample_t));
+
+ m_plan->FFT(m_inBuffer);
+ std::memcpy(transformedData, m_inBuffer, (m_realBufLen / 2)*sizeof(fftwf_complex));
+ for(int i = 0; i < m_realBufLen / 2; i++)
+ {
+ accBuffer[i] += (m_inBuffer[i] * (*m_irBuffer)[i]) / sample_t(m_N);
+ }
+}
+
+
+void FFTConvolver::setImpulseResponse(std::shared_ptr<std::vector<std::complex<sample_t>>> ir)
+{
+ clear();
+ m_irBuffer = ir;
+}
+
+std::shared_ptr<std::vector<std::complex<sample_t>>> FFTConvolver::getImpulseResponse()
+{
+ return m_irBuffer;
+}
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/Fader.cpp b/extern/audaspace/src/fx/Fader.cpp
new file mode 100644
index 00000000000..041d8369a01
--- /dev/null
+++ b/extern/audaspace/src/fx/Fader.cpp
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/Fader.h"
+
+AUD_NAMESPACE_BEGIN
+
+Fader::Fader(std::shared_ptr<ISound> sound, FadeType type, float start, float length) :
+ Effect(sound),
+ m_type(type),
+ m_start(start),
+ m_length(length)
+{
+}
+
+FadeType Fader::getType() const
+{
+ return m_type;
+}
+
+float Fader::getStart() const
+{
+ return m_start;
+}
+
+float Fader::getLength() const
+{
+ return m_length;
+}
+
+std::shared_ptr<IReader> Fader::createReader()
+{
+ return std::shared_ptr<IReader>(new FaderReader(getReader(), m_type, m_start, m_length));
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/FaderReader.cpp b/extern/audaspace/src/fx/FaderReader.cpp
new file mode 100644
index 00000000000..b1e23b993f3
--- /dev/null
+++ b/extern/audaspace/src/fx/FaderReader.cpp
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/FaderReader.h"
+
+#include <cstring>
+
+AUD_NAMESPACE_BEGIN
+
+FaderReader::FaderReader(std::shared_ptr<IReader> reader, FadeType type, float start,float length) :
+ EffectReader(reader),
+ m_type(type),
+ m_start(start),
+ m_length(length)
+{
+}
+
+void FaderReader::read(int& length, bool& eos, sample_t* buffer)
+{
+ int position = m_reader->getPosition();
+ Specs specs = m_reader->getSpecs();
+ int samplesize = AUD_SAMPLE_SIZE(specs);
+
+ m_reader->read(length, eos, buffer);
+
+ if((position + length) / (float)specs.rate <= m_start)
+ {
+ if(m_type != FADE_OUT)
+ {
+ std::memset(buffer, 0, length * samplesize);
+ }
+ }
+ else if(position / (float)specs.rate >= m_start+m_length)
+ {
+ if(m_type == FADE_OUT)
+ {
+ std::memset(buffer, 0, length * samplesize);
+ }
+ }
+ else
+ {
+ float volume = 1.0f;
+
+ for(int i = 0; i < length * specs.channels; i++)
+ {
+ if(i % specs.channels == 0)
+ {
+ volume = (((position+i)/(float)specs.rate)-m_start) / m_length;
+ if(volume > 1.0f)
+ volume = 1.0f;
+ else if(volume < 0.0f)
+ volume = 0.0f;
+
+ if(m_type == FADE_OUT)
+ volume = 1.0f - volume;
+ }
+
+ buffer[i] = buffer[i] * volume;
+ }
+ }
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/HRTF.cpp b/extern/audaspace/src/fx/HRTF.cpp
new file mode 100644
index 00000000000..14ef3ad0912
--- /dev/null
+++ b/extern/audaspace/src/fx/HRTF.cpp
@@ -0,0 +1,122 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "fx/HRTF.h"
+#include "Exception.h"
+
+#include <cmath>
+
+AUD_NAMESPACE_BEGIN
+HRTF::HRTF() :
+ HRTF(std::make_shared<FFTPlan>(0.0))
+{
+}
+
+HRTF::HRTF(std::shared_ptr<FFTPlan> plan) :
+ m_plan(plan)
+{
+ m_specs.channels = CHANNELS_INVALID;
+ m_specs.rate = 0;
+ m_empty = true;
+}
+
+bool HRTF::addImpulseResponse(std::shared_ptr<StreamBuffer> impulseResponse, float azimuth, float elevation)
+{
+ Specs spec = impulseResponse->getSpecs();
+
+ azimuth = std::fmod(azimuth, 360);
+ if(azimuth < 0)
+ azimuth += 360;
+
+ if((spec.channels != CHANNELS_MONO) || (spec.rate != m_specs.rate && m_specs.rate > 0.0))
+ return false;
+
+ m_hrtfs[elevation][azimuth] = std::make_shared<ImpulseResponse>(impulseResponse, m_plan);
+ m_specs.channels = CHANNELS_MONO;
+ m_specs.rate = spec.rate;
+ m_empty = false;
+ return true;
+}
+
+std::pair<std::shared_ptr<ImpulseResponse>, std::shared_ptr<ImpulseResponse>> HRTF::getImpulseResponse(float &azimuth, float &elevation)
+{
+ if(m_hrtfs.empty())
+ return std::make_pair(nullptr, nullptr);
+ azimuth = std::fmod(azimuth, 360);
+ if(azimuth < 0)
+ azimuth += 360;
+
+ std::shared_ptr<ImpulseResponse> R, L;
+ float az = 0, el = 0, dif=0, minDif=360;
+
+ for(auto elem : m_hrtfs)
+ {
+ dif = std::fabs(elevation - elem.first);
+ if(dif < minDif)
+ {
+ minDif = dif;
+ el = elem.first;
+ }
+ }
+ elevation = el;
+ dif = 0;
+ minDif = 360;
+
+ for(auto elem : m_hrtfs[elevation])
+ {
+ dif = std::fabs(azimuth - elem.first);
+ if(dif < minDif)
+ {
+ minDif = dif;
+ az = elem.first;
+ R = elem.second;
+ }
+ }
+ azimuth = az;
+ float azL = 360 - azimuth;
+ if(azL == 360)
+ azL = 0;
+
+ auto iter = m_hrtfs[elevation].find(azL);
+ if(iter != m_hrtfs[elevation].end())
+ L = iter->second;
+ else
+ {
+ dif = 0;
+ minDif = 360;
+ for(auto elem : m_hrtfs[elevation])
+ {
+ dif = std::fabs(azL - elem.first);
+ if(dif < minDif)
+ {
+ minDif = dif;
+ L = elem.second;
+ }
+ }
+ }
+ return std::make_pair(L, R);
+}
+
+Specs HRTF::getSpecs()
+{
+ return m_specs;
+}
+
+bool HRTF::isEmpty()
+{
+ return m_empty;
+}
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/HRTFLoaderUnix.cpp b/extern/audaspace/src/fx/HRTFLoaderUnix.cpp
new file mode 100644
index 00000000000..12a23913912
--- /dev/null
+++ b/extern/audaspace/src/fx/HRTFLoaderUnix.cpp
@@ -0,0 +1,89 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "fx/HRTFLoader.h"
+#include "file/File.h"
+#include "Exception.h"
+
+#include <dirent.h>
+#include <exception>
+
+AUD_NAMESPACE_BEGIN
+
+std::shared_ptr<HRTF> HRTFLoader::loadLeftHRTFs(std::shared_ptr<FFTPlan> plan, const std::string& fileExtension, const std::string& path)
+{
+ std::shared_ptr<HRTF> hrtfs(std::make_shared<HRTF>(plan));
+ loadHRTFs(hrtfs, 'L', fileExtension, path);
+ return hrtfs;
+}
+
+std::shared_ptr<HRTF> HRTFLoader::loadRightHRTFs(std::shared_ptr<FFTPlan> plan, const std::string& fileExtension, const std::string& path)
+{
+ std::shared_ptr<HRTF> hrtfs(std::make_shared<HRTF>(plan));
+ loadHRTFs(hrtfs, 'R', fileExtension, path);
+ return hrtfs;
+}
+
+std::shared_ptr<HRTF> HRTFLoader::loadLeftHRTFs(const std::string& fileExtension, const std::string& path)
+{
+ std::shared_ptr<HRTF> hrtfs(std::make_shared<HRTF>());
+ loadHRTFs(hrtfs, 'L', fileExtension, path);
+ return hrtfs;
+}
+
+std::shared_ptr<HRTF> HRTFLoader::loadRightHRTFs(const std::string& fileExtension, const std::string& path)
+{
+ std::shared_ptr<HRTF> hrtfs(std::make_shared<HRTF>());
+ loadHRTFs(hrtfs, 'R', fileExtension, path);
+ return hrtfs;
+}
+
+void HRTFLoader::loadHRTFs(std::shared_ptr<HRTF> hrtfs, char ear, const std::string& fileExtension, const std::string& path)
+{
+ std::string readpath = path;
+ if(path == "")
+ readpath = ".";
+
+ DIR* dir = opendir(path.c_str());
+ if(!dir)
+ return;
+
+ float azim, elev;
+
+ while(dirent* entry = readdir(dir))
+ {
+ std::string filename = entry->d_name;
+ if(filename.front() == ear && filename.length() >= fileExtension.length() && filename.substr(filename.length() - fileExtension.length()) == fileExtension)
+ {
+ try
+ {
+ elev = std::stof(filename.substr(1, filename.find("e") - 1));
+ azim = std::stof(filename.substr(filename.find("e") + 1, filename.find("a") - filename.find("e") - 1));
+ if(ear == 'L')
+ azim = 360 - azim;
+ }
+ catch(std::exception& e)
+ {
+ AUD_THROW(FileException, "The HRTF name doesn't follow the naming scheme: " + filename);
+ }
+ hrtfs->addImpulseResponse(std::make_shared<StreamBuffer>(std::make_shared<File>(readpath + "/" + filename)), azim, elev);
+ }
+ }
+ closedir(dir);
+ return;
+}
+
+AUD_NAMESPACE_END \ No newline at end of file
diff --git a/extern/audaspace/src/fx/HRTFLoaderWindows.cpp b/extern/audaspace/src/fx/HRTFLoaderWindows.cpp
new file mode 100644
index 00000000000..148f1fa015d
--- /dev/null
+++ b/extern/audaspace/src/fx/HRTFLoaderWindows.cpp
@@ -0,0 +1,93 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "fx/HRTFLoader.h"
+#include "file/File.h"
+#include "Exception.h"
+
+#include <windows.h>
+#include <exception>
+
+AUD_NAMESPACE_BEGIN
+
+std::shared_ptr<HRTF> HRTFLoader::loadLeftHRTFs(std::shared_ptr<FFTPlan> plan, const std::string& fileExtension, const std::string& path)
+{
+ std::shared_ptr<HRTF> hrtfs(std::make_shared<HRTF>(plan));
+ loadHRTFs(hrtfs, 'L', fileExtension, path);
+ return hrtfs;
+}
+
+std::shared_ptr<HRTF> HRTFLoader::loadRightHRTFs(std::shared_ptr<FFTPlan> plan, const std::string& fileExtension, const std::string& path)
+{
+ std::shared_ptr<HRTF> hrtfs(std::make_shared<HRTF>(plan));
+ loadHRTFs(hrtfs, 'R', fileExtension, path);
+ return hrtfs;
+}
+
+std::shared_ptr<HRTF> HRTFLoader::loadLeftHRTFs(const std::string& fileExtension, const std::string& path)
+{
+ std::shared_ptr<HRTF> hrtfs(std::make_shared<HRTF>());
+ loadHRTFs(hrtfs, 'L', fileExtension, path);
+ return hrtfs;
+}
+
+std::shared_ptr<HRTF> HRTFLoader::loadRightHRTFs(const std::string& fileExtension, const std::string& path)
+{
+ std::shared_ptr<HRTF> hrtfs(std::make_shared<HRTF>());
+ loadHRTFs(hrtfs, 'R', fileExtension, path);
+ return hrtfs;
+}
+
+void HRTFLoader::loadHRTFs(std::shared_ptr<HRTF> hrtfs, char ear, const std::string& fileExtension, const std::string& path)
+{
+ std::string readpath = path;
+ if(path == "")
+ readpath = ".";
+
+ WIN32_FIND_DATA entry;
+ bool found_file = true;
+ std::string search = readpath + "\\*";
+ HANDLE dir = FindFirstFile(search.c_str(), &entry);
+ if(dir == INVALID_HANDLE_VALUE)
+ return;
+
+ float azim, elev;
+
+ while(found_file)
+ {
+ std::string filename = entry.cFileName;
+ if(filename.front() == ear && filename.length() >= fileExtension.length() && filename.substr(filename.length() - fileExtension.length()) == fileExtension)
+ {
+ try
+ {
+ elev = std::stof(filename.substr(1, filename.find("e") - 1));
+ azim = std::stof(filename.substr(filename.find("e") + 1, filename.find("a") - filename.find("e") - 1));
+ if(ear == 'L')
+ azim = 360 - azim;
+ }
+ catch(std::exception& e)
+ {
+ AUD_THROW(FileException, "The HRTF name doesn't follow the naming scheme: " + filename);
+ }
+ hrtfs->addImpulseResponse(std::make_shared<StreamBuffer>(std::make_shared<File>(readpath + "/" + filename)), azim, elev);
+ }
+ found_file = FindNextFile(dir, &entry);
+ }
+ FindClose(dir);
+ return;
+}
+
+AUD_NAMESPACE_END \ No newline at end of file
diff --git a/extern/audaspace/src/fx/Highpass.cpp b/extern/audaspace/src/fx/Highpass.cpp
new file mode 100644
index 00000000000..2490d512078
--- /dev/null
+++ b/extern/audaspace/src/fx/Highpass.cpp
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/Highpass.h"
+#include "fx/IIRFilterReader.h"
+#include "fx/HighpassCalculator.h"
+
+AUD_NAMESPACE_BEGIN
+
+Highpass::Highpass(std::shared_ptr<ISound> sound, float frequency, float Q) :
+ DynamicIIRFilter(sound, std::shared_ptr<IDynamicIIRFilterCalculator>(new HighpassCalculator(frequency, Q)))
+{
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/HighpassCalculator.cpp b/extern/audaspace/src/fx/HighpassCalculator.cpp
new file mode 100644
index 00000000000..2b69efe2fa7
--- /dev/null
+++ b/extern/audaspace/src/fx/HighpassCalculator.cpp
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/HighpassCalculator.h"
+
+#include <cmath>
+
+AUD_NAMESPACE_BEGIN
+
+HighpassCalculator::HighpassCalculator(float frequency, float Q) :
+ m_frequency(frequency),
+ m_Q(Q)
+{
+}
+
+void HighpassCalculator::recalculateCoefficients(SampleRate rate, std::vector<float> &b, std::vector<float> &a)
+{
+ float w0 = 2.0 * M_PI * (SampleRate)m_frequency / rate;
+ float alpha = (float)(std::sin(w0) / (2.0 * (double)m_Q));
+ float norm = 1 + alpha;
+ float c = std::cos(w0);
+ a.push_back(1);
+ a.push_back(-2 * c / norm);
+ a.push_back((1 - alpha) / norm);
+ b.push_back((1 + c) / (2 * norm));
+ b.push_back((-1 - c) / norm);
+ b.push_back(b[0]);
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/IIRFilter.cpp b/extern/audaspace/src/fx/IIRFilter.cpp
new file mode 100644
index 00000000000..fce6d01e4bf
--- /dev/null
+++ b/extern/audaspace/src/fx/IIRFilter.cpp
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/IIRFilter.h"
+#include "fx/IIRFilterReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+IIRFilter::IIRFilter(std::shared_ptr<ISound> sound, const std::vector<float>& b, const std::vector<float>& a) :
+ Effect(sound), m_a(a), m_b(b)
+{
+}
+
+std::shared_ptr<IReader> IIRFilter::createReader()
+{
+ return std::shared_ptr<IReader>(new IIRFilterReader(getReader(), m_b, m_a));
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/IIRFilterReader.cpp b/extern/audaspace/src/fx/IIRFilterReader.cpp
new file mode 100644
index 00000000000..8d879a85846
--- /dev/null
+++ b/extern/audaspace/src/fx/IIRFilterReader.cpp
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/IIRFilterReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+IIRFilterReader::IIRFilterReader(std::shared_ptr<IReader> reader, const std::vector<float>& b, const std::vector<float>& a) :
+ BaseIIRFilterReader(reader, b.size(), a.size()), m_a(a), m_b(b)
+{
+ if(m_a.empty() == false)
+ {
+ for(int i = 1; i < m_a.size(); i++)
+ m_a[i] /= m_a[0];
+ for(int i = 0; i < m_b.size(); i++)
+ m_b[i] /= m_a[0];
+ m_a[0] = 1;
+ }
+}
+
+sample_t IIRFilterReader::filter()
+{
+ sample_t out = 0;
+
+ for(int i = 1; i < m_a.size(); i++)
+ out -= y(-i) * m_a[i];
+ for(int i = 0; i < m_b.size(); i++)
+ out += x(-i) * m_b[i];
+
+ return out;
+}
+
+void IIRFilterReader::setCoefficients(const std::vector<float>& b, const std::vector<float>& a)
+{
+ setLengths(b.size(), a.size());
+ m_a = a;
+ m_b = b;
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/ImpulseResponse.cpp b/extern/audaspace/src/fx/ImpulseResponse.cpp
new file mode 100644
index 00000000000..babb628eb7a
--- /dev/null
+++ b/extern/audaspace/src/fx/ImpulseResponse.cpp
@@ -0,0 +1,97 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "fx/ImpulseResponse.h"
+
+#include <algorithm>
+#include <cstring>
+#include <cstdlib>
+#include <cmath>
+
+AUD_NAMESPACE_BEGIN
+ImpulseResponse::ImpulseResponse(std::shared_ptr<StreamBuffer> impulseResponse) :
+ ImpulseResponse(impulseResponse, std::make_shared<FFTPlan>(0.0))
+{
+}
+
+ImpulseResponse::ImpulseResponse(std::shared_ptr<StreamBuffer> impulseResponse, std::shared_ptr<FFTPlan> plan)
+{
+ auto reader = impulseResponse->createReader();
+ m_length = reader->getLength();
+ processImpulseResponse(impulseResponse->createReader(), plan);
+}
+
+Specs ImpulseResponse::getSpecs()
+{
+ return m_specs;
+}
+
+int ImpulseResponse::getLength()
+{
+ return m_length;
+}
+
+std::shared_ptr<std::vector<std::shared_ptr<std::vector<std::complex<sample_t>>>>> ImpulseResponse::getChannel(int n)
+{
+ return m_processedIR[n];
+}
+
+void ImpulseResponse::processImpulseResponse(std::shared_ptr<IReader> reader, std::shared_ptr<FFTPlan> plan)
+{
+ m_specs.channels = reader->getSpecs().channels;
+ m_specs.rate = reader->getSpecs().rate;
+ int N = plan->getSize();
+ bool eos = false;
+ int length = reader->getLength();
+ sample_t* buffer = (sample_t*)std::malloc(length * m_specs.channels * sizeof(sample_t));
+ int numParts = std::ceil((float)length / (plan->getSize() / 2));
+
+ for(int i = 0; i < m_specs.channels; i++)
+ {
+ m_processedIR.push_back(std::make_shared<std::vector<std::shared_ptr<std::vector<std::complex<sample_t>>>>>());
+ for(int j = 0; j < numParts; j++)
+ (*m_processedIR[i]).push_back(std::make_shared<std::vector<std::complex<sample_t>>>((N / 2) + 1));
+ }
+ length += reader->getSpecs().rate;
+ reader->read(length, eos, buffer);
+
+
+ void* bufferFFT = plan->getBuffer();
+ for(int i = 0; i < m_specs.channels; i++)
+ {
+ int partStart = 0;
+ for(int h = 0; h < numParts; h++)
+ {
+ int k = 0;
+ int len = std::min(partStart + ((N / 2)*m_specs.channels), length*m_specs.channels);
+ std::memset(bufferFFT, 0, ((N / 2) + 1) * 2 * sizeof(fftwf_complex));
+ for(int j = partStart; j < len; j += m_specs.channels)
+ {
+ ((float*)bufferFFT)[k] = buffer[j + i];
+ k++;
+ }
+ plan->FFT(bufferFFT);
+ for(int j = 0; j < (N / 2) + 1; j++)
+ {
+ (*(*m_processedIR[i])[h])[j] = reinterpret_cast<std::complex<sample_t>*>(bufferFFT)[j];
+ }
+ partStart += N / 2 * m_specs.channels;
+ }
+ }
+ plan->freeBuffer(bufferFFT);
+ std::free(buffer);
+}
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/Limiter.cpp b/extern/audaspace/src/fx/Limiter.cpp
new file mode 100644
index 00000000000..38a7288e8d7
--- /dev/null
+++ b/extern/audaspace/src/fx/Limiter.cpp
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/Limiter.h"
+#include "fx/LimiterReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+Limiter::Limiter(std::shared_ptr<ISound> sound,
+ float start, float end) :
+ Effect(sound),
+ m_start(start),
+ m_end(end)
+{
+}
+
+float Limiter::getStart() const
+{
+ return m_start;
+}
+
+float Limiter::getEnd() const
+{
+ return m_end;
+}
+
+std::shared_ptr<IReader> Limiter::createReader()
+{
+ return std::shared_ptr<IReader>(new LimiterReader(getReader(), m_start, m_end));
+}
+
+AUD_NAMESPACE_END
diff --git a/intern/audaspace/FX/AUD_LimiterReader.cpp b/extern/audaspace/src/fx/LimiterReader.cpp
index 7d850ac7b5f..1d003c29679 100644
--- a/intern/audaspace/FX/AUD_LimiterReader.cpp
+++ b/extern/audaspace/src/fx/LimiterReader.cpp
@@ -1,45 +1,35 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
*
- * Copyright 2009-2011 Jörg Hermann Müller
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * This file is part of AudaSpace.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * 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 *****
- */
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
-/** \file audaspace/FX/AUD_LimiterReader.cpp
- * \ingroup audfx
- */
+#include "fx/LimiterReader.h"
+#include "util/Buffer.h"
+#include <algorithm>
-#include "AUD_LimiterReader.h"
-#include "AUD_Buffer.h"
+AUD_NAMESPACE_BEGIN
-AUD_LimiterReader::AUD_LimiterReader(boost::shared_ptr<AUD_IReader> reader,
- float start, float end) :
- AUD_EffectReader(reader),
+LimiterReader::LimiterReader(std::shared_ptr<IReader> reader, float start, float end) :
+ EffectReader(reader),
m_start(start),
m_end(end)
{
if(m_start > 0)
{
- AUD_Specs specs = m_reader->getSpecs();
- AUD_Specs specs2;
+ Specs specs = m_reader->getSpecs();
+ Specs specs2;
if(m_reader->isSeekable())
m_reader->seek(m_start * specs.rate);
@@ -47,7 +37,7 @@ AUD_LimiterReader::AUD_LimiterReader(boost::shared_ptr<AUD_IReader> reader,
{
// skip first m_start samples by reading them
int length = AUD_DEFAULT_BUFFER_SIZE;
- AUD_Buffer buffer(AUD_DEFAULT_BUFFER_SIZE * AUD_SAMPLE_SIZE(specs));
+ Buffer buffer(AUD_DEFAULT_BUFFER_SIZE * AUD_SAMPLE_SIZE(specs));
bool eos = false;
for(int len = m_start * specs.rate;
length > 0 && !eos;
@@ -75,34 +65,34 @@ AUD_LimiterReader::AUD_LimiterReader(boost::shared_ptr<AUD_IReader> reader,
}
}
-void AUD_LimiterReader::seek(int position)
+void LimiterReader::seek(int position)
{
m_reader->seek(position + m_start * m_reader->getSpecs().rate);
}
-int AUD_LimiterReader::getLength() const
+int LimiterReader::getLength() const
{
int len = m_reader->getLength();
- AUD_SampleRate rate = m_reader->getSpecs().rate;
+ SampleRate rate = m_reader->getSpecs().rate;
if(len < 0 || (len > m_end * rate && m_end >= 0))
len = m_end * rate;
return len - m_start * rate;
}
-int AUD_LimiterReader::getPosition() const
+int LimiterReader::getPosition() const
{
int pos = m_reader->getPosition();
- AUD_SampleRate rate = m_reader->getSpecs().rate;
- return AUD_MIN(pos, m_end * rate) - m_start * rate;
+ SampleRate rate = m_reader->getSpecs().rate;
+ return std::min(pos, int(m_end * rate)) - m_start * rate;
}
-void AUD_LimiterReader::read(int& length, bool& eos, sample_t* buffer)
+void LimiterReader::read(int& length, bool& eos, sample_t* buffer)
{
eos = false;
if(m_end >= 0)
{
int position = m_reader->getPosition();
- AUD_SampleRate rate = m_reader->getSpecs().rate;
+ SampleRate rate = m_reader->getSpecs().rate;
if(position + length > m_end * rate)
{
@@ -145,3 +135,5 @@ void AUD_LimiterReader::read(int& length, bool& eos, sample_t* buffer)
else
m_reader->read(length, eos, buffer);
}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/Loop.cpp b/extern/audaspace/src/fx/Loop.cpp
new file mode 100644
index 00000000000..1695fcf1662
--- /dev/null
+++ b/extern/audaspace/src/fx/Loop.cpp
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/Loop.h"
+#include "fx/LoopReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+Loop::Loop(std::shared_ptr<ISound> sound, int loop) :
+ Effect(sound),
+ m_loop(loop)
+{
+}
+
+int Loop::getLoop() const
+{
+ return m_loop;
+}
+
+std::shared_ptr<IReader> Loop::createReader()
+{
+ return std::shared_ptr<IReader>(new LoopReader(getReader(), m_loop));
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/LoopReader.cpp b/extern/audaspace/src/fx/LoopReader.cpp
new file mode 100644
index 00000000000..2f13a5880eb
--- /dev/null
+++ b/extern/audaspace/src/fx/LoopReader.cpp
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/LoopReader.h"
+
+#include <cstring>
+
+AUD_NAMESPACE_BEGIN
+
+LoopReader::LoopReader(std::shared_ptr<IReader> reader, int loop) :
+ EffectReader(reader), m_count(loop), m_left(loop)
+{
+}
+
+void LoopReader::seek(int position)
+{
+ int len = m_reader->getLength();
+ if(len < 0)
+ m_reader->seek(position);
+ else
+ {
+ if(m_count >= 0)
+ {
+ m_left = m_count - (position / len);
+ if(m_left < 0)
+ m_left = 0;
+ }
+ m_reader->seek(position % len);
+ }
+}
+
+int LoopReader::getLength() const
+{
+ if(m_count < 0)
+ return -1;
+ return m_reader->getLength() * m_count;
+}
+
+int LoopReader::getPosition() const
+{
+ return m_reader->getPosition() * (m_count < 0 ? 1 : m_count);
+}
+
+void LoopReader::read(int& length, bool& eos, sample_t* buffer)
+{
+ const Specs specs = m_reader->getSpecs();
+
+ int len = length;
+
+ m_reader->read(length, eos, buffer);
+
+ if(length < len && eos && m_left)
+ {
+ int pos = length;
+ length = len;
+
+ while(pos < length && eos && m_left)
+ {
+ if(m_left > 0)
+ m_left--;
+
+ m_reader->seek(0);
+
+ len = length - pos;
+ m_reader->read(len, eos, buffer + pos * specs.channels);
+
+ // prevent endless loop
+ if(!len)
+ break;
+
+ pos += len;
+ }
+
+ length = pos;
+ }
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/Lowpass.cpp b/extern/audaspace/src/fx/Lowpass.cpp
new file mode 100644
index 00000000000..8c33291baa3
--- /dev/null
+++ b/extern/audaspace/src/fx/Lowpass.cpp
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/Lowpass.h"
+#include "fx/LowpassCalculator.h"
+
+AUD_NAMESPACE_BEGIN
+
+Lowpass::Lowpass(std::shared_ptr<ISound> sound, float frequency, float Q) :
+ DynamicIIRFilter(sound, std::shared_ptr<IDynamicIIRFilterCalculator>(new LowpassCalculator(frequency, Q)))
+{
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/LowpassCalculator.cpp b/extern/audaspace/src/fx/LowpassCalculator.cpp
new file mode 100644
index 00000000000..f2a53ed7514
--- /dev/null
+++ b/extern/audaspace/src/fx/LowpassCalculator.cpp
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/LowpassCalculator.h"
+
+#include <cmath>
+
+AUD_NAMESPACE_BEGIN
+
+LowpassCalculator::LowpassCalculator(float frequency, float Q) :
+ m_frequency(frequency),
+ m_Q(Q)
+{
+}
+
+void LowpassCalculator::recalculateCoefficients(SampleRate rate, std::vector<float> &b, std::vector<float> &a)
+{
+ float w0 = 2 * M_PI * m_frequency / rate;
+ float alpha = std::sin(w0) / (2 * m_Q);
+ float norm = 1 + alpha;
+ float c = std::cos(w0);
+ a.push_back(1);
+ a.push_back(-2 * c / norm);
+ a.push_back((1 - alpha) / norm);
+ b.push_back((1 - c) / (2 * norm));
+ b.push_back((1 - c) / norm);
+ b.push_back(b[0]);
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/MutableReader.cpp b/extern/audaspace/src/fx/MutableReader.cpp
new file mode 100644
index 00000000000..aa867d83f03
--- /dev/null
+++ b/extern/audaspace/src/fx/MutableReader.cpp
@@ -0,0 +1,64 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "fx/MutableReader.h"
+
+#include <cstring>
+
+AUD_NAMESPACE_BEGIN
+
+MutableReader::MutableReader(std::shared_ptr<ISound> sound) :
+m_sound(sound)
+{
+ m_reader = m_sound->createReader();
+}
+
+bool MutableReader::isSeekable() const
+{
+ return m_reader->isSeekable();
+}
+
+void MutableReader::seek(int position)
+{
+ if(position < m_reader->getPosition())
+ {
+ m_reader = m_sound->createReader();
+ }
+ else
+ m_reader->seek(position);
+}
+
+int MutableReader::getLength() const
+{
+ return m_reader->getLength();
+}
+
+int MutableReader::getPosition() const
+{
+ return m_reader->getPosition();
+}
+
+Specs MutableReader::getSpecs() const
+{
+ return m_reader->getSpecs();
+}
+
+void MutableReader::read(int& length, bool& eos, sample_t* buffer)
+{
+ m_reader->read(length, eos, buffer);
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/MutableSound.cpp b/extern/audaspace/src/fx/MutableSound.cpp
new file mode 100644
index 00000000000..5326b640394
--- /dev/null
+++ b/extern/audaspace/src/fx/MutableSound.cpp
@@ -0,0 +1,35 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "fx/MutableSound.h"
+#include "fx/MutableReader.h"
+#include "Exception.h"
+
+#include <cstring>
+
+AUD_NAMESPACE_BEGIN
+
+MutableSound::MutableSound(std::shared_ptr<ISound> sound) :
+m_sound(sound)
+{
+}
+
+std::shared_ptr<IReader> MutableSound::createReader()
+{
+ return std::make_shared<MutableReader>(m_sound);
+}
+
+AUD_NAMESPACE_END \ No newline at end of file
diff --git a/extern/audaspace/src/fx/Pitch.cpp b/extern/audaspace/src/fx/Pitch.cpp
new file mode 100644
index 00000000000..d7348a2d49e
--- /dev/null
+++ b/extern/audaspace/src/fx/Pitch.cpp
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/Pitch.h"
+#include "fx/PitchReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+Pitch::Pitch(std::shared_ptr<ISound> sound, float pitch) :
+ Effect(sound),
+ m_pitch(pitch)
+{
+}
+
+std::shared_ptr<IReader> Pitch::createReader()
+{
+ return std::shared_ptr<IReader>(new PitchReader(getReader(), m_pitch));
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/PitchReader.cpp b/extern/audaspace/src/fx/PitchReader.cpp
new file mode 100644
index 00000000000..f44be0261e6
--- /dev/null
+++ b/extern/audaspace/src/fx/PitchReader.cpp
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/PitchReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+PitchReader::PitchReader(std::shared_ptr<IReader> reader, float pitch) :
+ EffectReader(reader), m_pitch(pitch)
+{
+}
+
+Specs PitchReader::getSpecs() const
+{
+ Specs specs = m_reader->getSpecs();
+ specs.rate *= m_pitch;
+ return specs;
+}
+
+float PitchReader::getPitch() const
+{
+ return m_pitch;
+}
+
+void PitchReader::setPitch(float pitch)
+{
+ if(pitch > 0.0f)
+ m_pitch = pitch;
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/PlaybackCategory.cpp b/extern/audaspace/src/fx/PlaybackCategory.cpp
new file mode 100644
index 00000000000..e09a74c4017
--- /dev/null
+++ b/extern/audaspace/src/fx/PlaybackCategory.cpp
@@ -0,0 +1,144 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "fx/PlaybackCategory.h"
+#include "fx/VolumeSound.h"
+
+AUD_NAMESPACE_BEGIN
+
+struct HandleData {
+ unsigned int id;
+ PlaybackCategory* category;
+};
+
+PlaybackCategory::PlaybackCategory(std::shared_ptr<IDevice> device) :
+ m_device(device), m_volumeStorage(std::make_shared<VolumeStorage>(1.0f)), m_status(STATUS_PLAYING), m_currentID(0)
+{
+}
+
+PlaybackCategory::~PlaybackCategory()
+{
+ stop();
+}
+
+std::shared_ptr<IHandle> PlaybackCategory::play(std::shared_ptr<ISound> sound)
+{
+ std::shared_ptr<ISound> vs(std::make_shared<VolumeSound>(sound, m_volumeStorage));
+ m_device->lock();
+ auto handle = m_device->play(vs);
+ if(handle == nullptr)
+ return nullptr;
+ switch (m_status)
+ {
+ case STATUS_PAUSED:
+ handle->pause();
+ break;
+ default:
+ m_status = STATUS_PLAYING;
+ };
+ m_handles[m_currentID] = handle;
+ HandleData* data = new HandleData;
+ data->category = this;
+ data->id = m_currentID;
+ handle->setStopCallback(cleanHandleCallback, data);
+ m_device->unlock();
+
+ m_currentID++;
+ return handle;
+}
+
+void PlaybackCategory::resume()
+{
+ m_device->lock();
+ for(auto i = m_handles.begin(); i != m_handles.end();)
+ {
+ if(i->second->getStatus() == STATUS_INVALID)
+ i = m_handles.erase(i);
+ else
+ {
+ i->second->resume();
+ i++;
+ }
+ }
+ m_device->unlock();
+ m_status = STATUS_PLAYING;
+}
+
+void PlaybackCategory::pause()
+{
+ m_device->lock();
+ for(auto i = m_handles.begin(); i != m_handles.end();)
+ {
+ if(i->second->getStatus() == STATUS_INVALID)
+ i = m_handles.erase(i);
+ else
+ {
+ i->second->pause();
+ i++;
+ }
+ }
+ m_device->unlock();
+ m_status = STATUS_PAUSED;
+}
+
+float PlaybackCategory::getVolume()
+{
+ return m_volumeStorage->getVolume();
+}
+
+void PlaybackCategory::setVolume(float volume)
+{
+ m_volumeStorage->setVolume(volume);
+}
+
+void PlaybackCategory::stop()
+{
+ m_device->lock();
+ for(auto i = m_handles.begin(); i != m_handles.end();)
+ {
+ i->second->stop();
+ if(i->second->getStatus() == STATUS_INVALID)
+ i = m_handles.erase(i);
+ else
+ i++;
+ }
+ m_device->unlock();
+ m_status = STATUS_STOPPED;
+}
+
+std::shared_ptr<VolumeStorage> PlaybackCategory::getSharedVolume()
+{
+ return m_volumeStorage;
+}
+
+void PlaybackCategory::cleanHandles()
+{
+ for(auto i = m_handles.begin(); i != m_handles.end();)
+ {
+ if(i->second->getStatus() == STATUS_INVALID)
+ i = m_handles.erase(i);
+ else
+ i++;
+ }
+}
+
+void PlaybackCategory::cleanHandleCallback(void* data)
+{
+ auto dat = reinterpret_cast<HandleData*>(data);
+ dat->category->m_handles.erase(dat->id);
+ delete dat;
+}
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/PlaybackManager.cpp b/extern/audaspace/src/fx/PlaybackManager.cpp
new file mode 100644
index 00000000000..0fbeeba04e2
--- /dev/null
+++ b/extern/audaspace/src/fx/PlaybackManager.cpp
@@ -0,0 +1,186 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "fx/PlaybackManager.h"
+#include "fx/VolumeSound.h"
+
+#include <stdexcept>
+
+AUD_NAMESPACE_BEGIN
+PlaybackManager::PlaybackManager(std::shared_ptr<IDevice> device) :
+ m_device(device), m_currentKey(0)
+{
+}
+
+unsigned int PlaybackManager::addCategory(std::shared_ptr<PlaybackCategory> category)
+{
+ bool flag = true;
+ unsigned int k = -1;
+ do {
+ auto iter = m_categories.find(m_currentKey);
+ if(iter == m_categories.end())
+ {
+ m_categories[m_currentKey] = category;
+ k = m_currentKey;
+ m_currentKey++;
+ flag = false;
+ }
+ else
+ m_currentKey++;
+ } while(flag);
+
+ return k;
+}
+
+unsigned int PlaybackManager::addCategory(float volume)
+{
+ std::shared_ptr<PlaybackCategory> category = std::make_shared<PlaybackCategory>(m_device);
+ category->setVolume(volume);
+ bool flag = true;
+ unsigned int k = -1;
+ do {
+ auto iter = m_categories.find(m_currentKey);
+ if(iter == m_categories.end())
+ {
+ m_categories[m_currentKey] = category;
+ k = m_currentKey;
+ m_currentKey++;
+ flag = false;
+ }
+ else
+ m_currentKey++;
+ } while(flag);
+
+ return k;
+}
+
+std::shared_ptr<IHandle> PlaybackManager::play(std::shared_ptr<ISound> sound, unsigned int catKey)
+{
+ auto iter = m_categories.find(catKey);
+ std::shared_ptr<PlaybackCategory> category;
+
+ if(iter != m_categories.end())
+ {
+ category = iter->second;
+ }
+ else
+ {
+ category = std::make_shared<PlaybackCategory>(m_device);
+ m_categories[catKey] = category;
+ }
+ return category->play(sound);
+}
+
+bool PlaybackManager::resume(unsigned int catKey)
+{
+ auto iter = m_categories.find(catKey);
+
+ if(iter != m_categories.end())
+ {
+ iter->second->resume();
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+bool PlaybackManager::pause(unsigned int catKey)
+{
+ auto iter = m_categories.find(catKey);
+
+ if(iter != m_categories.end())
+ {
+ iter->second->pause();
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+float PlaybackManager::getVolume(unsigned int catKey)
+{
+ auto iter = m_categories.find(catKey);
+
+ if(iter != m_categories.end())
+ {
+ return iter->second->getVolume();
+ }
+ else
+ {
+ return -1.0;
+ }
+}
+
+bool PlaybackManager::setVolume(float volume, unsigned int catKey)
+{
+ auto iter = m_categories.find(catKey);
+
+ if(iter != m_categories.end())
+ {
+ iter->second->setVolume(volume);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+bool PlaybackManager::stop(unsigned int catKey)
+{
+ auto iter = m_categories.find(catKey);
+
+ if(iter != m_categories.end())
+ {
+ iter->second->stop();
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+void PlaybackManager::clean()
+{
+ for(auto cat : m_categories)
+ cat.second->cleanHandles();
+}
+
+bool PlaybackManager::clean(unsigned int catKey)
+{
+ auto iter = m_categories.find(catKey);
+
+ if(iter != m_categories.end())
+ {
+ iter->second->cleanHandles();
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+std::shared_ptr<IDevice> PlaybackManager::getDevice()
+{
+ return m_device;
+}
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/Reverse.cpp b/extern/audaspace/src/fx/Reverse.cpp
new file mode 100644
index 00000000000..7d906056071
--- /dev/null
+++ b/extern/audaspace/src/fx/Reverse.cpp
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/Reverse.h"
+#include "fx/ReverseReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+Reverse::Reverse(std::shared_ptr<ISound> sound) :
+ Effect(sound)
+{
+}
+
+std::shared_ptr<IReader> Reverse::createReader()
+{
+ return std::shared_ptr<IReader>(new ReverseReader(getReader()));
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/ReverseReader.cpp b/extern/audaspace/src/fx/ReverseReader.cpp
new file mode 100644
index 00000000000..19a1e25ce4f
--- /dev/null
+++ b/extern/audaspace/src/fx/ReverseReader.cpp
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/ReverseReader.h"
+#include "Exception.h"
+
+#include <cstring>
+
+AUD_NAMESPACE_BEGIN
+
+ReverseReader::ReverseReader(std::shared_ptr<IReader> reader) :
+ EffectReader(reader),
+ m_length(reader->getLength()),
+ m_position(0)
+{
+ if(m_length < 0 || !reader->isSeekable())
+ AUD_THROW(StateException, "A reader has to be seekable and have finite length to be reversible.");
+}
+
+void ReverseReader::seek(int position)
+{
+ m_position = position;
+}
+
+int ReverseReader::getLength() const
+{
+ return m_length;
+}
+
+int ReverseReader::getPosition() const
+{
+ return m_position;
+}
+
+void ReverseReader::read(int& length, bool& eos, sample_t* buffer)
+{
+ // first correct the length
+ if(m_position + length > m_length)
+ length = m_length - m_position;
+
+ if(length <= 0)
+ {
+ length = 0;
+ eos = true;
+ return;
+ }
+
+ const Specs specs = getSpecs();
+ const int samplesize = AUD_SAMPLE_SIZE(specs);
+
+ sample_t temp[CHANNEL_MAX];
+
+ int len = length;
+
+ // read from reader
+ m_reader->seek(m_length - m_position - len);
+ m_reader->read(len, eos, buffer);
+
+ // set null if reader didn't give enough data
+ if(len < length)
+ std::memset(buffer, 0, (length - len) * samplesize);
+
+ // copy the samples reverted
+ for(int i = 0; i < length / 2; i++)
+ {
+ std::memcpy(temp, buffer + (len - 1 - i) * specs.channels, samplesize);
+ std::memcpy(buffer + (len - 1 - i) * specs.channels, buffer + i * specs.channels, samplesize);
+ std::memcpy(buffer + i * specs.channels, temp, samplesize);
+ }
+
+ m_position += length;
+ eos = false;
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/SoundList.cpp b/extern/audaspace/src/fx/SoundList.cpp
new file mode 100644
index 00000000000..81239ca5baa
--- /dev/null
+++ b/extern/audaspace/src/fx/SoundList.cpp
@@ -0,0 +1,84 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "fx/SoundList.h"
+#include "Exception.h"
+
+#include <cstring>
+#include <cstdlib>
+#include <chrono>
+
+AUD_NAMESPACE_BEGIN
+
+SoundList::SoundList(bool random) :
+m_random(random)
+{
+ std::srand(time(NULL));
+}
+
+SoundList::SoundList(std::vector<std::shared_ptr<ISound>>& list, bool random) :
+m_list(list), m_random(random)
+{
+ std::srand(time(NULL));
+}
+
+std::shared_ptr<IReader> SoundList::createReader()
+{
+ if(m_list.size() > 0)
+ {
+ m_mutex.lock();
+
+ if(!m_random){
+ m_index++;
+ if(m_index >= m_list.size())
+ m_index = 0;
+ }
+ else
+ {
+ int temp;
+ do{
+ temp = std::rand() % m_list.size();
+ } while(temp == m_index && m_list.size()>1);
+ m_index = temp;
+ }
+ auto reader = m_list[m_index]->createReader();
+ m_mutex.unlock();
+ return reader;
+ }
+ else
+ AUD_THROW(FileException, "The sound list is empty");
+}
+
+void SoundList::addSound(std::shared_ptr<ISound> sound)
+{
+ m_list.push_back(sound);
+}
+
+void SoundList::setRandomMode(bool random)
+{
+ m_random = random;
+}
+
+bool SoundList::getRandomMode()
+{
+ return m_random;
+}
+
+int SoundList::getSize()
+{
+ return m_list.size();
+}
+AUD_NAMESPACE_END \ No newline at end of file
diff --git a/extern/audaspace/src/fx/Source.cpp b/extern/audaspace/src/fx/Source.cpp
new file mode 100644
index 00000000000..354ed69674b
--- /dev/null
+++ b/extern/audaspace/src/fx/Source.cpp
@@ -0,0 +1,71 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "fx/Source.h"
+
+#include <cmath>
+
+AUD_NAMESPACE_BEGIN
+Source::Source(float azimuth, float elevation, float distance) :
+ m_elevation(elevation), m_distance(distance)
+{
+ azimuth = std::fmod(azimuth, 360);
+ if(azimuth < 0)
+ azimuth += 360;
+ m_azimuth = azimuth;
+}
+
+float Source::getAzimuth()
+{
+ return m_azimuth;
+}
+
+float Source::getElevation()
+{
+ return m_elevation;
+}
+
+float Source::getDistance()
+{
+ return m_distance;
+}
+
+float Source::getVolume()
+{
+ float volume = 1.0f - m_distance;
+ if(volume < 0.0f)
+ volume = 0.0f;
+ return volume;
+}
+
+void Source::setAzimuth(float azimuth)
+{
+ azimuth = std::fmod(azimuth, 360);
+ if(azimuth < 0)
+ azimuth += 360;
+ m_azimuth = azimuth;
+}
+
+void Source::setElevation(float elevation)
+{
+ m_elevation = elevation;
+}
+
+void Source::setDistance(float distance)
+{
+ m_distance = distance;
+}
+AUD_NAMESPACE_END \ No newline at end of file
diff --git a/extern/audaspace/src/fx/Sum.cpp b/extern/audaspace/src/fx/Sum.cpp
new file mode 100644
index 00000000000..306bc5de953
--- /dev/null
+++ b/extern/audaspace/src/fx/Sum.cpp
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/Sum.h"
+#include "fx/IIRFilterReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+Sum::Sum(std::shared_ptr<ISound> sound) :
+ Effect(sound)
+{
+}
+
+std::shared_ptr<IReader> Sum::createReader()
+{
+ std::vector<float> a, b;
+ a.push_back(1);
+ a.push_back(-1);
+ b.push_back(1);
+ return std::shared_ptr<IReader>(new IIRFilterReader(getReader(), b, a));
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/Threshold.cpp b/extern/audaspace/src/fx/Threshold.cpp
new file mode 100644
index 00000000000..03c4ae4c8a5
--- /dev/null
+++ b/extern/audaspace/src/fx/Threshold.cpp
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/Threshold.h"
+#include "fx/CallbackIIRFilterReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+sample_t Threshold::thresholdFilter(CallbackIIRFilterReader* reader, float* threshold)
+{
+ float in = reader->x(0);
+ if(in >= *threshold)
+ return 1;
+ else if(in <= -*threshold)
+ return -1;
+ else
+ return 0;
+}
+
+void Threshold::endThresholdFilter(float* threshold)
+{
+ delete threshold;
+}
+
+Threshold::Threshold(std::shared_ptr<ISound> sound, float threshold) :
+ Effect(sound),
+ m_threshold(threshold)
+{
+}
+
+float Threshold::getThreshold() const
+{
+ return m_threshold;
+}
+
+std::shared_ptr<IReader> Threshold::createReader()
+{
+ return std::shared_ptr<IReader>(new CallbackIIRFilterReader(getReader(), 1, 0, doFilterIIR(thresholdFilter), endFilterIIR(endThresholdFilter), new float(m_threshold)));
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/Volume.cpp b/extern/audaspace/src/fx/Volume.cpp
new file mode 100644
index 00000000000..231f5856a6c
--- /dev/null
+++ b/extern/audaspace/src/fx/Volume.cpp
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "fx/Volume.h"
+#include "fx/IIRFilterReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+Volume::Volume(std::shared_ptr<ISound> sound, float volume) :
+ Effect(sound),
+ m_volume(volume)
+{
+}
+
+float Volume::getVolume() const
+{
+ return m_volume;
+}
+
+std::shared_ptr<IReader> Volume::createReader()
+{
+ std::vector<float> a, b;
+ a.push_back(1);
+ b.push_back(m_volume);
+ return std::shared_ptr<IReader>(new IIRFilterReader(getReader(), b, a));
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/fx/VolumeReader.cpp b/extern/audaspace/src/fx/VolumeReader.cpp
new file mode 100644
index 00000000000..ac1d4882a87
--- /dev/null
+++ b/extern/audaspace/src/fx/VolumeReader.cpp
@@ -0,0 +1,60 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "fx/VolumeReader.h"
+
+#include <cstring>
+
+AUD_NAMESPACE_BEGIN
+
+VolumeReader::VolumeReader(std::shared_ptr<IReader> reader, std::shared_ptr<VolumeStorage> volumeStorage) :
+ m_reader(reader), m_volumeStorage(volumeStorage)
+{
+}
+
+bool VolumeReader::isSeekable() const
+{
+ return m_reader->isSeekable();
+}
+
+void VolumeReader::seek(int position)
+{
+ m_reader->seek(position);
+}
+
+int VolumeReader::getLength() const
+{
+ return m_reader->getLength();
+}
+
+int VolumeReader::getPosition() const
+{
+ return m_reader->getPosition();
+}
+
+Specs VolumeReader::getSpecs() const
+{
+ return m_reader->getSpecs();
+}
+
+void VolumeReader::read(int& length, bool& eos, sample_t* buffer)
+{
+ m_reader->read(length, eos, buffer);
+ for(int i = 0; i < length * m_reader->getSpecs().channels; i++)
+ buffer[i] = buffer[i] * m_volumeStorage->getVolume();
+}
+
+AUD_NAMESPACE_END \ No newline at end of file
diff --git a/extern/audaspace/src/fx/VolumeSound.cpp b/extern/audaspace/src/fx/VolumeSound.cpp
new file mode 100644
index 00000000000..b7f96225682
--- /dev/null
+++ b/extern/audaspace/src/fx/VolumeSound.cpp
@@ -0,0 +1,45 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "fx/VolumeSound.h"
+#include "fx/VolumeReader.h"
+#include "Exception.h"
+
+#include <cstring>
+
+AUD_NAMESPACE_BEGIN
+
+VolumeSound::VolumeSound(std::shared_ptr<ISound> sound, std::shared_ptr<VolumeStorage> volumeStorage) :
+ m_sound(sound), m_volumeStorage(volumeStorage)
+{
+}
+
+std::shared_ptr<IReader> VolumeSound::createReader()
+{
+ return std::make_shared<VolumeReader>(m_sound->createReader(), m_volumeStorage);
+}
+
+std::shared_ptr<VolumeStorage> VolumeSound::getSharedVolume()
+{
+ return m_volumeStorage;
+}
+
+void VolumeSound::setSharedVolume(std::shared_ptr<VolumeStorage> volumeStorage)
+{
+ m_volumeStorage = volumeStorage;
+}
+
+AUD_NAMESPACE_END \ No newline at end of file
diff --git a/extern/audaspace/src/fx/VolumeStorage.cpp b/extern/audaspace/src/fx/VolumeStorage.cpp
new file mode 100644
index 00000000000..4c5164d0ea1
--- /dev/null
+++ b/extern/audaspace/src/fx/VolumeStorage.cpp
@@ -0,0 +1,39 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "fx/VolumeStorage.h"
+
+AUD_NAMESPACE_BEGIN
+VolumeStorage::VolumeStorage() :
+ m_volume(1.0f)
+{
+}
+
+VolumeStorage::VolumeStorage(float volume) :
+ m_volume(volume)
+{
+}
+
+float VolumeStorage::getVolume()
+{
+ return m_volume;
+}
+
+void VolumeStorage::setVolume(float volume)
+{
+ m_volume = volume;
+}
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/generator/Sawtooth.cpp b/extern/audaspace/src/generator/Sawtooth.cpp
new file mode 100644
index 00000000000..f5acad44839
--- /dev/null
+++ b/extern/audaspace/src/generator/Sawtooth.cpp
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "generator/Sawtooth.h"
+#include "generator/SawtoothReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+Sawtooth::Sawtooth(float frequency, SampleRate sampleRate) :
+ m_frequency(frequency),
+ m_sampleRate(sampleRate)
+{
+}
+
+float Sawtooth::getFrequency() const
+{
+ return m_frequency;
+}
+
+std::shared_ptr<IReader> Sawtooth::createReader()
+{
+ return std::shared_ptr<IReader>(new SawtoothReader(m_frequency, m_sampleRate));
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/generator/SawtoothReader.cpp b/extern/audaspace/src/generator/SawtoothReader.cpp
new file mode 100644
index 00000000000..3664b8d3b61
--- /dev/null
+++ b/extern/audaspace/src/generator/SawtoothReader.cpp
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "generator/SawtoothReader.h"
+
+#include <cmath>
+
+AUD_NAMESPACE_BEGIN
+
+SawtoothReader::SawtoothReader(float frequency, SampleRate sampleRate) :
+ m_frequency(frequency),
+ m_position(0),
+ m_sample(0),
+ m_sampleRate(sampleRate)
+{
+}
+
+void SawtoothReader::setFrequency(float frequency)
+{
+ m_frequency = frequency;
+}
+
+bool SawtoothReader::isSeekable() const
+{
+ return true;
+}
+
+void SawtoothReader::seek(int position)
+{
+ m_position = position;
+ m_sample = std::fmod(m_position * m_frequency / (float)m_sampleRate + 1.0f, 2.0f) - 1.0f;
+}
+
+int SawtoothReader::getLength() const
+{
+ return -1;
+}
+
+int SawtoothReader::getPosition() const
+{
+ return m_position;
+}
+
+Specs SawtoothReader::getSpecs() const
+{
+ Specs specs;
+ specs.rate = m_sampleRate;
+ specs.channels = CHANNELS_MONO;
+ return specs;
+}
+
+void SawtoothReader::read(int& length, bool& eos, sample_t* buffer)
+{
+ float k = 2.0 * m_frequency / m_sampleRate;
+
+ for(int i = 0; i < length; i++)
+ {
+ m_sample += k;
+
+ if(m_sample >= 1.0f)
+ m_sample -= std::floor(m_sample) + 1.0f;
+
+ buffer[i] = m_sample;
+ }
+
+ m_position += length;
+ eos = false;
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/generator/Silence.cpp b/extern/audaspace/src/generator/Silence.cpp
new file mode 100644
index 00000000000..a173a1bc5f6
--- /dev/null
+++ b/extern/audaspace/src/generator/Silence.cpp
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "generator/Silence.h"
+#include "generator/SilenceReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+Silence::Silence()
+{
+}
+
+std::shared_ptr<IReader> Silence::createReader()
+{
+ return std::shared_ptr<IReader>(new SilenceReader());
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/generator/SilenceReader.cpp b/extern/audaspace/src/generator/SilenceReader.cpp
new file mode 100644
index 00000000000..39358cc087a
--- /dev/null
+++ b/extern/audaspace/src/generator/SilenceReader.cpp
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "generator/SilenceReader.h"
+
+#include <cstring>
+
+AUD_NAMESPACE_BEGIN
+
+SilenceReader::SilenceReader() :
+ m_position(0)
+{
+}
+
+bool SilenceReader::isSeekable() const
+{
+ return true;
+}
+
+void SilenceReader::seek(int position)
+{
+ m_position = position;
+}
+
+int SilenceReader::getLength() const
+{
+ return -1;
+}
+
+int SilenceReader::getPosition() const
+{
+ return m_position;
+}
+
+Specs SilenceReader::getSpecs() const
+{
+ Specs specs;
+ specs.rate = RATE_48000;
+ specs.channels = CHANNELS_MONO;
+ return specs;
+}
+
+void SilenceReader::read(int& length, bool& eos, sample_t* buffer)
+{
+ std::memset(buffer, 0, length * sizeof(sample_t));
+ m_position += length;
+ eos = false;
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/generator/Sine.cpp b/extern/audaspace/src/generator/Sine.cpp
new file mode 100644
index 00000000000..b7cdc132df6
--- /dev/null
+++ b/extern/audaspace/src/generator/Sine.cpp
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "generator/Sine.h"
+#include "generator/SineReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+Sine::Sine(float frequency, SampleRate sampleRate) :
+ m_frequency(frequency),
+ m_sampleRate(sampleRate)
+{
+}
+
+float Sine::getFrequency() const
+{
+ return m_frequency;
+}
+
+std::shared_ptr<IReader> Sine::createReader()
+{
+ return std::shared_ptr<IReader>(new SineReader(m_frequency, m_sampleRate));
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/generator/SineReader.cpp b/extern/audaspace/src/generator/SineReader.cpp
new file mode 100644
index 00000000000..49b7cc3114b
--- /dev/null
+++ b/extern/audaspace/src/generator/SineReader.cpp
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "generator/SineReader.h"
+
+#include <cmath>
+
+AUD_NAMESPACE_BEGIN
+
+SineReader::SineReader(float frequency, SampleRate sampleRate) :
+ m_frequency(frequency),
+ m_position(0),
+ m_sampleRate(sampleRate)
+{
+}
+
+void SineReader::setFrequency(float frequency)
+{
+ m_frequency = frequency;
+}
+
+bool SineReader::isSeekable() const
+{
+ return true;
+}
+
+void SineReader::seek(int position)
+{
+ m_position = position;
+}
+
+int SineReader::getLength() const
+{
+ return -1;
+}
+
+int SineReader::getPosition() const
+{
+ return m_position;
+}
+
+Specs SineReader::getSpecs() const
+{
+ Specs specs;
+ specs.rate = m_sampleRate;
+ specs.channels = CHANNELS_MONO;
+ return specs;
+}
+
+void SineReader::read(int& length, bool& eos, sample_t* buffer)
+{
+ // fill with sine data
+ for(int i = 0; i < length; i++)
+ {
+ buffer[i] = std::sin((m_position + i) * 2 * M_PI * m_frequency / m_sampleRate);
+ }
+
+ m_position += length;
+ eos = false;
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/generator/Square.cpp b/extern/audaspace/src/generator/Square.cpp
new file mode 100644
index 00000000000..361c243c549
--- /dev/null
+++ b/extern/audaspace/src/generator/Square.cpp
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "generator/Square.h"
+#include "generator/SquareReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+Square::Square(float frequency, SampleRate sampleRate) :
+ m_frequency(frequency),
+ m_sampleRate(sampleRate)
+{
+}
+
+float Square::getFrequency() const
+{
+ return m_frequency;
+}
+
+std::shared_ptr<IReader> Square::createReader()
+{
+ return std::shared_ptr<IReader>(new SquareReader(m_frequency, m_sampleRate));
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/generator/SquareReader.cpp b/extern/audaspace/src/generator/SquareReader.cpp
new file mode 100644
index 00000000000..8f49b097487
--- /dev/null
+++ b/extern/audaspace/src/generator/SquareReader.cpp
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "generator/SquareReader.h"
+
+#include <cmath>
+
+AUD_NAMESPACE_BEGIN
+
+SquareReader::SquareReader(float frequency, SampleRate sampleRate) :
+ m_frequency(frequency),
+ m_position(0),
+ m_sample(0),
+ m_sampleRate(sampleRate)
+{
+}
+
+void SquareReader::setFrequency(float frequency)
+{
+ m_frequency = frequency;
+}
+
+bool SquareReader::isSeekable() const
+{
+ return true;
+}
+
+void SquareReader::seek(int position)
+{
+ m_position = position;
+ m_sample = std::fmod(m_position * m_frequency / (float)m_sampleRate, 2.0f);
+}
+
+int SquareReader::getLength() const
+{
+ return -1;
+}
+
+int SquareReader::getPosition() const
+{
+ return m_position;
+}
+
+Specs SquareReader::getSpecs() const
+{
+ Specs specs;
+ specs.rate = m_sampleRate;
+ specs.channels = CHANNELS_MONO;
+ return specs;
+}
+
+void SquareReader::read(int& length, bool& eos, sample_t* buffer)
+{
+ float k = 2.0 * m_frequency / m_sampleRate;
+
+ for(int i = 0; i < length; i++)
+ {
+ m_sample += k;
+
+ if(m_sample >= 2.0f)
+ m_sample = std::fmod(m_sample, 2.0f);
+
+ buffer[i] = (m_sample < 1.0f) * 2.0f - 1.0f;
+ }
+
+ m_position += length;
+ eos = false;
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/generator/Triangle.cpp b/extern/audaspace/src/generator/Triangle.cpp
new file mode 100644
index 00000000000..ca8f1b63fb9
--- /dev/null
+++ b/extern/audaspace/src/generator/Triangle.cpp
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "generator/Triangle.h"
+#include "generator/TriangleReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+Triangle::Triangle(float frequency, SampleRate sampleRate) :
+ m_frequency(frequency),
+ m_sampleRate(sampleRate)
+{
+}
+
+float Triangle::getFrequency() const
+{
+ return m_frequency;
+}
+
+std::shared_ptr<IReader> Triangle::createReader()
+{
+ return std::shared_ptr<IReader>(new TriangleReader(m_frequency, m_sampleRate));
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/generator/TriangleReader.cpp b/extern/audaspace/src/generator/TriangleReader.cpp
new file mode 100644
index 00000000000..c363d3850ca
--- /dev/null
+++ b/extern/audaspace/src/generator/TriangleReader.cpp
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "generator/TriangleReader.h"
+
+#include <cmath>
+
+AUD_NAMESPACE_BEGIN
+
+TriangleReader::TriangleReader(float frequency, SampleRate sampleRate) :
+ m_frequency(frequency),
+ m_position(0),
+ m_sample(0.5f),
+ m_sampleRate(sampleRate)
+{
+}
+
+void TriangleReader::setFrequency(float frequency)
+{
+ m_frequency = frequency;
+}
+
+bool TriangleReader::isSeekable() const
+{
+ return true;
+}
+
+void TriangleReader::seek(int position)
+{
+ m_position = position;
+ m_sample = std::fmod(m_position * m_frequency / (float)m_sampleRate + 1.5f, 2.0f) - 1.0f;
+}
+
+int TriangleReader::getLength() const
+{
+ return -1;
+}
+
+int TriangleReader::getPosition() const
+{
+ return m_position;
+}
+
+Specs TriangleReader::getSpecs() const
+{
+ Specs specs;
+ specs.rate = m_sampleRate;
+ specs.channels = CHANNELS_MONO;
+ return specs;
+}
+
+void TriangleReader::read(int& length, bool& eos, sample_t* buffer)
+{
+ float k = 2.0 * m_frequency / m_sampleRate;
+
+ for(int i = 0; i < length; i++)
+ {
+ m_sample += k;
+
+ if(m_sample >= 1.0f)
+ m_sample -= std::floor(m_sample) + 1.0f;
+
+ buffer[i] = std::fabs(m_sample) * 2.0f - 1.0f;
+ }
+
+ m_position += length;
+ eos = false;
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/plugin/PluginManagerUnix.cpp.in b/extern/audaspace/src/plugin/PluginManagerUnix.cpp.in
new file mode 100644
index 00000000000..d08804bc2e7
--- /dev/null
+++ b/extern/audaspace/src/plugin/PluginManagerUnix.cpp.in
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "plugin/PluginManager.h"
+
+#include <dlfcn.h>
+#include <dirent.h>
+
+AUD_NAMESPACE_BEGIN
+
+std::unordered_map<std::string, void*> PluginManager::m_plugins;
+
+void* PluginManager::openLibrary(const std::string& path)
+{
+ return dlopen(path.c_str(), RTLD_LAZY);
+}
+
+void *PluginManager::lookupLibrary(void *handle, const std::string &name)
+{
+ return dlsym(handle, name.c_str());
+}
+
+void PluginManager::closeLibrary(void *handle)
+{
+ dlclose(handle);
+}
+
+bool PluginManager::loadPlugin(const std::string& path)
+{
+ void* handle = openLibrary(path);
+
+ if (!handle)
+ return false;
+
+ void (*registerPlugin)() = (void (*)())lookupLibrary(handle, "registerPlugin");
+ const char* (*getName)() = (const char* (*)())lookupLibrary(handle, "getName");
+
+ if(!registerPlugin || !getName)
+ {
+ closeLibrary(handle);
+ return false;
+ }
+
+ registerPlugin();
+
+ m_plugins[getName()] = handle;
+
+ return true;
+}
+
+#define STATIC_PLUGIN_CLASS(name) class name { public: static void registerPlugin(); };
+#define STATIC_PLUGIN_REGISTER(name) name::registerPlugin();
+
+@STATIC_PLUGIN_CLASSES@
+
+void PluginManager::loadPlugins(const std::string& path)
+{
+@STATIC_PLUGIN_REGISTERS@
+
+ std::string readpath = path;
+
+ if(path == "")
+ readpath = "@DEFAULT_PLUGIN_PATH@";
+
+ DIR* dir = opendir(readpath.c_str());
+
+ if(!dir)
+ return;
+
+ while(dirent* entry = readdir(dir))
+ {
+ const std::string filename = entry->d_name;
+ const std::string end = ".so";
+
+ if(filename.length() >= end.length() && filename.substr(filename.length() - end.length()) == end)
+ {
+ if(!loadPlugin(readpath + "/" + filename + ".@AUDASPACE_VERSION@"))
+ loadPlugin(readpath + "/" + filename);
+ }
+ }
+
+ closedir(dir);
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/plugin/PluginManagerWindows.cpp.in b/extern/audaspace/src/plugin/PluginManagerWindows.cpp.in
new file mode 100644
index 00000000000..62350fd24fd
--- /dev/null
+++ b/extern/audaspace/src/plugin/PluginManagerWindows.cpp.in
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "plugin/PluginManager.h"
+
+#include <windows.h>
+
+AUD_NAMESPACE_BEGIN
+
+std::unordered_map<std::string, void*> PluginManager::m_plugins;
+
+void* PluginManager::openLibrary(const std::string& path)
+{
+ return reinterpret_cast<void*>(LoadLibrary(path.c_str()));
+}
+
+void *PluginManager::lookupLibrary(void *handle, const std::string &name)
+{
+ return GetProcAddress(reinterpret_cast<HMODULE>(handle), name.c_str());
+}
+
+void PluginManager::closeLibrary(void *handle)
+{
+ FreeLibrary(reinterpret_cast<HMODULE>(handle));
+}
+
+bool PluginManager::loadPlugin(const std::string& path)
+{
+ void* handle = openLibrary(path);
+
+ if (!handle)
+ return false;
+
+ void (*registerPlugin)() = (void (*)())lookupLibrary(handle, "registerPlugin");
+ const char* (*getName)() = (const char* (*)())lookupLibrary(handle, "getName");
+
+ if(!registerPlugin || !getName)
+ {
+ closeLibrary(handle);
+ return false;
+ }
+
+ registerPlugin();
+
+ m_plugins[getName()] = handle;
+
+ return true;
+}
+
+#define STATIC_PLUGIN_CLASS(name) class name { public: static void registerPlugin(); };
+#define STATIC_PLUGIN_REGISTER(name) name::registerPlugin();
+
+@STATIC_PLUGIN_CLASSES@
+
+void PluginManager::loadPlugins(const std::string& path)
+{
+@STATIC_PLUGIN_REGISTERS@
+
+ std::string readpath = path;
+
+ if(path == "")
+ readpath = "@DEFAULT_PLUGIN_PATH@";
+
+ WIN32_FIND_DATA entry;
+ bool found_file = true;
+ std::string search = readpath + "\\*";
+ HANDLE dir = FindFirstFile(search.c_str(), &entry);
+
+ if(dir == INVALID_HANDLE_VALUE)
+ return;
+
+ while(found_file)
+ {
+ const std::string filename = entry.cFileName;
+ const std::string end = ".dll";
+
+ if(filename.length() >= end.length() && filename.substr(filename.length() - end.length()) == end)
+ {
+ loadPlugin(readpath + "/" + filename);
+ }
+
+ found_file = FindNextFile(dir, &entry);
+ }
+
+ FindClose(dir);
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/respec/ChannelMapper.cpp b/extern/audaspace/src/respec/ChannelMapper.cpp
new file mode 100644
index 00000000000..e6e214598cb
--- /dev/null
+++ b/extern/audaspace/src/respec/ChannelMapper.cpp
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "respec/ChannelMapper.h"
+#include "respec/ChannelMapperReader.h"
+
+#include <cstring>
+
+AUD_NAMESPACE_BEGIN
+
+ChannelMapper::ChannelMapper(std::shared_ptr<ISound> sound, DeviceSpecs specs) :
+ SpecsChanger(sound, specs)
+{
+}
+
+std::shared_ptr<IReader> ChannelMapper::createReader()
+{
+ std::shared_ptr<IReader> reader = getReader();
+ return std::shared_ptr<IReader>(new ChannelMapperReader(reader, m_specs.channels));
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/respec/ChannelMapperReader.cpp b/extern/audaspace/src/respec/ChannelMapperReader.cpp
new file mode 100644
index 00000000000..850e54b73cf
--- /dev/null
+++ b/extern/audaspace/src/respec/ChannelMapperReader.cpp
@@ -0,0 +1,379 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "respec/ChannelMapperReader.h"
+
+#include <cmath>
+#include <limits>
+
+AUD_NAMESPACE_BEGIN
+
+ChannelMapperReader::ChannelMapperReader(std::shared_ptr<IReader> reader,
+ Channels channels) :
+ EffectReader(reader), m_target_channels(channels),
+ m_source_channels(CHANNELS_INVALID), m_mapping(nullptr), m_map_size(0), m_mono_angle(0)
+{
+}
+
+ChannelMapperReader::~ChannelMapperReader()
+{
+ delete[] m_mapping;
+}
+
+Channels ChannelMapperReader::getSourceChannels() const
+{
+ return m_reader->getSpecs().channels;
+}
+
+Channels ChannelMapperReader::getChannels() const
+{
+ return m_target_channels;
+}
+
+void ChannelMapperReader::setChannels(Channels channels)
+{
+ m_target_channels = channels;
+ calculateMapping();
+}
+
+float ChannelMapperReader::getMapping(int source, int target)
+{
+ Channels source_channels = m_reader->getSpecs().channels;
+ if(source_channels != m_source_channels)
+ {
+ m_source_channels = source_channels;
+ calculateMapping();
+ }
+
+ if(source < 0 || source >= source_channels || target < 0 || target >= m_target_channels)
+ return std::numeric_limits<float>::quiet_NaN();
+
+ return m_mapping[target * source_channels + source];
+}
+
+void ChannelMapperReader::setMonoAngle(float angle)
+{
+ if(angle != angle)
+ angle = 0;
+ m_mono_angle = angle;
+ if(m_source_channels == CHANNELS_MONO)
+ calculateMapping();
+}
+
+float ChannelMapperReader::angleDistance(float alpha, float beta)
+{
+ alpha = beta - alpha;
+
+ if(alpha > M_PI)
+ alpha -= 2 * M_PI;
+ if(alpha < -M_PI)
+ alpha += 2 * M_PI;
+
+ return alpha;
+}
+
+void ChannelMapperReader::calculateMapping()
+{
+ if(m_map_size < m_source_channels * m_target_channels)
+ {
+ delete[] m_mapping;
+ m_mapping = new float[m_source_channels * m_target_channels];
+ m_map_size = m_source_channels * m_target_channels;
+ }
+
+ for(int i = 0; i < m_source_channels * m_target_channels; i++)
+ m_mapping[i] = 0;
+
+ const Channel* source_channels = CHANNEL_MAPS[m_source_channels - 1];
+ const Channel* target_channels = CHANNEL_MAPS[m_target_channels - 1];
+
+ int lfe = -1;
+
+ for(int i = 0; i < m_target_channels; i++)
+ {
+ if(target_channels[i] == CHANNEL_LFE)
+ {
+ lfe = i;
+ break;
+ }
+ }
+
+ const float* source_angles = CHANNEL_ANGLES[m_source_channels - 1];
+ const float* target_angles = CHANNEL_ANGLES[m_target_channels - 1];
+
+ if(m_source_channels == CHANNELS_MONO)
+ source_angles = &m_mono_angle;
+
+ int channel_left, channel_right;
+ float angle_left, angle_right, angle;
+
+ for(int i = 0; i < m_source_channels; i++)
+ {
+ if(source_channels[i] == CHANNEL_LFE)
+ {
+ if(lfe != -1)
+ m_mapping[lfe * m_source_channels + i] = 1;
+
+ continue;
+ }
+
+ channel_left = channel_right = -1;
+ angle_left = -2 * M_PI;
+ angle_right = 2 * M_PI;
+
+ for(int j = 0; j < m_target_channels; j++)
+ {
+ if(j == lfe)
+ continue;
+ angle = angleDistance(source_angles[i], target_angles[j]);
+ if(angle < 0)
+ {
+ if(angle > angle_left)
+ {
+ angle_left = angle;
+ channel_left = j;
+ }
+ }
+ else
+ {
+ if(angle < angle_right)
+ {
+ angle_right = angle;
+ channel_right = j;
+ }
+ }
+ }
+
+ angle = angle_right - angle_left;
+ if(channel_right == -1 || angle == 0)
+ {
+ m_mapping[channel_left * m_source_channels + i] = 1;
+ }
+ else if(channel_left == -1)
+ {
+ m_mapping[channel_right * m_source_channels + i] = 1;
+ }
+ else
+ {
+ m_mapping[channel_left * m_source_channels + i] = std::cos(M_PI_2 * angle_left / angle);
+ m_mapping[channel_right * m_source_channels + i] = std::cos(M_PI_2 * angle_right / angle);
+ }
+ }
+}
+
+Specs ChannelMapperReader::getSpecs() const
+{
+ Specs specs = m_reader->getSpecs();
+ specs.channels = m_target_channels;
+ return specs;
+}
+
+void ChannelMapperReader::read(int& length, bool& eos, sample_t* buffer)
+{
+ Channels channels = m_reader->getSpecs().channels;
+ if(channels != m_source_channels)
+ {
+ m_source_channels = channels;
+ calculateMapping();
+ }
+
+ if(m_source_channels == m_target_channels)
+ {
+ m_reader->read(length, eos, buffer);
+ return;
+ }
+
+ m_buffer.assureSize(length * channels * sizeof(sample_t));
+
+ sample_t* in = m_buffer.getBuffer();
+
+ m_reader->read(length, eos, in);
+
+ sample_t sum;
+
+ for(int i = 0; i < length; i++)
+ {
+ for(int j = 0; j < m_target_channels; j++)
+ {
+ sum = 0;
+ for(int k = 0; k < m_source_channels; k++)
+ sum += m_mapping[j * m_source_channels + k] * in[i * m_source_channels + k];
+ buffer[i * m_target_channels + j] = sum;
+ }
+ }
+}
+
+const Channel ChannelMapperReader::MONO_MAP[] =
+{
+ CHANNEL_FRONT_CENTER
+};
+
+const Channel ChannelMapperReader::STEREO_MAP[] =
+{
+ CHANNEL_FRONT_LEFT,
+ CHANNEL_FRONT_RIGHT
+};
+
+const Channel ChannelMapperReader::STEREO_LFE_MAP[] =
+{
+ CHANNEL_FRONT_LEFT,
+ CHANNEL_FRONT_RIGHT,
+ CHANNEL_LFE
+};
+
+const Channel ChannelMapperReader::SURROUND4_MAP[] =
+{
+ CHANNEL_FRONT_LEFT,
+ CHANNEL_FRONT_RIGHT,
+ CHANNEL_REAR_LEFT,
+ CHANNEL_REAR_RIGHT
+};
+
+const Channel ChannelMapperReader::SURROUND5_MAP[] =
+{
+ CHANNEL_FRONT_LEFT,
+ CHANNEL_FRONT_RIGHT,
+ CHANNEL_FRONT_CENTER,
+ CHANNEL_REAR_LEFT,
+ CHANNEL_REAR_RIGHT
+};
+
+const Channel ChannelMapperReader::SURROUND51_MAP[] =
+{
+ CHANNEL_FRONT_LEFT,
+ CHANNEL_FRONT_RIGHT,
+ CHANNEL_FRONT_CENTER,
+ CHANNEL_LFE,
+ CHANNEL_REAR_LEFT,
+ CHANNEL_REAR_RIGHT
+};
+
+const Channel ChannelMapperReader::SURROUND61_MAP[] =
+{
+ CHANNEL_FRONT_LEFT,
+ CHANNEL_FRONT_RIGHT,
+ CHANNEL_FRONT_CENTER,
+ CHANNEL_LFE,
+ CHANNEL_REAR_CENTER,
+ CHANNEL_REAR_LEFT,
+ CHANNEL_REAR_RIGHT
+};
+
+const Channel ChannelMapperReader::SURROUND71_MAP[] =
+{
+ CHANNEL_FRONT_LEFT,
+ CHANNEL_FRONT_RIGHT,
+ CHANNEL_FRONT_CENTER,
+ CHANNEL_LFE,
+ CHANNEL_REAR_LEFT,
+ CHANNEL_REAR_RIGHT,
+ CHANNEL_SIDE_LEFT,
+ CHANNEL_SIDE_RIGHT
+};
+
+const Channel* ChannelMapperReader::CHANNEL_MAPS[] =
+{
+ ChannelMapperReader::MONO_MAP,
+ ChannelMapperReader::STEREO_MAP,
+ ChannelMapperReader::STEREO_LFE_MAP,
+ ChannelMapperReader::SURROUND4_MAP,
+ ChannelMapperReader::SURROUND5_MAP,
+ ChannelMapperReader::SURROUND51_MAP,
+ ChannelMapperReader::SURROUND61_MAP,
+ ChannelMapperReader::SURROUND71_MAP
+};
+
+const float ChannelMapperReader::MONO_ANGLES[] =
+{
+ 0.0f * M_PI / 180.0f
+};
+
+const float ChannelMapperReader::STEREO_ANGLES[] =
+{
+ -90.0f * M_PI / 180.0f,
+ 90.0f * M_PI / 180.0f
+};
+
+const float ChannelMapperReader::STEREO_LFE_ANGLES[] =
+{
+ -90.0f * M_PI / 180.0f,
+ 90.0f * M_PI / 180.0f,
+ 0.0f * M_PI / 180.0f
+};
+
+const float ChannelMapperReader::SURROUND4_ANGLES[] =
+{
+ -45.0f * M_PI / 180.0f,
+ 45.0f * M_PI / 180.0f,
+ -135.0f * M_PI / 180.0f,
+ 135.0f * M_PI / 180.0f
+};
+
+const float ChannelMapperReader::SURROUND5_ANGLES[] =
+{
+ -30.0f * M_PI / 180.0f,
+ 30.0f * M_PI / 180.0f,
+ 0.0f * M_PI / 180.0f,
+ -110.0f * M_PI / 180.0f,
+ 110.0f * M_PI / 180.0f
+};
+
+const float ChannelMapperReader::SURROUND51_ANGLES[] =
+{
+ -30.0f * M_PI / 180.0f,
+ 30.0f * M_PI / 180.0f,
+ 0.0f * M_PI / 180.0f,
+ 0.0f * M_PI / 180.0f,
+ -110.0f * M_PI / 180.0f,
+ 110.0f * M_PI / 180.0f
+};
+
+const float ChannelMapperReader::SURROUND61_ANGLES[] =
+{
+ -30.0f * M_PI / 180.0f,
+ 30.0f * M_PI / 180.0f,
+ 0.0f * M_PI / 180.0f,
+ 0.0f * M_PI / 180.0f,
+ 180.0f * M_PI / 180.0f,
+ -110.0f * M_PI / 180.0f,
+ 110.0f * M_PI / 180.0f
+};
+
+const float ChannelMapperReader::SURROUND71_ANGLES[] =
+{
+ -30.0f * M_PI / 180.0f,
+ 30.0f * M_PI / 180.0f,
+ 0.0f * M_PI / 180.0f,
+ 0.0f * M_PI / 180.0f,
+ -110.0f * M_PI / 180.0f,
+ 110.0f * M_PI / 180.0f,
+ -150.0f * M_PI / 180.0f,
+ 150.0f * M_PI / 180.0f
+};
+
+const float* ChannelMapperReader::CHANNEL_ANGLES[] =
+{
+ ChannelMapperReader::MONO_ANGLES,
+ ChannelMapperReader::STEREO_ANGLES,
+ ChannelMapperReader::STEREO_LFE_ANGLES,
+ ChannelMapperReader::SURROUND4_ANGLES,
+ ChannelMapperReader::SURROUND5_ANGLES,
+ ChannelMapperReader::SURROUND51_ANGLES,
+ ChannelMapperReader::SURROUND61_ANGLES,
+ ChannelMapperReader::SURROUND71_ANGLES
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/respec/Converter.cpp b/extern/audaspace/src/respec/Converter.cpp
new file mode 100644
index 00000000000..f3cca20c741
--- /dev/null
+++ b/extern/audaspace/src/respec/Converter.cpp
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "respec/Converter.h"
+#include "respec/ConverterReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+Converter::Converter(std::shared_ptr<ISound> sound,
+ DeviceSpecs specs) :
+ SpecsChanger(sound, specs)
+{
+}
+
+std::shared_ptr<IReader> Converter::createReader()
+{
+ std::shared_ptr<IReader> reader = getReader();
+
+ if(m_specs.format != FORMAT_FLOAT32)
+ reader = std::shared_ptr<IReader>(new ConverterReader(reader, m_specs));
+
+ return reader;
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/respec/ConverterFunctions.cpp b/extern/audaspace/src/respec/ConverterFunctions.cpp
new file mode 100644
index 00000000000..d3df4a9ecbb
--- /dev/null
+++ b/extern/audaspace/src/respec/ConverterFunctions.cpp
@@ -0,0 +1,464 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "respec/ConverterFunctions.h"
+
+#include <stdint.h>
+
+#define U8_0 0x80
+#define S16_MAX ((int16_t)0x7FFF)
+#define S16_MIN ((int16_t)0x8000)
+#define S16_FLT 32767.0f
+#define S32_MAX ((int32_t)0x7FFFFFFF)
+#define S32_MIN ((int32_t)0x80000000)
+#define S32_FLT 2147483647.0f
+#define FLT_MAX 1.0f
+#define FLT_MIN -1.0f
+
+AUD_NAMESPACE_BEGIN
+
+void convert_u8_s16(data_t* target, data_t* source, int length)
+{
+ int16_t* t = (int16_t*) target;
+ for(int i = length - 1; i >= 0; i--)
+ t[i] = (((int16_t)source[i]) - U8_0) << 8;
+}
+
+void convert_u8_s24_be(data_t* target, data_t* source, int length)
+{
+ for(int i = length - 1; i >= 0; i--)
+ {
+ target[i*3] = source[i] - U8_0;
+ target[i*3+1] = 0;
+ target[i*3+2] = 0;
+ }
+}
+
+void convert_u8_s24_le(data_t* target, data_t* source, int length)
+{
+ for(int i = length - 1; i >= 0; i--)
+ {
+ target[i*3+2] = source[i] - U8_0;
+ target[i*3+1] = 0;
+ target[i*3] = 0;
+ }
+}
+
+void convert_u8_s32(data_t* target, data_t* source, int length)
+{
+ int32_t* t = (int32_t*) target;
+ for(int i = length - 1; i >= 0; i--)
+ t[i] = (((int32_t)source[i]) - U8_0) << 24;
+}
+
+void convert_u8_float(data_t* target, data_t* source, int length)
+{
+ float* t = (float*) target;
+ for(int i = length - 1; i >= 0; i--)
+ t[i] = (((int32_t)source[i]) - U8_0) / ((float)U8_0);
+}
+
+void convert_u8_double(data_t* target, data_t* source, int length)
+{
+ double* t = (double*) target;
+ for(int i = length - 1; i >= 0; i--)
+ t[i] = (((int32_t)source[i]) - U8_0) / ((double)U8_0);
+}
+
+void convert_s16_u8(data_t* target, data_t* source, int length)
+{
+ int16_t* s = (int16_t*) source;
+ for(int i = 0; i < length; i++)
+ target[i] = (unsigned char)((s[i] >> 8) + U8_0);
+}
+
+void convert_s16_s24_be(data_t* target, data_t* source, int length)
+{
+ int16_t* s = (int16_t*) source;
+ int16_t t;
+ for(int i = length - 1; i >= 0; i--)
+ {
+ t = s[i];
+ target[i*3] = t >> 8 & 0xFF;
+ target[i*3+1] = t & 0xFF;
+ target[i*3+2] = 0;
+ }
+}
+
+void convert_s16_s24_le(data_t* target, data_t* source, int length)
+{
+ int16_t* s = (int16_t*) source;
+ int16_t t;
+ for(int i = length - 1; i >= 0; i--)
+ {
+ t = s[i];
+ target[i*3+2] = t >> 8 & 0xFF;
+ target[i*3+1] = t & 0xFF;
+ target[i*3] = 0;
+ }
+}
+
+void convert_s16_s32(data_t* target, data_t* source, int length)
+{
+ int16_t* s = (int16_t*) source;
+ int32_t* t = (int32_t*) target;
+ for(int i = length - 1; i >= 0; i--)
+ t[i] = ((int32_t)s[i]) << 16;
+}
+
+void convert_s16_float(data_t* target, data_t* source, int length)
+{
+ int16_t* s = (int16_t*) source;
+ float* t = (float*) target;
+ for(int i = length - 1; i >= 0; i--)
+ t[i] = s[i] / S16_FLT;
+}
+
+void convert_s16_double(data_t* target, data_t* source, int length)
+{
+ int16_t* s = (int16_t*) source;
+ double* t = (double*) target;
+ for(int i = length - 1; i >= 0; i--)
+ t[i] = s[i] / S16_FLT;
+}
+
+void convert_s24_u8_be(data_t* target, data_t* source, int length)
+{
+ for(int i = 0; i < length; i++)
+ target[i] = source[i*3] ^ U8_0;
+}
+
+void convert_s24_u8_le(data_t* target, data_t* source, int length)
+{
+ for(int i = 0; i < length; i++)
+ target[i] = source[i*3+2] ^ U8_0;
+}
+
+void convert_s24_s16_be(data_t* target, data_t* source, int length)
+{
+ int16_t* t = (int16_t*) target;
+ for(int i = 0; i < length; i++)
+ t[i] = source[i*3] << 8 | source[i*3+1];
+}
+
+void convert_s24_s16_le(data_t* target, data_t* source, int length)
+{
+ int16_t* t = (int16_t*) target;
+ for(int i = 0; i < length; i++)
+ t[i] = source[i*3+2] << 8 | source[i*3+1];
+}
+
+void convert_s24_s24(data_t* target, data_t* source, int length)
+{
+ std::memcpy(target, source, length * 3);
+}
+
+void convert_s24_s32_be(data_t* target, data_t* source, int length)
+{
+ int32_t* t = (int32_t*) target;
+ for(int i = length - 1; i >= 0; i--)
+ t[i] = source[i*3] << 24 | source[i*3+1] << 16 | source[i*3+2] << 8;
+}
+
+void convert_s24_s32_le(data_t* target, data_t* source, int length)
+{
+ int32_t* t = (int32_t*) target;
+ for(int i = length - 1; i >= 0; i--)
+ t[i] = source[i*3+2] << 24 | source[i*3+1] << 16 | source[i*3] << 8;
+}
+
+void convert_s24_float_be(data_t* target, data_t* source, int length)
+{
+ float* t = (float*) target;
+ int32_t s;
+ for(int i = length - 1; i >= 0; i--)
+ {
+ s = source[i*3] << 24 | source[i*3+1] << 16 | source[i*3+2] << 8;
+ t[i] = s / S32_FLT;
+ }
+}
+
+void convert_s24_float_le(data_t* target, data_t* source, int length)
+{
+ float* t = (float*) target;
+ int32_t s;
+ for(int i = length - 1; i >= 0; i--)
+ {
+ s = source[i*3+2] << 24 | source[i*3+1] << 16 | source[i*3] << 8;
+ t[i] = s / S32_FLT;
+ }
+}
+
+void convert_s24_double_be(data_t* target, data_t* source, int length)
+{
+ double* t = (double*) target;
+ int32_t s;
+ for(int i = length - 1; i >= 0; i--)
+ {
+ s = source[i*3] << 24 | source[i*3+1] << 16 | source[i*3+2] << 8;
+ t[i] = s / S32_FLT;
+ }
+}
+
+void convert_s24_double_le(data_t* target, data_t* source, int length)
+{
+ double* t = (double*) target;
+ int32_t s;
+ for(int i = length - 1; i >= 0; i--)
+ {
+ s = source[i*3+2] << 24 | source[i*3+1] << 16 | source[i*3] << 8;
+ t[i] = s / S32_FLT;
+ }
+}
+
+void convert_s32_u8(data_t* target, data_t* source, int length)
+{
+ int16_t* s = (int16_t*) source;
+ for(int i = 0; i < length; i++)
+ target[i] = (unsigned char)((s[i] >> 24) + U8_0);
+}
+
+void convert_s32_s16(data_t* target, data_t* source, int length)
+{
+ int16_t* t = (int16_t*) target;
+ int32_t* s = (int32_t*) source;
+ for(int i = 0; i < length; i++)
+ t[i] = s[i] >> 16;
+}
+
+void convert_s32_s24_be(data_t* target, data_t* source, int length)
+{
+ int32_t* s = (int32_t*) source;
+ int32_t t;
+ for(int i = 0; i < length; i++)
+ {
+ t = s[i];
+ target[i*3] = t >> 24 & 0xFF;
+ target[i*3+1] = t >> 16 & 0xFF;
+ target[i*3+2] = t >> 8 & 0xFF;
+ }
+}
+
+void convert_s32_s24_le(data_t* target, data_t* source, int length)
+{
+ int32_t* s = (int32_t*) source;
+ int32_t t;
+ for(int i = 0; i < length; i++)
+ {
+ t = s[i];
+ target[i*3+2] = t >> 24 & 0xFF;
+ target[i*3+1] = t >> 16 & 0xFF;
+ target[i*3] = t >> 8 & 0xFF;
+ }
+}
+
+void convert_s32_float(data_t* target, data_t* source, int length)
+{
+ int32_t* s = (int32_t*) source;
+ float* t = (float*) target;
+ for(int i = 0; i < length; i++)
+ t[i] = s[i] / S32_FLT;
+}
+
+void convert_s32_double(data_t* target, data_t* source, int length)
+{
+ int32_t* s = (int32_t*) source;
+ double* t = (double*) target;
+ for(int i = length - 1; i >= 0; i--)
+ t[i] = s[i] / S32_FLT;
+}
+
+void convert_float_u8(data_t* target, data_t* source, int length)
+{
+ float* s = (float*) source;
+ float t;
+ for(int i = 0; i < length; i++)
+ {
+ t = s[i] + FLT_MAX;
+ if(t <= 0.0f)
+ target[i] = 0;
+ else if(t >= 2.0f)
+ target[i] = 255;
+ else
+ target[i] = (unsigned char)(t*127);
+ }
+}
+
+void convert_float_s16(data_t* target, data_t* source, int length)
+{
+ int16_t* t = (int16_t*) target;
+ float* s = (float*) source;
+ for(int i = 0; i < length; i++)
+ {
+ if(s[i] <= FLT_MIN)
+ t[i] = S16_MIN;
+ else if(s[i] >= FLT_MAX)
+ t[i] = S16_MAX;
+ else
+ t[i] = (int16_t)(s[i] * S16_MAX);
+ }
+}
+
+void convert_float_s24_be(data_t* target, data_t* source, int length)
+{
+ int32_t t;
+ float* s = (float*) source;
+ for(int i = 0; i < length; i++)
+ {
+ if(s[i] <= FLT_MIN)
+ t = S32_MIN;
+ else if(s[i] >= FLT_MAX)
+ t = S32_MAX;
+ else
+ t = (int32_t)(s[i]*S32_MAX);
+ target[i*3] = t >> 24 & 0xFF;
+ target[i*3+1] = t >> 16 & 0xFF;
+ target[i*3+2] = t >> 8 & 0xFF;
+ }
+}
+
+void convert_float_s24_le(data_t* target, data_t* source, int length)
+{
+ int32_t t;
+ float* s = (float*) source;
+ for(int i = 0; i < length; i++)
+ {
+ if(s[i] <= FLT_MIN)
+ t = S32_MIN;
+ else if(s[i] >= FLT_MAX)
+ t = S32_MAX;
+ else
+ t = (int32_t)(s[i]*S32_MAX);
+ target[i*3+2] = t >> 24 & 0xFF;
+ target[i*3+1] = t >> 16 & 0xFF;
+ target[i*3] = t >> 8 & 0xFF;
+ }
+}
+
+void convert_float_s32(data_t* target, data_t* source, int length)
+{
+ int32_t* t = (int32_t*) target;
+ float* s = (float*) source;
+ for(int i = 0; i < length; i++)
+ {
+ if(s[i] <= FLT_MIN)
+ t[i] = S32_MIN;
+ else if(s[i] >= FLT_MAX)
+ t[i] = S32_MAX;
+ else
+ t[i] = (int32_t)(s[i]*S32_MAX);
+ }
+}
+
+void convert_float_double(data_t* target, data_t* source, int length)
+{
+ float* s = (float*) source;
+ double* t = (double*) target;
+ for(int i = length - 1; i >= 0; i--)
+ t[i] = s[i];
+}
+
+void convert_double_u8(data_t* target, data_t* source, int length)
+{
+ double* s = (double*) source;
+ double t;
+ for(int i = 0; i < length; i++)
+ {
+ t = s[i] + FLT_MAX;
+ if(t <= 0.0)
+ target[i] = 0;
+ else if(t >= 2.0)
+ target[i] = 255;
+ else
+ target[i] = (unsigned char)(t*127);
+ }
+}
+
+void convert_double_s16(data_t* target, data_t* source, int length)
+{
+ int16_t* t = (int16_t*) target;
+ double* s = (double*) source;
+ for(int i = 0; i < length; i++)
+ {
+ if(s[i] <= FLT_MIN)
+ t[i] = S16_MIN;
+ else if(s[i] >= FLT_MAX)
+ t[i] = S16_MAX;
+ else
+ t[i] = (int16_t)(s[i]*S16_MAX);
+ }
+}
+
+void convert_double_s24_be(data_t* target, data_t* source, int length)
+{
+ int32_t t;
+ double* s = (double*) source;
+ for(int i = 0; i < length; i++)
+ {
+ if(s[i] <= FLT_MIN)
+ t = S32_MIN;
+ else if(s[i] >= FLT_MAX)
+ t = S32_MAX;
+ else
+ t = (int32_t)(s[i]*S32_MAX);
+ target[i*3] = t >> 24 & 0xFF;
+ target[i*3+1] = t >> 16 & 0xFF;
+ target[i*3+2] = t >> 8 & 0xFF;
+ }
+}
+
+void convert_double_s24_le(data_t* target, data_t* source, int length)
+{
+ int32_t t;
+ double* s = (double*) source;
+ for(int i = 0; i < length; i++)
+ {
+ if(s[i] <= FLT_MIN)
+ t = S32_MIN;
+ else if(s[i] >= FLT_MAX)
+ t = S32_MAX;
+ else
+ t = (int32_t)(s[i]*S32_MAX);
+ target[i*3+2] = t >> 24 & 0xFF;
+ target[i*3+1] = t >> 16 & 0xFF;
+ target[i*3] = t >> 8 & 0xFF;
+ }
+}
+
+void convert_double_s32(data_t* target, data_t* source, int length)
+{
+ int32_t* t = (int32_t*) target;
+ double* s = (double*) source;
+ for(int i = 0; i < length; i++)
+ {
+ if(s[i] <= FLT_MIN)
+ t[i] = S32_MIN;
+ else if(s[i] >= FLT_MAX)
+ t[i] = S32_MAX;
+ else
+ t[i] = (int32_t)(s[i]*S32_MAX);
+ }
+}
+
+void convert_double_float(data_t* target, data_t* source, int length)
+{
+ double* s = (double*) source;
+ float* t = (float*) target;
+ for(int i = 0; i < length; i++)
+ t[i] = s[i];
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/respec/ConverterReader.cpp b/extern/audaspace/src/respec/ConverterReader.cpp
new file mode 100644
index 00000000000..88a5e7f225d
--- /dev/null
+++ b/extern/audaspace/src/respec/ConverterReader.cpp
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "respec/ConverterReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+ConverterReader::ConverterReader(std::shared_ptr<IReader> reader,
+ DeviceSpecs specs) :
+ EffectReader(reader),
+ m_format(specs.format)
+{
+ switch(m_format)
+ {
+ case FORMAT_U8:
+ m_convert = convert_float_u8;
+ break;
+ case FORMAT_S16:
+ m_convert = convert_float_s16;
+ break;
+ case FORMAT_S24:
+#ifdef __BIG_ENDIAN__
+ m_convert = convert_float_s24_be;
+#else
+ m_convert = convert_float_s24_le;
+#endif
+ break;
+ case FORMAT_S32:
+ m_convert = convert_float_s32;
+ break;
+ case FORMAT_FLOAT32:
+ m_convert = convert_copy<float>;
+ break;
+ case FORMAT_FLOAT64:
+ m_convert = convert_float_double;
+ break;
+ default:
+ break;
+ }
+}
+
+void ConverterReader::read(int& length, bool& eos, sample_t* buffer)
+{
+ Specs specs = m_reader->getSpecs();
+ int samplesize = AUD_SAMPLE_SIZE(specs);
+
+ m_buffer.assureSize(length * samplesize);
+
+ m_reader->read(length, eos, m_buffer.getBuffer());
+
+ m_convert((data_t*)buffer, (data_t*)m_buffer.getBuffer(),
+ length * specs.channels);
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/respec/JOSResample.cpp b/extern/audaspace/src/respec/JOSResample.cpp
new file mode 100644
index 00000000000..fae116d057a
--- /dev/null
+++ b/extern/audaspace/src/respec/JOSResample.cpp
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "respec/JOSResample.h"
+#include "respec/JOSResampleReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+JOSResample::JOSResample(std::shared_ptr<ISound> sound,
+ DeviceSpecs specs) :
+ SpecsChanger(sound, specs)
+{
+}
+
+std::shared_ptr<IReader> JOSResample::createReader()
+{
+ return std::shared_ptr<IReader>(new JOSResampleReader(getReader(), m_specs.rate));
+}
+
+AUD_NAMESPACE_END
diff --git a/intern/audaspace/intern/AUD_JOSResampleReader.cpp b/extern/audaspace/src/respec/JOSResampleReader.cpp
index 0448c75d777..6753a2e8b6b 100644
--- a/intern/audaspace/intern/AUD_JOSResampleReader.cpp
+++ b/extern/audaspace/src/respec/JOSResampleReader.cpp
@@ -1,68 +1,26 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
*
- * Copyright 2009-2011 Jörg Hermann Müller
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * This file is part of AudaSpace.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * 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_JOSResampleReader.cpp
- * \ingroup audaspaceintern
- */
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
-#include "AUD_JOSResampleReader.h"
-
-#include "AUD_JOSResampleReaderCoeff.cpp"
+#include "respec/JOSResampleReader.h"
+#include <algorithm>
#include <cmath>
#include <cstring>
-#include <iostream>
-
-/* MSVC does not have lrint */
-#ifdef _MSC_VER
-#if _MSC_VER < 1800
-#ifdef _M_X64
-#include <emmintrin.h>
-static inline int lrint(double d)
-{
- return _mm_cvtsd_si32(_mm_load_sd(&d));
-}
-#else
-static inline int lrint(double d)
-{
- int i;
-
- _asm{
- fld d
- fistp i
- };
-
- return i;
-}
-#endif
-#endif
-#endif
-// UNUSED
-// #define CC m_channels + channel
-
-#define AUD_RATE_MAX 256
+#define RATE_MAX 256
#define SHIFT_BITS 12
#define double_to_fp(x) (lrint(x * double(1 << SHIFT_BITS)))
#define int_to_fp(x) (x << SHIFT_BITS)
@@ -71,9 +29,11 @@ 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(boost::shared_ptr<AUD_IReader> reader, AUD_Specs specs) :
- AUD_ResampleReader(reader, specs.rate),
- m_channels(AUD_CHANNELS_INVALID),
+AUD_NAMESPACE_BEGIN
+
+JOSResampleReader::JOSResampleReader(std::shared_ptr<IReader> reader, SampleRate rate) :
+ ResampleReader(reader, rate),
+ m_channels(CHANNELS_INVALID),
m_n(0),
m_P(0),
m_cache_valid(0),
@@ -81,7 +41,7 @@ AUD_JOSResampleReader::AUD_JOSResampleReader(boost::shared_ptr<AUD_IReader> read
{
}
-void AUD_JOSResampleReader::reset()
+void JOSResampleReader::reset()
{
m_cache_valid = 0;
m_n = 0;
@@ -89,25 +49,25 @@ void AUD_JOSResampleReader::reset()
m_last_factor = 0;
}
-void AUD_JOSResampleReader::updateBuffer(int size, double factor, int samplesize)
+void JOSResampleReader::updateBuffer(int size, double factor, int samplesize)
{
unsigned int len;
double num_samples = double(m_len) / double(m_L);
// first calculate what length we need right now
if(factor >= 1)
- len = ceil(num_samples);
+ len = std::ceil(num_samples);
else
- len = (unsigned int)(ceil(num_samples / factor));
+ len = (unsigned int)(std::ceil(num_samples / factor));
// then check if afterwards the length is enough for the maximum rate
- if(len + size < num_samples * AUD_RATE_MAX)
- len = num_samples * AUD_RATE_MAX - size;
+ if(len + size < num_samples * RATE_MAX)
+ len = num_samples * RATE_MAX - size;
if(m_n > len)
{
sample_t* buf = m_buffer.getBuffer();
len = m_n - len;
- memmove(buf, buf + len * m_channels, (m_cache_valid - len) * samplesize);
+ std::memmove(buf, buf + len * m_channels, (m_cache_valid - len) * samplesize);
m_n -= len;
m_cache_valid -= len;
}
@@ -115,7 +75,7 @@ void AUD_JOSResampleReader::updateBuffer(int size, double factor, int samplesize
m_buffer.assureSize((m_cache_valid + size) * samplesize, true);
}
-#define RESAMPLE_METHOD(name, left, right) void AUD_JOSResampleReader::name(double target_factor, int length, sample_t* buffer)\
+#define RESAMPLE_METHOD(name, left, right) void JOSResampleReader::name(double target_factor, int length, sample_t* buffer)\
{\
sample_t* buf = m_buffer.getBuffer();\
\
@@ -134,13 +94,13 @@ void AUD_JOSResampleReader::updateBuffer(int size, double factor, int samplesize
{\
factor = (m_last_factor * (length - t - 1) + target_factor * (t + 1)) / length;\
\
- memset(sums, 0, sizeof(double) * m_channels);\
+ std::memset(sums, 0, sizeof(double) * m_channels);\
\
if(factor >= 1)\
{\
P = double_to_fp(m_P * m_L);\
\
- end = floor(m_len / double(m_L) - m_P) - 1;\
+ end = std::floor(m_len / double(m_L) - m_P) - 1;\
if(m_n < end)\
end = m_n;\
\
@@ -158,7 +118,7 @@ void AUD_JOSResampleReader::updateBuffer(int size, double factor, int samplesize
\
P = int_to_fp(m_L) - P;\
\
- end = floor((m_len - 1) / double(m_L) + m_P) - 1;\
+ end = std::floor((m_len - 1) / double(m_L) + m_P) - 1;\
if(m_cache_valid - m_n - 2 < end)\
end = m_cache_valid - m_n - 2;\
\
@@ -224,13 +184,13 @@ void AUD_JOSResampleReader::updateBuffer(int size, double factor, int samplesize
\
for(channel = 0; channel < m_channels; channel++)\
{\
- *buffer = factor * sums[channel];\
+ *buffer = factor * sums[channel];\
buffer++;\
}\
}\
\
- m_P += fmod(1.0 / factor, 1.0);\
- m_n += floor(1.0 / factor);\
+ m_P += std::fmod(1.0 / factor, 1.0);\
+ m_n += std::floor(1.0 / factor);\
\
while(m_P >= 1.0)\
{\
@@ -278,37 +238,36 @@ RESAMPLE_METHOD(resample_stereo, {
sums[1] += data[2] * v;
})
-void AUD_JOSResampleReader::seek(int position)
+void JOSResampleReader::seek(int position)
{
- position = floor(position * double(m_reader->getSpecs().rate) / double(m_rate));
+ position = std::floor(position * double(m_reader->getSpecs().rate) / double(m_rate));
m_reader->seek(position);
reset();
}
-int AUD_JOSResampleReader::getLength() const
+int JOSResampleReader::getLength() const
{
- return floor(m_reader->getLength() * double(m_rate) / double(m_reader->getSpecs().rate));
+ return std::floor(m_reader->getLength() * double(m_rate) / double(m_reader->getSpecs().rate));
}
-int AUD_JOSResampleReader::getPosition() const
+int JOSResampleReader::getPosition() const
{
- return floor((m_reader->getPosition() + double(m_P))
- * m_rate / m_reader->getSpecs().rate);
+ return std::floor((m_reader->getPosition() + double(m_P)) * m_rate / m_reader->getSpecs().rate);
}
-AUD_Specs AUD_JOSResampleReader::getSpecs() const
+Specs JOSResampleReader::getSpecs() const
{
- AUD_Specs specs = m_reader->getSpecs();
+ Specs specs = m_reader->getSpecs();
specs.rate = m_rate;
return specs;
}
-void AUD_JOSResampleReader::read(int& length, bool& eos, sample_t* buffer)
+void JOSResampleReader::read(int& length, bool& eos, sample_t* buffer)
{
if(length == 0)
return;
- AUD_Specs specs = m_reader->getSpecs();
+ Specs specs = m_reader->getSpecs();
int samplesize = AUD_SAMPLE_SIZE(specs);
double target_factor = double(m_rate) / double(specs.rate);
@@ -324,14 +283,14 @@ void AUD_JOSResampleReader::read(int& length, bool& eos, sample_t* buffer)
switch(m_channels)
{
- case AUD_CHANNELS_MONO:
- m_resample = &AUD_JOSResampleReader::resample_mono;
+ case CHANNELS_MONO:
+ m_resample = &JOSResampleReader::resample_mono;
break;
- case AUD_CHANNELS_STEREO:
- m_resample = &AUD_JOSResampleReader::resample_stereo;
+ case CHANNELS_STEREO:
+ m_resample = &JOSResampleReader::resample_stereo;
break;
default:
- m_resample = &AUD_JOSResampleReader::resample;
+ m_resample = &JOSResampleReader::resample;
break;
}
}
@@ -355,7 +314,7 @@ void AUD_JOSResampleReader::read(int& length, bool& eos, sample_t* buffer)
if(length > 0)
{
- memcpy(buffer, buf + m_n * m_channels, length * samplesize);
+ std::memcpy(buffer, buf + m_n * m_channels, length * samplesize);
m_n += length;
}
@@ -363,12 +322,12 @@ void AUD_JOSResampleReader::read(int& length, bool& eos, sample_t* buffer)
}
// use minimum for the following calculations
- double factor = AUD_MIN(target_factor, m_last_factor);
+ double factor = std::min(target_factor, m_last_factor);
if(factor >= 1)
- len = (int(m_n) - m_cache_valid) + int(ceil(length / factor)) + ceil(num_samples);
+ len = (int(m_n) - m_cache_valid) + int(std::ceil(length / factor)) + std::ceil(num_samples);
else
- len = (int(m_n) - m_cache_valid) + int(ceil(length / factor) + ceil(num_samples / factor));
+ len = (int(m_n) - m_cache_valid) + int(std::ceil(length / factor) + std::ceil(num_samples / factor));
if(len > 0)
{
@@ -386,22 +345,22 @@ void AUD_JOSResampleReader::read(int& length, bool& eos, sample_t* buffer)
else
{
// use maximum for the following calculations
- factor = AUD_MAX(target_factor, m_last_factor);
+ factor = std::max(target_factor, m_last_factor);
if(eos)
{
// end of stream, let's check how many more samples we can produce
- len = floor((m_cache_valid - m_n) * factor);
+ len = std::floor((m_cache_valid - m_n) * factor);
if(len < length)
length = len;
}
else
{
- // not enough data available yet, so we recalculate how many samples we can calculate
+ // not enough data available yet, so we recalculate how many samples we can calculate
if(factor >= 1)
- len = floor((num_samples + m_cache_valid - m_n) * factor);
+ len = std::floor((num_samples + m_cache_valid - m_n) * factor);
else
- len = floor((num_samples * factor + m_cache_valid - m_n) * factor);
+ len = std::floor((num_samples * factor + m_cache_valid - m_n) * factor);
if(len < length)
length = len;
}
@@ -420,3 +379,5 @@ void AUD_JOSResampleReader::read(int& length, bool& eos, sample_t* buffer)
eos = eos && ((m_n == m_cache_valid) || (length == 0));
}
+
+AUD_NAMESPACE_END
diff --git a/intern/audaspace/intern/AUD_JOSResampleReaderCoeff.cpp b/extern/audaspace/src/respec/JOSResampleReaderCoeff.cpp
index f8fefd5b88f..133e081f4a7 100644
--- a/intern/audaspace/intern/AUD_JOSResampleReaderCoeff.cpp
+++ b/extern/audaspace/src/respec/JOSResampleReaderCoeff.cpp
@@ -1,39 +1,29 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
*
- * Copyright 2009-2011 Jörg Hermann Müller
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * This file is part of AudaSpace.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * 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 *****
- */
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
-/** \file audaspace/intern/AUD_JOSResampleReaderCoeff.cpp
- * \ingroup audaspaceintern
- */
-
-#include "AUD_JOSResampleReader.h"
+#include "respec/JOSResampleReader.h"
// sinc filter coefficients, Nz = 136, L = 2304, freq = 0.963904, Kaiser Window B = 16
-const int AUD_JOSResampleReader::m_len = 325078;
-const int AUD_JOSResampleReader::m_L = 2304;
+AUD_NAMESPACE_BEGIN
+
+const int JOSResampleReader::m_len = 325078;
+const int JOSResampleReader::m_L = 2304;
-const float AUD_JOSResampleReader::m_coeff[] = {
+const float JOSResampleReader::m_coeff[] = {
9.639035268e-01f, 9.639032492e-01f, 9.639024165e-01f, 9.639010286e-01f, 9.638990855e-01f, 9.638965872e-01f, 9.638935338e-01f, 9.638899253e-01f, 9.638857615e-01f, 9.638810427e-01f,
9.638757686e-01f, 9.638699395e-01f, 9.638635552e-01f, 9.638566158e-01f, 9.638491212e-01f, 9.638410716e-01f, 9.638324668e-01f, 9.638233070e-01f, 9.638135921e-01f, 9.638033220e-01f,
9.637924970e-01f, 9.637811168e-01f, 9.637691817e-01f, 9.637566915e-01f, 9.637436463e-01f, 9.637300461e-01f, 9.637158908e-01f, 9.637011807e-01f, 9.636859155e-01f, 9.636700955e-01f,
@@ -32543,3 +32533,5 @@ const float AUD_JOSResampleReader::m_coeff[] = {
-6.072286860e-11f, -5.735986806e-11f, -5.399941461e-11f, -5.064151335e-11f, -4.728616936e-11f, -4.393338771e-11f, -4.058317348e-11f, -3.723553173e-11f, -3.389046751e-11f, -3.054798585e-11f,
-2.720809180e-11f, -2.387079037e-11f, -2.053608658e-11f, -1.720398544e-11f, -1.387449194e-11f, -1.054761107e-11f, -7.223347816e-12f, -3.901707142e-12f, -3.901707142e-12f
};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/respec/LinearResample.cpp b/extern/audaspace/src/respec/LinearResample.cpp
new file mode 100644
index 00000000000..bcdc3409771
--- /dev/null
+++ b/extern/audaspace/src/respec/LinearResample.cpp
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "respec/LinearResample.h"
+#include "respec/LinearResampleReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+LinearResample::LinearResample(std::shared_ptr<ISound> sound, DeviceSpecs specs) :
+ SpecsChanger(sound, specs)
+{
+}
+
+std::shared_ptr<IReader> LinearResample::createReader()
+{
+ return std::shared_ptr<IReader>(new LinearResampleReader(getReader(), m_specs.rate));
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/respec/LinearResampleReader.cpp b/extern/audaspace/src/respec/LinearResampleReader.cpp
new file mode 100644
index 00000000000..53d506115ce
--- /dev/null
+++ b/extern/audaspace/src/respec/LinearResampleReader.cpp
@@ -0,0 +1,174 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "respec/LinearResampleReader.h"
+
+#include <cmath>
+#include <cstring>
+
+AUD_NAMESPACE_BEGIN
+
+LinearResampleReader::LinearResampleReader(std::shared_ptr<IReader> reader, SampleRate rate) :
+ ResampleReader(reader, rate),
+ m_channels(reader->getSpecs().channels),
+ m_cache_pos(0),
+ m_cache_ok(false)
+{
+ Specs specs = { rate, m_channels };
+ m_cache.resize(2 * AUD_SAMPLE_SIZE(specs));
+}
+
+void LinearResampleReader::seek(int position)
+{
+ position = std::floor(position * double(m_reader->getSpecs().rate) / double(m_rate));
+ m_reader->seek(position);
+ m_cache_ok = false;
+ m_cache_pos = 0;
+}
+
+int LinearResampleReader::getLength() const
+{
+ return std::floor(m_reader->getLength() * double(m_rate) / double(m_reader->getSpecs().rate));
+}
+
+int LinearResampleReader::getPosition() const
+{
+ return std::floor((m_reader->getPosition() + (m_cache_ok ? m_cache_pos - 1 : 0))
+ * m_rate / m_reader->getSpecs().rate);
+}
+
+Specs LinearResampleReader::getSpecs() const
+{
+ Specs specs = m_reader->getSpecs();
+ specs.rate = m_rate;
+ return specs;
+}
+
+void LinearResampleReader::read(int& length, bool& eos, sample_t* buffer)
+{
+ if(length == 0)
+ return;
+
+ Specs specs = m_reader->getSpecs();
+
+ int samplesize = AUD_SAMPLE_SIZE(specs);
+ int size = length;
+ float factor = m_rate / m_reader->getSpecs().rate;
+ float spos = 0.0f;
+ sample_t low, high;
+ eos = false;
+
+ // check for channels changed
+
+ if(specs.channels != m_channels)
+ {
+ m_cache.resize(2 * samplesize);
+ m_channels = specs.channels;
+ m_cache_ok = false;
+ }
+
+ if(factor == 1 && (!m_cache_ok || m_cache_pos == 1))
+ {
+ // can read directly!
+ m_reader->read(length, eos, buffer);
+
+ if(length > 0)
+ {
+ std::memcpy(m_cache.getBuffer() + m_channels, buffer + m_channels * (length - 1), samplesize);
+ m_cache_pos = 1;
+ m_cache_ok = true;
+ }
+
+ return;
+ }
+
+ int len;
+ sample_t* buf;
+
+ if(m_cache_ok)
+ {
+ int need = std::ceil(length / factor + m_cache_pos) - 1;
+
+ len = need;
+
+ m_buffer.assureSize((len + 2) * samplesize);
+ buf = m_buffer.getBuffer();
+
+ std::memcpy(buf, m_cache.getBuffer(), 2 * samplesize);
+ m_reader->read(len, eos, buf + 2 * m_channels);
+
+ if(len < need)
+ length = std::floor((len + 1 - m_cache_pos) * factor);
+ }
+ else
+ {
+ m_cache_pos = 1 - 1 / factor;
+
+ int need = std::ceil(length / factor + m_cache_pos);
+
+ len = need;
+
+ m_buffer.assureSize((len + 1) * samplesize);
+ buf = m_buffer.getBuffer();
+
+ std::memset(buf, 0, samplesize);
+ m_reader->read(len, eos, buf + m_channels);
+
+ if(len == 0)
+ {
+ length = 0;
+ return;
+ }
+
+ if(len < need)
+ {
+ length = std::floor((len - m_cache_pos) * factor);
+ }
+
+ m_cache_ok = true;
+ }
+
+ if(length == 0)
+ return;
+
+ for(int channel = 0; channel < m_channels; channel++)
+ {
+ for(int i = 0; i < length; i++)
+ {
+ spos = (i + 1) / factor + m_cache_pos;
+
+ low = buf[(int)std::floor(spos) * m_channels + channel];
+ high = buf[(int)std::ceil(spos) * m_channels + channel];
+
+ buffer[i * m_channels + channel] = low + (spos - std::floor(spos)) * (high - low);
+ }
+ }
+
+ if(std::floor(spos) == spos)
+ {
+ std::memcpy(m_cache.getBuffer() + m_channels, buf + int(std::floor(spos)) * m_channels, samplesize);
+ m_cache_pos = 1;
+ }
+ else
+ {
+ std::memcpy(m_cache.getBuffer(), buf + int(std::floor(spos)) * m_channels, 2 * samplesize);
+ m_cache_pos = spos - std::floor(spos);
+ }
+
+ eos &= length < size;
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/respec/Mixer.cpp b/extern/audaspace/src/respec/Mixer.cpp
new file mode 100644
index 00000000000..d63f0bab2bb
--- /dev/null
+++ b/extern/audaspace/src/respec/Mixer.cpp
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "respec/Mixer.h"
+
+#include <algorithm>
+#include <cstring>
+
+AUD_NAMESPACE_BEGIN
+
+Mixer::Mixer(DeviceSpecs specs) :
+ m_specs(specs)
+{
+ switch(m_specs.format)
+ {
+ case FORMAT_U8:
+ m_convert = convert_float_u8;
+ break;
+ case FORMAT_S16:
+ m_convert = convert_float_s16;
+ break;
+ case FORMAT_S24:
+
+#ifdef __BIG_ENDIAN__
+ m_convert = convert_float_s24_be;
+#else
+ m_convert = convert_float_s24_le;
+#endif
+ break;
+ case FORMAT_S32:
+ m_convert = convert_float_s32;
+ break;
+ case FORMAT_FLOAT32:
+ m_convert = convert_copy<float>;
+ break;
+ case FORMAT_FLOAT64:
+ m_convert = convert_float_double;
+ break;
+ default:
+ break;
+ }
+}
+
+DeviceSpecs Mixer::getSpecs() const
+{
+ return m_specs;
+}
+
+void Mixer::setSpecs(Specs specs)
+{
+ m_specs.specs = specs;
+}
+
+void Mixer::clear(int length)
+{
+ m_buffer.assureSize(length * m_specs.channels * AUD_SAMPLE_SIZE(m_specs));
+
+ m_length = length;
+
+ std::memset(m_buffer.getBuffer(), 0, length * m_specs.channels * AUD_SAMPLE_SIZE(m_specs));
+}
+
+void Mixer::mix(sample_t* buffer, int start, int length, float volume)
+{
+ sample_t* out = m_buffer.getBuffer();
+
+ length = (std::min(m_length, length + start) - start) * m_specs.channels;
+ start *= m_specs.channels;
+
+ for(int i = 0; i < length; i++)
+ out[i + start] += buffer[i] * volume;
+}
+
+void Mixer::mix(sample_t* buffer, int start, int length, float volume_to, float volume_from)
+{
+ sample_t* out = m_buffer.getBuffer();
+
+ length = (std::min(m_length, length + start) - start);
+
+ for(int i = 0; i < length; i++)
+ {
+ float volume = volume_from * (1.0f - i / float(length)) + volume_to * (i / float(length));
+
+ for(int c = 0; c < m_specs.channels; c++)
+ out[(i + start) * m_specs.channels + c] += buffer[i * m_specs.channels + c] * volume;
+ }
+}
+
+void Mixer::read(data_t* buffer, float volume)
+{
+ sample_t* out = m_buffer.getBuffer();
+
+ for(int i = 0; i < m_length * m_specs.channels; i++)
+ out[i] *= volume;
+
+ m_convert(buffer, (data_t*) out, m_length * m_specs.channels);
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/respec/ResampleReader.cpp b/extern/audaspace/src/respec/ResampleReader.cpp
new file mode 100644
index 00000000000..d7f5bff3a51
--- /dev/null
+++ b/extern/audaspace/src/respec/ResampleReader.cpp
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "respec/ResampleReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+ResampleReader::ResampleReader(std::shared_ptr<IReader> reader, SampleRate rate) :
+ EffectReader(reader), m_rate(rate)
+{
+}
+
+void ResampleReader::setRate(SampleRate rate)
+{
+ m_rate = rate;
+}
+
+SampleRate ResampleReader::getRate()
+{
+ return m_rate;
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/respec/SpecsChanger.cpp b/extern/audaspace/src/respec/SpecsChanger.cpp
new file mode 100644
index 00000000000..146d9789160
--- /dev/null
+++ b/extern/audaspace/src/respec/SpecsChanger.cpp
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "respec/SpecsChanger.h"
+
+AUD_NAMESPACE_BEGIN
+
+std::shared_ptr<IReader> SpecsChanger::getReader() const
+{
+ return m_sound->createReader();
+}
+
+SpecsChanger::SpecsChanger(std::shared_ptr<ISound> sound,
+ DeviceSpecs specs) :
+ m_specs(specs), m_sound(sound)
+{
+}
+
+DeviceSpecs SpecsChanger::getSpecs() const
+{
+ return m_specs;
+}
+
+std::shared_ptr<ISound> SpecsChanger::getSound() const
+{
+ return m_sound;
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/sequence/AnimateableProperty.cpp b/extern/audaspace/src/sequence/AnimateableProperty.cpp
new file mode 100644
index 00000000000..306ba8e07f5
--- /dev/null
+++ b/extern/audaspace/src/sequence/AnimateableProperty.cpp
@@ -0,0 +1,217 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "sequence/AnimateableProperty.h"
+
+#include <cstring>
+#include <cmath>
+#include <mutex>
+
+AUD_NAMESPACE_BEGIN
+
+AnimateableProperty::AnimateableProperty(int count) :
+ Buffer(count * sizeof(float)), m_count(count), m_isAnimated(false)
+{
+ std::memset(getBuffer(), 0, count * sizeof(float));
+}
+
+AnimateableProperty::AnimateableProperty(int count, float value) :
+ Buffer(count * sizeof(float)), m_count(count), m_isAnimated(false)
+{
+ sample_t* buf = getBuffer();
+
+ for(int i = 0; i < count; i++)
+ buf[i] = value;
+}
+
+void AnimateableProperty::updateUnknownCache(int start, int end)
+{
+ float* buf = getBuffer();
+
+ // we could do a better interpolation than zero order, but that doesn't work with Blender's animation system
+ // as frames are only written when changing, so to support jumps, we need zero order interpolation here.
+ for(int i = start; i <= end; i++)
+ std::memcpy(buf + i * m_count, buf + (start - 1) * m_count, m_count * sizeof(float));
+}
+
+AnimateableProperty::~AnimateableProperty()
+{
+}
+
+int AnimateableProperty::getCount() const
+{
+ return m_count;
+}
+
+void AnimateableProperty::write(const float* data)
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ m_isAnimated = false;
+ m_unknown.clear();
+ std::memcpy(getBuffer(), data, m_count * sizeof(float));
+}
+
+void AnimateableProperty::write(const float* data, int position, int count)
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ int pos = getSize() / (sizeof(float) * m_count);
+
+ if(!m_isAnimated)
+ pos = 0;
+
+ m_isAnimated = true;
+
+ assureSize((count + position) * m_count * sizeof(float), true);
+
+ float* buf = getBuffer();
+
+ std::memcpy(buf + position * m_count, data, count * m_count * sizeof(float));
+
+ // have to fill up space between?
+ if(pos < position)
+ {
+ m_unknown.push_back(Unknown(pos, position - 1));
+
+ // if the buffer was not animated before, we copy the previous static value
+ if(pos == 0)
+ pos = 1;
+
+ updateUnknownCache(pos, position - 1);
+ }
+ // otherwise it's not at the end, let's check if some unknown part got filled
+ else
+ {
+ bool erased = false;
+
+ for(auto it = m_unknown.begin(); it != m_unknown.end(); erased ? it : it++)
+ {
+ erased = false;
+
+ // unknown area before position
+ if(it->end < position)
+ continue;
+
+ // we're after the new area, let's stop
+ if(it->start >= position + count)
+ break;
+
+ // we have an intersection, now 4 cases:
+ // the start is included
+ if(position <= it->start)
+ {
+ // the end is included
+ if(position + count > it->end)
+ {
+ // simply delete
+ it = m_unknown.erase(it);
+ erased = true;
+ }
+ // the end is excluded, a second part remains
+ else
+ {
+ // update second part
+ it->start = position + count;
+ updateUnknownCache(it->start, it->end);
+ break;
+ }
+ }
+ // start is excluded, a first part remains
+ else
+ {
+ // the end is included
+ if(position + count > it->end)
+ {
+ // update first part
+ it->end = position - 1;
+ }
+ // the end is excluded, a second part remains
+ else
+ {
+ // add another item and update both parts
+ m_unknown.insert(it, Unknown(it->start, position - 1));
+ it->start = position + count;
+ updateUnknownCache(it->start, it->end);
+ }
+ }
+ }
+ }
+}
+
+void AnimateableProperty::read(float position, float* out)
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ if(!m_isAnimated)
+ {
+ std::memcpy(out, getBuffer(), m_count * sizeof(float));
+ return;
+ }
+
+ int last = getSize() / (sizeof(float) * m_count) - 1;
+ float t = position - std::floor(position);
+
+ if(position >= last)
+ {
+ position = last;
+ t = 0;
+ }
+
+ if(t == 0)
+ {
+ std::memcpy(out, getBuffer() + int(std::floor(position)) * m_count, m_count * sizeof(float));
+ }
+ else
+ {
+ int pos = int(std::floor(position)) * m_count;
+ float t2 = t * t;
+ float t3 = t2 * t;
+ float m0, m1;
+ float* p0;
+ float* p1 = getBuffer() + pos;
+ float* p2;
+ float* p3;
+ last *= m_count;
+
+ if(pos == 0)
+ p0 = p1;
+ else
+ p0 = p1 - m_count;
+
+ p2 = p1 + m_count;
+ if(pos + m_count == last)
+ p3 = p2;
+ else
+ p3 = p2 + m_count;
+
+ for(int i = 0; i < m_count; i++)
+ {
+ m0 = (p2[i] - p0[i]) / 2.0f;
+ m1 = (p3[i] - p1[i]) / 2.0f;
+
+ out[i] = (2 * t3 - 3 * t2 + 1) * p0[i] + (-2 * t3 + 3 * t2) * p1[i] +
+ (t3 - 2 * t2 + t) * m0 + (t3 - t2) * m1;
+ }
+ }
+}
+
+bool AnimateableProperty::isAnimated() const
+{
+ return m_isAnimated;
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/sequence/Double.cpp b/extern/audaspace/src/sequence/Double.cpp
new file mode 100644
index 00000000000..1086be84a11
--- /dev/null
+++ b/extern/audaspace/src/sequence/Double.cpp
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "sequence/Double.h"
+#include "sequence/DoubleReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+Double::Double(std::shared_ptr<ISound> sound1, std::shared_ptr<ISound> sound2) :
+ m_sound1(sound1), m_sound2(sound2)
+{
+}
+
+std::shared_ptr<IReader> Double::createReader()
+{
+ std::shared_ptr<IReader> reader1 = m_sound1->createReader();
+ std::shared_ptr<IReader> reader2 = m_sound2->createReader();
+
+ return std::shared_ptr<IReader>(new DoubleReader(reader1, reader2));
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/sequence/DoubleReader.cpp b/extern/audaspace/src/sequence/DoubleReader.cpp
new file mode 100644
index 00000000000..33ab34ce366
--- /dev/null
+++ b/extern/audaspace/src/sequence/DoubleReader.cpp
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "sequence/DoubleReader.h"
+
+#include <cstring>
+
+AUD_NAMESPACE_BEGIN
+
+DoubleReader::DoubleReader(std::shared_ptr<IReader> reader1, std::shared_ptr<IReader> reader2) :
+ m_reader1(reader1), m_reader2(reader2), m_finished1(false)
+{
+ Specs s1, s2;
+ s1 = reader1->getSpecs();
+ s2 = reader2->getSpecs();
+}
+
+DoubleReader::~DoubleReader()
+{
+}
+
+bool DoubleReader::isSeekable() const
+{
+ return m_reader1->isSeekable() && m_reader2->isSeekable();
+}
+
+void DoubleReader::seek(int position)
+{
+ m_reader1->seek(position);
+
+ int pos1 = m_reader1->getPosition();
+
+ if((m_finished1 = (pos1 < position)))
+ m_reader2->seek(position - pos1);
+ else
+ m_reader2->seek(0);
+}
+
+int DoubleReader::getLength() const
+{
+ int len1 = m_reader1->getLength();
+ int len2 = m_reader2->getLength();
+ if(len1 < 0 || len2 < 0)
+ return -1;
+ return len1 + len2;
+}
+
+int DoubleReader::getPosition() const
+{
+ return m_reader1->getPosition() + m_reader2->getPosition();
+}
+
+Specs DoubleReader::getSpecs() const
+{
+ return m_finished1 ? m_reader1->getSpecs() : m_reader2->getSpecs();
+}
+
+void DoubleReader::read(int& length, bool& eos, sample_t* buffer)
+{
+ eos = false;
+
+ if(!m_finished1)
+ {
+ int len = length;
+
+ m_reader1->read(len, m_finished1, buffer);
+
+ if(len < length)
+ {
+ Specs specs1, specs2;
+ specs1 = m_reader1->getSpecs();
+ specs2 = m_reader2->getSpecs();
+ if(AUD_COMPARE_SPECS(specs1, specs2))
+ {
+ int len2 = length - len;
+ m_reader2->read(len2, eos, buffer + specs1.channels * len);
+ length = len + len2;
+ }
+ else
+ length = len;
+ }
+ }
+ else
+ {
+ m_reader2->read(length, eos, buffer);
+ }
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/sequence/PingPong.cpp b/extern/audaspace/src/sequence/PingPong.cpp
new file mode 100644
index 00000000000..19bfb10fc2d
--- /dev/null
+++ b/extern/audaspace/src/sequence/PingPong.cpp
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "sequence/PingPong.h"
+#include "sequence/DoubleReader.h"
+#include "fx/ReverseReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+PingPong::PingPong(std::shared_ptr<ISound> sound) :
+ Effect(sound)
+{
+}
+
+std::shared_ptr<IReader> PingPong::createReader()
+{
+ std::shared_ptr<IReader> reader = getReader();
+ std::shared_ptr<IReader> reader2 = std::shared_ptr<IReader>(new ReverseReader(getReader()));
+
+ return std::shared_ptr<IReader>(new DoubleReader(reader, reader2));
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/sequence/Sequence.cpp b/extern/audaspace/src/sequence/Sequence.cpp
new file mode 100644
index 00000000000..eaec4d84ae1
--- /dev/null
+++ b/extern/audaspace/src/sequence/Sequence.cpp
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "sequence/Sequence.h"
+#include "sequence/SequenceReader.h"
+#include "sequence/SequenceData.h"
+
+AUD_NAMESPACE_BEGIN
+
+Sequence::Sequence(Specs specs, float fps, bool muted)
+{
+ m_sequence = std::shared_ptr<SequenceData>(new SequenceData(specs, fps, muted));
+}
+
+Specs Sequence::getSpecs()
+{
+ return m_sequence->getSpecs();
+}
+
+void Sequence::setSpecs(Specs specs)
+{
+ m_sequence->setSpecs(specs);
+}
+
+float Sequence::getFPS() const
+{
+ return m_sequence->getFPS();
+}
+
+void Sequence::setFPS(float fps)
+{
+ m_sequence->setFPS(fps);
+}
+
+void Sequence::mute(bool muted)
+{
+ m_sequence->mute(muted);
+}
+
+bool Sequence::isMuted() const
+{
+ return m_sequence->isMuted();
+}
+
+float Sequence::getSpeedOfSound() const
+{
+ return m_sequence->getSpeedOfSound();
+}
+
+void Sequence::setSpeedOfSound(float speed)
+{
+ m_sequence->setSpeedOfSound(speed);
+}
+
+float Sequence::getDopplerFactor() const
+{
+ return m_sequence->getDopplerFactor();
+}
+
+void Sequence::setDopplerFactor(float factor)
+{
+ m_sequence->setDopplerFactor(factor);
+}
+
+DistanceModel Sequence::getDistanceModel() const
+{
+ return m_sequence->getDistanceModel();
+}
+
+void Sequence::setDistanceModel(DistanceModel model)
+{
+ m_sequence->setDistanceModel(model);
+}
+
+AnimateableProperty* Sequence::getAnimProperty(AnimateablePropertyType type)
+{
+ return m_sequence->getAnimProperty(type);
+}
+
+std::shared_ptr<SequenceEntry> Sequence::add(std::shared_ptr<ISound> sound, float begin, float end, float skip)
+{
+ return m_sequence->add(sound, begin, end, skip);
+}
+
+void Sequence::remove(std::shared_ptr<SequenceEntry> entry)
+{
+ m_sequence->remove(entry);
+}
+
+std::shared_ptr<IReader> Sequence::createQualityReader()
+{
+ return std::shared_ptr<IReader>(new SequenceReader(m_sequence, true));
+}
+
+std::shared_ptr<IReader> Sequence::createReader()
+{
+ return std::shared_ptr<IReader>(new SequenceReader(m_sequence));
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/sequence/SequenceData.cpp b/extern/audaspace/src/sequence/SequenceData.cpp
new file mode 100644
index 00000000000..fb920acc1a8
--- /dev/null
+++ b/extern/audaspace/src/sequence/SequenceData.cpp
@@ -0,0 +1,172 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "sequence/SequenceData.h"
+#include "sequence/SequenceReader.h"
+#include "sequence/SequenceEntry.h"
+
+#include <mutex>
+
+AUD_NAMESPACE_BEGIN
+
+SequenceData::SequenceData(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(343.3f),
+ m_doppler_factor(1),
+ m_distance_model(DISTANCE_MODEL_INVERSE_CLAMPED),
+ m_volume(1, 1.0f),
+ m_location(3),
+ m_orientation(4)
+{
+ Quaternion q;
+ m_orientation.write(q.get());
+ float f = 1;
+ m_volume.write(&f);
+}
+
+SequenceData::~SequenceData()
+{
+}
+
+void SequenceData::lock()
+{
+ m_mutex.lock();
+}
+
+void SequenceData::unlock()
+{
+ m_mutex.unlock();
+}
+
+Specs SequenceData::getSpecs()
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ return m_specs;
+}
+
+void SequenceData::setSpecs(Specs specs)
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ m_specs = specs;
+ m_status++;
+}
+
+float SequenceData::getFPS() const
+{
+ return m_fps;
+}
+
+void SequenceData::setFPS(float fps)
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ m_fps = fps;
+}
+
+void SequenceData::mute(bool muted)
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ m_muted = muted;
+}
+
+bool SequenceData::isMuted() const
+{
+ return m_muted;
+}
+
+float SequenceData::getSpeedOfSound() const
+{
+ return m_speed_of_sound;
+}
+
+void SequenceData::setSpeedOfSound(float speed)
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ m_speed_of_sound = speed;
+ m_status++;
+}
+
+float SequenceData::getDopplerFactor() const
+{
+ return m_doppler_factor;
+}
+
+void SequenceData::setDopplerFactor(float factor)
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ m_doppler_factor = factor;
+ m_status++;
+}
+
+DistanceModel SequenceData::getDistanceModel() const
+{
+ return m_distance_model;
+}
+
+void SequenceData::setDistanceModel(DistanceModel model)
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ m_distance_model = model;
+ m_status++;
+}
+
+AnimateableProperty* SequenceData::getAnimProperty(AnimateablePropertyType type)
+{
+ switch(type)
+ {
+ case AP_VOLUME:
+ return &m_volume;
+ case AP_LOCATION:
+ return &m_location;
+ case AP_ORIENTATION:
+ return &m_orientation;
+ default:
+ return nullptr;
+ }
+}
+
+std::shared_ptr<SequenceEntry> SequenceData::add(std::shared_ptr<ISound> sound, float begin, float end, float skip)
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ std::shared_ptr<SequenceEntry> entry = std::shared_ptr<SequenceEntry>(new SequenceEntry(sound, begin, end, skip, m_id++));
+
+ m_entries.push_back(entry);
+ m_entry_status++;
+
+ return entry;
+}
+
+void SequenceData::remove(std::shared_ptr<SequenceEntry> entry)
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ m_entries.remove(entry);
+ m_entry_status++;
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/sequence/SequenceEntry.cpp b/extern/audaspace/src/sequence/SequenceEntry.cpp
new file mode 100644
index 00000000000..de538199d7d
--- /dev/null
+++ b/extern/audaspace/src/sequence/SequenceEntry.cpp
@@ -0,0 +1,256 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "sequence/SequenceEntry.h"
+#include "sequence/SequenceReader.h"
+
+#include <limits>
+#include <mutex>
+
+AUD_NAMESPACE_BEGIN
+
+SequenceEntry::SequenceEntry(std::shared_ptr<ISound> sound, float begin, float end, float skip, int id) :
+ m_status(0),
+ m_pos_status(1),
+ m_sound_status(0),
+ m_id(id),
+ m_sound(sound),
+ m_begin(begin),
+ m_end(end),
+ m_skip(skip),
+ m_muted(false),
+ 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(360),
+ m_cone_angle_inner(360),
+ m_cone_volume_outer(0),
+ m_volume(1, 1.0f),
+ m_pitch(1, 1.0f),
+ m_location(3),
+ m_orientation(4)
+{
+ Quaternion q;
+ m_orientation.write(q.get());
+ float f = 1;
+ m_volume.write(&f);
+ m_pitch.write(&f);
+}
+
+SequenceEntry::~SequenceEntry()
+{
+}
+
+void SequenceEntry::lock()
+{
+ m_mutex.lock();
+}
+
+void SequenceEntry::unlock()
+{
+ m_mutex.unlock();
+}
+
+std::shared_ptr<ISound> SequenceEntry::getSound()
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+ return m_sound;
+}
+
+void SequenceEntry::setSound(std::shared_ptr<ISound> sound)
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ if(m_sound.get() != sound.get())
+ {
+ m_sound = sound;
+ m_sound_status++;
+ }
+}
+
+void SequenceEntry::move(float begin, float end, float skip)
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ if(m_begin != begin || m_skip != skip || m_end != end)
+ {
+ m_begin = begin;
+ m_skip = skip;
+ m_end = end;
+ m_pos_status++;
+ }
+}
+
+bool SequenceEntry::isMuted()
+{
+ return m_muted;
+}
+
+void SequenceEntry::mute(bool mute)
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ m_muted = mute;
+}
+
+int SequenceEntry::getID() const
+{
+ return m_id;
+}
+
+AnimateableProperty* SequenceEntry::getAnimProperty(AnimateablePropertyType type)
+{
+ switch(type)
+ {
+ case AP_VOLUME:
+ return &m_volume;
+ case AP_PITCH:
+ return &m_pitch;
+ case AP_PANNING:
+ return &m_panning;
+ case AP_LOCATION:
+ return &m_location;
+ case AP_ORIENTATION:
+ return &m_orientation;
+ default:
+ return nullptr;
+ }
+}
+
+bool SequenceEntry::isRelative()
+{
+ return m_relative;
+}
+
+void SequenceEntry::setRelative(bool relative)
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ if(m_relative != relative)
+ {
+ m_relative = relative;
+ m_status++;
+ }
+}
+
+float SequenceEntry::getVolumeMaximum()
+{
+ return m_volume_max;
+}
+
+void SequenceEntry::setVolumeMaximum(float volume)
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ m_volume_max = volume;
+ m_status++;
+}
+
+float SequenceEntry::getVolumeMinimum()
+{
+ return m_volume_min;
+}
+
+void SequenceEntry::setVolumeMinimum(float volume)
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ m_volume_min = volume;
+ m_status++;
+}
+
+float SequenceEntry::getDistanceMaximum()
+{
+ return m_distance_max;
+}
+
+void SequenceEntry::setDistanceMaximum(float distance)
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ m_distance_max = distance;
+ m_status++;
+}
+
+float SequenceEntry::getDistanceReference()
+{
+ return m_distance_reference;
+}
+
+void SequenceEntry::setDistanceReference(float distance)
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ m_distance_reference = distance;
+ m_status++;
+}
+
+float SequenceEntry::getAttenuation()
+{
+ return m_attenuation;
+}
+
+void SequenceEntry::setAttenuation(float factor)
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ m_attenuation = factor;
+ m_status++;
+}
+
+float SequenceEntry::getConeAngleOuter()
+{
+ return m_cone_angle_outer;
+}
+
+void SequenceEntry::setConeAngleOuter(float angle)
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ m_cone_angle_outer = angle;
+ m_status++;
+}
+
+float SequenceEntry::getConeAngleInner()
+{
+ return m_cone_angle_inner;
+}
+
+void SequenceEntry::setConeAngleInner(float angle)
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ m_cone_angle_inner = angle;
+ m_status++;
+}
+
+float SequenceEntry::getConeVolumeOuter()
+{
+ return m_cone_volume_outer;
+}
+
+void SequenceEntry::setConeVolumeOuter(float volume)
+{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
+ m_cone_volume_outer = volume;
+ m_status++;
+}
+
+AUD_NAMESPACE_END
diff --git a/intern/audaspace/intern/AUD_SequencerHandle.cpp b/extern/audaspace/src/sequence/SequenceHandle.cpp
index aa742f7b8db..140b1fbd94a 100644
--- a/intern/audaspace/intern/AUD_SequencerHandle.cpp
+++ b/extern/audaspace/src/sequence/SequenceHandle.cpp
@@ -1,39 +1,31 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
*
- * Copyright 2009-2011 Jörg Hermann Müller
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * This file is part of AudaSpace.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * 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 *****
- */
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
-/** \file audaspace/intern/AUD_SequencerHandle.cpp
- * \ingroup audaspaceintern
- */
+#include "SequenceHandle.h"
+#include "sequence/SequenceEntry.h"
+#include "devices/ReadDevice.h"
+#include "Exception.h"
-
-#include "AUD_SequencerHandle.h"
-#include "AUD_ReadDevice.h"
-#include "AUD_MutexLock.h"
+#include <mutex>
#define KEEP_TIME 10
-void AUD_SequencerHandle::start()
+AUD_NAMESPACE_BEGIN
+
+void SequenceHandle::start()
{
// we already tried to start, aborting
if(!m_valid)
@@ -42,7 +34,7 @@ void AUD_SequencerHandle::start()
// in case the sound is playing, we need to stop first
stop();
- AUD_MutexLock lock(*m_entry);
+ std::lock_guard<ILockable> lock(*m_entry);
// let's try playing
if(m_entry->m_sound.get())
@@ -50,9 +42,9 @@ void AUD_SequencerHandle::start()
try
{
m_handle = m_device.play(m_entry->m_sound, true);
- m_3dhandle = boost::dynamic_pointer_cast<AUD_I3DHandle>(m_handle);
+ m_3dhandle = std::dynamic_pointer_cast<I3DHandle>(m_handle);
}
- catch(AUD_Exception&)
+ catch(Exception&)
{
// handle stays invalid in case we get an exception
}
@@ -65,9 +57,9 @@ void AUD_SequencerHandle::start()
m_valid = m_handle.get();
}
-bool AUD_SequencerHandle::updatePosition(float position)
+bool SequenceHandle::updatePosition(float position)
{
- AUD_MutexLock lock(*m_entry);
+ std::lock_guard<ILockable> lock(*m_entry);
if(m_handle.get())
{
@@ -116,7 +108,7 @@ bool AUD_SequencerHandle::updatePosition(float position)
return false;
}
-AUD_SequencerHandle::AUD_SequencerHandle(boost::shared_ptr<AUD_SequencerEntry> entry, AUD_ReadDevice& device) :
+SequenceHandle::SequenceHandle(std::shared_ptr<SequenceEntry> entry, ReadDevice& device) :
m_entry(entry),
m_valid(true),
m_status(0),
@@ -126,12 +118,12 @@ AUD_SequencerHandle::AUD_SequencerHandle(boost::shared_ptr<AUD_SequencerEntry> e
{
}
-AUD_SequencerHandle::~AUD_SequencerHandle()
+SequenceHandle::~SequenceHandle()
{
stop();
}
-int AUD_SequencerHandle::compare(boost::shared_ptr<AUD_SequencerEntry> entry) const
+int SequenceHandle::compare(std::shared_ptr<SequenceEntry> entry) const
{
if(m_entry->getID() < entry->getID())
return -1;
@@ -140,15 +132,15 @@ int AUD_SequencerHandle::compare(boost::shared_ptr<AUD_SequencerEntry> entry) co
return 1;
}
-void AUD_SequencerHandle::stop()
+void SequenceHandle::stop()
{
if(m_handle.get())
m_handle->stop();
- m_handle = boost::shared_ptr<AUD_IHandle>();
- m_3dhandle = boost::shared_ptr<AUD_I3DHandle>();
+ m_handle = nullptr;
+ m_3dhandle = nullptr;
}
-void AUD_SequencerHandle::update(float position, float frame, float fps)
+void SequenceHandle::update(float position, float frame, float fps)
{
if(m_sound_status != m_entry->m_sound_status)
{
@@ -185,7 +177,7 @@ void AUD_SequencerHandle::update(float position, float frame, float fps)
}
}
- AUD_MutexLock lock(*m_entry);
+ std::lock_guard<ILockable> lock(*m_entry);
if(m_pos_status != m_entry->m_pos_status)
{
m_pos_status = m_entry->m_pos_status;
@@ -200,8 +192,6 @@ void AUD_SequencerHandle::update(float position, float frame, float fps)
if(m_status != m_entry->m_status)
{
- m_status = m_entry->m_status;
-
m_3dhandle->setRelative(m_entry->m_relative);
m_3dhandle->setVolumeMaximum(m_entry->m_volume_max);
m_3dhandle->setVolumeMinimum(m_entry->m_volume_min);
@@ -211,6 +201,8 @@ void AUD_SequencerHandle::update(float position, float frame, float fps)
m_3dhandle->setConeAngleOuter(m_entry->m_cone_angle_outer);
m_3dhandle->setConeAngleInner(m_entry->m_cone_angle_inner);
m_3dhandle->setConeVolumeOuter(m_entry->m_cone_volume_outer);
+
+ m_status = m_entry->m_status;
}
float value;
@@ -220,24 +212,24 @@ void AUD_SequencerHandle::update(float position, float frame, float fps)
m_entry->m_pitch.read(frame, &value);
m_handle->setPitch(value);
m_entry->m_panning.read(frame, &value);
- AUD_SoftwareDevice::setPanning(m_handle.get(), value);
+ SoftwareDevice::setPanning(m_handle.get(), value);
- AUD_Vector3 v, v2;
- AUD_Quaternion q;
+ Vector3 v, v2;
+ Quaternion q;
m_entry->m_orientation.read(frame, q.get());
- m_3dhandle->setSourceOrientation(q);
+ m_3dhandle->setOrientation(q);
m_entry->m_location.read(frame, v.get());
- m_3dhandle->setSourceLocation(v);
+ m_3dhandle->setLocation(v);
m_entry->m_location.read(frame + 1, v2.get());
v2 -= v;
- m_3dhandle->setSourceVelocity(v2 * fps);
+ m_3dhandle->setVelocity(v2 * fps);
if(m_entry->m_muted)
m_handle->setVolume(0);
}
-bool AUD_SequencerHandle::seek(float position)
+bool SequenceHandle::seek(float position)
{
if(!m_valid)
// sound not valid, aborting
@@ -247,7 +239,7 @@ bool AUD_SequencerHandle::seek(float position)
// no handle, aborting
return false;
- AUD_MutexLock lock(*m_entry);
+ std::lock_guard<ILockable> lock(*m_entry);
float seekpos = position - m_entry->m_begin;
if(seekpos < 0)
seekpos = 0;
@@ -257,3 +249,5 @@ bool AUD_SequencerHandle::seek(float position)
return true;
}
+
+AUD_NAMESPACE_END
diff --git a/intern/audaspace/intern/AUD_SequencerHandle.h b/extern/audaspace/src/sequence/SequenceHandle.h
index 306df4a84b9..9a77489a8f8 100644
--- a/intern/audaspace/intern/AUD_SequencerHandle.h
+++ b/extern/audaspace/src/sequence/SequenceHandle.h
@@ -1,55 +1,46 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
*
- * Copyright 2009-2011 Jörg Hermann Müller
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * This file is part of AudaSpace.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * 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 *****
- */
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
-/** \file audaspace/intern/AUD_SequencerHandle.h
- * \ingroup audaspaceintern
- */
+#pragma once
+#include "Audaspace.h"
-#ifndef __AUD_SEQUENCERHANDLE_H__
-#define __AUD_SEQUENCERHANDLE_H__
+#include <memory>
-#include "AUD_SequencerEntry.h"
-#include "AUD_IHandle.h"
-#include "AUD_I3DHandle.h"
+AUD_NAMESPACE_BEGIN
-class AUD_ReadDevice;
+class ReadDevice;
+class IHandle;
+class I3DHandle;
+class SequenceEntry;
/**
* Represents a playing sequenced entry.
*/
-class AUD_SequencerHandle
+class SequenceHandle
{
private:
/// The entry this handle belongs to.
- boost::shared_ptr<AUD_SequencerEntry> m_entry;
+ std::shared_ptr<SequenceEntry> m_entry;
/// The handle in the read device.
- boost::shared_ptr<AUD_IHandle> m_handle;
+ std::shared_ptr<IHandle> m_handle;
/// The 3D handle in the read device.
- boost::shared_ptr<AUD_I3DHandle> m_3dhandle;
+ std::shared_ptr<I3DHandle> m_3dhandle;
/// Whether the sound is playable.
bool m_valid;
@@ -64,7 +55,11 @@ private:
int m_sound_status;
/// The read device this handle is played on.
- AUD_ReadDevice& m_device;
+ ReadDevice& m_device;
+
+ // delete copy constructor and operator=
+ SequenceHandle(const SequenceHandle&) = delete;
+ SequenceHandle& operator=(const SequenceHandle&) = delete;
/**
* Starts playing back the handle.
@@ -84,19 +79,19 @@ public:
* \param entry The entry this handle plays.
* \param device The read device to play on.
*/
- AUD_SequencerHandle(boost::shared_ptr<AUD_SequencerEntry> entry, AUD_ReadDevice& device);
+ SequenceHandle(std::shared_ptr<SequenceEntry> entry, ReadDevice& device);
/**
* Destroys the handle.
*/
- ~AUD_SequencerHandle();
+ ~SequenceHandle();
/**
* Compares whether this handle is playing the same entry as supplied.
* \param entry The entry to compare to.
* \return Whether the entries ID is smaller, equal or bigger.
*/
- int compare(boost::shared_ptr<AUD_SequencerEntry> entry) const;
+ int compare(std::shared_ptr<SequenceEntry> entry) const;
/**
* Stops playing back the handle.
@@ -119,4 +114,4 @@ public:
bool seek(float position);
};
-#endif //__AUD_SEQUENCERHANDLE_H__
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/sequence/SequenceReader.cpp b/extern/audaspace/src/sequence/SequenceReader.cpp
new file mode 100644
index 00000000000..38647aaeadf
--- /dev/null
+++ b/extern/audaspace/src/sequence/SequenceReader.cpp
@@ -0,0 +1,198 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "sequence/SequenceReader.h"
+#include "sequence/SequenceData.h"
+#include "Exception.h"
+#include "SequenceHandle.h"
+
+#include <algorithm>
+#include <mutex>
+#include <cmath>
+
+AUD_NAMESPACE_BEGIN
+
+SequenceReader::SequenceReader(std::shared_ptr<SequenceData> 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);
+}
+
+SequenceReader::~SequenceReader()
+{
+}
+
+bool SequenceReader::isSeekable() const
+{
+ return true;
+}
+
+void SequenceReader::seek(int position)
+{
+ if(position < 0)
+ return;
+
+ m_position = position;
+
+ for(auto& handle : m_handles)
+ {
+ handle->seek(position / m_sequence->m_specs.rate);
+ }
+}
+
+int SequenceReader::getLength() const
+{
+ return -1;
+}
+
+int SequenceReader::getPosition() const
+{
+ return m_position;
+}
+
+Specs SequenceReader::getSpecs() const
+{
+ return m_sequence->m_specs;
+}
+
+void SequenceReader::read(int& length, bool& eos, sample_t* buffer)
+{
+ std::lock_guard<ILockable> lock(*m_sequence);
+
+ if(m_sequence->m_status != m_status)
+ {
+ 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_sequence->m_status;
+ }
+
+ if(m_sequence->m_entry_status != m_entry_status)
+ {
+ std::list<std::shared_ptr<SequenceHandle> > handles;
+
+ auto hit = m_handles.begin();
+ auto eit = m_sequence->m_entries.begin();
+
+ int result;
+ std::shared_ptr<SequenceHandle> handle;
+
+ while(hit != m_handles.end() && eit != m_sequence->m_entries.end())
+ {
+ handle = *hit;
+ std::shared_ptr<SequenceEntry> entry = *eit;
+
+ result = handle->compare(entry);
+
+ if(result < 0)
+ {
+ try
+ {
+ handle = std::shared_ptr<SequenceHandle>(new SequenceHandle(entry, m_device));
+ handles.push_back(handle);
+ }
+ catch(Exception&)
+ {
+ }
+ eit++;
+ }
+ else if(result == 0)
+ {
+ handles.push_back(handle);
+ hit++;
+ eit++;
+ }
+ else
+ {
+ handle->stop();
+ hit++;
+ }
+ }
+
+ while(hit != m_handles.end())
+ {
+ (*hit)->stop();
+ hit++;
+ }
+
+ while(eit != m_sequence->m_entries.end())
+ {
+ try
+ {
+ handle = std::shared_ptr<SequenceHandle>(new SequenceHandle(*eit, m_device));
+ handles.push_back(handle);
+ }
+ catch(Exception&)
+ {
+ }
+ eit++;
+ }
+
+ m_handles = handles;
+
+ m_entry_status = m_sequence->m_entry_status;
+ }
+
+ Specs specs = m_sequence->m_specs;
+ int pos = 0;
+ float time = float(m_position) / float(specs.rate);
+ float volume, frame;
+ int len, cfra;
+ Vector3 v, v2;
+ Quaternion q;
+
+
+ while(pos < length)
+ {
+ frame = time * m_sequence->m_fps;
+ cfra = int(std::floor(frame));
+
+ len = int(std::ceil((cfra + 1) / m_sequence->m_fps * specs.rate)) - m_position;
+ len = std::min(length - pos, len);
+ len = std::max(len, 1);
+
+ for(auto& handle : m_handles)
+ {
+ handle->update(time, frame, m_sequence->m_fps);
+ }
+
+ m_sequence->m_volume.read(frame, &volume);
+ if(m_sequence->m_muted)
+ volume = 0.0f;
+ m_device.setVolume(volume);
+
+ m_sequence->m_orientation.read(frame, q.get());
+ m_device.setListenerOrientation(q);
+ m_sequence->m_location.read(frame, v.get());
+ m_device.setListenerLocation(v);
+ m_sequence->m_location.read(frame + 1, v2.get());
+ v2 -= v;
+ m_device.setListenerVelocity(v2 * m_sequence->m_fps);
+
+ m_device.read(reinterpret_cast<data_t*>(buffer + specs.channels * pos), len);
+
+ pos += len;
+ time += float(len) / float(specs.rate);
+ }
+
+ m_position += length;
+
+ eos = false;
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/sequence/Superpose.cpp b/extern/audaspace/src/sequence/Superpose.cpp
new file mode 100644
index 00000000000..3d13f7db627
--- /dev/null
+++ b/extern/audaspace/src/sequence/Superpose.cpp
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "sequence/Superpose.h"
+#include "sequence/SuperposeReader.h"
+
+AUD_NAMESPACE_BEGIN
+
+Superpose::Superpose(std::shared_ptr<ISound> sound1, std::shared_ptr<ISound> sound2) :
+ m_sound1(sound1), m_sound2(sound2)
+{
+}
+
+std::shared_ptr<IReader> Superpose::createReader()
+{
+ std::shared_ptr<IReader> reader1 = m_sound1->createReader();
+ std::shared_ptr<IReader> reader2 = m_sound2->createReader();
+
+ return std::shared_ptr<IReader>(new SuperposeReader(reader1, reader2));
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/sequence/SuperposeReader.cpp b/extern/audaspace/src/sequence/SuperposeReader.cpp
new file mode 100644
index 00000000000..9206a7a96ef
--- /dev/null
+++ b/extern/audaspace/src/sequence/SuperposeReader.cpp
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "sequence/SuperposeReader.h"
+#include "Exception.h"
+
+#include <algorithm>
+#include <cstring>
+
+AUD_NAMESPACE_BEGIN
+
+SuperposeReader::SuperposeReader(std::shared_ptr<IReader> reader1, std::shared_ptr<IReader> reader2) :
+ m_reader1(reader1), m_reader2(reader2)
+{
+}
+
+SuperposeReader::~SuperposeReader()
+{
+}
+
+bool SuperposeReader::isSeekable() const
+{
+ return m_reader1->isSeekable() && m_reader2->isSeekable();
+}
+
+void SuperposeReader::seek(int position)
+{
+ m_reader1->seek(position);
+ m_reader2->seek(position);
+}
+
+int SuperposeReader::getLength() const
+{
+ int len1 = m_reader1->getLength();
+ int len2 = m_reader2->getLength();
+ if((len1 < 0) || (len2 < 0))
+ return -1;
+ return std::min(len1, len2);
+}
+
+int SuperposeReader::getPosition() const
+{
+ int pos1 = m_reader1->getPosition();
+ int pos2 = m_reader2->getPosition();
+ return std::max(pos1, pos2);
+}
+
+Specs SuperposeReader::getSpecs() const
+{
+ return m_reader1->getSpecs();
+}
+
+void SuperposeReader::read(int& length, bool& eos, sample_t* buffer)
+{
+ Specs specs = m_reader1->getSpecs();
+ Specs s2 = m_reader2->getSpecs();
+ if(!AUD_COMPARE_SPECS(specs, s2))
+ AUD_THROW(StateException, "Two readers with different specifiactions cannot be superposed.");
+
+ int samplesize = AUD_SAMPLE_SIZE(specs);
+
+ m_buffer.assureSize(length * samplesize);
+
+ int len1 = length;
+ m_reader1->read(len1, eos, buffer);
+
+ if(len1 < length)
+ std::memset(buffer + len1 * specs.channels, 0, (length - len1) * samplesize);
+
+ int len2 = length;
+ bool eos2;
+ sample_t* buf = m_buffer.getBuffer();
+ m_reader2->read(len2, eos2, buf);
+
+ for(int i = 0; i < len2 * specs.channels; i++)
+ buffer[i] += buf[i];
+
+ length = std::max(len1, len2);
+ eos &= eos2;
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/util/Barrier.cpp b/extern/audaspace/src/util/Barrier.cpp
new file mode 100644
index 00000000000..3347a38092b
--- /dev/null
+++ b/extern/audaspace/src/util/Barrier.cpp
@@ -0,0 +1,42 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "util/Barrier.h"
+
+AUD_NAMESPACE_BEGIN
+Barrier::Barrier(unsigned int count) :
+ m_threshold(count), m_count(count), m_generation(0)
+{
+}
+
+Barrier::~Barrier()
+{
+}
+
+void Barrier::wait()
+{
+ std::unique_lock<std::mutex> lck(m_mutex);
+ int gen = m_generation;
+ if(!--m_count)
+ {
+ m_count = m_threshold;
+ m_generation++;
+ m_condition.notify_all();
+ }
+ else
+ m_condition.wait(lck, [this, gen] { return gen != m_generation; });
+}
+AUD_NAMESPACE_END \ No newline at end of file
diff --git a/extern/audaspace/src/util/Buffer.cpp b/extern/audaspace/src/util/Buffer.cpp
new file mode 100644
index 00000000000..d212278cacc
--- /dev/null
+++ b/extern/audaspace/src/util/Buffer.cpp
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "util/Buffer.h"
+
+#include <algorithm>
+#include <cstring>
+#include <cstdlib>
+
+#define ALIGNMENT 32
+#define ALIGN(a) (a + ALIGNMENT - ((long long)a & (ALIGNMENT-1)))
+
+AUD_NAMESPACE_BEGIN
+
+Buffer::Buffer(int size)
+{
+ m_size = size;
+ m_buffer = (data_t*) std::malloc(size + ALIGNMENT);
+}
+
+Buffer::~Buffer()
+{
+ std::free(m_buffer);
+}
+
+sample_t* Buffer::getBuffer() const
+{
+ return (sample_t*) ALIGN(m_buffer);
+}
+
+int Buffer::getSize() const
+{
+ return m_size;
+}
+
+void Buffer::resize(int size, bool keep)
+{
+ if(keep)
+ {
+ data_t* buffer = (data_t*) std::malloc(size + ALIGNMENT);
+
+ std::memcpy(ALIGN(buffer), ALIGN(m_buffer), std::min(size, m_size));
+
+ std::free(m_buffer);
+ m_buffer = buffer;
+ }
+ else
+ m_buffer = (data_t*) std::realloc(m_buffer, size + ALIGNMENT);
+
+ m_size = size;
+}
+
+void Buffer::assureSize(int size, bool keep)
+{
+ if(m_size < size)
+ resize(size, keep);
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/util/BufferReader.cpp b/extern/audaspace/src/util/BufferReader.cpp
new file mode 100644
index 00000000000..37744420ab8
--- /dev/null
+++ b/extern/audaspace/src/util/BufferReader.cpp
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "util/BufferReader.h"
+#include "util/Buffer.h"
+
+#include <cstring>
+
+AUD_NAMESPACE_BEGIN
+
+BufferReader::BufferReader(std::shared_ptr<Buffer> buffer,
+ Specs specs) :
+ m_position(0), m_buffer(buffer), m_specs(specs)
+{
+}
+
+bool BufferReader::isSeekable() const
+{
+ return true;
+}
+
+void BufferReader::seek(int position)
+{
+ m_position = position;
+}
+
+int BufferReader::getLength() const
+{
+ return m_buffer->getSize() / AUD_SAMPLE_SIZE(m_specs);
+}
+
+int BufferReader::getPosition() const
+{
+ return m_position;
+}
+
+Specs BufferReader::getSpecs() const
+{
+ return m_specs;
+}
+
+void BufferReader::read(int& length, bool& eos, sample_t* buffer)
+{
+ eos = false;
+
+ int sample_size = AUD_SAMPLE_SIZE(m_specs);
+
+ sample_t* buf = m_buffer->getBuffer() + m_position * m_specs.channels;
+
+ // in case the end of the buffer is reached
+ if(m_buffer->getSize() < (m_position + length) * sample_size)
+ {
+ length = m_buffer->getSize() / sample_size - m_position;
+ eos = true;
+ }
+
+ if(length < 0)
+ {
+ length = 0;
+ return;
+ }
+
+ m_position += length;
+ std::memcpy(buffer, buf, length * sample_size);
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/util/FFTPlan.cpp b/extern/audaspace/src/util/FFTPlan.cpp
new file mode 100644
index 00000000000..5e99dbff247
--- /dev/null
+++ b/extern/audaspace/src/util/FFTPlan.cpp
@@ -0,0 +1,66 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "util/FFTPlan.h"
+
+AUD_NAMESPACE_BEGIN
+FFTPlan::FFTPlan(double measureTime) :
+ FFTPlan(DEFAULT_N, measureTime)
+{
+}
+
+FFTPlan::FFTPlan(int n, double measureTime) :
+ m_N(n), m_bufferSize(((n/2)+1)*2*sizeof(fftwf_complex))
+{
+ fftwf_set_timelimit(measureTime);
+ void* buf = fftwf_malloc(m_bufferSize);
+ m_fftPlanR2C = fftwf_plan_dft_r2c_1d(m_N, (float*)buf, (fftwf_complex*)buf, FFTW_EXHAUSTIVE);
+ m_fftPlanC2R = fftwf_plan_dft_c2r_1d(m_N, (fftwf_complex*)buf, (float*)buf, FFTW_EXHAUSTIVE);
+ fftwf_free(buf);
+}
+
+FFTPlan::~FFTPlan()
+{
+ fftwf_destroy_plan(m_fftPlanC2R);
+ fftwf_destroy_plan(m_fftPlanR2C);
+}
+
+int FFTPlan::getSize()
+{
+ return m_N;
+}
+
+void FFTPlan::FFT(void* buffer)
+{
+ fftwf_execute_dft_r2c(m_fftPlanR2C, (float*)buffer, (fftwf_complex*)buffer);
+}
+
+void FFTPlan::IFFT(void* buffer)
+{
+ fftwf_execute_dft_c2r(m_fftPlanC2R, (fftwf_complex*)buffer, (float*)buffer);
+}
+
+void* FFTPlan::getBuffer()
+{
+ return fftwf_malloc(m_bufferSize);
+}
+
+void FFTPlan::freeBuffer(void* buffer)
+{
+ fftwf_free(buffer);
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/util/StreamBuffer.cpp b/extern/audaspace/src/util/StreamBuffer.cpp
new file mode 100644
index 00000000000..b87b363377d
--- /dev/null
+++ b/extern/audaspace/src/util/StreamBuffer.cpp
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#include "util/StreamBuffer.h"
+#include "util/BufferReader.h"
+#include "util/Buffer.h"
+
+// 5 sec * 48000 samples/sec * 4 bytes/sample * 6 channels
+#define BUFFER_RESIZE_BYTES 5760000
+
+AUD_NAMESPACE_BEGIN
+
+StreamBuffer::StreamBuffer(std::shared_ptr<ISound> sound) :
+ m_buffer(new Buffer())
+{
+ std::shared_ptr<IReader> reader = sound->createReader();
+
+ m_specs = reader->getSpecs();
+
+ int sample_size = AUD_SAMPLE_SIZE(m_specs);
+ int length;
+ int index = 0;
+ bool eos = false;
+
+ // get an approximated size if possible
+ int size = reader->getLength();
+
+ if(size <= 0)
+ size = BUFFER_RESIZE_BYTES / sample_size;
+ else
+ size += m_specs.rate;
+
+ // as long as the end of the stream is not reached
+ while(!eos)
+ {
+ // increase
+ m_buffer->resize(size*sample_size, true);
+
+ // read more
+ length = size-index;
+ reader->read(length, eos, m_buffer->getBuffer() + index * m_specs.channels);
+ if(index == m_buffer->getSize() / sample_size)
+ size += BUFFER_RESIZE_BYTES / sample_size;
+ index += length;
+ }
+
+ m_buffer->resize(index * sample_size, true);
+}
+
+StreamBuffer::StreamBuffer(std::shared_ptr<Buffer> buffer, Specs specs) :
+ m_buffer(buffer), m_specs(specs)
+{
+}
+
+std::shared_ptr<Buffer> StreamBuffer::getBuffer()
+{
+ return m_buffer;
+}
+
+Specs StreamBuffer::getSpecs()
+{
+ return m_specs;
+}
+
+std::shared_ptr<IReader> StreamBuffer::createReader()
+{
+ return std::shared_ptr<IReader>(new BufferReader(m_buffer, m_specs));
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/util/ThreadPool.cpp b/extern/audaspace/src/util/ThreadPool.cpp
new file mode 100644
index 00000000000..74051902c3b
--- /dev/null
+++ b/extern/audaspace/src/util/ThreadPool.cpp
@@ -0,0 +1,60 @@
+/*******************************************************************************
+* Copyright 2015-2016 Juan Francisco Crespo Galán
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+******************************************************************************/
+
+#include "util/ThreadPool.h"
+
+AUD_NAMESPACE_BEGIN
+
+ThreadPool::ThreadPool(unsigned int count) :
+ m_stopFlag(false), m_numThreads(count)
+{
+ for(unsigned int i = 0; i < count; i++)
+ m_threads.emplace_back(&ThreadPool::threadFunction, this);
+}
+
+ThreadPool::~ThreadPool()
+{
+ m_mutex.lock();
+ m_stopFlag = true;
+ m_mutex.unlock();
+ m_condition.notify_all();
+ for(unsigned int i = 0; i < m_threads.size(); i++)
+ m_threads[i].join();
+}
+
+unsigned int ThreadPool::getNumOfThreads()
+{
+ return m_numThreads;
+}
+
+void ThreadPool::threadFunction()
+{
+ while(true)
+ {
+ std::function<void()> task;
+ {
+ std::unique_lock<std::mutex> lock(m_mutex);
+ m_condition.wait(lock, [this] { return m_stopFlag || !m_queue.empty(); });
+ if(m_stopFlag && m_queue.empty())
+ return;
+ task = std::move(m_queue.front());
+ this->m_queue.pop();
+ }
+ task();
+ }
+}
+
+AUD_NAMESPACE_END
diff --git a/extern/carve/carve-capi.cc b/extern/carve/carve-capi.cc
index 5648977ad27..d6666a52c10 100644
--- a/extern/carve/carve-capi.cc
+++ b/extern/carve/carve-capi.cc
@@ -568,6 +568,22 @@ void cleanupFaceEdgeAttrsCallback(const MeshSet<3> *left,
&descr->orig_face_edge_mapping);
}
+void copyVertexAttrsCallback(const carve::mesh::MeshSet<3>::vertex_t *orig_vert,
+ const carve::mesh::MeshSet<3>::vertex_t *new_vert,
+ void *descr_v)
+{
+ CarveMeshDescr *descr = (CarveMeshDescr *) descr_v;
+ if (!descr->orig_vert_mapping.hasAttribute(orig_vert)) {
+ return;
+ }
+ if (descr->orig_vert_mapping.hasAttribute(new_vert)) {
+ return;
+ }
+ OrigIndex attr = descr->orig_vert_mapping.getAttribute(orig_vert);
+ descr->orig_vert_mapping.setAttribute(new_vert, attr);
+ descr->orig_vert_mapping.removeAttribute(orig_vert);
+}
+
} // namespace
CarveMeshDescr *carve_addMesh(struct ImportMeshData *import_data,
@@ -751,6 +767,7 @@ bool carve_performBooleanOperation(CarveMeshDescr *left_mesh,
// done properly. The only way to make such situations working is to
// union intersecting meshes of the same operand.
carve_unionIntersections(&csg, &left, &right,
+ copyVertexAttrsCallback,
cleanupFaceEdgeAttrsCallback,
(void *) output_descr);
diff --git a/extern/carve/carve-util.cc b/extern/carve/carve-util.cc
index 0dff1deb750..78997c72e71 100644
--- a/extern/carve/carve-util.cc
+++ b/extern/carve/carve-util.cc
@@ -141,6 +141,11 @@ void carve_getRescaleMinMax(const MeshSet<3> *left,
namespace {
+struct UnionIntersectionContext {
+ VertexAttrsCallback vertex_attr_callback;
+ void *user_data;
+};
+
void copyMeshes(const std::vector<MeshSet<3>::mesh_t*> &meshes,
std::vector<MeshSet<3>::mesh_t*> *new_meshes)
{
@@ -154,24 +159,73 @@ void copyMeshes(const std::vector<MeshSet<3>::mesh_t*> &meshes,
}
}
-MeshSet<3> *meshSetFromMeshes(const std::vector<MeshSet<3>::mesh_t*> &meshes)
+struct NewMeshMapping {
+ std::map<const MeshSet<3>::edge_t*, MeshSet<3>::vertex_t*> orig_edge_vert;
+};
+
+void prepareNewMeshMapping(const std::vector<MeshSet<3>::mesh_t*> &meshes,
+ NewMeshMapping *mapping)
{
- std::vector<MeshSet<3>::mesh_t*> new_meshes;
+ for (size_t m = 0; m < meshes.size(); ++m) {
+ MeshSet<3>::mesh_t *mesh = meshes[m];
+ for (size_t f = 0; f < mesh->faces.size(); ++f) {
+ MeshSet<3>::face_t *face = mesh->faces[f];
+ MeshSet<3>::edge_t *edge = face->edge;
+ do {
+ mapping->orig_edge_vert[edge] = edge->vert;
+ edge = edge->next;
+ } while (edge != face->edge);
+ }
+ }
+}
- copyMeshes(meshes, &new_meshes);
+void runNewMeshSetHooks(UnionIntersectionContext *ctx,
+ NewMeshMapping *mapping,
+ MeshSet<3> *mesh_set)
+{
+ for (size_t m = 0; m < mesh_set->meshes.size(); ++m) {
+ MeshSet<3>::mesh_t *mesh = mesh_set->meshes[m];
+ for (size_t f = 0; f < mesh->faces.size(); ++f) {
+ MeshSet<3>::face_t *face = mesh->faces[f];
+ MeshSet<3>::edge_t *edge = face->edge;
+ do {
+ const MeshSet<3>::vertex_t *orig_vert = mapping->orig_edge_vert[edge];
+ const MeshSet<3>::vertex_t *new_vert = edge->vert;
+ ctx->vertex_attr_callback(orig_vert, new_vert, ctx->user_data);
+ edge = edge->next;
+ } while (edge != face->edge);
+ }
+ }
+}
- return new MeshSet<3>(new_meshes);
+MeshSet<3> *newMeshSetFromMeshesWithAttrs(
+ UnionIntersectionContext *ctx,
+ std::vector<MeshSet<3>::mesh_t*> &meshes)
+{
+ NewMeshMapping mapping;
+ prepareNewMeshMapping(meshes, &mapping);
+ MeshSet<3> *mesh_set = new MeshSet<3>(meshes);
+ runNewMeshSetHooks(ctx, &mapping, mesh_set);
+ return mesh_set;
}
-MeshSet<3> *meshSetFromTwoMeshes(const std::vector<MeshSet<3>::mesh_t*> &left_meshes,
- const std::vector<MeshSet<3>::mesh_t*> &right_meshes)
+
+MeshSet<3> *meshSetFromMeshes(UnionIntersectionContext *ctx,
+ const std::vector<MeshSet<3>::mesh_t*> &meshes)
{
std::vector<MeshSet<3>::mesh_t*> new_meshes;
+ copyMeshes(meshes, &new_meshes);
+ return newMeshSetFromMeshesWithAttrs(ctx, new_meshes);
+}
+MeshSet<3> *meshSetFromTwoMeshes(UnionIntersectionContext *ctx,
+ const std::vector<MeshSet<3>::mesh_t*> &left_meshes,
+ const std::vector<MeshSet<3>::mesh_t*> &right_meshes)
+{
+ std::vector<MeshSet<3>::mesh_t*> new_meshes;
copyMeshes(left_meshes, &new_meshes);
copyMeshes(right_meshes, &new_meshes);
-
- return new MeshSet<3>(new_meshes);
+ return newMeshSetFromMeshesWithAttrs(ctx, new_meshes);
}
bool checkEdgeFaceIntersections_do(Intersections &intersections,
@@ -349,7 +403,8 @@ void getIntersectedOperandMeshes(std::vector<MeshSet<3>::mesh_t*> *meshes,
}
}
-MeshSet<3> *getIntersectedOperand(std::vector<MeshSet<3>::mesh_t*> *meshes,
+MeshSet<3> *getIntersectedOperand(UnionIntersectionContext *ctx,
+ std::vector<MeshSet<3>::mesh_t*> *meshes,
const MeshSet<3>::aabb_t &otherAABB,
RTreeCache *rtree_cache,
IntersectCache *intersect_cache)
@@ -360,13 +415,14 @@ MeshSet<3> *getIntersectedOperand(std::vector<MeshSet<3>::mesh_t*> *meshes,
if (operandMeshes.size() == 0)
return NULL;
- return meshSetFromMeshes(operandMeshes);
+ return meshSetFromMeshes(ctx, operandMeshes);
}
MeshSet<3> *unionIntersectingMeshes(carve::csg::CSG *csg,
MeshSet<3> *poly,
const MeshSet<3> *other_poly,
const MeshSet<3>::aabb_t &otherAABB,
+ VertexAttrsCallback vertex_attr_callback,
UnionIntersectionsCallback callback,
void *user_data)
{
@@ -380,7 +436,12 @@ MeshSet<3> *unionIntersectingMeshes(carve::csg::CSG *csg,
RTreeCache rtree_cache;
IntersectCache intersect_cache;
- MeshSet<3> *left = getIntersectedOperand(&orig_meshes,
+ UnionIntersectionContext ctx;
+ ctx.vertex_attr_callback = vertex_attr_callback;
+ ctx.user_data = user_data;
+
+ MeshSet<3> *left = getIntersectedOperand(&ctx,
+ &orig_meshes,
otherAABB,
&rtree_cache,
&intersect_cache);
@@ -391,7 +452,8 @@ MeshSet<3> *unionIntersectingMeshes(carve::csg::CSG *csg,
}
while (orig_meshes.size()) {
- MeshSet<3> *right = getIntersectedOperand(&orig_meshes,
+ MeshSet<3> *right = getIntersectedOperand(&ctx,
+ &orig_meshes,
otherAABB,
&rtree_cache,
&intersect_cache);
@@ -422,7 +484,9 @@ MeshSet<3> *unionIntersectingMeshes(carve::csg::CSG *csg,
catch (carve::exception e) {
std::cerr << "CSG failed, exception " << e.str() << std::endl;
- MeshSet<3> *result = meshSetFromTwoMeshes(left->meshes, right->meshes);
+ MeshSet<3> *result = meshSetFromTwoMeshes(&ctx,
+ left->meshes,
+ right->meshes);
callback(result, other_poly, user_data);
@@ -448,7 +512,9 @@ MeshSet<3> *unionIntersectingMeshes(carve::csg::CSG *csg,
// Append all meshes which doesn't have intersection with another operand as-is.
if (orig_meshes.size()) {
- MeshSet<3> *result = meshSetFromTwoMeshes(left->meshes, orig_meshes);
+ MeshSet<3> *result = meshSetFromTwoMeshes(&ctx,
+ left->meshes,
+ orig_meshes);
delete left;
left = result;
@@ -464,6 +530,7 @@ MeshSet<3> *unionIntersectingMeshes(carve::csg::CSG *csg,
void carve_unionIntersections(carve::csg::CSG *csg,
MeshSet<3> **left_r,
MeshSet<3> **right_r,
+ VertexAttrsCallback vertex_attr_callback,
UnionIntersectionsCallback callback,
void *user_data)
{
@@ -477,9 +544,9 @@ void carve_unionIntersections(carve::csg::CSG *csg,
MeshSet<3>::aabb_t rightAABB = right->getAABB();;
left = unionIntersectingMeshes(csg, left, right, rightAABB,
- callback, user_data);
+ vertex_attr_callback, callback, user_data);
right = unionIntersectingMeshes(csg, right, left, leftAABB,
- callback, user_data);
+ vertex_attr_callback, callback, user_data);
if (left != *left_r) {
delete *left_r;
diff --git a/extern/carve/carve-util.h b/extern/carve/carve-util.h
index 3edf1bb1c02..e8f62cd2751 100644
--- a/extern/carve/carve-util.h
+++ b/extern/carve/carve-util.h
@@ -70,6 +70,10 @@ void carve_getRescaleMinMax(const carve::mesh::MeshSet<3> *left,
carve::geom3d::Vector *min,
carve::geom3d::Vector *max);
+typedef void (*VertexAttrsCallback) (const carve::mesh::MeshSet<3>::vertex_t *orig_vert,
+ const carve::mesh::MeshSet<3>::vertex_t *new_vert,
+ void *userdata);
+
typedef void (*UnionIntersectionsCallback) (const carve::mesh::MeshSet<3> *left,
const carve::mesh::MeshSet<3> *right,
void *userdata);
@@ -77,6 +81,7 @@ typedef void (*UnionIntersectionsCallback) (const carve::mesh::MeshSet<3> *left,
void carve_unionIntersections(carve::csg::CSG *csg,
carve::mesh::MeshSet<3> **left_r,
carve::mesh::MeshSet<3> **right_r,
+ VertexAttrsCallback vertex_attr_callback,
UnionIntersectionsCallback callback,
void *user_data);
@@ -148,6 +153,13 @@ namespace carve {
void setAttribute(const meshset_t::vertex_t *v, const attr_t &attr) {
attrs[v] = attr;
}
+
+ void removeAttribute(const meshset_t::vertex_t *v) {
+ typename attrmap_t::iterator it = attrs.find(v);
+ if (it != attrs.end()) {
+ attrs.erase(it);
+ }
+ }
};
template<typename attr_t>
diff --git a/extern/cuew/README.blender b/extern/cuew/README.blender
index 7b77935d750..a53a927c25f 100644
--- a/extern/cuew/README.blender
+++ b/extern/cuew/README.blender
@@ -1,5 +1,5 @@
Project: Cuda Wrangler
URL: https://github.com/CudaWrangler/cuew
License: Apache 2.0
-Upstream version: 63d2a0f
+Upstream version: cbf465b
Local modifications: None
diff --git a/extern/cuew/include/cuew.h b/extern/cuew/include/cuew.h
index 4cce29d38ab..0eace96bc3f 100644
--- a/extern/cuew/include/cuew.h
+++ b/extern/cuew/include/cuew.h
@@ -27,7 +27,7 @@ extern "C" {
#define CUEW_VERSION_MAJOR 1
#define CUEW_VERSION_MINOR 2
-#define CUDA_VERSION 7050
+#define CUDA_VERSION 8000
#define CU_IPC_HANDLE_SIZE 64
#define CU_STREAM_LEGACY ((CUstream)0x1)
#define CU_STREAM_PER_THREAD ((CUstream)0x2)
@@ -51,6 +51,8 @@ extern "C" {
#define CU_LAUNCH_PARAM_BUFFER_POINTER ((void*)0x01)
#define CU_LAUNCH_PARAM_BUFFER_SIZE ((void*)0x02)
#define CU_PARAM_TR_DEFAULT -1
+#define CU_DEVICE_CPU ((CUdevice)-1)
+#define CU_DEVICE_INVALID ((CUdevice)-2)
/* Functions which changed 3.1 -> 3.2 for 64 bit stuff,
* the cuda library has both the old ones for compatibility and new
@@ -114,12 +116,30 @@ extern "C" {
#define cuGLGetDevices cuGLGetDevices_v2
/* Types. */
+#ifdef _MSC_VER
+typedef unsigned __int32 cuuint32_t;
+typedef unsigned __int64 cuuint64_t;
+#else
+#include <stdint.h>
+typedef uint32_t cuuint32_t;
+typedef uint64_t cuuint64_t;
+#endif
+
#if defined(__x86_64) || defined(AMD64) || defined(_M_AMD64) || defined (__aarch64__)
typedef unsigned long long CUdeviceptr;
#else
typedef unsigned int CUdeviceptr;
#endif
+
+#ifdef _WIN32
+# define CUDAAPI __stdcall
+# define CUDA_CB __stdcall
+#else
+# define CUDAAPI
+# define CUDA_CB
+#endif
+
typedef int CUdevice;
typedef struct CUctx_st* CUcontext;
typedef struct CUmod_st* CUmodule;
@@ -180,6 +200,53 @@ typedef enum CUevent_flags_enum {
CU_EVENT_INTERPROCESS = 0x4,
} CUevent_flags;
+typedef enum CUstreamWaitValue_flags_enum {
+ CU_STREAM_WAIT_VALUE_GEQ = 0x0,
+ CU_STREAM_WAIT_VALUE_EQ = 0x1,
+ CU_STREAM_WAIT_VALUE_AND = 0x2,
+ CU_STREAM_WAIT_VALUE_FLUSH = (1 << 30),
+} CUstreamWaitValue_flags;
+
+typedef enum CUstreamWriteValue_flags_enum {
+ CU_STREAM_WRITE_VALUE_DEFAULT = 0x0,
+ CU_STREAM_WRITE_VALUE_NO_MEMORY_BARRIER = 0x1,
+} CUstreamWriteValue_flags;
+
+typedef enum CUstreamBatchMemOpType_enum {
+ CU_STREAM_MEM_OP_WAIT_VALUE_32 = 1,
+ CU_STREAM_MEM_OP_WRITE_VALUE_32 = 2,
+ CU_STREAM_MEM_OP_FLUSH_REMOTE_WRITES = 3,
+} CUstreamBatchMemOpType;
+
+typedef union CUstreamBatchMemOpParams_union {
+ CUstreamBatchMemOpType operation;
+ struct CUstreamMemOpWaitValueParams_st {
+ CUstreamBatchMemOpType operation;
+ CUdeviceptr address;
+ union {
+ cuuint32_t value;
+ cuuint64_t pad;
+ };
+ unsigned int flags;
+ CUdeviceptr alias;
+ } waitValue;
+ struct CUstreamMemOpWriteValueParams_st {
+ CUstreamBatchMemOpType operation;
+ CUdeviceptr address;
+ union {
+ cuuint32_t value;
+ cuuint64_t pad;
+ };
+ unsigned int flags;
+ CUdeviceptr alias;
+ } writeValue;
+ struct CUstreamMemOpFlushRemoteWritesParams_st {
+ CUstreamBatchMemOpType operation;
+ unsigned int flags;
+ } flushRemoteWrites;
+ cuuint64_t pad[6];
+} CUstreamBatchMemOpParams;
+
typedef enum CUoccupancy_flags_enum {
CU_OCCUPANCY_DEFAULT = 0x0,
CU_OCCUPANCY_DISABLE_CACHING_OVERRIDE = 0x1,
@@ -299,6 +366,12 @@ typedef enum CUdevice_attribute_enum {
CU_DEVICE_ATTRIBUTE_MANAGED_MEMORY = 83,
CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD = 84,
CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD_GROUP_ID = 85,
+ CU_DEVICE_ATTRIBUTE_HOST_NATIVE_ATOMIC_SUPPORTED = 86,
+ CU_DEVICE_ATTRIBUTE_SINGLE_TO_DOUBLE_PRECISION_PERF_RATIO = 87,
+ CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS = 88,
+ CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS = 89,
+ CU_DEVICE_ATTRIBUTE_COMPUTE_PREEMPTION_SUPPORTED = 90,
+ CU_DEVICE_ATTRIBUTE_CAN_USE_HOST_POINTER_FOR_REGISTERED_MEM = 91,
CU_DEVICE_ATTRIBUTE_MAX,
} CUdevice_attribute;
@@ -360,11 +433,26 @@ typedef enum CUmemorytype_enum {
typedef enum CUcomputemode_enum {
CU_COMPUTEMODE_DEFAULT = 0,
- CU_COMPUTEMODE_EXCLUSIVE = 1,
CU_COMPUTEMODE_PROHIBITED = 2,
CU_COMPUTEMODE_EXCLUSIVE_PROCESS = 3,
} CUcomputemode;
+typedef enum CUmem_advise_enum {
+ CU_MEM_ADVISE_SET_READ_MOSTLY = 1,
+ CU_MEM_ADVISE_UNSET_READ_MOSTLY = 2,
+ CU_MEM_ADVISE_SET_PREFERRED_LOCATION = 3,
+ CU_MEM_ADVISE_UNSET_PREFERRED_LOCATION = 4,
+ CU_MEM_ADVISE_SET_ACCESSED_BY = 5,
+ CU_MEM_ADVISE_UNSET_ACCESSED_BY = 6,
+} CUmem_advise;
+
+typedef enum CUmem_range_attribute_enum {
+ CU_MEM_RANGE_ATTRIBUTE_READ_MOSTLY = 1,
+ CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION = 2,
+ CU_MEM_RANGE_ATTRIBUTE_ACCESSED_BY = 3,
+ CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION = 4,
+} CUmem_range_attribute;
+
typedef enum CUjit_option_enum {
CU_JIT_MAX_REGISTERS = 0,
CU_JIT_THREADS_PER_BLOCK,
@@ -381,6 +469,8 @@ typedef enum CUjit_option_enum {
CU_JIT_LOG_VERBOSE,
CU_JIT_GENERATE_LINE_INFO,
CU_JIT_CACHE_MODE,
+ CU_JIT_NEW_SM3X_OPT,
+ CU_JIT_FAST_COMPILE,
CU_JIT_NUM_OPTIONS,
} CUjit_option;
@@ -397,6 +487,10 @@ typedef enum CUjit_target_enum {
CU_TARGET_COMPUTE_37 = 37,
CU_TARGET_COMPUTE_50 = 50,
CU_TARGET_COMPUTE_52 = 52,
+ CU_TARGET_COMPUTE_53 = 53,
+ CU_TARGET_COMPUTE_60 = 60,
+ CU_TARGET_COMPUTE_61 = 61,
+ CU_TARGET_COMPUTE_62 = 62,
} CUjit_target;
typedef enum CUjit_fallback_enum {
@@ -490,6 +584,7 @@ typedef enum cudaError_enum {
CUDA_ERROR_PEER_ACCESS_UNSUPPORTED = 217,
CUDA_ERROR_INVALID_PTX = 218,
CUDA_ERROR_INVALID_GRAPHICS_CONTEXT = 219,
+ CUDA_ERROR_NVLINK_UNCORRECTABLE = 220,
CUDA_ERROR_INVALID_SOURCE = 300,
CUDA_ERROR_FILE_NOT_FOUND = 301,
CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND = 302,
@@ -521,8 +616,14 @@ typedef enum cudaError_enum {
CUDA_ERROR_UNKNOWN = 999,
} CUresult;
-typedef void* CUstreamCallback;
-typedef size_t* CUoccupancyB2DSize;
+typedef enum CUdevice_P2PAttribute_enum {
+ CU_DEVICE_P2P_ATTRIBUTE_PERFORMANCE_RANK = 0x01,
+ CU_DEVICE_P2P_ATTRIBUTE_ACCESS_SUPPORTED = 0x02,
+ CU_DEVICE_P2P_ATTRIBUTE_NATIVE_ATOMIC_SUPPORTED = 0x03,
+} CUdevice_P2PAttribute;
+
+typedef void (CUDA_CB *CUstreamCallback)(CUstream hStream, CUresult status, void* userData);
+typedef size_t (CUDA_CB *CUoccupancyB2DSize)(int blockSize);
typedef struct CUDA_MEMCPY2D_st {
size_t srcXInBytes;
@@ -654,7 +755,8 @@ typedef struct CUDA_TEXTURE_DESC_st {
float mipmapLevelBias;
float minMipmapLevelClamp;
float maxMipmapLevelClamp;
- int reserved[16];
+ float borderColor[4];
+ int reserved[12];
} CUDA_TEXTURE_DESC;
typedef enum CUresourceViewFormat_enum {
@@ -736,21 +838,16 @@ typedef enum {
NVRTC_ERROR_INVALID_OPTION = 5,
NVRTC_ERROR_COMPILATION = 6,
NVRTC_ERROR_BUILTIN_OPERATION_FAILURE = 7,
+ NVRTC_ERROR_NO_NAME_EXPRESSIONS_AFTER_COMPILATION = 8,
+ NVRTC_ERROR_NO_LOWERED_NAMES_BEFORE_COMPILATION = 9,
+ NVRTC_ERROR_NAME_EXPRESSION_NOT_VALID = 10,
+ NVRTC_ERROR_INTERNAL_ERROR = 11,
} nvrtcResult;
typedef struct _nvrtcProgram* nvrtcProgram;
-
-#ifdef _WIN32
-# define CUDAAPI __stdcall
-# define CUDA_CB __stdcall
-#else
-# define CUDAAPI
-# define CUDA_CB
-#endif
-
/* Function types. */
-typedef CUresult CUDAAPI tcuGetErrorString(CUresult error, const char* pStr);
-typedef CUresult CUDAAPI tcuGetErrorName(CUresult error, const char* pStr);
+typedef CUresult CUDAAPI tcuGetErrorString(CUresult error, const char** pStr);
+typedef CUresult CUDAAPI tcuGetErrorName(CUresult error, const char** pStr);
typedef CUresult CUDAAPI tcuInit(unsigned int Flags);
typedef CUresult CUDAAPI tcuDriverGetVersion(int* driverVersion);
typedef CUresult CUDAAPI tcuDeviceGet(CUdevice* device, int ordinal);
@@ -786,26 +883,26 @@ typedef CUresult CUDAAPI tcuCtxAttach(CUcontext* pctx, unsigned int flags);
typedef CUresult CUDAAPI tcuCtxDetach(CUcontext ctx);
typedef CUresult CUDAAPI tcuModuleLoad(CUmodule* module, const char* fname);
typedef CUresult CUDAAPI tcuModuleLoadData(CUmodule* module, const void* image);
-typedef CUresult CUDAAPI tcuModuleLoadDataEx(CUmodule* module, const void* image, unsigned int numOptions, CUjit_option* options, void* optionValues);
+typedef CUresult CUDAAPI tcuModuleLoadDataEx(CUmodule* module, const void* image, unsigned int numOptions, CUjit_option* options, void** optionValues);
typedef CUresult CUDAAPI tcuModuleLoadFatBinary(CUmodule* module, const void* fatCubin);
typedef CUresult CUDAAPI tcuModuleUnload(CUmodule hmod);
typedef CUresult CUDAAPI tcuModuleGetFunction(CUfunction* hfunc, CUmodule hmod, const char* name);
typedef CUresult CUDAAPI tcuModuleGetGlobal_v2(CUdeviceptr* dptr, size_t* bytes, CUmodule hmod, const char* name);
typedef CUresult CUDAAPI tcuModuleGetTexRef(CUtexref* pTexRef, CUmodule hmod, const char* name);
typedef CUresult CUDAAPI tcuModuleGetSurfRef(CUsurfref* pSurfRef, CUmodule hmod, const char* name);
-typedef CUresult CUDAAPI tcuLinkCreate_v2(unsigned int numOptions, CUjit_option* options, void* optionValues, CUlinkState* stateOut);
-typedef CUresult CUDAAPI tcuLinkAddData_v2(CUlinkState state, CUjitInputType type, void* data, size_t size, const char* name, unsigned int numOptions, CUjit_option* options, void* optionValues);
-typedef CUresult CUDAAPI tcuLinkAddFile_v2(CUlinkState state, CUjitInputType type, const char* path, unsigned int numOptions, CUjit_option* options, void* optionValues);
-typedef CUresult CUDAAPI tcuLinkComplete(CUlinkState state, void* cubinOut, size_t* sizeOut);
+typedef CUresult CUDAAPI tcuLinkCreate_v2(unsigned int numOptions, CUjit_option* options, void** optionValues, CUlinkState* stateOut);
+typedef CUresult CUDAAPI tcuLinkAddData_v2(CUlinkState state, CUjitInputType type, void* data, size_t size, const char* name, unsigned int numOptions, CUjit_option* options, void** optionValues);
+typedef CUresult CUDAAPI tcuLinkAddFile_v2(CUlinkState state, CUjitInputType type, const char* path, unsigned int numOptions, CUjit_option* options, void** optionValues);
+typedef CUresult CUDAAPI tcuLinkComplete(CUlinkState state, void** cubinOut, size_t* sizeOut);
typedef CUresult CUDAAPI tcuLinkDestroy(CUlinkState state);
typedef CUresult CUDAAPI tcuMemGetInfo_v2(size_t* free, size_t* total);
typedef CUresult CUDAAPI tcuMemAlloc_v2(CUdeviceptr* dptr, size_t bytesize);
typedef CUresult CUDAAPI tcuMemAllocPitch_v2(CUdeviceptr* dptr, size_t* pPitch, size_t WidthInBytes, size_t Height, unsigned int ElementSizeBytes);
typedef CUresult CUDAAPI tcuMemFree_v2(CUdeviceptr dptr);
typedef CUresult CUDAAPI tcuMemGetAddressRange_v2(CUdeviceptr* pbase, size_t* psize, CUdeviceptr dptr);
-typedef CUresult CUDAAPI tcuMemAllocHost_v2(void* pp, size_t bytesize);
+typedef CUresult CUDAAPI tcuMemAllocHost_v2(void** pp, size_t bytesize);
typedef CUresult CUDAAPI tcuMemFreeHost(void* p);
-typedef CUresult CUDAAPI tcuMemHostAlloc(void* pp, size_t bytesize, unsigned int Flags);
+typedef CUresult CUDAAPI tcuMemHostAlloc(void** pp, size_t bytesize, unsigned int Flags);
typedef CUresult CUDAAPI tcuMemHostGetDevicePointer_v2(CUdeviceptr* pdptr, void* p, unsigned int Flags);
typedef CUresult CUDAAPI tcuMemHostGetFlags(unsigned int* pFlags, void* p);
typedef CUresult CUDAAPI tcuMemAllocManaged(CUdeviceptr* dptr, size_t bytesize, unsigned int flags);
@@ -863,8 +960,12 @@ typedef CUresult CUDAAPI tcuMipmappedArrayCreate(CUmipmappedArray* pHandle, cons
typedef CUresult CUDAAPI tcuMipmappedArrayGetLevel(CUarray* pLevelArray, CUmipmappedArray hMipmappedArray, unsigned int level);
typedef CUresult CUDAAPI tcuMipmappedArrayDestroy(CUmipmappedArray hMipmappedArray);
typedef CUresult CUDAAPI tcuPointerGetAttribute(void* data, CUpointer_attribute attribute, CUdeviceptr ptr);
+typedef CUresult CUDAAPI tcuMemPrefetchAsync(CUdeviceptr devPtr, size_t count, CUdevice dstDevice, CUstream hStream);
+typedef CUresult CUDAAPI tcuMemAdvise(CUdeviceptr devPtr, size_t count, CUmem_advise advice, CUdevice device);
+typedef CUresult CUDAAPI tcuMemRangeGetAttribute(void* data, size_t dataSize, CUmem_range_attribute attribute, CUdeviceptr devPtr, size_t count);
+typedef CUresult CUDAAPI tcuMemRangeGetAttributes(void** data, size_t* dataSizes, CUmem_range_attribute* attributes, size_t numAttributes, CUdeviceptr devPtr, size_t count);
typedef CUresult CUDAAPI tcuPointerSetAttribute(const void* value, CUpointer_attribute attribute, CUdeviceptr ptr);
-typedef CUresult CUDAAPI tcuPointerGetAttributes(unsigned int numAttributes, CUpointer_attribute* attributes, void* data, CUdeviceptr ptr);
+typedef CUresult CUDAAPI tcuPointerGetAttributes(unsigned int numAttributes, CUpointer_attribute* attributes, void** data, CUdeviceptr ptr);
typedef CUresult CUDAAPI tcuStreamCreate(CUstream* phStream, unsigned int Flags);
typedef CUresult CUDAAPI tcuStreamCreateWithPriority(CUstream* phStream, unsigned int flags, int priority);
typedef CUresult CUDAAPI tcuStreamGetPriority(CUstream hStream, int* priority);
@@ -881,10 +982,13 @@ typedef CUresult CUDAAPI tcuEventQuery(CUevent hEvent);
typedef CUresult CUDAAPI tcuEventSynchronize(CUevent hEvent);
typedef CUresult CUDAAPI tcuEventDestroy_v2(CUevent hEvent);
typedef CUresult CUDAAPI tcuEventElapsedTime(float* pMilliseconds, CUevent hStart, CUevent hEnd);
+typedef CUresult CUDAAPI tcuStreamWaitValue32(CUstream stream, CUdeviceptr addr, cuuint32_t value, unsigned int flags);
+typedef CUresult CUDAAPI tcuStreamWriteValue32(CUstream stream, CUdeviceptr addr, cuuint32_t value, unsigned int flags);
+typedef CUresult CUDAAPI tcuStreamBatchMemOp(CUstream stream, unsigned int count, CUstreamBatchMemOpParams* paramArray, unsigned int flags);
typedef CUresult CUDAAPI tcuFuncGetAttribute(int* pi, CUfunction_attribute attrib, CUfunction hfunc);
typedef CUresult CUDAAPI tcuFuncSetCacheConfig(CUfunction hfunc, CUfunc_cache config);
typedef CUresult CUDAAPI tcuFuncSetSharedMemConfig(CUfunction hfunc, CUsharedconfig config);
-typedef CUresult CUDAAPI tcuLaunchKernel(CUfunction f, unsigned int gridDimX, unsigned int gridDimY, unsigned int gridDimZ, unsigned int blockDimX, unsigned int blockDimY, unsigned int blockDimZ, unsigned int sharedMemBytes, CUstream hStream, void* kernelParams, void* extra);
+typedef CUresult CUDAAPI tcuLaunchKernel(CUfunction f, unsigned int gridDimX, unsigned int gridDimY, unsigned int gridDimZ, unsigned int blockDimX, unsigned int blockDimY, unsigned int blockDimZ, unsigned int sharedMemBytes, CUstream hStream, void** kernelParams, void** extra);
typedef CUresult CUDAAPI tcuFuncSetBlockShape(CUfunction hfunc, int x, int y, int z);
typedef CUresult CUDAAPI tcuFuncSetSharedSize(CUfunction hfunc, unsigned int bytes);
typedef CUresult CUDAAPI tcuParamSetSize(CUfunction hfunc, unsigned int numbytes);
@@ -910,6 +1014,7 @@ typedef CUresult CUDAAPI tcuTexRefSetMipmapFilterMode(CUtexref hTexRef, CUfilter
typedef CUresult CUDAAPI tcuTexRefSetMipmapLevelBias(CUtexref hTexRef, float bias);
typedef CUresult CUDAAPI tcuTexRefSetMipmapLevelClamp(CUtexref hTexRef, float minMipmapLevelClamp, float maxMipmapLevelClamp);
typedef CUresult CUDAAPI tcuTexRefSetMaxAnisotropy(CUtexref hTexRef, unsigned int maxAniso);
+typedef CUresult CUDAAPI tcuTexRefSetBorderColor(CUtexref hTexRef, float* pBorderColor);
typedef CUresult CUDAAPI tcuTexRefSetFlags(CUtexref hTexRef, unsigned int Flags);
typedef CUresult CUDAAPI tcuTexRefGetAddress_v2(CUdeviceptr* pdptr, CUtexref hTexRef);
typedef CUresult CUDAAPI tcuTexRefGetArray(CUarray* phArray, CUtexref hTexRef);
@@ -921,6 +1026,7 @@ typedef CUresult CUDAAPI tcuTexRefGetMipmapFilterMode(CUfilter_mode* pfm, CUtexr
typedef CUresult CUDAAPI tcuTexRefGetMipmapLevelBias(float* pbias, CUtexref hTexRef);
typedef CUresult CUDAAPI tcuTexRefGetMipmapLevelClamp(float* pminMipmapLevelClamp, float* pmaxMipmapLevelClamp, CUtexref hTexRef);
typedef CUresult CUDAAPI tcuTexRefGetMaxAnisotropy(int* pmaxAniso, CUtexref hTexRef);
+typedef CUresult CUDAAPI tcuTexRefGetBorderColor(float* pBorderColor, CUtexref hTexRef);
typedef CUresult CUDAAPI tcuTexRefGetFlags(unsigned int* pFlags, CUtexref hTexRef);
typedef CUresult CUDAAPI tcuTexRefCreate(CUtexref* pTexRef);
typedef CUresult CUDAAPI tcuTexRefDestroy(CUtexref hTexRef);
@@ -935,6 +1041,7 @@ typedef CUresult CUDAAPI tcuSurfObjectCreate(CUsurfObject* pSurfObject, const CU
typedef CUresult CUDAAPI tcuSurfObjectDestroy(CUsurfObject surfObject);
typedef CUresult CUDAAPI tcuSurfObjectGetResourceDesc(CUDA_RESOURCE_DESC* pResDesc, CUsurfObject surfObject);
typedef CUresult CUDAAPI tcuDeviceCanAccessPeer(int* canAccessPeer, CUdevice dev, CUdevice peerDev);
+typedef CUresult CUDAAPI tcuDeviceGetP2PAttribute(int* value, CUdevice_P2PAttribute attrib, CUdevice srcDevice, CUdevice dstDevice);
typedef CUresult CUDAAPI tcuCtxEnablePeerAccess(CUcontext peerContext, unsigned int Flags);
typedef CUresult CUDAAPI tcuCtxDisablePeerAccess(CUcontext peerContext);
typedef CUresult CUDAAPI tcuGraphicsUnregisterResource(CUgraphicsResource resource);
@@ -944,7 +1051,7 @@ typedef CUresult CUDAAPI tcuGraphicsResourceGetMappedPointer_v2(CUdeviceptr* pDe
typedef CUresult CUDAAPI tcuGraphicsResourceSetMapFlags_v2(CUgraphicsResource resource, unsigned int flags);
typedef CUresult CUDAAPI tcuGraphicsMapResources(unsigned int count, CUgraphicsResource* resources, CUstream hStream);
typedef CUresult CUDAAPI tcuGraphicsUnmapResources(unsigned int count, CUgraphicsResource* resources, CUstream hStream);
-typedef CUresult CUDAAPI tcuGetExportTable(const void* ppExportTable, const CUuuid* pExportTableId);
+typedef CUresult CUDAAPI tcuGetExportTable(const void** ppExportTable, const CUuuid* pExportTableId);
typedef CUresult CUDAAPI tcuGraphicsGLRegisterBuffer(CUgraphicsResource* pCudaResource, GLuint buffer, unsigned int Flags);
typedef CUresult CUDAAPI tcuGraphicsGLRegisterImage(CUgraphicsResource* pCudaResource, GLuint image, GLenum target, unsigned int Flags);
@@ -961,13 +1068,15 @@ typedef CUresult CUDAAPI tcuGLUnmapBufferObjectAsync(GLuint buffer, CUstream hSt
typedef const char* CUDAAPI tnvrtcGetErrorString(nvrtcResult result);
typedef nvrtcResult CUDAAPI tnvrtcVersion(int* major, int* minor);
-typedef nvrtcResult CUDAAPI tnvrtcCreateProgram(nvrtcProgram* prog, const char* src, const char* name, int numHeaders, const char* headers, const char* includeNames);
+typedef nvrtcResult CUDAAPI tnvrtcCreateProgram(nvrtcProgram* prog, const char* src, const char* name, int numHeaders, const char** headers, const char** includeNames);
typedef nvrtcResult CUDAAPI tnvrtcDestroyProgram(nvrtcProgram* prog);
-typedef nvrtcResult CUDAAPI tnvrtcCompileProgram(nvrtcProgram prog, int numOptions, const char* options);
+typedef nvrtcResult CUDAAPI tnvrtcCompileProgram(nvrtcProgram prog, int numOptions, const char** options);
typedef nvrtcResult CUDAAPI tnvrtcGetPTXSize(nvrtcProgram prog, size_t* ptxSizeRet);
typedef nvrtcResult CUDAAPI tnvrtcGetPTX(nvrtcProgram prog, char* ptx);
typedef nvrtcResult CUDAAPI tnvrtcGetProgramLogSize(nvrtcProgram prog, size_t* logSizeRet);
typedef nvrtcResult CUDAAPI tnvrtcGetProgramLog(nvrtcProgram prog, char* log);
+typedef nvrtcResult CUDAAPI tnvrtcAddNameExpression(nvrtcProgram prog, const char* name_expression);
+typedef nvrtcResult CUDAAPI tnvrtcGetLoweredName(nvrtcProgram prog, const char* name_expression, const char** lowered_name);
/* Function declarations. */
@@ -1085,6 +1194,10 @@ extern tcuMipmappedArrayCreate *cuMipmappedArrayCreate;
extern tcuMipmappedArrayGetLevel *cuMipmappedArrayGetLevel;
extern tcuMipmappedArrayDestroy *cuMipmappedArrayDestroy;
extern tcuPointerGetAttribute *cuPointerGetAttribute;
+extern tcuMemPrefetchAsync *cuMemPrefetchAsync;
+extern tcuMemAdvise *cuMemAdvise;
+extern tcuMemRangeGetAttribute *cuMemRangeGetAttribute;
+extern tcuMemRangeGetAttributes *cuMemRangeGetAttributes;
extern tcuPointerSetAttribute *cuPointerSetAttribute;
extern tcuPointerGetAttributes *cuPointerGetAttributes;
extern tcuStreamCreate *cuStreamCreate;
@@ -1103,6 +1216,9 @@ extern tcuEventQuery *cuEventQuery;
extern tcuEventSynchronize *cuEventSynchronize;
extern tcuEventDestroy_v2 *cuEventDestroy_v2;
extern tcuEventElapsedTime *cuEventElapsedTime;
+extern tcuStreamWaitValue32 *cuStreamWaitValue32;
+extern tcuStreamWriteValue32 *cuStreamWriteValue32;
+extern tcuStreamBatchMemOp *cuStreamBatchMemOp;
extern tcuFuncGetAttribute *cuFuncGetAttribute;
extern tcuFuncSetCacheConfig *cuFuncSetCacheConfig;
extern tcuFuncSetSharedMemConfig *cuFuncSetSharedMemConfig;
@@ -1132,6 +1248,7 @@ extern tcuTexRefSetMipmapFilterMode *cuTexRefSetMipmapFilterMode;
extern tcuTexRefSetMipmapLevelBias *cuTexRefSetMipmapLevelBias;
extern tcuTexRefSetMipmapLevelClamp *cuTexRefSetMipmapLevelClamp;
extern tcuTexRefSetMaxAnisotropy *cuTexRefSetMaxAnisotropy;
+extern tcuTexRefSetBorderColor *cuTexRefSetBorderColor;
extern tcuTexRefSetFlags *cuTexRefSetFlags;
extern tcuTexRefGetAddress_v2 *cuTexRefGetAddress_v2;
extern tcuTexRefGetArray *cuTexRefGetArray;
@@ -1143,6 +1260,7 @@ extern tcuTexRefGetMipmapFilterMode *cuTexRefGetMipmapFilterMode;
extern tcuTexRefGetMipmapLevelBias *cuTexRefGetMipmapLevelBias;
extern tcuTexRefGetMipmapLevelClamp *cuTexRefGetMipmapLevelClamp;
extern tcuTexRefGetMaxAnisotropy *cuTexRefGetMaxAnisotropy;
+extern tcuTexRefGetBorderColor *cuTexRefGetBorderColor;
extern tcuTexRefGetFlags *cuTexRefGetFlags;
extern tcuTexRefCreate *cuTexRefCreate;
extern tcuTexRefDestroy *cuTexRefDestroy;
@@ -1157,6 +1275,7 @@ extern tcuSurfObjectCreate *cuSurfObjectCreate;
extern tcuSurfObjectDestroy *cuSurfObjectDestroy;
extern tcuSurfObjectGetResourceDesc *cuSurfObjectGetResourceDesc;
extern tcuDeviceCanAccessPeer *cuDeviceCanAccessPeer;
+extern tcuDeviceGetP2PAttribute *cuDeviceGetP2PAttribute;
extern tcuCtxEnablePeerAccess *cuCtxEnablePeerAccess;
extern tcuCtxDisablePeerAccess *cuCtxDisablePeerAccess;
extern tcuGraphicsUnregisterResource *cuGraphicsUnregisterResource;
@@ -1190,6 +1309,8 @@ extern tnvrtcGetPTXSize *nvrtcGetPTXSize;
extern tnvrtcGetPTX *nvrtcGetPTX;
extern tnvrtcGetProgramLogSize *nvrtcGetProgramLogSize;
extern tnvrtcGetProgramLog *nvrtcGetProgramLog;
+extern tnvrtcAddNameExpression *nvrtcAddNameExpression;
+extern tnvrtcGetLoweredName *nvrtcGetLoweredName;
enum {
diff --git a/extern/cuew/src/cuew.c b/extern/cuew/src/cuew.c
index c96ea2c1959..962059bfcce 100644
--- a/extern/cuew/src/cuew.c
+++ b/extern/cuew/src/cuew.c
@@ -184,6 +184,10 @@ tcuMipmappedArrayCreate *cuMipmappedArrayCreate;
tcuMipmappedArrayGetLevel *cuMipmappedArrayGetLevel;
tcuMipmappedArrayDestroy *cuMipmappedArrayDestroy;
tcuPointerGetAttribute *cuPointerGetAttribute;
+tcuMemPrefetchAsync *cuMemPrefetchAsync;
+tcuMemAdvise *cuMemAdvise;
+tcuMemRangeGetAttribute *cuMemRangeGetAttribute;
+tcuMemRangeGetAttributes *cuMemRangeGetAttributes;
tcuPointerSetAttribute *cuPointerSetAttribute;
tcuPointerGetAttributes *cuPointerGetAttributes;
tcuStreamCreate *cuStreamCreate;
@@ -202,6 +206,9 @@ tcuEventQuery *cuEventQuery;
tcuEventSynchronize *cuEventSynchronize;
tcuEventDestroy_v2 *cuEventDestroy_v2;
tcuEventElapsedTime *cuEventElapsedTime;
+tcuStreamWaitValue32 *cuStreamWaitValue32;
+tcuStreamWriteValue32 *cuStreamWriteValue32;
+tcuStreamBatchMemOp *cuStreamBatchMemOp;
tcuFuncGetAttribute *cuFuncGetAttribute;
tcuFuncSetCacheConfig *cuFuncSetCacheConfig;
tcuFuncSetSharedMemConfig *cuFuncSetSharedMemConfig;
@@ -231,6 +238,7 @@ tcuTexRefSetMipmapFilterMode *cuTexRefSetMipmapFilterMode;
tcuTexRefSetMipmapLevelBias *cuTexRefSetMipmapLevelBias;
tcuTexRefSetMipmapLevelClamp *cuTexRefSetMipmapLevelClamp;
tcuTexRefSetMaxAnisotropy *cuTexRefSetMaxAnisotropy;
+tcuTexRefSetBorderColor *cuTexRefSetBorderColor;
tcuTexRefSetFlags *cuTexRefSetFlags;
tcuTexRefGetAddress_v2 *cuTexRefGetAddress_v2;
tcuTexRefGetArray *cuTexRefGetArray;
@@ -242,6 +250,7 @@ tcuTexRefGetMipmapFilterMode *cuTexRefGetMipmapFilterMode;
tcuTexRefGetMipmapLevelBias *cuTexRefGetMipmapLevelBias;
tcuTexRefGetMipmapLevelClamp *cuTexRefGetMipmapLevelClamp;
tcuTexRefGetMaxAnisotropy *cuTexRefGetMaxAnisotropy;
+tcuTexRefGetBorderColor *cuTexRefGetBorderColor;
tcuTexRefGetFlags *cuTexRefGetFlags;
tcuTexRefCreate *cuTexRefCreate;
tcuTexRefDestroy *cuTexRefDestroy;
@@ -256,6 +265,7 @@ tcuSurfObjectCreate *cuSurfObjectCreate;
tcuSurfObjectDestroy *cuSurfObjectDestroy;
tcuSurfObjectGetResourceDesc *cuSurfObjectGetResourceDesc;
tcuDeviceCanAccessPeer *cuDeviceCanAccessPeer;
+tcuDeviceGetP2PAttribute *cuDeviceGetP2PAttribute;
tcuCtxEnablePeerAccess *cuCtxEnablePeerAccess;
tcuCtxDisablePeerAccess *cuCtxDisablePeerAccess;
tcuGraphicsUnregisterResource *cuGraphicsUnregisterResource;
@@ -289,6 +299,8 @@ tnvrtcGetPTXSize *nvrtcGetPTXSize;
tnvrtcGetPTX *nvrtcGetPTX;
tnvrtcGetProgramLogSize *nvrtcGetProgramLogSize;
tnvrtcGetProgramLog *nvrtcGetProgramLog;
+tnvrtcAddNameExpression *nvrtcAddNameExpression;
+tnvrtcGetLoweredName *nvrtcGetLoweredName;
static DynamicLibrary dynamic_library_open_find(const char **paths) {
@@ -486,6 +498,10 @@ int cuewInit(void) {
CUDA_LIBRARY_FIND(cuMipmappedArrayGetLevel);
CUDA_LIBRARY_FIND(cuMipmappedArrayDestroy);
CUDA_LIBRARY_FIND(cuPointerGetAttribute);
+ CUDA_LIBRARY_FIND(cuMemPrefetchAsync);
+ CUDA_LIBRARY_FIND(cuMemAdvise);
+ CUDA_LIBRARY_FIND(cuMemRangeGetAttribute);
+ CUDA_LIBRARY_FIND(cuMemRangeGetAttributes);
CUDA_LIBRARY_FIND(cuPointerSetAttribute);
CUDA_LIBRARY_FIND(cuPointerGetAttributes);
CUDA_LIBRARY_FIND(cuStreamCreate);
@@ -504,6 +520,9 @@ int cuewInit(void) {
CUDA_LIBRARY_FIND(cuEventSynchronize);
CUDA_LIBRARY_FIND(cuEventDestroy_v2);
CUDA_LIBRARY_FIND(cuEventElapsedTime);
+ CUDA_LIBRARY_FIND(cuStreamWaitValue32);
+ CUDA_LIBRARY_FIND(cuStreamWriteValue32);
+ CUDA_LIBRARY_FIND(cuStreamBatchMemOp);
CUDA_LIBRARY_FIND(cuFuncGetAttribute);
CUDA_LIBRARY_FIND(cuFuncSetCacheConfig);
CUDA_LIBRARY_FIND(cuFuncSetSharedMemConfig);
@@ -533,6 +552,7 @@ int cuewInit(void) {
CUDA_LIBRARY_FIND(cuTexRefSetMipmapLevelBias);
CUDA_LIBRARY_FIND(cuTexRefSetMipmapLevelClamp);
CUDA_LIBRARY_FIND(cuTexRefSetMaxAnisotropy);
+ CUDA_LIBRARY_FIND(cuTexRefSetBorderColor);
CUDA_LIBRARY_FIND(cuTexRefSetFlags);
CUDA_LIBRARY_FIND(cuTexRefGetAddress_v2);
CUDA_LIBRARY_FIND(cuTexRefGetArray);
@@ -544,6 +564,7 @@ int cuewInit(void) {
CUDA_LIBRARY_FIND(cuTexRefGetMipmapLevelBias);
CUDA_LIBRARY_FIND(cuTexRefGetMipmapLevelClamp);
CUDA_LIBRARY_FIND(cuTexRefGetMaxAnisotropy);
+ CUDA_LIBRARY_FIND(cuTexRefGetBorderColor);
CUDA_LIBRARY_FIND(cuTexRefGetFlags);
CUDA_LIBRARY_FIND(cuTexRefCreate);
CUDA_LIBRARY_FIND(cuTexRefDestroy);
@@ -558,6 +579,7 @@ int cuewInit(void) {
CUDA_LIBRARY_FIND(cuSurfObjectDestroy);
CUDA_LIBRARY_FIND(cuSurfObjectGetResourceDesc);
CUDA_LIBRARY_FIND(cuDeviceCanAccessPeer);
+ CUDA_LIBRARY_FIND(cuDeviceGetP2PAttribute);
CUDA_LIBRARY_FIND(cuCtxEnablePeerAccess);
CUDA_LIBRARY_FIND(cuCtxDisablePeerAccess);
CUDA_LIBRARY_FIND(cuGraphicsUnregisterResource);
@@ -593,6 +615,8 @@ int cuewInit(void) {
NVRTC_LIBRARY_FIND(nvrtcGetPTX);
NVRTC_LIBRARY_FIND(nvrtcGetProgramLogSize);
NVRTC_LIBRARY_FIND(nvrtcGetProgramLog);
+ NVRTC_LIBRARY_FIND(nvrtcAddNameExpression);
+ NVRTC_LIBRARY_FIND(nvrtcGetLoweredName);
}
result = CUEW_SUCCESS;
@@ -630,6 +654,7 @@ const char *cuewErrorString(CUresult result) {
case CUDA_ERROR_PEER_ACCESS_UNSUPPORTED: return "Peer access unsupported";
case CUDA_ERROR_INVALID_PTX: return "Invalid ptx";
case CUDA_ERROR_INVALID_GRAPHICS_CONTEXT: return "Invalid graphics context";
+ case CUDA_ERROR_NVLINK_UNCORRECTABLE: return "Nvlink uncorrectable";
case CUDA_ERROR_INVALID_SOURCE: return "Invalid source";
case CUDA_ERROR_FILE_NOT_FOUND: return "File not found";
case CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND: return "Link to a shared object failed to resolve";
diff --git a/extern/curve_fit_nd/intern/curve_fit_cubic_refit.c b/extern/curve_fit_nd/intern/curve_fit_cubic_refit.c
index 96ec9a33270..b5340efdcb2 100644
--- a/extern/curve_fit_nd/intern/curve_fit_cubic_refit.c
+++ b/extern/curve_fit_nd/intern/curve_fit_cubic_refit.c
@@ -137,7 +137,7 @@ struct Knot {
/* Initially point to contiguous memory, however we may re-assign */
double *tan[2];
-} Knot;
+};
struct KnotRemoveState {
@@ -1102,7 +1102,7 @@ int curve_fit_cubic_to_points_refit_db(
uint **r_corner_index_array, uint *r_corner_index_len)
{
const uint knots_len = points_len;
- struct Knot *knots = malloc(sizeof(Knot) * knots_len);
+ struct Knot *knots = malloc(sizeof(struct Knot) * knots_len);
#ifndef USE_CORNER_DETECT
(void)r_corner_index_array;
diff --git a/intern/atomic/atomic_ops.h b/intern/atomic/atomic_ops.h
index 1e9528f9ed9..38670be56fd 100644
--- a/intern/atomic/atomic_ops.h
+++ b/intern/atomic/atomic_ops.h
@@ -100,6 +100,7 @@ ATOMIC_INLINE size_t atomic_sub_and_fetch_z(size_t *p, size_t x);
ATOMIC_INLINE size_t atomic_fetch_and_add_z(size_t *p, size_t x);
ATOMIC_INLINE size_t atomic_fetch_and_sub_z(size_t *p, size_t x);
ATOMIC_INLINE size_t atomic_cas_z(size_t *v, size_t old, size_t _new);
+ATOMIC_INLINE size_t atomic_fetch_and_update_max_z(size_t *p, size_t x); /* Uses CAS loop, see warning below. */
ATOMIC_INLINE unsigned int atomic_add_and_fetch_u(unsigned int *p, unsigned int x);
ATOMIC_INLINE unsigned int atomic_sub_and_fetch_u(unsigned int *p, unsigned int x);
@@ -107,6 +108,8 @@ ATOMIC_INLINE unsigned int atomic_fetch_and_add_u(unsigned int *p, unsigned int
ATOMIC_INLINE unsigned int atomic_fetch_and_sub_u(unsigned int *p, unsigned int x);
ATOMIC_INLINE unsigned int atomic_cas_u(unsigned int *v, unsigned int old, unsigned int _new);
+ATOMIC_INLINE void *atomic_cas_ptr(void **v, void *old, void *_new);
+
/* WARNING! Float 'atomics' are really faked ones, those are actually closer to some kind of spinlock-sync'ed operation,
* which means they are only efficient if collisions are highly unlikely (i.e. if probability of two threads
* working on the same pointer at the same time is very low). */
diff --git a/intern/atomic/intern/atomic_ops_ext.h b/intern/atomic/intern/atomic_ops_ext.h
index b72c94563fc..34158a0b45e 100644
--- a/intern/atomic/intern/atomic_ops_ext.h
+++ b/intern/atomic/intern/atomic_ops_ext.h
@@ -111,6 +111,17 @@ ATOMIC_INLINE size_t atomic_cas_z(size_t *v, size_t old, size_t _new)
#endif
}
+ATOMIC_INLINE size_t atomic_fetch_and_update_max_z(size_t *p, size_t x)
+{
+ size_t prev_value;
+ while((prev_value = *p) < x) {
+ if(atomic_cas_z(p, prev_value, x) == prev_value) {
+ break;
+ }
+ }
+ return prev_value;
+}
+
/******************************************************************************/
/* unsigned operations. */
ATOMIC_INLINE unsigned int atomic_add_and_fetch_u(unsigned int *p, unsigned int x)
@@ -169,6 +180,18 @@ ATOMIC_INLINE unsigned int atomic_cas_u(unsigned int *v, unsigned int old, unsig
}
/******************************************************************************/
+/* Pointer operations. */
+
+ATOMIC_INLINE void *atomic_cas_ptr(void **v, void *old, void *_new)
+{
+#if (LG_SIZEOF_PTR == 8)
+ return (void *)atomic_cas_uint64((uint64_t *)v, *(uint64_t *)&old, *(uint64_t *)&_new);
+#elif (LG_SIZEOF_PTR == 4)
+ return (void *)atomic_cas_uint32((uint32_t *)v, *(uint32_t *)&old, *(uint32_t *)&_new);
+#endif
+}
+
+/******************************************************************************/
/* float operations. */
ATOMIC_INLINE float atomic_add_and_fetch_fl(float *p, const float x)
diff --git a/intern/atomic/intern/atomic_ops_utils.h b/intern/atomic/intern/atomic_ops_utils.h
index bfec9918c16..c190b655e0a 100644
--- a/intern/atomic/intern/atomic_ops_utils.h
+++ b/intern/atomic/intern/atomic_ops_utils.h
@@ -52,8 +52,8 @@
#ifndef __ATOMIC_OPS_UTILS_H__
#define __ATOMIC_OPS_UTILS_H__
-/* needed for int types */
-#include "../../../source/blender/blenlib/BLI_sys_types.h"
+#include <stdint.h>
+#include <stddef.h>
#include <stdlib.h>
#include <limits.h>
@@ -63,12 +63,7 @@
#if defined(_MSC_VER)
# define ATOMIC_INLINE static __forceinline
#else
-# if (defined(__APPLE__) && defined(__ppc__))
-/* static inline __attribute__ here breaks osx ppc gcc42 build */
-# define ATOMIC_INLINE static __attribute__((always_inline))
-# else
-# define ATOMIC_INLINE static inline __attribute__((always_inline))
-# endif
+# define ATOMIC_INLINE static inline __attribute__((always_inline))
#endif
#ifndef LIKELY
diff --git a/intern/audaspace/CMakeLists.txt b/intern/audaspace/CMakeLists.txt
index dd446613fd0..e359a631532 100644
--- a/intern/audaspace/CMakeLists.txt
+++ b/intern/audaspace/CMakeLists.txt
@@ -24,9 +24,6 @@ remove_strict_flags()
if(CMAKE_COMPILER_IS_GNUCC)
remove_cc_flag("-Wunused-macros")
endif()
-
-if(WITH_SYSTEM_AUDASPACE)
-
set(INC
.
)
@@ -52,305 +49,4 @@ if(WITH_PYTHON)
add_definitions(-DWITH_PYTHON)
endif()
-else()
-
-set(INC
- .
- FX
- intern
- ../ffmpeg
-)
-
-set(INC_SYS
- ${PTHREADS_INCLUDE_DIRS}
- ${BOOST_INCLUDE_DIR}
-)
-
-set(SRC
- FX/AUD_AccumulatorFactory.cpp
- FX/AUD_BandpassCalculator.cpp
- FX/AUD_BaseIIRFilterReader.cpp
- FX/AUD_ButterworthCalculator.cpp
- FX/AUD_ButterworthFactory.cpp
- FX/AUD_CallbackIIRFilterReader.cpp
- FX/AUD_DelayFactory.cpp
- FX/AUD_DelayReader.cpp
- FX/AUD_DoubleFactory.cpp
- FX/AUD_DoubleReader.cpp
- FX/AUD_DynamicIIRFilterFactory.cpp
- FX/AUD_DynamicIIRFilterReader.cpp
- FX/AUD_EffectFactory.cpp
- FX/AUD_EffectReader.cpp
- FX/AUD_EnvelopeFactory.cpp
- FX/AUD_FaderFactory.cpp
- FX/AUD_FaderReader.cpp
- FX/AUD_HighpassCalculator.cpp
- FX/AUD_HighpassFactory.cpp
- FX/AUD_IIRFilterFactory.cpp
- FX/AUD_IIRFilterReader.cpp
- FX/AUD_LimiterFactory.cpp
- FX/AUD_LimiterReader.cpp
- FX/AUD_LoopFactory.cpp
- FX/AUD_LoopReader.cpp
- FX/AUD_LowpassCalculator.cpp
- FX/AUD_LowpassFactory.cpp
- FX/AUD_PingPongFactory.cpp
- FX/AUD_PitchFactory.cpp
- FX/AUD_PitchReader.cpp
- FX/AUD_RectifyFactory.cpp
- FX/AUD_ReverseFactory.cpp
- FX/AUD_ReverseReader.cpp
- FX/AUD_SquareFactory.cpp
- FX/AUD_SumFactory.cpp
- FX/AUD_SuperposeFactory.cpp
- FX/AUD_SuperposeReader.cpp
- FX/AUD_VolumeFactory.cpp
-
- intern/AUD_3DMath.h
- intern/AUD_AnimateableProperty.cpp
- intern/AUD_AnimateableProperty.h
- intern/AUD_Buffer.cpp
- intern/AUD_Buffer.h
- intern/AUD_BufferReader.cpp
- intern/AUD_BufferReader.h
- intern/AUD_C-API.cpp
- intern/AUD_C-API.h
- intern/AUD_ChannelMapperFactory.cpp
- intern/AUD_ChannelMapperFactory.h
- intern/AUD_ChannelMapperReader.cpp
- intern/AUD_ChannelMapperReader.h
- intern/AUD_ConverterFactory.cpp
- intern/AUD_ConverterFactory.h
- intern/AUD_ConverterFunctions.cpp
- intern/AUD_ConverterFunctions.h
- intern/AUD_ConverterReader.cpp
- intern/AUD_ConverterReader.h
- intern/AUD_FileFactory.cpp
- intern/AUD_FileFactory.h
- intern/AUD_FileWriter.cpp
- intern/AUD_FileWriter.h
- intern/AUD_I3DDevice.h
- intern/AUD_I3DHandle.h
- intern/AUD_IDevice.h
- intern/AUD_IFactory.h
- intern/AUD_IHandle.h
- intern/AUD_ILockable.h
- intern/AUD_IReader.h
- intern/AUD_IWriter.h
- intern/AUD_JOSResampleFactory.cpp
- intern/AUD_JOSResampleFactory.h
- intern/AUD_JOSResampleReader.cpp
- intern/AUD_JOSResampleReader.h
- intern/AUD_LinearResampleFactory.cpp
- intern/AUD_LinearResampleFactory.h
- intern/AUD_LinearResampleReader.cpp
- intern/AUD_LinearResampleReader.h
- intern/AUD_Mixer.cpp
- intern/AUD_Mixer.h
- intern/AUD_MixerFactory.cpp
- intern/AUD_MixerFactory.h
- intern/AUD_MutexLock.h
- intern/AUD_NULLDevice.cpp
- intern/AUD_NULLDevice.h
- intern/AUD_PyInit.h
- intern/AUD_ReadDevice.cpp
- intern/AUD_ReadDevice.h
- 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
- intern/AUD_SequencerFactory.h
- intern/AUD_SequencerHandle.cpp
- intern/AUD_SequencerHandle.h
- intern/AUD_SequencerReader.cpp
- intern/AUD_SequencerReader.h
- intern/AUD_Set.cpp
- intern/AUD_Set.h
- intern/AUD_SilenceFactory.cpp
- intern/AUD_SilenceFactory.h
- intern/AUD_SilenceReader.cpp
- intern/AUD_SilenceReader.h
- intern/AUD_SinusFactory.cpp
- intern/AUD_SinusFactory.h
- intern/AUD_SinusReader.cpp
- intern/AUD_SinusReader.h
- intern/AUD_SoftwareDevice.cpp
- intern/AUD_SoftwareDevice.h
- intern/AUD_Space.h
- intern/AUD_StreamBufferFactory.cpp
- intern/AUD_StreamBufferFactory.h
-
- FX/AUD_AccumulatorFactory.h
- FX/AUD_BandpassCalculator.h
- FX/AUD_BaseIIRFilterReader.h
- FX/AUD_ButterworthCalculator.h
- FX/AUD_ButterworthFactory.h
- FX/AUD_CallbackIIRFilterReader.h
- FX/AUD_DelayFactory.h
- 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
- FX/AUD_EffectReader.h
- FX/AUD_EnvelopeFactory.h
- FX/AUD_FaderFactory.h
- FX/AUD_FaderReader.h
- FX/AUD_HighpassCalculator.h
- FX/AUD_HighpassFactory.h
- FX/AUD_IIRFilterFactory.h
- FX/AUD_IIRFilterReader.h
- FX/AUD_LimiterFactory.h
- FX/AUD_LimiterReader.h
- FX/AUD_LoopFactory.h
- FX/AUD_LoopReader.h
- FX/AUD_LowpassCalculator.h
- FX/AUD_LowpassFactory.h
- FX/AUD_PingPongFactory.h
- FX/AUD_PitchFactory.h
- FX/AUD_PitchReader.h
- FX/AUD_RectifyFactory.h
- FX/AUD_ReverseFactory.h
- FX/AUD_ReverseReader.h
- FX/AUD_SquareFactory.h
- FX/AUD_SumFactory.h
- FX/AUD_SuperposeFactory.h
- FX/AUD_SuperposeReader.h
- FX/AUD_VolumeFactory.h
-)
-
-if(WITH_CODEC_FFMPEG)
- add_definitions(-DWITH_FFMPEG)
- list(APPEND INC
- ffmpeg
- )
- list(APPEND INC_SYS
- ${FFMPEG_INCLUDE_DIRS}
- )
- list(APPEND SRC
- ffmpeg/AUD_FFMPEGFactory.cpp
- ffmpeg/AUD_FFMPEGReader.cpp
- ffmpeg/AUD_FFMPEGWriter.cpp
-
- ffmpeg/AUD_FFMPEGFactory.h
- ffmpeg/AUD_FFMPEGReader.h
- ffmpeg/AUD_FFMPEGWriter.h
- )
-
- remove_strict_flags_file(
- ffmpeg/AUD_FFMPEGFactory.cpp
- ffmpeg/AUD_FFMPEGReader.cpp
- ffmpeg/AUD_FFMPEGWriter.cpp
- )
-endif()
-
-if(WITH_SDL)
- add_definitions(-DWITH_SDL)
- list(APPEND INC
- SDL
- )
- list(APPEND INC_SYS
- ${SDL_INCLUDE_DIR}
- )
- list(APPEND SRC
- SDL/AUD_SDLDevice.cpp
-
- SDL/AUD_SDLDevice.h
- )
-endif()
-
-if(WITH_OPENAL)
- add_definitions(-DWITH_OPENAL)
- list(APPEND INC
- OpenAL
- )
- list(APPEND INC_SYS
- ${OPENAL_INCLUDE_DIR}
- )
- list(APPEND SRC
- OpenAL/AUD_OpenALDevice.cpp
-
- OpenAL/AUD_OpenALDevice.h
- )
-endif()
-
-if(WITH_JACK)
- add_definitions(-DWITH_JACK)
- list(APPEND INC
- jack
- )
- list(APPEND INC_SYS
- ${JACK_INCLUDE_DIRS}
- )
- list(APPEND SRC
- jack/AUD_JackDevice.cpp
- jack/AUD_JackLibrary.cpp
-
- jack/AUD_JackDevice.h
- jack/AUD_JackLibrary.h
- )
-
- if(WITH_JACK_DYNLOAD)
- add_definitions(-DWITH_JACK_DYNLOAD)
- endif()
-endif()
-
-if(WITH_CODEC_SNDFILE)
- add_definitions(-DWITH_SNDFILE)
- list(APPEND INC
- sndfile
- )
- list(APPEND INC_SYS
- ${SNDFILE_INCLUDE_DIRS}
- )
- list(APPEND SRC
- sndfile/AUD_SndFileFactory.cpp
- sndfile/AUD_SndFileReader.cpp
- sndfile/AUD_SndFileWriter.cpp
-
- sndfile/AUD_SndFileFactory.h
- sndfile/AUD_SndFileReader.h
- sndfile/AUD_SndFileWriter.h
- )
-endif()
-
-if(WITH_FFTW3 AND FALSE)
- add_definitions(-DWITH_FFTW3)
- list(APPEND INC
- fftw
- )
- list(APPEND INC_SYS
- ${FFTW3_INCLUDE_DIRS}
- )
- list(APPEND SRC
- fftw/AUD_BandPassFactory.cpp
- fftw/AUD_BandPassReader.cpp
-
- fftw/AUD_BandPassFactory.h
- fftw/AUD_BandPassReader.h
- )
-endif()
-
-if(WITH_PYTHON)
- list(APPEND INC
- Python
- )
- list(APPEND INC_SYS
- ${PYTHON_INCLUDE_DIRS}
- )
- list(APPEND SRC
- Python/AUD_PyAPI.cpp
-
- Python/AUD_PyAPI.h
- )
- add_definitions(-DWITH_PYTHON)
-endif()
-endif()
-
blender_add_lib(bf_intern_audaspace "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/intern/audaspace/COPYING b/intern/audaspace/COPYING
deleted file mode 100644
index a330e6d9193..00000000000
--- a/intern/audaspace/COPYING
+++ /dev/null
@@ -1,339 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Lesser General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- 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.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License.
diff --git a/intern/audaspace/FX/AUD_AccumulatorFactory.cpp b/intern/audaspace/FX/AUD_AccumulatorFactory.cpp
deleted file mode 100644
index 00d3a9f2395..00000000000
--- a/intern/audaspace/FX/AUD_AccumulatorFactory.cpp
+++ /dev/null
@@ -1,64 +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/FX/AUD_AccumulatorFactory.cpp
- * \ingroup audfx
- */
-
-
-#include "AUD_AccumulatorFactory.h"
-#include "AUD_CallbackIIRFilterReader.h"
-
-sample_t AUD_AccumulatorFactory::accumulatorFilterAdditive(AUD_CallbackIIRFilterReader* reader, void* useless)
-{
- float in = reader->x(0);
- float lastin = reader->x(-1);
- float out = reader->y(-1) + in - lastin;
- if(in > lastin)
- out += in - lastin;
- return out;
-}
-
-sample_t AUD_AccumulatorFactory::accumulatorFilter(AUD_CallbackIIRFilterReader* reader, void* useless)
-{
- float in = reader->x(0);
- float lastin = reader->x(-1);
- float out = reader->y(-1);
- if(in > lastin)
- out += in - lastin;
- return out;
-}
-
-AUD_AccumulatorFactory::AUD_AccumulatorFactory(boost::shared_ptr<AUD_IFactory> factory,
- bool additive) :
- AUD_EffectFactory(factory),
- m_additive(additive)
-{
-}
-
-boost::shared_ptr<AUD_IReader> AUD_AccumulatorFactory::createReader()
-{
- 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
deleted file mode 100644
index 9087218a5f9..00000000000
--- a/intern/audaspace/FX/AUD_AccumulatorFactory.h
+++ /dev/null
@@ -1,69 +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/FX/AUD_AccumulatorFactory.h
- * \ingroup audfx
- */
-
-
-#ifndef __AUD_ACCUMULATORFACTORY_H__
-#define __AUD_ACCUMULATORFACTORY_H__
-
-#include "AUD_EffectFactory.h"
-class AUD_CallbackIIRFilterReader;
-
-/**
- * This factory creates an accumulator reader.
- *
- * The accumulator adds the difference at the input to the last output in case
- * it's positive. In additive mode it additionaly adds the difference always.
- * So in case the difference is positive, it's added twice.
- */
-class AUD_AccumulatorFactory : public AUD_EffectFactory
-{
-private:
- /**
- * Whether the accumulator is additive.
- */
- const bool m_additive;
-
- // hide copy constructor and operator=
- AUD_AccumulatorFactory(const AUD_AccumulatorFactory&);
- AUD_AccumulatorFactory& operator=(const AUD_AccumulatorFactory&);
-
-public:
- /**
- * Creates a new accumulator factory.
- * \param factory The input factory.
- * \param additive Whether the accumulator is additive.
- */
- AUD_AccumulatorFactory(boost::shared_ptr<AUD_IFactory> factory, bool additive = false);
-
- 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);
-};
-
-#endif //__AUD_ACCUMULATORFACTORY_H__
diff --git a/intern/audaspace/FX/AUD_BandpassCalculator.cpp b/intern/audaspace/FX/AUD_BandpassCalculator.cpp
deleted file mode 100644
index f5bbd63f81c..00000000000
--- a/intern/audaspace/FX/AUD_BandpassCalculator.cpp
+++ /dev/null
@@ -1,5 +0,0 @@
-#include "AUD_BandpassCalculator.h"
-
-AUD_BandpassCalculator::AUD_BandpassCalculator()
-{
-}
diff --git a/intern/audaspace/FX/AUD_BandpassCalculator.h b/intern/audaspace/FX/AUD_BandpassCalculator.h
deleted file mode 100644
index b5b3cad17ca..00000000000
--- a/intern/audaspace/FX/AUD_BandpassCalculator.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef AUD_BANDPASSCALCULATOR_H
-#define AUD_BANDPASSCALCULATOR_H
-
-class AUD_BandpassCalculator
-{
-public:
- AUD_BandpassCalculator();
-};
-
-#endif // AUD_BANDPASSCALCULATOR_H
diff --git a/intern/audaspace/FX/AUD_BaseIIRFilterReader.cpp b/intern/audaspace/FX/AUD_BaseIIRFilterReader.cpp
deleted file mode 100644
index eadfc525f96..00000000000
--- a/intern/audaspace/FX/AUD_BaseIIRFilterReader.cpp
+++ /dev/null
@@ -1,137 +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/FX/AUD_BaseIIRFilterReader.cpp
- * \ingroup audfx
- */
-
-
-#include "AUD_BaseIIRFilterReader.h"
-
-#include <cstring>
-
-#define CC m_specs.channels + m_channel
-
-AUD_BaseIIRFilterReader::AUD_BaseIIRFilterReader(boost::shared_ptr<AUD_IReader> reader, int in,
- int out) :
- AUD_EffectReader(reader),
- m_specs(reader->getSpecs()),
- m_xlen(in), m_ylen(out),
- m_xpos(0), m_ypos(0), m_channel(0)
-{
- m_x = new sample_t[m_xlen * m_specs.channels];
- m_y = new sample_t[m_ylen * m_specs.channels];
-
- memset(m_x, 0, sizeof(sample_t) * m_xlen * m_specs.channels);
- memset(m_y, 0, sizeof(sample_t) * m_ylen * m_specs.channels);
-}
-
-AUD_BaseIIRFilterReader::~AUD_BaseIIRFilterReader()
-{
- delete[] m_x;
- delete[] m_y;
-}
-
-void AUD_BaseIIRFilterReader::setLengths(int in, int out)
-{
- if(in != m_xlen)
- {
- sample_t* xn = new sample_t[in * m_specs.channels];
- memset(xn, 0, sizeof(sample_t) * in * m_specs.channels);
-
- for(m_channel = 0; m_channel < m_specs.channels; m_channel++)
- {
- for(int i = 1; i <= in && i <= m_xlen; i++)
- {
- xn[(in - i) * CC] = x(-i);
- }
- }
-
- delete[] m_x;
- m_x = xn;
- m_xpos = 0;
- m_xlen = in;
- }
-
- if(out != m_ylen)
- {
- sample_t* yn = new sample_t[out * m_specs.channels];
- memset(yn, 0, sizeof(sample_t) * out * m_specs.channels);
-
- for(m_channel = 0; m_channel < m_specs.channels; m_channel++)
- {
- for(int i = 1; i <= out && i <= m_ylen; i++)
- {
- yn[(out - i) * CC] = y(-i);
- }
- }
-
- delete[] m_y;
- m_y = yn;
- m_ypos = 0;
- m_ylen = out;
- }
-}
-
-void AUD_BaseIIRFilterReader::read(int& length, bool& eos, sample_t* buffer)
-{
- AUD_Specs specs = m_reader->getSpecs();
- if(specs.channels != m_specs.channels)
- {
- m_specs.channels = specs.channels;
-
- delete[] m_x;
- delete[] m_y;
-
- m_x = new sample_t[m_xlen * m_specs.channels];
- m_y = new sample_t[m_ylen * m_specs.channels];
-
- memset(m_x, 0, sizeof(sample_t) * m_xlen * m_specs.channels);
- memset(m_y, 0, sizeof(sample_t) * m_ylen * m_specs.channels);
- }
-
- if(specs.rate != m_specs.rate)
- {
- m_specs = specs;
- sampleRateChanged(m_specs.rate);
- }
-
- m_reader->read(length, eos, buffer);
-
- for(m_channel = 0; m_channel < m_specs.channels; m_channel++)
- {
- for(int i = 0; i < length; i++)
- {
- m_x[m_xpos * CC] = buffer[i * CC];
- m_y[m_ypos * CC] = buffer[i * CC] = filter();
-
- m_xpos = (m_xpos + 1) % m_xlen;
- m_ypos = (m_ypos + 1) % m_ylen;
- }
- }
-}
-
-void AUD_BaseIIRFilterReader::sampleRateChanged(AUD_SampleRate rate)
-{
-}
diff --git a/intern/audaspace/FX/AUD_ButterworthCalculator.cpp b/intern/audaspace/FX/AUD_ButterworthCalculator.cpp
deleted file mode 100644
index 7a3c6f71e15..00000000000
--- a/intern/audaspace/FX/AUD_ButterworthCalculator.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-#include "AUD_ButterworthCalculator.h"
-
-#include <cmath>
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-#define BWPB41 0.76536686473
-#define BWPB42 1.84775906502
-
-AUD_ButterworthCalculator::AUD_ButterworthCalculator(float frequency) :
- m_frequency(frequency)
-{
-}
-
-void AUD_ButterworthCalculator::recalculateCoefficients(AUD_SampleRate rate, std::vector<float> &b, std::vector<float> &a)
-{
- float omega = 2 * tan(m_frequency * M_PI / rate);
- float o2 = omega * omega;
- float o4 = o2 * o2;
- float x1 = o2 + 2.0f * (float)BWPB41 * omega + 4.0f;
- float x2 = o2 + 2.0f * (float)BWPB42 * omega + 4.0f;
- float y1 = o2 - 2.0f * (float)BWPB41 * omega + 4.0f;
- float y2 = o2 - 2.0f * (float)BWPB42 * omega + 4.0f;
- float o228 = 2.0f * o2 - 8.0f;
- float norm = x1 * x2;
- a.push_back(1);
- a.push_back((x1 + x2) * o228 / norm);
- a.push_back((x1 * y2 + x2 * y1 + o228 * o228) / norm);
- a.push_back((y1 + y2) * o228 / norm);
- a.push_back(y1 * y2 / norm);
- b.push_back(o4 / norm);
- b.push_back(4 * o4 / norm);
- b.push_back(6 * o4 / norm);
- b.push_back(b[1]);
- b.push_back(b[0]);
-}
diff --git a/intern/audaspace/FX/AUD_ButterworthCalculator.h b/intern/audaspace/FX/AUD_ButterworthCalculator.h
deleted file mode 100644
index a7ae196afda..00000000000
--- a/intern/audaspace/FX/AUD_ButterworthCalculator.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef AUD_BUTTERWORTHCALCULATOR_H
-#define AUD_BUTTERWORTHCALCULATOR_H
-
-#include "AUD_IDynamicIIRFilterCalculator.h"
-
-class AUD_ButterworthCalculator : public AUD_IDynamicIIRFilterCalculator
-{
-private:
- /**
- * The attack value in seconds.
- */
- const float m_frequency;
-
-public:
- AUD_ButterworthCalculator(float frequency);
-
- virtual void recalculateCoefficients(AUD_SampleRate rate, std::vector<float> &b, std::vector<float> &a);
-};
-
-#endif // AUD_BUTTERWORTHCALCULATOR_H
diff --git a/intern/audaspace/FX/AUD_ButterworthFactory.cpp b/intern/audaspace/FX/AUD_ButterworthFactory.cpp
deleted file mode 100644
index 12c4306c2f7..00000000000
--- a/intern/audaspace/FX/AUD_ButterworthFactory.cpp
+++ /dev/null
@@ -1,39 +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/FX/AUD_ButterworthFactory.cpp
- * \ingroup audfx
- */
-
-
-#include "AUD_ButterworthFactory.h"
-#include "AUD_IIRFilterReader.h"
-#include "AUD_ButterworthCalculator.h"
-
-AUD_ButterworthFactory::AUD_ButterworthFactory(boost::shared_ptr<AUD_IFactory> factory,
- float frequency) :
- AUD_DynamicIIRFilterFactory(factory, boost::shared_ptr<AUD_IDynamicIIRFilterCalculator>(new AUD_ButterworthCalculator(frequency)))
-{
-}
-
diff --git a/intern/audaspace/FX/AUD_ButterworthFactory.h b/intern/audaspace/FX/AUD_ButterworthFactory.h
deleted file mode 100644
index 3a86b14a7a6..00000000000
--- a/intern/audaspace/FX/AUD_ButterworthFactory.h
+++ /dev/null
@@ -1,54 +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/FX/AUD_ButterworthFactory.h
- * \ingroup audfx
- */
-
-
-#ifndef __AUD_BUTTERWORTHFACTORY_H__
-#define __AUD_BUTTERWORTHFACTORY_H__
-
-#include "AUD_DynamicIIRFilterFactory.h"
-
-/**
- * This factory creates a butterworth lowpass filter reader.
- */
-class AUD_ButterworthFactory : public AUD_DynamicIIRFilterFactory
-{
-private:
- // hide copy constructor and operator=
- AUD_ButterworthFactory(const AUD_ButterworthFactory&);
- AUD_ButterworthFactory& operator=(const AUD_ButterworthFactory&);
-
-public:
- /**
- * Creates a new butterworth factory.
- * \param factory The input factory.
- * \param frequency The cutoff frequency.
- */
- AUD_ButterworthFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency);
-};
-
-#endif //__AUD_BUTTERWORTHFACTORY_H__
diff --git a/intern/audaspace/FX/AUD_CallbackIIRFilterReader.cpp b/intern/audaspace/FX/AUD_CallbackIIRFilterReader.cpp
deleted file mode 100644
index b5157d47666..00000000000
--- a/intern/audaspace/FX/AUD_CallbackIIRFilterReader.cpp
+++ /dev/null
@@ -1,51 +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/FX/AUD_CallbackIIRFilterReader.cpp
- * \ingroup audfx
- */
-
-
-#include "AUD_CallbackIIRFilterReader.h"
-
-AUD_CallbackIIRFilterReader::AUD_CallbackIIRFilterReader(boost::shared_ptr<AUD_IReader> reader,
- int in, int out,
- doFilterIIR doFilter,
- endFilterIIR endFilter,
- void* data) :
- AUD_BaseIIRFilterReader(reader, in, out),
- m_filter(doFilter), m_endFilter(endFilter), m_data(data)
-{
-}
-
-AUD_CallbackIIRFilterReader::~AUD_CallbackIIRFilterReader()
-{
- if(m_endFilter)
- m_endFilter(m_data);
-}
-
-sample_t AUD_CallbackIIRFilterReader::filter()
-{
- return m_filter(this, m_data);
-}
diff --git a/intern/audaspace/FX/AUD_CallbackIIRFilterReader.h b/intern/audaspace/FX/AUD_CallbackIIRFilterReader.h
deleted file mode 100644
index 66f82ba1a01..00000000000
--- a/intern/audaspace/FX/AUD_CallbackIIRFilterReader.h
+++ /dev/null
@@ -1,87 +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/FX/AUD_CallbackIIRFilterReader.h
- * \ingroup audfx
- */
-
-
-#ifndef __AUD_CALLBACKIIRFILTERREADER_H__
-#define __AUD_CALLBACKIIRFILTERREADER_H__
-
-#include "AUD_BaseIIRFilterReader.h"
-#include "AUD_Buffer.h"
-
-class AUD_CallbackIIRFilterReader;
-
-typedef sample_t (*doFilterIIR)(AUD_CallbackIIRFilterReader*, void*);
-typedef void (*endFilterIIR)(void*);
-
-/**
- * This class provides an interface for infinite impulse response filters via a
- * callback filter function.
- */
-class AUD_CallbackIIRFilterReader : public AUD_BaseIIRFilterReader
-{
-private:
- /**
- * Filter function.
- */
- const doFilterIIR m_filter;
-
- /**
- * End filter function.
- */
- const endFilterIIR m_endFilter;
-
- /**
- * Data pointer.
- */
- void* m_data;
-
- // hide copy constructor and operator=
- AUD_CallbackIIRFilterReader(const AUD_CallbackIIRFilterReader&);
- AUD_CallbackIIRFilterReader& operator=(const AUD_CallbackIIRFilterReader&);
-
-public:
- /**
- * Creates a new callback IIR filter reader.
- * \param reader The reader to read from.
- * \param in The count of past input samples needed.
- * \param out The count of past output samples needed.
- * \param doFilter The filter callback.
- * \param endFilter The finishing callback.
- * \param data Data pointer for the callbacks.
- */
- AUD_CallbackIIRFilterReader(boost::shared_ptr<AUD_IReader> reader, int in, int out,
- doFilterIIR doFilter,
- endFilterIIR endFilter = 0,
- void* data = NULL);
-
- virtual ~AUD_CallbackIIRFilterReader();
-
- virtual sample_t filter();
-};
-
-#endif //__AUD_CALLBACKIIRFILTERREADER_H__
diff --git a/intern/audaspace/FX/AUD_DelayFactory.cpp b/intern/audaspace/FX/AUD_DelayFactory.cpp
deleted file mode 100644
index 3e5a7cfd2f8..00000000000
--- a/intern/audaspace/FX/AUD_DelayFactory.cpp
+++ /dev/null
@@ -1,48 +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/FX/AUD_DelayFactory.cpp
- * \ingroup audfx
- */
-
-
-#include "AUD_DelayFactory.h"
-#include "AUD_DelayReader.h"
-#include "AUD_Space.h"
-
-AUD_DelayFactory::AUD_DelayFactory(boost::shared_ptr<AUD_IFactory> factory, float delay) :
- AUD_EffectFactory(factory),
- m_delay(delay)
-{
-}
-
-float AUD_DelayFactory::getDelay() const
-{
- return m_delay;
-}
-
-boost::shared_ptr<AUD_IReader> AUD_DelayFactory::createReader()
-{
- 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
deleted file mode 100644
index 8cfb2be9ac8..00000000000
--- a/intern/audaspace/FX/AUD_DelayFactory.h
+++ /dev/null
@@ -1,66 +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/FX/AUD_DelayFactory.h
- * \ingroup audfx
- */
-
-
-#ifndef __AUD_DELAYFACTORY_H__
-#define __AUD_DELAYFACTORY_H__
-
-#include "AUD_EffectFactory.h"
-
-/**
- * This factory plays another factory delayed.
- */
-class AUD_DelayFactory : public AUD_EffectFactory
-{
-private:
- /**
- * The delay in samples.
- */
- const float m_delay;
-
- // hide copy constructor and operator=
- AUD_DelayFactory(const AUD_DelayFactory&);
- AUD_DelayFactory& operator=(const AUD_DelayFactory&);
-
-public:
- /**
- * Creates a new delay factory.
- * \param factory The input factory.
- * \param delay The desired delay in seconds.
- */
- AUD_DelayFactory(boost::shared_ptr<AUD_IFactory> factory, float delay = 0);
-
- /**
- * Returns the delay in seconds.
- */
- float getDelay() const;
-
- 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
deleted file mode 100644
index 050508f28da..00000000000
--- a/intern/audaspace/FX/AUD_DelayReader.cpp
+++ /dev/null
@@ -1,96 +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/FX/AUD_DelayReader.cpp
- * \ingroup audfx
- */
-
-
-#include "AUD_DelayReader.h"
-
-#include <cstring>
-
-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))
-{
-}
-
-void AUD_DelayReader::seek(int position)
-{
- if(position < m_delay)
- {
- m_remdelay = m_delay - position;
- m_reader->seek(0);
- }
- else
- {
- m_remdelay = 0;
- m_reader->seek(position - m_delay);
- }
-}
-
-int AUD_DelayReader::getLength() const
-{
- int len = m_reader->getLength();
- if(len < 0)
- return len;
- return len + m_delay;
-}
-
-int AUD_DelayReader::getPosition() const
-{
- if(m_remdelay > 0)
- return m_delay - m_remdelay;
- return m_reader->getPosition() + m_delay;
-}
-
-void AUD_DelayReader::read(int& length, bool& eos, sample_t* buffer)
-{
- if(m_remdelay > 0)
- {
- AUD_Specs specs = m_reader->getSpecs();
- int samplesize = AUD_SAMPLE_SIZE(specs);
-
- if(length > m_remdelay)
- {
- memset(buffer, 0, m_remdelay * samplesize);
-
- int len = length - m_remdelay;
- m_reader->read(len, eos, buffer + m_remdelay * specs.channels);
-
- length = m_remdelay + len;
-
- m_remdelay = 0;
- }
- else
- {
- memset(buffer, 0, length * samplesize);
- m_remdelay -= length;
- }
- }
- else
- m_reader->read(length, eos, buffer);
-}
diff --git a/intern/audaspace/FX/AUD_DelayReader.h b/intern/audaspace/FX/AUD_DelayReader.h
deleted file mode 100644
index d4388e3befc..00000000000
--- a/intern/audaspace/FX/AUD_DelayReader.h
+++ /dev/null
@@ -1,70 +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/FX/AUD_DelayReader.h
- * \ingroup audfx
- */
-
-
-#ifndef __AUD_DELAYREADER_H__
-#define __AUD_DELAYREADER_H__
-
-#include "AUD_EffectReader.h"
-#include "AUD_Buffer.h"
-
-/**
- * This class reads another reader and delays it.
- */
-class AUD_DelayReader : public AUD_EffectReader
-{
-private:
- /**
- * The delay level.
- */
- const int m_delay;
-
- /**
- * The remaining delay for playback.
- */
- int m_remdelay;
-
- // hide copy constructor and operator=
- AUD_DelayReader(const AUD_DelayReader&);
- AUD_DelayReader& operator=(const AUD_DelayReader&);
-
-public:
- /**
- * Creates a new delay reader.
- * \param reader The reader to read from.
- * \param delay The delay in seconds.
- */
- AUD_DelayReader(boost::shared_ptr<AUD_IReader> reader, float delay);
-
- virtual void seek(int position);
- virtual int getLength() const;
- virtual int getPosition() const;
- virtual void read(int& length, bool& eos, sample_t* buffer);
-};
-
-#endif //__AUD_DELAYREADER_H__
diff --git a/intern/audaspace/FX/AUD_DoubleFactory.cpp b/intern/audaspace/FX/AUD_DoubleFactory.cpp
deleted file mode 100644
index 21bcbc2f649..00000000000
--- a/intern/audaspace/FX/AUD_DoubleFactory.cpp
+++ /dev/null
@@ -1,44 +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/FX/AUD_DoubleFactory.cpp
- * \ingroup audfx
- */
-
-
-#include "AUD_DoubleFactory.h"
-#include "AUD_DoubleReader.h"
-
-AUD_DoubleFactory::AUD_DoubleFactory(boost::shared_ptr<AUD_IFactory> factory1, boost::shared_ptr<AUD_IFactory> factory2) :
- m_factory1(factory1), m_factory2(factory2)
-{
-}
-
-boost::shared_ptr<AUD_IReader> AUD_DoubleFactory::createReader()
-{
- boost::shared_ptr<AUD_IReader> reader1 = m_factory1->createReader();
- boost::shared_ptr<AUD_IReader> reader2 = m_factory2->createReader();
-
- 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
deleted file mode 100644
index 4a02cc7bcdb..00000000000
--- a/intern/audaspace/FX/AUD_DoubleFactory.h
+++ /dev/null
@@ -1,66 +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/FX/AUD_DoubleFactory.h
- * \ingroup audfx
- */
-
-
-#ifndef __AUD_DOUBLEFACTORY_H__
-#define __AUD_DOUBLEFACTORY_H__
-
-#include "AUD_IFactory.h"
-
-/**
- * This factory plays two other factories behind each other.
- */
-class AUD_DoubleFactory : public AUD_IFactory
-{
-private:
- /**
- * First played factory.
- */
- boost::shared_ptr<AUD_IFactory> m_factory1;
-
- /**
- * Second played factory.
- */
- boost::shared_ptr<AUD_IFactory> m_factory2;
-
- // hide copy constructor and operator=
- AUD_DoubleFactory(const AUD_DoubleFactory&);
- AUD_DoubleFactory& operator=(const AUD_DoubleFactory&);
-
-public:
- /**
- * Creates a new double factory.
- * \param factory1 The first input factory.
- * \param factory2 The second input factory.
- */
- AUD_DoubleFactory(boost::shared_ptr<AUD_IFactory> factory1, boost::shared_ptr<AUD_IFactory> factory2);
-
- 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
deleted file mode 100644
index ee18914e93f..00000000000
--- a/intern/audaspace/FX/AUD_DoubleReader.cpp
+++ /dev/null
@@ -1,112 +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/FX/AUD_DoubleReader.cpp
- * \ingroup audfx
- */
-
-
-#include "AUD_DoubleReader.h"
-
-#include <cstring>
-
-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;
- s1 = reader1->getSpecs();
- s2 = reader2->getSpecs();
-}
-
-AUD_DoubleReader::~AUD_DoubleReader()
-{
-}
-
-bool AUD_DoubleReader::isSeekable() const
-{
- return m_reader1->isSeekable() && m_reader2->isSeekable();
-}
-
-void AUD_DoubleReader::seek(int position)
-{
- m_reader1->seek(position);
-
- int pos1 = m_reader1->getPosition();
-
- if((m_finished1 = (pos1 < position)))
- m_reader2->seek(position - pos1);
- else
- m_reader2->seek(0);
-}
-
-int AUD_DoubleReader::getLength() const
-{
- int len1 = m_reader1->getLength();
- int len2 = m_reader2->getLength();
- if(len1 < 0 || len2 < 0)
- return -1;
- return len1 + len2;
-}
-
-int AUD_DoubleReader::getPosition() const
-{
- return m_reader1->getPosition() + m_reader2->getPosition();
-}
-
-AUD_Specs AUD_DoubleReader::getSpecs() const
-{
- return m_finished1 ? m_reader1->getSpecs() : m_reader2->getSpecs();
-}
-
-void AUD_DoubleReader::read(int& length, bool& eos, sample_t* buffer)
-{
- eos = false;
-
- if(!m_finished1)
- {
- int len = length;
-
- m_reader1->read(len, m_finished1, buffer);
-
- if(len < length)
- {
- AUD_Specs specs1, specs2;
- specs1 = m_reader1->getSpecs();
- specs2 = m_reader2->getSpecs();
- if(AUD_COMPARE_SPECS(specs1, specs2))
- {
- int len2 = length - len;
- m_reader2->read(len2, eos, buffer + specs1.channels * len);
- length = len + len2;
- }
- else
- length = len;
- }
- }
- else
- {
- m_reader2->read(length, eos, buffer);
- }
-}
diff --git a/intern/audaspace/FX/AUD_DoubleReader.h b/intern/audaspace/FX/AUD_DoubleReader.h
deleted file mode 100644
index 5d2f65f1a90..00000000000
--- a/intern/audaspace/FX/AUD_DoubleReader.h
+++ /dev/null
@@ -1,84 +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/FX/AUD_DoubleReader.h
- * \ingroup audfx
- */
-
-
-#ifndef __AUD_DOUBLEREADER_H__
-#define __AUD_DOUBLEREADER_H__
-
-#include "AUD_IReader.h"
-#include "AUD_Buffer.h"
-
-#include <boost/shared_ptr.hpp>
-
-/**
- * This reader plays two readers sequently.
- */
-class AUD_DoubleReader : public AUD_IReader
-{
-private:
- /**
- * The first reader.
- */
- boost::shared_ptr<AUD_IReader> m_reader1;
-
- /**
- * The second reader.
- */
- boost::shared_ptr<AUD_IReader> m_reader2;
-
- /**
- * Whether we've reached the end of the first reader.
- */
- bool m_finished1;
-
- // hide copy constructor and operator=
- AUD_DoubleReader(const AUD_DoubleReader&);
- AUD_DoubleReader& operator=(const AUD_DoubleReader&);
-
-public:
- /**
- * Creates a new double reader.
- * \param reader1 The first reader to read from.
- * \param reader2 The second reader to read from.
- */
- AUD_DoubleReader(boost::shared_ptr<AUD_IReader> reader1, boost::shared_ptr<AUD_IReader> reader2);
-
- /**
- * Destroys the reader.
- */
- virtual ~AUD_DoubleReader();
-
- virtual bool isSeekable() const;
- virtual void seek(int position);
- virtual int getLength() const;
- virtual int getPosition() const;
- virtual AUD_Specs getSpecs() const;
- virtual void read(int& length, bool& eos, sample_t* buffer);
-};
-
-#endif //__AUD_DOUBLEREADER_H__
diff --git a/intern/audaspace/FX/AUD_DynamicIIRFilterFactory.cpp b/intern/audaspace/FX/AUD_DynamicIIRFilterFactory.cpp
deleted file mode 100644
index 319a78cfedd..00000000000
--- a/intern/audaspace/FX/AUD_DynamicIIRFilterFactory.cpp
+++ /dev/null
@@ -1,44 +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/FX/AUD_DynamicIIRFilterFactory.cpp
- * \ingroup audfx
- */
-
-#include "AUD_DynamicIIRFilterFactory.h"
-#include "AUD_DynamicIIRFilterReader.h"
-
-
-AUD_DynamicIIRFilterFactory::AUD_DynamicIIRFilterFactory(boost::shared_ptr<AUD_IFactory> factory,
- boost::shared_ptr<AUD_IDynamicIIRFilterCalculator> calculator) :
- AUD_EffectFactory(factory),
- m_calculator(calculator)
-{
-}
-
-boost::shared_ptr<AUD_IReader> AUD_DynamicIIRFilterFactory::createReader()
-{
- 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
deleted file mode 100644
index aece7a8c2ef..00000000000
--- a/intern/audaspace/FX/AUD_DynamicIIRFilterFactory.h
+++ /dev/null
@@ -1,58 +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/FX/AUD_DynamicIIRFilterFactory.h
- * \ingroup audfx
- */
-
-#ifndef __AUD_DYNAMICIIRFILTERFACTORY_H__
-#define __AUD_DYNAMICIIRFILTERFACTORY_H__
-
-#include "AUD_EffectFactory.h"
-#include "AUD_IDynamicIIRFilterCalculator.h"
-#include <vector>
-
-/**
- * This factory creates a IIR filter reader.
- *
- * This means that on sample rate change the filter recalculates its
- * coefficients.
- */
-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(boost::shared_ptr<AUD_IFactory> factory,
- boost::shared_ptr<AUD_IDynamicIIRFilterCalculator> calculator);
-
- 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
deleted file mode 100644
index 52aaf2311c0..00000000000
--- a/intern/audaspace/FX/AUD_DynamicIIRFilterReader.cpp
+++ /dev/null
@@ -1,44 +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/FX/AUD_DynamicIIRFilterReader.cpp
- * \ingroup audfx
- */
-
-#include "AUD_DynamicIIRFilterReader.h"
-
-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_calculator(calculator)
-{
- sampleRateChanged(reader->getSpecs().rate);
-}
-
-void AUD_DynamicIIRFilterReader::sampleRateChanged(AUD_SampleRate rate)
-{
- std::vector<float> a, b;
- 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
deleted file mode 100644
index 0b68578bc53..00000000000
--- a/intern/audaspace/FX/AUD_DynamicIIRFilterReader.h
+++ /dev/null
@@ -1,54 +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/FX/AUD_DynamicIIRFilterReader.h
- * \ingroup audfx
- */
-
-#ifndef __AUD_DYNAMICIIRFILTERREADER_H__
-#define __AUD_DYNAMICIIRFILTERREADER_H__
-
-#include "AUD_IIRFilterReader.h"
-#include "AUD_IDynamicIIRFilterCalculator.h"
-
-/**
- * This class is for dynamic infinite impulse response filters with simple
- * coefficients that change depending on the sample rate.
- */
-class AUD_DynamicIIRFilterReader : public AUD_IIRFilterReader
-{
-private:
- /**
- * The factory for dynamically recalculating filter coefficients.
- */
- boost::shared_ptr<AUD_IDynamicIIRFilterCalculator> m_calculator;
-
-public:
- AUD_DynamicIIRFilterReader(boost::shared_ptr<AUD_IReader> reader,
- boost::shared_ptr<AUD_IDynamicIIRFilterCalculator> calculator);
-
- virtual void sampleRateChanged(AUD_SampleRate rate);
-};
-
-#endif // __AUD_DYNAMICIIRFILTERREADER_H__
diff --git a/intern/audaspace/FX/AUD_EffectFactory.cpp b/intern/audaspace/FX/AUD_EffectFactory.cpp
deleted file mode 100644
index 6018ed561ca..00000000000
--- a/intern/audaspace/FX/AUD_EffectFactory.cpp
+++ /dev/null
@@ -1,45 +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/FX/AUD_EffectFactory.cpp
- * \ingroup audfx
- */
-
-
-#include "AUD_EffectFactory.h"
-#include "AUD_IReader.h"
-
-AUD_EffectFactory::AUD_EffectFactory(boost::shared_ptr<AUD_IFactory> factory)
-{
- m_factory = factory;
-}
-
-AUD_EffectFactory::~AUD_EffectFactory()
-{
-}
-
-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
deleted file mode 100644
index d09872638be..00000000000
--- a/intern/audaspace/FX/AUD_EffectFactory.h
+++ /dev/null
@@ -1,82 +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/FX/AUD_EffectFactory.h
- * \ingroup audfx
- */
-
-
-#ifndef __AUD_EFFECTFACTORY_H__
-#define __AUD_EFFECTFACTORY_H__
-
-#include "AUD_IFactory.h"
-
-/**
- * This factory is a base class for all effect factories that take one other
- * factory as input.
- */
-class AUD_EffectFactory : public AUD_IFactory
-{
-private:
- // hide copy constructor and operator=
- AUD_EffectFactory(const AUD_EffectFactory&);
- AUD_EffectFactory& operator=(const AUD_EffectFactory&);
-
-protected:
- /**
- * If there is no reader it is created out of this factory.
- */
- boost::shared_ptr<AUD_IFactory> m_factory;
-
- /**
- * Returns the reader created out of the factory.
- * This method can be used for the createReader function of the implementing
- * classes.
- * \return The reader created out of the factory.
- */
- inline boost::shared_ptr<AUD_IReader> getReader() const
- {
- return m_factory->createReader();
- }
-
-public:
- /**
- * Creates a new factory.
- * \param factory The input factory.
- */
- AUD_EffectFactory(boost::shared_ptr<AUD_IFactory> factory);
-
- /**
- * Destroys the factory.
- */
- virtual ~AUD_EffectFactory();
-
- /**
- * Returns the saved factory.
- * \return The factory or NULL if there has no factory been saved.
- */
- 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
deleted file mode 100644
index b3e80bef03b..00000000000
--- a/intern/audaspace/FX/AUD_EffectReader.cpp
+++ /dev/null
@@ -1,69 +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/FX/AUD_EffectReader.cpp
- * \ingroup audfx
- */
-
-
-#include "AUD_EffectReader.h"
-
-AUD_EffectReader::AUD_EffectReader(boost::shared_ptr<AUD_IReader> reader)
-{
- m_reader = reader;
-}
-
-AUD_EffectReader::~AUD_EffectReader()
-{
-}
-
-bool AUD_EffectReader::isSeekable() const
-{
- return m_reader->isSeekable();
-}
-
-void AUD_EffectReader::seek(int position)
-{
- m_reader->seek(position);
-}
-
-int AUD_EffectReader::getLength() const
-{
- return m_reader->getLength();
-}
-
-int AUD_EffectReader::getPosition() const
-{
- return m_reader->getPosition();
-}
-
-AUD_Specs AUD_EffectReader::getSpecs() const
-{
- return m_reader->getSpecs();
-}
-
-void AUD_EffectReader::read(int& length, bool& eos, sample_t* buffer)
-{
- m_reader->read(length, eos, buffer);
-}
diff --git a/intern/audaspace/FX/AUD_EffectReader.h b/intern/audaspace/FX/AUD_EffectReader.h
deleted file mode 100644
index 2745c12afaf..00000000000
--- a/intern/audaspace/FX/AUD_EffectReader.h
+++ /dev/null
@@ -1,74 +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/FX/AUD_EffectReader.h
- * \ingroup audfx
- */
-
-
-#ifndef __AUD_EFFECTREADER_H__
-#define __AUD_EFFECTREADER_H__
-
-#include "AUD_IReader.h"
-
-#include <boost/shared_ptr.hpp>
-
-/**
- * This reader is a base class for all effect readers that take one other reader
- * as input.
- */
-class AUD_EffectReader : public AUD_IReader
-{
-private:
- // hide copy constructor and operator=
- AUD_EffectReader(const AUD_EffectReader&);
- AUD_EffectReader& operator=(const AUD_EffectReader&);
-
-protected:
- /**
- * The reader to read from.
- */
- boost::shared_ptr<AUD_IReader> m_reader;
-
-public:
- /**
- * Creates a new effect reader.
- * \param reader The reader to read from.
- */
- AUD_EffectReader(boost::shared_ptr<AUD_IReader> reader);
-
- /**
- * Destroys the reader.
- */
- virtual ~AUD_EffectReader();
-
- virtual bool isSeekable() const;
- virtual void seek(int position);
- virtual int getLength() const;
- virtual int getPosition() const;
- virtual AUD_Specs getSpecs() const;
- virtual void read(int& length, bool& eos, sample_t* buffer);
-};
-
-#endif //__AUD_EFFECTREADER_H__
diff --git a/intern/audaspace/FX/AUD_EnvelopeFactory.cpp b/intern/audaspace/FX/AUD_EnvelopeFactory.cpp
deleted file mode 100644
index 1e5737557c1..00000000000
--- a/intern/audaspace/FX/AUD_EnvelopeFactory.cpp
+++ /dev/null
@@ -1,82 +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/FX/AUD_EnvelopeFactory.cpp
- * \ingroup audfx
- */
-
-
-#include "AUD_EnvelopeFactory.h"
-#include "AUD_CallbackIIRFilterReader.h"
-
-#include <cmath>
-
-struct EnvelopeParameters
-{
- float attack;
- float release;
- float threshold;
- float arthreshold;
-};
-
-sample_t AUD_EnvelopeFactory::envelopeFilter(AUD_CallbackIIRFilterReader* reader, EnvelopeParameters* param)
-{
- float in = fabs(reader->x(0));
- float out = reader->y(-1);
- if(in < param->threshold)
- in = 0.0f;
- return (in > out ? param->attack : param->release) * (out - in) + in;
-}
-
-void AUD_EnvelopeFactory::endEnvelopeFilter(EnvelopeParameters* param)
-{
- delete param;
-}
-
-AUD_EnvelopeFactory::AUD_EnvelopeFactory(boost::shared_ptr<AUD_IFactory> factory, float attack,
- float release, float threshold,
- float arthreshold) :
- AUD_EffectFactory(factory),
- m_attack(attack),
- m_release(release),
- m_threshold(threshold),
- m_arthreshold(arthreshold)
-{
-}
-
-boost::shared_ptr<AUD_IReader> AUD_EnvelopeFactory::createReader()
-{
- boost::shared_ptr<AUD_IReader> reader = getReader();
-
- EnvelopeParameters* param = new EnvelopeParameters();
- param->arthreshold = m_arthreshold;
- param->attack = pow(m_arthreshold, 1.0f/(static_cast<float>(reader->getSpecs().rate) * m_attack));
- param->release = pow(m_arthreshold, 1.0f/(static_cast<float>(reader->getSpecs().rate) * m_release));
- param->threshold = m_threshold;
-
- return boost::shared_ptr<AUD_IReader>(new AUD_CallbackIIRFilterReader(reader, 1, 2,
- (doFilterIIR) envelopeFilter,
- (endFilterIIR) endEnvelopeFilter,
- param));
-}
diff --git a/intern/audaspace/FX/AUD_EnvelopeFactory.h b/intern/audaspace/FX/AUD_EnvelopeFactory.h
deleted file mode 100644
index 656212c8cac..00000000000
--- a/intern/audaspace/FX/AUD_EnvelopeFactory.h
+++ /dev/null
@@ -1,85 +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/FX/AUD_EnvelopeFactory.h
- * \ingroup audfx
- */
-
-
-#ifndef __AUD_ENVELOPEFACTORY_H__
-#define __AUD_ENVELOPEFACTORY_H__
-
-#include "AUD_EffectFactory.h"
-class AUD_CallbackIIRFilterReader;
-struct EnvelopeParameters;
-
-/**
- * This factory creates an envelope follower reader.
- */
-class AUD_EnvelopeFactory : public AUD_EffectFactory
-{
-private:
- /**
- * The attack value in seconds.
- */
- const float m_attack;
-
- /**
- * The release value in seconds.
- */
- const float m_release;
-
- /**
- * The threshold value.
- */
- const float m_threshold;
-
- /**
- * The attack/release threshold value.
- */
- const float m_arthreshold;
-
- // hide copy constructor and operator=
- AUD_EnvelopeFactory(const AUD_EnvelopeFactory&);
- AUD_EnvelopeFactory& operator=(const AUD_EnvelopeFactory&);
-
-public:
- /**
- * Creates a new envelope factory.
- * \param factory The input factory.
- * \param attack The attack value in seconds.
- * \param release The release value in seconds.
- * \param threshold The threshold value.
- * \param arthreshold The attack/release threshold value.
- */
- AUD_EnvelopeFactory(boost::shared_ptr<AUD_IFactory> factory, float attack, float release,
- float threshold, float arthreshold);
-
- virtual boost::shared_ptr<AUD_IReader> createReader();
-
- static sample_t envelopeFilter(AUD_CallbackIIRFilterReader* reader, EnvelopeParameters* param);
- static void endEnvelopeFilter(EnvelopeParameters* param);
-};
-
-#endif //__AUD_ENVELOPEFACTORY_H__
diff --git a/intern/audaspace/FX/AUD_FaderFactory.cpp b/intern/audaspace/FX/AUD_FaderFactory.cpp
deleted file mode 100644
index b34d2134385..00000000000
--- a/intern/audaspace/FX/AUD_FaderFactory.cpp
+++ /dev/null
@@ -1,60 +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/FX/AUD_FaderFactory.cpp
- * \ingroup audfx
- */
-
-
-#include "AUD_FaderFactory.h"
-#include "AUD_FaderReader.h"
-
-AUD_FaderFactory::AUD_FaderFactory(boost::shared_ptr<AUD_IFactory> factory, AUD_FadeType type,
- float start, float length) :
- AUD_EffectFactory(factory),
- m_type(type),
- m_start(start),
- m_length(length)
-{
-}
-
-AUD_FadeType AUD_FaderFactory::getType() const
-{
- return m_type;
-}
-
-float AUD_FaderFactory::getStart() const
-{
- return m_start;
-}
-
-float AUD_FaderFactory::getLength() const
-{
- return m_length;
-}
-
-boost::shared_ptr<AUD_IReader> AUD_FaderFactory::createReader()
-{
- 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
deleted file mode 100644
index f9ad88a751d..00000000000
--- a/intern/audaspace/FX/AUD_FaderFactory.h
+++ /dev/null
@@ -1,92 +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/FX/AUD_FaderFactory.h
- * \ingroup audfx
- */
-
-
-#ifndef __AUD_FADERFACTORY_H__
-#define __AUD_FADERFACTORY_H__
-
-#include "AUD_EffectFactory.h"
-
-/**
- * This factory fades another factory.
- * If the fading type is AUD_FADE_IN, everything before the fading start will be
- * silenced, for AUD_FADE_OUT that's true for everything after fading ends.
- */
-class AUD_FaderFactory : public AUD_EffectFactory
-{
-private:
- /**
- * The fading type.
- */
- const AUD_FadeType m_type;
-
- /**
- * The fading start.
- */
- const float m_start;
-
- /**
- * The fading length.
- */
- const float m_length;
-
- // hide copy constructor and operator=
- AUD_FaderFactory(const AUD_FaderFactory&);
- AUD_FaderFactory& operator=(const AUD_FaderFactory&);
-
-public:
- /**
- * Creates a new fader factory.
- * \param factory The input factory.
- * \param type The fading type.
- * \param start The time where fading should start in seconds.
- * \param length How long fading should last in seconds.
- */
- AUD_FaderFactory(boost::shared_ptr<AUD_IFactory> factory,
- AUD_FadeType type = AUD_FADE_IN,
- float start = 0.0f, float length = 1.0f);
-
- /**
- * Returns the fading type.
- */
- AUD_FadeType getType() const;
-
- /**
- * Returns the fading start.
- */
- float getStart() const;
-
- /**
- * Returns the fading length.
- */
- float getLength() const;
-
- 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
deleted file mode 100644
index e09072054cb..00000000000
--- a/intern/audaspace/FX/AUD_FaderReader.cpp
+++ /dev/null
@@ -1,86 +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/FX/AUD_FaderReader.cpp
- * \ingroup audfx
- */
-
-
-#include "AUD_FaderReader.h"
-
-#include <cstring>
-
-AUD_FaderReader::AUD_FaderReader(boost::shared_ptr<AUD_IReader> reader, AUD_FadeType type,
- float start,float length) :
- AUD_EffectReader(reader),
- m_type(type),
- m_start(start),
- m_length(length)
-{
-}
-
-void AUD_FaderReader::read(int& length, bool& eos, sample_t* buffer)
-{
- int position = m_reader->getPosition();
- AUD_Specs specs = m_reader->getSpecs();
- int samplesize = AUD_SAMPLE_SIZE(specs);
-
- m_reader->read(length, eos, buffer);
-
- if((position + length) / (float)specs.rate <= m_start)
- {
- if(m_type != AUD_FADE_OUT)
- {
- memset(buffer, 0, length * samplesize);
- }
- }
- else if(position / (float)specs.rate >= m_start+m_length)
- {
- if(m_type == AUD_FADE_OUT)
- {
- memset(buffer, 0, length * samplesize);
- }
- }
- else
- {
- float volume = 1.0f;
-
- for(int i = 0; i < length * specs.channels; i++)
- {
- if(i % specs.channels == 0)
- {
- volume = (((position+i)/(float)specs.rate)-m_start) / m_length;
- if(volume > 1.0f)
- volume = 1.0f;
- else if(volume < 0.0f)
- volume = 0.0f;
-
- if(m_type == AUD_FADE_OUT)
- volume = 1.0f - volume;
- }
-
- buffer[i] = buffer[i] * volume;
- }
- }
-}
diff --git a/intern/audaspace/FX/AUD_FaderReader.h b/intern/audaspace/FX/AUD_FaderReader.h
deleted file mode 100644
index a49960b30fb..00000000000
--- a/intern/audaspace/FX/AUD_FaderReader.h
+++ /dev/null
@@ -1,76 +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/FX/AUD_FaderReader.h
- * \ingroup audfx
- */
-
-
-#ifndef __AUD_FADERREADER_H__
-#define __AUD_FADERREADER_H__
-
-#include "AUD_EffectReader.h"
-#include "AUD_Buffer.h"
-
-/**
- * This class fades another reader.
- * If the fading type is AUD_FADE_IN, everything before the fading start will be
- * silenced, for AUD_FADE_OUT that's true for everything after fading ends.
- */
-class AUD_FaderReader : public AUD_EffectReader
-{
-private:
- /**
- * The fading type.
- */
- const AUD_FadeType m_type;
-
- /**
- * The fading start.
- */
- const float m_start;
-
- /**
- * The fading length.
- */
- const float m_length;
-
- // hide copy constructor and operator=
- AUD_FaderReader(const AUD_FaderReader&);
- AUD_FaderReader& operator=(const AUD_FaderReader&);
-
-public:
- /**
- * Creates a new fader reader.
- * \param type The fading type.
- * \param start The time where fading should start in seconds.
- * \param length How long fading should last in seconds.
- */
- 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);
-};
-
-#endif //__AUD_FADERREADER_H__
diff --git a/intern/audaspace/FX/AUD_HighpassCalculator.cpp b/intern/audaspace/FX/AUD_HighpassCalculator.cpp
deleted file mode 100644
index 573bba1c62b..00000000000
--- a/intern/audaspace/FX/AUD_HighpassCalculator.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-#include "AUD_HighpassCalculator.h"
-
-#include <cmath>
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-AUD_HighpassCalculator::AUD_HighpassCalculator(float frequency, float Q) :
- m_frequency(frequency),
- m_Q(Q)
-{
-}
-
-void AUD_HighpassCalculator::recalculateCoefficients(AUD_SampleRate rate, std::vector<float> &b, std::vector<float> &a)
-{
- float w0 = 2.0 * M_PI * (AUD_SampleRate)m_frequency / rate;
- float alpha = (float)(sin(w0) / (2.0 * (double)m_Q));
- float norm = 1 + alpha;
- float c = cos(w0);
- a.push_back(1);
- a.push_back(-2 * c / norm);
- a.push_back((1 - alpha) / norm);
- b.push_back((1 + c) / (2 * norm));
- b.push_back((-1 - c) / norm);
- b.push_back(b[0]);
-}
diff --git a/intern/audaspace/FX/AUD_HighpassCalculator.h b/intern/audaspace/FX/AUD_HighpassCalculator.h
deleted file mode 100644
index bad1c08f7c7..00000000000
--- a/intern/audaspace/FX/AUD_HighpassCalculator.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef AUD_HIGHPASSCALCULATOR_H
-#define AUD_HIGHPASSCALCULATOR_H
-
-#include "AUD_IDynamicIIRFilterCalculator.h"
-
-class AUD_HighpassCalculator : public AUD_IDynamicIIRFilterCalculator
-{
-private:
- /**
- * The cutoff frequency.
- */
- const float m_frequency;
-
- /**
- * The Q factor.
- */
- const float m_Q;
-
-public:
- AUD_HighpassCalculator(float frequency, float Q);
-
- virtual void recalculateCoefficients(AUD_SampleRate rate, std::vector<float> &b, std::vector<float> &a);
-};
-
-#endif // AUD_HIGHPASSCALCULATOR_H
diff --git a/intern/audaspace/FX/AUD_HighpassFactory.cpp b/intern/audaspace/FX/AUD_HighpassFactory.cpp
deleted file mode 100644
index 2456085a8a1..00000000000
--- a/intern/audaspace/FX/AUD_HighpassFactory.cpp
+++ /dev/null
@@ -1,39 +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/FX/AUD_HighpassFactory.cpp
- * \ingroup audfx
- */
-
-
-#include "AUD_HighpassFactory.h"
-#include "AUD_IIRFilterReader.h"
-#include "AUD_HighpassCalculator.h"
-
-AUD_HighpassFactory::AUD_HighpassFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency,
- float Q) :
- AUD_DynamicIIRFilterFactory(factory, boost::shared_ptr<AUD_IDynamicIIRFilterCalculator>(new AUD_HighpassCalculator(frequency, Q)))
-{
-}
-
diff --git a/intern/audaspace/FX/AUD_HighpassFactory.h b/intern/audaspace/FX/AUD_HighpassFactory.h
deleted file mode 100644
index 56ced91c53c..00000000000
--- a/intern/audaspace/FX/AUD_HighpassFactory.h
+++ /dev/null
@@ -1,55 +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/FX/AUD_HighpassFactory.h
- * \ingroup audfx
- */
-
-
-#ifndef __AUD_HIGHPASSFACTORY_H__
-#define __AUD_HIGHPASSFACTORY_H__
-
-#include "AUD_DynamicIIRFilterFactory.h"
-
-/**
- * This factory creates a highpass filter reader.
- */
-class AUD_HighpassFactory : public AUD_DynamicIIRFilterFactory
-{
-private:
- // hide copy constructor and operator=
- AUD_HighpassFactory(const AUD_HighpassFactory&);
- AUD_HighpassFactory& operator=(const AUD_HighpassFactory&);
-
-public:
- /**
- * Creates a new highpass factory.
- * \param factory The input factory.
- * \param frequency The cutoff frequency.
- * \param Q The Q factor.
- */
- AUD_HighpassFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency, float Q = 1.0f);
-};
-
-#endif //__AUD_HIGHPASSFACTORY_H__
diff --git a/intern/audaspace/FX/AUD_IDynamicIIRFilterCalculator.h b/intern/audaspace/FX/AUD_IDynamicIIRFilterCalculator.h
deleted file mode 100644
index 2e0d8418571..00000000000
--- a/intern/audaspace/FX/AUD_IDynamicIIRFilterCalculator.h
+++ /dev/null
@@ -1,56 +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/FX/AUD_IDynamicIIRFilterCalculator.h
- * \ingroup audfx
- */
-
-#ifndef AUD_IDYNAMICIIRFILTERCALCULATOR_H
-#define AUD_IDYNAMICIIRFILTERCALCULATOR_H
-
-#include "AUD_Space.h"
-
-#include <vector>
-
-/**
- * This interface calculates dynamic filter coefficients which depend on the
- * sampling rate for AUD_DynamicIIRFilterReaders.
- */
-class AUD_IDynamicIIRFilterCalculator
-{
-public:
- virtual ~AUD_IDynamicIIRFilterCalculator() {}
-
- /**
- * 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
deleted file mode 100644
index c4f94a2dc27..00000000000
--- a/intern/audaspace/FX/AUD_IIRFilterFactory.cpp
+++ /dev/null
@@ -1,43 +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/FX/AUD_IIRFilterFactory.cpp
- * \ingroup audfx
- */
-
-
-#include "AUD_IIRFilterFactory.h"
-#include "AUD_IIRFilterReader.h"
-
-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)
-{
-}
-
-boost::shared_ptr<AUD_IReader> AUD_IIRFilterFactory::createReader()
-{
- 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
deleted file mode 100644
index 0b55c120384..00000000000
--- a/intern/audaspace/FX/AUD_IIRFilterFactory.h
+++ /dev/null
@@ -1,71 +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/FX/AUD_IIRFilterFactory.h
- * \ingroup audfx
- */
-
-
-#ifndef __AUD_IIRFILTERFACTORY_H__
-#define __AUD_IIRFILTERFACTORY_H__
-
-#include "AUD_EffectFactory.h"
-#include "AUD_IDynamicIIRFilterCalculator.h"
-
-#include <vector>
-
-/**
- * This factory creates a IIR filter reader.
- */
-class AUD_IIRFilterFactory : public AUD_EffectFactory
-{
-private:
- /**
- * Output filter coefficients.
- */
- std::vector<float> m_a;
-
- /**
- * Input filter coefficients.
- */
- std::vector<float> m_b;
-
- // hide copy constructor and operator=
- AUD_IIRFilterFactory(const AUD_IIRFilterFactory&);
- AUD_IIRFilterFactory& operator=(const AUD_IIRFilterFactory&);
-
-public:
- /**
- * Creates a new IIR filter factory.
- * \param factory The input factory.
- * \param b The input filter coefficients.
- * \param a The output filter coefficients.
- */
- AUD_IIRFilterFactory(boost::shared_ptr<AUD_IFactory> factory, std::vector<float> b,
- std::vector<float> a);
-
- 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
deleted file mode 100644
index 6716e6b9ddc..00000000000
--- a/intern/audaspace/FX/AUD_IIRFilterReader.cpp
+++ /dev/null
@@ -1,65 +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/FX/AUD_IIRFilterReader.cpp
- * \ingroup audfx
- */
-
-
-#include "AUD_IIRFilterReader.h"
-
-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)
-{
- if(m_a.empty() == false)
- {
- for(int i = 1; i < m_a.size(); i++)
- m_a[i] /= m_a[0];
- for(int i = 0; i < m_b.size(); i++)
- m_b[i] /= m_a[0];
- m_a[0] = 1;
- }
-}
-
-sample_t AUD_IIRFilterReader::filter()
-{
- sample_t out = 0;
-
- for(int i = 1; i < m_a.size(); i++)
- out -= y(-i) * m_a[i];
- for(int i = 0; i < m_b.size(); i++)
- out += x(-i) * m_b[i];
-
- return out;
-}
-
-void AUD_IIRFilterReader::setCoefficients(const std::vector<float>& b,
- const std::vector<float>& a)
-{
- setLengths(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
deleted file mode 100644
index d663805b50f..00000000000
--- a/intern/audaspace/FX/AUD_IIRFilterReader.h
+++ /dev/null
@@ -1,73 +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/FX/AUD_IIRFilterReader.h
- * \ingroup audfx
- */
-
-
-#ifndef __AUD_IIRFILTERREADER_H__
-#define __AUD_IIRFILTERREADER_H__
-
-#include "AUD_BaseIIRFilterReader.h"
-
-#include <vector>
-
-/**
- * This class is for infinite impulse response filters with simple coefficients.
- */
-class AUD_IIRFilterReader : public AUD_BaseIIRFilterReader
-{
-private:
- /**
- * Output filter coefficients.
- */
- std::vector<float> m_a;
-
- /**
- * Input filter coefficients.
- */
- std::vector<float> m_b;
-
- // hide copy constructor and operator=
- AUD_IIRFilterReader(const AUD_IIRFilterReader&);
- AUD_IIRFilterReader& operator=(const AUD_IIRFilterReader&);
-
-public:
- /**
- * Creates a new IIR filter reader.
- * \param reader The reader to read from.
- * \param b The input filter coefficients.
- * \param a The output filter coefficients.
- */
- AUD_IIRFilterReader(boost::shared_ptr<AUD_IReader> reader, const std::vector<float>& b,
- const std::vector<float>& a);
-
- virtual sample_t filter();
-
- void setCoefficients(const std::vector<float>& b,
- const std::vector<float>& a);
-};
-
-#endif //__AUD_IIRFILTERREADER_H__
diff --git a/intern/audaspace/FX/AUD_LimiterFactory.cpp b/intern/audaspace/FX/AUD_LimiterFactory.cpp
deleted file mode 100644
index 679ed3a6b8b..00000000000
--- a/intern/audaspace/FX/AUD_LimiterFactory.cpp
+++ /dev/null
@@ -1,55 +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/FX/AUD_LimiterFactory.cpp
- * \ingroup audfx
- */
-
-
-#include "AUD_LimiterFactory.h"
-#include "AUD_LimiterReader.h"
-#include "AUD_Space.h"
-
-AUD_LimiterFactory::AUD_LimiterFactory(boost::shared_ptr<AUD_IFactory> factory,
- float start, float end) :
- AUD_EffectFactory(factory),
- m_start(start),
- m_end(end)
-{
-}
-
-float AUD_LimiterFactory::getStart() const
-{
- return m_start;
-}
-
-float AUD_LimiterFactory::getEnd() const
-{
- return m_end;
-}
-
-boost::shared_ptr<AUD_IReader> AUD_LimiterFactory::createReader()
-{
- 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
deleted file mode 100644
index 0376952b4bd..00000000000
--- a/intern/audaspace/FX/AUD_LimiterFactory.h
+++ /dev/null
@@ -1,79 +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/FX/AUD_LimiterFactory.h
- * \ingroup audfx
- */
-
-
-#ifndef __AUD_LIMITERFACTORY_H__
-#define __AUD_LIMITERFACTORY_H__
-
-#include "AUD_EffectFactory.h"
-
-/**
- * This factory limits another factory in start and end time.
- */
-class AUD_LimiterFactory : public AUD_EffectFactory
-{
-private:
- /**
- * The start time.
- */
- const float m_start;
-
- /**
- * The end time.
- */
- const float m_end;
-
- // hide copy constructor and operator=
- AUD_LimiterFactory(const AUD_LimiterFactory&);
- AUD_LimiterFactory& operator=(const AUD_LimiterFactory&);
-
-public:
- /**
- * Creates a new limiter factory.
- * \param factory The input factory.
- * \param start The desired start time.
- * \param end The desired end time, a negative value signals that it should
- * play to the end.
- */
- AUD_LimiterFactory(boost::shared_ptr<AUD_IFactory> factory,
- float start = 0, float end = -1);
-
- /**
- * Returns the start time.
- */
- float getStart() const;
-
- /**
- * Returns the end time.
- */
- float getEnd() const;
-
- virtual boost::shared_ptr<AUD_IReader> createReader();
-};
-
-#endif //__AUD_LIMITERFACTORY_H__
diff --git a/intern/audaspace/FX/AUD_LimiterReader.h b/intern/audaspace/FX/AUD_LimiterReader.h
deleted file mode 100644
index 607eb9e5bec..00000000000
--- a/intern/audaspace/FX/AUD_LimiterReader.h
+++ /dev/null
@@ -1,71 +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/FX/AUD_LimiterReader.h
- * \ingroup audfx
- */
-
-
-#ifndef __AUD_LIMITERREADER_H__
-#define __AUD_LIMITERREADER_H__
-
-#include "AUD_EffectReader.h"
-
-/**
- * This reader limits another reader in start and end times.
- */
-class AUD_LimiterReader : public AUD_EffectReader
-{
-private:
- /**
- * The start sample: inclusive.
- */
- const float m_start;
-
- /**
- * The end sample: exlusive.
- */
- const float m_end;
-
- // hide copy constructor and operator=
- AUD_LimiterReader(const AUD_LimiterReader&);
- AUD_LimiterReader& operator=(const AUD_LimiterReader&);
-
-public:
- /**
- * Creates a new limiter reader.
- * \param reader The reader to read from.
- * \param start The desired start time (inclusive).
- * \param end The desired end time (sample exklusive), a negative value
- * signals that it should play to the end.
- */
- AUD_LimiterReader(boost::shared_ptr<AUD_IReader> reader, float start = 0, float end = -1);
-
- virtual void seek(int position);
- virtual int getLength() const;
- virtual int getPosition() const;
- virtual void read(int& length, bool& eos, sample_t* buffer);
-};
-
-#endif //__AUD_LIMITERREADER_H__
diff --git a/intern/audaspace/FX/AUD_LoopFactory.cpp b/intern/audaspace/FX/AUD_LoopFactory.cpp
deleted file mode 100644
index a9e83e349a0..00000000000
--- a/intern/audaspace/FX/AUD_LoopFactory.cpp
+++ /dev/null
@@ -1,47 +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/FX/AUD_LoopFactory.cpp
- * \ingroup audfx
- */
-
-
-#include "AUD_LoopFactory.h"
-#include "AUD_LoopReader.h"
-
-AUD_LoopFactory::AUD_LoopFactory(boost::shared_ptr<AUD_IFactory> factory, int loop) :
- AUD_EffectFactory(factory),
- m_loop(loop)
-{
-}
-
-int AUD_LoopFactory::getLoop() const
-{
- return m_loop;
-}
-
-boost::shared_ptr<AUD_IReader> AUD_LoopFactory::createReader()
-{
- 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
deleted file mode 100644
index 570536bee9a..00000000000
--- a/intern/audaspace/FX/AUD_LoopFactory.h
+++ /dev/null
@@ -1,68 +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/FX/AUD_LoopFactory.h
- * \ingroup audfx
- */
-
-
-#ifndef __AUD_LOOPFACTORY_H__
-#define __AUD_LOOPFACTORY_H__
-
-#include "AUD_EffectFactory.h"
-
-/**
- * This factory loops another factory.
- * \note The reader has to be seekable.
- */
-class AUD_LoopFactory : public AUD_EffectFactory
-{
-private:
- /**
- * The loop count.
- */
- const int m_loop;
-
- // hide copy constructor and operator=
- AUD_LoopFactory(const AUD_LoopFactory&);
- AUD_LoopFactory& operator=(const AUD_LoopFactory&);
-
-public:
- /**
- * Creates a new loop factory.
- * \param factory The input factory.
- * \param loop The desired loop count, negative values result in endless
- * looping.
- */
- AUD_LoopFactory(boost::shared_ptr<AUD_IFactory> factory, int loop = -1);
-
- /**
- * Returns the loop count.
- */
- int getLoop() const;
-
- 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
deleted file mode 100644
index 6fbcaa5af37..00000000000
--- a/intern/audaspace/FX/AUD_LoopReader.cpp
+++ /dev/null
@@ -1,101 +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/FX/AUD_LoopReader.cpp
- * \ingroup audfx
- */
-
-
-#include "AUD_LoopReader.h"
-#include "AUD_Buffer.h"
-
-#include <cstring>
-
-AUD_LoopReader::AUD_LoopReader(boost::shared_ptr<AUD_IReader> reader, int loop) :
- AUD_EffectReader(reader), m_count(loop), m_left(loop)
-{
-}
-
-void AUD_LoopReader::seek(int position)
-{
- int len = m_reader->getLength();
- if(len < 0)
- m_reader->seek(position);
- else
- {
- if(m_count >= 0)
- {
- m_left = m_count - (position / len);
- if(m_left < 0)
- m_left = 0;
- }
- m_reader->seek(position % len);
- }
-}
-
-int AUD_LoopReader::getLength() const
-{
- if(m_count < 0)
- return -1;
- return m_reader->getLength() * m_count;
-}
-
-int AUD_LoopReader::getPosition() const
-{
- return m_reader->getPosition() * (m_count < 0 ? 1 : m_count);
-}
-
-void AUD_LoopReader::read(int& length, bool& eos, sample_t* buffer)
-{
- const AUD_Specs specs = m_reader->getSpecs();
-
- int len = length;
-
- m_reader->read(length, eos, buffer);
-
- if(length < len && eos && m_left)
- {
- int pos = length;
- length = len;
-
- while(pos < length && eos && m_left)
- {
- if(m_left > 0)
- m_left--;
-
- m_reader->seek(0);
-
- len = length - pos;
- m_reader->read(len, eos, buffer + pos * specs.channels);
-
- // prevent endless loop
- if(!len)
- break;
-
- pos += len;
- }
-
- length = pos;
- }
-}
diff --git a/intern/audaspace/FX/AUD_LoopReader.h b/intern/audaspace/FX/AUD_LoopReader.h
deleted file mode 100644
index 12b8078b12d..00000000000
--- a/intern/audaspace/FX/AUD_LoopReader.h
+++ /dev/null
@@ -1,72 +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/FX/AUD_LoopReader.h
- * \ingroup audfx
- */
-
-
-#ifndef __AUD_LOOPREADER_H__
-#define __AUD_LOOPREADER_H__
-
-#include "AUD_EffectReader.h"
-#include "AUD_Buffer.h"
-
-/**
- * This class reads another reader and loops it.
- * \note The other reader must be seekable.
- */
-class AUD_LoopReader : public AUD_EffectReader
-{
-private:
- /**
- * The loop count.
- */
- const int m_count;
-
- /**
- * The left loop count.
- */
- int m_left;
-
- // hide copy constructor and operator=
- AUD_LoopReader(const AUD_LoopReader&);
- AUD_LoopReader& operator=(const AUD_LoopReader&);
-
-public:
- /**
- * Creates a new loop reader.
- * \param reader The reader to read from.
- * \param loop The desired loop count, negative values result in endless
- * looping.
- */
- AUD_LoopReader(boost::shared_ptr<AUD_IReader> reader, int loop);
-
- virtual void seek(int position);
- virtual int getLength() const;
- virtual int getPosition() const;
- virtual void read(int& length, bool& eos, sample_t* buffer);
-};
-
-#endif //__AUD_LOOPREADER_H__
diff --git a/intern/audaspace/FX/AUD_LowpassCalculator.cpp b/intern/audaspace/FX/AUD_LowpassCalculator.cpp
deleted file mode 100644
index 57452f09038..00000000000
--- a/intern/audaspace/FX/AUD_LowpassCalculator.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-#include "AUD_LowpassCalculator.h"
-
-#include <cmath>
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-AUD_LowpassCalculator::AUD_LowpassCalculator(float frequency, float Q) :
- m_frequency(frequency),
- m_Q(Q)
-{
-}
-
-void AUD_LowpassCalculator::recalculateCoefficients(AUD_SampleRate rate, std::vector<float> &b, std::vector<float> &a)
-{
- float w0 = 2 * M_PI * m_frequency / rate;
- float alpha = sin(w0) / (2 * m_Q);
- float norm = 1 + alpha;
- float c = cos(w0);
- a.push_back(1);
- a.push_back(-2 * c / norm);
- a.push_back((1 - alpha) / norm);
- b.push_back((1 - c) / (2 * norm));
- b.push_back((1 - c) / norm);
- b.push_back(b[0]);
-}
diff --git a/intern/audaspace/FX/AUD_LowpassCalculator.h b/intern/audaspace/FX/AUD_LowpassCalculator.h
deleted file mode 100644
index 18bb11feda7..00000000000
--- a/intern/audaspace/FX/AUD_LowpassCalculator.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef AUD_LOWPASSCALCULATOR_H
-#define AUD_LOWPASSCALCULATOR_H
-
-#include "AUD_IDynamicIIRFilterCalculator.h"
-
-class AUD_LowpassCalculator : public AUD_IDynamicIIRFilterCalculator
-{
-private:
- /**
- * The cutoff frequency.
- */
- const float m_frequency;
-
- /**
- * The Q factor.
- */
- const float m_Q;
-
-public:
- AUD_LowpassCalculator(float frequency, float Q);
-
- virtual void recalculateCoefficients(AUD_SampleRate rate, std::vector<float> &b, std::vector<float> &a);
-};
-
-#endif // AUD_LOWPASSCALCULATOR_H
diff --git a/intern/audaspace/FX/AUD_LowpassFactory.cpp b/intern/audaspace/FX/AUD_LowpassFactory.cpp
deleted file mode 100644
index bd225998392..00000000000
--- a/intern/audaspace/FX/AUD_LowpassFactory.cpp
+++ /dev/null
@@ -1,38 +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/FX/AUD_LowpassFactory.cpp
- * \ingroup audfx
- */
-
-
-#include "AUD_LowpassFactory.h"
-#include "AUD_IIRFilterReader.h"
-#include "AUD_LowpassCalculator.h"
-
-AUD_LowpassFactory::AUD_LowpassFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency,
- float Q) :
- AUD_DynamicIIRFilterFactory(factory, boost::shared_ptr<AUD_IDynamicIIRFilterCalculator>(new AUD_LowpassCalculator(frequency, Q)))
-{
-}
diff --git a/intern/audaspace/FX/AUD_LowpassFactory.h b/intern/audaspace/FX/AUD_LowpassFactory.h
deleted file mode 100644
index dfd8ab35521..00000000000
--- a/intern/audaspace/FX/AUD_LowpassFactory.h
+++ /dev/null
@@ -1,55 +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/FX/AUD_LowpassFactory.h
- * \ingroup audfx
- */
-
-
-#ifndef __AUD_LOWPASSFACTORY_H__
-#define __AUD_LOWPASSFACTORY_H__
-
-#include "AUD_DynamicIIRFilterFactory.h"
-
-/**
- * This factory creates a lowpass filter reader.
- */
-class AUD_LowpassFactory : public AUD_DynamicIIRFilterFactory
-{
-private:
- // hide copy constructor and operator=
- AUD_LowpassFactory(const AUD_LowpassFactory&);
- AUD_LowpassFactory& operator=(const AUD_LowpassFactory&);
-
-public:
- /**
- * Creates a new lowpass factory.
- * \param factory The input factory.
- * \param frequency The cutoff frequency.
- * \param Q The Q factor.
- */
- AUD_LowpassFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency, float Q = 1.0f);
-};
-
-#endif //__AUD_LOWPASSFACTORY_H__
diff --git a/intern/audaspace/FX/AUD_PingPongFactory.cpp b/intern/audaspace/FX/AUD_PingPongFactory.cpp
deleted file mode 100644
index 84e4b29415e..00000000000
--- a/intern/audaspace/FX/AUD_PingPongFactory.cpp
+++ /dev/null
@@ -1,46 +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/FX/AUD_PingPongFactory.cpp
- * \ingroup audfx
- */
-
-
-#include "AUD_PingPongFactory.h"
-#include "AUD_DoubleReader.h"
-#include "AUD_ReverseFactory.h"
-
-AUD_PingPongFactory::AUD_PingPongFactory(boost::shared_ptr<AUD_IFactory> factory) :
- AUD_EffectFactory(factory)
-{
-}
-
-boost::shared_ptr<AUD_IReader> AUD_PingPongFactory::createReader()
-{
- boost::shared_ptr<AUD_IReader> reader = getReader();
- AUD_ReverseFactory factory(m_factory);
- boost::shared_ptr<AUD_IReader> reader2 = factory.createReader();
-
- 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
deleted file mode 100644
index e8ee5c9e389..00000000000
--- a/intern/audaspace/FX/AUD_PingPongFactory.h
+++ /dev/null
@@ -1,56 +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/FX/AUD_PingPongFactory.h
- * \ingroup audfx
- */
-
-
-#ifndef __AUD_PINGPONGFACTORY_H__
-#define __AUD_PINGPONGFACTORY_H__
-
-#include "AUD_EffectFactory.h"
-
-/**
- * This factory plays another factory first normal, then reversed.
- * \note Readers from the underlying factory must be reversable with seeking.
- */
-class AUD_PingPongFactory : public AUD_EffectFactory
-{
-private:
- // hide copy constructor and operator=
- AUD_PingPongFactory(const AUD_PingPongFactory&);
- AUD_PingPongFactory& operator=(const AUD_PingPongFactory&);
-
-public:
- /**
- * Creates a new ping pong factory.
- * \param factory The input factory.
- */
- AUD_PingPongFactory(boost::shared_ptr<AUD_IFactory> factory);
-
- 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
deleted file mode 100644
index 9dc27a58162..00000000000
--- a/intern/audaspace/FX/AUD_PitchFactory.cpp
+++ /dev/null
@@ -1,43 +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/FX/AUD_PitchFactory.cpp
- * \ingroup audfx
- */
-
-
-#include "AUD_PitchFactory.h"
-#include "AUD_PitchReader.h"
-#include "AUD_Space.h"
-
-AUD_PitchFactory::AUD_PitchFactory(boost::shared_ptr<AUD_IFactory> factory, float pitch) :
- AUD_EffectFactory(factory),
- m_pitch(pitch)
-{
-}
-
-boost::shared_ptr<AUD_IReader> AUD_PitchFactory::createReader()
-{
- 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
deleted file mode 100644
index 159388b28dd..00000000000
--- a/intern/audaspace/FX/AUD_PitchFactory.h
+++ /dev/null
@@ -1,61 +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/FX/AUD_PitchFactory.h
- * \ingroup audfx
- */
-
-
-#ifndef __AUD_PITCHFACTORY_H__
-#define __AUD_PITCHFACTORY_H__
-
-#include "AUD_EffectFactory.h"
-
-/**
- * This factory changes the pitch of another factory.
- */
-class AUD_PitchFactory : public AUD_EffectFactory
-{
-private:
- /**
- * The pitch.
- */
- const float m_pitch;
-
- // hide copy constructor and operator=
- AUD_PitchFactory(const AUD_PitchFactory&);
- AUD_PitchFactory& operator=(const AUD_PitchFactory&);
-
-public:
- /**
- * Creates a new pitch factory.
- * \param factory The input factory.
- * \param pitch The desired pitch.
- */
- AUD_PitchFactory(boost::shared_ptr<AUD_IFactory> factory, float pitch);
-
- 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
deleted file mode 100644
index b3775c71a28..00000000000
--- a/intern/audaspace/FX/AUD_PitchReader.cpp
+++ /dev/null
@@ -1,54 +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/FX/AUD_PitchReader.cpp
- * \ingroup audfx
- */
-
-
-#include "AUD_PitchReader.h"
-
-AUD_PitchReader::AUD_PitchReader(boost::shared_ptr<AUD_IReader> reader, float pitch) :
- AUD_EffectReader(reader), m_pitch(pitch)
-{
-}
-
-AUD_Specs AUD_PitchReader::getSpecs() const
-{
- AUD_Specs specs = m_reader->getSpecs();
- specs.rate *= m_pitch;
- return specs;
-}
-
-float AUD_PitchReader::getPitch() const
-{
- return m_pitch;
-}
-
-void AUD_PitchReader::setPitch(float pitch)
-{
- if(pitch <= 0)
- pitch = 1;
- m_pitch = pitch;
-}
diff --git a/intern/audaspace/FX/AUD_PitchReader.h b/intern/audaspace/FX/AUD_PitchReader.h
deleted file mode 100644
index d22e589b05d..00000000000
--- a/intern/audaspace/FX/AUD_PitchReader.h
+++ /dev/null
@@ -1,73 +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/FX/AUD_PitchReader.h
- * \ingroup audfx
- */
-
-
-#ifndef __AUD_PITCHREADER_H__
-#define __AUD_PITCHREADER_H__
-
-#include "AUD_EffectReader.h"
-
-/**
- * This class reads another reader and changes it's pitch.
- */
-class AUD_PitchReader : public AUD_EffectReader
-{
-private:
- /**
- * The pitch level.
- */
- float m_pitch;
-
- // hide copy constructor and operator=
- AUD_PitchReader(const AUD_PitchReader&);
- AUD_PitchReader& operator=(const AUD_PitchReader&);
-
-public:
- /**
- * Creates a new pitch reader.
- * \param reader The reader to read from.
- * \param pitch The pitch value.
- */
- AUD_PitchReader(boost::shared_ptr<AUD_IReader> reader, float pitch);
-
- virtual AUD_Specs getSpecs() const;
-
- /**
- * Retrieves the pitch.
- * \return The current pitch value.
- */
- float getPitch() const;
-
- /**
- * Sets the pitch.
- * \param pitch The new pitch value.
- */
- void setPitch(float pitch);
-};
-
-#endif //__AUD_PITCHREADER_H__
diff --git a/intern/audaspace/FX/AUD_RectifyFactory.cpp b/intern/audaspace/FX/AUD_RectifyFactory.cpp
deleted file mode 100644
index 26bb5615dad..00000000000
--- a/intern/audaspace/FX/AUD_RectifyFactory.cpp
+++ /dev/null
@@ -1,48 +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/FX/AUD_RectifyFactory.cpp
- * \ingroup audfx
- */
-
-
-#include "AUD_RectifyFactory.h"
-#include "AUD_CallbackIIRFilterReader.h"
-
-#include <cmath>
-
-sample_t AUD_RectifyFactory::rectifyFilter(AUD_CallbackIIRFilterReader* reader, void* useless)
-{
- return fabs(reader->x(0));
-}
-
-AUD_RectifyFactory::AUD_RectifyFactory(boost::shared_ptr<AUD_IFactory> factory) :
- AUD_EffectFactory(factory)
-{
-}
-
-boost::shared_ptr<AUD_IReader> AUD_RectifyFactory::createReader()
-{
- 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
deleted file mode 100644
index eb595e43e4f..00000000000
--- a/intern/audaspace/FX/AUD_RectifyFactory.h
+++ /dev/null
@@ -1,58 +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/FX/AUD_RectifyFactory.h
- * \ingroup audfx
- */
-
-
-#ifndef __AUD_RECTIFYFACTORY_H__
-#define __AUD_RECTIFYFACTORY_H__
-
-#include "AUD_EffectFactory.h"
-class AUD_CallbackIIRFilterReader;
-
-/**
- * This factory rectifies another factory.
- */
-class AUD_RectifyFactory : public AUD_EffectFactory
-{
-private:
- // hide copy constructor and operator=
- AUD_RectifyFactory(const AUD_RectifyFactory&);
- AUD_RectifyFactory& operator=(const AUD_RectifyFactory&);
-
-public:
- /**
- * Creates a new rectify factory.
- * \param factory The input factory.
- */
- AUD_RectifyFactory(boost::shared_ptr<AUD_IFactory> factory);
-
- virtual boost::shared_ptr<AUD_IReader> createReader();
-
- static sample_t rectifyFilter(AUD_CallbackIIRFilterReader* reader, void* useless);
-};
-
-#endif //__AUD_RECTIFYFACTORY_H__
diff --git a/intern/audaspace/FX/AUD_ReverseFactory.cpp b/intern/audaspace/FX/AUD_ReverseFactory.cpp
deleted file mode 100644
index afb4ad2bec9..00000000000
--- a/intern/audaspace/FX/AUD_ReverseFactory.cpp
+++ /dev/null
@@ -1,42 +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/FX/AUD_ReverseFactory.cpp
- * \ingroup audfx
- */
-
-
-#include "AUD_ReverseFactory.h"
-#include "AUD_ReverseReader.h"
-#include "AUD_Space.h"
-
-AUD_ReverseFactory::AUD_ReverseFactory(boost::shared_ptr<AUD_IFactory> factory) :
- AUD_EffectFactory(factory)
-{
-}
-
-boost::shared_ptr<AUD_IReader> AUD_ReverseFactory::createReader()
-{
- 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
deleted file mode 100644
index 5b0c9e3c29a..00000000000
--- a/intern/audaspace/FX/AUD_ReverseFactory.h
+++ /dev/null
@@ -1,56 +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/FX/AUD_ReverseFactory.h
- * \ingroup audfx
- */
-
-
-#ifndef __AUD_REVERSEFACTORY_H__
-#define __AUD_REVERSEFACTORY_H__
-
-#include "AUD_EffectFactory.h"
-
-/**
- * This factory reads another factory reverted.
- * \note Readers from the underlying factory must be seekable.
- */
-class AUD_ReverseFactory : public AUD_EffectFactory
-{
-private:
- // hide copy constructor and operator=
- AUD_ReverseFactory(const AUD_ReverseFactory&);
- AUD_ReverseFactory& operator=(const AUD_ReverseFactory&);
-
-public:
- /**
- * Creates a new reverse factory.
- * \param factory The input factory.
- */
- AUD_ReverseFactory(boost::shared_ptr<AUD_IFactory> factory);
-
- 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
deleted file mode 100644
index c0a5962a299..00000000000
--- a/intern/audaspace/FX/AUD_ReverseReader.cpp
+++ /dev/null
@@ -1,105 +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/FX/AUD_ReverseReader.cpp
- * \ingroup audfx
- */
-
-
-#include "AUD_ReverseReader.h"
-
-#include <cstring>
-
-static const char* props_error = "AUD_ReverseReader: The reader has to be "
- "seekable and a finite length.";
-
-AUD_ReverseReader::AUD_ReverseReader(boost::shared_ptr<AUD_IReader> reader) :
- AUD_EffectReader(reader),
- m_length(reader->getLength()),
- m_position(0)
-{
- if(m_length < 0 || !reader->isSeekable())
- AUD_THROW(AUD_ERROR_PROPS, props_error);
-}
-
-void AUD_ReverseReader::seek(int position)
-{
- m_position = position;
-}
-
-int AUD_ReverseReader::getLength() const
-{
- return m_length;
-}
-
-int AUD_ReverseReader::getPosition() const
-{
- return m_position;
-}
-
-void AUD_ReverseReader::read(int& length, bool& eos, sample_t* buffer)
-{
- // first correct the length
- if(m_position + length > m_length)
- length = m_length - m_position;
-
- if(length <= 0)
- {
- length = 0;
- eos = true;
- return;
- }
-
- const AUD_Specs specs = getSpecs();
- const int samplesize = AUD_SAMPLE_SIZE(specs);
-
- sample_t temp[AUD_CHANNEL_MAX];
-
- int len = length;
-
- // read from reader
- m_reader->seek(m_length - m_position - len);
- m_reader->read(len, eos, buffer);
-
- // set null if reader didn't give enough data
- if(len < length)
- memset(buffer, 0, (length - len) * samplesize);
-
- // copy the samples reverted
- for(int i = 0; i < length / 2; i++)
- {
- memcpy(temp,
- buffer + (len - 1 - i) * specs.channels,
- samplesize);
- memcpy(buffer + (len - 1 - i) * specs.channels,
- buffer + i * specs.channels,
- samplesize);
- memcpy(buffer + i * specs.channels,
- temp,
- samplesize);
- }
-
- m_position += length;
- eos = false;
-}
diff --git a/intern/audaspace/FX/AUD_ReverseReader.h b/intern/audaspace/FX/AUD_ReverseReader.h
deleted file mode 100644
index 219047915bd..00000000000
--- a/intern/audaspace/FX/AUD_ReverseReader.h
+++ /dev/null
@@ -1,72 +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/FX/AUD_ReverseReader.h
- * \ingroup audfx
- */
-
-
-#ifndef __AUD_REVERSEREADER_H__
-#define __AUD_REVERSEREADER_H__
-
-#include "AUD_EffectReader.h"
-#include "AUD_Buffer.h"
-
-/**
- * This class reads another reader from back to front.
- * \note The underlying reader must be seekable.
- */
-class AUD_ReverseReader : public AUD_EffectReader
-{
-private:
- /**
- * The sample count.
- */
- const int m_length;
-
- /**
- * The current position.
- */
- int m_position;
-
- // hide copy constructor and operator=
- AUD_ReverseReader(const AUD_ReverseReader&);
- AUD_ReverseReader& operator=(const AUD_ReverseReader&);
-
-public:
- /**
- * Creates a new reverse reader.
- * \param reader The reader to read from.
- * \exception AUD_Exception Thrown if the reader specified has an
- * undeterminable/infinite length or is not seekable.
- */
- AUD_ReverseReader(boost::shared_ptr<AUD_IReader> reader);
-
- virtual void seek(int position);
- virtual int getLength() const;
- virtual int getPosition() const;
- virtual void read(int& length, bool& eos, sample_t* buffer);
-};
-
-#endif //__AUD_REVERSEREADER_H__
diff --git a/intern/audaspace/FX/AUD_SquareFactory.cpp b/intern/audaspace/FX/AUD_SquareFactory.cpp
deleted file mode 100644
index 4b4dccb6e6b..00000000000
--- a/intern/audaspace/FX/AUD_SquareFactory.cpp
+++ /dev/null
@@ -1,66 +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/FX/AUD_SquareFactory.cpp
- * \ingroup audfx
- */
-
-
-#include "AUD_SquareFactory.h"
-#include "AUD_CallbackIIRFilterReader.h"
-
-sample_t AUD_SquareFactory::squareFilter(AUD_CallbackIIRFilterReader* reader, float* threshold)
-{
- float in = reader->x(0);
- if(in >= *threshold)
- return 1;
- else if(in <= -*threshold)
- return -1;
- else
- return 0;
-}
-
-void AUD_SquareFactory::endSquareFilter(float* threshold)
-{
- delete threshold;
-}
-
-AUD_SquareFactory::AUD_SquareFactory(boost::shared_ptr<AUD_IFactory> factory, float threshold) :
- AUD_EffectFactory(factory),
- m_threshold(threshold)
-{
-}
-
-float AUD_SquareFactory::getThreshold() const
-{
- return m_threshold;
-}
-
-boost::shared_ptr<AUD_IReader> AUD_SquareFactory::createReader()
-{
- return boost::shared_ptr<AUD_IReader>(new AUD_CallbackIIRFilterReader(getReader(), 1, 1,
- (doFilterIIR) squareFilter,
- (endFilterIIR) endSquareFilter,
- new float(m_threshold)));
-}
diff --git a/intern/audaspace/FX/AUD_SquareFactory.h b/intern/audaspace/FX/AUD_SquareFactory.h
deleted file mode 100644
index 27e62b6f4cc..00000000000
--- a/intern/audaspace/FX/AUD_SquareFactory.h
+++ /dev/null
@@ -1,70 +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/FX/AUD_SquareFactory.h
- * \ingroup audfx
- */
-
-
-#ifndef __AUD_SQUAREFACTORY_H__
-#define __AUD_SQUAREFACTORY_H__
-
-#include "AUD_EffectFactory.h"
-class AUD_CallbackIIRFilterReader;
-
-/**
- * This factory Transforms any signal to a square signal.
- */
-class AUD_SquareFactory : public AUD_EffectFactory
-{
-private:
- /**
- * The threshold.
- */
- const float m_threshold;
-
- // hide copy constructor and operator=
- AUD_SquareFactory(const AUD_SquareFactory&);
- AUD_SquareFactory& operator=(const AUD_SquareFactory&);
-
-public:
- /**
- * Creates a new square factory.
- * \param factory The input factory.
- * \param threshold The threshold.
- */
- AUD_SquareFactory(boost::shared_ptr<AUD_IFactory> factory, float threshold = 0.0f);
-
- /**
- * Returns the threshold.
- */
- float getThreshold() const;
-
- virtual boost::shared_ptr<AUD_IReader> createReader();
-
- static sample_t squareFilter(AUD_CallbackIIRFilterReader* reader, float* threshold);
- static void endSquareFilter(float* threshold);
-};
-
-#endif //__AUD_SQUAREFACTORY_H__
diff --git a/intern/audaspace/FX/AUD_SumFactory.cpp b/intern/audaspace/FX/AUD_SumFactory.cpp
deleted file mode 100644
index 7f82233a0b7..00000000000
--- a/intern/audaspace/FX/AUD_SumFactory.cpp
+++ /dev/null
@@ -1,45 +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/FX/AUD_SumFactory.cpp
- * \ingroup audfx
- */
-
-
-#include "AUD_SumFactory.h"
-#include "AUD_IIRFilterReader.h"
-
-AUD_SumFactory::AUD_SumFactory(boost::shared_ptr<AUD_IFactory> factory) :
- AUD_EffectFactory(factory)
-{
-}
-
-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 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
deleted file mode 100644
index a916f3509cb..00000000000
--- a/intern/audaspace/FX/AUD_SumFactory.h
+++ /dev/null
@@ -1,55 +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/FX/AUD_SumFactory.h
- * \ingroup audfx
- */
-
-
-#ifndef __AUD_SUMFACTORY_H__
-#define __AUD_SUMFACTORY_H__
-
-#include "AUD_EffectFactory.h"
-
-/**
- * This factory creates a sum reader.
- */
-class AUD_SumFactory : public AUD_EffectFactory
-{
-private:
- // hide copy constructor and operator=
- AUD_SumFactory(const AUD_SumFactory&);
- AUD_SumFactory& operator=(const AUD_SumFactory&);
-
-public:
- /**
- * Creates a new sum factory.
- * \param factory The input factory.
- */
- AUD_SumFactory(boost::shared_ptr<AUD_IFactory> factory);
-
- 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
deleted file mode 100644
index 3efad37a5b3..00000000000
--- a/intern/audaspace/FX/AUD_SuperposeFactory.cpp
+++ /dev/null
@@ -1,44 +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/FX/AUD_SuperposeFactory.cpp
- * \ingroup audfx
- */
-
-
-#include "AUD_SuperposeFactory.h"
-#include "AUD_SuperposeReader.h"
-
-AUD_SuperposeFactory::AUD_SuperposeFactory(boost::shared_ptr<AUD_IFactory> factory1, boost::shared_ptr<AUD_IFactory> factory2) :
- m_factory1(factory1), m_factory2(factory2)
-{
-}
-
-boost::shared_ptr<AUD_IReader> AUD_SuperposeFactory::createReader()
-{
- boost::shared_ptr<AUD_IReader> reader1 = m_factory1->createReader();
- boost::shared_ptr<AUD_IReader> reader2 = m_factory2->createReader();
-
- 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
deleted file mode 100644
index caa0dfb752f..00000000000
--- a/intern/audaspace/FX/AUD_SuperposeFactory.h
+++ /dev/null
@@ -1,68 +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/FX/AUD_SuperposeFactory.h
- * \ingroup audfx
- */
-
-
-#ifndef __AUD_SUPERPOSEFACTORY_H__
-#define __AUD_SUPERPOSEFACTORY_H__
-
-#include "AUD_IFactory.h"
-
-/**
- * This factory mixes two other factories, playing them the same time.
- * \note Readers from the underlying factories must have the same sample rate
- * and channel count.
- */
-class AUD_SuperposeFactory : public AUD_IFactory
-{
-private:
- /**
- * First played factory.
- */
- boost::shared_ptr<AUD_IFactory> m_factory1;
-
- /**
- * Second played factory.
- */
- boost::shared_ptr<AUD_IFactory> m_factory2;
-
- // hide copy constructor and operator=
- AUD_SuperposeFactory(const AUD_SuperposeFactory&);
- AUD_SuperposeFactory& operator=(const AUD_SuperposeFactory&);
-
-public:
- /**
- * Creates a new superpose factory.
- * \param factory1 The first input factory.
- * \param factory2 The second input factory.
- */
- AUD_SuperposeFactory(boost::shared_ptr<AUD_IFactory> factory1, boost::shared_ptr<AUD_IFactory> factory2);
-
- 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
deleted file mode 100644
index 294a48b3e7a..00000000000
--- a/intern/audaspace/FX/AUD_SuperposeReader.cpp
+++ /dev/null
@@ -1,105 +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/FX/AUD_SuperposeReader.cpp
- * \ingroup audfx
- */
-
-
-#include "AUD_SuperposeReader.h"
-
-#include <cstring>
-
-static const char* specs_error = "AUD_SuperposeReader: Both readers have to "
- "have the same specs.";
-
-AUD_SuperposeReader::AUD_SuperposeReader(boost::shared_ptr<AUD_IReader> reader1, boost::shared_ptr<AUD_IReader> reader2) :
- m_reader1(reader1), m_reader2(reader2)
-{
-}
-
-AUD_SuperposeReader::~AUD_SuperposeReader()
-{
-}
-
-bool AUD_SuperposeReader::isSeekable() const
-{
- return m_reader1->isSeekable() && m_reader2->isSeekable();
-}
-
-void AUD_SuperposeReader::seek(int position)
-{
- m_reader1->seek(position);
- m_reader2->seek(position);
-}
-
-int AUD_SuperposeReader::getLength() const
-{
- int len1 = m_reader1->getLength();
- int len2 = m_reader2->getLength();
- if((len1 < 0) || (len2 < 0))
- return -1;
- return AUD_MIN(len1, len2);
-}
-
-int AUD_SuperposeReader::getPosition() const
-{
- int pos1 = m_reader1->getPosition();
- int pos2 = m_reader2->getPosition();
- return AUD_MAX(pos1, pos2);
-}
-
-AUD_Specs AUD_SuperposeReader::getSpecs() const
-{
- return m_reader1->getSpecs();
-}
-
-void AUD_SuperposeReader::read(int& length, bool& eos, sample_t* buffer)
-{
- AUD_Specs specs = m_reader1->getSpecs();
- AUD_Specs s2 = m_reader2->getSpecs();
- if(!AUD_COMPARE_SPECS(specs, s2))
- AUD_THROW(AUD_ERROR_SPECS, specs_error);
-
- int samplesize = AUD_SAMPLE_SIZE(specs);
-
- m_buffer.assureSize(length * samplesize);
-
- int len1 = length;
- m_reader1->read(len1, eos, buffer);
-
- if(len1 < length)
- memset(buffer + len1 * specs.channels, 0, (length - len1) * samplesize);
-
- int len2 = length;
- bool eos2;
- sample_t* buf = m_buffer.getBuffer();
- m_reader2->read(len2, eos2, buf);
-
- for(int i = 0; i < len2 * specs.channels; i++)
- buffer[i] += buf[i];
-
- length = AUD_MAX(len1, len2);
- eos &= eos2;
-}
diff --git a/intern/audaspace/FX/AUD_SuperposeReader.h b/intern/audaspace/FX/AUD_SuperposeReader.h
deleted file mode 100644
index a04ab90fe43..00000000000
--- a/intern/audaspace/FX/AUD_SuperposeReader.h
+++ /dev/null
@@ -1,85 +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/FX/AUD_SuperposeReader.h
- * \ingroup audfx
- */
-
-
-#ifndef __AUD_SUPERPOSEREADER_H__
-#define __AUD_SUPERPOSEREADER_H__
-
-#include "AUD_IReader.h"
-#include "AUD_Buffer.h"
-
-#include <boost/shared_ptr.hpp>
-
-/**
- * This reader plays two readers with the same specs in parallel.
- */
-class AUD_SuperposeReader : public AUD_IReader
-{
-private:
- /**
- * The first reader.
- */
- boost::shared_ptr<AUD_IReader> m_reader1;
-
- /**
- * The second reader.
- */
- boost::shared_ptr<AUD_IReader> m_reader2;
-
- /**
- * Buffer used for mixing.
- */
- AUD_Buffer m_buffer;
-
- // hide copy constructor and operator=
- AUD_SuperposeReader(const AUD_SuperposeReader&);
- AUD_SuperposeReader& operator=(const AUD_SuperposeReader&);
-
-public:
- /**
- * Creates a new superpose reader.
- * \param reader1 The first reader to read from.
- * \param reader2 The second reader to read from.
- * \exception AUD_Exception Thrown if the specs from the readers differ.
- */
- AUD_SuperposeReader(boost::shared_ptr<AUD_IReader> reader1, boost::shared_ptr<AUD_IReader> reader2);
-
- /**
- * Destroys the reader.
- */
- virtual ~AUD_SuperposeReader();
-
- virtual bool isSeekable() const;
- virtual void seek(int position);
- virtual int getLength() const;
- virtual int getPosition() const;
- virtual AUD_Specs getSpecs() const;
- virtual void read(int& length, bool& eos, sample_t* buffer);
-};
-
-#endif //__AUD_SUPERPOSEREADER_H__
diff --git a/intern/audaspace/FX/AUD_VolumeFactory.cpp b/intern/audaspace/FX/AUD_VolumeFactory.cpp
deleted file mode 100644
index 4f0e1e425e6..00000000000
--- a/intern/audaspace/FX/AUD_VolumeFactory.cpp
+++ /dev/null
@@ -1,50 +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/FX/AUD_VolumeFactory.cpp
- * \ingroup audfx
- */
-
-
-#include "AUD_VolumeFactory.h"
-#include "AUD_IIRFilterReader.h"
-
-AUD_VolumeFactory::AUD_VolumeFactory(boost::shared_ptr<AUD_IFactory> factory, float volume) :
- AUD_EffectFactory(factory),
- m_volume(volume)
-{
-}
-
-float AUD_VolumeFactory::getVolume() const
-{
- return m_volume;
-}
-
-boost::shared_ptr<AUD_IReader> AUD_VolumeFactory::createReader()
-{
- std::vector<float> a, b;
- a.push_back(1);
- b.push_back(m_volume);
- 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
deleted file mode 100644
index 6fe779ffb88..00000000000
--- a/intern/audaspace/FX/AUD_VolumeFactory.h
+++ /dev/null
@@ -1,69 +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/FX/AUD_VolumeFactory.h
- * \ingroup audfx
- */
-
-
-#ifndef __AUD_VOLUMEFACTORY_H__
-#define __AUD_VOLUMEFACTORY_H__
-
-#include "AUD_EffectFactory.h"
-
-/**
- * This factory changes the volume of another factory.
- * The set volume should be a value between 0.0 and 1.0, higher values at your
- * own risk!
- */
-class AUD_VolumeFactory : public AUD_EffectFactory
-{
-private:
- /**
- * The volume.
- */
- const float m_volume;
-
- // hide copy constructor and operator=
- AUD_VolumeFactory(const AUD_VolumeFactory&);
- AUD_VolumeFactory& operator=(const AUD_VolumeFactory&);
-
-public:
- /**
- * Creates a new volume factory.
- * \param factory The input factory.
- * \param volume The desired volume.
- */
- AUD_VolumeFactory(boost::shared_ptr<AUD_IFactory> factory, float volume);
-
- /**
- * Returns the volume.
- * \return The current volume.
- */
- float getVolume() const;
-
- 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
deleted file mode 100644
index c0c77b6f917..00000000000
--- a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
+++ /dev/null
@@ -1,1647 +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/OpenAL/AUD_OpenALDevice.cpp
- * \ingroup audopenal
- */
-
-
-#include "AUD_OpenALDevice.h"
-#include "AUD_IFactory.h"
-#include "AUD_IReader.h"
-#include "AUD_ConverterReader.h"
-#include "AUD_MutexLock.h"
-
-#include <cstring>
-#include <limits>
-
-#ifdef WIN32
-#include <windows.h>
-#else
-#include <unistd.h>
-#endif
-
-/*struct AUD_OpenALBufferedFactory
-{
- /// The factory.
- AUD_IFactory* factory;
-
- /// The OpenAL buffer.
- ALuint buffer;
-};*/
-
-//typedef std::list<AUD_OpenALBufferedFactory*>::iterator AUD_BFIterator;
-
-
-/******************************************************************************/
-/*********************** AUD_OpenALHandle Handle Code *************************/
-/******************************************************************************/
-
-static const char* genbuffer_error = "AUD_OpenALDevice: Buffer couldn't be "
- "generated.";
-static const char* gensource_error = "AUD_OpenALDevice: Source couldn't be "
- "generated.";
-static const char* queue_error = "AUD_OpenALDevice: Buffer couldn't be "
- "queued to the source.";
-static const char* bufferdata_error = "AUD_OpenALDevice: Buffer couldn't be "
- "filled with data.";
-
-bool AUD_OpenALDevice::AUD_OpenALHandle::pause(bool keep)
-{
- if(m_status)
- {
- AUD_MutexLock lock(*m_device);
-
- if(m_status == AUD_STATUS_PLAYING)
- {
- 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;
-
- m_device->m_playingSounds.erase(it);
- m_device->m_pausedSounds.push_back(This);
-
- alSourcePause(m_source);
-
- m_status = keep ? AUD_STATUS_STOPPED : AUD_STATUS_PAUSED;
-
- return true;
- }
- }
- }
- }
-
- return false;}
-
-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)
-{
- AUD_DeviceSpecs specs = m_device->m_specs;
- specs.specs = m_reader->getSpecs();
-
- // OpenAL playback code
- alGenBuffers(CYCLE_BUFFERS, m_buffers);
- if(alGetError() != AL_NO_ERROR)
- AUD_THROW(AUD_ERROR_OPENAL, genbuffer_error);
-
- try
- {
- m_device->m_buffer.assureSize(m_device->m_buffersize * AUD_DEVICE_SAMPLE_SIZE(specs));
- int length;
- bool eos;
-
- for(int i = 0; i < CYCLE_BUFFERS; i++)
- {
- length = m_device->m_buffersize;
- reader->read(length, eos, m_device->m_buffer.getBuffer());
-
- if(length == 0)
- {
- // AUD_XXX: TODO: don't fill all buffers and enqueue them later
- length = 1;
- memset(m_device->m_buffer.getBuffer(), 0, length * AUD_DEVICE_SAMPLE_SIZE(specs));
- }
-
- alBufferData(m_buffers[i], m_format, m_device->m_buffer.getBuffer(),
- length * AUD_DEVICE_SAMPLE_SIZE(specs),
- specs.rate);
- if(alGetError() != AL_NO_ERROR)
- AUD_THROW(AUD_ERROR_OPENAL, bufferdata_error);
- }
-
- alGenSources(1, &m_source);
- if(alGetError() != AL_NO_ERROR)
- AUD_THROW(AUD_ERROR_OPENAL, gensource_error);
-
- try
- {
- alSourceQueueBuffers(m_source, CYCLE_BUFFERS, m_buffers);
- if(alGetError() != AL_NO_ERROR)
- AUD_THROW(AUD_ERROR_OPENAL, queue_error);
- }
- catch(AUD_Exception&)
- {
- alDeleteSources(1, &m_source);
- throw;
- }
- }
- catch(AUD_Exception&)
- {
- alDeleteBuffers(CYCLE_BUFFERS, m_buffers);
- throw;
- }
- alSourcei(m_source, AL_SOURCE_RELATIVE, 1);
-}
-
-bool AUD_OpenALDevice::AUD_OpenALHandle::pause()
-{
- return pause(false);
-}
-
-bool AUD_OpenALDevice::AUD_OpenALHandle::resume()
-{
- if(m_status)
- {
- AUD_MutexLock lock(*m_device);
-
- if(m_status == AUD_STATUS_PAUSED)
- {
- 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->m_pausedSounds.erase(it);
- m_device->m_playingSounds.push_back(This);
-
- m_device->start();
- m_status = AUD_STATUS_PLAYING;
-
- return true;
- }
- }
- }
- }
-
- return false;
-}
-
-bool AUD_OpenALDevice::AUD_OpenALHandle::stop()
-{
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return false;
-
- m_status = AUD_STATUS_INVALID;
-
- alDeleteSources(1, &m_source);
- if(!m_isBuffered)
- alDeleteBuffers(CYCLE_BUFFERS, m_buffers);
-
- 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;
-
- m_device->m_playingSounds.erase(it);
-
- return true;
- }
- }
-
- for(AUD_HandleIterator it = m_device->m_pausedSounds.begin(); it != m_device->m_pausedSounds.end(); it++)
- {
- if(it->get() == this)
- {
- m_device->m_pausedSounds.erase(it);
- return true;
- }
- }
-
- return false;
-}
-
-bool AUD_OpenALDevice::AUD_OpenALHandle::getKeep()
-{
- if(m_status)
- return m_keep;
-
- return false;
-}
-
-bool AUD_OpenALDevice::AUD_OpenALHandle::setKeep(bool keep)
-{
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return false;
-
- m_keep = keep;
-
- return true;
-}
-
-bool AUD_OpenALDevice::AUD_OpenALHandle::seek(float position)
-{
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return false;
-
- if(m_isBuffered)
- alSourcef(m_source, AL_SEC_OFFSET, position);
- else
- {
- m_reader->seek((int)(position * m_reader->getSpecs().rate));
- m_eos = false;
-
- ALint info;
-
- alGetSourcei(m_source, AL_SOURCE_STATE, &info);
-
- // we need to stop playing sounds as well to clear the buffers
- // this might cause clicks, but fixes a bug regarding position determination
- if(info == AL_PAUSED || info == AL_PLAYING)
- alSourceStop(m_source);
-
- alSourcei(m_source, AL_BUFFER, 0);
- m_current = 0;
-
- ALenum err;
- if((err = alGetError()) == AL_NO_ERROR)
- {
- int length;
- AUD_DeviceSpecs specs = m_device->m_specs;
- specs.specs = m_reader->getSpecs();
- m_device->m_buffer.assureSize(m_device->m_buffersize * AUD_DEVICE_SAMPLE_SIZE(specs));
-
- for(int i = 0; i < CYCLE_BUFFERS; i++)
- {
- length = m_device->m_buffersize;
- m_reader->read(length, m_eos, m_device->m_buffer.getBuffer());
-
- if(length == 0)
- {
- // AUD_XXX: TODO: don't fill all buffers and enqueue them later
- length = 1;
- memset(m_device->m_buffer.getBuffer(), 0, length * AUD_DEVICE_SAMPLE_SIZE(specs));
- }
-
- alBufferData(m_buffers[i], m_format, m_device->m_buffer.getBuffer(),
- length * AUD_DEVICE_SAMPLE_SIZE(specs), specs.rate);
-
- if(alGetError() != AL_NO_ERROR)
- break;
- }
-
- if(m_loopcount != 0)
- m_eos = false;
-
- alSourceQueueBuffers(m_source, CYCLE_BUFFERS, m_buffers);
- }
-
- alSourceRewind(m_source);
- }
-
- if(m_status == AUD_STATUS_STOPPED)
- m_status = AUD_STATUS_PAUSED;
-
- return true;
-}
-
-float AUD_OpenALDevice::AUD_OpenALHandle::getPosition()
-{
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return 0.0f;
-
- float position = 0.0f;
-
- alGetSourcef(m_source, AL_SEC_OFFSET, &position);
-
- if(!m_isBuffered)
- {
- int queued;
-
- // this usually always returns CYCLE_BUFFERS
- alGetSourcei(m_source, AL_BUFFERS_QUEUED, &queued);
-
- AUD_Specs specs = m_reader->getSpecs();
- position += (m_reader->getPosition() - m_device->m_buffersize *
- queued) / (float)specs.rate;
- }
-
- return position;
-}
-
-AUD_Status AUD_OpenALDevice::AUD_OpenALHandle::getStatus()
-{
- return m_status;
-}
-
-float AUD_OpenALDevice::AUD_OpenALHandle::getVolume()
-{
- float result = std::numeric_limits<float>::quiet_NaN();
-
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return result;
-
- alGetSourcef(m_source, AL_GAIN, &result);
-
- return result;
-}
-
-bool AUD_OpenALDevice::AUD_OpenALHandle::setVolume(float volume)
-{
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return false;
-
- alSourcef(m_source, AL_GAIN, volume);
-
- return true;
-}
-
-float AUD_OpenALDevice::AUD_OpenALHandle::getPitch()
-{
- float result = std::numeric_limits<float>::quiet_NaN();
-
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return result;
-
- alGetSourcef(m_source, AL_PITCH, &result);
-
- return result;
-}
-
-bool AUD_OpenALDevice::AUD_OpenALHandle::setPitch(float pitch)
-{
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return false;
-
- alSourcef(m_source, AL_PITCH, pitch);
-
- return true;
-}
-
-int AUD_OpenALDevice::AUD_OpenALHandle::getLoopCount()
-{
- if(!m_status)
- return 0;
- return m_loopcount;
-}
-
-bool AUD_OpenALDevice::AUD_OpenALHandle::setLoopCount(int count)
-{
- if(!m_status)
- return false;
-
- if(m_status == AUD_STATUS_STOPPED && (count > m_loopcount || count < 0))
- m_status = AUD_STATUS_PAUSED;
-
- m_loopcount = count;
-
- return true;
-}
-
-bool AUD_OpenALDevice::AUD_OpenALHandle::setStopCallback(stopCallback callback, void* data)
-{
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return false;
-
- m_stop = callback;
- m_stop_data = data;
-
- return true;
-}
-
-/******************************************************************************/
-/********************* AUD_OpenALHandle 3DHandle Code *************************/
-/******************************************************************************/
-
-AUD_Vector3 AUD_OpenALDevice::AUD_OpenALHandle::getSourceLocation()
-{
- AUD_Vector3 result = AUD_Vector3(0, 0, 0);
-
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return result;
-
- ALfloat p[3];
- alGetSourcefv(m_source, AL_POSITION, p);
-
- result = AUD_Vector3(p[0], p[1], p[2]);
-
- return result;
-}
-
-bool AUD_OpenALDevice::AUD_OpenALHandle::setSourceLocation(const AUD_Vector3& location)
-{
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return false;
-
- alSourcefv(m_source, AL_POSITION, (ALfloat*)location.get());
-
- return true;
-}
-
-AUD_Vector3 AUD_OpenALDevice::AUD_OpenALHandle::getSourceVelocity()
-{
- AUD_Vector3 result = AUD_Vector3(0, 0, 0);
-
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return result;
-
- ALfloat v[3];
- alGetSourcefv(m_source, AL_VELOCITY, v);
-
- result = AUD_Vector3(v[0], v[1], v[2]);
-
- return result;
-}
-
-bool AUD_OpenALDevice::AUD_OpenALHandle::setSourceVelocity(const AUD_Vector3& velocity)
-{
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return false;
-
- alSourcefv(m_source, AL_VELOCITY, (ALfloat*)velocity.get());
-
- return true;
-}
-
-AUD_Quaternion AUD_OpenALDevice::AUD_OpenALHandle::getSourceOrientation()
-{
- return m_orientation;
-}
-
-bool AUD_OpenALDevice::AUD_OpenALHandle::setSourceOrientation(const AUD_Quaternion& orientation)
-{
- ALfloat direction[3];
- direction[0] = -2 * (orientation.w() * orientation.y() +
- orientation.x() * orientation.z());
- direction[1] = 2 * (orientation.x() * orientation.w() -
- orientation.z() * orientation.y());
- direction[2] = 2 * (orientation.x() * orientation.x() +
- orientation.y() * orientation.y()) - 1;
-
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return false;
-
- alSourcefv(m_source, AL_DIRECTION, direction);
-
- m_orientation = orientation;
-
- return true;
-}
-
-bool AUD_OpenALDevice::AUD_OpenALHandle::isRelative()
-{
- int result;
-
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return false;
-
- alGetSourcei(m_source, AL_SOURCE_RELATIVE, &result);
-
- return result;
-}
-
-bool AUD_OpenALDevice::AUD_OpenALHandle::setRelative(bool relative)
-{
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return false;
-
- alSourcei(m_source, AL_SOURCE_RELATIVE, relative);
-
- return true;
-}
-
-float AUD_OpenALDevice::AUD_OpenALHandle::getVolumeMaximum()
-{
- float result = std::numeric_limits<float>::quiet_NaN();
-
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return result;
-
- alGetSourcef(m_source, AL_MAX_GAIN, &result);
-
- return result;
-}
-
-bool AUD_OpenALDevice::AUD_OpenALHandle::setVolumeMaximum(float volume)
-{
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return false;
-
- alSourcef(m_source, AL_MAX_GAIN, volume);
-
- return true;
-}
-
-float AUD_OpenALDevice::AUD_OpenALHandle::getVolumeMinimum()
-{
- float result = std::numeric_limits<float>::quiet_NaN();
-
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return result;
-
- alGetSourcef(m_source, AL_MIN_GAIN, &result);
-
- return result;
-}
-
-bool AUD_OpenALDevice::AUD_OpenALHandle::setVolumeMinimum(float volume)
-{
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return false;
-
- alSourcef(m_source, AL_MIN_GAIN, volume);
-
- return true;
-}
-
-float AUD_OpenALDevice::AUD_OpenALHandle::getDistanceMaximum()
-{
- float result = std::numeric_limits<float>::quiet_NaN();
-
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return result;
-
- alGetSourcef(m_source, AL_MAX_DISTANCE, &result);
-
- return result;
-}
-
-bool AUD_OpenALDevice::AUD_OpenALHandle::setDistanceMaximum(float distance)
-{
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return false;
-
- alSourcef(m_source, AL_MAX_DISTANCE, distance);
-
- return true;
-}
-
-float AUD_OpenALDevice::AUD_OpenALHandle::getDistanceReference()
-{
- float result = std::numeric_limits<float>::quiet_NaN();
-
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return result;
-
- alGetSourcef(m_source, AL_REFERENCE_DISTANCE, &result);
-
- return result;
-}
-
-bool AUD_OpenALDevice::AUD_OpenALHandle::setDistanceReference(float distance)
-{
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return false;
-
- alSourcef(m_source, AL_REFERENCE_DISTANCE, distance);
-
- return true;
-}
-
-float AUD_OpenALDevice::AUD_OpenALHandle::getAttenuation()
-{
- float result = std::numeric_limits<float>::quiet_NaN();
-
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return result;
-
- alGetSourcef(m_source, AL_ROLLOFF_FACTOR, &result);
-
- return result;
-}
-
-bool AUD_OpenALDevice::AUD_OpenALHandle::setAttenuation(float factor)
-{
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return false;
-
- alSourcef(m_source, AL_ROLLOFF_FACTOR, factor);
-
- return true;
-}
-
-float AUD_OpenALDevice::AUD_OpenALHandle::getConeAngleOuter()
-{
- float result = std::numeric_limits<float>::quiet_NaN();
-
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return result;
-
- alGetSourcef(m_source, AL_CONE_OUTER_ANGLE, &result);
-
- return result;
-}
-
-bool AUD_OpenALDevice::AUD_OpenALHandle::setConeAngleOuter(float angle)
-{
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return false;
-
- alSourcef(m_source, AL_CONE_OUTER_ANGLE, angle);
-
- return true;
-}
-
-float AUD_OpenALDevice::AUD_OpenALHandle::getConeAngleInner()
-{
- float result = std::numeric_limits<float>::quiet_NaN();
-
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return result;
-
- alGetSourcef(m_source, AL_CONE_INNER_ANGLE, &result);
-
- return result;
-}
-
-bool AUD_OpenALDevice::AUD_OpenALHandle::setConeAngleInner(float angle)
-{
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return false;
-
- alSourcef(m_source, AL_CONE_INNER_ANGLE, angle);
-
- return true;
-}
-
-float AUD_OpenALDevice::AUD_OpenALHandle::getConeVolumeOuter()
-{
- float result = std::numeric_limits<float>::quiet_NaN();
-
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return result;
-
- alGetSourcef(m_source, AL_CONE_OUTER_GAIN, &result);
-
- return result;
-}
-
-bool AUD_OpenALDevice::AUD_OpenALHandle::setConeVolumeOuter(float volume)
-{
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return false;
-
- alSourcef(m_source, AL_CONE_OUTER_GAIN, volume);
-
- return true;
-}
-
-/******************************************************************************/
-/**************************** Threading Code **********************************/
-/******************************************************************************/
-
-static void *AUD_openalRunThread(void *device)
-{
- AUD_OpenALDevice* dev = (AUD_OpenALDevice*)device;
- dev->updateStreams();
- return NULL;
-}
-
-void AUD_OpenALDevice::start(bool join)
-{
- AUD_MutexLock lock(*this);
-
- if(!m_playing)
- {
- if(join)
- pthread_join(m_thread, NULL);
-
- pthread_attr_t attr;
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
-
- pthread_create(&m_thread, &attr, AUD_openalRunThread, this);
-
- pthread_attr_destroy(&attr);
-
- m_playing = true;
- }
-}
-
-void AUD_OpenALDevice::updateStreams()
-{
- boost::shared_ptr<AUD_OpenALHandle> sound;
-
- int length;
-
- ALint info;
- AUD_DeviceSpecs specs = m_specs;
- ALCenum cerr;
- std::list<boost::shared_ptr<AUD_OpenALHandle> > stopSounds;
- std::list<boost::shared_ptr<AUD_OpenALHandle> > pauseSounds;
- AUD_HandleIterator it;
-
- while(1)
- {
- lock();
-
- alcSuspendContext(m_context);
- cerr = alcGetError(m_device);
- if(cerr == ALC_NO_ERROR)
- {
- // for all sounds
- for(it = m_playingSounds.begin(); it != m_playingSounds.end(); it++)
- {
- sound = *it;
-
- // is it a streamed sound?
- if(!sound->m_isBuffered)
- {
- // check for buffer refilling
- alGetSourcei(sound->m_source, AL_BUFFERS_PROCESSED, &info);
-
- if(info)
- {
- specs.specs = sound->m_reader->getSpecs();
- m_buffer.assureSize(m_buffersize * AUD_DEVICE_SAMPLE_SIZE(specs));
-
- // for all empty buffers
- while(info--)
- {
- // if there's still data to play back
- if(!sound->m_eos)
- {
- // read data
- length = m_buffersize;
- sound->m_reader->read(length, sound->m_eos, m_buffer.getBuffer());
-
- // looping necessary?
- if(length == 0 && sound->m_loopcount)
- {
- if(sound->m_loopcount > 0)
- sound->m_loopcount--;
-
- sound->m_reader->seek(0);
-
- length = m_buffersize;
- sound->m_reader->read(length, sound->m_eos, m_buffer.getBuffer());
- }
-
- if(sound->m_loopcount != 0)
- sound->m_eos = false;
-
- // read nothing?
- if(length == 0)
- {
- break;
- }
-
- // unqueue buffer (warning: this might fail for slow early returning sources (none exist so far) if the buffer was not queued due to recent changes - has to be tested)
- alSourceUnqueueBuffers(sound->m_source, 1, &sound->m_buffers[sound->m_current]);
- ALenum err;
- if((err = alGetError()) != AL_NO_ERROR)
- {
- sound->m_eos = true;
- break;
- }
-
- // fill with new data
- alBufferData(sound->m_buffers[sound->m_current],
- sound->m_format,
- m_buffer.getBuffer(), length *
- AUD_DEVICE_SAMPLE_SIZE(specs),
- specs.rate);
-
- if((err = alGetError()) != AL_NO_ERROR)
- {
- sound->m_eos = true;
- break;
- }
-
- // and queue again
- alSourceQueueBuffers(sound->m_source, 1,
- &sound->m_buffers[sound->m_current]);
- if(alGetError() != AL_NO_ERROR)
- {
- sound->m_eos = true;
- break;
- }
-
- sound->m_current = (sound->m_current+1) %
- AUD_OpenALHandle::CYCLE_BUFFERS;
- }
- else
- break;
- }
- }
- }
-
- // check if the sound has been stopped
- alGetSourcei(sound->m_source, AL_SOURCE_STATE, &info);
-
- if(info != AL_PLAYING)
- {
- // if it really stopped
- if(sound->m_eos && info != AL_INITIAL)
- {
- if(sound->m_stop)
- sound->m_stop(sound->m_stop_data);
-
- // pause or
- if(sound->m_keep)
- pauseSounds.push_back(sound);
- // stop
- else
- stopSounds.push_back(sound);
- }
- // continue playing
- else
- alSourcePlay(sound->m_source);
- }
- }
-
- for(it = pauseSounds.begin(); it != pauseSounds.end(); it++)
- (*it)->pause(true);
-
- for(it = stopSounds.begin(); it != stopSounds.end(); it++)
- (*it)->stop();
-
- pauseSounds.clear();
- stopSounds.clear();
-
- alcProcessContext(m_context);
- }
-
- // stop thread
- if(m_playingSounds.empty() || (cerr != ALC_NO_ERROR))
- {
- m_playing = false;
- unlock();
- pthread_exit(NULL);
- }
-
- unlock();
-
-#ifdef WIN32
- Sleep(20);
-#else
- usleep(20000);
-#endif
- }
-}
-
-/******************************************************************************/
-/**************************** IDevice Code ************************************/
-/******************************************************************************/
-
-static const char* open_error = "AUD_OpenALDevice: Device couldn't be opened.";
-
-AUD_OpenALDevice::AUD_OpenALDevice(AUD_DeviceSpecs specs, int buffersize)
-{
- // cannot determine how many channels or which format OpenAL uses, but
- // it at least is able to play 16 bit stereo audio
- specs.format = AUD_FORMAT_S16;
-
-#if 0
- if(alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT") == AL_TRUE)
- {
- ALCchar* devices = const_cast<ALCchar*>(alcGetString(NULL, ALC_DEVICE_SPECIFIER));
- printf("OpenAL devices (standard is: %s):\n", alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER));
-
- while(*devices)
- {
- printf("%s\n", devices);
- devices += strlen(devices) + 1;
- }
- }
-#endif
-
- m_device = alcOpenDevice(NULL);
-
- if(!m_device)
- AUD_THROW(AUD_ERROR_OPENAL, open_error);
-
- // at least try to set the frequency
- ALCint attribs[] = { ALC_FREQUENCY, (ALCint)specs.rate, 0 };
- ALCint* attributes = attribs;
- if(specs.rate == AUD_RATE_INVALID)
- attributes = NULL;
-
- m_context = alcCreateContext(m_device, attributes);
- alcMakeContextCurrent(m_context);
-
- alcGetIntegerv(m_device, ALC_FREQUENCY, 1, (ALCint*)&specs.rate);
-
- // check for specific formats and channel counts to be played back
- if(alIsExtensionPresent("AL_EXT_FLOAT32") == AL_TRUE)
- specs.format = AUD_FORMAT_FLOAT32;
-
- m_useMC = alIsExtensionPresent("AL_EXT_MCFORMATS") == AL_TRUE;
-
- if((!m_useMC && specs.channels > AUD_CHANNELS_STEREO) ||
- specs.channels == AUD_CHANNELS_STEREO_LFE ||
- specs.channels == AUD_CHANNELS_SURROUND5)
- specs.channels = AUD_CHANNELS_STEREO;
-
- alGetError();
- alcGetError(m_device);
-
- m_specs = specs;
- m_buffersize = buffersize;
- m_playing = false;
-
-// m_bufferedFactories = new std::list<AUD_OpenALBufferedFactory*>();
-
- 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);
-
- start(false);
-}
-
-AUD_OpenALDevice::~AUD_OpenALDevice()
-{
- lock();
- alcSuspendContext(m_context);
-
- while(!m_playingSounds.empty())
- m_playingSounds.front()->stop();
-
- while(!m_pausedSounds.empty())
- m_pausedSounds.front()->stop();
-
-
- // delete all buffered factories
- /*while(!m_bufferedFactories->empty())
- {
- alDeleteBuffers(1, &(*(m_bufferedFactories->begin()))->buffer);
- delete *m_bufferedFactories->begin();
- m_bufferedFactories->erase(m_bufferedFactories->begin());
- }*/
-
- alcProcessContext(m_context);
-
- // wait for the thread to stop
- unlock();
- pthread_join(m_thread, NULL);
-
- //delete m_bufferedFactories;
-
- // quit OpenAL
- alcMakeContextCurrent(NULL);
- alcDestroyContext(m_context);
- alcCloseDevice(m_device);
-
- pthread_mutex_destroy(&m_mutex);
-}
-
-AUD_DeviceSpecs AUD_OpenALDevice::getSpecs() const
-{
- return m_specs;
-}
-
-bool AUD_OpenALDevice::getFormat(ALenum &format, AUD_Specs specs)
-{
- bool valid = true;
- format = 0;
-
- switch(m_specs.format)
- {
- case AUD_FORMAT_S16:
- switch(specs.channels)
- {
- case AUD_CHANNELS_MONO:
- format = AL_FORMAT_MONO16;
- break;
- case AUD_CHANNELS_STEREO:
- format = AL_FORMAT_STEREO16;
- break;
- case AUD_CHANNELS_SURROUND4:
- if(m_useMC)
- {
- format = alGetEnumValue("AL_FORMAT_QUAD16");
- break;
- }
- case AUD_CHANNELS_SURROUND51:
- if(m_useMC)
- {
- format = alGetEnumValue("AL_FORMAT_51CHN16");
- break;
- }
- case AUD_CHANNELS_SURROUND61:
- if(m_useMC)
- {
- format = alGetEnumValue("AL_FORMAT_61CHN16");
- break;
- }
- case AUD_CHANNELS_SURROUND71:
- if(m_useMC)
- {
- format = alGetEnumValue("AL_FORMAT_71CHN16");
- break;
- }
- default:
- valid = false;
- }
- break;
- case AUD_FORMAT_FLOAT32:
- switch(specs.channels)
- {
- case AUD_CHANNELS_MONO:
- format = alGetEnumValue("AL_FORMAT_MONO_FLOAT32");
- break;
- case AUD_CHANNELS_STEREO:
- format = alGetEnumValue("AL_FORMAT_STEREO_FLOAT32");
- break;
- case AUD_CHANNELS_SURROUND4:
- if(m_useMC)
- {
- format = alGetEnumValue("AL_FORMAT_QUAD32");
- break;
- }
- case AUD_CHANNELS_SURROUND51:
- if(m_useMC)
- {
- format = alGetEnumValue("AL_FORMAT_51CHN32");
- break;
- }
- case AUD_CHANNELS_SURROUND61:
- if(m_useMC)
- {
- format = alGetEnumValue("AL_FORMAT_61CHN32");
- break;
- }
- case AUD_CHANNELS_SURROUND71:
- if(m_useMC)
- {
- format = alGetEnumValue("AL_FORMAT_71CHN32");
- break;
- }
- default:
- valid = false;
- }
- break;
- default:
- valid = false;
- }
-
- if(!format)
- valid = false;
-
- return valid;
-}
-
-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 boost::shared_ptr<AUD_IHandle>();
-
- if(m_specs.format != AUD_FORMAT_FLOAT32)
- reader = boost::shared_ptr<AUD_IReader>(new AUD_ConverterReader(reader, m_specs));
-
- ALenum format;
-
- if(!getFormat(format, specs))
- return boost::shared_ptr<AUD_IHandle>();
-
- AUD_MutexLock lock(*this);
-
- alcSuspendContext(m_context);
-
- boost::shared_ptr<AUD_OpenALDevice::AUD_OpenALHandle> sound;
-
- try
- {
- // create the handle
- sound = boost::shared_ptr<AUD_OpenALDevice::AUD_OpenALHandle>(new AUD_OpenALDevice::AUD_OpenALHandle(this, format, reader, keep));
- }
- catch(AUD_Exception&)
- {
- alcProcessContext(m_context);
- throw;
- }
-
- alcProcessContext(m_context);
-
- // play sound
- m_playingSounds.push_back(sound);
-
- start();
-
- return boost::shared_ptr<AUD_IHandle>(sound);
-}
-
-boost::shared_ptr<AUD_IHandle> AUD_OpenALDevice::play(boost::shared_ptr<AUD_IFactory> factory, bool keep)
-{
- /* AUD_XXX disabled
- AUD_OpenALHandle* sound = NULL;
-
- lock();
-
- try
- {
- // check if it is a buffered factory
- for(AUD_BFIterator i = m_bufferedFactories->begin();
- i != m_bufferedFactories->end(); i++)
- {
- if((*i)->factory == factory)
- {
- // create the handle
- sound = new AUD_OpenALHandle;
- sound->keep = keep;
- sound->current = -1;
- sound->isBuffered = true;
- sound->eos = true;
- sound->loopcount = 0;
- sound->stop = NULL;
- sound->stop_data = NULL;
-
- alcSuspendContext(m_context);
-
- // OpenAL playback code
- try
- {
- alGenSources(1, &sound->source);
- if(alGetError() != AL_NO_ERROR)
- AUD_THROW(AUD_ERROR_OPENAL, gensource_error);
-
- try
- {
- alSourcei(sound->source, AL_BUFFER, (*i)->buffer);
- if(alGetError() != AL_NO_ERROR)
- AUD_THROW(AUD_ERROR_OPENAL, queue_error);
- }
- catch(AUD_Exception&)
- {
- alDeleteSources(1, &sound->source);
- throw;
- }
- }
- catch(AUD_Exception&)
- {
- delete sound;
- alcProcessContext(m_context);
- throw;
- }
-
- // play sound
- m_playingSounds->push_back(sound);
-
- alSourcei(sound->source, AL_SOURCE_RELATIVE, 1);
- start();
-
- alcProcessContext(m_context);
- }
- }
- }
- catch(AUD_Exception&)
- {
- unlock();
- throw;
- }
-
- unlock();
-
- if(sound)
- return sound;*/
-
- return play(factory->createReader(), keep);
-}
-
-void AUD_OpenALDevice::stopAll()
-{
- AUD_MutexLock lock(*this);
-
- alcSuspendContext(m_context);
-
- while(!m_playingSounds.empty())
- m_playingSounds.front()->stop();
-
- while(!m_pausedSounds.empty())
- m_pausedSounds.front()->stop();
-
- alcProcessContext(m_context);
-}
-
-void AUD_OpenALDevice::lock()
-{
- pthread_mutex_lock(&m_mutex);
-}
-
-void AUD_OpenALDevice::unlock()
-{
- pthread_mutex_unlock(&m_mutex);
-}
-
-float AUD_OpenALDevice::getVolume() const
-{
- float result;
- alGetListenerf(AL_GAIN, &result);
- return result;
-}
-
-void AUD_OpenALDevice::setVolume(float volume)
-{
- alListenerf(AL_GAIN, volume);
-}
-
-/* AUD_XXX Temorary disabled
-
-bool AUD_OpenALDevice::bufferFactory(void *value)
-{
- bool result = false;
- AUD_IFactory* factory = (AUD_IFactory*) value;
-
- // load the factory into an OpenAL buffer
- if(factory)
- {
- // check if the factory is already buffered
- lock();
- for(AUD_BFIterator i = m_bufferedFactories->begin();
- i != m_bufferedFactories->end(); i++)
- {
- if((*i)->factory == factory)
- {
- result = true;
- break;
- }
- }
- unlock();
- if(result)
- return result;
-
- AUD_IReader* reader = factory->createReader();
-
- if(reader == NULL)
- return false;
-
- AUD_DeviceSpecs specs = m_specs;
- specs.specs = reader->getSpecs();
-
- if(m_specs.format != AUD_FORMAT_FLOAT32)
- reader = new AUD_ConverterReader(reader, m_specs);
-
- ALenum format;
-
- if(!getFormat(format, specs.specs))
- {
- return false;
- }
-
- // load into a buffer
- lock();
- alcSuspendContext(m_context);
-
- AUD_OpenALBufferedFactory* bf = new AUD_OpenALBufferedFactory;
- bf->factory = factory;
-
- try
- {
- alGenBuffers(1, &bf->buffer);
- if(alGetError() != AL_NO_ERROR)
- AUD_THROW(AUD_ERROR_OPENAL);
-
- try
- {
- sample_t* buf;
- int length = reader->getLength();
-
- reader->read(length, buf);
- alBufferData(bf->buffer, format, buf,
- length * AUD_DEVICE_SAMPLE_SIZE(specs),
- specs.rate);
- if(alGetError() != AL_NO_ERROR)
- AUD_THROW(AUD_ERROR_OPENAL);
- }
- catch(AUD_Exception&)
- {
- alDeleteBuffers(1, &bf->buffer);
- throw;
- }
- }
- catch(AUD_Exception&)
- {
- delete bf;
- alcProcessContext(m_context);
- unlock();
- return false;
- }
-
- m_bufferedFactories->push_back(bf);
-
- alcProcessContext(m_context);
- unlock();
- }
- else
- {
- // stop all playing and paused buffered sources
- lock();
- alcSuspendContext(m_context);
-
- AUD_OpenALHandle* sound;
- AUD_HandleIterator it = m_playingSounds->begin();
- while(it != m_playingSounds->end())
- {
- sound = *it;
- ++it;
-
- if(sound->isBuffered)
- stop(sound);
- }
- alcProcessContext(m_context);
-
- while(!m_bufferedFactories->empty())
- {
- alDeleteBuffers(1,
- &(*(m_bufferedFactories->begin()))->buffer);
- delete *m_bufferedFactories->begin();
- m_bufferedFactories->erase(m_bufferedFactories->begin());
- }
- unlock();
- }
-
- return true;
-}*/
-
-/******************************************************************************/
-/**************************** 3D Device Code **********************************/
-/******************************************************************************/
-
-AUD_Vector3 AUD_OpenALDevice::getListenerLocation() const
-{
- ALfloat p[3];
- alGetListenerfv(AL_POSITION, p);
- return AUD_Vector3(p[0], p[1], p[2]);
-}
-
-void AUD_OpenALDevice::setListenerLocation(const AUD_Vector3& location)
-{
- alListenerfv(AL_POSITION, (ALfloat*)location.get());
-}
-
-AUD_Vector3 AUD_OpenALDevice::getListenerVelocity() const
-{
- ALfloat v[3];
- alGetListenerfv(AL_VELOCITY, v);
- return AUD_Vector3(v[0], v[1], v[2]);
-}
-
-void AUD_OpenALDevice::setListenerVelocity(const AUD_Vector3& velocity)
-{
- alListenerfv(AL_VELOCITY, (ALfloat*)velocity.get());
-}
-
-AUD_Quaternion AUD_OpenALDevice::getListenerOrientation() const
-{
- return m_orientation;
-}
-
-void AUD_OpenALDevice::setListenerOrientation(const AUD_Quaternion& orientation)
-{
- ALfloat direction[6];
- direction[0] = -2 * (orientation.w() * orientation.y() +
- orientation.x() * orientation.z());
- direction[1] = 2 * (orientation.x() * orientation.w() -
- orientation.z() * orientation.y());
- direction[2] = 2 * (orientation.x() * orientation.x() +
- orientation.y() * orientation.y()) - 1;
- direction[3] = 2 * (orientation.x() * orientation.y() -
- orientation.w() * orientation.z());
- direction[4] = 1 - 2 * (orientation.x() * orientation.x() +
- orientation.z() * orientation.z());
- direction[5] = 2 * (orientation.w() * orientation.x() +
- orientation.y() * orientation.z());
- alListenerfv(AL_ORIENTATION, direction);
- m_orientation = orientation;
-}
-
-float AUD_OpenALDevice::getSpeedOfSound() const
-{
- return alGetFloat(AL_SPEED_OF_SOUND);
-}
-
-void AUD_OpenALDevice::setSpeedOfSound(float speed)
-{
- alSpeedOfSound(speed);
-}
-
-float AUD_OpenALDevice::getDopplerFactor() const
-{
- return alGetFloat(AL_DOPPLER_FACTOR);
-}
-
-void AUD_OpenALDevice::setDopplerFactor(float factor)
-{
- alDopplerFactor(factor);
-}
-
-AUD_DistanceModel AUD_OpenALDevice::getDistanceModel() const
-{
- switch(alGetInteger(AL_DISTANCE_MODEL))
- {
- case AL_INVERSE_DISTANCE:
- return AUD_DISTANCE_MODEL_INVERSE;
- case AL_INVERSE_DISTANCE_CLAMPED:
- return AUD_DISTANCE_MODEL_INVERSE_CLAMPED;
- case AL_LINEAR_DISTANCE:
- return AUD_DISTANCE_MODEL_LINEAR;
- case AL_LINEAR_DISTANCE_CLAMPED:
- return AUD_DISTANCE_MODEL_LINEAR_CLAMPED;
- case AL_EXPONENT_DISTANCE:
- return AUD_DISTANCE_MODEL_EXPONENT;
- case AL_EXPONENT_DISTANCE_CLAMPED:
- return AUD_DISTANCE_MODEL_EXPONENT_CLAMPED;
- default:
- return AUD_DISTANCE_MODEL_INVALID;
- }
-}
-
-void AUD_OpenALDevice::setDistanceModel(AUD_DistanceModel model)
-{
- switch(model)
- {
- case AUD_DISTANCE_MODEL_INVERSE:
- alDistanceModel(AL_INVERSE_DISTANCE);
- break;
- case AUD_DISTANCE_MODEL_INVERSE_CLAMPED:
- alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED);
- break;
- case AUD_DISTANCE_MODEL_LINEAR:
- alDistanceModel(AL_LINEAR_DISTANCE);
- break;
- case AUD_DISTANCE_MODEL_LINEAR_CLAMPED:
- alDistanceModel(AL_LINEAR_DISTANCE_CLAMPED);
- break;
- case AUD_DISTANCE_MODEL_EXPONENT:
- alDistanceModel(AL_EXPONENT_DISTANCE);
- break;
- case AUD_DISTANCE_MODEL_EXPONENT_CLAMPED:
- alDistanceModel(AL_EXPONENT_DISTANCE_CLAMPED);
- break;
- default:
- alDistanceModel(AL_NONE);
- }
-}
diff --git a/intern/audaspace/Python/AUD_PyAPI.cpp b/intern/audaspace/Python/AUD_PyAPI.cpp
deleted file mode 100644
index 6d4939bf96c..00000000000
--- a/intern/audaspace/Python/AUD_PyAPI.cpp
+++ /dev/null
@@ -1,2922 +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/Python/AUD_PyAPI.cpp
- * \ingroup audpython
- */
-
-
-#include "AUD_PyAPI.h"
-#include <structmember.h>
-
-#include "AUD_I3DDevice.h"
-#include "AUD_I3DHandle.h"
-#include "AUD_NULLDevice.h"
-#include "AUD_DelayFactory.h"
-#include "AUD_DoubleFactory.h"
-#include "AUD_FaderFactory.h"
-#include "AUD_HighpassFactory.h"
-#include "AUD_LimiterFactory.h"
-#include "AUD_LoopFactory.h"
-#include "AUD_LowpassFactory.h"
-#include "AUD_PingPongFactory.h"
-#include "AUD_PitchFactory.h"
-#include "AUD_ReverseFactory.h"
-#include "AUD_SinusFactory.h"
-#include "AUD_FileFactory.h"
-#include "AUD_SquareFactory.h"
-#include "AUD_StreamBufferFactory.h"
-#include "AUD_SuperposeFactory.h"
-#include "AUD_VolumeFactory.h"
-#include "AUD_IIRFilterFactory.h"
-
-#ifdef WITH_SDL
-#include "AUD_SDLDevice.h"
-#endif
-
-#ifdef WITH_OPENAL
-#include "AUD_OpenALDevice.h"
-#endif
-
-#ifdef WITH_JACK
-#include "AUD_JackDevice.h"
-#endif
-
-// ====================================================================
-
-typedef enum
-{
- AUD_DEVICE_NULL = 0,
- AUD_DEVICE_OPENAL,
- AUD_DEVICE_SDL,
- AUD_DEVICE_JACK,
- AUD_DEVICE_READ,
-} AUD_DeviceTypes;
-
-// ====================================================================
-
-#define PY_MODULE_ADD_CONSTANT(module, name) PyModule_AddIntConstant(module, #name, name)
-
-// ====================================================================
-
-static PyObject *AUDError;
-
-static const char* device_not_3d_error = "Device is not a 3D device!";
-
-// ====================================================================
-
-static void
-Factory_dealloc(Factory* self)
-{
- if(self->factory)
- delete reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory);
- Py_XDECREF(self->child_list);
- Py_TYPE(self)->tp_free((PyObject *)self);
-}
-
-static PyObject *
-Factory_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
- Factory *self;
-
- self = (Factory*)type->tp_alloc(type, 0);
- if(self != NULL)
- {
- static const char *kwlist[] = {"filename", NULL};
- const char* filename = NULL;
-
- if(!PyArg_ParseTupleAndKeywords(args, kwds, "s:Factory", const_cast<char**>(kwlist), &filename))
- {
- Py_DECREF(self);
- return NULL;
- }
-
- try
- {
- self->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_FileFactory(filename));
- }
- catch(AUD_Exception& e)
- {
- Py_DECREF(self);
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
- }
-
- return (PyObject *)self;
-}
-
-PyDoc_STRVAR(M_aud_Factory_sine_doc,
- "sine(frequency, rate=48000)\n\n"
- "Creates a sine factory which plays a sine wave.\n\n"
- ":arg frequency: The frequency of the sine wave in Hz.\n"
- ":type frequency: float\n"
- ":arg rate: The sampling rate in Hz. It's recommended to set this "
- "value to the playback device's samling rate to avoid resamping.\n"
- ":type rate: int\n"
- ":return: The created :class:`Factory` object.\n"
- ":rtype: :class:`Factory`");
-
-static PyObject *
-Factory_sine(PyTypeObject* type, PyObject *args)
-{
- float frequency;
- double rate = 48000;
-
- if(!PyArg_ParseTuple(args, "f|d:sine", &frequency, &rate))
- return NULL;
-
- Factory *self;
-
- self = (Factory*)type->tp_alloc(type, 0);
- if(self != NULL)
- {
- try
- {
- self->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_SinusFactory(frequency, (AUD_SampleRate)rate));
- }
- catch(AUD_Exception& e)
- {
- Py_DECREF(self);
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
- }
-
- return (PyObject *)self;
-}
-
-PyDoc_STRVAR(M_aud_Factory_file_doc,
- "file(filename)\n\n"
- "Creates a factory object of a sound file.\n\n"
- ":arg filename: Path of the file.\n"
- ":type filename: string\n"
- ":return: The created :class:`Factory` object.\n"
- ":rtype: :class:`Factory`\n\n"
- ".. warning:: If the file doesn't exist or can't be read you will "
- "not get an exception immediately, but when you try to start "
- "playback of that factory.");
-
-static PyObject *
-Factory_file(PyTypeObject* type, PyObject *args)
-{
- const char* filename = NULL;
-
- if(!PyArg_ParseTuple(args, "s:file", &filename))
- return NULL;
-
- Factory *self;
-
- self = (Factory*)type->tp_alloc(type, 0);
- if(self != NULL)
- {
- try
- {
- self->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_FileFactory(filename));
- }
- catch(AUD_Exception& e)
- {
- Py_DECREF(self);
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
- }
-
- return (PyObject *)self;
-}
-
-PyDoc_STRVAR(M_aud_Factory_lowpass_doc,
- "lowpass(frequency, Q=0.5)\n\n"
- "Creates a second order lowpass filter based on the transfer "
- "function H(s) = 1 / (s^2 + s/Q + 1)\n\n"
- ":arg frequency: The cut off trequency of the lowpass.\n"
- ":type frequency: float\n"
- ":arg Q: Q factor of the lowpass.\n"
- ":type Q: float\n"
- ":return: The created :class:`Factory` object.\n"
- ":rtype: :class:`Factory`");
-
-static PyObject *
-Factory_lowpass(Factory* self, PyObject *args)
-{
- float frequency;
- float Q = 0.5;
-
- if(!PyArg_ParseTuple(args, "f|f:lowpass", &frequency, &Q))
- return NULL;
-
- PyTypeObject* type = Py_TYPE(self);
- Factory *parent = (Factory*)type->tp_alloc(type, 0);
-
- if(parent != NULL)
- {
- Py_INCREF(self);
- parent->child_list = (PyObject *)self;
-
- try
- {
- 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)
- {
- Py_DECREF(parent);
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
- }
-
- return (PyObject *)parent;
-}
-
-PyDoc_STRVAR(M_aud_Factory_delay_doc,
- "delay(time)\n\n"
- "Delays by playing adding silence in front of the other factory's "
- "data.\n\n"
- ":arg time: How many seconds of silence should be added before "
- "the factory.\n"
- ":type time: float\n"
- ":return: The created :class:`Factory` object.\n"
- ":rtype: :class:`Factory`");
-
-static PyObject *
-Factory_delay(Factory* self, PyObject *args)
-{
- float delay;
-
- if(!PyArg_ParseTuple(args, "f:delay", &delay))
- return NULL;
-
- PyTypeObject* type = Py_TYPE(self);
- Factory *parent = (Factory*)type->tp_alloc(type, 0);
-
- if(parent != NULL)
- {
- Py_INCREF(self);
- parent->child_list = (PyObject *)self;
-
- try
- {
- 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)
- {
- Py_DECREF(parent);
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
- }
-
- return (PyObject *)parent;
-}
-
-PyDoc_STRVAR(M_aud_Factory_join_doc,
- "join(factory)\n\n"
- "Plays two factories in sequence.\n\n"
- ":arg factory: The factory to play second.\n"
- ":type factory: :class:`Factory`\n"
- ":return: The created :class:`Factory` object.\n"
- ":rtype: :class:`Factory`\n\n"
- ".. note:: The two factories have to have the same specifications "
- "(channels and samplerate).");
-
-static PyObject *
-Factory_join(Factory* self, PyObject *object)
-{
- PyTypeObject* type = Py_TYPE(self);
-
- if(!PyObject_TypeCheck(object, type))
- {
- PyErr_SetString(PyExc_TypeError, "Object has to be of type Factory!");
- return NULL;
- }
-
- Factory *parent;
- Factory *child = (Factory*)object;
-
- parent = (Factory*)type->tp_alloc(type, 0);
- if(parent != NULL)
- {
- parent->child_list = Py_BuildValue("(OO)", self, object);
-
- try
- {
- 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)
- {
- Py_DECREF(parent);
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
- }
-
- return (PyObject *)parent;
-}
-
-PyDoc_STRVAR(M_aud_Factory_highpass_doc,
- "highpass(frequency, Q=0.5)\n\n"
- "Creates a second order highpass filter based on the transfer "
- "function H(s) = s^2 / (s^2 + s/Q + 1)\n\n"
- ":arg frequency: The cut off trequency of the highpass.\n"
- ":type frequency: float\n"
- ":arg Q: Q factor of the lowpass.\n"
- ":type Q: float\n"
- ":return: The created :class:`Factory` object.\n"
- ":rtype: :class:`Factory`");
-
-static PyObject *
-Factory_highpass(Factory* self, PyObject *args)
-{
- float frequency;
- float Q = 0.5;
-
- if(!PyArg_ParseTuple(args, "f|f:highpass", &frequency, &Q))
- return NULL;
-
- PyTypeObject* type = Py_TYPE(self);
- Factory *parent = (Factory*)type->tp_alloc(type, 0);
-
- if(parent != NULL)
- {
- Py_INCREF(self);
- parent->child_list = (PyObject *)self;
-
- try
- {
- 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)
- {
- Py_DECREF(parent);
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
- }
-
- return (PyObject *)parent;
-}
-
-PyDoc_STRVAR(M_aud_Factory_limit_doc,
- "limit(start, end)\n\n"
- "Limits a factory within a specific start and end time.\n\n"
- ":arg start: Start time in seconds.\n"
- ":type start: float\n"
- ":arg end: End time in seconds.\n"
- ":type end: float\n"
- ":return: The created :class:`Factory` object.\n"
- ":rtype: :class:`Factory`");
-
-static PyObject *
-Factory_limit(Factory* self, PyObject *args)
-{
- float start, end;
-
- if(!PyArg_ParseTuple(args, "ff:limit", &start, &end))
- return NULL;
-
- PyTypeObject* type = Py_TYPE(self);
- Factory *parent = (Factory*)type->tp_alloc(type, 0);
-
- if(parent != NULL)
- {
- Py_INCREF(self);
- parent->child_list = (PyObject *)self;
-
- try
- {
- 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)
- {
- Py_DECREF(parent);
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
- }
-
- return (PyObject *)parent;
-}
-
-PyDoc_STRVAR(M_aud_Factory_pitch_doc,
- "pitch(factor)\n\n"
- "Changes the pitch of a factory with a specific factor.\n\n"
- ":arg factor: The factor to change the pitch with.\n"
- ":type factor: float\n"
- ":return: The created :class:`Factory` object.\n"
- ":rtype: :class:`Factory`\n\n"
- ".. note:: This is done by changing the sample rate of the "
- "underlying factory, which has to be an integer, so the factor "
- "value rounded and the factor may not be 100 % accurate.\n\n"
- ".. note:: This is a filter function, you might consider using "
- ":attr:`Handle.pitch` instead.");
-
-static PyObject *
-Factory_pitch(Factory* self, PyObject *args)
-{
- float factor;
-
- if(!PyArg_ParseTuple(args, "f:pitch", &factor))
- return NULL;
-
- PyTypeObject* type = Py_TYPE(self);
- Factory *parent = (Factory*)type->tp_alloc(type, 0);
-
- if(parent != NULL)
- {
- Py_INCREF(self);
- parent->child_list = (PyObject *)self;
-
- try
- {
- 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)
- {
- Py_DECREF(parent);
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
- }
-
- return (PyObject *)parent;
-}
-
-PyDoc_STRVAR(M_aud_Factory_volume_doc,
- "volume(volume)\n\n"
- "Changes the volume of a factory.\n\n"
- ":arg volume: The new volume..\n"
- ":type volume: float\n"
- ":return: The created :class:`Factory` object.\n"
- ":rtype: :class:`Factory`\n\n"
- ".. note:: Should be in the range [0, 1] to avoid clipping.\n\n"
- ".. note:: This is a filter function, you might consider using "
- ":attr:`Handle.volume` instead.");
-
-static PyObject *
-Factory_volume(Factory* self, PyObject *args)
-{
- float volume;
-
- if(!PyArg_ParseTuple(args, "f:volume", &volume))
- return NULL;
-
- PyTypeObject* type = Py_TYPE(self);
- Factory *parent = (Factory*)type->tp_alloc(type, 0);
-
- if(parent != NULL)
- {
- Py_INCREF(self);
- parent->child_list = (PyObject *)self;
-
- try
- {
- 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)
- {
- Py_DECREF(parent);
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
- }
-
- return (PyObject *)parent;
-}
-
-PyDoc_STRVAR(M_aud_Factory_fadein_doc,
- "fadein(start, length)\n\n"
- "Fades a factory in by raising the volume linearly in the given "
- "time interval.\n\n"
- ":arg start: Time in seconds when the fading should start.\n"
- ":type start: float\n"
- ":arg length: Time in seconds how long the fading should last.\n"
- ":type length: float\n"
- ":return: The created :class:`Factory` object.\n"
- ":rtype: :class:`Factory`\n\n"
- ".. note:: Before the fade starts it plays silence.");
-
-static PyObject *
-Factory_fadein(Factory* self, PyObject *args)
-{
- float start, length;
-
- if(!PyArg_ParseTuple(args, "ff:fadein", &start, &length))
- return NULL;
-
- PyTypeObject* type = Py_TYPE(self);
- Factory *parent = (Factory*)type->tp_alloc(type, 0);
-
- if(parent != NULL)
- {
- Py_INCREF(self);
- parent->child_list = (PyObject *)self;
-
- try
- {
- 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)
- {
- Py_DECREF(parent);
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
- }
-
- return (PyObject *)parent;
-}
-
-PyDoc_STRVAR(M_aud_Factory_fadeout_doc,
- "fadeout(start, length)\n\n"
- "Fades a factory in by lowering the volume linearly in the given "
- "time interval.\n\n"
- ":arg start: Time in seconds when the fading should start.\n"
- ":type start: float\n"
- ":arg length: Time in seconds how long the fading should last.\n"
- ":type length: float\n"
- ":return: The created :class:`Factory` object.\n"
- ":rtype: :class:`Factory`\n\n"
- ".. note:: After the fade this factory plays silence, so that "
- "the length of the factory is not altered.");
-
-static PyObject *
-Factory_fadeout(Factory* self, PyObject *args)
-{
- float start, length;
-
- if(!PyArg_ParseTuple(args, "ff:fadeout", &start, &length))
- return NULL;
-
- PyTypeObject* type = Py_TYPE(self);
- Factory *parent = (Factory*)type->tp_alloc(type, 0);
-
- if(parent != NULL)
- {
- Py_INCREF(self);
- parent->child_list = (PyObject *)self;
-
- try
- {
- 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)
- {
- Py_DECREF(parent);
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
- }
-
- return (PyObject *)parent;
-}
-
-PyDoc_STRVAR(M_aud_Factory_loop_doc,
- "loop(count)\n\n"
- "Loops a factory.\n\n"
- ":arg count: How often the factory should be looped. "
- "Negative values mean endlessly.\n"
- ":type count: integer\n"
- ":return: The created :class:`Factory` object.\n"
- ":rtype: :class:`Factory`\n\n"
- ".. note:: This is a filter function, you might consider using "
- ":attr:`Handle.loop_count` instead.");
-
-static PyObject *
-Factory_loop(Factory* self, PyObject *args)
-{
- int loop;
-
- if(!PyArg_ParseTuple(args, "i:loop", &loop))
- return NULL;
-
- PyTypeObject* type = Py_TYPE(self);
- Factory *parent = (Factory*)type->tp_alloc(type, 0);
-
- if(parent != NULL)
- {
- Py_INCREF(self);
- parent->child_list = (PyObject *)self;
-
- try
- {
- 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)
- {
- Py_DECREF(parent);
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
- }
-
- return (PyObject *)parent;
-}
-
-PyDoc_STRVAR(M_aud_Factory_mix_doc,
- "mix(factory)\n\n"
- "Mixes two factories.\n\n"
- ":arg factory: The factory to mix over the other.\n"
- ":type factory: :class:`Factory`\n"
- ":return: The created :class:`Factory` object.\n"
- ":rtype: :class:`Factory`\n\n"
- ".. note:: The two factories have to have the same specifications "
- "(channels and samplerate).");
-
-static PyObject *
-Factory_mix(Factory* self, PyObject *object)
-{
- PyTypeObject* type = Py_TYPE(self);
-
- if(!PyObject_TypeCheck(object, type))
- {
- PyErr_SetString(PyExc_TypeError, "Object is not of type Factory!");
- return NULL;
- }
-
- Factory *parent = (Factory*)type->tp_alloc(type, 0);
- Factory *child = (Factory*)object;
-
- if(parent != NULL)
- {
- parent->child_list = Py_BuildValue("(OO)", self, object);
-
- try
- {
- 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)
- {
- Py_DECREF(parent);
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
- }
-
- return (PyObject *)parent;
-}
-
-PyDoc_STRVAR(M_aud_Factory_pingpong_doc,
- "pingpong()\n\n"
- "Plays a factory forward and then backward.\n"
- "This is like joining a factory with its reverse.\n\n"
- ":return: The created :class:`Factory` object.\n"
- ":rtype: :class:`Factory`");
-
-static PyObject *
-Factory_pingpong(Factory* self)
-{
- PyTypeObject* type = Py_TYPE(self);
- Factory *parent = (Factory*)type->tp_alloc(type, 0);
-
- if(parent != NULL)
- {
- Py_INCREF(self);
- parent->child_list = (PyObject *)self;
-
- try
- {
- parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_PingPongFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory)));
- }
- catch(AUD_Exception& e)
- {
- Py_DECREF(parent);
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
- }
-
- return (PyObject *)parent;
-}
-
-PyDoc_STRVAR(M_aud_Factory_reverse_doc,
- "reverse()\n\n"
- "Plays a factory reversed.\n\n"
- ":return: The created :class:`Factory` object.\n"
- ":rtype: :class:`Factory`\n\n"
- ".. note:: The factory has to have a finite length and has to be "
- "seekable. It's recommended to use this only with factories with "
- "fast and accurate seeking, which is not true for encoded audio "
- "files, such ones should be buffered using :meth:`buffer` before "
- "being played reversed.\n\n"
- ".. warning:: If seeking is not accurate in the underlying factory "
- "you'll likely hear skips/jumps/cracks.");
-
-static PyObject *
-Factory_reverse(Factory* self)
-{
- PyTypeObject* type = Py_TYPE(self);
- Factory *parent = (Factory*)type->tp_alloc(type, 0);
-
- if(parent != NULL)
- {
- Py_INCREF(self);
- parent->child_list = (PyObject *)self;
-
- try
- {
- parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_ReverseFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory)));
- }
- catch(AUD_Exception& e)
- {
- Py_DECREF(parent);
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
- }
-
- return (PyObject *)parent;
-}
-
-PyDoc_STRVAR(M_aud_Factory_buffer_doc,
- "buffer()\n\n"
- "Buffers a factory into RAM.\n"
- "This saves CPU usage needed for decoding and file access if the "
- "underlying factory reads from a file on the harddisk, but it "
- "consumes a lot of memory.\n\n"
- ":return: The created :class:`Factory` object.\n"
- ":rtype: :class:`Factory`\n\n"
- ".. note:: Only known-length factories can be buffered.\n\n"
- ".. warning:: Raw PCM data needs a lot of space, only buffer "
- "short factories.");
-
-static PyObject *
-Factory_buffer(Factory* self)
-{
- PyTypeObject* type = Py_TYPE(self);
- Factory *parent = (Factory*)type->tp_alloc(type, 0);
-
- if(parent != NULL)
- {
- try
- {
- parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_StreamBufferFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory)));
- }
- catch(AUD_Exception& e)
- {
- Py_DECREF(parent);
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
- }
-
- return (PyObject *)parent;
-}
-
-PyDoc_STRVAR(M_aud_Factory_square_doc,
- "square(threshold = 0)\n\n"
- "Makes a square wave out of an audio wave by setting all samples "
- "with a amplitude >= threshold to 1, all <= -threshold to -1 and "
- "all between to 0.\n\n"
- ":arg threshold: Threshold value over which an amplitude counts "
- "non-zero.\n"
- ":type threshold: float\n"
- ":return: The created :class:`Factory` object.\n"
- ":rtype: :class:`Factory`");
-
-static PyObject *
-Factory_square(Factory* self, PyObject *args)
-{
- float threshold = 0;
-
- if(!PyArg_ParseTuple(args, "|f:square", &threshold))
- return NULL;
-
- PyTypeObject* type = Py_TYPE(self);
- Factory *parent = (Factory*)type->tp_alloc(type, 0);
-
- if(parent != NULL)
- {
- Py_INCREF(self);
- parent->child_list = (PyObject *)self;
-
- try
- {
- 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)
- {
- Py_DECREF(parent);
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
- }
-
- return (PyObject *)parent;
-}
-
-PyDoc_STRVAR(M_aud_Factory_filter_doc,
- "filter(b, a = (1))\n\n"
- "Filters a factory with the supplied IIR filter coefficients.\n"
- "Without the second parameter you'll get a FIR filter.\n"
- "If the first value of the a sequence is 0 it will be set to 1 "
- "automatically.\n"
- "If the first value of the a sequence is neither 0 nor 1, all "
- "filter coefficients will be scaled by this value so that it is 1 "
- "in the end, you don't have to scale yourself.\n\n"
- ":arg b: The nominator filter coefficients.\n"
- ":type b: sequence of float\n"
- ":arg a: The denominator filter coefficients.\n"
- ":type a: sequence of float\n"
- ":return: The created :class:`Factory` object.\n"
- ":rtype: :class:`Factory`");
-
-static PyObject *
-Factory_filter(Factory* self, PyObject *args)
-{
- PyObject *py_b;
- PyObject *py_a = NULL;
- Py_ssize_t py_a_len;
- Py_ssize_t py_b_len;
-
- if(!PyArg_ParseTuple(args, "O|O:filter", &py_b, &py_a))
- return NULL;
-
- if(!PySequence_Check(py_b) || (py_a != NULL && !PySequence_Check(py_a)))
- {
- PyErr_SetString(PyExc_TypeError, "Parameter is not a sequence!");
- return NULL;
- }
-
- py_a_len= py_a ? PySequence_Size(py_a) : 0;
- py_b_len= PySequence_Size(py_b);
-
- if(!py_b_len || ((py_a != NULL) && !py_a_len))
- {
- PyErr_SetString(PyExc_ValueError, "The sequence has to contain at least one value!");
- return NULL;
- }
-
- std::vector<float> a, b;
- PyObject *py_value;
- float value;
-
- for(Py_ssize_t i = 0; i < py_b_len; i++)
- {
- py_value = PySequence_GetItem(py_b, i);
- value= (float)PyFloat_AsDouble(py_value);
- Py_DECREF(py_value);
-
- if (value==-1.0f && PyErr_Occurred()) {
- return NULL;
- }
-
- b.push_back(value);
- }
-
- if(py_a)
- {
- for(Py_ssize_t i = 0; i < py_a_len; i++)
- {
- py_value = PySequence_GetItem(py_a, i);
- value= (float)PyFloat_AsDouble(py_value);
- Py_DECREF(py_value);
-
- if (value==-1.0f && PyErr_Occurred()) {
- return NULL;
- }
-
- a.push_back(value);
- }
-
- if(a[0] == 0)
- a[0] = 1;
- }
- else
- a.push_back(1);
-
- PyTypeObject* type = Py_TYPE(self);
- Factory *parent = (Factory*)type->tp_alloc(type, 0);
-
- if(parent != NULL)
- {
- Py_INCREF(self);
- parent->child_list = (PyObject *)self;
-
- try
- {
- 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)
- {
- Py_DECREF(parent);
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
- }
-
- return (PyObject *)parent;
-}
-
-static PyMethodDef Factory_methods[] = {
- {"sine", (PyCFunction)Factory_sine, METH_VARARGS | METH_CLASS,
- M_aud_Factory_sine_doc
- },
- {"file", (PyCFunction)Factory_file, METH_VARARGS | METH_CLASS,
- M_aud_Factory_file_doc
- },
- {"lowpass", (PyCFunction)Factory_lowpass, METH_VARARGS,
- M_aud_Factory_lowpass_doc
- },
- {"delay", (PyCFunction)Factory_delay, METH_VARARGS,
- M_aud_Factory_delay_doc
- },
- {"join", (PyCFunction)Factory_join, METH_O,
- M_aud_Factory_join_doc
- },
- {"highpass", (PyCFunction)Factory_highpass, METH_VARARGS,
- M_aud_Factory_highpass_doc
- },
- {"limit", (PyCFunction)Factory_limit, METH_VARARGS,
- M_aud_Factory_limit_doc
- },
- {"pitch", (PyCFunction)Factory_pitch, METH_VARARGS,
- M_aud_Factory_pitch_doc
- },
- {"volume", (PyCFunction)Factory_volume, METH_VARARGS,
- M_aud_Factory_volume_doc
- },
- {"fadein", (PyCFunction)Factory_fadein, METH_VARARGS,
- M_aud_Factory_fadein_doc
- },
- {"fadeout", (PyCFunction)Factory_fadeout, METH_VARARGS,
- M_aud_Factory_fadeout_doc
- },
- {"loop", (PyCFunction)Factory_loop, METH_VARARGS,
- M_aud_Factory_loop_doc
- },
- {"mix", (PyCFunction)Factory_mix, METH_O,
- M_aud_Factory_mix_doc
- },
- {"pingpong", (PyCFunction)Factory_pingpong, METH_NOARGS,
- M_aud_Factory_pingpong_doc
- },
- {"reverse", (PyCFunction)Factory_reverse, METH_NOARGS,
- M_aud_Factory_reverse_doc
- },
- {"buffer", (PyCFunction)Factory_buffer, METH_NOARGS,
- M_aud_Factory_buffer_doc
- },
- {"square", (PyCFunction)Factory_square, METH_VARARGS,
- M_aud_Factory_square_doc
- },
- {"filter", (PyCFunction)Factory_filter, METH_VARARGS,
- M_aud_Factory_filter_doc
- },
- {NULL} /* Sentinel */
-};
-
-PyDoc_STRVAR(M_aud_Factory_doc,
- "Factory objects are immutable and represent a sound that can be "
- "played simultaneously multiple times. They are called factories "
- "because they create reader objects internally that are used for "
- "playback.");
-
-static PyTypeObject FactoryType = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "aud.Factory", /* tp_name */
- sizeof(Factory), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)Factory_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- M_aud_Factory_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- Factory_methods, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- Factory_new, /* tp_new */
-};
-
-// ========== Handle ==================================================
-
-static void
-Handle_dealloc(Handle* self)
-{
- if(self->handle)
- delete reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle);
- Py_TYPE(self)->tp_free((PyObject *)self);
-}
-
-PyDoc_STRVAR(M_aud_Handle_pause_doc,
- "pause()\n\n"
- "Pauses playback.\n\n"
- ":return: Whether the action succeeded.\n"
- ":rtype: bool");
-
-static PyObject *
-Handle_pause(Handle *self)
-{
- try
- {
- return PyBool_FromLong((long)(*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->pause());
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
-}
-
-PyDoc_STRVAR(M_aud_Handle_resume_doc,
- "resume()\n\n"
- "Resumes playback.\n\n"
- ":return: Whether the action succeeded.\n"
- ":rtype: bool");
-
-static PyObject *
-Handle_resume(Handle *self)
-{
- try
- {
- return PyBool_FromLong((long)(*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->resume());
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
-}
-
-PyDoc_STRVAR(M_aud_Handle_stop_doc,
- "stop()\n\n"
- "Stops playback.\n\n"
- ":return: Whether the action succeeded.\n"
- ":rtype: bool\n\n"
- ".. note:: This makes the handle invalid.");
-
-static PyObject *
-Handle_stop(Handle *self)
-{
- try
- {
- return PyBool_FromLong((long)(*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->stop());
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
-}
-
-static PyMethodDef Handle_methods[] = {
- {"pause", (PyCFunction)Handle_pause, METH_NOARGS,
- M_aud_Handle_pause_doc
- },
- {"resume", (PyCFunction)Handle_resume, METH_NOARGS,
- M_aud_Handle_resume_doc
- },
- {"stop", (PyCFunction)Handle_stop, METH_NOARGS,
- M_aud_Handle_stop_doc
- },
- {NULL} /* Sentinel */
-};
-
-PyDoc_STRVAR(M_aud_Handle_position_doc,
- "The playback position of the sound in seconds.");
-
-static PyObject *
-Handle_get_position(Handle *self, void* nothing)
-{
- try
- {
- return Py_BuildValue("f", (*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->getPosition());
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
-}
-
-static int
-Handle_set_position(Handle *self, PyObject *args, void* nothing)
-{
- float position;
-
- if(!PyArg_Parse(args, "f:position", &position))
- return -1;
-
- try
- {
- if((*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->seek(position))
- return 0;
- PyErr_SetString(AUDError, "Couldn't seek the sound!");
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- }
-
- return -1;
-}
-
-PyDoc_STRVAR(M_aud_Handle_keep_doc,
- "Whether the sound should be kept paused in the device when its "
- "end is reached.\n"
- "This can be used to seek the sound to some position and start "
- "playback again.\n\n"
- ".. warning:: If this is set to true and you forget stopping this "
- "equals a memory leak as the handle exists until the device is "
- "destroyed.");
-
-static PyObject *
-Handle_get_keep(Handle *self, void* nothing)
-{
- try
- {
- return PyBool_FromLong((long)(*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->getKeep());
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
-}
-
-static int
-Handle_set_keep(Handle *self, PyObject *args, void* nothing)
-{
- if(!PyBool_Check(args))
- {
- PyErr_SetString(PyExc_TypeError, "keep is not a boolean!");
- return -1;
- }
-
- bool keep = args == Py_True;
-
- try
- {
- if((*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->setKeep(keep))
- return 0;
- PyErr_SetString(AUDError, "Couldn't set keep of the sound!");
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- }
-
- return -1;
-}
-
-PyDoc_STRVAR(M_aud_Handle_status_doc,
- "Whether the sound is playing, paused or stopped (=invalid).");
-
-static PyObject *
-Handle_get_status(Handle *self, void* nothing)
-{
- try
- {
- return PyBool_FromLong((long)(*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->getStatus());
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
-}
-
-PyDoc_STRVAR(M_aud_Handle_volume_doc,
- "The volume of the sound.");
-
-static PyObject *
-Handle_get_volume(Handle *self, void* nothing)
-{
- try
- {
- return Py_BuildValue("f", (*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->getVolume());
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
-}
-
-static int
-Handle_set_volume(Handle *self, PyObject *args, void* nothing)
-{
- float volume;
-
- if(!PyArg_Parse(args, "f:volume", &volume))
- return -1;
-
- try
- {
- if((*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->setVolume(volume))
- return 0;
- PyErr_SetString(AUDError, "Couldn't set the sound volume!");
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- }
-
- return -1;
-}
-
-PyDoc_STRVAR(M_aud_Handle_pitch_doc,
- "The pitch of the sound.");
-
-static PyObject *
-Handle_get_pitch(Handle *self, void* nothing)
-{
- try
- {
- return Py_BuildValue("f", (*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->getPitch());
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
-}
-
-static int
-Handle_set_pitch(Handle *self, PyObject *args, void* nothing)
-{
- float pitch;
-
- if(!PyArg_Parse(args, "f:pitch", &pitch))
- return -1;
-
- try
- {
- if((*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->setPitch(pitch))
- return 0;
- PyErr_SetString(AUDError, "Couldn't set the sound pitch!");
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- }
-
- return -1;
-}
-
-PyDoc_STRVAR(M_aud_Handle_loop_count_doc,
- "The (remaining) loop count of the sound. A negative value indicates infinity.");
-
-static PyObject *
-Handle_get_loop_count(Handle *self, void* nothing)
-{
- try
- {
- return Py_BuildValue("i", (*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->getLoopCount());
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
-}
-
-static int
-Handle_set_loop_count(Handle *self, PyObject *args, void* nothing)
-{
- int loops;
-
- if(!PyArg_Parse(args, "i:loop_count", &loops))
- return -1;
-
- try
- {
- if((*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->setLoopCount(loops))
- return 0;
- PyErr_SetString(AUDError, "Couldn't set the loop count!");
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- }
-
- return -1;
-}
-
-PyDoc_STRVAR(M_aud_Handle_location_doc,
- "The source's location in 3D space, a 3D tuple of floats.");
-
-static PyObject *
-Handle_get_location(Handle *self, void* nothing)
-{
- try
- {
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
- if(handle)
- {
- AUD_Vector3 v = handle->getSourceLocation();
- return Py_BuildValue("(fff)", v.x(), v.y(), v.z());
- }
- else
- {
- PyErr_SetString(AUDError, device_not_3d_error);
- }
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- }
-
- return NULL;
-}
-
-static int
-Handle_set_location(Handle *self, PyObject *args, void* nothing)
-{
- float x, y, z;
-
- if(!PyArg_Parse(args, "(fff):location", &x, &y, &z))
- return -1;
-
- try
- {
- 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);
- if(handle->setSourceLocation(location))
- return 0;
- PyErr_SetString(AUDError, "Location couldn't be set!");
- }
- else
- PyErr_SetString(AUDError, device_not_3d_error);
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- }
-
- return -1;
-}
-
-PyDoc_STRVAR(M_aud_Handle_velocity_doc,
- "The source's velocity in 3D space, a 3D tuple of floats.");
-
-static PyObject *
-Handle_get_velocity(Handle *self, void* nothing)
-{
- try
- {
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
- if(handle)
- {
- AUD_Vector3 v = handle->getSourceVelocity();
- return Py_BuildValue("(fff)", v.x(), v.y(), v.z());
- }
- else
- {
- PyErr_SetString(AUDError, device_not_3d_error);
- }
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- }
-
- return NULL;
-}
-
-static int
-Handle_set_velocity(Handle *self, PyObject *args, void* nothing)
-{
- float x, y, z;
-
- if(!PyArg_Parse(args, "(fff):velocity", &x, &y, &z))
- return -1;
-
- try
- {
- 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);
- if(handle->setSourceVelocity(velocity))
- return 0;
- PyErr_SetString(AUDError, "Couldn't set the velocity!");
- }
- else
- PyErr_SetString(AUDError, device_not_3d_error);
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- }
-
- return -1;
-}
-
-PyDoc_STRVAR(M_aud_Handle_orientation_doc,
- "The source's orientation in 3D space as quaternion, a 4 float tuple.");
-
-static PyObject *
-Handle_get_orientation(Handle *self, void* nothing)
-{
- try
- {
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
- if(handle)
- {
- AUD_Quaternion o = handle->getSourceOrientation();
- return Py_BuildValue("(ffff)", o.w(), o.x(), o.y(), o.z());
- }
- else
- {
- PyErr_SetString(AUDError, device_not_3d_error);
- }
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- }
-
- return NULL;
-}
-
-static int
-Handle_set_orientation(Handle *self, PyObject *args, void* nothing)
-{
- float w, x, y, z;
-
- if(!PyArg_Parse(args, "(ffff):orientation", &w, &x, &y, &z))
- return -1;
-
- try
- {
- 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);
- if(handle->setSourceOrientation(orientation))
- return 0;
- PyErr_SetString(AUDError, "Couldn't set the orientation!");
- }
- else
- PyErr_SetString(AUDError, device_not_3d_error);
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- }
-
- return -1;
-}
-
-PyDoc_STRVAR(M_aud_Handle_relative_doc,
- "Whether the source's location, velocity and orientation is relative or absolute to the listener.");
-
-static PyObject *
-Handle_get_relative(Handle *self, void* nothing)
-{
- try
- {
- 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());
- }
- else
- {
- PyErr_SetString(AUDError, device_not_3d_error);
- }
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- }
-
- return NULL;
-}
-
-static int
-Handle_set_relative(Handle *self, PyObject *args, void* nothing)
-{
- if(!PyBool_Check(args))
- {
- PyErr_SetString(PyExc_TypeError, "Value is not a boolean!");
- return -1;
- }
-
- bool relative = (args == Py_True);
-
- try
- {
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
- if(handle)
- {
- if(handle->setRelative(relative))
- return 0;
- PyErr_SetString(AUDError, "Couldn't set the relativeness!");
- }
- else
- PyErr_SetString(AUDError, device_not_3d_error);
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- }
-
- return -1;
-}
-
-PyDoc_STRVAR(M_aud_Handle_volume_minimum_doc,
- "The minimum volume of the source.\n\n"
- ".. seealso:: :attr:`Device.distance_model`");
-
-static PyObject *
-Handle_get_volume_minimum(Handle *self, void* nothing)
-{
- try
- {
- 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());
- }
- else
- {
- PyErr_SetString(AUDError, device_not_3d_error);
- return NULL;
- }
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
-}
-
-static int
-Handle_set_volume_minimum(Handle *self, PyObject *args, void* nothing)
-{
- float volume;
-
- if(!PyArg_Parse(args, "f:volume_minimum", &volume))
- return -1;
-
- try
- {
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
- if(handle)
- {
- if(handle->setVolumeMinimum(volume))
- return 0;
- PyErr_SetString(AUDError, "Couldn't set the minimum volume!");
- }
- else
- PyErr_SetString(AUDError, device_not_3d_error);
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- }
-
- return -1;
-}
-
-PyDoc_STRVAR(M_aud_Handle_volume_maximum_doc,
- "The maximum volume of the source.\n\n"
- ".. seealso:: :attr:`Device.distance_model`");
-
-static PyObject *
-Handle_get_volume_maximum(Handle *self, void* nothing)
-{
- try
- {
- 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());
- }
- else
- {
- PyErr_SetString(AUDError, device_not_3d_error);
- return NULL;
- }
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
-}
-
-static int
-Handle_set_volume_maximum(Handle *self, PyObject *args, void* nothing)
-{
- float volume;
-
- if(!PyArg_Parse(args, "f:volume_maximum", &volume))
- return -1;
-
- try
- {
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
- if(handle)
- {
- if(handle->setVolumeMaximum(volume))
- return 0;
- PyErr_SetString(AUDError, "Couldn't set the maximum volume!");
- }
- else
- PyErr_SetString(AUDError, device_not_3d_error);
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- }
-
- return -1;
-}
-
-PyDoc_STRVAR(M_aud_Handle_distance_reference_doc,
- "The reference distance of the source.\n"
- "At this distance the volume will be exactly :attr:`volume`.\n\n"
- ".. seealso:: :attr:`Device.distance_model`");
-
-static PyObject *
-Handle_get_distance_reference(Handle *self, void* nothing)
-{
- try
- {
- 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());
- }
- else
- {
- PyErr_SetString(AUDError, device_not_3d_error);
- return NULL;
- }
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
-}
-
-static int
-Handle_set_distance_reference(Handle *self, PyObject *args, void* nothing)
-{
- float distance;
-
- if(!PyArg_Parse(args, "f:distance_reference", &distance))
- return -1;
-
- try
- {
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
- if(handle)
- {
- if(handle->setDistanceReference(distance))
- return 0;
- PyErr_SetString(AUDError, "Couldn't set the reference distance!");
- }
- else
- PyErr_SetString(AUDError, device_not_3d_error);
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- }
-
- return -1;
-}
-
-PyDoc_STRVAR(M_aud_Handle_distance_maximum_doc,
- "The maximum distance of the source.\n"
- "If the listener is further away the source volume will be 0.\n\n"
- ".. seealso:: :attr:`Device.distance_model`");
-
-static PyObject *
-Handle_get_distance_maximum(Handle *self, void* nothing)
-{
- try
- {
- 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());
- }
- else
- {
- PyErr_SetString(AUDError, device_not_3d_error);
- return NULL;
- }
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
-}
-
-static int
-Handle_set_distance_maximum(Handle *self, PyObject *args, void* nothing)
-{
- float distance;
-
- if(!PyArg_Parse(args, "f:distance_maximum", &distance))
- return -1;
-
- try
- {
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
- if(handle)
- {
- if(handle->setDistanceMaximum(distance))
- return 0;
- PyErr_SetString(AUDError, "Couldn't set the maximum distance!");
- }
- else
- PyErr_SetString(AUDError, device_not_3d_error);
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- }
-
- return -1;
-}
-
-PyDoc_STRVAR(M_aud_Handle_attenuation_doc,
- "This factor is used for distance based attenuation of the "
- "source.\n\n"
- ".. seealso:: :attr:`Device.distance_model`");
-
-static PyObject *
-Handle_get_attenuation(Handle *self, void* nothing)
-{
- try
- {
- 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());
- }
- else
- {
- PyErr_SetString(AUDError, device_not_3d_error);
- return NULL;
- }
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
-}
-
-static int
-Handle_set_attenuation(Handle *self, PyObject *args, void* nothing)
-{
- float factor;
-
- if(!PyArg_Parse(args, "f:attenuation", &factor))
- return -1;
-
- try
- {
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
- if(handle)
- {
- if(handle->setAttenuation(factor))
- return 0;
- PyErr_SetString(AUDError, "Couldn't set the attenuation!");
- }
- else
- PyErr_SetString(AUDError, device_not_3d_error);
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- }
-
- return -1;
-}
-
-PyDoc_STRVAR(M_aud_Handle_cone_angle_inner_doc,
- "The opening angle of the inner cone of the source. If the cone "
- "values of a source are set there are two (audible) cones with "
- "the apex at the :attr:`location` of the source and with infinite "
- "height, heading in the direction of the source's "
- ":attr:`orientation`.\n"
- "In the inner cone the volume is normal. Outside the outer cone "
- "the volume will be :attr:`cone_volume_outer` and in the area "
- "between the volume will be interpolated linearly.");
-
-static PyObject *
-Handle_get_cone_angle_inner(Handle *self, void* nothing)
-{
- try
- {
- 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());
- }
- else
- {
- PyErr_SetString(AUDError, device_not_3d_error);
- return NULL;
- }
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
-}
-
-static int
-Handle_set_cone_angle_inner(Handle *self, PyObject *args, void* nothing)
-{
- float angle;
-
- if(!PyArg_Parse(args, "f:cone_angle_inner", &angle))
- return -1;
-
- try
- {
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
- if(handle)
- {
- if(handle->setConeAngleInner(angle))
- return 0;
- PyErr_SetString(AUDError, "Couldn't set the cone inner angle!");
- }
- else
- PyErr_SetString(AUDError, device_not_3d_error);
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- }
-
- return -1;
-}
-
-PyDoc_STRVAR(M_aud_Handle_cone_angle_outer_doc,
- "The opening angle of the outer cone of the source.\n\n"
- ".. seealso:: :attr:`cone_angle_inner`");
-
-static PyObject *
-Handle_get_cone_angle_outer(Handle *self, void* nothing)
-{
- try
- {
- 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());
- }
- else
- {
- PyErr_SetString(AUDError, device_not_3d_error);
- return NULL;
- }
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
-}
-
-static int
-Handle_set_cone_angle_outer(Handle *self, PyObject *args, void* nothing)
-{
- float angle;
-
- if(!PyArg_Parse(args, "f:cone_angle_outer", &angle))
- return -1;
-
- try
- {
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
- if(handle)
- {
- if(handle->setConeAngleOuter(angle))
- return 0;
- PyErr_SetString(AUDError, "Couldn't set the cone outer angle!");
- }
- else
- PyErr_SetString(AUDError, device_not_3d_error);
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- }
-
- return -1;
-}
-
-PyDoc_STRVAR(M_aud_Handle_cone_volume_outer_doc,
- "The volume outside the outer cone of the source.\n\n"
- ".. seealso:: :attr:`cone_angle_inner`");
-
-static PyObject *
-Handle_get_cone_volume_outer(Handle *self, void* nothing)
-{
- try
- {
- 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());
- }
- else
- {
- PyErr_SetString(AUDError, device_not_3d_error);
- return NULL;
- }
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
-}
-
-static int
-Handle_set_cone_volume_outer(Handle *self, PyObject *args, void* nothing)
-{
- float volume;
-
- if(!PyArg_Parse(args, "f:cone_volume_outer", &volume))
- return -1;
-
- try
- {
- AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
- if(handle)
- {
- if(handle->setConeVolumeOuter(volume))
- return 0;
- PyErr_SetString(AUDError, "Couldn't set the cone outer volume!");
- }
- else
- PyErr_SetString(AUDError, device_not_3d_error);
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- }
-
- return -1;
-}
-
-static PyGetSetDef Handle_properties[] = {
- {(char*)"position", (getter)Handle_get_position, (setter)Handle_set_position,
- M_aud_Handle_position_doc, NULL },
- {(char*)"keep", (getter)Handle_get_keep, (setter)Handle_set_keep,
- M_aud_Handle_keep_doc, NULL },
- {(char*)"status", (getter)Handle_get_status, NULL,
- M_aud_Handle_status_doc, NULL },
- {(char*)"volume", (getter)Handle_get_volume, (setter)Handle_set_volume,
- M_aud_Handle_volume_doc, NULL },
- {(char*)"pitch", (getter)Handle_get_pitch, (setter)Handle_set_pitch,
- M_aud_Handle_pitch_doc, NULL },
- {(char*)"loop_count", (getter)Handle_get_loop_count, (setter)Handle_set_loop_count,
- M_aud_Handle_loop_count_doc, NULL },
- {(char*)"location", (getter)Handle_get_location, (setter)Handle_set_location,
- M_aud_Handle_location_doc, NULL },
- {(char*)"velocity", (getter)Handle_get_velocity, (setter)Handle_set_velocity,
- M_aud_Handle_velocity_doc, NULL },
- {(char*)"orientation", (getter)Handle_get_orientation, (setter)Handle_set_orientation,
- M_aud_Handle_orientation_doc, NULL },
- {(char*)"relative", (getter)Handle_get_relative, (setter)Handle_set_relative,
- M_aud_Handle_relative_doc, NULL },
- {(char*)"volume_minimum", (getter)Handle_get_volume_minimum, (setter)Handle_set_volume_minimum,
- M_aud_Handle_volume_minimum_doc, NULL },
- {(char*)"volume_maximum", (getter)Handle_get_volume_maximum, (setter)Handle_set_volume_maximum,
- M_aud_Handle_volume_maximum_doc, NULL },
- {(char*)"distance_reference", (getter)Handle_get_distance_reference, (setter)Handle_set_distance_reference,
- M_aud_Handle_distance_reference_doc, NULL },
- {(char*)"distance_maximum", (getter)Handle_get_distance_maximum, (setter)Handle_set_distance_maximum,
- M_aud_Handle_distance_maximum_doc, NULL },
- {(char*)"attenuation", (getter)Handle_get_attenuation, (setter)Handle_set_attenuation,
- M_aud_Handle_attenuation_doc, NULL },
- {(char*)"cone_angle_inner", (getter)Handle_get_cone_angle_inner, (setter)Handle_set_cone_angle_inner,
- M_aud_Handle_cone_angle_inner_doc, NULL },
- {(char*)"cone_angle_outer", (getter)Handle_get_cone_angle_outer, (setter)Handle_set_cone_angle_outer,
- M_aud_Handle_cone_angle_outer_doc, NULL },
- {(char*)"cone_volume_outer", (getter)Handle_get_cone_volume_outer, (setter)Handle_set_cone_volume_outer,
- M_aud_Handle_cone_volume_outer_doc, NULL },
- {NULL} /* Sentinel */
-};
-
-PyDoc_STRVAR(M_aud_Handle_doc,
- "Handle objects are playback handles that can be used to control "
- "playback of a sound. If a sound is played back multiple times "
- "then there are as many handles.");
-
-static PyTypeObject HandleType = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "aud.Handle", /* tp_name */
- sizeof(Handle), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)Handle_dealloc,/* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- M_aud_Handle_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- Handle_methods, /* tp_methods */
- 0, /* tp_members */
- Handle_properties, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
-};
-
-// ========== Device ==================================================
-
-static void
-Device_dealloc(Device* self)
-{
- if(self->device)
- delete reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device);
- Py_TYPE(self)->tp_free((PyObject *)self);
-}
-
-static PyObject *
-Device_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
- Device *self;
-
- static const char *kwlist[] = {"type", "rate", "channels", "format", "buffer_size", "name", NULL};
- int device;
- double rate = AUD_RATE_48000;
- int channels = AUD_CHANNELS_STEREO;
- int format = AUD_FORMAT_FLOAT32;
- int buffersize = AUD_DEFAULT_BUFFER_SIZE;
- const char* name = "Audaspace";
-
- if(!PyArg_ParseTupleAndKeywords(args, kwds, "i|diiis:Device", const_cast<char**>(kwlist),
- &device, &rate, &channels, &format, &buffersize, &name))
- return NULL;
-
- if(buffersize < 128)
- {
- PyErr_SetString(PyExc_ValueError, "buffer_size must be greater than 127!");
- return NULL;
- }
-
- self = (Device*)type->tp_alloc(type, 0);
- if(self != NULL)
- {
- AUD_DeviceSpecs specs;
- specs.channels = (AUD_Channels)channels;
- specs.format = (AUD_SampleFormat)format;
- specs.rate = (AUD_SampleRate)rate;
-
- self->device = NULL;
-
- try
- {
- switch(device)
- {
- case AUD_DEVICE_NULL:
- (void)specs; /* quiet warning when others disabled */
- self->device = new boost::shared_ptr<AUD_IDevice>(new AUD_NULLDevice());
- break;
- case AUD_DEVICE_OPENAL:
-#ifdef WITH_OPENAL
- 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 boost::shared_ptr<AUD_IDevice>(new AUD_SDLDevice(specs, buffersize));
-#endif
- break;
- case AUD_DEVICE_JACK:
-#ifdef WITH_JACK
- self->device = new boost::shared_ptr<AUD_IDevice>(new AUD_JackDevice(name, specs, buffersize));
-#endif
- break;
- case AUD_DEVICE_READ:
- break;
- }
-
- }
- catch(AUD_Exception& e)
- {
- Py_DECREF(self);
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
-
- if(!self->device)
- {
- Py_DECREF(self);
- PyErr_SetString(AUDError, "Unsupported device type!");
- return NULL;
- }
- }
-
- return (PyObject *)self;
-}
-
-PyDoc_STRVAR(M_aud_Device_play_doc,
- "play(factory, keep=False)\n\n"
- "Plays a factory.\n\n"
- ":arg factory: The factory to play.\n"
- ":type factory: :class:`Factory`\n"
- ":arg keep: See :attr:`Handle.keep`.\n"
- ":type keep: bool\n"
- ":return: The playback handle with which playback can be "
- "controlled with.\n"
- ":rtype: :class:`Handle`");
-
-static PyObject *
-Device_play(Device *self, PyObject *args, PyObject *kwds)
-{
- PyObject *object;
- PyObject *keepo = NULL;
-
- bool keep = false;
-
- static const char *kwlist[] = {"factory", "keep", NULL};
-
- if(!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:play", const_cast<char**>(kwlist), &object, &keepo))
- return NULL;
-
- if(!PyObject_TypeCheck(object, &FactoryType))
- {
- PyErr_SetString(PyExc_TypeError, "Object is not of type Factory!");
- return NULL;
- }
-
- if(keepo != NULL)
- {
- if(!PyBool_Check(keepo))
- {
- PyErr_SetString(PyExc_TypeError, "keep is not a boolean!");
- return NULL;
- }
-
- keep = keepo == Py_True;
- }
-
- Factory* sound = (Factory*)object;
- Handle *handle;
-
- handle = (Handle*)HandleType.tp_alloc(&HandleType, 0);
- if(handle != NULL)
- {
- try
- {
- 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)
- {
- Py_DECREF(handle);
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
- }
-
- return (PyObject *)handle;
-}
-
-PyDoc_STRVAR(M_aud_Device_stopAll_doc,
- "stopAll()\n\n"
- "Stops all playing and paused sounds.");
-
-static PyObject *
-Device_stopAll(Device *self)
-{
- try
- {
- (*reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device))->stopAll();
- Py_RETURN_NONE;
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
-}
-
-PyDoc_STRVAR(M_aud_Device_lock_doc,
- "lock()\n\n"
- "Locks the device so that it's guaranteed, that no samples are "
- "read from the streams until :meth:`unlock` is called.\n"
- "This is useful if you want to do start/stop/pause/resume some "
- "sounds at the same time.\n\n"
- ".. note:: The device has to be unlocked as often as locked to be "
- "able to continue playback.\n\n"
- ".. warning:: Make sure the time between locking and unlocking is "
- "as short as possible to avoid clicks.");
-
-static PyObject *
-Device_lock(Device *self)
-{
- try
- {
- (*reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device))->lock();
- Py_RETURN_NONE;
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
-}
-
-PyDoc_STRVAR(M_aud_Device_unlock_doc,
- "unlock()\n\n"
- "Unlocks the device after a lock call, see :meth:`lock` for "
- "details.");
-
-static PyObject *
-Device_unlock(Device *self)
-{
- try
- {
- (*reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device))->unlock();
- Py_RETURN_NONE;
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
-}
-
-static PyMethodDef Device_methods[] = {
- {"play", (PyCFunction)Device_play, METH_VARARGS | METH_KEYWORDS,
- M_aud_Device_play_doc
- },
- {"stopAll", (PyCFunction)Device_stopAll, METH_NOARGS,
- M_aud_Device_stopAll_doc
- },
- {"lock", (PyCFunction)Device_lock, METH_NOARGS,
- M_aud_Device_lock_doc
- },
- {"unlock", (PyCFunction)Device_unlock, METH_NOARGS,
- M_aud_Device_unlock_doc
- },
- {NULL} /* Sentinel */
-};
-
-PyDoc_STRVAR(M_aud_Device_rate_doc,
- "The sampling rate of the device in Hz.");
-
-static PyObject *
-Device_get_rate(Device *self, void* nothing)
-{
- try
- {
- AUD_DeviceSpecs specs = (*reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device))->getSpecs();
- return Py_BuildValue("d", specs.rate);
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
-}
-
-PyDoc_STRVAR(M_aud_Device_format_doc,
- "The native sample format of the device.");
-
-static PyObject *
-Device_get_format(Device *self, void* nothing)
-{
- try
- {
- AUD_DeviceSpecs specs = (*reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device))->getSpecs();
- return Py_BuildValue("i", specs.format);
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
-}
-
-PyDoc_STRVAR(M_aud_Device_channels_doc,
- "The channel count of the device.");
-
-static PyObject *
-Device_get_channels(Device *self, void* nothing)
-{
- try
- {
- AUD_DeviceSpecs specs = (*reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device))->getSpecs();
- return Py_BuildValue("i", specs.channels);
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
-}
-
-PyDoc_STRVAR(M_aud_Device_volume_doc,
- "The overall volume of the device.");
-
-static PyObject *
-Device_get_volume(Device *self, void* nothing)
-{
- try
- {
- return Py_BuildValue("f", (*reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device))->getVolume());
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
-}
-
-static int
-Device_set_volume(Device *self, PyObject *args, void* nothing)
-{
- float volume;
-
- if(!PyArg_Parse(args, "f:volume", &volume))
- return -1;
-
- try
- {
- (*reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device))->setVolume(volume);
- return 0;
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- return -1;
- }
-}
-
-PyDoc_STRVAR(M_aud_Device_listener_location_doc,
- "The listeners's location in 3D space, a 3D tuple of floats.");
-
-static PyObject *
-Device_get_listener_location(Device *self, void* nothing)
-{
- try
- {
- AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device)->get());
- if(device)
- {
- AUD_Vector3 v = device->getListenerLocation();
- return Py_BuildValue("(fff)", v.x(), v.y(), v.z());
- }
- else
- {
- PyErr_SetString(AUDError, device_not_3d_error);
- }
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- }
-
- return NULL;
-}
-
-static int
-Device_set_listener_location(Device *self, PyObject *args, void* nothing)
-{
- float x, y, z;
-
- if(!PyArg_Parse(args, "(fff):listener_location", &x, &y, &z))
- return -1;
-
- try
- {
- 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);
- device->setListenerLocation(location);
- return 0;
- }
- else
- PyErr_SetString(AUDError, device_not_3d_error);
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- }
-
- return -1;
-}
-
-PyDoc_STRVAR(M_aud_Device_listener_velocity_doc,
- "The listener's velocity in 3D space, a 3D tuple of floats.");
-
-static PyObject *
-Device_get_listener_velocity(Device *self, void* nothing)
-{
- try
- {
- AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device)->get());
- if(device)
- {
- AUD_Vector3 v = device->getListenerVelocity();
- return Py_BuildValue("(fff)", v.x(), v.y(), v.z());
- }
- else
- {
- PyErr_SetString(AUDError, device_not_3d_error);
- }
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- }
-
- return NULL;
-}
-
-static int
-Device_set_listener_velocity(Device *self, PyObject *args, void* nothing)
-{
- float x, y, z;
-
- if(!PyArg_Parse(args, "(fff):listener_velocity", &x, &y, &z))
- return -1;
-
- try
- {
- 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);
- device->setListenerVelocity(velocity);
- return 0;
- }
- else
- PyErr_SetString(AUDError, device_not_3d_error);
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- }
-
- return -1;
-}
-
-PyDoc_STRVAR(M_aud_Device_listener_orientation_doc,
- "The listener's orientation in 3D space as quaternion, a 4 float tuple.");
-
-static PyObject *
-Device_get_listener_orientation(Device *self, void* nothing)
-{
- try
- {
- AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device)->get());
- if(device)
- {
- AUD_Quaternion o = device->getListenerOrientation();
- return Py_BuildValue("(ffff)", o.w(), o.x(), o.y(), o.z());
- }
- else
- {
- PyErr_SetString(AUDError, device_not_3d_error);
- }
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- }
-
- return NULL;
-}
-
-static int
-Device_set_listener_orientation(Device *self, PyObject *args, void* nothing)
-{
- float w, x, y, z;
-
- if(!PyArg_Parse(args, "(ffff):listener_orientation", &w, &x, &y, &z))
- return -1;
-
- try
- {
- 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);
- device->setListenerOrientation(orientation);
- return 0;
- }
- else
- PyErr_SetString(AUDError, device_not_3d_error);
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- }
-
- return -1;
-}
-
-PyDoc_STRVAR(M_aud_Device_speed_of_sound_doc,
- "The speed of sound of the device.\n"
- "The speed of sound in air is typically 343.3 m/s.");
-
-static PyObject *
-Device_get_speed_of_sound(Device *self, void* nothing)
-{
- try
- {
- 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());
- }
- else
- {
- PyErr_SetString(AUDError, device_not_3d_error);
- return NULL;
- }
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
-}
-
-static int
-Device_set_speed_of_sound(Device *self, PyObject *args, void* nothing)
-{
- float speed;
-
- if(!PyArg_Parse(args, "f:speed_of_sound", &speed))
- return -1;
-
- try
- {
- AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device)->get());
- if(device)
- {
- device->setSpeedOfSound(speed);
- return 0;
- }
- else
- PyErr_SetString(AUDError, device_not_3d_error);
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- }
-
- return -1;
-}
-
-PyDoc_STRVAR(M_aud_Device_doppler_factor_doc,
- "The doppler factor of the device.\n"
- "This factor is a scaling factor for the velocity vectors in "
- "doppler calculation. So a value bigger than 1 will exaggerate "
- "the effect as it raises the velocity.");
-
-static PyObject *
-Device_get_doppler_factor(Device *self, void* nothing)
-{
- try
- {
- 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());
- }
- else
- {
- PyErr_SetString(AUDError, device_not_3d_error);
- return NULL;
- }
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
-}
-
-static int
-Device_set_doppler_factor(Device *self, PyObject *args, void* nothing)
-{
- float factor;
-
- if(!PyArg_Parse(args, "f:doppler_factor", &factor))
- return -1;
-
- try
- {
- AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device)->get());
- if(device)
- {
- device->setDopplerFactor(factor);
- return 0;
- }
- else
- PyErr_SetString(AUDError, device_not_3d_error);
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- }
-
- return -1;
-}
-
-PyDoc_STRVAR(M_aud_Device_distance_model_doc,
- "The distance model of the device.\n\n"
- ".. seealso:: `OpenAL documentation <https://www.openal.org/documentation>`");
-
-static PyObject *
-Device_get_distance_model(Device *self, void* nothing)
-{
- try
- {
- 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()));
- }
- else
- {
- PyErr_SetString(AUDError, device_not_3d_error);
- return NULL;
- }
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- return NULL;
- }
-}
-
-static int
-Device_set_distance_model(Device *self, PyObject *args, void* nothing)
-{
- int model;
-
- if(!PyArg_Parse(args, "i:distance_model", &model))
- return -1;
-
- try
- {
- AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device)->get());
- if(device)
- {
- device->setDistanceModel(AUD_DistanceModel(model));
- return 0;
- }
- else
- PyErr_SetString(AUDError, device_not_3d_error);
- }
- catch(AUD_Exception& e)
- {
- PyErr_SetString(AUDError, e.str);
- }
-
- return -1;
-}
-
-static PyGetSetDef Device_properties[] = {
- {(char*)"rate", (getter)Device_get_rate, NULL,
- M_aud_Device_rate_doc, NULL },
- {(char*)"format", (getter)Device_get_format, NULL,
- M_aud_Device_format_doc, NULL },
- {(char*)"channels", (getter)Device_get_channels, NULL,
- M_aud_Device_channels_doc, NULL },
- {(char*)"volume", (getter)Device_get_volume, (setter)Device_set_volume,
- M_aud_Device_volume_doc, NULL },
- {(char*)"listener_location", (getter)Device_get_listener_location, (setter)Device_set_listener_location,
- M_aud_Device_listener_location_doc, NULL },
- {(char*)"listener_velocity", (getter)Device_get_listener_velocity, (setter)Device_set_listener_velocity,
- M_aud_Device_listener_velocity_doc, NULL },
- {(char*)"listener_orientation", (getter)Device_get_listener_orientation, (setter)Device_set_listener_orientation,
- M_aud_Device_listener_orientation_doc, NULL },
- {(char*)"speed_of_sound", (getter)Device_get_speed_of_sound, (setter)Device_set_speed_of_sound,
- M_aud_Device_speed_of_sound_doc, NULL },
- {(char*)"doppler_factor", (getter)Device_get_doppler_factor, (setter)Device_set_doppler_factor,
- M_aud_Device_doppler_factor_doc, NULL },
- {(char*)"distance_model", (getter)Device_get_distance_model, (setter)Device_set_distance_model,
- M_aud_Device_distance_model_doc, NULL },
- {NULL} /* Sentinel */
-};
-
-PyDoc_STRVAR(M_aud_Device_doc,
- "Device objects represent an audio output backend like OpenAL or "
- "SDL, but might also represent a file output or RAM buffer "
- "output.");
-
-static PyTypeObject DeviceType = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "aud.Device", /* tp_name */
- sizeof(Device), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)Device_dealloc,/* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- M_aud_Device_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- Device_methods, /* tp_methods */
- 0, /* tp_members */
- Device_properties, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- Device_new, /* tp_new */
-};
-
-PyObject *
-Device_empty()
-{
- return DeviceType.tp_alloc(&DeviceType, 0);
-}
-
-PyObject *
-Factory_empty()
-{
- return FactoryType.tp_alloc(&FactoryType, 0);
-}
-
-Factory*
-checkFactory(PyObject *factory)
-{
- if(!PyObject_TypeCheck(factory, &FactoryType))
- {
- PyErr_SetString(PyExc_TypeError, "Object is not of type Factory!");
- return NULL;
- }
-
- return (Factory*)factory;
-}
-
-
-// ====================================================================
-
-PyDoc_STRVAR(M_aud_doc,
- "This module provides access to the audaspace audio library.");
-
-static struct PyModuleDef audmodule = {
- PyModuleDef_HEAD_INIT,
- "aud", /* name of module */
- M_aud_doc, /* module documentation */
- -1, /* size of per-interpreter state of the module,
- or -1 if the module keeps state in global variables. */
- NULL, NULL, NULL, NULL, NULL
-};
-
-PyMODINIT_FUNC
-PyInit_aud(void)
-{
- PyObject *m;
-
- if(PyType_Ready(&FactoryType) < 0)
- return NULL;
-
- if(PyType_Ready(&DeviceType) < 0)
- return NULL;
-
- if(PyType_Ready(&HandleType) < 0)
- return NULL;
-
- m = PyModule_Create(&audmodule);
- if(m == NULL)
- return NULL;
-
- Py_INCREF(&FactoryType);
- PyModule_AddObject(m, "Factory", (PyObject *)&FactoryType);
-
- Py_INCREF(&DeviceType);
- PyModule_AddObject(m, "Device", (PyObject *)&DeviceType);
-
- Py_INCREF(&HandleType);
- PyModule_AddObject(m, "Handle", (PyObject *)&HandleType);
-
- AUDError = PyErr_NewException("aud.error", NULL, NULL);
- Py_INCREF(AUDError);
- PyModule_AddObject(m, "error", AUDError);
-
- // device constants
- PY_MODULE_ADD_CONSTANT(m, AUD_DEVICE_NULL);
- PY_MODULE_ADD_CONSTANT(m, AUD_DEVICE_OPENAL);
- PY_MODULE_ADD_CONSTANT(m, AUD_DEVICE_SDL);
- PY_MODULE_ADD_CONSTANT(m, AUD_DEVICE_JACK);
- //PY_MODULE_ADD_CONSTANT(m, AUD_DEVICE_READ);
- // format constants
- PY_MODULE_ADD_CONSTANT(m, AUD_FORMAT_FLOAT32);
- PY_MODULE_ADD_CONSTANT(m, AUD_FORMAT_FLOAT64);
- PY_MODULE_ADD_CONSTANT(m, AUD_FORMAT_INVALID);
- PY_MODULE_ADD_CONSTANT(m, AUD_FORMAT_S16);
- PY_MODULE_ADD_CONSTANT(m, AUD_FORMAT_S24);
- PY_MODULE_ADD_CONSTANT(m, AUD_FORMAT_S32);
- PY_MODULE_ADD_CONSTANT(m, AUD_FORMAT_U8);
- // status constants
- PY_MODULE_ADD_CONSTANT(m, AUD_STATUS_INVALID);
- PY_MODULE_ADD_CONSTANT(m, AUD_STATUS_PAUSED);
- PY_MODULE_ADD_CONSTANT(m, AUD_STATUS_PLAYING);
- PY_MODULE_ADD_CONSTANT(m, AUD_STATUS_STOPPED);
- // distance model constants
- PY_MODULE_ADD_CONSTANT(m, AUD_DISTANCE_MODEL_EXPONENT);
- PY_MODULE_ADD_CONSTANT(m, AUD_DISTANCE_MODEL_EXPONENT_CLAMPED);
- PY_MODULE_ADD_CONSTANT(m, AUD_DISTANCE_MODEL_INVERSE);
- PY_MODULE_ADD_CONSTANT(m, AUD_DISTANCE_MODEL_INVERSE_CLAMPED);
- PY_MODULE_ADD_CONSTANT(m, AUD_DISTANCE_MODEL_LINEAR);
- PY_MODULE_ADD_CONSTANT(m, AUD_DISTANCE_MODEL_LINEAR_CLAMPED);
- PY_MODULE_ADD_CONSTANT(m, AUD_DISTANCE_MODEL_INVALID);
-
- return m;
-}
diff --git a/intern/audaspace/Python/AUD_PyAPI.h b/intern/audaspace/Python/AUD_PyAPI.h
deleted file mode 100644
index 0183a2df6b2..00000000000
--- a/intern/audaspace/Python/AUD_PyAPI.h
+++ /dev/null
@@ -1,74 +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/Python/AUD_PyAPI.h
- * \ingroup audpython
- */
-
-
-#ifndef __AUD_PYAPI_H__
-#define __AUD_PYAPI_H__
-
-#include "Python.h"
-
-#ifdef __cplusplus
-extern "C" {
-#else
-typedef void AUD_IFactory;
-typedef void AUD_IDevice;
-typedef void AUD_IHandle;
-#endif
-
-typedef void AUD_Reference_AUD_IFactory;
-typedef void AUD_Reference_AUD_IDevice;
-typedef void AUD_Reference_AUD_IHandle;
-
-typedef struct {
- PyObject_HEAD
- PyObject *child_list;
- AUD_Reference_AUD_IFactory* factory;
-} Factory;
-
-typedef struct {
- PyObject_HEAD
- AUD_Reference_AUD_IHandle* handle;
-} Handle;
-
-typedef struct {
- PyObject_HEAD
- AUD_Reference_AUD_IDevice* device;
-} Device;
-
-PyMODINIT_FUNC
-PyInit_aud(void);
-
-extern PyObject *Device_empty();
-extern PyObject *Factory_empty();
-extern Factory *checkFactory(PyObject *factory);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__AUD_PYAPI_H__
diff --git a/intern/audaspace/SDL/AUD_SDLDevice.cpp b/intern/audaspace/SDL/AUD_SDLDevice.cpp
deleted file mode 100644
index 23729a7a171..00000000000
--- a/intern/audaspace/SDL/AUD_SDLDevice.cpp
+++ /dev/null
@@ -1,97 +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/SDL/AUD_SDLDevice.cpp
- * \ingroup audsdl
- */
-
-
-#include "AUD_SDLDevice.h"
-#include "AUD_IReader.h"
-
-void AUD_SDLDevice::SDL_mix(void *data, Uint8* buffer, int length)
-{
- AUD_SDLDevice* device = (AUD_SDLDevice*)data;
-
- device->mix((data_t*)buffer,length/AUD_DEVICE_SAMPLE_SIZE(device->m_specs));
-}
-
-static const char* open_error = "AUD_SDLDevice: Device couldn't be opened.";
-static const char* format_error = "AUD_SDLDevice: Obtained unsupported sample "
- "format.";
-
-AUD_SDLDevice::AUD_SDLDevice(AUD_DeviceSpecs specs, int buffersize)
-{
- if(specs.channels == AUD_CHANNELS_INVALID)
- specs.channels = AUD_CHANNELS_STEREO;
- if(specs.format == AUD_FORMAT_INVALID)
- specs.format = AUD_FORMAT_S16;
- if(specs.rate == AUD_RATE_INVALID)
- specs.rate = AUD_RATE_48000;
-
- m_specs = specs;
-
- SDL_AudioSpec format, obtained;
-
- format.freq = m_specs.rate;
- if(m_specs.format == AUD_FORMAT_U8)
- format.format = AUDIO_U8;
- else
- format.format = AUDIO_S16SYS;
- format.channels = m_specs.channels;
- format.samples = buffersize;
- format.callback = AUD_SDLDevice::SDL_mix;
- format.userdata = this;
-
- if(SDL_OpenAudio(&format, &obtained) != 0)
- AUD_THROW(AUD_ERROR_SDL, open_error);
-
- m_specs.rate = (AUD_SampleRate)obtained.freq;
- m_specs.channels = (AUD_Channels)obtained.channels;
- if(obtained.format == AUDIO_U8)
- m_specs.format = AUD_FORMAT_U8;
- else if(obtained.format == AUDIO_S16LSB || obtained.format == AUDIO_S16MSB)
- m_specs.format = AUD_FORMAT_S16;
- else
- {
- SDL_CloseAudio();
- AUD_THROW(AUD_ERROR_SDL, format_error);
- }
-
- create();
-}
-
-AUD_SDLDevice::~AUD_SDLDevice()
-{
- lock();
- SDL_CloseAudio();
- unlock();
-
- destroy();
-}
-
-void AUD_SDLDevice::playing(bool playing)
-{
- SDL_PauseAudio(playing ? 0 : 1);
-}
diff --git a/intern/audaspace/SDL/AUD_SDLDevice.h b/intern/audaspace/SDL/AUD_SDLDevice.h
deleted file mode 100644
index c4ff9e80aa9..00000000000
--- a/intern/audaspace/SDL/AUD_SDLDevice.h
+++ /dev/null
@@ -1,86 +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/SDL/AUD_SDLDevice.h
- * \ingroup audsdl
- */
-
-
-#ifndef __AUD_SDLDEVICE_H__
-#define __AUD_SDLDEVICE_H__
-
-#include "AUD_SoftwareDevice.h"
-
-/* SDL force defines __SSE__ and __SSE2__ flags, which generates warnings
- * because we pass those defines via command line as well. For until there's
- * proper ifndef added to SDL headers we ignore the redefinition warning.
- */
-#ifdef _MSC_VER
-# pragma warning(push)
-# pragma warning(disable : 4005)
-#endif
-#include <SDL.h>
-#ifdef _MSC_VER
-# pragma warning(pop)
-#endif
-
-/**
- * This device plays back through SDL, the simple direct media layer.
- */
-class AUD_SDLDevice : public AUD_SoftwareDevice
-{
-private:
- /**
- * Mixes the next bytes into the buffer.
- * \param data The SDL device.
- * \param buffer The target buffer.
- * \param length The length in bytes to be filled.
- */
- static void SDL_mix(void *data, Uint8* buffer, int length);
-
- // hide copy constructor and operator=
- AUD_SDLDevice(const AUD_SDLDevice&);
- AUD_SDLDevice& operator=(const AUD_SDLDevice&);
-
-protected:
- virtual void playing(bool playing);
-
-public:
- /**
- * Opens the SDL audio device for playback.
- * \param specs The wanted audio specification.
- * \param buffersize The size of the internal buffer.
- * \note The specification really used for opening the device may differ.
- * \exception AUD_Exception Thrown if the audio device cannot be opened.
- */
- AUD_SDLDevice(AUD_DeviceSpecs specs,
- int buffersize = AUD_DEFAULT_BUFFER_SIZE);
-
- /**
- * Closes the SDL audio device.
- */
- virtual ~AUD_SDLDevice();
-};
-
-#endif //__AUD_SDLDEVICE_H__
diff --git a/intern/audaspace/SRC/AUD_SRCResampleFactory.cpp b/intern/audaspace/SRC/AUD_SRCResampleFactory.cpp
deleted file mode 100644
index 6861e878abc..00000000000
--- a/intern/audaspace/SRC/AUD_SRCResampleFactory.cpp
+++ /dev/null
@@ -1,42 +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/SRC/AUD_SRCResampleFactory.cpp
- * \ingroup audsrc
- */
-
-
-#include "AUD_SRCResampleFactory.h"
-#include "AUD_SRCResampleReader.h"
-
-AUD_SRCResampleFactory::AUD_SRCResampleFactory(AUD_Reference<AUD_IFactory> factory,
- AUD_DeviceSpecs specs) :
- AUD_MixerFactory(factory, specs)
-{
-}
-
-AUD_Reference<AUD_IReader> AUD_SRCResampleFactory::createReader()
-{
- return new AUD_SRCResampleReader(getReader(), m_specs.specs);
-}
diff --git a/intern/audaspace/SRC/AUD_SRCResampleFactory.h b/intern/audaspace/SRC/AUD_SRCResampleFactory.h
deleted file mode 100644
index 858bb0c130a..00000000000
--- a/intern/audaspace/SRC/AUD_SRCResampleFactory.h
+++ /dev/null
@@ -1,57 +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/SRC/AUD_SRCResampleFactory.h
- * \ingroup audsrc
- */
-
-
-#ifndef __AUD_SRCRESAMPLEFACTORY_H__
-#define __AUD_SRCRESAMPLEFACTORY_H__
-
-#include "AUD_MixerFactory.h"
-
-/**
- * This factory creates a resampling reader that uses libsamplerate for
- * resampling.
- */
-class AUD_SRCResampleFactory : public AUD_MixerFactory
-{
-private:
- // hide copy constructor and operator=
- AUD_SRCResampleFactory(const AUD_SRCResampleFactory&);
- AUD_SRCResampleFactory& operator=(const AUD_SRCResampleFactory&);
-
-public:
- /**
- * Creates a new factory.
- * \param factory The input factory.
- * \param specs The target specifications.
- */
- AUD_SRCResampleFactory(AUD_Reference<AUD_IFactory> factory, AUD_DeviceSpecs specs);
-
- virtual AUD_Reference<AUD_IReader> createReader();
-};
-
-#endif //__AUD_SRCRESAMPLEFACTORY_H__
diff --git a/intern/audaspace/SRC/AUD_SRCResampleReader.cpp b/intern/audaspace/SRC/AUD_SRCResampleReader.cpp
deleted file mode 100644
index 242a7135aff..00000000000
--- a/intern/audaspace/SRC/AUD_SRCResampleReader.cpp
+++ /dev/null
@@ -1,150 +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/SRC/AUD_SRCResampleReader.cpp
- * \ingroup audsrc
- */
-
-
-#include "AUD_SRCResampleReader.h"
-
-#include <cmath>
-#include <cstring>
-#include <cstdio>
-
-static long src_callback(void *cb_data, float **data)
-{
- return ((AUD_SRCResampleReader*)cb_data)->doCallback(data);
-}
-
-static const char* state_error = "AUD_SRCResampleReader: SRC State couldn't be "
- "created.";
-
-AUD_SRCResampleReader::AUD_SRCResampleReader(AUD_Reference<AUD_IReader> reader,
- AUD_Specs specs) :
- AUD_ResampleReader(reader, specs.rate),
- m_channels(reader->getSpecs().channels),
- m_position(0)
-{
- int error;
- m_src = src_callback_new(src_callback,
- SRC_SINC_MEDIUM_QUALITY,
- m_channels,
- &error,
- this);
-
- if(!m_src)
- {
- // XXX printf("%s\n", src_strerror(error));
- AUD_THROW(AUD_ERROR_SRC, state_error);
- }
-}
-
-AUD_SRCResampleReader::~AUD_SRCResampleReader()
-{
- src_delete(m_src);
-}
-
-long AUD_SRCResampleReader::doCallback(float** data)
-{
- AUD_Specs specs;
- specs.channels = m_channels;
- specs.rate = m_rate;
-
- int length = m_buffer.getSize() / AUD_SAMPLE_SIZE(specs);
-
- *data = m_buffer.getBuffer();
- m_reader->read(length, m_eos, *data);
-
- return length;
-}
-
-void AUD_SRCResampleReader::seek(int position)
-{
- AUD_Specs specs = m_reader->getSpecs();
- double factor = double(m_rate) / double(specs.rate);
- m_reader->seek(position / factor);
- src_reset(m_src);
- m_position = position;
-}
-
-int AUD_SRCResampleReader::getLength() const
-{
- AUD_Specs specs = m_reader->getSpecs();
- double factor = double(m_rate) / double(specs.rate);
- return m_reader->getLength() * factor;
-}
-
-int AUD_SRCResampleReader::getPosition() const
-{
- return m_position;
-}
-
-AUD_Specs AUD_SRCResampleReader::getSpecs() const
-{
- AUD_Specs specs = m_reader->getSpecs();
- specs.rate = m_rate;
- return specs;
-}
-
-void AUD_SRCResampleReader::read(int& length, bool& eos, sample_t* buffer)
-{
- AUD_Specs specs = m_reader->getSpecs();
-
- double factor = double(m_rate) / double(specs.rate);
-
- specs.rate = m_rate;
-
- int size = length;
-
- m_buffer.assureSize(length * AUD_SAMPLE_SIZE(specs));
-
- if(specs.channels != m_channels)
- {
- src_delete(m_src);
-
- m_channels = specs.channels;
-
- int error;
- m_src = src_callback_new(src_callback,
- SRC_SINC_MEDIUM_QUALITY,
- m_channels,
- &error,
- this);
-
- if(!m_src)
- {
- // XXX printf("%s\n", src_strerror(error));
- AUD_THROW(AUD_ERROR_SRC, state_error);
- }
- }
-
- m_eos = false;
-
- length = src_callback_read(m_src, factor, length, buffer);
-
- m_position += length;
-
- eos = m_eos && (length < size);
-}
diff --git a/intern/audaspace/SRC/AUD_SRCResampleReader.h b/intern/audaspace/SRC/AUD_SRCResampleReader.h
deleted file mode 100644
index 891b28b0993..00000000000
--- a/intern/audaspace/SRC/AUD_SRCResampleReader.h
+++ /dev/null
@@ -1,103 +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/SRC/AUD_SRCResampleReader.h
- * \ingroup audsrc
- */
-
-
-#ifndef __AUD_SRCRESAMPLEREADER_H__
-#define __AUD_SRCRESAMPLEREADER_H__
-
-#include "AUD_ResampleReader.h"
-#include "AUD_Buffer.h"
-
-#include <samplerate.h>
-
-/**
- * This resampling reader uses libsamplerate for resampling.
- */
-class AUD_SRCResampleReader : public AUD_ResampleReader
-{
-private:
- /**
- * The sound output buffer.
- */
- AUD_Buffer m_buffer;
-
- /**
- * The reader channels.
- */
- AUD_Channels m_channels;
-
- /**
- * The src state structure.
- */
- SRC_STATE* m_src;
-
- /**
- * The current playback position;
- */
- int m_position;
-
- /**
- * Whether reader reached end of stream.
- */
- bool m_eos;
-
- // hide copy constructor and operator=
- AUD_SRCResampleReader(const AUD_SRCResampleReader&);
- AUD_SRCResampleReader& operator=(const AUD_SRCResampleReader&);
-
-public:
- /**
- * Creates a resampling reader.
- * \param reader The reader to mix.
- * \param specs The target specification.
- * \exception AUD_Exception Thrown if the source specification cannot be
- * resampled to the target specification.
- */
- AUD_SRCResampleReader(AUD_Reference<AUD_IReader> reader, AUD_Specs specs);
-
- /**
- * Destroys the reader.
- */
- ~AUD_SRCResampleReader();
-
- /**
- * The callback function for SRC.
- * \warning Do not call!
- * \param data The pointer to the float data.
- * \return The count of samples in the float data.
- */
- long doCallback(float** data);
-
- virtual void seek(int position);
- virtual int getLength() const;
- virtual int getPosition() const;
- virtual AUD_Specs getSpecs() const;
- virtual void read(int& length, bool& eos, sample_t* buffer);
-};
-
-#endif //__AUD_SRCRESAMPLEREADER_H__
diff --git a/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.cpp b/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.cpp
deleted file mode 100644
index 403c367fccc..00000000000
--- a/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.cpp
+++ /dev/null
@@ -1,55 +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/ffmpeg/AUD_FFMPEGFactory.cpp
- * \ingroup audffmpeg
- */
-
-
-// needed for INT64_C
-#ifndef __STDC_CONSTANT_MACROS
-#define __STDC_CONSTANT_MACROS
-#endif
-
-#include "AUD_FFMPEGFactory.h"
-#include "AUD_FFMPEGReader.h"
-
-AUD_FFMPEGFactory::AUD_FFMPEGFactory(std::string filename) :
- m_filename(filename)
-{
-}
-
-AUD_FFMPEGFactory::AUD_FFMPEGFactory(const data_t* buffer, int size) :
- m_buffer(new AUD_Buffer(size))
-{
- memcpy(m_buffer->getBuffer(), buffer, size);
-}
-
-boost::shared_ptr<AUD_IReader> AUD_FFMPEGFactory::createReader()
-{
- if(m_buffer.get())
- return boost::shared_ptr<AUD_IReader>(new AUD_FFMPEGReader(m_buffer));
- else
- 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
deleted file mode 100644
index 23d0f07ed0b..00000000000
--- a/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.h
+++ /dev/null
@@ -1,78 +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/ffmpeg/AUD_FFMPEGFactory.h
- * \ingroup audffmpeg
- */
-
-
-#ifndef __AUD_FFMPEGFACTORY_H__
-#define __AUD_FFMPEGFACTORY_H__
-
-#include "AUD_IFactory.h"
-#include "AUD_Buffer.h"
-
-#include <string>
-#include <boost/shared_ptr.hpp>
-
-/**
- * This factory reads a sound file via ffmpeg.
- * \warning Notice that the needed formats and codecs have to be registered
- * for ffmpeg before this class can be used.
- */
-class AUD_FFMPEGFactory : public AUD_IFactory
-{
-private:
- /**
- * The filename of the sound source file.
- */
- const std::string m_filename;
-
- /**
- * The buffer to read from.
- */
- boost::shared_ptr<AUD_Buffer> m_buffer;
-
- // hide copy constructor and operator=
- AUD_FFMPEGFactory(const AUD_FFMPEGFactory&);
- AUD_FFMPEGFactory& operator=(const AUD_FFMPEGFactory&);
-
-public:
- /**
- * Creates a new factory.
- * \param filename The sound file path.
- */
- AUD_FFMPEGFactory(std::string filename);
-
- /**
- * Creates a new factory.
- * \param buffer The buffer to read from.
- * \param size The size of the buffer.
- */
- AUD_FFMPEGFactory(const data_t* buffer, int size);
-
- 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
deleted file mode 100644
index e9eea195208..00000000000
--- a/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp
+++ /dev/null
@@ -1,483 +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/ffmpeg/AUD_FFMPEGReader.cpp
- * \ingroup audffmpeg
- */
-
-
-// needed for INT64_C
-#ifndef __STDC_CONSTANT_MACROS
-#define __STDC_CONSTANT_MACROS
-#endif
-
-#include "AUD_FFMPEGReader.h"
-
-extern "C" {
-#include <libavcodec/avcodec.h>
-#include <libavformat/avformat.h>
-#include <libavformat/avio.h>
-#include "ffmpeg_compat.h"
-}
-
-int AUD_FFMPEGReader::decode(AVPacket& packet, AUD_Buffer& buffer)
-{
-#ifdef FFMPEG_HAVE_DECODE_AUDIO4
- AVFrame* frame = NULL;
- int got_frame;
- int read_length;
- uint8_t* orig_data = packet.data;
- int orig_size = packet.size;
-
- int buf_size = buffer.getSize();
- int buf_pos = 0;
-
- while(packet.size > 0)
- {
- got_frame = 0;
-
- if(!frame)
- frame = av_frame_alloc();
- else
- av_frame_unref(frame);
-
- read_length = avcodec_decode_audio4(m_codecCtx, frame, &got_frame, &packet);
- if(read_length < 0)
- break;
-
- if(got_frame)
- {
- int data_size = av_samples_get_buffer_size(NULL, m_codecCtx->channels, frame->nb_samples, m_codecCtx->sample_fmt, 1);
-
- if(buf_size - buf_pos < data_size)
- {
- buffer.resize(buf_size + data_size, true);
- buf_size += data_size;
- }
-
- if(m_tointerleave)
- {
- int single_size = data_size / m_codecCtx->channels / frame->nb_samples;
- for(int channel = 0; channel < m_codecCtx->channels; channel++)
- {
- for(int i = 0; i < frame->nb_samples; i++)
- {
- memcpy(((data_t*)buffer.getBuffer()) + buf_pos + ((m_codecCtx->channels * i) + channel) * single_size,
- frame->data[channel] + i * single_size, single_size);
- }
- }
- }
- else
- memcpy(((data_t*)buffer.getBuffer()) + buf_pos, frame->data[0], data_size);
-
- buf_pos += data_size;
- }
- packet.size -= read_length;
- packet.data += read_length;
- }
-
- packet.data = orig_data;
- packet.size = orig_size;
- av_free(frame);
-
- return buf_pos;
-#else
- // save packet parameters
- uint8_t *audio_pkg_data = packet.data;
- int audio_pkg_size = packet.size;
-
- int buf_size = buffer.getSize();
- int buf_pos = 0;
-
- int read_length, data_size;
-
- AVPacket tmp_pkt;
-
- av_init_packet(&tmp_pkt);
-
- // as long as there is still data in the package
- while(audio_pkg_size > 0)
- {
- // resize buffer if needed
- if(buf_size - buf_pos < AVCODEC_MAX_AUDIO_FRAME_SIZE)
- {
- buffer.resize(buf_size + AVCODEC_MAX_AUDIO_FRAME_SIZE, true);
- buf_size += AVCODEC_MAX_AUDIO_FRAME_SIZE;
- }
-
- // read samples from the packet
- data_size = buf_size - buf_pos;
-
- tmp_pkt.data = audio_pkg_data;
- tmp_pkt.size = audio_pkg_size;
-
- read_length = avcodec_decode_audio3(
- m_codecCtx,
- (int16_t*)(((data_t*)buffer.getBuffer()) + buf_pos),
- &data_size, &tmp_pkt);
-
- // read error, next packet!
- if(read_length < 0)
- break;
-
- buf_pos += data_size;
-
- // move packet parameters
- audio_pkg_data += read_length;
- audio_pkg_size -= read_length;
- }
-
- return buf_pos;
-#endif
-}
-
-static const char* streaminfo_error = "AUD_FFMPEGReader: Stream info couldn't "
- "be found.";
-static const char* noaudio_error = "AUD_FFMPEGReader: File doesn't include an "
- "audio stream.";
-static const char* nodecoder_error = "AUD_FFMPEGReader: No decoder found for "
- "the audio stream.";
-static const char* codecopen_error = "AUD_FFMPEGReader: Codec couldn't be "
- "opened.";
-static const char* format_error = "AUD_FFMPEGReader: Unsupported sample "
- "format.";
-
-void AUD_FFMPEGReader::init()
-{
- m_position = 0;
- m_pkgbuf_left = 0;
-
- if(avformat_find_stream_info(m_formatCtx, NULL) < 0)
- AUD_THROW(AUD_ERROR_FFMPEG, streaminfo_error);
-
- // find audio stream and codec
- m_stream = -1;
-
- for(unsigned int i = 0; i < m_formatCtx->nb_streams; i++)
- {
- if((m_formatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
- && (m_stream < 0))
- {
- m_stream=i;
- break;
- }
- }
-
- if(m_stream == -1)
- AUD_THROW(AUD_ERROR_FFMPEG, noaudio_error);
-
- m_codecCtx = m_formatCtx->streams[m_stream]->codec;
-
- // get a decoder and open it
- AVCodec *aCodec = avcodec_find_decoder(m_codecCtx->codec_id);
- if(!aCodec)
- AUD_THROW(AUD_ERROR_FFMPEG, nodecoder_error);
-
- if(avcodec_open2(m_codecCtx, aCodec, NULL) < 0)
- AUD_THROW(AUD_ERROR_FFMPEG, codecopen_error);
-
- // XXX this prints file information to stdout:
- //dump_format(m_formatCtx, 0, NULL, 0);
-
- m_specs.channels = (AUD_Channels) m_codecCtx->channels;
- m_tointerleave = av_sample_fmt_is_planar(m_codecCtx->sample_fmt);
-
- switch(av_get_packed_sample_fmt(m_codecCtx->sample_fmt))
- {
- case AV_SAMPLE_FMT_U8:
- m_convert = AUD_convert_u8_float;
- m_specs.format = AUD_FORMAT_U8;
- break;
- case AV_SAMPLE_FMT_S16:
- m_convert = AUD_convert_s16_float;
- m_specs.format = AUD_FORMAT_S16;
- break;
- case AV_SAMPLE_FMT_S32:
- m_convert = AUD_convert_s32_float;
- m_specs.format = AUD_FORMAT_S32;
- break;
- case AV_SAMPLE_FMT_FLT:
- m_convert = AUD_convert_copy<float>;
- m_specs.format = AUD_FORMAT_FLOAT32;
- break;
- case AV_SAMPLE_FMT_DBL:
- m_convert = AUD_convert_double_float;
- m_specs.format = AUD_FORMAT_FLOAT64;
- break;
- default:
- AUD_THROW(AUD_ERROR_FFMPEG, format_error);
- }
-
- m_specs.rate = (AUD_SampleRate) m_codecCtx->sample_rate;
-}
-
-static const char* fileopen_error = "AUD_FFMPEGReader: File couldn't be "
- "opened.";
-
-AUD_FFMPEGReader::AUD_FFMPEGReader(std::string filename) :
- m_pkgbuf(AVCODEC_MAX_AUDIO_FRAME_SIZE<<1),
- m_formatCtx(NULL),
- m_aviocontext(NULL),
- m_membuf(NULL)
-{
- // open file
- if(avformat_open_input(&m_formatCtx, filename.c_str(), NULL, NULL)!=0)
- AUD_THROW(AUD_ERROR_FILE, fileopen_error);
-
- try
- {
- init();
- }
- catch(AUD_Exception&)
- {
- avformat_close_input(&m_formatCtx);
- throw;
- }
-}
-
-static const char* streamopen_error = "AUD_FFMPEGReader: Stream couldn't be "
- "opened.";
-
-AUD_FFMPEGReader::AUD_FFMPEGReader(boost::shared_ptr<AUD_Buffer> buffer) :
- m_pkgbuf(AVCODEC_MAX_AUDIO_FRAME_SIZE<<1),
- m_membuffer(buffer),
- m_membufferpos(0)
-{
- m_membuf = reinterpret_cast<data_t*>(av_malloc(FF_MIN_BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE));
-
- m_aviocontext = avio_alloc_context(m_membuf, FF_MIN_BUFFER_SIZE, 0, this,
- read_packet, NULL, seek_packet);
-
- if(!m_aviocontext)
- {
- av_free(m_aviocontext);
- AUD_THROW(AUD_ERROR_FILE, fileopen_error);
- }
-
- m_formatCtx = avformat_alloc_context();
- m_formatCtx->pb = m_aviocontext;
- if(avformat_open_input(&m_formatCtx, "", NULL, NULL)!=0)
- {
- av_free(m_aviocontext);
- AUD_THROW(AUD_ERROR_FILE, streamopen_error);
- }
-
- try
- {
- init();
- }
- catch(AUD_Exception&)
- {
- avformat_close_input(&m_formatCtx);
- av_free(m_aviocontext);
- throw;
- }
-}
-
-AUD_FFMPEGReader::~AUD_FFMPEGReader()
-{
- avcodec_close(m_codecCtx);
- avformat_close_input(&m_formatCtx);
-}
-
-int AUD_FFMPEGReader::read_packet(void* opaque, uint8_t* buf, int buf_size)
-{
- AUD_FFMPEGReader* reader = reinterpret_cast<AUD_FFMPEGReader*>(opaque);
-
- int size = AUD_MIN(buf_size, reader->m_membuffer->getSize() - reader->m_membufferpos);
-
- if(size < 0)
- return -1;
-
- memcpy(buf, ((data_t*)reader->m_membuffer->getBuffer()) + reader->m_membufferpos, size);
- reader->m_membufferpos += size;
-
- return size;
-}
-
-int64_t AUD_FFMPEGReader::seek_packet(void* opaque, int64_t offset, int whence)
-{
- AUD_FFMPEGReader* reader = reinterpret_cast<AUD_FFMPEGReader*>(opaque);
-
- switch(whence)
- {
- case SEEK_SET:
- reader->m_membufferpos = 0;
- break;
- case SEEK_END:
- reader->m_membufferpos = reader->m_membuffer->getSize();
- break;
- case AVSEEK_SIZE:
- return reader->m_membuffer->getSize();
- }
-
- return (reader->m_membufferpos += offset);
-}
-
-bool AUD_FFMPEGReader::isSeekable() const
-{
- return true;
-}
-
-void AUD_FFMPEGReader::seek(int position)
-{
- if(position >= 0)
- {
- uint64_t st_time = m_formatCtx->start_time;
- uint64_t seek_pos = ((uint64_t)position) * ((uint64_t)AV_TIME_BASE) / ((uint64_t)m_specs.rate);
-
- if (st_time != AV_NOPTS_VALUE) {
- seek_pos += st_time;
- }
-
- double pts_time_base =
- av_q2d(m_formatCtx->streams[m_stream]->time_base);
- uint64_t pts_st_time =
- ((st_time != AV_NOPTS_VALUE) ? st_time : 0)
- / pts_time_base / (uint64_t) AV_TIME_BASE;
-
- // a value < 0 tells us that seeking failed
- if(av_seek_frame(m_formatCtx, -1, seek_pos,
- AVSEEK_FLAG_BACKWARD | AVSEEK_FLAG_ANY) >= 0)
- {
- avcodec_flush_buffers(m_codecCtx);
- m_position = position;
-
- AVPacket packet;
- bool search = true;
-
- while(search && av_read_frame(m_formatCtx, &packet) >= 0)
- {
- // is it a frame from the audio stream?
- if(packet.stream_index == m_stream)
- {
- // decode the package
- m_pkgbuf_left = decode(packet, m_pkgbuf);
- search = false;
-
- // check position
- if(packet.pts != AV_NOPTS_VALUE)
- {
- // calculate real position, and read to frame!
- m_position = (packet.pts -
- pts_st_time) * pts_time_base * m_specs.rate;
-
- if(m_position < position)
- {
- // read until we're at the right position
- int length = AUD_DEFAULT_BUFFER_SIZE;
- AUD_Buffer buffer(length * AUD_SAMPLE_SIZE(m_specs));
- bool eos;
- for(int len = position - m_position; len > 0; len -= AUD_DEFAULT_BUFFER_SIZE)
- {
- if(len < AUD_DEFAULT_BUFFER_SIZE)
- length = len;
- read(length, eos, buffer.getBuffer());
- }
- }
- }
- }
- av_free_packet(&packet);
- }
- }
- else
- {
- fprintf(stderr, "seeking failed!\n");
- // Seeking failed, do nothing.
- }
- }
-}
-
-int AUD_FFMPEGReader::getLength() const
-{
- // return approximated remaning size
- return (int)((m_formatCtx->duration * m_codecCtx->sample_rate)
- / AV_TIME_BASE)-m_position;
-}
-
-int AUD_FFMPEGReader::getPosition() const
-{
- return m_position;
-}
-
-AUD_Specs AUD_FFMPEGReader::getSpecs() const
-{
- return m_specs.specs;
-}
-
-void AUD_FFMPEGReader::read(int& length, bool& eos, sample_t* buffer)
-{
- // read packages and decode them
- AVPacket packet;
- int data_size = 0;
- int pkgbuf_pos;
- int left = length;
- int sample_size = AUD_DEVICE_SAMPLE_SIZE(m_specs);
-
- sample_t* buf = buffer;
- pkgbuf_pos = m_pkgbuf_left;
- m_pkgbuf_left = 0;
-
- // there may still be data in the buffer from the last call
- if(pkgbuf_pos > 0)
- {
- data_size = AUD_MIN(pkgbuf_pos, left * sample_size);
- m_convert((data_t*) buf, (data_t*) m_pkgbuf.getBuffer(),
- data_size / AUD_FORMAT_SIZE(m_specs.format));
- buf += data_size / AUD_FORMAT_SIZE(m_specs.format);
- left -= data_size/sample_size;
- }
-
- // for each frame read as long as there isn't enough data already
- while((left > 0) && (av_read_frame(m_formatCtx, &packet) >= 0))
- {
- // is it a frame from the audio stream?
- if(packet.stream_index == m_stream)
- {
- // decode the package
- pkgbuf_pos = decode(packet, m_pkgbuf);
-
- // copy to output buffer
- data_size = AUD_MIN(pkgbuf_pos, left * sample_size);
- m_convert((data_t*) buf, (data_t*) m_pkgbuf.getBuffer(),
- data_size / AUD_FORMAT_SIZE(m_specs.format));
- buf += data_size / AUD_FORMAT_SIZE(m_specs.format);
- left -= data_size/sample_size;
- }
- av_free_packet(&packet);
- }
- // read more data than necessary?
- if(pkgbuf_pos > data_size)
- {
- m_pkgbuf_left = pkgbuf_pos-data_size;
- memmove(m_pkgbuf.getBuffer(),
- ((data_t*)m_pkgbuf.getBuffer())+data_size,
- pkgbuf_pos-data_size);
- }
-
- if((eos = (left > 0)))
- length -= left;
-
- m_position += length;
-}
diff --git a/intern/audaspace/ffmpeg/AUD_FFMPEGReader.h b/intern/audaspace/ffmpeg/AUD_FFMPEGReader.h
deleted file mode 100644
index 377086e2625..00000000000
--- a/intern/audaspace/ffmpeg/AUD_FFMPEGReader.h
+++ /dev/null
@@ -1,169 +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/ffmpeg/AUD_FFMPEGReader.h
- * \ingroup audffmpeg
- */
-
-
-#ifndef __AUD_FFMPEGREADER_H__
-#define __AUD_FFMPEGREADER_H__
-
-#include "AUD_ConverterFunctions.h"
-#include "AUD_IReader.h"
-#include "AUD_Buffer.h"
-
-#include <string>
-#include <boost/shared_ptr.hpp>
-
-struct AVCodecContext;
-extern "C" {
-#include <libavformat/avformat.h>
-}
-
-/**
- * This class reads a sound file via ffmpeg.
- * \warning Seeking may not be accurate! Moreover the position is updated after
- * a buffer reading call. So calling getPosition right after seek
- * normally results in a wrong value.
- */
-class AUD_FFMPEGReader : public AUD_IReader
-{
-private:
- /**
- * The current position in samples.
- */
- int m_position;
-
- /**
- * The specification of the audio data.
- */
- AUD_DeviceSpecs m_specs;
-
- /**
- * The buffer for package reading.
- */
- AUD_Buffer m_pkgbuf;
-
- /**
- * The count of samples still available from the last read package.
- */
- int m_pkgbuf_left;
-
- /**
- * The AVFormatContext structure for using ffmpeg.
- */
- AVFormatContext* m_formatCtx;
-
- /**
- * The AVCodecContext structure for using ffmpeg.
- */
- AVCodecContext* m_codecCtx;
-
- /**
- * The AVIOContext to read the data from.
- */
- AVIOContext* m_aviocontext;
-
- /**
- * The stream ID in the file.
- */
- int m_stream;
-
- /**
- * Converter function.
- */
- AUD_convert_f m_convert;
-
- /**
- * The memory file to read from.
- */
- boost::shared_ptr<AUD_Buffer> m_membuffer;
-
- /**
- * The buffer to read with.
- */
- data_t* m_membuf;
-
- /**
- * Reading position of the buffer.
- */
- int64_t m_membufferpos;
-
- /**
- * Whether the audio data has to be interleaved after reading.
- */
- bool m_tointerleave;
-
- /**
- * Decodes a packet into the given buffer.
- * \param packet The AVPacket to decode.
- * \param buffer The target buffer.
- * \return The count of read bytes.
- */
- int decode(AVPacket& packet, AUD_Buffer& buffer);
-
- /**
- * Initializes the object.
- */
- void init();
-
- // hide copy constructor and operator=
- AUD_FFMPEGReader(const AUD_FFMPEGReader&);
- AUD_FFMPEGReader& operator=(const AUD_FFMPEGReader&);
-
-public:
- /**
- * Creates a new reader.
- * \param filename The path to the file to be read.
- * \exception AUD_Exception Thrown if the file specified does not exist or
- * cannot be read with ffmpeg.
- */
- AUD_FFMPEGReader(std::string filename);
-
- /**
- * Creates a new reader.
- * \param buffer The buffer to read from.
- * \exception AUD_Exception Thrown if the buffer specified cannot be read
- * with ffmpeg.
- */
- AUD_FFMPEGReader(boost::shared_ptr<AUD_Buffer> buffer);
-
- /**
- * Destroys the reader and closes the file.
- */
- virtual ~AUD_FFMPEGReader();
-
- static int read_packet(void* opaque, uint8_t* buf, int buf_size);
- static int64_t seek_packet(void* opaque, int64_t offset, int whence);
-
- virtual bool isSeekable() const;
- virtual void seek(int position);
- virtual int getLength() const;
- virtual int getPosition() const;
- virtual AUD_Specs getSpecs() const;
- virtual void read(int& length, bool& eos, sample_t* buffer);
-};
-
-#endif //__AUD_FFMPEGREADER_H__
diff --git a/intern/audaspace/ffmpeg/AUD_FFMPEGWriter.cpp b/intern/audaspace/ffmpeg/AUD_FFMPEGWriter.cpp
deleted file mode 100644
index 3f95ac7a4da..00000000000
--- a/intern/audaspace/ffmpeg/AUD_FFMPEGWriter.cpp
+++ /dev/null
@@ -1,395 +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/ffmpeg/AUD_FFMPEGWriter.cpp
- * \ingroup audffmpeg
- */
-
-
-// needed for INT64_C
-#ifndef __STDC_CONSTANT_MACROS
-#define __STDC_CONSTANT_MACROS
-#endif
-
-#include "AUD_FFMPEGWriter.h"
-
-extern "C" {
-#include <libavcodec/avcodec.h>
-#include <libavformat/avformat.h>
-#include <libavformat/avio.h>
-#include "ffmpeg_compat.h"
-}
-
-static const char* context_error = "AUD_FFMPEGWriter: Couldn't allocate context.";
-static const char* codec_error = "AUD_FFMPEGWriter: Invalid codec or codec not found.";
-static const char* stream_error = "AUD_FFMPEGWriter: Couldn't allocate stream.";
-static const char* format_error = "AUD_FFMPEGWriter: Unsupported sample format.";
-static const char* file_error = "AUD_FFMPEGWriter: File couldn't be written.";
-static const char* write_error = "AUD_FFMPEGWriter: Error writing packet.";
-
-AUD_FFMPEGWriter::AUD_FFMPEGWriter(std::string filename, AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate) :
- m_position(0),
- m_specs(specs),
- m_input_samples(0)
-{
- static const char* formats[] = { NULL, "ac3", "flac", "matroska", "mp2", "mp3", "ogg", "wav" };
-
- m_formatCtx = avformat_alloc_context();
- if (!m_formatCtx) AUD_THROW(AUD_ERROR_FFMPEG, context_error);
-
- strcpy(m_formatCtx->filename, filename.c_str());
- m_outputFmt = m_formatCtx->oformat = av_guess_format(formats[format], filename.c_str(), NULL);
- if (!m_outputFmt) {
- avformat_free_context(m_formatCtx);
- AUD_THROW(AUD_ERROR_FFMPEG, context_error);
- }
-
- switch(codec)
- {
- case AUD_CODEC_AAC:
- m_outputFmt->audio_codec = AV_CODEC_ID_AAC;
- break;
- case AUD_CODEC_AC3:
- m_outputFmt->audio_codec = AV_CODEC_ID_AC3;
- break;
- case AUD_CODEC_FLAC:
- m_outputFmt->audio_codec = AV_CODEC_ID_FLAC;
- break;
- case AUD_CODEC_MP2:
- m_outputFmt->audio_codec = AV_CODEC_ID_MP2;
- break;
- case AUD_CODEC_MP3:
- m_outputFmt->audio_codec = AV_CODEC_ID_MP3;
- break;
- case AUD_CODEC_PCM:
- switch(specs.format)
- {
- case AUD_FORMAT_U8:
- m_outputFmt->audio_codec = AV_CODEC_ID_PCM_U8;
- break;
- case AUD_FORMAT_S16:
- m_outputFmt->audio_codec = AV_CODEC_ID_PCM_S16LE;
- break;
- case AUD_FORMAT_S24:
- m_outputFmt->audio_codec = AV_CODEC_ID_PCM_S24LE;
- break;
- case AUD_FORMAT_S32:
- m_outputFmt->audio_codec = AV_CODEC_ID_PCM_S32LE;
- break;
- case AUD_FORMAT_FLOAT32:
- m_outputFmt->audio_codec = AV_CODEC_ID_PCM_F32LE;
- break;
- case AUD_FORMAT_FLOAT64:
- m_outputFmt->audio_codec = AV_CODEC_ID_PCM_F64LE;
- break;
- default:
- m_outputFmt->audio_codec = AV_CODEC_ID_NONE;
- break;
- }
- break;
- case AUD_CODEC_VORBIS:
- m_outputFmt->audio_codec = AV_CODEC_ID_VORBIS;
- break;
- default:
- m_outputFmt->audio_codec = AV_CODEC_ID_NONE;
- break;
- }
-
- try
- {
- if(m_outputFmt->audio_codec == AV_CODEC_ID_NONE)
- AUD_THROW(AUD_ERROR_SPECS, codec_error);
-
- m_stream = avformat_new_stream(m_formatCtx, NULL);
- if(!m_stream)
- AUD_THROW(AUD_ERROR_FFMPEG, stream_error);
-
- m_codecCtx = m_stream->codec;
- m_codecCtx->codec_id = m_outputFmt->audio_codec;
- m_codecCtx->codec_type = AVMEDIA_TYPE_AUDIO;
- m_codecCtx->bit_rate = bitrate;
- m_codecCtx->sample_rate = int(m_specs.rate);
- m_codecCtx->channels = m_specs.channels;
- m_codecCtx->time_base.num = 1;
- m_codecCtx->time_base.den = m_codecCtx->sample_rate;
-
- switch(m_specs.format)
- {
- case AUD_FORMAT_U8:
- m_convert = AUD_convert_float_u8;
- m_codecCtx->sample_fmt = AV_SAMPLE_FMT_U8;
- break;
- case AUD_FORMAT_S16:
- m_convert = AUD_convert_float_s16;
- m_codecCtx->sample_fmt = AV_SAMPLE_FMT_S16;
- break;
- case AUD_FORMAT_S32:
- m_convert = AUD_convert_float_s32;
- m_codecCtx->sample_fmt = AV_SAMPLE_FMT_S32;
- break;
- case AUD_FORMAT_FLOAT32:
- m_convert = AUD_convert_copy<float>;
- m_codecCtx->sample_fmt = AV_SAMPLE_FMT_FLT;
- break;
- case AUD_FORMAT_FLOAT64:
- m_convert = AUD_convert_float_double;
- m_codecCtx->sample_fmt = AV_SAMPLE_FMT_DBL;
- break;
- default:
- AUD_THROW(AUD_ERROR_FFMPEG, format_error);
- }
-
- try
- {
- if(m_formatCtx->oformat->flags & AVFMT_GLOBALHEADER)
- m_codecCtx->flags |= CODEC_FLAG_GLOBAL_HEADER;
-
- AVCodec* codec = avcodec_find_encoder(m_codecCtx->codec_id);
- if(!codec)
- AUD_THROW(AUD_ERROR_FFMPEG, codec_error);
-
- if(codec->sample_fmts) {
- // Check if the preferred sample format for this codec is supported.
- const enum AVSampleFormat *p = codec->sample_fmts;
- for(; *p != -1; p++) {
- if(*p == m_stream->codec->sample_fmt)
- break;
- }
- if(*p == -1) {
- // Sample format incompatible with codec. Defaulting to a format known to work.
- m_stream->codec->sample_fmt = codec->sample_fmts[0];
- }
- }
-
- if(avcodec_open2(m_codecCtx, codec, NULL))
- AUD_THROW(AUD_ERROR_FFMPEG, codec_error);
-
- m_output_buffer.resize(FF_MIN_BUFFER_SIZE);
- int samplesize = AUD_MAX(AUD_SAMPLE_SIZE(m_specs), AUD_DEVICE_SAMPLE_SIZE(m_specs));
-
- if(m_codecCtx->frame_size <= 1) {
- m_input_size = FF_MIN_BUFFER_SIZE * 8 / m_codecCtx->bits_per_coded_sample / m_codecCtx->channels;
- m_input_buffer.resize(m_input_size * samplesize);
- }
- else
- {
- m_input_buffer.resize(m_codecCtx->frame_size * samplesize);
- m_input_size = m_codecCtx->frame_size;
- }
-
-#ifdef FFMPEG_HAVE_ENCODE_AUDIO2
- m_frame = av_frame_alloc();
- if (!m_frame)
- AUD_THROW(AUD_ERROR_FFMPEG, codec_error);
- av_frame_unref(m_frame);
- m_frame->linesize[0] = m_input_size * samplesize;
- m_frame->format = m_codecCtx->sample_fmt;
- m_frame->nb_samples = m_input_size;
-# ifdef FFMPEG_HAVE_AVFRAME_SAMPLE_RATE
- m_frame->sample_rate = m_codecCtx->sample_rate;
-# endif
-# ifdef FFMPEG_HAVE_FRAME_CHANNEL_LAYOUT
- m_frame->channel_layout = m_codecCtx->channel_layout;
-# endif
- m_sample_size = av_get_bytes_per_sample(m_codecCtx->sample_fmt);
- m_frame_pts = 0;
- m_deinterleave = av_sample_fmt_is_planar(m_codecCtx->sample_fmt);
- if(m_deinterleave)
- m_deinterleave_buffer.resize(m_input_size * m_codecCtx->channels * m_sample_size);
-#endif
-
- try
- {
- if(avio_open(&m_formatCtx->pb, filename.c_str(), AVIO_FLAG_WRITE))
- AUD_THROW(AUD_ERROR_FILE, file_error);
-
- if(avformat_write_header(m_formatCtx, NULL) < 0) {
- throw;
- }
- }
- catch(AUD_Exception&)
- {
- avcodec_close(m_codecCtx);
- av_freep(&m_formatCtx->streams[0]->codec);
- throw;
- }
- }
- catch(AUD_Exception&)
- {
- av_freep(&m_formatCtx->streams[0]);
- throw;
- }
- }
- catch(AUD_Exception&)
- {
- av_free(m_formatCtx);
- throw;
- }
-}
-
-AUD_FFMPEGWriter::~AUD_FFMPEGWriter()
-{
- // writte missing data
- if(m_input_samples)
- {
- sample_t* buf = m_input_buffer.getBuffer();
- memset(buf + m_specs.channels * m_input_samples, 0,
- (m_input_size - m_input_samples) * AUD_DEVICE_SAMPLE_SIZE(m_specs));
-
- encode(buf);
- }
-
- av_write_trailer(m_formatCtx);
-
- avcodec_close(m_codecCtx);
-
- av_freep(&m_formatCtx->streams[0]->codec);
- av_freep(&m_formatCtx->streams[0]);
-
-#ifdef FFMPEG_HAVE_ENCODE_AUDIO2
- av_frame_free(&m_frame);
-#endif
-
- avio_close(m_formatCtx->pb);
- av_free(m_formatCtx);
-}
-
-int AUD_FFMPEGWriter::getPosition() const
-{
- return m_position;
-}
-
-AUD_DeviceSpecs AUD_FFMPEGWriter::getSpecs() const
-{
- return m_specs;
-}
-
-void AUD_FFMPEGWriter::encode(sample_t* data)
-{
- // convert first
- if(m_input_size)
- m_convert(reinterpret_cast<data_t*>(data), reinterpret_cast<data_t*>(data), m_input_size * m_specs.channels);
-
- AVPacket packet = { 0 };
- av_init_packet(&packet);
-
-#ifdef FFMPEG_HAVE_ENCODE_AUDIO2
- int got_output, ret;
- m_frame->pts = m_frame_pts / av_q2d(m_codecCtx->time_base);
- m_frame_pts++;
-#ifdef FFMPEG_HAVE_FRAME_CHANNEL_LAYOUT
- m_frame->channel_layout = m_codecCtx->channel_layout;
-#endif
-
- if(m_deinterleave) {
- for(int channel = 0; channel < m_codecCtx->channels; channel++) {
- for(int i = 0; i < m_frame->nb_samples; i++) {
- memcpy(reinterpret_cast<uint8_t*>(m_deinterleave_buffer.getBuffer()) + (i + channel * m_frame->nb_samples) * m_sample_size,
- reinterpret_cast<uint8_t*>(data) + (m_codecCtx->channels * i + channel) * m_sample_size, m_sample_size);
- }
- }
-
- data = m_deinterleave_buffer.getBuffer();
- }
-
- avcodec_fill_audio_frame(m_frame, m_codecCtx->channels, m_codecCtx->sample_fmt, reinterpret_cast<uint8_t*>(data),
- m_frame->nb_samples * av_get_bytes_per_sample(m_codecCtx->sample_fmt) * m_codecCtx->channels, 1);
-
- ret = avcodec_encode_audio2(m_codecCtx, &packet, m_frame, &got_output);
- if(ret < 0)
- AUD_THROW(AUD_ERROR_FFMPEG, codec_error);
-
- if(!got_output)
- return;
-#else
- sample_t* outbuf = m_output_buffer.getBuffer();
-
- packet.size = avcodec_encode_audio(m_codecCtx, reinterpret_cast<uint8_t*>(outbuf), m_output_buffer.getSize(), reinterpret_cast<short*>(data));
- if(m_codecCtx->coded_frame && m_codecCtx->coded_frame->pts != AV_NOPTS_VALUE)
- packet.pts = av_rescale_q(m_codecCtx->coded_frame->pts, m_codecCtx->time_base, m_stream->time_base);
- packet.flags |= AV_PKT_FLAG_KEY;
- packet.data = reinterpret_cast<uint8_t*>(outbuf);
-#endif
-
- if(packet.pts != AV_NOPTS_VALUE)
- packet.pts = av_rescale_q(packet.pts, m_codecCtx->time_base, m_stream->time_base);
- if(packet.dts != AV_NOPTS_VALUE)
- packet.dts = av_rescale_q(packet.dts, m_codecCtx->time_base, m_stream->time_base);
- if(packet.duration > 0)
- packet.duration = av_rescale_q(packet.duration, m_codecCtx->time_base, m_stream->time_base);
-
- packet.stream_index = m_stream->index;
-
- packet.flags |= AV_PKT_FLAG_KEY;
-
- if(av_interleaved_write_frame(m_formatCtx, &packet)) {
- av_free_packet(&packet);
- AUD_THROW(AUD_ERROR_FFMPEG, write_error);
- }
-
- av_free_packet(&packet);
-}
-
-void AUD_FFMPEGWriter::write(unsigned int length, sample_t* buffer)
-{
- unsigned int samplesize = AUD_SAMPLE_SIZE(m_specs);
-
- if(m_input_size)
- {
- sample_t* inbuf = m_input_buffer.getBuffer();
-
- while(length)
- {
- unsigned int len = AUD_MIN(m_input_size - m_input_samples, length);
-
- memcpy(inbuf + m_input_samples * m_specs.channels, buffer, len * samplesize);
-
- buffer += len * m_specs.channels;
- m_input_samples += len;
- m_position += len;
- length -= len;
-
- if(m_input_samples == m_input_size)
- {
- encode(inbuf);
-
- m_input_samples = 0;
- }
- }
- }
- else // PCM data, can write directly!
- {
- int samplesize = AUD_SAMPLE_SIZE(m_specs);
- if(m_output_buffer.getSize() != length * m_specs.channels * m_codecCtx->bits_per_coded_sample / 8)
- m_output_buffer.resize(length * m_specs.channels * m_codecCtx->bits_per_coded_sample / 8);
- m_input_buffer.assureSize(length * AUD_MAX(AUD_DEVICE_SAMPLE_SIZE(m_specs), samplesize));
-
- sample_t* buf = m_input_buffer.getBuffer();
- m_convert(reinterpret_cast<data_t*>(buf), reinterpret_cast<data_t*>(buffer), length * m_specs.channels);
-
- encode(buf);
-
- m_position += length;
- }
-}
diff --git a/intern/audaspace/ffmpeg/AUD_FFMPEGWriter.h b/intern/audaspace/ffmpeg/AUD_FFMPEGWriter.h
deleted file mode 100644
index 492aa35ff12..00000000000
--- a/intern/audaspace/ffmpeg/AUD_FFMPEGWriter.h
+++ /dev/null
@@ -1,160 +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/ffmpeg/AUD_FFMPEGWriter.h
- * \ingroup audffmpeg
- */
-
-
-#ifndef __AUD_FFMPEGWRITER_H__
-#define __AUD_FFMPEGWRITER_H__
-
-#include "AUD_ConverterFunctions.h"
-#include "AUD_Buffer.h"
-#include "AUD_IWriter.h"
-
-#include <string>
-
-struct AVCodecContext;
-extern "C" {
-#include <libavformat/avformat.h>
-}
-
-/**
- * This class writes a sound file via ffmpeg.
- */
-class AUD_FFMPEGWriter : public AUD_IWriter
-{
-private:
- /**
- * The current position in samples.
- */
- int m_position;
-
- /**
- * The specification of the audio data.
- */
- AUD_DeviceSpecs m_specs;
-
- /**
- * The AVFormatContext structure for using ffmpeg.
- */
- AVFormatContext* m_formatCtx;
-
- /**
- * The AVCodecContext structure for using ffmpeg.
- */
- AVCodecContext* m_codecCtx;
-
- /**
- * The AVOutputFormat structure for using ffmpeg.
- */
- AVOutputFormat* m_outputFmt;
-
- /**
- * The AVStream structure for using ffmpeg.
- */
- AVStream* m_stream;
-
- /**
- * Frame sent to the encoder.
- */
- AVFrame *m_frame;
-
- /**
- * PTS of next frame to write.
- */
- int m_frame_pts;
-
- /**
- * Number of bytes per sample.
- */
- int m_sample_size;
-
- /**
- * Need to de-interleave audio for planar sample formats.
- */
- bool m_deinterleave;
-
- AUD_Buffer m_deinterleave_buffer;
-
- /**
- * The input buffer for the format converted data before encoding.
- */
- AUD_Buffer m_input_buffer;
-
- /**
- * The output buffer for the encoded audio data.
- */
- AUD_Buffer m_output_buffer;
-
- /**
- * The count of input samples we have so far.
- */
- unsigned int m_input_samples;
-
- /**
- * The count of input samples necessary to encode a packet.
- */
- unsigned int m_input_size;
-
- /**
- * Converter function.
- */
- AUD_convert_f m_convert;
-
- // hide copy constructor and operator=
- AUD_FFMPEGWriter(const AUD_FFMPEGWriter&);
- AUD_FFMPEGWriter& operator=(const AUD_FFMPEGWriter&);
-
- /**
- * Encodes to the output buffer.
- * \param data Pointer to the data to encode.
- */
- void encode(sample_t* data);
-
-public:
- /**
- * Creates a new writer.
- * \param filename The path to the file to be read.
- * \param specs The file's audio specification.
- * \param format The file's container format.
- * \param codec The codec used for encoding the audio data.
- * \param bitrate The bitrate for encoding.
- * \exception AUD_Exception Thrown if the file specified does not exist or
- * cannot be read with ffmpeg.
- */
- AUD_FFMPEGWriter(std::string filename, AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate);
-
- /**
- * Destroys the writer and closes the file.
- */
- virtual ~AUD_FFMPEGWriter();
-
- virtual int getPosition() const;
- virtual AUD_DeviceSpecs getSpecs() const;
- virtual void write(unsigned int length, sample_t* buffer);
-};
-
-#endif //__AUD_FFMPEGWRITER_H__
diff --git a/intern/audaspace/fftw/AUD_BandPassFactory.cpp b/intern/audaspace/fftw/AUD_BandPassFactory.cpp
deleted file mode 100644
index 1e6538d80de..00000000000
--- a/intern/audaspace/fftw/AUD_BandPassFactory.cpp
+++ /dev/null
@@ -1,75 +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/fftw/AUD_BandPassFactory.cpp
- * \ingroup audfftw
- */
-
-
-#include "AUD_BandPassFactory.h"
-#include "AUD_BandPassReader.h"
-
-AUD_BandPassFactory::AUD_BandPassFactory(AUD_IFactory* factory, float low,
- float high) :
- AUD_EffectFactory(factory),
- m_low(low),
- m_high(high) {}
-
-AUD_BandPassFactory::AUD_BandPassFactory(float low, float high) :
- AUD_EffectFactory(0),
- m_low(low),
- m_high(high) {}
-
-float AUD_BandPassFactory::getLow()
-{
- return m_low;
-}
-
-float AUD_BandPassFactory::getHigh()
-{
- return m_high;
-}
-
-void AUD_BandPassFactory::setLow(float low)
-{
- m_low = low;
-}
-
-void AUD_BandPassFactory::setHigh(float high)
-{
- m_high = high;
-}
-
-AUD_IReader* AUD_BandPassFactory::createReader()
-{
- AUD_IReader* reader = getReader();
-
- if(reader != 0)
- {
- reader = new AUD_BandPassReader(reader, m_low, m_high);
- AUD_NEW("reader")
- }
-
- return reader;
-}
diff --git a/intern/audaspace/fftw/AUD_BandPassFactory.h b/intern/audaspace/fftw/AUD_BandPassFactory.h
deleted file mode 100644
index 90b090dce16..00000000000
--- a/intern/audaspace/fftw/AUD_BandPassFactory.h
+++ /dev/null
@@ -1,92 +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/fftw/AUD_BandPassFactory.h
- * \ingroup audfftw
- */
-
-
-#ifndef __AUD_BANDPASSFACTORY_H__
-#define __AUD_BANDPASSFACTORY_H__
-
-#include "AUD_EffectFactory.h"
-
-/**
- * This factory creates a band pass filter for a sound wave.
- */
-class AUD_BandPassFactory : public AUD_EffectFactory
-{
-private:
- /**
- * The lowest frequency to be passed.
- */
- float m_low;
-
- /**
- * The highest frequency to be passed.
- */
- float m_high;
-
-public:
- /**
- * Creates a new band pass factory.
- * \param factory The input factory.
- * \param low The lowest passed frequency.
- * \param high The highest passed frequency.
- */
- AUD_BandPassFactory(AUD_IFactory* factory, float low, float high);
-
- /**
- * Creates a new band pass factory.
- * \param low The lowest passed frequency.
- * \param high The highest passed frequency.
- */
- AUD_BandPassFactory(float low, float high);
-
- /**
- * Returns the lowest passed frequency.
- */
- float getLow();
-
- /**
- * Returns the highest passed frequency.
- */
- float getHigh();
-
- /**
- * Sets the lowest passed frequency.
- * \param low The lowest passed frequency.
- */
- void setLow(float low);
-
- /**
- * Sets the highest passed frequency.
- * \param high The highest passed frequency.
- */
- void setHigh(float high);
-
- virtual AUD_IReader* createReader();
-};
-
-#endif //__AUD_BANDPASSFACTORY_H__
diff --git a/intern/audaspace/fftw/AUD_BandPassReader.cpp b/intern/audaspace/fftw/AUD_BandPassReader.cpp
deleted file mode 100644
index 7e181fb499d..00000000000
--- a/intern/audaspace/fftw/AUD_BandPassReader.cpp
+++ /dev/null
@@ -1,127 +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/fftw/AUD_BandPassReader.cpp
- * \ingroup audfftw
- */
-
-
-#include "AUD_BandPassReader.h"
-#include "AUD_Buffer.h"
-
-#include <cstring>
-#include <stdio.h>
-
-AUD_BandPassReader::AUD_BandPassReader(AUD_IReader* reader, float low,
- float high) :
- AUD_EffectReader(reader), m_low(low), m_high(high)
-{
- m_buffer = new AUD_Buffer(); AUD_NEW("buffer")
- m_in = new AUD_Buffer(); AUD_NEW("buffer")
- m_out = new AUD_Buffer(); AUD_NEW("buffer")
- m_length = 0;
-}
-
-AUD_BandPassReader::~AUD_BandPassReader()
-{
- if(m_length != 0)
- {
- fftw_destroy_plan(m_forward);
- fftw_destroy_plan(m_backward);
- }
-
- delete m_buffer; AUD_DELETE("buffer")
- delete m_in; AUD_DELETE("buffer")
- delete m_out; AUD_DELETE("buffer")
-}
-
-AUD_ReaderType AUD_BandPassReader::getType()
-{
- return m_reader->getType();
-}
-
-void AUD_BandPassReader::read(int & length, sample_t* & buffer)
-{
- AUD_Specs specs = m_reader->getSpecs();
-
- m_reader->read(length, buffer);
-
- if(length > 0)
- {
- m_buffer->assureSize(length * AUD_SAMPLE_SIZE(specs));
-
- if(length != m_length)
- {
- if(m_length != 0)
- {
- fftw_destroy_plan(m_forward);
- fftw_destroy_plan(m_backward);
- }
-
- m_length = length;
-
- if(m_length * sizeof(double) > m_in->getSize())
- {
- m_in->resize(m_length * sizeof(double));
- m_out->resize((m_length / 2 + 1) * sizeof(fftw_complex));
- }
-
- m_forward = fftw_plan_dft_r2c_1d(m_length,
- (double*)m_in->getBuffer(),
- (fftw_complex*)m_out->getBuffer(),
- FFTW_ESTIMATE);
- m_backward = fftw_plan_dft_c2r_1d(m_length,
- (fftw_complex*)m_out->getBuffer(),
- (double*)m_in->getBuffer(),
- FFTW_ESTIMATE);
- }
-
- double* target = (double*) m_in->getBuffer();
- sample_t* target2 = m_buffer->getBuffer();
- fftw_complex* complex = (fftw_complex*) m_out->getBuffer();
- float frequency;
-
- for(int channel = 0; channel < specs.channels; channel++)
- {
- for(int i = 0; i < m_length; i++)
- target[i] = buffer[i * specs.channels + channel];
-
- fftw_execute(m_forward);
-
- for(int i = 0; i < m_length / 2 + 1; i++)
- {
- frequency = i * specs.rate / (m_length / 2.0f + 1.0f);
- if((frequency < m_low) || (frequency > m_high))
- complex[i][0] = complex[i][1] = 0.0;
- }
-
- fftw_execute(m_backward);
-
- for(int i = 0; i < m_length; i++)
- target2[i * specs.channels + channel] = target[i] / m_length;
- }
- }
-
- buffer = m_buffer->getBuffer();
-}
diff --git a/intern/audaspace/fftw/AUD_BandPassReader.h b/intern/audaspace/fftw/AUD_BandPassReader.h
deleted file mode 100644
index 55a950818e0..00000000000
--- a/intern/audaspace/fftw/AUD_BandPassReader.h
+++ /dev/null
@@ -1,102 +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/fftw/AUD_BandPassReader.h
- * \ingroup audfftw
- */
-
-
-#ifndef __AUD_BANDPASSREADER_H__
-#define __AUD_BANDPASSREADER_H__
-
-#include <fftw3.h>
-
-#include "AUD_EffectReader.h"
-class AUD_Buffer;
-
-/**
- * This class only passes a specific frequency band of another reader.
- */
-class AUD_BandPassReader : public AUD_EffectReader
-{
-private:
- /**
- * The playback buffer.
- */
- AUD_Buffer *m_buffer;
-
- /**
- * The input buffer for fourier transformations.
- */
- AUD_Buffer *m_in;
-
- /**
- * The output buffer for fourier transformations.
- */
- AUD_Buffer *m_out;
-
- /**
- * The lowest passed frequency.
- */
- float m_low;
-
- /**
- * The highest passed frequency.
- */
- float m_high;
-
- /**
- * The fftw plan for forward transformation.
- */
- fftw_plan m_forward;
-
- /**
- * The fftw plan for backward transformation.
- */
- fftw_plan m_backward;
-
- /**
- * The length of the plans.
- */
- int m_length;
-
-public:
- /**
- * Creates a new band pass reader.
- * \param reader The reader to read from.
- * \param low The lowest passed frequency.
- * \param high The highest passed frequency.
- */
- AUD_BandPassReader(AUD_IReader* reader, float low, float high);
-
- /**
- * Destroys the reader.
- */
- virtual ~AUD_BandPassReader();
-
- virtual AUD_ReaderType getType();
- virtual void read(int & length, sample_t* & buffer);
-};
-
-#endif //__AUD_BANDPASSREADER_H__
diff --git a/intern/audaspace/intern/AUD_AnimateableProperty.cpp b/intern/audaspace/intern/AUD_AnimateableProperty.cpp
deleted file mode 100644
index e0bc18ea520..00000000000
--- a/intern/audaspace/intern/AUD_AnimateableProperty.cpp
+++ /dev/null
@@ -1,247 +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_AnimateableProperty.cpp
- * \ingroup audaspaceintern
- */
-
-
-#include "AUD_AnimateableProperty.h"
-#include "AUD_MutexLock.h"
-
-#include <cstring>
-#include <cmath>
-
-AUD_AnimateableProperty::AUD_AnimateableProperty(int count) :
- AUD_Buffer(count * sizeof(float)), m_count(count), m_isAnimated(false)
-{
- memset(getBuffer(), 0, count * sizeof(float));
-
- 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_AnimateableProperty::AUD_AnimateableProperty(int count, float value) :
- AUD_Buffer(count * sizeof(float)), m_count(count), m_isAnimated(false)
-{
- sample_t* buf = getBuffer();
-
- for(int i = 0; i < count; i++)
- buf[i] = value;
-
- 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);
-}
-
-void AUD_AnimateableProperty::updateUnknownCache(int start, int end)
-{
- float* buf = getBuffer();
-
- for(int i = start; i <= end; i++)
- // TODO: maybe first instead of zero order interpolation?
- memcpy(buf + i * m_count, buf + (start - 1) * m_count, m_count * sizeof(float));
-}
-
-AUD_AnimateableProperty::~AUD_AnimateableProperty()
-{
- pthread_mutex_destroy(&m_mutex);
-}
-
-void AUD_AnimateableProperty::lock()
-{
- pthread_mutex_lock(&m_mutex);
-}
-
-void AUD_AnimateableProperty::unlock()
-{
- pthread_mutex_unlock(&m_mutex);
-}
-
-void AUD_AnimateableProperty::write(const float* data)
-{
- AUD_MutexLock lock(*this);
-
- m_isAnimated = false;
- m_unknown.clear();
- memcpy(getBuffer(), data, m_count * sizeof(float));
-}
-
-void AUD_AnimateableProperty::write(const float* data, int position, int count)
-{
- AUD_MutexLock lock(*this);
-
- int pos = getSize() / (sizeof(float) * m_count);
-
- if(!m_isAnimated)
- pos = 0;
-
- m_isAnimated = true;
-
- assureSize((count + position) * m_count * sizeof(float), true);
-
- float* buf = getBuffer();
-
- memcpy(buf + position * m_count, data, count * m_count * sizeof(float));
-
- // have to fill up space between?
- if(pos < position)
- {
- m_unknown.push_back(Unknown(pos, position - 1));
-
- // if the buffer was not animated before, we copy the previous static value
- if(pos == 0)
- pos = 1;
-
- updateUnknownCache(pos, position - 1);
- }
- // otherwise it's not at the end, let's check if some unknown part got filled
- else
- {
- bool erased = false;
-
- for(std::list<Unknown>::iterator it = m_unknown.begin(); it != m_unknown.end(); erased ? it : it++)
- {
- erased = false;
-
- // unknown area before position
- if(it->end < position)
- continue;
-
- // we're after the new area, let's stop
- if(it->start >= position + count)
- break;
-
- // we have an intersection, now 4 cases:
- // the start is included
- if(position <= it->start)
- {
- // the end is included
- if(position + count > it->end)
- {
- // simply delete
- it = m_unknown.erase(it);
- erased = true;
- }
- // the end is excluded, a second part remains
- else
- {
- // update second part
- it->start = position + count;
- updateUnknownCache(it->start, it->end);
- break;
- }
- }
- // start is excluded, a first part remains
- else
- {
- // the end is included
- if(position + count > it->end)
- {
- // update first part
- it->end = position - 1;
- }
- // the end is excluded, a second part remains
- else
- {
- // add another item and update both parts
- m_unknown.insert(it, Unknown(it->start, position - 1));
- it->start = position + count;
- updateUnknownCache(it->start, it->end);
- }
- }
- }
- }
-}
-
-void AUD_AnimateableProperty::read(float position, float* out)
-{
- AUD_MutexLock lock(*this);
-
- if(!m_isAnimated)
- {
- memcpy(out, getBuffer(), m_count * sizeof(float));
- return;
- }
-
- int last = getSize() / (sizeof(float) * m_count) - 1;
- float t = position - floor(position);
-
- if(position >= last)
- {
- position = last;
- t = 0;
- }
-
- if(t == 0)
- {
- memcpy(out, getBuffer() + int(floor(position)) * m_count, m_count * sizeof(float));
- }
- else
- {
- int pos = int(floor(position)) * m_count;
- float t2 = t * t;
- float t3 = t2 * t;
- float m0, m1;
- float* p0;
- float* p1 = getBuffer() + pos;
- float* p2;
- float* p3;
- last *= m_count;
-
- if(pos == 0)
- p0 = p1;
- else
- p0 = p1 - m_count;
-
- p2 = p1 + m_count;
- if(pos + m_count == last)
- p3 = p2;
- else
- p3 = p2 + m_count;
-
- for(int i = 0; i < m_count; i++)
- {
- m0 = (p2[i] - p0[i]) / 2.0f;
- m1 = (p3[i] - p1[i]) / 2.0f;
-
- out[i] = (2 * t3 - 3 * t2 + 1) * p0[i] + (-2 * t3 + 3 * t2) * p1[i] +
- (t3 - 2 * t2 + t) * m0 + (t3 - t2) * m1;
- }
- }
-}
-
-bool AUD_AnimateableProperty::isAnimated() const
-{
- return m_isAnimated;
-}
diff --git a/intern/audaspace/intern/AUD_AnimateableProperty.h b/intern/audaspace/intern/AUD_AnimateableProperty.h
deleted file mode 100644
index f07e5916b25..00000000000
--- a/intern/audaspace/intern/AUD_AnimateableProperty.h
+++ /dev/null
@@ -1,128 +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_AnimateableProperty.h
- * \ingroup audaspaceintern
- */
-
-
-#ifndef __AUD_ANIMATEABLEPROPERTY_H__
-#define __AUD_ANIMATEABLEPROPERTY_H__
-
-#include "AUD_Buffer.h"
-#include "AUD_ILockable.h"
-
-#include <pthread.h>
-#include <list>
-
-/**
- * This class saves animation data for float properties.
- */
-class AUD_AnimateableProperty : private AUD_Buffer, public AUD_ILockable
-{
-private:
- struct Unknown {
- int start;
- int end;
-
- Unknown(int start, int end) :
- start(start), end(end) {}
- };
-
- /// The count of floats for a single property.
- const int m_count;
-
- /// Whether the property is animated or not.
- bool m_isAnimated;
-
- /// The mutex for locking.
- pthread_mutex_t m_mutex;
-
- /// The list of unknown buffer areas.
- std::list<Unknown> m_unknown;
-
- // hide copy constructor and operator=
- AUD_AnimateableProperty(const AUD_AnimateableProperty&);
- AUD_AnimateableProperty& operator=(const AUD_AnimateableProperty&);
-
- void updateUnknownCache(int start, int end);
-
-public:
- /**
- * Creates a new animateable property.
- * \param count The count of floats for a single property.
- */
- AUD_AnimateableProperty(int count = 1);
-
- /**
- * Creates a new animateable property.
- * \param count The count of floats for a single property.
- * \param count The value that the property should get initialized with. All count floats will be initialized to the same value.
- */
- AUD_AnimateableProperty(int count, float value);
-
- /**
- * Destroys the animateable property.
- */
- ~AUD_AnimateableProperty();
-
- /**
- * Locks the property.
- */
- virtual void lock();
-
- /**
- * Unlocks the previously locked property.
- */
- virtual void unlock();
-
- /**
- * Writes the properties value and marks it non-animated.
- * \param data The new value.
- */
- void write(const float* data);
-
- /**
- * Writes the properties value and marks it animated.
- * \param data The new value.
- * \param position The position in the animation in frames.
- * \param count The count of frames to write.
- */
- void write(const float* data, int position, int count);
-
- /**
- * Reads the properties value.
- * \param position The position in the animation in frames.
- * \param[out] out Where to write the value to.
- */
- void read(float position, float* out);
-
- /**
- * Returns whether the property is animated.
- * \return Whether the property is animated.
- */
- bool isAnimated() const;
-};
-
-#endif //__AUD_ANIMATEABLEPROPERTY_H__
diff --git a/intern/audaspace/intern/AUD_Buffer.cpp b/intern/audaspace/intern/AUD_Buffer.cpp
deleted file mode 100644
index b7157f672b4..00000000000
--- a/intern/audaspace/intern/AUD_Buffer.cpp
+++ /dev/null
@@ -1,80 +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_Buffer.cpp
- * \ingroup audaspaceintern
- */
-
-
-#include "AUD_Buffer.h"
-#include "AUD_Space.h"
-
-#include <cstring>
-#include <cstdlib>
-
-#define AUD_ALIGN(a) (a + 16 - ((long)a & 15))
-
-AUD_Buffer::AUD_Buffer(int size)
-{
- m_size = size;
- m_buffer = (data_t*) malloc(size+16);
-}
-
-AUD_Buffer::~AUD_Buffer()
-{
- free(m_buffer);
-}
-
-sample_t* AUD_Buffer::getBuffer() const
-{
- return (sample_t*) AUD_ALIGN(m_buffer);
-}
-
-int AUD_Buffer::getSize() const
-{
- return m_size;
-}
-
-void AUD_Buffer::resize(int size, bool keep)
-{
- if(keep)
- {
- data_t* buffer = (data_t*) malloc(size + 16);
-
- memcpy(AUD_ALIGN(buffer), AUD_ALIGN(m_buffer), AUD_MIN(size, m_size));
-
- free(m_buffer);
- m_buffer = buffer;
- }
- else
- m_buffer = (data_t*) realloc(m_buffer, size + 16);
-
- m_size = size;
-}
-
-void AUD_Buffer::assureSize(int size, bool keep)
-{
- if(m_size < size)
- resize(size, keep);
-}
diff --git a/intern/audaspace/intern/AUD_Buffer.h b/intern/audaspace/intern/AUD_Buffer.h
deleted file mode 100644
index d3207f04f83..00000000000
--- a/intern/audaspace/intern/AUD_Buffer.h
+++ /dev/null
@@ -1,93 +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_Buffer.h
- * \ingroup audaspaceintern
- */
-
-
-#ifndef __AUD_BUFFER_H__
-#define __AUD_BUFFER_H__
-
-#include "AUD_Space.h"
-
-/**
- * This class is a simple buffer in RAM which is 16 Byte aligned and provides
- * resize functionality.
- */
-class AUD_Buffer
-{
-private:
- /// The size of the buffer in bytes.
- int m_size;
-
- /// The pointer to the buffer memory.
- data_t* m_buffer;
-
- // hide copy constructor and operator=
- AUD_Buffer(const AUD_Buffer&);
- AUD_Buffer& operator=(const AUD_Buffer&);
-
-public:
- /**
- * Creates a new buffer.
- * \param size The size of the buffer in bytes.
- */
- AUD_Buffer(int size = 0);
-
- /**
- * Destroys the buffer.
- */
- ~AUD_Buffer();
-
- /**
- * Returns the pointer to the buffer in memory.
- */
- sample_t* getBuffer() const;
-
- /**
- * Returns the size of the buffer in bytes.
- */
- int getSize() const;
-
- /**
- * Resizes the buffer.
- * \param size The new size of the buffer, measured in bytes.
- * \param keep Whether to keep the old data. If the new buffer is smaller,
- * the data at the end will be lost.
- */
- void resize(int size, bool keep = false);
-
- /**
- * Makes sure the buffer has a minimum size.
- * If size is >= current size, nothing will happen.
- * Otherwise the buffer is resized with keep as parameter.
- * \param size The new minimum size of the buffer, measured in bytes.
- * \param keep Whether to keep the old data. If the new buffer is smaller,
- * the data at the end will be lost.
- */
- void assureSize(int size, bool keep = false);
-};
-
-#endif //__AUD_BUFFER_H__
diff --git a/intern/audaspace/intern/AUD_BufferReader.cpp b/intern/audaspace/intern/AUD_BufferReader.cpp
deleted file mode 100644
index b9d819ff774..00000000000
--- a/intern/audaspace/intern/AUD_BufferReader.cpp
+++ /dev/null
@@ -1,90 +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_BufferReader.cpp
- * \ingroup audaspaceintern
- */
-
-
-#include "AUD_BufferReader.h"
-#include "AUD_Buffer.h"
-#include "AUD_Space.h"
-
-#include <cstring>
-
-AUD_BufferReader::AUD_BufferReader(boost::shared_ptr<AUD_Buffer> buffer,
- AUD_Specs specs) :
- m_position(0), m_buffer(buffer), m_specs(specs)
-{
-}
-
-bool AUD_BufferReader::isSeekable() const
-{
- return true;
-}
-
-void AUD_BufferReader::seek(int position)
-{
- m_position = position;
-}
-
-int AUD_BufferReader::getLength() const
-{
- return m_buffer->getSize() / AUD_SAMPLE_SIZE(m_specs);
-}
-
-int AUD_BufferReader::getPosition() const
-{
- return m_position;
-}
-
-AUD_Specs AUD_BufferReader::getSpecs() const
-{
- return m_specs;
-}
-
-void AUD_BufferReader::read(int& length, bool& eos, sample_t* buffer)
-{
- eos = false;
-
- int sample_size = AUD_SAMPLE_SIZE(m_specs);
-
- sample_t* buf = m_buffer->getBuffer() + m_position * m_specs.channels;
-
- // in case the end of the buffer is reached
- if(m_buffer->getSize() < (m_position + length) * sample_size)
- {
- length = m_buffer->getSize() / sample_size - m_position;
- eos = true;
- }
-
- if(length < 0)
- {
- length = 0;
- return;
- }
-
- m_position += length;
- memcpy(buffer, buf, length * sample_size);
-}
diff --git a/intern/audaspace/intern/AUD_BufferReader.h b/intern/audaspace/intern/AUD_BufferReader.h
deleted file mode 100644
index d0c90ce7e61..00000000000
--- a/intern/audaspace/intern/AUD_BufferReader.h
+++ /dev/null
@@ -1,81 +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_BufferReader.h
- * \ingroup audaspaceintern
- */
-
-
-#ifndef __AUD_BUFFERREADER_H__
-#define __AUD_BUFFERREADER_H__
-
-#include "AUD_IReader.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
- * long as the reader exists.
- */
-class AUD_BufferReader : public AUD_IReader
-{
-private:
- /**
- * The current position in the buffer.
- */
- int m_position;
-
- /**
- * The buffer that is read.
- */
- boost::shared_ptr<AUD_Buffer> m_buffer;
-
- /**
- * The specification of the sample data in the buffer.
- */
- AUD_Specs m_specs;
-
- // hide copy constructor and operator=
- AUD_BufferReader(const AUD_BufferReader&);
- AUD_BufferReader& operator=(const AUD_BufferReader&);
-
-public:
- /**
- * Creates a new buffer reader.
- * \param buffer The buffer to read from.
- * \param specs The specification of the sample data in the buffer.
- */
- AUD_BufferReader(boost::shared_ptr<AUD_Buffer> buffer, AUD_Specs specs);
-
- virtual bool isSeekable() const;
- virtual void seek(int position);
- virtual int getLength() const;
- virtual int getPosition() const;
- virtual AUD_Specs getSpecs() const;
- virtual void read(int& length, bool& eos, sample_t* buffer);
-};
-
-#endif //__AUD_BUFFERREADER_H__
diff --git a/intern/audaspace/intern/AUD_C-API.cpp b/intern/audaspace/intern/AUD_C-API.cpp
deleted file mode 100644
index 52cf256147f..00000000000
--- a/intern/audaspace/intern/AUD_C-API.cpp
+++ /dev/null
@@ -1,1323 +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_C-API.cpp
- * \ingroup audaspaceintern
- */
-
-// needed for INT64_C
-#ifndef __STDC_CONSTANT_MACROS
-#define __STDC_CONSTANT_MACROS
-#endif
-
-// quiet unudef define warning
-#ifdef __STDC_CONSTANT_MACROS
-// pass
-#endif
-
-#ifdef WITH_PYTHON
-# include "AUD_PyInit.h"
-# include "AUD_PyAPI.h"
-#endif
-
-#include <cstdlib>
-#include <cstring>
-#include <cmath>
-#include <sstream>
-#include <iostream>
-
-#include "AUD_NULLDevice.h"
-#include "AUD_I3DDevice.h"
-#include "AUD_I3DHandle.h"
-#include "AUD_FileFactory.h"
-#include "AUD_FileWriter.h"
-#include "AUD_StreamBufferFactory.h"
-#include "AUD_DelayFactory.h"
-#include "AUD_LimiterFactory.h"
-#include "AUD_PingPongFactory.h"
-#include "AUD_LoopFactory.h"
-#include "AUD_RectifyFactory.h"
-#include "AUD_EnvelopeFactory.h"
-#include "AUD_LinearResampleFactory.h"
-#include "AUD_LowpassFactory.h"
-#include "AUD_HighpassFactory.h"
-#include "AUD_AccumulatorFactory.h"
-#include "AUD_SumFactory.h"
-#include "AUD_SquareFactory.h"
-#include "AUD_ChannelMapperFactory.h"
-#include "AUD_Buffer.h"
-#include "AUD_ReadDevice.h"
-#include "AUD_IReader.h"
-#include "AUD_SequencerFactory.h"
-#include "AUD_SequencerEntry.h"
-#include "AUD_SilenceFactory.h"
-#include "AUD_MutexLock.h"
-
-#ifdef WITH_SDL
-#include "AUD_SDLDevice.h"
-#endif
-
-#ifdef WITH_OPENAL
-#include "AUD_OpenALDevice.h"
-#endif
-
-#ifdef WITH_JACK
-#include "AUD_JackDevice.h"
-#include "AUD_JackLibrary.h"
-#endif
-
-
-#ifdef WITH_FFMPEG
-extern "C" {
-#include <libavformat/avformat.h>
-}
-#endif
-
-#include <cassert>
-
-typedef boost::shared_ptr<AUD_IFactory> AUD_Sound;
-typedef boost::shared_ptr<AUD_IDevice> 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"
-
-#ifndef NULL
-# define NULL (void *)0
-#endif
-
-static boost::shared_ptr<AUD_IDevice> AUD_device;
-static AUD_I3DDevice *AUD_3ddevice;
-
-void AUD_initOnce()
-{
-#ifdef WITH_FFMPEG
- av_register_all();
-#endif
-#ifdef WITH_JACK
- AUD_jack_init();
-#endif
-}
-
-void AUD_exitOnce()
-{
-#ifdef WITH_JACK
- AUD_jack_exit();
-#endif
-}
-
-AUD_Device* AUD_init(const char* device, AUD_DeviceSpecs specs, int buffersize, const char* name)
-{
- boost::shared_ptr<AUD_IDevice> dev;
-
- if (AUD_device.get()) {
- AUD_exit(NULL);
- }
-
- std::string dname = device;
-
- try {
- if(dname == "Null") {
- dev = boost::shared_ptr<AUD_IDevice>(new AUD_NULLDevice());
- }
-#ifdef WITH_SDL
- else if(dname == "SDL")
- {
- dev = boost::shared_ptr<AUD_IDevice>(new AUD_SDLDevice(specs, buffersize));
- }
-#endif
-#ifdef WITH_OPENAL
- else if(dname == "OpenAL")
- {
- dev = boost::shared_ptr<AUD_IDevice>(new AUD_OpenALDevice(specs, buffersize));
- }
-#endif
-#ifdef WITH_JACK
- else if(dname == "JACK")
- {
-#ifdef __APPLE__
- struct stat st;
- if (stat("/Library/Frameworks/Jackmp.framework", &st) != 0) {
- printf("Warning: JACK Framework not installed\n");
- return NULL;
- }
- else
-#endif
- if (!AUD_jack_supported()) {
- printf("Warning: JACK cllient not installed\n");
- return NULL;
- }
- else {
- dev = boost::shared_ptr<AUD_IDevice>(new AUD_JackDevice(name, specs, buffersize));
- }
- }
-#endif
- else
- {
- return NULL;
- }
-
- AUD_device = dev;
- AUD_3ddevice = dynamic_cast<AUD_I3DDevice *>(AUD_device.get());
-
- return (AUD_Device*)1;
- }
- catch(AUD_Exception&)
- {
- return NULL;
- }
-}
-
-void AUD_exit(AUD_Device* device)
-{
- AUD_device = boost::shared_ptr<AUD_IDevice>();
- AUD_3ddevice = NULL;
-}
-
-#ifdef WITH_PYTHON
-static PyObject *AUD_getCDevice(PyObject *self)
-{
- if (AUD_device.get()) {
- Device *device = (Device *)Device_empty();
- if (device != NULL) {
- device->device = new boost::shared_ptr<AUD_IDevice>(AUD_device);
- return (PyObject *)device;
- }
- }
-
- Py_RETURN_NONE;
-}
-
-static PyMethodDef meth_getcdevice[] = {
- {"device", (PyCFunction)AUD_getCDevice, METH_NOARGS,
- "device()\n\n"
- "Returns the application's :class:`Device`.\n\n"
- ":return: The application's :class:`Device`.\n"
- ":rtype: :class:`Device`"}
-};
-
-extern "C" {
-extern void *BKE_sound_get_factory(void *sound);
-}
-
-static PyObject *AUD_getSoundFromPointer(PyObject *self, PyObject *args)
-{
- long int lptr;
-
- if (PyArg_Parse(args, "l:_sound_from_pointer", &lptr)) {
- if (lptr) {
- boost::shared_ptr<AUD_IFactory>* factory = (boost::shared_ptr<AUD_IFactory>*) BKE_sound_get_factory((void *) lptr);
-
- if (factory) {
- Factory *obj = (Factory *)Factory_empty();
- if (obj) {
- obj->factory = new boost::shared_ptr<AUD_IFactory>(*factory);
- return (PyObject *) obj;
- }
- }
- }
- }
-
- Py_RETURN_NONE;
-}
-
-static PyMethodDef meth_sound_from_pointer[] = {
- {"_sound_from_pointer", (PyCFunction)AUD_getSoundFromPointer, METH_O,
- "_sound_from_pointer(pointer)\n\n"
- "Returns the corresponding :class:`Factory` object.\n\n"
- ":arg pointer: The pointer to the bSound object as long.\n"
- ":type pointer: long\n"
- ":return: The corresponding :class:`Factory` object.\n"
- ":rtype: :class:`Factory`"}
-};
-
-PyObject *AUD_initPython()
-{
- PyObject *module = PyInit_aud();
- PyModule_AddObject(module, "device", (PyObject *)PyCFunction_New(meth_getcdevice, NULL));
- PyModule_AddObject(module, "_sound_from_pointer", (PyObject *)PyCFunction_New(meth_sound_from_pointer, NULL));
- PyDict_SetItemString(PyImport_GetModuleDict(), "aud", module);
-
- return module;
-}
-
-void *AUD_getPythonSound(AUD_Sound *sound)
-{
- if (sound) {
- Factory *obj = (Factory *) Factory_empty();
- if (obj) {
- obj->factory = new boost::shared_ptr<AUD_IFactory>(*sound);
- return (PyObject *) obj;
- }
- }
-
- return NULL;
-}
-
-AUD_Sound *AUD_getSoundFromPython(void *sound)
-{
- Factory *factory = checkFactory((PyObject *)sound);
-
- if (!factory)
- return NULL;
-
- return new boost::shared_ptr<AUD_IFactory>(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(factory->factory));
-}
-
-#endif
-
-void AUD_Device_lock(AUD_Device* device)
-{
- AUD_device->lock();
-}
-
-void AUD_Device_unlock(AUD_Device* device)
-{
- AUD_device->unlock();
-}
-
-AUD_Channels AUD_Device_getChannels(AUD_Device* device)
-{
- return AUD_device->getSpecs().channels;
-}
-
-AUD_SampleRate AUD_Device_getRate(AUD_Device* device)
-{
- return AUD_device->getSpecs().rate;
-}
-
-AUD_SoundInfo AUD_getInfo(AUD_Sound *sound)
-{
- assert(sound);
-
- AUD_SoundInfo info;
- info.specs.channels = AUD_CHANNELS_INVALID;
- info.specs.rate = AUD_RATE_INVALID;
- info.length = 0.0f;
-
- try {
- boost::shared_ptr<AUD_IReader> reader = (*sound)->createReader();
-
- if (reader.get()) {
- info.specs = reader->getSpecs();
- info.length = reader->getLength() / (float) info.specs.rate;
- }
- }
- catch(AUD_Exception &ae)
- {
- std::cout << ae.str << std::endl;
- }
-
- return info;
-}
-
-AUD_Sound *AUD_Sound_file(const char *filename)
-{
- assert(filename);
- return new AUD_Sound(new AUD_FileFactory(filename));
-}
-
-AUD_Sound *AUD_Sound_bufferFile(unsigned char *buffer, int size)
-{
- assert(buffer);
- return new AUD_Sound(new AUD_FileFactory(buffer, size));
-}
-
-AUD_Sound *AUD_Sound_cache(AUD_Sound *sound)
-{
- assert(sound);
-
- try {
- return new AUD_Sound(new AUD_StreamBufferFactory(*sound));
- }
- catch(AUD_Exception&)
- {
- return NULL;
- }
-}
-
-AUD_Sound *AUD_Sound_rechannel(AUD_Sound *sound, AUD_Channels channels)
-{
- assert(sound);
-
- try {
- AUD_DeviceSpecs specs;
- specs.channels = channels;
- specs.rate = AUD_RATE_INVALID;
- specs.format = AUD_FORMAT_INVALID;
- return new AUD_Sound(new AUD_ChannelMapperFactory(*sound, specs));
- }
- catch(AUD_Exception&)
- {
- return NULL;
- }
-}
-
-AUD_Sound *AUD_Sound_delay(AUD_Sound *sound, float delay)
-{
- assert(sound);
-
- try {
- return new AUD_Sound(new AUD_DelayFactory(*sound, delay));
- }
- catch(AUD_Exception&)
- {
- return NULL;
- }
-}
-
-AUD_Sound *AUD_Sound_limit(AUD_Sound *sound, float start, float end)
-{
- assert(sound);
-
- try {
- return new AUD_Sound(new AUD_LimiterFactory(*sound, start, end));
- }
- catch(AUD_Exception&)
- {
- return NULL;
- }
-}
-
-AUD_Sound *AUD_Sound_pingpong(AUD_Sound *sound)
-{
- assert(sound);
-
- try {
- return new AUD_Sound(new AUD_PingPongFactory(*sound));
- }
- catch(AUD_Exception&)
- {
- return NULL;
- }
-}
-
-AUD_Sound *AUD_Sound_loop(AUD_Sound *sound)
-{
- assert(sound);
-
- try {
- return new AUD_Sound(new AUD_LoopFactory(*sound));
- }
- catch(AUD_Exception&)
- {
- return NULL;
- }
-}
-
-int AUD_Handle_setLoopCount(AUD_Handle *handle, int loops)
-{
- assert(handle);
-
- try {
- return (*handle)->setLoopCount(loops);
- }
- catch(AUD_Exception&)
- {
- }
-
- return false;
-}
-
-AUD_Sound *AUD_rectifySound(AUD_Sound *sound)
-{
- assert(sound);
-
- try {
- return new AUD_Sound(new AUD_RectifyFactory(*sound));
- }
- catch(AUD_Exception&)
- {
- return NULL;
- }
-}
-
-void AUD_Sound_free(AUD_Sound *sound)
-{
- assert(sound);
- delete sound;
-}
-
-AUD_Handle *AUD_Device_play(AUD_Device* device, AUD_Sound *sound, int keep)
-{
- assert(sound);
- try {
- AUD_Handle handle = AUD_device->play(*sound, keep);
- if (handle.get()) {
- return new AUD_Handle(handle);
- }
- }
- catch(AUD_Exception&)
- {
- }
- return NULL;
-}
-
-int AUD_Handle_pause(AUD_Handle *handle)
-{
- assert(handle);
- return (*handle)->pause();
-}
-
-int AUD_Handle_resume(AUD_Handle *handle)
-{
- assert(handle);
- return (*handle)->resume();
-}
-
-int AUD_Handle_stop(AUD_Handle *handle)
-{
- assert(handle);
- int result = (*handle)->stop();
- delete handle;
- return result;
-}
-
-void AUD_Device_stopAll(void* device)
-{
- AUD_device->stopAll();
-}
-
-int AUD_Handle_setKeep(AUD_Handle *handle, int keep)
-{
- assert(handle);
- return (*handle)->setKeep(keep);
-}
-
-int AUD_Handle_setPosition(AUD_Handle *handle, float seekTo)
-{
- assert(handle);
- return (*handle)->seek(seekTo);
-}
-
-float AUD_Handle_getPosition(AUD_Handle *handle)
-{
- assert(handle);
- return (*handle)->getPosition();
-}
-
-AUD_Status AUD_Handle_getStatus(AUD_Handle *handle)
-{
- assert(handle);
- return (*handle)->getStatus();
-}
-
-int AUD_Device_setListenerLocation(const float location[3])
-{
- if (AUD_3ddevice) {
- AUD_Vector3 v(location[0], location[1], location[2]);
- AUD_3ddevice->setListenerLocation(v);
- return true;
- }
-
- return false;
-}
-
-int AUD_Device_setListenerVelocity(const float velocity[3])
-{
- if (AUD_3ddevice) {
- AUD_Vector3 v(velocity[0], velocity[1], velocity[2]);
- AUD_3ddevice->setListenerVelocity(v);
- return true;
- }
-
- return false;
-}
-
-int AUD_Device_setListenerOrientation(const float orientation[4])
-{
- if (AUD_3ddevice) {
- AUD_Quaternion q(orientation[3], orientation[0], orientation[1], orientation[2]);
- AUD_3ddevice->setListenerOrientation(q);
- return true;
- }
-
- return false;
-}
-
-int AUD_Device_setSpeedOfSound(void* device, float speed)
-{
- if (AUD_3ddevice) {
- AUD_3ddevice->setSpeedOfSound(speed);
- return true;
- }
-
- return false;
-}
-
-int AUD_Device_setDopplerFactor(void* device, float factor)
-{
- if (AUD_3ddevice) {
- AUD_3ddevice->setDopplerFactor(factor);
- return true;
- }
-
- return false;
-}
-
-int AUD_Device_setDistanceModel(void* device, AUD_DistanceModel model)
-{
- if (AUD_3ddevice) {
- AUD_3ddevice->setDistanceModel(model);
- return true;
- }
-
- return false;
-}
-
-int AUD_Handle_setLocation(AUD_Handle *handle, const float location[3])
-{
- assert(handle);
- boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
-
- if (h.get()) {
- AUD_Vector3 v(location[0], location[1], location[2]);
- return h->setSourceLocation(v);
- }
-
- return false;
-}
-
-int AUD_Handle_setVelocity(AUD_Handle *handle, const float velocity[3])
-{
- assert(handle);
- boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
-
- if (h.get()) {
- AUD_Vector3 v(velocity[0], velocity[1], velocity[2]);
- return h->setSourceVelocity(v);
- }
-
- return false;
-}
-
-int AUD_Handle_setOrientation(AUD_Handle *handle, const float orientation[4])
-{
- assert(handle);
- boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
-
- if (h.get()) {
- AUD_Quaternion q(orientation[3], orientation[0], orientation[1], orientation[2]);
- return h->setSourceOrientation(q);
- }
-
- return false;
-}
-
-int AUD_Handle_setRelative(AUD_Handle *handle, int relative)
-{
- assert(handle);
- boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
-
- if (h.get()) {
- return h->setRelative(relative);
- }
-
- return false;
-}
-
-int AUD_Handle_setVolumeMaximum(AUD_Handle *handle, float volume)
-{
- assert(handle);
- boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
-
- if (h.get()) {
- return h->setVolumeMaximum(volume);
- }
-
- return false;
-}
-
-int AUD_Handle_setVolumeMinimum(AUD_Handle *handle, float volume)
-{
- assert(handle);
- boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
-
- if (h.get()) {
- return h->setVolumeMinimum(volume);
- }
-
- return false;
-}
-
-int AUD_Handle_setDistanceMaximum(AUD_Handle *handle, float distance)
-{
- assert(handle);
- boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
-
- if (h.get()) {
- return h->setDistanceMaximum(distance);
- }
-
- return false;
-}
-
-int AUD_Handle_setDistanceReference(AUD_Handle *handle, float distance)
-{
- assert(handle);
- boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
-
- if (h.get()) {
- return h->setDistanceReference(distance);
- }
-
- return false;
-}
-
-int AUD_Handle_setAttenuation(AUD_Handle *handle, float factor)
-{
- assert(handle);
- boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
-
- if (h.get()) {
- return h->setAttenuation(factor);
- }
-
- return false;
-}
-
-int AUD_Handle_setConeAngleOuter(AUD_Handle *handle, float angle)
-{
- assert(handle);
- boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
-
- if (h.get()) {
- return h->setConeAngleOuter(angle);
- }
-
- return false;
-}
-
-int AUD_Handle_setConeAngleInner(AUD_Handle *handle, float angle)
-{
- assert(handle);
- boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
-
- if (h.get()) {
- return h->setConeAngleInner(angle);
- }
-
- return false;
-}
-
-int AUD_Handle_setConeVolumeOuter(AUD_Handle *handle, float volume)
-{
- assert(handle);
- boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
-
- if (h.get()) {
- return h->setConeVolumeOuter(volume);
- }
-
- return false;
-}
-
-int AUD_Handle_setVolume(AUD_Handle *handle, float volume)
-{
- assert(handle);
- try {
- return (*handle)->setVolume(volume);
- }
- catch(AUD_Exception&) {}
- return false;
-}
-
-int AUD_Handle_setPitch(AUD_Handle *handle, float pitch)
-{
- assert(handle);
- try {
- return (*handle)->setPitch(pitch);
- }
- catch(AUD_Exception&) {}
- return false;
-}
-
-AUD_Device *AUD_openReadDevice(AUD_DeviceSpecs specs)
-{
- try {
- return new AUD_Device(new AUD_ReadDevice(specs));
- }
- catch(AUD_Exception&)
- {
- return NULL;
- }
-}
-
-AUD_Handle *AUD_playDevice(AUD_Device *device, AUD_Sound *sound, float seek)
-{
- assert(device);
- assert(sound);
-
- try {
- AUD_Handle handle = (*device)->play(*sound);
- if (handle.get()) {
- handle->seek(seek);
- return new AUD_Handle(handle);
- }
- }
- catch(AUD_Exception&)
- {
- }
- return NULL;
-}
-
-int AUD_setDeviceVolume(AUD_Device *device, float volume)
-{
- assert(device);
-
- try {
- (*device)->setVolume(volume);
- return true;
- }
- catch(AUD_Exception&) {}
-
- return false;
-}
-
-int AUD_Device_read(AUD_Device *device, data_t *buffer, int length)
-{
- assert(device);
- assert(buffer);
-
- try {
- return boost::dynamic_pointer_cast<AUD_ReadDevice>(*device)->read(buffer, length);
- }
- catch(AUD_Exception&)
- {
- return false;
- }
-}
-
-void AUD_Device_free(AUD_Device *device)
-{
- try {
- if(device != &AUD_device)
- delete device;
- }
- catch(AUD_Exception&)
- {
- }
-}
-
-float *AUD_readSoundBuffer(const char *filename, float low, float high,
- float attack, float release, float threshold,
- int accumulate, int additive, int square,
- float sthreshold, double samplerate, int *length)
-{
- AUD_Buffer buffer;
- AUD_DeviceSpecs specs;
- specs.channels = AUD_CHANNELS_MONO;
- specs.rate = (AUD_SampleRate)samplerate;
- boost::shared_ptr<AUD_IFactory> sound;
-
- boost::shared_ptr<AUD_IFactory> file = boost::shared_ptr<AUD_IFactory>(new AUD_FileFactory(filename));
-
- int position = 0;
-
- try {
- boost::shared_ptr<AUD_IReader> reader = file->createReader();
-
- AUD_SampleRate rate = reader->getSpecs().rate;
-
- sound = boost::shared_ptr<AUD_IFactory>(new AUD_ChannelMapperFactory(file, specs));
-
- if (high < rate)
- sound = boost::shared_ptr<AUD_IFactory>(new AUD_LowpassFactory(sound, high));
- if (low > 0)
- sound = boost::shared_ptr<AUD_IFactory>(new AUD_HighpassFactory(sound, low));
-
- 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 = boost::shared_ptr<AUD_IFactory>(new AUD_SquareFactory(sound, sthreshold));
-
- if (accumulate)
- sound = boost::shared_ptr<AUD_IFactory>(new AUD_AccumulatorFactory(sound, additive));
- else if (additive)
- sound = boost::shared_ptr<AUD_IFactory>(new AUD_SumFactory(sound));
-
- reader = sound->createReader();
-
- if (!reader.get())
- return NULL;
-
- int len;
- bool eos;
- do
- {
- len = samplerate;
- buffer.resize((position + len) * sizeof(float), true);
- reader->read(len, eos, buffer.getBuffer() + position);
- position += len;
- } while(!eos);
- }
- catch(AUD_Exception&)
- {
- return NULL;
- }
-
- float * result = (float *)malloc(position * sizeof(float));
- memcpy(result, buffer.getBuffer(), position * sizeof(float));
- *length = position;
- return result;
-}
-
-static void pauseSound(AUD_Handle *handle)
-{
- assert(handle);
- (*handle)->pause();
-}
-
-AUD_Handle *AUD_pauseAfter(AUD_Handle *handle, float 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.get()) {
- handle2->setStopCallback((stopCallback)pauseSound, handle);
- return new AUD_Handle(handle2);
- }
- }
- catch(AUD_Exception&)
- {
- }
-
- return NULL;
-}
-
-AUD_Sound *AUD_Sequence_create(float fps, int muted)
-{
- // specs are changed at a later point!
- AUD_Specs specs;
- specs.channels = AUD_CHANNELS_STEREO;
- specs.rate = AUD_RATE_48000;
- AUD_Sound *sequencer = new AUD_Sound(boost::shared_ptr<AUD_SequencerFactory>(new AUD_SequencerFactory(specs, fps, muted)));
- return sequencer;
-}
-
-void AUD_Sequence_free(AUD_Sound *sequencer)
-{
- delete sequencer;
-}
-
-void AUD_Sequence_setMuted(AUD_Sound *sequencer, int muted)
-{
- dynamic_cast<AUD_SequencerFactory *>(sequencer->get())->mute(muted);
-}
-
-void AUD_Sequence_setFPS(AUD_Sound *sequencer, float fps)
-{
- dynamic_cast<AUD_SequencerFactory *>(sequencer->get())->setFPS(fps);
-}
-
-AUD_SEntry *AUD_Sequence_add(AUD_Sound *sequencer, AUD_Sound *sound,
- float begin, float end, float skip)
-{
- if (!sound)
- return new AUD_SEntry(((AUD_SequencerFactory *)sequencer->get())->add(AUD_Sound(), begin, end, skip));
- return new AUD_SEntry(((AUD_SequencerFactory *)sequencer->get())->add(*sound, begin, end, skip));
-}
-
-void AUD_Sequence_remove(AUD_Sound *sequencer, AUD_SEntry *entry)
-{
- dynamic_cast<AUD_SequencerFactory *>(sequencer->get())->remove(*entry);
- delete entry;
-}
-
-void AUD_SequenceEntry_move(AUD_SEntry *entry, float begin, float end, float skip)
-{
- (*entry)->move(begin, end, skip);
-}
-
-void AUD_SequenceEntry_setMuted(AUD_SEntry *entry, char mute)
-{
- (*entry)->mute(mute);
-}
-
-void AUD_SequenceEntry_setSound(AUD_SEntry *entry, AUD_Sound *sound)
-{
- if (sound)
- (*entry)->setSound(*sound);
- else
- (*entry)->setSound(AUD_Sound());
-}
-
-void AUD_SequenceEntry_setAnimationData(AUD_SEntry *entry, AUD_AnimateablePropertyType type, int frame, float *data, char animated)
-{
- AUD_AnimateableProperty *prop = (*entry)->getAnimProperty(type);
- if (animated) {
- if (frame >= 0)
- prop->write(data, frame, 1);
- }
- else {
- prop->write(data);
- }
-}
-
-void AUD_Sequence_setAnimationData(AUD_Sound *sequencer, AUD_AnimateablePropertyType type, int frame, float *data, char animated)
-{
- AUD_AnimateableProperty *prop = dynamic_cast<AUD_SequencerFactory *>(sequencer->get())->getAnimProperty(type);
- if (animated) {
- if (frame >= 0) {
- prop->write(data, frame, 1);
- }
- }
- else {
- prop->write(data);
- }
-}
-
-void AUD_Sequence_setDistanceModel(AUD_Sound* sequence, AUD_DistanceModel value)
-{
- assert(sequence);
- dynamic_cast<AUD_SequencerFactory *>(sequence->get())->setDistanceModel(static_cast<AUD_DistanceModel>(value));
-}
-
-void AUD_Sequence_setDopplerFactor(AUD_Sound* sequence, float value)
-{
- assert(sequence);
- dynamic_cast<AUD_SequencerFactory *>(sequence->get())->setDopplerFactor(value);
-}
-
-void AUD_Sequence_setSpeedOfSound(AUD_Sound* sequence, float value)
-{
- assert(sequence);
- dynamic_cast<AUD_SequencerFactory *>(sequence->get())->setSpeedOfSound(value);
-}
-
-void AUD_SequenceEntry_setAttenuation(AUD_SEntry* sequence_entry, float value)
-{
- assert(sequence_entry);
- (*sequence_entry)->setAttenuation(value);
-}
-
-void AUD_SequenceEntry_setConeAngleInner(AUD_SEntry* sequence_entry, float value)
-{
- assert(sequence_entry);
- (*sequence_entry)->setConeAngleInner(value);
-}
-
-void AUD_SequenceEntry_setConeAngleOuter(AUD_SEntry* sequence_entry, float value)
-{
- assert(sequence_entry);
- (*sequence_entry)->setConeAngleOuter(value);
-}
-
-void AUD_SequenceEntry_setConeVolumeOuter(AUD_SEntry* sequence_entry, float value)
-{
- assert(sequence_entry);
- (*sequence_entry)->setConeVolumeOuter(value);
-}
-
-void AUD_SequenceEntry_setDistanceMaximum(AUD_SEntry* sequence_entry, float value)
-{
- assert(sequence_entry);
- (*sequence_entry)->setDistanceMaximum(value);
-}
-
-void AUD_SequenceEntry_setDistanceReference(AUD_SEntry* sequence_entry, float value)
-{
- assert(sequence_entry);
- (*sequence_entry)->setDistanceReference(value);
-}
-
-void AUD_SequenceEntry_setRelative(AUD_SEntry* sequence_entry, int value)
-{
- assert(sequence_entry);
- (*sequence_entry)->setRelative(value);
-}
-
-void AUD_SequenceEntry_setVolumeMaximum(AUD_SEntry* sequence_entry, float value)
-{
- assert(sequence_entry);
- (*sequence_entry)->setVolumeMaximum(value);
-}
-
-void AUD_SequenceEntry_setVolumeMinimum(AUD_SEntry* sequence_entry, float value)
-{
- assert(sequence_entry);
- (*sequence_entry)->setVolumeMinimum(value);
-}
-
-void AUD_setSequencerDeviceSpecs(AUD_Sound *sequencer)
-{
- dynamic_cast<AUD_SequencerFactory *>(sequencer->get())->setSpecs(AUD_device->getSpecs().specs);
-}
-
-void AUD_Sequence_setSpecs(AUD_Sound *sequencer, AUD_Specs specs)
-{
- dynamic_cast<AUD_SequencerFactory *>(sequencer->get())->setSpecs(specs);
-}
-
-void AUD_seekSynchronizer(AUD_Handle *handle, float time)
-{
-#ifdef WITH_JACK
- AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get());
- if (device) {
- device->seekPlayback(time);
- }
- else
-#endif
- {
- assert(handle);
- (*handle)->seek(time);
- }
-}
-
-float AUD_getSynchronizerPosition(AUD_Handle *handle)
-{
-#ifdef WITH_JACK
- AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get());
- if (device) {
- return device->getPlaybackPosition();
- }
- else
-#endif
- {
- assert(handle);
- return (*handle)->getPosition();
- }
-}
-
-void AUD_playSynchronizer()
-{
-#ifdef WITH_JACK
- AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get());
- if (device) {
- device->startPlayback();
- }
-#endif
-}
-
-void AUD_stopSynchronizer()
-{
-#ifdef WITH_JACK
- AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get());
- if (device) {
- device->stopPlayback();
- }
-#endif
-}
-
-#ifdef WITH_JACK
-void AUD_setSynchronizerCallback(AUD_syncFunction function, void *data)
-{
- AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get());
- if (device) {
- device->setSyncCallback(function, data);
- }
-}
-#endif
-
-int AUD_isSynchronizerPlaying()
-{
-#ifdef WITH_JACK
- AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get());
- if (device) {
- return device->doesPlayback();
- }
-#endif
- return -1;
-}
-
-int AUD_readSound(AUD_Sound *sound, sample_t *buffer, int length, int samples_per_second, short *interrupt)
-{
- AUD_DeviceSpecs specs;
- sample_t *buf;
- AUD_Buffer aBuffer;
-
- specs.rate = AUD_RATE_INVALID;
- specs.channels = AUD_CHANNELS_MONO;
- specs.format = AUD_FORMAT_INVALID;
-
- boost::shared_ptr<AUD_IReader> reader = AUD_ChannelMapperFactory(*sound, specs).createReader();
-
- specs.specs = reader->getSpecs();
- int len;
- float samplejump = specs.rate / samples_per_second;
- float min, max, power, overallmax;
- bool eos;
-
- overallmax = 0;
-
- for (int i = 0; i < length; i++) {
- len = floor(samplejump * (i+1)) - floor(samplejump * i);
-
- if (*interrupt) {
- return 0;
- }
- aBuffer.assureSize(len * AUD_SAMPLE_SIZE(specs));
- buf = aBuffer.getBuffer();
-
- reader->read(len, eos, buf);
-
- max = min = *buf;
- power = *buf * *buf;
- for (int j = 1; j < len; j++) {
- if (buf[j] < min)
- min = buf[j];
- if (buf[j] > max)
- max = buf[j];
- power += buf[j] * buf[j];
- }
-
- buffer[i * 3] = min;
- buffer[i * 3 + 1] = max;
- buffer[i * 3 + 2] = sqrt(power) / len;
-
- if (overallmax < max)
- overallmax = max;
- if (overallmax < -min)
- overallmax = -min;
-
- if (eos) {
- length = i;
- break;
- }
- }
-
- if (overallmax > 1.0f) {
- for (int i = 0; i < length * 3; i++) {
- buffer[i] /= overallmax;
- }
- }
-
- return length;
-}
-
-AUD_Sound *AUD_Sound_copy(AUD_Sound *sound)
-{
- return new boost::shared_ptr<AUD_IFactory>(*sound);
-}
-
-void AUD_Handle_free(AUD_Handle *handle)
-{
- delete handle;
-}
-
-const char *AUD_mixdown(AUD_Sound *sound, unsigned int start, unsigned int length, unsigned int buffersize, const char *filename, AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate)
-{
- try {
- AUD_SequencerFactory *f = dynamic_cast<AUD_SequencerFactory *>(sound->get());
-
- f->setSpecs(specs.specs);
- boost::shared_ptr<AUD_IReader> reader = f->createQualityReader();
- reader->seek(start);
- boost::shared_ptr<AUD_IWriter> writer = AUD_FileWriter::createWriter(filename, specs, format, codec, bitrate);
- AUD_FileWriter::writeReader(reader, writer, length, buffersize);
-
- return NULL;
- }
- catch(AUD_Exception& e)
- {
- return e.str;
- }
-}
-
-const char *AUD_mixdown_per_channel(AUD_Sound *sound, unsigned int start, unsigned int length, unsigned int buffersize, const char *filename, AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate)
-{
- try {
- AUD_SequencerFactory *f = dynamic_cast<AUD_SequencerFactory *>(sound->get());
-
- f->setSpecs(specs.specs);
-
- std::vector<boost::shared_ptr<AUD_IWriter> > writers;
-
- int channels = specs.channels;
- specs.channels = AUD_CHANNELS_MONO;
-
- for (int i = 0; i < channels; i++) {
- std::stringstream stream;
- std::string fn = filename;
- size_t index = fn.find_last_of('.');
- size_t index_slash = fn.find_last_of('/');
- size_t index_backslash = fn.find_last_of('\\');
-
- if ((index == std::string::npos) ||
- ((index < index_slash) && (index_slash != std::string::npos)) ||
- ((index < index_backslash) && (index_backslash != std::string::npos)))
- {
- stream << filename << "_" << (i + 1);
- }
- else {
- stream << fn.substr(0, index) << "_" << (i + 1) << fn.substr(index);
- }
- writers.push_back(AUD_FileWriter::createWriter(stream.str(), specs, format, codec, bitrate));
- }
-
- boost::shared_ptr<AUD_IReader> reader = f->createQualityReader();
- reader->seek(start);
- AUD_FileWriter::writeReader(reader, writers, length, buffersize);
-
- return NULL;
- }
- catch(AUD_Exception& e)
- {
- return e.str;
- }
-}
-
-AUD_Device *AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound *sequencer, float volume, float start)
-{
- try {
- AUD_ReadDevice *device = new AUD_ReadDevice(specs);
- device->setQuality(true);
- device->setVolume(volume);
-
- AUD_SequencerFactory *f = dynamic_cast<AUD_SequencerFactory *>(sequencer->get());
-
- f->setSpecs(specs.specs);
-
- AUD_Handle handle = device->play(f->createQualityReader());
- if (handle.get()) {
- handle->seek(start);
- }
-
- return new AUD_Device(device);
- }
- catch(AUD_Exception&)
- {
- return NULL;
- }
-}
-
-AUD_Device *AUD_Device_getCurrent(void)
-{
- return &AUD_device;
-}
-
-int AUD_isJackSupported(void)
-{
-#ifdef WITH_JACK
- return AUD_jack_supported();
-#else
- return 0;
-#endif
-}
diff --git a/intern/audaspace/intern/AUD_C-API.h b/intern/audaspace/intern/AUD_C-API.h
deleted file mode 100644
index cc9059a8e09..00000000000
--- a/intern/audaspace/intern/AUD_C-API.h
+++ /dev/null
@@ -1,822 +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 AUD_C-API.h
- * \ingroup audaspace
- */
-
-#ifndef __AUD_C_API_H__
-#define __AUD_C_API_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "AUD_Space.h"
-
-/// Supported output devices.
-typedef enum
-{
- AUD_NULL_DEVICE = 0,
- AUD_SDL_DEVICE,
- AUD_OPENAL_DEVICE,
- AUD_JACK_DEVICE
-} AUD_DeviceType;
-
-/// Sound information structure.
-typedef struct
-{
- AUD_Specs specs;
- float length;
-} AUD_SoundInfo;
-
-#ifndef AUD_CAPI_IMPLEMENTATION
- typedef void AUD_Sound;
- typedef void AUD_Handle;
- typedef void AUD_Device;
- typedef void AUD_SEntry;
- typedef float (*AUD_volumeFunction)(void *, void *, float);
- typedef void (*AUD_syncFunction)(void *, int, float);
-#endif
-
-/**
- * Initializes audio routines (FFMPEG/JACK if it is enabled).
- */
-extern void AUD_initOnce(void);
-
-/**
- * Unitinitializes an audio routines.
- */
-extern void AUD_exitOnce(void);
-
-/**
- * Initializes an audio device.
- * \param device The device type that should be used.
- * \param specs The audio specification to be used.
- * \param buffersize The buffersize for the device.
- * \return Whether the device has been initialized.
- */
-extern AUD_Device* AUD_init(const char* device, AUD_DeviceSpecs specs, int buffersize, const char* name);
-
-/**
- * Unitinitializes an audio device.
- */
-extern void AUD_exit(AUD_Device* device);
-
-/**
- * Locks the playback device.
- */
-extern void AUD_Device_lock(AUD_Device* device);
-
-/**
- * Unlocks the device.
- */
-extern void AUD_Device_unlock(AUD_Device* device);
-
-extern AUD_Channels AUD_Device_getChannels(AUD_Device* device);
-
-extern AUD_SampleRate AUD_Device_getRate(AUD_Device* device);
-
-/**
- * Returns information about a sound.
- * \param sound The sound to get the info about.
- * \return The AUD_SoundInfo structure with filled in data.
- */
-extern AUD_SoundInfo AUD_getInfo(AUD_Sound *sound);
-
-/**
- * Loads a sound file.
- * \param filename The filename of the sound file.
- * \return A handle of the sound file.
- */
-extern AUD_Sound *AUD_Sound_file(const char *filename);
-
-/**
- * Loads a sound file.
- * \param buffer The buffer which contains the sound file.
- * \param size The size of the buffer.
- * \return A handle of the sound file.
- */
-extern AUD_Sound *AUD_Sound_bufferFile(unsigned char *buffer, int size);
-
-/**
- * Buffers a sound.
- * \param sound The sound to buffer.
- * \return A handle of the sound buffer.
- */
-extern AUD_Sound *AUD_Sound_cache(AUD_Sound *sound);
-
-/**
- * Rechannels the sound to be mono.
- * \param sound The sound to rechannel.
- * \return The mono sound.
- */
-extern AUD_Sound *AUD_Sound_rechannel(AUD_Sound *sound, AUD_Channels channels);
-
-/**
- * Delays a sound.
- * \param sound The sound to dealy.
- * \param delay The delay in seconds.
- * \return A handle of the delayed sound.
- */
-extern AUD_Sound *AUD_Sound_delay(AUD_Sound *sound, float delay);
-
-/**
- * Limits a sound.
- * \param sound The sound to limit.
- * \param start The start time in seconds.
- * \param end The stop time in seconds.
- * \return A handle of the limited sound.
- */
-extern AUD_Sound *AUD_Sound_limit(AUD_Sound *sound, float start, float end);
-
-/**
- * Ping pongs a sound.
- * \param sound The sound to ping pong.
- * \return A handle of the ping pong sound.
- */
-extern AUD_Sound *AUD_Sound_pingpong(AUD_Sound *sound);
-
-/**
- * Loops a sound.
- * \param sound The sound to loop.
- * \return A handle of the looped sound.
- */
-extern AUD_Sound *AUD_Sound_loop(AUD_Sound *sound);
-
-/**
- * Sets a remaining loop count of a looping sound that currently plays.
- * \param handle The playback handle.
- * \param loops The count of remaining loops, -1 for infinity.
- * \return Whether the handle is valid.
- */
-extern int AUD_Handle_setLoopCount(AUD_Handle *handle, int loops);
-
-/**
- * Rectifies a sound.
- * \param sound The sound to rectify.
- * \return A handle of the rectified sound.
- */
-extern AUD_Sound *AUD_rectifySound(AUD_Sound *sound);
-
-/**
- * Unloads a sound of any type.
- * \param sound The handle of the sound.
- */
-extern void AUD_Sound_free(AUD_Sound *sound);
-
-/**
- * Plays back a sound file.
- * \param sound The handle of the sound file.
- * \param keep When keep is true the sound source will not be deleted but set to
- * paused when its end has been reached.
- * \return A handle to the played back sound.
- */
-extern AUD_Handle *AUD_Device_play(AUD_Device* device, AUD_Sound *sound, int keep);
-
-/**
- * Pauses a played back sound.
- * \param handle The handle to the sound.
- * \return Whether the handle has been playing or not.
- */
-extern int AUD_Handle_pause(AUD_Handle *handle);
-
-/**
- * Resumes a paused sound.
- * \param handle The handle to the sound.
- * \return Whether the handle has been paused or not.
- */
-extern int AUD_Handle_resume(AUD_Handle *handle);
-
-/**
- * Stops a playing or paused sound.
- * \param handle The handle to the sound.
- * \return Whether the handle has been valid or not.
- */
-extern int AUD_Handle_stop(AUD_Handle *handle);
-
-extern void AUD_Device_stopAll(void* device);
-
-/**
- * Sets the end behaviour of a playing or paused sound.
- * \param handle The handle to the sound.
- * \param keep When keep is true the sound source will not be deleted but set to
- * paused when its end has been reached.
- * \return Whether the handle has been valid or not.
- */
-extern int AUD_Handle_setKeep(AUD_Handle *handle, int keep);
-
-/**
- * Seeks a playing or paused sound.
- * \param handle The handle to the sound.
- * \param seekTo From where the sound file should be played back in seconds.
- * \return Whether the handle has been valid or not.
- */
-extern int AUD_Handle_setPosition(AUD_Handle *handle, float seekTo);
-
-/**
- * Retrieves the playback position of a handle.
- * \param handle The handle to the sound.
- * \return The current playback position in seconds or 0.0 if the handle is
- * invalid.
- */
-extern float AUD_Handle_getPosition(AUD_Handle *handle);
-
-/**
- * Returns the status of a playing, paused or stopped sound.
- * \param handle The handle to the sound.
- * \return The status of the sound behind the handle.
- */
-extern AUD_Status AUD_Handle_getStatus(AUD_Handle *handle);
-
-/**
- * Sets the listener location.
- * \param location The new location.
- */
-extern int AUD_Device_setListenerLocation(const float location[3]);
-
-/**
- * Sets the listener velocity.
- * \param velocity The new velocity.
- */
-extern int AUD_Device_setListenerVelocity(const float velocity[3]);
-
-/**
- * Sets the listener orientation.
- * \param orientation The new orientation as quaternion.
- */
-extern int AUD_Device_setListenerOrientation(const float orientation[4]);
-
-/**
- * Sets the speed of sound.
- * This value is needed for doppler effect calculation.
- * \param speed The new speed of sound.
- */
-extern int AUD_Device_setSpeedOfSound(void* device, float speed);
-
-/**
- * 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.
- */
-extern int AUD_Device_setDopplerFactor(void* device, float factor);
-
-/**
- * Sets the distance model.
- * \param model distance model.
- */
-extern int AUD_Device_setDistanceModel(void* device, AUD_DistanceModel model);
-
-/**
- * Sets the location of a source.
- * \param handle The handle of the source.
- * \param location The new location.
- * \return Whether the action succeeded.
- */
-extern int AUD_Handle_setLocation(AUD_Handle *handle, const float location[3]);
-
-/**
- * Sets the velocity of a source.
- * \param handle The handle of the source.
- * \param velocity The new velocity.
- * \return Whether the action succeeded.
- */
-extern int AUD_Handle_setVelocity(AUD_Handle *handle, const float velocity[3]);
-
-/**
- * Sets the orientation of a source.
- * \param handle The handle of the source.
- * \param orientation The new orientation as quaternion.
- * \return Whether the action succeeded.
- */
-extern int AUD_Handle_setOrientation(AUD_Handle *handle, const float orientation[4]);
-
-/**
- * Sets whether the source location, velocity and orientation are relative
- * to the listener.
- * \param handle The handle of the source.
- * \param relative Whether the source is relative.
- * \return Whether the action succeeded.
- */
-extern int AUD_Handle_setRelative(AUD_Handle *handle, int relative);
-
-/**
- * Sets the maximum volume of a source.
- * \param handle The handle of the source.
- * \param volume The new maximum volume.
- * \return Whether the action succeeded.
- */
-extern int AUD_Handle_setVolumeMaximum(AUD_Handle *handle, float volume);
-
-/**
- * Sets the minimum volume of a source.
- * \param handle The handle of the source.
- * \param volume The new minimum volume.
- * \return Whether the action succeeded.
- */
-extern int AUD_Handle_setVolumeMinimum(AUD_Handle *handle, float volume);
-
-/**
- * Sets the maximum distance of a source.
- * If a source is further away from the reader than this distance, the
- * volume will automatically be set to 0.
- * \param handle The handle of the source.
- * \param distance The new maximum distance.
- * \return Whether the action succeeded.
- */
-extern int AUD_Handle_setDistanceMaximum(AUD_Handle *handle, float distance);
-
-/**
- * Sets the reference distance of a source.
- * \param handle The handle of the source.
- * \param distance The new reference distance.
- * \return Whether the action succeeded.
- */
-extern int AUD_Handle_setDistanceReference(AUD_Handle *handle, float distance);
-
-/**
- * Sets the attenuation of a source.
- * This value is used for distance calculation.
- * \param handle The handle of the source.
- * \param factor The new attenuation.
- * \return Whether the action succeeded.
- */
-extern int AUD_Handle_setAttenuation(AUD_Handle *handle, float factor);
-
-/**
- * Sets the outer angle of the cone of a source.
- * \param handle The handle of the source.
- * \param angle The new outer angle of the cone.
- * \return Whether the action succeeded.
- */
-extern int AUD_Handle_setConeAngleOuter(AUD_Handle *handle, float angle);
-
-/**
- * Sets the inner angle of the cone of a source.
- * \param handle The handle of the source.
- * \param angle The new inner angle of the cone.
- * \return Whether the action succeeded.
- */
-extern int AUD_Handle_setConeAngleInner(AUD_Handle *handle, float angle);
-
-/**
- * Sets the outer volume of the cone of a source.
- * The volume between inner and outer angle is interpolated between inner
- * volume and this value.
- * \param handle The handle of the source.
- * \param volume The new outer volume of the cone.
- * \return Whether the action succeeded.
- */
-extern int AUD_Handle_setConeVolumeOuter(AUD_Handle *handle, float volume);
-
-/**
- * Sets the volume of a played back sound.
- * \param handle The handle to the sound.
- * \param volume The new volume, must be between 0.0 and 1.0.
- * \return Whether the action succeeded.
- */
-extern int AUD_Handle_setVolume(AUD_Handle *handle, float volume);
-
-/**
- * Sets the pitch of a played back sound.
- * \param handle The handle to the sound.
- * \param pitch The new pitch.
- * \return Whether the action succeeded.
- */
-extern int AUD_Handle_setPitch(AUD_Handle *handle, float pitch);
-
-/**
- * Opens a read device, with which audio data can be read.
- * \param specs The specification of the audio data.
- * \return A device handle.
- */
-extern AUD_Device *AUD_openReadDevice(AUD_DeviceSpecs specs);
-
-/**
- * Sets the main volume of a device.
- * \param device The device.
- * \param volume The new volume, must be between 0.0 and 1.0.
- * \return Whether the action succeeded.
- */
-extern int AUD_setDeviceVolume(AUD_Device *device, float volume);
-
-/**
- * Plays back a sound file through a read device.
- * \param device The read device.
- * \param sound The handle of the sound file.
- * \param seek The position where the sound should be seeked to.
- * \return A handle to the played back sound.
- */
-extern AUD_Handle *AUD_playDevice(AUD_Device *device, AUD_Sound *sound, float seek);
-
-/**
- * Reads the next samples into the supplied buffer.
- * \param device The read device.
- * \param buffer The target buffer.
- * \param length The length in samples to be filled.
- * \return True if the reading succeeded, false if there are no sounds
- * played back currently, in that case the buffer is filled with
- * silence.
- */
-extern int AUD_Device_read(AUD_Device *device, data_t *buffer, int length);
-
-/**
- * Closes a read device.
- * \param device The read device.
- */
-extern void AUD_Device_free(AUD_Device *device);
-
-/**
- * Reads a sound file into a newly created float buffer.
- * The sound is therefore bandpassed, rectified and resampled.
- */
-extern float *AUD_readSoundBuffer(const char *filename, float low, float high,
- float attack, float release, float threshold,
- int accumulate, int additive, int square,
- float sthreshold, double samplerate,
- int *length);
-
-/**
- * Pauses a playing sound after a specific amount of time.
- * \param handle The handle to the sound.
- * \param seconds The time in seconds.
- * \return The silence handle.
- */
-extern AUD_Handle *AUD_pauseAfter(AUD_Handle *handle, float seconds);
-
-/**
- * Creates a new sequenced sound scene.
- * \param fps The FPS of the scene.
- * \param muted Whether the scene is muted.
- * \return The new sound scene.
- */
-extern AUD_Sound *AUD_Sequence_create(float fps, int muted);
-
-/**
- * Deletes a sound scene.
- * \param sequencer The sound scene.
- */
-extern void AUD_Sequence_free(AUD_Sound *sequencer);
-
-/**
- * Sets the muting state of the scene.
- * \param sequencer The sound scene.
- * \param muted Whether the scene is muted.
- */
-extern void AUD_Sequence_setMuted(AUD_Sound *sequencer, int muted);
-
-/**
- * Sets the scene's FPS.
- * \param sequencer The sound scene.
- * \param fps The new FPS.
- */
-extern void AUD_Sequence_setFPS(AUD_Sound *sequencer, float fps);
-
-/**
- * Adds a new entry to the scene.
- * \param sequencer The sound 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.
- */
-extern AUD_SEntry *AUD_Sequence_add(AUD_Sound *sequencer, AUD_Sound *sound,
- float begin, float end, float skip);
-
-/**
- * Removes an entry from the scene.
- * \param sequencer The sound scene.
- * \param entry The entry to remove.
- */
-extern void AUD_Sequence_remove(AUD_Sound *sequencer, AUD_SEntry *entry);
-
-/**
- * Moves the entry.
- * \param entry The sequenced entry.
- * \param begin The new start time.
- * \param end The new end time or a negative value if unknown.
- * \param skip How many seconds to skip at the beginning.
- */
-extern void AUD_SequenceEntry_move(AUD_SEntry *entry, float begin, float end, float skip);
-
-/**
- * Sets the muting state of the entry.
- * \param entry The sequenced entry.
- * \param mute Whether the entry should be muted or not.
- */
-extern void AUD_SequenceEntry_setMuted(AUD_SEntry *entry, char mute);
-
-/**
- * Sets the sound of the entry.
- * \param entry The sequenced entry.
- * \param sound The new sound.
- */
-extern void AUD_SequenceEntry_setSound(AUD_SEntry *entry, AUD_Sound *sound);
-
-/**
- * Writes animation data to a sequenced entry.
- * \param entry The sequenced entry.
- * \param type The type of animation data.
- * \param frame The frame this data is for.
- * \param data The data to write.
- * \param animated Whether the attribute is animated.
- */
-extern void AUD_SequenceEntry_setAnimationData(AUD_SEntry *entry, AUD_AnimateablePropertyType type, int frame, float *data, char animated);
-
-/**
- * Writes animation data to a sequenced entry.
- * \param sequencer The sound scene.
- * \param type The type of animation data.
- * \param frame The frame this data is for.
- * \param data The data to write.
- * \param animated Whether the attribute is animated.
- */
-extern void AUD_Sequence_setAnimationData(AUD_Sound *sequencer, AUD_AnimateablePropertyType type, int frame, float *data, char animated);
-
-/**
- * Sets the distance model of a sequence.
- * param sequence The sequence to set the distance model from.
- * param value The new distance model to set.
- */
-extern void AUD_Sequence_setDistanceModel(AUD_Sound* sequence, AUD_DistanceModel value);
-
-/**
- * Sets the doppler factor of a sequence.
- * param sequence The sequence to set the doppler factor from.
- * param value The new doppler factor to set.
- */
-extern void AUD_Sequence_setDopplerFactor(AUD_Sound* sequence, float value);
-
-/**
- * Sets the speed of sound of a sequence.
- * param sequence The sequence to set the speed of sound from.
- * param value The new speed of sound to set.
- */
-extern void AUD_Sequence_setSpeedOfSound(AUD_Sound* sequence, float value);
-/**
- * Sets the attenuation of a sequence_entry.
- * param sequence_entry The sequence_entry to set the attenuation from.
- * param value The new attenuation to set.
- */
-extern void AUD_SequenceEntry_setAttenuation(AUD_SEntry* sequence_entry, float value);
-
-/**
- * Sets the cone angle inner of a sequence_entry.
- * param sequence_entry The sequence_entry to set the cone angle inner from.
- * param value The new cone angle inner to set.
- */
-extern void AUD_SequenceEntry_setConeAngleInner(AUD_SEntry* sequence_entry, float value);
-
-/**
- * Sets the cone angle outer of a sequence_entry.
- * param sequence_entry The sequence_entry to set the cone angle outer from.
- * param value The new cone angle outer to set.
- */
-extern void AUD_SequenceEntry_setConeAngleOuter(AUD_SEntry* sequence_entry, float value);
-
-/**
- * Sets the cone volume outer of a sequence_entry.
- * param sequence_entry The sequence_entry to set the cone volume outer from.
- * param value The new cone volume outer to set.
- */
-extern void AUD_SequenceEntry_setConeVolumeOuter(AUD_SEntry* sequence_entry, float value);
-
-/**
- * Sets the distance maximum of a sequence_entry.
- * param sequence_entry The sequence_entry to set the distance maximum from.
- * param value The new distance maximum to set.
- */
-extern void AUD_SequenceEntry_setDistanceMaximum(AUD_SEntry* sequence_entry, float value);
-
-/**
- * Sets the distance reference of a sequence_entry.
- * param sequence_entry The sequence_entry to set the distance reference from.
- * param value The new distance reference to set.
- */
-extern void AUD_SequenceEntry_setDistanceReference(AUD_SEntry* sequence_entry, float value);
-
-/**
- * Sets the relative of a sequence_entry.
- * param sequence_entry The sequence_entry to set the relative from.
- * param value The new relative to set.
- */
-extern void AUD_SequenceEntry_setRelative(AUD_SEntry* sequence_entry, int value);
-
-/**
- * Sets the volume maximum of a sequence_entry.
- * param sequence_entry The sequence_entry to set the volume maximum from.
- * param value The new volume maximum to set.
- */
-extern void AUD_SequenceEntry_setVolumeMaximum(AUD_SEntry* sequence_entry, float value);
-
-/**
- * Sets the volume minimum of a sequence_entry.
- * param sequence_entry The sequence_entry to set the volume minimum from.
- * param value The new volume minimum to set.
- */
-extern void AUD_SequenceEntry_setVolumeMinimum(AUD_SEntry* sequence_entry, float value);
-
-/**
- * Sets the audio output specification of the sound scene to the specs of the
- * current playback device.
- * \param sequencer The sound scene.
- */
-extern void AUD_setSequencerDeviceSpecs(AUD_Sound *sequencer);
-
-/**
- * Sets the audio output specification of the sound scene.
- * \param sequencer The sound scene.
- * \param specs The new specification.
- */
-extern void AUD_Sequence_setSpecs(AUD_Sound *sequencer, AUD_Specs specs);
-
-/**
- * Seeks sequenced sound scene playback.
- * \param handle Playback handle.
- * \param time Time in seconds to seek to.
- */
-extern void AUD_seekSynchronizer(AUD_Handle *handle, float time);
-
-/**
- * Returns the current sound scene playback time.
- * \param handle Playback handle.
- * \return The playback time in seconds.
- */
-extern float AUD_getSynchronizerPosition(AUD_Handle *handle);
-
-/**
- * Starts the playback of jack transport if possible.
- */
-extern void AUD_playSynchronizer(void);
-
-/**
- * Stops the playback of jack transport if possible.
- */
-extern void AUD_stopSynchronizer(void);
-
-#ifdef WITH_JACK
-/**
- * Sets the sync callback for jack transport.
- * \param function The callback function.
- * \param data The data parameter for the callback.
- */
-extern void AUD_setSynchronizerCallback(AUD_syncFunction function, void *data);
-#endif
-
-/**
- * Returns whether jack transport is currently playing.
- * \return Whether jack transport is currently playing.
- */
-extern int AUD_isSynchronizerPlaying(void);
-
-/**
- * Reads a sound into a buffer for drawing at a specific sampling rate.
- * \param sound The sound to read.
- * \param buffer The buffer to write to. Must have a size of 3*4*length.
- * \param length How many samples to read from the sound.
- * \param samples_per_second How many samples to read per second of the sound.
- * \return How many samples really have been read. Always <= length.
- */
-extern int AUD_readSound(AUD_Sound *sound, sample_t *buffer, int length, int samples_per_second, short *interrupt);
-
-/**
- * Copies a sound.
- * \param sound Sound to copy.
- * \return Copied sound.
- */
-extern AUD_Sound *AUD_Sound_copy(AUD_Sound *sound);
-
-/**
- * Frees a handle.
- * \param channel Handle to free.
- */
-extern void AUD_Handle_free(AUD_Handle *channel);
-
-/**
- * Creates a new set.
- * \return The new set.
- */
-extern void *AUD_createSet(void);
-
-/**
- * Deletes a set.
- * \param set The set to delete.
- */
-extern void AUD_destroySet(void *set);
-
-/**
- * Removes an entry from a set.
- * \param set The set work on.
- * \param entry The entry to remove.
- * \return Whether the entry was in the set or not.
- */
-extern char AUD_removeSet(void *set, void *entry);
-
-/**
- * Adds a new entry to a set.
- * \param set The set work on.
- * \param entry The entry to add.
- */
-extern void AUD_addSet(void *set, void *entry);
-
-/**
- * Removes one entry from a set and returns it.
- * \param set The set work on.
- * \return The entry or NULL if the set is empty.
- */
-extern void *AUD_getSet(void *set);
-
-/**
- * Mixes a sound down into a file.
- * \param sound The sound scene to mix down.
- * \param start The start frame.
- * \param length The count of frames to write.
- * \param buffersize How many samples should be written at once.
- * \param filename The file to write to.
- * \param specs The file's audio specification.
- * \param format The file's container format.
- * \param codec The codec used for encoding the audio data.
- * \param bitrate The bitrate for encoding.
- * \return An error message or NULL in case of success.
- */
-extern const char *AUD_mixdown(AUD_Sound *sound, unsigned int start, unsigned int length,
- unsigned int buffersize, const char *filename,
- AUD_DeviceSpecs specs, AUD_Container format,
- AUD_Codec codec, unsigned int bitrate);
-
-/**
- * Mixes a sound down into multiple files.
- * \param sound The sound scene to mix down.
- * \param start The start frame.
- * \param length The count of frames to write.
- * \param buffersize How many samples should be written at once.
- * \param filename The file to write to, the channel number and an underscore are added at the beginning.
- * \param specs The file's audio specification.
- * \param format The file's container format.
- * \param codec The codec used for encoding the audio data.
- * \param bitrate The bitrate for encoding.
- * \return An error message or NULL in case of success.
- */
-extern const char *AUD_mixdown_per_channel(AUD_Sound *sound, unsigned int start, unsigned int length,
- unsigned int buffersize, const char *filename,
- AUD_DeviceSpecs specs, AUD_Container format,
- AUD_Codec codec, unsigned int bitrate);
-
-/**
- * Opens a read device and prepares it for mixdown of the sound scene.
- * \param specs Output audio specifications.
- * \param sequencer The sound scene to mix down.
- * \param volume The overall mixdown volume.
- * \param start The start time of the mixdown in the sound scene.
- * \return The read device for the mixdown.
- */
-extern AUD_Device *AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound *sequencer, float volume, float start);
-
-#ifdef WITH_PYTHON
-/**
- * Retrieves the python factory of a sound.
- * \param sound The sound factory.
- * \return The python factory.
- */
-extern void *AUD_getPythonSound(AUD_Sound *sound);
-
-/**
- * Retrieves the sound factory of a python factory.
- * \param sound The python factory.
- * \return The sound factory.
- */
-extern AUD_Sound *AUD_getSoundFromPython(void *sound);
-#endif
-
-extern AUD_Device *AUD_Device_getCurrent(void);
-
-extern int AUD_isJackSupported(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__AUD_C_API_H__
diff --git a/intern/audaspace/intern/AUD_ChannelMapperFactory.cpp b/intern/audaspace/intern/AUD_ChannelMapperFactory.cpp
deleted file mode 100644
index f4ba5d05ff0..00000000000
--- a/intern/audaspace/intern/AUD_ChannelMapperFactory.cpp
+++ /dev/null
@@ -1,45 +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_ChannelMapperFactory.cpp
- * \ingroup audaspaceintern
- */
-
-
-#include "AUD_ChannelMapperFactory.h"
-#include "AUD_ChannelMapperReader.h"
-
-#include <cstring>
-
-AUD_ChannelMapperFactory::AUD_ChannelMapperFactory(boost::shared_ptr<AUD_IFactory> factory,
- AUD_DeviceSpecs specs) :
- AUD_MixerFactory(factory, specs)
-{
-}
-
-boost::shared_ptr<AUD_IReader> AUD_ChannelMapperFactory::createReader()
-{
- 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
deleted file mode 100644
index 611b5041c39..00000000000
--- a/intern/audaspace/intern/AUD_ChannelMapperFactory.h
+++ /dev/null
@@ -1,57 +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_ChannelMapperFactory.h
- * \ingroup audaspaceintern
- */
-
-
-#ifndef __AUD_CHANNELMAPPERFACTORY_H__
-#define __AUD_CHANNELMAPPERFACTORY_H__
-
-#include "AUD_MixerFactory.h"
-
-/**
- * This factory creates a reader that maps a sound source's channels to a
- * specific output channel count.
- */
-class AUD_ChannelMapperFactory : public AUD_MixerFactory
-{
-private:
- // hide copy constructor and operator=
- AUD_ChannelMapperFactory(const AUD_ChannelMapperFactory&);
- AUD_ChannelMapperFactory& operator=(const AUD_ChannelMapperFactory&);
-
-public:
- /**
- * Creates a new factory.
- * \param factory The input factory.
- * \param specs The target specifications.
- */
- AUD_ChannelMapperFactory(boost::shared_ptr<AUD_IFactory> factory, AUD_DeviceSpecs specs);
-
- 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
deleted file mode 100644
index 8b983d5c43d..00000000000
--- a/intern/audaspace/intern/AUD_ChannelMapperReader.cpp
+++ /dev/null
@@ -1,378 +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_ChannelMapperReader.cpp
- * \ingroup audaspaceintern
- */
-
-#include <cmath>
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-#ifndef M_PI_2
-#define M_PI_2 1.57079632679489661923
-#endif
-
-#include "AUD_ChannelMapperReader.h"
-
-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)
-{
-}
-
-AUD_ChannelMapperReader::~AUD_ChannelMapperReader()
-{
- delete[] m_mapping;
-}
-
-void AUD_ChannelMapperReader::setChannels(AUD_Channels channels)
-{
- m_target_channels = channels;
- calculateMapping();
-}
-
-void AUD_ChannelMapperReader::setMonoAngle(float angle)
-{
- if(angle != angle)
- angle = 0;
- m_mono_angle = angle;
- if(m_source_channels == AUD_CHANNELS_MONO)
- calculateMapping();
-}
-
-float AUD_ChannelMapperReader::angleDistance(float alpha, float beta)
-{
- alpha = beta - alpha;
-
- if(alpha > M_PI)
- alpha -= 2 * M_PI;
- if(alpha < -M_PI)
- alpha += 2 * M_PI;
-
- return alpha;
-}
-
-void AUD_ChannelMapperReader::calculateMapping()
-{
- if(m_map_size < m_source_channels * m_target_channels)
- {
- delete[] m_mapping;
- m_mapping = new float[m_source_channels * m_target_channels];
- m_map_size = m_source_channels * m_target_channels;
- }
-
- for(int i = 0; i < m_source_channels * m_target_channels; i++)
- m_mapping[i] = 0;
-
- const AUD_Channel* source_channels = CHANNEL_MAPS[m_source_channels - 1];
- const AUD_Channel* target_channels = CHANNEL_MAPS[m_target_channels - 1];
-
- int lfe = -1;
-
- for(int i = 0; i < m_target_channels; i++)
- {
- if(target_channels[i] == AUD_CHANNEL_LFE)
- {
- lfe = i;
- break;
- }
- }
-
- const float* source_angles = CHANNEL_ANGLES[m_source_channels - 1];
- const float* target_angles = CHANNEL_ANGLES[m_target_channels - 1];
-
- if(m_source_channels == AUD_CHANNELS_MONO)
- source_angles = &m_mono_angle;
-
- int channel_left, channel_right;
- float angle_left, angle_right, angle;
-
- for(int i = 0; i < m_source_channels; i++)
- {
- if(source_channels[i] == AUD_CHANNEL_LFE)
- {
- if(lfe != -1)
- m_mapping[lfe * m_source_channels + i] = 1;
-
- continue;
- }
-
- channel_left = channel_right = -1;
- angle_left = -2 * M_PI;
- angle_right = 2 * M_PI;
-
- for(int j = 0; j < m_target_channels; j++)
- {
- if(j == lfe)
- continue;
- angle = angleDistance(source_angles[i], target_angles[j]);
- if(angle < 0)
- {
- if(angle > angle_left)
- {
- angle_left = angle;
- channel_left = j;
- }
- }
- else
- {
- if(angle < angle_right)
- {
- angle_right = angle;
- channel_right = j;
- }
- }
- }
-
- angle = angle_right - angle_left;
- if(channel_right == -1 || angle == 0)
- {
- m_mapping[channel_left * m_source_channels + i] = 1;
- }
- else if(channel_left == -1)
- {
- m_mapping[channel_right * m_source_channels + i] = 1;
- }
- else
- {
- m_mapping[channel_left * m_source_channels + i] = cos(M_PI_2 * angle_left / angle);
- m_mapping[channel_right * m_source_channels + i] = cos(M_PI_2 * angle_right / angle);
- }
- }
-
- /* AUD_XXX for(int i = 0; i < m_source_channels; i++)
- {
- for(int j = 0; j < m_target_channels; j++)
- {
- std::cout << m_mapping[i * m_source_channels + j] << " ";
- }
- std::cout << std::endl;
- }*/
-}
-
-AUD_Specs AUD_ChannelMapperReader::getSpecs() const
-{
- AUD_Specs specs = m_reader->getSpecs();
- specs.channels = m_target_channels;
- return specs;
-}
-
-void AUD_ChannelMapperReader::read(int& length, bool& eos, sample_t* buffer)
-{
- AUD_Channels channels = m_reader->getSpecs().channels;
- if(channels != m_source_channels)
- {
- m_source_channels = channels;
- calculateMapping();
- }
-
- if(m_source_channels == m_target_channels)
- {
- m_reader->read(length, eos, buffer);
- return;
- }
-
- m_buffer.assureSize(length * channels * sizeof(sample_t));
-
- sample_t* in = m_buffer.getBuffer();
-
- m_reader->read(length, eos, in);
-
- sample_t sum;
-
- for(int i = 0; i < length; i++)
- {
- for(int j = 0; j < m_target_channels; j++)
- {
- sum = 0;
- for(int k = 0; k < m_source_channels; k++)
- sum += m_mapping[j * m_source_channels + k] * in[i * m_source_channels + k];
- buffer[i * m_target_channels + j] = sum;
- }
- }
-}
-
-const AUD_Channel AUD_ChannelMapperReader::MONO_MAP[] =
-{
- AUD_CHANNEL_FRONT_CENTER
-};
-
-const AUD_Channel AUD_ChannelMapperReader::STEREO_MAP[] =
-{
- AUD_CHANNEL_FRONT_LEFT,
- AUD_CHANNEL_FRONT_RIGHT
-};
-
-const AUD_Channel AUD_ChannelMapperReader::STEREO_LFE_MAP[] =
-{
- AUD_CHANNEL_FRONT_LEFT,
- AUD_CHANNEL_FRONT_RIGHT,
- AUD_CHANNEL_LFE
-};
-
-const AUD_Channel AUD_ChannelMapperReader::SURROUND4_MAP[] =
-{
- AUD_CHANNEL_FRONT_LEFT,
- AUD_CHANNEL_FRONT_RIGHT,
- AUD_CHANNEL_REAR_LEFT,
- AUD_CHANNEL_REAR_RIGHT
-};
-
-const AUD_Channel AUD_ChannelMapperReader::SURROUND5_MAP[] =
-{
- AUD_CHANNEL_FRONT_LEFT,
- AUD_CHANNEL_FRONT_RIGHT,
- AUD_CHANNEL_FRONT_CENTER,
- AUD_CHANNEL_REAR_LEFT,
- AUD_CHANNEL_REAR_RIGHT
-};
-
-const AUD_Channel AUD_ChannelMapperReader::SURROUND51_MAP[] =
-{
- AUD_CHANNEL_FRONT_LEFT,
- AUD_CHANNEL_FRONT_RIGHT,
- AUD_CHANNEL_FRONT_CENTER,
- AUD_CHANNEL_LFE,
- AUD_CHANNEL_REAR_LEFT,
- AUD_CHANNEL_REAR_RIGHT
-};
-
-const AUD_Channel AUD_ChannelMapperReader::SURROUND61_MAP[] =
-{
- AUD_CHANNEL_FRONT_LEFT,
- AUD_CHANNEL_FRONT_RIGHT,
- AUD_CHANNEL_FRONT_CENTER,
- AUD_CHANNEL_LFE,
- AUD_CHANNEL_REAR_CENTER,
- AUD_CHANNEL_REAR_LEFT,
- AUD_CHANNEL_REAR_RIGHT
-};
-
-const AUD_Channel AUD_ChannelMapperReader::SURROUND71_MAP[] =
-{
- AUD_CHANNEL_FRONT_LEFT,
- AUD_CHANNEL_FRONT_RIGHT,
- AUD_CHANNEL_FRONT_CENTER,
- AUD_CHANNEL_LFE,
- AUD_CHANNEL_REAR_LEFT,
- AUD_CHANNEL_REAR_RIGHT,
- AUD_CHANNEL_SIDE_LEFT,
- AUD_CHANNEL_SIDE_RIGHT
-};
-
-const AUD_Channel* AUD_ChannelMapperReader::CHANNEL_MAPS[] =
-{
- AUD_ChannelMapperReader::MONO_MAP,
- AUD_ChannelMapperReader::STEREO_MAP,
- AUD_ChannelMapperReader::STEREO_LFE_MAP,
- AUD_ChannelMapperReader::SURROUND4_MAP,
- AUD_ChannelMapperReader::SURROUND5_MAP,
- AUD_ChannelMapperReader::SURROUND51_MAP,
- AUD_ChannelMapperReader::SURROUND61_MAP,
- AUD_ChannelMapperReader::SURROUND71_MAP
-};
-
-const float AUD_ChannelMapperReader::MONO_ANGLES[] =
-{
- 0.0f * M_PI / 180.0f
-};
-
-const float AUD_ChannelMapperReader::STEREO_ANGLES[] =
-{
- -90.0f * M_PI / 180.0f,
- 90.0f * M_PI / 180.0f
-};
-
-const float AUD_ChannelMapperReader::STEREO_LFE_ANGLES[] =
-{
- -90.0f * M_PI / 180.0f,
- 90.0f * M_PI / 180.0f,
- 0.0f * M_PI / 180.0f
-};
-
-const float AUD_ChannelMapperReader::SURROUND4_ANGLES[] =
-{
- -45.0f * M_PI / 180.0f,
- 45.0f * M_PI / 180.0f,
- -135.0f * M_PI / 180.0f,
- 135.0f * M_PI / 180.0f
-};
-
-const float AUD_ChannelMapperReader::SURROUND5_ANGLES[] =
-{
- -30.0f * M_PI / 180.0f,
- 30.0f * M_PI / 180.0f,
- 0.0f * M_PI / 180.0f,
- -110.0f * M_PI / 180.0f,
- 110.0f * M_PI / 180.0f
-};
-
-const float AUD_ChannelMapperReader::SURROUND51_ANGLES[] =
-{
- -30.0f * M_PI / 180.0f,
- 30.0f * M_PI / 180.0f,
- 0.0f * M_PI / 180.0f,
- 0.0f * M_PI / 180.0f,
- -110.0f * M_PI / 180.0f,
- 110.0f * M_PI / 180.0f
-};
-
-const float AUD_ChannelMapperReader::SURROUND61_ANGLES[] =
-{
- -30.0f * M_PI / 180.0f,
- 30.0f * M_PI / 180.0f,
- 0.0f * M_PI / 180.0f,
- 0.0f * M_PI / 180.0f,
- 180.0f * M_PI / 180.0f,
- -110.0f * M_PI / 180.0f,
- 110.0f * M_PI / 180.0f
-};
-
-const float AUD_ChannelMapperReader::SURROUND71_ANGLES[] =
-{
- -30.0f * M_PI / 180.0f,
- 30.0f * M_PI / 180.0f,
- 0.0f * M_PI / 180.0f,
- 0.0f * M_PI / 180.0f,
- -110.0f * M_PI / 180.0f,
- 110.0f * M_PI / 180.0f,
- -150.0f * M_PI / 180.0f,
- 150.0f * M_PI / 180.0f
-};
-
-const float* AUD_ChannelMapperReader::CHANNEL_ANGLES[] =
-{
- AUD_ChannelMapperReader::MONO_ANGLES,
- AUD_ChannelMapperReader::STEREO_ANGLES,
- AUD_ChannelMapperReader::STEREO_LFE_ANGLES,
- AUD_ChannelMapperReader::SURROUND4_ANGLES,
- AUD_ChannelMapperReader::SURROUND5_ANGLES,
- AUD_ChannelMapperReader::SURROUND51_ANGLES,
- AUD_ChannelMapperReader::SURROUND61_ANGLES,
- AUD_ChannelMapperReader::SURROUND71_ANGLES
-};
diff --git a/intern/audaspace/intern/AUD_ChannelMapperReader.h b/intern/audaspace/intern/AUD_ChannelMapperReader.h
deleted file mode 100644
index b122b070d29..00000000000
--- a/intern/audaspace/intern/AUD_ChannelMapperReader.h
+++ /dev/null
@@ -1,136 +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_ChannelMapperReader.h
- * \ingroup audaspaceintern
- */
-
-
-#ifndef __AUD_CHANNELMAPPERREADER_H__
-#define __AUD_CHANNELMAPPERREADER_H__
-
-#include "AUD_EffectReader.h"
-#include "AUD_Buffer.h"
-
-/**
- * This class maps a sound source's channels to a specific output channel count.
- * \note The input sample format must be float.
- */
-class AUD_ChannelMapperReader : public AUD_EffectReader
-{
-private:
- /**
- * The sound reading buffer.
- */
- AUD_Buffer m_buffer;
-
- /**
- * The output specification.
- */
- AUD_Channels m_target_channels;
-
- /**
- * The channel count of the reader.
- */
- AUD_Channels m_source_channels;
-
- /**
- * The mapping specification.
- */
- float* m_mapping;
-
- /**
- * The size of the mapping.
- */
- int m_map_size;
-
- /**
- * The mono source angle.
- */
- float m_mono_angle;
-
- static const AUD_Channel MONO_MAP[];
- static const AUD_Channel STEREO_MAP[];
- static const AUD_Channel STEREO_LFE_MAP[];
- static const AUD_Channel SURROUND4_MAP[];
- static const AUD_Channel SURROUND5_MAP[];
- static const AUD_Channel SURROUND51_MAP[];
- static const AUD_Channel SURROUND61_MAP[];
- static const AUD_Channel SURROUND71_MAP[];
- static const AUD_Channel* CHANNEL_MAPS[];
-
- static const float MONO_ANGLES[];
- static const float STEREO_ANGLES[];
- static const float STEREO_LFE_ANGLES[];
- static const float SURROUND4_ANGLES[];
- static const float SURROUND5_ANGLES[];
- static const float SURROUND51_ANGLES[];
- static const float SURROUND61_ANGLES[];
- static const float SURROUND71_ANGLES[];
- static const float* CHANNEL_ANGLES[];
-
- // hide copy constructor and operator=
- AUD_ChannelMapperReader(const AUD_ChannelMapperReader&);
- AUD_ChannelMapperReader& operator=(const AUD_ChannelMapperReader&);
-
- /**
- * Calculates the mapping matrix.
- */
- void calculateMapping();
-
- /**
- * Calculates the distance between two angles.
- */
- float angleDistance(float alpha, float beta);
-
-public:
- /**
- * Creates a channel mapper reader.
- * \param reader The reader to map.
- * \param mapping The mapping specification as two dimensional float array.
- */
- AUD_ChannelMapperReader(boost::shared_ptr<AUD_IReader> reader, AUD_Channels channels);
-
- /**
- * Destroys the reader.
- */
- ~AUD_ChannelMapperReader();
-
- /**
- * Sets the requested channel output count.
- * \param channels The channel output count.
- */
- void setChannels(AUD_Channels channels);
-
- /**
- * Sets the angle for mono sources.
- * \param angle The angle for mono sources.
- */
- void setMonoAngle(float angle);
-
- virtual AUD_Specs getSpecs() const;
- virtual void read(int& length, bool& eos, sample_t* buffer);
-};
-
-#endif //__AUD_CHANNELMAPPERREADER_H__
diff --git a/intern/audaspace/intern/AUD_ConverterFactory.cpp b/intern/audaspace/intern/AUD_ConverterFactory.cpp
deleted file mode 100644
index 7cbf64f1697..00000000000
--- a/intern/audaspace/intern/AUD_ConverterFactory.cpp
+++ /dev/null
@@ -1,47 +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_ConverterFactory.cpp
- * \ingroup audaspaceintern
- */
-
-
-#include "AUD_ConverterFactory.h"
-#include "AUD_ConverterReader.h"
-
-AUD_ConverterFactory::AUD_ConverterFactory(boost::shared_ptr<AUD_IFactory> factory,
- AUD_DeviceSpecs specs) :
- AUD_MixerFactory(factory, specs)
-{
-}
-
-boost::shared_ptr<AUD_IReader> AUD_ConverterFactory::createReader()
-{
- boost::shared_ptr<AUD_IReader> reader = getReader();
-
- if(m_specs.format != AUD_FORMAT_FLOAT32)
- 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
deleted file mode 100644
index 2c9c82d235b..00000000000
--- a/intern/audaspace/intern/AUD_ConverterFactory.h
+++ /dev/null
@@ -1,57 +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_ConverterFactory.h
- * \ingroup audaspaceintern
- */
-
-
-#ifndef __AUD_CONVERTERFACTORY_H__
-#define __AUD_CONVERTERFACTORY_H__
-
-#include "AUD_MixerFactory.h"
-
-/**
- * This factory creates a converter reader that is able to convert from one
- * audio format to another.
- */
-class AUD_ConverterFactory : public AUD_MixerFactory
-{
-private:
- // hide copy constructor and operator=
- AUD_ConverterFactory(const AUD_ConverterFactory&);
- AUD_ConverterFactory& operator=(const AUD_ConverterFactory&);
-
-public:
- /**
- * Creates a new factory.
- * \param factory The input factory.
- * \param specs The target specifications.
- */
- AUD_ConverterFactory(boost::shared_ptr<AUD_IFactory> factory, AUD_DeviceSpecs specs);
-
- virtual boost::shared_ptr<AUD_IReader> createReader();
-};
-
-#endif //__AUD_CONVERTERFACTORY_H__
diff --git a/intern/audaspace/intern/AUD_ConverterFunctions.cpp b/intern/audaspace/intern/AUD_ConverterFunctions.cpp
deleted file mode 100644
index c20f19a7e67..00000000000
--- a/intern/audaspace/intern/AUD_ConverterFunctions.cpp
+++ /dev/null
@@ -1,472 +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_ConverterFunctions.cpp
- * \ingroup audaspaceintern
- */
-
-
-#include "AUD_ConverterFunctions.h"
-#include "AUD_Buffer.h"
-
-#define AUD_U8_0 0x80
-#define AUD_S16_MAX ((int16_t)0x7FFF)
-#define AUD_S16_MIN ((int16_t)0x8000)
-#define AUD_S16_FLT 32767.0f
-#define AUD_S32_MAX ((int32_t)0x7FFFFFFF)
-#define AUD_S32_MIN ((int32_t)0x80000000)
-#define AUD_S32_FLT 2147483647.0f
-#define AUD_FLT_MAX 1.0f
-#define AUD_FLT_MIN -1.0f
-
-void AUD_convert_u8_s16(data_t* target, data_t* source, int length)
-{
- int16_t* t = (int16_t*) target;
- for(int i = length - 1; i >= 0; i--)
- t[i] = (((int16_t)source[i]) - AUD_U8_0) << 8;
-}
-
-void AUD_convert_u8_s24_be(data_t* target, data_t* source, int length)
-{
- for(int i = length - 1; i >= 0; i--)
- {
- target[i*3] = source[i] - AUD_U8_0;
- target[i*3+1] = 0;
- target[i*3+2] = 0;
- }
-}
-
-void AUD_convert_u8_s24_le(data_t* target, data_t* source, int length)
-{
- for(int i = length - 1; i >= 0; i--)
- {
- target[i*3+2] = source[i] - AUD_U8_0;
- target[i*3+1] = 0;
- target[i*3] = 0;
- }
-}
-
-void AUD_convert_u8_s32(data_t* target, data_t* source, int length)
-{
- int32_t* t = (int32_t*) target;
- for(int i = length - 1; i >= 0; i--)
- t[i] = (((int32_t)source[i]) - AUD_U8_0) << 24;
-}
-
-void AUD_convert_u8_float(data_t* target, data_t* source, int length)
-{
- float* t = (float*) target;
- for(int i = length - 1; i >= 0; i--)
- t[i] = (((int32_t)source[i]) - AUD_U8_0) / ((float)AUD_U8_0);
-}
-
-void AUD_convert_u8_double(data_t* target, data_t* source, int length)
-{
- double* t = (double*) target;
- for(int i = length - 1; i >= 0; i--)
- t[i] = (((int32_t)source[i]) - AUD_U8_0) / ((double)AUD_U8_0);
-}
-
-void AUD_convert_s16_u8(data_t* target, data_t* source, int length)
-{
- int16_t* s = (int16_t*) source;
- for(int i = 0; i < length; i++)
- target[i] = (unsigned char)((s[i] >> 8) + AUD_U8_0);
-}
-
-void AUD_convert_s16_s24_be(data_t* target, data_t* source, int length)
-{
- int16_t* s = (int16_t*) source;
- int16_t t;
- for(int i = length - 1; i >= 0; i--)
- {
- t = s[i];
- target[i*3] = t >> 8 & 0xFF;
- target[i*3+1] = t & 0xFF;
- target[i*3+2] = 0;
- }
-}
-
-void AUD_convert_s16_s24_le(data_t* target, data_t* source, int length)
-{
- int16_t* s = (int16_t*) source;
- int16_t t;
- for(int i = length - 1; i >= 0; i--)
- {
- t = s[i];
- target[i*3+2] = t >> 8 & 0xFF;
- target[i*3+1] = t & 0xFF;
- target[i*3] = 0;
- }
-}
-
-void AUD_convert_s16_s32(data_t* target, data_t* source, int length)
-{
- int16_t* s = (int16_t*) source;
- int32_t* t = (int32_t*) target;
- for(int i = length - 1; i >= 0; i--)
- t[i] = ((int32_t)s[i]) << 16;
-}
-
-void AUD_convert_s16_float(data_t* target, data_t* source, int length)
-{
- int16_t* s = (int16_t*) source;
- float* t = (float*) target;
- for(int i = length - 1; i >= 0; i--)
- t[i] = s[i] / AUD_S16_FLT;
-}
-
-void AUD_convert_s16_double(data_t* target, data_t* source, int length)
-{
- int16_t* s = (int16_t*) source;
- double* t = (double*) target;
- for(int i = length - 1; i >= 0; i--)
- t[i] = s[i] / AUD_S16_FLT;
-}
-
-void AUD_convert_s24_u8_be(data_t* target, data_t* source, int length)
-{
- for(int i = 0; i < length; i++)
- target[i] = source[i*3] ^ AUD_U8_0;
-}
-
-void AUD_convert_s24_u8_le(data_t* target, data_t* source, int length)
-{
- for(int i = 0; i < length; i++)
- target[i] = source[i*3+2] ^ AUD_U8_0;
-}
-
-void AUD_convert_s24_s16_be(data_t* target, data_t* source, int length)
-{
- int16_t* t = (int16_t*) target;
- for(int i = 0; i < length; i++)
- t[i] = source[i*3] << 8 | source[i*3+1];
-}
-
-void AUD_convert_s24_s16_le(data_t* target, data_t* source, int length)
-{
- int16_t* t = (int16_t*) target;
- for(int i = 0; i < length; i++)
- t[i] = source[i*3+2] << 8 | source[i*3+1];
-}
-
-void AUD_convert_s24_s24(data_t* target, data_t* source, int length)
-{
- memcpy(target, source, length * 3);
-}
-
-void AUD_convert_s24_s32_be(data_t* target, data_t* source, int length)
-{
- int32_t* t = (int32_t*) target;
- for(int i = length - 1; i >= 0; i--)
- t[i] = source[i*3] << 24 | source[i*3+1] << 16 | source[i*3+2] << 8;
-}
-
-void AUD_convert_s24_s32_le(data_t* target, data_t* source, int length)
-{
- int32_t* t = (int32_t*) target;
- for(int i = length - 1; i >= 0; i--)
- t[i] = source[i*3+2] << 24 | source[i*3+1] << 16 | source[i*3] << 8;
-}
-
-void AUD_convert_s24_float_be(data_t* target, data_t* source, int length)
-{
- float* t = (float*) target;
- int32_t s;
- for(int i = length - 1; i >= 0; i--)
- {
- s = source[i*3] << 24 | source[i*3+1] << 16 | source[i*3+2] << 8;
- t[i] = s / AUD_S32_FLT;
- }
-}
-
-void AUD_convert_s24_float_le(data_t* target, data_t* source, int length)
-{
- float* t = (float*) target;
- int32_t s;
- for(int i = length - 1; i >= 0; i--)
- {
- s = source[i*3+2] << 24 | source[i*3+1] << 16 | source[i*3] << 8;
- t[i] = s / AUD_S32_FLT;
- }
-}
-
-void AUD_convert_s24_double_be(data_t* target, data_t* source, int length)
-{
- double* t = (double*) target;
- int32_t s;
- for(int i = length - 1; i >= 0; i--)
- {
- s = source[i*3] << 24 | source[i*3+1] << 16 | source[i*3+2] << 8;
- t[i] = s / AUD_S32_FLT;
- }
-}
-
-void AUD_convert_s24_double_le(data_t* target, data_t* source, int length)
-{
- double* t = (double*) target;
- int32_t s;
- for(int i = length - 1; i >= 0; i--)
- {
- s = source[i*3+2] << 24 | source[i*3+1] << 16 | source[i*3] << 8;
- t[i] = s / AUD_S32_FLT;
- }
-}
-
-void AUD_convert_s32_u8(data_t* target, data_t* source, int length)
-{
- int16_t* s = (int16_t*) source;
- for(int i = 0; i < length; i++)
- target[i] = (unsigned char)((s[i] >> 24) + AUD_U8_0);
-}
-
-void AUD_convert_s32_s16(data_t* target, data_t* source, int length)
-{
- int16_t* t = (int16_t*) target;
- int32_t* s = (int32_t*) source;
- for(int i = 0; i < length; i++)
- t[i] = s[i] >> 16;
-}
-
-void AUD_convert_s32_s24_be(data_t* target, data_t* source, int length)
-{
- int32_t* s = (int32_t*) source;
- int32_t t;
- for(int i = 0; i < length; i++)
- {
- t = s[i];
- target[i*3] = t >> 24 & 0xFF;
- target[i*3+1] = t >> 16 & 0xFF;
- target[i*3+2] = t >> 8 & 0xFF;
- }
-}
-
-void AUD_convert_s32_s24_le(data_t* target, data_t* source, int length)
-{
- int32_t* s = (int32_t*) source;
- int32_t t;
- for(int i = 0; i < length; i++)
- {
- t = s[i];
- target[i*3+2] = t >> 24 & 0xFF;
- target[i*3+1] = t >> 16 & 0xFF;
- target[i*3] = t >> 8 & 0xFF;
- }
-}
-
-void AUD_convert_s32_float(data_t* target, data_t* source, int length)
-{
- int32_t* s = (int32_t*) source;
- float* t = (float*) target;
- for(int i = 0; i < length; i++)
- t[i] = s[i] / AUD_S32_FLT;
-}
-
-void AUD_convert_s32_double(data_t* target, data_t* source, int length)
-{
- int32_t* s = (int32_t*) source;
- double* t = (double*) target;
- for(int i = length - 1; i >= 0; i--)
- t[i] = s[i] / AUD_S32_FLT;
-}
-
-void AUD_convert_float_u8(data_t* target, data_t* source, int length)
-{
- float* s = (float*) source;
- float t;
- for(int i = 0; i < length; i++)
- {
- t = s[i] + AUD_FLT_MAX;
- if(t <= 0.0f)
- target[i] = 0;
- else if(t >= 2.0f)
- target[i] = 255;
- else
- target[i] = (unsigned char)(t*127);
- }
-}
-
-void AUD_convert_float_s16(data_t* target, data_t* source, int length)
-{
- int16_t* t = (int16_t*) target;
- float* s = (float*) source;
- for(int i = 0; i < length; i++)
- {
- if(s[i] <= AUD_FLT_MIN)
- t[i] = AUD_S16_MIN;
- else if(s[i] >= AUD_FLT_MAX)
- t[i] = AUD_S16_MAX;
- else
- t[i] = (int16_t)(s[i] * AUD_S16_MAX);
- }
-}
-
-void AUD_convert_float_s24_be(data_t* target, data_t* source, int length)
-{
- int32_t t;
- float* s = (float*) source;
- for(int i = 0; i < length; i++)
- {
- if(s[i] <= AUD_FLT_MIN)
- t = AUD_S32_MIN;
- else if(s[i] >= AUD_FLT_MAX)
- t = AUD_S32_MAX;
- else
- t = (int32_t)(s[i]*AUD_S32_MAX);
- target[i*3] = t >> 24 & 0xFF;
- target[i*3+1] = t >> 16 & 0xFF;
- target[i*3+2] = t >> 8 & 0xFF;
- }
-}
-
-void AUD_convert_float_s24_le(data_t* target, data_t* source, int length)
-{
- int32_t t;
- float* s = (float*) source;
- for(int i = 0; i < length; i++)
- {
- if(s[i] <= AUD_FLT_MIN)
- t = AUD_S32_MIN;
- else if(s[i] >= AUD_FLT_MAX)
- t = AUD_S32_MAX;
- else
- t = (int32_t)(s[i]*AUD_S32_MAX);
- target[i*3+2] = t >> 24 & 0xFF;
- target[i*3+1] = t >> 16 & 0xFF;
- target[i*3] = t >> 8 & 0xFF;
- }
-}
-
-void AUD_convert_float_s32(data_t* target, data_t* source, int length)
-{
- int32_t* t = (int32_t*) target;
- float* s = (float*) source;
- for(int i = 0; i < length; i++)
- {
- if(s[i] <= AUD_FLT_MIN)
- t[i] = AUD_S32_MIN;
- else if(s[i] >= AUD_FLT_MAX)
- t[i] = AUD_S32_MAX;
- else
- t[i] = (int32_t)(s[i]*AUD_S32_MAX);
- }
-}
-
-void AUD_convert_float_double(data_t* target, data_t* source, int length)
-{
- float* s = (float*) source;
- double* t = (double*) target;
- for(int i = length - 1; i >= 0; i--)
- t[i] = s[i];
-}
-
-void AUD_convert_double_u8(data_t* target, data_t* source, int length)
-{
- double* s = (double*) source;
- double t;
- for(int i = 0; i < length; i++)
- {
- t = s[i] + AUD_FLT_MAX;
- if(t <= 0.0)
- target[i] = 0;
- else if(t >= 2.0)
- target[i] = 255;
- else
- target[i] = (unsigned char)(t*127);
- }
-}
-
-void AUD_convert_double_s16(data_t* target, data_t* source, int length)
-{
- int16_t* t = (int16_t*) target;
- double* s = (double*) source;
- for(int i = 0; i < length; i++)
- {
- if(s[i] <= AUD_FLT_MIN)
- t[i] = AUD_S16_MIN;
- else if(s[i] >= AUD_FLT_MAX)
- t[i] = AUD_S16_MAX;
- else
- t[i] = (int16_t)(s[i]*AUD_S16_MAX);
- }
-}
-
-void AUD_convert_double_s24_be(data_t* target, data_t* source, int length)
-{
- int32_t t;
- double* s = (double*) source;
- for(int i = 0; i < length; i++)
- {
- if(s[i] <= AUD_FLT_MIN)
- t = AUD_S32_MIN;
- else if(s[i] >= AUD_FLT_MAX)
- t = AUD_S32_MAX;
- else
- t = (int32_t)(s[i]*AUD_S32_MAX);
- target[i*3] = t >> 24 & 0xFF;
- target[i*3+1] = t >> 16 & 0xFF;
- target[i*3+2] = t >> 8 & 0xFF;
- }
-}
-
-void AUD_convert_double_s24_le(data_t* target, data_t* source, int length)
-{
- int32_t t;
- double* s = (double*) source;
- for(int i = 0; i < length; i++)
- {
- if(s[i] <= AUD_FLT_MIN)
- t = AUD_S32_MIN;
- else if(s[i] >= AUD_FLT_MAX)
- t = AUD_S32_MAX;
- else
- t = (int32_t)(s[i]*AUD_S32_MAX);
- target[i*3+2] = t >> 24 & 0xFF;
- target[i*3+1] = t >> 16 & 0xFF;
- target[i*3] = t >> 8 & 0xFF;
- }
-}
-
-void AUD_convert_double_s32(data_t* target, data_t* source, int length)
-{
- int32_t* t = (int32_t*) target;
- double* s = (double*) source;
- for(int i = 0; i < length; i++)
- {
- if(s[i] <= AUD_FLT_MIN)
- t[i] = AUD_S32_MIN;
- else if(s[i] >= AUD_FLT_MAX)
- t[i] = AUD_S32_MAX;
- else
- t[i] = (int32_t)(s[i]*AUD_S32_MAX);
- }
-}
-
-void AUD_convert_double_float(data_t* target, data_t* source, int length)
-{
- double* s = (double*) source;
- float* t = (float*) target;
- for(int i = 0; i < length; i++)
- t[i] = s[i];
-}
diff --git a/intern/audaspace/intern/AUD_ConverterFunctions.h b/intern/audaspace/intern/AUD_ConverterFunctions.h
deleted file mode 100644
index eca2b327b8c..00000000000
--- a/intern/audaspace/intern/AUD_ConverterFunctions.h
+++ /dev/null
@@ -1,128 +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_ConverterFunctions.h
- * \ingroup audaspaceintern
- */
-
-
-#ifndef __AUD_CONVERTERFUNCTIONS_H__
-#define __AUD_CONVERTERFUNCTIONS_H__
-
-#include "AUD_Space.h"
-
-#include <cstring>
-#include <stdint.h>
-
-typedef void (*AUD_convert_f)(data_t* target, data_t* source, int length);
-
-template <class T>
-void AUD_convert_copy(data_t* target, data_t* source, int length)
-{
- memcpy(target, source, length*sizeof(T));
-}
-
-void AUD_convert_u8_s16(data_t* target, data_t* source, int length);
-
-void AUD_convert_u8_s24_be(data_t* target, data_t* source, int length);
-
-void AUD_convert_u8_s24_le(data_t* target, data_t* source, int length);
-
-void AUD_convert_u8_s32(data_t* target, data_t* source, int length);
-
-void AUD_convert_u8_float(data_t* target, data_t* source, int length);
-
-void AUD_convert_u8_double(data_t* target, data_t* source, int length);
-
-void AUD_convert_s16_u8(data_t* target, data_t* source, int length);
-
-void AUD_convert_s16_s24_be(data_t* target, data_t* source, int length);
-
-void AUD_convert_s16_s24_le(data_t* target, data_t* source, int length);
-
-void AUD_convert_s16_s32(data_t* target, data_t* source, int length);
-
-void AUD_convert_s16_float(data_t* target, data_t* source, int length);
-
-void AUD_convert_s16_double(data_t* target, data_t* source, int length);
-
-void AUD_convert_s24_u8_be(data_t* target, data_t* source, int length);
-
-void AUD_convert_s24_u8_le(data_t* target, data_t* source, int length);
-
-void AUD_convert_s24_s16_be(data_t* target, data_t* source, int length);
-
-void AUD_convert_s24_s16_le(data_t* target, data_t* source, int length);
-
-void AUD_convert_s24_s24(data_t* target, data_t* source, int length);
-
-void AUD_convert_s24_s32_be(data_t* target, data_t* source, int length);
-
-void AUD_convert_s24_s32_le(data_t* target, data_t* source, int length);
-
-void AUD_convert_s24_float_be(data_t* target, data_t* source, int length);
-
-void AUD_convert_s24_float_le(data_t* target, data_t* source, int length);
-
-void AUD_convert_s24_double_be(data_t* target, data_t* source, int length);
-
-void AUD_convert_s24_double_le(data_t* target, data_t* source, int length);
-
-void AUD_convert_s32_u8(data_t* target, data_t* source, int length);
-
-void AUD_convert_s32_s16(data_t* target, data_t* source, int length);
-
-void AUD_convert_s32_s24_be(data_t* target, data_t* source, int length);
-
-void AUD_convert_s32_s24_le(data_t* target, data_t* source, int length);
-
-void AUD_convert_s32_float(data_t* target, data_t* source, int length);
-
-void AUD_convert_s32_double(data_t* target, data_t* source, int length);
-
-void AUD_convert_float_u8(data_t* target, data_t* source, int length);
-
-void AUD_convert_float_s16(data_t* target, data_t* source, int length);
-
-void AUD_convert_float_s24_be(data_t* target, data_t* source, int length);
-
-void AUD_convert_float_s24_le(data_t* target, data_t* source, int length);
-
-void AUD_convert_float_s32(data_t* target, data_t* source, int length);
-
-void AUD_convert_float_double(data_t* target, data_t* source, int length);
-
-void AUD_convert_double_u8(data_t* target, data_t* source, int length);
-
-void AUD_convert_double_s16(data_t* target, data_t* source, int length);
-
-void AUD_convert_double_s24_be(data_t* target, data_t* source, int length);
-
-void AUD_convert_double_s24_le(data_t* target, data_t* source, int length);
-
-void AUD_convert_double_s32(data_t* target, data_t* source, int length);
-
-void AUD_convert_double_float(data_t* target, data_t* source, int length);
-
-#endif //__AUD_CONVERTERFUNCTIONS_H__
diff --git a/intern/audaspace/intern/AUD_ConverterReader.cpp b/intern/audaspace/intern/AUD_ConverterReader.cpp
deleted file mode 100644
index a90a54670e8..00000000000
--- a/intern/audaspace/intern/AUD_ConverterReader.cpp
+++ /dev/null
@@ -1,77 +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_ConverterReader.cpp
- * \ingroup audaspaceintern
- */
-
-
-#include "AUD_ConverterReader.h"
-
-AUD_ConverterReader::AUD_ConverterReader(boost::shared_ptr<AUD_IReader> reader,
- AUD_DeviceSpecs specs) :
- AUD_EffectReader(reader),
- m_format(specs.format)
-{
- switch(m_format)
- {
- case AUD_FORMAT_U8:
- m_convert = AUD_convert_float_u8;
- break;
- case AUD_FORMAT_S16:
- m_convert = AUD_convert_float_s16;
- break;
- case AUD_FORMAT_S24:
-#ifdef __BIG_ENDIAN__
- m_convert = AUD_convert_float_s24_be;
-#else
- m_convert = AUD_convert_float_s24_le;
-#endif
- break;
- case AUD_FORMAT_S32:
- m_convert = AUD_convert_float_s32;
- break;
- case AUD_FORMAT_FLOAT32:
- m_convert = AUD_convert_copy<float>;
- break;
- case AUD_FORMAT_FLOAT64:
- m_convert = AUD_convert_float_double;
- break;
- default:
- break;
- }
-}
-
-void AUD_ConverterReader::read(int& length, bool& eos, sample_t* buffer)
-{
- AUD_Specs specs = m_reader->getSpecs();
- int samplesize = AUD_SAMPLE_SIZE(specs);
-
- m_buffer.assureSize(length * samplesize);
-
- m_reader->read(length, eos, m_buffer.getBuffer());
-
- m_convert((data_t*)buffer, (data_t*)m_buffer.getBuffer(),
- length * specs.channels);
-}
diff --git a/intern/audaspace/intern/AUD_ConverterReader.h b/intern/audaspace/intern/AUD_ConverterReader.h
deleted file mode 100644
index 987b7c70279..00000000000
--- a/intern/audaspace/intern/AUD_ConverterReader.h
+++ /dev/null
@@ -1,73 +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_ConverterReader.h
- * \ingroup audaspaceintern
- */
-
-
-#ifndef __AUD_CONVERTERREADER_H__
-#define __AUD_CONVERTERREADER_H__
-
-#include "AUD_EffectReader.h"
-#include "AUD_ConverterFunctions.h"
-#include "AUD_Buffer.h"
-
-/**
- * This class converts a sound source from one to another format.
- */
-class AUD_ConverterReader : public AUD_EffectReader
-{
-private:
- /**
- * The sound output buffer.
- */
- AUD_Buffer m_buffer;
-
- /**
- * The target specification.
- */
- AUD_SampleFormat m_format;
-
- /**
- * Converter function.
- */
- AUD_convert_f m_convert;
-
- // hide copy constructor and operator=
- AUD_ConverterReader(const AUD_ConverterReader&);
- AUD_ConverterReader& operator=(const AUD_ConverterReader&);
-
-public:
- /**
- * Creates a converter reader.
- * \param reader The reader to convert.
- * \param specs The target specification.
- */
- AUD_ConverterReader(boost::shared_ptr<AUD_IReader> reader, AUD_DeviceSpecs specs);
-
- virtual void read(int& length, bool& eos, sample_t* buffer);
-};
-
-#endif //__AUD_CONVERTERREADER_H__
diff --git a/intern/audaspace/intern/AUD_FileFactory.cpp b/intern/audaspace/intern/AUD_FileFactory.cpp
deleted file mode 100644
index f9353db6677..00000000000
--- a/intern/audaspace/intern/AUD_FileFactory.cpp
+++ /dev/null
@@ -1,84 +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_FileFactory.cpp
- * \ingroup audaspaceintern
- */
-
-
-#ifdef WITH_FFMPEG
-// needed for INT64_C
-#ifndef __STDC_CONSTANT_MACROS
-#define __STDC_CONSTANT_MACROS
-#endif
-#include "AUD_FFMPEGReader.h"
-#endif
-
-#include "AUD_FileFactory.h"
-
-#include <cstring>
-
-#ifdef WITH_SNDFILE
-#include "AUD_SndFileReader.h"
-#endif
-
-AUD_FileFactory::AUD_FileFactory(std::string filename) :
- m_filename(filename)
-{
-}
-
-AUD_FileFactory::AUD_FileFactory(const data_t* buffer, int size) :
- m_buffer(new AUD_Buffer(size))
-{
- memcpy(m_buffer->getBuffer(), buffer, size);
-}
-
-static const char* read_error = "AUD_FileFactory: File couldn't be read.";
-
-boost::shared_ptr<AUD_IReader> AUD_FileFactory::createReader()
-{
-#ifdef WITH_SNDFILE
- try
- {
- if(m_buffer.get())
- return boost::shared_ptr<AUD_IReader>(new AUD_SndFileReader(m_buffer));
- else
- return boost::shared_ptr<AUD_IReader>(new AUD_SndFileReader(m_filename));
- }
- catch(AUD_Exception&) {}
-#endif
-
-#ifdef WITH_FFMPEG
- try
- {
- if(m_buffer.get())
- return boost::shared_ptr<AUD_IReader>(new AUD_FFMPEGReader(m_buffer));
- else
- return boost::shared_ptr<AUD_IReader>(new AUD_FFMPEGReader(m_filename));
- }
- catch(AUD_Exception&) {}
-#endif
-
- AUD_THROW(AUD_ERROR_FILE, read_error);
-}
diff --git a/intern/audaspace/intern/AUD_FileFactory.h b/intern/audaspace/intern/AUD_FileFactory.h
deleted file mode 100644
index 35c8db731b4..00000000000
--- a/intern/audaspace/intern/AUD_FileFactory.h
+++ /dev/null
@@ -1,76 +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_FileFactory.h
- * \ingroup audaspaceintern
- */
-
-
-#ifndef __AUD_FILEFACTORY_H__
-#define __AUD_FILEFACTORY_H__
-
-#include "AUD_IFactory.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.
- */
-class AUD_FileFactory : public AUD_IFactory
-{
-private:
- /**
- * The filename of the sound source file.
- */
- std::string m_filename;
-
- /**
- * The buffer to read from.
- */
- boost::shared_ptr<AUD_Buffer> m_buffer;
-
- // hide copy constructor and operator=
- AUD_FileFactory(const AUD_FileFactory&);
- AUD_FileFactory& operator=(const AUD_FileFactory&);
-
-public:
- /**
- * Creates a new factory.
- * \param filename The sound file path.
- */
- AUD_FileFactory(std::string filename);
-
- /**
- * Creates a new factory.
- * \param buffer The buffer to read from.
- * \param size The size of the buffer.
- */
- AUD_FileFactory(const data_t* buffer, int size);
-
- 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
deleted file mode 100644
index e3072fa82e0..00000000000
--- a/intern/audaspace/intern/AUD_FileWriter.cpp
+++ /dev/null
@@ -1,131 +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_FileWriter.cpp
- * \ingroup audaspaceintern
- */
-
-#ifdef WITH_FFMPEG
-// needed for INT64_C
-#ifndef __STDC_CONSTANT_MACROS
-#define __STDC_CONSTANT_MACROS
-#endif
-#include "AUD_FFMPEGWriter.h"
-#endif
-
-#ifdef WITH_SNDFILE
-#include "AUD_SndFileWriter.h"
-#endif
-
-#include "AUD_FileWriter.h"
-#include "AUD_Buffer.h"
-
-static const char* write_error = "AUD_FileWriter: File couldn't be written.";
-
-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 boost::shared_ptr<AUD_IWriter>(new AUD_SndFileWriter(filename, specs, format, codec, bitrate));
- }
- catch(AUD_Exception&) {}
-#endif
-
-#ifdef WITH_FFMPEG
- try
- {
- return boost::shared_ptr<AUD_IWriter>(new AUD_FFMPEGWriter(filename, specs, format, codec, bitrate));
- }
- catch(AUD_Exception&) {}
-#endif
-
- AUD_THROW(AUD_ERROR_SPECS, write_error);
-}
-
-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();
-
- int len;
- bool eos = false;
- int channels = writer->getSpecs().channels;
-
- for(unsigned int pos = 0; ((pos < length) || (length <= 0)) && !eos; pos += len)
- {
- len = buffersize;
- if((len > length - pos) && (length > 0))
- len = length - pos;
- reader->read(len, eos, buf);
-
- for(int i = 0; i < len * channels; i++)
- {
- // clamping!
- if(buf[i] > 1)
- buf[i] = 1;
- else if(buf[i] < -1)
- buf[i] = -1;
- }
-
- writer->write(len, buf);
- }
-}
-
-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));
- sample_t* buf = buffer.getBuffer();
- sample_t* buf2 = buffer2.getBuffer();
-
- int len;
- bool eos = false;
- int channels = reader->getSpecs().channels;
-
- for(unsigned int pos = 0; ((pos < length) || (length <= 0)) && !eos; pos += len)
- {
- len = buffersize;
- if((len > length - pos) && (length > 0))
- len = length - pos;
- reader->read(len, eos, buf);
-
- for(int channel = 0; channel < channels; channel++)
- {
- for(int i = 0; i < len; i++)
- {
- // clamping!
- if(buf[i * channels + channel] > 1)
- buf2[i] = 1;
- else if(buf[i * channels + channel] < -1)
- buf2[i] = -1;
- else
- buf2[i] = buf[i * channels + channel];
- }
-
- writers[channel]->write(len, buf2);
- }
- }
-}
diff --git a/intern/audaspace/intern/AUD_FileWriter.h b/intern/audaspace/intern/AUD_FileWriter.h
deleted file mode 100644
index 3291c1ad03a..00000000000
--- a/intern/audaspace/intern/AUD_FileWriter.h
+++ /dev/null
@@ -1,82 +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_FileWriter.h
- * \ingroup audaspaceintern
- */
-
-
-#ifndef __AUD_FILEWRITER_H__
-#define __AUD_FILEWRITER_H__
-
-#include <string>
-#include <vector>
-#include <boost/shared_ptr.hpp>
-
-#include "AUD_IWriter.h"
-#include "AUD_IReader.h"
-
-/**
- * This class is able to create IWriter classes as well as write reads to them.
- */
-class AUD_FileWriter
-{
-private:
- // hide default constructor, copy constructor and operator=
- AUD_FileWriter();
- AUD_FileWriter(const AUD_FileWriter&);
- AUD_FileWriter& operator=(const AUD_FileWriter&);
-
-public:
- /**
- * Creates a new IWriter.
- * \param filename The file to write to.
- * \param specs The file's audio specification.
- * \param format The file's container format.
- * \param codec The codec used for encoding the audio data.
- * \param bitrate The bitrate for encoding.
- * \return The writer to write data to.
- */
- 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.
- * \param reader The reader to read from.
- * \param writer The writer to write to.
- * \param length How many samples should be transferred.
- * \param buffersize How many samples should be transferred at once.
- */
- 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.
- * \param reader The reader to read from.
- * \param writers The writers to write to.
- * \param length How many samples should be transferred.
- * \param buffersize How many samples should be transferred at once.
- */
- 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_I3DDevice.h b/intern/audaspace/intern/AUD_I3DDevice.h
deleted file mode 100644
index 1df710b7e5b..00000000000
--- a/intern/audaspace/intern/AUD_I3DDevice.h
+++ /dev/null
@@ -1,122 +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_I3DDevice.h
- * \ingroup audaspaceintern
- */
-
-
-#ifndef __AUD_I3DDEVICE_H__
-#define __AUD_I3DDEVICE_H__
-
-#include "AUD_Space.h"
-#include "AUD_3DMath.h"
-
-/**
- * This class represents an output device for 3D sound.
- */
-class AUD_I3DDevice
-{
-public:
- /**
- * Retrieves the listener location.
- * \return The listener location.
- */
- virtual AUD_Vector3 getListenerLocation() const=0;
-
- /**
- * Sets the listener location.
- * \param location The new location.
- */
- virtual void setListenerLocation(const AUD_Vector3& location)=0;
-
- /**
- * Retrieves the listener velocity.
- * \return The listener velocity.
- */
- virtual AUD_Vector3 getListenerVelocity() const=0;
-
- /**
- * Sets the listener velocity.
- * \param velocity The new velocity.
- */
- virtual void setListenerVelocity(const AUD_Vector3& velocity)=0;
-
- /**
- * Retrieves the listener orientation.
- * \return The listener orientation as quaternion.
- */
- virtual AUD_Quaternion getListenerOrientation() const=0;
-
- /**
- * Sets the listener orientation.
- * \param orientation The new orientation as quaternion.
- */
- virtual void setListenerOrientation(const AUD_Quaternion& orientation)=0;
-
-
- /**
- * Retrieves the speed of sound.
- * This value is needed for doppler effect calculation.
- * \return The speed of sound.
- */
- virtual float getSpeedOfSound() const=0;
-
- /**
- * Sets the speed of sound.
- * This value is needed for doppler effect calculation.
- * \param speed The new speed of sound.
- */
- virtual void setSpeedOfSound(float speed)=0;
-
- /**
- * 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.
- */
- virtual float getDopplerFactor() const=0;
-
- /**
- * 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.
- */
- virtual void setDopplerFactor(float factor)=0;
-
- /**
- * Retrieves the distance model.
- * \return The distance model.
- */
- virtual AUD_DistanceModel getDistanceModel() const=0;
-
- /**
- * Sets the distance model.
- * \param model distance model.
- */
- virtual void setDistanceModel(AUD_DistanceModel model)=0;
-};
-
-#endif //__AUD_I3DDEVICE_H__
diff --git a/intern/audaspace/intern/AUD_IDevice.h b/intern/audaspace/intern/AUD_IDevice.h
deleted file mode 100644
index a7f9a985ce4..00000000000
--- a/intern/audaspace/intern/AUD_IDevice.h
+++ /dev/null
@@ -1,120 +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_IDevice.h
- * \ingroup audaspaceintern
- */
-
-
-#ifndef __AUD_IDEVICE_H__
-#define __AUD_IDEVICE_H__
-
-#include "AUD_Space.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
- * SDL or OpenAL or plattform specific like DirectSound, but they may also be
- * files, RAM buffers or other types of streams.
- * \warning Thread safety must be insured so that no reader is beeing called
- * twice at the same time.
- */
-class AUD_IDevice : public AUD_ILockable
-{
-public:
- /**
- * Destroys the device.
- */
- virtual ~AUD_IDevice() {}
-
- /**
- * Returns the specification of the device.
- */
- virtual AUD_DeviceSpecs getSpecs() const=0;
-
- /**
- * Plays a sound source.
- * \param reader The reader to play.
- * \param keep When keep is true the sound source will not be deleted but
- * set to paused when its end has been reached.
- * \return Returns a handle with which the playback can be controlled.
- * This is NULL if the sound couldn't be played back.
- * \exception AUD_Exception Thrown if there's an unexpected (from the
- * device side) error during creation of the reader.
- */
- virtual boost::shared_ptr<AUD_IHandle> play(boost::shared_ptr<AUD_IReader> reader, bool keep = false)=0;
-
- /**
- * Plays a sound source.
- * \param factory The factory to create the reader for the sound source.
- * \param keep When keep is true the sound source will not be deleted but
- * set to paused when its end has been reached.
- * \return Returns a handle with which the playback can be controlled.
- * This is NULL if the sound couldn't be played back.
- * \exception AUD_Exception Thrown if there's an unexpected (from the
- * device side) error during creation of the reader.
- */
- virtual boost::shared_ptr<AUD_IHandle> play(boost::shared_ptr<AUD_IFactory> factory, bool keep = false)=0;
-
- /**
- * Stops all playing sounds.
- */
- virtual void stopAll()=0;
-
- /**
- * Locks the device.
- * Used to make sure that between lock and unlock, no buffers are read, so
- * that it is possible to start, resume, pause, stop or seek several
- * playback handles simultaneously.
- * \warning Make sure the locking time is as small as possible to avoid
- * playback delays that result in unexpected noise and cracks.
- */
- virtual void lock()=0;
-
- /**
- * Unlocks the previously locked device.
- */
- virtual void unlock()=0;
-
- /**
- * Retrieves the overall device volume.
- * \return The overall device volume.
- */
- virtual float getVolume() const=0;
-
- /**
- * Sets the overall device volume.
- * \param handle The sound handle.
- * \param volume The overall device volume.
- */
- virtual void setVolume(float volume)=0;
-};
-
-#endif //AUD_IDevice
diff --git a/intern/audaspace/intern/AUD_IFactory.h b/intern/audaspace/intern/AUD_IFactory.h
deleted file mode 100644
index 75103963c68..00000000000
--- a/intern/audaspace/intern/AUD_IFactory.h
+++ /dev/null
@@ -1,61 +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_IFactory.h
- * \ingroup audaspaceintern
- */
-
-
-#ifndef __AUD_IFACTORY_H__
-#define __AUD_IFACTORY_H__
-
-#include "AUD_Space.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
- * of the respective sound source through the factory method createReader.
- */
-class AUD_IFactory
-{
-public:
- /**
- * Destroys the factory.
- */
- virtual ~AUD_IFactory() {}
-
- /**
- * Creates a reader for playback of the sound source.
- * \return A pointer to an AUD_IReader object or NULL if there has been an
- * error.
- * \exception AUD_Exception An exception may be thrown if there has been
- * a more unexpected error during reader creation.
- */
- virtual boost::shared_ptr<AUD_IReader> createReader()=0;
-};
-
-#endif //__AUD_IFACTORY_H__
diff --git a/intern/audaspace/intern/AUD_ILockable.h b/intern/audaspace/intern/AUD_ILockable.h
deleted file mode 100644
index 9bc417504fe..00000000000
--- a/intern/audaspace/intern/AUD_ILockable.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef AUD_ILOCKABLE_H
-#define AUD_ILOCKABLE_H
-
-/**
- * This class provides an interface for lockable objects.
- * The main reason for this interface is to be used with AUD_MutexLock.
- */
-class AUD_ILockable
-{
-public:
- /**
- * Locks the object.
- */
- virtual void lock()=0;
- /**
- * Unlocks the previously locked object.
- */
- virtual void unlock()=0;
-};
-
-#endif // AUD_ILOCKABLE_H
diff --git a/intern/audaspace/intern/AUD_IWriter.h b/intern/audaspace/intern/AUD_IWriter.h
deleted file mode 100644
index 5406577dd50..00000000000
--- a/intern/audaspace/intern/AUD_IWriter.h
+++ /dev/null
@@ -1,67 +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_IWriter.h
- * \ingroup audaspaceintern
- */
-
-
-#ifndef __AUD_IWRITER_H__
-#define __AUD_IWRITER_H__
-
-#include "AUD_Space.h"
-
-/**
- * This class represents a sound sink where audio data can be written to.
- */
-class AUD_IWriter
-{
-public:
- /**
- * Destroys the writer.
- */
- virtual ~AUD_IWriter() {}
-
- /**
- * Returns how many samples have been written so far.
- * \return The writing position as sample count. May be negative if unknown.
- */
- virtual int getPosition() const=0;
-
- /**
- * Returns the specification of the audio data being written into the sink.
- * \return The AUD_DeviceSpecs structure.
- * \note Regardless of the format the input still has to be float!
- */
- virtual AUD_DeviceSpecs getSpecs() const=0;
-
- /**
- * Request to write the next length samples out into the sink.
- * \param length The count of samples to write.
- * \param buffer The pointer to the buffer containing the data.
- */
- virtual void write(unsigned int length, sample_t* buffer)=0;
-};
-
-#endif //__AUD_IWRITER_H__
diff --git a/intern/audaspace/intern/AUD_JOSResampleFactory.cpp b/intern/audaspace/intern/AUD_JOSResampleFactory.cpp
deleted file mode 100644
index 188960f986f..00000000000
--- a/intern/audaspace/intern/AUD_JOSResampleFactory.cpp
+++ /dev/null
@@ -1,42 +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_JOSResampleFactory.cpp
- * \ingroup audaspaceintern
- */
-
-
-#include "AUD_JOSResampleFactory.h"
-#include "AUD_JOSResampleReader.h"
-
-AUD_JOSResampleFactory::AUD_JOSResampleFactory(boost::shared_ptr<AUD_IFactory> factory,
- AUD_DeviceSpecs specs) :
- AUD_MixerFactory(factory, specs)
-{
-}
-
-boost::shared_ptr<AUD_IReader> AUD_JOSResampleFactory::createReader()
-{
- 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
deleted file mode 100644
index b6c2961c88a..00000000000
--- a/intern/audaspace/intern/AUD_JOSResampleFactory.h
+++ /dev/null
@@ -1,56 +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_JOSResampleFactory.h
- * \ingroup audaspaceintern
- */
-
-
-#ifndef __AUD_JOSRESAMPLEFACTORY_H__
-#define __AUD_JOSRESAMPLEFACTORY_H__
-
-#include "AUD_MixerFactory.h"
-
-/**
- * This factory creates a resampling reader that does Julius O. Smith's resampling algorithm.
- */
-class AUD_JOSResampleFactory : public AUD_MixerFactory
-{
-private:
- // hide copy constructor and operator=
- AUD_JOSResampleFactory(const AUD_JOSResampleFactory&);
- AUD_JOSResampleFactory& operator=(const AUD_JOSResampleFactory&);
-
-public:
- /**
- * Creates a new factory.
- * \param factory The input factory.
- * \param specs The target specifications.
- */
- AUD_JOSResampleFactory(boost::shared_ptr<AUD_IFactory> factory, AUD_DeviceSpecs specs);
-
- virtual boost::shared_ptr<AUD_IReader> createReader();
-};
-
-#endif //__AUD_JOSRESAMPLEFACTORY_H__
diff --git a/intern/audaspace/intern/AUD_JOSResampleReader.h b/intern/audaspace/intern/AUD_JOSResampleReader.h
deleted file mode 100644
index fb68e4dc9f5..00000000000
--- a/intern/audaspace/intern/AUD_JOSResampleReader.h
+++ /dev/null
@@ -1,135 +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_JOSResampleReader.h
- * \ingroup audaspaceintern
- */
-
-
-#ifndef __AUD_JOSRESAMPLEREADER_H__
-#define __AUD_JOSRESAMPLEREADER_H__
-
-#include "AUD_ResampleReader.h"
-#include "AUD_Buffer.h"
-
-/**
- * This resampling reader uses Julius O. Smith's resampling algorithm.
- */
-class AUD_JOSResampleReader : public AUD_ResampleReader
-{
-private:
- typedef void (AUD_JOSResampleReader::*AUD_resample_f)(double target_factor, int length, sample_t* buffer);
-
- /**
- * The half filter length.
- */
- static const int m_len;
-
- /**
- * The sample step size for the filter.
- */
- static const int m_L;
-
- /**
- * The filter coefficients.
- */
- static const float m_coeff[];
-
- /**
- * The reader channels.
- */
- AUD_Channels m_channels;
-
- /**
- * The sample position in the cache.
- */
- unsigned int m_n;
-
- /**
- * The subsample position in the cache.
- */
- double m_P;
-
- /**
- * The input data buffer.
- */
- AUD_Buffer m_buffer;
-
- /**
- * Double buffer for the sums.
- */
- AUD_Buffer m_sums;
-
- /**
- * How many samples in the cache are valid.
- */
- int m_cache_valid;
-
- /**
- * Resample function.
- */
- AUD_resample_f m_resample;
-
- /**
- * Last resampling factor.
- */
- double m_last_factor;
-
- // hide copy constructor and operator=
- AUD_JOSResampleReader(const AUD_JOSResampleReader&);
- AUD_JOSResampleReader& operator=(const AUD_JOSResampleReader&);
-
- /**
- * Resets the resampler to its initial state.
- */
- void reset();
-
- /**
- * Updates the buffer to be as small as possible for the coming reading.
- * \param size The size of samples to be read.
- * \param factor The next resampling factor.
- * \param samplesize The size of a sample.
- */
- void updateBuffer(int size, double factor, int samplesize);
-
- void resample(double target_factor, int length, sample_t* buffer);
- void resample_mono(double target_factor, int length, sample_t* buffer);
- void resample_stereo(double target_factor, int length, sample_t* buffer);
-
-public:
- /**
- * Creates a resampling reader.
- * \param reader The reader to mix.
- * \param specs The target specification.
- */
- AUD_JOSResampleReader(boost::shared_ptr<AUD_IReader> reader, AUD_Specs specs);
-
- virtual void seek(int position);
- virtual int getLength() const;
- virtual int getPosition() const;
- virtual AUD_Specs getSpecs() const;
- virtual void read(int& length, bool& eos, sample_t* buffer);
-};
-
-#endif //__AUD_JOSRESAMPLEREADER_H__
diff --git a/intern/audaspace/intern/AUD_LinearResampleFactory.cpp b/intern/audaspace/intern/AUD_LinearResampleFactory.cpp
deleted file mode 100644
index cd573f1047c..00000000000
--- a/intern/audaspace/intern/AUD_LinearResampleFactory.cpp
+++ /dev/null
@@ -1,42 +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_LinearResampleFactory.cpp
- * \ingroup audaspaceintern
- */
-
-
-#include "AUD_LinearResampleFactory.h"
-#include "AUD_LinearResampleReader.h"
-
-AUD_LinearResampleFactory::AUD_LinearResampleFactory(boost::shared_ptr<AUD_IFactory> factory,
- AUD_DeviceSpecs specs) :
- AUD_MixerFactory(factory, specs)
-{
-}
-
-boost::shared_ptr<AUD_IReader> AUD_LinearResampleFactory::createReader()
-{
- 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
deleted file mode 100644
index ceb29ef2edd..00000000000
--- a/intern/audaspace/intern/AUD_LinearResampleFactory.h
+++ /dev/null
@@ -1,56 +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_LinearResampleFactory.h
- * \ingroup audaspaceintern
- */
-
-
-#ifndef __AUD_LINEARRESAMPLEFACTORY_H__
-#define __AUD_LINEARRESAMPLEFACTORY_H__
-
-#include "AUD_MixerFactory.h"
-
-/**
- * This factory creates a resampling reader that does simple linear resampling.
- */
-class AUD_LinearResampleFactory : public AUD_MixerFactory
-{
-private:
- // hide copy constructor and operator=
- AUD_LinearResampleFactory(const AUD_LinearResampleFactory&);
- AUD_LinearResampleFactory& operator=(const AUD_LinearResampleFactory&);
-
-public:
- /**
- * Creates a new factory.
- * \param factory The input factory.
- * \param specs The target specifications.
- */
- AUD_LinearResampleFactory(boost::shared_ptr<AUD_IFactory> factory, AUD_DeviceSpecs specs);
-
- 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
deleted file mode 100644
index b342b8f31fb..00000000000
--- a/intern/audaspace/intern/AUD_LinearResampleReader.cpp
+++ /dev/null
@@ -1,186 +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_LinearResampleReader.cpp
- * \ingroup audaspaceintern
- */
-
-
-#include "AUD_LinearResampleReader.h"
-
-#include <cmath>
-#include <cstring>
-
-#define CC m_channels + channel
-
-AUD_LinearResampleReader::AUD_LinearResampleReader(boost::shared_ptr<AUD_IReader> reader,
- AUD_Specs specs) :
- AUD_ResampleReader(reader, specs.rate),
- m_channels(reader->getSpecs().channels),
- m_cache_pos(0),
- m_cache_ok(false)
-{
- specs.channels = m_channels;
- m_cache.resize(2 * AUD_SAMPLE_SIZE(specs));
-}
-
-void AUD_LinearResampleReader::seek(int position)
-{
- position = floor(position * double(m_reader->getSpecs().rate) / double(m_rate));
- m_reader->seek(position);
- m_cache_ok = false;
- m_cache_pos = 0;
-}
-
-int AUD_LinearResampleReader::getLength() const
-{
- return floor(m_reader->getLength() * double(m_rate) / double(m_reader->getSpecs().rate));
-}
-
-int AUD_LinearResampleReader::getPosition() const
-{
- return floor((m_reader->getPosition() + (m_cache_ok ? m_cache_pos - 1 : 0))
- * m_rate / m_reader->getSpecs().rate);
-}
-
-AUD_Specs AUD_LinearResampleReader::getSpecs() const
-{
- AUD_Specs specs = m_reader->getSpecs();
- specs.rate = m_rate;
- return specs;
-}
-
-void AUD_LinearResampleReader::read(int& length, bool& eos, sample_t* buffer)
-{
- if(length == 0)
- return;
-
- AUD_Specs specs = m_reader->getSpecs();
-
- int samplesize = AUD_SAMPLE_SIZE(specs);
- int size = length;
- float factor = m_rate / m_reader->getSpecs().rate;
- float spos = 0.0f;
- sample_t low, high;
- eos = false;
-
- // check for channels changed
-
- if(specs.channels != m_channels)
- {
- m_cache.resize(2 * samplesize);
- m_channels = specs.channels;
- m_cache_ok = false;
- }
-
- if(factor == 1 && (!m_cache_ok || m_cache_pos == 1))
- {
- // can read directly!
- m_reader->read(length, eos, buffer);
-
- if(length > 0)
- {
- memcpy(m_cache.getBuffer() + m_channels, buffer + m_channels * (length - 1), samplesize);
- m_cache_pos = 1;
- m_cache_ok = true;
- }
-
- return;
- }
-
- int len;
- sample_t* buf;
-
- if(m_cache_ok)
- {
- int need = ceil(length / factor + m_cache_pos) - 1;
-
- len = need;
-
- m_buffer.assureSize((len + 2) * samplesize);
- buf = m_buffer.getBuffer();
-
- memcpy(buf, m_cache.getBuffer(), 2 * samplesize);
- m_reader->read(len, eos, buf + 2 * m_channels);
-
- if(len < need)
- length = floor((len + 1 - m_cache_pos) * factor);
- }
- else
- {
- m_cache_pos = 1 - 1 / factor;
-
- int need = ceil(length / factor + m_cache_pos);
-
- len = need;
-
- m_buffer.assureSize((len + 1) * samplesize);
- buf = m_buffer.getBuffer();
-
- memset(buf, 0, samplesize);
- m_reader->read(len, eos, buf + m_channels);
-
- if(len == 0)
- {
- length = 0;
- return;
- }
-
- if(len < need)
- {
- length = floor((len - m_cache_pos) * factor);
- }
-
- m_cache_ok = true;
- }
-
- if(length == 0)
- return;
-
- for(int channel = 0; channel < m_channels; channel++)
- {
- for(int i = 0; i < length; i++)
- {
- spos = (i + 1) / factor + m_cache_pos;
-
- low = buf[(int)floor(spos) * CC];
- high = buf[(int)ceil(spos) * CC];
-
- buffer[i * CC] = low + (spos - floor(spos)) * (high - low);
- }
- }
-
- if(floor(spos) == spos)
- {
- memcpy(m_cache.getBuffer() + m_channels, buf + int(floor(spos)) * m_channels, samplesize);
- m_cache_pos = 1;
- }
- else
- {
- memcpy(m_cache.getBuffer(), buf + int(floor(spos)) * m_channels, 2 * samplesize);
- m_cache_pos = spos - floor(spos);
- }
-
- eos &= length < size;
-}
diff --git a/intern/audaspace/intern/AUD_LinearResampleReader.h b/intern/audaspace/intern/AUD_LinearResampleReader.h
deleted file mode 100644
index 9beea251c07..00000000000
--- a/intern/audaspace/intern/AUD_LinearResampleReader.h
+++ /dev/null
@@ -1,86 +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_LinearResampleReader.h
- * \ingroup audaspaceintern
- */
-
-
-#ifndef __AUD_LINEARRESAMPLEREADER_H__
-#define __AUD_LINEARRESAMPLEREADER_H__
-
-#include "AUD_ResampleReader.h"
-#include "AUD_Buffer.h"
-
-/**
- * This resampling reader does simple first-order hold resampling.
- */
-class AUD_LinearResampleReader : public AUD_ResampleReader
-{
-private:
- /**
- * The reader channels.
- */
- AUD_Channels m_channels;
-
- /**
- * The position in the cache.
- */
- float m_cache_pos;
-
- /**
- * The sound output buffer.
- */
- AUD_Buffer m_buffer;
-
- /**
- * The input caching buffer.
- */
- AUD_Buffer m_cache;
-
- /**
- * Whether the cache contains valid data.
- */
- bool m_cache_ok;
-
- // hide copy constructor and operator=
- AUD_LinearResampleReader(const AUD_LinearResampleReader&);
- AUD_LinearResampleReader& operator=(const AUD_LinearResampleReader&);
-
-public:
- /**
- * Creates a resampling reader.
- * \param reader The reader to mix.
- * \param specs The target specification.
- */
- AUD_LinearResampleReader(boost::shared_ptr<AUD_IReader> reader, AUD_Specs specs);
-
- virtual void seek(int position);
- virtual int getLength() const;
- virtual int getPosition() const;
- virtual AUD_Specs getSpecs() const;
- virtual void read(int& length, bool& eos, sample_t* buffer);
-};
-
-#endif //__AUD_LINEARRESAMPLEREADER_H__
diff --git a/intern/audaspace/intern/AUD_Mixer.cpp b/intern/audaspace/intern/AUD_Mixer.cpp
deleted file mode 100644
index 78dfaddd27a..00000000000
--- a/intern/audaspace/intern/AUD_Mixer.cpp
+++ /dev/null
@@ -1,121 +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_Mixer.cpp
- * \ingroup audaspaceintern
- */
-
-
-#include "AUD_Mixer.h"
-#include "AUD_IReader.h"
-
-#include <cstring>
-
-AUD_Mixer::AUD_Mixer(AUD_DeviceSpecs specs) :
- m_specs(specs)
-{
- switch(m_specs.format)
- {
- case AUD_FORMAT_U8:
- m_convert = AUD_convert_float_u8;
- break;
- case AUD_FORMAT_S16:
- m_convert = AUD_convert_float_s16;
- break;
- case AUD_FORMAT_S24:
-
-#ifdef __BIG_ENDIAN__
- m_convert = AUD_convert_float_s24_be;
-#else
- m_convert = AUD_convert_float_s24_le;
-#endif
- break;
- case AUD_FORMAT_S32:
- m_convert = AUD_convert_float_s32;
- break;
- case AUD_FORMAT_FLOAT32:
- m_convert = AUD_convert_copy<float>;
- break;
- case AUD_FORMAT_FLOAT64:
- m_convert = AUD_convert_float_double;
- break;
- default:
- break;
- }
-}
-
-AUD_DeviceSpecs AUD_Mixer::getSpecs() const
-{
- return m_specs;
-}
-
-void AUD_Mixer::setSpecs(AUD_Specs specs)
-{
- m_specs.specs = specs;
-}
-
-void AUD_Mixer::clear(int length)
-{
- m_buffer.assureSize(length * m_specs.channels * AUD_SAMPLE_SIZE(m_specs));
-
- m_length = length;
-
- memset(m_buffer.getBuffer(), 0, length * m_specs.channels * AUD_SAMPLE_SIZE(m_specs));
-}
-
-void AUD_Mixer::mix(sample_t* buffer, int start, int length, float volume)
-{
- sample_t* out = m_buffer.getBuffer();
-
- length = (AUD_MIN(m_length, length + start) - start) * m_specs.channels;
- start *= m_specs.channels;
-
- for(int i = 0; i < length; i++)
- out[i + start] += buffer[i] * volume;
-}
-
-void AUD_Mixer::mix(sample_t* buffer, int start, int length, float volume_to, float volume_from)
-{
- sample_t* out = m_buffer.getBuffer();
-
- length = (std::min(m_length, length + start) - start);
-
- for(int i = 0; i < length; i++)
- {
- float volume = volume_from * (1.0f - i / float(length)) + volume_to * (i / float(length));
-
- for(int c = 0; c < m_specs.channels; c++)
- out[(i + start) * m_specs.channels + c] += buffer[i * m_specs.channels + c] * volume;
- }
-}
-
-void AUD_Mixer::read(data_t* buffer, float volume)
-{
- sample_t* out = m_buffer.getBuffer();
-
- for(int i = 0; i < m_length * m_specs.channels; i++)
- out[i] *= volume;
-
- m_convert(buffer, (data_t*) out, m_length * m_specs.channels);
-}
diff --git a/intern/audaspace/intern/AUD_Mixer.h b/intern/audaspace/intern/AUD_Mixer.h
deleted file mode 100644
index 0735fee715b..00000000000
--- a/intern/audaspace/intern/AUD_Mixer.h
+++ /dev/null
@@ -1,114 +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_Mixer.h
- * \ingroup audaspaceintern
- */
-
-
-#ifndef __AUD_MIXER_H__
-#define __AUD_MIXER_H__
-
-#include "AUD_ConverterFunctions.h"
-#include "AUD_Buffer.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.
- */
-class AUD_Mixer
-{
-protected:
- /**
- * The output specification.
- */
- AUD_DeviceSpecs m_specs;
-
- /**
- * The length of the mixing buffer.
- */
- int m_length;
-
- /**
- * The mixing buffer.
- */
- AUD_Buffer m_buffer;
-
- /**
- * Converter function.
- */
- AUD_convert_f m_convert;
-
-public:
- /**
- * Creates the mixer.
- */
- AUD_Mixer(AUD_DeviceSpecs specs);
-
- /**
- * Destroys the mixer.
- */
- virtual ~AUD_Mixer() {}
-
- /**
- * Returns the target specification for superposing.
- * \return The target specification.
- */
- AUD_DeviceSpecs getSpecs() const;
-
- /**
- * Sets the target specification for superposing.
- * \param specs The target specification.
- */
- void setSpecs(AUD_Specs specs);
-
- /**
- * Mixes a buffer.
- * \param buffer The buffer to superpose.
- * \param start The start sample of the buffer.
- * \param length The length of the buffer in samples.
- * \param volume The mixing volume. Must be a value between 0.0 and 1.0.
- */
- void mix(sample_t* buffer, int start, int length, float volume);
-
- void mix(sample_t* buffer, int start, int length, float volume_to, float volume_from);
-
- /**
- * Writes the mixing buffer into an output buffer.
- * \param buffer The target buffer for superposing.
- * \param volume The mixing volume. Must be a value between 0.0 and 1.0.
- */
- void read(data_t* buffer, float volume);
-
- /**
- * Clears the mixing buffer.
- * \param length The length of the buffer in samples.
- */
- void clear(int length);
-};
-
-#endif //__AUD_MIXER_H__
diff --git a/intern/audaspace/intern/AUD_MixerFactory.cpp b/intern/audaspace/intern/AUD_MixerFactory.cpp
deleted file mode 100644
index f3f00ea2cb6..00000000000
--- a/intern/audaspace/intern/AUD_MixerFactory.cpp
+++ /dev/null
@@ -1,52 +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_MixerFactory.cpp
- * \ingroup audaspaceintern
- */
-
-
-#include "AUD_MixerFactory.h"
-#include "AUD_IReader.h"
-
-boost::shared_ptr<AUD_IReader> AUD_MixerFactory::getReader() const
-{
- return m_factory->createReader();
-}
-
-AUD_MixerFactory::AUD_MixerFactory(boost::shared_ptr<AUD_IFactory> factory,
- AUD_DeviceSpecs specs) :
- m_specs(specs), m_factory(factory)
-{
-}
-
-AUD_DeviceSpecs AUD_MixerFactory::getSpecs() const
-{
- return m_specs;
-}
-
-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
deleted file mode 100644
index 1d2b6a4cc91..00000000000
--- a/intern/audaspace/intern/AUD_MixerFactory.h
+++ /dev/null
@@ -1,79 +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_MixerFactory.h
- * \ingroup audaspaceintern
- */
-
-
-#ifndef __AUD_MIXERFACTORY_H__
-#define __AUD_MIXERFACTORY_H__
-
-#include "AUD_IFactory.h"
-
-/**
- * This factory is a base class for all mixer factories.
- */
-class AUD_MixerFactory : public AUD_IFactory
-{
-protected:
- /**
- * The target specification for resampling.
- */
- const AUD_DeviceSpecs m_specs;
-
- /**
- * If there is no reader it is created out of this factory.
- */
- boost::shared_ptr<AUD_IFactory> m_factory;
-
- /**
- * Returns the reader created out of the factory.
- * This method can be used for the createReader function of the implementing
- * classes.
- * \return The reader to mix.
- */
- boost::shared_ptr<AUD_IReader> getReader() const;
-
-public:
- /**
- * Creates a new factory.
- * \param factory The factory to create the readers to mix out of.
- * \param specs The target specification.
- */
- AUD_MixerFactory(boost::shared_ptr<AUD_IFactory> factory, AUD_DeviceSpecs specs);
-
- /**
- * Returns the target specification for resampling.
- */
- AUD_DeviceSpecs getSpecs() const;
-
- /**
- * Returns the saved factory.
- * \return The factory.
- */
- boost::shared_ptr<AUD_IFactory> getFactory() const;
-};
-
-#endif //__AUD_MIXERFACTORY_H__
diff --git a/intern/audaspace/intern/AUD_MutexLock.h b/intern/audaspace/intern/AUD_MutexLock.h
deleted file mode 100644
index b6f6d2b4334..00000000000
--- a/intern/audaspace/intern/AUD_MutexLock.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef AUD_MUTEXLOCK_H
-#define AUD_MUTEXLOCK_H
-
-#include "AUD_ILockable.h"
-
-class AUD_MutexLock
-{
-public:
- inline AUD_MutexLock(AUD_ILockable& lockable) :
- lockable(lockable)
- {
- lockable.lock();
- }
-
- inline ~AUD_MutexLock()
- {
- lockable.unlock();
- }
-
-private:
- AUD_ILockable& lockable;
-};
-
-#endif // AUD_MUTEXLOCK_H
diff --git a/intern/audaspace/intern/AUD_NULLDevice.cpp b/intern/audaspace/intern/AUD_NULLDevice.cpp
deleted file mode 100644
index 98a0d324c61..00000000000
--- a/intern/audaspace/intern/AUD_NULLDevice.cpp
+++ /dev/null
@@ -1,159 +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_NULLDevice.cpp
- * \ingroup audaspaceintern
- */
-
-
-#include <limits>
-
-#include "AUD_NULLDevice.h"
-
-AUD_NULLDevice::AUD_NULLHandle::AUD_NULLHandle()
-{
-}
-
-bool AUD_NULLDevice::AUD_NULLHandle::pause()
-{
- return false;
-}
-
-bool AUD_NULLDevice::AUD_NULLHandle::resume()
-{
- return false;
-}
-
-bool AUD_NULLDevice::AUD_NULLHandle::stop()
-{
- return false;
-}
-
-bool AUD_NULLDevice::AUD_NULLHandle::getKeep()
-{
- return false;
-}
-
-bool AUD_NULLDevice::AUD_NULLHandle::setKeep(bool keep)
-{
- return false;
-}
-
-bool AUD_NULLDevice::AUD_NULLHandle::seek(float position)
-{
- return false;
-}
-
-float AUD_NULLDevice::AUD_NULLHandle::getPosition()
-{
- return std::numeric_limits<float>::quiet_NaN();
-}
-
-AUD_Status AUD_NULLDevice::AUD_NULLHandle::getStatus()
-{
- return AUD_STATUS_INVALID;
-}
-
-float AUD_NULLDevice::AUD_NULLHandle::getVolume()
-{
- return std::numeric_limits<float>::quiet_NaN();
-}
-
-bool AUD_NULLDevice::AUD_NULLHandle::setVolume(float volume)
-{
- return false;
-}
-
-float AUD_NULLDevice::AUD_NULLHandle::getPitch()
-{
- return std::numeric_limits<float>::quiet_NaN();
-}
-
-bool AUD_NULLDevice::AUD_NULLHandle::setPitch(float pitch)
-{
- return false;
-}
-
-int AUD_NULLDevice::AUD_NULLHandle::getLoopCount()
-{
- return 0;
-}
-
-bool AUD_NULLDevice::AUD_NULLHandle::setLoopCount(int count)
-{
- return false;
-}
-
-bool AUD_NULLDevice::AUD_NULLHandle::setStopCallback(stopCallback callback, void* data)
-{
- return false;
-}
-
-AUD_NULLDevice::AUD_NULLDevice()
-{
-}
-
-AUD_NULLDevice::~AUD_NULLDevice()
-{
-}
-
-AUD_DeviceSpecs AUD_NULLDevice::getSpecs() const
-{
- AUD_DeviceSpecs specs;
- specs.channels = AUD_CHANNELS_INVALID;
- specs.format = AUD_FORMAT_INVALID;
- specs.rate = AUD_RATE_INVALID;
- return specs;
-}
-
-boost::shared_ptr<AUD_IHandle> AUD_NULLDevice::play(boost::shared_ptr<AUD_IReader> reader, bool keep)
-{
- return boost::shared_ptr<AUD_IHandle>(new AUD_NULLHandle());
-}
-
-boost::shared_ptr<AUD_IHandle> AUD_NULLDevice::play(boost::shared_ptr<AUD_IFactory> factory, bool keep)
-{
- return boost::shared_ptr<AUD_IHandle>(new AUD_NULLHandle());
-}
-
-void AUD_NULLDevice::stopAll()
-{
-}
-
-void AUD_NULLDevice::lock()
-{
-}
-
-void AUD_NULLDevice::unlock()
-{
-}
-
-float AUD_NULLDevice::getVolume() const
-{
- return std::numeric_limits<float>::quiet_NaN();
-}
-
-void AUD_NULLDevice::setVolume(float volume)
-{
-}
diff --git a/intern/audaspace/intern/AUD_NULLDevice.h b/intern/audaspace/intern/AUD_NULLDevice.h
deleted file mode 100644
index ae1435bbeea..00000000000
--- a/intern/audaspace/intern/AUD_NULLDevice.h
+++ /dev/null
@@ -1,84 +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_NULLDevice.h
- * \ingroup audaspaceintern
- */
-
-
-#ifndef __AUD_NULLDEVICE_H__
-#define __AUD_NULLDEVICE_H__
-
-#include "AUD_IReader.h"
-#include "AUD_IDevice.h"
-#include "AUD_IHandle.h"
-
-/**
- * This device plays nothing.
- */
-class AUD_NULLDevice : public AUD_IDevice
-{
-private:
- class AUD_NULLHandle : public AUD_IHandle
- {
- public:
-
- AUD_NULLHandle();
-
- virtual ~AUD_NULLHandle() {}
- virtual bool pause();
- virtual bool resume();
- virtual bool stop();
- virtual bool getKeep();
- virtual bool setKeep(bool keep);
- virtual bool seek(float position);
- virtual float getPosition();
- virtual AUD_Status getStatus();
- virtual float getVolume();
- virtual bool setVolume(float volume);
- virtual float getPitch();
- virtual bool setPitch(float pitch);
- virtual int getLoopCount();
- virtual bool setLoopCount(int count);
- virtual bool setStopCallback(stopCallback callback = 0, void* data = 0);
- };
-public:
- /**
- * Creates a new NULL device.
- */
- AUD_NULLDevice();
-
- virtual ~AUD_NULLDevice();
-
- virtual AUD_DeviceSpecs getSpecs() const;
- 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();
- virtual float getVolume() const;
- virtual void setVolume(float volume);
-};
-
-#endif //__AUD_NULLDEVICE_H__
diff --git a/intern/audaspace/intern/AUD_ReadDevice.cpp b/intern/audaspace/intern/AUD_ReadDevice.cpp
deleted file mode 100644
index bab6ce4f001..00000000000
--- a/intern/audaspace/intern/AUD_ReadDevice.cpp
+++ /dev/null
@@ -1,78 +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_ReadDevice.cpp
- * \ingroup audaspaceintern
- */
-
-
-#include "AUD_ReadDevice.h"
-#include "AUD_IReader.h"
-
-#include <cstring>
-
-AUD_ReadDevice::AUD_ReadDevice(AUD_DeviceSpecs specs) :
- m_playing(false)
-{
- m_specs = specs;
-
- create();
-}
-
-AUD_ReadDevice::AUD_ReadDevice(AUD_Specs specs) :
- m_playing(false)
-{
- m_specs.specs = specs;
- m_specs.format = AUD_FORMAT_FLOAT32;
-
- create();
-}
-
-AUD_ReadDevice::~AUD_ReadDevice()
-{
- destroy();
-}
-
-bool AUD_ReadDevice::read(data_t* buffer, int length)
-{
- if(m_playing)
- mix(buffer, length);
- else
- if(m_specs.format == AUD_FORMAT_U8)
- memset(buffer, 0x80, length * AUD_DEVICE_SAMPLE_SIZE(m_specs));
- else
- memset(buffer, 0, length * AUD_DEVICE_SAMPLE_SIZE(m_specs));
- return m_playing;
-}
-
-void AUD_ReadDevice::changeSpecs(AUD_Specs specs)
-{
- if(!AUD_COMPARE_SPECS(specs, m_specs.specs))
- setSpecs(specs);
-}
-
-void AUD_ReadDevice::playing(bool playing)
-{
- m_playing = playing;
-}
diff --git a/intern/audaspace/intern/AUD_ReadDevice.h b/intern/audaspace/intern/AUD_ReadDevice.h
deleted file mode 100644
index 0f077fe5d7e..00000000000
--- a/intern/audaspace/intern/AUD_ReadDevice.h
+++ /dev/null
@@ -1,88 +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_ReadDevice.h
- * \ingroup audaspaceintern
- */
-
-
-#ifndef __AUD_READDEVICE_H__
-#define __AUD_READDEVICE_H__
-
-#include "AUD_SoftwareDevice.h"
-
-/**
- * This device enables to let the user read raw data out of it.
- */
-class AUD_ReadDevice : public AUD_SoftwareDevice
-{
-private:
- /**
- * Whether the device currently.
- */
- bool m_playing;
-
- // hide copy constructor and operator=
- AUD_ReadDevice(const AUD_ReadDevice&);
- AUD_ReadDevice& operator=(const AUD_ReadDevice&);
-
-protected:
- virtual void playing(bool playing);
-
-public:
- /**
- * Creates a new read device.
- * \param specs The wanted audio specification.
- */
- AUD_ReadDevice(AUD_DeviceSpecs specs);
-
- /**
- * Creates a new read device.
- * \param specs The wanted audio specification.
- */
- AUD_ReadDevice(AUD_Specs specs);
-
- /**
- * Closes the device.
- */
- virtual ~AUD_ReadDevice();
-
- /**
- * Reads the next bytes into the supplied buffer.
- * \param buffer The target buffer.
- * \param length The length in samples to be filled.
- * \return True if the reading succeeded, false if there are no sounds
- * played back currently, in that case the buffer is filled with
- * silence.
- */
- bool read(data_t* buffer, int length);
-
- /**
- * Changes the output specification.
- * \param specs The new audio data specification.
- */
- void changeSpecs(AUD_Specs specs);
-};
-
-#endif //__AUD_READDEVICE_H__
diff --git a/intern/audaspace/intern/AUD_ResampleFactory.h b/intern/audaspace/intern/AUD_ResampleFactory.h
deleted file mode 100644
index 11f8dc15f03..00000000000
--- a/intern/audaspace/intern/AUD_ResampleFactory.h
+++ /dev/null
@@ -1,37 +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_ResampleFactory.h
- * \ingroup audaspaceintern
- */
-
-
-#ifndef __AUD_RESAMPLEFACTORY_H__
-#define __AUD_RESAMPLEFACTORY_H__
-
-#include "AUD_MixerFactory.h"
-
-typedef AUD_MixerFactory AUD_ResampleFactory;
-
-#endif //__AUD_RESAMPLEFACTORY_H__
diff --git a/intern/audaspace/intern/AUD_ResampleReader.cpp b/intern/audaspace/intern/AUD_ResampleReader.cpp
deleted file mode 100644
index 4b247ffd862..00000000000
--- a/intern/audaspace/intern/AUD_ResampleReader.cpp
+++ /dev/null
@@ -1,45 +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_ResampleReader.cpp
- * \ingroup audaspaceintern
- */
-
-
-#include "AUD_ResampleReader.h"
-
-AUD_ResampleReader::AUD_ResampleReader(boost::shared_ptr<AUD_IReader> reader, AUD_SampleRate rate) :
- AUD_EffectReader(reader), m_rate(rate)
-{
-}
-
-void AUD_ResampleReader::setRate(AUD_SampleRate rate)
-{
- m_rate = rate;
-}
-
-AUD_SampleRate AUD_ResampleReader::getRate()
-{
- return m_rate;
-}
diff --git a/intern/audaspace/intern/AUD_ResampleReader.h b/intern/audaspace/intern/AUD_ResampleReader.h
deleted file mode 100644
index 7e21989bfa8..00000000000
--- a/intern/audaspace/intern/AUD_ResampleReader.h
+++ /dev/null
@@ -1,66 +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_ResampleReader.h
- * \ingroup audaspaceintern
- */
-
-#ifndef __AUD_RESAMPLEREADER_H__
-#define __AUD_RESAMPLEREADER_H__
-
-#include "AUD_EffectReader.h"
-
-/**
- * This is the base class for all resampling readers.
- */
-class AUD_ResampleReader : public AUD_EffectReader
-{
-protected:
- /**
- * The target sampling rate.
- */
- AUD_SampleRate m_rate;
-
- /**
- * Creates a resampling reader.
- * \param reader The reader to mix.
- * \param rate The target sampling rate.
- */
- AUD_ResampleReader(boost::shared_ptr<AUD_IReader> reader, AUD_SampleRate rate);
-
-public:
- /**
- * Sets the sample rate.
- * \param rate The target sampling rate.
- */
- virtual void setRate(AUD_SampleRate rate);
-
- /**
- * Retrieves the sample rate.
- * \return The target sampling rate.
- */
- virtual AUD_SampleRate getRate();
-};
-
-#endif // __AUD_RESAMPLEREADER_H__
diff --git a/intern/audaspace/intern/AUD_Sequencer.cpp b/intern/audaspace/intern/AUD_Sequencer.cpp
deleted file mode 100644
index ddcf97e2ea1..00000000000
--- a/intern/audaspace/intern/AUD_Sequencer.cpp
+++ /dev/null
@@ -1,177 +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_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(343.3f),
- m_doppler_factor(1),
- m_distance_model(AUD_DISTANCE_MODEL_INVERSE_CLAMPED),
- m_volume(1, 1.0f),
- 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_back(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_SequencerEntry.cpp b/intern/audaspace/intern/AUD_SequencerEntry.cpp
deleted file mode 100644
index 6ef8479cdb8..00000000000
--- a/intern/audaspace/intern/AUD_SequencerEntry.cpp
+++ /dev/null
@@ -1,319 +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_SequencerEntry.cpp
- * \ingroup audaspaceintern
- */
-
-
-#include "AUD_SequencerEntry.h"
-#include "AUD_SequencerReader.h"
-#include "AUD_MutexLock.h"
-
-#include <cmath>
-#include <limits>
-
-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),
- m_id(id),
- m_sound(sound),
- m_begin(begin),
- m_end(end),
- m_skip(skip),
- m_muted(false),
- 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(360),
- m_cone_angle_inner(360),
- m_cone_volume_outer(0),
- m_volume(1, 1.0f),
- m_pitch(1, 1.0f),
- m_location(3),
- m_orientation(4)
-{
- AUD_Quaternion q;
- m_orientation.write(q.get());
- float f = 1;
- m_volume.write(&f);
- m_pitch.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_SequencerEntry::~AUD_SequencerEntry()
-{
- pthread_mutex_destroy(&m_mutex);
-}
-
-void AUD_SequencerEntry::lock()
-{
- pthread_mutex_lock(&m_mutex);
-}
-
-void AUD_SequencerEntry::unlock()
-{
- pthread_mutex_unlock(&m_mutex);
-}
-
-void AUD_SequencerEntry::setSound(boost::shared_ptr<AUD_IFactory> sound)
-{
- AUD_MutexLock lock(*this);
-
- if(m_sound.get() != sound.get())
- {
- m_sound = sound;
- m_sound_status++;
- }
-}
-
-void AUD_SequencerEntry::move(float begin, float end, float skip)
-{
- AUD_MutexLock lock(*this);
-
- if(m_begin != begin || m_skip != skip || m_end != end)
- {
- m_begin = begin;
- m_skip = skip;
- m_end = end;
- m_pos_status++;
- }
-}
-
-void AUD_SequencerEntry::mute(bool mute)
-{
- AUD_MutexLock lock(*this);
-
- m_muted = mute;
-}
-
-int AUD_SequencerEntry::getID() const
-{
- return m_id;
-}
-
-AUD_AnimateableProperty* AUD_SequencerEntry::getAnimProperty(AUD_AnimateablePropertyType type)
-{
- switch(type)
- {
- case AUD_AP_VOLUME:
- return &m_volume;
- case AUD_AP_PITCH:
- return &m_pitch;
- case AUD_AP_PANNING:
- return &m_panning;
- case AUD_AP_LOCATION:
- return &m_location;
- case AUD_AP_ORIENTATION:
- return &m_orientation;
- default:
- return NULL;
- }
-}
-
-void AUD_SequencerEntry::updateAll(float volume_max, float volume_min, float distance_max,
- float distance_reference, float attenuation, float cone_angle_outer,
- float cone_angle_inner, float cone_volume_outer)
-{
- AUD_MutexLock lock(*this);
-
- if(volume_max != m_volume_max)
- {
- m_volume_max = volume_max;
- m_status++;
- }
-
- if(volume_min != m_volume_min)
- {
- m_volume_min = volume_min;
- m_status++;
- }
-
- if(distance_max != m_distance_max)
- {
- m_distance_max = distance_max;
- m_status++;
- }
-
- if(distance_reference != m_distance_reference)
- {
- m_distance_reference = distance_reference;
- m_status++;
- }
-
- if(attenuation != m_attenuation)
- {
- m_attenuation = attenuation;
- m_status++;
- }
-
- if(cone_angle_outer != m_cone_angle_outer)
- {
- m_cone_angle_outer = cone_angle_outer;
- m_status++;
- }
-
- if(cone_angle_inner != m_cone_angle_inner)
- {
- m_cone_angle_inner = cone_angle_inner;
- m_status++;
- }
-
- if(cone_volume_outer != m_cone_volume_outer)
- {
- m_cone_volume_outer = cone_volume_outer;
- m_status++;
- }
-}
-
-bool AUD_SequencerEntry::isRelative()
-{
- return m_relative;
-}
-
-void AUD_SequencerEntry::setRelative(bool relative)
-{
- AUD_MutexLock lock(*this);
-
- if(m_relative != relative)
- {
- m_relative = relative;
- m_status++;
- }
-}
-
-float AUD_SequencerEntry::getVolumeMaximum()
-{
- return m_volume_max;
-}
-
-void AUD_SequencerEntry::setVolumeMaximum(float volume)
-{
- AUD_MutexLock lock(*this);
-
- m_volume_max = volume;
- m_status++;
-}
-
-float AUD_SequencerEntry::getVolumeMinimum()
-{
- return m_volume_min;
-}
-
-void AUD_SequencerEntry::setVolumeMinimum(float volume)
-{
- AUD_MutexLock lock(*this);
-
- m_volume_min = volume;
- m_status++;
-}
-
-float AUD_SequencerEntry::getDistanceMaximum()
-{
- return m_distance_max;
-}
-
-void AUD_SequencerEntry::setDistanceMaximum(float distance)
-{
- AUD_MutexLock lock(*this);
-
- m_distance_max = distance;
- m_status++;
-}
-
-float AUD_SequencerEntry::getDistanceReference()
-{
- return m_distance_reference;
-}
-
-void AUD_SequencerEntry::setDistanceReference(float distance)
-{
- AUD_MutexLock lock(*this);
-
- m_distance_reference = distance;
- m_status++;
-}
-
-float AUD_SequencerEntry::getAttenuation()
-{
- return m_attenuation;
-}
-
-void AUD_SequencerEntry::setAttenuation(float factor)
-{
- AUD_MutexLock lock(*this);
-
- m_attenuation = factor;
- m_status++;
-}
-
-float AUD_SequencerEntry::getConeAngleOuter()
-{
- return m_cone_angle_outer;
-}
-
-void AUD_SequencerEntry::setConeAngleOuter(float angle)
-{
- AUD_MutexLock lock(*this);
-
- m_cone_angle_outer = angle;
- m_status++;
-}
-
-float AUD_SequencerEntry::getConeAngleInner()
-{
- return m_cone_angle_inner;
-}
-
-void AUD_SequencerEntry::setConeAngleInner(float angle)
-{
- AUD_MutexLock lock(*this);
-
- m_cone_angle_inner = angle;
- m_status++;
-}
-
-float AUD_SequencerEntry::getConeVolumeOuter()
-{
- return m_cone_volume_outer;
-}
-
-void AUD_SequencerEntry::setConeVolumeOuter(float volume)
-{
- AUD_MutexLock lock(*this);
-
- m_cone_volume_outer = volume;
- m_status++;
-}
diff --git a/intern/audaspace/intern/AUD_SequencerFactory.cpp b/intern/audaspace/intern/AUD_SequencerFactory.cpp
deleted file mode 100644
index f6076603c2b..00000000000
--- a/intern/audaspace/intern/AUD_SequencerFactory.cpp
+++ /dev/null
@@ -1,123 +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_SequencerFactory.cpp
- * \ingroup audaspaceintern
- */
-
-
-#include "AUD_SequencerFactory.h"
-#include "AUD_SequencerReader.h"
-#include "AUD_3DMath.h"
-#include "AUD_MutexLock.h"
-
-AUD_SequencerFactory::AUD_SequencerFactory(AUD_Specs specs, float fps, bool muted)
-{
- m_sequence = boost::shared_ptr<AUD_Sequencer>(new AUD_Sequencer(specs, fps, muted));
-}
-
-/*void AUD_SequencerFactory::lock()
-{
- pthread_mutex_lock(&m_mutex);
-}
-
-void AUD_SequencerFactory::unlock()
-{
- pthread_mutex_unlock(&m_mutex);
-}*/
-
-void AUD_SequencerFactory::setSpecs(AUD_Specs specs)
-{
- m_sequence->setSpecs(specs);
-}
-
-void AUD_SequencerFactory::setFPS(float fps)
-{
- m_sequence->setFPS(fps);
-}
-
-void AUD_SequencerFactory::mute(bool muted)
-{
- m_sequence->mute(muted);
-}
-
-bool AUD_SequencerFactory::getMute() const
-{
- return m_sequence->getMute();
-}
-
-float AUD_SequencerFactory::getSpeedOfSound() const
-{
- return m_sequence->getSpeedOfSound();
-}
-
-void AUD_SequencerFactory::setSpeedOfSound(float speed)
-{
- m_sequence->setSpeedOfSound(speed);
-}
-
-float AUD_SequencerFactory::getDopplerFactor() const
-{
- return m_sequence->getDopplerFactor();
-}
-
-void AUD_SequencerFactory::setDopplerFactor(float factor)
-{
- m_sequence->setDopplerFactor(factor);
-}
-
-AUD_DistanceModel AUD_SequencerFactory::getDistanceModel() const
-{
- return m_sequence->getDistanceModel();
-}
-
-void AUD_SequencerFactory::setDistanceModel(AUD_DistanceModel model)
-{
- m_sequence->setDistanceModel(model);
-}
-
-AUD_AnimateableProperty* AUD_SequencerFactory::getAnimProperty(AUD_AnimateablePropertyType type)
-{
- return m_sequence->getAnimProperty(type);
-}
-
-boost::shared_ptr<AUD_SequencerEntry> AUD_SequencerFactory::add(boost::shared_ptr<AUD_IFactory> sound, float begin, float end, float skip)
-{
- return m_sequence->add(sound, begin, end, skip);
-}
-
-void AUD_SequencerFactory::remove(boost::shared_ptr<AUD_SequencerEntry> entry)
-{
- m_sequence->remove(entry);
-}
-
-boost::shared_ptr<AUD_IReader> AUD_SequencerFactory::createQualityReader()
-{
- return boost::shared_ptr<AUD_IReader>(new AUD_SequencerReader(m_sequence, true));
-}
-
-boost::shared_ptr<AUD_IReader> AUD_SequencerFactory::createReader()
-{
- return boost::shared_ptr<AUD_IReader>(new AUD_SequencerReader(m_sequence));
-}
diff --git a/intern/audaspace/intern/AUD_SequencerReader.cpp b/intern/audaspace/intern/AUD_SequencerReader.cpp
deleted file mode 100644
index aef93cd3896..00000000000
--- a/intern/audaspace/intern/AUD_SequencerReader.cpp
+++ /dev/null
@@ -1,204 +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_SequencerReader.cpp
- * \ingroup audaspaceintern
- */
-
-
-#include "AUD_SequencerReader.h"
-#include "AUD_MutexLock.h"
-
-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(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);
-}
-
-AUD_SequencerReader::~AUD_SequencerReader()
-{
-}
-
-bool AUD_SequencerReader::isSeekable() const
-{
- return true;
-}
-
-void AUD_SequencerReader::seek(int position)
-{
- if(position < 0)
- return;
-
- m_position = position;
-
- for(AUD_HandleIterator it = m_handles.begin(); it != m_handles.end(); it++)
- {
- (*it)->seek(position / m_sequence->m_specs.rate);
- }
-}
-
-int AUD_SequencerReader::getLength() const
-{
- return -1;
-}
-
-int AUD_SequencerReader::getPosition() const
-{
- return m_position;
-}
-
-AUD_Specs AUD_SequencerReader::getSpecs() const
-{
- return m_sequence->m_specs;
-}
-
-void AUD_SequencerReader::read(int& length, bool& eos, sample_t* buffer)
-{
- AUD_MutexLock lock(*m_sequence);
-
- if(m_sequence->m_status != m_status)
- {
- 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_sequence->m_status;
- }
-
- if(m_sequence->m_entry_status != m_entry_status)
- {
- std::list<boost::shared_ptr<AUD_SequencerHandle> > handles;
-
- AUD_HandleIterator hit = m_handles.begin();
- AUD_EntryIterator eit = m_sequence->m_entries.begin();
-
- int result;
- boost::shared_ptr<AUD_SequencerHandle> handle;
-
- while(hit != m_handles.end() && eit != m_sequence->m_entries.end())
- {
- handle = *hit;
- boost::shared_ptr<AUD_SequencerEntry> entry = *eit;
-
- result = handle->compare(entry);
-
- if(result < 0)
- {
- try
- {
- handle = boost::shared_ptr<AUD_SequencerHandle>(new AUD_SequencerHandle(entry, m_device));
- handles.push_back(handle);
- }
- catch(AUD_Exception&)
- {
- }
- eit++;
- }
- else if(result == 0)
- {
- handles.push_back(handle);
- hit++;
- eit++;
- }
- else
- {
- handle->stop();
- hit++;
- }
- }
-
- while(hit != m_handles.end())
- {
- (*hit)->stop();
- hit++;
- }
-
- while(eit != m_sequence->m_entries.end())
- {
- try
- {
- handle = boost::shared_ptr<AUD_SequencerHandle>(new AUD_SequencerHandle(*eit, m_device));
- handles.push_back(handle);
- }
- catch(AUD_Exception&)
- {
- }
- eit++;
- }
-
- m_handles = handles;
-
- m_entry_status = m_sequence->m_entry_status;
- }
-
- AUD_Specs specs = m_sequence->m_specs;
- int pos = 0;
- float time = float(m_position) / float(specs.rate);
- float volume, frame;
- int len, cfra;
- AUD_Vector3 v, v2;
- AUD_Quaternion q;
-
-
- while(pos < length)
- {
- frame = time * m_sequence->m_fps;
- cfra = int(floor(frame));
-
- 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_sequence->m_fps);
- }
-
- m_sequence->m_volume.read(frame, &volume);
- if(m_sequence->m_muted)
- volume = 0.0f;
- m_device.setVolume(volume);
-
- m_sequence->m_orientation.read(frame, q.get());
- m_device.setListenerOrientation(q);
- m_sequence->m_location.read(frame, v.get());
- m_device.setListenerLocation(v);
- m_sequence->m_location.read(frame + 1, v2.get());
- v2 -= v;
- m_device.setListenerVelocity(v2 * m_sequence->m_fps);
-
- m_device.read(reinterpret_cast<data_t*>(buffer + specs.channels * pos), len);
-
- pos += len;
- time += float(len) / float(specs.rate);
- }
-
- m_position += length;
-
- eos = false;
-}
diff --git a/intern/audaspace/intern/AUD_SequencerReader.h b/intern/audaspace/intern/AUD_SequencerReader.h
deleted file mode 100644
index 6b3dbc9313e..00000000000
--- a/intern/audaspace/intern/AUD_SequencerReader.h
+++ /dev/null
@@ -1,99 +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_SequencerReader.h
- * \ingroup audaspaceintern
- */
-
-
-#ifndef __AUD_SEQUENCERREADER_H__
-#define __AUD_SEQUENCERREADER_H__
-
-#include "AUD_IReader.h"
-#include "AUD_ReadDevice.h"
-#include "AUD_Sequencer.h"
-#include "AUD_SequencerHandle.h"
-
-/**
- * This reader plays back sequenced entries.
- */
-class AUD_SequencerReader : public AUD_IReader
-{
-private:
- /**
- * The current position.
- */
- int m_position;
-
- /**
- * The read device used to mix the sounds correctly.
- */
- AUD_ReadDevice m_device;
-
- /**
- * Saves the sequence the reader belongs to.
- */
- boost::shared_ptr<AUD_Sequencer> m_sequence;
-
- /**
- * The list of playback handles for the entries.
- */
- std::list<boost::shared_ptr<AUD_SequencerHandle> > m_handles;
-
- /**
- * Last status read from the sequence.
- */
- int m_status;
-
- /**
- * Last entry status read from the sequence.
- */
- int m_entry_status;
-
- // hide copy constructor and operator=
- AUD_SequencerReader(const AUD_SequencerReader&);
- AUD_SequencerReader& operator=(const AUD_SequencerReader&);
-
-public:
- /**
- * Creates a resampling reader.
- * \param reader The reader to mix.
- * \param specs The target specification.
- */
- AUD_SequencerReader(boost::shared_ptr<AUD_Sequencer> sequence, bool quality = false);
-
- /**
- * Destroys the reader.
- */
- ~AUD_SequencerReader();
-
- virtual bool isSeekable() const;
- virtual void seek(int position);
- virtual int getLength() const;
- virtual int getPosition() const;
- virtual AUD_Specs getSpecs() const;
- virtual void read(int& length, bool& eos, sample_t* buffer);
-};
-
-#endif //__AUD_SEQUENCERREADER_H__
diff --git a/intern/audaspace/intern/AUD_SilenceFactory.cpp b/intern/audaspace/intern/AUD_SilenceFactory.cpp
deleted file mode 100644
index 85034b316ca..00000000000
--- a/intern/audaspace/intern/AUD_SilenceFactory.cpp
+++ /dev/null
@@ -1,41 +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_SilenceFactory.cpp
- * \ingroup audaspaceintern
- */
-
-
-#include "AUD_SilenceFactory.h"
-#include "AUD_SilenceReader.h"
-#include "AUD_Space.h"
-
-AUD_SilenceFactory::AUD_SilenceFactory()
-{
-}
-
-boost::shared_ptr<AUD_IReader> AUD_SilenceFactory::createReader()
-{
- 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
deleted file mode 100644
index de62a2f94fc..00000000000
--- a/intern/audaspace/intern/AUD_SilenceFactory.h
+++ /dev/null
@@ -1,54 +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_SilenceFactory.h
- * \ingroup audaspaceintern
- */
-
-
-#ifndef __AUD_SILENCEFACTORY_H__
-#define __AUD_SILENCEFACTORY_H__
-
-#include "AUD_IFactory.h"
-
-/**
- * This factory creates a reader that plays silence.
- */
-class AUD_SilenceFactory : public AUD_IFactory
-{
-private:
- // hide copy constructor and operator=
- AUD_SilenceFactory(const AUD_SilenceFactory&);
- AUD_SilenceFactory& operator=(const AUD_SilenceFactory&);
-
-public:
- /**
- * Creates a new silence factory.
- */
- AUD_SilenceFactory();
-
- virtual boost::shared_ptr<AUD_IReader> createReader();
-};
-
-#endif //__AUD_SILENCEFACTORY_H__
diff --git a/intern/audaspace/intern/AUD_SilenceReader.cpp b/intern/audaspace/intern/AUD_SilenceReader.cpp
deleted file mode 100644
index 5d7e83f7f09..00000000000
--- a/intern/audaspace/intern/AUD_SilenceReader.cpp
+++ /dev/null
@@ -1,72 +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_SilenceReader.cpp
- * \ingroup audaspaceintern
- */
-
-
-#include "AUD_SilenceReader.h"
-
-#include <cstring>
-
-AUD_SilenceReader::AUD_SilenceReader() :
- m_position(0)
-{
-}
-
-bool AUD_SilenceReader::isSeekable() const
-{
- return true;
-}
-
-void AUD_SilenceReader::seek(int position)
-{
- m_position = position;
-}
-
-int AUD_SilenceReader::getLength() const
-{
- return -1;
-}
-
-int AUD_SilenceReader::getPosition() const
-{
- return m_position;
-}
-
-AUD_Specs AUD_SilenceReader::getSpecs() const
-{
- AUD_Specs specs;
- specs.rate = AUD_RATE_48000;
- specs.channels = AUD_CHANNELS_MONO;
- return specs;
-}
-
-void AUD_SilenceReader::read(int& length, bool& eos, sample_t* buffer)
-{
- memset(buffer, 0, length * sizeof(sample_t));
- m_position += length;
- eos = false;
-}
diff --git a/intern/audaspace/intern/AUD_SilenceReader.h b/intern/audaspace/intern/AUD_SilenceReader.h
deleted file mode 100644
index cac56a0861b..00000000000
--- a/intern/audaspace/intern/AUD_SilenceReader.h
+++ /dev/null
@@ -1,66 +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_SilenceReader.h
- * \ingroup audaspaceintern
- */
-
-
-#ifndef __AUD_SILENCEREADER_H__
-#define __AUD_SILENCEREADER_H__
-
-#include "AUD_IReader.h"
-#include "AUD_Buffer.h"
-
-/**
- * This class is used for silence playback.
- * The signal generated is 44.1kHz mono.
- */
-class AUD_SilenceReader : public AUD_IReader
-{
-private:
- /**
- * The current position in samples.
- */
- int m_position;
-
- // hide copy constructor and operator=
- AUD_SilenceReader(const AUD_SilenceReader&);
- AUD_SilenceReader& operator=(const AUD_SilenceReader&);
-
-public:
- /**
- * Creates a new reader.
- */
- AUD_SilenceReader();
-
- virtual bool isSeekable() const;
- virtual void seek(int position);
- virtual int getLength() const;
- virtual int getPosition() const;
- virtual AUD_Specs getSpecs() const;
- virtual void read(int& length, bool& eos, sample_t* buffer);
-};
-
-#endif //__AUD_SILENCEREADER_H__
diff --git a/intern/audaspace/intern/AUD_SinusFactory.cpp b/intern/audaspace/intern/AUD_SinusFactory.cpp
deleted file mode 100644
index 2b9742cc90c..00000000000
--- a/intern/audaspace/intern/AUD_SinusFactory.cpp
+++ /dev/null
@@ -1,48 +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_SinusFactory.cpp
- * \ingroup audaspaceintern
- */
-
-
-#include "AUD_SinusFactory.h"
-#include "AUD_SinusReader.h"
-#include "AUD_Space.h"
-
-AUD_SinusFactory::AUD_SinusFactory(float frequency, AUD_SampleRate sampleRate) :
- m_frequency(frequency),
- m_sampleRate(sampleRate)
-{
-}
-
-float AUD_SinusFactory::getFrequency() const
-{
- return m_frequency;
-}
-
-boost::shared_ptr<AUD_IReader> AUD_SinusFactory::createReader()
-{
- 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
deleted file mode 100644
index c8d409a4aff..00000000000
--- a/intern/audaspace/intern/AUD_SinusFactory.h
+++ /dev/null
@@ -1,72 +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_SinusFactory.h
- * \ingroup audaspaceintern
- */
-
-
-#ifndef __AUD_SINUSFACTORY_H__
-#define __AUD_SINUSFACTORY_H__
-
-#include "AUD_IFactory.h"
-
-/**
- * This factory creates a reader that plays a sine tone.
- */
-class AUD_SinusFactory : public AUD_IFactory
-{
-private:
- /**
- * The frequence of the sine wave.
- */
- const float m_frequency;
-
- /**
- * The target sample rate for output.
- */
- const AUD_SampleRate m_sampleRate;
-
- // hide copy constructor and operator=
- AUD_SinusFactory(const AUD_SinusFactory&);
- AUD_SinusFactory& operator=(const AUD_SinusFactory&);
-
-public:
- /**
- * Creates a new sine factory.
- * \param frequency The desired frequency.
- * \param sampleRate The target sample rate for playback.
- */
- AUD_SinusFactory(float frequency,
- AUD_SampleRate sampleRate = AUD_RATE_48000);
-
- /**
- * Returns the frequency of the sine wave.
- */
- float getFrequency() const;
-
- virtual boost::shared_ptr<AUD_IReader> createReader();
-};
-
-#endif //__AUD_SINUSFACTORY_H__
diff --git a/intern/audaspace/intern/AUD_SinusReader.cpp b/intern/audaspace/intern/AUD_SinusReader.cpp
deleted file mode 100644
index 2e89126bd7b..00000000000
--- a/intern/audaspace/intern/AUD_SinusReader.cpp
+++ /dev/null
@@ -1,83 +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_SinusReader.cpp
- * \ingroup audaspaceintern
- */
-
-
-#include "AUD_SinusReader.h"
-
-#include <cmath>
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-AUD_SinusReader::AUD_SinusReader(float frequency, AUD_SampleRate sampleRate) :
- m_frequency(frequency),
- m_position(0),
- m_sampleRate(sampleRate)
-{
-}
-
-bool AUD_SinusReader::isSeekable() const
-{
- return true;
-}
-
-void AUD_SinusReader::seek(int position)
-{
- m_position = position;
-}
-
-int AUD_SinusReader::getLength() const
-{
- return -1;
-}
-
-int AUD_SinusReader::getPosition() const
-{
- return m_position;
-}
-
-AUD_Specs AUD_SinusReader::getSpecs() const
-{
- AUD_Specs specs;
- specs.rate = m_sampleRate;
- specs.channels = AUD_CHANNELS_MONO;
- return specs;
-}
-
-void AUD_SinusReader::read(int& length, bool& eos, sample_t* buffer)
-{
- // fill with sine data
- for(int i = 0; i < length; i++)
- {
- buffer[i] = sin((m_position + i) * 2 * M_PI * m_frequency / m_sampleRate);
- }
-
- m_position += length;
- eos = false;
-}
diff --git a/intern/audaspace/intern/AUD_SinusReader.h b/intern/audaspace/intern/AUD_SinusReader.h
deleted file mode 100644
index 50487ea94aa..00000000000
--- a/intern/audaspace/intern/AUD_SinusReader.h
+++ /dev/null
@@ -1,78 +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_SinusReader.h
- * \ingroup audaspaceintern
- */
-
-
-#ifndef __AUD_SINUSREADER_H__
-#define __AUD_SINUSREADER_H__
-
-#include "AUD_IReader.h"
-#include "AUD_Buffer.h"
-
-/**
- * This class is used for sine tone playback.
- * The sample rate can be specified, the signal is mono.
- */
-class AUD_SinusReader : public AUD_IReader
-{
-private:
- /**
- * The frequency of the sine wave.
- */
- const float m_frequency;
-
- /**
- * The current position in samples.
- */
- int m_position;
-
- /**
- * The sample rate for the output.
- */
- const AUD_SampleRate m_sampleRate;
-
- // hide copy constructor and operator=
- AUD_SinusReader(const AUD_SinusReader&);
- AUD_SinusReader& operator=(const AUD_SinusReader&);
-
-public:
- /**
- * Creates a new reader.
- * \param frequency The frequency of the sine wave.
- * \param sampleRate The output sample rate.
- */
- AUD_SinusReader(float frequency, AUD_SampleRate sampleRate);
-
- virtual bool isSeekable() const;
- virtual void seek(int position);
- virtual int getLength() const;
- virtual int getPosition() const;
- virtual AUD_Specs getSpecs() const;
- virtual void read(int& length, bool& eos, sample_t* buffer);
-};
-
-#endif //__AUD_SINUSREADER_H__
diff --git a/intern/audaspace/intern/AUD_SoftwareDevice.cpp b/intern/audaspace/intern/AUD_SoftwareDevice.cpp
deleted file mode 100644
index f9d65aa2363..00000000000
--- a/intern/audaspace/intern/AUD_SoftwareDevice.cpp
+++ /dev/null
@@ -1,995 +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_SoftwareDevice.cpp
- * \ingroup audaspaceintern
- */
-
-
-#include "AUD_SoftwareDevice.h"
-#include "AUD_IReader.h"
-#include "AUD_Mixer.h"
-#include "AUD_IFactory.h"
-#include "AUD_JOSResampleReader.h"
-#include "AUD_LinearResampleReader.h"
-#include "AUD_MutexLock.h"
-
-#include <cstring>
-#include <cmath>
-#include <limits>
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-typedef enum
-{
- AUD_RENDER_DISTANCE = 0x01,
- AUD_RENDER_DOPPLER = 0x02,
- AUD_RENDER_CONE = 0x04,
- AUD_RENDER_VOLUME = 0x08
-} AUD_RenderFlags;
-
-#define AUD_PITCH_MAX 10
-
-/******************************************************************************/
-/********************** AUD_SoftwareHandle Handle Code ************************/
-/******************************************************************************/
-
-bool AUD_SoftwareDevice::AUD_SoftwareHandle::pause(bool keep)
-{
- if(m_status)
- {
- AUD_MutexLock lock(*m_device);
-
- if(m_status == AUD_STATUS_PLAYING)
- {
- 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;
-
- m_device->m_playingSounds.erase(it);
- m_device->m_pausedSounds.push_back(This);
-
- if(m_device->m_playingSounds.empty())
- m_device->playing(m_device->m_playback = false);
-
- m_status = keep ? AUD_STATUS_STOPPED : AUD_STATUS_PAUSED;
-
- return true;
- }
- }
- }
- }
-
- return false;
-}
-
-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_old_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),
- m_flags(AUD_RENDER_CONE), m_stop(NULL), m_stop_data(NULL), m_status(AUD_STATUS_PLAYING), m_device(device)
-{
-}
-
-void AUD_SoftwareDevice::AUD_SoftwareHandle::update()
-{
- int flags = 0;
-
- m_old_volume = m_volume;
-
- AUD_Vector3 SL;
- if(m_relative)
- SL = -m_location;
- else
- SL = m_device->m_location - m_location;
- float distance = SL * SL;
-
- if(distance > 0)
- distance = sqrt(distance);
- else
- flags |= AUD_RENDER_DOPPLER | AUD_RENDER_DISTANCE;
-
- if(m_pitch->getSpecs().channels != AUD_CHANNELS_MONO)
- {
- m_volume = m_user_volume;
- m_pitch->setPitch(m_user_pitch);
- return;
- }
-
- flags = ~(flags | m_flags | m_device->m_flags);
-
- // Doppler and Pitch
-
- if(flags & AUD_RENDER_DOPPLER)
- {
- float vls;
- if(m_relative)
- vls = 0;
- else
- vls = SL * m_device->m_velocity / distance;
- float vss = SL * m_velocity / distance;
- float max = m_device->m_speed_of_sound / m_device->m_doppler_factor;
- if(vss >= max)
- {
- m_pitch->setPitch(AUD_PITCH_MAX);
- }
- else
- {
- if(vls > max)
- vls = max;
-
- m_pitch->setPitch((m_device->m_speed_of_sound - m_device->m_doppler_factor * vls) / (m_device->m_speed_of_sound - m_device->m_doppler_factor * vss) * m_user_pitch);
- }
- }
- else
- m_pitch->setPitch(m_user_pitch);
-
- if(flags & AUD_RENDER_VOLUME)
- {
- // Distance
-
- if(flags & AUD_RENDER_DISTANCE)
- {
- if(m_device->m_distance_model == AUD_DISTANCE_MODEL_INVERSE_CLAMPED ||
- m_device->m_distance_model == AUD_DISTANCE_MODEL_LINEAR_CLAMPED ||
- m_device->m_distance_model == AUD_DISTANCE_MODEL_EXPONENT_CLAMPED)
- {
- distance = AUD_MAX(AUD_MIN(m_distance_max, distance), m_distance_reference);
- }
-
- switch(m_device->m_distance_model)
- {
- case AUD_DISTANCE_MODEL_INVERSE:
- case AUD_DISTANCE_MODEL_INVERSE_CLAMPED:
- m_volume = m_distance_reference / (m_distance_reference + m_attenuation * (distance - m_distance_reference));
- break;
- case AUD_DISTANCE_MODEL_LINEAR:
- case AUD_DISTANCE_MODEL_LINEAR_CLAMPED:
- {
- float temp = m_distance_max - m_distance_reference;
- if(temp == 0)
- {
- if(distance > m_distance_reference)
- m_volume = 0.0f;
- else
- m_volume = 1.0f;
- }
- else
- m_volume = 1.0f - m_attenuation * (distance - m_distance_reference) / (m_distance_max - m_distance_reference);
- break;
- }
- case AUD_DISTANCE_MODEL_EXPONENT:
- case AUD_DISTANCE_MODEL_EXPONENT_CLAMPED:
- if(m_distance_reference == 0)
- m_volume = 0;
- else
- m_volume = pow(distance / m_distance_reference, -m_attenuation);
- break;
- default:
- m_volume = 1.0f;
- }
- }
- else
- m_volume = 1.0f;
-
- // Cone
-
- if(flags & AUD_RENDER_CONE)
- {
- AUD_Vector3 SZ = m_orientation.getLookAt();
-
- float phi = acos(float(SZ * SL / (SZ.length() * SL.length())));
- float t = (phi - m_cone_angle_inner)/(m_cone_angle_outer - m_cone_angle_inner);
-
- if(t > 0)
- {
- if(t > 1)
- m_volume *= m_cone_volume_outer;
- else
- m_volume *= 1 + t * (m_cone_volume_outer - 1);
- }
- }
-
- if(m_volume > m_volume_max)
- m_volume = m_volume_max;
- else if(m_volume < m_volume_min)
- m_volume = m_volume_min;
-
- // Volume
-
- m_volume *= m_user_volume;
- }
-
- // 3D Cue
-
- AUD_Quaternion orientation;
-
- if(!m_relative)
- orientation = m_device->m_orientation;
-
- AUD_Vector3 Z = orientation.getLookAt();
- AUD_Vector3 N = orientation.getUp();
- AUD_Vector3 A = N * ((SL * N) / (N * N)) - SL;
-
- float Asquare = A * A;
-
- if(Asquare > 0)
- {
- float phi = acos(float(Z * A / (Z.length() * sqrt(Asquare))));
- if(N.cross(Z) * A > 0)
- phi = -phi;
-
- m_mapper->setMonoAngle(phi);
- }
- else
- m_mapper->setMonoAngle(m_relative ? m_user_pan * M_PI / 2.0 : 0);
-}
-
-void AUD_SoftwareDevice::AUD_SoftwareHandle::setSpecs(AUD_Specs specs)
-{
- m_mapper->setChannels(specs.channels);
- m_resampler->setRate(specs.rate);
-}
-
-bool AUD_SoftwareDevice::AUD_SoftwareHandle::pause()
-{
- return pause(false);
-}
-
-bool AUD_SoftwareDevice::AUD_SoftwareHandle::resume()
-{
- if(m_status)
- {
- AUD_MutexLock lock(*m_device);
-
- if(m_status == AUD_STATUS_PAUSED)
- {
- 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;
-
- 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;
- }
- }
- }
-
- }
-
- return false;
-}
-
-bool AUD_SoftwareDevice::AUD_SoftwareHandle::stop()
-{
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return false;
-
- m_status = AUD_STATUS_INVALID;
-
- 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;
-
- m_device->m_playingSounds.erase(it);
-
- if(m_device->m_playingSounds.empty())
- m_device->playing(m_device->m_playback = false);
-
- return true;
- }
- }
-
- for(AUD_HandleIterator it = m_device->m_pausedSounds.begin(); it != m_device->m_pausedSounds.end(); it++)
- {
- if(it->get() == this)
- {
- m_device->m_pausedSounds.erase(it);
- return true;
- }
- }
-
- return false;
-}
-
-bool AUD_SoftwareDevice::AUD_SoftwareHandle::getKeep()
-{
- if(m_status)
- return m_keep;
-
- return false;
-}
-
-bool AUD_SoftwareDevice::AUD_SoftwareHandle::setKeep(bool keep)
-{
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return false;
-
- m_keep = keep;
-
- return true;
-}
-
-bool AUD_SoftwareDevice::AUD_SoftwareHandle::seek(float position)
-{
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return false;
-
- m_pitch->setPitch(m_user_pitch);
- m_reader->seek((int)(position * m_reader->getSpecs().rate));
-
- if(m_status == AUD_STATUS_STOPPED)
- m_status = AUD_STATUS_PAUSED;
-
- return true;
-}
-
-float AUD_SoftwareDevice::AUD_SoftwareHandle::getPosition()
-{
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return 0.0f;
-
- float position = m_reader->getPosition() / (float)m_device->m_specs.rate;
-
- return position;
-}
-
-AUD_Status AUD_SoftwareDevice::AUD_SoftwareHandle::getStatus()
-{
- return m_status;
-}
-
-float AUD_SoftwareDevice::AUD_SoftwareHandle::getVolume()
-{
- return m_user_volume;
-}
-
-bool AUD_SoftwareDevice::AUD_SoftwareHandle::setVolume(float volume)
-{
- if(!m_status)
- return false;
- m_user_volume = volume;
-
- if(volume == 0)
- {
- m_old_volume = m_volume = volume;
- m_flags |= AUD_RENDER_VOLUME;
- }
- else
- m_flags &= ~AUD_RENDER_VOLUME;
-
- return true;
-}
-
-float AUD_SoftwareDevice::AUD_SoftwareHandle::getPitch()
-{
- return m_user_pitch;
-}
-
-bool AUD_SoftwareDevice::AUD_SoftwareHandle::setPitch(float pitch)
-{
- if(!m_status)
- return false;
- if(pitch <= 0)
- pitch = 1;
- m_user_pitch = pitch;
- return true;
-}
-
-int AUD_SoftwareDevice::AUD_SoftwareHandle::getLoopCount()
-{
- if(!m_status)
- return 0;
- return m_loopcount;
-}
-
-bool AUD_SoftwareDevice::AUD_SoftwareHandle::setLoopCount(int count)
-{
- if(!m_status)
- return false;
-
- if(m_status == AUD_STATUS_STOPPED && (count > m_loopcount || count < 0))
- m_status = AUD_STATUS_PAUSED;
-
- m_loopcount = count;
-
- return true;
-}
-
-bool AUD_SoftwareDevice::AUD_SoftwareHandle::setStopCallback(stopCallback callback, void* data)
-{
- if(!m_status)
- return false;
-
- AUD_MutexLock lock(*m_device);
-
- if(!m_status)
- return false;
-
- m_stop = callback;
- m_stop_data = data;
-
- return true;
-}
-
-
-
-/******************************************************************************/
-/******************** AUD_SoftwareHandle 3DHandle Code ************************/
-/******************************************************************************/
-
-AUD_Vector3 AUD_SoftwareDevice::AUD_SoftwareHandle::getSourceLocation()
-{
- if(!m_status)
- return AUD_Vector3();
-
- return m_location;
-}
-
-bool AUD_SoftwareDevice::AUD_SoftwareHandle::setSourceLocation(const AUD_Vector3& location)
-{
- if(!m_status)
- return false;
-
- m_location = location;
-
- return true;
-}
-
-AUD_Vector3 AUD_SoftwareDevice::AUD_SoftwareHandle::getSourceVelocity()
-{
- if(!m_status)
- return AUD_Vector3();
-
- return m_velocity;
-}
-
-bool AUD_SoftwareDevice::AUD_SoftwareHandle::setSourceVelocity(const AUD_Vector3& velocity)
-{
- if(!m_status)
- return false;
-
- m_velocity = velocity;
-
- return true;
-}
-
-AUD_Quaternion AUD_SoftwareDevice::AUD_SoftwareHandle::getSourceOrientation()
-{
- if(!m_status)
- return AUD_Quaternion();
-
- return m_orientation;
-}
-
-bool AUD_SoftwareDevice::AUD_SoftwareHandle::setSourceOrientation(const AUD_Quaternion& orientation)
-{
- if(!m_status)
- return false;
-
- m_orientation = orientation;
-
- return true;
-}
-
-bool AUD_SoftwareDevice::AUD_SoftwareHandle::isRelative()
-{
- if(!m_status)
- return false;
-
- return m_relative;
-}
-
-bool AUD_SoftwareDevice::AUD_SoftwareHandle::setRelative(bool relative)
-{
- if(!m_status)
- return false;
-
- m_relative = relative;
-
- return true;
-}
-
-float AUD_SoftwareDevice::AUD_SoftwareHandle::getVolumeMaximum()
-{
- if(!m_status)
- return std::numeric_limits<float>::quiet_NaN();
-
- return m_volume_max;
-}
-
-bool AUD_SoftwareDevice::AUD_SoftwareHandle::setVolumeMaximum(float volume)
-{
- if(!m_status)
- return false;
-
- m_volume_max = volume;
-
- return true;
-}
-
-float AUD_SoftwareDevice::AUD_SoftwareHandle::getVolumeMinimum()
-{
- if(!m_status)
- return std::numeric_limits<float>::quiet_NaN();
-
- return m_volume_min;
-}
-
-bool AUD_SoftwareDevice::AUD_SoftwareHandle::setVolumeMinimum(float volume)
-{
- if(!m_status)
- return false;
-
- m_volume_min = volume;
-
- return true;
-}
-
-float AUD_SoftwareDevice::AUD_SoftwareHandle::getDistanceMaximum()
-{
- if(!m_status)
- return std::numeric_limits<float>::quiet_NaN();
-
- return m_distance_max;
-}
-
-bool AUD_SoftwareDevice::AUD_SoftwareHandle::setDistanceMaximum(float distance)
-{
- if(!m_status)
- return false;
-
- m_distance_max = distance;
-
- return true;
-}
-
-float AUD_SoftwareDevice::AUD_SoftwareHandle::getDistanceReference()
-{
- if(!m_status)
- return std::numeric_limits<float>::quiet_NaN();
-
- return m_distance_reference;
-}
-
-bool AUD_SoftwareDevice::AUD_SoftwareHandle::setDistanceReference(float distance)
-{
- if(!m_status)
- return false;
-
- m_distance_reference = distance;
-
- return true;
-}
-
-float AUD_SoftwareDevice::AUD_SoftwareHandle::getAttenuation()
-{
- if(!m_status)
- return std::numeric_limits<float>::quiet_NaN();
-
- return m_attenuation;
-}
-
-bool AUD_SoftwareDevice::AUD_SoftwareHandle::setAttenuation(float factor)
-{
- if(!m_status)
- return false;
-
- m_attenuation = factor;
-
- if(factor == 0)
- m_flags |= AUD_RENDER_DISTANCE;
- else
- m_flags &= ~AUD_RENDER_DISTANCE;
-
- return true;
-}
-
-float AUD_SoftwareDevice::AUD_SoftwareHandle::getConeAngleOuter()
-{
- if(!m_status)
- return std::numeric_limits<float>::quiet_NaN();
-
- return m_cone_angle_outer * 360.0f / M_PI;
-}
-
-bool AUD_SoftwareDevice::AUD_SoftwareHandle::setConeAngleOuter(float angle)
-{
- if(!m_status)
- return false;
-
- m_cone_angle_outer = angle * M_PI / 360.0f;
-
- return true;
-}
-
-float AUD_SoftwareDevice::AUD_SoftwareHandle::getConeAngleInner()
-{
- if(!m_status)
- return std::numeric_limits<float>::quiet_NaN();
-
- return m_cone_angle_inner * 360.0f / M_PI;
-}
-
-bool AUD_SoftwareDevice::AUD_SoftwareHandle::setConeAngleInner(float angle)
-{
- if(!m_status)
- return false;
-
- if(angle >= 360)
- m_flags |= AUD_RENDER_CONE;
- else
- m_flags &= ~AUD_RENDER_CONE;
-
- m_cone_angle_inner = angle * M_PI / 360.0f;
-
- return true;
-}
-
-float AUD_SoftwareDevice::AUD_SoftwareHandle::getConeVolumeOuter()
-{
- if(!m_status)
- return std::numeric_limits<float>::quiet_NaN();
-
- return m_cone_volume_outer;
-}
-
-bool AUD_SoftwareDevice::AUD_SoftwareHandle::setConeVolumeOuter(float volume)
-{
- if(!m_status)
- return false;
-
- m_cone_volume_outer = volume;
-
- return true;
-}
-
-/******************************************************************************/
-/**************************** IDevice Code ************************************/
-/******************************************************************************/
-
-void AUD_SoftwareDevice::create()
-{
- m_playback = false;
- m_volume = 1.0f;
- m_mixer = boost::shared_ptr<AUD_Mixer>(new AUD_Mixer(m_specs));
- m_speed_of_sound = 343.3f;
- m_doppler_factor = 1.0f;
- m_distance_model = AUD_DISTANCE_MODEL_INVERSE_CLAMPED;
- m_flags = 0;
- m_quality = false;
-
- 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);
-}
-
-void AUD_SoftwareDevice::destroy()
-{
- if(m_playback)
- playing(m_playback = false);
-
- while(!m_playingSounds.empty())
- m_playingSounds.front()->stop();
-
- while(!m_pausedSounds.empty())
- m_pausedSounds.front()->stop();
-
- pthread_mutex_destroy(&m_mutex);
-}
-
-void AUD_SoftwareDevice::mix(data_t* buffer, int length)
-{
- m_buffer.assureSize(length * AUD_SAMPLE_SIZE(m_specs));
-
- AUD_MutexLock lock(*this);
-
- {
- boost::shared_ptr<AUD_SoftwareDevice::AUD_SoftwareHandle> sound;
- int len;
- int pos;
- bool eos;
- 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);
-
- // for all sounds
- AUD_HandleIterator it = m_playingSounds.begin();
- while(it != m_playingSounds.end())
- {
- sound = *it;
- // increment the iterator to make sure it's valid,
- // in case the sound gets deleted after stopping
- ++it;
-
- // get the buffer from the source
- pos = 0;
- len = length;
-
- // update 3D Info
- sound->update();
-
- sound->m_reader->read(len, eos, buf);
-
- // in case of looping
- while(pos + len < length && sound->m_loopcount && eos)
- {
- m_mixer->mix(buf, pos, len, sound->m_volume, sound->m_old_volume);
-
- pos += len;
-
- if(sound->m_loopcount > 0)
- sound->m_loopcount--;
-
- sound->m_reader->seek(0);
-
- len = length - pos;
- sound->m_reader->read(len, eos, buf);
-
- // prevent endless loop
- if(!len)
- break;
- }
-
- m_mixer->mix(buf, pos, len, sound->m_volume, sound->m_old_volume);
-
- // in case the end of the sound is reached
- if(eos && !sound->m_loopcount)
- {
- if(sound->m_stop)
- sound->m_stop(sound->m_stop_data);
-
- if(sound->m_keep)
- pauseSounds.push_back(sound);
- else
- stopSounds.push_back(sound);
- }
- }
-
- // superpose
- m_mixer->read(buffer, m_volume);
-
- // cleanup
- for(it = pauseSounds.begin(); it != pauseSounds.end(); it++)
- (*it)->pause(true);
-
- for(it = stopSounds.begin(); it != stopSounds.end(); it++)
- (*it)->stop();
-
- pauseSounds.clear();
- stopSounds.clear();
- }
-}
-
-void AUD_SoftwareDevice::setPanning(AUD_IHandle* handle, float pan)
-{
- AUD_SoftwareDevice::AUD_SoftwareHandle* h = dynamic_cast<AUD_SoftwareDevice::AUD_SoftwareHandle*>(handle);
- h->m_user_pan = pan;
-}
-
-void AUD_SoftwareDevice::setQuality(bool quality)
-{
- m_quality = quality;
-}
-
-void AUD_SoftwareDevice::setSpecs(AUD_Specs specs)
-{
- m_specs.specs = specs;
- m_mixer->setSpecs(specs);
-
- for(AUD_HandleIterator it = m_playingSounds.begin(); it != m_playingSounds.end(); it++)
- {
- (*it)->setSpecs(specs);
- }
-}
-
-AUD_DeviceSpecs AUD_SoftwareDevice::getSpecs() const
-{
- return m_specs;
-}
-
-boost::shared_ptr<AUD_IHandle> AUD_SoftwareDevice::play(boost::shared_ptr<AUD_IReader> reader, bool keep)
-{
- // prepare the reader
- // pitch
-
- boost::shared_ptr<AUD_PitchReader> pitch = boost::shared_ptr<AUD_PitchReader>(new AUD_PitchReader(reader, 1));
- reader = boost::shared_ptr<AUD_IReader>(pitch);
-
- boost::shared_ptr<AUD_ResampleReader> resampler;
-
- // resample
- if(m_quality)
- resampler = boost::shared_ptr<AUD_ResampleReader>(new AUD_JOSResampleReader(reader, m_specs.specs));
- else
- resampler = boost::shared_ptr<AUD_ResampleReader>(new AUD_LinearResampleReader(reader, m_specs.specs));
- reader = boost::shared_ptr<AUD_IReader>(resampler);
-
- // rechannel
- 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.get())
- return boost::shared_ptr<AUD_IHandle>();
-
- // play sound
- 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);
-
- m_playingSounds.push_back(sound);
-
- if(!m_playback)
- playing(m_playback = true);
-
- return boost::shared_ptr<AUD_IHandle>(sound);
-}
-
-boost::shared_ptr<AUD_IHandle> AUD_SoftwareDevice::play(boost::shared_ptr<AUD_IFactory> factory, bool keep)
-{
- return play(factory->createReader(), keep);
-}
-
-void AUD_SoftwareDevice::stopAll()
-{
- AUD_MutexLock lock(*this);
-
- while(!m_playingSounds.empty())
- m_playingSounds.front()->stop();
-
- while(!m_pausedSounds.empty())
- m_pausedSounds.front()->stop();
-}
-
-void AUD_SoftwareDevice::lock()
-{
- pthread_mutex_lock(&m_mutex);
-}
-
-void AUD_SoftwareDevice::unlock()
-{
- pthread_mutex_unlock(&m_mutex);
-}
-
-float AUD_SoftwareDevice::getVolume() const
-{
- return m_volume;
-}
-
-void AUD_SoftwareDevice::setVolume(float volume)
-{
- m_volume = volume;
-}
-
-/******************************************************************************/
-/**************************** 3D Device Code **********************************/
-/******************************************************************************/
-
-AUD_Vector3 AUD_SoftwareDevice::getListenerLocation() const
-{
- return m_location;
-}
-
-void AUD_SoftwareDevice::setListenerLocation(const AUD_Vector3& location)
-{
- m_location = location;
-}
-
-AUD_Vector3 AUD_SoftwareDevice::getListenerVelocity() const
-{
- return m_velocity;
-}
-
-void AUD_SoftwareDevice::setListenerVelocity(const AUD_Vector3& velocity)
-{
- m_velocity = velocity;
-}
-
-AUD_Quaternion AUD_SoftwareDevice::getListenerOrientation() const
-{
- return m_orientation;
-}
-
-void AUD_SoftwareDevice::setListenerOrientation(const AUD_Quaternion& orientation)
-{
- m_orientation = orientation;
-}
-
-float AUD_SoftwareDevice::getSpeedOfSound() const
-{
- return m_speed_of_sound;
-}
-
-void AUD_SoftwareDevice::setSpeedOfSound(float speed)
-{
- m_speed_of_sound = speed;
-}
-
-float AUD_SoftwareDevice::getDopplerFactor() const
-{
- return m_doppler_factor;
-}
-
-void AUD_SoftwareDevice::setDopplerFactor(float factor)
-{
- m_doppler_factor = factor;
- if(factor == 0)
- m_flags |= AUD_RENDER_DOPPLER;
- else
- m_flags &= ~AUD_RENDER_DOPPLER;
-}
-
-AUD_DistanceModel AUD_SoftwareDevice::getDistanceModel() const
-{
- return m_distance_model;
-}
-
-void AUD_SoftwareDevice::setDistanceModel(AUD_DistanceModel model)
-{
- m_distance_model = model;
- if(model == AUD_DISTANCE_MODEL_INVALID)
- m_flags |= AUD_RENDER_DISTANCE;
- else
- m_flags &= ~AUD_RENDER_DISTANCE;
-}
diff --git a/intern/audaspace/intern/AUD_Space.h b/intern/audaspace/intern/AUD_Space.h
deleted file mode 100644
index 26bbdc5a8f7..00000000000
--- a/intern/audaspace/intern/AUD_Space.h
+++ /dev/null
@@ -1,257 +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_Space.h
- * \ingroup audaspaceintern
- */
-
-
-#ifndef __AUD_SPACE_H__
-#define __AUD_SPACE_H__
-
-/// The size of a format in bytes.
-#define AUD_FORMAT_SIZE(format) (format & 0x0F)
-/// The size of a sample in the specified device format in bytes.
-#define AUD_DEVICE_SAMPLE_SIZE(specs) (specs.channels * (specs.format & 0x0F))
-/// The size of a sample in the specified format in bytes.
-#define AUD_SAMPLE_SIZE(specs) (specs.channels * sizeof(sample_t))
-/// Throws a AUD_Exception with the provided error code.
-#define AUD_THROW(exception, errorstr) { AUD_Exception e; e.error = exception; e.str = errorstr; throw e; }
-
-/// Compares two audio data specifications.
-#define AUD_COMPARE_SPECS(s1, s2) ((s1.rate == s2.rate) && (s1.channels == s2.channels))
-
-/// Returns the bit for a channel mask.
-#define AUD_CHANNEL_BIT(channel) (0x01 << channel)
-
-/// Returns the smaller of the two values.
-#define AUD_MIN(a, b) (((a) < (b)) ? (a) : (b))
-/// Returns the bigger of the two values.
-#define AUD_MAX(a, b) (((a) > (b)) ? (a) : (b))
-
-// 5 sec * 48000 samples/sec * 4 bytes/sample * 6 channels
-/// The size by which a buffer should be resized if the final extent is unknown.
-#define AUD_BUFFER_RESIZE_BYTES 5760000
-
-/// The default playback buffer size of a device.
-#define AUD_DEFAULT_BUFFER_SIZE 1024
-
-/**
- * The format of a sample.
- * The last 4 bit save the byte count of the format.
- */
-typedef enum
-{
- AUD_FORMAT_INVALID = 0x00, /// Invalid sample format.
- AUD_FORMAT_U8 = 0x01, /// 1 byte unsigned byte.
- AUD_FORMAT_S16 = 0x12, /// 2 byte signed integer.
- AUD_FORMAT_S24 = 0x13, /// 3 byte signed integer.
- AUD_FORMAT_S32 = 0x14, /// 4 byte signed integer.
- AUD_FORMAT_FLOAT32 = 0x24, /// 4 byte float.
- AUD_FORMAT_FLOAT64 = 0x28 /// 8 byte float.
-} AUD_SampleFormat;
-
-/// The channel count.
-typedef enum
-{
- AUD_CHANNELS_INVALID = 0, /// Invalid channel count.
- AUD_CHANNELS_MONO = 1, /// Mono.
- AUD_CHANNELS_STEREO = 2, /// Stereo.
- AUD_CHANNELS_STEREO_LFE = 3, /// Stereo with LFE channel.
- AUD_CHANNELS_SURROUND4 = 4, /// 4 channel surround sound.
- AUD_CHANNELS_SURROUND5 = 5, /// 5 channel surround sound.
- AUD_CHANNELS_SURROUND51 = 6, /// 5.1 surround sound.
- AUD_CHANNELS_SURROUND61 = 7, /// 6.1 surround sound.
- AUD_CHANNELS_SURROUND71 = 8 /// 7.1 surround sound.
-} AUD_Channels;
-
-/// The channel names.
-typedef enum
-{
- AUD_CHANNEL_FRONT_LEFT = 0,
- AUD_CHANNEL_FRONT_RIGHT,
- AUD_CHANNEL_FRONT_CENTER,
- AUD_CHANNEL_LFE,
- AUD_CHANNEL_REAR_LEFT,
- AUD_CHANNEL_REAR_RIGHT,
- AUD_CHANNEL_REAR_CENTER,
- AUD_CHANNEL_SIDE_LEFT,
- AUD_CHANNEL_SIDE_RIGHT,
- AUD_CHANNEL_MAX
-} AUD_Channel;
-
-/**
- * The sample rate tells how many samples are played back within one second.
- * Some exotic formats may use other sample rates than provided here.
- */
-typedef enum
-{
- AUD_RATE_INVALID = 0, /// Invalid sample rate.
- AUD_RATE_8000 = 8000, /// 8000 Hz.
- AUD_RATE_16000 = 16000, /// 16000 Hz.
- AUD_RATE_11025 = 11025, /// 11025 Hz.
- AUD_RATE_22050 = 22050, /// 22050 Hz.
- AUD_RATE_32000 = 32000, /// 32000 Hz.
- AUD_RATE_44100 = 44100, /// 44100 Hz.
- AUD_RATE_48000 = 48000, /// 48000 Hz.
- AUD_RATE_88200 = 88200, /// 88200 Hz.
- AUD_RATE_96000 = 96000, /// 96000 Hz.
- AUD_RATE_192000 = 192000 /// 192000 Hz.
-} AUD_DefaultSampleRate;
-
-/// Status of a playback handle.
-typedef enum
-{
- AUD_STATUS_INVALID = 0, /// Invalid handle. Maybe due to stopping.
- AUD_STATUS_PLAYING, /// Sound is playing.
- AUD_STATUS_PAUSED, /// Sound is being paused.
- AUD_STATUS_STOPPED /// Sound is stopped but kept in the device.
-} AUD_Status;
-
-/// Error codes for exceptions (C++ library) or for return values (C API).
-typedef enum
-{
- AUD_NO_ERROR = 0,
- AUD_ERROR_SPECS,
- AUD_ERROR_PROPS,
- AUD_ERROR_FILE,
- AUD_ERROR_SRC,
- AUD_ERROR_FFMPEG,
- AUD_ERROR_OPENAL,
- AUD_ERROR_SDL,
- AUD_ERROR_JACK
-} AUD_Error;
-
-/// Fading types.
-typedef enum
-{
- AUD_FADE_IN,
- AUD_FADE_OUT
-} AUD_FadeType;
-
-/// Possible distance models for the 3D device.
-typedef enum
-{
- AUD_DISTANCE_MODEL_INVALID = 0,
- AUD_DISTANCE_MODEL_INVERSE,
- AUD_DISTANCE_MODEL_INVERSE_CLAMPED,
- AUD_DISTANCE_MODEL_LINEAR,
- AUD_DISTANCE_MODEL_LINEAR_CLAMPED,
- AUD_DISTANCE_MODEL_EXPONENT,
- AUD_DISTANCE_MODEL_EXPONENT_CLAMPED
-} AUD_DistanceModel;
-
-/// Possible animatable properties for Sequencer Factories and Entries.
-typedef enum
-{
- AUD_AP_VOLUME,
- AUD_AP_PANNING,
- AUD_AP_PITCH,
- AUD_AP_LOCATION,
- AUD_AP_ORIENTATION
-} AUD_AnimateablePropertyType;
-
-/// Container formats for writers.
-typedef enum
-{
- AUD_CONTAINER_INVALID = 0,
- AUD_CONTAINER_AC3,
- AUD_CONTAINER_FLAC,
- AUD_CONTAINER_MATROSKA,
- AUD_CONTAINER_MP2,
- AUD_CONTAINER_MP3,
- AUD_CONTAINER_OGG,
- AUD_CONTAINER_WAV
-} AUD_Container;
-
-/// Audio codecs for writers.
-typedef enum
-{
- AUD_CODEC_INVALID = 0,
- AUD_CODEC_AAC,
- AUD_CODEC_AC3,
- AUD_CODEC_FLAC,
- AUD_CODEC_MP2,
- AUD_CODEC_MP3,
- AUD_CODEC_PCM,
- AUD_CODEC_VORBIS
-} AUD_Codec;
-
-/// Sample type.(float samples)
-typedef float sample_t;
-
-/// Sample data type (format samples)
-typedef unsigned char data_t;
-
-/// Sample rate type.
-typedef double AUD_SampleRate;
-
-/// Specification of a sound source.
-typedef struct
-{
- /// Sample rate in Hz.
- AUD_SampleRate rate;
-
- /// Channel count.
- AUD_Channels channels;
-} AUD_Specs;
-
-/// Specification of a sound device.
-typedef struct
-{
- /// Sample format.
- AUD_SampleFormat format;
-
- union
- {
- struct
- {
- /// Sample rate in Hz.
- AUD_SampleRate rate;
-
- /// Channel count.
- AUD_Channels channels;
- };
- AUD_Specs specs;
- };
-} AUD_DeviceSpecs;
-
-/// Exception structure.
-typedef struct
-{
- /**
- * Error code.
- * \see AUD_Error
- */
- AUD_Error error;
-
- /**
- * Error string.
- */
- const char* str;
-
- // void* userData; - for the case it is needed someday
-} AUD_Exception;
-
-#endif //__AUD_SPACE_H__
diff --git a/intern/audaspace/intern/AUD_StreamBufferFactory.cpp b/intern/audaspace/intern/AUD_StreamBufferFactory.cpp
deleted file mode 100644
index daa714aeec3..00000000000
--- a/intern/audaspace/intern/AUD_StreamBufferFactory.cpp
+++ /dev/null
@@ -1,76 +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_StreamBufferFactory.cpp
- * \ingroup audaspaceintern
- */
-
-
-#include "AUD_StreamBufferFactory.h"
-#include "AUD_BufferReader.h"
-#include "AUD_Buffer.h"
-
-#include <cstring>
-
-AUD_StreamBufferFactory::AUD_StreamBufferFactory(boost::shared_ptr<AUD_IFactory> factory) :
- m_buffer(new AUD_Buffer())
-{
- boost::shared_ptr<AUD_IReader> reader = factory->createReader();
-
- m_specs = reader->getSpecs();
-
- int sample_size = AUD_SAMPLE_SIZE(m_specs);
- int length;
- int index = 0;
- bool eos = false;
-
- // get an approximated size if possible
- int size = reader->getLength();
-
- if(size <= 0)
- size = AUD_BUFFER_RESIZE_BYTES / sample_size;
- else
- size += m_specs.rate;
-
- // as long as the end of the stream is not reached
- while(!eos)
- {
- // increase
- m_buffer->resize(size*sample_size, true);
-
- // read more
- length = size-index;
- reader->read(length, eos, m_buffer->getBuffer() + index * m_specs.channels);
- if(index == m_buffer->getSize() / sample_size)
- size += AUD_BUFFER_RESIZE_BYTES / sample_size;
- index += length;
- }
-
- m_buffer->resize(index * sample_size, true);
-}
-
-boost::shared_ptr<AUD_IReader> AUD_StreamBufferFactory::createReader()
-{
- 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
deleted file mode 100644
index 1bcd73d59b6..00000000000
--- a/intern/audaspace/intern/AUD_StreamBufferFactory.h
+++ /dev/null
@@ -1,71 +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_StreamBufferFactory.h
- * \ingroup audaspaceintern
- */
-
-
-#ifndef __AUD_STREAMBUFFERFACTORY_H__
-#define __AUD_STREAMBUFFERFACTORY_H__
-
-#include "AUD_IFactory.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.
- */
-class AUD_StreamBufferFactory : public AUD_IFactory
-{
-private:
- /**
- * The buffer that holds the audio data.
- */
- boost::shared_ptr<AUD_Buffer> m_buffer;
-
- /**
- * The specification of the samples.
- */
- AUD_Specs m_specs;
-
- // hide copy constructor and operator=
- AUD_StreamBufferFactory(const AUD_StreamBufferFactory&);
- AUD_StreamBufferFactory& operator=(const AUD_StreamBufferFactory&);
-
-public:
- /**
- * Creates the factory and reads the reader created by the factory supplied
- * to the buffer.
- * \param factory The factory that creates the reader for buffering.
- * \exception AUD_Exception Thrown if the reader cannot be created.
- */
- AUD_StreamBufferFactory(boost::shared_ptr<AUD_IFactory> factory);
-
- virtual boost::shared_ptr<AUD_IReader> createReader();
-};
-
-#endif //__AUD_STREAMBUFFERFACTORY_H__
diff --git a/intern/audaspace/jack/AUD_JackDevice.cpp b/intern/audaspace/jack/AUD_JackDevice.cpp
deleted file mode 100644
index cfbf80ac110..00000000000
--- a/intern/audaspace/jack/AUD_JackDevice.cpp
+++ /dev/null
@@ -1,348 +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/jack/AUD_JackDevice.cpp
- * \ingroup audjack
- */
-
-#include "AUD_JackDevice.h"
-#include "AUD_IReader.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-
-void* AUD_JackDevice::runMixingThread(void* device)
-{
- ((AUD_JackDevice*)device)->updateRingBuffers();
- return NULL;
-}
-
-void AUD_JackDevice::updateRingBuffers()
-{
- size_t size, temp;
- unsigned int samplesize = AUD_SAMPLE_SIZE(m_specs);
- unsigned int i, j;
- unsigned int channels = m_specs.channels;
- sample_t* buffer = m_buffer.getBuffer();
- float* deinterleave = m_deinterleavebuf.getBuffer();
- jack_transport_state_t state;
- jack_position_t position;
-
- pthread_mutex_lock(&m_mixingLock);
- while(m_valid)
- {
- if(m_sync > 1)
- {
- if(m_syncFunc)
- {
- state = AUD_jack_transport_query(m_client, &position);
- m_syncFunc(m_syncFuncData, state != JackTransportStopped, position.frame / (float) m_specs.rate);
- }
-
- for(i = 0; i < channels; i++)
- AUD_jack_ringbuffer_reset(m_ringbuffers[i]);
- }
-
- size = AUD_jack_ringbuffer_write_space(m_ringbuffers[0]);
- for(i = 1; i < channels; i++)
- if((temp = AUD_jack_ringbuffer_write_space(m_ringbuffers[i])) < size)
- size = temp;
-
- while(size > samplesize)
- {
- size /= samplesize;
- mix((data_t*)buffer, size);
- for(i = 0; i < channels; i++)
- {
- for(j = 0; j < size; j++)
- deinterleave[i * size + j] = buffer[i + j * channels];
- AUD_jack_ringbuffer_write(m_ringbuffers[i], (char*)(deinterleave + i * size), size * sizeof(float));
- }
-
- size = AUD_jack_ringbuffer_write_space(m_ringbuffers[0]);
- for(i = 1; i < channels; i++)
- if((temp = AUD_jack_ringbuffer_write_space(m_ringbuffers[i])) < size)
- size = temp;
- }
-
- if(m_sync > 1)
- {
- m_sync = 3;
- }
-
- pthread_cond_wait(&m_mixingCondition, &m_mixingLock);
- }
- pthread_mutex_unlock(&m_mixingLock);
-}
-
-int AUD_JackDevice::jack_mix(jack_nframes_t length, void *data)
-{
- AUD_JackDevice* device = (AUD_JackDevice*)data;
- unsigned int i;
- int count = device->m_specs.channels;
- char* buffer;
-
- if(device->m_sync)
- {
- // play silence while syncing
- for(unsigned int i = 0; i < count; i++)
- memset(AUD_jack_port_get_buffer(device->m_ports[i], length), 0, length * sizeof(float));
- }
- else
- {
- size_t temp;
- size_t readsamples = AUD_jack_ringbuffer_read_space(device->m_ringbuffers[0]);
- for(i = 1; i < count; i++)
- if((temp = AUD_jack_ringbuffer_read_space(device->m_ringbuffers[i])) < readsamples)
- readsamples = temp;
-
- readsamples = AUD_MIN(readsamples / sizeof(float), length);
-
- for(unsigned int i = 0; i < count; i++)
- {
- buffer = (char*)AUD_jack_port_get_buffer(device->m_ports[i], length);
- AUD_jack_ringbuffer_read(device->m_ringbuffers[i], buffer, readsamples * sizeof(float));
- if(readsamples < length)
- memset(buffer + readsamples * sizeof(float), 0, (length - readsamples) * sizeof(float));
- }
-
- if(pthread_mutex_trylock(&(device->m_mixingLock)) == 0)
- {
- pthread_cond_signal(&(device->m_mixingCondition));
- pthread_mutex_unlock(&(device->m_mixingLock));
- }
- }
-
- return 0;
-}
-
-int AUD_JackDevice::jack_sync(jack_transport_state_t state, jack_position_t* pos, void* data)
-{
- AUD_JackDevice* device = (AUD_JackDevice*)data;
-
- if(state == JackTransportStopped)
- return 1;
-
- if(pthread_mutex_trylock(&(device->m_mixingLock)) == 0)
- {
- if(device->m_sync > 2)
- {
- if(device->m_sync == 3)
- {
- device->m_sync = 0;
- pthread_mutex_unlock(&(device->m_mixingLock));
- return 1;
- }
- }
- else
- {
- device->m_sync = 2;
- pthread_cond_signal(&(device->m_mixingCondition));
- }
- pthread_mutex_unlock(&(device->m_mixingLock));
- }
- else if(!device->m_sync)
- device->m_sync = 1;
-
- return 0;
-}
-
-void AUD_JackDevice::jack_shutdown(void *data)
-{
- AUD_JackDevice* device = (AUD_JackDevice*)data;
- device->m_valid = false;
-}
-
-static const char* clientopen_error = "AUD_JackDevice: Couldn't connect to "
- "jack server.";
-static const char* port_error = "AUD_JackDevice: Couldn't create output port.";
-static const char* activate_error = "AUD_JackDevice: Couldn't activate the "
- "client.";
-
-AUD_JackDevice::AUD_JackDevice(std::string name, AUD_DeviceSpecs specs, int buffersize)
-{
- if(specs.channels == AUD_CHANNELS_INVALID)
- specs.channels = AUD_CHANNELS_STEREO;
-
- // jack uses floats
- m_specs = specs;
- m_specs.format = AUD_FORMAT_FLOAT32;
-
- jack_options_t options = JackNullOption;
- jack_status_t status;
-
- // open client
- m_client = AUD_jack_client_open(name.c_str(), options, &status);
- if(m_client == NULL)
- AUD_THROW(AUD_ERROR_JACK, clientopen_error);
-
- // set callbacks
- AUD_jack_set_process_callback(m_client, AUD_JackDevice::jack_mix, this);
- AUD_jack_on_shutdown(m_client, AUD_JackDevice::jack_shutdown, this);
- AUD_jack_set_sync_callback(m_client, AUD_JackDevice::jack_sync, this);
-
- // register our output channels which are called ports in jack
- m_ports = new jack_port_t*[m_specs.channels];
-
- try
- {
- char portname[64];
- for(int i = 0; i < m_specs.channels; i++)
- {
- sprintf(portname, "out %d", i+1);
- m_ports[i] = AUD_jack_port_register(m_client, portname,
- JACK_DEFAULT_AUDIO_TYPE,
- JackPortIsOutput, 0);
- if(m_ports[i] == NULL)
- AUD_THROW(AUD_ERROR_JACK, port_error);
- }
- }
- catch(AUD_Exception&)
- {
- AUD_jack_client_close(m_client);
- delete[] m_ports;
- throw;
- }
-
- m_specs.rate = (AUD_SampleRate)AUD_jack_get_sample_rate(m_client);
-
- buffersize *= sizeof(sample_t);
- m_ringbuffers = new jack_ringbuffer_t*[specs.channels];
- for(unsigned int i = 0; i < specs.channels; i++)
- m_ringbuffers[i] = AUD_jack_ringbuffer_create(buffersize);
- buffersize *= specs.channels;
- m_deinterleavebuf.resize(buffersize);
- m_buffer.resize(buffersize);
-
- create();
-
- m_valid = true;
- m_sync = 0;
- m_syncFunc = NULL;
- m_nextState = m_state = AUD_jack_transport_query(m_client, NULL);
-
- pthread_mutex_init(&m_mixingLock, NULL);
- pthread_cond_init(&m_mixingCondition, NULL);
-
- // activate the client
- if(AUD_jack_activate(m_client))
- {
- AUD_jack_client_close(m_client);
- delete[] m_ports;
- for(unsigned int i = 0; i < specs.channels; i++)
- AUD_jack_ringbuffer_free(m_ringbuffers[i]);
- delete[] m_ringbuffers;
- pthread_mutex_destroy(&m_mixingLock);
- pthread_cond_destroy(&m_mixingCondition);
- destroy();
-
- AUD_THROW(AUD_ERROR_JACK, activate_error);
- }
-
- const char** ports = AUD_jack_get_ports(m_client, NULL, NULL,
- JackPortIsPhysical | JackPortIsInput);
- if(ports != NULL)
- {
- for(int i = 0; i < m_specs.channels && ports[i]; i++)
- AUD_jack_connect(m_client, AUD_jack_port_name(m_ports[i]), ports[i]);
-
- free(ports);
- }
-
- pthread_attr_t attr;
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
-
- pthread_create(&m_mixingThread, &attr, runMixingThread, this);
-
- pthread_attr_destroy(&attr);
-}
-
-AUD_JackDevice::~AUD_JackDevice()
-{
- if(m_valid)
- AUD_jack_client_close(m_client);
- m_valid = false;
-
- delete[] m_ports;
-
- pthread_mutex_lock(&m_mixingLock);
- pthread_cond_signal(&m_mixingCondition);
- pthread_mutex_unlock(&m_mixingLock);
- pthread_join(m_mixingThread, NULL);
-
- pthread_cond_destroy(&m_mixingCondition);
- pthread_mutex_destroy(&m_mixingLock);
- for(unsigned int i = 0; i < m_specs.channels; i++)
- AUD_jack_ringbuffer_free(m_ringbuffers[i]);
- delete[] m_ringbuffers;
-
- destroy();
-}
-
-void AUD_JackDevice::playing(bool playing)
-{
- // Do nothing.
-}
-
-void AUD_JackDevice::startPlayback()
-{
- AUD_jack_transport_start(m_client);
- m_nextState = JackTransportRolling;
-}
-
-void AUD_JackDevice::stopPlayback()
-{
- AUD_jack_transport_stop(m_client);
- m_nextState = JackTransportStopped;
-}
-
-void AUD_JackDevice::seekPlayback(float time)
-{
- if(time >= 0.0f)
- AUD_jack_transport_locate(m_client, time * m_specs.rate);
-}
-
-void AUD_JackDevice::setSyncCallback(AUD_syncFunction sync, void* data)
-{
- m_syncFunc = sync;
- m_syncFuncData = data;
-}
-
-float AUD_JackDevice::getPlaybackPosition()
-{
- jack_position_t position;
- AUD_jack_transport_query(m_client, &position);
- return position.frame / (float) m_specs.rate;
-}
-
-bool AUD_JackDevice::doesPlayback()
-{
- jack_transport_state_t state = AUD_jack_transport_query(m_client, NULL);
-
- if(state != m_state)
- m_nextState = m_state = state;
-
- return m_nextState != JackTransportStopped;
-}
diff --git a/intern/audaspace/jack/AUD_JackLibrary.cpp b/intern/audaspace/jack/AUD_JackLibrary.cpp
deleted file mode 100644
index 9ed6862bbb9..00000000000
--- a/intern/audaspace/jack/AUD_JackLibrary.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * Copyright 2013 Blender Foundation
- *
- * 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/jack/AUD_JackLibrary.cpp
- * \ingroup audjack
- */
-
-#define AUD_JACK_LIBRARY_IMPL
-
-#include "AUD_JackLibrary.h"
-
-#ifdef WITH_JACK_DYNLOAD
-# include <dlfcn.h>
-# include <stdio.h>
-#endif
-
-#ifdef WITH_JACK_DYNLOAD
-static void *jack_handle = NULL;
-#endif
-
-static bool jack_supported = false;
-
-void AUD_jack_init(void)
-{
-#ifdef WITH_JACK_DYNLOAD
- const char *names[] = {"libjack.so",
- "libjack.so.0",
- "libjack.so.1",
- "libjack.so.2",
- NULL};
- int index = 0;
- while (names[index] != NULL) {
- jack_handle = dlopen(names[index], RTLD_LAZY);
- if (jack_handle != NULL) {
- // Found existing library.
- break;
- }
- ++index;
- }
-
- if (!jack_handle) {
- return;
- }
-
-# define JACK_SYMBOL(sym) \
- { \
- char *error; \
- *(void **) (&(AUD_##sym)) = dlsym(jack_handle, #sym); \
- if ((error = dlerror()) != NULL) { \
- fprintf(stderr, "%s\n", error); \
- return; \
- } \
- } (void)0
-
- dlerror(); /* Clear any existing error */
-#else // WITH_JACK_DYNLOAD
-# define JACK_SYMBOL(sym) AUD_##sym = sym
-#endif // WITH_JACK_DYNLOAD
-
- JACK_SYMBOL(jack_transport_query);
- JACK_SYMBOL(jack_transport_locate);
-
- JACK_SYMBOL(jack_transport_start);
- JACK_SYMBOL(jack_transport_stop);
-
- JACK_SYMBOL(jack_ringbuffer_reset);
- JACK_SYMBOL(jack_ringbuffer_write);
- JACK_SYMBOL(jack_ringbuffer_write_space);
- JACK_SYMBOL(jack_ringbuffer_write_advance);
- JACK_SYMBOL(jack_ringbuffer_read);
- JACK_SYMBOL(jack_ringbuffer_create);
- JACK_SYMBOL(jack_ringbuffer_free);
- JACK_SYMBOL(jack_ringbuffer_read_space);
- JACK_SYMBOL(jack_set_sync_callback);
-
- JACK_SYMBOL(jack_port_get_buffer);
-
- JACK_SYMBOL(jack_client_open);
- JACK_SYMBOL(jack_set_process_callback);
- JACK_SYMBOL(jack_on_shutdown);
- JACK_SYMBOL(jack_port_register);
- JACK_SYMBOL(jack_client_close);
- JACK_SYMBOL(jack_get_sample_rate);
- JACK_SYMBOL(jack_activate);
- JACK_SYMBOL(jack_get_ports);
- JACK_SYMBOL(jack_port_name);
- JACK_SYMBOL(jack_connect);
-
- jack_supported = true;
-
-#undef JACK_SYMBOL
-}
-
-void AUD_jack_exit(void)
-{
-#ifdef WITH_JACK_DYNLOAD
- if (jack_handle) {
- dlclose(jack_handle);
- }
-#endif
- jack_supported = false;
-}
-
-bool AUD_jack_supported(void)
-{
- return jack_supported;
-}
diff --git a/intern/audaspace/jack/AUD_JackLibrary.h b/intern/audaspace/jack/AUD_JackLibrary.h
deleted file mode 100644
index d74d9ba8021..00000000000
--- a/intern/audaspace/jack/AUD_JackLibrary.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * Copyright 2013 Blender Foundation
- *
- * 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/jack/AUD_JackLibrary.cpp
- * \ingroup audjack
- */
-
-#ifndef __AUD_JACKLIBRARY__
-#define __AUD_JACKLIBRARY__
-
-#if defined(__APPLE__) // always first include for jack weaklinking !
-#include <weakjack.h>
-#endif
-
-#include <jack.h>
-#include <ringbuffer.h>
-
-#ifdef AUD_JACK_LIBRARY_IMPL
-# define JACK_SYM
-#else
-# define JACK_SYM extern
-#endif
-
-/* All loadable JACK sumbols, prototypes from original jack.h */
-
-JACK_SYM jack_transport_state_t (*AUD_jack_transport_query) (
- const jack_client_t *client,
- jack_position_t *pos);
-
-JACK_SYM int (*AUD_jack_transport_locate) (jack_client_t *client,
- jack_nframes_t frame);
-
-JACK_SYM void (*AUD_jack_transport_start) (jack_client_t *client);
-JACK_SYM void (*AUD_jack_transport_stop) (jack_client_t *client);
-
-JACK_SYM void (*AUD_jack_ringbuffer_reset) (jack_ringbuffer_t *rb);
-JACK_SYM size_t (*AUD_jack_ringbuffer_write) (jack_ringbuffer_t *rb,
- const char *src, size_t cnt);
-JACK_SYM size_t (*AUD_jack_ringbuffer_write_space) (const jack_ringbuffer_t *rb);
-JACK_SYM void (*AUD_jack_ringbuffer_write_advance) (jack_ringbuffer_t *rb,
- size_t cnt);
-JACK_SYM size_t (*AUD_jack_ringbuffer_read) (jack_ringbuffer_t *rb, char *dest,
- size_t cnt);
-JACK_SYM jack_ringbuffer_t *(*AUD_jack_ringbuffer_create) (size_t sz);
-JACK_SYM void (*AUD_jack_ringbuffer_free) (jack_ringbuffer_t *rb);
-JACK_SYM size_t (*AUD_jack_ringbuffer_read_space) (const jack_ringbuffer_t *rb);
-JACK_SYM int (*AUD_jack_set_sync_callback) (jack_client_t *client,
- JackSyncCallback sync_callback,
- void *arg);
-
-JACK_SYM void *(*AUD_jack_port_get_buffer) (jack_port_t *, jack_nframes_t);
-
-JACK_SYM jack_client_t *(*AUD_jack_client_open) (const char *client_name,
- jack_options_t options,
- jack_status_t *status, ...);
-JACK_SYM int (*AUD_jack_set_process_callback) (jack_client_t *client,
- JackProcessCallback process_callback, void *arg);
-JACK_SYM void (*AUD_jack_on_shutdown) (jack_client_t *client,
- JackShutdownCallback function, void *arg);
-JACK_SYM jack_port_t *(*AUD_jack_port_register) (jack_client_t *client,
- const char *port_name,
- const char *port_type,
- unsigned long flags,
- unsigned long buffer_size);
-JACK_SYM int (*AUD_jack_client_close) (jack_client_t *client);
-JACK_SYM jack_nframes_t (*AUD_jack_get_sample_rate) (jack_client_t *);
-JACK_SYM int (*AUD_jack_activate) (jack_client_t *client);
-JACK_SYM const char **(*AUD_jack_get_ports) (jack_client_t *,
- const char *port_name_pattern,
- const char *type_name_pattern,
- unsigned long flags);
-JACK_SYM const char *(*AUD_jack_port_name) (const jack_port_t *port);
-JACK_SYM int (*AUD_jack_connect) (jack_client_t *,
- const char *source_port,
- const char *destination_port);
-
-/* Public API */
-
-void AUD_jack_init(void);
-void AUD_jack_exit(void);
-bool AUD_jack_supported(void);
-
-#endif // __AUD_JACKLIBRARY__
diff --git a/intern/audaspace/sndfile/AUD_SndFileFactory.cpp b/intern/audaspace/sndfile/AUD_SndFileFactory.cpp
deleted file mode 100644
index 106b2937a06..00000000000
--- a/intern/audaspace/sndfile/AUD_SndFileFactory.cpp
+++ /dev/null
@@ -1,52 +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/sndfile/AUD_SndFileFactory.cpp
- * \ingroup audsndfile
- */
-
-
-#include "AUD_SndFileFactory.h"
-#include "AUD_SndFileReader.h"
-
-#include <cstring>
-
-AUD_SndFileFactory::AUD_SndFileFactory(std::string filename) :
- m_filename(filename)
-{
-}
-
-AUD_SndFileFactory::AUD_SndFileFactory(const data_t* buffer, int size) :
- m_buffer(new AUD_Buffer(size))
-{
- memcpy(m_buffer->getBuffer(), buffer, size);
-}
-
-boost::shared_ptr<AUD_IReader> AUD_SndFileFactory::createReader()
-{
- if(m_buffer.get())
- return boost::shared_ptr<AUD_IReader>(new AUD_SndFileReader(m_buffer));
- else
- 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
deleted file mode 100644
index bc96325d6eb..00000000000
--- a/intern/audaspace/sndfile/AUD_SndFileFactory.h
+++ /dev/null
@@ -1,76 +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/sndfile/AUD_SndFileFactory.h
- * \ingroup audsndfile
- */
-
-
-#ifndef __AUD_SNDFILEFACTORY_H__
-#define __AUD_SNDFILEFACTORY_H__
-
-#include "AUD_IFactory.h"
-#include "AUD_Buffer.h"
-
-#include <string>
-#include <boost/shared_ptr.hpp>
-
-/**
- * This factory reads a sound file via libsndfile.
- */
-class AUD_SndFileFactory : public AUD_IFactory
-{
-private:
- /**
- * The filename of the sound source file.
- */
- std::string m_filename;
-
- /**
- * The buffer to read from.
- */
- boost::shared_ptr<AUD_Buffer> m_buffer;
-
- // hide copy constructor and operator=
- AUD_SndFileFactory(const AUD_SndFileFactory&);
- AUD_SndFileFactory& operator=(const AUD_SndFileFactory&);
-
-public:
- /**
- * Creates a new factory.
- * \param filename The sound file path.
- */
- AUD_SndFileFactory(std::string filename);
-
- /**
- * Creates a new factory.
- * \param buffer The buffer to read from.
- * \param size The size of the buffer.
- */
- AUD_SndFileFactory(const data_t* buffer, int size);
-
- 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
deleted file mode 100644
index aaee814f56b..00000000000
--- a/intern/audaspace/sndfile/AUD_SndFileReader.cpp
+++ /dev/null
@@ -1,171 +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/sndfile/AUD_SndFileReader.cpp
- * \ingroup audsndfile
- */
-
-
-#include "AUD_SndFileReader.h"
-
-#include <cstring>
-
-sf_count_t AUD_SndFileReader::vio_get_filelen(void *user_data)
-{
- AUD_SndFileReader* reader = (AUD_SndFileReader*)user_data;
- return reader->m_membuffer->getSize();
-}
-
-sf_count_t AUD_SndFileReader::vio_seek(sf_count_t offset, int whence,
- void *user_data)
-{
- AUD_SndFileReader* reader = (AUD_SndFileReader*)user_data;
-
- switch(whence)
- {
- case SEEK_SET:
- reader->m_memoffset = offset;
- break;
- case SEEK_CUR:
- reader->m_memoffset = reader->m_memoffset + offset;
- break;
- case SEEK_END:
- reader->m_memoffset = reader->m_membuffer->getSize() + offset;
- break;
- }
-
- return reader->m_memoffset;
-}
-
-sf_count_t AUD_SndFileReader::vio_read(void *ptr, sf_count_t count,
- void *user_data)
-{
- AUD_SndFileReader* reader = (AUD_SndFileReader*)user_data;
-
- if(reader->m_memoffset + count > reader->m_membuffer->getSize())
- count = reader->m_membuffer->getSize() - reader->m_memoffset;
-
- memcpy(ptr, ((data_t*)reader->m_membuffer->getBuffer()) +
- reader->m_memoffset, count);
- reader->m_memoffset += count;
-
- return count;
-}
-
-sf_count_t AUD_SndFileReader::vio_tell(void *user_data)
-{
- AUD_SndFileReader* reader = (AUD_SndFileReader*)user_data;
-
- return reader->m_memoffset;
-}
-
-static const char* fileopen_error = "AUD_SndFileReader: File couldn't be "
- "read.";
-
-AUD_SndFileReader::AUD_SndFileReader(std::string filename) :
- m_position(0)
-{
- SF_INFO sfinfo;
-
- sfinfo.format = 0;
- m_sndfile = sf_open(filename.c_str(), SFM_READ, &sfinfo);
-
- if(!m_sndfile)
- AUD_THROW(AUD_ERROR_FILE, fileopen_error);
-
- m_specs.channels = (AUD_Channels) sfinfo.channels;
- m_specs.rate = (AUD_SampleRate) sfinfo.samplerate;
- m_length = sfinfo.frames;
- m_seekable = sfinfo.seekable;
-}
-
-AUD_SndFileReader::AUD_SndFileReader(boost::shared_ptr<AUD_Buffer> buffer) :
- m_position(0),
- m_membuffer(buffer),
- m_memoffset(0)
-{
- m_vio.get_filelen = vio_get_filelen;
- m_vio.read = vio_read;
- m_vio.seek = vio_seek;
- m_vio.tell = vio_tell;
- m_vio.write = NULL;
-
- SF_INFO sfinfo;
-
- sfinfo.format = 0;
- m_sndfile = sf_open_virtual(&m_vio, SFM_READ, &sfinfo, this);
-
- if(!m_sndfile)
- AUD_THROW(AUD_ERROR_FILE, fileopen_error);
-
- m_specs.channels = (AUD_Channels) sfinfo.channels;
- m_specs.rate = (AUD_SampleRate) sfinfo.samplerate;
- m_length = sfinfo.frames;
- m_seekable = sfinfo.seekable;
-}
-
-AUD_SndFileReader::~AUD_SndFileReader()
-{
- sf_close(m_sndfile);
-}
-
-bool AUD_SndFileReader::isSeekable() const
-{
- return m_seekable;
-}
-
-void AUD_SndFileReader::seek(int position)
-{
- if(m_seekable)
- {
- position = sf_seek(m_sndfile, position, SEEK_SET);
- m_position = position;
- }
-}
-
-int AUD_SndFileReader::getLength() const
-{
- return m_length;
-}
-
-int AUD_SndFileReader::getPosition() const
-{
- return m_position;
-}
-
-AUD_Specs AUD_SndFileReader::getSpecs() const
-{
- return m_specs;
-}
-
-void AUD_SndFileReader::read(int& length, bool& eos, sample_t* buffer)
-{
- int olen = length;
-
- length = sf_readf_float(m_sndfile, buffer, length);
-
- m_position += length;
-
- eos = length < olen;
-}
diff --git a/intern/audaspace/sndfile/AUD_SndFileReader.h b/intern/audaspace/sndfile/AUD_SndFileReader.h
deleted file mode 100644
index 5cac5051ee2..00000000000
--- a/intern/audaspace/sndfile/AUD_SndFileReader.h
+++ /dev/null
@@ -1,128 +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/sndfile/AUD_SndFileReader.h
- * \ingroup audsndfile
- */
-
-
-#ifndef __AUD_SNDFILEREADER_H__
-#define __AUD_SNDFILEREADER_H__
-
-#include "AUD_IReader.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);
-
-/**
- * This class reads a sound file via libsndfile.
- */
-class AUD_SndFileReader : public AUD_IReader
-{
-private:
- /**
- * The current position in samples.
- */
- int m_position;
-
- /**
- * The sample count in the file.
- */
- int m_length;
-
- /**
- * Whether the file is seekable.
- */
- bool m_seekable;
-
- /**
- * The specification of the audio data.
- */
- AUD_Specs m_specs;
-
- /**
- * The sndfile.
- */
- SNDFILE* m_sndfile;
-
- /**
- * The virtual IO structure for memory file reading.
- */
- SF_VIRTUAL_IO m_vio;
-
- /**
- * The pointer to the memory file.
- */
- boost::shared_ptr<AUD_Buffer> m_membuffer;
-
- /**
- * The current reading pointer of the memory file.
- */
- int m_memoffset;
-
- // Functions for libsndfile virtual IO functionality
- static sf_count_t vio_get_filelen(void *user_data);
- static sf_count_t vio_seek(sf_count_t offset, int whence, void *user_data);
- static sf_count_t vio_read(void *ptr, sf_count_t count, void *user_data);
- static sf_count_t vio_tell(void *user_data);
-
- // hide copy constructor and operator=
- AUD_SndFileReader(const AUD_SndFileReader&);
- AUD_SndFileReader& operator=(const AUD_SndFileReader&);
-
-public:
- /**
- * Creates a new reader.
- * \param filename The path to the file to be read.
- * \exception AUD_Exception Thrown if the file specified does not exist or
- * cannot be read with libsndfile.
- */
- AUD_SndFileReader(std::string filename);
-
- /**
- * Creates a new reader.
- * \param buffer The buffer to read from.
- * \exception AUD_Exception Thrown if the buffer specified cannot be read
- * with libsndfile.
- */
- AUD_SndFileReader(boost::shared_ptr<AUD_Buffer> buffer);
-
- /**
- * Destroys the reader and closes the file.
- */
- virtual ~AUD_SndFileReader();
-
- virtual bool isSeekable() const;
- virtual void seek(int position);
- virtual int getLength() const;
- virtual int getPosition() const;
- virtual AUD_Specs getSpecs() const;
- virtual void read(int& length, bool& eos, sample_t* buffer);
-};
-
-#endif //__AUD_SNDFILEREADER_H__
diff --git a/intern/audaspace/sndfile/AUD_SndFileWriter.cpp b/intern/audaspace/sndfile/AUD_SndFileWriter.cpp
deleted file mode 100644
index da3464751cb..00000000000
--- a/intern/audaspace/sndfile/AUD_SndFileWriter.cpp
+++ /dev/null
@@ -1,139 +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/sndfile/AUD_SndFileWriter.cpp
- * \ingroup audsndfile
- */
-
-
-#include "AUD_SndFileWriter.h"
-
-#include <cstring>
-
-static const char* fileopen_error = "AUD_SndFileWriter: File couldn't be written.";
-static const char* format_error = "AUD_SndFileWriter: Unsupported format.";
-
-AUD_SndFileWriter::AUD_SndFileWriter(std::string filename, AUD_DeviceSpecs specs,
- AUD_Container format, AUD_Codec codec, unsigned int bitrate) :
- m_specs(specs)
-{
- SF_INFO sfinfo;
-
- sfinfo.channels = specs.channels;
- sfinfo.samplerate = int(specs.rate);
-
- switch(format)
- {
- case AUD_CONTAINER_FLAC:
- sfinfo.format = SF_FORMAT_FLAC;
- switch(specs.format)
- {
- case AUD_FORMAT_S16:
- sfinfo.format |= SF_FORMAT_PCM_16;
- break;
- case AUD_FORMAT_S24:
- sfinfo.format |= SF_FORMAT_PCM_24;
- break;
- case AUD_FORMAT_S32:
- sfinfo.format |= SF_FORMAT_PCM_32;
- break;
- case AUD_FORMAT_FLOAT32:
- sfinfo.format |= SF_FORMAT_FLOAT;
- break;
- case AUD_FORMAT_FLOAT64:
- sfinfo.format |= SF_FORMAT_DOUBLE;
- break;
- default:
- sfinfo.format = 0;
- break;
- }
- break;
- case AUD_CONTAINER_OGG:
- if(codec == AUD_CODEC_VORBIS)
- sfinfo.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS;
- else
- sfinfo.format = 0;
- break;
- case AUD_CONTAINER_WAV:
- sfinfo.format = SF_FORMAT_WAV;
- switch(specs.format)
- {
- case AUD_FORMAT_U8:
- sfinfo.format |= SF_FORMAT_PCM_U8;
- break;
- case AUD_FORMAT_S16:
- sfinfo.format |= SF_FORMAT_PCM_16;
- break;
- case AUD_FORMAT_S24:
- sfinfo.format |= SF_FORMAT_PCM_24;
- break;
- case AUD_FORMAT_S32:
- sfinfo.format |= SF_FORMAT_PCM_32;
- break;
- case AUD_FORMAT_FLOAT32:
- sfinfo.format |= SF_FORMAT_FLOAT;
- break;
- case AUD_FORMAT_FLOAT64:
- sfinfo.format |= SF_FORMAT_DOUBLE;
- break;
- default:
- sfinfo.format = 0;
- break;
- }
- break;
- default:
- sfinfo.format = 0;
- break;
- }
-
- if(sfinfo.format == 0)
- AUD_THROW(AUD_ERROR_SPECS, format_error);
-
- m_sndfile = sf_open(filename.c_str(), SFM_WRITE, &sfinfo);
-
- if(!m_sndfile)
- AUD_THROW(AUD_ERROR_FILE, fileopen_error);
-}
-
-AUD_SndFileWriter::~AUD_SndFileWriter()
-{
- sf_close(m_sndfile);
-}
-
-int AUD_SndFileWriter::getPosition() const
-{
- return m_position;
-}
-
-AUD_DeviceSpecs AUD_SndFileWriter::getSpecs() const
-{
- return m_specs;
-}
-
-void AUD_SndFileWriter::write(unsigned int length, sample_t* buffer)
-{
- length = sf_writef_float(m_sndfile, buffer, length);
-
- m_position += length;
-}
diff --git a/intern/audaspace/sndfile/AUD_SndFileWriter.h b/intern/audaspace/sndfile/AUD_SndFileWriter.h
deleted file mode 100644
index 0cadbd19a09..00000000000
--- a/intern/audaspace/sndfile/AUD_SndFileWriter.h
+++ /dev/null
@@ -1,86 +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/sndfile/AUD_SndFileWriter.h
- * \ingroup audsndfile
- */
-
-
-#ifndef __AUD_SNDFILEWRITER_H__
-#define __AUD_SNDFILEWRITER_H__
-
-#include "AUD_IWriter.h"
-
-#include <string>
-#include <sndfile.h>
-
-/**
- * This class writes a sound file via libsndfile.
- */
-class AUD_SndFileWriter : public AUD_IWriter
-{
-private:
- /**
- * The current position in samples.
- */
- int m_position;
-
- /**
- * The specification of the audio data.
- */
- AUD_DeviceSpecs m_specs;
-
- /**
- * The sndfile.
- */
- SNDFILE* m_sndfile;
-
- // hide copy constructor and operator=
- AUD_SndFileWriter(const AUD_SndFileWriter&);
- AUD_SndFileWriter& operator=(const AUD_SndFileWriter&);
-
-public:
- /**
- * Creates a new writer.
- * \param filename The path to the file to be read.
- * \param specs The file's audio specification.
- * \param format The file's container format.
- * \param codec The codec used for encoding the audio data.
- * \param bitrate The bitrate for encoding.
- * \exception AUD_Exception Thrown if the file specified cannot be written
- * with libsndfile.
- */
- AUD_SndFileWriter(std::string filename, AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate);
-
- /**
- * Destroys the writer and closes the file.
- */
- virtual ~AUD_SndFileWriter();
-
- virtual int getPosition() const;
- virtual AUD_DeviceSpecs getSpecs() const;
- virtual void write(unsigned int length, sample_t* buffer);
-};
-
-#endif //__AUD_SNDFILEWRITER_H__
diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt
index c53a9f91cc0..5844c2480d6 100644
--- a/intern/cycles/CMakeLists.txt
+++ b/intern/cycles/CMakeLists.txt
@@ -41,61 +41,65 @@ elseif(WIN32 AND MSVC)
set(CYCLES_AVX2_ARCH_FLAGS "/arch:SSE2")
endif()
+ # Unlike GCC/clang we still use fast math, because there is no fine
+ # grained control and the speedup we get here is too big to ignore.
+ set(CYCLES_KERNEL_FLAGS "/fp:fast -D_CRT_SECURE_NO_WARNINGS /GS-")
+
# there is no /arch:SSE3, but intrinsics are available anyway
if(CMAKE_CL_64)
- set(CYCLES_SSE2_KERNEL_FLAGS "/fp:fast -D_CRT_SECURE_NO_WARNINGS /GS-")
- set(CYCLES_SSE3_KERNEL_FLAGS "/fp:fast -D_CRT_SECURE_NO_WARNINGS /GS-")
- set(CYCLES_SSE41_KERNEL_FLAGS "/fp:fast -D_CRT_SECURE_NO_WARNINGS /GS-")
- set(CYCLES_AVX_KERNEL_FLAGS "${CYCLES_AVX_ARCH_FLAGS} /fp:fast -D_CRT_SECURE_NO_WARNINGS /GS-")
- set(CYCLES_AVX2_KERNEL_FLAGS "${CYCLES_AVX2_ARCH_FLAGS} /fp:fast -D_CRT_SECURE_NO_WARNINGS /GS-")
+ set(CYCLES_SSE2_KERNEL_FLAGS "${CYCLES_KERNEL_FLAGS}")
+ set(CYCLES_SSE3_KERNEL_FLAGS "${CYCLES_KERNEL_FLAGS}")
+ set(CYCLES_SSE41_KERNEL_FLAGS "${CYCLES_KERNEL_FLAGS}")
+ set(CYCLES_AVX_KERNEL_FLAGS "${CYCLES_AVX_ARCH_FLAGS} ${CYCLES_KERNEL_FLAGS}")
+ set(CYCLES_AVX2_KERNEL_FLAGS "${CYCLES_AVX2_ARCH_FLAGS} ${CYCLES_KERNEL_FLAGS}")
else()
- set(CYCLES_SSE2_KERNEL_FLAGS "/arch:SSE2 /fp:fast -D_CRT_SECURE_NO_WARNINGS /GS-")
- set(CYCLES_SSE3_KERNEL_FLAGS "/arch:SSE2 /fp:fast -D_CRT_SECURE_NO_WARNINGS /GS-")
- set(CYCLES_SSE41_KERNEL_FLAGS "/arch:SSE2 /fp:fast -D_CRT_SECURE_NO_WARNINGS /GS-")
- set(CYCLES_AVX_KERNEL_FLAGS "${CYCLES_AVX_ARCH_FLAGS} /fp:fast -D_CRT_SECURE_NO_WARNINGS /GS-")
- set(CYCLES_AVX2_KERNEL_FLAGS "${CYCLES_AVX2_ARCH_FLAGS} /fp:fast -D_CRT_SECURE_NO_WARNINGS /GS-")
+ set(CYCLES_SSE2_KERNEL_FLAGS "/arch:SSE2 ${CYCLES_KERNEL_FLAGS}")
+ set(CYCLES_SSE3_KERNEL_FLAGS "/arch:SSE2 ${CYCLES_KERNEL_FLAGS}")
+ set(CYCLES_SSE41_KERNEL_FLAGS "/arch:SSE2 ${CYCLES_KERNEL_FLAGS}")
+ set(CYCLES_AVX_KERNEL_FLAGS "${CYCLES_AVX_ARCH_FLAGS} ${CYCLES_KERNEL_FLAGS}")
+ set(CYCLES_AVX2_KERNEL_FLAGS "${CYCLES_AVX2_ARCH_FLAGS} ${CYCLES_KERNEL_FLAGS}")
endif()
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast -D_CRT_SECURE_NO_WARNINGS /GS-")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CYCLES_KERNEL_FLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Ox")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Ox")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /Ox")
-
- set(CYCLES_KERNEL_FLAGS "/fp:fast -D_CRT_SECURE_NO_WARNINGS /GS-")
-elseif(CMAKE_COMPILER_IS_GNUCC)
+elseif(CMAKE_COMPILER_IS_GNUCC OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
check_cxx_compiler_flag(-msse CXX_HAS_SSE)
check_cxx_compiler_flag(-mavx CXX_HAS_AVX)
check_cxx_compiler_flag(-mavx2 CXX_HAS_AVX2)
- set(CYCLES_KERNEL_FLAGS "-ffast-math")
- if(CXX_HAS_SSE)
- set(CYCLES_SSE2_KERNEL_FLAGS "-ffast-math -msse -msse2 -mfpmath=sse")
- set(CYCLES_SSE3_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mssse3 -mfpmath=sse")
- set(CYCLES_SSE41_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mssse3 -msse4.1 -mfpmath=sse")
- endif()
- if(CXX_HAS_AVX)
- set(CYCLES_AVX_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mssse3 -msse4.1 -mavx -mfpmath=sse")
- endif()
- if(CXX_HAS_AVX2)
- set(CYCLES_AVX2_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mssse3 -msse4.1 -mavx -mavx2 -mfma -mlzcnt -mbmi -mbmi2 -mf16c -mfpmath=sse")
+
+ # Assume no signal trapping for better code generation.
+ set(CYCLES_KERNEL_FLAGS "-fno-trapping-math")
+ # Avoid overhead of setting errno for NaNs.
+ set(CYCLES_KERNEL_FLAGS "${CYCLES_KERNEL_FLAGS} -fno-math-errno")
+ # Let compiler optimize 0.0 - x without worrying about signed zeros.
+ set(CYCLES_KERNEL_FLAGS "${CYCLES_KERNEL_FLAGS} -fno-signed-zeros")
+
+ if(CMAKE_COMPILER_IS_GNUCC)
+ # Assume no signal trapping for better code generation.
+ set(CYCLES_KERNEL_FLAGS "${CYCLES_KERNEL_FLAGS} -fno-signaling-nans")
+ # Assume a fixed rounding mode for better constant folding.
+ set(CYCLES_KERNEL_FLAGS "${CYCLES_KERNEL_FLAGS} -fno-rounding-math")
endif()
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffast-math -fno-finite-math-only")
-elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
- check_cxx_compiler_flag(-msse CXX_HAS_SSE)
- check_cxx_compiler_flag(-mavx CXX_HAS_AVX)
- check_cxx_compiler_flag(-mavx2 CXX_HAS_AVX2)
- set(CYCLES_KERNEL_FLAGS "-ffast-math")
+
if(CXX_HAS_SSE)
- set(CYCLES_SSE2_KERNEL_FLAGS "-ffast-math -msse -msse2")
- set(CYCLES_SSE3_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mssse3")
- set(CYCLES_SSE41_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mssse3 -msse4.1")
- endif()
- if(CXX_HAS_AVX)
- set(CYCLES_AVX_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mssse3 -msse4.1 -mavx")
- endif()
- if(CXX_HAS_AVX2)
- set(CYCLES_AVX2_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mssse3 -msse4.1 -mavx -mavx2 -mfma -mlzcnt -mbmi -mbmi2 -mf16c")
+ if(CMAKE_COMPILER_IS_GNUCC)
+ set(CYCLES_KERNEL_FLAGS "${CYCLES_KERNEL_FLAGS} -mfpmath=sse")
+ endif()
+
+ set(CYCLES_SSE2_KERNEL_FLAGS "${CYCLES_KERNEL_FLAGS} -msse -msse2")
+ set(CYCLES_SSE3_KERNEL_FLAGS "${CYCLES_SSE2_KERNEL_FLAGS} -msse3 -mssse3")
+ set(CYCLES_SSE41_KERNEL_FLAGS "${CYCLES_SSE3_KERNEL_FLAGS} -msse4.1")
+ if(CXX_HAS_AVX)
+ set(CYCLES_AVX_KERNEL_FLAGS "${CYCLES_SSE41_KERNEL_FLAGS} -mavx")
+ endif()
+ if(CXX_HAS_AVX2)
+ set(CYCLES_AVX2_KERNEL_FLAGS "${CYCLES_SSE41_KERNEL_FLAGS} -mavx -mavx2 -mfma -mlzcnt -mbmi -mbmi2 -mf16c")
+ endif()
endif()
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffast-math -fno-finite-math-only")
+
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CYCLES_KERNEL_FLAGS}")
endif()
if(CXX_HAS_SSE)
diff --git a/intern/cycles/blender/addon/presets.py b/intern/cycles/blender/addon/presets.py
index 82c4ffc6e50..17efb00abdb 100644
--- a/intern/cycles/blender/addon/presets.py
+++ b/intern/cycles/blender/addon/presets.py
@@ -32,14 +32,11 @@ class AddPresetIntegrator(AddPresetBase, Operator):
preset_values = [
"cycles.max_bounces",
- "cycles.min_bounces",
"cycles.diffuse_bounces",
"cycles.glossy_bounces",
"cycles.transmission_bounces",
"cycles.volume_bounces",
- "cycles.transparent_min_bounces",
"cycles.transparent_max_bounces",
- "cycles.use_transparent_shadows",
"cycles.caustics_reflective",
"cycles.caustics_refractive",
"cycles.blur_glossy"
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index 309e44ccbb8..a50da3634f3 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -199,13 +199,13 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
name="AA Samples",
description="Number of antialiasing samples to render for each pixel",
min=1, max=2097151,
- default=4,
+ default=128,
)
cls.preview_aa_samples = IntProperty(
name="AA Samples",
description="Number of antialiasing samples to render in the viewport, unlimited if 0",
min=0, max=2097151,
- default=4,
+ default=32,
)
cls.diffuse_samples = IntProperty(
name="Diffuse Samples",
@@ -302,17 +302,9 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
description="Adaptively blur glossy shaders after blurry bounces, "
"to reduce noise at the cost of accuracy",
min=0.0, max=10.0,
- default=0.0,
+ default=1.0,
)
- cls.min_bounces = IntProperty(
- name="Min Bounces",
- description="Minimum number of bounces, setting this lower "
- "than the maximum enables probabilistic path "
- "termination (faster but noisier)",
- min=0, max=1024,
- default=3,
- )
cls.max_bounces = IntProperty(
name="Max Bounces",
description="Total maximum number of bounces",
@@ -345,26 +337,12 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
default=0,
)
- cls.transparent_min_bounces = IntProperty(
- name="Transparent Min Bounces",
- description="Minimum number of transparent bounces, setting "
- "this lower than the maximum enables "
- "probabilistic path termination (faster but "
- "noisier)",
- min=0, max=1024,
- default=8,
- )
cls.transparent_max_bounces = IntProperty(
name="Transparent Max Bounces",
description="Maximum number of transparent bounces",
min=0, max=1024,
default=8,
)
- cls.use_transparent_shadows = BoolProperty(
- name="Transparent Shadows",
- description="Use transparency of surfaces for rendering shadows",
- default=True,
- )
cls.volume_step_size = FloatProperty(
name="Step Size",
@@ -469,7 +447,7 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
"higher values will be scaled down to avoid too "
"much noise and slow convergence at the cost of accuracy",
min=0.0, max=1e8,
- default=0.0,
+ default=10.0,
)
cls.debug_tile_size = IntProperty(
@@ -697,6 +675,9 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
cls.debug_use_opencl_debug = BoolProperty(name="Debug OpenCL", default=False)
+ cls.debug_opencl_mem_limit = IntProperty(name="Memory limit", default=0,
+ description="Artificial limit on OpenCL memory usage in MB (0 to disable limit)")
+
@classmethod
def unregister(cls):
del bpy.types.Scene.cycles
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index 756d3b15a89..130b9434255 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -140,7 +140,7 @@ def draw_samples_info(layout, context):
(ao * aa, ml * aa, sss * aa, vol * aa))
-class CyclesRender_PT_sampling(CyclesButtonsPanel, Panel):
+class CYCLES_RENDER_PT_sampling(CyclesButtonsPanel, Panel):
bl_label = "Sampling"
bl_options = {'DEFAULT_CLOSED'}
@@ -215,7 +215,7 @@ class CyclesRender_PT_sampling(CyclesButtonsPanel, Panel):
draw_samples_info(layout, context)
-class CyclesRender_PT_geometry(CyclesButtonsPanel, Panel):
+class CYCLES_RENDER_PT_geometry(CyclesButtonsPanel, Panel):
bl_label = "Geometry"
bl_options = {'DEFAULT_CLOSED'}
@@ -271,7 +271,7 @@ class CyclesRender_PT_geometry(CyclesButtonsPanel, Panel):
row.prop(ccscene, "maximum_width", text="Max Extension")
-class CyclesRender_PT_light_paths(CyclesButtonsPanel, Panel):
+class CYCLES_RENDER_PT_light_paths(CyclesButtonsPanel, Panel):
bl_label = "Light Paths"
bl_options = {'DEFAULT_CLOSED'}
@@ -293,8 +293,6 @@ class CyclesRender_PT_light_paths(CyclesButtonsPanel, Panel):
sub = col.column(align=True)
sub.label("Transparency:")
sub.prop(cscene, "transparent_max_bounces", text="Max")
- sub.prop(cscene, "transparent_min_bounces", text="Min")
- sub.prop(cscene, "use_transparent_shadows", text="Shadows")
col.separator()
@@ -307,7 +305,6 @@ class CyclesRender_PT_light_paths(CyclesButtonsPanel, Panel):
sub = col.column(align=True)
sub.label(text="Bounces:")
sub.prop(cscene, "max_bounces", text="Max")
- sub.prop(cscene, "min_bounces", text="Min")
sub = col.column(align=True)
sub.prop(cscene, "diffuse_bounces", text="Diffuse")
@@ -316,7 +313,7 @@ class CyclesRender_PT_light_paths(CyclesButtonsPanel, Panel):
sub.prop(cscene, "volume_bounces", text="Volume")
-class CyclesRender_PT_motion_blur(CyclesButtonsPanel, Panel):
+class CYCLES_RENDER_PT_motion_blur(CyclesButtonsPanel, Panel):
bl_label = "Motion Blur"
bl_options = {'DEFAULT_CLOSED'}
@@ -357,7 +354,7 @@ class CyclesRender_PT_motion_blur(CyclesButtonsPanel, Panel):
row.prop(cscene, "rolling_shutter_duration")
-class CyclesRender_PT_film(CyclesButtonsPanel, Panel):
+class CYCLES_RENDER_PT_film(CyclesButtonsPanel, Panel):
bl_label = "Film"
def draw(self, context):
@@ -379,7 +376,7 @@ class CyclesRender_PT_film(CyclesButtonsPanel, Panel):
sub.prop(cscene, "filter_width", text="Width")
-class CyclesRender_PT_performance(CyclesButtonsPanel, Panel):
+class CYCLES_RENDER_PT_performance(CyclesButtonsPanel, Panel):
bl_label = "Performance"
bl_options = {'DEFAULT_CLOSED'}
@@ -400,6 +397,8 @@ class CyclesRender_PT_performance(CyclesButtonsPanel, Panel):
sub.enabled = rd.threads_mode == 'FIXED'
sub.prop(rd, "threads")
+ col.separator()
+
sub = col.column(align=True)
sub.label(text="Tiles:")
sub.prop(cscene, "tile_order", text="")
@@ -409,19 +408,10 @@ class CyclesRender_PT_performance(CyclesButtonsPanel, Panel):
sub.prop(cscene, "use_progressive_refine")
- subsub = sub.column(align=True)
- subsub.prop(rd, "use_save_buffers")
-
- col = split.column(align=True)
-
- col.label(text="Viewport:")
- col.prop(cscene, "debug_bvh_type", text="")
- col.separator()
- col.prop(cscene, "preview_start_resolution")
-
- col.separator()
+ col = split.column()
col.label(text="Final Render:")
+ col.prop(rd, "use_save_buffers")
col.prop(rd, "use_persistent_data", text="Persistent Images")
col.separator()
@@ -434,8 +424,14 @@ class CyclesRender_PT_performance(CyclesButtonsPanel, Panel):
row.active = not cscene.debug_use_spatial_splits
row.prop(cscene, "debug_bvh_time_steps")
+ col = layout.column()
+ col.label(text="Viewport Resolution:")
+ split = col.split()
+ split.prop(rd, "preview_pixel_size", text="")
+ split.prop(cscene, "preview_start_resolution")
+
-class CyclesRender_PT_layer_options(CyclesButtonsPanel, Panel):
+class CYCLES_RENDER_PT_layer_options(CyclesButtonsPanel, Panel):
bl_label = "Layer"
bl_context = "render_layer"
@@ -471,7 +467,7 @@ class CyclesRender_PT_layer_options(CyclesButtonsPanel, Panel):
col.prop(rl, "use_strand", "Use Hair")
-class CyclesRender_PT_layer_passes(CyclesButtonsPanel, Panel):
+class CYCLES_RENDER_PT_layer_passes(CyclesButtonsPanel, Panel):
bl_label = "Passes"
bl_context = "render_layer"
bl_options = {'DEFAULT_CLOSED'}
@@ -545,7 +541,7 @@ class CyclesRender_PT_layer_passes(CyclesButtonsPanel, Panel):
col.prop(crl, "pass_debug_ray_bounces")
-class CyclesRender_PT_views(CyclesButtonsPanel, Panel):
+class CYCLES_RENDER_PT_views(CyclesButtonsPanel, Panel):
bl_label = "Views"
bl_context = "render_layer"
bl_options = {'DEFAULT_CLOSED'}
@@ -588,7 +584,7 @@ class CyclesRender_PT_views(CyclesButtonsPanel, Panel):
row.prop(rv, "camera_suffix", text="")
-class CyclesRender_PT_denoising(CyclesButtonsPanel, Panel):
+class CYCLES_RENDER_PT_denoising(CyclesButtonsPanel, Panel):
bl_label = "Denoising"
bl_context = "render_layer"
bl_options = {'DEFAULT_CLOSED'}
@@ -653,7 +649,7 @@ class CyclesRender_PT_denoising(CyclesButtonsPanel, Panel):
sub.prop(crl, "denoising_subsurface_indirect", text="Indirect", toggle=True)
-class Cycles_PT_post_processing(CyclesButtonsPanel, Panel):
+class CYCLES_PT_post_processing(CyclesButtonsPanel, Panel):
bl_label = "Post Processing"
bl_options = {'DEFAULT_CLOSED'}
@@ -672,7 +668,7 @@ class Cycles_PT_post_processing(CyclesButtonsPanel, Panel):
col.prop(rd, "dither_intensity", text="Dither", slider=True)
-class CyclesCamera_PT_dof(CyclesButtonsPanel, Panel):
+class CYCLES_CAMERA_PT_dof(CyclesButtonsPanel, Panel):
bl_label = "Depth of Field"
bl_context = "data"
@@ -723,7 +719,7 @@ class CyclesCamera_PT_dof(CyclesButtonsPanel, Panel):
sub.prop(ccam, "aperture_ratio", text="Ratio")
-class Cycles_PT_context_material(CyclesButtonsPanel, Panel):
+class CYCLES_PT_context_material(CyclesButtonsPanel, Panel):
bl_label = ""
bl_context = "material"
bl_options = {'HIDE_HEADER'}
@@ -783,7 +779,7 @@ class Cycles_PT_context_material(CyclesButtonsPanel, Panel):
split.separator()
-class CyclesObject_PT_motion_blur(CyclesButtonsPanel, Panel):
+class CYCLES_OBJECT_PT_motion_blur(CyclesButtonsPanel, Panel):
bl_label = "Motion Blur"
bl_context = "object"
bl_options = {'DEFAULT_CLOSED'}
@@ -831,7 +827,7 @@ class CyclesObject_PT_motion_blur(CyclesButtonsPanel, Panel):
sub.prop(cob, "motion_steps", text="Steps")
-class CyclesObject_PT_cycles_settings(CyclesButtonsPanel, Panel):
+class CYCLES_OBJECT_PT_cycles_settings(CyclesButtonsPanel, Panel):
bl_label = "Cycles Settings"
bl_context = "object"
bl_options = {'DEFAULT_CLOSED'}
@@ -899,24 +895,27 @@ class CYCLES_OT_use_shading_nodes(Operator):
return {'FINISHED'}
-def panel_node_draw(layout, id_data, output_type, input_name):
+def panel_node_draw(layout, id_data, output_types, input_name):
if not id_data.use_nodes:
layout.operator("cycles.use_shading_nodes", icon='NODETREE')
return False
ntree = id_data.node_tree
- node = find_output_node(ntree, output_type)
- if not node:
- layout.label(text="No output node")
- else:
+ node = find_output_node(ntree, output_types)
+ if node:
input = find_node_input(node, input_name)
- layout.template_node_view(ntree, node, input)
+ if input:
+ layout.template_node_view(ntree, node, input)
+ else:
+ layout.label(text="Incompatible output node")
+ else:
+ layout.label(text="No output node")
return True
-class CyclesLamp_PT_preview(CyclesButtonsPanel, Panel):
+class CYCLES_LAMP_PT_preview(CyclesButtonsPanel, Panel):
bl_label = "Preview"
bl_context = "data"
bl_options = {'DEFAULT_CLOSED'}
@@ -932,7 +931,7 @@ class CyclesLamp_PT_preview(CyclesButtonsPanel, Panel):
self.layout.template_preview(context.lamp)
-class CyclesLamp_PT_lamp(CyclesButtonsPanel, Panel):
+class CYCLES_LAMP_PT_lamp(CyclesButtonsPanel, Panel):
bl_label = "Lamp"
bl_context = "data"
@@ -986,7 +985,7 @@ class CyclesLamp_PT_lamp(CyclesButtonsPanel, Panel):
layout.label(text="Not supported, interpreted as sun lamp")
-class CyclesLamp_PT_nodes(CyclesButtonsPanel, Panel):
+class CYCLES_LAMP_PT_nodes(CyclesButtonsPanel, Panel):
bl_label = "Nodes"
bl_context = "data"
@@ -1000,11 +999,11 @@ class CyclesLamp_PT_nodes(CyclesButtonsPanel, Panel):
layout = self.layout
lamp = context.lamp
- if not panel_node_draw(layout, lamp, 'OUTPUT_LAMP', 'Surface'):
+ if not panel_node_draw(layout, lamp, ('OUTPUT_LAMP',), 'Surface'):
layout.prop(lamp, "color")
-class CyclesLamp_PT_spot(CyclesButtonsPanel, Panel):
+class CYCLES_LAMP_PT_spot(CyclesButtonsPanel, Panel):
bl_label = "Spot Shape"
bl_context = "data"
@@ -1029,7 +1028,7 @@ class CyclesLamp_PT_spot(CyclesButtonsPanel, Panel):
col.prop(lamp, "show_cone")
-class CyclesWorld_PT_preview(CyclesButtonsPanel, Panel):
+class CYCLES_WORLD_PT_preview(CyclesButtonsPanel, Panel):
bl_label = "Preview"
bl_context = "world"
bl_options = {'DEFAULT_CLOSED'}
@@ -1042,7 +1041,7 @@ class CyclesWorld_PT_preview(CyclesButtonsPanel, Panel):
self.layout.template_preview(context.world)
-class CyclesWorld_PT_surface(CyclesButtonsPanel, Panel):
+class CYCLES_WORLD_PT_surface(CyclesButtonsPanel, Panel):
bl_label = "Surface"
bl_context = "world"
@@ -1055,11 +1054,11 @@ class CyclesWorld_PT_surface(CyclesButtonsPanel, Panel):
world = context.world
- if not panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Surface'):
+ if not panel_node_draw(layout, world, ('OUTPUT_WORLD',), 'Surface'):
layout.prop(world, "horizon_color", text="Color")
-class CyclesWorld_PT_volume(CyclesButtonsPanel, Panel):
+class CYCLES_WORLD_PT_volume(CyclesButtonsPanel, Panel):
bl_label = "Volume"
bl_context = "world"
bl_options = {'DEFAULT_CLOSED'}
@@ -1073,10 +1072,10 @@ class CyclesWorld_PT_volume(CyclesButtonsPanel, Panel):
layout = self.layout
world = context.world
- panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Volume')
+ panel_node_draw(layout, world, ('OUTPUT_WORLD',), 'Volume')
-class CyclesWorld_PT_ambient_occlusion(CyclesButtonsPanel, Panel):
+class CYCLES_WORLD_PT_ambient_occlusion(CyclesButtonsPanel, Panel):
bl_label = "Ambient Occlusion"
bl_context = "world"
@@ -1101,7 +1100,7 @@ class CyclesWorld_PT_ambient_occlusion(CyclesButtonsPanel, Panel):
row.prop(light, "distance", text="Distance")
-class CyclesWorld_PT_mist(CyclesButtonsPanel, Panel):
+class CYCLES_WORLD_PT_mist(CyclesButtonsPanel, Panel):
bl_label = "Mist Pass"
bl_context = "world"
bl_options = {'DEFAULT_CLOSED'}
@@ -1128,7 +1127,7 @@ class CyclesWorld_PT_mist(CyclesButtonsPanel, Panel):
layout.prop(world.mist_settings, "falloff")
-class CyclesWorld_PT_ray_visibility(CyclesButtonsPanel, Panel):
+class CYCLES_WORLD_PT_ray_visibility(CyclesButtonsPanel, Panel):
bl_label = "Ray Visibility"
bl_context = "world"
bl_options = {'DEFAULT_CLOSED'}
@@ -1152,7 +1151,7 @@ class CyclesWorld_PT_ray_visibility(CyclesButtonsPanel, Panel):
flow.prop(visibility, "scatter")
-class CyclesWorld_PT_settings(CyclesButtonsPanel, Panel):
+class CYCLES_WORLD_PT_settings(CyclesButtonsPanel, Panel):
bl_label = "Settings"
bl_context = "world"
bl_options = {'DEFAULT_CLOSED'}
@@ -1193,7 +1192,7 @@ class CyclesWorld_PT_settings(CyclesButtonsPanel, Panel):
col.prop(cworld, "homogeneous_volume", text="Homogeneous")
-class CyclesMaterial_PT_preview(CyclesButtonsPanel, Panel):
+class CYCLES_MATERIAL_PT_preview(CyclesButtonsPanel, Panel):
bl_label = "Preview"
bl_context = "material"
bl_options = {'DEFAULT_CLOSED'}
@@ -1206,7 +1205,7 @@ class CyclesMaterial_PT_preview(CyclesButtonsPanel, Panel):
self.layout.template_preview(context.material)
-class CyclesMaterial_PT_surface(CyclesButtonsPanel, Panel):
+class CYCLES_MATERIAL_PT_surface(CyclesButtonsPanel, Panel):
bl_label = "Surface"
bl_context = "material"
@@ -1218,11 +1217,11 @@ class CyclesMaterial_PT_surface(CyclesButtonsPanel, Panel):
layout = self.layout
mat = context.material
- if not panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Surface'):
+ if not panel_node_draw(layout, mat, ('OUTPUT_MATERIAL', 'OUTPUT_EEVEE_MATERIAL'), 'Surface'):
layout.prop(mat, "diffuse_color")
-class CyclesMaterial_PT_volume(CyclesButtonsPanel, Panel):
+class CYCLES_MATERIAL_PT_volume(CyclesButtonsPanel, Panel):
bl_label = "Volume"
bl_context = "material"
bl_options = {'DEFAULT_CLOSED'}
@@ -1238,10 +1237,10 @@ class CyclesMaterial_PT_volume(CyclesButtonsPanel, Panel):
mat = context.material
# cmat = mat.cycles
- panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Volume')
+ panel_node_draw(layout, mat, ('OUTPUT_MATERIAL', 'OUTPUT_EEVEE_MATERIAL'), 'Volume')
-class CyclesMaterial_PT_displacement(CyclesButtonsPanel, Panel):
+class CYCLES_MATERIAL_PT_displacement(CyclesButtonsPanel, Panel):
bl_label = "Displacement"
bl_context = "material"
@@ -1254,10 +1253,10 @@ class CyclesMaterial_PT_displacement(CyclesButtonsPanel, Panel):
layout = self.layout
mat = context.material
- panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Displacement')
+ panel_node_draw(layout, mat, ('OUTPUT_MATERIAL', 'OUTPUT_EEVEE_MATERIAL'), 'Displacement')
-class CyclesMaterial_PT_settings(CyclesButtonsPanel, Panel):
+class CYCLES_MATERIAL_PT_settings(CyclesButtonsPanel, Panel):
bl_label = "Settings"
bl_context = "material"
bl_options = {'DEFAULT_CLOSED'}
@@ -1312,7 +1311,7 @@ class CyclesMaterial_PT_settings(CyclesButtonsPanel, Panel):
col.prop(mat, "pass_index")
-class CyclesTexture_PT_context(CyclesButtonsPanel, Panel):
+class CYCLES_TEXTURE_PT_context(CyclesButtonsPanel, Panel):
bl_label = ""
bl_context = "texture"
bl_options = {'HIDE_HEADER'}
@@ -1353,7 +1352,7 @@ class CyclesTexture_PT_context(CyclesButtonsPanel, Panel):
split.prop(tex, "type", text="")
-class CyclesTexture_PT_node(CyclesButtonsPanel, Panel):
+class CYCLES_TEXTURE_PT_node(CyclesButtonsPanel, Panel):
bl_label = "Node"
bl_context = "texture"
@@ -1370,7 +1369,7 @@ class CyclesTexture_PT_node(CyclesButtonsPanel, Panel):
layout.template_node_view(ntree, node, None)
-class CyclesTexture_PT_mapping(CyclesButtonsPanel, Panel):
+class CYCLES_TEXTURE_PT_mapping(CyclesButtonsPanel, Panel):
bl_label = "Mapping"
bl_context = "texture"
@@ -1403,7 +1402,7 @@ class CyclesTexture_PT_mapping(CyclesButtonsPanel, Panel):
row.prop(mapping, "mapping_z", text="")
-class CyclesTexture_PT_colors(CyclesButtonsPanel, Panel):
+class CYCLES_TEXTURE_PT_colors(CyclesButtonsPanel, Panel):
bl_label = "Color"
bl_context = "texture"
bl_options = {'DEFAULT_CLOSED'}
@@ -1442,7 +1441,7 @@ class CyclesTexture_PT_colors(CyclesButtonsPanel, Panel):
layout.template_color_ramp(mapping, "color_ramp", expand=True)
-class CyclesParticle_PT_textures(CyclesButtonsPanel, Panel):
+class CYCLES_PARTICLE_PT_textures(CyclesButtonsPanel, Panel):
bl_label = "Textures"
bl_context = "particle"
bl_options = {'DEFAULT_CLOSED'}
@@ -1473,7 +1472,7 @@ class CyclesParticle_PT_textures(CyclesButtonsPanel, Panel):
layout.template_ID(slot, "texture", new="texture.new")
-class CyclesRender_PT_bake(CyclesButtonsPanel, Panel):
+class CYCLES_RENDER_PT_bake(CyclesButtonsPanel, Panel):
bl_label = "Bake"
bl_context = "render"
bl_options = {'DEFAULT_CLOSED'}
@@ -1546,7 +1545,7 @@ class CyclesRender_PT_bake(CyclesButtonsPanel, Panel):
sub.prop(cbk, "cage_extrusion", text="Ray Distance")
-class CyclesRender_PT_debug(CyclesButtonsPanel, Panel):
+class CYCLES_RENDER_PT_debug(CyclesButtonsPanel, Panel):
bl_label = "Debug"
bl_context = "render"
bl_options = {'DEFAULT_CLOSED'}
@@ -1574,20 +1573,30 @@ class CyclesRender_PT_debug(CyclesButtonsPanel, Panel):
col.prop(cscene, "debug_use_qbvh")
col.prop(cscene, "debug_use_cpu_split_kernel")
+ col.separator()
+
col = layout.column()
col.label('CUDA Flags:')
col.prop(cscene, "debug_use_cuda_adaptive_compile")
col.prop(cscene, "debug_use_cuda_split_kernel")
+ col.separator()
+
col = layout.column()
col.label('OpenCL Flags:')
col.prop(cscene, "debug_opencl_kernel_type", text="Kernel")
col.prop(cscene, "debug_opencl_device_type", text="Device")
col.prop(cscene, "debug_opencl_kernel_single_program", text="Single Program")
col.prop(cscene, "debug_use_opencl_debug", text="Debug")
+ col.prop(cscene, "debug_opencl_mem_limit")
+
+ col.separator()
+
+ col = layout.column()
+ col.prop(cscene, "debug_bvh_type")
-class CyclesParticle_PT_CurveSettings(CyclesButtonsPanel, Panel):
+class CYCLES_PARTICLE_PT_curve_settings(CyclesButtonsPanel, Panel):
bl_label = "Cycles Hair Settings"
bl_context = "particle"
@@ -1618,7 +1627,7 @@ class CyclesParticle_PT_CurveSettings(CyclesButtonsPanel, Panel):
row.prop(cpsys, "use_closetip", text="Close tip")
-class CyclesScene_PT_simplify(CyclesButtonsPanel, Panel):
+class CYCLES_SCENE_PT_simplify(CyclesButtonsPanel, Panel):
bl_label = "Simplify"
bl_context = "scene"
COMPAT_ENGINES = {'CYCLES'}
@@ -1771,47 +1780,47 @@ def get_panels():
classes = (
CYCLES_MT_sampling_presets,
CYCLES_MT_integrator_presets,
- CyclesRender_PT_sampling,
- CyclesRender_PT_geometry,
- CyclesRender_PT_light_paths,
- CyclesRender_PT_motion_blur,
- CyclesRender_PT_film,
- CyclesRender_PT_performance,
- CyclesRender_PT_layer_options,
- CyclesRender_PT_layer_passes,
- CyclesRender_PT_views,
- CyclesRender_PT_denoising,
- Cycles_PT_post_processing,
- CyclesCamera_PT_dof,
- Cycles_PT_context_material,
- CyclesObject_PT_motion_blur,
- CyclesObject_PT_cycles_settings,
+ CYCLES_RENDER_PT_sampling,
+ CYCLES_RENDER_PT_geometry,
+ CYCLES_RENDER_PT_light_paths,
+ CYCLES_RENDER_PT_motion_blur,
+ CYCLES_RENDER_PT_film,
+ CYCLES_RENDER_PT_performance,
+ CYCLES_RENDER_PT_layer_options,
+ CYCLES_RENDER_PT_layer_passes,
+ CYCLES_RENDER_PT_views,
+ CYCLES_RENDER_PT_denoising,
+ CYCLES_PT_post_processing,
+ CYCLES_CAMERA_PT_dof,
+ CYCLES_PT_context_material,
+ CYCLES_OBJECT_PT_motion_blur,
+ CYCLES_OBJECT_PT_cycles_settings,
CYCLES_OT_use_shading_nodes,
- CyclesLamp_PT_preview,
- CyclesLamp_PT_lamp,
- CyclesLamp_PT_nodes,
- CyclesLamp_PT_spot,
- CyclesWorld_PT_preview,
- CyclesWorld_PT_surface,
- CyclesWorld_PT_volume,
- CyclesWorld_PT_ambient_occlusion,
- CyclesWorld_PT_mist,
- CyclesWorld_PT_ray_visibility,
- CyclesWorld_PT_settings,
- CyclesMaterial_PT_preview,
- CyclesMaterial_PT_surface,
- CyclesMaterial_PT_volume,
- CyclesMaterial_PT_displacement,
- CyclesMaterial_PT_settings,
- CyclesTexture_PT_context,
- CyclesTexture_PT_node,
- CyclesTexture_PT_mapping,
- CyclesTexture_PT_colors,
- CyclesParticle_PT_textures,
- CyclesRender_PT_bake,
- CyclesRender_PT_debug,
- CyclesParticle_PT_CurveSettings,
- CyclesScene_PT_simplify,
+ CYCLES_LAMP_PT_preview,
+ CYCLES_LAMP_PT_lamp,
+ CYCLES_LAMP_PT_nodes,
+ CYCLES_LAMP_PT_spot,
+ CYCLES_WORLD_PT_preview,
+ CYCLES_WORLD_PT_surface,
+ CYCLES_WORLD_PT_volume,
+ CYCLES_WORLD_PT_ambient_occlusion,
+ CYCLES_WORLD_PT_mist,
+ CYCLES_WORLD_PT_ray_visibility,
+ CYCLES_WORLD_PT_settings,
+ CYCLES_MATERIAL_PT_preview,
+ CYCLES_MATERIAL_PT_surface,
+ CYCLES_MATERIAL_PT_volume,
+ CYCLES_MATERIAL_PT_displacement,
+ CYCLES_MATERIAL_PT_settings,
+ CYCLES_TEXTURE_PT_context,
+ CYCLES_TEXTURE_PT_node,
+ CYCLES_TEXTURE_PT_mapping,
+ CYCLES_TEXTURE_PT_colors,
+ CYCLES_PARTICLE_PT_textures,
+ CYCLES_RENDER_PT_bake,
+ CYCLES_RENDER_PT_debug,
+ CYCLES_PARTICLE_PT_curve_settings,
+ CYCLES_SCENE_PT_simplify,
)
diff --git a/intern/cycles/blender/addon/version_update.py b/intern/cycles/blender/addon/version_update.py
index b2a745500a1..efd794461d6 100644
--- a/intern/cycles/blender/addon/version_update.py
+++ b/intern/cycles/blender/addon/version_update.py
@@ -302,3 +302,16 @@ def do_versions(self):
cscene = scene.cycles
if not cscene.is_property_set("light_sampling_threshold"):
cscene.light_sampling_threshold = 0.0
+
+ if bpy.data.version <= (2, 79, 0):
+ for scene in bpy.data.scenes:
+ cscene = scene.cycles
+ # Default changes
+ if not cscene.is_property_set("aa_samples"):
+ cscene.aa_samples = 4
+ if not cscene.is_property_set("preview_aa_samples"):
+ cscene.preview_aa_samples = 4
+ if not cscene.is_property_set("blur_glossy"):
+ cscene.blur_glossy = 0.0
+ if not cscene.is_property_set("sample_clamp_indirect"):
+ cscene.sample_clamp_indirect = 0.0
diff --git a/intern/cycles/blender/blender_camera.cpp b/intern/cycles/blender/blender_camera.cpp
index 40d6b25f2b7..b29711d30d3 100644
--- a/intern/cycles/blender/blender_camera.cpp
+++ b/intern/cycles/blender/blender_camera.cpp
@@ -544,7 +544,11 @@ void BlenderSync::sync_camera_motion(BL::RenderSettings& b_render,
if(tfm != cam->matrix) {
VLOG(1) << "Camera " << b_ob.name() << " motion detected.";
- if(motion_time == -1.0f) {
+ if(motion_time == 0.0f) {
+ /* When motion blur is not centered in frame, cam->matrix gets reset. */
+ cam->matrix = tfm;
+ }
+ else if(motion_time == -1.0f) {
cam->motion.pre = tfm;
cam->use_motion = true;
}
@@ -573,7 +577,10 @@ void BlenderSync::sync_camera_motion(BL::RenderSettings& b_render,
float fov = 2.0f * atanf((0.5f * sensor_size) / bcam.lens / aspectratio);
if(fov != cam->fov) {
VLOG(1) << "Camera " << b_ob.name() << " FOV change detected.";
- if(motion_time == -1.0f) {
+ if(motion_time == 0.0f) {
+ cam->fov = fov;
+ }
+ else if(motion_time == -1.0f) {
cam->fov_pre = fov;
cam->use_perspective_motion = true;
}
diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp
index 42b985305ea..63b07936426 100644
--- a/intern/cycles/blender/blender_curves.cpp
+++ b/intern/cycles/blender/blender_curves.cpp
@@ -325,14 +325,14 @@ static bool ObtainCacheParticleVcol(Mesh *mesh,
return true;
}
-static void set_resolution(BL::Object *b_ob, BL::Scene *scene, bool render)
+static void set_resolution(BL::Object *b_ob, BL::Scene *scene, BL::SceneLayer *sl, bool render)
{
BL::Object::modifiers_iterator b_mod;
for(b_ob->modifiers.begin(b_mod); b_mod != b_ob->modifiers.end(); ++b_mod) {
if((b_mod->type() == b_mod->type_PARTICLE_SYSTEM) && ((b_mod->show_viewport()) || (b_mod->show_render()))) {
BL::ParticleSystemModifier psmd((const PointerRNA)b_mod->ptr);
BL::ParticleSystem b_psys((const PointerRNA)psmd.particle_system().ptr);
- b_psys.set_resolution(*scene, *b_ob, (render)? 2: 1);
+ b_psys.set_resolution(*scene, *sl, *b_ob, (render)? 2: 1);
}
}
}
@@ -912,7 +912,7 @@ void BlenderSync::sync_curves(Mesh *mesh,
ParticleCurveData CData;
if(!preview)
- set_resolution(&b_ob, &b_scene, true);
+ set_resolution(&b_ob, &b_scene, &b_scene_layer, true);
ObtainCacheParticleData(mesh, &b_mesh, &b_ob, &CData, !preview);
@@ -1057,7 +1057,7 @@ void BlenderSync::sync_curves(Mesh *mesh,
}
if(!preview)
- set_resolution(&b_ob, &b_scene, false);
+ set_resolution(&b_ob, &b_scene, &b_scene_layer, false);
mesh->compute_bounds();
}
diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp
index 75933c955ee..31f3e1e4859 100644
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@ -50,8 +50,7 @@ enum {
* Two triangles has vertex indices in the original Blender-side face.
* If face is already a quad tri_b will not be initialized.
*/
-inline void face_split_tri_indices(const int num_verts,
- const int face_flag,
+inline void face_split_tri_indices(const int face_flag,
int tri_a[3],
int tri_b[3])
{
@@ -59,36 +58,37 @@ inline void face_split_tri_indices(const int num_verts,
tri_a[0] = 0;
tri_a[1] = 1;
tri_a[2] = 3;
- if(num_verts == 4) {
- tri_b[0] = 2;
- tri_b[1] = 3;
- tri_b[2] = 1;
- }
+
+ tri_b[0] = 2;
+ tri_b[1] = 3;
+ tri_b[2] = 1;
}
- else /*if(face_flag & FACE_FLAG_DIVIDE_13)*/ {
+ else {
+ /* Quad with FACE_FLAG_DIVIDE_13 or single triangle. */
tri_a[0] = 0;
tri_a[1] = 1;
tri_a[2] = 2;
- if(num_verts == 4) {
- tri_b[0] = 0;
- tri_b[1] = 2;
- tri_b[2] = 3;
- }
+
+ tri_b[0] = 0;
+ tri_b[1] = 2;
+ tri_b[2] = 3;
}
}
/* Tangent Space */
struct MikkUserData {
- MikkUserData(const BL::Mesh& mesh_,
- BL::MeshTextureFaceLayer *layer_,
- int num_faces_)
- : mesh(mesh_), layer(layer_), num_faces(num_faces_)
+ MikkUserData(const BL::Mesh& b_mesh,
+ BL::MeshTextureFaceLayer *layer,
+ int num_faces)
+ : b_mesh(b_mesh),
+ layer(layer),
+ num_faces(num_faces)
{
tangent.resize(num_faces*4);
}
- BL::Mesh mesh;
+ BL::Mesh b_mesh;
BL::MeshTextureFaceLayer *layer;
int num_faces;
vector<float4> tangent;
@@ -103,7 +103,7 @@ static int mikk_get_num_faces(const SMikkTSpaceContext *context)
static int mikk_get_num_verts_of_face(const SMikkTSpaceContext *context, const int face_num)
{
MikkUserData *userdata = (MikkUserData*)context->m_pUserData;
- BL::MeshTessFace f = userdata->mesh.tessfaces[face_num];
+ BL::MeshTessFace f = userdata->b_mesh.tessfaces[face_num];
int4 vi = get_int4(f.vertices_raw());
return (vi[3] == 0)? 3: 4;
@@ -112,9 +112,9 @@ static int mikk_get_num_verts_of_face(const SMikkTSpaceContext *context, const i
static void mikk_get_position(const SMikkTSpaceContext *context, float P[3], const int face_num, const int vert_num)
{
MikkUserData *userdata = (MikkUserData*)context->m_pUserData;
- BL::MeshTessFace f = userdata->mesh.tessfaces[face_num];
+ BL::MeshTessFace f = userdata->b_mesh.tessfaces[face_num];
int4 vi = get_int4(f.vertices_raw());
- BL::MeshVertex v = userdata->mesh.vertices[vi[vert_num]];
+ BL::MeshVertex v = userdata->b_mesh.vertices[vi[vert_num]];
float3 vP = get_float3(v.co());
P[0] = vP.x;
@@ -148,9 +148,9 @@ static void mikk_get_texture_coordinate(const SMikkTSpaceContext *context, float
uv[1] = tfuv.y;
}
else {
- int vert_idx = userdata->mesh.tessfaces[face_num].vertices()[vert_num];
+ int vert_idx = userdata->b_mesh.tessfaces[face_num].vertices()[vert_num];
float3 orco =
- get_float3(userdata->mesh.vertices[vert_idx].undeformed_co());
+ get_float3(userdata->b_mesh.vertices[vert_idx].undeformed_co());
float2 tmp = map_to_sphere(make_float3(orco[0], orco[1], orco[2]));
uv[0] = tmp.x;
uv[1] = tmp.y;
@@ -160,12 +160,12 @@ static void mikk_get_texture_coordinate(const SMikkTSpaceContext *context, float
static void mikk_get_normal(const SMikkTSpaceContext *context, float N[3], const int face_num, const int vert_num)
{
MikkUserData *userdata = (MikkUserData*)context->m_pUserData;
- BL::MeshTessFace f = userdata->mesh.tessfaces[face_num];
+ BL::MeshTessFace f = userdata->b_mesh.tessfaces[face_num];
float3 vN;
if(f.use_smooth()) {
int4 vi = get_int4(f.vertices_raw());
- BL::MeshVertex v = userdata->mesh.vertices[vi[vert_num]];
+ BL::MeshVertex v = userdata->b_mesh.vertices[vi[vert_num]];
vN = get_float3(v.normal());
}
else {
@@ -250,7 +250,7 @@ static void mikk_compute_tangents(BL::Mesh& b_mesh,
for(int i = 0; i < nverts.size(); i++) {
int tri_a[3], tri_b[3];
- face_split_tri_indices(nverts[i], face_flags[i], tri_a, tri_b);
+ face_split_tri_indices(face_flags[i], tri_a, tri_b);
tangent[0] = float4_to_float3(userdata.tangent[i*4 + tri_a[0]]);
tangent[1] = float4_to_float3(userdata.tangent[i*4 + tri_a[1]]);
@@ -376,7 +376,7 @@ static void attr_create_vertex_color(Scene *scene,
for(l->data.begin(c); c != l->data.end(); ++c, ++i) {
int tri_a[3], tri_b[3];
- face_split_tri_indices(nverts[i], face_flags[i], tri_a, tri_b);
+ face_split_tri_indices(face_flags[i], tri_a, tri_b);
uchar4 colors[4];
colors[0] = color_float_to_byte(color_srgb_to_scene_linear_v3(get_float3(c->color1())));
@@ -469,7 +469,7 @@ static void attr_create_uv_map(Scene *scene,
for(l->data.begin(t); t != l->data.end(); ++t, ++i) {
int tri_a[3], tri_b[3];
- face_split_tri_indices(nverts[i], face_flags[i], tri_a, tri_b);
+ face_split_tri_indices(face_flags[i], tri_a, tri_b);
float3 uvs[4];
uvs[0] = get_float3(t->uv1());
@@ -719,6 +719,11 @@ static void create_mesh(Scene *scene,
int numngons = 0;
bool use_loop_normals = b_mesh.use_auto_smooth() && (mesh->subdivision_type != Mesh::SUBDIVISION_CATMULL_CLARK);
+ /* If no faces, create empty mesh. */
+ if(numfaces == 0) {
+ return;
+ }
+
BL::Mesh::vertices_iterator v;
BL::Mesh::tessfaces_iterator f;
BL::Mesh::polygons_iterator p;
@@ -1056,6 +1061,7 @@ Mesh *BlenderSync::sync_mesh(BL::Object& b_ob,
BL::Mesh b_mesh = object_to_mesh(b_data,
b_ob,
b_scene,
+ b_scene_layer,
true,
!preview,
need_undeformed,
@@ -1080,7 +1086,7 @@ Mesh *BlenderSync::sync_mesh(BL::Object& b_ob,
}
/* free derived mesh */
- b_data.meshes.remove(b_mesh, false);
+ b_data.meshes.remove(b_mesh, false, true, false);
}
}
mesh->geometry_flags = requested_geometry_flags;
@@ -1187,6 +1193,7 @@ void BlenderSync::sync_mesh_motion(BL::Object& b_ob,
b_mesh = object_to_mesh(b_data,
b_ob,
b_scene,
+ b_scene_layer,
true,
!preview,
false,
@@ -1300,7 +1307,7 @@ void BlenderSync::sync_mesh_motion(BL::Object& b_ob,
sync_curves(mesh, b_mesh, b_ob, true, time_index);
/* free derived mesh */
- b_data.meshes.remove(b_mesh, false);
+ b_data.meshes.remove(b_mesh, false, true, false);
}
CCL_NAMESPACE_END
diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp
index 991b834dcfa..a25ae278058 100644
--- a/intern/cycles/blender/blender_object.cpp
+++ b/intern/cycles/blender/blender_object.cpp
@@ -63,8 +63,26 @@ bool BlenderSync::object_is_mesh(BL::Object& b_ob)
{
BL::ID b_ob_data = b_ob.data();
- return (b_ob_data && (b_ob_data.is_a(&RNA_Mesh) ||
- b_ob_data.is_a(&RNA_Curve) || b_ob_data.is_a(&RNA_MetaBall)));
+ if(!b_ob_data) {
+ return false;
+ }
+
+ if(b_ob.type() == BL::Object::type_CURVE) {
+ /* Skip exporting curves without faces, overhead can be
+ * significant if there are many for path animation. */
+ BL::Curve b_curve(b_ob.data());
+
+ return (b_curve.bevel_object() ||
+ b_curve.extrude() != 0.0f ||
+ b_curve.bevel_depth() != 0.0f ||
+ b_curve.dimensions() == BL::Curve::dimensions_2D ||
+ b_ob.modifiers.length());
+ }
+ else {
+ return (b_ob_data.is_a(&RNA_Mesh) ||
+ b_ob_data.is_a(&RNA_Curve) ||
+ b_ob_data.is_a(&RNA_MetaBall));
+ }
}
bool BlenderSync::object_is_light(BL::Object& b_ob)
@@ -286,6 +304,29 @@ Object *BlenderSync::sync_object(BL::Depsgraph::duplis_iterator& b_dupli_iter,
return NULL;
}
+ /* Visibility flags for both parent and child. */
+ bool use_holdout = (layer_flag & render_layer.holdout_layer) != 0;
+ uint visibility = object_ray_visibility(b_ob) & PATH_RAY_ALL_VISIBILITY;
+
+ if(b_parent.ptr.data != b_ob.ptr.data) {
+ visibility &= object_ray_visibility(b_parent);
+ }
+
+ /* Make holdout objects on excluded layer invisible for non-camera rays. */
+ if(use_holdout && (layer_flag & render_layer.exclude_layer)) {
+ visibility &= ~(PATH_RAY_ALL_VISIBILITY - PATH_RAY_CAMERA);
+ }
+
+ /* Hide objects not on render layer from camera rays. */
+ if(!(layer_flag & render_layer.layer)) {
+ visibility &= ~PATH_RAY_CAMERA;
+ }
+
+ /* Don't export completely invisible objects. */
+ if(visibility == 0) {
+ return NULL;
+ }
+
/* key to lookup object */
ObjectKey key(b_parent, persistent_id, b_ob_instance);
Object *object;
@@ -326,8 +367,6 @@ Object *BlenderSync::sync_object(BL::Depsgraph::duplis_iterator& b_dupli_iter,
if(object_map.sync(&object, b_ob, b_parent, key))
object_updated = true;
- bool use_holdout = (layer_flag & render_layer.holdout_layer) != 0;
-
/* mesh sync */
object->mesh = sync_mesh(b_ob, b_ob_instance, object_updated, hide_tris);
@@ -340,22 +379,6 @@ Object *BlenderSync::sync_object(BL::Depsgraph::duplis_iterator& b_dupli_iter,
object_updated = true;
}
- /* visibility flags for both parent and child */
- uint visibility = object_ray_visibility(b_ob) & PATH_RAY_ALL_VISIBILITY;
- if(b_parent.ptr.data != b_ob.ptr.data) {
- visibility &= object_ray_visibility(b_parent);
- }
-
- /* make holdout objects on excluded layer invisible for non-camera rays */
- if(use_holdout && (layer_flag & render_layer.exclude_layer)) {
- visibility &= ~(PATH_RAY_ALL_VISIBILITY - PATH_RAY_CAMERA);
- }
-
- /* hide objects not on render layer from camera rays */
- if(!(layer_flag & render_layer.layer)) {
- visibility &= ~PATH_RAY_CAMERA;
- }
-
if(visibility != object->visibility) {
object->visibility = visibility;
object_updated = true;
@@ -519,6 +542,10 @@ void BlenderSync::sync_objects(float motion_time)
++b_dupli_iter)
{
BL::Object b_ob = b_dupli_iter->object();
+ if(!b_ob.is_visible()) {
+ continue;
+ }
+
progress.set_sync_status("Synchronizing object", b_ob.name());
/* load per-object culling data */
diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp
index 3c769881bb7..300ccc06ea9 100644
--- a/intern/cycles/blender/blender_python.cpp
+++ b/intern/cycles/blender/blender_python.cpp
@@ -60,6 +60,8 @@ bool debug_flags_sync_from_scene(BL::Scene b_scene)
/* Backup some settings for comparison. */
DebugFlags::OpenCL::DeviceType opencl_device_type = flags.opencl.device_type;
DebugFlags::OpenCL::KernelType opencl_kernel_type = flags.opencl.kernel_type;
+ /* Synchronize shared flags. */
+ flags.viewport_static_bvh = get_enum(cscene, "debug_bvh_type");
/* Synchronize CPU flags. */
flags.cpu.avx2 = get_boolean(cscene, "debug_use_cpu_avx2");
flags.cpu.avx = get_boolean(cscene, "debug_use_cpu_avx");
@@ -106,6 +108,7 @@ bool debug_flags_sync_from_scene(BL::Scene b_scene)
}
/* Synchronize other OpenCL flags. */
flags.opencl.debug = get_boolean(cscene, "debug_use_opencl_debug");
+ flags.opencl.mem_limit = ((size_t)get_int(cscene, "debug_opencl_mem_limit"))*1024*1024;
flags.opencl.single_program = get_boolean(cscene, "debug_opencl_kernel_single_program");
return flags.opencl.device_type != opencl_device_type ||
flags.opencl.kernel_type != opencl_kernel_type;
diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp
index d8c3750cf20..f4e9da43454 100644
--- a/intern/cycles/blender/blender_session.cpp
+++ b/intern/cycles/blender/blender_session.cpp
@@ -60,6 +60,7 @@ BlenderSession::BlenderSession(BL::RenderEngine& b_engine,
b_render(b_engine.render()),
b_depsgraph(b_depsgraph),
b_scene(b_scene),
+ b_scene_layer(b_engine.scene_layer()),
b_v3d(PointerRNA_NULL),
b_rv3d(PointerRNA_NULL),
python_thread_state(NULL)
@@ -89,6 +90,7 @@ BlenderSession::BlenderSession(BL::RenderEngine& b_engine,
b_render(b_scene.render()),
b_depsgraph(b_depsgraph),
b_scene(b_scene),
+ b_scene_layer(b_engine.scene_layer()),
b_v3d(b_v3d),
b_rv3d(b_rv3d),
width(width),
@@ -133,9 +135,9 @@ void BlenderSession::create_session()
scene = new Scene(scene_params, session_params.device);
/* setup callbacks for builtin image support */
- scene->image_manager->builtin_image_info_cb = function_bind(&BlenderSession::builtin_image_info, this, _1, _2, _3, _4, _5, _6, _7);
- scene->image_manager->builtin_image_pixels_cb = function_bind(&BlenderSession::builtin_image_pixels, this, _1, _2, _3, _4);
- scene->image_manager->builtin_image_float_pixels_cb = function_bind(&BlenderSession::builtin_image_float_pixels, this, _1, _2, _3, _4);
+ scene->image_manager->builtin_image_info_cb = function_bind(&BlenderSession::builtin_image_info, this, _1, _2, _3, _4, _5, _6, _7, _8);
+ scene->image_manager->builtin_image_pixels_cb = function_bind(&BlenderSession::builtin_image_pixels, this, _1, _2, _3, _4, _5);
+ scene->image_manager->builtin_image_float_pixels_cb = function_bind(&BlenderSession::builtin_image_float_pixels, this, _1, _2, _3, _4, _5);
/* create session */
session = new Session(session_params);
@@ -1017,7 +1019,8 @@ void BlenderSession::builtin_image_info(const string &builtin_name,
int &width,
int &height,
int &depth,
- int &channels)
+ int &channels,
+ bool& free_cache)
{
/* empty image */
is_float = false;
@@ -1025,6 +1028,7 @@ void BlenderSession::builtin_image_info(const string &builtin_name,
height = 1;
depth = 0;
channels = 0;
+ free_cache = false;
if(!builtin_data)
return;
@@ -1038,6 +1042,7 @@ void BlenderSession::builtin_image_info(const string &builtin_name,
/* image data */
BL::Image b_image(b_id);
+ free_cache = !b_image.has_data();
is_float = b_image.is_float();
width = b_image.size()[0];
height = b_image.size()[1];
@@ -1098,7 +1103,8 @@ void BlenderSession::builtin_image_info(const string &builtin_name,
bool BlenderSession::builtin_image_pixels(const string &builtin_name,
void *builtin_data,
unsigned char *pixels,
- const size_t pixels_size)
+ const size_t pixels_size,
+ const bool free_cache)
{
if(!builtin_data) {
return false;
@@ -1119,7 +1125,6 @@ bool BlenderSession::builtin_image_pixels(const string &builtin_name,
if(image_pixels && num_pixels * channels == pixels_size) {
memcpy(pixels, image_pixels, pixels_size * sizeof(unsigned char));
- MEM_freeN(image_pixels);
}
else {
if(channels == 1) {
@@ -1138,6 +1143,16 @@ bool BlenderSession::builtin_image_pixels(const string &builtin_name,
}
}
}
+
+ if(image_pixels) {
+ MEM_freeN(image_pixels);
+ }
+
+ /* Free image buffers to save memory during render. */
+ if(free_cache) {
+ b_image.buffers_free();
+ }
+
/* Premultiply, byte images are always straight for Blender. */
unsigned char *cp = pixels;
for(size_t i = 0; i < num_pixels; i++, cp += channels) {
@@ -1151,7 +1166,8 @@ bool BlenderSession::builtin_image_pixels(const string &builtin_name,
bool BlenderSession::builtin_image_float_pixels(const string &builtin_name,
void *builtin_data,
float *pixels,
- const size_t pixels_size)
+ const size_t pixels_size,
+ const bool free_cache)
{
if(!builtin_data) {
return false;
@@ -1176,7 +1192,6 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name,
if(image_pixels && num_pixels * channels == pixels_size) {
memcpy(pixels, image_pixels, pixels_size * sizeof(float));
- MEM_freeN(image_pixels);
}
else {
if(channels == 1) {
@@ -1196,6 +1211,15 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name,
}
}
+ if(image_pixels) {
+ MEM_freeN(image_pixels);
+ }
+
+ /* Free image buffers to save memory during render. */
+ if(free_cache) {
+ b_image.buffers_free();
+ }
+
return true;
}
else if(b_id.is_a(&RNA_Object)) {
@@ -1279,7 +1303,7 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name,
BL::ShaderNodeTexPointDensity b_point_density_node(b_node);
int length;
int settings = background ? 1 : 0; /* 1 - render settings, 0 - vewport settings. */
- b_point_density_node.calc_point_density(b_scene, settings, &length, &pixels);
+ b_point_density_node.calc_point_density(b_scene, b_scene_layer, settings, &length, &pixels);
}
}
diff --git a/intern/cycles/blender/blender_session.h b/intern/cycles/blender/blender_session.h
index 254e8a049ff..7ae7bde1737 100644
--- a/intern/cycles/blender/blender_session.h
+++ b/intern/cycles/blender/blender_session.h
@@ -108,6 +108,7 @@ public:
BL::RenderSettings b_render;
BL::Depsgraph b_depsgraph;
BL::Scene b_scene;
+ BL::SceneLayer b_scene_layer;
BL::SpaceView3D b_v3d;
BL::RegionView3D b_rv3d;
string b_rlay_name;
@@ -159,15 +160,18 @@ protected:
int &width,
int &height,
int &depth,
- int &channels);
+ int &channels,
+ bool &free_cache);
bool builtin_image_pixels(const string &builtin_name,
void *builtin_data,
unsigned char *pixels,
- const size_t pixels_size);
+ const size_t pixels_size,
+ const bool free_cache);
bool builtin_image_float_pixels(const string &builtin_name,
void *builtin_data,
float *pixels,
- const size_t pixels_size);
+ const size_t pixels_size,
+ const bool free_cache);
/* Update tile manager to reflect resumable render settings. */
void update_resumable_tile_manager(int num_samples);
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp
index c96727d5f64..b9af0dd0bf6 100644
--- a/intern/cycles/blender/blender_shader.cpp
+++ b/intern/cycles/blender/blender_shader.cpp
@@ -231,17 +231,11 @@ static void get_tex_mapping(TextureMapping *mapping,
mapping->max = get_float3(b_mapping.max());
}
-static bool is_output_node(BL::Node& b_node)
-{
- return (b_node.is_a(&RNA_ShaderNodeOutputMaterial)
- || b_node.is_a(&RNA_ShaderNodeOutputWorld)
- || b_node.is_a(&RNA_ShaderNodeOutputLamp));
-}
-
static ShaderNode *add_node(Scene *scene,
BL::RenderEngine& b_engine,
BL::BlendData& b_data,
BL::Scene& b_scene,
+ BL::SceneLayer b_scene_layer,
const bool background,
ShaderGraph *graph,
BL::ShaderNodeTree& b_ntree,
@@ -838,7 +832,7 @@ static ShaderNode *add_node(Scene *scene,
/* TODO(sergey): Use more proper update flag. */
if(true) {
- b_point_density_node.cache_point_density(b_scene, settings);
+ b_point_density_node.cache_point_density(b_scene, b_scene_layer, settings);
scene->image_manager->tag_reload_image(
point_density->filename.string(),
point_density->builtin_data,
@@ -856,7 +850,7 @@ static ShaderNode *add_node(Scene *scene,
BL::Object b_ob(b_point_density_node.object());
if(b_ob) {
float3 loc, size;
- point_density_texture_space(b_scene,
+ point_density_texture_space(b_scene, b_scene_layer,
b_point_density_node,
settings,
loc,
@@ -949,10 +943,36 @@ static ShaderOutput *node_find_output_by_name(ShaderNode *node,
return node->output(name.c_str());
}
+static BL::ShaderNode find_output_node(BL::ShaderNodeTree& b_ntree)
+{
+ BL::ShaderNodeTree::nodes_iterator b_node;
+ BL::ShaderNode output_node(PointerRNA_NULL);
+
+ for(b_ntree.nodes.begin(b_node); b_node != b_ntree.nodes.end(); ++b_node) {
+ BL::ShaderNodeOutputMaterial b_output_node(*b_node);
+
+ if (b_output_node.is_a(&RNA_ShaderNodeOutputMaterial) ||
+ b_output_node.is_a(&RNA_ShaderNodeOutputWorld) ||
+ b_output_node.is_a(&RNA_ShaderNodeOutputLamp)) {
+ /* regular Cycles output node */
+ if(b_output_node.is_active_output()) {
+ output_node = b_output_node;
+ break;
+ }
+ else if(!output_node.ptr.data) {
+ output_node = b_output_node;
+ }
+ }
+ }
+
+ return output_node;
+}
+
static void add_nodes(Scene *scene,
BL::RenderEngine& b_engine,
BL::BlendData& b_data,
BL::Scene& b_scene,
+ BL::SceneLayer& b_scene_layer,
const bool background,
ShaderGraph *graph,
BL::ShaderNodeTree& b_ntree,
@@ -968,23 +988,7 @@ static void add_nodes(Scene *scene,
BL::Node::outputs_iterator b_output;
/* find the node to use for output if there are multiple */
- bool found_active_output = false;
- BL::ShaderNode output_node(PointerRNA_NULL);
-
- for(b_ntree.nodes.begin(b_node); b_node != b_ntree.nodes.end(); ++b_node) {
- if(is_output_node(*b_node)) {
- BL::ShaderNodeOutputMaterial b_output_node(*b_node);
-
- if(b_output_node.is_active_output()) {
- output_node = b_output_node;
- found_active_output = true;
- break;
- }
- else if(!output_node.ptr.data && !found_active_output) {
- output_node = b_output_node;
- }
- }
- }
+ BL::ShaderNode output_node = find_output_node(b_ntree);
/* add nodes */
for(b_ntree.nodes.begin(b_node); b_node != b_ntree.nodes.end(); ++b_node) {
@@ -1043,6 +1047,7 @@ static void add_nodes(Scene *scene,
b_engine,
b_data,
b_scene,
+ b_scene_layer,
background,
graph,
b_group_ntree,
@@ -1081,10 +1086,8 @@ static void add_nodes(Scene *scene,
else {
ShaderNode *node = NULL;
- if(is_output_node(*b_node)) {
- if(b_node->ptr.data == output_node.ptr.data) {
- node = graph->output();
- }
+ if(b_node->ptr.data == output_node.ptr.data) {
+ node = graph->output();
}
else {
BL::ShaderNode b_shader_node(*b_node);
@@ -1092,6 +1095,7 @@ static void add_nodes(Scene *scene,
b_engine,
b_data,
b_scene,
+ b_scene_layer,
background,
graph,
b_ntree,
@@ -1155,6 +1159,7 @@ static void add_nodes(Scene *scene,
BL::RenderEngine& b_engine,
BL::BlendData& b_data,
BL::Scene& b_scene,
+ BL::SceneLayer& b_scene_layer,
const bool background,
ShaderGraph *graph,
BL::ShaderNodeTree& b_ntree)
@@ -1164,6 +1169,7 @@ static void add_nodes(Scene *scene,
b_engine,
b_data,
b_scene,
+ b_scene_layer,
background,
graph,
b_ntree,
@@ -1202,7 +1208,7 @@ void BlenderSync::sync_materials(bool update_all)
if(b_mat->use_nodes() && b_mat->node_tree()) {
BL::ShaderNodeTree b_ntree(b_mat->node_tree());
- add_nodes(scene, b_engine, b_data, b_scene, !preview, graph, b_ntree);
+ add_nodes(scene, b_engine, b_data, b_scene, b_scene_layer, !preview, graph, b_ntree);
}
else {
DiffuseBsdfNode *diffuse = new DiffuseBsdfNode();
@@ -1273,7 +1279,7 @@ void BlenderSync::sync_world(bool update_all)
if(b_world && b_world.use_nodes() && b_world.node_tree()) {
BL::ShaderNodeTree b_ntree(b_world.node_tree());
- add_nodes(scene, b_engine, b_data, b_scene, !preview, graph, b_ntree);
+ add_nodes(scene, b_engine, b_data, b_scene, b_scene_layer, !preview, graph, b_ntree);
/* volume */
PointerRNA cworld = RNA_pointer_get(&b_world.ptr, "cycles");
@@ -1368,7 +1374,7 @@ void BlenderSync::sync_lamps(bool update_all)
BL::ShaderNodeTree b_ntree(b_lamp->node_tree());
- add_nodes(scene, b_engine, b_data, b_scene, !preview, graph, b_ntree);
+ add_nodes(scene, b_engine, b_data, b_scene, b_scene_layer, !preview, graph, b_ntree);
}
else {
float strength = 1.0f;
diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp
index ab986766211..432f67f3b5e 100644
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@ -54,6 +54,7 @@ BlenderSync::BlenderSync(BL::RenderEngine& b_engine,
b_data(b_data),
b_depsgraph(b_depsgraph),
b_scene(b_scene),
+ b_scene_layer(b_engine.scene_layer()),
shader_map(&scene->shaders),
object_map(&scene->objects),
mesh_map(&scene->meshes),
@@ -236,7 +237,6 @@ void BlenderSync::sync_integrator()
Integrator *integrator = scene->integrator;
Integrator previntegrator = *integrator;
- integrator->min_bounce = get_int(cscene, "min_bounces");
integrator->max_bounce = get_int(cscene, "max_bounces");
integrator->max_diffuse_bounce = get_int(cscene, "diffuse_bounces");
@@ -245,8 +245,6 @@ void BlenderSync::sync_integrator()
integrator->max_volume_bounce = get_int(cscene, "volume_bounces");
integrator->transparent_max_bounce = get_int(cscene, "transparent_max_bounces");
- integrator->transparent_min_bounce = get_int(cscene, "transparent_min_bounces");
- integrator->transparent_shadows = get_boolean(cscene, "use_transparent_shadows");
integrator->volume_max_steps = get_int(cscene, "volume_max_steps");
integrator->volume_step_size = get_float(cscene, "volume_step_size");
@@ -613,14 +611,10 @@ SceneParams BlenderSync::get_scene_params(BL::Scene& b_scene,
else if(shadingsystem == 1)
params.shadingsystem = SHADINGSYSTEM_OSL;
- if(background)
+ if(background || DebugFlags().viewport_static_bvh)
params.bvh_type = SceneParams::BVH_STATIC;
else
- params.bvh_type = (SceneParams::BVHType)get_enum(
- cscene,
- "debug_bvh_type",
- SceneParams::BVH_NUM_TYPES,
- SceneParams::BVH_STATIC);
+ params.bvh_type = SceneParams::BVH_DYNAMIC;
params.use_bvh_spatial_split = RNA_boolean_get(&cscene, "debug_use_spatial_splits");
params.use_bvh_unaligned_nodes = RNA_boolean_get(&cscene, "debug_use_hair_bvh");
@@ -794,6 +788,7 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine& b_engine,
}
params.start_resolution = get_int(cscene, "preview_start_resolution");
+ params.pixel_size = b_engine.get_preview_pixel_size(b_scene);
/* other parameters */
if(b_scene.render().threads_mode() == BL::RenderSettings::threads_mode_FIXED)
@@ -814,6 +809,7 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine& b_engine,
params.progressive = false;
params.start_resolution = INT_MAX;
+ params.pixel_size = 1;
}
else
params.progressive = true;
diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h
index fda8cb390c2..69fee9551dd 100644
--- a/intern/cycles/blender/blender_sync.h
+++ b/intern/cycles/blender/blender_sync.h
@@ -43,6 +43,7 @@ class Mesh;
class Object;
class ParticleSystem;
class Scene;
+class SceneLayer;
class Shader;
class ShaderGraph;
class ShaderNode;
@@ -165,6 +166,7 @@ private:
BL::BlendData b_data;
BL::Depsgraph b_depsgraph;
BL::Scene b_scene;
+ BL::SceneLayer b_scene_layer;
id_map<void*, Shader> shader_map;
id_map<ObjectKey, Object> object_map;
diff --git a/intern/cycles/blender/blender_texture.cpp b/intern/cycles/blender/blender_texture.cpp
index b2e27b76189..dd08be3ddc9 100644
--- a/intern/cycles/blender/blender_texture.cpp
+++ b/intern/cycles/blender/blender_texture.cpp
@@ -34,7 +34,7 @@ void density_texture_space_invert(float3& loc,
} /* namespace */
-void point_density_texture_space(BL::Scene& b_scene,
+void point_density_texture_space(BL::Scene& b_scene, BL::SceneLayer& b_scene_layer,
BL::ShaderNodeTexPointDensity& b_point_density_node,
int settings,
float3& loc,
@@ -48,6 +48,7 @@ void point_density_texture_space(BL::Scene& b_scene,
}
float3 min, max;
b_point_density_node.calc_point_density_minmax(b_scene,
+ b_scene_layer,
settings,
&min[0],
&max[0]);
diff --git a/intern/cycles/blender/blender_texture.h b/intern/cycles/blender/blender_texture.h
index 734231a85ec..c343d5dab92 100644
--- a/intern/cycles/blender/blender_texture.h
+++ b/intern/cycles/blender/blender_texture.h
@@ -22,7 +22,7 @@
CCL_NAMESPACE_BEGIN
-void point_density_texture_space(BL::Scene& b_scene,
+void point_density_texture_space(BL::Scene& b_scene, BL::SceneLayer& b_scene_layer,
BL::ShaderNodeTexPointDensity& b_point_density_node,
const int settings,
float3& loc,
diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h
index ebbf325f95b..314bcaf23c4 100644
--- a/intern/cycles/blender/blender_util.h
+++ b/intern/cycles/blender/blender_util.h
@@ -46,13 +46,14 @@ void python_thread_state_restore(void **python_thread_state);
static inline BL::Mesh object_to_mesh(BL::BlendData& data,
BL::Object& object,
BL::Scene& scene,
+ BL::SceneLayer scene_layer,
bool apply_modifiers,
bool render,
bool calc_undeformed,
Mesh::SubdivisionType subdivision_type)
{
- bool subsurf_mod_show_render;
- bool subsurf_mod_show_viewport;
+ bool subsurf_mod_show_render = false;
+ bool subsurf_mod_show_viewport = false;
if(subdivision_type != Mesh::SUBDIVISION_NONE) {
BL::Modifier subsurf_mod = object.modifiers[object.modifiers.length()-1];
@@ -64,7 +65,7 @@ static inline BL::Mesh object_to_mesh(BL::BlendData& data,
subsurf_mod.show_viewport(false);
}
- BL::Mesh me = data.meshes.new_from_object(scene, object, apply_modifiers, (render)? 2: 1, false, calc_undeformed);
+ BL::Mesh me = data.meshes.new_from_object(scene, scene_layer, object, apply_modifiers, (render)? 2: 1, false, calc_undeformed);
if(subdivision_type != Mesh::SUBDIVISION_NONE) {
BL::Modifier subsurf_mod = object.modifiers[object.modifiers.length()-1];
diff --git a/intern/cycles/bvh/bvh.cpp b/intern/cycles/bvh/bvh.cpp
index 33143e2d8aa..0ad3c8a7429 100644
--- a/intern/cycles/bvh/bvh.cpp
+++ b/intern/cycles/bvh/bvh.cpp
@@ -153,7 +153,6 @@ void BVH::pack_primitives()
if(pack.prim_index[i] != -1) {
int tob = pack.prim_object[i];
Object *ob = objects[tob];
-
if((pack.prim_type[i] & PRIMITIVE_ALL_TRIANGLE) != 0) {
pack_triangle(i, (float4*)&pack.prim_tri_verts[3 * prim_triangle_index]);
pack.prim_tri_index[i] = 3 * prim_triangle_index;
@@ -162,11 +161,10 @@ void BVH::pack_primitives()
else {
pack.prim_tri_index[i] = -1;
}
-
- pack.prim_visibility[i] = ob->visibility;
-
- if(pack.prim_type[i] & PRIMITIVE_ALL_CURVE)
+ pack.prim_visibility[i] = ob->visibility_for_tracing();
+ if(pack.prim_type[i] & PRIMITIVE_ALL_CURVE) {
pack.prim_visibility[i] |= PATH_RAY_CURVE;
+ }
}
else {
pack.prim_tri_index[i] = -1;
diff --git a/intern/cycles/bvh/bvh2.cpp b/intern/cycles/bvh/bvh2.cpp
index 340ba7dcf53..9aa8e71dfd0 100644
--- a/intern/cycles/bvh/bvh2.cpp
+++ b/intern/cycles/bvh/bvh2.cpp
@@ -312,10 +312,8 @@ void BVH2::refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility)
}
}
}
-
- visibility |= ob->visibility;
+ visibility |= ob->visibility_for_tracing();
}
-
/* TODO(sergey): De-duplicate with pack_leaf(). */
float4 leaf_data[BVH_NODE_LEAF_SIZE];
leaf_data[0].x = __int_as_float(c0);
diff --git a/intern/cycles/bvh/bvh4.cpp b/intern/cycles/bvh/bvh4.cpp
index 5034ab811d5..777de20423b 100644
--- a/intern/cycles/bvh/bvh4.cpp
+++ b/intern/cycles/bvh/bvh4.cpp
@@ -242,21 +242,21 @@ void BVH4::pack_unaligned_node(int idx,
* so kernel might safely assume there are always 4 child nodes.
*/
- data[1][i] = 1.0f;
- data[2][i] = 0.0f;
- data[3][i] = 0.0f;
+ data[1][i] = NAN;
+ data[2][i] = NAN;
+ data[3][i] = NAN;
- data[4][i] = 0.0f;
- data[5][i] = 0.0f;
- data[6][i] = 0.0f;
+ data[4][i] = NAN;
+ data[5][i] = NAN;
+ data[6][i] = NAN;
- data[7][i] = 0.0f;
- data[8][i] = 0.0f;
- data[9][i] = 0.0f;
+ data[7][i] = NAN;
+ data[8][i] = NAN;
+ data[9][i] = NAN;
- data[10][i] = -FLT_MAX;
- data[11][i] = -FLT_MAX;
- data[12][i] = -FLT_MAX;
+ data[10][i] = NAN;
+ data[11][i] = NAN;
+ data[12][i] = NAN;
data[13][i] = __int_as_float(0);
}
@@ -438,10 +438,8 @@ void BVH4::refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility)
}
}
}
-
- visibility |= ob->visibility;
+ visibility |= ob->visibility_for_tracing();
}
-
/* TODO(sergey): This is actually a copy of pack_leaf(),
* but this chunk of code only knows actual data and has
* no idea about BVHNode.
diff --git a/intern/cycles/bvh/bvh_build.cpp b/intern/cycles/bvh/bvh_build.cpp
index 1880964355c..649ce52da05 100644
--- a/intern/cycles/bvh/bvh_build.cpp
+++ b/intern/cycles/bvh/bvh_build.cpp
@@ -529,7 +529,9 @@ BVHNode* BVHBuild::run()
<< " Allocation slop factor: "
<< ((prim_type.capacity() != 0)
? (float)prim_type.size() / prim_type.capacity()
- : 1.0f) << "\n";
+ : 1.0f) << "\n"
+ << " Maximum depth: "
+ << string_human_readable_number(rootnode->getSubtreeSize(BVH_STAT_DEPTH)) << "\n";
}
}
@@ -671,7 +673,7 @@ BVHNode* BVHBuild::build_node(const BVHObjectBinning& range, int level)
return create_leaf_node(range, references);
}
}
- /* Check whether unaligned split is better than the regulat one. */
+ /* Check whether unaligned split is better than the regular one. */
if(unalignedSplitSAH < splitSAH) {
do_unalinged_split = true;
}
@@ -865,7 +867,7 @@ BVHNode *BVHBuild::create_object_leaf_nodes(const BVHReference *ref, int start,
prim_time[start] = make_float2(ref->time_from(), ref->time_to());
}
- uint visibility = objects[ref->prim_object()]->visibility;
+ const uint visibility = objects[ref->prim_object()]->visibility_for_tracing();
BVHNode *leaf_node = new LeafNode(ref->bounds(), visibility, start, start+1);
leaf_node->time_from = ref->time_from();
leaf_node->time_to = ref->time_to();
@@ -939,7 +941,7 @@ BVHNode* BVHBuild::create_leaf_node(const BVHRange& range,
ref.time_to()));
bounds[type_index].grow(ref.bounds());
- visibility[type_index] |= objects[ref.prim_object()]->visibility;
+ visibility[type_index] |= objects[ref.prim_object()]->visibility_for_tracing();
if(ref.prim_type() & PRIMITIVE_ALL_CURVE) {
visibility[type_index] |= PATH_RAY_CURVE;
}
@@ -1040,7 +1042,6 @@ BVHNode* BVHBuild::create_leaf_node(const BVHRange& range,
*/
start_index = spatial_free_index;
spatial_free_index += range.size();
-
/* Extend an array when needed. */
const size_t range_end = start_index + range.size();
if(prim_type.size() < range_end) {
@@ -1066,8 +1067,6 @@ BVHNode* BVHBuild::create_leaf_node(const BVHRange& range,
prim_time.resize(range_end);
}
}
- spatial_spin_lock.unlock();
-
/* Perform actual data copy. */
if(new_leaf_data_size > 0) {
memcpy(&prim_type[start_index], &local_prim_type[0], new_leaf_data_size);
@@ -1077,6 +1076,7 @@ BVHNode* BVHBuild::create_leaf_node(const BVHRange& range,
memcpy(&prim_time[start_index], &local_prim_time[0], sizeof(float2)*num_new_leaf_data);
}
}
+ spatial_spin_lock.unlock();
}
else {
/* For the regular BVH builder we simply copy new data starting at the
diff --git a/intern/cycles/bvh/bvh_node.cpp b/intern/cycles/bvh/bvh_node.cpp
index 4237c62ab5b..ab6df4d265d 100644
--- a/intern/cycles/bvh/bvh_node.cpp
+++ b/intern/cycles/bvh/bvh_node.cpp
@@ -132,6 +132,17 @@ int BVHNode::getSubtreeSize(BVH_STAT stat) const
case BVH_STAT_UNALIGNED_LEAF_COUNT:
cnt = (is_leaf() && is_unaligned) ? 1 : 0;
break;
+ case BVH_STAT_DEPTH:
+ if(is_leaf()) {
+ cnt = 1;
+ }
+ else {
+ for(int i = 0; i < num_children(); i++) {
+ cnt = max(cnt, get_child(i)->getSubtreeSize(stat));
+ }
+ cnt += 1;
+ }
+ return cnt;
default:
assert(0); /* unknown mode */
}
diff --git a/intern/cycles/bvh/bvh_node.h b/intern/cycles/bvh/bvh_node.h
index 1c875f5a524..94cf5ab730c 100644
--- a/intern/cycles/bvh/bvh_node.h
+++ b/intern/cycles/bvh/bvh_node.h
@@ -38,6 +38,7 @@ enum BVH_STAT {
BVH_STAT_UNALIGNED_INNER_QNODE_COUNT,
BVH_STAT_ALIGNED_LEAF_COUNT,
BVH_STAT_UNALIGNED_LEAF_COUNT,
+ BVH_STAT_DEPTH,
};
class BVHParams;
diff --git a/intern/cycles/device/CMakeLists.txt b/intern/cycles/device/CMakeLists.txt
index 74ec57ddf74..3c632160fbd 100644
--- a/intern/cycles/device/CMakeLists.txt
+++ b/intern/cycles/device/CMakeLists.txt
@@ -34,11 +34,13 @@ set(SRC
set(SRC_OPENCL
opencl/opencl.h
+ opencl/memory_manager.h
opencl/opencl_base.cpp
opencl/opencl_mega.cpp
opencl/opencl_split.cpp
opencl/opencl_util.cpp
+ opencl/memory_manager.cpp
)
if(WITH_CYCLES_NETWORK)
diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp
index 31671e76ec3..5ae83b56fcd 100644
--- a/intern/cycles/device/device.cpp
+++ b/intern/cycles/device/device.cpp
@@ -526,11 +526,9 @@ DeviceInfo Device::get_multi_device(vector<DeviceInfo> subdevices)
info.num = 0;
info.has_bindless_textures = true;
- info.pack_images = false;
foreach(DeviceInfo &device, subdevices) {
assert(device.type == info.multi_devices[0].type);
- info.pack_images |= device.pack_images;
info.has_bindless_textures &= device.has_bindless_textures;
}
diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h
index 68a555c1a93..8736a6927e0 100644
--- a/intern/cycles/device/device.h
+++ b/intern/cycles/device/device.h
@@ -53,7 +53,6 @@ public:
int num;
bool display_device;
bool advanced_shading;
- bool pack_images;
bool has_bindless_textures; /* flag for GPU and Multi device */
bool use_split_kernel; /* Denotes if the device is going to run cycles using split-kernel */
vector<DeviceInfo> multi_devices;
@@ -65,7 +64,6 @@ public:
num = 0;
display_device = false;
advanced_shading = true;
- pack_images = false;
has_bindless_textures = false;
use_split_kernel = false;
}
diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp
index 29bb1f91a40..19e3c0a9075 100644
--- a/intern/cycles/device/device_cpu.cpp
+++ b/intern/cycles/device/device_cpu.cpp
@@ -48,6 +48,7 @@
#include "util/util_logging.h"
#include "util/util_map.h"
#include "util/util_opengl.h"
+#include "util/util_optimization.h"
#include "util/util_progress.h"
#include "util/util_system.h"
#include "util/util_thread.h"
@@ -119,7 +120,7 @@ public:
}
#endif
- if(strstr(architecture_name, logged_architecture) != 0) {
+ if(strcmp(architecture_name, logged_architecture) != 0) {
VLOG(1) << "Will be using " << architecture_name << " kernels.";
logged_architecture = architecture_name;
}
@@ -149,7 +150,8 @@ public:
device_memory& use_queues_flag,
device_memory& work_pool_wgs);
- virtual SplitKernelFunction* get_split_kernel_function(string kernel_name, const DeviceRequestedFeatures&);
+ virtual SplitKernelFunction* get_split_kernel_function(const string& kernel_name,
+ const DeviceRequestedFeatures&);
virtual int2 split_kernel_local_size();
virtual int2 split_kernel_global_size(device_memory& kg, device_memory& data, DeviceTask *task);
virtual uint64_t state_buffer_size(device_memory& kg, device_memory& data, size_t num_threads);
@@ -169,15 +171,15 @@ public:
DeviceRequestedFeatures requested_features;
- KernelFunctions<void(*)(KernelGlobals *, float *, unsigned int *, int, int, int, int, int)> path_trace_kernel;
- KernelFunctions<void(*)(KernelGlobals *, uchar4 *, float *, float, int, int, int, int)> convert_to_half_float_kernel;
- KernelFunctions<void(*)(KernelGlobals *, uchar4 *, float *, float, int, int, int, int)> convert_to_byte_kernel;
- KernelFunctions<void(*)(KernelGlobals *, uint4 *, float4 *, float*, int, int, int, int, int)> shader_kernel;
+ KernelFunctions<void(*)(KernelGlobals *, float *, int, int, int, int, int)> path_trace_kernel;
+ KernelFunctions<void(*)(KernelGlobals *, uchar4 *, float *, float, int, int, int, int)> convert_to_half_float_kernel;
+ KernelFunctions<void(*)(KernelGlobals *, uchar4 *, float *, float, int, int, int, int)> convert_to_byte_kernel;
+ KernelFunctions<void(*)(KernelGlobals *, uint4 *, float4 *, int, int, int, int, int)> shader_kernel;
- KernelFunctions<void(*)(int, TilesInfo*, int, int, float*, float*, float*, float*, float*, int*, int, int, bool)> filter_divide_shadow_kernel;
- KernelFunctions<void(*)(int, TilesInfo*, int, int, int, int, float*, float*, int*, int, int, bool)> filter_get_feature_kernel;
- KernelFunctions<void(*)(int, int, float*, float*, float*, float*, int*, int)> filter_detect_outliers_kernel;
- KernelFunctions<void(*)(int, int, float*, float*, float*, float*, int*, int)> filter_combine_halves_kernel;
+ KernelFunctions<void(*)(int, TilesInfo*, int, int, float*, float*, float*, float*, float*, int*, int, int)> filter_divide_shadow_kernel;
+ KernelFunctions<void(*)(int, TilesInfo*, int, int, int, int, float*, float*, int*, int, int)> filter_get_feature_kernel;
+ KernelFunctions<void(*)(int, int, float*, float*, float*, float*, int*, int)> filter_detect_outliers_kernel;
+ KernelFunctions<void(*)(int, int, float*, float*, float*, float*, int*, int)> filter_combine_halves_kernel;
KernelFunctions<void(*)(int, int, float*, float*, float*, int*, int, int, float, float)> filter_nlm_calc_difference_kernel;
KernelFunctions<void(*)(float*, float*, int*, int, int)> filter_nlm_blur_kernel;
@@ -190,7 +192,7 @@ public:
KernelFunctions<void(*)(int, int, int, int, int, float*, int*, float*, float3*, int*, int)> filter_finalize_kernel;
KernelFunctions<void(*)(KernelGlobals *, ccl_constant KernelData*, ccl_global void*, int, ccl_global char*,
- ccl_global uint*, int, int, int, int, int, int, int, int, ccl_global int*, int,
+ int, int, int, int, int, int, int, int, ccl_global int*, int,
ccl_global char*, ccl_global unsigned int*, unsigned int, ccl_global float*)> data_init_kernel;
unordered_map<string, KernelFunctions<void(*)(KernelGlobals*, KernelData*)> > split_kernels;
@@ -248,6 +250,7 @@ public:
REGISTER_SPLIT_KERNEL(direct_lighting);
REGISTER_SPLIT_KERNEL(shadow_blocked_ao);
REGISTER_SPLIT_KERNEL(shadow_blocked_dl);
+ REGISTER_SPLIT_KERNEL(enqueue_inactive);
REGISTER_SPLIT_KERNEL(next_iteration_setup);
REGISTER_SPLIT_KERNEL(indirect_subsurface);
REGISTER_SPLIT_KERNEL(buffer_update);
@@ -560,8 +563,7 @@ public:
(float*) buffer_variance_ptr,
&task->rect.x,
task->render_buffer.pass_stride,
- task->render_buffer.denoising_data_offset,
- use_split_kernel);
+ task->render_buffer.denoising_data_offset);
}
}
return true;
@@ -584,8 +586,7 @@ public:
(float*) variance_ptr,
&task->rect.x,
task->render_buffer.pass_stride,
- task->render_buffer.denoising_data_offset,
- use_split_kernel);
+ task->render_buffer.denoising_data_offset);
}
}
return true;
@@ -614,7 +615,6 @@ public:
void path_trace(DeviceTask &task, RenderTile &tile, KernelGlobals *kg)
{
float *render_buffer = (float*)tile.buffer;
- uint *rng_state = (uint*)tile.rng_state;
int start_sample = tile.start_sample;
int end_sample = tile.start_sample + tile.num_samples;
@@ -626,7 +626,7 @@ public:
for(int y = tile.y; y < tile.y + tile.h; y++) {
for(int x = tile.x; x < tile.x + tile.w; x++) {
- path_trace_kernel()(kg, render_buffer, rng_state,
+ path_trace_kernel()(kg, render_buffer,
sample, x, y, tile.offset, tile.stride);
}
}
@@ -756,7 +756,6 @@ public:
shader_kernel()(&kg,
(uint4*)task.shader_input,
(float4*)task.shader_output,
- (float*)task.shader_output_luma,
task.shader_eval_type,
task.shader_filter,
x,
@@ -910,7 +909,6 @@ bool CPUSplitKernel::enqueue_split_kernel_data_init(const KernelDimensions& dim,
(void*)split_data.device_pointer,
num_global_elements,
(char*)ray_state.device_pointer,
- (uint*)rtile.rng_state,
rtile.start_sample,
rtile.start_sample + rtile.num_samples,
rtile.x,
@@ -931,7 +929,8 @@ bool CPUSplitKernel::enqueue_split_kernel_data_init(const KernelDimensions& dim,
return true;
}
-SplitKernelFunction* CPUSplitKernel::get_split_kernel_function(string kernel_name, const DeviceRequestedFeatures&)
+SplitKernelFunction* CPUSplitKernel::get_split_kernel_function(const string& kernel_name,
+ const DeviceRequestedFeatures&)
{
CPUSplitKernelFunction *kernel = new CPUSplitKernelFunction(device);
@@ -973,7 +972,6 @@ void device_cpu_info(vector<DeviceInfo>& devices)
info.id = "CPU";
info.num = 0;
info.advanced_shading = true;
- info.pack_images = false;
devices.insert(devices.begin(), info);
}
diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp
index 19e68007934..48ffa1484fb 100644
--- a/intern/cycles/device/device_cuda.cpp
+++ b/intern/cycles/device/device_cuda.cpp
@@ -105,11 +105,22 @@ public:
device_memory& use_queues_flag,
device_memory& work_pool_wgs);
- virtual SplitKernelFunction* get_split_kernel_function(string kernel_name, const DeviceRequestedFeatures&);
+ virtual SplitKernelFunction* get_split_kernel_function(const string& kernel_name,
+ const DeviceRequestedFeatures&);
virtual int2 split_kernel_local_size();
virtual int2 split_kernel_global_size(device_memory& kg, device_memory& data, DeviceTask *task);
};
+/* Utility to push/pop CUDA context. */
+class CUDAContextScope {
+public:
+ CUDAContextScope(CUDADevice *device);
+ ~CUDAContextScope();
+
+private:
+ CUDADevice *device;
+};
+
class CUDADevice : public Device
{
public:
@@ -205,16 +216,6 @@ public:
cuda_error_documentation();
}
- void cuda_push_context()
- {
- cuda_assert(cuCtxSetCurrent(cuContext));
- }
-
- void cuda_pop_context()
- {
- cuda_assert(cuCtxSetCurrent(NULL));
- }
-
CUDADevice(DeviceInfo& info, Stats &stats, bool background_)
: Device(info, stats, background_)
{
@@ -262,7 +263,8 @@ public:
cuDeviceGetAttribute(&minor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, cuDevId);
cuDevArchitecture = major*100 + minor*10;
- cuda_pop_context();
+ /* Pop context set by cuCtxCreate. */
+ cuCtxPopCurrent(NULL);
}
~CUDADevice()
@@ -518,7 +520,7 @@ public:
return false;
/* open module */
- cuda_push_context();
+ CUDAContextScope scope(this);
string cubin_data;
CUresult result;
@@ -539,8 +541,6 @@ public:
if(cuda_error_(result, "cuModuleLoad"))
cuda_error_message(string_printf("Failed loading CUDA kernel %s.", filter_cubin.c_str()));
- cuda_pop_context();
-
return (result == CUDA_SUCCESS);
}
@@ -555,36 +555,36 @@ public:
void mem_alloc(const char *name, device_memory& mem, MemoryType /*type*/)
{
+ CUDAContextScope scope(this);
+
if(name) {
VLOG(1) << "Buffer allocate: " << name << ", "
<< string_human_readable_number(mem.memory_size()) << " bytes. ("
<< string_human_readable_size(mem.memory_size()) << ")";
}
- cuda_push_context();
CUdeviceptr device_pointer;
size_t size = mem.memory_size();
cuda_assert(cuMemAlloc(&device_pointer, size));
mem.device_pointer = (device_ptr)device_pointer;
mem.device_size = size;
stats.mem_alloc(size);
- cuda_pop_context();
}
void mem_copy_to(device_memory& mem)
{
- cuda_push_context();
+ CUDAContextScope scope(this);
+
if(mem.device_pointer)
cuda_assert(cuMemcpyHtoD(cuda_device_ptr(mem.device_pointer), (void*)mem.data_pointer, mem.memory_size()));
- cuda_pop_context();
}
void mem_copy_from(device_memory& mem, int y, int w, int h, int elem)
{
+ CUDAContextScope scope(this);
size_t offset = elem*y*w;
size_t size = elem*w*h;
- cuda_push_context();
if(mem.device_pointer) {
cuda_assert(cuMemcpyDtoH((uchar*)mem.data_pointer + offset,
(CUdeviceptr)(mem.device_pointer + offset), size));
@@ -592,7 +592,6 @@ public:
else {
memset((char*)mem.data_pointer + offset, 0, size);
}
- cuda_pop_context();
}
void mem_zero(device_memory& mem)
@@ -601,18 +600,17 @@ public:
memset((void*)mem.data_pointer, 0, mem.memory_size());
}
- cuda_push_context();
- if(mem.device_pointer)
+ if(mem.device_pointer) {
+ CUDAContextScope scope(this);
cuda_assert(cuMemsetD8(cuda_device_ptr(mem.device_pointer), 0, mem.memory_size()));
- cuda_pop_context();
+ }
}
void mem_free(device_memory& mem)
{
if(mem.device_pointer) {
- cuda_push_context();
+ CUDAContextScope scope(this);
cuda_assert(cuMemFree(cuda_device_ptr(mem.device_pointer)));
- cuda_pop_context();
mem.device_pointer = 0;
@@ -628,14 +626,13 @@ public:
void const_copy_to(const char *name, void *host, size_t size)
{
+ CUDAContextScope scope(this);
CUdeviceptr mem;
size_t bytes;
- cuda_push_context();
cuda_assert(cuModuleGetGlobal(&mem, &bytes, cuModule, name));
//assert(bytes == size);
cuda_assert(cuMemcpyHtoD(mem, host, size));
- cuda_pop_context();
}
void tex_alloc(const char *name,
@@ -643,6 +640,8 @@ public:
InterpolationType interpolation,
ExtensionType extension)
{
+ CUDAContextScope scope(this);
+
VLOG(1) << "Texture allocate: " << name << ", "
<< string_human_readable_number(mem.memory_size()) << " bytes. ("
<< string_human_readable_size(mem.memory_size()) << ")";
@@ -705,9 +704,7 @@ public:
tokens[3].c_str());
}
- cuda_push_context();
cuda_assert(cuModuleGetTexRef(&texref, cuModule, bind_name.c_str()));
- cuda_pop_context();
if(!texref) {
return;
@@ -720,8 +717,6 @@ public:
mem_alloc(NULL, mem, MEM_READ_ONLY);
mem_copy_to(mem);
- cuda_push_context();
-
CUdeviceptr cumem;
size_t cubytes;
@@ -737,28 +732,20 @@ public:
uint32_t ptr = (uint32_t)mem.device_pointer;
cuda_assert(cuMemcpyHtoD(cumem, (void*)&ptr, cubytes));
}
-
- cuda_pop_context();
}
else {
mem_alloc(NULL, mem, MEM_READ_ONLY);
mem_copy_to(mem);
- cuda_push_context();
-
cuda_assert(cuTexRefSetAddress(NULL, texref, cuda_device_ptr(mem.device_pointer), size));
cuda_assert(cuTexRefSetFilterMode(texref, CU_TR_FILTER_MODE_POINT));
cuda_assert(cuTexRefSetFlags(texref, CU_TRSF_READ_AS_INTEGER));
-
- cuda_pop_context();
}
}
/* Texture Storage */
else {
CUarray handle = NULL;
- cuda_push_context();
-
if(mem.data_depth > 1) {
CUDA_ARRAY3D_DESCRIPTOR desc;
@@ -783,7 +770,6 @@ public:
}
if(!handle) {
- cuda_pop_context();
return;
}
@@ -876,14 +862,10 @@ public:
cuda_assert(cuTexRefSetFilterMode(texref, filter_mode));
cuda_assert(cuTexRefSetFlags(texref, CU_TRSF_NORMALIZED_COORDINATES));
}
-
- cuda_pop_context();
}
/* Fermi, Data and Image Textures */
if(!has_bindless_textures) {
- cuda_push_context();
-
cuda_assert(cuTexRefSetAddressMode(texref, 0, address_mode));
cuda_assert(cuTexRefSetAddressMode(texref, 1, address_mode));
if(mem.data_depth > 1) {
@@ -891,8 +873,6 @@ public:
}
cuda_assert(cuTexRefSetFormat(texref, format, mem.data_elements));
-
- cuda_pop_context();
}
/* Fermi and Kepler */
@@ -903,9 +883,8 @@ public:
{
if(mem.device_pointer) {
if(tex_interp_map[mem.device_pointer]) {
- cuda_push_context();
+ CUDAContextScope scope(this);
cuArrayDestroy((CUarray)mem.device_pointer);
- cuda_pop_context();
/* Free CUtexObject (Bindless Textures) */
if(info.has_bindless_textures && tex_bindless_map[mem.device_pointer]) {
@@ -959,7 +938,7 @@ public:
if(have_error())
return false;
- cuda_push_context();
+ CUDAContextScope scope(this);
int4 rect = task->rect;
int w = align_up(rect.z-rect.x, 4);
@@ -1016,7 +995,6 @@ public:
CUDA_LAUNCH_KERNEL(cuNLMNormalize, normalize_args);
cuda_assert(cuCtxSynchronize());
- cuda_pop_context();
return !have_error();
}
@@ -1025,7 +1003,7 @@ public:
if(have_error())
return false;
- cuda_push_context();
+ CUDAContextScope scope(this);
CUfunction cuFilterConstructTransform;
cuda_assert(cuModuleGetFunction(&cuFilterConstructTransform, cuFilterModule, "kernel_cuda_filter_construct_transform"));
@@ -1045,7 +1023,6 @@ public:
CUDA_LAUNCH_KERNEL(cuFilterConstructTransform, args);
cuda_assert(cuCtxSynchronize());
- cuda_pop_context();
return !have_error();
}
@@ -1057,11 +1034,11 @@ public:
if(have_error())
return false;
+ CUDAContextScope scope(this);
+
mem_zero(task->storage.XtWX);
mem_zero(task->storage.XtWY);
- cuda_push_context();
-
CUfunction cuNLMCalcDifference, cuNLMBlur, cuNLMCalcWeight, cuNLMConstructGramian, cuFinalize;
cuda_assert(cuModuleGetFunction(&cuNLMCalcDifference, cuFilterModule, "kernel_cuda_filter_nlm_calc_difference"));
cuda_assert(cuModuleGetFunction(&cuNLMBlur, cuFilterModule, "kernel_cuda_filter_nlm_blur"));
@@ -1149,7 +1126,6 @@ public:
CUDA_LAUNCH_KERNEL(cuFinalize, finalize_args);
cuda_assert(cuCtxSynchronize());
- cuda_pop_context();
return !have_error();
}
@@ -1160,7 +1136,7 @@ public:
if(have_error())
return false;
- cuda_push_context();
+ CUDAContextScope scope(this);
CUfunction cuFilterCombineHalves;
cuda_assert(cuModuleGetFunction(&cuFilterCombineHalves, cuFilterModule, "kernel_cuda_filter_combine_halves"));
@@ -1178,7 +1154,6 @@ public:
CUDA_LAUNCH_KERNEL(cuFilterCombineHalves, args);
cuda_assert(cuCtxSynchronize());
- cuda_pop_context();
return !have_error();
}
@@ -1189,7 +1164,7 @@ public:
if(have_error())
return false;
- cuda_push_context();
+ CUDAContextScope scope(this);
CUfunction cuFilterDivideShadow;
cuda_assert(cuModuleGetFunction(&cuFilterDivideShadow, cuFilterModule, "kernel_cuda_filter_divide_shadow"));
@@ -1198,7 +1173,6 @@ public:
task->rect.z-task->rect.x,
task->rect.w-task->rect.y);
- bool use_split_variance = use_split_kernel();
void *args[] = {&task->render_buffer.samples,
&task->tiles_mem.device_pointer,
&a_ptr,
@@ -1208,12 +1182,10 @@ public:
&buffer_variance_ptr,
&task->rect,
&task->render_buffer.pass_stride,
- &task->render_buffer.denoising_data_offset,
- &use_split_variance};
+ &task->render_buffer.denoising_data_offset};
CUDA_LAUNCH_KERNEL(cuFilterDivideShadow, args);
cuda_assert(cuCtxSynchronize());
- cuda_pop_context();
return !have_error();
}
@@ -1226,7 +1198,7 @@ public:
if(have_error())
return false;
- cuda_push_context();
+ CUDAContextScope scope(this);
CUfunction cuFilterGetFeature;
cuda_assert(cuModuleGetFunction(&cuFilterGetFeature, cuFilterModule, "kernel_cuda_filter_get_feature"));
@@ -1235,7 +1207,6 @@ public:
task->rect.z-task->rect.x,
task->rect.w-task->rect.y);
- bool use_split_variance = use_split_kernel();
void *args[] = {&task->render_buffer.samples,
&task->tiles_mem.device_pointer,
&mean_offset,
@@ -1244,12 +1215,10 @@ public:
&variance_ptr,
&task->rect,
&task->render_buffer.pass_stride,
- &task->render_buffer.denoising_data_offset,
- &use_split_variance};
+ &task->render_buffer.denoising_data_offset};
CUDA_LAUNCH_KERNEL(cuFilterGetFeature, args);
cuda_assert(cuCtxSynchronize());
- cuda_pop_context();
return !have_error();
}
@@ -1262,7 +1231,7 @@ public:
if(have_error())
return false;
- cuda_push_context();
+ CUDAContextScope scope(this);
CUfunction cuFilterDetectOutliers;
cuda_assert(cuModuleGetFunction(&cuFilterDetectOutliers, cuFilterModule, "kernel_cuda_filter_detect_outliers"));
@@ -1281,7 +1250,6 @@ public:
CUDA_LAUNCH_KERNEL(cuFilterDetectOutliers, args);
cuda_assert(cuCtxSynchronize());
- cuda_pop_context();
return !have_error();
}
@@ -1313,64 +1281,85 @@ public:
task.unmap_neighbor_tiles(rtiles, this);
}
- void path_trace(RenderTile& rtile, int sample, bool branched)
+ void path_trace(DeviceTask& task, RenderTile& rtile)
{
if(have_error())
return;
- cuda_push_context();
-
+ CUDAContextScope scope(this);
CUfunction cuPathTrace;
- CUdeviceptr d_buffer = cuda_device_ptr(rtile.buffer);
- CUdeviceptr d_rng_state = cuda_device_ptr(rtile.rng_state);
- /* get kernel function */
- if(branched) {
+ /* Get kernel function. */
+ if(task.integrator_branched) {
cuda_assert(cuModuleGetFunction(&cuPathTrace, cuModule, "kernel_cuda_branched_path_trace"));
}
else {
cuda_assert(cuModuleGetFunction(&cuPathTrace, cuModule, "kernel_cuda_path_trace"));
}
- if(have_error())
+ if(have_error()) {
return;
+ }
- /* pass in parameters */
- void *args[] = {&d_buffer,
- &d_rng_state,
- &sample,
- &rtile.x,
- &rtile.y,
- &rtile.w,
- &rtile.h,
- &rtile.offset,
- &rtile.stride};
-
- /* launch kernel */
- int threads_per_block;
- cuda_assert(cuFuncGetAttribute(&threads_per_block, CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK, cuPathTrace));
-
- /*int num_registers;
- cuda_assert(cuFuncGetAttribute(&num_registers, CU_FUNC_ATTRIBUTE_NUM_REGS, cuPathTrace));
-
- printf("threads_per_block %d\n", threads_per_block);
- printf("num_registers %d\n", num_registers);*/
+ cuda_assert(cuFuncSetCacheConfig(cuPathTrace, CU_FUNC_CACHE_PREFER_L1));
- int xthreads = (int)sqrt(threads_per_block);
- int ythreads = (int)sqrt(threads_per_block);
- int xblocks = (rtile.w + xthreads - 1)/xthreads;
- int yblocks = (rtile.h + ythreads - 1)/ythreads;
+ /* Allocate work tile. */
+ device_vector<WorkTile> work_tiles;
+ work_tiles.resize(1);
+
+ WorkTile *wtile = work_tiles.get_data();
+ wtile->x = rtile.x;
+ wtile->y = rtile.y;
+ wtile->w = rtile.w;
+ wtile->h = rtile.h;
+ wtile->offset = rtile.offset;
+ wtile->stride = rtile.stride;
+ wtile->buffer = (float*)cuda_device_ptr(rtile.buffer);
+ mem_alloc("work_tiles", work_tiles, MEM_READ_ONLY);
+
+ CUdeviceptr d_work_tiles = cuda_device_ptr(work_tiles.device_pointer);
+
+ /* Prepare work size. More step samples render faster, but for now we
+ * remain conservative to avoid driver timeouts. */
+ int min_blocks, num_threads_per_block;
+ cuda_assert(cuOccupancyMaxPotentialBlockSize(&min_blocks, &num_threads_per_block, cuPathTrace, NULL, 0, 0));
+ uint step_samples = divide_up(min_blocks * num_threads_per_block, wtile->w * wtile->h);;
+
+ /* Render all samples. */
+ int start_sample = rtile.start_sample;
+ int end_sample = rtile.start_sample + rtile.num_samples;
+
+ for(int sample = start_sample; sample < end_sample; sample += step_samples) {
+ /* Setup and copy work tile to device. */
+ wtile->start_sample = sample;
+ wtile->num_samples = min(step_samples, end_sample - sample);;
+ mem_copy_to(work_tiles);
+
+ uint total_work_size = wtile->w * wtile->h * wtile->num_samples;
+ uint num_blocks = divide_up(total_work_size, num_threads_per_block);
+
+ /* Launch kernel. */
+ void *args[] = {&d_work_tiles,
+ &total_work_size};
+
+ cuda_assert(cuLaunchKernel(cuPathTrace,
+ num_blocks, 1, 1,
+ num_threads_per_block, 1, 1,
+ 0, 0, args, 0));
- cuda_assert(cuFuncSetCacheConfig(cuPathTrace, CU_FUNC_CACHE_PREFER_L1));
+ cuda_assert(cuCtxSynchronize());
- cuda_assert(cuLaunchKernel(cuPathTrace,
- xblocks , yblocks, 1, /* blocks */
- xthreads, ythreads, 1, /* threads */
- 0, 0, args, 0));
+ /* Update progress. */
+ rtile.sample = sample + wtile->num_samples;
+ task.update_progress(&rtile, rtile.w*rtile.h*wtile->num_samples);
- cuda_assert(cuCtxSynchronize());
+ if(task.get_cancel()) {
+ if(task.need_finish_queue == false)
+ break;
+ }
+ }
- cuda_pop_context();
+ mem_free(work_tiles);
}
void film_convert(DeviceTask& task, device_ptr buffer, device_ptr rgba_byte, device_ptr rgba_half)
@@ -1378,7 +1367,7 @@ public:
if(have_error())
return;
- cuda_push_context();
+ CUDAContextScope scope(this);
CUfunction cuFilmConvert;
CUdeviceptr d_rgba = map_pixels((rgba_byte)? rgba_byte: rgba_half);
@@ -1423,8 +1412,6 @@ public:
0, 0, args, 0));
unmap_pixels((rgba_byte)? rgba_byte: rgba_half);
-
- cuda_pop_context();
}
void shader(DeviceTask& task)
@@ -1432,19 +1419,21 @@ public:
if(have_error())
return;
- cuda_push_context();
+ CUDAContextScope scope(this);
CUfunction cuShader;
CUdeviceptr d_input = cuda_device_ptr(task.shader_input);
CUdeviceptr d_output = cuda_device_ptr(task.shader_output);
- CUdeviceptr d_output_luma = cuda_device_ptr(task.shader_output_luma);
/* get kernel function */
if(task.shader_eval_type >= SHADER_EVAL_BAKE) {
cuda_assert(cuModuleGetFunction(&cuShader, cuModule, "kernel_cuda_bake"));
}
+ else if(task.shader_eval_type == SHADER_EVAL_DISPLACE) {
+ cuda_assert(cuModuleGetFunction(&cuShader, cuModule, "kernel_cuda_displace"));
+ }
else {
- cuda_assert(cuModuleGetFunction(&cuShader, cuModule, "kernel_cuda_shader"));
+ cuda_assert(cuModuleGetFunction(&cuShader, cuModule, "kernel_cuda_background"));
}
/* do tasks in smaller chunks, so we can cancel it */
@@ -1463,9 +1452,6 @@ public:
int arg = 0;
args[arg++] = &d_input;
args[arg++] = &d_output;
- if(task.shader_eval_type < SHADER_EVAL_BAKE) {
- args[arg++] = &d_output_luma;
- }
args[arg++] = &task.shader_eval_type;
if(task.shader_eval_type >= SHADER_EVAL_BAKE) {
args[arg++] = &task.shader_filter;
@@ -1497,8 +1483,6 @@ public:
task.update_progress(NULL);
}
-
- cuda_pop_context();
}
CUdeviceptr map_pixels(device_ptr mem)
@@ -1534,7 +1518,7 @@ public:
pmem.w = mem.data_width;
pmem.h = mem.data_height;
- cuda_push_context();
+ CUDAContextScope scope(this);
glGenBuffers(1, &pmem.cuPBO);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pmem.cuPBO);
@@ -1558,8 +1542,6 @@ public:
CUresult result = cuGraphicsGLRegisterBuffer(&pmem.cuPBOresource, pmem.cuPBO, CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE);
if(result == CUDA_SUCCESS) {
- cuda_pop_context();
-
mem.device_pointer = pmem.cuTexId;
pixel_mem_map[mem.device_pointer] = pmem;
@@ -1573,8 +1555,6 @@ public:
glDeleteBuffers(1, &pmem.cuPBO);
glDeleteTextures(1, &pmem.cuTexId);
- cuda_pop_context();
-
background = true;
}
}
@@ -1587,7 +1567,7 @@ public:
if(!background) {
PixelMem pmem = pixel_mem_map[mem.device_pointer];
- cuda_push_context();
+ CUDAContextScope scope(this);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pmem.cuPBO);
uchar *pixels = (uchar*)glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_READ_ONLY);
@@ -1596,8 +1576,6 @@ public:
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
- cuda_pop_context();
-
return;
}
@@ -1610,14 +1588,12 @@ public:
if(!background) {
PixelMem pmem = pixel_mem_map[mem.device_pointer];
- cuda_push_context();
+ CUDAContextScope scope(this);
cuda_assert(cuGraphicsUnregisterResource(pmem.cuPBOresource));
glDeleteBuffers(1, &pmem.cuPBO);
glDeleteTextures(1, &pmem.cuTexId);
- cuda_pop_context();
-
pixel_mem_map.erase(pixel_mem_map.find(mem.device_pointer));
mem.device_pointer = 0;
@@ -1642,7 +1618,7 @@ public:
PixelMem pmem = pixel_mem_map[mem.device_pointer];
float *vpointer;
- cuda_push_context();
+ CUDAContextScope scope(this);
/* for multi devices, this assumes the inefficient method that we allocate
* all pixels on the device even though we only render to a subset */
@@ -1748,8 +1724,6 @@ public:
glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_TEXTURE_2D);
- cuda_pop_context();
-
return;
}
@@ -1758,11 +1732,11 @@ public:
void thread_run(DeviceTask *task)
{
+ CUDAContextScope scope(this);
+
if(task->type == DeviceTask::RENDER) {
RenderTile tile;
- bool branched = task->integrator_branched;
-
/* Upload Bindless Mapping */
load_bindless_mapping();
@@ -1786,21 +1760,7 @@ public:
split_kernel->path_trace(task, tile, void_buffer, void_buffer);
}
else {
- int start_sample = tile.start_sample;
- int end_sample = tile.start_sample + tile.num_samples;
-
- for(int sample = start_sample; sample < end_sample; sample++) {
- if(task->get_cancel()) {
- if(task->need_finish_queue == false)
- break;
- }
-
- path_trace(tile, sample, branched);
-
- tile.sample = sample + 1;
-
- task->update_progress(&tile, tile.w*tile.h);
- }
+ path_trace(*task, tile);
}
}
else if(tile.task == RenderTile::DENOISE) {
@@ -1825,9 +1785,7 @@ public:
shader(*task);
- cuda_push_context();
cuda_assert(cuCtxSynchronize());
- cuda_pop_context();
}
}
@@ -1848,12 +1806,11 @@ public:
void task_add(DeviceTask& task)
{
if(task.type == DeviceTask::FILM_CONVERT) {
+ CUDAContextScope scope(this);
+
/* must be done in main thread due to opengl access */
film_convert(task, task.buffer, task.rgba_byte, task.rgba_half);
-
- cuda_push_context();
cuda_assert(cuCtxSynchronize());
- cuda_pop_context();
}
else {
task_pool.push(new CUDADeviceTask(this, task));
@@ -1872,6 +1829,7 @@ public:
friend class CUDASplitKernelFunction;
friend class CUDASplitKernel;
+ friend class CUDAContextScope;
};
/* redefine the cuda_assert macro so it can be used outside of the CUDADevice class
@@ -1892,6 +1850,20 @@ public:
} \
} (void)0
+
+/* CUDA context scope. */
+
+CUDAContextScope::CUDAContextScope(CUDADevice *device)
+: device(device)
+{
+ cuda_assert(cuCtxPushCurrent(device->cuContext));
+}
+
+CUDAContextScope::~CUDAContextScope()
+{
+ cuda_assert(cuCtxPopCurrent(NULL));
+}
+
/* split kernel */
class CUDASplitKernelFunction : public SplitKernelFunction{
@@ -1909,30 +1881,24 @@ public:
/* enqueue the kernel, returns false if there is an error */
bool enqueue(const KernelDimensions &dim, void *args[])
{
- device->cuda_push_context();
-
if(device->have_error())
return false;
+ CUDAContextScope scope(device);
+
/* we ignore dim.local_size for now, as this is faster */
int threads_per_block;
cuda_assert(cuFuncGetAttribute(&threads_per_block, CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK, func));
- int xthreads = (int)sqrt(threads_per_block);
- int ythreads = (int)sqrt(threads_per_block);
-
- int xblocks = (dim.global_size[0] + xthreads - 1)/xthreads;
- int yblocks = (dim.global_size[1] + ythreads - 1)/ythreads;
+ int xblocks = (dim.global_size[0]*dim.global_size[1] + threads_per_block - 1)/threads_per_block;
cuda_assert(cuFuncSetCacheConfig(func, CU_FUNC_CACHE_PREFER_L1));
cuda_assert(cuLaunchKernel(func,
- xblocks , yblocks, 1, /* blocks */
- xthreads, ythreads, 1, /* threads */
+ xblocks, 1, 1, /* blocks */
+ threads_per_block, 1, 1, /* threads */
0, 0, args, 0));
- device->cuda_pop_context();
-
return !device->have_error();
}
};
@@ -1943,12 +1909,12 @@ CUDASplitKernel::CUDASplitKernel(CUDADevice *device) : DeviceSplitKernel(device)
uint64_t CUDASplitKernel::state_buffer_size(device_memory& /*kg*/, device_memory& /*data*/, size_t num_threads)
{
+ CUDAContextScope scope(device);
+
device_vector<uint64_t> size_buffer;
size_buffer.resize(1);
device->mem_alloc(NULL, size_buffer, MEM_READ_WRITE);
- device->cuda_push_context();
-
uint threads = num_threads;
CUdeviceptr d_size = device->cuda_device_ptr(size_buffer.device_pointer);
@@ -1970,8 +1936,6 @@ uint64_t CUDASplitKernel::state_buffer_size(device_memory& /*kg*/, device_memory
1, 1, 1,
0, 0, (void**)&args, 0));
- device->cuda_pop_context();
-
device->mem_copy_from(size_buffer, 0, 1, 1, sizeof(uint64_t));
device->mem_free(size_buffer);
@@ -1989,7 +1953,7 @@ bool CUDASplitKernel::enqueue_split_kernel_data_init(const KernelDimensions& dim
device_memory& use_queues_flag,
device_memory& work_pool_wgs)
{
- device->cuda_push_context();
+ CUDAContextScope scope(device);
CUdeviceptr d_split_data = device->cuda_device_ptr(split_data.device_pointer);
CUdeviceptr d_ray_state = device->cuda_device_ptr(ray_state.device_pointer);
@@ -1997,7 +1961,6 @@ bool CUDASplitKernel::enqueue_split_kernel_data_init(const KernelDimensions& dim
CUdeviceptr d_use_queues_flag = device->cuda_device_ptr(use_queues_flag.device_pointer);
CUdeviceptr d_work_pool_wgs = device->cuda_device_ptr(work_pool_wgs.device_pointer);
- CUdeviceptr d_rng_state = device->cuda_device_ptr(rtile.rng_state);
CUdeviceptr d_buffer = device->cuda_device_ptr(rtile.buffer);
int end_sample = rtile.start_sample + rtile.num_samples;
@@ -2007,7 +1970,6 @@ bool CUDASplitKernel::enqueue_split_kernel_data_init(const KernelDimensions& dim
CUdeviceptr* split_data_buffer;
int* num_elements;
CUdeviceptr* ray_state;
- CUdeviceptr* rng_state;
int* start_sample;
int* end_sample;
int* sx;
@@ -2028,7 +1990,6 @@ bool CUDASplitKernel::enqueue_split_kernel_data_init(const KernelDimensions& dim
&d_split_data,
&num_global_elements,
&d_ray_state,
- &d_rng_state,
&rtile.start_sample,
&end_sample,
&rtile.x,
@@ -2053,25 +2014,21 @@ bool CUDASplitKernel::enqueue_split_kernel_data_init(const KernelDimensions& dim
CUDASplitKernelFunction(device, data_init).enqueue(dim, (void**)&args);
- device->cuda_pop_context();
-
return !device->have_error();
}
-SplitKernelFunction* CUDASplitKernel::get_split_kernel_function(string kernel_name, const DeviceRequestedFeatures&)
+SplitKernelFunction* CUDASplitKernel::get_split_kernel_function(const string& kernel_name,
+ const DeviceRequestedFeatures&)
{
+ CUDAContextScope scope(device);
CUfunction func;
- device->cuda_push_context();
-
cuda_assert(cuModuleGetFunction(&func, device->cuModule, (string("kernel_cuda_") + kernel_name).data()));
if(device->have_error()) {
device->cuda_error_message(string_printf("kernel \"kernel_cuda_%s\" not found in module", kernel_name.data()));
return NULL;
}
- device->cuda_pop_context();
-
return new CUDASplitKernelFunction(device, func);
}
@@ -2082,12 +2039,11 @@ int2 CUDASplitKernel::split_kernel_local_size()
int2 CUDASplitKernel::split_kernel_global_size(device_memory& kg, device_memory& data, DeviceTask * /*task*/)
{
+ CUDAContextScope scope(device);
size_t free;
size_t total;
- device->cuda_push_context();
cuda_assert(cuMemGetInfo(&free, &total));
- device->cuda_pop_context();
VLOG(1) << "Maximum device allocation size: "
<< string_human_readable_number(free) << " bytes. ("
@@ -2146,18 +2102,34 @@ Device *device_cuda_create(DeviceInfo& info, Stats &stats, bool background)
return new CUDADevice(info, stats, background);
}
-void device_cuda_info(vector<DeviceInfo>& devices)
+static CUresult device_cuda_safe_init()
{
- CUresult result;
- int count = 0;
+#ifdef _WIN32
+ __try {
+ return cuInit(0);
+ }
+ __except(EXCEPTION_EXECUTE_HANDLER) {
+ /* Ignore crashes inside the CUDA driver and hope we can
+ * survive even with corrupted CUDA installs. */
+ fprintf(stderr, "Cycles CUDA: driver crashed, continuing without CUDA.\n");
+ }
+
+ return CUDA_ERROR_NO_DEVICE;
+#else
+ return cuInit(0);
+#endif
+}
- result = cuInit(0);
+void device_cuda_info(vector<DeviceInfo>& devices)
+{
+ CUresult result = device_cuda_safe_init();
if(result != CUDA_SUCCESS) {
if(result != CUDA_ERROR_NO_DEVICE)
fprintf(stderr, "CUDA cuInit: %s\n", cuewErrorString(result));
return;
}
+ int count = 0;
result = cuDeviceGetCount(&count);
if(result != CUDA_SUCCESS) {
fprintf(stderr, "CUDA cuDeviceGetCount: %s\n", cuewErrorString(result));
@@ -2187,7 +2159,6 @@ void device_cuda_info(vector<DeviceInfo>& devices)
info.advanced_shading = (major >= 2);
info.has_bindless_textures = (major >= 3);
- info.pack_images = false;
int pci_location[3] = {0, 0, 0};
cuDeviceGetAttribute(&pci_location[0], CU_DEVICE_ATTRIBUTE_PCI_DOMAIN_ID, num);
@@ -2215,7 +2186,7 @@ void device_cuda_info(vector<DeviceInfo>& devices)
string device_cuda_capabilities(void)
{
- CUresult result = cuInit(0);
+ CUresult result = device_cuda_safe_init();
if(result != CUDA_SUCCESS) {
if(result != CUDA_ERROR_NO_DEVICE) {
return string("Error initializing CUDA: ") + cuewErrorString(result);
diff --git a/intern/cycles/device/device_memory.h b/intern/cycles/device/device_memory.h
index b63dd00068b..20707ad04c9 100644
--- a/intern/cycles/device/device_memory.h
+++ b/intern/cycles/device/device_memory.h
@@ -46,6 +46,7 @@ enum MemoryType {
/* Supported Data Types */
enum DataType {
+ TYPE_UNKNOWN,
TYPE_UCHAR,
TYPE_UINT,
TYPE_INT,
@@ -57,6 +58,7 @@ enum DataType {
static inline size_t datatype_size(DataType datatype)
{
switch(datatype) {
+ case TYPE_UNKNOWN: return 1;
case TYPE_UCHAR: return sizeof(uchar);
case TYPE_FLOAT: return sizeof(float);
case TYPE_UINT: return sizeof(uint);
@@ -70,8 +72,8 @@ static inline size_t datatype_size(DataType datatype)
/* Traits for data types */
template<typename T> struct device_type_traits {
- static const DataType data_type = TYPE_UCHAR;
- static const int num_elements = 0;
+ static const DataType data_type = TYPE_UNKNOWN;
+ static const int num_elements = sizeof(T);
};
template<> struct device_type_traits<uchar> {
diff --git a/intern/cycles/device/device_multi.cpp b/intern/cycles/device/device_multi.cpp
index 35ae0303d6e..1b1a577d52f 100644
--- a/intern/cycles/device/device_multi.cpp
+++ b/intern/cycles/device/device_multi.cpp
@@ -284,7 +284,6 @@ public:
foreach(SubDevice& sub, devices) {
if(sub.device == sub_device) {
if(tile.buffer) tile.buffer = sub.ptr_map[tile.buffer];
- if(tile.rng_state) tile.rng_state = sub.ptr_map[tile.rng_state];
}
}
}
@@ -387,7 +386,6 @@ public:
if(task.rgba_half) subtask.rgba_half = sub.ptr_map[task.rgba_half];
if(task.shader_input) subtask.shader_input = sub.ptr_map[task.shader_input];
if(task.shader_output) subtask.shader_output = sub.ptr_map[task.shader_output];
- if(task.shader_output_luma) subtask.shader_output_luma = sub.ptr_map[task.shader_output_luma];
sub.device->task_add(subtask);
}
diff --git a/intern/cycles/device/device_network.cpp b/intern/cycles/device/device_network.cpp
index 66758954f44..deea59f1d23 100644
--- a/intern/cycles/device/device_network.cpp
+++ b/intern/cycles/device/device_network.cpp
@@ -344,7 +344,6 @@ void device_network_info(vector<DeviceInfo>& devices)
info.id = "NETWORK";
info.num = 0;
info.advanced_shading = true; /* todo: get this info from device */
- info.pack_images = false;
devices.push_back(info);
}
@@ -661,10 +660,6 @@ protected:
if(task.shader_output)
task.shader_output = device_ptr_from_client_pointer(task.shader_output);
- if(task.shader_output_luma)
- task.shader_output_luma = device_ptr_from_client_pointer(task.shader_output_luma);
-
-
task.acquire_tile = function_bind(&DeviceServer::task_acquire_tile, this, _1, _2);
task.release_tile = function_bind(&DeviceServer::task_release_tile, this, _1);
task.update_progress_sample = function_bind(&DeviceServer::task_update_progress_sample, this);
@@ -738,7 +733,6 @@ protected:
tile = entry.tile;
if(tile.buffer) tile.buffer = ptr_map[tile.buffer];
- if(tile.rng_state) tile.rng_state = ptr_map[tile.rng_state];
result = true;
break;
@@ -770,7 +764,6 @@ protected:
thread_scoped_lock acquire_lock(acquire_mutex);
if(tile.buffer) tile.buffer = ptr_imap[tile.buffer];
- if(tile.rng_state) tile.rng_state = ptr_imap[tile.rng_state];
{
thread_scoped_lock lock(rpc_lock);
diff --git a/intern/cycles/device/device_network.h b/intern/cycles/device/device_network.h
index a5d24c66018..3d3bd99dfe7 100644
--- a/intern/cycles/device/device_network.h
+++ b/intern/cycles/device/device_network.h
@@ -132,7 +132,7 @@ public:
archive & type & task.x & task.y & task.w & task.h;
archive & task.rgba_byte & task.rgba_half & task.buffer & task.sample & task.num_samples;
archive & task.offset & task.stride;
- archive & task.shader_input & task.shader_output & task.shader_output_luma & task.shader_eval_type;
+ archive & task.shader_input & task.shader_output & task.shader_eval_type;
archive & task.shader_x & task.shader_w;
archive & task.need_finish_queue;
}
@@ -142,7 +142,7 @@ public:
archive & tile.x & tile.y & tile.w & tile.h;
archive & tile.start_sample & tile.num_samples & tile.sample;
archive & tile.resolution & tile.offset & tile.stride;
- archive & tile.buffer & tile.rng_state;
+ archive & tile.buffer;
}
void write()
@@ -291,7 +291,7 @@ public:
*archive & type & task.x & task.y & task.w & task.h;
*archive & task.rgba_byte & task.rgba_half & task.buffer & task.sample & task.num_samples;
*archive & task.offset & task.stride;
- *archive & task.shader_input & task.shader_output & task.shader_output_luma & task.shader_eval_type;
+ *archive & task.shader_input & task.shader_output & task.shader_eval_type;
*archive & task.shader_x & task.shader_w;
*archive & task.need_finish_queue;
@@ -303,7 +303,7 @@ public:
*archive & tile.x & tile.y & tile.w & tile.h;
*archive & tile.start_sample & tile.num_samples & tile.sample;
*archive & tile.resolution & tile.offset & tile.stride;
- *archive & tile.buffer & tile.rng_state;
+ *archive & tile.buffer;
tile.buffers = NULL;
}
diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp
index 681b8214b03..9d89decaaaf 100644
--- a/intern/cycles/device/device_opencl.cpp
+++ b/intern/cycles/device/device_opencl.cpp
@@ -73,8 +73,34 @@ bool device_opencl_init(void)
return result;
}
+
+static cl_int device_opencl_get_num_platforms_safe(cl_uint *num_platforms)
+{
+#ifdef _WIN32
+ __try {
+ return clGetPlatformIDs(0, NULL, num_platforms);
+ }
+ __except(EXCEPTION_EXECUTE_HANDLER) {
+ /* Ignore crashes inside the OpenCL driver and hope we can
+ * survive even with corrupted OpenCL installs. */
+ fprintf(stderr, "Cycles OpenCL: driver crashed, continuing without OpenCL.\n");
+ }
+
+ *num_platforms = 0;
+ return CL_DEVICE_NOT_FOUND;
+#else
+ return clGetPlatformIDs(0, NULL, num_platforms);
+#endif
+}
+
void device_opencl_info(vector<DeviceInfo>& devices)
{
+ cl_uint num_platforms = 0;
+ device_opencl_get_num_platforms_safe(&num_platforms);
+ if(num_platforms == 0) {
+ return;
+ }
+
vector<OpenCLPlatformDevice> usable_devices;
OpenCLInfo::get_usable_devices(&usable_devices);
/* Devices are numbered consecutively across platforms. */
@@ -95,7 +121,6 @@ void device_opencl_info(vector<DeviceInfo>& devices)
/* We don't know if it's used for display, but assume it is. */
info.display_device = true;
info.advanced_shading = OpenCLInfo::kernel_use_advanced_shading(platform_name);
- info.pack_images = true;
info.use_split_kernel = OpenCLInfo::kernel_use_split(platform_name,
device_type);
info.id = string("OPENCL_") + platform_name + "_" + device_name + "_" + hardware_id;
@@ -114,7 +139,7 @@ string device_opencl_capabilities(void)
* it could also be nicely reported to the console.
*/
cl_uint num_platforms = 0;
- opencl_assert(clGetPlatformIDs(0, NULL, &num_platforms));
+ opencl_assert(device_opencl_get_num_platforms_safe(&num_platforms));
if(num_platforms == 0) {
return "No OpenCL platforms found\n";
}
diff --git a/intern/cycles/device/device_split_kernel.h b/intern/cycles/device/device_split_kernel.h
index 2bac1998cb7..9c42cb58520 100644
--- a/intern/cycles/device/device_split_kernel.h
+++ b/intern/cycles/device/device_split_kernel.h
@@ -125,7 +125,8 @@ public:
device_memory& use_queues_flag,
device_memory& work_pool_wgs) = 0;
- virtual SplitKernelFunction* get_split_kernel_function(string kernel_name, const DeviceRequestedFeatures&) = 0;
+ virtual SplitKernelFunction* get_split_kernel_function(const string& kernel_name,
+ const DeviceRequestedFeatures&) = 0;
virtual int2 split_kernel_local_size() = 0;
virtual int2 split_kernel_global_size(device_memory& kg, device_memory& data, DeviceTask *task) = 0;
};
diff --git a/intern/cycles/device/device_task.cpp b/intern/cycles/device/device_task.cpp
index 3bc4c310283..3c7d24fb5b7 100644
--- a/intern/cycles/device/device_task.cpp
+++ b/intern/cycles/device/device_task.cpp
@@ -31,7 +31,7 @@ CCL_NAMESPACE_BEGIN
DeviceTask::DeviceTask(Type type_)
: type(type_), x(0), y(0), w(0), h(0), rgba_byte(0), rgba_half(0), buffer(0),
sample(0), num_samples(1),
- shader_input(0), shader_output(0), shader_output_luma(0),
+ shader_input(0), shader_output(0),
shader_eval_type(0), shader_filter(0), shader_x(0), shader_w(0)
{
last_update_time = time_dt();
diff --git a/intern/cycles/device/device_task.h b/intern/cycles/device/device_task.h
index 44a1efff1f5..b9658eb978f 100644
--- a/intern/cycles/device/device_task.h
+++ b/intern/cycles/device/device_task.h
@@ -46,7 +46,7 @@ public:
int offset, stride;
device_ptr shader_input;
- device_ptr shader_output, shader_output_luma;
+ device_ptr shader_output;
int shader_eval_type;
int shader_filter;
int shader_x, shader_w;
diff --git a/intern/cycles/device/opencl/memory_manager.cpp b/intern/cycles/device/opencl/memory_manager.cpp
new file mode 100644
index 00000000000..b67dfef88aa
--- /dev/null
+++ b/intern/cycles/device/opencl/memory_manager.cpp
@@ -0,0 +1,253 @@
+/*
+ * Copyright 2011-2017 Blender Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifdef WITH_OPENCL
+
+#include "util/util_foreach.h"
+
+#include "device/opencl/opencl.h"
+#include "device/opencl/memory_manager.h"
+
+CCL_NAMESPACE_BEGIN
+
+void MemoryManager::DeviceBuffer::add_allocation(Allocation& allocation)
+{
+ allocations.push_back(&allocation);
+}
+
+void MemoryManager::DeviceBuffer::update_device_memory(OpenCLDeviceBase *device)
+{
+ bool need_realloc = false;
+
+ /* Calculate total size and remove any freed. */
+ size_t total_size = 0;
+
+ for(int i = allocations.size()-1; i >= 0; i--) {
+ Allocation* allocation = allocations[i];
+
+ /* Remove allocations that have been freed. */
+ if(!allocation->mem || allocation->mem->memory_size() == 0) {
+ allocation->device_buffer = NULL;
+ allocation->size = 0;
+
+ allocations.erase(allocations.begin()+i);
+
+ need_realloc = true;
+
+ continue;
+ }
+
+ /* Get actual size for allocation. */
+ size_t alloc_size = align_up(allocation->mem->memory_size(), 16);
+
+ if(allocation->size != alloc_size) {
+ /* Allocation is either new or resized. */
+ allocation->size = alloc_size;
+ allocation->needs_copy_to_device = true;
+
+ need_realloc = true;
+ }
+
+ total_size += alloc_size;
+ }
+
+ if(need_realloc) {
+ cl_ulong max_buffer_size;
+ clGetDeviceInfo(device->cdDevice, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof(cl_ulong), &max_buffer_size, NULL);
+
+ if(total_size > max_buffer_size) {
+ device->set_error("Scene too complex to fit in available memory.");
+ return;
+ }
+
+ device_memory *new_buffer = new device_memory;
+
+ new_buffer->resize(total_size);
+ device->mem_alloc(string_printf("buffer_%p", this).data(), *new_buffer, MEM_READ_ONLY);
+
+ size_t offset = 0;
+
+ foreach(Allocation* allocation, allocations) {
+ if(allocation->needs_copy_to_device) {
+ /* Copy from host to device. */
+ opencl_device_assert(device, clEnqueueWriteBuffer(device->cqCommandQueue,
+ CL_MEM_PTR(new_buffer->device_pointer),
+ CL_FALSE,
+ offset,
+ allocation->mem->memory_size(),
+ (void*)allocation->mem->data_pointer,
+ 0, NULL, NULL
+ ));
+
+ allocation->needs_copy_to_device = false;
+ }
+ else {
+ /* Fast copy from memory already on device. */
+ opencl_device_assert(device, clEnqueueCopyBuffer(device->cqCommandQueue,
+ CL_MEM_PTR(buffer->device_pointer),
+ CL_MEM_PTR(new_buffer->device_pointer),
+ allocation->desc.offset,
+ offset,
+ allocation->mem->memory_size(),
+ 0, NULL, NULL
+ ));
+ }
+
+ allocation->desc.offset = offset;
+ offset += allocation->size;
+ }
+
+ device->mem_free(*buffer);
+ delete buffer;
+
+ buffer = new_buffer;
+ }
+ else {
+ assert(total_size == buffer->data_size);
+
+ size_t offset = 0;
+
+ foreach(Allocation* allocation, allocations) {
+ if(allocation->needs_copy_to_device) {
+ /* Copy from host to device. */
+ opencl_device_assert(device, clEnqueueWriteBuffer(device->cqCommandQueue,
+ CL_MEM_PTR(buffer->device_pointer),
+ CL_FALSE,
+ offset,
+ allocation->mem->memory_size(),
+ (void*)allocation->mem->data_pointer,
+ 0, NULL, NULL
+ ));
+
+ allocation->needs_copy_to_device = false;
+ }
+
+ offset += allocation->size;
+ }
+ }
+
+ /* Not really necessary, but seems to improve responsiveness for some reason. */
+ clFinish(device->cqCommandQueue);
+}
+
+void MemoryManager::DeviceBuffer::free(OpenCLDeviceBase *device)
+{
+ device->mem_free(*buffer);
+}
+
+MemoryManager::DeviceBuffer* MemoryManager::smallest_device_buffer()
+{
+ DeviceBuffer* smallest = device_buffers;
+
+ foreach(DeviceBuffer& device_buffer, device_buffers) {
+ if(device_buffer.size < smallest->size) {
+ smallest = &device_buffer;
+ }
+ }
+
+ return smallest;
+}
+
+MemoryManager::MemoryManager(OpenCLDeviceBase *device) : device(device), need_update(false)
+{
+}
+
+void MemoryManager::free()
+{
+ foreach(DeviceBuffer& device_buffer, device_buffers) {
+ device_buffer.free(device);
+ }
+}
+
+void MemoryManager::alloc(const char *name, device_memory& mem)
+{
+ Allocation& allocation = allocations[name];
+
+ allocation.mem = &mem;
+ allocation.needs_copy_to_device = true;
+
+ if(!allocation.device_buffer) {
+ DeviceBuffer* device_buffer = smallest_device_buffer();
+ allocation.device_buffer = device_buffer;
+
+ allocation.desc.device_buffer = device_buffer - device_buffers;
+
+ device_buffer->add_allocation(allocation);
+
+ device_buffer->size += mem.memory_size();
+ }
+
+ need_update = true;
+}
+
+bool MemoryManager::free(device_memory& mem)
+{
+ foreach(AllocationsMap::value_type& value, allocations) {
+ Allocation& allocation = value.second;
+ if(allocation.mem == &mem) {
+
+ allocation.device_buffer->size -= mem.memory_size();
+
+ allocation.mem = NULL;
+ allocation.needs_copy_to_device = false;
+
+ need_update = true;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+MemoryManager::BufferDescriptor MemoryManager::get_descriptor(string name)
+{
+ update_device_memory();
+
+ Allocation& allocation = allocations[name];
+ return allocation.desc;
+}
+
+void MemoryManager::update_device_memory()
+{
+ if(!need_update) {
+ return;
+ }
+
+ need_update = false;
+
+ foreach(DeviceBuffer& device_buffer, device_buffers) {
+ device_buffer.update_device_memory(device);
+ }
+}
+
+void MemoryManager::set_kernel_arg_buffers(cl_kernel kernel, cl_uint *narg)
+{
+ update_device_memory();
+
+ foreach(DeviceBuffer& device_buffer, device_buffers) {
+ if(device_buffer.buffer->device_pointer) {
+ device->kernel_set_args(kernel, (*narg)++, *device_buffer.buffer);
+ }
+ else {
+ device->kernel_set_args(kernel, (*narg)++, device->null_mem);
+ }
+ }
+}
+
+CCL_NAMESPACE_END
+
+#endif /* WITH_OPENCL */
+
diff --git a/intern/cycles/device/opencl/memory_manager.h b/intern/cycles/device/opencl/memory_manager.h
new file mode 100644
index 00000000000..3714405d026
--- /dev/null
+++ b/intern/cycles/device/opencl/memory_manager.h
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2011-2017 Blender Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include "device/device.h"
+
+#include "util/util_map.h"
+#include "util/util_vector.h"
+#include "util/util_string.h"
+
+#include "clew.h"
+
+CCL_NAMESPACE_BEGIN
+
+class OpenCLDeviceBase;
+
+class MemoryManager {
+public:
+ static const int NUM_DEVICE_BUFFERS = 8;
+
+ struct BufferDescriptor {
+ uint device_buffer;
+ cl_ulong offset;
+ };
+
+private:
+ struct DeviceBuffer;
+
+ struct Allocation {
+ device_memory *mem;
+
+ DeviceBuffer *device_buffer;
+ size_t size; /* Size of actual allocation, may be larger than requested. */
+
+ BufferDescriptor desc;
+
+ bool needs_copy_to_device;
+
+ Allocation() : mem(NULL), device_buffer(NULL), size(0), needs_copy_to_device(false)
+ {
+ }
+ };
+
+ struct DeviceBuffer {
+ device_memory *buffer;
+ vector<Allocation*> allocations;
+ size_t size; /* Size of all allocations. */
+
+ DeviceBuffer() : buffer(new device_memory), size(0)
+ {
+ }
+
+ ~DeviceBuffer() {
+ delete buffer;
+ buffer = NULL;
+ }
+
+ void add_allocation(Allocation& allocation);
+
+ void update_device_memory(OpenCLDeviceBase *device);
+
+ void free(OpenCLDeviceBase *device);
+ };
+
+ OpenCLDeviceBase *device;
+
+ DeviceBuffer device_buffers[NUM_DEVICE_BUFFERS];
+
+ typedef unordered_map<string, Allocation> AllocationsMap;
+ AllocationsMap allocations;
+
+ bool need_update;
+
+ DeviceBuffer* smallest_device_buffer();
+
+public:
+ MemoryManager(OpenCLDeviceBase *device);
+
+ void free(); /* Free all memory. */
+
+ void alloc(const char *name, device_memory& mem);
+ bool free(device_memory& mem);
+
+ BufferDescriptor get_descriptor(string name);
+
+ void update_device_memory();
+ void set_kernel_arg_buffers(cl_kernel kernel, cl_uint *narg);
+};
+
+CCL_NAMESPACE_END
+
diff --git a/intern/cycles/device/opencl/opencl.h b/intern/cycles/device/opencl/opencl.h
index 399fae9b42e..26bf4a9af5b 100644
--- a/intern/cycles/device/opencl/opencl.h
+++ b/intern/cycles/device/opencl/opencl.h
@@ -25,8 +25,13 @@
#include "clew.h"
+#include "device/opencl/memory_manager.h"
+
CCL_NAMESPACE_BEGIN
+/* Disable workarounds, seems to be working fine on latest drivers. */
+#define CYCLES_DISABLE_DRIVER_WORKAROUNDS
+
/* Define CYCLES_DISABLE_DRIVER_WORKAROUNDS to disable workaounds for testing */
#ifndef CYCLES_DISABLE_DRIVER_WORKAROUNDS
/* Work around AMD driver hangs by ensuring each command is finished before doing anything else. */
@@ -84,7 +89,7 @@ public:
string *error = NULL);
static bool device_version_check(cl_device_id device,
string *error = NULL);
- static string get_hardware_id(string platform_name,
+ static string get_hardware_id(const string& platform_name,
cl_device_id device_id);
static void get_usable_devices(vector<OpenCLPlatformDevice> *usable_devices,
bool force_all = false);
@@ -221,6 +226,18 @@ public:
static string get_kernel_md5();
};
+#define opencl_device_assert(device, stmt) \
+ { \
+ cl_int err = stmt; \
+ \
+ if(err != CL_SUCCESS) { \
+ string message = string_printf("OpenCL error: %s in %s (%s:%d)", clewErrorString(err), #stmt, __FILE__, __LINE__); \
+ if((device)->error_message() == "") \
+ (device)->set_error(message); \
+ fprintf(stderr, "%s\n", message.c_str()); \
+ } \
+ } (void)0
+
#define opencl_assert(stmt) \
{ \
cl_int err = stmt; \
@@ -247,17 +264,17 @@ public:
public:
OpenCLProgram() : loaded(false), device(NULL) {}
OpenCLProgram(OpenCLDeviceBase *device,
- string program_name,
- string kernel_name,
- string kernel_build_options,
+ const string& program_name,
+ const string& kernel_name,
+ const string& kernel_build_options,
bool use_stdout = true);
~OpenCLProgram();
void add_kernel(ustring name);
void load();
- bool is_loaded() { return loaded; }
- string get_log() { return log; }
+ bool is_loaded() const { return loaded; }
+ const string& get_log() const { return log; }
void report_error();
cl_kernel operator()();
@@ -271,8 +288,8 @@ public:
bool load_binary(const string& clbin, const string *debug_src = NULL);
bool save_binary(const string& clbin);
- void add_log(string msg, bool is_debug);
- void add_error(string msg);
+ void add_log(const string& msg, bool is_debug);
+ void add_error(const string& msg);
bool loaded;
cl_program program;
@@ -341,6 +358,7 @@ public:
size_t global_size_round_up(int group_size, int global_size);
void enqueue_kernel(cl_kernel kernel, size_t w, size_t h, size_t max_workgroup_size = -1);
void set_kernel_arg_mem(cl_kernel kernel, cl_uint *narg, const char *name);
+ void set_kernel_arg_buffers(cl_kernel kernel, cl_uint *narg);
void film_convert(DeviceTask& task, device_ptr buffer, device_ptr rgba_byte, device_ptr rgba_half);
void shader(DeviceTask& task);
@@ -522,6 +540,42 @@ protected:
virtual string build_options_for_base_program(
const DeviceRequestedFeatures& /*requested_features*/);
+
+private:
+ MemoryManager memory_manager;
+ friend class MemoryManager;
+
+ struct tex_info_t {
+ uint buffer, padding;
+ cl_ulong offset;
+ uint width, height, depth, options;
+ };
+ static_assert_align(tex_info_t, 16);
+
+ vector<tex_info_t> texture_descriptors;
+ device_memory texture_descriptors_buffer;
+
+ struct Texture {
+ Texture() {}
+ Texture(device_memory* mem,
+ InterpolationType interpolation,
+ ExtensionType extension)
+ : mem(mem),
+ interpolation(interpolation),
+ extension(extension) {
+ }
+ device_memory* mem;
+ InterpolationType interpolation;
+ ExtensionType extension;
+ };
+
+ typedef map<string, Texture> TexturesMap;
+ TexturesMap textures;
+
+ bool textures_need_update;
+
+protected:
+ void flush_texture_buffers();
};
Device *opencl_create_mega_device(DeviceInfo& info, Stats& stats, bool background);
diff --git a/intern/cycles/device/opencl/opencl_base.cpp b/intern/cycles/device/opencl/opencl_base.cpp
index e4ab979dcbf..3db3efd1103 100644
--- a/intern/cycles/device/opencl/opencl_base.cpp
+++ b/intern/cycles/device/opencl/opencl_base.cpp
@@ -20,6 +20,7 @@
#include "kernel/kernel_types.h"
+#include "util/util_algorithm.h"
#include "util/util_foreach.h"
#include "util/util_logging.h"
#include "util/util_md5.h"
@@ -28,6 +29,15 @@
CCL_NAMESPACE_BEGIN
+struct texture_slot_t {
+ texture_slot_t(const string& name, int slot)
+ : name(name),
+ slot(slot) {
+ }
+ string name;
+ int slot;
+};
+
bool OpenCLDeviceBase::opencl_error(cl_int err)
{
if(err != CL_SUCCESS) {
@@ -62,7 +72,7 @@ void OpenCLDeviceBase::opencl_assert_err(cl_int err, const char* where)
}
OpenCLDeviceBase::OpenCLDeviceBase(DeviceInfo& info, Stats &stats, bool background_)
-: Device(info, stats, background_)
+: Device(info, stats, background_), memory_manager(this)
{
cpPlatform = NULL;
cdDevice = NULL;
@@ -70,6 +80,7 @@ OpenCLDeviceBase::OpenCLDeviceBase(DeviceInfo& info, Stats &stats, bool backgrou
cqCommandQueue = NULL;
null_mem = 0;
device_initialized = false;
+ textures_need_update = true;
vector<OpenCLPlatformDevice> usable_devices;
OpenCLInfo::get_usable_devices(&usable_devices);
@@ -125,6 +136,12 @@ OpenCLDeviceBase::OpenCLDeviceBase(DeviceInfo& info, Stats &stats, bool backgrou
return;
}
+ /* Allocate this right away so that texture_descriptors_buffer is placed at offset 0 in the device memory buffers */
+ texture_descriptors.resize(1);
+ texture_descriptors_buffer.resize(1);
+ texture_descriptors_buffer.data_pointer = (device_ptr)&texture_descriptors[0];
+ memory_manager.alloc("texture_descriptors", texture_descriptors_buffer);
+
fprintf(stderr, "Device init success\n");
device_initialized = true;
}
@@ -133,6 +150,8 @@ OpenCLDeviceBase::~OpenCLDeviceBase()
{
task_pool.stop();
+ memory_manager.free();
+
if(null_mem)
clReleaseMemObject(CL_MEM_PTR(null_mem));
@@ -209,7 +228,8 @@ bool OpenCLDeviceBase::load_kernels(const DeviceRequestedFeatures& requested_fea
base_program = OpenCLProgram(this, "base", "kernel.cl", build_options_for_base_program(requested_features));
base_program.add_kernel(ustring("convert_to_byte"));
base_program.add_kernel(ustring("convert_to_half_float"));
- base_program.add_kernel(ustring("shader"));
+ base_program.add_kernel(ustring("displace"));
+ base_program.add_kernel(ustring("background"));
base_program.add_kernel(ustring("bake"));
base_program.add_kernel(ustring("zero_buffer"));
@@ -276,6 +296,25 @@ void OpenCLDeviceBase::mem_alloc(const char *name, device_memory& mem, MemoryTyp
size_t size = mem.memory_size();
+ /* check there is enough memory available for the allocation */
+ cl_ulong max_alloc_size = 0;
+ clGetDeviceInfo(cdDevice, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof(cl_ulong), &max_alloc_size, NULL);
+
+ if(DebugFlags().opencl.mem_limit) {
+ max_alloc_size = min(max_alloc_size,
+ cl_ulong(DebugFlags().opencl.mem_limit - stats.mem_used));
+ }
+
+ if(size > max_alloc_size) {
+ string error = "Scene too complex to fit in available memory.";
+ if(name != NULL) {
+ error += string_printf(" (allocating buffer %s failed.)", name);
+ }
+ set_error(error);
+
+ return;
+ }
+
cl_mem_flags mem_flag;
void *mem_ptr = NULL;
@@ -473,29 +512,35 @@ void OpenCLDeviceBase::const_copy_to(const char *name, void *host, size_t size)
void OpenCLDeviceBase::tex_alloc(const char *name,
device_memory& mem,
- InterpolationType /*interpolation*/,
- ExtensionType /*extension*/)
+ InterpolationType interpolation,
+ ExtensionType extension)
{
VLOG(1) << "Texture allocate: " << name << ", "
<< string_human_readable_number(mem.memory_size()) << " bytes. ("
<< string_human_readable_size(mem.memory_size()) << ")";
- mem_alloc(NULL, mem, MEM_READ_ONLY);
- mem_copy_to(mem);
- assert(mem_map.find(name) == mem_map.end());
- mem_map.insert(MemMap::value_type(name, mem.device_pointer));
+
+ memory_manager.alloc(name, mem);
+ /* Set the pointer to non-null to keep code that inspects its value from thinking its unallocated. */
+ mem.device_pointer = 1;
+ textures[name] = Texture(&mem, interpolation, extension);
+ textures_need_update = true;
}
void OpenCLDeviceBase::tex_free(device_memory& mem)
{
if(mem.device_pointer) {
- foreach(const MemMap::value_type& value, mem_map) {
- if(value.second == mem.device_pointer) {
- mem_map.erase(value.first);
+ mem.device_pointer = 0;
+
+ if(memory_manager.free(mem)) {
+ textures_need_update = true;
+ }
+
+ foreach(TexturesMap::value_type& value, textures) {
+ if(value.second.mem == &mem) {
+ textures.erase(value.first);
break;
}
}
-
- mem_free(mem);
}
}
@@ -561,6 +606,98 @@ void OpenCLDeviceBase::set_kernel_arg_mem(cl_kernel kernel, cl_uint *narg, const
opencl_assert(clSetKernelArg(kernel, (*narg)++, sizeof(ptr), (void*)&ptr));
}
+void OpenCLDeviceBase::set_kernel_arg_buffers(cl_kernel kernel, cl_uint *narg)
+{
+ flush_texture_buffers();
+
+ memory_manager.set_kernel_arg_buffers(kernel, narg);
+}
+
+void OpenCLDeviceBase::flush_texture_buffers()
+{
+ if(!textures_need_update) {
+ return;
+ }
+ textures_need_update = false;
+
+ /* Setup slots for textures. */
+ int num_slots = 0;
+
+ vector<texture_slot_t> texture_slots;
+
+#define KERNEL_TEX(type, ttype, name) \
+ if(textures.find(#name) != textures.end()) { \
+ texture_slots.push_back(texture_slot_t(#name, num_slots)); \
+ } \
+ num_slots++;
+#include "kernel/kernel_textures.h"
+
+ int num_data_slots = num_slots;
+
+ foreach(TexturesMap::value_type& tex, textures) {
+ string name = tex.first;
+
+ if(string_startswith(name, "__tex_image")) {
+ int pos = name.rfind("_");
+ int id = atoi(name.data() + pos + 1);
+ texture_slots.push_back(texture_slot_t(name,
+ num_data_slots + id));
+ num_slots = max(num_slots, num_data_slots + id + 1);
+ }
+ }
+
+ /* Realloc texture descriptors buffer. */
+ memory_manager.free(texture_descriptors_buffer);
+
+ texture_descriptors.resize(num_slots);
+ texture_descriptors_buffer.resize(num_slots * sizeof(tex_info_t));
+ texture_descriptors_buffer.data_pointer = (device_ptr)&texture_descriptors[0];
+
+ memory_manager.alloc("texture_descriptors", texture_descriptors_buffer);
+
+ /* Fill in descriptors */
+ foreach(texture_slot_t& slot, texture_slots) {
+ Texture& tex = textures[slot.name];
+
+ tex_info_t& info = texture_descriptors[slot.slot];
+
+ MemoryManager::BufferDescriptor desc = memory_manager.get_descriptor(slot.name);
+
+ info.offset = desc.offset;
+ info.buffer = desc.device_buffer;
+
+ if(string_startswith(slot.name, "__tex_image")) {
+ info.width = tex.mem->data_width;
+ info.height = tex.mem->data_height;
+ info.depth = tex.mem->data_depth;
+
+ info.options = 0;
+
+ if(tex.interpolation == INTERPOLATION_CLOSEST) {
+ info.options |= (1 << 0);
+ }
+
+ switch(tex.extension) {
+ case EXTENSION_REPEAT:
+ info.options |= (1 << 1);
+ break;
+ case EXTENSION_EXTEND:
+ info.options |= (1 << 2);
+ break;
+ case EXTENSION_CLIP:
+ info.options |= (1 << 3);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ /* Force write of descriptors. */
+ memory_manager.free(texture_descriptors_buffer);
+ memory_manager.alloc("texture_descriptors", texture_descriptors_buffer);
+}
+
void OpenCLDeviceBase::film_convert(DeviceTask& task, device_ptr buffer, device_ptr rgba_byte, device_ptr rgba_half)
{
/* cast arguments to cl types */
@@ -585,10 +722,7 @@ void OpenCLDeviceBase::film_convert(DeviceTask& task, device_ptr buffer, device_
d_rgba,
d_buffer);
-#define KERNEL_TEX(type, ttype, name) \
-set_kernel_arg_mem(ckFilmConvertKernel, &start_arg_index, #name);
-#include "kernel/kernel_textures.h"
-#undef KERNEL_TEX
+ set_kernel_arg_buffers(ckFilmConvertKernel, &start_arg_index);
start_arg_index += kernel_set_args(ckFilmConvertKernel,
start_arg_index,
@@ -849,7 +983,6 @@ bool OpenCLDeviceBase::denoising_divide_shadow(device_ptr a_ptr,
cl_kernel ckFilterDivideShadow = denoising_program(ustring("filter_divide_shadow"));
- char split_kernel = is_split_kernel()? 1 : 0;
kernel_set_args(ckFilterDivideShadow, 0,
task->render_buffer.samples,
tiles_mem,
@@ -860,8 +993,7 @@ bool OpenCLDeviceBase::denoising_divide_shadow(device_ptr a_ptr,
buffer_variance_mem,
task->rect,
task->render_buffer.pass_stride,
- task->render_buffer.denoising_data_offset,
- split_kernel);
+ task->render_buffer.denoising_data_offset);
enqueue_kernel(ckFilterDivideShadow,
task->rect.z-task->rect.x,
task->rect.w-task->rect.y);
@@ -882,7 +1014,6 @@ bool OpenCLDeviceBase::denoising_get_feature(int mean_offset,
cl_kernel ckFilterGetFeature = denoising_program(ustring("filter_get_feature"));
- char split_kernel = is_split_kernel()? 1 : 0;
kernel_set_args(ckFilterGetFeature, 0,
task->render_buffer.samples,
tiles_mem,
@@ -892,8 +1023,7 @@ bool OpenCLDeviceBase::denoising_get_feature(int mean_offset,
variance_mem,
task->rect,
task->render_buffer.pass_stride,
- task->render_buffer.denoising_data_offset,
- split_kernel);
+ task->render_buffer.denoising_data_offset);
enqueue_kernel(ckFilterGetFeature,
task->rect.z-task->rect.x,
task->rect.w-task->rect.y);
@@ -983,7 +1113,6 @@ void OpenCLDeviceBase::shader(DeviceTask& task)
cl_mem d_data = CL_MEM_PTR(const_mem_map["__data"]->device_pointer);
cl_mem d_input = CL_MEM_PTR(task.shader_input);
cl_mem d_output = CL_MEM_PTR(task.shader_output);
- cl_mem d_output_luma = CL_MEM_PTR(task.shader_output_luma);
cl_int d_shader_eval_type = task.shader_eval_type;
cl_int d_shader_filter = task.shader_filter;
cl_int d_shader_x = task.shader_x;
@@ -992,10 +1121,15 @@ void OpenCLDeviceBase::shader(DeviceTask& task)
cl_kernel kernel;
- if(task.shader_eval_type >= SHADER_EVAL_BAKE)
+ if(task.shader_eval_type >= SHADER_EVAL_BAKE) {
kernel = base_program(ustring("bake"));
- else
- kernel = base_program(ustring("shader"));
+ }
+ else if(task.shader_eval_type >= SHADER_EVAL_DISPLACE) {
+ kernel = base_program(ustring("displace"));
+ }
+ else {
+ kernel = base_program(ustring("background"));
+ }
cl_uint start_arg_index =
kernel_set_args(kernel,
@@ -1004,16 +1138,7 @@ void OpenCLDeviceBase::shader(DeviceTask& task)
d_input,
d_output);
- if(task.shader_eval_type < SHADER_EVAL_BAKE) {
- start_arg_index += kernel_set_args(kernel,
- start_arg_index,
- d_output_luma);
- }
-
-#define KERNEL_TEX(type, ttype, name) \
- set_kernel_arg_mem(kernel, &start_arg_index, #name);
-#include "kernel/kernel_textures.h"
-#undef KERNEL_TEX
+ set_kernel_arg_buffers(kernel, &start_arg_index);
start_arg_index += kernel_set_args(kernel,
start_arg_index,
@@ -1226,7 +1351,7 @@ void OpenCLDeviceBase::store_cached_kernel(
}
string OpenCLDeviceBase::build_options_for_base_program(
- const DeviceRequestedFeatures& /*requested_features*/)
+ const DeviceRequestedFeatures& requested_features)
{
/* TODO(sergey): By default we compile all features, meaning
* mega kernel is not getting feature-based optimizations.
@@ -1234,6 +1359,14 @@ string OpenCLDeviceBase::build_options_for_base_program(
* Ideally we need always compile kernel with as less features
* enabled as possible to keep performance at it's max.
*/
+
+ /* For now disable baking when not in use as this has major
+ * impact on kernel build times.
+ */
+ if(!requested_features.use_baking) {
+ return "-D__NO_BAKING__";
+ }
+
return "";
}
diff --git a/intern/cycles/device/opencl/opencl_mega.cpp b/intern/cycles/device/opencl/opencl_mega.cpp
index 06c15bcf401..f4555eaba4f 100644
--- a/intern/cycles/device/opencl/opencl_mega.cpp
+++ b/intern/cycles/device/opencl/opencl_mega.cpp
@@ -62,7 +62,6 @@ public:
/* Cast arguments to cl types. */
cl_mem d_data = CL_MEM_PTR(const_mem_map["__data"]->device_pointer);
cl_mem d_buffer = CL_MEM_PTR(rtile.buffer);
- cl_mem d_rng_state = CL_MEM_PTR(rtile.rng_state);
cl_int d_x = rtile.x;
cl_int d_y = rtile.y;
cl_int d_w = rtile.w;
@@ -79,13 +78,9 @@ public:
kernel_set_args(ckPathTraceKernel,
0,
d_data,
- d_buffer,
- d_rng_state);
+ d_buffer);
-#define KERNEL_TEX(type, ttype, name) \
- set_kernel_arg_mem(ckPathTraceKernel, &start_arg_index, #name);
-#include "kernel/kernel_textures.h"
-#undef KERNEL_TEX
+ set_kernel_arg_buffers(ckPathTraceKernel, &start_arg_index);
start_arg_index += kernel_set_args(ckPathTraceKernel,
start_arg_index,
diff --git a/intern/cycles/device/opencl/opencl_split.cpp b/intern/cycles/device/opencl/opencl_split.cpp
index 08b632ee9d3..976cc9df46d 100644
--- a/intern/cycles/device/opencl/opencl_split.cpp
+++ b/intern/cycles/device/opencl/opencl_split.cpp
@@ -25,6 +25,7 @@
#include "device/device_split_kernel.h"
+#include "util/util_algorithm.h"
#include "util/util_logging.h"
#include "util/util_md5.h"
#include "util/util_path.h"
@@ -98,6 +99,8 @@ public:
void thread_run(DeviceTask *task)
{
+ flush_texture_buffers();
+
if(task->type == DeviceTask::FILM_CONVERT) {
film_convert(*task, task->buffer, task->rgba_byte, task->rgba_half);
}
@@ -112,10 +115,19 @@ public:
*/
typedef struct KernelGlobals {
ccl_constant KernelData *data;
+ ccl_global char *buffers[8];
+
+ typedef struct _tex_info_t {
+ uint buffer, padding;
+ uint64_t offset;
+ uint width, height, depth, options;
+ } _tex_info_t;
+
#define KERNEL_TEX(type, ttype, name) \
- ccl_global type *name;
+ _tex_info_t name;
#include "kernel/kernel_textures.h"
#undef KERNEL_TEX
+
SplitData split_data;
SplitParams split_param_data;
} KernelGlobals;
@@ -180,7 +192,6 @@ struct CachedSplitMemory {
int id;
device_memory *split_data;
device_memory *ray_state;
- device_ptr *rng_state;
device_memory *queue_index;
device_memory *use_queues_flag;
device_memory *work_pools;
@@ -213,14 +224,9 @@ public:
kg,
data,
*cached_memory.split_data,
- *cached_memory.ray_state,
- *cached_memory.rng_state);
+ *cached_memory.ray_state);
-/* TODO(sergey): Avoid map lookup here. */
-#define KERNEL_TEX(type, ttype, name) \
- device->set_kernel_arg_mem(program(), &start_arg_index, #name);
-#include "kernel/kernel_textures.h"
-#undef KERNEL_TEX
+ device->set_kernel_arg_buffers(program(), &start_arg_index);
start_arg_index +=
device->kernel_set_args(program(),
@@ -263,7 +269,7 @@ public:
explicit OpenCLSplitKernel(OpenCLDeviceSplitKernel *device) : DeviceSplitKernel(device), device(device) {
}
- virtual SplitKernelFunction* get_split_kernel_function(string kernel_name,
+ virtual SplitKernelFunction* get_split_kernel_function(const string& kernel_name,
const DeviceRequestedFeatures& requested_features)
{
OpenCLSplitKernelFunction* kernel = new OpenCLSplitKernelFunction(device, cached_memory);
@@ -348,14 +354,9 @@ public:
kernel_data,
split_data,
num_global_elements,
- ray_state,
- rtile.rng_state);
+ ray_state);
-/* TODO(sergey): Avoid map lookup here. */
-#define KERNEL_TEX(type, ttype, name) \
- device->set_kernel_arg_mem(device->program_data_init(), &start_arg_index, #name);
-#include "kernel/kernel_textures.h"
-#undef KERNEL_TEX
+ device->set_kernel_arg_buffers(device->program_data_init(), &start_arg_index);
start_arg_index +=
device->kernel_set_args(device->program_data_init(),
@@ -397,7 +398,6 @@ public:
cached_memory.split_data = &split_data;
cached_memory.ray_state = &ray_state;
- cached_memory.rng_state = &rtile.rng_state;
cached_memory.queue_index = &queue_index;
cached_memory.use_queues_flag = &use_queues_flag;
cached_memory.work_pools = &work_pool_wgs;
@@ -423,12 +423,18 @@ public:
cl_ulong max_buffer_size;
clGetDeviceInfo(device->cdDevice, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof(cl_ulong), &max_buffer_size, NULL);
+
+ if(DebugFlags().opencl.mem_limit) {
+ max_buffer_size = min(max_buffer_size,
+ cl_ulong(DebugFlags().opencl.mem_limit - device->stats.mem_used));
+ }
+
VLOG(1) << "Maximum device allocation size: "
<< string_human_readable_number(max_buffer_size) << " bytes. ("
<< string_human_readable_size(max_buffer_size) << ").";
size_t num_elements = max_elements_for_max_buffer_size(kg, data, max_buffer_size / 2);
- int2 global_size = make_int2(round_down((int)sqrt(num_elements), 64), (int)sqrt(num_elements));
+ int2 global_size = make_int2(max(round_down((int)sqrt(num_elements), 64), 64), (int)sqrt(num_elements));
VLOG(1) << "Global size: " << global_size << ".";
return global_size;
}
diff --git a/intern/cycles/device/opencl/opencl_util.cpp b/intern/cycles/device/opencl/opencl_util.cpp
index 8ba2a8e26da..7d5173a5f1d 100644
--- a/intern/cycles/device/opencl/opencl_util.cpp
+++ b/intern/cycles/device/opencl/opencl_util.cpp
@@ -241,9 +241,9 @@ string OpenCLCache::get_kernel_md5()
}
OpenCLDeviceBase::OpenCLProgram::OpenCLProgram(OpenCLDeviceBase *device,
- string program_name,
- string kernel_file,
- string kernel_build_options,
+ const string& program_name,
+ const string& kernel_file,
+ const string& kernel_build_options,
bool use_stdout)
: device(device),
program_name(program_name),
@@ -274,7 +274,7 @@ void OpenCLDeviceBase::OpenCLProgram::release()
}
}
-void OpenCLDeviceBase::OpenCLProgram::add_log(string msg, bool debug)
+void OpenCLDeviceBase::OpenCLProgram::add_log(const string& msg, bool debug)
{
if(!use_stdout) {
log += msg + "\n";
@@ -288,7 +288,7 @@ void OpenCLDeviceBase::OpenCLProgram::add_log(string msg, bool debug)
}
}
-void OpenCLDeviceBase::OpenCLProgram::add_error(string msg)
+void OpenCLDeviceBase::OpenCLProgram::add_error(const string& msg)
{
if(use_stdout) {
fprintf(stderr, "%s\n", msg.c_str());
@@ -635,7 +635,7 @@ bool OpenCLInfo::device_supported(const string& platform_name,
"Tahiti", "Pitcairn", "Capeverde", "Oland",
NULL
};
- for (int i = 0; blacklist[i] != NULL; i++) {
+ for(int i = 0; blacklist[i] != NULL; i++) {
if(device_name == blacklist[i]) {
VLOG(1) << "AMD device " << device_name << " not supported";
return false;
@@ -707,7 +707,7 @@ bool OpenCLInfo::device_version_check(cl_device_id device,
return true;
}
-string OpenCLInfo::get_hardware_id(string platform_name, cl_device_id device_id)
+string OpenCLInfo::get_hardware_id(const string& platform_name, cl_device_id device_id)
{
if(platform_name == "AMD Accelerated Parallel Processing" || platform_name == "Apple") {
/* Use cl_amd_device_topology extension. */
diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt
index 23e9bd311c4..b10dd05cb9b 100644
--- a/intern/cycles/kernel/CMakeLists.txt
+++ b/intern/cycles/kernel/CMakeLists.txt
@@ -79,7 +79,6 @@ set(SRC_HEADERS
kernel_compat_cpu.h
kernel_compat_cuda.h
kernel_compat_opencl.h
- kernel_debug.h
kernel_differential.h
kernel_emission.h
kernel_film.h
@@ -202,6 +201,7 @@ set(SRC_GEOM_HEADERS
geom/geom.h
geom/geom_attribute.h
geom/geom_curve.h
+ geom/geom_curve_intersect.h
geom/geom_motion_curve.h
geom/geom_motion_triangle.h
geom/geom_motion_triangle_intersect.h
@@ -233,6 +233,7 @@ set(SRC_FILTER_HEADERS
set(SRC_UTIL_HEADERS
../util/util_atomic.h
../util/util_color.h
+ ../util/util_defines.h
../util/util_half.h
../util/util_hash.h
../util/util_math.h
@@ -320,7 +321,7 @@ if(WITH_CYCLES_CUDA_BINARIES)
set(CUDA_VERSION "${CUDA_VERSION_MAJOR}${CUDA_VERSION_MINOR}")
# warn for other versions
- if(CUDA_VERSION MATCHES "80")
+ if(CUDA_VERSION MATCHES "80" OR CUDA_VERSION MATCHES "90")
else()
message(WARNING
"CUDA version ${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR} detected, "
@@ -398,13 +399,17 @@ if(WITH_CYCLES_CUDA_BINARIES)
endmacro()
foreach(arch ${CYCLES_CUDA_BINARIES_ARCH})
- # Compile regular kernel
- CYCLES_CUDA_KERNEL_ADD(${arch} kernel "" "${cuda_sources}" FALSE)
- CYCLES_CUDA_KERNEL_ADD(${arch} filter "" "${cuda_filter_sources}" FALSE)
-
- if(WITH_CYCLES_CUDA_SPLIT_KERNEL_BINARIES)
- # Compile split kernel
- CYCLES_CUDA_KERNEL_ADD(${arch} kernel_split "-D__SPLIT__" ${cuda_sources} FALSE)
+ if(CUDA_VERSION MATCHES "90" AND ${arch} MATCHES "sm_2.")
+ message(STATUS "CUDA binaries for ${arch} disabled, not supported by CUDA 9.")
+ else()
+ # Compile regular kernel
+ CYCLES_CUDA_KERNEL_ADD(${arch} kernel "" "${cuda_sources}" FALSE)
+ CYCLES_CUDA_KERNEL_ADD(${arch} filter "" "${cuda_filter_sources}" FALSE)
+
+ if(WITH_CYCLES_CUDA_SPLIT_KERNEL_BINARIES)
+ # Compile split kernel
+ CYCLES_CUDA_KERNEL_ADD(${arch} kernel_split "-D__SPLIT__" ${cuda_sources} FALSE)
+ endif()
endif()
endforeach()
diff --git a/intern/cycles/kernel/bvh/bvh.h b/intern/cycles/kernel/bvh/bvh.h
index 85741016b25..cf0c8542d69 100644
--- a/intern/cycles/kernel/bvh/bvh.h
+++ b/intern/cycles/kernel/bvh/bvh.h
@@ -233,7 +233,7 @@ ccl_device_intersect void scene_intersect_subsurface(KernelGlobals *kg,
ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals *kg,
const Ray *ray,
Intersection *isect,
- int skip_object,
+ uint visibility,
uint max_hits,
uint *num_hits)
{
@@ -244,7 +244,7 @@ ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals *kg,
return bvh_intersect_shadow_all_hair_motion(kg,
ray,
isect,
- skip_object,
+ visibility,
max_hits,
num_hits);
}
@@ -253,7 +253,7 @@ ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals *kg,
return bvh_intersect_shadow_all_motion(kg,
ray,
isect,
- skip_object,
+ visibility,
max_hits,
num_hits);
}
@@ -264,7 +264,7 @@ ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals *kg,
return bvh_intersect_shadow_all_hair(kg,
ray,
isect,
- skip_object,
+ visibility,
max_hits,
num_hits);
}
@@ -275,7 +275,7 @@ ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals *kg,
return bvh_intersect_shadow_all_instancing(kg,
ray,
isect,
- skip_object,
+ visibility,
max_hits,
num_hits);
}
@@ -284,7 +284,7 @@ ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals *kg,
return bvh_intersect_shadow_all(kg,
ray,
isect,
- skip_object,
+ visibility,
max_hits,
num_hits);
}
diff --git a/intern/cycles/kernel/bvh/bvh_nodes.h b/intern/cycles/kernel/bvh/bvh_nodes.h
index 74a9ebf14e4..6c33dad5426 100644
--- a/intern/cycles/kernel/bvh/bvh_nodes.h
+++ b/intern/cycles/kernel/bvh/bvh_nodes.h
@@ -52,8 +52,8 @@ ccl_device_forceinline int bvh_aligned_node_intersect(KernelGlobals *kg,
float c0hiy = (node1.z - P.y) * idir.y;
float c0loz = (node2.x - P.z) * idir.z;
float c0hiz = (node2.z - P.z) * idir.z;
- float c0min = max4(min(c0lox, c0hix), min(c0loy, c0hiy), min(c0loz, c0hiz), 0.0f);
- float c0max = min4(max(c0lox, c0hix), max(c0loy, c0hiy), max(c0loz, c0hiz), t);
+ float c0min = max4(0.0f, min(c0lox, c0hix), min(c0loy, c0hiy), min(c0loz, c0hiz));
+ float c0max = min4(t, max(c0lox, c0hix), max(c0loy, c0hiy), max(c0loz, c0hiz));
float c1lox = (node0.y - P.x) * idir.x;
float c1hix = (node0.w - P.x) * idir.x;
@@ -61,8 +61,8 @@ ccl_device_forceinline int bvh_aligned_node_intersect(KernelGlobals *kg,
float c1hiy = (node1.w - P.y) * idir.y;
float c1loz = (node2.y - P.z) * idir.z;
float c1hiz = (node2.w - P.z) * idir.z;
- float c1min = max4(min(c1lox, c1hix), min(c1loy, c1hiy), min(c1loz, c1hiz), 0.0f);
- float c1max = min4(max(c1lox, c1hix), max(c1loy, c1hiy), max(c1loz, c1hiz), t);
+ float c1min = max4(0.0f, min(c1lox, c1hix), min(c1loy, c1hiy), min(c1loz, c1hiz));
+ float c1max = min4(t, max(c1lox, c1hix), max(c1loy, c1hiy), max(c1loz, c1hiz));
dist[0] = c0min;
dist[1] = c1min;
@@ -101,8 +101,8 @@ ccl_device_forceinline int bvh_aligned_node_intersect_robust(KernelGlobals *kg,
float c0hiy = (node1.z - P.y) * idir.y;
float c0loz = (node2.x - P.z) * idir.z;
float c0hiz = (node2.z - P.z) * idir.z;
- float c0min = max4(min(c0lox, c0hix), min(c0loy, c0hiy), min(c0loz, c0hiz), 0.0f);
- float c0max = min4(max(c0lox, c0hix), max(c0loy, c0hiy), max(c0loz, c0hiz), t);
+ float c0min = max4(0.0f, min(c0lox, c0hix), min(c0loy, c0hiy), min(c0loz, c0hiz));
+ float c0max = min4(t, max(c0lox, c0hix), max(c0loy, c0hiy), max(c0loz, c0hiz));
float c1lox = (node0.y - P.x) * idir.x;
float c1hix = (node0.w - P.x) * idir.x;
@@ -110,8 +110,8 @@ ccl_device_forceinline int bvh_aligned_node_intersect_robust(KernelGlobals *kg,
float c1hiy = (node1.w - P.y) * idir.y;
float c1loz = (node2.y - P.z) * idir.z;
float c1hiz = (node2.w - P.z) * idir.z;
- float c1min = max4(min(c1lox, c1hix), min(c1loy, c1hiy), min(c1loz, c1hiz), 0.0f);
- float c1max = min4(max(c1lox, c1hix), max(c1loy, c1hiy), max(c1loz, c1hiz), t);
+ float c1min = max4(0.0f, min(c1lox, c1hix), min(c1loy, c1hiy), min(c1loz, c1hiz));
+ float c1max = min4(t, max(c1lox, c1hix), max(c1loy, c1hiy), max(c1loz, c1hiz));
if(difl != 0.0f) {
float hdiff = 1.0f + difl;
@@ -483,8 +483,8 @@ ccl_device_forceinline int bvh_unaligned_node_intersect(KernelGlobals *kg,
ssef tfar_y = max(lower_y, upper_y);
ssef tfar_z = max(lower_z, upper_z);
- const ssef tnear = max4(tnear_x, tnear_y, tnear_z, isect_near);
- const ssef tfar = min4(tfar_x, tfar_y, tfar_z, isect_far);
+ const ssef tnear = max4(isect_near, tnear_x, tnear_y, tnear_z);
+ const ssef tfar = min4(isect_far, tfar_x, tfar_y, tfar_z);
sseb vmask = tnear <= tfar;
dist[0] = tnear.f[0];
dist[1] = tnear.f[1];
@@ -545,8 +545,8 @@ ccl_device_forceinline int bvh_unaligned_node_intersect_robust(KernelGlobals *kg
ssef tfar_y = max(lower_y, upper_y);
ssef tfar_z = max(lower_z, upper_z);
- const ssef tnear = max4(tnear_x, tnear_y, tnear_z, isect_near);
- const ssef tfar = min4(tfar_x, tfar_y, tfar_z, isect_far);
+ const ssef tnear = max4(isect_near, tnear_x, tnear_y, tnear_z);
+ const ssef tfar = min4(isect_far, tfar_x, tfar_y, tfar_z);
sseb vmask;
if(difl != 0.0f) {
const float round_down = 1.0f - difl;
@@ -615,7 +615,7 @@ ccl_device_forceinline int bvh_node_intersect_robust(KernelGlobals *kg,
const float3& P,
const float3& dir,
const ssef& isect_near,
- const ssef& isect_far,
+ const ssef& isect_far,
const ssef& tsplat,
const ssef Psplat[3],
const ssef idirsplat[3],
diff --git a/intern/cycles/kernel/bvh/bvh_shadow_all.h b/intern/cycles/kernel/bvh/bvh_shadow_all.h
index 267e098f912..a6a4353562c 100644
--- a/intern/cycles/kernel/bvh/bvh_shadow_all.h
+++ b/intern/cycles/kernel/bvh/bvh_shadow_all.h
@@ -45,7 +45,7 @@ ccl_device_inline
bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
const Ray *ray,
Intersection *isect_array,
- const int skip_object,
+ const uint visibility,
const uint max_hits,
uint *num_hits)
{
@@ -119,7 +119,7 @@ bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
idir,
isect_t,
node_addr,
- PATH_RAY_SHADOW,
+ visibility,
dist);
#else // __KERNEL_SSE2__
traverse_mask = NODE_INTERSECT(kg,
@@ -134,7 +134,7 @@ bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
idirsplat,
shufflexyz,
node_addr,
- PATH_RAY_SHADOW,
+ visibility,
dist);
#endif // __KERNEL_SSE2__
@@ -186,17 +186,6 @@ bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
/* primitive intersection */
while(prim_addr < prim_addr2) {
kernel_assert((kernel_tex_fetch(__prim_type, prim_addr) & PRIMITIVE_ALL) == p_type);
-
-#ifdef __SHADOW_TRICKS__
- uint tri_object = (object == OBJECT_NONE)
- ? kernel_tex_fetch(__prim_object, prim_addr)
- : object;
- if(tri_object == skip_object) {
- ++prim_addr;
- continue;
- }
-#endif
-
bool hit;
/* todo: specialized intersect functions which don't fill in
@@ -209,7 +198,7 @@ bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
isect_array,
P,
dir,
- PATH_RAY_SHADOW,
+ visibility,
object,
prim_addr);
break;
@@ -221,7 +210,7 @@ bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
P,
dir,
ray->time,
- PATH_RAY_SHADOW,
+ visibility,
object,
prim_addr);
break;
@@ -232,30 +221,30 @@ bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
case PRIMITIVE_MOTION_CURVE: {
const uint curve_type = kernel_tex_fetch(__prim_type, prim_addr);
if(kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE) {
- hit = bvh_cardinal_curve_intersect(kg,
- isect_array,
- P,
- dir,
- PATH_RAY_SHADOW,
- object,
- prim_addr,
- ray->time,
- curve_type,
- NULL,
- 0, 0);
+ hit = cardinal_curve_intersect(kg,
+ isect_array,
+ P,
+ dir,
+ visibility,
+ object,
+ prim_addr,
+ ray->time,
+ curve_type,
+ NULL,
+ 0, 0);
}
else {
- hit = bvh_curve_intersect(kg,
- isect_array,
- P,
- dir,
- PATH_RAY_SHADOW,
- object,
- prim_addr,
- ray->time,
- curve_type,
- NULL,
- 0, 0);
+ hit = curve_intersect(kg,
+ isect_array,
+ P,
+ dir,
+ visibility,
+ object,
+ prim_addr,
+ ray->time,
+ curve_type,
+ NULL,
+ 0, 0);
}
break;
}
@@ -402,7 +391,7 @@ bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
ccl_device_inline bool BVH_FUNCTION_NAME(KernelGlobals *kg,
const Ray *ray,
Intersection *isect_array,
- const int skip_object,
+ const uint visibility,
const uint max_hits,
uint *num_hits)
{
@@ -411,7 +400,7 @@ ccl_device_inline bool BVH_FUNCTION_NAME(KernelGlobals *kg,
return BVH_FUNCTION_FULL_NAME(QBVH)(kg,
ray,
isect_array,
- skip_object,
+ visibility,
max_hits,
num_hits);
}
@@ -422,7 +411,7 @@ ccl_device_inline bool BVH_FUNCTION_NAME(KernelGlobals *kg,
return BVH_FUNCTION_FULL_NAME(BVH)(kg,
ray,
isect_array,
- skip_object,
+ visibility,
max_hits,
num_hits);
}
diff --git a/intern/cycles/kernel/bvh/bvh_traversal.h b/intern/cycles/kernel/bvh/bvh_traversal.h
index c58d3b0316c..ae8f54821f2 100644
--- a/intern/cycles/kernel/bvh/bvh_traversal.h
+++ b/intern/cycles/kernel/bvh/bvh_traversal.h
@@ -244,14 +244,14 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
{
/* shadow ray early termination */
#if defined(__KERNEL_SSE2__)
- if(visibility == PATH_RAY_SHADOW_OPAQUE)
+ if(visibility & PATH_RAY_SHADOW_OPAQUE)
return true;
tsplat = ssef(0.0f, 0.0f, -isect->t, -isect->t);
# if BVH_FEATURE(BVH_HAIR)
tfar = ssef(isect->t);
# endif
#else
- if(visibility == PATH_RAY_SHADOW_OPAQUE)
+ if(visibility & PATH_RAY_SHADOW_OPAQUE)
return true;
#endif
}
@@ -274,14 +274,14 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
{
/* shadow ray early termination */
# if defined(__KERNEL_SSE2__)
- if(visibility == PATH_RAY_SHADOW_OPAQUE)
+ if(visibility & PATH_RAY_SHADOW_OPAQUE)
return true;
tsplat = ssef(0.0f, 0.0f, -isect->t, -isect->t);
# if BVH_FEATURE(BVH_HAIR)
tfar = ssef(isect->t);
# endif
# else
- if(visibility == PATH_RAY_SHADOW_OPAQUE)
+ if(visibility & PATH_RAY_SHADOW_OPAQUE)
return true;
# endif
}
@@ -298,44 +298,44 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
kernel_assert((curve_type & PRIMITIVE_ALL) == (type & PRIMITIVE_ALL));
bool hit;
if(kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE) {
- hit = bvh_cardinal_curve_intersect(kg,
- isect,
- P,
- dir,
- visibility,
- object,
- prim_addr,
- ray->time,
- curve_type,
- lcg_state,
- difl,
- extmax);
+ hit = cardinal_curve_intersect(kg,
+ isect,
+ P,
+ dir,
+ visibility,
+ object,
+ prim_addr,
+ ray->time,
+ curve_type,
+ lcg_state,
+ difl,
+ extmax);
}
else {
- hit = bvh_curve_intersect(kg,
- isect,
- P,
- dir,
- visibility,
- object,
- prim_addr,
- ray->time,
- curve_type,
- lcg_state,
- difl,
- extmax);
+ hit = curve_intersect(kg,
+ isect,
+ P,
+ dir,
+ visibility,
+ object,
+ prim_addr,
+ ray->time,
+ curve_type,
+ lcg_state,
+ difl,
+ extmax);
}
if(hit) {
/* shadow ray early termination */
# if defined(__KERNEL_SSE2__)
- if(visibility == PATH_RAY_SHADOW_OPAQUE)
+ if(visibility & PATH_RAY_SHADOW_OPAQUE)
return true;
tsplat = ssef(0.0f, 0.0f, -isect->t, -isect->t);
# if BVH_FEATURE(BVH_HAIR)
tfar = ssef(isect->t);
# endif
# else
- if(visibility == PATH_RAY_SHADOW_OPAQUE)
+ if(visibility & PATH_RAY_SHADOW_OPAQUE)
return true;
# endif
}
diff --git a/intern/cycles/kernel/bvh/qbvh_nodes.h b/intern/cycles/kernel/bvh/qbvh_nodes.h
index 6d22f0b0d6a..3036efd4198 100644
--- a/intern/cycles/kernel/bvh/qbvh_nodes.h
+++ b/intern/cycles/kernel/bvh/qbvh_nodes.h
@@ -126,8 +126,8 @@ ccl_device_inline int qbvh_aligned_node_intersect(KernelGlobals *ccl_restrict kg
const sseb vmask = cast(tnear) > cast(tfar);
int mask = (int)movemask(vmask)^0xf;
#else
- const ssef tnear = max4(tnear_x, tnear_y, tnear_z, isect_near);
- const ssef tfar = min4(tfar_x, tfar_y, tfar_z, isect_far);
+ const ssef tnear = max4(isect_near, tnear_x, tnear_y, tnear_z);
+ const ssef tfar = min4(isect_far, tfar_x, tfar_y, tfar_z);
const sseb vmask = tnear <= tfar;
int mask = (int)movemask(vmask);
#endif
@@ -174,8 +174,8 @@ ccl_device_inline int qbvh_aligned_node_intersect_robust(
const float round_down = 1.0f - difl;
const float round_up = 1.0f + difl;
- const ssef tnear = max4(tnear_x, tnear_y, tnear_z, isect_near);
- const ssef tfar = min4(tfar_x, tfar_y, tfar_z, isect_far);
+ const ssef tnear = max4(isect_near, tnear_x, tnear_y, tnear_z);
+ const ssef tfar = min4(isect_far, tfar_x, tfar_y, tfar_z);
const sseb vmask = round_down*tnear <= round_up*tfar;
*dist = tnear;
return (int)movemask(vmask);
diff --git a/intern/cycles/kernel/bvh/qbvh_shadow_all.h b/intern/cycles/kernel/bvh/qbvh_shadow_all.h
index ce474438f2c..522213f30ca 100644
--- a/intern/cycles/kernel/bvh/qbvh_shadow_all.h
+++ b/intern/cycles/kernel/bvh/qbvh_shadow_all.h
@@ -33,7 +33,7 @@
ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
const Ray *ray,
Intersection *isect_array,
- const int skip_object,
+ const uint visibility,
const uint max_hits,
uint *num_hits)
{
@@ -107,7 +107,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
if(false
#ifdef __VISIBILITY_FLAG__
- || ((__float_as_uint(inodes.x) & PATH_RAY_SHADOW) == 0)
+ || ((__float_as_uint(inodes.x) & visibility) == 0)
#endif
#if BVH_FEATURE(BVH_MOTION)
|| UNLIKELY(ray->time < inodes.y)
@@ -244,7 +244,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
if(node_addr < 0) {
float4 leaf = kernel_tex_fetch(__bvh_leaf_nodes, (-node_addr-1));
#ifdef __VISIBILITY_FLAG__
- if((__float_as_uint(leaf.z) & PATH_RAY_SHADOW) == 0) {
+ if((__float_as_uint(leaf.z) & visibility) == 0) {
/* Pop. */
node_addr = traversal_stack[stack_ptr].addr;
--stack_ptr;
@@ -268,17 +268,6 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
/* Primitive intersection. */
while(prim_addr < prim_addr2) {
kernel_assert((kernel_tex_fetch(__prim_type, prim_addr) & PRIMITIVE_ALL) == p_type);
-
-#ifdef __SHADOW_TRICKS__
- uint tri_object = (object == OBJECT_NONE)
- ? kernel_tex_fetch(__prim_object, prim_addr)
- : object;
- if(tri_object == skip_object) {
- ++prim_addr;
- continue;
- }
-#endif
-
bool hit;
/* todo: specialized intersect functions which don't fill in
@@ -291,7 +280,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
isect_array,
P,
dir,
- PATH_RAY_SHADOW,
+ visibility,
object,
prim_addr);
break;
@@ -303,7 +292,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
P,
dir,
ray->time,
- PATH_RAY_SHADOW,
+ visibility,
object,
prim_addr);
break;
@@ -314,30 +303,30 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
case PRIMITIVE_MOTION_CURVE: {
const uint curve_type = kernel_tex_fetch(__prim_type, prim_addr);
if(kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE) {
- hit = bvh_cardinal_curve_intersect(kg,
- isect_array,
- P,
- dir,
- PATH_RAY_SHADOW,
- object,
- prim_addr,
- ray->time,
- curve_type,
- NULL,
- 0, 0);
+ hit = cardinal_curve_intersect(kg,
+ isect_array,
+ P,
+ dir,
+ visibility,
+ object,
+ prim_addr,
+ ray->time,
+ curve_type,
+ NULL,
+ 0, 0);
}
else {
- hit = bvh_curve_intersect(kg,
- isect_array,
- P,
- dir,
- PATH_RAY_SHADOW,
- object,
- prim_addr,
- ray->time,
- curve_type,
- NULL,
- 0, 0);
+ hit = curve_intersect(kg,
+ isect_array,
+ P,
+ dir,
+ visibility,
+ object,
+ prim_addr,
+ ray->time,
+ curve_type,
+ NULL,
+ 0, 0);
}
break;
}
diff --git a/intern/cycles/kernel/bvh/qbvh_traversal.h b/intern/cycles/kernel/bvh/qbvh_traversal.h
index fca75a1d416..335a4afd47a 100644
--- a/intern/cycles/kernel/bvh/qbvh_traversal.h
+++ b/intern/cycles/kernel/bvh/qbvh_traversal.h
@@ -340,7 +340,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
prim_addr)) {
tfar = ssef(isect->t);
/* Shadow ray early termination. */
- if(visibility == PATH_RAY_SHADOW_OPAQUE) {
+ if(visibility & PATH_RAY_SHADOW_OPAQUE) {
return true;
}
}
@@ -362,7 +362,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
prim_addr)) {
tfar = ssef(isect->t);
/* Shadow ray early termination. */
- if(visibility == PATH_RAY_SHADOW_OPAQUE) {
+ if(visibility & PATH_RAY_SHADOW_OPAQUE) {
return true;
}
}
@@ -379,37 +379,37 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
kernel_assert((curve_type & PRIMITIVE_ALL) == (type & PRIMITIVE_ALL));
bool hit;
if(kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE) {
- hit = bvh_cardinal_curve_intersect(kg,
- isect,
- P,
- dir,
- visibility,
- object,
- prim_addr,
- ray->time,
- curve_type,
- lcg_state,
- difl,
- extmax);
+ hit = cardinal_curve_intersect(kg,
+ isect,
+ P,
+ dir,
+ visibility,
+ object,
+ prim_addr,
+ ray->time,
+ curve_type,
+ lcg_state,
+ difl,
+ extmax);
}
else {
- hit = bvh_curve_intersect(kg,
- isect,
- P,
- dir,
- visibility,
- object,
- prim_addr,
- ray->time,
- curve_type,
- lcg_state,
- difl,
- extmax);
+ hit = curve_intersect(kg,
+ isect,
+ P,
+ dir,
+ visibility,
+ object,
+ prim_addr,
+ ray->time,
+ curve_type,
+ lcg_state,
+ difl,
+ extmax);
}
if(hit) {
tfar = ssef(isect->t);
/* Shadow ray early termination. */
- if(visibility == PATH_RAY_SHADOW_OPAQUE) {
+ if(visibility & PATH_RAY_SHADOW_OPAQUE) {
return true;
}
}
diff --git a/intern/cycles/kernel/closure/bsdf.h b/intern/cycles/kernel/closure/bsdf.h
index a04c157dc40..86a00d2124d 100644
--- a/intern/cycles/kernel/closure/bsdf.h
+++ b/intern/cycles/kernel/closure/bsdf.h
@@ -423,6 +423,11 @@ ccl_device bool bsdf_merge(ShaderClosure *a, ShaderClosure *b)
case CLOSURE_BSDF_HAIR_REFLECTION_ID:
case CLOSURE_BSDF_HAIR_TRANSMISSION_ID:
return bsdf_hair_merge(a, b);
+#ifdef __PRINCIPLED__
+ case CLOSURE_BSDF_PRINCIPLED_DIFFUSE_ID:
+ case CLOSURE_BSDF_BSSRDF_PRINCIPLED_ID:
+ return bsdf_principled_diffuse_merge(a, b);
+#endif
#ifdef __VOLUME__
case CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID:
return volume_henyey_greenstein_merge(a, b);
diff --git a/intern/cycles/kernel/closure/bsdf_microfacet_multi.h b/intern/cycles/kernel/closure/bsdf_microfacet_multi.h
index 22d0092093a..2f2c35d5d1f 100644
--- a/intern/cycles/kernel/closure/bsdf_microfacet_multi.h
+++ b/intern/cycles/kernel/closure/bsdf_microfacet_multi.h
@@ -40,20 +40,20 @@ ccl_device_forceinline float D_ggx_aniso(const float3 wm, const float2 alpha)
}
/* Sample slope distribution (based on page 14 of the supplemental implementation). */
-ccl_device_forceinline float2 mf_sampleP22_11(const float cosI, const float2 randU)
+ccl_device_forceinline float2 mf_sampleP22_11(const float cosI, const float randx, const float randy)
{
if(cosI > 0.9999f || fabsf(cosI) < 1e-6f) {
- const float r = sqrtf(randU.x / max(1.0f - randU.x, 1e-7f));
- const float phi = M_2PI_F * randU.y;
+ const float r = sqrtf(randx / max(1.0f - randx, 1e-7f));
+ const float phi = M_2PI_F * randy;
return make_float2(r*cosf(phi), r*sinf(phi));
}
- const float sinI = sqrtf(1.0f - cosI*cosI);
+ const float sinI = safe_sqrtf(1.0f - cosI*cosI);
const float tanI = sinI/cosI;
const float projA = 0.5f * (cosI + 1.0f);
if(projA < 0.0001f)
return make_float2(0.0f, 0.0f);
- const float A = 2.0f*randU.x*projA / cosI - 1.0f;
+ const float A = 2.0f*randx*projA / cosI - 1.0f;
float tmp = A*A-1.0f;
if(fabsf(tmp) < 1e-7f)
return make_float2(0.0f, 0.0f);
@@ -64,24 +64,24 @@ ccl_device_forceinline float2 mf_sampleP22_11(const float cosI, const float2 ran
const float slopeX = (A < 0.0f || slopeX2 > 1.0f/tanI)? (tanI*tmp - D) : slopeX2;
float U2;
- if(randU.y >= 0.5f)
- U2 = 2.0f*(randU.y - 0.5f);
+ if(randy >= 0.5f)
+ U2 = 2.0f*(randy - 0.5f);
else
- U2 = 2.0f*(0.5f - randU.y);
+ U2 = 2.0f*(0.5f - randy);
const float z = (U2*(U2*(U2*0.27385f-0.73369f)+0.46341f)) / (U2*(U2*(U2*0.093073f+0.309420f)-1.0f)+0.597999f);
const float slopeY = z * sqrtf(1.0f + slopeX*slopeX);
- if(randU.y >= 0.5f)
+ if(randy >= 0.5f)
return make_float2(slopeX, slopeY);
else
return make_float2(slopeX, -slopeY);
}
/* Visible normal sampling for the GGX distribution (based on page 7 of the supplemental implementation). */
-ccl_device_forceinline float3 mf_sample_vndf(const float3 wi, const float2 alpha, const float2 randU)
+ccl_device_forceinline float3 mf_sample_vndf(const float3 wi, const float2 alpha, const float randx, const float randy)
{
const float3 wi_11 = normalize(make_float3(alpha.x*wi.x, alpha.y*wi.y, wi.z));
- const float2 slope_11 = mf_sampleP22_11(wi_11.z, randU);
+ const float2 slope_11 = mf_sampleP22_11(wi_11.z, randx, randy);
const float3 cossin_phi = safe_normalize(make_float3(wi_11.x, wi_11.y, 0.0f));
const float slope_x = alpha.x*(cossin_phi.x * slope_11.x - cossin_phi.y * slope_11.y);
@@ -474,6 +474,7 @@ ccl_device int bsdf_microfacet_multi_ggx_sample(KernelGlobals *kg, const ShaderC
*eval *= *pdf;
*omega_in = X*localO.x + Y*localO.y + Z*localO.z;
+
#ifdef __RAY_DIFFERENTIALS__
*domega_in_dx = (2 * dot(Z, dIdx)) * Z - dIdx;
*domega_in_dy = (2 * dot(Z, dIdy)) * Z - dIdy;
diff --git a/intern/cycles/kernel/closure/bsdf_microfacet_multi_impl.h b/intern/cycles/kernel/closure/bsdf_microfacet_multi_impl.h
index 2eb2457c9e5..e73915dbda7 100644
--- a/intern/cycles/kernel/closure/bsdf_microfacet_multi_impl.h
+++ b/intern/cycles/kernel/closure/bsdf_microfacet_multi_impl.h
@@ -100,11 +100,14 @@ ccl_device_forceinline float3 MF_FUNCTION_FULL_NAME(mf_eval)(
bool outside = true;
for(int order = 0; order < 10; order++) {
- /* Sample microfacet height and normal */
- if(!mf_sample_height(wr, &hr, &C1_r, &G1_r, &lambda_r, lcg_step_float_addrspace(lcg_state)))
+ /* Sample microfacet height. */
+ float height_rand = lcg_step_float_addrspace(lcg_state);
+ if(!mf_sample_height(wr, &hr, &C1_r, &G1_r, &lambda_r, height_rand))
break;
- float3 wm = mf_sample_vndf(-wr, alpha, make_float2(lcg_step_float_addrspace(lcg_state),
- lcg_step_float_addrspace(lcg_state)));
+ /* Sample microfacet normal. */
+ float vndf_rand_y = lcg_step_float_addrspace(lcg_state);
+ float vndf_rand_x = lcg_step_float_addrspace(lcg_state);
+ float3 wm = mf_sample_vndf(-wr, alpha, vndf_rand_x, vndf_rand_y);
#ifdef MF_MULTI_GLASS
if(order == 0 && use_fresnel) {
@@ -136,7 +139,8 @@ ccl_device_forceinline float3 MF_FUNCTION_FULL_NAME(mf_eval)(
#ifdef MF_MULTI_GLASS
bool next_outside;
float3 wi_prev = -wr;
- wr = mf_sample_phase_glass(-wr, outside? eta: 1.0f/eta, wm, lcg_step_float_addrspace(lcg_state), &next_outside);
+ float phase_rand = lcg_step_float_addrspace(lcg_state);
+ wr = mf_sample_phase_glass(-wr, outside? eta: 1.0f/eta, wm, phase_rand, &next_outside);
if(!next_outside) {
outside = !outside;
wr = -wr;
@@ -204,14 +208,16 @@ ccl_device_forceinline float3 MF_FUNCTION_FULL_NAME(mf_sample)(
int order;
for(order = 0; order < 10; order++) {
/* Sample microfacet height. */
- if(!mf_sample_height(wr, &hr, &C1_r, &G1_r, &lambda_r, lcg_step_float_addrspace(lcg_state))) {
+ float height_rand = lcg_step_float_addrspace(lcg_state);
+ if(!mf_sample_height(wr, &hr, &C1_r, &G1_r, &lambda_r, height_rand)) {
/* The random walk has left the surface. */
*wo = outside? wr: -wr;
return throughput;
}
/* Sample microfacet normal. */
- float3 wm = mf_sample_vndf(-wr, alpha, make_float2(lcg_step_float_addrspace(lcg_state),
- lcg_step_float_addrspace(lcg_state)));
+ float vndf_rand_y = lcg_step_float_addrspace(lcg_state);
+ float vndf_rand_x = lcg_step_float_addrspace(lcg_state);
+ float3 wm = mf_sample_vndf(-wr, alpha, vndf_rand_x, vndf_rand_y);
/* First-bounce color is already accounted for in mix weight. */
if(!use_fresnel && order > 0)
@@ -221,7 +227,8 @@ ccl_device_forceinline float3 MF_FUNCTION_FULL_NAME(mf_sample)(
#ifdef MF_MULTI_GLASS
bool next_outside;
float3 wi_prev = -wr;
- wr = mf_sample_phase_glass(-wr, outside? eta: 1.0f/eta, wm, lcg_step_float_addrspace(lcg_state), &next_outside);
+ float phase_rand = lcg_step_float_addrspace(lcg_state);
+ wr = mf_sample_phase_glass(-wr, outside? eta: 1.0f/eta, wm, phase_rand, &next_outside);
if(!next_outside) {
hr = -hr;
wr = -wr;
diff --git a/intern/cycles/kernel/closure/bsdf_principled_diffuse.h b/intern/cycles/kernel/closure/bsdf_principled_diffuse.h
index 215c32e1ffb..f8ca64293b0 100644
--- a/intern/cycles/kernel/closure/bsdf_principled_diffuse.h
+++ b/intern/cycles/kernel/closure/bsdf_principled_diffuse.h
@@ -58,6 +58,14 @@ ccl_device int bsdf_principled_diffuse_setup(PrincipledDiffuseBsdf *bsdf)
return SD_BSDF|SD_BSDF_HAS_EVAL;
}
+ccl_device bool bsdf_principled_diffuse_merge(const ShaderClosure *a, const ShaderClosure *b)
+{
+ const PrincipledDiffuseBsdf *bsdf_a = (const PrincipledDiffuseBsdf*)a;
+ const PrincipledDiffuseBsdf *bsdf_b = (const PrincipledDiffuseBsdf*)b;
+
+ return (isequal_float3(bsdf_a->N, bsdf_b->N) && bsdf_a->roughness == bsdf_b->roughness);
+}
+
ccl_device float3 bsdf_principled_diffuse_eval_reflect(const ShaderClosure *sc, const float3 I,
const float3 omega_in, float *pdf)
{
diff --git a/intern/cycles/kernel/closure/bssrdf.h b/intern/cycles/kernel/closure/bssrdf.h
index f733ea4c517..267aeea6e86 100644
--- a/intern/cycles/kernel/closure/bssrdf.h
+++ b/intern/cycles/kernel/closure/bssrdf.h
@@ -348,8 +348,9 @@ ccl_device_inline Bssrdf *bssrdf_alloc(ShaderData *sd, float3 weight)
{
Bssrdf *bssrdf = (Bssrdf*)closure_alloc(sd, sizeof(Bssrdf), CLOSURE_NONE_ID, weight);
- if(!bssrdf)
+ if(bssrdf == NULL) {
return NULL;
+ }
float sample_weight = fabsf(average(weight));
bssrdf->sample_weight = sample_weight;
@@ -399,7 +400,7 @@ ccl_device int bssrdf_setup(Bssrdf *bssrdf, ClosureType type)
bssrdf_burley_setup(bssrdf);
}
- return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSSRDF;
+ return SD_BSSRDF;
}
}
diff --git a/intern/cycles/kernel/filter/filter_features_sse.h b/intern/cycles/kernel/filter/filter_features_sse.h
index 3185330994c..3ddd8712266 100644
--- a/intern/cycles/kernel/filter/filter_features_sse.h
+++ b/intern/cycles/kernel/filter/filter_features_sse.h
@@ -16,7 +16,7 @@
CCL_NAMESPACE_BEGIN
-#define ccl_get_feature_sse(pass) _mm_loadu_ps(buffer + (pass)*pass_stride)
+#define ccl_get_feature_sse(pass) load_float4(buffer + (pass)*pass_stride)
/* Loop over the pixels in the range [low.x, high.x) x [low.y, high.y), 4 at a time.
* pixel_buffer always points to the first of the 4 current pixel in the first pass.
@@ -24,25 +24,25 @@ CCL_NAMESPACE_BEGIN
#define FOR_PIXEL_WINDOW_SSE pixel_buffer = buffer + (low.y - rect.y)*buffer_w + (low.x - rect.x); \
for(pixel.y = low.y; pixel.y < high.y; pixel.y++) { \
- __m128 y4 = _mm_set1_ps(pixel.y); \
+ float4 y4 = make_float4(pixel.y); \
for(pixel.x = low.x; pixel.x < high.x; pixel.x += 4, pixel_buffer += 4) { \
- __m128 x4 = _mm_add_ps(_mm_set1_ps(pixel.x), _mm_set_ps(3.0f, 2.0f, 1.0f, 0.0f)); \
- __m128 active_pixels = _mm_cmplt_ps(x4, _mm_set1_ps(high.x));
+ float4 x4 = make_float4(pixel.x) + make_float4(0.0f, 1.0f, 2.0f, 3.0f); \
+ int4 active_pixels = x4 < make_float4(high.x);
#define END_FOR_PIXEL_WINDOW_SSE } \
pixel_buffer += buffer_w - (pixel.x - low.x); \
}
-ccl_device_inline void filter_get_features_sse(__m128 x, __m128 y,
- __m128 active_pixels,
+ccl_device_inline void filter_get_features_sse(float4 x, float4 y,
+ int4 active_pixels,
const float *ccl_restrict buffer,
- __m128 *features,
- const __m128 *ccl_restrict mean,
+ float4 *features,
+ const float4 *ccl_restrict mean,
int pass_stride)
{
features[0] = x;
features[1] = y;
- features[2] = _mm_fabs_ps(ccl_get_feature_sse(0));
+ features[2] = fabs(ccl_get_feature_sse(0));
features[3] = ccl_get_feature_sse(1);
features[4] = ccl_get_feature_sse(2);
features[5] = ccl_get_feature_sse(3);
@@ -52,53 +52,41 @@ ccl_device_inline void filter_get_features_sse(__m128 x, __m128 y,
features[9] = ccl_get_feature_sse(7);
if(mean) {
for(int i = 0; i < DENOISE_FEATURES; i++)
- features[i] = _mm_sub_ps(features[i], mean[i]);
+ features[i] = features[i] - mean[i];
}
for(int i = 0; i < DENOISE_FEATURES; i++)
- features[i] = _mm_mask_ps(features[i], active_pixels);
+ features[i] = mask(active_pixels, features[i]);
}
-ccl_device_inline void filter_get_feature_scales_sse(__m128 x, __m128 y,
- __m128 active_pixels,
+ccl_device_inline void filter_get_feature_scales_sse(float4 x, float4 y,
+ int4 active_pixels,
const float *ccl_restrict buffer,
- __m128 *scales,
- const __m128 *ccl_restrict mean,
+ float4 *scales,
+ const float4 *ccl_restrict mean,
int pass_stride)
{
- scales[0] = _mm_mask_ps(_mm_fabs_ps(_mm_sub_ps(x, mean[0])), active_pixels);
- scales[1] = _mm_mask_ps(_mm_fabs_ps(_mm_sub_ps(y, mean[1])), active_pixels);
-
- scales[2] = _mm_mask_ps(_mm_fabs_ps(_mm_sub_ps(_mm_fabs_ps(ccl_get_feature_sse(0)), mean[2])), active_pixels);
-
- __m128 diff, scale;
- diff = _mm_sub_ps(ccl_get_feature_sse(1), mean[3]);
- scale = _mm_mul_ps(diff, diff);
- diff = _mm_sub_ps(ccl_get_feature_sse(2), mean[4]);
- scale = _mm_add_ps(scale, _mm_mul_ps(diff, diff));
- diff = _mm_sub_ps(ccl_get_feature_sse(3), mean[5]);
- scale = _mm_add_ps(scale, _mm_mul_ps(diff, diff));
- scales[3] = _mm_mask_ps(scale, active_pixels);
-
- scales[4] = _mm_mask_ps(_mm_fabs_ps(_mm_sub_ps(ccl_get_feature_sse(4), mean[6])), active_pixels);
-
- diff = _mm_sub_ps(ccl_get_feature_sse(5), mean[7]);
- scale = _mm_mul_ps(diff, diff);
- diff = _mm_sub_ps(ccl_get_feature_sse(6), mean[8]);
- scale = _mm_add_ps(scale, _mm_mul_ps(diff, diff));
- diff = _mm_sub_ps(ccl_get_feature_sse(7), mean[9]);
- scale = _mm_add_ps(scale, _mm_mul_ps(diff, diff));
- scales[5] = _mm_mask_ps(scale, active_pixels);
+ scales[0] = fabs(x - mean[0]);
+ scales[1] = fabs(y - mean[1]);
+ scales[2] = fabs(fabs(ccl_get_feature_sse(0)) - mean[2]);
+ scales[3] = sqr(ccl_get_feature_sse(1) - mean[3]) +
+ sqr(ccl_get_feature_sse(2) - mean[4]) +
+ sqr(ccl_get_feature_sse(3) - mean[5]);
+ scales[4] = fabs(ccl_get_feature_sse(4) - mean[6]);
+ scales[5] = sqr(ccl_get_feature_sse(5) - mean[7]) +
+ sqr(ccl_get_feature_sse(6) - mean[8]) +
+ sqr(ccl_get_feature_sse(7) - mean[9]);
+ for(int i = 0; i < 6; i++)
+ scales[i] = mask(active_pixels, scales[i]);
}
-ccl_device_inline void filter_calculate_scale_sse(__m128 *scale)
+ccl_device_inline void filter_calculate_scale_sse(float4 *scale)
{
- scale[0] = _mm_rcp_ps(_mm_max_ps(_mm_hmax_ps(scale[0]), _mm_set1_ps(0.01f)));
- scale[1] = _mm_rcp_ps(_mm_max_ps(_mm_hmax_ps(scale[1]), _mm_set1_ps(0.01f)));
- scale[2] = _mm_rcp_ps(_mm_max_ps(_mm_hmax_ps(scale[2]), _mm_set1_ps(0.01f)));
- scale[6] = _mm_rcp_ps(_mm_max_ps(_mm_hmax_ps(scale[4]), _mm_set1_ps(0.01f)));
-
- scale[7] = scale[8] = scale[9] = _mm_rcp_ps(_mm_max_ps(_mm_hmax_ps(_mm_sqrt_ps(scale[5])), _mm_set1_ps(0.01f)));
- scale[3] = scale[4] = scale[5] = _mm_rcp_ps(_mm_max_ps(_mm_hmax_ps(_mm_sqrt_ps(scale[3])), _mm_set1_ps(0.01f)));
+ scale[0] = rcp(max(reduce_max(scale[0]), make_float4(0.01f)));
+ scale[1] = rcp(max(reduce_max(scale[1]), make_float4(0.01f)));
+ scale[2] = rcp(max(reduce_max(scale[2]), make_float4(0.01f)));
+ scale[6] = rcp(max(reduce_max(scale[4]), make_float4(0.01f)));
+ scale[7] = scale[8] = scale[9] = rcp(max(reduce_max(sqrt(scale[5])), make_float4(0.01f)));
+ scale[3] = scale[4] = scale[5] = rcp(max(reduce_max(sqrt(scale[3])), make_float4(0.01f)));
}
diff --git a/intern/cycles/kernel/filter/filter_nlm_cpu.h b/intern/cycles/kernel/filter/filter_nlm_cpu.h
index 3e752bce68f..5e989331bc2 100644
--- a/intern/cycles/kernel/filter/filter_nlm_cpu.h
+++ b/intern/cycles/kernel/filter/filter_nlm_cpu.h
@@ -50,10 +50,8 @@ ccl_device_inline void kernel_filter_nlm_blur(const float *ccl_restrict differen
int w,
int f)
{
-#ifdef __KERNEL_SSE3__
- int aligned_lowx = (rect.x & ~(3));
- int aligned_highx = ((rect.z + 3) & ~(3));
-#endif
+ int aligned_lowx = rect.x / 4;
+ int aligned_highx = (rect.z + 3) / 4;
for(int y = rect.y; y < rect.w; y++) {
const int low = max(rect.y, y-f);
const int high = min(rect.w, y+f+1);
@@ -61,15 +59,11 @@ ccl_device_inline void kernel_filter_nlm_blur(const float *ccl_restrict differen
out_image[y*w+x] = 0.0f;
}
for(int y1 = low; y1 < high; y1++) {
-#ifdef __KERNEL_SSE3__
- for(int x = aligned_lowx; x < aligned_highx; x+=4) {
- _mm_store_ps(out_image + y*w+x, _mm_add_ps(_mm_load_ps(out_image + y*w+x), _mm_load_ps(difference_image + y1*w+x)));
+ float4* out_image4 = (float4*)(out_image + y*w);
+ float4* difference_image4 = (float4*)(difference_image + y1*w);
+ for(int x = aligned_lowx; x < aligned_highx; x++) {
+ out_image4[x] += difference_image4[x];
}
-#else
- for(int x = rect.x; x < rect.z; x++) {
- out_image[y*w+x] += difference_image[y1*w+x];
- }
-#endif
}
for(int x = rect.x; x < rect.z; x++) {
out_image[y*w+x] *= 1.0f/(high - low);
diff --git a/intern/cycles/kernel/filter/filter_prefilter.h b/intern/cycles/kernel/filter/filter_prefilter.h
index d5ae1b73927..eefcbfea230 100644
--- a/intern/cycles/kernel/filter/filter_prefilter.h
+++ b/intern/cycles/kernel/filter/filter_prefilter.h
@@ -35,8 +35,7 @@ ccl_device void kernel_filter_divide_shadow(int sample,
ccl_global float *bufferVariance,
int4 rect,
int buffer_pass_stride,
- int buffer_denoising_offset,
- bool use_split_variance)
+ int buffer_denoising_offset)
{
int xtile = (x < tiles->x[1])? 0: ((x < tiles->x[2])? 1: 2);
int ytile = (y < tiles->y[1])? 0: ((y < tiles->y[2])? 1: 2);
@@ -57,12 +56,14 @@ ccl_device void kernel_filter_divide_shadow(int sample,
float varB = center_buffer[5];
int odd_sample = (sample+1)/2;
int even_sample = sample/2;
- if(use_split_variance) {
- varA = max(0.0f, varA - unfilteredA[idx]*unfilteredA[idx]*odd_sample);
- varB = max(0.0f, varB - unfilteredB[idx]*unfilteredB[idx]*even_sample);
- }
- varA /= (odd_sample - 1);
- varB /= (even_sample - 1);
+
+ /* Approximate variance as E[x^2] - 1/N * (E[x])^2, since online variance
+ * update does not work efficiently with atomics in the kernel. */
+ varA = max(0.0f, varA - unfilteredA[idx]*unfilteredA[idx]*odd_sample);
+ varB = max(0.0f, varB - unfilteredB[idx]*unfilteredB[idx]*even_sample);
+
+ varA /= max(odd_sample - 1, 1);
+ varB /= max(even_sample - 1, 1);
sampleVariance[idx] = 0.5f*(varA + varB) / sample;
sampleVarianceV[idx] = 0.5f * (varA - varB) * (varA - varB) / (sample*sample);
@@ -84,8 +85,7 @@ ccl_device void kernel_filter_get_feature(int sample,
ccl_global float *mean,
ccl_global float *variance,
int4 rect, int buffer_pass_stride,
- int buffer_denoising_offset,
- bool use_split_variance)
+ int buffer_denoising_offset)
{
int xtile = (x < tiles->x[1])? 0: ((x < tiles->x[2])? 1: 2);
int ytile = (y < tiles->y[1])? 0: ((y < tiles->y[2])? 1: 2);
@@ -96,11 +96,14 @@ ccl_device void kernel_filter_get_feature(int sample,
int idx = (y-rect.y)*buffer_w + (x - rect.x);
mean[idx] = center_buffer[m_offset] / sample;
- if(use_split_variance) {
+ if(sample > 1) {
+ /* Approximate variance as E[x^2] - 1/N * (E[x])^2, since online variance
+ * update does not work efficiently with atomics in the kernel. */
variance[idx] = max(0.0f, (center_buffer[v_offset] - mean[idx]*mean[idx]*sample) / (sample * (sample-1)));
}
else {
- variance[idx] = center_buffer[v_offset] / (sample * (sample-1));
+ /* Can't compute variance with single sample, just set it very high. */
+ variance[idx] = 1e10f;
}
}
@@ -114,49 +117,56 @@ ccl_device void kernel_filter_detect_outliers(int x, int y,
{
int buffer_w = align_up(rect.z - rect.x, 4);
- int n = 0;
- float values[25];
- for(int y1 = max(y-2, rect.y); y1 < min(y+3, rect.w); y1++) {
- for(int x1 = max(x-2, rect.x); x1 < min(x+3, rect.z); x1++) {
- int idx = (y1-rect.y)*buffer_w + (x1-rect.x);
- float L = average(make_float3(image[idx], image[idx+pass_stride], image[idx+2*pass_stride]));
-
- /* Find the position of L. */
- int i;
- for(i = 0; i < n; i++) {
- if(values[i] > L) break;
- }
- /* Make space for L by shifting all following values to the right. */
- for(int j = n; j > i; j--) {
- values[j] = values[j-1];
- }
- /* Insert L. */
- values[i] = L;
- n++;
- }
- }
-
int idx = (y-rect.y)*buffer_w + (x-rect.x);
- float L = average(make_float3(image[idx], image[idx+pass_stride], image[idx+2*pass_stride]));
+ float3 color = make_float3(image[idx], image[idx+pass_stride], image[idx+2*pass_stride]);
- float ref = 2.0f*values[(int)(n*0.75f)];
float fac = 1.0f;
- if(L > ref) {
- /* The pixel appears to be an outlier.
- * However, it may just be a legitimate highlight. Therefore, it is checked how likely it is that the pixel
- * should actually be at the reference value:
- * If the reference is within the 3-sigma interval, the pixel is assumed to be a statistical outlier.
- * Otherwise, it is very unlikely that the pixel should be darker, which indicates a legitimate highlight.
- */
- float stddev = sqrtf(average(make_float3(variance[idx], variance[idx+pass_stride], variance[idx+2*pass_stride])));
- if(L - 3*stddev < ref) {
- /* The pixel is an outlier, so negate the depth value to mark it as one.
- * Also, scale its brightness down to the outlier threshold to avoid trouble with the NLM weights. */
- depth[idx] = -depth[idx];
- fac = ref/L;
- variance[idx ] *= fac*fac;
- variance[idx + pass_stride] *= fac*fac;
- variance[idx+2*pass_stride] *= fac*fac;
+ if(color.x < 0.0f || color.y < 0.0f || color.z < 0.0f) {
+ depth[idx] = -depth[idx];
+ fac = 0.0f;
+ }
+ else {
+ float L = average(color);
+ int n = 0;
+ float values[25];
+ for(int y1 = max(y-2, rect.y); y1 < min(y+3, rect.w); y1++) {
+ for(int x1 = max(x-2, rect.x); x1 < min(x+3, rect.z); x1++) {
+ int idx = (y1-rect.y)*buffer_w + (x1-rect.x);
+ float L = average(make_float3(image[idx], image[idx+pass_stride], image[idx+2*pass_stride]));
+
+ /* Find the position of L. */
+ int i;
+ for(i = 0; i < n; i++) {
+ if(values[i] > L) break;
+ }
+ /* Make space for L by shifting all following values to the right. */
+ for(int j = n; j > i; j--) {
+ values[j] = values[j-1];
+ }
+ /* Insert L. */
+ values[i] = L;
+ n++;
+ }
+ }
+
+ float ref = 2.0f*values[(int)(n*0.75f)];
+ if(L > ref) {
+ /* The pixel appears to be an outlier.
+ * However, it may just be a legitimate highlight. Therefore, it is checked how likely it is that the pixel
+ * should actually be at the reference value:
+ * If the reference is within the 3-sigma interval, the pixel is assumed to be a statistical outlier.
+ * Otherwise, it is very unlikely that the pixel should be darker, which indicates a legitimate highlight.
+ */
+ float stddev = sqrtf(average(make_float3(variance[idx], variance[idx+pass_stride], variance[idx+2*pass_stride])));
+ if(L - 3*stddev < ref) {
+ /* The pixel is an outlier, so negate the depth value to mark it as one.
+ * Also, scale its brightness down to the outlier threshold to avoid trouble with the NLM weights. */
+ depth[idx] = -depth[idx];
+ fac = ref/L;
+ variance[idx ] *= fac*fac;
+ variance[idx + pass_stride] *= fac*fac;
+ variance[idx+2*pass_stride] *= fac*fac;
+ }
}
}
out[idx ] = fac*image[idx];
diff --git a/intern/cycles/kernel/filter/filter_transform_sse.h b/intern/cycles/kernel/filter/filter_transform_sse.h
index 30dc2969b11..9e65f61664b 100644
--- a/intern/cycles/kernel/filter/filter_transform_sse.h
+++ b/intern/cycles/kernel/filter/filter_transform_sse.h
@@ -24,7 +24,7 @@ ccl_device void kernel_filter_construct_transform(const float *ccl_restrict buff
{
int buffer_w = align_up(rect.z - rect.x, 4);
- __m128 features[DENOISE_FEATURES];
+ float4 features[DENOISE_FEATURES];
const float *ccl_restrict pixel_buffer;
int2 pixel;
@@ -34,19 +34,19 @@ ccl_device void kernel_filter_construct_transform(const float *ccl_restrict buff
min(rect.w, y + radius + 1));
int num_pixels = (high.y - low.y) * (high.x - low.x);
- __m128 feature_means[DENOISE_FEATURES];
+ float4 feature_means[DENOISE_FEATURES];
math_vector_zero_sse(feature_means, DENOISE_FEATURES);
FOR_PIXEL_WINDOW_SSE {
filter_get_features_sse(x4, y4, active_pixels, pixel_buffer, features, NULL, pass_stride);
math_vector_add_sse(feature_means, DENOISE_FEATURES, features);
} END_FOR_PIXEL_WINDOW_SSE
- __m128 pixel_scale = _mm_set1_ps(1.0f / num_pixels);
+ float4 pixel_scale = make_float4(1.0f / num_pixels);
for(int i = 0; i < DENOISE_FEATURES; i++) {
- feature_means[i] = _mm_mul_ps(_mm_hsum_ps(feature_means[i]), pixel_scale);
+ feature_means[i] = reduce_add(feature_means[i]) * pixel_scale;
}
- __m128 feature_scale[DENOISE_FEATURES];
+ float4 feature_scale[DENOISE_FEATURES];
math_vector_zero_sse(feature_scale, DENOISE_FEATURES);
FOR_PIXEL_WINDOW_SSE {
filter_get_feature_scales_sse(x4, y4, active_pixels, pixel_buffer, features, feature_means, pass_stride);
@@ -55,12 +55,12 @@ ccl_device void kernel_filter_construct_transform(const float *ccl_restrict buff
filter_calculate_scale_sse(feature_scale);
- __m128 feature_matrix_sse[DENOISE_FEATURES*DENOISE_FEATURES];
+ float4 feature_matrix_sse[DENOISE_FEATURES*DENOISE_FEATURES];
math_matrix_zero_sse(feature_matrix_sse, DENOISE_FEATURES);
FOR_PIXEL_WINDOW_SSE {
filter_get_features_sse(x4, y4, active_pixels, pixel_buffer, features, feature_means, pass_stride);
math_vector_mul_sse(features, DENOISE_FEATURES, feature_scale);
- math_matrix_add_gramian_sse(feature_matrix_sse, DENOISE_FEATURES, features, _mm_set1_ps(1.0f));
+ math_matrix_add_gramian_sse(feature_matrix_sse, DENOISE_FEATURES, features, make_float4(1.0f));
} END_FOR_PIXEL_WINDOW_SSE
float feature_matrix[DENOISE_FEATURES*DENOISE_FEATURES];
@@ -98,7 +98,7 @@ ccl_device void kernel_filter_construct_transform(const float *ccl_restrict buff
/* Bake the feature scaling into the transformation matrix. */
for(int i = 0; i < DENOISE_FEATURES; i++) {
- math_vector_scale(transform + i*DENOISE_FEATURES, _mm_cvtss_f32(feature_scale[i]), *rank);
+ math_vector_scale(transform + i*DENOISE_FEATURES, feature_scale[i][0], *rank);
}
}
diff --git a/intern/cycles/kernel/geom/geom.h b/intern/cycles/kernel/geom/geom.h
index c623e3490fd..f34b77ebc07 100644
--- a/intern/cycles/kernel/geom/geom.h
+++ b/intern/cycles/kernel/geom/geom.h
@@ -27,6 +27,7 @@
#include "kernel/geom/geom_motion_triangle_shader.h"
#include "kernel/geom/geom_motion_curve.h"
#include "kernel/geom/geom_curve.h"
+#include "kernel/geom/geom_curve_intersect.h"
#include "kernel/geom/geom_volume.h"
#include "kernel/geom/geom_primitive.h"
diff --git a/intern/cycles/kernel/geom/geom_curve.h b/intern/cycles/kernel/geom/geom_curve.h
index 5c3b0ee3c15..e35267f02bf 100644
--- a/intern/cycles/kernel/geom/geom_curve.h
+++ b/intern/cycles/kernel/geom/geom_curve.h
@@ -16,18 +16,13 @@ CCL_NAMESPACE_BEGIN
/* Curve Primitive
*
- * Curve primitive for rendering hair and fur. These can be render as flat ribbons
- * or curves with actual thickness. The curve can also be rendered as line segments
- * rather than curves for better performance */
+ * Curve primitive for rendering hair and fur. These can be render as flat
+ * ribbons or curves with actual thickness. The curve can also be rendered as
+ * line segments rather than curves for better performance.
+ */
#ifdef __HAIR__
-#if defined(__KERNEL_CUDA__) && (__CUDA_ARCH__ < 300)
-# define ccl_device_curveintersect ccl_device
-#else
-# define ccl_device_curveintersect ccl_device_forceinline
-#endif
-
/* Reading attributes on various curve elements */
ccl_device float curve_attribute_float(KernelGlobals *kg, const ShaderData *sd, const AttributeDescriptor desc, float *dx, float *dy)
@@ -151,7 +146,7 @@ ccl_device float3 curve_motion_center_location(KernelGlobals *kg, ShaderData *sd
/* Curve tangent normal */
ccl_device float3 curve_tangent_normal(KernelGlobals *kg, ShaderData *sd)
-{
+{
float3 tgN = make_float3(0.0f,0.0f,0.0f);
if(sd->type & PRIMITIVE_ALL_CURVE) {
@@ -219,893 +214,6 @@ ccl_device_inline void curvebounds(float *lower, float *upper, float *extremta,
}
}
-#ifdef __KERNEL_SSE2__
-ccl_device_inline ssef transform_point_T3(const ssef t[3], const ssef &a)
-{
- return madd(shuffle<0>(a), t[0], madd(shuffle<1>(a), t[1], shuffle<2>(a) * t[2]));
-}
-#endif
-
-#ifdef __KERNEL_SSE2__
-/* Pass P and dir by reference to aligned vector */
-ccl_device_curveintersect bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersection *isect,
- const float3 &P, const float3 &dir, uint visibility, int object, int curveAddr, float time, int type, uint *lcg_state, float difl, float extmax)
-#else
-ccl_device_curveintersect bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersection *isect,
- float3 P, float3 dir, uint visibility, int object, int curveAddr, float time,int type, uint *lcg_state, float difl, float extmax)
-#endif
-{
- const bool is_curve_primitive = (type & PRIMITIVE_CURVE);
-
- if(!is_curve_primitive && kernel_data.bvh.use_bvh_steps) {
- const float2 prim_time = kernel_tex_fetch(__prim_time, curveAddr);
- if(time < prim_time.x || time > prim_time.y) {
- return false;
- }
- }
-
- int segment = PRIMITIVE_UNPACK_SEGMENT(type);
- float epsilon = 0.0f;
- float r_st, r_en;
-
- int depth = kernel_data.curve.subdivisions;
- int flags = kernel_data.curve.curveflags;
- int prim = kernel_tex_fetch(__prim_index, curveAddr);
-
-#ifdef __KERNEL_SSE2__
- ssef vdir = load4f(dir);
- ssef vcurve_coef[4];
- const float3 *curve_coef = (float3 *)vcurve_coef;
-
- {
- ssef dtmp = vdir * vdir;
- ssef d_ss = mm_sqrt(dtmp + shuffle<2>(dtmp));
- ssef rd_ss = load1f_first(1.0f) / d_ss;
-
- ssei v00vec = load4i((ssei *)&kg->__curves.data[prim]);
- int2 &v00 = (int2 &)v00vec;
-
- int k0 = v00.x + segment;
- int k1 = k0 + 1;
- int ka = max(k0 - 1, v00.x);
- int kb = min(k1 + 1, v00.x + v00.y - 1);
-
-#if defined(__KERNEL_AVX2__) && defined(__KERNEL_SSE__) && (!defined(_MSC_VER) || _MSC_VER > 1800)
- avxf P_curve_0_1, P_curve_2_3;
- if(is_curve_primitive) {
- P_curve_0_1 = _mm256_loadu2_m128(&kg->__curve_keys.data[k0].x, &kg->__curve_keys.data[ka].x);
- P_curve_2_3 = _mm256_loadu2_m128(&kg->__curve_keys.data[kb].x, &kg->__curve_keys.data[k1].x);
- }
- else {
- int fobject = (object == OBJECT_NONE) ? kernel_tex_fetch(__prim_object, curveAddr) : object;
- motion_cardinal_curve_keys_avx(kg, fobject, prim, time, ka, k0, k1, kb, &P_curve_0_1,&P_curve_2_3);
- }
-#else /* __KERNEL_AVX2__ */
- ssef P_curve[4];
-
- if(is_curve_primitive) {
- P_curve[0] = load4f(&kg->__curve_keys.data[ka].x);
- P_curve[1] = load4f(&kg->__curve_keys.data[k0].x);
- P_curve[2] = load4f(&kg->__curve_keys.data[k1].x);
- P_curve[3] = load4f(&kg->__curve_keys.data[kb].x);
- }
- else {
- int fobject = (object == OBJECT_NONE)? kernel_tex_fetch(__prim_object, curveAddr): object;
- motion_cardinal_curve_keys(kg, fobject, prim, time, ka, k0, k1, kb, (float4*)&P_curve);
- }
-#endif /* __KERNEL_AVX2__ */
-
- ssef rd_sgn = set_sign_bit<0, 1, 1, 1>(shuffle<0>(rd_ss));
- ssef mul_zxxy = shuffle<2, 0, 0, 1>(vdir) * rd_sgn;
- ssef mul_yz = shuffle<1, 2, 1, 2>(vdir) * mul_zxxy;
- ssef mul_shuf = shuffle<0, 1, 2, 3>(mul_zxxy, mul_yz);
- ssef vdir0 = vdir & cast(ssei(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0));
-
- ssef htfm0 = shuffle<0, 2, 0, 3>(mul_shuf, vdir0);
- ssef htfm1 = shuffle<1, 0, 1, 3>(load1f_first(extract<0>(d_ss)), vdir0);
- ssef htfm2 = shuffle<1, 3, 2, 3>(mul_shuf, vdir0);
-
-#if defined(__KERNEL_AVX2__) && defined(__KERNEL_SSE__) && (!defined(_MSC_VER) || _MSC_VER > 1800)
- const avxf vPP = _mm256_broadcast_ps(&P.m128);
- const avxf htfm00 = avxf(htfm0.m128, htfm0.m128);
- const avxf htfm11 = avxf(htfm1.m128, htfm1.m128);
- const avxf htfm22 = avxf(htfm2.m128, htfm2.m128);
-
- const avxf p01 = madd(shuffle<0>(P_curve_0_1 - vPP),
- htfm00,
- madd(shuffle<1>(P_curve_0_1 - vPP),
- htfm11,
- shuffle<2>(P_curve_0_1 - vPP) * htfm22));
- const avxf p23 = madd(shuffle<0>(P_curve_2_3 - vPP),
- htfm00,
- madd(shuffle<1>(P_curve_2_3 - vPP),
- htfm11,
- shuffle<2>(P_curve_2_3 - vPP)*htfm22));
-
- const ssef p0 = _mm256_castps256_ps128(p01);
- const ssef p1 = _mm256_extractf128_ps(p01, 1);
- const ssef p2 = _mm256_castps256_ps128(p23);
- const ssef p3 = _mm256_extractf128_ps(p23, 1);
-
- const ssef P_curve_1 = _mm256_extractf128_ps(P_curve_0_1, 1);
- r_st = ((float4 &)P_curve_1).w;
- const ssef P_curve_2 = _mm256_castps256_ps128(P_curve_2_3);
- r_en = ((float4 &)P_curve_2).w;
-#else /* __KERNEL_AVX2__ */
- ssef htfm[] = { htfm0, htfm1, htfm2 };
- ssef vP = load4f(P);
- ssef p0 = transform_point_T3(htfm, P_curve[0] - vP);
- ssef p1 = transform_point_T3(htfm, P_curve[1] - vP);
- ssef p2 = transform_point_T3(htfm, P_curve[2] - vP);
- ssef p3 = transform_point_T3(htfm, P_curve[3] - vP);
-
- r_st = ((float4 &)P_curve[1]).w;
- r_en = ((float4 &)P_curve[2]).w;
-#endif /* __KERNEL_AVX2__ */
-
- float fc = 0.71f;
- ssef vfc = ssef(fc);
- ssef vfcxp3 = vfc * p3;
-
- vcurve_coef[0] = p1;
- vcurve_coef[1] = vfc * (p2 - p0);
- vcurve_coef[2] = madd(ssef(fc * 2.0f), p0, madd(ssef(fc - 3.0f), p1, msub(ssef(3.0f - 2.0f * fc), p2, vfcxp3)));
- vcurve_coef[3] = msub(ssef(fc - 2.0f), p2 - p1, msub(vfc, p0, vfcxp3));
-
- }
-#else
- float3 curve_coef[4];
-
- /* curve Intersection check */
- /* obtain curve parameters */
- {
- /* ray transform created - this should be created at beginning of intersection loop */
- Transform htfm;
- float d = sqrtf(dir.x * dir.x + dir.z * dir.z);
- htfm = make_transform(
- dir.z / d, 0, -dir.x /d, 0,
- -dir.x * dir.y /d, d, -dir.y * dir.z /d, 0,
- dir.x, dir.y, dir.z, 0,
- 0, 0, 0, 1);
-
- float4 v00 = kernel_tex_fetch(__curves, prim);
-
- int k0 = __float_as_int(v00.x) + segment;
- int k1 = k0 + 1;
-
- int ka = max(k0 - 1,__float_as_int(v00.x));
- int kb = min(k1 + 1,__float_as_int(v00.x) + __float_as_int(v00.y) - 1);
-
- float4 P_curve[4];
-
- if(is_curve_primitive) {
- P_curve[0] = kernel_tex_fetch(__curve_keys, ka);
- P_curve[1] = kernel_tex_fetch(__curve_keys, k0);
- P_curve[2] = kernel_tex_fetch(__curve_keys, k1);
- P_curve[3] = kernel_tex_fetch(__curve_keys, kb);
- }
- else {
- int fobject = (object == OBJECT_NONE)? kernel_tex_fetch(__prim_object, curveAddr): object;
- motion_cardinal_curve_keys(kg, fobject, prim, time, ka, k0, k1, kb, P_curve);
- }
-
- float3 p0 = transform_point(&htfm, float4_to_float3(P_curve[0]) - P);
- float3 p1 = transform_point(&htfm, float4_to_float3(P_curve[1]) - P);
- float3 p2 = transform_point(&htfm, float4_to_float3(P_curve[2]) - P);
- float3 p3 = transform_point(&htfm, float4_to_float3(P_curve[3]) - P);
-
- float fc = 0.71f;
- curve_coef[0] = p1;
- curve_coef[1] = -fc*p0 + fc*p2;
- curve_coef[2] = 2.0f * fc * p0 + (fc - 3.0f) * p1 + (3.0f - 2.0f * fc) * p2 - fc * p3;
- curve_coef[3] = -fc * p0 + (2.0f - fc) * p1 + (fc - 2.0f) * p2 + fc * p3;
- r_st = P_curve[1].w;
- r_en = P_curve[2].w;
- }
-#endif
-
- float r_curr = max(r_st, r_en);
-
- if((flags & CURVE_KN_RIBBONS) || !(flags & CURVE_KN_BACKFACING))
- epsilon = 2 * r_curr;
-
- /* find bounds - this is slow for cubic curves */
- float upper, lower;
-
- float zextrem[4];
- curvebounds(&lower, &upper, &zextrem[0], &zextrem[1], &zextrem[2], &zextrem[3], curve_coef[0].z, curve_coef[1].z, curve_coef[2].z, curve_coef[3].z);
- if(lower - r_curr > isect->t || upper + r_curr < epsilon)
- return false;
-
- /* minimum width extension */
- float mw_extension = min(difl * fabsf(upper), extmax);
- float r_ext = mw_extension + r_curr;
-
- float xextrem[4];
- curvebounds(&lower, &upper, &xextrem[0], &xextrem[1], &xextrem[2], &xextrem[3], curve_coef[0].x, curve_coef[1].x, curve_coef[2].x, curve_coef[3].x);
- if(lower > r_ext || upper < -r_ext)
- return false;
-
- float yextrem[4];
- curvebounds(&lower, &upper, &yextrem[0], &yextrem[1], &yextrem[2], &yextrem[3], curve_coef[0].y, curve_coef[1].y, curve_coef[2].y, curve_coef[3].y);
- if(lower > r_ext || upper < -r_ext)
- return false;
-
- /* setup recurrent loop */
- int level = 1 << depth;
- int tree = 0;
- float resol = 1.0f / (float)level;
- bool hit = false;
-
- /* begin loop */
- while(!(tree >> (depth))) {
- const float i_st = tree * resol;
- const float i_en = i_st + (level * resol);
-
-#ifdef __KERNEL_SSE2__
- ssef vi_st = ssef(i_st), vi_en = ssef(i_en);
- ssef vp_st = madd(madd(madd(vcurve_coef[3], vi_st, vcurve_coef[2]), vi_st, vcurve_coef[1]), vi_st, vcurve_coef[0]);
- ssef vp_en = madd(madd(madd(vcurve_coef[3], vi_en, vcurve_coef[2]), vi_en, vcurve_coef[1]), vi_en, vcurve_coef[0]);
-
- ssef vbmin = min(vp_st, vp_en);
- ssef vbmax = max(vp_st, vp_en);
-
- float3 &bmin = (float3 &)vbmin, &bmax = (float3 &)vbmax;
- float &bminx = bmin.x, &bminy = bmin.y, &bminz = bmin.z;
- float &bmaxx = bmax.x, &bmaxy = bmax.y, &bmaxz = bmax.z;
- float3 &p_st = (float3 &)vp_st, &p_en = (float3 &)vp_en;
-#else
- float3 p_st = ((curve_coef[3] * i_st + curve_coef[2]) * i_st + curve_coef[1]) * i_st + curve_coef[0];
- float3 p_en = ((curve_coef[3] * i_en + curve_coef[2]) * i_en + curve_coef[1]) * i_en + curve_coef[0];
-
- float bminx = min(p_st.x, p_en.x);
- float bmaxx = max(p_st.x, p_en.x);
- float bminy = min(p_st.y, p_en.y);
- float bmaxy = max(p_st.y, p_en.y);
- float bminz = min(p_st.z, p_en.z);
- float bmaxz = max(p_st.z, p_en.z);
-#endif
-
- if(xextrem[0] >= i_st && xextrem[0] <= i_en) {
- bminx = min(bminx,xextrem[1]);
- bmaxx = max(bmaxx,xextrem[1]);
- }
- if(xextrem[2] >= i_st && xextrem[2] <= i_en) {
- bminx = min(bminx,xextrem[3]);
- bmaxx = max(bmaxx,xextrem[3]);
- }
- if(yextrem[0] >= i_st && yextrem[0] <= i_en) {
- bminy = min(bminy,yextrem[1]);
- bmaxy = max(bmaxy,yextrem[1]);
- }
- if(yextrem[2] >= i_st && yextrem[2] <= i_en) {
- bminy = min(bminy,yextrem[3]);
- bmaxy = max(bmaxy,yextrem[3]);
- }
- if(zextrem[0] >= i_st && zextrem[0] <= i_en) {
- bminz = min(bminz,zextrem[1]);
- bmaxz = max(bmaxz,zextrem[1]);
- }
- if(zextrem[2] >= i_st && zextrem[2] <= i_en) {
- bminz = min(bminz,zextrem[3]);
- bmaxz = max(bmaxz,zextrem[3]);
- }
-
- float r1 = r_st + (r_en - r_st) * i_st;
- float r2 = r_st + (r_en - r_st) * i_en;
- r_curr = max(r1, r2);
-
- mw_extension = min(difl * fabsf(bmaxz), extmax);
- float r_ext = mw_extension + r_curr;
- float coverage = 1.0f;
-
- if(bminz - r_curr > isect->t || bmaxz + r_curr < epsilon || bminx > r_ext|| bmaxx < -r_ext|| bminy > r_ext|| bmaxy < -r_ext) {
- /* the bounding box does not overlap the square centered at O */
- tree += level;
- level = tree & -tree;
- }
- else if(level == 1) {
-
- /* the maximum recursion depth is reached.
- * check if dP0.(Q-P0)>=0 and dPn.(Pn-Q)>=0.
- * dP* is reversed if necessary.*/
- float t = isect->t;
- float u = 0.0f;
- float gd = 0.0f;
-
- if(flags & CURVE_KN_RIBBONS) {
- float3 tg = (p_en - p_st);
-#ifdef __KERNEL_SSE__
- const float3 tg_sq = tg * tg;
- float w = tg_sq.x + tg_sq.y;
-#else
- float w = tg.x * tg.x + tg.y * tg.y;
-#endif
- if(w == 0) {
- tree++;
- level = tree & -tree;
- continue;
- }
-#ifdef __KERNEL_SSE__
- const float3 p_sttg = p_st * tg;
- w = -(p_sttg.x + p_sttg.y) / w;
-#else
- w = -(p_st.x * tg.x + p_st.y * tg.y) / w;
-#endif
- w = saturate(w);
-
- /* compute u on the curve segment */
- u = i_st * (1 - w) + i_en * w;
- r_curr = r_st + (r_en - r_st) * u;
- /* compare x-y distances */
- float3 p_curr = ((curve_coef[3] * u + curve_coef[2]) * u + curve_coef[1]) * u + curve_coef[0];
-
- float3 dp_st = (3 * curve_coef[3] * i_st + 2 * curve_coef[2]) * i_st + curve_coef[1];
- if(dot(tg, dp_st)< 0)
- dp_st *= -1;
- if(dot(dp_st, -p_st) + p_curr.z * dp_st.z < 0) {
- tree++;
- level = tree & -tree;
- continue;
- }
- float3 dp_en = (3 * curve_coef[3] * i_en + 2 * curve_coef[2]) * i_en + curve_coef[1];
- if(dot(tg, dp_en) < 0)
- dp_en *= -1;
- if(dot(dp_en, p_en) - p_curr.z * dp_en.z < 0) {
- tree++;
- level = tree & -tree;
- continue;
- }
-
- /* compute coverage */
- float r_ext = r_curr;
- coverage = 1.0f;
- if(difl != 0.0f) {
- mw_extension = min(difl * fabsf(bmaxz), extmax);
- r_ext = mw_extension + r_curr;
-#ifdef __KERNEL_SSE__
- const float3 p_curr_sq = p_curr * p_curr;
- const float3 dxxx(_mm_sqrt_ss(_mm_hadd_ps(p_curr_sq.m128, p_curr_sq.m128)));
- float d = dxxx.x;
-#else
- float d = sqrtf(p_curr.x * p_curr.x + p_curr.y * p_curr.y);
-#endif
- float d0 = d - r_curr;
- float d1 = d + r_curr;
- float inv_mw_extension = 1.0f/mw_extension;
- if(d0 >= 0)
- coverage = (min(d1 * inv_mw_extension, 1.0f) - min(d0 * inv_mw_extension, 1.0f)) * 0.5f;
- else // inside
- coverage = (min(d1 * inv_mw_extension, 1.0f) + min(-d0 * inv_mw_extension, 1.0f)) * 0.5f;
- }
-
- if(p_curr.x * p_curr.x + p_curr.y * p_curr.y >= r_ext * r_ext || p_curr.z <= epsilon || isect->t < p_curr.z) {
- tree++;
- level = tree & -tree;
- continue;
- }
-
- t = p_curr.z;
-
- /* stochastic fade from minimum width */
- if(difl != 0.0f && lcg_state) {
- if(coverage != 1.0f && (lcg_step_float(lcg_state) > coverage))
- return hit;
- }
- }
- else {
- float l = len(p_en - p_st);
- /* minimum width extension */
- float or1 = r1;
- float or2 = r2;
-
- if(difl != 0.0f) {
- mw_extension = min(len(p_st - P) * difl, extmax);
- or1 = r1 < mw_extension ? mw_extension : r1;
- mw_extension = min(len(p_en - P) * difl, extmax);
- or2 = r2 < mw_extension ? mw_extension : r2;
- }
- /* --- */
- float invl = 1.0f/l;
- float3 tg = (p_en - p_st) * invl;
- gd = (or2 - or1) * invl;
- float difz = -dot(p_st,tg);
- float cyla = 1.0f - (tg.z * tg.z * (1 + gd*gd));
- float invcyla = 1.0f/cyla;
- float halfb = (-p_st.z - tg.z*(difz + gd*(difz*gd + or1)));
- float tcentre = -halfb*invcyla;
- float zcentre = difz + (tg.z * tcentre);
- float3 tdif = - p_st;
- tdif.z += tcentre;
- float tdifz = dot(tdif,tg);
- float tb = 2*(tdif.z - tg.z*(tdifz + gd*(tdifz*gd + or1)));
- float tc = dot(tdif,tdif) - tdifz * tdifz * (1 + gd*gd) - or1*or1 - 2*or1*tdifz*gd;
- float td = tb*tb - 4*cyla*tc;
- if(td < 0.0f) {
- tree++;
- level = tree & -tree;
- continue;
- }
-
- float rootd = sqrtf(td);
- float correction = (-tb - rootd) * 0.5f * invcyla;
- t = tcentre + correction;
-
- float3 dp_st = (3 * curve_coef[3] * i_st + 2 * curve_coef[2]) * i_st + curve_coef[1];
- if(dot(tg, dp_st)< 0)
- dp_st *= -1;
- float3 dp_en = (3 * curve_coef[3] * i_en + 2 * curve_coef[2]) * i_en + curve_coef[1];
- if(dot(tg, dp_en) < 0)
- dp_en *= -1;
-
- if(flags & CURVE_KN_BACKFACING && (dot(dp_st, -p_st) + t * dp_st.z < 0 || dot(dp_en, p_en) - t * dp_en.z < 0 || isect->t < t || t <= 0.0f)) {
- correction = (-tb + rootd) * 0.5f * invcyla;
- t = tcentre + correction;
- }
-
- if(dot(dp_st, -p_st) + t * dp_st.z < 0 || dot(dp_en, p_en) - t * dp_en.z < 0 || isect->t < t || t <= 0.0f) {
- tree++;
- level = tree & -tree;
- continue;
- }
-
- float w = (zcentre + (tg.z * correction)) * invl;
- w = saturate(w);
- /* compute u on the curve segment */
- u = i_st * (1 - w) + i_en * w;
-
- /* stochastic fade from minimum width */
- if(difl != 0.0f && lcg_state) {
- r_curr = r1 + (r2 - r1) * w;
- r_ext = or1 + (or2 - or1) * w;
- coverage = r_curr/r_ext;
-
- if(coverage != 1.0f && (lcg_step_float(lcg_state) > coverage))
- return hit;
- }
- }
- /* we found a new intersection */
-
-#ifdef __VISIBILITY_FLAG__
- /* visibility flag test. we do it here under the assumption
- * that most triangles are culled by node flags */
- if(kernel_tex_fetch(__prim_visibility, curveAddr) & visibility)
-#endif
- {
- /* record intersection */
- isect->t = t;
- isect->u = u;
- isect->v = gd;
- isect->prim = curveAddr;
- isect->object = object;
- isect->type = type;
- hit = true;
- }
-
- tree++;
- level = tree & -tree;
- }
- else {
- /* split the curve into two curves and process */
- level = level >> 1;
- }
- }
-
- return hit;
-}
-
-ccl_device_curveintersect bool bvh_curve_intersect(KernelGlobals *kg, Intersection *isect,
- float3 P, float3 direction, uint visibility, int object, int curveAddr, float time, int type, uint *lcg_state, float difl, float extmax)
-{
- /* define few macros to minimize code duplication for SSE */
-#ifndef __KERNEL_SSE2__
-# define len3_squared(x) len_squared(x)
-# define len3(x) len(x)
-# define dot3(x, y) dot(x, y)
-#endif
-
- const bool is_curve_primitive = (type & PRIMITIVE_CURVE);
-
- if(!is_curve_primitive && kernel_data.bvh.use_bvh_steps) {
- const float2 prim_time = kernel_tex_fetch(__prim_time, curveAddr);
- if(time < prim_time.x || time > prim_time.y) {
- return false;
- }
- }
-
- int segment = PRIMITIVE_UNPACK_SEGMENT(type);
- /* curve Intersection check */
- int flags = kernel_data.curve.curveflags;
-
- int prim = kernel_tex_fetch(__prim_index, curveAddr);
- float4 v00 = kernel_tex_fetch(__curves, prim);
-
- int cnum = __float_as_int(v00.x);
- int k0 = cnum + segment;
- int k1 = k0 + 1;
-
-#ifndef __KERNEL_SSE2__
- float4 P_curve[2];
-
- if(is_curve_primitive) {
- P_curve[0] = kernel_tex_fetch(__curve_keys, k0);
- P_curve[1] = kernel_tex_fetch(__curve_keys, k1);
- }
- else {
- int fobject = (object == OBJECT_NONE)? kernel_tex_fetch(__prim_object, curveAddr): object;
- motion_curve_keys(kg, fobject, prim, time, k0, k1, P_curve);
- }
-
- float or1 = P_curve[0].w;
- float or2 = P_curve[1].w;
- float3 p1 = float4_to_float3(P_curve[0]);
- float3 p2 = float4_to_float3(P_curve[1]);
-
- /* minimum width extension */
- float r1 = or1;
- float r2 = or2;
- float3 dif = P - p1;
- float3 dif_second = P - p2;
- if(difl != 0.0f) {
- float pixelsize = min(len3(dif) * difl, extmax);
- r1 = or1 < pixelsize ? pixelsize : or1;
- pixelsize = min(len3(dif_second) * difl, extmax);
- r2 = or2 < pixelsize ? pixelsize : or2;
- }
- /* --- */
-
- float3 p21_diff = p2 - p1;
- float3 sphere_dif1 = (dif + dif_second) * 0.5f;
- float3 dir = direction;
- float sphere_b_tmp = dot3(dir, sphere_dif1);
- float3 sphere_dif2 = sphere_dif1 - sphere_b_tmp * dir;
-#else
- ssef P_curve[2];
-
- if(is_curve_primitive) {
- P_curve[0] = load4f(&kg->__curve_keys.data[k0].x);
- P_curve[1] = load4f(&kg->__curve_keys.data[k1].x);
- }
- else {
- int fobject = (object == OBJECT_NONE)? kernel_tex_fetch(__prim_object, curveAddr): object;
- motion_curve_keys(kg, fobject, prim, time, k0, k1, (float4*)&P_curve);
- }
-
- const ssef or12 = shuffle<3, 3, 3, 3>(P_curve[0], P_curve[1]);
-
- ssef r12 = or12;
- const ssef vP = load4f(P);
- const ssef dif = vP - P_curve[0];
- const ssef dif_second = vP - P_curve[1];
- if(difl != 0.0f) {
- const ssef len1_sq = len3_squared_splat(dif);
- const ssef len2_sq = len3_squared_splat(dif_second);
- const ssef len12 = mm_sqrt(shuffle<0, 0, 0, 0>(len1_sq, len2_sq));
- const ssef pixelsize12 = min(len12 * difl, ssef(extmax));
- r12 = max(or12, pixelsize12);
- }
- float or1 = extract<0>(or12), or2 = extract<0>(shuffle<2>(or12));
- float r1 = extract<0>(r12), r2 = extract<0>(shuffle<2>(r12));
-
- const ssef p21_diff = P_curve[1] - P_curve[0];
- const ssef sphere_dif1 = (dif + dif_second) * 0.5f;
- const ssef dir = load4f(direction);
- const ssef sphere_b_tmp = dot3_splat(dir, sphere_dif1);
- const ssef sphere_dif2 = nmadd(sphere_b_tmp, dir, sphere_dif1);
-#endif
-
- float mr = max(r1, r2);
- float l = len3(p21_diff);
- float invl = 1.0f / l;
- float sp_r = mr + 0.5f * l;
-
- float sphere_b = dot3(dir, sphere_dif2);
- float sdisc = sphere_b * sphere_b - len3_squared(sphere_dif2) + sp_r * sp_r;
-
- if(sdisc < 0.0f)
- return false;
-
- /* obtain parameters and test midpoint distance for suitable modes */
-#ifndef __KERNEL_SSE2__
- float3 tg = p21_diff * invl;
-#else
- const ssef tg = p21_diff * invl;
-#endif
- float gd = (r2 - r1) * invl;
-
- float dirz = dot3(dir, tg);
- float difz = dot3(dif, tg);
-
- float a = 1.0f - (dirz*dirz*(1 + gd*gd));
-
- float halfb = dot3(dir, dif) - dirz*(difz + gd*(difz*gd + r1));
-
- float tcentre = -halfb/a;
- float zcentre = difz + (dirz * tcentre);
-
- if((tcentre > isect->t) && !(flags & CURVE_KN_ACCURATE))
- return false;
- if((zcentre < 0 || zcentre > l) && !(flags & CURVE_KN_ACCURATE) && !(flags & CURVE_KN_INTERSECTCORRECTION))
- return false;
-
- /* test minimum separation */
-#ifndef __KERNEL_SSE2__
- float3 cprod = cross(tg, dir);
- float cprod2sq = len3_squared(cross(tg, dif));
-#else
- const ssef cprod = cross(tg, dir);
- float cprod2sq = len3_squared(cross_zxy(tg, dif));
-#endif
- float cprodsq = len3_squared(cprod);
- float distscaled = dot3(cprod, dif);
-
- if(cprodsq == 0)
- distscaled = cprod2sq;
- else
- distscaled = (distscaled*distscaled)/cprodsq;
-
- if(distscaled > mr*mr)
- return false;
-
- /* calculate true intersection */
-#ifndef __KERNEL_SSE2__
- float3 tdif = dif + tcentre * dir;
-#else
- const ssef tdif = madd(ssef(tcentre), dir, dif);
-#endif
- float tdifz = dot3(tdif, tg);
- float tdifma = tdifz*gd + r1;
- float tb = 2*(dot3(dir, tdif) - dirz*(tdifz + gd*tdifma));
- float tc = dot3(tdif, tdif) - tdifz*tdifz - tdifma*tdifma;
- float td = tb*tb - 4*a*tc;
-
- if(td < 0.0f)
- return false;
-
- float rootd = 0.0f;
- float correction = 0.0f;
- if(flags & CURVE_KN_ACCURATE) {
- rootd = sqrtf(td);
- correction = ((-tb - rootd)/(2*a));
- }
-
- float t = tcentre + correction;
-
- if(t < isect->t) {
-
- if(flags & CURVE_KN_INTERSECTCORRECTION) {
- rootd = sqrtf(td);
- correction = ((-tb - rootd)/(2*a));
- t = tcentre + correction;
- }
-
- float z = zcentre + (dirz * correction);
- // bool backface = false;
-
- if(flags & CURVE_KN_BACKFACING && (t < 0.0f || z < 0 || z > l)) {
- // backface = true;
- correction = ((-tb + rootd)/(2*a));
- t = tcentre + correction;
- z = zcentre + (dirz * correction);
- }
-
- /* stochastic fade from minimum width */
- float adjradius = or1 + z * (or2 - or1) * invl;
- adjradius = adjradius / (r1 + z * gd);
- if(lcg_state && adjradius != 1.0f) {
- if(lcg_step_float(lcg_state) > adjradius)
- return false;
- }
- /* --- */
-
- if(t > 0.0f && t < isect->t && z >= 0 && z <= l) {
-
- if(flags & CURVE_KN_ENCLOSEFILTER) {
- float enc_ratio = 1.01f;
- if((difz > -r1 * enc_ratio) && (dot3(dif_second, tg) < r2 * enc_ratio)) {
- float a2 = 1.0f - (dirz*dirz*(1 + gd*gd*enc_ratio*enc_ratio));
- float c2 = dot3(dif, dif) - difz * difz * (1 + gd*gd*enc_ratio*enc_ratio) - r1*r1*enc_ratio*enc_ratio - 2*r1*difz*gd*enc_ratio;
- if(a2*c2 < 0.0f)
- return false;
- }
- }
-
-#ifdef __VISIBILITY_FLAG__
- /* visibility flag test. we do it here under the assumption
- * that most triangles are culled by node flags */
- if(kernel_tex_fetch(__prim_visibility, curveAddr) & visibility)
-#endif
- {
- /* record intersection */
- isect->t = t;
- isect->u = z*invl;
- isect->v = gd;
- isect->prim = curveAddr;
- isect->object = object;
- isect->type = type;
-
- return true;
- }
- }
- }
-
- return false;
-
-#ifndef __KERNEL_SSE2__
-# undef len3_squared
-# undef len3
-# undef dot3
-#endif
-}
-
-ccl_device_inline float3 curvetangent(float t, float3 p0, float3 p1, float3 p2, float3 p3)
-{
- float fc = 0.71f;
- float data[4];
- float t2 = t * t;
- data[0] = -3.0f * fc * t2 + 4.0f * fc * t - fc;
- data[1] = 3.0f * (2.0f - fc) * t2 + 2.0f * (fc - 3.0f) * t;
- data[2] = 3.0f * (fc - 2.0f) * t2 + 2.0f * (3.0f - 2.0f * fc) * t + fc;
- data[3] = 3.0f * fc * t2 - 2.0f * fc * t;
- return data[0] * p0 + data[1] * p1 + data[2] * p2 + data[3] * p3;
-}
-
-ccl_device_inline float3 curvepoint(float t, float3 p0, float3 p1, float3 p2, float3 p3)
-{
- float data[4];
- float fc = 0.71f;
- float t2 = t * t;
- float t3 = t2 * t;
- data[0] = -fc * t3 + 2.0f * fc * t2 - fc * t;
- data[1] = (2.0f - fc) * t3 + (fc - 3.0f) * t2 + 1.0f;
- data[2] = (fc - 2.0f) * t3 + (3.0f - 2.0f * fc) * t2 + fc * t;
- data[3] = fc * t3 - fc * t2;
- return data[0] * p0 + data[1] * p1 + data[2] * p2 + data[3] * p3;
-}
-
-ccl_device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, const Intersection *isect, const Ray *ray)
-{
- int flag = kernel_data.curve.curveflags;
- float t = isect->t;
- float3 P = ray->P;
- float3 D = ray->D;
-
- if(isect->object != OBJECT_NONE) {
-#ifdef __OBJECT_MOTION__
- Transform tfm = sd->ob_itfm;
-#else
- Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_INVERSE_TRANSFORM);
-#endif
-
- P = transform_point(&tfm, P);
- D = transform_direction(&tfm, D*t);
- D = normalize_len(D, &t);
- }
-
- int prim = kernel_tex_fetch(__prim_index, isect->prim);
- float4 v00 = kernel_tex_fetch(__curves, prim);
-
- int k0 = __float_as_int(v00.x) + PRIMITIVE_UNPACK_SEGMENT(sd->type);
- int k1 = k0 + 1;
-
- float3 tg;
-
- if(flag & CURVE_KN_INTERPOLATE) {
- int ka = max(k0 - 1,__float_as_int(v00.x));
- int kb = min(k1 + 1,__float_as_int(v00.x) + __float_as_int(v00.y) - 1);
-
- float4 P_curve[4];
-
- if(sd->type & PRIMITIVE_CURVE) {
- P_curve[0] = kernel_tex_fetch(__curve_keys, ka);
- P_curve[1] = kernel_tex_fetch(__curve_keys, k0);
- P_curve[2] = kernel_tex_fetch(__curve_keys, k1);
- P_curve[3] = kernel_tex_fetch(__curve_keys, kb);
- }
- else {
- motion_cardinal_curve_keys(kg, sd->object, sd->prim, sd->time, ka, k0, k1, kb, P_curve);
- }
-
- float3 p[4];
- p[0] = float4_to_float3(P_curve[0]);
- p[1] = float4_to_float3(P_curve[1]);
- p[2] = float4_to_float3(P_curve[2]);
- p[3] = float4_to_float3(P_curve[3]);
-
- P = P + D*t;
-
-#ifdef __UV__
- sd->u = isect->u;
- sd->v = 0.0f;
-#endif
-
- tg = normalize(curvetangent(isect->u, p[0], p[1], p[2], p[3]));
-
- if(kernel_data.curve.curveflags & CURVE_KN_RIBBONS) {
- sd->Ng = normalize(-(D - tg * (dot(tg, D))));
- }
- else {
- /* direction from inside to surface of curve */
- float3 p_curr = curvepoint(isect->u, p[0], p[1], p[2], p[3]);
- sd->Ng = normalize(P - p_curr);
-
- /* adjustment for changing radius */
- float gd = isect->v;
-
- if(gd != 0.0f) {
- sd->Ng = sd->Ng - gd * tg;
- sd->Ng = normalize(sd->Ng);
- }
- }
-
- /* todo: sometimes the normal is still so that this is detected as
- * backfacing even if cull backfaces is enabled */
-
- sd->N = sd->Ng;
- }
- else {
- float4 P_curve[2];
-
- if(sd->type & PRIMITIVE_CURVE) {
- P_curve[0]= kernel_tex_fetch(__curve_keys, k0);
- P_curve[1]= kernel_tex_fetch(__curve_keys, k1);
- }
- else {
- motion_curve_keys(kg, sd->object, sd->prim, sd->time, k0, k1, P_curve);
- }
-
- float l = 1.0f;
- tg = normalize_len(float4_to_float3(P_curve[1] - P_curve[0]), &l);
-
- P = P + D*t;
-
- float3 dif = P - float4_to_float3(P_curve[0]);
-
-#ifdef __UV__
- sd->u = dot(dif,tg)/l;
- sd->v = 0.0f;
-#endif
-
- if(flag & CURVE_KN_TRUETANGENTGNORMAL) {
- sd->Ng = -(D - tg * dot(tg, D));
- sd->Ng = normalize(sd->Ng);
- }
- else {
- float gd = isect->v;
-
- /* direction from inside to surface of curve */
- sd->Ng = (dif - tg * sd->u * l) / (P_curve[0].w + sd->u * l * gd);
-
- /* adjustment for changing radius */
- if(gd != 0.0f) {
- sd->Ng = sd->Ng - gd * tg;
- sd->Ng = normalize(sd->Ng);
- }
- }
-
- sd->N = sd->Ng;
- }
-
-#ifdef __DPDU__
- /* dPdu/dPdv */
- sd->dPdu = tg;
- sd->dPdv = cross(tg, sd->Ng);
-#endif
-
- if(isect->object != OBJECT_NONE) {
-#ifdef __OBJECT_MOTION__
- Transform tfm = sd->ob_tfm;
-#else
- Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_TRANSFORM);
-#endif
-
- P = transform_point(&tfm, P);
- }
-
- return P;
-}
-
-#endif
+#endif /* __HAIR__ */
CCL_NAMESPACE_END
-
diff --git a/intern/cycles/kernel/geom/geom_curve_intersect.h b/intern/cycles/kernel/geom/geom_curve_intersect.h
new file mode 100644
index 00000000000..e9a149ea1ab
--- /dev/null
+++ b/intern/cycles/kernel/geom/geom_curve_intersect.h
@@ -0,0 +1,934 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+CCL_NAMESPACE_BEGIN
+
+/* Curve primitive intersection functions. */
+
+#ifdef __HAIR__
+
+#if defined(__KERNEL_CUDA__) && (__CUDA_ARCH__ < 300)
+# define ccl_device_curveintersect ccl_device
+#else
+# define ccl_device_curveintersect ccl_device_forceinline
+#endif
+
+#ifdef __KERNEL_SSE2__
+ccl_device_inline ssef transform_point_T3(const ssef t[3], const ssef &a)
+{
+ return madd(shuffle<0>(a), t[0], madd(shuffle<1>(a), t[1], shuffle<2>(a) * t[2]));
+}
+#endif
+
+/* On CPU pass P and dir by reference to aligned vector. */
+ccl_device_curveintersect bool cardinal_curve_intersect(
+ KernelGlobals *kg,
+ Intersection *isect,
+ const float3 ccl_ref P,
+ const float3 ccl_ref dir,
+ uint visibility,
+ int object,
+ int curveAddr,
+ float time,
+ int type,
+ uint *lcg_state,
+ float difl,
+ float extmax)
+{
+ const bool is_curve_primitive = (type & PRIMITIVE_CURVE);
+
+ if(!is_curve_primitive && kernel_data.bvh.use_bvh_steps) {
+ const float2 prim_time = kernel_tex_fetch(__prim_time, curveAddr);
+ if(time < prim_time.x || time > prim_time.y) {
+ return false;
+ }
+ }
+
+ int segment = PRIMITIVE_UNPACK_SEGMENT(type);
+ float epsilon = 0.0f;
+ float r_st, r_en;
+
+ int depth = kernel_data.curve.subdivisions;
+ int flags = kernel_data.curve.curveflags;
+ int prim = kernel_tex_fetch(__prim_index, curveAddr);
+
+#ifdef __KERNEL_SSE2__
+ ssef vdir = load4f(dir);
+ ssef vcurve_coef[4];
+ const float3 *curve_coef = (float3 *)vcurve_coef;
+
+ {
+ ssef dtmp = vdir * vdir;
+ ssef d_ss = mm_sqrt(dtmp + shuffle<2>(dtmp));
+ ssef rd_ss = load1f_first(1.0f) / d_ss;
+
+ ssei v00vec = load4i((ssei *)&kg->__curves.data[prim]);
+ int2 &v00 = (int2 &)v00vec;
+
+ int k0 = v00.x + segment;
+ int k1 = k0 + 1;
+ int ka = max(k0 - 1, v00.x);
+ int kb = min(k1 + 1, v00.x + v00.y - 1);
+
+#if defined(__KERNEL_AVX2__) && defined(__KERNEL_SSE__) && (!defined(_MSC_VER) || _MSC_VER > 1800)
+ avxf P_curve_0_1, P_curve_2_3;
+ if(is_curve_primitive) {
+ P_curve_0_1 = _mm256_loadu2_m128(&kg->__curve_keys.data[k0].x, &kg->__curve_keys.data[ka].x);
+ P_curve_2_3 = _mm256_loadu2_m128(&kg->__curve_keys.data[kb].x, &kg->__curve_keys.data[k1].x);
+ }
+ else {
+ int fobject = (object == OBJECT_NONE) ? kernel_tex_fetch(__prim_object, curveAddr) : object;
+ motion_cardinal_curve_keys_avx(kg, fobject, prim, time, ka, k0, k1, kb, &P_curve_0_1,&P_curve_2_3);
+ }
+#else /* __KERNEL_AVX2__ */
+ ssef P_curve[4];
+
+ if(is_curve_primitive) {
+ P_curve[0] = load4f(&kg->__curve_keys.data[ka].x);
+ P_curve[1] = load4f(&kg->__curve_keys.data[k0].x);
+ P_curve[2] = load4f(&kg->__curve_keys.data[k1].x);
+ P_curve[3] = load4f(&kg->__curve_keys.data[kb].x);
+ }
+ else {
+ int fobject = (object == OBJECT_NONE)? kernel_tex_fetch(__prim_object, curveAddr): object;
+ motion_cardinal_curve_keys(kg, fobject, prim, time, ka, k0, k1, kb, (float4*)&P_curve);
+ }
+#endif /* __KERNEL_AVX2__ */
+
+ ssef rd_sgn = set_sign_bit<0, 1, 1, 1>(shuffle<0>(rd_ss));
+ ssef mul_zxxy = shuffle<2, 0, 0, 1>(vdir) * rd_sgn;
+ ssef mul_yz = shuffle<1, 2, 1, 2>(vdir) * mul_zxxy;
+ ssef mul_shuf = shuffle<0, 1, 2, 3>(mul_zxxy, mul_yz);
+ ssef vdir0 = vdir & cast(ssei(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0));
+
+ ssef htfm0 = shuffle<0, 2, 0, 3>(mul_shuf, vdir0);
+ ssef htfm1 = shuffle<1, 0, 1, 3>(load1f_first(extract<0>(d_ss)), vdir0);
+ ssef htfm2 = shuffle<1, 3, 2, 3>(mul_shuf, vdir0);
+
+#if defined(__KERNEL_AVX2__) && defined(__KERNEL_SSE__) && (!defined(_MSC_VER) || _MSC_VER > 1800)
+ const avxf vPP = _mm256_broadcast_ps(&P.m128);
+ const avxf htfm00 = avxf(htfm0.m128, htfm0.m128);
+ const avxf htfm11 = avxf(htfm1.m128, htfm1.m128);
+ const avxf htfm22 = avxf(htfm2.m128, htfm2.m128);
+
+ const avxf p01 = madd(shuffle<0>(P_curve_0_1 - vPP),
+ htfm00,
+ madd(shuffle<1>(P_curve_0_1 - vPP),
+ htfm11,
+ shuffle<2>(P_curve_0_1 - vPP) * htfm22));
+ const avxf p23 = madd(shuffle<0>(P_curve_2_3 - vPP),
+ htfm00,
+ madd(shuffle<1>(P_curve_2_3 - vPP),
+ htfm11,
+ shuffle<2>(P_curve_2_3 - vPP)*htfm22));
+
+ const ssef p0 = _mm256_castps256_ps128(p01);
+ const ssef p1 = _mm256_extractf128_ps(p01, 1);
+ const ssef p2 = _mm256_castps256_ps128(p23);
+ const ssef p3 = _mm256_extractf128_ps(p23, 1);
+
+ const ssef P_curve_1 = _mm256_extractf128_ps(P_curve_0_1, 1);
+ r_st = ((float4 &)P_curve_1).w;
+ const ssef P_curve_2 = _mm256_castps256_ps128(P_curve_2_3);
+ r_en = ((float4 &)P_curve_2).w;
+#else /* __KERNEL_AVX2__ */
+ ssef htfm[] = { htfm0, htfm1, htfm2 };
+ ssef vP = load4f(P);
+ ssef p0 = transform_point_T3(htfm, P_curve[0] - vP);
+ ssef p1 = transform_point_T3(htfm, P_curve[1] - vP);
+ ssef p2 = transform_point_T3(htfm, P_curve[2] - vP);
+ ssef p3 = transform_point_T3(htfm, P_curve[3] - vP);
+
+ r_st = ((float4 &)P_curve[1]).w;
+ r_en = ((float4 &)P_curve[2]).w;
+#endif /* __KERNEL_AVX2__ */
+
+ float fc = 0.71f;
+ ssef vfc = ssef(fc);
+ ssef vfcxp3 = vfc * p3;
+
+ vcurve_coef[0] = p1;
+ vcurve_coef[1] = vfc * (p2 - p0);
+ vcurve_coef[2] = madd(ssef(fc * 2.0f), p0, madd(ssef(fc - 3.0f), p1, msub(ssef(3.0f - 2.0f * fc), p2, vfcxp3)));
+ vcurve_coef[3] = msub(ssef(fc - 2.0f), p2 - p1, msub(vfc, p0, vfcxp3));
+
+ }
+#else
+ float3 curve_coef[4];
+
+ /* curve Intersection check */
+ /* obtain curve parameters */
+ {
+ /* ray transform created - this should be created at beginning of intersection loop */
+ Transform htfm;
+ float d = sqrtf(dir.x * dir.x + dir.z * dir.z);
+ htfm = make_transform(
+ dir.z / d, 0, -dir.x /d, 0,
+ -dir.x * dir.y /d, d, -dir.y * dir.z /d, 0,
+ dir.x, dir.y, dir.z, 0,
+ 0, 0, 0, 1);
+
+ float4 v00 = kernel_tex_fetch(__curves, prim);
+
+ int k0 = __float_as_int(v00.x) + segment;
+ int k1 = k0 + 1;
+
+ int ka = max(k0 - 1,__float_as_int(v00.x));
+ int kb = min(k1 + 1,__float_as_int(v00.x) + __float_as_int(v00.y) - 1);
+
+ float4 P_curve[4];
+
+ if(is_curve_primitive) {
+ P_curve[0] = kernel_tex_fetch(__curve_keys, ka);
+ P_curve[1] = kernel_tex_fetch(__curve_keys, k0);
+ P_curve[2] = kernel_tex_fetch(__curve_keys, k1);
+ P_curve[3] = kernel_tex_fetch(__curve_keys, kb);
+ }
+ else {
+ int fobject = (object == OBJECT_NONE)? kernel_tex_fetch(__prim_object, curveAddr): object;
+ motion_cardinal_curve_keys(kg, fobject, prim, time, ka, k0, k1, kb, P_curve);
+ }
+
+ float3 p0 = transform_point(&htfm, float4_to_float3(P_curve[0]) - P);
+ float3 p1 = transform_point(&htfm, float4_to_float3(P_curve[1]) - P);
+ float3 p2 = transform_point(&htfm, float4_to_float3(P_curve[2]) - P);
+ float3 p3 = transform_point(&htfm, float4_to_float3(P_curve[3]) - P);
+
+ float fc = 0.71f;
+ curve_coef[0] = p1;
+ curve_coef[1] = -fc*p0 + fc*p2;
+ curve_coef[2] = 2.0f * fc * p0 + (fc - 3.0f) * p1 + (3.0f - 2.0f * fc) * p2 - fc * p3;
+ curve_coef[3] = -fc * p0 + (2.0f - fc) * p1 + (fc - 2.0f) * p2 + fc * p3;
+ r_st = P_curve[1].w;
+ r_en = P_curve[2].w;
+ }
+#endif
+
+ float r_curr = max(r_st, r_en);
+
+ if((flags & CURVE_KN_RIBBONS) || !(flags & CURVE_KN_BACKFACING))
+ epsilon = 2 * r_curr;
+
+ /* find bounds - this is slow for cubic curves */
+ float upper, lower;
+
+ float zextrem[4];
+ curvebounds(&lower, &upper, &zextrem[0], &zextrem[1], &zextrem[2], &zextrem[3], curve_coef[0].z, curve_coef[1].z, curve_coef[2].z, curve_coef[3].z);
+ if(lower - r_curr > isect->t || upper + r_curr < epsilon)
+ return false;
+
+ /* minimum width extension */
+ float mw_extension = min(difl * fabsf(upper), extmax);
+ float r_ext = mw_extension + r_curr;
+
+ float xextrem[4];
+ curvebounds(&lower, &upper, &xextrem[0], &xextrem[1], &xextrem[2], &xextrem[3], curve_coef[0].x, curve_coef[1].x, curve_coef[2].x, curve_coef[3].x);
+ if(lower > r_ext || upper < -r_ext)
+ return false;
+
+ float yextrem[4];
+ curvebounds(&lower, &upper, &yextrem[0], &yextrem[1], &yextrem[2], &yextrem[3], curve_coef[0].y, curve_coef[1].y, curve_coef[2].y, curve_coef[3].y);
+ if(lower > r_ext || upper < -r_ext)
+ return false;
+
+ /* setup recurrent loop */
+ int level = 1 << depth;
+ int tree = 0;
+ float resol = 1.0f / (float)level;
+ bool hit = false;
+
+ /* begin loop */
+ while(!(tree >> (depth))) {
+ const float i_st = tree * resol;
+ const float i_en = i_st + (level * resol);
+
+#ifdef __KERNEL_SSE2__
+ ssef vi_st = ssef(i_st), vi_en = ssef(i_en);
+ ssef vp_st = madd(madd(madd(vcurve_coef[3], vi_st, vcurve_coef[2]), vi_st, vcurve_coef[1]), vi_st, vcurve_coef[0]);
+ ssef vp_en = madd(madd(madd(vcurve_coef[3], vi_en, vcurve_coef[2]), vi_en, vcurve_coef[1]), vi_en, vcurve_coef[0]);
+
+ ssef vbmin = min(vp_st, vp_en);
+ ssef vbmax = max(vp_st, vp_en);
+
+ float3 &bmin = (float3 &)vbmin, &bmax = (float3 &)vbmax;
+ float &bminx = bmin.x, &bminy = bmin.y, &bminz = bmin.z;
+ float &bmaxx = bmax.x, &bmaxy = bmax.y, &bmaxz = bmax.z;
+ float3 &p_st = (float3 &)vp_st, &p_en = (float3 &)vp_en;
+#else
+ float3 p_st = ((curve_coef[3] * i_st + curve_coef[2]) * i_st + curve_coef[1]) * i_st + curve_coef[0];
+ float3 p_en = ((curve_coef[3] * i_en + curve_coef[2]) * i_en + curve_coef[1]) * i_en + curve_coef[0];
+
+ float bminx = min(p_st.x, p_en.x);
+ float bmaxx = max(p_st.x, p_en.x);
+ float bminy = min(p_st.y, p_en.y);
+ float bmaxy = max(p_st.y, p_en.y);
+ float bminz = min(p_st.z, p_en.z);
+ float bmaxz = max(p_st.z, p_en.z);
+#endif
+
+ if(xextrem[0] >= i_st && xextrem[0] <= i_en) {
+ bminx = min(bminx,xextrem[1]);
+ bmaxx = max(bmaxx,xextrem[1]);
+ }
+ if(xextrem[2] >= i_st && xextrem[2] <= i_en) {
+ bminx = min(bminx,xextrem[3]);
+ bmaxx = max(bmaxx,xextrem[3]);
+ }
+ if(yextrem[0] >= i_st && yextrem[0] <= i_en) {
+ bminy = min(bminy,yextrem[1]);
+ bmaxy = max(bmaxy,yextrem[1]);
+ }
+ if(yextrem[2] >= i_st && yextrem[2] <= i_en) {
+ bminy = min(bminy,yextrem[3]);
+ bmaxy = max(bmaxy,yextrem[3]);
+ }
+ if(zextrem[0] >= i_st && zextrem[0] <= i_en) {
+ bminz = min(bminz,zextrem[1]);
+ bmaxz = max(bmaxz,zextrem[1]);
+ }
+ if(zextrem[2] >= i_st && zextrem[2] <= i_en) {
+ bminz = min(bminz,zextrem[3]);
+ bmaxz = max(bmaxz,zextrem[3]);
+ }
+
+ float r1 = r_st + (r_en - r_st) * i_st;
+ float r2 = r_st + (r_en - r_st) * i_en;
+ r_curr = max(r1, r2);
+
+ mw_extension = min(difl * fabsf(bmaxz), extmax);
+ float r_ext = mw_extension + r_curr;
+ float coverage = 1.0f;
+
+ if(bminz - r_curr > isect->t || bmaxz + r_curr < epsilon || bminx > r_ext|| bmaxx < -r_ext|| bminy > r_ext|| bmaxy < -r_ext) {
+ /* the bounding box does not overlap the square centered at O */
+ tree += level;
+ level = tree & -tree;
+ }
+ else if(level == 1) {
+
+ /* the maximum recursion depth is reached.
+ * check if dP0.(Q-P0)>=0 and dPn.(Pn-Q)>=0.
+ * dP* is reversed if necessary.*/
+ float t = isect->t;
+ float u = 0.0f;
+ float gd = 0.0f;
+
+ if(flags & CURVE_KN_RIBBONS) {
+ float3 tg = (p_en - p_st);
+#ifdef __KERNEL_SSE__
+ const float3 tg_sq = tg * tg;
+ float w = tg_sq.x + tg_sq.y;
+#else
+ float w = tg.x * tg.x + tg.y * tg.y;
+#endif
+ if(w == 0) {
+ tree++;
+ level = tree & -tree;
+ continue;
+ }
+#ifdef __KERNEL_SSE__
+ const float3 p_sttg = p_st * tg;
+ w = -(p_sttg.x + p_sttg.y) / w;
+#else
+ w = -(p_st.x * tg.x + p_st.y * tg.y) / w;
+#endif
+ w = saturate(w);
+
+ /* compute u on the curve segment */
+ u = i_st * (1 - w) + i_en * w;
+ r_curr = r_st + (r_en - r_st) * u;
+ /* compare x-y distances */
+ float3 p_curr = ((curve_coef[3] * u + curve_coef[2]) * u + curve_coef[1]) * u + curve_coef[0];
+
+ float3 dp_st = (3 * curve_coef[3] * i_st + 2 * curve_coef[2]) * i_st + curve_coef[1];
+ if(dot(tg, dp_st)< 0)
+ dp_st *= -1;
+ if(dot(dp_st, -p_st) + p_curr.z * dp_st.z < 0) {
+ tree++;
+ level = tree & -tree;
+ continue;
+ }
+ float3 dp_en = (3 * curve_coef[3] * i_en + 2 * curve_coef[2]) * i_en + curve_coef[1];
+ if(dot(tg, dp_en) < 0)
+ dp_en *= -1;
+ if(dot(dp_en, p_en) - p_curr.z * dp_en.z < 0) {
+ tree++;
+ level = tree & -tree;
+ continue;
+ }
+
+ /* compute coverage */
+ float r_ext = r_curr;
+ coverage = 1.0f;
+ if(difl != 0.0f) {
+ mw_extension = min(difl * fabsf(bmaxz), extmax);
+ r_ext = mw_extension + r_curr;
+#ifdef __KERNEL_SSE__
+ const float3 p_curr_sq = p_curr * p_curr;
+ const float3 dxxx(_mm_sqrt_ss(_mm_hadd_ps(p_curr_sq.m128, p_curr_sq.m128)));
+ float d = dxxx.x;
+#else
+ float d = sqrtf(p_curr.x * p_curr.x + p_curr.y * p_curr.y);
+#endif
+ float d0 = d - r_curr;
+ float d1 = d + r_curr;
+ float inv_mw_extension = 1.0f/mw_extension;
+ if(d0 >= 0)
+ coverage = (min(d1 * inv_mw_extension, 1.0f) - min(d0 * inv_mw_extension, 1.0f)) * 0.5f;
+ else // inside
+ coverage = (min(d1 * inv_mw_extension, 1.0f) + min(-d0 * inv_mw_extension, 1.0f)) * 0.5f;
+ }
+
+ if(p_curr.x * p_curr.x + p_curr.y * p_curr.y >= r_ext * r_ext || p_curr.z <= epsilon || isect->t < p_curr.z) {
+ tree++;
+ level = tree & -tree;
+ continue;
+ }
+
+ t = p_curr.z;
+
+ /* stochastic fade from minimum width */
+ if(difl != 0.0f && lcg_state) {
+ if(coverage != 1.0f && (lcg_step_float(lcg_state) > coverage))
+ return hit;
+ }
+ }
+ else {
+ float l = len(p_en - p_st);
+ /* minimum width extension */
+ float or1 = r1;
+ float or2 = r2;
+
+ if(difl != 0.0f) {
+ mw_extension = min(len(p_st - P) * difl, extmax);
+ or1 = r1 < mw_extension ? mw_extension : r1;
+ mw_extension = min(len(p_en - P) * difl, extmax);
+ or2 = r2 < mw_extension ? mw_extension : r2;
+ }
+ /* --- */
+ float invl = 1.0f/l;
+ float3 tg = (p_en - p_st) * invl;
+ gd = (or2 - or1) * invl;
+ float difz = -dot(p_st,tg);
+ float cyla = 1.0f - (tg.z * tg.z * (1 + gd*gd));
+ float invcyla = 1.0f/cyla;
+ float halfb = (-p_st.z - tg.z*(difz + gd*(difz*gd + or1)));
+ float tcentre = -halfb*invcyla;
+ float zcentre = difz + (tg.z * tcentre);
+ float3 tdif = - p_st;
+ tdif.z += tcentre;
+ float tdifz = dot(tdif,tg);
+ float tb = 2*(tdif.z - tg.z*(tdifz + gd*(tdifz*gd + or1)));
+ float tc = dot(tdif,tdif) - tdifz * tdifz * (1 + gd*gd) - or1*or1 - 2*or1*tdifz*gd;
+ float td = tb*tb - 4*cyla*tc;
+ if(td < 0.0f) {
+ tree++;
+ level = tree & -tree;
+ continue;
+ }
+
+ float rootd = sqrtf(td);
+ float correction = (-tb - rootd) * 0.5f * invcyla;
+ t = tcentre + correction;
+
+ float3 dp_st = (3 * curve_coef[3] * i_st + 2 * curve_coef[2]) * i_st + curve_coef[1];
+ if(dot(tg, dp_st)< 0)
+ dp_st *= -1;
+ float3 dp_en = (3 * curve_coef[3] * i_en + 2 * curve_coef[2]) * i_en + curve_coef[1];
+ if(dot(tg, dp_en) < 0)
+ dp_en *= -1;
+
+ if(flags & CURVE_KN_BACKFACING && (dot(dp_st, -p_st) + t * dp_st.z < 0 || dot(dp_en, p_en) - t * dp_en.z < 0 || isect->t < t || t <= 0.0f)) {
+ correction = (-tb + rootd) * 0.5f * invcyla;
+ t = tcentre + correction;
+ }
+
+ if(dot(dp_st, -p_st) + t * dp_st.z < 0 || dot(dp_en, p_en) - t * dp_en.z < 0 || isect->t < t || t <= 0.0f) {
+ tree++;
+ level = tree & -tree;
+ continue;
+ }
+
+ float w = (zcentre + (tg.z * correction)) * invl;
+ w = saturate(w);
+ /* compute u on the curve segment */
+ u = i_st * (1 - w) + i_en * w;
+
+ /* stochastic fade from minimum width */
+ if(difl != 0.0f && lcg_state) {
+ r_curr = r1 + (r2 - r1) * w;
+ r_ext = or1 + (or2 - or1) * w;
+ coverage = r_curr/r_ext;
+
+ if(coverage != 1.0f && (lcg_step_float(lcg_state) > coverage))
+ return hit;
+ }
+ }
+ /* we found a new intersection */
+
+#ifdef __VISIBILITY_FLAG__
+ /* visibility flag test. we do it here under the assumption
+ * that most triangles are culled by node flags */
+ if(kernel_tex_fetch(__prim_visibility, curveAddr) & visibility)
+#endif
+ {
+ /* record intersection */
+ isect->t = t;
+ isect->u = u;
+ isect->v = gd;
+ isect->prim = curveAddr;
+ isect->object = object;
+ isect->type = type;
+ hit = true;
+ }
+
+ tree++;
+ level = tree & -tree;
+ }
+ else {
+ /* split the curve into two curves and process */
+ level = level >> 1;
+ }
+ }
+
+ return hit;
+}
+
+ccl_device_curveintersect bool curve_intersect(KernelGlobals *kg,
+ Intersection *isect,
+ float3 P,
+ float3 direction,
+ uint visibility,
+ int object,
+ int curveAddr,
+ float time,
+ int type,
+ uint *lcg_state,
+ float difl,
+ float extmax)
+{
+ /* define few macros to minimize code duplication for SSE */
+#ifndef __KERNEL_SSE2__
+# define len3_squared(x) len_squared(x)
+# define len3(x) len(x)
+# define dot3(x, y) dot(x, y)
+#endif
+
+ const bool is_curve_primitive = (type & PRIMITIVE_CURVE);
+
+ if(!is_curve_primitive && kernel_data.bvh.use_bvh_steps) {
+ const float2 prim_time = kernel_tex_fetch(__prim_time, curveAddr);
+ if(time < prim_time.x || time > prim_time.y) {
+ return false;
+ }
+ }
+
+ int segment = PRIMITIVE_UNPACK_SEGMENT(type);
+ /* curve Intersection check */
+ int flags = kernel_data.curve.curveflags;
+
+ int prim = kernel_tex_fetch(__prim_index, curveAddr);
+ float4 v00 = kernel_tex_fetch(__curves, prim);
+
+ int cnum = __float_as_int(v00.x);
+ int k0 = cnum + segment;
+ int k1 = k0 + 1;
+
+#ifndef __KERNEL_SSE2__
+ float4 P_curve[2];
+
+ if(is_curve_primitive) {
+ P_curve[0] = kernel_tex_fetch(__curve_keys, k0);
+ P_curve[1] = kernel_tex_fetch(__curve_keys, k1);
+ }
+ else {
+ int fobject = (object == OBJECT_NONE)? kernel_tex_fetch(__prim_object, curveAddr): object;
+ motion_curve_keys(kg, fobject, prim, time, k0, k1, P_curve);
+ }
+
+ float or1 = P_curve[0].w;
+ float or2 = P_curve[1].w;
+ float3 p1 = float4_to_float3(P_curve[0]);
+ float3 p2 = float4_to_float3(P_curve[1]);
+
+ /* minimum width extension */
+ float r1 = or1;
+ float r2 = or2;
+ float3 dif = P - p1;
+ float3 dif_second = P - p2;
+ if(difl != 0.0f) {
+ float pixelsize = min(len3(dif) * difl, extmax);
+ r1 = or1 < pixelsize ? pixelsize : or1;
+ pixelsize = min(len3(dif_second) * difl, extmax);
+ r2 = or2 < pixelsize ? pixelsize : or2;
+ }
+ /* --- */
+
+ float3 p21_diff = p2 - p1;
+ float3 sphere_dif1 = (dif + dif_second) * 0.5f;
+ float3 dir = direction;
+ float sphere_b_tmp = dot3(dir, sphere_dif1);
+ float3 sphere_dif2 = sphere_dif1 - sphere_b_tmp * dir;
+#else
+ ssef P_curve[2];
+
+ if(is_curve_primitive) {
+ P_curve[0] = load4f(&kg->__curve_keys.data[k0].x);
+ P_curve[1] = load4f(&kg->__curve_keys.data[k1].x);
+ }
+ else {
+ int fobject = (object == OBJECT_NONE)? kernel_tex_fetch(__prim_object, curveAddr): object;
+ motion_curve_keys(kg, fobject, prim, time, k0, k1, (float4*)&P_curve);
+ }
+
+ const ssef or12 = shuffle<3, 3, 3, 3>(P_curve[0], P_curve[1]);
+
+ ssef r12 = or12;
+ const ssef vP = load4f(P);
+ const ssef dif = vP - P_curve[0];
+ const ssef dif_second = vP - P_curve[1];
+ if(difl != 0.0f) {
+ const ssef len1_sq = len3_squared_splat(dif);
+ const ssef len2_sq = len3_squared_splat(dif_second);
+ const ssef len12 = mm_sqrt(shuffle<0, 0, 0, 0>(len1_sq, len2_sq));
+ const ssef pixelsize12 = min(len12 * difl, ssef(extmax));
+ r12 = max(or12, pixelsize12);
+ }
+ float or1 = extract<0>(or12), or2 = extract<0>(shuffle<2>(or12));
+ float r1 = extract<0>(r12), r2 = extract<0>(shuffle<2>(r12));
+
+ const ssef p21_diff = P_curve[1] - P_curve[0];
+ const ssef sphere_dif1 = (dif + dif_second) * 0.5f;
+ const ssef dir = load4f(direction);
+ const ssef sphere_b_tmp = dot3_splat(dir, sphere_dif1);
+ const ssef sphere_dif2 = nmadd(sphere_b_tmp, dir, sphere_dif1);
+#endif
+
+ float mr = max(r1, r2);
+ float l = len3(p21_diff);
+ float invl = 1.0f / l;
+ float sp_r = mr + 0.5f * l;
+
+ float sphere_b = dot3(dir, sphere_dif2);
+ float sdisc = sphere_b * sphere_b - len3_squared(sphere_dif2) + sp_r * sp_r;
+
+ if(sdisc < 0.0f)
+ return false;
+
+ /* obtain parameters and test midpoint distance for suitable modes */
+#ifndef __KERNEL_SSE2__
+ float3 tg = p21_diff * invl;
+#else
+ const ssef tg = p21_diff * invl;
+#endif
+ float gd = (r2 - r1) * invl;
+
+ float dirz = dot3(dir, tg);
+ float difz = dot3(dif, tg);
+
+ float a = 1.0f - (dirz*dirz*(1 + gd*gd));
+
+ float halfb = dot3(dir, dif) - dirz*(difz + gd*(difz*gd + r1));
+
+ float tcentre = -halfb/a;
+ float zcentre = difz + (dirz * tcentre);
+
+ if((tcentre > isect->t) && !(flags & CURVE_KN_ACCURATE))
+ return false;
+ if((zcentre < 0 || zcentre > l) && !(flags & CURVE_KN_ACCURATE) && !(flags & CURVE_KN_INTERSECTCORRECTION))
+ return false;
+
+ /* test minimum separation */
+#ifndef __KERNEL_SSE2__
+ float3 cprod = cross(tg, dir);
+ float cprod2sq = len3_squared(cross(tg, dif));
+#else
+ const ssef cprod = cross(tg, dir);
+ float cprod2sq = len3_squared(cross_zxy(tg, dif));
+#endif
+ float cprodsq = len3_squared(cprod);
+ float distscaled = dot3(cprod, dif);
+
+ if(cprodsq == 0)
+ distscaled = cprod2sq;
+ else
+ distscaled = (distscaled*distscaled)/cprodsq;
+
+ if(distscaled > mr*mr)
+ return false;
+
+ /* calculate true intersection */
+#ifndef __KERNEL_SSE2__
+ float3 tdif = dif + tcentre * dir;
+#else
+ const ssef tdif = madd(ssef(tcentre), dir, dif);
+#endif
+ float tdifz = dot3(tdif, tg);
+ float tdifma = tdifz*gd + r1;
+ float tb = 2*(dot3(dir, tdif) - dirz*(tdifz + gd*tdifma));
+ float tc = dot3(tdif, tdif) - tdifz*tdifz - tdifma*tdifma;
+ float td = tb*tb - 4*a*tc;
+
+ if(td < 0.0f)
+ return false;
+
+ float rootd = 0.0f;
+ float correction = 0.0f;
+ if(flags & CURVE_KN_ACCURATE) {
+ rootd = sqrtf(td);
+ correction = ((-tb - rootd)/(2*a));
+ }
+
+ float t = tcentre + correction;
+
+ if(t < isect->t) {
+
+ if(flags & CURVE_KN_INTERSECTCORRECTION) {
+ rootd = sqrtf(td);
+ correction = ((-tb - rootd)/(2*a));
+ t = tcentre + correction;
+ }
+
+ float z = zcentre + (dirz * correction);
+ // bool backface = false;
+
+ if(flags & CURVE_KN_BACKFACING && (t < 0.0f || z < 0 || z > l)) {
+ // backface = true;
+ correction = ((-tb + rootd)/(2*a));
+ t = tcentre + correction;
+ z = zcentre + (dirz * correction);
+ }
+
+ /* stochastic fade from minimum width */
+ float adjradius = or1 + z * (or2 - or1) * invl;
+ adjradius = adjradius / (r1 + z * gd);
+ if(lcg_state && adjradius != 1.0f) {
+ if(lcg_step_float(lcg_state) > adjradius)
+ return false;
+ }
+ /* --- */
+
+ if(t > 0.0f && t < isect->t && z >= 0 && z <= l) {
+
+ if(flags & CURVE_KN_ENCLOSEFILTER) {
+ float enc_ratio = 1.01f;
+ if((difz > -r1 * enc_ratio) && (dot3(dif_second, tg) < r2 * enc_ratio)) {
+ float a2 = 1.0f - (dirz*dirz*(1 + gd*gd*enc_ratio*enc_ratio));
+ float c2 = dot3(dif, dif) - difz * difz * (1 + gd*gd*enc_ratio*enc_ratio) - r1*r1*enc_ratio*enc_ratio - 2*r1*difz*gd*enc_ratio;
+ if(a2*c2 < 0.0f)
+ return false;
+ }
+ }
+
+#ifdef __VISIBILITY_FLAG__
+ /* visibility flag test. we do it here under the assumption
+ * that most triangles are culled by node flags */
+ if(kernel_tex_fetch(__prim_visibility, curveAddr) & visibility)
+#endif
+ {
+ /* record intersection */
+ isect->t = t;
+ isect->u = z*invl;
+ isect->v = gd;
+ isect->prim = curveAddr;
+ isect->object = object;
+ isect->type = type;
+
+ return true;
+ }
+ }
+ }
+
+ return false;
+
+#ifndef __KERNEL_SSE2__
+# undef len3_squared
+# undef len3
+# undef dot3
+#endif
+}
+
+ccl_device_inline float3 curvetangent(float t, float3 p0, float3 p1, float3 p2, float3 p3)
+{
+ float fc = 0.71f;
+ float data[4];
+ float t2 = t * t;
+ data[0] = -3.0f * fc * t2 + 4.0f * fc * t - fc;
+ data[1] = 3.0f * (2.0f - fc) * t2 + 2.0f * (fc - 3.0f) * t;
+ data[2] = 3.0f * (fc - 2.0f) * t2 + 2.0f * (3.0f - 2.0f * fc) * t + fc;
+ data[3] = 3.0f * fc * t2 - 2.0f * fc * t;
+ return data[0] * p0 + data[1] * p1 + data[2] * p2 + data[3] * p3;
+}
+
+ccl_device_inline float3 curvepoint(float t, float3 p0, float3 p1, float3 p2, float3 p3)
+{
+ float data[4];
+ float fc = 0.71f;
+ float t2 = t * t;
+ float t3 = t2 * t;
+ data[0] = -fc * t3 + 2.0f * fc * t2 - fc * t;
+ data[1] = (2.0f - fc) * t3 + (fc - 3.0f) * t2 + 1.0f;
+ data[2] = (fc - 2.0f) * t3 + (3.0f - 2.0f * fc) * t2 + fc * t;
+ data[3] = fc * t3 - fc * t2;
+ return data[0] * p0 + data[1] * p1 + data[2] * p2 + data[3] * p3;
+}
+
+ccl_device_inline float3 curve_refine(KernelGlobals *kg,
+ ShaderData *sd,
+ const Intersection *isect,
+ const Ray *ray)
+{
+ int flag = kernel_data.curve.curveflags;
+ float t = isect->t;
+ float3 P = ray->P;
+ float3 D = ray->D;
+
+ if(isect->object != OBJECT_NONE) {
+#ifdef __OBJECT_MOTION__
+ Transform tfm = sd->ob_itfm;
+#else
+ Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_INVERSE_TRANSFORM);
+#endif
+
+ P = transform_point(&tfm, P);
+ D = transform_direction(&tfm, D*t);
+ D = normalize_len(D, &t);
+ }
+
+ int prim = kernel_tex_fetch(__prim_index, isect->prim);
+ float4 v00 = kernel_tex_fetch(__curves, prim);
+
+ int k0 = __float_as_int(v00.x) + PRIMITIVE_UNPACK_SEGMENT(sd->type);
+ int k1 = k0 + 1;
+
+ float3 tg;
+
+ if(flag & CURVE_KN_INTERPOLATE) {
+ int ka = max(k0 - 1,__float_as_int(v00.x));
+ int kb = min(k1 + 1,__float_as_int(v00.x) + __float_as_int(v00.y) - 1);
+
+ float4 P_curve[4];
+
+ if(sd->type & PRIMITIVE_CURVE) {
+ P_curve[0] = kernel_tex_fetch(__curve_keys, ka);
+ P_curve[1] = kernel_tex_fetch(__curve_keys, k0);
+ P_curve[2] = kernel_tex_fetch(__curve_keys, k1);
+ P_curve[3] = kernel_tex_fetch(__curve_keys, kb);
+ }
+ else {
+ motion_cardinal_curve_keys(kg, sd->object, sd->prim, sd->time, ka, k0, k1, kb, P_curve);
+ }
+
+ float3 p[4];
+ p[0] = float4_to_float3(P_curve[0]);
+ p[1] = float4_to_float3(P_curve[1]);
+ p[2] = float4_to_float3(P_curve[2]);
+ p[3] = float4_to_float3(P_curve[3]);
+
+ P = P + D*t;
+
+#ifdef __UV__
+ sd->u = isect->u;
+ sd->v = 0.0f;
+#endif
+
+ tg = normalize(curvetangent(isect->u, p[0], p[1], p[2], p[3]));
+
+ if(kernel_data.curve.curveflags & CURVE_KN_RIBBONS) {
+ sd->Ng = normalize(-(D - tg * (dot(tg, D))));
+ }
+ else {
+ /* direction from inside to surface of curve */
+ float3 p_curr = curvepoint(isect->u, p[0], p[1], p[2], p[3]);
+ sd->Ng = normalize(P - p_curr);
+
+ /* adjustment for changing radius */
+ float gd = isect->v;
+
+ if(gd != 0.0f) {
+ sd->Ng = sd->Ng - gd * tg;
+ sd->Ng = normalize(sd->Ng);
+ }
+ }
+
+ /* todo: sometimes the normal is still so that this is detected as
+ * backfacing even if cull backfaces is enabled */
+
+ sd->N = sd->Ng;
+ }
+ else {
+ float4 P_curve[2];
+
+ if(sd->type & PRIMITIVE_CURVE) {
+ P_curve[0]= kernel_tex_fetch(__curve_keys, k0);
+ P_curve[1]= kernel_tex_fetch(__curve_keys, k1);
+ }
+ else {
+ motion_curve_keys(kg, sd->object, sd->prim, sd->time, k0, k1, P_curve);
+ }
+
+ float l = 1.0f;
+ tg = normalize_len(float4_to_float3(P_curve[1] - P_curve[0]), &l);
+
+ P = P + D*t;
+
+ float3 dif = P - float4_to_float3(P_curve[0]);
+
+#ifdef __UV__
+ sd->u = dot(dif,tg)/l;
+ sd->v = 0.0f;
+#endif
+
+ if(flag & CURVE_KN_TRUETANGENTGNORMAL) {
+ sd->Ng = -(D - tg * dot(tg, D));
+ sd->Ng = normalize(sd->Ng);
+ }
+ else {
+ float gd = isect->v;
+
+ /* direction from inside to surface of curve */
+ sd->Ng = (dif - tg * sd->u * l) / (P_curve[0].w + sd->u * l * gd);
+
+ /* adjustment for changing radius */
+ if(gd != 0.0f) {
+ sd->Ng = sd->Ng - gd * tg;
+ sd->Ng = normalize(sd->Ng);
+ }
+ }
+
+ sd->N = sd->Ng;
+ }
+
+#ifdef __DPDU__
+ /* dPdu/dPdv */
+ sd->dPdu = tg;
+ sd->dPdv = cross(tg, sd->Ng);
+#endif
+
+ if(isect->object != OBJECT_NONE) {
+#ifdef __OBJECT_MOTION__
+ Transform tfm = sd->ob_tfm;
+#else
+ Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_TRANSFORM);
+#endif
+
+ P = transform_point(&tfm, P);
+ }
+
+ return P;
+}
+
+#endif
+
+CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/geom/geom_object.h b/intern/cycles/kernel/geom/geom_object.h
index 6ecdfe0173a..1ffc143be34 100644
--- a/intern/cycles/kernel/geom/geom_object.h
+++ b/intern/cycles/kernel/geom/geom_object.h
@@ -415,12 +415,7 @@ ccl_device_inline float3 bvh_clamp_direction(float3 dir)
ccl_device_inline float3 bvh_inverse_direction(float3 dir)
{
- /* TODO(sergey): Currently disabled, gives speedup but causes precision issues. */
-#if defined(__KERNEL_SSE__) && 0
return rcp(dir);
-#else
- return 1.0f / dir;
-#endif
}
/* Transform ray into object space to enter static object in BVH */
diff --git a/intern/cycles/kernel/geom/geom_volume.h b/intern/cycles/kernel/geom/geom_volume.h
index 1e0ef5201c9..698cd6b03fd 100644
--- a/intern/cycles/kernel/geom/geom_volume.h
+++ b/intern/cycles/kernel/geom/geom_volume.h
@@ -35,10 +35,10 @@ ccl_device float4 volume_image_texture_3d(int id, float x, float y, float z)
float4 r;
switch(id) {
case 0: r = kernel_tex_image_interp_3d(__tex_image_float4_3d_000, x, y, z); break;
- case 1: r = kernel_tex_image_interp_3d(__tex_image_float4_3d_001, x, y, z); break;
- case 2: r = kernel_tex_image_interp_3d(__tex_image_float4_3d_002, x, y, z); break;
- case 3: r = kernel_tex_image_interp_3d(__tex_image_float4_3d_003, x, y, z); break;
- case 4: r = kernel_tex_image_interp_3d(__tex_image_float4_3d_004, x, y, z); break;
+ case 8: r = kernel_tex_image_interp_3d(__tex_image_float4_3d_008, x, y, z); break;
+ case 16: r = kernel_tex_image_interp_3d(__tex_image_float4_3d_016, x, y, z); break;
+ case 24: r = kernel_tex_image_interp_3d(__tex_image_float4_3d_024, x, y, z); break;
+ case 32: r = kernel_tex_image_interp_3d(__tex_image_float4_3d_032, x, y, z); break;
}
return r;
}
diff --git a/intern/cycles/kernel/kernel_accumulate.h b/intern/cycles/kernel/kernel_accumulate.h
index 175bd6b9737..366f25422fd 100644
--- a/intern/cycles/kernel/kernel_accumulate.h
+++ b/intern/cycles/kernel/kernel_accumulate.h
@@ -21,6 +21,9 @@ CCL_NAMESPACE_BEGIN
* BSDF evaluation result, split per BSDF type. This is used to accumulate
* render passes separately. */
+ccl_device float3 shader_bsdf_transparency(KernelGlobals *kg,
+ const ShaderData *sd);
+
ccl_device_inline void bsdf_eval_init(BsdfEval *eval, ClosureType type, float3 value, int use_light_pass)
{
#ifdef __PASSES__
@@ -178,7 +181,6 @@ ccl_device_inline void path_radiance_init(PathRadiance *L, int use_light_pass)
if(use_light_pass) {
L->indirect = make_float3(0.0f, 0.0f, 0.0f);
- L->direct_throughput = make_float3(0.0f, 0.0f, 0.0f);
L->direct_emission = make_float3(0.0f, 0.0f, 0.0f);
L->color_diffuse = make_float3(0.0f, 0.0f, 0.0f);
@@ -199,57 +201,78 @@ ccl_device_inline void path_radiance_init(PathRadiance *L, int use_light_pass)
L->indirect_subsurface = make_float3(0.0f, 0.0f, 0.0f);
L->indirect_scatter = make_float3(0.0f, 0.0f, 0.0f);
- L->path_diffuse = make_float3(0.0f, 0.0f, 0.0f);
- L->path_glossy = make_float3(0.0f, 0.0f, 0.0f);
- L->path_transmission = make_float3(0.0f, 0.0f, 0.0f);
- L->path_subsurface = make_float3(0.0f, 0.0f, 0.0f);
- L->path_scatter = make_float3(0.0f, 0.0f, 0.0f);
-
+ L->transparent = 0.0f;
L->emission = make_float3(0.0f, 0.0f, 0.0f);
L->background = make_float3(0.0f, 0.0f, 0.0f);
L->ao = make_float3(0.0f, 0.0f, 0.0f);
L->shadow = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
L->mist = 0.0f;
+
+ L->state.diffuse = make_float3(0.0f, 0.0f, 0.0f);
+ L->state.glossy = make_float3(0.0f, 0.0f, 0.0f);
+ L->state.transmission = make_float3(0.0f, 0.0f, 0.0f);
+ L->state.subsurface = make_float3(0.0f, 0.0f, 0.0f);
+ L->state.scatter = make_float3(0.0f, 0.0f, 0.0f);
+ L->state.direct = make_float3(0.0f, 0.0f, 0.0f);
}
else
#endif
{
+ L->transparent = 0.0f;
L->emission = make_float3(0.0f, 0.0f, 0.0f);
}
#ifdef __SHADOW_TRICKS__
L->path_total = make_float3(0.0f, 0.0f, 0.0f);
L->path_total_shaded = make_float3(0.0f, 0.0f, 0.0f);
- L->shadow_color = make_float3(0.0f, 0.0f, 0.0f);
+ L->shadow_background_color = make_float3(0.0f, 0.0f, 0.0f);
+ L->shadow_throughput = 0.0f;
+ L->shadow_transparency = 1.0f;
+ L->has_shadow_catcher = 0;
#endif
#ifdef __DENOISING_FEATURES__
L->denoising_normal = make_float3(0.0f, 0.0f, 0.0f);
L->denoising_albedo = make_float3(0.0f, 0.0f, 0.0f);
L->denoising_depth = 0.0f;
-#endif /* __DENOISING_FEATURES__ */
+#endif
+
+#ifdef __KERNEL_DEBUG__
+ L->debug_data.num_bvh_traversed_nodes = 0;
+ L->debug_data.num_bvh_traversed_instances = 0;
+ L->debug_data.num_bvh_intersections = 0;
+ L->debug_data.num_ray_bounces = 0;
+#endif
}
-ccl_device_inline void path_radiance_bsdf_bounce(PathRadiance *L, ccl_addr_space float3 *throughput,
- BsdfEval *bsdf_eval, float bsdf_pdf, int bounce, int bsdf_label)
+ccl_device_inline void path_radiance_bsdf_bounce(
+ KernelGlobals *kg,
+ PathRadianceState *L_state,
+ ccl_addr_space float3 *throughput,
+ BsdfEval *bsdf_eval,
+ float bsdf_pdf, int bounce, int bsdf_label)
{
float inverse_pdf = 1.0f/bsdf_pdf;
#ifdef __PASSES__
- if(L->use_light_pass) {
+ if(kernel_data.film.use_light_pass) {
if(bounce == 0 && !(bsdf_label & LABEL_TRANSPARENT)) {
/* first on directly visible surface */
float3 value = *throughput*inverse_pdf;
- L->path_diffuse = bsdf_eval->diffuse*value;
- L->path_glossy = bsdf_eval->glossy*value;
- L->path_transmission = bsdf_eval->transmission*value;
- L->path_subsurface = bsdf_eval->subsurface*value;
- L->path_scatter = bsdf_eval->scatter*value;
-
- *throughput = L->path_diffuse + L->path_glossy + L->path_transmission + L->path_subsurface + L->path_scatter;
+ L_state->diffuse = bsdf_eval->diffuse*value;
+ L_state->glossy = bsdf_eval->glossy*value;
+ L_state->transmission = bsdf_eval->transmission*value;
+ L_state->subsurface = bsdf_eval->subsurface*value;
+ L_state->scatter = bsdf_eval->scatter*value;
+
+ *throughput = L_state->diffuse +
+ L_state->glossy +
+ L_state->transmission +
+ L_state->subsurface +
+ L_state->scatter;
- L->direct_throughput = *throughput;
+ L_state->direct = *throughput;
}
else {
/* transparent bounce before first hit, or indirectly visible through BSDF */
@@ -264,13 +287,22 @@ ccl_device_inline void path_radiance_bsdf_bounce(PathRadiance *L, ccl_addr_space
}
}
-ccl_device_inline void path_radiance_accum_emission(PathRadiance *L, float3 throughput, float3 value, int bounce)
+ccl_device_inline void path_radiance_accum_emission(PathRadiance *L,
+ ccl_addr_space PathState *state,
+ float3 throughput,
+ float3 value)
{
+#ifdef __SHADOW_TRICKS__
+ if(state->flag & PATH_RAY_SHADOW_CATCHER) {
+ return;
+ }
+#endif
+
#ifdef __PASSES__
if(L->use_light_pass) {
- if(bounce == 0)
+ if(state->bounce == 0)
L->emission += throughput*value;
- else if(bounce == 1)
+ else if(state->bounce == 1)
L->direct_emission += throughput*value;
else
L->indirect += throughput*value;
@@ -289,6 +321,18 @@ ccl_device_inline void path_radiance_accum_ao(PathRadiance *L,
float3 bsdf,
float3 ao)
{
+#ifdef __SHADOW_TRICKS__
+ if(state->flag & PATH_RAY_STORE_SHADOW_INFO) {
+ float3 light = throughput * bsdf;
+ L->path_total += light;
+ L->path_total_shaded += ao * light;
+
+ if(state->flag & PATH_RAY_SHADOW_CATCHER) {
+ return;
+ }
+ }
+#endif
+
#ifdef __PASSES__
if(L->use_light_pass) {
if(state->bounce == 0) {
@@ -306,14 +350,6 @@ ccl_device_inline void path_radiance_accum_ao(PathRadiance *L,
{
L->emission += throughput*bsdf*ao;
}
-
-#ifdef __SHADOW_TRICKS__
- if(state->flag & PATH_RAY_STORE_SHADOW_INFO) {
- float3 light = throughput * bsdf;
- L->path_total += light;
- L->path_total_shaded += ao * light;
- }
-#endif
}
ccl_device_inline void path_radiance_accum_total_ao(
@@ -342,6 +378,18 @@ ccl_device_inline void path_radiance_accum_light(PathRadiance *L,
float shadow_fac,
bool is_lamp)
{
+#ifdef __SHADOW_TRICKS__
+ if(state->flag & PATH_RAY_STORE_SHADOW_INFO) {
+ float3 light = throughput * bsdf_eval->sum_no_mis;
+ L->path_total += light;
+ L->path_total_shaded += shadow * light;
+
+ if(state->flag & PATH_RAY_SHADOW_CATCHER) {
+ return;
+ }
+ }
+#endif
+
#ifdef __PASSES__
if(L->use_light_pass) {
if(state->bounce == 0) {
@@ -368,14 +416,6 @@ ccl_device_inline void path_radiance_accum_light(PathRadiance *L,
{
L->emission += throughput*bsdf_eval->diffuse*shadow;
}
-
-#ifdef __SHADOW_TRICKS__
- if(state->flag & PATH_RAY_STORE_SHADOW_INFO) {
- float3 light = throughput * bsdf_eval->sum_no_mis;
- L->path_total += light;
- L->path_total_shaded += shadow * light;
- }
-#endif
}
ccl_device_inline void path_radiance_accum_total_light(
@@ -396,11 +436,24 @@ ccl_device_inline void path_radiance_accum_total_light(
#endif
}
-ccl_device_inline void path_radiance_accum_background(PathRadiance *L,
- ccl_addr_space PathState *state,
- float3 throughput,
- float3 value)
+ccl_device_inline void path_radiance_accum_background(
+ PathRadiance *L,
+ ccl_addr_space PathState *state,
+ float3 throughput,
+ float3 value)
{
+
+#ifdef __SHADOW_TRICKS__
+ if(state->flag & PATH_RAY_STORE_SHADOW_INFO) {
+ L->path_total += throughput * value;
+ L->path_total_shaded += throughput * value * L->shadow_transparency;
+
+ if(state->flag & PATH_RAY_SHADOW_CATCHER) {
+ return;
+ }
+ }
+#endif
+
#ifdef __PASSES__
if(L->use_light_pass) {
if(state->bounce == 0)
@@ -416,20 +469,31 @@ ccl_device_inline void path_radiance_accum_background(PathRadiance *L,
L->emission += throughput*value;
}
-#ifdef __SHADOW_TRICKS__
- if(state->flag & PATH_RAY_STORE_SHADOW_INFO) {
- L->path_total += throughput * value;
- if(state->flag & PATH_RAY_SHADOW_CATCHER_ONLY) {
- L->path_total_shaded += throughput * value;
- }
- }
-#endif
-
#ifdef __DENOISING_FEATURES__
L->denoising_albedo += state->denoising_feature_weight * value;
#endif /* __DENOISING_FEATURES__ */
}
+ccl_device_inline void path_radiance_accum_transparent(
+ PathRadiance *L,
+ ccl_addr_space PathState *state,
+ float3 throughput)
+{
+ L->transparent += average(throughput);
+}
+
+#ifdef __SHADOW_TRICKS__
+ccl_device_inline void path_radiance_accum_shadowcatcher(
+ PathRadiance *L,
+ float3 throughput,
+ float3 background)
+{
+ L->shadow_throughput += average(throughput);
+ L->shadow_background_color += throughput * background;
+ L->has_shadow_catcher = 1;
+}
+#endif
+
ccl_device_inline void path_radiance_sum_indirect(PathRadiance *L)
{
#ifdef __PASSES__
@@ -437,19 +501,19 @@ ccl_device_inline void path_radiance_sum_indirect(PathRadiance *L)
* only a single throughput further along the path, here we recover just
* the indirect path that is not influenced by any particular BSDF type */
if(L->use_light_pass) {
- L->direct_emission = safe_divide_color(L->direct_emission, L->direct_throughput);
- L->direct_diffuse += L->path_diffuse*L->direct_emission;
- L->direct_glossy += L->path_glossy*L->direct_emission;
- L->direct_transmission += L->path_transmission*L->direct_emission;
- L->direct_subsurface += L->path_subsurface*L->direct_emission;
- L->direct_scatter += L->path_scatter*L->direct_emission;
-
- L->indirect = safe_divide_color(L->indirect, L->direct_throughput);
- L->indirect_diffuse += L->path_diffuse*L->indirect;
- L->indirect_glossy += L->path_glossy*L->indirect;
- L->indirect_transmission += L->path_transmission*L->indirect;
- L->indirect_subsurface += L->path_subsurface*L->indirect;
- L->indirect_scatter += L->path_scatter*L->indirect;
+ L->direct_emission = safe_divide_color(L->direct_emission, L->state.direct);
+ L->direct_diffuse += L->state.diffuse*L->direct_emission;
+ L->direct_glossy += L->state.glossy*L->direct_emission;
+ L->direct_transmission += L->state.transmission*L->direct_emission;
+ L->direct_subsurface += L->state.subsurface*L->direct_emission;
+ L->direct_scatter += L->state.scatter*L->direct_emission;
+
+ L->indirect = safe_divide_color(L->indirect, L->state.direct);
+ L->indirect_diffuse += L->state.diffuse*L->indirect;
+ L->indirect_glossy += L->state.glossy*L->indirect;
+ L->indirect_transmission += L->state.transmission*L->indirect;
+ L->indirect_subsurface += L->state.subsurface*L->indirect;
+ L->indirect_scatter += L->state.scatter*L->indirect;
}
#endif
}
@@ -458,11 +522,11 @@ ccl_device_inline void path_radiance_reset_indirect(PathRadiance *L)
{
#ifdef __PASSES__
if(L->use_light_pass) {
- L->path_diffuse = make_float3(0.0f, 0.0f, 0.0f);
- L->path_glossy = make_float3(0.0f, 0.0f, 0.0f);
- L->path_transmission = make_float3(0.0f, 0.0f, 0.0f);
- L->path_subsurface = make_float3(0.0f, 0.0f, 0.0f);
- L->path_scatter = make_float3(0.0f, 0.0f, 0.0f);
+ L->state.diffuse = make_float3(0.0f, 0.0f, 0.0f);
+ L->state.glossy = make_float3(0.0f, 0.0f, 0.0f);
+ L->state.transmission = make_float3(0.0f, 0.0f, 0.0f);
+ L->state.subsurface = make_float3(0.0f, 0.0f, 0.0f);
+ L->state.scatter = make_float3(0.0f, 0.0f, 0.0f);
L->direct_emission = make_float3(0.0f, 0.0f, 0.0f);
L->indirect = make_float3(0.0f, 0.0f, 0.0f);
@@ -475,11 +539,7 @@ ccl_device_inline void path_radiance_copy_indirect(PathRadiance *L,
{
#ifdef __PASSES__
if(L->use_light_pass) {
- L->path_diffuse = L_src->path_diffuse;
- L->path_glossy = L_src->path_glossy;
- L->path_transmission = L_src->path_transmission;
- L->path_subsurface = L_src->path_subsurface;
- L->path_scatter = L_src->path_scatter;
+ L->state = L_src->state;
L->direct_emission = L_src->direct_emission;
L->indirect = L_src->indirect;
@@ -487,7 +547,40 @@ ccl_device_inline void path_radiance_copy_indirect(PathRadiance *L,
#endif
}
-ccl_device_inline float3 path_radiance_clamp_and_sum(KernelGlobals *kg, PathRadiance *L)
+#ifdef __SHADOW_TRICKS__
+ccl_device_inline void path_radiance_sum_shadowcatcher(KernelGlobals *kg,
+ PathRadiance *L,
+ float3 *L_sum,
+ float *alpha)
+{
+ /* Calculate current shadow of the path. */
+ float path_total = average(L->path_total);
+ float shadow;
+
+ if(UNLIKELY(!isfinite_safe(path_total))) {
+ kernel_assert(!"Non-finite total radiance along the path");
+ shadow = 0.0f;
+ }
+ else if(path_total == 0.0f) {
+ shadow = L->shadow_transparency;
+ }
+ else {
+ float path_total_shaded = average(L->path_total_shaded);
+ shadow = path_total_shaded / path_total;
+ }
+
+ /* Calculate final light sum and transparency for shadow catcher object. */
+ if(kernel_data.background.transparent) {
+ *alpha -= L->shadow_throughput * shadow;
+ }
+ else {
+ L->shadow_background_color *= shadow;
+ *L_sum += L->shadow_background_color;
+ }
+}
+#endif
+
+ccl_device_inline float3 path_radiance_clamp_and_sum(KernelGlobals *kg, PathRadiance *L, float *alpha)
{
float3 L_sum;
/* Light Passes are used */
@@ -564,8 +657,6 @@ ccl_device_inline float3 path_radiance_clamp_and_sum(KernelGlobals *kg, PathRadi
L_sum = L_direct + L_indirect;
}
#endif
-
- return L_sum;
}
/* No Light Passes */
@@ -573,14 +664,24 @@ ccl_device_inline float3 path_radiance_clamp_and_sum(KernelGlobals *kg, PathRadi
#endif
{
L_sum = L->emission;
+
+ /* Reject invalid value */
+ float sum = fabsf((L_sum).x) + fabsf((L_sum).y) + fabsf((L_sum).z);
+ if(!isfinite_safe(sum)) {
+ kernel_assert(!"Non-finite final sum in path_radiance_clamp_and_sum!");
+ L_sum = make_float3(0.0f, 0.0f, 0.0f);
+ }
}
- /* Reject invalid value */
- float sum = fabsf((L_sum).x) + fabsf((L_sum).y) + fabsf((L_sum).z);
- if(!isfinite_safe(sum)) {
- kernel_assert(!"Non-finite final sum in path_radiance_clamp_and_sum!");
- L_sum = make_float3(0.0f, 0.0f, 0.0f);
+ /* Compute alpha. */
+ *alpha = 1.0f - L->transparent;
+
+ /* Add shadow catcher contributions. */
+#ifdef __SHADOW_TRICKS__
+ if(L->has_shadow_catcher) {
+ path_radiance_sum_shadowcatcher(kg, L, &L_sum, alpha);
}
+#endif /* __SHADOW_TRICKS__ */
return L_sum;
}
@@ -613,14 +714,18 @@ ccl_device_inline void path_radiance_split_denoising(KernelGlobals *kg, PathRadi
*clean = make_float3(0.0f, 0.0f, 0.0f);
#endif
+#ifdef __SHADOW_TRICKS__
+ if(L->has_shadow_catcher) {
+ *noisy += L->shadow_background_color;
+ }
+#endif
+
*noisy = ensure_finite3(*noisy);
*clean = ensure_finite3(*clean);
}
-ccl_device_inline void path_radiance_accum_sample(PathRadiance *L, PathRadiance *L_sample, int num_samples)
+ccl_device_inline void path_radiance_accum_sample(PathRadiance *L, PathRadiance *L_sample)
{
- float fac = 1.0f/num_samples;
-
#ifdef __SPLIT_KERNEL__
# define safe_float3_add(f, v) \
do { \
@@ -629,65 +734,35 @@ ccl_device_inline void path_radiance_accum_sample(PathRadiance *L, PathRadiance
atomic_add_and_fetch_float(p+1, (v).y); \
atomic_add_and_fetch_float(p+2, (v).z); \
} while(0)
+# define safe_float_add(f, v) \
+ atomic_add_and_fetch_float(&(f), (v))
#else
# define safe_float3_add(f, v) (f) += (v)
+# define safe_float_add(f, v) (f) += (v)
#endif /* __SPLIT_KERNEL__ */
#ifdef __PASSES__
- safe_float3_add(L->direct_diffuse, L_sample->direct_diffuse*fac);
- safe_float3_add(L->direct_glossy, L_sample->direct_glossy*fac);
- safe_float3_add(L->direct_transmission, L_sample->direct_transmission*fac);
- safe_float3_add(L->direct_subsurface, L_sample->direct_subsurface*fac);
- safe_float3_add(L->direct_scatter, L_sample->direct_scatter*fac);
-
- safe_float3_add(L->indirect_diffuse, L_sample->indirect_diffuse*fac);
- safe_float3_add(L->indirect_glossy, L_sample->indirect_glossy*fac);
- safe_float3_add(L->indirect_transmission, L_sample->indirect_transmission*fac);
- safe_float3_add(L->indirect_subsurface, L_sample->indirect_subsurface*fac);
- safe_float3_add(L->indirect_scatter, L_sample->indirect_scatter*fac);
-
- safe_float3_add(L->background, L_sample->background*fac);
- safe_float3_add(L->ao, L_sample->ao*fac);
- safe_float3_add(L->shadow, L_sample->shadow*fac);
-# ifdef __SPLIT_KERNEL__
- atomic_add_and_fetch_float(&L->mist, L_sample->mist*fac);
-# else
- L->mist += L_sample->mist*fac;
-# endif /* __SPLIT_KERNEL__ */
+ safe_float3_add(L->direct_diffuse, L_sample->direct_diffuse);
+ safe_float3_add(L->direct_glossy, L_sample->direct_glossy);
+ safe_float3_add(L->direct_transmission, L_sample->direct_transmission);
+ safe_float3_add(L->direct_subsurface, L_sample->direct_subsurface);
+ safe_float3_add(L->direct_scatter, L_sample->direct_scatter);
+
+ safe_float3_add(L->indirect_diffuse, L_sample->indirect_diffuse);
+ safe_float3_add(L->indirect_glossy, L_sample->indirect_glossy);
+ safe_float3_add(L->indirect_transmission, L_sample->indirect_transmission);
+ safe_float3_add(L->indirect_subsurface, L_sample->indirect_subsurface);
+ safe_float3_add(L->indirect_scatter, L_sample->indirect_scatter);
+
+ safe_float3_add(L->background, L_sample->background);
+ safe_float3_add(L->ao, L_sample->ao);
+ safe_float3_add(L->shadow, L_sample->shadow);
+ safe_float_add(L->mist, L_sample->mist);
#endif /* __PASSES__ */
- safe_float3_add(L->emission, L_sample->emission*fac);
+ safe_float3_add(L->emission, L_sample->emission);
+#undef safe_float_add
#undef safe_float3_add
}
-#ifdef __SHADOW_TRICKS__
-/* Calculate current shadow of the path. */
-ccl_device_inline float path_radiance_sum_shadow(const PathRadiance *L)
-{
- float path_total = average(L->path_total);
- float path_total_shaded = average(L->path_total_shaded);
- if(path_total != 0.0f) {
- return path_total_shaded / path_total;
- }
- return 1.0f;
-}
-
-/* Calculate final light sum and transparency for shadow catcher object. */
-ccl_device_inline float3 path_radiance_sum_shadowcatcher(KernelGlobals *kg,
- const PathRadiance *L,
- float* alpha)
-{
- const float shadow = path_radiance_sum_shadow(L);
- float3 L_sum;
- if(kernel_data.background.transparent) {
- *alpha = 1.0f-shadow;
- L_sum = make_float3(0.0f, 0.0f, 0.0f);
- }
- else {
- L_sum = L->shadow_color * shadow;
- }
- return L_sum;
-}
-#endif
-
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/kernel_bake.h b/intern/cycles/kernel/kernel_bake.h
index f18d145f7cf..84d8d84d486 100644
--- a/intern/cycles/kernel/kernel_bake.h
+++ b/intern/cycles/kernel/kernel_bake.h
@@ -21,7 +21,7 @@ CCL_NAMESPACE_BEGIN
ccl_device_inline void compute_light_pass(KernelGlobals *kg,
ShaderData *sd,
PathRadiance *L,
- RNG rng,
+ uint rng_hash,
int pass_filter,
int sample)
{
@@ -48,11 +48,10 @@ ccl_device_inline void compute_light_pass(KernelGlobals *kg,
path_radiance_init(&L_sample, kernel_data.film.use_light_pass);
/* init path state */
- path_state_init(kg, &emission_sd, &state, &rng, sample, NULL);
+ path_state_init(kg, &emission_sd, &state, rng_hash, sample, NULL);
/* evaluate surface shader */
- float rbsdf = path_state_rng_1D(kg, &rng, &state, PRNG_BSDF);
- shader_eval_surface(kg, sd, &rng, &state, rbsdf, state.flag, SHADER_CONTEXT_MAIN);
+ shader_eval_surface(kg, sd, &state, state.flag);
/* TODO, disable more closures we don't need besides transparent */
shader_bsdf_disable_transparency(kg, sd);
@@ -64,13 +63,13 @@ ccl_device_inline void compute_light_pass(KernelGlobals *kg,
/* sample ambient occlusion */
if(pass_filter & BAKE_FILTER_AO) {
- kernel_path_ao(kg, sd, &emission_sd, &L_sample, &state, &rng, throughput, shader_bsdf_alpha(kg, sd));
+ kernel_path_ao(kg, sd, &emission_sd, &L_sample, &state, throughput, shader_bsdf_alpha(kg, sd));
}
/* sample emission */
if((pass_filter & BAKE_FILTER_EMISSION) && (sd->flag & SD_EMISSION)) {
float3 emission = indirect_primitive_emission(kg, sd, 0.0f, state.flag, state.ray_pdf);
- path_radiance_accum_emission(&L_sample, throughput, emission, state.bounce);
+ path_radiance_accum_emission(&L_sample, &state, throughput, emission);
}
bool is_sss_sample = false;
@@ -86,7 +85,6 @@ ccl_device_inline void compute_light_pass(KernelGlobals *kg,
&emission_sd,
&L_sample,
&state,
- &rng,
&ray,
&throughput,
&ss_indirect))
@@ -101,13 +99,10 @@ ccl_device_inline void compute_light_pass(KernelGlobals *kg,
kernel_path_indirect(kg,
&indirect_sd,
&emission_sd,
- &rng,
&ray,
throughput,
- state.num_samples,
&state,
&L_sample);
- kernel_path_subsurface_accum_indirect(&ss_indirect, &L_sample);
}
is_sss_sample = true;
}
@@ -116,14 +111,14 @@ ccl_device_inline void compute_light_pass(KernelGlobals *kg,
/* sample light and BSDF */
if(!is_sss_sample && (pass_filter & (BAKE_FILTER_DIRECT | BAKE_FILTER_INDIRECT))) {
- kernel_path_surface_connect_light(kg, &rng, sd, &emission_sd, throughput, &state, &L_sample);
+ kernel_path_surface_connect_light(kg, sd, &emission_sd, throughput, &state, &L_sample);
- if(kernel_path_surface_bounce(kg, &rng, sd, &throughput, &state, &L_sample, &ray)) {
+ if(kernel_path_surface_bounce(kg, sd, &throughput, &state, &L_sample.state, &ray)) {
#ifdef __LAMP_MIS__
state.ray_t = 0.0f;
#endif
/* compute indirect light */
- kernel_path_indirect(kg, &indirect_sd, &emission_sd, &rng, &ray, throughput, 1, &state, &L_sample);
+ kernel_path_indirect(kg, &indirect_sd, &emission_sd, &ray, throughput, &state, &L_sample);
/* sum and reset indirect light pass variables for the next samples */
path_radiance_sum_indirect(&L_sample);
@@ -137,13 +132,13 @@ ccl_device_inline void compute_light_pass(KernelGlobals *kg,
/* sample ambient occlusion */
if(pass_filter & BAKE_FILTER_AO) {
- kernel_branched_path_ao(kg, sd, &emission_sd, &L_sample, &state, &rng, throughput);
+ kernel_branched_path_ao(kg, sd, &emission_sd, &L_sample, &state, throughput);
}
/* sample emission */
if((pass_filter & BAKE_FILTER_EMISSION) && (sd->flag & SD_EMISSION)) {
float3 emission = indirect_primitive_emission(kg, sd, 0.0f, state.flag, state.ray_pdf);
- path_radiance_accum_emission(&L_sample, throughput, emission, state.bounce);
+ path_radiance_accum_emission(&L_sample, &state, throughput, emission);
}
#ifdef __SUBSURFACE__
@@ -151,7 +146,7 @@ ccl_device_inline void compute_light_pass(KernelGlobals *kg,
if((pass_filter & BAKE_FILTER_SUBSURFACE) && (sd->flag & SD_BSSRDF)) {
/* when mixing BSSRDF and BSDF closures we should skip BSDF lighting if scattering was successful */
kernel_branched_path_subsurface_scatter(kg, sd, &indirect_sd,
- &emission_sd, &L_sample, &state, &rng, &ray, throughput);
+ &emission_sd, &L_sample, &state, &ray, throughput);
}
#endif
@@ -161,20 +156,20 @@ ccl_device_inline void compute_light_pass(KernelGlobals *kg,
/* direct light */
if(kernel_data.integrator.use_direct_light) {
int all = kernel_data.integrator.sample_all_lights_direct;
- kernel_branched_path_surface_connect_light(kg, &rng,
+ kernel_branched_path_surface_connect_light(kg,
sd, &emission_sd, &state, throughput, 1.0f, &L_sample, all);
}
#endif
/* indirect light */
- kernel_branched_path_surface_indirect_light(kg, &rng,
+ kernel_branched_path_surface_indirect_light(kg,
sd, &indirect_sd, &emission_sd, throughput, 1.0f, &state, &L_sample);
}
}
#endif
/* accumulate into master L */
- path_radiance_accum_sample(L, &L_sample, 1);
+ path_radiance_accum_sample(L, &L_sample);
}
ccl_device bool is_aa_pass(ShaderEvalType type)
@@ -225,7 +220,6 @@ ccl_device_inline float3 kernel_bake_shader_bsdf(KernelGlobals *kg,
ccl_device float3 kernel_bake_evaluate_direct_indirect(KernelGlobals *kg,
ShaderData *sd,
- RNG *rng,
PathState *state,
float3 direct,
float3 indirect,
@@ -245,12 +239,12 @@ ccl_device float3 kernel_bake_evaluate_direct_indirect(KernelGlobals *kg,
}
else {
/* surface color of the pass only */
- shader_eval_surface(kg, sd, rng, state, 0.0f, 0, SHADER_CONTEXT_MAIN);
+ shader_eval_surface(kg, sd, state, 0);
return kernel_bake_shader_bsdf(kg, sd, type);
}
}
else {
- shader_eval_surface(kg, sd, rng, state, 0.0f, 0, SHADER_CONTEXT_MAIN);
+ shader_eval_surface(kg, sd, state, 0);
color = kernel_bake_shader_bsdf(kg, sd, type);
}
@@ -292,14 +286,14 @@ ccl_device void kernel_bake_evaluate(KernelGlobals *kg, ccl_global uint4 *input,
int num_samples = kernel_data.integrator.aa_samples;
/* random number generator */
- RNG rng = cmj_hash(offset + i, kernel_data.integrator.seed);
+ uint rng_hash = cmj_hash(offset + i, kernel_data.integrator.seed);
float filter_x, filter_y;
if(sample == 0) {
filter_x = filter_y = 0.5f;
}
else {
- path_rng_2D(kg, &rng, sample, num_samples, PRNG_FILTER_U, &filter_x, &filter_y);
+ path_rng_2D(kg, rng_hash, sample, num_samples, PRNG_FILTER_U, &filter_x, &filter_y);
}
/* subpixel u/v offset */
@@ -335,18 +329,20 @@ ccl_device void kernel_bake_evaluate(KernelGlobals *kg, ccl_global uint4 *input,
/* light passes if we need more than color */
if(pass_filter & ~BAKE_FILTER_COLOR)
- compute_light_pass(kg, &sd, &L, rng, pass_filter, sample);
+ compute_light_pass(kg, &sd, &L, rng_hash, pass_filter, sample);
switch(type) {
/* data passes */
case SHADER_EVAL_NORMAL:
{
+ float3 N = sd.N;
if((sd.flag & SD_HAS_BUMP)) {
- shader_eval_surface(kg, &sd, &rng, &state, 0.f, 0, SHADER_CONTEXT_MAIN);
+ shader_eval_surface(kg, &sd, &state, 0);
+ N = shader_bsdf_average_normal(kg, &sd);
}
- /* compression: normal = (2 * color) - 1 */
- out = sd.N * 0.5f + make_float3(0.5f, 0.5f, 0.5f);
+ /* encoding: normal = (2 * color) - 1 */
+ out = N * 0.5f + make_float3(0.5f, 0.5f, 0.5f);
break;
}
case SHADER_EVAL_UV:
@@ -356,7 +352,7 @@ ccl_device void kernel_bake_evaluate(KernelGlobals *kg, ccl_global uint4 *input,
}
case SHADER_EVAL_EMISSION:
{
- shader_eval_surface(kg, &sd, &rng, &state, 0.f, 0, SHADER_CONTEXT_EMISSION);
+ shader_eval_surface(kg, &sd, &state, 0);
out = shader_emissive_eval(kg, &sd);
break;
}
@@ -371,7 +367,8 @@ ccl_device void kernel_bake_evaluate(KernelGlobals *kg, ccl_global uint4 *input,
case SHADER_EVAL_COMBINED:
{
if((pass_filter & BAKE_FILTER_COMBINED) == BAKE_FILTER_COMBINED) {
- out = path_radiance_clamp_and_sum(kg, &L);
+ float alpha;
+ out = path_radiance_clamp_and_sum(kg, &L, &alpha);
break;
}
@@ -409,7 +406,6 @@ ccl_device void kernel_bake_evaluate(KernelGlobals *kg, ccl_global uint4 *input,
{
out = kernel_bake_evaluate_direct_indirect(kg,
&sd,
- &rng,
&state,
L.direct_diffuse,
L.indirect_diffuse,
@@ -421,7 +417,6 @@ ccl_device void kernel_bake_evaluate(KernelGlobals *kg, ccl_global uint4 *input,
{
out = kernel_bake_evaluate_direct_indirect(kg,
&sd,
- &rng,
&state,
L.direct_glossy,
L.indirect_glossy,
@@ -433,7 +428,6 @@ ccl_device void kernel_bake_evaluate(KernelGlobals *kg, ccl_global uint4 *input,
{
out = kernel_bake_evaluate_direct_indirect(kg,
&sd,
- &rng,
&state,
L.direct_transmission,
L.indirect_transmission,
@@ -446,7 +440,6 @@ ccl_device void kernel_bake_evaluate(KernelGlobals *kg, ccl_global uint4 *input,
#ifdef __SUBSURFACE__
out = kernel_bake_evaluate_direct_indirect(kg,
&sd,
- &rng,
&state,
L.direct_subsurface,
L.indirect_subsurface,
@@ -480,7 +473,7 @@ ccl_device void kernel_bake_evaluate(KernelGlobals *kg, ccl_global uint4 *input,
/* evaluate */
int flag = 0; /* we can't know which type of BSDF this is for */
- out = shader_eval_background(kg, &sd, &state, flag, SHADER_CONTEXT_MAIN);
+ out = shader_eval_background(kg, &sd, &state, flag);
break;
}
default:
@@ -500,78 +493,69 @@ ccl_device void kernel_bake_evaluate(KernelGlobals *kg, ccl_global uint4 *input,
#endif /* __BAKING__ */
-ccl_device void kernel_shader_evaluate(KernelGlobals *kg,
- ccl_global uint4 *input,
- ccl_global float4 *output,
- ccl_global float *output_luma,
- ShaderEvalType type,
- int i,
- int sample)
+ccl_device void kernel_displace_evaluate(KernelGlobals *kg,
+ ccl_global uint4 *input,
+ ccl_global float4 *output,
+ int i)
{
ShaderData sd;
PathState state = {0};
uint4 in = input[i];
- float3 out;
- if(type == SHADER_EVAL_DISPLACE) {
- /* setup shader data */
- int object = in.x;
- int prim = in.y;
- float u = __uint_as_float(in.z);
- float v = __uint_as_float(in.w);
+ /* setup shader data */
+ int object = in.x;
+ int prim = in.y;
+ float u = __uint_as_float(in.z);
+ float v = __uint_as_float(in.w);
- shader_setup_from_displace(kg, &sd, object, prim, u, v);
+ shader_setup_from_displace(kg, &sd, object, prim, u, v);
- /* evaluate */
- float3 P = sd.P;
- shader_eval_displacement(kg, &sd, &state, SHADER_CONTEXT_MAIN);
- out = sd.P - P;
+ /* evaluate */
+ float3 P = sd.P;
+ shader_eval_displacement(kg, &sd, &state);
+ float3 D = sd.P - P;
- object_inverse_dir_transform(kg, &sd, &out);
- }
- else { // SHADER_EVAL_BACKGROUND
- /* setup ray */
- Ray ray;
- float u = __uint_as_float(in.x);
- float v = __uint_as_float(in.y);
-
- ray.P = make_float3(0.0f, 0.0f, 0.0f);
- ray.D = equirectangular_to_direction(u, v);
- ray.t = 0.0f;
+ object_inverse_dir_transform(kg, &sd, &D);
+
+ /* write output */
+ output[i] += make_float4(D.x, D.y, D.z, 0.0f);
+}
+
+ccl_device void kernel_background_evaluate(KernelGlobals *kg,
+ ccl_global uint4 *input,
+ ccl_global float4 *output,
+ int i)
+{
+ ShaderData sd;
+ PathState state = {0};
+ uint4 in = input[i];
+
+ /* setup ray */
+ Ray ray;
+ float u = __uint_as_float(in.x);
+ float v = __uint_as_float(in.y);
+
+ ray.P = make_float3(0.0f, 0.0f, 0.0f);
+ ray.D = equirectangular_to_direction(u, v);
+ ray.t = 0.0f;
#ifdef __CAMERA_MOTION__
- ray.time = 0.5f;
+ ray.time = 0.5f;
#endif
#ifdef __RAY_DIFFERENTIALS__
- ray.dD = differential3_zero();
- ray.dP = differential3_zero();
+ ray.dD = differential3_zero();
+ ray.dP = differential3_zero();
#endif
- /* setup shader data */
- shader_setup_from_background(kg, &sd, &ray);
+ /* setup shader data */
+ shader_setup_from_background(kg, &sd, &ray);
+
+ /* evaluate */
+ int flag = 0; /* we can't know which type of BSDF this is for */
+ float3 color = shader_eval_background(kg, &sd, &state, flag);
- /* evaluate */
- int flag = 0; /* we can't know which type of BSDF this is for */
- out = shader_eval_background(kg, &sd, &state, flag, SHADER_CONTEXT_MAIN);
- }
-
/* write output */
- if(sample == 0) {
- if(output != NULL) {
- output[i] = make_float4(out.x, out.y, out.z, 0.0f);
- }
- if(output_luma != NULL) {
- output_luma[i] = average(out);
- }
- }
- else {
- if(output != NULL) {
- output[i] += make_float4(out.x, out.y, out.z, 0.0f);
- }
- if(output_luma != NULL) {
- output_luma[i] += average(out);
- }
- }
+ output[i] += make_float4(color.x, color.y, color.z, 0.0f);
}
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/kernel_compat_cuda.h b/intern/cycles/kernel/kernel_compat_cuda.h
index 38708f7ff0b..2e8ca48c413 100644
--- a/intern/cycles/kernel/kernel_compat_cuda.h
+++ b/intern/cycles/kernel/kernel_compat_cuda.h
@@ -38,21 +38,30 @@
/* Qualifier wrappers for different names on different devices */
#define ccl_device __device__ __inline__
+#if __CUDA_ARCH__ < 300
+# define ccl_device_inline __device__ __inline__
# define ccl_device_forceinline __device__ __forceinline__
-#if __CUDA_ARCH__ < 500
+#elif __CUDA_ARCH__ < 500
# define ccl_device_inline __device__ __forceinline__
+# define ccl_device_forceinline __device__ __forceinline__
#else
# define ccl_device_inline __device__ __inline__
+# define ccl_device_forceinline __device__ __forceinline__
#endif
#define ccl_device_noinline __device__ __noinline__
#define ccl_global
-#define ccl_constant
+#define ccl_static_constant __constant__
+#define ccl_constant const
#define ccl_local __shared__
#define ccl_local_param
#define ccl_private
#define ccl_may_alias
#define ccl_addr_space
#define ccl_restrict __restrict__
+/* TODO(sergey): In theory we might use references with CUDA, however
+ * performance impact yet to be investigated.
+ */
+#define ccl_ref
#define ccl_align(n) __align__(n)
#define ATTR_FALLTHROUGH
diff --git a/intern/cycles/kernel/kernel_compat_opencl.h b/intern/cycles/kernel/kernel_compat_opencl.h
index 4836c290312..7f81523791b 100644
--- a/intern/cycles/kernel/kernel_compat_opencl.h
+++ b/intern/cycles/kernel/kernel_compat_opencl.h
@@ -36,12 +36,14 @@
#define ccl_device_forceinline ccl_device
#define ccl_device_noinline ccl_device ccl_noinline
#define ccl_may_alias
+#define ccl_static_constant static __constant
#define ccl_constant __constant
#define ccl_global __global
#define ccl_local __local
#define ccl_local_param __local
#define ccl_private __private
#define ccl_restrict restrict
+#define ccl_ref
#define ccl_align(n) __attribute__((aligned(n)))
#ifdef __SPLIT_KERNEL__
@@ -129,6 +131,7 @@
# define expf(x) native_exp(((float)(x)))
# define sqrtf(x) native_sqrt(((float)(x)))
# define logf(x) native_log(((float)(x)))
+# define rcp(x) native_recip(x)
#else
# define sinf(x) sin(((float)(x)))
# define cosf(x) cos(((float)(x)))
@@ -136,11 +139,12 @@
# define expf(x) exp(((float)(x)))
# define sqrtf(x) sqrt(((float)(x)))
# define logf(x) log(((float)(x)))
+# define rcp(x) recip(x))
#endif
/* data lookup defines */
#define kernel_data (*kg->data)
-#define kernel_tex_fetch(t, index) kg->t[index]
+#define kernel_tex_fetch(tex, index) ((ccl_global tex##_t*)(kg->buffers[kg->tex.buffer] + kg->tex.offset))[(index)]
/* define NULL */
#define NULL 0
diff --git a/intern/cycles/kernel/kernel_debug.h b/intern/cycles/kernel/kernel_debug.h
deleted file mode 100644
index 5647bbae5b5..00000000000
--- a/intern/cycles/kernel/kernel_debug.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2011-2014 Blender Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-CCL_NAMESPACE_BEGIN
-
-ccl_device_inline void debug_data_init(DebugData *debug_data)
-{
- debug_data->num_bvh_traversed_nodes = 0;
- debug_data->num_bvh_traversed_instances = 0;
- debug_data->num_bvh_intersections = 0;
- debug_data->num_ray_bounces = 0;
-}
-
-ccl_device_inline void kernel_write_debug_passes(KernelGlobals *kg,
- ccl_global float *buffer,
- ccl_addr_space PathState *state,
- DebugData *debug_data,
- int sample)
-{
- int flag = kernel_data.film.pass_flag;
- if(flag & PASS_BVH_TRAVERSED_NODES) {
- kernel_write_pass_float(buffer + kernel_data.film.pass_bvh_traversed_nodes,
- sample,
- debug_data->num_bvh_traversed_nodes);
- }
- if(flag & PASS_BVH_TRAVERSED_INSTANCES) {
- kernel_write_pass_float(buffer + kernel_data.film.pass_bvh_traversed_instances,
- sample,
- debug_data->num_bvh_traversed_instances);
- }
- if(flag & PASS_BVH_INTERSECTIONS) {
- kernel_write_pass_float(buffer + kernel_data.film.pass_bvh_intersections,
- sample,
- debug_data->num_bvh_intersections);
- }
- if(flag & PASS_RAY_BOUNCES) {
- kernel_write_pass_float(buffer + kernel_data.film.pass_ray_bounces,
- sample,
- debug_data->num_ray_bounces);
- }
-}
-
-CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/kernel_emission.h b/intern/cycles/kernel/kernel_emission.h
index 9e7d51f23f5..45b8c6311e1 100644
--- a/intern/cycles/kernel/kernel_emission.h
+++ b/intern/cycles/kernel/kernel_emission.h
@@ -37,16 +37,14 @@ ccl_device_noinline float3 direct_emissive_eval(KernelGlobals *kg,
ray.D = ls->D;
ray.P = ls->P;
ray.t = 1.0f;
-# ifdef __OBJECT_MOTION__
ray.time = time;
-# endif
ray.dP = differential3_zero();
ray.dD = dI;
shader_setup_from_background(kg, emission_sd, &ray);
path_state_modify_bounce(state, true);
- eval = shader_eval_background(kg, emission_sd, state, 0, SHADER_CONTEXT_EMISSION);
+ eval = shader_eval_background(kg, emission_sd, state, 0);
path_state_modify_bounce(state, false);
}
else
@@ -72,7 +70,7 @@ ccl_device_noinline float3 direct_emissive_eval(KernelGlobals *kg,
/* no path flag, we're evaluating this for all closures. that's weak but
* we'd have to do multiple evaluations otherwise */
path_state_modify_bounce(state, true);
- shader_eval_surface(kg, emission_sd, NULL, state, 0.0f, 0, SHADER_CONTEXT_EMISSION);
+ shader_eval_surface(kg, emission_sd, state, 0);
path_state_modify_bounce(state, false);
/* evaluate emissive closure */
@@ -216,7 +214,7 @@ ccl_device_noinline float3 indirect_primitive_emission(KernelGlobals *kg, Shader
{
/* multiple importance sampling, get triangle light pdf,
* and compute weight with respect to BSDF pdf */
- float pdf = triangle_light_pdf(kg, sd->Ng, sd->I, t);
+ float pdf = triangle_light_pdf(kg, sd, t);
float mis_weight = power_heuristic(bsdf_pdf, pdf);
return L*mis_weight;
@@ -319,7 +317,7 @@ ccl_device_noinline float3 indirect_background(KernelGlobals *kg,
# endif
path_state_modify_bounce(state, true);
- float3 L = shader_eval_background(kg, emission_sd, state, state->flag, SHADER_CONTEXT_EMISSION);
+ float3 L = shader_eval_background(kg, emission_sd, state, state->flag);
path_state_modify_bounce(state, false);
#ifdef __BACKGROUND_MIS__
diff --git a/intern/cycles/kernel/kernel_globals.h b/intern/cycles/kernel/kernel_globals.h
index f95f0d98c52..9d55183d94b 100644
--- a/intern/cycles/kernel/kernel_globals.h
+++ b/intern/cycles/kernel/kernel_globals.h
@@ -23,6 +23,10 @@
# include "util/util_vector.h"
#endif
+#ifdef __KERNEL_OPENCL__
+# include "util/util_atomic.h"
+#endif
+
CCL_NAMESPACE_BEGIN
/* On the CPU, we pass along the struct KernelGlobals to nearly everywhere in
@@ -109,11 +113,22 @@ typedef struct KernelGlobals {
#ifdef __KERNEL_OPENCL__
+# define KERNEL_TEX(type, ttype, name) \
+typedef type name##_t;
+# include "kernel/kernel_textures.h"
+
+typedef struct tex_info_t {
+ uint buffer, padding;
+ uint64_t offset;
+ uint width, height, depth, options;
+} tex_info_t;
+
typedef ccl_addr_space struct KernelGlobals {
ccl_constant KernelData *data;
+ ccl_global char *buffers[8];
# define KERNEL_TEX(type, ttype, name) \
- ccl_global type *name;
+ tex_info_t name;
# include "kernel/kernel_textures.h"
# ifdef __SPLIT_KERNEL__
@@ -122,6 +137,57 @@ typedef ccl_addr_space struct KernelGlobals {
# endif
} KernelGlobals;
+#define KERNEL_BUFFER_PARAMS \
+ ccl_global char *buffer0, \
+ ccl_global char *buffer1, \
+ ccl_global char *buffer2, \
+ ccl_global char *buffer3, \
+ ccl_global char *buffer4, \
+ ccl_global char *buffer5, \
+ ccl_global char *buffer6, \
+ ccl_global char *buffer7
+
+#define KERNEL_BUFFER_ARGS buffer0, buffer1, buffer2, buffer3, buffer4, buffer5, buffer6, buffer7
+
+ccl_device_inline void kernel_set_buffer_pointers(KernelGlobals *kg, KERNEL_BUFFER_PARAMS)
+{
+#ifdef __SPLIT_KERNEL__
+ if(ccl_local_id(0) + ccl_local_id(1) == 0)
+#endif
+ {
+ kg->buffers[0] = buffer0;
+ kg->buffers[1] = buffer1;
+ kg->buffers[2] = buffer2;
+ kg->buffers[3] = buffer3;
+ kg->buffers[4] = buffer4;
+ kg->buffers[5] = buffer5;
+ kg->buffers[6] = buffer6;
+ kg->buffers[7] = buffer7;
+ }
+
+# ifdef __SPLIT_KERNEL__
+ ccl_barrier(CCL_LOCAL_MEM_FENCE);
+# endif
+}
+
+ccl_device_inline void kernel_set_buffer_info(KernelGlobals *kg)
+{
+# ifdef __SPLIT_KERNEL__
+ if(ccl_local_id(0) + ccl_local_id(1) == 0)
+# endif
+ {
+ ccl_global tex_info_t *info = (ccl_global tex_info_t*)kg->buffers[0];
+
+# define KERNEL_TEX(type, ttype, name) \
+ kg->name = *(info++);
+# include "kernel/kernel_textures.h"
+ }
+
+# ifdef __SPLIT_KERNEL__
+ ccl_barrier(CCL_LOCAL_MEM_FENCE);
+# endif
+}
+
#endif /* __KERNEL_OPENCL__ */
/* Interpolated lookup table access */
diff --git a/intern/cycles/kernel/kernel_image_opencl.h b/intern/cycles/kernel/kernel_image_opencl.h
index 90747e09357..9e3373432ec 100644
--- a/intern/cycles/kernel/kernel_image_opencl.h
+++ b/intern/cycles/kernel/kernel_image_opencl.h
@@ -15,30 +15,42 @@
*/
-/* For OpenCL all images are packed in a single array, and we do manual lookup
- * and interpolation. */
+/* For OpenCL we do manual lookup and interpolation. */
+
+ccl_device_inline ccl_global tex_info_t* kernel_tex_info(KernelGlobals *kg, uint id) {
+ const uint tex_offset = id
+#define KERNEL_TEX(type, ttype, name) + 1
+#include "kernel/kernel_textures.h"
+ ;
+
+ return &((ccl_global tex_info_t*)kg->buffers[0])[tex_offset];
+}
+
+#define tex_fetch(type, info, index) ((ccl_global type*)(kg->buffers[info->buffer] + info->offset))[(index)]
ccl_device_inline float4 svm_image_texture_read(KernelGlobals *kg, int id, int offset)
{
+ const ccl_global tex_info_t *info = kernel_tex_info(kg, id);
const int texture_type = kernel_tex_type(id);
+
/* Float4 */
if(texture_type == IMAGE_DATA_TYPE_FLOAT4) {
- return kernel_tex_fetch(__tex_image_float4_packed, offset);
+ return tex_fetch(float4, info, offset);
}
/* Byte4 */
else if(texture_type == IMAGE_DATA_TYPE_BYTE4) {
- uchar4 r = kernel_tex_fetch(__tex_image_byte4_packed, offset);
+ uchar4 r = tex_fetch(uchar4, info, offset);
float f = 1.0f/255.0f;
return make_float4(r.x*f, r.y*f, r.z*f, r.w*f);
}
/* Float */
else if(texture_type == IMAGE_DATA_TYPE_FLOAT) {
- float f = kernel_tex_fetch(__tex_image_float_packed, offset);
+ float f = tex_fetch(float, info, offset);
return make_float4(f, f, f, 1.0f);
}
/* Byte */
else {
- uchar r = kernel_tex_fetch(__tex_image_byte_packed, offset);
+ uchar r = tex_fetch(uchar, info, offset);
float f = r * (1.0f/255.0f);
return make_float4(f, f, f, 1.0f);
}
@@ -64,17 +76,17 @@ ccl_device_inline float svm_image_texture_frac(float x, int *ix)
return x - (float)i;
}
-ccl_device_inline uint kernel_decode_image_interpolation(uint4 info)
+ccl_device_inline uint kernel_decode_image_interpolation(uint info)
{
- return (info.w & (1 << 0)) ? INTERPOLATION_CLOSEST : INTERPOLATION_LINEAR;
+ return (info & (1 << 0)) ? INTERPOLATION_CLOSEST : INTERPOLATION_LINEAR;
}
-ccl_device_inline uint kernel_decode_image_extension(uint4 info)
+ccl_device_inline uint kernel_decode_image_extension(uint info)
{
- if(info.w & (1 << 1)) {
+ if(info & (1 << 1)) {
return EXTENSION_REPEAT;
}
- else if(info.w & (1 << 2)) {
+ else if(info & (1 << 2)) {
return EXTENSION_EXTEND;
}
else {
@@ -84,13 +96,16 @@ ccl_device_inline uint kernel_decode_image_extension(uint4 info)
ccl_device float4 kernel_tex_image_interp(KernelGlobals *kg, int id, float x, float y)
{
- uint4 info = kernel_tex_fetch(__tex_image_packed_info, id*2);
- uint width = info.x;
- uint height = info.y;
- uint offset = info.z;
+ const ccl_global tex_info_t *info = kernel_tex_info(kg, id);
+
+ uint width = info->width;
+ uint height = info->height;
+ uint offset = 0;
+
/* Decode image options. */
- uint interpolation = kernel_decode_image_interpolation(info);
- uint extension = kernel_decode_image_extension(info);
+ uint interpolation = kernel_decode_image_interpolation(info->options);
+ uint extension = kernel_decode_image_extension(info->options);
+
/* Actual sampling. */
float4 r;
int ix, iy, nix, niy;
@@ -150,14 +165,17 @@ ccl_device float4 kernel_tex_image_interp(KernelGlobals *kg, int id, float x, fl
ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals *kg, int id, float x, float y, float z)
{
- uint4 info = kernel_tex_fetch(__tex_image_packed_info, id*2);
- uint width = info.x;
- uint height = info.y;
- uint offset = info.z;
- uint depth = kernel_tex_fetch(__tex_image_packed_info, id*2+1).x;
+ const ccl_global tex_info_t *info = kernel_tex_info(kg, id);
+
+ uint width = info->width;
+ uint height = info->height;
+ uint offset = 0;
+ uint depth = info->depth;
+
/* Decode image options. */
- uint interpolation = kernel_decode_image_interpolation(info);
- uint extension = kernel_decode_image_extension(info);
+ uint interpolation = kernel_decode_image_interpolation(info->options);
+ uint extension = kernel_decode_image_extension(info->options);
+
/* Actual sampling. */
float4 r;
int ix, iy, iz, nix, niy, niz;
diff --git a/intern/cycles/kernel/kernel_light.h b/intern/cycles/kernel/kernel_light.h
index 9baa9d54957..c806deee8e7 100644
--- a/intern/cycles/kernel/kernel_light.h
+++ b/intern/cycles/kernel/kernel_light.h
@@ -396,11 +396,13 @@ ccl_device_inline float3 background_light_sample(KernelGlobals *kg,
+ (1.0f - portal_sampling_pdf) * cdf_pdf);
}
return D;
- } else {
+ }
+ else {
/* Sample map, but with nonzero portal_sampling_pdf for MIS. */
randu = (randu - portal_sampling_pdf) / (1.0f - portal_sampling_pdf);
}
- } else {
+ }
+ else {
/* We can't sample a portal.
* Check if we can sample the map instead.
*/
@@ -763,78 +765,280 @@ ccl_device bool lamp_light_eval(KernelGlobals *kg, int lamp, float3 P, float3 D,
/* Triangle Light */
-ccl_device void object_transform_light_sample(KernelGlobals *kg, LightSample *ls, int object, float time)
+/* returns true if the triangle is has motion blur or an instancing transform applied */
+ccl_device_inline bool triangle_world_space_vertices(KernelGlobals *kg, int object, int prim, float time, float3 V[3])
{
+ bool has_motion = false;
+ const int object_flag = kernel_tex_fetch(__object_flag, object);
+
+ if(object_flag & SD_OBJECT_HAS_VERTEX_MOTION && time >= 0.0f) {
+ motion_triangle_vertices(kg, object, prim, time, V);
+ has_motion = true;
+ }
+ else {
+ triangle_vertices(kg, prim, V);
+ }
+
#ifdef __INSTANCING__
- /* instance transform */
- if(!(kernel_tex_fetch(__object_flag, object) & SD_OBJECT_TRANSFORM_APPLIED)) {
+ if(!(object_flag & SD_OBJECT_TRANSFORM_APPLIED)) {
# ifdef __OBJECT_MOTION__
- Transform itfm;
- Transform tfm = object_fetch_transform_motion_test(kg, object, time, &itfm);
+ Transform tfm = object_fetch_transform_motion_test(kg, object, time, NULL);
# else
Transform tfm = object_fetch_transform(kg, object, OBJECT_TRANSFORM);
# endif
-
- ls->P = transform_point(&tfm, ls->P);
- ls->Ng = normalize(transform_direction(&tfm, ls->Ng));
+ V[0] = transform_point(&tfm, V[0]);
+ V[1] = transform_point(&tfm, V[1]);
+ V[2] = transform_point(&tfm, V[2]);
+ has_motion = true;
}
#endif
+ return has_motion;
}
-ccl_device void triangle_light_sample(KernelGlobals *kg, int prim, int object,
- float randu, float randv, float time, LightSample *ls)
+ccl_device_inline float triangle_light_pdf_area(KernelGlobals *kg, const float3 Ng, const float3 I, float t)
{
- float u, v;
+ float pdf = kernel_data.integrator.pdf_triangles;
+ float cos_pi = fabsf(dot(Ng, I));
- /* compute random point in triangle */
- randu = sqrtf(randu);
+ if(cos_pi == 0.0f)
+ return 0.0f;
+
+ return t*t*pdf/cos_pi;
+}
- u = 1.0f - randu;
- v = randv*randu;
+ccl_device_forceinline float triangle_light_pdf(KernelGlobals *kg, ShaderData *sd, float t)
+{
+ /* A naive heuristic to decide between costly solid angle sampling
+ * and simple area sampling, comparing the distance to the triangle plane
+ * to the length of the edges of the triangle. */
+
+ float3 V[3];
+ bool has_motion = triangle_world_space_vertices(kg, sd->object, sd->prim, sd->time, V);
+
+ const float3 e0 = V[1] - V[0];
+ const float3 e1 = V[2] - V[0];
+ const float3 e2 = V[2] - V[1];
+ const float longest_edge_squared = max(len_squared(e0), max(len_squared(e1), len_squared(e2)));
+ const float3 N = cross(e0, e1);
+ const float distance_to_plane = fabsf(dot(N, sd->I * t))/dot(N, N);
+
+ if(longest_edge_squared > distance_to_plane*distance_to_plane) {
+ /* sd contains the point on the light source
+ * calculate Px, the point that we're shading */
+ const float3 Px = sd->P + sd->I * t;
+ const float3 v0_p = V[0] - Px;
+ const float3 v1_p = V[1] - Px;
+ const float3 v2_p = V[2] - Px;
+
+ const float3 u01 = safe_normalize(cross(v0_p, v1_p));
+ const float3 u02 = safe_normalize(cross(v0_p, v2_p));
+ const float3 u12 = safe_normalize(cross(v1_p, v2_p));
+
+ const float alpha = fast_acosf(dot(u02, u01));
+ const float beta = fast_acosf(-dot(u01, u12));
+ const float gamma = fast_acosf(dot(u02, u12));
+ const float solid_angle = alpha + beta + gamma - M_PI_F;
+
+ /* pdf_triangles is calculated over triangle area, but we're not sampling over its area */
+ if(UNLIKELY(solid_angle == 0.0f)) {
+ return 0.0f;
+ }
+ else {
+ float area = 1.0f;
+ if(has_motion) {
+ /* get the center frame vertices, this is what the PDF was calculated from */
+ triangle_world_space_vertices(kg, sd->object, sd->prim, -1.0f, V);
+ area = triangle_area(V[0], V[1], V[2]);
+ }
+ else {
+ area = 0.5f * len(N);
+ }
+ const float pdf = area * kernel_data.integrator.pdf_triangles;
+ return pdf / solid_angle;
+ }
+ }
+ else {
+ float pdf = triangle_light_pdf_area(kg, sd->Ng, sd->I, t);
+ if(has_motion) {
+ const float area = 0.5f * len(N);
+ if(UNLIKELY(area == 0.0f)) {
+ return 0.0f;
+ }
+ /* scale the PDF.
+ * area = the area the sample was taken from
+ * area_pre = the are from which pdf_triangles was calculated from */
+ triangle_world_space_vertices(kg, sd->object, sd->prim, -1.0f, V);
+ const float area_pre = triangle_area(V[0], V[1], V[2]);
+ pdf = pdf * area_pre / area;
+ }
+ return pdf;
+ }
+}
- /* triangle, so get position, normal, shader */
- triangle_point_normal(kg, object, prim, u, v, &ls->P, &ls->Ng, &ls->shader);
+ccl_device_forceinline void triangle_light_sample(KernelGlobals *kg, int prim, int object,
+ float randu, float randv, float time, LightSample *ls, const float3 P)
+{
+ /* A naive heuristic to decide between costly solid angle sampling
+ * and simple area sampling, comparing the distance to the triangle plane
+ * to the length of the edges of the triangle. */
+
+ float3 V[3];
+ bool has_motion = triangle_world_space_vertices(kg, object, prim, time, V);
+
+ const float3 e0 = V[1] - V[0];
+ const float3 e1 = V[2] - V[0];
+ const float3 e2 = V[2] - V[1];
+ const float longest_edge_squared = max(len_squared(e0), max(len_squared(e1), len_squared(e2)));
+ const float3 N0 = cross(e0, e1);
+ float Nl = 0.0f;
+ ls->Ng = safe_normalize_len(N0, &Nl);
+ float area = 0.5f * Nl;
+
+ /* flip normal if necessary */
+ const int object_flag = kernel_tex_fetch(__object_flag, object);
+ if(object_flag & SD_OBJECT_NEGATIVE_SCALE_APPLIED) {
+ ls->Ng = -ls->Ng;
+ }
+ ls->eval_fac = 1.0f;
+ ls->shader = kernel_tex_fetch(__tri_shader, prim);
ls->object = object;
ls->prim = prim;
ls->lamp = LAMP_NONE;
ls->shader |= SHADER_USE_MIS;
- ls->t = 0.0f;
- ls->u = u;
- ls->v = v;
ls->type = LIGHT_TRIANGLE;
- ls->eval_fac = 1.0f;
- object_transform_light_sample(kg, ls, object, time);
-}
+ float distance_to_plane = fabsf(dot(N0, V[0] - P)/dot(N0, N0));
+
+ if(longest_edge_squared > distance_to_plane*distance_to_plane) {
+ /* see James Arvo, "Stratified Sampling of Spherical Triangles"
+ * http://www.graphics.cornell.edu/pubs/1995/Arv95c.pdf */
+
+ /* project the triangle to the unit sphere
+ * and calculate its edges and angles */
+ const float3 v0_p = V[0] - P;
+ const float3 v1_p = V[1] - P;
+ const float3 v2_p = V[2] - P;
+
+ const float3 u01 = safe_normalize(cross(v0_p, v1_p));
+ const float3 u02 = safe_normalize(cross(v0_p, v2_p));
+ const float3 u12 = safe_normalize(cross(v1_p, v2_p));
+
+ const float3 A = safe_normalize(v0_p);
+ const float3 B = safe_normalize(v1_p);
+ const float3 C = safe_normalize(v2_p);
+
+ const float cos_alpha = dot(u02, u01);
+ const float cos_beta = -dot(u01, u12);
+ const float cos_gamma = dot(u02, u12);
+
+ /* calculate dihedral angles */
+ const float alpha = fast_acosf(cos_alpha);
+ const float beta = fast_acosf(cos_beta);
+ const float gamma = fast_acosf(cos_gamma);
+ /* the area of the unit spherical triangle = solid angle */
+ const float solid_angle = alpha + beta + gamma - M_PI_F;
+
+ /* precompute a few things
+ * these could be re-used to take several samples
+ * as they are independent of randu/randv */
+ const float cos_c = dot(A, B);
+ const float sin_alpha = fast_sinf(alpha);
+ const float product = sin_alpha * cos_c;
+
+ /* Select a random sub-area of the spherical triangle
+ * and calculate the third vertex C_ of that new triangle */
+ const float phi = randu * solid_angle - alpha;
+ float s, t;
+ fast_sincosf(phi, &s, &t);
+ const float u = t - cos_alpha;
+ const float v = s + product;
+
+ const float3 U = safe_normalize(C - dot(C, A) * A);
+
+ float q = 1.0f;
+ const float det = ((v * s + u * t) * sin_alpha);
+ if(det != 0.0f) {
+ q = ((v * t - u * s) * cos_alpha - v) / det;
+ }
+ const float temp = max(1.0f - q*q, 0.0f);
-ccl_device float triangle_light_pdf(KernelGlobals *kg,
- const float3 Ng, const float3 I, float t)
-{
- float pdf = kernel_data.integrator.pdf_triangles;
- float cos_pi = fabsf(dot(Ng, I));
+ const float3 C_ = safe_normalize(q * A + sqrtf(temp) * U);
- if(cos_pi == 0.0f)
- return 0.0f;
-
- return t*t*pdf/cos_pi;
+ /* Finally, select a random point along the edge of the new triangle
+ * That point on the spherical triangle is the sampled ray direction */
+ const float z = 1.0f - randv * (1.0f - dot(C_, B));
+ ls->D = z * B + safe_sqrtf(1.0f - z*z) * safe_normalize(C_ - dot(C_, B) * B);
+
+ /* calculate intersection with the planar triangle */
+ if(!ray_triangle_intersect(P, ls->D, FLT_MAX,
+#if defined(__KERNEL_SSE2__) && defined(__KERNEL_SSE__)
+ (ssef*)V,
+#else
+ V[0], V[1], V[2],
+#endif
+ &ls->u, &ls->v, &ls->t)) {
+ ls->pdf = 0.0f;
+ return;
+ }
+
+ ls->P = P + ls->D * ls->t;
+
+ /* pdf_triangles is calculated over triangle area, but we're sampling over solid angle */
+ if(UNLIKELY(solid_angle == 0.0f)) {
+ ls->pdf = 0.0f;
+ return;
+ }
+ else {
+ if(has_motion) {
+ /* get the center frame vertices, this is what the PDF was calculated from */
+ triangle_world_space_vertices(kg, object, prim, -1.0f, V);
+ area = triangle_area(V[0], V[1], V[2]);
+ }
+ const float pdf = area * kernel_data.integrator.pdf_triangles;
+ ls->pdf = pdf / solid_angle;
+ }
+ }
+ else {
+ /* compute random point in triangle */
+ randu = sqrtf(randu);
+
+ const float u = 1.0f - randu;
+ const float v = randv*randu;
+ const float t = 1.0f - u - v;
+ ls->P = u * V[0] + v * V[1] + t * V[2];
+ /* compute incoming direction, distance and pdf */
+ ls->D = normalize_len(ls->P - P, &ls->t);
+ ls->pdf = triangle_light_pdf_area(kg, ls->Ng, -ls->D, ls->t);
+ if(has_motion && area != 0.0f) {
+ /* scale the PDF.
+ * area = the area the sample was taken from
+ * area_pre = the are from which pdf_triangles was calculated from */
+ triangle_world_space_vertices(kg, object, prim, -1.0f, V);
+ const float area_pre = triangle_area(V[0], V[1], V[2]);
+ ls->pdf = ls->pdf * area_pre / area;
+ }
+ ls->u = u;
+ ls->v = v;
+ }
}
/* Light Distribution */
-ccl_device int light_distribution_sample(KernelGlobals *kg, float randt)
+ccl_device int light_distribution_sample(KernelGlobals *kg, float *randu)
{
- /* this is basically std::upper_bound as used by pbrt, to find a point light or
+ /* This is basically std::upper_bound as used by pbrt, to find a point light or
* triangle to emit from, proportional to area. a good improvement would be to
* also sample proportional to power, though it's not so well defined with
- * OSL shaders. */
+ * arbitrary shaders. */
int first = 0;
int len = kernel_data.integrator.num_distribution + 1;
+ float r = *randu;
while(len > 0) {
int half_len = len >> 1;
int middle = first + half_len;
- if(randt < kernel_tex_fetch(__light_distribution, middle).x) {
+ if(r < kernel_tex_fetch(__light_distribution, middle).x) {
len = half_len;
}
else {
@@ -843,9 +1047,17 @@ ccl_device int light_distribution_sample(KernelGlobals *kg, float randt)
}
}
- /* clamping should not be needed but float rounding errors seem to
- * make this fail on rare occasions */
- return clamp(first-1, 0, kernel_data.integrator.num_distribution-1);
+ /* Clamping should not be needed but float rounding errors seem to
+ * make this fail on rare occasions. */
+ int index = clamp(first-1, 0, kernel_data.integrator.num_distribution-1);
+
+ /* Rescale to reuse random number. this helps the 2D samples within
+ * each area light be stratified as well. */
+ float distr_min = kernel_tex_fetch(__light_distribution, index).x;
+ float distr_max = kernel_tex_fetch(__light_distribution, index+1).x;
+ *randu = (r - distr_min)/(distr_max - distr_min);
+
+ return index;
}
/* Generic Light */
@@ -857,7 +1069,6 @@ ccl_device bool light_select_reached_max_bounces(KernelGlobals *kg, int index, i
}
ccl_device_noinline bool light_sample(KernelGlobals *kg,
- float randt,
float randu,
float randv,
float time,
@@ -866,7 +1077,7 @@ ccl_device_noinline bool light_sample(KernelGlobals *kg,
LightSample *ls)
{
/* sample index */
- int index = light_distribution_sample(kg, randt);
+ int index = light_distribution_sample(kg, &randu);
/* fetch light data */
float4 l = kernel_tex_fetch(__light_distribution, index);
@@ -876,10 +1087,7 @@ ccl_device_noinline bool light_sample(KernelGlobals *kg,
int object = __float_as_int(l.w);
int shader_flag = __float_as_int(l.z);
- triangle_light_sample(kg, prim, object, randu, randv, time, ls);
- /* compute incoming direction, distance and pdf */
- ls->D = normalize_len(ls->P - P, &ls->t);
- ls->pdf = triangle_light_pdf(kg, ls->Ng, -ls->D, ls->t);
+ triangle_light_sample(kg, prim, object, randu, randv, time, ls, P);
ls->shader |= shader_flag;
return (ls->pdf > 0.0f);
}
diff --git a/intern/cycles/kernel/kernel_montecarlo.h b/intern/cycles/kernel/kernel_montecarlo.h
index af7b727c1ba..9995490505f 100644
--- a/intern/cycles/kernel/kernel_montecarlo.h
+++ b/intern/cycles/kernel/kernel_montecarlo.h
@@ -67,8 +67,8 @@ ccl_device_inline void sample_cos_hemisphere(const float3 N,
/* sample direction uniformly distributed in hemisphere */
ccl_device_inline void sample_uniform_hemisphere(const float3 N,
- float randu, float randv,
- float3 *omega_in, float *pdf)
+ float randu, float randv,
+ float3 *omega_in, float *pdf)
{
float z = randu;
float r = sqrtf(max(0.0f, 1.0f - z*z));
@@ -84,8 +84,8 @@ ccl_device_inline void sample_uniform_hemisphere(const float3 N,
/* sample direction uniformly distributed in cone */
ccl_device_inline void sample_uniform_cone(const float3 N, float angle,
- float randu, float randv,
- float3 *omega_in, float *pdf)
+ float randu, float randv,
+ float3 *omega_in, float *pdf)
{
float z = cosf(angle*randu);
float r = sqrtf(max(0.0f, 1.0f - z*z));
@@ -187,4 +187,3 @@ ccl_device float2 regular_polygon_sample(float corners, float rotation, float u,
CCL_NAMESPACE_END
#endif /* __KERNEL_MONTECARLO_CL__ */
-
diff --git a/intern/cycles/kernel/kernel_passes.h b/intern/cycles/kernel/kernel_passes.h
index 9cd7ffb181d..b31356905f2 100644
--- a/intern/cycles/kernel/kernel_passes.h
+++ b/intern/cycles/kernel/kernel_passes.h
@@ -16,19 +16,23 @@
CCL_NAMESPACE_BEGIN
-ccl_device_inline void kernel_write_pass_float(ccl_global float *buffer, int sample, float value)
+#if defined(__SPLIT_KERNEL__) || defined(__KERNEL_CUDA__)
+#define __ATOMIC_PASS_WRITE__
+#endif
+
+ccl_device_inline void kernel_write_pass_float(ccl_global float *buffer, float value)
{
ccl_global float *buf = buffer;
-#if defined(__SPLIT_KERNEL__)
+#ifdef __ATOMIC_PASS_WRITE__
atomic_add_and_fetch_float(buf, value);
#else
- *buf = (sample == 0)? value: *buf + value;
-#endif /* __SPLIT_KERNEL__ */
+ *buf += value;
+#endif
}
-ccl_device_inline void kernel_write_pass_float3(ccl_global float *buffer, int sample, float3 value)
+ccl_device_inline void kernel_write_pass_float3(ccl_global float *buffer, float3 value)
{
-#if defined(__SPLIT_KERNEL__)
+#ifdef __ATOMIC_PASS_WRITE__
ccl_global float *buf_x = buffer + 0;
ccl_global float *buf_y = buffer + 1;
ccl_global float *buf_z = buffer + 2;
@@ -38,13 +42,13 @@ ccl_device_inline void kernel_write_pass_float3(ccl_global float *buffer, int sa
atomic_add_and_fetch_float(buf_z, value.z);
#else
ccl_global float3 *buf = (ccl_global float3*)buffer;
- *buf = (sample == 0)? value: *buf + value;
-#endif /* __SPLIT_KERNEL__ */
+ *buf += value;
+#endif
}
-ccl_device_inline void kernel_write_pass_float4(ccl_global float *buffer, int sample, float4 value)
+ccl_device_inline void kernel_write_pass_float4(ccl_global float *buffer, float4 value)
{
-#if defined(__SPLIT_KERNEL__)
+#ifdef __ATOMIC_PASS_WRITE__
ccl_global float *buf_x = buffer + 0;
ccl_global float *buf_y = buffer + 1;
ccl_global float *buf_z = buffer + 2;
@@ -56,58 +60,35 @@ ccl_device_inline void kernel_write_pass_float4(ccl_global float *buffer, int sa
atomic_add_and_fetch_float(buf_w, value.w);
#else
ccl_global float4 *buf = (ccl_global float4*)buffer;
- *buf = (sample == 0)? value: *buf + value;
-#endif /* __SPLIT_KERNEL__ */
+ *buf += value;
+#endif
}
#ifdef __DENOISING_FEATURES__
-ccl_device_inline void kernel_write_pass_float_variance(ccl_global float *buffer, int sample, float value)
+ccl_device_inline void kernel_write_pass_float_variance(ccl_global float *buffer, float value)
{
- kernel_write_pass_float(buffer, sample, value);
+ kernel_write_pass_float(buffer, value);
/* The online one-pass variance update that's used for the megakernel can't easily be implemented
* with atomics, so for the split kernel the E[x^2] - 1/N * (E[x])^2 fallback is used. */
-# ifdef __SPLIT_KERNEL__
- kernel_write_pass_float(buffer+1, sample, value*value);
-# else
- if(sample == 0) {
- kernel_write_pass_float(buffer+1, sample, 0.0f);
- }
- else {
- float new_mean = buffer[0] * (1.0f / (sample + 1));
- float old_mean = (buffer[0] - value) * (1.0f / sample);
- kernel_write_pass_float(buffer+1, sample, (value - new_mean) * (value - old_mean));
- }
-# endif
+ kernel_write_pass_float(buffer+1, value*value);
}
-# if defined(__SPLIT_KERNEL__)
+# ifdef __ATOMIC_PASS_WRITE__
# define kernel_write_pass_float3_unaligned kernel_write_pass_float3
# else
-ccl_device_inline void kernel_write_pass_float3_unaligned(ccl_global float *buffer, int sample, float3 value)
+ccl_device_inline void kernel_write_pass_float3_unaligned(ccl_global float *buffer, float3 value)
{
- buffer[0] = (sample == 0)? value.x: buffer[0] + value.x;
- buffer[1] = (sample == 0)? value.y: buffer[1] + value.y;
- buffer[2] = (sample == 0)? value.z: buffer[2] + value.z;
+ buffer[0] += value.x;
+ buffer[1] += value.y;
+ buffer[2] += value.z;
}
# endif
-ccl_device_inline void kernel_write_pass_float3_variance(ccl_global float *buffer, int sample, float3 value)
+ccl_device_inline void kernel_write_pass_float3_variance(ccl_global float *buffer, float3 value)
{
- kernel_write_pass_float3_unaligned(buffer, sample, value);
-# ifdef __SPLIT_KERNEL__
- kernel_write_pass_float3_unaligned(buffer+3, sample, value*value);
-# else
- if(sample == 0) {
- kernel_write_pass_float3_unaligned(buffer+3, sample, make_float3(0.0f, 0.0f, 0.0f));
- }
- else {
- float3 sum = make_float3(buffer[0], buffer[1], buffer[2]);
- float3 new_mean = sum * (1.0f / (sample + 1));
- float3 old_mean = (sum - value) * (1.0f / sample);
- kernel_write_pass_float3_unaligned(buffer+3, sample, (value - new_mean) * (value - old_mean));
- }
-# endif
+ kernel_write_pass_float3_unaligned(buffer, value);
+ kernel_write_pass_float3_unaligned(buffer+3, value*value);
}
ccl_device_inline void kernel_write_denoising_shadow(KernelGlobals *kg, ccl_global float *buffer,
@@ -121,22 +102,11 @@ ccl_device_inline void kernel_write_denoising_shadow(KernelGlobals *kg, ccl_glob
path_total = ensure_finite(path_total);
path_total_shaded = ensure_finite(path_total_shaded);
- kernel_write_pass_float(buffer, sample/2, path_total);
- kernel_write_pass_float(buffer+1, sample/2, path_total_shaded);
+ kernel_write_pass_float(buffer, path_total);
+ kernel_write_pass_float(buffer+1, path_total_shaded);
float value = path_total_shaded / max(path_total, 1e-7f);
-# ifdef __SPLIT_KERNEL__
- kernel_write_pass_float(buffer+2, sample/2, value*value);
-# else
- if(sample < 2) {
- kernel_write_pass_float(buffer+2, sample/2, 0.0f);
- }
- else {
- float old_value = (buffer[1] - path_total_shaded) / max(buffer[0] - path_total, 1e-7f);
- float new_value = buffer[1] / max(buffer[0], 1e-7f);
- kernel_write_pass_float(buffer+2, sample, (value - new_value) * (value - old_value));
- }
-# endif
+ kernel_write_pass_float(buffer+2, value*value);
}
#endif /* __DENOISING_FEATURES__ */
@@ -194,8 +164,33 @@ ccl_device_inline void kernel_update_denoising_features(KernelGlobals *kg,
#endif /* __DENOISING_FEATURES__ */
}
+#ifdef __KERNEL_DEBUG__
+ccl_device_inline void kernel_write_debug_passes(KernelGlobals *kg,
+ ccl_global float *buffer,
+ PathRadiance *L)
+{
+ int flag = kernel_data.film.pass_flag;
+ if(flag & PASS_BVH_TRAVERSED_NODES) {
+ kernel_write_pass_float(buffer + kernel_data.film.pass_bvh_traversed_nodes,
+ L->debug_data.num_bvh_traversed_nodes);
+ }
+ if(flag & PASS_BVH_TRAVERSED_INSTANCES) {
+ kernel_write_pass_float(buffer + kernel_data.film.pass_bvh_traversed_instances,
+ L->debug_data.num_bvh_traversed_instances);
+ }
+ if(flag & PASS_BVH_INTERSECTIONS) {
+ kernel_write_pass_float(buffer + kernel_data.film.pass_bvh_intersections,
+ L->debug_data.num_bvh_intersections);
+ }
+ if(flag & PASS_RAY_BOUNCES) {
+ kernel_write_pass_float(buffer + kernel_data.film.pass_ray_bounces,
+ L->debug_data.num_ray_bounces);
+ }
+}
+#endif /* __KERNEL_DEBUG__ */
+
ccl_device_inline void kernel_write_data_passes(KernelGlobals *kg, ccl_global float *buffer, PathRadiance *L,
- ShaderData *sd, int sample, ccl_addr_space PathState *state, float3 throughput)
+ ShaderData *sd, ccl_addr_space PathState *state, float3 throughput)
{
#ifdef __PASSES__
int path_flag = state->flag;
@@ -213,34 +208,33 @@ ccl_device_inline void kernel_write_data_passes(KernelGlobals *kg, ccl_global fl
kernel_data.film.pass_alpha_threshold == 0.0f ||
average(shader_bsdf_alpha(kg, sd)) >= kernel_data.film.pass_alpha_threshold)
{
-
- if(sample == 0) {
+ if(state->sample == 0) {
if(flag & PASS_DEPTH) {
float depth = camera_distance(kg, sd->P);
- kernel_write_pass_float(buffer + kernel_data.film.pass_depth, sample, depth);
+ kernel_write_pass_float(buffer + kernel_data.film.pass_depth, depth);
}
if(flag & PASS_OBJECT_ID) {
float id = object_pass_id(kg, sd->object);
- kernel_write_pass_float(buffer + kernel_data.film.pass_object_id, sample, id);
+ kernel_write_pass_float(buffer + kernel_data.film.pass_object_id, id);
}
if(flag & PASS_MATERIAL_ID) {
float id = shader_pass_id(kg, sd);
- kernel_write_pass_float(buffer + kernel_data.film.pass_material_id, sample, id);
+ kernel_write_pass_float(buffer + kernel_data.film.pass_material_id, id);
}
}
if(flag & PASS_NORMAL) {
- float3 normal = sd->N;
- kernel_write_pass_float3(buffer + kernel_data.film.pass_normal, sample, normal);
+ float3 normal = shader_bsdf_average_normal(kg, sd);
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_normal, normal);
}
if(flag & PASS_UV) {
float3 uv = primitive_uv(kg, sd);
- kernel_write_pass_float3(buffer + kernel_data.film.pass_uv, sample, uv);
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_uv, uv);
}
if(flag & PASS_MOTION) {
float4 speed = primitive_motion_vector(kg, sd);
- kernel_write_pass_float4(buffer + kernel_data.film.pass_motion, sample, speed);
- kernel_write_pass_float(buffer + kernel_data.film.pass_motion_weight, sample, 1.0f);
+ kernel_write_pass_float4(buffer + kernel_data.film.pass_motion, speed);
+ kernel_write_pass_float(buffer + kernel_data.film.pass_motion_weight, 1.0f);
}
state->flag |= PATH_RAY_SINGLE_PASS_DONE;
@@ -283,7 +277,7 @@ ccl_device_inline void kernel_write_data_passes(KernelGlobals *kg, ccl_global fl
#endif
}
-ccl_device_inline void kernel_write_light_passes(KernelGlobals *kg, ccl_global float *buffer, PathRadiance *L, int sample)
+ccl_device_inline void kernel_write_light_passes(KernelGlobals *kg, ccl_global float *buffer, PathRadiance *L)
{
#ifdef __PASSES__
int flag = kernel_data.film.pass_flag;
@@ -292,128 +286,104 @@ ccl_device_inline void kernel_write_light_passes(KernelGlobals *kg, ccl_global f
return;
if(flag & PASS_DIFFUSE_INDIRECT)
- kernel_write_pass_float3(buffer + kernel_data.film.pass_diffuse_indirect, sample, L->indirect_diffuse);
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_diffuse_indirect, L->indirect_diffuse);
if(flag & PASS_GLOSSY_INDIRECT)
- kernel_write_pass_float3(buffer + kernel_data.film.pass_glossy_indirect, sample, L->indirect_glossy);
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_glossy_indirect, L->indirect_glossy);
if(flag & PASS_TRANSMISSION_INDIRECT)
- kernel_write_pass_float3(buffer + kernel_data.film.pass_transmission_indirect, sample, L->indirect_transmission);
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_transmission_indirect, L->indirect_transmission);
if(flag & PASS_SUBSURFACE_INDIRECT)
- kernel_write_pass_float3(buffer + kernel_data.film.pass_subsurface_indirect, sample, L->indirect_subsurface);
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_subsurface_indirect, L->indirect_subsurface);
if(flag & PASS_DIFFUSE_DIRECT)
- kernel_write_pass_float3(buffer + kernel_data.film.pass_diffuse_direct, sample, L->direct_diffuse);
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_diffuse_direct, L->direct_diffuse);
if(flag & PASS_GLOSSY_DIRECT)
- kernel_write_pass_float3(buffer + kernel_data.film.pass_glossy_direct, sample, L->direct_glossy);
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_glossy_direct, L->direct_glossy);
if(flag & PASS_TRANSMISSION_DIRECT)
- kernel_write_pass_float3(buffer + kernel_data.film.pass_transmission_direct, sample, L->direct_transmission);
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_transmission_direct, L->direct_transmission);
if(flag & PASS_SUBSURFACE_DIRECT)
- kernel_write_pass_float3(buffer + kernel_data.film.pass_subsurface_direct, sample, L->direct_subsurface);
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_subsurface_direct, L->direct_subsurface);
if(flag & PASS_EMISSION)
- kernel_write_pass_float3(buffer + kernel_data.film.pass_emission, sample, L->emission);
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_emission, L->emission);
if(flag & PASS_BACKGROUND)
- kernel_write_pass_float3(buffer + kernel_data.film.pass_background, sample, L->background);
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_background, L->background);
if(flag & PASS_AO)
- kernel_write_pass_float3(buffer + kernel_data.film.pass_ao, sample, L->ao);
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_ao, L->ao);
if(flag & PASS_DIFFUSE_COLOR)
- kernel_write_pass_float3(buffer + kernel_data.film.pass_diffuse_color, sample, L->color_diffuse);
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_diffuse_color, L->color_diffuse);
if(flag & PASS_GLOSSY_COLOR)
- kernel_write_pass_float3(buffer + kernel_data.film.pass_glossy_color, sample, L->color_glossy);
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_glossy_color, L->color_glossy);
if(flag & PASS_TRANSMISSION_COLOR)
- kernel_write_pass_float3(buffer + kernel_data.film.pass_transmission_color, sample, L->color_transmission);
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_transmission_color, L->color_transmission);
if(flag & PASS_SUBSURFACE_COLOR)
- kernel_write_pass_float3(buffer + kernel_data.film.pass_subsurface_color, sample, L->color_subsurface);
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_subsurface_color, L->color_subsurface);
if(flag & PASS_SHADOW) {
float4 shadow = L->shadow;
shadow.w = kernel_data.film.pass_shadow_scale;
- kernel_write_pass_float4(buffer + kernel_data.film.pass_shadow, sample, shadow);
+ kernel_write_pass_float4(buffer + kernel_data.film.pass_shadow, shadow);
}
if(flag & PASS_MIST)
- kernel_write_pass_float(buffer + kernel_data.film.pass_mist, sample, 1.0f - L->mist);
+ kernel_write_pass_float(buffer + kernel_data.film.pass_mist, 1.0f - L->mist);
#endif
}
-ccl_device_inline void kernel_write_result(KernelGlobals *kg, ccl_global float *buffer,
- int sample, PathRadiance *L, float alpha, bool is_shadow_catcher)
+ccl_device_inline void kernel_write_result(KernelGlobals *kg,
+ ccl_global float *buffer,
+ int sample,
+ PathRadiance *L)
{
- if(L) {
- float3 L_sum;
-#ifdef __SHADOW_TRICKS__
- if(is_shadow_catcher) {
- L_sum = path_radiance_sum_shadowcatcher(kg, L, &alpha);
- }
- else
-#endif /* __SHADOW_TRICKS__ */
- {
- L_sum = path_radiance_clamp_and_sum(kg, L);
- }
+ float alpha;
+ float3 L_sum = path_radiance_clamp_and_sum(kg, L, &alpha);
- kernel_write_pass_float4(buffer, sample, make_float4(L_sum.x, L_sum.y, L_sum.z, alpha));
+ kernel_write_pass_float4(buffer, make_float4(L_sum.x, L_sum.y, L_sum.z, alpha));
- kernel_write_light_passes(kg, buffer, L, sample);
+ kernel_write_light_passes(kg, buffer, L);
#ifdef __DENOISING_FEATURES__
- if(kernel_data.film.pass_denoising_data) {
+ if(kernel_data.film.pass_denoising_data) {
# ifdef __SHADOW_TRICKS__
- kernel_write_denoising_shadow(kg, buffer + kernel_data.film.pass_denoising_data, sample, average(L->path_total), average(L->path_total_shaded));
+ kernel_write_denoising_shadow(kg,
+ buffer + kernel_data.film.pass_denoising_data,
+ sample,
+ average(L->path_total),
+ average(L->path_total_shaded));
# else
- kernel_write_denoising_shadow(kg, buffer + kernel_data.film.pass_denoising_data, sample, 0.0f, 0.0f);
+ kernel_write_denoising_shadow(kg,
+ buffer + kernel_data.film.pass_denoising_data,
+ sample,
+ 0.0f, 0.0f);
# endif
- if(kernel_data.film.pass_denoising_clean) {
- float3 noisy, clean;
-#ifdef __SHADOW_TRICKS__
- if(is_shadow_catcher) {
- noisy = L_sum;
- clean = make_float3(0.0f, 0.0f, 0.0f);
- }
- else
-#endif /* __SHADOW_TRICKS__ */
- {
- path_radiance_split_denoising(kg, L, &noisy, &clean);
- }
- kernel_write_pass_float3_variance(buffer + kernel_data.film.pass_denoising_data + DENOISING_PASS_COLOR,
- sample, noisy);
- kernel_write_pass_float3_unaligned(buffer + kernel_data.film.pass_denoising_clean,
- sample, clean);
- }
- else {
- kernel_write_pass_float3_variance(buffer + kernel_data.film.pass_denoising_data + DENOISING_PASS_COLOR,
- sample, ensure_finite3(L_sum));
- }
-
- kernel_write_pass_float3_variance(buffer + kernel_data.film.pass_denoising_data + DENOISING_PASS_NORMAL,
- sample, L->denoising_normal);
- kernel_write_pass_float3_variance(buffer + kernel_data.film.pass_denoising_data + DENOISING_PASS_ALBEDO,
- sample, L->denoising_albedo);
- kernel_write_pass_float_variance(buffer + kernel_data.film.pass_denoising_data + DENOISING_PASS_DEPTH,
- sample, L->denoising_depth);
+ if(kernel_data.film.pass_denoising_clean) {
+ float3 noisy, clean;
+ path_radiance_split_denoising(kg, L, &noisy, &clean);
+ kernel_write_pass_float3_variance(
+ buffer + kernel_data.film.pass_denoising_data + DENOISING_PASS_COLOR,
+ noisy);
+ kernel_write_pass_float3_unaligned(
+ buffer + kernel_data.film.pass_denoising_clean,
+ clean);
}
-#endif /* __DENOISING_FEATURES__ */
- }
- else {
- kernel_write_pass_float4(buffer, sample, make_float4(0.0f, 0.0f, 0.0f, 0.0f));
-
-#ifdef __DENOISING_FEATURES__
- if(kernel_data.film.pass_denoising_data) {
- kernel_write_denoising_shadow(kg, buffer + kernel_data.film.pass_denoising_data, sample, 0.0f, 0.0f);
-
+ else {
kernel_write_pass_float3_variance(buffer + kernel_data.film.pass_denoising_data + DENOISING_PASS_COLOR,
- sample, make_float3(0.0f, 0.0f, 0.0f));
-
- kernel_write_pass_float3_variance(buffer + kernel_data.film.pass_denoising_data + DENOISING_PASS_NORMAL,
- sample, make_float3(0.0f, 0.0f, 0.0f));
- kernel_write_pass_float3_variance(buffer + kernel_data.film.pass_denoising_data + DENOISING_PASS_ALBEDO,
- sample, make_float3(0.0f, 0.0f, 0.0f));
- kernel_write_pass_float_variance(buffer + kernel_data.film.pass_denoising_data + DENOISING_PASS_DEPTH,
- sample, 0.0f);
-
- if(kernel_data.film.pass_denoising_clean) {
- kernel_write_pass_float3_unaligned(buffer + kernel_data.film.pass_denoising_clean,
- sample, make_float3(0.0f, 0.0f, 0.0f));
- }
+ ensure_finite3(L_sum));
}
-#endif /* __DENOISING_FEATURES__ */
+
+ kernel_write_pass_float3_variance(
+ buffer + kernel_data.film.pass_denoising_data + DENOISING_PASS_NORMAL,
+ L->denoising_normal);
+ kernel_write_pass_float3_variance(
+ buffer + kernel_data.film.pass_denoising_data + DENOISING_PASS_ALBEDO,
+ L->denoising_albedo);
+ kernel_write_pass_float_variance(
+ buffer + kernel_data.film.pass_denoising_data + DENOISING_PASS_DEPTH,
+ L->denoising_depth);
}
+#endif /* __DENOISING_FEATURES__ */
+
+
+#ifdef __KERNEL_DEBUG__
+ kernel_write_debug_passes(kg, buffer, L);
+#endif
}
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h
index fc093ad8319..6b6c5603b70 100644
--- a/intern/cycles/kernel/kernel_path.h
+++ b/intern/cycles/kernel/kernel_path.h
@@ -48,25 +48,308 @@
#include "kernel/kernel_path_volume.h"
#include "kernel/kernel_path_subsurface.h"
+CCL_NAMESPACE_BEGIN
+
+ccl_device_forceinline bool kernel_path_scene_intersect(
+ KernelGlobals *kg,
+ ccl_addr_space PathState *state,
+ Ray *ray,
+ Intersection *isect,
+ PathRadiance *L)
+{
+ uint visibility = path_state_ray_visibility(kg, state);
+
+#ifdef __HAIR__
+ float difl = 0.0f, extmax = 0.0f;
+ uint lcg_state = 0;
+
+ if(kernel_data.bvh.have_curves) {
+ if((kernel_data.cam.resolution == 1) && (state->flag & PATH_RAY_CAMERA)) {
+ float3 pixdiff = ray->dD.dx + ray->dD.dy;
+ /*pixdiff = pixdiff - dot(pixdiff, ray.D)*ray.D;*/
+ difl = kernel_data.curve.minimum_width * len(pixdiff) * 0.5f;
+ }
+
+ extmax = kernel_data.curve.maximum_width;
+ lcg_state = lcg_state_init_addrspace(state, 0x51633e2d);
+ }
+
+ if(path_state_ao_bounce(kg, state)) {
+ visibility = PATH_RAY_SHADOW;
+ ray->t = kernel_data.background.ao_distance;
+ }
+
+ bool hit = scene_intersect(kg, *ray, visibility, isect, &lcg_state, difl, extmax);
+#else
+ bool hit = scene_intersect(kg, *ray, visibility, isect, NULL, 0.0f, 0.0f);
+#endif /* __HAIR__ */
+
#ifdef __KERNEL_DEBUG__
-# include "kernel/kernel_debug.h"
-#endif
+ if(state->flag & PATH_RAY_CAMERA) {
+ L->debug_data.num_bvh_traversed_nodes += isect->num_traversed_nodes;
+ L->debug_data.num_bvh_traversed_instances += isect->num_traversed_instances;
+ L->debug_data.num_bvh_intersections += isect->num_intersections;
+ }
+ L->debug_data.num_ray_bounces++;
+#endif /* __KERNEL_DEBUG__ */
-CCL_NAMESPACE_BEGIN
+ return hit;
+}
+
+ccl_device_forceinline void kernel_path_lamp_emission(
+ KernelGlobals *kg,
+ ccl_addr_space PathState *state,
+ Ray *ray,
+ float3 throughput,
+ ccl_addr_space Intersection *isect,
+ ShaderData *emission_sd,
+ PathRadiance *L)
+{
+#ifdef __LAMP_MIS__
+ if(kernel_data.integrator.use_lamp_mis && !(state->flag & PATH_RAY_CAMERA)) {
+ /* ray starting from previous non-transparent bounce */
+ Ray light_ray;
+
+ light_ray.P = ray->P - state->ray_t*ray->D;
+ state->ray_t += isect->t;
+ light_ray.D = ray->D;
+ light_ray.t = state->ray_t;
+ light_ray.time = ray->time;
+ light_ray.dD = ray->dD;
+ light_ray.dP = ray->dP;
+
+ /* intersect with lamp */
+ float3 emission;
+
+ if(indirect_lamp_emission(kg, emission_sd, state, &light_ray, &emission))
+ path_radiance_accum_emission(L, state, throughput, emission);
+ }
+#endif /* __LAMP_MIS__ */
+}
+
+ccl_device_forceinline void kernel_path_background(
+ KernelGlobals *kg,
+ ccl_addr_space PathState *state,
+ ccl_addr_space Ray *ray,
+ float3 throughput,
+ ShaderData *emission_sd,
+ PathRadiance *L)
+{
+ /* eval background shader if nothing hit */
+ if(kernel_data.background.transparent && (state->flag & PATH_RAY_CAMERA)) {
+ L->transparent += average(throughput);
+
+#ifdef __PASSES__
+ if(!(kernel_data.film.pass_flag & PASS_BACKGROUND))
+#endif /* __PASSES__ */
+ return;
+ }
+
+#ifdef __BACKGROUND__
+ /* sample background shader */
+ float3 L_background = indirect_background(kg, emission_sd, state, ray);
+ path_radiance_accum_background(L, state, throughput, L_background);
+#endif /* __BACKGROUND__ */
+}
+
+#ifndef __SPLIT_KERNEL__
+
+#ifdef __VOLUME__
+ccl_device_forceinline VolumeIntegrateResult kernel_path_volume(
+ KernelGlobals *kg,
+ ShaderData *sd,
+ PathState *state,
+ Ray *ray,
+ float3 *throughput,
+ ccl_addr_space Intersection *isect,
+ bool hit,
+ ShaderData *emission_sd,
+ PathRadiance *L)
+{
+ /* Sanitize volume stack. */
+ if(!hit) {
+ kernel_volume_clean_stack(kg, state->volume_stack);
+ }
+ /* volume attenuation, emission, scatter */
+ if(state->volume_stack[0].shader != SHADER_NONE) {
+ Ray volume_ray = *ray;
+ volume_ray.t = (hit)? isect->t: FLT_MAX;
+
+ bool heterogeneous = volume_stack_is_heterogeneous(kg, state->volume_stack);
+
+# ifdef __VOLUME_DECOUPLED__
+ int sampling_method = volume_stack_sampling_method(kg, state->volume_stack);
+ bool direct = (state->flag & PATH_RAY_CAMERA) != 0;
+ bool decoupled = kernel_volume_use_decoupled(kg, heterogeneous, direct, sampling_method);
+
+ if(decoupled) {
+ /* cache steps along volume for repeated sampling */
+ VolumeSegment volume_segment;
+
+ shader_setup_from_volume(kg, sd, &volume_ray);
+ kernel_volume_decoupled_record(kg, state,
+ &volume_ray, sd, &volume_segment, heterogeneous);
+
+ volume_segment.sampling_method = sampling_method;
+
+ /* emission */
+ if(volume_segment.closure_flag & SD_EMISSION)
+ path_radiance_accum_emission(L, state, *throughput, volume_segment.accum_emission);
+
+ /* scattering */
+ VolumeIntegrateResult result = VOLUME_PATH_ATTENUATED;
+
+ if(volume_segment.closure_flag & SD_SCATTER) {
+ int all = kernel_data.integrator.sample_all_lights_indirect;
+
+ /* direct light sampling */
+ kernel_branched_path_volume_connect_light(kg, sd,
+ emission_sd, *throughput, state, L, all,
+ &volume_ray, &volume_segment);
+
+ /* indirect sample. if we use distance sampling and take just
+ * one sample for direct and indirect light, we could share
+ * this computation, but makes code a bit complex */
+ float rphase = path_state_rng_1D(kg, state, PRNG_PHASE_CHANNEL);
+ float rscatter = path_state_rng_1D(kg, state, PRNG_SCATTER_DISTANCE);
+
+ result = kernel_volume_decoupled_scatter(kg,
+ state, &volume_ray, sd, throughput,
+ rphase, rscatter, &volume_segment, NULL, true);
+ }
+
+ /* free cached steps */
+ kernel_volume_decoupled_free(kg, &volume_segment);
+
+ if(result == VOLUME_PATH_SCATTERED) {
+ if(kernel_path_volume_bounce(kg, sd, throughput, state, &L->state, ray))
+ return VOLUME_PATH_SCATTERED;
+ else
+ return VOLUME_PATH_MISSED;
+ }
+ else {
+ *throughput *= volume_segment.accum_transmittance;
+ }
+ }
+ else
+# endif /* __VOLUME_DECOUPLED__ */
+ {
+ /* integrate along volume segment with distance sampling */
+ VolumeIntegrateResult result = kernel_volume_integrate(
+ kg, state, sd, &volume_ray, L, throughput, heterogeneous);
+
+# ifdef __VOLUME_SCATTER__
+ if(result == VOLUME_PATH_SCATTERED) {
+ /* direct lighting */
+ kernel_path_volume_connect_light(kg, sd, emission_sd, *throughput, state, L);
+
+ /* indirect light bounce */
+ if(kernel_path_volume_bounce(kg, sd, throughput, state, &L->state, ray))
+ return VOLUME_PATH_SCATTERED;
+ else
+ return VOLUME_PATH_MISSED;
+ }
+# endif /* __VOLUME_SCATTER__ */
+ }
+ }
+
+ return VOLUME_PATH_ATTENUATED;
+}
+#endif /* __VOLUME__ */
+
+#endif /* __SPLIT_KERNEL__ */
+
+ccl_device_forceinline bool kernel_path_shader_apply(
+ KernelGlobals *kg,
+ ShaderData *sd,
+ ccl_addr_space PathState *state,
+ ccl_addr_space Ray *ray,
+ float3 throughput,
+ ShaderData *emission_sd,
+ PathRadiance *L,
+ ccl_global float *buffer)
+{
+#ifdef __SHADOW_TRICKS__
+ if((sd->object_flag & SD_OBJECT_SHADOW_CATCHER)) {
+ if(state->flag & PATH_RAY_CAMERA) {
+ state->flag |= (PATH_RAY_SHADOW_CATCHER |
+ PATH_RAY_STORE_SHADOW_INFO);
+
+ float3 bg = make_float3(0.0f, 0.0f, 0.0f);
+ if(!kernel_data.background.transparent) {
+ bg = indirect_background(kg, emission_sd, state, ray);
+ }
+ path_radiance_accum_shadowcatcher(L, throughput, bg);
+ }
+ }
+ else if(state->flag & PATH_RAY_SHADOW_CATCHER) {
+ /* Only update transparency after shadow catcher bounce. */
+ L->shadow_transparency *=
+ average(shader_bsdf_transparency(kg, sd));
+ }
+#endif /* __SHADOW_TRICKS__ */
+
+ /* holdout */
+#ifdef __HOLDOUT__
+ if(((sd->flag & SD_HOLDOUT) ||
+ (sd->object_flag & SD_OBJECT_HOLDOUT_MASK)) &&
+ (state->flag & PATH_RAY_CAMERA))
+ {
+ if(kernel_data.background.transparent) {
+ float3 holdout_weight;
+ if(sd->object_flag & SD_OBJECT_HOLDOUT_MASK) {
+ holdout_weight = make_float3(1.0f, 1.0f, 1.0f);
+ }
+ else {
+ holdout_weight = shader_holdout_eval(kg, sd);
+ }
+ /* any throughput is ok, should all be identical here */
+ L->transparent += average(holdout_weight*throughput);
+ }
+
+ if(sd->object_flag & SD_OBJECT_HOLDOUT_MASK) {
+ return false;
+ }
+ }
+#endif /* __HOLDOUT__ */
+
+ /* holdout mask objects do not write data passes */
+ kernel_write_data_passes(kg, buffer, L, sd, state, throughput);
+
+ /* blurring of bsdf after bounces, for rays that have a small likelihood
+ * of following this particular path (diffuse, rough glossy) */
+ if(kernel_data.integrator.filter_glossy != FLT_MAX) {
+ float blur_pdf = kernel_data.integrator.filter_glossy*state->min_ray_pdf;
+
+ if(blur_pdf < 1.0f) {
+ float blur_roughness = sqrtf(1.0f - blur_pdf)*0.5f;
+ shader_bsdf_blur(kg, sd, blur_roughness);
+ }
+ }
+
+#ifdef __EMISSION__
+ /* emission */
+ if(sd->flag & SD_EMISSION) {
+ float3 emission = indirect_primitive_emission(kg, sd, sd->ray_length, state->flag, state->ray_pdf);
+ path_radiance_accum_emission(L, state, throughput, emission);
+ }
+#endif /* __EMISSION__ */
+
+ return true;
+}
ccl_device_noinline void kernel_path_ao(KernelGlobals *kg,
ShaderData *sd,
ShaderData *emission_sd,
PathRadiance *L,
ccl_addr_space PathState *state,
- RNG *rng,
float3 throughput,
float3 ao_alpha)
{
/* todo: solve correlation */
float bsdf_u, bsdf_v;
- path_state_rng_2D(kg, rng, state, PRNG_BSDF_U, &bsdf_u, &bsdf_v);
+ path_state_rng_2D(kg, state, PRNG_BSDF_U, &bsdf_u, &bsdf_v);
float ao_factor = kernel_data.background.ao_factor;
float3 ao_N;
@@ -83,13 +366,11 @@ ccl_device_noinline void kernel_path_ao(KernelGlobals *kg,
light_ray.P = ray_offset(sd->P, sd->Ng);
light_ray.D = ao_D;
light_ray.t = kernel_data.background.ao_distance;
-#ifdef __OBJECT_MOTION__
light_ray.time = sd->time;
-#endif /* __OBJECT_MOTION__ */
light_ray.dP = sd->dP;
light_ray.dD = differential3_zero();
- if(!shadow_blocked(kg, emission_sd, state, &light_ray, &ao_shadow)) {
+ if(!shadow_blocked(kg, sd, emission_sd, state, &light_ray, &ao_shadow)) {
path_radiance_accum_ao(L, state, throughput, ao_alpha, ao_bsdf, ao_shadow);
}
else {
@@ -100,265 +381,85 @@ ccl_device_noinline void kernel_path_ao(KernelGlobals *kg,
#ifndef __SPLIT_KERNEL__
+#if defined(__BRANCHED_PATH__) || defined(__BAKING__)
+
ccl_device void kernel_path_indirect(KernelGlobals *kg,
ShaderData *sd,
ShaderData *emission_sd,
- RNG *rng,
Ray *ray,
float3 throughput,
- int num_samples,
PathState *state,
PathRadiance *L)
{
/* path iteration */
for(;;) {
- /* intersect scene */
+ /* Find intersection with objects in scene. */
Intersection isect;
- uint visibility = path_state_ray_visibility(kg, state);
- if(state->bounce > kernel_data.integrator.ao_bounces) {
- visibility = PATH_RAY_SHADOW;
- ray->t = kernel_data.background.ao_distance;
- }
- bool hit = scene_intersect(kg,
- *ray,
- visibility,
- &isect,
- NULL,
- 0.0f, 0.0f);
+ bool hit = kernel_path_scene_intersect(kg, state, ray, &isect, L);
-#ifdef __LAMP_MIS__
- if(kernel_data.integrator.use_lamp_mis && !(state->flag & PATH_RAY_CAMERA)) {
- /* ray starting from previous non-transparent bounce */
- Ray light_ray;
-
- light_ray.P = ray->P - state->ray_t*ray->D;
- state->ray_t += isect.t;
- light_ray.D = ray->D;
- light_ray.t = state->ray_t;
- light_ray.time = ray->time;
- light_ray.dD = ray->dD;
- light_ray.dP = ray->dP;
-
- /* intersect with lamp */
- float3 emission;
- if(indirect_lamp_emission(kg, emission_sd, state, &light_ray, &emission)) {
- path_radiance_accum_emission(L,
- throughput,
- emission,
- state->bounce);
- }
- }
-#endif /* __LAMP_MIS__ */
+ /* Find intersection with lamps and compute emission for MIS. */
+ kernel_path_lamp_emission(kg, state, ray, throughput, &isect, emission_sd, L);
#ifdef __VOLUME__
- /* Sanitize volume stack. */
- if(!hit) {
- kernel_volume_clean_stack(kg, state->volume_stack);
- }
- /* volume attenuation, emission, scatter */
- if(state->volume_stack[0].shader != SHADER_NONE) {
- Ray volume_ray = *ray;
- volume_ray.t = (hit)? isect.t: FLT_MAX;
-
- bool heterogeneous =
- volume_stack_is_heterogeneous(kg,
- state->volume_stack);
-
-# ifdef __VOLUME_DECOUPLED__
- int sampling_method =
- volume_stack_sampling_method(kg,
- state->volume_stack);
- bool decoupled = kernel_volume_use_decoupled(kg, heterogeneous, false, sampling_method);
-
- if(decoupled) {
- /* cache steps along volume for repeated sampling */
- VolumeSegment volume_segment;
-
- shader_setup_from_volume(kg,
- sd,
- &volume_ray);
- kernel_volume_decoupled_record(kg,
- state,
- &volume_ray,
- sd,
- &volume_segment,
- heterogeneous);
-
- volume_segment.sampling_method = sampling_method;
-
- /* emission */
- if(volume_segment.closure_flag & SD_EMISSION) {
- path_radiance_accum_emission(L,
- throughput,
- volume_segment.accum_emission,
- state->bounce);
- }
-
- /* scattering */
- VolumeIntegrateResult result = VOLUME_PATH_ATTENUATED;
-
- if(volume_segment.closure_flag & SD_SCATTER) {
- int all = kernel_data.integrator.sample_all_lights_indirect;
-
- /* direct light sampling */
- kernel_branched_path_volume_connect_light(kg,
- rng,
- sd,
- emission_sd,
- throughput,
- state,
- L,
- all,
- &volume_ray,
- &volume_segment);
-
- /* indirect sample. if we use distance sampling and take just
- * one sample for direct and indirect light, we could share
- * this computation, but makes code a bit complex */
- float rphase = path_state_rng_1D_for_decision(kg, rng, state, PRNG_PHASE);
- float rscatter = path_state_rng_1D_for_decision(kg, rng, state, PRNG_SCATTER_DISTANCE);
-
- result = kernel_volume_decoupled_scatter(kg,
- state,
- &volume_ray,
- sd,
- &throughput,
- rphase,
- rscatter,
- &volume_segment,
- NULL,
- true);
- }
-
- /* free cached steps */
- kernel_volume_decoupled_free(kg, &volume_segment);
-
- if(result == VOLUME_PATH_SCATTERED) {
- if(kernel_path_volume_bounce(kg,
- rng,
- sd,
- &throughput,
- state,
- L,
- ray))
- {
- continue;
- }
- else {
- break;
- }
- }
- else {
- throughput *= volume_segment.accum_transmittance;
- }
- }
- else
-# endif /* __VOLUME_DECOUPLED__ */
- {
- /* integrate along volume segment with distance sampling */
- VolumeIntegrateResult result = kernel_volume_integrate(
- kg, state, sd, &volume_ray, L, &throughput, rng, heterogeneous);
-
-# ifdef __VOLUME_SCATTER__
- if(result == VOLUME_PATH_SCATTERED) {
- /* direct lighting */
- kernel_path_volume_connect_light(kg,
- rng,
- sd,
- emission_sd,
- throughput,
- state,
- L);
-
- /* indirect light bounce */
- if(kernel_path_volume_bounce(kg,
- rng,
- sd,
- &throughput,
- state,
- L,
- ray))
- {
- continue;
- }
- else {
- break;
- }
- }
-# endif /* __VOLUME_SCATTER__ */
- }
+ /* Volume integration. */
+ VolumeIntegrateResult result = kernel_path_volume(kg,
+ sd,
+ state,
+ ray,
+ &throughput,
+ &isect,
+ hit,
+ emission_sd,
+ L);
+
+ if(result == VOLUME_PATH_SCATTERED) {
+ continue;
+ }
+ else if(result == VOLUME_PATH_MISSED) {
+ break;
}
-#endif /* __VOLUME__ */
+#endif /* __VOLUME__*/
+ /* Shade background. */
if(!hit) {
-#ifdef __BACKGROUND__
- /* sample background shader */
- float3 L_background = indirect_background(kg, emission_sd, state, ray);
- path_radiance_accum_background(L,
- state,
- throughput,
- L_background);
-#endif /* __BACKGROUND__ */
-
+ kernel_path_background(kg, state, ray, throughput, emission_sd, L);
break;
}
- else if(state->bounce > kernel_data.integrator.ao_bounces) {
+ else if(path_state_ao_bounce(kg, state)) {
break;
}
- /* setup shading */
+ /* Setup and evaluate shader. */
shader_setup_from_ray(kg,
sd,
&isect,
ray);
- float rbsdf = path_state_rng_1D_for_decision(kg, rng, state, PRNG_BSDF);
- shader_eval_surface(kg, sd, rng, state, rbsdf, state->flag, SHADER_CONTEXT_INDIRECT);
-#ifdef __BRANCHED_PATH__
- shader_merge_closures(sd);
-#endif /* __BRANCHED_PATH__ */
-
-#ifdef __SHADOW_TRICKS__
- if(!(sd->object_flag & SD_OBJECT_SHADOW_CATCHER)) {
- state->flag &= ~PATH_RAY_SHADOW_CATCHER_ONLY;
- }
-#endif /* __SHADOW_TRICKS__ */
-
- /* blurring of bsdf after bounces, for rays that have a small likelihood
- * of following this particular path (diffuse, rough glossy) */
- if(kernel_data.integrator.filter_glossy != FLT_MAX) {
- float blur_pdf = kernel_data.integrator.filter_glossy*state->min_ray_pdf;
-
- if(blur_pdf < 1.0f) {
- float blur_roughness = sqrtf(1.0f - blur_pdf)*0.5f;
- shader_bsdf_blur(kg, sd, blur_roughness);
- }
- }
-
-#ifdef __EMISSION__
- /* emission */
- if(sd->flag & SD_EMISSION) {
- float3 emission = indirect_primitive_emission(kg,
- sd,
- isect.t,
- state->flag,
- state->ray_pdf);
- path_radiance_accum_emission(L, throughput, emission, state->bounce);
+ shader_eval_surface(kg, sd, state, state->flag);
+ shader_prepare_closures(sd, state);
+
+ /* Apply shadow catcher, holdout, emission. */
+ if(!kernel_path_shader_apply(kg,
+ sd,
+ state,
+ ray,
+ throughput,
+ emission_sd,
+ L,
+ NULL))
+ {
+ break;
}
-#endif /* __EMISSION__ */
/* path termination. this is a strange place to put the termination, it's
* mainly due to the mixed in MIS that we use. gives too many unneeded
* shader evaluations, only need emission if we are going to terminate */
- float probability =
- path_state_terminate_probability(kg,
- state,
- throughput*num_samples);
+ float probability = path_state_continuation_probability(kg, state, throughput);
if(probability == 0.0f) {
break;
}
else if(probability != 1.0f) {
- float terminate = path_state_rng_1D_for_decision(kg, rng, state, PRNG_TERMINATE);
+ float terminate = path_state_rng_1D(kg, state, PRNG_TERMINATE);
if(terminate >= probability)
break;
@@ -371,7 +472,7 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
#ifdef __AO__
/* ambient occlusion */
if(kernel_data.integrator.use_ambient_occlusion || (sd->flag & SD_AO)) {
- kernel_path_ao(kg, sd, emission_sd, L, state, rng, throughput, make_float3(0.0f, 0.0f, 0.0f));
+ kernel_path_ao(kg, sd, emission_sd, L, state, throughput, make_float3(0.0f, 0.0f, 0.0f));
}
#endif /* __AO__ */
@@ -379,22 +480,18 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
/* bssrdf scatter to a different location on the same object, replacing
* the closures with a diffuse BSDF */
if(sd->flag & SD_BSSRDF) {
- float bssrdf_probability;
- ShaderClosure *sc = subsurface_scatter_pick_closure(kg, sd, &bssrdf_probability);
+ float bssrdf_u, bssrdf_v;
+ path_state_rng_2D(kg,
+ state,
+ PRNG_BSDF_U,
+ &bssrdf_u, &bssrdf_v);
- /* modify throughput for picking bssrdf or bsdf */
- throughput *= bssrdf_probability;
+ const ShaderClosure *sc = shader_bssrdf_pick(sd, &throughput, &bssrdf_u);
/* do bssrdf scatter step if we picked a bssrdf closure */
if(sc) {
- uint lcg_state = lcg_state_init(rng, state->rng_offset, state->sample, 0x68bc21eb);
-
- float bssrdf_u, bssrdf_v;
- path_state_rng_2D(kg,
- rng,
- state,
- PRNG_BSDF_U,
- &bssrdf_u, &bssrdf_v);
+ uint lcg_state = lcg_state_init(state, 0x68bc21eb);
+
subsurface_scatter_step(kg,
sd,
state,
@@ -412,7 +509,6 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
int all = (kernel_data.integrator.sample_all_lights_indirect) ||
(state->flag & PATH_RAY_SHADOW_CATCHER);
kernel_branched_path_surface_connect_light(kg,
- rng,
sd,
emission_sd,
state,
@@ -423,38 +519,24 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
}
#endif /* defined(__EMISSION__) */
- if(!kernel_path_surface_bounce(kg, rng, sd, &throughput, state, L, ray))
+ if(!kernel_path_surface_bounce(kg, sd, &throughput, state, &L->state, ray))
break;
}
}
+#endif /* defined(__BRANCHED_PATH__) || defined(__BAKING__) */
-ccl_device_inline float kernel_path_integrate(KernelGlobals *kg,
- RNG *rng,
- int sample,
- Ray ray,
- ccl_global float *buffer,
- PathRadiance *L,
- bool *is_shadow_catcher)
+ccl_device_forceinline void kernel_path_integrate(
+ KernelGlobals *kg,
+ PathState *state,
+ float3 throughput,
+ Ray *ray,
+ PathRadiance *L,
+ ccl_global float *buffer,
+ ShaderData *emission_sd)
{
- /* initialize */
- float3 throughput = make_float3(1.0f, 1.0f, 1.0f);
- float L_transparent = 0.0f;
-
- path_radiance_init(L, kernel_data.film.use_light_pass);
-
- /* shader data memory used for both volumes and surfaces, saves stack space */
+ /* Shader data memory used for both volumes and surfaces, saves stack space. */
ShaderData sd;
- /* shader data used by emission, shadows, volume stacks */
- ShaderData emission_sd;
-
- PathState state;
- path_state_init(kg, &emission_sd, &state, rng, sample, &ray);
-
-#ifdef __KERNEL_DEBUG__
- DebugData debug_data;
- debug_data_init(&debug_data);
-#endif /* __KERNEL_DEBUG__ */
#ifdef __SUBSURFACE__
SubsurfaceIndirectRays ss_indirect;
@@ -465,265 +547,82 @@ ccl_device_inline float kernel_path_integrate(KernelGlobals *kg,
/* path iteration */
for(;;) {
- /* intersect scene */
+ /* Find intersection with objects in scene. */
Intersection isect;
- uint visibility = path_state_ray_visibility(kg, &state);
-
-#ifdef __HAIR__
- float difl = 0.0f, extmax = 0.0f;
- uint lcg_state = 0;
-
- if(kernel_data.bvh.have_curves) {
- if((kernel_data.cam.resolution == 1) && (state.flag & PATH_RAY_CAMERA)) {
- float3 pixdiff = ray.dD.dx + ray.dD.dy;
- /*pixdiff = pixdiff - dot(pixdiff, ray.D)*ray.D;*/
- difl = kernel_data.curve.minimum_width * len(pixdiff) * 0.5f;
- }
-
- extmax = kernel_data.curve.maximum_width;
- lcg_state = lcg_state_init(rng, state.rng_offset, state.sample, 0x51633e2d);
- }
-
- if(state.bounce > kernel_data.integrator.ao_bounces) {
- visibility = PATH_RAY_SHADOW;
- ray.t = kernel_data.background.ao_distance;
- }
-
- bool hit = scene_intersect(kg, ray, visibility, &isect, &lcg_state, difl, extmax);
-#else
- bool hit = scene_intersect(kg, ray, visibility, &isect, NULL, 0.0f, 0.0f);
-#endif /* __HAIR__ */
+ bool hit = kernel_path_scene_intersect(kg, state, ray, &isect, L);
-#ifdef __KERNEL_DEBUG__
- if(state.flag & PATH_RAY_CAMERA) {
- debug_data.num_bvh_traversed_nodes += isect.num_traversed_nodes;
- debug_data.num_bvh_traversed_instances += isect.num_traversed_instances;
- debug_data.num_bvh_intersections += isect.num_intersections;
- }
- debug_data.num_ray_bounces++;
-#endif /* __KERNEL_DEBUG__ */
-
-#ifdef __LAMP_MIS__
- if(kernel_data.integrator.use_lamp_mis && !(state.flag & PATH_RAY_CAMERA)) {
- /* ray starting from previous non-transparent bounce */
- Ray light_ray;
-
- light_ray.P = ray.P - state.ray_t*ray.D;
- state.ray_t += isect.t;
- light_ray.D = ray.D;
- light_ray.t = state.ray_t;
- light_ray.time = ray.time;
- light_ray.dD = ray.dD;
- light_ray.dP = ray.dP;
-
- /* intersect with lamp */
- float3 emission;
-
- if(indirect_lamp_emission(kg, &emission_sd, &state, &light_ray, &emission))
- path_radiance_accum_emission(L, throughput, emission, state.bounce);
- }
-#endif /* __LAMP_MIS__ */
+ /* Find intersection with lamps and compute emission for MIS. */
+ kernel_path_lamp_emission(kg, state, ray, throughput, &isect, emission_sd, L);
#ifdef __VOLUME__
- /* Sanitize volume stack. */
- if(!hit) {
- kernel_volume_clean_stack(kg, state.volume_stack);
- }
- /* volume attenuation, emission, scatter */
- if(state.volume_stack[0].shader != SHADER_NONE) {
- Ray volume_ray = ray;
- volume_ray.t = (hit)? isect.t: FLT_MAX;
-
- bool heterogeneous = volume_stack_is_heterogeneous(kg, state.volume_stack);
-
-# ifdef __VOLUME_DECOUPLED__
- int sampling_method = volume_stack_sampling_method(kg, state.volume_stack);
- bool decoupled = kernel_volume_use_decoupled(kg, heterogeneous, true, sampling_method);
-
- if(decoupled) {
- /* cache steps along volume for repeated sampling */
- VolumeSegment volume_segment;
-
- shader_setup_from_volume(kg, &sd, &volume_ray);
- kernel_volume_decoupled_record(kg, &state,
- &volume_ray, &sd, &volume_segment, heterogeneous);
-
- volume_segment.sampling_method = sampling_method;
-
- /* emission */
- if(volume_segment.closure_flag & SD_EMISSION)
- path_radiance_accum_emission(L, throughput, volume_segment.accum_emission, state.bounce);
-
- /* scattering */
- VolumeIntegrateResult result = VOLUME_PATH_ATTENUATED;
-
- if(volume_segment.closure_flag & SD_SCATTER) {
- int all = false;
-
- /* direct light sampling */
- kernel_branched_path_volume_connect_light(kg, rng, &sd,
- &emission_sd, throughput, &state, L, all,
- &volume_ray, &volume_segment);
-
- /* indirect sample. if we use distance sampling and take just
- * one sample for direct and indirect light, we could share
- * this computation, but makes code a bit complex */
- float rphase = path_state_rng_1D_for_decision(kg, rng, &state, PRNG_PHASE);
- float rscatter = path_state_rng_1D_for_decision(kg, rng, &state, PRNG_SCATTER_DISTANCE);
-
- result = kernel_volume_decoupled_scatter(kg,
- &state, &volume_ray, &sd, &throughput,
- rphase, rscatter, &volume_segment, NULL, true);
- }
-
- /* free cached steps */
- kernel_volume_decoupled_free(kg, &volume_segment);
-
- if(result == VOLUME_PATH_SCATTERED) {
- if(kernel_path_volume_bounce(kg, rng, &sd, &throughput, &state, L, &ray))
- continue;
- else
- break;
- }
- else {
- throughput *= volume_segment.accum_transmittance;
- }
- }
- else
-# endif /* __VOLUME_DECOUPLED__ */
- {
- /* integrate along volume segment with distance sampling */
- VolumeIntegrateResult result = kernel_volume_integrate(
- kg, &state, &sd, &volume_ray, L, &throughput, rng, heterogeneous);
-
-# ifdef __VOLUME_SCATTER__
- if(result == VOLUME_PATH_SCATTERED) {
- /* direct lighting */
- kernel_path_volume_connect_light(kg, rng, &sd, &emission_sd, throughput, &state, L);
-
- /* indirect light bounce */
- if(kernel_path_volume_bounce(kg, rng, &sd, &throughput, &state, L, &ray))
- continue;
- else
- break;
- }
-# endif /* __VOLUME_SCATTER__ */
- }
+ /* Volume integration. */
+ VolumeIntegrateResult result = kernel_path_volume(kg,
+ &sd,
+ state,
+ ray,
+ &throughput,
+ &isect,
+ hit,
+ emission_sd,
+ L);
+
+ if(result == VOLUME_PATH_SCATTERED) {
+ continue;
+ }
+ else if(result == VOLUME_PATH_MISSED) {
+ break;
}
-#endif /* __VOLUME__ */
+#endif /* __VOLUME__*/
+ /* Shade background. */
if(!hit) {
- /* eval background shader if nothing hit */
- if(kernel_data.background.transparent && (state.flag & PATH_RAY_CAMERA)) {
- L_transparent += average(throughput);
-
-#ifdef __PASSES__
- if(!(kernel_data.film.pass_flag & PASS_BACKGROUND))
-#endif /* __PASSES__ */
- break;
- }
-
-#ifdef __BACKGROUND__
- /* sample background shader */
- float3 L_background = indirect_background(kg, &emission_sd, &state, &ray);
- path_radiance_accum_background(L, &state, throughput, L_background);
-#endif /* __BACKGROUND__ */
-
+ kernel_path_background(kg, state, ray, throughput, emission_sd, L);
break;
}
- else if(state.bounce > kernel_data.integrator.ao_bounces) {
+ else if(path_state_ao_bounce(kg, state)) {
break;
}
- /* setup shading */
- shader_setup_from_ray(kg, &sd, &isect, &ray);
- float rbsdf = path_state_rng_1D_for_decision(kg, rng, &state, PRNG_BSDF);
- shader_eval_surface(kg, &sd, rng, &state, rbsdf, state.flag, SHADER_CONTEXT_MAIN);
-
-#ifdef __SHADOW_TRICKS__
- if((sd.object_flag & SD_OBJECT_SHADOW_CATCHER)) {
- if(state.flag & PATH_RAY_CAMERA) {
- state.flag |= (PATH_RAY_SHADOW_CATCHER | PATH_RAY_SHADOW_CATCHER_ONLY | PATH_RAY_STORE_SHADOW_INFO);
- state.catcher_object = sd.object;
- if(!kernel_data.background.transparent) {
- L->shadow_color = indirect_background(kg, &emission_sd, &state, &ray);
- }
- }
- }
- else {
- state.flag &= ~PATH_RAY_SHADOW_CATCHER_ONLY;
- }
-#endif /* __SHADOW_TRICKS__ */
-
- /* holdout */
-#ifdef __HOLDOUT__
- if(((sd.flag & SD_HOLDOUT) ||
- (sd.object_flag & SD_OBJECT_HOLDOUT_MASK)) &&
- (state.flag & PATH_RAY_CAMERA))
+ /* Setup and evaluate shader. */
+ shader_setup_from_ray(kg, &sd, &isect, ray);
+ shader_eval_surface(kg, &sd, state, state->flag);
+ shader_prepare_closures(&sd, state);
+
+ /* Apply shadow catcher, holdout, emission. */
+ if(!kernel_path_shader_apply(kg,
+ &sd,
+ state,
+ ray,
+ throughput,
+ emission_sd,
+ L,
+ buffer))
{
- if(kernel_data.background.transparent) {
- float3 holdout_weight;
- if(sd.object_flag & SD_OBJECT_HOLDOUT_MASK) {
- holdout_weight = make_float3(1.0f, 1.0f, 1.0f);
- }
- else {
- holdout_weight = shader_holdout_eval(kg, &sd);
- }
- /* any throughput is ok, should all be identical here */
- L_transparent += average(holdout_weight*throughput);
- }
-
- if(sd.object_flag & SD_OBJECT_HOLDOUT_MASK) {
- break;
- }
- }
-#endif /* __HOLDOUT__ */
-
- /* holdout mask objects do not write data passes */
- kernel_write_data_passes(kg, buffer, L, &sd, sample, &state, throughput);
-
- /* blurring of bsdf after bounces, for rays that have a small likelihood
- * of following this particular path (diffuse, rough glossy) */
- if(kernel_data.integrator.filter_glossy != FLT_MAX) {
- float blur_pdf = kernel_data.integrator.filter_glossy*state.min_ray_pdf;
-
- if(blur_pdf < 1.0f) {
- float blur_roughness = sqrtf(1.0f - blur_pdf)*0.5f;
- shader_bsdf_blur(kg, &sd, blur_roughness);
- }
- }
-
-#ifdef __EMISSION__
- /* emission */
- if(sd.flag & SD_EMISSION) {
- /* todo: is isect.t wrong here for transparent surfaces? */
- float3 emission = indirect_primitive_emission(kg, &sd, isect.t, state.flag, state.ray_pdf);
- path_radiance_accum_emission(L, throughput, emission, state.bounce);
+ break;
}
-#endif /* __EMISSION__ */
/* path termination. this is a strange place to put the termination, it's
* mainly due to the mixed in MIS that we use. gives too many unneeded
* shader evaluations, only need emission if we are going to terminate */
- float probability = path_state_terminate_probability(kg, &state, throughput);
+ float probability = path_state_continuation_probability(kg, state, throughput);
if(probability == 0.0f) {
break;
}
else if(probability != 1.0f) {
- float terminate = path_state_rng_1D_for_decision(kg, rng, &state, PRNG_TERMINATE);
+ float terminate = path_state_rng_1D(kg, state, PRNG_TERMINATE);
if(terminate >= probability)
break;
throughput /= probability;
}
- kernel_update_denoising_features(kg, &sd, &state, L);
+ kernel_update_denoising_features(kg, &sd, state, L);
#ifdef __AO__
/* ambient occlusion */
if(kernel_data.integrator.use_ambient_occlusion || (sd.flag & SD_AO)) {
- kernel_path_ao(kg, &sd, &emission_sd, L, &state, rng, throughput, shader_bsdf_alpha(kg, &sd));
+ kernel_path_ao(kg, &sd, emission_sd, L, state, throughput, shader_bsdf_alpha(kg, &sd));
}
#endif /* __AO__ */
@@ -733,11 +632,10 @@ ccl_device_inline float kernel_path_integrate(KernelGlobals *kg,
if(sd.flag & SD_BSSRDF) {
if(kernel_path_subsurface_scatter(kg,
&sd,
- &emission_sd,
+ emission_sd,
L,
- &state,
- rng,
- &ray,
+ state,
+ ray,
&throughput,
&ss_indirect))
{
@@ -747,24 +645,22 @@ ccl_device_inline float kernel_path_integrate(KernelGlobals *kg,
#endif /* __SUBSURFACE__ */
/* direct lighting */
- kernel_path_surface_connect_light(kg, rng, &sd, &emission_sd, throughput, &state, L);
+ kernel_path_surface_connect_light(kg, &sd, emission_sd, throughput, state, L);
/* compute direct lighting and next bounce */
- if(!kernel_path_surface_bounce(kg, rng, &sd, &throughput, &state, L, &ray))
+ if(!kernel_path_surface_bounce(kg, &sd, &throughput, state, &L->state, ray))
break;
}
#ifdef __SUBSURFACE__
- kernel_path_subsurface_accum_indirect(&ss_indirect, L);
-
/* Trace indirect subsurface rays by restarting the loop. this uses less
* stack memory than invoking kernel_path_indirect.
*/
if(ss_indirect.num_rays) {
kernel_path_subsurface_setup_indirect(kg,
&ss_indirect,
- &state,
- &ray,
+ state,
+ ray,
L,
&throughput);
}
@@ -773,48 +669,48 @@ ccl_device_inline float kernel_path_integrate(KernelGlobals *kg,
}
}
#endif /* __SUBSURFACE__ */
-
-#ifdef __SHADOW_TRICKS__
- *is_shadow_catcher = (state.flag & PATH_RAY_SHADOW_CATCHER);
-#endif /* __SHADOW_TRICKS__ */
-
-#ifdef __KERNEL_DEBUG__
- kernel_write_debug_passes(kg, buffer, &state, &debug_data, sample);
-#endif /* __KERNEL_DEBUG__ */
-
- return 1.0f - L_transparent;
}
ccl_device void kernel_path_trace(KernelGlobals *kg,
- ccl_global float *buffer, ccl_global uint *rng_state,
+ ccl_global float *buffer,
int sample, int x, int y, int offset, int stride)
{
/* buffer offset */
int index = offset + x + y*stride;
int pass_stride = kernel_data.film.pass_stride;
- rng_state += index;
buffer += index*pass_stride;
- /* initialize random numbers and ray */
- RNG rng;
+ /* Initialize random numbers and sample ray. */
+ uint rng_hash;
Ray ray;
- kernel_path_trace_setup(kg, rng_state, sample, x, y, &rng, &ray);
-
- /* integrate */
- PathRadiance L;
- bool is_shadow_catcher;
+ kernel_path_trace_setup(kg, sample, x, y, &rng_hash, &ray);
- if(ray.t != 0.0f) {
- float alpha = kernel_path_integrate(kg, &rng, sample, ray, buffer, &L, &is_shadow_catcher);
- kernel_write_result(kg, buffer, sample, &L, alpha, is_shadow_catcher);
- }
- else {
- kernel_write_result(kg, buffer, sample, NULL, 0.0f, false);
+ if(ray.t == 0.0f) {
+ return;
}
- path_rng_end(kg, rng_state, rng);
+ /* Initialize state. */
+ float3 throughput = make_float3(1.0f, 1.0f, 1.0f);
+
+ PathRadiance L;
+ path_radiance_init(&L, kernel_data.film.use_light_pass);
+
+ ShaderData emission_sd;
+ PathState state;
+ path_state_init(kg, &emission_sd, &state, rng_hash, sample, &ray);
+
+ /* Integrate. */
+ kernel_path_integrate(kg,
+ &state,
+ throughput,
+ &ray,
+ &L,
+ buffer,
+ &emission_sd);
+
+ kernel_write_result(kg, buffer, sample, &L);
}
#endif /* __SPLIT_KERNEL__ */
diff --git a/intern/cycles/kernel/kernel_path_branched.h b/intern/cycles/kernel/kernel_path_branched.h
index 10816d3e5d1..2597d684a36 100644
--- a/intern/cycles/kernel/kernel_path_branched.h
+++ b/intern/cycles/kernel/kernel_path_branched.h
@@ -23,7 +23,6 @@ ccl_device_inline void kernel_branched_path_ao(KernelGlobals *kg,
ShaderData *emission_sd,
PathRadiance *L,
ccl_addr_space PathState *state,
- RNG *rng,
float3 throughput)
{
int num_samples = kernel_data.integrator.ao_samples;
@@ -35,7 +34,7 @@ ccl_device_inline void kernel_branched_path_ao(KernelGlobals *kg,
for(int j = 0; j < num_samples; j++) {
float bsdf_u, bsdf_v;
- path_branched_rng_2D(kg, rng, state, j, num_samples, PRNG_BSDF_U, &bsdf_u, &bsdf_v);
+ path_branched_rng_2D(kg, state->rng_hash, state, j, num_samples, PRNG_BSDF_U, &bsdf_u, &bsdf_v);
float3 ao_D;
float ao_pdf;
@@ -49,13 +48,11 @@ ccl_device_inline void kernel_branched_path_ao(KernelGlobals *kg,
light_ray.P = ray_offset(sd->P, sd->Ng);
light_ray.D = ao_D;
light_ray.t = kernel_data.background.ao_distance;
-#ifdef __OBJECT_MOTION__
light_ray.time = sd->time;
-#endif /* __OBJECT_MOTION__ */
light_ray.dP = sd->dP;
light_ray.dD = differential3_zero();
- if(!shadow_blocked(kg, emission_sd, state, &light_ray, &ao_shadow)) {
+ if(!shadow_blocked(kg, sd, emission_sd, state, &light_ray, &ao_shadow)) {
path_radiance_accum_ao(L, state, throughput*num_samples_inv, ao_alpha, ao_bsdf, ao_shadow);
}
else {
@@ -69,7 +66,7 @@ ccl_device_inline void kernel_branched_path_ao(KernelGlobals *kg,
/* bounce off surface and integrate indirect light */
ccl_device_noinline void kernel_branched_path_surface_indirect_light(KernelGlobals *kg,
- RNG *rng, ShaderData *sd, ShaderData *indirect_sd, ShaderData *emission_sd,
+ ShaderData *sd, ShaderData *indirect_sd, ShaderData *emission_sd,
float3 throughput, float num_samples_adjust, PathState *state, PathRadiance *L)
{
float sum_sample_weight = 0.0f;
@@ -113,35 +110,38 @@ ccl_device_noinline void kernel_branched_path_surface_indirect_light(KernelGloba
num_samples = ceil_to_int(num_samples_adjust*num_samples);
float num_samples_inv = num_samples_adjust/num_samples;
- RNG bsdf_rng = cmj_hash(*rng, i);
for(int j = 0; j < num_samples; j++) {
PathState ps = *state;
float3 tp = throughput;
Ray bsdf_ray;
+#ifdef __SHADOW_TRICKS__
+ float shadow_transparency = L->shadow_transparency;
+#endif
+
+ ps.rng_hash = cmj_hash(state->rng_hash, i);
if(!kernel_branched_path_surface_bounce(kg,
- &bsdf_rng,
sd,
sc,
j,
num_samples,
&tp,
&ps,
- L,
+ &L->state,
&bsdf_ray,
sum_sample_weight))
{
continue;
}
+ ps.rng_hash = state->rng_hash;
+
kernel_path_indirect(kg,
indirect_sd,
emission_sd,
- rng,
&bsdf_ray,
tp*num_samples_inv,
- num_samples,
&ps,
L);
@@ -149,6 +149,10 @@ ccl_device_noinline void kernel_branched_path_surface_indirect_light(KernelGloba
* for the next samples */
path_radiance_sum_indirect(L);
path_radiance_reset_indirect(L);
+
+#ifdef __SHADOW_TRICKS__
+ L->shadow_transparency = shadow_transparency;
+#endif
}
}
}
@@ -160,7 +164,6 @@ ccl_device void kernel_branched_path_subsurface_scatter(KernelGlobals *kg,
ShaderData *emission_sd,
PathRadiance *L,
PathState *state,
- RNG *rng,
Ray *ray,
float3 throughput)
{
@@ -171,17 +174,17 @@ ccl_device void kernel_branched_path_subsurface_scatter(KernelGlobals *kg,
continue;
/* set up random number generator */
- uint lcg_state = lcg_state_init(rng, state->rng_offset, state->sample, 0x68bc21eb);
+ uint lcg_state = lcg_state_init(state, 0x68bc21eb);
int num_samples = kernel_data.integrator.subsurface_samples;
float num_samples_inv = 1.0f/num_samples;
- RNG bssrdf_rng = cmj_hash(*rng, i);
+ uint bssrdf_rng_hash = cmj_hash(state->rng_hash, i);
/* do subsurface scatter step with copy of shader data, this will
* replace the BSSRDF with a diffuse BSDF closure */
for(int j = 0; j < num_samples; j++) {
SubsurfaceIntersection ss_isect;
float bssrdf_u, bssrdf_v;
- path_branched_rng_2D(kg, &bssrdf_rng, state, j, num_samples, PRNG_BSDF_U, &bssrdf_u, &bssrdf_v);
+ path_branched_rng_2D(kg, bssrdf_rng_hash, state, j, num_samples, PRNG_BSDF_U, &bssrdf_u, &bssrdf_v);
int num_hits = subsurface_scatter_multi_intersect(kg,
&ss_isect,
sd,
@@ -234,7 +237,6 @@ ccl_device void kernel_branched_path_subsurface_scatter(KernelGlobals *kg,
(state->flag & PATH_RAY_SHADOW_CATCHER);
kernel_branched_path_surface_connect_light(
kg,
- rng,
&bssrdf_sd,
emission_sd,
&hit_state,
@@ -248,7 +250,6 @@ ccl_device void kernel_branched_path_subsurface_scatter(KernelGlobals *kg,
/* indirect light */
kernel_branched_path_surface_indirect_light(
kg,
- rng,
&bssrdf_sd,
indirect_sd,
emission_sd,
@@ -262,17 +263,15 @@ ccl_device void kernel_branched_path_subsurface_scatter(KernelGlobals *kg,
}
#endif /* __SUBSURFACE__ */
-ccl_device float kernel_branched_path_integrate(KernelGlobals *kg,
- RNG *rng,
- int sample,
- Ray ray,
- ccl_global float *buffer,
- PathRadiance *L,
- bool *is_shadow_catcher)
+ccl_device void kernel_branched_path_integrate(KernelGlobals *kg,
+ uint rng_hash,
+ int sample,
+ Ray ray,
+ ccl_global float *buffer,
+ PathRadiance *L)
{
/* initialize */
float3 throughput = make_float3(1.0f, 1.0f, 1.0f);
- float L_transparent = 0.0f;
path_radiance_init(L, kernel_data.film.use_light_pass);
@@ -282,48 +281,16 @@ ccl_device float kernel_branched_path_integrate(KernelGlobals *kg,
ShaderData emission_sd, indirect_sd;
PathState state;
- path_state_init(kg, &emission_sd, &state, rng, sample, &ray);
-
-#ifdef __KERNEL_DEBUG__
- DebugData debug_data;
- debug_data_init(&debug_data);
-#endif /* __KERNEL_DEBUG__ */
+ path_state_init(kg, &emission_sd, &state, rng_hash, sample, &ray);
/* Main Loop
* Here we only handle transparency intersections from the camera ray.
* Indirect bounces are handled in kernel_branched_path_surface_indirect_light().
*/
for(;;) {
- /* intersect scene */
+ /* Find intersection with objects in scene. */
Intersection isect;
- uint visibility = path_state_ray_visibility(kg, &state);
-
-#ifdef __HAIR__
- float difl = 0.0f, extmax = 0.0f;
- uint lcg_state = 0;
-
- if(kernel_data.bvh.have_curves) {
- if(kernel_data.cam.resolution == 1) {
- float3 pixdiff = ray.dD.dx + ray.dD.dy;
- /*pixdiff = pixdiff - dot(pixdiff, ray.D)*ray.D;*/
- difl = kernel_data.curve.minimum_width * len(pixdiff) * 0.5f;
- }
-
- extmax = kernel_data.curve.maximum_width;
- lcg_state = lcg_state_init(rng, state.rng_offset, state.sample, 0x51633e2d);
- }
-
- bool hit = scene_intersect(kg, ray, visibility, &isect, &lcg_state, difl, extmax);
-#else
- bool hit = scene_intersect(kg, ray, visibility, &isect, NULL, 0.0f, 0.0f);
-#endif /* __HAIR__ */
-
-#ifdef __KERNEL_DEBUG__
- debug_data.num_bvh_traversed_nodes += isect.num_traversed_nodes;
- debug_data.num_bvh_traversed_instances += isect.num_traversed_instances;
- debug_data.num_bvh_intersections += isect.num_intersections;
- debug_data.num_ray_bounces++;
-#endif /* __KERNEL_DEBUG__ */
+ bool hit = kernel_path_scene_intersect(kg, &state, &ray, &isect, L);
#ifdef __VOLUME__
/* Sanitize volume stack. */
@@ -353,7 +320,7 @@ ccl_device float kernel_branched_path_integrate(KernelGlobals *kg,
int all = kernel_data.integrator.sample_all_lights_direct;
- kernel_branched_path_volume_connect_light(kg, rng, &sd,
+ kernel_branched_path_volume_connect_light(kg, &sd,
&emission_sd, throughput, &state, L, all,
&volume_ray, &volume_segment);
@@ -372,30 +339,25 @@ ccl_device float kernel_branched_path_integrate(KernelGlobals *kg,
/* scatter sample. if we use distance sampling and take just one
* sample for direct and indirect light, we could share this
* computation, but makes code a bit complex */
- float rphase = path_state_rng_1D_for_decision(kg, rng, &ps, PRNG_PHASE);
- float rscatter = path_state_rng_1D_for_decision(kg, rng, &ps, PRNG_SCATTER_DISTANCE);
+ float rphase = path_state_rng_1D(kg, &ps, PRNG_PHASE_CHANNEL);
+ float rscatter = path_state_rng_1D(kg, &ps, PRNG_SCATTER_DISTANCE);
VolumeIntegrateResult result = kernel_volume_decoupled_scatter(kg,
&ps, &pray, &sd, &tp, rphase, rscatter, &volume_segment, NULL, false);
- (void)result;
- kernel_assert(result == VOLUME_PATH_SCATTERED);
-
- if(kernel_path_volume_bounce(kg,
- rng,
+ if(result == VOLUME_PATH_SCATTERED &&
+ kernel_path_volume_bounce(kg,
&sd,
&tp,
&ps,
- L,
+ &L->state,
&pray))
{
kernel_path_indirect(kg,
&indirect_sd,
&emission_sd,
- rng,
&pray,
tp*num_samples_inv,
- num_samples,
&ps,
L);
@@ -409,7 +371,7 @@ ccl_device float kernel_branched_path_integrate(KernelGlobals *kg,
/* emission and transmittance */
if(volume_segment.closure_flag & SD_EMISSION)
- path_radiance_accum_emission(L, throughput, volume_segment.accum_emission, state.bounce);
+ path_radiance_accum_emission(L, &state, throughput, volume_segment.accum_emission);
throughput *= volume_segment.accum_transmittance;
/* free cached steps */
@@ -431,29 +393,26 @@ ccl_device float kernel_branched_path_integrate(KernelGlobals *kg,
path_state_branch(&ps, j, num_samples);
VolumeIntegrateResult result = kernel_volume_integrate(
- kg, &ps, &sd, &volume_ray, L, &tp, rng, heterogeneous);
+ kg, &ps, &sd, &volume_ray, L, &tp, heterogeneous);
#ifdef __VOLUME_SCATTER__
if(result == VOLUME_PATH_SCATTERED) {
/* todo: support equiangular, MIS and all light sampling.
* alternatively get decoupled ray marching working on the GPU */
- kernel_path_volume_connect_light(kg, rng, &sd, &emission_sd, tp, &state, L);
+ kernel_path_volume_connect_light(kg, &sd, &emission_sd, tp, &state, L);
if(kernel_path_volume_bounce(kg,
- rng,
&sd,
&tp,
&ps,
- L,
+ &L->state,
&pray))
{
kernel_path_indirect(kg,
&indirect_sd,
&emission_sd,
- rng,
&pray,
tp,
- num_samples,
&ps,
L);
@@ -472,89 +431,42 @@ ccl_device float kernel_branched_path_integrate(KernelGlobals *kg,
}
#endif /* __VOLUME__ */
+ /* Shade background. */
if(!hit) {
- /* eval background shader if nothing hit */
- if(kernel_data.background.transparent) {
- L_transparent += average(throughput);
-
-#ifdef __PASSES__
- if(!(kernel_data.film.pass_flag & PASS_BACKGROUND))
-#endif /* __PASSES__ */
- break;
- }
-
-#ifdef __BACKGROUND__
- /* sample background shader */
- float3 L_background = indirect_background(kg, &emission_sd, &state, &ray);
- path_radiance_accum_background(L, &state, throughput, L_background);
-#endif /* __BACKGROUND__ */
-
+ kernel_path_background(kg, &state, &ray, throughput, &emission_sd, L);
break;
}
- /* setup shading */
+ /* Setup and evaluate shader. */
shader_setup_from_ray(kg, &sd, &isect, &ray);
- shader_eval_surface(kg, &sd, rng, &state, 0.0f, state.flag, SHADER_CONTEXT_MAIN);
+ shader_eval_surface(kg, &sd, &state, state.flag);
shader_merge_closures(&sd);
-#ifdef __SHADOW_TRICKS__
- if((sd.object_flag & SD_OBJECT_SHADOW_CATCHER)) {
- if(state.flag & PATH_RAY_CAMERA) {
- state.flag |= (PATH_RAY_SHADOW_CATCHER | PATH_RAY_SHADOW_CATCHER_ONLY | PATH_RAY_STORE_SHADOW_INFO);
- state.catcher_object = sd.object;
- if(!kernel_data.background.transparent) {
- L->shadow_color = indirect_background(kg, &emission_sd, &state, &ray);
- }
- }
- }
- else {
- state.flag &= ~PATH_RAY_SHADOW_CATCHER_ONLY;
- }
-#endif /* __SHADOW_TRICKS__ */
-
- /* holdout */
-#ifdef __HOLDOUT__
- if((sd.flag & SD_HOLDOUT) || (sd.object_flag & SD_OBJECT_HOLDOUT_MASK)) {
- if(kernel_data.background.transparent) {
- float3 holdout_weight;
- if(sd.object_flag & SD_OBJECT_HOLDOUT_MASK) {
- holdout_weight = make_float3(1.0f, 1.0f, 1.0f);
- }
- else {
- holdout_weight = shader_holdout_eval(kg, &sd);
- }
- /* any throughput is ok, should all be identical here */
- L_transparent += average(holdout_weight*throughput);
- }
- if(sd.object_flag & SD_OBJECT_HOLDOUT_MASK) {
- break;
- }
- }
-#endif /* __HOLDOUT__ */
-
- /* holdout mask objects do not write data passes */
- kernel_write_data_passes(kg, buffer, L, &sd, sample, &state, throughput);
-
-#ifdef __EMISSION__
- /* emission */
- if(sd.flag & SD_EMISSION) {
- float3 emission = indirect_primitive_emission(kg, &sd, isect.t, state.flag, state.ray_pdf);
- path_radiance_accum_emission(L, throughput, emission, state.bounce);
+ /* Apply shadow catcher, holdout, emission. */
+ if(!kernel_path_shader_apply(kg,
+ &sd,
+ &state,
+ &ray,
+ throughput,
+ &emission_sd,
+ L,
+ buffer))
+ {
+ break;
}
-#endif /* __EMISSION__ */
/* transparency termination */
if(state.flag & PATH_RAY_TRANSPARENT) {
/* path termination. this is a strange place to put the termination, it's
* mainly due to the mixed in MIS that we use. gives too many unneeded
* shader evaluations, only need emission if we are going to terminate */
- float probability = path_state_terminate_probability(kg, &state, throughput);
+ float probability = path_state_continuation_probability(kg, &state, throughput);
if(probability == 0.0f) {
break;
}
else if(probability != 1.0f) {
- float terminate = path_state_rng_1D_for_decision(kg, rng, &state, PRNG_TERMINATE);
+ float terminate = path_state_rng_1D(kg, &state, PRNG_TERMINATE);
if(terminate >= probability)
break;
@@ -568,7 +480,7 @@ ccl_device float kernel_branched_path_integrate(KernelGlobals *kg,
#ifdef __AO__
/* ambient occlusion */
if(kernel_data.integrator.use_ambient_occlusion || (sd.flag & SD_AO)) {
- kernel_branched_path_ao(kg, &sd, &emission_sd, L, &state, rng, throughput);
+ kernel_branched_path_ao(kg, &sd, &emission_sd, L, &state, throughput);
}
#endif /* __AO__ */
@@ -576,7 +488,7 @@ ccl_device float kernel_branched_path_integrate(KernelGlobals *kg,
/* bssrdf scatter to a different location on the same object */
if(sd.flag & SD_BSSRDF) {
kernel_branched_path_subsurface_scatter(kg, &sd, &indirect_sd, &emission_sd,
- L, &state, rng, &ray, throughput);
+ L, &state, &ray, throughput);
}
#endif /* __SUBSURFACE__ */
@@ -588,13 +500,13 @@ ccl_device float kernel_branched_path_integrate(KernelGlobals *kg,
if(kernel_data.integrator.use_direct_light) {
int all = (kernel_data.integrator.sample_all_lights_direct) ||
(state.flag & PATH_RAY_SHADOW_CATCHER);
- kernel_branched_path_surface_connect_light(kg, rng,
+ kernel_branched_path_surface_connect_light(kg,
&sd, &emission_sd, &hit_state, throughput, 1.0f, L, all);
}
#endif /* __EMISSION__ */
/* indirect light */
- kernel_branched_path_surface_indirect_light(kg, rng,
+ kernel_branched_path_surface_indirect_light(kg,
&sd, &indirect_sd, &emission_sd, throughput, 1.0f, &hit_state, L);
/* continue in case of transparency */
@@ -623,48 +535,31 @@ ccl_device float kernel_branched_path_integrate(KernelGlobals *kg,
kernel_volume_stack_enter_exit(kg, &sd, state.volume_stack);
#endif /* __VOLUME__ */
}
-
-#ifdef __SHADOW_TRICKS__
- *is_shadow_catcher = (state.flag & PATH_RAY_SHADOW_CATCHER);
-#endif /* __SHADOW_TRICKS__ */
-
-#ifdef __KERNEL_DEBUG__
- kernel_write_debug_passes(kg, buffer, &state, &debug_data, sample);
-#endif /* __KERNEL_DEBUG__ */
-
- return 1.0f - L_transparent;
}
ccl_device void kernel_branched_path_trace(KernelGlobals *kg,
- ccl_global float *buffer, ccl_global uint *rng_state,
+ ccl_global float *buffer,
int sample, int x, int y, int offset, int stride)
{
/* buffer offset */
int index = offset + x + y*stride;
int pass_stride = kernel_data.film.pass_stride;
- rng_state += index;
buffer += index*pass_stride;
/* initialize random numbers and ray */
- RNG rng;
+ uint rng_hash;
Ray ray;
- kernel_path_trace_setup(kg, rng_state, sample, x, y, &rng, &ray);
+ kernel_path_trace_setup(kg, sample, x, y, &rng_hash, &ray);
/* integrate */
PathRadiance L;
- bool is_shadow_catcher;
if(ray.t != 0.0f) {
- float alpha = kernel_branched_path_integrate(kg, &rng, sample, ray, buffer, &L, &is_shadow_catcher);
- kernel_write_result(kg, buffer, sample, &L, alpha, is_shadow_catcher);
+ kernel_branched_path_integrate(kg, rng_hash, sample, ray, buffer, &L);
+ kernel_write_result(kg, buffer, sample, &L);
}
- else {
- kernel_write_result(kg, buffer, sample, NULL, 0.0f, false);
- }
-
- path_rng_end(kg, rng_state, rng);
}
#endif /* __SPLIT_KERNEL__ */
diff --git a/intern/cycles/kernel/kernel_path_common.h b/intern/cycles/kernel/kernel_path_common.h
index 82f83deb595..d83fd474cde 100644
--- a/intern/cycles/kernel/kernel_path_common.h
+++ b/intern/cycles/kernel/kernel_path_common.h
@@ -19,10 +19,9 @@
CCL_NAMESPACE_BEGIN
ccl_device_inline void kernel_path_trace_setup(KernelGlobals *kg,
- ccl_global uint *rng_state,
int sample,
int x, int y,
- RNG *rng,
+ uint *rng_hash,
ccl_addr_space Ray *ray)
{
float filter_u;
@@ -30,24 +29,20 @@ ccl_device_inline void kernel_path_trace_setup(KernelGlobals *kg,
int num_samples = kernel_data.integrator.aa_samples;
- if(sample == kernel_data.integrator.start_sample) {
- *rng_state = hash_int_2d(x, y);
- }
-
- path_rng_init(kg, rng_state, sample, num_samples, rng, x, y, &filter_u, &filter_v);
+ path_rng_init(kg, sample, num_samples, rng_hash, x, y, &filter_u, &filter_v);
/* sample camera ray */
float lens_u = 0.0f, lens_v = 0.0f;
if(kernel_data.cam.aperturesize > 0.0f)
- path_rng_2D(kg, rng, sample, num_samples, PRNG_LENS_U, &lens_u, &lens_v);
+ path_rng_2D(kg, *rng_hash, sample, num_samples, PRNG_LENS_U, &lens_u, &lens_v);
float time = 0.0f;
#ifdef __CAMERA_MOTION__
if(kernel_data.cam.shuttertime != -1.0f)
- time = path_rng_1D(kg, rng, sample, num_samples, PRNG_TIME);
+ time = path_rng_1D(kg, *rng_hash, sample, num_samples, PRNG_TIME);
#endif
camera_sample(kg, x, y, filter_u, filter_v, lens_u, lens_v, time, ray);
diff --git a/intern/cycles/kernel/kernel_path_state.h b/intern/cycles/kernel/kernel_path_state.h
index 5d92fd12201..eccee54c0e3 100644
--- a/intern/cycles/kernel/kernel_path_state.h
+++ b/intern/cycles/kernel/kernel_path_state.h
@@ -19,15 +19,17 @@ CCL_NAMESPACE_BEGIN
ccl_device_inline void path_state_init(KernelGlobals *kg,
ShaderData *stack_sd,
ccl_addr_space PathState *state,
- RNG *rng,
+ uint rng_hash,
int sample,
ccl_addr_space Ray *ray)
{
state->flag = PATH_RAY_CAMERA|PATH_RAY_MIS_SKIP;
+ state->rng_hash = rng_hash;
state->rng_offset = PRNG_BASE_NUM;
state->sample = sample;
state->num_samples = kernel_data.integrator.aa_samples;
+ state->branch_factor = 1.0f;
state->bounce = 0;
state->diffuse_bounce = 0;
@@ -58,16 +60,12 @@ ccl_device_inline void path_state_init(KernelGlobals *kg,
/* Initialize volume stack with volume we are inside of. */
kernel_volume_stack_init(kg, stack_sd, state, ray, state->volume_stack);
/* Seed RNG for cases where we can't use stratified samples .*/
- state->rng_congruential = lcg_init(*rng + sample*0x51633e2d);
+ state->rng_congruential = lcg_init(rng_hash + sample*0x51633e2d);
}
else {
state->volume_stack[0].shader = SHADER_NONE;
}
#endif
-
-#ifdef __SHADOW_TRICKS__
- state->catcher_object = OBJECT_NONE;
-#endif
}
ccl_device_inline void path_state_next(KernelGlobals *kg, ccl_addr_space PathState *state, int label)
@@ -78,12 +76,12 @@ ccl_device_inline void path_state_next(KernelGlobals *kg, ccl_addr_space PathSta
state->flag |= PATH_RAY_TRANSPARENT;
state->transparent_bounce++;
- /* don't increase random number generator offset here, to avoid some
- * unwanted patterns, see path_state_rng_1D_for_decision */
-
if(!kernel_data.integrator.transparent_shadows)
state->flag |= PATH_RAY_MIS_SKIP;
+ /* random number generator next bounce */
+ state->rng_offset += PRNG_BOUNCE_NUM;
+
return;
}
@@ -146,7 +144,7 @@ ccl_device_inline void path_state_next(KernelGlobals *kg, ccl_addr_space PathSta
#endif
}
-ccl_device_inline uint path_state_ray_visibility(KernelGlobals *kg, PathState *state)
+ccl_device_inline uint path_state_ray_visibility(KernelGlobals *kg, ccl_addr_space PathState *state)
{
uint flag = state->flag & PATH_RAY_ALL_VISIBILITY;
@@ -160,17 +158,28 @@ ccl_device_inline uint path_state_ray_visibility(KernelGlobals *kg, PathState *s
return flag;
}
-ccl_device_inline float path_state_terminate_probability(KernelGlobals *kg, ccl_addr_space PathState *state, const float3 throughput)
+ccl_device_inline float path_state_continuation_probability(KernelGlobals *kg,
+ ccl_addr_space PathState *state,
+ const float3 throughput)
{
if(state->flag & PATH_RAY_TRANSPARENT) {
- /* transparent rays treated separately */
- if(state->transparent_bounce >= kernel_data.integrator.transparent_max_bounce)
+ /* Transparent rays are treated separately with own max bounces. */
+ if(state->transparent_bounce >= kernel_data.integrator.transparent_max_bounce) {
return 0.0f;
- else if(state->transparent_bounce <= kernel_data.integrator.transparent_min_bounce)
+ }
+ /* Do at least one bounce without RR. */
+ else if(state->transparent_bounce <= 1) {
return 1.0f;
+ }
+#ifdef __SHADOW_TRICKS__
+ /* Exception for shadow catcher not working correctly with RR. */
+ else if((state->flag & PATH_RAY_SHADOW_CATCHER) && (state->transparent_bounce <= 8)) {
+ return 1.0f;
+ }
+#endif
}
else {
- /* other rays */
+ /* Test max bounces for various ray types. */
if((state->bounce >= kernel_data.integrator.max_bounce) ||
(state->diffuse_bounce >= kernel_data.integrator.max_diffuse_bounce) ||
(state->glossy_bounce >= kernel_data.integrator.max_glossy_bounce) ||
@@ -181,13 +190,21 @@ ccl_device_inline float path_state_terminate_probability(KernelGlobals *kg, ccl_
{
return 0.0f;
}
- else if(state->bounce <= kernel_data.integrator.min_bounce) {
+ /* Do at least one bounce without RR. */
+ else if(state->bounce <= 1) {
return 1.0f;
}
+#ifdef __SHADOW_TRICKS__
+ /* Exception for shadow catcher not working correctly with RR. */
+ else if((state->flag & PATH_RAY_SHADOW_CATCHER) && (state->bounce <= 3)) {
+ return 1.0f;
+ }
+#endif
}
- /* probalistic termination */
- return average(throughput); /* todo: try using max here */
+ /* Probalistic termination: use sqrt() to roughly match typical view
+ * transform and do path termination a bit later on average. */
+ return min(sqrtf(max3(fabs(throughput)) * state->branch_factor), 1.0f);
}
/* TODO(DingTo): Find more meaningful name for this */
@@ -200,5 +217,30 @@ ccl_device_inline void path_state_modify_bounce(ccl_addr_space PathState *state,
state->bounce -= 1;
}
+ccl_device_inline bool path_state_ao_bounce(KernelGlobals *kg, ccl_addr_space PathState *state)
+{
+ if(state->bounce <= kernel_data.integrator.ao_bounces) {
+ return false;
+ }
+
+ int bounce = state->bounce - state->transmission_bounce - (state->glossy_bounce > 0);
+ return (bounce > kernel_data.integrator.ao_bounces);
+}
+
+ccl_device_inline void path_state_branch(ccl_addr_space PathState *state,
+ int branch,
+ int num_branches)
+{
+ state->rng_offset += PRNG_BOUNCE_NUM;
+
+ if(num_branches > 1) {
+ /* Path is splitting into a branch, adjust so that each branch
+ * still gets a unique sample from the same sequence. */
+ state->sample = state->sample*num_branches + branch;
+ state->num_samples = state->num_samples*num_branches;
+ state->branch_factor *= num_branches;
+ }
+}
+
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/kernel_path_subsurface.h b/intern/cycles/kernel/kernel_path_subsurface.h
index 10b568ac3dd..1436e8e5a5b 100644
--- a/intern/cycles/kernel/kernel_path_subsurface.h
+++ b/intern/cycles/kernel/kernel_path_subsurface.h
@@ -28,16 +28,14 @@ bool kernel_path_subsurface_scatter(
ShaderData *emission_sd,
PathRadiance *L,
ccl_addr_space PathState *state,
- RNG *rng,
ccl_addr_space Ray *ray,
ccl_addr_space float3 *throughput,
ccl_addr_space SubsurfaceIndirectRays *ss_indirect)
{
- float bssrdf_probability;
- ShaderClosure *sc = subsurface_scatter_pick_closure(kg, sd, &bssrdf_probability);
+ float bssrdf_u, bssrdf_v;
+ path_state_rng_2D(kg, state, PRNG_BSDF_U, &bssrdf_u, &bssrdf_v);
- /* modify throughput for picking bssrdf or bsdf */
- *throughput *= bssrdf_probability;
+ const ShaderClosure *sc = shader_bssrdf_pick(sd, throughput, &bssrdf_u);
/* do bssrdf scatter step if we picked a bssrdf closure */
if(sc) {
@@ -45,13 +43,11 @@ bool kernel_path_subsurface_scatter(
* the second one should be converted to a diffuse BSDF to
* avoid this.
*/
- kernel_assert(!ss_indirect->tracing);
+ kernel_assert(!(state->flag & PATH_RAY_DIFFUSE_ANCESTOR));
- uint lcg_state = lcg_state_init(rng, state->rng_offset, state->sample, 0x68bc21eb);
+ uint lcg_state = lcg_state_init_addrspace(state, 0x68bc21eb);
SubsurfaceIntersection ss_isect;
- float bssrdf_u, bssrdf_v;
- path_state_rng_2D(kg, rng, state, PRNG_BSDF_U, &bssrdf_u, &bssrdf_v);
int num_hits = subsurface_scatter_multi_intersect(kg,
&ss_isect,
sd,
@@ -60,7 +56,7 @@ bool kernel_path_subsurface_scatter(
bssrdf_u, bssrdf_v,
false);
# ifdef __VOLUME__
- ss_indirect->need_update_volume_stack =
+ bool need_update_volume_stack =
kernel_data.integrator.use_volumes &&
sd->object_flag & SD_OBJECT_INTERSECTS_VOLUME;
# endif /* __VOLUME__ */
@@ -79,29 +75,25 @@ bool kernel_path_subsurface_scatter(
sc,
false);
+ kernel_path_surface_connect_light(kg, sd, emission_sd, *throughput, state, L);
+
ccl_addr_space PathState *hit_state = &ss_indirect->state[ss_indirect->num_rays];
ccl_addr_space Ray *hit_ray = &ss_indirect->rays[ss_indirect->num_rays];
ccl_addr_space float3 *hit_tp = &ss_indirect->throughputs[ss_indirect->num_rays];
- PathRadiance *hit_L = &ss_indirect->L[ss_indirect->num_rays];
+ PathRadianceState *hit_L_state = &ss_indirect->L_state[ss_indirect->num_rays];
*hit_state = *state;
*hit_ray = *ray;
*hit_tp = *throughput;
+ *hit_L_state = L->state;
hit_state->rng_offset += PRNG_BOUNCE_NUM;
- path_radiance_init(hit_L, kernel_data.film.use_light_pass);
- hit_L->direct_throughput = L->direct_throughput;
- path_radiance_copy_indirect(hit_L, L);
-
- kernel_path_surface_connect_light(kg, rng, sd, emission_sd, *hit_tp, state, hit_L);
-
if(kernel_path_surface_bounce(kg,
- rng,
sd,
hit_tp,
hit_state,
- hit_L,
+ hit_L_state,
hit_ray))
{
# ifdef __LAMP_MIS__
@@ -109,7 +101,7 @@ bool kernel_path_subsurface_scatter(
# endif /* __LAMP_MIS__ */
# ifdef __VOLUME__
- if(ss_indirect->need_update_volume_stack) {
+ if(need_update_volume_stack) {
Ray volume_ray = *ray;
/* Setup ray from previous surface point to the new one. */
volume_ray.D = normalize_len(hit_ray->P - volume_ray.P,
@@ -122,12 +114,8 @@ bool kernel_path_subsurface_scatter(
hit_state->volume_stack);
}
# endif /* __VOLUME__ */
- path_radiance_reset_indirect(L);
ss_indirect->num_rays++;
}
- else {
- path_radiance_accum_sample(L, hit_L, 1);
- }
}
return true;
}
@@ -137,23 +125,9 @@ bool kernel_path_subsurface_scatter(
ccl_device_inline void kernel_path_subsurface_init_indirect(
ccl_addr_space SubsurfaceIndirectRays *ss_indirect)
{
- ss_indirect->tracing = false;
ss_indirect->num_rays = 0;
}
-ccl_device void kernel_path_subsurface_accum_indirect(
- ccl_addr_space SubsurfaceIndirectRays *ss_indirect,
- PathRadiance *L)
-{
- if(ss_indirect->tracing) {
- path_radiance_sum_indirect(L);
- path_radiance_accum_sample(&ss_indirect->direct_L, L, 1);
- if(ss_indirect->num_rays == 0) {
- *L = ss_indirect->direct_L;
- }
- }
-}
-
ccl_device void kernel_path_subsurface_setup_indirect(
KernelGlobals *kg,
ccl_addr_space SubsurfaceIndirectRays *ss_indirect,
@@ -162,20 +136,15 @@ ccl_device void kernel_path_subsurface_setup_indirect(
PathRadiance *L,
ccl_addr_space float3 *throughput)
{
- if(!ss_indirect->tracing) {
- ss_indirect->direct_L = *L;
- }
- ss_indirect->tracing = true;
-
/* Setup state, ray and throughput for indirect SSS rays. */
ss_indirect->num_rays--;
- ccl_addr_space Ray *indirect_ray = &ss_indirect->rays[ss_indirect->num_rays];
- PathRadiance *indirect_L = &ss_indirect->L[ss_indirect->num_rays];
+ path_radiance_sum_indirect(L);
+ path_radiance_reset_indirect(L);
*state = ss_indirect->state[ss_indirect->num_rays];
- *ray = *indirect_ray;
- *L = *indirect_L;
+ *ray = ss_indirect->rays[ss_indirect->num_rays];
+ L->state = ss_indirect->L_state[ss_indirect->num_rays];
*throughput = ss_indirect->throughputs[ss_indirect->num_rays];
state->rng_offset += ss_indirect->num_rays * PRNG_BOUNCE_NUM;
diff --git a/intern/cycles/kernel/kernel_path_surface.h b/intern/cycles/kernel/kernel_path_surface.h
index dcb577e176f..7b566b01b04 100644
--- a/intern/cycles/kernel/kernel_path_surface.h
+++ b/intern/cycles/kernel/kernel_path_surface.h
@@ -20,7 +20,6 @@ CCL_NAMESPACE_BEGIN
/* branched path tracing: connect path directly to position on one or more lights and add it to L */
ccl_device_noinline void kernel_branched_path_surface_connect_light(
KernelGlobals *kg,
- RNG *rng,
ShaderData *sd,
ShaderData *emission_sd,
ccl_addr_space PathState *state,
@@ -50,12 +49,12 @@ ccl_device_noinline void kernel_branched_path_surface_connect_light(
int num_samples = ceil_to_int(num_samples_adjust*light_select_num_samples(kg, i));
float num_samples_inv = num_samples_adjust/(num_samples*kernel_data.integrator.num_all_lights);
- RNG lamp_rng = cmj_hash(*rng, i);
+ uint lamp_rng_hash = cmj_hash(state->rng_hash, i);
for(int j = 0; j < num_samples; j++) {
float light_u, light_v;
- path_branched_rng_2D(kg, &lamp_rng, state, j, num_samples, PRNG_LIGHT_U, &light_u, &light_v);
- float terminate = path_branched_rng_light_termination(kg, &lamp_rng, state, j, num_samples);
+ path_branched_rng_2D(kg, lamp_rng_hash, state, j, num_samples, PRNG_LIGHT_U, &light_u, &light_v);
+ float terminate = path_branched_rng_light_termination(kg, lamp_rng_hash, state, j, num_samples);
LightSample ls;
if(lamp_light_sample(kg, i, light_u, light_v, sd->P, &ls)) {
@@ -68,7 +67,7 @@ ccl_device_noinline void kernel_branched_path_surface_connect_light(
/* trace shadow ray */
float3 shadow;
- if(!shadow_blocked(kg, emission_sd, state, &light_ray, &shadow)) {
+ if(!shadow_blocked(kg, sd, emission_sd, state, &light_ray, &shadow)) {
/* accumulate */
path_radiance_accum_light(L, state, throughput*num_samples_inv, &L_light, shadow, num_samples_inv, is_lamp);
}
@@ -86,17 +85,16 @@ ccl_device_noinline void kernel_branched_path_surface_connect_light(
float num_samples_inv = num_samples_adjust/num_samples;
for(int j = 0; j < num_samples; j++) {
- float light_t = path_branched_rng_1D(kg, rng, state, j, num_samples, PRNG_LIGHT);
float light_u, light_v;
- path_branched_rng_2D(kg, rng, state, j, num_samples, PRNG_LIGHT_U, &light_u, &light_v);
- float terminate = path_branched_rng_light_termination(kg, rng, state, j, num_samples);
+ path_branched_rng_2D(kg, state->rng_hash, state, j, num_samples, PRNG_LIGHT_U, &light_u, &light_v);
+ float terminate = path_branched_rng_light_termination(kg, state->rng_hash, state, j, num_samples);
/* only sample triangle lights */
if(kernel_data.integrator.num_all_lights)
- light_t = 0.5f*light_t;
+ light_u = 0.5f*light_u;
LightSample ls;
- if(light_sample(kg, light_t, light_u, light_v, sd->time, sd->P, state->bounce, &ls)) {
+ if(light_sample(kg, light_u, light_v, sd->time, sd->P, state->bounce, &ls)) {
/* Same as above, probability needs to be corrected since the sampling was forced to select a mesh light. */
if(kernel_data.integrator.num_all_lights)
ls.pdf *= 2.0f;
@@ -105,7 +103,7 @@ ccl_device_noinline void kernel_branched_path_surface_connect_light(
/* trace shadow ray */
float3 shadow;
- if(!shadow_blocked(kg, emission_sd, state, &light_ray, &shadow)) {
+ if(!shadow_blocked(kg, sd, emission_sd, state, &light_ray, &shadow)) {
/* accumulate */
path_radiance_accum_light(L, state, throughput*num_samples_inv, &L_light, shadow, num_samples_inv, is_lamp);
}
@@ -119,19 +117,18 @@ ccl_device_noinline void kernel_branched_path_surface_connect_light(
}
else {
/* sample one light at random */
- float light_t = path_state_rng_1D(kg, rng, state, PRNG_LIGHT);
float light_u, light_v;
- path_state_rng_2D(kg, rng, state, PRNG_LIGHT_U, &light_u, &light_v);
- float terminate = path_state_rng_light_termination(kg, rng, state);
+ path_state_rng_2D(kg, state, PRNG_LIGHT_U, &light_u, &light_v);
+ float terminate = path_state_rng_light_termination(kg, state);
LightSample ls;
- if(light_sample(kg, light_t, light_u, light_v, sd->time, sd->P, state->bounce, &ls)) {
+ if(light_sample(kg, light_u, light_v, sd->time, sd->P, state->bounce, &ls)) {
/* sample random light */
if(direct_emission(kg, sd, emission_sd, &ls, state, &light_ray, &L_light, &is_lamp, terminate)) {
/* trace shadow ray */
float3 shadow;
- if(!shadow_blocked(kg, emission_sd, state, &light_ray, &shadow)) {
+ if(!shadow_blocked(kg, sd, emission_sd, state, &light_ray, &shadow)) {
/* accumulate */
path_radiance_accum_light(L, state, throughput*num_samples_adjust, &L_light, shadow, num_samples_adjust, is_lamp);
}
@@ -147,14 +144,13 @@ ccl_device_noinline void kernel_branched_path_surface_connect_light(
/* branched path tracing: bounce off or through surface to with new direction stored in ray */
ccl_device bool kernel_branched_path_surface_bounce(
KernelGlobals *kg,
- RNG *rng,
ShaderData *sd,
const ShaderClosure *sc,
int sample,
int num_samples,
ccl_addr_space float3 *throughput,
ccl_addr_space PathState *state,
- PathRadiance *L,
+ PathRadianceState *L_state,
ccl_addr_space Ray *ray,
float sum_sample_weight)
{
@@ -164,7 +160,7 @@ ccl_device bool kernel_branched_path_surface_bounce(
float3 bsdf_omega_in;
differential3 bsdf_domega_in;
float bsdf_u, bsdf_v;
- path_branched_rng_2D(kg, rng, state, sample, num_samples, PRNG_BSDF_U, &bsdf_u, &bsdf_v);
+ path_branched_rng_2D(kg, state->rng_hash, state, sample, num_samples, PRNG_BSDF_U, &bsdf_u, &bsdf_v);
int label;
label = shader_bsdf_sample_closure(kg, sd, sc, bsdf_u, bsdf_v, &bsdf_eval,
@@ -174,7 +170,7 @@ ccl_device bool kernel_branched_path_surface_bounce(
return false;
/* modify throughput */
- path_radiance_bsdf_bounce(L, throughput, &bsdf_eval, bsdf_pdf, state->bounce, label);
+ path_radiance_bsdf_bounce(kg, L_state, throughput, &bsdf_eval, bsdf_pdf, state->bounce, label);
#ifdef __DENOISING_FEATURES__
state->denoising_feature_weight *= sc->sample_weight / (sum_sample_weight * num_samples);
@@ -217,7 +213,7 @@ ccl_device bool kernel_branched_path_surface_bounce(
#endif
/* path tracing: connect path directly to position on a light and add it to L */
-ccl_device_inline void kernel_path_surface_connect_light(KernelGlobals *kg, RNG *rng,
+ccl_device_inline void kernel_path_surface_connect_light(KernelGlobals *kg,
ShaderData *sd, ShaderData *emission_sd, float3 throughput, ccl_addr_space PathState *state,
PathRadiance *L)
{
@@ -228,7 +224,6 @@ ccl_device_inline void kernel_path_surface_connect_light(KernelGlobals *kg, RNG
#ifdef __SHADOW_TRICKS__
if(state->flag & PATH_RAY_SHADOW_CATCHER) {
kernel_branched_path_surface_connect_light(kg,
- rng,
sd,
emission_sd,
state,
@@ -241,9 +236,8 @@ ccl_device_inline void kernel_path_surface_connect_light(KernelGlobals *kg, RNG
#endif
/* sample illumination from lights to find path contribution */
- float light_t = path_state_rng_1D(kg, rng, state, PRNG_LIGHT);
float light_u, light_v;
- path_state_rng_2D(kg, rng, state, PRNG_LIGHT_U, &light_u, &light_v);
+ path_state_rng_2D(kg, state, PRNG_LIGHT_U, &light_u, &light_v);
Ray light_ray;
BsdfEval L_light;
@@ -254,13 +248,13 @@ ccl_device_inline void kernel_path_surface_connect_light(KernelGlobals *kg, RNG
#endif
LightSample ls;
- if(light_sample(kg, light_t, light_u, light_v, sd->time, sd->P, state->bounce, &ls)) {
- float terminate = path_state_rng_light_termination(kg, rng, state);
+ if(light_sample(kg, light_u, light_v, sd->time, sd->P, state->bounce, &ls)) {
+ float terminate = path_state_rng_light_termination(kg, state);
if(direct_emission(kg, sd, emission_sd, &ls, state, &light_ray, &L_light, &is_lamp, terminate)) {
/* trace shadow ray */
float3 shadow;
- if(!shadow_blocked(kg, emission_sd, state, &light_ray, &shadow)) {
+ if(!shadow_blocked(kg, sd, emission_sd, state, &light_ray, &shadow)) {
/* accumulate */
path_radiance_accum_light(L, state, throughput, &L_light, shadow, 1.0f, is_lamp);
}
@@ -274,11 +268,10 @@ ccl_device_inline void kernel_path_surface_connect_light(KernelGlobals *kg, RNG
/* path tracing: bounce off or through surface to with new direction stored in ray */
ccl_device bool kernel_path_surface_bounce(KernelGlobals *kg,
- RNG *rng,
ShaderData *sd,
ccl_addr_space float3 *throughput,
ccl_addr_space PathState *state,
- PathRadiance *L,
+ PathRadianceState *L_state,
ccl_addr_space Ray *ray)
{
/* no BSDF? we can stop here */
@@ -289,7 +282,7 @@ ccl_device bool kernel_path_surface_bounce(KernelGlobals *kg,
float3 bsdf_omega_in;
differential3 bsdf_domega_in;
float bsdf_u, bsdf_v;
- path_state_rng_2D(kg, rng, state, PRNG_BSDF_U, &bsdf_u, &bsdf_v);
+ path_state_rng_2D(kg, state, PRNG_BSDF_U, &bsdf_u, &bsdf_v);
int label;
label = shader_bsdf_sample(kg, sd, bsdf_u, bsdf_v, &bsdf_eval,
@@ -299,7 +292,7 @@ ccl_device bool kernel_path_surface_bounce(KernelGlobals *kg,
return false;
/* modify throughput */
- path_radiance_bsdf_bounce(L, throughput, &bsdf_eval, bsdf_pdf, state->bounce, label);
+ path_radiance_bsdf_bounce(kg, L_state, throughput, &bsdf_eval, bsdf_pdf, state->bounce, label);
/* set labels */
if(!(label & LABEL_TRANSPARENT)) {
diff --git a/intern/cycles/kernel/kernel_path_volume.h b/intern/cycles/kernel/kernel_path_volume.h
index dcedf51e479..b6a856baf24 100644
--- a/intern/cycles/kernel/kernel_path_volume.h
+++ b/intern/cycles/kernel/kernel_path_volume.h
@@ -20,7 +20,6 @@ CCL_NAMESPACE_BEGIN
ccl_device_inline void kernel_path_volume_connect_light(
KernelGlobals *kg,
- RNG *rng,
ShaderData *sd,
ShaderData *emission_sd,
float3 throughput,
@@ -32,9 +31,8 @@ ccl_device_inline void kernel_path_volume_connect_light(
return;
/* sample illumination from lights to find path contribution */
- float light_t = path_state_rng_1D(kg, rng, state, PRNG_LIGHT);
float light_u, light_v;
- path_state_rng_2D(kg, rng, state, PRNG_LIGHT_U, &light_u, &light_v);
+ path_state_rng_2D(kg, state, PRNG_LIGHT_U, &light_u, &light_v);
Ray light_ray;
BsdfEval L_light;
@@ -42,18 +40,16 @@ ccl_device_inline void kernel_path_volume_connect_light(
bool is_lamp;
/* connect to light from given point where shader has been evaluated */
-# ifdef __OBJECT_MOTION__
light_ray.time = sd->time;
-# endif
- if(light_sample(kg, light_t, light_u, light_v, sd->time, sd->P, state->bounce, &ls))
+ if(light_sample(kg, light_u, light_v, sd->time, sd->P, state->bounce, &ls))
{
- float terminate = path_state_rng_light_termination(kg, rng, state);
+ float terminate = path_state_rng_light_termination(kg, state);
if(direct_emission(kg, sd, emission_sd, &ls, state, &light_ray, &L_light, &is_lamp, terminate)) {
/* trace shadow ray */
float3 shadow;
- if(!shadow_blocked(kg, emission_sd, state, &light_ray, &shadow)) {
+ if(!shadow_blocked(kg, sd, emission_sd, state, &light_ray, &shadow)) {
/* accumulate */
path_radiance_accum_light(L, state, throughput, &L_light, shadow, 1.0f, is_lamp);
}
@@ -69,11 +65,10 @@ ccl_device
#endif
bool kernel_path_volume_bounce(
KernelGlobals *kg,
- RNG *rng,
ShaderData *sd,
ccl_addr_space float3 *throughput,
ccl_addr_space PathState *state,
- PathRadiance *L,
+ PathRadianceState *L_state,
ccl_addr_space Ray *ray)
{
/* sample phase function */
@@ -82,7 +77,7 @@ bool kernel_path_volume_bounce(
float3 phase_omega_in;
differential3 phase_domega_in;
float phase_u, phase_v;
- path_state_rng_2D(kg, rng, state, PRNG_PHASE_U, &phase_u, &phase_v);
+ path_state_rng_2D(kg, state, PRNG_BSDF_U, &phase_u, &phase_v);
int label;
label = shader_volume_phase_sample(kg, sd, phase_u, phase_v, &phase_eval,
@@ -92,7 +87,7 @@ bool kernel_path_volume_bounce(
return false;
/* modify throughput */
- path_radiance_bsdf_bounce(L, throughput, &phase_eval, phase_pdf, state->bounce, label);
+ path_radiance_bsdf_bounce(kg, L_state, throughput, &phase_eval, phase_pdf, state->bounce, label);
/* set labels */
state->ray_pdf = phase_pdf;
@@ -120,7 +115,6 @@ bool kernel_path_volume_bounce(
#ifndef __SPLIT_KERNEL__
ccl_device void kernel_branched_path_volume_connect_light(
KernelGlobals *kg,
- RNG *rng,
ShaderData *sd,
ShaderData *emission_sd,
float3 throughput,
@@ -138,9 +132,7 @@ ccl_device void kernel_branched_path_volume_connect_light(
BsdfEval L_light;
bool is_lamp;
-# ifdef __OBJECT_MOTION__
light_ray.time = sd->time;
-# endif
if(sample_all_lights) {
/* lamp sampling */
@@ -150,12 +142,12 @@ ccl_device void kernel_branched_path_volume_connect_light(
int num_samples = light_select_num_samples(kg, i);
float num_samples_inv = 1.0f/(num_samples*kernel_data.integrator.num_all_lights);
- RNG lamp_rng = cmj_hash(*rng, i);
+ uint lamp_rng_hash = cmj_hash(state->rng_hash, i);
for(int j = 0; j < num_samples; j++) {
/* sample random position on given light */
float light_u, light_v;
- path_branched_rng_2D(kg, &lamp_rng, state, j, num_samples, PRNG_LIGHT_U, &light_u, &light_v);
+ path_branched_rng_2D(kg, lamp_rng_hash, state, j, num_samples, PRNG_LIGHT_U, &light_u, &light_v);
LightSample ls;
lamp_light_sample(kg, i, light_u, light_v, ray->P, &ls);
@@ -163,26 +155,24 @@ ccl_device void kernel_branched_path_volume_connect_light(
float3 tp = throughput;
/* sample position on volume segment */
- float rphase = path_branched_rng_1D_for_decision(kg, rng, state, j, num_samples, PRNG_PHASE);
- float rscatter = path_branched_rng_1D_for_decision(kg, rng, state, j, num_samples, PRNG_SCATTER_DISTANCE);
+ float rphase = path_branched_rng_1D(kg, state->rng_hash, state, j, num_samples, PRNG_PHASE_CHANNEL);
+ float rscatter = path_branched_rng_1D(kg, state->rng_hash, state, j, num_samples, PRNG_SCATTER_DISTANCE);
VolumeIntegrateResult result = kernel_volume_decoupled_scatter(kg,
state, ray, sd, &tp, rphase, rscatter, segment, (ls.t != FLT_MAX)? &ls.P: NULL, false);
- (void)result;
- kernel_assert(result == VOLUME_PATH_SCATTERED);
-
/* todo: split up light_sample so we don't have to call it again with new position */
- if(lamp_light_sample(kg, i, light_u, light_v, sd->P, &ls)) {
+ if(result == VOLUME_PATH_SCATTERED &&
+ lamp_light_sample(kg, i, light_u, light_v, sd->P, &ls)) {
if(kernel_data.integrator.pdf_triangles != 0.0f)
ls.pdf *= 2.0f;
- float terminate = path_branched_rng_light_termination(kg, rng, state, j, num_samples);
+ float terminate = path_branched_rng_light_termination(kg, state->rng_hash, state, j, num_samples);
if(direct_emission(kg, sd, emission_sd, &ls, state, &light_ray, &L_light, &is_lamp, terminate)) {
/* trace shadow ray */
float3 shadow;
- if(!shadow_blocked(kg, emission_sd, state, &light_ray, &shadow)) {
+ if(!shadow_blocked(kg, sd, emission_sd, state, &light_ray, &shadow)) {
/* accumulate */
path_radiance_accum_light(L, state, tp*num_samples_inv, &L_light, shadow, num_samples_inv, is_lamp);
}
@@ -198,40 +188,37 @@ ccl_device void kernel_branched_path_volume_connect_light(
for(int j = 0; j < num_samples; j++) {
/* sample random position on random triangle */
- float light_t = path_branched_rng_1D_for_decision(kg, rng, state, j, num_samples, PRNG_LIGHT);
float light_u, light_v;
- path_branched_rng_2D(kg, rng, state, j, num_samples, PRNG_LIGHT_U, &light_u, &light_v);
+ path_branched_rng_2D(kg, state->rng_hash, state, j, num_samples, PRNG_LIGHT_U, &light_u, &light_v);
/* only sample triangle lights */
if(kernel_data.integrator.num_all_lights)
- light_t = 0.5f*light_t;
+ light_u = 0.5f*light_u;
LightSample ls;
- light_sample(kg, light_t, light_u, light_v, sd->time, ray->P, state->bounce, &ls);
+ light_sample(kg, light_u, light_v, sd->time, ray->P, state->bounce, &ls);
float3 tp = throughput;
/* sample position on volume segment */
- float rphase = path_branched_rng_1D_for_decision(kg, rng, state, j, num_samples, PRNG_PHASE);
- float rscatter = path_branched_rng_1D_for_decision(kg, rng, state, j, num_samples, PRNG_SCATTER_DISTANCE);
+ float rphase = path_branched_rng_1D(kg, state->rng_hash, state, j, num_samples, PRNG_PHASE_CHANNEL);
+ float rscatter = path_branched_rng_1D(kg, state->rng_hash, state, j, num_samples, PRNG_SCATTER_DISTANCE);
VolumeIntegrateResult result = kernel_volume_decoupled_scatter(kg,
state, ray, sd, &tp, rphase, rscatter, segment, (ls.t != FLT_MAX)? &ls.P: NULL, false);
- (void)result;
- kernel_assert(result == VOLUME_PATH_SCATTERED);
-
/* todo: split up light_sample so we don't have to call it again with new position */
- if(light_sample(kg, light_t, light_u, light_v, sd->time, sd->P, state->bounce, &ls)) {
+ if(result == VOLUME_PATH_SCATTERED &&
+ light_sample(kg, light_u, light_v, sd->time, sd->P, state->bounce, &ls)) {
if(kernel_data.integrator.num_all_lights)
ls.pdf *= 2.0f;
- float terminate = path_branched_rng_light_termination(kg, rng, state, j, num_samples);
+ float terminate = path_branched_rng_light_termination(kg, state->rng_hash, state, j, num_samples);
if(direct_emission(kg, sd, emission_sd, &ls, state, &light_ray, &L_light, &is_lamp, terminate)) {
/* trace shadow ray */
float3 shadow;
- if(!shadow_blocked(kg, emission_sd, state, &light_ray, &shadow)) {
+ if(!shadow_blocked(kg, sd, emission_sd, state, &light_ray, &shadow)) {
/* accumulate */
path_radiance_accum_light(L, state, tp*num_samples_inv, &L_light, shadow, num_samples_inv, is_lamp);
}
@@ -242,34 +229,31 @@ ccl_device void kernel_branched_path_volume_connect_light(
}
else {
/* sample random position on random light */
- float light_t = path_state_rng_1D(kg, rng, state, PRNG_LIGHT);
float light_u, light_v;
- path_state_rng_2D(kg, rng, state, PRNG_LIGHT_U, &light_u, &light_v);
+ path_state_rng_2D(kg, state, PRNG_LIGHT_U, &light_u, &light_v);
LightSample ls;
- light_sample(kg, light_t, light_u, light_v, sd->time, ray->P, state->bounce, &ls);
+ light_sample(kg, light_u, light_v, sd->time, ray->P, state->bounce, &ls);
float3 tp = throughput;
/* sample position on volume segment */
- float rphase = path_state_rng_1D_for_decision(kg, rng, state, PRNG_PHASE);
- float rscatter = path_state_rng_1D_for_decision(kg, rng, state, PRNG_SCATTER_DISTANCE);
+ float rphase = path_state_rng_1D(kg, state, PRNG_PHASE_CHANNEL);
+ float rscatter = path_state_rng_1D(kg, state, PRNG_SCATTER_DISTANCE);
VolumeIntegrateResult result = kernel_volume_decoupled_scatter(kg,
state, ray, sd, &tp, rphase, rscatter, segment, (ls.t != FLT_MAX)? &ls.P: NULL, false);
- (void)result;
- kernel_assert(result == VOLUME_PATH_SCATTERED);
-
/* todo: split up light_sample so we don't have to call it again with new position */
- if(light_sample(kg, light_t, light_u, light_v, sd->time, sd->P, state->bounce, &ls)) {
+ if(result == VOLUME_PATH_SCATTERED &&
+ light_sample(kg, light_u, light_v, sd->time, sd->P, state->bounce, &ls)) {
/* sample random light */
- float terminate = path_state_rng_light_termination(kg, rng, state);
+ float terminate = path_state_rng_light_termination(kg, state);
if(direct_emission(kg, sd, emission_sd, &ls, state, &light_ray, &L_light, &is_lamp, terminate)) {
/* trace shadow ray */
float3 shadow;
- if(!shadow_blocked(kg, emission_sd, state, &light_ray, &shadow)) {
+ if(!shadow_blocked(kg, sd, emission_sd, state, &light_ray, &shadow)) {
/* accumulate */
path_radiance_accum_light(L, state, tp, &L_light, shadow, 1.0f, is_lamp);
}
diff --git a/intern/cycles/kernel/kernel_random.h b/intern/cycles/kernel/kernel_random.h
index e8a912ccc0b..e7a6134b8eb 100644
--- a/intern/cycles/kernel/kernel_random.h
+++ b/intern/cycles/kernel/kernel_random.h
@@ -15,58 +15,22 @@
*/
#include "kernel/kernel_jitter.h"
+#include "util/util_hash.h"
CCL_NAMESPACE_BEGIN
-#ifdef __SOBOL__
-
-/* Skip initial numbers that are not as well distributed, especially the
- * first sequence is just 0 everywhere, which can be problematic for e.g.
- * path termination.
- */
-#define SOBOL_SKIP 64
+/* Pseudo random numbers, uncomment this for debugging correlations. Only run
+ * this single threaded on a CPU for repeatable resutls. */
+//#define __DEBUG_CORRELATION__
-/* High Dimensional Sobol. */
-/* Van der Corput radical inverse. */
-ccl_device uint van_der_corput(uint bits)
-{
- bits = (bits << 16) | (bits >> 16);
- bits = ((bits & 0x00ff00ff) << 8) | ((bits & 0xff00ff00) >> 8);
- bits = ((bits & 0x0f0f0f0f) << 4) | ((bits & 0xf0f0f0f0) >> 4);
- bits = ((bits & 0x33333333) << 2) | ((bits & 0xcccccccc) >> 2);
- bits = ((bits & 0x55555555) << 1) | ((bits & 0xaaaaaaaa) >> 1);
- return bits;
-}
-
-/* Sobol radical inverse. */
-ccl_device uint sobol(uint i)
-{
- uint r = 0;
- for(uint v = 1U << 31; i; i >>= 1, v ^= v >> 1) {
- if(i & 1) {
- r ^= v;
- }
- }
- return r;
-}
+/* High Dimensional Sobol.
+ *
+ * Multidimensional sobol with generator matrices. Dimension 0 and 1 are equal
+ * to classic Van der Corput and Sobol sequences. */
-/* Inverse of sobol radical inverse. */
-ccl_device uint sobol_inverse(uint i)
-{
- const uint msb = 1U << 31;
- uint r = 0;
- for(uint v = 1; i; i <<= 1, v ^= v << 1) {
- if(i & msb) {
- r ^= v;
- }
- }
- return r;
-}
+#ifdef __SOBOL__
-/* Multidimensional sobol with generator matrices
- * dimension 0 and 1 are equal to van_der_corput() and sobol() respectively.
- */
ccl_device uint sobol_dimension(KernelGlobals *kg, int index, int dimension)
{
uint result = 0;
@@ -79,51 +43,32 @@ ccl_device uint sobol_dimension(KernelGlobals *kg, int index, int dimension)
return result;
}
-/* Lookup index and x/y coordinate, assumes m is a power of two. */
-ccl_device uint sobol_lookup(const uint m,
- const uint frame,
- const uint ex,
- const uint ey,
- uint *x, uint *y)
-{
- /* Shift is constant per frame. */
- const uint shift = frame << (m << 1);
- const uint sobol_shift = sobol(shift);
- /* Van der Corput is its own inverse. */
- const uint lower = van_der_corput(ex << (32 - m));
- /* Need to compensate for ey difference and shift. */
- const uint sobol_lower = sobol(lower);
- const uint mask = ~-(1 << m) << (32 - m); /* Only m upper bits. */
- const uint delta = ((ey << (32 - m)) ^ sobol_lower ^ sobol_shift) & mask;
- /* Only use m upper bits for the index (m is a power of two). */
- const uint sobol_result = delta | (delta >> m);
- const uint upper = sobol_inverse(sobol_result);
- const uint index = shift | upper | lower;
- *x = van_der_corput(index);
- *y = sobol_shift ^ sobol_result ^ sobol_lower;
- return index;
-}
+#endif /* __SOBOL__ */
+
ccl_device_forceinline float path_rng_1D(KernelGlobals *kg,
- RNG *rng,
+ uint rng_hash,
int sample, int num_samples,
int dimension)
{
+#ifdef __DEBUG_CORRELATION__
+ return (float)drand48();
+#endif
+
#ifdef __CMJ__
- if(kernel_data.integrator.sampling_pattern == SAMPLING_PATTERN_CMJ) {
+# ifdef __SOBOL__
+ if(kernel_data.integrator.sampling_pattern == SAMPLING_PATTERN_CMJ)
+# endif
+ {
/* Correlated multi-jitter. */
- int p = *rng + dimension;
+ int p = rng_hash + dimension;
return cmj_sample_1D(sample, num_samples, p);
}
#endif
-#ifdef __SOBOL_FULL_SCREEN__
- uint result = sobol_dimension(kg, *rng, dimension);
- float r = (float)result * (1.0f/(float)0xFFFFFFFF);
- return r;
-#else
- /* Compute sobol sequence value using direction vectors. */
- uint result = sobol_dimension(kg, sample + SOBOL_SKIP, dimension);
+#ifdef __SOBOL__
+ /* Sobol sequence value using direction vectors. */
+ uint result = sobol_dimension(kg, sample, dimension);
float r = (float)result * (1.0f/(float)0xFFFFFFFF);
/* Cranly-Patterson rotation using rng seed */
@@ -132,7 +77,7 @@ ccl_device_forceinline float path_rng_1D(KernelGlobals *kg,
/* Hash rng with dimension to solve correlation issues.
* See T38710, T50116.
*/
- RNG tmp_rng = cmj_hash_simple(dimension, *rng);
+ uint tmp_rng = cmj_hash_simple(dimension, rng_hash);
shift = tmp_rng * (1.0f/(float)0xFFFFFFFF);
return r + shift - floorf(r + shift);
@@ -140,128 +85,59 @@ ccl_device_forceinline float path_rng_1D(KernelGlobals *kg,
}
ccl_device_forceinline void path_rng_2D(KernelGlobals *kg,
- RNG *rng,
+ uint rng_hash,
int sample, int num_samples,
int dimension,
float *fx, float *fy)
{
+#ifdef __DEBUG_CORRELATION__
+ *fx = (float)drand48();
+ *fy = (float)drand48();
+ return;
+#endif
+
#ifdef __CMJ__
- if(kernel_data.integrator.sampling_pattern == SAMPLING_PATTERN_CMJ) {
+# ifdef __SOBOL__
+ if(kernel_data.integrator.sampling_pattern == SAMPLING_PATTERN_CMJ)
+# endif
+ {
/* Correlated multi-jitter. */
- int p = *rng + dimension;
+ int p = rng_hash + dimension;
cmj_sample_2D(sample, num_samples, p, fx, fy);
+ return;
}
- else
#endif
- {
- /* Sobol. */
- *fx = path_rng_1D(kg, rng, sample, num_samples, dimension);
- *fy = path_rng_1D(kg, rng, sample, num_samples, dimension + 1);
- }
+
+#ifdef __SOBOL__
+ /* Sobol. */
+ *fx = path_rng_1D(kg, rng_hash, sample, num_samples, dimension);
+ *fy = path_rng_1D(kg, rng_hash, sample, num_samples, dimension + 1);
+#endif
}
ccl_device_inline void path_rng_init(KernelGlobals *kg,
- ccl_global uint *rng_state,
int sample, int num_samples,
- RNG *rng,
+ uint *rng_hash,
int x, int y,
float *fx, float *fy)
{
-#ifdef __SOBOL_FULL_SCREEN__
- uint px, py;
- uint bits = 16; /* limits us to 65536x65536 and 65536 samples */
- uint size = 1 << bits;
- uint frame = sample;
-
- *rng = sobol_lookup(bits, frame, x, y, &px, &py);
-
- *rng ^= kernel_data.integrator.seed;
-
- if(sample == 0) {
- *fx = 0.5f;
- *fy = 0.5f;
- }
- else {
- *fx = size * (float)px * (1.0f/(float)0xFFFFFFFF) - x;
- *fy = size * (float)py * (1.0f/(float)0xFFFFFFFF) - y;
- }
-#else
- *rng = *rng_state;
-
- *rng ^= kernel_data.integrator.seed;
-
- if(sample == 0) {
- *fx = 0.5f;
- *fy = 0.5f;
- }
- else {
- path_rng_2D(kg, rng, sample, num_samples, PRNG_FILTER_U, fx, fy);
- }
-#endif
-}
-
-ccl_device void path_rng_end(KernelGlobals *kg,
- ccl_global uint *rng_state,
- RNG rng)
-{
- /* nothing to do */
-}
-
-#else /* __SOBOL__ */
-
-/* Linear Congruential Generator */
-
-ccl_device_forceinline float path_rng_1D(KernelGlobals *kg,
- RNG *rng,
- int sample, int num_samples,
- int dimension)
-{
- /* implicit mod 2^32 */
- *rng = (1103515245*(*rng) + 12345);
- return (float)*rng * (1.0f/(float)0xFFFFFFFF);
-}
-
-ccl_device_inline void path_rng_2D(KernelGlobals *kg,
- RNG *rng,
- int sample, int num_samples,
- int dimension,
- float *fx, float *fy)
-{
- *fx = path_rng_1D(kg, rng, sample, num_samples, dimension);
- *fy = path_rng_1D(kg, rng, sample, num_samples, dimension + 1);
-}
-
-ccl_device void path_rng_init(KernelGlobals *kg,
- ccl_global uint *rng_state,
- int sample, int num_samples,
- RNG *rng,
- int x, int y,
- float *fx, float *fy)
-{
/* load state */
- *rng = *rng_state;
+ *rng_hash = hash_int_2d(x, y);
+ *rng_hash ^= kernel_data.integrator.seed;
- *rng ^= kernel_data.integrator.seed;
+#ifdef __DEBUG_CORRELATION__
+ srand48(*rng_hash + sample);
+#endif
if(sample == 0) {
*fx = 0.5f;
*fy = 0.5f;
}
else {
- path_rng_2D(kg, rng, sample, num_samples, PRNG_FILTER_U, fx, fy);
+ path_rng_2D(kg, *rng_hash, sample, num_samples, PRNG_FILTER_U, fx, fy);
}
}
-ccl_device void path_rng_end(KernelGlobals *kg,
- ccl_global uint *rng_state,
- RNG rng)
-{
- /* store state for next sample */
- *rng_state = rng;
-}
-
-#endif /* __SOBOL__ */
-
/* Linear Congruential Generator */
ccl_device uint lcg_step_uint(uint *rng)
@@ -295,44 +171,22 @@ ccl_device uint lcg_init(uint seed)
*/
ccl_device_inline float path_state_rng_1D(KernelGlobals *kg,
- RNG *rng,
const ccl_addr_space PathState *state,
int dimension)
{
return path_rng_1D(kg,
- rng,
+ state->rng_hash,
state->sample, state->num_samples,
state->rng_offset + dimension);
}
-ccl_device_inline float path_state_rng_1D_for_decision(
- KernelGlobals *kg,
- RNG *rng,
- const ccl_addr_space PathState *state,
- int dimension)
-{
- /* The rng_offset is not increased for transparent bounces. if we do then
- * fully transparent objects can become subtly visible by the different
- * sampling patterns used where the transparent object is.
- *
- * however for some random numbers that will determine if we next bounce
- * is transparent we do need to increase the offset to avoid always making
- * the same decision. */
- const int rng_offset = state->rng_offset + state->transparent_bounce * PRNG_BOUNCE_NUM;
- return path_rng_1D(kg,
- rng,
- state->sample, state->num_samples,
- rng_offset + dimension);
-}
-
ccl_device_inline void path_state_rng_2D(KernelGlobals *kg,
- RNG *rng,
const ccl_addr_space PathState *state,
int dimension,
float *fx, float *fy)
{
path_rng_2D(kg,
- rng,
+ state->rng_hash,
state->sample, state->num_samples,
state->rng_offset + dimension,
fx, fy);
@@ -340,38 +194,22 @@ ccl_device_inline void path_state_rng_2D(KernelGlobals *kg,
ccl_device_inline float path_branched_rng_1D(
KernelGlobals *kg,
- RNG *rng,
+ uint rng_hash,
const ccl_addr_space PathState *state,
int branch,
int num_branches,
int dimension)
{
return path_rng_1D(kg,
- rng,
+ rng_hash,
state->sample * num_branches + branch,
state->num_samples * num_branches,
state->rng_offset + dimension);
}
-ccl_device_inline float path_branched_rng_1D_for_decision(
- KernelGlobals *kg,
- RNG *rng,
- const ccl_addr_space PathState *state,
- int branch,
- int num_branches,
- int dimension)
-{
- const int rng_offset = state->rng_offset + state->transparent_bounce * PRNG_BOUNCE_NUM;
- return path_rng_1D(kg,
- rng,
- state->sample * num_branches + branch,
- state->num_samples * num_branches,
- rng_offset + dimension);
-}
-
ccl_device_inline void path_branched_rng_2D(
KernelGlobals *kg,
- RNG *rng,
+ uint rng_hash,
const ccl_addr_space PathState *state,
int branch,
int num_branches,
@@ -379,7 +217,7 @@ ccl_device_inline void path_branched_rng_2D(
float *fx, float *fy)
{
path_rng_2D(kg,
- rng,
+ rng_hash,
state->sample * num_branches + branch,
state->num_samples * num_branches,
state->rng_offset + dimension,
@@ -391,52 +229,45 @@ ccl_device_inline void path_branched_rng_2D(
*/
ccl_device_inline float path_state_rng_light_termination(
KernelGlobals *kg,
- RNG *rng,
const ccl_addr_space PathState *state)
{
if(kernel_data.integrator.light_inv_rr_threshold > 0.0f) {
- return path_state_rng_1D_for_decision(kg, rng, state, PRNG_LIGHT_TERMINATE);
+ return path_state_rng_1D(kg, state, PRNG_LIGHT_TERMINATE);
}
return 0.0f;
}
ccl_device_inline float path_branched_rng_light_termination(
KernelGlobals *kg,
- RNG *rng,
+ uint rng_hash,
const ccl_addr_space PathState *state,
int branch,
int num_branches)
{
if(kernel_data.integrator.light_inv_rr_threshold > 0.0f) {
- return path_branched_rng_1D_for_decision(kg,
- rng,
- state,
- branch,
- num_branches,
- PRNG_LIGHT_TERMINATE);
+ return path_branched_rng_1D(kg,
+ rng_hash,
+ state,
+ branch,
+ num_branches,
+ PRNG_LIGHT_TERMINATE);
}
return 0.0f;
}
-ccl_device_inline void path_state_branch(ccl_addr_space PathState *state,
- int branch,
- int num_branches)
+ccl_device_inline uint lcg_state_init(PathState *state,
+ uint scramble)
{
- /* path is splitting into a branch, adjust so that each branch
- * still gets a unique sample from the same sequence */
- state->rng_offset += PRNG_BOUNCE_NUM;
- state->sample = state->sample*num_branches + branch;
- state->num_samples = state->num_samples*num_branches;
+ return lcg_init(state->rng_hash + state->rng_offset + state->sample*scramble);
}
-ccl_device_inline uint lcg_state_init(RNG *rng,
- int rng_offset,
- int sample,
- uint scramble)
+ccl_device_inline uint lcg_state_init_addrspace(ccl_addr_space PathState *state,
+ uint scramble)
{
- return lcg_init(*rng + rng_offset + sample*scramble);
+ return lcg_init(state->rng_hash + state->rng_offset + state->sample*scramble);
}
+
ccl_device float lcg_step_float_addrspace(ccl_addr_space uint *rng)
{
/* Implicit mod 2^32 */
diff --git a/intern/cycles/kernel/kernel_shader.h b/intern/cycles/kernel/kernel_shader.h
index c66f52255f0..695d4fc380a 100644
--- a/intern/cycles/kernel/kernel_shader.h
+++ b/intern/cycles/kernel/kernel_shader.h
@@ -66,8 +66,8 @@ ccl_device_noinline void shader_setup_from_ray(KernelGlobals *kg,
/* matrices and time */
#ifdef __OBJECT_MOTION__
shader_setup_object_transforms(kg, sd, ray->time);
- sd->time = ray->time;
#endif
+ sd->time = ray->time;
sd->prim = kernel_tex_fetch(__prim_index, isect->prim);
sd->ray_length = isect->t;
@@ -83,7 +83,7 @@ ccl_device_noinline void shader_setup_from_ray(KernelGlobals *kg,
float4 curvedata = kernel_tex_fetch(__curves, sd->prim);
sd->shader = __float_as_int(curvedata.z);
- sd->P = bvh_curve_refine(kg, sd, isect, ray);
+ sd->P = curve_refine(kg, sd, isect, ray);
}
else
#endif
@@ -271,17 +271,17 @@ ccl_device_inline void shader_setup_from_sample(KernelGlobals *kg,
sd->u = u;
sd->v = v;
#endif
+ sd->time = time;
sd->ray_length = t;
sd->flag = kernel_tex_fetch(__shader_flag, (sd->shader & SHADER_MASK)*SHADER_SIZE);
sd->object_flag = 0;
if(sd->object != OBJECT_NONE) {
sd->object_flag |= kernel_tex_fetch(__object_flag,
- sd->object);
+ sd->object);
#ifdef __OBJECT_MOTION__
shader_setup_object_transforms(kg, sd, time);
- sd->time = time;
}
else if(lamp != LAMP_NONE) {
sd->ob_tfm = lamp_fetch_transform(kg, lamp, false);
@@ -385,9 +385,7 @@ ccl_device_inline void shader_setup_from_background(KernelGlobals *kg, ShaderDat
sd->shader = kernel_data.background.surface_shader;
sd->flag = kernel_tex_fetch(__shader_flag, (sd->shader & SHADER_MASK)*SHADER_SIZE);
sd->object_flag = 0;
-#ifdef __OBJECT_MOTION__
sd->time = ray->time;
-#endif
sd->ray_length = 0.0f;
#ifdef __INSTANCING__
@@ -427,9 +425,7 @@ ccl_device_inline void shader_setup_from_volume(KernelGlobals *kg, ShaderData *s
sd->shader = SHADER_NONE;
sd->flag = 0;
sd->object_flag = 0;
-#ifdef __OBJECT_MOTION__
sd->time = ray->time;
-#endif
sd->ray_length = 0.0f; /* todo: can we set this to some useful value? */
#ifdef __INSTANCING__
@@ -498,20 +494,45 @@ ccl_device_inline void shader_merge_closures(ShaderData *sd)
}
#endif
+/* Defensive sampling. */
+
+ccl_device_inline void shader_prepare_closures(ShaderData *sd,
+ ccl_addr_space PathState *state)
+{
+ /* We can likely also do defensive sampling at deeper bounces, particularly
+ * for cases like a perfect mirror but possibly also others. This will need
+ * a good heuristic. */
+ if(state->bounce + state->transparent_bounce == 0 && sd->num_closure > 1) {
+ float sum = 0.0f;
+
+ for(int i = 0; i < sd->num_closure; i++) {
+ ShaderClosure *sc = &sd->closure[i];
+ if(CLOSURE_IS_BSDF_OR_BSSRDF(sc->type)) {
+ sum += sc->sample_weight;
+ }
+ }
+
+ for(int i = 0; i < sd->num_closure; i++) {
+ ShaderClosure *sc = &sd->closure[i];
+ if(CLOSURE_IS_BSDF_OR_BSSRDF(sc->type)) {
+ sc->sample_weight = max(sc->sample_weight, 0.125f * sum);
+ }
+ }
+ }
+}
+
+
/* BSDF */
ccl_device_inline void _shader_bsdf_multi_eval(KernelGlobals *kg, ShaderData *sd, const float3 omega_in, float *pdf,
- int skip_bsdf, BsdfEval *result_eval, float sum_pdf, float sum_sample_weight)
+ const ShaderClosure *skip_sc, BsdfEval *result_eval, float sum_pdf, float sum_sample_weight)
{
/* this is the veach one-sample model with balance heuristic, some pdf
* factors drop out when using balance heuristic weighting */
for(int i = 0; i < sd->num_closure; i++) {
- if(i == skip_bsdf)
- continue;
-
const ShaderClosure *sc = &sd->closure[i];
- if(CLOSURE_IS_BSDF(sc->type)) {
+ if(sc != skip_sc && CLOSURE_IS_BSDF(sc->type)) {
float bsdf_pdf = 0.0f;
float3 eval = bsdf_eval(kg, sd, sc, omega_in, &bsdf_pdf);
@@ -574,7 +595,7 @@ void shader_bsdf_eval(KernelGlobals *kg,
#endif
{
float pdf;
- _shader_bsdf_multi_eval(kg, sd, omega_in, &pdf, -1, eval, 0.0f, 0.0f);
+ _shader_bsdf_multi_eval(kg, sd, omega_in, &pdf, NULL, eval, 0.0f, 0.0f);
if(use_mis) {
float weight = power_heuristic(light_pdf, pdf);
bsdf_eval_mis(eval, weight);
@@ -582,48 +603,120 @@ void shader_bsdf_eval(KernelGlobals *kg,
}
}
-ccl_device_inline int shader_bsdf_sample(KernelGlobals *kg,
- ShaderData *sd,
- float randu, float randv,
- BsdfEval *bsdf_eval,
- float3 *omega_in,
- differential3 *domega_in,
- float *pdf)
+ccl_device_inline const ShaderClosure *shader_bsdf_pick(ShaderData *sd,
+ float *randu)
{
int sampled = 0;
if(sd->num_closure > 1) {
- /* pick a BSDF closure based on sample weights */
+ /* Pick a BSDF or based on sample weights. */
float sum = 0.0f;
- for(sampled = 0; sampled < sd->num_closure; sampled++) {
- const ShaderClosure *sc = &sd->closure[sampled];
-
- if(CLOSURE_IS_BSDF(sc->type))
+ for(int i = 0; i < sd->num_closure; i++) {
+ const ShaderClosure *sc = &sd->closure[i];
+
+ if(CLOSURE_IS_BSDF(sc->type)) {
sum += sc->sample_weight;
+ }
}
- float r = sd->randb_closure*sum;
- sum = 0.0f;
+ float r = (*randu)*sum;
+ float partial_sum = 0.0f;
+
+ for(int i = 0; i < sd->num_closure; i++) {
+ const ShaderClosure *sc = &sd->closure[i];
- for(sampled = 0; sampled < sd->num_closure; sampled++) {
- const ShaderClosure *sc = &sd->closure[sampled];
-
if(CLOSURE_IS_BSDF(sc->type)) {
- sum += sc->sample_weight;
+ float next_sum = partial_sum + sc->sample_weight;
+
+ if(r < next_sum) {
+ sampled = i;
- if(r <= sum)
+ /* Rescale to reuse for direction sample, to better
+ * preserve stratifaction. */
+ *randu = (r - partial_sum) / sc->sample_weight;
break;
+ }
+
+ partial_sum = next_sum;
}
}
+ }
- if(sampled == sd->num_closure) {
- *pdf = 0.0f;
- return LABEL_NONE;
+ return &sd->closure[sampled];
+}
+
+ccl_device_inline const ShaderClosure *shader_bssrdf_pick(ShaderData *sd,
+ ccl_addr_space float3 *throughput,
+ float *randu)
+{
+ int sampled = 0;
+
+ if(sd->num_closure > 1) {
+ /* Pick a BSDF or BSSRDF or based on sample weights. */
+ float sum_bsdf = 0.0f;
+ float sum_bssrdf = 0.0f;
+
+ for(int i = 0; i < sd->num_closure; i++) {
+ const ShaderClosure *sc = &sd->closure[i];
+
+ if(CLOSURE_IS_BSDF(sc->type)) {
+ sum_bsdf += sc->sample_weight;
+ }
+ else if(CLOSURE_IS_BSSRDF(sc->type)) {
+ sum_bssrdf += sc->sample_weight;
+ }
+ }
+
+ float r = (*randu)*(sum_bsdf + sum_bssrdf);
+ float partial_sum = 0.0f;
+
+ for(int i = 0; i < sd->num_closure; i++) {
+ const ShaderClosure *sc = &sd->closure[i];
+
+ if(CLOSURE_IS_BSDF_OR_BSSRDF(sc->type)) {
+ float next_sum = partial_sum + sc->sample_weight;
+
+ if(r < next_sum) {
+ if(CLOSURE_IS_BSDF(sc->type)) {
+ *throughput *= (sum_bsdf + sum_bssrdf) / sum_bsdf;
+ return NULL;
+ }
+ else {
+ *throughput *= (sum_bsdf + sum_bssrdf) / sum_bssrdf;
+ sampled = i;
+
+ /* Rescale to reuse for direction sample, to better
+ * preserve stratifaction. */
+ *randu = (r - partial_sum) / sc->sample_weight;
+ break;
+ }
+ }
+
+ partial_sum = next_sum;
+ }
}
}
- const ShaderClosure *sc = &sd->closure[sampled];
+ return &sd->closure[sampled];
+}
+
+ccl_device_inline int shader_bsdf_sample(KernelGlobals *kg,
+ ShaderData *sd,
+ float randu, float randv,
+ BsdfEval *bsdf_eval,
+ float3 *omega_in,
+ differential3 *domega_in,
+ float *pdf)
+{
+ const ShaderClosure *sc = shader_bsdf_pick(sd, &randu);
+ if(sc == NULL) {
+ *pdf = 0.0f;
+ return LABEL_NONE;
+ }
+
+ /* BSSRDF should already have been handled elsewhere. */
+ kernel_assert(CLOSURE_IS_BSDF(sc->type));
int label;
float3 eval;
@@ -636,7 +729,7 @@ ccl_device_inline int shader_bsdf_sample(KernelGlobals *kg,
if(sd->num_closure > 1) {
float sweight = sc->sample_weight;
- _shader_bsdf_multi_eval(kg, sd, *omega_in, pdf, sampled, bsdf_eval, *pdf*sweight, sweight);
+ _shader_bsdf_multi_eval(kg, sd, *omega_in, pdf, sc, bsdf_eval, *pdf*sweight, sweight);
}
}
@@ -669,7 +762,7 @@ ccl_device void shader_bsdf_blur(KernelGlobals *kg, ShaderData *sd, float roughn
}
}
-ccl_device float3 shader_bsdf_transparency(KernelGlobals *kg, ShaderData *sd)
+ccl_device float3 shader_bsdf_transparency(KernelGlobals *kg, const ShaderData *sd)
{
if(sd->flag & SD_HAS_ONLY_VOLUME)
return make_float3(1.0f, 1.0f, 1.0f);
@@ -677,7 +770,7 @@ ccl_device float3 shader_bsdf_transparency(KernelGlobals *kg, ShaderData *sd)
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
for(int i = 0; i < sd->num_closure; i++) {
- ShaderClosure *sc = &sd->closure[i];
+ const ShaderClosure *sc = &sd->closure[i];
if(sc->type == CLOSURE_BSDF_TRANSPARENT_ID) // todo: make this work for osl
eval += sc->weight;
@@ -764,6 +857,19 @@ ccl_device float3 shader_bsdf_subsurface(KernelGlobals *kg, ShaderData *sd)
return eval;
}
+ccl_device float3 shader_bsdf_average_normal(KernelGlobals *kg, ShaderData *sd)
+{
+ float3 N = 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_BSDF_OR_BSSRDF(sc->type))
+ N += sc->N*average(sc->weight);
+ }
+
+ return (is_zero(N))? sd->N : normalize(N);
+}
+
ccl_device float3 shader_bsdf_ao(KernelGlobals *kg, ShaderData *sd, float ao_factor, float3 *N_)
{
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
@@ -783,12 +889,7 @@ ccl_device float3 shader_bsdf_ao(KernelGlobals *kg, ShaderData *sd, float ao_fac
}
}
- if(is_zero(N))
- N = sd->N;
- else
- N = normalize(N);
-
- *N_ = N;
+ *N_ = (is_zero(N))? sd->N : normalize(N);
return eval;
}
@@ -863,16 +964,15 @@ ccl_device float3 shader_holdout_eval(KernelGlobals *kg, ShaderData *sd)
/* Surface Evaluation */
-ccl_device void shader_eval_surface(KernelGlobals *kg, ShaderData *sd, RNG *rng,
- ccl_addr_space PathState *state, float randb, int path_flag, ShaderContext ctx)
+ccl_device void shader_eval_surface(KernelGlobals *kg, ShaderData *sd,
+ ccl_addr_space PathState *state, int path_flag)
{
sd->num_closure = 0;
sd->num_closure_extra = 0;
- sd->randb_closure = randb;
#ifdef __OSL__
if(kg->osl)
- OSLShader::eval_surface(kg, sd, state, path_flag, ctx);
+ OSLShader::eval_surface(kg, sd, state, path_flag);
else
#endif
{
@@ -887,24 +987,23 @@ ccl_device void shader_eval_surface(KernelGlobals *kg, ShaderData *sd, RNG *rng,
#endif
}
- if(rng && (sd->flag & SD_BSDF_NEEDS_LCG)) {
- sd->lcg_state = lcg_state_init(rng, state->rng_offset, state->sample, 0xb4bc3953);
+ if(sd->flag & SD_BSDF_NEEDS_LCG) {
+ sd->lcg_state = lcg_state_init_addrspace(state, 0xb4bc3953);
}
}
/* Background Evaluation */
ccl_device float3 shader_eval_background(KernelGlobals *kg, ShaderData *sd,
- ccl_addr_space PathState *state, int path_flag, ShaderContext ctx)
+ ccl_addr_space PathState *state, int path_flag)
{
sd->num_closure = 0;
sd->num_closure_extra = 0;
- sd->randb_closure = 0.0f;
#ifdef __SVM__
#ifdef __OSL__
if(kg->osl) {
- OSLShader::eval_background(kg, sd, state, path_flag, ctx);
+ OSLShader::eval_background(kg, sd, state, path_flag);
}
else
#endif
@@ -981,17 +1080,22 @@ ccl_device int shader_volume_phase_sample(KernelGlobals *kg, const ShaderData *s
sum += sc->sample_weight;
}
- float r = sd->randb_closure*sum;
- sum = 0.0f;
+ float r = randu*sum;
+ float partial_sum = 0.0f;
for(sampled = 0; sampled < sd->num_closure; sampled++) {
const ShaderClosure *sc = &sd->closure[sampled];
if(CLOSURE_IS_PHASE(sc->type)) {
- sum += sc->sample_weight;
+ float next_sum = partial_sum + sc->sample_weight;
- if(r <= sum)
+ if(r <= next_sum) {
+ /* Rescale to reuse for BSDF direction sample. */
+ randu = (r - partial_sum) / sc->sample_weight;
break;
+ }
+
+ partial_sum = next_sum;
}
}
@@ -1039,8 +1143,7 @@ ccl_device_inline void shader_eval_volume(KernelGlobals *kg,
ShaderData *sd,
ccl_addr_space PathState *state,
ccl_addr_space VolumeStack *stack,
- int path_flag,
- ShaderContext ctx)
+ int path_flag)
{
/* reset closures once at the start, we will be accumulating the closures
* for all volumes in the stack into a single array of closures */
@@ -1073,7 +1176,7 @@ ccl_device_inline void shader_eval_volume(KernelGlobals *kg,
#ifdef __SVM__
# ifdef __OSL__
if(kg->osl) {
- OSLShader::eval_volume(kg, sd, state, path_flag, ctx);
+ OSLShader::eval_volume(kg, sd, state, path_flag);
}
else
# endif
@@ -1092,17 +1195,16 @@ ccl_device_inline void shader_eval_volume(KernelGlobals *kg,
/* Displacement Evaluation */
-ccl_device void shader_eval_displacement(KernelGlobals *kg, ShaderData *sd, ccl_addr_space PathState *state, ShaderContext ctx)
+ccl_device void shader_eval_displacement(KernelGlobals *kg, ShaderData *sd, ccl_addr_space PathState *state)
{
sd->num_closure = 0;
sd->num_closure_extra = 0;
- sd->randb_closure = 0.0f;
/* this will modify sd->P */
#ifdef __SVM__
# ifdef __OSL__
if(kg->osl)
- OSLShader::eval_displacement(kg, sd, ctx);
+ OSLShader::eval_displacement(kg, sd, state);
else
# endif
{
diff --git a/intern/cycles/kernel/kernel_shadow.h b/intern/cycles/kernel/kernel_shadow.h
index fab5946970d..8a0da6c3b13 100644
--- a/intern/cycles/kernel/kernel_shadow.h
+++ b/intern/cycles/kernel/kernel_shadow.h
@@ -16,6 +16,42 @@
CCL_NAMESPACE_BEGIN
+#ifdef __VOLUME__
+typedef struct VolumeState {
+# ifdef __SPLIT_KERNEL__
+# else
+ PathState ps;
+# endif
+} VolumeState;
+
+/* Get PathState ready for use for volume stack evaluation. */
+# ifdef __SPLIT_KERNEL__
+ccl_addr_space
+# endif
+ccl_device_inline PathState *shadow_blocked_volume_path_state(
+ KernelGlobals *kg,
+ VolumeState *volume_state,
+ ccl_addr_space PathState *state,
+ ShaderData *sd,
+ Ray *ray)
+{
+# ifdef __SPLIT_KERNEL__
+ ccl_addr_space PathState *ps =
+ &kernel_split_state.state_shadow[ccl_global_id(1) * ccl_global_size(0) + ccl_global_id(0)];
+# else
+ PathState *ps = &volume_state->ps;
+# endif
+ *ps = *state;
+ /* We are checking for shadow on the "other" side of the surface, so need
+ * to discard volume we are currently at.
+ */
+ if(dot(sd->Ng, ray->D) < 0.0f) {
+ kernel_volume_stack_enter_exit(kg, sd, ps->volume_stack);
+ }
+ return ps;
+}
+#endif /* __VOLUME__ */
+
/* Attenuate throughput accordingly to the given intersection event.
* Returns true if the throughput is zero and traversal can be aborted.
*/
@@ -49,11 +85,8 @@ ccl_device_forceinline bool shadow_handle_transparent_isect(
path_state_modify_bounce(state, true);
shader_eval_surface(kg,
shadow_sd,
- NULL,
state,
- 0.0f,
- PATH_RAY_SHADOW,
- SHADER_CONTEXT_SHADOW);
+ PATH_RAY_SHADOW);
path_state_modify_bounce(state, false);
*throughput *= shader_bsdf_transparency(kg, shadow_sd);
}
@@ -72,13 +105,14 @@ ccl_device_forceinline bool shadow_handle_transparent_isect(
ccl_device bool shadow_blocked_opaque(KernelGlobals *kg,
ShaderData *shadow_sd,
ccl_addr_space PathState *state,
+ const uint visibility,
Ray *ray,
Intersection *isect,
float3 *shadow)
{
const bool blocked = scene_intersect(kg,
*ray,
- PATH_RAY_SHADOW_OPAQUE,
+ visibility & PATH_RAY_SHADOW_OPAQUE,
isect,
NULL,
0.0f, 0.0f);
@@ -126,9 +160,10 @@ ccl_device bool shadow_blocked_opaque(KernelGlobals *kg,
* Note that hits array should be as big as max_hits+1.
*/
ccl_device bool shadow_blocked_transparent_all_loop(KernelGlobals *kg,
+ ShaderData *sd,
ShaderData *shadow_sd,
ccl_addr_space PathState *state,
- const int skip_object,
+ const uint visibility,
Ray *ray,
Intersection *hits,
uint max_hits,
@@ -141,9 +176,12 @@ ccl_device bool shadow_blocked_transparent_all_loop(KernelGlobals *kg,
const bool blocked = scene_intersect_shadow_all(kg,
ray,
hits,
- skip_object,
+ visibility,
max_hits,
&num_hits);
+# ifdef __VOLUME__
+ VolumeState volume_state;
+# endif
/* If no opaque surface found but we did find transparent hits,
* shade them.
*/
@@ -155,12 +193,13 @@ ccl_device bool shadow_blocked_transparent_all_loop(KernelGlobals *kg,
Intersection *isect = hits;
# ifdef __VOLUME__
# ifdef __SPLIT_KERNEL__
- ccl_addr_space PathState *ps = &kernel_split_state.state_shadow[ccl_global_id(1) * ccl_global_size(0) + ccl_global_id(0)];
-# else
- PathState ps_object;
- PathState *ps = &ps_object;
+ ccl_addr_space
# endif
- *ps = *state;
+ PathState *ps = shadow_blocked_volume_path_state(kg,
+ &volume_state,
+ state,
+ sd,
+ ray);
# endif
sort_intersections(hits, num_hits);
for(int hit = 0; hit < num_hits; hit++, isect++) {
@@ -205,8 +244,16 @@ ccl_device bool shadow_blocked_transparent_all_loop(KernelGlobals *kg,
}
# ifdef __VOLUME__
if(!blocked && state->volume_stack[0].shader != SHADER_NONE) {
- /* Apply attenuation from current volume shader/ */
- kernel_volume_shadow(kg, shadow_sd, state, ray, shadow);
+ /* Apply attenuation from current volume shader. */
+# ifdef __SPLIT_KERNEL__
+ ccl_addr_space
+# endif
+ PathState *ps = shadow_blocked_volume_path_state(kg,
+ &volume_state,
+ state,
+ sd,
+ ray);
+ kernel_volume_shadow(kg, shadow_sd, ps, ray, shadow);
}
# endif
return blocked;
@@ -216,9 +263,10 @@ ccl_device bool shadow_blocked_transparent_all_loop(KernelGlobals *kg,
* loop to help readability of the actual logic.
*/
ccl_device bool shadow_blocked_transparent_all(KernelGlobals *kg,
+ ShaderData *sd,
ShaderData *shadow_sd,
ccl_addr_space PathState *state,
- const int skip_object,
+ const uint visibility,
Ray *ray,
uint max_hits,
float3 *shadow)
@@ -251,9 +299,10 @@ ccl_device bool shadow_blocked_transparent_all(KernelGlobals *kg,
# endif /* __KERNEL_GPU__ */
/* Invoke actual traversal. */
return shadow_blocked_transparent_all_loop(kg,
+ sd,
shadow_sd,
state,
- skip_object,
+ visibility,
ray,
hits,
max_hits,
@@ -276,27 +325,32 @@ ccl_device bool shadow_blocked_transparent_all(KernelGlobals *kg,
*/
ccl_device bool shadow_blocked_transparent_stepped_loop(
KernelGlobals *kg,
+ ShaderData *sd,
ShaderData *shadow_sd,
ccl_addr_space PathState *state,
- const int skip_object,
+ const uint visibility,
Ray *ray,
Intersection *isect,
const bool blocked,
const bool is_transparent_isect,
float3 *shadow)
{
- if((blocked && is_transparent_isect) || skip_object != OBJECT_NONE) {
+# ifdef __VOLUME__
+ VolumeState volume_state;
+# endif
+ if(blocked && is_transparent_isect) {
float3 throughput = make_float3(1.0f, 1.0f, 1.0f);
float3 Pend = ray->P + ray->D*ray->t;
int bounce = state->transparent_bounce;
# ifdef __VOLUME__
# ifdef __SPLIT_KERNEL__
- ccl_addr_space PathState *ps = &kernel_split_state.state_shadow[ccl_global_id(1) * ccl_global_size(0) + ccl_global_id(0)];
-# else
- PathState ps_object;
- PathState *ps = &ps_object;
+ ccl_addr_space
# endif
- *ps = *state;
+ PathState *ps = shadow_blocked_volume_path_state(kg,
+ &volume_state,
+ state,
+ sd,
+ ray);
# endif
for(;;) {
if(bounce >= kernel_data.integrator.transparent_max_bounce) {
@@ -304,30 +358,13 @@ ccl_device bool shadow_blocked_transparent_stepped_loop(
}
if(!scene_intersect(kg,
*ray,
- PATH_RAY_SHADOW_TRANSPARENT,
+ visibility & PATH_RAY_SHADOW_TRANSPARENT,
isect,
NULL,
0.0f, 0.0f))
{
break;
}
-#ifdef __SHADOW_TRICKS__
- if(skip_object != OBJECT_NONE) {
- const int isect_object = (isect->object == PRIM_NONE)
- ? kernel_tex_fetch(__prim_object, isect->prim)
- : isect->object;
- if(isect_object == skip_object) {
- shader_setup_from_ray(kg, shadow_sd, isect, ray);
- /* Move ray forward. */
- ray->P = ray_offset(shadow_sd->P, -shadow_sd->Ng);
- if(ray->t != FLT_MAX) {
- ray->D = normalize_len(Pend - ray->P, &ray->t);
- }
- bounce++;
- continue;
- }
- }
-#endif
if(!shader_transparent_shadow(kg, isect)) {
return true;
}
@@ -363,7 +400,15 @@ ccl_device bool shadow_blocked_transparent_stepped_loop(
# ifdef __VOLUME__
if(!blocked && state->volume_stack[0].shader != SHADER_NONE) {
/* Apply attenuation from current volume shader. */
- kernel_volume_shadow(kg, shadow_sd, state, ray, shadow);
+# ifdef __SPLIT_KERNEL__
+ ccl_addr_space
+# endif
+ PathState *ps = shadow_blocked_volume_path_state(kg,
+ &volume_state,
+ state,
+ sd,
+ ray);
+ kernel_volume_shadow(kg, shadow_sd, ps, ray, shadow);
}
# endif
return blocked;
@@ -371,33 +416,28 @@ ccl_device bool shadow_blocked_transparent_stepped_loop(
ccl_device bool shadow_blocked_transparent_stepped(
KernelGlobals *kg,
+ ShaderData *sd,
ShaderData *shadow_sd,
ccl_addr_space PathState *state,
- const int skip_object,
+ const uint visibility,
Ray *ray,
Intersection *isect,
float3 *shadow)
{
- bool blocked, is_transparent_isect;
- if(skip_object == OBJECT_NONE) {
- blocked = scene_intersect(kg,
- *ray,
- PATH_RAY_SHADOW_OPAQUE,
- isect,
- NULL,
- 0.0f, 0.0f);
- is_transparent_isect = blocked
- ? shader_transparent_shadow(kg, isect)
- : false;
- }
- else {
- blocked = false;
- is_transparent_isect = false;
- }
+ bool blocked = scene_intersect(kg,
+ *ray,
+ visibility & PATH_RAY_SHADOW_OPAQUE,
+ isect,
+ NULL,
+ 0.0f, 0.0f);
+ bool is_transparent_isect = blocked
+ ? shader_transparent_shadow(kg, isect)
+ : false;
return shadow_blocked_transparent_stepped_loop(kg,
+ sd,
shadow_sd,
state,
- skip_object,
+ visibility,
ray,
isect,
blocked,
@@ -409,6 +449,7 @@ ccl_device bool shadow_blocked_transparent_stepped(
#endif /* __TRANSPARENT_SHADOWS__ */
ccl_device_inline bool shadow_blocked(KernelGlobals *kg,
+ ShaderData *sd,
ShaderData *shadow_sd,
ccl_addr_space PathState *state,
Ray *ray_input,
@@ -422,25 +463,24 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg,
return false;
}
#ifdef __SHADOW_TRICKS__
- const int skip_object = state->catcher_object;
+ const uint visibility = (state->flag & PATH_RAY_SHADOW_CATCHER)
+ ? PATH_RAY_SHADOW_NON_CATCHER
+ : PATH_RAY_SHADOW;
#else
- const int skip_object = OBJECT_NONE;
+ const uint visibility = PATH_RAY_SHADOW;
#endif
/* Do actual shadow shading. */
/* First of all, we check if integrator requires transparent shadows.
* if not, we use simplest and fastest ever way to calculate occlusion.
- *
- * NOTE: We can't do quick opaque test here if we are on shadow-catcher
- * path because we don't want catcher object to be casting shadow here.
*/
#ifdef __TRANSPARENT_SHADOWS__
- if(!kernel_data.integrator.transparent_shadows &&
- skip_object == OBJECT_NONE)
+ if(!kernel_data.integrator.transparent_shadows)
#endif
{
return shadow_blocked_opaque(kg,
shadow_sd,
state,
+ visibility,
ray,
&isect,
shadow);
@@ -467,7 +507,7 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg,
*/
const bool blocked = scene_intersect(kg,
*ray,
- PATH_RAY_SHADOW_OPAQUE,
+ visibility & PATH_RAY_SHADOW_OPAQUE,
&isect,
NULL,
0.0f, 0.0f);
@@ -478,9 +518,10 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg,
max_hits + 1 >= SHADOW_STACK_MAX_HITS)
{
return shadow_blocked_transparent_stepped_loop(kg,
+ sd,
shadow_sd,
state,
- skip_object,
+ visibility,
ray,
&isect,
blocked,
@@ -489,18 +530,20 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg,
}
# endif /* __KERNEL_GPU__ */
return shadow_blocked_transparent_all(kg,
+ sd,
shadow_sd,
state,
- skip_object,
+ visibility,
ray,
max_hits,
shadow);
# else /* __SHADOW_RECORD_ALL__ */
/* Fallback to a slowest version which works on all devices. */
return shadow_blocked_transparent_stepped(kg,
+ sd,
shadow_sd,
state,
- skip_object,
+ visibility,
ray,
&isect,
shadow);
diff --git a/intern/cycles/kernel/kernel_subsurface.h b/intern/cycles/kernel/kernel_subsurface.h
index 6475d4b66fd..23a09e5e2ca 100644
--- a/intern/cycles/kernel/kernel_subsurface.h
+++ b/intern/cycles/kernel/kernel_subsurface.h
@@ -28,87 +28,31 @@ CCL_NAMESPACE_BEGIN
* - try to reduce one sample model variance
*/
-#define BSSRDF_MULTI_EVAL
-
-ccl_device ShaderClosure *subsurface_scatter_pick_closure(KernelGlobals *kg, ShaderData *sd, float *probability)
-{
- /* sum sample weights of bssrdf and bsdf */
- float bsdf_sum = 0.0f;
- float bssrdf_sum = 0.0f;
-
- for(int i = 0; i < sd->num_closure; i++) {
- ShaderClosure *sc = &sd->closure[i];
-
- if(CLOSURE_IS_BSDF(sc->type))
- bsdf_sum += sc->sample_weight;
- else if(CLOSURE_IS_BSSRDF(sc->type))
- bssrdf_sum += sc->sample_weight;
- }
-
- /* use bsdf or bssrdf? */
- float r = sd->randb_closure*(bsdf_sum + bssrdf_sum);
-
- if(r < bsdf_sum) {
- /* use bsdf, and adjust randb so we can reuse it for picking a bsdf */
- sd->randb_closure = r/bsdf_sum;
- *probability = (bsdf_sum > 0.0f)? (bsdf_sum + bssrdf_sum)/bsdf_sum: 1.0f;
- return NULL;
- }
-
- /* use bssrdf */
- r -= bsdf_sum;
-
- float sum = 0.0f;
-
- for(int i = 0; i < sd->num_closure; i++) {
- ShaderClosure *sc = &sd->closure[i];
-
- if(CLOSURE_IS_BSSRDF(sc->type)) {
- sum += sc->sample_weight;
-
- if(r <= sum) {
- sd->randb_closure = (r - (sum - sc->sample_weight))/sc->sample_weight;
-
-#ifdef BSSRDF_MULTI_EVAL
- *probability = (bssrdf_sum > 0.0f)? (bsdf_sum + bssrdf_sum)/bssrdf_sum: 1.0f;
-#else
- *probability = (bssrdf_sum > 0.0f)? (bsdf_sum + bssrdf_sum)/sc->sample_weight: 1.0f;
-#endif
- return sc;
- }
- }
- }
-
- /* should never happen */
- sd->randb_closure = 0.0f;
- *probability = 1.0f;
- return NULL;
-}
-
ccl_device_inline float3 subsurface_scatter_eval(ShaderData *sd,
- ShaderClosure *sc,
+ const ShaderClosure *sc,
float disk_r,
float r,
bool all)
{
-#ifdef BSSRDF_MULTI_EVAL
/* this is the veach one-sample model with balance heuristic, some pdf
* factors drop out when using balance heuristic weighting */
float3 eval_sum = make_float3(0.0f, 0.0f, 0.0f);
float pdf_sum = 0.0f;
- float sample_weight_sum = 0.0f;
- int num_bssrdf = 0;
+ float sample_weight_inv = 0.0f;
- for(int i = 0; i < sd->num_closure; i++) {
- sc = &sd->closure[i];
-
- if(CLOSURE_IS_BSSRDF(sc->type)) {
- float sample_weight = (all)? 1.0f: sc->sample_weight;
- sample_weight_sum += sample_weight;
+ if(!all) {
+ float sample_weight_sum = 0.0f;
+
+ for(int i = 0; i < sd->num_closure; i++) {
+ sc = &sd->closure[i];
+
+ if(CLOSURE_IS_BSSRDF(sc->type)) {
+ sample_weight_sum += sc->sample_weight;
+ }
}
- }
- float sample_weight_inv = 1.0f/sample_weight_sum;
+ sample_weight_inv = 1.0f/sample_weight_sum;
+ }
for(int i = 0; i < sd->num_closure; i++) {
sc = &sd->closure[i];
@@ -125,25 +69,16 @@ ccl_device_inline float3 subsurface_scatter_eval(ShaderData *sd,
/* TODO power heuristic is not working correct here */
eval_sum += sc->weight*pdf; //*sample_weight*disk_pdf;
pdf_sum += sample_weight*disk_pdf; //*sample_weight*disk_pdf;
-
- num_bssrdf++;
}
}
return (pdf_sum > 0.0f)? eval_sum / pdf_sum : make_float3(0.0f, 0.0f, 0.0f);
-#else
- float pdf = bssrdf_pdf(pick_sc, r);
- float disk_pdf = bssrdf_pdf(pick_sc, disk_r);
-
- return pick_sc->weight * pdf / disk_pdf;
-#endif
}
/* replace closures with a single diffuse bsdf closure after scatter step */
-ccl_device void subsurface_scatter_setup_diffuse_bsdf(ShaderData *sd, ShaderClosure *sc, float3 weight, bool hit, float3 N)
+ccl_device void subsurface_scatter_setup_diffuse_bsdf(ShaderData *sd, const ShaderClosure *sc, float3 weight, bool hit, float3 N)
{
sd->flag &= ~SD_CLOSURE_FLAGS;
- sd->randb_closure = 0.0f;
sd->num_closure = 0;
sd->num_closure_extra = 0;
@@ -219,7 +154,7 @@ ccl_device void subsurface_color_bump_blur(KernelGlobals *kg,
if(bump || texture_blur > 0.0f) {
/* average color and normal at incoming point */
- shader_eval_surface(kg, sd, NULL, state, 0.0f, state_flag, SHADER_CONTEXT_SSS);
+ shader_eval_surface(kg, sd, state, state_flag);
float3 in_color = shader_bssrdf_sum(sd, (bump)? N: NULL, NULL);
/* we simply divide out the average color and multiply with the average
@@ -242,8 +177,8 @@ ccl_device_inline int subsurface_scatter_multi_intersect(
KernelGlobals *kg,
SubsurfaceIntersection *ss_isect,
ShaderData *sd,
- ShaderClosure *sc,
- RNG *lcg_state,
+ const ShaderClosure *sc,
+ uint *lcg_state,
float disk_u,
float disk_v,
bool all)
@@ -255,26 +190,20 @@ ccl_device_inline int subsurface_scatter_multi_intersect(
disk_N = sd->Ng;
make_orthonormals(disk_N, &disk_T, &disk_B);
- /* reusing variable for picking the closure gives a bit nicer stratification
- * for path tracer, for branched we do all closures so it doesn't help */
- float axisu = (all)? disk_u: sd->randb_closure;
-
- if(axisu < 0.5f) {
+ if(disk_u < 0.5f) {
pick_pdf_N = 0.5f;
pick_pdf_T = 0.25f;
pick_pdf_B = 0.25f;
- if(all)
- disk_u *= 2.0f;
+ disk_u *= 2.0f;
}
- else if(axisu < 0.75f) {
+ else if(disk_u < 0.75f) {
float3 tmp = disk_N;
disk_N = disk_T;
disk_T = tmp;
pick_pdf_N = 0.25f;
pick_pdf_T = 0.5f;
pick_pdf_B = 0.25f;
- if(all)
- disk_u = (disk_u - 0.5f)*4.0f;
+ disk_u = (disk_u - 0.5f)*4.0f;
}
else {
float3 tmp = disk_N;
@@ -283,8 +212,7 @@ ccl_device_inline int subsurface_scatter_multi_intersect(
pick_pdf_N = 0.25f;
pick_pdf_T = 0.25f;
pick_pdf_B = 0.5f;
- if(all)
- disk_u = (disk_u - 0.75f)*4.0f;
+ disk_u = (disk_u - 0.75f)*4.0f;
}
/* sample point on disk */
@@ -390,7 +318,7 @@ ccl_device_noinline void subsurface_scatter_multi_setup(
ShaderData *sd,
ccl_addr_space PathState *state,
int state_flag,
- ShaderClosure *sc,
+ const ShaderClosure *sc,
bool all)
{
#ifdef __SPLIT_KERNEL__
@@ -419,7 +347,7 @@ ccl_device_noinline void subsurface_scatter_multi_setup(
/* subsurface scattering step, from a point on the surface to another nearby point on the same object */
ccl_device void subsurface_scatter_step(KernelGlobals *kg, ShaderData *sd, ccl_addr_space PathState *state,
- int state_flag, ShaderClosure *sc, uint *lcg_state, float disk_u, float disk_v, bool all)
+ int state_flag, const ShaderClosure *sc, uint *lcg_state, float disk_u, float disk_v, bool all)
{
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
@@ -430,18 +358,20 @@ ccl_device void subsurface_scatter_step(KernelGlobals *kg, ShaderData *sd, ccl_a
disk_N = sd->Ng;
make_orthonormals(disk_N, &disk_T, &disk_B);
- if(sd->randb_closure < 0.5f) {
+ if(disk_u < 0.5f) {
pick_pdf_N = 0.5f;
pick_pdf_T = 0.25f;
pick_pdf_B = 0.25f;
+ disk_u *= 2.0f;
}
- else if(sd->randb_closure < 0.75f) {
+ else if(disk_u < 0.75f) {
float3 tmp = disk_N;
disk_N = disk_T;
disk_T = tmp;
pick_pdf_N = 0.25f;
pick_pdf_T = 0.5f;
pick_pdf_B = 0.25f;
+ disk_u = (disk_u - 0.5f)*4.0f;
}
else {
float3 tmp = disk_N;
@@ -450,6 +380,7 @@ ccl_device void subsurface_scatter_step(KernelGlobals *kg, ShaderData *sd, ccl_a
pick_pdf_N = 0.25f;
pick_pdf_T = 0.25f;
pick_pdf_B = 0.5f;
+ disk_u = (disk_u - 0.75f)*4.0f;
}
/* sample point on disk */
diff --git a/intern/cycles/kernel/kernel_textures.h b/intern/cycles/kernel/kernel_textures.h
index cb1a3f40dee..5eab28a2953 100644
--- a/intern/cycles/kernel/kernel_textures.h
+++ b/intern/cycles/kernel/kernel_textures.h
@@ -82,115 +82,110 @@ KERNEL_TEX(uint, texture_uint, __sobol_directions)
# if __CUDA_ARCH__ < 300
/* full-float image */
KERNEL_IMAGE_TEX(float4, texture_image_float4, __tex_image_float4_000)
-KERNEL_IMAGE_TEX(float4, texture_image_float4, __tex_image_float4_001)
-KERNEL_IMAGE_TEX(float4, texture_image_float4, __tex_image_float4_002)
-KERNEL_IMAGE_TEX(float4, texture_image_float4, __tex_image_float4_003)
-KERNEL_IMAGE_TEX(float4, texture_image_float4, __tex_image_float4_004)
+KERNEL_IMAGE_TEX(float4, texture_image_float4, __tex_image_float4_008)
+KERNEL_IMAGE_TEX(float4, texture_image_float4, __tex_image_float4_016)
+KERNEL_IMAGE_TEX(float4, texture_image_float4, __tex_image_float4_024)
+KERNEL_IMAGE_TEX(float4, texture_image_float4, __tex_image_float4_032)
KERNEL_IMAGE_TEX(float4, texture_image3d_float4, __tex_image_float4_3d_000)
-KERNEL_IMAGE_TEX(float4, texture_image3d_float4, __tex_image_float4_3d_001)
-KERNEL_IMAGE_TEX(float4, texture_image3d_float4, __tex_image_float4_3d_002)
-KERNEL_IMAGE_TEX(float4, texture_image3d_float4, __tex_image_float4_3d_003)
-KERNEL_IMAGE_TEX(float4, texture_image3d_float4, __tex_image_float4_3d_004)
-
-/* image */
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_005)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_006)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_007)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_008)
+KERNEL_IMAGE_TEX(float4, texture_image3d_float4, __tex_image_float4_3d_008)
+KERNEL_IMAGE_TEX(float4, texture_image3d_float4, __tex_image_float4_3d_016)
+KERNEL_IMAGE_TEX(float4, texture_image3d_float4, __tex_image_float4_3d_024)
+KERNEL_IMAGE_TEX(float4, texture_image3d_float4, __tex_image_float4_3d_032)
+
+/* image
+ * These texture names are encoded to their flattened slots as
+ * ImageManager::type_index_to_flattened_slot() returns them. */
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_001)
KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_009)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_010)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_011)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_012)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_013)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_014)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_015)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_016)
KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_017)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_018)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_019)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_020)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_021)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_022)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_023)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_024)
KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_025)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_026)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_027)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_028)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_029)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_030)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_031)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_032)
KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_033)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_034)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_035)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_036)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_037)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_038)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_039)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_040)
KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_041)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_042)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_043)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_044)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_045)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_046)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_047)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_048)
KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_049)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_050)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_051)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_052)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_053)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_054)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_055)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_056)
KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_057)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_058)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_059)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_060)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_061)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_062)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_063)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_064)
KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_065)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_066)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_067)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_068)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_069)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_070)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_071)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_072)
KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_073)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_074)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_075)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_076)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_077)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_078)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_079)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_080)
KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_081)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_082)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_083)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_084)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_085)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_086)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_087)
-KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_088)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_089)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_097)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_105)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_113)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_121)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_129)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_137)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_145)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_153)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_161)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_169)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_177)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_185)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_193)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_201)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_209)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_217)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_225)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_233)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_241)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_249)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_257)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_265)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_273)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_281)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_289)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_297)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_305)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_313)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_321)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_329)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_337)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_345)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_353)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_361)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_369)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_377)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_385)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_393)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_401)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_409)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_417)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_425)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_433)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_441)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_449)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_457)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_465)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_473)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_481)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_489)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_497)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_505)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_513)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_521)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_529)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_537)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_545)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_553)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_561)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_569)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_577)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_585)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_593)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_601)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_609)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_617)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_625)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_633)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_641)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_649)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_657)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_665)
# else
/* bindless textures */
KERNEL_TEX(uint, texture_uint, __bindless_mapping)
-# endif
-#endif
-
-/* packed image (opencl) */
-KERNEL_TEX(uchar4, texture_uchar4, __tex_image_byte4_packed)
-KERNEL_TEX(float4, texture_float4, __tex_image_float4_packed)
-KERNEL_TEX(uchar, texture_uchar, __tex_image_byte_packed)
-KERNEL_TEX(float, texture_float, __tex_image_float_packed)
-KERNEL_TEX(uint4, texture_uint4, __tex_image_packed_info)
+# endif /* __CUDA_ARCH__ */
+#endif /* __KERNEL_CUDA__ */
#undef KERNEL_TEX
#undef KERNEL_IMAGE_TEX
diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h
index 34affab1b9d..19c77c1ed4f 100644
--- a/intern/cycles/kernel/kernel_types.h
+++ b/intern/cycles/kernel/kernel_types.h
@@ -130,6 +130,7 @@ CCL_NAMESPACE_BEGIN
# ifdef __KERNEL_OPENCL_APPLE__
# define __KERNEL_SHADING__
# define __KERNEL_ADV_SHADING__
+# define __PRINCIPLED__
# define __CMJ__
/* TODO(sergey): Currently experimental section is ignored here,
* this is because megakernel in device_opencl does not support
@@ -154,6 +155,7 @@ CCL_NAMESPACE_BEGIN
# define __CL_USE_NATIVE__
# define __KERNEL_SHADING__
# define __KERNEL_ADV_SHADING__
+# define __PRINCIPLED__
# define __CMJ__
# endif /* __KERNEL_OPENCL_INTEL_CPU__ */
@@ -240,10 +242,6 @@ CCL_NAMESPACE_BEGIN
# undef __DENOISING_FEATURES__
#endif
-/* Random Numbers */
-
-typedef uint RNG;
-
/* Shader Evaluation */
typedef enum ShaderEvalType {
@@ -283,31 +281,21 @@ enum PathTraceDimension {
PRNG_FILTER_V = 1,
PRNG_LENS_U = 2,
PRNG_LENS_V = 3,
-#ifdef __CAMERA_MOTION__
PRNG_TIME = 4,
PRNG_UNUSED_0 = 5,
PRNG_UNUSED_1 = 6, /* for some reason (6, 7) is a bad sobol pattern */
PRNG_UNUSED_2 = 7, /* with a low number of samples (< 64) */
-#endif
- PRNG_BASE_NUM = 8,
+ PRNG_BASE_NUM = 10,
PRNG_BSDF_U = 0,
PRNG_BSDF_V = 1,
- PRNG_BSDF = 2,
- PRNG_LIGHT = 3,
- PRNG_LIGHT_U = 4,
- PRNG_LIGHT_V = 5,
- PRNG_LIGHT_TERMINATE = 6,
- PRNG_TERMINATE = 7,
-
-#ifdef __VOLUME__
- PRNG_PHASE_U = 8,
- PRNG_PHASE_V = 9,
- PRNG_PHASE = 10,
- PRNG_SCATTER_DISTANCE = 11,
-#endif
-
- PRNG_BOUNCE_NUM = 12,
+ PRNG_LIGHT_U = 2,
+ PRNG_LIGHT_V = 3,
+ PRNG_LIGHT_TERMINATE = 4,
+ PRNG_TERMINATE = 5,
+ PRNG_PHASE_CHANNEL = 6,
+ PRNG_SCATTER_DISTANCE = 7,
+ PRNG_BOUNCE_NUM = 8,
};
enum SamplingPattern {
@@ -328,24 +316,28 @@ enum PathRayFlag {
PATH_RAY_SINGULAR = (1 << 5),
PATH_RAY_TRANSPARENT = (1 << 6),
- PATH_RAY_SHADOW_OPAQUE = (1 << 7),
- PATH_RAY_SHADOW_TRANSPARENT = (1 << 8),
- PATH_RAY_SHADOW = (PATH_RAY_SHADOW_OPAQUE|PATH_RAY_SHADOW_TRANSPARENT),
+ PATH_RAY_SHADOW_OPAQUE_NON_CATCHER = (1 << 7),
+ PATH_RAY_SHADOW_OPAQUE_CATCHER = (1 << 8),
+ PATH_RAY_SHADOW_OPAQUE = (PATH_RAY_SHADOW_OPAQUE_NON_CATCHER|PATH_RAY_SHADOW_OPAQUE_CATCHER),
+ PATH_RAY_SHADOW_TRANSPARENT_NON_CATCHER = (1 << 9),
+ PATH_RAY_SHADOW_TRANSPARENT_CATCHER = (1 << 10),
+ PATH_RAY_SHADOW_TRANSPARENT = (PATH_RAY_SHADOW_TRANSPARENT_NON_CATCHER|PATH_RAY_SHADOW_TRANSPARENT_CATCHER),
+ PATH_RAY_SHADOW_NON_CATCHER = (PATH_RAY_SHADOW_OPAQUE_NON_CATCHER|PATH_RAY_SHADOW_TRANSPARENT_NON_CATCHER),
+ PATH_RAY_SHADOW = (PATH_RAY_SHADOW_OPAQUE|PATH_RAY_SHADOW_TRANSPARENT),
- PATH_RAY_CURVE = (1 << 9), /* visibility flag to define curve segments */
- PATH_RAY_VOLUME_SCATTER = (1 << 10), /* volume scattering */
+ PATH_RAY_CURVE = (1 << 11), /* visibility flag to define curve segments */
+ PATH_RAY_VOLUME_SCATTER = (1 << 12), /* volume scattering */
/* Special flag to tag unaligned BVH nodes. */
- PATH_RAY_NODE_UNALIGNED = (1 << 11),
+ PATH_RAY_NODE_UNALIGNED = (1 << 13),
- PATH_RAY_ALL_VISIBILITY = ((1 << 12)-1),
+ PATH_RAY_ALL_VISIBILITY = ((1 << 14)-1),
- PATH_RAY_MIS_SKIP = (1 << 12),
- PATH_RAY_DIFFUSE_ANCESTOR = (1 << 13),
- PATH_RAY_SINGLE_PASS_DONE = (1 << 14),
- PATH_RAY_SHADOW_CATCHER = (1 << 15),
- PATH_RAY_SHADOW_CATCHER_ONLY = (1 << 16),
- PATH_RAY_STORE_SHADOW_INFO = (1 << 17),
+ PATH_RAY_MIS_SKIP = (1 << 15),
+ PATH_RAY_DIFFUSE_ANCESTOR = (1 << 16),
+ PATH_RAY_SINGLE_PASS_DONE = (1 << 17),
+ PATH_RAY_SHADOW_CATCHER = (1 << 18),
+ PATH_RAY_STORE_SHADOW_INFO = (1 << 19),
};
/* Closure Label */
@@ -462,18 +454,42 @@ typedef enum DenoiseFlag {
DENOISING_CLEAN_ALL_PASSES = (1 << 8)-1,
} DenoiseFlag;
+#ifdef __KERNEL_DEBUG__
+/* NOTE: This is a runtime-only struct, alignment is not
+ * really important here.
+ */
+typedef struct DebugData {
+ int num_bvh_traversed_nodes;
+ int num_bvh_traversed_instances;
+ int num_bvh_intersections;
+ int num_ray_bounces;
+} DebugData;
+#endif
+
+typedef ccl_addr_space struct PathRadianceState {
+#ifdef __PASSES__
+ float3 diffuse;
+ float3 glossy;
+ float3 transmission;
+ float3 subsurface;
+ float3 scatter;
+
+ float3 direct;
+#endif
+} PathRadianceState;
+
typedef ccl_addr_space struct PathRadiance {
#ifdef __PASSES__
int use_light_pass;
#endif
+ float transparent;
float3 emission;
#ifdef __PASSES__
float3 background;
float3 ao;
float3 indirect;
- float3 direct_throughput;
float3 direct_emission;
float3 color_diffuse;
@@ -494,16 +510,12 @@ typedef ccl_addr_space struct PathRadiance {
float3 indirect_subsurface;
float3 indirect_scatter;
- float3 path_diffuse;
- float3 path_glossy;
- float3 path_transmission;
- float3 path_subsurface;
- float3 path_scatter;
-
float4 shadow;
float mist;
#endif
+ struct PathRadianceState state;
+
#ifdef __SHADOW_TRICKS__
/* Total light reachable across the path, ignoring shadow blocked queries. */
float3 path_total;
@@ -515,7 +527,18 @@ typedef ccl_addr_space struct PathRadiance {
float3 path_total_shaded;
/* Color of the background on which shadow is alpha-overed. */
- float3 shadow_color;
+ float3 shadow_background_color;
+
+ /* Path radiance sum and throughput at the moment when ray hits shadow
+ * catcher object.
+ */
+ float shadow_throughput;
+
+ /* Accumulated transparency along the path after shadow catcher bounce. */
+ float shadow_transparency;
+
+ /* Indicate if any shadow catcher data is set. */
+ int has_shadow_catcher;
#endif
#ifdef __DENOISING_FEATURES__
@@ -523,6 +546,10 @@ typedef ccl_addr_space struct PathRadiance {
float3 denoising_albedo;
float denoising_depth;
#endif /* __DENOISING_FEATURES__ */
+
+#ifdef __KERNEL_DEBUG__
+ DebugData debug_data;
+#endif /* __KERNEL_DEBUG__ */
} PathRadiance;
typedef struct BsdfEval {
@@ -774,20 +801,6 @@ typedef ccl_addr_space struct ccl_align(16) ShaderClosure {
float data[10]; /* pad to 80 bytes */
} ShaderClosure;
-/* Shader Context
- *
- * For OSL we recycle a fixed number of contexts for speed */
-
-typedef enum ShaderContext {
- SHADER_CONTEXT_MAIN = 0,
- SHADER_CONTEXT_INDIRECT = 1,
- SHADER_CONTEXT_EMISSION = 2,
- SHADER_CONTEXT_SHADOW = 3,
- SHADER_CONTEXT_SSS = 4,
- SHADER_CONTEXT_VOLUME = 5,
- SHADER_CONTEXT_NUM = 6
-} ShaderContext;
-
/* Shader Data
*
* Main shader state at a point on the surface or in a volume. All coordinates
@@ -850,7 +863,7 @@ enum ShaderDataFlag {
SD_VOLUME_MIS = (1 << 23),
/* Use cubic interpolation for voxels. */
SD_VOLUME_CUBIC = (1 << 24),
- /* Has data connected to the displacement input. */
+ /* Has data connected to the displacement input or uses bump map. */
SD_HAS_BUMP = (1 << 25),
/* Has true displacement. */
SD_HAS_DISPLACEMENT = (1 << 26),
@@ -991,9 +1004,11 @@ typedef struct PathState {
int flag;
/* random number generator state */
- int rng_offset; /* dimension offset */
- int sample; /* path sample number */
- int num_samples; /* total number of times this path will be sampled */
+ uint rng_hash; /* per pixel hash */
+ int rng_offset; /* dimension offset */
+ int sample; /* path sample number */
+ int num_samples; /* total number of times this path will be sampled */
+ float branch_factor; /* number of branches in indirect paths */
/* bounce counting */
int bounce;
@@ -1016,20 +1031,15 @@ typedef struct PathState {
/* volume rendering */
#ifdef __VOLUME__
int volume_bounce;
- RNG rng_congruential;
+ uint rng_congruential;
VolumeStack volume_stack[VOLUME_STACK_SIZE];
#endif
-
-#ifdef __SHADOW_TRICKS__
- int catcher_object;
-#endif
} PathState;
/* Subsurface */
/* Struct to gather multiple SSS hits. */
-typedef struct SubsurfaceIntersection
-{
+typedef struct SubsurfaceIntersection {
Ray ray;
float3 weight[BSSRDF_MAX_HITS];
@@ -1039,17 +1049,14 @@ typedef struct SubsurfaceIntersection
} SubsurfaceIntersection;
/* Struct to gather SSS indirect rays and delay tracing them. */
-typedef struct SubsurfaceIndirectRays
-{
- bool need_update_volume_stack;
- bool tracing;
+typedef struct SubsurfaceIndirectRays {
PathState state[BSSRDF_MAX_HITS];
- struct PathRadiance direct_L;
int num_rays;
+
struct Ray rays[BSSRDF_MAX_HITS];
float3 throughputs[BSSRDF_MAX_HITS];
- struct PathRadiance L[BSSRDF_MAX_HITS];
+ struct PathRadianceState L_state[BSSRDF_MAX_HITS];
} SubsurfaceIndirectRays;
/* Constant Kernel Data
@@ -1228,7 +1235,6 @@ typedef struct KernelIntegrator {
int portal_offset;
/* bounces */
- int min_bounce;
int max_bounce;
int max_diffuse_bounce;
@@ -1239,7 +1245,6 @@ typedef struct KernelIntegrator {
int ao_bounces;
/* transparent */
- int transparent_min_bounce;
int transparent_max_bounce;
int transparent_shadows;
@@ -1282,7 +1287,7 @@ typedef struct KernelIntegrator {
float light_inv_rr_threshold;
int start_sample;
- int pad1, pad2, pad3;
+ int pad1;
} KernelIntegrator;
static_assert_align(KernelIntegrator, 16);
@@ -1336,18 +1341,6 @@ typedef struct KernelData {
} KernelData;
static_assert_align(KernelData, 16);
-#ifdef __KERNEL_DEBUG__
-/* NOTE: This is a runtime-only struct, alignment is not
- * really important here.
- */
-typedef ccl_addr_space struct DebugData {
- int num_bvh_traversed_nodes;
- int num_bvh_traversed_instances;
- int num_bvh_intersections;
- int num_ray_bounces;
-} DebugData;
-#endif
-
/* Declarations required for split kernel */
/* Macro for queues */
@@ -1455,6 +1448,20 @@ enum RayState {
#define PATCH_MAP_NODE_IS_LEAF (1u << 31)
#define PATCH_MAP_NODE_INDEX_MASK (~(PATCH_MAP_NODE_IS_SET | PATCH_MAP_NODE_IS_LEAF))
+/* Work Tiles */
+
+typedef struct WorkTile {
+ uint x, y, w, h;
+
+ uint start_sample;
+ uint num_samples;
+
+ uint offset;
+ uint stride;
+
+ ccl_global float *buffer;
+} WorkTile;
+
CCL_NAMESPACE_END
#endif /* __KERNEL_TYPES_H__ */
diff --git a/intern/cycles/kernel/kernel_volume.h b/intern/cycles/kernel/kernel_volume.h
index 1e472aaf51a..d9c310a893e 100644
--- a/intern/cycles/kernel/kernel_volume.h
+++ b/intern/cycles/kernel/kernel_volume.h
@@ -43,7 +43,7 @@ ccl_device_inline bool volume_shader_extinction_sample(KernelGlobals *kg,
float3 *extinction)
{
sd->P = P;
- shader_eval_volume(kg, sd, state, state->volume_stack, PATH_RAY_SHADOW, SHADER_CONTEXT_SHADOW);
+ shader_eval_volume(kg, sd, state, state->volume_stack, PATH_RAY_SHADOW);
if(!(sd->flag & (SD_ABSORPTION|SD_SCATTER)))
return false;
@@ -69,7 +69,7 @@ ccl_device_inline bool volume_shader_sample(KernelGlobals *kg,
VolumeShaderCoefficients *coeff)
{
sd->P = P;
- shader_eval_volume(kg, sd, state, state->volume_stack, state->flag, SHADER_CONTEXT_VOLUME);
+ shader_eval_volume(kg, sd, state, state->volume_stack, state->flag);
if(!(sd->flag & (SD_ABSORPTION|SD_SCATTER|SD_EMISSION)))
return false;
@@ -360,7 +360,6 @@ ccl_device VolumeIntegrateResult kernel_volume_integrate_homogeneous(
ShaderData *sd,
PathRadiance *L,
ccl_addr_space float3 *throughput,
- RNG *rng,
bool probalistic_scatter)
{
VolumeShaderCoefficients coeff;
@@ -380,13 +379,12 @@ ccl_device VolumeIntegrateResult kernel_volume_integrate_homogeneous(
/* pick random color channel, we use the Veach one-sample
* model with balance heuristic for the channels */
- float rphase = path_state_rng_1D_for_decision(kg, rng, state, PRNG_PHASE);
+ float rphase = path_state_rng_1D(kg, state, PRNG_PHASE_CHANNEL);
int channel = (int)(rphase*3.0f);
- sd->randb_closure = rphase*3.0f - channel;
/* decide if we will hit or miss */
bool scatter = true;
- float xi = path_state_rng_1D_for_decision(kg, rng, state, PRNG_SCATTER_DISTANCE);
+ float xi = path_state_rng_1D(kg, state, PRNG_SCATTER_DISTANCE);
if(probalistic_scatter) {
float sample_sigma_t = kernel_volume_channel_get(sigma_t, channel);
@@ -439,7 +437,7 @@ ccl_device VolumeIntegrateResult kernel_volume_integrate_homogeneous(
float3 sigma_t = coeff.sigma_a + coeff.sigma_s;
float3 transmittance = volume_color_transmittance(sigma_t, ray->t);
float3 emission = kernel_volume_emission_integrate(&coeff, closure_flag, transmittance, ray->t);
- path_radiance_accum_emission(L, *throughput, emission, state->bounce);
+ path_radiance_accum_emission(L, state, *throughput, emission);
}
/* modify throughput */
@@ -468,8 +466,7 @@ ccl_device VolumeIntegrateResult kernel_volume_integrate_heterogeneous_distance(
Ray *ray,
ShaderData *sd,
PathRadiance *L,
- ccl_addr_space float3 *throughput,
- RNG *rng)
+ ccl_addr_space float3 *throughput)
{
float3 tp = *throughput;
const float tp_eps = 1e-6f; /* todo: this is likely not the right value */
@@ -485,10 +482,9 @@ ccl_device VolumeIntegrateResult kernel_volume_integrate_heterogeneous_distance(
/* pick random color channel, we use the Veach one-sample
* model with balance heuristic for the channels */
- float xi = path_state_rng_1D_for_decision(kg, rng, state, PRNG_SCATTER_DISTANCE);
- float rphase = path_state_rng_1D_for_decision(kg, rng, state, PRNG_PHASE);
+ float xi = path_state_rng_1D(kg, state, PRNG_SCATTER_DISTANCE);
+ float rphase = path_state_rng_1D(kg, state, PRNG_PHASE_CHANNEL);
int channel = (int)(rphase*3.0f);
- sd->randb_closure = rphase*3.0f - channel;
bool has_scatter = false;
for(int i = 0; i < max_steps; i++) {
@@ -560,7 +556,7 @@ ccl_device VolumeIntegrateResult kernel_volume_integrate_heterogeneous_distance(
/* integrate emission attenuated by absorption */
if(L && (closure_flag & SD_EMISSION)) {
float3 emission = kernel_volume_emission_integrate(&coeff, closure_flag, transmittance, dt);
- path_radiance_accum_emission(L, tp, emission, state->bounce);
+ path_radiance_accum_emission(L, state, tp, emission);
}
/* modify throughput */
@@ -610,15 +606,14 @@ ccl_device_noinline VolumeIntegrateResult kernel_volume_integrate(
Ray *ray,
PathRadiance *L,
ccl_addr_space float3 *throughput,
- RNG *rng,
bool heterogeneous)
{
shader_setup_from_volume(kg, sd, ray);
if(heterogeneous)
- return kernel_volume_integrate_heterogeneous_distance(kg, state, ray, sd, L, throughput, rng);
+ return kernel_volume_integrate_heterogeneous_distance(kg, state, ray, sd, L, throughput);
else
- return kernel_volume_integrate_homogeneous(kg, state, ray, sd, L, throughput, rng, true);
+ return kernel_volume_integrate_homogeneous(kg, state, ray, sd, L, throughput, true);
}
#ifndef __SPLIT_KERNEL__
@@ -846,7 +841,6 @@ ccl_device VolumeIntegrateResult kernel_volume_decoupled_scatter(
/* pick random color channel, we use the Veach one-sample
* model with balance heuristic for the channels */
int channel = (int)(rphase*3.0f);
- sd->randb_closure = rphase*3.0f - channel;
float xi = rscatter;
/* probabilistic scattering decision based on transmittance */
@@ -1000,8 +994,8 @@ ccl_device VolumeIntegrateResult kernel_volume_decoupled_scatter(
mis_weight = 2.0f*power_heuristic(pdf, distance_pdf);
}
}
- if(sample_t < 1e-6f || pdf == 0.0f) {
- return VOLUME_PATH_SCATTERED;
+ if(sample_t < 0.0f || pdf == 0.0f) {
+ return VOLUME_PATH_MISSED;
}
/* compute transmittance up to this step */
diff --git a/intern/cycles/kernel/kernel_work_stealing.h b/intern/cycles/kernel/kernel_work_stealing.h
index 28fc5ce1c30..0c2d9379b63 100644
--- a/intern/cycles/kernel/kernel_work_stealing.h
+++ b/intern/cycles/kernel/kernel_work_stealing.h
@@ -27,90 +27,54 @@ CCL_NAMESPACE_BEGIN
# pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics : enable
#endif
-ccl_device_inline uint kernel_total_work_size(KernelGlobals *kg)
-{
- return kernel_split_params.w * kernel_split_params.h * kernel_split_params.num_samples;
-}
-
-ccl_device_inline uint kernel_num_work_pools(KernelGlobals *kg)
-{
- return ccl_global_size(0) * ccl_global_size(1) / WORK_POOL_SIZE;
-}
-
-ccl_device_inline uint work_pool_from_ray_index(KernelGlobals *kg, uint ray_index)
-{
- return ray_index / WORK_POOL_SIZE;
-}
-
-ccl_device_inline uint work_pool_work_size(KernelGlobals *kg, uint work_pool)
-{
- uint total_work_size = kernel_total_work_size(kg);
- uint num_pools = kernel_num_work_pools(kg);
-
- if(work_pool >= num_pools || work_pool * WORK_POOL_SIZE >= total_work_size) {
- return 0;
- }
-
- uint work_size = (total_work_size / (num_pools * WORK_POOL_SIZE)) * WORK_POOL_SIZE;
-
- uint remainder = (total_work_size % (num_pools * WORK_POOL_SIZE));
- if(work_pool < remainder / WORK_POOL_SIZE) {
- work_size += WORK_POOL_SIZE;
- }
- else if(work_pool == remainder / WORK_POOL_SIZE) {
- work_size += remainder % WORK_POOL_SIZE;
- }
-
- return work_size;
-}
-
-ccl_device_inline uint get_global_work_index(KernelGlobals *kg, uint work_index, uint ray_index)
-{
- uint num_pools = kernel_num_work_pools(kg);
- uint pool = work_pool_from_ray_index(kg, ray_index);
-
- return (work_index / WORK_POOL_SIZE) * (num_pools * WORK_POOL_SIZE)
- + (pool * WORK_POOL_SIZE)
- + (work_index % WORK_POOL_SIZE);
-}
-
+#ifdef __SPLIT_KERNEL__
/* Returns true if there is work */
-ccl_device bool get_next_work(KernelGlobals *kg, ccl_private uint *work_index, uint ray_index)
+ccl_device bool get_next_work(KernelGlobals *kg,
+ ccl_global uint *work_pools,
+ uint total_work_size,
+ uint ray_index,
+ ccl_private uint *global_work_index)
{
- uint work_pool = work_pool_from_ray_index(kg, ray_index);
- uint pool_size = work_pool_work_size(kg, work_pool);
-
- if(pool_size == 0) {
+ /* With a small amount of work there may be more threads than work due to
+ * rounding up of global size, stop such threads immediately. */
+ if(ray_index >= total_work_size) {
return false;
}
- *work_index = atomic_fetch_and_inc_uint32(&kernel_split_params.work_pools[work_pool]);
- return (*work_index < pool_size);
-}
+ /* Increase atomic work index counter in pool. */
+ uint pool = ray_index / WORK_POOL_SIZE;
+ uint work_index = atomic_fetch_and_inc_uint32(&work_pools[pool]);
-/* This function assumes that the passed `work` is valid. */
-/* Decode sample number w.r.t. assigned `work`. */
-ccl_device uint get_work_sample(KernelGlobals *kg, uint work_index, uint ray_index)
-{
- return get_global_work_index(kg, work_index, ray_index) / (kernel_split_params.w * kernel_split_params.h);
-}
+ /* Map per-pool work index to a global work index. */
+ uint global_size = ccl_global_size(0) * ccl_global_size(1);
+ kernel_assert(global_size % WORK_POOL_SIZE == 0);
+ kernel_assert(ray_index < global_size);
-/* Decode pixel and tile position w.r.t. assigned `work`. */
-ccl_device void get_work_pixel_tile_position(KernelGlobals *kg,
- ccl_private uint *pixel_x,
- ccl_private uint *pixel_y,
- ccl_private uint *tile_x,
- ccl_private uint *tile_y,
- uint work_index,
- uint ray_index)
-{
- uint pixel_index = get_global_work_index(kg, work_index, ray_index) % (kernel_split_params.w*kernel_split_params.h);
+ *global_work_index = (work_index / WORK_POOL_SIZE) * global_size
+ + (pool * WORK_POOL_SIZE)
+ + (work_index % WORK_POOL_SIZE);
- *tile_x = pixel_index % kernel_split_params.w;
- *tile_y = pixel_index / kernel_split_params.w;
+ /* Test if all work for this pool is done. */
+ return (*global_work_index < total_work_size);
+}
+#endif
- *pixel_x = *tile_x + kernel_split_params.x;
- *pixel_y = *tile_y + kernel_split_params.y;
+/* Map global work index to tile, pixel X/Y and sample. */
+ccl_device_inline void get_work_pixel(ccl_global const WorkTile *tile,
+ uint global_work_index,
+ ccl_private uint *x,
+ ccl_private uint *y,
+ ccl_private uint *sample)
+{
+ uint tile_pixels = tile->w * tile->h;
+ uint sample_offset = global_work_index / tile_pixels;
+ uint pixel_offset = global_work_index - sample_offset * tile_pixels;
+ uint y_offset = pixel_offset / tile->w;
+ uint x_offset = pixel_offset - y_offset * tile->w;
+
+ *x = tile->x + x_offset;
+ *y = tile->y + y_offset;
+ *sample = tile->start_sample + sample_offset;
}
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/kernels/cpu/filter_cpu.h b/intern/cycles/kernel/kernels/cpu/filter_cpu.h
index 2ed713299fd..bf13ba62806 100644
--- a/intern/cycles/kernel/kernels/cpu/filter_cpu.h
+++ b/intern/cycles/kernel/kernels/cpu/filter_cpu.h
@@ -27,8 +27,7 @@ void KERNEL_FUNCTION_FULL_NAME(filter_divide_shadow)(int sample,
float *bufferV,
int* prefilter_rect,
int buffer_pass_stride,
- int buffer_denoising_offset,
- bool use_split_variance);
+ int buffer_denoising_offset);
void KERNEL_FUNCTION_FULL_NAME(filter_get_feature)(int sample,
TilesInfo *tiles,
@@ -40,8 +39,7 @@ void KERNEL_FUNCTION_FULL_NAME(filter_get_feature)(int sample,
float *variance,
int* prefilter_rect,
int buffer_pass_stride,
- int buffer_denoising_offset,
- bool use_split_variance);
+ int buffer_denoising_offset);
void KERNEL_FUNCTION_FULL_NAME(filter_detect_outliers)(int x, int y,
ccl_global float *image,
diff --git a/intern/cycles/kernel/kernels/cpu/filter_cpu_impl.h b/intern/cycles/kernel/kernels/cpu/filter_cpu_impl.h
index 8dc1a8d583c..2fbb0ea2bdb 100644
--- a/intern/cycles/kernel/kernels/cpu/filter_cpu_impl.h
+++ b/intern/cycles/kernel/kernels/cpu/filter_cpu_impl.h
@@ -45,8 +45,7 @@ void KERNEL_FUNCTION_FULL_NAME(filter_divide_shadow)(int sample,
float *bufferVariance,
int* prefilter_rect,
int buffer_pass_stride,
- int buffer_denoising_offset,
- bool use_split_variance)
+ int buffer_denoising_offset)
{
#ifdef KERNEL_STUB
STUB_ASSERT(KERNEL_ARCH, filter_divide_shadow);
@@ -60,8 +59,7 @@ void KERNEL_FUNCTION_FULL_NAME(filter_divide_shadow)(int sample,
bufferVariance,
load_int4(prefilter_rect),
buffer_pass_stride,
- buffer_denoising_offset,
- use_split_variance);
+ buffer_denoising_offset);
#endif
}
@@ -74,8 +72,7 @@ void KERNEL_FUNCTION_FULL_NAME(filter_get_feature)(int sample,
float *mean, float *variance,
int* prefilter_rect,
int buffer_pass_stride,
- int buffer_denoising_offset,
- bool use_split_variance)
+ int buffer_denoising_offset)
{
#ifdef KERNEL_STUB
STUB_ASSERT(KERNEL_ARCH, filter_get_feature);
@@ -86,8 +83,7 @@ void KERNEL_FUNCTION_FULL_NAME(filter_get_feature)(int sample,
mean, variance,
load_int4(prefilter_rect),
buffer_pass_stride,
- buffer_denoising_offset,
- use_split_variance);
+ buffer_denoising_offset);
#endif
}
diff --git a/intern/cycles/kernel/kernels/cpu/filter_sse41.cpp b/intern/cycles/kernel/kernels/cpu/filter_sse41.cpp
index 1a7b2040da1..254025be4e2 100644
--- a/intern/cycles/kernel/kernels/cpu/filter_sse41.cpp
+++ b/intern/cycles/kernel/kernels/cpu/filter_sse41.cpp
@@ -25,6 +25,7 @@
#else
/* SSE optimization disabled for now on 32 bit, see bug #36316 */
# if !(defined(__GNUC__) && (defined(i386) || defined(_M_IX86)))
+# define __KERNEL_SSE__
# define __KERNEL_SSE2__
# define __KERNEL_SSE3__
# define __KERNEL_SSSE3__
diff --git a/intern/cycles/kernel/kernels/cpu/kernel_cpu.h b/intern/cycles/kernel/kernels/cpu/kernel_cpu.h
index c8938534fe8..6bdb8546a24 100644
--- a/intern/cycles/kernel/kernels/cpu/kernel_cpu.h
+++ b/intern/cycles/kernel/kernels/cpu/kernel_cpu.h
@@ -18,7 +18,6 @@
void KERNEL_FUNCTION_FULL_NAME(path_trace)(KernelGlobals *kg,
float *buffer,
- unsigned int *rng_state,
int sample,
int x, int y,
int offset,
@@ -42,7 +41,6 @@ void KERNEL_FUNCTION_FULL_NAME(convert_to_half_float)(KernelGlobals *kg,
void KERNEL_FUNCTION_FULL_NAME(shader)(KernelGlobals *kg,
uint4 *input,
float4 *output,
- float *output_luma,
int type,
int filter,
int i,
@@ -57,7 +55,6 @@ void KERNEL_FUNCTION_FULL_NAME(data_init)(
ccl_global void *split_data_buffer,
int num_elements,
ccl_global char *ray_state,
- ccl_global uint *rng_state,
int start_sample,
int end_sample,
int sx, int sy, int sw, int sh, int offset, int stride,
diff --git a/intern/cycles/kernel/kernels/cpu/kernel_cpu_impl.h b/intern/cycles/kernel/kernels/cpu/kernel_cpu_impl.h
index d4315ee5ec4..fdeb7dcd3e4 100644
--- a/intern/cycles/kernel/kernels/cpu/kernel_cpu_impl.h
+++ b/intern/cycles/kernel/kernels/cpu/kernel_cpu_impl.h
@@ -75,7 +75,6 @@ CCL_NAMESPACE_BEGIN
void KERNEL_FUNCTION_FULL_NAME(path_trace)(KernelGlobals *kg,
float *buffer,
- unsigned int *rng_state,
int sample,
int x, int y,
int offset,
@@ -88,7 +87,6 @@ void KERNEL_FUNCTION_FULL_NAME(path_trace)(KernelGlobals *kg,
if(kernel_data.integrator.branched) {
kernel_branched_path_trace(kg,
buffer,
- rng_state,
sample,
x, y,
offset,
@@ -97,7 +95,7 @@ void KERNEL_FUNCTION_FULL_NAME(path_trace)(KernelGlobals *kg,
else
# endif
{
- kernel_path_trace(kg, buffer, rng_state, sample, x, y, offset, stride);
+ kernel_path_trace(kg, buffer, sample, x, y, offset, stride);
}
#endif /* KERNEL_STUB */
}
@@ -151,7 +149,6 @@ void KERNEL_FUNCTION_FULL_NAME(convert_to_half_float)(KernelGlobals *kg,
void KERNEL_FUNCTION_FULL_NAME(shader)(KernelGlobals *kg,
uint4 *input,
float4 *output,
- float *output_luma,
int type,
int filter,
int i,
@@ -162,7 +159,6 @@ void KERNEL_FUNCTION_FULL_NAME(shader)(KernelGlobals *kg,
STUB_ASSERT(KERNEL_ARCH, shader);
#else
if(type >= SHADER_EVAL_BAKE) {
- kernel_assert(output_luma == NULL);
# ifdef __BAKING__
kernel_bake_evaluate(kg,
input,
@@ -174,14 +170,11 @@ void KERNEL_FUNCTION_FULL_NAME(shader)(KernelGlobals *kg,
sample);
# endif
}
+ else if(type == SHADER_EVAL_DISPLACE) {
+ kernel_displace_evaluate(kg, input, output, i);
+ }
else {
- kernel_shader_evaluate(kg,
- input,
- output,
- output_luma,
- (ShaderEvalType)type,
- i,
- sample);
+ kernel_background_evaluate(kg, input, output, i);
}
#endif /* KERNEL_STUB */
}
diff --git a/intern/cycles/kernel/kernels/cuda/filter.cu b/intern/cycles/kernel/kernels/cuda/filter.cu
index 009c3fde9d5..c8172355a7f 100644
--- a/intern/cycles/kernel/kernels/cuda/filter.cu
+++ b/intern/cycles/kernel/kernels/cuda/filter.cu
@@ -37,8 +37,7 @@ kernel_cuda_filter_divide_shadow(int sample,
float *bufferVariance,
int4 prefilter_rect,
int buffer_pass_stride,
- int buffer_denoising_offset,
- bool use_split_variance)
+ int buffer_denoising_offset)
{
int x = prefilter_rect.x + blockDim.x*blockIdx.x + threadIdx.x;
int y = prefilter_rect.y + blockDim.y*blockIdx.y + threadIdx.y;
@@ -53,8 +52,7 @@ kernel_cuda_filter_divide_shadow(int sample,
bufferVariance,
prefilter_rect,
buffer_pass_stride,
- buffer_denoising_offset,
- use_split_variance);
+ buffer_denoising_offset);
}
}
@@ -68,8 +66,7 @@ kernel_cuda_filter_get_feature(int sample,
float *variance,
int4 prefilter_rect,
int buffer_pass_stride,
- int buffer_denoising_offset,
- bool use_split_variance)
+ int buffer_denoising_offset)
{
int x = prefilter_rect.x + blockDim.x*blockIdx.x + threadIdx.x;
int y = prefilter_rect.y + blockDim.y*blockIdx.y + threadIdx.y;
@@ -81,8 +78,7 @@ kernel_cuda_filter_get_feature(int sample,
mean, variance,
prefilter_rect,
buffer_pass_stride,
- buffer_denoising_offset,
- use_split_variance);
+ buffer_denoising_offset);
}
}
diff --git a/intern/cycles/kernel/kernels/cuda/kernel.cu b/intern/cycles/kernel/kernels/cuda/kernel.cu
index dc343cb387a..1ac6afd167a 100644
--- a/intern/cycles/kernel/kernels/cuda/kernel.cu
+++ b/intern/cycles/kernel/kernels/cuda/kernel.cu
@@ -20,6 +20,9 @@
#include "kernel/kernel_compat_cuda.h"
#include "kernel_config.h"
+
+#include "util/util_atomic.h"
+
#include "kernel/kernel_math.h"
#include "kernel/kernel_types.h"
#include "kernel/kernel_globals.h"
@@ -27,32 +30,37 @@
#include "kernel/kernel_path.h"
#include "kernel/kernel_path_branched.h"
#include "kernel/kernel_bake.h"
+#include "kernel/kernel_work_stealing.h"
/* kernels */
extern "C" __global__ void
CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_MAX_REGISTERS)
-kernel_cuda_path_trace(float *buffer, uint *rng_state, int sample, int sx, int sy, int sw, int sh, int offset, int stride)
+kernel_cuda_path_trace(WorkTile *tile, uint total_work_size)
{
- int x = sx + blockDim.x*blockIdx.x + threadIdx.x;
- int y = sy + blockDim.y*blockIdx.y + threadIdx.y;
+ int work_index = ccl_global_id(0);
+
+ if(work_index < total_work_size) {
+ uint x, y, sample;
+ get_work_pixel(tile, work_index, &x, &y, &sample);
- if(x < sx + sw && y < sy + sh) {
KernelGlobals kg;
- kernel_path_trace(&kg, buffer, rng_state, sample, x, y, offset, stride);
+ kernel_path_trace(&kg, tile->buffer, sample, x, y, tile->offset, tile->stride);
}
}
#ifdef __BRANCHED_PATH__
extern "C" __global__ void
CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_BRANCHED_MAX_REGISTERS)
-kernel_cuda_branched_path_trace(float *buffer, uint *rng_state, int sample, int sx, int sy, int sw, int sh, int offset, int stride)
+kernel_cuda_branched_path_trace(WorkTile *tile, uint total_work_size)
{
- int x = sx + blockDim.x*blockIdx.x + threadIdx.x;
- int y = sy + blockDim.y*blockIdx.y + threadIdx.y;
+ int work_index = ccl_global_id(0);
+
+ if(work_index < total_work_size) {
+ uint x, y, sample;
+ get_work_pixel(tile, work_index, &x, &y, &sample);
- if(x < sx + sw && y < sy + sh) {
KernelGlobals kg;
- kernel_branched_path_trace(&kg, buffer, rng_state, sample, x, y, offset, stride);
+ kernel_branched_path_trace(&kg, tile->buffer, sample, x, y, tile->offset, tile->stride);
}
}
#endif
@@ -83,26 +91,37 @@ kernel_cuda_convert_to_half_float(uchar4 *rgba, float *buffer, float sample_scal
extern "C" __global__ void
CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_MAX_REGISTERS)
-kernel_cuda_shader(uint4 *input,
- float4 *output,
- float *output_luma,
- int type,
- int sx,
- int sw,
- int offset,
- int sample)
+kernel_cuda_displace(uint4 *input,
+ float4 *output,
+ int type,
+ int sx,
+ int sw,
+ int offset,
+ int sample)
+{
+ int x = sx + blockDim.x*blockIdx.x + threadIdx.x;
+
+ if(x < sx + sw) {
+ KernelGlobals kg;
+ kernel_displace_evaluate(&kg, input, output, x);
+ }
+}
+
+extern "C" __global__ void
+CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_MAX_REGISTERS)
+kernel_cuda_background(uint4 *input,
+ float4 *output,
+ int type,
+ int sx,
+ int sw,
+ int offset,
+ int sample)
{
int x = sx + blockDim.x*blockIdx.x + threadIdx.x;
if(x < sx + sw) {
KernelGlobals kg;
- kernel_shader_evaluate(&kg,
- input,
- output,
- output_luma,
- (ShaderEvalType)type,
- x,
- sample);
+ kernel_background_evaluate(&kg, input, output, x);
}
}
diff --git a/intern/cycles/kernel/kernels/cuda/kernel_config.h b/intern/cycles/kernel/kernels/cuda/kernel_config.h
index 9fa39dc9ebb..7ae205b7e14 100644
--- a/intern/cycles/kernel/kernels/cuda/kernel_config.h
+++ b/intern/cycles/kernel/kernels/cuda/kernel_config.h
@@ -81,8 +81,13 @@
# error "Unknown or unsupported CUDA architecture, can't determine launch bounds"
#endif
-/* compute number of threads per block and minimum blocks per multiprocessor
- * given the maximum number of registers per thread */
+/* For split kernel using all registers seems fastest for now, but this
+ * is unlikely to be optimal once we resolve other bottlenecks. */
+
+#define CUDA_KERNEL_SPLIT_MAX_REGISTERS CUDA_THREAD_MAX_REGISTERS
+
+/* Compute number of threads per block and minimum blocks per multiprocessor
+ * given the maximum number of registers per thread. */
#define CUDA_LAUNCH_BOUNDS(threads_block_width, thread_num_registers) \
__launch_bounds__( \
diff --git a/intern/cycles/kernel/kernels/cuda/kernel_split.cu b/intern/cycles/kernel/kernels/cuda/kernel_split.cu
index 628891b1458..43b3d0aa0e6 100644
--- a/intern/cycles/kernel/kernels/cuda/kernel_split.cu
+++ b/intern/cycles/kernel/kernels/cuda/kernel_split.cu
@@ -60,7 +60,6 @@ kernel_cuda_path_trace_data_init(
ccl_global void *split_data_buffer,
int num_elements,
ccl_global char *ray_state,
- ccl_global uint *rng_state,
int start_sample,
int end_sample,
int sx, int sy, int sw, int sh, int offset, int stride,
@@ -76,7 +75,6 @@ kernel_cuda_path_trace_data_init(
split_data_buffer,
num_elements,
ray_state,
- rng_state,
start_sample,
end_sample,
sx, sy, sw, sh, offset, stride,
@@ -90,7 +88,7 @@ kernel_cuda_path_trace_data_init(
#define DEFINE_SPLIT_KERNEL_FUNCTION(name) \
extern "C" __global__ void \
- CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_MAX_REGISTERS) \
+ CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_SPLIT_MAX_REGISTERS) \
kernel_cuda_##name() \
{ \
kernel_##name(NULL); \
@@ -98,7 +96,7 @@ kernel_cuda_path_trace_data_init(
#define DEFINE_SPLIT_KERNEL_FUNCTION_LOCALS(name, type) \
extern "C" __global__ void \
- CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_MAX_REGISTERS) \
+ CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_SPLIT_MAX_REGISTERS) \
kernel_cuda_##name() \
{ \
ccl_local type locals; \
diff --git a/intern/cycles/kernel/kernels/opencl/filter.cl b/intern/cycles/kernel/kernels/opencl/filter.cl
index ba53ba4b26f..7a7b596a350 100644
--- a/intern/cycles/kernel/kernels/opencl/filter.cl
+++ b/intern/cycles/kernel/kernels/opencl/filter.cl
@@ -31,8 +31,7 @@ __kernel void kernel_ocl_filter_divide_shadow(int sample,
ccl_global float *bufferVariance,
int4 prefilter_rect,
int buffer_pass_stride,
- int buffer_denoising_offset,
- char use_split_variance)
+ int buffer_denoising_offset)
{
int x = prefilter_rect.x + get_global_id(0);
int y = prefilter_rect.y + get_global_id(1);
@@ -47,8 +46,7 @@ __kernel void kernel_ocl_filter_divide_shadow(int sample,
bufferVariance,
prefilter_rect,
buffer_pass_stride,
- buffer_denoising_offset,
- use_split_variance);
+ buffer_denoising_offset);
}
}
@@ -60,8 +58,7 @@ __kernel void kernel_ocl_filter_get_feature(int sample,
ccl_global float *variance,
int4 prefilter_rect,
int buffer_pass_stride,
- int buffer_denoising_offset,
- char use_split_variance)
+ int buffer_denoising_offset)
{
int x = prefilter_rect.x + get_global_id(0);
int y = prefilter_rect.y + get_global_id(1);
@@ -73,8 +70,7 @@ __kernel void kernel_ocl_filter_get_feature(int sample,
mean, variance,
prefilter_rect,
buffer_pass_stride,
- buffer_denoising_offset,
- use_split_variance);
+ buffer_denoising_offset);
}
}
@@ -235,7 +231,7 @@ __kernel void kernel_ocl_filter_nlm_construct_gramian(int dx,
}
__kernel void kernel_ocl_filter_finalize(int w,
- int h,
+ int h,
ccl_global float *buffer,
ccl_global int *rank,
ccl_global float *XtWX,
diff --git a/intern/cycles/kernel/kernels/opencl/kernel.cl b/intern/cycles/kernel/kernels/opencl/kernel.cl
index 078acc1631e..66b6e19de84 100644
--- a/intern/cycles/kernel/kernels/opencl/kernel.cl
+++ b/intern/cycles/kernel/kernels/opencl/kernel.cl
@@ -50,11 +50,8 @@
__kernel void kernel_ocl_path_trace(
ccl_constant KernelData *data,
ccl_global float *buffer,
- ccl_global uint *rng_state,
-#define KERNEL_TEX(type, ttype, name) \
- ccl_global type *name,
-#include "kernel/kernel_textures.h"
+ KERNEL_BUFFER_PARAMS,
int sample,
int sx, int sy, int sw, int sh, int offset, int stride)
@@ -63,28 +60,24 @@ __kernel void kernel_ocl_path_trace(
kg->data = data;
-#define KERNEL_TEX(type, ttype, name) \
- kg->name = name;
-#include "kernel/kernel_textures.h"
+ kernel_set_buffer_pointers(kg, KERNEL_BUFFER_ARGS);
+ kernel_set_buffer_info(kg);
int x = sx + ccl_global_id(0);
int y = sy + ccl_global_id(1);
if(x < sx + sw && y < sy + sh)
- kernel_path_trace(kg, buffer, rng_state, sample, x, y, offset, stride);
+ kernel_path_trace(kg, buffer, sample, x, y, offset, stride);
}
#else /* __COMPILE_ONLY_MEGAKERNEL__ */
-__kernel void kernel_ocl_shader(
+__kernel void kernel_ocl_displace(
ccl_constant KernelData *data,
ccl_global uint4 *input,
ccl_global float4 *output,
- ccl_global float *output_luma,
-#define KERNEL_TEX(type, ttype, name) \
- ccl_global type *name,
-#include "kernel/kernel_textures.h"
+ KERNEL_BUFFER_PARAMS,
int type, int sx, int sw, int offset, int sample)
{
@@ -92,20 +85,35 @@ __kernel void kernel_ocl_shader(
kg->data = data;
-#define KERNEL_TEX(type, ttype, name) \
- kg->name = name;
-#include "kernel/kernel_textures.h"
+ kernel_set_buffer_pointers(kg, KERNEL_BUFFER_ARGS);
+ kernel_set_buffer_info(kg);
int x = sx + ccl_global_id(0);
if(x < sx + sw) {
- kernel_shader_evaluate(kg,
- input,
- output,
- output_luma,
- (ShaderEvalType)type,
- x,
- sample);
+ kernel_displace_evaluate(kg, input, output, x);
+ }
+}
+__kernel void kernel_ocl_background(
+ ccl_constant KernelData *data,
+ ccl_global uint4 *input,
+ ccl_global float4 *output,
+
+ KERNEL_BUFFER_PARAMS,
+
+ int type, int sx, int sw, int offset, int sample)
+{
+ KernelGlobals kglobals, *kg = &kglobals;
+
+ kg->data = data;
+
+ kernel_set_buffer_pointers(kg, KERNEL_BUFFER_ARGS);
+ kernel_set_buffer_info(kg);
+
+ int x = sx + ccl_global_id(0);
+
+ if(x < sx + sw) {
+ kernel_background_evaluate(kg, input, output, x);
}
}
@@ -114,9 +122,7 @@ __kernel void kernel_ocl_bake(
ccl_global uint4 *input,
ccl_global float4 *output,
-#define KERNEL_TEX(type, ttype, name) \
- ccl_global type *name,
-#include "kernel/kernel_textures.h"
+ KERNEL_BUFFER_PARAMS,
int type, int filter, int sx, int sw, int offset, int sample)
{
@@ -124,9 +130,8 @@ __kernel void kernel_ocl_bake(
kg->data = data;
-#define KERNEL_TEX(type, ttype, name) \
- kg->name = name;
-#include "kernel/kernel_textures.h"
+ kernel_set_buffer_pointers(kg, KERNEL_BUFFER_ARGS);
+ kernel_set_buffer_info(kg);
int x = sx + ccl_global_id(0);
@@ -144,9 +149,7 @@ __kernel void kernel_ocl_convert_to_byte(
ccl_global uchar4 *rgba,
ccl_global float *buffer,
-#define KERNEL_TEX(type, ttype, name) \
- ccl_global type *name,
-#include "kernel/kernel_textures.h"
+ KERNEL_BUFFER_PARAMS,
float sample_scale,
int sx, int sy, int sw, int sh, int offset, int stride)
@@ -155,9 +158,8 @@ __kernel void kernel_ocl_convert_to_byte(
kg->data = data;
-#define KERNEL_TEX(type, ttype, name) \
- kg->name = name;
-#include "kernel/kernel_textures.h"
+ kernel_set_buffer_pointers(kg, KERNEL_BUFFER_ARGS);
+ kernel_set_buffer_info(kg);
int x = sx + ccl_global_id(0);
int y = sy + ccl_global_id(1);
@@ -171,9 +173,7 @@ __kernel void kernel_ocl_convert_to_half_float(
ccl_global uchar4 *rgba,
ccl_global float *buffer,
-#define KERNEL_TEX(type, ttype, name) \
- ccl_global type *name,
-#include "kernel/kernel_textures.h"
+ KERNEL_BUFFER_PARAMS,
float sample_scale,
int sx, int sy, int sw, int sh, int offset, int stride)
@@ -182,9 +182,8 @@ __kernel void kernel_ocl_convert_to_half_float(
kg->data = data;
-#define KERNEL_TEX(type, ttype, name) \
- kg->name = name;
-#include "kernel/kernel_textures.h"
+ kernel_set_buffer_pointers(kg, KERNEL_BUFFER_ARGS);
+ kernel_set_buffer_info(kg);
int x = sx + ccl_global_id(0);
int y = sy + ccl_global_id(1);
@@ -193,7 +192,7 @@ __kernel void kernel_ocl_convert_to_half_float(
kernel_film_convert_to_half_float(kg, rgba, buffer, sample_scale, x, y, offset, stride);
}
-__kernel void kernel_ocl_zero_buffer(ccl_global float4 *buffer, ulong size, ulong offset)
+__kernel void kernel_ocl_zero_buffer(ccl_global float4 *buffer, uint64_t size, uint64_t offset)
{
size_t i = ccl_global_id(0) + ccl_global_id(1) * ccl_global_size(0);
diff --git a/intern/cycles/kernel/kernels/opencl/kernel_data_init.cl b/intern/cycles/kernel/kernels/opencl/kernel_data_init.cl
index 8b85d362f8a..7125348a49f 100644
--- a/intern/cycles/kernel/kernels/opencl/kernel_data_init.cl
+++ b/intern/cycles/kernel/kernels/opencl/kernel_data_init.cl
@@ -24,12 +24,7 @@ __kernel void kernel_ocl_path_trace_data_init(
ccl_global void *split_data_buffer,
int num_elements,
ccl_global char *ray_state,
- ccl_global uint *rng_state,
-
-#define KERNEL_TEX(type, ttype, name) \
- ccl_global type *name,
-#include "kernel/kernel_textures.h"
-
+ KERNEL_BUFFER_PARAMS,
int start_sample,
int end_sample,
int sx, int sy, int sw, int sh, int offset, int stride,
@@ -45,11 +40,7 @@ __kernel void kernel_ocl_path_trace_data_init(
split_data_buffer,
num_elements,
ray_state,
- rng_state,
-
-#define KERNEL_TEX(type, ttype, name) name,
-#include "kernel/kernel_textures.h"
-
+ KERNEL_BUFFER_ARGS,
start_sample,
end_sample,
sx, sy, sw, sh, offset, stride,
diff --git a/intern/cycles/kernel/kernels/opencl/kernel_split.cl b/intern/cycles/kernel/kernels/opencl/kernel_split.cl
index 651addb02f4..4cbda1bc2e7 100644
--- a/intern/cycles/kernel/kernels/opencl/kernel_split.cl
+++ b/intern/cycles/kernel/kernels/opencl/kernel_split.cl
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+#include "kernel/kernel_compat_opencl.h" // PRECOMPILED
+#include "kernel/split/kernel_split_common.h" // PRECOMPILED
+
#include "kernel/kernels/opencl/kernel_state_buffer_size.cl"
#include "kernel/kernels/opencl/kernel_data_init.cl"
#include "kernel/kernels/opencl/kernel_path_init.cl"
diff --git a/intern/cycles/kernel/kernels/opencl/kernel_split_function.h b/intern/cycles/kernel/kernels/opencl/kernel_split_function.h
index f1e914a70d4..6aa7681cbed 100644
--- a/intern/cycles/kernel/kernels/opencl/kernel_split_function.h
+++ b/intern/cycles/kernel/kernels/opencl/kernel_split_function.h
@@ -23,11 +23,8 @@ __kernel void KERNEL_NAME_EVAL(kernel_ocl_path_trace, KERNEL_NAME)(
ccl_global void *split_data_buffer,
ccl_global char *ray_state,
- ccl_global uint *rng_state,
-#define KERNEL_TEX(type, ttype, name) \
- ccl_global type *name,
-#include "kernel/kernel_textures.h"
+ KERNEL_BUFFER_PARAMS,
ccl_global int *queue_index,
ccl_global char *use_queues_flag,
@@ -44,20 +41,16 @@ __kernel void KERNEL_NAME_EVAL(kernel_ocl_path_trace, KERNEL_NAME)(
if(ccl_local_id(0) + ccl_local_id(1) == 0) {
kg->data = data;
- kernel_split_params.rng_state = rng_state;
kernel_split_params.queue_index = queue_index;
kernel_split_params.use_queues_flag = use_queues_flag;
kernel_split_params.work_pools = work_pools;
- kernel_split_params.buffer = buffer;
+ kernel_split_params.tile.buffer = buffer;
split_data_init(kg, &kernel_split_state, ccl_global_size(0)*ccl_global_size(1), split_data_buffer, ray_state);
-#define KERNEL_TEX(type, ttype, name) \
- kg->name = name;
-#include "kernel/kernel_textures.h"
}
- ccl_barrier(CCL_LOCAL_MEM_FENCE);
+ kernel_set_buffer_pointers(kg, KERNEL_BUFFER_ARGS);
KERNEL_NAME_EVAL(kernel, KERNEL_NAME)(
kg
diff --git a/intern/cycles/kernel/osl/osl_closures.cpp b/intern/cycles/kernel/osl/osl_closures.cpp
index 2f0897434ec..14c5c1c3db5 100644
--- a/intern/cycles/kernel/osl/osl_closures.cpp
+++ b/intern/cycles/kernel/osl/osl_closures.cpp
@@ -156,7 +156,7 @@ BSDF_CLOSURE_CLASS_BEGIN(MicrofacetBeckmannRefraction, microfacet_beckmann_refra
BSDF_CLOSURE_CLASS_END(MicrofacetBeckmannRefraction, microfacet_beckmann_refraction)
BSDF_CLOSURE_CLASS_BEGIN(HairReflection, hair_reflection, HairBsdf, LABEL_GLOSSY)
- CLOSURE_FLOAT3_PARAM(HairReflectionClosure, unused),
+ CLOSURE_FLOAT3_PARAM(HairReflectionClosure, params.N),
CLOSURE_FLOAT_PARAM(HairReflectionClosure, params.roughness1),
CLOSURE_FLOAT_PARAM(HairReflectionClosure, params.roughness2),
CLOSURE_FLOAT3_PARAM(HairReflectionClosure, params.T),
@@ -164,7 +164,7 @@ BSDF_CLOSURE_CLASS_BEGIN(HairReflection, hair_reflection, HairBsdf, LABEL_GLOSSY
BSDF_CLOSURE_CLASS_END(HairReflection, hair_reflection)
BSDF_CLOSURE_CLASS_BEGIN(HairTransmission, hair_transmission, HairBsdf, LABEL_GLOSSY)
- CLOSURE_FLOAT3_PARAM(HairTransmissionClosure, unused),
+ CLOSURE_FLOAT3_PARAM(HairTransmissionClosure, params.N),
CLOSURE_FLOAT_PARAM(HairTransmissionClosure, params.roughness1),
CLOSURE_FLOAT_PARAM(HairTransmissionClosure, params.roughness2),
CLOSURE_FLOAT3_PARAM(HairReflectionClosure, params.T),
diff --git a/intern/cycles/kernel/osl/osl_globals.h b/intern/cycles/kernel/osl/osl_globals.h
index 02c083a83f8..9585d9f4825 100644
--- a/intern/cycles/kernel/osl/osl_globals.h
+++ b/intern/cycles/kernel/osl/osl_globals.h
@@ -86,7 +86,7 @@ struct OSLThreadData {
OSL::ShaderGlobals globals;
OSL::PerThreadInfo *osl_thread_info;
OSLTraceData tracedata;
- OSL::ShadingContext *context[SHADER_CONTEXT_NUM];
+ OSL::ShadingContext *context;
OIIO::TextureSystem::Perthread *oiio_thread_info;
};
diff --git a/intern/cycles/kernel/osl/osl_services.cpp b/intern/cycles/kernel/osl/osl_services.cpp
index b767c60c617..8ad2e12b067 100644
--- a/intern/cycles/kernel/osl/osl_services.cpp
+++ b/intern/cycles/kernel/osl/osl_services.cpp
@@ -824,7 +824,7 @@ bool OSLRenderServices::get_background_attribute(KernelGlobals *kg, ShaderData *
bool OSLRenderServices::get_attribute(OSL::ShaderGlobals *sg, bool derivatives, ustring object_name,
TypeDesc type, ustring name, void *val)
{
- if(sg->renderstate == NULL)
+ if(sg == NULL || sg->renderstate == NULL)
return false;
ShaderData *sd = (ShaderData *)(sg->renderstate);
@@ -1197,8 +1197,9 @@ bool OSLRenderServices::trace(TraceOpt &options, OSL::ShaderGlobals *sg,
tracedata->init = true;
tracedata->sd.osl_globals = sd->osl_globals;
- /* raytrace */
- return scene_intersect(sd->osl_globals, ray, PATH_RAY_ALL_VISIBILITY, &tracedata->isect, NULL, 0.0f, 0.0f);
+ /* Raytrace, leaving out shadow opaque to avoid early exit. */
+ uint visibility = PATH_RAY_ALL_VISIBILITY - PATH_RAY_SHADOW_OPAQUE;
+ return scene_intersect(sd->osl_globals, ray, visibility, &tracedata->isect, NULL, 0.0f, 0.0f);
}
diff --git a/intern/cycles/kernel/osl/osl_shader.cpp b/intern/cycles/kernel/osl/osl_shader.cpp
index 13b19d86eca..6b3a996ca12 100644
--- a/intern/cycles/kernel/osl/osl_shader.cpp
+++ b/intern/cycles/kernel/osl/osl_shader.cpp
@@ -57,9 +57,7 @@ void OSLShader::thread_init(KernelGlobals *kg, KernelGlobals *kernel_globals, OS
tdata->globals.tracedata = &tdata->tracedata;
tdata->globals.flipHandedness = false;
tdata->osl_thread_info = ss->create_thread_info();
-
- for(int i = 0; i < SHADER_CONTEXT_NUM; i++)
- tdata->context[i] = ss->get_context(tdata->osl_thread_info);
+ tdata->context = ss->get_context(tdata->osl_thread_info);
tdata->oiio_thread_info = osl_globals->ts->get_perthread_info();
@@ -74,9 +72,7 @@ void OSLShader::thread_free(KernelGlobals *kg)
OSL::ShadingSystem *ss = (OSL::ShadingSystem*)kg->osl_ss;
OSLThreadData *tdata = kg->osl_tdata;
-
- for(int i = 0; i < SHADER_CONTEXT_NUM; i++)
- ss->release_context(tdata->context[i]);
+ ss->release_context(tdata->context);
ss->destroy_thread_info(tdata->osl_thread_info);
@@ -173,7 +169,7 @@ static void flatten_surface_closure_tree(ShaderData *sd,
}
}
-void OSLShader::eval_surface(KernelGlobals *kg, ShaderData *sd, PathState *state, int path_flag, ShaderContext ctx)
+void OSLShader::eval_surface(KernelGlobals *kg, ShaderData *sd, PathState *state, int path_flag)
{
/* setup shader globals from shader data */
OSLThreadData *tdata = kg->osl_tdata;
@@ -182,7 +178,7 @@ void OSLShader::eval_surface(KernelGlobals *kg, ShaderData *sd, PathState *state
/* execute shader for this point */
OSL::ShadingSystem *ss = (OSL::ShadingSystem*)kg->osl_ss;
OSL::ShaderGlobals *globals = &tdata->globals;
- OSL::ShadingContext *octx = tdata->context[(int)ctx];
+ OSL::ShadingContext *octx = tdata->context;
int shader = sd->shader & SHADER_MASK;
/* automatic bump shader */
@@ -274,7 +270,7 @@ static void flatten_background_closure_tree(ShaderData *sd,
}
}
-void OSLShader::eval_background(KernelGlobals *kg, ShaderData *sd, PathState *state, int path_flag, ShaderContext ctx)
+void OSLShader::eval_background(KernelGlobals *kg, ShaderData *sd, PathState *state, int path_flag)
{
/* setup shader globals from shader data */
OSLThreadData *tdata = kg->osl_tdata;
@@ -283,7 +279,7 @@ void OSLShader::eval_background(KernelGlobals *kg, ShaderData *sd, PathState *st
/* execute shader for this point */
OSL::ShadingSystem *ss = (OSL::ShadingSystem*)kg->osl_ss;
OSL::ShaderGlobals *globals = &tdata->globals;
- OSL::ShadingContext *octx = tdata->context[(int)ctx];
+ OSL::ShadingContext *octx = tdata->context;
if(kg->osl->background_state) {
ss->execute(octx, *(kg->osl->background_state), *globals);
@@ -329,7 +325,7 @@ static void flatten_volume_closure_tree(ShaderData *sd,
}
}
-void OSLShader::eval_volume(KernelGlobals *kg, ShaderData *sd, PathState *state, int path_flag, ShaderContext ctx)
+void OSLShader::eval_volume(KernelGlobals *kg, ShaderData *sd, PathState *state, int path_flag)
{
/* setup shader globals from shader data */
OSLThreadData *tdata = kg->osl_tdata;
@@ -338,7 +334,7 @@ void OSLShader::eval_volume(KernelGlobals *kg, ShaderData *sd, PathState *state,
/* execute shader */
OSL::ShadingSystem *ss = (OSL::ShadingSystem*)kg->osl_ss;
OSL::ShaderGlobals *globals = &tdata->globals;
- OSL::ShadingContext *octx = tdata->context[(int)ctx];
+ OSL::ShadingContext *octx = tdata->context;
int shader = sd->shader & SHADER_MASK;
if(kg->osl->volume_state[shader]) {
@@ -352,19 +348,17 @@ void OSLShader::eval_volume(KernelGlobals *kg, ShaderData *sd, PathState *state,
/* Displacement */
-void OSLShader::eval_displacement(KernelGlobals *kg, ShaderData *sd, ShaderContext ctx)
+void OSLShader::eval_displacement(KernelGlobals *kg, ShaderData *sd, PathState *state)
{
/* setup shader globals from shader data */
OSLThreadData *tdata = kg->osl_tdata;
- PathState state = {0};
-
- shaderdata_to_shaderglobals(kg, sd, &state, 0, tdata);
+ shaderdata_to_shaderglobals(kg, sd, state, 0, tdata);
/* execute shader */
OSL::ShadingSystem *ss = (OSL::ShadingSystem*)kg->osl_ss;
OSL::ShaderGlobals *globals = &tdata->globals;
- OSL::ShadingContext *octx = tdata->context[(int)ctx];
+ OSL::ShadingContext *octx = tdata->context;
int shader = sd->shader & SHADER_MASK;
if(kg->osl->displacement_state[shader]) {
diff --git a/intern/cycles/kernel/osl/osl_shader.h b/intern/cycles/kernel/osl/osl_shader.h
index 32121e940b4..6b392b25cf7 100644
--- a/intern/cycles/kernel/osl/osl_shader.h
+++ b/intern/cycles/kernel/osl/osl_shader.h
@@ -53,10 +53,10 @@ public:
static void thread_free(KernelGlobals *kg);
/* eval */
- static void eval_surface(KernelGlobals *kg, ShaderData *sd, PathState *state, int path_flag, ShaderContext ctx);
- static void eval_background(KernelGlobals *kg, ShaderData *sd, PathState *state, int path_flag, ShaderContext ctx);
- static void eval_volume(KernelGlobals *kg, ShaderData *sd, PathState *state, int path_flag, ShaderContext ctx);
- static void eval_displacement(KernelGlobals *kg, ShaderData *sd, ShaderContext ctx);
+ static void eval_surface(KernelGlobals *kg, ShaderData *sd, PathState *state, int path_flag);
+ static void eval_background(KernelGlobals *kg, ShaderData *sd, PathState *state, int path_flag);
+ static void eval_volume(KernelGlobals *kg, ShaderData *sd, PathState *state, int path_flag);
+ static void eval_displacement(KernelGlobals *kg, ShaderData *sd, PathState *state);
/* attributes */
static int find_attribute(KernelGlobals *kg, const ShaderData *sd, uint id, AttributeDescriptor *desc);
diff --git a/intern/cycles/kernel/shaders/node_principled_bsdf.osl b/intern/cycles/kernel/shaders/node_principled_bsdf.osl
index 2bb981c3918..6870d479af3 100644
--- a/intern/cycles/kernel/shaders/node_principled_bsdf.osl
+++ b/intern/cycles/kernel/shaders/node_principled_bsdf.osl
@@ -76,8 +76,8 @@ shader node_principled_bsdf(
float aspect = sqrt(1.0 - Anisotropic * 0.9);
float r2 = Roughness * Roughness;
- float alpha_x = max(0.001, r2 / aspect);
- float alpha_y = max(0.001, r2 * aspect);
+ float alpha_x = r2 / aspect;
+ float alpha_y = r2 * aspect;
color tmp_col = color(1.0, 1.0, 1.0) * (1.0 - SpecularTint) + m_ctint * SpecularTint;
diff --git a/intern/cycles/kernel/split/kernel_branched.h b/intern/cycles/kernel/split/kernel_branched.h
index e2762a85fc8..2313feac089 100644
--- a/intern/cycles/kernel/split/kernel_branched.h
+++ b/intern/cycles/kernel/split/kernel_branched.h
@@ -87,7 +87,6 @@ ccl_device_inline bool kernel_split_branched_indirect_start_shared(KernelGlobals
PathRadiance *inactive_L = &kernel_split_state.path_radiance[inactive_ray];
path_radiance_init(inactive_L, kernel_data.film.use_light_pass);
- inactive_L->direct_throughput = L->direct_throughput;
path_radiance_copy_indirect(inactive_L, L);
ray_state[inactive_ray] = RAY_REGENERATED;
@@ -110,7 +109,6 @@ ccl_device_noinline bool kernel_split_branched_path_surface_indirect_light_iter(
SplitBranchedState *branched_state = &kernel_split_state.branched_state[ray_index];
ShaderData *sd = saved_sd;
- RNG rng = kernel_split_state.rng[ray_index];
PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
float3 throughput = branched_state->throughput;
ccl_global PathState *ps = &kernel_split_state.path_state[ray_index];
@@ -157,37 +155,38 @@ ccl_device_noinline bool kernel_split_branched_path_surface_indirect_light_iter(
num_samples = ceil_to_int(num_samples_adjust*num_samples);
float num_samples_inv = num_samples_adjust/num_samples;
- RNG bsdf_rng = cmj_hash(rng, i);
for(int j = branched_state->next_sample; j < num_samples; j++) {
if(reset_path_state) {
*ps = branched_state->path_state;
}
+ ps->rng_hash = cmj_hash(branched_state->path_state.rng_hash, i);
+
ccl_global float3 *tp = &kernel_split_state.throughput[ray_index];
*tp = throughput;
ccl_global Ray *bsdf_ray = &kernel_split_state.ray[ray_index];
if(!kernel_branched_path_surface_bounce(kg,
- &bsdf_rng,
sd,
sc,
j,
num_samples,
tp,
ps,
- L,
+ &L->state,
bsdf_ray,
sum_sample_weight))
{
continue;
}
+ ps->rng_hash = branched_state->path_state.rng_hash;
+
/* update state for next iteration */
branched_state->next_closure = i;
branched_state->next_sample = j+1;
- branched_state->num_samples = num_samples;
/* start the indirect path */
*tp *= num_samples_inv;
diff --git a/intern/cycles/kernel/split/kernel_buffer_update.h b/intern/cycles/kernel/split/kernel_buffer_update.h
index 4c1fdd2d69c..511334e0550 100644
--- a/intern/cycles/kernel/split/kernel_buffer_update.h
+++ b/intern/cycles/kernel/split/kernel_buffer_update.h
@@ -75,107 +75,65 @@ ccl_device void kernel_buffer_update(KernelGlobals *kg,
if(ray_index != QUEUE_EMPTY_SLOT) {
#endif
- ccl_global uint *rng_state = kernel_split_params.rng_state;
- int stride = kernel_split_params.stride;
-
ccl_global char *ray_state = kernel_split_state.ray_state;
-#ifdef __KERNEL_DEBUG__
- DebugData *debug_data = &kernel_split_state.debug_data[ray_index];
-#endif
ccl_global PathState *state = &kernel_split_state.path_state[ray_index];
PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
ccl_global Ray *ray = &kernel_split_state.ray[ray_index];
ccl_global float3 *throughput = &kernel_split_state.throughput[ray_index];
- ccl_global float *L_transparent = &kernel_split_state.L_transparent[ray_index];
- RNG rng = kernel_split_state.rng[ray_index];
- ccl_global float *buffer = kernel_split_params.buffer;
-
- unsigned int work_index;
- ccl_global uint *initial_rng;
-
- unsigned int sample;
- unsigned int tile_x;
- unsigned int tile_y;
- unsigned int pixel_x;
- unsigned int pixel_y;
-
- work_index = kernel_split_state.work_array[ray_index];
- sample = get_work_sample(kg, work_index, ray_index) + kernel_split_params.start_sample;
- get_work_pixel_tile_position(kg, &pixel_x, &pixel_y,
- &tile_x, &tile_y,
- work_index,
- ray_index);
- initial_rng = rng_state;
-
- rng_state += kernel_split_params.offset + pixel_x + pixel_y*stride;
- buffer += (kernel_split_params.offset + pixel_x + pixel_y*stride) * kernel_data.film.pass_stride;
if(IS_STATE(ray_state, ray_index, RAY_UPDATE_BUFFER)) {
-#ifdef __KERNEL_DEBUG__
- kernel_write_debug_passes(kg, buffer, state, debug_data, sample);
-#endif
+ uint sample = state->sample;
+ uint buffer_offset = kernel_split_state.buffer_offset[ray_index];
+ ccl_global float *buffer = kernel_split_params.tile.buffer + buffer_offset;
/* accumulate result in output buffer */
- bool is_shadow_catcher = (state->flag & PATH_RAY_SHADOW_CATCHER);
- kernel_write_result(kg, buffer, sample, L, 1.0f - (*L_transparent), is_shadow_catcher);
-
- path_rng_end(kg, rng_state, rng);
+ kernel_write_result(kg, buffer, sample, L);
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_TO_REGENERATE);
}
if(IS_STATE(ray_state, ray_index, RAY_TO_REGENERATE)) {
/* We have completed current work; So get next work */
- int valid_work = get_next_work(kg, &work_index, ray_index);
- if(!valid_work) {
+ ccl_global uint *work_pools = kernel_split_params.work_pools;
+ uint total_work_size = kernel_split_params.total_work_size;
+ uint work_index;
+
+ if(!get_next_work(kg, work_pools, total_work_size, ray_index, &work_index)) {
/* If work is invalid, this means no more work is available and the thread may exit */
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_INACTIVE);
}
if(IS_STATE(ray_state, ray_index, RAY_TO_REGENERATE)) {
- kernel_split_state.work_array[ray_index] = work_index;
- /* Get the sample associated with the current work */
- sample = get_work_sample(kg, work_index, ray_index) + kernel_split_params.start_sample;
- /* Get pixel and tile position associated with current work */
- get_work_pixel_tile_position(kg, &pixel_x, &pixel_y, &tile_x, &tile_y, work_index, ray_index);
+ ccl_global WorkTile *tile = &kernel_split_params.tile;
+ uint x, y, sample;
+ get_work_pixel(tile, work_index, &x, &y, &sample);
- /* Remap rng_state according to the current work */
- rng_state = initial_rng + kernel_split_params.offset + pixel_x + pixel_y*stride;
- /* Remap buffer according to the current work */
- buffer += (kernel_split_params.offset + pixel_x + pixel_y*stride) * kernel_data.film.pass_stride;
+ /* Store buffer offset for writing to passes. */
+ uint buffer_offset = (tile->offset + x + y*tile->stride) * kernel_data.film.pass_stride;
+ kernel_split_state.buffer_offset[ray_index] = buffer_offset;
/* Initialize random numbers and ray. */
- kernel_path_trace_setup(kg, rng_state, sample, pixel_x, pixel_y, &rng, ray);
+ uint rng_hash;
+ kernel_path_trace_setup(kg, sample, x, y, &rng_hash, ray);
if(ray->t != 0.0f) {
- /* Initialize throughput, L_transparent, Ray, PathState;
+ /* Initialize throughput, path radiance, Ray, PathState;
* These rays proceed with path-iteration.
*/
*throughput = make_float3(1.0f, 1.0f, 1.0f);
- *L_transparent = 0.0f;
path_radiance_init(L, kernel_data.film.use_light_pass);
- path_state_init(kg, &kernel_split_state.sd_DL_shadow[ray_index], state, &rng, sample, ray);
+ path_state_init(kg, &kernel_split_state.sd_DL_shadow[ray_index], state, rng_hash, sample, ray);
#ifdef __SUBSURFACE__
kernel_path_subsurface_init_indirect(&kernel_split_state.ss_rays[ray_index]);
#endif
-#ifdef __KERNEL_DEBUG__
- debug_data_init(debug_data);
-#endif
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_REGENERATED);
enqueue_flag = 1;
}
else {
- /* These rays do not participate in path-iteration. */
- float4 L_rad = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
- /* Accumulate result in output buffer. */
- kernel_write_pass_float4(buffer, sample, L_rad);
- path_rng_end(kg, rng_state, rng);
-
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_TO_REGENERATE);
}
}
}
- kernel_split_state.rng[ray_index] = rng;
#ifndef __COMPUTE_DEVICE_GPU__
}
diff --git a/intern/cycles/kernel/split/kernel_data_init.h b/intern/cycles/kernel/split/kernel_data_init.h
index e4545d66eff..77fb61b80a8 100644
--- a/intern/cycles/kernel/split/kernel_data_init.h
+++ b/intern/cycles/kernel/split/kernel_data_init.h
@@ -23,22 +23,6 @@ CCL_NAMESPACE_BEGIN
* The number of elements in the queues is initialized to 0;
*/
-/* Distributes an amount of work across all threads
- * note: work done inside the loop may not show up to all threads till after
- * the current kernel has completed
- */
-#define parallel_for(kg, iter_name, work_size) \
- for(size_t _size = (work_size), \
- _global_size = ccl_global_size(0) * ccl_global_size(1), \
- _n = _size / _global_size, \
- _thread = ccl_global_id(0) + ccl_global_id(1) * ccl_global_size(0), \
- iter_name = (_n > 0) ? (_thread * _n) : (_thread) \
- ; \
- (iter_name < (_thread+1) * _n) || (iter_name == _n * _global_size + _thread && _thread < _size % _global_size) \
- ; \
- iter_name = (iter_name != (_thread+1) * _n - 1) ? (iter_name + 1) : (_n * _global_size + _thread) \
- )
-
#ifndef __KERNEL_CPU__
ccl_device void kernel_data_init(
#else
@@ -49,12 +33,9 @@ void KERNEL_FUNCTION_FULL_NAME(data_init)(
ccl_global void *split_data_buffer,
int num_elements,
ccl_global char *ray_state,
- ccl_global uint *rng_state,
#ifdef __KERNEL_OPENCL__
-#define KERNEL_TEX(type, ttype, name) \
- ccl_global type *name,
-#include "kernel/kernel_textures.h"
+ KERNEL_BUFFER_PARAMS,
#endif
int start_sample,
@@ -75,34 +56,32 @@ void KERNEL_FUNCTION_FULL_NAME(data_init)(
kg->data = data;
#endif
- kernel_split_params.x = sx;
- kernel_split_params.y = sy;
- kernel_split_params.w = sw;
- kernel_split_params.h = sh;
+ kernel_split_params.tile.x = sx;
+ kernel_split_params.tile.y = sy;
+ kernel_split_params.tile.w = sw;
+ kernel_split_params.tile.h = sh;
- kernel_split_params.offset = offset;
- kernel_split_params.stride = stride;
+ kernel_split_params.tile.start_sample = start_sample;
+ kernel_split_params.tile.num_samples = num_samples;
- kernel_split_params.rng_state = rng_state;
+ kernel_split_params.tile.offset = offset;
+ kernel_split_params.tile.stride = stride;
- kernel_split_params.start_sample = start_sample;
- kernel_split_params.end_sample = end_sample;
+ kernel_split_params.tile.buffer = buffer;
+
+ kernel_split_params.total_work_size = sw * sh * num_samples;
kernel_split_params.work_pools = work_pools;
- kernel_split_params.num_samples = num_samples;
kernel_split_params.queue_index = Queue_index;
kernel_split_params.queue_size = queuesize;
kernel_split_params.use_queues_flag = use_queues_flag;
- kernel_split_params.buffer = buffer;
-
split_data_init(kg, &kernel_split_state, num_elements, split_data_buffer, ray_state);
#ifdef __KERNEL_OPENCL__
-#define KERNEL_TEX(type, ttype, name) \
- kg->name = name;
-#include "kernel/kernel_textures.h"
+ kernel_set_buffer_pointers(kg, KERNEL_BUFFER_ARGS);
+ kernel_set_buffer_info(kg);
#endif
int thread_index = ccl_global_id(1) * ccl_global_size(0) + ccl_global_id(0);
@@ -124,30 +103,6 @@ void KERNEL_FUNCTION_FULL_NAME(data_init)(
*/
*use_queues_flag = 0;
}
-
- /* zero the tiles pixels and initialize rng_state if this is the first sample */
- if(start_sample == 0) {
- parallel_for(kg, i, sw * sh * kernel_data.film.pass_stride) {
- int pixel = i / kernel_data.film.pass_stride;
- int pass = i % kernel_data.film.pass_stride;
-
- int x = sx + pixel % sw;
- int y = sy + pixel / sw;
-
- int index = (offset + x + y*stride) * kernel_data.film.pass_stride + pass;
-
- *(buffer + index) = 0.0f;
- }
-
- parallel_for(kg, i, sw * sh) {
- int x = sx + i % sw;
- int y = sy + i / sw;
-
- int index = (offset + x + y*stride);
- *(rng_state + index) = hash_int_2d(x, y);
- }
- }
-
#endif /* KERENL_STUB */
}
diff --git a/intern/cycles/kernel/split/kernel_direct_lighting.h b/intern/cycles/kernel/split/kernel_direct_lighting.h
index 3336c968a44..2aac66ecb84 100644
--- a/intern/cycles/kernel/split/kernel_direct_lighting.h
+++ b/intern/cycles/kernel/split/kernel_direct_lighting.h
@@ -62,8 +62,6 @@ ccl_device void kernel_direct_lighting(KernelGlobals *kg,
/* direct lighting */
#ifdef __EMISSION__
- RNG rng = kernel_split_state.rng[ray_index];
-
bool flag = (kernel_data.integrator.use_direct_light &&
(sd->flag & SD_BSDF_HAS_EVAL));
@@ -83,23 +81,20 @@ ccl_device void kernel_direct_lighting(KernelGlobals *kg,
if(flag) {
/* Sample illumination from lights to find path contribution. */
- float light_t = path_state_rng_1D(kg, &rng, state, PRNG_LIGHT);
float light_u, light_v;
- path_state_rng_2D(kg, &rng, state, PRNG_LIGHT_U, &light_u, &light_v);
- float terminate = path_state_rng_light_termination(kg, &rng, state);
+ path_state_rng_2D(kg, state, PRNG_LIGHT_U, &light_u, &light_v);
+ float terminate = path_state_rng_light_termination(kg, state);
LightSample ls;
if(light_sample(kg,
- light_t, light_u, light_v,
+ light_u, light_v,
sd->time,
sd->P,
state->bounce,
&ls)) {
Ray light_ray;
-# ifdef __OBJECT_MOTION__
light_ray.time = sd->time;
-# endif
BsdfEval L_light;
bool is_lamp;
@@ -115,7 +110,6 @@ ccl_device void kernel_direct_lighting(KernelGlobals *kg,
}
}
}
- kernel_split_state.rng[ray_index] = rng;
#endif /* __EMISSION__ */
}
diff --git a/intern/cycles/kernel/split/kernel_do_volume.h b/intern/cycles/kernel/split/kernel_do_volume.h
index 9f8dd2392d9..491487f1230 100644
--- a/intern/cycles/kernel/split/kernel_do_volume.h
+++ b/intern/cycles/kernel/split/kernel_do_volume.h
@@ -30,7 +30,6 @@ ccl_device_noinline bool kernel_split_branched_path_volume_indirect_light_iter(K
SplitBranchedState *branched_state = &kernel_split_state.branched_state[ray_index];
ShaderData *sd = &kernel_split_state.sd[ray_index];
- RNG rng = kernel_split_state.rng[ray_index];
PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
ShaderData *emission_sd = &kernel_split_state.sd_DL_shadow[ray_index];
@@ -58,22 +57,21 @@ ccl_device_noinline bool kernel_split_branched_path_volume_indirect_light_iter(K
/* integrate along volume segment with distance sampling */
VolumeIntegrateResult result = kernel_volume_integrate(
- kg, ps, sd, &volume_ray, L, tp, &rng, heterogeneous);
+ kg, ps, sd, &volume_ray, L, tp, heterogeneous);
# ifdef __VOLUME_SCATTER__
if(result == VOLUME_PATH_SCATTERED) {
/* direct lighting */
- kernel_path_volume_connect_light(kg, &rng, sd, emission_sd, *tp, &branched_state->path_state, L);
+ kernel_path_volume_connect_light(kg, sd, emission_sd, *tp, &branched_state->path_state, L);
/* indirect light bounce */
- if(!kernel_path_volume_bounce(kg, &rng, sd, tp, ps, L, pray)) {
+ if(!kernel_path_volume_bounce(kg, sd, tp, ps, &L->state, pray)) {
continue;
}
/* start the indirect path */
branched_state->next_closure = 0;
branched_state->next_sample = j+1;
- branched_state->num_samples = num_samples;
/* Attempting to share too many samples is slow for volumes as it causes us to
* loop here more and have many calls to kernel_volume_integrate which evaluates
@@ -141,7 +139,6 @@ ccl_device void kernel_do_volume(KernelGlobals *kg)
IS_STATE(ray_state, ray_index, RAY_HIT_BACKGROUND)) {
ccl_global float3 *throughput = &kernel_split_state.throughput[ray_index];
ccl_global Ray *ray = &kernel_split_state.ray[ray_index];
- RNG rng = kernel_split_state.rng[ray_index];
ccl_global Intersection *isect = &kernel_split_state.isect[ray_index];
ShaderData *sd = &kernel_split_state.sd[ray_index];
ShaderData *emission_sd = &kernel_split_state.sd_DL_shadow[ray_index];
@@ -165,15 +162,15 @@ ccl_device void kernel_do_volume(KernelGlobals *kg)
{
/* integrate along volume segment with distance sampling */
VolumeIntegrateResult result = kernel_volume_integrate(
- kg, state, sd, &volume_ray, L, throughput, &rng, heterogeneous);
+ kg, state, sd, &volume_ray, L, throughput, heterogeneous);
# ifdef __VOLUME_SCATTER__
if(result == VOLUME_PATH_SCATTERED) {
/* direct lighting */
- kernel_path_volume_connect_light(kg, &rng, sd, emission_sd, *throughput, state, L);
+ kernel_path_volume_connect_light(kg, sd, emission_sd, *throughput, state, L);
/* indirect light bounce */
- if(kernel_path_volume_bounce(kg, &rng, sd, throughput, state, L, ray)) {
+ if(kernel_path_volume_bounce(kg, sd, throughput, state, &L->state, ray)) {
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_REGENERATED);
}
else {
@@ -194,8 +191,6 @@ ccl_device void kernel_do_volume(KernelGlobals *kg)
}
# endif /* __BRANCHED_PATH__ */
}
-
- kernel_split_state.rng[ray_index] = rng;
}
# ifdef __BRANCHED_PATH__
diff --git a/intern/cycles/kernel/split/kernel_holdout_emission_blurring_pathtermination_ao.h b/intern/cycles/kernel/split/kernel_holdout_emission_blurring_pathtermination_ao.h
index 670a557f084..906bad8ceb6 100644
--- a/intern/cycles/kernel/split/kernel_holdout_emission_blurring_pathtermination_ao.h
+++ b/intern/cycles/kernel/split/kernel_holdout_emission_blurring_pathtermination_ao.h
@@ -90,163 +90,58 @@ ccl_device void kernel_holdout_emission_blurring_pathtermination_ao(
if(ray_index != QUEUE_EMPTY_SLOT) {
#endif
- int stride = kernel_split_params.stride;
-
- unsigned int work_index;
- unsigned int pixel_x;
- unsigned int pixel_y;
-
- unsigned int tile_x;
- unsigned int tile_y;
- unsigned int sample;
-
- RNG rng = kernel_split_state.rng[ray_index];
ccl_global PathState *state = 0x0;
float3 throughput;
ccl_global char *ray_state = kernel_split_state.ray_state;
ShaderData *sd = &kernel_split_state.sd[ray_index];
- ccl_global float *buffer = kernel_split_params.buffer;
if(IS_STATE(ray_state, ray_index, RAY_ACTIVE)) {
+ uint buffer_offset = kernel_split_state.buffer_offset[ray_index];
+ ccl_global float *buffer = kernel_split_params.tile.buffer + buffer_offset;
+
+ ccl_global Ray *ray = &kernel_split_state.ray[ray_index];
+ ShaderData *emission_sd = &kernel_split_state.sd_DL_shadow[ray_index];
+ PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
throughput = kernel_split_state.throughput[ray_index];
state = &kernel_split_state.path_state[ray_index];
- work_index = kernel_split_state.work_array[ray_index];
- sample = get_work_sample(kg, work_index, ray_index) + kernel_split_params.start_sample;
- get_work_pixel_tile_position(kg, &pixel_x, &pixel_y,
- &tile_x, &tile_y,
- work_index,
- ray_index);
-
- buffer += (kernel_split_params.offset + pixel_x + pixel_y * stride) * kernel_data.film.pass_stride;
-
-#ifdef __SHADOW_TRICKS__
- if((sd->object_flag & SD_OBJECT_SHADOW_CATCHER)) {
- if(state->flag & PATH_RAY_CAMERA) {
- state->flag |= (PATH_RAY_SHADOW_CATCHER | PATH_RAY_SHADOW_CATCHER_ONLY | PATH_RAY_STORE_SHADOW_INFO);
- state->catcher_object = sd->object;
- if(!kernel_data.background.transparent) {
- PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
- ccl_global Ray *ray = &kernel_split_state.ray[ray_index];
- L->shadow_color = indirect_background(kg, &kernel_split_state.sd_DL_shadow[ray_index], state, ray);
- }
- }
- }
- else {
- state->flag &= ~PATH_RAY_SHADOW_CATCHER_ONLY;
- }
-#endif /* __SHADOW_TRICKS__ */
-
- /* holdout */
-#ifdef __HOLDOUT__
- if(((sd->flag & SD_HOLDOUT) ||
- (sd->object_flag & SD_OBJECT_HOLDOUT_MASK)) &&
- (state->flag & PATH_RAY_CAMERA))
+ if(!kernel_path_shader_apply(kg,
+ sd,
+ state,
+ ray,
+ throughput,
+ emission_sd,
+ L,
+ buffer))
{
- if(kernel_data.background.transparent) {
- float3 holdout_weight;
- if(sd->object_flag & SD_OBJECT_HOLDOUT_MASK) {
- holdout_weight = make_float3(1.0f, 1.0f, 1.0f);
- }
- else {
- holdout_weight = shader_holdout_eval(kg, sd);
- }
- /* any throughput is ok, should all be identical here */
- kernel_split_state.L_transparent[ray_index] += average(holdout_weight*throughput);
- }
- if(sd->object_flag & SD_OBJECT_HOLDOUT_MASK) {
- kernel_split_path_end(kg, ray_index);
- }
+ kernel_split_path_end(kg, ray_index);
}
-#endif /* __HOLDOUT__ */
}
if(IS_STATE(ray_state, ray_index, RAY_ACTIVE)) {
- PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
-
-#ifdef __BRANCHED_PATH__
- if(!IS_FLAG(ray_state, ray_index, RAY_BRANCHED_INDIRECT))
-#endif /* __BRANCHED_PATH__ */
- {
- /* Holdout mask objects do not write data passes. */
- kernel_write_data_passes(kg,
- buffer,
- L,
- sd,
- sample,
- state,
- throughput);
- }
-
- /* Blurring of bsdf after bounces, for rays that have a small likelihood
- * of following this particular path (diffuse, rough glossy.
- */
-#ifndef __BRANCHED_PATH__
- if(kernel_data.integrator.filter_glossy != FLT_MAX)
-#else
- if(kernel_data.integrator.filter_glossy != FLT_MAX &&
- (!kernel_data.integrator.branched || IS_FLAG(ray_state, ray_index, RAY_BRANCHED_INDIRECT)))
-#endif /* __BRANCHED_PATH__ */
- {
- float blur_pdf = kernel_data.integrator.filter_glossy*state->min_ray_pdf;
- if(blur_pdf < 1.0f) {
- float blur_roughness = sqrtf(1.0f - blur_pdf)*0.5f;
- shader_bsdf_blur(kg, sd, blur_roughness);
- }
- }
-
-#ifdef __EMISSION__
- /* emission */
- if(sd->flag & SD_EMISSION) {
- /* TODO(sergey): is isect.t wrong here for transparent surfaces? */
- float3 emission = indirect_primitive_emission(
- kg,
- sd,
- kernel_split_state.isect[ray_index].t,
- state->flag,
- state->ray_pdf);
- path_radiance_accum_emission(L, throughput, emission, state->bounce);
- }
-#endif /* __EMISSION__ */
-
/* Path termination. this is a strange place to put the termination, it's
* mainly due to the mixed in MIS that we use. gives too many unneeded
* shader evaluations, only need emission if we are going to terminate.
*/
-#ifndef __BRANCHED_PATH__
- float probability = path_state_terminate_probability(kg, state, throughput);
-#else
- float probability = 1.0f;
-
- if(!kernel_data.integrator.branched) {
- probability = path_state_terminate_probability(kg, state, throughput);
- }
- else if(IS_FLAG(ray_state, ray_index, RAY_BRANCHED_INDIRECT)) {
- int num_samples = kernel_split_state.branched_state[ray_index].num_samples;
- probability = path_state_terminate_probability(kg, state, throughput*num_samples);
- }
- else if(state->flag & PATH_RAY_TRANSPARENT) {
- probability = path_state_terminate_probability(kg, state, throughput);
- }
-#endif
+ float probability = path_state_continuation_probability(kg, state, throughput);
if(probability == 0.0f) {
kernel_split_path_end(kg, ray_index);
}
-
- if(IS_STATE(ray_state, ray_index, RAY_ACTIVE)) {
- if(probability != 1.0f) {
- float terminate = path_state_rng_1D_for_decision(kg, &rng, state, PRNG_TERMINATE);
- if(terminate >= probability) {
- kernel_split_path_end(kg, ray_index);
- }
- else {
- kernel_split_state.throughput[ray_index] = throughput/probability;
- }
+ else if(probability < 1.0f) {
+ float terminate = path_state_rng_1D(kg, state, PRNG_TERMINATE);
+ if(terminate >= probability) {
+ kernel_split_path_end(kg, ray_index);
}
+ else {
+ kernel_split_state.throughput[ray_index] = throughput/probability;
+ }
+ }
+ if(IS_STATE(ray_state, ray_index, RAY_ACTIVE)) {
+ PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
kernel_update_denoising_features(kg, sd, state, L);
}
}
@@ -260,8 +155,6 @@ ccl_device void kernel_holdout_emission_blurring_pathtermination_ao(
}
#endif /* __AO__ */
- kernel_split_state.rng[ray_index] = rng;
-
#ifndef __COMPUTE_DEVICE_GPU__
}
#endif
diff --git a/intern/cycles/kernel/split/kernel_indirect_background.h b/intern/cycles/kernel/split/kernel_indirect_background.h
index f0ebb90f60a..437043a5971 100644
--- a/intern/cycles/kernel/split/kernel_indirect_background.h
+++ b/intern/cycles/kernel/split/kernel_indirect_background.h
@@ -33,7 +33,7 @@ ccl_device void kernel_indirect_background(KernelGlobals *kg)
if(ray_index != QUEUE_EMPTY_SLOT) {
if(IS_STATE(ray_state, ray_index, RAY_ACTIVE)) {
ccl_global PathState *state = &kernel_split_state.path_state[ray_index];
- if(state->bounce > kernel_data.integrator.ao_bounces) {
+ if(path_state_ao_bounce(kg, state)) {
kernel_split_path_end(kg, ray_index);
}
}
@@ -50,33 +50,16 @@ ccl_device void kernel_indirect_background(KernelGlobals *kg)
return;
}
- ccl_global PathState *state = &kernel_split_state.path_state[ray_index];
- PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
- ccl_global Ray *ray = &kernel_split_state.ray[ray_index];
- ccl_global float3 *throughput = &kernel_split_state.throughput[ray_index];
- ccl_global float *L_transparent = &kernel_split_state.L_transparent[ray_index];
-
if(IS_STATE(ray_state, ray_index, RAY_HIT_BACKGROUND)) {
- /* eval background shader if nothing hit */
- if(kernel_data.background.transparent && (state->flag & PATH_RAY_CAMERA)) {
- *L_transparent = (*L_transparent) + average((*throughput));
-#ifdef __PASSES__
- if(!(kernel_data.film.pass_flag & PASS_BACKGROUND))
-#endif
- kernel_split_path_end(kg, ray_index);
- }
+ ccl_global PathState *state = &kernel_split_state.path_state[ray_index];
+ PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
+ ccl_global Ray *ray = &kernel_split_state.ray[ray_index];
+ float3 throughput = kernel_split_state.throughput[ray_index];
+ ShaderData *emission_sd = &kernel_split_state.sd_DL_shadow[ray_index];
- if(IS_STATE(ray_state, ray_index, RAY_HIT_BACKGROUND)) {
-#ifdef __BACKGROUND__
- /* sample background shader */
- float3 L_background = indirect_background(kg, &kernel_split_state.sd_DL_shadow[ray_index], state, ray);
- path_radiance_accum_background(L, state, (*throughput), L_background);
-#endif
- kernel_split_path_end(kg, ray_index);
- }
+ kernel_path_background(kg, state, ray, throughput, emission_sd, L);
+ kernel_split_path_end(kg, ray_index);
}
-
-
}
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/split/kernel_indirect_subsurface.h b/intern/cycles/kernel/split/kernel_indirect_subsurface.h
index 82bc2f01fd7..e9fe5552e8c 100644
--- a/intern/cycles/kernel/split/kernel_indirect_subsurface.h
+++ b/intern/cycles/kernel/split/kernel_indirect_subsurface.h
@@ -54,7 +54,6 @@ ccl_device void kernel_indirect_subsurface(KernelGlobals *kg)
#endif
if(IS_STATE(ray_state, ray_index, RAY_UPDATE_BUFFER)) {
ccl_addr_space SubsurfaceIndirectRays *ss_indirect = &kernel_split_state.ss_rays[ray_index];
- kernel_path_subsurface_accum_indirect(ss_indirect, L);
/* Trace indirect subsurface rays by restarting the loop. this uses less
* stack memory than invoking kernel_path_indirect.
diff --git a/intern/cycles/kernel/split/kernel_lamp_emission.h b/intern/cycles/kernel/split/kernel_lamp_emission.h
index c669d79ddcd..448456d167d 100644
--- a/intern/cycles/kernel/split/kernel_lamp_emission.h
+++ b/intern/cycles/kernel/split/kernel_lamp_emission.h
@@ -57,27 +57,10 @@ ccl_device void kernel_lamp_emission(KernelGlobals *kg)
float3 throughput = kernel_split_state.throughput[ray_index];
Ray ray = kernel_split_state.ray[ray_index];
+ ccl_global Intersection *isect = &kernel_split_state.isect[ray_index];
+ ShaderData *emission_sd = &kernel_split_state.sd_DL_shadow[ray_index];
-#ifdef __LAMP_MIS__
- if(kernel_data.integrator.use_lamp_mis && !(state->flag & PATH_RAY_CAMERA)) {
- /* ray starting from previous non-transparent bounce */
- Ray light_ray;
-
- light_ray.P = ray.P - state->ray_t*ray.D;
- state->ray_t += kernel_split_state.isect[ray_index].t;
- light_ray.D = ray.D;
- light_ray.t = state->ray_t;
- light_ray.time = ray.time;
- light_ray.dD = ray.dD;
- light_ray.dP = ray.dP;
- /* intersect with lamp */
- float3 emission;
-
- if(indirect_lamp_emission(kg, &kernel_split_state.sd_DL_shadow[ray_index], state, &light_ray, &emission)) {
- path_radiance_accum_emission(L, throughput, emission, state->bounce);
- }
- }
-#endif /* __LAMP_MIS__ */
+ kernel_path_lamp_emission(kg, state, &ray, throughput, isect, emission_sd, L);
}
}
diff --git a/intern/cycles/kernel/split/kernel_next_iteration_setup.h b/intern/cycles/kernel/split/kernel_next_iteration_setup.h
index 7758e35fd32..c3373174582 100644
--- a/intern/cycles/kernel/split/kernel_next_iteration_setup.h
+++ b/intern/cycles/kernel/split/kernel_next_iteration_setup.h
@@ -126,7 +126,6 @@ ccl_device void kernel_next_iteration_setup(KernelGlobals *kg,
if(active) {
ccl_global float3 *throughput = &kernel_split_state.throughput[ray_index];
ccl_global Ray *ray = &kernel_split_state.ray[ray_index];
- RNG rng = kernel_split_state.rng[ray_index];
ShaderData *sd = &kernel_split_state.sd[ray_index];
ccl_global PathState *state = &kernel_split_state.path_state[ray_index];
PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
@@ -135,7 +134,7 @@ ccl_device void kernel_next_iteration_setup(KernelGlobals *kg,
if(!kernel_data.integrator.branched || IS_FLAG(ray_state, ray_index, RAY_BRANCHED_INDIRECT)) {
#endif
/* Compute direct lighting and next bounce. */
- if(!kernel_path_surface_bounce(kg, &rng, sd, throughput, state, L, ray)) {
+ if(!kernel_path_surface_bounce(kg, sd, throughput, state, &L->state, ray)) {
kernel_split_path_end(kg, ray_index);
}
#ifdef __BRANCHED_PATH__
@@ -157,8 +156,6 @@ ccl_device void kernel_next_iteration_setup(KernelGlobals *kg,
}
}
#endif /* __BRANCHED_PATH__ */
-
- kernel_split_state.rng[ray_index] = rng;
}
/* Enqueue RAY_UPDATE_BUFFER rays. */
diff --git a/intern/cycles/kernel/split/kernel_path_init.h b/intern/cycles/kernel/split/kernel_path_init.h
index a7ecde7c80d..5ad62b585fe 100644
--- a/intern/cycles/kernel/split/kernel_path_init.h
+++ b/intern/cycles/kernel/split/kernel_path_init.h
@@ -29,77 +29,53 @@ ccl_device void kernel_path_init(KernelGlobals *kg) {
*/
kernel_split_state.ray_state[ray_index] = RAY_ACTIVE;
- unsigned int my_sample;
- unsigned int pixel_x;
- unsigned int pixel_y;
- unsigned int tile_x;
- unsigned int tile_y;
-
- unsigned int work_index = 0;
/* Get work. */
- if(!get_next_work(kg, &work_index, ray_index)) {
+ ccl_global uint *work_pools = kernel_split_params.work_pools;
+ uint total_work_size = kernel_split_params.total_work_size;
+ uint work_index;
+
+ if(!get_next_work(kg, work_pools, total_work_size, ray_index, &work_index)) {
/* No more work, mark ray as inactive */
kernel_split_state.ray_state[ray_index] = RAY_INACTIVE;
return;
}
- /* Get the sample associated with the work. */
- my_sample = get_work_sample(kg, work_index, ray_index) + kernel_split_params.start_sample;
-
- /* Get pixel and tile position associated with the work. */
- get_work_pixel_tile_position(kg, &pixel_x, &pixel_y,
- &tile_x, &tile_y,
- work_index,
- ray_index);
- kernel_split_state.work_array[ray_index] = work_index;
-
- ccl_global uint *rng_state = kernel_split_params.rng_state;
- rng_state += kernel_split_params.offset + pixel_x + pixel_y*kernel_split_params.stride;
+ ccl_global WorkTile *tile = &kernel_split_params.tile;
+ uint x, y, sample;
+ get_work_pixel(tile, work_index, &x, &y, &sample);
- ccl_global float *buffer = kernel_split_params.buffer;
- buffer += (kernel_split_params.offset + pixel_x + pixel_y * kernel_split_params.stride) * kernel_data.film.pass_stride;
-
- RNG rng = kernel_split_state.rng[ray_index];
+ /* Store buffer offset for writing to passes. */
+ uint buffer_offset = (tile->offset + x + y*tile->stride) * kernel_data.film.pass_stride;
+ kernel_split_state.buffer_offset[ray_index] = buffer_offset;
/* Initialize random numbers and ray. */
+ uint rng_hash;
kernel_path_trace_setup(kg,
- rng_state,
- my_sample,
- pixel_x, pixel_y,
- &rng,
+ sample,
+ x, y,
+ &rng_hash,
&kernel_split_state.ray[ray_index]);
if(kernel_split_state.ray[ray_index].t != 0.0f) {
- /* Initialize throughput, L_transparent, Ray, PathState;
+ /* Initialize throughput, path radiance, Ray, PathState;
* These rays proceed with path-iteration.
*/
kernel_split_state.throughput[ray_index] = make_float3(1.0f, 1.0f, 1.0f);
- kernel_split_state.L_transparent[ray_index] = 0.0f;
path_radiance_init(&kernel_split_state.path_radiance[ray_index], kernel_data.film.use_light_pass);
path_state_init(kg,
&kernel_split_state.sd_DL_shadow[ray_index],
&kernel_split_state.path_state[ray_index],
- &rng,
- my_sample,
+ rng_hash,
+ sample,
&kernel_split_state.ray[ray_index]);
#ifdef __SUBSURFACE__
kernel_path_subsurface_init_indirect(&kernel_split_state.ss_rays[ray_index]);
#endif
-
-#ifdef __KERNEL_DEBUG__
- debug_data_init(&kernel_split_state.debug_data[ray_index]);
-#endif
}
else {
- /* These rays do not participate in path-iteration. */
- float4 L_rad = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
- /* Accumulate result in output buffer. */
- kernel_write_pass_float4(buffer, my_sample, L_rad);
- path_rng_end(kg, rng_state, kernel_split_state.rng[ray_index]);
ASSIGN_RAY_STATE(kernel_split_state.ray_state, ray_index, RAY_TO_REGENERATE);
}
- kernel_split_state.rng[ray_index] = rng;
}
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/split/kernel_queue_enqueue.h b/intern/cycles/kernel/split/kernel_queue_enqueue.h
index e2e841f36d3..66ce2dfb6f1 100644
--- a/intern/cycles/kernel/split/kernel_queue_enqueue.h
+++ b/intern/cycles/kernel/split/kernel_queue_enqueue.h
@@ -51,7 +51,8 @@ ccl_device void kernel_queue_enqueue(KernelGlobals *kg,
int queue_number = -1;
if(IS_STATE(kernel_split_state.ray_state, ray_index, RAY_HIT_BACKGROUND) ||
- IS_STATE(kernel_split_state.ray_state, ray_index, RAY_UPDATE_BUFFER)) {
+ IS_STATE(kernel_split_state.ray_state, ray_index, RAY_UPDATE_BUFFER) ||
+ IS_STATE(kernel_split_state.ray_state, ray_index, RAY_TO_REGENERATE)) {
queue_number = QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS;
}
else if(IS_STATE(kernel_split_state.ray_state, ray_index, RAY_ACTIVE) ||
diff --git a/intern/cycles/kernel/split/kernel_scene_intersect.h b/intern/cycles/kernel/split/kernel_scene_intersect.h
index 45984ca509b..f5378bc172b 100644
--- a/intern/cycles/kernel/split/kernel_scene_intersect.h
+++ b/intern/cycles/kernel/split/kernel_scene_intersect.h
@@ -59,52 +59,14 @@ ccl_device void kernel_scene_intersect(KernelGlobals *kg)
return;
}
-#ifdef __KERNEL_DEBUG__
- DebugData *debug_data = &kernel_split_state.debug_data[ray_index];
-#endif
- Intersection isect;
- PathState state = kernel_split_state.path_state[ray_index];
+ ccl_global PathState *state = &kernel_split_state.path_state[ray_index];
Ray ray = kernel_split_state.ray[ray_index];
+ PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
- /* intersect scene */
- uint visibility = path_state_ray_visibility(kg, &state);
-
- if(state.bounce > kernel_data.integrator.ao_bounces) {
- visibility = PATH_RAY_SHADOW;
- ray.t = kernel_data.background.ao_distance;
- }
-
-#ifdef __HAIR__
- float difl = 0.0f, extmax = 0.0f;
- uint lcg_state = 0;
- RNG rng = kernel_split_state.rng[ray_index];
-
- if(kernel_data.bvh.have_curves) {
- if((kernel_data.cam.resolution == 1) && (state.flag & PATH_RAY_CAMERA)) {
- float3 pixdiff = ray.dD.dx + ray.dD.dy;
- /*pixdiff = pixdiff - dot(pixdiff, ray.D)*ray.D;*/
- difl = kernel_data.curve.minimum_width * len(pixdiff) * 0.5f;
- }
-
- extmax = kernel_data.curve.maximum_width;
- lcg_state = lcg_state_init(&rng, state.rng_offset, state.sample, 0x51633e2d);
- }
-
- bool hit = scene_intersect(kg, ray, visibility, &isect, &lcg_state, difl, extmax);
-#else
- bool hit = scene_intersect(kg, ray, visibility, &isect, NULL, 0.0f, 0.0f);
-#endif
+ Intersection isect;
+ bool hit = kernel_path_scene_intersect(kg, state, &ray, &isect, L);
kernel_split_state.isect[ray_index] = isect;
-#ifdef __KERNEL_DEBUG__
- if(state.flag & PATH_RAY_CAMERA) {
- debug_data->num_bvh_traversed_nodes += isect.num_traversed_nodes;
- debug_data->num_bvh_traversed_instances += isect.num_traversed_instances;
- debug_data->num_bvh_intersections += isect.num_intersections;
- }
- debug_data->num_ray_bounces++;
-#endif
-
if(!hit) {
/* Change the state of rays that hit the background;
* These rays undergo special processing in the
diff --git a/intern/cycles/kernel/split/kernel_shader_eval.h b/intern/cycles/kernel/split/kernel_shader_eval.h
index 2801b32f285..7032461b04a 100644
--- a/intern/cycles/kernel/split/kernel_shader_eval.h
+++ b/intern/cycles/kernel/split/kernel_shader_eval.h
@@ -48,30 +48,18 @@ ccl_device void kernel_shader_eval(KernelGlobals *kg)
ccl_global char *ray_state = kernel_split_state.ray_state;
if(IS_STATE(ray_state, ray_index, RAY_ACTIVE)) {
- RNG rng = kernel_split_state.rng[ray_index];
ccl_global PathState *state = &kernel_split_state.path_state[ray_index];
-#ifndef __BRANCHED_PATH__
- float rbsdf = path_state_rng_1D_for_decision(kg, &rng, state, PRNG_BSDF);
- shader_eval_surface(kg, &kernel_split_state.sd[ray_index], &rng, state, rbsdf, state->flag, SHADER_CONTEXT_MAIN);
-#else
- ShaderContext ctx = SHADER_CONTEXT_MAIN;
- float rbsdf = 0.0f;
-
- if(!kernel_data.integrator.branched || IS_FLAG(ray_state, ray_index, RAY_BRANCHED_INDIRECT)) {
- rbsdf = path_state_rng_1D_for_decision(kg, &rng, state, PRNG_BSDF);
-
+ shader_eval_surface(kg, &kernel_split_state.sd[ray_index], state, state->flag);
+#ifdef __BRANCHED_PATH__
+ if(kernel_data.integrator.branched) {
+ shader_merge_closures(&kernel_split_state.sd[ray_index]);
}
-
- if(IS_FLAG(ray_state, ray_index, RAY_BRANCHED_INDIRECT)) {
- ctx = SHADER_CONTEXT_INDIRECT;
+ else
+#endif
+ {
+ shader_prepare_closures(&kernel_split_state.sd[ray_index], state);
}
-
- shader_eval_surface(kg, &kernel_split_state.sd[ray_index], &rng, state, rbsdf, state->flag, ctx);
- shader_merge_closures(&kernel_split_state.sd[ray_index]);
-#endif /* __BRANCHED_PATH__ */
-
- kernel_split_state.rng[ray_index] = rng;
}
}
diff --git a/intern/cycles/kernel/split/kernel_shader_sort.h b/intern/cycles/kernel/split/kernel_shader_sort.h
index 297decb0bc2..5a55b680695 100644
--- a/intern/cycles/kernel/split/kernel_shader_sort.h
+++ b/intern/cycles/kernel/split/kernel_shader_sort.h
@@ -39,7 +39,7 @@ ccl_device void kernel_shader_sort(KernelGlobals *kg,
ccl_local ushort *local_index = &locals->local_index[0];
/* copy to local memory */
- for (uint i = 0; i < SHADER_SORT_BLOCK_SIZE; i += SHADER_SORT_LOCAL_SIZE) {
+ for(uint i = 0; i < SHADER_SORT_BLOCK_SIZE; i += SHADER_SORT_LOCAL_SIZE) {
uint idx = offset + i + lid;
uint add = input + idx;
uint value = (~0);
@@ -59,9 +59,9 @@ ccl_device void kernel_shader_sort(KernelGlobals *kg,
# ifdef __KERNEL_OPENCL__
/* bitonic sort */
- for (uint length = 1; length < SHADER_SORT_BLOCK_SIZE; length <<= 1) {
- for (uint inc = length; inc > 0; inc >>= 1) {
- for (uint ii = 0; ii < SHADER_SORT_BLOCK_SIZE; ii += SHADER_SORT_LOCAL_SIZE) {
+ for(uint length = 1; length < SHADER_SORT_BLOCK_SIZE; length <<= 1) {
+ for(uint inc = length; inc > 0; inc >>= 1) {
+ for(uint ii = 0; ii < SHADER_SORT_BLOCK_SIZE; ii += SHADER_SORT_LOCAL_SIZE) {
uint i = lid + ii;
bool direction = ((i & (length << 1)) != 0);
uint j = i ^ inc;
@@ -81,7 +81,7 @@ ccl_device void kernel_shader_sort(KernelGlobals *kg,
# endif /* __KERNEL_OPENCL__ */
/* copy to destination */
- for (uint i = 0; i < SHADER_SORT_BLOCK_SIZE; i += SHADER_SORT_LOCAL_SIZE) {
+ for(uint i = 0; i < SHADER_SORT_BLOCK_SIZE; i += SHADER_SORT_LOCAL_SIZE) {
uint idx = offset + i + lid;
uint lidx = local_index[i + lid];
uint outi = output + idx;
diff --git a/intern/cycles/kernel/split/kernel_shadow_blocked_ao.h b/intern/cycles/kernel/split/kernel_shadow_blocked_ao.h
index 474286285a9..79aa2c9435b 100644
--- a/intern/cycles/kernel/split/kernel_shadow_blocked_ao.h
+++ b/intern/cycles/kernel/split/kernel_shadow_blocked_ao.h
@@ -37,21 +37,18 @@ ccl_device void kernel_shadow_blocked_ao(KernelGlobals *kg)
ShaderData *emission_sd = &kernel_split_state.sd_DL_shadow[ray_index];
PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
ccl_global PathState *state = &kernel_split_state.path_state[ray_index];
- RNG rng = kernel_split_state.rng[ray_index];
float3 throughput = kernel_split_state.throughput[ray_index];
#ifdef __BRANCHED_PATH__
if(!kernel_data.integrator.branched || IS_FLAG(kernel_split_state.ray_state, ray_index, RAY_BRANCHED_INDIRECT)) {
#endif
- kernel_path_ao(kg, sd, emission_sd, L, state, &rng, throughput, shader_bsdf_alpha(kg, sd));
+ kernel_path_ao(kg, sd, emission_sd, L, state, throughput, shader_bsdf_alpha(kg, sd));
#ifdef __BRANCHED_PATH__
}
else {
- kernel_branched_path_ao(kg, sd, emission_sd, L, state, &rng, throughput);
+ kernel_branched_path_ao(kg, sd, emission_sd, L, state, throughput);
}
#endif
-
- kernel_split_state.rng[ray_index] = rng;
}
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/split/kernel_shadow_blocked_dl.h b/intern/cycles/kernel/split/kernel_shadow_blocked_dl.h
index 78e61709b01..b52f9a5eb81 100644
--- a/intern/cycles/kernel/split/kernel_shadow_blocked_dl.h
+++ b/intern/cycles/kernel/split/kernel_shadow_blocked_dl.h
@@ -45,7 +45,6 @@ ccl_device void kernel_shadow_blocked_dl(KernelGlobals *kg)
PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
ShaderData *sd = &kernel_split_state.sd[ray_index];
float3 throughput = kernel_split_state.throughput[ray_index];
- RNG rng = kernel_split_state.rng[ray_index];
BsdfEval L_light = kernel_split_state.bsdf_eval[ray_index];
ShaderData *emission_sd = &kernel_split_state.sd_DL_shadow[ray_index];
@@ -75,7 +74,6 @@ ccl_device void kernel_shadow_blocked_dl(KernelGlobals *kg)
if(use_branched) {
kernel_branched_path_surface_connect_light(kg,
- &rng,
sd,
emission_sd,
state,
@@ -91,10 +89,11 @@ ccl_device void kernel_shadow_blocked_dl(KernelGlobals *kg)
float3 shadow;
if(!shadow_blocked(kg,
- emission_sd,
- state,
- &ray,
- &shadow))
+ sd,
+ emission_sd,
+ state,
+ &ray,
+ &shadow))
{
/* accumulate */
path_radiance_accum_light(L, state, throughput, &L_light, shadow, 1.0f, is_lamp);
@@ -103,8 +102,6 @@ ccl_device void kernel_shadow_blocked_dl(KernelGlobals *kg)
path_radiance_accum_total_light(L, state, throughput, &L_light);
}
}
-
- kernel_split_state.rng[ray_index] = rng;
}
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/split/kernel_split_common.h b/intern/cycles/kernel/split/kernel_split_common.h
index 08f0124b529..558d327bc76 100644
--- a/intern/cycles/kernel/split/kernel_split_common.h
+++ b/intern/cycles/kernel/split/kernel_split_common.h
@@ -63,7 +63,7 @@ ccl_device_inline void kernel_split_path_end(KernelGlobals *kg, int ray_index)
PathRadiance *orig_ray_L = &kernel_split_state.path_radiance[orig_ray];
path_radiance_sum_indirect(L);
- path_radiance_accum_sample(orig_ray_L, L, 1);
+ path_radiance_accum_sample(orig_ray_L, L);
atomic_fetch_and_dec_uint32((ccl_global uint*)&kernel_split_state.branched_state[orig_ray].shared_sample_count);
diff --git a/intern/cycles/kernel/split/kernel_split_data_types.h b/intern/cycles/kernel/split/kernel_split_data_types.h
index 4bb2f0d3d80..b0e6e5f5250 100644
--- a/intern/cycles/kernel/split/kernel_split_data_types.h
+++ b/intern/cycles/kernel/split/kernel_split_data_types.h
@@ -22,28 +22,15 @@ CCL_NAMESPACE_BEGIN
/* parameters used by the split kernels, we use a single struct to avoid passing these to each kernel */
typedef struct SplitParams {
- int x;
- int y;
- int w;
- int h;
-
- int offset;
- int stride;
-
- ccl_global uint *rng_state;
-
- int start_sample;
- int end_sample;
+ WorkTile tile;
+ uint total_work_size;
ccl_global unsigned int *work_pools;
- unsigned int num_samples;
ccl_global int *queue_index;
int queue_size;
ccl_global char *use_queues_flag;
- ccl_global float *buffer;
-
/* Place for storing sd->flag. AMD GPU OpenCL compiler workaround */
int dummy_sd_flag;
} SplitParams;
@@ -56,14 +43,6 @@ typedef struct SplitParams {
/* SPLIT_DATA_ENTRY(type, name, num) */
-#if defined(WITH_CYCLES_DEBUG) || defined(__KERNEL_DEBUG__)
-/* DebugData memory */
-# define SPLIT_DATA_DEBUG_ENTRIES \
- SPLIT_DATA_ENTRY(DebugData, debug_data, 1)
-#else
-# define SPLIT_DATA_DEBUG_ENTRIES
-#endif /* DEBUG */
-
#ifdef __BRANCHED_PATH__
typedef ccl_global struct SplitBranchedState {
@@ -80,7 +59,6 @@ typedef ccl_global struct SplitBranchedState {
/* indirect loop state */
int next_closure;
int next_sample;
- int num_samples;
#ifdef __SUBSURFACE__
int ss_next_closure;
@@ -122,9 +100,7 @@ typedef ccl_global struct SplitBranchedState {
#endif /* __VOLUME__ */
#define SPLIT_DATA_ENTRIES \
- SPLIT_DATA_ENTRY(ccl_global RNG, rng, 1) \
SPLIT_DATA_ENTRY(ccl_global float3, throughput, 1) \
- SPLIT_DATA_ENTRY(ccl_global float, L_transparent, 1) \
SPLIT_DATA_ENTRY(PathRadiance, path_radiance, 1) \
SPLIT_DATA_ENTRY(ccl_global Ray, ray, 1) \
SPLIT_DATA_ENTRY(ccl_global PathState, path_state, 1) \
@@ -133,19 +109,16 @@ typedef ccl_global struct SplitBranchedState {
SPLIT_DATA_ENTRY(ccl_global int, is_lamp, 1) \
SPLIT_DATA_ENTRY(ccl_global Ray, light_ray, 1) \
SPLIT_DATA_ENTRY(ccl_global int, queue_data, (NUM_QUEUES*2)) /* TODO(mai): this is too large? */ \
- SPLIT_DATA_ENTRY(ccl_global uint, work_array, 1) \
+ SPLIT_DATA_ENTRY(ccl_global uint, buffer_offset, 1) \
SPLIT_DATA_ENTRY(ShaderData, sd, 1) \
SPLIT_DATA_ENTRY(ShaderData, sd_DL_shadow, 1) \
SPLIT_DATA_SUBSURFACE_ENTRIES \
SPLIT_DATA_VOLUME_ENTRIES \
SPLIT_DATA_BRANCHED_ENTRIES \
- SPLIT_DATA_DEBUG_ENTRIES \
/* entries to be copied to inactive rays when sharing branched samples (TODO: which are actually needed?) */
#define SPLIT_DATA_ENTRIES_BRANCHED_SHARED \
- SPLIT_DATA_ENTRY(ccl_global RNG, rng, 1) \
SPLIT_DATA_ENTRY(ccl_global float3, throughput, 1) \
- SPLIT_DATA_ENTRY(ccl_global float, L_transparent, 1) \
SPLIT_DATA_ENTRY(PathRadiance, path_radiance, 1) \
SPLIT_DATA_ENTRY(ccl_global Ray, ray, 1) \
SPLIT_DATA_ENTRY(ccl_global PathState, path_state, 1) \
@@ -158,7 +131,6 @@ typedef ccl_global struct SplitBranchedState {
SPLIT_DATA_SUBSURFACE_ENTRIES \
SPLIT_DATA_VOLUME_ENTRIES \
SPLIT_DATA_BRANCHED_ENTRIES \
- SPLIT_DATA_DEBUG_ENTRIES \
/* struct that holds pointers to data in the shared state buffer */
typedef struct SplitData {
diff --git a/intern/cycles/kernel/split/kernel_subsurface_scatter.h b/intern/cycles/kernel/split/kernel_subsurface_scatter.h
index d5083b23f80..3b957856aea 100644
--- a/intern/cycles/kernel/split/kernel_subsurface_scatter.h
+++ b/intern/cycles/kernel/split/kernel_subsurface_scatter.h
@@ -38,7 +38,6 @@ ccl_device_noinline bool kernel_split_branched_path_subsurface_indirect_light_it
SplitBranchedState *branched_state = &kernel_split_state.branched_state[ray_index];
ShaderData *sd = &branched_state->sd;
- RNG rng = kernel_split_state.rng[ray_index];
PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
ShaderData *emission_sd = &kernel_split_state.sd_DL_shadow[ray_index];
@@ -52,14 +51,12 @@ ccl_device_noinline bool kernel_split_branched_path_subsurface_indirect_light_it
if(branched_state->ss_next_sample == 0 && branched_state->next_hit == 0 &&
branched_state->next_closure == 0 && branched_state->next_sample == 0)
{
- branched_state->lcg_state = lcg_state_init(&rng,
- branched_state->path_state.rng_offset,
- branched_state->path_state.sample,
- 0x68bc21eb);
+ branched_state->lcg_state = lcg_state_init_addrspace(&branched_state->path_state,
+ 0x68bc21eb);
}
int num_samples = kernel_data.integrator.subsurface_samples;
float num_samples_inv = 1.0f/num_samples;
- RNG bssrdf_rng = cmj_hash(rng, i);
+ uint bssrdf_rng_hash = cmj_hash(branched_state->path_state.rng_hash, i);
/* do subsurface scatter step with copy of shader data, this will
* replace the BSSRDF with a diffuse BSDF closure */
@@ -67,7 +64,7 @@ ccl_device_noinline bool kernel_split_branched_path_subsurface_indirect_light_it
ccl_global SubsurfaceIntersection *ss_isect = &branched_state->ss_isect;
float bssrdf_u, bssrdf_v;
path_branched_rng_2D(kg,
- &bssrdf_rng,
+ bssrdf_rng_hash,
&branched_state->path_state,
j,
num_samples,
@@ -77,7 +74,7 @@ ccl_device_noinline bool kernel_split_branched_path_subsurface_indirect_light_it
/* intersection is expensive so avoid doing multiple times for the same input */
if(branched_state->next_hit == 0 && branched_state->next_closure == 0 && branched_state->next_sample == 0) {
- RNG lcg_state = branched_state->lcg_state;
+ uint lcg_state = branched_state->lcg_state;
SubsurfaceIntersection ss_isect_private;
branched_state->num_hits = subsurface_scatter_multi_intersect(kg,
@@ -152,7 +149,6 @@ ccl_device_noinline bool kernel_split_branched_path_subsurface_indirect_light_it
int all = (kernel_data.integrator.sample_all_lights_direct) ||
(branched_state->path_state.flag & PATH_RAY_SHADOW_CATCHER);
kernel_branched_path_surface_connect_light(kg,
- &rng,
bssrdf_sd,
emission_sd,
hit_state,
@@ -229,7 +225,6 @@ ccl_device void kernel_subsurface_scatter(KernelGlobals *kg)
if(IS_STATE(ray_state, ray_index, RAY_ACTIVE)) {
ccl_global PathState *state = &kernel_split_state.path_state[ray_index];
PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
- RNG rng = kernel_split_state.rng[ray_index];
ccl_global Ray *ray = &kernel_split_state.ray[ray_index];
ccl_global float3 *throughput = &kernel_split_state.throughput[ray_index];
ccl_global SubsurfaceIndirectRays *ss_indirect = &kernel_split_state.ss_rays[ray_index];
@@ -246,7 +241,6 @@ ccl_device void kernel_subsurface_scatter(KernelGlobals *kg)
emission_sd,
L,
state,
- &rng,
ray,
throughput,
ss_indirect))
@@ -256,21 +250,17 @@ ccl_device void kernel_subsurface_scatter(KernelGlobals *kg)
#ifdef __BRANCHED_PATH__
}
else if(IS_FLAG(ray_state, ray_index, RAY_BRANCHED_INDIRECT)) {
- float bssrdf_probability;
- ShaderClosure *sc = subsurface_scatter_pick_closure(kg, sd, &bssrdf_probability);
+ float bssrdf_u, bssrdf_v;
+ path_state_rng_2D(kg,
+ state,
+ PRNG_BSDF_U,
+ &bssrdf_u, &bssrdf_v);
- /* modify throughput for picking bssrdf or bsdf */
- *throughput *= bssrdf_probability;
+ const ShaderClosure *sc = shader_bssrdf_pick(sd, throughput, &bssrdf_u);
/* do bssrdf scatter step if we picked a bssrdf closure */
if(sc) {
- uint lcg_state = lcg_state_init(&rng, state->rng_offset, state->sample, 0x68bc21eb);
- float bssrdf_u, bssrdf_v;
- path_state_rng_2D(kg,
- &rng,
- state,
- PRNG_BSDF_U,
- &bssrdf_u, &bssrdf_v);
+ uint lcg_state = lcg_state_init_addrspace(state, 0x68bc21eb);
subsurface_scatter_step(kg,
sd,
state,
@@ -290,7 +280,6 @@ ccl_device void kernel_subsurface_scatter(KernelGlobals *kg)
}
#endif
}
- kernel_split_state.rng[ray_index] = rng;
}
# ifdef __BRANCHED_PATH__
diff --git a/intern/cycles/kernel/svm/svm_blackbody.h b/intern/cycles/kernel/svm/svm_blackbody.h
index b750ad87b7f..51590b18505 100644
--- a/intern/cycles/kernel/svm/svm_blackbody.h
+++ b/intern/cycles/kernel/svm/svm_blackbody.h
@@ -41,8 +41,7 @@ ccl_device void svm_node_blackbody(KernelGlobals *kg, ShaderData *sd, float *sta
float3 color_rgb = svm_math_blackbody_color(temperature);
- if(stack_valid(col_offset))
- stack_store_float3(stack, col_offset, color_rgb);
+ stack_store_float3(stack, col_offset, color_rgb);
}
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/svm/svm_closure.h b/intern/cycles/kernel/svm/svm_closure.h
index 844245ee2d4..4268813b263 100644
--- a/intern/cycles/kernel/svm/svm_closure.h
+++ b/intern/cycles/kernel/svm/svm_closure.h
@@ -158,8 +158,8 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
}
/* diffuse */
- if(fabsf(average(base_color)) > CLOSURE_WEIGHT_CUTOFF) {
- if(subsurface < CLOSURE_WEIGHT_CUTOFF && diffuse_weight > CLOSURE_WEIGHT_CUTOFF) {
+ if(fabsf(average(mixed_ss_base_color)) > CLOSURE_WEIGHT_CUTOFF) {
+ if(subsurface <= CLOSURE_WEIGHT_CUTOFF && diffuse_weight > CLOSURE_WEIGHT_CUTOFF) {
float3 diff_weight = weight * base_color * diffuse_weight;
PrincipledDiffuseBsdf *bsdf = (PrincipledDiffuseBsdf*)bsdf_alloc(sd, sizeof(PrincipledDiffuseBsdf), diff_weight);
@@ -280,8 +280,8 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
float aspect = safe_sqrtf(1.0f - anisotropic * 0.9f);
float r2 = roughness * roughness;
- bsdf->alpha_x = fmaxf(0.001f, r2 / aspect);
- bsdf->alpha_y = fmaxf(0.001f, r2 * aspect);
+ bsdf->alpha_x = r2 / aspect;
+ bsdf->alpha_y = r2 * aspect;
float m_cdlum = 0.3f * base_color.x + 0.6f * base_color.y + 0.1f * base_color.z; // luminance approx.
float3 m_ctint = m_cdlum > 0.0f ? base_color / m_cdlum : make_float3(0.0f, 0.0f, 0.0f); // normalize lum. to isolate hue+sat
@@ -725,6 +725,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
HairBsdf *bsdf = (HairBsdf*)bsdf_alloc(sd, sizeof(HairBsdf), weight);
if(bsdf) {
+ bsdf->N = N;
bsdf->roughness1 = param1;
bsdf->roughness2 = param2;
bsdf->offset = -stack_load_float(stack, data_node.z);
diff --git a/intern/cycles/kernel/svm/svm_image.h b/intern/cycles/kernel/svm/svm_image.h
index 8e45dbfa5ff..6d6e92e73f6 100644
--- a/intern/cycles/kernel/svm/svm_image.h
+++ b/intern/cycles/kernel/svm/svm_image.h
@@ -16,19 +16,6 @@
CCL_NAMESPACE_BEGIN
-/* Float4 textures on various devices. */
-#if defined(__KERNEL_CPU__)
-# define TEX_NUM_FLOAT4_IMAGES TEX_NUM_FLOAT4_CPU
-#elif defined(__KERNEL_CUDA__)
-# if __CUDA_ARCH__ < 300
-# define TEX_NUM_FLOAT4_IMAGES TEX_NUM_FLOAT4_CUDA
-# else
-# define TEX_NUM_FLOAT4_IMAGES TEX_NUM_FLOAT4_CUDA_KEPLER
-# endif
-#else
-# define TEX_NUM_FLOAT4_IMAGES TEX_NUM_FLOAT4_OPENCL
-#endif
-
ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, uint srgb, uint use_alpha)
{
#ifdef __KERNEL_CPU__
@@ -50,94 +37,94 @@ ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y,
switch(id) {
case 0: r = kernel_tex_image_interp(__tex_image_float4_000, x, y); break;
- case 1: r = kernel_tex_image_interp(__tex_image_float4_001, x, y); break;
- case 2: r = kernel_tex_image_interp(__tex_image_float4_002, x, y); break;
- case 3: r = kernel_tex_image_interp(__tex_image_float4_003, x, y); break;
- case 4: r = kernel_tex_image_interp(__tex_image_float4_004, x, y); break;
- case 5: r = kernel_tex_image_interp(__tex_image_byte4_005, x, y); break;
- case 6: r = kernel_tex_image_interp(__tex_image_byte4_006, x, y); break;
- case 7: r = kernel_tex_image_interp(__tex_image_byte4_007, x, y); break;
- case 8: r = kernel_tex_image_interp(__tex_image_byte4_008, x, y); break;
+ case 8: r = kernel_tex_image_interp(__tex_image_float4_008, x, y); break;
+ case 16: r = kernel_tex_image_interp(__tex_image_float4_016, x, y); break;
+ case 24: r = kernel_tex_image_interp(__tex_image_float4_024, x, y); break;
+ case 32: r = kernel_tex_image_interp(__tex_image_float4_032, x, y); break;
+ case 1: r = kernel_tex_image_interp(__tex_image_byte4_001, x, y); break;
case 9: r = kernel_tex_image_interp(__tex_image_byte4_009, x, y); break;
- case 10: r = kernel_tex_image_interp(__tex_image_byte4_010, x, y); break;
- case 11: r = kernel_tex_image_interp(__tex_image_byte4_011, x, y); break;
- case 12: r = kernel_tex_image_interp(__tex_image_byte4_012, x, y); break;
- case 13: r = kernel_tex_image_interp(__tex_image_byte4_013, x, y); break;
- case 14: r = kernel_tex_image_interp(__tex_image_byte4_014, x, y); break;
- case 15: r = kernel_tex_image_interp(__tex_image_byte4_015, x, y); break;
- case 16: r = kernel_tex_image_interp(__tex_image_byte4_016, x, y); break;
case 17: r = kernel_tex_image_interp(__tex_image_byte4_017, x, y); break;
- case 18: r = kernel_tex_image_interp(__tex_image_byte4_018, x, y); break;
- case 19: r = kernel_tex_image_interp(__tex_image_byte4_019, x, y); break;
- case 20: r = kernel_tex_image_interp(__tex_image_byte4_020, x, y); break;
- case 21: r = kernel_tex_image_interp(__tex_image_byte4_021, x, y); break;
- case 22: r = kernel_tex_image_interp(__tex_image_byte4_022, x, y); break;
- case 23: r = kernel_tex_image_interp(__tex_image_byte4_023, x, y); break;
- case 24: r = kernel_tex_image_interp(__tex_image_byte4_024, x, y); break;
case 25: r = kernel_tex_image_interp(__tex_image_byte4_025, x, y); break;
- case 26: r = kernel_tex_image_interp(__tex_image_byte4_026, x, y); break;
- case 27: r = kernel_tex_image_interp(__tex_image_byte4_027, x, y); break;
- case 28: r = kernel_tex_image_interp(__tex_image_byte4_028, x, y); break;
- case 29: r = kernel_tex_image_interp(__tex_image_byte4_029, x, y); break;
- case 30: r = kernel_tex_image_interp(__tex_image_byte4_030, x, y); break;
- case 31: r = kernel_tex_image_interp(__tex_image_byte4_031, x, y); break;
- case 32: r = kernel_tex_image_interp(__tex_image_byte4_032, x, y); break;
case 33: r = kernel_tex_image_interp(__tex_image_byte4_033, x, y); break;
- case 34: r = kernel_tex_image_interp(__tex_image_byte4_034, x, y); break;
- case 35: r = kernel_tex_image_interp(__tex_image_byte4_035, x, y); break;
- case 36: r = kernel_tex_image_interp(__tex_image_byte4_036, x, y); break;
- case 37: r = kernel_tex_image_interp(__tex_image_byte4_037, x, y); break;
- case 38: r = kernel_tex_image_interp(__tex_image_byte4_038, x, y); break;
- case 39: r = kernel_tex_image_interp(__tex_image_byte4_039, x, y); break;
- case 40: r = kernel_tex_image_interp(__tex_image_byte4_040, x, y); break;
case 41: r = kernel_tex_image_interp(__tex_image_byte4_041, x, y); break;
- case 42: r = kernel_tex_image_interp(__tex_image_byte4_042, x, y); break;
- case 43: r = kernel_tex_image_interp(__tex_image_byte4_043, x, y); break;
- case 44: r = kernel_tex_image_interp(__tex_image_byte4_044, x, y); break;
- case 45: r = kernel_tex_image_interp(__tex_image_byte4_045, x, y); break;
- case 46: r = kernel_tex_image_interp(__tex_image_byte4_046, x, y); break;
- case 47: r = kernel_tex_image_interp(__tex_image_byte4_047, x, y); break;
- case 48: r = kernel_tex_image_interp(__tex_image_byte4_048, x, y); break;
case 49: r = kernel_tex_image_interp(__tex_image_byte4_049, x, y); break;
- case 50: r = kernel_tex_image_interp(__tex_image_byte4_050, x, y); break;
- case 51: r = kernel_tex_image_interp(__tex_image_byte4_051, x, y); break;
- case 52: r = kernel_tex_image_interp(__tex_image_byte4_052, x, y); break;
- case 53: r = kernel_tex_image_interp(__tex_image_byte4_053, x, y); break;
- case 54: r = kernel_tex_image_interp(__tex_image_byte4_054, x, y); break;
- case 55: r = kernel_tex_image_interp(__tex_image_byte4_055, x, y); break;
- case 56: r = kernel_tex_image_interp(__tex_image_byte4_056, x, y); break;
case 57: r = kernel_tex_image_interp(__tex_image_byte4_057, x, y); break;
- case 58: r = kernel_tex_image_interp(__tex_image_byte4_058, x, y); break;
- case 59: r = kernel_tex_image_interp(__tex_image_byte4_059, x, y); break;
- case 60: r = kernel_tex_image_interp(__tex_image_byte4_060, x, y); break;
- case 61: r = kernel_tex_image_interp(__tex_image_byte4_061, x, y); break;
- case 62: r = kernel_tex_image_interp(__tex_image_byte4_062, x, y); break;
- case 63: r = kernel_tex_image_interp(__tex_image_byte4_063, x, y); break;
- case 64: r = kernel_tex_image_interp(__tex_image_byte4_064, x, y); break;
case 65: r = kernel_tex_image_interp(__tex_image_byte4_065, x, y); break;
- case 66: r = kernel_tex_image_interp(__tex_image_byte4_066, x, y); break;
- case 67: r = kernel_tex_image_interp(__tex_image_byte4_067, x, y); break;
- case 68: r = kernel_tex_image_interp(__tex_image_byte4_068, x, y); break;
- case 69: r = kernel_tex_image_interp(__tex_image_byte4_069, x, y); break;
- case 70: r = kernel_tex_image_interp(__tex_image_byte4_070, x, y); break;
- case 71: r = kernel_tex_image_interp(__tex_image_byte4_071, x, y); break;
- case 72: r = kernel_tex_image_interp(__tex_image_byte4_072, x, y); break;
case 73: r = kernel_tex_image_interp(__tex_image_byte4_073, x, y); break;
- case 74: r = kernel_tex_image_interp(__tex_image_byte4_074, x, y); break;
- case 75: r = kernel_tex_image_interp(__tex_image_byte4_075, x, y); break;
- case 76: r = kernel_tex_image_interp(__tex_image_byte4_076, x, y); break;
- case 77: r = kernel_tex_image_interp(__tex_image_byte4_077, x, y); break;
- case 78: r = kernel_tex_image_interp(__tex_image_byte4_078, x, y); break;
- case 79: r = kernel_tex_image_interp(__tex_image_byte4_079, x, y); break;
- case 80: r = kernel_tex_image_interp(__tex_image_byte4_080, x, y); break;
case 81: r = kernel_tex_image_interp(__tex_image_byte4_081, x, y); break;
- case 82: r = kernel_tex_image_interp(__tex_image_byte4_082, x, y); break;
- case 83: r = kernel_tex_image_interp(__tex_image_byte4_083, x, y); break;
- case 84: r = kernel_tex_image_interp(__tex_image_byte4_084, x, y); break;
- case 85: r = kernel_tex_image_interp(__tex_image_byte4_085, x, y); break;
- case 86: r = kernel_tex_image_interp(__tex_image_byte4_086, x, y); break;
- case 87: r = kernel_tex_image_interp(__tex_image_byte4_087, x, y); break;
- case 88: r = kernel_tex_image_interp(__tex_image_byte4_088, x, y); break;
+ case 89: r = kernel_tex_image_interp(__tex_image_byte4_089, x, y); break;
+ case 97: r = kernel_tex_image_interp(__tex_image_byte4_097, x, y); break;
+ case 105: r = kernel_tex_image_interp(__tex_image_byte4_105, x, y); break;
+ case 113: r = kernel_tex_image_interp(__tex_image_byte4_113, x, y); break;
+ case 121: r = kernel_tex_image_interp(__tex_image_byte4_121, x, y); break;
+ case 129: r = kernel_tex_image_interp(__tex_image_byte4_129, x, y); break;
+ case 137: r = kernel_tex_image_interp(__tex_image_byte4_137, x, y); break;
+ case 145: r = kernel_tex_image_interp(__tex_image_byte4_145, x, y); break;
+ case 153: r = kernel_tex_image_interp(__tex_image_byte4_153, x, y); break;
+ case 161: r = kernel_tex_image_interp(__tex_image_byte4_161, x, y); break;
+ case 169: r = kernel_tex_image_interp(__tex_image_byte4_169, x, y); break;
+ case 177: r = kernel_tex_image_interp(__tex_image_byte4_177, x, y); break;
+ case 185: r = kernel_tex_image_interp(__tex_image_byte4_185, x, y); break;
+ case 193: r = kernel_tex_image_interp(__tex_image_byte4_193, x, y); break;
+ case 201: r = kernel_tex_image_interp(__tex_image_byte4_201, x, y); break;
+ case 209: r = kernel_tex_image_interp(__tex_image_byte4_209, x, y); break;
+ case 217: r = kernel_tex_image_interp(__tex_image_byte4_217, x, y); break;
+ case 225: r = kernel_tex_image_interp(__tex_image_byte4_225, x, y); break;
+ case 233: r = kernel_tex_image_interp(__tex_image_byte4_233, x, y); break;
+ case 241: r = kernel_tex_image_interp(__tex_image_byte4_241, x, y); break;
+ case 249: r = kernel_tex_image_interp(__tex_image_byte4_249, x, y); break;
+ case 257: r = kernel_tex_image_interp(__tex_image_byte4_257, x, y); break;
+ case 265: r = kernel_tex_image_interp(__tex_image_byte4_265, x, y); break;
+ case 273: r = kernel_tex_image_interp(__tex_image_byte4_273, x, y); break;
+ case 281: r = kernel_tex_image_interp(__tex_image_byte4_281, x, y); break;
+ case 289: r = kernel_tex_image_interp(__tex_image_byte4_289, x, y); break;
+ case 297: r = kernel_tex_image_interp(__tex_image_byte4_297, x, y); break;
+ case 305: r = kernel_tex_image_interp(__tex_image_byte4_305, x, y); break;
+ case 313: r = kernel_tex_image_interp(__tex_image_byte4_313, x, y); break;
+ case 321: r = kernel_tex_image_interp(__tex_image_byte4_321, x, y); break;
+ case 329: r = kernel_tex_image_interp(__tex_image_byte4_329, x, y); break;
+ case 337: r = kernel_tex_image_interp(__tex_image_byte4_337, x, y); break;
+ case 345: r = kernel_tex_image_interp(__tex_image_byte4_345, x, y); break;
+ case 353: r = kernel_tex_image_interp(__tex_image_byte4_353, x, y); break;
+ case 361: r = kernel_tex_image_interp(__tex_image_byte4_361, x, y); break;
+ case 369: r = kernel_tex_image_interp(__tex_image_byte4_369, x, y); break;
+ case 377: r = kernel_tex_image_interp(__tex_image_byte4_377, x, y); break;
+ case 385: r = kernel_tex_image_interp(__tex_image_byte4_385, x, y); break;
+ case 393: r = kernel_tex_image_interp(__tex_image_byte4_393, x, y); break;
+ case 401: r = kernel_tex_image_interp(__tex_image_byte4_401, x, y); break;
+ case 409: r = kernel_tex_image_interp(__tex_image_byte4_409, x, y); break;
+ case 417: r = kernel_tex_image_interp(__tex_image_byte4_417, x, y); break;
+ case 425: r = kernel_tex_image_interp(__tex_image_byte4_425, x, y); break;
+ case 433: r = kernel_tex_image_interp(__tex_image_byte4_433, x, y); break;
+ case 441: r = kernel_tex_image_interp(__tex_image_byte4_441, x, y); break;
+ case 449: r = kernel_tex_image_interp(__tex_image_byte4_449, x, y); break;
+ case 457: r = kernel_tex_image_interp(__tex_image_byte4_457, x, y); break;
+ case 465: r = kernel_tex_image_interp(__tex_image_byte4_465, x, y); break;
+ case 473: r = kernel_tex_image_interp(__tex_image_byte4_473, x, y); break;
+ case 481: r = kernel_tex_image_interp(__tex_image_byte4_481, x, y); break;
+ case 489: r = kernel_tex_image_interp(__tex_image_byte4_489, x, y); break;
+ case 497: r = kernel_tex_image_interp(__tex_image_byte4_497, x, y); break;
+ case 505: r = kernel_tex_image_interp(__tex_image_byte4_505, x, y); break;
+ case 513: r = kernel_tex_image_interp(__tex_image_byte4_513, x, y); break;
+ case 521: r = kernel_tex_image_interp(__tex_image_byte4_521, x, y); break;
+ case 529: r = kernel_tex_image_interp(__tex_image_byte4_529, x, y); break;
+ case 537: r = kernel_tex_image_interp(__tex_image_byte4_537, x, y); break;
+ case 545: r = kernel_tex_image_interp(__tex_image_byte4_545, x, y); break;
+ case 553: r = kernel_tex_image_interp(__tex_image_byte4_553, x, y); break;
+ case 561: r = kernel_tex_image_interp(__tex_image_byte4_561, x, y); break;
+ case 569: r = kernel_tex_image_interp(__tex_image_byte4_569, x, y); break;
+ case 577: r = kernel_tex_image_interp(__tex_image_byte4_577, x, y); break;
+ case 585: r = kernel_tex_image_interp(__tex_image_byte4_585, x, y); break;
+ case 593: r = kernel_tex_image_interp(__tex_image_byte4_593, x, y); break;
+ case 601: r = kernel_tex_image_interp(__tex_image_byte4_601, x, y); break;
+ case 609: r = kernel_tex_image_interp(__tex_image_byte4_609, x, y); break;
+ case 617: r = kernel_tex_image_interp(__tex_image_byte4_617, x, y); break;
+ case 625: r = kernel_tex_image_interp(__tex_image_byte4_625, x, y); break;
+ case 633: r = kernel_tex_image_interp(__tex_image_byte4_633, x, y); break;
+ case 641: r = kernel_tex_image_interp(__tex_image_byte4_641, x, y); break;
+ case 649: r = kernel_tex_image_interp(__tex_image_byte4_649, x, y); break;
+ case 657: r = kernel_tex_image_interp(__tex_image_byte4_657, x, y); break;
+ case 665: r = kernel_tex_image_interp(__tex_image_byte4_665, x, y); break;
default:
kernel_assert(0);
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
@@ -224,6 +211,8 @@ ccl_device void svm_node_tex_image_box(KernelGlobals *kg, ShaderData *sd, float
object_inverse_normal_transform(kg, sd, &N);
/* project from direction vector to barycentric coordinates in triangles */
+ float3 signed_N = N;
+
N.x = fabsf(N.x);
N.y = fabsf(N.y);
N.z = fabsf(N.z);
@@ -293,12 +282,19 @@ ccl_device void svm_node_tex_image_box(KernelGlobals *kg, ShaderData *sd, float
float4 f = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
uint use_alpha = stack_valid(alpha_offset);
- if(weight.x > 0.0f)
- f += weight.x*svm_image_texture(kg, id, co.y, co.z, srgb, use_alpha);
- if(weight.y > 0.0f)
- f += weight.y*svm_image_texture(kg, id, co.x, co.z, srgb, use_alpha);
- if(weight.z > 0.0f)
- f += weight.z*svm_image_texture(kg, id, co.y, co.x, srgb, use_alpha);
+ /* Map so that no textures are flipped, rotation is somewhat arbitrary. */
+ if(weight.x > 0.0f) {
+ float2 uv = make_float2((signed_N.x < 0.0f)? 1.0f - co.y: co.y, co.z);
+ f += weight.x*svm_image_texture(kg, id, uv.x, uv.y, srgb, use_alpha);
+ }
+ if(weight.y > 0.0f) {
+ float2 uv = make_float2((signed_N.y > 0.0f)? 1.0f - co.x: co.x, co.z);
+ f += weight.y*svm_image_texture(kg, id, uv.x, uv.y, srgb, use_alpha);
+ }
+ if(weight.z > 0.0f) {
+ float2 uv = make_float2((signed_N.z > 0.0f)? 1.0f - co.y: co.y, co.x);
+ f += weight.z*svm_image_texture(kg, id, uv.x, uv.y, srgb, use_alpha);
+ }
if(stack_valid(out_offset))
stack_store_float3(stack, out_offset, make_float3(f.x, f.y, f.z));
diff --git a/intern/cycles/kernel/svm/svm_math_util.h b/intern/cycles/kernel/svm/svm_math_util.h
index a7f15de7325..1ce7777aac3 100644
--- a/intern/cycles/kernel/svm/svm_math_util.h
+++ b/intern/cycles/kernel/svm/svm_math_util.h
@@ -100,71 +100,64 @@ ccl_device float svm_math(NodeMath type, float Fac1, float Fac2)
return Fac;
}
-ccl_device float3 svm_math_blackbody_color(float t) {
- /* Calculate color in range 800..12000 using an approximation
- * a/x+bx+c for R and G and ((at + b)t + c)t + d) for B
- * Max absolute error for RGB is (0.00095, 0.00077, 0.00057),
- * which is enough to get the same 8 bit/channel color.
- */
-
- const float rc[6][3] = {
- { 2.52432244e+03f, -1.06185848e-03f, 3.11067539e+00f },
- { 3.37763626e+03f, -4.34581697e-04f, 1.64843306e+00f },
- { 4.10671449e+03f, -8.61949938e-05f, 6.41423749e-01f },
- { 4.66849800e+03f, 2.85655028e-05f, 1.29075375e-01f },
- { 4.60124770e+03f, 2.89727618e-05f, 1.48001316e-01f },
- { 3.78765709e+03f, 9.36026367e-06f, 3.98995841e-01f },
- };
-
- const float gc[6][3] = {
- { -7.50343014e+02f, 3.15679613e-04f, 4.73464526e-01f },
- { -1.00402363e+03f, 1.29189794e-04f, 9.08181524e-01f },
- { -1.22075471e+03f, 2.56245413e-05f, 1.20753416e+00f },
- { -1.42546105e+03f, -4.01730887e-05f, 1.44002695e+00f },
- { -1.18134453e+03f, -2.18913373e-05f, 1.30656109e+00f },
- { -5.00279505e+02f, -4.59745390e-06f, 1.09090465e+00f },
- };
-
- const float bc[6][4] = {
- { 0.0f, 0.0f, 0.0f, 0.0f }, /* zeros should be optimized by compiler */
- { 0.0f, 0.0f, 0.0f, 0.0f },
- { 0.0f, 0.0f, 0.0f, 0.0f },
- { -2.02524603e-11f, 1.79435860e-07f, -2.60561875e-04f, -1.41761141e-02f },
- { -2.22463426e-13f, -1.55078698e-08f, 3.81675160e-04f, -7.30646033e-01f },
- { 6.72595954e-13f, -2.73059993e-08f, 4.24068546e-04f, -7.52204323e-01f },
- };
-
- int i;
+/* Calculate color in range 800..12000 using an approximation
+ * a/x+bx+c for R and G and ((at + b)t + c)t + d) for B
+ * Max absolute error for RGB is (0.00095, 0.00077, 0.00057),
+ * which is enough to get the same 8 bit/channel color.
+ */
+
+ccl_static_constant float blackbody_table_r[6][3] = {
+ { 2.52432244e+03f, -1.06185848e-03f, 3.11067539e+00f },
+ { 3.37763626e+03f, -4.34581697e-04f, 1.64843306e+00f },
+ { 4.10671449e+03f, -8.61949938e-05f, 6.41423749e-01f },
+ { 4.66849800e+03f, 2.85655028e-05f, 1.29075375e-01f },
+ { 4.60124770e+03f, 2.89727618e-05f, 1.48001316e-01f },
+ { 3.78765709e+03f, 9.36026367e-06f, 3.98995841e-01f },
+};
+
+ccl_static_constant float blackbody_table_g[6][3] = {
+ { -7.50343014e+02f, 3.15679613e-04f, 4.73464526e-01f },
+ { -1.00402363e+03f, 1.29189794e-04f, 9.08181524e-01f },
+ { -1.22075471e+03f, 2.56245413e-05f, 1.20753416e+00f },
+ { -1.42546105e+03f, -4.01730887e-05f, 1.44002695e+00f },
+ { -1.18134453e+03f, -2.18913373e-05f, 1.30656109e+00f },
+ { -5.00279505e+02f, -4.59745390e-06f, 1.09090465e+00f },
+};
+
+ccl_static_constant float blackbody_table_b[6][4] = {
+ { 0.0f, 0.0f, 0.0f, 0.0f }, /* zeros should be optimized by compiler */
+ { 0.0f, 0.0f, 0.0f, 0.0f },
+ { 0.0f, 0.0f, 0.0f, 0.0f },
+ { -2.02524603e-11f, 1.79435860e-07f, -2.60561875e-04f, -1.41761141e-02f },
+ { -2.22463426e-13f, -1.55078698e-08f, 3.81675160e-04f, -7.30646033e-01f },
+ { 6.72595954e-13f, -2.73059993e-08f, 4.24068546e-04f, -7.52204323e-01f },
+};
+
+
+ccl_device float3 svm_math_blackbody_color(float t)
+{
if(t >= 12000.0f) {
return make_float3(0.826270103f, 0.994478524f, 1.56626022f);
}
- else if(t >= 6365.0f) {
- i = 5;
- }
- else if(t >= 3315.0f) {
- i = 4;
- }
- else if(t >= 1902.0f) {
- i = 3;
- }
- else if(t >= 1449.0f) {
- i = 2;
- }
- else if(t >= 1167.0f) {
- i = 1;
- }
- else if(t >= 965.0f) {
- i = 0;
- }
- else {
+ else if(t < 965.0f) {
/* For 800 <= t < 965 color does not change in OSL implementation, so keep color the same */
return make_float3(4.70366907f, 0.0f, 0.0f);
}
+ int i = (t >= 6365.0f)? 5:
+ (t >= 3315.0f)? 4:
+ (t >= 1902.0f)? 3:
+ (t >= 1449.0f)? 2:
+ (t >= 1167.0f)? 1: 0;
+
+ ccl_constant float *r = blackbody_table_r[i];
+ ccl_constant float *g = blackbody_table_g[i];
+ ccl_constant float *b = blackbody_table_b[i];
+
const float t_inv = 1.0f / t;
- return make_float3(rc[i][0] * t_inv + rc[i][1] * t + rc[i][2],
- gc[i][0] * t_inv + gc[i][1] * t + gc[i][2],
- ((bc[i][0] * t + bc[i][1]) * t + bc[i][2]) * t + bc[i][3]);
+ return make_float3(r[0] * t_inv + r[1] * t + r[2],
+ g[0] * t_inv + g[1] * t + g[2],
+ ((b[0] * t + b[1]) * t + b[2]) * t + b[3]);
}
ccl_device_inline float3 svm_math_gamma_color(float3 color, float gamma)
diff --git a/intern/cycles/kernel/svm/svm_wavelength.h b/intern/cycles/kernel/svm/svm_wavelength.h
index 57030f3979d..855b356b397 100644
--- a/intern/cycles/kernel/svm/svm_wavelength.h
+++ b/intern/cycles/kernel/svm/svm_wavelength.h
@@ -34,44 +34,44 @@ CCL_NAMESPACE_BEGIN
/* Wavelength to RGB */
+// CIE colour matching functions xBar, yBar, and zBar for
+// wavelengths from 380 through 780 nanometers, every 5
+// nanometers. For a wavelength lambda in this range:
+// cie_colour_match[(lambda - 380) / 5][0] = xBar
+// cie_colour_match[(lambda - 380) / 5][1] = yBar
+// cie_colour_match[(lambda - 380) / 5][2] = zBar
+ccl_static_constant float cie_colour_match[81][3] = {
+ {0.0014f,0.0000f,0.0065f}, {0.0022f,0.0001f,0.0105f}, {0.0042f,0.0001f,0.0201f},
+ {0.0076f,0.0002f,0.0362f}, {0.0143f,0.0004f,0.0679f}, {0.0232f,0.0006f,0.1102f},
+ {0.0435f,0.0012f,0.2074f}, {0.0776f,0.0022f,0.3713f}, {0.1344f,0.0040f,0.6456f},
+ {0.2148f,0.0073f,1.0391f}, {0.2839f,0.0116f,1.3856f}, {0.3285f,0.0168f,1.6230f},
+ {0.3483f,0.0230f,1.7471f}, {0.3481f,0.0298f,1.7826f}, {0.3362f,0.0380f,1.7721f},
+ {0.3187f,0.0480f,1.7441f}, {0.2908f,0.0600f,1.6692f}, {0.2511f,0.0739f,1.5281f},
+ {0.1954f,0.0910f,1.2876f}, {0.1421f,0.1126f,1.0419f}, {0.0956f,0.1390f,0.8130f},
+ {0.0580f,0.1693f,0.6162f}, {0.0320f,0.2080f,0.4652f}, {0.0147f,0.2586f,0.3533f},
+ {0.0049f,0.3230f,0.2720f}, {0.0024f,0.4073f,0.2123f}, {0.0093f,0.5030f,0.1582f},
+ {0.0291f,0.6082f,0.1117f}, {0.0633f,0.7100f,0.0782f}, {0.1096f,0.7932f,0.0573f},
+ {0.1655f,0.8620f,0.0422f}, {0.2257f,0.9149f,0.0298f}, {0.2904f,0.9540f,0.0203f},
+ {0.3597f,0.9803f,0.0134f}, {0.4334f,0.9950f,0.0087f}, {0.5121f,1.0000f,0.0057f},
+ {0.5945f,0.9950f,0.0039f}, {0.6784f,0.9786f,0.0027f}, {0.7621f,0.9520f,0.0021f},
+ {0.8425f,0.9154f,0.0018f}, {0.9163f,0.8700f,0.0017f}, {0.9786f,0.8163f,0.0014f},
+ {1.0263f,0.7570f,0.0011f}, {1.0567f,0.6949f,0.0010f}, {1.0622f,0.6310f,0.0008f},
+ {1.0456f,0.5668f,0.0006f}, {1.0026f,0.5030f,0.0003f}, {0.9384f,0.4412f,0.0002f},
+ {0.8544f,0.3810f,0.0002f}, {0.7514f,0.3210f,0.0001f}, {0.6424f,0.2650f,0.0000f},
+ {0.5419f,0.2170f,0.0000f}, {0.4479f,0.1750f,0.0000f}, {0.3608f,0.1382f,0.0000f},
+ {0.2835f,0.1070f,0.0000f}, {0.2187f,0.0816f,0.0000f}, {0.1649f,0.0610f,0.0000f},
+ {0.1212f,0.0446f,0.0000f}, {0.0874f,0.0320f,0.0000f}, {0.0636f,0.0232f,0.0000f},
+ {0.0468f,0.0170f,0.0000f}, {0.0329f,0.0119f,0.0000f}, {0.0227f,0.0082f,0.0000f},
+ {0.0158f,0.0057f,0.0000f}, {0.0114f,0.0041f,0.0000f}, {0.0081f,0.0029f,0.0000f},
+ {0.0058f,0.0021f,0.0000f}, {0.0041f,0.0015f,0.0000f}, {0.0029f,0.0010f,0.0000f},
+ {0.0020f,0.0007f,0.0000f}, {0.0014f,0.0005f,0.0000f}, {0.0010f,0.0004f,0.0000f},
+ {0.0007f,0.0002f,0.0000f}, {0.0005f,0.0002f,0.0000f}, {0.0003f,0.0001f,0.0000f},
+ {0.0002f,0.0001f,0.0000f}, {0.0002f,0.0001f,0.0000f}, {0.0001f,0.0000f,0.0000f},
+ {0.0001f,0.0000f,0.0000f}, {0.0001f,0.0000f,0.0000f}, {0.0000f,0.0000f,0.0000f}
+};
+
ccl_device void svm_node_wavelength(ShaderData *sd, float *stack, uint wavelength, uint color_out)
{
- // CIE colour matching functions xBar, yBar, and zBar for
- // wavelengths from 380 through 780 nanometers, every 5
- // nanometers. For a wavelength lambda in this range:
- // cie_colour_match[(lambda - 380) / 5][0] = xBar
- // cie_colour_match[(lambda - 380) / 5][1] = yBar
- // cie_colour_match[(lambda - 380) / 5][2] = zBar
- const float cie_colour_match[81][3] = {
- {0.0014f,0.0000f,0.0065f}, {0.0022f,0.0001f,0.0105f}, {0.0042f,0.0001f,0.0201f},
- {0.0076f,0.0002f,0.0362f}, {0.0143f,0.0004f,0.0679f}, {0.0232f,0.0006f,0.1102f},
- {0.0435f,0.0012f,0.2074f}, {0.0776f,0.0022f,0.3713f}, {0.1344f,0.0040f,0.6456f},
- {0.2148f,0.0073f,1.0391f}, {0.2839f,0.0116f,1.3856f}, {0.3285f,0.0168f,1.6230f},
- {0.3483f,0.0230f,1.7471f}, {0.3481f,0.0298f,1.7826f}, {0.3362f,0.0380f,1.7721f},
- {0.3187f,0.0480f,1.7441f}, {0.2908f,0.0600f,1.6692f}, {0.2511f,0.0739f,1.5281f},
- {0.1954f,0.0910f,1.2876f}, {0.1421f,0.1126f,1.0419f}, {0.0956f,0.1390f,0.8130f},
- {0.0580f,0.1693f,0.6162f}, {0.0320f,0.2080f,0.4652f}, {0.0147f,0.2586f,0.3533f},
- {0.0049f,0.3230f,0.2720f}, {0.0024f,0.4073f,0.2123f}, {0.0093f,0.5030f,0.1582f},
- {0.0291f,0.6082f,0.1117f}, {0.0633f,0.7100f,0.0782f}, {0.1096f,0.7932f,0.0573f},
- {0.1655f,0.8620f,0.0422f}, {0.2257f,0.9149f,0.0298f}, {0.2904f,0.9540f,0.0203f},
- {0.3597f,0.9803f,0.0134f}, {0.4334f,0.9950f,0.0087f}, {0.5121f,1.0000f,0.0057f},
- {0.5945f,0.9950f,0.0039f}, {0.6784f,0.9786f,0.0027f}, {0.7621f,0.9520f,0.0021f},
- {0.8425f,0.9154f,0.0018f}, {0.9163f,0.8700f,0.0017f}, {0.9786f,0.8163f,0.0014f},
- {1.0263f,0.7570f,0.0011f}, {1.0567f,0.6949f,0.0010f}, {1.0622f,0.6310f,0.0008f},
- {1.0456f,0.5668f,0.0006f}, {1.0026f,0.5030f,0.0003f}, {0.9384f,0.4412f,0.0002f},
- {0.8544f,0.3810f,0.0002f}, {0.7514f,0.3210f,0.0001f}, {0.6424f,0.2650f,0.0000f},
- {0.5419f,0.2170f,0.0000f}, {0.4479f,0.1750f,0.0000f}, {0.3608f,0.1382f,0.0000f},
- {0.2835f,0.1070f,0.0000f}, {0.2187f,0.0816f,0.0000f}, {0.1649f,0.0610f,0.0000f},
- {0.1212f,0.0446f,0.0000f}, {0.0874f,0.0320f,0.0000f}, {0.0636f,0.0232f,0.0000f},
- {0.0468f,0.0170f,0.0000f}, {0.0329f,0.0119f,0.0000f}, {0.0227f,0.0082f,0.0000f},
- {0.0158f,0.0057f,0.0000f}, {0.0114f,0.0041f,0.0000f}, {0.0081f,0.0029f,0.0000f},
- {0.0058f,0.0021f,0.0000f}, {0.0041f,0.0015f,0.0000f}, {0.0029f,0.0010f,0.0000f},
- {0.0020f,0.0007f,0.0000f}, {0.0014f,0.0005f,0.0000f}, {0.0010f,0.0004f,0.0000f},
- {0.0007f,0.0002f,0.0000f}, {0.0005f,0.0002f,0.0000f}, {0.0003f,0.0001f,0.0000f},
- {0.0002f,0.0001f,0.0000f}, {0.0002f,0.0001f,0.0000f}, {0.0001f,0.0000f,0.0000f},
- {0.0001f,0.0000f,0.0000f}, {0.0001f,0.0000f,0.0000f}, {0.0000f,0.0000f,0.0000f}
- };
-
float lambda_nm = stack_load_float(stack, wavelength);
float ii = (lambda_nm-380.0f) * (1.0f/5.0f); // scaled 0..80
int i = float_to_int(ii);
@@ -82,7 +82,7 @@ ccl_device void svm_node_wavelength(ShaderData *sd, float *stack, uint wavelengt
}
else {
ii -= i;
- const float *c = cie_colour_match[i];
+ ccl_constant float *c = cie_colour_match[i];
color = interp(make_float3(c[0], c[1], c[2]), make_float3(c[3], c[4], c[5]), ii);
}
@@ -92,8 +92,7 @@ ccl_device void svm_node_wavelength(ShaderData *sd, float *stack, uint wavelengt
/* Clamp to zero if values are smaller */
color = max(color, make_float3(0.0f, 0.0f, 0.0f));
- if(stack_valid(color_out))
- stack_store_float3(stack, color_out, color);
+ stack_store_float3(stack, color_out, color);
}
CCL_NAMESPACE_END
diff --git a/intern/cycles/render/bake.cpp b/intern/cycles/render/bake.cpp
index c0fcd517390..2bedf3668f7 100644
--- a/intern/cycles/render/bake.cpp
+++ b/intern/cycles/render/bake.cpp
@@ -174,6 +174,7 @@ bool BakeManager::bake(Device *device, DeviceScene *dscene, Scene *scene, Progre
device->mem_alloc("bake_input", d_input, MEM_READ_ONLY);
device->mem_copy_to(d_input);
device->mem_alloc("bake_output", d_output, MEM_READ_WRITE);
+ device->mem_zero(d_output);
DeviceTask task(DeviceTask::SHADER);
task.shader_input = d_input.device_pointer;
diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp
index ff6f40c010e..a7a1260e425 100644
--- a/intern/cycles/render/buffers.cpp
+++ b/intern/cycles/render/buffers.cpp
@@ -108,7 +108,6 @@ RenderTile::RenderTile()
stride = 0;
buffer = 0;
- rng_state = 0;
buffers = NULL;
}
@@ -131,11 +130,6 @@ void RenderBuffers::device_free()
device->mem_free(buffer);
buffer.clear();
}
-
- if(rng_state.device_pointer) {
- device->mem_free(rng_state);
- rng_state.clear();
- }
}
void RenderBuffers::reset(Device *device, BufferParams& params_)
@@ -149,11 +143,13 @@ void RenderBuffers::reset(Device *device, BufferParams& params_)
buffer.resize(params.width*params.height*params.get_passes_size());
device->mem_alloc("render_buffer", buffer, MEM_READ_WRITE);
device->mem_zero(buffer);
+}
- /* allocate rng state */
- rng_state.resize(params.width, params.height);
-
- device->mem_alloc("rng_state", rng_state, MEM_READ_WRITE);
+void RenderBuffers::zero(Device *device)
+{
+ if(buffer.device_pointer) {
+ device->mem_zero(buffer);
+ }
}
bool RenderBuffers::copy_from_device(Device *from_device)
diff --git a/intern/cycles/render/buffers.h b/intern/cycles/render/buffers.h
index e56556c8abe..2780fc8a68d 100644
--- a/intern/cycles/render/buffers.h
+++ b/intern/cycles/render/buffers.h
@@ -74,8 +74,6 @@ public:
/* float buffer */
device_vector<float> buffer;
- /* random number generator state */
- device_vector<uint> rng_state;
Device *device;
@@ -83,6 +81,7 @@ public:
~RenderBuffers();
void reset(Device *device, BufferParams& params);
+ void zero(Device *device);
bool copy_from_device(Device *from_device = NULL);
bool get_pass_rect(PassType type, float exposure, int sample, int components, float *pixels);
@@ -149,7 +148,6 @@ public:
int tile_index;
device_ptr buffer;
- device_ptr rng_state;
RenderBuffers *buffers;
diff --git a/intern/cycles/render/constant_fold.cpp b/intern/cycles/render/constant_fold.cpp
index 2569d9eec27..943b218f0e4 100644
--- a/intern/cycles/render/constant_fold.cpp
+++ b/intern/cycles/render/constant_fold.cpp
@@ -160,6 +160,14 @@ bool ConstantFolder::try_bypass_or_make_constant(ShaderInput *input, bool clamp)
bypass(input->link);
return true;
}
+ else {
+ /* disconnect other inputs if we can't fully bypass due to clamp */
+ foreach(ShaderInput *other, node->inputs) {
+ if(other != input && other->link) {
+ graph->disconnect(other);
+ }
+ }
+ }
return false;
}
diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp
index 2d810ff664f..08203163d1a 100644
--- a/intern/cycles/render/graph.cpp
+++ b/intern/cycles/render/graph.cpp
@@ -221,28 +221,6 @@ OutputNode *ShaderGraph::output()
return (OutputNode*)nodes.front();
}
-ShaderGraph *ShaderGraph::copy()
-{
- ShaderGraph *newgraph = new ShaderGraph();
-
- /* copy nodes */
- ShaderNodeSet nodes_all;
- foreach(ShaderNode *node, nodes)
- nodes_all.insert(node);
-
- ShaderNodeMap nodes_copy;
- copy_nodes(nodes_all, nodes_copy);
-
- /* add nodes (in same order, so output is still first) */
- newgraph->clear_nodes();
- foreach(ShaderNode *node, nodes)
- newgraph->add(nodes_copy[node]);
-
- newgraph->simplified = simplified;
-
- return newgraph;
-}
-
void ShaderGraph::connect(ShaderOutput *from, ShaderInput *to)
{
assert(!finalized);
@@ -1040,6 +1018,9 @@ int ShaderGraph::get_num_closures()
else if(CLOSURE_IS_PRINCIPLED(closure_type)) {
num_closures += 8;
}
+ else if(CLOSURE_IS_VOLUME(closure_type)) {
+ num_closures += VOLUME_STACK_SIZE;
+ }
else {
++num_closures;
}
diff --git a/intern/cycles/render/graph.h b/intern/cycles/render/graph.h
index 72e391991a7..f0fd789c6bd 100644
--- a/intern/cycles/render/graph.h
+++ b/intern/cycles/render/graph.h
@@ -151,6 +151,7 @@ public:
virtual bool has_surface_emission() { return false; }
virtual bool has_surface_transparent() { return false; }
virtual bool has_surface_bssrdf() { return false; }
+ virtual bool has_bump() { return false; }
virtual bool has_bssrdf_bump() { return false; }
virtual bool has_spatial_varying() { return false; }
virtual bool has_object_dependency() { return false; }
@@ -245,8 +246,6 @@ public:
ShaderGraph();
~ShaderGraph();
- ShaderGraph *copy();
-
ShaderNode *add(ShaderNode *node);
OutputNode *output();
diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp
index f4482e0bb25..bb94b9bb82a 100644
--- a/intern/cycles/render/image.cpp
+++ b/intern/cycles/render/image.cpp
@@ -43,7 +43,6 @@ static bool isfinite(half /*value*/)
ImageManager::ImageManager(const DeviceInfo& info)
{
need_update = true;
- pack_images = false;
osl_texture_system = NULL;
animation_frame = 0;
@@ -87,11 +86,6 @@ ImageManager::~ImageManager()
}
}
-void ImageManager::set_pack_images(bool pack_images_)
-{
- pack_images = pack_images_;
-}
-
void ImageManager::set_osl_texture_system(void *texture_system)
{
osl_texture_system = texture_system;
@@ -115,16 +109,18 @@ bool ImageManager::set_animation_frame_update(int frame)
ImageDataType ImageManager::get_image_metadata(const string& filename,
void *builtin_data,
- bool& is_linear)
+ bool& is_linear,
+ bool& builtin_free_cache)
{
bool is_float = false, is_half = false;
is_linear = false;
+ builtin_free_cache = false;
int channels = 4;
if(builtin_data) {
if(builtin_image_info_cb) {
int width, height, depth;
- builtin_image_info_cb(filename, builtin_data, is_float, width, height, depth, channels);
+ builtin_image_info_cb(filename, builtin_data, is_float, width, height, depth, channels, builtin_free_cache);
}
if(is_float) {
@@ -218,37 +214,14 @@ int ImageManager::max_flattened_slot(ImageDataType type)
/* The lower three bits of a device texture slot number indicate its type.
* These functions convert the slot ids from ImageManager "images" ones
* to device ones and vice verse.
- *
- * There are special cases for CUDA Fermi, since there we have only 90 image texture
- * slots available and should keep the flattended numbers in the 0-89 range.
*/
int ImageManager::type_index_to_flattened_slot(int slot, ImageDataType type)
{
- if(cuda_fermi_limits) {
- if(type == IMAGE_DATA_TYPE_BYTE4) {
- return slot + TEX_START_BYTE4_CUDA;
- }
- else {
- return slot;
- }
- }
-
return (slot << IMAGE_DATA_TYPE_SHIFT) | (type);
}
int ImageManager::flattened_slot_to_type_index(int flat_slot, ImageDataType *type)
{
- if(cuda_fermi_limits) {
- if(flat_slot >= 4) {
- *type = IMAGE_DATA_TYPE_BYTE4;
- return flat_slot - TEX_START_BYTE4_CUDA;
- }
- else {
- *type = IMAGE_DATA_TYPE_FLOAT4;
- return flat_slot;
- }
- }
-
*type = (ImageDataType)(flat_slot & IMAGE_DATA_TYPE_MASK);
return flat_slot >> IMAGE_DATA_TYPE_SHIFT;
}
@@ -295,8 +268,9 @@ int ImageManager::add_image(const string& filename,
{
Image *img;
size_t slot;
+ bool builtin_free_cache;
- ImageDataType type = get_image_metadata(filename, builtin_data, is_linear);
+ ImageDataType type = get_image_metadata(filename, builtin_data, is_linear, builtin_free_cache);
thread_scoped_lock device_lock(device_mutex);
@@ -364,7 +338,7 @@ int ImageManager::add_image(const string& filename,
else {
/* Very unlikely, since max_num_images is insanely big. But better safe than sorry. */
int tex_count = 0;
- for (int type = 0; type < IMAGE_DATA_NUM_TYPES; type++) {
+ for(int type = 0; type < IMAGE_DATA_NUM_TYPES; type++) {
tex_count += tex_num_images[type];
}
if(tex_count > max_num_images) {
@@ -382,6 +356,7 @@ int ImageManager::add_image(const string& filename,
img = new Image();
img->filename = filename;
img->builtin_data = builtin_data;
+ img->builtin_free_cache = builtin_free_cache;
img->need_load = true;
img->animated = animated;
img->frame = frame;
@@ -467,7 +442,12 @@ void ImageManager::tag_reload_image(const string& filename,
}
}
-bool ImageManager::file_load_image_generic(Image *img, ImageInput **in, int &width, int &height, int &depth, int &components)
+bool ImageManager::file_load_image_generic(Image *img,
+ ImageInput **in,
+ int &width,
+ int &height,
+ int &depth,
+ int &components)
{
if(img->filename == "")
return false;
@@ -506,8 +486,8 @@ bool ImageManager::file_load_image_generic(Image *img, ImageInput **in, int &wid
if(!builtin_image_info_cb || !builtin_image_pixels_cb)
return false;
- bool is_float;
- builtin_image_info_cb(img->filename, img->builtin_data, is_float, width, height, depth, components);
+ bool is_float, free_cache;
+ builtin_image_info_cb(img->filename, img->builtin_data, is_float, width, height, depth, components, free_cache);
}
/* we only handle certain number of components */
@@ -542,6 +522,10 @@ bool ImageManager::file_load_image(Image *img,
vector<StorageType> pixels_storage;
StorageType *pixels;
const size_t max_size = max(max(width, height), depth);
+ if(max_size == 0) {
+ /* Don't bother with invalid images. */
+ return false;
+ }
if(texture_limit > 0 && max_size > texture_limit) {
pixels_storage.resize(((size_t)width)*height*depth*4);
pixels = &pixels_storage[0];
@@ -549,6 +533,10 @@ bool ImageManager::file_load_image(Image *img,
else {
pixels = (StorageType*)tex_img.resize(width, height, depth);
}
+ if(pixels == NULL) {
+ /* Could be that we've run out of memory. */
+ return false;
+ }
bool cmyk = false;
const size_t num_pixels = ((size_t)width) * height * depth;
if(in) {
@@ -588,13 +576,15 @@ bool ImageManager::file_load_image(Image *img,
builtin_image_float_pixels_cb(img->filename,
img->builtin_data,
(float*)&pixels[0],
- num_pixels * components);
+ num_pixels * components,
+ img->builtin_free_cache);
}
else if(FileFormat == TypeDesc::UINT8) {
builtin_image_pixels_cb(img->filename,
img->builtin_data,
(uchar*)&pixels[0],
- num_pixels * components);
+ num_pixels * components,
+ img->builtin_free_cache);
}
else {
/* TODO(dingto): Support half for ImBuf. */
@@ -754,7 +744,7 @@ void ImageManager::device_load_image(Device *device,
pixels[3] = TEX_IMAGE_MISSING_A;
}
- if(!pack_images) {
+ {
thread_scoped_lock device_lock(device_mutex);
device->tex_alloc(name.c_str(),
tex_img,
@@ -783,7 +773,7 @@ void ImageManager::device_load_image(Device *device,
pixels[0] = TEX_IMAGE_MISSING_R;
}
- if(!pack_images) {
+ {
thread_scoped_lock device_lock(device_mutex);
device->tex_alloc(name.c_str(),
tex_img,
@@ -815,7 +805,7 @@ void ImageManager::device_load_image(Device *device,
pixels[3] = (TEX_IMAGE_MISSING_A * 255);
}
- if(!pack_images) {
+ {
thread_scoped_lock device_lock(device_mutex);
device->tex_alloc(name.c_str(),
tex_img,
@@ -843,7 +833,7 @@ void ImageManager::device_load_image(Device *device,
pixels[0] = (TEX_IMAGE_MISSING_R * 255);
}
- if(!pack_images) {
+ {
thread_scoped_lock device_lock(device_mutex);
device->tex_alloc(name.c_str(),
tex_img,
@@ -874,7 +864,7 @@ void ImageManager::device_load_image(Device *device,
pixels[3] = TEX_IMAGE_MISSING_A;
}
- if(!pack_images) {
+ {
thread_scoped_lock device_lock(device_mutex);
device->tex_alloc(name.c_str(),
tex_img,
@@ -902,7 +892,7 @@ void ImageManager::device_load_image(Device *device,
pixels[0] = TEX_IMAGE_MISSING_R;
}
- if(!pack_images) {
+ {
thread_scoped_lock device_lock(device_mutex);
device->tex_alloc(name.c_str(),
tex_img,
@@ -1059,9 +1049,6 @@ void ImageManager::device_update(Device *device,
pool.wait_work();
- if(pack_images)
- device_pack_images(device, dscene, progress);
-
need_update = false;
}
@@ -1091,141 +1078,6 @@ void ImageManager::device_update_slot(Device *device,
}
}
-uint8_t ImageManager::pack_image_options(ImageDataType type, size_t slot)
-{
- uint8_t options = 0;
- /* Image Options are packed into one uint:
- * bit 0 -> Interpolation
- * bit 1 + 2 + 3 -> Extension
- */
- if(images[type][slot]->interpolation == INTERPOLATION_CLOSEST) {
- options |= (1 << 0);
- }
- if(images[type][slot]->extension == EXTENSION_REPEAT) {
- options |= (1 << 1);
- }
- else if(images[type][slot]->extension == EXTENSION_EXTEND) {
- options |= (1 << 2);
- }
- else /* EXTENSION_CLIP */ {
- options |= (1 << 3);
- }
- return options;
-}
-
-template<typename T>
-void ImageManager::device_pack_images_type(
- ImageDataType type,
- const vector<device_vector<T>*>& cpu_textures,
- device_vector<T> *device_image,
- uint4 *info)
-{
- size_t size = 0, offset = 0;
- /* First step is to calculate size of the texture we need. */
- for(size_t slot = 0; slot < images[type].size(); slot++) {
- if(images[type][slot] == NULL) {
- continue;
- }
- device_vector<T>& tex_img = *cpu_textures[slot];
- size += tex_img.size();
- }
- /* Now we know how much memory we need, so we can allocate and fill. */
- T *pixels = device_image->resize(size);
- for(size_t slot = 0; slot < images[type].size(); slot++) {
- if(images[type][slot] == NULL) {
- continue;
- }
- device_vector<T>& tex_img = *cpu_textures[slot];
- uint8_t options = pack_image_options(type, slot);
- const int index = type_index_to_flattened_slot(slot, type) * 2;
- info[index] = make_uint4(tex_img.data_width,
- tex_img.data_height,
- offset,
- options);
- info[index+1] = make_uint4(tex_img.data_depth, 0, 0, 0);
- memcpy(pixels + offset,
- (void*)tex_img.data_pointer,
- tex_img.memory_size());
- offset += tex_img.size();
- }
-}
-
-void ImageManager::device_pack_images(Device *device,
- DeviceScene *dscene,
- Progress& /*progess*/)
-{
- /* For OpenCL, we pack all image textures into a single large texture, and
- * do our own interpolation in the kernel.
- */
-
- /* TODO(sergey): This will over-allocate a bit, but this is constant memory
- * so should be fine for a short term.
- */
- const size_t info_size = max4(max_flattened_slot(IMAGE_DATA_TYPE_FLOAT4),
- max_flattened_slot(IMAGE_DATA_TYPE_BYTE4),
- max_flattened_slot(IMAGE_DATA_TYPE_FLOAT),
- max_flattened_slot(IMAGE_DATA_TYPE_BYTE));
- uint4 *info = dscene->tex_image_packed_info.resize(info_size*2);
-
- /* Pack byte4 textures. */
- device_pack_images_type(IMAGE_DATA_TYPE_BYTE4,
- dscene->tex_byte4_image,
- &dscene->tex_image_byte4_packed,
- info);
- /* Pack float4 textures. */
- device_pack_images_type(IMAGE_DATA_TYPE_FLOAT4,
- dscene->tex_float4_image,
- &dscene->tex_image_float4_packed,
- info);
- /* Pack byte textures. */
- device_pack_images_type(IMAGE_DATA_TYPE_BYTE,
- dscene->tex_byte_image,
- &dscene->tex_image_byte_packed,
- info);
- /* Pack float textures. */
- device_pack_images_type(IMAGE_DATA_TYPE_FLOAT,
- dscene->tex_float_image,
- &dscene->tex_image_float_packed,
- info);
-
- /* Push textures to the device. */
- if(dscene->tex_image_byte4_packed.size()) {
- if(dscene->tex_image_byte4_packed.device_pointer) {
- thread_scoped_lock device_lock(device_mutex);
- device->tex_free(dscene->tex_image_byte4_packed);
- }
- device->tex_alloc("__tex_image_byte4_packed", dscene->tex_image_byte4_packed);
- }
- if(dscene->tex_image_float4_packed.size()) {
- if(dscene->tex_image_float4_packed.device_pointer) {
- thread_scoped_lock device_lock(device_mutex);
- device->tex_free(dscene->tex_image_float4_packed);
- }
- device->tex_alloc("__tex_image_float4_packed", dscene->tex_image_float4_packed);
- }
- if(dscene->tex_image_byte_packed.size()) {
- if(dscene->tex_image_byte_packed.device_pointer) {
- thread_scoped_lock device_lock(device_mutex);
- device->tex_free(dscene->tex_image_byte_packed);
- }
- device->tex_alloc("__tex_image_byte_packed", dscene->tex_image_byte_packed);
- }
- if(dscene->tex_image_float_packed.size()) {
- if(dscene->tex_image_float_packed.device_pointer) {
- thread_scoped_lock device_lock(device_mutex);
- device->tex_free(dscene->tex_image_float_packed);
- }
- device->tex_alloc("__tex_image_float_packed", dscene->tex_image_float_packed);
- }
- if(dscene->tex_image_packed_info.size()) {
- if(dscene->tex_image_packed_info.device_pointer) {
- thread_scoped_lock device_lock(device_mutex);
- device->tex_free(dscene->tex_image_packed_info);
- }
- device->tex_alloc("__tex_image_packed_info", dscene->tex_image_packed_info);
- }
-}
-
void ImageManager::device_free_builtin(Device *device, DeviceScene *dscene)
{
for(int type = 0; type < IMAGE_DATA_NUM_TYPES; type++) {
@@ -1251,18 +1103,6 @@ void ImageManager::device_free(Device *device, DeviceScene *dscene)
dscene->tex_float_image.clear();
dscene->tex_byte_image.clear();
dscene->tex_half_image.clear();
-
- device->tex_free(dscene->tex_image_float4_packed);
- device->tex_free(dscene->tex_image_byte4_packed);
- device->tex_free(dscene->tex_image_float_packed);
- device->tex_free(dscene->tex_image_byte_packed);
- device->tex_free(dscene->tex_image_packed_info);
-
- dscene->tex_image_float4_packed.clear();
- dscene->tex_image_byte4_packed.clear();
- dscene->tex_image_float_packed.clear();
- dscene->tex_image_byte_packed.clear();
- dscene->tex_image_packed_info.clear();
}
CCL_NAMESPACE_END
diff --git a/intern/cycles/render/image.h b/intern/cycles/render/image.h
index 77214bf25bc..c86d1cbedbf 100644
--- a/intern/cycles/render/image.h
+++ b/intern/cycles/render/image.h
@@ -57,7 +57,10 @@ public:
InterpolationType interpolation,
ExtensionType extension,
bool use_alpha);
- ImageDataType get_image_metadata(const string& filename, void *builtin_data, bool& is_linear);
+ ImageDataType get_image_metadata(const string& filename,
+ void *builtin_data,
+ bool& is_linear,
+ bool& builtin_free_cache);
void device_prepare_update(DeviceScene *dscene);
void device_update(Device *device,
@@ -73,7 +76,6 @@ public:
void device_free_builtin(Device *device, DeviceScene *dscene);
void set_osl_texture_system(void *texture_system);
- void set_pack_images(bool pack_images_);
bool set_animation_frame_update(int frame);
bool need_update;
@@ -88,19 +90,23 @@ public:
int &width,
int &height,
int &depth,
- int &channels)> builtin_image_info_cb;
+ int &channels,
+ bool &free_cache)> builtin_image_info_cb;
function<bool(const string &filename,
void *data,
unsigned char *pixels,
- const size_t pixels_size)> builtin_image_pixels_cb;
+ const size_t pixels_size,
+ const bool free_cache)> builtin_image_pixels_cb;
function<bool(const string &filename,
void *data,
float *pixels,
- const size_t pixels_size)> builtin_image_float_pixels_cb;
+ const size_t pixels_size,
+ const bool free_cache)> builtin_image_float_pixels_cb;
struct Image {
string filename;
void *builtin_data;
+ bool builtin_free_cache;
bool use_alpha;
bool need_load;
@@ -123,9 +129,13 @@ private:
vector<Image*> images[IMAGE_DATA_NUM_TYPES];
void *osl_texture_system;
- bool pack_images;
- bool file_load_image_generic(Image *img, ImageInput **in, int &width, int &height, int &depth, int &components);
+ bool file_load_image_generic(Image *img,
+ ImageInput **in,
+ int &width,
+ int &height,
+ int &depth,
+ int &components);
template<TypeDesc::BASETYPE FileFormat,
typename StorageType,
@@ -140,8 +150,6 @@ private:
int flattened_slot_to_type_index(int flat_slot, ImageDataType *type);
string name_from_type(int type);
- uint8_t pack_image_options(ImageDataType type, size_t slot);
-
void device_load_image(Device *device,
DeviceScene *dscene,
Scene *scene,
@@ -152,17 +160,6 @@ private:
DeviceScene *dscene,
ImageDataType type,
int slot);
-
- template<typename T>
- void device_pack_images_type(
- ImageDataType type,
- const vector<device_vector<T>*>& cpu_textures,
- device_vector<T> *device_image,
- uint4 *info);
-
- void device_pack_images(Device *device,
- DeviceScene *dscene,
- Progress& progess);
};
CCL_NAMESPACE_END
diff --git a/intern/cycles/render/integrator.cpp b/intern/cycles/render/integrator.cpp
index a004bb5b856..15b728d6e02 100644
--- a/intern/cycles/render/integrator.cpp
+++ b/intern/cycles/render/integrator.cpp
@@ -31,7 +31,6 @@ NODE_DEFINE(Integrator)
{
NodeType *type = NodeType::add("integrator", create);
- SOCKET_INT(min_bounce, "Min Bounce", 2);
SOCKET_INT(max_bounce, "Max Bounce", 7);
SOCKET_INT(max_diffuse_bounce, "Max Diffuse Bounce", 7);
@@ -39,9 +38,7 @@ NODE_DEFINE(Integrator)
SOCKET_INT(max_transmission_bounce, "Max Transmission Bounce", 7);
SOCKET_INT(max_volume_bounce, "Max Volume Bounce", 7);
- SOCKET_INT(transparent_min_bounce, "Transparent Min Bounce", 2);
SOCKET_INT(transparent_max_bounce, "Transparent Max Bounce", 7);
- SOCKET_BOOLEAN(transparent_shadows, "Transparent Shadows", false);
SOCKET_INT(ao_bounces, "AO Bounces", 0);
@@ -104,7 +101,6 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene
/* integrator parameters */
kintegrator->max_bounce = max_bounce + 1;
- kintegrator->min_bounce = min_bounce + 1;
kintegrator->max_diffuse_bounce = max_diffuse_bounce + 1;
kintegrator->max_glossy_bounce = max_glossy_bounce + 1;
@@ -112,7 +108,6 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene
kintegrator->max_volume_bounce = max_volume_bounce + 1;
kintegrator->transparent_max_bounce = transparent_max_bounce + 1;
- kintegrator->transparent_min_bounce = transparent_min_bounce + 1;
if(ao_bounces == 0) {
kintegrator->ao_bounces = INT_MAX;
@@ -125,19 +120,14 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene
* We only need to enable transparent shadows, if we actually have
* transparent shaders in the scene. Otherwise we can disable it
* to improve performance a bit. */
- if(transparent_shadows) {
- kintegrator->transparent_shadows = false;
- foreach(Shader *shader, scene->shaders) {
- /* keep this in sync with SD_HAS_TRANSPARENT_SHADOW in shader.cpp */
- if((shader->has_surface_transparent && shader->use_transparent_shadow) || shader->has_volume) {
- kintegrator->transparent_shadows = true;
- break;
- }
+ kintegrator->transparent_shadows = false;
+ foreach(Shader *shader, scene->shaders) {
+ /* keep this in sync with SD_HAS_TRANSPARENT_SHADOW in shader.cpp */
+ if((shader->has_surface_transparent && shader->use_transparent_shadow) || shader->has_volume) {
+ kintegrator->transparent_shadows = true;
+ break;
}
}
- else {
- kintegrator->transparent_shadows = false;
- }
kintegrator->volume_max_steps = volume_max_steps;
kintegrator->volume_step_size = volume_step_size;
diff --git a/intern/cycles/render/integrator.h b/intern/cycles/render/integrator.h
index 9501d7f8416..3cb430d72b4 100644
--- a/intern/cycles/render/integrator.h
+++ b/intern/cycles/render/integrator.h
@@ -31,7 +31,6 @@ class Integrator : public Node {
public:
NODE_DECLARE
- int min_bounce;
int max_bounce;
int max_diffuse_bounce;
@@ -39,9 +38,7 @@ public:
int max_transmission_bounce;
int max_volume_bounce;
- int transparent_min_bounce;
int transparent_max_bounce;
- bool transparent_shadows;
int ao_bounces;
diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp
index 625dd3ded39..6a7f985b756 100644
--- a/intern/cycles/render/light.cpp
+++ b/intern/cycles/render/light.cpp
@@ -60,6 +60,7 @@ static void shade_background_pixels(Device *device, DeviceScene *dscene, int res
device->mem_alloc("shade_background_pixels_input", d_input, MEM_READ_ONLY);
device->mem_copy_to(d_input);
device->mem_alloc("shade_background_pixels_output", d_output, MEM_WRITE_ONLY);
+ device->mem_zero(d_output);
DeviceTask main_task(DeviceTask::SHADER);
main_task.shader_input = d_input.device_pointer;
@@ -224,12 +225,12 @@ void LightManager::disable_ineffective_light(Device *device, Scene *scene)
bool LightManager::object_usable_as_light(Object *object) {
Mesh *mesh = object->mesh;
- /* Skip if we are not visible for BSDFs. */
- if(!(object->visibility & (PATH_RAY_DIFFUSE|PATH_RAY_GLOSSY|PATH_RAY_TRANSMIT))) {
+ /* Skip objects with NaNs */
+ if(!object->bounds.valid()) {
return false;
}
- /* Skip motion blurred deforming meshes, not supported yet. */
- if(mesh->has_motion_blur()) {
+ /* Skip if we are not visible for BSDFs. */
+ if(!(object->visibility & (PATH_RAY_DIFFUSE|PATH_RAY_GLOSSY|PATH_RAY_TRANSMIT))) {
return false;
}
/* Skip if we have no emission shaders. */
diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp
index 03825f780e0..84537bf5993 100644
--- a/intern/cycles/render/mesh.cpp
+++ b/intern/cycles/render/mesh.cpp
@@ -1925,16 +1925,7 @@ void MeshManager::device_update_displacement_images(Device *device,
if(node->special_type != SHADER_SPECIAL_TYPE_IMAGE_SLOT) {
continue;
}
- if(device->info.pack_images) {
- /* If device requires packed images we need to update all
- * images now, even if they're not used for displacement.
- */
- image_manager->device_update(device,
- dscene,
- scene,
- progress);
- return;
- }
+
ImageSlotTextureNode *image_node = static_cast<ImageSlotTextureNode*>(node);
int slot = image_node->slot;
if(slot != -1) {
diff --git a/intern/cycles/render/mesh_displace.cpp b/intern/cycles/render/mesh_displace.cpp
index 4ca20cf7ef3..350a56bf185 100644
--- a/intern/cycles/render/mesh_displace.cpp
+++ b/intern/cycles/render/mesh_displace.cpp
@@ -124,6 +124,7 @@ bool MeshManager::displace(Device *device, DeviceScene *dscene, Scene *scene, Me
device->mem_alloc("displace_input", d_input, MEM_READ_ONLY);
device->mem_copy_to(d_input);
device->mem_alloc("displace_output", d_output, MEM_WRITE_ONLY);
+ device->mem_zero(d_output);
DeviceTask task(DeviceTask::SHADER);
task.shader_input = d_input.device_pointer;
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 166156f7ac3..2b682756c6a 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -365,7 +365,8 @@ void ImageTextureNode::compile(OSLCompiler& compiler)
if(is_float == -1) {
if(builtin_data == NULL) {
ImageDataType type;
- type = image_manager->get_image_metadata(filename.string(), NULL, is_linear);
+ bool builtin_free_cache;
+ type = image_manager->get_image_metadata(filename.string(), NULL, is_linear, builtin_free_cache);
if(type == IMAGE_DATA_TYPE_FLOAT || type == IMAGE_DATA_TYPE_FLOAT4)
is_float = 1;
}
@@ -554,7 +555,8 @@ void EnvironmentTextureNode::compile(OSLCompiler& compiler)
if(is_float == -1) {
if(builtin_data == NULL) {
ImageDataType type;
- type = image_manager->get_image_metadata(filename.string(), NULL, is_linear);
+ bool builtin_free_cache;
+ type = image_manager->get_image_metadata(filename.string(), NULL, is_linear, builtin_free_cache);
if(type == IMAGE_DATA_TYPE_FLOAT || type == IMAGE_DATA_TYPE_FLOAT4)
is_float = 1;
}
@@ -1799,6 +1801,14 @@ BsdfBaseNode::BsdfBaseNode(const NodeType *node_type)
special_type = SHADER_SPECIAL_TYPE_CLOSURE;
}
+bool BsdfBaseNode::has_bump()
+{
+ /* detect if anything is plugged into the normal input besides the default */
+ ShaderInput *normal_in = input("Normal");
+ return (normal_in && normal_in->link &&
+ normal_in->link->parent->special_type != SHADER_SPECIAL_TYPE_GEOMETRY);
+}
+
/* BSDF Closure */
BsdfNode::BsdfNode(const NodeType *node_type)
@@ -2337,6 +2347,12 @@ PrincipledBsdfNode::PrincipledBsdfNode()
distribution_orig = NBUILTIN_CLOSURES;
}
+bool PrincipledBsdfNode::has_surface_bssrdf()
+{
+ ShaderInput *subsurface_in = input("Subsurface");
+ return (subsurface_in->link != NULL || subsurface > CLOSURE_WEIGHT_CUTOFF);
+}
+
void PrincipledBsdfNode::attributes(Shader *shader, AttributeRequestSet *attributes)
{
if(shader->has_surface) {
@@ -2431,9 +2447,7 @@ void PrincipledBsdfNode::compile(OSLCompiler& compiler)
bool PrincipledBsdfNode::has_bssrdf_bump()
{
- /* detect if anything is plugged into the normal input besides the default */
- ShaderInput *normal_in = input("Normal");
- return (normal_in->link && normal_in->link->parent->special_type != SHADER_SPECIAL_TYPE_GEOMETRY);
+ return has_surface_bssrdf() && has_bump();
}
/* Translucent BSDF Closure */
diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h
index c6ab47fcc84..ec4c7c7c50d 100644
--- a/intern/cycles/render/nodes.h
+++ b/intern/cycles/render/nodes.h
@@ -326,6 +326,16 @@ class BsdfBaseNode : public ShaderNode {
public:
BsdfBaseNode(const NodeType *node_type);
+ bool has_spatial_varying() { return true; }
+ virtual ClosureType get_closure_type() { return closure; }
+ virtual bool has_bump();
+
+ virtual bool equals(const ShaderNode& /*other*/)
+ {
+ /* TODO(sergey): With some care BSDF nodes can be de-duplicated. */
+ return false;
+ }
+
ClosureType closure;
};
@@ -334,19 +344,11 @@ public:
explicit BsdfNode(const NodeType *node_type);
SHADER_NODE_BASE_CLASS(BsdfNode)
- bool has_spatial_varying() { return true; }
void compile(SVMCompiler& compiler, ShaderInput *param1, ShaderInput *param2, ShaderInput *param3 = NULL, ShaderInput *param4 = NULL);
- virtual ClosureType get_closure_type() { return closure; }
float3 color;
float3 normal;
float surface_mix_weight;
-
- virtual bool equals(const ShaderNode& /*other*/)
- {
- /* TODO(sergey): With some care BSDF nodes can be de-duplicated. */
- return false;
- }
};
class AnisotropicBsdfNode : public BsdfNode {
@@ -373,8 +375,7 @@ class PrincipledBsdfNode : public BsdfBaseNode {
public:
SHADER_NODE_CLASS(PrincipledBsdfNode)
- bool has_spatial_varying() { return true; }
- bool has_surface_bssrdf() { return true; }
+ bool has_surface_bssrdf();
bool has_bssrdf_bump();
void compile(SVMCompiler& compiler, ShaderInput *metallic, ShaderInput *subsurface, ShaderInput *subsurface_radius,
ShaderInput *specular, ShaderInput *roughness, ShaderInput *specular_tint, ShaderInput *anisotropic,
@@ -390,13 +391,6 @@ public:
float surface_mix_weight;
ClosureType distribution, distribution_orig;
- virtual bool equals(const ShaderNode * /*other*/)
- {
- /* TODO(sergey): With some care BSDF nodes can be de-duplicated. */
- return false;
- }
-
- ClosureType get_closure_type() { return closure; }
bool has_integrator_dependency();
void attributes(Shader *shader, AttributeRequestSet *attributes);
};
diff --git a/intern/cycles/render/object.cpp b/intern/cycles/render/object.cpp
index 375abfeb27a..12690090066 100644
--- a/intern/cycles/render/object.cpp
+++ b/intern/cycles/render/object.cpp
@@ -262,6 +262,17 @@ bool Object::is_traceable()
return true;
}
+uint Object::visibility_for_tracing() const {
+ uint trace_visibility = visibility;
+ if (is_shadow_catcher) {
+ trace_visibility &= ~PATH_RAY_SHADOW_NON_CATCHER;
+ }
+ else {
+ trace_visibility &= ~PATH_RAY_SHADOW_CATCHER;
+ }
+ return trace_visibility;
+}
+
/* Object Manager */
ObjectManager::ObjectManager()
@@ -356,6 +367,13 @@ void ObjectManager::device_update_object_transform(UpdateObejctTransformState *s
/* OBJECT_PROPERTIES */
objects[offset+8] = make_float4(surface_area, pass_id, random_number, __int_as_float(particle_index));
+ if(mesh->use_motion_blur) {
+ state->have_motion = true;
+ }
+ if(mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION)) {
+ flag |= SD_OBJECT_HAS_VERTEX_MOTION;
+ }
+
if(state->need_motion == Scene::MOTION_PASS) {
/* Motion transformations, is world/object space depending if mesh
* comes with deformed position in object space, or if we transform
@@ -376,9 +394,6 @@ void ObjectManager::device_update_object_transform(UpdateObejctTransformState *s
mtfm.pre = mtfm.pre * itfm;
mtfm.post = mtfm.post * itfm;
}
- else {
- flag |= SD_OBJECT_HAS_VERTEX_MOTION;
- }
memcpy(&objects_vector[object_index*OBJECT_VECTOR_SIZE+0], &mtfm.pre, sizeof(float4)*3);
memcpy(&objects_vector[object_index*OBJECT_VECTOR_SIZE+3], &mtfm.post, sizeof(float4)*3);
@@ -397,10 +412,6 @@ void ObjectManager::device_update_object_transform(UpdateObejctTransformState *s
}
#endif
- if(mesh->use_motion_blur) {
- state->have_motion = true;
- }
-
/* Dupli object coords and motion info. */
int totalsteps = mesh->motion_steps;
int numsteps = (totalsteps - 1)/2;
diff --git a/intern/cycles/render/object.h b/intern/cycles/render/object.h
index 12d7b2c81cf..6927bbfe4c7 100644
--- a/intern/cycles/render/object.h
+++ b/intern/cycles/render/object.h
@@ -60,7 +60,7 @@ public:
ParticleSystem *particle_system;
int particle_index;
-
+
Object();
~Object();
@@ -75,6 +75,11 @@ public:
* kernel scene.
*/
bool is_traceable();
+
+ /* Combine object's visibility with all possible internal run-time
+ * determined flags which denotes trace-time visibility.
+ */
+ uint visibility_for_tracing() const;
};
/* Object Manager */
diff --git a/intern/cycles/render/osl.cpp b/intern/cycles/render/osl.cpp
index 6bff29d1c76..5c5ac6e2be9 100644
--- a/intern/cycles/render/osl.cpp
+++ b/intern/cycles/render/osl.cpp
@@ -156,6 +156,7 @@ void OSLShaderManager::device_free(Device *device, DeviceScene *dscene, Scene *s
og->surface_state.clear();
og->volume_state.clear();
og->displacement_state.clear();
+ og->bump_state.clear();
og->background_state.reset();
}
@@ -232,8 +233,10 @@ void OSLShaderManager::shading_system_init()
"glossy", /* PATH_RAY_GLOSSY */
"singular", /* PATH_RAY_SINGULAR */
"transparent", /* PATH_RAY_TRANSPARENT */
- "shadow", /* PATH_RAY_SHADOW_OPAQUE */
- "shadow", /* PATH_RAY_SHADOW_TRANSPARENT */
+ "shadow", /* PATH_RAY_SHADOW_OPAQUE_NON_CATCHER */
+ "shadow", /* PATH_RAY_SHADOW_OPAQUE_CATCHER */
+ "shadow", /* PATH_RAY_SHADOW_TRANSPARENT_NON_CATCHER */
+ "shadow", /* PATH_RAY_SHADOW_TRANSPARENT_CATCHER */
"__unused__",
"__unused__",
@@ -718,6 +721,7 @@ void OSLCompiler::add(ShaderNode *node, const char *name, bool isfilepath)
current_shader->has_surface_bssrdf = true;
current_shader->has_bssrdf_bump = true; /* can't detect yet */
}
+ current_shader->has_bump = true; /* can't detect yet */
}
if(node->has_spatial_varying()) {
@@ -1026,6 +1030,9 @@ void OSLCompiler::generate_nodes(const ShaderNodeSet& nodes)
if(node->has_bssrdf_bump())
current_shader->has_bssrdf_bump = true;
}
+ if(node->has_bump()) {
+ current_shader->has_bump = true;
+ }
}
else if(current_type == SHADER_TYPE_VOLUME) {
if(node->has_spatial_varying())
@@ -1088,21 +1095,14 @@ void OSLCompiler::compile(Scene *scene, OSLGlobals *og, Shader *shader)
ShaderGraph *graph = shader->graph;
ShaderNode *output = (graph)? graph->output(): NULL;
- /* copy graph for shader with bump mapping */
- if(output->input("Surface")->link && output->input("Displacement")->link)
- if(!shader->graph_bump)
- shader->graph_bump = shader->graph->copy();
+ bool has_bump = (shader->displacement_method != DISPLACE_TRUE) &&
+ output->input("Surface")->link && output->input("Displacement")->link;
/* finalize */
shader->graph->finalize(scene,
- false,
- shader->has_integrator_dependency);
- if(shader->graph_bump) {
- shader->graph_bump->finalize(scene,
- true,
- shader->has_integrator_dependency,
- shader->displacement_method == DISPLACE_BOTH);
- }
+ has_bump,
+ shader->has_integrator_dependency,
+ shader->displacement_method == DISPLACE_BOTH);
current_shader = shader;
@@ -1110,7 +1110,8 @@ void OSLCompiler::compile(Scene *scene, OSLGlobals *og, Shader *shader)
shader->has_surface_emission = false;
shader->has_surface_transparent = false;
shader->has_surface_bssrdf = false;
- shader->has_bssrdf_bump = false;
+ shader->has_bump = has_bump;
+ shader->has_bssrdf_bump = has_bump;
shader->has_volume = false;
shader->has_displacement = false;
shader->has_surface_spatial_varying = false;
@@ -1122,8 +1123,8 @@ void OSLCompiler::compile(Scene *scene, OSLGlobals *og, Shader *shader)
if(shader->used && graph && output->input("Surface")->link) {
shader->osl_surface_ref = compile_type(shader, shader->graph, SHADER_TYPE_SURFACE);
- if(shader->graph_bump && shader->displacement_method != DISPLACE_TRUE)
- shader->osl_surface_bump_ref = compile_type(shader, shader->graph_bump, SHADER_TYPE_BUMP);
+ if(has_bump)
+ shader->osl_surface_bump_ref = compile_type(shader, shader->graph, SHADER_TYPE_BUMP);
else
shader->osl_surface_bump_ref = OSL::ShaderGroupRef();
diff --git a/intern/cycles/render/scene.cpp b/intern/cycles/render/scene.cpp
index 4db20338744..c59a5d97df5 100644
--- a/intern/cycles/render/scene.cpp
+++ b/intern/cycles/render/scene.cpp
@@ -148,8 +148,6 @@ void Scene::device_update(Device *device_, Progress& progress)
* - Film needs light manager to run for use_light_visibility
* - Lookup tables are done a second time to handle film tables
*/
-
- image_manager->set_pack_images(device->info.pack_images);
progress.set_status("Updating Shaders");
shader_manager->device_update(device, &dscene, this, progress);
diff --git a/intern/cycles/render/scene.h b/intern/cycles/render/scene.h
index 4c2c4f5fcc3..0194327f567 100644
--- a/intern/cycles/render/scene.h
+++ b/intern/cycles/render/scene.h
@@ -121,13 +121,6 @@ public:
vector<device_vector<uchar>* > tex_byte_image;
vector<device_vector<half>* > tex_half_image;
- /* opencl images */
- device_vector<float4> tex_image_float4_packed;
- device_vector<uchar4> tex_image_byte4_packed;
- device_vector<float> tex_image_float_packed;
- device_vector<uchar> tex_image_byte_packed;
- device_vector<uint4> tex_image_packed_info;
-
KernelData data;
};
diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp
index ae462a1084a..f1ff6b49b71 100644
--- a/intern/cycles/render/session.cpp
+++ b/intern/cycles/render/session.cpp
@@ -46,7 +46,7 @@ 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, params.tile_order,
- max(params.device.multi_devices.size(), 1)),
+ max(params.device.multi_devices.size(), 1), params.pixel_size),
stats()
{
device_use_gl = ((params.device.type != DEVICE_CPU) && !params.background);
@@ -384,7 +384,6 @@ bool Session::acquire_tile(Device *tile_device, RenderTile& rtile)
tile_manager.state.buffer.get_offset_stride(rtile.offset, rtile.stride);
rtile.buffer = buffers->buffer.device_pointer;
- rtile.rng_state = buffers->rng_state.device_pointer;
rtile.buffers = buffers;
tile->buffers = buffers;
@@ -442,7 +441,6 @@ bool Session::acquire_tile(Device *tile_device, RenderTile& rtile)
tile->buffers->params.get_offset_stride(rtile.offset, rtile.stride);
rtile.buffer = tile->buffers->buffer.device_pointer;
- rtile.rng_state = tile->buffers->rng_state.device_pointer;
rtile.buffers = tile->buffers;
rtile.sample = 0;
@@ -721,7 +719,6 @@ DeviceRequestedFeatures Session::get_requested_device_features()
BakeManager *bake_manager = scene->bake_manager;
requested_features.use_baking = bake_manager->get_baking();
requested_features.use_integrator_branched = (scene->integrator->method == Integrator::BRANCHED_PATH);
- requested_features.use_transparent &= scene->integrator->transparent_shadows;
requested_features.use_denoising = params.use_denoising;
return requested_features;
@@ -931,7 +928,7 @@ void Session::update_status_time(bool show_pause, bool show_done)
const bool rendering_finished = (tile == num_tiles);
const bool is_last_tile = (tile + 1) == num_tiles;
- substatus = string_printf("Path Tracing Tile %d/%d", tile, num_tiles);
+ substatus = string_printf("Rendered %d/%d Tiles", tile, num_tiles);
if(!rendering_finished && (device->show_samples() || (is_cpu && is_last_tile))) {
/* Some devices automatically support showing the sample number:
@@ -961,6 +958,7 @@ void Session::update_status_time(bool show_pause, bool show_done)
}
else if(show_done) {
status = "Done";
+ progress.set_end_time(); /* Save end time so that further calls to get_time are accurate. */
}
else {
status = substatus;
@@ -972,7 +970,12 @@ void Session::update_status_time(bool show_pause, bool show_done)
void Session::render()
{
- /* add path trace task */
+ /* Clear buffers. */
+ if(buffers && tile_manager.state.sample == 0) {
+ buffers->zero(device);
+ }
+
+ /* Add path trace task. */
DeviceTask task(DeviceTask::RENDER);
task.acquire_tile = function_bind(&Session::acquire_tile, this, _1, _2);
diff --git a/intern/cycles/render/session.h b/intern/cycles/render/session.h
index 9f8bb8c42fa..980eda0876d 100644
--- a/intern/cycles/render/session.h
+++ b/intern/cycles/render/session.h
@@ -53,6 +53,7 @@ public:
int2 tile_size;
TileOrder tile_order;
int start_resolution;
+ int pixel_size;
int threads;
bool display_buffer_linear;
@@ -81,6 +82,7 @@ public:
samples = INT_MAX;
tile_size = make_int2(64, 64);
start_resolution = INT_MAX;
+ pixel_size = 1;
threads = 0;
use_denoising = false;
@@ -110,6 +112,7 @@ public:
&& experimental == params.experimental
&& tile_size == params.tile_size
&& start_resolution == params.start_resolution
+ && pixel_size == params.pixel_size
&& threads == params.threads
&& display_buffer_linear == params.display_buffer_linear
&& cancel_timeout == params.cancel_timeout
diff --git a/intern/cycles/render/shader.cpp b/intern/cycles/render/shader.cpp
index 50400edd5ca..864875361c0 100644
--- a/intern/cycles/render/shader.cpp
+++ b/intern/cycles/render/shader.cpp
@@ -33,7 +33,9 @@
CCL_NAMESPACE_BEGIN
+thread_mutex ShaderManager::lookup_table_mutex;
vector<float> ShaderManager::beckmann_table;
+bool ShaderManager::beckmann_table_ready = false;
/* Beckmann sampling precomputed table, see bsdf_microfacet.h */
@@ -177,7 +179,6 @@ Shader::Shader()
pass_id = 0;
graph = NULL;
- graph_bump = NULL;
has_surface = false;
has_surface_transparent = false;
@@ -185,11 +186,13 @@ Shader::Shader()
has_surface_bssrdf = false;
has_volume = false;
has_displacement = false;
+ has_bump = false;
has_bssrdf_bump = false;
has_surface_spatial_varying = false;
has_volume_spatial_varying = false;
has_object_dependency = false;
has_integrator_dependency = false;
+ has_volume_connected = false;
displacement_method = DISPLACE_BUMP;
@@ -203,7 +206,6 @@ Shader::Shader()
Shader::~Shader()
{
delete graph;
- delete graph_bump;
}
bool Shader::is_constant_emission(float3 *emission)
@@ -238,9 +240,7 @@ void Shader::set_graph(ShaderGraph *graph_)
/* assign graph */
delete graph;
- delete graph_bump;
graph = graph_;
- graph_bump = NULL;
/* Store info here before graph optimization to make sure that
* nodes that get optimized away still count. */
@@ -457,15 +457,11 @@ void ShaderManager::device_update_common(Device *device,
flag |= SD_VOLUME_MIS;
if(shader->volume_interpolation_method == VOLUME_INTERPOLATION_CUBIC)
flag |= SD_VOLUME_CUBIC;
- if(shader->graph_bump)
+ if(shader->has_bump)
flag |= SD_HAS_BUMP;
if(shader->displacement_method != DISPLACE_BUMP)
flag |= SD_HAS_DISPLACEMENT;
- /* shader with bump mapping */
- if(shader->displacement_method != DISPLACE_TRUE && shader->graph_bump)
- flag |= SD_HAS_BSSRDF_BUMP;
-
/* constant emission check */
float3 constant_emission = make_float3(0.0f, 0.0f, 0.0f);
if(shader->is_constant_emission(&constant_emission))
@@ -488,10 +484,11 @@ void ShaderManager::device_update_common(Device *device,
/* beckmann lookup table */
if(beckmann_table_offset == TABLE_OFFSET_INVALID) {
- if(beckmann_table.size() == 0) {
+ if(!beckmann_table_ready) {
thread_scoped_lock lock(lookup_table_mutex);
- if(beckmann_table.size() == 0) {
+ if(!beckmann_table_ready) {
beckmann_table_build(beckmann_table);
+ beckmann_table_ready = true;
}
}
beckmann_table_offset = scene->lookup_tables->add_table(dscene, beckmann_table);
@@ -502,9 +499,7 @@ void ShaderManager::device_update_common(Device *device,
KernelIntegrator *kintegrator = &dscene->data.integrator;
kintegrator->use_volumes = has_volumes;
/* TODO(sergey): De-duplicate with flags set in integrator.cpp. */
- if(scene->integrator->transparent_shadows) {
- kintegrator->transparent_shadows = has_transparent_shadow;
- }
+ kintegrator->transparent_shadows = has_transparent_shadow;
}
void ShaderManager::device_free_common(Device *device, DeviceScene *dscene, Scene *scene)
@@ -609,11 +604,6 @@ void ShaderManager::get_requested_features(Scene *scene,
Shader *shader = scene->shaders[i];
/* Gather requested features from all the nodes from the graph nodes. */
get_requested_graph_features(shader->graph, requested_features);
- /* Gather requested features from the graph itself. */
- if(shader->graph_bump) {
- get_requested_graph_features(shader->graph_bump,
- requested_features);
- }
ShaderNode *output_node = shader->graph->output();
if(output_node->input("Displacement")->link != NULL) {
requested_features->nodes_features |= NODE_FEATURE_BUMP;
diff --git a/intern/cycles/render/shader.h b/intern/cycles/render/shader.h
index b6714b13247..3fdcd3c0c5b 100644
--- a/intern/cycles/render/shader.h
+++ b/intern/cycles/render/shader.h
@@ -89,11 +89,6 @@ public:
/* shader graph */
ShaderGraph *graph;
- /* shader graph with auto bump mapping included, we compile two shaders,
- * with and without bump, because the displacement method is a mesh
- * level setting, so we need to handle both */
- ShaderGraph *graph_bump;
-
/* sampling */
bool use_mis;
bool use_transparent_shadow;
@@ -121,6 +116,7 @@ public:
bool has_volume;
bool has_displacement;
bool has_surface_bssrdf;
+ bool has_bump;
bool has_bssrdf_bump;
bool has_surface_spatial_varying;
bool has_volume_spatial_varying;
@@ -204,8 +200,9 @@ protected:
typedef unordered_map<ustring, uint, ustringHash> AttributeIDMap;
AttributeIDMap unique_attribute_id;
- thread_mutex lookup_table_mutex;
+ static thread_mutex lookup_table_mutex;
static vector<float> beckmann_table;
+ static bool beckmann_table_ready;
size_t beckmann_table_offset;
diff --git a/intern/cycles/render/svm.cpp b/intern/cycles/render/svm.cpp
index 48287d872d4..32f89897970 100644
--- a/intern/cycles/render/svm.cpp
+++ b/intern/cycles/render/svm.cpp
@@ -521,6 +521,9 @@ void SVMCompiler::generate_closure_node(ShaderNode *node,
if(node->has_bssrdf_bump())
current_shader->has_bssrdf_bump = true;
}
+ if(node->has_bump()) {
+ current_shader->has_bump = true;
+ }
}
}
@@ -799,29 +802,21 @@ void SVMCompiler::compile(Scene *scene,
Summary *summary)
{
/* copy graph for shader with bump mapping */
- ShaderNode *node = shader->graph->output();
+ ShaderNode *output = shader->graph->output();
int start_num_svm_nodes = svm_nodes.size();
const double time_start = time_dt();
- if(node->input("Surface")->link && node->input("Displacement")->link)
- if(!shader->graph_bump)
- shader->graph_bump = shader->graph->copy();
+ bool has_bump = (shader->displacement_method != DISPLACE_TRUE) &&
+ output->input("Surface")->link && output->input("Displacement")->link;
/* finalize */
{
scoped_timer timer((summary != NULL)? &summary->time_finalize: NULL);
shader->graph->finalize(scene,
- false,
- shader->has_integrator_dependency);
- }
-
- if(shader->graph_bump) {
- scoped_timer timer((summary != NULL)? &summary->time_finalize_bump: NULL);
- shader->graph_bump->finalize(scene,
- true,
- shader->has_integrator_dependency,
- shader->displacement_method == DISPLACE_BOTH);
+ has_bump,
+ shader->has_integrator_dependency,
+ shader->displacement_method == DISPLACE_BOTH);
}
current_shader = shader;
@@ -830,7 +825,8 @@ void SVMCompiler::compile(Scene *scene,
shader->has_surface_emission = false;
shader->has_surface_transparent = false;
shader->has_surface_bssrdf = false;
- shader->has_bssrdf_bump = false;
+ shader->has_bump = has_bump;
+ shader->has_bssrdf_bump = has_bump;
shader->has_volume = false;
shader->has_displacement = false;
shader->has_surface_spatial_varying = false;
@@ -839,9 +835,9 @@ void SVMCompiler::compile(Scene *scene,
shader->has_integrator_dependency = false;
/* generate bump shader */
- if(shader->displacement_method != DISPLACE_TRUE && shader->graph_bump) {
+ if(has_bump) {
scoped_timer timer((summary != NULL)? &summary->time_generate_bump: NULL);
- compile_type(shader, shader->graph_bump, SHADER_TYPE_BUMP);
+ compile_type(shader, shader->graph, SHADER_TYPE_BUMP);
svm_nodes[index].y = svm_nodes.size();
svm_nodes.insert(svm_nodes.end(),
current_svm_nodes.begin(),
@@ -853,7 +849,7 @@ void SVMCompiler::compile(Scene *scene,
scoped_timer timer((summary != NULL)? &summary->time_generate_surface: NULL);
compile_type(shader, shader->graph, SHADER_TYPE_SURFACE);
/* only set jump offset if there's no bump shader, as the bump shader will fall thru to this one if it exists */
- if(shader->displacement_method == DISPLACE_TRUE || !shader->graph_bump) {
+ if(!has_bump) {
svm_nodes[index].y = svm_nodes.size();
}
svm_nodes.insert(svm_nodes.end(),
@@ -895,7 +891,6 @@ SVMCompiler::Summary::Summary()
: num_svm_nodes(0),
peak_stack_usage(0),
time_finalize(0.0),
- time_finalize_bump(0.0),
time_generate_surface(0.0),
time_generate_bump(0.0),
time_generate_volume(0.0),
@@ -911,10 +906,7 @@ string SVMCompiler::Summary::full_report() const
report += string_printf("Peak stack usage: %d\n", peak_stack_usage);
report += string_printf("Time (in seconds):\n");
- report += string_printf(" Finalize: %f\n", time_finalize);
- report += string_printf(" Bump finalize: %f\n", time_finalize_bump);
- report += string_printf("Finalize: %f\n", time_finalize +
- time_finalize_bump);
+ report += string_printf("Finalize: %f\n", time_finalize);
report += string_printf(" Surface: %f\n", time_generate_surface);
report += string_printf(" Bump: %f\n", time_generate_bump);
report += string_printf(" Volume: %f\n", time_generate_volume);
diff --git a/intern/cycles/render/svm.h b/intern/cycles/render/svm.h
index abbd9e50610..98ef5fa05d8 100644
--- a/intern/cycles/render/svm.h
+++ b/intern/cycles/render/svm.h
@@ -74,9 +74,6 @@ public:
/* Time spent on surface graph finalization. */
double time_finalize;
- /* Time spent on bump graph finalization. */
- double time_finalize_bump;
-
/* Time spent on generating SVM nodes for surface shader. */
double time_generate_surface;
diff --git a/intern/cycles/render/tile.cpp b/intern/cycles/render/tile.cpp
index 176a1f4f0f3..a9620f79fa0 100644
--- a/intern/cycles/render/tile.cpp
+++ b/intern/cycles/render/tile.cpp
@@ -88,12 +88,14 @@ enum SpiralDirection {
} /* namespace */
TileManager::TileManager(bool progressive_, int num_samples_, int2 tile_size_, int start_resolution_,
- bool preserve_tile_device_, bool background_, TileOrder tile_order_, int num_devices_)
+ bool preserve_tile_device_, bool background_, TileOrder tile_order_,
+ int num_devices_, int pixel_size_)
{
progressive = progressive_;
tile_size = tile_size_;
tile_order = tile_order_;
start_resolution = start_resolution_;
+ pixel_size = pixel_size_;
num_samples = num_samples_;
num_devices = num_devices_;
preserve_tile_device = preserve_tile_device_;
@@ -163,15 +165,17 @@ void TileManager::set_samples(int num_samples_)
uint64_t pixel_samples = 0;
/* While rendering in the viewport, the initial preview resolution is increased to the native resolution
* before the actual rendering begins. Therefore, additional pixel samples will be rendered. */
- int divider = get_divider(params.width, params.height, start_resolution) / 2;
- while(divider > 1) {
+ int divider = max(get_divider(params.width, params.height, start_resolution) / 2, pixel_size);
+ while(divider > pixel_size) {
int image_w = max(1, params.width/divider);
int image_h = max(1, params.height/divider);
pixel_samples += image_w * image_h;
divider >>= 1;
}
- state.total_pixel_samples = pixel_samples + (uint64_t)get_num_effective_samples() * params.width*params.height;
+ int image_w = max(1, params.width/divider);
+ int image_h = max(1, params.height/divider);
+ state.total_pixel_samples = pixel_samples + (uint64_t)get_num_effective_samples() * image_w*image_h;
if(schedule_denoising) {
state.total_pixel_samples += params.width*params.height;
}
@@ -471,7 +475,7 @@ bool TileManager::done()
int end_sample = (range_num_samples == -1)
? num_samples
: range_start_sample + range_num_samples;
- return (state.resolution_divider == 1) &&
+ return (state.resolution_divider == pixel_size) &&
(state.sample+state.num_samples >= end_sample);
}
@@ -480,9 +484,9 @@ bool TileManager::next()
if(done())
return false;
- if(progressive && state.resolution_divider > 1) {
+ if(progressive && state.resolution_divider > pixel_size) {
state.sample = 0;
- state.resolution_divider /= 2;
+ state.resolution_divider = max(state.resolution_divider/2, pixel_size);
state.num_samples = 1;
set_tiles();
}
@@ -496,7 +500,7 @@ bool TileManager::next()
else
state.num_samples = range_num_samples;
- state.resolution_divider = 1;
+ state.resolution_divider = pixel_size;
set_tiles();
}
diff --git a/intern/cycles/render/tile.h b/intern/cycles/render/tile.h
index e39a8f0627a..4cd57b7b30c 100644
--- a/intern/cycles/render/tile.h
+++ b/intern/cycles/render/tile.h
@@ -88,7 +88,7 @@ public:
int num_samples;
TileManager(bool progressive, int num_samples, int2 tile_size, int start_resolution,
- bool preserve_tile_device, bool background, TileOrder tile_order, int num_devices = 1);
+ bool preserve_tile_device, bool background, TileOrder tile_order, int num_devices = 1, int pixel_size = 1);
~TileManager();
void free_device();
@@ -122,6 +122,7 @@ protected:
int2 tile_size;
TileOrder tile_order;
int start_resolution;
+ int pixel_size;
int num_devices;
/* in some cases it is important that the same tile will be returned for the same
diff --git a/intern/cycles/util/CMakeLists.txt b/intern/cycles/util/CMakeLists.txt
index 43f9a57d099..7f3747a0f58 100644
--- a/intern/cycles/util/CMakeLists.txt
+++ b/intern/cycles/util/CMakeLists.txt
@@ -38,6 +38,7 @@ set(SRC_HEADERS
util_atomic.h
util_boundbox.h
util_debug.h
+ util_defines.h
util_guarded_allocator.cpp
util_foreach.h
util_function.h
diff --git a/intern/cycles/util/util_atomic.h b/intern/cycles/util/util_atomic.h
index 643af87a65f..f3c7ae546a0 100644
--- a/intern/cycles/util/util_atomic.h
+++ b/intern/cycles/util/util_atomic.h
@@ -22,16 +22,6 @@
/* Using atomic ops header from Blender. */
#include "atomic_ops.h"
-ATOMIC_INLINE void atomic_update_max_z(size_t *maximum_value, size_t value)
-{
- size_t prev_value = *maximum_value;
- while(prev_value < value) {
- if(atomic_cas_z(maximum_value, prev_value, value) != prev_value) {
- break;
- }
- }
-}
-
#define atomic_add_and_fetch_float(p, x) atomic_add_and_fetch_fl((p), (x))
#define atomic_fetch_and_inc_uint32(p) atomic_fetch_and_add_uint32((p), 1)
diff --git a/intern/cycles/util/util_debug.cpp b/intern/cycles/util/util_debug.cpp
index ab038d2b9fb..eb078d69252 100644
--- a/intern/cycles/util/util_debug.cpp
+++ b/intern/cycles/util/util_debug.cpp
@@ -122,13 +122,16 @@ void DebugFlags::OpenCL::reset()
}
DebugFlags::DebugFlags()
+: viewport_static_bvh(false)
{
/* Nothing for now. */
}
void DebugFlags::reset()
{
+ viewport_static_bvh = false;
cpu.reset();
+ cuda.reset();
opencl.reset();
}
@@ -184,8 +187,8 @@ std::ostream& operator <<(std::ostream &os,
<< " Device type : " << opencl_device_type << "\n"
<< " Kernel type : " << opencl_kernel_type << "\n"
<< " Debug : " << string_from_bool(debug_flags.opencl.debug) << "\n"
- << " Single program : " << string_from_bool(debug_flags.opencl.single_program)
- << "\n";
+ << " Single program : " << string_from_bool(debug_flags.opencl.single_program) << "\n"
+ << " Memory limit : " << string_human_readable_size(debug_flags.opencl.mem_limit) << "\n";
return os;
}
diff --git a/intern/cycles/util/util_debug.h b/intern/cycles/util/util_debug.h
index 4505d584490..9255279c5ab 100644
--- a/intern/cycles/util/util_debug.h
+++ b/intern/cycles/util/util_debug.h
@@ -30,6 +30,9 @@ CCL_NAMESPACE_BEGIN
*/
class DebugFlags {
public:
+ /* Use static BVH in viewport, to match final render exactly. */
+ bool viewport_static_bvh;
+
/* Descriptor of CPU feature-set to be used. */
struct CPU {
CPU();
@@ -115,6 +118,10 @@ public:
/* Use single program */
bool single_program;
+
+ /* TODO(mai): Currently this is only for OpenCL, but we should have it implemented for all devices. */
+ /* Artificial memory limit in bytes (0 if disabled). */
+ size_t mem_limit;
};
/* Get instance of debug flags registry. */
diff --git a/intern/cycles/util/util_defines.h b/intern/cycles/util/util_defines.h
new file mode 100644
index 00000000000..98944a19022
--- /dev/null
+++ b/intern/cycles/util/util_defines.h
@@ -0,0 +1,136 @@
+
+/*
+ * Copyright 2011-2017 Blender Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __UTIL_DEFINES_H__
+#define __UTIL_DEFINES_H__
+
+/* Bitness */
+
+#if defined(__ppc64__) || defined(__PPC64__) || defined(__x86_64__) || defined(__ia64__) || defined(_M_X64)
+# define __KERNEL_64_BIT__
+#endif
+
+/* Qualifiers for kernel code shared by CPU and GPU */
+
+#ifndef __KERNEL_GPU__
+# define ccl_device static inline
+# define ccl_device_noinline static
+# define ccl_global
+# define ccl_static_constant static const
+# define ccl_constant const
+# define ccl_local
+# define ccl_local_param
+# define ccl_private
+# define ccl_restrict __restrict
+# define ccl_ref &
+# define __KERNEL_WITH_SSE_ALIGN__
+
+# if defined(_WIN32) && !defined(FREE_WINDOWS)
+# define ccl_device_inline static __forceinline
+# define ccl_device_forceinline static __forceinline
+# define ccl_align(...) __declspec(align(__VA_ARGS__))
+# ifdef __KERNEL_64_BIT__
+# define ccl_try_align(...) __declspec(align(__VA_ARGS__))
+# else /* __KERNEL_64_BIT__ */
+# undef __KERNEL_WITH_SSE_ALIGN__
+/* No support for function arguments (error C2719). */
+# define ccl_try_align(...)
+# endif /* __KERNEL_64_BIT__ */
+# define ccl_may_alias
+# define ccl_always_inline __forceinline
+# define ccl_never_inline __declspec(noinline)
+# define ccl_maybe_unused
+# else /* _WIN32 && !FREE_WINDOWS */
+# define ccl_device_inline static inline __attribute__((always_inline))
+# define ccl_device_forceinline static inline __attribute__((always_inline))
+# define ccl_align(...) __attribute__((aligned(__VA_ARGS__)))
+# ifndef FREE_WINDOWS64
+# define __forceinline inline __attribute__((always_inline))
+# endif
+# define ccl_try_align(...) __attribute__((aligned(__VA_ARGS__)))
+# define ccl_may_alias __attribute__((__may_alias__))
+# define ccl_always_inline __attribute__((always_inline))
+# define ccl_never_inline __attribute__((noinline))
+# define ccl_maybe_unused __attribute__((used))
+# endif /* _WIN32 && !FREE_WINDOWS */
+
+/* Use to suppress '-Wimplicit-fallthrough' (in place of 'break'). */
+# if defined(__GNUC__) && (__GNUC__ >= 7) /* gcc7.0+ only */
+# define ATTR_FALLTHROUGH __attribute__((fallthrough))
+# else
+# define ATTR_FALLTHROUGH ((void)0)
+# endif
+#endif /* __KERNEL_GPU__ */
+
+/* macros */
+
+/* hints for branch prediction, only use in code that runs a _lot_ */
+#if defined(__GNUC__) && defined(__KERNEL_CPU__)
+# define LIKELY(x) __builtin_expect(!!(x), 1)
+# define UNLIKELY(x) __builtin_expect(!!(x), 0)
+#else
+# define LIKELY(x) (x)
+# define UNLIKELY(x) (x)
+#endif
+
+#if defined(__cplusplus) && ((__cplusplus >= 201103L) || (defined(_MSC_VER) && _MSC_VER >= 1800))
+# define HAS_CPP11_FEATURES
+#endif
+
+#if defined(__GNUC__) || defined(__clang__)
+# if defined(HAS_CPP11_FEATURES)
+/* Some magic to be sure we don't have reference in the type. */
+template<typename T> static inline T decltype_helper(T x) { return x; }
+# define TYPEOF(x) decltype(decltype_helper(x))
+# else
+# define TYPEOF(x) typeof(x)
+# endif
+#endif
+
+/* Causes warning:
+ * incompatible types when assigning to type 'Foo' from type 'Bar'
+ * ... the compiler optimizes away the temp var */
+#ifdef __GNUC__
+#define CHECK_TYPE(var, type) { \
+ TYPEOF(var) *__tmp; \
+ __tmp = (type *)NULL; \
+ (void)__tmp; \
+} (void)0
+
+#define CHECK_TYPE_PAIR(var_a, var_b) { \
+ TYPEOF(var_a) *__tmp; \
+ __tmp = (typeof(var_b) *)NULL; \
+ (void)__tmp; \
+} (void)0
+#else
+# define CHECK_TYPE(var, type)
+# define CHECK_TYPE_PAIR(var_a, var_b)
+#endif
+
+/* can be used in simple macros */
+#define CHECK_TYPE_INLINE(val, type) \
+ ((void)(((type)0) != (val)))
+
+#ifndef __KERNEL_GPU__
+# include <cassert>
+# define util_assert(statement) assert(statement)
+#else
+# define util_assert(statement)
+#endif
+
+#endif /* __UTIL_DEFINES_H__ */
+
diff --git a/intern/cycles/util/util_logging.h b/intern/cycles/util/util_logging.h
index ecf9c9cfee0..492f830e67c 100644
--- a/intern/cycles/util/util_logging.h
+++ b/intern/cycles/util/util_logging.h
@@ -19,28 +19,30 @@
#if defined(WITH_CYCLES_LOGGING) && !defined(__KERNEL_GPU__)
# include <glog/logging.h>
-#else
-# include <iostream>
#endif
+#include <iostream>
+
CCL_NAMESPACE_BEGIN
#if !defined(WITH_CYCLES_LOGGING) || defined(__KERNEL_GPU__)
-class StubStream : public std::ostream {
- public:
- StubStream() : std::ostream(NULL) { }
+class StubStream {
+public:
+ template<class T>
+ StubStream& operator<<(const T&) {
+ return *this;
+ }
};
class LogMessageVoidify {
public:
LogMessageVoidify() { }
- void operator&(::std::ostream&) { }
+ void operator&(StubStream&) { }
};
# define LOG_SUPPRESS() (true) ? (void) 0 : LogMessageVoidify() & StubStream()
# define LOG(severity) LOG_SUPPRESS()
# define VLOG(severity) LOG_SUPPRESS()
-
#endif
#define VLOG_ONCE(level, flag) if(!flag) flag = true, VLOG(level)
diff --git a/intern/cycles/util/util_math.h b/intern/cycles/util/util_math.h
index b719640b19c..fb04d49bcd9 100644
--- a/intern/cycles/util/util_math.h
+++ b/intern/cycles/util/util_math.h
@@ -94,6 +94,7 @@ ccl_device_inline float fminf(float a, float b)
#ifndef __KERNEL_GPU__
using std::isfinite;
using std::isnan;
+using std::sqrt;
ccl_device_inline int abs(int x)
{
@@ -223,7 +224,7 @@ ccl_device_inline bool isfinite_safe(float f)
{
/* By IEEE 754 rule, 2*Inf equals Inf */
unsigned int x = __float_as_uint(f);
- return (f == f) && (x == 0 || (f != 2.0f*f)) && !((x << 1) > 0xff000000u);
+ return (f == f) && (x == 0 || x == (1u << 31) || (f != 2.0f*f)) && !((x << 1) > 0xff000000u);
}
ccl_device_inline float ensure_finite(float v)
@@ -329,15 +330,22 @@ template<class A, class B> A lerp(const A& a, const A& b, const B& t)
return (A)(a * ((B)1 - t) + b * t);
}
+#endif /* __KERNEL_OPENCL__ */
+
/* Triangle */
+#ifndef __KERNEL_OPENCL__
ccl_device_inline float triangle_area(const float3& v1,
const float3& v2,
const float3& v3)
+#else
+ccl_device_inline float triangle_area(const float3 v1,
+ const float3 v2,
+ const float3 v3)
+#endif
{
return len(cross(v3 - v2, v1 - v2))*0.5f;
}
-#endif /* __KERNEL_OPENCL__ */
/* Orthonormal vectors */
diff --git a/intern/cycles/util/util_math_float3.h b/intern/cycles/util/util_math_float3.h
index 5327d9f7cc6..e73e5bc17a2 100644
--- a/intern/cycles/util/util_math_float3.h
+++ b/intern/cycles/util/util_math_float3.h
@@ -108,8 +108,7 @@ ccl_device_inline float3 operator*(const float3& a, const float f)
ccl_device_inline float3 operator*(const float f, const float3& a)
{
- /* TODO(sergey): Currently disabled, gives speedup but causes precision issues. */
-#if defined(__KERNEL_SSE__) && 0
+#if defined(__KERNEL_SSE__)
return float3(_mm_mul_ps(_mm_set1_ps(f), a.m128));
#else
return make_float3(a.x*f, a.y*f, a.z*f);
@@ -118,10 +117,8 @@ ccl_device_inline float3 operator*(const float f, const float3& a)
ccl_device_inline float3 operator/(const float f, const float3& a)
{
- /* TODO(sergey): Currently disabled, gives speedup but causes precision issues. */
-#if defined(__KERNEL_SSE__) && 0
- __m128 rc = _mm_rcp_ps(a.m128);
- return float3(_mm_mul_ps(_mm_set1_ps(f),rc));
+#if defined(__KERNEL_SSE__)
+ return float3(_mm_div_ps(_mm_set1_ps(f), a.m128));
#else
return make_float3(f / a.x, f / a.y, f / a.z);
#endif
@@ -135,10 +132,8 @@ ccl_device_inline float3 operator/(const float3& a, const float f)
ccl_device_inline float3 operator/(const float3& a, const float3& b)
{
- /* TODO(sergey): Currently disabled, gives speedup but causes precision issues. */
-#if defined(__KERNEL_SSE__) && 0
- __m128 rc = _mm_rcp_ps(b.m128);
- return float3(_mm_mul_ps(a, rc));
+#if defined(__KERNEL_SSE__)
+ return float3(_mm_div_ps(a.m128, b.m128));
#else
return make_float3(a.x / b.x, a.y / b.y, a.z / b.z);
#endif
@@ -282,9 +277,8 @@ ccl_device_inline float3 mix(const float3& a, const float3& b, float t)
ccl_device_inline float3 rcp(const float3& a)
{
#ifdef __KERNEL_SSE__
- const float4 r(_mm_rcp_ps(a.m128));
- return float3(_mm_sub_ps(_mm_add_ps(r, r),
- _mm_mul_ps(_mm_mul_ps(r, r), a)));
+ /* Don't use _mm_rcp_ps due to poor precision. */
+ return float3(_mm_div_ps(_mm_set_ps1(1.0f), a.m128));
#else
return make_float3(1.0f/a.x, 1.0f/a.y, 1.0f/a.z);
#endif
@@ -374,9 +368,9 @@ ccl_device_inline bool isfinite3_safe(float3 v)
ccl_device_inline float3 ensure_finite3(float3 v)
{
- if(!isfinite_safe(v.x)) v.x = 0.0;
- if(!isfinite_safe(v.y)) v.y = 0.0;
- if(!isfinite_safe(v.z)) v.z = 0.0;
+ if(!isfinite_safe(v.x)) v.x = 0.0f;
+ if(!isfinite_safe(v.y)) v.y = 0.0f;
+ if(!isfinite_safe(v.z)) v.z = 0.0f;
return v;
}
diff --git a/intern/cycles/util/util_math_float4.h b/intern/cycles/util/util_math_float4.h
index d89121b3a1d..aa7e56fefe9 100644
--- a/intern/cycles/util/util_math_float4.h
+++ b/intern/cycles/util/util_math_float4.h
@@ -48,23 +48,30 @@ ccl_device_inline bool operator==(const float4& a, const float4& b);
ccl_device_inline float dot(const float4& a, const float4& b);
ccl_device_inline float len_squared(const float4& a);
ccl_device_inline float4 rcp(const float4& a);
+ccl_device_inline float4 sqrt(const float4& a);
+ccl_device_inline float4 sqr(const float4& a);
ccl_device_inline float4 cross(const float4& a, const float4& b);
ccl_device_inline bool is_zero(const float4& a);
-ccl_device_inline float reduce_add(const float4& a);
ccl_device_inline float average(const float4& a);
ccl_device_inline float len(const float4& a);
ccl_device_inline float4 normalize(const float4& a);
ccl_device_inline float4 safe_normalize(const float4& a);
ccl_device_inline float4 min(const float4& a, const float4& b);
ccl_device_inline float4 max(const float4& a, const float4& b);
+ccl_device_inline float4 fabs(const float4& a);
#endif /* !__KERNEL_OPENCL__*/
#ifdef __KERNEL_SSE__
template<size_t index_0, size_t index_1, size_t index_2, size_t index_3>
__forceinline const float4 shuffle(const float4& b);
+template<size_t index_0, size_t index_1, size_t index_2, size_t index_3>
+__forceinline const float4 shuffle(const float4& a, const float4& b);
template<> __forceinline const float4 shuffle<0, 1, 0, 1>(const float4& b);
+template<> __forceinline const float4 shuffle<0, 1, 0, 1>(const float4& a, const float4& b);
+template<> __forceinline const float4 shuffle<2, 3, 2, 3>(const float4& a, const float4& b);
+
# ifdef __KERNEL_SSE3__
template<> __forceinline const float4 shuffle<0, 0, 2, 2>(const float4& b);
template<> __forceinline const float4 shuffle<1, 1, 3, 3>(const float4& b);
@@ -77,9 +84,7 @@ ccl_device_inline float4 select(const int4& mask,
const float4& b);
ccl_device_inline float4 reduce_min(const float4& a);
ccl_device_inline float4 reduce_max(const float4& a);
-# if 0
ccl_device_inline float4 reduce_add(const float4& a);
-# endif
#endif /* !__KERNEL_GPU__ */
/*******************************************************************************
@@ -128,7 +133,7 @@ ccl_device_inline float4 operator/(const float4& a, float f)
ccl_device_inline float4 operator/(const float4& a, const float4& b)
{
#ifdef __KERNEL_SSE__
- return a * rcp(b);
+ return float4(_mm_div_ps(a.m128, b.m128));
#else
return make_float4(a.x/b.x, a.y/b.y, a.z/b.z, a.w/b.w);
#endif
@@ -171,8 +176,7 @@ ccl_device_inline float4 operator/=(float4& a, float f)
ccl_device_inline int4 operator<(const float4& a, const float4& b)
{
#ifdef __KERNEL_SSE__
- /* TODO(sergey): avoid cvt. */
- return int4(_mm_cvtps_epi32(_mm_cmplt_ps(a.m128, b.m128)));
+ return int4(_mm_castps_si128(_mm_cmplt_ps(a.m128, b.m128)));
#else
return make_int4(a.x < b.x, a.y < b.y, a.z < b.z, a.w < b.w);
#endif
@@ -181,8 +185,7 @@ ccl_device_inline int4 operator<(const float4& a, const float4& b)
ccl_device_inline int4 operator>=(const float4& a, const float4& b)
{
#ifdef __KERNEL_SSE__
- /* TODO(sergey): avoid cvt. */
- return int4(_mm_cvtps_epi32(_mm_cmpge_ps(a.m128, b.m128)));
+ return int4(_mm_castps_si128(_mm_cmpge_ps(a.m128, b.m128)));
#else
return make_int4(a.x >= b.x, a.y >= b.y, a.z >= b.z, a.w >= b.w);
#endif
@@ -191,8 +194,7 @@ ccl_device_inline int4 operator>=(const float4& a, const float4& b)
ccl_device_inline int4 operator<=(const float4& a, const float4& b)
{
#ifdef __KERNEL_SSE__
- /* TODO(sergey): avoid cvt. */
- return int4(_mm_cvtps_epi32(_mm_cmple_ps(a.m128, b.m128)));
+ return int4(_mm_castps_si128(_mm_cmple_ps(a.m128, b.m128)));
#else
return make_int4(a.x <= b.x, a.y <= b.y, a.z <= b.z, a.w <= b.w);
#endif
@@ -224,14 +226,30 @@ ccl_device_inline float len_squared(const float4& a)
ccl_device_inline float4 rcp(const float4& a)
{
#ifdef __KERNEL_SSE__
- float4 r(_mm_rcp_ps(a.m128));
- return float4(_mm_sub_ps(_mm_add_ps(r, r),
- _mm_mul_ps(_mm_mul_ps(r, r), a)));
+ /* Don't use _mm_rcp_ps due to poor precision. */
+ return float4(_mm_div_ps(_mm_set_ps1(1.0f), a.m128));
#else
return make_float4(1.0f/a.x, 1.0f/a.y, 1.0f/a.z, 1.0f/a.w);
#endif
}
+ccl_device_inline float4 sqrt(const float4& a)
+{
+#ifdef __KERNEL_SSE__
+ return float4(_mm_sqrt_ps(a.m128));
+#else
+ return make_float4(sqrtf(a.x),
+ sqrtf(a.y),
+ sqrtf(a.z),
+ sqrtf(a.w));
+#endif
+}
+
+ccl_device_inline float4 sqr(const float4& a)
+{
+ return a * a;
+}
+
ccl_device_inline float4 cross(const float4& a, const float4& b)
{
#ifdef __KERNEL_SSE__
@@ -254,20 +272,25 @@ ccl_device_inline bool is_zero(const float4& a)
#endif
}
-ccl_device_inline float reduce_add(const float4& a)
+ccl_device_inline float4 reduce_add(const float4& a)
{
#ifdef __KERNEL_SSE__
+# ifdef __KERNEL_SSE3__
+ float4 h(_mm_hadd_ps(a.m128, a.m128));
+ return float4( _mm_hadd_ps(h.m128, h.m128));
+# else
float4 h(shuffle<1,0,3,2>(a) + a);
- /* TODO(sergey): Investigate efficiency. */
- return _mm_cvtss_f32(shuffle<2,3,0,1>(h) + h);
+ return shuffle<2,3,0,1>(h) + h;
+# endif
#else
- return ((a.x + a.y) + (a.z + a.w));
+ float sum = (a.x + a.y) + (a.z + a.w);
+ return make_float4(sum, sum, sum, sum);
#endif
}
ccl_device_inline float average(const float4& a)
{
- return reduce_add(a) * 0.25f;
+ return reduce_add(a).x * 0.25f;
}
ccl_device_inline float len(const float4& a)
@@ -309,6 +332,18 @@ ccl_device_inline float4 max(const float4& a, const float4& b)
max(a.w, b.w));
#endif
}
+
+ccl_device_inline float4 fabs(const float4& a)
+{
+#ifdef __KERNEL_SSE__
+ return float4(_mm_and_ps(a.m128, _mm_castsi128_ps(_mm_set1_epi32(0x7fffffff))));
+#else
+ return make_float4(fabsf(a.x),
+ fabsf(a.y),
+ fabsf(a.z),
+ fabsf(a.w));
+#endif
+}
#endif /* !__KERNEL_OPENCL__*/
#ifdef __KERNEL_SSE__
@@ -320,11 +355,28 @@ __forceinline const float4 shuffle(const float4& b)
_MM_SHUFFLE(index_3, index_2, index_1, index_0))));
}
+template<size_t index_0, size_t index_1, size_t index_2, size_t index_3>
+__forceinline const float4 shuffle(const float4& a, const float4& b)
+{
+ return float4(_mm_shuffle_ps(a.m128, b.m128,
+ _MM_SHUFFLE(index_3, index_2, index_1, index_0)));
+}
+
template<> __forceinline const float4 shuffle<0, 1, 0, 1>(const float4& b)
{
return float4(_mm_castpd_ps(_mm_movedup_pd(_mm_castps_pd(b))));
}
+template<> __forceinline const float4 shuffle<0, 1, 0, 1>(const float4& a, const float4& b)
+{
+ return float4(_mm_movelh_ps(a.m128, b.m128));
+}
+
+template<> __forceinline const float4 shuffle<2, 3, 2, 3>(const float4& a, const float4& b)
+{
+ return float4(_mm_movehl_ps(b.m128, a.m128));
+}
+
# ifdef __KERNEL_SSE3__
template<> __forceinline const float4 shuffle<0, 0, 2, 2>(const float4& b)
{
@@ -344,9 +396,7 @@ ccl_device_inline float4 select(const int4& mask,
const float4& b)
{
#ifdef __KERNEL_SSE__
- /* TODO(sergey): avoid cvt. */
- return float4(_mm_or_ps(_mm_and_ps(_mm_cvtepi32_ps(mask), a),
- _mm_andnot_ps(_mm_cvtepi32_ps(mask), b)));
+ return float4(_mm_blendv_ps(b.m128, a.m128, _mm_castsi128_ps(mask.m128)));
#else
return make_float4((mask.x)? a.x: b.x,
(mask.y)? a.y: b.y,
@@ -355,6 +405,13 @@ ccl_device_inline float4 select(const int4& mask,
#endif
}
+ccl_device_inline float4 mask(const int4& mask,
+ const float4& a)
+{
+ /* Replace elements of x with zero where mask isn't set. */
+ return select(mask, a, make_float4(0.0f));
+}
+
ccl_device_inline float4 reduce_min(const float4& a)
{
#ifdef __KERNEL_SSE__
@@ -375,17 +432,15 @@ ccl_device_inline float4 reduce_max(const float4& a)
#endif
}
-#if 0
-ccl_device_inline float4 reduce_add(const float4& a)
+ccl_device_inline float4 load_float4(const float *v)
{
#ifdef __KERNEL_SSE__
- float4 h = shuffle<1,0,3,2>(a) + a;
- return shuffle<2,3,0,1>(h) + h;
+ return float4(_mm_loadu_ps(v));
#else
- return make_float4((a.x + a.y) + (a.z + a.w));
+ return make_float4(v[0], v[1], v[2], v[3]);
#endif
}
-#endif
+
#endif /* !__KERNEL_GPU__ */
CCL_NAMESPACE_END
diff --git a/intern/cycles/util/util_math_matrix.h b/intern/cycles/util/util_math_matrix.h
index c7511f8306e..b31dbe4fc67 100644
--- a/intern/cycles/util/util_math_matrix.h
+++ b/intern/cycles/util/util_math_matrix.h
@@ -223,20 +223,20 @@ ccl_device void math_matrix_jacobi_eigendecomposition(float *A, ccl_global float
{
const float singular_epsilon = 1e-9f;
- for (int row = 0; row < n; row++) {
- for (int col = 0; col < n; col++) {
+ for(int row = 0; row < n; row++) {
+ for(int col = 0; col < n; col++) {
MATS(V, n, row, col, v_stride) = (col == row) ? 1.0f : 0.0f;
}
}
- for (int sweep = 0; sweep < 8; sweep++) {
+ for(int sweep = 0; sweep < 8; sweep++) {
float off_diagonal = 0.0f;
- for (int row = 1; row < n; row++) {
- for (int col = 0; col < row; col++) {
+ for(int row = 1; row < n; row++) {
+ for(int col = 0; col < row; col++) {
off_diagonal += fabsf(MAT(A, n, row, col));
}
}
- if (off_diagonal < 1e-7f) {
+ if(off_diagonal < 1e-7f) {
/* The matrix has nearly reached diagonal form.
* Since the eigenvalues are only used to determine truncation, their exact values aren't required - a relative error of a few ULPs won't matter at all. */
break;
@@ -253,7 +253,7 @@ ccl_device void math_matrix_jacobi_eigendecomposition(float *A, ccl_global float
float abs_element = fabsf(element);
/* If we're in a later sweep and the element already is very small, just set it to zero and skip the rotation. */
- if (sweep > 3 && abs_element <= singular_epsilon*fabsf(MAT(A, n, row, row)) && abs_element <= singular_epsilon*fabsf(MAT(A, n, col, col))) {
+ if(sweep > 3 && abs_element <= singular_epsilon*fabsf(MAT(A, n, row, row)) && abs_element <= singular_epsilon*fabsf(MAT(A, n, col, col))) {
MAT(A, n, row, col) = 0.0f;
continue;
}
@@ -272,10 +272,10 @@ ccl_device void math_matrix_jacobi_eigendecomposition(float *A, ccl_global float
* Then, we compute sin(phi) and cos(phi) themselves. */
float singular_diff = MAT(A, n, row, row) - MAT(A, n, col, col);
float ratio;
- if (abs_element > singular_epsilon*fabsf(singular_diff)) {
+ if(abs_element > singular_epsilon*fabsf(singular_diff)) {
float cot_2phi = 0.5f*singular_diff / element;
ratio = 1.0f / (fabsf(cot_2phi) + sqrtf(1.0f + cot_2phi*cot_2phi));
- if (cot_2phi < 0.0f) ratio = -ratio; /* Copy sign. */
+ if(cot_2phi < 0.0f) ratio = -ratio; /* Copy sign. */
}
else {
ratio = element / singular_diff;
@@ -315,21 +315,21 @@ ccl_device void math_matrix_jacobi_eigendecomposition(float *A, ccl_global float
}
/* Sort eigenvalues and the associated eigenvectors. */
- for (int i = 0; i < n - 1; i++) {
+ for(int i = 0; i < n - 1; i++) {
float v = MAT(A, n, i, i);
int k = i;
- for (int j = i; j < n; j++) {
- if (MAT(A, n, j, j) >= v) {
+ for(int j = i; j < n; j++) {
+ if(MAT(A, n, j, j) >= v) {
v = MAT(A, n, j, j);
k = j;
}
}
- if (k != i) {
+ if(k != i) {
/* Swap eigenvalues. */
MAT(A, n, k, k) = MAT(A, n, i, i);
MAT(A, n, i, i) = v;
/* Swap eigenvectors. */
- for (int j = 0; j < n; j++) {
+ for(int j = 0; j < n; j++) {
float v = MATS(V, n, i, j, v_stride);
MATS(V, n, i, j, v_stride) = MATS(V, n, k, j, v_stride);
MATS(V, n, k, j, v_stride) = v;
@@ -339,59 +339,59 @@ ccl_device void math_matrix_jacobi_eigendecomposition(float *A, ccl_global float
}
#ifdef __KERNEL_SSE3__
-ccl_device_inline void math_vector_zero_sse(__m128 *A, int n)
+ccl_device_inline void math_vector_zero_sse(float4 *A, int n)
{
for(int i = 0; i < n; i++) {
- A[i] = _mm_setzero_ps();
+ A[i] = make_float4(0.0f);
}
}
-ccl_device_inline void math_matrix_zero_sse(__m128 *A, int n)
+ccl_device_inline void math_matrix_zero_sse(float4 *A, int n)
{
for(int row = 0; row < n; row++) {
for(int col = 0; col <= row; col++) {
- MAT(A, n, row, col) = _mm_setzero_ps();
+ MAT(A, n, row, col) = make_float4(0.0f);
}
}
}
/* Add Gramian matrix of v to A.
* The Gramian matrix of v is v^T*v, so element (i,j) is v[i]*v[j]. */
-ccl_device_inline void math_matrix_add_gramian_sse(__m128 *A, int n, const __m128 *ccl_restrict v, __m128 weight)
+ccl_device_inline void math_matrix_add_gramian_sse(float4 *A, int n, const float4 *ccl_restrict v, float4 weight)
{
for(int row = 0; row < n; row++) {
for(int col = 0; col <= row; col++) {
- MAT(A, n, row, col) = _mm_add_ps(MAT(A, n, row, col), _mm_mul_ps(_mm_mul_ps(v[row], v[col]), weight));
+ MAT(A, n, row, col) = MAT(A, n, row, col) + v[row] * v[col] * weight;
}
}
}
-ccl_device_inline void math_vector_add_sse(__m128 *V, int n, const __m128 *ccl_restrict a)
+ccl_device_inline void math_vector_add_sse(float4 *V, int n, const float4 *ccl_restrict a)
{
for(int i = 0; i < n; i++) {
- V[i] = _mm_add_ps(V[i], a[i]);
+ V[i] += a[i];
}
}
-ccl_device_inline void math_vector_mul_sse(__m128 *V, int n, const __m128 *ccl_restrict a)
+ccl_device_inline void math_vector_mul_sse(float4 *V, int n, const float4 *ccl_restrict a)
{
for(int i = 0; i < n; i++) {
- V[i] = _mm_mul_ps(V[i], a[i]);
+ V[i] *= a[i];
}
}
-ccl_device_inline void math_vector_max_sse(__m128 *a, const __m128 *ccl_restrict b, int n)
+ccl_device_inline void math_vector_max_sse(float4 *a, const float4 *ccl_restrict b, int n)
{
for(int i = 0; i < n; i++) {
- a[i] = _mm_max_ps(a[i], b[i]);
+ a[i] = max(a[i], b[i]);
}
}
-ccl_device_inline void math_matrix_hsum(float *A, int n, const __m128 *ccl_restrict B)
+ccl_device_inline void math_matrix_hsum(float *A, int n, const float4 *ccl_restrict B)
{
for(int row = 0; row < n; row++) {
for(int col = 0; col <= row; col++) {
- MAT(A, n, row, col) = _mm_hsum_ss(MAT(B, n, row, col));
+ MAT(A, n, row, col) = reduce_add(MAT(B, n, row, col))[0];
}
}
}
diff --git a/intern/cycles/util/util_optimization.h b/intern/cycles/util/util_optimization.h
index 6f70a474fe7..3c5785c4807 100644
--- a/intern/cycles/util/util_optimization.h
+++ b/intern/cycles/util/util_optimization.h
@@ -19,22 +19,15 @@
#ifndef __KERNEL_GPU__
-/* quiet unused define warnings */
-#if defined(__KERNEL_SSE2__) || \
- defined(__KERNEL_SSE3__) || \
- defined(__KERNEL_SSSE3__) || \
- defined(__KERNEL_SSE41__) || \
- defined(__KERNEL_AVX__) || \
- defined(__KERNEL_AVX2__)
- /* do nothing */
-#endif
-
/* x86
*
* Compile a regular, SSE2 and SSE3 kernel. */
#if defined(i386) || defined(_M_IX86)
+/* We require minimum SSE2 support on x86, so auto enable. */
+# define __KERNEL_SSE2__
+
# ifdef WITH_KERNEL_SSE2
# define WITH_CYCLES_OPTIMIZED_KERNEL_SSE2
# endif
@@ -73,48 +66,6 @@
#endif /* defined(__x86_64__) || defined(_M_X64) */
-/* SSE Experiment
- *
- * This is disabled code for an experiment to use SSE types globally for types
- * such as float3 and float4. Currently this gives an overall slowdown. */
-
-#if 0
-# define __KERNEL_SSE__
-# ifndef __KERNEL_SSE2__
-# define __KERNEL_SSE2__
-# endif
-# ifndef __KERNEL_SSE3__
-# define __KERNEL_SSE3__
-# endif
-# ifndef __KERNEL_SSSE3__
-# define __KERNEL_SSSE3__
-# endif
-# ifndef __KERNEL_SSE4__
-# define __KERNEL_SSE4__
-# endif
-#endif
-
-/* SSE Intrinsics includes
- *
- * We assume __KERNEL_SSEX__ flags to have been defined at this point */
-
-/* SSE intrinsics headers */
-#ifndef FREE_WINDOWS64
-
-#ifdef _MSC_VER
-# include <intrin.h>
-#elif (defined(__x86_64__) || defined(__i386__))
-# include <x86intrin.h>
-#endif
-
-#else
-
-/* MinGW64 has conflicting declarations for these SSE headers in <windows.h>.
- * Since we can't avoid including <windows.h>, better only include that */
-#include "util/util_windows.h"
-
-#endif
-
#endif
#endif /* __UTIL_OPTIMIZATION_H__ */
diff --git a/intern/cycles/util/util_path.cpp b/intern/cycles/util/util_path.cpp
index f9c3b4bb139..bae5d5bd6d1 100644
--- a/intern/cycles/util/util_path.cpp
+++ b/intern/cycles/util/util_path.cpp
@@ -45,6 +45,7 @@ OIIO_NAMESPACE_USING
# include <shlwapi.h>
#endif
+#include "util/util_map.h"
#include "util/util_windows.h"
CCL_NAMESPACE_BEGIN
@@ -768,68 +769,180 @@ bool path_remove(const string& path)
return remove(path.c_str()) == 0;
}
-static string line_directive(const string& base, const string& path, int line)
+struct SourceReplaceState {
+ typedef map<string, string> ProcessedMapping;
+ /* Base director for all relative include headers. */
+ string base;
+ /* Result of processed files. */
+ ProcessedMapping processed_files;
+ /* Set of files which are considered "precompiled" and which are replaced
+ * with and empty string on a subsequent occurrence in include statement.
+ */
+ set<string> precompiled_headers;
+};
+
+static string path_source_replace_includes_recursive(
+ const string& source,
+ const string& source_filepath,
+ SourceReplaceState *state);
+
+static string line_directive(const SourceReplaceState& state,
+ const string& path,
+ const int line)
{
- string escaped_path = path;
+ string unescaped_path = path;
/* First we make path relative. */
- if(string_startswith(escaped_path, base.c_str())) {
- const string base_file = path_filename(base);
- const size_t base_len = base.length();
- escaped_path = base_file + escaped_path.substr(base_len,
- escaped_path.length() - base_len);
+ if(string_startswith(unescaped_path, state.base.c_str())) {
+ const string base_file = path_filename(state.base);
+ const size_t base_len = state.base.length();
+ unescaped_path = base_file +
+ unescaped_path.substr(base_len,
+ unescaped_path.length() - base_len);
}
/* Second, we replace all unsafe characters. */
- string_replace(escaped_path, "\"", "\\\"");
- string_replace(escaped_path, "\'", "\\\'");
- string_replace(escaped_path, "\?", "\\\?");
- string_replace(escaped_path, "\\", "\\\\");
+ const size_t length = unescaped_path.length();
+ string escaped_path = "";
+ for(size_t i = 0; i < length; ++i) {
+ const char ch = unescaped_path[i];
+ if(strchr("\"\'\?\\", ch) != NULL) {
+ escaped_path += "\\";
+ }
+ escaped_path += ch;
+ }
+ /* TODO(sergey): Check whether using std::to_string combined with several
+ * concatenation operations is any faster.
+ */
return string_printf("#line %d \"%s\"", line, escaped_path.c_str());
}
+static string path_source_handle_preprocessor(
+ const string& preprocessor_line,
+ const string& source_filepath,
+ const size_t line_number,
+ SourceReplaceState *state)
+{
+ string result = preprocessor_line;
+ string token = string_strip(
+ preprocessor_line.substr(1, preprocessor_line.size() - 1));
+ if(string_startswith(token, "include")) {
+ token = string_strip(token.substr(7, token.size() - 7));
+ if(token[0] == '"') {
+ const size_t n_start = 1;
+ const size_t n_end = token.find("\"", n_start);
+ const string filename = token.substr(n_start, n_end - n_start);
+ const bool is_precompiled = string_endswith(token, "// PRECOMPILED");
+ string filepath = path_join(state->base, filename);
+ if(!path_exists(filepath)) {
+ filepath = path_join(path_dirname(source_filepath),
+ filename);
+ }
+ if(is_precompiled) {
+ state->precompiled_headers.insert(filepath);
+ }
+ string text;
+ if(path_read_text(filepath, text)) {
+ text = path_source_replace_includes_recursive(
+ text, filepath, state);
+ /* Use line directives for better error messages. */
+ result = line_directive(*state, filepath, 1) + "\n"
+ + text + "\n"
+ + line_directive(*state, source_filepath, line_number + 1);
+ }
+ }
+ }
+ return result;
+}
+
+/* Our own little c preprocessor that replaces #includes with the file
+ * contents, to work around issue of OpenCL drivers not supporting
+ * include paths with spaces in them.
+ */
static string path_source_replace_includes_recursive(
- const string& base,
const string& source,
- const string& source_filepath)
+ const string& source_filepath,
+ SourceReplaceState *state)
{
- /* Our own little c preprocessor that replaces #includes with the file
- * contents, to work around issue of OpenCL drivers not supporting
- * include paths with spaces in them.
+ /* Try to re-use processed file without spending time on replacing all
+ * include directives again.
*/
-
+ SourceReplaceState::ProcessedMapping::iterator replaced_file =
+ state->processed_files.find(source_filepath);
+ if(replaced_file != state->processed_files.end()) {
+ if(state->precompiled_headers.find(source_filepath) !=
+ state->precompiled_headers.end()) {
+ return "";
+ }
+ return replaced_file->second;
+ }
+ /* Perform full file processing. */
string result = "";
- vector<string> lines;
- string_split(lines, source, "\n", false);
-
- for(size_t i = 0; i < lines.size(); ++i) {
- string line = lines[i];
- if(line[0] == '#') {
- string token = string_strip(line.substr(1, line.size() - 1));
- if(string_startswith(token, "include")) {
- token = string_strip(token.substr(7, token.size() - 7));
- if(token[0] == '"') {
- const size_t n_start = 1;
- const size_t n_end = token.find("\"", n_start);
- const string filename = token.substr(n_start, n_end - n_start);
- string filepath = path_join(base, filename);
- if(!path_exists(filepath)) {
- filepath = path_join(path_dirname(source_filepath),
- filename);
- }
- string text;
- if(path_read_text(filepath, text)) {
- text = path_source_replace_includes_recursive(
- base, text, filepath);
- /* Use line directives for better error messages. */
- line = line_directive(base, filepath, 1)
- + token.replace(0, n_end + 1, "\n" + text + "\n")
- + line_directive(base, source_filepath, i + 1);
- }
- }
+ const size_t source_length = source.length();
+ size_t index = 0;
+ /* Information about where we are in the source. */
+ size_t line_number = 0, column_number = 1;
+ /* Currently gathered non-preprocessor token.
+ * Store as start/length rather than token itself to avoid overhead of
+ * memory re-allocations on each character concatenation.
+ */
+ size_t token_start = 0, token_length = 0;
+ /* Denotes whether we're inside of preprocessor line, together with
+ * preprocessor line itself.
+ *
+ * TODO(sergey): Investigate whether using token start/end position
+ * gives measurable speedup.
+ */
+ bool inside_preprocessor = false;
+ string preprocessor_line = "";
+ /* Actual loop over the whole source. */
+ while(index < source_length) {
+ const char ch = source[index];
+ if(ch == '\n') {
+ if(inside_preprocessor) {
+ result += path_source_handle_preprocessor(preprocessor_line,
+ source_filepath,
+ line_number,
+ state);
+ /* Start gathering net part of the token. */
+ token_start = index;
+ token_length = 0;
+ }
+ inside_preprocessor = false;
+ preprocessor_line = "";
+ column_number = 0;
+ ++line_number;
+ }
+ else if(ch == '#' && column_number == 1 && !inside_preprocessor) {
+ /* Append all possible non-preprocessor token to the result. */
+ if(token_length != 0) {
+ result.append(source, token_start, token_length);
+ token_start = index;
+ token_length = 0;
}
+ inside_preprocessor = true;
+ }
+ if(inside_preprocessor) {
+ preprocessor_line += ch;
+ }
+ else {
+ ++token_length;
}
- result += line + "\n";
+ ++index;
+ ++column_number;
}
-
+ /* Append possible tokens which happened before special events handled
+ * above.
+ */
+ if(token_length != 0) {
+ result.append(source, token_start, token_length);
+ }
+ if(inside_preprocessor) {
+ result += path_source_handle_preprocessor(preprocessor_line,
+ source_filepath,
+ line_number,
+ state);
+ }
+ /* Store result for further reuse. */
+ state->processed_files[source_filepath] = result;
return result;
}
@@ -837,10 +950,12 @@ string path_source_replace_includes(const string& source,
const string& path,
const string& source_filename)
{
+ SourceReplaceState state;
+ state.base = path;
return path_source_replace_includes_recursive(
- path,
source,
- path_join(path, source_filename));
+ path_join(path, source_filename),
+ &state);
}
FILE *path_fopen(const string& path, const string& mode)
diff --git a/intern/cycles/util/util_progress.h b/intern/cycles/util/util_progress.h
index cd4fe52fdc9..134383e88db 100644
--- a/intern/cycles/util/util_progress.h
+++ b/intern/cycles/util/util_progress.h
@@ -41,6 +41,7 @@ public:
denoised_tiles = 0;
start_time = time_dt();
render_start_time = time_dt();
+ end_time = 0.0;
status = "Initializing";
substatus = "";
sync_status = "";
@@ -80,6 +81,7 @@ public:
denoised_tiles = 0;
start_time = time_dt();
render_start_time = time_dt();
+ end_time = 0.0;
status = "Initializing";
substatus = "";
sync_status = "";
@@ -146,6 +148,7 @@ public:
thread_scoped_lock lock(progress_mutex);
start_time = time_dt();
+ end_time = 0.0;
}
void set_render_start_time()
@@ -169,8 +172,15 @@ public:
{
thread_scoped_lock lock(progress_mutex);
- total_time_ = time_dt() - start_time;
- render_time_ = time_dt() - render_start_time;
+ double time = (end_time > 0) ? end_time : time_dt();
+
+ total_time_ = time - start_time;
+ render_time_ = time - render_start_time;
+ }
+
+ void set_end_time()
+ {
+ end_time = time_dt();
}
void reset_sample()
@@ -337,6 +347,8 @@ protected:
int rendered_tiles, denoised_tiles;
double start_time, render_start_time;
+ /* End time written when render is done, so it doesn't keep increasing on redraws. */
+ double end_time;
string status;
string substatus;
diff --git a/intern/cycles/util/util_simd.h b/intern/cycles/util/util_simd.h
index 587febe3e52..58b3d267266 100644
--- a/intern/cycles/util/util_simd.h
+++ b/intern/cycles/util/util_simd.h
@@ -18,19 +18,38 @@
#ifndef __UTIL_SIMD_TYPES_H__
#define __UTIL_SIMD_TYPES_H__
+#ifndef __KERNEL_GPU__
+
#include <limits>
#include "util/util_debug.h"
-#include "util/util_types.h"
+#include "util/util_defines.h"
+
+/* SSE Intrinsics includes
+ *
+ * We assume __KERNEL_SSEX__ flags to have been defined at this point */
+
+/* SSE intrinsics headers */
+#ifndef FREE_WINDOWS64
+
+#ifdef _MSC_VER
+# include <intrin.h>
+#elif (defined(__x86_64__) || defined(__i386__))
+# include <x86intrin.h>
+#endif
+
+#else
+
+/* MinGW64 has conflicting declarations for these SSE headers in <windows.h>.
+ * Since we can't avoid including <windows.h>, better only include that */
+#include "util/util_windows.h"
+
+#endif
CCL_NAMESPACE_BEGIN
#ifdef __KERNEL_SSE2__
-struct sseb;
-struct ssei;
-struct ssef;
-
extern const __m128 _mm_lookupmask_ps[16];
/* Special Types */
@@ -328,12 +347,12 @@ __forceinline size_t __bscf(size_t& v)
#endif /* _WIN32 */
-static const unsigned int BITSCAN_NO_BIT_SET_32 = 32;
-static const size_t BITSCAN_NO_BIT_SET_64 = 64;
+/* Test __KERNEL_SSE41__ for MSVC which does not define __SSE4_1__, and test
+ * __SSE4_1__ to avoid OpenImageIO conflicts with our emulation macros on other
+ * platforms when compiling code outside the kernel. */
+#if !(defined(__KERNEL_SSE41__) || defined(__SSE4_1__) || defined(__SSE4_2__))
-#ifdef __KERNEL_SSE3__
-/* Emulation of SSE4 functions with SSE3 */
-# ifndef __KERNEL_SSE41__
+/* Emulation of SSE4 functions with SSE2 */
#define _MM_FROUND_TO_NEAREST_INT 0x00
#define _MM_FROUND_TO_NEG_INF 0x01
@@ -342,50 +361,50 @@ static const size_t BITSCAN_NO_BIT_SET_64 = 64;
#define _MM_FROUND_CUR_DIRECTION 0x04
#undef _mm_blendv_ps
-#define _mm_blendv_ps __emu_mm_blendv_ps
-__forceinline __m128 _mm_blendv_ps( __m128 value, __m128 input, __m128 mask ) {
- return _mm_or_ps(_mm_and_ps(mask, input), _mm_andnot_ps(mask, value));
+#define _mm_blendv_ps _mm_blendv_ps_emu
+__forceinline __m128 _mm_blendv_ps_emu( __m128 value, __m128 input, __m128 mask)
+{
+ __m128i isignmask = _mm_set1_epi32(0x80000000);
+ __m128 signmask = _mm_castsi128_ps(isignmask);
+ __m128i iandsign = _mm_castps_si128(_mm_and_ps(mask, signmask));
+ __m128i icmpmask = _mm_cmpeq_epi32(iandsign, isignmask);
+ __m128 cmpmask = _mm_castsi128_ps(icmpmask);
+ return _mm_or_ps(_mm_and_ps(cmpmask, input), _mm_andnot_ps(cmpmask, value));
}
#undef _mm_blend_ps
-#define _mm_blend_ps __emu_mm_blend_ps
-__forceinline __m128 _mm_blend_ps( __m128 value, __m128 input, const int mask ) {
+#define _mm_blend_ps _mm_blend_ps_emu
+__forceinline __m128 _mm_blend_ps_emu( __m128 value, __m128 input, const int mask)
+{
assert(mask < 0x10); return _mm_blendv_ps(value, input, _mm_lookupmask_ps[mask]);
}
#undef _mm_blendv_epi8
-#define _mm_blendv_epi8 __emu_mm_blendv_epi8
-__forceinline __m128i _mm_blendv_epi8( __m128i value, __m128i input, __m128i mask ) {
+#define _mm_blendv_epi8 _mm_blendv_epi8_emu
+__forceinline __m128i _mm_blendv_epi8_emu( __m128i value, __m128i input, __m128i mask)
+{
return _mm_or_si128(_mm_and_si128(mask, input), _mm_andnot_si128(mask, value));
}
-#undef _mm_mullo_epi32
-#define _mm_mullo_epi32 __emu_mm_mullo_epi32
-__forceinline __m128i _mm_mullo_epi32( __m128i value, __m128i input ) {
- __m128i rvalue;
- char* _r = (char*)(&rvalue + 1);
- char* _v = (char*)(& value + 1);
- char* _i = (char*)(& input + 1);
- for( ssize_t i = -16 ; i != 0 ; i += 4 ) *((int32_t*)(_r + i)) = *((int32_t*)(_v + i))* *((int32_t*)(_i + i));
- return rvalue;
-}
-
#undef _mm_min_epi32
-#define _mm_min_epi32 __emu_mm_min_epi32
-__forceinline __m128i _mm_min_epi32( __m128i value, __m128i input ) {
+#define _mm_min_epi32 _mm_min_epi32_emu
+__forceinline __m128i _mm_min_epi32_emu( __m128i value, __m128i input)
+{
return _mm_blendv_epi8(input, value, _mm_cmplt_epi32(value, input));
}
#undef _mm_max_epi32
-#define _mm_max_epi32 __emu_mm_max_epi32
-__forceinline __m128i _mm_max_epi32( __m128i value, __m128i input ) {
+#define _mm_max_epi32 _mm_max_epi32_emu
+__forceinline __m128i _mm_max_epi32_emu( __m128i value, __m128i input)
+{
return _mm_blendv_epi8(value, input, _mm_cmplt_epi32(value, input));
}
#undef _mm_extract_epi32
-#define _mm_extract_epi32 __emu_mm_extract_epi32
-__forceinline int _mm_extract_epi32( __m128i input, const int index ) {
- switch ( index ) {
+#define _mm_extract_epi32 _mm_extract_epi32_emu
+__forceinline int _mm_extract_epi32_emu( __m128i input, const int index)
+{
+ switch(index) {
case 0: return _mm_cvtsi128_si32(input);
case 1: return _mm_cvtsi128_si32(_mm_shuffle_epi32(input, _MM_SHUFFLE(1, 1, 1, 1)));
case 2: return _mm_cvtsi128_si32(_mm_shuffle_epi32(input, _MM_SHUFFLE(2, 2, 2, 2)));
@@ -395,27 +414,26 @@ __forceinline int _mm_extract_epi32( __m128i input, const int index ) {
}
#undef _mm_insert_epi32
-#define _mm_insert_epi32 __emu_mm_insert_epi32
-__forceinline __m128i _mm_insert_epi32( __m128i value, int input, const int index ) {
+#define _mm_insert_epi32 _mm_insert_epi32_emu
+__forceinline __m128i _mm_insert_epi32_emu( __m128i value, int input, const int index)
+{
assert(index >= 0 && index < 4); ((int*)&value)[index] = input; return value;
}
-#undef _mm_extract_ps
-#define _mm_extract_ps __emu_mm_extract_ps
-__forceinline int _mm_extract_ps( __m128 input, const int index ) {
- int32_t* ptr = (int32_t*)&input; return ptr[index];
-}
-
#undef _mm_insert_ps
-#define _mm_insert_ps __emu_mm_insert_ps
-__forceinline __m128 _mm_insert_ps( __m128 value, __m128 input, const int index )
-{ assert(index < 0x100); ((float*)&value)[(index >> 4)&0x3] = ((float*)&input)[index >> 6]; return _mm_andnot_ps(_mm_lookupmask_ps[index&0xf], value); }
+#define _mm_insert_ps _mm_insert_ps_emu
+__forceinline __m128 _mm_insert_ps_emu( __m128 value, __m128 input, const int index)
+{
+ assert(index < 0x100);
+ ((float*)&value)[(index >> 4)&0x3] = ((float*)&input)[index >> 6];
+ return _mm_andnot_ps(_mm_lookupmask_ps[index&0xf], value);
+}
#undef _mm_round_ps
-#define _mm_round_ps __emu_mm_round_ps
-__forceinline __m128 _mm_round_ps( __m128 value, const int flags )
+#define _mm_round_ps _mm_round_ps_emu
+__forceinline __m128 _mm_round_ps_emu( __m128 value, const int flags)
{
- switch ( flags )
+ switch(flags)
{
case _MM_FROUND_TO_NEAREST_INT: return _mm_cvtepi32_ps(_mm_cvtps_epi32(value));
case _MM_FROUND_TO_NEG_INF : return _mm_cvtepi32_ps(_mm_cvtps_epi32(_mm_add_ps(value, _mm_set1_ps(-0.5f))));
@@ -425,57 +443,7 @@ __forceinline __m128 _mm_round_ps( __m128 value, const int flags )
return value;
}
-# ifdef _M_X64
-#undef _mm_insert_epi64
-#define _mm_insert_epi64 __emu_mm_insert_epi64
-__forceinline __m128i _mm_insert_epi64( __m128i value, __int64 input, const int index ) {
- assert(size_t(index) < 4); ((__int64*)&value)[index] = input; return value;
-}
-
-#undef _mm_extract_epi64
-#define _mm_extract_epi64 __emu_mm_extract_epi64
-__forceinline __int64 _mm_extract_epi64( __m128i input, const int index ) {
- assert(size_t(index) < 2);
- return index == 0 ? _mm_cvtsi128_si64x(input) : _mm_cvtsi128_si64x(_mm_unpackhi_epi64(input, input));
-}
-# endif
-
-# endif
-
-#undef _mm_fabs_ps
-#define _mm_fabs_ps(x) _mm_and_ps(x, _mm_castsi128_ps(_mm_set1_epi32(0x7fffffff)))
-
-/* Return a __m128 with every element set to the largest element of v. */
-ccl_device_inline __m128 _mm_hmax_ps(__m128 v)
-{
- /* v[0, 1, 2, 3] => [0, 1, 0, 1] and [2, 3, 2, 3] => v[max(0, 2), max(1, 3), max(0, 2), max(1, 3)] */
- v = _mm_max_ps(_mm_movehl_ps(v, v), _mm_movelh_ps(v, v));
- /* v[max(0, 2), max(1, 3), max(0, 2), max(1, 3)] => [4 times max(1, 3)] and [4 times max(0, 2)] => v[4 times max(0, 1, 2, 3)] */
- v = _mm_max_ps(_mm_movehdup_ps(v), _mm_moveldup_ps(v));
- return v;
-}
-
-/* Return the sum of the four elements of x. */
-ccl_device_inline float _mm_hsum_ss(__m128 x)
-{
- __m128 a = _mm_movehdup_ps(x);
- __m128 b = _mm_add_ps(x, a);
- return _mm_cvtss_f32(_mm_add_ss(_mm_movehl_ps(a, b), b));
-}
-
-/* Return a __m128 with every element set to the sum of the four elements of x. */
-ccl_device_inline __m128 _mm_hsum_ps(__m128 x)
-{
- x = _mm_hadd_ps(x, x);
- x = _mm_hadd_ps(x, x);
- return x;
-}
-
-/* Replace elements of x with zero where mask isn't set. */
-#undef _mm_mask_ps
-#define _mm_mask_ps(x, mask) _mm_blendv_ps(_mm_setzero_ps(), x, mask)
-
-#endif
+#endif /* !(defined(__KERNEL_SSE41__) || defined(__SSE4_1__) || defined(__SSE4_2__)) */
#else /* __KERNEL_SSE2__ */
@@ -496,13 +464,19 @@ ccl_device_inline int bitscan(int value)
#endif /* __KERNEL_SSE2__ */
+/* quiet unused define warnings */
+#if defined(__KERNEL_SSE2__) || \
+ defined(__KERNEL_SSE3__) || \
+ defined(__KERNEL_SSSE3__) || \
+ defined(__KERNEL_SSE41__) || \
+ defined(__KERNEL_AVX__) || \
+ defined(__KERNEL_AVX2__)
+ /* do nothing */
+#endif
+
CCL_NAMESPACE_END
-#include "util/util_math.h"
-#include "util/util_sseb.h"
-#include "util/util_ssei.h"
-#include "util/util_ssef.h"
-#include "util/util_avxf.h"
+#endif /* __KERNEL_GPU__ */
#endif /* __UTIL_SIMD_TYPES_H__ */
diff --git a/intern/cycles/util/util_sseb.h b/intern/cycles/util/util_sseb.h
index 6e669701f3b..93c22aafdcd 100644
--- a/intern/cycles/util/util_sseb.h
+++ b/intern/cycles/util/util_sseb.h
@@ -22,6 +22,9 @@ CCL_NAMESPACE_BEGIN
#ifdef __KERNEL_SSE2__
+struct ssei;
+struct ssef;
+
/*! 4-wide SSE bool type. */
struct sseb
{
diff --git a/intern/cycles/util/util_ssef.h b/intern/cycles/util/util_ssef.h
index cf99a08efae..bb007ff84a9 100644
--- a/intern/cycles/util/util_ssef.h
+++ b/intern/cycles/util/util_ssef.h
@@ -22,6 +22,9 @@ CCL_NAMESPACE_BEGIN
#ifdef __KERNEL_SSE2__
+struct sseb;
+struct ssef;
+
/*! 4-wide SSE float type. */
struct ssef
{
diff --git a/intern/cycles/util/util_ssei.h b/intern/cycles/util/util_ssei.h
index 5f62569268c..ef2a9e68b7d 100644
--- a/intern/cycles/util/util_ssei.h
+++ b/intern/cycles/util/util_ssei.h
@@ -22,6 +22,9 @@ CCL_NAMESPACE_BEGIN
#ifdef __KERNEL_SSE2__
+struct sseb;
+struct ssef;
+
/*! 4-wide SSE integer type. */
struct ssei
{
@@ -234,8 +237,10 @@ __forceinline size_t select_max(const sseb& valid, const ssei& v) { const ssei a
#else
-__forceinline int reduce_min(const ssei& v) { return min(min(v[0],v[1]),min(v[2],v[3])); }
-__forceinline int reduce_max(const ssei& v) { return max(max(v[0],v[1]),max(v[2],v[3])); }
+__forceinline int ssei_min(int a, int b) { return (a < b)? a: b; }
+__forceinline int ssei_max(int a, int b) { return (a > b)? a: b; }
+__forceinline int reduce_min(const ssei& v) { return ssei_min(ssei_min(v[0],v[1]),ssei_min(v[2],v[3])); }
+__forceinline int reduce_max(const ssei& v) { return ssei_max(ssei_max(v[0],v[1]),ssei_max(v[2],v[3])); }
__forceinline int reduce_add(const ssei& v) { return v[0]+v[1]+v[2]+v[3]; }
#endif
diff --git a/intern/cycles/util/util_stats.h b/intern/cycles/util/util_stats.h
index baba549753d..7667f58eb7d 100644
--- a/intern/cycles/util/util_stats.h
+++ b/intern/cycles/util/util_stats.h
@@ -30,7 +30,7 @@ public:
void mem_alloc(size_t size) {
atomic_add_and_fetch_z(&mem_used, size);
- atomic_update_max_z(&mem_peak, mem_used);
+ atomic_fetch_and_update_max_z(&mem_peak, mem_used);
}
void mem_free(size_t size) {
diff --git a/intern/cycles/util/util_task.cpp b/intern/cycles/util/util_task.cpp
index fb0c34e1dc4..6ed97b0e0a6 100644
--- a/intern/cycles/util/util_task.cpp
+++ b/intern/cycles/util/util_task.cpp
@@ -206,9 +206,9 @@ void TaskScheduler::init(int num_threads)
threads.resize(num_threads);
const int num_groups = system_cpu_group_count();
- unsigned short num_process_groups;
+ unsigned short num_process_groups = 0;
vector<unsigned short> process_groups;
- int current_group_threads;
+ int current_group_threads = 0;
if(num_groups > 1) {
process_groups.resize(num_groups);
num_process_groups = system_cpu_process_groups(num_groups,
diff --git a/intern/cycles/util/util_time.h b/intern/cycles/util/util_time.h
index 65798244111..f03aa590e9b 100644
--- a/intern/cycles/util/util_time.h
+++ b/intern/cycles/util/util_time.h
@@ -37,7 +37,7 @@ public:
~scoped_timer()
{
if(value_ != NULL) {
- *value_ = time_dt() - time_start_;
+ *value_ = get_time();
}
}
@@ -46,6 +46,11 @@ public:
return time_start_;
}
+ double get_time() const
+ {
+ return time_dt() - time_start_;
+ }
+
protected:
double *value_;
double time_start_;
diff --git a/intern/cycles/util/util_types.h b/intern/cycles/util/util_types.h
index a5d1d7152d5..aabca6c81fc 100644
--- a/intern/cycles/util/util_types.h
+++ b/intern/cycles/util/util_types.h
@@ -21,72 +21,18 @@
# include <stdlib.h>
#endif
-/* Bitness */
+/* Standard Integer Types */
-#if defined(__ppc64__) || defined(__PPC64__) || defined(__x86_64__) || defined(__ia64__) || defined(_M_X64)
-# define __KERNEL_64_BIT__
+#if !defined(__KERNEL_GPU__) && !defined(_WIN32)
+# include <stdint.h>
#endif
-/* Qualifiers for kernel code shared by CPU and GPU */
-
-#ifndef __KERNEL_GPU__
-# define ccl_device static inline
-# define ccl_device_noinline static
-# define ccl_global
-# define ccl_constant
-# define ccl_local
-# define ccl_local_param
-# define ccl_private
-# define ccl_restrict __restrict
-# define __KERNEL_WITH_SSE_ALIGN__
-
-# if defined(_WIN32) && !defined(FREE_WINDOWS)
-# define ccl_device_inline static __forceinline
-# define ccl_device_forceinline static __forceinline
-# define ccl_align(...) __declspec(align(__VA_ARGS__))
-# ifdef __KERNEL_64_BIT__
-# define ccl_try_align(...) __declspec(align(__VA_ARGS__))
-# else /* __KERNEL_64_BIT__ */
-# undef __KERNEL_WITH_SSE_ALIGN__
-/* No support for function arguments (error C2719). */
-# define ccl_try_align(...)
-# endif /* __KERNEL_64_BIT__ */
-# define ccl_may_alias
-# define ccl_always_inline __forceinline
-# define ccl_never_inline __declspec(noinline)
-# define ccl_maybe_unused
-# else /* _WIN32 && !FREE_WINDOWS */
-# define ccl_device_inline static inline __attribute__((always_inline))
-# define ccl_device_forceinline static inline __attribute__((always_inline))
-# define ccl_align(...) __attribute__((aligned(__VA_ARGS__)))
-# ifndef FREE_WINDOWS64
-# define __forceinline inline __attribute__((always_inline))
-# endif
-# define ccl_try_align(...) __attribute__((aligned(__VA_ARGS__)))
-# define ccl_may_alias __attribute__((__may_alias__))
-# define ccl_always_inline __attribute__((always_inline))
-# define ccl_never_inline __attribute__((noinline))
-# define ccl_maybe_unused __attribute__((used))
-# endif /* _WIN32 && !FREE_WINDOWS */
-
-/* Use to suppress '-Wimplicit-fallthrough' (in place of 'break'). */
-# if defined(__GNUC__) && (__GNUC__ >= 7) /* gcc7.0+ only */
-# define ATTR_FALLTHROUGH __attribute__((fallthrough))
-# else
-# define ATTR_FALLTHROUGH ((void)0)
-# endif
-#endif /* __KERNEL_GPU__ */
-
-/* Standard Integer Types */
+#include "util/util_defines.h"
#ifndef __KERNEL_GPU__
-/* int8_t, uint16_t, and friends */
-# ifndef _WIN32
-# include <stdint.h>
-# endif
-/* SIMD Types */
# include "util/util_optimization.h"
-#endif /* __KERNEL_GPU__ */
+# include "util/util_simd.h"
+#endif
CCL_NAMESPACE_BEGIN
@@ -201,65 +147,8 @@ enum ExtensionType {
EXTENSION_NUM_TYPES,
};
-/* macros */
-
-/* hints for branch prediction, only use in code that runs a _lot_ */
-#if defined(__GNUC__) && defined(__KERNEL_CPU__)
-# define LIKELY(x) __builtin_expect(!!(x), 1)
-# define UNLIKELY(x) __builtin_expect(!!(x), 0)
-#else
-# define LIKELY(x) (x)
-# define UNLIKELY(x) (x)
-#endif
-
-#if defined(__cplusplus) && ((__cplusplus >= 201103L) || (defined(_MSC_VER) && _MSC_VER >= 1800))
-# define HAS_CPP11_FEATURES
-#endif
-
-#if defined(__GNUC__) || defined(__clang__)
-# if defined(HAS_CPP11_FEATURES)
-/* Some magic to be sure we don't have reference in the type. */
-template<typename T> static inline T decltype_helper(T x) { return x; }
-# define TYPEOF(x) decltype(decltype_helper(x))
-# else
-# define TYPEOF(x) typeof(x)
-# endif
-#endif
-
-/* Causes warning:
- * incompatible types when assigning to type 'Foo' from type 'Bar'
- * ... the compiler optimizes away the temp var */
-#ifdef __GNUC__
-#define CHECK_TYPE(var, type) { \
- TYPEOF(var) *__tmp; \
- __tmp = (type *)NULL; \
- (void)__tmp; \
-} (void)0
-
-#define CHECK_TYPE_PAIR(var_a, var_b) { \
- TYPEOF(var_a) *__tmp; \
- __tmp = (typeof(var_b) *)NULL; \
- (void)__tmp; \
-} (void)0
-#else
-# define CHECK_TYPE(var, type)
-# define CHECK_TYPE_PAIR(var_a, var_b)
-#endif
-
-/* can be used in simple macros */
-#define CHECK_TYPE_INLINE(val, type) \
- ((void)(((type)0) != (val)))
-
-
CCL_NAMESPACE_END
-#ifndef __KERNEL_GPU__
-# include <cassert>
-# define util_assert(statement) assert(statement)
-#else
-# define util_assert(statement)
-#endif
-
/* Vectorized types declaration. */
#include "util/util_types_uchar2.h"
#include "util/util_types_uchar3.h"
@@ -298,5 +187,13 @@ CCL_NAMESPACE_END
#include "util/util_types_vector3_impl.h"
+/* SSE types. */
+#ifndef __KERNEL_GPU__
+# include "util/util_sseb.h"
+# include "util/util_ssei.h"
+# include "util/util_ssef.h"
+# include "util/util_avxf.h"
+#endif
+
#endif /* __UTIL_TYPES_H__ */
diff --git a/intern/elbeem/intern/isosurface.cpp b/intern/elbeem/intern/isosurface.cpp
index fb61fb416b4..de7bfe8e687 100644
--- a/intern/elbeem/intern/isosurface.cpp
+++ b/intern/elbeem/intern/isosurface.cpp
@@ -15,6 +15,7 @@
#include "particletracer.h"
#include <algorithm>
#include <stdio.h>
+#include <cmath>
#ifdef sun
#include "ieeefp.h"
@@ -25,6 +26,8 @@
#define round(x) (x)
#endif
+using std::isfinite;
+
/******************************************************************************
* Constructor
*****************************************************************************/
@@ -937,17 +940,10 @@ void IsoSurface::smoothSurface(float sigma, bool normSmooth)
ew[(j+2)%3]);
}
- // NT important, check this...
-#ifndef WIN32
- if(! finite(cornerareas[i][0]) ) cornerareas[i][0]=1e-6;
- if(! finite(cornerareas[i][1]) ) cornerareas[i][1]=1e-6;
- if(! finite(cornerareas[i][2]) ) cornerareas[i][2]=1e-6;
-#else // WIN32
- // FIXME check as well...
- if(! (cornerareas[i][0]>=0.0) ) cornerareas[i][0]=1e-6;
- if(! (cornerareas[i][1]>=0.0) ) cornerareas[i][1]=1e-6;
- if(! (cornerareas[i][2]>=0.0) ) cornerareas[i][2]=1e-6;
-#endif // WIN32
+ // FIX T50887: ensure pointareas are finite
+ if (!isfinite(cornerareas[i][0])) cornerareas[i][0] = 1e-6;
+ if (!isfinite(cornerareas[i][1])) cornerareas[i][1] = 1e-6;
+ if (!isfinite(cornerareas[i][2])) cornerareas[i][2] = 1e-6;
pointareas[mIndices[i*3+0]] += cornerareas[i][0];
pointareas[mIndices[i*3+1]] += cornerareas[i][1];
@@ -1096,17 +1092,10 @@ void IsoSurface::smoothNormals(float sigma) {
ew[(j+2)%3]);
}
- // NT important, check this...
-#ifndef WIN32
- if(! finite(cornerareas[i][0]) ) cornerareas[i][0]=1e-6;
- if(! finite(cornerareas[i][1]) ) cornerareas[i][1]=1e-6;
- if(! finite(cornerareas[i][2]) ) cornerareas[i][2]=1e-6;
-#else // WIN32
- // FIXME check as well...
- if(! (cornerareas[i][0]>=0.0) ) cornerareas[i][0]=1e-6;
- if(! (cornerareas[i][1]>=0.0) ) cornerareas[i][1]=1e-6;
- if(! (cornerareas[i][2]>=0.0) ) cornerareas[i][2]=1e-6;
-#endif // WIN32
+ // FIX T50887: ensure pointareas are finite
+ if (!isfinite(cornerareas[i][0])) cornerareas[i][0] = 1e-6;
+ if (!isfinite(cornerareas[i][1])) cornerareas[i][1] = 1e-6;
+ if (!isfinite(cornerareas[i][2])) cornerareas[i][2] = 1e-6;
pointareas[mIndices[i*3+0]] += cornerareas[i][0];
pointareas[mIndices[i*3+1]] += cornerareas[i][1];
diff --git a/intern/elbeem/intern/solver_util.cpp b/intern/elbeem/intern/solver_util.cpp
index 5e112eb3f29..4bcc3640d72 100644
--- a/intern/elbeem/intern/solver_util.cpp
+++ b/intern/elbeem/intern/solver_util.cpp
@@ -855,6 +855,10 @@ void LbmFsgrSolver::advanceParticles() {
if(k<=mSizez-1-cutval){
CellFlagType pflag = RFLAG(level, i,j,k, workSet);
//errMsg("PIT move"," at "<<PRINT_IJK<<" flag"<<convertCellFlagType2String(pflag) );
+ if (pflag & CFMbndOutflow) {
+ DEL_PART;
+ continue;
+ }
if(pflag & (CFBnd)) {
handleObstacleParticle(p);
continue;
diff --git a/intern/gawain/CMakeLists.txt b/intern/gawain/CMakeLists.txt
index 48392012176..9924daa8cd1 100644
--- a/intern/gawain/CMakeLists.txt
+++ b/intern/gawain/CMakeLists.txt
@@ -8,31 +8,31 @@ set(INC_SYS
)
set(SRC
- src/attrib_binding.c
- src/batch.c
- src/element.c
- src/buffer_id.cpp
- src/immediate.c
- src/imm_util.c
- src/primitive.c
- src/shader_interface.c
- src/vertex_buffer.c
- src/vertex_format.c
+ src/gwn_attr_binding.c
+ src/gwn_batch.c
+ src/gwn_element.c
+ src/gwn_buffer_id.cpp
+ src/gwn_immediate.c
+ src/gwn_imm_util.c
+ src/gwn_primitive.c
+ src/gwn_shader_interface.c
+ src/gwn_vertex_buffer.c
+ src/gwn_vertex_format.c
- gawain/attrib_binding.h
- gawain/attrib_binding_private.h
- gawain/batch.h
- gawain/buffer_id.h
- gawain/common.h
- gawain/element.h
- gawain/imm_util.h
- gawain/immediate.h
- gawain/primitive.h
- gawain/primitive_private.h
- gawain/shader_interface.h
- gawain/vertex_buffer.h
- gawain/vertex_format.h
- gawain/vertex_format_private.h
+ gawain/gwn_attr_binding.h
+ gawain/gwn_attr_binding_private.h
+ gawain/gwn_batch.h
+ gawain/gwn_buffer_id.h
+ gawain/gwn_common.h
+ gawain/gwn_element.h
+ gawain/gwn_imm_util.h
+ gawain/gwn_immediate.h
+ gawain/gwn_primitive.h
+ gawain/gwn_primitive_private.h
+ gawain/gwn_shader_interface.h
+ gawain/gwn_vertex_buffer.h
+ gawain/gwn_vertex_format.h
+ gawain/gwn_vertex_format_private.h
)
add_definitions(${GL_DEFINITIONS})
diff --git a/intern/gawain/gawain/attrib_binding.h b/intern/gawain/gawain/gwn_attr_binding.h
index a254f05dc05..a209e1c4f0f 100644
--- a/intern/gawain/gawain/attrib_binding.h
+++ b/intern/gawain/gawain/gwn_attr_binding.h
@@ -11,9 +11,9 @@
#pragma once
-#include "common.h"
+#include "gwn_common.h"
-typedef struct {
+typedef struct Gwn_AttrBinding {
uint64_t loc_bits; // store 4 bits for each of the 16 attribs
uint16_t enabled_bits; // 1 bit for each attrib
} Gwn_AttrBinding;
diff --git a/intern/gawain/gawain/attrib_binding_private.h b/intern/gawain/gawain/gwn_attr_binding_private.h
index 53fdecff9ce..300945d464b 100644
--- a/intern/gawain/gawain/attrib_binding_private.h
+++ b/intern/gawain/gawain/gwn_attr_binding_private.h
@@ -11,8 +11,8 @@
#pragma once
-#include "vertex_format.h"
-#include "shader_interface.h"
+#include "gwn_vertex_format.h"
+#include "gwn_shader_interface.h"
void AttribBinding_clear(Gwn_AttrBinding*);
diff --git a/intern/gawain/gawain/batch.h b/intern/gawain/gawain/gwn_batch.h
index 6e2f32c1996..ee1599845c8 100644
--- a/intern/gawain/gawain/batch.h
+++ b/intern/gawain/gawain/gwn_batch.h
@@ -11,9 +11,9 @@
#pragma once
-#include "vertex_buffer.h"
-#include "element.h"
-#include "shader_interface.h"
+#include "gwn_vertex_buffer.h"
+#include "gwn_element.h"
+#include "gwn_shader_interface.h"
typedef enum {
GWN_BATCH_READY_TO_FORMAT,
@@ -36,21 +36,36 @@ typedef struct Gwn_Batch {
Gwn_BatchPhase phase;
bool program_dirty;
bool program_in_use;
+ unsigned owns_flag;
// state
GLuint program;
const Gwn_ShaderInterface* interface;
} Gwn_Batch;
-Gwn_Batch* GWN_batch_create(Gwn_PrimType, Gwn_VertBuf*, Gwn_IndexBuf*);
-void GWN_batch_init(Gwn_Batch*, Gwn_PrimType, Gwn_VertBuf*, Gwn_IndexBuf*);
+enum {
+ GWN_BATCH_OWNS_VBO = (1 << 0),
+ /* each vbo index gets bit-shifted */
+ GWN_BATCH_OWNS_INDEX = (1 << 31),
+};
+
+Gwn_Batch* GWN_batch_create_ex(Gwn_PrimType, Gwn_VertBuf*, Gwn_IndexBuf*, unsigned owns_flag);
+void GWN_batch_init_ex(Gwn_Batch*, Gwn_PrimType, Gwn_VertBuf*, Gwn_IndexBuf*, unsigned owns_flag);
+
+#define GWN_batch_create(prim, verts, elem) \
+ GWN_batch_create_ex(prim, verts, elem, 0)
+#define GWN_batch_init(batch, prim, verts, elem) \
+ GWN_batch_init_ex(batch, prim, verts, elem, 0)
void GWN_batch_discard(Gwn_Batch*); // verts & elem are not discarded
-void GWN_batch_discard_all(Gwn_Batch*); // including verts & elem
-int GWN_batch_vertbuf_add(Gwn_Batch*, Gwn_VertBuf*);
+int GWN_batch_vertbuf_add_ex(Gwn_Batch*, Gwn_VertBuf*, bool own_vbo);
+
+#define GWN_batch_vertbuf_add(batch, verts) \
+ GWN_batch_vertbuf_add_ex(batch, verts, false)
void GWN_batch_program_set(Gwn_Batch*, GLuint program, const Gwn_ShaderInterface*);
+void GWN_batch_program_unset(Gwn_Batch*);
// Entire batch draws with one shader program, but can be redrawn later with another program.
// Vertex shader's inputs must be compatible with the batch's vertex format.
@@ -63,6 +78,7 @@ void GWN_batch_uniform_1f(Gwn_Batch*, const char* name, float value);
void GWN_batch_uniform_2f(Gwn_Batch*, const char* name, float x, float y);
void GWN_batch_uniform_3f(Gwn_Batch*, const char* name, float x, float y, float z);
void GWN_batch_uniform_4f(Gwn_Batch*, const char* name, float x, float y, float z, float w);
+void GWN_batch_uniform_2fv(Gwn_Batch*, const char* name, const float data[2]);
void GWN_batch_uniform_3fv(Gwn_Batch*, const char* name, const float data[3]);
void GWN_batch_uniform_4fv(Gwn_Batch*, const char* name, const float data[4]);
@@ -87,17 +103,17 @@ void GWN_batch_draw_stupid_instanced_with_batch(Gwn_Batch*, Gwn_Batch*);
// We often need a batch with its own data, to be created and discarded together.
// WithOwn variants reduce number of system allocations.
-typedef struct {
+typedef struct BatchWithOwnVertexBuffer {
Gwn_Batch batch;
Gwn_VertBuf verts; // link batch.verts to this
} BatchWithOwnVertexBuffer;
-typedef struct {
+typedef struct BatchWithOwnElementList {
Gwn_Batch batch;
Gwn_IndexBuf elem; // link batch.elem to this
} BatchWithOwnElementList;
-typedef struct {
+typedef struct BatchWithOwnVertexBufferAndElementList {
Gwn_Batch batch;
Gwn_IndexBuf elem; // link batch.elem to this
Gwn_VertBuf verts; // link batch.verts to this
@@ -121,9 +137,3 @@ Gwn_Batch* create_BatchInGeneral(Gwn_PrimType, VertexBufferStuff, ElementListStu
batch = NULL; \
} \
} while (0)
-#define BATCH_DISCARD_ALL_SAFE(batch) do { \
- if (batch != NULL) { \
- GWN_batch_discard_all(batch); \
- batch = NULL; \
- } \
-} while (0)
diff --git a/intern/gawain/gawain/buffer_id.h b/intern/gawain/gawain/gwn_buffer_id.h
index e978eec67d8..db5df99f526 100644
--- a/intern/gawain/gawain/buffer_id.h
+++ b/intern/gawain/gawain/gwn_buffer_id.h
@@ -20,7 +20,7 @@
extern "C" {
#endif
-#include "common.h"
+#include "gwn_common.h"
GLuint GWN_buf_id_alloc(void);
void GWN_buf_id_free(GLuint buffer_id);
diff --git a/intern/gawain/gawain/common.h b/intern/gawain/gawain/gwn_common.h
index e21b241160d..e96a3b5c2a2 100644
--- a/intern/gawain/gawain/common.h
+++ b/intern/gawain/gawain/gwn_common.h
@@ -25,3 +25,10 @@
#if TRUST_NO_ONE
#include <assert.h>
#endif
+
+/* GWN_INLINE */
+#if defined(_MSC_VER)
+# define GWN_INLINE static __forceinline
+#else
+# define GWN_INLINE static inline __attribute__((always_inline)) __attribute__((__unused__))
+#endif \ No newline at end of file
diff --git a/intern/gawain/gawain/element.h b/intern/gawain/gawain/gwn_element.h
index 771462be7c5..3081305769f 100644
--- a/intern/gawain/gawain/element.h
+++ b/intern/gawain/gawain/gwn_element.h
@@ -11,7 +11,7 @@
#pragma once
-#include "primitive.h"
+#include "gwn_primitive.h"
#define GWN_TRACK_INDEX_RANGE 1
@@ -21,7 +21,7 @@ typedef enum {
GWN_INDEX_U32
} Gwn_IndexBufType;
-typedef struct {
+typedef struct Gwn_IndexBuf {
unsigned index_ct;
#if GWN_TRACK_INDEX_RANGE
Gwn_IndexBufType index_type;
@@ -37,7 +37,7 @@ typedef struct {
void GWN_indexbuf_use(Gwn_IndexBuf*);
unsigned GWN_indexbuf_size_get(const Gwn_IndexBuf*);
-typedef struct {
+typedef struct Gwn_IndexBufBuilder {
unsigned max_allowed_index;
unsigned max_index_ct;
unsigned index_ct;
diff --git a/intern/gawain/gawain/imm_util.h b/intern/gawain/gawain/gwn_imm_util.h
index 730bd7c1a3c..730bd7c1a3c 100644
--- a/intern/gawain/gawain/imm_util.h
+++ b/intern/gawain/gawain/gwn_imm_util.h
diff --git a/intern/gawain/gawain/immediate.h b/intern/gawain/gawain/gwn_immediate.h
index 39ba76db931..386b26b63b1 100644
--- a/intern/gawain/gawain/immediate.h
+++ b/intern/gawain/gawain/gwn_immediate.h
@@ -11,9 +11,9 @@
#pragma once
-#include "vertex_format.h"
-#include "primitive.h"
-#include "shader_interface.h"
+#include "gwn_vertex_format.h"
+#include "gwn_primitive.h"
+#include "gwn_shader_interface.h"
#define IMM_BATCH_COMBO 1
@@ -28,7 +28,7 @@ void immBeginAtMost(Gwn_PrimType, unsigned max_vertex_ct); // can supply fewer v
void immEnd(void); // finishes and draws
#if IMM_BATCH_COMBO
-#include "batch.h"
+#include "gwn_batch.h"
// immBegin a batch, then use standard immFunctions as usual.
// immEnd will finalize the batch instead of drawing.
// Then you can draw it as many times as you like! Partially replaces the need for display lists.
diff --git a/intern/gawain/gawain/primitive.h b/intern/gawain/gawain/gwn_primitive.h
index c6786dc1993..5e5b8019889 100644
--- a/intern/gawain/gawain/primitive.h
+++ b/intern/gawain/gawain/gwn_primitive.h
@@ -11,7 +11,7 @@
#pragma once
-#include "common.h"
+#include "gwn_common.h"
typedef enum {
GWN_PRIM_POINTS,
diff --git a/intern/gawain/gawain/primitive_private.h b/intern/gawain/gawain/gwn_primitive_private.h
index d959cd89852..d959cd89852 100644
--- a/intern/gawain/gawain/primitive_private.h
+++ b/intern/gawain/gawain/gwn_primitive_private.h
diff --git a/intern/gawain/gawain/gwn_shader_interface.h b/intern/gawain/gawain/gwn_shader_interface.h
new file mode 100644
index 00000000000..345ad8d389b
--- /dev/null
+++ b/intern/gawain/gawain/gwn_shader_interface.h
@@ -0,0 +1,74 @@
+
+// Gawain shader interface (C --> GLSL)
+//
+// This code is part of the Gawain library, with modifications
+// specific to integration with Blender.
+//
+// Copyright 2017 Mike Erwin
+//
+// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
+// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
+
+#pragma once
+
+#include "gwn_common.h"
+
+typedef enum {
+ GWN_UNIFORM_NONE = 0, // uninitialized/unknown
+
+ GWN_UNIFORM_MODEL, // mat4 ModelMatrix
+ GWN_UNIFORM_VIEW, // mat4 ViewMatrix
+ GWN_UNIFORM_MODELVIEW, // mat4 ModelViewMatrix
+ GWN_UNIFORM_PROJECTION, // mat4 ProjectionMatrix
+ GWN_UNIFORM_VIEWPROJECTION, // mat4 ViewProjectionMatrix
+ GWN_UNIFORM_MVP, // mat4 ModelViewProjectionMatrix
+
+ GWN_UNIFORM_MODEL_INV, // mat4 ModelMatrixInverse
+ GWN_UNIFORM_VIEW_INV, // mat4 ViewMatrixInverse
+ GWN_UNIFORM_MODELVIEW_INV, // mat4 ModelViewMatrixInverse
+ GWN_UNIFORM_PROJECTION_INV, // mat4 ProjectionMatrixInverse
+ GWN_UNIFORM_VIEWPROJECTION_INV, // mat4 ViewProjectionMatrixInverse
+
+ GWN_UNIFORM_NORMAL, // mat3 NormalMatrix
+ GWN_UNIFORM_WORLDNORMAL, // mat3 WorldNormalMatrix
+ GWN_UNIFORM_CAMERATEXCO, // vec4 CameraTexCoFactors
+ GWN_UNIFORM_ORCO, // vec3 OrcoTexCoFactors[]
+ GWN_UNIFORM_CLIPPLANES, // vec4 ClipPlanes[]
+
+ GWN_UNIFORM_COLOR, // vec4 color
+ GWN_UNIFORM_EYE, // vec3 eye
+
+ GWN_UNIFORM_CUSTOM, // custom uniform, not one of the above built-ins
+
+ GWN_NUM_UNIFORMS, // Special value, denotes number of builtin uniforms.
+} Gwn_UniformBuiltin;
+
+typedef struct Gwn_ShaderInput {
+ struct Gwn_ShaderInput* next;
+ uint32_t name_offset;
+ unsigned name_hash;
+ Gwn_UniformBuiltin builtin_type; // only for uniform inputs
+ GLenum gl_type; // only for attrib inputs
+ GLint size; // only for attrib inputs
+ GLint location;
+} Gwn_ShaderInput;
+
+#define GWN_NUM_SHADERINTERFACE_BUCKETS 257
+
+typedef struct Gwn_ShaderInterface {
+ GLint program;
+ uint32_t name_buffer_offset;
+ Gwn_ShaderInput* attrib_buckets[GWN_NUM_SHADERINTERFACE_BUCKETS];
+ Gwn_ShaderInput* uniform_buckets[GWN_NUM_SHADERINTERFACE_BUCKETS];
+ Gwn_ShaderInput* ubo_buckets[GWN_NUM_SHADERINTERFACE_BUCKETS];
+ Gwn_ShaderInput* builtin_uniforms[GWN_NUM_UNIFORMS];
+ char* name_buffer;
+} Gwn_ShaderInterface;
+
+Gwn_ShaderInterface* GWN_shaderinterface_create(GLint program_id);
+void GWN_shaderinterface_discard(Gwn_ShaderInterface*);
+
+const Gwn_ShaderInput* GWN_shaderinterface_uniform(const Gwn_ShaderInterface*, const char* name);
+const Gwn_ShaderInput* GWN_shaderinterface_uniform_builtin(const Gwn_ShaderInterface*, Gwn_UniformBuiltin);
+const Gwn_ShaderInput* GWN_shaderinterface_ubo(const Gwn_ShaderInterface*, const char* name);
+const Gwn_ShaderInput* GWN_shaderinterface_attr(const Gwn_ShaderInterface*, const char* name);
diff --git a/intern/gawain/gawain/vertex_buffer.h b/intern/gawain/gawain/gwn_vertex_buffer.h
index 46f83f5c551..5ad82251e79 100644
--- a/intern/gawain/gawain/vertex_buffer.h
+++ b/intern/gawain/gawain/gwn_vertex_buffer.h
@@ -11,7 +11,7 @@
#pragma once
-#include "vertex_format.h"
+#include "gwn_vertex_format.h"
// How to create a Gwn_VertBuf:
// 1) verts = GWN_vertbuf_create() or GWN_vertbuf_init(verts)
@@ -21,7 +21,7 @@
// Is Gwn_VertBuf always used as part of a Gwn_Batch?
-typedef struct {
+typedef struct Gwn_VertBuf {
Gwn_VertFormat format;
unsigned vertex_ct;
GLubyte* data; // NULL indicates data in VRAM (unmapped) or not yet allocated
@@ -31,6 +31,7 @@ typedef struct {
Gwn_VertBuf* GWN_vertbuf_create(void);
Gwn_VertBuf* GWN_vertbuf_create_with_format(const Gwn_VertFormat*);
+void GWN_vertbuf_clear(Gwn_VertBuf* verts);
void GWN_vertbuf_discard(Gwn_VertBuf*);
void GWN_vertbuf_init(Gwn_VertBuf*);
@@ -49,6 +50,35 @@ void GWN_vertbuf_attr_set(Gwn_VertBuf*, unsigned a_idx, unsigned v_idx, const vo
void GWN_vertbuf_attr_fill(Gwn_VertBuf*, unsigned a_idx, const void* data); // tightly packed, non interleaved input data
void GWN_vertbuf_attr_fill_stride(Gwn_VertBuf*, unsigned a_idx, unsigned stride, const void* data);
+// For low level access only
+typedef struct Gwn_VertBufRaw {
+ unsigned size;
+ unsigned stride;
+ GLubyte* data;
+ GLubyte* data_init;
+#if TRUST_NO_ONE
+ // Only for overflow check
+ GLubyte* _data_end;
+#endif
+} Gwn_VertBufRaw;
+
+GWN_INLINE void *GWN_vertbuf_raw_step(Gwn_VertBufRaw *a)
+ {
+ GLubyte* data = a->data;
+ a->data += a->stride;
+#if TRUST_NO_ONE
+ assert(data < a->_data_end);
+#endif
+ return (void *)data;
+ }
+
+GWN_INLINE unsigned GWN_vertbuf_raw_used(Gwn_VertBufRaw *a)
+ {
+ return ((a->data - a->data_init) / a->stride);
+ }
+
+void GWN_vertbuf_attr_get_raw_data(Gwn_VertBuf*, unsigned a_idx, Gwn_VertBufRaw *access);
+
// TODO: decide whether to keep the functions below
// doesn't immediate mode satisfy these needs?
diff --git a/intern/gawain/gawain/vertex_format.h b/intern/gawain/gawain/gwn_vertex_format.h
index 3b2a3be4209..348e6399afa 100644
--- a/intern/gawain/gawain/vertex_format.h
+++ b/intern/gawain/gawain/gwn_vertex_format.h
@@ -11,7 +11,7 @@
#pragma once
-#include "common.h"
+#include "gwn_common.h"
#define GWN_VERT_ATTR_MAX_LEN 16
#define MAX_ATTRIB_NAMES 3
@@ -38,7 +38,7 @@ typedef enum {
GWN_FETCH_INT_TO_FLOAT // 127 (any int type) -> 127.0
} Gwn_VertFetchMode;
-typedef struct {
+typedef struct Gwn_VertAttr {
Gwn_VertCompType comp_type;
unsigned gl_comp_type;
unsigned comp_ct; // 1 to 4
@@ -49,7 +49,7 @@ typedef struct {
unsigned name_ct;
} Gwn_VertAttr;
-typedef struct {
+typedef struct Gwn_VertFormat {
unsigned attrib_ct; // 0 to 16 (GWN_VERT_ATTR_MAX_LEN)
unsigned name_ct; // total count of active vertex attrib
unsigned stride; // stride in bytes, 1 to 256
@@ -67,12 +67,12 @@ void GWN_vertformat_alias_add(Gwn_VertFormat*, const char* alias);
// format conversion
-typedef struct {
+typedef struct Gwn_PackedNormal {
int x : 10;
int y : 10;
int z : 10;
int w : 2; // 0 by default, can manually set to { -2, -1, 0, 1 }
-} PackedNormal;
+} Gwn_PackedNormal;
-PackedNormal convert_i10_v3(const float data[3]);
-PackedNormal convert_i10_s3(const short data[3]);
+Gwn_PackedNormal GWN_normal_convert_i10_v3(const float data[3]);
+Gwn_PackedNormal GWN_normal_convert_i10_s3(const short data[3]);
diff --git a/intern/gawain/gawain/vertex_format_private.h b/intern/gawain/gawain/gwn_vertex_format_private.h
index c1a0f734eda..c1a0f734eda 100644
--- a/intern/gawain/gawain/vertex_format_private.h
+++ b/intern/gawain/gawain/gwn_vertex_format_private.h
diff --git a/intern/gawain/gawain/shader_interface.h b/intern/gawain/gawain/shader_interface.h
deleted file mode 100644
index 5304cc9fa51..00000000000
--- a/intern/gawain/gawain/shader_interface.h
+++ /dev/null
@@ -1,53 +0,0 @@
-
-// Gawain shader interface (C --> GLSL)
-//
-// This code is part of the Gawain library, with modifications
-// specific to integration with Blender.
-//
-// Copyright 2017 Mike Erwin
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
-// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
-#pragma once
-
-#include "common.h"
-
-typedef enum {
- GWN_UNIFORM_NONE, // uninitialized/unknown
-
- GWN_UNIFORM_MODELVIEW, // mat4 ModelViewMatrix
- GWN_UNIFORM_PROJECTION, // mat4 ProjectionMatrix
- GWN_UNIFORM_MVP, // mat4 ModelViewProjectionMatrix
-
- GWN_UNIFORM_MODELVIEW_INV, // mat4 ModelViewInverseMatrix
- GWN_UNIFORM_PROJECTION_INV, // mat4 ProjectionInverseMatrix
-
- GWN_UNIFORM_NORMAL, // mat3 NormalMatrix
-
- GWN_UNIFORM_COLOR, // vec4 color
-
- GWN_UNIFORM_CUSTOM // custom uniform, not one of the above built-ins
-} Gwn_UniformBuiltin;
-
-typedef struct {
- const char* name;
- unsigned name_hash;
- GLenum gl_type;
- Gwn_UniformBuiltin builtin_type; // only for uniform inputs
- GLint size;
- GLint location;
-} Gwn_ShaderInput;
-
-typedef struct {
- uint16_t uniform_ct;
- uint16_t attrib_ct;
- Gwn_ShaderInput inputs[0]; // dynamic size, uniforms followed by attribs
-} Gwn_ShaderInterface;
-
-Gwn_ShaderInterface* GWN_shaderinterface_create(GLint program_id);
-void GWN_shaderinterface_discard(Gwn_ShaderInterface*);
-
-const Gwn_ShaderInput* GWN_shaderinterface_uniform(const Gwn_ShaderInterface*, const char* name);
-const Gwn_ShaderInput* GWN_shaderinterface_uniform_builtin(const Gwn_ShaderInterface*, Gwn_UniformBuiltin);
-const Gwn_ShaderInput* GWN_shaderinterface_attr(const Gwn_ShaderInterface*, const char* name);
diff --git a/intern/gawain/src/attrib_binding.c b/intern/gawain/src/gwn_attr_binding.c
index 6cdb8a0e542..7647a927b1e 100644
--- a/intern/gawain/src/attrib_binding.c
+++ b/intern/gawain/src/gwn_attr_binding.c
@@ -9,8 +9,8 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#include "attrib_binding.h"
-#include "attrib_binding_private.h"
+#include "gwn_attr_binding.h"
+#include "gwn_attr_binding_private.h"
#include <stddef.h>
#if GWN_VERT_ATTR_MAX_LEN != 16
diff --git a/intern/gawain/src/batch.c b/intern/gawain/src/gwn_batch.c
index 17e45084613..c651fb3a26f 100644
--- a/intern/gawain/src/batch.c
+++ b/intern/gawain/src/gwn_batch.c
@@ -9,25 +9,29 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#include "batch.h"
-#include "buffer_id.h"
-#include "primitive_private.h"
+#include "gwn_batch.h"
+#include "gwn_buffer_id.h"
+#include "gwn_primitive_private.h"
#include <stdlib.h>
// necessary functions from matrix API
extern void gpuBindMatrices(const Gwn_ShaderInterface* shaderface);
extern bool gpuMatricesDirty(void); // how best to use this here?
-Gwn_Batch* GWN_batch_create(Gwn_PrimType prim_type, Gwn_VertBuf* verts, Gwn_IndexBuf* elem)
+Gwn_Batch* GWN_batch_create_ex(
+ Gwn_PrimType prim_type, Gwn_VertBuf* verts, Gwn_IndexBuf* elem,
+ unsigned owns_flag)
{
Gwn_Batch* batch = calloc(1, sizeof(Gwn_Batch));
- GWN_batch_init(batch, prim_type, verts, elem);
+ GWN_batch_init_ex(batch, prim_type, verts, elem, owns_flag);
return batch;
}
-void GWN_batch_init(Gwn_Batch* batch, Gwn_PrimType prim_type, Gwn_VertBuf* verts, Gwn_IndexBuf* elem)
+void GWN_batch_init_ex(
+ Gwn_Batch* batch, Gwn_PrimType prim_type, Gwn_VertBuf* verts, Gwn_IndexBuf* elem,
+ unsigned owns_flag)
{
#if TRUST_NO_ONE
assert(verts != NULL);
@@ -40,32 +44,34 @@ void GWN_batch_init(Gwn_Batch* batch, Gwn_PrimType prim_type, Gwn_VertBuf* verts
batch->prim_type = prim_type;
batch->gl_prim_type = convert_prim_type_to_gl(prim_type);
batch->phase = GWN_BATCH_READY_TO_DRAW;
+ batch->owns_flag = owns_flag;
}
void GWN_batch_discard(Gwn_Batch* batch)
{
- if (batch->vao_id)
- GWN_vao_free(batch->vao_id);
-
- free(batch);
- }
+ if (batch->owns_flag & GWN_BATCH_OWNS_INDEX)
+ GWN_indexbuf_discard(batch->elem);
-void GWN_batch_discard_all(Gwn_Batch* batch)
- {
- for (int v = 0; v < GWN_BATCH_VBO_MAX_LEN; ++v)
+ if ((batch->owns_flag & ~GWN_BATCH_OWNS_INDEX) != 0)
{
- if (batch->verts[v] == NULL)
- break;
- GWN_vertbuf_discard(batch->verts[v]);
+ for (int v = 0; v < GWN_BATCH_VBO_MAX_LEN; ++v)
+ {
+ if (batch->verts[v] == NULL)
+ break;
+ if (batch->owns_flag & (1 << v))
+ GWN_vertbuf_discard(batch->verts[v]);
+ }
}
- if (batch->elem)
- GWN_indexbuf_discard(batch->elem);
+ if (batch->vao_id)
+ GWN_vao_free(batch->vao_id);
- GWN_batch_discard(batch);
+ free(batch);
}
-int GWN_batch_vertbuf_add(Gwn_Batch* batch, Gwn_VertBuf* verts)
+int GWN_batch_vertbuf_add_ex(
+ Gwn_Batch* batch, Gwn_VertBuf* verts,
+ bool own_vbo)
{
for (unsigned v = 0; v < GWN_BATCH_VBO_MAX_LEN; ++v)
{
@@ -78,6 +84,8 @@ int GWN_batch_vertbuf_add(Gwn_Batch* batch, Gwn_VertBuf* verts)
#endif
batch->verts[v] = verts;
// TODO: mark dirty so we can keep attrib bindings up-to-date
+ if (own_vbo)
+ batch->owns_flag |= (1 << v);
return v;
}
}
@@ -102,6 +110,14 @@ void GWN_batch_program_set(Gwn_Batch* batch, GLuint program, const Gwn_ShaderInt
GWN_batch_program_use_begin(batch); // hack! to make Batch_Uniform* simpler
}
+// fclem : hack !
+// we need this because we don't want to unbind the shader between drawcalls
+// but we still want the correct shader to be bound outside the draw manager
+void GWN_batch_program_unset(Gwn_Batch* batch)
+ {
+ batch->program_in_use = false;
+ }
+
static void Batch_update_program_bindings(Gwn_Batch* batch)
{
// disable all as a precaution
@@ -219,6 +235,12 @@ void GWN_batch_uniform_1f(Gwn_Batch* batch, const char* name, float x)
glUniform1f(uniform->location, x);
}
+void GWN_batch_uniform_2fv(Gwn_Batch* batch, const char* name, const float data[2])
+ {
+ GET_UNIFORM
+ glUniform2fv(uniform->location, 1, data);
+ }
+
void GWN_batch_uniform_3fv(Gwn_Batch* batch, const char* name, const float data[3])
{
GET_UNIFORM
@@ -365,8 +387,11 @@ void GWN_batch_draw_stupid_instanced(Gwn_Batch* batch, unsigned int instance_vbo
if (batch->elem)
{
const Gwn_IndexBuf* el = batch->elem;
-
+#if GWN_TRACK_INDEX_RANGE
+ glDrawElementsInstancedBaseVertex(batch->gl_prim_type, el->index_ct, el->gl_index_type, 0, instance_count, el->base_index);
+#else
glDrawElementsInstanced(batch->gl_prim_type, el->index_ct, GL_UNSIGNED_INT, 0, instance_count);
+#endif
}
else
glDrawArraysInstanced(batch->gl_prim_type, 0, batch->verts[0]->vertex_ct, instance_count);
@@ -432,11 +457,15 @@ void GWN_batch_draw_stupid_instanced_with_batch(Gwn_Batch* batch_instanced, Gwn_
{
const Gwn_IndexBuf* el = batch_instanced->elem;
+#if GWN_TRACK_INDEX_RANGE
+ glDrawElementsInstancedBaseVertex(batch_instanced->gl_prim_type, el->index_ct, el->gl_index_type, 0, verts->vertex_ct, el->base_index);
+#else
glDrawElementsInstanced(batch_instanced->gl_prim_type, el->index_ct, GL_UNSIGNED_INT, 0, verts->vertex_ct);
+#endif
}
else
glDrawArraysInstanced(batch_instanced->gl_prim_type, 0, batch_instanced->verts[0]->vertex_ct, verts->vertex_ct);
// GWN_batch_program_use_end(batch);
glBindVertexArray(0);
- } \ No newline at end of file
+ }
diff --git a/intern/gawain/src/buffer_id.cpp b/intern/gawain/src/gwn_buffer_id.cpp
index 59a6b9c89e7..a93c3950d29 100644
--- a/intern/gawain/src/buffer_id.cpp
+++ b/intern/gawain/src/gwn_buffer_id.cpp
@@ -9,7 +9,7 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.#include "buffer_id.h"
-#include "buffer_id.h"
+#include "gwn_buffer_id.h"
#include <mutex>
#include <vector>
diff --git a/intern/gawain/src/element.c b/intern/gawain/src/gwn_element.c
index ecf555fbfe8..f31b64fa232 100644
--- a/intern/gawain/src/element.c
+++ b/intern/gawain/src/gwn_element.c
@@ -9,8 +9,8 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#include "element.h"
-#include "buffer_id.h"
+#include "gwn_element.h"
+#include "gwn_buffer_id.h"
#include <stdlib.h>
#define KEEP_SINGLE_COPY 1
diff --git a/intern/gawain/src/imm_util.c b/intern/gawain/src/gwn_imm_util.c
index b06778c9045..45d8a7036e8 100644
--- a/intern/gawain/src/imm_util.c
+++ b/intern/gawain/src/gwn_imm_util.c
@@ -9,8 +9,8 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#include "imm_util.h"
-#include "immediate.h"
+#include "gwn_imm_util.h"
+#include "gwn_immediate.h"
void immRectf(unsigned pos, float x1, float y1, float x2, float y2)
diff --git a/intern/gawain/src/immediate.c b/intern/gawain/src/gwn_immediate.c
index 5eb5ebb8336..1c0776d1bbf 100644
--- a/intern/gawain/src/immediate.c
+++ b/intern/gawain/src/gwn_immediate.c
@@ -9,12 +9,12 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#include "immediate.h"
-#include "buffer_id.h"
-#include "attrib_binding.h"
-#include "attrib_binding_private.h"
-#include "vertex_format_private.h"
-#include "primitive_private.h"
+#include "gwn_immediate.h"
+#include "gwn_buffer_id.h"
+#include "gwn_attr_binding.h"
+#include "gwn_attr_binding_private.h"
+#include "gwn_vertex_format_private.h"
+#include "gwn_primitive_private.h"
#include <string.h>
// necessary functions from matrix API
diff --git a/intern/gawain/src/primitive.c b/intern/gawain/src/gwn_primitive.c
index b9d92a6bdf8..b206b3ae1b3 100644
--- a/intern/gawain/src/primitive.c
+++ b/intern/gawain/src/gwn_primitive.c
@@ -9,8 +9,8 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#include "primitive.h"
-#include "primitive_private.h"
+#include "gwn_primitive.h"
+#include "gwn_primitive_private.h"
Gwn_PrimClass GWN_primtype_class(Gwn_PrimType prim_type)
{
diff --git a/intern/gawain/src/gwn_shader_interface.c b/intern/gawain/src/gwn_shader_interface.c
new file mode 100644
index 00000000000..1fb941f9225
--- /dev/null
+++ b/intern/gawain/src/gwn_shader_interface.c
@@ -0,0 +1,311 @@
+
+// Gawain shader interface (C --> GLSL)
+//
+// This code is part of the Gawain library, with modifications
+// specific to integration with Blender.
+//
+// Copyright 2017 Mike Erwin
+//
+// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
+// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
+
+#include "gwn_shader_interface.h"
+#include <stdlib.h>
+#include <stddef.h>
+#include <string.h>
+
+#define DEBUG_SHADER_INTERFACE 0
+
+#if DEBUG_SHADER_INTERFACE
+ #include <stdio.h>
+#endif
+
+static const char* BuiltinUniform_name(Gwn_UniformBuiltin u)
+ {
+ static const char* names[] =
+ {
+ [GWN_UNIFORM_NONE] = NULL,
+
+ [GWN_UNIFORM_MODEL] = "ModelMatrix",
+ [GWN_UNIFORM_VIEW] = "ViewMatrix",
+ [GWN_UNIFORM_MODELVIEW] = "ModelViewMatrix",
+ [GWN_UNIFORM_PROJECTION] = "ProjectionMatrix",
+ [GWN_UNIFORM_VIEWPROJECTION] = "ViewProjectionMatrix",
+ [GWN_UNIFORM_MVP] = "ModelViewProjectionMatrix",
+
+ [GWN_UNIFORM_MODEL_INV] = "ModelMatrixInverse",
+ [GWN_UNIFORM_VIEW_INV] = "ViewMatrixInverse",
+ [GWN_UNIFORM_MODELVIEW_INV] = "ModelViewMatrixInverse",
+ [GWN_UNIFORM_PROJECTION_INV] = "ProjectionMatrixInverse",
+ [GWN_UNIFORM_VIEWPROJECTION_INV] = "ViewProjectionMatrixInverse",
+
+ [GWN_UNIFORM_NORMAL] = "NormalMatrix",
+ [GWN_UNIFORM_WORLDNORMAL] = "WorldNormalMatrix",
+ [GWN_UNIFORM_CAMERATEXCO] = "CameraTexCoFactors",
+ [GWN_UNIFORM_ORCO] = "OrcoTexCoFactors",
+ [GWN_UNIFORM_CLIPPLANES] = "ClipPlanes",
+
+ [GWN_UNIFORM_COLOR] = "color",
+ [GWN_UNIFORM_EYE] = "eye",
+
+ [GWN_UNIFORM_CUSTOM] = NULL,
+ [GWN_NUM_UNIFORMS] = NULL,
+ };
+
+ return names[u];
+ }
+
+GWN_INLINE bool match(const char* a, const char* b)
+ {
+ return strcmp(a, b) == 0;
+ }
+
+GWN_INLINE unsigned hash_string(const char *str)
+ {
+ unsigned i = 0, c;
+
+ while ((c = *str++))
+ {
+ i = i * 37 + c;
+ }
+
+ return i;
+ }
+
+GWN_INLINE void set_input_name(Gwn_ShaderInterface* shaderface, Gwn_ShaderInput* input,
+ const char* name, uint32_t name_len)
+ {
+ input->name_offset = shaderface->name_buffer_offset;
+ input->name_hash = hash_string(name);
+ shaderface->name_buffer_offset += name_len + 1; // include NULL terminator
+ }
+
+GWN_INLINE void shader_input_to_bucket(Gwn_ShaderInput* input,
+ Gwn_ShaderInput* buckets[GWN_NUM_SHADERINTERFACE_BUCKETS])
+ {
+ const unsigned bucket_index = input->name_hash % GWN_NUM_SHADERINTERFACE_BUCKETS;
+ input->next = buckets[bucket_index];
+ buckets[bucket_index] = input;
+ }
+
+GWN_INLINE const Gwn_ShaderInput* buckets_lookup(Gwn_ShaderInput* const buckets[GWN_NUM_SHADERINTERFACE_BUCKETS],
+ const char *name_buffer, const char *name)
+ {
+ const unsigned name_hash = hash_string(name);
+ const unsigned bucket_index = name_hash % GWN_NUM_SHADERINTERFACE_BUCKETS;
+ const Gwn_ShaderInput* input = buckets[bucket_index];
+ if (input == NULL)
+ {
+ // Requested uniform is not found at all.
+ return NULL;
+ }
+ // Optimization bit: if there is no hash collision detected when constructing shader interface
+ // it means we can only request the single possible uniform. Surely, it's possible we request
+ // uniform which causes hash collision, but that will be detected in debug builds.
+ if (input->next == NULL)
+ {
+ if (name_hash == input->name_hash)
+ {
+#if TRUST_NO_ONE
+ assert(match(name_buffer + input->name_offset, name));
+#endif
+ return input;
+ }
+ return NULL;
+ }
+ // Work through possible collisions.
+ const Gwn_ShaderInput* next = input;
+ while (next != NULL)
+ {
+ input = next;
+ next = input->next;
+
+ if (input->name_hash != name_hash)
+ {
+ continue;
+ }
+ if (match(name_buffer + input->name_offset, name))
+ {
+ return input;
+ }
+ }
+ return NULL; // not found
+ }
+
+GWN_INLINE void buckets_free(Gwn_ShaderInput* buckets[GWN_NUM_SHADERINTERFACE_BUCKETS])
+ {
+ for (unsigned bucket_index = 0; bucket_index < GWN_NUM_SHADERINTERFACE_BUCKETS; ++bucket_index)
+ {
+ Gwn_ShaderInput *input = buckets[bucket_index];
+ while (input != NULL)
+ {
+ Gwn_ShaderInput *input_next = input->next;
+ free(input);
+ input = input_next;
+ }
+ }
+ }
+
+static bool setup_builtin_uniform(Gwn_ShaderInput* input, const char* name)
+ {
+ // TODO: reject DOUBLE, IMAGE, ATOMIC_COUNTER gl_types
+
+ // detect built-in uniforms (name must match)
+ for (Gwn_UniformBuiltin u = GWN_UNIFORM_NONE + 1; u < GWN_UNIFORM_CUSTOM; ++u)
+ {
+ const char* builtin_name = BuiltinUniform_name(u);
+ if (match(name, builtin_name))
+ {
+ input->builtin_type = u;
+ return true;
+ }
+ }
+
+ input->builtin_type = GWN_UNIFORM_CUSTOM;
+ return false;
+ }
+
+static const Gwn_ShaderInput* add_uniform(Gwn_ShaderInterface* shaderface, const char* name)
+ {
+ Gwn_ShaderInput* input = malloc(sizeof(Gwn_ShaderInput));
+
+ input->location = glGetUniformLocation(shaderface->program, name);
+
+ unsigned name_len = strlen(name);
+ shaderface->name_buffer = realloc(shaderface->name_buffer, shaderface->name_buffer_offset + name_len + 1); // include NULL terminator
+ char* name_buffer = shaderface->name_buffer + shaderface->name_buffer_offset;
+ strcpy(name_buffer, name);
+
+ set_input_name(shaderface, input, name, name_len);
+ setup_builtin_uniform(input, name);
+
+ shader_input_to_bucket(input, shaderface->uniform_buckets);
+ if (input->builtin_type != GWN_UNIFORM_NONE &&
+ input->builtin_type != GWN_UNIFORM_CUSTOM)
+ {
+ shaderface->builtin_uniforms[input->builtin_type] = input;
+ }
+#if DEBUG_SHADER_INTERFACE
+ printf("Gwn_ShaderInterface %p, program %d, uniform[] '%s' at location %d\n", shaderface, shaderface->program, name, input->location);
+#endif
+ return input;
+ }
+
+Gwn_ShaderInterface* GWN_shaderinterface_create(GLint program)
+ {
+ Gwn_ShaderInterface* shaderface = calloc(1, sizeof(Gwn_ShaderInterface));
+ shaderface->program = program;
+
+#if DEBUG_SHADER_INTERFACE
+ printf("%s {\n", __func__); // enter function
+ printf("Gwn_ShaderInterface %p, program %d\n", shaderface, program);
+#endif
+
+ GLint max_attrib_name_len, attrib_ct;
+ glGetProgramiv(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_attrib_name_len);
+ glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &attrib_ct);
+
+ GLint max_ubo_name_len, ubo_ct;
+ glGetProgramiv(program, GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH, &max_ubo_name_len);
+ glGetProgramiv(program, GL_ACTIVE_UNIFORM_BLOCKS, &ubo_ct);
+
+ const uint32_t name_buffer_len = attrib_ct * max_attrib_name_len + ubo_ct * max_ubo_name_len;
+ shaderface->name_buffer = malloc(name_buffer_len);
+
+ // Attributes
+ for (uint32_t i = 0; i < attrib_ct; ++i)
+ {
+ Gwn_ShaderInput* input = malloc(sizeof(Gwn_ShaderInput));
+ GLsizei remaining_buffer = name_buffer_len - shaderface->name_buffer_offset;
+ char* name = shaderface->name_buffer + shaderface->name_buffer_offset;
+ GLsizei name_len = 0;
+
+ glGetActiveAttrib(program, i, remaining_buffer, &name_len, &input->size, &input->gl_type, name);
+
+ // TODO: reject DOUBLE gl_types
+
+ input->location = glGetAttribLocation(program, name);
+
+ set_input_name(shaderface, input, name, name_len);
+
+ shader_input_to_bucket(input, shaderface->attrib_buckets);
+
+#if DEBUG_SHADER_INTERFACE
+ printf("attrib[%u] '%s' at location %d\n", i, name, input->location);
+#endif
+ }
+
+ // Uniform Blocks
+ for (uint32_t i = 0; i < ubo_ct; ++i)
+ {
+ Gwn_ShaderInput* input = malloc(sizeof(Gwn_ShaderInput));
+ GLsizei remaining_buffer = name_buffer_len - shaderface->name_buffer_offset;
+ char* name = shaderface->name_buffer + shaderface->name_buffer_offset;
+ GLsizei name_len = 0;
+
+ glGetActiveUniformBlockName(program, i, remaining_buffer, &name_len, name);
+
+ input->location = i;
+
+ set_input_name(shaderface, input, name, name_len);
+
+ shader_input_to_bucket(input, shaderface->ubo_buckets);
+
+#if DEBUG_SHADER_INTERFACE
+ printf("attrib[%u] '%s' at location %d\n", i, name, input->location);
+#endif
+ }
+
+ return shaderface;
+ }
+
+void GWN_shaderinterface_discard(Gwn_ShaderInterface* shaderface)
+ {
+ // Free memory used by buckets and has entries.
+ buckets_free(shaderface->uniform_buckets);
+ buckets_free(shaderface->attrib_buckets);
+ buckets_free(shaderface->ubo_buckets);
+ // Free memory used by name_buffer.
+ free(shaderface->name_buffer);
+ // Free memory used by shader interface by its self.
+ free(shaderface);
+ }
+
+const Gwn_ShaderInput* GWN_shaderinterface_uniform(const Gwn_ShaderInterface* shaderface, const char* name)
+ {
+ // TODO: Warn if we find a matching builtin, since these can be looked up much quicker.
+ const Gwn_ShaderInput* input = buckets_lookup(shaderface->uniform_buckets, shaderface->name_buffer, name);
+
+ // If input is not found add it so it's found next time.
+ if (input == NULL)
+ input = add_uniform((Gwn_ShaderInterface*)shaderface, name);
+
+ return (input->location != -1) ? input : NULL;
+ }
+
+const Gwn_ShaderInput* GWN_shaderinterface_uniform_builtin(const Gwn_ShaderInterface* shaderface, Gwn_UniformBuiltin builtin)
+ {
+#if TRUST_NO_ONE
+ assert(builtin != GWN_UNIFORM_NONE);
+ assert(builtin != GWN_UNIFORM_CUSTOM);
+ assert(builtin != GWN_NUM_UNIFORMS);
+#endif
+
+ const Gwn_ShaderInput* input = shaderface->builtin_uniforms[builtin];
+
+ // If input is not found add it so it's found next time.
+ if (input == NULL)
+ input = add_uniform((Gwn_ShaderInterface*)shaderface, BuiltinUniform_name(builtin));
+
+ return (input->location != -1) ? input : NULL;
+ }
+
+const Gwn_ShaderInput* GWN_shaderinterface_ubo(const Gwn_ShaderInterface* shaderface, const char* name)
+ {
+ return buckets_lookup(shaderface->ubo_buckets, shaderface->name_buffer, name);
+ }
+
+const Gwn_ShaderInput* GWN_shaderinterface_attr(const Gwn_ShaderInterface* shaderface, const char* name)
+ {
+ return buckets_lookup(shaderface->attrib_buckets, shaderface->name_buffer, name);
+ }
diff --git a/intern/gawain/src/vertex_buffer.c b/intern/gawain/src/gwn_vertex_buffer.c
index 03691b0c21d..2019d7d50bc 100644
--- a/intern/gawain/src/vertex_buffer.c
+++ b/intern/gawain/src/gwn_vertex_buffer.c
@@ -9,9 +9,9 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#include "vertex_buffer.h"
-#include "buffer_id.h"
-#include "vertex_format_private.h"
+#include "gwn_vertex_buffer.h"
+#include "gwn_buffer_id.h"
+#include "gwn_vertex_format_private.h"
#include <stdlib.h>
#include <string.h>
@@ -51,6 +51,25 @@ void GWN_vertbuf_init_with_format(Gwn_VertBuf* verts, const Gwn_VertFormat* form
VertexFormat_pack(&verts->format);
}
+/**
+ * Like #GWN_vertbuf_discard but doesn't free.
+ */
+void GWN_vertbuf_clear(Gwn_VertBuf* verts)
+ {
+ if (verts->vbo_id) {
+ GWN_buf_id_free(verts->vbo_id);
+ vbo_memory_usage -= GWN_vertbuf_size_get(verts);
+ }
+#if KEEP_SINGLE_COPY
+ else
+#endif
+ if (verts->data)
+ {
+ free(verts->data);
+ verts->data = NULL;
+ }
+ }
+
void GWN_vertbuf_discard(Gwn_VertBuf* verts)
{
if (verts->vbo_id) {
@@ -151,6 +170,26 @@ void GWN_vertbuf_attr_fill_stride(Gwn_VertBuf* verts, unsigned a_idx, unsigned s
}
}
+void GWN_vertbuf_attr_get_raw_data(Gwn_VertBuf* verts, unsigned a_idx, Gwn_VertBufRaw *access)
+ {
+ const Gwn_VertFormat* format = &verts->format;
+ const Gwn_VertAttr* a = format->attribs + a_idx;
+
+#if TRUST_NO_ONE
+ assert(a_idx < format->attrib_ct);
+ assert(verts->data != NULL); // data must be in main mem
+#endif
+
+ access->size = a->sz;
+ access->stride = format->stride;
+ access->data = (GLubyte*)verts->data + a->offset;
+ access->data_init = access->data;
+#if TRUST_NO_ONE
+ access->_data_end = access->data_init + (size_t)(verts->vertex_ct * format->stride);
+#endif
+ }
+
+
static void VertexBuffer_prime(Gwn_VertBuf* verts)
{
const unsigned buffer_sz = GWN_vertbuf_size_get(verts);
diff --git a/intern/gawain/src/vertex_format.c b/intern/gawain/src/gwn_vertex_format.c
index 139a76cf7ef..d6367935703 100644
--- a/intern/gawain/src/vertex_format.c
+++ b/intern/gawain/src/gwn_vertex_format.c
@@ -9,8 +9,8 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#include "vertex_format.h"
-#include "vertex_format_private.h"
+#include "gwn_vertex_format.h"
+#include "gwn_vertex_format_private.h"
#include <stddef.h>
#include <string.h>
@@ -251,7 +251,7 @@ void VertexFormat_pack(Gwn_VertFormat* format)
// OpenGL ES packs in a different order as desktop GL but component conversion is the same.
-// Of the code here, only struct PackedNormal needs to change.
+// Of the code here, only struct Gwn_PackedNormal needs to change.
#define SIGNED_INT_10_MAX 511
#define SIGNED_INT_10_MIN -512
@@ -283,14 +283,14 @@ static int convert_i16(short x)
// TODO: round?
}
-PackedNormal convert_i10_v3(const float data[3])
+Gwn_PackedNormal GWN_normal_convert_i10_v3(const float data[3])
{
- PackedNormal n = { .x = quantize(data[0]), .y = quantize(data[1]), .z = quantize(data[2]) };
+ Gwn_PackedNormal n = { .x = quantize(data[0]), .y = quantize(data[1]), .z = quantize(data[2]) };
return n;
}
-PackedNormal convert_i10_s3(const short data[3])
+Gwn_PackedNormal GWN_normal_convert_i10_s3(const short data[3])
{
- PackedNormal n = { .x = convert_i16(data[0]), .y = convert_i16(data[1]), .z = convert_i16(data[2]) };
+ Gwn_PackedNormal n = { .x = convert_i16(data[0]), .y = convert_i16(data[1]), .z = convert_i16(data[2]) };
return n;
}
diff --git a/intern/gawain/src/shader_interface.c b/intern/gawain/src/shader_interface.c
deleted file mode 100644
index dff2c06f531..00000000000
--- a/intern/gawain/src/shader_interface.c
+++ /dev/null
@@ -1,311 +0,0 @@
-
-// Gawain shader interface (C --> GLSL)
-//
-// This code is part of the Gawain library, with modifications
-// specific to integration with Blender.
-//
-// Copyright 2017 Mike Erwin
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
-// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
-#include "shader_interface.h"
-#include <stdlib.h>
-#include <stddef.h>
-#include <string.h>
-
-#define SUPPORT_LEGACY_GLSL 1
-#define DEBUG_SHADER_INTERFACE 0
-
-#if DEBUG_SHADER_INTERFACE
- #include <stdio.h>
-#endif
-
-static const char* BuiltinUniform_name(Gwn_UniformBuiltin u)
- {
- static const char* names[] =
- {
- [GWN_UNIFORM_NONE] = NULL,
-
- [GWN_UNIFORM_MODELVIEW] = "ModelViewMatrix",
- [GWN_UNIFORM_PROJECTION] = "ProjectionMatrix",
- [GWN_UNIFORM_MVP] = "ModelViewProjectionMatrix",
-
- [GWN_UNIFORM_MODELVIEW_INV] = "ModelViewInverseMatrix",
- [GWN_UNIFORM_PROJECTION_INV] = "ProjectionInverseMatrix",
-
- [GWN_UNIFORM_NORMAL] = "NormalMatrix",
-
- [GWN_UNIFORM_COLOR] = "color",
-
- [GWN_UNIFORM_CUSTOM] = NULL
- };
-
- return names[u];
- }
-
-static bool match(const char* a, const char* b)
- {
- return strcmp(a, b) == 0;
- }
-
-static unsigned hash_string(const char *str)
- {
- unsigned i = 0, c;
-
- while ((c = *str++))
- {
- i = i * 37 + c;
- }
-
- return i;
- }
-
-static void set_input_name(Gwn_ShaderInput* input, const char* name)
- {
- input->name = name;
- input->name_hash = hash_string(name);
- }
-
-// keep these in sync with Gwn_UniformBuiltin order
-#define FIRST_MAT4_UNIFORM GWN_UNIFORM_MODELVIEW
-#define LAST_MAT4_UNIFORM GWN_UNIFORM_PROJECTION_INV
-
-static bool setup_builtin_uniform(Gwn_ShaderInput* input, const char* name)
- {
- // TODO: reject DOUBLE, IMAGE, ATOMIC_COUNTER gl_types
-
- // detect built-in uniforms (gl_type and name must match)
- // if a match is found, use BuiltinUniform_name so name buffer space can be reclaimed
- switch (input->gl_type)
- {
- case GL_FLOAT_MAT4:
- for (Gwn_UniformBuiltin u = FIRST_MAT4_UNIFORM; u <= LAST_MAT4_UNIFORM; ++u)
- {
- const char* builtin_name = BuiltinUniform_name(u);
- if (match(name, builtin_name))
- {
- set_input_name(input, builtin_name);
- input->builtin_type = u;
- return true;
- }
- }
- break;
- case GL_FLOAT_MAT3:
- {
- const char* builtin_name = BuiltinUniform_name(GWN_UNIFORM_NORMAL);
- if (match(name, builtin_name))
- {
- set_input_name(input, builtin_name);
- input->builtin_type = GWN_UNIFORM_NORMAL;
- return true;
- }
- }
- break;
- case GL_FLOAT_VEC4:
- {
- const char* builtin_name = BuiltinUniform_name(GWN_UNIFORM_COLOR);
- if (match(name, builtin_name))
- {
- set_input_name(input, builtin_name);
- input->builtin_type = GWN_UNIFORM_COLOR;
- return true;
- }
- }
- break;
- default:
- ;
- }
-
- input->builtin_type = GWN_UNIFORM_CUSTOM;
- return false;
- }
-
-Gwn_ShaderInterface* GWN_shaderinterface_create(GLint program)
- {
-#if DEBUG_SHADER_INTERFACE
- printf("%s {\n", __func__); // enter function
-#endif
-
- GLint uniform_ct, attrib_ct;
- glGetProgramiv(program, GL_ACTIVE_UNIFORMS, &uniform_ct);
- glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &attrib_ct);
- const GLint input_ct = uniform_ct + attrib_ct;
-
- GLint max_uniform_name_len, max_attrib_name_len;
- glGetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max_uniform_name_len);
- glGetProgramiv(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_attrib_name_len);
- const uint32_t name_buffer_len = uniform_ct * max_uniform_name_len + attrib_ct * max_attrib_name_len;
-
- // allocate enough space for input counts, details for each input, and a buffer for name strings
- Gwn_ShaderInterface* shaderface = calloc(1, offsetof(Gwn_ShaderInterface, inputs) + input_ct * sizeof(Gwn_ShaderInput) + name_buffer_len);
- shaderface->uniform_ct = uniform_ct;
- shaderface->attrib_ct = attrib_ct;
-
- char* name_buffer = (char*)shaderface + offsetof(Gwn_ShaderInterface, inputs) + input_ct * sizeof(Gwn_ShaderInput);
- uint32_t name_buffer_offset = 0;
-
- for (uint32_t i = 0; i < uniform_ct; ++i)
- {
- Gwn_ShaderInput* input = shaderface->inputs + i;
- GLsizei remaining_buffer = name_buffer_len - name_buffer_offset;
- char* name = name_buffer + name_buffer_offset;
- GLsizei name_len = 0;
-
- glGetActiveUniform(program, i, remaining_buffer, &name_len, &input->size, &input->gl_type, name);
-
- input->location = glGetUniformLocation(program, name);
-
-#if SUPPORT_LEGACY_GLSL
- if (input->location != -1)
- {
-#elif TRUST_NO_ONE
- assert(input->location != -1);
-#endif
-
- if (setup_builtin_uniform(input, name))
- ; // reclaim space from name buffer (don't advance offset)
- else
- {
- set_input_name(input, name);
- name_buffer_offset += name_len + 1; // include NULL terminator
- }
-#if SUPPORT_LEGACY_GLSL
- }
-#endif
-
-#if DEBUG_SHADER_INTERFACE
- printf("uniform[%u] '%s' at location %d\n", i, name, input->location);
-#endif
- }
-
- for (uint32_t i = 0; i < attrib_ct; ++i)
- {
- Gwn_ShaderInput* input = shaderface->inputs + uniform_ct + i;
- GLsizei remaining_buffer = name_buffer_len - name_buffer_offset;
- char* name = name_buffer + name_buffer_offset;
- GLsizei name_len = 0;
-
- glGetActiveAttrib(program, i, remaining_buffer, &name_len, &input->size, &input->gl_type, name);
-
- // TODO: reject DOUBLE gl_types
-
- input->location = glGetAttribLocation(program, name);
-
-#if SUPPORT_LEGACY_GLSL
- if (input->location != -1)
- {
-#elif TRUST_NO_ONE
- assert(input->location != -1);
-#endif
-
- set_input_name(input, name);
- name_buffer_offset += name_len + 1; // include NULL terminator
-#if SUPPORT_LEGACY_GLSL
- }
-#endif
-
-#if DEBUG_SHADER_INTERFACE
- printf("attrib[%u] '%s' at location %d\n", i, name, input->location);
-#endif
- }
-
- const uint32_t name_buffer_used = name_buffer_offset;
-
-#if DEBUG_SHADER_INTERFACE
- printf("using %u of %u bytes from name buffer\n", name_buffer_used, name_buffer_len);
- printf("}\n"); // exit function
-#endif
-
- if (name_buffer_used < name_buffer_len)
- {
- // realloc shaderface to shrink name buffer
- const size_t shaderface_alloc =
- offsetof(Gwn_ShaderInterface, inputs) + (input_ct * sizeof(Gwn_ShaderInput)) + name_buffer_used;
- const char* shaderface_orig_start = (const char*)shaderface;
- const char* shaderface_orig_end = &shaderface_orig_start[shaderface_alloc];
- shaderface = realloc(shaderface, shaderface_alloc);
- const ptrdiff_t delta = (char*)shaderface - shaderface_orig_start;
-
- if (delta)
- {
- // each input->name will need adjustment (except static built-in names)
- for (uint32_t i = 0; i < input_ct; ++i)
- {
- Gwn_ShaderInput* input = shaderface->inputs + i;
-
- if (input->name >= shaderface_orig_start && input->name < shaderface_orig_end)
- input->name += delta;
- }
- }
- }
-
- return shaderface;
- }
-
-void GWN_shaderinterface_discard(Gwn_ShaderInterface* shaderface)
- {
- // allocated as one chunk, so discard is simple
- free(shaderface);
- }
-
-const Gwn_ShaderInput* GWN_shaderinterface_uniform(const Gwn_ShaderInterface* shaderface, const char* name)
- {
- const unsigned name_hash = hash_string(name);
- for (uint32_t i = 0; i < shaderface->uniform_ct; ++i)
- {
- const Gwn_ShaderInput* uniform = shaderface->inputs + i;
-
-#if SUPPORT_LEGACY_GLSL
- if (uniform->name == NULL) continue;
-#endif
-
- if (uniform->name_hash != name_hash) continue;
-
- if (match(uniform->name, name))
- return uniform;
-
- // TODO: warn if we find a matching builtin, since these can be looked up much quicker --v
- }
-
- return NULL; // not found
- }
-
-const Gwn_ShaderInput* GWN_shaderinterface_uniform_builtin(const Gwn_ShaderInterface* shaderface, Gwn_UniformBuiltin builtin)
- {
-#if TRUST_NO_ONE
- assert(builtin != GWN_UNIFORM_NONE);
- assert(builtin != GWN_UNIFORM_CUSTOM);
-#endif
-
- // look up by enum, not name
- for (uint32_t i = 0; i < shaderface->uniform_ct; ++i)
- {
- const Gwn_ShaderInput* uniform = shaderface->inputs + i;
-
- if (uniform->builtin_type == builtin)
- return uniform;
- }
- return NULL; // not found
- }
-
-const Gwn_ShaderInput* GWN_shaderinterface_attr(const Gwn_ShaderInterface* shaderface, const char* name)
- {
- // attribs are stored after uniforms
- const uint32_t input_ct = shaderface->uniform_ct + shaderface->attrib_ct;
- const unsigned name_hash = hash_string(name);
- for (uint32_t i = shaderface->uniform_ct; i < input_ct; ++i)
- {
- const Gwn_ShaderInput* attrib = shaderface->inputs + i;
-
-#if SUPPORT_LEGACY_GLSL
- if (attrib->name == NULL) continue;
-#endif
-
- if (attrib->name_hash != name_hash) continue;
-
- if (match(attrib->name, name))
- return attrib;
- }
- return NULL; // not found
- }
diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt
index e549a48d4b9..31e92c94eed 100644
--- a/intern/ghost/CMakeLists.txt
+++ b/intern/ghost/CMakeLists.txt
@@ -168,10 +168,6 @@ elseif(APPLE AND NOT WITH_X11)
)
endif()
- if(WITH_CODEC_QUICKTIME)
- add_definitions(-DWITH_QUICKTIME)
- endif()
-
elseif(WITH_X11)
list(APPEND INC_SYS
${X11_X11_INCLUDE_PATH}
diff --git a/intern/ghost/intern/GHOST_ContextGLX.cpp b/intern/ghost/intern/GHOST_ContextGLX.cpp
index 0a9dc900aed..061ac29945b 100644
--- a/intern/ghost/intern/GHOST_ContextGLX.cpp
+++ b/intern/ghost/intern/GHOST_ContextGLX.cpp
@@ -57,7 +57,6 @@ GHOST_ContextGLX::GHOST_ContextGLX(
GHOST_TUns16 numOfAASamples,
Window window,
Display *display,
- XVisualInfo *visualInfo,
GLXFBConfig fbconfig,
int contextProfileMask,
int contextMajorVersion,
@@ -66,7 +65,6 @@ GHOST_ContextGLX::GHOST_ContextGLX(
int contextResetNotificationStrategy)
: GHOST_Context(stereoVisual, numOfAASamples),
m_display(display),
- m_visualInfo(visualInfo),
m_fbconfig(fbconfig),
m_window(window),
m_contextProfileMask(contextProfileMask),
diff --git a/intern/ghost/intern/GHOST_ContextGLX.h b/intern/ghost/intern/GHOST_ContextGLX.h
index 6547a0bd00a..51fb1dd57dc 100644
--- a/intern/ghost/intern/GHOST_ContextGLX.h
+++ b/intern/ghost/intern/GHOST_ContextGLX.h
@@ -57,7 +57,6 @@ public:
GHOST_TUns16 numOfAASamples,
Window window,
Display *display,
- XVisualInfo *visualInfo,
GLXFBConfig fbconfig,
int contextProfileMask,
int contextMajorVersion,
@@ -113,7 +112,6 @@ private:
void initContextGLXEW();
Display *m_display;
- XVisualInfo *m_visualInfo;
GLXFBConfig m_fbconfig;
Window m_window;
diff --git a/intern/ghost/intern/GHOST_ContextWGL.cpp b/intern/ghost/intern/GHOST_ContextWGL.cpp
index 8cf311b9e84..d2dd38878f7 100644
--- a/intern/ghost/intern/GHOST_ContextWGL.cpp
+++ b/intern/ghost/intern/GHOST_ContextWGL.cpp
@@ -914,29 +914,6 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext()
reportContextString("Version", m_dummyVersion, version);
#endif
- if ((strcmp(vendor, "Microsoft Corporation") == 0 ||
- strcmp(renderer, "GDI Generic") == 0) && version[0] == '1' && version[2] == '1')
- {
- MessageBox(m_hWnd, "Your system does not use 3D hardware acceleration.\n"
- "Blender requires a graphics driver with OpenGL 3.3 support.\n\n"
- "This may be caused by:\n"
- "* A missing or faulty graphics driver installation.\n"
- " Blender needs a graphics card driver to work correctly.\n"
- "* Accessing Blender through a remote connection.\n"
- "* Using Blender through a virtual machine.\n\n"
- "The program will now close.",
- "Blender - Can't detect 3D hardware accelerated Driver!",
- MB_OK | MB_ICONERROR);
- exit(0);
- }
- else if (version[0] < '3' || (version[0] == '3' && version[2] < '3')) {
- MessageBox(m_hWnd, "Blender requires a graphics driver with OpenGL 3.3 support.\n\n"
- "The program will now close.",
- "Blender - Unsupported Graphics Driver!",
- MB_OK | MB_ICONERROR);
- exit(0);
- }
-
return GHOST_kSuccess;
}
@@ -950,3 +927,97 @@ GHOST_TSuccess GHOST_ContextWGL::releaseNativeHandles()
return success;
}
+
+/**
+ * For any given HDC you may call SetPixelFormat once
+ *
+ * So we better try to get the correct OpenGL version in a new window altogether, in case it fails.
+ * (see https://msdn.microsoft.com/en-us/library/windows/desktop/dd369049(v=vs.85).aspx)
+ */
+static bool TryOpenGLVersion(
+ HWND hwnd,
+ bool wantStereoVisual,
+ bool wantAlphaBackground,
+ GHOST_TUns16 wantNumOfAASamples,
+ int contextProfileMask,
+ bool debugContext,
+ int major, int minor)
+{
+ HWND dummyHWND = clone_window(hwnd, NULL);
+ if (dummyHWND == NULL) {
+ return false;
+ }
+
+ HDC dummyHDC = GetDC(dummyHWND);
+ if (dummyHDC == NULL) {
+ return false;
+ }
+
+ GHOST_ContextWGL * context = new GHOST_ContextWGL(
+ wantStereoVisual,
+ wantAlphaBackground,
+ wantNumOfAASamples,
+ dummyHWND,
+ dummyHDC,
+ contextProfileMask,
+ major, minor,
+ (debugContext ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
+ GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
+
+ bool result = context->initializeDrawingContext();
+ delete context;
+
+ ReleaseDC(dummyHWND, dummyHDC);
+ DestroyWindow(dummyHWND);
+
+ return result;
+}
+
+GHOST_TSuccess GHOST_ContextWGL::getMaximumSupportedOpenGLVersion(
+ HWND hwnd,
+ bool wantStereoVisual,
+ bool wantAlphaBackground,
+ GHOST_TUns16 wantNumOfAASamples,
+ int contextProfileMask,
+ bool debugContext,
+ GHOST_TUns8 *r_major_version,
+ GHOST_TUns8 *r_minor_version)
+{
+ /* - AMD and Intel give us exactly this version
+ * - NVIDIA gives at least this version <-- desired behavior
+ * So we ask for 4.5, 4.4 ... 3.3 in descending order to get the best version on the user's system. */
+ for (int minor = 5; minor >= 0; --minor) {
+ if (TryOpenGLVersion(
+ hwnd,
+ wantStereoVisual,
+ wantAlphaBackground,
+ wantNumOfAASamples,
+ contextProfileMask,
+ debugContext,
+ 4, minor))
+ {
+ *r_major_version = 4;
+ *r_minor_version = minor;
+ return GHOST_kSuccess;
+ }
+ }
+
+ /* Fallback to OpenGL 3.3 */
+ if (TryOpenGLVersion(
+ hwnd,
+ wantStereoVisual,
+ wantAlphaBackground,
+ wantNumOfAASamples,
+ contextProfileMask,
+ debugContext,
+ 3, 3))
+ {
+ *r_major_version = 3;
+ *r_minor_version = 3;
+ return GHOST_kSuccess;
+ }
+
+ *r_major_version = 0;
+ *r_minor_version = 0;
+ return GHOST_kFailure;
+}
diff --git a/intern/ghost/intern/GHOST_ContextWGL.h b/intern/ghost/intern/GHOST_ContextWGL.h
index a07cc1b6301..0d9986a0802 100644
--- a/intern/ghost/intern/GHOST_ContextWGL.h
+++ b/intern/ghost/intern/GHOST_ContextWGL.h
@@ -105,6 +105,20 @@ public:
*/
GHOST_TSuccess getSwapInterval(int &intervalOut);
+ /**
+ * Gets the maximum supported OpenGL context for the user hardware
+ * \return Whether major_version and minor_version resulted in a valid context.
+ */
+ static GHOST_TSuccess getMaximumSupportedOpenGLVersion(
+ HWND hwnd,
+ bool wantStereoVisual,
+ bool wantAlphaBackground,
+ GHOST_TUns16 wantNumOfAASamples,
+ int contextProfileMask,
+ bool debugContext,
+ GHOST_TUns8 *r_major_version,
+ GHOST_TUns8 *r_minor_version);
+
private:
int choose_pixel_format(
bool stereoVisual,
diff --git a/intern/ghost/intern/GHOST_EventPrinter.cpp b/intern/ghost/intern/GHOST_EventPrinter.cpp
index f25f6637cb1..a6adba12152 100644
--- a/intern/ghost/intern/GHOST_EventPrinter.cpp
+++ b/intern/ghost/intern/GHOST_EventPrinter.cpp
@@ -193,16 +193,6 @@ void GHOST_EventPrinter::getKeyString(GHOST_TKey key, char str[32]) const
}
else if ((key >= GHOST_kKeyNumpad0) && (key <= GHOST_kKeyNumpad9)) {
sprintf(str, "Numpad %d", (key - GHOST_kKeyNumpad0));
-#if defined(__sun__) || defined(__sun)
- }
- else if (key == 268828432) { /* solaris keyboards are messed up */
- /* This should really test XK_F11 but that doesn't work */
- strcpy(str, "F11");
- }
- else if (key == 268828433) { /* solaris keyboards are messed up */
- /* This should really test XK_F12 but that doesn't work */
- strcpy(str, "F12");
-#endif
}
else if ((key >= GHOST_kKeyF1) && (key <= GHOST_kKeyF24)) {
sprintf(str, "F%d", key - GHOST_kKeyF1 + 1);
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.h b/intern/ghost/intern/GHOST_SystemCocoa.h
index b142c2f7194..6802ad42c7b 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.h
+++ b/intern/ghost/intern/GHOST_SystemCocoa.h
@@ -292,11 +292,6 @@ protected:
/** Ignores window size messages (when window is dragged). */
bool m_ignoreWindowSizedMessages;
- /** Stores the mouse cursor delta due to setting a new cursor position
- * Needed because cocoa event delta cursor move takes setCursorPosition changes too.
- */
- GHOST_TInt32 m_cursorDelta_x, m_cursorDelta_y;
-
/** Temporarily ignore momentum scroll events */
bool m_ignoreMomentumScroll;
/** Is the scroll wheel event generated by a multitouch trackpad or mouse? */
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm
index 173f59c9c8f..42ccfb06fd9 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -366,8 +366,6 @@ GHOST_SystemCocoa::GHOST_SystemCocoa()
char *rstring = NULL;
m_modifierMask =0;
- m_cursorDelta_x=0;
- m_cursorDelta_y=0;
m_outsideLoopEventProcessed = false;
m_needDelayedApplicationBecomeActiveEventProcessing = false;
m_displayManager = new GHOST_DisplayManagerCocoa ();
@@ -644,6 +642,13 @@ GHOST_TSuccess GHOST_SystemCocoa::setMouseCursorPosition(GHOST_TInt32 x, GHOST_T
CGDisplayMoveCursorToPoint((CGDirectDisplayID)[[[windowScreen deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue], CGPointMake(xf, yf));
+ // See https://stackoverflow.com/a/17559012. By default, hardware events
+ // will be suppressed for 500ms after a synthetic mouse event. For unknown
+ // reasons CGEventSourceSetLocalEventsSuppressionInterval does not work,
+ // however calling CGAssociateMouseAndMouseCursorPosition also removes the
+ // delay, even if this is undocumented.
+ CGAssociateMouseAndMouseCursorPosition(true);
+
[pool drain];
return GHOST_kSuccess;
}
@@ -1249,27 +1254,6 @@ bool GHOST_SystemCocoa::handleTabletEvent(void *eventPtr)
}
}
-#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070
-enum {
- NSEventPhaseNone = 0,
- NSEventPhaseBegan = 0x1 << 0,
- NSEventPhaseStationary = 0x1 << 1,
- NSEventPhaseChanged = 0x1 << 2,
- NSEventPhaseEnded = 0x1 << 3,
- NSEventPhaseCancelled = 0x1 << 4,
-};
-typedef NSUInteger NSEventPhase;
-
-@interface NSEvent (AvailableOn1070AndLater)
-- (BOOL)hasPreciseScrollingDeltas;
-- (CGFloat)scrollingDeltaX;
-- (CGFloat)scrollingDeltaY;
-- (NSEventPhase)momentumPhase;
-- (BOOL)isDirectionInvertedFromDevice;
-- (NSEventPhase)phase;
-@end
-#endif
-
GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
{
NSEvent *event = (NSEvent *)eventPtr;
@@ -1354,9 +1338,8 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
case GHOST_kGrabWrap: //Wrap cursor at area/window boundaries
{
NSPoint mousePos = [cocoawindow mouseLocationOutsideOfEventStream];
- GHOST_TInt32 x_mouse= mousePos.x;
- GHOST_TInt32 y_mouse= mousePos.y;
- GHOST_TInt32 x_accum, y_accum, x_cur, y_cur, x, y;
+ GHOST_TInt32 x_mouse = mousePos.x;
+ GHOST_TInt32 y_mouse = mousePos.y;
GHOST_Rect bounds, windowBounds, correctedBounds;
/* fallback to window bounds */
@@ -1370,29 +1353,26 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
correctedBounds.m_b = (windowBounds.m_b - windowBounds.m_t) - correctedBounds.m_b;
correctedBounds.m_t = (windowBounds.m_b - windowBounds.m_t) - correctedBounds.m_t;
- //Update accumulation counts
+ //Get accumulation from previous mouse warps
+ GHOST_TInt32 x_accum, y_accum;
window->getCursorGrabAccum(x_accum, y_accum);
- x_accum += [event deltaX]-m_cursorDelta_x;
- y_accum += -[event deltaY]-m_cursorDelta_y; //Strange Apple implementation (inverted coordinates for the deltaY) ...
- window->setCursorGrabAccum(x_accum, y_accum);
//Warp mouse cursor if needed
- x_mouse += [event deltaX]-m_cursorDelta_x;
- y_mouse += -[event deltaY]-m_cursorDelta_y;
- correctedBounds.wrapPoint(x_mouse, y_mouse, 2);
-
- //Compensate for mouse moved event taking cursor position set into account
- m_cursorDelta_x = x_mouse-mousePos.x;
- m_cursorDelta_y = y_mouse-mousePos.y;
+ GHOST_TInt32 warped_x_mouse = x_mouse;
+ GHOST_TInt32 warped_y_mouse = y_mouse;
+ correctedBounds.wrapPoint(warped_x_mouse, warped_y_mouse, 4);
//Set new cursor position
- window->clientToScreenIntern(x_mouse, y_mouse, x_cur, y_cur);
- setMouseCursorPosition(x_cur, y_cur); /* wrap */
+ if (x_mouse != warped_x_mouse || y_mouse != warped_y_mouse) {
+ GHOST_TInt32 warped_x, warped_y;
+ window->clientToScreenIntern(warped_x_mouse, warped_y_mouse, warped_x, warped_y);
+ setMouseCursorPosition(warped_x, warped_y); /* wrap */
+ window->setCursorGrabAccum(x_accum + (x_mouse - warped_x_mouse), y_accum + (y_mouse - warped_y_mouse));
+ }
- //Post event
- window->getCursorGrabInitPos(x_cur, y_cur);
- window->screenToClientIntern(x_cur, y_cur, x_cur, y_cur);
- window->clientToScreenIntern(x_cur + x_accum, y_cur + y_accum, x, y);
+ //Generate event
+ GHOST_TInt32 x, y;
+ window->clientToScreenIntern(x_mouse + x_accum, y_mouse + y_accum, x, y);
pushEvent(new GHOST_EventCursor([event timestamp] * 1000, GHOST_kEventCursorMove, window, x, y));
break;
}
@@ -1404,9 +1384,6 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
window->clientToScreenIntern(mousePos.x, mousePos.y, x, y);
pushEvent(new GHOST_EventCursor([event timestamp] * 1000, GHOST_kEventCursorMove, window, x, y));
-
- m_cursorDelta_x=0;
- m_cursorDelta_y=0; //Mouse motion occurred between two cursor warps, so we can reset the delta counter
break;
}
}
@@ -1461,7 +1438,6 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
double dx;
double dy;
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
/* with 10.7 nice scrolling deltas are supported */
dx = [event scrollingDeltaX];
dy = [event scrollingDeltaY];
@@ -1471,29 +1447,6 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
dx = [event deltaX];
dy = [event deltaY];
}
-#else
- /* trying to pretend you have nice scrolls... */
- dx = [event deltaX];
- dy = -[event deltaY];
- const double deltaMax = 50.0;
-
- if ((dx == 0) && (dy == 0)) break;
-
- /* Quadratic acceleration */
- dx = dx*(fabs(dx) + 0.5);
- if (dx < 0.0) dx -= 0.5;
- else dx += 0.5;
- if (dx < -deltaMax) dx = -deltaMax;
- else if (dx > deltaMax) dx = deltaMax;
-
- dy = dy*(fabs(dy) + 0.5);
- if (dy < 0.0) dy -= 0.5;
- else dy += 0.5;
- if (dy < -deltaMax) dy= -deltaMax;
- else if (dy > deltaMax) dy= deltaMax;
-
- dy = -dy;
-#endif
window->clientToScreenIntern(mousePos.x, mousePos.y, x, y);
pushEvent(new GHOST_EventTrackpad([event timestamp] * 1000, window, GHOST_kTrackpadEventScroll, x, y, dx, dy));
diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index 9f03b5e9537..b0dae432643 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -941,6 +941,8 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
GHOST_ASSERT(system, "GHOST_SystemWin32::s_wndProc(): system not initialized");
if (hwnd) {
+#if 0
+ // Disabled due to bug in Intel drivers, see T51959
if(msg == WM_NCCREATE) {
// Tell Windows to automatically handle scaling of non-client areas
// such as the caption bar. EnableNonClientDpiScaling was introduced in Windows 10
@@ -954,6 +956,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
}
}
}
+#endif
GHOST_WindowWin32 *window = (GHOST_WindowWin32 *)::GetWindowLongPtr(hwnd, GWLP_USERDATA);
if (window) {
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index 30cfac08153..8fff565338f 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -1601,26 +1601,6 @@ convertXKey(KeySym key)
}
else if ((key >= XK_F1) && (key <= XK_F24)) {
type = GHOST_TKey(key - XK_F1 + int(GHOST_kKeyF1));
-#if defined(__sun) || defined(__sun__)
- /* This is a bit of a hack, but it looks like sun
- * Used F11 and friends for its special keys Stop,again etc..
- * So this little patch enables F11 and F12 to work as expected
- * following link has documentation on it:
- * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4734408
- * also from /usr/include/X11/Sunkeysym.h
- * #define SunXK_F36 0x1005FF10 // Labeled F11
- * #define SunXK_F37 0x1005FF11 // Labeled F12
- *
- * mein@cs.umn.edu
- */
-
- }
- else if (key == 268828432) {
- type = GHOST_kKeyF11;
- }
- else if (key == 268828433) {
- type = GHOST_kKeyF12;
-#endif
}
else {
switch (key) {
@@ -1714,19 +1694,6 @@ convertXKey(KeySym key)
GXMAP(type, XF86XK_AudioForward, GHOST_kKeyMediaLast);
#endif
#endif
-
- /* some extra sun cruft (NICE KEYBOARD!) */
-#ifdef __sun__
- GXMAP(type, 0xffde, GHOST_kKeyNumpad1);
- GXMAP(type, 0xffe0, GHOST_kKeyNumpad3);
- GXMAP(type, 0xffdc, GHOST_kKeyNumpad5);
- GXMAP(type, 0xffd8, GHOST_kKeyNumpad7);
- GXMAP(type, 0xffda, GHOST_kKeyNumpad9);
-
- GXMAP(type, 0xffd6, GHOST_kKeyNumpadSlash);
- GXMAP(type, 0xffd7, GHOST_kKeyNumpadAsterisk);
-#endif
-
default:
type = GHOST_kKeyUnknown;
break;
diff --git a/intern/ghost/intern/GHOST_WindowCocoa.h b/intern/ghost/intern/GHOST_WindowCocoa.h
index 5168c48ca2f..9dbc85d91e2 100644
--- a/intern/ghost/intern/GHOST_WindowCocoa.h
+++ b/intern/ghost/intern/GHOST_WindowCocoa.h
@@ -303,8 +303,6 @@ protected:
GHOST_TabletData m_tablet;
- bool m_lionStyleFullScreen;
-
bool m_immediateDraw;
bool m_debug_context; // for debug messages during context setup
};
diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm
index b0feb11a6af..309c19f92af 100644
--- a/intern/ghost/intern/GHOST_WindowCocoa.mm
+++ b/intern/ghost/intern/GHOST_WindowCocoa.mm
@@ -43,14 +43,6 @@
#include <sys/sysctl.h>
-#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070
-/* Lion style fullscreen support when building with the 10.6 SDK */
-enum {
- NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7,
- NSFullScreenWindowMask = 1 << 14
-};
-#endif
-
#pragma mark Cocoa window delegate object
@interface CocoaWindowDelegate : NSObject
@@ -511,14 +503,6 @@ enum {
#pragma mark initialization / finalization
-#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070
-@interface NSView (NSOpenGLSurfaceResolution)
-- (BOOL)wantsBestResolutionOpenGLSurface;
-- (void)setWantsBestResolutionOpenGLSurface:(BOOL)flag;
-- (NSRect)convertRectToBacking:(NSRect)bounds;
-@end
-#endif
-
GHOST_WindowCocoa::GHOST_WindowCocoa(
GHOST_SystemCocoa *systemCocoa,
const STR_String& title,
@@ -537,7 +521,6 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
m_systemCocoa = systemCocoa;
m_fullScreen = false;
m_immediateDraw = false;
- m_lionStyleFullScreen = false;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
@@ -613,16 +596,6 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
if (state == GHOST_kWindowStateFullScreen)
setState(GHOST_kWindowStateFullScreen);
- // Starting with 10.9 (darwin 13.x.x), we can use Lion fullscreen,
- // since it now has better multi-monitor support
- // if the screens are spawned, additional screens get useless,
- // so we only use lionStyleFullScreen when screens have separate spaces
-
- if ([NSScreen respondsToSelector:@selector(screensHaveSeparateSpaces)] && [NSScreen screensHaveSeparateSpaces]) {
- // implies we are on >= OSX 10.9
- m_lionStyleFullScreen = true;
- }
-
[pool drain];
}
@@ -760,28 +733,18 @@ void GHOST_WindowCocoa::getClientBounds(GHOST_Rect& bounds) const
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- if (!m_fullScreen) {
- NSRect screenSize = [[m_window screen] visibleFrame];
+ NSRect screenSize = [[m_window screen] visibleFrame];
- //Max window contents as screen size (excluding title bar...)
- NSRect contentRect = [CocoaWindow contentRectForFrameRect:screenSize
- styleMask:(NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask)];
+ //Max window contents as screen size (excluding title bar...)
+ NSRect contentRect = [CocoaWindow contentRectForFrameRect:screenSize
+ styleMask:(NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask)];
- rect = [m_window contentRectForFrameRect:[m_window frame]];
-
- bounds.m_b = contentRect.size.height - (rect.origin.y -contentRect.origin.y);
- bounds.m_l = rect.origin.x -contentRect.origin.x;
- bounds.m_r = rect.origin.x-contentRect.origin.x + rect.size.width;
- bounds.m_t = contentRect.size.height - (rect.origin.y + rect.size.height -contentRect.origin.y);
- }
- else {
- NSRect screenSize = [[m_window screen] frame];
-
- bounds.m_b = screenSize.origin.y + screenSize.size.height;
- bounds.m_l = screenSize.origin.x;
- bounds.m_r = screenSize.origin.x + screenSize.size.width;
- bounds.m_t = screenSize.origin.y;
- }
+ rect = [m_window contentRectForFrameRect:[m_window frame]];
+
+ bounds.m_b = contentRect.size.height - (rect.origin.y -contentRect.origin.y);
+ bounds.m_l = rect.origin.x -contentRect.origin.x;
+ bounds.m_r = rect.origin.x-contentRect.origin.x + rect.size.width;
+ bounds.m_t = contentRect.size.height - (rect.origin.y + rect.size.height -contentRect.origin.y);
[pool drain];
}
@@ -856,9 +819,6 @@ GHOST_TWindowState GHOST_WindowCocoa::getState() const
state = GHOST_kWindowStateNormal;
}
}
- else if (m_fullScreen) {
- state = GHOST_kWindowStateFullScreen;
- }
else if ([m_window isMiniaturized]) {
state = GHOST_kWindowStateMinimized;
}
@@ -940,15 +900,12 @@ NSScreen* GHOST_WindowCocoa::getScreen()
/* called for event, when window leaves monitor to another */
void GHOST_WindowCocoa::setNativePixelSize(void)
{
- /* make sure 10.6 keeps running */
- if ([m_openGLView respondsToSelector:@selector(setWantsBestResolutionOpenGLSurface:)]) {
- NSRect backingBounds = [m_openGLView convertRectToBacking:[m_openGLView bounds]];
-
- GHOST_Rect rect;
- getClientBounds(rect);
+ NSRect backingBounds = [m_openGLView convertRectToBacking:[m_openGLView bounds]];
+
+ GHOST_Rect rect;
+ getClientBounds(rect);
- m_nativePixelSize = (float)backingBounds.size.width / (float)rect.getWidth();
- }
+ m_nativePixelSize = (float)backingBounds.size.width / (float)rect.getWidth();
}
/**
@@ -973,35 +930,8 @@ GHOST_TSuccess GHOST_WindowCocoa::setState(GHOST_TWindowState state)
{
NSUInteger masks = [m_window styleMask];
- if (!m_fullScreen && !(masks & NSFullScreenWindowMask)) {
- if (m_lionStyleFullScreen) {
- [m_window toggleFullScreen:nil];
- break;
- }
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- /* This status change needs to be done before Cocoa call to enter fullscreen mode
- * to give window delegate hint not to forward its deactivation to ghost wm that
- * doesn't know view/window difference. */
- m_fullScreen = true;
-
- /* Disable toggle for Lion style fullscreen */
- [m_window setCollectionBehavior:NSWindowCollectionBehaviorDefault];
-
- //10.6 provides Cocoa functions to autoshow menu bar, and to change a window style
- //Hide menu & dock if on primary screen. else only menu
- if ([[m_window screen] isEqual:[[NSScreen screens] objectAtIndex:0]]) {
- [NSApp setPresentationOptions:(NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)];
- }
- //Make window borderless and enlarge it
- [m_window setStyleMask:NSBorderlessWindowMask];
- [m_window setFrame:[[m_window screen] frame] display:YES];
- [m_window makeFirstResponder:m_openGLView];
-
- //Tell WM of view new size
- m_systemCocoa->handleWindowEvent(GHOST_kEventWindowSize, this);
-
- [pool drain];
+ if (!(masks & NSFullScreenWindowMask)) {
+ [m_window toggleFullScreen:nil];
}
break;
}
@@ -1014,26 +944,6 @@ GHOST_TSuccess GHOST_WindowCocoa::setState(GHOST_TWindowState state)
// Lion style fullscreen
[m_window toggleFullScreen:nil];
}
- else if (m_fullScreen) {
- m_fullScreen = false;
-
- /* Enable toggle for into Lion style fullscreen */
- [m_window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
-
- //Exit fullscreen
- //Show again menu & dock if needed
- if ([[m_window screen] isEqual:[NSScreen mainScreen]]) {
- [NSApp setPresentationOptions:NSApplicationPresentationDefault];
- }
- //Make window normal and resize it
- [m_window setStyleMask:(NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask)];
- [m_window setFrame:[[m_window screen] visibleFrame] display:YES];
- //TODO for 10.6 only : window title is forgotten after the style change
- [m_window makeFirstResponder:m_openGLView];
-
- //Tell WM of view new size
- m_systemCocoa->handleWindowEvent(GHOST_kEventWindowSize, this);
- }
else if ([m_window isMiniaturized])
[m_window deminiaturize:nil];
else if ([m_window isZoomed])
@@ -1164,7 +1074,6 @@ GHOST_TSuccess GHOST_WindowCocoa::setProgressBar(float progress)
return GHOST_kSuccess;
}
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
static void postNotification()
{
NSUserNotification *notification = [[NSUserNotification alloc] init];
@@ -1174,7 +1083,6 @@ static void postNotification()
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
[notification release];
}
-#endif
GHOST_TSuccess GHOST_WindowCocoa::endProgressBar()
{
@@ -1189,15 +1097,13 @@ GHOST_TSuccess GHOST_WindowCocoa::endProgressBar()
[dockIcon unlockFocus];
[NSApp setApplicationIconImage:dockIcon];
-
- // With OSX 10.8 and later, we can use notifications to inform the user when the progress reached 100%
- // Atm. just fire this when the progressbar ends, the behavior is controlled in the NotificationCenter
- // If Blender is not frontmost window, a message pops up with sound, in any case an entry in notifications
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
+ // We use notifications to inform the user when the progress reached 100%
+ // Atm. just fire this when the progressbar ends, the behavior is controlled
+ // in the NotificationCenter If Blender is not frontmost window, a message
+ // pops up with sound, in any case an entry in notifications
if ([NSUserNotificationCenter respondsToSelector:@selector(defaultUserNotificationCenter)]) {
postNotification();
}
-#endif
[dockIcon release];
@@ -1311,9 +1217,6 @@ GHOST_TSuccess GHOST_WindowCocoa::setWindowCursorGrab(GHOST_TGrabCursorMode mode
//Make window key if it wasn't to get the mouse move events
[m_window makeKeyWindow];
- //Dissociate cursor position even for warp mode, to allow mouse acceleration to work even when warping the cursor
- err = CGAssociateMouseAndMouseCursorPosition(false) == kCGErrorSuccess ? GHOST_kSuccess : GHOST_kFailure;
-
[pool drain];
}
}
@@ -1323,7 +1226,6 @@ GHOST_TSuccess GHOST_WindowCocoa::setWindowCursorGrab(GHOST_TGrabCursorMode mode
setWindowCursorVisibility(true);
}
- err = CGAssociateMouseAndMouseCursorPosition(true) == kCGErrorSuccess ? GHOST_kSuccess : GHOST_kFailure;
/* Almost works without but important otherwise the mouse GHOST location can be incorrect on exit */
setCursorGrabAccum(0, 0);
m_cursorGrabBounds.m_l= m_cursorGrabBounds.m_r= -1; /* disable */
diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp
index 2a141f8770c..ee0d7ef460c 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.cpp
+++ b/intern/ghost/intern/GHOST_WindowWin32.cpp
@@ -402,21 +402,29 @@ void GHOST_WindowWin32::getClientBounds(GHOST_Rect &bounds) const
{
RECT rect;
POINT coord;
- ::GetClientRect(m_hWnd, &rect);
+ if (!IsIconic(m_hWnd)) {
+ ::GetClientRect(m_hWnd, &rect);
- coord.x = rect.left;
- coord.y = rect.top;
- ::ClientToScreen(m_hWnd, &coord);
+ coord.x = rect.left;
+ coord.y = rect.top;
+ ::ClientToScreen(m_hWnd, &coord);
- bounds.m_l = coord.x;
- bounds.m_t = coord.y;
+ bounds.m_l = coord.x;
+ bounds.m_t = coord.y;
- coord.x = rect.right;
- coord.y = rect.bottom;
- ::ClientToScreen(m_hWnd, &coord);
+ coord.x = rect.right;
+ coord.y = rect.bottom;
+ ::ClientToScreen(m_hWnd, &coord);
- bounds.m_r = coord.x;
- bounds.m_b = coord.y;
+ bounds.m_r = coord.x;
+ bounds.m_b = coord.y;
+ }
+ else {
+ bounds.m_b = 0;
+ bounds.m_l = 0;
+ bounds.m_r = 0;
+ bounds.m_t = 0;
+ }
}
@@ -611,54 +619,48 @@ GHOST_TSuccess GHOST_WindowWin32::invalidate()
GHOST_Context *GHOST_WindowWin32::newDrawingContext(GHOST_TDrawingContextType type)
{
if (type == GHOST_kDrawingContextTypeOpenGL) {
-
- // During development:
- // ask for 2.1 context, driver gives latest compatibility profile
- // (we check later to ensure it's >= 3.3 on Windows)
- //
- // Final Blender 2.8:
- // try 4.x core profile
- // try 3.3 core profile
- // no fallbacks
-
- // TODO(merwin): query version of initial dummy context, request that + profile + debug
-
GHOST_Context *context;
#if defined(WITH_GL_PROFILE_CORE)
- // our minimum requirement is 3.3 core profile
- // when we request a specific GL version:
- // - AMD and Intel give us exactly this version
- // - NVIDIA gives at least this version <-- desired behavior
- // so we ask for 4.5, 4.4 ... 3.3 in descending order to get the best version on the user's system
- for (int minor = 5; minor >= 0; --minor) {
+ GHOST_TUns8 major, minor;
+
+ if (GHOST_ContextWGL::getMaximumSupportedOpenGLVersion(
+ m_hWnd,
+ m_wantStereoVisual,
+ m_wantAlphaBackground,
+ m_wantNumOfAASamples,
+ WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
+ m_debug_context,
+ &major, &minor))
+ {
context = new GHOST_ContextWGL(
- m_wantStereoVisual,
- m_wantAlphaBackground,
- m_wantNumOfAASamples,
- m_hWnd,
- m_hDC,
- WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
- 4, minor,
- (m_debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
- GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
-
- if (context->initializeDrawingContext())
+ m_wantStereoVisual,
+ m_wantAlphaBackground,
+ m_wantNumOfAASamples,
+ m_hWnd,
+ m_hDC,
+ WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
+ major, minor,
+ (m_debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
+ GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
+
+ if (context->initializeDrawingContext()) {
return context;
- else
+ }
+ else {
delete context;
+ }
+ }
+ else {
+ MessageBox(
+ m_hWnd,
+ "Blender requires a graphics driver with at least OpenGL 3.3 support.\n\n"
+ "The program will now close.",
+ "Blender - Unsupported Graphics Driver!",
+ MB_OK | MB_ICONERROR);
+ exit(0);
+ return NULL;
}
-
- context = new GHOST_ContextWGL(
- m_wantStereoVisual,
- m_wantAlphaBackground,
- m_wantNumOfAASamples,
- m_hWnd,
- m_hDC,
- WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
- 3, 3,
- (m_debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
- GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
#elif defined(WITH_GL_PROFILE_COMPAT)
// ask for 2.1 context, driver gives any GL version >= 2.1 (hopefully the latest compatibility profile)
@@ -677,10 +679,12 @@ GHOST_Context *GHOST_WindowWin32::newDrawingContext(GHOST_TDrawingContextType ty
# error // must specify either core or compat at build time
#endif
- if (context->initializeDrawingContext())
+ if (context->initializeDrawingContext()) {
return context;
- else
+ }
+ else {
delete context;
+ }
}
return NULL;
@@ -865,19 +869,14 @@ void GHOST_WindowWin32::processWin32TabletEvent(WPARAM wParam, LPARAM lParam)
if (fpWTPacket) {
if (fpWTPacket((HCTX)lParam, wParam, &pkt)) {
if (m_tabletData) {
- switch (pkt.pkCursor) {
- case 0: /* first device */
- case 3: /* second device */
+ switch (pkt.pkCursor % 3) { /* % 3 for multiple devices ("DualTrack") */
+ case 0:
m_tabletData->Active = GHOST_kTabletModeNone; /* puck - not yet supported */
break;
case 1:
- case 4:
- case 7:
m_tabletData->Active = GHOST_kTabletModeStylus; /* stylus */
break;
case 2:
- case 5:
- case 8:
m_tabletData->Active = GHOST_kTabletModeEraser; /* eraser */
break;
}
diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp
index 450fe568814..c48e969baf3 100644
--- a/intern/ghost/intern/GHOST_WindowX11.cpp
+++ b/intern/ghost/intern/GHOST_WindowX11.cpp
@@ -59,10 +59,6 @@
//For DPI value
#include <X11/Xresource.h>
-#if defined(__sun__) || defined(__sun) || defined(__sparc) || defined(__sparc__) || defined(_AIX)
-# include <strings.h>
-#endif
-
#include <cstring>
#include <cstdio>
@@ -1356,7 +1352,6 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
m_wantNumOfAASamples,
m_window,
m_display,
- m_visualInfo,
(GLXFBConfig)m_fbconfig,
profile_mask,
4, minor,
@@ -1374,7 +1369,6 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
m_wantNumOfAASamples,
m_window,
m_display,
- m_visualInfo,
(GLXFBConfig)m_fbconfig,
profile_mask,
3, 3,
diff --git a/intern/guardedalloc/MEM_guardedalloc.h b/intern/guardedalloc/MEM_guardedalloc.h
index 05a98c1a4e5..f6048a04cf3 100644
--- a/intern/guardedalloc/MEM_guardedalloc.h
+++ b/intern/guardedalloc/MEM_guardedalloc.h
@@ -225,7 +225,7 @@ public: \
MEM_freeN(mem); \
} \
-#if defined __GNUC__ || defined __sun
+#if defined __GNUC__
# define OBJECT_GUARDED_NEW(type, args ...) \
new(MEM_mallocN(sizeof(type), __func__)) type(args)
#else
diff --git a/intern/guardedalloc/intern/mallocn_lockfree_impl.c b/intern/guardedalloc/intern/mallocn_lockfree_impl.c
index b4838cdca18..66573b91ace 100644
--- a/intern/guardedalloc/intern/mallocn_lockfree_impl.c
+++ b/intern/guardedalloc/intern/mallocn_lockfree_impl.c
@@ -76,12 +76,7 @@ enum {
MEM_INLINE void update_maximum(size_t *maximum_value, size_t value)
{
#ifdef USE_ATOMIC_MAX
- size_t prev_value = *maximum_value;
- while (prev_value < value) {
- if (atomic_cas_z(maximum_value, prev_value, value) != prev_value) {
- break;
- }
- }
+ atomic_fetch_and_update_max_z(maximum_value, value);
#else
*maximum_value = value > *maximum_value ? value : *maximum_value;
#endif
diff --git a/intern/itasc/FixedObject.hpp b/intern/itasc/FixedObject.hpp
index ad26e7cb2d6..e768157ed2b 100644
--- a/intern/itasc/FixedObject.hpp
+++ b/intern/itasc/FixedObject.hpp
@@ -21,7 +21,7 @@ public:
int addFrame(const std::string& name, const Frame& frame);
- virtual void updateCoordinates(const Timestamp& timestamp) {};
+ virtual void updateCoordinates(const struct EvaluationContext *eval_ctx, const Timestamp& timestamp) {};
virtual int addEndEffector(const std::string& name);
virtual bool finalize();
virtual const Frame& getPose(const unsigned int frameIndex);
diff --git a/intern/itasc/MovingFrame.cpp b/intern/itasc/MovingFrame.cpp
index 90ebe091eb5..83e15bb59d9 100644
--- a/intern/itasc/MovingFrame.cpp
+++ b/intern/itasc/MovingFrame.cpp
@@ -90,7 +90,7 @@ bool MovingFrame::setCallback(MovingFrameCallback _function, void* _param)
return true;
}
-void MovingFrame::updateCoordinates(const Timestamp& timestamp)
+void MovingFrame::updateCoordinates(const struct EvaluationContext *eval_ctx, const Timestamp& timestamp)
{
// don't compute the velocity during substepping, it is assumed constant.
if (!timestamp.substep) {
@@ -98,7 +98,7 @@ void MovingFrame::updateCoordinates(const Timestamp& timestamp)
if (!timestamp.reiterate) {
cacheAvail = popInternalFrame(timestamp.cacheTimestamp);
if (m_function)
- (*m_function)(timestamp, m_internalPose, m_nextPose, m_param);
+ (*m_function)(eval_ctx, timestamp, m_internalPose, m_nextPose, m_param);
}
// only compute velocity if we have a previous pose
if (cacheAvail && timestamp.interpolate) {
diff --git a/intern/itasc/MovingFrame.hpp b/intern/itasc/MovingFrame.hpp
index d2a956d7312..719e06b4bf7 100644
--- a/intern/itasc/MovingFrame.hpp
+++ b/intern/itasc/MovingFrame.hpp
@@ -11,10 +11,16 @@
#include "UncontrolledObject.hpp"
#include <vector>
+struct EvaluationContext;
namespace iTaSC{
-typedef bool (*MovingFrameCallback)(const Timestamp& timestamp, const Frame& _current, Frame& _next, void *param);
+typedef bool (*MovingFrameCallback)(
+ const struct EvaluationContext *eval_ctx,
+ const Timestamp& timestamp,
+ const Frame& _current,
+ Frame& _next,
+ void *param);
class MovingFrame: public UncontrolledObject {
public:
@@ -24,7 +30,7 @@ public:
bool setFrame(const Frame& frame);
bool setCallback(MovingFrameCallback _function, void* _param);
- virtual void updateCoordinates(const Timestamp& timestamp);
+ virtual void updateCoordinates(const struct EvaluationContext *eval_ctx, const Timestamp& timestamp);
virtual void updateKinematics(const Timestamp& timestamp);
virtual void pushCache(const Timestamp& timestamp);
virtual void initCache(Cache *_cache);
diff --git a/intern/itasc/Scene.cpp b/intern/itasc/Scene.cpp
index 5768a994970..93f316783ba 100644
--- a/intern/itasc/Scene.cpp
+++ b/intern/itasc/Scene.cpp
@@ -257,7 +257,7 @@ bool Scene::getConstraintPose(ConstraintSet* constraint, void *_param, KDL::Fram
return true;
}
-bool Scene::update(double timestamp, double timestep, unsigned int numsubstep, bool reiterate, bool cache, bool interpolate)
+bool Scene::update(const struct EvaluationContext *eval_ctx, double timestamp, double timestep, unsigned int numsubstep, bool reiterate, bool cache, bool interpolate)
{
// we must have valid timestep and timestamp
if (timestamp < KDL::epsilon || timestep < 0.0)
@@ -316,7 +316,7 @@ bool Scene::update(double timestamp, double timestep, unsigned int numsubstep, b
}
}
if (os->object->getType()==Object::UnControlled && ((UncontrolledObject*)os->object)->getNrOfCoordinates() != 0) {
- ((UncontrolledObject*)(os->object))->updateCoordinates(ts);
+ ((UncontrolledObject*)(os->object))->updateCoordinates(eval_ctx, ts);
if (!ts.substep) {
// velocity of uncontrolled object remains constant during substepping
project(m_xdot,os->coordinaterange) = ((UncontrolledObject*)(os->object))->getXudot();
diff --git a/intern/itasc/Scene.hpp b/intern/itasc/Scene.hpp
index 5ed031b543e..ebbec561a6e 100644
--- a/intern/itasc/Scene.hpp
+++ b/intern/itasc/Scene.hpp
@@ -39,7 +39,7 @@ public:
bool addSolver(Solver* _solver);
bool addCache(Cache* _cache);
bool initialize();
- bool update(double timestamp, double timestep, unsigned int numsubstep=1, bool reiterate=false, bool cache=true, bool interpolate=true);
+ bool update(const struct EvaluationContext *eval_ctx, double timestamp, double timestep, unsigned int numsubstep=1, bool reiterate=false, bool cache=true, bool interpolate=true);
bool setParam(SceneParam paramId, double value);
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
diff --git a/intern/itasc/UncontrolledObject.hpp b/intern/itasc/UncontrolledObject.hpp
index 81445538fa6..d932974a24d 100644
--- a/intern/itasc/UncontrolledObject.hpp
+++ b/intern/itasc/UncontrolledObject.hpp
@@ -11,6 +11,9 @@
#include "eigen_types.hpp"
#include "Object.hpp"
+
+struct EvaluationContext;
+
namespace iTaSC{
class UncontrolledObject: public Object {
@@ -26,7 +29,7 @@ public:
virtual void initialize(unsigned int _nu, unsigned int _nf);
virtual const e_matrix& getJu(unsigned int frameIndex) const;
virtual const e_vector& getXudot() const {return m_xudot;}
- virtual void updateCoordinates(const Timestamp& timestamp)=0;
+ virtual void updateCoordinates(const struct EvaluationContext *eval_ctx, const Timestamp& timestamp)=0;
virtual const unsigned int getNrOfCoordinates(){return m_nu;};
virtual const unsigned int getNrOfFrames(){return m_nf;};
diff --git a/intern/itasc/WorldObject.hpp b/intern/itasc/WorldObject.hpp
index 99756dcd684..9876090e128 100644
--- a/intern/itasc/WorldObject.hpp
+++ b/intern/itasc/WorldObject.hpp
@@ -16,7 +16,7 @@ public:
WorldObject();
virtual ~WorldObject();
- virtual void updateCoordinates(const Timestamp& timestamp) {};
+ virtual void updateCoordinates(const struct EvaluationContext *eval_ctx, const Timestamp& timestamp) {};
virtual void updateKinematics(const Timestamp& timestamp) {};
virtual void pushCache(const Timestamp& timestamp) {};
virtual void initCache(Cache *_cache) {};
diff --git a/intern/itasc/kdl/tree.hpp b/intern/itasc/kdl/tree.hpp
index c8a253fc901..bd35f82d185 100644
--- a/intern/itasc/kdl/tree.hpp
+++ b/intern/itasc/kdl/tree.hpp
@@ -34,7 +34,7 @@ namespace KDL
//Forward declaration
class TreeElement;
// 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;
+ typedef std::map<std::string,TreeElement, std::less<std::string>, Eigen::aligned_allocator<std::pair<const std::string, TreeElement> > > SegmentMap;
class TreeElement
{
diff --git a/intern/libmv/intern/track_region.cc b/intern/libmv/intern/track_region.cc
index d395b6457d7..8989897e09f 100644
--- a/intern/libmv/intern/track_region.cc
+++ b/intern/libmv/intern/track_region.cc
@@ -36,7 +36,7 @@
/* define this to generate PNG images with content of search areas
on every itteration of tracking */
-#define DUMP_ALWAYS
+#undef DUMP_ALWAYS
using libmv::FloatImage;
using libmv::TrackRegionOptions;
diff --git a/intern/mikktspace/mikktspace.c b/intern/mikktspace/mikktspace.c
index 0342ae0146f..f832b356ffe 100644
--- a/intern/mikktspace/mikktspace.c
+++ b/intern/mikktspace/mikktspace.c
@@ -39,17 +39,23 @@
#define INTERNAL_RND_SORT_SEED 39871946
+#ifdef _MSC_VER
+# define MIKK_INLINE static __forceinline
+#else
+# define MIKK_INLINE static inline __attribute__((always_inline)) __attribute__((unused))
+#endif
+
// internal structure
typedef struct {
float x, y, z;
} SVec3;
-static tbool veq( const SVec3 v1, const SVec3 v2 )
+MIKK_INLINE tbool veq( const SVec3 v1, const SVec3 v2 )
{
return (v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z);
}
-static SVec3 vadd( const SVec3 v1, const SVec3 v2 )
+MIKK_INLINE SVec3 vadd( const SVec3 v1, const SVec3 v2 )
{
SVec3 vRes;
@@ -61,7 +67,7 @@ static SVec3 vadd( const SVec3 v1, const SVec3 v2 )
}
-static SVec3 vsub( const SVec3 v1, const SVec3 v2 )
+MIKK_INLINE SVec3 vsub( const SVec3 v1, const SVec3 v2 )
{
SVec3 vRes;
@@ -72,7 +78,7 @@ static SVec3 vsub( const SVec3 v1, const SVec3 v2 )
return vRes;
}
-static SVec3 vscale(const float fS, const SVec3 v)
+MIKK_INLINE SVec3 vscale(const float fS, const SVec3 v)
{
SVec3 vRes;
@@ -83,39 +89,54 @@ static SVec3 vscale(const float fS, const SVec3 v)
return vRes;
}
-static float LengthSquared( const SVec3 v )
+MIKK_INLINE float LengthSquared( const SVec3 v )
{
return v.x*v.x + v.y*v.y + v.z*v.z;
}
-static float Length( const SVec3 v )
+MIKK_INLINE float Length( const SVec3 v )
{
return sqrtf(LengthSquared(v));
}
-static SVec3 Normalize( const SVec3 v )
+#if 0 // UNUSED
+MIKK_INLINE SVec3 Normalize( const SVec3 v )
+{
+ return vscale(1.0f / Length(v), v);
+}
+#endif
+
+MIKK_INLINE SVec3 NormalizeSafe( const SVec3 v )
{
- return vscale(1 / Length(v), v);
+ const float len = Length(v);
+ if (len != 0.0f) {
+ return vscale(1.0f / len, v);
+ }
+ else
+ {
+ return v;
+ }
}
-static float vdot( const SVec3 v1, const SVec3 v2)
+MIKK_INLINE float vdot( const SVec3 v1, const SVec3 v2)
{
return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
}
-static tbool NotZero(const float fX)
+MIKK_INLINE tbool NotZero(const float fX)
{
// could possibly use FLT_EPSILON instead
return fabsf(fX) > FLT_MIN;
}
-static tbool VNotZero(const SVec3 v)
+#if 0 // UNUSED
+MIKK_INLINE tbool VNotZero(const SVec3 v)
{
// might change this to an epsilon based test
return NotZero(v.x) || NotZero(v.y) || NotZero(v.z);
}
-
+#endif
typedef struct {
@@ -169,13 +190,13 @@ static tbool GenerateTSpaces(STSpace psTspace[], const STriInfo pTriInfos[], con
const int iNrActiveGroups, const int piTriListIn[], const float fThresCos,
const SMikkTSpaceContext * pContext);
-static int MakeIndex(const int iFace, const int iVert)
+MIKK_INLINE int MakeIndex(const int iFace, const int iVert)
{
assert(iVert>=0 && iVert<4 && iFace>=0);
return (iFace<<2) | (iVert&0x3);
}
-static void IndexToData(int * piFace, int * piVert, const int iIndexIn)
+MIKK_INLINE void IndexToData(int * piFace, int * piVert, const int iIndexIn)
{
piVert[0] = iIndexIn&0x3;
piFace[0] = iIndexIn>>2;
@@ -202,8 +223,8 @@ static STSpace AvgTSpace(const STSpace * pTS0, const STSpace * pTS1)
ts_res.fMagT = 0.5f*(pTS0->fMagT+pTS1->fMagT);
ts_res.vOs = vadd(pTS0->vOs,pTS1->vOs);
ts_res.vOt = vadd(pTS0->vOt,pTS1->vOt);
- if ( VNotZero(ts_res.vOs) ) ts_res.vOs = Normalize(ts_res.vOs);
- if ( VNotZero(ts_res.vOt) ) ts_res.vOt = Normalize(ts_res.vOt);
+ ts_res.vOs = NormalizeSafe(ts_res.vOs);
+ ts_res.vOt = NormalizeSafe(ts_res.vOt);
}
return ts_res;
@@ -211,9 +232,9 @@ static STSpace AvgTSpace(const STSpace * pTS0, const STSpace * pTS1)
-static SVec3 GetPosition(const SMikkTSpaceContext * pContext, const int index);
-static SVec3 GetNormal(const SMikkTSpaceContext * pContext, const int index);
-static SVec3 GetTexCoord(const SMikkTSpaceContext * pContext, const int index);
+MIKK_INLINE SVec3 GetPosition(const SMikkTSpaceContext * pContext, const int index);
+MIKK_INLINE SVec3 GetNormal(const SMikkTSpaceContext * pContext, const int index);
+MIKK_INLINE SVec3 GetTexCoord(const SMikkTSpaceContext * pContext, const int index);
// degen triangles
@@ -238,7 +259,7 @@ tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThre
int iNrActiveGroups = 0, index = 0;
const int iNrFaces = pContext->m_pInterface->m_getNumFaces(pContext);
tbool bRes = TFALSE;
- const float fThresCos = (float) cos((fAngularThreshold*(float)M_PI)/180.0f);
+ const float fThresCos = cosf((fAngularThreshold*(float)M_PI)/180.0f);
// verify all call-backs have been set
if ( pContext->m_pInterface->m_getNumFaces==NULL ||
@@ -258,7 +279,7 @@ tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThre
if (iNrTrianglesIn<=0) return TFALSE;
// allocate memory for an index list
- piTriListIn = (int *) malloc(sizeof(int)*3*iNrTrianglesIn);
+ piTriListIn = (int *) malloc(sizeof(int[3])*iNrTrianglesIn);
pTriInfos = (STriInfo *) malloc(sizeof(STriInfo)*iNrTrianglesIn);
if (piTriListIn==NULL || pTriInfos==NULL)
{
@@ -311,7 +332,7 @@ tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThre
// based on the 4 rules, identify groups based on connectivity
iNrMaxGroups = iNrTrianglesIn*3;
pGroups = (SGroup *) malloc(sizeof(SGroup)*iNrMaxGroups);
- piGroupTrianglesBuffer = (int *) malloc(sizeof(int)*iNrTrianglesIn*3);
+ piGroupTrianglesBuffer = (int *) malloc(sizeof(int[3])*iNrTrianglesIn);
if (pGroups==NULL || piGroupTrianglesBuffer==NULL)
{
if (pGroups!=NULL) free(pGroups);
@@ -427,6 +448,7 @@ typedef struct {
} STmpVert;
static const int g_iCells = 2048;
+static const float g_iCells_fl = 2048.0f;
#ifdef _MSC_VER
# define NOINLINE __declspec(noinline)
@@ -439,7 +461,7 @@ static const int g_iCells = 2048;
// results for the same effective input value fVal.
static NOINLINE int FindGridCell(const float fMin, const float fMax, const float fVal)
{
- const float fIndex = g_iCells * ((fVal-fMin)/(fMax-fMin));
+ const float fIndex = g_iCells_fl * ((fVal-fMin)/(fMax-fMin));
const int iIndex = (int)fIndex;
return iIndex < g_iCells ? (iIndex >= 0 ? iIndex : 0) : (g_iCells - 1);
}
@@ -488,7 +510,7 @@ static void GenerateSharedVerticesIndexList(int piTriList_in_and_out[], const SM
}
// make allocations
- piHashTable = (int *) malloc(sizeof(int)*iNrTrianglesIn*3);
+ piHashTable = (int *) malloc(sizeof(int[3])*iNrTrianglesIn);
piHashCount = (int *) malloc(sizeof(int)*g_iCells);
piHashOffsets = (int *) malloc(sizeof(int)*g_iCells);
piHashCount2 = (int *) malloc(sizeof(int)*g_iCells);
@@ -544,7 +566,7 @@ static void GenerateSharedVerticesIndexList(int piTriList_in_and_out[], const SM
if (iMaxCount<piHashCount[k])
iMaxCount=piHashCount[k];
pTmpVert = (STmpVert *) malloc(sizeof(STmpVert)*iMaxCount);
-
+
// complete the merge
for (k=0; k<g_iCells; k++)
@@ -880,7 +902,7 @@ static int GenerateInitialVerticesIndexList(STriInfo pTriInfos[], int piTriList_
return iTSpacesOffs;
}
-static SVec3 GetPosition(const SMikkTSpaceContext * pContext, const int index)
+MIKK_INLINE SVec3 GetPosition(const SMikkTSpaceContext * pContext, const int index)
{
int iF, iI;
SVec3 res; float pos[3];
@@ -890,7 +912,7 @@ static SVec3 GetPosition(const SMikkTSpaceContext * pContext, const int index)
return res;
}
-static SVec3 GetNormal(const SMikkTSpaceContext * pContext, const int index)
+MIKK_INLINE SVec3 GetNormal(const SMikkTSpaceContext * pContext, const int index)
{
int iF, iI;
SVec3 res; float norm[3];
@@ -900,7 +922,7 @@ static SVec3 GetNormal(const SMikkTSpaceContext * pContext, const int index)
return res;
}
-static SVec3 GetTexCoord(const SMikkTSpaceContext * pContext, const int index)
+MIKK_INLINE SVec3 GetTexCoord(const SMikkTSpaceContext * pContext, const int index)
{
int iF, iI;
SVec3 res; float texc[2];
@@ -1048,7 +1070,7 @@ static void InitTriInfo(STriInfo pTriInfos[], const int piTriListIn[], const SMi
// match up edge pairs
{
- SEdge * pEdges = (SEdge *) malloc(sizeof(SEdge)*iNrTrianglesIn*3);
+ SEdge * pEdges = (SEdge *) malloc(sizeof(SEdge[3])*iNrTrianglesIn);
if (pEdges==NULL)
BuildNeighborsSlow(pTriInfos, piTriListIn, iNrTrianglesIn);
else
@@ -1064,7 +1086,7 @@ static void InitTriInfo(STriInfo pTriInfos[], const int piTriListIn[], const SMi
/////////////////////////////////////////////////////////////////////////////////////////////////////
static tbool AssignRecur(const int piTriListIn[], STriInfo psTriInfos[], const int iMyTriIndex, SGroup * pGroup);
-static void AddTriToGroup(SGroup * pGroup, const int iTriIndex);
+MIKK_INLINE void AddTriToGroup(SGroup * pGroup, const int iTriIndex);
static int Build4RuleGroups(STriInfo pTriInfos[], SGroup pGroups[], int piGroupTrianglesBuffer[], const int piTriListIn[], const int iNrTrianglesIn)
{
@@ -1130,7 +1152,7 @@ static int Build4RuleGroups(STriInfo pTriInfos[], SGroup pGroups[], int piGroupT
return iNrActiveGroups;
}
-static void AddTriToGroup(SGroup * pGroup, const int iTriIndex)
+MIKK_INLINE void AddTriToGroup(SGroup * pGroup, const int iTriIndex)
{
pGroup->pFaceIndices[pGroup->iNrFaces] = iTriIndex;
++pGroup->iNrFaces;
@@ -1247,10 +1269,8 @@ static tbool GenerateTSpaces(STSpace psTspace[], const STriInfo pTriInfos[], con
n = GetNormal(pContext, iVertIndex);
// project
- vOs = vsub(pTriInfos[f].vOs, vscale(vdot(n,pTriInfos[f].vOs), n));
- vOt = vsub(pTriInfos[f].vOt, vscale(vdot(n,pTriInfos[f].vOt), n));
- if ( VNotZero(vOs) ) vOs = Normalize(vOs);
- if ( VNotZero(vOt) ) vOt = Normalize(vOt);
+ vOs = NormalizeSafe(vsub(pTriInfos[f].vOs, vscale(vdot(n,pTriInfos[f].vOs), n)));
+ vOt = NormalizeSafe(vsub(pTriInfos[f].vOt, vscale(vdot(n,pTriInfos[f].vOt), n)));
// original face number
iOF_1 = pTriInfos[f].iOrgFaceNumber;
@@ -1262,10 +1282,8 @@ static tbool GenerateTSpaces(STSpace psTspace[], const STriInfo pTriInfos[], con
const int iOF_2 = pTriInfos[t].iOrgFaceNumber;
// project
- SVec3 vOs2 = vsub(pTriInfos[t].vOs, vscale(vdot(n,pTriInfos[t].vOs), n));
- SVec3 vOt2 = vsub(pTriInfos[t].vOt, vscale(vdot(n,pTriInfos[t].vOt), n));
- if ( VNotZero(vOs2) ) vOs2 = Normalize(vOs2);
- if ( VNotZero(vOt2) ) vOt2 = Normalize(vOt2);
+ SVec3 vOs2 = NormalizeSafe(vsub(pTriInfos[t].vOs, vscale(vdot(n,pTriInfos[t].vOs), n)));
+ SVec3 vOt2 = NormalizeSafe(vsub(pTriInfos[t].vOt, vscale(vdot(n,pTriInfos[t].vOt), n)));
{
const tbool bAny = ( (pTriInfos[f].iFlag | pTriInfos[t].iFlag) & GROUP_WITH_ANY )!=0 ? TTRUE : TFALSE;
@@ -1321,7 +1339,7 @@ static tbool GenerateTSpaces(STSpace psTspace[], const STriInfo pTriInfos[], con
}
pUniSubGroups[iUniqueSubGroups].iNrFaces = iMembers;
pUniSubGroups[iUniqueSubGroups].pTriMembers = pIndices;
- memcpy(pIndices, tmp_group.pTriMembers, iMembers*sizeof(int));
+ memcpy(pIndices, tmp_group.pTriMembers, sizeof(int)*iMembers);
pSubGroupTspace[iUniqueSubGroups] =
EvalTspace(tmp_group.pTriMembers, iMembers, piTriListIn, pTriInfos, pContext, pGroup->iVertexRepresentitive);
++iUniqueSubGroups;
@@ -1392,10 +1410,8 @@ static STSpace EvalTspace(int face_indices[], const int iFaces, const int piTriL
// project
index = piTriListIn[3*f+i];
n = GetNormal(pContext, index);
- vOs = vsub(pTriInfos[f].vOs, vscale(vdot(n,pTriInfos[f].vOs), n));
- vOt = vsub(pTriInfos[f].vOt, vscale(vdot(n,pTriInfos[f].vOt), n));
- if ( VNotZero(vOs) ) vOs = Normalize(vOs);
- if ( VNotZero(vOt) ) vOt = Normalize(vOt);
+ vOs = NormalizeSafe(vsub(pTriInfos[f].vOs, vscale(vdot(n,pTriInfos[f].vOs), n)));
+ vOt = NormalizeSafe(vsub(pTriInfos[f].vOt, vscale(vdot(n,pTriInfos[f].vOt), n)));
i2 = piTriListIn[3*f + (i<2?(i+1):0)];
i1 = piTriListIn[3*f + i];
@@ -1408,8 +1424,8 @@ static STSpace EvalTspace(int face_indices[], const int iFaces, const int piTriL
v2 = vsub(p2,p1);
// project
- v1 = vsub(v1, vscale(vdot(n,v1),n)); if ( VNotZero(v1) ) v1 = Normalize(v1);
- v2 = vsub(v2, vscale(vdot(n,v2),n)); if ( VNotZero(v2) ) v2 = Normalize(v2);
+ v1 = NormalizeSafe(vsub(v1, vscale(vdot(n,v1),n)));
+ v2 = NormalizeSafe(vsub(v2, vscale(vdot(n,v2),n)));
// weight contribution by the angle
// between the two edge vectors
@@ -1427,8 +1443,8 @@ static STSpace EvalTspace(int face_indices[], const int iFaces, const int piTriL
}
// normalize
- if ( VNotZero(res.vOs) ) res.vOs = Normalize(res.vOs);
- if ( VNotZero(res.vOt) ) res.vOt = Normalize(res.vOt);
+ res.vOs = NormalizeSafe(res.vOs);
+ res.vOt = NormalizeSafe(res.vOt);
if (fAngleSum>0)
{
res.fMagS /= fAngleSum;
@@ -1464,7 +1480,7 @@ static void QuickSort(int* pSortBuffer, int iLeft, int iRight, unsigned int uSee
iL=iLeft; iR=iRight;
n = (iR-iL)+1;
assert(n>=0);
- index = (int) (uSeed%n);
+ index = (int) (uSeed%(unsigned int)n);
iMid=pSortBuffer[index + iL];
@@ -1661,6 +1677,20 @@ static void QuickSortEdges(SEdge * pSortBuffer, int iLeft, int iRight, const int
}
return;
}
+ else if(iElems < 16) {
+ int i, j;
+ for (i = 0; i < iElems - 1; i++) {
+ for (j = 0; j < iElems - i - 1; j++) {
+ int index = iLeft + j;
+ if (pSortBuffer[index].array[channel] > pSortBuffer[index + 1].array[channel]) {
+ sTmp = pSortBuffer[index];
+ pSortBuffer[index] = pSortBuffer[index + 1];
+ pSortBuffer[index + 1] = sTmp;
+ }
+ }
+ }
+ return;
+ }
// Random
t=uSeed&31;
@@ -1672,7 +1702,7 @@ static void QuickSortEdges(SEdge * pSortBuffer, int iLeft, int iRight, const int
iR = iRight;
n = (iR-iL)+1;
assert(n>=0);
- index = (int) (uSeed%n);
+ index = (int) (uSeed%(unsigned int)n);
iMid=pSortBuffer[index + iL].array[channel];
@@ -1817,47 +1847,134 @@ static void DegenPrologue(STriInfo pTriInfos[], int piTriList_out[], const int i
assert(iNrTrianglesIn == t);
}
-static void DegenEpilogue(STSpace psTspace[], STriInfo pTriInfos[], int piTriListIn[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn, const int iTotTris)
+typedef struct VertReverseLookupContext {
+ tbool bIsInitialized;
+ int * pLookup;
+ int iMaxVertIndex;
+} VertReverseLookupContext;
+
+static void GenerateReverseLookup(
+ const int piTriListIn[],
+ const int iNrTrianglesIn,
+ VertReverseLookupContext *pLookupCtx)
+{
+ int t;
+ // Figure out what size of lookup array we need.
+ pLookupCtx->iMaxVertIndex = -1;
+ for (t=0; t<3*iNrTrianglesIn; t++)
+ {
+ int iVertIndex = piTriListIn[t];
+ if (iVertIndex > pLookupCtx->iMaxVertIndex) {
+ pLookupCtx->iMaxVertIndex = iVertIndex;
+ }
+ }
+ // Allocate memory.
+ if (pLookupCtx->iMaxVertIndex < 1)
+ {
+ // Nothing to allocate, all triangles are degenerate.
+ return;
+ }
+ pLookupCtx->pLookup = malloc(sizeof(int) * (pLookupCtx->iMaxVertIndex + 1));
+ if (pLookupCtx->pLookup == NULL)
+ {
+ // Most likely run out of memory.
+ return;
+ }
+ // Fill in lookup.
+ for (t=0; t<=pLookupCtx->iMaxVertIndex; t++) {
+ pLookupCtx->pLookup[t] = -1;
+ }
+ for (t=0; t<3*iNrTrianglesIn; t++)
+ {
+ int iVertIndex = piTriListIn[t];
+ if (pLookupCtx->pLookup[iVertIndex] != -1)
+ {
+ continue;
+ }
+ pLookupCtx->pLookup[iVertIndex] = t;
+ }
+}
+
+static int LookupVertexIndexFromGoodTriangle(
+ VertReverseLookupContext *pLookupCtx,
+ int piTriListIn[],
+ const int iNrTrianglesIn,
+ const int iVertexIndex)
+{
+ // Allocate lookup on demand.
+ if (!pLookupCtx->bIsInitialized)
+ {
+ GenerateReverseLookup(piTriListIn,
+ iNrTrianglesIn,
+ pLookupCtx);
+ pLookupCtx->bIsInitialized = TTRUE;
+ }
+ // Make sure vertex index is in the mapping.
+ if (iVertexIndex > pLookupCtx->iMaxVertIndex)
+ {
+ return -1;
+ }
+ if (pLookupCtx->pLookup == NULL) {
+ return -1;
+ }
+ // Perform actual lookup.
+ return pLookupCtx->pLookup[iVertexIndex];
+}
+
+static void FreeReverseLookup(VertReverseLookupContext *pLookupCtx)
+{
+ if (!pLookupCtx->bIsInitialized) {
+ return;
+ }
+ if (pLookupCtx->pLookup != NULL) {
+ free(pLookupCtx->pLookup);
+ }
+}
+
+static void DegenEpilogue(STSpace psTspace[],
+ STriInfo pTriInfos[],
+ int piTriListIn[],
+ const SMikkTSpaceContext * pContext,
+ const int iNrTrianglesIn,
+ const int iTotTris)
{
int t=0, i=0;
+ VertReverseLookupContext lookupCtx = { TFALSE };
// deal with degenerate triangles
- // punishment for degenerate triangles is O(N^2)
+ // punishment for degenerate triangles is O(iNrTrianglesIn) extra memory.
for (t=iNrTrianglesIn; t<iTotTris; t++)
{
// degenerate triangles on a quad with one good triangle are skipped
// here but processed in the next loop
const tbool bSkip = (pTriInfos[t].iFlag&QUAD_ONE_DEGEN_TRI)!=0 ? TTRUE : TFALSE;
+ if (bSkip) {
+ continue;
+ }
- if (!bSkip)
+ for (i=0; i<3; i++)
{
- for (i=0; i<3; i++)
+ const int index1 = piTriListIn[t*3+i];
+ int j = LookupVertexIndexFromGoodTriangle(&lookupCtx,
+ piTriListIn,
+ iNrTrianglesIn,
+ index1);
+ if (j < 0)
{
- const int index1 = piTriListIn[t*3+i];
- // search through the good triangles
- tbool bNotFound = TTRUE;
- int j=0;
- while (bNotFound && j<(3*iNrTrianglesIn))
- {
- const int index2 = piTriListIn[j];
- if (index1==index2) bNotFound=TFALSE;
- else ++j;
- }
-
- if (!bNotFound)
- {
- const int iTri = j/3;
- const int iVert = j%3;
- const int iSrcVert=pTriInfos[iTri].vert_num[iVert];
- const int iSrcOffs=pTriInfos[iTri].iTSpacesOffs;
- const int iDstVert=pTriInfos[t].vert_num[i];
- const int iDstOffs=pTriInfos[t].iTSpacesOffs;
-
- // copy tspace
- psTspace[iDstOffs+iDstVert] = psTspace[iSrcOffs+iSrcVert];
- }
+ // Matching vertex from good triangle is not found.
+ continue;
}
+
+ const int iTri = j/3;
+ const int iVert = j%3;
+ const int iSrcVert=pTriInfos[iTri].vert_num[iVert];
+ const int iSrcOffs=pTriInfos[iTri].iTSpacesOffs;
+ const int iDstVert=pTriInfos[t].vert_num[i];
+ const int iDstOffs=pTriInfos[t].iTSpacesOffs;
+ // copy tspace
+ psTspace[iDstOffs+iDstVert] = psTspace[iSrcOffs+iSrcVert];
}
}
+ FreeReverseLookup(&lookupCtx);
// deal with degenerate quads with one good triangle
for (t=0; t<iNrTrianglesIn; t++)
diff --git a/intern/opencolorio/gpu_shader_display_transform.glsl b/intern/opencolorio/gpu_shader_display_transform.glsl
index 372d41dfecb..f1dca04b823 100644
--- a/intern/opencolorio/gpu_shader_display_transform.glsl
+++ b/intern/opencolorio/gpu_shader_display_transform.glsl
@@ -5,14 +5,8 @@ uniform sampler3D lut3d_texture;
uniform float dither;
#endif
-#ifdef USE_TEXTURE_SIZE
-uniform float image_texture_width;
-uniform float image_texture_height;
-#endif
-
in vec2 texCoord_interp;
out vec4 fragColor;
-#define texture2D texture
#ifdef USE_CURVE_MAPPING
/* Curve mapping parameters
@@ -42,7 +36,7 @@ float read_curve_mapping(int table, int index)
* But is it actually correct to subtract 1 here?
*/
float texture_index = float(index) / float(curve_mapping_lut_size - 1);
- return texture1D(curve_mapping_texture, texture_index)[table];
+ return texture(curve_mapping_texture, texture_index)[table];
}
float curvemap_calc_extend(int table, float x, vec2 first, vec2 last)
@@ -123,11 +117,7 @@ float dither_random_value(vec2 co)
vec2 round_to_pixel(vec2 st)
{
vec2 result;
-#ifdef USE_TEXTURE_SIZE
- vec2 size = vec2(image_texture_width, image_texture_height);
-#else
vec2 size = textureSize(image_texture, 0);
-#endif
result.x = float(int(st.x * size.x)) / size.x;
result.y = float(int(st.y * size.y)) / size.y;
return result;
@@ -147,7 +137,7 @@ vec4 apply_dither(vec2 st, vec4 col)
void main()
{
- vec4 col = texture2D(image_texture, texCoord_interp.st);
+ vec4 col = texture(image_texture, texCoord_interp.st);
#ifdef USE_CURVE_MAPPING
col = curvemapping_evaluate_premulRGBF(col);
#endif
diff --git a/intern/opencolorio/ocio_impl_glsl.cc b/intern/opencolorio/ocio_impl_glsl.cc
index b89221c36da..08f3c15eb95 100644
--- a/intern/opencolorio/ocio_impl_glsl.cc
+++ b/intern/opencolorio/ocio_impl_glsl.cc
@@ -49,7 +49,7 @@
#endif
extern "C" {
-#include "gawain/immediate.h"
+#include "gawain/gwn_immediate.h"
}
using namespace OCIO_NAMESPACE;
@@ -85,8 +85,6 @@ typedef struct OCIO_GLSLDrawState {
bool predivide_used;
- bool texture_size_used;
-
/* Cache */
std::string lut3dcacheid;
std::string shadercacheid;
@@ -240,17 +238,6 @@ bool OCIOImpl::supportGLSLDraw()
return GLEW_VERSION_3_0 || GLEW_ARB_texture_float;
}
-static bool supportGLSL13()
-{
- const char *version = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION);
- int major = 1, minor = 0;
-
- if (version && sscanf(version, "%d.%d", &major, &minor) == 2)
- return (major > 1 || (major == 1 && minor >= 30));
-
- return false;
-}
-
/**
* Setup OpenGL contexts for a transform defined by processor using GLSL
* All LUT allocating baking and shader compilation happens here.
@@ -353,13 +340,7 @@ bool OCIOImpl::setupGLSLDraw(OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRc
/* Vertex shader */
std::ostringstream osv;
- if (supportGLSL13()) {
- osv << "#version 130\n";
- }
- else {
- osv << "#version 120\n";
- }
-
+ osv << "#version 330\n";
osv << datatoc_gpu_shader_display_transform_vertex_glsl;
state->vert_shader = compileShaderText(GL_VERTEX_SHADER, osv.str().c_str());
@@ -367,13 +348,11 @@ bool OCIOImpl::setupGLSLDraw(OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRc
/* Fragment shader */
std::ostringstream os;
- if (supportGLSL13()) {
- os << "#version 130\n";
- }
- else {
- os << "#define USE_TEXTURE_SIZE\n";
- state->texture_size_used = use_dither;
- }
+ os << "#version 330\n";
+
+ /* Work around OpenColorIO not supporting latest GLSL yet. */
+ os << "#define texture2D texture\n";
+ os << "#define texture3D texture\n";
if (use_predivide) {
os << "#define USE_PREDIVIDE\n";
@@ -397,6 +376,9 @@ bool OCIOImpl::setupGLSLDraw(OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRc
}
if (state->program) {
+ if (state->shader_interface) {
+ GWN_shaderinterface_discard(state->shader_interface);
+ }
state->shader_interface = GWN_shaderinterface_create(state->program);
}
@@ -432,18 +414,6 @@ bool OCIOImpl::setupGLSLDraw(OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRc
immUniform1i("image_texture", 0);
immUniform1i("lut3d_texture", 1);
- if (state->texture_size_used) {
- /* we use textureSize() if possible for best performance, if not
- * supported we query the size and pass it as uniform variables */
- GLint width, height;
-
- glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width);
- glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height);
-
- immUniform1f("image_texture_width", (float)width);
- immUniform1f("image_texture_height", (float)height);
- }
-
if (use_dither) {
immUniform1f("dither", dither);
}
diff --git a/intern/opensubdiv/opensubdiv_capi.cc b/intern/opensubdiv/opensubdiv_capi.cc
index aed5d4fbd14..bb865bc0e0f 100644
--- a/intern/opensubdiv/opensubdiv_capi.cc
+++ b/intern/opensubdiv/opensubdiv_capi.cc
@@ -75,6 +75,16 @@
#include "MEM_guardedalloc.h"
+#include <string>
+#include <vector>
+
+using std::string;
+using std::vector;
+
+#define STRINGIFY_ARG(x) "" #x
+#define STRINGIFY_APPEND(a, b) "" a #b
+#define STRINGIFY(x) STRINGIFY_APPEND("", x)
+
/* **************** Types declaration **************** */
using OpenSubdiv::Osd::GLMeshInterface;
@@ -147,6 +157,38 @@ typedef Mesh<GLVertexBuffer,
namespace {
+#if !defined(OPENSUBDIV_VERSION_NUMBER) && !defined(OPENSUBDIV_VERSION_MINOR)
+void stringSplit(vector<string>* tokens,
+ const string& str,
+ const string& separators,
+ bool skip_empty) {
+ size_t token_start = 0, token_length = 0;
+ for (size_t i = 0; i < str.length(); ++i) {
+ const char ch = str[i];
+ if (separators.find(ch) == string::npos) {
+ /* Append non-separator char to a token. */
+ ++token_length;
+ } else {
+ /* Append current token to the list (if any). */
+ if (token_length > 0 || !skip_empty) {
+ string token = str.substr(token_start, token_length);
+ tokens->push_back(token);
+ }
+ /* Re-set token pointers, */
+ token_start = i + 1;
+ token_length = 0;
+ }
+ }
+ /* Append token which might be at the end of the string. */
+ if ((token_length != 0) ||
+ (!skip_empty && token_start > 0 &&
+ separators.find(str[token_start-1]) != string::npos)) {
+ string token = str.substr(token_start, token_length);
+ tokens->push_back(token);
+ }
+}
+#endif
+
struct FVarVertex {
float u, v;
void Clear() {
@@ -372,5 +414,27 @@ const struct OpenSubdiv_TopologyRefinerDescr *openSubdiv_getGLMeshTopologyRefine
int openSubdiv_getVersionHex(void)
{
+#if defined(OPENSUBDIV_VERSION_NUMBER)
return OPENSUBDIV_VERSION_NUMBER;
+#elif defined(OPENSUBDIV_VERSION_MAJOR)
+ return OPENSUBDIV_VERSION_MAJOR * 10000 +
+ OPENSUBDIV_VERSION_MINOR * 100 +
+ OPENSUBDIV_VERSION_PATCH;
+#elif defined(OPENSUBDIV_VERSION)
+ const char* version = STRINGIFY(OPENSUBDIV_VERSION);
+ if (version[0] == 'v') {
+ version += 1;
+ }
+ int major = 0, minor = 0, patch = 0;
+ vector<string> tokens;
+ stringSplit(&tokens, version, "_", true);
+ if (tokens.size() == 3) {
+ major = atoi(tokens[0].c_str());
+ minor = atoi(tokens[1].c_str());
+ patch = atoi(tokens[2].c_str());
+ }
+ return major * 10000 + minor * 100 + patch;
+#else
+ return 0;
+#endif
}
diff --git a/intern/opensubdiv/opensubdiv_gpu_capi.cc b/intern/opensubdiv/opensubdiv_gpu_capi.cc
index 811cd18745e..7d8085c1ff5 100644
--- a/intern/opensubdiv/opensubdiv_gpu_capi.cc
+++ b/intern/opensubdiv/opensubdiv_gpu_capi.cc
@@ -616,7 +616,7 @@ static GLuint prepare_patchDraw(OpenSubdiv_GLMesh *gl_mesh,
if (fill_quads) {
int model;
- GLboolean use_texture_2d, use_lighting;
+ GLboolean use_texture_2d;
glGetIntegerv(GL_SHADE_MODEL, &model);
glGetBooleanv(GL_TEXTURE_2D, &use_texture_2d);
diff --git a/intern/openvdb/intern/openvdb_writer.cc b/intern/openvdb/intern/openvdb_writer.cc
index 923752909d9..e886c5a76a8 100644
--- a/intern/openvdb/intern/openvdb_writer.cc
+++ b/intern/openvdb/intern/openvdb_writer.cc
@@ -45,7 +45,11 @@ void OpenVDBWriter::insert(const openvdb::GridBase::Ptr &grid)
void OpenVDBWriter::insert(const openvdb::GridBase &grid)
{
+#if (OPENVDB_LIBRARY_MAJOR_VERSION_NUMBER == 3)
m_grids->push_back(grid.copyGrid());
+#else
+ m_grids->push_back(grid.copyGridWithNewTree());
+#endif
}
void OpenVDBWriter::insertFloatMeta(const openvdb::Name &name, const float value)
diff --git a/intern/string/intern/STR_String.cpp b/intern/string/intern/STR_String.cpp
index 4612c91b6a6..3ec65ddc725 100644
--- a/intern/string/intern/STR_String.cpp
+++ b/intern/string/intern/STR_String.cpp
@@ -37,9 +37,6 @@
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
-#if defined(__sun__) || defined(__sun) || defined(__sparc) || defined(__sparc__) || defined(_AIX)
-# include <strings.h>
-#endif
#include "STR_String.h"
/*-------------------------------------------------------------------------------------------------
diff --git a/make.bat b/make.bat
index 4abcd086cdf..0a398c5b2b7 100644
--- a/make.bat
+++ b/make.bat
@@ -5,6 +5,7 @@ setlocal EnableDelayedExpansion
setlocal ENABLEEXTENSIONS
set BLENDER_DIR=%~dp0
set BLENDER_DIR_NOSPACES=%BLENDER_DIR: =%
+for %%X in (svn.exe) do (set HAS_SVN=%%~$PATH:X)
if not "%BLENDER_DIR%"=="%BLENDER_DIR_NOSPACES%" (
echo There are spaces detected in the build path "%BLENDER_DIR%", this is currently not supported, exiting....
goto EOF
@@ -17,6 +18,9 @@ set BUILD_CMAKE_ARGS=
set BUILD_ARCH=
set BUILD_VS_VER=
set BUILD_VS_YEAR=
+set BUILD_VS_LIBDIRPOST=
+set BUILD_VS_LIBDIR=
+set BUILD_VS_SVNDIR=
set BUILD_NGE=
set KEY_NAME=
set MSBUILD_PLATFORM=
@@ -67,25 +71,28 @@ if NOT "%1" == "" (
-C"%BLENDER_DIR%\build_files\cmake\config\bpy_module.cmake"
) else if "%1" == "release" (
set TARGET=Release
- ) else if "%1" == "x86" (
+ ) else if "%1" == "x86" (
set BUILD_ARCH=x86
- ) else if "%1" == "x64" (
+ ) else if "%1" == "x64" (
set BUILD_ARCH=x64
- ) else if "%1" == "2017" (
+ ) else if "%1" == "2017" (
set BUILD_VS_VER=15
set BUILD_VS_YEAR=2017
- ) else if "%1" == "2015" (
+ set BUILD_VS_LIBDIRPOST=vc14
+ ) else if "%1" == "2015" (
set BUILD_VS_VER=14
set BUILD_VS_YEAR=2015
- ) else if "%1" == "2013" (
+ set BUILD_VS_LIBDIRPOST=vc14
+ ) else if "%1" == "2013" (
set BUILD_VS_VER=12
set BUILD_VS_YEAR=2013
- ) else if "%1" == "packagename" (
+ set BUILD_VS_LIBDIRPOST=vc12
+ ) else if "%1" == "packagename" (
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -DCPACK_OVERRIDE_PACKAGENAME="%2"
shift /1
- ) else if "%1" == "nobuild" (
+ ) else if "%1" == "nobuild" (
set NOBUILD=1
- ) else if "%1" == "showhash" (
+ ) else if "%1" == "showhash" (
for /f "delims=" %%i in ('git rev-parse HEAD') do echo Branch_hash=%%i
cd release/datafiles/locale
for /f "delims=" %%i in ('git rev-parse HEAD') do echo Locale_hash=%%i
@@ -122,31 +129,32 @@ if "%BUILD_ARCH%"=="" (
set BUILD_ARCH=x86
)
) else if "%BUILD_ARCH%"=="x64" (
- set WINDOWS_ARCH= Win64
- ) else if "%BUILD_ARCH%"=="x86" (
- set WINDOWS_ARCH=
- )
+ set WINDOWS_ARCH= Win64
+) else if "%BUILD_ARCH%"=="x86" (
+ set WINDOWS_ARCH=
+)
if "%BUILD_VS_VER%"=="" (
set BUILD_VS_VER=12
set BUILD_VS_YEAR=2013
+ set BUILD_VS_LIBDIRPOST=vc12
)
if "%BUILD_ARCH%"=="x64" (
set MSBUILD_PLATFORM=x64
- ) else if "%BUILD_ARCH%"=="x86" (
- set MSBUILD_PLATFORM=win32
+) else if "%BUILD_ARCH%"=="x86" (
+ set MSBUILD_PLATFORM=win32
)
if "%target%"=="Release" (
- rem for vc12 check for both cuda 7.5 and 8
- if "%CUDA_PATH%"=="" (
- echo Cuda Not found, aborting!
- goto EOF
- )
- set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% ^
- -C"%BLENDER_DIR%\build_files\cmake\config\blender_release.cmake"
+ rem for vc12 check for both cuda 7.5 and 8
+ if "%CUDA_PATH%"=="" (
+ echo Cuda Not found, aborting!
+ goto EOF
+ )
+ set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% ^
+ -C"%BLENDER_DIR%\build_files\cmake\config\blender_release.cmake"
)
:DetectMSVC
@@ -183,8 +191,9 @@ if %ERRORLEVEL% NEQ 0 (
echo Visual Studio 2013 not found, trying Visual Studio 2015.
set BUILD_VS_VER=14
set BUILD_VS_YEAR=2015
+ set BUILD_VS_LIBDIRPOST=vc14
goto DetectMSVC
- ) else (
+ ) else (
echo Error: "MSBuild" command not in the PATH.
echo You must have MSVC installed and run this from the "Developer Command Prompt"
echo ^(available from Visual Studio's Start menu entry^), aborting!
@@ -204,11 +213,36 @@ if %ERRORLEVEL% NEQ 0 (
echo You must have CMake installed and added to your PATH, aborting!
goto EOF
)
-if NOT EXIST %BLENDER_DIR%..\lib\nul (
- echo Error: Path to libraries not found "%BLENDER_DIR%..\lib\"
+
+if "%BUILD_ARCH%"=="x64" (
+ set BUILD_VS_SVNDIR=win64_%BUILD_VS_LIBDIRPOST%
+) else if "%BUILD_ARCH%"=="x86" (
+ set BUILD_VS_SVNDIR=windows_%BUILD_VS_LIBDIRPOST%
+)
+set BUILD_VS_LIBDIR="%BLENDER_DIR%..\lib\%BUILD_VS_SVNDIR%"
+
+if NOT EXIST %BUILD_VS_LIBDIR% (
+ rem libs not found, but svn is on the system
+ if not "%HAS_SVN%"=="" (
+ echo.
+ echo The required external libraries in %BUILD_VS_LIBDIR% are missing
+ echo.
+ set /p GetLibs= "Would you like to download them? (y/n)"
+ if /I "!GetLibs!"=="Y" (
+ echo.
+ echo Downloading %BUILD_VS_SVNDIR% libraries, please wait.
+ echo.
+ svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/%BUILD_VS_SVNDIR% %BUILD_VS_LIBDIR%
+ )
+ )
+)
+
+if NOT EXIST %BUILD_VS_LIBDIR% (
+ echo Error: Path to libraries not found "%BUILD_VS_LIBDIR%"
echo This is needed for building, aborting!
goto EOF
)
+
if "%TARGET%"=="" (
echo Error: Convenience target not set
echo This is required for building, aborting!
@@ -297,31 +331,32 @@ echo Blender successfully built, run from: "%BUILD_DIR%\bin\%BUILD_TYPE%\blender
echo.
goto EOF
:HELP
- echo.
- echo Convenience targets
- echo - release ^(identical to the official blender.org builds^)
- echo - full ^(same as release minus the cuda kernels^)
- echo - lite
- echo - headless
- echo - cycles
- echo - bpy
- echo.
- echo Utilities ^(not associated with building^)
- echo - clean ^(Target must be set^)
- echo - update
- echo - nobuild ^(only generate project files^)
- echo - showhash ^(Show git hashes of source tree^)
- echo.
- echo Configuration options
- echo - with_tests ^(enable building unit tests^)
- echo - noge ^(disable building game enginge and player^)
- echo - debug ^(Build an unoptimized debuggable build^)
- echo - packagename [newname] ^(override default cpack package name^)
- echo - buildir [newdir] ^(override default build folder^)
- echo - x86 ^(override host auto-detect and build 32 bit code^)
- echo - x64 ^(override host auto-detect and build 64 bit code^)
- echo - 2013 ^(build with visual studio 2013^)
- echo - 2015 ^(build with visual studio 2015^) [EXPERIMENTAL]
- echo.
+ echo.
+ echo Convenience targets
+ echo - release ^(identical to the official blender.org builds^)
+ echo - full ^(same as release minus the cuda kernels^)
+ echo - lite
+ echo - headless
+ echo - cycles
+ echo - bpy
+ echo.
+ echo Utilities ^(not associated with building^)
+ echo - clean ^(Target must be set^)
+ echo - update
+ echo - nobuild ^(only generate project files^)
+ echo - showhash ^(Show git hashes of source tree^)
+ echo.
+ echo Configuration options
+ echo - with_tests ^(enable building unit tests^)
+ echo - noge ^(disable building game enginge and player^)
+ echo - debug ^(Build an unoptimized debuggable build^)
+ echo - packagename [newname] ^(override default cpack package name^)
+ echo - buildir [newdir] ^(override default build folder^)
+ echo - x86 ^(override host auto-detect and build 32 bit code^)
+ echo - x64 ^(override host auto-detect and build 64 bit code^)
+ echo - 2013 ^(build with visual studio 2013^)
+ echo - 2015 ^(build with visual studio 2015^) [EXPERIMENTAL]
+ echo - 2017 ^(build with visual studio 2017^) [EXPERIMENTAL]
+ echo.
:EOF
diff --git a/release/datafiles/splash.png b/release/datafiles/splash.png
index 60956db2576..80ad5929f76 100644
--- a/release/datafiles/splash.png
+++ b/release/datafiles/splash.png
Binary files differ
diff --git a/release/datafiles/splash_2x.png b/release/datafiles/splash_2x.png
index 3a5000c6bbc..79cfe5301ef 100644
--- a/release/datafiles/splash_2x.png
+++ b/release/datafiles/splash_2x.png
Binary files differ
diff --git a/release/scripts/freestyle/styles/apriori_and_causal_density.py b/release/scripts/freestyle/styles/apriori_and_causal_density.py
index 2ba768af835..42fc3370488 100644
--- a/release/scripts/freestyle/styles/apriori_and_causal_density.py
+++ b/release/scripts/freestyle/styles/apriori_and_causal_density.py
@@ -19,8 +19,8 @@
# Filename : apriori_and_causal_density.py
# Author : Stephane Grabli
# Date : 04/08/2005
-# Purpose : Selects the lines with high a priori density and
-# subjects them to the causal density so as to avoid
+# Purpose : Selects the lines with high a priori density and
+# subjects them to the causal density so as to avoid
# cluttering
from freestyle.chainingiterators import ChainPredicateIterator
diff --git a/release/scripts/freestyle/styles/cartoon.py b/release/scripts/freestyle/styles/cartoon.py
index e630127db1a..87518bb832e 100644
--- a/release/scripts/freestyle/styles/cartoon.py
+++ b/release/scripts/freestyle/styles/cartoon.py
@@ -19,7 +19,7 @@
# Filename : cartoon.py
# Author : Stephane Grabli
# Date : 04/08/2005
-# Purpose : Draws colored lines. The color is automatically
+# Purpose : Draws colored lines. The color is automatically
# inferred from each object's material in a cartoon-like
# fashion.
diff --git a/release/scripts/freestyle/styles/external_contour_sketchy.py b/release/scripts/freestyle/styles/external_contour_sketchy.py
index 44dbda4709f..6bccf23ac8d 100644
--- a/release/scripts/freestyle/styles/external_contour_sketchy.py
+++ b/release/scripts/freestyle/styles/external_contour_sketchy.py
@@ -19,8 +19,8 @@
# Filename : external_contour_sketchy.py
# Author : Stephane Grabli
# Date : 04/08/2005
-# Purpose : Draws the external contour of the scene using a sketchy
-# chaining iterator (in particular each ViewEdge can be drawn
+# Purpose : Draws the external contour of the scene using a sketchy
+# chaining iterator (in particular each ViewEdge can be drawn
# several times
from freestyle.chainingiterators import pySketchyChainingIterator
@@ -41,7 +41,7 @@ from freestyle.shaders import (
from freestyle.types import Operators
-upred = AndUP1D(QuantitativeInvisibilityUP1D(0), ExternalContourUP1D())
+upred = AndUP1D(QuantitativeInvisibilityUP1D(0), ExternalContourUP1D())
Operators.select(upred)
Operators.bidirectional_chain(pySketchyChainingIterator(), NotUP1D(upred))
shaders_list = [
diff --git a/release/scripts/freestyle/styles/haloing.py b/release/scripts/freestyle/styles/haloing.py
index 6cd37779a42..34e4f65cf91 100644
--- a/release/scripts/freestyle/styles/haloing.py
+++ b/release/scripts/freestyle/styles/haloing.py
@@ -19,8 +19,8 @@
# Filename : haloing.py
# Author : Stephane Grabli
# Date : 04/08/2005
-# Purpose : This style module selects the lines that
-# are connected (in the image) to a specific
+# Purpose : This style module selects the lines that
+# are connected (in the image) to a specific
# object and trims them in order to produce
# a haloing effect around the target shape
@@ -42,14 +42,14 @@ from freestyle.shaders import (
from freestyle.types import Id, Operators
-# id corresponds to the id of the target object
+# id corresponds to the id of the target object
# (accessed by SHIFT+click)
id = Id(3,0)
upred = AndUP1D(QuantitativeInvisibilityUP1D(0), pyIsOccludedByUP1D(id))
Operators.select(upred)
Operators.bidirectional_chain(ChainSilhouetteIterator(), NotUP1D(upred))
shaders_list = [
- IncreasingThicknessShader(3, 5),
+ IncreasingThicknessShader(3, 5),
IncreasingColorShader(1,0,0, 1,0,1,0,1),
SamplingShader(1.0),
pyTVertexRemoverShader(),
diff --git a/release/scripts/freestyle/styles/invisible_lines.py b/release/scripts/freestyle/styles/invisible_lines.py
index 461429b6437..5506f4ef11f 100644
--- a/release/scripts/freestyle/styles/invisible_lines.py
+++ b/release/scripts/freestyle/styles/invisible_lines.py
@@ -19,7 +19,7 @@
# Filename : invisible_lines.py
# Author : Stephane Grabli
# Date : 04/08/2005
-# Purpose : Draws all lines whose Quantitative Invisibility
+# Purpose : Draws all lines whose Quantitative Invisibility
# is different from 0
from freestyle.chainingiterators import ChainSilhouetteIterator
diff --git a/release/scripts/freestyle/styles/long_anisotropically_dense.py b/release/scripts/freestyle/styles/long_anisotropically_dense.py
index 50bec4f1a79..bfd5910cefe 100644
--- a/release/scripts/freestyle/styles/long_anisotropically_dense.py
+++ b/release/scripts/freestyle/styles/long_anisotropically_dense.py
@@ -19,13 +19,13 @@
# Filename : long_anisotropically_dense.py
# Author : Stephane Grabli
# Date : 04/08/2005
-# Purpose : Selects the lines that are long and have a high anisotropic
-# a priori density and uses causal density
+# Purpose : Selects the lines that are long and have a high anisotropic
+# a priori density and uses causal density
# to draw without cluttering. Ideally, half of the
# selected lines are culled using the causal density.
#
# ********************* WARNING *************************************
-# ******** The Directional a priori density maps must ******
+# ******** The Directional a priori density maps must ******
# ******** have been computed prior to using this style module ******
from freestyle.chainingiterators import ChainSilhouetteIterator
@@ -75,7 +75,7 @@ Operators.sort(pyLengthBP1D())
shaders_list = [
SamplingShader(2.0),
ConstantThicknessShader(2),
- ConstantColorShader(0.2,0.2,0.25,1),
+ ConstantColorShader(0.2,0.2,0.25,1),
]
## uniform culling
Operators.create(pyDensityUP1D(3.0,2.0e-2, IntegrationType.MEAN, 0.1), shaders_list)
diff --git a/release/scripts/freestyle/styles/multiple_parameterization.py b/release/scripts/freestyle/styles/multiple_parameterization.py
index 0e224c74bbf..c03a61c9a81 100644
--- a/release/scripts/freestyle/styles/multiple_parameterization.py
+++ b/release/scripts/freestyle/styles/multiple_parameterization.py
@@ -19,7 +19,7 @@
# Filename : multiple_parameterization.py
# Author : Stephane Grabli
# Date : 04/08/2005
-# Purpose : The thickness and the color of the strokes vary continuously
+# Purpose : The thickness and the color of the strokes vary continuously
# independently from occlusions although only
# visible lines are actually drawn. This is equivalent
# to assigning the thickness using a parameterization covering
diff --git a/release/scripts/freestyle/styles/nature.py b/release/scripts/freestyle/styles/nature.py
index 74a42e6b2e5..1061f22017a 100644
--- a/release/scripts/freestyle/styles/nature.py
+++ b/release/scripts/freestyle/styles/nature.py
@@ -22,7 +22,7 @@
# Purpose : Uses the NatureUP1D predicate to select the lines
# of a given type (among Nature.SILHOUETTE, Nature.CREASE, Nature.SUGGESTIVE_CONTOURS,
# Nature.BORDERS).
-# The suggestive contours must have been enabled in the
+# The suggestive contours must have been enabled in the
# options dialog to appear in the View Map.
from freestyle.chainingiterators import ChainSilhouetteIterator
diff --git a/release/scripts/freestyle/styles/near_lines.py b/release/scripts/freestyle/styles/near_lines.py
index 5e260a22382..14c8d2f9e01 100644
--- a/release/scripts/freestyle/styles/near_lines.py
+++ b/release/scripts/freestyle/styles/near_lines.py
@@ -19,7 +19,7 @@
# Filename : near_lines.py
# Author : Stephane Grabli
# Date : 04/08/2005
-# Purpose : Draws the lines that are "closer" than a threshold
+# Purpose : Draws the lines that are "closer" than a threshold
# (between 0 and 1)
from freestyle.chainingiterators import ChainSilhouetteIterator
diff --git a/release/scripts/freestyle/styles/qi1.py b/release/scripts/freestyle/styles/qi1.py
index d70e56d401a..4d87055eafb 100644
--- a/release/scripts/freestyle/styles/qi1.py
+++ b/release/scripts/freestyle/styles/qi1.py
@@ -20,7 +20,7 @@
# Author : Stephane Grabli
# Date : 04/08/2005
# Purpose : Draws lines hidden by one surface.
-# *** Quantitative Invisibility must have been
+# *** Quantitative Invisibility must have been
# enabled in the options dialog to use this style module ****
from freestyle.chainingiterators import ChainSilhouetteIterator
diff --git a/release/scripts/freestyle/styles/qi2.py b/release/scripts/freestyle/styles/qi2.py
index 6ac933ecc05..937b5db590a 100644
--- a/release/scripts/freestyle/styles/qi2.py
+++ b/release/scripts/freestyle/styles/qi2.py
@@ -20,7 +20,7 @@
# Author : Stephane Grabli
# Date : 04/08/2005
# Purpose : Draws lines hidden by two surfaces.
-# *** Quantitative Invisibility must have been
+# *** Quantitative Invisibility must have been
# enabled in the options dialog to use this style module ****
from freestyle.chainingiterators import ChainSilhouetteIterator
diff --git a/release/scripts/freestyle/styles/sequentialsplit_sketchy.py b/release/scripts/freestyle/styles/sequentialsplit_sketchy.py
index b980fdc87d7..5755fd3b845 100644
--- a/release/scripts/freestyle/styles/sequentialsplit_sketchy.py
+++ b/release/scripts/freestyle/styles/sequentialsplit_sketchy.py
@@ -21,7 +21,7 @@
# Date : 04/08/2005
# Purpose : Use the sequential split with two different
# predicates to specify respectively the starting and
-# the stopping extremities for strokes
+# the stopping extremities for strokes
from freestyle.chainingiterators import ChainSilhouetteIterator
from freestyle.predicates import (
diff --git a/release/scripts/freestyle/styles/sketchy_multiple_parameterization.py b/release/scripts/freestyle/styles/sketchy_multiple_parameterization.py
index a3ce6112165..8302ec8e4c3 100644
--- a/release/scripts/freestyle/styles/sketchy_multiple_parameterization.py
+++ b/release/scripts/freestyle/styles/sketchy_multiple_parameterization.py
@@ -19,7 +19,7 @@
# Filename : sketchy_multiple_parameterization.py
# Author : Stephane Grabli
# Date : 04/08/2005
-# Purpose : Builds sketchy strokes whose topology relies on a
+# Purpose : Builds sketchy strokes whose topology relies on a
# parameterization that covers the complete lines (visible+invisible)
# whereas only the visible portions are actually drawn
diff --git a/release/scripts/freestyle/styles/uniformpruning_zsort.py b/release/scripts/freestyle/styles/uniformpruning_zsort.py
index 814e140ee49..64e808d9f8a 100644
--- a/release/scripts/freestyle/styles/uniformpruning_zsort.py
+++ b/release/scripts/freestyle/styles/uniformpruning_zsort.py
@@ -17,7 +17,7 @@
# ##### END GPL LICENSE BLOCK #####
# Filename : uniformpruning_zsort.py
-# Authors : Fredo Durand, Stephane Grabli, Francois Sillion, Emmanuel Turquin
+# Authors : Fredo Durand, Stephane Grabli, Francois Sillion, Emmanuel Turquin
# Date : 08/04/2005
from freestyle.chainingiterators import ChainSilhouetteIterator
diff --git a/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py b/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py
index 3b7eff6db9c..bbeb1780355 100644
--- a/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py
+++ b/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py
@@ -227,6 +227,8 @@ def dump_rna_messages(msgs, reports, settings, verbose=False):
# More builtin classes we don't need to parse.
blacklist_rna_class |= {cls for cls in bpy.types.Property.__subclasses__()}
+ # None of this seems needed anymore, and it's broken anyway with current master (blender 2.79.1)...
+ """
_rna = {getattr(bpy.types, cls) for cls in dir(bpy.types)}
# Classes which are attached to collections can be skipped too, these are api access only.
@@ -276,6 +278,7 @@ def dump_rna_messages(msgs, reports, settings, verbose=False):
#op = get_instance(idname)
#if 'INTERNAL' in path_resolve(op, "bl_options"):
#blacklist_rna_class.add(idname)
+ """
return blacklist_rna_class
diff --git a/release/scripts/modules/bl_i18n_utils/utils_spell_check.py b/release/scripts/modules/bl_i18n_utils/utils_spell_check.py
index 285e2ebe477..2ce8385f714 100644
--- a/release/scripts/modules/bl_i18n_utils/utils_spell_check.py
+++ b/release/scripts/modules/bl_i18n_utils/utils_spell_check.py
@@ -107,6 +107,7 @@ class SpellChecker:
"fulldome", "fulldomes",
"fullscreen",
"gridline",
+ "hardlight",
"hemi",
"inbetween",
"inscatter", "inscattering",
@@ -128,7 +129,7 @@ class SpellChecker:
"multisampling",
"multiscatter",
"multitexture",
- "multithreaded",
+ "multithreaded",
"multiuser",
"multiview",
"namespace",
@@ -447,6 +448,7 @@ class SpellChecker:
"gpencil",
"idcol",
"keyframe", "keyframes", "keyframing", "keyframed",
+ "luminocity",
"mathvis",
"metaball", "metaballs", "mball",
"metaelement", "metaelements",
diff --git a/release/scripts/modules/bl_previews_utils/bl_previews_render.py b/release/scripts/modules/bl_previews_utils/bl_previews_render.py
index b4f0b8dd3b8..71208ef3485 100644
--- a/release/scripts/modules/bl_previews_utils/bl_previews_render.py
+++ b/release/scripts/modules/bl_previews_utils/bl_previews_render.py
@@ -278,7 +278,7 @@ def do_previews(do_objects, do_groups, do_scenes, do_data_intern):
bbox[1].z = v.z
def objects_bbox_calc(camera, objects, offset_matrix):
- bbox = (Vector((1e9, 1e9, 1e9)), Vector((-1e9, -1e9, -1e9)))
+ bbox = (Vector((1e24, 1e24, 1e24)), Vector((-1e24, -1e24, -1e24)))
for obname, libpath in objects:
ob = bpy.data.objects[obname, libpath]
object_bbox_merge(bbox, ob, camera, offset_matrix)
@@ -305,6 +305,17 @@ def do_previews(do_objects, do_groups, do_scenes, do_data_intern):
cos = objects_bbox_calc(camera, objects, offset_matrix)
loc, ortho_scale = camera.camera_fit_coords(scene, cos)
camera.location = loc
+ # Set camera clipping accordingly to computed bbox.
+ min_dist = 1e24
+ max_dist = -1e24
+ for co in zip(*(iter(cos),) * 3):
+ dist = (Vector(co) - loc).length
+ if dist < min_dist:
+ min_dist = dist
+ if dist > max_dist:
+ max_dist = dist
+ camera.data.clip_start = min_dist / 2
+ camera.data.clip_end = max_dist * 2
if lamp:
loc, ortho_scale = lamp.camera_fit_coords(scene, cos)
lamp.location = loc
diff --git a/release/scripts/modules/bpy/utils/__init__.py b/release/scripts/modules/bpy/utils/__init__.py
index 1d555ae7123..c3175f93f4e 100644
--- a/release/scripts/modules/bpy/utils/__init__.py
+++ b/release/scripts/modules/bpy/utils/__init__.py
@@ -37,6 +37,8 @@ __all__ = (
"register_module",
"register_manual_map",
"unregister_manual_map",
+ "register_classes_factory",
+ "register_submodule_factory",
"make_rna_paths",
"manual_map",
"previews",
@@ -71,6 +73,7 @@ import addon_utils as _addon_utils
_user_preferences = _bpy.context.user_preferences
_script_module_dirs = "startup", "modules"
+_is_factory_startup = _bpy.app.factory_startup
def _test_import(module_name, loaded_modules):
@@ -144,6 +147,7 @@ def load_scripts(reload_scripts=False, refresh_scripts=False):
:type refresh_scripts: bool
"""
use_time = use_class_register_check = _bpy.app.debug_python
+ use_user = not _is_factory_startup
if use_time:
import time
@@ -234,7 +238,7 @@ def load_scripts(reload_scripts=False, refresh_scripts=False):
from bpy_restrict_state import RestrictBlend
with RestrictBlend():
- for base_path in script_paths():
+ for base_path in script_paths(use_user=use_user):
for path_subdir in _script_module_dirs:
path = _os.path.join(base_path, path_subdir)
if _os.path.isdir(path):
@@ -306,7 +310,7 @@ def script_path_pref():
return _os.path.normpath(path) if path else None
-def script_paths(subdir=None, user_pref=True, check_all=False):
+def script_paths(subdir=None, user_pref=True, check_all=False, use_user=True):
"""
Returns a list of valid script paths.
@@ -328,15 +332,30 @@ def script_paths(subdir=None, user_pref=True, check_all=False):
# so the 'BLENDER_SYSTEM_SCRIPTS' environment variable will be used.
base_paths = _bpy_script_paths()
+ # Defined to be (system, user) so we can skip the second if needed.
+ if not use_user:
+ base_paths = base_paths[:1]
+
if check_all:
# All possible paths, no duplicates, keep order.
+ if use_user:
+ test_paths = ('LOCAL', 'USER', 'SYSTEM')
+ else:
+ test_paths = ('LOCAL', 'SYSTEM')
+
base_paths = (
- *(path for path in (_os.path.join(resource_path(res), "scripts")
- for res in ('LOCAL', 'USER', 'SYSTEM')) if path not in base_paths),
+ *(path for path in (
+ _os.path.join(resource_path(res), "scripts")
+ for res in test_paths) if path not in base_paths),
*base_paths,
- )
+ )
- for path in (*base_paths, script_path_user(), script_path_pref()):
+ if use_user:
+ test_paths = (*base_paths, script_path_user(), script_path_pref())
+ else:
+ test_paths = (*base_paths, script_path_pref())
+
+ for path in test_paths:
if path:
path = _os.path.normpath(path)
if path not in scripts and _os.path.isdir(path):
@@ -381,27 +400,26 @@ def app_template_paths(subdir=None):
:return: app template paths.
:rtype: generator
"""
+ # Note: keep in sync with: Blender's BKE_appdir_app_template_any
- # note: LOCAL, USER, SYSTEM order matches script resolution order.
subdir_tuple = (subdir,) if subdir is not None else ()
- path = _os.path.join(*(
- resource_path('LOCAL'), "scripts", "startup",
- "bl_app_templates_user", *subdir_tuple))
- if _os.path.isdir(path):
- yield path
- else:
- path = _os.path.join(*(
- resource_path('USER'), "scripts", "startup",
- "bl_app_templates_user", *subdir_tuple))
- if _os.path.isdir(path):
- yield path
-
- path = _os.path.join(*(
- resource_path('SYSTEM'), "scripts", "startup",
- "bl_app_templates_system", *subdir_tuple))
- if _os.path.isdir(path):
- yield path
+ # Avoid adding 'bl_app_templates_system' twice.
+ # Either we have a portable build or an installed system build.
+ for resource_type, module_name in (
+ ('USER', "bl_app_templates_user"),
+ ('LOCAL', "bl_app_templates_system"),
+ ('SYSTEM', "bl_app_templates_system"),
+ ):
+ path = resource_path(resource_type)
+ if path:
+ path = _os.path.join(
+ *(path, "scripts", "startup", module_name, *subdir_tuple))
+ if _os.path.isdir(path):
+ yield path
+ # Only load LOCAL or SYSTEM (never both).
+ if resource_type == 'LOCAL':
+ break
def preset_paths(subdir):
@@ -684,6 +702,65 @@ def unregister_module(module, verbose=False):
print("done.\n")
+def register_classes_factory(classes):
+ """
+ Utility function to create register and unregister functions
+ which simply registers and unregisters a sequence of classes.
+ """
+ def register():
+ from bpy.utils import register_class
+ for cls in classes:
+ register_class(cls)
+
+ def unregister():
+ from bpy.utils import unregister_class
+ for cls in reversed(classes):
+ unregister_class(cls)
+
+ return register, unregister
+
+
+def register_submodule_factory(module_name, submodule_names):
+ """
+ Utility function to create register and unregister functions
+ which simply load submodules,
+ calling their register & unregister functions.
+
+ .. note::
+
+ Modules are registered in the order given,
+ unregistered in reverse order.
+
+ :arg module_name: The module name, typically ``__name__``.
+ :type module_name: string
+ :arg submodule_names: List of submodule names to load and unload.
+ :type submodule_names: list of strings
+ :return: register and unregister functions.
+ :rtype: tuple pair of functions
+ """
+
+ module = None
+ submodules = []
+
+ def register():
+ nonlocal module
+ module = __import__(name=module_name, fromlist=submodule_names)
+ submodules[:] = [getattr(module, name) for name in submodule_names]
+ for mod in submodules:
+ mod.register()
+
+ def unregister():
+ from sys import modules
+ for mod in reversed(submodules):
+ mod.unregister()
+ name = mod.__name__
+ delattr(module, name.partition(".")[2])
+ del modules[name]
+ submodules.clear()
+
+ return register, unregister
+
+
# -----------------------------------------------------------------------------
# Manual lookups, each function has to return a basepath and a sequence
# of...
diff --git a/release/scripts/modules/bpy_extras/anim_utils.py b/release/scripts/modules/bpy_extras/anim_utils.py
index 5e21260e5e4..ea0bd77c0f0 100644
--- a/release/scripts/modules/bpy_extras/anim_utils.py
+++ b/release/scripts/modules/bpy_extras/anim_utils.py
@@ -20,35 +20,118 @@
__all__ = (
"bake_action",
- )
+ "bake_action_objects",
+
+ "bake_action_iter",
+ "bake_action_objects_iter",
+)
import bpy
-# XXX visual keying is actually always considered as True in this code...
-def bake_action(frame_start,
- frame_end,
- frame_step=1,
- only_selected=False,
- do_pose=True,
- do_object=True,
- do_visual_keying=True,
- do_constraint_clear=False,
- do_parents_clear=False,
- do_clean=False,
- action=None,
- ):
+def bake_action(
+ obj,
+ *,
+ action, frames,
+ **kwargs
+):
+ """
+ :arg obj: Object to bake.
+ :type obj: :class:`bpy.types.Object`
+ :arg action: An action to bake the data into, or None for a new action
+ to be created.
+ :type action: :class:`bpy.types.Action` or None
+ :arg frames: Frames to bake.
+ :type frames: iterable of int
+ :return: an action or None
+ :rtype: :class:`bpy.types.Action`
"""
- Return an image from the file path with options to search multiple paths
- and return a placeholder if its not found.
-
- :arg frame_start: First frame to bake.
- :type frame_start: int
- :arg frame_end: Last frame to bake.
- :type frame_end: int
- :arg frame_step: Frame step.
- :type frame_step: int
+ if not (do_pose or do_object):
+ return None
+
+ action, = bake_action_objects(
+ [(obj, action)],
+ frames,
+ **kwargs,
+ )
+ return action
+
+
+def bake_action_objects(
+ object_action_pairs,
+ *,
+ frames,
+ **kwargs
+):
+ """
+ A version of :func:`bake_action_objects_iter` that takes frames and returns the output.
+
+ :arg frames: Frames to bake.
+ :type frames: iterable of int
+
+ :return: A sequence of Action or None types (aligned with `object_action_pairs`)
+ :rtype: sequence of :class:`bpy.types.Action`
+ """
+ iter = bake_action_objects_iter(object_action_pairs, **kwargs)
+ iter.send(None)
+ for frame in frames:
+ iter.send(frame)
+ return iter.send(None)
+
+
+def bake_action_objects_iter(
+ object_action_pairs,
+ **kwargs
+):
+ """
+ An coroutine that bakes actions for multiple objects.
+
+ :arg object_action_pairs: Sequence of object action tuples,
+ action is the destination for the baked data. When None a new action will be created.
+ :type object_action_pairs: Sequence of (:class:`bpy.types.Object`, :class:`bpy.types.Action`)
+ """
+ scene = bpy.context.scene
+ frame_back = scene.frame_current
+ iter_all = tuple(
+ bake_action_iter(obj, action=action, **kwargs)
+ for (obj, action) in object_action_pairs
+ )
+ for iter in iter_all:
+ iter.send(None)
+ while True:
+ frame = yield None
+ if frame is None:
+ break
+ scene.frame_set(frame)
+ scene.update()
+ for iter in iter_all:
+ iter.send(frame)
+ scene.frame_set(frame_back)
+ yield tuple(iter.send(None) for iter in iter_all)
+
+
+# XXX visual keying is actually always considered as True in this code...
+def bake_action_iter(
+ obj,
+ *,
+ action,
+ only_selected=False,
+ do_pose=True,
+ do_object=True,
+ do_visual_keying=True,
+ do_constraint_clear=False,
+ do_parents_clear=False,
+ do_clean=False
+):
+ """
+ An coroutine that bakes action for a single object.
+
+ :arg obj: Object to bake.
+ :type obj: :class:`bpy.types.Object`
+ :arg action: An action to bake the data into, or None for a new action
+ to be created.
+ :type action: :class:`bpy.types.Action` or None
:arg only_selected: Only bake selected bones.
:type only_selected: bool
:arg do_pose: Bake pose channels.
@@ -63,14 +146,10 @@ def bake_action(frame_start,
:type do_parents_clear: bool
:arg do_clean: Remove redundant keyframes after baking.
:type do_clean: bool
- :arg action: An action to bake the data into, or None for a new action
- to be created.
- :type action: :class:`bpy.types.Action` or None
:return: an action or None
:rtype: :class:`bpy.types.Action`
"""
-
# -------------------------------------------------------------------------
# Helper Functions and vars
@@ -112,34 +191,32 @@ def bake_action(frame_start,
# -------------------------------------------------------------------------
# Setup the Context
- # TODO, pass data rather then grabbing from the context!
- scene = bpy.context.scene
- obj = bpy.context.object
- frame_back = scene.frame_current
-
if obj.pose is None:
do_pose = False
if not (do_pose or do_object):
- return None
+ raise Exception("Pose and object baking is disabled, no action needed")
pose_info = []
obj_info = []
options = {'INSERTKEY_NEEDED'}
- frame_range = range(frame_start, frame_end + 1, frame_step)
-
# -------------------------------------------------------------------------
# Collect transformations
- for f in frame_range:
- scene.frame_set(f)
- scene.update()
+ while True:
+ # Caller is responsible for setting the frame and updating the scene.
+ frame = yield None
+
+ # Signal we're done!
+ if frame is None:
+ break
+
if do_pose:
- pose_info.append(pose_frame_info(obj))
+ pose_info.append((frame, pose_frame_info(obj)))
if do_object:
- obj_info.append(obj_frame_info(obj))
+ obj_info.append((frame, obj_frame_info(obj)))
# -------------------------------------------------------------------------
# Clean (store initial data)
@@ -178,7 +255,7 @@ def bake_action(frame_start,
# create compatible eulers
euler_prev = None
- for (f, matrix) in zip(frame_range, pose_info):
+ for (f, matrix) in pose_info:
pbone.matrix_basis = matrix[name].copy()
pbone.keyframe_insert("location", -1, f, name, options)
@@ -210,7 +287,7 @@ def bake_action(frame_start,
# create compatible eulers
euler_prev = None
- for (f, matrix) in zip(frame_range, obj_info):
+ for (f, matrix) in obj_info:
name = "Action Bake" # XXX: placeholder
obj.matrix_basis = matrix
@@ -261,6 +338,4 @@ def bake_action(frame_start,
else:
i += 1
- scene.frame_set(frame_back)
-
- return action
+ yield action
diff --git a/release/scripts/modules/bpy_extras/node_utils.py b/release/scripts/modules/bpy_extras/node_utils.py
index 3b8d4ad7c2a..9a2be5b9f68 100644
--- a/release/scripts/modules/bpy_extras/node_utils.py
+++ b/release/scripts/modules/bpy_extras/node_utils.py
@@ -32,16 +32,19 @@ def find_node_input(node, name):
return None
-# Return the output node to display in the UI
-def find_output_node(ntree, nodetype):
+# Return the output node to display in the UI. In case multiple node types are
+# specified, node types earlier in the list get priority.
+def find_output_node(ntree, nodetypes):
if ntree:
- active_output_node = None
- for node in ntree.nodes:
- if getattr(node, "type", None) == nodetype:
- if getattr(node, "is_active_output", True):
- return node
- if not active_output_node:
- active_output_node = node
- return active_output_node
+ output_node = None
+ for nodetype in nodetypes:
+ for node in ntree.nodes:
+ if getattr(node, "type", None) == nodetype:
+ if getattr(node, "is_active_output", True):
+ return node
+ if not output_node:
+ output_node = node
+ if output_node:
+ return output_node
return None
diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py
index 89d8e0746a6..78c70225a04 100644
--- a/release/scripts/modules/bpy_types.py
+++ b/release/scripts/modules/bpy_types.py
@@ -618,7 +618,74 @@ class Manipulator(StructRNA, metaclass=OrderedMeta):
return delattr(properties, attr)
return super().__delattr__(attr)
- target_set_handler = _bpy._rna_manipulator_target_set_handler
+ from _bpy import (
+ _rna_manipulator_target_set_handler as target_set_handler,
+ _rna_manipulator_target_get_value as target_get_value,
+ _rna_manipulator_target_set_value as target_set_value,
+ _rna_manipulator_target_get_range as target_get_range,
+ )
+
+ # Convenience wrappers around private `_gawain` module.
+ def draw_custom_shape(self, shape, *, matrix=None, select_id=None):
+ """
+ Draw a shape created form :class:`bpy.types.Manipulator.draw_custom_shape`.
+
+ :arg shape: The cached shape to draw.
+ :type shape: Undefined.
+ :arg matrix: 4x4 matrix, when not given
+ :class:`bpy.types.Manipulator.matrix_world` is used.
+ :type matrix: :class:`mathutils.Matrix`
+ :arg select_id: The selection id.
+ Only use when drawing within :class:`bpy.types.Manipulator.draw_select`.
+ :type select_it: int
+ """
+ import gpu
+
+ if matrix is None:
+ matrix = self.matrix_world
+
+ if select_id is not None:
+ gpu.select.load_id(select_id)
+ else:
+ if self.is_highlight:
+ color = (*self.color_highlight, self.alpha_highlight)
+ else:
+ color = (*self.color, self.alpha)
+ shape.uniform_f32("color", *color)
+
+ with gpu.matrix.push_pop():
+ gpu.matrix.multiply_matrix(matrix)
+ shape.draw()
+
+ @staticmethod
+ def new_custom_shape(type, verts):
+ """
+ Create a new shape that can be passed to :class:`bpy.types.Manipulator.draw_custom_shape`.
+
+ :arg type: The type of shape to create in (POINTS, LINES, TRIS, LINE_STRIP).
+ :type type: string
+ :arg verts: Coordinates.
+ :type verts: sequence of of 2D or 3D coordinates.
+ :arg display_name: Optional callback that takes the full path, returns the name to display.
+ :type display_name: Callable that takes a string and returns a string.
+ :return: The newly created shape.
+ :rtype: Undefined (it may change).
+ """
+ from _gawain.types import (
+ Gwn_Batch,
+ Gwn_VertBuf,
+ Gwn_VertFormat,
+ )
+ dims = len(verts[0])
+ if dims not in {2, 3}:
+ raise ValueError("Expected 2D or 3D vertex")
+ fmt = Gwn_VertFormat()
+ pos_id = fmt.attr_add(id="pos", comp_type='F32', len=dims, fetch_mode='FLOAT')
+ vbo = Gwn_VertBuf(len=len(verts), format=fmt)
+ vbo.fill(id=pos_id, data=verts)
+ batch = Gwn_Batch(type=type, buf=vbo)
+ batch.program_set_builtin('3D_UNIFORM_COLOR' if dims == 3 else '2D_UNIFORM_COLOR')
+ return batch
# Only defined so operators members can be used by accessing self.order
diff --git a/release/scripts/modules/keyingsets_utils.py b/release/scripts/modules/keyingsets_utils.py
index 8cef64c3590..7ce5f3e029b 100644
--- a/release/scripts/modules/keyingsets_utils.py
+++ b/release/scripts/modules/keyingsets_utils.py
@@ -232,7 +232,7 @@ bbone_property_ids = (
"bbone_scalein",
"bbone_scaleout",
- # NOTE: These are in the nested bone struct
+ # NOTE: These are in the nested bone struct
# Do it this way to force them to be included
# in whatever actions are being keyed here
"bone.bbone_in",
diff --git a/release/scripts/modules/nodeitems_utils.py b/release/scripts/modules/nodeitems_utils.py
index be6f031217c..117e35dd028 100644
--- a/release/scripts/modules/nodeitems_utils.py
+++ b/release/scripts/modules/nodeitems_utils.py
@@ -59,15 +59,29 @@ class NodeItem:
return self._label
else:
# if no custom label is defined, fall back to the node type UI name
- return getattr(bpy.types, self.nodetype).bl_rna.name
+ bl_rna = bpy.types.Node.bl_rna_get_subclass(self.nodetype)
+ if bl_rna is not None:
+ return bl_rna.name
+ else:
+ return "Unknown"
+
+ @property
+ def translation_context(self):
+ if self._label:
+ return bpy.app.translations.contexts.default
+ else:
+ # if no custom label is defined, fall back to the node type UI name
+ bl_rna = bpy.types.Node.bl_rna_get_subclass(self.nodetype)
+ if bl_rna is not None:
+ return bl_rna.translation_context
+ else:
+ return bpy.app.translations.contexts.default
# NB: is a staticmethod because called with an explicit self argument
# NodeItemCustom sets this as a variable attribute in __init__
@staticmethod
def draw(self, layout, context):
- default_context = bpy.app.translations.contexts.default
-
- props = layout.operator("node.add_node", text=self.label, text_ctxt=default_context)
+ props = layout.operator("node.add_node", text=self.label, text_ctxt=self.translation_context)
props.type = self.nodetype
props.use_transform = True
diff --git a/release/scripts/modules/rna_info.py b/release/scripts/modules/rna_info.py
index 94f5e9e17bb..1a3d0698871 100644
--- a/release/scripts/modules/rna_info.py
+++ b/release/scripts/modules/rna_info.py
@@ -82,6 +82,32 @@ def float_as_string(f):
return val_str
+def get_py_class_from_rna(rna_type):
+ """ Get's the Python type for a class which isn't necessarily added to ``bpy.types``.
+ """
+ identifier = rna_type.identifier
+ py_class = getattr(bpy.types, identifier, None)
+ if py_class is not None:
+ return py_class
+
+ def subclasses_recurse(cls):
+ for c in cls.__subclasses__():
+ # is_registered
+ if "bl_rna" in cls.__dict__:
+ yield c
+ yield from subclasses_recurse(c)
+
+ while py_class is None:
+ base = rna_type.base
+ if base is None:
+ raise Exception("can't find type")
+ py_class_base = getattr(bpy.types, base.identifier, None)
+ if py_class_base is not None:
+ for cls in subclasses_recurse(py_class_base):
+ if cls.bl_rna.identifier == identifier:
+ return cls
+
+
class InfoStructRNA:
__slots__ = (
"bl_rna",
@@ -146,7 +172,8 @@ class InfoStructRNA:
def _get_py_visible_attrs(self):
attrs = []
- py_class = getattr(bpy.types, self.identifier)
+ py_class = get_py_class_from_rna(self.bl_rna)
+
for attr_str in dir(py_class):
if attr_str.startswith("_"):
continue
@@ -210,6 +237,7 @@ class InfoPropertyRNA:
"min",
"max",
"array_length",
+ "array_dimensions",
"collection_type",
"type",
"fixed_type",
@@ -235,6 +263,7 @@ class InfoPropertyRNA:
self.min = getattr(rna_prop, "hard_min", -1)
self.max = getattr(rna_prop, "hard_max", -1)
self.array_length = getattr(rna_prop, "array_length", 0)
+ self.array_dimensions = getattr(rna_prop, "array_dimensions", ())[:]
self.collection_type = GetInfoStructRNA(rna_prop.srna)
self.is_required = rna_prop.is_required
self.is_readonly = rna_prop.is_readonly
@@ -254,13 +283,21 @@ class InfoPropertyRNA:
else:
self.is_enum_flag = False
+ self.default_str = "" # fallback
+
if self.array_length:
self.default = tuple(getattr(rna_prop, "default_array", ()))
+ if self.array_dimensions[1] != 0: # Multi-dimensional array, convert default flat one accordingly.
+ self.default_str = tuple(float_as_string(v) if self.type == "float" else str(v) for v in self.default)
+ for dim in self.array_dimensions[::-1]:
+ if dim != 0:
+ self.default = tuple(zip(*((iter(self.default),) * dim)))
+ self.default_str = tuple("(%s)" % ", ".join(s for s in b) for b in zip(*((iter(self.default_str),) * dim)))
+ self.default_str = self.default_str[0]
elif self.type == "enum" and self.is_enum_flag:
self.default = getattr(rna_prop, "default_flag", set())
else:
self.default = getattr(rna_prop, "default", None)
- self.default_str = "" # fallback
if self.type == "pointer":
# pointer has no default, just set as None
@@ -275,13 +312,12 @@ class InfoPropertyRNA:
else:
self.default_str = "'%s'" % self.default
elif self.array_length:
- self.default_str = ''
- # special case for floats
- if len(self.default) > 0:
- if self.type == "float":
+ if self.array_dimensions[1] == 0: # single dimension array, we already took care of multi-dimensions ones.
+ # special case for floats
+ if self.type == "float" and len(self.default) > 0:
self.default_str = "(%s)" % ", ".join(float_as_string(f) for f in self.default)
- if not self.default_str:
- self.default_str = str(self.default)
+ else:
+ self.default_str = str(self.default)
else:
if self.type == "float":
self.default_str = float_as_string(self.default)
@@ -301,7 +337,10 @@ class InfoPropertyRNA:
if self.fixed_type is None:
type_str += self.type
if self.array_length:
- type_str += " array of %d items" % (self.array_length)
+ if self.array_dimensions[1] != 0:
+ type_str += " multi-dimensional array of %s items" % (" * ".join(str(d) for d in self.array_dimensions if d != 0))
+ else:
+ type_str += " array of %d items" % (self.array_length)
if self.type in {"float", "int"}:
type_str += " in [%s, %s]" % (range_str(self.min), range_str(self.max))
@@ -437,7 +476,11 @@ class InfoOperatorRNA:
self.args.append(prop)
def get_location(self):
- op_class = getattr(bpy.types, self.identifier)
+ try:
+ op_class = getattr(bpy.types, self.identifier)
+ except AttributeError:
+ # defined in C.
+ return None, None
op_func = getattr(op_class, "execute", None)
if op_func is None:
op_func = getattr(op_class, "invoke", None)
@@ -601,7 +644,7 @@ def BuildRNAInfo():
for rna_prop_ptr in (getattr(rna_prop, "fixed_type", None), getattr(rna_prop, "srna", None)):
# Does this property point to me?
- if rna_prop_ptr:
+ if rna_prop_ptr and rna_prop_ptr.identifier in rna_references_dict:
rna_references_dict[rna_prop_ptr.identifier].append(
"%s.%s" % (rna_struct_path, rna_prop_identifier))
@@ -614,7 +657,7 @@ def BuildRNAInfo():
rna_prop_ptr = getattr(rna_prop, "fixed_type", None)
# Does this property point to me?
- if rna_prop_ptr:
+ if rna_prop_ptr and rna_prop_ptr.identifier in rna_references_dict:
rna_references_dict[rna_prop_ptr.identifier].append(
"%s.%s" % (rna_struct_path, rna_func.identifier))
@@ -649,16 +692,22 @@ def BuildRNAInfo():
for rna_info_prop in InfoFunctionRNA.global_lookup.values():
rna_info_prop.build()
- for rna_info in InfoStructRNA.global_lookup.values():
- rna_info.build()
- for prop in rna_info.properties:
- prop.build()
- for func in rna_info.functions:
- func.build()
- for prop in func.args:
- prop.build()
- for prop in func.return_values:
+ done_keys = set()
+ new_keys = set(InfoStructRNA.global_lookup.keys())
+ while new_keys:
+ for rna_key in new_keys:
+ rna_info = InfoStructRNA.global_lookup[rna_key]
+ rna_info.build()
+ for prop in rna_info.properties:
prop.build()
+ for func in rna_info.functions:
+ func.build()
+ for prop in func.args:
+ prop.build()
+ for prop in func.return_values:
+ prop.build()
+ done_keys |= new_keys
+ new_keys = set(InfoStructRNA.global_lookup.keys()) - done_keys
# there are too many invalid defaults, unless we intend to fix, leave this off
if 0:
diff --git a/release/scripts/modules/rna_keymap_ui.py b/release/scripts/modules/rna_keymap_ui.py
index 54e6b0235a1..46a93b6a43e 100644
--- a/release/scripts/modules/rna_keymap_ui.py
+++ b/release/scripts/modules/rna_keymap_ui.py
@@ -232,6 +232,7 @@ def draw_filtered(display_keymaps, filter_type, filter_text, layout):
"`": 'ACCENT_GRAVE',
"*": 'NUMPAD_ASTERIX',
"/": 'NUMPAD_SLASH',
+ '+': 'NUMPAD_PLUS',
"RMB": 'RIGHTMOUSE',
"LMB": 'LEFTMOUSE',
"MMB": 'MIDDLEMOUSE',
diff --git a/release/scripts/presets/cycles/integrator/direct_light.py b/release/scripts/presets/cycles/integrator/direct_light.py
index 12b332cb431..701aa10d556 100644
--- a/release/scripts/presets/cycles/integrator/direct_light.py
+++ b/release/scripts/presets/cycles/integrator/direct_light.py
@@ -2,12 +2,10 @@ import bpy
cycles = bpy.context.scene.cycles
cycles.max_bounces = 8
-cycles.min_bounces = 8
cycles.caustics_reflective = False
cycles.caustics_refractive = False
cycles.diffuse_bounces = 0
cycles.glossy_bounces = 1
cycles.transmission_bounces = 2
cycles.volume_bounces = 0
-cycles.transparent_min_bounces = 8
cycles.transparent_max_bounces = 8
diff --git a/release/scripts/presets/cycles/integrator/full_global_illumination.py b/release/scripts/presets/cycles/integrator/full_global_illumination.py
index 69fa6e735bd..a03c6c8bd64 100644
--- a/release/scripts/presets/cycles/integrator/full_global_illumination.py
+++ b/release/scripts/presets/cycles/integrator/full_global_illumination.py
@@ -2,12 +2,10 @@ import bpy
cycles = bpy.context.scene.cycles
cycles.max_bounces = 128
-cycles.min_bounces = 3
cycles.caustics_reflective = True
cycles.caustics_refractive = True
cycles.diffuse_bounces = 128
cycles.glossy_bounces = 128
cycles.transmission_bounces = 128
cycles.volume_bounces = 128
-cycles.transparent_min_bounces = 8
cycles.transparent_max_bounces = 128
diff --git a/release/scripts/presets/cycles/integrator/limited_global_illumination.py b/release/scripts/presets/cycles/integrator/limited_global_illumination.py
index 22a8478d23b..d37bf46c705 100644
--- a/release/scripts/presets/cycles/integrator/limited_global_illumination.py
+++ b/release/scripts/presets/cycles/integrator/limited_global_illumination.py
@@ -2,12 +2,10 @@ import bpy
cycles = bpy.context.scene.cycles
cycles.max_bounces = 8
-cycles.min_bounces = 3
cycles.caustics_reflective = False
cycles.caustics_refractive = False
cycles.diffuse_bounces = 1
cycles.glossy_bounces = 4
cycles.transmission_bounces = 8
cycles.volume_bounces = 2
-cycles.transparent_min_bounces = 8
cycles.transparent_max_bounces = 8
diff --git a/release/scripts/presets/cycles/sampling/final.py b/release/scripts/presets/cycles/sampling/final.py
index d03423b6c2e..f1222d927c1 100644
--- a/release/scripts/presets/cycles/sampling/final.py
+++ b/release/scripts/presets/cycles/sampling/final.py
@@ -1,20 +1,18 @@
import bpy
cycles = bpy.context.scene.cycles
-cycles.use_square_samples = True
-
# Path Trace
-cycles.samples = 24
-cycles.preview_samples = 12
+cycles.samples = 512
+cycles.preview_samples = 128
# Branched Path Trace
-cycles.aa_samples = 8
-cycles.preview_aa_samples = 4
+cycles.aa_samples = 128
+cycles.preview_aa_samples = 32
-cycles.diffuse_samples = 3
-cycles.glossy_samples = 2
-cycles.transmission_samples = 2
+cycles.diffuse_samples = 4
+cycles.glossy_samples = 4
+cycles.transmission_samples = 4
cycles.ao_samples = 1
-cycles.mesh_light_samples = 2
-cycles.subsurface_samples = 2
-cycles.volume_samples = 2
+cycles.mesh_light_samples = 4
+cycles.subsurface_samples = 4
+cycles.volume_samples = 4
diff --git a/release/scripts/presets/cycles/sampling/preview.py b/release/scripts/presets/cycles/sampling/preview.py
index 5f071c7474d..c16449e2c8f 100644
--- a/release/scripts/presets/cycles/sampling/preview.py
+++ b/release/scripts/presets/cycles/sampling/preview.py
@@ -1,20 +1,18 @@
import bpy
cycles = bpy.context.scene.cycles
-cycles.use_square_samples = True
-
# Path Trace
-cycles.samples = 12
-cycles.preview_samples = 6
+cycles.samples = 128
+cycles.preview_samples = 32
# Branched Path Trace
-cycles.aa_samples = 4
-cycles.preview_aa_samples = 2
+cycles.aa_samples = 32
+cycles.preview_aa_samples = 4
-cycles.diffuse_samples = 3
-cycles.glossy_samples = 2
-cycles.transmission_samples = 2
+cycles.diffuse_samples = 4
+cycles.glossy_samples = 4
+cycles.transmission_samples = 4
cycles.ao_samples = 1
-cycles.mesh_light_samples = 2
-cycles.subsurface_samples = 2
-cycles.volume_samples = 2
+cycles.mesh_light_samples = 4
+cycles.subsurface_samples = 4
+cycles.volume_samples = 4
diff --git a/release/scripts/presets/ffmpeg/DVD (note_colon_ this changes render resolution).py b/release/scripts/presets/ffmpeg/DVD_(note_colon__this_changes_render_resolution).py
index d858bd70836..d858bd70836 100644
--- a/release/scripts/presets/ffmpeg/DVD (note_colon_ this changes render resolution).py
+++ b/release/scripts/presets/ffmpeg/DVD_(note_colon__this_changes_render_resolution).py
diff --git a/release/scripts/presets/ffmpeg/h264 in MP4.py b/release/scripts/presets/ffmpeg/h264_in_MP4.py
index 0e9c32c4878..0e9c32c4878 100644
--- a/release/scripts/presets/ffmpeg/h264 in MP4.py
+++ b/release/scripts/presets/ffmpeg/h264_in_MP4.py
diff --git a/release/scripts/presets/ffmpeg/h264 in Matroska.py b/release/scripts/presets/ffmpeg/h264_in_Matroska.py
index 1fe066dc4bf..1fe066dc4bf 100644
--- a/release/scripts/presets/ffmpeg/h264 in Matroska.py
+++ b/release/scripts/presets/ffmpeg/h264_in_Matroska.py
diff --git a/release/scripts/presets/ffmpeg/h264 in Matroska for scrubbing.py b/release/scripts/presets/ffmpeg/h264_in_Matroska_for_scrubbing.py
index eb1889d272f..eb1889d272f 100644
--- a/release/scripts/presets/ffmpeg/h264 in Matroska for scrubbing.py
+++ b/release/scripts/presets/ffmpeg/h264_in_Matroska_for_scrubbing.py
diff --git a/release/scripts/presets/interface_theme/dark_blue_gradient.xml b/release/scripts/presets/interface_theme/dark_blue_gradient.xml
index d3d0f5bb522..d226f8531b2 100644
--- a/release/scripts/presets/interface_theme/dark_blue_gradient.xml
+++ b/release/scripts/presets/interface_theme/dark_blue_gradient.xml
@@ -110,7 +110,7 @@
inner="#39424bcc"
inner_sel="#667686bf"
item="#191919ff"
- text="#000000"
+ text="#b8b8b8"
text_sel="#ffffff"
show_shaded="TRUE"
shadetop="25"
diff --git a/release/scripts/presets/interface_theme/elsyiun.xml b/release/scripts/presets/interface_theme/elsyiun.xml
index 7a3d5146636..b9292856fe9 100644
--- a/release/scripts/presets/interface_theme/elsyiun.xml
+++ b/release/scripts/presets/interface_theme/elsyiun.xml
@@ -110,7 +110,7 @@
inner="#4b4b4bff"
inner_sel="#646464ff"
item="#191919ff"
- text="#000000"
+ text="#b8b8b8"
text_sel="#ffffff"
show_shaded="TRUE"
shadetop="0"
diff --git a/release/scripts/presets/interface_theme/flatty_light.xml b/release/scripts/presets/interface_theme/flatty_light.xml
index 623e0b334dd..c89cbd92ca0 100644
--- a/release/scripts/presets/interface_theme/flatty_light.xml
+++ b/release/scripts/presets/interface_theme/flatty_light.xml
@@ -216,7 +216,7 @@
<wcol_list_item>
<ThemeWidgetColors outline="#e6e6e6"
inner="#00000000"
- inner_sel="#5680c2ff"
+ inner_sel="#446599ff"
item="#80b1ffff"
text="#1a1a1a"
text_sel="#ffffff"
@@ -238,30 +238,33 @@
</ThemeUserInterface>
</user_interface>
<view_3d>
- <ThemeView3D grid="#414141"
+ <ThemeView3D grid="#464646"
+ clipping_border_3d="#313131ff"
wire="#000000"
wire_edit="#808080"
gp_vertex="#000000"
gp_vertex_select="#ff8500"
gp_vertex_size="3"
- lamp="#00000028"
- speaker="#000000"
- camera="#000000"
- view_overlay="#808080"
- empty="#000000"
+ text_grease_pencil="#b5e61d"
object_selected="#f15800"
object_active="#ffaa40"
- object_grouped="#083008"
+ object_grouped="#004200"
object_grouped_active="#55bb55"
- transform="#ffffff"
+ text_keyframe="#ddd700"
+ camera="#000000"
+ empty="#000000"
+ lamp="#00000028"
+ speaker="#000000"
vertex="#000000"
vertex_select="#ff8500"
vertex_size="3"
+ vertex_bevel="#00a5ff"
vertex_unreferenced="#000000"
edge_select="#ffa000"
edge_seam="#db2512"
edge_sharp="#00ffff"
edge_crease="#cc0099"
+ edge_bevel="#00a5ff"
edge_facesel="#4b4b4b"
freestyle_edge_mark="#7fff7f"
face="#00000012"
@@ -291,19 +294,18 @@
normal="#22dddd"
vertex_normal="#2361dd"
split_normal="#dd23dd"
- bone_solid="#c8c8c8"
bone_pose="#50c8ff"
bone_pose_active="#8cffff"
- frame_current="#60c040"
- outline_width="1"
+ bone_solid="#c8c8c8"
bundle_solid="#c8c8c8"
camera_path="#000000"
skin_root="#b44d4d"
- clipping_border_3d="#313131ff"
- text_keyframe="#ddd700"
- text_grease_pencil="#b5e61d"
+ view_overlay="#808080"
+ transform="#ffffff"
+ frame_current="#60c040"
paint_curve_handle="#7fff7f7f"
- paint_curve_pivot="#ff7f7f7f">
+ paint_curve_pivot="#ff7f7f7f"
+ outline_width="1">
<space>
<ThemeSpaceGradient title="#000000"
text="#000000"
@@ -321,8 +323,8 @@
tab_outline="#999999">
<gradients>
<ThemeGradientColors show_grad="TRUE"
- gradient="#1b1b1b"
- high_gradient="#3a3a3a">
+ gradient="#444444"
+ high_gradient="#858585">
</ThemeGradientColors>
</gradients>
<panelcolors>
@@ -348,6 +350,7 @@
vertex="#000000"
vertex_select="#ff8500"
vertex_size="6"
+ vertex_bevel="#000000"
vertex_unreferenced="#000000"
handle_free="#000000"
handle_auto="#909000"
@@ -372,13 +375,13 @@
header_text="#000000"
header_text_hi="#ffffff"
button="#999999e6"
- button_title="#000000"
+ button_title="#1a1a1a"
button_text="#000000"
button_text_hi="#ffffff"
- tab_active="#727272"
- tab_inactive="#535353"
- tab_back="#404040ff"
- tab_outline="#3c3c3c">
+ tab_active="#6697e6"
+ tab_inactive="#cccccc"
+ tab_back="#999999ff"
+ tab_outline="#999999">
<panelcolors>
<ThemePanelColors header="#c2c2c2ea"
back="#999999ff"
@@ -398,23 +401,23 @@
</ThemeGraphEditor>
</graph_editor>
<file_browser>
- <ThemeFileBrowser selected_file="#ff8c19">
+ <ThemeFileBrowser selected_file="#5680c2">
<space>
<ThemeSpaceGeneric back="#404040"
title="#000000"
- text="#f1f1f1"
- text_hi="#0f0f0f"
- header="#b3b3b3"
+ text="#eeeeee"
+ text_hi="#ffffff"
+ header="#adadad"
header_text="#000000"
header_text_hi="#ffffff"
- button="#7272727f"
- button_title="#000000"
+ button="#999999e6"
+ button_title="#1a1a1a"
button_text="#000000"
button_text_hi="#ffffff"
tab_active="#6697e6"
- tab_inactive="#535353"
- tab_back="#404040ff"
- tab_outline="#3c3c3c">
+ tab_inactive="#cccccc"
+ tab_back="#999999ff"
+ tab_outline="#999999">
<panelcolors>
<ThemePanelColors header="#c2c2c2ea"
back="#99999980"
@@ -501,6 +504,7 @@
keyframe_jitter_selected="#61c042"
keyframe_border="#000000ff"
keyframe_border_selected="#000000ff"
+ keyframe_scale_factor="1"
summary="#d3660066">
<space>
<ThemeSpaceGeneric back="#6b6b6b"
@@ -543,6 +547,7 @@
vertex="#000000"
vertex_select="#ff8500"
vertex_size="3"
+ vertex_bevel="#000000"
vertex_unreferenced="#000000"
face="#ffffff0a"
face_select="#ff85003c"
diff --git a/release/scripts/presets/interface_theme/science_lab.xml b/release/scripts/presets/interface_theme/science_lab.xml
index 9341e945375..2fe4cf99e41 100644
--- a/release/scripts/presets/interface_theme/science_lab.xml
+++ b/release/scripts/presets/interface_theme/science_lab.xml
@@ -110,7 +110,7 @@
inner="#303030ff"
inner_sel="#678db2ff"
item="#191919ff"
- text="#272727"
+ text="#e6f1ff"
text_sel="#ffffff"
show_shaded="FALSE"
shadetop="0"
diff --git a/release/scripts/startup/bl_operators/anim.py b/release/scripts/startup/bl_operators/anim.py
index 02fb05e29eb..0632f9bc3ca 100644
--- a/release/scripts/startup/bl_operators/anim.py
+++ b/release/scripts/startup/bl_operators/anim.py
@@ -137,6 +137,9 @@ class ANIM_OT_keying_set_export(Operator):
break
else:
self.report({'WARN'}, "Could not find scene using Compositor Node Tree - %s" % (ksp.id))
+ elif ksp.id.bl_rna.name == "Key":
+ # "keys" conflicts with a Python keyword, hence the simple solution won't work
+ id_bpy_path = "bpy.data.shape_keys[\"%s\"]" % (ksp.id.name)
else:
idtype_list = ksp.id.bl_rna.name.lower() + "s"
id_bpy_path = "bpy.data.%s[\"%s\"]" % (idtype_list, ksp.id.name)
@@ -195,7 +198,7 @@ class ANIM_OT_keying_set_export(Operator):
class BakeAction(Operator):
- """Bake object/pose loc/scale/rotation animation to a new action"""
+ """Bake all selected objects loc/scale/rotation animation to an action"""
bl_idname = "nla.bake"
bl_label = "Bake Action"
bl_options = {'REGISTER', 'UNDO'}
@@ -219,7 +222,7 @@ class BakeAction(Operator):
default=1,
)
only_selected = BoolProperty(
- name="Only Selected",
+ name="Only Selected Bones",
description="Only key selected bones (Pose baking only)",
default=True,
)
@@ -255,29 +258,27 @@ class BakeAction(Operator):
)
def execute(self, context):
-
from bpy_extras import anim_utils
-
- action = None
- if self.use_current_action:
- obj = context.object
- if obj.animation_data:
- action = obj.animation_data.action
-
- action = anim_utils.bake_action(self.frame_start,
- self.frame_end,
- frame_step=self.step,
- only_selected=self.only_selected,
- do_pose='POSE' in self.bake_types,
- do_object='OBJECT' in self.bake_types,
- do_visual_keying=self.visual_keying,
- do_constraint_clear=self.clear_constraints,
- do_parents_clear=self.clear_parents,
- do_clean=True,
- action=action,
- )
-
- if action is None:
+ objects = context.selected_editable_objects
+ object_action_pairs = (
+ [(obj, getattr(obj.animation_data, "action", None)) for obj in objects]
+ if self.use_current_action else
+ [(obj, None) for obj in objects]
+ )
+
+ actions = anim_utils.bake_action_objects(
+ object_action_pairs,
+ frames=range(self.frame_start, self.frame_end + 1, self.step),
+ only_selected=self.only_selected,
+ do_pose='POSE' in self.bake_types,
+ do_object='OBJECT' in self.bake_types,
+ do_visual_keying=self.visual_keying,
+ do_constraint_clear=self.clear_constraints,
+ do_parents_clear=self.clear_parents,
+ do_clean=True,
+ )
+
+ if not any(actions):
self.report({'INFO'}, "Nothing to bake")
return {'CANCELLED'}
diff --git a/release/scripts/startup/bl_operators/clip.py b/release/scripts/startup/bl_operators/clip.py
index 6747bfec1fb..ea68641f68b 100644
--- a/release/scripts/startup/bl_operators/clip.py
+++ b/release/scripts/startup/bl_operators/clip.py
@@ -210,7 +210,7 @@ class CLIP_OT_set_active_clip(bpy.types.Operator):
@classmethod
def poll(cls, context):
space = context.space_data
- return space.type == 'CLIP_EDITOR'
+ return space.type == 'CLIP_EDITOR' and space.clip
def execute(self, context):
clip = context.space_data.clip
@@ -254,6 +254,11 @@ class CLIP_OT_track_to_empty(Operator):
constraint.object = tracking_object.name
constraint.camera = CLIP_camera_for_clip(context, clip)
+ @classmethod
+ def poll(cls, context):
+ space = context.space_data
+ return space.type == 'CLIP_EDITOR' and space.clip
+
def execute(self, context):
sc = context.space_data
clip = sc.clip
@@ -782,8 +787,8 @@ class CLIP_OT_setup_tracking_scene(Operator):
tree.links.new(mul_shadow.outputs["Image"], mul_image.inputs[2])
tree.links.new(rlayer_fg.outputs["Image"], vector_blur.inputs["Image"])
- tree.links.new(rlayer_fg.outputs["Z"], vector_blur.inputs["Z"])
- tree.links.new(rlayer_fg.outputs["Speed"], vector_blur.inputs["Speed"])
+ tree.links.new(rlayer_fg.outputs["Depth"], vector_blur.inputs["Z"])
+ tree.links.new(rlayer_fg.outputs["Vector"], vector_blur.inputs["Speed"])
tree.links.new(mul_image.outputs["Image"], alphaover.inputs[1])
tree.links.new(vector_blur.outputs["Image"], alphaover.inputs[2])
diff --git a/release/scripts/startup/bl_operators/object_align.py b/release/scripts/startup/bl_operators/object_align.py
index 1539ffb3545..b7d3866989d 100644
--- a/release/scripts/startup/bl_operators/object_align.py
+++ b/release/scripts/startup/bl_operators/object_align.py
@@ -131,6 +131,11 @@ def align_objects(context,
cursor = (space if space and space.type == 'VIEW_3D' else scene).cursor_location
+ # We are accessing runtime data such as evaluated bounding box, so we need to
+ # be sure it is properly updated and valid (bounding box might be lost on operator
+ # redo).
+ scene.update()
+
Left_Front_Up_SEL = [0.0, 0.0, 0.0]
Right_Back_Down_SEL = [0.0, 0.0, 0.0]
diff --git a/release/scripts/startup/bl_operators/uvcalc_smart_project.py b/release/scripts/startup/bl_operators/uvcalc_smart_project.py
index b7ef6856575..411c318643b 100644
--- a/release/scripts/startup/bl_operators/uvcalc_smart_project.py
+++ b/release/scripts/startup/bl_operators/uvcalc_smart_project.py
@@ -723,7 +723,7 @@ def main(context,
global USER_FILL_HOLES_QUALITY
global USER_STRETCH_ASPECT
global USER_ISLAND_MARGIN
-
+
from math import cos
import time
@@ -747,7 +747,7 @@ def main(context,
USER_FILL_HOLES = 0
USER_FILL_HOLES_QUALITY = 50 # Only for hole filling.
USER_VIEW_INIT = 0 # Only for hole filling.
-
+
is_editmode = (context.active_object.mode == 'EDIT')
if is_editmode:
obList = [ob for ob in [context.active_object] if ob and ob.type == 'MESH']
diff --git a/release/scripts/startup/bl_ui/properties_animviz.py b/release/scripts/startup/bl_ui/properties_animviz.py
index 43c01822b58..9782d5a072c 100644
--- a/release/scripts/startup/bl_ui/properties_animviz.py
+++ b/release/scripts/startup/bl_ui/properties_animviz.py
@@ -87,11 +87,11 @@ class MotionPathButtonsPanel:
col.label(text="Show:")
col.prop(mps, "show_frame_numbers", text="Frame Numbers")
if mpath is not None:
- col.prop(mpath, "lines", text='Lines')
- col.prop(mpath, "line_thickness", text='Thickness')
+ col.prop(mpath, "lines", text="Lines")
+ col.prop(mpath, "line_thickness", text="Thickness")
col = split.column()
- col.label('')
+ col.label("")
col.prop(mps, "show_keyframe_highlight", text="Keyframes")
sub = col.column()
sub.enabled = mps.show_keyframe_highlight
@@ -102,10 +102,10 @@ class MotionPathButtonsPanel:
# Customize path
if mpath is not None:
row = layout.row(align=True)
- row.prop(mpath, "use_custom_color", text='', toggle=True, icon='COLOR')
+ row.prop(mpath, "use_custom_color", text="", toggle=True, icon='COLOR')
sub = row.row(align=True)
sub.enabled = mpath.use_custom_color
- sub.prop(mpath, "color", text='')
+ sub.prop(mpath, "color", text="")
# FIXME: this panel still needs to be ported so that it will work correctly with animviz
diff --git a/release/scripts/startup/bl_ui/properties_constraint.py b/release/scripts/startup/bl_ui/properties_constraint.py
index 00892d5f85b..9b61101778f 100644
--- a/release/scripts/startup/bl_ui/properties_constraint.py
+++ b/release/scripts/startup/bl_ui/properties_constraint.py
@@ -886,10 +886,10 @@ class ConstraintButtonsPanel:
box.template_cache_file(con, "cache_file")
cache_file = con.cache_file
-
+
layout.label(text="Constraint Properties:")
box = layout.box()
-
+
if cache_file is not None:
box.prop_search(con, "object_path", cache_file, "object_paths")
diff --git a/release/scripts/startup/bl_ui/properties_data_armature.py b/release/scripts/startup/bl_ui/properties_data_armature.py
index ee159adfcef..bed8baf8210 100644
--- a/release/scripts/startup/bl_ui/properties_data_armature.py
+++ b/release/scripts/startup/bl_ui/properties_data_armature.py
@@ -96,7 +96,7 @@ class DATA_PT_display(ArmatureButtonsPanel, Panel):
col.prop(arm, "use_deform_delay", text="Delay Refresh")
-class DATA_PT_bone_group_specials(Menu):
+class DATA_MT_bone_group_specials(Menu):
bl_label = "Bone Group Specials"
def draw(self, context):
@@ -130,7 +130,7 @@ class DATA_PT_bone_groups(ArmatureButtonsPanel, Panel):
col.active = (ob.proxy is None)
col.operator("pose.group_add", icon='ZOOMIN', text="")
col.operator("pose.group_remove", icon='ZOOMOUT', text="")
- col.menu("DATA_PT_bone_group_specials", icon='DOWNARROW_HLT', text="")
+ col.menu("DATA_MT_bone_group_specials", icon='DOWNARROW_HLT', text="")
if group:
col.separator()
col.operator("pose.group_move", icon='TRIA_UP', text="").direction = 'UP'
@@ -178,6 +178,10 @@ class DATA_PT_pose_library(ArmatureButtonsPanel, Panel):
layout.template_ID(ob, "pose_library", new="poselib.new", unlink="poselib.unlink")
if poselib:
+ # warning about poselib being in an invalid state
+ if len(poselib.fcurves) > 0 and len(poselib.pose_markers) == 0:
+ layout.label(icon='ERROR', text="Error: Potentially corrupt library, run 'Sanitize' operator to fix")
+
# list of poses in pose library
row = layout.row()
row.template_list("UI_UL_list", "pose_markers", poselib, "pose_markers",
@@ -333,7 +337,7 @@ classes = (
DATA_PT_context_arm,
DATA_PT_skeleton,
DATA_PT_display,
- DATA_PT_bone_group_specials,
+ DATA_MT_bone_group_specials,
DATA_PT_bone_groups,
DATA_PT_pose_library,
DATA_PT_ghost,
diff --git a/release/scripts/startup/bl_ui/properties_data_lamp.py b/release/scripts/startup/bl_ui/properties_data_lamp.py
index bef2b2769d0..40ebdbda75d 100644
--- a/release/scripts/startup/bl_ui/properties_data_lamp.py
+++ b/release/scripts/startup/bl_ui/properties_data_lamp.py
@@ -258,7 +258,7 @@ class DATA_PT_shadow(DataButtonsPanel, Panel):
split = layout.split()
col = split.column()
- col.label(text="Form factor sampling:")
+ col.label(text="Form Factor Sampling:")
sub = col.row(align=True)
@@ -371,19 +371,48 @@ class DATA_PT_EEVEE_shadow(DataButtonsPanel, Panel):
lamp = context.lamp
+ split = layout.split()
+ split.active = lamp.use_shadow
+
+ sub = split.column()
+ col = sub.column(align=True)
+ col.prop(lamp, "shadow_buffer_clip_start", text="Clip Start")
+ col.prop(lamp, "shadow_buffer_clip_end", text="Clip End")
+ col = sub.column()
+ col.prop(lamp, "shadow_buffer_soft", text="Soft")
+
+ col = split.column(align=True)
+ col.prop(lamp, "shadow_buffer_bias", text="Bias")
+ col.prop(lamp, "shadow_buffer_exp", text="Exponent")
+ col.prop(lamp, "shadow_buffer_bleed_bias", text="Bleed Bias")
+
if lamp.type == 'SUN':
- layout.label("Comming Soon")
- else:
- split = layout.split()
- split.active = lamp.use_shadow
+ col = layout.column()
+ col.active = lamp.use_shadow
+ col.label("Cascaded Shadow Map:")
+
+ split = col.split()
- col = split.column(align=True)
- col.prop(lamp, "shadow_buffer_clip_start", text="Clip Start")
- col.prop(lamp, "shadow_buffer_clip_end", text="Clip End")
+ sub = split.column()
+ sub.prop(lamp, "shadow_cascade_count", text="Count")
+ sub.prop(lamp, "shadow_cascade_fade", text="Fade")
- col = split.column(align=True)
- col.prop(lamp, "shadow_buffer_bias", text="Bias")
- col.prop(lamp, "shadow_buffer_exp", text="Exponent")
+ sub = split.column()
+ sub.prop(lamp, "shadow_cascade_max_distance", text="Max Distance")
+ sub.prop(lamp, "shadow_cascade_exponent", text="Distribution")
+
+ layout.separator()
+
+ layout.prop(lamp, "use_contact_shadow")
+ split = layout.split()
+ split.active = lamp.use_contact_shadow
+ col = split.column()
+ col.prop(lamp, "contact_shadow_distance", text="Distance")
+ col.prop(lamp, "contact_shadow_soft_size", text="Soft")
+
+ col = split.column()
+ col.prop(lamp, "contact_shadow_bias", text="Bias")
+ col.prop(lamp, "contact_shadow_thickness", text="Thickness")
class DATA_PT_area(DataButtonsPanel, Panel):
diff --git a/release/scripts/startup/bl_ui/properties_data_lightprobe.py b/release/scripts/startup/bl_ui/properties_data_lightprobe.py
index cca5f823549..13af5139632 100644
--- a/release/scripts/startup/bl_ui/properties_data_lightprobe.py
+++ b/release/scripts/startup/bl_ui/properties_data_lightprobe.py
@@ -139,20 +139,6 @@ class DATA_PT_lightprobe_display(DataButtonsPanel, Panel):
ob = context.object
probe = context.lightprobe
- is_planar = (probe.type is "PLANAR")
-
- split = layout.split()
-
- col = split.column()
- col.prop(probe, "show_influence")
-
- col = split.column()
- col.active = is_planar
- col.prop(probe, "show_parallax")
-
- col = split.column()
- col.active = is_planar
- col.prop(probe, "show_clip")
row = layout.row()
row.prop(probe, "show_data")
@@ -162,6 +148,20 @@ class DATA_PT_lightprobe_display(DataButtonsPanel, Panel):
else:
row.prop(ob, "empty_draw_size", text="Arrow Size")
+ split = layout.split()
+
+ if probe.type in {'GRID', 'CUBEMAP'}:
+ col = split.column()
+ col.prop(probe, "show_influence")
+
+ col = split.column()
+ col.prop(probe, "show_clip")
+
+ if probe.type == 'CUBEMAP':
+ col = split.column()
+ col.active = probe.use_custom_parallax
+ col.prop(probe, "show_parallax")
+
classes = (
DATA_PT_context_lightprobe,
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 05321ee4486..32c758e9d02 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -146,9 +146,10 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
layout.row().prop(md, "offset_type", expand=True)
def BOOLEAN(self, layout, ob, md):
+ solver = md.solver
if not bpy.app.build_options.mod_boolean:
- layout.label("Built without Boolean modifier")
- return
+ if solver == 'CARVE':
+ layout.label("Built without Carve solver")
split = layout.split()
@@ -164,9 +165,13 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
split.column().label(text="Solver:")
split.column().prop(md, "solver", text="")
- if md.solver == 'BMESH':
+ if solver == 'BMESH':
layout.prop(md, "double_threshold")
+ if bpy.app.debug:
+ layout.prop(md, "debug_options")
+
+
def BUILD(self, layout, ob, md):
split = layout.split()
@@ -381,7 +386,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
split = layout.split()
col = split.column()
- col.label(text="Vertex group:")
+ col.label(text="Vertex Group:")
col.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
sub = col.column()
sub.active = bool(md.vertex_group)
@@ -566,8 +571,8 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
col = split.column()
col.label(text="Textures:")
- col.prop(md, "use_mirror_u", text="U")
- col.prop(md, "use_mirror_v", text="V")
+ col.prop(md, "use_mirror_u", text="Flip U")
+ col.prop(md, "use_mirror_v", text="Flip V")
col = layout.column(align=True)
@@ -577,6 +582,10 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
if md.use_mirror_v:
col.prop(md, "mirror_offset_v")
+ col = layout.column(align=True)
+ col.prop(md, "offset_u")
+ col.prop(md, "offset_v")
+
col = layout.column()
if md.use_mirror_merge is True:
@@ -747,6 +756,10 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
col.prop(md, "steps")
col.prop(md, "render_steps")
col.prop(md, "use_smooth_shade")
+ col.prop(md, "use_merge_vertices")
+ sub = col.column()
+ sub.active = md.use_merge_vertices
+ sub.prop(md, "merge_threshold")
col = split.column()
row = col.row()
@@ -917,9 +930,10 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
scene = bpy.context.scene
engine = scene.render.engine
- show_adaptive_options = (engine == "CYCLES" and md == ob.modifiers[-1] and
- scene.cycles.feature_set == "EXPERIMENTAL")
-
+ show_adaptive_options = (
+ engine == 'CYCLES' and md == ob.modifiers[-1] and
+ scene.cycles.feature_set == 'EXPERIMENTAL'
+ )
if show_adaptive_options:
col.label(text="View:")
col.prop(md, "levels", text="Levels")
diff --git a/release/scripts/startup/bl_ui/properties_freestyle.py b/release/scripts/startup/bl_ui/properties_freestyle.py
index 9c5be7624e0..3d105934bf8 100644
--- a/release/scripts/startup/bl_ui/properties_freestyle.py
+++ b/release/scripts/startup/bl_ui/properties_freestyle.py
@@ -123,7 +123,7 @@ class RENDERLAYER_PT_freestyle(RenderLayerFreestyleButtonsPanel, Panel):
layout.active = rl.use_freestyle
row = layout.row()
- layout.prop(freestyle, "mode", text="Control mode")
+ layout.prop(freestyle, "mode", text="Control Mode")
layout.prop(freestyle, "use_view_map_cache", text="View Map Cache")
layout.label(text="Edge Detection Options:")
@@ -285,7 +285,7 @@ class RENDERLAYER_PT_freestyle_linestyle(RenderLayerFreestyleEditorButtonsPanel,
def draw_modifier_box_error(self, box, modifier, message):
row = box.row()
- row.label(text=message, icon="ERROR")
+ row.label(text=message, icon='ERROR')
def draw_modifier_common(self, box, modifier):
row = box.row()
diff --git a/release/scripts/startup/bl_ui/properties_game.py b/release/scripts/startup/bl_ui/properties_game.py
index 7f33041e338..8ea64b53727 100644
--- a/release/scripts/startup/bl_ui/properties_game.py
+++ b/release/scripts/startup/bl_ui/properties_game.py
@@ -90,11 +90,11 @@ class PHYSICS_PT_game_physics(PhysicsButtonsPanel, Panel):
split = layout.split()
col = split.column()
- col.label(text="Linear velocity:")
+ col.label(text="Linear Velocity:")
sub = col.column(align=True)
sub.prop(game, "velocity_min", text="Minimum")
sub.prop(game, "velocity_max", text="Maximum")
- col.label(text="Angular velocity:")
+ col.label(text="Angular Velocity:")
sub = col.column(align=True)
sub.prop(game, "angular_velocity_min", text="Minimum")
sub.prop(game, "angular_velocity_max", text="Maximum")
diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index 52835a00796..2aa978a51d8 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -75,16 +75,16 @@ def gpencil_active_brush_settings_simple(context, layout):
col.prop(brush, "line_width", slider=True)
row = col.row(align=True)
- row.prop(brush, "use_random_pressure", text='', icon='RNDCURVE')
+ row.prop(brush, "use_random_pressure", text="", icon='RNDCURVE')
row.prop(brush, "pen_sensitivity_factor", slider=True)
- row.prop(brush, "use_pressure", text='', icon='STYLUS_PRESSURE')
+ row.prop(brush, "use_pressure", text="", icon='STYLUS_PRESSURE')
row = col.row(align=True)
- row.prop(brush, "use_random_strength", text='', icon='RNDCURVE')
+ row.prop(brush, "use_random_strength", text="", icon='RNDCURVE')
row.prop(brush, "strength", slider=True)
- row.prop(brush, "use_strength_pressure", text='', icon='STYLUS_PRESSURE')
+ row.prop(brush, "use_strength_pressure", text="", icon='STYLUS_PRESSURE')
row = col.row(align=True)
row.prop(brush, "jitter", slider=True)
- row.prop(brush, "use_jitter_pressure", text='', icon='STYLUS_PRESSURE')
+ row.prop(brush, "use_jitter_pressure", text="", icon='STYLUS_PRESSURE')
row = col.row()
row.prop(brush, "angle", slider=True)
row.prop(brush, "angle_factor", text="Factor", slider=True)
@@ -340,19 +340,19 @@ class GreasePencilBrushPanel:
row = layout.row()
row.prop(brush, "line_width")
row = layout.row(align=True)
- row.prop(brush, "use_random_pressure", text='', icon='RNDCURVE')
+ row.prop(brush, "use_random_pressure", text="", icon='RNDCURVE')
row.prop(brush, "pen_sensitivity_factor", slider=True)
- row.prop(brush, "use_pressure", text='', icon='STYLUS_PRESSURE')
+ row.prop(brush, "use_pressure", text="", icon='STYLUS_PRESSURE')
row = layout.row(align=True)
- row.prop(brush, "use_random_strength", text='', icon='RNDCURVE')
+ row.prop(brush, "use_random_strength", text="", icon='RNDCURVE')
row.prop(brush, "strength", slider=True)
- row.prop(brush, "use_strength_pressure", text='', icon='STYLUS_PRESSURE')
+ row.prop(brush, "use_strength_pressure", text="", icon='STYLUS_PRESSURE')
row = layout.row(align=True)
row.prop(brush, "random_press", slider=True)
row = layout.row(align=True)
row.prop(brush, "jitter", slider=True)
- row.prop(brush, "use_jitter_pressure", text='', icon='STYLUS_PRESSURE')
+ row.prop(brush, "use_jitter_pressure", text="", icon='STYLUS_PRESSURE')
row = layout.row()
row.prop(brush, "angle", slider=True)
row.prop(brush, "angle_factor", text="Factor", slider=True)
@@ -365,7 +365,7 @@ class GreasePencilBrushPanel:
col.separator()
row = col.row(align=False)
row.prop(brush, "pen_subdivision_steps")
- row.prop(brush, "random_subdiv", text='Randomness', slider=True)
+ row.prop(brush, "random_subdiv", text="Randomness", slider=True)
class GreasePencilStrokeSculptPanel:
@@ -463,7 +463,7 @@ class GreasePencilBrushCurvesPanel:
###############################
-class GPENCIL_PIE_tool_palette(Menu):
+class GPENCIL_MT_pie_tool_palette(Menu):
"""A pie menu for quick access to Grease Pencil tools"""
bl_label = "Grease Pencil Tools"
@@ -487,7 +487,7 @@ class GPENCIL_PIE_tool_palette(Menu):
# E - "Settings" Palette is included here too, since it needs to be in a stable position...
if gpd and gpd.layers.active:
col.separator()
- col.operator("wm.call_menu_pie", text="Settings...", icon='SCRIPTWIN').name = "GPENCIL_PIE_settings_palette"
+ col.operator("wm.call_menu_pie", text="Settings...", icon='SCRIPTWIN').name = "GPENCIL_MT_pie_settings_palette"
# Editing tools
if gpd:
@@ -525,13 +525,13 @@ class GPENCIL_PIE_tool_palette(Menu):
col.operator("gpencil.delete", icon='X', text="Delete...")
# SE - More Tools
- pie.operator("wm.call_menu_pie", text="More...").name = "GPENCIL_PIE_tools_more"
+ pie.operator("wm.call_menu_pie", text="More...").name = "GPENCIL_MT_pie_tools_more"
else:
# Toggle Edit Mode
pie.operator("gpencil.editmode_toggle", text="Enable Stroke Editing", icon='EDIT')
-class GPENCIL_PIE_settings_palette(Menu):
+class GPENCIL_MT_pie_settings_palette(Menu):
"""A pie menu for quick access to Grease Pencil settings"""
bl_label = "Grease Pencil Settings"
@@ -609,12 +609,12 @@ class GPENCIL_PIE_settings_palette(Menu):
row = col.row()
row.operator("gpencil.stroke_join", text="Join").type = 'JOIN'
row.operator("gpencil.stroke_join", text="Join & Copy").type = 'JOINCOPY'
- col.operator("gpencil.stroke_flip", text="Flip direction")
+ col.operator("gpencil.stroke_flip", text="Flip Direction")
- col.prop(gpd, "show_stroke_direction", text="Show drawing direction")
+ col.prop(gpd, "show_stroke_direction", text="Show Drawing Direction")
-class GPENCIL_PIE_tools_more(Menu):
+class GPENCIL_MT_pie_tools_more(Menu):
"""A pie menu for accessing more Grease Pencil tools"""
bl_label = "More Grease Pencil Tools"
@@ -643,10 +643,10 @@ class GPENCIL_PIE_tools_more(Menu):
pie.operator("transform.tosphere", icon='MOD_MULTIRES')
pie.operator("gpencil.convert", icon='OUTLINER_OB_CURVE', text="Convert...")
- pie.operator("wm.call_menu_pie", text="Back to Main Palette...").name = "GPENCIL_PIE_tool_palette"
+ pie.operator("wm.call_menu_pie", text="Back to Main Palette...").name = "GPENCIL_MT_pie_tool_palette"
-class GPENCIL_PIE_sculpt(Menu):
+class GPENCIL_MT_pie_sculpt(Menu):
"""A pie menu for accessing Grease Pencil stroke sculpting settings"""
bl_label = "Grease Pencil Sculpt"
@@ -839,8 +839,8 @@ class GPENCIL_MT_brush_specials(Menu):
def draw(self, context):
layout = self.layout
- layout.operator("gpencil.brush_copy", icon='PASTEDOWN', text="Copy current drawing brush")
- layout.operator("gpencil.brush_presets_create", icon='HELP', text="Create a set of predefined brushes")
+ layout.operator("gpencil.brush_copy", icon='PASTEDOWN', text="Copy Current Drawing Brush")
+ layout.operator("gpencil.brush_presets_create", icon='HELP', text="Create a Set of Predefined Brushes")
class GPENCIL_MT_palettecolor_specials(Menu):
@@ -1158,10 +1158,10 @@ class GreasePencilToolsPanel:
classes = (
- GPENCIL_PIE_tool_palette,
- GPENCIL_PIE_settings_palette,
- GPENCIL_PIE_tools_more,
- GPENCIL_PIE_sculpt,
+ GPENCIL_MT_pie_tool_palette,
+ GPENCIL_MT_pie_settings_palette,
+ GPENCIL_MT_pie_tools_more,
+ GPENCIL_MT_pie_sculpt,
GPENCIL_MT_snap,
GPENCIL_MT_gpencil_edit_specials,
GPENCIL_UL_brush,
diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py
index 2991dc110ee..29cb2466ee5 100644
--- a/release/scripts/startup/bl_ui/properties_material.py
+++ b/release/scripts/startup/bl_ui/properties_material.py
@@ -1120,10 +1120,12 @@ def panel_node_draw(layout, ntree, output_type):
if node:
input = find_node_input(node, 'Surface')
- layout.template_node_view(ntree, node, input)
- return True
-
- return False
+ if input:
+ layout.template_node_view(ntree, node, input)
+ else:
+ layout.label(text="Incompatible output node")
+ else:
+ layout.label(text="No output node")
class EEVEE_MATERIAL_PT_surface(MaterialButtonsPanel, Panel):
@@ -1145,8 +1147,7 @@ class EEVEE_MATERIAL_PT_surface(MaterialButtonsPanel, Panel):
layout.separator()
if mat.use_nodes:
- if not panel_node_draw(layout, mat.node_tree, 'OUTPUT_EEVEE_MATERIAL'):
- layout.label(text="No output node")
+ panel_node_draw(layout, mat.node_tree, ('OUTPUT_EEVEE_MATERIAL', 'OUTPUT_MATERIAL'))
else:
raym = mat.raytrace_mirror
layout.prop(mat, "diffuse_color", text="Base Color")
@@ -1155,6 +1156,37 @@ class EEVEE_MATERIAL_PT_surface(MaterialButtonsPanel, Panel):
layout.prop(raym, "gloss_factor", text="Roughness")
+class EEVEE_MATERIAL_PT_options(MaterialButtonsPanel, Panel):
+ bl_label = "Options"
+ bl_context = "material"
+ COMPAT_ENGINES = {'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ engine = context.scene.render.engine
+ return context.material and (engine in cls.COMPAT_ENGINES)
+
+ def draw(self, context):
+ layout = self.layout
+
+ mat = context.material
+
+ layout.prop(mat, "blend_method")
+
+ if mat.blend_method != "OPAQUE":
+ layout.prop(mat, "transparent_shadow_method")
+
+ row = layout.row()
+ row.active = ((mat.blend_method == "CLIP") or (mat.transparent_shadow_method == "CLIP"))
+ layout.prop(mat, "alpha_threshold")
+
+ if mat.blend_method not in {"OPAQUE", "CLIP", "HASHED"}:
+ layout.prop(mat, "transparent_hide_backside")
+
+ layout.prop(mat, "use_screen_refraction")
+ layout.prop(mat, "refraction_depth")
+
+
classes = (
MATERIAL_MT_sss_presets,
MATERIAL_MT_specials,
@@ -1185,6 +1217,7 @@ classes = (
MATERIAL_PT_custom_props,
EEVEE_MATERIAL_PT_context_material,
EEVEE_MATERIAL_PT_surface,
+ EEVEE_MATERIAL_PT_options,
)
if __name__ == "__main__": # only for live edit.
diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py
index 5311e893773..0d8309268fb 100644
--- a/release/scripts/startup/bl_ui/properties_object.py
+++ b/release/scripts/startup/bl_ui/properties_object.py
@@ -40,7 +40,7 @@ class OBJECT_PT_context_object(ObjectButtonsPanel, Panel):
layout.template_ID(space, "pin_id")
else:
row = layout.row()
- row.template_ID(context.scene.objects, "active")
+ row.template_ID(context.render_layer.objects, "active")
class OBJECT_PT_transform(ObjectButtonsPanel, Panel):
diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index 91f4239c067..bc8bc523e12 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -157,9 +157,9 @@ def brush_texpaint_common(panel, context, layout, brush, settings, projpaint=Fal
col.separator()
if projpaint:
if settings.mode == 'MATERIAL':
- col.prop(settings, "use_clone_layer", text="Clone from paint slot")
+ col.prop(settings, "use_clone_layer", text="Clone from Paint Slot")
elif settings.mode == 'IMAGE':
- col.prop(settings, "use_clone_layer", text="Clone from image/UV map")
+ col.prop(settings, "use_clone_layer", text="Clone from Image/UV Map")
if settings.use_clone_layer:
ob = context.active_object
diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py
index c9012e46698..68f040fb8aa 100644
--- a/release/scripts/startup/bl_ui/properties_particle.py
+++ b/release/scripts/startup/bl_ui/properties_particle.py
@@ -628,7 +628,7 @@ class PARTICLE_PT_physics(ParticleButtonsPanel, Panel):
split = layout.split()
col = split.column()
- col.label(text="Fluid properties:")
+ col.label(text="Fluid Properties:")
col.prop(fluid, "stiffness", text="Stiffness")
col.prop(fluid, "linear_viscosity", text="Viscosity")
col.prop(fluid, "buoyancy", text="Buoyancy", slider=True)
@@ -749,7 +749,7 @@ class PARTICLE_PT_physics(ParticleButtonsPanel, Panel):
if part.physics_type == 'BOIDS':
layout.label(text="Relations:")
elif part.physics_type == 'FLUID':
- layout.label(text="Fluid interaction:")
+ layout.label(text="Fluid Interaction:")
row = layout.row()
row.template_list("UI_UL_list", "particle_targets", psys, "targets",
@@ -1081,7 +1081,7 @@ class PARTICLE_PT_render(ParticleButtonsPanel, Panel):
col = row.column()
col.prop(part, "trail_count")
if part.trail_count > 1:
- col.prop(part, "use_absolute_path_time", text="Length in frames")
+ col.prop(part, "use_absolute_path_time", text="Length in Frames")
col = row.column()
col.prop(part, "path_end", text="Length", slider=not part.use_absolute_path_time)
col.prop(part, "length_random", text="Random", slider=True)
diff --git a/release/scripts/startup/bl_ui/properties_physics_common.py b/release/scripts/startup/bl_ui/properties_physics_common.py
index 0b98d8738dc..73d3d5fc755 100644
--- a/release/scripts/startup/bl_ui/properties_physics_common.py
+++ b/release/scripts/startup/bl_ui/properties_physics_common.py
@@ -79,7 +79,7 @@ class PHYSICS_PT_add(PhysicButtonsPanel, Panel):
col = split.column()
- if obj.type in {'MESH', 'LATTICE', 'CURVE'}:
+ if obj.type in {'MESH', 'LATTICE', 'CURVE', 'SURFACE', 'FONT'}:
physics_add(self, col, context.soft_body, "Soft Body", 'SOFT_BODY', 'MOD_SOFT', True)
if obj.type == 'MESH':
diff --git a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
index 538022a0fcf..767eb185d8e 100644
--- a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
+++ b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
@@ -245,7 +245,7 @@ class PHYSICS_PT_dp_canvas_output(PhysicButtonsPanel, Panel):
# paint-map output
row = layout.row()
- row.prop_search(surface, "output_name_a", ob.data, "vertex_colors", text="Paintmap layer")
+ row.prop_search(surface, "output_name_a", ob.data, "vertex_colors", text="Paintmap Layer")
if surface.output_exists(object=ob, index=0):
ic = 'ZOOMOUT'
else:
@@ -255,7 +255,7 @@ class PHYSICS_PT_dp_canvas_output(PhysicButtonsPanel, Panel):
# wet-map output
row = layout.row()
- row.prop_search(surface, "output_name_b", ob.data, "vertex_colors", text="Wetmap layer")
+ row.prop_search(surface, "output_name_b", ob.data, "vertex_colors", text="Wetmap Layer")
if surface.output_exists(object=ob, index=1):
ic = 'ZOOMOUT'
else:
@@ -282,7 +282,7 @@ class PHYSICS_PT_dp_canvas_output(PhysicButtonsPanel, Panel):
layout.prop(surface, "image_output_path", text="")
row = layout.row()
row.prop(surface, "image_fileformat", text="")
- row.prop(surface, "use_premultiply", text="Premultiply alpha")
+ row.prop(surface, "use_premultiply", text="Premultiply Alpha")
if surface_type == 'PAINT':
split = layout.split(percentage=0.4)
@@ -439,12 +439,12 @@ class PHYSICS_PT_dp_brush_source(PhysicButtonsPanel, Panel):
if brush.paint_source == 'PARTICLE_SYSTEM':
col.prop_search(brush, "particle_system", ob, "particle_systems", text="")
if brush.particle_system:
- col.label(text="Particle effect:")
+ col.label(text="Particle Effect:")
sub = col.column()
sub.active = not brush.use_particle_radius
sub.prop(brush, "solid_radius", text="Solid Radius")
col.prop(brush, "use_particle_radius", text="Use Particle's Radius")
- col.prop(brush, "smooth_radius", text="Smooth radius")
+ col.prop(brush, "smooth_radius", text="Smooth Radius")
if brush.paint_source in {'DISTANCE', 'VOLUME_DISTANCE', 'POINT'}:
col.prop(brush, "paint_distance", text="Paint Distance")
diff --git a/release/scripts/startup/bl_ui/properties_physics_softbody.py b/release/scripts/startup/bl_ui/properties_physics_softbody.py
index 5ce4302891d..5efe105e7d8 100644
--- a/release/scripts/startup/bl_ui/properties_physics_softbody.py
+++ b/release/scripts/startup/bl_ui/properties_physics_softbody.py
@@ -26,6 +26,9 @@ from bl_ui.properties_physics_common import (
)
+COMPAT_OB_TYPES = {'MESH', 'LATTICE', 'CURVE', 'SURFACE', 'FONT'}
+
+
def softbody_panel_enabled(md):
return (md.point_cache.is_baked is False)
@@ -39,7 +42,7 @@ class PhysicButtonsPanel:
def poll(cls, context):
ob = context.object
rd = context.scene.render
- return (ob and (ob.type == 'MESH' or ob.type == 'LATTICE'or ob.type == 'CURVE')) and (rd.engine in cls.COMPAT_ENGINES) and (context.soft_body)
+ return ob and ob.type in COMPAT_OB_TYPES and rd.engine in cls.COMPAT_ENGINES and context.soft_body
class PHYSICS_PT_softbody(PhysicButtonsPanel, Panel):
diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py
index bd599bc0cb4..6957f9b7f15 100644
--- a/release/scripts/startup/bl_ui/properties_render.py
+++ b/release/scripts/startup/bl_ui/properties_render.py
@@ -79,7 +79,7 @@ class RENDER_PT_render(RenderButtonsPanel, Panel):
class RENDER_PT_dimensions(RenderButtonsPanel, Panel):
bl_label = "Dimensions"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
_frame_rate_args_prev = None
_preset_class = None
@@ -275,6 +275,7 @@ class RENDER_PT_performance(RenderButtonsPanel, Panel):
col.separator()
col.prop(rd, "preview_start_resolution")
+ col.prop(rd, "preview_pixel_size", text="")
col = split.column()
col.label(text="Memory:")
@@ -286,7 +287,7 @@ class RENDER_PT_performance(RenderButtonsPanel, Panel):
sub.prop(rd, "use_free_image_textures")
sub = col.column()
sub.active = rd.use_raytrace
- sub.label(text="Acceleration structure:")
+ sub.label(text="Acceleration Structure:")
sub.prop(rd, "raytrace_method", text="")
if rd.raytrace_method == 'OCTREE':
sub.prop(rd, "octree_resolution", text="Resolution")
@@ -335,7 +336,7 @@ class RENDER_PT_post_processing(RenderButtonsPanel, Panel):
class RENDER_PT_stamp(RenderButtonsPanel, Panel):
bl_label = "Metadata"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -347,7 +348,7 @@ class RENDER_PT_stamp(RenderButtonsPanel, Panel):
col.active = rd.use_stamp
row = col.row()
row.prop(rd, "stamp_font_size", text="Font Size")
- row.prop(rd, "use_stamp_labels", text="Draw labels")
+ row.prop(rd, "use_stamp_labels", text="Draw Labels")
row = col.row()
row.column().prop(rd, "stamp_foreground", slider=True)
@@ -383,7 +384,7 @@ class RENDER_PT_stamp(RenderButtonsPanel, Panel):
class RENDER_PT_output(RenderButtonsPanel, Panel):
bl_label = "Output"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -409,37 +410,6 @@ class RENDER_PT_output(RenderButtonsPanel, Panel):
if rd.use_multiview:
layout.template_image_views(image_settings)
- if file_format == 'QUICKTIME':
- quicktime = rd.quicktime
-
- split = layout.split()
- col = split.column()
- col.prop(quicktime, "codec_type", text="Video Codec")
- col.prop(quicktime, "codec_spatial_quality", text="Quality")
-
- # Audio
- col.prop(quicktime, "audiocodec_type", text="Audio Codec")
- if quicktime.audiocodec_type != 'No audio':
- split = layout.split()
- if quicktime.audiocodec_type == 'LPCM':
- split.prop(quicktime, "audio_bitdepth", text="")
-
- split.prop(quicktime, "audio_samplerate", text="")
-
- split = layout.split()
- col = split.column()
- if quicktime.audiocodec_type == 'AAC':
- col.prop(quicktime, "audio_bitrate")
-
- subsplit = split.split()
- col = subsplit.column()
-
- if quicktime.audiocodec_type == 'AAC':
- col.prop(quicktime, "audio_codec_isvbr")
-
- col = subsplit.column()
- col.prop(quicktime, "audio_resampling_hq")
-
class RENDER_PT_encoding(RenderButtonsPanel, Panel):
bl_label = "Encoding"
@@ -482,9 +452,9 @@ class RENDER_PT_encoding(RenderButtonsPanel, Panel):
layout.prop(ffmpeg, "gopsize")
# B-Frames
row = layout.row()
- row.prop(ffmpeg, "use_max_b_frames", text='Max B-frames')
+ row.prop(ffmpeg, "use_max_b_frames", text="Max B-frames")
pbox = row.split()
- pbox.prop(ffmpeg, "max_b_frames", text='')
+ pbox.prop(ffmpeg, "max_b_frames", text="")
pbox.enabled = ffmpeg.use_max_b_frames
split = layout.split()
@@ -616,8 +586,10 @@ class RENDER_PT_clay_collection_settings(RenderButtonsPanel, Panel):
col.prop(props, "ssao_attenuation")
col.prop(props, "hair_brightness_randomness")
-class RENDER_PT_eevee_poststack_settings(RenderButtonsPanel, Panel):
- bl_label = "Post Process Stack"
+
+class RENDER_PT_eevee_ambient_occlusion(RenderButtonsPanel, Panel):
+ bl_label = "Ambient Occlusion"
+ bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_EEVEE'}
@classmethod
@@ -625,20 +597,30 @@ class RENDER_PT_eevee_poststack_settings(RenderButtonsPanel, Panel):
scene = context.scene
return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+ def draw_header(self, context):
+ scene = context.scene
+ props = scene.layer_properties['BLENDER_EEVEE']
+ self.layout.prop(props, "gtao_enable", text="")
+
def draw(self, context):
layout = self.layout
scene = context.scene
props = scene.layer_properties['BLENDER_EEVEE']
+ layout.active = props.gtao_enable
col = layout.column()
- col.prop(props, "gtao_enable")
- col.prop(props, "motion_blur_enable")
- col.prop(props, "dof_enable")
- col.prop(props, "bloom_enable")
+ col.prop(props, "gtao_use_bent_normals")
+ col.prop(props, "gtao_denoise")
+ col.prop(props, "gtao_bounce")
+ col.prop(props, "gtao_samples")
+ col.prop(props, "gtao_distance")
+ col.prop(props, "gtao_factor")
+ col.prop(props, "gtao_quality")
-class RENDER_PT_eevee_postprocess_settings(RenderButtonsPanel, Panel):
- bl_label = "Post Process Settings"
+class RENDER_PT_eevee_motion_blur(RenderButtonsPanel, Panel):
+ bl_label = "Motion Blur"
+ bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_EEVEE'}
@classmethod
@@ -646,35 +628,200 @@ class RENDER_PT_eevee_postprocess_settings(RenderButtonsPanel, Panel):
scene = context.scene
return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+ def draw_header(self, context):
+ scene = context.scene
+ props = scene.layer_properties['BLENDER_EEVEE']
+ self.layout.prop(props, "motion_blur_enable", text="")
+
def draw(self, context):
layout = self.layout
scene = context.scene
props = scene.layer_properties['BLENDER_EEVEE']
+ layout.active = props.motion_blur_enable
col = layout.column()
-
- col.label("Ambient Occlusion:")
- col.prop(props, "gtao_use_bent_normals")
- col.prop(props, "gtao_samples")
- col.prop(props, "gtao_distance")
- col.prop(props, "gtao_factor")
- col.separator()
-
- col.label("Motion Blur:")
col.prop(props, "motion_blur_samples")
col.prop(props, "motion_blur_shutter")
- col.separator()
- col.label("Depth of Field:")
+
+class RENDER_PT_eevee_depth_of_field(RenderButtonsPanel, Panel):
+ bl_label = "Depth of Field"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ scene = context.scene
+ return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+
+ def draw_header(self, context):
+ scene = context.scene
+ props = scene.layer_properties['BLENDER_EEVEE']
+ self.layout.prop(props, "dof_enable", text="")
+
+ def draw(self, context):
+ layout = self.layout
+ scene = context.scene
+ props = scene.layer_properties['BLENDER_EEVEE']
+
+ layout.active = props.dof_enable
+ col = layout.column()
col.prop(props, "bokeh_max_size")
col.prop(props, "bokeh_threshold")
- col.separator()
- col.label("Bloom:")
+
+class RENDER_PT_eevee_bloom(RenderButtonsPanel, Panel):
+ bl_label = "Bloom"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ scene = context.scene
+ return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+
+ def draw_header(self, context):
+ scene = context.scene
+ props = scene.layer_properties['BLENDER_EEVEE']
+ self.layout.prop(props, "bloom_enable", text="")
+
+ def draw(self, context):
+ layout = self.layout
+ scene = context.scene
+ props = scene.layer_properties['BLENDER_EEVEE']
+
+ layout.active = props.bloom_enable
+ col = layout.column()
col.prop(props, "bloom_threshold")
col.prop(props, "bloom_knee")
col.prop(props, "bloom_radius")
+ col.prop(props, "bloom_color")
col.prop(props, "bloom_intensity")
+ col.prop(props, "bloom_clamp")
+
+
+class RENDER_PT_eevee_volumetric(RenderButtonsPanel, Panel):
+ bl_label = "Volumetric"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ scene = context.scene
+ return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+
+ def draw_header(self, context):
+ scene = context.scene
+ props = scene.layer_properties['BLENDER_EEVEE']
+ self.layout.prop(props, "volumetric_enable", text="")
+
+ def draw(self, context):
+ layout = self.layout
+ scene = context.scene
+ props = scene.layer_properties['BLENDER_EEVEE']
+
+ layout.active = props.volumetric_enable
+ col = layout.column()
+ col.prop(props, "volumetric_start")
+ col.prop(props, "volumetric_end")
+ col.prop(props, "volumetric_samples")
+ col.prop(props, "volumetric_sample_distribution")
+ col.prop(props, "volumetric_lights")
+ col.prop(props, "volumetric_light_clamp")
+ col.prop(props, "volumetric_shadows")
+ col.prop(props, "volumetric_shadow_samples")
+ col.prop(props, "volumetric_colored_transmittance")
+
+
+class RENDER_PT_eevee_screen_space_reflections(RenderButtonsPanel, Panel):
+ bl_label = "Screen Space Reflections"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ scene = context.scene
+ return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+
+ def draw_header(self, context):
+ scene = context.scene
+ props = scene.layer_properties['BLENDER_EEVEE']
+ self.layout.prop(props, "ssr_enable", text="")
+
+ def draw(self, context):
+ layout = self.layout
+ scene = context.scene
+ props = scene.layer_properties['BLENDER_EEVEE']
+
+ col = layout.column()
+ col.active = props.ssr_enable
+ col.prop(props, "ssr_refraction")
+ col.prop(props, "ssr_halfres")
+ col.prop(props, "ssr_ray_count")
+ col.prop(props, "ssr_quality")
+ col.prop(props, "ssr_max_roughness")
+ col.prop(props, "ssr_thickness")
+ col.prop(props, "ssr_border_fade")
+ col.prop(props, "ssr_firefly_fac")
+
+
+class RENDER_PT_eevee_shadows(RenderButtonsPanel, Panel):
+ bl_label = "Shadows"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ scene = context.scene
+ return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+
+ def draw(self, context):
+ layout = self.layout
+ scene = context.scene
+ props = scene.layer_properties['BLENDER_EEVEE']
+
+ col = layout.column()
+ col.prop(props, "shadow_method")
+ col.prop(props, "shadow_size")
+ col.prop(props, "shadow_high_bitdepth")
+
+
+class RENDER_PT_eevee_sampling(RenderButtonsPanel, Panel):
+ bl_label = "Sampling"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ scene = context.scene
+ return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+
+ def draw(self, context):
+ layout = self.layout
+ scene = context.scene
+ props = scene.layer_properties['BLENDER_EEVEE']
+
+ col = layout.column()
+ col.prop(props, "taa_samples")
+
+
+class RENDER_PT_eevee_indirect_lighting(RenderButtonsPanel, Panel):
+ bl_label = "Indirect Lighting"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ scene = context.scene
+ return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+
+ def draw(self, context):
+ layout = self.layout
+ scene = context.scene
+ props = scene.layer_properties['BLENDER_EEVEE']
+
+ col = layout.column()
+ col.prop(props, "gi_diffuse_bounces")
classes = (
@@ -694,8 +841,15 @@ classes = (
RENDER_PT_bake,
RENDER_PT_clay_layer_settings,
RENDER_PT_clay_collection_settings,
- RENDER_PT_eevee_poststack_settings,
- RENDER_PT_eevee_postprocess_settings,
+ RENDER_PT_eevee_sampling,
+ RENDER_PT_eevee_shadows,
+ RENDER_PT_eevee_indirect_lighting,
+ RENDER_PT_eevee_screen_space_reflections,
+ RENDER_PT_eevee_ambient_occlusion,
+ RENDER_PT_eevee_volumetric,
+ RENDER_PT_eevee_motion_blur,
+ RENDER_PT_eevee_depth_of_field,
+ RENDER_PT_eevee_bloom,
)
if __name__ == "__main__": # only for live edit.
diff --git a/release/scripts/startup/bl_ui/properties_render_layer.py b/release/scripts/startup/bl_ui/properties_render_layer.py
index 4de48f00b04..a53de764405 100644
--- a/release/scripts/startup/bl_ui/properties_render_layer.py
+++ b/release/scripts/startup/bl_ui/properties_render_layer.py
@@ -150,8 +150,9 @@ class RENDERLAYER_PT_clay_settings(RenderLayerButtonsPanel, Panel):
col.template_override_property(layer_props, scene_props, "ssao_samples")
-class RENDERLAYER_PT_eevee_poststack_settings(RenderLayerButtonsPanel, Panel):
- bl_label = "Post Process Stack"
+class RENDERLAYER_PT_eevee_ambient_occlusion(RenderLayerButtonsPanel, Panel):
+ bl_label = "Ambient Occlusion"
+ bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_EEVEE'}
@classmethod
@@ -159,6 +160,14 @@ class RENDERLAYER_PT_eevee_poststack_settings(RenderLayerButtonsPanel, Panel):
scene = context.scene
return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+ def draw_header(self, context):
+ scene = context.scene
+ scene_props = scene.layer_properties['BLENDER_EEVEE']
+ layer = bpy.context.render_layer
+ layer_props = layer.engine_overrides['BLENDER_EEVEE']
+
+ self.layout.template_override_property(layer_props, scene_props, "gtao_enable", text="")
+
def draw(self, context):
layout = self.layout
scene = context.scene
@@ -167,14 +176,18 @@ class RENDERLAYER_PT_eevee_poststack_settings(RenderLayerButtonsPanel, Panel):
layer_props = layer.engine_overrides['BLENDER_EEVEE']
col = layout.column()
- col.template_override_property(layer_props, scene_props, "gtao_enable")
- col.template_override_property(layer_props, scene_props, "motion_blur_enable")
- col.template_override_property(layer_props, scene_props, "dof_enable")
- col.template_override_property(layer_props, scene_props, "bloom_enable")
+ col.template_override_property(layer_props, scene_props, "gtao_use_bent_normals")
+ col.template_override_property(layer_props, scene_props, "gtao_denoise")
+ col.template_override_property(layer_props, scene_props, "gtao_bounce")
+ col.template_override_property(layer_props, scene_props, "gtao_samples")
+ col.template_override_property(layer_props, scene_props, "gtao_distance")
+ col.template_override_property(layer_props, scene_props, "gtao_factor")
+ col.template_override_property(layer_props, scene_props, "gtao_quality")
-class RENDERLAYER_PT_eevee_postprocess_settings(RenderLayerButtonsPanel, Panel):
- bl_label = "Post Process Settings"
+class RENDERLAYER_PT_eevee_motion_blur(RenderLayerButtonsPanel, Panel):
+ bl_label = "Motion Blur"
+ bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_EEVEE'}
@classmethod
@@ -182,6 +195,14 @@ class RENDERLAYER_PT_eevee_postprocess_settings(RenderLayerButtonsPanel, Panel):
scene = context.scene
return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+ def draw_header(self, context):
+ scene = context.scene
+ scene_props = scene.layer_properties['BLENDER_EEVEE']
+ layer = bpy.context.render_layer
+ layer_props = layer.engine_overrides['BLENDER_EEVEE']
+
+ self.layout.template_override_property(layer_props, scene_props, "motion_blur_enable", text="")
+
def draw(self, context):
layout = self.layout
scene = context.scene
@@ -190,28 +211,210 @@ class RENDERLAYER_PT_eevee_postprocess_settings(RenderLayerButtonsPanel, Panel):
layer_props = layer.engine_overrides['BLENDER_EEVEE']
col = layout.column()
- col.label("Ambient Occlusion:")
- col.template_override_property(layer_props, scene_props, "gtao_use_bent_normals")
- col.template_override_property(layer_props, scene_props, "gtao_samples")
- col.template_override_property(layer_props, scene_props, "gtao_distance")
- col.template_override_property(layer_props, scene_props, "gtao_factor")
- col.separator()
-
- col.label("Motion Blur:")
col.template_override_property(layer_props, scene_props, "motion_blur_samples")
col.template_override_property(layer_props, scene_props, "motion_blur_shutter")
- col.separator()
- col.label("Depth of Field:")
+
+class RENDERLAYER_PT_eevee_depth_of_field(RenderLayerButtonsPanel, Panel):
+ bl_label = "Depth Of Field"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ scene = context.scene
+ return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+
+ def draw_header(self, context):
+ scene = context.scene
+ scene_props = scene.layer_properties['BLENDER_EEVEE']
+ layer = bpy.context.render_layer
+ layer_props = layer.engine_overrides['BLENDER_EEVEE']
+
+ self.layout.template_override_property(layer_props, scene_props, "dof_enable", text="")
+
+ def draw(self, context):
+ layout = self.layout
+ scene = context.scene
+ scene_props = scene.layer_properties['BLENDER_EEVEE']
+ layer = bpy.context.render_layer
+ layer_props = layer.engine_overrides['BLENDER_EEVEE']
+
+ col = layout.column()
col.template_override_property(layer_props, scene_props, "bokeh_max_size")
col.template_override_property(layer_props, scene_props, "bokeh_threshold")
- col.separator()
- col.label("Bloom:")
+
+class RENDERLAYER_PT_eevee_bloom(RenderLayerButtonsPanel, Panel):
+ bl_label = "Bloom"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ scene = context.scene
+ return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+
+ def draw_header(self, context):
+ scene = context.scene
+ scene_props = scene.layer_properties['BLENDER_EEVEE']
+ layer = bpy.context.render_layer
+ layer_props = layer.engine_overrides['BLENDER_EEVEE']
+
+ self.layout.template_override_property(layer_props, scene_props, "bloom_enable", text="")
+
+ def draw(self, context):
+ layout = self.layout
+ scene = context.scene
+ scene_props = scene.layer_properties['BLENDER_EEVEE']
+ layer = bpy.context.render_layer
+ layer_props = layer.engine_overrides['BLENDER_EEVEE']
+
+ col = layout.column()
col.template_override_property(layer_props, scene_props, "bloom_threshold")
col.template_override_property(layer_props, scene_props, "bloom_knee")
col.template_override_property(layer_props, scene_props, "bloom_radius")
+ col.template_override_property(layer_props, scene_props, "bloom_color")
col.template_override_property(layer_props, scene_props, "bloom_intensity")
+ col.template_override_property(layer_props, scene_props, "bloom_clamp")
+
+
+class RENDERLAYER_PT_eevee_volumetric(RenderLayerButtonsPanel, Panel):
+ bl_label = "Volumetric"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ scene = context.scene
+ return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+
+ def draw_header(self, context):
+ scene = context.scene
+ scene_props = scene.layer_properties['BLENDER_EEVEE']
+ layer = bpy.context.render_layer
+ layer_props = layer.engine_overrides['BLENDER_EEVEE']
+
+ self.layout.template_override_property(layer_props, scene_props, "volumetric_enable", text="")
+
+ def draw(self, context):
+ layout = self.layout
+ scene = context.scene
+ scene_props = scene.layer_properties['BLENDER_EEVEE']
+ layer = bpy.context.render_layer
+ layer_props = layer.engine_overrides['BLENDER_EEVEE']
+
+ col = layout.column()
+ col.template_override_property(layer_props, scene_props, "volumetric_start")
+ col.template_override_property(layer_props, scene_props, "volumetric_end")
+ col.template_override_property(layer_props, scene_props, "volumetric_samples")
+ col.template_override_property(layer_props, scene_props, "volumetric_sample_distribution")
+ col.template_override_property(layer_props, scene_props, "volumetric_lights")
+ col.template_override_property(layer_props, scene_props, "volumetric_light_clamp")
+ col.template_override_property(layer_props, scene_props, "volumetric_shadows")
+ col.template_override_property(layer_props, scene_props, "volumetric_shadow_samples")
+ col.template_override_property(layer_props, scene_props, "volumetric_colored_transmittance")
+
+
+class RENDERLAYER_PT_eevee_screen_space_reflections(RenderLayerButtonsPanel, Panel):
+ bl_label = "Screen Space Reflections"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ scene = context.scene
+ return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+
+ def draw_header(self, context):
+ scene = context.scene
+ scene_props = scene.layer_properties['BLENDER_EEVEE']
+ layer = bpy.context.render_layer
+ layer_props = layer.engine_overrides['BLENDER_EEVEE']
+
+ self.layout.template_override_property(layer_props, scene_props, "ssr_enable", text="")
+
+ def draw(self, context):
+ layout = self.layout
+ scene = context.scene
+ scene_props = scene.layer_properties['BLENDER_EEVEE']
+ layer = bpy.context.render_layer
+ layer_props = layer.engine_overrides['BLENDER_EEVEE']
+
+ col = layout.column()
+ col.template_override_property(layer_props, scene_props, "ssr_halfres")
+ col.template_override_property(layer_props, scene_props, "ssr_refraction")
+ col.template_override_property(layer_props, scene_props, "ssr_ray_count")
+ col.template_override_property(layer_props, scene_props, "ssr_quality")
+ col.template_override_property(layer_props, scene_props, "ssr_max_roughness")
+ col.template_override_property(layer_props, scene_props, "ssr_thickness")
+ col.template_override_property(layer_props, scene_props, "ssr_border_fade")
+ col.template_override_property(layer_props, scene_props, "ssr_firefly_fac")
+
+
+class RENDERLAYER_PT_eevee_shadows(RenderLayerButtonsPanel, Panel):
+ bl_label = "Shadows"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ scene = context.scene
+ return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+
+ def draw(self, context):
+ layout = self.layout
+ scene = context.scene
+ scene_props = scene.layer_properties['BLENDER_EEVEE']
+ layer = bpy.context.render_layer
+ layer_props = layer.engine_overrides['BLENDER_EEVEE']
+
+ col = layout.column()
+ col.template_override_property(layer_props, scene_props, "shadow_method")
+ col.template_override_property(layer_props, scene_props, "shadow_size")
+ col.template_override_property(layer_props, scene_props, "shadow_high_bitdepth")
+
+
+class RENDERLAYER_PT_eevee_sampling(RenderLayerButtonsPanel, Panel):
+ bl_label = "Sampling"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ scene = context.scene
+ return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+
+ def draw(self, context):
+ layout = self.layout
+ scene = context.scene
+ scene_props = scene.layer_properties['BLENDER_EEVEE']
+ layer = bpy.context.render_layer
+ layer_props = layer.engine_overrides['BLENDER_EEVEE']
+
+ col = layout.column()
+ col.template_override_property(layer_props, scene_props, "taa_samples")
+
+
+class RENDERLAYER_PT_eevee_indirect_lighting(RenderLayerButtonsPanel, Panel):
+ bl_label = "Indirect Lighting"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ scene = context.scene
+ return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+
+ def draw(self, context):
+ layout = self.layout
+ scene = context.scene
+ scene_props = scene.layer_properties['BLENDER_EEVEE']
+ layer = bpy.context.render_layer
+ layer_props = layer.engine_overrides['BLENDER_EEVEE']
+
+ col = layout.column()
+ col.template_override_property(layer_props, scene_props, "gi_diffuse_bounces")
classes = (
@@ -220,8 +423,15 @@ classes = (
RENDERLAYER_UL_renderviews,
RENDERLAYER_PT_views,
RENDERLAYER_PT_clay_settings,
- RENDERLAYER_PT_eevee_poststack_settings,
- RENDERLAYER_PT_eevee_postprocess_settings,
+ RENDERLAYER_PT_eevee_sampling,
+ RENDERLAYER_PT_eevee_shadows,
+ RENDERLAYER_PT_eevee_indirect_lighting,
+ RENDERLAYER_PT_eevee_screen_space_reflections,
+ RENDERLAYER_PT_eevee_ambient_occlusion,
+ RENDERLAYER_PT_eevee_volumetric,
+ RENDERLAYER_PT_eevee_motion_blur,
+ RENDERLAYER_PT_eevee_depth_of_field,
+ RENDERLAYER_PT_eevee_bloom,
)
if __name__ == "__main__": # only for live edit.
diff --git a/release/scripts/startup/bl_ui/properties_world.py b/release/scripts/startup/bl_ui/properties_world.py
index fc5835d23d0..6e06d0593ff 100644
--- a/release/scripts/startup/bl_ui/properties_world.py
+++ b/release/scripts/startup/bl_ui/properties_world.py
@@ -270,13 +270,16 @@ class EEVEE_WORLD_PT_surface(WorldButtonsPanel, Panel):
if world.use_nodes:
ntree = world.node_tree
- node = find_output_node(ntree, 'OUTPUT_WORLD')
+ node = find_output_node(ntree, ('OUTPUT_WORLD',))
- if not node:
- layout.label(text="No output node")
- else:
+ if node:
input = find_node_input(node, 'Surface')
- layout.template_node_view(ntree, node, input)
+ if input:
+ layout.template_node_view(ntree, node, input)
+ else:
+ layout.label(text="Incompatible output node")
+ else:
+ layout.label(text="No output node")
else:
layout.prop(world, "horizon_color", text="Color")
diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py
index 43679727992..57195d22340 100644
--- a/release/scripts/startup/bl_ui/space_clip.py
+++ b/release/scripts/startup/bl_ui/space_clip.py
@@ -1033,11 +1033,11 @@ class CLIP_PT_proxy(CLIP_PT_clip_view_panel, Panel):
if clip.source == 'MOVIE':
col2 = col.column()
- col2.label(text="Use timecode index:")
+ col2.label(text="Use Timecode Index:")
col2.prop(clip.proxy, "timecode", text="")
col2 = col.column()
- col2.label(text="Proxy render size:")
+ col2.label(text="Proxy Render Size:")
col.prop(sc.clip_user, "proxy_render_size", text="")
@@ -1418,7 +1418,7 @@ class CLIP_MT_tracking_specials(Menu):
text="Enable Markers").action = 'ENABLE'
layout.operator("clip.disable_markers",
- text="Disable markers").action = 'DISABLE'
+ text="Disable Markers").action = 'DISABLE'
layout.separator()
layout.operator("clip.set_origin")
diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py
index eeb32a32066..5d3f4585a8a 100644
--- a/release/scripts/startup/bl_ui/space_image.py
+++ b/release/scripts/startup/bl_ui/space_image.py
@@ -1086,7 +1086,7 @@ class IMAGE_PT_tools_paint_options(BrushButtonsPanel, Panel):
col.prop(ups, "use_unified_color", text="Color")
-class IMAGE_UV_sculpt_curve(Panel):
+class IMAGE_PT_uv_sculpt_curve(Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'TOOLS'
bl_label = "UV Sculpt Curve"
@@ -1117,7 +1117,7 @@ class IMAGE_UV_sculpt_curve(Panel):
row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'
-class IMAGE_UV_sculpt(Panel, ImagePaintPanel):
+class IMAGE_PT_uv_sculpt(Panel, ImagePaintPanel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'TOOLS'
bl_category = "Tools"
@@ -1370,8 +1370,8 @@ classes = (
IMAGE_PT_tools_imagepaint_symmetry,
IMAGE_PT_tools_brush_appearance,
IMAGE_PT_tools_paint_options,
- IMAGE_UV_sculpt,
- IMAGE_UV_sculpt_curve,
+ IMAGE_PT_uv_sculpt,
+ IMAGE_PT_uv_sculpt_curve,
IMAGE_PT_view_histogram,
IMAGE_PT_view_waveform,
IMAGE_PT_view_vectorscope,
diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py
index 2021a69059b..3def0ca6328 100644
--- a/release/scripts/startup/bl_ui/space_node.py
+++ b/release/scripts/startup/bl_ui/space_node.py
@@ -187,10 +187,10 @@ class NODE_MT_view(Menu):
if context.space_data.show_backdrop:
layout.separator()
- layout.operator("node.backimage_move", text="Backdrop move")
- layout.operator("node.backimage_zoom", text="Backdrop zoom in").factor = 1.2
- layout.operator("node.backimage_zoom", text="Backdrop zoom out").factor = 0.83333
- layout.operator("node.backimage_fit", text="Fit backdrop to available space")
+ layout.operator("node.backimage_move", text="Backdrop Move")
+ layout.operator("node.backimage_zoom", text="Backdrop Zoom In").factor = 1.2
+ layout.operator("node.backimage_zoom", text="Backdrop Zoom Out").factor = 0.83333
+ layout.operator("node.backimage_fit", text="Fit Backdrop to Available Space")
layout.separator()
@@ -243,7 +243,7 @@ class NODE_MT_node(Menu):
layout.separator()
- layout.operator("node.join", text="Join in new Frame")
+ layout.operator("node.join", text="Join in New Frame")
layout.operator("node.detach", text="Remove from Frame")
layout.separator()
diff --git a/release/scripts/startup/bl_ui/space_outliner.py b/release/scripts/startup/bl_ui/space_outliner.py
index 054a955ab9c..dbd436b72c3 100644
--- a/release/scripts/startup/bl_ui/space_outliner.py
+++ b/release/scripts/startup/bl_ui/space_outliner.py
@@ -56,7 +56,7 @@ class OUTLINER_HT_header(Header):
row.operator("anim.keyframe_delete", text="", icon='KEY_DEHLT')
else:
row = layout.row()
- row.label(text="No Keying Set active")
+ row.label(text="No Keying Set Active")
elif space.display_mode == 'ORPHAN_DATA':
layout.operator("outliner.orphans_purge")
diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py
index 79bb10cefeb..06dd90685b7 100644
--- a/release/scripts/startup/bl_ui/space_sequencer.py
+++ b/release/scripts/startup/bl_ui/space_sequencer.py
@@ -43,7 +43,7 @@ def draw_color_balance(layout, color_balance):
col.separator()
col.separator()
col.prop(color_balance, "lift", text="")
- col.prop(color_balance, "invert_lift", text="Invert", icon="ARROW_LEFTRIGHT")
+ col.prop(color_balance, "invert_lift", text="Invert", icon='ARROW_LEFTRIGHT')
split.template_color_picker(color_balance, "lift", value_slider=True, cubic=True)
box = layout.box()
@@ -53,7 +53,7 @@ def draw_color_balance(layout, color_balance):
col.separator()
col.separator()
col.prop(color_balance, "gamma", text="")
- col.prop(color_balance, "invert_gamma", text="Invert", icon="ARROW_LEFTRIGHT")
+ col.prop(color_balance, "invert_gamma", text="Invert", icon='ARROW_LEFTRIGHT')
split.template_color_picker(color_balance, "gamma", value_slider=True, lock_luminosity=True, cubic=True)
box = layout.box()
@@ -63,7 +63,7 @@ def draw_color_balance(layout, color_balance):
col.separator()
col.separator()
col.prop(color_balance, "gain", text="")
- col.prop(color_balance, "invert_gain", text="Invert", icon="ARROW_LEFTRIGHT")
+ col.prop(color_balance, "invert_gain", text="Invert", icon='ARROW_LEFTRIGHT')
split.template_color_picker(color_balance, "gain", value_slider=True, lock_luminosity=True, cubic=True)
@@ -197,7 +197,7 @@ class SEQUENCER_MT_view(Menu):
layout.operator_context = 'INVOKE_DEFAULT'
if is_preview:
layout.operator_context = 'INVOKE_REGION_PREVIEW'
- layout.operator("sequencer.view_all_preview", text="Fit preview in window")
+ layout.operator("sequencer.view_all_preview", text="Fit Preview in Window")
layout.separator()
@@ -246,10 +246,10 @@ class SEQUENCER_MT_select(Menu):
layout.operator("sequencer.select_active_side", text="Strips to the Left").side = 'LEFT'
layout.operator("sequencer.select_active_side", text="Strips to the Right").side = 'RIGHT'
- props = layout.operator("sequencer.select", text="All strips to the Left")
+ props = layout.operator("sequencer.select", text="All Strips to the Left")
props.left_right = 'LEFT'
props.linked_time = True
- props = layout.operator("sequencer.select", text="All strips to the Right")
+ props = layout.operator("sequencer.select", text="All Strips to the Right")
props.left_right = 'RIGHT'
props.linked_time = True
@@ -397,15 +397,15 @@ class SEQUENCER_MT_strip(Menu):
layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator("transform.transform", text="Grab/Move").mode = 'TRANSLATION'
- layout.operator("transform.transform", text="Grab/Extend from frame").mode = 'TIME_EXTEND'
+ layout.operator("transform.transform", text="Grab/Extend from Frame").mode = 'TIME_EXTEND'
layout.operator("sequencer.gap_remove").all = False
layout.operator("sequencer.gap_insert")
# uiItemO(layout, NULL, 0, "sequencer.strip_snap"); // TODO - add this operator
layout.separator()
- layout.operator("sequencer.cut", text="Cut (hard) at frame").type = 'HARD'
- layout.operator("sequencer.cut", text="Cut (soft) at frame").type = 'SOFT'
+ layout.operator("sequencer.cut", text="Cut (Hard) at Frame").type = 'HARD'
+ layout.operator("sequencer.cut", text="Cut (Soft) at Frame").type = 'SOFT'
layout.operator("sequencer.slip", text="Slip Strip Contents")
layout.operator("sequencer.images_separate")
layout.operator("sequencer.offset_clear")
@@ -631,7 +631,7 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel, Panel):
if strip.use_as_speed:
layout.prop(strip, "speed_factor")
else:
- layout.prop(strip, "speed_factor", text="Frame number")
+ layout.prop(strip, "speed_factor", text="Frame Number")
layout.prop(strip, "scale_to_length")
elif strip.type == 'TRANSFORM':
@@ -698,7 +698,7 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel, Panel):
row.label("")
else:
col.separator()
- col.label(text="Two or more channels are needed below this strip", icon="INFO")
+ col.label(text="Two or more channels are needed below this strip", icon='INFO')
elif strip.type == 'TEXT':
@@ -728,7 +728,7 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel, Panel):
elif strip.type in {'CROSS', 'GAMMA_CROSS', 'WIPE', 'ALPHA_OVER', 'ALPHA_UNDER', 'OVER_DROP'}:
col.prop(strip, "use_default_fade", "Default fade")
if not strip.use_default_fade:
- col.prop(strip, "effect_fader", text="Effect fader")
+ col.prop(strip, "effect_fader", text="Effect Fader")
elif strip.type == 'GAUSSIAN_BLUR':
row = col.row(align=True)
row.prop(strip, "size_x")
@@ -784,7 +784,7 @@ class SEQUENCER_PT_input(SequencerButtonsPanel, Panel):
split.label(text="Alpha:")
split.prop(strip, "alpha_mode", text="")
- layout.operator("sequencer.change_path", icon="FILESEL").filter_image = True
+ layout.operator("sequencer.change_path", icon='FILESEL').filter_image = True
elif seq_type == 'MOVIE':
split = layout.split(percentage=0.2)
@@ -1056,9 +1056,9 @@ class SEQUENCER_PT_proxy(SequencerButtonsPanel, Panel):
proxy = strip.proxy
flow = layout.column_flow()
- flow.prop(sequencer, "proxy_storage", text='Storage')
+ flow.prop(sequencer, "proxy_storage", text="Storage")
if sequencer.proxy_storage == 'PROJECT':
- flow.prop(sequencer, "proxy_dir", text='Directory')
+ flow.prop(sequencer, "proxy_dir", text="Directory")
else:
flow.prop(proxy, "use_proxy_custom_directory")
flow.prop(proxy, "use_proxy_custom_file")
@@ -1077,7 +1077,7 @@ class SEQUENCER_PT_proxy(SequencerButtonsPanel, Panel):
layout.prop(proxy, "use_overwrite")
col = layout.column()
- col.prop(proxy, "quality", text="Build JPEG quality")
+ col.prop(proxy, "quality", text="Build JPEG Quality")
if strip.type == 'MOVIE':
col = layout.column()
@@ -1101,9 +1101,6 @@ class SEQUENCER_PT_preview(SequencerButtonsPanel_Output, Panel):
render = context.scene.render
col = layout.column()
- col.prop(render, "use_sequencer_gl_preview", text="OpenGL Preview")
- col = layout.column()
- #col.active = render.use_sequencer_gl_preview
col.prop(render, "sequencer_gl_preview", text="")
row = col.row()
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 25d0e430708..571e924b4eb 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -220,6 +220,7 @@ class USERPREF_PT_interface(Panel):
col = row.column()
col.label(text="Display:")
col.prop(view, "ui_scale", text="Scale")
+ col.prop(view, "ui_line_width", text="Line Width")
col.prop(view, "show_tooltips")
col.prop(view, "show_tooltips_python")
col.prop(view, "show_object_info", text="Object Info")
@@ -250,6 +251,7 @@ class USERPREF_PT_interface(Panel):
col = row.column()
col.label(text="View Manipulation:")
col.prop(view, "use_mouse_depth_cursor")
+ col.prop(view, "use_cursor_lock_adjust")
col.prop(view, "use_mouse_depth_navigate")
col.prop(view, "use_zoom_to_mouse")
col.prop(view, "use_rotate_around_active")
@@ -478,7 +480,7 @@ class USERPREF_PT_system(Panel):
col.label(text="Sound:")
col.row().prop(system, "audio_device", expand=False)
sub = col.column()
- sub.active = system.audio_device != 'NONE' and system.audio_device != 'Null'
+ sub.active = system.audio_device not in {'NONE', 'Null'}
#sub.prop(system, "use_preview_images")
sub.prop(system, "audio_channels", text="Channels")
sub.prop(system, "audio_mixing_buffer", text="Mixing Buffer")
@@ -908,7 +910,7 @@ class USERPREF_PT_theme(Panel):
col.separator()
col.separator()
- col.label("Axis Colors:")
+ col.label("Axis & Manipulator Colors:")
row = col.row()
@@ -926,9 +928,13 @@ class USERPREF_PT_theme(Panel):
padding = subsplit.split(percentage=0.15)
colsub = padding.column()
colsub = padding.column()
+ colsub.row().prop(ui, "manipulator_primary")
+ colsub.row().prop(ui, "manipulator_secondary")
+ colsub.row().prop(ui, "manipulator_a")
+ colsub.row().prop(ui, "manipulator_b")
- layout.separator()
- layout.separator()
+ col.separator()
+ col.separator()
elif theme.theme_area == 'BONE_COLOR_SETS':
col = split.column()
@@ -1106,29 +1112,29 @@ class USERPREF_MT_ndof_settings(Menu):
layout.prop(input_prefs, "ndof_show_guide")
layout.separator()
- layout.label(text="Orbit style")
+ layout.label(text="Orbit Style")
layout.row().prop(input_prefs, "ndof_view_navigate_method", text="")
layout.row().prop(input_prefs, "ndof_view_rotate_method", text="")
layout.separator()
- layout.label(text="Orbit options")
+ layout.label(text="Orbit Options")
layout.prop(input_prefs, "ndof_rotx_invert_axis")
layout.prop(input_prefs, "ndof_roty_invert_axis")
layout.prop(input_prefs, "ndof_rotz_invert_axis")
# view2d use pan/zoom
layout.separator()
- layout.label(text="Pan options")
+ layout.label(text="Pan Options")
layout.prop(input_prefs, "ndof_panx_invert_axis")
layout.prop(input_prefs, "ndof_pany_invert_axis")
layout.prop(input_prefs, "ndof_panz_invert_axis")
layout.prop(input_prefs, "ndof_pan_yz_swap_axis")
- layout.label(text="Zoom options")
+ layout.label(text="Zoom Options")
layout.prop(input_prefs, "ndof_zoom_invert")
if is_view3d:
layout.separator()
- layout.label(text="Fly/Walk options")
+ layout.label(text="Fly/Walk Options")
layout.prop(input_prefs, "ndof_fly_helicopter", icon='NDOF_FLY')
layout.prop(input_prefs, "ndof_lock_horizon", icon='NDOF_DOM')
@@ -1453,7 +1459,7 @@ class USERPREF_PT_addons(Panel):
sub = row.row()
sub.active = is_enabled
- sub.label(text='%s: %s' % (info["category"], info["name"]))
+ sub.label(text="%s: %s" % (info["category"], info["name"]))
if info["warning"]:
sub.label(icon='ERROR')
@@ -1481,11 +1487,11 @@ class USERPREF_PT_addons(Panel):
if info["version"]:
split = colsub.row().split(percentage=0.15)
split.label(text="Version:")
- split.label(text='.'.join(str(x) for x in info["version"]), translate=False)
+ split.label(text=".".join(str(x) for x in info["version"]), translate=False)
if info["warning"]:
split = colsub.row().split(percentage=0.15)
split.label(text="Warning:")
- split.label(text=' ' + info["warning"], icon='ERROR')
+ split.label(text=" " + info["warning"], icon='ERROR')
user_addon = USERPREF_PT_addons.is_user_addon(mod, user_addon_paths)
tot_row = bool(info["wiki_url"]) + bool(user_addon)
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index b3792686fc4..a31fd81efb5 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -55,7 +55,7 @@ class VIEW3D_HT_header(Header):
# Occlude geometry
if ((view.viewport_shade not in {'BOUNDBOX', 'WIREFRAME'} and (mode == 'PARTICLE_EDIT' or (mode == 'EDIT' and obj.type == 'MESH'))) or
- (mode == 'WEIGHT_PAINT')):
+ (mode in {'WEIGHT_PAINT', 'VERTEX_PAINT'})):
row.prop(view, "use_occlude_geometry", text="")
# Proportional editing
@@ -170,7 +170,7 @@ class VIEW3D_MT_editor_menus(Menu):
mesh = obj.data
if mesh.use_paint_mask:
layout.menu("VIEW3D_MT_select_paint_mask")
- elif mesh.use_paint_mask_vertex and mode_string == 'PAINT_WEIGHT':
+ elif mesh.use_paint_mask_vertex and mode_string in {'PAINT_WEIGHT', 'PAINT_VERTEX'}:
layout.menu("VIEW3D_MT_select_paint_mask_vertex")
elif mode_string != 'SCULPT':
layout.menu("VIEW3D_MT_select_%s" % mode_string.lower())
@@ -294,12 +294,19 @@ class VIEW3D_MT_transform_object(VIEW3D_MT_transform_base):
layout.operator("object.origin_set", text="Geometry to Origin").type = 'GEOMETRY_ORIGIN'
layout.operator("object.origin_set", text="Origin to Geometry").type = 'ORIGIN_GEOMETRY'
layout.operator("object.origin_set", text="Origin to 3D Cursor").type = 'ORIGIN_CURSOR'
- layout.operator("object.origin_set", text="Origin to Center of Mass").type = 'ORIGIN_CENTER_OF_MASS'
+ layout.operator("object.origin_set", text="Origin to Center of Mass (Surface)").type = 'ORIGIN_CENTER_OF_MASS'
+ layout.operator("object.origin_set", text="Origin to Center of Mass (Volume)").type = 'ORIGIN_CENTER_OF_VOLUME'
layout.separator()
layout.operator("object.randomize_transform")
layout.operator("object.align")
+ # TODO: there is a strange context bug here.
+ """
+ layout.operator_context = 'INVOKE_REGION_WIN'
+ layout.operator("object.transform_axis_target")
+ """
+
# Armature EditMode extensions to Transform menu
class VIEW3D_MT_transform_armature(VIEW3D_MT_transform_base):
@@ -1702,7 +1709,7 @@ class VIEW3D_MT_brush(Menu):
# skip if no active brush
if not brush:
- layout.label(text="No Brushes currently available", icon="INFO")
+ layout.label(text="No Brushes currently available", icon='INFO')
return
# brush paint modes
@@ -1771,6 +1778,7 @@ class VIEW3D_MT_paint_vertex(Menu):
layout.operator("paint.vertex_color_set")
layout.operator("paint.vertex_color_smooth")
layout.operator("paint.vertex_color_dirt")
+ layout.operator("paint.vertex_color_from_weight")
layout.separator()
@@ -2105,7 +2113,7 @@ class VIEW3D_MT_pose_transform(Menu):
layout.separator()
- layout.operator("pose.user_transforms_clear", text="Reset unkeyed")
+ layout.operator("pose.user_transforms_clear", text="Reset Unkeyed")
class VIEW3D_MT_pose_slide(Menu):
@@ -3266,6 +3274,9 @@ class VIEW3D_PT_view3d_display(Panel):
col.prop(view, "show_only_render")
col.prop(view, "show_world")
+ if context.mode in {'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE'}:
+ col.prop(view, "show_mode_shade_override")
+
col = layout.column()
display_all = not view.show_only_render
col.active = display_all
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 996e351e715..5430b108642 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -51,6 +51,19 @@ def draw_keyframing_tools(context, layout):
row.operator("anim.keyframe_delete_v3d", text="Remove")
+# Used by vertex & weight paint
+def draw_vpaint_symmetry(layout, vpaint):
+ col = layout.column(align=True)
+ col.label(text="Mirror:")
+ row = col.row(align=True)
+
+ row.prop(vpaint, "use_symmetry_x", text="X", toggle=True)
+ row.prop(vpaint, "use_symmetry_y", text="Y", toggle=True)
+ row.prop(vpaint, "use_symmetry_z", text="Z", toggle=True)
+
+ col = layout.column()
+ col.prop(vpaint, "radial_symmetry", text="Radial")
+
# ********** default tools for object-mode ****************
@@ -916,16 +929,18 @@ class VIEW3D_PT_imapaint_tools_missing(Panel, View3DPaintPanel):
col.separator()
col.label("Missing Canvas", icon='INFO')
col.label("Add or assign a canvas image below")
- col.label("Canvas Image")
- col.template_ID(toolsettings, "canvas")
+ col.label("Canvas Image:")
+ # todo this should be combinded into a single row
+ col.template_ID(toolsettings, "canvas", open="image.open")
col.operator("image.new", text="New").gen_context = 'PAINT_CANVAS'
if toolsettings.missing_stencil:
col.separator()
col.label("Missing Stencil", icon='INFO')
col.label("Add or assign a stencil image below")
- col.label("Stencil Image")
- col.template_ID(toolsettings, "stencil_image")
+ col.label("Stencil Image:")
+ # todo this should be combinded into a single row
+ col.template_ID(toolsettings, "stencil_image", open="image.open")
col.operator("image.new", text="New").gen_context = 'PAINT_STENCIL'
@@ -1065,8 +1080,8 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
# use_frontface
col.separator()
- row = col.row()
- row.prop(brush, "use_frontface", text="Front Faces Only")
+ col.prop(brush, "use_frontface", text="Front Faces Only")
+ col.prop(brush, "use_projected")
# direction
col.separator()
@@ -1116,12 +1131,22 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
self.prop_unified_strength(row, context, brush, "strength", text="Strength")
self.prop_unified_strength(row, context, brush, "use_pressure_strength")
+ col.separator()
col.prop(brush, "vertex_tool", text="Blend")
- if brush.vertex_tool == 'BLUR':
+ if brush.vertex_tool != 'SMEAR':
col.prop(brush, "use_accumulate")
col.separator()
+ col.prop(brush, "use_frontface", text="Front Faces Only")
+ row = col.row()
+ row.prop(brush, "use_frontface_falloff", text="Falloff Angle")
+ sub = row.row()
+ sub.active = brush.use_frontface_falloff
+ sub.prop(brush, "falloff_angle", text="")
+
+ col.prop(brush, "use_projected")
+
col = layout.column()
col.prop(toolsettings, "use_auto_normalize", text="Auto Normalize")
col.prop(toolsettings, "use_multipaint", text="Multi-Paint")
@@ -1132,7 +1157,11 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
self.prop_unified_color_picker(col, context, brush, "color", value_slider=True)
if settings.palette:
col.template_palette(settings, "palette", color=True)
- self.prop_unified_color(col, context, brush, "color", text="")
+ row = col.row(align=True)
+ self.prop_unified_color(row, context, brush, "color", text="")
+ self.prop_unified_color(row, context, brush, "secondary_color", text="")
+ row.separator()
+ row.operator("paint.brush_colors_flip", icon='FILE_REFRESH', text="")
col.separator()
row = col.row(align=True)
@@ -1143,12 +1172,22 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
self.prop_unified_strength(row, context, brush, "strength", text="Strength")
self.prop_unified_strength(row, context, brush, "use_pressure_strength")
- # XXX - TODO
- # row = col.row(align=True)
- # row.prop(brush, "jitter", slider=True)
- # row.prop(brush, "use_pressure_jitter", toggle=True, text="")
col.separator()
col.prop(brush, "vertex_tool", text="Blend")
+ col.prop(brush, "use_alpha")
+
+ if brush.vertex_tool != 'SMEAR':
+ col.prop(brush, "use_accumulate")
+ col.separator()
+
+ col.prop(brush, "use_frontface", text="Front Faces Only")
+ row = col.row()
+ row.prop(brush, "use_frontface_falloff", text="Falloff Angle")
+ sub = row.row()
+ sub.active = brush.use_frontface_falloff
+ sub.prop(brush, "falloff_angle", text="")
+
+ col.prop(brush, "use_projected")
col.separator()
col.template_ID(settings, "palette", new="palette.new")
@@ -1200,20 +1239,20 @@ class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel):
ob = context.active_object
col = layout.column()
- col.label("Painting Mode")
+ col.label("Painting Mode:")
col.prop(settings, "mode", text="")
col.separator()
if settings.mode == 'MATERIAL':
if len(ob.material_slots) > 1:
- col.label("Materials")
+ col.label("Materials:")
col.template_list("MATERIAL_UL_matslots", "layers",
ob, "material_slots",
ob, "active_material_index", rows=2)
mat = ob.active_material
if mat:
- col.label("Available Paint Slots")
+ col.label("Available Paint Slots:")
col.template_list("TEXTURE_UL_texpaintslots", "",
mat, "texture_paint_images",
mat, "paint_active_slot", rows=2)
@@ -1233,16 +1272,17 @@ class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel):
col.separator()
if slot and slot.index != -1:
- col.label("UV Map")
+ col.label("UV Map:")
col.prop_search(slot, "uv_layer", ob.data, "uv_layers", text="")
elif settings.mode == 'IMAGE':
mesh = ob.data
uv_text = mesh.uv_layers.active.name if mesh.uv_layers.active else ""
- col.label("Canvas Image")
- col.template_ID(settings, "canvas")
+ col.label("Canvas Image:")
+ # todo this should be combinded into a single row
+ col.template_ID(settings, "canvas", open="image.open")
col.operator("image.new", text="New").gen_context = 'PAINT_CANVAS'
- col.label("UV Map")
+ col.label("UV Map:")
col.menu("VIEW3D_MT_tools_projectpaint_uvlayer", text=uv_text, translate=False)
col.separator()
@@ -1275,15 +1315,16 @@ class VIEW3D_PT_stencil_projectpaint(View3DPanel, Panel):
col = layout.column()
col.active = ipaint.use_stencil_layer
- stencil_text = mesh.uv_texture_stencil.name if mesh.uv_texture_stencil else ""
+ stencil_text = mesh.uv_layer_stencil.name if mesh.uv_layer_stencil else ""
col.label("UV Map")
col.menu("VIEW3D_MT_tools_projectpaint_stencil", text=stencil_text, translate=False)
- col.label("Stencil Image")
- col.template_ID(ipaint, "stencil_image")
+ col.label("Stencil Image:")
+ # todo this should be combinded into a single row
+ col.template_ID(ipaint, "stencil_image", open="image.open")
col.operator("image.new", text="New").gen_context = 'PAINT_STENCIL'
- col.label("Visualization")
+ col.label("Visualization:")
row = col.row(align=True)
row.prop(ipaint, "stencil_color", text="")
row.prop(ipaint, "invert_stencil", text="", icon='IMAGE_ALPHA')
@@ -1713,6 +1754,19 @@ class VIEW3D_PT_tools_weightpaint(View3DPanel, Panel):
props.data_type = 'VGROUP_WEIGHTS'
+class VIEW3D_PT_tools_weightpaint_symmetry(Panel, View3DPaintPanel):
+ bl_category = "Tools"
+ bl_context = "weightpaint"
+ bl_options = {'DEFAULT_CLOSED'}
+ bl_label = "Symmetry"
+
+ def draw(self, context):
+ layout = self.layout
+ toolsettings = context.tool_settings
+ wpaint = toolsettings.weight_paint
+ draw_vpaint_symmetry(layout, wpaint)
+
+
class VIEW3D_PT_tools_weightpaint_options(Panel, View3DPaintPanel):
bl_category = "Options"
bl_context = "weightpaint"
@@ -1725,13 +1779,7 @@ class VIEW3D_PT_tools_weightpaint_options(Panel, View3DPaintPanel):
wpaint = tool_settings.weight_paint
col = layout.column()
- row = col.row()
-
- row.prop(wpaint, "use_normal")
- col = layout.column()
- row = col.row()
- row.prop(wpaint, "use_spray")
- row.prop(wpaint, "use_group_restrict")
+ col.prop(wpaint, "use_group_restrict")
obj = context.weight_paint_object
if obj.type == 'MESH':
@@ -1762,18 +1810,28 @@ class VIEW3D_PT_tools_vertexpaint(Panel, View3DPaintPanel):
vpaint = toolsettings.vertex_paint
col = layout.column()
+ col.label("Falloff:")
row = col.row()
- # col.prop(vpaint, "mode", text="")
- row.prop(vpaint, "use_normal")
- col.prop(vpaint, "use_spray")
+ row.prop(vpaint, "use_normal_falloff")
+ sub = row.row()
+ sub.active = (vpaint.use_normal_falloff)
+ sub.prop(vpaint, "normal_angle", text="")
self.unified_paint_settings(col, context)
-# Commented out because the Apply button isn't an operator yet, making these settings useless
-#~ col.label(text="Gamma:")
-#~ col.prop(vpaint, "gamma", text="")
-#~ col.label(text="Multiply:")
-#~ col.prop(vpaint, "mul", text="")
+
+class VIEW3D_PT_tools_vertexpaint_symmetry(Panel, View3DPaintPanel):
+ bl_category = "Tools"
+ bl_context = "vertexpaint"
+ bl_options = {'DEFAULT_CLOSED'}
+ bl_label = "Symmetry"
+
+ def draw(self, context):
+ layout = self.layout
+ toolsettings = context.tool_settings
+ vpaint = toolsettings.vertex_paint
+ draw_vpaint_symmetry(layout, vpaint)
+
# ********** default tools for texture-paint ****************
@@ -1878,7 +1936,7 @@ class VIEW3D_MT_tools_projectpaint_stencil(Menu):
layout = self.layout
for i, uv_layer in enumerate(context.active_object.data.uv_layers):
props = layout.operator("wm.context_set_int", text=uv_layer.name, translate=False)
- props.data_path = "active_object.data.uv_texture_stencil_index"
+ props.data_path = "active_object.data.uv_layer_stencil_index"
props.value = i
@@ -1921,7 +1979,7 @@ class VIEW3D_PT_tools_particlemode(View3DPanel, Panel):
col = layout.column(align=True)
if pe.is_hair:
col.active = pe.is_editable
- col.prop(pe, "use_emitter_deflect", text="Deflect emitter")
+ col.prop(pe, "use_emitter_deflect", text="Deflect Emitter")
sub = col.row(align=True)
sub.active = pe.use_emitter_deflect
sub.prop(pe, "emitter_distance", text="Distance")
@@ -2054,8 +2112,10 @@ classes = (
VIEW3D_PT_sculpt_symmetry,
VIEW3D_PT_tools_brush_appearance,
VIEW3D_PT_tools_weightpaint,
+ VIEW3D_PT_tools_weightpaint_symmetry,
VIEW3D_PT_tools_weightpaint_options,
VIEW3D_PT_tools_vertexpaint,
+ VIEW3D_PT_tools_vertexpaint_symmetry,
VIEW3D_PT_tools_imagepaint_external,
VIEW3D_PT_tools_imagepaint_symmetry,
VIEW3D_PT_tools_projectpaint,
diff --git a/release/scripts/startup/keyingsets_builtins.py b/release/scripts/startup/keyingsets_builtins.py
index f62e3602bb9..390c043bb31 100644
--- a/release/scripts/startup/keyingsets_builtins.py
+++ b/release/scripts/startup/keyingsets_builtins.py
@@ -494,7 +494,7 @@ class BUILTIN_KSI_WholeCharacter(KeyingSetInfo):
# bendy bone properties
def doBBone(ksi, context, ks, pchan):
bone = pchan.bone
-
+
# This check is crude, but is the best we can do for now
# It simply adds all of these if the bbone has segments
# (and the bone is a control bone). This may lead to some
diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py
index f13222140b1..341efd78f5e 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -145,6 +145,15 @@ def cycles_shader_nodes_poll(context):
return context.scene.render.engine == 'CYCLES'
+def eevee_shader_nodes_poll(context):
+ return context.scene.render.engine == 'BLENDER_EEVEE'
+
+
+def eevee_cycles_shader_nodes_poll(context):
+ return (cycles_shader_nodes_poll(context) or
+ eevee_shader_nodes_poll(context))
+
+
def object_cycles_shader_nodes_poll(context):
return (object_shader_nodes_poll(context) and
cycles_shader_nodes_poll(context))
@@ -152,7 +161,19 @@ def object_cycles_shader_nodes_poll(context):
def object_eevee_shader_nodes_poll(context):
return (object_shader_nodes_poll(context) and
- context.scene.render.engine == 'BLENDER_EEVEE')
+ eevee_shader_nodes_poll(context))
+
+
+def object_eevee_cycles_shader_nodes_poll(context):
+ return (object_shader_nodes_poll(context) and
+ eevee_cycles_shader_nodes_poll(context))
+
+
+# Until volume shader on objects are supported in eevee.
+def volume_shader_nodes_poll(context):
+ return (cycles_shader_nodes_poll(context) or
+ (eevee_shader_nodes_poll(context) and
+ world_shader_nodes_poll(context)))
# All standard node categories currently used in nodes.
@@ -230,35 +251,33 @@ shader_node_categories = [
NodeItem("NodeGroupInput", poll=group_input_output_item_poll),
]),
ShaderNewNodeCategory("SH_NEW_OUTPUT", "Output", items=[
- NodeItem("ShaderNodeOutputMaterial", poll=object_cycles_shader_nodes_poll),
- NodeItem("ShaderNodeOutputEeveeMaterial", poll=object_eevee_shader_nodes_poll),
+ NodeItem("ShaderNodeOutputMaterial", poll=object_eevee_cycles_shader_nodes_poll),
NodeItem("ShaderNodeOutputLamp", poll=object_cycles_shader_nodes_poll),
NodeItem("ShaderNodeOutputWorld", poll=world_shader_nodes_poll),
NodeItem("ShaderNodeOutputLineStyle", poll=line_style_shader_nodes_poll),
NodeItem("NodeGroupOutput", poll=group_input_output_item_poll),
]),
ShaderNewNodeCategory("SH_NEW_SHADER", "Shader", items=[
- NodeItem("ShaderNodeMixShader", poll=cycles_shader_nodes_poll),
- NodeItem("ShaderNodeAddShader", poll=cycles_shader_nodes_poll),
- NodeItem("ShaderNodeBsdfDiffuse", poll=object_cycles_shader_nodes_poll),
- NodeItem("ShaderNodeBsdfPrincipled", poll=object_cycles_shader_nodes_poll),
- NodeItem("ShaderNodeBsdfGlossy", poll=object_cycles_shader_nodes_poll),
- NodeItem("ShaderNodeBsdfTransparent", poll=object_cycles_shader_nodes_poll),
- NodeItem("ShaderNodeBsdfRefraction", poll=object_cycles_shader_nodes_poll),
- NodeItem("ShaderNodeBsdfGlass", poll=object_cycles_shader_nodes_poll),
+ NodeItem("ShaderNodeMixShader", poll=eevee_cycles_shader_nodes_poll),
+ NodeItem("ShaderNodeAddShader", poll=eevee_cycles_shader_nodes_poll),
+ NodeItem("ShaderNodeBsdfDiffuse", poll=object_eevee_cycles_shader_nodes_poll),
+ NodeItem("ShaderNodeBsdfPrincipled", poll=object_eevee_cycles_shader_nodes_poll),
+ NodeItem("ShaderNodeBsdfGlossy", poll=object_eevee_cycles_shader_nodes_poll),
+ NodeItem("ShaderNodeBsdfTransparent", poll=object_eevee_cycles_shader_nodes_poll),
+ NodeItem("ShaderNodeBsdfRefraction", poll=object_eevee_cycles_shader_nodes_poll),
+ NodeItem("ShaderNodeBsdfGlass", poll=object_eevee_cycles_shader_nodes_poll),
NodeItem("ShaderNodeBsdfTranslucent", poll=object_cycles_shader_nodes_poll),
NodeItem("ShaderNodeBsdfAnisotropic", poll=object_cycles_shader_nodes_poll),
NodeItem("ShaderNodeBsdfVelvet", poll=object_cycles_shader_nodes_poll),
NodeItem("ShaderNodeBsdfToon", poll=object_cycles_shader_nodes_poll),
NodeItem("ShaderNodeSubsurfaceScattering", poll=object_cycles_shader_nodes_poll),
- NodeItem("ShaderNodeEmission", poll=object_cycles_shader_nodes_poll),
+ NodeItem("ShaderNodeEmission", poll=object_eevee_cycles_shader_nodes_poll),
NodeItem("ShaderNodeBsdfHair", poll=object_cycles_shader_nodes_poll),
NodeItem("ShaderNodeBackground", poll=world_shader_nodes_poll),
NodeItem("ShaderNodeAmbientOcclusion", poll=object_cycles_shader_nodes_poll),
NodeItem("ShaderNodeHoldout", poll=object_cycles_shader_nodes_poll),
- NodeItem("ShaderNodeVolumeAbsorption", poll=cycles_shader_nodes_poll),
- NodeItem("ShaderNodeVolumeScatter", poll=cycles_shader_nodes_poll),
- NodeItem("ShaderNodeEeveeMetallic", poll=object_eevee_shader_nodes_poll),
+ NodeItem("ShaderNodeVolumeAbsorption", poll=volume_shader_nodes_poll),
+ NodeItem("ShaderNodeVolumeScatter", poll=volume_shader_nodes_poll),
NodeItem("ShaderNodeEeveeSpecular", poll=object_eevee_shader_nodes_poll),
]),
ShaderNewNodeCategory("SH_NEW_TEXTURE", "Texture", items=[
diff --git a/release/scripts/templates_py/custom_nodes.py b/release/scripts/templates_py/custom_nodes.py
index 32c61abace7..8ca748c1d66 100644
--- a/release/scripts/templates_py/custom_nodes.py
+++ b/release/scripts/templates_py/custom_nodes.py
@@ -11,7 +11,7 @@ class MyCustomTree(NodeTree):
# Optional identifier string. If not explicitly defined, the python class name is used.
bl_idname = 'CustomTreeType'
# Label for nice name display
- bl_label = 'Custom Node Tree'
+ bl_label = "Custom Node Tree"
# Icon identifier
bl_icon = 'NODETREE'
@@ -23,24 +23,24 @@ class MyCustomSocket(NodeSocket):
# Optional identifier string. If not explicitly defined, the python class name is used.
bl_idname = 'CustomSocketType'
# Label for nice name display
- bl_label = 'Custom Node Socket'
+ bl_label = "Custom Node Socket"
# Enum items list
- my_items = [
- ("DOWN", "Down", "Where your feet are"),
- ("UP", "Up", "Where your head should be"),
- ("LEFT", "Left", "Not right"),
- ("RIGHT", "Right", "Not left")
- ]
+ my_items = (
+ ('DOWN', "Down", "Where your feet are"),
+ ('UP', "Up", "Where your head should be"),
+ ('LEFT', "Left", "Not right"),
+ ('RIGHT', "Right", "Not left")
+ )
- myEnumProperty = bpy.props.EnumProperty(name="Direction", description="Just an example", items=my_items, default='UP')
+ my_enum_prop = bpy.props.EnumProperty(name="Direction", description="Just an example", items=my_items, default='UP')
# Optional function for drawing the socket input value
def draw(self, context, layout, node, text):
if self.is_output or self.is_linked:
layout.label(text)
else:
- layout.prop(self, "myEnumProperty", text=text)
+ layout.prop(self, "my_enum_prop", text=text)
# Socket color
def draw_color(self, context, node):
@@ -63,7 +63,7 @@ class MyCustomNode(Node, MyCustomTreeNode):
# Optional identifier string. If not explicitly defined, the python class name is used.
bl_idname = 'CustomNodeType'
# Label for nice name display
- bl_label = 'Custom Node'
+ bl_label = "Custom Node"
# Icon identifier
bl_icon = 'SOUND'
@@ -71,8 +71,8 @@ class MyCustomNode(Node, MyCustomTreeNode):
# These work just like custom properties in ID data blocks
# Extensive information can be found under
# http://wiki.blender.org/index.php/Doc:2.6/Manual/Extensions/Python/Properties
- myStringProperty = bpy.props.StringProperty()
- myFloatProperty = bpy.props.FloatProperty(default=3.1415926)
+ my_string_prop = bpy.props.StringProperty()
+ my_float_prop = bpy.props.FloatProperty(default=3.1415926)
# === Optional Functions ===
# Initialization function, called when a new node is created.
@@ -99,14 +99,14 @@ class MyCustomNode(Node, MyCustomTreeNode):
# Additional buttons displayed on the node.
def draw_buttons(self, context, layout):
layout.label("Node settings")
- layout.prop(self, "myFloatProperty")
+ layout.prop(self, "my_float_prop")
# Detail buttons in the sidebar.
# If this function is not defined, the draw_buttons function is used instead
def draw_buttons_ext(self, context, layout):
- layout.prop(self, "myFloatProperty")
- # myStringProperty button will only be visible in the sidebar
- layout.prop(self, "myStringProperty")
+ layout.prop(self, "my_float_prop")
+ # my_string_prop button will only be visible in the sidebar
+ layout.prop(self, "my_string_prop")
# Optional: custom label
# Explicit user label overrides this, but here we can define a label dynamically
@@ -122,7 +122,6 @@ class MyCustomNode(Node, MyCustomTreeNode):
import nodeitems_utils
from nodeitems_utils import NodeCategory, NodeItem
-
# our own base class with an appropriate poll function,
# so the categories only show up in our own tree type
class MyNodeCategory(NodeCategory):
@@ -130,44 +129,50 @@ class MyNodeCategory(NodeCategory):
def poll(cls, context):
return context.space_data.tree_type == 'CustomTreeType'
+
# all categories in a list
node_categories = [
# identifier, label, items list
- MyNodeCategory("SOMENODES", "Some Nodes", items=[
+ MyNodeCategory('SOMENODES', "Some Nodes", items=[
# our basic node
NodeItem("CustomNodeType"),
- ]),
- MyNodeCategory("OTHERNODES", "Other Nodes", items=[
+ ]),
+ MyNodeCategory('OTHERNODES', "Other Nodes", items=[
# the node item can have additional settings,
# which are applied to new nodes
# NB: settings values are stored as string expressions,
# for this reason they should be converted to strings using repr()
NodeItem("CustomNodeType", label="Node A", settings={
- "myStringProperty": repr("Lorem ipsum dolor sit amet"),
- "myFloatProperty": repr(1.0),
- }),
+ "my_string_prop": repr("Lorem ipsum dolor sit amet"),
+ "my_float_prop": repr(1.0),
+ }),
NodeItem("CustomNodeType", label="Node B", settings={
- "myStringProperty": repr("consectetur adipisicing elit"),
- "myFloatProperty": repr(2.0),
- }),
- ]),
- ]
-
+ "my_string_prop": repr("consectetur adipisicing elit"),
+ "my_float_prop": repr(2.0),
+ }),
+ ]),
+]
+
+classes = (
+ MyCustomTree,
+ MyCustomSocket,
+ MyCustomNode,
+)
def register():
- bpy.utils.register_class(MyCustomTree)
- bpy.utils.register_class(MyCustomSocket)
- bpy.utils.register_class(MyCustomNode)
+ from bpy.utils import register_class
+ for cls in classes:
+ register_class(cls)
- nodeitems_utils.register_node_categories("CUSTOM_NODES", node_categories)
+ nodeitems_utils.register_node_categories('CUSTOM_NODES', node_categories)
def unregister():
- nodeitems_utils.unregister_node_categories("CUSTOM_NODES")
+ nodeitems_utils.unregister_node_categories('CUSTOM_NODES')
- bpy.utils.unregister_class(MyCustomTree)
- bpy.utils.unregister_class(MyCustomSocket)
- bpy.utils.unregister_class(MyCustomNode)
+ from bpy.utils import unregister_class
+ for cls in reversed(classes):
+ unregister_class(cls)
if __name__ == "__main__":
diff --git a/release/scripts/templates_py/gamelogic.py b/release/scripts/templates_py/gamelogic.py
index 01ac27c56cd..e589ad43e63 100644
--- a/release/scripts/templates_py/gamelogic.py
+++ b/release/scripts/templates_py/gamelogic.py
@@ -62,7 +62,7 @@ def main():
# adding to our objects "life" property
"""
actu_collide = cont.sensors["collision_sens"]
- for ob in actu_collide.objectHitList:
+ for ob in actu_collide.hitObjectList:
# Check to see the object has this property
if "life" in ob:
own["life"] += ob["life"]
diff --git a/release/scripts/templates_py/manipulator_custom_geometry.py b/release/scripts/templates_py/manipulator_custom_geometry.py
new file mode 100644
index 00000000000..0f1ab72f9ef
--- /dev/null
+++ b/release/scripts/templates_py/manipulator_custom_geometry.py
@@ -0,0 +1,158 @@
+# Example of a custom widget that defines it's own geometry.
+#
+# Usage: Select a lamp in the 3D view and drag the arrow at it's rear
+# to change it's energy value.
+#
+import bpy
+from bpy.types import (
+ Manipulator,
+ ManipulatorGroup,
+)
+
+# Coordinates (each one is a triangle).
+custom_shape_verts = (
+ (3.0, 1.0, -1.0), (2.0, 2.0, -1.0), (3.0, 3.0, -1.0),
+ (1.0, 3.0, 1.0), (3.0, 3.0, -1.0), (1.0, 3.0, -1.0),
+ (3.0, 3.0, 1.0), (3.0, 1.0, -1.0), (3.0, 3.0, -1.0),
+ (2.0, 0.0, 1.0), (3.0, 1.0, -1.0), (3.0, 1.0, 1.0),
+ (2.0, 0.0, -1.0), (2.0, 2.0, 1.0), (2.0, 2.0, -1.0),
+ (2.0, 2.0, -1.0), (0.0, 2.0, 1.0), (0.0, 2.0, -1.0),
+ (1.0, 3.0, 1.0), (2.0, 2.0, 1.0), (3.0, 3.0, 1.0),
+ (0.0, 2.0, -1.0), (1.0, 3.0, 1.0), (1.0, 3.0, -1.0),
+ (2.0, 2.0, 1.0), (3.0, 1.0, 1.0), (3.0, 3.0, 1.0),
+ (2.0, 2.0, -1.0), (1.0, 3.0, -1.0), (3.0, 3.0, -1.0),
+ (-3.0, -1.0, -1.0), (-2.0, -2.0, -1.0), (-3.0, -3.0, -1.0),
+ (-1.0, -3.0, 1.0), (-3.0, -3.0, -1.0), (-1.0, -3.0, -1.0),
+ (-3.0, -3.0, 1.0), (-3.0, -1.0, -1.0), (-3.0, -3.0, -1.0),
+ (-2.0, 0.0, 1.0), (-3.0, -1.0, -1.0), (-3.0, -1.0, 1.0),
+ (-2.0, 0.0, -1.0), (-2.0, -2.0, 1.0), (-2.0, -2.0, -1.0),
+ (-2.0, -2.0, -1.0), (0.0, -2.0, 1.0), (0.0, -2.0, -1.0),
+ (-1.0, -3.0, 1.0), (-2.0, -2.0, 1.0), (-3.0, -3.0, 1.0),
+ (0.0, -2.0, -1.0), (-1.0, -3.0, 1.0), (-1.0, -3.0, -1.0),
+ (-2.0, -2.0, 1.0), (-3.0, -1.0, 1.0), (-3.0, -3.0, 1.0),
+ (-2.0, -2.0, -1.0), (-1.0, -3.0, -1.0), (-3.0, -3.0, -1.0),
+ (1.0, -1.0, 0.0), (-1.0, -1.0, 0.0), (0.0, 0.0, -5.0),
+ (-1.0, -1.0, 0.0), (1.0, -1.0, 0.0), (0.0, 0.0, 5.0),
+ (1.0, -1.0, 0.0), (1.0, 1.0, 0.0), (0.0, 0.0, 5.0),
+ (1.0, 1.0, 0.0), (-1.0, 1.0, 0.0), (0.0, 0.0, 5.0),
+ (-1.0, 1.0, 0.0), (-1.0, -1.0, 0.0), (0.0, 0.0, 5.0),
+ (-1.0, -1.0, 0.0), (-1.0, 1.0, 0.0), (0.0, 0.0, -5.0),
+ (-1.0, 1.0, 0.0), (1.0, 1.0, 0.0), (0.0, 0.0, -5.0),
+ (1.0, 1.0, 0.0), (1.0, -1.0, 0.0), (0.0, 0.0, -5.0),
+ (3.0, 1.0, -1.0), (2.0, 0.0, -1.0), (2.0, 2.0, -1.0),
+ (1.0, 3.0, 1.0), (3.0, 3.0, 1.0), (3.0, 3.0, -1.0),
+ (3.0, 3.0, 1.0), (3.0, 1.0, 1.0), (3.0, 1.0, -1.0),
+ (2.0, 0.0, 1.0), (2.0, 0.0, -1.0), (3.0, 1.0, -1.0),
+ (2.0, 0.0, -1.0), (2.0, 0.0, 1.0), (2.0, 2.0, 1.0),
+ (2.0, 2.0, -1.0), (2.0, 2.0, 1.0), (0.0, 2.0, 1.0),
+ (1.0, 3.0, 1.0), (0.0, 2.0, 1.0), (2.0, 2.0, 1.0),
+ (0.0, 2.0, -1.0), (0.0, 2.0, 1.0), (1.0, 3.0, 1.0),
+ (2.0, 2.0, 1.0), (2.0, 0.0, 1.0), (3.0, 1.0, 1.0),
+ (2.0, 2.0, -1.0), (0.0, 2.0, -1.0), (1.0, 3.0, -1.0),
+ (-3.0, -1.0, -1.0), (-2.0, 0.0, -1.0), (-2.0, -2.0, -1.0),
+ (-1.0, -3.0, 1.0), (-3.0, -3.0, 1.0), (-3.0, -3.0, -1.0),
+ (-3.0, -3.0, 1.0), (-3.0, -1.0, 1.0), (-3.0, -1.0, -1.0),
+ (-2.0, 0.0, 1.0), (-2.0, 0.0, -1.0), (-3.0, -1.0, -1.0),
+ (-2.0, 0.0, -1.0), (-2.0, 0.0, 1.0), (-2.0, -2.0, 1.0),
+ (-2.0, -2.0, -1.0), (-2.0, -2.0, 1.0), (0.0, -2.0, 1.0),
+ (-1.0, -3.0, 1.0), (0.0, -2.0, 1.0), (-2.0, -2.0, 1.0),
+ (0.0, -2.0, -1.0), (0.0, -2.0, 1.0), (-1.0, -3.0, 1.0),
+ (-2.0, -2.0, 1.0), (-2.0, 0.0, 1.0), (-3.0, -1.0, 1.0),
+ (-2.0, -2.0, -1.0), (0.0, -2.0, -1.0), (-1.0, -3.0, -1.0),
+)
+
+
+class MyCustomShapeWidget(Manipulator):
+ bl_idname = "VIEW3D_WT_auto_facemap"
+ bl_target_properties = (
+ {"id": "offset", "type": 'FLOAT', "array_length": 1},
+ )
+
+ __slots__ = (
+ "custom_shape",
+ "init_mouse_y",
+ "init_value",
+ )
+
+ def _update_offset_matrix(self):
+ # offset behind the lamp
+ self.matrix_offset.col[3][2] = self.target_get_value("offset") / -10.0
+
+ def draw(self, context):
+ self._update_offset_matrix()
+ self.draw_custom_shape(self.custom_shape)
+
+ def draw_select(self, context, select_id):
+ self._update_offset_matrix()
+ self.draw_custom_shape(self.custom_shape, select_id=select_id)
+
+ def setup(self):
+ if not hasattr(self, "custom_shape"):
+ self.custom_shape = self.new_custom_shape('TRIS', custom_shape_verts)
+
+ def invoke(self, context, event):
+ self.init_mouse_y = event.mouse_y
+ self.init_value = self.target_get_value("offset")
+ return {'RUNNING_MODAL'}
+
+ def exit(self, context, cancel):
+ context.area.header_text_set()
+ if cancel:
+ self.target_set_value("offset", self.init_value)
+
+ def modal(self, context, event, tweak):
+ delta = (event.mouse_y - self.init_mouse_y) / 10.0
+ if 'SNAP' in tweak:
+ delta = round(delta)
+ if 'PRECISE' in tweak:
+ delta /= 10.0
+ value = self.init_value + delta
+ self.target_set_value("offset", value)
+ context.area.header_text_set("My Manipulator: %.4f" % value)
+ return {'RUNNING_MODAL'}
+
+
+class MyCustomShapeWidgetGroup(ManipulatorGroup):
+ bl_idname = "OBJECT_WGT_lamp_test"
+ bl_label = "Test Lamp Widget"
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'WINDOW'
+ bl_options = {'3D', 'PERSISTENT'}
+
+ @classmethod
+ def poll(cls, context):
+ ob = context.object
+ return (ob and ob.type == 'LAMP')
+
+ def setup(self, context):
+ # Assign the 'offset' target property to the lamp energy.
+ ob = context.object
+ mpr = self.manipulators.new(MyCustomShapeWidget.bl_idname)
+ mpr.target_set_prop("offset", ob.data, "energy")
+ mpr.matrix_basis = ob.matrix_world.normalized()
+
+ mpr.color = 1.0, 0.5, 1.0
+ mpr.alpha = 0.5
+
+ mpr.color_highlight = 1.0, 0.5, 1.0
+ mpr.alpha_highlight = 0.5
+
+ # units are large, so shrink to something more reasonable.
+ mpr.scale_basis = 0.1
+ mpr.use_draw_modal = True
+
+ self.energy_widget = mpr
+
+ def refresh(self, context):
+ ob = context.object
+ mpr = self.energy_widget
+ mpr.matrix_basis = ob.matrix_world.normalized()
+
+
+classes = (
+ MyCustomShapeWidget,
+ MyCustomShapeWidgetGroup,
+)
+
+for cls in classes:
+ bpy.utils.register_class(cls)
diff --git a/release/scripts/templates_py/manipulator_operator.py b/release/scripts/templates_py/manipulator_operator.py
index 0ba871bea84..00b24736b8e 100644
--- a/release/scripts/templates_py/manipulator_operator.py
+++ b/release/scripts/templates_py/manipulator_operator.py
@@ -130,8 +130,12 @@ class SelectSideOfPlaneManipulatorGroup(ManipulatorGroup):
mpr.use_draw_value = True
- mpr.color = 0.8, 0.8, 0.8, 0.5
- mpr.color_highlight = 1.0, 1.0, 1.0, 1.0
+ mpr.color = 0.8, 0.8, 0.8
+ mpr.alpha = 0.5
+
+ mpr.color_highlight = 1.0, 1.0, 1.0
+ mpr.alpha_highlight = 1.0
+
mpr.scale_basis = 0.2
self.widget_grab = mpr
@@ -162,8 +166,11 @@ class SelectSideOfPlaneManipulatorGroup(ManipulatorGroup):
mpr.use_draw_value = True
- mpr.color = 0.8, 0.8, 0.8, 0.5
+ mpr.color = 0.8, 0.8, 0.8
+ mpr.alpha = 0.5
+
mpr.color_highlight = 1.0, 1.0, 1.0, 1.0
+ mpr.alpha_highlight = 1.0
self.widget_dial = mpr
diff --git a/release/scripts/templates_py/manipulator_operator_target.py b/release/scripts/templates_py/manipulator_operator_target.py
index eafe8b1a863..0abf6f2f654 100644
--- a/release/scripts/templates_py/manipulator_operator_target.py
+++ b/release/scripts/templates_py/manipulator_operator_target.py
@@ -32,8 +32,11 @@ class MyCameraWidgetGroup(ManipulatorGroup):
mpr.matrix_basis = ob.matrix_world.normalized()
mpr.line_width = 3
- mpr.color = 0.8, 0.8, 0.8, 0.5
- mpr.color_highlight = 1.0, 1.0, 1.0, 1.0
+ mpr.color = 0.8, 0.8, 0.8
+ mpr.alpha = 0.5
+
+ mpr.color_highlight = 1.0, 1.0, 1.0
+ mpr.alpha_highlight = 1.0
self.roll_widget = mpr
diff --git a/release/scripts/templates_py/manipulator_simple.py b/release/scripts/templates_py/manipulator_simple.py
index 6cb232312e8..7e02940d527 100644
--- a/release/scripts/templates_py/manipulator_simple.py
+++ b/release/scripts/templates_py/manipulator_simple.py
@@ -29,8 +29,11 @@ class MyLampWidgetGroup(ManipulatorGroup):
mpr.matrix_basis = ob.matrix_world.normalized()
mpr.draw_style = 'BOX'
- mpr.color = 1, 0.5, 0, 0.5
- mpr.color_highlight = 1, 0.5, 1, 0.5
+ mpr.color = 1.0, 0.5, 0.0
+ mpr.alpha = 0.5
+
+ mpr.color_highlight = 1.0, 0.5, 1.0
+ mpr.alpha_highlight = 0.5
self.energy_widget = mpr
diff --git a/release/text/copyright.txt b/release/text/copyright.txt
index 207d6f54ea8..d0490b9ca91 100644
--- a/release/text/copyright.txt
+++ b/release/text/copyright.txt
@@ -21,7 +21,7 @@
Subject to the provisions of the GNU GPL license, BF grants You a
non-exclusive right to use the Software at any computer You own or use.
Artwork you create with the Software - whether it is images, movies,
- scripts, exported 3d files or the .blend files themselves - is your sole
+ exported 3d files or the .blend files themselves - is your sole
property, and can be licensed or sold under any conditions you prefer.
2. Permitted copying and electronic distribution of Software
diff --git a/source/blender/quicktime/CMakeLists.txt b/release/windows/blendthumb/CMakeLists.txt
index f853c35457f..1e5f5131a36 100644
--- a/source/blender/quicktime/CMakeLists.txt
+++ b/release/windows/blendthumb/CMakeLists.txt
@@ -23,40 +23,20 @@
#
# ***** END GPL LICENSE BLOCK *****
-set(INC
- .
- ../avi
- ../blenkernel
- ../blenlib
- ../imbuf
- ../imbuf/intern
- ../makesdna
- ../makesrna
- ../render/extern/include
- ../windowmanager
- ../../../intern/guardedalloc
+#-----------------------------------------------------------------------------
+cmake_minimum_required(VERSION 2.8)
+project(BlendThumb)
+
+#Bring the headers, such as Student.h into the project
+include_directories(${ZLIB_INCLUDE})
+
+#Can manually add the sources using the set command as follows:
+set(SOURCES src/BlenderThumb.cpp
+ src/BlendThumb.def
+ src/BlendThumb.rc
+ src/Dll.cpp
)
-
-set(INC_SYS
- ${QUICKTIME_INCLUDE_DIRS}
-)
-
-set(SRC
- apple/qtkit_import.m
- apple/qtkit_export.m
-
- quicktime_export.h
- quicktime_import.h
-)
-
-add_definitions(-DWITH_QUICKTIME)
-
-if(WITH_AUDASPACE)
- add_definitions(${AUDASPACE_DEFINITIONS})
-
- list(APPEND INC_SYS
- ${AUDASPACE_C_INCLUDE_DIRS}
- )
-endif()
-
-blender_add_lib(bf_quicktime "${SRC}" "${INC}" "${INC_SYS}")
+
+add_library(BlendThumb SHARED ${SOURCES})
+target_link_libraries(BlendThumb ${ZLIB_LIBS})
+install (TARGETS BlendThumb DESTINATION bin)
diff --git a/release/windows/blendthumb/src/BlendThumb.def b/release/windows/blendthumb/src/BlendThumb.def
new file mode 100644
index 00000000000..71f9236735f
--- /dev/null
+++ b/release/windows/blendthumb/src/BlendThumb.def
@@ -0,0 +1,5 @@
+EXPORTS
+ DllGetClassObject PRIVATE
+ DllCanUnloadNow PRIVATE
+ DllRegisterServer PRIVATE
+ DllUnregisterServer PRIVATE \ No newline at end of file
diff --git a/release/windows/blendthumb/src/BlendThumb.rc b/release/windows/blendthumb/src/BlendThumb.rc
new file mode 100644
index 00000000000..5dfd416b0c5
--- /dev/null
+++ b/release/windows/blendthumb/src/BlendThumb.rc
@@ -0,0 +1,26 @@
+#define IDR_VERSION1 1
+
+IDR_VERSION1 VERSIONINFO
+FILEVERSION 1,4,0,0
+PRODUCTVERSION 2,78,0,0
+FILEOS 0x00000004
+FILETYPE 0x00000002
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "FFFF04B0"
+ BEGIN
+ VALUE "FileVersion", "1.4\0"
+ VALUE "ProductVersion", "2.78\0"
+ VALUE "FileDescription", "Blender Thumbnail Handler\0"
+ VALUE "OriginalFilename", "BlendThumb.dll\0"
+ VALUE "ProductName", "Blender\0"
+ VALUE "LegalCopyright", "GPL2, 2016\0"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x0409, 0x04B0
+ END
+END
+
diff --git a/release/windows/blendthumb/src/BlenderThumb.cpp b/release/windows/blendthumb/src/BlenderThumb.cpp
new file mode 100644
index 00000000000..508b9f74852
--- /dev/null
+++ b/release/windows/blendthumb/src/BlenderThumb.cpp
@@ -0,0 +1,324 @@
+/*
+ * ***** 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <shlwapi.h>
+#include <thumbcache.h> // For IThumbnailProvider.
+#include <new>
+
+#pragma comment(lib, "shlwapi.lib")
+
+// this thumbnail provider implements IInitializeWithStream to enable being hosted
+// in an isolated process for robustness
+
+class CBlendThumb : public IInitializeWithStream, public IThumbnailProvider
+{
+public:
+ CBlendThumb() : _cRef(1), _pStream(NULL) {}
+
+ virtual ~CBlendThumb()
+ {
+ if (_pStream)
+ {
+ _pStream->Release();
+ }
+ }
+
+ // IUnknown
+ IFACEMETHODIMP QueryInterface(REFIID riid, void **ppv)
+ {
+ static const QITAB qit[] =
+ {
+ QITABENT(CBlendThumb, IInitializeWithStream),
+ QITABENT(CBlendThumb, IThumbnailProvider),
+ { 0 },
+ };
+ return QISearch(this, qit, riid, ppv);
+ }
+
+ IFACEMETHODIMP_(ULONG) AddRef()
+ {
+ return InterlockedIncrement(&_cRef);
+ }
+
+ IFACEMETHODIMP_(ULONG) Release()
+ {
+ ULONG cRef = InterlockedDecrement(&_cRef);
+ if (!cRef)
+ {
+ delete this;
+ }
+ return cRef;
+ }
+
+ // IInitializeWithStream
+ IFACEMETHODIMP Initialize(IStream *pStream, DWORD grfMode);
+
+ // IThumbnailProvider
+ IFACEMETHODIMP GetThumbnail(UINT cx, HBITMAP *phbmp, WTS_ALPHATYPE *pdwAlpha);
+
+private:
+ long _cRef;
+ IStream *_pStream; // provided during initialization.
+};
+
+HRESULT CBlendThumb_CreateInstance(REFIID riid, void **ppv)
+{
+ CBlendThumb *pNew = new (std::nothrow) CBlendThumb();
+ HRESULT hr = pNew ? S_OK : E_OUTOFMEMORY;
+ if (SUCCEEDED(hr))
+ {
+ hr = pNew->QueryInterface(riid, ppv);
+ pNew->Release();
+ }
+ return hr;
+}
+
+// IInitializeWithStream
+IFACEMETHODIMP CBlendThumb::Initialize(IStream *pStream, DWORD)
+{
+ HRESULT hr = E_UNEXPECTED; // can only be inited once
+ if (_pStream == NULL)
+ {
+ // take a reference to the stream if we have not been inited yet
+ hr = pStream->QueryInterface(&_pStream);
+ }
+ return hr;
+}
+
+#include <math.h>
+#include <zlib.h>
+#include "Wincodec.h"
+const unsigned char gzip_magic[3] = { 0x1f, 0x8b, 0x08 };
+
+// IThumbnailProvider
+IFACEMETHODIMP CBlendThumb::GetThumbnail(UINT cx, HBITMAP *phbmp, WTS_ALPHATYPE *pdwAlpha)
+{
+ ULONG BytesRead;
+ HRESULT hr = S_FALSE;
+ LARGE_INTEGER SeekPos;
+
+ // Compressed?
+ unsigned char in_magic[3];
+ _pStream->Read(&in_magic,3,&BytesRead);
+ bool gzipped = true;
+ for ( int i=0; i < 3; i++ )
+ if ( in_magic[i] != gzip_magic[i] )
+ {
+ gzipped = false;
+ break;
+ }
+
+ if (gzipped)
+ {
+ // Zlib inflate
+ z_stream stream;
+ stream.zalloc = Z_NULL;
+ stream.zfree = Z_NULL;
+ stream.opaque = Z_NULL;
+
+ // Get compressed file length
+ SeekPos.QuadPart = 0;
+ _pStream->Seek(SeekPos,STREAM_SEEK_END,NULL);
+
+ // Get compressed and uncompressed size
+ uLong source_size;
+ uLongf dest_size;
+ //SeekPos.QuadPart = -4; // last 4 bytes define size of uncompressed file
+ //ULARGE_INTEGER Tell;
+ //_pStream->Seek(SeekPos,STREAM_SEEK_END,&Tell);
+ //source_size = (uLong)Tell.QuadPart + 4; // src
+ //_pStream->Read(&dest_size,4,&BytesRead); // dest
+ dest_size = 1024*70; // thumbnail is currently always inside the first 65KB...if it moves or enlargens this line will have to change or go!
+ source_size = (uLong)max(SeekPos.QuadPart,dest_size); // for safety, assume no compression
+
+ // Input
+ Bytef* src = new Bytef[source_size];
+ stream.next_in = (Bytef*)src;
+ stream.avail_in = (uInt)source_size;
+
+ // Output
+ Bytef* dest = new Bytef[dest_size];
+ stream.next_out = (Bytef*)dest;
+ stream.avail_out = dest_size;
+
+ // IStream to src
+ SeekPos.QuadPart = 0;
+ _pStream->Seek(SeekPos,STREAM_SEEK_SET,NULL);
+ _pStream->Read(src,source_size,&BytesRead);
+
+ // Do the inflation
+ int err;
+ err = inflateInit2(&stream,16); // 16 means "gzip"...nice!
+ err = inflate(&stream, Z_FINISH);
+ err = inflateEnd(&stream);
+
+ // Replace the IStream, which is read-only
+ _pStream->Release();
+ _pStream = SHCreateMemStream(dest,dest_size);
+
+ delete[] src;
+ delete[] dest;
+ }
+
+ // Blender version, early out if sub 2.5
+ SeekPos.QuadPart = 9;
+ _pStream->Seek(SeekPos,STREAM_SEEK_SET,NULL);
+ char version[4];
+ version[3] = '\0';
+ _pStream->Read(&version,3,&BytesRead);
+ if ( BytesRead != 3)
+ return E_UNEXPECTED;
+ int iVersion = atoi(version);
+ if ( iVersion < 250 )
+ return S_FALSE;
+
+ // 32 or 64 bit blend?
+ SeekPos.QuadPart = 7;
+ _pStream->Seek(SeekPos,STREAM_SEEK_SET,NULL);
+
+ char _PointerSize;
+ _pStream->Read(&_PointerSize,1,&BytesRead);
+
+ int PointerSize = _PointerSize == '_' ? 4 : 8;
+ int HeaderSize = 16 + PointerSize;
+
+ // Find and read thumbnail ("TEST") block
+ SeekPos.QuadPart = 12;
+ _pStream->Seek(SeekPos,STREAM_SEEK_SET,NULL);
+ int BlockOffset = 12;
+ while ( _pStream )
+ {
+ // Scan current block
+ char BlockName[5];
+ BlockName[4] = '\0';
+ int BlockSize = 0;
+
+ if (_pStream->Read(BlockName,4,&BytesRead) == S_OK && _pStream->Read((void*)&BlockSize,4,&BytesRead) == S_OK)
+ {
+ if ( strcmp (BlockName,"TEST") != 0 )
+ {
+ SeekPos.QuadPart = BlockOffset += HeaderSize + BlockSize;
+ _pStream->Seek(SeekPos,STREAM_SEEK_SET,NULL);
+ continue;
+ }
+ }
+ else break; // eof
+
+ // Found the block
+ SeekPos.QuadPart = BlockOffset + HeaderSize;
+ _pStream->Seek(SeekPos,STREAM_SEEK_SET,NULL);
+
+ int width, height;
+ _pStream->Read((char*)&width,4,&BytesRead);
+ _pStream->Read((char*)&height,4,&BytesRead);
+ BlockSize -= 8;
+
+ // Isolate RGBA data
+ char* pRGBA = new char[BlockSize];
+ _pStream->Read(pRGBA,BlockSize,&BytesRead);
+
+ if (BytesRead != (ULONG)BlockSize)
+ return E_UNEXPECTED;
+
+ // Convert to BGRA for Windows
+ for (int i=0; i < BlockSize; i+=4 )
+ {
+ #define RED_BYTE pRGBA[i]
+ #define BLUE_BYTE pRGBA[i+2]
+
+ char red = RED_BYTE;
+ RED_BYTE = BLUE_BYTE;
+ BLUE_BYTE = red;
+ }
+
+ // Flip vertically (Blender stores it upside-down)
+ unsigned int LineSize = width*4;
+ char* FlippedImage = new char[BlockSize];
+ for (int i=0; i<height; i++)
+ {
+ if ( 0 != memcpy_s(&FlippedImage[ (height - i - 1)*LineSize ],LineSize,&pRGBA[ i*LineSize ],LineSize))
+ return E_UNEXPECTED;
+ }
+ delete[] pRGBA;
+ pRGBA = FlippedImage;
+
+ // Create image
+ *phbmp = CreateBitmap(width,height,1,32,pRGBA);
+ if (!*phbmp)
+ return E_FAIL;
+ *pdwAlpha = WTSAT_ARGB; // it's actually BGRA, not sure why this works
+
+ // Scale down if required
+ if ( (unsigned)width > cx || (unsigned)height > cx )
+ {
+ float scale = 1.0f / (max(width,height) / (float)cx);
+ LONG NewWidth = (LONG)(width *scale);
+ LONG NewHeight = (LONG)(height *scale);
+
+#ifdef _DEBUG
+#if 1
+ MessageBox(0,L"Attach now",L"Debugging",MB_OK);
+#endif
+#endif
+ IWICImagingFactory *pImgFac;
+ hr = CoCreateInstance(CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pImgFac));
+
+ IWICBitmap* WICBmp;
+ hr = pImgFac->CreateBitmapFromHBITMAP(*phbmp,0,WICBitmapUseAlpha,&WICBmp);
+
+ BITMAPINFO bmi = {};
+ bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);
+ bmi.bmiHeader.biWidth = NewWidth;
+ bmi.bmiHeader.biHeight = -NewHeight;
+ bmi.bmiHeader.biPlanes = 1;
+ bmi.bmiHeader.biBitCount = 32;
+ bmi.bmiHeader.biCompression = BI_RGB;
+
+ BYTE *pBits;
+ HBITMAP ResizedHBmp = CreateDIBSection(NULL, &bmi, DIB_RGB_COLORS, (void**)&pBits, NULL, 0);
+ hr = ResizedHBmp ? S_OK : E_OUTOFMEMORY;
+ if (SUCCEEDED(hr))
+ {
+ IWICBitmapScaler* pIScaler;
+ hr = pImgFac->CreateBitmapScaler(&pIScaler);
+ hr = pIScaler->Initialize(WICBmp,NewWidth,NewHeight,WICBitmapInterpolationModeFant);
+
+ WICRect rect = {0, 0, NewWidth, NewHeight};
+ hr = pIScaler->CopyPixels(&rect, NewWidth * 4, NewWidth * NewHeight * 4, pBits);
+
+ if (SUCCEEDED(hr))
+ {
+ DeleteObject(*phbmp);
+ *phbmp = ResizedHBmp;
+ }
+ else
+ DeleteObject(ResizedHBmp);
+
+ pIScaler->Release();
+ }
+ WICBmp->Release();
+ pImgFac->Release();
+ }
+ else
+ hr = S_OK;
+ break;
+ }
+ return hr;
+}
diff --git a/release/windows/blendthumb/src/Dll.cpp b/release/windows/blendthumb/src/Dll.cpp
new file mode 100644
index 00000000000..09ccd34ff8e
--- /dev/null
+++ b/release/windows/blendthumb/src/Dll.cpp
@@ -0,0 +1,277 @@
+/*
+ * ***** 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <objbase.h>
+#include <shlwapi.h>
+#include <thumbcache.h> // For IThumbnailProvider.
+#include <shlobj.h> // For SHChangeNotify
+#include <new>
+
+extern HRESULT CBlendThumb_CreateInstance(REFIID riid, void **ppv);
+
+#define SZ_CLSID_BLENDTHUMBHANDLER L"{D45F043D-F17F-4e8a-8435-70971D9FA46D}"
+#define SZ_BLENDTHUMBHANDLER L"Blender Thumbnail Handler"
+const CLSID CLSID_BlendThumbHandler = { 0xd45f043d, 0xf17f, 0x4e8a, { 0x84, 0x35, 0x70, 0x97, 0x1d, 0x9f, 0xa4, 0x6d } };
+
+typedef HRESULT (*PFNCREATEINSTANCE)(REFIID riid, void **ppvObject);
+struct CLASS_OBJECT_INIT
+{
+ const CLSID *pClsid;
+ PFNCREATEINSTANCE pfnCreate;
+};
+
+// add classes supported by this module here
+const CLASS_OBJECT_INIT c_rgClassObjectInit[] =
+{
+ { &CLSID_BlendThumbHandler, CBlendThumb_CreateInstance }
+};
+
+
+long g_cRefModule = 0;
+
+// Handle the the DLL's module
+HINSTANCE g_hInst = NULL;
+
+// Standard DLL functions
+STDAPI_(BOOL) DllMain(HINSTANCE hInstance, DWORD dwReason, void *)
+{
+ if (dwReason == DLL_PROCESS_ATTACH)
+ {
+ g_hInst = hInstance;
+ DisableThreadLibraryCalls(hInstance);
+ }
+ return TRUE;
+}
+
+STDAPI DllCanUnloadNow()
+{
+ // Only allow the DLL to be unloaded after all outstanding references have been released
+ return (g_cRefModule == 0) ? S_OK : S_FALSE;
+}
+
+void DllAddRef()
+{
+ InterlockedIncrement(&g_cRefModule);
+}
+
+void DllRelease()
+{
+ InterlockedDecrement(&g_cRefModule);
+}
+
+class CClassFactory : public IClassFactory
+{
+public:
+ static HRESULT CreateInstance(REFCLSID clsid, const CLASS_OBJECT_INIT *pClassObjectInits, size_t cClassObjectInits, REFIID riid, void **ppv)
+ {
+ *ppv = NULL;
+ HRESULT hr = CLASS_E_CLASSNOTAVAILABLE;
+ for (size_t i = 0; i < cClassObjectInits; i++)
+ {
+ if (clsid == *pClassObjectInits[i].pClsid)
+ {
+ IClassFactory *pClassFactory = new (std::nothrow) CClassFactory(pClassObjectInits[i].pfnCreate);
+ hr = pClassFactory ? S_OK : E_OUTOFMEMORY;
+ if (SUCCEEDED(hr))
+ {
+ hr = pClassFactory->QueryInterface(riid, ppv);
+ pClassFactory->Release();
+ }
+ break; // match found
+ }
+ }
+ return hr;
+ }
+
+ CClassFactory(PFNCREATEINSTANCE pfnCreate) : _cRef(1), _pfnCreate(pfnCreate)
+ {
+ DllAddRef();
+ }
+
+ // IUnknown
+ IFACEMETHODIMP QueryInterface(REFIID riid, void ** ppv)
+ {
+ static const QITAB qit[] =
+ {
+ QITABENT(CClassFactory, IClassFactory),
+ { 0 }
+ };
+ return QISearch(this, qit, riid, ppv);
+ }
+
+ IFACEMETHODIMP_(ULONG) AddRef()
+ {
+ return InterlockedIncrement(&_cRef);
+ }
+
+ IFACEMETHODIMP_(ULONG) Release()
+ {
+ long cRef = InterlockedDecrement(&_cRef);
+ if (cRef == 0)
+ {
+ delete this;
+ }
+ return cRef;
+ }
+
+ // IClassFactory
+ IFACEMETHODIMP CreateInstance(IUnknown *punkOuter, REFIID riid, void **ppv)
+ {
+ return punkOuter ? CLASS_E_NOAGGREGATION : _pfnCreate(riid, ppv);
+ }
+
+ IFACEMETHODIMP LockServer(BOOL fLock)
+ {
+ if (fLock)
+ {
+ DllAddRef();
+ }
+ else
+ {
+ DllRelease();
+ }
+ return S_OK;
+ }
+
+private:
+ ~CClassFactory()
+ {
+ DllRelease();
+ }
+
+ long _cRef;
+ PFNCREATEINSTANCE _pfnCreate;
+};
+
+STDAPI DllGetClassObject(REFCLSID clsid, REFIID riid, void **ppv)
+{
+ return CClassFactory::CreateInstance(clsid, c_rgClassObjectInit, ARRAYSIZE(c_rgClassObjectInit), riid, ppv);
+}
+
+// A struct to hold the information required for a registry entry
+
+struct REGISTRY_ENTRY
+{
+ HKEY hkeyRoot;
+ PCWSTR pszKeyName;
+ PCWSTR pszValueName;
+ DWORD dwValueType;
+ PCWSTR pszData;
+};
+
+// Creates a registry key (if needed) and sets the default value of the key
+
+HRESULT CreateRegKeyAndSetValue(const REGISTRY_ENTRY *pRegistryEntry)
+{
+ HKEY hKey;
+ HRESULT hr = HRESULT_FROM_WIN32(RegCreateKeyExW(pRegistryEntry->hkeyRoot, pRegistryEntry->pszKeyName,
+ 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &hKey, NULL));
+ if (SUCCEEDED(hr))
+ {
+ // All this just to support REG_DWORD...
+ DWORD size;
+ DWORD data;
+ BYTE* lpData = (LPBYTE) pRegistryEntry->pszData;
+ switch (pRegistryEntry->dwValueType)
+ {
+ case REG_SZ:
+ size = ((DWORD) wcslen(pRegistryEntry->pszData) + 1) * sizeof(WCHAR);
+ break;
+ case REG_DWORD:
+ size = sizeof(DWORD);
+ data = (DWORD)pRegistryEntry->pszData;
+ lpData = (BYTE*)&data;
+ break;
+ default:
+ return E_INVALIDARG;
+ }
+
+ hr = HRESULT_FROM_WIN32(RegSetValueExW(hKey, pRegistryEntry->pszValueName, 0, pRegistryEntry->dwValueType,
+ lpData, size ));
+ RegCloseKey(hKey);
+ }
+ return hr;
+}
+
+//
+// Registers this COM server
+//
+STDAPI DllRegisterServer()
+{
+ HRESULT hr;
+
+ WCHAR szModuleName[MAX_PATH];
+
+ if (!GetModuleFileNameW(g_hInst, szModuleName, ARRAYSIZE(szModuleName)))
+ {
+ hr = HRESULT_FROM_WIN32(GetLastError());
+ }
+ else
+ {
+ const REGISTRY_ENTRY rgRegistryEntries[] =
+ {
+ // RootKey KeyName ValueName ValueType Data
+ {HKEY_CURRENT_USER, L"Software\\Classes\\CLSID\\" SZ_CLSID_BLENDTHUMBHANDLER, NULL, REG_SZ, SZ_BLENDTHUMBHANDLER},
+ {HKEY_CURRENT_USER, L"Software\\Classes\\CLSID\\" SZ_CLSID_BLENDTHUMBHANDLER L"\\InProcServer32", NULL, REG_SZ, szModuleName},
+ {HKEY_CURRENT_USER, L"Software\\Classes\\CLSID\\" SZ_CLSID_BLENDTHUMBHANDLER L"\\InProcServer32", L"ThreadingModel", REG_SZ, L"Apartment"},
+ {HKEY_CURRENT_USER, L"Software\\Classes\\.blend\\", L"Treatment", REG_DWORD, 0}, // doesn't appear to do anything...
+ {HKEY_CURRENT_USER, L"Software\\Classes\\.blend\\ShellEx\\{e357fccd-a995-4576-b01f-234630154e96}", NULL, REG_SZ, SZ_CLSID_BLENDTHUMBHANDLER},
+ };
+
+ hr = S_OK;
+ for (int i = 0; i < ARRAYSIZE(rgRegistryEntries) && SUCCEEDED(hr); i++)
+ {
+ hr = CreateRegKeyAndSetValue(&rgRegistryEntries[i]);
+ }
+ }
+ if (SUCCEEDED(hr))
+ {
+ // This tells the shell to invalidate the thumbnail cache. This is important because any .blend files
+ // viewed before registering this handler would otherwise show cached blank thumbnails.
+ SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
+ }
+ return hr;
+}
+
+//
+// Unregisters this COM server
+//
+STDAPI DllUnregisterServer()
+{
+ HRESULT hr = S_OK;
+
+ const PCWSTR rgpszKeys[] =
+ {
+ L"Software\\Classes\\CLSID\\" SZ_CLSID_BLENDTHUMBHANDLER,
+ L"Software\\Classes\\.blend\\ShellEx\\{e357fccd-a995-4576-b01f-234630154e96}"
+ };
+
+ // Delete the registry entries
+ for (int i = 0; i < ARRAYSIZE(rgpszKeys) && SUCCEEDED(hr); i++)
+ {
+ hr = HRESULT_FROM_WIN32(RegDeleteTreeW(HKEY_CURRENT_USER, rgpszKeys[i]));
+ if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
+ {
+ // If the registry entry has already been deleted, say S_OK.
+ hr = S_OK;
+ }
+ }
+ return hr;
+}
diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt
index 564ca473903..c2fac8fc7d7 100644
--- a/source/blender/CMakeLists.txt
+++ b/source/blender/CMakeLists.txt
@@ -142,10 +142,6 @@ if(WITH_CODEC_AVI)
add_subdirectory(avi)
endif()
-if(WITH_CODEC_QUICKTIME)
- add_subdirectory(quicktime)
-endif()
-
if(WITH_PYTHON)
add_subdirectory(python)
endif()
diff --git a/source/blender/alembic/intern/abc_camera.cc b/source/blender/alembic/intern/abc_camera.cc
index 16416205983..aa5d77ce4ec 100644
--- a/source/blender/alembic/intern/abc_camera.cc
+++ b/source/blender/alembic/intern/abc_camera.cc
@@ -49,12 +49,13 @@ using Alembic::AbcGeom::kWrapExisting;
/* ************************************************************************** */
-AbcCameraWriter::AbcCameraWriter(Scene *scene,
+AbcCameraWriter::AbcCameraWriter(EvaluationContext *eval_ctx,
+ Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings)
- : AbcObjectWriter(scene, ob, time_sampling, settings, parent)
+ : AbcObjectWriter(eval_ctx, scene, ob, time_sampling, settings, parent)
{
OCamera camera(parent->alembicXform(), m_name, m_time_sampling);
m_camera_schema = camera.getSchema();
diff --git a/source/blender/alembic/intern/abc_camera.h b/source/blender/alembic/intern/abc_camera.h
index 16c5cccd5ea..772b7a6aec6 100644
--- a/source/blender/alembic/intern/abc_camera.h
+++ b/source/blender/alembic/intern/abc_camera.h
@@ -35,7 +35,8 @@ class AbcCameraWriter : public AbcObjectWriter {
Alembic::AbcGeom::OFloatProperty m_eye_separation;
public:
- AbcCameraWriter(Scene *scene,
+ AbcCameraWriter(EvaluationContext *eval_ctx,
+ Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
diff --git a/source/blender/alembic/intern/abc_curves.cc b/source/blender/alembic/intern/abc_curves.cc
index f73fe957fea..5328c471093 100644
--- a/source/blender/alembic/intern/abc_curves.cc
+++ b/source/blender/alembic/intern/abc_curves.cc
@@ -71,12 +71,13 @@ using Alembic::AbcGeom::OV2fGeomParam;
/* ************************************************************************** */
-AbcCurveWriter::AbcCurveWriter(Scene *scene,
+AbcCurveWriter::AbcCurveWriter(EvaluationContext *eval_ctx,
+ Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings)
- : AbcObjectWriter(scene, ob, time_sampling, settings, parent)
+ : AbcObjectWriter(eval_ctx, scene, ob, time_sampling, settings, parent)
{
OCurves curves(parent->alembicXform(), m_name, m_time_sampling);
m_schema = curves.getSchema();
diff --git a/source/blender/alembic/intern/abc_curves.h b/source/blender/alembic/intern/abc_curves.h
index a9231f947b2..73cc8b35e27 100644
--- a/source/blender/alembic/intern/abc_curves.h
+++ b/source/blender/alembic/intern/abc_curves.h
@@ -36,7 +36,8 @@ class AbcCurveWriter : public AbcObjectWriter {
Alembic::AbcGeom::OCurvesSchema::Sample m_sample;
public:
- AbcCurveWriter(Scene *scene,
+ AbcCurveWriter(EvaluationContext *eval_ctx,
+ Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
diff --git a/source/blender/alembic/intern/abc_customdata.cc b/source/blender/alembic/intern/abc_customdata.cc
index 1d2bc689027..d6e7a80d174 100644
--- a/source/blender/alembic/intern/abc_customdata.cc
+++ b/source/blender/alembic/intern/abc_customdata.cc
@@ -252,7 +252,31 @@ static void read_uvs(const CDStreamConfig &config, void *data,
}
}
-static void read_custom_data_mcols(const ICompoundProperty &arbGeomParams,
+static size_t mcols_out_of_bounds_check(
+ const size_t color_index,
+ const size_t array_size,
+ const std::string & iobject_full_name,
+ const PropertyHeader &prop_header,
+ bool &r_bounds_warning_given)
+{
+ if (color_index < array_size) {
+ return color_index;
+ }
+
+ if (!r_bounds_warning_given) {
+ std::cerr << "Alembic: color index out of bounds "
+ "reading face colors for object "
+ << iobject_full_name
+ << ", property "
+ << prop_header.getName() << std::endl;
+ r_bounds_warning_given = true;
+ }
+
+ return 0;
+}
+
+static void read_custom_data_mcols(const std::string & iobject_full_name,
+ const ICompoundProperty &arbGeomParams,
const PropertyHeader &prop_header,
const CDStreamConfig &config,
const Alembic::Abc::ISampleSelector &iss)
@@ -303,6 +327,8 @@ static void read_custom_data_mcols(const ICompoundProperty &arbGeomParams,
size_t face_index = 0;
size_t color_index;
+ bool bounds_warning_given = false;
+
for (int i = 0; i < config.totpoly; ++i) {
MPoly *poly = &mpolys[i];
MCol *cface = &cfaces[poly->loopstart + poly->totloop];
@@ -311,9 +337,14 @@ static void read_custom_data_mcols(const ICompoundProperty &arbGeomParams,
for (int j = 0; j < poly->totloop; ++j, ++face_index) {
--cface;
--mloop;
- color_index = is_facevarying ? face_index : mloop->v;
if (use_c3f_ptr) {
+ color_index = mcols_out_of_bounds_check(
+ is_facevarying ? face_index : mloop->v,
+ c3f_ptr->size(),
+ iobject_full_name, prop_header,
+ bounds_warning_given);
+
const Imath::C3f &color = (*c3f_ptr)[color_index];
cface->a = FTOCHAR(color[0]);
cface->r = FTOCHAR(color[1]);
@@ -321,6 +352,12 @@ static void read_custom_data_mcols(const ICompoundProperty &arbGeomParams,
cface->b = 255;
}
else {
+ color_index = mcols_out_of_bounds_check(
+ is_facevarying ? face_index : mloop->v,
+ c4f_ptr->size(),
+ iobject_full_name, prop_header,
+ bounds_warning_given);
+
const Imath::C4f &color = (*c4f_ptr)[color_index];
cface->a = FTOCHAR(color[0]);
cface->r = FTOCHAR(color[1]);
@@ -356,7 +393,10 @@ static void read_custom_data_uvs(const ICompoundProperty &prop,
read_uvs(config, cd_data, sample.getVals(), sample.getIndices());
}
-void read_custom_data(const ICompoundProperty &prop, const CDStreamConfig &config, const Alembic::Abc::ISampleSelector &iss)
+void read_custom_data(const std::string & iobject_full_name,
+ const ICompoundProperty &prop,
+ const CDStreamConfig &config,
+ const Alembic::Abc::ISampleSelector &iss)
{
if (!prop.valid()) {
return;
@@ -386,7 +426,7 @@ void read_custom_data(const ICompoundProperty &prop, const CDStreamConfig &confi
continue;
}
- read_custom_data_mcols(prop, prop_header, config, iss);
+ read_custom_data_mcols(iobject_full_name, prop, prop_header, config, iss);
continue;
}
}
diff --git a/source/blender/alembic/intern/abc_customdata.h b/source/blender/alembic/intern/abc_customdata.h
index 9e671fde386..b3072a2c9f7 100644
--- a/source/blender/alembic/intern/abc_customdata.h
+++ b/source/blender/alembic/intern/abc_customdata.h
@@ -96,7 +96,8 @@ void write_custom_data(const OCompoundProperty &prop,
CustomData *data,
int data_type);
-void read_custom_data(const ICompoundProperty &prop,
+void read_custom_data(const std::string & iobject_full_name,
+ const ICompoundProperty &prop,
const CDStreamConfig &config,
const Alembic::Abc::ISampleSelector &iss);
diff --git a/source/blender/alembic/intern/abc_exporter.cc b/source/blender/alembic/intern/abc_exporter.cc
index 680913e45ea..df2bc52aa2c 100644
--- a/source/blender/alembic/intern/abc_exporter.cc
+++ b/source/blender/alembic/intern/abc_exporter.cc
@@ -163,11 +163,12 @@ static bool export_object(const ExportSettings * const settings, const Base * co
/* ************************************************************************** */
-AbcExporter::AbcExporter(Scene *scene, const char *filename, ExportSettings &settings)
+AbcExporter::AbcExporter(EvaluationContext *eval_ctx, Scene *scene, const char *filename, ExportSettings &settings)
: m_settings(settings)
, m_filename(filename)
, m_trans_sampling_index(0)
, m_shape_sampling_index(0)
+ , m_eval_ctx(eval_ctx)
, m_scene(scene)
, m_writer(NULL)
{}
@@ -383,7 +384,7 @@ void AbcExporter::exploreTransform(EvaluationContext *eval_ctx, Base *ob_base, O
}
if (object_type_is_exportable(ob)) {
- createTransformWriter(ob, parent, dupliObParent);
+ createTransformWriter(eval_ctx, ob, parent, dupliObParent);
}
ListBase *lb = object_duplilist(eval_ctx, m_scene, ob);
@@ -415,7 +416,7 @@ void AbcExporter::exploreTransform(EvaluationContext *eval_ctx, Base *ob_base, O
free_object_duplilist(lb);
}
-AbcTransformWriter * AbcExporter::createTransformWriter(Object *ob, Object *parent, Object *dupliObParent)
+AbcTransformWriter * AbcExporter::createTransformWriter(EvaluationContext *eval_ctx, Object *ob, Object *parent, Object *dupliObParent)
{
/* An object should not be its own parent, or we'll get infinite loops. */
BLI_assert(ob != parent);
@@ -450,29 +451,29 @@ AbcTransformWriter * AbcExporter::createTransformWriter(Object *ob, Object *pare
* return the parent's AbcTransformWriter pointer. */
if (parent->parent) {
if (parent == dupliObParent) {
- parent_writer = createTransformWriter(parent, parent->parent, NULL);
+ parent_writer = createTransformWriter(eval_ctx, parent, parent->parent, NULL);
}
else {
- parent_writer = createTransformWriter(parent, parent->parent, dupliObParent);
+ parent_writer = createTransformWriter(eval_ctx, parent, parent->parent, dupliObParent);
}
}
else if (parent == dupliObParent) {
if (dupliObParent->parent == NULL) {
- parent_writer = createTransformWriter(parent, NULL, NULL);
+ parent_writer = createTransformWriter(eval_ctx, parent, NULL, NULL);
}
else {
- parent_writer = createTransformWriter(parent, dupliObParent->parent, dupliObParent->parent);
+ parent_writer = createTransformWriter(eval_ctx, parent, dupliObParent->parent, dupliObParent->parent);
}
}
else {
- parent_writer = createTransformWriter(parent, dupliObParent, dupliObParent);
+ parent_writer = createTransformWriter(eval_ctx, parent, dupliObParent, dupliObParent);
}
BLI_assert(parent_writer);
alembic_parent = parent_writer->alembicXform();
}
- my_writer = new AbcTransformWriter(ob, alembic_parent, parent_writer,
+ my_writer = new AbcTransformWriter(eval_ctx, ob, alembic_parent, parent_writer,
m_trans_sampling_index, m_settings);
/* When flattening, the matrix of the dupliobject has to be added. */
@@ -540,10 +541,10 @@ void AbcExporter::createParticleSystemsWriters(Object *ob, AbcTransformWriter *x
if (m_settings.export_hair && psys->part->type == PART_HAIR) {
m_settings.export_child_hairs = true;
- m_shapes.push_back(new AbcHairWriter(m_scene, ob, xform, m_shape_sampling_index, m_settings, psys));
+ m_shapes.push_back(new AbcHairWriter(m_eval_ctx, m_scene, ob, xform, m_shape_sampling_index, m_settings, psys));
}
else if (m_settings.export_particles && psys->part->type == PART_EMITTER) {
- m_shapes.push_back(new AbcPointsWriter(m_scene, ob, xform, m_shape_sampling_index, m_settings, psys));
+ m_shapes.push_back(new AbcPointsWriter(m_eval_ctx, m_scene, ob, xform, m_shape_sampling_index, m_settings, psys));
}
}
}
@@ -583,7 +584,7 @@ void AbcExporter::createShapeWriter(Base *ob_base, Object *dupliObParent)
return;
}
- m_shapes.push_back(new AbcMeshWriter(m_scene, ob, xform, m_shape_sampling_index, m_settings));
+ m_shapes.push_back(new AbcMeshWriter(m_eval_ctx, m_scene, ob, xform, m_shape_sampling_index, m_settings));
break;
}
case OB_SURF:
@@ -594,7 +595,7 @@ void AbcExporter::createShapeWriter(Base *ob_base, Object *dupliObParent)
return;
}
- m_shapes.push_back(new AbcNurbsWriter(m_scene, ob, xform, m_shape_sampling_index, m_settings));
+ m_shapes.push_back(new AbcNurbsWriter(m_eval_ctx, m_scene, ob, xform, m_shape_sampling_index, m_settings));
break;
}
case OB_CURVE:
@@ -605,7 +606,7 @@ void AbcExporter::createShapeWriter(Base *ob_base, Object *dupliObParent)
return;
}
- m_shapes.push_back(new AbcCurveWriter(m_scene, ob, xform, m_shape_sampling_index, m_settings));
+ m_shapes.push_back(new AbcCurveWriter(m_eval_ctx, m_scene, ob, xform, m_shape_sampling_index, m_settings));
break;
}
case OB_CAMERA:
@@ -613,7 +614,7 @@ void AbcExporter::createShapeWriter(Base *ob_base, Object *dupliObParent)
Camera *cam = static_cast<Camera *>(ob->data);
if (cam->type == CAM_PERSP) {
- m_shapes.push_back(new AbcCameraWriter(m_scene, ob, xform, m_shape_sampling_index, m_settings));
+ m_shapes.push_back(new AbcCameraWriter(m_eval_ctx, m_scene, ob, xform, m_shape_sampling_index, m_settings));
}
break;
diff --git a/source/blender/alembic/intern/abc_exporter.h b/source/blender/alembic/intern/abc_exporter.h
index 15158a9ef51..9c5fb69234c 100644
--- a/source/blender/alembic/intern/abc_exporter.h
+++ b/source/blender/alembic/intern/abc_exporter.h
@@ -90,6 +90,7 @@ class AbcExporter {
unsigned int m_trans_sampling_index, m_shape_sampling_index;
+ EvaluationContext *m_eval_ctx;
Scene *m_scene;
ArchiveWriter *m_writer;
@@ -101,7 +102,7 @@ class AbcExporter {
std::vector<AbcObjectWriter *> m_shapes;
public:
- AbcExporter(Scene *scene, const char *filename, ExportSettings &settings);
+ AbcExporter(EvaluationContext *eval_ctx, Scene *scene, const char *filename, ExportSettings &settings);
~AbcExporter();
void operator()(Main *bmain, float &progress, bool &was_canceled);
@@ -116,7 +117,7 @@ private:
Alembic::Abc::TimeSamplingPtr createTimeSampling(double step);
void createTransformWritersHierarchy(EvaluationContext *eval_ctx);
- AbcTransformWriter * createTransformWriter(Object *ob, Object *parent, Object *dupliObParent);
+ AbcTransformWriter * createTransformWriter(EvaluationContext *eval_ctx, Object *ob, Object *parent, Object *dupliObParent);
void exploreTransform(EvaluationContext *eval_ctx, Base *ob_base, Object *parent, Object *dupliObParent);
void exploreObject(EvaluationContext *eval_ctx, Base *ob_base, Object *dupliObParent);
void createShapeWriters(EvaluationContext *eval_ctx);
diff --git a/source/blender/alembic/intern/abc_hair.cc b/source/blender/alembic/intern/abc_hair.cc
index 8f8ed2019d5..2579aa3cc36 100644
--- a/source/blender/alembic/intern/abc_hair.cc
+++ b/source/blender/alembic/intern/abc_hair.cc
@@ -49,13 +49,14 @@ using Alembic::AbcGeom::OV2fGeomParam;
/* ************************************************************************** */
-AbcHairWriter::AbcHairWriter(Scene *scene,
+AbcHairWriter::AbcHairWriter(EvaluationContext *eval_ctx,
+ Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings,
ParticleSystem *psys)
- : AbcObjectWriter(scene, ob, time_sampling, settings, parent)
+ : AbcObjectWriter(eval_ctx, scene, ob, time_sampling, settings, parent)
, m_uv_warning_shown(false)
{
m_psys = psys;
@@ -76,7 +77,7 @@ void AbcHairWriter::do_write()
return;
}
- DerivedMesh *dm = mesh_create_derived_render(m_scene, m_object, CD_MASK_MESH);
+ DerivedMesh *dm = mesh_create_derived_render(m_eval_ctx, m_scene, m_object, CD_MASK_MESH);
DM_ensure_tessface(dm);
std::vector<Imath::V3f> verts;
diff --git a/source/blender/alembic/intern/abc_hair.h b/source/blender/alembic/intern/abc_hair.h
index 61f5fe361f8..8190c449205 100644
--- a/source/blender/alembic/intern/abc_hair.h
+++ b/source/blender/alembic/intern/abc_hair.h
@@ -40,7 +40,8 @@ class AbcHairWriter : public AbcObjectWriter {
bool m_uv_warning_shown;
public:
- AbcHairWriter(Scene *scene,
+ AbcHairWriter(EvaluationContext *eval_ctx,
+ Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
diff --git a/source/blender/alembic/intern/abc_mesh.cc b/source/blender/alembic/intern/abc_mesh.cc
index bc62db5702c..de0ed421eb7 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -286,12 +286,13 @@ static ModifierData *get_liquid_sim_modifier(Scene *scene, Object *ob)
/* ************************************************************************** */
-AbcMeshWriter::AbcMeshWriter(Scene *scene,
+AbcMeshWriter::AbcMeshWriter(EvaluationContext *eval_ctx,
+ Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings)
- : AbcObjectWriter(scene, ob, time_sampling, settings, parent)
+ : AbcObjectWriter(eval_ctx, scene, ob, time_sampling, settings, parent)
{
m_is_animated = isAnimated();
m_subsurf_mod = NULL;
@@ -519,7 +520,7 @@ DerivedMesh *AbcMeshWriter::getFinalMesh()
m_subsurf_mod->mode |= eModifierMode_DisableTemporary;
}
- DerivedMesh *dm = mesh_create_derived_render(m_scene, m_object, CD_MASK_MESH);
+ DerivedMesh *dm = mesh_create_derived_render(m_eval_ctx, m_scene, m_object, CD_MASK_MESH);
if (m_subsurf_mod) {
m_subsurf_mod->mode &= ~eModifierMode_DisableTemporary;
@@ -680,17 +681,17 @@ static void assign_materials(Main *bmain, Object *ob, const std::map<std::string
std::string mat_name = it->first;
mat_iter = mat_map.find(mat_name.c_str());
- Material *assigned_name;
+ Material *assigned_mat;
if (mat_iter == mat_map.end()) {
- assigned_name = BKE_material_add(bmain, mat_name.c_str());
- mat_map[mat_name] = assigned_name;
+ assigned_mat = BKE_material_add(bmain, mat_name.c_str());
+ mat_map[mat_name] = assigned_mat;
}
else {
- assigned_name = mat_iter->second;
+ assigned_mat = mat_iter->second;
}
- assign_material(ob, assigned_name, it->second, BKE_MAT_ASSIGN_OBDATA);
+ assign_material(ob, assigned_mat, it->second, BKE_MAT_ASSIGN_OBDATA);
}
}
}
@@ -936,7 +937,8 @@ static void get_weight_and_index(CDStreamConfig &config,
config.ceil_index = i1;
}
-static void read_mesh_sample(ImportSettings *settings,
+static void read_mesh_sample(const std::string & iobject_full_name,
+ ImportSettings *settings,
const IPolyMeshSchema &schema,
const ISampleSelector &selector,
CDStreamConfig &config,
@@ -974,10 +976,9 @@ static void read_mesh_sample(ImportSettings *settings,
}
if ((settings->read_flag & (MOD_MESHSEQ_READ_UV | MOD_MESHSEQ_READ_COLOR)) != 0) {
- read_custom_data(schema.getArbGeomParams(), config, selector);
+ read_custom_data(iobject_full_name,
+ schema.getArbGeomParams(), config, selector);
}
-
- /* TODO: face sets */
}
CDStreamConfig get_config(DerivedMesh *dm)
@@ -1105,7 +1106,8 @@ DerivedMesh *AbcMeshReader::read_derivedmesh(DerivedMesh *dm,
config.time = sample_sel.getRequestedTime();
bool do_normals = false;
- read_mesh_sample(&settings, m_schema, sample_sel, config, do_normals);
+ read_mesh_sample(m_iobject.getFullName(),
+ &settings, m_schema, sample_sel, config, do_normals);
if (new_dm) {
/* Check if we had ME_SMOOTH flag set to restore it. */
@@ -1116,6 +1118,16 @@ DerivedMesh *AbcMeshReader::read_derivedmesh(DerivedMesh *dm,
CDDM_calc_normals(new_dm);
CDDM_calc_edges(new_dm);
+ /* Here we assume that the number of materials doesn't change, i.e. that
+ * the material slots that were created when the object was loaded from
+ * Alembic are still valid now. */
+ size_t num_polys = new_dm->getNumPolys(new_dm);
+ if (num_polys > 0) {
+ MPoly *dmpolies = new_dm->getPolyArray(new_dm);
+ std::map<std::string, int> mat_map;
+ assign_facesets_to_mpoly(sample_sel, 0, dmpolies, num_polys, mat_map);
+ }
+
return new_dm;
}
@@ -1126,8 +1138,11 @@ DerivedMesh *AbcMeshReader::read_derivedmesh(DerivedMesh *dm,
return dm;
}
-void AbcMeshReader::readFaceSetsSample(Main *bmain, Mesh *mesh, size_t poly_start,
- const ISampleSelector &sample_sel)
+void AbcMeshReader::assign_facesets_to_mpoly(
+ const ISampleSelector &sample_sel,
+ size_t poly_start,
+ MPoly *mpoly, int totpoly,
+ std::map<std::string, int> & r_mat_map)
{
std::vector<std::string> face_sets;
m_schema.getFaceSetNames(face_sets);
@@ -1136,21 +1151,21 @@ void AbcMeshReader::readFaceSetsSample(Main *bmain, Mesh *mesh, size_t poly_star
return;
}
- std::map<std::string, int> mat_map;
int current_mat = 0;
for (int i = 0; i < face_sets.size(); ++i) {
const std::string &grp_name = face_sets[i];
- if (mat_map.find(grp_name) == mat_map.end()) {
- mat_map[grp_name] = 1 + current_mat++;
+ if (r_mat_map.find(grp_name) == r_mat_map.end()) {
+ r_mat_map[grp_name] = 1 + current_mat++;
}
- const int assigned_mat = mat_map[grp_name];
+ const int assigned_mat = r_mat_map[grp_name];
const IFaceSet faceset = m_schema.getFaceSet(grp_name);
if (!faceset.valid()) {
+ std::cerr << " Face set " << grp_name << " invalid for " << m_object_name << "\n";
continue;
}
@@ -1162,16 +1177,25 @@ void AbcMeshReader::readFaceSetsSample(Main *bmain, Mesh *mesh, size_t poly_star
for (size_t l = 0; l < num_group_faces; l++) {
size_t pos = (*group_faces)[l] + poly_start;
- if (pos >= mesh->totpoly) {
+ if (pos >= totpoly) {
std::cerr << "Faceset overflow on " << faceset.getName() << '\n';
break;
}
- MPoly &poly = mesh->mpoly[pos];
+ MPoly &poly = mpoly[pos];
poly.mat_nr = assigned_mat - 1;
}
}
+}
+
+void AbcMeshReader::readFaceSetsSample(Main *bmain, Mesh *mesh, size_t poly_start,
+ const ISampleSelector &sample_sel)
+{
+ std::map<std::string, int> mat_map;
+ assign_facesets_to_mpoly(sample_sel,
+ poly_start, mesh->mpoly, mesh->totpoly,
+ mat_map);
utils::assign_materials(bmain, m_object, mat_map);
}
@@ -1190,7 +1214,8 @@ ABC_INLINE MEdge *find_edge(MEdge *edges, int totedge, int v1, int v2)
return NULL;
}
-static void read_subd_sample(ImportSettings *settings,
+static void read_subd_sample(const std::string & iobject_full_name,
+ ImportSettings *settings,
const ISubDSchema &schema,
const ISampleSelector &selector,
CDStreamConfig &config)
@@ -1225,10 +1250,9 @@ static void read_subd_sample(ImportSettings *settings,
}
if ((settings->read_flag & (MOD_MESHSEQ_READ_UV | MOD_MESHSEQ_READ_COLOR)) != 0) {
- read_custom_data(schema.getArbGeomParams(), config, selector);
+ read_custom_data(iobject_full_name,
+ schema.getArbGeomParams(), config, selector);
}
-
- /* TODO: face sets */
}
/* ************************************************************************** */
@@ -1357,7 +1381,8 @@ DerivedMesh *AbcSubDReader::read_derivedmesh(DerivedMesh *dm,
/* Only read point data when streaming meshes, unless we need to create new ones. */
CDStreamConfig config = get_config(new_dm ? new_dm : dm);
config.time = sample_sel.getRequestedTime();
- read_subd_sample(&settings, m_schema, sample_sel, config);
+ read_subd_sample(m_iobject.getFullName(),
+ &settings, m_schema, sample_sel, config);
if (new_dm) {
/* Check if we had ME_SMOOTH flag set to restore it. */
diff --git a/source/blender/alembic/intern/abc_mesh.h b/source/blender/alembic/intern/abc_mesh.h
index 6bf1dde3d1d..e0b2365e134 100644
--- a/source/blender/alembic/intern/abc_mesh.h
+++ b/source/blender/alembic/intern/abc_mesh.h
@@ -50,7 +50,8 @@ class AbcMeshWriter : public AbcObjectWriter {
bool m_is_subd;
public:
- AbcMeshWriter(Scene *scene,
+ AbcMeshWriter(EvaluationContext *eval_ctx,
+ Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
@@ -112,6 +113,11 @@ public:
private:
void readFaceSetsSample(Main *bmain, Mesh *mesh, size_t poly_start,
const Alembic::AbcGeom::ISampleSelector &sample_sel);
+
+ void assign_facesets_to_mpoly(const Alembic::Abc::ISampleSelector &sample_sel,
+ size_t poly_start,
+ MPoly *mpoly, int totpoly,
+ std::map<std::string, int> & r_mat_map);
};
/* ************************************************************************** */
diff --git a/source/blender/alembic/intern/abc_nurbs.cc b/source/blender/alembic/intern/abc_nurbs.cc
index eaef06fd6d1..0532191a28d 100644
--- a/source/blender/alembic/intern/abc_nurbs.cc
+++ b/source/blender/alembic/intern/abc_nurbs.cc
@@ -60,12 +60,13 @@ using Alembic::AbcGeom::ONuPatchSchema;
/* ************************************************************************** */
-AbcNurbsWriter::AbcNurbsWriter(Scene *scene,
+AbcNurbsWriter::AbcNurbsWriter(EvaluationContext *eval_ctx,
+ Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings)
- : AbcObjectWriter(scene, ob, time_sampling, settings, parent)
+ : AbcObjectWriter(eval_ctx, scene, ob, time_sampling, settings, parent)
{
m_is_animated = isAnimated();
diff --git a/source/blender/alembic/intern/abc_nurbs.h b/source/blender/alembic/intern/abc_nurbs.h
index abe460a8988..3d20c5c60bb 100644
--- a/source/blender/alembic/intern/abc_nurbs.h
+++ b/source/blender/alembic/intern/abc_nurbs.h
@@ -32,7 +32,8 @@ class AbcNurbsWriter : public AbcObjectWriter {
bool m_is_animated;
public:
- AbcNurbsWriter(Scene *scene,
+ AbcNurbsWriter(EvaluationContext *eval_ctx,
+ Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
diff --git a/source/blender/alembic/intern/abc_object.cc b/source/blender/alembic/intern/abc_object.cc
index 8b169988096..98ebcf6debb 100644
--- a/source/blender/alembic/intern/abc_object.cc
+++ b/source/blender/alembic/intern/abc_object.cc
@@ -58,13 +58,15 @@ using Alembic::AbcGeom::OStringProperty;
/* ************************************************************************** */
-AbcObjectWriter::AbcObjectWriter(Scene *scene,
+AbcObjectWriter::AbcObjectWriter(EvaluationContext *eval_ctx,
+ Scene *scene,
Object *ob,
uint32_t time_sampling,
ExportSettings &settings,
AbcObjectWriter *parent)
: m_object(ob)
, m_settings(settings)
+ , m_eval_ctx(eval_ctx)
, m_scene(scene)
, m_time_sampling(time_sampling)
, m_first_frame(true)
@@ -139,6 +141,38 @@ AbcObjectReader::AbcObjectReader(const IObject &object, ImportSettings &settings
else {
m_object_name = m_data_name = parts[parts.size() - 1];
}
+
+ determine_inherits_xform();
+}
+
+/* Determine whether we can inherit our parent's XForm */
+void AbcObjectReader::determine_inherits_xform()
+{
+ m_inherits_xform = false;
+
+ IXform ixform = xform();
+ if (!ixform) {
+ return;
+ }
+
+ const IXformSchema & schema(ixform.getSchema());
+ if (!schema.valid()) {
+ std::cerr << "Alembic object " << ixform.getFullName()
+ << " has an invalid schema." << std::endl;
+ return;
+ }
+
+ m_inherits_xform = schema.getInheritsXforms();
+
+ IObject ixform_parent = ixform.getParent();
+ if (!ixform_parent.getParent()) {
+ /* The archive top object certainly is not a transform itself, so handle
+ * it as "no parent". */
+ m_inherits_xform = false;
+ }
+ else {
+ m_inherits_xform = ixform_parent && m_inherits_xform;
+ }
}
AbcObjectReader::~AbcObjectReader()
@@ -285,32 +319,10 @@ void AbcObjectReader::read_matrix(float r_mat[4][4], const float time,
return;
}
- bool has_alembic_parent;
- IObject ixform_parent = ixform.getParent();
- if (!ixform_parent.getParent()) {
- /* The archive top object certainly is not a transform itself, so handle
- * it as "no parent". */
- has_alembic_parent = false;
- }
- else {
- has_alembic_parent = ixform_parent && schema.getInheritsXforms();
-
- if (has_alembic_parent && m_object->parent == NULL) {
- /* TODO Sybren: This happened in some files. I think I solved it,
- * but I'll leave this check in here anyway until we've tested it
- * more thoroughly. Better than crashing on a null parent anyway. */
- std::cerr << "Alembic object " << m_iobject.getFullName()
- << " with transform " << ixform.getFullName()
- << " has an Alembic parent but no parent Blender object."
- << std::endl;
- has_alembic_parent = false;
- }
- }
-
const Imath::M44d matrix = get_matrix(schema, time);
convert_matrix(matrix, m_object, r_mat);
- if (has_alembic_parent) {
+ if (m_inherits_xform) {
/* In this case, the matrix in Alembic is in local coordinates, so
* convert to world matrix. To prevent us from reading and accumulating
* all parent matrices in the Alembic file, we assume that the Blender
diff --git a/source/blender/alembic/intern/abc_object.h b/source/blender/alembic/intern/abc_object.h
index 1462f93a422..6aa6224f8d5 100644
--- a/source/blender/alembic/intern/abc_object.h
+++ b/source/blender/alembic/intern/abc_object.h
@@ -44,6 +44,7 @@ protected:
Object *m_object;
ExportSettings &m_settings;
+ EvaluationContext *m_eval_ctx;
Scene *m_scene;
uint32_t m_time_sampling;
@@ -56,7 +57,8 @@ protected:
std::string m_name;
public:
- AbcObjectWriter(Scene *scene,
+ AbcObjectWriter(EvaluationContext *eval_ctx,
+ Scene *scene,
Object *ob,
uint32_t time_sampling,
ExportSettings &settings,
@@ -90,7 +92,7 @@ struct ImportSettings {
/* Length and frame offset of file sequences. */
int sequence_len;
- int offset;
+ int sequence_offset;
/* From MeshSeqCacheModifierData.read_flag */
int read_flag;
@@ -107,7 +109,7 @@ struct ImportSettings {
, is_sequence(false)
, set_frame_range(false)
, sequence_len(1)
- , offset(0)
+ , sequence_offset(0)
, read_flag(0)
, validate_meshes(false)
, cache_file(NULL)
@@ -143,6 +145,8 @@ protected:
* modifiers and/or constraints. */
int m_refcount;
+ bool m_inherits_xform;
+
public:
AbcObjectReader *parent_reader;
@@ -167,6 +171,7 @@ public:
const std::string & name() const { return m_name; }
const std::string & object_name() const { return m_object_name; }
const std::string & data_name() const { return m_data_name; }
+ bool inherits_xform() const { return m_inherits_xform; }
virtual bool valid() const = 0;
virtual bool accepts_object_type(const Alembic::AbcCoreAbstract::ObjectHeader &alembic_header,
@@ -194,6 +199,9 @@ public:
void read_matrix(float r_mat[4][4], const float time,
const float scale, bool &is_constant);
+
+protected:
+ void determine_inherits_xform();
};
Imath::M44d get_matrix(const Alembic::AbcGeom::IXformSchema &schema, const float time);
diff --git a/source/blender/alembic/intern/abc_points.cc b/source/blender/alembic/intern/abc_points.cc
index 80567cd6bf0..feb2eff5b9d 100644
--- a/source/blender/alembic/intern/abc_points.cc
+++ b/source/blender/alembic/intern/abc_points.cc
@@ -58,13 +58,14 @@ using Alembic::AbcGeom::OPointsSchema;
/* ************************************************************************** */
-AbcPointsWriter::AbcPointsWriter(Scene *scene,
+AbcPointsWriter::AbcPointsWriter(EvaluationContext *eval_ctx,
+ Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings,
ParticleSystem *psys)
- : AbcObjectWriter(scene, ob, time_sampling, settings, parent)
+ : AbcObjectWriter(eval_ctx, scene, ob, time_sampling, settings, parent)
{
m_psys = psys;
@@ -86,6 +87,7 @@ void AbcPointsWriter::do_write()
ParticleKey state;
ParticleSimulationData sim;
+ sim.eval_ctx = m_eval_ctx;
sim.scene = m_scene;
sim.ob = m_object;
sim.psys = m_psys;
diff --git a/source/blender/alembic/intern/abc_points.h b/source/blender/alembic/intern/abc_points.h
index 369a802d763..b60f1997aa8 100644
--- a/source/blender/alembic/intern/abc_points.h
+++ b/source/blender/alembic/intern/abc_points.h
@@ -38,7 +38,8 @@ class AbcPointsWriter : public AbcObjectWriter {
ParticleSystem *m_psys;
public:
- AbcPointsWriter(Scene *scene,
+ AbcPointsWriter(EvaluationContext *eval_ctx,
+ Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
diff --git a/source/blender/alembic/intern/abc_transform.cc b/source/blender/alembic/intern/abc_transform.cc
index 5392387663f..0a1480e62b0 100644
--- a/source/blender/alembic/intern/abc_transform.cc
+++ b/source/blender/alembic/intern/abc_transform.cc
@@ -57,12 +57,13 @@ static bool has_parent_camera(Object *ob)
/* ************************************************************************** */
-AbcTransformWriter::AbcTransformWriter(Object *ob,
+AbcTransformWriter::AbcTransformWriter(EvaluationContext *eval_ctx,
+ Object *ob,
const OObject &abc_parent,
AbcTransformWriter *parent,
unsigned int time_sampling,
ExportSettings &settings)
- : AbcObjectWriter(NULL, ob, time_sampling, settings, parent)
+ : AbcObjectWriter(eval_ctx, NULL, ob, time_sampling, settings, parent)
, m_proxy_from(NULL)
{
m_is_animated = hasAnimation(m_object);
diff --git a/source/blender/alembic/intern/abc_transform.h b/source/blender/alembic/intern/abc_transform.h
index 753a4247e9f..e82765cb169 100644
--- a/source/blender/alembic/intern/abc_transform.h
+++ b/source/blender/alembic/intern/abc_transform.h
@@ -44,7 +44,8 @@ public:
Object *m_proxy_from;
public:
- AbcTransformWriter(Object *ob,
+ AbcTransformWriter(EvaluationContext *eval_ctx,
+ Object *ob,
const Alembic::AbcGeom::OObject &abc_parent,
AbcTransformWriter *parent,
unsigned int time_sampling,
diff --git a/source/blender/alembic/intern/abc_util.cc b/source/blender/alembic/intern/abc_util.cc
index 8601dff54ed..8bdc7ae3455 100644
--- a/source/blender/alembic/intern/abc_util.cc
+++ b/source/blender/alembic/intern/abc_util.cc
@@ -358,10 +358,10 @@ AbcObjectReader *create_reader(const Alembic::AbcGeom::IObject &object, ImportSe
reader = new AbcCurveReader(object, settings);
}
else {
- std::cerr << "Alembic: unknown how to handle objects of schema "
+ std::cerr << "Alembic: unknown how to handle objects of schema '"
<< md.get("schemaObjTitle")
- << ", skipping object "
- << object.getFullName() << std::endl;
+ << "', skipping object '"
+ << object.getFullName() << "'" << std::endl;
}
return reader;
diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc
index 54b49330355..e7c7213cecb 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -230,6 +230,7 @@ static void find_iobject(const IObject &object, IObject &ret,
}
struct ExportJobData {
+ EvaluationContext eval_ctx;
Scene *scene;
Main *bmain;
@@ -262,7 +263,7 @@ static void export_startjob(void *customdata, short *stop, short *do_update, flo
try {
Scene *scene = data->scene;
- AbcExporter exporter(scene, data->filename, data->settings);
+ AbcExporter exporter(&data->eval_ctx, scene, data->filename, data->settings);
const int orig_frame = CFRA;
@@ -310,6 +311,9 @@ bool ABC_export(
bool as_background_job)
{
ExportJobData *job = static_cast<ExportJobData *>(MEM_mallocN(sizeof(ExportJobData), "ExportJobData"));
+
+ CTX_data_eval_ctx(C, &job->eval_ctx);
+
job->scene = scene;
job->bmain = CTX_data_main(C);
job->export_ok = false;
@@ -762,7 +766,7 @@ static void import_startjob(void *user_data, short *stop, short *do_update, floa
Scene *scene = data->scene;
if (data->settings.is_sequence) {
- SFRA = data->settings.offset;
+ SFRA = data->settings.sequence_offset;
EFRA = SFRA + (data->settings.sequence_len - 1);
CFRA = SFRA;
}
@@ -779,7 +783,7 @@ static void import_startjob(void *user_data, short *stop, short *do_update, floa
const AbcObjectReader *parent_reader = reader->parent_reader;
Object *ob = reader->object();
- if (parent_reader == NULL) {
+ if (parent_reader == NULL || !reader->inherits_xform()) {
ob->parent = NULL;
}
else {
@@ -902,7 +906,7 @@ bool ABC_import(bContext *C, const char *filepath, float scale, bool is_sequence
job->settings.is_sequence = is_sequence;
job->settings.set_frame_range = set_frame_range;
job->settings.sequence_len = sequence_len;
- job->settings.offset = offset;
+ job->settings.sequence_offset = offset;
job->settings.validate_meshes = validate_meshes;
job->error_code = ABC_NO_ERROR;
job->was_cancelled = false;
@@ -1022,6 +1026,10 @@ CacheReader *CacheReader_open_alembic_object(AbcArchiveHandle *handle, CacheRead
ImportSettings settings;
AbcObjectReader *abc_reader = create_reader(iobject, settings);
+ if (abc_reader == NULL) {
+ /* This object is not supported */
+ return NULL;
+ }
abc_reader->object(object);
abc_reader->incref();
diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h
index 1b967f889c0..22559edad22 100644
--- a/source/blender/blenfont/BLF_api.h
+++ b/source/blender/blenfont/BLF_api.h
@@ -41,7 +41,7 @@ struct rctf;
struct ColorManagedDisplay;
struct ResultBLF;
-int BLF_init(int points, int dpi);
+int BLF_init(void);
void BLF_exit(void);
void BLF_default_dpi(int dpi);
void BLF_default_set(int fontid);
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index 55c08361a47..24347d57917 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -97,15 +97,16 @@ static FontBLF *blf_get(int fontid)
return NULL;
}
-int BLF_init(int points, int dpi)
+int BLF_init(void)
{
int i;
for (i = 0; i < BLF_MAX_FONT; i++)
global_font[i] = NULL;
- global_font_points = points;
- global_font_dpi = dpi;
+ global_font_points = 11;
+ global_font_dpi = 72;
+
return blf_font_init();
}
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index 116724463ca..9bb44a726de 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -98,6 +98,7 @@ struct ColorBand;
struct GPUVertexAttribs;
struct GPUDrawObject;
struct PBVH;
+struct EvaluationContext;
/* number of sub-elements each mesh element has (for interpolation) */
#define SUB_ELEMS_VERT 0
@@ -191,7 +192,9 @@ struct DerivedMesh {
* \warning Typical access is done via #getLoopTriArray, #getNumLoopTri.
*/
struct {
- struct MLoopTri *array;
+ /* WARNING! swapping between array (ready-to-be-used data) and array_wip (where data is actually computed)
+ * shall always be protected by same lock as one used for looptris computing. */
+ struct MLoopTri *array, *array_wip;
int num;
int num_alloc;
} looptris;
@@ -199,7 +202,7 @@ struct DerivedMesh {
/* use for converting to BMesh which doesn't store bevel weight and edge crease by default */
char cd_flag;
- char tangent_mask; /* which tangent layers are calculated */
+ short tangent_mask; /* which tangent layers are calculated */
/** Calculate vert and face normals */
void (*calcNormals)(DerivedMesh *dm);
@@ -218,7 +221,7 @@ struct DerivedMesh {
/** Recalculates mesh tessellation */
void (*recalcTessellation)(DerivedMesh *dm);
- /** Loop tessellation cache */
+ /** Loop tessellation cache (WARNING! Only call inside threading-protected code!) */
void (*recalcLoopTri)(DerivedMesh *dm);
/** accessor functions */
const struct MLoopTri *(*getLoopTriArray)(DerivedMesh * dm);
@@ -604,7 +607,6 @@ void DM_ensure_normals(DerivedMesh *dm);
void DM_ensure_tessface(DerivedMesh *dm);
void DM_ensure_looptri_data(DerivedMesh *dm);
-void DM_ensure_looptri(DerivedMesh *dm);
void DM_verttri_from_looptri(MVertTri *verttri, const MLoop *mloop, const MLoopTri *looptri, int looptri_num);
void DM_update_tessface_data(DerivedMesh *dm);
@@ -658,56 +660,56 @@ void mesh_get_mapped_verts_coords(DerivedMesh *dm, float (*r_cos)[3], const int
/* */
DerivedMesh *mesh_get_derived_final(
- struct Scene *scene, struct Object *ob,
- CustomDataMask dataMask);
+ const struct EvaluationContext *eval_ctx, struct Scene *scene,
+ struct Object *ob, CustomDataMask dataMask);
DerivedMesh *mesh_get_derived_deform(
- struct Scene *scene, struct Object *ob,
- CustomDataMask dataMask);
+ const struct EvaluationContext *eval_ctx, struct Scene *scene,
+ struct Object *ob, CustomDataMask dataMask);
DerivedMesh *mesh_create_derived_for_modifier(
- struct Scene *scene, struct Object *ob,
+ const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
struct ModifierData *md, int build_shapekey_layers);
DerivedMesh *mesh_create_derived_render(
- struct Scene *scene, struct Object *ob,
- CustomDataMask dataMask);
+ const struct EvaluationContext *eval_ctx, struct Scene *scene,
+ struct Object *ob, CustomDataMask dataMask);
DerivedMesh *getEditDerivedBMesh(
struct BMEditMesh *em, struct Object *ob, CustomDataMask data_mask,
float (*vertexCos)[3]);
DerivedMesh *mesh_create_derived_index_render(
- struct Scene *scene, struct Object *ob,
- CustomDataMask dataMask, int index);
+ const struct EvaluationContext *eval_ctx, struct Scene *scene,
+ struct Object *ob, CustomDataMask dataMask, int index);
/* same as above but wont use render settings */
DerivedMesh *mesh_create_derived(struct Mesh *me, float (*vertCos)[3]);
DerivedMesh *mesh_create_derived_view(
- struct Scene *scene, struct Object *ob,
- CustomDataMask dataMask);
+ const struct EvaluationContext *eval_ctx, struct Scene *scene,
+ struct Object *ob, CustomDataMask dataMask);
DerivedMesh *mesh_create_derived_no_deform(
- struct Scene *scene, struct Object *ob,
- float (*vertCos)[3],
+ const struct EvaluationContext *eval_ctx, struct Scene *scene,
+ struct Object *ob, float (*vertCos)[3],
CustomDataMask dataMask);
DerivedMesh *mesh_create_derived_no_deform_render(
- struct Scene *scene, struct Object *ob,
- float (*vertCos)[3],
+ const struct EvaluationContext *eval_ctx, struct Scene *scene,
+ struct Object *ob, float (*vertCos)[3],
CustomDataMask dataMask);
/* for gameengine */
DerivedMesh *mesh_create_derived_no_virtual(
- struct Scene *scene, struct Object *ob, float (*vertCos)[3],
- CustomDataMask dataMask);
+ const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
+ float (*vertCos)[3], CustomDataMask dataMask);
DerivedMesh *mesh_create_derived_physics(
- struct Scene *scene, struct Object *ob, float (*vertCos)[3],
- CustomDataMask dataMask);
+ const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
+ float (*vertCos)[3], CustomDataMask dataMask);
DerivedMesh *editbmesh_get_derived_base(
struct Object *ob, struct BMEditMesh *em, CustomDataMask data_mask);
DerivedMesh *editbmesh_get_derived_cage(
- struct Scene *scene, struct Object *,
+ const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *,
struct BMEditMesh *em, CustomDataMask dataMask);
DerivedMesh *editbmesh_get_derived_cage_and_final(
- struct Scene *scene, struct Object *,
+ const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *,
struct BMEditMesh *em, CustomDataMask dataMask,
DerivedMesh **r_final);
@@ -716,7 +718,7 @@ DerivedMesh *object_get_derived_final(struct Object *ob, const bool for_render);
float (*editbmesh_get_vertex_cos(struct BMEditMesh *em, int *r_numVerts))[3];
bool editbmesh_modifier_is_enabled(struct Scene *scene, struct ModifierData *md, DerivedMesh *dm);
void makeDerivedMesh(
- struct Scene *scene, struct Object *ob, struct BMEditMesh *em,
+ const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct BMEditMesh *em,
CustomDataMask dataMask, const bool build_shapekey_layers);
void weight_to_rgb(float r_rgb[3], const float weight);
@@ -768,6 +770,10 @@ void DM_calc_tangents_names_from_gpu(
const struct GPUVertexAttribs *gattribs,
char (*tangent_names)[MAX_NAME], int *tangent_names_count);
+void DM_add_named_tangent_layer_for_uv(
+ CustomData *uv_data, CustomData *tan_data, int numLoopData,
+ const char *layer_name);
+
void DM_calc_loop_tangents(
DerivedMesh *dm, bool calc_active_tangent, const char (*tangent_names)[MAX_NAME],
int tangent_names_count);
@@ -803,11 +809,5 @@ struct MEdge *DM_get_edge_array(struct DerivedMesh *dm, bool *r_allocated);
struct MLoop *DM_get_loop_array(struct DerivedMesh *dm, bool *r_allocated);
struct MPoly *DM_get_poly_array(struct DerivedMesh *dm, bool *r_allocated);
struct MFace *DM_get_tessface_array(struct DerivedMesh *dm, bool *r_allocated);
-const MLoopTri *DM_get_looptri_array(
- DerivedMesh *dm,
- const MVert *mvert,
- const MPoly *mpoly, int mpoly_len,
- const MLoop *mloop, int mloop_len,
- bool *r_allocated);
#endif /* __BKE_DERIVEDMESH_H__ */
diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h
index 5db0c3c9130..28be2b04c71 100644
--- a/source/blender/blenkernel/BKE_action.h
+++ b/source/blender/blenkernel/BKE_action.h
@@ -57,8 +57,9 @@ extern "C" {
/* Allocate a new bAction with the given name */
struct bAction *add_empty_action(struct Main *bmain, const char name[]);
-/* Allocate a copy of the given Action and all its data */
-struct bAction *BKE_action_copy(struct Main *bmain, const struct bAction *src);
+void BKE_action_copy_data(struct Main *bmain, struct bAction *act_dst, const struct bAction *act_src, const int flag);
+/* Allocate a copy of the given Action and all its data */
+struct bAction *BKE_action_copy(struct Main *bmain, const struct bAction *act_src);
/* Deallocate all of the Action's data, but not the Action itself */
void BKE_action_free(struct bAction *act);
@@ -150,6 +151,7 @@ void BKE_pose_free_data_ex(struct bPose *pose, bool do_id_user);
void BKE_pose_free_data(struct bPose *pose);
void BKE_pose_free(struct bPose *pose);
void BKE_pose_free_ex(struct bPose *pose, bool do_id_user);
+void BKE_pose_copy_data_ex(struct bPose **dst, const struct bPose *src, const int flag, const bool copy_constraints);
void BKE_pose_copy_data(struct bPose **dst, const struct bPose *src, const bool copy_constraints);
void BKE_pose_channel_copy_data(struct bPoseChannel *pchan, const struct bPoseChannel *pchan_from);
struct bPoseChannel *BKE_pose_channel_find_name(const struct bPose *pose, const char *name);
diff --git a/source/blender/blenkernel/BKE_anim.h b/source/blender/blenkernel/BKE_anim.h
index 584f0da323a..9beff85b87c 100644
--- a/source/blender/blenkernel/BKE_anim.h
+++ b/source/blender/blenkernel/BKE_anim.h
@@ -41,6 +41,7 @@ struct bAnimVizSettings;
struct bMotionPath;
struct bPoseChannel;
struct ReportList;
+struct bContext;
/* ---------------------------------------------------- */
/* Animation Visualization */
@@ -53,7 +54,7 @@ void animviz_free_motionpath(struct bMotionPath *mpath);
struct bMotionPath *animviz_verify_motionpaths(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan);
void animviz_get_object_motionpaths(struct Object *ob, ListBase *targets);
-void animviz_calc_motionpaths(struct Scene *scene, ListBase *targets);
+void animviz_calc_motionpaths(struct bContext *C, struct Scene *scene, ListBase *targets);
/* ---------------------------------------------------- */
/* Curve Paths */
@@ -65,8 +66,8 @@ int where_on_path(struct Object *ob, float ctime, float vec[4], float dir[3], fl
/* ---------------------------------------------------- */
/* Dupli-Geometry */
-struct ListBase *object_duplilist_ex(struct EvaluationContext *eval_ctx, struct Scene *sce, struct Object *ob, bool update);
-struct ListBase *object_duplilist(struct EvaluationContext *eval_ctx, struct Scene *sce, struct Object *ob);
+struct ListBase *object_duplilist_ex(const struct EvaluationContext *eval_ctx, struct Scene *sce, struct Object *ob, bool update);
+struct ListBase *object_duplilist(const struct EvaluationContext *eval_ctx, struct Scene *sce, struct Object *ob);
void free_object_duplilist(struct ListBase *lb);
int count_duplilist(struct Object *ob);
@@ -80,7 +81,7 @@ typedef struct DupliApplyData {
DupliExtraData *extra;
} DupliApplyData;
-DupliApplyData *duplilist_apply(struct Object *ob, struct Scene *scene, struct ListBase *duplilist);
+DupliApplyData *duplilist_apply(const struct EvaluationContext *eval_ctx, struct Object *ob, struct Scene *scene, struct ListBase *duplilist);
void duplilist_restore(struct ListBase *duplilist, DupliApplyData *apply_data);
void duplilist_free_apply_data(DupliApplyData *apply_data);
diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h
index 3e6e24a28b0..622767baa10 100644
--- a/source/blender/blenkernel/BKE_animsys.h
+++ b/source/blender/blenkernel/BKE_animsys.h
@@ -67,10 +67,10 @@ bool BKE_animdata_set_action(struct ReportList *reports, struct ID *id, struct b
void BKE_animdata_free(struct ID *id, const bool do_id_user);
/* Copy AnimData */
-struct AnimData *BKE_animdata_copy(struct AnimData *adt, const bool do_action);
+struct AnimData *BKE_animdata_copy(struct Main *bmain, struct AnimData *adt, const bool do_action);
/* Copy AnimData */
-bool BKE_animdata_copy_id(struct ID *id_to, struct ID *id_from, const bool do_action);
+bool BKE_animdata_copy_id(struct Main *bmain, struct ID *id_to, struct ID *id_from, const bool do_action);
/* Copy AnimData Actions */
void BKE_animdata_copy_id_action(struct ID *id, const bool set_newid);
@@ -102,7 +102,7 @@ struct KS_Path *BKE_keyingset_add_path(struct KeyingSet *ks, struct ID *id, cons
struct KS_Path *BKE_keyingset_find_path(struct KeyingSet *ks, struct ID *id, const char group_name[], const char rna_path[], int array_index, int group_mode);
/* Copy all KeyingSets in the given list */
-void BKE_keyingsets_copy(struct ListBase *newlist, struct ListBase *list);
+void BKE_keyingsets_copy(struct ListBase *newlist, const struct ListBase *list);
/* Free the given Keying Set path */
void BKE_keyingset_free_path(struct KeyingSet *ks, struct KS_Path *ksp);
@@ -195,8 +195,8 @@ void animsys_evaluate_action_group(struct PointerRNA *ptr, struct bAction *act,
struct EvaluationContext;
-void BKE_animsys_eval_animdata(struct EvaluationContext *eval_ctx, struct ID *id);
-void BKE_animsys_eval_driver(struct EvaluationContext *eval_ctx, struct ID *id, struct FCurve *fcurve);
+void BKE_animsys_eval_animdata(const struct EvaluationContext *eval_ctx, struct ID *id);
+void BKE_animsys_eval_driver(const struct EvaluationContext *eval_ctx, struct ID *id, struct FCurve *fcurve);
/* ************************************* */
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h
index fa3bf0e79c9..192690c074c 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -35,6 +35,7 @@
struct bPose;
struct Bone;
+struct EvaluationContext;
struct GHash;
struct Main;
struct bArmature;
@@ -78,6 +79,7 @@ int BKE_armature_bonelist_count(struct ListBase *lb);
void BKE_armature_bonelist_free(struct ListBase *lb);
void BKE_armature_free(struct bArmature *arm);
void BKE_armature_make_local(struct Main *bmain, struct bArmature *arm, const bool lib_local);
+void BKE_armature_copy_data(struct Main *bmain, struct bArmature *arm_dst, const struct bArmature *arm_src, const int flag);
struct bArmature *BKE_armature_copy(struct Main *bmain, const struct bArmature *arm);
/* Bounding box. */
@@ -98,8 +100,8 @@ void BKE_armature_where_is(struct bArmature *arm);
void BKE_armature_where_is_bone(struct Bone *bone, struct Bone *prevbone, const bool use_recursion);
void BKE_pose_clear_pointers(struct bPose *pose);
void BKE_pose_rebuild(struct Object *ob, struct bArmature *arm);
-void BKE_pose_where_is(struct Scene *scene, struct Object *ob);
-void BKE_pose_where_is_bone(struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime, bool do_extra);
+void BKE_pose_where_is(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
+void BKE_pose_where_is_bone(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime, bool do_extra);
void BKE_pose_where_is_bone_tail(struct bPoseChannel *pchan);
/* get_objectspace_bone_matrix has to be removed still */
@@ -116,7 +118,7 @@ void BKE_armature_loc_pose_to_bone(struct bPoseChannel *pchan, const float inloc
void BKE_armature_mat_bone_to_pose(struct bPoseChannel *pchan, float inmat[4][4], float outmat[4][4]);
void BKE_armature_mat_pose_to_delta(float delta_mat[4][4], float pose_mat[4][4], float arm_mat[4][4]);
-void BKE_armature_mat_pose_to_bone_ex(struct Object *ob, struct bPoseChannel *pchan, float inmat[4][4], float outmat[4][4]);
+void BKE_armature_mat_pose_to_bone_ex(const struct EvaluationContext *eval_ctx, struct Object *ob, struct bPoseChannel *pchan, float inmat[4][4], float outmat[4][4]);
void BKE_pchan_mat3_to_rot(struct bPoseChannel *pchan, float mat[3][3], bool use_compat);
void BKE_pchan_apply_mat4(struct bPoseChannel *pchan, float mat[4][4], bool use_comat);
@@ -154,7 +156,6 @@ void b_bone_spline_setup(struct bPoseChannel *pchan, int rest, Mat4 result_array
struct bKinematicConstraint;
struct bPose;
struct bSplineIKConstraint;
-struct EvaluationContext;
struct bPoseChannel *BKE_armature_ik_solver_find_root(
struct bPoseChannel *pchan,
@@ -164,42 +165,49 @@ struct bPoseChannel *BKE_armature_splineik_solver_find_root(
struct bSplineIKConstraint *data);
void BKE_pose_splineik_init_tree(struct Scene *scene, struct Object *ob, float ctime);
-void BKE_splineik_execute_tree(struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan_root, float ctime);
+void BKE_splineik_execute_tree(
+ const struct EvaluationContext *eval_ctx, struct Scene *scene,
+ struct Object *ob, struct bPoseChannel *pchan_root, float ctime);
-void BKE_pose_eval_init(struct EvaluationContext *eval_ctx,
+void BKE_pose_eval_init(const struct EvaluationContext *eval_ctx,
struct Scene *scene,
struct Object *ob,
struct bPose *pose);
-void BKE_pose_eval_bone(struct EvaluationContext *eval_ctx,
+void BKE_pose_eval_init_ik(const struct EvaluationContext *eval_ctx,
+ struct Scene *scene,
+ struct Object *ob,
+ struct bPose *pose);
+
+void BKE_pose_eval_bone(const struct EvaluationContext *eval_ctx,
struct Scene *scene,
struct Object *ob,
struct bPoseChannel *pchan);
-void BKE_pose_constraints_evaluate(struct EvaluationContext *eval_ctx,
+void BKE_pose_constraints_evaluate(const struct EvaluationContext *eval_ctx,
struct Scene *scene,
struct Object *ob,
struct bPoseChannel *pchan);
-void BKE_pose_bone_done(struct EvaluationContext *eval_ctx,
+void BKE_pose_bone_done(const struct EvaluationContext *eval_ctx,
struct bPoseChannel *pchan);
-void BKE_pose_iktree_evaluate(struct EvaluationContext *eval_ctx,
+void BKE_pose_iktree_evaluate(const struct EvaluationContext *eval_ctx,
struct Scene *scene,
struct Object *ob,
struct bPoseChannel *rootchan);
-void BKE_pose_splineik_evaluate(struct EvaluationContext *eval_ctx,
+void BKE_pose_splineik_evaluate(const struct EvaluationContext *eval_ctx,
struct Scene *scene,
struct Object *ob,
struct bPoseChannel *rootchan);
-void BKE_pose_eval_flush(struct EvaluationContext *eval_ctx,
+void BKE_pose_eval_flush(const struct EvaluationContext *eval_ctx,
struct Scene *scene,
struct Object *ob,
struct bPose *pose);
-void BKE_pose_eval_proxy_copy(struct EvaluationContext *eval_ctx,
+void BKE_pose_eval_proxy_copy(const struct EvaluationContext *eval_ctx,
struct Object *ob);
#ifdef __cplusplus
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h
index d55926ffb1e..ec0bfa6f5fa 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -50,7 +50,6 @@ void BKE_blender_version_string(
void BKE_blender_userdef_set_data(struct UserDef *userdef);
void BKE_blender_userdef_free_data(struct UserDef *userdef);
-void BKE_blender_userdef_refresh(void);
void BKE_blender_userdef_set_app_template(struct UserDef *userdef);
diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h
index 42e4e73f2d5..7c2873046d5 100644
--- a/source/blender/blenkernel/BKE_brush.h
+++ b/source/blender/blenkernel/BKE_brush.h
@@ -44,6 +44,7 @@ void BKE_brush_system_exit(void);
void BKE_brush_init(struct Brush *brush);
struct Brush *BKE_brush_add(struct Main *bmain, const char *name, short ob_mode);
struct Brush *BKE_brush_first_search(struct Main *bmain, short ob_mode);
+void BKE_brush_copy_data(struct Main *bmain, struct Brush *brush_dst, const struct Brush *brush_src, const int flag);
struct Brush *BKE_brush_copy(struct Main *bmain, const struct Brush *brush);
void BKE_brush_make_local(struct Main *bmain, struct Brush *brush, const bool lib_local);
void BKE_brush_unlink(struct Main *bmain, struct Brush *brush);
@@ -69,11 +70,11 @@ void BKE_brush_randomize_texture_coords(struct UnifiedPaintSettings *ups, bool m
/* brush curve */
void BKE_brush_curve_preset(struct Brush *b, int preset);
float BKE_brush_curve_strength_clamped(struct Brush *br, float p, const float len);
-float BKE_brush_curve_strength(struct Brush *br, float p, const float len);
+float BKE_brush_curve_strength(const struct Brush *br, float p, const float len);
/* sampling */
float BKE_brush_sample_tex_3D(
- const struct Scene *scene, struct Brush *br, const float point[3],
+ const struct Scene *scene, const struct Brush *br, const float point[3],
float rgba[4], const int thread, struct ImagePool *pool);
float BKE_brush_sample_masktex(
const struct Scene *scene, struct Brush *br, const float point[2],
@@ -102,9 +103,11 @@ void BKE_brush_alpha_set(struct Scene *scene, struct Brush *brush, float alpha);
float BKE_brush_weight_get(const struct Scene *scene, const struct Brush *brush);
void BKE_brush_weight_set(const struct Scene *scene, struct Brush *brush, float value);
-int BKE_brush_use_locked_size(const struct Scene *scene, const struct Brush *brush);
-int BKE_brush_use_alpha_pressure(const struct Scene *scene, const struct Brush *brush);
-int BKE_brush_use_size_pressure(const struct Scene *scene, const struct Brush *brush);
+bool BKE_brush_use_locked_size(const struct Scene *scene, const struct Brush *brush);
+bool BKE_brush_use_alpha_pressure(const struct Scene *scene, const struct Brush *brush);
+bool BKE_brush_use_size_pressure(const struct Scene *scene, const struct Brush *brush);
+
+bool BKE_brush_sculpt_has_secondary_color(const struct Brush *brush);
/* scale unprojected radius to reflect a change in the brush's 2D size */
void BKE_brush_scale_unprojected_radius(
diff --git a/source/blender/blenkernel/BKE_cachefile.h b/source/blender/blenkernel/BKE_cachefile.h
index db8ddb2ba68..e0419d0e749 100644
--- a/source/blender/blenkernel/BKE_cachefile.h
+++ b/source/blender/blenkernel/BKE_cachefile.h
@@ -47,6 +47,8 @@ void BKE_cachefile_init(struct CacheFile *cache_file);
void BKE_cachefile_free(struct CacheFile *cache_file);
+void BKE_cachefile_copy_data(
+ struct Main *bmain, struct CacheFile *cache_file_dst, const struct CacheFile *cache_file_src, const int flag);
struct CacheFile *BKE_cachefile_copy(struct Main *bmain, const struct CacheFile *cache_file);
void BKE_cachefile_make_local(struct Main *bmain, struct CacheFile *cache_file, const bool lib_local);
diff --git a/source/blender/blenkernel/BKE_camera.h b/source/blender/blenkernel/BKE_camera.h
index 22165212ed8..2234cee0e0d 100644
--- a/source/blender/blenkernel/BKE_camera.h
+++ b/source/blender/blenkernel/BKE_camera.h
@@ -53,6 +53,7 @@ struct GPUFXSettings;
void BKE_camera_init(struct Camera *cam);
void *BKE_camera_add(struct Main *bmain, const char *name);
+void BKE_camera_copy_data(struct Main *bmain, struct Camera *cam_dst, const struct Camera *cam_src, const int flag);
struct Camera *BKE_camera_copy(struct Main *bmain, const struct Camera *cam);
void BKE_camera_make_local(struct Main *bmain, struct Camera *cam, const bool lib_local);
void BKE_camera_free(struct Camera *ca);
diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h
index 6c517bd02df..7f7cbd678e2 100644
--- a/source/blender/blenkernel/BKE_cloth.h
+++ b/source/blender/blenkernel/BKE_cloth.h
@@ -41,6 +41,7 @@ struct MFace;
struct DerivedMesh;
struct ClothModifierData;
struct CollisionModifierData;
+struct EvaluationContext;
#define DO_INLINE MALWAYS_INLINE
@@ -226,7 +227,7 @@ void cloth_free_contacts(ColliderContacts *collider_contacts, int totcolliders);
void cloth_free_modifier_extern (struct ClothModifierData *clmd );
void cloth_free_modifier (struct ClothModifierData *clmd );
void cloth_init (struct ClothModifierData *clmd );
-void clothModifier_do (struct ClothModifierData *clmd, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm, float (*vertexCos)[3]);
+void clothModifier_do(struct ClothModifierData *clmd, const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm, float (*vertexCos)[3]);
int cloth_uses_vgroup(struct ClothModifierData *clmd);
diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h
index 047d1787f76..cf7e2908360 100644
--- a/source/blender/blenkernel/BKE_constraint.h
+++ b/source/blender/blenkernel/BKE_constraint.h
@@ -40,6 +40,7 @@ struct ListBase;
struct Object;
struct Scene;
struct bPoseChannel;
+struct EvaluationContext;
/* ---------------------------------------------------------------------------- */
#ifdef __cplusplus
@@ -102,7 +103,7 @@ typedef struct bConstraintTypeInfo {
/* evaluation */
/* set the ct->matrix for the given constraint target (at the given ctime) */
- void (*get_target_matrix)(struct bConstraint *con, struct bConstraintOb *cob, struct bConstraintTarget *ct, float ctime);
+ void (*get_target_matrix)(const struct EvaluationContext *eval_ctx, struct bConstraint *con, struct bConstraintOb *cob, struct bConstraintTarget *ct, float ctime);
/* evaluate the constraint for the given time */
void (*evaluate_constraint)(struct bConstraint *con, struct bConstraintOb *cob, struct ListBase *targets);
} bConstraintTypeInfo;
@@ -120,6 +121,7 @@ void BKE_constraint_unique_name(struct bConstraint *con, struct ListBase *list);
void BKE_constraints_free(struct ListBase *list);
void BKE_constraints_free_ex(struct ListBase *list, bool do_id_user);
void BKE_constraints_copy(struct ListBase *dst, const struct ListBase *src, bool do_extern);
+void BKE_constraints_copy_ex(struct ListBase *dst, const struct ListBase *src, const int flag, bool do_extern);
void BKE_constraints_id_loop(struct ListBase *list, ConstraintIDFunc func, void *userdata);
void BKE_constraint_free_data(struct bConstraint *con);
void BKE_constraint_free_data_ex(struct bConstraint *con, bool do_id_user);
@@ -146,9 +148,10 @@ void BKE_constraints_clear_evalob(struct bConstraintOb *cob);
void BKE_constraint_mat_convertspace(
struct Object *ob, struct bPoseChannel *pchan, float mat[4][4], short from, short to, const bool keep_scale);
-void BKE_constraint_target_matrix_get(struct Scene *scene, struct bConstraint *con, int n, short ownertype, void *ownerdata, float mat[4][4], float ctime);
-void BKE_constraint_targets_for_solving_get(struct bConstraint *con, struct bConstraintOb *ob, struct ListBase *targets, float ctime);
-void BKE_constraints_solve(struct ListBase *conlist, struct bConstraintOb *cob, float ctime);
+void BKE_constraint_target_matrix_get(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct bConstraint *con,
+ int n, short ownertype, void *ownerdata, float mat[4][4], float ctime);
+void BKE_constraint_targets_for_solving_get(const struct EvaluationContext *eval_ctx, struct bConstraint *con, struct bConstraintOb *ob, struct ListBase *targets, float ctime);
+void BKE_constraints_solve(const struct EvaluationContext *eval_ctx, struct ListBase *conlist, struct bConstraintOb *cob, float ctime);
#ifdef __cplusplus
}
diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h
index b71f5a4aa8e..350d7a40875 100644
--- a/source/blender/blenkernel/BKE_context.h
+++ b/source/blender/blenkernel/BKE_context.h
@@ -73,6 +73,7 @@ struct SpaceText;
struct SpaceImage;
struct SpaceClip;
struct ID;
+struct EvaluationContext;
/* Structs */
@@ -152,6 +153,7 @@ struct SpaceLink *CTX_wm_space_data(const bContext *C);
struct ARegion *CTX_wm_region(const bContext *C);
void *CTX_wm_region_data(const bContext *C);
struct ARegion *CTX_wm_menu(const bContext *C);
+struct wmManipulatorGroup *CTX_wm_manipulator_group(const bContext *C);
struct ReportList *CTX_wm_reports(const bContext *C);
struct View3D *CTX_wm_view3d(const bContext *C);
@@ -179,6 +181,7 @@ void CTX_wm_screen_set(bContext *C, struct bScreen *screen); /* to be removed */
void CTX_wm_area_set(bContext *C, struct ScrArea *sa);
void CTX_wm_region_set(bContext *C, struct ARegion *region);
void CTX_wm_menu_set(bContext *C, struct ARegion *menu);
+void CTX_wm_manipulator_group_set(bContext *C, struct wmManipulatorGroup *mgroup);
const char *CTX_wm_operator_poll_msg_get(struct bContext *C);
void CTX_wm_operator_poll_msg_set(struct bContext *C, const char *msg);
@@ -308,6 +311,8 @@ int CTX_data_editable_gpencil_strokes(const bContext *C, ListBase *list);
struct Depsgraph *CTX_data_depsgraph(const bContext *C);
+void CTX_data_eval_ctx(const bContext *C, struct EvaluationContext *eval_ctx);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/BKE_crazyspace.h b/source/blender/blenkernel/BKE_crazyspace.h
index ee6c5c57678..31542cd6f8a 100644
--- a/source/blender/blenkernel/BKE_crazyspace.h
+++ b/source/blender/blenkernel/BKE_crazyspace.h
@@ -38,23 +38,24 @@ struct Scene;
struct Object;
struct BMEditMesh;
struct Mesh;
+struct EvaluationContext;
/* crazyspace.c */
float (*BKE_crazyspace_get_mapped_editverts(
- struct Scene *scene, struct Object *obedit))[3];
+ const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *obedit))[3];
void BKE_crazyspace_set_quats_editmesh(
struct BMEditMesh *em, float (*origcos)[3], float (*mappedcos)[3], float (*quats)[4],
const bool use_select);
void BKE_crazyspace_set_quats_mesh(
struct Mesh *me, float (*origcos)[3], float (*mappedcos)[3], float (*quats)[4]);
int BKE_crazyspace_get_first_deform_matrices_editbmesh(
- struct Scene *, struct Object *, struct BMEditMesh *em,
+ const struct EvaluationContext *eval_ctx, struct Scene *, struct Object *, struct BMEditMesh *em,
float (**deformmats)[3][3], float (**deformcos)[3]);
int BKE_sculpt_get_first_deform_matrices(
- struct Scene *scene, struct Object *ob,
+ const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
float (**deformmats)[3][3], float (**deformcos)[3]);
void BKE_crazyspace_build_sculpt(
- struct Scene *scene, struct Object *ob,
+ const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
float (**deformmats)[3][3], float (**deformcos)[3]);
#ifdef __cplusplus
diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h
index 4d55b663f68..06bef637107 100644
--- a/source/blender/blenkernel/BKE_curve.h
+++ b/source/blender/blenkernel/BKE_curve.h
@@ -36,6 +36,7 @@
struct BezTriple;
struct Curve;
struct EditNurb;
+struct EvaluationContext;
struct GHash;
struct ListBase;
struct Main;
@@ -78,6 +79,7 @@ void BKE_curve_free(struct Curve *cu);
void BKE_curve_editfont_free(struct Curve *cu);
void BKE_curve_init(struct Curve *cu);
struct Curve *BKE_curve_add(struct Main *bmain, const char *name, int type);
+void BKE_curve_copy_data(struct Main *bmain, struct Curve *cu_dst, const struct Curve *cu_src, const int flag);
struct Curve *BKE_curve_copy(struct Main *bmain, const struct Curve *cu);
void BKE_curve_make_local(struct Main *bmain, struct Curve *cu, const bool lib_local);
short BKE_curve_type_get(struct Curve *cu);
@@ -92,8 +94,8 @@ void BKE_curve_texspace_get(struct Curve *cu, float r_loc[3], float r_rot[3], fl
bool BKE_curve_minmax(struct Curve *cu, bool use_radius, float min[3], float max[3]);
bool BKE_curve_center_median(struct Curve *cu, float cent[3]);
bool BKE_curve_center_bounds(struct Curve *cu, float cent[3]);
-void BKE_curve_transform_ex(struct Curve *cu, float mat[4][4], const bool do_keys, const float unit_scale);
-void BKE_curve_transform(struct Curve *cu, float mat[4][4], const bool do_keys);
+void BKE_curve_transform_ex(struct Curve *cu, float mat[4][4], const bool do_keys, const bool do_props, const float unit_scale);
+void BKE_curve_transform(struct Curve *cu, float mat[4][4], const bool do_keys, const bool do_props);
void BKE_curve_translate(struct Curve *cu, float offset[3], const bool do_keys);
void BKE_curve_material_index_remove(struct Curve *cu, int index);
void BKE_curve_material_index_clear(struct Curve *cu);
@@ -121,13 +123,14 @@ void BKE_curve_editNurb_keyIndex_free(struct GHash **keyindex);
void BKE_curve_editNurb_free(struct Curve *cu);
struct ListBase *BKE_curve_editNurbs_get(struct Curve *cu);
-float *BKE_curve_make_orco(struct Scene *scene, struct Object *ob, int *r_numVerts);
+float *BKE_curve_make_orco(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, int *r_numVerts);
float *BKE_curve_surf_make_orco(struct Object *ob);
void BKE_curve_bevelList_free(struct ListBase *bev);
void BKE_curve_bevelList_make(struct Object *ob, struct ListBase *nurbs, bool for_render);
-void BKE_curve_bevel_make(struct Scene *scene, struct Object *ob, struct ListBase *disp,
- const bool for_render, const bool use_render_resolution);
+void BKE_curve_bevel_make(
+ const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct ListBase *disp,
+ const bool for_render, const bool use_render_resolution);
void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride);
void BKE_curve_forward_diff_tangent_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride);
@@ -198,6 +201,7 @@ void BKE_nurb_bezt_calc_normal(struct Nurb *nu, struct BezTriple *bezt, float r_
void BKE_nurb_bezt_calc_plane(struct Nurb *nu, struct BezTriple *bezt, float r_plane[3]);
void BKE_nurb_bpoint_calc_normal(struct Nurb *nu, struct BPoint *bp, float r_normal[3]);
+void BKE_nurb_bpoint_calc_plane(struct Nurb *nu, struct BPoint *bp, float r_plane[3]);
void BKE_nurb_handle_calc(struct BezTriple *bezt, struct BezTriple *prev, struct BezTriple *next,
const bool is_fcurve);
@@ -211,13 +215,9 @@ void BKE_nurb_handles_test(struct Nurb *nu, const bool use_handles);
/* **** Depsgraph evaluation **** */
-struct EvaluationContext;
-
-void BKE_curve_eval_geometry(struct EvaluationContext *eval_ctx,
- struct Curve *curve);
-
-void BKE_curve_eval_path(struct EvaluationContext *eval_ctx,
- struct Curve *curve);
+void BKE_curve_eval_geometry(
+ const struct EvaluationContext *eval_ctx,
+ struct Curve *curve);
/* Draw Cache */
enum {
diff --git a/source/blender/blenkernel/BKE_data_transfer.h b/source/blender/blenkernel/BKE_data_transfer.h
index 2ee9d8d2408..d5f0313ca64 100644
--- a/source/blender/blenkernel/BKE_data_transfer.h
+++ b/source/blender/blenkernel/BKE_data_transfer.h
@@ -42,6 +42,7 @@ struct Object;
struct Scene;
struct SpaceTransform;
struct ReportList;
+struct EvaluationContext;
/* Warning, those def are stored in files (TransferData modifier), *DO NOT* modify those values. */
enum {
@@ -129,11 +130,12 @@ enum {
};
void BKE_object_data_transfer_layout(
- struct Scene *scene, struct Object *ob_src, struct Object *ob_dst, const int data_types, const bool use_delete,
+ const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob_src,
+ struct Object *ob_dst, const int data_types, const bool use_delete,
const int fromlayers_select[DT_MULTILAYER_INDEX_MAX], const int tolayers_select[DT_MULTILAYER_INDEX_MAX]);
bool BKE_object_data_transfer_mesh(
- struct Scene *scene,
+ const struct EvaluationContext *eval_ctx, struct Scene *scene,
struct Object *ob_src, struct Object *ob_dst, const int data_types, const bool use_create,
const int map_vert_mode, const int map_edge_mode, const int map_loop_mode, const int map_poly_mode,
struct SpaceTransform *space_transform, const bool auto_transform,
@@ -142,7 +144,7 @@ bool BKE_object_data_transfer_mesh(
const int mix_mode, const float mix_factor, const char *vgroup_name, const bool invert_vgroup,
struct ReportList *reports);
bool BKE_object_data_transfer_dm(
- struct Scene *scene,
+ const struct EvaluationContext *eval_ctx, struct Scene *scene,
struct Object *ob_src, struct Object *ob_dst, struct DerivedMesh *dm_dst,
const int data_types, bool use_create,
const int map_vert_mode, const int map_edge_mode, const int map_loop_mode, const int map_poly_mode,
diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h
index 9625f05192a..c2229976dd9 100644
--- a/source/blender/blenkernel/BKE_displist.h
+++ b/source/blender/blenkernel/BKE_displist.h
@@ -86,23 +86,30 @@ void BKE_displist_count(struct ListBase *lb, int *totvert, int *totface, int *to
void BKE_displist_free(struct ListBase *lb);
bool BKE_displist_has_faces(struct ListBase *lb);
-void BKE_displist_make_surf(struct Scene *scene, struct Object *ob, struct ListBase *dispbase, struct DerivedMesh **r_dm_final,
- const bool for_render, const bool for_orco, const bool use_render_resolution);
-void BKE_displist_make_curveTypes(struct Scene *scene, struct Object *ob, const bool for_orco);
-void BKE_displist_make_curveTypes_forRender(struct Scene *scene, struct Object *ob, struct ListBase *dispbase, struct DerivedMesh **r_dm_final,
- const bool for_orco, const bool use_render_resolution);
-void BKE_displist_make_curveTypes_forOrco(struct Scene *scene, struct Object *ob, struct ListBase *dispbase);
-void BKE_displist_make_mball(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
-void BKE_displist_make_mball_forRender(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct ListBase *dispbase);
+void BKE_displist_make_surf(
+ const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct ListBase *dispbase,
+ struct DerivedMesh **r_dm_final, const bool for_render, const bool for_orco, const bool use_render_resolution);
+void BKE_displist_make_curveTypes(
+ const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, const bool for_orco);
+void BKE_displist_make_curveTypes_forRender(
+ const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct ListBase *dispbase,
+ struct DerivedMesh **r_dm_final, const bool for_orco, const bool use_render_resolution);
+void BKE_displist_make_curveTypes_forOrco(
+ const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct ListBase *dispbase);
+void BKE_displist_make_mball(
+ const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
+void BKE_displist_make_mball_forRender(
+ const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct ListBase *dispbase);
bool BKE_displist_surfindex_get(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4);
void BKE_displist_fill(struct ListBase *dispbase, struct ListBase *to, const float normal_proj[3], const bool flipnormal);
-float BKE_displist_calc_taper(struct Scene *scene, struct Object *taperobj, int cur, int tot);
+float BKE_displist_calc_taper(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *taperobj, int cur, int tot);
/* add Orco layer to the displist object which has got derived mesh and return orco */
-float *BKE_displist_make_orco(struct Scene *scene, struct Object *ob, struct DerivedMesh *dm_final,
- const bool for_render, const bool use_render_resolution);
+float *BKE_displist_make_orco(
+ const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm_final,
+ const bool for_render, const bool use_render_resolution);
void BKE_displist_minmax(struct ListBase *dispbase, float min[3], float max[3]);
diff --git a/source/blender/blenkernel/BKE_dynamicpaint.h b/source/blender/blenkernel/BKE_dynamicpaint.h
index b22f5fa7630..cee10d2bd56 100644
--- a/source/blender/blenkernel/BKE_dynamicpaint.h
+++ b/source/blender/blenkernel/BKE_dynamicpaint.h
@@ -29,6 +29,7 @@
struct Scene;
struct SceneLayer;
+struct EvaluationContext;
/* Actual surface point */
typedef struct PaintSurfaceData {
@@ -61,8 +62,8 @@ typedef struct PaintWavePoint {
short state;
} PaintWavePoint;
-struct DerivedMesh *dynamicPaint_Modifier_do(struct DynamicPaintModifierData *pmd, struct Scene *scene,
- struct SceneLayer *sl, struct Object *ob, struct DerivedMesh *dm);
+struct DerivedMesh *dynamicPaint_Modifier_do(struct DynamicPaintModifierData *pmd, const struct EvaluationContext *eval_ctx, struct Scene *scene,
+ struct Object *ob, struct DerivedMesh *dm);
void dynamicPaint_Modifier_free(struct DynamicPaintModifierData *pmd);
void dynamicPaint_Modifier_copy(struct DynamicPaintModifierData *pmd, struct DynamicPaintModifierData *tsmd);
@@ -85,7 +86,7 @@ struct DynamicPaintSurface *get_activeSurface(struct DynamicPaintCanvasSettings
/* image sequence baking */
int dynamicPaint_createUVSurface(struct Scene *scene, struct DynamicPaintSurface *surface, float *progress, short *do_update);
-int dynamicPaint_calculateFrame(struct DynamicPaintSurface *surface, struct Scene *scene, struct SceneLayer *sl, struct Object *cObject, int frame);
+int dynamicPaint_calculateFrame(struct DynamicPaintSurface *surface, const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *cObject, int frame);
void dynamicPaint_outputSurfaceImage(struct DynamicPaintSurface *surface, char *filename, short output_layer);
/* PaintPoint state */
diff --git a/source/blender/blenkernel/BKE_editmesh.h b/source/blender/blenkernel/BKE_editmesh.h
index 9ee1bcf2d37..af1aeff230f 100644
--- a/source/blender/blenkernel/BKE_editmesh.h
+++ b/source/blender/blenkernel/BKE_editmesh.h
@@ -40,6 +40,7 @@ struct Mesh;
struct Scene;
struct DerivedMesh;
struct MeshStatVis;
+struct EvaluationContext;
/**
* This structure is used for mesh edit-mode.
@@ -98,6 +99,7 @@ float (*BKE_editmesh_vertexCos_get_orco(BMEditMesh *em, int *r_numVerts))[3]
void BKE_editmesh_statvis_calc(BMEditMesh *em, struct DerivedMesh *dm,
const struct MeshStatVis *statvis);
-float (*BKE_editmesh_vertexCos_get(struct BMEditMesh *em, struct Scene *scene, int *r_numVerts))[3];
+float (*BKE_editmesh_vertexCos_get(
+ const struct EvaluationContext *eval_ctx, struct BMEditMesh *em, struct Scene *scene, int *r_numVerts))[3];
#endif /* __BKE_EDITMESH_H__ */
diff --git a/source/blender/blenkernel/BKE_editmesh_tangent.h b/source/blender/blenkernel/BKE_editmesh_tangent.h
index 7d6839a4e6a..9553fbc1a5c 100644
--- a/source/blender/blenkernel/BKE_editmesh_tangent.h
+++ b/source/blender/blenkernel/BKE_editmesh_tangent.h
@@ -35,6 +35,6 @@ void BKE_editmesh_loop_tangent_calc(
const float (*vert_orco)[3],
CustomData *dm_loopdata_out,
const uint dm_loopdata_out_len,
- char *tangent_mask_curr_p);
+ short *tangent_mask_curr_p);
#endif /* __BKE_EDITMESH_TANGENT_H__ */
diff --git a/source/blender/blenkernel/BKE_effect.h b/source/blender/blenkernel/BKE_effect.h
index aa45132cbe9..6fa19d4aaf6 100644
--- a/source/blender/blenkernel/BKE_effect.h
+++ b/source/blender/blenkernel/BKE_effect.h
@@ -44,6 +44,7 @@ struct Group;
struct ParticleSimulationData;
struct ParticleData;
struct ParticleKey;
+struct EvaluationContext;
struct EffectorWeights *BKE_add_effector_weights(struct Group *group);
struct PartDeflect *object_add_collision_fields(int type);
@@ -93,6 +94,7 @@ typedef struct EffectorData {
typedef struct EffectorCache {
struct EffectorCache *next, *prev;
+ const struct EvaluationContext *eval_ctx;
struct Scene *scene;
struct Object *ob;
struct ParticleSystem *psys;
@@ -110,9 +112,11 @@ typedef struct EffectorCache {
} EffectorCache;
void free_partdeflect(struct PartDeflect *pd);
-struct ListBase *pdInitEffectors(struct Scene *scene, struct Object *ob_src, struct ParticleSystem *psys_src, struct EffectorWeights *weights, bool for_simulation);
+struct ListBase *pdInitEffectors(
+ const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob_src, struct ParticleSystem *psys_src,
+ struct EffectorWeights *weights, bool for_simulation);
void pdEndEffectors(struct ListBase **effectors);
-void pdPrecalculateEffectors(struct ListBase *effectors);
+void pdPrecalculateEffectors(const struct EvaluationContext *eval_ctx, struct ListBase *effectors);
void pdDoEffectors(struct ListBase *effectors, struct ListBase *colliders, struct EffectorWeights *weights, struct EffectedPoint *point, float *force, float *impulse);
void pd_point_from_particle(struct ParticleSimulationData *sim, struct ParticleData *pa, struct ParticleKey *state, struct EffectedPoint *point);
diff --git a/source/blender/blenkernel/BKE_fluidsim.h b/source/blender/blenkernel/BKE_fluidsim.h
index 6501c968abc..4ec58b2a0e5 100644
--- a/source/blender/blenkernel/BKE_fluidsim.h
+++ b/source/blender/blenkernel/BKE_fluidsim.h
@@ -36,10 +36,11 @@ struct Object;
struct Scene;
struct FluidsimSettings;
struct MVert;
+struct EvaluationContext;
/* old interface */
-void initElbeemMesh(struct Scene *scene, struct Object *ob,
+void initElbeemMesh(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
int *numVertices, float **vertices,
int *numTriangles, int **triangles,
int useGlobalCoords, int modifierIndex);
diff --git a/source/blender/blenkernel/BKE_font.h b/source/blender/blenkernel/BKE_font.h
index e7ae0f606e7..60ad061bf77 100644
--- a/source/blender/blenkernel/BKE_font.h
+++ b/source/blender/blenkernel/BKE_font.h
@@ -78,6 +78,7 @@ void BKE_vfont_builtin_register(void *mem, int size);
void BKE_vfont_free_data(struct VFont *vfont);
void BKE_vfont_free(struct VFont *sc);
void BKE_vfont_init(struct VFont *vfont);
+void BKE_vfont_copy_data(struct Main *bmain, struct VFont *vfont_dst, const struct VFont *vfont_src, const int flag);
struct VFont *BKE_vfont_builtin_get(void);
struct VFont *BKE_vfont_load(struct Main *bmain, const char *filepath);
struct VFont *BKE_vfont_load_exists_ex(struct Main *bmain, const char *filepath, bool *r_exists);
diff --git a/source/blender/blenkernel/BKE_freestyle.h b/source/blender/blenkernel/BKE_freestyle.h
index 50407f3bdfc..1045fde0039 100644
--- a/source/blender/blenkernel/BKE_freestyle.h
+++ b/source/blender/blenkernel/BKE_freestyle.h
@@ -50,7 +50,7 @@ typedef struct FreestyleModuleSettings FreestyleModuleSettings;
/* FreestyleConfig */
void BKE_freestyle_config_init(FreestyleConfig *config);
void BKE_freestyle_config_free(FreestyleConfig *config);
-void BKE_freestyle_config_copy(FreestyleConfig *new_config, FreestyleConfig *config);
+void BKE_freestyle_config_copy(FreestyleConfig *new_config, FreestyleConfig *config, const int flag);
/* FreestyleConfig.modules */
FreestyleModuleConfig *BKE_freestyle_module_add(FreestyleConfig *config);
diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h
index 830518906ab..80a8f750d20 100644
--- a/source/blender/blenkernel/BKE_global.h
+++ b/source/blender/blenkernel/BKE_global.h
@@ -83,8 +83,6 @@ typedef struct Global {
/* debug flag, G_DEBUG, G_DEBUG_PYTHON & friends, set python or command line args */
int debug;
- bool have_quicktime;
-
/* this variable is written to / read from FileGlobal->fileflags */
int fileflags;
@@ -130,10 +128,11 @@ enum {
G_DEBUG_DEPSGRAPH_NO_THREADS = (1 << 11), /* single threaded depsgraph */
G_DEBUG_GPU = (1 << 12), /* gpu debug */
G_DEBUG_IO = (1 << 13), /* IO Debugging (for Collada, ...)*/
+ G_DEBUG_GPU_SHADERS = (1 << 14), /* GLSL shaders */
};
#define G_DEBUG_ALL (G_DEBUG | G_DEBUG_FFMPEG | G_DEBUG_PYTHON | G_DEBUG_EVENTS | G_DEBUG_WM | G_DEBUG_JOBS | \
- G_DEBUG_FREESTYLE | G_DEBUG_DEPSGRAPH | G_DEBUG_GPU_MEM | G_DEBUG_IO)
+ G_DEBUG_FREESTYLE | G_DEBUG_DEPSGRAPH | G_DEBUG_GPU_MEM | G_DEBUG_IO | G_DEBUG_GPU_SHADERS)
/* G.fileflags */
diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h
index bdd28baf137..b6de922c245 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -60,6 +60,7 @@ struct bGPdata *BKE_gpencil_data_addnew(const char name[]);
struct bGPDframe *BKE_gpencil_frame_duplicate(const struct bGPDframe *gpf_src);
struct bGPDlayer *BKE_gpencil_layer_duplicate(const struct bGPDlayer *gpl_src);
+void BKE_gpencil_copy_data(struct Main *bmain, struct bGPdata *gpd_dst, const struct bGPdata *gpd_src, const int flag);
struct bGPdata *BKE_gpencil_data_duplicate(struct Main *bmain, const struct bGPdata *gpd, bool internal_copy);
void BKE_gpencil_make_local(struct Main *bmain, struct bGPdata *gpd, const bool lib_local);
diff --git a/source/blender/blenkernel/BKE_group.h b/source/blender/blenkernel/BKE_group.h
index 4555bbf076d..205f42d6643 100644
--- a/source/blender/blenkernel/BKE_group.h
+++ b/source/blender/blenkernel/BKE_group.h
@@ -43,6 +43,7 @@ struct Scene;
void BKE_group_free(struct Group *group);
struct Group *BKE_group_add(struct Main *bmain, const char *name);
+void BKE_group_copy_data(struct Main *bmain, struct Group *group_dst, const struct Group *group_src, const int flag);
struct Group *BKE_group_copy(struct Main *bmain, const struct Group *group);
void BKE_group_make_local(struct Main *bmain, struct Group *group, const bool lib_local);
bool BKE_group_object_add(struct Group *group, struct Object *ob);
@@ -53,6 +54,6 @@ bool BKE_group_object_cyclic_check(struct Main *bmain, struct Object *o
bool BKE_group_is_animated(struct Group *group, struct Object *parent);
void BKE_group_tag_recalc(struct Group *group);
-void BKE_group_handle_recalc_and_update(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *parent, struct Group *group);
+void BKE_group_handle_recalc_and_update(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *parent, struct Group *group);
#endif /* __BKE_GROUP_H__ */
diff --git a/source/blender/blenkernel/BKE_idprop.h b/source/blender/blenkernel/BKE_idprop.h
index ab8728faedb..055c530d255 100644
--- a/source/blender/blenkernel/BKE_idprop.h
+++ b/source/blender/blenkernel/BKE_idprop.h
@@ -58,7 +58,7 @@ typedef union IDPropertyTemplate {
/* ----------- Property Array Type ---------- */
IDProperty *IDP_NewIDPArray(const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
-IDProperty *IDP_CopyIDPArray(const IDProperty *array) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
+IDProperty *IDP_CopyIDPArray(const IDProperty *array, const int flag) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
/* shallow copies item */
void IDP_SetIndexArray(struct IDProperty *prop, int index, struct IDProperty *item) ATTR_NONNULL();
@@ -91,6 +91,7 @@ void IDP_ReplaceGroupInGroup(struct IDProperty *dest, const struct IDProperty *s
void IDP_ReplaceInGroup(struct IDProperty *group, struct IDProperty *prop) ATTR_NONNULL();
void IDP_ReplaceInGroup_ex(struct IDProperty *group, struct IDProperty *prop, struct IDProperty *prop_exist);
void IDP_MergeGroup(IDProperty *dest, const IDProperty *src, const bool do_overwrite) ATTR_NONNULL();
+void IDP_MergeGroup_ex(IDProperty *dest, const IDProperty *src, const bool do_overwrite, const int flag) ATTR_NONNULL();
bool IDP_AddToGroup(struct IDProperty *group, struct IDProperty *prop) ATTR_NONNULL();
bool IDP_InsertToGroup(struct IDProperty *group, struct IDProperty *previous,
struct IDProperty *pnew) ATTR_NONNULL(1 /* group */, 3 /* pnew */);
@@ -103,6 +104,7 @@ IDProperty *IDP_GetPropertyTypeFromGroup(struct IDProperty *prop, const char *na
/*-------- Main Functions --------*/
struct IDProperty *IDP_GetProperties(struct ID *id, const bool create_if_needed) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
struct IDProperty *IDP_CopyProperty(const struct IDProperty *prop) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
+struct IDProperty *IDP_CopyProperty_ex(const struct IDProperty *prop, const int flag) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
bool IDP_EqualsProperties_ex(IDProperty *prop1, IDProperty *prop2, const bool is_strict) ATTR_WARN_UNUSED_RESULT;
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index e155b0719cc..3c716f39dd0 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -58,6 +58,7 @@ void BKE_images_exit(void);
void BKE_image_free_packedfiles(struct Image *image);
void BKE_image_free_views(struct Image *image);
void BKE_image_free_buffers(struct Image *image);
+void BKE_image_free_buffers_ex(struct Image *image, bool do_lock);
/* call from library */
void BKE_image_free(struct Image *image);
@@ -250,6 +251,7 @@ void BKE_image_packfiles_from_mem(struct ReportList *reports, struct Image *ima,
void BKE_image_print_memlist(void);
/* empty image block, of similar type and filename */
+void BKE_image_copy_data(struct Main *bmain, struct Image *ima_dst, const struct Image *ima_src, const int flag);
struct Image *BKE_image_copy(struct Main *bmain, const struct Image *ima);
/* merge source into dest, and free source */
diff --git a/source/blender/blenkernel/BKE_key.h b/source/blender/blenkernel/BKE_key.h
index 94e8a24fbc5..5eef44ef896 100644
--- a/source/blender/blenkernel/BKE_key.h
+++ b/source/blender/blenkernel/BKE_key.h
@@ -51,6 +51,7 @@ extern "C" {
void BKE_key_free(struct Key *sc);
void BKE_key_free_nolib(struct Key *key);
struct Key *BKE_key_add(struct ID *id);
+void BKE_key_copy_data(struct Main *bmain, struct Key *key_dst, const struct Key *key_src, const int flag);
struct Key *BKE_key_copy(struct Main *bmain, const struct Key *key);
struct Key *BKE_key_copy_nolib(struct Key *key);
void BKE_key_sort(struct Key *key);
diff --git a/source/blender/blenkernel/BKE_lamp.h b/source/blender/blenkernel/BKE_lamp.h
index 713ca80fb1a..b68da654520 100644
--- a/source/blender/blenkernel/BKE_lamp.h
+++ b/source/blender/blenkernel/BKE_lamp.h
@@ -44,6 +44,7 @@ struct Scene;
void BKE_lamp_init(struct Lamp *la);
struct Lamp *BKE_lamp_add(struct Main *bmain, const char *name) ATTR_WARN_UNUSED_RESULT;
+void BKE_lamp_copy_data(struct Main *bmain, struct Lamp *la_dst, const struct Lamp *la_src, const int flag);
struct Lamp *BKE_lamp_copy(struct Main *bmain, const struct Lamp *la) ATTR_WARN_UNUSED_RESULT;
struct Lamp *localize_lamp(struct Lamp *la) ATTR_WARN_UNUSED_RESULT;
void BKE_lamp_make_local(struct Main *bmain, struct Lamp *la, const bool lib_local);
diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h
index 3c66d29e6ac..52d6dc53808 100644
--- a/source/blender/blenkernel/BKE_lattice.h
+++ b/source/blender/blenkernel/BKE_lattice.h
@@ -43,10 +43,12 @@ struct Scene;
struct DerivedMesh;
struct BPoint;
struct MDeformVert;
+struct EvaluationContext;
void BKE_lattice_resize(struct Lattice *lt, int u, int v, int w, struct Object *ltOb);
void BKE_lattice_init(struct Lattice *lt);
struct Lattice *BKE_lattice_add(struct Main *bmain, const char *name);
+void BKE_lattice_copy_data(struct Main *bmain, struct Lattice *lt_dst, const struct Lattice *lt_src, const int flag);
struct Lattice *BKE_lattice_copy(struct Main *bmain, const struct Lattice *lt);
void BKE_lattice_free(struct Lattice *lt);
void BKE_lattice_make_local(struct Main *bmain, struct Lattice *lt, const bool lib_local);
@@ -60,10 +62,12 @@ void end_latt_deform(struct LatticeDeformData *lattice_deform_data);
bool object_deform_mball(struct Object *ob, struct ListBase *dispbase);
void outside_lattice(struct Lattice *lt);
-void curve_deform_verts(struct Scene *scene, struct Object *cuOb, struct Object *target,
- struct DerivedMesh *dm, float (*vertexCos)[3],
+void curve_deform_verts(
+ const struct EvaluationContext *eval_ctx, struct Scene *scene,
+ struct Object *cuOb, struct Object *target,
+ struct DerivedMesh *dm, float (*vertexCos)[3],
int numVerts, const char *vgroup, short defaxis);
-void curve_deform_vector(struct Scene *scene, struct Object *cuOb, struct Object *target,
+void curve_deform_vector(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *cuOb, struct Object *target,
float orco[3], float vec[3], float mat[3][3], int no_rot_axis);
void lattice_deform_verts(struct Object *laOb, struct Object *target,
@@ -76,7 +80,7 @@ void armature_deform_verts(struct Object *armOb, struct Object *target,
float (*BKE_lattice_vertexcos_get(struct Object *ob, int *r_numVerts))[3];
void BKE_lattice_vertexcos_apply(struct Object *ob, float (*vertexCos)[3]);
-void BKE_lattice_modifiers_calc(struct Scene *scene, struct Object *ob);
+void BKE_lattice_modifiers_calc(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
struct MDeformVert *BKE_lattice_deform_verts_get(struct Object *lattice);
struct BPoint *BKE_lattice_active_point_get(struct Lattice *lt);
@@ -100,7 +104,7 @@ void BKE_lattice_bitmap_from_flag(struct Lattice *lt, unsigned int *bitmap, cons
struct EvaluationContext;
-void BKE_lattice_eval_geometry(struct EvaluationContext *eval_ctx,
+void BKE_lattice_eval_geometry(const struct EvaluationContext *eval_ctx,
struct Lattice *latt);
/* Draw Cache */
diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h
index 578cc97466a..52d5405ec0a 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -33,13 +33,9 @@
extern "C" {
#endif
-#define TODO_LAYER_SYNC /* syncing of SceneCollection and LayerCollection trees*/
#define TODO_LAYER_SYNC_FILTER /* syncing of filter_objects across all trees */
#define TODO_LAYER_OVERRIDE /* CollectionOverride */
-#define TODO_LAYER_CONTEXT /* get/set current (context) SceneLayer */
-#define TODO_LAYER_BASE /* BaseLegacy to Base related TODO */
#define TODO_LAYER_OPERATORS /* collection mamanger and property panel operators */
-#define TODO_LAYER_DEPSGRAPH /* placeholder for real Depsgraph fix */
#define TODO_LAYER /* generic todo */
#define ROOT_PROP "root"
@@ -56,14 +52,17 @@ struct RenderEngine;
struct Scene;
struct SceneCollection;
struct SceneLayer;
+struct WorkSpace;
void BKE_layer_exit(void);
-struct SceneLayer *BKE_scene_layer_render_active(const struct Scene *scene);
-struct SceneLayer *BKE_scene_layer_context_active_ex(const struct Main *bmain, const struct Scene *scene);
-struct SceneLayer *BKE_scene_layer_context_active(const struct Scene *scene);
+struct SceneLayer *BKE_scene_layer_from_scene_get(const struct Scene *scene);
+struct SceneLayer *BKE_scene_layer_from_workspace_get(const struct WorkSpace *workspace);
struct SceneLayer *BKE_scene_layer_add(struct Scene *scene, const char *name);
+/* DEPRECATED */
+struct SceneLayer *BKE_scene_layer_context_active_PLACEHOLDER(const struct Scene *scene);
+
void BKE_scene_layer_free(struct SceneLayer *sl);
void BKE_scene_layer_engine_set(struct SceneLayer *sl, const char *engine);
@@ -82,6 +81,7 @@ struct LayerCollection *BKE_layer_collection_get_active_ensure(struct Scene *sce
int BKE_layer_collection_count(struct SceneLayer *sl);
+struct LayerCollection *BKE_layer_collection_from_index(struct SceneLayer *sl, const int index);
int BKE_layer_collection_findindex(struct SceneLayer *sl, const struct LayerCollection *lc);
bool BKE_layer_collection_move_above(const struct Scene *scene, struct LayerCollection *lc_dst, struct LayerCollection *lc_src);
@@ -94,6 +94,9 @@ struct LayerCollection *BKE_collection_link(struct SceneLayer *sl, struct SceneC
void BKE_collection_unlink(struct SceneLayer *sl, struct LayerCollection *lc);
+void BKE_collection_enable(struct SceneLayer *sl, struct LayerCollection *lc);
+void BKE_collection_disable(struct SceneLayer *sl, struct LayerCollection *lc);
+
bool BKE_scene_layer_has_collection(struct SceneLayer *sl, const struct SceneCollection *sc);
bool BKE_scene_has_object(struct Scene *scene, struct Object *ob);
@@ -145,13 +148,13 @@ void BKE_collection_engine_property_value_set_bool(struct IDProperty *props, con
/* evaluation */
-void BKE_layer_eval_layer_collection_pre(struct EvaluationContext *eval_ctx,
+void BKE_layer_eval_layer_collection_pre(const struct EvaluationContext *eval_ctx,
struct Scene *scene,
struct SceneLayer *scene_layer);
-void BKE_layer_eval_layer_collection(struct EvaluationContext *eval_ctx,
+void BKE_layer_eval_layer_collection(const struct EvaluationContext *eval_ctx,
struct LayerCollection *layer_collection,
struct LayerCollection *parent_layer_collection);
-void BKE_layer_eval_layer_collection_post(struct EvaluationContext *eval_ctx,
+void BKE_layer_eval_layer_collection_post(const struct EvaluationContext *eval_ctx,
struct SceneLayer *scene_layer);
/* iterators */
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index bfe8cea7519..eac4dc81582 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -52,11 +52,38 @@ struct PropertyRNA;
size_t BKE_libblock_get_alloc_info(short type, const char **name);
void *BKE_libblock_alloc_notest(short type);
-void *BKE_libblock_alloc(struct Main *bmain, short type, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
+void *BKE_libblock_alloc(struct Main *bmain, short type, const char *name, const int flag) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
void BKE_libblock_init_empty(struct ID *id);
+
+/**
+ * New ID creation/copying options.
+ */
+enum {
+ /* *** Generic options (should be handled by all ID types copying, ID creation, etc.). *** */
+ /* Create datablock outside of any main database - similar to 'localize' functions of materials etc. */
+ LIB_ID_CREATE_NO_MAIN = 1 << 0,
+ /* Do not affect user refcount of datablocks used by new one (which also gets zero usercount then).
+ * Implies LIB_ID_CREATE_NO_MAIN. */
+ LIB_ID_CREATE_NO_USER_REFCOUNT = 1 << 1,
+ /* Assume given 'newid' already points to allocated memory for whole datablock (ID + data) - USE WITH CAUTION!
+ * Implies LIB_ID_CREATE_NO_MAIN. */
+ LIB_ID_CREATE_NO_ALLOCATE = 1 << 2,
+
+ LIB_ID_CREATE_NO_DEG_TAG = 1 << 8, /* Do not tag new ID for update in depsgraph. */
+
+ /* Specific options to some ID types or usages, may be ignored by unrelated ID copying functions. */
+ LIB_ID_COPY_NO_PROXY_CLEAR = 1 << 16, /* Object only, needed by make_local code. */
+ LIB_ID_COPY_NO_PREVIEW = 1 << 17, /* Do not copy preview data, when supported. */
+ LIB_ID_COPY_CACHES = 1 << 18, /* Copy runtime data caches. */
+ /* XXX TODO Do we want to keep that? would rather try to get rid of it... */
+ LIB_ID_COPY_ACTIONS = 1 << 19, /* EXCEPTION! Deep-copy actions used by animdata of copied ID. */
+};
+
+void BKE_libblock_copy_ex(struct Main *bmain, const struct ID *id, struct ID **r_newid, const int flag);
void *BKE_libblock_copy(struct Main *bmain, const struct ID *id) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
+/* "Deprecated" old API. */
void *BKE_libblock_copy_nolib(const struct ID *id, const bool do_action) ATTR_NONNULL();
-void BKE_libblock_copy_data(struct ID *id, const struct ID *id_from, const bool do_action);
+
void BKE_libblock_rename(struct Main *bmain, struct ID *id, const char *name) ATTR_NONNULL();
void BLI_libblock_ensure_unique_name(struct Main *bmain, const char *name) ATTR_NONNULL();
@@ -64,13 +91,45 @@ struct ID *BKE_libblock_find_name_ex(struct Main *bmain, const short type, const
struct ID *BKE_libblock_find_name(const short type, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
/* library_remap.c (keep here since they're general functions) */
-void BKE_libblock_free(struct Main *bmain, void *idv) ATTR_NONNULL();
-void BKE_libblock_free_datablock(struct ID *id) ATTR_NONNULL();
+/**
+ * New freeing logic options.
+ */
+enum {
+ /* *** Generic options (should be handled by all ID types freeing). *** */
+ /* Do not try to remove freed ID from given Main (passed Main may be NULL). */
+ LIB_ID_FREE_NO_MAIN = 1 << 0,
+ /* Do not affect user refcount of datablocks used by freed one.
+ * Implies LIB_ID_FREE_NO_MAIN. */
+ LIB_ID_FREE_NO_USER_REFCOUNT = 1 << 1,
+ /* Assume freed ID datablock memory is managed elsewhere, do not free it
+ * (still calls relevant ID type's freeing function though) - USE WITH CAUTION!
+ * Implies LIB_ID_FREE_NO_MAIN. */
+ LIB_ID_FREE_NOT_ALLOCATED = 1 << 2,
+
+ LIB_ID_FREE_NO_DEG_TAG = 1 << 8, /* Do not tag freed ID for update in depsgraph. */
+ LIB_ID_FREE_NO_UI_USER = 1 << 9, /* Do not attempt to remove freed ID from UI data/notifiers/... */
+};
+
+void BKE_id_free_ex(struct Main *bmain, void *idv, int flag, const bool use_flag_from_idtag);
+void BKE_id_free(struct Main *bmain, void *idv);
+/* Those three naming are bad actually, should be BKE_id_free... (since it goes beyond mere datablock). */
+/* "Deprecated" old API */
void BKE_libblock_free_ex(struct Main *bmain, void *idv, const bool do_id_user, const bool do_ui_user) ATTR_NONNULL();
+void BKE_libblock_free(struct Main *bmain, void *idv) ATTR_NONNULL();
void BKE_libblock_free_us(struct Main *bmain, void *idv) ATTR_NONNULL();
-void BKE_libblock_free_data(struct ID *id, const bool do_id_user) ATTR_NONNULL();
+
+void BKE_libblock_management_main_add(struct Main *bmain, void *idv);
+void BKE_libblock_management_main_remove(struct Main *bmain, void *idv);
+
+void BKE_libblock_management_usercounts_set(struct Main *bmain, void *idv);
+void BKE_libblock_management_usercounts_clear(struct Main *bmain, void *idv);
+
+/* TODO should be named "BKE_id_delete()". */
void BKE_libblock_delete(struct Main *bmain, void *idv) ATTR_NONNULL();
+void BKE_libblock_free_datablock(struct ID *id, const int flag) ATTR_NONNULL();
+void BKE_libblock_free_data(struct ID *id, const bool do_id_user) ATTR_NONNULL();
+
void BKE_id_lib_local_paths(struct Main *bmain, struct Library *lib, struct ID *id);
void id_lib_extern(struct ID *id);
void BKE_library_filepath_set(struct Library *lib, const char *filepath);
@@ -87,6 +146,7 @@ void BKE_id_make_local_generic(struct Main *bmain, struct ID *id, const bool id_
bool id_make_local(struct Main *bmain, struct ID *id, const bool test, const bool force_local);
bool id_single_user(struct bContext *C, struct ID *id, struct PointerRNA *ptr, struct PropertyRNA *prop);
bool id_copy(struct Main *bmain, const struct ID *id, struct ID **newid, bool test);
+bool BKE_id_copy_ex(struct Main *bmain, const struct ID *id, struct ID **r_newid, const int flag, const bool test);
void id_sort_by_name(struct ListBase *lb, struct ID *id);
void BKE_id_expand_local(struct Main *bmain, struct ID *id);
void BKE_id_copy_ensure_local(struct Main *bmain, const struct ID *old_id, struct ID *new_id);
diff --git a/source/blender/blenkernel/BKE_library_query.h b/source/blender/blenkernel/BKE_library_query.h
index 6cf18e28e17..d6e7d98f371 100644
--- a/source/blender/blenkernel/BKE_library_query.h
+++ b/source/blender/blenkernel/BKE_library_query.h
@@ -83,6 +83,8 @@ enum {
IDWALK_NOP = 0,
IDWALK_READONLY = (1 << 0),
IDWALK_RECURSE = (1 << 1), /* Also implies IDWALK_READONLY. */
+
+ IDWALK_NO_INDIRECT_PROXY_DATA_USAGE = (1 << 8), /* Ugly special case :(((( */
};
/* Loop over all of the ID's this datablock links to. */
diff --git a/source/blender/blenkernel/BKE_library_remap.h b/source/blender/blenkernel/BKE_library_remap.h
index 53d438a0fdd..fd37fd762f4 100644
--- a/source/blender/blenkernel/BKE_library_remap.h
+++ b/source/blender/blenkernel/BKE_library_remap.h
@@ -46,6 +46,11 @@ enum {
/* This tells the callback func to force setting IDs using target one with a 'never NULL' pointer to NULL.
* WARNING! Use with extreme care, this will leave database in broken state and can cause crashes very easily! */
ID_REMAP_FORCE_NEVER_NULL_USAGE = 1 << 3,
+ /* Do not consider proxy/_group pointers of local objects as indirect usages...
+ * Our oh-so-beloved proxies again... Do not consider data used by local proxy object as indirect usage.
+ * This is needed e.g. in reload scenario, since we have to ensure remapping of Armature data of local proxy
+ * is also performed. Usual nightmare... */
+ ID_REMAP_NO_INDIRECT_PROXY_DATA_USAGE = 1 << 4,
};
/* Note: Requiring new_id to be non-null, this *may* not be the case ultimately, but makes things simpler for now. */
diff --git a/source/blender/blenkernel/BKE_lightprobe.h b/source/blender/blenkernel/BKE_lightprobe.h
index ae7df75345d..a769b6653d7 100644
--- a/source/blender/blenkernel/BKE_lightprobe.h
+++ b/source/blender/blenkernel/BKE_lightprobe.h
@@ -38,7 +38,8 @@ struct LightProbe;
void BKE_lightprobe_init(struct LightProbe *probe);
void *BKE_lightprobe_add(struct Main *bmain, const char *name);
-struct LightProbe *BKE_lightprobe_copy(struct Main *bmain, struct LightProbe *probe);
+void BKE_lightprobe_copy_data(struct Main *bmain, struct LightProbe *probe_dst, const struct LightProbe *probe_src, const int flag);
+struct LightProbe *BKE_lightprobe_copy(struct Main *bmain, const struct LightProbe *probe);
void BKE_lightprobe_make_local(struct Main *bmain, struct LightProbe *probe, const bool lib_local);
void BKE_lightprobe_free(struct LightProbe *probe);
diff --git a/source/blender/blenkernel/BKE_linestyle.h b/source/blender/blenkernel/BKE_linestyle.h
index c7b323d0f6e..3ba4fbe0338 100644
--- a/source/blender/blenkernel/BKE_linestyle.h
+++ b/source/blender/blenkernel/BKE_linestyle.h
@@ -52,6 +52,9 @@ struct bContext;
void BKE_linestyle_init(struct FreestyleLineStyle *linestyle);
FreestyleLineStyle *BKE_linestyle_new(struct Main *bmain, const char *name);
void BKE_linestyle_free(FreestyleLineStyle *linestyle);
+void BKE_linestyle_copy_data(
+ struct Main *bmain, struct FreestyleLineStyle *linestyle_dst, const struct FreestyleLineStyle *linestyle_src,
+ const int flag);
FreestyleLineStyle *BKE_linestyle_copy(struct Main *bmain, const FreestyleLineStyle *linestyle);
void BKE_linestyle_make_local(struct Main *bmain, struct FreestyleLineStyle *linestyle, const bool lib_local);
@@ -63,10 +66,14 @@ LineStyleModifier *BKE_linestyle_alpha_modifier_add(FreestyleLineStyle *linestyl
LineStyleModifier *BKE_linestyle_thickness_modifier_add(FreestyleLineStyle *linestyle, const char *name, int type);
LineStyleModifier *BKE_linestyle_geometry_modifier_add(FreestyleLineStyle *linestyle, const char *name, int type);
-LineStyleModifier *BKE_linestyle_color_modifier_copy(FreestyleLineStyle *linestyle, const LineStyleModifier *m);
-LineStyleModifier *BKE_linestyle_alpha_modifier_copy(FreestyleLineStyle *linestyle, const LineStyleModifier *m);
-LineStyleModifier *BKE_linestyle_thickness_modifier_copy(FreestyleLineStyle *linestyle, const LineStyleModifier *m);
-LineStyleModifier *BKE_linestyle_geometry_modifier_copy(FreestyleLineStyle *linestyle, const LineStyleModifier *m);
+LineStyleModifier *BKE_linestyle_color_modifier_copy(
+ FreestyleLineStyle *linestyle, const LineStyleModifier *m, const int flag);
+LineStyleModifier *BKE_linestyle_alpha_modifier_copy(
+ FreestyleLineStyle *linestyle, const LineStyleModifier *m, const int flag);
+LineStyleModifier *BKE_linestyle_thickness_modifier_copy(
+ FreestyleLineStyle *linestyle, const LineStyleModifier *m, const int flag);
+LineStyleModifier *BKE_linestyle_geometry_modifier_copy(
+ FreestyleLineStyle *linestyle, const LineStyleModifier *m, const int flag);
int BKE_linestyle_color_modifier_remove(FreestyleLineStyle *linestyle, LineStyleModifier *modifier);
int BKE_linestyle_alpha_modifier_remove(FreestyleLineStyle *linestyle, LineStyleModifier *modifier);
diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h
index 0735d2d97a1..5598f0dc473 100644
--- a/source/blender/blenkernel/BKE_mask.h
+++ b/source/blender/blenkernel/BKE_mask.h
@@ -32,6 +32,7 @@
* \ingroup bke
*/
+struct EvaluationContext;
struct ImageUser;
struct Image;
struct ListBase;
@@ -122,6 +123,7 @@ void BKE_mask_point_select_set_handle(struct MaskSplinePoint *point, const eMask
/* general */
struct Mask *BKE_mask_new(struct Main *bmain, const char *name);
+void BKE_mask_copy_data(struct Main *bmain, struct Mask *mask_dst, const struct Mask *mask_src, const int flag);
struct Mask *BKE_mask_copy_nolib(struct Mask *mask);
struct Mask *BKE_mask_copy(struct Main *bmain, const struct Mask *mask);
@@ -232,6 +234,12 @@ float *BKE_mask_point_segment_feather_diff(struct MaskSpline *spline, struct Mas
int width, int height,
unsigned int *tot_feather_point);
+void BKE_mask_layer_evaluate_animation(struct MaskLayer *masklay, const float ctime);
+void BKE_mask_layer_evaluate_deform(struct MaskLayer *masklay, const float ctime);
+
+void BKE_mask_eval_animation(struct EvaluationContext *eval_ctx, struct Mask *mask);
+void BKE_mask_eval_update(struct EvaluationContext *eval_ctx, struct Mask *mask);
+
/* mask_rasterize.c */
struct MaskRasterHandle;
typedef struct MaskRasterHandle MaskRasterHandle;
diff --git a/source/blender/blenkernel/BKE_material.h b/source/blender/blenkernel/BKE_material.h
index 85c649bbd3d..49fb128417e 100644
--- a/source/blender/blenkernel/BKE_material.h
+++ b/source/blender/blenkernel/BKE_material.h
@@ -54,6 +54,7 @@ void BKE_material_init(struct Material *ma);
void BKE_material_remap_object(struct Object *ob, const unsigned int *remap);
void BKE_material_remap_object_calc(struct Object *ob_dst, struct Object *ob_src, short *remap_src_to_dst);
struct Material *BKE_material_add(struct Main *bmain, const char *name);
+void BKE_material_copy_data(struct Main *bmain, struct Material *ma_dst, const struct Material *ma_src, const int flag);
struct Material *BKE_material_copy(struct Main *bmain, const struct Material *ma);
struct Material *localize_material(struct Material *ma);
struct Material *give_node_material(struct Material *ma); /* returns node material or self */
@@ -118,6 +119,12 @@ void free_matcopybuf(void);
void copy_matcopybuf(struct Material *ma);
void paste_matcopybuf(struct Material *ma);
+/* Evaluation. */
+
+struct EvaluationContext;
+
+void BKE_material_eval(const struct EvaluationContext *eval_ctx, struct Material *material);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/BKE_mball.h b/source/blender/blenkernel/BKE_mball.h
index c00a0743ebb..0c07ce55781 100644
--- a/source/blender/blenkernel/BKE_mball.h
+++ b/source/blender/blenkernel/BKE_mball.h
@@ -41,6 +41,7 @@ struct MetaElem;
void BKE_mball_free(struct MetaBall *mb);
void BKE_mball_init(struct MetaBall *mb);
struct MetaBall *BKE_mball_add(struct Main *bmain, const char *name);
+void BKE_mball_copy_data(struct Main *bmain, struct MetaBall *mb_dst, const struct MetaBall *mb_src, const int flag);
struct MetaBall *BKE_mball_copy(struct Main *bmain, const struct MetaBall *mb);
void BKE_mball_make_local(struct Main *bmain, struct MetaBall *mb, const bool lib_local);
@@ -59,7 +60,7 @@ bool BKE_mball_minmax_ex(struct MetaBall *mb, float min[3], float max[3],
float obmat[4][4], const short flag);
bool BKE_mball_center_median(struct MetaBall *mb, float r_cent[3]);
bool BKE_mball_center_bounds(struct MetaBall *mb, float r_cent[3]);
-void BKE_mball_transform(struct MetaBall *mb, float mat[4][4]);
+void BKE_mball_transform(struct MetaBall *mb, float mat[4][4], const bool do_props);
void BKE_mball_translate(struct MetaBall *mb, const float offset[3]);
struct MetaElem *BKE_mball_element_add(struct MetaBall *mb, const int type);
@@ -72,7 +73,7 @@ void BKE_mball_select_swap(struct MetaBall *mb);
struct EvaluationContext;
-void BKE_mball_eval_geometry(struct EvaluationContext *eval_ctx,
+void BKE_mball_eval_geometry(const struct EvaluationContext *eval_ctx,
struct MetaBall *mball);
#endif
diff --git a/source/blender/blenkernel/BKE_mball_tessellate.h b/source/blender/blenkernel/BKE_mball_tessellate.h
index 361f31b704c..40cdc80e280 100644
--- a/source/blender/blenkernel/BKE_mball_tessellate.h
+++ b/source/blender/blenkernel/BKE_mball_tessellate.h
@@ -28,7 +28,7 @@ struct Object;
struct Scene;
void BKE_mball_polygonize(
- struct EvaluationContext *eval_ctx, struct Scene *scene,
+ const struct EvaluationContext *eval_ctx, struct Scene *scene,
struct Object *ob, struct ListBase *dispbase);
void BKE_mball_cubeTable_free(void);
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index b7f793ea6cf..5ee3b9be5f9 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -35,6 +35,7 @@ struct ID;
struct BMeshCreateParams;
struct BoundBox;
struct EdgeHash;
+struct EvaluationContext;
struct ListBase;
struct LinkNode;
struct BLI_Stack;
@@ -87,10 +88,14 @@ int BKE_mesh_edge_other_vert(const struct MEdge *e, int v);
void BKE_mesh_free(struct Mesh *me);
void BKE_mesh_init(struct Mesh *me);
struct Mesh *BKE_mesh_add(struct Main *bmain, const char *name);
+void BKE_mesh_copy_data(struct Main *bmain, struct Mesh *me_dst, const struct Mesh *me_src, const int flag);
struct Mesh *BKE_mesh_copy(struct Main *bmain, const struct Mesh *me);
void BKE_mesh_update_customdata_pointers(struct Mesh *me, const bool do_ensure_tess_cd);
void BKE_mesh_ensure_skin_customdata(struct Mesh *me);
+bool BKE_mesh_ensure_facemap_customdata(struct Mesh *me);
+bool BKE_mesh_clear_facemap_customdata(struct Mesh *me);
+
void BKE_mesh_make_local(struct Main *bmain, struct Mesh *me, const bool lib_local);
void BKE_mesh_boundbox_calc(struct Mesh *me, float r_loc[3], float r_size[3]);
void BKE_mesh_texspace_calc(struct Mesh *me);
@@ -114,7 +119,7 @@ void BKE_mesh_from_nurbs_displist(
struct Object *ob, struct ListBase *dispbase, const bool use_orco_uv, const char *obdata_name);
void BKE_mesh_from_nurbs(struct Object *ob);
void BKE_mesh_to_curve_nurblist(struct DerivedMesh *dm, struct ListBase *nurblist, const int edge_users_test);
-void BKE_mesh_to_curve(struct Scene *scene, struct Object *ob);
+void BKE_mesh_to_curve(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
void BKE_mesh_material_index_remove(struct Mesh *me, short index);
void BKE_mesh_material_index_clear(struct Mesh *me);
void BKE_mesh_material_remap(struct Mesh *me, const unsigned int *remap, unsigned int remap_len);
@@ -135,7 +140,7 @@ float (*BKE_mesh_vertexCos_get(const struct Mesh *me, int *r_numVerts))[3];
void BKE_mesh_split_faces(struct Mesh *mesh, bool free_loop_normals);
-struct Mesh *BKE_mesh_new_from_object(struct Main *bmain, struct Scene *sce, struct Object *ob,
+struct Mesh *BKE_mesh_new_from_object(const struct EvaluationContext *eval_ctx, struct Main *bmain, struct Scene *sce, struct Object *ob,
int apply_modifiers, int settings, int calc_tessface, int calc_undeformed);
/* vertex level transformations & checks (no derived mesh) */
@@ -273,7 +278,8 @@ void BKE_mesh_poly_edgebitmap_insert(
bool BKE_mesh_center_median(const struct Mesh *me, float r_cent[3]);
bool BKE_mesh_center_bounds(const struct Mesh *me, float r_cent[3]);
-bool BKE_mesh_center_centroid(const struct Mesh *me, float r_cent[3]);
+bool BKE_mesh_center_of_surface(const struct Mesh *me, float r_cent[3]);
+bool BKE_mesh_center_of_volume(const struct Mesh *me, float r_cent[3]);
void BKE_mesh_calc_volume(
const struct MVert *mverts, const int mverts_num,
@@ -396,16 +402,16 @@ void BKE_mesh_calc_edges(struct Mesh *mesh, bool update, const bool select);
/* **** Depsgraph evaluation **** */
-struct EvaluationContext;
-
-void BKE_mesh_eval_geometry(struct EvaluationContext *eval_ctx,
+void BKE_mesh_eval_geometry(const struct EvaluationContext *eval_ctx,
struct Mesh *mesh);
/* Draw Cache */
enum {
BKE_MESH_BATCH_DIRTY_ALL = 0,
+ BKE_MESH_BATCH_DIRTY_MAYBE_ALL,
BKE_MESH_BATCH_DIRTY_SELECT,
- BKE_MESH_BATCH_DIRTY_PAINT,
+ BKE_MESH_BATCH_DIRTY_SHADING,
+ BKE_MESH_BATCH_DIRTY_SCULPT_COORDS,
};
void BKE_mesh_batch_cache_dirty(struct Mesh *me, int mode);
void BKE_mesh_batch_cache_free(struct Mesh *me);
diff --git a/source/blender/blenkernel/BKE_mesh_tangent.h b/source/blender/blenkernel/BKE_mesh_tangent.h
index 66b8a26e35b..cb3100c1c2f 100644
--- a/source/blender/blenkernel/BKE_mesh_tangent.h
+++ b/source/blender/blenkernel/BKE_mesh_tangent.h
@@ -43,17 +43,19 @@ void BKE_mesh_calc_loop_tangent_ex(
/* result */
struct CustomData *loopdata_out,
const uint loopdata_out_len,
- char *tangent_mask_curr_p);
+ short *tangent_mask_curr_p);
/* Helpers */
void BKE_mesh_add_loop_tangent_named_layer_for_uv(
struct CustomData *uv_data, struct CustomData *tan_data, int numLoopData,
const char *layer_name);
+
+#define DM_TANGENT_MASK_ORCO (1 << 9)
void BKE_mesh_calc_loop_tangent_step_0(
const struct CustomData *loopData, bool calc_active_tangent,
const char (*tangent_names)[64], int tangent_names_count,
bool *rcalc_act, bool *rcalc_ren, int *ract_uv_n, int *rren_uv_n,
- char *ract_uv_name, char *rren_uv_name, char *rtangent_mask);
+ char *ract_uv_name, char *rren_uv_name, short *rtangent_mask);
#endif /* __BKE_MESH_TANGENT_H__ */
diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h
index be6ed4f254d..76a36bdf3ff 100644
--- a/source/blender/blenkernel/BKE_modifier.h
+++ b/source/blender/blenkernel/BKE_modifier.h
@@ -36,6 +36,7 @@ struct ID;
struct DerivedMesh;
struct DagForest;
struct DagNode;
+struct EvaluationContext;
struct Object;
struct Scene;
struct SceneLayer;
@@ -158,25 +159,27 @@ typedef struct ModifierTypeInfo {
* the object it can obtain it from the derivedData argument if non-NULL,
* and otherwise the ob argument.
*/
- void (*deformVerts)(struct ModifierData *md, struct Object *ob,
- struct DerivedMesh *derivedData,
+ void (*deformVerts)(struct ModifierData *md, const struct EvaluationContext *eval_ctx,
+ struct Object *ob, struct DerivedMesh *derivedData,
float (*vertexCos)[3], int numVerts,
ModifierApplyFlag flag);
/* Like deformMatricesEM but called from object mode (for supporting modifiers in sculpt mode) */
- void (*deformMatrices)(struct ModifierData *md, struct Object *ob,
- struct DerivedMesh *derivedData,
+ void (*deformMatrices)(struct ModifierData *md, const struct EvaluationContext *eval_ctx,
+ struct Object *ob, struct DerivedMesh *derivedData,
float (*vertexCos)[3], float (*defMats)[3][3], int numVerts);
/* Like deformVerts but called during editmode (for supporting modifiers)
*/
- void (*deformVertsEM)(struct ModifierData *md, struct Object *ob,
- struct BMEditMesh *editData, struct DerivedMesh *derivedData,
+ void (*deformVertsEM)(struct ModifierData *md, const struct EvaluationContext *eval_ctx,
+ struct Object *ob, struct BMEditMesh *editData,
+ struct DerivedMesh *derivedData,
float (*vertexCos)[3], int numVerts);
/* Set deform matrix per vertex for crazyspace correction */
- void (*deformMatricesEM)(struct ModifierData *md, struct Object *ob,
- struct BMEditMesh *editData, struct DerivedMesh *derivedData,
+ void (*deformMatricesEM)(struct ModifierData *md, const struct EvaluationContext *eval_ctx,
+ struct Object *ob, struct BMEditMesh *editData,
+ struct DerivedMesh *derivedData,
float (*vertexCos)[3], float (*defMats)[3][3], int numVerts);
/********************* Non-deform modifier functions *********************/
@@ -200,8 +203,8 @@ typedef struct ModifierTypeInfo {
* The modifier may reuse the derivedData argument (i.e. return it in
* modified form), but must not release it.
*/
- struct DerivedMesh *(*applyModifier)(struct ModifierData *md, struct Object *ob,
- struct DerivedMesh *derivedData,
+ struct DerivedMesh *(*applyModifier)(struct ModifierData *md, const struct EvaluationContext *eval_ctx,
+ struct Object *ob, struct DerivedMesh *derivedData,
ModifierApplyFlag flag);
/* Like applyModifier but called during editmode (for supporting
@@ -211,10 +214,9 @@ typedef struct ModifierTypeInfo {
* are expected from editmode objects. The same qualifications regarding
* derivedData apply as for applyModifier.
*/
- struct DerivedMesh *(*applyModifierEM)(struct ModifierData *md, struct Object *ob,
- struct BMEditMesh *editData,
- struct DerivedMesh *derivedData,
- ModifierApplyFlag flag);
+ struct DerivedMesh *(*applyModifierEM)(struct ModifierData *md, const struct EvaluationContext *eval_ctx,
+ struct Object *ob, struct BMEditMesh *editData,
+ struct DerivedMesh *derivedData, ModifierApplyFlag flag);
/********************* Optional functions *********************/
@@ -265,7 +267,6 @@ typedef struct ModifierTypeInfo {
*
* This function is optional.
*/
- /* TODO(sergey): Remove once we finally switched to the new depsgraph. */
void (*updateDepsgraph)(struct ModifierData *md,
struct Main *bmain,
struct Scene *scene,
@@ -336,6 +337,7 @@ bool modifier_unique_name(struct ListBase *modifiers, struct ModifierDa
void modifier_copyData_generic(const struct ModifierData *md, struct ModifierData *target);
void modifier_copyData(struct ModifierData *md, struct ModifierData *target);
+void modifier_copyData_ex(struct ModifierData *md, struct ModifierData *target, const int flag);
bool modifier_dependsOnTime(struct ModifierData *md);
bool modifier_supportsMapping(struct ModifierData *md);
bool modifier_supportsCage(struct Scene *scene, struct ModifierData *md);
@@ -418,24 +420,24 @@ const char *modifier_path_relbase(struct Object *ob);
/* wrappers for modifier callbacks */
struct DerivedMesh *modwrap_applyModifier(
- ModifierData *md, struct Object *ob,
- struct DerivedMesh *dm,
+ ModifierData *md, const struct EvaluationContext *eval_ctx,
+ struct Object *ob, struct DerivedMesh *dm,
ModifierApplyFlag flag);
struct DerivedMesh *modwrap_applyModifierEM(
- ModifierData *md, struct Object *ob,
- struct BMEditMesh *em,
+ ModifierData *md, const struct EvaluationContext *eval_ctx,
+ struct Object *ob, struct BMEditMesh *em,
struct DerivedMesh *dm,
ModifierApplyFlag flag);
void modwrap_deformVerts(
- ModifierData *md, struct Object *ob,
- struct DerivedMesh *dm,
+ ModifierData *md, const struct EvaluationContext *eval_ctx,
+ struct Object *ob, struct DerivedMesh *dm,
float (*vertexCos)[3], int numVerts,
ModifierApplyFlag flag);
void modwrap_deformVertsEM(
- ModifierData *md, struct Object *ob,
+ ModifierData *md, const struct EvaluationContext *eval_ctx, struct Object *ob,
struct BMEditMesh *em, struct DerivedMesh *dm,
float (*vertexCos)[3], int numVerts);
diff --git a/source/blender/blenkernel/BKE_movieclip.h b/source/blender/blenkernel/BKE_movieclip.h
index 69fdad5ef7b..3ddf75f204e 100644
--- a/source/blender/blenkernel/BKE_movieclip.h
+++ b/source/blender/blenkernel/BKE_movieclip.h
@@ -41,6 +41,7 @@ struct MovieDistortion;
void BKE_movieclip_free(struct MovieClip *clip);
+void BKE_movieclip_copy_data(struct Main *bmain, struct MovieClip *clip_dst, const struct MovieClip *clip_src, const int flag);
struct MovieClip *BKE_movieclip_copy(struct Main *bmain, const struct MovieClip *clip);
void BKE_movieclip_make_local(struct Main *bmain, struct MovieClip *clip, const bool lib_local);
diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h
index 178751d1640..761bb7e8acb 100644
--- a/source/blender/blenkernel/BKE_multires.h
+++ b/source/blender/blenkernel/BKE_multires.h
@@ -34,6 +34,7 @@
enum MultiresModifiedFlags;
struct DerivedMesh;
+struct EvaluationContext;
struct MDisps;
struct Mesh;
struct ModifierData;
@@ -80,18 +81,18 @@ struct DerivedMesh *multires_make_derived_from_derived(struct DerivedMesh *dm,
struct MultiresModifierData *find_multires_modifier_before(struct Scene *scene,
struct ModifierData *lastmd);
struct MultiresModifierData *get_multires_modifier(struct Scene *scene, struct Object *ob, bool use_first);
-struct DerivedMesh *get_multires_dm(struct Scene *scene, struct MultiresModifierData *mmd,
+struct DerivedMesh *get_multires_dm(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct MultiresModifierData *mmd,
struct Object *ob);
void multiresModifier_del_levels(struct MultiresModifierData *, struct Object *, int direction);
void multiresModifier_base_apply(struct MultiresModifierData *mmd, struct Object *ob);
void multiresModifier_subdivide(struct MultiresModifierData *mmd, struct Object *ob, int updateblock, int simple);
void multiresModifier_sync_levels_ex(
struct Object *ob_dst, struct MultiresModifierData *mmd_src, struct MultiresModifierData *mmd_dst);
-int multiresModifier_reshape(struct Scene *scene, struct MultiresModifierData *mmd,
+int multiresModifier_reshape(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct MultiresModifierData *mmd,
struct Object *dst, struct Object *src);
-int multiresModifier_reshapeFromDM(struct Scene *scene, struct MultiresModifierData *mmd,
+int multiresModifier_reshapeFromDM(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct MultiresModifierData *mmd,
struct Object *ob, struct DerivedMesh *srcdm);
-int multiresModifier_reshapeFromDeformMod(struct Scene *scene, struct MultiresModifierData *mmd,
+int multiresModifier_reshapeFromDeformMod(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct MultiresModifierData *mmd,
struct Object *ob, struct ModifierData *md);
void multires_stitch_grids(struct Object *);
@@ -109,8 +110,8 @@ void multires_free(struct Multires *mr);
void multires_load_old(struct Object *ob, struct Mesh *me);
void multires_load_old_250(struct Mesh *);
-void multiresModifier_scale_disp(struct Scene *scene, struct Object *ob);
-void multiresModifier_prepare_join(struct Scene *scene, struct Object *ob, struct Object *to_ob);
+void multiresModifier_scale_disp(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
+void multiresModifier_prepare_join(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct Object *to_ob);
int multires_mdisp_corners(struct MDisps *s);
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index a668ae9a7af..ea0b350b8af 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -336,6 +336,7 @@ struct bNodeTree *ntreeAddTree(struct Main *bmain, const char *name, const char
/* copy/free funcs, need to manage ID users */
void ntreeFreeTree(struct bNodeTree *ntree);
+void BKE_node_tree_copy_data(struct Main *bmain, struct bNodeTree *ntree_dst, const struct bNodeTree *ntree_src, const int flag);
struct bNodeTree *ntreeCopyTree_ex(const struct bNodeTree *ntree, struct Main *bmain, const bool do_id_user);
struct bNodeTree *ntreeCopyTree(struct Main *bmain, const struct bNodeTree *ntree);
/* node->id user count */
@@ -453,6 +454,7 @@ void nodeUnlinkNode(struct bNodeTree *ntree, struct bNode *node);
void nodeUniqueName(struct bNodeTree *ntree, struct bNode *node);
void nodeFreeNode(struct bNodeTree *ntree, struct bNode *node);
+struct bNode *BKE_node_copy_ex(struct bNodeTree *ntree, struct bNode *node_src, const int flag);
struct bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node);
struct bNodeLink *nodeAddLink(struct bNodeTree *ntree, struct bNode *fromnode, struct bNodeSocket *fromsock, struct bNode *tonode, struct bNodeSocket *tosock);
@@ -794,9 +796,7 @@ struct ShadeResult;
#define SH_NODE_UVALONGSTROKE 191
#define SH_NODE_TEX_POINTDENSITY 192
#define SH_NODE_BSDF_PRINCIPLED 193
-#define SH_NODE_EEVEE_METALLIC 194
#define SH_NODE_EEVEE_SPECULAR 195
-#define SH_NODE_OUTPUT_EEVEE_MATERIAL 196
/* custom defines options for Material node */
#define SH_NODE_MAT_DIFF 1
@@ -1050,4 +1050,16 @@ int ntreeTexExecTree(struct bNodeTree *ntree, struct TexResult *target,
void init_nodesystem(void);
void free_nodesystem(void);
+/* -------------------------------------------------------------------- */
+/* evaluation support, */
+
+struct EvaluationContext;
+
+void BKE_nodetree_copy_default_values(struct bNodeTree *ntree_dst,
+ const struct bNodeTree *ntree_src);
+
+void BKE_nodetree_shading_params_eval(const struct EvaluationContext *eval_ctx,
+ struct bNodeTree *ntree_dst,
+ const struct bNodeTree *ntree_src);
+
#endif /* __BKE_NODE_H__ */
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 2aa7829c9df..ce6a95c682b 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -51,13 +51,13 @@ struct HookModifierData;
struct ModifierData;
void BKE_object_workob_clear(struct Object *workob);
-void BKE_object_workob_calc_parent(struct Scene *scene, struct Object *ob, struct Object *workob);
+void BKE_object_workob_calc_parent(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct Object *workob);
void BKE_object_transform_copy(struct Object *ob_tar, const struct Object *ob_src);
-struct SoftBody *copy_softbody(const struct SoftBody *sb, bool copy_caches);
-struct BulletSoftBody *copy_bulletsoftbody(const struct BulletSoftBody *sb);
-struct ParticleSystem *BKE_object_copy_particlesystem(struct ParticleSystem *psys);
-void BKE_object_copy_particlesystems(struct Object *ob_dst, const struct Object *ob_src);
+struct SoftBody *copy_softbody(const struct SoftBody *sb, const int flag);
+struct BulletSoftBody *copy_bulletsoftbody(const struct BulletSoftBody *sb, const int flag);
+struct ParticleSystem *BKE_object_copy_particlesystem(struct ParticleSystem *psys, const int flag);
+void BKE_object_copy_particlesystems(struct Object *ob_dst, const struct Object *ob_src, const int flag);
void BKE_object_copy_softbody(struct Object *ob_dst, const struct Object *ob_src);
void BKE_object_free_particlesystems(struct Object *ob);
void BKE_object_free_softbody(struct Object *ob);
@@ -83,6 +83,7 @@ bool BKE_object_exists_check(struct Object *obtest);
bool BKE_object_is_in_editmode(struct Object *ob);
bool BKE_object_is_in_editmode_vgroup(struct Object *ob);
bool BKE_object_is_in_wpaint_select_vert(struct Object *ob);
+bool BKE_object_is_visible(struct Object *ob);
void BKE_object_init(struct Object *ob);
struct Object *BKE_object_add_only_object(
@@ -106,7 +107,7 @@ bool BKE_object_lod_is_usable(struct Object *ob, struct SceneLayer *sl);
struct Object *BKE_object_lod_meshob_get(struct Object *ob, struct SceneLayer *sl);
struct Object *BKE_object_lod_matob_get(struct Object *ob, struct SceneLayer *sl);
-struct Object *BKE_object_copy_ex(struct Main *bmain, const struct Object *ob, bool copy_caches);
+void BKE_object_copy_data(struct Main *bmain, struct Object *ob_dst, const struct Object *ob_src, const int flag);
struct Object *BKE_object_copy(struct Main *bmain, const struct Object *ob);
void BKE_object_make_local(struct Main *bmain, struct Object *ob, const bool lib_local);
void BKE_object_make_local_ex(struct Main *bmain, struct Object *ob, const bool lib_local, const bool clear_proxy);
@@ -126,11 +127,12 @@ void BKE_object_matrix_local_get(struct Object *ob, float mat[4][4]);
bool BKE_object_pose_context_check(struct Object *ob);
struct Object *BKE_object_pose_armature_get(struct Object *ob);
-void BKE_object_get_parent_matrix(struct Scene *scene, struct Object *ob, struct Object *par, float parentmat[4][4]);
-void BKE_object_where_is_calc(struct Scene *scene, struct Object *ob);
-void BKE_object_where_is_calc_ex(struct Scene *scene, struct RigidBodyWorld *rbw, struct Object *ob, float r_originmat[3][3]);
-void BKE_object_where_is_calc_time(struct Scene *scene, struct Object *ob, float ctime);
-void BKE_object_where_is_calc_time_ex(struct Scene *scene, struct Object *ob, float ctime,
+void BKE_object_get_parent_matrix(struct Scene *scene, struct Object *ob,
+ struct Object *par, float parentmat[4][4]);
+void BKE_object_where_is_calc(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
+void BKE_object_where_is_calc_ex(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct RigidBodyWorld *rbw, struct Object *ob, float r_originmat[3][3]);
+void BKE_object_where_is_calc_time(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, float ctime);
+void BKE_object_where_is_calc_time_ex(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, float ctime,
struct RigidBodyWorld *rbw, float r_originmat[3][3]);
void BKE_object_where_is_calc_mat4(struct Scene *scene, struct Object *ob, float obmat[4][4]);
@@ -178,37 +180,43 @@ void BKE_object_tfm_protected_restore(struct Object *ob,
const short protectflag);
/* Dependency graph evaluation callbacks. */
-void BKE_object_eval_local_transform(struct EvaluationContext *eval_ctx,
+void BKE_object_eval_local_transform(const struct EvaluationContext *eval_ctx,
struct Scene *scene,
struct Object *ob);
-void BKE_object_eval_parent(struct EvaluationContext *eval_ctx,
+void BKE_object_eval_parent(const struct EvaluationContext *eval_ctx,
struct Scene *scene,
struct Object *ob);
-void BKE_object_eval_constraints(struct EvaluationContext *eval_ctx,
+void BKE_object_eval_constraints(const struct EvaluationContext *eval_ctx,
struct Scene *scene,
struct Object *ob);
-void BKE_object_eval_done(struct EvaluationContext *eval_ctx, struct Object *ob);
+void BKE_object_eval_done(const struct EvaluationContext *eval_ctx, struct Object *ob);
-void BKE_object_eval_uber_transform(struct EvaluationContext *eval_ctx,
+void BKE_object_eval_uber_transform(const struct EvaluationContext *eval_ctx,
struct Scene *scene,
struct Object *ob);
-void BKE_object_eval_uber_data(struct EvaluationContext *eval_ctx,
+void BKE_object_eval_uber_data(const struct EvaluationContext *eval_ctx,
struct Scene *scene,
struct Object *ob);
-void BKE_object_eval_cloth(struct EvaluationContext *eval_ctx,
+void BKE_object_eval_cloth(const struct EvaluationContext *eval_ctx,
struct Scene *scene,
struct Object *object);
-
-void BKE_object_handle_data_update(struct EvaluationContext *eval_ctx,
- struct Scene *scene,
- struct Object *ob);
-void BKE_object_handle_update(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
-void BKE_object_handle_update_ex(struct EvaluationContext *eval_ctx,
- struct Scene *scene, struct Object *ob,
- struct RigidBodyWorld *rbw,
- const bool do_proxy_update);
+void BKE_object_eval_update_shading(const struct EvaluationContext *eval_ctx,
+ struct Object *object);
+
+void BKE_object_handle_data_update(
+ const struct EvaluationContext *eval_ctx,
+ struct Scene *scene,
+ struct Object *ob);
+void BKE_object_handle_update(
+ const struct EvaluationContext *eval_ctx,
+ struct Scene *scene, struct Object *ob);
+void BKE_object_handle_update_ex(
+ const struct EvaluationContext *eval_ctx,
+ struct Scene *scene, struct Object *ob,
+ struct RigidBodyWorld *rbw,
+ const bool do_proxy_update);
void BKE_object_sculpt_modifiers_changed(struct Object *ob);
int BKE_object_obdata_texspace_get(struct Object *ob, short **r_texflag, float **r_loc, float **r_size, float **r_rot);
@@ -259,9 +267,8 @@ struct KDTree *BKE_object_as_kdtree(struct Object *ob, int *r_tot);
bool BKE_object_modifier_use_time(struct Object *ob, struct ModifierData *md);
-bool BKE_object_modifier_update_subframe(struct Scene *scene, struct Object *ob, bool update_mesh,
- int parent_recursion, float frame,
- int type);
+bool BKE_object_modifier_update_subframe(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
+ bool update_mesh, int parent_recursion, float frame, int type);
#ifdef __cplusplus
}
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 787a67170c2..f88dfc6f817 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -58,6 +58,7 @@ struct StrokeCache;
struct Tex;
struct ImagePool;
struct UnifiedPaintSettings;
+struct EvaluationContext;
enum OverlayFlags;
@@ -100,6 +101,8 @@ void BKE_paint_set_overlay_override(enum OverlayFlags flag);
/* palettes */
void BKE_palette_free(struct Palette *palette);
struct Palette *BKE_palette_add(struct Main *bmain, const char *name);
+void BKE_palette_copy_data(
+ struct Main *bmain, struct Palette *palette_dst, const struct Palette *palette_src, const int flag);
struct Palette *BKE_palette_copy(struct Main *bmain, const struct Palette *palette);
void BKE_palette_make_local(struct Main *bmain, struct Palette *palette, const bool lib_local);
struct PaletteColor *BKE_palette_color_add(struct Palette *palette);
@@ -110,12 +113,14 @@ void BKE_palette_clear(struct Palette *palette);
/* paint curves */
struct PaintCurve *BKE_paint_curve_add(struct Main *bmain, const char *name);
void BKE_paint_curve_free(struct PaintCurve *pc);
+void BKE_paint_curve_copy_data(
+ struct Main *bmain, struct PaintCurve *pc_dst, const struct PaintCurve *pc_src, const int flag);
struct PaintCurve *BKE_paint_curve_copy(struct Main *bmain, const struct PaintCurve *pc);
void BKE_paint_curve_make_local(struct Main *bmain, struct PaintCurve *pc, const bool lib_local);
void BKE_paint_init(struct Scene *sce, PaintMode mode, const char col[3]);
void BKE_paint_free(struct Paint *p);
-void BKE_paint_copy(struct Paint *src, struct Paint *tar);
+void BKE_paint_copy(struct Paint *src, struct Paint *tar, const int flag);
void BKE_paint_cavity_curve_preset(struct Paint *p, int preset);
@@ -157,6 +162,14 @@ void paint_update_brush_rake_rotation(struct UnifiedPaintSettings *ups, struct B
void BKE_paint_stroke_get_average(struct Scene *scene, struct Object *ob, float stroke[3]);
+/* Used for both vertex color and weight paint */
+struct SculptVertexPaintGeomMap {
+ int *vert_map_mem;
+ struct MeshElemMap *vert_to_loop;
+ int *poly_map_mem;
+ struct MeshElemMap *vert_to_poly;
+};
+
/* Session data (mode-specific) */
typedef struct SculptSession {
@@ -202,14 +215,43 @@ typedef struct SculptSession {
struct SculptStroke *stroke;
struct StrokeCache *cache;
+
+ union {
+ struct {
+ struct SculptVertexPaintGeomMap gmap;
+
+ /* For non-airbrush painting to re-apply from the original (MLoop aligned). */
+ unsigned int *previous_color;
+ } vpaint;
+
+ struct {
+ struct SculptVertexPaintGeomMap gmap;
+ /* Keep track of how much each vertex has been painted (non-airbrush only). */
+ float *alpha_weight;
+
+ /* Needed to continuously re-apply over the same weights (BRUSH_ACCUMULATE disabled).
+ * Lazy initialize as needed (flag is set to 1 to tag it as uninitialized). */
+ struct MDeformVert *dvert_prev;
+ } wpaint;
+
+ //struct {
+ //ToDo: identify sculpt-only fields
+ //} sculpt;
+ } mode;
+ int mode_type;
+
+ /* This flag prevents PBVH from being freed when creating the vp_handle for texture paint. */
+ bool building_vp_handle;
} SculptSession;
void BKE_sculptsession_free(struct Object *ob);
void BKE_sculptsession_free_deformMats(struct SculptSession *ss);
+void BKE_sculptsession_free_vwpaint_data(struct SculptSession *ss);
void BKE_sculptsession_bm_to_me(struct Object *ob, bool reorder);
void BKE_sculptsession_bm_to_me_for_render(struct Object *object);
-void BKE_sculpt_update_mesh_elements(struct Scene *scene, struct Sculpt *sd, struct Object *ob,
- bool need_pmap, bool need_mask);
+void BKE_sculpt_update_mesh_elements(
+ const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Sculpt *sd, struct Object *ob,
+ bool need_pmap, bool need_mask);
struct MultiresModifierData *BKE_sculpt_multires_active(struct Scene *scene, struct Object *ob);
int BKE_sculpt_mask_layers_ensure(struct Object *ob,
struct MultiresModifierData *mmd);
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index ec707c84872..a563fcbc99e 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -62,6 +62,7 @@ struct RNG;
struct BVHTreeRay;
struct BVHTreeRayHit;
struct EdgeHash;
+struct EvaluationContext;
#define PARTICLE_COLLISION_MAX_COLLISIONS 10
@@ -77,6 +78,7 @@ struct EdgeHash;
/* common stuff that many particle functions need */
typedef struct ParticleSimulationData {
+ const struct EvaluationContext *eval_ctx;
struct Scene *scene;
struct Object *ob;
struct ParticleSystem *psys;
@@ -324,6 +326,9 @@ struct ParticleSystemModifierData *psys_get_modifier(struct Object *ob, struct P
struct ModifierData *object_add_particle_system(struct Scene *scene, struct Object *ob, const char *name);
void object_remove_particle_system(struct Scene *scene, struct Object *ob);
struct ParticleSettings *psys_new_settings(const char *name, struct Main *main);
+void BKE_particlesettings_copy_data(
+ struct Main *bmain, struct ParticleSettings *part_dst, const struct ParticleSettings *part_src,
+ const int flag);
struct ParticleSettings *BKE_particlesettings_copy(struct Main *bmain, const struct ParticleSettings *part);
void BKE_particlesettings_make_local(struct Main *bmain, struct ParticleSettings *part, const bool lib_local);
@@ -332,9 +337,9 @@ void psys_reset(struct ParticleSystem *psys, int mode);
void psys_find_parents(struct ParticleSimulationData *sim, const bool use_render_params);
void psys_cache_paths(struct ParticleSimulationData *sim, float cfra, const bool use_render_params);
-void psys_cache_edit_paths(struct Scene *scene, struct Object *ob, struct PTCacheEdit *edit, float cfra, const bool use_render_params);
+void psys_cache_edit_paths(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct PTCacheEdit *edit, float cfra, const bool use_render_params);
void psys_cache_child_paths(struct ParticleSimulationData *sim, float cfra, const bool editupdate, const bool use_render_params);
-int do_guides(struct ParticleSettings *part, struct ListBase *effectors, ParticleKey *state, int pa_num, float time);
+int do_guides(const struct EvaluationContext *eval_ctx, struct ParticleSettings *part, struct ListBase *effectors, ParticleKey *state, int pa_num, float time);
void precalc_guides(struct ParticleSimulationData *sim, struct ListBase *effectors);
float psys_get_timestep(struct ParticleSimulationData *sim);
float psys_get_child_time(struct ParticleSystem *psys, struct ChildParticle *cpa, float cfra, float *birthtime, float *dietime);
@@ -366,7 +371,7 @@ void psys_tasks_create(struct ParticleThreadContext *ctx, int startpart, int end
void psys_tasks_free(struct ParticleTask *tasks, int numtasks);
void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3], float zvec[3], float center[3]);
-void psys_apply_hair_lattice(struct Scene *scene, struct Object *ob, struct ParticleSystem *psys);
+void psys_apply_hair_lattice(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct ParticleSystem *psys);
/* particle_system.c */
struct ParticleSystem *psys_get_target_system(struct Object *ob, struct ParticleTarget *pt);
@@ -381,7 +386,7 @@ void psys_check_boid_data(struct ParticleSystem *psys);
void psys_get_birth_coords(struct ParticleSimulationData *sim, struct ParticleData *pa, struct ParticleKey *state, float dtime, float cfra);
-void particle_system_update(struct Scene *scene, struct Object *ob, struct ParticleSystem *psys, const bool use_render_params);
+void particle_system_update(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct ParticleSystem *psys, const bool use_render_params);
/* Callback format for performing operations on ID-pointers for particle systems */
typedef void (*ParticleSystemIDFunc)(struct ParticleSystem *psys, struct ID **idpoin, void *userdata, int cb_flag);
@@ -473,10 +478,14 @@ typedef struct ParticleRenderData {
struct EvaluationContext;
-void BKE_particle_system_eval(struct EvaluationContext *eval_ctx,
- struct Scene *scene,
- struct Object *ob,
- struct ParticleSystem *psys);
+void BKE_particle_system_settings_eval(const struct EvaluationContext *eval_ctx,
+ struct ParticleSystem *psys);
+void BKE_particle_system_settings_recalc_clear(struct EvaluationContext *UNUSED(eval_ctx),
+ struct ParticleSettings *particle_settings);
+
+void BKE_particle_system_eval_init(const struct EvaluationContext *eval_ctx,
+ struct Scene *scene,
+ struct Object *ob);
#endif
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index 905eb677612..9aea5dc95a0 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -33,6 +33,7 @@
struct Gwn_Batch;
struct CCGElem;
struct CCGKey;
+struct CCGDerivedMesh;
struct CustomData;
struct DMFlagMat;
struct MPoly;
@@ -59,6 +60,8 @@ typedef bool (*BKE_pbvh_SearchCallback)(PBVHNode *node, void *data);
typedef void (*BKE_pbvh_HitCallback)(PBVHNode *node, void *data);
typedef void (*BKE_pbvh_HitOccludedCallback)(PBVHNode *node, void *data, float *tmin);
+typedef void (*BKE_pbvh_SearchNearestCallback)(PBVHNode *node, void *data, float *tmin);
+
/* Building */
PBVH *BKE_pbvh_new(void);
@@ -72,7 +75,7 @@ void BKE_pbvh_build_grids(PBVH *bvh, struct CCGElem **grid_elems,
struct CCGKey *key, void **gridfaces, struct DMFlagMat *flagmats,
unsigned int **grid_hidden);
void BKE_pbvh_build_bmesh(PBVH *bvh, struct BMesh *bm, bool smooth_shading, struct BMLog *log, const int cd_vert_node_offset, const int cd_face_node_offset);
-
+void BKE_pbvh_set_ccgdm(PBVH *bvh, struct CCGDerivedMesh *ccgdm);
void BKE_pbvh_free(PBVH *bvh);
void BKE_pbvh_free_layer_disp(PBVH *bvh);
@@ -101,12 +104,12 @@ void BKE_pbvh_raycast(
bool BKE_pbvh_node_raycast(
PBVH *bvh, PBVHNode *node, float (*origco)[3], bool use_origco,
const float ray_start[3], const float ray_normal[3],
- float *dist);
+ float *depth);
bool BKE_pbvh_bmesh_node_raycast_detail(
PBVHNode *node,
const float ray_start[3], const float ray_normal[3],
- float *dist, float *r_detail);
+ float *depth, float *r_detail);
/* for orthographic cameras, project the far away ray segment points to the root node so
* we can have better precision. */
@@ -114,11 +117,22 @@ void BKE_pbvh_raycast_project_ray_root(
PBVH *bvh, bool original,
float ray_start[3], float ray_end[3], float ray_normal[3]);
+void BKE_pbvh_find_nearest_to_ray(
+ PBVH *bvh, BKE_pbvh_HitOccludedCallback cb, void *data,
+ const float ray_start[3], const float ray_normal[3],
+ bool original);
+
+bool BKE_pbvh_node_find_nearest_to_ray(
+ PBVH *bvh, PBVHNode *node, float (*origco)[3], bool use_origco,
+ const float ray_start[3], const float ray_normal[3],
+ float *depth, float *dist_sq);
+
/* Drawing */
void BKE_pbvh_node_draw(PBVHNode *node, void *data);
void BKE_pbvh_draw(PBVH *bvh, float (*planes)[4], float (*face_nors)[3],
int (*setMaterial)(int matnr, void *attribs), bool wireframe, bool fast);
+void BKE_pbvh_draw_BB(PBVH *bvh);
void BKE_pbvh_draw_cb(
PBVH *bvh, float (*planes)[4], float (*fnors)[3], bool fast,
void (*draw_fn)(void *user_data, struct Gwn_Batch *batch), void *user_data);
@@ -145,6 +159,7 @@ int BKE_pbvh_count_grid_quads(BLI_bitmap **grid_hidden,
/* multires level, only valid for type == PBVH_GRIDS */
void BKE_pbvh_get_grid_key(const PBVH *pbvh, struct CCGKey *key);
+struct CCGDerivedMesh *BKE_pbvh_get_ccgdm(const PBVH *bvh);
/* Only valid for type == PBVH_BMESH */
struct BMesh *BKE_pbvh_get_bmesh(PBVH *pbvh);
@@ -157,7 +172,7 @@ typedef enum {
bool BKE_pbvh_bmesh_update_topology(
PBVH *bvh, PBVHTopologyUpdateMode mode,
const float center[3], const float view_normal[3],
- float radius);
+ float radius, const bool use_frontface, const bool use_projected);
/* Node Access */
diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h
index 02f6c435ee2..f0819c8d79d 100644
--- a/source/blender/blenkernel/BKE_pointcache.h
+++ b/source/blender/blenkernel/BKE_pointcache.h
@@ -314,7 +314,7 @@ struct PointCache *BKE_ptcache_add(struct ListBase *ptcaches);
void BKE_ptcache_free_mem(struct ListBase *mem_cache);
void BKE_ptcache_free(struct PointCache *cache);
void BKE_ptcache_free_list(struct ListBase *ptcaches);
-struct PointCache *BKE_ptcache_copy_list(struct ListBase *ptcaches_new, const struct ListBase *ptcaches_old, bool copy_data);
+struct PointCache *BKE_ptcache_copy_list(struct ListBase *ptcaches_new, const struct ListBase *ptcaches_old, const int flag);
/********************** Baking *********************/
diff --git a/source/blender/blenkernel/BKE_rigidbody.h b/source/blender/blenkernel/BKE_rigidbody.h
index c72f067a111..6aa43665427 100644
--- a/source/blender/blenkernel/BKE_rigidbody.h
+++ b/source/blender/blenkernel/BKE_rigidbody.h
@@ -37,6 +37,7 @@
struct RigidBodyWorld;
struct RigidBodyOb;
+struct EvaluationContext;
struct Scene;
struct Object;
@@ -49,8 +50,8 @@ void BKE_rigidbody_free_constraint(struct Object *ob);
/* ...... */
-struct RigidBodyOb *BKE_rigidbody_copy_object(const struct Object *ob);
-struct RigidBodyCon *BKE_rigidbody_copy_constraint(const struct Object *ob);
+struct RigidBodyOb *BKE_rigidbody_copy_object(const struct Object *ob, const int flag);
+struct RigidBodyCon *BKE_rigidbody_copy_constraint(const struct Object *ob, const int flag);
/* Callback format for performing operations on ID-pointers for rigidbody world. */
typedef void (*RigidbodyWorldIDFunc)(struct RigidBodyWorld *rbw, struct ID **idpoin, void *userdata, int cb_flag);
@@ -66,7 +67,7 @@ struct RigidBodyOb *BKE_rigidbody_create_object(struct Scene *scene, struct Obje
struct RigidBodyCon *BKE_rigidbody_create_constraint(struct Scene *scene, struct Object *ob, short type);
/* copy */
-struct RigidBodyWorld *BKE_rigidbody_world_copy(struct RigidBodyWorld *rbw);
+struct RigidBodyWorld *BKE_rigidbody_world_copy(struct RigidBodyWorld *rbw, const int flag);
void BKE_rigidbody_world_groups_relink(struct RigidBodyWorld *rbw);
/* 'validate' (i.e. make new or replace old) Physics-Engine objects */
@@ -99,21 +100,19 @@ void BKE_rigidbody_aftertrans_update(struct Object *ob, float loc[3], float rot[
void BKE_rigidbody_sync_transforms(struct RigidBodyWorld *rbw, struct Object *ob, float ctime);
bool BKE_rigidbody_check_sim_running(struct RigidBodyWorld *rbw, float ctime);
void BKE_rigidbody_cache_reset(struct RigidBodyWorld *rbw);
-void BKE_rigidbody_rebuild_world(struct Scene *scene, float ctime);
-void BKE_rigidbody_do_simulation(struct Scene *scene, float ctime);
+void BKE_rigidbody_rebuild_world(const struct EvaluationContext *eval_ctx, struct Scene *scene, float ctime);
+void BKE_rigidbody_do_simulation(const struct EvaluationContext *eval_ctx, struct Scene *scene, float ctime);
/* -------------------- */
/* Depsgraph evaluation */
-struct EvaluationContext;
-
-void BKE_rigidbody_rebuild_sim(struct EvaluationContext *eval_ctx,
+void BKE_rigidbody_rebuild_sim(const struct EvaluationContext *eval_ctx,
struct Scene *scene);
-void BKE_rigidbody_eval_simulation(struct EvaluationContext *eval_ctx,
+void BKE_rigidbody_eval_simulation(const struct EvaluationContext *eval_ctx,
struct Scene *scene);
-void BKE_rigidbody_object_sync_transforms(struct EvaluationContext *eval_ctx,
+void BKE_rigidbody_object_sync_transforms(const struct EvaluationContext *eval_ctx,
struct Scene *scene,
struct Object *ob);
diff --git a/source/blender/blenkernel/BKE_sca.h b/source/blender/blenkernel/BKE_sca.h
index 10cddd7b454..35bcd91a9b1 100644
--- a/source/blender/blenkernel/BKE_sca.h
+++ b/source/blender/blenkernel/BKE_sca.h
@@ -52,16 +52,16 @@ void free_actuators(struct ListBase *lb);
void free_sensor(struct bSensor *sens);
void free_sensors(struct ListBase *lb);
-struct bSensor *copy_sensor(struct bSensor *sens);
-void copy_sensors(struct ListBase *lbn, const struct ListBase *lbo);
+struct bSensor *copy_sensor(struct bSensor *sens, const int flag);
+void copy_sensors(struct ListBase *lbn, const struct ListBase *lbo, const int flag);
void init_sensor(struct bSensor *sens);
struct bSensor *new_sensor(int type);
-struct bController *copy_controller(struct bController *cont);
-void copy_controllers(struct ListBase *lbn, const struct ListBase *lbo);
+struct bController *copy_controller(struct bController *cont, const int flag);
+void copy_controllers(struct ListBase *lbn, const struct ListBase *lbo, const int flag);
void init_controller(struct bController *cont);
struct bController *new_controller(int type);
-struct bActuator *copy_actuator(struct bActuator *act);
-void copy_actuators(struct ListBase *lbn, const struct ListBase *lbo);
+struct bActuator *copy_actuator(struct bActuator *act, const int flag);
+void copy_actuators(struct ListBase *lbn, const struct ListBase *lbo, const int flag);
void init_actuator(struct bActuator *act);
struct bActuator *new_actuator(int type);
void clear_sca_new_poins_ob(struct Object *ob);
@@ -70,7 +70,7 @@ void set_sca_new_poins_ob(struct Object *ob);
void set_sca_new_poins(void);
void BKE_sca_logic_links_remap(struct Main *bmain, struct Object *ob_old, struct Object *ob_new);
-void BKE_sca_logic_copy(struct Object *ob_new, const struct Object *ob);
+void BKE_sca_logic_copy(struct Object *ob_new, const struct Object *ob, const int flag);
void sca_move_sensor(struct bSensor *sens_to_move, struct Object *ob, int move_up);
void sca_move_controller(struct bController *cont_to_move, struct Object *ob, int move_up);
diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h
index 5047070012c..e517b65cf3e 100644
--- a/source/blender/blenkernel/BKE_scene.h
+++ b/source/blender/blenkernel/BKE_scene.h
@@ -39,12 +39,12 @@ extern "C" {
struct AviCodecData;
struct BaseLegacy;
+struct Depsgraph;
struct EvaluationContext;
struct Main;
struct Object;
-struct Base;
-struct QuicktimeCodecData;
struct RenderData;
+struct SceneLayer;
struct SceneRenderLayer;
struct Scene;
struct SceneCollection;
@@ -69,7 +69,6 @@ typedef enum eSceneCopyMethod {
struct Base *_setlooper_base_step(struct Scene **sce_iter, struct Base *base);
void free_avicodecdata(struct AviCodecData *acd);
-void free_qtcodecdata(struct QuicktimeCodecData *acd);
void BKE_scene_free_ex(struct Scene *sce, const bool do_id_user);
void BKE_scene_free(struct Scene *sce);
@@ -97,8 +96,9 @@ typedef struct SceneBaseIter {
int phase;
} SceneBaseIter;
-int BKE_scene_base_iter_next(struct EvaluationContext *eval_ctx, struct SceneBaseIter *iter,
- struct Scene **scene, int val, struct BaseLegacy **base, struct Object **ob);
+int BKE_scene_base_iter_next(
+ const struct EvaluationContext *eval_ctx, struct SceneBaseIter *iter,
+ struct Scene **scene, int val, struct BaseLegacy **base, struct Object **ob);
void BKE_scene_base_flag_to_objects(struct SceneLayer *sl);
void BKE_scene_base_flag_from_objects(struct Scene *scene);
@@ -110,6 +110,7 @@ void BKE_scene_object_base_flag_sync_from_object(struct Base *base);
void BKE_scene_set_background(struct Main *bmain, struct Scene *sce);
struct Scene *BKE_scene_set_name(struct Main *bmain, const char *name);
+void BKE_scene_copy_data(struct Main *bmain, struct Scene *sce_dst, const struct Scene *sce_src, const int flag);
struct Scene *BKE_scene_copy(struct Main *bmain, struct Scene *sce, int type);
void BKE_scene_groups_relink(struct Scene *sce);
@@ -165,6 +166,8 @@ bool BKE_scene_check_rigidbody_active(const struct Scene *scene);
int BKE_scene_num_threads(const struct Scene *scene);
int BKE_render_num_threads(const struct RenderData *r);
+int BKE_render_preview_pixel_size(const struct RenderData *r);
+
double BKE_scene_unit_scale(const struct UnitSettings *unit, const int unit_type, double value);
/* multiview */
@@ -184,9 +187,11 @@ void BKE_scene_multiview_view_prefix_get(struct Scene *scene, const char
void BKE_scene_multiview_videos_dimensions_get(const struct RenderData *rd, const size_t width, const size_t height, size_t *r_width, size_t *r_height);
int BKE_scene_multiview_num_videos_get(const struct RenderData *rd);
+/* depsgraph */
+struct Depsgraph *BKE_scene_get_depsgraph(struct Scene *scene, struct SceneLayer *scene_layer);
+
#ifdef __cplusplus
}
#endif
#endif
-
diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h
index 6ff344fea38..3cb78a427ab 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -294,6 +294,7 @@ void BKE_area_region_free(struct SpaceType *st, struct ARegion *ar);
void BKE_screen_area_free(struct ScrArea *sa);
/* Manipulator-maps of a region need to be freed with the region. Uses callback to avoid low-level call. */
void BKE_region_callback_free_manipulatormap_set(void (*callback)(struct wmManipulatorMap *));
+void BKE_region_callback_refresh_tag_manipulatormap_set(void (*callback)(struct wmManipulatorMap *));
struct ARegion *BKE_area_find_region_type(struct ScrArea *sa, int type);
struct ARegion *BKE_area_find_region_active_win(struct ScrArea *sa);
@@ -309,6 +310,8 @@ unsigned int BKE_screen_view3d_layer_active(
unsigned int BKE_screen_view3d_layer_all(const struct bScreen *sc) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
+void BKE_screen_manipulator_tag_refresh(struct bScreen *sc);
+
void BKE_screen_view3d_sync(struct View3D *v3d, struct Scene *scene);
void BKE_screen_view3d_scene_sync(struct bScreen *sc, struct Scene *scene);
void BKE_screen_transform_orientation_remove(
diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h
index 7c09cafaf64..bcc06a4ab25 100644
--- a/source/blender/blenkernel/BKE_sequencer.h
+++ b/source/blender/blenkernel/BKE_sequencer.h
@@ -335,7 +335,8 @@ bool BKE_sequence_base_shuffle(
bool BKE_sequence_base_shuffle_time(ListBase *seqbasep, struct Scene *evil_scene);
bool BKE_sequence_base_isolated_sel_check(struct ListBase *seqbase);
void BKE_sequencer_free_imbuf(struct Scene *scene, struct ListBase *seqbasep, bool for_render);
-struct Sequence *BKE_sequence_dupli_recursive(struct Scene *scene, struct Scene *scene_to, struct Sequence *seq, int dupe_flag);
+struct Sequence *BKE_sequence_dupli_recursive(
+ const struct Scene *scene_src, struct Scene *scene_dst, struct Sequence *seq, int dupe_flag);
int BKE_sequence_swap(struct Sequence *seq_a, struct Sequence *seq_b, const char **error_str);
bool BKE_sequence_check_depend(struct Sequence *seq, struct Sequence *cur);
@@ -352,8 +353,8 @@ void BKE_sequencer_refresh_sound_length(struct Scene *scene);
void BKE_sequence_base_unique_name_recursive(ListBase *seqbasep, struct Sequence *seq);
void BKE_sequence_base_dupli_recursive(
- struct Scene *scene, struct Scene *scene_to, ListBase *nseqbase, ListBase *seqbase,
- int dupe_flag);
+ const struct Scene *scene_src, struct Scene *scene_dst, struct ListBase *nseqbase, const struct ListBase *seqbase,
+ int dupe_flag, const int flag);
bool BKE_sequence_is_valid_check(struct Sequence *seq);
void BKE_sequencer_clear_scene_in_allseqs(struct Main *bmain, struct Scene *sce);
@@ -421,7 +422,7 @@ struct Sequence *BKE_sequencer_add_movie_strip(struct bContext *C, ListBase *seq
/* view3d draw callback, run when not in background view */
typedef struct ImBuf *(*SequencerDrawView)(
- struct Scene *, struct SceneLayer *sl, struct Object *, int, int,
+ const struct EvaluationContext *eval_ctx, struct Scene *, struct SceneLayer *sl, struct Object *, int, int,
unsigned int, int, bool, bool, bool,
int, int, bool, const char *,
struct GPUFX *, struct GPUOffScreen *, char[256]);
diff --git a/source/blender/blenkernel/BKE_smoke.h b/source/blender/blenkernel/BKE_smoke.h
index 33d7acdd864..64d70e8e209 100644
--- a/source/blender/blenkernel/BKE_smoke.h
+++ b/source/blender/blenkernel/BKE_smoke.h
@@ -35,7 +35,9 @@
typedef float (*bresenham_callback)(float *result, float *input, int res[3], int *pixel, float *tRay, float correct);
-struct DerivedMesh *smokeModifier_do(struct SmokeModifierData *smd, struct Scene *scene, struct SceneLayer *sl, struct Object *ob, struct DerivedMesh *dm);
+struct DerivedMesh *smokeModifier_do(struct SmokeModifierData *smd, const struct EvaluationContext *eval_ctx,
+ struct Scene *scene,
+ struct Object *ob, struct DerivedMesh *dm);
void smoke_reallocate_fluid(struct SmokeDomainSettings *sds, float dx, int res[3], int free_old);
void smoke_reallocate_highres_fluid(struct SmokeDomainSettings *sds, float dx, int res[3], int free_old);
diff --git a/source/blender/blenkernel/BKE_softbody.h b/source/blender/blenkernel/BKE_softbody.h
index 75c5faf4088..e2255bdb779 100644
--- a/source/blender/blenkernel/BKE_softbody.h
+++ b/source/blender/blenkernel/BKE_softbody.h
@@ -34,6 +34,7 @@
struct Object;
struct Scene;
struct SoftBody;
+struct EvaluationContext;
typedef struct BodyPoint {
float origS[3], origE[3], origT[3], pos[3], vec[3], force[3];
@@ -59,7 +60,7 @@ extern void sbFree(struct SoftBody *sb);
extern void sbFreeSimulation(struct SoftBody *sb);
/* do one simul step, reading and writing vertex locs from given array */
-extern void sbObjectStep(struct Scene *scene, struct SceneLayer *sl, struct Object *ob,
+extern void sbObjectStep(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
float framnr, float (*vertexCos)[3], int numVerts);
/* makes totally fresh start situation, resets time */
diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h
index a5c626e74d7..98fb4f47339 100644
--- a/source/blender/blenkernel/BKE_sound.h
+++ b/source/blender/blenkernel/BKE_sound.h
@@ -35,8 +35,8 @@
#define SOUND_WAVE_SAMPLES_PER_SECOND 250
-#ifdef WITH_SYSTEM_AUDASPACE
-# include AUD_DEVICE_H
+#if defined(WITH_AUDASPACE)
+# include <AUD_Device.h>
#endif
struct bSound;
@@ -80,9 +80,11 @@ void BKE_sound_load(struct Main *main, struct bSound *sound);
void BKE_sound_free(struct bSound *sound);
+void BKE_sound_copy_data(struct Main *bmain, struct bSound *sound_dst, const struct bSound *sound_src, const int flag);
+
void BKE_sound_make_local(struct Main *bmain, struct bSound *sound, const bool lib_local);
-#if defined(__AUD_C_API_H__) || defined(WITH_SYSTEM_AUDASPACE)
+#if defined(WITH_AUDASPACE)
AUD_Device *BKE_sound_mixdown(struct Scene *scene, AUD_DeviceSpecs specs, int start, float volume);
#endif
@@ -147,6 +149,4 @@ float BKE_sound_get_length(struct bSound *sound);
char **BKE_sound_get_device_names(void);
-bool BKE_sound_is_jack_supported(void);
-
#endif /* __BKE_SOUND_H__ */
diff --git a/source/blender/blenkernel/BKE_speaker.h b/source/blender/blenkernel/BKE_speaker.h
index 907558f9203..57f4c37f129 100644
--- a/source/blender/blenkernel/BKE_speaker.h
+++ b/source/blender/blenkernel/BKE_speaker.h
@@ -33,6 +33,7 @@ struct Speaker;
void BKE_speaker_init(struct Speaker *spk);
void *BKE_speaker_add(struct Main *bmain, const char *name);
+void BKE_speaker_copy_data(struct Main *bmain, struct Speaker *spk_dst, const struct Speaker *spk_src, const int flag);
struct Speaker *BKE_speaker_copy(struct Main *bmain, const struct Speaker *spk);
void BKE_speaker_make_local(struct Main *bmain, struct Speaker *spk, const bool lib_local);
void BKE_speaker_free(struct Speaker *spk);
diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h
index c8fb483cdf2..14d3318e059 100644
--- a/source/blender/blenkernel/BKE_text.h
+++ b/source/blender/blenkernel/BKE_text.h
@@ -52,6 +52,7 @@ bool BKE_text_reload(struct Text *text);
struct Text *BKE_text_load_ex(struct Main *bmain, const char *file, const char *relpath,
const bool is_internal);
struct Text *BKE_text_load (struct Main *bmain, const char *file, const char *relpath);
+void BKE_text_copy_data(struct Main *bmain, struct Text *ta_dst, const struct Text *ta_src, const int flag);
struct Text *BKE_text_copy (struct Main *bmain, const struct Text *ta);
void BKE_text_make_local (struct Main *bmain, struct Text *text, const bool lib_local);
void BKE_text_clear (struct Text *text);
diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h
index 190fdeafaec..8a9171673ea 100644
--- a/source/blender/blenkernel/BKE_texture.h
+++ b/source/blender/blenkernel/BKE_texture.h
@@ -70,6 +70,7 @@ void colorband_update_sort(struct ColorBand *coba);
void BKE_texture_free(struct Tex *tex);
void BKE_texture_default(struct Tex *tex);
+void BKE_texture_copy_data(struct Main *bmain, struct Tex *tex_dst, const struct Tex *tex_src, const int flag);
struct Tex *BKE_texture_copy(struct Main *bmain, const struct Tex *tex);
struct Tex *BKE_texture_add(struct Main *bmain, const char *name);
struct Tex *BKE_texture_localize(struct Tex *tex);
@@ -114,13 +115,13 @@ void BKE_texture_colormapping_default(struct ColorMapping *color
void BKE_texture_envmap_free_data(struct EnvMap *env);
void BKE_texture_envmap_free(struct EnvMap *env);
struct EnvMap *BKE_texture_envmap_add(void);
-struct EnvMap *BKE_texture_envmap_copy(const struct EnvMap *env);
+struct EnvMap *BKE_texture_envmap_copy(const struct EnvMap *env, const int flag);
void BKE_texture_pointdensity_init_data(struct PointDensity *pd);
void BKE_texture_pointdensity_free_data(struct PointDensity *pd);
void BKE_texture_pointdensity_free(struct PointDensity *pd);
struct PointDensity *BKE_texture_pointdensity_add(void);
-struct PointDensity *BKE_texture_pointdensity_copy(const struct PointDensity *pd);
+struct PointDensity *BKE_texture_pointdensity_copy(const struct PointDensity *pd, const int flag);
void BKE_texture_voxeldata_free_data(struct VoxelData *vd);
void BKE_texture_voxeldata_free(struct VoxelData *vd);
@@ -129,7 +130,7 @@ struct VoxelData *BKE_texture_voxeldata_copy(struct VoxelData *vd);
void BKE_texture_ocean_free(struct OceanTex *ot);
struct OceanTex *BKE_texture_ocean_add(void);
-struct OceanTex *BKE_texture_ocean_copy(const struct OceanTex *ot);
+struct OceanTex *BKE_texture_ocean_copy(const struct OceanTex *ot, const int flag);
bool BKE_texture_dependsOnTime(const struct Tex *texture);
bool BKE_texture_is_image_user(const struct Tex *tex);
diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h
index b48be382073..b4ca1b79238 100644
--- a/source/blender/blenkernel/BKE_tracking.h
+++ b/source/blender/blenkernel/BKE_tracking.h
@@ -47,12 +47,13 @@ struct MovieDistortion;
struct Camera;
struct Object;
struct Scene;
+struct EvaluationContext;
struct rcti;
/* **** Common functions **** */
void BKE_tracking_free(struct MovieTracking *tracking);
-void BKE_tracking_copy(struct MovieTracking *tracking_dst, const struct MovieTracking *tracking_src);
+void BKE_tracking_copy(struct MovieTracking *tracking_dst, const struct MovieTracking *tracking_src, const int flag);
void BKE_tracking_settings_init(struct MovieTracking *tracking);
diff --git a/source/blender/blenkernel/BKE_world.h b/source/blender/blenkernel/BKE_world.h
index 18ae61f7653..ea0cd125b06 100644
--- a/source/blender/blenkernel/BKE_world.h
+++ b/source/blender/blenkernel/BKE_world.h
@@ -39,9 +39,16 @@ struct World;
void BKE_world_free(struct World *sc);
void BKE_world_init(struct World *wrld);
struct World *add_world(struct Main *bmian, const char *name);
+void BKE_world_copy_data(struct Main *bmain, struct World *wrld_dst, const struct World *wrld_src, const int flag);
struct World *BKE_world_copy(struct Main *bmain, const struct World *wrld);
struct World *localize_world(struct World *wrld);
void BKE_world_make_local(struct Main *bmain, struct World *wrld, const bool lib_local);
+/* Evaluation. */
+
+struct EvaluationContext;
+
+void BKE_world_eval(const struct EvaluationContext *eval_ctx, struct World *world);
+
#endif
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 1d4565f1ec6..dad862b87e7 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -333,7 +333,7 @@ if(WIN32)
endif()
if(WITH_AUDASPACE)
- add_definitions(${AUDASPACE_DEFINITIONS})
+ add_definitions(-DWITH_AUDASPACE)
list(APPEND INC_SYS
${AUDASPACE_C_INCLUDE_DIRS}
@@ -397,16 +397,6 @@ if(WITH_CODEC_AVI)
add_definitions(-DWITH_AVI)
endif()
-if(WITH_CODEC_QUICKTIME)
- list(APPEND INC
- ../quicktime
- )
- list(APPEND INC_SYS
- ${QUICKTIME_INCLUDE_DIRS}
- )
- add_definitions(-DWITH_QUICKTIME)
-endif()
-
if(WITH_CODEC_FFMPEG)
list(APPEND SRC
intern/writeffmpeg.c
@@ -431,6 +421,10 @@ if(WITH_PYTHON)
)
add_definitions(-DWITH_PYTHON)
+ if(WITH_PYTHON_SAFETY)
+ add_definitions(-DWITH_PYTHON_SAFETY)
+ endif()
+
if(WITH_PYTHON_SECURITY)
add_definitions(-DWITH_PYTHON_SECURITY)
endif()
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 55d5f6f89a1..18db368ee2b 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -96,6 +96,10 @@ static DerivedMesh *navmesh_dm_createNavMeshForVisualization(DerivedMesh *dm);
# define ASSERT_IS_VALID_DM(dm)
#endif
+
+static ThreadRWMutex loops_cache_lock = PTHREAD_RWLOCK_INITIALIZER;
+
+
static void add_shapekey_layers(DerivedMesh *dm, Mesh *me, Object *ob);
static void shapekey_layers_to_keyblocks(DerivedMesh *dm, Mesh *me, int actshape_uid);
@@ -238,6 +242,30 @@ static int dm_getNumLoopTri(DerivedMesh *dm)
return numlooptris;
}
+static const MLoopTri *dm_getLoopTriArray(DerivedMesh *dm)
+{
+ MLoopTri *looptri;
+
+ BLI_rw_mutex_lock(&loops_cache_lock, THREAD_LOCK_READ);
+ looptri = dm->looptris.array;
+ BLI_rw_mutex_unlock(&loops_cache_lock);
+
+ if (looptri != NULL) {
+ BLI_assert(dm->getNumLoopTri(dm) == dm->looptris.num);
+ }
+ else {
+ BLI_rw_mutex_lock(&loops_cache_lock, THREAD_LOCK_WRITE);
+ /* We need to ensure array is still NULL inside mutex-protected code, some other thread might have already
+ * recomputed those looptris. */
+ if (dm->looptris.array == NULL) {
+ dm->recalcLoopTri(dm);
+ }
+ looptri = dm->looptris.array;
+ BLI_rw_mutex_unlock(&loops_cache_lock);
+ }
+ return looptri;
+}
+
static CustomData *dm_getVertCData(DerivedMesh *dm)
{
return &dm->vertData;
@@ -281,6 +309,8 @@ void DM_init_funcs(DerivedMesh *dm)
dm->dupLoopArray = dm_dupLoopArray;
dm->dupPolyArray = dm_dupPolyArray;
+ dm->getLoopTriArray = dm_getLoopTriArray;
+
/* subtypes handle getting actual data */
dm->getNumLoopTri = dm_getNumLoopTri;
@@ -475,6 +505,8 @@ void DM_ensure_tessface(DerivedMesh *dm)
/**
* Ensure the array is large enough
+ *
+ * /note This function must always be thread-protected by caller. It should only be used by internal code.
*/
void DM_ensure_looptri_data(DerivedMesh *dm)
{
@@ -482,18 +514,22 @@ void DM_ensure_looptri_data(DerivedMesh *dm)
const unsigned int totloop = dm->numLoopData;
const int looptris_num = poly_to_tri_count(totpoly, totloop);
+ BLI_assert(dm->looptris.array_wip == NULL);
+
+ SWAP(MLoopTri *, dm->looptris.array, dm->looptris.array_wip);
+
if ((looptris_num > dm->looptris.num_alloc) ||
(looptris_num < dm->looptris.num_alloc * 2) ||
(totpoly == 0))
{
- MEM_SAFE_FREE(dm->looptris.array);
+ MEM_SAFE_FREE(dm->looptris.array_wip);
dm->looptris.num_alloc = 0;
dm->looptris.num = 0;
}
if (totpoly) {
- if (dm->looptris.array == NULL) {
- dm->looptris.array = MEM_mallocN(sizeof(*dm->looptris.array) * looptris_num, __func__);
+ if (dm->looptris.array_wip == NULL) {
+ dm->looptris.array_wip = MEM_mallocN(sizeof(*dm->looptris.array_wip) * looptris_num, __func__);
dm->looptris.num_alloc = looptris_num;
}
@@ -501,19 +537,6 @@ void DM_ensure_looptri_data(DerivedMesh *dm)
}
}
-/**
- * The purpose of this function is that we can call:
- * `dm->getLoopTriArray(dm)` and get the array returned.
- */
-void DM_ensure_looptri(DerivedMesh *dm)
-{
- const int numPolys = dm->getNumPolys(dm);
-
- if ((dm->looptris.num == 0) && (numPolys != 0)) {
- dm->recalcLoopTri(dm);
- }
-}
-
void DM_verttri_from_looptri(MVertTri *verttri, const MLoop *mloop, const MLoopTri *looptri, int looptri_num)
{
int i;
@@ -1126,7 +1149,7 @@ DerivedMesh *mesh_create_derived(Mesh *me, float (*vertCos)[3])
}
DerivedMesh *mesh_create_derived_for_modifier(
- Scene *scene, Object *ob,
+ const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob,
ModifierData *md, int build_shapekey_layers)
{
Mesh *me = ob->data;
@@ -1152,7 +1175,7 @@ DerivedMesh *mesh_create_derived_for_modifier(
int numVerts;
float (*deformedVerts)[3] = BKE_mesh_vertexCos_get(me, &numVerts);
- modwrap_deformVerts(md, ob, NULL, deformedVerts, numVerts, 0);
+ modwrap_deformVerts(md, eval_ctx, ob, NULL, deformedVerts, numVerts, 0);
dm = mesh_create_derived(me, deformedVerts);
if (build_shapekey_layers)
@@ -1166,7 +1189,7 @@ DerivedMesh *mesh_create_derived_for_modifier(
if (build_shapekey_layers)
add_shapekey_layers(tdm, me, ob);
- dm = modwrap_applyModifier(md, ob, tdm, 0);
+ dm = modwrap_applyModifier(md, eval_ctx, ob, tdm, 0);
ASSERT_IS_VALID_DM(dm);
if (tdm != dm) tdm->release(tdm);
@@ -1732,7 +1755,7 @@ static void dm_ensure_display_normals(DerivedMesh *dm)
* - apply deform modifiers and input vertexco
*/
static void mesh_calc_modifiers(
- Scene *scene, Object *ob, float (*inputVertexCos)[3],
+ const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float (*inputVertexCos)[3],
const bool useRenderParams, int useDeform,
const bool need_mapping, CustomDataMask dataMask,
const int index, const bool useCache, const bool build_shapekey_layers,
@@ -1843,7 +1866,7 @@ static void mesh_calc_modifiers(
if (!deformedVerts)
deformedVerts = BKE_mesh_vertexCos_get(me, &numVerts);
- modwrap_deformVerts(md, ob, NULL, deformedVerts, numVerts, deform_app_flags);
+ modwrap_deformVerts(md, eval_ctx, ob, NULL, deformedVerts, numVerts, deform_app_flags);
}
else {
break;
@@ -1984,7 +2007,7 @@ static void mesh_calc_modifiers(
}
}
- modwrap_deformVerts(md, ob, dm, deformedVerts, numVerts, deform_app_flags);
+ modwrap_deformVerts(md, eval_ctx, ob, dm, deformedVerts, numVerts, deform_app_flags);
}
else {
DerivedMesh *ndm;
@@ -2059,7 +2082,7 @@ static void mesh_calc_modifiers(
}
}
- ndm = modwrap_applyModifier(md, ob, dm, app_flags);
+ ndm = modwrap_applyModifier(md, eval_ctx, ob, dm, app_flags);
ASSERT_IS_VALID_DM(ndm);
if (ndm) {
@@ -2086,7 +2109,7 @@ static void mesh_calc_modifiers(
(mti->requiredDataMask ?
mti->requiredDataMask(ob, md) : 0));
- ndm = modwrap_applyModifier(md, ob, orcodm, (app_flags & ~MOD_APPLY_USECACHE) | MOD_APPLY_ORCO);
+ ndm = modwrap_applyModifier(md, eval_ctx, ob, orcodm, (app_flags & ~MOD_APPLY_USECACHE) | MOD_APPLY_ORCO);
ASSERT_IS_VALID_DM(ndm);
if (ndm) {
@@ -2104,7 +2127,7 @@ static void mesh_calc_modifiers(
nextmask &= ~CD_MASK_CLOTH_ORCO;
DM_set_only_copy(clothorcodm, nextmask | CD_MASK_ORIGINDEX);
- ndm = modwrap_applyModifier(md, ob, clothorcodm, (app_flags & ~MOD_APPLY_USECACHE) | MOD_APPLY_ORCO);
+ ndm = modwrap_applyModifier(md, eval_ctx, ob, clothorcodm, (app_flags & ~MOD_APPLY_USECACHE) | MOD_APPLY_ORCO);
ASSERT_IS_VALID_DM(ndm);
if (ndm) {
@@ -2203,7 +2226,6 @@ static void mesh_calc_modifiers(
if (dataMask & CD_MASK_MFACE) {
DM_ensure_tessface(finaldm);
}
- DM_ensure_looptri(finaldm);
/* without this, drawing ngon tri's faces will show ugly tessellated face
* normals and will also have to calculate normals on the fly, try avoid
@@ -2288,8 +2310,8 @@ bool editbmesh_modifier_is_enabled(Scene *scene, ModifierData *md, DerivedMesh *
}
static void editbmesh_calc_modifiers(
- Scene *scene, Object *ob, BMEditMesh *em,
- CustomDataMask dataMask,
+ const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob,
+ BMEditMesh *em, CustomDataMask dataMask,
/* return args */
DerivedMesh **r_cage, DerivedMesh **r_final)
{
@@ -2376,9 +2398,9 @@ static void editbmesh_calc_modifiers(
}
if (mti->deformVertsEM)
- modwrap_deformVertsEM(md, ob, em, dm, deformedVerts, numVerts);
+ modwrap_deformVertsEM(md, eval_ctx, ob, em, dm, deformedVerts, numVerts);
else
- modwrap_deformVerts(md, ob, dm, deformedVerts, numVerts, 0);
+ modwrap_deformVerts(md, eval_ctx, ob, dm, deformedVerts, numVerts, 0);
}
else {
DerivedMesh *ndm;
@@ -2423,10 +2445,10 @@ static void editbmesh_calc_modifiers(
DM_set_only_copy(orcodm, mask | CD_MASK_ORIGINDEX);
if (mti->applyModifierEM) {
- ndm = modwrap_applyModifierEM(md, ob, em, orcodm, MOD_APPLY_ORCO);
+ ndm = modwrap_applyModifierEM(md, eval_ctx, ob, em, orcodm, MOD_APPLY_ORCO);
}
else {
- ndm = modwrap_applyModifier(md, ob, orcodm, MOD_APPLY_ORCO);
+ ndm = modwrap_applyModifier(md, eval_ctx, ob, orcodm, MOD_APPLY_ORCO);
}
ASSERT_IS_VALID_DM(ndm);
@@ -2451,9 +2473,9 @@ static void editbmesh_calc_modifiers(
}
if (mti->applyModifierEM)
- ndm = modwrap_applyModifierEM(md, ob, em, dm, MOD_APPLY_USECACHE | MOD_APPLY_ALLOW_GPU);
+ ndm = modwrap_applyModifierEM(md, eval_ctx, ob, em, dm, MOD_APPLY_USECACHE | MOD_APPLY_ALLOW_GPU);
else
- ndm = modwrap_applyModifier(md, ob, dm, MOD_APPLY_USECACHE | MOD_APPLY_ALLOW_GPU);
+ ndm = modwrap_applyModifier(md, eval_ctx, ob, dm, MOD_APPLY_USECACHE | MOD_APPLY_ALLOW_GPU);
ASSERT_IS_VALID_DM(ndm);
if (ndm) {
@@ -2605,7 +2627,8 @@ static bool calc_modifiers_skip_orco(Scene *scene,
else if ((ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) != 0) {
return false;
}
- else if ((DEG_get_eval_flags_for_id(scene->depsgraph, &ob->id) & DAG_EVAL_NEED_CPU) != 0) {
+ /* TODO(sergey): How do we get depsgraph here? */
+ else if ((DEG_get_eval_flags_for_id(scene->depsgraph_legacy, &ob->id) & DAG_EVAL_NEED_CPU) != 0) {
return false;
}
SubsurfModifierData *smd = (SubsurfModifierData *)last_md;
@@ -2617,7 +2640,7 @@ static bool calc_modifiers_skip_orco(Scene *scene,
#endif
static void mesh_build_data(
- Scene *scene, Object *ob, CustomDataMask dataMask,
+ const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, CustomDataMask dataMask,
const bool build_shapekey_layers, const bool need_mapping)
{
BLI_assert(ob->type == OB_MESH);
@@ -2632,7 +2655,7 @@ static void mesh_build_data(
#endif
mesh_calc_modifiers(
- scene, ob, NULL, false, 1, need_mapping, dataMask, -1, true, build_shapekey_layers,
+ eval_ctx, scene, ob, NULL, false, 1, need_mapping, dataMask, -1, true, build_shapekey_layers,
true,
&ob->derivedDeform, &ob->derivedFinal);
@@ -2643,17 +2666,19 @@ static void mesh_build_data(
ob->lastDataMask = dataMask;
ob->lastNeedMapping = need_mapping;
- if ((ob->mode & OB_MODE_SCULPT) && ob->sculpt) {
+ if ((ob->mode & OB_MODE_ALL_SCULPT) && ob->sculpt) {
/* create PBVH immediately (would be created on the fly too,
* but this avoids waiting on first stroke) */
- BKE_sculpt_update_mesh_elements(scene, scene->toolsettings->sculpt, ob, false, false);
+ BKE_sculpt_update_mesh_elements(eval_ctx, scene, scene->toolsettings->sculpt, ob, false, false);
}
BLI_assert(!(ob->derivedFinal->dirty & DM_DIRTY_NORMALS));
}
-static void editbmesh_build_data(Scene *scene, Object *obedit, BMEditMesh *em, CustomDataMask dataMask)
+static void editbmesh_build_data(
+ const struct EvaluationContext *eval_ctx, Scene *scene,
+ Object *obedit, BMEditMesh *em, CustomDataMask dataMask)
{
BKE_object_free_derived_caches(obedit);
BKE_object_sculpt_modifiers_changed(obedit);
@@ -2667,7 +2692,7 @@ static void editbmesh_build_data(Scene *scene, Object *obedit, BMEditMesh *em, C
#endif
editbmesh_calc_modifiers(
- scene, obedit, em, dataMask,
+ eval_ctx, scene, obedit, em, dataMask,
&em->derivedCage, &em->derivedFinal);
DM_set_object_boundbox(obedit, em->derivedFinal);
@@ -2682,7 +2707,7 @@ static void editbmesh_build_data(Scene *scene, Object *obedit, BMEditMesh *em, C
static CustomDataMask object_get_datamask(const Scene *scene, Object *ob, bool *r_need_mapping)
{
/* TODO(sergey): Avoid this linear list lookup. */
- SceneLayer *sl = BKE_scene_layer_context_active(scene);
+ SceneLayer *sl = BKE_scene_layer_context_active_PLACEHOLDER(scene);
Object *actob = sl->basact ? sl->basact->object : NULL;
CustomDataMask mask = ob->customdata_mask;
@@ -2720,23 +2745,24 @@ static CustomDataMask object_get_datamask(const Scene *scene, Object *ob, bool *
}
void makeDerivedMesh(
- Scene *scene, Object *ob, BMEditMesh *em,
+ const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, BMEditMesh *em,
CustomDataMask dataMask, const bool build_shapekey_layers)
{
bool need_mapping;
dataMask |= object_get_datamask(scene, ob, &need_mapping);
if (em) {
- editbmesh_build_data(scene, ob, em, dataMask);
+ editbmesh_build_data(eval_ctx, scene, ob, em, dataMask);
}
else {
- mesh_build_data(scene, ob, dataMask, build_shapekey_layers, need_mapping);
+ mesh_build_data(eval_ctx, scene, ob, dataMask, build_shapekey_layers, need_mapping);
}
}
/***/
-DerivedMesh *mesh_get_derived_final(Scene *scene, Object *ob, CustomDataMask dataMask)
+DerivedMesh *mesh_get_derived_final(
+ const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, CustomDataMask dataMask)
{
/* if there's no derived mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh
@@ -2748,14 +2774,14 @@ DerivedMesh *mesh_get_derived_final(Scene *scene, Object *ob, CustomDataMask dat
((dataMask & ob->lastDataMask) != dataMask) ||
(need_mapping != ob->lastNeedMapping))
{
- mesh_build_data(scene, ob, dataMask, false, need_mapping);
+ mesh_build_data(eval_ctx, scene, ob, dataMask, false, need_mapping);
}
if (ob->derivedFinal) { BLI_assert(!(ob->derivedFinal->dirty & DM_DIRTY_NORMALS)); }
return ob->derivedFinal;
}
-DerivedMesh *mesh_get_derived_deform(Scene *scene, Object *ob, CustomDataMask dataMask)
+DerivedMesh *mesh_get_derived_deform(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, CustomDataMask dataMask)
{
/* if there's no derived mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh
@@ -2768,37 +2794,37 @@ DerivedMesh *mesh_get_derived_deform(Scene *scene, Object *ob, CustomDataMask da
((dataMask & ob->lastDataMask) != dataMask) ||
(need_mapping != ob->lastNeedMapping))
{
- mesh_build_data(scene, ob, dataMask, false, need_mapping);
+ mesh_build_data(eval_ctx, scene, ob, dataMask, false, need_mapping);
}
return ob->derivedDeform;
}
-DerivedMesh *mesh_create_derived_render(Scene *scene, Object *ob, CustomDataMask dataMask)
+DerivedMesh *mesh_create_derived_render(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, CustomDataMask dataMask)
{
DerivedMesh *final;
mesh_calc_modifiers(
- scene, ob, NULL, true, 1, false, dataMask, -1, false, false, false,
+ eval_ctx, scene, ob, NULL, true, 1, false, dataMask, -1, false, false, false,
NULL, &final);
return final;
}
-DerivedMesh *mesh_create_derived_index_render(Scene *scene, Object *ob, CustomDataMask dataMask, int index)
+DerivedMesh *mesh_create_derived_index_render(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, CustomDataMask dataMask, int index)
{
DerivedMesh *final;
mesh_calc_modifiers(
- scene, ob, NULL, true, 1, false, dataMask, index, false, false, false,
+ eval_ctx, scene, ob, NULL, true, 1, false, dataMask, index, false, false, false,
NULL, &final);
return final;
}
DerivedMesh *mesh_create_derived_view(
- Scene *scene, Object *ob,
- CustomDataMask dataMask)
+ const struct EvaluationContext *eval_ctx, Scene *scene,
+ Object *ob, CustomDataMask dataMask)
{
DerivedMesh *final;
@@ -2809,7 +2835,7 @@ DerivedMesh *mesh_create_derived_view(
ob->transflag |= OB_NO_PSYS_UPDATE;
mesh_calc_modifiers(
- scene, ob, NULL, false, 1, false, dataMask, -1, false, false, false,
+ eval_ctx, scene, ob, NULL, false, 1, false, dataMask, -1, false, false, false,
NULL, &final);
ob->transflag &= ~OB_NO_PSYS_UPDATE;
@@ -2818,53 +2844,53 @@ DerivedMesh *mesh_create_derived_view(
}
DerivedMesh *mesh_create_derived_no_deform(
- Scene *scene, Object *ob, float (*vertCos)[3],
- CustomDataMask dataMask)
+ const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob,
+ float (*vertCos)[3], CustomDataMask dataMask)
{
DerivedMesh *final;
mesh_calc_modifiers(
- scene, ob, vertCos, false, 0, false, dataMask, -1, false, false, false,
+ eval_ctx, scene, ob, vertCos, false, 0, false, dataMask, -1, false, false, false,
NULL, &final);
return final;
}
DerivedMesh *mesh_create_derived_no_virtual(
- Scene *scene, Object *ob, float (*vertCos)[3],
- CustomDataMask dataMask)
+ const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob,
+ float (*vertCos)[3], CustomDataMask dataMask)
{
DerivedMesh *final;
mesh_calc_modifiers(
- scene, ob, vertCos, false, -1, false, dataMask, -1, false, false, false,
+ eval_ctx, scene, ob, vertCos, false, -1, false, dataMask, -1, false, false, false,
NULL, &final);
return final;
}
DerivedMesh *mesh_create_derived_physics(
- Scene *scene, Object *ob, float (*vertCos)[3],
- CustomDataMask dataMask)
+ const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob,
+ float (*vertCos)[3], CustomDataMask dataMask)
{
DerivedMesh *final;
mesh_calc_modifiers(
- scene, ob, vertCos, false, -1, true, dataMask, -1, false, false, false,
+ eval_ctx, scene, ob, vertCos, false, -1, true, dataMask, -1, false, false, false,
NULL, &final);
return final;
}
DerivedMesh *mesh_create_derived_no_deform_render(
- Scene *scene, Object *ob,
- float (*vertCos)[3],
+ const struct EvaluationContext *eval_ctx, Scene *scene,
+ Object *ob, float (*vertCos)[3],
CustomDataMask dataMask)
{
DerivedMesh *final;
mesh_calc_modifiers(
- scene, ob, vertCos, true, 0, false, dataMask, -1, false, false, false,
+ eval_ctx, scene, ob, vertCos, true, 0, false, dataMask, -1, false, false, false,
NULL, &final);
return final;
@@ -2873,7 +2899,7 @@ DerivedMesh *mesh_create_derived_no_deform_render(
/***/
DerivedMesh *editbmesh_get_derived_cage_and_final(
- Scene *scene, Object *obedit, BMEditMesh *em,
+ const struct EvaluationContext *eval_ctx, Scene *scene, Object *obedit, BMEditMesh *em,
CustomDataMask dataMask,
/* return args */
DerivedMesh **r_final)
@@ -2886,7 +2912,7 @@ DerivedMesh *editbmesh_get_derived_cage_and_final(
if (!em->derivedCage ||
(em->lastDataMask & dataMask) != dataMask)
{
- editbmesh_build_data(scene, obedit, em, dataMask);
+ editbmesh_build_data(eval_ctx, scene, obedit, em, dataMask);
}
*r_final = em->derivedFinal;
@@ -2894,7 +2920,9 @@ DerivedMesh *editbmesh_get_derived_cage_and_final(
return em->derivedCage;
}
-DerivedMesh *editbmesh_get_derived_cage(Scene *scene, Object *obedit, BMEditMesh *em, CustomDataMask dataMask)
+DerivedMesh *editbmesh_get_derived_cage(
+ const struct EvaluationContext *eval_ctx, Scene *scene, Object *obedit, BMEditMesh *em,
+ CustomDataMask dataMask)
{
/* if there's no derived mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh
@@ -2904,7 +2932,7 @@ DerivedMesh *editbmesh_get_derived_cage(Scene *scene, Object *obedit, BMEditMesh
if (!em->derivedCage ||
(em->lastDataMask & dataMask) != dataMask)
{
- editbmesh_build_data(scene, obedit, em, dataMask);
+ editbmesh_build_data(eval_ctx, scene, obedit, em, dataMask);
}
return em->derivedCage;
@@ -3054,14 +3082,23 @@ void DM_calc_tangents_names_from_gpu(
*r_tangent_names_count = count;
}
+void DM_add_named_tangent_layer_for_uv(
+ CustomData *uv_data, CustomData *tan_data, int numLoopData,
+ const char *layer_name)
+{
+ if (CustomData_get_named_layer_index(tan_data, CD_TANGENT, layer_name) == -1 &&
+ CustomData_get_named_layer_index(uv_data, CD_MLOOPUV, layer_name) != -1)
+ {
+ CustomData_add_layer_named(
+ tan_data, CD_TANGENT, CD_CALLOC, NULL,
+ numLoopData, layer_name);
+ }
+}
+
void DM_calc_loop_tangents(
DerivedMesh *dm, bool calc_active_tangent,
const char (*tangent_names)[MAX_NAME], int tangent_names_len)
{
- if (CustomData_number_of_layers(&dm->loopData, CD_MLOOPUV) == 0) {
- return;
- }
-
BKE_mesh_calc_loop_tangent_ex(
dm->getVertArray(dm),
dm->getPolyArray(dm), dm->getNumPolys(dm),
@@ -3941,35 +3978,3 @@ MFace *DM_get_tessface_array(DerivedMesh *dm, bool *r_allocated)
return mface;
}
-
-const MLoopTri *DM_get_looptri_array(
- DerivedMesh *dm,
- const MVert *mvert,
- const MPoly *mpoly, int mpoly_len,
- const MLoop *mloop, int mloop_len,
- bool *r_allocated)
-{
- const MLoopTri *looptri = dm->getLoopTriArray(dm);
- *r_allocated = false;
-
- if (looptri == NULL) {
- if (mpoly_len > 0) {
- const int looptris_num = poly_to_tri_count(mpoly_len, mloop_len);
- MLoopTri *looptri_data;
-
- looptri_data = MEM_mallocN(sizeof(MLoopTri) * looptris_num, __func__);
-
- BKE_mesh_recalc_looptri(
- mloop, mpoly,
- mvert,
- mloop_len, mpoly_len,
- looptri_data);
-
- looptri = looptri_data;
-
- *r_allocated = true;
- }
- }
-
- return looptri;
-}
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index 8a94d4b8666..6f7b3286e40 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -89,7 +89,7 @@ bAction *add_empty_action(Main *bmain, const char name[])
{
bAction *act;
- act = BKE_libblock_alloc(bmain, ID_AC, name);
+ act = BKE_libblock_alloc(bmain, ID_AC, name, 0);
return act;
}
@@ -121,46 +121,56 @@ void BKE_action_free(bAction *act)
/* .................................. */
-bAction *BKE_action_copy(Main *bmain, const bAction *src)
+/**
+ * Only copy internal data of Action ID from source to already allocated/initialized destination.
+ * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
+ *
+ * WARNING! This function will not handle ID user count!
+ *
+ * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
+ */
+void BKE_action_copy_data(Main *UNUSED(bmain), bAction *act_dst, const bAction *act_src, const int UNUSED(flag))
{
- bAction *dst = NULL;
- bActionGroup *dgrp, *sgrp;
- FCurve *dfcu, *sfcu;
-
- if (src == NULL)
- return NULL;
- dst = BKE_libblock_copy(bmain, &src->id);
-
+ bActionGroup *grp_dst, *grp_src;
+ FCurve *fcu_dst, *fcu_src;
+
/* duplicate the lists of groups and markers */
- BLI_duplicatelist(&dst->groups, &src->groups);
- BLI_duplicatelist(&dst->markers, &src->markers);
-
+ BLI_duplicatelist(&act_dst->groups, &act_src->groups);
+ BLI_duplicatelist(&act_dst->markers, &act_src->markers);
+
/* copy F-Curves, fixing up the links as we go */
- BLI_listbase_clear(&dst->curves);
-
- for (sfcu = src->curves.first; sfcu; sfcu = sfcu->next) {
+ BLI_listbase_clear(&act_dst->curves);
+
+ for (fcu_src = act_src->curves.first; fcu_src; fcu_src = fcu_src->next) {
/* duplicate F-Curve */
- dfcu = copy_fcurve(sfcu);
- BLI_addtail(&dst->curves, dfcu);
-
+ fcu_dst = copy_fcurve(fcu_src); /* XXX TODO pass subdata flag? But surprisingly does not seem to be doing any ID refcounting... */
+ BLI_addtail(&act_dst->curves, fcu_dst);
+
/* fix group links (kindof bad list-in-list search, but this is the most reliable way) */
- for (dgrp = dst->groups.first, sgrp = src->groups.first; dgrp && sgrp; dgrp = dgrp->next, sgrp = sgrp->next) {
- if (sfcu->grp == sgrp) {
- dfcu->grp = dgrp;
-
- if (dgrp->channels.first == sfcu)
- dgrp->channels.first = dfcu;
- if (dgrp->channels.last == sfcu)
- dgrp->channels.last = dfcu;
-
+ for (grp_dst = act_dst->groups.first, grp_src = act_src->groups.first;
+ grp_dst && grp_src;
+ grp_dst = grp_dst->next, grp_src = grp_src->next)
+ {
+ if (fcu_src->grp == grp_src) {
+ fcu_dst->grp = grp_dst;
+
+ if (grp_dst->channels.first == fcu_src) {
+ grp_dst->channels.first = fcu_dst;
+ }
+ if (grp_dst->channels.last == fcu_src) {
+ grp_dst->channels.last = fcu_dst;
+ }
break;
}
}
}
-
- BKE_id_copy_ensure_local(bmain, &src->id, &dst->id);
+}
- return dst;
+bAction *BKE_action_copy(Main *bmain, const bAction *act_src)
+{
+ bAction *act_copy;
+ BKE_id_copy_ex(bmain, &act_src->id, (ID **)&act_copy, 0, false);
+ return act_copy;
}
/* *************** Action Groups *************** */
@@ -524,7 +534,7 @@ const char *BKE_pose_ikparam_get_name(bPose *pose)
*
* \param dst Should be freed already, makes entire duplicate.
*/
-void BKE_pose_copy_data(bPose **dst, const bPose *src, const bool copy_constraints)
+void BKE_pose_copy_data_ex(bPose **dst, const bPose *src, const int flag, const bool copy_constraints)
{
bPose *outPose;
bPoseChannel *pchan;
@@ -554,9 +564,8 @@ void BKE_pose_copy_data(bPose **dst, const bPose *src, const bool copy_constrain
outPose->avs = src->avs;
for (pchan = outPose->chanbase.first; pchan; pchan = pchan->next) {
-
- if (pchan->custom) {
- id_us_plus(&pchan->custom->id);
+ if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
+ id_us_plus((ID *)pchan->custom);
}
/* warning, O(n2) here, if done without the hash, but these are rarely used features. */
@@ -571,13 +580,13 @@ void BKE_pose_copy_data(bPose **dst, const bPose *src, const bool copy_constrain
}
if (copy_constraints) {
- BKE_constraints_copy(&listb, &pchan->constraints, true); // BKE_constraints_copy NULLs listb
+ BKE_constraints_copy_ex(&listb, &pchan->constraints, flag, true); // BKE_constraints_copy NULLs listb
pchan->constraints = listb;
pchan->mpath = NULL; /* motion paths should not get copied yet... */
}
if (pchan->prop) {
- pchan->prop = IDP_CopyProperty(pchan->prop);
+ pchan->prop = IDP_CopyProperty_ex(pchan->prop, flag);
}
pchan->draw_data = NULL; /* Drawing cache, no need to copy. */
@@ -591,6 +600,11 @@ void BKE_pose_copy_data(bPose **dst, const bPose *src, const bool copy_constrain
*dst = outPose;
}
+void BKE_pose_copy_data(bPose **dst, const bPose *src, const bool copy_constraints)
+{
+ BKE_pose_copy_data_ex(dst, src, 0, copy_constraints);
+}
+
void BKE_pose_itasc_init(bItasc *itasc)
{
if (itasc) {
@@ -1121,9 +1135,13 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_
if (fcu->totvert) {
float nmin, nmax;
- /* get extents for this curve */
- /* TODO: allow enabling/disabling this? */
- calc_fcurve_range(fcu, &nmin, &nmax, false, true);
+ /* get extents for this curve
+ * - no "selected only", since this is often used in the backend
+ * - no "minimum length" (we will apply this later), otherwise
+ * single-keyframe curves will increase the overall length by
+ * a phantom frame (T50354)
+ */
+ calc_fcurve_range(fcu, &nmin, &nmax, false, false);
/* compare to the running tally */
min = min_ff(min, nmin);
@@ -1176,7 +1194,9 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_
}
if (foundvert || foundmod) {
+ /* ensure that action is at least 1 frame long (for NLA strips to have a valid length) */
if (min == max) max += 1.0f;
+
*start = min;
*end = max;
}
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index 59484724aee..34ab8a064d4 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -43,6 +43,7 @@
#include "DNA_key_types.h"
#include "DNA_scene_types.h"
+#include "BKE_context.h"
#include "BKE_curve.h"
#include "BKE_global.h"
#include "BKE_key.h"
@@ -282,10 +283,11 @@ void animviz_get_object_motionpaths(Object *ob, ListBase *targets)
*/
/* tweak the object ordering to trick depsgraph into making MotionPath calculations run faster */
-static void motionpaths_calc_optimise_depsgraph(Scene *scene, ListBase *targets)
+static void motionpaths_calc_optimise_depsgraph(bContext *C, Scene *scene, ListBase *targets)
{
BaseLegacy *base, *baseNext;
MPathTarget *mpt;
+ Main *bmain = CTX_data_main(C);
/* make sure our temp-tag isn't already in use */
for (base = scene->base.first; base; base = base->next)
@@ -309,7 +311,7 @@ static void motionpaths_calc_optimise_depsgraph(Scene *scene, ListBase *targets)
}
/* "brew me a list that's sorted a bit faster now depsy" */
- DEG_scene_relations_rebuild(G.main, scene);
+ DEG_scene_relations_rebuild(bmain, scene);
}
/* update scene for current frame */
@@ -373,7 +375,7 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets)
* - recalc: whether we need to
*/
/* TODO: include reports pointer? */
-void animviz_calc_motionpaths(Scene *scene, ListBase *targets)
+void animviz_calc_motionpaths(bContext *C, Scene *scene, ListBase *targets)
{
MPathTarget *mpt;
int sfra, efra;
@@ -399,7 +401,7 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets)
/* optimize the depsgraph for faster updates */
/* TODO: whether this is used should depend on some setting for the level of optimizations used */
- motionpaths_calc_optimise_depsgraph(scene, targets);
+ motionpaths_calc_optimise_depsgraph(C, scene, targets);
/* calculate path over requested range */
for (CFRA = sfra; CFRA <= efra; CFRA++) {
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 6475e5c8acd..5b7947df9dd 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -261,7 +261,7 @@ void BKE_animdata_free(ID *id, const bool do_id_user)
/* Copying -------------------------------------------- */
/* Make a copy of the given AnimData - to be used when copying datablocks */
-AnimData *BKE_animdata_copy(AnimData *adt, const bool do_action)
+AnimData *BKE_animdata_copy(Main *bmain, AnimData *adt, const bool do_action)
{
AnimData *dadt;
@@ -272,8 +272,9 @@ AnimData *BKE_animdata_copy(AnimData *adt, const bool do_action)
/* make a copy of action - at worst, user has to delete copies... */
if (do_action) {
- dadt->action = BKE_action_copy(G.main, adt->action);
- dadt->tmpact = BKE_action_copy(G.main, adt->tmpact);
+ BLI_assert(bmain != NULL);
+ BKE_id_copy_ex(bmain, (ID *)dadt->action, (ID **)&dadt->action, 0, false);
+ BKE_id_copy_ex(bmain, (ID *)dadt->tmpact, (ID **)&dadt->tmpact, 0, false);
}
else {
id_us_plus((ID *)dadt->action);
@@ -293,7 +294,7 @@ AnimData *BKE_animdata_copy(AnimData *adt, const bool do_action)
return dadt;
}
-bool BKE_animdata_copy_id(ID *id_to, ID *id_from, const bool do_action)
+bool BKE_animdata_copy_id(Main *bmain, ID *id_to, ID *id_from, const bool do_action)
{
AnimData *adt;
@@ -305,7 +306,7 @@ bool BKE_animdata_copy_id(ID *id_to, ID *id_from, const bool do_action)
adt = BKE_animdata_from_id(id_from);
if (adt) {
IdAdtTemplate *iat = (IdAdtTemplate *)id_to;
- iat->adt = BKE_animdata_copy(adt, do_action);
+ iat->adt = BKE_animdata_copy(bmain, adt, do_action);
}
return true;
@@ -625,6 +626,8 @@ char *BKE_animdata_driver_path_hack(bContext *C, PointerRNA *ptr, PropertyRNA *p
}
break;
}
+ default:
+ break;
}
/* fix RNA pointer, as we've now changed the ID root by changing the paths */
@@ -1349,7 +1352,7 @@ void BKE_keyingset_free_path(KeyingSet *ks, KS_Path *ksp)
}
/* Copy all KeyingSets in the given list */
-void BKE_keyingsets_copy(ListBase *newlist, ListBase *list)
+void BKE_keyingsets_copy(ListBase *newlist, const ListBase *list)
{
KeyingSet *ksn;
KS_Path *kspn;
@@ -1521,7 +1524,8 @@ static bool animsys_write_rna_setting(PathResolvedRNA *anim_rna, const float val
}
case PROP_INT:
{
- const int value_coerce = (int)value;
+ int value_coerce = (int)value;
+ RNA_property_int_clamp(ptr, prop, &value_coerce);
if (array_index != -1) {
if (RNA_property_int_get_index(ptr, prop, array_index) != value_coerce) {
RNA_property_int_set_index(ptr, prop, array_index, value_coerce);
@@ -1538,15 +1542,17 @@ static bool animsys_write_rna_setting(PathResolvedRNA *anim_rna, const float val
}
case PROP_FLOAT:
{
+ float value_coerce = value;
+ RNA_property_float_clamp(ptr, prop, &value_coerce);
if (array_index != -1) {
- if (RNA_property_float_get_index(ptr, prop, array_index) != value) {
- RNA_property_float_set_index(ptr, prop, array_index, value);
+ if (RNA_property_float_get_index(ptr, prop, array_index) != value_coerce) {
+ RNA_property_float_set_index(ptr, prop, array_index, value_coerce);
written = true;
}
}
else {
- if (RNA_property_float_get(ptr, prop) != value) {
- RNA_property_float_set(ptr, prop, value);
+ if (RNA_property_float_get(ptr, prop) != value_coerce) {
+ RNA_property_float_set(ptr, prop, value_coerce);
written = true;
}
}
@@ -2846,7 +2852,7 @@ void BKE_animsys_evaluate_all_animation(Main *main, Scene *scene, float ctime)
#define DEBUG_PRINT if (G.debug & G_DEBUG_DEPSGRAPH) printf
-void BKE_animsys_eval_animdata(EvaluationContext *eval_ctx, ID *id)
+void BKE_animsys_eval_animdata(const EvaluationContext *eval_ctx, ID *id)
{
AnimData *adt = BKE_animdata_from_id(id);
Scene *scene = NULL; /* XXX: this is only needed for flushing RNA updates,
@@ -2856,7 +2862,7 @@ void BKE_animsys_eval_animdata(EvaluationContext *eval_ctx, ID *id)
BKE_animsys_evaluate_animdata(scene, id, adt, eval_ctx->ctime, ADT_RECALC_ANIM);
}
-void BKE_animsys_eval_driver(EvaluationContext *eval_ctx,
+void BKE_animsys_eval_driver(const EvaluationContext *eval_ctx,
ID *id,
FCurve *fcu)
{
diff --git a/source/blender/blenkernel/intern/appdir.c b/source/blender/blenkernel/intern/appdir.c
index 43fd47981b1..6dd852c7875 100644
--- a/source/blender/blenkernel/intern/appdir.c
+++ b/source/blender/blenkernel/intern/appdir.c
@@ -106,7 +106,8 @@ const char *BKE_appdir_folder_default(void)
static char *blender_version_decimal(const int ver)
{
static char version_str[5];
- sprintf(version_str, "%d.%02d", ver / 100, ver % 100);
+ BLI_assert(ver < 1000);
+ BLI_snprintf(version_str, sizeof(version_str), "%d.%02d", ver / 100, ver % 100);
return version_str;
}
@@ -212,8 +213,10 @@ static bool get_path_local(
/* try EXECUTABLE_DIR/2.5x/folder_name - new default directory for local blender installed files */
#ifdef __APPLE__
/* due new codesign situation in OSX > 10.9.5 we must move the blender_version dir with contents to Resources */
- static char osx_resourses[FILE_MAX];
- sprintf(osx_resourses, "%s../Resources", bprogdir);
+ char osx_resourses[FILE_MAX];
+ BLI_snprintf(osx_resourses, sizeof(osx_resourses), "%s../Resources", bprogdir);
+ /* Remove the '/../' added above. */
+ BLI_cleanup_path(NULL, osx_resourses);
return test_path(targetpath, targetpath_len, osx_resourses, blender_version_decimal(ver), relfolder);
#else
return test_path(targetpath, targetpath_len, bprogdir, blender_version_decimal(ver), relfolder);
@@ -326,10 +329,12 @@ static bool get_path_system(
return true;
}
}
-
/* try EXECUTABLE_DIR/release/folder_name */
- if (test_path(targetpath, targetpath_len, bprogdir, "release", relfolder))
+ if (test_path(targetpath, targetpath_len, bprogdir, "release", relfolder)) {
return true;
+ }
+ /* never use if not existing. */
+ targetpath[0] = '\0';
/* end developer overrides */
@@ -591,6 +596,9 @@ static void where_am_i(char *fullname, const size_t maxlen, const char *name)
else {
BLI_path_program_search(fullname, maxlen, name);
}
+ /* Remove "/./" and "/../" so string comparisons can be used on the path. */
+ BLI_cleanup_path(NULL, fullname);
+
#if defined(DEBUG)
if (!STREQ(name, fullname)) {
printf("guessing '%s' == '%s'\n", name, fullname);
@@ -683,13 +691,16 @@ bool BKE_appdir_program_python_search(
return is_found;
}
+/** Keep in sync with `bpy.utils.app_template_paths()` */
static const char *app_template_directory_search[2] = {
"startup" SEP_STR "bl_app_templates_user",
"startup" SEP_STR "bl_app_templates_system",
};
static const int app_template_directory_id[2] = {
+ /* Only 'USER' */
BLENDER_USER_SCRIPTS,
+ /* Covers 'LOCAL' & 'SYSTEM'. */
BLENDER_SYSTEM_SCRIPTS,
};
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 38b98f1eee6..7dfc4df114c 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -82,7 +82,7 @@ bArmature *BKE_armature_add(Main *bmain, const char *name)
{
bArmature *arm;
- arm = BKE_libblock_alloc(bmain, ID_AR, name);
+ arm = BKE_libblock_alloc(bmain, ID_AR, name, 0);
arm->deformflag = ARM_DEF_VGROUP | ARM_DEF_ENVELOPE;
arm->flag = ARM_COL_CUSTOM; /* custom bone-group colors */
arm->layer = 1;
@@ -149,54 +149,70 @@ void BKE_armature_make_local(Main *bmain, bArmature *arm, const bool lib_local)
BKE_id_make_local_generic(bmain, &arm->id, true, lib_local);
}
-static void copy_bonechildren(Bone *newBone, const Bone *oldBone, const Bone *actBone, Bone **newActBone)
+static void copy_bonechildren(
+ Bone *bone_dst, const Bone *bone_src, const Bone *bone_src_act, Bone **r_bone_dst_act, const int flag)
{
- Bone *curBone, *newChildBone;
+ Bone *bone_src_child, *bone_dst_child;
- if (oldBone == actBone)
- *newActBone = newBone;
+ if (bone_src == bone_src_act) {
+ *r_bone_dst_act = bone_dst;
+ }
- if (oldBone->prop)
- newBone->prop = IDP_CopyProperty(oldBone->prop);
+ if (bone_src->prop) {
+ bone_dst->prop = IDP_CopyProperty_ex(bone_src->prop, flag);
+ }
/* Copy this bone's list */
- BLI_duplicatelist(&newBone->childbase, &oldBone->childbase);
+ BLI_duplicatelist(&bone_dst->childbase, &bone_src->childbase);
/* For each child in the list, update it's children */
- newChildBone = newBone->childbase.first;
- for (curBone = oldBone->childbase.first; curBone; curBone = curBone->next) {
- newChildBone->parent = newBone;
- copy_bonechildren(newChildBone, curBone, actBone, newActBone);
- newChildBone = newChildBone->next;
+ for (bone_src_child = bone_src->childbase.first, bone_dst_child = bone_dst->childbase.first;
+ bone_src_child;
+ bone_src_child = bone_src_child->next, bone_dst_child = bone_dst_child->next)
+ {
+ bone_dst_child->parent = bone_dst;
+ copy_bonechildren(bone_dst_child, bone_src_child, bone_src_act, r_bone_dst_act, flag);
}
}
-bArmature *BKE_armature_copy(Main *bmain, const bArmature *arm)
+/**
+ * Only copy internal data of Armature ID from source to already allocated/initialized destination.
+ * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
+ *
+ * WARNING! This function will not handle ID user count!
+ *
+ * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
+ */
+void BKE_armature_copy_data(Main *UNUSED(bmain), bArmature *arm_dst, const bArmature *arm_src, const int flag)
{
- bArmature *newArm;
- Bone *oldBone, *newBone;
- Bone *newActBone = NULL;
+ Bone *bone_src, *bone_dst;
+ Bone *bone_dst_act = NULL;
+
+ /* We never handle usercount here for own data. */
+ const int flag_subdata = flag | LIB_ID_CREATE_NO_USER_REFCOUNT;
- newArm = BKE_libblock_copy(bmain, &arm->id);
- BLI_duplicatelist(&newArm->bonebase, &arm->bonebase);
+ BLI_duplicatelist(&arm_dst->bonebase, &arm_src->bonebase);
/* Duplicate the childrens' lists */
- newBone = newArm->bonebase.first;
- for (oldBone = arm->bonebase.first; oldBone; oldBone = oldBone->next) {
- newBone->parent = NULL;
- copy_bonechildren(newBone, oldBone, arm->act_bone, &newActBone);
- newBone = newBone->next;
+ bone_dst = arm_dst->bonebase.first;
+ for (bone_src = arm_src->bonebase.first; bone_src; bone_src = bone_src->next) {
+ bone_dst->parent = NULL;
+ copy_bonechildren(bone_dst, bone_src, arm_src->act_bone, &bone_dst_act, flag_subdata);
+ bone_dst = bone_dst->next;
}
- newArm->act_bone = newActBone;
-
- newArm->edbo = NULL;
- newArm->act_edbone = NULL;
- newArm->sketch = NULL;
+ arm_dst->act_bone = bone_dst_act;
- BKE_id_copy_ensure_local(bmain, &arm->id, &newArm->id);
+ arm_dst->edbo = NULL;
+ arm_dst->act_edbone = NULL;
+ arm_dst->sketch = NULL;
+}
- return newArm;
+bArmature *BKE_armature_copy(Main *bmain, const bArmature *arm)
+{
+ bArmature *arm_copy;
+ BKE_id_copy_ex(bmain, &arm->id, (ID **)&arm_copy, 0, false);
+ return arm_copy;
}
static Bone *get_named_bone_bonechildren(ListBase *lb, const char *name)
@@ -1445,13 +1461,13 @@ void BKE_armature_loc_pose_to_bone(bPoseChannel *pchan, const float inloc[3], fl
copy_v3_v3(outloc, nLocMat[3]);
}
-void BKE_armature_mat_pose_to_bone_ex(Object *ob, bPoseChannel *pchan, float inmat[4][4], float outmat[4][4])
+void BKE_armature_mat_pose_to_bone_ex(const struct EvaluationContext *eval_ctx, Object *ob, bPoseChannel *pchan, float inmat[4][4], float outmat[4][4])
{
bPoseChannel work_pchan = *pchan;
/* recalculate pose matrix with only parent transformations,
* bone loc/sca/rot is ignored, scene and frame are not used. */
- BKE_pose_where_is_bone(NULL, ob, &work_pchan, 0.0f, false);
+ BKE_pose_where_is_bone(eval_ctx, NULL, ob, &work_pchan, 0.0f, false);
/* find the matrix, need to remove the bone transforms first so this is
* calculated as a matrix to set rather then a difference ontop of whats
@@ -2178,7 +2194,9 @@ void BKE_pose_where_is_bone_tail(bPoseChannel *pchan)
/* pchan is validated, as having bone and parent pointer
* 'do_extra': when zero skips loc/size/rot, constraints and strip modifiers.
*/
-void BKE_pose_where_is_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float ctime, bool do_extra)
+void BKE_pose_where_is_bone(
+ const struct EvaluationContext *eval_ctx, Scene *scene,
+ Object *ob, bPoseChannel *pchan, float ctime, bool do_extra)
{
/* This gives a chan_mat with actions (ipos) results. */
if (do_extra)
@@ -2217,7 +2235,7 @@ void BKE_pose_where_is_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float
cob = BKE_constraints_make_evalob(scene, ob, pchan, CONSTRAINT_OBTYPE_BONE);
/* Solve PoseChannel's Constraints */
- BKE_constraints_solve(&pchan->constraints, cob, ctime); /* ctime doesnt alter objects */
+ BKE_constraints_solve(eval_ctx, &pchan->constraints, cob, ctime); /* ctime doesnt alter objects */
/* cleanup after Constraint Solving
* - applies matrix back to pchan, and frees temporary struct used
@@ -2239,7 +2257,7 @@ void BKE_pose_where_is_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float
/* This only reads anim data from channels, and writes to channels */
/* This is the only function adding poses */
-void BKE_pose_where_is(Scene *scene, Object *ob)
+void BKE_pose_where_is(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob)
{
bArmature *arm;
Bone *bone;
@@ -2278,7 +2296,7 @@ void BKE_pose_where_is(Scene *scene, Object *ob)
}
/* 2a. construct the IK tree (standard IK) */
- BIK_initialize_tree(scene, ob, ctime);
+ BIK_initialize_tree(eval_ctx, scene, ob, ctime);
/* 2b. construct the Spline IK trees
* - this is not integrated as an IK plugin, since it should be able
@@ -2290,15 +2308,15 @@ void BKE_pose_where_is(Scene *scene, Object *ob)
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
/* 4a. if we find an IK root, we handle it separated */
if (pchan->flag & POSE_IKTREE) {
- BIK_execute_tree(scene, ob, pchan, ctime);
+ BIK_execute_tree(eval_ctx, scene, ob, pchan, ctime);
}
/* 4b. if we find a Spline IK root, we handle it separated too */
else if (pchan->flag & POSE_IKSPLINE) {
- BKE_splineik_execute_tree(scene, ob, pchan, ctime);
+ BKE_splineik_execute_tree(eval_ctx, scene, ob, pchan, ctime);
}
/* 5. otherwise just call the normal solver */
else if (!(pchan->flag & POSE_DONE)) {
- BKE_pose_where_is_bone(scene, ob, pchan, ctime, 1);
+ BKE_pose_where_is_bone(eval_ctx, scene, ob, pchan, ctime, 1);
}
}
/* 6. release the IK tree */
diff --git a/source/blender/blenkernel/intern/armature_update.c b/source/blender/blenkernel/intern/armature_update.c
index 73e9f5d0774..1addbcbadc0 100644
--- a/source/blender/blenkernel/intern/armature_update.c
+++ b/source/blender/blenkernel/intern/armature_update.c
@@ -113,9 +113,11 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos
* currently for paths to work it needs to go through the bevlist/displist system (ton)
*/
+ /* TODO: Make sure this doesn't crash. */
+#if 0
/* only happens on reload file, but violates depsgraph still... fix! */
if (ELEM(NULL, ikData->tar->curve_cache, ikData->tar->curve_cache->path, ikData->tar->curve_cache->path->data)) {
- BKE_displist_make_curveTypes(scene, ikData->tar, 0);
+ BKE_displist_make_curveTypes(eval_ctx, scene, ikData->tar, 0);
/* path building may fail in EditMode after removing verts [#33268]*/
if (ELEM(NULL, ikData->tar->curve_cache->path, ikData->tar->curve_cache->path->data)) {
@@ -123,6 +125,9 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos
return;
}
}
+#else
+ (void) scene;
+#endif
}
/* find the root bone and the chain of bones from the root to the tip
@@ -261,15 +266,16 @@ static void splineik_init_tree(Scene *scene, Object *ob, float UNUSED(ctime))
/* ----------- */
/* Evaluate spline IK for a given bone */
-static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *ob, bPoseChannel *pchan,
- int index, float ctime)
+static void splineik_evaluate_bone(
+ const struct EvaluationContext *eval_ctx, tSplineIK_Tree *tree, Scene *scene, Object *ob, bPoseChannel *pchan,
+ int index, float ctime)
{
bSplineIKConstraint *ikData = tree->ikData;
float poseHead[3], poseTail[3], poseMat[4][4];
float splineVec[3], scaleFac, radius = 1.0f;
/* firstly, calculate the bone matrix the standard way, since this is needed for roll control */
- BKE_pose_where_is_bone(scene, ob, pchan, ctime, 1);
+ BKE_pose_where_is_bone(eval_ctx, scene, ob, pchan, ctime, 1);
copy_v3_v3(poseHead, pchan->pose_head);
copy_v3_v3(poseTail, pchan->pose_tail);
@@ -511,7 +517,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
}
/* Evaluate the chain starting from the nominated bone */
-static void splineik_execute_tree(Scene *scene, Object *ob, bPoseChannel *pchan_root, float ctime)
+static void splineik_execute_tree(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, bPoseChannel *pchan_root, float ctime)
{
tSplineIK_Tree *tree;
@@ -525,7 +531,7 @@ static void splineik_execute_tree(Scene *scene, Object *ob, bPoseChannel *pchan_
*/
for (i = tree->chainlen - 1; i >= 0; i--) {
bPoseChannel *pchan = tree->chain[i];
- splineik_evaluate_bone(tree, scene, ob, pchan, i, ctime);
+ splineik_evaluate_bone(eval_ctx, tree, scene, ob, pchan, i, ctime);
}
/* free the tree info specific to SplineIK trees now */
@@ -544,19 +550,20 @@ void BKE_pose_splineik_init_tree(Scene *scene, Object *ob, float ctime)
splineik_init_tree(scene, ob, ctime);
}
-void BKE_splineik_execute_tree(Scene *scene, Object *ob, bPoseChannel *pchan_root, float ctime)
+void BKE_splineik_execute_tree(
+ const struct EvaluationContext *eval_ctx, Scene *scene,
+ Object *ob, bPoseChannel *pchan_root, float ctime)
{
- splineik_execute_tree(scene, ob, pchan_root, ctime);
+ splineik_execute_tree(eval_ctx, scene, ob, pchan_root, ctime);
}
/* *************** Depsgraph evaluation callbacks ************ */
-void BKE_pose_eval_init(struct EvaluationContext *UNUSED(eval_ctx),
- Scene *scene,
+void BKE_pose_eval_init(const struct EvaluationContext *UNUSED(eval_ctx),
+ Scene *UNUSED(scene),
Object *ob,
bPose *pose)
{
- float ctime = BKE_scene_frame_get(scene); /* not accurate... */
bPoseChannel *pchan;
DEBUG_PRINT("%s on %s\n", __func__, ob->id.name);
@@ -574,9 +581,19 @@ void BKE_pose_eval_init(struct EvaluationContext *UNUSED(eval_ctx),
for (pchan = pose->chanbase.first; pchan != NULL; pchan = pchan->next) {
pchan->flag &= ~(POSE_DONE | POSE_CHAIN | POSE_IKTREE | POSE_IKSPLINE);
}
+}
+
+void BKE_pose_eval_init_ik(const struct EvaluationContext *eval_ctx,
+ Scene *scene,
+ Object *ob,
+ bPose *UNUSED(pose))
+{
+ float ctime = BKE_scene_frame_get(scene); /* not accurate... */
+
+ DEBUG_PRINT("%s on %s\n", __func__, ob->id.name);
/* 2a. construct the IK tree (standard IK) */
- BIK_initialize_tree(scene, ob, ctime);
+ BIK_initialize_tree(eval_ctx, scene, ob, ctime);
/* 2b. construct the Spline IK trees
* - this is not integrated as an IK plugin, since it should be able
@@ -585,7 +602,7 @@ void BKE_pose_eval_init(struct EvaluationContext *UNUSED(eval_ctx),
BKE_pose_splineik_init_tree(scene, ob, ctime);
}
-void BKE_pose_eval_bone(struct EvaluationContext *UNUSED(eval_ctx),
+void BKE_pose_eval_bone(const struct EvaluationContext *eval_ctx,
Scene *scene,
Object *ob,
bPoseChannel *pchan)
@@ -613,14 +630,14 @@ void BKE_pose_eval_bone(struct EvaluationContext *UNUSED(eval_ctx),
if ((pchan->flag & POSE_DONE) == 0) {
/* TODO(sergey): Use time source node for time. */
float ctime = BKE_scene_frame_get(scene); /* not accurate... */
- BKE_pose_where_is_bone(scene, ob, pchan, ctime, 1);
+ BKE_pose_where_is_bone(eval_ctx, scene, ob, pchan, ctime, 1);
}
}
}
}
}
-void BKE_pose_constraints_evaluate(struct EvaluationContext *UNUSED(eval_ctx),
+void BKE_pose_constraints_evaluate(const struct EvaluationContext *eval_ctx,
Scene *scene,
Object *ob,
bPoseChannel *pchan)
@@ -636,12 +653,12 @@ void BKE_pose_constraints_evaluate(struct EvaluationContext *UNUSED(eval_ctx),
else {
if ((pchan->flag & POSE_DONE) == 0) {
float ctime = BKE_scene_frame_get(scene); /* not accurate... */
- BKE_pose_where_is_bone(scene, ob, pchan, ctime, 1);
+ BKE_pose_where_is_bone(eval_ctx, scene, ob, pchan, ctime, 1);
}
}
}
-void BKE_pose_bone_done(struct EvaluationContext *UNUSED(eval_ctx),
+void BKE_pose_bone_done(const struct EvaluationContext *UNUSED(eval_ctx),
bPoseChannel *pchan)
{
float imat[4][4];
@@ -652,27 +669,27 @@ void BKE_pose_bone_done(struct EvaluationContext *UNUSED(eval_ctx),
}
}
-void BKE_pose_iktree_evaluate(struct EvaluationContext *UNUSED(eval_ctx),
+void BKE_pose_iktree_evaluate(const struct EvaluationContext *eval_ctx,
Scene *scene,
Object *ob,
bPoseChannel *rootchan)
{
float ctime = BKE_scene_frame_get(scene); /* not accurate... */
DEBUG_PRINT("%s on %s pchan %s\n", __func__, ob->id.name, rootchan->name);
- BIK_execute_tree(scene, ob, rootchan, ctime);
+ BIK_execute_tree(eval_ctx, scene, ob, rootchan, ctime);
}
-void BKE_pose_splineik_evaluate(struct EvaluationContext *UNUSED(eval_ctx),
+void BKE_pose_splineik_evaluate(const struct EvaluationContext *eval_ctx,
Scene *scene,
Object *ob,
bPoseChannel *rootchan)
{
float ctime = BKE_scene_frame_get(scene); /* not accurate... */
DEBUG_PRINT("%s on %s pchan %s\n", __func__, ob->id.name, rootchan->name);
- BKE_splineik_execute_tree(scene, ob, rootchan, ctime);
+ BKE_splineik_execute_tree(eval_ctx, scene, ob, rootchan, ctime);
}
-void BKE_pose_eval_flush(struct EvaluationContext *UNUSED(eval_ctx),
+void BKE_pose_eval_flush(const struct EvaluationContext *UNUSED(eval_ctx),
Scene *scene,
Object *ob,
bPose *UNUSED(pose))
@@ -687,7 +704,7 @@ void BKE_pose_eval_flush(struct EvaluationContext *UNUSED(eval_ctx),
ob->recalc &= ~OB_RECALC_ALL;
}
-void BKE_pose_eval_proxy_copy(struct EvaluationContext *UNUSED(eval_ctx), Object *ob)
+void BKE_pose_eval_proxy_copy(const struct EvaluationContext *UNUSED(eval_ctx), Object *ob)
{
BLI_assert(ID_IS_LINKED_DATABLOCK(ob) && ob->proxy_from != NULL);
DEBUG_PRINT("%s on %s\n", __func__, ob->id.name);
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index ebb10c02683..1f75c85291d 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -230,19 +230,6 @@ void BKE_blender_userdef_free_data(UserDef *userdef)
}
/**
- * Handle changes in settings that need refreshing.
- */
-void BKE_blender_userdef_refresh(void)
-{
- /* prevent accidents */
- if (U.pixelsize == 0) U.pixelsize = 1;
-
- BLF_default_dpi(U.pixelsize * U.dpi);
- U.widget_unit = (U.pixelsize * U.dpi * 20 + 36) / 72;
-
-}
-
-/**
* Write U from userdef.
* This function defines which settings a template will override for the user preferences.
*/
diff --git a/source/blender/blenkernel/intern/blender_copybuffer.c b/source/blender/blenkernel/intern/blender_copybuffer.c
index 206b0f2a8cc..2d37f3ab0cb 100644
--- a/source/blender/blenkernel/intern/blender_copybuffer.c
+++ b/source/blender/blenkernel/intern/blender_copybuffer.c
@@ -49,6 +49,7 @@
#include "BKE_main.h"
#include "BKE_scene.h"
+#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
#include "BLO_readfile.h"
@@ -160,6 +161,10 @@ bool BKE_copybuffer_paste(bContext *C, const char *libname, const short flag, Re
/* recreate dependency graph to include new objects */
DEG_relations_tag_update(bmain);
+ /* Tag update the scene to flush base collection settings, since the new object is added to a
+ * new (active) collection, not its original collection, thus need recalculation. */
+ DEG_id_tag_update(&scene->id, 0);
+
BLO_blendhandle_close(bh);
/* remove library... */
diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c
index 53f2462ee98..e1350aa8a46 100644
--- a/source/blender/blenkernel/intern/blendfile.c
+++ b/source/blender/blenkernel/intern/blendfile.c
@@ -117,6 +117,7 @@ static void setup_app_data(
const char *filepath, ReportList *reports)
{
Scene *curscene = NULL;
+ const bool is_startup = (bfd->filename[0] == '\0');
const bool recover = (G.fileflags & G_FILE_RECOVER) != 0;
enum {
LOAD_UI = 1,
@@ -132,7 +133,7 @@ static void setup_app_data(
else if (BLI_listbase_is_empty(&bfd->main->screen)) {
mode = LOAD_UNDO;
}
- else if (G.fileflags & G_FILE_NO_UI) {
+ else if ((G.fileflags & G_FILE_NO_UI) && (is_startup == false)) {
mode = LOAD_UI_OFF;
}
else {
@@ -193,7 +194,7 @@ static void setup_app_data(
}
if (cur_render_layer == NULL) {
/* fallback to scene layer */
- cur_render_layer = BKE_scene_layer_render_active(curscene);
+ cur_render_layer = BKE_scene_layer_from_scene_get(curscene);
}
if (track_undo_scene) {
@@ -218,6 +219,13 @@ static void setup_app_data(
BKE_screen_view3d_scene_sync(curscreen, curscene);
}
}
+
+ /* We need to tag this here because events may be handled immediately after.
+ * only the current screen is important because we wont have to handle
+ * events from multiple screens at once.*/
+ {
+ BKE_screen_manipulator_tag_refresh(curscreen);
+ }
}
/* free G.main Main database */
@@ -257,7 +265,9 @@ static void setup_app_data(
CTX_data_scene_set(C, curscene);
}
else {
- G.fileflags = bfd->fileflags;
+ /* Keep state from preferences. */
+ const int fileflags_skip = G_FILE_FLAGS_RUNTIME;
+ G.fileflags = (G.fileflags & fileflags_skip) | (bfd->fileflags & ~fileflags_skip);
CTX_wm_manager_set(C, G.main->wm.first);
CTX_wm_screen_set(C, bfd->curscreen);
CTX_data_scene_set(C, bfd->curscene);
@@ -333,20 +343,19 @@ static void setup_app_data(
}
}
- if (mode == LOAD_UI_OFF && BLI_listbase_is_empty(&G.main->wm)) {
- /* XXX prevent crash in pdInitEffectors called through DEG_scene_relations_rebuild (see T51794).
- * Can be removed once BKE_scene_layer_context_active_ex gets workspace passed. */
- BLI_addhead(&G.main->wm, CTX_wm_manager(C));
- BKE_scene_set_background(G.main, curscene);
- BLI_listbase_clear(&G.main->wm);
- }
- else {
- BKE_scene_set_background(G.main, curscene);
+ /* Setting scene might require having a dependency graph, with copy on write
+ * we need to make sure we ensure scene has correct color management before
+ * constructing dependency graph.
+ */
+ if (mode != LOAD_UNDO) {
+ IMB_colormanagement_check_file_config(G.main);
}
+ BKE_scene_set_background(G.main, curscene);
+
if (mode != LOAD_UNDO) {
+ /* TODO(sergey): Can this be also move above? */
RE_FreeAllPersistentData();
- IMB_colormanagement_check_file_config(G.main);
}
MEM_freeN(bfd);
diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c
index 7ca4e07076d..8c78787c259 100644
--- a/source/blender/blenkernel/intern/boids.c
+++ b/source/blender/blenkernel/intern/boids.c
@@ -132,6 +132,7 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
if (eff == NULL && gabr->ob) {
memset(&temp_eff, 0, sizeof(EffectorCache));
temp_eff.ob = gabr->ob;
+ temp_eff.eval_ctx = bbd->sim->eval_ctx;
temp_eff.scene = bbd->sim->scene;
eff = &temp_eff;
get_effector_data(eff, &efd, &epoint, 0);
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index aae323a5056..aeaead578a1 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -152,7 +152,7 @@ Brush *BKE_brush_add(Main *bmain, const char *name, short ob_mode)
{
Brush *brush;
- brush = BKE_libblock_alloc(bmain, ID_BR, name);
+ brush = BKE_libblock_alloc(bmain, ID_BR, name, 0);
BKE_brush_init(brush);
@@ -172,34 +172,38 @@ struct Brush *BKE_brush_first_search(struct Main *bmain, short ob_mode)
return NULL;
}
-Brush *BKE_brush_copy(Main *bmain, const Brush *brush)
+/**
+ * Only copy internal data of Brush ID from source to already allocated/initialized destination.
+ * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
+ *
+ * WARNING! This function will not handle ID user count!
+ *
+ * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
+ */
+void BKE_brush_copy_data(Main *UNUSED(bmain), Brush *brush_dst, const Brush *brush_src, const int flag)
{
- Brush *brushn;
-
- brushn = BKE_libblock_copy(bmain, &brush->id);
-
- if (brush->mtex.tex)
- id_us_plus((ID *)brush->mtex.tex);
-
- if (brush->mask_mtex.tex)
- id_us_plus((ID *)brush->mask_mtex.tex);
-
- if (brush->paint_curve)
- id_us_plus((ID *)brush->paint_curve);
-
- if (brush->icon_imbuf)
- brushn->icon_imbuf = IMB_dupImBuf(brush->icon_imbuf);
+ if (brush_src->icon_imbuf) {
+ brush_dst->icon_imbuf = IMB_dupImBuf(brush_src->icon_imbuf);
+ }
- brushn->preview = NULL;
+ if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0) {
+ BKE_previewimg_id_copy(&brush_dst->id, &brush_src->id);
+ }
+ else {
+ brush_dst->preview = NULL;
+ }
- brushn->curve = curvemapping_copy(brush->curve);
+ brush_dst->curve = curvemapping_copy(brush_src->curve);
/* enable fake user by default */
- id_fake_user_set(&brushn->id);
-
- BKE_id_copy_ensure_local(bmain, &brush->id, &brushn->id);
+ id_fake_user_set(&brush_dst->id);
+}
- return brushn;
+Brush *BKE_brush_copy(Main *bmain, const Brush *brush)
+{
+ Brush *brush_copy;
+ BKE_id_copy_ex(bmain, &brush->id, (ID **)&brush_copy, 0, false);
+ return brush_copy;
}
/** Free (or release) any data used by this brush (does not free the brush itself). */
@@ -517,13 +521,13 @@ int BKE_brush_clone_image_delete(Brush *brush)
* region space mouse coordinates, or 3d world coordinates for 3D mapping.
*
* rgba outputs straight alpha. */
-float BKE_brush_sample_tex_3D(const Scene *scene, Brush *br,
+float BKE_brush_sample_tex_3D(const Scene *scene, const Brush *br,
const float point[3],
float rgba[4], const int thread,
struct ImagePool *pool)
{
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
- MTex *mtex = &br->mtex;
+ const MTex *mtex = &br->mtex;
float intensity = 1.0;
bool hasrgb = false;
@@ -817,7 +821,7 @@ int BKE_brush_size_get(const Scene *scene, const Brush *brush)
return size;
}
-int BKE_brush_use_locked_size(const Scene *scene, const Brush *brush)
+bool BKE_brush_use_locked_size(const Scene *scene, const Brush *brush)
{
const short us_flag = scene->toolsettings->unified_paint_settings.flag;
@@ -826,7 +830,7 @@ int BKE_brush_use_locked_size(const Scene *scene, const Brush *brush)
(brush->flag & BRUSH_LOCK_SIZE);
}
-int BKE_brush_use_size_pressure(const Scene *scene, const Brush *brush)
+bool BKE_brush_use_size_pressure(const Scene *scene, const Brush *brush)
{
const short us_flag = scene->toolsettings->unified_paint_settings.flag;
@@ -835,7 +839,7 @@ int BKE_brush_use_size_pressure(const Scene *scene, const Brush *brush)
(brush->flag & BRUSH_SIZE_PRESSURE);
}
-int BKE_brush_use_alpha_pressure(const Scene *scene, const Brush *brush)
+bool BKE_brush_use_alpha_pressure(const Scene *scene, const Brush *brush)
{
const short us_flag = scene->toolsettings->unified_paint_settings.flag;
@@ -844,6 +848,16 @@ int BKE_brush_use_alpha_pressure(const Scene *scene, const Brush *brush)
(brush->flag & BRUSH_ALPHA_PRESSURE);
}
+bool BKE_brush_sculpt_has_secondary_color(const Brush *brush)
+{
+ return ELEM(
+ brush->sculpt_tool, SCULPT_TOOL_BLOB, SCULPT_TOOL_DRAW,
+ SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY, SCULPT_TOOL_CLAY_STRIPS,
+ SCULPT_TOOL_PINCH, SCULPT_TOOL_CREASE, SCULPT_TOOL_LAYER,
+ SCULPT_TOOL_FLATTEN, SCULPT_TOOL_FILL, SCULPT_TOOL_SCRAPE,
+ SCULPT_TOOL_MASK);
+}
+
void BKE_brush_unprojected_radius_set(Scene *scene, Brush *brush, float unprojected_radius)
{
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
@@ -962,7 +976,7 @@ void BKE_brush_randomize_texture_coords(UnifiedPaintSettings *ups, bool mask)
}
/* Uses the brush curve control to find a strength value */
-float BKE_brush_curve_strength(Brush *br, float p, const float len)
+float BKE_brush_curve_strength(const Brush *br, float p, const float len)
{
float strength;
diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c
index c1fad4f80c8..775499304d4 100644
--- a/source/blender/blenkernel/intern/bvhutils.c
+++ b/source/blender/blenkernel/intern/bvhutils.c
@@ -1137,7 +1137,6 @@ BVHTree *bvhtree_from_mesh_looptri(
const MLoopTri *looptri = NULL;
bool vert_allocated = false;
bool loop_allocated = false;
- bool looptri_allocated = false;
BLI_rw_mutex_lock(&cache_rwlock, THREAD_LOCK_READ);
tree = bvhcache_find(dm->bvhCache, BVHTREE_FROM_LOOPTRI);
@@ -1150,12 +1149,7 @@ BVHTree *bvhtree_from_mesh_looptri(
mpoly = DM_get_poly_array(dm, &poly_allocated);
mloop = DM_get_loop_array(dm, &loop_allocated);
- looptri = DM_get_looptri_array(
- dm,
- mvert,
- mpoly, dm->getNumPolys(dm),
- mloop, dm->getNumLoops(dm),
- &looptri_allocated);
+ looptri = dm->getLoopTriArray(dm);
if (poly_allocated) {
MEM_freeN(mpoly);
@@ -1193,7 +1187,7 @@ BVHTree *bvhtree_from_mesh_looptri(
data, tree, true, epsilon,
mvert, vert_allocated,
mloop, loop_allocated,
- looptri, looptri_allocated);
+ looptri, false);
}
else {
if (vert_allocated) {
@@ -1202,9 +1196,6 @@ BVHTree *bvhtree_from_mesh_looptri(
if (loop_allocated) {
MEM_freeN(mloop);
}
- if (looptri_allocated) {
- MEM_freeN((void *)looptri);
- }
memset(data, 0, sizeof(*data));
}
diff --git a/source/blender/blenkernel/intern/cachefile.c b/source/blender/blenkernel/intern/cachefile.c
index 43dcde302b3..9d02a27187c 100644
--- a/source/blender/blenkernel/intern/cachefile.c
+++ b/source/blender/blenkernel/intern/cachefile.c
@@ -66,7 +66,7 @@ void BKE_cachefiles_exit(void)
void *BKE_cachefile_add(Main *bmain, const char *name)
{
- CacheFile *cache_file = BKE_libblock_alloc(bmain, ID_CF, name);
+ CacheFile *cache_file = BKE_libblock_alloc(bmain, ID_CF, name, 0);
BKE_cachefile_init(cache_file);
@@ -100,16 +100,26 @@ void BKE_cachefile_free(CacheFile *cache_file)
BLI_freelistN(&cache_file->object_paths);
}
-CacheFile *BKE_cachefile_copy(Main *bmain, const CacheFile *cache_file)
+/**
+ * Only copy internal data of CacheFile ID from source to already allocated/initialized destination.
+ * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
+ *
+ * WARNING! This function will not handle ID user count!
+ *
+ * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
+ */
+void BKE_cachefile_copy_data(
+ Main *UNUSED(bmain), CacheFile *cache_file_dst, const CacheFile *UNUSED(cache_file_src), const int UNUSED(flag))
{
- CacheFile *new_cache_file = BKE_libblock_copy(bmain, &cache_file->id);
- new_cache_file->handle = NULL;
-
- BLI_listbase_clear(&new_cache_file->object_paths);
-
- BKE_id_copy_ensure_local(bmain, &cache_file->id, &new_cache_file->id);
+ cache_file_dst->handle = NULL;
+ BLI_listbase_clear(&cache_file_dst->object_paths);
+}
- return new_cache_file;
+CacheFile *BKE_cachefile_copy(Main *bmain, const CacheFile *cache_file)
+{
+ CacheFile *cache_file_copy;
+ BKE_id_copy_ex(bmain, &cache_file->id, (ID **)&cache_file_copy, 0, false);
+ return cache_file_copy;
}
void BKE_cachefile_make_local(Main *bmain, CacheFile *cache_file, const bool lib_local)
@@ -166,10 +176,12 @@ void BKE_cachefile_update_frame(Main *bmain, Scene *scene, const float ctime, co
const float time = BKE_cachefile_time_offset(cache_file, ctime, fps);
if (BKE_cachefile_filepath_get(bmain, cache_file, time, filename)) {
+ BKE_cachefile_clean(bmain, cache_file);
#ifdef WITH_ALEMBIC
ABC_free_handle(cache_file->handle);
cache_file->handle = ABC_create_handle(filename, NULL);
#endif
+ break;
}
}
}
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index 2e36de4e8d4..97bb679f8b0 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -86,22 +86,31 @@ void *BKE_camera_add(Main *bmain, const char *name)
{
Camera *cam;
- cam = BKE_libblock_alloc(bmain, ID_CA, name);
+ cam = BKE_libblock_alloc(bmain, ID_CA, name, 0);
BKE_camera_init(cam);
return cam;
}
-Camera *BKE_camera_copy(Main *bmain, const Camera *cam)
+/**
+ * Only copy internal data of Camera ID from source to already allocated/initialized destination.
+ * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
+ *
+ * WARNING! This function will not handle ID user count!
+ *
+ * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
+ */
+void BKE_camera_copy_data(Main *UNUSED(bmain), Camera *UNUSED(cam_dst), const Camera *UNUSED(cam_src), const int UNUSED(flag))
{
- Camera *camn;
-
- camn = BKE_libblock_copy(bmain, &cam->id);
-
- BKE_id_copy_ensure_local(bmain, &cam->id, &camn->id);
+ /* Nothing to do! */
+}
- return camn;
+Camera *BKE_camera_copy(Main *bmain, const Camera *cam)
+{
+ Camera *cam_copy;
+ BKE_id_copy_ex(bmain, &cam->id, (ID **)&cam_copy, 0, false);
+ return cam_copy;
}
void BKE_camera_make_local(Main *bmain, Camera *cam, const bool lib_local)
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index 155634c9d9c..d1282c1a0fe 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -34,10 +34,12 @@
* \ingroup bke
*/
+#include "atomic_ops.h"
+
#include "BLI_math.h"
#include "BLI_edgehash.h"
#include "BLI_utildefines.h"
-#include "BLI_stackdefines.h"
+#include "BLI_utildefines_stack.h"
#include "BKE_pbvh.h"
#include "BKE_cdderivedmesh.h"
@@ -549,6 +551,11 @@ static void cdDM_drawMappedFaces(
const int *index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX);
+ if (cddm->pbvh) {
+ if (G.debug_value == 14)
+ BKE_pbvh_draw_BB(cddm->pbvh);
+ }
+
/* fist, setup common buffers */
GPU_vertex_setup(dm);
GPU_triangle_setup(dm);
@@ -1398,8 +1405,8 @@ static void cdDM_buffer_copy_mcol(
for (i = 0; i < totpoly; i++, mpoly++) {
for (j = 0; j < mpoly->totloop; j++) {
- copy_v3_v3_uchar(&varray[start], &mloopcol[mpoly->loopstart + j].r);
- start += 3;
+ copy_v4_v4_uchar(&varray[start], &mloopcol[mpoly->loopstart + j].r);
+ start += 4;
}
}
}
@@ -1799,25 +1806,17 @@ void CDDM_recalc_looptri(DerivedMesh *dm)
const unsigned int totloop = dm->numLoopData;
DM_ensure_looptri_data(dm);
+ BLI_assert(totpoly == 0 || cddm->dm.looptris.array_wip != NULL);
BKE_mesh_recalc_looptri(
cddm->mloop, cddm->mpoly,
cddm->mvert,
totloop, totpoly,
- cddm->dm.looptris.array);
-}
+ cddm->dm.looptris.array_wip);
-static const MLoopTri *cdDM_getLoopTriArray(DerivedMesh *dm)
-{
- if (dm->looptris.array) {
- BLI_assert(poly_to_tri_count(dm->numPolyData, dm->numLoopData) == dm->looptris.num);
- }
- else {
- dm->recalcLoopTri(dm);
-
- /* ccdm is an exception here, that recalcLoopTri will fill in the array too */
- }
- return dm->looptris.array;
+ BLI_assert(cddm->dm.looptris.array == NULL);
+ atomic_cas_ptr((void **)&cddm->dm.looptris.array, cddm->dm.looptris.array, cddm->dm.looptris.array_wip);
+ cddm->dm.looptris.array_wip = NULL;
}
static void cdDM_free_internal(CDDerivedMesh *cddm)
@@ -1870,8 +1869,6 @@ static CDDerivedMesh *cdDM_create(const char *desc)
dm->getEdgeDataArray = DM_get_edge_data_layer;
dm->getTessFaceDataArray = DM_get_tessface_data_layer;
- dm->getLoopTriArray = cdDM_getLoopTriArray;
-
dm->calcNormals = CDDM_calc_normals;
dm->calcLoopNormals = CDDM_calc_loop_normals;
dm->calcLoopNormalsSpaceArray = CDDM_calc_loop_normals_spacearr;
@@ -3056,7 +3053,7 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap, const int
MPoly *target_poly = cddm->mpoly + *(cddm->pmap[v_target].indices + i_poly);
if (cddm_poly_compare(cddm->mloop, mp, target_poly, vtargetmap, +1) ||
- cddm_poly_compare(cddm->mloop, mp, target_poly, vtargetmap, -1))
+ cddm_poly_compare(cddm->mloop, mp, target_poly, vtargetmap, -1))
{
found = true;
break;
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 6d0ad3255a2..09b793629f7 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -345,7 +345,7 @@ static int do_init_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul
return 1;
}
-static int do_step_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *result, int framenr)
+static int do_step_cloth(const struct EvaluationContext *eval_ctx, Object *ob, ClothModifierData *clmd, DerivedMesh *result, int framenr)
{
ClothVertex *verts = NULL;
Cloth *cloth;
@@ -370,7 +370,7 @@ static int do_step_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul
mul_m4_v3(ob->obmat, verts->xconst);
}
- effectors = pdInitEffectors(clmd->scene, ob, NULL, clmd->sim_parms->effector_weights, true);
+ effectors = pdInitEffectors(eval_ctx, clmd->scene, ob, NULL, clmd->sim_parms->effector_weights, true);
if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_DYNAMIC_BASEMESH )
cloth_update_verts ( ob, clmd, result );
@@ -400,7 +400,7 @@ static int do_step_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul
/************************************************
* clothModifier_do - main simulation function
************************************************/
-void clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, DerivedMesh *dm, float (*vertexCos)[3])
+void clothModifier_do(ClothModifierData *clmd, const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, DerivedMesh *dm, float (*vertexCos)[3])
{
PointCache *cache;
PTCacheID pid;
@@ -489,7 +489,7 @@ void clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, Derived
/* do simulation */
BKE_ptcache_validate(cache, framenr);
- if (!do_step_cloth(ob, clmd, dm, framenr)) {
+ if (!do_step_cloth(eval_ctx, ob, clmd, dm, framenr)) {
BKE_ptcache_invalidate(cache);
}
else
@@ -806,7 +806,6 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
if ( !dm )
return 0;
- DM_ensure_looptri(dm);
cloth_from_mesh ( clmd, dm );
// create springs
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 3bf3a5ce5a4..2b69c176c39 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -261,6 +261,9 @@ void BKE_collection_object_add_from(Scene *scene, Object *ob_src, Object *ob_dst
for (SceneLayer *sl = scene->render_layers.first; sl; sl = sl->next) {
Base *base_src = BKE_scene_layer_base_find(sl, ob_src);
if (base_src != NULL) {
+ if (base_src->collection_properties == NULL) {
+ continue;
+ }
Base *base_dst = BKE_scene_layer_base_find(sl, ob_dst);
IDP_MergeGroup(base_dst->collection_properties, base_src->collection_properties, true);
}
@@ -565,7 +568,7 @@ void BKE_scene_collections_iterator_end(struct BLI_Iterator *iter)
typedef struct SceneObjectsIteratorData {
GSet *visited;
- LinkData *link;
+ LinkData *link_next;
BLI_Iterator scene_collection_iter;
} SceneObjectsIteratorData;
@@ -597,8 +600,9 @@ static LinkData *object_base_unique(GSet *gs, LinkData *link)
{
for (; link != NULL; link = link->next) {
Object *ob = link->data;
- if (!BLI_gset_haskey(gs, ob)) {
- BLI_gset_add(gs, ob);
+ void **ob_key_p;
+ if (!BLI_gset_ensure_p_ex(gs, ob, &ob_key_p)) {
+ *ob_key_p = ob;
return link;
}
}
@@ -608,10 +612,10 @@ static LinkData *object_base_unique(GSet *gs, LinkData *link)
void BKE_scene_objects_iterator_next(BLI_Iterator *iter)
{
SceneObjectsIteratorData *data = iter->data;
- LinkData *link = data->link ? object_base_unique(data->visited, data->link->next) : NULL;
+ LinkData *link = data->link_next ? object_base_unique(data->visited, data->link_next) : NULL;
if (link) {
- data->link = link;
+ data->link_next = link->next;
iter->current = link->data;
}
else {
@@ -623,8 +627,8 @@ void BKE_scene_objects_iterator_next(BLI_Iterator *iter)
/* get the first unique object of this collection */
LinkData *new_link = object_base_unique(data->visited, sc->objects.first);
if (new_link) {
- data->link = new_link;
- iter->current = data->link->data;
+ data->link_next = new_link->next;
+ iter->current = new_link->data;
return;
}
BKE_scene_collections_iterator_next(&data->scene_collection_iter);
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c
index ee0f904c3a6..310255a15c1 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -1380,7 +1380,7 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, const ColorManagedViewSettings *
/* Keep number of threads in sync with the merge parts below. */
ScopesUpdateData data = {
- .scopes = scopes, . ibuf = ibuf,
+ .scopes = scopes, .ibuf = ibuf,
.cm_processor = cm_processor, .display_buffer = display_buffer, .ycc_mode = ycc_mode,
.bin_lum = bin_lum, .bin_r = bin_r, .bin_g = bin_g, .bin_b = bin_b, .bin_a = bin_a,
};
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 07a6b304dff..1c6bc7f98a2 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -689,7 +689,7 @@ static bConstraintTypeInfo CTI_CONSTRNAME = {
/* This function should be used for the get_target_matrix member of all
* constraints that are not picky about what happens to their target matrix.
*/
-static void default_get_tarmat(bConstraint *con, bConstraintOb *UNUSED(cob), bConstraintTarget *ct, float UNUSED(ctime))
+static void default_get_tarmat(const struct EvaluationContext *UNUSED(eval_ctx), bConstraint *con, bConstraintOb *UNUSED(cob), bConstraintTarget *ct, float UNUSED(ctime))
{
if (VALID_CONS_TARGET(ct))
constraint_target_to_mat4(ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->flag, con->headtail);
@@ -1019,7 +1019,7 @@ static void vectomat(const float vec[3], const float target_up[3], short axis, s
}
/* project the up vector onto the plane specified by n */
- project_v3_v3v3(proj, u, n); /* first u onto n... */
+ project_v3_v3v3_normalized(proj, u, n); /* first u onto n... */
sub_v3_v3v3(proj, u, proj); /* then onto the plane */
/* proj specifies the transformation of the up axis */
@@ -1155,7 +1155,7 @@ static void kinematic_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
}
}
-static void kinematic_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
+static void kinematic_get_tarmat(const struct EvaluationContext *UNUSED(eval_ctx), bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
{
bKinematicConstraint *data = con->data;
@@ -1242,7 +1242,7 @@ static void followpath_flush_tars(bConstraint *con, ListBase *list, bool no_copy
}
}
-static void followpath_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
+static void followpath_get_tarmat(const struct EvaluationContext *eval_ctx, bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
{
bFollowPathConstraint *data = con->data;
@@ -1259,7 +1259,7 @@ static void followpath_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstra
#ifdef CYCLIC_DEPENDENCY_WORKAROUND
if (ct->tar->curve_cache == NULL) {
- BKE_displist_make_curveTypes(cob->scene, ct->tar, false);
+ BKE_displist_make_curveTypes(eval_ctx, cob->scene, ct->tar, false);
}
#endif
@@ -1930,7 +1930,7 @@ static void samevolume_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *
/* calculate normalizing scale factor for non-essential values */
if (obsize[data->flag] != 0)
- fac = sqrtf(volume / obsize[data->flag]) / obsize[data->flag];
+ fac = sqrtf(volume / obsize[data->flag]);
/* apply scaling factor to the channels not being kept */
switch (data->flag) {
@@ -2024,7 +2024,7 @@ static void pycon_id_looper(bConstraint *con, ConstraintIDFunc func, void *userd
}
/* Whether this approach is maintained remains to be seen (aligorith) */
-static void pycon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
+static void pycon_get_tarmat(const struct EvaluationContext *eval_ctx, bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
{
#ifdef WITH_PYTHON
bPythonConstraint *data = con->data;
@@ -2035,7 +2035,7 @@ static void pycon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTa
/* special exception for curves - depsgraph issues */
if (ct->tar->type == OB_CURVE) {
if (ct->tar->curve_cache == NULL) {
- BKE_displist_make_curveTypes(cob->scene, ct->tar, false);
+ BKE_displist_make_curveTypes(eval_ctx, cob->scene, ct->tar, false);
}
}
#endif
@@ -2142,7 +2142,7 @@ static void actcon_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
}
}
-static void actcon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
+static void actcon_get_tarmat(const struct EvaluationContext *UNUSED(eval_ctx), bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
{
bActionConstraint *data = con->data;
@@ -3131,12 +3131,12 @@ static void clampto_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
}
}
-static void clampto_get_tarmat(bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
+static void clampto_get_tarmat(const struct EvaluationContext *eval_ctx, bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
{
#ifdef CYCLIC_DEPENDENCY_WORKAROUND
if (VALID_CONS_TARGET(ct)) {
if (ct->tar->curve_cache == NULL) {
- BKE_displist_make_curveTypes(cob->scene, ct->tar, false);
+ BKE_displist_make_curveTypes(eval_ctx, cob->scene, ct->tar, false);
}
}
#endif
@@ -3474,7 +3474,7 @@ static void shrinkwrap_flush_tars(bConstraint *con, ListBase *list, bool no_copy
}
-static void shrinkwrap_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
+static void shrinkwrap_get_tarmat(const struct EvaluationContext *UNUSED(eval_ctx), bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
{
bShrinkwrapConstraint *scon = (bShrinkwrapConstraint *) con->data;
@@ -3806,12 +3806,12 @@ static void splineik_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
}
}
-static void splineik_get_tarmat(bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
+static void splineik_get_tarmat(const struct EvaluationContext *eval_ctx, bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
{
#ifdef CYCLIC_DEPENDENCY_WORKAROUND
if (VALID_CONS_TARGET(ct)) {
if (ct->tar->curve_cache == NULL) {
- BKE_displist_make_curveTypes(cob->scene, ct->tar, false);
+ BKE_displist_make_curveTypes(eval_ctx, cob->scene, ct->tar, false);
}
}
#endif
@@ -4737,29 +4737,30 @@ static void con_fix_copied_refs_cb(bConstraint *UNUSED(con), ID **idpoin, bool i
}
/* duplicate all of the constraints in a constraint stack */
-void BKE_constraints_copy(ListBase *dst, const ListBase *src, bool do_extern)
+void BKE_constraints_copy_ex(ListBase *dst, const ListBase *src, const int flag, bool do_extern)
{
bConstraint *con, *srccon;
-
+
BLI_listbase_clear(dst);
BLI_duplicatelist(dst, src);
-
+
for (con = dst->first, srccon = src->first; con && srccon; srccon = srccon->next, con = con->next) {
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
-
+
/* make a new copy of the constraint's data */
con->data = MEM_dupallocN(con->data);
-
+
/* only do specific constraints if required */
if (cti) {
/* perform custom copying operations if needed */
if (cti->copy_data)
cti->copy_data(con, srccon);
-
- /* fix usercounts for all referenced data in referenced data */
- if (cti->id_looper)
+
+ /* Fix usercounts for all referenced data that need it. */
+ if (cti->id_looper && (flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
cti->id_looper(con, con_fix_copied_refs_cb, NULL);
-
+ }
+
/* for proxies we don't want to make extern */
if (do_extern) {
/* go over used ID-links for this constraint to ensure that they are valid for proxies */
@@ -4770,6 +4771,11 @@ void BKE_constraints_copy(ListBase *dst, const ListBase *src, bool do_extern)
}
}
+void BKE_constraints_copy(ListBase *dst, const ListBase *src, bool do_extern)
+{
+ BKE_constraints_copy_ex(dst, src, 0, do_extern);
+}
+
/* ......... */
bConstraint *BKE_constraints_find_name(ListBase *list, const char *name)
@@ -4858,7 +4864,7 @@ bool BKE_constraints_proxylocked_owner(Object *ob, bPoseChannel *pchan)
* None of the actual calculations of the matrices should be done here! Also, this function is
* not to be used by any new constraints, particularly any that have multiple targets.
*/
-void BKE_constraint_target_matrix_get(Scene *scene, bConstraint *con, int index, short ownertype, void *ownerdata, float mat[4][4], float ctime)
+void BKE_constraint_target_matrix_get(const struct EvaluationContext *eval_ctx, Scene *scene, bConstraint *con, int index, short ownertype, void *ownerdata, float mat[4][4], float ctime)
{
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
@@ -4909,7 +4915,7 @@ void BKE_constraint_target_matrix_get(Scene *scene, bConstraint *con, int index,
if (ct) {
if (cti->get_target_matrix)
- cti->get_target_matrix(con, cob, ct, ctime);
+ cti->get_target_matrix(eval_ctx, con, cob, ct, ctime);
copy_m4_m4(mat, ct->matrix);
}
@@ -4925,7 +4931,7 @@ void BKE_constraint_target_matrix_get(Scene *scene, bConstraint *con, int index,
}
/* Get the list of targets required for solving a constraint */
-void BKE_constraint_targets_for_solving_get(bConstraint *con, bConstraintOb *cob, ListBase *targets, float ctime)
+void BKE_constraint_targets_for_solving_get(const struct EvaluationContext *eval_ctx, bConstraint *con, bConstraintOb *cob, ListBase *targets, float ctime)
{
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
@@ -4943,7 +4949,7 @@ void BKE_constraint_targets_for_solving_get(bConstraint *con, bConstraintOb *cob
*/
if (cti->get_target_matrix) {
for (ct = targets->first; ct; ct = ct->next)
- cti->get_target_matrix(con, cob, ct, ctime);
+ cti->get_target_matrix(eval_ctx, con, cob, ct, ctime);
}
else {
for (ct = targets->first; ct; ct = ct->next)
@@ -4960,7 +4966,7 @@ void BKE_constraint_targets_for_solving_get(bConstraint *con, bConstraintOb *cob
* BKE_constraints_make_evalob and BKE_constraints_clear_evalob should be called before and
* after running this function, to sort out cob
*/
-void BKE_constraints_solve(ListBase *conlist, bConstraintOb *cob, float ctime)
+void BKE_constraints_solve(const struct EvaluationContext *eval_ctx, ListBase *conlist, bConstraintOb *cob, float ctime)
{
bConstraint *con;
float oldmat[4][4];
@@ -4995,7 +5001,7 @@ void BKE_constraints_solve(ListBase *conlist, bConstraintOb *cob, float ctime)
BKE_constraint_mat_convertspace(cob->ob, cob->pchan, cob->matrix, CONSTRAINT_SPACE_WORLD, con->ownspace, false);
/* prepare targets for constraint solving */
- BKE_constraint_targets_for_solving_get(con, cob, &targets, ctime);
+ BKE_constraint_targets_for_solving_get(eval_ctx, con, cob, &targets, ctime);
/* Solve the constraint and put result in cob->matrix */
cti->evaluate_constraint(con, cob, &targets);
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index ac214a70b75..4f1dd18b39c 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -52,6 +52,7 @@
#include "BKE_context.h"
#include "BKE_layer.h"
#include "BKE_main.h"
+#include "BKE_scene.h"
#include "BKE_screen.h"
#include "BKE_sound.h"
#include "BKE_workspace.h"
@@ -76,6 +77,7 @@ struct bContext {
struct ScrArea *area;
struct ARegion *region;
struct ARegion *menu;
+ struct wmManipulatorGroup *manipulator_group;
struct bContextStore *store;
const char *operator_poll_msg; /* reason for poll failing */
} wm;
@@ -670,6 +672,11 @@ struct ARegion *CTX_wm_menu(const bContext *C)
return C->wm.menu;
}
+struct wmManipulatorGroup *CTX_wm_manipulator_group(const bContext *C)
+{
+ return C->wm.manipulator_group;
+}
+
struct ReportList *CTX_wm_reports(const bContext *C)
{
if (C->wm.manager)
@@ -869,6 +876,11 @@ void CTX_wm_menu_set(bContext *C, ARegion *menu)
C->wm.menu = menu;
}
+void CTX_wm_manipulator_group_set(bContext *C, struct wmManipulatorGroup *mgroup)
+{
+ C->wm.manipulator_group = mgroup;
+}
+
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
{
C->wm.operator_poll_msg = msg;
@@ -915,7 +927,7 @@ SceneLayer *CTX_data_scene_layer(const bContext *C)
return sl;
}
else {
- return BKE_scene_layer_context_active(CTX_data_scene(C));
+ return BKE_scene_layer_from_workspace_get(CTX_wm_workspace(C));
}
}
@@ -1225,5 +1237,17 @@ int CTX_data_editable_gpencil_strokes(const bContext *C, ListBase *list)
Depsgraph *CTX_data_depsgraph(const bContext *C)
{
Scene *scene = CTX_data_scene(C);
- return scene->depsgraph;
+ SceneLayer *scene_layer = CTX_data_scene_layer(C);
+ return BKE_scene_get_depsgraph(scene, scene_layer);
+}
+
+void CTX_data_eval_ctx(const bContext *C, EvaluationContext *eval_ctx)
+{
+ BLI_assert(C != NULL);
+
+ Scene *scene = CTX_data_scene(C);
+ SceneLayer *scene_layer = CTX_data_scene_layer(C);
+ DEG_evaluation_context_init_from_scene(eval_ctx,
+ scene, scene_layer,
+ DAG_EVAL_VIEWPORT);
}
diff --git a/source/blender/blenkernel/intern/crazyspace.c b/source/blender/blenkernel/intern/crazyspace.c
index 56df8e51eba..d2ffbbcf27b 100644
--- a/source/blender/blenkernel/intern/crazyspace.c
+++ b/source/blender/blenkernel/intern/crazyspace.c
@@ -99,7 +99,8 @@ static int modifiers_disable_subsurf_temporary(Object *ob)
}
/* disable subsurf temporal, get mapped cos, and enable it */
-float (*BKE_crazyspace_get_mapped_editverts(Scene *scene, Object *obedit))[3]
+float (*BKE_crazyspace_get_mapped_editverts(
+ const struct EvaluationContext *eval_ctx, Scene *scene, Object *obedit))[3]
{
Mesh *me = obedit->data;
DerivedMesh *dm;
@@ -109,13 +110,13 @@ float (*BKE_crazyspace_get_mapped_editverts(Scene *scene, Object *obedit))[3]
/* disable subsurf temporal, get mapped cos, and enable it */
if (modifiers_disable_subsurf_temporary(obedit)) {
/* need to make new derivemesh */
- makeDerivedMesh(scene, obedit, me->edit_btmesh, CD_MASK_BAREMESH, false);
+ makeDerivedMesh(eval_ctx, scene, obedit, me->edit_btmesh, CD_MASK_BAREMESH, false);
}
/* now get the cage */
vertexcos = MEM_mallocN(sizeof(*vertexcos) * nverts, "vertexcos map");
- dm = editbmesh_get_derived_cage(scene, obedit, me->edit_btmesh, CD_MASK_BAREMESH);
+ dm = editbmesh_get_derived_cage(eval_ctx, scene, obedit, me->edit_btmesh, CD_MASK_BAREMESH);
mesh_get_mapped_verts_coords(dm, vertexcos, nverts);
@@ -250,8 +251,9 @@ void BKE_crazyspace_set_quats_mesh(Mesh *me, float (*origcos)[3], float (*mapped
/** returns an array of deform matrices for crazyspace correction, and the
* number of modifiers left */
-int BKE_crazyspace_get_first_deform_matrices_editbmesh(Scene *scene, Object *ob, BMEditMesh *em,
- float (**deformmats)[3][3], float (**deformcos)[3])
+int BKE_crazyspace_get_first_deform_matrices_editbmesh(
+ const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, BMEditMesh *em,
+ float (**deformmats)[3][3], float (**deformcos)[3])
{
ModifierData *md;
DerivedMesh *dm;
@@ -290,7 +292,7 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh(Scene *scene, Object *ob,
unit_m3(defmats[a]);
}
- mti->deformMatricesEM(md, ob, em, dm, deformedVerts, defmats,
+ mti->deformMatricesEM(md, eval_ctx, ob, em, dm, deformedVerts, defmats,
numVerts);
}
else
@@ -310,7 +312,9 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh(Scene *scene, Object *ob,
return numleft;
}
-int BKE_sculpt_get_first_deform_matrices(Scene *scene, Object *ob, float (**deformmats)[3][3], float (**deformcos)[3])
+int BKE_sculpt_get_first_deform_matrices(
+ const struct EvaluationContext *eval_ctx, Scene *scene,
+ Object *ob, float (**deformmats)[3][3], float (**deformcos)[3])
{
ModifierData *md;
DerivedMesh *dm;
@@ -346,7 +350,7 @@ int BKE_sculpt_get_first_deform_matrices(Scene *scene, Object *ob, float (**defo
unit_m3(defmats[a]);
}
- if (mti->deformMatrices) mti->deformMatrices(md, ob, dm, deformedVerts, defmats, numVerts);
+ if (mti->deformMatrices) mti->deformMatrices(md, eval_ctx, ob, dm, deformedVerts, defmats, numVerts);
else break;
}
}
@@ -369,9 +373,9 @@ int BKE_sculpt_get_first_deform_matrices(Scene *scene, Object *ob, float (**defo
return numleft;
}
-void BKE_crazyspace_build_sculpt(Scene *scene, Object *ob, float (**deformmats)[3][3], float (**deformcos)[3])
+void BKE_crazyspace_build_sculpt(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float (**deformmats)[3][3], float (**deformcos)[3])
{
- int totleft = BKE_sculpt_get_first_deform_matrices(scene, ob, deformmats, deformcos);
+ int totleft = BKE_sculpt_get_first_deform_matrices(eval_ctx, scene, ob, deformmats, deformcos);
if (totleft) {
/* there are deformation modifier which doesn't support deformation matrices
@@ -396,7 +400,7 @@ void BKE_crazyspace_build_sculpt(Scene *scene, Object *ob, float (**deformmats)[
if (mti->deformMatrices && !deformed)
continue;
- mti->deformVerts(md, ob, NULL, deformedVerts, me->totvert, 0);
+ mti->deformVerts(md, eval_ctx, ob, NULL, deformedVerts, me->totvert, 0);
deformed = 1;
}
}
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 8a6d9f57093..5fbaae7212b 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -182,7 +182,7 @@ Curve *BKE_curve_add(Main *bmain, const char *name, int type)
{
Curve *cu;
- cu = BKE_libblock_alloc(bmain, ID_CU, name);
+ cu = BKE_libblock_alloc(bmain, ID_CU, name, 0);
cu->type = type;
BKE_curve_init(cu);
@@ -190,43 +190,40 @@ Curve *BKE_curve_add(Main *bmain, const char *name, int type)
return cu;
}
-Curve *BKE_curve_copy(Main *bmain, const Curve *cu)
+/**
+ * Only copy internal data of Curve ID from source to already allocated/initialized destination.
+ * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
+ *
+ * WARNING! This function will not handle ID user count!
+ *
+ * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
+ */
+void BKE_curve_copy_data(Main *bmain, Curve *cu_dst, const Curve *cu_src, const int flag)
{
- Curve *cun;
- int a;
+ BLI_listbase_clear(&cu_dst->nurb);
+ BKE_nurbList_duplicate(&(cu_dst->nurb), &(cu_src->nurb));
- cun = BKE_libblock_copy(bmain, &cu->id);
+ cu_dst->mat = MEM_dupallocN(cu_src->mat);
- BLI_listbase_clear(&cun->nurb);
- BKE_nurbList_duplicate(&(cun->nurb), &(cu->nurb));
+ cu_dst->str = MEM_dupallocN(cu_src->str);
+ cu_dst->strinfo = MEM_dupallocN(cu_src->strinfo);
+ cu_dst->tb = MEM_dupallocN(cu_src->tb);
+ cu_dst->bb = MEM_dupallocN(cu_src->bb);
+ cu_dst->batch_cache = NULL;
- cun->mat = MEM_dupallocN(cu->mat);
- for (a = 0; a < cun->totcol; a++) {
- id_us_plus((ID *)cun->mat[a]);
+ if (cu_src->key) {
+ BKE_id_copy_ex(bmain, &cu_src->key->id, (ID **)&cu_dst->key, flag, false);
}
- cun->str = MEM_dupallocN(cu->str);
- cun->strinfo = MEM_dupallocN(cu->strinfo);
- cun->tb = MEM_dupallocN(cu->tb);
- cun->bb = MEM_dupallocN(cu->bb);
- cun->batch_cache = NULL;
-
- if (cu->key) {
- cun->key = BKE_key_copy(bmain, cu->key);
- cun->key->from = (ID *)cun;
- }
-
- cun->editnurb = NULL;
- cun->editfont = NULL;
-
- id_us_plus((ID *)cun->vfont);
- id_us_plus((ID *)cun->vfontb);
- id_us_plus((ID *)cun->vfonti);
- id_us_plus((ID *)cun->vfontbi);
-
- BKE_id_copy_ensure_local(bmain, &cu->id, &cun->id);
+ cu_dst->editnurb = NULL;
+ cu_dst->editfont = NULL;
+}
- return cun;
+Curve *BKE_curve_copy(Main *bmain, const Curve *cu)
+{
+ Curve *cu_copy;
+ BKE_id_copy_ex(bmain, &cu->id, (ID **)&cu_copy, 0, false);
+ return cu_copy;
}
void BKE_curve_make_local(Main *bmain, Curve *cu, const bool lib_local)
@@ -748,6 +745,7 @@ BezTriple *BKE_nurb_bezt_get_prev(Nurb *nu, BezTriple *bezt)
BezTriple *bezt_prev;
BLI_assert(ARRAY_HAS_ITEM(bezt, nu->bezt, nu->pntsu));
+ BLI_assert(nu->pntsv == 1);
if (bezt == nu->bezt) {
if (nu->flagu & CU_NURB_CYCLIC) {
@@ -769,6 +767,7 @@ BPoint *BKE_nurb_bpoint_get_prev(Nurb *nu, BPoint *bp)
BPoint *bp_prev;
BLI_assert(ARRAY_HAS_ITEM(bp, nu->bp, nu->pntsu));
+ BLI_assert(nu->pntsv == 1);
if (bp == nu->bp) {
if (nu->flagu & CU_NURB_CYCLIC) {
@@ -785,7 +784,7 @@ BPoint *BKE_nurb_bpoint_get_prev(Nurb *nu, BPoint *bp)
return bp_prev;
}
-void BKE_nurb_bezt_calc_normal(struct Nurb *UNUSED(nu), struct BezTriple *bezt, float r_normal[3])
+void BKE_nurb_bezt_calc_normal(struct Nurb *UNUSED(nu), BezTriple *bezt, float r_normal[3])
{
/* calculate the axis matrix from the spline */
float dir_prev[3], dir_next[3];
@@ -800,7 +799,7 @@ void BKE_nurb_bezt_calc_normal(struct Nurb *UNUSED(nu), struct BezTriple *bezt,
normalize_v3(r_normal);
}
-void BKE_nurb_bezt_calc_plane(struct Nurb *nu, struct BezTriple *bezt, float r_plane[3])
+void BKE_nurb_bezt_calc_plane(struct Nurb *nu, BezTriple *bezt, float r_plane[3])
{
float dir_prev[3], dir_next[3];
@@ -837,7 +836,7 @@ void BKE_nurb_bezt_calc_plane(struct Nurb *nu, struct BezTriple *bezt, float r_p
normalize_v3(r_plane);
}
-void BKE_nurb_bpoint_calc_normal(struct Nurb *nu, struct BPoint *bp, float r_normal[3])
+void BKE_nurb_bpoint_calc_normal(struct Nurb *nu, BPoint *bp, float r_normal[3])
{
BPoint *bp_prev = BKE_nurb_bpoint_get_prev(nu, bp);
BPoint *bp_next = BKE_nurb_bpoint_get_next(nu, bp);
@@ -860,6 +859,34 @@ void BKE_nurb_bpoint_calc_normal(struct Nurb *nu, struct BPoint *bp, float r_nor
normalize_v3(r_normal);
}
+void BKE_nurb_bpoint_calc_plane(struct Nurb *nu, BPoint *bp, float r_plane[3])
+{
+ BPoint *bp_prev = BKE_nurb_bpoint_get_prev(nu, bp);
+ BPoint *bp_next = BKE_nurb_bpoint_get_next(nu, bp);
+
+ float dir_prev[3] = {0.0f}, dir_next[3] = {0.0f};
+
+ if (bp_prev) {
+ sub_v3_v3v3(dir_prev, bp_prev->vec, bp->vec);
+ normalize_v3(dir_prev);
+ }
+ if (bp_next) {
+ sub_v3_v3v3(dir_next, bp->vec, bp_next->vec);
+ normalize_v3(dir_next);
+ }
+ cross_v3_v3v3(r_plane, dir_prev, dir_next);
+
+ /* matches with bones more closely */
+ {
+ float dir_mid[3], tvec[3];
+ add_v3_v3v3(dir_mid, dir_prev, dir_next);
+ cross_v3_v3v3(tvec, r_plane, dir_mid);
+ copy_v3_v3(r_plane, tvec);
+ }
+
+ normalize_v3(r_plane);
+}
+
/* ~~~~~~~~~~~~~~~~~~~~Non Uniform Rational B Spline calculations ~~~~~~~~~~~ */
@@ -1595,7 +1622,7 @@ float *BKE_curve_surf_make_orco(Object *ob)
/* NOTE: This routine is tied to the order of vertex
* built by displist and as passed to the renderer.
*/
-float *BKE_curve_make_orco(Scene *scene, Object *ob, int *r_numVerts)
+float *BKE_curve_make_orco(const EvaluationContext *eval_ctx, Scene *scene, Object *ob, int *r_numVerts)
{
Curve *cu = ob->data;
DispList *dl;
@@ -1603,7 +1630,7 @@ float *BKE_curve_make_orco(Scene *scene, Object *ob, int *r_numVerts)
float *fp, *coord_array;
ListBase disp = {NULL, NULL};
- BKE_displist_make_curveTypes_forOrco(scene, ob, &disp);
+ BKE_displist_make_curveTypes_forOrco(eval_ctx, scene, ob, &disp);
numVerts = 0;
for (dl = disp.first; dl; dl = dl->next) {
@@ -1694,8 +1721,9 @@ float *BKE_curve_make_orco(Scene *scene, Object *ob, int *r_numVerts)
/* ***************** BEVEL ****************** */
-void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp,
- const bool for_render, const bool use_render_resolution)
+void BKE_curve_bevel_make(
+ const EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *disp,
+ const bool for_render, const bool use_render_resolution)
{
DispList *dl, *dlnew;
Curve *bevcu, *cu;
@@ -1719,7 +1747,7 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp,
facy = cu->bevobj->size[1];
if (for_render) {
- BKE_displist_make_curveTypes_forRender(scene, cu->bevobj, &bevdisp, NULL, false, use_render_resolution);
+ BKE_displist_make_curveTypes_forRender(eval_ctx, scene, cu->bevobj, &bevdisp, NULL, false, use_render_resolution);
dl = bevdisp.first;
}
else if (cu->bevobj->curve_cache) {
@@ -4016,7 +4044,7 @@ bool BKE_nurb_check_valid_u(struct Nurb *nu)
return true; /* not a nurb, lets assume its valid */
if (nu->pntsu < nu->orderu) return false;
- if (((nu->flag & CU_NURB_CYCLIC) == 0) && (nu->flagu & CU_NURB_BEZIER)) { /* Bezier U Endpoints */
+ if (((nu->flagu & CU_NURB_CYCLIC) == 0) && (nu->flagu & CU_NURB_BEZIER)) { /* Bezier U Endpoints */
if (nu->orderu == 4) {
if (nu->pntsu < 5)
return false; /* bezier with 4 orderu needs 5 points */
@@ -4037,7 +4065,7 @@ bool BKE_nurb_check_valid_v(struct Nurb *nu)
if (nu->pntsv < nu->orderv)
return false;
- if (((nu->flag & CU_NURB_CYCLIC) == 0) && (nu->flagv & CU_NURB_BEZIER)) { /* Bezier V Endpoints */
+ if (((nu->flagv & CU_NURB_CYCLIC) == 0) && (nu->flagv & CU_NURB_BEZIER)) { /* Bezier V Endpoints */
if (nu->orderv == 4) {
if (nu->pntsv < 5)
return false; /* bezier with 4 orderu needs 5 points */
@@ -4419,7 +4447,9 @@ bool BKE_curve_center_bounds(Curve *cu, float cent[3])
}
-void BKE_curve_transform_ex(Curve *cu, float mat[4][4], const bool do_keys, const float unit_scale)
+void BKE_curve_transform_ex(
+ Curve *cu, float mat[4][4],
+ const bool do_keys, const bool do_props, const float unit_scale)
{
Nurb *nu;
BPoint *bp;
@@ -4433,7 +4463,9 @@ void BKE_curve_transform_ex(Curve *cu, float mat[4][4], const bool do_keys, cons
mul_m4_v3(mat, bezt->vec[0]);
mul_m4_v3(mat, bezt->vec[1]);
mul_m4_v3(mat, bezt->vec[2]);
- bezt->radius *= unit_scale;
+ if (do_props) {
+ bezt->radius *= unit_scale;
+ }
}
BKE_nurb_handles_calc(nu);
}
@@ -4441,7 +4473,9 @@ void BKE_curve_transform_ex(Curve *cu, float mat[4][4], const bool do_keys, cons
i = nu->pntsu * nu->pntsv;
for (bp = nu->bp; i--; bp++) {
mul_m4_v3(mat, bp->vec);
- bp->radius *= unit_scale;
+ if (do_props) {
+ bp->radius *= unit_scale;
+ }
}
}
}
@@ -4457,10 +4491,12 @@ void BKE_curve_transform_ex(Curve *cu, float mat[4][4], const bool do_keys, cons
}
}
-void BKE_curve_transform(Curve *cu, float mat[4][4], const bool do_keys)
+void BKE_curve_transform(
+ Curve *cu, float mat[4][4],
+ const bool do_keys, const bool do_props)
{
float unit_scale = mat4_to_scale(mat);
- BKE_curve_transform_ex(cu, mat, do_keys, unit_scale);
+ BKE_curve_transform_ex(cu, mat, do_keys, do_props, unit_scale);
}
void BKE_curve_translate(Curve *cu, float offset[3], const bool do_keys)
@@ -4639,7 +4675,7 @@ void BKE_curve_rect_from_textbox(const struct Curve *cu, const struct TextBox *t
/* **** Depsgraph evaluation **** */
-void BKE_curve_eval_geometry(EvaluationContext *UNUSED(eval_ctx),
+void BKE_curve_eval_geometry(const EvaluationContext *UNUSED(eval_ctx),
Curve *curve)
{
if (G.debug & G_DEBUG_DEPSGRAPH) {
@@ -4650,17 +4686,6 @@ void BKE_curve_eval_geometry(EvaluationContext *UNUSED(eval_ctx),
}
}
-void BKE_curve_eval_path(EvaluationContext *UNUSED(eval_ctx),
- Curve *curve)
-{
- /* TODO(sergey): This will probably need to be a part of
- * the modifier stack still.
- */
- if (G.debug & G_DEBUG_DEPSGRAPH) {
- printf("%s on %s\n", __func__, curve->id.name);
- }
-}
-
/* Draw Engine */
void (*BKE_curve_batch_cache_dirty_cb)(Curve *cu, int mode) = NULL;
void (*BKE_curve_batch_cache_free_cb)(Curve *cu) = NULL;
@@ -4676,4 +4701,4 @@ void BKE_curve_batch_cache_free(Curve *cu)
if (cu->batch_cache) {
BKE_curve_batch_cache_free_cb(cu);
}
-} \ No newline at end of file
+}
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 3ccf619fd11..3bf5784e674 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -810,10 +810,10 @@ static void layerInterp_mloopcol(
* although weights should also not cause this situation */
/* also delay writing to the destination incase dest is in sources */
- mc->r = CLAMPIS(iroundf(col.r), 0, 255);
- mc->g = CLAMPIS(iroundf(col.g), 0, 255);
- mc->b = CLAMPIS(iroundf(col.b), 0, 255);
- mc->a = CLAMPIS(iroundf(col.a), 0, 255);
+ mc->r = round_fl_to_uchar_clamp(col.r);
+ mc->g = round_fl_to_uchar_clamp(col.g);
+ mc->b = round_fl_to_uchar_clamp(col.b);
+ mc->a = round_fl_to_uchar_clamp(col.a);
}
static int layerMaxNum_mloopcol(void)
@@ -1036,10 +1036,10 @@ static void layerInterp_mcol(
/* Subdivide smooth or fractal can cause problems without clamping
* although weights should also not cause this situation */
- mc[j].a = CLAMPIS(iroundf(col[j].a), 0, 255);
- mc[j].r = CLAMPIS(iroundf(col[j].r), 0, 255);
- mc[j].g = CLAMPIS(iroundf(col[j].g), 0, 255);
- mc[j].b = CLAMPIS(iroundf(col[j].b), 0, 255);
+ mc[j].a = round_fl_to_uchar_clamp(col[j].a);
+ mc[j].r = round_fl_to_uchar_clamp(col[j].r);
+ mc[j].g = round_fl_to_uchar_clamp(col[j].g);
+ mc[j].b = round_fl_to_uchar_clamp(col[j].b);
}
}
@@ -1344,7 +1344,7 @@ const CustomDataMask CD_MASK_BMESH =
CD_MASK_PROP_STR | CD_MASK_SHAPEKEY | CD_MASK_SHAPE_KEYINDEX | CD_MASK_MDISPS |
CD_MASK_CREASE | CD_MASK_BWEIGHT | CD_MASK_RECAST | CD_MASK_PAINT_MASK |
CD_MASK_GRID_PAINT_MASK | CD_MASK_MVERT_SKIN | CD_MASK_FREESTYLE_EDGE | CD_MASK_FREESTYLE_FACE |
- CD_MASK_CUSTOMLOOPNORMAL | CD_MASK_FACEMAP;
+ CD_MASK_CUSTOMLOOPNORMAL | CD_MASK_FACEMAP;
/**
* cover values copied by #BKE_mesh_loops_to_tessdata
*/
diff --git a/source/blender/blenkernel/intern/data_transfer.c b/source/blender/blenkernel/intern/data_transfer.c
index a83ec8f0486..00b8063110d 100644
--- a/source/blender/blenkernel/intern/data_transfer.c
+++ b/source/blender/blenkernel/intern/data_transfer.c
@@ -1010,7 +1010,8 @@ static bool data_transfer_layersmapping_generate(
* to get (as much as possible) exact copy of source data layout.
*/
void BKE_object_data_transfer_layout(
- Scene *scene, Object *ob_src, Object *ob_dst, const int data_types, const bool use_delete,
+ const struct EvaluationContext *eval_ctx, Scene *scene,
+ Object *ob_src, Object *ob_dst, const int data_types, const bool use_delete,
const int fromlayers_select[DT_MULTILAYER_INDEX_MAX], const int tolayers_select[DT_MULTILAYER_INDEX_MAX])
{
DerivedMesh *dm_src;
@@ -1027,7 +1028,7 @@ void BKE_object_data_transfer_layout(
/* Get source DM.*/
dm_src_mask |= BKE_object_data_transfer_dttypes_to_cdmask(data_types);
- dm_src = mesh_get_derived_final(scene, ob_src, dm_src_mask);
+ dm_src = mesh_get_derived_final(eval_ctx, scene, ob_src, dm_src_mask);
if (!dm_src) {
return;
}
@@ -1085,9 +1086,9 @@ void BKE_object_data_transfer_layout(
}
bool BKE_object_data_transfer_dm(
- Scene *scene, Object *ob_src, Object *ob_dst, DerivedMesh *dm_dst, const int data_types, bool use_create,
- const int map_vert_mode, const int map_edge_mode, const int map_loop_mode, const int map_poly_mode,
- SpaceTransform *space_transform, const bool auto_transform,
+ const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob_src, Object *ob_dst, DerivedMesh *dm_dst,
+ const int data_types, bool use_create, const int map_vert_mode, const int map_edge_mode,
+ const int map_loop_mode, const int map_poly_mode, SpaceTransform *space_transform, const bool auto_transform,
const float max_distance, const float ray_radius, const float islands_handling_precision,
const int fromlayers_select[DT_MULTILAYER_INDEX_MAX], const int tolayers_select[DT_MULTILAYER_INDEX_MAX],
const int mix_mode, const float mix_factor, const char *vgroup_name, const bool invert_vgroup,
@@ -1149,7 +1150,7 @@ bool BKE_object_data_transfer_dm(
* Also, we need to make a local copy of dm_src, otherwise we may end with concurrent creation
* of data in it (multi-threaded evaluation of the modifier stack, see T46672).
*/
- dm_src = dm_dst ? ob_src->derivedFinal : mesh_get_derived_final(scene, ob_src, dm_src_mask);
+ dm_src = dm_dst ? ob_src->derivedFinal : mesh_get_derived_final(eval_ctx, scene, ob_src, dm_src_mask);
if (!dm_src) {
return changed;
}
@@ -1457,16 +1458,16 @@ bool BKE_object_data_transfer_dm(
}
bool BKE_object_data_transfer_mesh(
- Scene *scene, Object *ob_src, Object *ob_dst, const int data_types, const bool use_create,
- const int map_vert_mode, const int map_edge_mode, const int map_loop_mode, const int map_poly_mode,
- SpaceTransform *space_transform, const bool auto_transform,
+ const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob_src, Object *ob_dst, const int data_types,
+ const bool use_create, const int map_vert_mode, const int map_edge_mode, const int map_loop_mode,
+ const int map_poly_mode, SpaceTransform *space_transform, const bool auto_transform,
const float max_distance, const float ray_radius, const float islands_handling_precision,
const int fromlayers_select[DT_MULTILAYER_INDEX_MAX], const int tolayers_select[DT_MULTILAYER_INDEX_MAX],
const int mix_mode, const float mix_factor, const char *vgroup_name, const bool invert_vgroup,
ReportList *reports)
{
return BKE_object_data_transfer_dm(
- scene, ob_src, ob_dst, NULL, data_types, use_create,
+ eval_ctx, scene, ob_src, ob_dst, NULL, data_types, use_create,
map_vert_mode, map_edge_mode, map_loop_mode, map_poly_mode,
space_transform, auto_transform,
max_distance, ray_radius, islands_handling_precision,
diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c
index 9f0024c01fd..1fc83b69bfe 100644
--- a/source/blender/blenkernel/intern/deform.c
+++ b/source/blender/blenkernel/intern/deform.c
@@ -74,7 +74,7 @@ bDeformGroup *BKE_defgroup_new(Object *ob, const char *name)
BLI_addtail(&ob->defbase, defgroup);
defgroup_unique_name(defgroup, ob);
- BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_PAINT);
+ BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_ALL);
return defgroup;
}
@@ -624,8 +624,17 @@ float defvert_find_weight(const struct MDeformVert *dvert, const int defgroup)
*/
float defvert_array_find_weight_safe(const struct MDeformVert *dvert, const int index, const int defgroup)
{
- if (defgroup == -1 || dvert == NULL)
+ /* Invalid defgroup index means the vgroup selected is invalid, does not exist, in that case it is OK to return 1.0
+ * (i.e. maximum weight, as if no vgroup was selected).
+ * But in case of valid defgroup and NULL dvert data pointer, it means that vgroup **is** valid,
+ * and just totally empty, so we shall return '0.0' value then!
+ */
+ if (defgroup == -1) {
return 1.0f;
+ }
+ else if (dvert == NULL) {
+ return 0.0f;
+ }
return defvert_find_weight(dvert + index, defgroup);
}
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index 44f284d043e..8316d68b35c 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -678,7 +678,7 @@ static void curve_to_filledpoly(Curve *cu, ListBase *UNUSED(nurb), ListBase *dis
* - first point left, last point right
* - based on subdivided points in original curve, not on points in taper curve (still)
*/
-static float displist_calc_taper(Scene *scene, Object *taperobj, float fac)
+static float displist_calc_taper(const EvaluationContext *eval_ctx, Scene *scene, Object *taperobj, float fac)
{
DispList *dl;
@@ -687,7 +687,7 @@ static float displist_calc_taper(Scene *scene, Object *taperobj, float fac)
dl = taperobj->curve_cache ? taperobj->curve_cache->disp.first : NULL;
if (dl == NULL) {
- BKE_displist_make_curveTypes(scene, taperobj, 0);
+ BKE_displist_make_curveTypes(eval_ctx, scene, taperobj, 0);
dl = taperobj->curve_cache->disp.first;
}
if (dl) {
@@ -718,14 +718,14 @@ static float displist_calc_taper(Scene *scene, Object *taperobj, float fac)
return 1.0;
}
-float BKE_displist_calc_taper(Scene *scene, Object *taperobj, int cur, int tot)
+float BKE_displist_calc_taper(const EvaluationContext *eval_ctx, Scene *scene, Object *taperobj, int cur, int tot)
{
float fac = ((float)cur) / (float)(tot - 1);
- return displist_calc_taper(scene, taperobj, fac);
+ return displist_calc_taper(eval_ctx, scene, taperobj, fac);
}
-void BKE_displist_make_mball(EvaluationContext *eval_ctx, Scene *scene, Object *ob)
+void BKE_displist_make_mball(const EvaluationContext *eval_ctx, Scene *scene, Object *ob)
{
if (!ob || ob->type != OB_MBALL)
return;
@@ -748,7 +748,7 @@ void BKE_displist_make_mball(EvaluationContext *eval_ctx, Scene *scene, Object *
}
}
-void BKE_displist_make_mball_forRender(EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *dispbase)
+void BKE_displist_make_mball_forRender(const EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *dispbase)
{
BKE_mball_polygonize(eval_ctx, scene, ob, dispbase);
BKE_mball_texspace_calc(ob);
@@ -798,8 +798,9 @@ static ModifierData *curve_get_tessellate_point(Scene *scene, Object *ob,
return pretessellatePoint;
}
-static void curve_calc_modifiers_pre(Scene *scene, Object *ob, ListBase *nurb,
- const bool for_render, const bool use_render_resolution)
+static void curve_calc_modifiers_pre(
+ const EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *nurb,
+ const bool for_render, const bool use_render_resolution)
{
VirtualModifierData virtualModifierData;
ModifierData *md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
@@ -856,7 +857,7 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, ListBase *nurb,
deformedVerts = BKE_curve_nurbs_vertexCos_get(nurb, &numVerts);
}
- mti->deformVerts(md, ob, NULL, deformedVerts, numVerts, app_flag);
+ mti->deformVerts(md, eval_ctx, ob, NULL, deformedVerts, numVerts, app_flag);
if (md == pretessellatePoint)
break;
@@ -908,9 +909,10 @@ static void displist_apply_allverts(ListBase *dispbase, float (*allverts)[3])
}
}
-static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *nurb,
- ListBase *dispbase, DerivedMesh **r_dm_final,
- const bool for_render, const bool use_render_resolution)
+static void curve_calc_modifiers_post(
+ const EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *nurb,
+ ListBase *dispbase, DerivedMesh **r_dm_final,
+ const bool for_render, const bool use_render_resolution)
{
VirtualModifierData virtualModifierData;
ModifierData *md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
@@ -964,14 +966,14 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *nurb,
dm->getVertCos(dm, vertCos);
}
- mti->deformVerts(md, ob, dm, vertCos, totvert, appf);
+ mti->deformVerts(md, eval_ctx, ob, dm, vertCos, totvert, appf);
}
else {
if (!vertCos) {
vertCos = displist_get_allverts(dispbase, &totvert);
}
- mti->deformVerts(md, ob, NULL, vertCos, totvert, appf);
+ mti->deformVerts(md, eval_ctx, ob, NULL, vertCos, totvert, appf);
}
}
else {
@@ -1013,7 +1015,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *nurb,
if (useCache)
appf |= MOD_APPLY_USECACHE;
- ndm = modwrap_applyModifier(md, ob, dm, appf);
+ ndm = modwrap_applyModifier(md, eval_ctx, ob, dm, appf);
if (ndm) {
/* Modifier returned a new derived mesh */
@@ -1090,13 +1092,13 @@ static void displist_surf_indices(DispList *dl)
}
}
-static DerivedMesh *create_orco_dm(Scene *scene, Object *ob)
+static DerivedMesh *create_orco_dm(const EvaluationContext *eval_ctx, Scene *scene, Object *ob)
{
DerivedMesh *dm;
ListBase disp = {NULL, NULL};
/* OrcoDM should be created from underformed disp lists */
- BKE_displist_make_curveTypes_forOrco(scene, ob, &disp);
+ BKE_displist_make_curveTypes_forOrco(eval_ctx, scene, ob, &disp);
dm = CDDM_from_curve_displist(ob, &disp);
BKE_displist_free(&disp);
@@ -1134,8 +1136,9 @@ static void add_orco_dm(Object *ob, DerivedMesh *dm, DerivedMesh *orcodm)
DM_add_vert_layer(dm, CD_ORCO, CD_ASSIGN, orco);
}
-static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *dm_final,
- const bool for_render, const bool use_render_resolution)
+static void curve_calc_orcodm(
+ const EvaluationContext *eval_ctx, Scene *scene, Object *ob, DerivedMesh *dm_final,
+ const bool for_render, const bool use_render_resolution)
{
/* this function represents logic of mesh's orcodm calculation
* for displist-based objects
@@ -1172,7 +1175,7 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *dm_final,
* This means we can create ORCO DM in advance and assume it's
* never NULL.
*/
- orcodm = create_orco_dm(scene, ob);
+ orcodm = create_orco_dm(eval_ctx, scene, ob);
for (; md; md = md->next) {
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
@@ -1184,7 +1187,7 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *dm_final,
if (mti->type != eModifierTypeType_Constructive)
continue;
- ndm = modwrap_applyModifier(md, ob, orcodm, app_flag);
+ ndm = modwrap_applyModifier(md, eval_ctx, ob, orcodm, app_flag);
if (ndm) {
/* if the modifier returned a new dm, release the old one */
@@ -1201,9 +1204,10 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *dm_final,
orcodm->release(orcodm);
}
-void BKE_displist_make_surf(Scene *scene, Object *ob, ListBase *dispbase,
- DerivedMesh **r_dm_final,
- const bool for_render, const bool for_orco, const bool use_render_resolution)
+void BKE_displist_make_surf(
+ const EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *dispbase,
+ DerivedMesh **r_dm_final,
+ const bool for_render, const bool for_orco, const bool use_render_resolution)
{
ListBase nubase = {NULL, NULL};
Nurb *nu;
@@ -1220,7 +1224,7 @@ void BKE_displist_make_surf(Scene *scene, Object *ob, ListBase *dispbase,
}
if (!for_orco)
- curve_calc_modifiers_pre(scene, ob, &nubase, for_render, use_render_resolution);
+ curve_calc_modifiers_pre(eval_ctx, scene, ob, &nubase, for_render, use_render_resolution);
for (nu = nubase.first; nu; nu = nu->next) {
if ((for_render || nu->hide == 0) && BKE_nurb_check_valid_uv(nu)) {
@@ -1287,7 +1291,7 @@ void BKE_displist_make_surf(Scene *scene, Object *ob, ListBase *dispbase,
if (!for_orco) {
BKE_nurbList_duplicate(&ob->curve_cache->deformed_nurbs, &nubase);
- curve_calc_modifiers_post(scene, ob, &nubase, dispbase, r_dm_final,
+ curve_calc_modifiers_post(eval_ctx, scene, ob, &nubase, dispbase, r_dm_final,
for_render, use_render_resolution);
}
@@ -1513,9 +1517,10 @@ static void calc_bevfac_mapping(Curve *cu, BevList *bl, Nurb *nu,
}
}
-static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispbase,
- DerivedMesh **r_dm_final,
- const bool for_render, const bool for_orco, const bool use_render_resolution)
+static void do_makeDispListCurveTypes(
+ const EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *dispbase,
+ DerivedMesh **r_dm_final,
+ const bool for_render, const bool for_orco, const bool use_render_resolution)
{
Curve *cu = ob->data;
@@ -1523,7 +1528,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
if (!ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT)) return;
if (ob->type == OB_SURF) {
- BKE_displist_make_surf(scene, ob, dispbase, r_dm_final, for_render, for_orco, use_render_resolution);
+ BKE_displist_make_surf(eval_ctx, scene, ob, dispbase, r_dm_final, for_render, for_orco, use_render_resolution);
}
else if (ELEM(ob->type, OB_CURVE, OB_FONT)) {
ListBase dlbev;
@@ -1548,12 +1553,12 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
}
if (!for_orco)
- curve_calc_modifiers_pre(scene, ob, &nubase, for_render, use_render_resolution);
+ curve_calc_modifiers_pre(eval_ctx, scene, ob, &nubase, for_render, use_render_resolution);
BKE_curve_bevelList_make(ob, &nubase, for_render != false);
/* If curve has no bevel will return nothing */
- BKE_curve_bevel_make(scene, ob, &dlbev, for_render, use_render_resolution);
+ BKE_curve_bevel_make(eval_ctx, scene, ob, &dlbev, for_render, use_render_resolution);
/* no bevel or extrude, and no width correction? */
if (!dlbev.first && cu->width == 1.0f) {
@@ -1688,7 +1693,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
taper_fac -= (1.0f - lastblend) / len;
}
- fac = displist_calc_taper(scene, cu->taperobj, taper_fac);
+ fac = displist_calc_taper(eval_ctx, scene, cu->taperobj, taper_fac);
}
if (bevp->split_tag) {
@@ -1740,8 +1745,9 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
}
if (!for_orco) {
+ /* TODO(sergey): How do we get depsgraph here? */
if ((cu->flag & CU_PATH) ||
- DEG_get_eval_flags_for_id(scene->depsgraph, &ob->id) & DAG_EVAL_NEED_CURVE_PATH)
+ DEG_get_eval_flags_for_id(scene->depsgraph_legacy, &ob->id) & DAG_EVAL_NEED_CURVE_PATH)
{
calc_curvepath(ob, &nubase);
}
@@ -1749,7 +1755,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
if (!for_orco) {
BKE_nurbList_duplicate(&ob->curve_cache->deformed_nurbs, &nubase);
- curve_calc_modifiers_post(scene, ob, &nubase, dispbase, r_dm_final, for_render, use_render_resolution);
+ curve_calc_modifiers_post(eval_ctx, scene, ob, &nubase, dispbase, r_dm_final, for_render, use_render_resolution);
}
if (cu->flag & CU_DEFORM_FILL && !ob->derivedFinal) {
@@ -1760,7 +1766,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
}
}
-void BKE_displist_make_curveTypes(Scene *scene, Object *ob, const bool for_orco)
+void BKE_displist_make_curveTypes(const EvaluationContext *eval_ctx, Scene *scene, Object *ob, const bool for_orco)
{
ListBase *dispbase;
@@ -1778,35 +1784,38 @@ void BKE_displist_make_curveTypes(Scene *scene, Object *ob, const bool for_orco)
dispbase = &(ob->curve_cache->disp);
- do_makeDispListCurveTypes(scene, ob, dispbase, &ob->derivedFinal, 0, for_orco, 0);
+ do_makeDispListCurveTypes(eval_ctx, scene, ob, dispbase, &ob->derivedFinal, 0, for_orco, 0);
boundbox_displist_object(ob);
}
-void BKE_displist_make_curveTypes_forRender(Scene *scene, Object *ob, ListBase *dispbase,
- DerivedMesh **r_dm_final, const bool for_orco,
- const bool use_render_resolution)
+void BKE_displist_make_curveTypes_forRender(
+ const EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *dispbase,
+ DerivedMesh **r_dm_final, const bool for_orco,
+ const bool use_render_resolution)
{
if (ob->curve_cache == NULL) {
ob->curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for Curve");
}
- do_makeDispListCurveTypes(scene, ob, dispbase, r_dm_final, true, for_orco, use_render_resolution);
+ do_makeDispListCurveTypes(eval_ctx, scene, ob, dispbase, r_dm_final, true, for_orco, use_render_resolution);
}
-void BKE_displist_make_curveTypes_forOrco(struct Scene *scene, struct Object *ob, struct ListBase *dispbase)
+void BKE_displist_make_curveTypes_forOrco(
+ const EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *dispbase)
{
if (ob->curve_cache == NULL) {
ob->curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for Curve");
}
- do_makeDispListCurveTypes(scene, ob, dispbase, NULL, 1, 1, 1);
+ do_makeDispListCurveTypes(eval_ctx, scene, ob, dispbase, NULL, 1, 1, 1);
}
/* add Orco layer to the displist object which has got derived mesh and return orco */
-float *BKE_displist_make_orco(Scene *scene, Object *ob, DerivedMesh *dm_final,
- const bool for_render,
- const bool use_render_resolution)
+float *BKE_displist_make_orco(
+ const EvaluationContext *eval_ctx, Scene *scene, Object *ob, DerivedMesh *dm_final,
+ const bool for_render,
+ const bool use_render_resolution)
{
float *orco;
@@ -1814,7 +1823,7 @@ float *BKE_displist_make_orco(Scene *scene, Object *ob, DerivedMesh *dm_final,
dm_final = ob->derivedFinal;
if (!dm_final->getVertDataArray(dm_final, CD_ORCO)) {
- curve_calc_orcodm(scene, ob, dm_final, for_render, use_render_resolution);
+ curve_calc_orcodm(eval_ctx, scene, ob, dm_final, for_render, use_render_resolution);
}
orco = dm_final->getVertDataArray(dm_final, CD_ORCO);
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index fb5ef403218..724b30d0cb1 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -74,6 +74,8 @@
#include "BKE_scene.h"
#include "BKE_texture.h"
+#include "DEG_depsgraph.h"
+
/* for image output */
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
@@ -498,7 +500,7 @@ static int surface_getBrushFlags(DynamicPaintSurface *surface, const SceneLayer
if (surface->brush_group)
go = surface->brush_group->gobject.first;
else
- base = FIRSTBASE_NEW;
+ base = FIRSTBASE_NEW(sl);
while (base || go) {
brushObj = NULL;
@@ -1973,7 +1975,9 @@ static void canvas_copyDerivedMesh(DynamicPaintCanvasSettings *canvas, DerivedMe
/*
* Updates derived mesh copy and processes dynamic paint step / caches.
*/
-static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene, SceneLayer *sl, Object *ob, DerivedMesh *dm)
+static void dynamicPaint_frameUpdate(
+ DynamicPaintModifierData *pmd, const struct EvaluationContext *eval_ctx, Scene *scene,
+ Object *ob, DerivedMesh *dm)
{
if (pmd->canvas) {
DynamicPaintCanvasSettings *canvas = pmd->canvas;
@@ -2036,7 +2040,7 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene
else if (can_simulate) {
/* calculate surface frame */
canvas->flags |= MOD_DPAINT_BAKING;
- dynamicPaint_calculateFrame(surface, scene, sl, ob, current_frame);
+ dynamicPaint_calculateFrame(surface, eval_ctx, scene, ob, current_frame);
canvas->flags &= ~MOD_DPAINT_BAKING;
/* restore canvas derivedmesh if required */
@@ -2055,16 +2059,15 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene
}
/* Modifier call. Processes dynamic paint modifier step. */
-DerivedMesh *dynamicPaint_Modifier_do(DynamicPaintModifierData *pmd, Scene *scene, SceneLayer *sl, Object *ob, DerivedMesh *dm)
+DerivedMesh *dynamicPaint_Modifier_do(
+ DynamicPaintModifierData *pmd, const struct EvaluationContext *eval_ctx, Scene *scene,
+ Object *ob, DerivedMesh *dm)
{
if (pmd->canvas) {
DerivedMesh *ret;
- /* For now generate looptris in every case */
- DM_ensure_looptri(dm);
-
/* Update canvas data for a new frame */
- dynamicPaint_frameUpdate(pmd, scene, sl, ob, dm);
+ dynamicPaint_frameUpdate(pmd, eval_ctx, scene, ob, dm);
/* Return output mesh */
ret = dynamicPaint_Modifier_apply(pmd, ob, dm);
@@ -2072,11 +2075,8 @@ DerivedMesh *dynamicPaint_Modifier_do(DynamicPaintModifierData *pmd, Scene *scen
return ret;
}
else {
- /* For now generate looptris in every case */
- DM_ensure_looptri(dm);
-
/* Update canvas data for a new frame */
- dynamicPaint_frameUpdate(pmd, scene, sl, ob, dm);
+ dynamicPaint_frameUpdate(pmd, eval_ctx, scene, ob, dm);
/* Return output mesh */
return dynamicPaint_Modifier_apply(pmd, ob, dm);
@@ -3582,7 +3582,8 @@ static void dynamic_paint_brush_velocity_compute_cb(void *userdata, const int i)
}
static void dynamicPaint_brushMeshCalculateVelocity(
- Scene *scene, Object *ob, DynamicPaintBrushSettings *brush, Vec3f **brushVel, float timescale)
+ const struct EvaluationContext *eval_ctx, Scene *scene,
+ Object *ob, DynamicPaintBrushSettings *brush, Vec3f **brushVel, float timescale)
{
float prev_obmat[4][4];
DerivedMesh *dm_p, *dm_c;
@@ -3604,7 +3605,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(
scene->r.subframe = prev_sfra;
BKE_object_modifier_update_subframe(
- scene, ob, true, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
+ eval_ctx, scene, ob, true, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
dm_p = CDDM_copy(brush->dm);
numOfVerts_p = dm_p->getNumVerts(dm_p);
mvert_p = dm_p->getVertArray(dm_p);
@@ -3615,7 +3616,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(
scene->r.subframe = cur_sfra;
BKE_object_modifier_update_subframe(
- scene, ob, true, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
+ eval_ctx, scene, ob, true, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
dm_c = brush->dm;
numOfVerts_c = dm_c->getNumVerts(dm_c);
mvert_c = dm_p->getVertArray(dm_c);
@@ -3640,7 +3641,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(
}
/* calculate velocity for object center point */
-static void dynamicPaint_brushObjectCalculateVelocity(Scene *scene, Object *ob, Vec3f *brushVel, float timescale)
+static void dynamicPaint_brushObjectCalculateVelocity(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, Vec3f *brushVel, float timescale)
{
float prev_obmat[4][4];
float cur_loc[3] = {0.0f}, prev_loc[3] = {0.0f};
@@ -3659,14 +3660,14 @@ static void dynamicPaint_brushObjectCalculateVelocity(Scene *scene, Object *ob,
scene->r.cfra = prev_fra;
scene->r.subframe = prev_sfra;
BKE_object_modifier_update_subframe(
- scene, ob, false, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
+ eval_ctx, scene, ob, false, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
copy_m4_m4(prev_obmat, ob->obmat);
/* current frame dm */
scene->r.cfra = cur_fra;
scene->r.subframe = cur_sfra;
BKE_object_modifier_update_subframe(
- scene, ob, false, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
+ eval_ctx, scene, ob, false, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
/* calculate speed */
mul_m4_v3(prev_obmat, prev_loc);
@@ -4036,7 +4037,7 @@ static void dynamic_paint_paint_mesh_cell_point_cb_ex(
}
}
-static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
+static int dynamicPaint_paintMesh(const struct EvaluationContext *eval_ctx, DynamicPaintSurface *surface,
DynamicPaintBrushSettings *brush,
Object *brushOb,
BrushMaterials *bMats,
@@ -4052,7 +4053,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
const MLoop *mloop = NULL;
if (brush->flags & MOD_DPAINT_USES_VELOCITY)
- dynamicPaint_brushMeshCalculateVelocity(scene, brushOb, brush, &brushVelocity, timescale);
+ dynamicPaint_brushMeshCalculateVelocity(eval_ctx, scene, brushOb, brush, &brushVelocity, timescale);
if (!brush->dm)
return 0;
@@ -4530,7 +4531,7 @@ static void dynamic_paint_paint_single_point_cb_ex(
}
static int dynamicPaint_paintSinglePoint(
- DynamicPaintSurface *surface, float *pointCoord, DynamicPaintBrushSettings *brush,
+ const struct EvaluationContext *eval_ctx, DynamicPaintSurface *surface, float *pointCoord, DynamicPaintBrushSettings *brush,
Object *brushOb, BrushMaterials *bMats, Scene *scene, float timescale)
{
PaintSurfaceData *sData = surface->data;
@@ -4538,7 +4539,7 @@ static int dynamicPaint_paintSinglePoint(
Vec3f brushVel;
if (brush->flags & MOD_DPAINT_USES_VELOCITY)
- dynamicPaint_brushObjectCalculateVelocity(scene, brushOb, &brushVel, timescale);
+ dynamicPaint_brushObjectCalculateVelocity(eval_ctx, scene, brushOb, &brushVel, timescale);
const MVert *mvert = brush->dm->getVertArray(brush->dm);
@@ -4845,7 +4846,7 @@ static void dynamic_paint_prepare_effect_cb(void *userdata, const int index)
}
static int dynamicPaint_prepareEffectStep(
- DynamicPaintSurface *surface, Scene *scene, Object *ob, float **force, float timescale)
+ const struct EvaluationContext *eval_ctx, DynamicPaintSurface *surface, Scene *scene, Object *ob, float **force, float timescale)
{
double average_force = 0.0f;
float shrink_speed = 0.0f, spread_speed = 0.0f;
@@ -4856,7 +4857,7 @@ static int dynamicPaint_prepareEffectStep(
/* Init force data if required */
if (surface->effect & MOD_DPAINT_EFFECT_DO_DRIP) {
- ListBase *effectors = pdInitEffectors(scene, ob, NULL, surface->effector_weights, true);
+ ListBase *effectors = pdInitEffectors(eval_ctx, scene, ob, NULL, surface->effector_weights, true);
/* allocate memory for force data (dir vector + strength) */
*force = MEM_mallocN(sData->total_points * 4 * sizeof(float), "PaintEffectForces");
@@ -5758,7 +5759,7 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, const Sce
/*
* Do Dynamic Paint step. Paints scene brush objects of current state/frame to the surface.
*/
-static int dynamicPaint_doStep(Scene *scene, SceneLayer *sl, Object *ob, DynamicPaintSurface *surface, float timescale, float subframe)
+static int dynamicPaint_doStep(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, DynamicPaintSurface *surface, float timescale, float subframe)
{
PaintSurfaceData *sData = surface->data;
PaintBakeData *bData = sData->bData;
@@ -5782,6 +5783,7 @@ static int dynamicPaint_doStep(Scene *scene, SceneLayer *sl, Object *ob, Dynamic
GroupObject *go = NULL;
Object *brushObj = NULL;
ModifierData *md = NULL;
+ SceneLayer *sl = eval_ctx->scene_layer;
/* backup current scene frame */
int scene_frame = scene->r.cfra;
@@ -5791,7 +5793,7 @@ static int dynamicPaint_doStep(Scene *scene, SceneLayer *sl, Object *ob, Dynamic
if (surface->brush_group)
go = surface->brush_group->gobject.first;
else
- base = FIRSTBASE_NEW;
+ base = FIRSTBASE_NEW(sl);
while (base || go) {
brushObj = NULL;
@@ -5836,7 +5838,7 @@ static int dynamicPaint_doStep(Scene *scene, SceneLayer *sl, Object *ob, Dynamic
/* update object data on this subframe */
if (subframe) {
scene_setSubframe(scene, subframe);
- BKE_object_modifier_update_subframe(scene, brushObj, true, SUBFRAME_RECURSION,
+ BKE_object_modifier_update_subframe(eval_ctx, scene, brushObj, true, SUBFRAME_RECURSION,
BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
}
/* Prepare materials if required */
@@ -5855,11 +5857,11 @@ static int dynamicPaint_doStep(Scene *scene, SceneLayer *sl, Object *ob, Dynamic
}
/* Object center distance: */
if (brush->collision == MOD_DPAINT_COL_POINT && brushObj != ob) {
- dynamicPaint_paintSinglePoint(surface, brushObj->loc, brush, brushObj, &bMats, scene, timescale);
+ dynamicPaint_paintSinglePoint(eval_ctx, surface, brushObj->loc, brush, brushObj, &bMats, scene, timescale);
}
/* Mesh volume/proximity: */
else if (brushObj != ob) {
- dynamicPaint_paintMesh(surface, brush, brushObj, &bMats, scene, timescale);
+ dynamicPaint_paintMesh(eval_ctx, surface, brush, brushObj, &bMats, scene, timescale);
}
/* free temp material data */
@@ -5869,7 +5871,7 @@ static int dynamicPaint_doStep(Scene *scene, SceneLayer *sl, Object *ob, Dynamic
if (subframe) {
scene->r.cfra = scene_frame;
scene->r.subframe = scene_subframe;
- BKE_object_modifier_update_subframe(scene, brushObj, true, SUBFRAME_RECURSION,
+ BKE_object_modifier_update_subframe(eval_ctx, scene, brushObj, true, SUBFRAME_RECURSION,
BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
}
@@ -5904,7 +5906,7 @@ static int dynamicPaint_doStep(Scene *scene, SceneLayer *sl, Object *ob, Dynamic
return setError(canvas, N_("Not enough free memory"));
/* Prepare effects and get number of required steps */
- steps = dynamicPaint_prepareEffectStep(surface, scene, ob, &force, timescale);
+ steps = dynamicPaint_prepareEffectStep(eval_ctx, surface, scene, ob, &force, timescale);
for (s = 0; s < steps; s++) {
dynamicPaint_doEffectStep(surface, force, prevPoint, timescale, (float)steps);
}
@@ -5928,7 +5930,9 @@ static int dynamicPaint_doStep(Scene *scene, SceneLayer *sl, Object *ob, Dynamic
/*
* Calculate a single frame and included subframes for surface
*/
-int dynamicPaint_calculateFrame(DynamicPaintSurface *surface, Scene *scene, SceneLayer *sl, Object *cObject, int frame)
+int dynamicPaint_calculateFrame(
+ DynamicPaintSurface *surface, const struct EvaluationContext *eval_ctx,
+ Scene *scene, Object *cObject, int frame)
{
float timescale = 1.0f;
@@ -5937,7 +5941,7 @@ int dynamicPaint_calculateFrame(DynamicPaintSurface *surface, Scene *scene, Scen
dynamicPaint_applySurfaceDisplace(surface, surface->canvas->dm);
/* update bake data */
- dynamicPaint_generateBakeData(surface, sl, cObject);
+ dynamicPaint_generateBakeData(surface, eval_ctx->scene_layer, cObject);
/* don't do substeps for first frame */
if (surface->substeps && (frame != surface->start_frame)) {
@@ -5946,10 +5950,10 @@ int dynamicPaint_calculateFrame(DynamicPaintSurface *surface, Scene *scene, Scen
for (st = 1; st <= surface->substeps; st++) {
float subframe = ((float) st) / (surface->substeps + 1);
- if (!dynamicPaint_doStep(scene, sl, cObject, surface, timescale, subframe))
+ if (!dynamicPaint_doStep(eval_ctx, scene, cObject, surface, timescale, subframe))
return 0;
}
}
- return dynamicPaint_doStep(scene, sl, cObject, surface, timescale, 0.0f);
+ return dynamicPaint_doStep(eval_ctx, scene, cObject, surface, timescale, 0.0f);
}
diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c
index c8ae3598097..0491cbd21f0 100644
--- a/source/blender/blenkernel/intern/editderivedmesh.c
+++ b/source/blender/blenkernel/intern/editderivedmesh.c
@@ -41,6 +41,8 @@
* is likely to be a little slow.
*/
+#include "atomic_ops.h"
+
#include "BLI_math.h"
#include "BLI_jitter.h"
#include "BLI_bitmap.h"
@@ -279,8 +281,9 @@ static void emDM_recalcLoopTri(DerivedMesh *dm)
int i;
DM_ensure_looptri_data(dm);
- mlooptri = dm->looptris.array;
+ mlooptri = dm->looptris.array_wip;
+ BLI_assert(tottri == 0 || mlooptri != NULL);
BLI_assert(poly_to_tri_count(dm->numPolyData, dm->numLoopData) == dm->looptris.num);
BLI_assert(tottri == dm->looptris.num);
@@ -297,18 +300,10 @@ static void emDM_recalcLoopTri(DerivedMesh *dm)
BM_elem_index_get(ltri[2]));
lt->poly = BM_elem_index_get(ltri[0]->f);
}
-}
-
-static const MLoopTri *emDM_getLoopTriArray(DerivedMesh *dm)
-{
- if (dm->looptris.array) {
- BLI_assert(poly_to_tri_count(dm->numPolyData, dm->numLoopData) == dm->looptris.num);
- }
- else {
- dm->recalcLoopTri(dm);
- }
- return dm->looptris.array;
+ BLI_assert(dm->looptris.array == NULL);
+ atomic_cas_ptr((void **)&dm->looptris.array, dm->looptris.array, dm->looptris.array_wip);
+ dm->looptris.array_wip = NULL;
}
static void emDM_foreachMappedVert(
@@ -1639,8 +1634,6 @@ DerivedMesh *getEditDerivedBMesh(
bmdm->dm.getNumLoops = emDM_getNumLoops;
bmdm->dm.getNumPolys = emDM_getNumPolys;
- bmdm->dm.getLoopTriArray = emDM_getLoopTriArray;
-
bmdm->dm.getVert = emDM_getVert;
bmdm->dm.getVertCo = emDM_getVertCo;
bmdm->dm.getVertNo = emDM_getVertNo;
@@ -2018,7 +2011,7 @@ static void statvis_calc_distort(
vertexCos[BM_elem_index_get(l_iter->next->v)]);
}
else {
- BM_loop_calc_face_normal(l_iter, no_corner);
+ BM_loop_calc_face_normal_safe(l_iter, no_corner);
}
/* simple way to detect (what is most likely) concave */
if (dot_v3v3(f_no, no_corner) < 0.0f) {
@@ -2183,14 +2176,14 @@ static void cage_mapped_verts_callback(
}
}
-float (*BKE_editmesh_vertexCos_get(BMEditMesh *em, Scene *scene, int *r_numVerts))[3]
+float (*BKE_editmesh_vertexCos_get(const struct EvaluationContext *eval_ctx, BMEditMesh *em, Scene *scene, int *r_numVerts))[3]
{
DerivedMesh *cage, *final;
BLI_bitmap *visit_bitmap;
struct CageUserData data;
float (*cos_cage)[3];
- cage = editbmesh_get_derived_cage_and_final(scene, em->ob, em, CD_MASK_BAREMESH, &final);
+ cage = editbmesh_get_derived_cage_and_final(eval_ctx, scene, em->ob, em, CD_MASK_BAREMESH, &final);
cos_cage = MEM_callocN(sizeof(*cos_cage) * em->bm->totvert, "bmbvh cos_cage");
/* when initializing cage verts, we only want the first cage coordinate for each vertex,
diff --git a/source/blender/blenkernel/intern/editmesh_tangent.c b/source/blender/blenkernel/intern/editmesh_tangent.c
index b04fc753f7a..f725a1793b4 100644
--- a/source/blender/blenkernel/intern/editmesh_tangent.c
+++ b/source/blender/blenkernel/intern/editmesh_tangent.c
@@ -283,33 +283,36 @@ void BKE_editmesh_loop_tangent_calc(
/* result */
CustomData *loopdata_out,
const uint loopdata_out_len,
- char *tangent_mask_curr_p)
+ short *tangent_mask_curr_p)
{
BMesh *bm = em->bm;
- BLI_assert(CustomData_number_of_layers(&bm->ldata, CD_MLOOPUV) != 0);
-
int act_uv_n = -1;
int ren_uv_n = -1;
bool calc_act = false;
bool calc_ren = false;
char act_uv_name[MAX_NAME];
char ren_uv_name[MAX_NAME];
- char tangent_mask = 0;
- char tangent_mask_curr = *tangent_mask_curr_p;
+ short tangent_mask = 0;
+ short tangent_mask_curr = *tangent_mask_curr_p;
BKE_mesh_calc_loop_tangent_step_0(
&bm->ldata, calc_active_tangent, tangent_names, tangent_names_len,
&calc_act, &calc_ren, &act_uv_n, &ren_uv_n, act_uv_name, ren_uv_name, &tangent_mask);
if ((tangent_mask_curr | tangent_mask) != tangent_mask_curr) {
- for (int i = 0; i < tangent_names_len; i++)
- if (tangent_names[i][0])
- BKE_mesh_add_loop_tangent_named_layer_for_uv(&bm->ldata, loopdata_out, loopdata_out_len, tangent_names[i]);
+ for (int i = 0; i < tangent_names_len; i++) {
+ if (tangent_names[i][0]) {
+ BKE_mesh_add_loop_tangent_named_layer_for_uv(
+ &bm->ldata, loopdata_out, (int)loopdata_out_len, tangent_names[i]);
+ }
+ }
+ if ((tangent_mask & DM_TANGENT_MASK_ORCO) && CustomData_get_named_layer_index(loopdata_out, CD_TANGENT, "") == -1)
+ CustomData_add_layer_named(loopdata_out, CD_TANGENT, CD_CALLOC, NULL, (int)loopdata_out_len, "");
if (calc_act && act_uv_name[0])
- BKE_mesh_add_loop_tangent_named_layer_for_uv(&bm->ldata, loopdata_out, loopdata_out_len, act_uv_name);
+ BKE_mesh_add_loop_tangent_named_layer_for_uv(&bm->ldata, loopdata_out, (int)loopdata_out_len, act_uv_name);
if (calc_ren && ren_uv_name[0])
- BKE_mesh_add_loop_tangent_named_layer_for_uv(&bm->ldata, loopdata_out, loopdata_out_len, ren_uv_name);
+ BKE_mesh_add_loop_tangent_named_layer_for_uv(&bm->ldata, loopdata_out, (int)loopdata_out_len, ren_uv_name);
int totface = em->tottri;
#ifdef USE_LOOPTRI_DETECT_QUADS
int num_face_as_quad_map;
@@ -336,7 +339,7 @@ void BKE_editmesh_loop_tangent_calc(
}
#endif
/* Calculation */
- {
+ if (em->tottri != 0) {
TaskScheduler *scheduler = BLI_task_scheduler_get();
TaskPool *task_pool;
task_pool = BLI_task_pool_create(scheduler, NULL);
@@ -372,6 +375,15 @@ void BKE_editmesh_loop_tangent_calc(
continue;
/* needed for orco lookups */
htype_index |= BM_VERT;
+ tangent_mask_curr |= DM_TANGENT_MASK_ORCO;
+ }
+ else {
+ /* Fill the resulting tangent_mask */
+ int uv_ind = CustomData_get_named_layer_index(&bm->ldata, CD_MLOOPUV, loopdata_out->layers[index].name);
+ int uv_start = CustomData_get_layer_index(&bm->ldata, CD_MLOOPUV);
+ BLI_assert(uv_ind != -1 && uv_start != -1);
+ BLI_assert(uv_ind - uv_start < MAX_MTFACE);
+ tangent_mask_curr |= 1 << (uv_ind - uv_start);
}
if (mesh2tangent->precomputedFaceNormals) {
/* needed for face normal lookups */
@@ -382,13 +394,6 @@ void BKE_editmesh_loop_tangent_calc(
mesh2tangent->looptris = (const BMLoop *(*)[3])em->looptris;
mesh2tangent->tangent = loopdata_out->layers[index].data;
- /* Fill the resulting tangent_mask */
- int uv_ind = CustomData_get_named_layer_index(
- &bm->ldata, CD_MLOOPUV, loopdata_out->layers[index].name);
- int uv_start = CustomData_get_layer_index(&bm->ldata, CD_MLOOPUV);
- BLI_assert(uv_ind != -1 && uv_start != -1);
- BLI_assert(uv_ind - uv_start < MAX_MTFACE);
- tangent_mask_curr |= 1 << (uv_ind - uv_start);
BLI_task_pool_push(task_pool, emDM_calc_loop_tangents_thread, mesh2tangent, false, TASK_PRIORITY_LOW);
}
@@ -396,6 +401,9 @@ void BKE_editmesh_loop_tangent_calc(
BLI_task_pool_work_and_wait(task_pool);
BLI_task_pool_free(task_pool);
}
+ else {
+ tangent_mask_curr = tangent_mask;
+ }
#ifdef USE_LOOPTRI_DETECT_QUADS
if (face_as_quad_map) {
MEM_freeN(face_as_quad_map);
@@ -406,15 +414,18 @@ void BKE_editmesh_loop_tangent_calc(
*tangent_mask_curr_p = tangent_mask_curr;
- /* Update active layer index */
- int uv_index = CustomData_get_layer_index_n(&bm->ldata, CD_MLOOPUV, act_uv_n);
- int tan_index = CustomData_get_named_layer_index(loopdata_out, CD_TANGENT, bm->ldata.layers[uv_index].name);
- CustomData_set_layer_active_index(loopdata_out, CD_TANGENT, tan_index);
+ int act_uv_index = CustomData_get_layer_index_n(&bm->ldata, CD_MLOOPUV, act_uv_n);
+ if (act_uv_index >= 0) {
+ int tan_index = CustomData_get_named_layer_index(loopdata_out, CD_TANGENT, bm->ldata.layers[act_uv_index].name);
+ CustomData_set_layer_active_index(loopdata_out, CD_TANGENT, tan_index);
+ } /* else tangent has been built from orco */
/* Update render layer index */
- uv_index = CustomData_get_layer_index_n(&bm->ldata, CD_MLOOPUV, ren_uv_n);
- tan_index = CustomData_get_named_layer_index(loopdata_out, CD_TANGENT, bm->ldata.layers[uv_index].name);
- CustomData_set_layer_render_index(loopdata_out, CD_TANGENT, tan_index);
+ int ren_uv_index = CustomData_get_layer_index_n(&bm->ldata, CD_MLOOPUV, ren_uv_n);
+ if (ren_uv_index >= 0) {
+ int tan_index = CustomData_get_named_layer_index(loopdata_out, CD_TANGENT, bm->ldata.layers[ren_uv_index].name);
+ CustomData_set_layer_render_index(loopdata_out, CD_TANGENT, tan_index);
+ } /* else tangent has been built from orco */
}
/** \} */ \ No newline at end of file
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index 2213094cd0b..36f7f6d604e 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -72,6 +72,7 @@
#include "BKE_scene.h"
#include "BKE_smoke.h"
+#include "DEG_depsgraph.h"
#include "RE_render_ext.h"
#include "RE_shader_ext.h"
@@ -146,9 +147,10 @@ void free_partdeflect(PartDeflect *pd)
MEM_freeN(pd);
}
-static EffectorCache *new_effector_cache(Scene *scene, Object *ob, ParticleSystem *psys, PartDeflect *pd)
+static EffectorCache *new_effector_cache(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, ParticleSystem *psys, PartDeflect *pd)
{
EffectorCache *eff = MEM_callocN(sizeof(EffectorCache), "EffectorCache");
+ eff->eval_ctx = eval_ctx;
eff->scene = scene;
eff->ob = ob;
eff->psys = psys;
@@ -156,7 +158,7 @@ static EffectorCache *new_effector_cache(Scene *scene, Object *ob, ParticleSyste
eff->frame = -1;
return eff;
}
-static void add_object_to_effectors(ListBase **effectors, Scene *scene, EffectorWeights *weights, Object *ob, Object *ob_src, bool for_simulation)
+static void add_object_to_effectors(ListBase **effectors, const struct EvaluationContext *eval_ctx, Scene *scene, EffectorWeights *weights, Object *ob, Object *ob_src, bool for_simulation)
{
EffectorCache *eff = NULL;
@@ -174,14 +176,14 @@ static void add_object_to_effectors(ListBase **effectors, Scene *scene, Effector
if (*effectors == NULL)
*effectors = MEM_callocN(sizeof(ListBase), "effectors list");
- eff = new_effector_cache(scene, ob, NULL, ob->pd);
+ eff = new_effector_cache(eval_ctx, scene, ob, NULL, ob->pd);
/* make sure imat is up to date */
invert_m4_m4(ob->imat, ob->obmat);
BLI_addtail(*effectors, eff);
}
-static void add_particles_to_effectors(ListBase **effectors, Scene *scene, EffectorWeights *weights, Object *ob, ParticleSystem *psys, ParticleSystem *psys_src, bool for_simulation)
+static void add_particles_to_effectors(ListBase **effectors, const struct EvaluationContext *eval_ctx, Scene *scene, EffectorWeights *weights, Object *ob, ParticleSystem *psys, ParticleSystem *psys_src, bool for_simulation)
{
ParticleSettings *part= psys->part;
@@ -195,25 +197,34 @@ static void add_particles_to_effectors(ListBase **effectors, Scene *scene, Effec
if (*effectors == NULL)
*effectors = MEM_callocN(sizeof(ListBase), "effectors list");
- BLI_addtail(*effectors, new_effector_cache(scene, ob, psys, part->pd));
+ BLI_addtail(*effectors, new_effector_cache(eval_ctx, scene, ob, psys, part->pd));
}
if (part->pd2 && part->pd2->forcefield && (!for_simulation || weights->weight[part->pd2->forcefield] != 0.0f)) {
if (*effectors == NULL)
*effectors = MEM_callocN(sizeof(ListBase), "effectors list");
- BLI_addtail(*effectors, new_effector_cache(scene, ob, psys, part->pd2));
+ BLI_addtail(*effectors, new_effector_cache(eval_ctx, scene, ob, psys, part->pd2));
}
}
/* returns ListBase handle with objects taking part in the effecting */
-ListBase *pdInitEffectors(Scene *scene, Object *ob_src, ParticleSystem *psys_src,
- EffectorWeights *weights, bool for_simulation)
+ListBase *pdInitEffectors(
+ const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob_src, ParticleSystem *psys_src,
+ EffectorWeights *weights, bool for_simulation)
{
- SceneLayer *sl = BKE_scene_layer_context_active(scene); /* Can't get sl from the calling modifiers yet */
+ SceneLayer *sl;
Base *base;
unsigned int layer= ob_src->lay;
ListBase *effectors = NULL;
+
+ /* eval_ctx is NULL during deg build */
+ if (eval_ctx) {
+ sl = eval_ctx->scene_layer;
+ }
+ else {
+ sl = BKE_scene_layer_context_active_PLACEHOLDER(scene);
+ }
if (weights->group) {
GroupObject *go;
@@ -221,33 +232,33 @@ ListBase *pdInitEffectors(Scene *scene, Object *ob_src, ParticleSystem *psys_src
for (go= weights->group->gobject.first; go; go= go->next) {
if ( (go->ob->lay & layer) ) {
if ( go->ob->pd && go->ob->pd->forcefield )
- add_object_to_effectors(&effectors, scene, weights, go->ob, ob_src, for_simulation);
+ add_object_to_effectors(&effectors, eval_ctx, scene, weights, go->ob, ob_src, for_simulation);
if ( go->ob->particlesystem.first ) {
ParticleSystem *psys= go->ob->particlesystem.first;
for ( ; psys; psys=psys->next )
- add_particles_to_effectors(&effectors, scene, weights, go->ob, psys, psys_src, for_simulation);
+ add_particles_to_effectors(&effectors, eval_ctx, scene, weights, go->ob, psys, psys_src, for_simulation);
}
}
}
}
else {
- for (base = FIRSTBASE_NEW; base; base = base->next) {
+ for (base = FIRSTBASE_NEW(sl); base; base = base->next) {
if ( base->object->pd && base->object->pd->forcefield )
- add_object_to_effectors(&effectors, scene, weights, base->object, ob_src, for_simulation);
+ add_object_to_effectors(&effectors, eval_ctx, scene, weights, base->object, ob_src, for_simulation);
if ( base->object->particlesystem.first ) {
ParticleSystem *psys= base->object->particlesystem.first;
for ( ; psys; psys=psys->next )
- add_particles_to_effectors(&effectors, scene, weights, base->object, psys, psys_src, for_simulation);
+ add_particles_to_effectors(&effectors, eval_ctx, scene, weights, base->object, psys, psys_src, for_simulation);
}
}
}
if (for_simulation)
- pdPrecalculateEffectors(effectors);
+ pdPrecalculateEffectors(eval_ctx, effectors);
return effectors;
}
@@ -268,7 +279,7 @@ void pdEndEffectors(ListBase **effectors)
}
}
-static void precalculate_effector(EffectorCache *eff)
+static void precalculate_effector(const struct EvaluationContext *eval_ctx, EffectorCache *eff)
{
unsigned int cfra = (unsigned int)(eff->scene->r.cfra >= 0 ? eff->scene->r.cfra : -eff->scene->r.cfra);
if (!eff->pd->rng)
@@ -280,7 +291,7 @@ static void precalculate_effector(EffectorCache *eff)
Curve *cu= eff->ob->data;
if (cu->flag & CU_PATH) {
if (eff->ob->curve_cache == NULL || eff->ob->curve_cache->path==NULL || eff->ob->curve_cache->path->data==NULL)
- BKE_displist_make_curveTypes(eff->scene, eff->ob, 0);
+ BKE_displist_make_curveTypes(eval_ctx, eff->scene, eff->ob, 0);
if (eff->ob->curve_cache->path && eff->ob->curve_cache->path->data) {
where_on_path(eff->ob, 0.0, eff->guide_loc, eff->guide_dir, NULL, &eff->guide_radius, NULL);
@@ -301,19 +312,19 @@ static void precalculate_effector(EffectorCache *eff)
if (eff->ob) {
float old_vel[3];
- BKE_object_where_is_calc_time(eff->scene, eff->ob, cfra - 1.0f);
+ BKE_object_where_is_calc_time(eval_ctx, eff->scene, eff->ob, cfra - 1.0f);
copy_v3_v3(old_vel, eff->ob->obmat[3]);
- BKE_object_where_is_calc_time(eff->scene, eff->ob, cfra);
+ BKE_object_where_is_calc_time(eval_ctx, eff->scene, eff->ob, cfra);
sub_v3_v3v3(eff->velocity, eff->ob->obmat[3], old_vel);
}
}
-void pdPrecalculateEffectors(ListBase *effectors)
+void pdPrecalculateEffectors(const struct EvaluationContext *eval_ctx, ListBase *effectors)
{
if (effectors) {
EffectorCache *eff = effectors->first;
for (; eff; eff=eff->next)
- precalculate_effector(eff);
+ precalculate_effector(eval_ctx, eff);
}
}
@@ -612,6 +623,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
}
else {
ParticleSimulationData sim= {NULL};
+ sim.eval_ctx = eff->eval_ctx;
sim.scene= eff->scene;
sim.ob= eff->ob;
sim.psys= eff->psys;
diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c
index 8247336d915..12b9abc6d03 100644
--- a/source/blender/blenkernel/intern/fluidsim.c
+++ b/source/blender/blenkernel/intern/fluidsim.c
@@ -65,7 +65,7 @@
// file handling
//-------------------------------------------------------------------------------
-void initElbeemMesh(struct Scene *scene, struct Object *ob,
+void initElbeemMesh(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
int *numVertices, float **vertices,
int *numTriangles, int **triangles,
int useGlobalCoords, int modifierIndex)
@@ -78,9 +78,7 @@ void initElbeemMesh(struct Scene *scene, struct Object *ob,
float *verts;
int *tris;
- dm = mesh_create_derived_index_render(scene, ob, CD_MASK_BAREMESH, modifierIndex);
-
- DM_ensure_looptri(dm);
+ dm = mesh_create_derived_index_render(eval_ctx, scene, ob, CD_MASK_BAREMESH, modifierIndex);
mvert = dm->getVertArray(dm);
mloop = dm->getLoopArray(dm);
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index 401fed74c52..d6b28cfaf70 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -106,6 +106,23 @@ void BKE_vfont_free(struct VFont *vf)
}
}
+void BKE_vfont_copy_data(Main *UNUSED(bmain), VFont *vfont_dst, const VFont *UNUSED(vfont_src), const int flag)
+{
+ /* We never handle usercount here for own data. */
+ const int flag_subdata = flag | LIB_ID_CREATE_NO_USER_REFCOUNT;
+
+ /* Just to be sure, should not have any value actually after reading time. */
+ vfont_dst->temp_pf = NULL;
+
+ if (vfont_dst->packedfile) {
+ vfont_dst->packedfile = dupPackedFile(vfont_dst->packedfile);
+ }
+
+ if (vfont_dst->data) {
+ vfont_dst->data = BLI_vfontdata_copy(vfont_dst->data, flag_subdata);
+ }
+}
+
static void *builtin_font_data = NULL;
static int builtin_font_size = 0;
@@ -249,7 +266,7 @@ VFont *BKE_vfont_load(Main *bmain, const char *filepath)
vfd = BLI_vfontdata_from_freetypefont(pf);
if (vfd) {
- vfont = BKE_libblock_alloc(bmain, ID_VF, filename);
+ vfont = BKE_libblock_alloc(bmain, ID_VF, filename, 0);
vfont->data = vfd;
/* if there's a font name, use it for the ID name */
diff --git a/source/blender/blenkernel/intern/freestyle.c b/source/blender/blenkernel/intern/freestyle.c
index 0a0b023df82..e45a938a4fc 100644
--- a/source/blender/blenkernel/intern/freestyle.c
+++ b/source/blender/blenkernel/intern/freestyle.c
@@ -44,7 +44,7 @@
// function declarations
static FreestyleLineSet *alloc_lineset(void);
-static void copy_lineset(FreestyleLineSet *new_lineset, FreestyleLineSet *lineset);
+static void copy_lineset(FreestyleLineSet *new_lineset, FreestyleLineSet *lineset, const int flag);
static FreestyleModuleConfig *alloc_module(void);
static void copy_module(FreestyleModuleConfig *new_module, FreestyleModuleConfig *module);
@@ -79,7 +79,7 @@ void BKE_freestyle_config_free(FreestyleConfig *config)
BLI_freelistN(&config->modules);
}
-void BKE_freestyle_config_copy(FreestyleConfig *new_config, FreestyleConfig *config)
+void BKE_freestyle_config_copy(FreestyleConfig *new_config, FreestyleConfig *config, const int flag)
{
FreestyleLineSet *lineset, *new_lineset;
FreestyleModuleConfig *module, *new_module;
@@ -93,7 +93,7 @@ void BKE_freestyle_config_copy(FreestyleConfig *new_config, FreestyleConfig *con
BLI_listbase_clear(&new_config->linesets);
for (lineset = (FreestyleLineSet *)config->linesets.first; lineset; lineset = lineset->next) {
new_lineset = alloc_lineset();
- copy_lineset(new_lineset, lineset);
+ copy_lineset(new_lineset, lineset, flag);
BLI_addtail(&new_config->linesets, (void *)new_lineset);
}
@@ -105,11 +105,9 @@ void BKE_freestyle_config_copy(FreestyleConfig *new_config, FreestyleConfig *con
}
}
-static void copy_lineset(FreestyleLineSet *new_lineset, FreestyleLineSet *lineset)
+static void copy_lineset(FreestyleLineSet *new_lineset, FreestyleLineSet *lineset, const int flag)
{
new_lineset->linestyle = lineset->linestyle;
- if (new_lineset->linestyle)
- id_us_plus(&new_lineset->linestyle->id);
new_lineset->flags = lineset->flags;
new_lineset->selection = lineset->selection;
new_lineset->qi = lineset->qi;
@@ -118,10 +116,12 @@ static void copy_lineset(FreestyleLineSet *new_lineset, FreestyleLineSet *linese
new_lineset->edge_types = lineset->edge_types;
new_lineset->exclude_edge_types = lineset->exclude_edge_types;
new_lineset->group = lineset->group;
- if (new_lineset->group) {
- id_us_plus(&new_lineset->group->id);
- }
strcpy(new_lineset->name, lineset->name);
+
+ if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
+ id_us_plus((ID *)new_lineset->linestyle);
+ id_us_plus((ID *)new_lineset->group);
+ }
}
static FreestyleModuleConfig *alloc_module(void)
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 758438bb051..ee0d0b41898 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -627,7 +627,7 @@ bGPdata *BKE_gpencil_data_addnew(const char name[])
bGPdata *gpd;
/* allocate memory for a new block */
- gpd = BKE_libblock_alloc(G.main, ID_GD, name);
+ gpd = BKE_libblock_alloc(G.main, ID_GD, name, 0);
/* initial settings */
gpd->flag = (GP_DATA_DISPINFO | GP_DATA_EXPAND);
@@ -753,47 +753,62 @@ bGPDlayer *BKE_gpencil_layer_duplicate(const bGPDlayer *gpl_src)
return gpl_dst;
}
-/* make a copy of a given gpencil datablock */
-bGPdata *BKE_gpencil_data_duplicate(Main *bmain, const bGPdata *gpd_src, bool internal_copy)
+/**
+ * Only copy internal data of GreasePencil ID from source to already allocated/initialized destination.
+ * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
+ *
+ * WARNING! This function will not handle ID user count!
+ *
+ * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
+ */
+void BKE_gpencil_copy_data(Main *UNUSED(bmain), bGPdata *gpd_dst, const bGPdata *gpd_src, const int UNUSED(flag))
{
- const bGPDlayer *gpl_src;
- bGPDlayer *gpl_dst;
- bGPdata *gpd_dst;
+ /* copy layers */
+ BLI_listbase_clear(&gpd_dst->layers);
+ for (const bGPDlayer *gpl_src = gpd_src->layers.first; gpl_src; gpl_src = gpl_src->next) {
+ /* make a copy of source layer and its data */
+ bGPDlayer *gpl_dst = BKE_gpencil_layer_duplicate(gpl_src); /* TODO here too could add unused flags... */
+ BLI_addtail(&gpd_dst->layers, gpl_dst);
+ }
- /* error checking */
- if (gpd_src == NULL) {
- return NULL;
+ /* copy palettes */
+ BLI_listbase_clear(&gpd_dst->palettes);
+ for (const bGPDpalette *palette_src = gpd_src->palettes.first; palette_src; palette_src = palette_src->next) {
+ bGPDpalette *palette_dst = BKE_gpencil_palette_duplicate(palette_src); /* TODO here too could add unused flags... */
+ BLI_addtail(&gpd_dst->palettes, palette_dst);
}
-
- /* make a copy of the base-data */
+}
+
+/* make a copy of a given gpencil datablock */
+bGPdata *BKE_gpencil_data_duplicate(Main *bmain, const bGPdata *gpd_src, bool internal_copy)
+{
+ /* Yuck and super-uber-hyper yuck!!!
+ * Should be replaceable with a no-main copy (LIB_ID_COPY_NO_MAIN etc.), but not sure about it,
+ * so for now keep old code for that one. */
if (internal_copy) {
+ const bGPDlayer *gpl_src;
+ bGPDlayer *gpl_dst;
+ bGPdata *gpd_dst;
+
/* make a straight copy for undo buffers used during stroke drawing */
gpd_dst = MEM_dupallocN(gpd_src);
+
+ /* copy layers */
+ BLI_listbase_clear(&gpd_dst->layers);
+ for (gpl_src = gpd_src->layers.first; gpl_src; gpl_src = gpl_src->next) {
+ /* make a copy of source layer and its data */
+ gpl_dst = BKE_gpencil_layer_duplicate(gpl_src);
+ BLI_addtail(&gpd_dst->layers, gpl_dst);
+ }
+
+ /* return new */
+ return gpd_dst;
}
else {
- /* make a copy when others use this */
- gpd_dst = BKE_libblock_copy(bmain, &gpd_src->id);
- }
-
- /* copy layers */
- BLI_listbase_clear(&gpd_dst->layers);
- for (gpl_src = gpd_src->layers.first; gpl_src; gpl_src = gpl_src->next) {
- /* make a copy of source layer and its data */
- gpl_dst = BKE_gpencil_layer_duplicate(gpl_src);
- BLI_addtail(&gpd_dst->layers, gpl_dst);
- }
- if (!internal_copy) {
- /* copy palettes */
- bGPDpalette *palette_src, *palette_dst;
- BLI_listbase_clear(&gpd_dst->palettes);
- for (palette_src = gpd_src->palettes.first; palette_src; palette_src = palette_src->next) {
- palette_dst = BKE_gpencil_palette_duplicate(palette_src);
- BLI_addtail(&gpd_dst->palettes, palette_dst);
- }
+ bGPdata *gpd_copy;
+ BKE_id_copy_ex(bmain, &gpd_src->id, (ID **)&gpd_copy, 0, false);
+ return gpd_copy;
}
-
- /* return new */
- return gpd_dst;
}
void BKE_gpencil_make_local(Main *bmain, bGPdata *gpd, const bool lib_local)
diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c
index 94a341de366..5ccbe9f7054 100644
--- a/source/blender/blenkernel/intern/group.c
+++ b/source/blender/blenkernel/intern/group.c
@@ -77,7 +77,7 @@ Group *BKE_group_add(Main *bmain, const char *name)
{
Group *group;
- group = BKE_libblock_alloc(bmain, ID_GR, name);
+ group = BKE_libblock_alloc(bmain, ID_GR, name, 0);
id_us_min(&group->id);
id_us_ensure_real(&group->id);
group->layer = (1 << 20) - 1;
@@ -87,19 +87,32 @@ Group *BKE_group_add(Main *bmain, const char *name)
return group;
}
-Group *BKE_group_copy(Main *bmain, const Group *group)
+/**
+ * Only copy internal data of Group ID from source to already allocated/initialized destination.
+ * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
+ *
+ * WARNING! This function will not handle ID user count!
+ *
+ * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
+ */
+void BKE_group_copy_data(Main *UNUSED(bmain), Group *group_dst, const Group *group_src, const int flag)
{
- Group *groupn;
-
- groupn = BKE_libblock_copy(bmain, &group->id);
- BLI_duplicatelist(&groupn->gobject, &group->gobject);
+ BLI_duplicatelist(&group_dst->gobject, &group_src->gobject);
/* Do not copy group's preview (same behavior as for objects). */
- groupn->preview = NULL;
-
- BKE_id_copy_ensure_local(bmain, &group->id, &groupn->id);
+ if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0 && false) { /* XXX TODO temp hack */
+ BKE_previewimg_id_copy(&group_dst->id, &group_src->id);
+ }
+ else {
+ group_dst->preview = NULL;
+ }
+}
- return groupn;
+Group *BKE_group_copy(Main *bmain, const Group *group)
+{
+ Group *group_copy;
+ BKE_id_copy_ex(bmain, &group->id, (ID **)&group_copy, 0, false);
+ return group_copy;
}
void BKE_group_make_local(Main *bmain, Group *group, const bool lib_local)
@@ -314,7 +327,7 @@ static void group_replaces_nla(Object *parent, Object *target, char mode)
* you can draw everything, leaves tags in objects to signal it needs further updating */
/* note: does not work for derivedmesh and render... it recreates all again in convertblender.c */
-void BKE_group_handle_recalc_and_update(struct EvaluationContext *eval_ctx, Scene *scene, Object *UNUSED(parent), Group *group)
+void BKE_group_handle_recalc_and_update(const struct EvaluationContext *eval_ctx, Scene *scene, Object *UNUSED(parent), Group *group)
{
GroupObject *go;
diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c
index db50a04348b..a407fd0bae8 100644
--- a/source/blender/blenkernel/intern/icons.c
+++ b/source/blender/blenkernel/intern/icons.c
@@ -255,6 +255,8 @@ PreviewImage **BKE_previewimg_id_get_p(const ID *id)
ID_PRV_CASE(ID_SCE, Scene);
ID_PRV_CASE(ID_SCR, bScreen);
#undef ID_PRV_CASE
+ default:
+ break;
}
return NULL;
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c
index a3bd15252cb..b00a62a1a87 100644
--- a/source/blender/blenkernel/intern/idprop.c
+++ b/source/blender/blenkernel/intern/idprop.c
@@ -90,7 +90,7 @@ IDProperty *IDP_NewIDPArray(const char *name)
return prop;
}
-IDProperty *IDP_CopyIDPArray(const IDProperty *array)
+IDProperty *IDP_CopyIDPArray(const IDProperty *array, const int flag)
{
/* don't use MEM_dupallocN because this may be part of an array */
IDProperty *narray, *tmp;
@@ -109,7 +109,7 @@ IDProperty *IDP_CopyIDPArray(const IDProperty *array)
* then free it. this makes for more maintainable
* code than simply reimplementing the copy functions
* in this loop.*/
- tmp = IDP_CopyProperty(GETPROP(narray, i));
+ tmp = IDP_CopyProperty_ex(GETPROP(narray, i), flag);
memcpy(GETPROP(narray, i), tmp, sizeof(IDProperty));
MEM_freeN(tmp);
}
@@ -285,9 +285,9 @@ void IDP_FreeArray(IDProperty *prop)
}
-static IDProperty *idp_generic_copy(const IDProperty *prop)
+static IDProperty *idp_generic_copy(const IDProperty *prop, const int UNUSED(flag))
{
- IDProperty *newp = MEM_callocN(sizeof(IDProperty), "IDProperty array dup");
+ IDProperty *newp = MEM_callocN(sizeof(IDProperty), __func__);
BLI_strncpy(newp->name, prop->name, MAX_IDPROP_NAME);
newp->type = prop->type;
@@ -298,9 +298,9 @@ static IDProperty *idp_generic_copy(const IDProperty *prop)
return newp;
}
-static IDProperty *IDP_CopyArray(const IDProperty *prop)
+static IDProperty *IDP_CopyArray(const IDProperty *prop, const int flag)
{
- IDProperty *newp = idp_generic_copy(prop);
+ IDProperty *newp = idp_generic_copy(prop, flag);
if (prop->data.pointer) {
newp->data.pointer = MEM_dupallocN(prop->data.pointer);
@@ -310,7 +310,7 @@ static IDProperty *IDP_CopyArray(const IDProperty *prop)
int a;
for (a = 0; a < prop->len; a++)
- array[a] = IDP_CopyProperty(array[a]);
+ array[a] = IDP_CopyProperty_ex(array[a], flag);
}
}
newp->len = prop->len;
@@ -363,12 +363,12 @@ IDProperty *IDP_NewString(const char *st, const char *name, int maxlen)
return prop;
}
-static IDProperty *IDP_CopyString(const IDProperty *prop)
+static IDProperty *IDP_CopyString(const IDProperty *prop, const int flag)
{
IDProperty *newp;
BLI_assert(prop->type == IDP_STRING);
- newp = idp_generic_copy(prop);
+ newp = idp_generic_copy(prop, flag);
if (prop->data.pointer)
newp->data.pointer = MEM_dupallocN(prop->data.pointer);
@@ -442,15 +442,17 @@ void IDP_FreeString(IDProperty *prop)
/** \name IDProperty ID API
* \{ */
-static IDProperty *IDP_CopyID(const IDProperty *prop)
+static IDProperty *IDP_CopyID(const IDProperty *prop, const int flag)
{
IDProperty *newp;
BLI_assert(prop->type == IDP_ID);
- newp = idp_generic_copy(prop);
+ newp = idp_generic_copy(prop, flag);
newp->data.pointer = prop->data.pointer;
- id_us_plus(IDP_Id(newp));
+ if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
+ id_us_plus(IDP_Id(newp));
+ }
return newp;
}
@@ -467,17 +469,17 @@ static IDProperty *IDP_CopyID(const IDProperty *prop)
/**
* Checks if a property with the same name as prop exists, and if so replaces it.
*/
-static IDProperty *IDP_CopyGroup(const IDProperty *prop)
+static IDProperty *IDP_CopyGroup(const IDProperty *prop, const int flag)
{
IDProperty *newp, *link;
BLI_assert(prop->type == IDP_GROUP);
- newp = idp_generic_copy(prop);
+ newp = idp_generic_copy(prop, flag);
newp->len = prop->len;
newp->subtype = prop->subtype;
for (link = prop->data.group.first; link; link = link->next) {
- BLI_addtail(&newp->data.group, IDP_CopyProperty(link));
+ BLI_addtail(&newp->data.group, IDP_CopyProperty_ex(link, flag));
}
return newp;
@@ -603,7 +605,7 @@ void IDP_ReplaceInGroup(IDProperty *group, IDProperty *prop)
* If a property is missing in \a dest, add it.
* Do it recursively.
*/
-void IDP_MergeGroup(IDProperty *dest, const IDProperty *src, const bool do_overwrite)
+void IDP_MergeGroup_ex(IDProperty *dest, const IDProperty *src, const bool do_overwrite, const int flag)
{
IDProperty *prop;
@@ -616,12 +618,12 @@ void IDP_MergeGroup(IDProperty *dest, const IDProperty *src, const bool do_overw
IDProperty *prop_exist = IDP_GetPropertyFromGroup(dest, prop->name);
if (prop_exist != NULL) {
- IDP_MergeGroup(prop_exist, prop, do_overwrite);
+ IDP_MergeGroup_ex(prop_exist, prop, do_overwrite, flag);
continue;
}
}
- IDProperty *copy = IDP_CopyProperty(prop);
+ IDProperty *copy = IDP_CopyProperty_ex(prop, flag);
IDP_ReplaceInGroup(dest, copy);
}
}
@@ -630,12 +632,12 @@ void IDP_MergeGroup(IDProperty *dest, const IDProperty *src, const bool do_overw
IDProperty *prop_exist = IDP_GetPropertyFromGroup(dest, prop->name);
if (prop_exist != NULL) {
if (prop->type == IDP_GROUP) {
- IDP_MergeGroup(prop_exist, prop, do_overwrite);
+ IDP_MergeGroup_ex(prop_exist, prop, do_overwrite, flag);
continue;
}
}
else {
- IDProperty *copy = IDP_CopyProperty(prop);
+ IDProperty *copy = IDP_CopyProperty_ex(prop, flag);
dest->len++;
BLI_addtail(&dest->data.group, copy);
}
@@ -644,6 +646,15 @@ void IDP_MergeGroup(IDProperty *dest, const IDProperty *src, const bool do_overw
}
/**
+ * If a property is missing in \a dest, add it.
+ * Do it recursively.
+ */
+void IDP_MergeGroup(IDProperty *dest, const IDProperty *src, const bool do_overwrite)
+{
+ IDP_MergeGroup_ex(dest, src, do_overwrite, 0);
+}
+
+/**
* This function has a sanity check to make sure ID properties with the same name don't
* get added to the group.
*
@@ -748,18 +759,23 @@ static void IDP_FreeGroup(IDProperty *prop, const bool do_id_user)
/** \name IDProperty Main API
* \{ */
-IDProperty *IDP_CopyProperty(const IDProperty *prop)
+IDProperty *IDP_CopyProperty_ex(const IDProperty *prop, const int flag)
{
switch (prop->type) {
- case IDP_GROUP: return IDP_CopyGroup(prop);
- case IDP_STRING: return IDP_CopyString(prop);
- case IDP_ID: return IDP_CopyID(prop);
- case IDP_ARRAY: return IDP_CopyArray(prop);
- case IDP_IDPARRAY: return IDP_CopyIDPArray(prop);
- default: return idp_generic_copy(prop);
+ case IDP_GROUP: return IDP_CopyGroup(prop, flag);
+ case IDP_STRING: return IDP_CopyString(prop, flag);
+ case IDP_ID: return IDP_CopyID(prop, flag);
+ case IDP_ARRAY: return IDP_CopyArray(prop, flag);
+ case IDP_IDPARRAY: return IDP_CopyIDPArray(prop, flag);
+ default: return idp_generic_copy(prop, flag);
}
}
+IDProperty *IDP_CopyProperty(const IDProperty *prop)
+{
+ return IDP_CopyProperty_ex(prop, 0);
+}
+
/* Updates ID pointers after an object has been copied */
/* TODO Nuke this once its only user has been correctly converted to use generic ID management from BKE_library! */
void IDP_RelinkProperty(struct IDProperty *prop)
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 2915e9d715d..33a690b32c6 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -304,8 +304,11 @@ static void image_free_anims(Image *ima)
* Simply free the image data from memory,
* on display the image can load again (except for render buffers).
*/
-void BKE_image_free_buffers(Image *ima)
+void BKE_image_free_buffers_ex(Image *ima, bool do_lock)
{
+ if (do_lock) {
+ BLI_spin_lock(&image_spin);
+ }
image_free_cached_frames(ima);
image_free_anims(ima);
@@ -324,6 +327,15 @@ void BKE_image_free_buffers(Image *ima)
}
ima->ok = IMA_OK;
+
+ if (do_lock) {
+ BLI_spin_unlock(&image_spin);
+ }
+}
+
+void BKE_image_free_buffers(Image *ima)
+{
+ BKE_image_free_buffers_ex(ima, false);
}
/** Free (or release) any data used by this image (does not free the image itself). */
@@ -383,7 +395,7 @@ static Image *image_alloc(Main *bmain, const char *name, short source, short typ
{
Image *ima;
- ima = BKE_libblock_alloc(bmain, ID_IM, name);
+ ima = BKE_libblock_alloc(bmain, ID_IM, name, 0);
if (ima) {
image_init(ima, source, type);
}
@@ -434,39 +446,53 @@ static void copy_image_packedfiles(ListBase *lb_dst, const ListBase *lb_src)
}
}
-/* empty image block, of similar type and filename */
-Image *BKE_image_copy(Main *bmain, const Image *ima)
+/**
+ * Only copy internal data of Image ID from source to already allocated/initialized destination.
+ * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
+ *
+ * WARNING! This function will not handle ID user count!
+ *
+ * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
+ */
+void BKE_image_copy_data(Main *UNUSED(bmain), Image *ima_dst, const Image *ima_src, const int flag)
{
- Image *nima = image_alloc(bmain, ima->id.name + 2, ima->source, ima->type);
+ BKE_color_managed_colorspace_settings_copy(&ima_dst->colorspace_settings, &ima_src->colorspace_settings);
- BLI_strncpy(nima->name, ima->name, sizeof(ima->name));
+ copy_image_packedfiles(&ima_dst->packedfiles, &ima_src->packedfiles);
- nima->flag = ima->flag;
- nima->tpageflag = ima->tpageflag;
+ ima_dst->stereo3d_format = MEM_dupallocN(ima_src->stereo3d_format);
+ BLI_duplicatelist(&ima_dst->views, &ima_src->views);
- nima->gen_x = ima->gen_x;
- nima->gen_y = ima->gen_y;
- nima->gen_type = ima->gen_type;
- copy_v4_v4(nima->gen_color, ima->gen_color);
-
- nima->animspeed = ima->animspeed;
-
- nima->aspx = ima->aspx;
- nima->aspy = ima->aspy;
-
- BKE_color_managed_colorspace_settings_copy(&nima->colorspace_settings, &ima->colorspace_settings);
-
- copy_image_packedfiles(&nima->packedfiles, &ima->packedfiles);
+ /* Cleanup stuff that cannot be copied. */
+ ima_dst->cache = NULL;
+ ima_dst->rr = NULL;
+ for (int i = 0; i < IMA_MAX_RENDER_SLOT; i++) {
+ ima_dst->renders[i] = NULL;
+ }
- /* nima->stere3d_format is already allocated by image_alloc... */
- *nima->stereo3d_format = *ima->stereo3d_format;
- BLI_duplicatelist(&nima->views, &ima->views);
+ BLI_listbase_clear(&ima_dst->anims);
- BKE_previewimg_id_copy(&nima->id, &ima->id);
+ ima_dst->totbind = 0;
+ for (int i = 0; i < TEXTARGET_COUNT; i++) {
+ ima_dst->bindcode[i] = 0;
+ ima_dst->gputexture[i] = NULL;
+ }
+ ima_dst->repbind = NULL;
- BKE_id_copy_ensure_local(bmain, &ima->id, &nima->id);
+ if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0) {
+ BKE_previewimg_id_copy(&ima_dst->id, &ima_src->id);
+ }
+ else {
+ ima_dst->preview = NULL;
+ }
+}
- return nima;
+/* empty image block, of similar type and filename */
+Image *BKE_image_copy(Main *bmain, const Image *ima)
+{
+ Image *ima_copy;
+ BKE_id_copy_ex(bmain, &ima->id, (ID **)&ima_copy, 0, false);
+ return ima_copy;
}
void BKE_image_make_local(Main *bmain, Image *ima, const bool lib_local)
@@ -1178,7 +1204,6 @@ bool BKE_imtype_is_movie(const char imtype)
switch (imtype) {
case R_IMF_IMTYPE_AVIRAW:
case R_IMF_IMTYPE_AVIJPEG:
- case R_IMF_IMTYPE_QUICKTIME:
case R_IMF_IMTYPE_FFMPEG:
case R_IMF_IMTYPE_H264:
case R_IMF_IMTYPE_THEORA:
@@ -1250,7 +1275,6 @@ char BKE_imtype_valid_channels(const char imtype, bool write_file)
case R_IMF_IMTYPE_MULTILAYER:
case R_IMF_IMTYPE_DDS:
case R_IMF_IMTYPE_JP2:
- case R_IMF_IMTYPE_QUICKTIME:
case R_IMF_IMTYPE_DPX:
chan_flag |= IMA_CHAN_FLAG_ALPHA;
break;
@@ -1313,7 +1337,6 @@ char BKE_imtype_from_arg(const char *imtype_arg)
else if (STREQ(imtype_arg, "AVIRAW")) return R_IMF_IMTYPE_AVIRAW;
else if (STREQ(imtype_arg, "AVIJPEG")) return R_IMF_IMTYPE_AVIJPEG;
else if (STREQ(imtype_arg, "PNG")) return R_IMF_IMTYPE_PNG;
- else if (STREQ(imtype_arg, "QUICKTIME")) return R_IMF_IMTYPE_QUICKTIME;
else if (STREQ(imtype_arg, "BMP")) return R_IMF_IMTYPE_BMP;
#ifdef WITH_HDR
else if (STREQ(imtype_arg, "HDR")) return R_IMF_IMTYPE_RADHDR;
@@ -1424,7 +1447,7 @@ static bool do_add_image_extension(char *string, const char imtype, const ImageF
}
}
#endif
- else { // R_IMF_IMTYPE_AVIRAW, R_IMF_IMTYPE_AVIJPEG, R_IMF_IMTYPE_JPEG90, R_IMF_IMTYPE_QUICKTIME etc
+ else { // R_IMF_IMTYPE_AVIRAW, R_IMF_IMTYPE_AVIJPEG, R_IMF_IMTYPE_JPEG90 etc
if (!(BLI_testextensie_n(string, extension_test = ".jpg", ".jpeg", NULL)))
extension = extension_test;
}
@@ -1432,9 +1455,7 @@ static bool do_add_image_extension(char *string, const char imtype, const ImageF
if (extension) {
/* prefer this in many cases to avoid .png.tga, but in certain cases it breaks */
/* remove any other known image extension */
- if (BLI_testextensie_array(string, imb_ext_image) ||
- (G.have_quicktime && BLI_testextensie_array(string, imb_ext_image_qt)))
- {
+ if (BLI_testextensie_array(string, imb_ext_image)) {
return BLI_replace_extension(string, FILE_MAX, extension);
}
else {
@@ -1710,7 +1731,7 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d
}
{
- Render *re = RE_GetRender(scene->id.name);
+ Render *re = RE_GetSceneRender(scene);
RenderStats *stats = re ? RE_GetStats(re) : NULL;
if (stats && (scene->r.stamp & R_STAMP_RENDERTIME)) {
@@ -2905,7 +2926,7 @@ RenderResult *BKE_image_acquire_renderresult(Scene *scene, Image *ima)
}
else if (ima->type == IMA_TYPE_R_RESULT) {
if (ima->render_slot == ima->last_render_slot)
- rr = RE_AcquireResultRead(RE_GetRender(scene->id.name));
+ rr = RE_AcquireResultRead(RE_GetSceneRender(scene));
else
rr = ima->renders[ima->render_slot];
@@ -2923,7 +2944,7 @@ void BKE_image_release_renderresult(Scene *scene, Image *ima)
}
else if (ima->type == IMA_TYPE_R_RESULT) {
if (ima->render_slot == ima->last_render_slot)
- RE_ReleaseResult(RE_GetRender(scene->id.name));
+ RE_ReleaseResult(RE_GetSceneRender(scene));
}
}
@@ -2943,7 +2964,7 @@ void BKE_image_backup_render(Scene *scene, Image *ima, bool free_current_slot)
{
/* called right before rendering, ima->renders contains render
* result pointers for everything but the current render */
- Render *re = RE_GetRender(scene->id.name);
+ Render *re = RE_GetSceneRender(scene);
int slot = ima->render_slot, last = ima->last_render_slot;
if (slot != last) {
@@ -3668,7 +3689,7 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **r_loc
if (!r_lock)
return NULL;
- re = RE_GetRender(iuser->scene->id.name);
+ re = RE_GetSceneRender(iuser->scene);
channels = 4;
layer = iuser->layer;
diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c
index 2c8399adece..1f1f4c9d341 100644
--- a/source/blender/blenkernel/intern/image_gen.c
+++ b/source/blender/blenkernel/intern/image_gen.c
@@ -132,7 +132,7 @@ static void image_buf_fill_checker_slice(unsigned char *rect,
float hsv[3] = {0.0f, 0.9f, 0.9f};
float rgb[3];
- float dark_linear_color, bright_linear_color;
+ float dark_linear_color = 0.0f, bright_linear_color = 0.0f;
if (rect_float != NULL) {
dark_linear_color = srgb_to_linearrgb(0.25f);
bright_linear_color = srgb_to_linearrgb(0.58f);
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index 98b251294ae..fd42556067e 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -107,7 +107,7 @@ Key *BKE_key_add(ID *id) /* common function */
Key *key;
char *el;
- key = BKE_libblock_alloc(G.main, ID_KE, "Key");
+ key = BKE_libblock_alloc(G.main, ID_KE, "Key", 0);
key->type = KEY_NORMAL;
key->from = id;
@@ -146,36 +146,48 @@ Key *BKE_key_add(ID *id) /* common function */
key->elemsize = 16;
break;
+
+ default:
+ break;
}
return key;
}
-Key *BKE_key_copy(Main *bmain, const Key *key)
+/**
+ * Only copy internal data of ShapeKey ID from source to already allocated/initialized destination.
+ * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
+ *
+ * WARNING! This function will not handle ID user count!
+ *
+ * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
+ */
+void BKE_key_copy_data(Main *UNUSED(bmain), Key *key_dst, const Key *key_src, const int UNUSED(flag))
{
- Key *keyn;
- KeyBlock *kbn, *kb;
-
- keyn = BKE_libblock_copy(bmain, &key->id);
-
- BLI_duplicatelist(&keyn->block, &key->block);
-
- kb = key->block.first;
- kbn = keyn->block.first;
- while (kbn) {
-
- if (kbn->data) kbn->data = MEM_dupallocN(kbn->data);
- if (kb == key->refkey) keyn->refkey = kbn;
-
- kbn = kbn->next;
- kb = kb->next;
- }
+ BLI_duplicatelist(&key_dst->block, &key_src->block);
- BKE_id_copy_ensure_local(bmain, &key->id, &keyn->id);
+ KeyBlock *kb_dst, *kb_src;
+ for (kb_src = key_src->block.first, kb_dst = key_dst->block.first;
+ kb_dst;
+ kb_src = kb_src->next, kb_dst = kb_dst->next)
+ {
+ if (kb_dst->data) {
+ kb_dst->data = MEM_dupallocN(kb_dst->data);
+ }
+ if (kb_src == key_src->refkey) {
+ key_dst->refkey = kb_dst;
+ }
+ }
+}
- return keyn;
+Key *BKE_key_copy(Main *bmain, const Key *key)
+{
+ Key *key_copy;
+ BKE_id_copy_ex(bmain, &key->id, (ID **)&key_copy, 0, false);
+ return key_copy;
}
+/* XXX TODO get rid of this! */
Key *BKE_key_copy_nolib(Key *key)
{
Key *keyn;
@@ -1397,6 +1409,8 @@ Key **BKE_key_from_id_p(ID *id)
Lattice *lt = (Lattice *)id;
return &lt->key;
}
+ default:
+ break;
}
return NULL;
diff --git a/source/blender/blenkernel/intern/lamp.c b/source/blender/blenkernel/intern/lamp.c
index 4a3a1c50195..3d0d5f87f15 100644
--- a/source/blender/blenkernel/intern/lamp.c
+++ b/source/blender/blenkernel/intern/lamp.c
@@ -69,7 +69,7 @@ void BKE_lamp_init(Lamp *la)
la->bufsize = 512;
la->clipsta = 0.5f;
la->clipend = 40.0f;
- la->bleedexp = 120.0f;
+ la->bleedexp = 2.5f;
la->samp = 3;
la->bias = 1.0f;
la->soft = 3.0f;
@@ -102,6 +102,14 @@ void BKE_lamp_init(Lamp *la)
la->sky_colorspace = BLI_XYZ_CIE;
la->sky_exposure = 1.0f;
la->shadow_frustum_size = 10.0f;
+ la->cascade_max_dist = 1000.0f;
+ la->cascade_count = 4;
+ la->cascade_exponent = 0.8f;
+ la->cascade_fade = 0.1f;
+ la->contact_dist = 1.0f;
+ la->contact_bias = 0.03f;
+ la->contact_spread = 0.2f;
+ la->contact_thickness = 0.5f;
curvemapping_initialize(la->curfalloff);
}
@@ -110,42 +118,60 @@ Lamp *BKE_lamp_add(Main *bmain, const char *name)
{
Lamp *la;
- la = BKE_libblock_alloc(bmain, ID_LA, name);
+ la = BKE_libblock_alloc(bmain, ID_LA, name, 0);
BKE_lamp_init(la);
return la;
}
-Lamp *BKE_lamp_copy(Main *bmain, const Lamp *la)
+/**
+ * Only copy internal data of Lamp ID from source to already allocated/initialized destination.
+ * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
+ *
+ * WARNING! This function will not handle ID user count!
+ *
+ * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
+ */
+void BKE_lamp_copy_data(Main *bmain, Lamp *la_dst, const Lamp *la_src, const int flag)
{
- Lamp *lan;
- int a;
-
- lan = BKE_libblock_copy(bmain, &la->id);
-
- for (a = 0; a < MAX_MTEX; a++) {
- if (lan->mtex[a]) {
- lan->mtex[a] = MEM_mallocN(sizeof(MTex), "copylamptex");
- memcpy(lan->mtex[a], la->mtex[a], sizeof(MTex));
- id_us_plus((ID *)lan->mtex[a]->tex);
+ for (int a = 0; a < MAX_MTEX; a++) {
+ if (la_dst->mtex[a]) {
+ la_dst->mtex[a] = MEM_mallocN(sizeof(*la_dst->mtex[a]), __func__);
+ *la_dst->mtex[a] = *la_src->mtex[a];
}
}
-
- lan->curfalloff = curvemapping_copy(la->curfalloff);
- if (la->nodetree)
- lan->nodetree = ntreeCopyTree(bmain, la->nodetree);
+ la_dst->curfalloff = curvemapping_copy(la_src->curfalloff);
- BKE_previewimg_id_copy(&lan->id, &la->id);
+ if (la_src->nodetree) {
+ BKE_id_copy_ex(bmain, (ID *)la_src->nodetree, (ID **)&la_dst->nodetree, flag, false);
+ }
- BKE_id_copy_ensure_local(bmain, &la->id, &lan->id);
+ if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0) {
+ BKE_previewimg_id_copy(&la_dst->id, &la_src->id);
+ }
+ else {
+ la_dst->preview = NULL;
+ }
+}
- return lan;
+Lamp *BKE_lamp_copy(Main *bmain, const Lamp *la)
+{
+ Lamp *la_copy;
+ BKE_id_copy_ex(bmain, &la->id, (ID **)&la_copy, 0, false);
+ return la_copy;
}
Lamp *localize_lamp(Lamp *la)
{
+ /* TODO replace with something like
+ * Lamp *la_copy;
+ * BKE_id_copy_ex(bmain, &la->id, (ID **)&la_copy, LIB_ID_COPY_NO_MAIN | LIB_ID_COPY_NO_PREVIEW | LIB_ID_COPY_NO_USER_REFCOUNT, false);
+ * return la_copy;
+ *
+ * ... Once f*** nodes are fully converted to that too :( */
+
Lamp *lan;
int a;
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index c6773d98adf..0f26f53113f 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -269,39 +269,46 @@ Lattice *BKE_lattice_add(Main *bmain, const char *name)
{
Lattice *lt;
- lt = BKE_libblock_alloc(bmain, ID_LT, name);
+ lt = BKE_libblock_alloc(bmain, ID_LT, name, 0);
BKE_lattice_init(lt);
return lt;
}
-Lattice *BKE_lattice_copy(Main *bmain, const Lattice *lt)
+/**
+ * Only copy internal data of Lattice ID from source to already allocated/initialized destination.
+ * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
+ *
+ * WARNING! This function will not handle ID user count!
+ *
+ * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
+ */
+void BKE_lattice_copy_data(Main *bmain, Lattice *lt_dst, const Lattice *lt_src, const int flag)
{
- Lattice *ltn;
+ lt_dst->def = MEM_dupallocN(lt_src->def);
- ltn = BKE_libblock_copy(bmain, &lt->id);
- ltn->def = MEM_dupallocN(lt->def);
-
- if (lt->key) {
- ltn->key = BKE_key_copy(bmain, ltn->key);
- ltn->key->from = (ID *)ltn;
- }
-
- if (lt->dvert) {
- int tot = lt->pntsu * lt->pntsv * lt->pntsw;
- ltn->dvert = MEM_mallocN(sizeof(MDeformVert) * tot, "Lattice MDeformVert");
- BKE_defvert_array_copy(ltn->dvert, lt->dvert, tot);
+ if (lt_src->key) {
+ BKE_id_copy_ex(bmain, &lt_src->key->id, (ID **)&lt_dst->key, flag, false);
}
- ltn->editlatt = NULL;
+ if (lt_src->dvert) {
+ int tot = lt_src->pntsu * lt_src->pntsv * lt_src->pntsw;
+ lt_dst->dvert = MEM_mallocN(sizeof(MDeformVert) * tot, "Lattice MDeformVert");
+ BKE_defvert_array_copy(lt_dst->dvert, lt_src->dvert, tot);
+ }
- BKE_id_copy_ensure_local(bmain, &lt->id, &ltn->id);
+ lt_dst->editlatt = NULL;
+}
- return ltn;
+Lattice *BKE_lattice_copy(Main *bmain, const Lattice *lt)
+{
+ Lattice *lt_copy;
+ BKE_id_copy_ex(bmain, &lt->id, (ID **)&lt_copy, 0, false);
+ return lt_copy;
}
-/** Free (or release) any data used by this lattice (does not free the lattice itself). */
+ /** Free (or release) any data used by this lattice (does not free the lattice itself). */
void BKE_lattice_free(Lattice *lt)
{
BKE_animdata_free(&lt->id, false);
@@ -596,7 +603,7 @@ static bool where_on_path_deform(Object *ob, float ctime, float vec[4], float di
/* co: local coord, result local too */
/* returns quaternion for rotation, using cd->no_rot_axis */
/* axis is using another define!!! */
-static bool calc_curve_deform(Scene *scene, Object *par, float co[3],
+static bool calc_curve_deform(const struct EvaluationContext *eval_ctx, Scene *scene, Object *par, float co[3],
const short axis, CurveDeform *cd, float r_quat[4])
{
Curve *cu = par->data;
@@ -607,7 +614,7 @@ static bool calc_curve_deform(Scene *scene, Object *par, float co[3],
/* to be sure, mostly after file load, also cyclic dependencies */
#ifdef CYCLIC_DEPENDENCY_WORKAROUND
if (par->curve_cache == NULL) {
- BKE_displist_make_curveTypes(scene, par, false);
+ BKE_displist_make_curveTypes(eval_ctx, scene, par, false);
}
#endif
@@ -700,7 +707,8 @@ static bool calc_curve_deform(Scene *scene, Object *par, float co[3],
}
void curve_deform_verts(
- Scene *scene, Object *cuOb, Object *target, DerivedMesh *dm, float (*vertexCos)[3],
+ const struct EvaluationContext *eval_ctx, Scene *scene,
+ Object *cuOb, Object *target, DerivedMesh *dm, float (*vertexCos)[3],
int numVerts, const char *vgroup, short defaxis)
{
Curve *cu;
@@ -759,7 +767,7 @@ void curve_deform_verts(
if (weight > 0.0f) {
mul_m4_v3(cd.curvespace, vertexCos[a]);
copy_v3_v3(vec, vertexCos[a]);
- calc_curve_deform(scene, cuOb, vec, defaxis, &cd, NULL);
+ calc_curve_deform(eval_ctx, scene, cuOb, vec, defaxis, &cd, NULL);
interp_v3_v3v3(vertexCos[a], vertexCos[a], vec, weight);
mul_m4_v3(cd.objectspace, vertexCos[a]);
}
@@ -782,7 +790,7 @@ void curve_deform_verts(
if (weight > 0.0f) {
/* already in 'cd.curvespace', prev for loop */
copy_v3_v3(vec, vertexCos[a]);
- calc_curve_deform(scene, cuOb, vec, defaxis, &cd, NULL);
+ calc_curve_deform(eval_ctx, scene, cuOb, vec, defaxis, &cd, NULL);
interp_v3_v3v3(vertexCos[a], vertexCos[a], vec, weight);
mul_m4_v3(cd.objectspace, vertexCos[a]);
}
@@ -793,7 +801,7 @@ void curve_deform_verts(
if (cu->flag & CU_DEFORM_BOUNDS_OFF) {
for (a = 0; a < numVerts; a++) {
mul_m4_v3(cd.curvespace, vertexCos[a]);
- calc_curve_deform(scene, cuOb, vertexCos[a], defaxis, &cd, NULL);
+ calc_curve_deform(eval_ctx, scene, cuOb, vertexCos[a], defaxis, &cd, NULL);
mul_m4_v3(cd.objectspace, vertexCos[a]);
}
}
@@ -808,7 +816,7 @@ void curve_deform_verts(
for (a = 0; a < numVerts; a++) {
/* already in 'cd.curvespace', prev for loop */
- calc_curve_deform(scene, cuOb, vertexCos[a], defaxis, &cd, NULL);
+ calc_curve_deform(eval_ctx, scene, cuOb, vertexCos[a], defaxis, &cd, NULL);
mul_m4_v3(cd.objectspace, vertexCos[a]);
}
}
@@ -818,7 +826,7 @@ void curve_deform_verts(
/* input vec and orco = local coord in armature space */
/* orco is original not-animated or deformed reference point */
/* result written in vec and mat */
-void curve_deform_vector(Scene *scene, Object *cuOb, Object *target,
+void curve_deform_vector(const struct EvaluationContext *eval_ctx, Scene *scene, Object *cuOb, Object *target,
float orco[3], float vec[3], float mat[3][3], int no_rot_axis)
{
CurveDeform cd;
@@ -837,7 +845,7 @@ void curve_deform_vector(Scene *scene, Object *cuOb, Object *target,
mul_m4_v3(cd.curvespace, vec);
- if (calc_curve_deform(scene, cuOb, vec, target->trackflag, &cd, quat)) {
+ if (calc_curve_deform(eval_ctx, scene, cuOb, vec, target->trackflag, &cd, quat)) {
float qmat[3][3];
quat_to_mat3(qmat, quat);
@@ -1027,7 +1035,7 @@ void BKE_lattice_vertexcos_apply(struct Object *ob, float (*vertexCos)[3])
}
}
-void BKE_lattice_modifiers_calc(Scene *scene, Object *ob)
+void BKE_lattice_modifiers_calc(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob)
{
Lattice *lt = ob->data;
VirtualModifierData virtualModifierData;
@@ -1054,7 +1062,7 @@ void BKE_lattice_modifiers_calc(Scene *scene, Object *ob)
if (mti->type != eModifierTypeType_OnlyDeform) continue;
if (!vertexCos) vertexCos = BKE_lattice_vertexcos_get(ob, &numVerts);
- mti->deformVerts(md, ob, NULL, vertexCos, numVerts, 0);
+ mti->deformVerts(md, eval_ctx, ob, NULL, vertexCos, numVerts, 0);
}
/* always displist to make this work like derivedmesh */
@@ -1228,7 +1236,7 @@ void BKE_lattice_translate(Lattice *lt, float offset[3], bool do_keys)
/* **** Depsgraph evaluation **** */
-void BKE_lattice_eval_geometry(struct EvaluationContext *UNUSED(eval_ctx),
+void BKE_lattice_eval_geometry(const struct EvaluationContext *UNUSED(eval_ctx),
Lattice *UNUSED(latt))
{
}
@@ -1248,4 +1256,4 @@ void BKE_lattice_batch_cache_free(Lattice *lt)
if (lt->batch_cache) {
BKE_lattice_batch_cache_free_cb(lt);
}
-} \ No newline at end of file
+}
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index 78954e56f8c..f20b96b8bc7 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -57,6 +57,7 @@
/* prototype */
struct EngineSettingsCB_Type;
static void layer_collection_free(SceneLayer *sl, LayerCollection *lc);
+static void layer_collection_objects_populate(SceneLayer *sl, LayerCollection *lc, ListBase *objects);
static LayerCollection *layer_collection_add(SceneLayer *sl, LayerCollection *parent, SceneCollection *sc);
static LayerCollection *find_layer_collection_by_scene_collection(LayerCollection *lc, const SceneCollection *sc);
static IDProperty *collection_engine_settings_create(struct EngineSettingsCB_Type *ces_type, const bool populate);
@@ -69,9 +70,9 @@ static void object_bases_iterator_next(BLI_Iterator *iter, const int flag);
/**
* Returns the SceneLayer to be used for rendering
- * Most of the time BKE_scene_layer_context_active should be used instead
+ * Most of the time BKE_scene_layer_from_workspace_get should be used instead
*/
-SceneLayer *BKE_scene_layer_render_active(const Scene *scene)
+SceneLayer *BKE_scene_layer_from_scene_get(const Scene *scene)
{
SceneLayer *sl = BLI_findlink(&scene->render_layers, scene->active_layer);
BLI_assert(sl);
@@ -81,23 +82,18 @@ SceneLayer *BKE_scene_layer_render_active(const Scene *scene)
/**
* Returns the SceneLayer to be used for drawing, outliner, and other context related areas.
*/
-SceneLayer *BKE_scene_layer_context_active_ex(const Main *bmain, const Scene *UNUSED(scene))
+SceneLayer *BKE_scene_layer_from_workspace_get(const struct WorkSpace *workspace)
{
- /* XXX We should really pass the workspace as argument, but would require
- * some bigger changes since it's often not available where we call this.
- * Just working around this by getting active window from WM for now */
- for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) {
- /* Called on startup, so 'winactive' may not be set, in that case fall back to first window. */
- wmWindow *win = wm->winactive ? wm->winactive : wm->windows.first;
- const WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook);
- return BKE_workspace_render_layer_get(workspace);
- }
-
- return NULL;
+ return BKE_workspace_render_layer_get(workspace);
}
-SceneLayer *BKE_scene_layer_context_active(const Scene *scene)
+
+/**
+ * This is a placeholder to know which areas of the code need to be addressed for the Workspace changes.
+ * Never use this, you should either use BKE_scene_layer_workspace_active or get SceneLayer explicitly.
+ */
+SceneLayer *BKE_scene_layer_context_active_PLACEHOLDER(const Scene *scene)
{
- return BKE_scene_layer_context_active_ex(G.main, scene);
+ return BKE_scene_layer_from_scene_get(scene);
}
/**
@@ -293,11 +289,7 @@ static Base *object_base_add(SceneLayer *sl, Object *ob)
/* LayerCollection */
-/**
- * When freeing the entire SceneLayer at once we don't bother with unref
- * otherwise SceneLayer is passed to keep the syncing of the LayerCollection tree
- */
-static void layer_collection_free(SceneLayer *sl, LayerCollection *lc)
+static void layer_collection_objects_unpopulate(SceneLayer *sl, LayerCollection *lc)
{
if (sl) {
for (LinkData *link = lc->object_bases.first; link; link = link->next) {
@@ -306,6 +298,15 @@ static void layer_collection_free(SceneLayer *sl, LayerCollection *lc)
}
BLI_freelistN(&lc->object_bases);
+}
+
+/**
+ * When freeing the entire SceneLayer at once we don't bother with unref
+ * otherwise SceneLayer is passed to keep the syncing of the LayerCollection tree
+ */
+static void layer_collection_free(SceneLayer *sl, LayerCollection *lc)
+{
+ layer_collection_objects_unpopulate(sl, lc);
BLI_freelistN(&lc->overrides);
if (lc->properties) {
@@ -357,6 +358,15 @@ static LayerCollection *collection_from_index(ListBase *lb, const int number, in
}
/**
+ * Get the collection for a given index
+ */
+LayerCollection *BKE_layer_collection_from_index(SceneLayer *sl, const int index)
+{
+ int i = 0;
+ return collection_from_index(&sl->layer_collections, index, &i);
+}
+
+/**
* Get the active collection
*/
LayerCollection *BKE_layer_collection_get_active(SceneLayer *sl)
@@ -802,6 +812,60 @@ void BKE_collection_unlink(SceneLayer *sl, LayerCollection *lc)
sl->active_collection = 0;
}
+/**
+ * Recursively enable nested collections
+ */
+static void layer_collection_enable(SceneLayer *sl, LayerCollection *lc)
+{
+ layer_collection_objects_populate(sl, lc, &lc->scene_collection->objects);
+
+ for (LayerCollection *nlc = lc->layer_collections.first; nlc; nlc = nlc->next) {
+ layer_collection_enable(sl, nlc);
+ }
+}
+
+/**
+ * Enable collection
+ * Add its objects bases to SceneLayer
+ * Depsgraph needs to be rebuilt afterwards
+ */
+void BKE_collection_enable(SceneLayer *sl, LayerCollection *lc)
+{
+ if ((lc->flag & COLLECTION_DISABLED) == 0) {
+ return;
+ }
+
+ lc->flag &= ~COLLECTION_DISABLED;
+ layer_collection_enable(sl, lc);
+}
+
+/**
+ * Recursively disable nested collections
+ */
+static void layer_collection_disable(SceneLayer *sl, LayerCollection *lc)
+{
+ layer_collection_objects_unpopulate(sl, lc);
+
+ for (LayerCollection *nlc = lc->layer_collections.first; nlc; nlc = nlc->next) {
+ layer_collection_disable(sl, nlc);
+ }
+}
+
+/**
+ * Disable collection
+ * Remove all its object bases from SceneLayer
+ * Depsgraph needs to be rebuilt afterwards
+ */
+void BKE_collection_disable(SceneLayer *sl, LayerCollection *lc)
+{
+ if ((lc->flag & COLLECTION_DISABLED) != 0) {
+ return;
+ }
+
+ lc->flag |= COLLECTION_DISABLED;
+ layer_collection_disable(sl, lc);
+}
+
static void layer_collection_object_add(SceneLayer *sl, LayerCollection *lc, Object *ob)
{
Base *base = object_base_add(sl, ob);
@@ -1356,7 +1420,7 @@ void BKE_collection_engine_property_add_float_array(
val.array.len = array_length;
val.array.type = IDP_FLOAT;
- IDProperty *idprop= IDP_New(IDP_ARRAY, &val, name);
+ IDProperty *idprop = IDP_New(IDP_ARRAY, &val, name);
memcpy(IDP_Array(idprop), values, sizeof(float) * idprop->len);
IDP_AddToGroup(props, idprop);
}
@@ -1739,10 +1803,10 @@ static void idproperty_reset(IDProperty **props, IDProperty *props_ref)
}
}
-void BKE_layer_eval_layer_collection_pre(struct EvaluationContext *UNUSED(eval_ctx),
+void BKE_layer_eval_layer_collection_pre(const struct EvaluationContext *UNUSED(eval_ctx),
Scene *scene, SceneLayer *scene_layer)
{
- DEBUG_PRINT("%s on %s\n", __func__, scene_layer->name);
+ DEBUG_PRINT("%s on %s (%p)\n", __func__, scene_layer->name, scene_layer);
for (Base *base = scene_layer->object_bases.first; base != NULL; base = base->next) {
base->flag &= ~(BASE_VISIBLED | BASE_SELECTABLED);
idproperty_reset(&base->collection_properties, scene->collection_properties);
@@ -1756,14 +1820,16 @@ void BKE_layer_eval_layer_collection_pre(struct EvaluationContext *UNUSED(eval_c
scene_layer->flag |= SCENE_LAYER_ENGINE_DIRTY;
}
-void BKE_layer_eval_layer_collection(struct EvaluationContext *UNUSED(eval_ctx),
+void BKE_layer_eval_layer_collection(const struct EvaluationContext *UNUSED(eval_ctx),
LayerCollection *layer_collection,
LayerCollection *parent_layer_collection)
{
- DEBUG_PRINT("%s on %s, parent %s\n",
+ DEBUG_PRINT("%s on %s (%p), parent %s (%p)\n",
__func__,
layer_collection->scene_collection->name,
- (parent_layer_collection != NULL) ? parent_layer_collection->scene_collection->name : "NONE");
+ layer_collection->scene_collection,
+ (parent_layer_collection != NULL) ? parent_layer_collection->scene_collection->name : "NONE",
+ (parent_layer_collection != NULL) ? parent_layer_collection->scene_collection : NULL);
/* visibility */
layer_collection->flag_evaluated = layer_collection->flag;
@@ -1794,6 +1860,9 @@ void BKE_layer_eval_layer_collection(struct EvaluationContext *UNUSED(eval_ctx),
IDP_MergeGroup(base->collection_properties, layer_collection->properties_evaluated, true);
base->flag |= BASE_VISIBLED;
}
+ else {
+ base->flag &= ~BASE_VISIBLED;
+ }
if (is_selectable) {
base->flag |= BASE_SELECTABLED;
@@ -1801,10 +1870,10 @@ void BKE_layer_eval_layer_collection(struct EvaluationContext *UNUSED(eval_ctx),
}
}
-void BKE_layer_eval_layer_collection_post(struct EvaluationContext *UNUSED(eval_ctx),
+void BKE_layer_eval_layer_collection_post(const struct EvaluationContext *UNUSED(eval_ctx),
SceneLayer *scene_layer)
{
- DEBUG_PRINT("%s on %s\n", __func__, scene_layer->name);
+ DEBUG_PRINT("%s on %s (%p)\n", __func__, scene_layer->name, scene_layer);
/* if base is not selectabled, clear select */
for (Base *base = scene_layer->object_bases.first; base; base = base->next) {
if ((base->flag & BASE_SELECTABLED) == 0) {
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index ed64de9b1aa..71fbb3d726a 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -385,7 +385,6 @@ bool id_make_local(Main *bmain, ID *id, const bool test, const bool lib_local)
switch ((ID_Type)GS(id->name)) {
case ID_SCE:
- /* Partially implemented (has no copy...). */
if (!test) BKE_scene_make_local(bmain, (Scene *)id, lib_local);
return true;
case ID_OB:
@@ -428,14 +427,12 @@ bool id_make_local(Main *bmain, ID *id, const bool test, const bool lib_local)
if (!test) BKE_world_make_local(bmain, (World *)id, lib_local);
return true;
case ID_VF:
- /* Partially implemented (has no copy...). */
if (!test) BKE_vfont_make_local(bmain, (VFont *)id, lib_local);
return true;
case ID_TXT:
if (!test) BKE_text_make_local(bmain, (Text *)id, lib_local);
return true;
case ID_SO:
- /* Partially implemented (has no copy...). */
if (!test) BKE_sound_make_local(bmain, (bSound *)id, lib_local);
return true;
case ID_GR:
@@ -493,118 +490,193 @@ bool id_make_local(Main *bmain, ID *id, const bool test, const bool lib_local)
return false;
}
+struct IDCopyLibManagementData {
+ const ID *id_src;
+ ID *id_dst;
+ int flag;
+};
+
+/* Increases usercount as required, and remap self ID pointers. */
+static int id_copy_libmanagement_cb(void *user_data, ID *UNUSED(id_self), ID **id_pointer, int cb_flag)
+{
+ struct IDCopyLibManagementData *data = user_data;
+ ID *id = *id_pointer;
+
+ /* Remap self-references to new copied ID. */
+ if (id == data->id_src) {
+ /* We cannot use id_self here, it is not *always* id_dst (thanks to $£!+@#&/? nodetrees). */
+ id = *id_pointer = data->id_dst;
+ }
+
+ /* Increase used IDs refcount if needed and required. */
+ if ((data->flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0 && (cb_flag & IDWALK_CB_USER)) {
+ id_us_plus(id);
+ }
+
+ return IDWALK_RET_NOP;
+}
+
/**
- * Invokes the appropriate copy method for the block and returns the result in
- * newid, unless test. Returns true if the block can be copied.
+ * Generic entry point for copying a datablock (new API).
+ *
+ * \note Copy is only affecting given data-block (no ID used by copied one will be affected, besides usercount).
+ * There is only one exception, if LIB_ID_COPY_ACTIONS is defined, actions used by animdata will be duplicated.
+ *
+ * \note Usercount of new copy is always set to 1.
+ *
+ * \param bmain Main database, may be NULL only if LIB_ID_COPY_NO_MAIN is specified.
+ * \param id Source datablock.
+ * \param r_newid Pointer to new (copied) ID pointer.
+ * \param flag Set of copy options, see DNA_ID.h enum for details (leave to zero for default, full copy).
+ * \param test If set, do not do any copy, just test whether copy is supported.
+ * \return False when copying that ID type is not supported, true otherwise.
*/
-bool id_copy(Main *bmain, const ID *id, ID **newid, bool test)
+/* XXX TODO remove test thing, *all* IDs should be copyable that way! */
+bool BKE_id_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag, const bool test)
{
- if (!test) {
- *newid = NULL;
+#define LIB_ID_TYPES_NOCOPY ID_LI, ID_SCR, ID_WM, /* Not supported */ \
+ ID_IP /* Deprecated */
+
+ BLI_assert(test || (r_newid != NULL));
+ if (r_newid != NULL) {
+ *r_newid = NULL;
+ }
+ if (id == NULL) {
+ return false;
}
- /* conventions:
- * - make shallow copy, only this ID block
- * - id.us of the new ID is set to 1 */
+ if (ELEM(GS(id->name), LIB_ID_TYPES_NOCOPY)) {
+ return false;
+ }
+ else if (test) {
+ return true;
+ }
+
+ BKE_libblock_copy_ex(bmain, id, r_newid, flag);
+
switch ((ID_Type)GS(id->name)) {
+ case ID_SCE:
+ BKE_scene_copy_data(bmain, (Scene *)*r_newid, (Scene *)id, flag);
+ break;
case ID_OB:
- if (!test) *newid = (ID *)BKE_object_copy(bmain, (Object *)id);
- return true;
+ BKE_object_copy_data(bmain, (Object *)*r_newid, (Object *)id, flag);
+ break;
case ID_ME:
- if (!test) *newid = (ID *)BKE_mesh_copy(bmain, (Mesh *)id);
- return true;
+ BKE_mesh_copy_data(bmain, (Mesh *)*r_newid, (Mesh *)id, flag);
+ break;
case ID_CU:
- if (!test) *newid = (ID *)BKE_curve_copy(bmain, (Curve *)id);
- return true;
+ BKE_curve_copy_data(bmain, (Curve *)*r_newid, (Curve *)id, flag);
+ break;
case ID_MB:
- if (!test) *newid = (ID *)BKE_mball_copy(bmain, (MetaBall *)id);
- return true;
+ BKE_mball_copy_data(bmain, (MetaBall *)*r_newid, (MetaBall *)id, flag);
+ break;
case ID_MA:
- if (!test) *newid = (ID *)BKE_material_copy(bmain, (Material *)id);
- return true;
+ BKE_material_copy_data(bmain, (Material *)*r_newid, (Material *)id, flag);
+ break;
case ID_TE:
- if (!test) *newid = (ID *)BKE_texture_copy(bmain, (Tex *)id);
- return true;
+ BKE_texture_copy_data(bmain, (Tex *)*r_newid, (Tex *)id, flag);
+ break;
case ID_IM:
- if (!test) *newid = (ID *)BKE_image_copy(bmain, (Image *)id);
- return true;
+ BKE_image_copy_data(bmain, (Image *)*r_newid, (Image *)id, flag);
+ break;
case ID_LT:
- if (!test) *newid = (ID *)BKE_lattice_copy(bmain, (Lattice *)id);
- return true;
+ BKE_lattice_copy_data(bmain, (Lattice *)*r_newid, (Lattice *)id, flag);
+ break;
case ID_LA:
- if (!test) *newid = (ID *)BKE_lamp_copy(bmain, (Lamp *)id);
- return true;
+ BKE_lamp_copy_data(bmain, (Lamp *)*r_newid, (Lamp *)id, flag);
+ break;
case ID_SPK:
- if (!test) *newid = (ID *)BKE_speaker_copy(bmain, (Speaker *)id);
- return true;
+ BKE_speaker_copy_data(bmain, (Speaker *)*r_newid, (Speaker *)id, flag);
+ break;
case ID_LP:
- if (!test) *newid = (ID *)BKE_lightprobe_copy(bmain, (LightProbe *)id);
- return true;
+ BKE_lightprobe_copy_data(bmain, (LightProbe *)*r_newid, (LightProbe *)id, flag);
+ break;
case ID_CA:
- if (!test) *newid = (ID *)BKE_camera_copy(bmain, (Camera *)id);
- return true;
+ BKE_camera_copy_data(bmain, (Camera *)*r_newid, (Camera *)id, flag);
+ break;
case ID_KE:
- if (!test) *newid = (ID *)BKE_key_copy(bmain, (Key *)id);
- return true;
+ BKE_key_copy_data(bmain, (Key *)*r_newid, (Key *)id, flag);
+ break;
case ID_WO:
- if (!test) *newid = (ID *)BKE_world_copy(bmain, (World *)id);
- return true;
+ BKE_world_copy_data(bmain, (World *)*r_newid, (World *)id, flag);
+ break;
case ID_TXT:
- if (!test) *newid = (ID *)BKE_text_copy(bmain, (Text *)id);
- return true;
+ BKE_text_copy_data(bmain, (Text *)*r_newid, (Text *)id, flag);
+ break;
case ID_GR:
- if (!test) *newid = (ID *)BKE_group_copy(bmain, (Group *)id);
- return true;
+ BKE_group_copy_data(bmain, (Group *)*r_newid, (Group *)id, flag);
+ break;
case ID_AR:
- if (!test) *newid = (ID *)BKE_armature_copy(bmain, (bArmature *)id);
- return true;
+ BKE_armature_copy_data(bmain, (bArmature *)*r_newid, (bArmature *)id, flag);
+ break;
case ID_AC:
- if (!test) *newid = (ID *)BKE_action_copy(bmain, (bAction *)id);
- return true;
+ BKE_action_copy_data(bmain, (bAction *)*r_newid, (bAction *)id, flag);
+ break;
case ID_NT:
- if (!test) *newid = (ID *)ntreeCopyTree(bmain, (bNodeTree *)id);
- return true;
+ BKE_node_tree_copy_data(bmain, (bNodeTree *)*r_newid, (bNodeTree *)id, flag);
+ break;
case ID_BR:
- if (!test) *newid = (ID *)BKE_brush_copy(bmain, (Brush *)id);
- return true;
+ BKE_brush_copy_data(bmain, (Brush *)*r_newid, (Brush *)id, flag);
+ break;
case ID_PA:
- if (!test) *newid = (ID *)BKE_particlesettings_copy(bmain, (ParticleSettings *)id);
- return true;
+ BKE_particlesettings_copy_data(bmain, (ParticleSettings *)*r_newid, (ParticleSettings *)id, flag);
+ break;
case ID_GD:
- if (!test) *newid = (ID *)BKE_gpencil_data_duplicate(bmain, (bGPdata *)id, false);
- return true;
+ BKE_gpencil_copy_data(bmain, (bGPdata *)*r_newid, (bGPdata *)id, flag);
+ break;
case ID_MC:
- if (!test) *newid = (ID *)BKE_movieclip_copy(bmain, (MovieClip *)id);
- return true;
+ BKE_movieclip_copy_data(bmain, (MovieClip *)*r_newid, (MovieClip *)id, flag);
+ break;
case ID_MSK:
- if (!test) *newid = (ID *)BKE_mask_copy(bmain, (Mask *)id);
- return true;
+ BKE_mask_copy_data(bmain, (Mask *)*r_newid, (Mask *)id, flag);
+ break;
case ID_LS:
- if (!test) *newid = (ID *)BKE_linestyle_copy(bmain, (FreestyleLineStyle *)id);
- return true;
+ BKE_linestyle_copy_data(bmain, (FreestyleLineStyle *)*r_newid, (FreestyleLineStyle *)id, flag);
+ break;
case ID_PAL:
- if (!test) *newid = (ID *)BKE_palette_copy(bmain, (Palette *)id);
- return true;
+ BKE_palette_copy_data(bmain, (Palette *)*r_newid, (Palette *)id, flag);
+ break;
case ID_PC:
- if (!test) *newid = (ID *)BKE_paint_curve_copy(bmain, (PaintCurve *)id);
- return true;
+ BKE_paint_curve_copy_data(bmain, (PaintCurve *)*r_newid, (PaintCurve *)id, flag);
+ break;
case ID_CF:
- if (!test) *newid = (ID *)BKE_cachefile_copy(bmain, (CacheFile *)id);
- return true;
- case ID_WS:
- case ID_SCE:
+ BKE_cachefile_copy_data(bmain, (CacheFile *)*r_newid, (CacheFile *)id, flag);
+ break;
+ case ID_SO:
+ BKE_sound_copy_data(bmain, (bSound *)*r_newid, (bSound *)id, flag);
+ break;
+ case ID_VF:
+ BKE_vfont_copy_data(bmain, (VFont *)*r_newid, (VFont *)id, flag);
+ break;
case ID_LI:
case ID_SCR:
case ID_WM:
- return false; /* can't be copied from here */
- case ID_VF:
- case ID_SO:
- return false; /* not implemented */
+ case ID_WS:
case ID_IP:
- return false; /* deprecated */
+ BLI_assert(0); /* Should have been rejected at start of function! */
+ break;
}
-
- return false;
+
+ /* Update ID refcount, remap pointers to self in new ID. */
+ struct IDCopyLibManagementData data = {.id_src = id, .id_dst = *r_newid, .flag = flag};
+ BKE_library_foreach_ID_link(bmain, *r_newid, id_copy_libmanagement_cb, &data, IDWALK_NOP);
+
+ /* Do not make new copy local in case we are copying outside of main...
+ * XXX TODO: is this behavior OK, or should we need own flag to control that? */
+ if ((flag & LIB_ID_CREATE_NO_MAIN) == 0) {
+ BKE_id_copy_ensure_local(bmain, id, *r_newid);
+ }
+
+ return true;
+}
+
+/**
+ * Invokes the appropriate copy method for the block and returns the result in
+ * newid, unless test. Returns true if the block can be copied.
+ */
+bool id_copy(Main *bmain, const ID *id, ID **newid, bool test)
+{
+ return BKE_id_copy_ex(bmain, id, newid, 0, test);
}
/** Does *not* set ID->newid pointer. */
@@ -636,6 +708,101 @@ bool id_single_user(bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop)
return false;
}
+static int libblock_management_us_plus(void *UNUSED(user_data), ID *UNUSED(id_self), ID **id_pointer, int cb_flag)
+{
+ if (cb_flag & IDWALK_CB_USER) {
+ id_us_plus(*id_pointer);
+ }
+ if (cb_flag & IDWALK_CB_USER_ONE) {
+ id_us_ensure_real(*id_pointer);
+ }
+
+ return IDWALK_RET_NOP;
+}
+
+static int libblock_management_us_min(void *UNUSED(user_data), ID *UNUSED(id_self), ID **id_pointer, int cb_flag)
+{
+ if (cb_flag & IDWALK_CB_USER) {
+ id_us_min(*id_pointer);
+ }
+ /* We can do nothing in IDWALK_CB_USER_ONE case! */
+
+ return IDWALK_RET_NOP;
+}
+
+/** Add a 'NO_MAIN' datablock to given main (also sets usercounts of its IDs if needed). */
+void BKE_libblock_management_main_add(Main *bmain, void *idv)
+{
+ ID *id = idv;
+
+ BLI_assert(bmain != NULL);
+ if ((id->tag & LIB_TAG_NO_MAIN) == 0) {
+ return;
+ }
+
+ if ((id->tag & LIB_TAG_NOT_ALLOCATED) != 0) {
+ /* We cannot add non-allocated ID to Main! */
+ return;
+ }
+
+ /* We cannot allow non-userrefcounting IDs in Main database! */
+ if ((id->tag & LIB_TAG_NO_USER_REFCOUNT) != 0) {
+ BKE_library_foreach_ID_link(bmain, id, libblock_management_us_plus, NULL, IDWALK_NOP);
+ }
+
+ ListBase *lb = which_libbase(bmain, GS(id->name));
+ BKE_main_lock(bmain);
+ BLI_addtail(lb, id);
+ new_id(lb, id, NULL);
+ /* alphabetic insertion: is in new_id */
+ id->tag &= ~(LIB_TAG_NO_MAIN | LIB_TAG_NO_USER_REFCOUNT);
+ BKE_main_unlock(bmain);
+}
+
+/** Remove a datablock from given main (set it to 'NO_MAIN' status). */
+void BKE_libblock_management_main_remove(Main *bmain, void *idv)
+{
+ ID *id = idv;
+
+ BLI_assert(bmain != NULL);
+ if ((id->tag & LIB_TAG_NO_MAIN) != 0) {
+ return;
+ }
+
+ /* For now, allow userrefcounting IDs to get out of Main - can be handy in some cases... */
+
+ ListBase *lb = which_libbase(bmain, GS(id->name));
+ BKE_main_lock(bmain);
+ BLI_remlink(lb, id);
+ id->tag |= LIB_TAG_NO_MAIN;
+ BKE_main_unlock(bmain);
+}
+
+void BKE_libblock_management_usercounts_set(Main *bmain, void *idv)
+{
+ ID *id = idv;
+
+ if ((id->tag & LIB_TAG_NO_USER_REFCOUNT) == 0) {
+ return;
+ }
+
+ BKE_library_foreach_ID_link(bmain, id, libblock_management_us_plus, NULL, IDWALK_NOP);
+ id->tag &= ~LIB_TAG_NO_USER_REFCOUNT;
+}
+
+void BKE_libblock_management_usercounts_clear(Main *bmain, void *idv)
+{
+ ID *id = idv;
+
+ /* We do not allow IDs in Main database to not be userrefcounting. */
+ if ((id->tag & LIB_TAG_NO_USER_REFCOUNT) != 0 || (id->tag & LIB_TAG_NO_MAIN) != 0) {
+ return;
+ }
+
+ BKE_library_foreach_ID_link(bmain, id, libblock_management_us_min, NULL, IDWALK_NOP);
+ id->tag |= LIB_TAG_NO_USER_REFCOUNT;
+}
+
ListBase *which_libbase(Main *mainlib, short type)
{
switch ((ID_Type)type) {
@@ -953,23 +1120,44 @@ void *BKE_libblock_alloc_notest(short type)
* The user count is set to 1, all other content (apart from name and links) being
* initialized to zero.
*/
-void *BKE_libblock_alloc(Main *bmain, short type, const char *name)
+void *BKE_libblock_alloc(Main *bmain, short type, const char *name, const int flag)
{
- ID *id = NULL;
- ListBase *lb = which_libbase(bmain, type);
-
- id = BKE_libblock_alloc_notest(type);
+ BLI_assert((flag & LIB_ID_CREATE_NO_ALLOCATE) == 0);
+
+ ID *id = BKE_libblock_alloc_notest(type);
+
if (id) {
- BKE_main_lock(bmain);
- BLI_addtail(lb, id);
- id->us = 1;
+ if ((flag & LIB_ID_CREATE_NO_MAIN) != 0) {
+ id->tag |= LIB_TAG_NO_MAIN;
+ }
+ if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) != 0) {
+ id->tag |= LIB_TAG_NO_USER_REFCOUNT;
+ }
+
id->icon_id = 0;
- *( (short *)id->name) = type;
- new_id(lb, id, name);
- /* alphabetic insertion: is in new_id */
- BKE_main_unlock(bmain);
+ *((short *)id->name) = type;
+ if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
+ id->us = 1;
+ }
+ if ((flag & LIB_ID_CREATE_NO_MAIN) == 0) {
+ ListBase *lb = which_libbase(bmain, type);
+
+ BKE_main_lock(bmain);
+ BLI_addtail(lb, id);
+ new_id(lb, id, name);
+ /* alphabetic insertion: is in new_id */
+ BKE_main_unlock(bmain);
+
+ /* TODO to be removed from here! */
+ if ((flag & LIB_ID_CREATE_NO_DEG_TAG) == 0) {
+ DEG_id_type_tag(bmain, type);
+ }
+ }
+ else {
+ BLI_strncpy(id->name + 2, name, sizeof(id->name) - 2);
+ }
}
- DEG_id_type_tag(bmain, type);
+
return id;
}
@@ -1095,70 +1283,80 @@ void BKE_libblock_init_empty(ID *id)
/* by spec, animdata is first item after ID */
/* and, trust that BKE_animdata_from_id() will only find AnimData for valid ID-types */
-static void id_copy_animdata(ID *id, const bool do_action)
+static void id_copy_animdata(Main *bmain, ID *id, const bool do_action)
{
AnimData *adt = BKE_animdata_from_id(id);
if (adt) {
IdAdtTemplate *iat = (IdAdtTemplate *)id;
- iat->adt = BKE_animdata_copy(iat->adt, do_action); /* could be set to false, need to investigate */
+ iat->adt = BKE_animdata_copy(bmain, iat->adt, do_action); /* could be set to false, need to investigate */
}
}
-/* material nodes use this since they are not treated as libdata */
-void BKE_libblock_copy_data(ID *id, const ID *id_from, const bool do_action)
+void BKE_libblock_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag)
{
- if (id_from->properties)
- id->properties = IDP_CopyProperty(id_from->properties);
+ ID *new_id = *r_newid;
+
+ /* Grrrrrrrrr... Not adding 'root' nodetrees to bmain.... grrrrrrrrrrrrrrrrrrrr! */
+ /* This is taken from original ntree copy code, might be weak actually? */
+ const bool use_nodetree_alloc_exception = ((GS(id->name) == ID_NT) && (bmain != NULL) &&
+ (BLI_findindex(&bmain->nodetree, id) < 0));
+
+ BLI_assert((flag & LIB_ID_CREATE_NO_MAIN) != 0 || bmain != NULL);
+ BLI_assert((flag & LIB_ID_CREATE_NO_MAIN) != 0 || (flag & LIB_ID_CREATE_NO_ALLOCATE) == 0);
+ BLI_assert((flag & LIB_ID_CREATE_NO_MAIN) == 0 || (flag & LIB_ID_CREATE_NO_USER_REFCOUNT) != 0);
+
+ if ((flag & LIB_ID_CREATE_NO_ALLOCATE) != 0) {
+ /* r_newid already contains pointer to allocated memory. */
+ /* TODO do we want to memset(0) whole mem before filling it? */
+ BLI_strncpy(new_id->name, id->name, sizeof(new_id->name));
+ new_id->us = 0;
+ new_id->tag |= LIB_TAG_NOT_ALLOCATED | LIB_TAG_NO_MAIN | LIB_TAG_NO_USER_REFCOUNT;
+ /* TODO Do we want/need to copy more from ID struct itself? */
+ }
+ else {
+ new_id = BKE_libblock_alloc(bmain, GS(id->name), id->name + 2, flag | (use_nodetree_alloc_exception ? LIB_ID_CREATE_NO_MAIN : 0));
+ }
+ BLI_assert(new_id != NULL);
+
+ const size_t id_len = BKE_libblock_get_alloc_info(GS(new_id->name), NULL);
+ const size_t id_offset = sizeof(ID);
+ if ((int)id_len - (int)id_offset > 0) { /* signed to allow neg result */ /* XXX ????? */
+ const char *cp = (const char *)id;
+ char *cpn = (char *)new_id;
+
+ memcpy(cpn + id_offset, cp + id_offset, id_len - id_offset);
+ }
+
+ if (id->properties) {
+ new_id->properties = IDP_CopyProperty_ex(id->properties, flag);
+ }
/* the duplicate should get a copy of the animdata */
- id_copy_animdata(id, do_action);
+ id_copy_animdata(bmain, new_id, (flag & LIB_ID_COPY_ACTIONS) != 0 && (flag & LIB_ID_CREATE_NO_MAIN) == 0);
+
+ if ((flag & LIB_ID_CREATE_NO_DEG_TAG) == 0 && (flag & LIB_ID_CREATE_NO_MAIN) == 0) {
+ DEG_id_type_tag(bmain, GS(new_id->name));
+ }
+
+ *r_newid = new_id;
}
/* used everywhere in blenkernel */
void *BKE_libblock_copy(Main *bmain, const ID *id)
{
ID *idn;
- size_t idn_len;
-
- idn = BKE_libblock_alloc(bmain, GS(id->name), id->name + 2);
- assert(idn != NULL);
+ BKE_libblock_copy_ex(bmain, id, &idn, 0);
- idn_len = MEM_allocN_len(idn);
- if ((int)idn_len - (int)sizeof(ID) > 0) { /* signed to allow neg result */
- const char *cp = (const char *)id;
- char *cpn = (char *)idn;
-
- memcpy(cpn + sizeof(ID), cp + sizeof(ID), idn_len - sizeof(ID));
- }
-
- BKE_libblock_copy_data(idn, id, false);
-
return idn;
}
void *BKE_libblock_copy_nolib(const ID *id, const bool do_action)
{
ID *idn;
- size_t idn_len;
-
- idn = BKE_libblock_alloc_notest(GS(id->name));
- assert(idn != NULL);
-
- BLI_strncpy(idn->name, id->name, sizeof(idn->name));
-
- idn_len = MEM_allocN_len(idn);
- if ((int)idn_len - (int)sizeof(ID) > 0) { /* signed to allow neg result */
- const char *cp = (const char *)id;
- char *cpn = (char *)idn;
-
- memcpy(cpn + sizeof(ID), cp + sizeof(ID), idn_len - sizeof(ID));
- }
-
- idn->us = 1;
- BKE_libblock_copy_data(idn, id, do_action);
+ BKE_libblock_copy_ex(NULL, id, &idn, LIB_ID_CREATE_NO_MAIN | LIB_ID_CREATE_NO_USER_REFCOUNT | (do_action ? LIB_ID_COPY_ACTIONS : 0));
return idn;
}
@@ -1198,41 +1396,41 @@ void BKE_main_free(Main *mainvar)
/* errors freeing ID's can be hard to track down,
* enable this so valgrind will give the line number in its error log */
switch (a) {
- case 0: BKE_libblock_free_ex(mainvar, id, false); break;
- case 1: BKE_libblock_free_ex(mainvar, id, false); break;
- case 2: BKE_libblock_free_ex(mainvar, id, false); break;
- case 3: BKE_libblock_free_ex(mainvar, id, false); break;
- case 4: BKE_libblock_free_ex(mainvar, id, false); break;
- case 5: BKE_libblock_free_ex(mainvar, id, false); break;
- case 6: BKE_libblock_free_ex(mainvar, id, false); break;
- case 7: BKE_libblock_free_ex(mainvar, id, false); break;
- case 8: BKE_libblock_free_ex(mainvar, id, false); break;
- case 9: BKE_libblock_free_ex(mainvar, id, false); break;
- case 10: BKE_libblock_free_ex(mainvar, id, false); break;
- case 11: BKE_libblock_free_ex(mainvar, id, false); break;
- case 12: BKE_libblock_free_ex(mainvar, id, false); break;
- case 13: BKE_libblock_free_ex(mainvar, id, false); break;
- case 14: BKE_libblock_free_ex(mainvar, id, false); break;
- case 15: BKE_libblock_free_ex(mainvar, id, false); break;
- case 16: BKE_libblock_free_ex(mainvar, id, false); break;
- case 17: BKE_libblock_free_ex(mainvar, id, false); break;
- case 18: BKE_libblock_free_ex(mainvar, id, false); break;
- case 19: BKE_libblock_free_ex(mainvar, id, false); break;
- case 20: BKE_libblock_free_ex(mainvar, id, false); break;
- case 21: BKE_libblock_free_ex(mainvar, id, false); break;
- case 22: BKE_libblock_free_ex(mainvar, id, false); break;
- case 23: BKE_libblock_free_ex(mainvar, id, false); break;
- case 24: BKE_libblock_free_ex(mainvar, id, false); break;
- case 25: BKE_libblock_free_ex(mainvar, id, false); break;
- case 26: BKE_libblock_free_ex(mainvar, id, false); break;
- case 27: BKE_libblock_free_ex(mainvar, id, false); break;
- case 28: BKE_libblock_free_ex(mainvar, id, false); break;
- case 29: BKE_libblock_free_ex(mainvar, id, false); break;
- case 30: BKE_libblock_free_ex(mainvar, id, false); break;
- case 31: BKE_libblock_free_ex(mainvar, id, false); break;
- case 32: BKE_libblock_free_ex(mainvar, id, false); break;
- case 33: BKE_libblock_free_ex(mainvar, id, false); break;
- case 34: BKE_libblock_free_ex(mainvar, id, false); break;
+ case 0: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 1: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 2: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 3: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 4: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 5: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 6: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 7: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 8: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 9: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 10: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 11: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 12: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 13: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 14: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 15: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 16: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 17: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 18: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 19: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 20: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 21: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 22: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 23: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 24: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 25: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 26: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 27: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 28: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 29: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 30: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 31: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 32: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 33: BKE_libblock_free_ex(mainvar, id, false, false); break;
+ case 34: BKE_libblock_free_ex(mainvar, id, false, false); break;
default:
BLI_assert(0);
break;
diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c
index 8a42a3334bd..e397dcf7667 100644
--- a/source/blender/blenkernel/intern/library_query.c
+++ b/source/blender/blenkernel/intern/library_query.c
@@ -536,7 +536,8 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call
/* Object is special, proxies make things hard... */
const int data_cb_flag = data.cb_flag;
- const int proxy_cb_flag = (object->proxy || object->proxy_group) ? IDWALK_CB_INDIRECT_USAGE : 0;
+ const int proxy_cb_flag = ((data.flag & IDWALK_NO_INDIRECT_PROXY_DATA_USAGE) == 0 && (object->proxy || object->proxy_group)) ?
+ IDWALK_CB_INDIRECT_USAGE : 0;
/* object data special case */
data.cb_flag |= proxy_cb_flag;
diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c
index f855de0dac5..8581530907f 100644
--- a/source/blender/blenkernel/intern/library_remap.c
+++ b/source/blender/blenkernel/intern/library_remap.c
@@ -193,8 +193,8 @@ static int foreach_libblock_remap_callback(void *user_data, ID *id_self, ID **id
const bool skip_never_null = (id_remap_data->flag & ID_REMAP_SKIP_NEVER_NULL_USAGE) != 0;
#ifdef DEBUG_PRINT
- printf("In %s: Remapping %s (%p) to %s (%p) (skip_indirect: %d)\n",
- id->name, old_id->name, old_id, new_id ? new_id->name : "<NONE>", new_id, skip_indirect);
+ printf("In %s: Remapping %s (%p) to %s (%p) (is_indirect: %d, skip_indirect: %d)\n",
+ id->name, old_id->name, old_id, new_id ? new_id->name : "<NONE>", new_id, is_indirect, skip_indirect);
#endif
if ((id_remap_data->flag & ID_REMAP_FLAG_NEVER_NULL_USAGE) && (cb_flag & IDWALK_CB_NEVER_NULL)) {
@@ -208,6 +208,14 @@ static int foreach_libblock_remap_callback(void *user_data, ID *id_self, ID **id
{
if (is_indirect) {
id_remap_data->skipped_indirect++;
+ if (is_obj) {
+ Object *ob = (Object *)id;
+ if (ob->data == *id_p && ob->proxy != NULL) {
+ /* And another 'Proudly brought to you by Proxy Hell' hack!
+ * This will allow us to avoid clearing 'LIB_EXTERN' flag of obdata of proxies... */
+ id_remap_data->skipped_direct++;
+ }
+ }
}
else if (is_never_null || is_obj_editmode) {
id_remap_data->skipped_direct++;
@@ -248,7 +256,7 @@ static int foreach_libblock_remap_callback(void *user_data, ID *id_self, ID **id
return IDWALK_RET_NOP;
}
-/* Some reamapping unfortunately require extra and/or specific handling, tackle those here. */
+/* Some remapping unfortunately require extra and/or specific handling, tackle those here. */
static void libblock_remap_data_preprocess_scene_base_unlink(
IDRemap *r_id_remap_data, Scene *sce, BaseLegacy *base, const bool skip_indirect, const bool is_indirect)
{
@@ -352,7 +360,7 @@ static void libblock_remap_data_preprocess(IDRemap *r_id_remap_data)
}
}
-static void libblock_remap_data_postprocess_object_fromgroup_update(Main *bmain, Object *old_ob, Object *new_ob)
+static void libblock_remap_data_postprocess_object_update(Main *bmain, Object *old_ob, Object *new_ob)
{
if (old_ob->flag & OB_FROMGROUP) {
/* Note that for Scene's BaseObject->flag, either we:
@@ -371,6 +379,13 @@ static void libblock_remap_data_postprocess_object_fromgroup_update(Main *bmain,
new_ob->flag |= OB_FROMGROUP;
}
}
+ if (old_ob->type == OB_MBALL) {
+ for (Object *ob = bmain->object.first; ob; ob = ob->id.next) {
+ if (ob->type == OB_MBALL && BKE_mball_is_basis_for(ob, old_ob)) {
+ DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ }
+ }
+ }
}
static void libblock_remap_data_postprocess_group_scene_unlink(Main *UNUSED(bmain), Scene *sce, ID *old_id)
@@ -447,6 +462,7 @@ ATTR_NONNULL(1) static void libblock_remap_data(
IDRemap id_remap_data;
ListBase *lb_array[MAX_LIBARRAY];
int i;
+ const int foreach_id_flags = (remap_flags & ID_REMAP_NO_INDIRECT_PROXY_DATA_USAGE) != 0 ? IDWALK_NO_INDIRECT_PROXY_DATA_USAGE : IDWALK_NOP;
if (r_id_remap_data == NULL) {
r_id_remap_data = &id_remap_data;
@@ -467,7 +483,7 @@ ATTR_NONNULL(1) static void libblock_remap_data(
#endif
r_id_remap_data->id = id;
libblock_remap_data_preprocess(r_id_remap_data);
- BKE_library_foreach_ID_link(NULL, id, foreach_libblock_remap_callback, (void *)r_id_remap_data, IDWALK_NOP);
+ BKE_library_foreach_ID_link(NULL, id, foreach_libblock_remap_callback, (void *)r_id_remap_data, foreach_id_flags);
}
else {
i = set_listbasepointers(bmain, lb_array);
@@ -484,7 +500,7 @@ ATTR_NONNULL(1) static void libblock_remap_data(
r_id_remap_data->id = id_curr;
libblock_remap_data_preprocess(r_id_remap_data);
BKE_library_foreach_ID_link(
- NULL, id_curr, foreach_libblock_remap_callback, (void *)r_id_remap_data, IDWALK_NOP);
+ NULL, id_curr, foreach_libblock_remap_callback, (void *)r_id_remap_data, foreach_id_flags);
}
}
}
@@ -574,7 +590,7 @@ void BKE_libblock_remap_locked(
*/
switch (GS(old_id->name)) {
case ID_OB:
- libblock_remap_data_postprocess_object_fromgroup_update(bmain, (Object *)old_id, (Object *)new_id);
+ libblock_remap_data_postprocess_object_update(bmain, (Object *)old_id, (Object *)new_id);
break;
case ID_GR:
if (!new_id) { /* Only affects us in case group was unlinked. */
@@ -604,7 +620,7 @@ void BKE_libblock_remap_locked(
libblock_remap_data_postprocess_nodetree_update(bmain, new_id);
BKE_main_lock(bmain);
- /* Full rebuild of DAG! */
+ /* Full rebuild of DEG! */
DEG_relations_tag_update(bmain);
}
@@ -684,8 +700,7 @@ void BKE_libblock_relink_ex(
switch (GS(old_id->name)) {
case ID_OB:
{
- libblock_remap_data_postprocess_object_fromgroup_update(
- bmain, (Object *)old_id, (Object *)new_id);
+ libblock_remap_data_postprocess_object_update(bmain, (Object *)old_id, (Object *)new_id);
break;
}
case ID_GR:
@@ -700,7 +715,7 @@ void BKE_libblock_relink_ex(
else {
/* No choice but to check whole objects/groups. */
for (Object *ob = bmain->object.first; ob; ob = ob->id.next) {
- libblock_remap_data_postprocess_object_fromgroup_update(bmain, ob, NULL);
+ libblock_remap_data_postprocess_object_update(bmain, ob, NULL);
}
for (Group *grp = bmain->group.first; grp; grp = grp->id.next) {
libblock_remap_data_postprocess_group_scene_unlink(bmain, sce, NULL);
@@ -757,9 +772,11 @@ void BKE_libblock_free_data(ID *id, const bool do_id_user)
IDP_FreeProperty_ex(id->properties, do_id_user);
MEM_freeN(id->properties);
}
+
+ /* XXX TODO remove animdata handling from each type's freeing func, and do it here, like for copy! */
}
-void BKE_libblock_free_datablock(ID *id)
+void BKE_libblock_free_datablock(ID *id, const int UNUSED(flag))
{
const short type = GS(id->name);
switch (type) {
@@ -875,6 +892,90 @@ void BKE_libblock_free_datablock(ID *id)
}
}
+
+void BKE_id_free_ex(Main *bmain, void *idv, int flag, const bool use_flag_from_idtag)
+{
+ ID *id = idv;
+
+ if (use_flag_from_idtag) {
+ if ((id->tag & LIB_TAG_NO_MAIN) != 0) {
+ flag |= LIB_ID_FREE_NO_MAIN;
+ }
+ else {
+ flag &= ~LIB_ID_FREE_NO_MAIN;
+ }
+
+ if ((id->tag & LIB_TAG_NO_USER_REFCOUNT) != 0) {
+ flag |= LIB_ID_FREE_NO_USER_REFCOUNT;
+ }
+ else {
+ flag &= ~LIB_ID_FREE_NO_USER_REFCOUNT;
+ }
+
+ if ((id->tag & LIB_TAG_NOT_ALLOCATED) != 0) {
+ flag |= LIB_ID_FREE_NOT_ALLOCATED;
+ }
+ else {
+ flag &= ~LIB_ID_FREE_NOT_ALLOCATED;
+ }
+ }
+
+ BLI_assert((flag & LIB_ID_FREE_NO_MAIN) != 0 || bmain != NULL);
+ BLI_assert((flag & LIB_ID_FREE_NO_MAIN) != 0 || (flag & LIB_ID_FREE_NOT_ALLOCATED) == 0);
+ BLI_assert((flag & LIB_ID_FREE_NO_MAIN) != 0 || (flag & LIB_ID_FREE_NO_USER_REFCOUNT) == 0);
+
+ const short type = GS(id->name);
+
+ if (bmain && (flag & LIB_ID_FREE_NO_DEG_TAG) == 0) {
+ DEG_id_type_tag(bmain, type);
+ }
+
+#ifdef WITH_PYTHON
+ BPY_id_release(id);
+#endif
+
+ if ((flag & LIB_ID_FREE_NO_USER_REFCOUNT) == 0) {
+ BKE_libblock_relink_ex(bmain, id, NULL, NULL, true);
+ }
+
+ BKE_libblock_free_datablock(id, flag);
+
+ /* avoid notifying on removed data */
+ if (bmain) {
+ BKE_main_lock(bmain);
+ }
+
+ if ((flag & LIB_ID_FREE_NO_UI_USER) == 0) {
+ if (free_notifier_reference_cb) {
+ free_notifier_reference_cb(id);
+ }
+
+ if (remap_editor_id_reference_cb) {
+ remap_editor_id_reference_cb(id, NULL);
+ }
+ }
+
+ if ((flag & LIB_ID_FREE_NO_MAIN) == 0) {
+ ListBase *lb = which_libbase(bmain, type);
+ BLI_remlink(lb, id);
+ }
+
+ BKE_libblock_free_data(id, (flag & LIB_ID_FREE_NO_USER_REFCOUNT) == 0);
+
+ if (bmain) {
+ BKE_main_unlock(bmain);
+ }
+
+ if ((flag & LIB_ID_FREE_NOT_ALLOCATED) == 0) {
+ MEM_freeN(id);
+ }
+}
+
+void BKE_id_free(Main *bmain, void *idv)
+{
+ BKE_id_free_ex(bmain, idv, 0, true);
+}
+
/**
* used in headerbuttons.c image.c mesh.c screen.c sound.c and library.c
*
@@ -892,14 +993,19 @@ void BKE_libblock_free_ex(Main *bmain, void *idv, const bool do_id_user, const b
DEG_id_type_tag(bmain, type);
#ifdef WITH_PYTHON
+#ifdef WITH_PYTHON_SAFETY
BPY_id_release(id);
#endif
+ if (id->py_instance) {
+ BPY_DECREF_RNA_INVALIDATE(id->py_instance);
+ }
+#endif
if (do_id_user) {
BKE_libblock_relink_ex(bmain, id, NULL, NULL, true);
}
- BKE_libblock_free_datablock(id);
+ BKE_libblock_free_datablock(id, 0);
/* avoid notifying on removed data */
BKE_main_lock(bmain);
diff --git a/source/blender/blenkernel/intern/lightprobe.c b/source/blender/blenkernel/intern/lightprobe.c
index a1fa266512b..03bd2344f7b 100644
--- a/source/blender/blenkernel/intern/lightprobe.c
+++ b/source/blender/blenkernel/intern/lightprobe.c
@@ -25,7 +25,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/blenkernel/intern/probe.c
+/** \file blender/blenkernel/intern/lightprobe.c
* \ingroup bke
*/
@@ -59,22 +59,32 @@ void *BKE_lightprobe_add(Main *bmain, const char *name)
{
LightProbe *probe;
- probe = BKE_libblock_alloc(bmain, ID_LP, name);
+ probe = BKE_libblock_alloc(bmain, ID_LP, name, 0);
BKE_lightprobe_init(probe);
return probe;
}
-LightProbe *BKE_lightprobe_copy(Main *bmain, LightProbe *probe)
+/**
+ * Only copy internal data of LightProbe ID from source to already allocated/initialized destination.
+ * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
+ *
+ * WARNING! This function will not handle ID user count!
+ *
+ * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
+ */
+void BKE_lightprobe_copy_data(
+ Main *UNUSED(bmain), LightProbe *UNUSED(probe_dst), const LightProbe *UNUSED(probe_src), const int UNUSED(flag))
{
- LightProbe *probe_new;
-
- probe_new = BKE_libblock_copy(bmain, &probe->id);
-
- BKE_id_copy_ensure_local(bmain, &probe->id, &probe_new->id);
+ /* Nothing to do here. */
+}
- return probe_new;
+LightProbe *BKE_lightprobe_copy(Main *bmain, const LightProbe *probe)
+{
+ LightProbe *probe_copy;
+ BKE_id_copy_ex(bmain, &probe->id, (ID **)&probe_copy, 0, false);
+ return probe_copy;
}
void BKE_lightprobe_make_local(Main *bmain, LightProbe *probe, const bool lib_local)
diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c
index 771e81ddc4f..1b1a12e702a 100644
--- a/source/blender/blenkernel/intern/linestyle.c
+++ b/source/blender/blenkernel/intern/linestyle.c
@@ -119,7 +119,7 @@ FreestyleLineStyle *BKE_linestyle_new(struct Main *bmain, const char *name)
{
FreestyleLineStyle *linestyle;
- linestyle = (FreestyleLineStyle *)BKE_libblock_alloc(bmain, ID_LS, name);
+ linestyle = (FreestyleLineStyle *)BKE_libblock_alloc(bmain, ID_LS, name, 0);
BKE_linestyle_init(linestyle);
@@ -155,73 +155,54 @@ void BKE_linestyle_free(FreestyleLineStyle *linestyle)
BKE_linestyle_geometry_modifier_remove(linestyle, m);
}
-FreestyleLineStyle *BKE_linestyle_copy(struct Main *bmain, const FreestyleLineStyle *linestyle)
+/**
+ * Only copy internal data of Linestyle ID from source to already allocated/initialized destination.
+ * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
+ *
+ * WARNING! This function will not handle ID user count!
+ *
+ * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
+ */
+void BKE_linestyle_copy_data(
+ struct Main *bmain, FreestyleLineStyle *linestyle_dst, const FreestyleLineStyle *linestyle_src, const int flag)
{
- FreestyleLineStyle *new_linestyle;
- LineStyleModifier *m;
- int a;
+ /* We never handle usercount here for own data. */
+ const int flag_subdata = flag | LIB_ID_CREATE_NO_USER_REFCOUNT;
- new_linestyle = BKE_linestyle_new(bmain, linestyle->id.name + 2);
- BKE_linestyle_free(new_linestyle);
-
- for (a = 0; a < MAX_MTEX; a++) {
- if (linestyle->mtex[a]) {
- new_linestyle->mtex[a] = MEM_mallocN(sizeof(MTex), "BKE_linestyle_copy");
- memcpy(new_linestyle->mtex[a], linestyle->mtex[a], sizeof(MTex));
- id_us_plus((ID *)new_linestyle->mtex[a]->tex);
+ for (int a = 0; a < MAX_MTEX; a++) {
+ if (linestyle_src->mtex[a]) {
+ linestyle_dst->mtex[a] = MEM_mallocN(sizeof(*linestyle_dst->mtex[a]), __func__);
+ *linestyle_dst->mtex[a] = *linestyle_src->mtex[a];
}
}
- if (linestyle->nodetree) {
- new_linestyle->nodetree = ntreeCopyTree(bmain, linestyle->nodetree);
+ if (linestyle_src->nodetree) {
+ BKE_id_copy_ex(bmain, (ID *)linestyle_src->nodetree, (ID **)&linestyle_dst->nodetree, flag, false);
}
- new_linestyle->r = linestyle->r;
- new_linestyle->g = linestyle->g;
- new_linestyle->b = linestyle->b;
- new_linestyle->alpha = linestyle->alpha;
- new_linestyle->thickness = linestyle->thickness;
- new_linestyle->thickness_position = linestyle->thickness_position;
- new_linestyle->thickness_ratio = linestyle->thickness_ratio;
- new_linestyle->flag = linestyle->flag;
- new_linestyle->caps = linestyle->caps;
- new_linestyle->chaining = linestyle->chaining;
- new_linestyle->rounds = linestyle->rounds;
- new_linestyle->split_length = linestyle->split_length;
- new_linestyle->min_angle = linestyle->min_angle;
- new_linestyle->max_angle = linestyle->max_angle;
- new_linestyle->min_length = linestyle->min_length;
- new_linestyle->max_length = linestyle->max_length;
- new_linestyle->chain_count = linestyle->chain_count;
- new_linestyle->split_dash1 = linestyle->split_dash1;
- new_linestyle->split_gap1 = linestyle->split_gap1;
- new_linestyle->split_dash2 = linestyle->split_dash2;
- new_linestyle->split_gap2 = linestyle->split_gap2;
- new_linestyle->split_dash3 = linestyle->split_dash3;
- new_linestyle->split_gap3 = linestyle->split_gap3;
- new_linestyle->dash1 = linestyle->dash1;
- new_linestyle->gap1 = linestyle->gap1;
- new_linestyle->dash2 = linestyle->dash2;
- new_linestyle->gap2 = linestyle->gap2;
- new_linestyle->dash3 = linestyle->dash3;
- new_linestyle->gap3 = linestyle->gap3;
- new_linestyle->panel = linestyle->panel;
- new_linestyle->sort_key = linestyle->sort_key;
- new_linestyle->integration_type = linestyle->integration_type;
- new_linestyle->texstep = linestyle->texstep;
- new_linestyle->pr_texture = linestyle->pr_texture;
- new_linestyle->use_nodes = linestyle->use_nodes;
- for (m = (LineStyleModifier *)linestyle->color_modifiers.first; m; m = m->next)
- BKE_linestyle_color_modifier_copy(new_linestyle, m);
- for (m = (LineStyleModifier *)linestyle->alpha_modifiers.first; m; m = m->next)
- BKE_linestyle_alpha_modifier_copy(new_linestyle, m);
- for (m = (LineStyleModifier *)linestyle->thickness_modifiers.first; m; m = m->next)
- BKE_linestyle_thickness_modifier_copy(new_linestyle, m);
- for (m = (LineStyleModifier *)linestyle->geometry_modifiers.first; m; m = m->next)
- BKE_linestyle_geometry_modifier_copy(new_linestyle, m);
-
- BKE_id_copy_ensure_local(bmain, &linestyle->id, &new_linestyle->id);
-
- return new_linestyle;
+ LineStyleModifier *m;
+ BLI_listbase_clear(&linestyle_dst->color_modifiers);
+ for (m = (LineStyleModifier *)linestyle_src->color_modifiers.first; m; m = m->next) {
+ BKE_linestyle_color_modifier_copy(linestyle_dst, m, flag_subdata);
+ }
+ BLI_listbase_clear(&linestyle_dst->alpha_modifiers);
+ for (m = (LineStyleModifier *)linestyle_src->alpha_modifiers.first; m; m = m->next) {
+ BKE_linestyle_alpha_modifier_copy(linestyle_dst, m, flag_subdata);
+ }
+ BLI_listbase_clear(&linestyle_dst->thickness_modifiers);
+ for (m = (LineStyleModifier *)linestyle_src->thickness_modifiers.first; m; m = m->next) {
+ BKE_linestyle_thickness_modifier_copy(linestyle_dst, m, flag_subdata);
+ }
+ BLI_listbase_clear(&linestyle_dst->geometry_modifiers);
+ for (m = (LineStyleModifier *)linestyle_src->geometry_modifiers.first; m; m = m->next) {
+ BKE_linestyle_geometry_modifier_copy(linestyle_dst, m, flag_subdata);
+ }
+}
+
+FreestyleLineStyle *BKE_linestyle_copy(struct Main *bmain, const FreestyleLineStyle *linestyle)
+{
+ FreestyleLineStyle *linestyle_copy;
+ BKE_id_copy_ex(bmain, &linestyle->id, (ID **)&linestyle_copy, 0, false);
+ return linestyle_copy;
}
void BKE_linestyle_make_local(struct Main *bmain, FreestyleLineStyle *linestyle, const bool lib_local)
@@ -355,7 +336,8 @@ LineStyleModifier *BKE_linestyle_color_modifier_add(FreestyleLineStyle *linestyl
return m;
}
-LineStyleModifier *BKE_linestyle_color_modifier_copy(FreestyleLineStyle *linestyle, const LineStyleModifier *m)
+LineStyleModifier *BKE_linestyle_color_modifier_copy(
+ FreestyleLineStyle *linestyle, const LineStyleModifier *m, const int flag)
{
LineStyleModifier *new_m;
@@ -388,9 +370,10 @@ LineStyleModifier *BKE_linestyle_color_modifier_copy(FreestyleLineStyle *linesty
{
LineStyleColorModifier_DistanceFromObject *p = (LineStyleColorModifier_DistanceFromObject *)m;
LineStyleColorModifier_DistanceFromObject *q = (LineStyleColorModifier_DistanceFromObject *)new_m;
- if (p->target)
- id_us_plus(&p->target->id);
q->target = p->target;
+ if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
+ id_us_plus((ID *)q->target);
+ }
q->color_ramp = MEM_dupallocN(p->color_ramp);
q->range_min = p->range_min;
q->range_max = p->range_max;
@@ -594,7 +577,8 @@ LineStyleModifier *BKE_linestyle_alpha_modifier_add(FreestyleLineStyle *linestyl
return m;
}
-LineStyleModifier *BKE_linestyle_alpha_modifier_copy(FreestyleLineStyle *linestyle, const LineStyleModifier *m)
+LineStyleModifier *BKE_linestyle_alpha_modifier_copy(
+ FreestyleLineStyle *linestyle, const LineStyleModifier *m, const int UNUSED(flag))
{
LineStyleModifier *new_m;
@@ -863,7 +847,8 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_add(FreestyleLineStyle *line
return m;
}
-LineStyleModifier *BKE_linestyle_thickness_modifier_copy(FreestyleLineStyle *linestyle, const LineStyleModifier *m)
+LineStyleModifier *BKE_linestyle_thickness_modifier_copy(
+ FreestyleLineStyle *linestyle, const LineStyleModifier *m, const int flag)
{
LineStyleModifier *new_m;
@@ -901,9 +886,10 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_copy(FreestyleLineStyle *lin
{
LineStyleThicknessModifier_DistanceFromObject *p = (LineStyleThicknessModifier_DistanceFromObject *)m;
LineStyleThicknessModifier_DistanceFromObject *q = (LineStyleThicknessModifier_DistanceFromObject *)new_m;
- if (p->target)
- id_us_plus(&p->target->id);
q->target = p->target;
+ if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
+ id_us_plus((ID *)q->target);
+ }
q->curve = curvemapping_copy(p->curve);
q->flags = p->flags;
q->range_min = p->range_min;
@@ -1195,7 +1181,8 @@ LineStyleModifier *BKE_linestyle_geometry_modifier_add(FreestyleLineStyle *lines
return m;
}
-LineStyleModifier *BKE_linestyle_geometry_modifier_copy(FreestyleLineStyle *linestyle, const LineStyleModifier *m)
+LineStyleModifier *BKE_linestyle_geometry_modifier_copy(
+ FreestyleLineStyle *linestyle, const LineStyleModifier *m, const int UNUSED(flag))
{
LineStyleModifier *new_m;
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c
index ae27e9bcd34..1e9447c4f09 100644
--- a/source/blender/blenkernel/intern/mask.c
+++ b/source/blender/blenkernel/intern/mask.c
@@ -61,6 +61,8 @@
#include "BKE_movieclip.h"
#include "BKE_image.h"
+#include "DEG_depsgraph_build.h"
+
static struct {
ListBase splines;
struct GHash *id_hash;
@@ -794,7 +796,7 @@ static Mask *mask_alloc(Main *bmain, const char *name)
{
Mask *mask;
- mask = BKE_libblock_alloc(bmain, ID_MSK, name);
+ mask = BKE_libblock_alloc(bmain, ID_MSK, name, 0);
id_fake_user_set(&mask->id);
@@ -817,10 +819,13 @@ Mask *BKE_mask_new(Main *bmain, const char *name)
mask->sfra = 1;
mask->efra = 100;
+ DEG_relations_tag_update(bmain);
+
return mask;
}
/* TODO(sergey): Use generic BKE_libblock_copy_nolib() instead. */
+/* TODO(bastien): Use new super cool & generic BKE_id_copy_ex() instead! */
Mask *BKE_mask_copy_nolib(Mask *mask)
{
Mask *mask_new;
@@ -840,22 +845,29 @@ Mask *BKE_mask_copy_nolib(Mask *mask)
return mask_new;
}
-Mask *BKE_mask_copy(Main *bmain, const Mask *mask)
+/**
+ * Only copy internal data of Mask ID from source to already allocated/initialized destination.
+ * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
+ *
+ * WARNING! This function will not handle ID user count!
+ *
+ * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
+ */
+void BKE_mask_copy_data(Main *UNUSED(bmain), Mask *mask_dst, const Mask *mask_src, const int UNUSED(flag))
{
- Mask *mask_new;
+ BLI_listbase_clear(&mask_dst->masklayers);
- mask_new = BKE_libblock_copy(bmain, &mask->id);
-
- BLI_listbase_clear(&mask_new->masklayers);
-
- BKE_mask_layer_copy_list(&mask_new->masklayers, &mask->masklayers);
+ BKE_mask_layer_copy_list(&mask_dst->masklayers, &mask_src->masklayers); /* TODO add unused flag to those as well. */
/* enable fake user by default */
- id_fake_user_set(&mask_new->id);
-
- BKE_id_copy_ensure_local(bmain, &mask->id, &mask_new->id);
+ id_fake_user_set(&mask_dst->id);
+}
- return mask_new;
+Mask *BKE_mask_copy(Main *bmain, const Mask *mask)
+{
+ Mask *mask_copy;
+ BKE_id_copy_ex(bmain, &mask->id, (ID **)&mask_copy, 0, false);
+ return mask_copy;
}
void BKE_mask_make_local(Main *bmain, Mask *mask, const bool lib_local)
@@ -1171,17 +1183,6 @@ void BKE_mask_point_parent_matrix_get(MaskSplinePoint *point, float ctime, float
}
}
-static void mask_evaluate_apply_point_parent(MaskSplinePoint *point, float ctime)
-{
- float parent_matrix[3][3];
-
- BKE_mask_point_parent_matrix_get(point, ctime, parent_matrix);
-
- mul_m3_v2(parent_matrix, point->bezt.vec[0]);
- mul_m3_v2(parent_matrix, point->bezt.vec[1]);
- mul_m3_v2(parent_matrix, point->bezt.vec[2]);
-}
-
static void mask_calc_point_handle(MaskSplinePoint *point, MaskSplinePoint *point_prev, MaskSplinePoint *point_next)
{
BezTriple *bezt = &point->bezt;
@@ -1397,80 +1398,12 @@ void BKE_mask_spline_ensure_deform(MaskSpline *spline)
void BKE_mask_layer_evaluate(MaskLayer *masklay, const float ctime, const bool do_newframe)
{
- /* animation if available */
+ /* Animation if available. */
if (do_newframe) {
- MaskLayerShape *masklay_shape_a;
- MaskLayerShape *masklay_shape_b;
- int found;
-
- if ((found = BKE_mask_layer_shape_find_frame_range(masklay, ctime,
- &masklay_shape_a, &masklay_shape_b)))
- {
- if (found == 1) {
-#if 0
- printf("%s: exact %d %d (%d)\n", __func__, (int)ctime, BLI_listbase_count(&masklay->splines_shapes),
- masklay_shape_a->frame);
-#endif
-
- BKE_mask_layer_shape_to_mask(masklay, masklay_shape_a);
- }
- else if (found == 2) {
- float w = masklay_shape_b->frame - masklay_shape_a->frame;
-#if 0
- printf("%s: tween %d %d (%d %d)\n", __func__, (int)ctime, BLI_listbase_count(&masklay->splines_shapes),
- masklay_shape_a->frame, masklay_shape_b->frame);
-#endif
- BKE_mask_layer_shape_to_mask_interp(masklay, masklay_shape_a, masklay_shape_b,
- (ctime - masklay_shape_a->frame) / w);
- }
- else {
- /* always fail, should never happen */
- BLI_assert(found == 2);
- }
- }
- }
- /* animation done... */
-
- BKE_mask_layer_calc_handles(masklay);
-
- /* update deform */
- {
- MaskSpline *spline;
-
- for (spline = masklay->splines.first; spline; spline = spline->next) {
- int i;
- bool need_handle_recalc = false;
-
- BKE_mask_spline_ensure_deform(spline);
-
- for (i = 0; i < spline->tot_point; i++) {
- MaskSplinePoint *point = &spline->points[i];
- MaskSplinePoint *point_deform = &spline->points_deform[i];
-
- BKE_mask_point_free(point_deform);
-
- *point_deform = *point;
- point_deform->uw = point->uw ? MEM_dupallocN(point->uw) : NULL;
-
- mask_evaluate_apply_point_parent(point_deform, ctime);
-
- if (ELEM(point->bezt.h1, HD_AUTO, HD_VECT)) {
- need_handle_recalc = true;
- }
- }
-
- /* if the spline has auto or vector handles, these need to be recalculated after deformation */
- if (need_handle_recalc) {
- for (i = 0; i < spline->tot_point; i++) {
- MaskSplinePoint *point_deform = &spline->points_deform[i];
- if (ELEM(point_deform->bezt.h1, HD_AUTO, HD_VECT)) {
- BKE_mask_calc_handle_point(spline, point_deform);
- }
- }
- }
- /* end extra calc handles loop */
- }
+ BKE_mask_layer_evaluate_animation(masklay, ctime);
}
+ /* Update deform. */
+ BKE_mask_layer_evaluate_deform(masklay, ctime);
}
void BKE_mask_evaluate(Mask *mask, const float ctime, const bool do_newframe)
diff --git a/source/blender/blenkernel/intern/mask_evaluate.c b/source/blender/blenkernel/intern/mask_evaluate.c
index 1b275f455f4..f60d87f2464 100644
--- a/source/blender/blenkernel/intern/mask_evaluate.c
+++ b/source/blender/blenkernel/intern/mask_evaluate.c
@@ -42,8 +42,11 @@
#include "DNA_mask_types.h"
#include "BKE_curve.h"
+#include "BKE_global.h"
#include "BKE_mask.h"
+#include "DEG_depsgraph.h"
+
unsigned int BKE_mask_spline_resolution(MaskSpline *spline, int width, int height)
{
@@ -810,3 +813,111 @@ float *BKE_mask_point_segment_diff(MaskSpline *spline, MaskSplinePoint *point,
return diff_points;
}
+
+static void mask_evaluate_apply_point_parent(MaskSplinePoint *point, float ctime)
+{
+ float parent_matrix[3][3];
+ BKE_mask_point_parent_matrix_get(point, ctime, parent_matrix);
+ mul_m3_v2(parent_matrix, point->bezt.vec[0]);
+ mul_m3_v2(parent_matrix, point->bezt.vec[1]);
+ mul_m3_v2(parent_matrix, point->bezt.vec[2]);
+}
+
+void BKE_mask_layer_evaluate_animation(MaskLayer *masklay, const float ctime)
+{
+ /* animation if available */
+ MaskLayerShape *masklay_shape_a;
+ MaskLayerShape *masklay_shape_b;
+ int found;
+ if ((found = BKE_mask_layer_shape_find_frame_range(
+ masklay, ctime, &masklay_shape_a, &masklay_shape_b)))
+ {
+ if (found == 1) {
+#if 0
+ printf("%s: exact %d %d (%d)\n",
+ __func__,
+ (int)ctime,
+ BLI_listbase_count(&masklay->splines_shapes),
+ masklay_shape_a->frame);
+#endif
+ BKE_mask_layer_shape_to_mask(masklay, masklay_shape_a);
+ }
+ else if (found == 2) {
+ float w = masklay_shape_b->frame - masklay_shape_a->frame;
+#if 0
+ printf("%s: tween %d %d (%d %d)\n",
+ __func__,
+ (int)ctime,
+ BLI_listbase_count(&masklay->splines_shapes),
+ masklay_shape_a->frame, masklay_shape_b->frame);
+#endif
+ BKE_mask_layer_shape_to_mask_interp(
+ masklay,
+ masklay_shape_a, masklay_shape_b,
+ (ctime - masklay_shape_a->frame) / w);
+ }
+ else {
+ /* always fail, should never happen */
+ BLI_assert(found == 2);
+ }
+ }
+}
+
+void BKE_mask_layer_evaluate_deform(MaskLayer *masklay, const float ctime)
+{
+ BKE_mask_layer_calc_handles(masklay);
+ for (MaskSpline *spline = masklay->splines.first;
+ spline != NULL;
+ spline = spline->next)
+ {
+ bool need_handle_recalc = false;
+ BKE_mask_spline_ensure_deform(spline);
+ for (int i = 0; i < spline->tot_point; i++) {
+ MaskSplinePoint *point = &spline->points[i];
+ MaskSplinePoint *point_deform = &spline->points_deform[i];
+ BKE_mask_point_free(point_deform);
+ *point_deform = *point;
+ point_deform->uw = point->uw ? MEM_dupallocN(point->uw) : NULL;
+ mask_evaluate_apply_point_parent(point_deform, ctime);
+ if (ELEM(point->bezt.h1, HD_AUTO, HD_VECT)) {
+ need_handle_recalc = true;
+ }
+ }
+ /* if the spline has auto or vector handles, these need to be
+ * recalculated after deformation.
+ */
+ if (need_handle_recalc) {
+ for (int i = 0; i < spline->tot_point; i++) {
+ MaskSplinePoint *point_deform = &spline->points_deform[i];
+ if (ELEM(point_deform->bezt.h1, HD_AUTO, HD_VECT)) {
+ BKE_mask_calc_handle_point(spline, point_deform);
+ }
+ }
+ }
+ /* end extra calc handles loop */
+ }
+}
+
+#define DEBUG_PRINT if (G.debug & G_DEBUG_DEPSGRAPH) printf
+
+void BKE_mask_eval_animation(struct EvaluationContext *eval_ctx, Mask *mask)
+{
+ DEBUG_PRINT("%s on %s (%p)\n", __func__, mask->id.name, mask);
+ for (MaskLayer *mask_layer = mask->masklayers.first;
+ mask_layer != NULL;
+ mask_layer = mask_layer->next)
+ {
+ BKE_mask_layer_evaluate_animation(mask_layer, eval_ctx->ctime);
+ }
+}
+
+void BKE_mask_eval_update(struct EvaluationContext *eval_ctx, Mask *mask)
+{
+ DEBUG_PRINT("%s on %s (%p)\n", __func__, mask->id.name, mask);
+ for (MaskLayer *mask_layer = mask->masklayers.first;
+ mask_layer != NULL;
+ mask_layer = mask_layer->next)
+ {
+ BKE_mask_layer_evaluate_deform(mask_layer, eval_ctx->ctime);
+ }
+}
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 824151f9c98..3a742520471 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -207,59 +207,78 @@ void BKE_material_init(Material *ma)
ma->mode2 = MA_CASTSHADOW;
ma->shade_flag = MA_APPROX_OCCLUSION;
ma->preview = NULL;
+
+ ma->alpha_threshold = 0.5f;
}
Material *BKE_material_add(Main *bmain, const char *name)
{
Material *ma;
- ma = BKE_libblock_alloc(bmain, ID_MA, name);
+ ma = BKE_libblock_alloc(bmain, ID_MA, name, 0);
BKE_material_init(ma);
return ma;
}
-/* XXX keep synced with next function */
-Material *BKE_material_copy(Main *bmain, const Material *ma)
+/**
+ * Only copy internal data of Material ID from source to already allocated/initialized destination.
+ * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
+ *
+ * WARNING! This function will not handle ID user count!
+ *
+ * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
+ */
+void BKE_material_copy_data(Main *bmain, Material *ma_dst, const Material *ma_src, const int flag)
{
- Material *man;
- int a;
-
- man = BKE_libblock_copy(bmain, &ma->id);
-
- id_lib_extern((ID *)man->group);
- id_lib_extern((ID *)man->edit_image);
-
- for (a = 0; a < MAX_MTEX; a++) {
- if (ma->mtex[a]) {
- man->mtex[a] = MEM_mallocN(sizeof(MTex), "copymaterial");
- memcpy(man->mtex[a], ma->mtex[a], sizeof(MTex));
- id_us_plus((ID *)man->mtex[a]->tex);
+ for (int a = 0; a < MAX_MTEX; a++) {
+ if (ma_src->mtex[a]) {
+ ma_dst->mtex[a] = MEM_mallocN(sizeof(*ma_dst->mtex[a]), __func__);
+ *ma_dst->mtex[a] = *ma_src->mtex[a];
}
}
-
- if (ma->ramp_col) man->ramp_col = MEM_dupallocN(ma->ramp_col);
- if (ma->ramp_spec) man->ramp_spec = MEM_dupallocN(ma->ramp_spec);
-
- if (ma->nodetree) {
- man->nodetree = ntreeCopyTree(bmain, ma->nodetree);
+
+ if (ma_src->ramp_col) {
+ ma_dst->ramp_col = MEM_dupallocN(ma_src->ramp_col);
+ }
+ if (ma_src->ramp_spec) {
+ ma_dst->ramp_spec = MEM_dupallocN(ma_src->ramp_spec);
}
- BKE_previewimg_id_copy(&man->id, &ma->id);
+ if (ma_src->nodetree) {
+ BKE_id_copy_ex(bmain, (ID *)ma_src->nodetree, (ID **)&ma_dst->nodetree, flag, false);
+ }
- BLI_listbase_clear(&man->gpumaterial);
+ if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0) {
+ BKE_previewimg_id_copy(&ma_dst->id, &ma_src->id);
+ }
+ else {
+ ma_dst->preview = NULL;
+ }
- /* TODO Duplicate Engine Settings and set runtime to NULL */
+ BLI_listbase_clear(&ma_dst->gpumaterial);
- BKE_id_copy_ensure_local(bmain, &ma->id, &man->id);
+ /* TODO Duplicate Engine Settings and set runtime to NULL */
+}
- return man;
+Material *BKE_material_copy(Main *bmain, const Material *ma)
+{
+ Material *ma_copy;
+ BKE_id_copy_ex(bmain, &ma->id, (ID **)&ma_copy, 0, false);
+ return ma_copy;
}
/* XXX (see above) material copy without adding to main dbase */
Material *localize_material(Material *ma)
{
+ /* TODO replace with something like
+ * Material *ma_copy;
+ * BKE_id_copy_ex(bmain, &ma->id, (ID **)&ma_copy, LIB_ID_COPY_NO_MAIN | LIB_ID_COPY_NO_PREVIEW | LIB_ID_COPY_NO_USER_REFCOUNT, false);
+ * return ma_copy;
+ *
+ * ... Once f*** nodes are fully converted to that too :( */
+
Material *man;
int a;
@@ -349,6 +368,8 @@ Material ***give_matarar_id(ID *id)
return &(((Curve *)id)->mat);
case ID_MB:
return &(((MetaBall *)id)->mat);
+ default:
+ break;
}
return NULL;
}
@@ -365,6 +386,8 @@ short *give_totcolp_id(ID *id)
return &(((Curve *)id)->totcol);
case ID_MB:
return &(((MetaBall *)id)->totcol);
+ default:
+ break;
}
return NULL;
}
@@ -384,6 +407,8 @@ static void material_data_index_remove_id(ID *id, short index)
case ID_MB:
/* meta-elems don't have materials atm */
break;
+ default:
+ break;
}
}
@@ -402,6 +427,8 @@ static void material_data_index_clear_id(ID *id)
case ID_MB:
/* meta-elems don't have materials atm */
break;
+ default:
+ break;
}
}
@@ -1795,3 +1822,13 @@ bool BKE_object_material_edit_image_set(Object *ob, short mat_nr, Image *image)
}
return false;
}
+
+void BKE_material_eval(const struct EvaluationContext *UNUSED(eval_ctx), Material *material)
+{
+ if (G.debug & G_DEBUG_DEPSGRAPH) {
+ printf("%s on %s (%p)\n", __func__, material->id.name, material);
+ }
+ if ((BLI_listbase_is_empty(&material->gpumaterial) == false)) {
+ GPU_material_uniform_buffer_tag_dirty(&material->gpumaterial);
+ }
+}
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index 27e2b17b4e2..f1e549b1400 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -97,33 +97,36 @@ MetaBall *BKE_mball_add(Main *bmain, const char *name)
{
MetaBall *mb;
- mb = BKE_libblock_alloc(bmain, ID_MB, name);
+ mb = BKE_libblock_alloc(bmain, ID_MB, name, 0);
BKE_mball_init(mb);
return mb;
}
-MetaBall *BKE_mball_copy(Main *bmain, const MetaBall *mb)
+/**
+ * Only copy internal data of MetaBall ID from source to already allocated/initialized destination.
+ * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
+ *
+ * WARNING! This function will not handle ID user count!
+ *
+ * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
+ */
+void BKE_mball_copy_data(Main *UNUSED(bmain), MetaBall *mb_dst, const MetaBall *mb_src, const int UNUSED(flag))
{
- MetaBall *mbn;
- int a;
-
- mbn = BKE_libblock_copy(bmain, &mb->id);
+ BLI_duplicatelist(&mb_dst->elems, &mb_src->elems);
- BLI_duplicatelist(&mbn->elems, &mb->elems);
-
- mbn->mat = MEM_dupallocN(mb->mat);
- for (a = 0; a < mbn->totcol; a++) {
- id_us_plus((ID *)mbn->mat[a]);
- }
+ mb_dst->mat = MEM_dupallocN(mb_src->mat);
- mbn->editelems = NULL;
- mbn->lastelem = NULL;
-
- BKE_id_copy_ensure_local(bmain, &mb->id, &mbn->id);
+ mb_dst->editelems = NULL;
+ mb_dst->lastelem = NULL;
+}
- return mbn;
+MetaBall *BKE_mball_copy(Main *bmain, const MetaBall *mb)
+{
+ MetaBall *mb_copy;
+ BKE_id_copy_ex(bmain, &mb->id, (ID **)&mb_copy, 0, false);
+ return mb_copy;
}
void BKE_mball_make_local(Main *bmain, MetaBall *mb, const bool lib_local)
@@ -469,7 +472,7 @@ bool BKE_mball_center_bounds(MetaBall *mb, float r_cent[3])
return false;
}
-void BKE_mball_transform(MetaBall *mb, float mat[4][4])
+void BKE_mball_transform(MetaBall *mb, float mat[4][4], const bool do_props)
{
MetaElem *me;
float quat[4];
@@ -481,14 +484,17 @@ void BKE_mball_transform(MetaBall *mb, float mat[4][4])
for (me = mb->elems.first; me; me = me->next) {
mul_m4_v3(mat, &me->x);
mul_qt_qtqt(me->quat, quat, me->quat);
- me->rad *= scale;
- /* hrmf, probably elems shouldn't be
- * treating scale differently - campbell */
- if (!MB_TYPE_SIZE_SQUARED(me->type)) {
- mul_v3_fl(&me->expx, scale);
- }
- else {
- mul_v3_fl(&me->expx, scale_sqrt);
+
+ if (do_props) {
+ me->rad *= scale;
+ /* hrmf, probably elems shouldn't be
+ * treating scale differently - campbell */
+ if (!MB_TYPE_SIZE_SQUARED(me->type)) {
+ mul_v3_fl(&me->expx, scale);
+ }
+ else {
+ mul_v3_fl(&me->expx, scale_sqrt);
+ }
}
}
}
@@ -532,7 +538,7 @@ void BKE_mball_select_swap(struct MetaBall *mb)
/* **** Depsgraph evaluation **** */
-void BKE_mball_eval_geometry(struct EvaluationContext *UNUSED(eval_ctx),
+void BKE_mball_eval_geometry(const struct EvaluationContext *UNUSED(eval_ctx),
MetaBall *UNUSED(mball))
{
}
diff --git a/source/blender/blenkernel/intern/mball_tessellate.c b/source/blender/blenkernel/intern/mball_tessellate.c
index d897213d362..d8e3df239df 100644
--- a/source/blender/blenkernel/intern/mball_tessellate.c
+++ b/source/blender/blenkernel/intern/mball_tessellate.c
@@ -424,13 +424,13 @@ static void make_face(PROCESS *process, int i1, int i2, int i3, int i4)
#ifdef USE_ACCUM_NORMAL
if (i4 == 0) {
normal_tri_v3(n, process->co[i1], process->co[i2], process->co[i3]);
- accumulate_vertex_normals(
+ accumulate_vertex_normals_v3(
process->no[i1], process->no[i2], process->no[i3], NULL, n,
process->co[i1], process->co[i2], process->co[i3], NULL);
}
else {
normal_quad_v3(n, process->co[i1], process->co[i2], process->co[i3], process->co[i4]);
- accumulate_vertex_normals(
+ accumulate_vertex_normals_v3(
process->no[i1], process->no[i2], process->no[i3], process->no[i4], n,
process->co[i1], process->co[i2], process->co[i3], process->co[i4]);
}
@@ -1079,7 +1079,7 @@ static void polygonize(PROCESS *process)
* Iterates over ALL objects in the scene and all of its sets, including
* making all duplis(not only metas). Copies metas to mainb array.
* Computes bounding boxes for building BVH. */
-static void init_meta(EvaluationContext *eval_ctx, PROCESS *process, Scene *scene, Object *ob)
+static void init_meta(const EvaluationContext *eval_ctx, PROCESS *process, Scene *scene, Object *ob)
{
Scene *sce_iter = scene;
BaseLegacy *base;
@@ -1256,7 +1256,7 @@ static void init_meta(EvaluationContext *eval_ctx, PROCESS *process, Scene *scen
}
}
-void BKE_mball_polygonize(EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *dispbase)
+void BKE_mball_polygonize(const EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *dispbase)
{
MetaBall *mb;
DispList *dl;
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 9c0881e79ff..8f41f0611d4 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -387,6 +387,48 @@ void BKE_mesh_ensure_skin_customdata(Mesh *me)
}
}
+bool BKE_mesh_ensure_facemap_customdata(struct Mesh *me)
+{
+ BMesh *bm = me->edit_btmesh ? me->edit_btmesh->bm : NULL;
+ bool changed = false;
+ if (bm) {
+ if (!CustomData_has_layer(&bm->pdata, CD_FACEMAP)) {
+ BM_data_layer_add(bm, &bm->pdata, CD_FACEMAP);
+ changed = true;
+ }
+ }
+ else {
+ if (!CustomData_has_layer(&me->pdata, CD_FACEMAP)) {
+ CustomData_add_layer(&me->pdata,
+ CD_FACEMAP,
+ CD_DEFAULT,
+ NULL,
+ me->totpoly);
+ changed = true;
+ }
+ }
+ return changed;
+}
+
+bool BKE_mesh_clear_facemap_customdata(struct Mesh *me)
+{
+ BMesh *bm = me->edit_btmesh ? me->edit_btmesh->bm : NULL;
+ bool changed = false;
+ if (bm) {
+ if (CustomData_has_layer(&bm->pdata, CD_FACEMAP)) {
+ BM_data_layer_free(bm, &bm->pdata, CD_FACEMAP);
+ changed = true;
+ }
+ }
+ else {
+ if (CustomData_has_layer(&me->pdata, CD_FACEMAP)) {
+ CustomData_free_layers(&me->pdata, CD_FACEMAP, me->totpoly);
+ changed = true;
+ }
+ }
+ return changed;
+}
+
/* this ensures grouped customdata (e.g. mtexpoly and mloopuv and mtface, or
* mloopcol and mcol) have the same relative active/render/clone/mask indices.
*
@@ -491,54 +533,57 @@ Mesh *BKE_mesh_add(Main *bmain, const char *name)
{
Mesh *me;
- me = BKE_libblock_alloc(bmain, ID_ME, name);
+ me = BKE_libblock_alloc(bmain, ID_ME, name, 0);
BKE_mesh_init(me);
return me;
}
-Mesh *BKE_mesh_copy(Main *bmain, const Mesh *me)
+/**
+ * Only copy internal data of Mesh ID from source to already allocated/initialized destination.
+ * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
+ *
+ * WARNING! This function will not handle ID user count!
+ *
+ * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
+ */
+void BKE_mesh_copy_data(Main *bmain, Mesh *me_dst, const Mesh *me_src, const int flag)
{
- Mesh *men;
- int a;
- const int do_tessface = ((me->totface != 0) && (me->totpoly == 0)); /* only do tessface if we have no polys */
-
- men = BKE_libblock_copy(bmain, &me->id);
-
- men->mat = MEM_dupallocN(me->mat);
- for (a = 0; a < men->totcol; a++) {
- id_us_plus((ID *)men->mat[a]);
- }
- id_us_plus((ID *)men->texcomesh);
+ const bool do_tessface = ((me_src->totface != 0) && (me_src->totpoly == 0)); /* only do tessface if we have no polys */
+
+ me_dst->mat = MEM_dupallocN(me_src->mat);
- CustomData_copy(&me->vdata, &men->vdata, CD_MASK_MESH, CD_DUPLICATE, men->totvert);
- CustomData_copy(&me->edata, &men->edata, CD_MASK_MESH, CD_DUPLICATE, men->totedge);
- CustomData_copy(&me->ldata, &men->ldata, CD_MASK_MESH, CD_DUPLICATE, men->totloop);
- CustomData_copy(&me->pdata, &men->pdata, CD_MASK_MESH, CD_DUPLICATE, men->totpoly);
+ CustomData_copy(&me_src->vdata, &me_dst->vdata, CD_MASK_MESH, CD_DUPLICATE, me_dst->totvert);
+ CustomData_copy(&me_src->edata, &me_dst->edata, CD_MASK_MESH, CD_DUPLICATE, me_dst->totedge);
+ CustomData_copy(&me_src->ldata, &me_dst->ldata, CD_MASK_MESH, CD_DUPLICATE, me_dst->totloop);
+ CustomData_copy(&me_src->pdata, &me_dst->pdata, CD_MASK_MESH, CD_DUPLICATE, me_dst->totpoly);
if (do_tessface) {
- CustomData_copy(&me->fdata, &men->fdata, CD_MASK_MESH, CD_DUPLICATE, men->totface);
+ CustomData_copy(&me_src->fdata, &me_dst->fdata, CD_MASK_MESH, CD_DUPLICATE, me_dst->totface);
}
else {
- mesh_tessface_clear_intern(men, false);
+ mesh_tessface_clear_intern(me_dst, false);
}
- BKE_mesh_update_customdata_pointers(men, do_tessface);
+ BKE_mesh_update_customdata_pointers(me_dst, do_tessface);
- men->edit_btmesh = NULL;
- men->batch_cache = NULL;
+ me_dst->edit_btmesh = NULL;
+ me_dst->batch_cache = NULL;
- men->mselect = MEM_dupallocN(men->mselect);
- men->bb = MEM_dupallocN(men->bb);
+ me_dst->mselect = MEM_dupallocN(me_dst->mselect);
+ me_dst->bb = MEM_dupallocN(me_dst->bb);
- if (me->key) {
- men->key = BKE_key_copy(bmain, me->key);
- men->key->from = (ID *)men;
+ /* TODO Do we want to add flag to prevent this? */
+ if (me_src->key) {
+ BKE_id_copy_ex(bmain, &me_src->key->id, (ID **)&me_dst->key, flag, false);
}
+}
- BKE_id_copy_ensure_local(bmain, &me->id, &men->id);
-
- return men;
+Mesh *BKE_mesh_copy(Main *bmain, const Mesh *me)
+{
+ Mesh *me_copy;
+ BKE_id_copy_ex(bmain, &me->id, (ID **)&me_copy, 0, false);
+ return me_copy;
}
BMesh *BKE_mesh_to_bmesh(
@@ -581,43 +626,44 @@ bool BKE_mesh_uv_cdlayer_rename_index(Mesh *me, const int poly_index, const int
ldata = &me->ldata;
fdata = &me->fdata;
}
- cdlp = (poly_index != -1) ? &pdata->layers[poly_index] : NULL;
- cdlu = &ldata->layers[loop_index];
- cdlf = fdata && do_tessface ? &fdata->layers[face_index] : NULL;
- if (cdlp == NULL && cdlf == NULL) {
- return false;
- }
+ cdlu = &ldata->layers[loop_index];
+ cdlp = (poly_index != -1) ? &pdata->layers[poly_index] : NULL;
+ cdlf = (face_index != -1) && fdata && do_tessface ? &fdata->layers[face_index] : NULL;
if (cdlu->name != new_name) {
/* Mesh validate passes a name from the CD layer as the new name,
* Avoid memcpy from self to self in this case.
*/
BLI_strncpy(cdlu->name, new_name, sizeof(cdlu->name));
- CustomData_set_layer_unique_name(pdata, cdlu - pdata->layers);
+ CustomData_set_layer_unique_name(ldata, loop_index);
+ }
+
+ if (cdlp == NULL && cdlf == NULL) {
+ return false;
}
/* Loop until we do have exactly the same name for all layers! */
for (i = 1;
- (cdlp && !STREQ(cdlp->name, cdlu->name)) ||
- (cdlf && !STREQ(cdlp->name, cdlf->name));
+ (cdlp && !STREQ(cdlu->name, cdlp->name)) ||
+ (cdlf && !STREQ(cdlu->name, cdlf->name));
i++)
{
switch (i % step) {
case 0:
if (cdlp) {
BLI_strncpy(cdlp->name, cdlu->name, sizeof(cdlp->name));
- CustomData_set_layer_unique_name(pdata, cdlp - pdata->layers);
+ CustomData_set_layer_unique_name(pdata, poly_index);
}
break;
case 1:
BLI_strncpy(cdlu->name, cdlp->name, sizeof(cdlu->name));
- CustomData_set_layer_unique_name(ldata, cdlu - ldata->layers);
+ CustomData_set_layer_unique_name(ldata, loop_index);
break;
case 2:
if (cdlf) {
BLI_strncpy(cdlf->name, cdlu->name, sizeof(cdlf->name));
- CustomData_set_layer_unique_name(fdata, cdlf - fdata->layers);
+ CustomData_set_layer_unique_name(fdata, face_index);
}
break;
}
@@ -1585,10 +1631,10 @@ void BKE_mesh_to_curve_nurblist(DerivedMesh *dm, ListBase *nurblist, const int e
}
}
-void BKE_mesh_to_curve(Scene *scene, Object *ob)
+void BKE_mesh_to_curve(const EvaluationContext *eval_ctx, Scene *scene, Object *ob)
{
/* make new mesh data from the original copy */
- DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_MESH);
+ DerivedMesh *dm = mesh_get_derived_final(eval_ctx, scene, ob, CD_MASK_MESH);
ListBase nurblist = {NULL, NULL};
bool needsFree = false;
@@ -2053,6 +2099,12 @@ void BKE_mesh_mselect_active_set(Mesh *me, int index, int type)
(me->mselect[me->totselect - 1].type == type));
}
+/**
+ * Compute 'split' (aka loop, or per face corner's) normals.
+ *
+ * \param r_lnors_spacearr Allows to get computed loop normal space array. That data, among other things,
+ * contains 'smooth fan' info, useful e.g. to split geometry along sharp edges...
+ */
void BKE_mesh_calc_normals_split_ex(Mesh *mesh, MLoopNorSpaceArray *r_lnors_spacearr)
{
float (*r_loopnors)[3];
@@ -2060,6 +2112,11 @@ void BKE_mesh_calc_normals_split_ex(Mesh *mesh, MLoopNorSpaceArray *r_lnors_spac
short (*clnors)[2] = NULL;
bool free_polynors = false;
+ /* Note that we enforce computing clnors when the clnor space array is requested by caller here.
+ * However, we obviously only use the autosmooth angle threshold only in case autosmooth is enabled. */
+ const bool use_split_normals = (r_lnors_spacearr != NULL) || ((mesh->flag & ME_AUTOSMOOTH) != 0);
+ const float split_angle = (mesh->flag & ME_AUTOSMOOTH) != 0 ? mesh->smoothresh : (float)M_PI;
+
if (CustomData_has_layer(&mesh->ldata, CD_NORMAL)) {
r_loopnors = CustomData_get_layer(&mesh->ldata, CD_NORMAL);
memset(r_loopnors, 0, sizeof(float[3]) * mesh->totloop);
@@ -2088,7 +2145,7 @@ void BKE_mesh_calc_normals_split_ex(Mesh *mesh, MLoopNorSpaceArray *r_lnors_spac
BKE_mesh_normals_loop_split(
mesh->mvert, mesh->totvert, mesh->medge, mesh->totedge,
mesh->mloop, r_loopnors, mesh->totloop, mesh->mpoly, (const float (*)[3])polynors, mesh->totpoly,
- (mesh->flag & ME_AUTOSMOOTH) != 0, mesh->smoothresh, r_lnors_spacearr, clnors, NULL);
+ use_split_normals, split_angle, r_lnors_spacearr, clnors, NULL);
if (free_polynors) {
MEM_freeN(polynors);
@@ -2120,118 +2177,70 @@ typedef struct SplitFaceNewEdge {
/* Detect needed new vertices, and update accordingly loops' vertex indices.
* WARNING! Leaves mesh in invalid state. */
static int split_faces_prepare_new_verts(
- const Mesh *mesh, MLoopNorSpaceArray *lnors_spacearr, SplitFaceNewVert **new_verts, MemArena *memarena,
- bool *r_need_vnors_recalc)
+ const Mesh *mesh, MLoopNorSpaceArray *lnors_spacearr, SplitFaceNewVert **new_verts, MemArena *memarena)
{
- /* Note: if lnors_spacearr is NULL, ther is no autosmooth handling, and we only split out flat polys. */
+ /* This is now mandatory, trying to do the job in simple way without that data is doomed to fail, even when only
+ * dealing with smooth/flat faces one can find cases that no simple algorithm can handle properly. */
+ BLI_assert(lnors_spacearr != NULL);
+
const int num_loops = mesh->totloop;
int num_verts = mesh->totvert;
MVert *mvert = mesh->mvert;
MLoop *mloop = mesh->mloop;
BLI_bitmap *verts_used = BLI_BITMAP_NEW(num_verts, __func__);
+ BLI_bitmap *done_loops = BLI_BITMAP_NEW(num_loops, __func__);
- if (lnors_spacearr) {
- BLI_bitmap *done_loops = BLI_BITMAP_NEW(num_loops, __func__);
-
- MLoop *ml = mloop;
- MLoopNorSpace **lnor_space = lnors_spacearr->lspacearr;
- for (int loop_idx = 0; loop_idx < num_loops; loop_idx++, ml++, lnor_space++) {
- if (!BLI_BITMAP_TEST(done_loops, loop_idx)) {
- const int vert_idx = ml->v;
- const bool vert_used = BLI_BITMAP_TEST_BOOL(verts_used, vert_idx);
- /* If vert is already used by another smooth fan, we need a new vert for this one. */
- const int new_vert_idx = vert_used ? num_verts++ : vert_idx;
-
- BLI_assert(*lnor_space);
-
- if ((*lnor_space)->loops) {
- for (LinkNode *lnode = (*lnor_space)->loops; lnode; lnode = lnode->next) {
- const int ml_fan_idx = GET_INT_FROM_POINTER(lnode->link);
- BLI_BITMAP_ENABLE(done_loops, ml_fan_idx);
- if (vert_used) {
- mloop[ml_fan_idx].v = new_vert_idx;
- }
- }
- }
- else {
- /* Single loop in this fan... */
- BLI_BITMAP_ENABLE(done_loops, loop_idx);
+ MLoop *ml = mloop;
+ MLoopNorSpace **lnor_space = lnors_spacearr->lspacearr;
+
+ for (int loop_idx = 0; loop_idx < num_loops; loop_idx++, ml++, lnor_space++) {
+ if (!BLI_BITMAP_TEST(done_loops, loop_idx)) {
+ const int vert_idx = ml->v;
+ const bool vert_used = BLI_BITMAP_TEST_BOOL(verts_used, vert_idx);
+ /* If vert is already used by another smooth fan, we need a new vert for this one. */
+ const int new_vert_idx = vert_used ? num_verts++ : vert_idx;
+
+ BLI_assert(*lnor_space);
+
+ if ((*lnor_space)->loops) {
+ for (LinkNode *lnode = (*lnor_space)->loops; lnode; lnode = lnode->next) {
+ const int ml_fan_idx = GET_INT_FROM_POINTER(lnode->link);
+ BLI_BITMAP_ENABLE(done_loops, ml_fan_idx);
if (vert_used) {
- ml->v = new_vert_idx;
+ mloop[ml_fan_idx].v = new_vert_idx;
}
}
-
- if (!vert_used) {
- BLI_BITMAP_ENABLE(verts_used, vert_idx);
- /* We need to update that vertex's normal here, we won't go over it again. */
- /* This is important! *DO NOT* set vnor to final computed lnor, vnor should always be defined to
- * 'automatic normal' value computed from its polys, not some custom normal.
- * Fortunately, that's the loop normal space's 'lnor' reference vector. ;) */
- normal_float_to_short_v3(mvert[vert_idx].no, (*lnor_space)->vec_lnor);
- }
- else {
- /* Add new vert to list. */
- SplitFaceNewVert *new_vert = BLI_memarena_alloc(memarena, sizeof(*new_vert));
- new_vert->orig_index = vert_idx;
- new_vert->new_index = new_vert_idx;
- new_vert->vnor = (*lnor_space)->vec_lnor; /* See note above. */
- new_vert->next = *new_verts;
- *new_verts = new_vert;
- }
}
- }
-
- MEM_freeN(done_loops);
- }
- else {
- /* No loop normal spaces available, we only split out flat polys. */
- const int num_polys = mesh->totpoly;
- const MPoly *mpoly = mesh->mpoly;
-
- /* We do that in two loops, to keep original edges/verts to smooth polys preferencially. */
- const MPoly *mp = mpoly;
- for (int i = 0; i < num_polys; i++, mp++) {
- if (mp->flag & ME_SMOOTH) {
- const MLoop *ml = &mloop[mp->loopstart];
- for (int j = 0; j < mp->totloop; j++, ml++) {
- /* Just mark the vertex as used/reserved, that way neighbor flat polys, if any,
- * will have to create their own. */
- BLI_BITMAP_ENABLE(verts_used, ml->v);
+ else {
+ /* Single loop in this fan... */
+ BLI_BITMAP_ENABLE(done_loops, loop_idx);
+ if (vert_used) {
+ ml->v = new_vert_idx;
}
}
- }
- mp = mpoly;
- for (int i = 0; i < num_polys; i++, mp++) {
- if (!(mp->flag & ME_SMOOTH)) {
- MLoop *ml = &mloop[mp->loopstart];
- for (int j = 0; j < mp->totloop; j++, ml++) {
- const int vert_idx = ml->v;
-
- if (BLI_BITMAP_TEST(verts_used, vert_idx)) {
- /* Add new vert to list. */
- const int new_vert_idx = num_verts++;
- ml->v = new_vert_idx;
-
- SplitFaceNewVert *new_vert = BLI_memarena_alloc(memarena, sizeof(*new_vert));
- new_vert->orig_index = vert_idx;
- new_vert->new_index = new_vert_idx;
- new_vert->vnor = NULL; /* See note below about normals. */
- new_vert->next = *new_verts;
- *new_verts = new_vert;
- }
- else {
- BLI_BITMAP_ENABLE(verts_used, vert_idx);
- }
- }
- /* Note: there is no way to get new normals for smooth vertices here (and we don't have direct access
- * to poly normals either for flat ones), so we'll have to recompute all vnors at the end... */
- *r_need_vnors_recalc = true;
+ if (!vert_used) {
+ BLI_BITMAP_ENABLE(verts_used, vert_idx);
+ /* We need to update that vertex's normal here, we won't go over it again. */
+ /* This is important! *DO NOT* set vnor to final computed lnor, vnor should always be defined to
+ * 'automatic normal' value computed from its polys, not some custom normal.
+ * Fortunately, that's the loop normal space's 'lnor' reference vector. ;) */
+ normal_float_to_short_v3(mvert[vert_idx].no, (*lnor_space)->vec_lnor);
+ }
+ else {
+ /* Add new vert to list. */
+ SplitFaceNewVert *new_vert = BLI_memarena_alloc(memarena, sizeof(*new_vert));
+ new_vert->orig_index = vert_idx;
+ new_vert->new_index = new_vert_idx;
+ new_vert->vnor = (*lnor_space)->vec_lnor; /* See note above. */
+ new_vert->next = *new_verts;
+ *new_verts = new_vert;
}
}
}
+ MEM_freeN(done_loops);
MEM_freeN(verts_used);
return num_verts - mesh->totvert;
@@ -2350,27 +2359,17 @@ void BKE_mesh_split_faces(Mesh *mesh, bool free_loop_normals)
}
BKE_mesh_tessface_clear(mesh);
- MLoopNorSpaceArray *lnors_spacearr = NULL;
- MemArena *memarena;
- bool need_vnors_recalc = false;
-
- if (mesh->flag & ME_AUTOSMOOTH) {
- lnors_spacearr = MEM_callocN(sizeof(*lnors_spacearr), __func__);
- /* Compute loop normals and loop normal spaces (a.k.a. smooth fans of faces around vertices). */
- BKE_mesh_calc_normals_split_ex(mesh, lnors_spacearr);
- /* Stealing memarena from loop normals space array. */
- memarena = lnors_spacearr->mem;
- }
- else {
- /* We still have to split out flat faces... */
- memarena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);
- }
+ MLoopNorSpaceArray lnors_spacearr = {NULL};
+ /* Compute loop normals and loop normal spaces (a.k.a. smooth fans of faces around vertices). */
+ BKE_mesh_calc_normals_split_ex(mesh, &lnors_spacearr);
+ /* Stealing memarena from loop normals space array. */
+ MemArena *memarena = lnors_spacearr.mem;
SplitFaceNewVert *new_verts = NULL;
SplitFaceNewEdge *new_edges = NULL;
/* Detect loop normal spaces (a.k.a. smooth fans) that will need a new vert. */
- const int num_new_verts = split_faces_prepare_new_verts(mesh, lnors_spacearr, &new_verts, memarena, &need_vnors_recalc);
+ const int num_new_verts = split_faces_prepare_new_verts(mesh, &lnors_spacearr, &new_verts, memarena);
if (num_new_verts > 0) {
/* Reminder: beyond this point, there is no way out, mesh is in invalid state (due to early-reassignment of
@@ -2382,9 +2381,9 @@ void BKE_mesh_split_faces(Mesh *mesh, bool free_loop_normals)
/* Reallocate all vert and edge related data. */
mesh->totvert += num_new_verts;
- mesh->totedge += num_new_edges;
CustomData_realloc(&mesh->vdata, mesh->totvert);
if (do_edges) {
+ mesh->totedge += num_new_edges;
CustomData_realloc(&mesh->edata, mesh->totedge);
}
/* Update pointers to a newly allocated memory. */
@@ -2404,18 +2403,9 @@ void BKE_mesh_split_faces(Mesh *mesh, bool free_loop_normals)
CustomData_free_layers(&mesh->ldata, CD_NORMAL, mesh->totloop);
}
- if (lnors_spacearr) {
- /* Also frees new_verts/edges temp data, since we used its memarena to allocate them. */
- BKE_lnor_spacearr_free(lnors_spacearr);
- MEM_freeN(lnors_spacearr);
- }
- else {
- BLI_memarena_free(memarena);
- }
+ /* Also frees new_verts/edges temp data, since we used its memarena to allocate them. */
+ BKE_lnor_spacearr_free(&lnors_spacearr);
- if (need_vnors_recalc) {
- BKE_mesh_calc_normals(mesh);
- }
#ifdef VALIDATE_MESH
BKE_mesh_validate(mesh, true, true);
#endif
@@ -2423,7 +2413,7 @@ void BKE_mesh_split_faces(Mesh *mesh, bool free_loop_normals)
/* settings: 1 - preview, 2 - render */
Mesh *BKE_mesh_new_from_object(
- Main *bmain, Scene *sce, Object *ob,
+ const EvaluationContext *eval_ctx, Main *bmain, Scene *sce, Object *ob,
int apply_modifiers, int settings, int calc_tessface, int calc_undeformed)
{
Mesh *tmpmesh;
@@ -2444,7 +2434,9 @@ Mesh *BKE_mesh_new_from_object(
int uv_from_orco;
/* copies object and modifiers (but not the data) */
- Object *tmpobj = BKE_object_copy_ex(bmain, ob, true);
+ Object *tmpobj;
+ /* TODO: make it temp copy outside bmain! */
+ BKE_id_copy_ex(bmain, &ob->id, (ID **)&tmpobj, LIB_ID_COPY_CACHES, false);
tmpcu = (Curve *)tmpobj->data;
id_us_min(&tmpcu->id);
@@ -2475,7 +2467,7 @@ Mesh *BKE_mesh_new_from_object(
copycu->editnurb = tmpcu->editnurb;
/* get updated display list, and convert to a mesh */
- BKE_displist_make_curveTypes_forRender(sce, tmpobj, &dispbase, &derivedFinal, false, render);
+ BKE_displist_make_curveTypes_forRender(eval_ctx, sce, tmpobj, &dispbase, &derivedFinal, false, render);
copycu->editfont = NULL;
copycu->editnurb = NULL;
@@ -2526,13 +2518,7 @@ Mesh *BKE_mesh_new_from_object(
if (render) {
ListBase disp = {NULL, NULL};
- /* TODO(sergey): This is gonna to work for until EvaluationContext
- * only contains for_render flag. As soon as CoW is
- * implemented, this is to be rethinked.
- */
- EvaluationContext eval_ctx;
- DEG_evaluation_context_init(&eval_ctx, DAG_EVAL_RENDER);
- BKE_displist_make_mball_forRender(&eval_ctx, sce, ob, &disp);
+ BKE_displist_make_mball_forRender(eval_ctx, sce, ob, &disp);
BKE_mesh_from_metaball(&disp, tmpmesh);
BKE_displist_free(&disp);
}
@@ -2571,9 +2557,9 @@ Mesh *BKE_mesh_new_from_object(
/* Write the display mesh into the dummy mesh */
if (render)
- dm = mesh_create_derived_render(sce, ob, mask);
+ dm = mesh_create_derived_render(eval_ctx, sce, ob, mask);
else
- dm = mesh_create_derived_view(sce, ob, mask);
+ dm = mesh_create_derived_view(eval_ctx, sce, ob, mask);
tmpmesh = BKE_mesh_add(bmain, ((ID *)ob->data)->name + 2);
DM_to_mesh(dm, tmpmesh, ob, mask, true);
@@ -2664,7 +2650,7 @@ Mesh *BKE_mesh_new_from_object(
/* **** Depsgraph evaluation **** */
-void BKE_mesh_eval_geometry(EvaluationContext *UNUSED(eval_ctx),
+void BKE_mesh_eval_geometry(const EvaluationContext *UNUSED(eval_ctx),
Mesh *mesh)
{
if (G.debug & G_DEBUG_DEPSGRAPH) {
@@ -2690,4 +2676,4 @@ void BKE_mesh_batch_cache_free(Mesh *me)
if (me->batch_cache) {
BKE_mesh_batch_cache_free_cb(me);
}
-} \ No newline at end of file
+}
diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c
index ca8b58ffae3..4a1952c798b 100644
--- a/source/blender/blenkernel/intern/mesh_evaluate.c
+++ b/source/blender/blenkernel/intern/mesh_evaluate.c
@@ -225,7 +225,7 @@ static void mesh_calc_normals_poly_accum_task_cb(void *userdata, const int pidx)
}
/* accumulate angle weighted face normal */
- /* inline version of #accumulate_vertex_normals_poly */
+ /* inline version of #accumulate_vertex_normals_poly_v3 */
{
const float *prev_edge = edgevecbuf[nverts - 1];
@@ -334,8 +334,9 @@ void BKE_mesh_calc_normals_tessface(
else
normal_tri_v3(f_no, mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co);
- accumulate_vertex_normals(tnorms[mf->v1], tnorms[mf->v2], tnorms[mf->v3], n4,
- f_no, mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, c4);
+ accumulate_vertex_normals_v3(
+ tnorms[mf->v1], tnorms[mf->v2], tnorms[mf->v3], n4,
+ f_no, mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, c4);
}
/* following Mesh convention; we use vertex coordinate itself for normal in this case */
@@ -379,7 +380,7 @@ void BKE_mesh_calc_normals_looptri(
f_no,
mverts[vtri[0]].co, mverts[vtri[1]].co, mverts[vtri[2]].co);
- accumulate_vertex_normals_tri(
+ accumulate_vertex_normals_tri_v3(
tnorms[vtri[0]], tnorms[vtri[1]], tnorms[vtri[2]],
f_no, mverts[vtri[0]].co, mverts[vtri[1]].co, mverts[vtri[2]].co);
}
@@ -845,7 +846,7 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data, LoopSpli
// printf("\thandling edge %d / loop %d\n", mlfan_curr->e, mlfan_curr_index);
{
- /* Code similar to accumulate_vertex_normals_poly. */
+ /* Code similar to accumulate_vertex_normals_poly_v3. */
/* Calculate angle between the two poly edges incident on this vertex. */
const float fac = saacos(dot_v3v3(vec_curr, vec_prev));
/* Accumulate */
@@ -1856,11 +1857,14 @@ float BKE_mesh_calc_poly_area(
* - http://forums.cgsociety.org/archive/index.php?t-756235.html
* - http://www.globalspec.com/reference/52702/203279/4-8-the-centroid-of-a-tetrahedron
*
- * \note volume is 6x actual volume, and centroid is 4x actual volume-weighted centroid
- * (so division can be done once at the end)
- * \note results will have bias if polygon is non-planar.
+ * \note
+ * - Volume is 6x actual volume, and centroid is 4x actual volume-weighted centroid
+ * (so division can be done once at the end).
+ * - Results will have bias if polygon is non-planar.
+ * - The resulting volume will only be correct if the mesh is manifold and has consistent face winding
+ * (non-contiguous face normals or holes in the mesh surface).
*/
-static float mesh_calc_poly_volume_and_weighted_centroid(
+static float mesh_calc_poly_volume_centroid(
const MPoly *mpoly, const MLoop *loopstart, const MVert *mvarray,
float r_cent[3])
{
@@ -1897,6 +1901,43 @@ static float mesh_calc_poly_volume_and_weighted_centroid(
return total_volume;
}
+/**
+ * \note
+ * - Results won't be correct if polygon is non-planar.
+ * - This has the advantage over #mesh_calc_poly_volume_centroid
+ * that it doesn't depend on solid geometry, instead it weights the surface by volume.
+ */
+static float mesh_calc_poly_area_centroid(
+ const MPoly *mpoly, const MLoop *loopstart, const MVert *mvarray,
+ float r_cent[3])
+{
+ int i;
+ float tri_area;
+ float total_area = 0.0f;
+ float v1[3], v2[3], v3[3], normal[3], tri_cent[3];
+
+ BKE_mesh_calc_poly_normal(mpoly, loopstart, mvarray, normal);
+ copy_v3_v3(v1, mvarray[loopstart[0].v].co);
+ copy_v3_v3(v2, mvarray[loopstart[1].v].co);
+ zero_v3(r_cent);
+
+ for (i = 2; i < mpoly->totloop; i++) {
+ copy_v3_v3(v3, mvarray[loopstart[i].v].co);
+
+ tri_area = area_tri_signed_v3(v1, v2, v3, normal);
+ total_area += tri_area;
+
+ mid_v3_v3v3v3(tri_cent, v1, v2, v3);
+ madd_v3_v3fl(r_cent, tri_cent, tri_area);
+
+ copy_v3_v3(v2, v3);
+ }
+
+ mul_v3_fl(r_cent, 1.0f / total_area);
+
+ return total_area;
+}
+
#if 0 /* slow version of the function below */
void BKE_mesh_calc_poly_angles(MPoly *mpoly, MLoop *loopstart,
MVert *mvarray, float angles[])
@@ -2011,7 +2052,40 @@ bool BKE_mesh_center_bounds(const Mesh *me, float r_cent[3])
return false;
}
-bool BKE_mesh_center_centroid(const Mesh *me, float r_cent[3])
+bool BKE_mesh_center_of_surface(const Mesh *me, float r_cent[3])
+{
+ int i = me->totpoly;
+ MPoly *mpoly;
+ float poly_area;
+ float total_area = 0.0f;
+ float poly_cent[3];
+
+ zero_v3(r_cent);
+
+ /* calculate a weighted average of polygon centroids */
+ for (mpoly = me->mpoly; i--; mpoly++) {
+ poly_area = mesh_calc_poly_area_centroid(mpoly, me->mloop + mpoly->loopstart, me->mvert, poly_cent);
+
+ madd_v3_v3fl(r_cent, poly_cent, poly_area);
+ total_area += poly_area;
+ }
+ /* otherwise we get NAN for 0 polys */
+ if (me->totpoly) {
+ mul_v3_fl(r_cent, 1.0f / total_area);
+ }
+
+ /* zero area faces cause this, fallback to median */
+ if (UNLIKELY(!is_finite_v3(r_cent))) {
+ return BKE_mesh_center_median(me, r_cent);
+ }
+
+ return (me->totpoly != 0);
+}
+
+/**
+ * \note Mesh must be manifold with consistent face-winding, see #mesh_calc_poly_volume_centroid for details.
+ */
+bool BKE_mesh_center_of_volume(const Mesh *me, float r_cent[3])
{
int i = me->totpoly;
MPoly *mpoly;
@@ -2023,7 +2097,7 @@ bool BKE_mesh_center_centroid(const Mesh *me, float r_cent[3])
/* calculate a weighted average of polyhedron centroids */
for (mpoly = me->mpoly; i--; mpoly++) {
- poly_volume = mesh_calc_poly_volume_and_weighted_centroid(mpoly, me->mloop + mpoly->loopstart, me->mvert, poly_cent);
+ poly_volume = mesh_calc_poly_volume_centroid(mpoly, me->mloop + mpoly->loopstart, me->mvert, poly_cent);
/* poly_cent is already volume-weighted, so no need to multiply by the volume */
add_v3_v3(r_cent, poly_cent);
@@ -2043,6 +2117,7 @@ bool BKE_mesh_center_centroid(const Mesh *me, float r_cent[3])
return (me->totpoly != 0);
}
+
/** \} */
diff --git a/source/blender/blenkernel/intern/mesh_remap.c b/source/blender/blenkernel/intern/mesh_remap.c
index c5fa9b15896..d2fe8f27f4a 100644
--- a/source/blender/blenkernel/intern/mesh_remap.c
+++ b/source/blender/blenkernel/intern/mesh_remap.c
@@ -1184,7 +1184,6 @@ void BKE_mesh_remap_calc_loops_from_dm(
bool polys_allocated_src;
MPoly *polys_src = DM_get_poly_array(dm_src, &polys_allocated_src);
const int num_polys_src = dm_src->getNumPolys(dm_src);
- bool looptri_allocated_src = false;
const MLoopTri *looptri_src = NULL;
int num_looptri_src = 0;
@@ -1374,17 +1373,11 @@ void BKE_mesh_remap_calc_loops_from_dm(
if (dirty_tess_flag) {
dm_src->dirty &= ~dirty_tess_flag;
}
- DM_ensure_looptri(dm_src);
if (dirty_tess_flag) {
dm_src->dirty |= dirty_tess_flag;
}
- looptri_src = DM_get_looptri_array(
- dm_src,
- verts_src,
- polys_src, num_polys_src,
- loops_src, num_loops_src,
- &looptri_allocated_src);
+ looptri_src = dm_src->getLoopTriArray(dm_src);
num_looptri_src = dm_src->getNumLoopTri(dm_src);
looptri_active = BLI_BITMAP_NEW((size_t)num_looptri_src, __func__);
@@ -1403,7 +1396,7 @@ void BKE_mesh_remap_calc_loops_from_dm(
&treedata[tindex],
verts_src, verts_allocated_src,
loops_src, loops_allocated_src,
- looptri_src, num_looptri_src, looptri_allocated_src,
+ looptri_src, num_looptri_src, false,
looptri_active, num_looptri_active, bvh_epsilon, 2, 6);
if (verts_allocated_src) {
verts_allocated_src = false; /* Only 'give' our verts once, to first tree! */
@@ -1411,9 +1404,6 @@ void BKE_mesh_remap_calc_loops_from_dm(
if (loops_allocated_src) {
loops_allocated_src = false; /* Only 'give' our loops once, to first tree! */
}
- if (looptri_allocated_src) {
- looptri_allocated_src = false; /* Only 'give' our looptri once, to first tree! */
- }
}
MEM_freeN(looptri_active);
@@ -1928,9 +1918,6 @@ void BKE_mesh_remap_calc_loops_from_dm(
if (polys_allocated_src) {
MEM_freeN(polys_src);
}
- if (looptri_allocated_src) {
- MEM_freeN((void *)looptri_src);
- }
if (vert_to_loop_map_src) {
MEM_freeN(vert_to_loop_map_src);
}
diff --git a/source/blender/blenkernel/intern/mesh_tangent.c b/source/blender/blenkernel/intern/mesh_tangent.c
index b9d1025d7b1..77288bd672e 100644
--- a/source/blender/blenkernel/intern/mesh_tangent.c
+++ b/source/blender/blenkernel/intern/mesh_tangent.c
@@ -230,8 +230,6 @@ typedef struct {
} SGLSLMeshToTangent;
/* interface */
-#include "mikktspace.h"
-
static int dm_ts_GetNumFaces(const SMikkTSpaceContext *pContext)
{
SGLSLMeshToTangent *pMesh = pContext->m_pUserData;
@@ -474,7 +472,7 @@ void BKE_mesh_calc_loop_tangent_step_0(
const CustomData *loopData, bool calc_active_tangent,
const char (*tangent_names)[MAX_NAME], int tangent_names_count,
bool *rcalc_act, bool *rcalc_ren, int *ract_uv_n, int *rren_uv_n,
- char *ract_uv_name, char *rren_uv_name, char *rtangent_mask) {
+ char *ract_uv_name, char *rren_uv_name, short *rtangent_mask) {
/* Active uv in viewport */
int layer_index = CustomData_get_layer_index(loopData, CD_MLOOPUV);
*ract_uv_n = CustomData_get_active_layer(loopData, CD_MLOOPUV);
@@ -526,8 +524,11 @@ void BKE_mesh_calc_loop_tangent_step_0(
add = true;
}
if (add)
- *rtangent_mask |= (char)(1 << n);
+ *rtangent_mask |= (short)(1 << n);
}
+
+ if (uv_layer_num == 0)
+ *rtangent_mask |= DM_TANGENT_MASK_ORCO;
}
/**
@@ -549,18 +550,16 @@ void BKE_mesh_calc_loop_tangent_ex(
/* result */
CustomData *loopdata_out,
const uint loopdata_out_len,
- char *tangent_mask_curr_p)
+ short *tangent_mask_curr_p)
{
- BLI_assert(CustomData_number_of_layers(loopdata, CD_MLOOPUV) != 0);
-
int act_uv_n = -1;
int ren_uv_n = -1;
bool calc_act = false;
bool calc_ren = false;
char act_uv_name[MAX_NAME];
char ren_uv_name[MAX_NAME];
- char tangent_mask = 0;
- char tangent_mask_curr = *tangent_mask_curr_p;
+ short tangent_mask = 0;
+ short tangent_mask_curr = *tangent_mask_curr_p;
BKE_mesh_calc_loop_tangent_step_0(
loopdata, calc_active_tangent, tangent_names, tangent_names_len,
@@ -571,6 +570,8 @@ void BKE_mesh_calc_loop_tangent_ex(
for (int i = 0; i < tangent_names_len; i++)
if (tangent_names[i][0])
BKE_mesh_add_loop_tangent_named_layer_for_uv(loopdata, loopdata_out, (int)loopdata_out_len, tangent_names[i]);
+ if ((tangent_mask & DM_TANGENT_MASK_ORCO) && CustomData_get_named_layer_index(loopdata, CD_TANGENT, "") == -1)
+ CustomData_add_layer_named(loopdata_out, CD_TANGENT, CD_CALLOC, NULL, (int)loopdata_out_len, "");
if (calc_act && act_uv_name[0])
BKE_mesh_add_loop_tangent_named_layer_for_uv(loopdata, loopdata_out, (int)loopdata_out_len, act_uv_name);
if (calc_ren && ren_uv_name[0])
@@ -602,7 +603,7 @@ void BKE_mesh_calc_loop_tangent_ex(
#endif
/* Calculation */
- {
+ if (looptri_len != 0) {
TaskScheduler *scheduler = BLI_task_scheduler_get();
TaskPool *task_pool;
task_pool = BLI_task_pool_create(scheduler, NULL);
@@ -631,21 +632,25 @@ void BKE_mesh_calc_loop_tangent_ex(
mesh2tangent->precomputedFaceNormals = poly_normals;
mesh2tangent->orco = NULL;
- mesh2tangent->mloopuv = CustomData_get_layer_named(loopdata, CD_MLOOPUV, loopdata->layers[index].name);
+ mesh2tangent->mloopuv = CustomData_get_layer_named(loopdata, CD_MLOOPUV, loopdata_out->layers[index].name);
+
+ /* Fill the resulting tangent_mask */
if (!mesh2tangent->mloopuv) {
- mesh2tangent->orco = vert_orco;
- if (!mesh2tangent->orco)
- continue;
+ mesh2tangent->orco = vert_orco;
+ if (!mesh2tangent->orco)
+ continue;
+
+ tangent_mask_curr |= DM_TANGENT_MASK_ORCO;
+ }
+ else {
+ int uv_ind = CustomData_get_named_layer_index(loopdata, CD_MLOOPUV, loopdata_out->layers[index].name);
+ int uv_start = CustomData_get_layer_index(loopdata, CD_MLOOPUV);
+ BLI_assert(uv_ind != -1 && uv_start != -1);
+ BLI_assert(uv_ind - uv_start < MAX_MTFACE);
+ tangent_mask_curr |= (short)(1 << (uv_ind - uv_start));
}
- mesh2tangent->tangent = loopdata_out->layers[index].data;
- /* Fill the resulting tangent_mask */
- int uv_ind = CustomData_get_named_layer_index(
- loopdata, CD_MLOOPUV, loopdata_out->layers[index].name);
- int uv_start = CustomData_get_layer_index(loopdata, CD_MLOOPUV);
- BLI_assert(uv_ind != -1 && uv_start != -1);
- BLI_assert(uv_ind - uv_start < MAX_MTFACE);
- tangent_mask_curr |= (char)(1 << (uv_ind - uv_start));
+ mesh2tangent->tangent = loopdata_out->layers[index].data;
BLI_task_pool_push(task_pool, DM_calc_loop_tangents_thread, mesh2tangent, false, TASK_PRIORITY_LOW);
}
@@ -653,6 +658,9 @@ void BKE_mesh_calc_loop_tangent_ex(
BLI_task_pool_work_and_wait(task_pool);
BLI_task_pool_free(task_pool);
}
+ else {
+ tangent_mask_curr = tangent_mask;
+ }
#ifdef USE_LOOPTRI_DETECT_QUADS
if (face_as_quad_map) {
MEM_freeN(face_as_quad_map);
@@ -663,21 +671,19 @@ void BKE_mesh_calc_loop_tangent_ex(
*tangent_mask_curr_p = tangent_mask_curr;
- int uv_index, tan_index;
-
/* Update active layer index */
- uv_index = CustomData_get_layer_index_n(loopdata, CD_MLOOPUV, act_uv_n);
- if (uv_index != -1) {
- tan_index = CustomData_get_named_layer_index(loopdata_out, CD_TANGENT, loopdata->layers[uv_index].name);
- CustomData_set_layer_active_index(loopdata_out, CD_TANGENT, tan_index);
- }
+ int act_uv_index = CustomData_get_layer_index_n(loopdata, CD_MLOOPUV, act_uv_n);
+ if (act_uv_index != -1) {
+ int tan_index = CustomData_get_named_layer_index(loopdata, CD_TANGENT, loopdata->layers[act_uv_index].name);
+ CustomData_set_layer_active_index(loopdata, CD_TANGENT, tan_index);
+ }/* else tangent has been built from orco */
/* Update render layer index */
- uv_index = CustomData_get_layer_index_n(loopdata, CD_MLOOPUV, ren_uv_n);
- if (uv_index != -1) {
- tan_index = CustomData_get_named_layer_index(loopdata_out, CD_TANGENT, loopdata->layers[uv_index].name);
- CustomData_set_layer_render_index(loopdata_out, CD_TANGENT, tan_index);
- }
+ int ren_uv_index = CustomData_get_layer_index_n(loopdata, CD_MLOOPUV, ren_uv_n);
+ if (ren_uv_index != -1) {
+ int tan_index = CustomData_get_named_layer_index(loopdata, CD_TANGENT, loopdata->layers[ren_uv_index].name);
+ CustomData_set_layer_render_index(loopdata, CD_TANGENT, tan_index);
+ }/* else tangent has been built from orco */
}
}
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index 2276d56b9c6..1a146dc67d1 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -59,6 +59,8 @@
#include "BKE_appdir.h"
#include "BKE_key.h"
+#include "BKE_library.h"
+#include "BKE_library_query.h"
#include "BKE_multires.h"
#include "BKE_DerivedMesh.h"
@@ -269,14 +271,37 @@ void modifier_copyData_generic(const ModifierData *md_src, ModifierData *md_dst)
memcpy(md_dst_data, md_src_data, (size_t)mti->structSize - data_size);
}
-void modifier_copyData(ModifierData *md, ModifierData *target)
+static void modifier_copy_data_id_us_cb(void *UNUSED(userData), Object *UNUSED(ob), ID **idpoin, int cb_flag)
+{
+ ID *id = *idpoin;
+ if (id != NULL && (cb_flag & IDWALK_CB_USER) != 0) {
+ id_us_plus(id);
+ }
+}
+
+void modifier_copyData_ex(ModifierData *md, ModifierData *target, const int flag)
{
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
target->mode = md->mode;
- if (mti->copyData)
+ if (mti->copyData) {
mti->copyData(md, target);
+ }
+
+ if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
+ if (mti->foreachIDLink) {
+ mti->foreachIDLink(target, NULL, modifier_copy_data_id_us_cb, NULL);
+ }
+ else if (mti->foreachObjectLink) {
+ mti->foreachObjectLink(target, NULL, (ObjectWalkFunc)modifier_copy_data_id_us_cb, NULL);
+ }
+ }
+}
+
+void modifier_copyData(ModifierData *md, ModifierData *target)
+{
+ modifier_copyData_ex(md, target, 0);
}
@@ -732,8 +757,8 @@ void modifier_path_init(char *path, int path_maxlen, const char *name)
/* wrapper around ModifierTypeInfo.applyModifier that ensures valid normals */
struct DerivedMesh *modwrap_applyModifier(
- ModifierData *md, Object *ob,
- struct DerivedMesh *dm,
+ ModifierData *md, const struct EvaluationContext *eval_ctx,
+ Object *ob, struct DerivedMesh *dm,
ModifierApplyFlag flag)
{
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
@@ -742,12 +767,12 @@ struct DerivedMesh *modwrap_applyModifier(
if (mti->dependsOnNormals && mti->dependsOnNormals(md)) {
DM_ensure_normals(dm);
}
- return mti->applyModifier(md, ob, dm, flag);
+ return mti->applyModifier(md, eval_ctx, ob, dm, flag);
}
struct DerivedMesh *modwrap_applyModifierEM(
- ModifierData *md, Object *ob,
- struct BMEditMesh *em,
+ ModifierData *md, const struct EvaluationContext *eval_ctx,
+ Object *ob, struct BMEditMesh *em,
DerivedMesh *dm,
ModifierApplyFlag flag)
{
@@ -757,12 +782,12 @@ struct DerivedMesh *modwrap_applyModifierEM(
if (mti->dependsOnNormals && mti->dependsOnNormals(md)) {
DM_ensure_normals(dm);
}
- return mti->applyModifierEM(md, ob, em, dm, flag);
+ return mti->applyModifierEM(md, eval_ctx, ob, em, dm, flag);
}
void modwrap_deformVerts(
- ModifierData *md, Object *ob,
- DerivedMesh *dm,
+ ModifierData *md, const struct EvaluationContext *eval_ctx,
+ Object *ob, DerivedMesh *dm,
float (*vertexCos)[3], int numVerts,
ModifierApplyFlag flag)
{
@@ -772,11 +797,11 @@ void modwrap_deformVerts(
if (dm && mti->dependsOnNormals && mti->dependsOnNormals(md)) {
DM_ensure_normals(dm);
}
- mti->deformVerts(md, ob, dm, vertexCos, numVerts, flag);
+ mti->deformVerts(md, eval_ctx, ob, dm, vertexCos, numVerts, flag);
}
void modwrap_deformVertsEM(
- ModifierData *md, Object *ob,
+ ModifierData *md, const struct EvaluationContext *eval_ctx, Object *ob,
struct BMEditMesh *em, DerivedMesh *dm,
float (*vertexCos)[3], int numVerts)
{
@@ -786,6 +811,6 @@ void modwrap_deformVertsEM(
if (dm && mti->dependsOnNormals && mti->dependsOnNormals(md)) {
DM_ensure_normals(dm);
}
- mti->deformVertsEM(md, ob, em, dm, vertexCos, numVerts);
+ mti->deformVertsEM(md, eval_ctx, ob, em, dm, vertexCos, numVerts);
}
/* end modifier callback wrappers */
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index dfa8742a295..16d597e25fa 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -588,7 +588,7 @@ static MovieClip *movieclip_alloc(Main *bmain, const char *name)
{
MovieClip *clip;
- clip = BKE_libblock_alloc(bmain, ID_MC, name);
+ clip = BKE_libblock_alloc(bmain, ID_MC, name, 0);
clip->aspx = clip->aspy = 1.0f;
@@ -1488,25 +1488,33 @@ void BKE_movieclip_free(MovieClip *clip)
BKE_animdata_free((ID *) clip, false);
}
-MovieClip *BKE_movieclip_copy(Main *bmain, const MovieClip *clip)
+/**
+ * Only copy internal data of MovieClip ID from source to already allocated/initialized destination.
+ * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
+ *
+ * WARNING! This function will not handle ID user count!
+ *
+ * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
+ */
+void BKE_movieclip_copy_data(Main *UNUSED(bmain), MovieClip *clip_dst, const MovieClip *clip_src, const int flag)
{
- MovieClip *clip_new;
-
- clip_new = BKE_libblock_copy(bmain, &clip->id);
+ /* We never handle usercount here for own data. */
+ const int flag_subdata = flag | LIB_ID_CREATE_NO_USER_REFCOUNT;
- clip_new->anim = NULL;
- clip_new->cache = NULL;
+ clip_dst->anim = NULL;
+ clip_dst->cache = NULL;
- BKE_tracking_copy(&clip_new->tracking, &clip->tracking);
- clip_new->tracking_context = NULL;
+ BKE_tracking_copy(&clip_dst->tracking, &clip_src->tracking, flag_subdata);
+ clip_dst->tracking_context = NULL;
- id_us_plus((ID *)clip_new->gpd);
-
- BKE_color_managed_colorspace_settings_copy(&clip_new->colorspace_settings, &clip->colorspace_settings);
-
- BKE_id_copy_ensure_local(bmain, &clip->id, &clip_new->id);
+ BKE_color_managed_colorspace_settings_copy(&clip_dst->colorspace_settings, &clip_src->colorspace_settings);
+}
- return clip_new;
+MovieClip *BKE_movieclip_copy(Main *bmain, const MovieClip *clip)
+{
+ MovieClip *clip_copy;
+ BKE_id_copy_ex(bmain, &clip->id, (ID **)&clip_copy, 0, false);
+ return clip_copy;
}
void BKE_movieclip_make_local(Main *bmain, MovieClip *clip, const bool lib_local)
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index 9679b585e6f..7ef4b588dcd 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -276,14 +276,14 @@ static MDisps *multires_mdisps_initialize_hidden(Mesh *me, int level)
return mdisps;
}
-DerivedMesh *get_multires_dm(Scene *scene, MultiresModifierData *mmd, Object *ob)
+DerivedMesh *get_multires_dm(const struct EvaluationContext *eval_ctx, Scene *scene, MultiresModifierData *mmd, Object *ob)
{
ModifierData *md = (ModifierData *)mmd;
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
- DerivedMesh *tdm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
+ DerivedMesh *tdm = mesh_get_derived_deform(eval_ctx, scene, ob, CD_MASK_BAREMESH);
DerivedMesh *dm;
- dm = mti->applyModifier(md, ob, tdm, MOD_APPLY_USECACHE | MOD_APPLY_IGNORE_SIMPLIFY);
+ dm = mti->applyModifier(md, eval_ctx, ob, tdm, MOD_APPLY_USECACHE | MOD_APPLY_IGNORE_SIMPLIFY);
if (dm == tdm) {
dm = CDDM_copy(tdm);
}
@@ -397,10 +397,10 @@ void multires_force_render_update(Object *ob)
multires_force_update(ob);
}
-int multiresModifier_reshapeFromDM(Scene *scene, MultiresModifierData *mmd,
+int multiresModifier_reshapeFromDM(const struct EvaluationContext *eval_ctx, Scene *scene, MultiresModifierData *mmd,
Object *ob, DerivedMesh *srcdm)
{
- DerivedMesh *mrdm = get_multires_dm(scene, mmd, ob);
+ DerivedMesh *mrdm = get_multires_dm(eval_ctx, scene, mmd, ob);
if (mrdm && srcdm && mrdm->getNumVerts(mrdm) == srcdm->getNumVerts(srcdm)) {
multires_mvert_to_ss(mrdm, srcdm->getVertArray(srcdm));
@@ -419,13 +419,13 @@ int multiresModifier_reshapeFromDM(Scene *scene, MultiresModifierData *mmd,
}
/* Returns 1 on success, 0 if the src's totvert doesn't match */
-int multiresModifier_reshape(Scene *scene, MultiresModifierData *mmd, Object *dst, Object *src)
+int multiresModifier_reshape(const struct EvaluationContext *eval_ctx, Scene *scene, MultiresModifierData *mmd, Object *dst, Object *src)
{
- DerivedMesh *srcdm = mesh_get_derived_final(scene, src, CD_MASK_BAREMESH);
- return multiresModifier_reshapeFromDM(scene, mmd, dst, srcdm);
+ DerivedMesh *srcdm = mesh_get_derived_final(eval_ctx, scene, src, CD_MASK_BAREMESH);
+ return multiresModifier_reshapeFromDM(eval_ctx, scene, mmd, dst, srcdm);
}
-int multiresModifier_reshapeFromDeformMod(Scene *scene, MultiresModifierData *mmd,
+int multiresModifier_reshapeFromDeformMod(const struct EvaluationContext *eval_ctx, Scene *scene, MultiresModifierData *mmd,
Object *ob, ModifierData *md)
{
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
@@ -437,12 +437,12 @@ int multiresModifier_reshapeFromDeformMod(Scene *scene, MultiresModifierData *mm
return 0;
/* Create DerivedMesh for deformation modifier */
- dm = get_multires_dm(scene, mmd, ob);
+ dm = get_multires_dm(eval_ctx, scene, mmd, ob);
numVerts = dm->getNumVerts(dm);
deformedVerts = MEM_mallocN(sizeof(float[3]) * numVerts, "multiresReshape_deformVerts");
dm->getVertCos(dm, deformedVerts);
- mti->deformVerts(md, ob, dm, deformedVerts, numVerts, 0);
+ mti->deformVerts(md, eval_ctx, ob, dm, deformedVerts, numVerts, 0);
ndm = CDDM_copy(dm);
CDDM_apply_vert_coords(ndm, deformedVerts);
@@ -451,7 +451,7 @@ int multiresModifier_reshapeFromDeformMod(Scene *scene, MultiresModifierData *mm
dm->release(dm);
/* Reshaping */
- result = multiresModifier_reshapeFromDM(scene, mmd, ob, ndm);
+ result = multiresModifier_reshapeFromDM(eval_ctx, scene, mmd, ob, ndm);
/* Cleanup */
ndm->release(ndm);
@@ -2174,7 +2174,7 @@ static void multires_sync_levels(Scene *scene, Object *ob_src, Object *ob_dst)
}
}
-static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3])
+static void multires_apply_smat(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float smat[3][3])
{
DerivedMesh *dm = NULL, *cddm = NULL, *subdm = NULL;
CCGElem **gridData, **subGridData;
@@ -2199,10 +2199,10 @@ static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3])
high_mmd.lvl = high_mmd.totlvl;
/* unscaled multires with applied displacement */
- subdm = get_multires_dm(scene, &high_mmd, ob);
+ subdm = get_multires_dm(eval_ctx, scene, &high_mmd, ob);
/* prepare scaled CDDM to create ccgDN */
- cddm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
+ cddm = mesh_get_derived_deform(eval_ctx, scene, ob, CD_MASK_BAREMESH);
totvert = cddm->getNumVerts(cddm);
vertCos = MEM_mallocN(sizeof(*vertCos) * totvert, "multiresScale vertCos");
@@ -2276,17 +2276,17 @@ int multires_mdisp_corners(MDisps *s)
return 0;
}
-void multiresModifier_scale_disp(Scene *scene, Object *ob)
+void multiresModifier_scale_disp(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob)
{
float smat[3][3];
/* object's scale matrix */
BKE_object_scale_to_mat3(ob, smat);
- multires_apply_smat(scene, ob, smat);
+ multires_apply_smat(eval_ctx, scene, ob, smat);
}
-void multiresModifier_prepare_join(Scene *scene, Object *ob, Object *to_ob)
+void multiresModifier_prepare_join(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, Object *to_ob)
{
float smat[3][3], tmat[3][3], mat[3][3];
multires_sync_levels(scene, to_ob, ob);
@@ -2297,7 +2297,7 @@ void multiresModifier_prepare_join(Scene *scene, Object *ob, Object *to_ob)
BKE_object_scale_to_mat3(ob, smat);
mul_m3_m3m3(mat, smat, tmat);
- multires_apply_smat(scene, ob, mat);
+ multires_apply_smat(eval_ctx, scene, ob, mat);
}
/* update multires data after topology changing */
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c
index 148fc3827e0..478b854c4df 100644
--- a/source/blender/blenkernel/intern/nla.c
+++ b/source/blender/blenkernel/intern/nla.c
@@ -59,7 +59,7 @@
#include "BKE_library.h"
#ifdef WITH_AUDASPACE
-# include AUD_SPECIAL_H
+# include <AUD_Special.h>
#endif
#include "RNA_access.h"
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 8ccd652edd4..3ff4885f7fc 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -902,80 +902,100 @@ bNode *nodeAddStaticNode(const struct bContext *C, bNodeTree *ntree, int type)
return nodeAddNode(C, ntree, idname);
}
-static void node_socket_copy(bNodeSocket *dst, bNodeSocket *src)
+static void node_socket_copy(bNodeSocket *sock_dst, bNodeSocket *sock_src, const int flag)
{
- src->new_sock = dst;
-
- if (src->prop)
- dst->prop = IDP_CopyProperty(src->prop);
-
- if (src->default_value)
- dst->default_value = MEM_dupallocN(src->default_value);
-
- dst->stack_index = 0;
+ sock_src->new_sock = sock_dst;
+
+ if (sock_src->prop) {
+ sock_dst->prop = IDP_CopyProperty_ex(sock_src->prop, flag);
+ }
+
+ if (sock_src->default_value) {
+ sock_dst->default_value = MEM_dupallocN(sock_src->default_value);
+ }
+
+ sock_dst->stack_index = 0;
/* XXX some compositor node (e.g. image, render layers) still store
* some persistent buffer data here, need to clear this to avoid dangling pointers.
*/
- dst->cache = NULL;
+ sock_dst->cache = NULL;
}
/* keep socket listorder identical, for copying links */
/* ntree is the target tree */
-bNode *nodeCopyNode(bNodeTree *ntree, bNode *node)
+bNode *BKE_node_copy_ex(bNodeTree *ntree, bNode *node_src, const int flag)
{
- bNode *nnode = MEM_callocN(sizeof(bNode), "dupli node");
- bNodeSocket *sock, *oldsock;
- bNodeLink *link, *oldlink;
+ bNode *node_dst = MEM_callocN(sizeof(bNode), "dupli node");
+ bNodeSocket *sock_dst, *sock_src;
+ bNodeLink *link_dst, *link_src;
- *nnode = *node;
+ *node_dst = *node_src;
/* can be called for nodes outside a node tree (e.g. clipboard) */
if (ntree) {
- nodeUniqueName(ntree, nnode);
+ nodeUniqueName(ntree, node_dst);
- BLI_addtail(&ntree->nodes, nnode);
+ BLI_addtail(&ntree->nodes, node_dst);
}
- BLI_duplicatelist(&nnode->inputs, &node->inputs);
- oldsock = node->inputs.first;
- for (sock = nnode->inputs.first; sock; sock = sock->next, oldsock = oldsock->next)
- node_socket_copy(sock, oldsock);
-
- BLI_duplicatelist(&nnode->outputs, &node->outputs);
- oldsock = node->outputs.first;
- for (sock = nnode->outputs.first; sock; sock = sock->next, oldsock = oldsock->next)
- node_socket_copy(sock, oldsock);
-
- if (node->prop)
- nnode->prop = IDP_CopyProperty(node->prop);
-
- BLI_duplicatelist(&nnode->internal_links, &node->internal_links);
- oldlink = node->internal_links.first;
- for (link = nnode->internal_links.first; link; link = link->next, oldlink = oldlink->next) {
- link->fromnode = nnode;
- link->tonode = nnode;
- link->fromsock = link->fromsock->new_sock;
- link->tosock = link->tosock->new_sock;
+ BLI_duplicatelist(&node_dst->inputs, &node_src->inputs);
+ for (sock_dst = node_dst->inputs.first, sock_src = node_src->inputs.first;
+ sock_dst != NULL;
+ sock_dst = sock_dst->next, sock_src = sock_src->next)
+ {
+ node_socket_copy(sock_dst, sock_src, flag);
}
-
- /* don't increase node->id users, freenode doesn't decrement either */
-
- if (node->typeinfo->copyfunc)
- node->typeinfo->copyfunc(ntree, nnode, node);
-
- node->new_node = nnode;
- nnode->new_node = NULL;
-
- if (nnode->typeinfo->copyfunc_api) {
+
+ BLI_duplicatelist(&node_dst->outputs, &node_src->outputs);
+ for (sock_dst = node_dst->outputs.first, sock_src = node_src->outputs.first;
+ sock_dst != NULL;
+ sock_dst = sock_dst->next, sock_src = sock_src->next)
+ {
+ node_socket_copy(sock_dst, sock_src, flag);
+ }
+
+ if (node_src->prop) {
+ node_dst->prop = IDP_CopyProperty_ex(node_src->prop, flag);
+ }
+
+ BLI_duplicatelist(&node_dst->internal_links, &node_src->internal_links);
+ for (link_dst = node_dst->internal_links.first, link_src = node_src->internal_links.first;
+ link_dst != NULL;
+ link_dst = link_dst->next, link_src = link_src->next)
+ {
+ link_dst->fromnode = node_dst;
+ link_dst->tonode = node_dst;
+ link_dst->fromsock = link_dst->fromsock->new_sock;
+ link_dst->tosock = link_dst->tosock->new_sock;
+ }
+
+ if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
+ id_us_plus(node_dst->id);
+ }
+
+ if (node_src->typeinfo->copyfunc) {
+ node_src->typeinfo->copyfunc(ntree, node_dst, node_src);
+ }
+
+ node_src->new_node = node_dst;
+ node_dst->new_node = NULL;
+
+ if (node_dst->typeinfo->copyfunc_api) {
PointerRNA ptr;
- RNA_pointer_create((ID *)ntree, &RNA_Node, nnode, &ptr);
-
- nnode->typeinfo->copyfunc_api(&ptr, node);
+ RNA_pointer_create((ID *)ntree, &RNA_Node, node_dst, &ptr);
+
+ node_dst->typeinfo->copyfunc_api(&ptr, node_src);
}
-
- if (ntree)
+
+ if (ntree) {
ntree->update |= NTREE_UPDATE_NODES;
-
- return nnode;
+ }
+
+ return node_dst;
+}
+
+bNode *nodeCopyNode(bNodeTree *ntree, bNode *node)
+{
+ return BKE_node_copy_ex(ntree, node, LIB_ID_CREATE_NO_USER_REFCOUNT);
}
/* also used via rna api, so we check for proper input output direction */
@@ -1172,7 +1192,7 @@ bNodeTree *ntreeAddTree(Main *bmain, const char *name, const char *idname)
* node groups and other tree types are created as library data.
*/
if (bmain) {
- ntree = BKE_libblock_alloc(bmain, ID_NT, name);
+ ntree = BKE_libblock_alloc(bmain, ID_NT, name, 0);
}
else {
ntree = MEM_callocN(sizeof(bNodeTree), "new node tree");
@@ -1191,119 +1211,96 @@ bNodeTree *ntreeAddTree(Main *bmain, const char *name, const char *idname)
return ntree;
}
-/* Warning: this function gets called during some rather unexpected times
- * - this gets called when executing compositing updates (for threaded previews)
- * - when the nodetree datablock needs to be copied (i.e. when users get copied)
- * - for scene duplication use ntreeSwapID() after so we don't have stale pointers.
+/**
+ * Only copy internal data of NodeTree ID from source to already allocated/initialized destination.
+ * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
+ *
+ * WARNING! This function will not handle ID user count!
*
- * do_make_extern: keep enabled for general use, only reason _not_ to enable is when
- * copying for internal use (threads for eg), where you wont want it to modify the
- * scene data.
+ * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
*/
-static bNodeTree *ntreeCopyTree_internal(
- const bNodeTree *ntree, Main *bmain,
- bool skip_database, bool do_id_user, bool do_make_extern, bool copy_previews)
+void BKE_node_tree_copy_data(Main *UNUSED(bmain), bNodeTree *ntree_dst, const bNodeTree *ntree_src, const int flag)
{
- bNodeTree *newtree;
- bNode *node /*, *nnode */ /* UNUSED */, *last;
- bNodeSocket *sock, *oldsock;
- bNodeLink *link;
-
- if (ntree == NULL) return NULL;
-
- /* is ntree part of library? */
- if (bmain && !skip_database && BLI_findindex(&bmain->nodetree, ntree) >= 0) {
- newtree = BKE_libblock_copy(bmain, &ntree->id);
- }
- else {
- newtree = BKE_libblock_copy_nolib(&ntree->id, true);
- }
+ bNodeSocket *sock_dst, *sock_src;
+ bNodeLink *link_dst;
- id_us_plus((ID *)newtree->gpd);
+ /* We never handle usercount here for own data. */
+ const int flag_subdata = flag | LIB_ID_CREATE_NO_USER_REFCOUNT;
/* in case a running nodetree is copied */
- newtree->execdata = NULL;
+ ntree_dst->execdata = NULL;
- newtree->duplilock = NULL;
-
- BLI_listbase_clear(&newtree->nodes);
- BLI_listbase_clear(&newtree->links);
-
- last = ntree->nodes.last;
- for (node = ntree->nodes.first; node; node = node->next) {
-
- /* ntreeUserDecrefID inline */
- if (do_id_user) {
- id_us_plus(node->id);
- }
+ ntree_dst->duplilock = NULL;
- if (do_make_extern) {
- id_lib_extern(node->id);
- }
+ BLI_listbase_clear(&ntree_dst->nodes);
+ BLI_listbase_clear(&ntree_dst->links);
- node->new_node = NULL;
- /* nnode = */ nodeCopyNode(newtree, node); /* sets node->new */
-
- /* make sure we don't copy new nodes again! */
- if (node == last)
- break;
+ for (bNode *node_src = ntree_src->nodes.first; node_src; node_src = node_src->next) {
+ BKE_node_copy_ex(ntree_dst, node_src, flag_subdata);
}
-
+
/* copy links */
- BLI_duplicatelist(&newtree->links, &ntree->links);
- for (link = newtree->links.first; link; link = link->next) {
- link->fromnode = (link->fromnode ? link->fromnode->new_node : NULL);
- link->fromsock = (link->fromsock ? link->fromsock->new_sock : NULL);
- link->tonode = (link->tonode ? link->tonode->new_node : NULL);
- link->tosock = (link->tosock ? link->tosock->new_sock : NULL);
+ BLI_duplicatelist(&ntree_dst->links, &ntree_src->links);
+ for (link_dst = ntree_dst->links.first; link_dst; link_dst = link_dst->next) {
+ link_dst->fromnode = (link_dst->fromnode ? link_dst->fromnode->new_node : NULL);
+ link_dst->fromsock = (link_dst->fromsock ? link_dst->fromsock->new_sock : NULL);
+ link_dst->tonode = (link_dst->tonode ? link_dst->tonode->new_node : NULL);
+ link_dst->tosock = (link_dst->tosock ? link_dst->tosock->new_sock : NULL);
/* update the link socket's pointer */
- if (link->tosock)
- link->tosock->link = link;
+ if (link_dst->tosock) {
+ link_dst->tosock->link = link_dst;
+ }
}
-
+
/* copy interface sockets */
- BLI_duplicatelist(&newtree->inputs, &ntree->inputs);
- oldsock = ntree->inputs.first;
- for (sock = newtree->inputs.first; sock; sock = sock->next, oldsock = oldsock->next)
- node_socket_copy(sock, oldsock);
-
- BLI_duplicatelist(&newtree->outputs, &ntree->outputs);
- oldsock = ntree->outputs.first;
- for (sock = newtree->outputs.first; sock; sock = sock->next, oldsock = oldsock->next)
- node_socket_copy(sock, oldsock);
-
+ BLI_duplicatelist(&ntree_dst->inputs, &ntree_src->inputs);
+ for (sock_dst = ntree_dst->inputs.first, sock_src = ntree_src->inputs.first;
+ sock_dst != NULL;
+ sock_dst = sock_dst->next, sock_src = sock_src->next)
+ {
+ node_socket_copy(sock_dst, sock_src, flag_subdata);
+ }
+
+ BLI_duplicatelist(&ntree_dst->outputs, &ntree_src->outputs);
+ for (sock_dst = ntree_dst->outputs.first, sock_src = ntree_src->outputs.first;
+ sock_dst != NULL;
+ sock_dst = sock_dst->next, sock_src = sock_src->next)
+ {
+ node_socket_copy(sock_dst, sock_src, flag_subdata);
+ }
+
/* copy preview hash */
- if (ntree->previews && copy_previews) {
+ if (ntree_src->previews && (flag & LIB_ID_COPY_NO_PREVIEW) == 0) {
bNodeInstanceHashIterator iter;
-
- newtree->previews = BKE_node_instance_hash_new("node previews");
-
- NODE_INSTANCE_HASH_ITER(iter, ntree->previews) {
+
+ ntree_dst->previews = BKE_node_instance_hash_new("node previews");
+
+ NODE_INSTANCE_HASH_ITER(iter, ntree_src->previews) {
bNodeInstanceKey key = BKE_node_instance_hash_iterator_get_key(&iter);
bNodePreview *preview = BKE_node_instance_hash_iterator_get_value(&iter);
- BKE_node_instance_hash_insert(newtree->previews, key, BKE_node_preview_copy(preview));
+ BKE_node_instance_hash_insert(ntree_dst->previews, key, BKE_node_preview_copy(preview));
}
}
- else
- newtree->previews = NULL;
-
+ else {
+ ntree_dst->previews = NULL;
+ }
+
/* update node->parent pointers */
- for (node = newtree->nodes.first; node; node = node->next) {
- if (node->parent)
- node->parent = node->parent->new_node;
+ for (bNode *node_dst = ntree_dst->nodes.first, *node_src = ntree_src->nodes.first; node_dst; node_dst = node_dst->next, node_src = node_src->next) {
+ if (node_dst->parent) {
+ node_dst->parent = node_dst->parent->new_node;
+ }
}
-
- /* node tree will generate its own interface type */
- newtree->interface_type = NULL;
-
- BKE_id_copy_ensure_local(bmain, &ntree->id, &newtree->id);
- return newtree;
+ /* node tree will generate its own interface type */
+ ntree_dst->interface_type = NULL;
}
bNodeTree *ntreeCopyTree_ex(const bNodeTree *ntree, Main *bmain, const bool do_id_user)
{
- return ntreeCopyTree_internal(ntree, bmain, false, do_id_user, true, true);
+ bNodeTree *ntree_copy;
+ BKE_id_copy_ex(bmain, (ID *)ntree, (ID **)&ntree_copy, do_id_user ? 0 : LIB_ID_CREATE_NO_USER_REFCOUNT, false);
+ return ntree_copy;
}
bNodeTree *ntreeCopyTree(Main *bmain, const bNodeTree *ntree)
{
@@ -1700,11 +1697,12 @@ static void node_free_node_ex(bNodeTree *ntree, bNode *node, bool remove_animdat
ntreeTexEndExecTree(ntree->execdata);
ntree->execdata = NULL;
}
-
- if (node->typeinfo->freefunc)
- node->typeinfo->freefunc(node);
}
-
+
+ if (node->typeinfo->freefunc) {
+ node->typeinfo->freefunc(node);
+ }
+
for (sock = node->inputs.first; sock; sock = nextsock) {
nextsock = sock->next;
node_socket_free(ntree, sock, node);
@@ -1993,10 +1991,11 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree)
adt->tmpact = NULL;
}
- /* Make full copy.
+ /* Make full copy outside of Main database.
* Note: previews are not copied here.
*/
- ltree = ntreeCopyTree_internal(ntree, G.main, true, false, false, false);
+ BKE_id_copy_ex(G.main, (ID *)ntree, (ID **)&ltree,
+ LIB_ID_CREATE_NO_MAIN | LIB_ID_CREATE_NO_USER_REFCOUNT | LIB_ID_COPY_NO_PREVIEW, false);
ltree->flag |= NTREE_IS_LOCALIZED;
for (node = ltree->nodes.first; node; node = node->next) {
@@ -2024,7 +2023,7 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree)
for (node = ntree->nodes.first; node; node = node->next) {
/* store new_node pointer to original */
- node->new_node->new_node = node;
+ node->new_node->original = node;
}
if (ntree->typeinfo->localize)
@@ -2236,7 +2235,7 @@ static void ntree_interface_type_create(bNodeTree *ntree)
/* register a subtype of PropertyGroup */
srna = RNA_def_struct_ptr(&BLENDER_RNA, identifier, &RNA_PropertyGroup);
RNA_def_struct_ui_text(srna, name, description);
- RNA_def_struct_duplicate_pointers(srna);
+ RNA_def_struct_duplicate_pointers(&BLENDER_RNA, srna);
/* associate the RNA type with the node tree */
ntree->interface_type = srna;
@@ -2275,10 +2274,10 @@ StructRNA *ntreeInterfaceTypeGet(bNodeTree *ntree, int create)
ntree_interface_identifier(ntree, base, identifier, sizeof(identifier), name, description);
/* rename the RNA type */
- RNA_def_struct_free_pointers(srna);
- RNA_def_struct_identifier(srna, identifier);
+ RNA_def_struct_free_pointers(&BLENDER_RNA, srna);
+ RNA_def_struct_identifier(&BLENDER_RNA, srna, identifier);
RNA_def_struct_ui_text(srna, name, description);
- RNA_def_struct_duplicate_pointers(srna);
+ RNA_def_struct_duplicate_pointers(&BLENDER_RNA, srna);
}
}
else if (create) {
@@ -3174,12 +3173,20 @@ void nodeSynchronizeID(bNode *node, bool copy_to_id)
void nodeLabel(bNodeTree *ntree, bNode *node, char *label, int maxlen)
{
- if (node->label[0] != '\0')
+ if (node->label[0] != '\0') {
BLI_strncpy(label, node->label, maxlen);
- else if (node->typeinfo->labelfunc)
+ }
+ else if (node->typeinfo->labelfunc) {
node->typeinfo->labelfunc(ntree, node, label, maxlen);
- else
- BLI_strncpy(label, IFACE_(node->typeinfo->ui_name), maxlen);
+ }
+ else {
+ /* Kind of hacky and weak... Ideally would be better to use RNA here. :| */
+ const char *tmp = CTX_IFACE_(BLT_I18NCONTEXT_ID_NODETREE, node->typeinfo->ui_name);
+ if (tmp == node->typeinfo->ui_name) {
+ tmp = IFACE_(node->typeinfo->ui_name);
+ }
+ BLI_strncpy(label, tmp, maxlen);
+ }
}
static void node_type_base_defaults(bNodeType *ntype)
@@ -3587,12 +3594,10 @@ static void registerShaderNodes(void)
register_node_type_sh_add_shader();
register_node_type_sh_uvmap();
register_node_type_sh_uvalongstroke();
- register_node_type_sh_eevee_metallic();
register_node_type_sh_eevee_specular();
register_node_type_sh_output_lamp();
register_node_type_sh_output_material();
- register_node_type_sh_output_eevee_material();
register_node_type_sh_output_world();
register_node_type_sh_output_linestyle();
@@ -3799,3 +3804,46 @@ void BKE_nodetree_remove_layer_n(bNodeTree *ntree, Scene *scene, const int layer
}
}
}
+
+static void node_copy_default_values_list(ListBase *sockets_dst,
+ const ListBase *sockets_src)
+{
+ bNodeSocket *sock_dst = sockets_dst->first;
+ const bNodeSocket *sock_src = sockets_src->first;
+ while (sock_dst != NULL) {
+ node_socket_copy_default_value(sock_dst, sock_src);
+ sock_dst = sock_dst->next;
+ sock_src = sock_src->next;
+ }
+}
+
+static void node_copy_default_values(bNode *node_dst, const bNode *node_src)
+{
+ node_copy_default_values_list(&node_dst->inputs, &node_src->inputs);
+ node_copy_default_values_list(&node_dst->outputs, &node_src->outputs);
+}
+
+void BKE_nodetree_copy_default_values(bNodeTree *ntree_dst,
+ const bNodeTree *ntree_src)
+{
+ if (ntree_dst == ntree_src) {
+ return;
+ }
+ bNode *node_dst = ntree_dst->nodes.first;
+ const bNode *node_src = ntree_src->nodes.first;
+ while (node_dst != NULL) {
+ node_copy_default_values(node_dst, node_src);
+ node_dst = node_dst->next;
+ node_src = node_src->next;
+ }
+}
+
+void BKE_nodetree_shading_params_eval(const struct EvaluationContext *UNUSED(eval_ctx),
+ bNodeTree *ntree_dst,
+ const bNodeTree *ntree_src)
+{
+ if (G.debug & G_DEBUG_DEPSGRAPH) {
+ printf("%s on %s (%p)\n", __func__, ntree_src->id.name, ntree_dst);
+ }
+ BKE_nodetree_copy_default_values(ntree_dst, ntree_src);
+}
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 68e5ddf8583..a47e88a8e48 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -319,7 +319,7 @@ void BKE_object_link_modifiers(struct Object *ob_dst, const struct Object *ob_sr
modifier_unique_name(&ob_dst->modifiers, nmd);
}
- BKE_object_copy_particlesystems(ob_dst, ob_src);
+ BKE_object_copy_particlesystems(ob_dst, ob_src, 0);
/* TODO: smoke?, cloth? */
}
@@ -337,14 +337,14 @@ void BKE_object_free_derived_caches(Object *ob)
Mesh *me = ob->data;
if (me && me->bb) {
- atomic_fetch_and_or_uint32((uint*)&me->bb->flag, BOUNDBOX_DIRTY);
+ atomic_fetch_and_or_uint32((uint *)&me->bb->flag, BOUNDBOX_DIRTY);
}
}
else if (ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT)) {
Curve *cu = ob->data;
if (cu && cu->bb) {
- atomic_fetch_and_or_uint32((uint*)&cu->bb->flag, BOUNDBOX_DIRTY);
+ atomic_fetch_and_or_uint32((uint *)&cu->bb->flag, BOUNDBOX_DIRTY);
}
}
@@ -365,6 +365,8 @@ void BKE_object_free_derived_caches(Object *ob)
}
if (ob->mesh_evaluated != NULL) {
+ /* Restore initial pointer. */
+ ob->data = ob->mesh_evaluated->id.newid;
/* Evaluated mesh points to edit mesh, but does not own it. */
ob->mesh_evaluated->edit_btmesh = NULL;
BKE_mesh_free(ob->mesh_evaluated);
@@ -560,6 +562,15 @@ bool BKE_object_is_in_wpaint_select_vert(Object *ob)
return false;
}
+/**
+ * Return if the object is visible, as evaluated by depsgraph
+ * Keep in sync with rna_object.c (object.is_visible).
+ */
+bool BKE_object_is_visible(Object *ob)
+{
+ return (ob->base_flag & BASE_VISIBLED) != 0;
+}
+
bool BKE_object_exists_check(Object *obtest)
{
Object *ob;
@@ -703,7 +714,7 @@ Object *BKE_object_add_only_object(Main *bmain, int type, const char *name)
if (!name)
name = get_obdata_defname(type);
- ob = BKE_libblock_alloc(bmain, ID_OB, name);
+ ob = BKE_libblock_alloc(bmain, ID_OB, name, 0);
/* default object vars */
ob->type = type;
@@ -832,7 +843,7 @@ static LodLevel *lod_level_select(Object *ob, const float camera_position[3])
bool BKE_object_lod_is_usable(Object *ob, SceneLayer *sl)
{
- bool active = (sl) ? ob == OBACT_NEW : false;
+ bool active = (sl) ? ob == OBACT_NEW(sl) : false;
return (ob->mode == OB_MODE_OBJECT || !active);
}
@@ -873,7 +884,7 @@ struct Object *BKE_object_lod_matob_get(Object *ob, SceneLayer *sl)
#endif /* WITH_GAMEENGINE */
-SoftBody *copy_softbody(const SoftBody *sb, bool copy_caches)
+SoftBody *copy_softbody(const SoftBody *sb, const int flag)
{
SoftBody *sbn;
@@ -881,7 +892,7 @@ SoftBody *copy_softbody(const SoftBody *sb, bool copy_caches)
sbn = MEM_dupallocN(sb);
- if (copy_caches == false) {
+ if ((flag & LIB_ID_COPY_CACHES) == 0) {
sbn->totspring = sbn->totpoint = 0;
sbn->bpoint = NULL;
sbn->bspring = NULL;
@@ -910,7 +921,7 @@ SoftBody *copy_softbody(const SoftBody *sb, bool copy_caches)
sbn->scratch = NULL;
- sbn->pointcache = BKE_ptcache_copy_list(&sbn->ptcaches, &sb->ptcaches, copy_caches);
+ sbn->pointcache = BKE_ptcache_copy_list(&sbn->ptcaches, &sb->ptcaches, flag);
if (sb->effector_weights)
sbn->effector_weights = MEM_dupallocN(sb->effector_weights);
@@ -918,7 +929,7 @@ SoftBody *copy_softbody(const SoftBody *sb, bool copy_caches)
return sbn;
}
-BulletSoftBody *copy_bulletsoftbody(const BulletSoftBody *bsb)
+BulletSoftBody *copy_bulletsoftbody(const BulletSoftBody *bsb, const int UNUSED(flag))
{
BulletSoftBody *bsbn;
@@ -929,7 +940,7 @@ BulletSoftBody *copy_bulletsoftbody(const BulletSoftBody *bsb)
return bsbn;
}
-ParticleSystem *BKE_object_copy_particlesystem(ParticleSystem *psys)
+ParticleSystem *BKE_object_copy_particlesystem(ParticleSystem *psys, const int flag)
{
ParticleSystem *psysn;
ParticleData *pa;
@@ -966,7 +977,7 @@ ParticleSystem *BKE_object_copy_particlesystem(ParticleSystem *psys)
if (psys->clmd) {
psysn->clmd = (ClothModifierData *)modifier_new(eModifierType_Cloth);
- modifier_copyData((ModifierData *)psys->clmd, (ModifierData *)psysn->clmd);
+ modifier_copyData_ex((ModifierData *)psys->clmd, (ModifierData *)psysn->clmd, flag);
psys->hair_in_dm = psys->hair_out_dm = NULL;
}
@@ -985,7 +996,8 @@ ParticleSystem *BKE_object_copy_particlesystem(ParticleSystem *psys)
BLI_listbase_clear(&psysn->childcachebufs);
psysn->renderdata = NULL;
- psysn->pointcache = BKE_ptcache_copy_list(&psysn->ptcaches, &psys->ptcaches, false);
+ /* XXX Never copy caches here? */
+ psysn->pointcache = BKE_ptcache_copy_list(&psysn->ptcaches, &psys->ptcaches, flag & ~LIB_ID_COPY_CACHES);
/* XXX - from reading existing code this seems correct but intended usage of
* pointcache should /w cloth should be added in 'ParticleSystem' - campbell */
@@ -993,12 +1005,14 @@ ParticleSystem *BKE_object_copy_particlesystem(ParticleSystem *psys)
psysn->clmd->point_cache = psysn->pointcache;
}
- id_us_plus((ID *)psysn->part);
+ if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
+ id_us_plus((ID *)psysn->part);
+ }
return psysn;
}
-void BKE_object_copy_particlesystems(Object *ob_dst, const Object *ob_src)
+void BKE_object_copy_particlesystems(Object *ob_dst, const Object *ob_src, const int flag)
{
ParticleSystem *psys, *npsys;
ModifierData *md;
@@ -1010,7 +1024,7 @@ void BKE_object_copy_particlesystems(Object *ob_dst, const Object *ob_src)
BLI_listbase_clear(&ob_dst->particlesystem);
for (psys = ob_src->particlesystem.first; psys; psys = psys->next) {
- npsys = BKE_object_copy_particlesystem(psys);
+ npsys = BKE_object_copy_particlesystem(psys, flag);
BLI_addtail(&ob_dst->particlesystem, npsys);
@@ -1047,23 +1061,25 @@ void BKE_object_copy_softbody(Object *ob_dst, const Object *ob_src)
{
if (ob_src->soft) {
ob_dst->softflag = ob_src->softflag;
- ob_dst->soft = copy_softbody(ob_src->soft, false);
+ ob_dst->soft = copy_softbody(ob_src->soft, 0);
}
}
-static void copy_object_pose(Object *obn, const Object *ob)
+static void copy_object_pose(Object *obn, const Object *ob, const int flag)
{
bPoseChannel *chan;
/* note: need to clear obn->pose pointer first, so that BKE_pose_copy_data works (otherwise there's a crash) */
obn->pose = NULL;
- BKE_pose_copy_data(&obn->pose, ob->pose, 1); /* 1 = copy constraints */
+ BKE_pose_copy_data_ex(&obn->pose, ob->pose, flag, true); /* true = copy constraints */
for (chan = obn->pose->chanbase.first; chan; chan = chan->next) {
bConstraint *con;
chan->flag &= ~(POSE_LOC | POSE_ROT | POSE_SIZE);
+ /* XXX Remapping object pointing onto itself should be handled by generic BKE_library_remap stuff, but...
+ * the flush_constraint_targets callback am not sure about, so will delay that for now. */
for (con = chan->constraints.first; con; con = con->next) {
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
@@ -1084,13 +1100,10 @@ static void copy_object_pose(Object *obn, const Object *ob)
}
}
-static void copy_object_lod(Object *obn, const Object *ob)
+static void copy_object_lod(Object *obn, const Object *ob, const int UNUSED(flag))
{
BLI_duplicatelist(&obn->lodlevels, &ob->lodlevels);
- if (obn->lodlevels.first)
- ((LodLevel *)obn->lodlevels.first)->source = obn;
-
obn->currentlod = (LodLevel *)obn->lodlevels.first;
}
@@ -1135,100 +1148,101 @@ void BKE_object_transform_copy(Object *ob_tar, const Object *ob_src)
copy_v3_v3(ob_tar->size, ob_src->size);
}
-Object *BKE_object_copy_ex(Main *bmain, const Object *ob, bool copy_caches)
+/**
+ * Only copy internal data of Object ID from source to already allocated/initialized destination.
+ * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
+ *
+ * WARNING! This function will not handle ID user count!
+ *
+ * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
+ */
+void BKE_object_copy_data(Main *UNUSED(bmain), Object *ob_dst, const Object *ob_src, const int flag)
{
- Object *obn;
ModifierData *md;
- int a;
- obn = BKE_libblock_copy(bmain, &ob->id);
-
- if (ob->totcol) {
- obn->mat = MEM_dupallocN(ob->mat);
- obn->matbits = MEM_dupallocN(ob->matbits);
- obn->totcol = ob->totcol;
+ /* We never handle usercount here for own data. */
+ const int flag_subdata = flag | LIB_ID_CREATE_NO_USER_REFCOUNT;
+
+ if (ob_src->totcol) {
+ ob_dst->mat = MEM_dupallocN(ob_src->mat);
+ ob_dst->matbits = MEM_dupallocN(ob_src->matbits);
+ ob_dst->totcol = ob_src->totcol;
}
- if (ob->iuser) obn->iuser = MEM_dupallocN(ob->iuser);
+ if (ob_src->iuser) ob_dst->iuser = MEM_dupallocN(ob_src->iuser);
- if (ob->bb) obn->bb = MEM_dupallocN(ob->bb);
- obn->flag &= ~OB_FROMGROUP;
+ if (ob_src->bb) ob_dst->bb = MEM_dupallocN(ob_src->bb);
+ ob_dst->flag &= ~OB_FROMGROUP;
- BLI_listbase_clear(&obn->modifiers);
+ BLI_listbase_clear(&ob_dst->modifiers);
- for (md = ob->modifiers.first; md; md = md->next) {
+ for (md = ob_src->modifiers.first; md; md = md->next) {
ModifierData *nmd = modifier_new(md->type);
BLI_strncpy(nmd->name, md->name, sizeof(nmd->name));
- modifier_copyData(md, nmd);
- BLI_addtail(&obn->modifiers, nmd);
+ modifier_copyData_ex(md, nmd, flag_subdata);
+ BLI_addtail(&ob_dst->modifiers, nmd);
}
- BLI_listbase_clear(&obn->prop);
- BKE_bproperty_copy_list(&obn->prop, &ob->prop);
+ BLI_listbase_clear(&ob_dst->prop);
+ BKE_bproperty_copy_list(&ob_dst->prop, &ob_src->prop);
- BKE_sca_logic_copy(obn, ob);
+ BKE_sca_logic_copy(ob_dst, ob_src, flag_subdata);
- if (ob->pose) {
- copy_object_pose(obn, ob);
+ if (ob_src->pose) {
+ copy_object_pose(ob_dst, ob_src, flag_subdata);
/* backwards compat... non-armatures can get poses in older files? */
- if (ob->type == OB_ARMATURE)
- BKE_pose_rebuild(obn, obn->data);
+ if (ob_src->type == OB_ARMATURE)
+ BKE_pose_rebuild(ob_dst, ob_dst->data);
}
- defgroup_copy_list(&obn->defbase, &ob->defbase);
- BKE_object_facemap_copy_list(&obn->fmaps, &ob->fmaps);
- BKE_constraints_copy(&obn->constraints, &ob->constraints, true);
+ defgroup_copy_list(&ob_dst->defbase, &ob_src->defbase);
+ BKE_object_facemap_copy_list(&ob_dst->fmaps, &ob_src->fmaps);
+ BKE_constraints_copy_ex(&ob_dst->constraints, &ob_src->constraints, flag_subdata, true);
- obn->mode = OB_MODE_OBJECT;
- obn->sculpt = NULL;
+ ob_dst->mode = OB_MODE_OBJECT;
+ ob_dst->sculpt = NULL;
- /* increase user numbers */
- id_us_plus((ID *)obn->data);
- id_us_plus((ID *)obn->poselib);
- id_us_plus((ID *)obn->gpd);
- id_us_plus((ID *)obn->dup_group);
+ if (ob_src->pd) {
+ ob_dst->pd = MEM_dupallocN(ob_src->pd);
+ if (ob_dst->pd->rng) {
+ ob_dst->pd->rng = MEM_dupallocN(ob_src->pd->rng);
+ }
+ }
+ ob_dst->soft = copy_softbody(ob_src->soft, flag_subdata);
+ ob_dst->bsoft = copy_bulletsoftbody(ob_src->bsoft, flag_subdata);
+ ob_dst->rigidbody_object = BKE_rigidbody_copy_object(ob_src, flag_subdata);
+ ob_dst->rigidbody_constraint = BKE_rigidbody_copy_constraint(ob_src, flag_subdata);
- for (a = 0; a < obn->totcol; a++) id_us_plus((ID *)obn->mat[a]);
+ BKE_object_copy_particlesystems(ob_dst, ob_src, flag_subdata);
- if (ob->pd) {
- obn->pd = MEM_dupallocN(ob->pd);
- if (obn->pd->tex)
- id_us_plus(&(obn->pd->tex->id));
- if (obn->pd->rng)
- obn->pd->rng = MEM_dupallocN(ob->pd->rng);
- }
- obn->soft = copy_softbody(ob->soft, copy_caches);
- obn->bsoft = copy_bulletsoftbody(ob->bsoft);
- obn->rigidbody_object = BKE_rigidbody_copy_object(ob);
- obn->rigidbody_constraint = BKE_rigidbody_copy_constraint(ob);
-
- BKE_object_copy_particlesystems(obn, ob);
-
- obn->derivedDeform = NULL;
- obn->derivedFinal = NULL;
+ ob_dst->derivedDeform = NULL;
+ ob_dst->derivedFinal = NULL;
- BLI_listbase_clear(&obn->gpulamp);
- BLI_listbase_clear(&obn->pc_ids);
- BLI_listbase_clear(&obn->drawdata);
+ BLI_listbase_clear(&ob_dst->gpulamp);
+ BLI_listbase_clear(&ob_dst->drawdata);
+ BLI_listbase_clear(&ob_dst->pc_ids);
- obn->mpath = NULL;
+ ob_dst->mpath = NULL;
- copy_object_lod(obn, ob);
+ copy_object_lod(ob_dst, ob_src, flag_subdata);
- /* Copy runtime surve data. */
- obn->curve_cache = NULL;
-
- BKE_id_copy_ensure_local(bmain, &ob->id, &obn->id);
+ /* Do not copy runtime curve data. */
+ ob_dst->curve_cache = NULL;
/* Do not copy object's preview (mostly due to the fact renderers create temp copy of objects). */
- obn->preview = NULL;
-
- return obn;
+ if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0 && false) { /* XXX TODO temp hack */
+ BKE_previewimg_id_copy(&ob_dst->id, &ob_src->id);
+ }
+ else {
+ ob_dst->preview = NULL;
+ }
}
/* copy objects, will re-initialize cached simulation data */
Object *BKE_object_copy(Main *bmain, const Object *ob)
{
- return BKE_object_copy_ex(bmain, ob, false);
+ Object *ob_copy;
+ BKE_id_copy_ex(bmain, &ob->id, (ID **)&ob_copy, 0, false);
+ return ob_copy;
}
void BKE_object_make_local_ex(Main *bmain, Object *ob, const bool lib_local, const bool clear_proxy)
@@ -1304,10 +1318,10 @@ static void armature_set_id_extern(Object *ob)
unsigned int lay = arm->layer_protected;
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- if (!(pchan->bone->layer & lay)) {
+ if (!(pchan->bone->layer & lay))
id_lib_extern((ID *)pchan->custom);
- }
}
+
}
void BKE_object_copy_proxy_drivers(Object *ob, Object *target)
@@ -1426,7 +1440,7 @@ void BKE_object_make_proxy(Object *ob, Object *target, Object *gob)
/* type conversions */
if (target->type == OB_ARMATURE) {
- copy_object_pose(ob, target); /* data copy, object pointers in constraints */
+ copy_object_pose(ob, target, 0); /* data copy, object pointers in constraints */
BKE_pose_rest(ob->pose); /* clear all transforms in channels */
BKE_pose_rebuild(ob, ob->data); /* set all internal links */
@@ -1709,13 +1723,16 @@ static bool ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[4][4])
Curve *cu = par->data;
float vec[4], dir[3], quat[4], radius, ctime;
+ /* TODO: Make sure this doesn't crash. */
+#if 0
/* only happens on reload file, but violates depsgraph still... fix! */
if (par->curve_cache == NULL) {
if (scene == NULL) {
return false;
}
- BKE_displist_make_curveTypes(scene, par, 0);
+ BKE_displist_make_curveTypes(eval_ctx, scene, par, 0);
}
+#endif
if (par->curve_cache->path == NULL) {
return false;
@@ -2096,8 +2113,9 @@ static bool where_is_object_parslow(Object *ob, float obmat[4][4], float slowmat
}
/* note, scene is the active scene while actual_scene is the scene the object resides in */
-void BKE_object_where_is_calc_time_ex(Scene *scene, Object *ob, float ctime,
- RigidBodyWorld *rbw, float r_originmat[3][3])
+void BKE_object_where_is_calc_time_ex(
+ const EvaluationContext *eval_ctx, Scene *scene, Object *ob, float ctime,
+ RigidBodyWorld *rbw, float r_originmat[3][3])
{
if (ob == NULL) return;
@@ -2132,7 +2150,7 @@ void BKE_object_where_is_calc_time_ex(Scene *scene, Object *ob, float ctime,
if (ob->constraints.first && !(ob->transflag & OB_NO_CONSTRAINTS)) {
bConstraintOb *cob;
cob = BKE_constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
- BKE_constraints_solve(&ob->constraints, cob, ctime);
+ BKE_constraints_solve(eval_ctx, &ob->constraints, cob, ctime);
BKE_constraints_clear_evalob(cob);
}
@@ -2141,9 +2159,9 @@ void BKE_object_where_is_calc_time_ex(Scene *scene, Object *ob, float ctime,
else ob->transflag &= ~OB_NEG_SCALE;
}
-void BKE_object_where_is_calc_time(Scene *scene, Object *ob, float ctime)
+void BKE_object_where_is_calc_time(const EvaluationContext *eval_ctx, Scene *scene, Object *ob, float ctime)
{
- BKE_object_where_is_calc_time_ex(scene, ob, ctime, NULL, NULL);
+ BKE_object_where_is_calc_time_ex(eval_ctx, scene, ob, ctime, NULL, NULL);
}
/* get object transformation matrix without recalculating dependencies and
@@ -2168,17 +2186,17 @@ void BKE_object_where_is_calc_mat4(Scene *scene, Object *ob, float obmat[4][4])
}
}
-void BKE_object_where_is_calc_ex(Scene *scene, RigidBodyWorld *rbw, Object *ob, float r_originmat[3][3])
+void BKE_object_where_is_calc_ex(const EvaluationContext *eval_ctx, Scene *scene, RigidBodyWorld *rbw, Object *ob, float r_originmat[3][3])
{
- BKE_object_where_is_calc_time_ex(scene, ob, BKE_scene_frame_get(scene), rbw, r_originmat);
+ BKE_object_where_is_calc_time_ex(eval_ctx, scene, ob, BKE_scene_frame_get(scene), rbw, r_originmat);
}
-void BKE_object_where_is_calc(Scene *scene, Object *ob)
+void BKE_object_where_is_calc(const EvaluationContext *eval_ctx, Scene *scene, Object *ob)
{
- BKE_object_where_is_calc_time_ex(scene, ob, BKE_scene_frame_get(scene), NULL, NULL);
+ BKE_object_where_is_calc_time_ex(eval_ctx, scene, ob, BKE_scene_frame_get(scene), NULL, NULL);
}
/* for calculation of the inverse parent transform, only used for editor */
-void BKE_object_workob_calc_parent(Scene *scene, Object *ob, Object *workob)
+void BKE_object_workob_calc_parent(const EvaluationContext *eval_ctx, Scene *scene, Object *ob, Object *workob)
{
BKE_object_workob_clear(workob);
@@ -2200,7 +2218,7 @@ void BKE_object_workob_calc_parent(Scene *scene, Object *ob, Object *workob)
BLI_strncpy(workob->parsubstr, ob->parsubstr, sizeof(workob->parsubstr));
- BKE_object_where_is_calc(scene, workob);
+ BKE_object_where_is_calc(eval_ctx, scene, workob);
}
/* see BKE_pchan_apply_mat4() for the equivalent 'pchan' function */
@@ -2531,7 +2549,7 @@ void BKE_scene_foreach_display_point(
Base *base;
Object *ob;
- for (base = FIRSTBASE_NEW; base; base = base->next) {
+ for (base = FIRSTBASE_NEW(sl); base; base = base->next) {
if (((base->flag & BASE_VISIBLED) != 0) && ((base->flag & BASE_SELECTED) != 0)) {
ob = base->object;
@@ -2630,7 +2648,7 @@ bool BKE_object_parent_loop_check(const Object *par, const Object *ob)
/* the main object update call, for object matrix, constraints, keys and displist (modifiers) */
/* requires flags to be set! */
/* Ideally we shouldn't have to pass the rigid body world, but need bigger restructuring to avoid id */
-void BKE_object_handle_update_ex(EvaluationContext *eval_ctx,
+void BKE_object_handle_update_ex(const EvaluationContext *eval_ctx,
Scene *scene, Object *ob,
RigidBodyWorld *rbw,
const bool do_proxy_update)
@@ -2679,7 +2697,7 @@ void BKE_object_handle_update_ex(EvaluationContext *eval_ctx,
copy_m4_m4(ob->obmat, ob->proxy_from->obmat);
}
else
- BKE_object_where_is_calc_ex(scene, rbw, ob, NULL);
+ BKE_object_where_is_calc_ex(eval_ctx, scene, rbw, ob, NULL);
}
if (ob->recalc & OB_RECALC_DATA) {
@@ -2709,7 +2727,7 @@ void BKE_object_handle_update_ex(EvaluationContext *eval_ctx,
* e.g. "scene" <-- set 1 <-- set 2 ("ob" lives here) <-- set 3 <-- ... <-- set n
* rigid bodies depend on their world so use BKE_object_handle_update_ex() to also pass along the corrent rigid body world
*/
-void BKE_object_handle_update(EvaluationContext *eval_ctx, Scene *scene, Object *ob)
+void BKE_object_handle_update(const EvaluationContext *eval_ctx, Scene *scene, Object *ob)
{
BKE_object_handle_update_ex(eval_ctx, scene, ob, NULL, true);
}
@@ -2718,7 +2736,7 @@ void BKE_object_sculpt_modifiers_changed(Object *ob)
{
SculptSession *ss = ob->sculpt;
- if (ss) {
+ if (ss && ss->building_vp_handle == false) {
if (!ss->cache) {
/* we free pbvh on changes, except during sculpt since it can't deal with
* changing PVBH node organization, we hope topology does not change in
@@ -2729,6 +2747,9 @@ void BKE_object_sculpt_modifiers_changed(Object *ob)
}
BKE_sculptsession_free_deformMats(ob->sculpt);
+
+ /* In vertex/weight paint, force maps to be rebuilt. */
+ BKE_sculptsession_free_vwpaint_data(ob->sculpt);
}
else {
PBVHNode **nodes;
@@ -3625,9 +3646,9 @@ static void object_cacheIgnoreClear(Object *ob, int state)
/* Note: this function should eventually be replaced by depsgraph functionality.
* Avoid calling this in new code unless there is a very good reason for it!
*/
-bool BKE_object_modifier_update_subframe(Scene *scene, Object *ob, bool update_mesh,
- int parent_recursion, float frame,
- int type)
+bool BKE_object_modifier_update_subframe(
+ const EvaluationContext *eval_ctx, Scene *scene, Object *ob, bool update_mesh,
+ int parent_recursion, float frame, int type)
{
ModifierData *md = modifiers_findByType(ob, (ModifierType)type);
bConstraint *con;
@@ -3650,8 +3671,8 @@ bool BKE_object_modifier_update_subframe(Scene *scene, Object *ob, bool update_m
if (parent_recursion) {
int recursion = parent_recursion - 1;
bool no_update = false;
- if (ob->parent) no_update |= BKE_object_modifier_update_subframe(scene, ob->parent, 0, recursion, frame, type);
- if (ob->track) no_update |= BKE_object_modifier_update_subframe(scene, ob->track, 0, recursion, frame, type);
+ if (ob->parent) no_update |= BKE_object_modifier_update_subframe(eval_ctx, scene, ob->parent, 0, recursion, frame, type);
+ if (ob->track) no_update |= BKE_object_modifier_update_subframe(eval_ctx, scene, ob->track, 0, recursion, frame, type);
/* skip subframe if object is parented
* to vertex of a dynamic paint canvas */
@@ -3668,7 +3689,7 @@ bool BKE_object_modifier_update_subframe(Scene *scene, Object *ob, bool update_m
cti->get_constraint_targets(con, &targets);
for (ct = targets.first; ct; ct = ct->next) {
if (ct->tar)
- BKE_object_modifier_update_subframe(scene, ct->tar, 0, recursion, frame, type);
+ BKE_object_modifier_update_subframe(eval_ctx, scene, ct->tar, 0, recursion, frame, type);
}
/* free temp targets */
if (cti->flush_constraint_targets)
@@ -3688,7 +3709,7 @@ bool BKE_object_modifier_update_subframe(Scene *scene, Object *ob, bool update_m
object_cacheIgnoreClear(ob, 0);
}
else
- BKE_object_where_is_calc_time(scene, ob, frame);
+ BKE_object_where_is_calc_time(eval_ctx, scene, ob, frame);
/* for curve following objects, parented curve has to be updated too */
if (ob->type == OB_CURVE) {
@@ -3699,7 +3720,7 @@ bool BKE_object_modifier_update_subframe(Scene *scene, Object *ob, bool update_m
if (ob->type == OB_ARMATURE) {
bArmature *arm = ob->data;
BKE_animsys_evaluate_animdata(scene, &arm->id, arm->adt, frame, ADT_RECALC_ANIM);
- BKE_pose_where_is(scene, ob);
+ BKE_pose_where_is(eval_ctx, scene, ob);
}
return false;
diff --git a/source/blender/blenkernel/intern/object_deform.c b/source/blender/blenkernel/intern/object_deform.c
index 455c4b6352d..754434eaef6 100644
--- a/source/blender/blenkernel/intern/object_deform.c
+++ b/source/blender/blenkernel/intern/object_deform.c
@@ -407,7 +407,7 @@ void BKE_object_defgroup_remove(Object *ob, bDeformGroup *defgroup)
else
object_defgroup_remove_object_mode(ob, defgroup);
- BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_PAINT);
+ BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_ALL);
}
/**
@@ -484,6 +484,8 @@ bool BKE_object_defgroup_array_get(ID *id, MDeformVert **dvert_arr, int *dvert_t
*dvert_tot = lt->pntsu * lt->pntsv * lt->pntsw;
return true;
}
+ default:
+ break;
}
}
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index 774ddca061d..c25207d81bf 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -69,7 +69,7 @@
/* Dupli-Geometry */
typedef struct DupliContext {
- EvaluationContext *eval_ctx;
+ const EvaluationContext *eval_ctx;
bool do_update;
bool animated;
Group *group; /* XXX child objects are selected from this group if set, could be nicer */
@@ -95,7 +95,7 @@ typedef struct DupliGenerator {
static const DupliGenerator *get_dupli_generator(const DupliContext *ctx);
/* create initial context for root object */
-static void init_context(DupliContext *r_ctx, EvaluationContext *eval_ctx, Scene *scene, Object *ob, float space_mat[4][4], bool update)
+static void init_context(DupliContext *r_ctx, const EvaluationContext *eval_ctx, Scene *scene, Object *ob, float space_mat[4][4], bool update)
{
r_ctx->eval_ctx = eval_ctx;
r_ctx->scene = scene;
@@ -341,7 +341,7 @@ static void make_duplis_group(const DupliContext *ctx)
}
}
-const DupliGenerator gen_dupli_group = {
+static const DupliGenerator gen_dupli_group = {
OB_DUPLIGROUP, /* type */
make_duplis_group /* make_duplis */
};
@@ -397,7 +397,7 @@ static void make_duplis_frames(const DupliContext *ctx)
* However, this has always been the way that this worked (i.e. pre 2.5), so I guess that it'll be fine!
*/
BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, (float)scene->r.cfra, ADT_RECALC_ANIM); /* ob-eval will do drivers, so we don't need to do them */
- BKE_object_where_is_calc_time(scene, ob, (float)scene->r.cfra);
+ BKE_object_where_is_calc_time(ctx->eval_ctx, scene, ob, (float)scene->r.cfra);
make_dupli(ctx, ob, ob->obmat, scene->r.cfra, false, false);
}
@@ -411,7 +411,7 @@ static void make_duplis_frames(const DupliContext *ctx)
scene->r.cfra = cfrao;
BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, (float)scene->r.cfra, ADT_RECALC_ANIM); /* ob-eval will do drivers, so we don't need to do them */
- BKE_object_where_is_calc_time(scene, ob, (float)scene->r.cfra);
+ BKE_object_where_is_calc_time(ctx->eval_ctx, scene, ob, (float)scene->r.cfra);
/* but, to make sure unkeyed object transforms are still sane,
* let's copy object's original data back over
@@ -419,7 +419,7 @@ static void make_duplis_frames(const DupliContext *ctx)
*ob = copyob;
}
-const DupliGenerator gen_dupli_frames = {
+static const DupliGenerator gen_dupli_frames = {
OB_DUPLIFRAMES, /* type */
make_duplis_frames /* make_duplis */
};
@@ -545,10 +545,15 @@ static void make_duplis_verts(const DupliContext *ctx)
BMEditMesh *em = BKE_editmesh_from_object(parent);
CustomDataMask dm_mask = (use_texcoords ? CD_MASK_BAREMESH | CD_MASK_ORCO : CD_MASK_BAREMESH);
- if (em)
- vdd.dm = editbmesh_get_derived_cage(scene, parent, em, dm_mask);
- else
- vdd.dm = mesh_get_derived_final(scene, parent, dm_mask);
+ if (ctx->eval_ctx->mode == DAG_EVAL_RENDER) {
+ vdd.dm = mesh_create_derived_render(ctx->eval_ctx, scene, parent, dm_mask);
+ }
+ else if (em) {
+ vdd.dm = editbmesh_get_derived_cage(ctx->eval_ctx, scene, parent, em, dm_mask);
+ }
+ else {
+ vdd.dm = mesh_get_derived_final(ctx->eval_ctx, scene, parent, dm_mask);
+ }
vdd.edit_btmesh = me->edit_btmesh;
if (use_texcoords)
@@ -564,7 +569,7 @@ static void make_duplis_verts(const DupliContext *ctx)
vdd.dm->release(vdd.dm);
}
-const DupliGenerator gen_dupli_verts = {
+static const DupliGenerator gen_dupli_verts = {
OB_DUPLIVERTS, /* type */
make_duplis_verts /* make_duplis */
};
@@ -677,7 +682,7 @@ static void make_duplis_font(const DupliContext *ctx)
MEM_freeN(chartransdata);
}
-const DupliGenerator gen_dupli_verts_font = {
+static const DupliGenerator gen_dupli_verts_font = {
OB_DUPLIVERTS, /* type */
make_duplis_font /* make_duplis */
};
@@ -808,10 +813,15 @@ static void make_duplis_faces(const DupliContext *ctx)
BMEditMesh *em = BKE_editmesh_from_object(parent);
CustomDataMask dm_mask = (use_texcoords ? CD_MASK_BAREMESH | CD_MASK_ORCO | CD_MASK_MLOOPUV : CD_MASK_BAREMESH);
- if (em)
- fdd.dm = editbmesh_get_derived_cage(scene, parent, em, dm_mask);
- else
- fdd.dm = mesh_get_derived_final(scene, parent, dm_mask);
+ if (ctx->eval_ctx->mode == DAG_EVAL_RENDER) {
+ fdd.dm = mesh_create_derived_render(ctx->eval_ctx, scene, parent, dm_mask);
+ }
+ else if (em) {
+ fdd.dm = editbmesh_get_derived_cage(ctx->eval_ctx, scene, parent, em, dm_mask);
+ }
+ else {
+ fdd.dm = mesh_get_derived_final(ctx->eval_ctx, scene, parent, dm_mask);
+ }
if (use_texcoords) {
CustomData *ml_data = fdd.dm->getLoopDataLayout(fdd.dm);
@@ -835,7 +845,7 @@ static void make_duplis_faces(const DupliContext *ctx)
fdd.dm->release(fdd.dm);
}
-const DupliGenerator gen_dupli_faces = {
+static const DupliGenerator gen_dupli_faces = {
OB_DUPLIFACES, /* type */
make_duplis_faces /* make_duplis */
};
@@ -888,6 +898,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
if ((psys->renderdata || part->draw_as == PART_DRAW_REND) && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) {
ParticleSimulationData sim = {NULL};
+ sim.eval_ctx = ctx->eval_ctx;
sim.scene = scene;
sim.ob = par;
sim.psys = psys;
@@ -1069,7 +1080,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
}
else {
/* to give ipos in object correct offset */
- BKE_object_where_is_calc_time(scene, ob, ctime - pa_time);
+ BKE_object_where_is_calc_time(ctx->eval_ctx, scene, ob, ctime - pa_time);
copy_v3_v3(vec, obmat[3]);
obmat[3][0] = obmat[3][1] = obmat[3][2] = 0.0f;
@@ -1156,7 +1167,7 @@ static void make_duplis_particles(const DupliContext *ctx)
}
}
-const DupliGenerator gen_dupli_particles = {
+static const DupliGenerator gen_dupli_particles = {
OB_DUPLIPARTS, /* type */
make_duplis_particles /* make_duplis */
};
@@ -1205,7 +1216,7 @@ static const DupliGenerator *get_dupli_generator(const DupliContext *ctx)
/* ---- ListBase dupli container implementation ---- */
/* Returns a list of DupliObject */
-ListBase *object_duplilist_ex(EvaluationContext *eval_ctx, Scene *scene, Object *ob, bool update)
+ListBase *object_duplilist_ex(const EvaluationContext *eval_ctx, Scene *scene, Object *ob, bool update)
{
ListBase *duplilist = MEM_callocN(sizeof(ListBase), "duplilist");
DupliContext ctx;
@@ -1220,7 +1231,7 @@ ListBase *object_duplilist_ex(EvaluationContext *eval_ctx, Scene *scene, Object
/* note: previously updating was always done, this is why it defaults to be on
* but there are likely places it can be called without updating */
-ListBase *object_duplilist(EvaluationContext *eval_ctx, Scene *sce, Object *ob)
+ListBase *object_duplilist(const EvaluationContext *eval_ctx, Scene *sce, Object *ob)
{
return object_duplilist_ex(eval_ctx, sce, ob, true);
}
@@ -1261,7 +1272,7 @@ int count_duplilist(Object *ob)
return 1;
}
-DupliApplyData *duplilist_apply(Object *ob, Scene *scene, ListBase *duplilist)
+DupliApplyData *duplilist_apply(const EvaluationContext *eval_ctx, Object *ob, Scene *scene, ListBase *duplilist)
{
DupliApplyData *apply_data = NULL;
int num_objects = BLI_listbase_count(duplilist);
@@ -1277,7 +1288,7 @@ DupliApplyData *duplilist_apply(Object *ob, Scene *scene, ListBase *duplilist)
for (dob = duplilist->first, i = 0; dob; dob = dob->next, ++i) {
/* make sure derivedmesh is calculated once, before drawing */
if (scene && !(dob->ob->transflag & OB_DUPLICALCDERIVED) && dob->ob->type == OB_MESH) {
- mesh_get_derived_final(scene, dob->ob, scene->customdata_mask);
+ mesh_get_derived_final(eval_ctx, scene, dob->ob, scene->customdata_mask);
dob->ob->transflag |= OB_DUPLICALCDERIVED;
}
}
diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c
index 70e1f434388..c5d267ace9d 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -69,7 +69,7 @@
static ThreadMutex material_lock = BLI_MUTEX_INITIALIZER;
-void BKE_object_eval_local_transform(EvaluationContext *UNUSED(eval_ctx),
+void BKE_object_eval_local_transform(const EvaluationContext *UNUSED(eval_ctx),
Scene *UNUSED(scene),
Object *ob)
{
@@ -81,7 +81,7 @@ void BKE_object_eval_local_transform(EvaluationContext *UNUSED(eval_ctx),
/* Evaluate parent */
/* NOTE: based on solve_parenting(), but with the cruft stripped out */
-void BKE_object_eval_parent(EvaluationContext *UNUSED(eval_ctx),
+void BKE_object_eval_parent(const EvaluationContext *UNUSED(eval_ctx),
Scene *scene,
Object *ob)
{
@@ -113,7 +113,7 @@ void BKE_object_eval_parent(EvaluationContext *UNUSED(eval_ctx),
}
}
-void BKE_object_eval_constraints(EvaluationContext *UNUSED(eval_ctx),
+void BKE_object_eval_constraints(const EvaluationContext *eval_ctx,
Scene *scene,
Object *ob)
{
@@ -132,11 +132,11 @@ void BKE_object_eval_constraints(EvaluationContext *UNUSED(eval_ctx),
*
*/
cob = BKE_constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
- BKE_constraints_solve(&ob->constraints, cob, ctime);
+ BKE_constraints_solve(eval_ctx, &ob->constraints, cob, ctime);
BKE_constraints_clear_evalob(cob);
}
-void BKE_object_eval_done(EvaluationContext *UNUSED(eval_ctx), Object *ob)
+void BKE_object_eval_done(const EvaluationContext *UNUSED(eval_ctx), Object *ob)
{
DEBUG_PRINT("%s on %s\n", __func__, ob->id.name);
@@ -145,9 +145,10 @@ void BKE_object_eval_done(EvaluationContext *UNUSED(eval_ctx), Object *ob)
else ob->transflag &= ~OB_NEG_SCALE;
}
-void BKE_object_handle_data_update(EvaluationContext *eval_ctx,
- Scene *scene,
- Object *ob)
+void BKE_object_handle_data_update(
+ const EvaluationContext *eval_ctx,
+ Scene *scene,
+ Object *ob)
{
ID *data_id = (ID *)ob->data;
AnimData *adt = BKE_animdata_from_id(data_id);
@@ -184,10 +185,10 @@ void BKE_object_handle_data_update(EvaluationContext *eval_ctx,
}
#endif
if (em) {
- makeDerivedMesh(scene, ob, em, data_mask, false); /* was CD_MASK_BAREMESH */
+ makeDerivedMesh(eval_ctx, scene, ob, em, data_mask, false); /* was CD_MASK_BAREMESH */
}
else {
- makeDerivedMesh(scene, ob, NULL, data_mask, false);
+ makeDerivedMesh(eval_ctx, scene, ob, NULL, data_mask, false);
}
break;
}
@@ -199,7 +200,7 @@ void BKE_object_handle_data_update(EvaluationContext *eval_ctx,
}
}
else {
- BKE_pose_where_is(scene, ob);
+ BKE_pose_where_is(eval_ctx, scene, ob);
}
break;
@@ -210,11 +211,11 @@ void BKE_object_handle_data_update(EvaluationContext *eval_ctx,
case OB_CURVE:
case OB_SURF:
case OB_FONT:
- BKE_displist_make_curveTypes(scene, ob, 0);
+ BKE_displist_make_curveTypes(eval_ctx, scene, ob, 0);
break;
case OB_LATTICE:
- BKE_lattice_modifiers_calc(scene, ob);
+ BKE_lattice_modifiers_calc(eval_ctx, scene, ob);
break;
case OB_EMPTY:
@@ -267,7 +268,7 @@ void BKE_object_handle_data_update(EvaluationContext *eval_ctx,
ob->transflag |= OB_DUPLIPARTS;
}
- particle_system_update(scene, ob, psys, (eval_ctx->mode == DAG_EVAL_RENDER));
+ particle_system_update(eval_ctx, scene, ob, psys, (eval_ctx->mode == DAG_EVAL_RENDER));
psys = psys->next;
}
else if (psys->flag & PSYS_DELETE) {
@@ -285,7 +286,7 @@ void BKE_object_handle_data_update(EvaluationContext *eval_ctx,
* the derivedmesh must be created before init_render_mesh,
* since object_duplilist does dupliparticles before that */
CustomDataMask data_mask = CD_MASK_BAREMESH | CD_MASK_MFACE | CD_MASK_MTFACE | CD_MASK_MCOL;
- dm = mesh_create_derived_render(scene, ob, data_mask);
+ dm = mesh_create_derived_render(eval_ctx, scene, ob, data_mask);
dm->release(dm);
for (psys = ob->particlesystem.first; psys; psys = psys->next)
@@ -296,7 +297,7 @@ void BKE_object_handle_data_update(EvaluationContext *eval_ctx,
/* quick cache removed */
}
-void BKE_object_eval_uber_transform(EvaluationContext *UNUSED(eval_ctx),
+void BKE_object_eval_uber_transform(const EvaluationContext *UNUSED(eval_ctx),
Scene *UNUSED(scene),
Object *ob)
{
@@ -326,7 +327,7 @@ void BKE_object_eval_uber_transform(EvaluationContext *UNUSED(eval_ctx),
}
}
-void BKE_object_eval_uber_data(EvaluationContext *eval_ctx,
+void BKE_object_eval_uber_data(const EvaluationContext *eval_ctx,
Scene *scene,
Object *ob)
{
@@ -361,7 +362,7 @@ void BKE_object_eval_uber_data(EvaluationContext *eval_ctx,
/* Copy materials so render engines can access them. */
new_mesh->mat = MEM_dupallocN(mesh->mat);
new_mesh->totcol = mesh->totcol;
- DM_to_mesh(dm, new_mesh, ob, ob->lastDataMask, true);
+ DM_to_mesh(dm, new_mesh, ob, CD_MASK_MESH, true);
new_mesh->edit_btmesh = mesh->edit_btmesh;
/* Store result mesh as derived_mesh of object. This way we have
* explicit way to query final object evaluated data and know for sure
@@ -377,6 +378,11 @@ void BKE_object_eval_uber_data(EvaluationContext *eval_ctx,
/* NOTE: Watch out, some tools might need it!
* So keep around for now..
*/
+ /* Store original ID as a pointer in evaluated ID.
+ * This way we can restore original object data when we are freeing
+ * evaluated mesh.
+ */
+ new_mesh->id.newid = &mesh->id;
}
#if 0
if (ob->derivedFinal != NULL) {
@@ -396,8 +402,16 @@ void BKE_object_eval_uber_data(EvaluationContext *eval_ctx,
ob->recalc &= ~(OB_RECALC_DATA | OB_RECALC_TIME);
}
-void BKE_object_eval_cloth(EvaluationContext *UNUSED(eval_ctx), Scene *scene, Object *object)
+void BKE_object_eval_cloth(const EvaluationContext *UNUSED(eval_ctx), Scene *scene, Object *object)
{
DEBUG_PRINT("%s on %s\n", __func__, object->id.name);
BKE_ptcache_object_reset(scene, object, PTCACHE_RESET_DEPSGRAPH);
}
+
+void BKE_object_eval_update_shading(const EvaluationContext *UNUSED(eval_ctx), Object *object)
+{
+ DEBUG_PRINT("%s on %s\n", __func__, object->id.name);
+ if (object->type == OB_MESH) {
+ BKE_mesh_batch_cache_dirty(object->data, BKE_MESH_BATCH_DIRTY_SHADING);
+ }
+}
diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c
index 64f90ef5c52..89f25136caf 100644
--- a/source/blender/blenkernel/intern/packedFile.c
+++ b/source/blender/blenkernel/intern/packedFile.c
@@ -522,6 +522,8 @@ static void unpack_generate_paths(
case ID_IM:
BLI_snprintf(r_relpath, relpathlen, "//textures/%s", tempname);
break;
+ default:
+ break;
}
{
@@ -712,6 +714,8 @@ bool BKE_pack_check(ID *id)
Library *li = (Library *)id;
return li->packedfile != NULL;
}
+ default:
+ break;
}
return false;
}
@@ -750,5 +754,7 @@ void BKE_unpack_id(Main *bmain, ID *id, ReportList *reports, int how)
BKE_reportf(reports, RPT_ERROR, "Cannot unpack individual Library file, '%s'", li->name);
break;
}
+ default:
+ break;
}
}
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 00efa4aa732..7acddbbb90e 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -49,6 +49,7 @@
#include "BKE_brush.h"
#include "BKE_colortools.h"
+#include "BKE_deform.h"
#include "BKE_main.h"
#include "BKE_context.h"
#include "BKE_crazyspace.h"
@@ -312,24 +313,31 @@ PaintCurve *BKE_paint_curve_add(Main *bmain, const char *name)
{
PaintCurve *pc;
- pc = BKE_libblock_alloc(bmain, ID_PC, name);
+ pc = BKE_libblock_alloc(bmain, ID_PC, name, 0);
return pc;
}
-PaintCurve *BKE_paint_curve_copy(Main *bmain, const PaintCurve *pc)
+/**
+ * Only copy internal data of PaintCurve ID from source to already allocated/initialized destination.
+ * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
+ *
+ * WARNING! This function will not handle ID user count!
+ *
+ * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
+ */
+void BKE_paint_curve_copy_data(Main *UNUSED(bmain), PaintCurve *pc_dst, const PaintCurve *pc_src, const int UNUSED(flag))
{
- PaintCurve *pc_new;
-
- pc_new = BKE_libblock_copy(bmain, &pc->id);
-
- if (pc->tot_points != 0) {
- pc_new->points = MEM_dupallocN(pc->points);
+ if (pc_src->tot_points != 0) {
+ pc_dst->points = MEM_dupallocN(pc_src->points);
}
+}
- BKE_id_copy_ensure_local(bmain, &pc->id, &pc_new->id);
-
- return pc_new;
+PaintCurve *BKE_paint_curve_copy(Main *bmain, const PaintCurve *pc)
+{
+ PaintCurve *pc_copy;
+ BKE_id_copy_ex(bmain, &pc->id, (ID **)&pc_copy, 0, false);
+ return pc_copy;
}
void BKE_paint_curve_make_local(Main *bmain, PaintCurve *pc, const bool lib_local)
@@ -391,7 +399,7 @@ Palette *BKE_palette_add(Main *bmain, const char *name)
{
Palette *palette;
- palette = BKE_libblock_alloc(bmain, ID_PAL, name);
+ palette = BKE_libblock_alloc(bmain, ID_PAL, name, 0);
/* enable fake user by default */
id_fake_user_set(&palette->id);
@@ -399,17 +407,24 @@ Palette *BKE_palette_add(Main *bmain, const char *name)
return palette;
}
-Palette *BKE_palette_copy(Main *bmain, const Palette *palette)
+/**
+ * Only copy internal data of Palette ID from source to already allocated/initialized destination.
+ * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
+ *
+ * WARNING! This function will not handle ID user count!
+ *
+ * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
+ */
+void BKE_palette_copy_data(Main *UNUSED(bmain), Palette *palette_dst, const Palette *palette_src, const int UNUSED(flag))
{
- Palette *palette_new;
-
- palette_new = BKE_libblock_copy(bmain, &palette->id);
-
- BLI_duplicatelist(&palette_new->colors, &palette->colors);
-
- BKE_id_copy_ensure_local(bmain, &palette->id, &palette_new->id);
+ BLI_duplicatelist(&palette_dst->colors, &palette_src->colors);
+}
- return palette_new;
+Palette *BKE_palette_copy(Main *bmain, const Palette *palette)
+{
+ Palette *palette_copy;
+ BKE_id_copy_ex(bmain, &palette->id, (ID **)&palette_copy, 0, false);
+ return palette_copy;
}
void BKE_palette_make_local(Main *bmain, Palette *palette, const bool lib_local)
@@ -455,7 +470,7 @@ bool BKE_paint_select_vert_test(Object *ob)
(ob->type == OB_MESH) &&
(ob->data != NULL) &&
(((Mesh *)ob->data)->editflag & ME_EDIT_PAINT_VERT_SEL) &&
- (ob->mode & OB_MODE_WEIGHT_PAINT)
+ (ob->mode & OB_MODE_WEIGHT_PAINT || ob->mode & OB_MODE_VERTEX_PAINT)
);
}
@@ -540,12 +555,15 @@ void BKE_paint_free(Paint *paint)
* still do a id_us_plus(), rather then if we were copying between 2 existing
* scenes where a matching value should decrease the existing user count as
* with paint_brush_set() */
-void BKE_paint_copy(Paint *src, Paint *tar)
+void BKE_paint_copy(Paint *src, Paint *tar, const int flag)
{
tar->brush = src->brush;
- id_us_plus((ID *)tar->brush);
- id_us_plus((ID *)tar->palette);
tar->cavity_curve = curvemapping_copy(src->cavity_curve);
+
+ if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
+ id_us_plus((ID *)tar->brush);
+ id_us_plus((ID *)tar->palette);
+ }
}
void BKE_paint_stroke_get_average(Scene *scene, Object *ob, float stroke[3])
@@ -659,6 +677,33 @@ void BKE_sculptsession_free_deformMats(SculptSession *ss)
MEM_SAFE_FREE(ss->deform_imats);
}
+void BKE_sculptsession_free_vwpaint_data(struct SculptSession *ss)
+{
+ struct SculptVertexPaintGeomMap *gmap = NULL;
+ if (ss->mode_type == OB_MODE_VERTEX_PAINT) {
+ gmap = &ss->mode.vpaint.gmap;
+
+ MEM_SAFE_FREE(ss->mode.vpaint.previous_color);
+ }
+ else if (ss->mode_type == OB_MODE_WEIGHT_PAINT) {
+ gmap = &ss->mode.wpaint.gmap;
+
+ MEM_SAFE_FREE(ss->mode.wpaint.alpha_weight);
+ if (ss->mode.wpaint.dvert_prev) {
+ BKE_defvert_array_free_elems(ss->mode.wpaint.dvert_prev, ss->totvert);
+ MEM_freeN(ss->mode.wpaint.dvert_prev);
+ ss->mode.wpaint.dvert_prev = NULL;
+ }
+ }
+ else {
+ return;
+ }
+ MEM_SAFE_FREE(gmap->vert_to_loop);
+ MEM_SAFE_FREE(gmap->vert_map_mem);
+ MEM_SAFE_FREE(gmap->vert_to_poly);
+ MEM_SAFE_FREE(gmap->poly_map_mem);
+}
+
/* Write out the sculpt dynamic-topology BMesh to the Mesh */
static void sculptsession_bm_to_me_update_data_only(Object *ob, bool reorder)
{
@@ -694,7 +739,7 @@ void BKE_sculptsession_bm_to_me_for_render(Object *object)
if (object->sculpt->bm) {
/* Ensure no points to old arrays are stored in DM
*
- * Apparently, we could not use DAG_id_tag_update
+ * Apparently, we could not use DEG_id_tag_update
* here because this will lead to the while object
* surface to disappear, so we'll release DM in place.
*/
@@ -750,6 +795,8 @@ void BKE_sculptsession_free(Object *ob)
if (ss->deform_imats)
MEM_freeN(ss->deform_imats);
+ BKE_sculptsession_free_vwpaint_data(ob->sculpt);
+
MEM_freeN(ss);
ob->sculpt = NULL;
@@ -823,8 +870,9 @@ static bool sculpt_modifiers_active(Scene *scene, Sculpt *sd, Object *ob)
/**
* \param need_mask So the DerivedMesh thats returned has mask data
*/
-void BKE_sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob,
- bool need_pmap, bool need_mask)
+void BKE_sculpt_update_mesh_elements(
+ const EvaluationContext *eval_ctx, Scene *scene, Sculpt *sd, Object *ob,
+ bool need_pmap, bool need_mask)
{
DerivedMesh *dm;
SculptSession *ss = ob->sculpt;
@@ -834,6 +882,8 @@ void BKE_sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob,
ss->modifiers_active = sculpt_modifiers_active(scene, sd, ob);
ss->show_diffuse_color = (sd->flags & SCULPT_SHOW_DIFFUSE) != 0;
+ ss->building_vp_handle = false;
+
if (need_mask) {
if (mmd == NULL) {
if (!CustomData_has_layer(&me->vdata, CD_PAINT_MASK)) {
@@ -860,9 +910,10 @@ void BKE_sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob,
ss->kb = (mmd == NULL) ? BKE_keyblock_from_object(ob) : NULL;
- dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
+ dm = mesh_get_derived_final(eval_ctx, scene, ob, CD_MASK_BAREMESH);
- if (mmd) {
+ /* VWPaint require mesh info for loop lookup, so require sculpt mode here */
+ if (mmd && ob->mode & OB_MODE_SCULPT) {
ss->multires = mmd;
ss->totvert = dm->getNumVerts(dm);
ss->totpoly = dm->getNumPolys(dm);
@@ -893,7 +944,7 @@ void BKE_sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob,
ss->orig_cos = (ss->kb) ? BKE_keyblock_convert_to_vertcos(ob, ss->kb) : BKE_mesh_vertexCos_get(me, NULL);
- BKE_crazyspace_build_sculpt(scene, ob, &ss->deform_imats, &ss->deform_cos);
+ BKE_crazyspace_build_sculpt(eval_ctx, scene, ob, &ss->deform_imats, &ss->deform_cos);
BKE_pbvh_apply_vertCos(ss->pbvh, ss->deform_cos);
for (a = 0; a < me->totvert; ++a) {
@@ -929,6 +980,9 @@ void BKE_sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob,
}
}
}
+
+ /* 2.8x - avoid full mesh update! */
+ BKE_mesh_batch_cache_dirty(me, BKE_MESH_BATCH_DIRTY_SCULPT_COORDS);
}
int BKE_sculpt_mask_layers_ensure(Object *ob, MultiresModifierData *mmd)
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 0a7ccc3ce35..7ba7c13fe40 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -255,11 +255,16 @@ struct LatticeDeformData *psys_create_lattice_deform_data(ParticleSimulationData
if (psys_in_edit_mode(sim->scene, sim->psys) == 0) {
Object *lattice = NULL;
ModifierData *md = (ModifierData *)psys_get_modifier(sim->ob, sim->psys);
+ int mode = G.is_rendering ? eModifierMode_Render : eModifierMode_Realtime;
for (; md; md = md->next) {
if (md->type == eModifierType_Lattice) {
- LatticeModifierData *lmd = (LatticeModifierData *)md;
- lattice = lmd->object;
+ if (md->mode & mode) {
+ LatticeModifierData *lmd = (LatticeModifierData *)md;
+ lattice = lmd->object;
+ sim->psys->lattice_strength = lmd->strength;
+ }
+
break;
}
}
@@ -1840,7 +1845,7 @@ void precalc_guides(ParticleSimulationData *sim, ListBase *effectors)
}
}
-int do_guides(ParticleSettings *part, ListBase *effectors, ParticleKey *state, int index, float time)
+int do_guides(const EvaluationContext *eval_ctx, ParticleSettings *part, ListBase *effectors, ParticleKey *state, int index, float time)
{
CurveMapping *clumpcurve = (part->child_flag & PART_CHILD_USE_CLUMP_CURVE) ? part->clumpcurve : NULL;
CurveMapping *roughcurve = (part->child_flag & PART_CHILD_USE_ROUGH_CURVE) ? part->roughcurve : NULL;
@@ -1903,7 +1908,7 @@ int do_guides(ParticleSettings *part, ListBase *effectors, ParticleKey *state, i
/* curve taper */
if (cu->taperobj)
- mul_v3_fl(vec_to_point, BKE_displist_calc_taper(eff->scene, cu->taperobj, (int)(data->strength * guidetime * 100.0f), 100));
+ mul_v3_fl(vec_to_point, BKE_displist_calc_taper(eval_ctx, eff->scene, cu->taperobj, (int)(data->strength * guidetime * 100.0f), 100));
else { /* curve size*/
if (cu->flag & CU_PATH_RADIUS) {
@@ -2704,13 +2709,13 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re
if (sim->psys->effectors && (psys->part->flag & PART_CHILD_EFFECT) == 0) {
for (k = 0, ca = cache[p]; k <= segments; k++, ca++)
/* ca is safe to cast, since only co and vel are used */
- do_guides(sim->psys->part, sim->psys->effectors, (ParticleKey *)ca, p, (float)k / (float)segments);
+ do_guides(sim->eval_ctx, sim->psys->part, sim->psys->effectors, (ParticleKey *)ca, p, (float)k / (float)segments);
}
/* lattices have to be calculated separately to avoid mixups between effector calculations */
if (psys->lattice_deform_data) {
for (k = 0, ca = cache[p]; k <= segments; k++, ca++)
- calc_latt_deform(psys->lattice_deform_data, ca->co, 1.0f);
+ calc_latt_deform(psys->lattice_deform_data, ca->co, psys->lattice_strength);
}
}
@@ -2752,7 +2757,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re
if (vg_length)
MEM_freeN(vg_length);
}
-void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cfra, const bool use_render_params)
+void psys_cache_edit_paths(const EvaluationContext *eval_ctx, Scene *scene, Object *ob, PTCacheEdit *edit, float cfra, const bool use_render_params)
{
ParticleCacheKey *ca, **cache = edit->pathcache;
ParticleEditSettings *pset = &scene->toolsettings->particle;
@@ -2943,6 +2948,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
if (psys) {
ParticleSimulationData sim = {0};
+ sim.eval_ctx = eval_ctx;
sim.scene = scene;
sim.ob = ob;
sim.psys = psys;
@@ -3300,7 +3306,7 @@ ParticleSettings *psys_new_settings(const char *name, Main *main)
if (main == NULL)
main = G.main;
- part = BKE_libblock_alloc(main, ID_PA, name);
+ part = BKE_libblock_alloc(main, ID_PA, name, 0);
default_particle_settings(part);
@@ -3331,38 +3337,45 @@ void BKE_particlesettings_rough_curve_init(ParticleSettings *part)
part->roughcurve = cumap;
}
-ParticleSettings *BKE_particlesettings_copy(Main *bmain, const ParticleSettings *part)
+/**
+ * Only copy internal data of ParticleSettings ID from source to already allocated/initialized destination.
+ * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
+ *
+ * WARNING! This function will not handle ID user count!
+ *
+ * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
+ */
+void BKE_particlesettings_copy_data(
+ Main *UNUSED(bmain), ParticleSettings *part_dst, const ParticleSettings *part_src, const int UNUSED(flag))
{
- ParticleSettings *partn;
- int a;
+ part_dst->pd = MEM_dupallocN(part_src->pd);
+ part_dst->pd2 = MEM_dupallocN(part_src->pd2);
+ part_dst->effector_weights = MEM_dupallocN(part_src->effector_weights);
+ part_dst->fluid = MEM_dupallocN(part_src->fluid);
- partn = BKE_libblock_copy(bmain, &part->id);
-
- partn->pd = MEM_dupallocN(part->pd);
- partn->pd2 = MEM_dupallocN(part->pd2);
- partn->effector_weights = MEM_dupallocN(part->effector_weights);
- partn->fluid = MEM_dupallocN(part->fluid);
+ if (part_src->clumpcurve) {
+ part_dst->clumpcurve = curvemapping_copy(part_src->clumpcurve);
+ }
+ if (part_src->roughcurve) {
+ part_dst->roughcurve = curvemapping_copy(part_src->roughcurve);
+ }
- if (part->clumpcurve)
- partn->clumpcurve = curvemapping_copy(part->clumpcurve);
- if (part->roughcurve)
- partn->roughcurve = curvemapping_copy(part->roughcurve);
-
- partn->boids = boid_copy_settings(part->boids);
+ part_dst->boids = boid_copy_settings(part_src->boids);
- for (a = 0; a < MAX_MTEX; a++) {
- if (part->mtex[a]) {
- partn->mtex[a] = MEM_mallocN(sizeof(MTex), "psys_copy_tex");
- memcpy(partn->mtex[a], part->mtex[a], sizeof(MTex));
- id_us_plus((ID *)partn->mtex[a]->tex);
+ for (int a = 0; a < MAX_MTEX; a++) {
+ if (part_src->mtex[a]) {
+ part_dst->mtex[a] = MEM_dupallocN(part_src->mtex[a]);
}
}
- BLI_duplicatelist(&partn->dupliweights, &part->dupliweights);
-
- BKE_id_copy_ensure_local(bmain, &part->id, &partn->id);
+ BLI_duplicatelist(&part_dst->dupliweights, &part_src->dupliweights);
+}
- return partn;
+ParticleSettings *BKE_particlesettings_copy(Main *bmain, const ParticleSettings *part)
+{
+ ParticleSettings *part_copy;
+ BKE_id_copy_ex(bmain, &part->id, (ID **)&part_copy, 0, false);
+ return part_copy;
}
void BKE_particlesettings_make_local(Main *bmain, ParticleSettings *part, const bool lib_local)
@@ -3374,7 +3387,8 @@ void BKE_particlesettings_make_local(Main *bmain, ParticleSettings *part, const
/* Textures */
/************************************************/
-static int get_particle_uv(DerivedMesh *dm, ParticleData *pa, int face_index, const float fuv[4], char *name, float *texco)
+static int get_particle_uv(DerivedMesh *dm, ParticleData *pa, int index, const float fuv[4],
+ char *name, float *texco, bool from_vert)
{
MFace *mf;
MTFace *tf;
@@ -3390,11 +3404,15 @@ static int get_particle_uv(DerivedMesh *dm, ParticleData *pa, int face_index, co
if (pa) {
i = ELEM(pa->num_dmcache, DMCACHE_NOTFOUND, DMCACHE_ISCHILD) ? pa->num : pa->num_dmcache;
- if (i >= dm->getNumTessFaces(dm))
+ if ((!from_vert && i >= dm->getNumTessFaces(dm)) ||
+ (from_vert && i >= dm->getNumVerts(dm)))
+ {
i = -1;
+ }
+ }
+ else {
+ i = index;
}
- else
- i = face_index;
if (i == -1) {
texco[0] = 0.0f;
@@ -3402,7 +3420,22 @@ static int get_particle_uv(DerivedMesh *dm, ParticleData *pa, int face_index, co
texco[2] = 0.0f;
}
else {
- mf = dm->getTessFaceData(dm, i, CD_MFACE);
+ if (from_vert) {
+ mf = dm->getTessFaceDataArray(dm, CD_MFACE);
+
+ /* This finds the first face to contain the emitting vertex,
+ * this is not ideal, but is mostly fine as UV seams generally
+ * map to equal-colored parts of a texture */
+ for (int j = 0; j < dm->getNumTessFaces(dm); j++, mf++) {
+ if (ELEM(i, mf->v1, mf->v2, mf->v3, mf->v4)) {
+ i = j;
+ break;
+ }
+ }
+ }
+ else {
+ mf = dm->getTessFaceData(dm, i, CD_MFACE);
+ }
psys_interpolate_uvs(&tf[i], mf->v4, fuv, texco);
@@ -3469,8 +3502,11 @@ static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSetti
mul_m4_v3(mtex->object->imat, texvec);
break;
case TEXCO_UV:
- if (fw && get_particle_uv(dm, NULL, face_index, fw, mtex->uvname, texvec))
+ if (fw && get_particle_uv(dm, NULL, face_index, fw, mtex->uvname,
+ texvec, (part->from == PART_FROM_VERT)))
+ {
break;
+ }
/* no break, failed to get uv's, so let's try orco's */
ATTR_FALLTHROUGH;
case TEXCO_ORCO:
@@ -3542,8 +3578,11 @@ void psys_get_texture(ParticleSimulationData *sim, ParticleData *pa, ParticleTex
mul_m4_v3(mtex->object->imat, texvec);
break;
case TEXCO_UV:
- if (get_particle_uv(sim->psmd->dm_final, pa, 0, pa->fuv, mtex->uvname, texvec))
+ if (get_particle_uv(sim->psmd->dm_final, pa, 0, pa->fuv, mtex->uvname,
+ texvec, (part->from == PART_FROM_VERT)))
+ {
break;
+ }
/* no break, failed to get uv's, so let's try orco's */
ATTR_FALLTHROUGH;
case TEXCO_ORCO:
@@ -3748,12 +3787,12 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey *
mul_mat3_m4_v3(hairmat, state->vel);
if (sim->psys->effectors && (part->flag & PART_CHILD_GUIDE) == 0) {
- do_guides(sim->psys->part, sim->psys->effectors, state, p, state->time);
+ do_guides(sim->eval_ctx, sim->psys->part, sim->psys->effectors, state, p, state->time);
/* TODO: proper velocity handling */
}
if (psys->lattice_deform_data && edit == 0)
- calc_latt_deform(psys->lattice_deform_data, state->co, 1.0f);
+ calc_latt_deform(psys->lattice_deform_data, state->co, psys->lattice_strength);
}
}
}
@@ -3992,7 +4031,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta
do_child_modifiers(NULL, sim, NULL, key1->co, key1->vel, key1->rot, par_orco, cpa, cpa->fuv, mat, state, t);
if (psys->lattice_deform_data)
- calc_latt_deform(psys->lattice_deform_data, state->co, 1.0f);
+ calc_latt_deform(psys->lattice_deform_data, state->co, psys->lattice_strength);
}
else {
if (pa->state.time == cfra || ELEM(part->phystype, PART_PHYS_NO, PART_PHYS_KEYED))
@@ -4051,7 +4090,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta
}
if (sim->psys->lattice_deform_data)
- calc_latt_deform(sim->psys->lattice_deform_data, state->co, 1.0f);
+ calc_latt_deform(sim->psys->lattice_deform_data, state->co, psys->lattice_strength);
}
return 1;
@@ -4275,9 +4314,10 @@ void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3]
madd_v3_v3fl(center, yvec, bb->offset[1]);
}
-void psys_apply_hair_lattice(Scene *scene, Object *ob, ParticleSystem *psys)
+void psys_apply_hair_lattice(const EvaluationContext *eval_ctx, Scene *scene, Object *ob, ParticleSystem *psys)
{
ParticleSimulationData sim = {0};
+ sim.eval_ctx = eval_ctx;
sim.scene = scene;
sim.ob = ob;
sim.psys = psys;
@@ -4298,7 +4338,7 @@ void psys_apply_hair_lattice(Scene *scene, Object *ob, ParticleSystem *psys)
hkey = pa->hair;
for (h = 0; h < pa->totkey; h++, hkey++) {
mul_m4_v3(hairmat, hkey->co);
- calc_latt_deform(psys->lattice_deform_data, hkey->co, 1.0f);
+ calc_latt_deform(psys->lattice_deform_data, hkey->co, psys->lattice_strength);
mul_m4_v3(imat, hkey->co);
}
}
diff --git a/source/blender/blenkernel/intern/particle_child.c b/source/blender/blenkernel/intern/particle_child.c
index bfcda89a635..d2ad05c20b7 100644
--- a/source/blender/blenkernel/intern/particle_child.c
+++ b/source/blender/blenkernel/intern/particle_child.c
@@ -702,7 +702,7 @@ void do_child_modifiers(ParticleThreadContext *ctx, ParticleSimulationData *sim,
if (part->flag & PART_CHILD_EFFECT)
/* state is safe to cast, since only co and vel are used */
- guided = do_guides(sim->psys->part, sim->psys->effectors, (ParticleKey *)state, cpa->parent, t);
+ guided = do_guides(sim->eval_ctx, sim->psys->part, sim->psys->effectors, (ParticleKey *)state, cpa->parent, t);
if (guided == 0) {
float orco_offset[3];
diff --git a/source/blender/blenkernel/intern/particle_distribute.c b/source/blender/blenkernel/intern/particle_distribute.c
index 6603521c42f..ff8a638089f 100644
--- a/source/blender/blenkernel/intern/particle_distribute.c
+++ b/source/blender/blenkernel/intern/particle_distribute.c
@@ -39,6 +39,7 @@
#include "BLI_jitter.h"
#include "BLI_kdtree.h"
#include "BLI_math.h"
+#include "BLI_math_geom.h"
#include "BLI_rand.h"
#include "BLI_sort.h"
#include "BLI_task.h"
@@ -213,14 +214,22 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys)
copy_v3_v3(co2, co1);
co2[a] += delta[a] + 0.001f*d;
co1[a] -= 0.001f*d;
-
+
+ struct IsectRayPrecalc isect_precalc;
+ float ray_direction[3];
+ sub_v3_v3v3(ray_direction, co2, co1);
+ isect_ray_tri_watertight_v3_precalc(&isect_precalc, ray_direction);
+
/* lets intersect the faces */
for (i=0; i<totface; i++,mface++) {
copy_v3_v3(v1, mvert[mface->v1].co);
copy_v3_v3(v2, mvert[mface->v2].co);
copy_v3_v3(v3, mvert[mface->v3].co);
- bool intersects_tri = isect_axial_line_segment_tri_v3(a, co1, co2, v2, v3, v1, &lambda);
+ bool intersects_tri = isect_ray_tri_watertight_v3(co1,
+ &isect_precalc,
+ v1, v2, v3,
+ &lambda, NULL);
if (intersects_tri) {
if (from==PART_FROM_FACE)
(pa+(int)(lambda*size[a])*a0mul)->flag &= ~PARS_UNEXIST;
@@ -231,7 +240,10 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys)
if (mface->v4 && (!intersects_tri || from==PART_FROM_VOLUME)) {
copy_v3_v3(v4, mvert[mface->v4].co);
- if (isect_axial_line_segment_tri_v3(a, co1, co2, v4, v1, v3, &lambda)) {
+ if (isect_ray_tri_watertight_v3(co1,
+ &isect_precalc,
+ v1, v3, v4,
+ &lambda, NULL)) {
if (from==PART_FROM_FACE)
(pa+(int)(lambda*size[a])*a0mul)->flag &= ~PARS_UNEXIST;
else
@@ -300,19 +312,16 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys)
static void hammersley_create(float *out, int n, int seed, float amount)
{
RNG *rng;
- double p, t, offs[2];
- int k, kk;
+
+ double offs[2], t;
rng = BLI_rng_new(31415926 + n + seed);
offs[0] = BLI_rng_get_double(rng) + (double)amount;
offs[1] = BLI_rng_get_double(rng) + (double)amount;
BLI_rng_free(rng);
- for (k = 0; k < n; k++) {
- t = 0;
- for (p = 0.5, kk = k; kk; p *= 0.5, kk >>= 1)
- if (kk & 1) /* kk mod 2 = 1 */
- t += p;
+ for (int k = 0; k < n; k++) {
+ BLI_hammersley_1D(k, &t);
out[2*k + 0] = fmod((double)k/(double)n + offs[0], 1.0);
out[2*k + 1] = fmod(t + offs[1], 1.0);
@@ -427,12 +436,37 @@ static int distribute_binary_search(float *sum, int n, float value)
static void distribute_from_verts_exec(ParticleTask *thread, ParticleData *pa, int p)
{
ParticleThreadContext *ctx= thread->ctx;
- int rng_skip_tot= PSYS_RND_DIST_SKIP; /* count how many rng_* calls wont need skipping */
+ MFace *mface;
+
+ mface = ctx->dm->getTessFaceDataArray(ctx->dm, CD_MFACE);
+
+ int rng_skip_tot = PSYS_RND_DIST_SKIP; /* count how many rng_* calls wont need skipping */
/* TODO_PARTICLE - use original index */
- pa->num= ctx->index[p];
- pa->fuv[0] = 1.0f;
- pa->fuv[1] = pa->fuv[2] = pa->fuv[3] = 0.0;
+ pa->num = ctx->index[p];
+
+ zero_v4(pa->fuv);
+
+ if (pa->num != DMCACHE_NOTFOUND && pa->num < ctx->dm->getNumVerts(ctx->dm)) {
+
+ /* This finds the first face to contain the emitting vertex,
+ * this is not ideal, but is mostly fine as UV seams generally
+ * map to equal-colored parts of a texture */
+ for (int i = 0; i < ctx->dm->getNumTessFaces(ctx->dm); i++, mface++) {
+ if (ELEM(pa->num, mface->v1, mface->v2, mface->v3, mface->v4)) {
+ unsigned int *vert = &mface->v1;
+
+ for (int j = 0; j < 4; j++, vert++) {
+ if (*vert == pa->num) {
+ pa->fuv[j] = 1.0f;
+ break;
+ }
+ }
+
+ break;
+ }
+ }
+ }
#if ONLY_WORKING_WITH_PA_VERTS
if (ctx->tree) {
@@ -873,10 +907,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
else
dm= CDDM_from_mesh((Mesh*)ob->data);
- /* BMESH ONLY, for verts we don't care about tessfaces */
- if (from != PART_FROM_VERT) {
- DM_ensure_tessface(dm);
- }
+ DM_ensure_tessface(dm);
/* we need orco for consistent distributions */
if (!CustomData_has_layer(&dm->vertData, CD_ORCO))
@@ -1070,13 +1101,10 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
/* This is to address tricky issues with vertex-emitting when user tries (and expects) exact 1-1 vert/part
* distribution (see T47983 and its two example files). It allows us to consider pos as
* 'midpoint between v and v+1' (or 'p and p+1', depending whether we have more vertices than particles or not),
- * and avoid stumbling over float imprecisions in element_sum. */
- if (from == PART_FROM_VERT) {
- pos = (totpart < totmapped) ? 0.5 / (double)totmapped : step * 0.5; /* We choose the smaller step. */
- }
- else {
- pos = 0.0;
- }
+ * and avoid stumbling over float imprecisions in element_sum.
+ * Note: moved face and volume distribution to this as well (instead of starting at zero),
+ * for the same reasons, see T52682. */
+ pos = (totpart < totmapped) ? 0.5 / (double)totmapped : step * 0.5; /* We choose the smaller step. */
for (i = 0, p = 0; p < totpart; p++, pos += step) {
for ( ; (i < totmapped - 1) && (pos > (double)element_sum[i]); i++);
@@ -1115,7 +1143,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
if (jitlevel == 0) {
jitlevel= totpart/totelem;
- if (part->flag & PART_EDISTR) jitlevel*= 2; /* looks better in general, not very scietific */
+ if (part->flag & PART_EDISTR) jitlevel*= 2; /* looks better in general, not very scientific */
if (jitlevel<3) jitlevel= 3;
}
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index a6ed50fd0e9..ddf4f04c808 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -980,14 +980,14 @@ void psys_get_birth_coords(ParticleSimulationData *sim, ParticleData *pa, Partic
}
/* recursively evaluate emitter parent anim at cfra */
-static void evaluate_emitter_anim(Scene *scene, Object *ob, float cfra)
+static void evaluate_emitter_anim(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float cfra)
{
if (ob->parent)
- evaluate_emitter_anim(scene, ob->parent, cfra);
+ evaluate_emitter_anim(eval_ctx, scene, ob->parent, cfra);
/* we have to force RECALC_ANIM here since where_is_objec_time only does drivers */
BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, cfra, ADT_RECALC_ANIM);
- BKE_object_where_is_calc_time(scene, ob, cfra);
+ BKE_object_where_is_calc_time(eval_ctx, scene, ob, cfra);
}
/* sets particle to the emitter surface with initial velocity & rotation */
@@ -1001,7 +1001,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
/* get precise emitter matrix if particle is born */
if (part->type != PART_HAIR && dtime > 0.f && pa->time < cfra && pa->time >= sim->psys->cfra) {
- evaluate_emitter_anim(sim->scene, sim->ob, pa->time);
+ evaluate_emitter_anim(sim->eval_ctx, sim->scene, sim->ob, pa->time);
psys->flag |= PSYS_OB_ANIM_RESTORE;
}
@@ -1133,7 +1133,8 @@ static void set_keyed_keys(ParticleSimulationData *sim)
int totpart = psys->totpart, k, totkeys = psys->totkeyed;
int keyed_flag = 0;
- ksim.scene= sim->scene;
+ ksim.eval_ctx = sim->eval_ctx;
+ ksim.scene = sim->scene;
/* no proper targets so let's clear and bail out */
if (psys->totkeyed==0) {
@@ -1294,7 +1295,7 @@ void psys_update_particle_tree(ParticleSystem *psys, float cfra)
static void psys_update_effectors(ParticleSimulationData *sim)
{
pdEndEffectors(&sim->psys->effectors);
- sim->psys->effectors = pdInitEffectors(sim->scene, sim->ob, sim->psys,
+ sim->psys->effectors = pdInitEffectors(sim->eval_ctx, sim->scene, sim->ob, sim->psys,
sim->psys->part->effector_weights, true);
precalc_guides(sim, sim->psys->effectors);
}
@@ -2115,7 +2116,7 @@ static void basic_integrate(ParticleSimulationData *sim, int p, float dfra, floa
tkey.time=pa->state.time;
if (part->type != PART_HAIR) {
- if (do_guides(sim->psys->part, sim->psys->effectors, &tkey, p, time)) {
+ if (do_guides(sim->eval_ctx, sim->psys->part, sim->psys->effectors, &tkey, p, time)) {
copy_v3_v3(pa->state.co,tkey.co);
/* guides don't produce valid velocity */
sub_v3_v3v3(pa->state.vel, tkey.co, pa->prev_state.co);
@@ -2319,21 +2320,21 @@ static void collision_point_on_surface(float p[3], ParticleCollisionElement *pce
}
case 3:
{
- float p0[3], e1[3], e2[3], nor[3];
+ float p0[3], e1[3], e2[3], nor[3];
- sub_v3_v3v3(e1, pce->x1, pce->x0);
- sub_v3_v3v3(e2, pce->x2, pce->x0);
- sub_v3_v3v3(p0, p, pce->x0);
+ sub_v3_v3v3(e1, pce->x1, pce->x0);
+ sub_v3_v3v3(e2, pce->x2, pce->x0);
+ sub_v3_v3v3(p0, p, pce->x0);
- cross_v3_v3v3(nor, e1, e2);
- normalize_v3(nor);
+ cross_v3_v3v3(nor, e1, e2);
+ normalize_v3(nor);
- if (pce->inv_nor == 1)
- negate_v3(nor);
+ if (pce->inv_nor == 1)
+ negate_v3(nor);
- madd_v3_v3v3fl(co, pce->x0, nor, col->radius);
- madd_v3_v3fl(co, e1, pce->uv[0]);
- madd_v3_v3fl(co, e2, pce->uv[1]);
+ madd_v3_v3v3fl(co, pce->x0, nor, col->radius);
+ madd_v3_v3fl(co, e1, pce->uv[0]);
+ madd_v3_v3fl(co, e2, pce->uv[1]);
break;
}
}
@@ -3043,10 +3044,12 @@ static void hair_create_input_dm(ParticleSimulationData *sim, int totpoint, int
/* calculate maximum segment length */
max_length = 0.0f;
LOOP_PARTICLES {
- for (k=1, key=pa->hair+1; k<pa->totkey; k++,key++) {
- float length = len_v3v3(key->co, (key-1)->co);
- if (max_length < length)
- max_length = length;
+ if (!(pa->flag & PARS_UNEXIST)) {
+ for (k=1, key=pa->hair+1; k<pa->totkey; k++,key++) {
+ float length = len_v3v3(key->co, (key-1)->co);
+ if (max_length < length)
+ max_length = length;
+ }
}
}
@@ -3058,76 +3061,78 @@ static void hair_create_input_dm(ParticleSimulationData *sim, int totpoint, int
/* make vgroup for pin roots etc.. */
hair_index = 1;
LOOP_PARTICLES {
- float root_mat[4][4];
- float bending_stiffness;
- bool use_hair;
-
- pa->hair_index = hair_index;
- use_hair = psys_hair_use_simulation(pa, max_length);
-
- psys_mat_hair_to_object(sim->ob, sim->psmd->dm_final, psys->part->from, pa, hairmat);
- mul_m4_m4m4(root_mat, sim->ob->obmat, hairmat);
- normalize_m4(root_mat);
-
- bending_stiffness = CLAMPIS(1.0f - part->bending_random * psys_frand(psys, p + 666), 0.0f, 1.0f);
-
- for (k=0, key=pa->hair; k<pa->totkey; k++,key++) {
- ClothHairData *hair;
- float *co, *co_next;
-
- co = key->co;
- co_next = (key+1)->co;
-
- /* create fake root before actual root to resist bending */
- if (k==0) {
- hair = &psys->clmd->hairdata[pa->hair_index - 1];
+ if (!(pa->flag & PARS_UNEXIST)) {
+ float root_mat[4][4];
+ float bending_stiffness;
+ bool use_hair;
+
+ pa->hair_index = hair_index;
+ use_hair = psys_hair_use_simulation(pa, max_length);
+
+ psys_mat_hair_to_object(sim->ob, sim->psmd->dm_final, psys->part->from, pa, hairmat);
+ mul_m4_m4m4(root_mat, sim->ob->obmat, hairmat);
+ normalize_m4(root_mat);
+
+ bending_stiffness = CLAMPIS(1.0f - part->bending_random * psys_frand(psys, p + 666), 0.0f, 1.0f);
+
+ for (k=0, key=pa->hair; k<pa->totkey; k++,key++) {
+ ClothHairData *hair;
+ float *co, *co_next;
+
+ co = key->co;
+ co_next = (key+1)->co;
+
+ /* create fake root before actual root to resist bending */
+ if (k==0) {
+ hair = &psys->clmd->hairdata[pa->hair_index - 1];
+ copy_v3_v3(hair->loc, root_mat[3]);
+ copy_m3_m4(hair->rot, root_mat);
+
+ hair->radius = hair_radius;
+ hair->bending_stiffness = bending_stiffness;
+
+ add_v3_v3v3(mvert->co, co, co);
+ sub_v3_v3(mvert->co, co_next);
+ mul_m4_v3(hairmat, mvert->co);
+
+ medge->v1 = pa->hair_index - 1;
+ medge->v2 = pa->hair_index;
+
+ dvert = hair_set_pinning(dvert, 1.0f);
+
+ mvert++;
+ medge++;
+ }
+
+ /* store root transform in cloth data */
+ hair = &psys->clmd->hairdata[pa->hair_index + k];
copy_v3_v3(hair->loc, root_mat[3]);
copy_m3_m4(hair->rot, root_mat);
-
+
hair->radius = hair_radius;
hair->bending_stiffness = bending_stiffness;
-
- add_v3_v3v3(mvert->co, co, co);
- sub_v3_v3(mvert->co, co_next);
+
+ copy_v3_v3(mvert->co, co);
mul_m4_v3(hairmat, mvert->co);
-
- medge->v1 = pa->hair_index - 1;
- medge->v2 = pa->hair_index;
-
- dvert = hair_set_pinning(dvert, 1.0f);
-
+
+ if (k) {
+ medge->v1 = pa->hair_index + k - 1;
+ medge->v2 = pa->hair_index + k;
+ }
+
+ /* roots and disabled hairs should be 1.0, the rest can be anything from 0.0 to 1.0 */
+ if (use_hair)
+ dvert = hair_set_pinning(dvert, key->weight);
+ else
+ dvert = hair_set_pinning(dvert, 1.0f);
+
mvert++;
- medge++;
- }
-
- /* store root transform in cloth data */
- hair = &psys->clmd->hairdata[pa->hair_index + k];
- copy_v3_v3(hair->loc, root_mat[3]);
- copy_m3_m4(hair->rot, root_mat);
-
- hair->radius = hair_radius;
- hair->bending_stiffness = bending_stiffness;
-
- copy_v3_v3(mvert->co, co);
- mul_m4_v3(hairmat, mvert->co);
-
- if (k) {
- medge->v1 = pa->hair_index + k - 1;
- medge->v2 = pa->hair_index + k;
+ if (k)
+ medge++;
}
-
- /* roots and disabled hairs should be 1.0, the rest can be anything from 0.0 to 1.0 */
- if (use_hair)
- dvert = hair_set_pinning(dvert, key->weight);
- else
- dvert = hair_set_pinning(dvert, 1.0f);
-
- mvert++;
- if (k)
- medge++;
+
+ hair_index += pa->totkey + 1;
}
-
- hair_index += pa->totkey + 1;
}
}
@@ -3153,9 +3158,11 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
totpoint = 0;
totedge = 0;
LOOP_PARTICLES {
- /* "out" dm contains all hairs */
- totedge += pa->totkey;
- totpoint += pa->totkey + 1; /* +1 for virtual root point */
+ if (!(pa->flag & PARS_UNEXIST)) {
+ /* "out" dm contains all hairs */
+ totedge += pa->totkey;
+ totpoint += pa->totkey + 1; /* +1 for virtual root point */
+ }
}
realloc_roots = false; /* whether hair root info array has to be reallocated */
@@ -3191,7 +3198,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
psys->hair_out_dm = CDDM_copy(psys->hair_in_dm);
psys->hair_out_dm->getVertCos(psys->hair_out_dm, deformedVerts);
- clothModifier_do(psys->clmd, sim->scene, sim->ob, psys->hair_in_dm, deformedVerts);
+ clothModifier_do(psys->clmd, sim->eval_ctx, sim->scene, sim->ob, psys->hair_in_dm, deformedVerts);
CDDM_apply_vert_coords(psys->hair_out_dm, deformedVerts);
@@ -4151,7 +4158,7 @@ static int hair_needs_recalc(ParticleSystem *psys)
/* main particle update call, checks that things are ok on the large scale and
* then advances in to actual particle calculations depending on particle type */
-void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys, const bool use_render_params)
+void particle_system_update(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, ParticleSystem *psys, const bool use_render_params)
{
ParticleSimulationData sim= {0};
ParticleSettings *part = psys->part;
@@ -4165,10 +4172,11 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys, cons
cfra= BKE_scene_frame_get(scene);
- sim.scene= scene;
- sim.ob= ob;
- sim.psys= psys;
- sim.psmd= psys_get_modifier(ob, psys);
+ sim.eval_ctx = eval_ctx;
+ sim.scene = scene;
+ sim.ob = ob;
+ sim.psys = psys;
+ sim.psmd = psys_get_modifier(ob, psys);
/* system was already updated from modifier stack */
if (sim.psmd->flag & eParticleSystemFlag_psys_updated) {
@@ -4311,7 +4319,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys, cons
/* make sure emitter is left at correct time (particle emission can change this) */
if (psys->flag & PSYS_OB_ANIM_RESTORE) {
- evaluate_emitter_anim(scene, ob, cfra);
+ evaluate_emitter_anim(eval_ctx, scene, ob, cfra);
psys->flag &= ~PSYS_OB_ANIM_RESTORE;
}
@@ -4353,13 +4361,30 @@ void BKE_particlesystem_id_loop(ParticleSystem *psys, ParticleSystemIDFunc func,
/* **** Depsgraph evaluation **** */
-void BKE_particle_system_eval(struct EvaluationContext *UNUSED(eval_ctx),
- Scene *scene,
- Object *ob,
- ParticleSystem *psys)
+void BKE_particle_system_settings_eval(const struct EvaluationContext *UNUSED(eval_ctx),
+ ParticleSystem *psys)
+{
+ if (G.debug & G_DEBUG_DEPSGRAPH) {
+ printf("%s on %s (%p)\n", __func__, psys->name, psys);
+ }
+ psys->recalc |= psys->part->recalc;
+}
+
+void BKE_particle_system_settings_recalc_clear(struct EvaluationContext *UNUSED(eval_ctx),
+ ParticleSettings *particle_settings)
+{
+ if (G.debug & G_DEBUG_DEPSGRAPH) {
+ printf("%s on %s (%p)\n", __func__, particle_settings->id.name, particle_settings);
+ }
+ particle_settings->recalc = 0;
+}
+
+void BKE_particle_system_eval_init(const struct EvaluationContext *UNUSED(eval_ctx),
+ Scene *scene,
+ Object *ob)
{
if (G.debug & G_DEBUG_DEPSGRAPH) {
- printf("%s on %s:%s\n", __func__, ob->id.name, psys->name);
+ printf("%s on %s (%p)\n", __func__, ob->id.name, ob);
}
BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_DEPSGRAPH);
}
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index ef2eaf8405b..6fc89eb778a 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -34,6 +34,7 @@
#include "BKE_pbvh.h"
#include "BKE_ccg.h"
+#include "BKE_subsurf.h"
#include "BKE_DerivedMesh.h"
#include "BKE_global.h"
#include "BKE_mesh.h" /* for BKE_mesh_calc_normals */
@@ -607,6 +608,11 @@ void BKE_pbvh_build_grids(PBVH *bvh, CCGElem **grids,
MEM_freeN(prim_bbc);
}
+void BKE_pbvh_set_ccgdm(PBVH *bvh, CCGDerivedMesh *ccgdm)
+{
+ bvh->ccgdm = ccgdm;
+}
+
PBVH *BKE_pbvh_new(void)
{
PBVH *bvh = MEM_callocN(sizeof(PBVH), "pbvh");
@@ -1157,7 +1163,7 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode)
}
}
-static void pbvh_draw_BB(PBVH *bvh)
+void BKE_pbvh_draw_BB(PBVH *bvh)
{
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
@@ -1331,6 +1337,12 @@ void BKE_pbvh_get_grid_key(const PBVH *bvh, CCGKey *key)
*key = bvh->gridkey;
}
+CCGDerivedMesh *BKE_pbvh_get_ccgdm(const PBVH *bvh)
+{
+ return bvh->ccgdm;
+}
+
+
BMesh *BKE_pbvh_get_bmesh(PBVH *bvh)
{
BLI_assert(bvh->type == PBVH_BMESH);
@@ -1529,14 +1541,16 @@ void BKE_pbvh_raycast(
bool ray_face_intersection_quad(
const float ray_start[3], const float ray_normal[3],
const float t0[3], const float t1[3], const float t2[3], const float t3[3],
- float *dist)
+ float *depth)
{
- float dist_test;
+ float depth_test;
- if ((isect_ray_tri_epsilon_v3(ray_start, ray_normal, t0, t1, t2, &dist_test, NULL, 0.1f) && (dist_test < *dist)) ||
- (isect_ray_tri_epsilon_v3(ray_start, ray_normal, t0, t2, t3, &dist_test, NULL, 0.1f) && (dist_test < *dist)))
+ if ((isect_ray_tri_epsilon_v3(
+ ray_start, ray_normal, t0, t1, t2, &depth_test, NULL, 0.1f) && (depth_test < *depth)) ||
+ (isect_ray_tri_epsilon_v3(
+ ray_start, ray_normal, t0, t2, t3, &depth_test, NULL, 0.1f) && (depth_test < *depth)))
{
- *dist = dist_test;
+ *depth = depth_test;
return true;
}
else {
@@ -1547,12 +1561,82 @@ bool ray_face_intersection_quad(
bool ray_face_intersection_tri(
const float ray_start[3], const float ray_normal[3],
const float t0[3], const float t1[3], const float t2[3],
- float *dist)
+ float *depth)
+{
+ float depth_test;
+
+ if ((isect_ray_tri_epsilon_v3(
+ ray_start, ray_normal, t0, t1, t2, &depth_test, NULL, 0.1f) && (depth_test < *depth)))
+ {
+ *depth = depth_test;
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
+/* Take advantage of the fact we know this wont be an intersection.
+ * Just handle ray-tri edges. */
+static float dist_squared_ray_to_tri_v3_fast(
+ const float ray_origin[3], const float ray_direction[3],
+ const float v0[3], const float v1[3], const float v2[3],
+ float r_point[3], float *r_depth)
+{
+ const float *tri[3] = {v0, v1, v2};
+ float dist_sq_best = FLT_MAX;
+ for (int i = 0, j = 2; i < 3; j = i++) {
+ float point_test[3], depth_test = FLT_MAX;
+ const float dist_sq_test = dist_squared_ray_to_seg_v3(
+ ray_origin, ray_direction, tri[i], tri[j], point_test, &depth_test);
+ if (dist_sq_test < dist_sq_best || i == 0) {
+ copy_v3_v3(r_point, point_test);
+ *r_depth = depth_test;
+ dist_sq_best = dist_sq_test;
+ }
+ }
+ return dist_sq_best;
+}
+
+bool ray_face_nearest_quad(
+ const float ray_start[3], const float ray_normal[3],
+ const float t0[3], const float t1[3], const float t2[3], const float t3[3],
+ float *depth, float *dist_sq)
+{
+ float dist_sq_test;
+ float co[3], depth_test;
+
+ if (((dist_sq_test = dist_squared_ray_to_tri_v3_fast(
+ ray_start, ray_normal, t0, t1, t2, co, &depth_test)) < *dist_sq))
+ {
+ *dist_sq = dist_sq_test;
+ *depth = depth_test;
+ if (((dist_sq_test = dist_squared_ray_to_tri_v3_fast(
+ ray_start, ray_normal, t0, t2, t3, co, &depth_test)) < *dist_sq))
+ {
+ *dist_sq = dist_sq_test;
+ *depth = depth_test;
+ }
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
+bool ray_face_nearest_tri(
+ const float ray_start[3], const float ray_normal[3],
+ const float t0[3], const float t1[3], const float t2[3],
+ float *depth, float *dist_sq)
{
- float dist_test;
+ float dist_sq_test;
+ float co[3], depth_test;
- if ((isect_ray_tri_epsilon_v3(ray_start, ray_normal, t0, t1, t2, &dist_test, NULL, 0.1f) && (dist_test < *dist))) {
- *dist = dist_test;
+ if (((dist_sq_test = dist_squared_ray_to_tri_v3_fast(
+ ray_start, ray_normal, t0, t1, t2, co, &depth_test)) < *dist_sq))
+ {
+ *dist_sq = dist_sq_test;
+ *depth = depth_test;
return true;
}
else {
@@ -1564,7 +1648,7 @@ static bool pbvh_faces_node_raycast(
PBVH *bvh, const PBVHNode *node,
float (*origco)[3],
const float ray_start[3], const float ray_normal[3],
- float *dist)
+ float *depth)
{
const MVert *vert = bvh->verts;
const MLoop *mloop = bvh->mloop;
@@ -1586,7 +1670,7 @@ static bool pbvh_faces_node_raycast(
origco[face_verts[0]],
origco[face_verts[1]],
origco[face_verts[2]],
- dist);
+ depth);
}
else {
/* intersect with current coordinates */
@@ -1595,7 +1679,7 @@ static bool pbvh_faces_node_raycast(
vert[mloop[lt->tri[0]].v].co,
vert[mloop[lt->tri[1]].v].co,
vert[mloop[lt->tri[2]].v].co,
- dist);
+ depth);
}
}
@@ -1606,7 +1690,7 @@ static bool pbvh_grids_node_raycast(
PBVH *bvh, PBVHNode *node,
float (*origco)[3],
const float ray_start[3], const float ray_normal[3],
- float *dist)
+ float *depth)
{
const int totgrid = node->totprim;
const int gridsize = bvh->gridkey.grid_size;
@@ -1636,7 +1720,7 @@ static bool pbvh_grids_node_raycast(
origco[y * gridsize + x + 1],
origco[(y + 1) * gridsize + x + 1],
origco[(y + 1) * gridsize + x],
- dist);
+ depth);
}
else {
hit |= ray_face_intersection_quad(
@@ -1645,7 +1729,7 @@ static bool pbvh_grids_node_raycast(
CCG_grid_elem_co(&bvh->gridkey, grid, x + 1, y),
CCG_grid_elem_co(&bvh->gridkey, grid, x + 1, y + 1),
CCG_grid_elem_co(&bvh->gridkey, grid, x, y + 1),
- dist);
+ depth);
}
}
}
@@ -1660,7 +1744,7 @@ static bool pbvh_grids_node_raycast(
bool BKE_pbvh_node_raycast(
PBVH *bvh, PBVHNode *node, float (*origco)[3], bool use_origco,
const float ray_start[3], const float ray_normal[3],
- float *dist)
+ float *depth)
{
bool hit = false;
@@ -1671,16 +1755,16 @@ bool BKE_pbvh_node_raycast(
case PBVH_FACES:
hit |= pbvh_faces_node_raycast(
bvh, node, origco,
- ray_start, ray_normal, dist);
+ ray_start, ray_normal, depth);
break;
case PBVH_GRIDS:
hit |= pbvh_grids_node_raycast(
bvh, node, origco,
- ray_start, ray_normal, dist);
+ ray_start, ray_normal, depth);
break;
case PBVH_BMESH:
hit = pbvh_bmesh_node_raycast(
- node, ray_start, ray_normal, dist, use_origco);
+ node, ray_start, ray_normal, depth, use_origco);
break;
}
@@ -1731,6 +1815,176 @@ void BKE_pbvh_raycast_project_ray_root(
}
}
+/* -------------------------------------------------------------------- */
+
+typedef struct {
+ struct DistRayAABB_Precalc dist_ray_to_aabb_precalc;
+ bool original;
+} FindNearestRayData;
+
+static bool nearest_to_ray_aabb_dist_sq(PBVHNode *node, void *data_v)
+{
+ FindNearestRayData *rcd = data_v;
+ const float *bb_min, *bb_max;
+
+ if (rcd->original) {
+ /* BKE_pbvh_node_get_original_BB */
+ bb_min = node->orig_vb.bmin;
+ bb_max = node->orig_vb.bmax;
+ }
+ else {
+ /* BKE_pbvh_node_get_BB */
+ bb_min = node->vb.bmin;
+ bb_max = node->vb.bmax;
+ }
+
+ float co_dummy[3], depth;
+ node->tmin = dist_squared_ray_to_aabb_v3(&rcd->dist_ray_to_aabb_precalc, bb_min, bb_max, co_dummy, &depth);
+ /* Ideally we would skip distances outside the range. */
+ return depth > 0.0f;
+}
+
+void BKE_pbvh_find_nearest_to_ray(
+ PBVH *bvh, BKE_pbvh_SearchNearestCallback cb, void *data,
+ const float ray_start[3], const float ray_normal[3],
+ bool original)
+{
+ FindNearestRayData ncd;
+
+ dist_squared_ray_to_aabb_v3_precalc(&ncd.dist_ray_to_aabb_precalc, ray_start, ray_normal);
+ ncd.original = original;
+
+ BKE_pbvh_search_callback_occluded(bvh, nearest_to_ray_aabb_dist_sq, &ncd, cb, data);
+}
+
+
+static bool pbvh_faces_node_nearest_to_ray(
+ PBVH *bvh, const PBVHNode *node,
+ float (*origco)[3],
+ const float ray_start[3], const float ray_normal[3],
+ float *depth, float *dist_sq)
+{
+ const MVert *vert = bvh->verts;
+ const MLoop *mloop = bvh->mloop;
+ const int *faces = node->prim_indices;
+ int i, totface = node->totprim;
+ bool hit = false;
+
+ for (i = 0; i < totface; ++i) {
+ const MLoopTri *lt = &bvh->looptri[faces[i]];
+ const int *face_verts = node->face_vert_indices[i];
+
+ if (paint_is_face_hidden(lt, vert, mloop))
+ continue;
+
+ if (origco) {
+ /* intersect with backuped original coordinates */
+ hit |= ray_face_nearest_tri(
+ ray_start, ray_normal,
+ origco[face_verts[0]],
+ origco[face_verts[1]],
+ origco[face_verts[2]],
+ depth, dist_sq);
+ }
+ else {
+ /* intersect with current coordinates */
+ hit |= ray_face_nearest_tri(
+ ray_start, ray_normal,
+ vert[mloop[lt->tri[0]].v].co,
+ vert[mloop[lt->tri[1]].v].co,
+ vert[mloop[lt->tri[2]].v].co,
+ depth, dist_sq);
+ }
+ }
+
+ return hit;
+}
+
+static bool pbvh_grids_node_nearest_to_ray(
+ PBVH *bvh, PBVHNode *node,
+ float (*origco)[3],
+ const float ray_start[3], const float ray_normal[3],
+ float *depth, float *dist_sq)
+{
+ const int totgrid = node->totprim;
+ const int gridsize = bvh->gridkey.grid_size;
+ bool hit = false;
+
+ for (int i = 0; i < totgrid; ++i) {
+ CCGElem *grid = bvh->grids[node->prim_indices[i]];
+ BLI_bitmap *gh;
+
+ if (!grid)
+ continue;
+
+ gh = bvh->grid_hidden[node->prim_indices[i]];
+
+ for (int y = 0; y < gridsize - 1; ++y) {
+ for (int x = 0; x < gridsize - 1; ++x) {
+ /* check if grid face is hidden */
+ if (gh) {
+ if (paint_is_grid_face_hidden(gh, gridsize, x, y))
+ continue;
+ }
+
+ if (origco) {
+ hit |= ray_face_nearest_quad(
+ ray_start, ray_normal,
+ origco[y * gridsize + x],
+ origco[y * gridsize + x + 1],
+ origco[(y + 1) * gridsize + x + 1],
+ origco[(y + 1) * gridsize + x],
+ depth, dist_sq);
+ }
+ else {
+ hit |= ray_face_nearest_quad(
+ ray_start, ray_normal,
+ CCG_grid_elem_co(&bvh->gridkey, grid, x, y),
+ CCG_grid_elem_co(&bvh->gridkey, grid, x + 1, y),
+ CCG_grid_elem_co(&bvh->gridkey, grid, x + 1, y + 1),
+ CCG_grid_elem_co(&bvh->gridkey, grid, x, y + 1),
+ depth, dist_sq);
+ }
+ }
+ }
+
+ if (origco)
+ origco += gridsize * gridsize;
+ }
+
+ return hit;
+}
+
+bool BKE_pbvh_node_find_nearest_to_ray(
+ PBVH *bvh, PBVHNode *node, float (*origco)[3], bool use_origco,
+ const float ray_start[3], const float ray_normal[3],
+ float *depth, float *dist_sq)
+{
+ bool hit = false;
+
+ if (node->flag & PBVH_FullyHidden)
+ return false;
+
+ switch (bvh->type) {
+ case PBVH_FACES:
+ hit |= pbvh_faces_node_nearest_to_ray(
+ bvh, node, origco,
+ ray_start, ray_normal, depth, dist_sq);
+ break;
+ case PBVH_GRIDS:
+ hit |= pbvh_grids_node_nearest_to_ray(
+ bvh, node, origco,
+ ray_start, ray_normal, depth, dist_sq);
+ break;
+ case PBVH_BMESH:
+ hit = pbvh_bmesh_node_nearest_to_ray(
+ node, ray_start, ray_normal, depth, dist_sq, use_origco);
+ break;
+ }
+
+ return hit;
+}
+
typedef struct {
DMSetMaterial setMaterial;
bool wireframe;
@@ -1844,7 +2098,7 @@ void BKE_pbvh_draw(PBVH *bvh, float (*planes)[4], float (*fnors)[3],
}
if (G.debug_value == 14)
- pbvh_draw_BB(bvh);
+ BKE_pbvh_draw_BB(bvh);
}
struct PBVHNodeDrawCallbackData {
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index c5e49883dc6..187891e7210 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -718,20 +718,24 @@ static void pbvh_bmesh_node_drop_orig(PBVHNode *node)
/****************************** EdgeQueue *****************************/
-typedef struct {
+struct EdgeQueue;
+
+typedef struct EdgeQueue {
Heap *heap;
const float *center;
+ float center_proj[3]; /* for when we use projected coords. */
float radius_squared;
float limit_len_squared;
#ifdef USE_EDGEQUEUE_EVEN_SUBDIV
float limit_len;
#endif
-#ifdef USE_EDGEQUEUE_FRONTFACE
+ bool (*edge_queue_tri_in_range)(const struct EdgeQueue *q, BMFace *f);
+
const float *view_normal;
+#ifdef USE_EDGEQUEUE_FRONTFACE
unsigned int use_view_normal : 1;
#endif
-
} EdgeQueue;
typedef struct {
@@ -785,7 +789,6 @@ static bool edge_queue_tri_in_sphere(const EdgeQueue *q, BMFace *f)
float c[3];
/* Get closest point in triangle to sphere center */
- // BM_iter_as_array(NULL, BM_VERTS_OF_FACE, f, (void **)v_tri, 3);
BM_face_as_array_vert_tri(f, v_tri);
closest_on_tri_to_point_v3(c, q->center, v_tri[0]->co, v_tri[1]->co, v_tri[2]->co);
@@ -794,6 +797,25 @@ static bool edge_queue_tri_in_sphere(const EdgeQueue *q, BMFace *f)
return len_squared_v3v3(q->center, c) <= q->radius_squared;
}
+static bool edge_queue_tri_in_circle(const EdgeQueue *q, BMFace *f)
+{
+ BMVert *v_tri[3];
+ float c[3];
+ float tri_proj[3][3];
+
+ /* Get closest point in triangle to sphere center */
+ BM_face_as_array_vert_tri(f, v_tri);
+
+ project_plane_normalized_v3_v3v3(tri_proj[0], v_tri[0]->co, q->view_normal);
+ project_plane_normalized_v3_v3v3(tri_proj[1], v_tri[1]->co, q->view_normal);
+ project_plane_normalized_v3_v3v3(tri_proj[2], v_tri[2]->co, q->view_normal);
+
+ closest_on_tri_to_point_v3(c, q->center_proj, tri_proj[0], tri_proj[1], tri_proj[2]);
+
+ /* Check if triangle intersects the sphere */
+ return len_squared_v3v3(q->center_proj, c) <= q->radius_squared;
+}
+
/* Return true if the vertex mask is less than 1.0, false otherwise */
static bool check_mask(EdgeQueueContext *eq_ctx, BMVert *v)
{
@@ -929,7 +951,7 @@ static void long_edge_queue_face_add(
}
#endif
- if (edge_queue_tri_in_sphere(eq_ctx->q, f)) {
+ if (eq_ctx->q->edge_queue_tri_in_range(eq_ctx->q, f)) {
/* Check each edge of the face */
BMLoop *l_first = BM_FACE_FIRST_LOOP(f);
BMLoop *l_iter = l_first;
@@ -960,7 +982,7 @@ static void short_edge_queue_face_add(
}
#endif
- if (edge_queue_tri_in_sphere(eq_ctx->q, f)) {
+ if (eq_ctx->q->edge_queue_tri_in_range(eq_ctx->q, f)) {
BMLoop *l_iter;
BMLoop *l_first;
@@ -984,7 +1006,7 @@ static void short_edge_queue_face_add(
static void long_edge_queue_create(
EdgeQueueContext *eq_ctx,
PBVH *bvh, const float center[3], const float view_normal[3],
- float radius)
+ float radius, const bool use_frontface, const bool use_projected)
{
eq_ctx->q->heap = BLI_heap_new();
eq_ctx->q->center = center;
@@ -994,13 +1016,22 @@ static void long_edge_queue_create(
eq_ctx->q->limit_len = bvh->bm_max_edge_len;
#endif
-#ifdef USE_EDGEQUEUE_FRONTFACE
eq_ctx->q->view_normal = view_normal;
- eq_ctx->q->use_view_normal = (view_normal != NULL);
+
+#ifdef USE_EDGEQUEUE_FRONTFACE
+ eq_ctx->q->use_view_normal = use_frontface;
#else
- UNUSED_VARS(view_normal);
+ UNUSED_VARS(use_frontface);
#endif
+ if (use_projected) {
+ eq_ctx->q->edge_queue_tri_in_range = edge_queue_tri_in_circle;
+ project_plane_normalized_v3_v3v3(eq_ctx->q->center_proj, center, view_normal);
+ }
+ else {
+ eq_ctx->q->edge_queue_tri_in_range = edge_queue_tri_in_sphere;
+ }
+
#ifdef USE_EDGEQUEUE_TAG_VERIFY
pbvh_bmesh_edge_tag_verify(bvh);
#endif
@@ -1037,7 +1068,7 @@ static void long_edge_queue_create(
static void short_edge_queue_create(
EdgeQueueContext *eq_ctx,
PBVH *bvh, const float center[3], const float view_normal[3],
- float radius)
+ float radius, const bool use_frontface, const bool use_projected)
{
eq_ctx->q->heap = BLI_heap_new();
eq_ctx->q->center = center;
@@ -1047,13 +1078,22 @@ static void short_edge_queue_create(
eq_ctx->q->limit_len = bvh->bm_min_edge_len;
#endif
-#ifdef USE_EDGEQUEUE_FRONTFACE
eq_ctx->q->view_normal = view_normal;
- eq_ctx->q->use_view_normal = (view_normal != NULL);
+
+#ifdef USE_EDGEQUEUE_FRONTFACE
+ eq_ctx->q->use_view_normal = use_frontface;
#else
- UNUSED_VARS(view_normal);
+ UNUSED_VARS(use_frontface);
#endif
+ if (use_projected) {
+ eq_ctx->q->edge_queue_tri_in_range = edge_queue_tri_in_circle;
+ project_plane_normalized_v3_v3v3(eq_ctx->q->center_proj, center, view_normal);
+ }
+ else {
+ eq_ctx->q->edge_queue_tri_in_range = edge_queue_tri_in_sphere;
+ }
+
for (int n = 0; n < bvh->totnode; n++) {
PBVHNode *node = &bvh->nodes[n];
@@ -1466,7 +1506,7 @@ static bool pbvh_bmesh_collapse_short_edges(
bool pbvh_bmesh_node_raycast(
PBVHNode *node, const float ray_start[3],
- const float ray_normal[3], float *dist,
+ const float ray_normal[3], float *depth,
bool use_original)
{
bool hit = false;
@@ -1479,7 +1519,7 @@ bool pbvh_bmesh_node_raycast(
node->bm_orco[t[0]],
node->bm_orco[t[1]],
node->bm_orco[t[2]],
- dist);
+ depth);
}
}
else {
@@ -1498,7 +1538,7 @@ bool pbvh_bmesh_node_raycast(
v_tri[0]->co,
v_tri[1]->co,
v_tri[2]->co,
- dist);
+ depth);
}
}
}
@@ -1509,7 +1549,7 @@ bool pbvh_bmesh_node_raycast(
bool BKE_pbvh_bmesh_node_raycast_detail(
PBVHNode *node,
const float ray_start[3], const float ray_normal[3],
- float *dist, float *r_detail)
+ float *depth, float *r_detail)
{
if (node->flag & PBVH_FullyHidden)
return 0;
@@ -1531,7 +1571,7 @@ bool BKE_pbvh_bmesh_node_raycast_detail(
v_tri[0]->co,
v_tri[1]->co,
v_tri[2]->co,
- dist);
+ depth);
if (hit_local) {
f_hit = f;
@@ -1554,6 +1594,47 @@ bool BKE_pbvh_bmesh_node_raycast_detail(
return hit;
}
+bool pbvh_bmesh_node_nearest_to_ray(
+ PBVHNode *node, const float ray_start[3],
+ const float ray_normal[3], float *depth, float *dist_sq,
+ bool use_original)
+{
+ bool hit = false;
+
+ if (use_original && node->bm_tot_ortri) {
+ for (int i = 0; i < node->bm_tot_ortri; i++) {
+ const int *t = node->bm_ortri[i];
+ hit |= ray_face_nearest_tri(
+ ray_start, ray_normal,
+ node->bm_orco[t[0]],
+ node->bm_orco[t[1]],
+ node->bm_orco[t[2]],
+ depth, dist_sq);
+ }
+ }
+ else {
+ GSetIterator gs_iter;
+
+ GSET_ITER (gs_iter, node->bm_faces) {
+ BMFace *f = BLI_gsetIterator_getKey(&gs_iter);
+
+ BLI_assert(f->len == 3);
+ if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
+ BMVert *v_tri[3];
+
+ BM_face_as_array_vert_tri(f, v_tri);
+ hit |= ray_face_nearest_tri(
+ ray_start, ray_normal,
+ v_tri[0]->co,
+ v_tri[1]->co,
+ v_tri[2]->co,
+ depth, dist_sq);
+ }
+ }
+ }
+
+ return hit;
+}
void pbvh_bmesh_normals_update(PBVHNode **nodes, int totnode)
{
@@ -1854,7 +1935,7 @@ void BKE_pbvh_build_bmesh(
bool BKE_pbvh_bmesh_update_topology(
PBVH *bvh, PBVHTopologyUpdateMode mode,
const float center[3], const float view_normal[3],
- float radius)
+ float radius, const bool use_frontface, const bool use_projected)
{
/* 2 is enough for edge faces - manifold edge */
BLI_buffer_declare_static(BMLoop *, edge_loops, BLI_BUFFER_NOP, 2);
@@ -1877,7 +1958,7 @@ bool BKE_pbvh_bmesh_update_topology(
cd_vert_mask_offset, cd_vert_node_offset, cd_face_node_offset,
};
- short_edge_queue_create(&eq_ctx, bvh, center, view_normal, radius);
+ short_edge_queue_create(&eq_ctx, bvh, center, view_normal, radius, use_frontface, use_projected);
modified |= pbvh_bmesh_collapse_short_edges(
&eq_ctx, bvh, &deleted_faces);
BLI_heap_free(q.heap, NULL);
@@ -1892,7 +1973,7 @@ bool BKE_pbvh_bmesh_update_topology(
cd_vert_mask_offset, cd_vert_node_offset, cd_face_node_offset,
};
- long_edge_queue_create(&eq_ctx, bvh, center, view_normal, radius);
+ long_edge_queue_create(&eq_ctx, bvh, center, view_normal, radius, use_frontface, use_projected);
modified |= pbvh_bmesh_subdivide_long_edges(
&eq_ctx, bvh, &edge_loops);
BLI_heap_free(q.heap, NULL);
diff --git a/source/blender/blenkernel/intern/pbvh_intern.h b/source/blender/blenkernel/intern/pbvh_intern.h
index 19d3b31bd31..e05a3068682 100644
--- a/source/blender/blenkernel/intern/pbvh_intern.h
+++ b/source/blender/blenkernel/intern/pbvh_intern.h
@@ -149,6 +149,8 @@ struct PBVH {
* objects in sculpt mode with different sizes at the same time, so now storing that common gpu buffer
* in an opaque pointer per pbvh. See T47637. */
struct GridCommonGPUBuffer *grid_common_gpu_buffer;
+ /* The ccgdm is required for CD_ORIGINDEX lookup in vertex paint + multires */
+ struct CCGDerivedMesh *ccgdm;
/* Only used during BVH build and update,
* don't need to remain valid after */
@@ -183,11 +185,21 @@ void pbvh_grow_nodes(PBVH *bvh, int totnode);
bool ray_face_intersection_quad(
const float ray_start[3], const float ray_normal[3],
const float *t0, const float *t1, const float *t2, const float *t3,
- float *r_dist);
+ float *depth);
bool ray_face_intersection_tri(
const float ray_start[3], const float ray_normal[3],
const float *t0, const float *t1, const float *t2,
- float *r_dist);
+ float *depth);
+
+bool ray_face_nearest_quad(
+ const float ray_start[3], const float ray_normal[3],
+ const float *t0, const float *t1, const float *t2, const float *t3,
+ float *r_depth, float *r_dist_sq);
+bool ray_face_nearest_tri(
+ const float ray_start[3], const float ray_normal[3],
+ const float *t0, const float *t1, const float *t2,
+ float *r_depth, float *r_dist_sq);
+
void pbvh_update_BB_redraw(PBVH *bvh, PBVHNode **nodes, int totnode, int flag);
/* pbvh_bmesh.c */
@@ -195,6 +207,10 @@ bool pbvh_bmesh_node_raycast(
PBVHNode *node, const float ray_start[3],
const float ray_normal[3], float *dist,
bool use_original);
+bool pbvh_bmesh_node_nearest_to_ray(
+ PBVHNode *node, const float ray_start[3],
+ const float ray_normal[3], float *depth, float *dist_sq,
+ bool use_original);
void pbvh_bmesh_normals_update(PBVHNode **nodes, int totnode);
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 0b152534dcb..5ec3156f4df 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -3449,7 +3449,7 @@ void BKE_ptcache_free_list(ListBase *ptcaches)
}
}
-static PointCache *ptcache_copy(PointCache *cache, bool copy_data)
+static PointCache *ptcache_copy(PointCache *cache, const bool copy_data)
{
PointCache *ncache;
@@ -3492,14 +3492,15 @@ static PointCache *ptcache_copy(PointCache *cache, bool copy_data)
}
/* returns first point cache */
-PointCache *BKE_ptcache_copy_list(ListBase *ptcaches_new, const ListBase *ptcaches_old, bool copy_data)
+PointCache *BKE_ptcache_copy_list(ListBase *ptcaches_new, const ListBase *ptcaches_old, const int flag)
{
PointCache *cache = ptcaches_old->first;
BLI_listbase_clear(ptcaches_new);
- for (; cache; cache=cache->next)
- BLI_addtail(ptcaches_new, ptcache_copy(cache, copy_data));
+ for (; cache; cache=cache->next) {
+ BLI_addtail(ptcaches_new, ptcache_copy(cache, (flag & LIB_ID_COPY_CACHES) != 0));
+ }
return ptcaches_new->first;
}
@@ -3618,7 +3619,13 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
psys_get_pointcache_start_end(scene, pid->calldata, &cache->startframe, &cache->endframe);
}
- if (((cache->flag & PTCACHE_BAKED) == 0) && (render || bake)) {
+ // XXX workaround for regression inroduced in ee3fadd, needs looking into
+ if (pid->type == PTCACHE_TYPE_RIGIDBODY) {
+ if ((cache->flag & PTCACHE_REDO_NEEDED || (cache->flag & PTCACHE_SIMULATION_VALID)==0) && (render || bake)) {
+ BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
+ }
+ }
+ else if (((cache->flag & PTCACHE_BAKED) == 0) && (render || bake)) {
BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
}
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 6056515af9a..f75b14579c7 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -183,7 +183,7 @@ void BKE_rigidbody_free_constraint(Object *ob)
* be added to relevant groups later...
*/
-RigidBodyOb *BKE_rigidbody_copy_object(const Object *ob)
+RigidBodyOb *BKE_rigidbody_copy_object(const Object *ob, const int UNUSED(flag))
{
RigidBodyOb *rboN = NULL;
@@ -203,7 +203,7 @@ RigidBodyOb *BKE_rigidbody_copy_object(const Object *ob)
return rboN;
}
-RigidBodyCon *BKE_rigidbody_copy_constraint(const Object *ob)
+RigidBodyCon *BKE_rigidbody_copy_constraint(const Object *ob, const int UNUSED(flag))
{
RigidBodyCon *rbcN = NULL;
@@ -290,8 +290,6 @@ static rbCollisionShape *rigidbody_get_shape_trimesh_from_mesh(Object *ob)
if (dm == NULL)
return NULL;
- DM_ensure_looptri(dm);
-
mvert = dm->getVertArray(dm);
totvert = dm->getNumVerts(dm);
looptri = dm->getLoopTriArray(dm);
@@ -523,8 +521,6 @@ void BKE_rigidbody_calc_volume(Object *ob, float *r_vol)
if (dm == NULL)
return;
- DM_ensure_looptri(dm);
-
mvert = dm->getVertArray(dm);
totvert = dm->getNumVerts(dm);
lt = dm->getLoopTriArray(dm);
@@ -608,8 +604,6 @@ void BKE_rigidbody_calc_center_of_mass(Object *ob, float r_center[3])
if (dm == NULL)
return;
- DM_ensure_looptri(dm);
-
mvert = dm->getVertArray(dm);
totvert = dm->getNumVerts(dm);
looptri = dm->getLoopTriArray(dm);
@@ -944,24 +938,26 @@ RigidBodyWorld *BKE_rigidbody_create_world(Scene *scene)
return rbw;
}
-RigidBodyWorld *BKE_rigidbody_world_copy(RigidBodyWorld *rbw)
+RigidBodyWorld *BKE_rigidbody_world_copy(RigidBodyWorld *rbw, const int flag)
{
- RigidBodyWorld *rbwn = MEM_dupallocN(rbw);
+ RigidBodyWorld *rbw_copy = MEM_dupallocN(rbw);
- if (rbw->effector_weights)
- rbwn->effector_weights = MEM_dupallocN(rbw->effector_weights);
- if (rbwn->group)
- id_us_plus(&rbwn->group->id);
- if (rbwn->constraints)
- id_us_plus(&rbwn->constraints->id);
+ if (rbw->effector_weights) {
+ rbw_copy->effector_weights = MEM_dupallocN(rbw->effector_weights);
+ }
+ if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
+ id_us_plus((ID *)rbw_copy->group);
+ id_us_plus((ID *)rbw_copy->constraints);
+ }
- rbwn->pointcache = BKE_ptcache_copy_list(&rbwn->ptcaches, &rbw->ptcaches, false);
+ /* XXX Never copy caches here? */
+ rbw_copy->pointcache = BKE_ptcache_copy_list(&rbw_copy->ptcaches, &rbw->ptcaches, flag & ~LIB_ID_COPY_CACHES);
- rbwn->objects = NULL;
- rbwn->physics_world = NULL;
- rbwn->numbodies = 0;
+ rbw_copy->objects = NULL;
+ rbw_copy->physics_world = NULL;
+ rbw_copy->numbodies = 0;
- return rbwn;
+ return rbw_copy;
}
void BKE_rigidbody_world_groups_relink(RigidBodyWorld *rbw)
@@ -1226,7 +1222,7 @@ static void rigidbody_update_sim_world(Scene *scene, RigidBodyWorld *rbw)
rigidbody_update_ob_array(rbw);
}
-static void rigidbody_update_sim_ob(Scene *scene, RigidBodyWorld *rbw, Object *ob, RigidBodyOb *rbo)
+static void rigidbody_update_sim_ob(const struct EvaluationContext *eval_ctx, Scene *scene, RigidBodyWorld *rbw, Object *ob, RigidBodyOb *rbo)
{
float loc[3];
float rot[4];
@@ -1274,7 +1270,7 @@ static void rigidbody_update_sim_ob(Scene *scene, RigidBodyWorld *rbw, Object *o
ListBase *effectors;
/* get effectors present in the group specified by effector_weights */
- effectors = pdInitEffectors(scene, ob, NULL, effector_weights, true);
+ effectors = pdInitEffectors(eval_ctx, scene, ob, NULL, effector_weights, true);
if (effectors) {
float eff_force[3] = {0.0f, 0.0f, 0.0f};
float eff_loc[3], eff_vel[3];
@@ -1315,7 +1311,7 @@ static void rigidbody_update_sim_ob(Scene *scene, RigidBodyWorld *rbw, Object *o
*
* \param rebuild Rebuild entire simulation
*/
-static void rigidbody_update_simulation(Scene *scene, RigidBodyWorld *rbw, bool rebuild)
+static void rigidbody_update_simulation(const struct EvaluationContext *eval_ctx, Scene *scene, RigidBodyWorld *rbw, bool rebuild)
{
GroupObject *go;
@@ -1352,7 +1348,7 @@ static void rigidbody_update_simulation(Scene *scene, RigidBodyWorld *rbw, bool
/* validate that we've got valid object set up here... */
RigidBodyOb *rbo = ob->rigidbody_object;
/* update transformation matrix of the object so we don't get a frame of lag for simple animations */
- BKE_object_where_is_calc(scene, ob);
+ BKE_object_where_is_calc(eval_ctx, scene, ob);
if (rbo == NULL) {
/* Since this object is included in the sim group but doesn't have
@@ -1386,7 +1382,7 @@ static void rigidbody_update_simulation(Scene *scene, RigidBodyWorld *rbw, bool
}
/* update simulation object... */
- rigidbody_update_sim_ob(scene, rbw, ob, rbo);
+ rigidbody_update_sim_ob(eval_ctx, scene, rbw, ob, rbo);
}
}
@@ -1400,7 +1396,7 @@ static void rigidbody_update_simulation(Scene *scene, RigidBodyWorld *rbw, bool
/* validate that we've got valid object set up here... */
RigidBodyCon *rbc = ob->rigidbody_constraint;
/* update transformation matrix of the object so we don't get a frame of lag for simple animations */
- BKE_object_where_is_calc(scene, ob);
+ BKE_object_where_is_calc(eval_ctx, scene, ob);
if (rbc == NULL) {
/* Since this object is included in the group but doesn't have
@@ -1485,24 +1481,60 @@ void BKE_rigidbody_sync_transforms(RigidBodyWorld *rbw, Object *ob, float ctime)
void BKE_rigidbody_aftertrans_update(Object *ob, float loc[3], float rot[3], float quat[4], float rotAxis[3], float rotAngle)
{
RigidBodyOb *rbo = ob->rigidbody_object;
+ bool correct_delta = !(rbo->flag & RBO_FLAG_KINEMATIC || rbo->type == RBO_TYPE_PASSIVE);
/* return rigid body and object to their initial states */
copy_v3_v3(rbo->pos, ob->loc);
copy_v3_v3(ob->loc, loc);
+ if (correct_delta) {
+ add_v3_v3(rbo->pos, ob->dloc);
+ }
+
if (ob->rotmode > 0) {
- eulO_to_quat(rbo->orn, ob->rot, ob->rotmode);
+ float qt[4];
+ eulO_to_quat(qt, ob->rot, ob->rotmode);
+
+ if (correct_delta) {
+ float dquat[4];
+ eulO_to_quat(dquat, ob->drot, ob->rotmode);
+
+ mul_qt_qtqt(rbo->orn, dquat, qt);
+ }
+ else {
+ copy_qt_qt(rbo->orn, qt);
+ }
+
copy_v3_v3(ob->rot, rot);
}
else if (ob->rotmode == ROT_MODE_AXISANGLE) {
- axis_angle_to_quat(rbo->orn, ob->rotAxis, ob->rotAngle);
+ float qt[4];
+ axis_angle_to_quat(qt, ob->rotAxis, ob->rotAngle);
+
+ if (correct_delta) {
+ float dquat[4];
+ axis_angle_to_quat(dquat, ob->drotAxis, ob->drotAngle);
+
+ mul_qt_qtqt(rbo->orn, dquat, qt);
+ }
+ else {
+ copy_qt_qt(rbo->orn, qt);
+ }
+
copy_v3_v3(ob->rotAxis, rotAxis);
ob->rotAngle = rotAngle;
}
else {
- copy_qt_qt(rbo->orn, ob->quat);
+ if (correct_delta) {
+ mul_qt_qtqt(rbo->orn, ob->dquat, ob->quat);
+ }
+ else {
+ copy_qt_qt(rbo->orn, ob->quat);
+ }
+
copy_qt_qt(ob->quat, quat);
}
+
if (rbo->physics_object) {
/* allow passive objects to return to original transform */
if (rbo->type == RBO_TYPE_PASSIVE)
@@ -1514,15 +1546,16 @@ void BKE_rigidbody_aftertrans_update(Object *ob, float loc[3], float rot[3], flo
void BKE_rigidbody_cache_reset(RigidBodyWorld *rbw)
{
- if (rbw)
+ if (rbw) {
rbw->pointcache->flag |= PTCACHE_OUTDATED;
+ }
}
/* ------------------ */
/* Rebuild rigid body world */
/* NOTE: this needs to be called before frame update to work correctly */
-void BKE_rigidbody_rebuild_world(Scene *scene, float ctime)
+void BKE_rigidbody_rebuild_world(const struct EvaluationContext *eval_ctx, Scene *scene, float ctime)
{
RigidBodyWorld *rbw = scene->rigidbody_world;
PointCache *cache;
@@ -1541,7 +1574,7 @@ void BKE_rigidbody_rebuild_world(Scene *scene, float ctime)
if (ctime == startframe + 1 && rbw->ltime == startframe) {
if (cache->flag & PTCACHE_OUTDATED) {
BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
- rigidbody_update_simulation(scene, rbw, true);
+ rigidbody_update_simulation(eval_ctx, scene, rbw, true);
BKE_ptcache_validate(cache, (int)ctime);
cache->last_exact = 0;
cache->flag &= ~PTCACHE_REDO_NEEDED;
@@ -1550,7 +1583,7 @@ void BKE_rigidbody_rebuild_world(Scene *scene, float ctime)
}
/* Run RigidBody simulation for the specified physics world */
-void BKE_rigidbody_do_simulation(Scene *scene, float ctime)
+void BKE_rigidbody_do_simulation(const struct EvaluationContext *eval_ctx, Scene *scene, float ctime)
{
float timestep;
RigidBodyWorld *rbw = scene->rigidbody_world;
@@ -1581,7 +1614,7 @@ void BKE_rigidbody_do_simulation(Scene *scene, float ctime)
// RB_TODO deal with interpolated, old and baked results
bool can_simulate = (ctime == rbw->ltime + 1) && !(cache->flag & PTCACHE_BAKED);
- if (BKE_ptcache_read(&pid, ctime, can_simulate)) {
+ if (BKE_ptcache_read(&pid, ctime, can_simulate) == PTCACHE_READ_EXACT) {
BKE_ptcache_validate(cache, (int)ctime);
rbw->ltime = ctime;
return;
@@ -1595,7 +1628,7 @@ void BKE_rigidbody_do_simulation(Scene *scene, float ctime)
}
/* update and validate simulation */
- rigidbody_update_simulation(scene, rbw, false);
+ rigidbody_update_simulation(eval_ctx, scene, rbw, false);
/* calculate how much time elapsed since last step in seconds */
timestep = 1.0f / (float)FPS * (ctime - rbw->ltime) * rbw->time_scale;
@@ -1621,13 +1654,13 @@ void BKE_rigidbody_do_simulation(Scene *scene, float ctime)
# pragma GCC diagnostic ignored "-Wunused-parameter"
#endif
-struct RigidBodyOb *BKE_rigidbody_copy_object(const Object *ob) { return NULL; }
-struct RigidBodyCon *BKE_rigidbody_copy_constraint(const Object *ob) { return NULL; }
+struct RigidBodyOb *BKE_rigidbody_copy_object(const Object *ob, const int flag) { return NULL; }
+struct RigidBodyCon *BKE_rigidbody_copy_constraint(const Object *ob, const int flag) { return NULL; }
void BKE_rigidbody_validate_sim_world(Scene *scene, RigidBodyWorld *rbw, bool rebuild) {}
void BKE_rigidbody_calc_volume(Object *ob, float *r_vol) { if (r_vol) *r_vol = 0.0f; }
void BKE_rigidbody_calc_center_of_mass(Object *ob, float r_center[3]) { zero_v3(r_center); }
struct RigidBodyWorld *BKE_rigidbody_create_world(Scene *scene) { return NULL; }
-struct RigidBodyWorld *BKE_rigidbody_world_copy(RigidBodyWorld *rbw) { return NULL; }
+struct RigidBodyWorld *BKE_rigidbody_world_copy(RigidBodyWorld *rbw, const int flag) { return NULL; }
void BKE_rigidbody_world_groups_relink(struct RigidBodyWorld *rbw) {}
void BKE_rigidbody_world_id_loop(struct RigidBodyWorld *rbw, RigidbodyWorldIDFunc func, void *userdata) {}
struct RigidBodyOb *BKE_rigidbody_create_object(Scene *scene, Object *ob, short type) { return NULL; }
@@ -1639,8 +1672,8 @@ void BKE_rigidbody_sync_transforms(RigidBodyWorld *rbw, Object *ob, float ctime)
void BKE_rigidbody_aftertrans_update(Object *ob, float loc[3], float rot[3], float quat[4], float rotAxis[3], float rotAngle) {}
bool BKE_rigidbody_check_sim_running(RigidBodyWorld *rbw, float ctime) { return false; }
void BKE_rigidbody_cache_reset(RigidBodyWorld *rbw) {}
-void BKE_rigidbody_rebuild_world(Scene *scene, float ctime) {}
-void BKE_rigidbody_do_simulation(Scene *scene, float ctime) {}
+void BKE_rigidbody_rebuild_world(const struct EvaluationContext *eval_ctx, Scene *scene, float ctime) {}
+void BKE_rigidbody_do_simulation(const struct EvaluationContext *eval_ctx, Scene *scene, float ctime) {}
#ifdef __GNUC__
# pragma GCC diagnostic pop
@@ -1651,7 +1684,7 @@ void BKE_rigidbody_do_simulation(Scene *scene, float ctime) {}
/* -------------------- */
/* Depsgraph evaluation */
-void BKE_rigidbody_rebuild_sim(struct EvaluationContext *UNUSED(eval_ctx),
+void BKE_rigidbody_rebuild_sim(const struct EvaluationContext *eval_ctx,
Scene *scene)
{
float ctime = BKE_scene_frame_get(scene);
@@ -1662,11 +1695,11 @@ void BKE_rigidbody_rebuild_sim(struct EvaluationContext *UNUSED(eval_ctx),
/* rebuild sim data (i.e. after resetting to start of timeline) */
if (BKE_scene_check_rigidbody_active(scene)) {
- BKE_rigidbody_rebuild_world(scene, ctime);
+ BKE_rigidbody_rebuild_world(eval_ctx, scene, ctime);
}
}
-void BKE_rigidbody_eval_simulation(struct EvaluationContext *UNUSED(eval_ctx),
+void BKE_rigidbody_eval_simulation(const struct EvaluationContext *eval_ctx,
Scene *scene)
{
float ctime = BKE_scene_frame_get(scene);
@@ -1677,11 +1710,11 @@ void BKE_rigidbody_eval_simulation(struct EvaluationContext *UNUSED(eval_ctx),
/* evaluate rigidbody sim */
if (BKE_scene_check_rigidbody_active(scene)) {
- BKE_rigidbody_do_simulation(scene, ctime);
+ BKE_rigidbody_do_simulation(eval_ctx, scene, ctime);
}
}
-void BKE_rigidbody_object_sync_transforms(struct EvaluationContext *UNUSED(eval_ctx),
+void BKE_rigidbody_object_sync_transforms(const struct EvaluationContext *UNUSED(eval_ctx),
Scene *scene,
Object *ob)
{
diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c
index 19d646daf9f..fb81ed4d47f 100644
--- a/source/blender/blenkernel/intern/sca.c
+++ b/source/blender/blenkernel/intern/sca.c
@@ -72,7 +72,7 @@ void free_sensors(ListBase *lb)
}
}
-bSensor *copy_sensor(bSensor *sens)
+bSensor *copy_sensor(bSensor *sens, const int UNUSED(flag))
{
bSensor *sensn;
@@ -87,14 +87,14 @@ bSensor *copy_sensor(bSensor *sens)
return sensn;
}
-void copy_sensors(ListBase *lbn, const ListBase *lbo)
+void copy_sensors(ListBase *lbn, const ListBase *lbo, const int flag)
{
bSensor *sens, *sensn;
lbn->first= lbn->last= NULL;
sens= lbo->first;
while (sens) {
- sensn= copy_sensor(sens);
+ sensn= copy_sensor(sens, flag);
BLI_addtail(lbn, sensn);
sens= sens->next;
}
@@ -234,7 +234,7 @@ void free_controllers(ListBase *lb)
}
}
-bController *copy_controller(bController *cont)
+bController *copy_controller(bController *cont, const int UNUSED(flag))
{
bController *contn;
@@ -251,14 +251,14 @@ bController *copy_controller(bController *cont)
return contn;
}
-void copy_controllers(ListBase *lbn, const ListBase *lbo)
+void copy_controllers(ListBase *lbn, const ListBase *lbo, const int flag)
{
bController *cont, *contn;
lbn->first= lbn->last= NULL;
cont= lbo->first;
while (cont) {
- contn= copy_controller(cont);
+ contn= copy_controller(cont, flag);
BLI_addtail(lbn, contn);
cont= cont->next;
}
@@ -359,7 +359,7 @@ void free_actuators(ListBase *lb)
}
}
-bActuator *copy_actuator(bActuator *act)
+bActuator *copy_actuator(bActuator *act, const int flag)
{
bActuator *actn;
@@ -374,29 +374,31 @@ bActuator *copy_actuator(bActuator *act)
case ACT_SHAPEACTION:
{
bActionActuator *aa = (bActionActuator *)act->data;
- if (aa->act)
+ if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
id_us_plus((ID *)aa->act);
+ }
break;
}
case ACT_SOUND:
{
bSoundActuator *sa = (bSoundActuator *)act->data;
- if (sa->sound)
+ if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
id_us_plus((ID *)sa->sound);
+ }
break;
}
}
return actn;
}
-void copy_actuators(ListBase *lbn, const ListBase *lbo)
+void copy_actuators(ListBase *lbn, const ListBase *lbo, const int flag)
{
bActuator *act, *actn;
lbn->first= lbn->last= NULL;
act= lbo->first;
while (act) {
- actn= copy_actuator(act);
+ actn= copy_actuator(act, flag);
BLI_addtail(lbn, actn);
act= act->next;
}
@@ -783,11 +785,11 @@ void BKE_sca_logic_links_remap(Main *bmain, Object *ob_old, Object *ob_new)
* Handle the copying of logic data into a new object, including internal logic links update.
* External links (links between logic bricks of different objects) must be handled separately.
*/
-void BKE_sca_logic_copy(Object *ob_new, const Object *ob)
+void BKE_sca_logic_copy(Object *ob_new, const Object *ob, const int flag)
{
- copy_sensors(&ob_new->sensors, &ob->sensors);
- copy_controllers(&ob_new->controllers, &ob->controllers);
- copy_actuators(&ob_new->actuators, &ob->actuators);
+ copy_sensors(&ob_new->sensors, &ob->sensors, flag);
+ copy_controllers(&ob_new->controllers, &ob->controllers, flag);
+ copy_actuators(&ob_new->actuators, &ob->actuators, flag);
for (bSensor *sens = ob_new->sensors.first; sens; sens = sens->next) {
if (sens->flag & SENS_NEW) {
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index f54a02f033a..d36f128cef1 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -131,17 +131,6 @@ void free_avicodecdata(AviCodecData *acd)
}
}
-void free_qtcodecdata(QuicktimeCodecData *qcd)
-{
- if (qcd) {
- if (qcd->cdParms) {
- MEM_freeN(qcd->cdParms);
- qcd->cdParms = NULL;
- qcd->cdSize = 0;
- }
- }
-}
-
static void remove_sequencer_fcurves(Scene *sce)
{
AnimData *adt = BKE_animdata_from_id(&sce->id);
@@ -161,314 +150,415 @@ static void remove_sequencer_fcurves(Scene *sce)
}
/* copy SceneCollection tree but keep pointing to the same objects */
-static void scene_collection_copy(SceneCollection *scn, SceneCollection *sc)
+static void scene_collection_copy(SceneCollection *sc_dst, SceneCollection *sc_src, const int flag)
{
- BLI_duplicatelist(&scn->objects, &sc->objects);
- for (LinkData *link = scn->objects.first; link; link = link->next) {
- id_us_plus(link->data);
+ BLI_duplicatelist(&sc_dst->objects, &sc_src->objects);
+ if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
+ for (LinkData *link = sc_dst->objects.first; link; link = link->next) {
+ id_us_plus(link->data);
+ }
}
- BLI_duplicatelist(&scn->filter_objects, &sc->filter_objects);
- for (LinkData *link = scn->filter_objects.first; link; link = link->next) {
- id_us_plus(link->data);
+ BLI_duplicatelist(&sc_dst->filter_objects, &sc_src->filter_objects);
+ if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
+ for (LinkData *link = sc_dst->filter_objects.first; link; link = link->next) {
+ id_us_plus(link->data);
+ }
}
- BLI_duplicatelist(&scn->scene_collections, &sc->scene_collections);
- SceneCollection *nscn = scn->scene_collections.first; /* nested SceneCollection new */
- for (SceneCollection *nsc = sc->scene_collections.first; nsc; nsc = nsc->next) {
- scene_collection_copy(nscn, nsc);
- nscn = nscn->next;
+ BLI_duplicatelist(&sc_dst->scene_collections, &sc_src->scene_collections);
+ for (SceneCollection *nsc_src = sc_src->scene_collections.first, *nsc_dst = sc_dst->scene_collections.first;
+ nsc_src;
+ nsc_src = nsc_src->next, nsc_dst = nsc_dst->next)
+ {
+ scene_collection_copy(nsc_dst, nsc_src, flag);
}
}
/* Find the equivalent SceneCollection in the new tree */
-static SceneCollection *scene_collection_from_new_tree(SceneCollection *sc_reference, SceneCollection *scn, SceneCollection *sc)
+static SceneCollection *scene_collection_from_new_tree(SceneCollection *sc_reference, SceneCollection *sc_dst, SceneCollection *sc_src)
{
- if (sc == sc_reference) {
- return scn;
+ if (sc_src == sc_reference) {
+ return sc_dst;
}
- SceneCollection *nscn = scn->scene_collections.first; /* nested master collection new */
- for (SceneCollection *nsc = sc->scene_collections.first; nsc; nsc = nsc->next) {
-
- SceneCollection *found = scene_collection_from_new_tree(sc_reference, nscn, nsc);
- if (found) {
+ for (SceneCollection *nsc_src = sc_src->scene_collections.first, *nsc_dst = sc_dst->scene_collections.first;
+ nsc_src;
+ nsc_src = nsc_src->next, nsc_dst = nsc_dst->next)
+ {
+ SceneCollection *found = scene_collection_from_new_tree(sc_reference, nsc_dst, nsc_src);
+ if (found != NULL) {
return found;
}
- nscn = nscn->next;
}
return NULL;
}
-/* recreate the LayerCollection tree */
-static void layer_collections_recreate(SceneLayer *sl, ListBase *lb, SceneCollection *mcn, SceneCollection *mc)
+static void layer_collections_sync_flags(ListBase *layer_collections_dst, const ListBase *layer_collections_src)
{
- for (LayerCollection *lc = lb->first; lc; lc = lc->next) {
+ LayerCollection *layer_collection_dst = (LayerCollection *)layer_collections_dst->first;
+ const LayerCollection *layer_collection_src = (const LayerCollection *)layer_collections_src->first;
+ while (layer_collection_dst != NULL) {
+ layer_collection_dst->flag = layer_collection_src->flag;
+ layer_collections_sync_flags(&layer_collection_dst->layer_collections,
+ &layer_collection_src->layer_collections);
+ /* TODO(sergey/dfelinto): Overrides. */
+ layer_collection_dst = layer_collection_dst->next;
+ layer_collection_src = layer_collection_src->next;
+ }
+}
- SceneCollection *sc = scene_collection_from_new_tree(lc->scene_collection, mcn, mc);
- BLI_assert(sc);
- /* instead of syncronizing both trees we simply re-create it */
- BKE_collection_link(sl, sc);
+/* recreate the LayerCollection tree */
+static void layer_collections_recreate(
+ SceneLayer *sl_dst, ListBase *lb_src, SceneCollection *mc_dst, SceneCollection *mc_src)
+{
+ for (LayerCollection *lc_src = lb_src->first; lc_src; lc_src = lc_src->next) {
+ SceneCollection *sc_dst = scene_collection_from_new_tree(lc_src->scene_collection, mc_dst, mc_src);
+ BLI_assert(sc_dst);
+
+ /* instead of synchronizing both trees we simply re-create it */
+ BKE_collection_link(sl_dst, sc_dst);
}
}
-Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type)
+/**
+ * Only copy internal data of Scene ID from source to already allocated/initialized destination.
+ * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
+ *
+ * WARNING! This function will not handle ID user count!
+ *
+ * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
+ */
+void BKE_scene_copy_data(Main *bmain, Scene *sce_dst, const Scene *sce_src, const int flag)
{
- Scene *scen;
- SceneRenderLayer *srl, *new_srl;
- FreestyleLineSet *lineset;
- ToolSettings *ts;
- BaseLegacy *legacy_base, *olegacy_base;
-
- if (type == SCE_COPY_EMPTY) {
- ListBase rl, rv;
- scen = BKE_scene_add(bmain, sce->id.name + 2);
-
- rl = scen->r.layers;
- rv = scen->r.views;
- curvemapping_free_data(&scen->r.mblur_shutter_curve);
- scen->r = sce->r;
- scen->r.layers = rl;
- scen->r.actlay = 0;
- scen->r.views = rv;
- scen->unit = sce->unit;
- scen->physics_settings = sce->physics_settings;
- scen->gm = sce->gm;
- scen->audio = sce->audio;
+ /* We never handle usercount here for own data. */
+ const int flag_subdata = flag | LIB_ID_CREATE_NO_USER_REFCOUNT;
- if (sce->id.properties)
- scen->id.properties = IDP_CopyProperty(sce->id.properties);
+ sce_dst->ed = NULL;
+ sce_dst->theDag = NULL;
+ sce_dst->depsgraph_legacy = NULL;
+ sce_dst->obedit = NULL;
+ sce_dst->fps_info = NULL;
- MEM_freeN(scen->toolsettings);
- BKE_sound_destroy_scene(scen);
+ BLI_duplicatelist(&(sce_dst->base), &(sce_src->base));
+ for (BaseLegacy *base_dst = sce_dst->base.first, *base_src = sce_src->base.first;
+ base_dst;
+ base_dst = base_dst->next, base_src = base_src->next)
+ {
+ if (base_src == sce_src->basact) {
+ sce_dst->basact = base_dst;
+ }
}
- else {
- scen = BKE_libblock_copy(bmain, &sce->id);
- BLI_duplicatelist(&(scen->base), &(sce->base));
-
- id_us_plus((ID *)scen->world);
- id_us_plus((ID *)scen->set);
- /* id_us_plus((ID *)scen->gm.dome.warptext); */ /* XXX Not refcounted? see readfile.c */
- scen->ed = NULL;
- scen->theDag = NULL;
- scen->depsgraph = NULL;
- scen->obedit = NULL;
- scen->fps_info = NULL;
+ /* layers and collections */
+ sce_dst->collection = MEM_dupallocN(sce_src->collection);
+ SceneCollection *mc_src = BKE_collection_master(sce_src);
+ SceneCollection *mc_dst = BKE_collection_master(sce_dst);
- if (sce->rigidbody_world)
- scen->rigidbody_world = BKE_rigidbody_world_copy(sce->rigidbody_world);
+ /* recursively creates a new SceneCollection tree */
+ scene_collection_copy(mc_dst, mc_src, flag_subdata);
- BLI_duplicatelist(&(scen->markers), &(sce->markers));
- BLI_duplicatelist(&(scen->r.layers), &(sce->r.layers));
- BLI_duplicatelist(&(scen->r.views), &(sce->r.views));
- BKE_keyingsets_copy(&(scen->keyingsets), &(sce->keyingsets));
-
- if (sce->nodetree) {
- /* ID's are managed on both copy and switch */
- scen->nodetree = ntreeCopyTree(bmain, sce->nodetree);
- BKE_libblock_relink_ex(bmain, scen->nodetree, &sce->id, &scen->id, false);
- }
+ IDPropertyTemplate val = {0};
+ BLI_duplicatelist(&sce_dst->render_layers, &sce_src->render_layers);
+ for (SceneLayer *sl_src = sce_src->render_layers.first, *sl_dst = sce_dst->render_layers.first;
+ sl_src;
+ sl_src = sl_src->next, sl_dst = sl_dst->next)
+ {
+ sl_dst->stats = NULL;
+ sl_dst->properties_evaluated = NULL;
+ sl_dst->properties = IDP_New(IDP_GROUP, &val, ROOT_PROP);
+ IDP_MergeGroup_ex(sl_dst->properties, sl_src->properties, true, flag_subdata);
+
+ /* we start fresh with no overrides and no visibility flags set
+ * instead of syncing both trees we simply unlink and relink the scene collection */
+ BLI_listbase_clear(&sl_dst->layer_collections);
+ BLI_listbase_clear(&sl_dst->object_bases);
+ BLI_listbase_clear(&sl_dst->drawdata);
+
+ layer_collections_recreate(sl_dst, &sl_src->layer_collections, mc_dst, mc_src);
+
+ /* Now we handle the syncing for visibility, selectability, ... */
+ layer_collections_sync_flags(&sl_dst->layer_collections, &sl_src->layer_collections);
+
+ Object *active_ob = OBACT_NEW(sl_src);
+ for (Base *base_src = sl_src->object_bases.first, *base_dst = sl_dst->object_bases.first;
+ base_src;
+ base_src = base_src->next, base_dst = base_dst->next)
+ {
+ base_dst->flag = base_src->flag;
+ base_dst->flag_legacy = base_src->flag_legacy;
- olegacy_base = sce->base.first;
- legacy_base = scen->base.first;
- while (legacy_base) {
- id_us_plus(&legacy_base->object->id);
- if (olegacy_base == sce->basact) scen->basact = legacy_base;
-
- olegacy_base = olegacy_base->next;
- legacy_base = legacy_base->next;
+ if (base_dst->object == active_ob) {
+ sl_dst->basact = base_dst;
+ }
}
+ }
- /* copy action and remove animation used by sequencer */
- BKE_animdata_copy_id_action(&scen->id, false);
+ sce_dst->collection_properties = IDP_New(IDP_GROUP, &val, ROOT_PROP);
+ if (sce_src->collection_properties) {
+ IDP_MergeGroup_ex(sce_dst->collection_properties, sce_src->collection_properties, true, flag_subdata);
+ }
+ sce_dst->layer_properties = IDP_New(IDP_GROUP, &val, ROOT_PROP);
+ if (sce_src->layer_properties) {
+ IDP_MergeGroup_ex(sce_dst->layer_properties, sce_src->layer_properties, true, flag_subdata);
+ }
- if (type != SCE_COPY_FULL)
- remove_sequencer_fcurves(scen);
+ BLI_duplicatelist(&(sce_dst->markers), &(sce_src->markers));
+ BLI_duplicatelist(&(sce_dst->r.layers), &(sce_src->r.layers));
+ BLI_duplicatelist(&(sce_dst->r.views), &(sce_src->r.views));
+ BKE_keyingsets_copy(&(sce_dst->keyingsets), &(sce_src->keyingsets));
- /* copy Freestyle settings */
- new_srl = scen->r.layers.first;
- for (srl = sce->r.layers.first; srl; srl = srl->next) {
- if (new_srl->prop != NULL) {
- new_srl->prop = IDP_CopyProperty(new_srl->prop);
- }
- BKE_freestyle_config_copy(&new_srl->freestyleConfig, &srl->freestyleConfig);
- if (type == SCE_COPY_FULL) {
- for (lineset = new_srl->freestyleConfig.linesets.first; lineset; lineset = lineset->next) {
- if (lineset->linestyle) {
- id_us_plus((ID *)lineset->linestyle);
- lineset->linestyle = BKE_linestyle_copy(bmain, lineset->linestyle);
- }
- }
- }
- new_srl = new_srl->next;
- }
+ if (sce_src->nodetree) {
+ BKE_id_copy_ex(bmain, (ID *)sce_src->nodetree, (ID **)&sce_dst->nodetree, flag, false);
+ BKE_libblock_relink_ex(bmain, sce_dst->nodetree, (void *)(&sce_src->id), &sce_dst->id, false);
+ }
- /* layers and collections */
- scen->collection = MEM_dupallocN(sce->collection);
- SceneCollection *mcn = BKE_collection_master(scen);
- SceneCollection *mc = BKE_collection_master(sce);
-
- /* recursively creates a new SceneCollection tree */
- scene_collection_copy(mcn, mc);
-
- IDPropertyTemplate val = {0};
- BLI_duplicatelist(&scen->render_layers, &sce->render_layers);
- SceneLayer *new_sl = scen->render_layers.first;
- for (SceneLayer *sl = sce->render_layers.first; sl; sl = sl->next) {
- new_sl->stats = NULL;
- new_sl->properties_evaluated = NULL;
- new_sl->properties = IDP_New(IDP_GROUP, &val, ROOT_PROP);
- IDP_MergeGroup(new_sl->properties, sl->properties, true);
-
- /* we start fresh with no overrides and no visibility flags set
- * instead of syncing both trees we simply unlink and relink the scene collection */
- BLI_listbase_clear(&new_sl->layer_collections);
- BLI_listbase_clear(&new_sl->object_bases);
- BLI_listbase_clear(&new_sl->drawdata);
- layer_collections_recreate(new_sl, &sl->layer_collections, mcn, mc);
-
- Object *active_ob = OBACT_NEW;
- Base *new_base = new_sl->object_bases.first;
- for (Base *base = sl->object_bases.first; base; base = base->next) {
- new_base->flag = base->flag;
- new_base->flag_legacy = base->flag_legacy;
-
- if (new_base->object == active_ob) {
- new_sl->basact = new_base;
- }
+ if (sce_src->rigidbody_world) {
+ sce_dst->rigidbody_world = BKE_rigidbody_world_copy(sce_src->rigidbody_world, flag_subdata);
+ }
- new_base = new_base->next;
- }
- new_sl = new_sl->next;
+ /* copy Freestyle settings */
+ for (SceneRenderLayer *srl_dst = sce_dst->r.layers.first, *srl_src = sce_src->r.layers.first;
+ srl_src;
+ srl_dst = srl_dst->next, srl_src = srl_src->next)
+ {
+ if (srl_dst->prop != NULL) {
+ srl_dst->prop = IDP_CopyProperty_ex(srl_dst->prop, flag_subdata);
}
-
- scen->collection_properties = IDP_New(IDP_GROUP, &val, ROOT_PROP);
- scen->layer_properties = IDP_New(IDP_GROUP, &val, ROOT_PROP);
+ BKE_freestyle_config_copy(&srl_dst->freestyleConfig, &srl_src->freestyleConfig, flag_subdata);
}
/* copy color management settings */
- BKE_color_managed_display_settings_copy(&scen->display_settings, &sce->display_settings);
- BKE_color_managed_view_settings_copy(&scen->view_settings, &sce->view_settings);
- BKE_color_managed_colorspace_settings_copy(&scen->sequencer_colorspace_settings, &sce->sequencer_colorspace_settings);
+ BKE_color_managed_display_settings_copy(&sce_dst->display_settings, &sce_src->display_settings);
+ BKE_color_managed_view_settings_copy(&sce_dst->view_settings, &sce_src->view_settings);
+ BKE_color_managed_colorspace_settings_copy(&sce_dst->sequencer_colorspace_settings, &sce_src->sequencer_colorspace_settings);
- BKE_color_managed_display_settings_copy(&scen->r.im_format.display_settings, &sce->r.im_format.display_settings);
- BKE_color_managed_view_settings_copy(&scen->r.im_format.view_settings, &sce->r.im_format.view_settings);
+ BKE_color_managed_display_settings_copy(&sce_dst->r.im_format.display_settings, &sce_src->r.im_format.display_settings);
+ BKE_color_managed_view_settings_copy(&sce_dst->r.im_format.view_settings, &sce_src->r.im_format.view_settings);
- BKE_color_managed_display_settings_copy(&scen->r.bake.im_format.display_settings, &sce->r.bake.im_format.display_settings);
- BKE_color_managed_view_settings_copy(&scen->r.bake.im_format.view_settings, &sce->r.bake.im_format.view_settings);
+ BKE_color_managed_display_settings_copy(&sce_dst->r.bake.im_format.display_settings, &sce_src->r.bake.im_format.display_settings);
+ BKE_color_managed_view_settings_copy(&sce_dst->r.bake.im_format.view_settings, &sce_src->r.bake.im_format.view_settings);
- curvemapping_copy_data(&scen->r.mblur_shutter_curve, &sce->r.mblur_shutter_curve);
+ curvemapping_copy_data(&sce_dst->r.mblur_shutter_curve, &sce_src->r.mblur_shutter_curve);
/* tool settings */
- scen->toolsettings = MEM_dupallocN(sce->toolsettings);
-
- ts = scen->toolsettings;
- if (ts) {
+ if (sce_dst->toolsettings != NULL) {
+ ToolSettings *ts = sce_dst->toolsettings = MEM_dupallocN(sce_dst->toolsettings);
if (ts->vpaint) {
ts->vpaint = MEM_dupallocN(ts->vpaint);
- ts->vpaint->paintcursor = NULL;
- ts->vpaint->vpaint_prev = NULL;
- ts->vpaint->wpaint_prev = NULL;
- BKE_paint_copy(&ts->vpaint->paint, &ts->vpaint->paint);
+ BKE_paint_copy(&ts->vpaint->paint, &ts->vpaint->paint, flag_subdata);
}
if (ts->wpaint) {
ts->wpaint = MEM_dupallocN(ts->wpaint);
- ts->wpaint->paintcursor = NULL;
- ts->wpaint->vpaint_prev = NULL;
- ts->wpaint->wpaint_prev = NULL;
- BKE_paint_copy(&ts->wpaint->paint, &ts->wpaint->paint);
+ BKE_paint_copy(&ts->wpaint->paint, &ts->wpaint->paint, flag_subdata);
}
if (ts->sculpt) {
ts->sculpt = MEM_dupallocN(ts->sculpt);
- BKE_paint_copy(&ts->sculpt->paint, &ts->sculpt->paint);
+ BKE_paint_copy(&ts->sculpt->paint, &ts->sculpt->paint, flag_subdata);
+ }
+ if (ts->uvsculpt) {
+ ts->uvsculpt = MEM_dupallocN(ts->uvsculpt);
+ BKE_paint_copy(&ts->uvsculpt->paint, &ts->uvsculpt->paint, flag_subdata);
}
- BKE_paint_copy(&ts->imapaint.paint, &ts->imapaint.paint);
+ BKE_paint_copy(&ts->imapaint.paint, &ts->imapaint.paint, flag_subdata);
ts->imapaint.paintcursor = NULL;
- id_us_plus((ID *)ts->imapaint.stencil);
ts->particle.paintcursor = NULL;
-
+ ts->particle.scene = NULL;
+ ts->particle.object = NULL;
+
/* duplicate Grease Pencil Drawing Brushes */
BLI_listbase_clear(&ts->gp_brushes);
- for (bGPDbrush *brush = sce->toolsettings->gp_brushes.first; brush; brush = brush->next) {
+ for (bGPDbrush *brush = sce_src->toolsettings->gp_brushes.first; brush; brush = brush->next) {
bGPDbrush *newbrush = BKE_gpencil_brush_duplicate(brush);
BLI_addtail(&ts->gp_brushes, newbrush);
}
-
+
/* duplicate Grease Pencil interpolation curve */
ts->gp_interpolate.custom_ipo = curvemapping_copy(ts->gp_interpolate.custom_ipo);
}
-
+
/* make a private copy of the avicodecdata */
- if (sce->r.avicodecdata) {
- scen->r.avicodecdata = MEM_dupallocN(sce->r.avicodecdata);
- scen->r.avicodecdata->lpFormat = MEM_dupallocN(scen->r.avicodecdata->lpFormat);
- scen->r.avicodecdata->lpParms = MEM_dupallocN(scen->r.avicodecdata->lpParms);
- }
-
- /* make a private copy of the qtcodecdata */
- if (sce->r.qtcodecdata) {
- scen->r.qtcodecdata = MEM_dupallocN(sce->r.qtcodecdata);
- scen->r.qtcodecdata->cdParms = MEM_dupallocN(scen->r.qtcodecdata->cdParms);
+ if (sce_src->r.avicodecdata) {
+ sce_dst->r.avicodecdata = MEM_dupallocN(sce_src->r.avicodecdata);
+ sce_dst->r.avicodecdata->lpFormat = MEM_dupallocN(sce_dst->r.avicodecdata->lpFormat);
+ sce_dst->r.avicodecdata->lpParms = MEM_dupallocN(sce_dst->r.avicodecdata->lpParms);
}
-
- if (sce->r.ffcodecdata.properties) { /* intentionally check scen not sce. */
- scen->r.ffcodecdata.properties = IDP_CopyProperty(sce->r.ffcodecdata.properties);
+
+ if (sce_src->r.ffcodecdata.properties) { /* intentionally check sce_dst not sce_src. */ /* XXX ??? comment outdated... */
+ sce_dst->r.ffcodecdata.properties = IDP_CopyProperty_ex(sce_src->r.ffcodecdata.properties, flag_subdata);
}
- /* NOTE: part of SCE_COPY_LINK_DATA and SCE_COPY_FULL operations
- * are done outside of blenkernel with ED_objects_single_users! */
+ /* before scene copy */
+ BKE_sound_create_scene(sce_dst);
+
+ /* Copy sequencer, this is local data! */
+ if (sce_src->ed) {
+ sce_dst->ed = MEM_callocN(sizeof(*sce_dst->ed), __func__);
+ sce_dst->ed->seqbasep = &sce_dst->ed->seqbase;
+ BKE_sequence_base_dupli_recursive(
+ sce_src, sce_dst, &sce_dst->ed->seqbase, &sce_src->ed->seqbase, SEQ_DUPE_ALL, flag_subdata);
+ }
- /* camera */
- if (type == SCE_COPY_LINK_DATA || type == SCE_COPY_FULL) {
- ID_NEW_REMAP(scen->camera);
+ if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0) {
+ BKE_previewimg_id_copy(&sce_dst->id, &sce_src->id);
}
-
- /* before scene copy */
- BKE_sound_create_scene(scen);
-
- /* world */
- if (type == SCE_COPY_FULL) {
- if (scen->world) {
- id_us_plus((ID *)scen->world);
- scen->world = BKE_world_copy(bmain, scen->world);
- BKE_animdata_copy_id_action((ID *)scen->world, false);
+ else {
+ sce_dst->preview = NULL;
+ }
+}
+
+Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type)
+{
+ Scene *sce_copy;
+
+ /* TODO this should/could most likely be replaced by call to more generic code at some point...
+ * But for now, let's keep it well isolated here. */
+ if (type == SCE_COPY_EMPTY) {
+ ToolSettings *ts;
+ ListBase rl, rv;
+
+ sce_copy = BKE_scene_add(bmain, sce->id.name + 2);
+
+ rl = sce_copy->r.layers;
+ rv = sce_copy->r.views;
+ curvemapping_free_data(&sce_copy->r.mblur_shutter_curve);
+ sce_copy->r = sce->r;
+ sce_copy->r.layers = rl;
+ sce_copy->r.actlay = 0;
+ sce_copy->r.views = rv;
+ sce_copy->unit = sce->unit;
+ sce_copy->physics_settings = sce->physics_settings;
+ sce_copy->gm = sce->gm;
+ sce_copy->audio = sce->audio;
+
+ if (sce->id.properties)
+ sce_copy->id.properties = IDP_CopyProperty(sce->id.properties);
+
+ MEM_freeN(sce_copy->toolsettings);
+ BKE_sound_destroy_scene(sce_copy);
+
+ /* copy color management settings */
+ BKE_color_managed_display_settings_copy(&sce_copy->display_settings, &sce->display_settings);
+ BKE_color_managed_view_settings_copy(&sce_copy->view_settings, &sce->view_settings);
+ BKE_color_managed_colorspace_settings_copy(&sce_copy->sequencer_colorspace_settings, &sce->sequencer_colorspace_settings);
+
+ BKE_color_managed_display_settings_copy(&sce_copy->r.im_format.display_settings, &sce->r.im_format.display_settings);
+ BKE_color_managed_view_settings_copy(&sce_copy->r.im_format.view_settings, &sce->r.im_format.view_settings);
+
+ BKE_color_managed_display_settings_copy(&sce_copy->r.bake.im_format.display_settings, &sce->r.bake.im_format.display_settings);
+ BKE_color_managed_view_settings_copy(&sce_copy->r.bake.im_format.view_settings, &sce->r.bake.im_format.view_settings);
+
+ curvemapping_copy_data(&sce_copy->r.mblur_shutter_curve, &sce->r.mblur_shutter_curve);
+
+ /* tool settings */
+ sce_copy->toolsettings = MEM_dupallocN(sce->toolsettings);
+
+ ts = sce_copy->toolsettings;
+ if (ts) {
+ if (ts->vpaint) {
+ ts->vpaint = MEM_dupallocN(ts->vpaint);
+ BKE_paint_copy(&ts->vpaint->paint, &ts->vpaint->paint, 0);
+ }
+ if (ts->wpaint) {
+ ts->wpaint = MEM_dupallocN(ts->wpaint);
+ BKE_paint_copy(&ts->wpaint->paint, &ts->wpaint->paint, 0);
+ }
+ if (ts->sculpt) {
+ ts->sculpt = MEM_dupallocN(ts->sculpt);
+ BKE_paint_copy(&ts->sculpt->paint, &ts->sculpt->paint, 0);
+ }
+ if (ts->uvsculpt) {
+ ts->uvsculpt = MEM_dupallocN(ts->uvsculpt);
+ BKE_paint_copy(&ts->uvsculpt->paint, &ts->uvsculpt->paint, 0);
+ }
+
+ BKE_paint_copy(&ts->imapaint.paint, &ts->imapaint.paint, 0);
+ ts->imapaint.paintcursor = NULL;
+ id_us_plus((ID *)ts->imapaint.stencil);
+ id_us_plus((ID *)ts->imapaint.clone);
+ id_us_plus((ID *)ts->imapaint.canvas);
+ ts->particle.paintcursor = NULL;
+ ts->particle.scene = NULL;
+ ts->particle.object = NULL;
+
+ /* duplicate Grease Pencil Drawing Brushes */
+ BLI_listbase_clear(&ts->gp_brushes);
+ for (bGPDbrush *brush = sce->toolsettings->gp_brushes.first; brush; brush = brush->next) {
+ bGPDbrush *newbrush = BKE_gpencil_brush_duplicate(brush);
+ BLI_addtail(&ts->gp_brushes, newbrush);
+ }
+
+ /* duplicate Grease Pencil interpolation curve */
+ ts->gp_interpolate.custom_ipo = curvemapping_copy(ts->gp_interpolate.custom_ipo);
+ }
+
+ /* make a private copy of the avicodecdata */
+ if (sce->r.avicodecdata) {
+ sce_copy->r.avicodecdata = MEM_dupallocN(sce->r.avicodecdata);
+ sce_copy->r.avicodecdata->lpFormat = MEM_dupallocN(sce_copy->r.avicodecdata->lpFormat);
+ sce_copy->r.avicodecdata->lpParms = MEM_dupallocN(sce_copy->r.avicodecdata->lpParms);
}
- if (sce->ed) {
- scen->ed = MEM_callocN(sizeof(Editing), "addseq");
- scen->ed->seqbasep = &scen->ed->seqbase;
- BKE_sequence_base_dupli_recursive(sce, scen, &scen->ed->seqbase, &sce->ed->seqbase, SEQ_DUPE_ALL);
+ if (sce->r.ffcodecdata.properties) { /* intentionally check scen not sce. */
+ sce_copy->r.ffcodecdata.properties = IDP_CopyProperty(sce->r.ffcodecdata.properties);
}
+
+ /* before scene copy */
+ BKE_sound_create_scene(sce_copy);
+
+ /* grease pencil */
+ sce_copy->gpd = NULL;
+
+ sce_copy->preview = NULL;
+
+ return sce_copy;
}
-
- /* grease pencil */
- if (scen->gpd) {
+ else {
+ BKE_id_copy_ex(bmain, (ID *)sce, (ID **)&sce_copy, LIB_ID_COPY_ACTIONS, false);
+
+ /* Extra actions, most notably SCE_FULL_COPY also duplicates several 'children' datablocks... */
+
if (type == SCE_COPY_FULL) {
- scen->gpd = BKE_gpencil_data_duplicate(bmain, scen->gpd, false);
- }
- else if (type == SCE_COPY_EMPTY) {
- scen->gpd = NULL;
+ /* Copy Freestyle LineStyle datablocks. */
+ for (SceneRenderLayer *srl_dst = sce_copy->r.layers.first; srl_dst; srl_dst = srl_dst->next) {
+ for (FreestyleLineSet *lineset = srl_dst->freestyleConfig.linesets.first; lineset; lineset = lineset->next) {
+ if (lineset->linestyle) {
+ /* XXX Not copying anim/actions here? */
+ BKE_id_copy_ex(bmain, (ID *)lineset->linestyle, (ID **)&lineset->linestyle, 0, false);
+ }
+ }
+ }
+
+ /* Full copy of world (included animations) */
+ if (sce_copy->world) {
+ BKE_id_copy_ex(bmain, (ID *)sce_copy->world, (ID **)&sce_copy->world, LIB_ID_COPY_ACTIONS, false);
+ }
+
+ /* Full copy of GreasePencil. */
+ /* XXX Not copying anim/actions here? */
+ if (sce_copy->gpd) {
+ BKE_id_copy_ex(bmain, (ID *)sce_copy->gpd, (ID **)&sce_copy->gpd, 0, false);
+ }
}
else {
- id_us_plus((ID *)scen->gpd);
+ /* Remove sequencer if not full copy */
+ /* XXX Why in Hell? :/ */
+ remove_sequencer_fcurves(sce_copy);
+ BKE_sequencer_editing_free(sce_copy);
}
- }
- BKE_previewimg_id_copy(&scen->id, &sce->id);
+ /* NOTE: part of SCE_COPY_LINK_DATA and SCE_COPY_FULL operations
+ * are done outside of blenkernel with ED_objects_single_users! */
- if (type != SCE_COPY_NEW) {
- if (sce->collection_properties) {
- IDP_MergeGroup(scen->collection_properties, sce->collection_properties, true);
+ /* camera */
+ if (ELEM(type, SCE_COPY_LINK_DATA, SCE_COPY_FULL)) {
+ ID_NEW_REMAP(sce_copy->camera);
}
- if (sce->layer_properties) {
- IDP_MergeGroup(scen->layer_properties, sce->layer_properties, true);
- }
- }
- return scen;
+ return sce_copy;
+ }
}
void BKE_scene_groups_relink(Scene *sce)
@@ -517,11 +607,6 @@ void BKE_scene_free_ex(Scene *sce, const bool do_id_user)
MEM_freeN(sce->r.avicodecdata);
sce->r.avicodecdata = NULL;
}
- if (sce->r.qtcodecdata) {
- free_qtcodecdata(sce->r.qtcodecdata);
- MEM_freeN(sce->r.qtcodecdata);
- sce->r.qtcodecdata = NULL;
- }
if (sce->r.ffcodecdata.properties) {
IDP_FreeProperty(sce->r.ffcodecdata.properties);
MEM_freeN(sce->r.ffcodecdata.properties);
@@ -539,7 +624,7 @@ void BKE_scene_free_ex(Scene *sce, const bool do_id_user)
BLI_freelistN(&sce->markers);
BLI_freelistN(&sce->r.layers);
BLI_freelistN(&sce->r.views);
-
+
if (sce->toolsettings) {
if (sce->toolsettings->vpaint) {
BKE_paint_free(&sce->toolsettings->vpaint->paint);
@@ -573,8 +658,8 @@ void BKE_scene_free_ex(Scene *sce, const bool do_id_user)
}
DEG_scene_graph_free(sce);
- if (sce->depsgraph)
- DEG_graph_free(sce->depsgraph);
+ if (sce->depsgraph_legacy)
+ DEG_graph_free(sce->depsgraph_legacy);
MEM_SAFE_FREE(sce->fps_info);
@@ -614,7 +699,7 @@ void BKE_scene_free_ex(Scene *sce, const bool do_id_user)
void BKE_scene_free(Scene *sce)
{
- return BKE_scene_free_ex(sce, true);
+ BKE_scene_free_ex(sce, true);
}
void BKE_scene_init(Scene *sce)
@@ -710,7 +795,7 @@ void BKE_scene_init(Scene *sce)
sce->r.seq_prev_type = OB_SOLID;
sce->r.seq_rend_type = OB_SOLID;
- sce->r.seq_flag = R_SEQ_GL_PREV;
+ sce->r.seq_flag = 0;
sce->r.threads = 1;
@@ -818,7 +903,7 @@ void BKE_scene_init(Scene *sce)
sce->r.ffcodecdata.audio_bitrate = 192;
sce->r.ffcodecdata.audio_channels = 2;
- BLI_strncpy(sce->r.engine, RE_engine_id_BLENDER_RENDER, sizeof(sce->r.engine));
+ BLI_strncpy(sce->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(sce->r.engine));
sce->audio.distance_model = 2.0f;
sce->audio.doppler_factor = 1.0f;
@@ -984,7 +1069,7 @@ Scene *BKE_scene_add(Main *bmain, const char *name)
{
Scene *sce;
- sce = BKE_libblock_alloc(bmain, ID_SCE, name);
+ sce = BKE_libblock_alloc(bmain, ID_SCE, name, 0);
id_us_min(&sce->id);
id_us_ensure_real(&sce->id);
@@ -1074,8 +1159,9 @@ Scene *BKE_scene_set_name(Main *bmain, const char *name)
}
/* Used by metaballs, return *all* objects (including duplis) existing in the scene (including scene's sets) */
-int BKE_scene_base_iter_next(EvaluationContext *eval_ctx, SceneBaseIter *iter,
- Scene **scene, int val, BaseLegacy **base, Object **ob)
+int BKE_scene_base_iter_next(
+ const EvaluationContext *eval_ctx, SceneBaseIter *iter,
+ Scene **scene, int val, BaseLegacy **base, Object **ob)
{
bool run_again = true;
@@ -1517,7 +1603,7 @@ void BKE_scene_update_tagged(EvaluationContext *eval_ctx, Main *bmain, Scene *sc
prepare_mesh_for_viewport_render(bmain, scene);
/* flush recalc flags to dependencies */
- DEG_ids_flush_tagged(bmain);
+ DEG_scene_flush_update(bmain, scene);
/* removed calls to quick_cache, see pointcache.c */
@@ -1532,9 +1618,7 @@ void BKE_scene_update_tagged(EvaluationContext *eval_ctx, Main *bmain, Scene *sc
*
* in the future this should handle updates for all datablocks, not
* only objects and scenes. - brecht */
- DEG_evaluate_on_refresh(eval_ctx, scene->depsgraph, scene);
- /* TODO(sergey): This is to beocme a node in new depsgraph. */
- BKE_mask_update_scene(bmain, scene);
+ DEG_evaluate_on_refresh(eval_ctx, scene->depsgraph_legacy, scene);
/* update sound system animation (TODO, move to depsgraph) */
BKE_sound_update_scene(bmain, scene);
@@ -1571,15 +1655,13 @@ void BKE_scene_update_for_newframe(EvaluationContext *eval_ctx, Main *bmain, Sce
BKE_image_update_frame(bmain, sce->r.cfra);
BKE_sound_set_cfra(sce->r.cfra);
-
+
/* clear animation overrides */
/* XXX TODO... */
for (sce_iter = sce; sce_iter; sce_iter = sce_iter->set)
DEG_scene_relations_update(bmain, sce_iter);
- BKE_mask_evaluate_all_masks(bmain, ctime, true);
-
/* Update animated cache files for modifiers. */
BKE_cachefile_update_frame(bmain, sce, ctime, (((double)sce->r.frs_sec) / (double)sce->r.frs_sec_base));
@@ -1594,7 +1676,7 @@ void BKE_scene_update_for_newframe(EvaluationContext *eval_ctx, Main *bmain, Sce
BKE_main_id_tag_idcode(bmain, ID_LA, LIB_TAG_DOIT, false);
/* BKE_object_handle_update() on all objects, groups and sets */
- DEG_evaluate_on_framechange(eval_ctx, bmain, sce->depsgraph, ctime);
+ DEG_evaluate_on_framechange(eval_ctx, bmain, sce->depsgraph_legacy, ctime);
/* update sound system animation (TODO, move to depsgraph) */
BKE_sound_update_scene(bmain, sce);
@@ -1764,7 +1846,7 @@ Base *_setlooper_base_step(Scene **sce_iter, Base *base)
/* first time looping, return the scenes first base */
/* for the first loop we should get the layer from context */
- SceneLayer *sl = BKE_scene_layer_context_active((*sce_iter));
+ SceneLayer *sl = BKE_scene_layer_context_active_PLACEHOLDER((*sce_iter));
/* TODO For first scene (non-background set), we should pass the render layer as argument.
* In some cases we want it to be the workspace one, in other the scene one. */
TODO_LAYER;
@@ -1779,7 +1861,7 @@ Base *_setlooper_base_step(Scene **sce_iter, Base *base)
next_set:
/* reached the end, get the next base in the set */
while ((*sce_iter = (*sce_iter)->set)) {
- SceneLayer *sl = BKE_scene_layer_render_active((*sce_iter));
+ SceneLayer *sl = BKE_scene_layer_from_scene_get((*sce_iter));
base = (Base *)sl->object_bases.first;
if (base) {
@@ -1935,6 +2017,14 @@ int BKE_scene_num_threads(const Scene *scene)
return BKE_render_num_threads(&scene->r);
}
+int BKE_render_preview_pixel_size(const RenderData *r)
+{
+ if (r->preview_pixel_size == 0) {
+ return (U.pixelsize > 1.5f) ? 2 : 1;
+ }
+ return r->preview_pixel_size;
+}
+
/* Apply the needed correction factor to value, based on unit_type (only length-related are affected currently)
* and unit->scale_length.
*/
@@ -2240,3 +2330,9 @@ int BKE_scene_multiview_num_videos_get(const RenderData *rd)
return BKE_scene_multiview_num_views_get(rd);
}
}
+
+Depsgraph *BKE_scene_get_depsgraph(Scene *scene, SceneLayer *scene_layer)
+{
+ (void) scene_layer;
+ return scene->depsgraph_legacy;
+}
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index f3a93a0a42c..6bd88099792 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -185,6 +185,7 @@ ARegion *BKE_area_region_copy(SpaceType *st, ARegion *ar)
newar->swinid = 0;
newar->manipulator_map = NULL;
newar->regiontimer = NULL;
+ newar->headerstr = NULL;
/* use optional regiondata callback */
if (ar->regiondata) {
@@ -292,6 +293,32 @@ void BKE_spacedata_id_unref(struct ScrArea *sa, struct SpaceLink *sl, struct ID
}
}
+/**
+ * Avoid bad-level calls to #WM_manipulatormap_tag_refresh.
+ */
+static void (*region_refresh_tag_manipulatormap_callback)(struct wmManipulatorMap *) = NULL;
+
+void BKE_region_callback_refresh_tag_manipulatormap_set(void (*callback)(struct wmManipulatorMap *))
+{
+ region_refresh_tag_manipulatormap_callback = callback;
+}
+
+void BKE_screen_manipulator_tag_refresh(struct bScreen *sc)
+{
+ if (region_refresh_tag_manipulatormap_callback == NULL) {
+ return;
+ }
+
+ ScrArea *sa;
+ ARegion *ar;
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ for (ar = sa->regionbase.first; ar; ar = ar->next) {
+ if (ar->manipulator_map != NULL) {
+ region_refresh_tag_manipulatormap_callback(ar->manipulator_map);
+ }
+ }
+ }
+}
/**
* Avoid bad-level calls to #WM_manipulatormap_delete.
@@ -353,7 +380,10 @@ void BKE_area_region_free(SpaceType *st, ARegion *ar)
}
}
- region_free_manipulatormap_callback(ar->manipulator_map);
+ if (ar->manipulator_map != NULL) {
+ region_free_manipulatormap_callback(ar->manipulator_map);
+ }
+
BLI_freelistN(&ar->ui_lists);
BLI_freelistN(&ar->ui_previews);
BLI_freelistN(&ar->panels_category);
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c
index e435d87024e..a2c45057bf7 100644
--- a/source/blender/blenkernel/intern/seqeffects.c
+++ b/source/blender/blenkernel/intern/seqeffects.c
@@ -1861,7 +1861,7 @@ static void RVBlurBitmap2_float(float *map, int width, int height, float blur, i
float *filter = NULL;
int x, y, i, fx, fy;
int index, ix, halfWidth;
- float fval, k, curColor[3], curColor2[3], weight = 0;
+ float fval, k, curColor[4], curColor2[4], weight = 0;
/* If we're not really blurring, bail out */
if (blur <= 0)
@@ -1906,47 +1906,38 @@ static void RVBlurBitmap2_float(float *map, int width, int height, float blur, i
for (y = 0; y < height; y++) {
/* Do the left & right strips */
for (x = 0; x < halfWidth; x++) {
- index = (x + y * width) * 4;
fx = 0;
- curColor[0] = curColor[1] = curColor[2] = 0.0f;
- curColor2[0] = curColor2[1] = curColor2[2] = 0.0f;
+ zero_v4(curColor);
+ zero_v4(curColor2);
for (i = x - halfWidth; i < x + halfWidth; i++) {
if ((i >= 0) && (i < width)) {
- curColor[0] += map[(i + y * width) * 4 + GlowR] * filter[fx];
- curColor[1] += map[(i + y * width) * 4 + GlowG] * filter[fx];
- curColor[2] += map[(i + y * width) * 4 + GlowB] * filter[fx];
+ index = (i + y * width) * 4;
+ madd_v4_v4fl(curColor, map + index, filter[fx]);
- curColor2[0] += map[(width - 1 - i + y * width) * 4 + GlowR] * filter[fx];
- curColor2[1] += map[(width - 1 - i + y * width) * 4 + GlowG] * filter[fx];
- curColor2[2] += map[(width - 1 - i + y * width) * 4 + GlowB] * filter[fx];
+ index = (width - 1 - i + y * width) * 4;
+ madd_v4_v4fl(curColor2, map + index, filter[fx]);
}
fx++;
}
- temp[index + GlowR] = curColor[0];
- temp[index + GlowG] = curColor[1];
- temp[index + GlowB] = curColor[2];
-
- temp[((width - 1 - x + y * width) * 4) + GlowR] = curColor2[0];
- temp[((width - 1 - x + y * width) * 4) + GlowG] = curColor2[1];
- temp[((width - 1 - x + y * width) * 4) + GlowB] = curColor2[2];
+ index = (x + y * width) * 4;
+ copy_v4_v4(temp + index, curColor);
+ index = (width - 1 - x + y * width) * 4;
+ copy_v4_v4(temp + index, curColor2);
}
/* Do the main body */
for (x = halfWidth; x < width - halfWidth; x++) {
- index = (x + y * width) * 4;
fx = 0;
- zero_v3(curColor);
+ zero_v4(curColor);
for (i = x - halfWidth; i < x + halfWidth; i++) {
- curColor[0] += map[(i + y * width) * 4 + GlowR] * filter[fx];
- curColor[1] += map[(i + y * width) * 4 + GlowG] * filter[fx];
- curColor[2] += map[(i + y * width) * 4 + GlowB] * filter[fx];
+ index = (i + y * width) * 4;
+ madd_v4_v4fl(curColor, map + index, filter[fx]);
fx++;
}
- temp[index + GlowR] = curColor[0];
- temp[index + GlowG] = curColor[1];
- temp[index + GlowB] = curColor[2];
+ index = (x + y * width) * 4;
+ copy_v4_v4(temp + index, curColor);
}
}
@@ -1957,46 +1948,39 @@ static void RVBlurBitmap2_float(float *map, int width, int height, float blur, i
for (x = 0; x < width; x++) {
/* Do the top & bottom strips */
for (y = 0; y < halfWidth; y++) {
- index = (x + y * width) * 4;
fy = 0;
- zero_v3(curColor);
- zero_v3(curColor2);
+ zero_v4(curColor);
+ zero_v4(curColor2);
for (i = y - halfWidth; i < y + halfWidth; i++) {
if ((i >= 0) && (i < height)) {
/* Bottom */
- curColor[0] += map[(x + i * width) * 4 + GlowR] * filter[fy];
- curColor[1] += map[(x + i * width) * 4 + GlowG] * filter[fy];
- curColor[2] += map[(x + i * width) * 4 + GlowB] * filter[fy];
+ index = (x + i * width) * 4;
+ madd_v4_v4fl(curColor, map + index, filter[fy]);
/* Top */
- curColor2[0] += map[(x + (height - 1 - i) * width) * 4 + GlowR] * filter[fy];
- curColor2[1] += map[(x + (height - 1 - i) * width) * 4 + GlowG] * filter[fy];
- curColor2[2] += map[(x + (height - 1 - i) * width) * 4 + GlowB] * filter[fy];
+ index = (x + (height - 1 - i) * width) * 4;
+ madd_v4_v4fl(curColor2, map + index, filter[fy]);
}
fy++;
}
- temp[index + GlowR] = curColor[0];
- temp[index + GlowG] = curColor[1];
- temp[index + GlowB] = curColor[2];
- temp[((x + (height - 1 - y) * width) * 4) + GlowR] = curColor2[0];
- temp[((x + (height - 1 - y) * width) * 4) + GlowG] = curColor2[1];
- temp[((x + (height - 1 - y) * width) * 4) + GlowB] = curColor2[2];
+ index = (x + y * width) * 4;
+ copy_v4_v4(temp + index, curColor);
+
+ index = (x + (height - 1 - y) * width) * 4;
+ copy_v4_v4(temp + index, curColor2);
}
/* Do the main body */
for (y = halfWidth; y < height - halfWidth; y++) {
- index = (x + y * width) * 4;
fy = 0;
- zero_v3(curColor);
+ zero_v4(curColor);
for (i = y - halfWidth; i < y + halfWidth; i++) {
- curColor[0] += map[(x + i * width) * 4 + GlowR] * filter[fy];
- curColor[1] += map[(x + i * width) * 4 + GlowG] * filter[fy];
- curColor[2] += map[(x + i * width) * 4 + GlowB] * filter[fy];
+ index = (x + i * width) * 4;
+ madd_v4_v4fl(curColor, map + index, filter[fy]);
fy++;
}
- temp[index + GlowR] = curColor[0];
- temp[index + GlowG] = curColor[1];
- temp[index + GlowB] = curColor[2];
+ index = (x + y * width) * 4;
+ copy_v4_v4(temp + index, curColor);
}
}
@@ -2015,10 +1999,10 @@ static void RVAddBitmaps_float(float *a, float *b, float *c, int width, int heig
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
index = (x + y * width) * 4;
- c[index + GlowR] = MIN2(1.0f, a[index + GlowR] + b[index + GlowR]);
- c[index + GlowG] = MIN2(1.0f, a[index + GlowG] + b[index + GlowG]);
- c[index + GlowB] = MIN2(1.0f, a[index + GlowB] + b[index + GlowB]);
- c[index + GlowA] = MIN2(1.0f, a[index + GlowA] + b[index + GlowA]);
+ c[index + GlowR] = min_ff(1.0f, a[index + GlowR] + b[index + GlowR]);
+ c[index + GlowG] = min_ff(1.0f, a[index + GlowG] + b[index + GlowG]);
+ c[index + GlowB] = min_ff(1.0f, a[index + GlowB] + b[index + GlowB]);
+ c[index + GlowA] = min_ff(1.0f, a[index + GlowA] + b[index + GlowA]);
}
}
}
@@ -2035,10 +2019,10 @@ static void RVIsolateHighlights_float(float *in, float *out, int width, int heig
/* Isolate the intensity */
intensity = (in[index + GlowR] + in[index + GlowG] + in[index + GlowB] - threshold);
if (intensity > 0) {
- out[index + GlowR] = MIN2(clamp, (in[index + GlowR] * boost * intensity));
- out[index + GlowG] = MIN2(clamp, (in[index + GlowG] * boost * intensity));
- out[index + GlowB] = MIN2(clamp, (in[index + GlowB] * boost * intensity));
- out[index + GlowA] = MIN2(clamp, (in[index + GlowA] * boost * intensity));
+ out[index + GlowR] = min_ff(clamp, (in[index + GlowR] * boost * intensity));
+ out[index + GlowG] = min_ff(clamp, (in[index + GlowG] * boost * intensity));
+ out[index + GlowB] = min_ff(clamp, (in[index + GlowB] * boost * intensity));
+ out[index + GlowA] = min_ff(clamp, (in[index + GlowA] * boost * intensity));
}
else {
out[index + GlowR] = 0;
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index e316b7f26e9..c6b6f97b0bc 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -91,7 +91,7 @@
#include "BKE_sound.h"
#ifdef WITH_AUDASPACE
-# include AUD_SPECIAL_H
+# include <AUD_Special.h>
#endif
/* mutable state for sequencer */
@@ -379,6 +379,8 @@ static void seqclipboard_ptr_restore(Main *bmain, ID **id_pt)
}
break;
}
+ default:
+ break;
}
}
@@ -482,9 +484,12 @@ void BKE_sequencer_editing_free(Scene *scene)
static void sequencer_imbuf_assign_spaces(Scene *scene, ImBuf *ibuf)
{
+#if 0
+ /* Bute buffer is supposed to be in sequencer working space already. */
if (ibuf->rect != NULL) {
IMB_colormanagement_assign_rect_colorspace(ibuf, scene->sequencer_colorspace_settings.name);
}
+#endif
if (ibuf->rect_float != NULL) {
IMB_colormanagement_assign_float_colorspace(ibuf, scene->sequencer_colorspace_settings.name);
}
@@ -2084,7 +2089,7 @@ void BKE_sequencer_proxy_set(struct Sequence *seq, bool value)
}
}
else {
- seq->flag ^= SEQ_USE_PROXY;
+ seq->flag &= ~SEQ_USE_PROXY;
}
}
@@ -3235,7 +3240,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context, Sequence *seq
const bool is_background = G.background;
const bool do_seq_gl = is_rendering ?
0 /* (context->scene->r.seq_flag & R_SEQ_GL_REND) */ :
- (context->scene->r.seq_flag & R_SEQ_GL_PREV) != 0;
+ (context->scene->r.seq_prev_type) != OB_RENDER;
// bool have_seq = false; /* UNUSED */
bool have_comp = false;
bool use_gpencil = true;
@@ -3306,7 +3311,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context, Sequence *seq
BKE_scene_update_for_newframe(context->eval_ctx, context->bmain, scene);
ibuf = sequencer_view3d_cb(
/* set for OpenGL render (NULL when scrubbing) */
- scene, BKE_scene_layer_render_active(scene), camera, width, height, IB_rect,
+ context->eval_ctx, scene, BKE_scene_layer_from_scene_get(scene), camera, width, height, IB_rect,
context->scene->r.seq_prev_type,
(context->scene->r.seq_flag & R_SEQ_SOLID_TEX) != 0,
use_gpencil, use_background, scene->r.alphamode,
@@ -3317,7 +3322,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context, Sequence *seq
}
}
else {
- Render *re = RE_GetRender(scene->id.name);
+ Render *re = RE_GetSceneRender(scene);
const int totviews = BKE_scene_multiview_num_views_get(&scene->r);
int i;
ImBuf **ibufs_arr;
@@ -3334,7 +3339,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context, Sequence *seq
*/
if (!is_thread_main || is_rendering == false || is_background || context->eval_ctx->mode == DAG_EVAL_RENDER) {
if (re == NULL)
- re = RE_NewRender(scene->id.name);
+ re = RE_NewSceneRender(scene);
BKE_scene_update_for_newframe(context->eval_ctx, context->bmain, scene);
RE_BlenderFrame(re, context->bmain, scene, NULL, camera, scene->lay, frame, false);
@@ -5373,9 +5378,8 @@ Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoad
return seq;
}
-static Sequence *seq_dupli(Scene *scene, Scene *scene_to, Sequence *seq, int dupe_flag)
+static Sequence *seq_dupli(const Scene *scene_src, Scene *scene_dst, Sequence *seq, int dupe_flag, const int flag)
{
- Scene *sce_audio = scene_to ? scene_to : scene;
Sequence *seqn = MEM_dupallocN(seq);
seq->tmp = seqn;
@@ -5399,7 +5403,7 @@ static Sequence *seq_dupli(Scene *scene, Scene *scene_to, Sequence *seq, int dup
}
if (seq->prop) {
- seqn->prop = IDP_CopyProperty(seq->prop);
+ seqn->prop = IDP_CopyProperty_ex(seq->prop, flag);
}
if (seqn->modifiers.first) {
@@ -5418,7 +5422,7 @@ static Sequence *seq_dupli(Scene *scene, Scene *scene_to, Sequence *seq, int dup
else if (seq->type == SEQ_TYPE_SCENE) {
seqn->strip->stripdata = NULL;
if (seq->scene_sound)
- seqn->scene_sound = BKE_sound_scene_add_scene_sound_defaults(sce_audio, seqn);
+ seqn->scene_sound = BKE_sound_scene_add_scene_sound_defaults(scene_dst, seqn);
}
else if (seq->type == SEQ_TYPE_MOVIECLIP) {
/* avoid assert */
@@ -5435,9 +5439,11 @@ static Sequence *seq_dupli(Scene *scene, Scene *scene_to, Sequence *seq, int dup
seqn->strip->stripdata =
MEM_dupallocN(seq->strip->stripdata);
if (seq->scene_sound)
- seqn->scene_sound = BKE_sound_add_scene_sound_defaults(sce_audio, seqn);
+ seqn->scene_sound = BKE_sound_add_scene_sound_defaults(scene_dst, seqn);
- id_us_plus((ID *)seqn->sound);
+ if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
+ id_us_plus((ID *)seqn->sound);
+ }
}
else if (seq->type == SEQ_TYPE_IMAGE) {
seqn->strip->stripdata =
@@ -5457,11 +5463,15 @@ static Sequence *seq_dupli(Scene *scene, Scene *scene_to, Sequence *seq, int dup
BLI_assert(0);
}
- if (dupe_flag & SEQ_DUPE_UNIQUE_NAME)
- BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seqn);
+ if (scene_src == scene_dst) {
+ if (dupe_flag & SEQ_DUPE_UNIQUE_NAME) {
+ BKE_sequence_base_unique_name_recursive(&scene_dst->ed->seqbase, seqn);
+ }
- if (dupe_flag & SEQ_DUPE_ANIM)
- BKE_sequencer_dupe_animdata(scene, seq->name + 2, seqn->name + 2);
+ if (dupe_flag & SEQ_DUPE_ANIM) {
+ BKE_sequencer_dupe_animdata(scene_dst, seq->name + 2, seqn->name + 2);
+ }
+ }
return seqn;
}
@@ -5488,16 +5498,16 @@ static void seq_new_fix_links_recursive(Sequence *seq)
}
}
-Sequence *BKE_sequence_dupli_recursive(Scene *scene, Scene *scene_to, Sequence *seq, int dupe_flag)
+Sequence *BKE_sequence_dupli_recursive(const Scene *scene_src, Scene *scene_dst, Sequence *seq, int dupe_flag)
{
Sequence *seqn;
seq->tmp = NULL;
- seqn = seq_dupli(scene, scene_to, seq, dupe_flag);
+ seqn = seq_dupli(scene_src, scene_dst, seq, dupe_flag, 0);
if (seq->type == SEQ_TYPE_META) {
Sequence *s;
for (s = seq->seqbase.first; s; s = s->next) {
- Sequence *n = BKE_sequence_dupli_recursive(scene, scene_to, s, dupe_flag);
+ Sequence *n = BKE_sequence_dupli_recursive(scene_src, scene_dst, s, dupe_flag);
if (n) {
BLI_addtail(&seqn->seqbase, n);
}
@@ -5510,19 +5520,19 @@ Sequence *BKE_sequence_dupli_recursive(Scene *scene, Scene *scene_to, Sequence *
}
void BKE_sequence_base_dupli_recursive(
- Scene *scene, Scene *scene_to, ListBase *nseqbase, ListBase *seqbase,
- int dupe_flag)
+ const Scene *scene_src, Scene *scene_dst, ListBase *nseqbase, const ListBase *seqbase,
+ int dupe_flag, const int flag)
{
Sequence *seq;
Sequence *seqn = NULL;
- Sequence *last_seq = BKE_sequencer_active_get(scene);
+ Sequence *last_seq = BKE_sequencer_active_get((Scene *)scene_src);
/* always include meta's strips */
int dupe_flag_recursive = dupe_flag | SEQ_DUPE_ALL;
for (seq = seqbase->first; seq; seq = seq->next) {
seq->tmp = NULL;
if ((seq->flag & SELECT) || (dupe_flag & SEQ_DUPE_ALL)) {
- seqn = seq_dupli(scene, scene_to, seq, dupe_flag);
+ seqn = seq_dupli(scene_src, scene_dst, seq, dupe_flag, flag);
if (seqn) { /*should never fail */
if (dupe_flag & SEQ_DUPE_CONTEXT) {
seq->flag &= ~SEQ_ALLSEL;
@@ -5532,13 +5542,13 @@ void BKE_sequence_base_dupli_recursive(
BLI_addtail(nseqbase, seqn);
if (seq->type == SEQ_TYPE_META) {
BKE_sequence_base_dupli_recursive(
- scene, scene_to, &seqn->seqbase, &seq->seqbase,
- dupe_flag_recursive);
+ scene_src, scene_dst, &seqn->seqbase, &seq->seqbase,
+ dupe_flag_recursive, flag);
}
if (dupe_flag & SEQ_DUPE_CONTEXT) {
if (seq == last_seq) {
- BKE_sequencer_active_set(scene, seqn);
+ BKE_sequencer_active_set(scene_dst, seqn);
}
}
}
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c
index 7094d5a3547..f9d1793d7cb 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -152,6 +152,9 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh;
BVHTreeNearest nearest = NULL_BVHTreeNearest;
+ if (calc->target != NULL && calc->target->getNumVerts(calc->target) == 0) {
+ return;
+ }
TIMEIT_BENCH(bvhtree_from_mesh_verts(&treeData, calc->target, 0.0, 2, 6), bvhtree_verts);
if (treeData.tree == NULL) {
@@ -376,6 +379,9 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, bool for
if ((calc->smd->shrinkOpts & (MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR | MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR)) == 0)
return;
+ if (calc->target != NULL && calc->target->getNumPolys(calc->target) == 0) {
+ return;
+ }
/* Prepare data to retrieve the direction in which we should project each vertex */
if (calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) {
@@ -432,7 +438,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, bool for
if (targ_tree) {
BVHTree *aux_tree = NULL;
void *aux_callback = NULL;
- if (auxMesh != NULL) {
+ if (auxMesh != NULL && auxMesh->getNumPolys(auxMesh) != 0) {
/* use editmesh to avoid array allocation */
if (calc->smd->auxTarget && auxMesh->type == DM_TYPE_EDITBMESH) {
emaux = BKE_editmesh_from_object(calc->smd->auxTarget);
@@ -560,6 +566,10 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh;
BVHTreeNearest nearest = NULL_BVHTreeNearest;
+ if (calc->target->getNumPolys(calc->target) == 0) {
+ return;
+ }
+
/* Create a bvh-tree of the given target */
bvhtree_from_mesh_looptri(&treeData, calc->target, 0.0, 2, 6);
if (treeData.tree == NULL) {
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 667f8d1e8c7..7ea985a311b 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -83,6 +83,8 @@
#include "BKE_smoke.h"
#include "BKE_texture.h"
+#include "DEG_depsgraph.h"
+
#include "RE_shader_ext.h"
#include "GPU_glew.h"
@@ -126,7 +128,7 @@ void smoke_initWaveletBlenderRNA(struct WTURBULENCE *UNUSED(wt), float *UNUSED(s
void smoke_initBlenderRNA(struct FLUID_3D *UNUSED(fluid), float *UNUSED(alpha), float *UNUSED(beta), float *UNUSED(dt_factor), float *UNUSED(vorticity),
int *UNUSED(border_colli), float *UNUSED(burning_rate), float *UNUSED(flame_smoke), float *UNUSED(flame_smoke_color),
float *UNUSED(flame_vorticity), float *UNUSED(flame_ignition_temp), float *UNUSED(flame_max_temp)) {}
-struct DerivedMesh *smokeModifier_do(SmokeModifierData *UNUSED(smd), Scene *UNUSED(scene), SceneLayer *UNUSED(sl), Object *UNUSED(ob), DerivedMesh *UNUSED(dm)) { return NULL; }
+struct DerivedMesh *smokeModifier_do(SmokeModifierData *UNUSED(smd), const struct EvaluationContext *UNUSED(eval_ctx), Scene *UNUSED(scene), Object *UNUSED(ob), DerivedMesh *UNUSED(dm)) { return NULL; }
float smoke_get_velocity_at(struct Object *UNUSED(ob), float UNUSED(position[3]), float UNUSED(velocity[3])) { return 0.0f; }
#endif /* WITH_SMOKE */
@@ -677,7 +679,7 @@ void smokeModifier_copy(struct SmokeModifierData *smd, struct SmokeModifierData
tsmd->flow->texture_size = smd->flow->texture_size;
tsmd->flow->texture_offset = smd->flow->texture_offset;
- BLI_strncpy(tsmd->flow->uvlayer_name, tsmd->flow->uvlayer_name, sizeof(tsmd->flow->uvlayer_name));
+ BLI_strncpy(tsmd->flow->uvlayer_name, smd->flow->uvlayer_name, sizeof(tsmd->flow->uvlayer_name));
tsmd->flow->vgroup_density = smd->flow->vgroup_density;
tsmd->flow->type = smd->flow->type;
@@ -702,7 +704,7 @@ static int get_lamp(SceneLayer *sl, float *light)
int found_lamp = 0;
// try to find a lamp, preferably local
- for (base_tmp = FIRSTBASE_NEW; base_tmp; base_tmp = base_tmp->next) {
+ for (base_tmp = FIRSTBASE_NEW(sl); base_tmp; base_tmp = base_tmp->next) {
if (base_tmp->object->type == OB_LAMP) {
Lamp *la = base_tmp->object->data;
@@ -2071,7 +2073,7 @@ BLI_INLINE void apply_inflow_fields(SmokeFlowSettings *sfs, float emission_value
}
}
-static void update_flowsfluids(Scene *scene, Object *ob, SmokeDomainSettings *sds, float dt)
+static void update_flowsfluids(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, SmokeDomainSettings *sds, float dt)
{
Object **flowobjs = NULL;
EmissionMap *emaps = NULL;
@@ -2178,7 +2180,7 @@ static void update_flowsfluids(Scene *scene, Object *ob, SmokeDomainSettings *sd
else { /* MOD_SMOKE_FLOW_SOURCE_MESH */
/* update flow object frame */
BLI_mutex_lock(&object_update_lock);
- BKE_object_modifier_update_subframe(scene, collob, true, 5, BKE_scene_frame_get(scene), eModifierType_Smoke);
+ BKE_object_modifier_update_subframe(eval_ctx, scene, collob, true, 5, BKE_scene_frame_get(scene), eModifierType_Smoke);
BLI_mutex_unlock(&object_update_lock);
/* apply flow */
@@ -2487,12 +2489,12 @@ static void update_effectors_task_cb(void *userdata, const int x)
}
}
-static void update_effectors(Scene *scene, Object *ob, SmokeDomainSettings *sds, float UNUSED(dt))
+static void update_effectors(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, SmokeDomainSettings *sds, float UNUSED(dt))
{
ListBase *effectors;
/* make sure smoke flow influence is 0.0f */
sds->effector_weights->weight[PFIELD_SMOKEFLOW] = 0.0f;
- effectors = pdInitEffectors(scene, ob, NULL, sds->effector_weights, true);
+ effectors = pdInitEffectors(eval_ctx, scene, ob, NULL, sds->effector_weights, true);
if (effectors) {
// precalculate wind forces
@@ -2516,7 +2518,7 @@ static void update_effectors(Scene *scene, Object *ob, SmokeDomainSettings *sds,
pdEndEffectors(&effectors);
}
-static void step(Scene *scene, Object *ob, SmokeModifierData *smd, DerivedMesh *domain_dm, float fps)
+static void step(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, SmokeModifierData *smd, DerivedMesh *domain_dm, float fps)
{
SmokeDomainSettings *sds = smd->domain;
/* stability values copied from wturbulence.cpp */
@@ -2586,11 +2588,11 @@ static void step(Scene *scene, Object *ob, SmokeModifierData *smd, DerivedMesh *
for (substep = 0; substep < totalSubsteps; substep++)
{
// calc animated obstacle velocities
- update_flowsfluids(scene, ob, sds, dtSubdiv);
+ update_flowsfluids(eval_ctx, scene, ob, sds, dtSubdiv);
update_obstacles(scene, ob, sds, dtSubdiv, substep, totalSubsteps);
if (sds->total_cells > 1) {
- update_effectors(scene, ob, sds, dtSubdiv); // DG TODO? problem --> uses forces instead of velocity, need to check how they need to be changed with variable dt
+ update_effectors(eval_ctx, scene, ob, sds, dtSubdiv); // DG TODO? problem --> uses forces instead of velocity, need to check how they need to be changed with variable dt
smoke_step(sds->fluid, gravity, dtSubdiv);
}
}
@@ -2683,7 +2685,8 @@ static DerivedMesh *createDomainGeometry(SmokeDomainSettings *sds, Object *ob)
return result;
}
-static void smokeModifier_process(SmokeModifierData *smd, Scene *scene, SceneLayer *sl, Object *ob, DerivedMesh *dm)
+static void smokeModifier_process(
+ SmokeModifierData *smd, const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, DerivedMesh *dm)
{
if ((smd->type & MOD_SMOKE_TYPE_FLOW))
{
@@ -2692,7 +2695,6 @@ static void smokeModifier_process(SmokeModifierData *smd, Scene *scene, SceneLay
if (smd->flow->dm) smd->flow->dm->release(smd->flow->dm);
smd->flow->dm = CDDM_copy(dm);
- DM_ensure_looptri(smd->flow->dm);
if (scene->r.cfra > smd->time)
{
@@ -2715,7 +2717,6 @@ static void smokeModifier_process(SmokeModifierData *smd, Scene *scene, SceneLay
smd->coll->dm->release(smd->coll->dm);
smd->coll->dm = CDDM_copy(dm);
- DM_ensure_looptri(smd->coll->dm);
}
smd->time = scene->r.cfra;
@@ -2806,11 +2807,11 @@ static void smokeModifier_process(SmokeModifierData *smd, Scene *scene, SceneLay
}
- step(scene, ob, smd, dm, scene->r.frs_sec / scene->r.frs_sec_base);
+ step(eval_ctx, scene, ob, smd, dm, scene->r.frs_sec / scene->r.frs_sec_base);
}
// create shadows before writing cache so they get stored
- smoke_calc_transparency(sds, sl);
+ smoke_calc_transparency(sds, eval_ctx->scene_layer);
if (sds->wt && sds->total_cells > 1) {
smoke_turbulence_step(sds->wt, sds->fluid);
@@ -2827,13 +2828,14 @@ static void smokeModifier_process(SmokeModifierData *smd, Scene *scene, SceneLay
}
}
-struct DerivedMesh *smokeModifier_do(SmokeModifierData *smd, Scene *scene, SceneLayer *sl, Object *ob, DerivedMesh *dm)
+struct DerivedMesh *smokeModifier_do(
+ SmokeModifierData *smd, const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, DerivedMesh *dm)
{
/* lock so preview render does not read smoke data while it gets modified */
if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain)
BLI_rw_mutex_lock(smd->domain->fluid_mutex, THREAD_LOCK_WRITE);
- smokeModifier_process(smd, scene, sl, ob, dm);
+ smokeModifier_process(smd, eval_ctx, scene, ob, dm);
if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain)
BLI_rw_mutex_unlock(smd->domain->fluid_mutex);
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index 0b8c11f6dc8..1ba8fe83971 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -81,6 +81,8 @@ variables on the UI for now
#include "BKE_mesh.h"
#include "BKE_scene.h"
+#include "DEG_depsgraph.h"
+
#include "PIL_time.h"
/* callbacks for errors and interrupts and some goo */
@@ -530,7 +532,7 @@ static void ccd_build_deflector_hash(SceneLayer *sl, Group *group, Object *verte
}
}
else {
- for (Base *base = FIRSTBASE_NEW; base; base = base->next) {
+ for (Base *base = FIRSTBASE_NEW(sl); base; base = base->next) {
/*Only proceed for mesh object in same layer */
if (base->object->type == OB_MESH) {
ob = base->object;
@@ -576,7 +578,7 @@ static void ccd_update_deflector_hash(SceneLayer *sl, Group *group, Object *vert
}
}
else {
- for (Base *base = FIRSTBASE_NEW; base; base = base->next) {
+ for (Base *base = FIRSTBASE_NEW(sl); base; base = base->next) {
/*Only proceed for mesh object in same layer */
if (base->object->type == OB_MESH) {
ob = base->object;
@@ -986,7 +988,7 @@ static bool are_there_deflectors(SceneLayer *sl, Group *group)
}
}
else {
- for (Base *base = FIRSTBASE_NEW; base; base = base->next) {
+ for (Base *base = FIRSTBASE_NEW(sl); base; base = base->next) {
if (base->object->pd) {
if (base->object->pd->deflect)
return 1;
@@ -1544,12 +1546,12 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow,
}
-static void scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow)
+static void scan_for_ext_spring_forces(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float timenow)
{
SoftBody *sb = ob->soft;
ListBase *do_effector = NULL;
- do_effector = pdInitEffectors(scene, ob, NULL, sb->effector_weights, true);
+ do_effector = pdInitEffectors(eval_ctx, scene, ob, NULL, sb->effector_weights, true);
_scan_for_ext_spring_forces(scene, ob, timenow, 0, sb->totspring, do_effector);
pdEndEffectors(&do_effector);
}
@@ -1561,7 +1563,7 @@ static void *exec_scan_for_ext_spring_forces(void *data)
return NULL;
}
-static void sb_sfesf_threads_run(Scene *scene, struct Object *ob, float timenow, int totsprings, int *UNUSED(ptr_to_break_func(void)))
+static void sb_sfesf_threads_run(const struct EvaluationContext *eval_ctx, Scene *scene, struct Object *ob, float timenow, int totsprings, int *UNUSED(ptr_to_break_func(void)))
{
ListBase *do_effector = NULL;
ListBase threads;
@@ -1569,7 +1571,7 @@ static void sb_sfesf_threads_run(Scene *scene, struct Object *ob, float timenow,
int i, totthread, left, dec;
int lowsprings =100; /* wild guess .. may increase with better thread management 'above' or even be UI option sb->spawn_cf_threads_nopts */
- do_effector= pdInitEffectors(scene, ob, NULL, ob->soft->effector_weights, true);
+ do_effector= pdInitEffectors(eval_ctx, scene, ob, NULL, ob->soft->effector_weights, true);
/* figure the number of threads while preventing pretty pointless threading overhead */
totthread= BKE_scene_num_threads(scene);
@@ -2233,7 +2235,7 @@ static void sb_cf_threads_run(Scene *scene, Object *ob, float forcetime, float t
MEM_freeN(sb_threads);
}
-static void softbody_calc_forcesEx(Scene *scene, SceneLayer *sl, Object *ob, float forcetime, float timenow)
+static void softbody_calc_forcesEx(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float forcetime, float timenow)
{
/* rule we never alter free variables :bp->vec bp->pos in here !
* this will ruin adaptive stepsize AKA heun! (BM)
@@ -2249,7 +2251,7 @@ static void softbody_calc_forcesEx(Scene *scene, SceneLayer *sl, Object *ob, flo
/* gravity = sb->grav * sb_grav_force_scale(ob); */ /* UNUSED */
/* check conditions for various options */
- do_deflector= query_external_colliders(sl, sb->collision_group);
+ do_deflector= query_external_colliders(eval_ctx->scene_layer, sb->collision_group);
/* do_selfcollision=((ob->softflag & OB_SB_EDGES) && (sb->bspring)&& (ob->softflag & OB_SB_SELF)); */ /* UNUSED */
do_springcollision=do_deflector && (ob->softflag & OB_SB_EDGES) &&(ob->softflag & OB_SB_EDGECOLL);
do_aero=((sb->aeroedge)&& (ob->softflag & OB_SB_EDGES));
@@ -2258,10 +2260,10 @@ static void softbody_calc_forcesEx(Scene *scene, SceneLayer *sl, Object *ob, flo
/* bproot= sb->bpoint; */ /* need this for proper spring addressing */ /* UNUSED */
if (do_springcollision || do_aero)
- sb_sfesf_threads_run(scene, ob, timenow, sb->totspring, NULL);
+ sb_sfesf_threads_run(eval_ctx, scene, ob, timenow, sb->totspring, NULL);
/* after spring scan because it uses Effoctors too */
- do_effector= pdInitEffectors(scene, ob, NULL, sb->effector_weights, true);
+ do_effector= pdInitEffectors(eval_ctx, scene, ob, NULL, sb->effector_weights, true);
if (do_deflector) {
float defforce[3];
@@ -2278,11 +2280,11 @@ static void softbody_calc_forcesEx(Scene *scene, SceneLayer *sl, Object *ob, flo
}
-static void softbody_calc_forces(Scene *scene, SceneLayer *sl, Object *ob, float forcetime, float timenow)
+static void softbody_calc_forces(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float forcetime, float timenow)
{
/* redirection to the new threaded Version */
if (!(G.debug_value & 0x10)) { // 16
- softbody_calc_forcesEx(scene, sl, ob, forcetime, timenow);
+ softbody_calc_forcesEx(eval_ctx, scene, ob, forcetime, timenow);
return;
}
else {
@@ -2313,7 +2315,7 @@ static void softbody_calc_forces(Scene *scene, SceneLayer *sl, Object *ob, float
}
/* check conditions for various options */
- do_deflector= query_external_colliders(sl, sb->collision_group);
+ do_deflector= query_external_colliders(eval_ctx->scene_layer, sb->collision_group);
do_selfcollision=((ob->softflag & OB_SB_EDGES) && (sb->bspring)&& (ob->softflag & OB_SB_SELF));
do_springcollision=do_deflector && (ob->softflag & OB_SB_EDGES) &&(ob->softflag & OB_SB_EDGECOLL);
do_aero=((sb->aeroedge)&& (ob->softflag & OB_SB_EDGES));
@@ -2321,9 +2323,9 @@ static void softbody_calc_forces(Scene *scene, SceneLayer *sl, Object *ob, float
iks = 1.0f/(1.0f-sb->inspring)-1.0f ;/* inner spring constants function */
/* bproot= sb->bpoint; */ /* need this for proper spring addressing */ /* UNUSED */
- if (do_springcollision || do_aero) scan_for_ext_spring_forces(scene, ob, timenow);
+ if (do_springcollision || do_aero) scan_for_ext_spring_forces(eval_ctx, scene, ob, timenow);
/* after spring scan because it uses Effoctors too */
- do_effector= pdInitEffectors(scene, ob, NULL, ob->soft->effector_weights, true);
+ do_effector= pdInitEffectors(eval_ctx, scene, ob, NULL, ob->soft->effector_weights, true);
if (do_deflector) {
float defforce[3];
@@ -3412,7 +3414,7 @@ static void softbody_update_positions(Object *ob, SoftBody *sb, float (*vertexCo
* lloc, lrot, lscale are allowed to be NULL, just in case you don't need it.
* should be pretty useful for pythoneers :)
* not! velocity .. 2nd order stuff
- * vcloud_estimate_transform see
+ * vcloud_estimate_transform_v3 see
*/
void SB_estimate_transform(Object *ob, float lloc[3], float lrot[3][3], float lscale[3][3])
@@ -3436,7 +3438,7 @@ void SB_estimate_transform(Object *ob, float lloc[3], float lrot[3][3], float ls
copy_v3_v3(opos[a], bp->pos);
}
- vcloud_estimate_transform(sb->totpoint, opos, NULL, rpos, NULL, com, rcom, lrot, lscale);
+ vcloud_estimate_transform_v3(sb->totpoint, opos, NULL, rpos, NULL, com, rcom, lrot, lscale);
//sub_v3_v3(com, rcom);
if (lloc) copy_v3_v3(lloc, com);
copy_v3_v3(sb->lcom, com);
@@ -3510,7 +3512,7 @@ static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int
}
}
-static void softbody_step(Scene *scene, SceneLayer *sl, Object *ob, SoftBody *sb, float dtime)
+static void softbody_step(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, SoftBody *sb, float dtime)
{
/* the simulator */
float forcetime;
@@ -3524,11 +3526,11 @@ static void softbody_step(Scene *scene, SceneLayer *sl, Object *ob, SoftBody *sb
*/
if (dtime < 0 || dtime > 10.5f) return;
- ccd_update_deflector_hash(sl, sb->collision_group, ob, sb->scratch->colliderhash);
+ ccd_update_deflector_hash(eval_ctx->scene_layer, sb->collision_group, ob, sb->scratch->colliderhash);
if (sb->scratch->needstobuildcollider) {
- if (query_external_colliders(sl, sb->collision_group)) {
- ccd_build_deflector_hash(sl, sb->collision_group, ob, sb->scratch->colliderhash);
+ if (query_external_colliders(eval_ctx->scene_layer, sb->collision_group)) {
+ ccd_build_deflector_hash(eval_ctx->scene_layer, sb->collision_group, ob, sb->scratch->colliderhash);
}
sb->scratch->needstobuildcollider=0;
}
@@ -3558,12 +3560,12 @@ static void softbody_step(Scene *scene, SceneLayer *sl, Object *ob, SoftBody *sb
sb->scratch->flag &= ~SBF_DOFUZZY;
/* do predictive euler step */
- softbody_calc_forces(scene, sl, ob, forcetime, timedone/dtime);
+ softbody_calc_forces(eval_ctx, scene, ob, forcetime, timedone/dtime);
softbody_apply_forces(ob, forcetime, 1, NULL, mid_flags);
/* crop new slope values to do averaged slope step */
- softbody_calc_forces(scene, sl, ob, forcetime, timedone/dtime);
+ softbody_calc_forces(eval_ctx, scene, ob, forcetime, timedone/dtime);
softbody_apply_forces(ob, forcetime, 2, &err, mid_flags);
softbody_apply_goalsnap(ob);
@@ -3644,7 +3646,7 @@ static void softbody_step(Scene *scene, SceneLayer *sl, Object *ob, SoftBody *sb
}
/* simulates one step. framenr is in frames */
-void sbObjectStep(Scene *scene, SceneLayer *sl, Object *ob, float cfra, float (*vertexCos)[3], int numVerts)
+void sbObjectStep(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], int numVerts)
{
SoftBody *sb= ob->soft;
PointCache *cache;
@@ -3759,7 +3761,7 @@ void sbObjectStep(Scene *scene, SceneLayer *sl, Object *ob, float cfra, float (*
dtime = framedelta*timescale;
/* do simulation */
- softbody_step(scene, sl, ob, sb, dtime);
+ softbody_step(eval_ctx, scene, ob, sb, dtime);
softbody_to_object(ob, vertexCos, numVerts, 0);
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index 8469351c54a..a2568707b0a 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -48,13 +48,11 @@
#include "DNA_speaker_types.h"
#ifdef WITH_AUDASPACE
-# include AUD_SOUND_H
-# include AUD_SEQUENCE_H
-# include AUD_HANDLE_H
-# include AUD_SPECIAL_H
-# ifdef WITH_SYSTEM_AUDASPACE
-# include "../../../intern/audaspace/intern/AUD_Set.h"
-# endif
+# include <AUD_Sound.h>
+# include <AUD_Sequence.h>
+# include <AUD_Handle.h>
+# include <AUD_Special.h>
+# include "../../../intern/audaspace/intern/AUD_Set.h"
#endif
#include "BKE_global.h"
@@ -83,7 +81,7 @@ bSound *BKE_sound_new_file(struct Main *bmain, const char *filepath)
BLI_path_abs(str, path);
- sound = BKE_libblock_alloc(bmain, ID_SO, BLI_path_basename(filepath));
+ sound = BKE_libblock_alloc(bmain, ID_SO, BLI_path_basename(filepath), 0);
BLI_strncpy(sound->name, filepath, FILE_MAX);
/* sound->type = SOUND_TYPE_FILE; */ /* XXX unused currently */
@@ -155,6 +153,34 @@ void BKE_sound_free(bSound *sound)
}
}
+/**
+ * Only copy internal data of Sound ID from source to already allocated/initialized destination.
+ * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
+ *
+ * WARNING! This function will not handle ID user count!
+ *
+ * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
+ */
+void BKE_sound_copy_data(Main *bmain, bSound *sound_dst, const bSound *UNUSED(sound_src), const int UNUSED(flag))
+{
+ sound_dst->handle = NULL;
+ sound_dst->cache = NULL;
+ sound_dst->waveform = NULL;
+ sound_dst->playback_handle = NULL;
+ sound_dst->spinlock = NULL; /* Think this is OK? Otherwise, easy to create new spinlock here... */
+
+ /* Just to be sure, should not have any value actually after reading time. */
+ sound_dst->ipo = NULL;
+ sound_dst->newpackedfile = NULL;
+
+ if (sound_dst->packedfile) {
+ sound_dst->packedfile = dupPackedFile(sound_dst->packedfile);
+ }
+
+ /* Initialize whole runtime (audaspace) stuff. */
+ BKE_sound_load(bmain, sound_dst);
+}
+
void BKE_sound_make_local(Main *bmain, bSound *sound, const bool lib_local)
{
BKE_id_make_local_generic(bmain, &sound->id, true, lib_local);
@@ -200,7 +226,7 @@ void BKE_sound_init_once(void)
atexit(BKE_sound_exit_once);
}
-static AUD_Device *sound_device;
+static AUD_Device *sound_device = NULL;
void *BKE_sound_get_device(void)
{
@@ -209,6 +235,9 @@ void *BKE_sound_get_device(void)
void BKE_sound_init(struct Main *bmain)
{
+ /* Make sure no instance of the sound system is running, otherwise we get leaks. */
+ BKE_sound_exit();
+
AUD_DeviceSpecs specs;
int device, buffersize;
const char *device_name;
@@ -274,7 +303,6 @@ void BKE_sound_exit_once(void)
sound_device = NULL;
AUD_exitOnce();
-#ifdef WITH_SYSTEM_AUDASPACE
if (audio_device_names != NULL) {
int i;
for (i = 0; audio_device_names[i]; i++) {
@@ -283,7 +311,6 @@ void BKE_sound_exit_once(void)
free(audio_device_names);
audio_device_names = NULL;
}
-#endif
}
/* XXX unused currently */
@@ -879,28 +906,12 @@ float BKE_sound_get_length(bSound *sound)
char **BKE_sound_get_device_names(void)
{
if (audio_device_names == NULL) {
-#ifdef WITH_SYSTEM_AUDASPACE
audio_device_names = AUD_getDeviceNames();
-#else
- static const char *names[] = {
- "Null", "SDL", "OpenAL", "JACK", NULL
- };
- audio_device_names = (char **)names;
-#endif
}
return audio_device_names;
}
-bool BKE_sound_is_jack_supported(void)
-{
-#ifdef WITH_SYSTEM_AUDASPACE
- return 1;
-#else
- return (bool)AUD_isJackSupported();
-#endif
-}
-
#else /* WITH_AUDASPACE */
#include "BLI_utildefines.h"
@@ -947,5 +958,6 @@ void BKE_sound_set_scene_sound_pan(void *UNUSED(handle), float UNUSED(pan), char
void BKE_sound_set_scene_volume(struct Scene *UNUSED(scene), float UNUSED(volume)) {}
void BKE_sound_set_scene_sound_pitch(void *UNUSED(handle), float UNUSED(pitch), char UNUSED(animated)) {}
float BKE_sound_get_length(struct bSound *UNUSED(sound)) { return 0; }
-bool BKE_sound_is_jack_supported(void) { return false; }
+char **BKE_sound_get_device_names(void) { static char *names[1] = {NULL}; return names; }
+
#endif /* WITH_AUDASPACE */
diff --git a/source/blender/blenkernel/intern/speaker.c b/source/blender/blenkernel/intern/speaker.c
index d00e4b1a0d2..9d604a9382a 100644
--- a/source/blender/blenkernel/intern/speaker.c
+++ b/source/blender/blenkernel/intern/speaker.c
@@ -61,25 +61,31 @@ void *BKE_speaker_add(Main *bmain, const char *name)
{
Speaker *spk;
- spk = BKE_libblock_alloc(bmain, ID_SPK, name);
+ spk = BKE_libblock_alloc(bmain, ID_SPK, name, 0);
BKE_speaker_init(spk);
return spk;
}
-Speaker *BKE_speaker_copy(Main *bmain, const Speaker *spk)
+/**
+ * Only copy internal data of Speaker ID from source to already allocated/initialized destination.
+ * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
+ *
+ * WARNING! This function will not handle ID user count!
+ *
+ * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
+ */
+void BKE_speaker_copy_data(Main *UNUSED(bmain), Speaker *UNUSED(spk_dst), const Speaker *UNUSED(spk_src), const int UNUSED(flag))
{
- Speaker *spkn;
-
- spkn = BKE_libblock_copy(bmain, &spk->id);
-
- if (spkn->sound)
- id_us_plus(&spkn->sound->id);
-
- BKE_id_copy_ensure_local(bmain, &spk->id, &spkn->id);
+ /* Nothing to do! */
+}
- return spkn;
+Speaker *BKE_speaker_copy(Main *bmain, const Speaker *spk)
+{
+ Speaker *spk_copy;
+ BKE_id_copy_ex(bmain, &spk->id, (ID **)&spk_copy, 0, false);
+ return spk_copy;
}
void BKE_speaker_make_local(Main *bmain, Speaker *spk, const bool lib_local)
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index 1f72744bdee..d461e03fcda 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -42,6 +42,8 @@
#include <math.h>
#include <float.h>
+#include "atomic_ops.h"
+
#include "MEM_guardedalloc.h"
#include "DNA_mesh_types.h"
@@ -2197,12 +2199,12 @@ static void ccgDM_buffer_copy_color(
for (S = 0; S < numVerts; S++) {
for (y = 0; y < gridFaces; y++) {
for (x = 0; x < gridFaces; x++) {
- copy_v3_v3_uchar(&varray[start + 0], &mloopcol[iface * 16 + 0]);
- copy_v3_v3_uchar(&varray[start + 3], &mloopcol[iface * 16 + 12]);
- copy_v3_v3_uchar(&varray[start + 6], &mloopcol[iface * 16 + 8]);
- copy_v3_v3_uchar(&varray[start + 9], &mloopcol[iface * 16 + 4]);
+ copy_v4_v4_uchar(&varray[start + 0], &mloopcol[iface * 16 + 0]);
+ copy_v4_v4_uchar(&varray[start + 4], &mloopcol[iface * 16 + 12]);
+ copy_v4_v4_uchar(&varray[start + 8], &mloopcol[iface * 16 + 8]);
+ copy_v4_v4_uchar(&varray[start + 12], &mloopcol[iface * 16 + 4]);
- start += 12;
+ start += 16;
iface++;
}
}
@@ -3427,6 +3429,11 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
int gridFaces = gridSize - 1, totface;
int prev_mat_nr = -1;
+ if (ccgdm->pbvh) {
+ if (G.debug_value == 14)
+ BKE_pbvh_draw_BB(ccgdm->pbvh);
+ }
+
#ifdef WITH_OPENSUBDIV
if (ccgdm->useGpuBackend) {
int new_matnr;
@@ -3537,16 +3544,16 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
float *c = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 1);
float *d = CCG_grid_elem_co(&key, faceGridData, x, y + 1);
- if (cp) glColor3ubv(&cp[4]);
+ if (cp) glColor4ubv(&cp[4]);
glNormal3fv(ln[1]);
glVertex3fv(d);
- if (cp) glColor3ubv(&cp[8]);
+ if (cp) glColor4ubv(&cp[8]);
glNormal3fv(ln[2]);
glVertex3fv(c);
- if (cp) glColor3ubv(&cp[12]);
+ if (cp) glColor4ubv(&cp[12]);
glNormal3fv(ln[3]);
glVertex3fv(b);
- if (cp) glColor3ubv(&cp[0]);
+ if (cp) glColor4ubv(&cp[0]);
glNormal3fv(ln[0]);
glVertex3fv(a);
@@ -3564,10 +3571,10 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
a = CCG_grid_elem(&key, faceGridData, x, y + 0);
b = CCG_grid_elem(&key, faceGridData, x, y + 1);
- if (cp) glColor3ubv(&cp[0]);
+ if (cp) glColor4ubv(&cp[0]);
glNormal3fv(CCG_elem_no(&key, a));
glVertex3fv(CCG_elem_co(&key, a));
- if (cp) glColor3ubv(&cp[4]);
+ if (cp) glColor4ubv(&cp[4]);
glNormal3fv(CCG_elem_no(&key, b));
glVertex3fv(CCG_elem_co(&key, b));
@@ -3579,10 +3586,10 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
a = CCG_grid_elem(&key, faceGridData, x, y + 0);
b = CCG_grid_elem(&key, faceGridData, x, y + 1);
- if (cp) glColor3ubv(&cp[12]);
+ if (cp) glColor4ubv(&cp[12]);
glNormal3fv(CCG_elem_no(&key, a));
glVertex3fv(CCG_elem_co(&key, a));
- if (cp) glColor3ubv(&cp[8]);
+ if (cp) glColor4ubv(&cp[8]);
glNormal3fv(CCG_elem_no(&key, b));
glVertex3fv(CCG_elem_co(&key, b));
@@ -3602,13 +3609,13 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
ccgDM_glNormalFast(a, b, c, d);
- if (cp) glColor3ubv(&cp[4]);
+ if (cp) glColor4ubv(&cp[4]);
glVertex3fv(d);
- if (cp) glColor3ubv(&cp[8]);
+ if (cp) glColor4ubv(&cp[8]);
glVertex3fv(c);
- if (cp) glColor3ubv(&cp[12]);
+ if (cp) glColor4ubv(&cp[12]);
glVertex3fv(b);
- if (cp) glColor3ubv(&cp[0]);
+ if (cp) glColor4ubv(&cp[0]);
glVertex3fv(a);
if (cp) cp += 16;
@@ -4160,7 +4167,8 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
if (!ob->sculpt)
return NULL;
- grid_pbvh = ccgDM_use_grid_pbvh(ccgdm);
+ /* In vwpaint, we always use a grid_pbvh for multires/subsurf */
+ grid_pbvh = (!(ob->mode & OB_MODE_SCULPT) || ccgDM_use_grid_pbvh(ccgdm));
if (ob->sculpt->pbvh) {
if (grid_pbvh) {
@@ -4176,12 +4184,18 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
ccgdm->pbvh = ob->sculpt->pbvh;
}
- if (ccgdm->pbvh)
+ if (ccgdm->pbvh) {
+ /* For vertex paint, keep track of ccgdm */
+ if (!(ob->mode & OB_MODE_SCULPT)) {
+ BKE_pbvh_set_ccgdm(ccgdm->pbvh, ccgdm);
+ }
return ccgdm->pbvh;
+ }
/* no pbvh exists yet, we need to create one. only in case of multires
* we build a pbvh over the modified mesh, in other cases the base mesh
* is being sculpted, so we build a pbvh from that. */
+ /* Note: vwpaint always builds a pbvh over the modified mesh. */
if (grid_pbvh) {
ccgdm_create_grids(dm);
@@ -4212,6 +4226,10 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
if (ccgdm->pbvh)
pbvh_show_diffuse_color_set(ccgdm->pbvh, ob->sculpt->show_diffuse_color);
+ /* For vertex paint, keep track of ccgdm */
+ if (!(ob->mode & OB_MODE_SCULPT) && ccgdm->pbvh) {
+ BKE_pbvh_set_ccgdm(ccgdm->pbvh, ccgdm);
+ }
return ccgdm->pbvh;
}
@@ -4220,16 +4238,17 @@ static void ccgDM_recalcTessellation(DerivedMesh *UNUSED(dm))
/* Nothing to do: CCG handles creating its own tessfaces */
}
+/* WARNING! *MUST* be called in an 'loops_cache_rwlock' protected thread context! */
static void ccgDM_recalcLoopTri(DerivedMesh *dm)
{
- BLI_rw_mutex_lock(&loops_cache_rwlock, THREAD_LOCK_WRITE);
- MLoopTri *mlooptri;
+ MLoopTri *mlooptri = dm->looptris.array;
const int tottri = dm->numPolyData * 2;
int i, poly_index;
DM_ensure_looptri_data(dm);
- mlooptri = dm->looptris.array;
+ mlooptri = dm->looptris.array_wip;
+ BLI_assert(tottri == 0 || mlooptri != NULL);
BLI_assert(poly_to_tri_count(dm->numPolyData, dm->numLoopData) == dm->looptris.num);
BLI_assert(tottri == dm->looptris.num);
@@ -4248,19 +4267,10 @@ static void ccgDM_recalcLoopTri(DerivedMesh *dm)
lt->tri[2] = (poly_index * 4) + 2;
lt->poly = poly_index;
}
- BLI_rw_mutex_unlock(&loops_cache_rwlock);
-}
-
-static const MLoopTri *ccgDM_getLoopTriArray(DerivedMesh *dm)
-{
- if (dm->looptris.array) {
- BLI_assert(poly_to_tri_count(dm->numPolyData, dm->numLoopData) == dm->looptris.num);
- }
- else {
- dm->recalcLoopTri(dm);
- }
- return dm->looptris.array;
+ BLI_assert(dm->looptris.array == NULL);
+ atomic_cas_ptr((void **)&dm->looptris.array, dm->looptris.array, dm->looptris.array_wip);
+ dm->looptris.array_wip = NULL;
}
static void ccgDM_calcNormals(DerivedMesh *dm)
@@ -4279,8 +4289,6 @@ static void set_default_ccgdm_callbacks(CCGDerivedMesh *ccgdm)
ccgdm->dm.getNumPolys = ccgDM_getNumPolys;
ccgdm->dm.getNumTessFaces = ccgDM_getNumTessFaces;
- ccgdm->dm.getLoopTriArray = ccgDM_getLoopTriArray;
-
ccgdm->dm.getVert = ccgDM_getFinalVert;
ccgdm->dm.getEdge = ccgDM_getFinalEdge;
ccgdm->dm.getTessFace = ccgDM_getFinalFace;
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index 9444e605e6d..4ae9818f891 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -223,7 +223,7 @@ Text *BKE_text_add(Main *bmain, const char *name)
{
Text *ta;
- ta = BKE_libblock_alloc(bmain, ID_TXT, name);
+ ta = BKE_libblock_alloc(bmain, ID_TXT, name, 0);
BKE_text_init(ta);
@@ -409,7 +409,7 @@ Text *BKE_text_load_ex(Main *bmain, const char *file, const char *relpath, const
return false;
}
- ta = BKE_libblock_alloc(bmain, ID_TXT, BLI_path_basename(filepath_abs));
+ ta = BKE_libblock_alloc(bmain, ID_TXT, BLI_path_basename(filepath_abs), 0);
ta->id.us = 0;
BLI_listbase_clear(&ta->lines);
@@ -448,53 +448,49 @@ Text *BKE_text_load(Main *bmain, const char *file, const char *relpath)
return BKE_text_load_ex(bmain, file, relpath, false);
}
-Text *BKE_text_copy(Main *bmain, const Text *ta)
+/**
+ * Only copy internal data of Text ID from source to already allocated/initialized destination.
+ * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
+ *
+ * WARNING! This function will not handle ID user count!
+ *
+ * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
+ */
+void BKE_text_copy_data(Main *UNUSED(bmain), Text *ta_dst, const Text *ta_src, const int UNUSED(flag))
{
- Text *tan;
- TextLine *line, *tmp;
-
- tan = BKE_libblock_copy(bmain, &ta->id);
-
/* file name can be NULL */
- if (ta->name) {
- tan->name = BLI_strdup(ta->name);
- }
- else {
- tan->name = NULL;
+ if (ta_src->name) {
+ ta_dst->name = BLI_strdup(ta_src->name);
}
- tan->flags = ta->flags | TXT_ISDIRTY;
-
- BLI_listbase_clear(&tan->lines);
- tan->curl = tan->sell = NULL;
- tan->compiled = NULL;
-
- tan->nlines = ta->nlines;
+ ta_dst->flags |= TXT_ISDIRTY;
+
+ BLI_listbase_clear(&ta_dst->lines);
+ ta_dst->curl = ta_dst->sell = NULL;
+ ta_dst->compiled = NULL;
- line = ta->lines.first;
/* Walk down, reconstructing */
- while (line) {
- tmp = (TextLine *) MEM_mallocN(sizeof(TextLine), "textline");
- tmp->line = MEM_mallocN(line->len + 1, "textline_string");
- tmp->format = NULL;
-
- strcpy(tmp->line, line->line);
+ for (TextLine *line_src = ta_src->lines.first; line_src; line_src = line_src->next) {
+ TextLine *line_dst = MEM_mallocN(sizeof(*line_dst), __func__);
- tmp->len = line->len;
-
- BLI_addtail(&tan->lines, tmp);
-
- line = line->next;
- }
+ line_dst->line = BLI_strdup(line_src->line);
+ line_dst->format = NULL;
+ line_dst->len = line_src->len;
- tan->curl = tan->sell = tan->lines.first;
- tan->curc = tan->selc = 0;
+ BLI_addtail(&ta_dst->lines, line_dst);
+ }
- init_undo_text(tan);
+ ta_dst->curl = ta_dst->sell = ta_dst->lines.first;
+ ta_dst->curc = ta_dst->selc = 0;
- BKE_id_copy_ensure_local(bmain, &ta->id, &tan->id);
+ init_undo_text(ta_dst);
+}
- return tan;
+Text *BKE_text_copy(Main *bmain, const Text *ta)
+{
+ Text *ta_copy;
+ BKE_id_copy_ex(bmain, &ta->id, (ID **)&ta_copy, 0, false);
+ return ta_copy;
}
void BKE_text_make_local(Main *bmain, Text *text, const bool lib_local)
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index 1e0659d3d67..8f0334a4752 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -707,7 +707,7 @@ Tex *BKE_texture_add(Main *bmain, const char *name)
{
Tex *tex;
- tex = BKE_libblock_alloc(bmain, ID_TE, name);
+ tex = BKE_libblock_alloc(bmain, ID_TE, name, 0);
BKE_texture_default(tex);
@@ -846,41 +846,71 @@ MTex *BKE_texture_mtex_add_id(ID *id, int slot)
/* ------------------------------------------------------------------------- */
-Tex *BKE_texture_copy(Main *bmain, const Tex *tex)
+/**
+ * Only copy internal data of Texture ID from source to already allocated/initialized destination.
+ * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
+ *
+ * WARNING! This function will not handle ID user count!
+ *
+ * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
+ */
+void BKE_texture_copy_data(Main *bmain, Tex *tex_dst, const Tex *tex_src, const int flag)
{
- Tex *texn;
-
- texn = BKE_libblock_copy(bmain, &tex->id);
- if (BKE_texture_is_image_user(tex)) {
- id_us_plus((ID *)texn->ima);
+ /* We never handle usercount here for own data. */
+ const int flag_subdata = flag | LIB_ID_CREATE_NO_USER_REFCOUNT;
+
+ if (!BKE_texture_is_image_user(tex_src)) {
+ tex_dst->ima = NULL;
}
- else {
- texn->ima = NULL;
+
+ if (tex_dst->coba) {
+ tex_dst->coba = MEM_dupallocN(tex_dst->coba);
+ }
+ if (tex_dst->env) {
+ tex_dst->env = BKE_texture_envmap_copy(tex_dst->env, flag_subdata);
+ }
+ if (tex_dst->pd) {
+ tex_dst->pd = BKE_texture_pointdensity_copy(tex_dst->pd, flag_subdata);
+ }
+ if (tex_dst->vd) {
+ tex_dst->vd = MEM_dupallocN(tex_dst->vd);
+ }
+ if (tex_dst->ot) {
+ tex_dst->ot = BKE_texture_ocean_copy(tex_dst->ot, flag_subdata);
}
-
- if (texn->coba) texn->coba = MEM_dupallocN(texn->coba);
- if (texn->env) texn->env = BKE_texture_envmap_copy(texn->env);
- if (texn->pd) texn->pd = BKE_texture_pointdensity_copy(texn->pd);
- if (texn->vd) texn->vd = MEM_dupallocN(texn->vd);
- if (texn->ot) texn->ot = BKE_texture_ocean_copy(texn->ot);
- if (tex->nodetree) {
- if (tex->nodetree->execdata) {
- ntreeTexEndExecTree(tex->nodetree->execdata);
+ if (tex_src->nodetree) {
+ if (tex_src->nodetree->execdata) {
+ ntreeTexEndExecTree(tex_src->nodetree->execdata);
}
- texn->nodetree = ntreeCopyTree(bmain, tex->nodetree);
+ BKE_id_copy_ex(bmain, (ID *)tex_src->nodetree, (ID **)&tex_dst->nodetree, flag, false);
}
- BKE_previewimg_id_copy(&texn->id, &tex->id);
-
- BKE_id_copy_ensure_local(bmain, &tex->id, &texn->id);
+ if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0) {
+ BKE_previewimg_id_copy(&tex_dst->id, &tex_src->id);
+ }
+ else {
+ tex_dst->preview = NULL;
+ }
+}
- return texn;
+Tex *BKE_texture_copy(Main *bmain, const Tex *tex)
+{
+ Tex *tex_copy;
+ BKE_id_copy_ex(bmain, &tex->id, (ID **)&tex_copy, 0, false);
+ return tex_copy;
}
/* texture copy without adding to main dbase */
Tex *BKE_texture_localize(Tex *tex)
{
+ /* TODO replace with something like
+ * Tex *tex_copy;
+ * BKE_id_copy_ex(bmain, &tex->id, (ID **)&tex_copy, LIB_ID_COPY_NO_MAIN | LIB_ID_COPY_NO_PREVIEW | LIB_ID_COPY_NO_USER_REFCOUNT, false);
+ * return tex_copy;
+ *
+ * ... Once f*** nodes are fully converted to that too :( */
+
Tex *texn;
texn = BKE_libblock_copy_nolib(&tex->id, false);
@@ -889,17 +919,17 @@ Tex *BKE_texture_localize(Tex *tex)
if (texn->coba) texn->coba = MEM_dupallocN(texn->coba);
if (texn->env) {
- texn->env = BKE_texture_envmap_copy(texn->env);
+ texn->env = BKE_texture_envmap_copy(texn->env, LIB_ID_CREATE_NO_USER_REFCOUNT);
id_us_min(&texn->env->ima->id);
}
- if (texn->pd) texn->pd = BKE_texture_pointdensity_copy(texn->pd);
+ if (texn->pd) texn->pd = BKE_texture_pointdensity_copy(texn->pd, LIB_ID_CREATE_NO_USER_REFCOUNT);
if (texn->vd) {
texn->vd = MEM_dupallocN(texn->vd);
if (texn->vd->dataset)
texn->vd->dataset = MEM_dupallocN(texn->vd->dataset);
}
if (texn->ot) {
- texn->ot = BKE_texture_ocean_copy(tex->ot);
+ texn->ot = BKE_texture_ocean_copy(tex->ot, LIB_ID_CREATE_NO_USER_REFCOUNT);
}
texn->preview = NULL;
@@ -1099,6 +1129,8 @@ void set_active_mtex(ID *id, short act)
case ID_PA:
((ParticleSettings *)id)->texact = act;
break;
+ default:
+ break;
}
}
@@ -1263,16 +1295,20 @@ EnvMap *BKE_texture_envmap_add(void)
/* ------------------------------------------------------------------------- */
-EnvMap *BKE_texture_envmap_copy(const EnvMap *env)
+EnvMap *BKE_texture_envmap_copy(const EnvMap *env, const int flag)
{
EnvMap *envn;
int a;
envn = MEM_dupallocN(env);
envn->ok = 0;
- for (a = 0; a < 6; a++) envn->cube[a] = NULL;
- if (envn->ima) id_us_plus((ID *)envn->ima);
-
+ for (a = 0; a < 6; a++) {
+ envn->cube[a] = NULL;
+ }
+ if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
+ id_us_plus((ID *)envn->ima);
+ }
+
return envn;
}
@@ -1336,14 +1372,16 @@ PointDensity *BKE_texture_pointdensity_add(void)
return pd;
}
-PointDensity *BKE_texture_pointdensity_copy(const PointDensity *pd)
+PointDensity *BKE_texture_pointdensity_copy(const PointDensity *pd, const int UNUSED(flag))
{
PointDensity *pdn;
pdn = MEM_dupallocN(pd);
pdn->point_tree = NULL;
pdn->point_data = NULL;
- if (pdn->coba) pdn->coba = MEM_dupallocN(pdn->coba);
+ if (pdn->coba) {
+ pdn->coba = MEM_dupallocN(pdn->coba);
+ }
pdn->falloff_curve = curvemapping_copy(pdn->falloff_curve); /* can be NULL */
return pdn;
}
@@ -1430,7 +1468,7 @@ OceanTex *BKE_texture_ocean_add(void)
return ot;
}
-OceanTex *BKE_texture_ocean_copy(const OceanTex *ot)
+OceanTex *BKE_texture_ocean_copy(const OceanTex *ot, const int UNUSED(flag))
{
OceanTex *otn = MEM_dupallocN(ot);
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index 9120d384a16..b4ef381534f 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -190,7 +190,7 @@ void BKE_tracking_free(MovieTracking *tracking)
}
/* Copy the whole list of tracks. */
-static void tracking_tracks_copy(ListBase *tracks_dst, const ListBase *tracks_src, GHash *tracks_mapping)
+static void tracking_tracks_copy(ListBase *tracks_dst, const ListBase *tracks_src, GHash *tracks_mapping, const int flag)
{
MovieTrackingTrack *track_dst, *track_src;
@@ -202,7 +202,9 @@ static void tracking_tracks_copy(ListBase *tracks_dst, const ListBase *tracks_sr
if (track_src->markers) {
track_dst->markers = MEM_dupallocN(track_src->markers);
}
- id_us_plus(&track_dst->gpd->id);
+ if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
+ id_us_plus(&track_dst->gpd->id);
+ }
BLI_addtail(tracks_dst, track_dst);
BLI_ghash_insert(tracks_mapping, track_src, track_dst);
}
@@ -210,7 +212,8 @@ static void tracking_tracks_copy(ListBase *tracks_dst, const ListBase *tracks_sr
/* copy the whole list of plane tracks (need whole MovieTracking structures due to embedded pointers to tracks).
* WARNING: implies tracking_[dst/src] and their tracks have already been copied. */
-static void tracking_plane_tracks_copy(ListBase *plane_tracks_dst, const ListBase *plane_tracks_src, GHash *tracks_mapping)
+static void tracking_plane_tracks_copy(
+ ListBase *plane_tracks_dst, const ListBase *plane_tracks_src, GHash *tracks_mapping, const int flag)
{
MovieTrackingPlaneTrack *plane_track_dst, *plane_track_src;
@@ -225,14 +228,17 @@ static void tracking_plane_tracks_copy(ListBase *plane_tracks_dst, const ListBas
for (int i = 0; i < plane_track_dst->point_tracksnr; i++) {
plane_track_dst->point_tracks[i] = BLI_ghash_lookup(tracks_mapping, plane_track_src->point_tracks[i]);
}
- id_us_plus(&plane_track_dst->image->id);
+ if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
+ id_us_plus(&plane_track_dst->image->id);
+ }
BLI_addtail(plane_tracks_dst, plane_track_dst);
}
}
/* Copy reconstruction structure. */
static void tracking_reconstruction_copy(
- MovieTrackingReconstruction *reconstruction_dst, const MovieTrackingReconstruction *reconstruction_src)
+ MovieTrackingReconstruction *reconstruction_dst, const MovieTrackingReconstruction *reconstruction_src,
+ const int UNUSED(flag))
{
*reconstruction_dst = *reconstruction_src;
if (reconstruction_src->cameras) {
@@ -242,23 +248,25 @@ static void tracking_reconstruction_copy(
/* Copy stabilization structure. */
static void tracking_stabilization_copy(
- MovieTrackingStabilization *stabilization_dst, const MovieTrackingStabilization *stabilization_src)
+ MovieTrackingStabilization *stabilization_dst, const MovieTrackingStabilization *stabilization_src,
+ const int UNUSED(flag))
{
*stabilization_dst = *stabilization_src;
}
/* Copy tracking object. */
static void tracking_object_copy(
- MovieTrackingObject *object_dst, const MovieTrackingObject *object_src, GHash *tracks_mapping)
+ MovieTrackingObject *object_dst, const MovieTrackingObject *object_src, GHash *tracks_mapping, const int flag)
{
*object_dst = *object_src;
- tracking_tracks_copy(&object_dst->tracks, &object_src->tracks, tracks_mapping);
- tracking_plane_tracks_copy(&object_dst->plane_tracks, &object_src->plane_tracks, tracks_mapping);
- tracking_reconstruction_copy(&object_dst->reconstruction, &object_src->reconstruction);
+ tracking_tracks_copy(&object_dst->tracks, &object_src->tracks, tracks_mapping, flag);
+ tracking_plane_tracks_copy(&object_dst->plane_tracks, &object_src->plane_tracks, tracks_mapping, flag);
+ tracking_reconstruction_copy(&object_dst->reconstruction, &object_src->reconstruction, flag);
}
/* Copy list of tracking objects. */
-static void tracking_objects_copy(ListBase *objects_dst, const ListBase *objects_src, GHash *tracks_mapping)
+static void tracking_objects_copy(
+ ListBase *objects_dst, const ListBase *objects_src, GHash *tracks_mapping, const int flag)
{
MovieTrackingObject *object_dst, *object_src;
@@ -266,22 +274,22 @@ static void tracking_objects_copy(ListBase *objects_dst, const ListBase *objects
for (object_src = objects_src->first; object_src != NULL; object_src = object_src->next) {
object_dst = MEM_mallocN(sizeof(*object_dst), __func__);
- tracking_object_copy(object_dst, object_src, tracks_mapping);
+ tracking_object_copy(object_dst, object_src, tracks_mapping, flag);
BLI_addtail(objects_dst, object_dst);
}
}
/* Copy tracking structure content. */
-void BKE_tracking_copy(MovieTracking *tracking_dst, const MovieTracking *tracking_src)
+void BKE_tracking_copy(MovieTracking *tracking_dst, const MovieTracking *tracking_src, const int flag)
{
GHash *tracks_mapping = BLI_ghash_ptr_new(__func__);
*tracking_dst = *tracking_src;
- tracking_tracks_copy(&tracking_dst->tracks, &tracking_src->tracks, tracks_mapping);
- tracking_plane_tracks_copy(&tracking_dst->plane_tracks, &tracking_src->plane_tracks, tracks_mapping);
- tracking_reconstruction_copy(&tracking_dst->reconstruction, &tracking_src->reconstruction);
- tracking_stabilization_copy(&tracking_dst->stabilization, &tracking_src->stabilization);
+ tracking_tracks_copy(&tracking_dst->tracks, &tracking_src->tracks, tracks_mapping, flag);
+ tracking_plane_tracks_copy(&tracking_dst->plane_tracks, &tracking_src->plane_tracks, tracks_mapping, flag);
+ tracking_reconstruction_copy(&tracking_dst->reconstruction, &tracking_src->reconstruction, flag);
+ tracking_stabilization_copy(&tracking_dst->stabilization, &tracking_src->stabilization, flag);
if (tracking_src->act_track) {
tracking_dst->act_track = BLI_ghash_lookup(tracks_mapping, tracking_src->act_track);
}
@@ -299,7 +307,7 @@ void BKE_tracking_copy(MovieTracking *tracking_dst, const MovieTracking *trackin
}
/* Warning! Will override tracks_mapping. */
- tracking_objects_copy(&tracking_dst->objects, &tracking_src->objects, tracks_mapping);
+ tracking_objects_copy(&tracking_dst->objects, &tracking_src->objects, tracks_mapping, flag);
/* Those remaining are runtime data, they will be reconstructed as needed, do not bother copying them. */
tracking_dst->dopesheet.ok = false;
diff --git a/source/blender/blenkernel/intern/tracking_auto.c b/source/blender/blenkernel/intern/tracking_auto.c
index 9475925cdda..30981ed8f23 100644
--- a/source/blender/blenkernel/intern/tracking_auto.c
+++ b/source/blender/blenkernel/intern/tracking_auto.c
@@ -312,7 +312,7 @@ AutoTrackContext *BKE_autotrack_context_new(MovieClip *clip,
int num_total_tracks = BLI_listbase_count(tracksbase);
context->tracks =
- MEM_callocN(sizeof(MovieTrackingTrack*) * num_total_tracks,
+ MEM_callocN(sizeof(MovieTrackingTrack *) * num_total_tracks,
"auto track pointers");
context->image_accessor =
@@ -381,7 +381,7 @@ AutoTrackContext *BKE_autotrack_context_new(MovieClip *clip,
bool BKE_autotrack_context_step(AutoTrackContext *context)
{
- int frame_delta = context->backwards ? -1 : 1;
+ const int frame_delta = context->backwards ? -1 : 1;
bool ok = false;
int track;
@@ -395,67 +395,64 @@ bool BKE_autotrack_context_step(AutoTrackContext *context)
libmv_reference_marker,
libmv_tracked_marker;
libmv_TrackRegionResult libmv_result;
- int frame = BKE_movieclip_remap_scene_to_clip_frame(
- context->clips[options->clip_index],
- context->user.framenr);
- bool has_marker;
-
+ const int frame = BKE_movieclip_remap_scene_to_clip_frame(
+ context->clips[options->clip_index],
+ context->user.framenr);
BLI_spin_lock(&context->spin_lock);
- has_marker = libmv_autoTrackGetMarker(context->autotrack,
- options->clip_index,
- frame,
- options->track_index,
- &libmv_current_marker);
+ const bool has_marker = libmv_autoTrackGetMarker(context->autotrack,
+ options->clip_index,
+ frame,
+ options->track_index,
+ &libmv_current_marker);
BLI_spin_unlock(&context->spin_lock);
-
- if (has_marker) {
- if (!tracking_check_marker_margin(&libmv_current_marker,
- options->track->margin,
- context->frame_width,
- context->frame_height))
- {
- continue;
- }
-
- libmv_tracked_marker = libmv_current_marker;
- libmv_tracked_marker.frame = frame + frame_delta;
-
- if (options->use_keyframe_match) {
- libmv_tracked_marker.reference_frame =
- libmv_current_marker.reference_frame;
- libmv_autoTrackGetMarker(context->autotrack,
- options->clip_index,
- libmv_tracked_marker.reference_frame,
- options->track_index,
- &libmv_reference_marker);
- }
- else {
- libmv_tracked_marker.reference_frame = frame;
- libmv_reference_marker = libmv_current_marker;
- }
-
- if (libmv_autoTrackMarker(context->autotrack,
- &options->track_region_options,
- &libmv_tracked_marker,
- &libmv_result))
- {
- BLI_spin_lock(&context->spin_lock);
- libmv_autoTrackAddMarker(context->autotrack,
- &libmv_tracked_marker);
- BLI_spin_unlock(&context->spin_lock);
- }
- else {
- options->is_failed = true;
- options->failed_frame = frame + frame_delta;
- }
- ok = true;
+ /* Check whether we've got marker to sync with. */
+ if (!has_marker) {
+ continue;
+ }
+ /* Check whether marker is going outside of allowed frame margin. */
+ if (!tracking_check_marker_margin(&libmv_current_marker,
+ options->track->margin,
+ context->frame_width,
+ context->frame_height))
+ {
+ continue;
+ }
+ libmv_tracked_marker = libmv_current_marker;
+ libmv_tracked_marker.frame = frame + frame_delta;
+ /* Update reference frame. */
+ if (options->use_keyframe_match) {
+ libmv_tracked_marker.reference_frame =
+ libmv_current_marker.reference_frame;
+ libmv_autoTrackGetMarker(context->autotrack,
+ options->clip_index,
+ libmv_tracked_marker.reference_frame,
+ options->track_index,
+ &libmv_reference_marker);
}
+ else {
+ libmv_tracked_marker.reference_frame = frame;
+ libmv_reference_marker = libmv_current_marker;
+ }
+ /* Perform actual tracking. */
+ if (libmv_autoTrackMarker(context->autotrack,
+ &options->track_region_options,
+ &libmv_tracked_marker,
+ &libmv_result))
+ {
+ BLI_spin_lock(&context->spin_lock);
+ libmv_autoTrackAddMarker(context->autotrack, &libmv_tracked_marker);
+ BLI_spin_unlock(&context->spin_lock);
+ }
+ else {
+ options->is_failed = true;
+ options->failed_frame = frame + frame_delta;
+ }
+ ok = true;
}
-
+ /* Advance the frame. */
BLI_spin_lock(&context->spin_lock);
context->user.framenr += frame_delta;
BLI_spin_unlock(&context->spin_lock);
-
return ok;
}
diff --git a/source/blender/blenkernel/intern/tracking_util.c b/source/blender/blenkernel/intern/tracking_util.c
index a95399562d5..d8e98291117 100644
--- a/source/blender/blenkernel/intern/tracking_util.c
+++ b/source/blender/blenkernel/intern/tracking_util.c
@@ -58,6 +58,15 @@
#include "libmv-capi.h"
+/* Uncomment this to have caching-specific debug prints. */
+// #define DEBUG_CACHE
+
+#ifdef DEBUG_CACHE
+# define CACHE_PRINTF(...) printf(__VA_ARGS__)
+#else
+# define CACHE_PRINTF(...)
+#endif
+
/*********************** Tracks map *************************/
TracksMap *tracks_map_new(const char *object_name, bool is_camera, int num_tracks, int customdata_size)
@@ -523,6 +532,8 @@ typedef struct AccessCacheKey {
int frame;
int downscale;
libmv_InputMode input_mode;
+ bool has_region;
+ float region_min[2], region_max[2];
int64_t transform_key;
} AccessCacheKey;
@@ -537,23 +548,44 @@ static bool accesscache_hashcmp(const void *a_v, const void *b_v)
{
const AccessCacheKey *a = (const AccessCacheKey *) a_v;
const AccessCacheKey *b = (const AccessCacheKey *) b_v;
-
-#define COMPARE_FIELD(field)
- { \
- if (a->clip_index != b->clip_index) { \
- return false; \
- } \
- } (void) 0
-
- COMPARE_FIELD(clip_index);
- COMPARE_FIELD(frame);
- COMPARE_FIELD(downscale);
- COMPARE_FIELD(input_mode);
- COMPARE_FIELD(transform_key);
-
-#undef COMPARE_FIELD
-
- return true;
+ if (a->clip_index != b->clip_index ||
+ a->frame != b->frame ||
+ a->downscale != b->downscale ||
+ a->input_mode != b->input_mode ||
+ a->has_region != b->has_region ||
+ a->transform_key != b->transform_key)
+ {
+ return true;
+ }
+ /* If there is region applied, compare it. */
+ if (a->has_region) {
+ if (!equals_v2v2(a->region_min, b->region_min) ||
+ !equals_v2v2(a->region_max, b->region_max))
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+static void accesscache_construct_key(AccessCacheKey *key,
+ int clip_index,
+ int frame,
+ libmv_InputMode input_mode,
+ int downscale,
+ const libmv_Region *region,
+ int64_t transform_key)
+{
+ key->clip_index = clip_index;
+ key->frame = frame;
+ key->input_mode = input_mode;
+ key->downscale = downscale;
+ key->has_region = (region != NULL);
+ if (key->has_region) {
+ copy_v2_v2(key->region_min, region->min);
+ copy_v2_v2(key->region_max, region->max);
+ }
+ key->transform_key = transform_key;
}
static void accesscache_put(TrackingImageAccessor *accessor,
@@ -561,15 +593,13 @@ static void accesscache_put(TrackingImageAccessor *accessor,
int frame,
libmv_InputMode input_mode,
int downscale,
+ const libmv_Region *region,
int64_t transform_key,
ImBuf *ibuf)
{
AccessCacheKey key;
- key.clip_index = clip_index;
- key.frame = frame;
- key.input_mode = input_mode;
- key.downscale = downscale;
- key.transform_key = transform_key;
+ accesscache_construct_key(&key, clip_index, frame, input_mode, downscale,
+ region, transform_key);
IMB_moviecache_put(accessor->cache, &key, ibuf);
}
@@ -578,14 +608,12 @@ static ImBuf *accesscache_get(TrackingImageAccessor *accessor,
int frame,
libmv_InputMode input_mode,
int downscale,
+ const libmv_Region *region,
int64_t transform_key)
{
AccessCacheKey key;
- key.clip_index = clip_index;
- key.frame = frame;
- key.input_mode = input_mode;
- key.downscale = downscale;
- key.transform_key = transform_key;
+ accesscache_construct_key(&key, clip_index, frame, input_mode, downscale,
+ region, transform_key);
return IMB_moviecache_get(accessor->cache, &key);
}
@@ -674,29 +702,37 @@ static ImBuf *accessor_get_ibuf(TrackingImageAccessor *accessor,
{
ImBuf *ibuf, *orig_ibuf, *final_ibuf;
int64_t transform_key = 0;
-
if (transform != NULL) {
transform_key = libmv_frameAccessorgetTransformKey(transform);
}
-
/* First try to get fully processed image from the cache. */
+ BLI_spin_lock(&accessor->cache_lock);
ibuf = accesscache_get(accessor,
clip_index,
frame,
input_mode,
downscale,
+ region,
transform_key);
+ BLI_spin_unlock(&accessor->cache_lock);
if (ibuf != NULL) {
+ CACHE_PRINTF("Used cached buffer for frame %d\n", frame);
+ /* This is a little heuristic here: if we re-used image once, this is
+ * a high probability of the image to be related to a keyframe matched
+ * reference image. Those images we don't want to be thrown away because
+ * if we toss them out we'll be re-calculating them at the next
+ * iteration.
+ */
+ ibuf->userflags |= IB_PERSISTENT;
return ibuf;
}
-
+ CACHE_PRINTF("Calculate new buffer for frame %d\n", frame);
/* And now we do postprocessing of the original frame. */
orig_ibuf = accessor_get_preprocessed_ibuf(accessor, clip_index, frame);
-
if (orig_ibuf == NULL) {
return NULL;
}
-
+ /* Cut a region if requested. */
if (region != NULL) {
int width = region->max[0] - region->min[0],
height = region->max[1] - region->min[1];
@@ -756,7 +792,7 @@ static ImBuf *accessor_get_ibuf(TrackingImageAccessor *accessor,
BLI_unlock_thread(LOCK_MOVIECLIP);
final_ibuf = orig_ibuf;
}
-
+ /* Downscale if needed. */
if (downscale > 0) {
if (final_ibuf == orig_ibuf) {
final_ibuf = IMB_dupImBuf(orig_ibuf);
@@ -765,7 +801,7 @@ static ImBuf *accessor_get_ibuf(TrackingImageAccessor *accessor,
orig_ibuf->x / (1 << downscale),
orig_ibuf->y / (1 << downscale));
}
-
+ /* Apply possible transformation. */
if (transform != NULL) {
libmv_FloatImage input_image, output_image;
ibuf_to_float_image(final_ibuf, &input_image);
@@ -778,12 +814,13 @@ static ImBuf *accessor_get_ibuf(TrackingImageAccessor *accessor,
final_ibuf = float_image_to_ibuf(&output_image);
libmv_floatImageDestroy(&output_image);
}
-
+ /* Transform number of channels. */
if (input_mode == LIBMV_IMAGE_MODE_RGBA) {
BLI_assert(orig_ibuf->channels == 3 || orig_ibuf->channels == 4);
/* pass */
}
else /* if (input_mode == LIBMV_IMAGE_MODE_MONO) */ {
+ BLI_assert(input_mode == LIBMV_IMAGE_MODE_MONO);
if (final_ibuf->channels != 1) {
ImBuf *grayscale_ibuf = make_grayscale_ibuf_copy(final_ibuf);
if (final_ibuf != orig_ibuf) {
@@ -793,37 +830,25 @@ static ImBuf *accessor_get_ibuf(TrackingImageAccessor *accessor,
final_ibuf = grayscale_ibuf;
}
}
-
- /* it's possible processing still didn't happen at this point,
+ /* It's possible processing still didn't happen at this point,
* but we really need a copy of the buffer to be transformed
* and to be put to the cache.
*/
if (final_ibuf == orig_ibuf) {
final_ibuf = IMB_dupImBuf(orig_ibuf);
}
-
IMB_freeImBuf(orig_ibuf);
-
- /* We put postprocessed frame to the cache always for now,
- * not the smartest thing in the world, but who cares at this point.
- */
-
- /* TODO(sergey): Disable cache for now, because we don't store region
- * in the cache key and can't check whether cached version is usable for
- * us or not.
- *
- * Need to think better about what to cache and when.
- */
- if (false) {
- accesscache_put(accessor,
- clip_index,
- frame,
- input_mode,
- downscale,
- transform_key,
- final_ibuf);
- }
-
+ BLI_spin_lock(&accessor->cache_lock);
+ /* Put final buffer to cache. */
+ accesscache_put(accessor,
+ clip_index,
+ frame,
+ input_mode,
+ downscale,
+ region,
+ transform_key,
+ final_ibuf);
+ BLI_spin_unlock(&accessor->cache_lock);
return final_ibuf;
}
@@ -876,7 +901,7 @@ static void accessor_release_image_callback(libmv_CacheKey cache_key)
}
static libmv_CacheKey accessor_get_mask_for_track_callback(
- libmv_FrameAccessorUserData* user_data,
+ libmv_FrameAccessorUserData *user_data,
int clip_index,
int frame,
int track_index,
@@ -958,6 +983,8 @@ TrackingImageAccessor *tracking_image_accessor_new(MovieClip *clips[MAX_ACCESSOR
accessor_get_mask_for_track_callback,
accessor_release_mask_callback);
+ BLI_spin_init(&accessor->cache_lock);
+
return accessor;
}
@@ -965,5 +992,6 @@ void tracking_image_accessor_destroy(TrackingImageAccessor *accessor)
{
IMB_moviecache_free(accessor->cache);
libmv_FrameAccessorDestroy(accessor->libmv_accessor);
+ BLI_spin_end(&accessor->cache_lock);
MEM_freeN(accessor);
}
diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c
index c0a373395dc..8606da0743b 100644
--- a/source/blender/blenkernel/intern/unit.c
+++ b/source/blender/blenkernel/intern/unit.c
@@ -372,6 +372,12 @@ static size_t unit_as_string(char *str, int len_max, double value, int prec, con
value_conv = value / unit->scalar;
+ /* Adjust precision to expected number of significant digits.
+ * Note that here, we shall not have to worry about very big/small numbers, units are expected to replace
+ * 'scientific notation' in those cases. */
+ prec -= integer_digits_d(value_conv);
+ CLAMP(prec, 0, 6);
+
/* Convert to a string */
len = BLI_snprintf_rlen(str, len_max, "%.*f", prec, value_conv);
@@ -442,12 +448,15 @@ size_t bUnit_AsString(char *str, int len_max, double value, int prec, int system
size_t i;
i = unit_as_string(str, len_max, value_a, prec, usys, unit_a, '\0');
+ prec -= integer_digits_d(value_a / unit_b->scalar) - integer_digits_d(value_b / unit_b->scalar);
+ prec = max_ii(prec, 0);
+
/* is there enough space for at least 1 char of the next unit? */
if (i + 2 < len_max) {
str[i++] = ' ';
/* use low precision since this is a smaller unit */
- i += unit_as_string(str + i, len_max - i, value_b, prec ? 1 : 0, usys, unit_b, '\0');
+ i += unit_as_string(str + i, len_max - i, value_b, prec, usys, unit_b, '\0');
}
return i;
}
diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c
index 82fface7d06..05dab9208e5 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -117,11 +117,11 @@ static void *workspace_relation_get_data_matching_parent(
* Hence, this should only be used as assert check before assigining a screen to a workspace.
*/
#ifndef NDEBUG
-static bool workspaces_is_screen_used(
+static bool workspaces_is_screen_used
#else
-static bool UNUSED_FUNCTION(workspaces_is_screen_used)(
+static bool UNUSED_FUNCTION(workspaces_is_screen_used)
#endif
- const Main *bmain, bScreen *screen)
+ (const Main *bmain, bScreen *screen)
{
for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) {
if (workspace_layout_find_exec(workspace, screen)) {
@@ -137,7 +137,7 @@ static bool UNUSED_FUNCTION(workspaces_is_screen_used)(
WorkSpace *BKE_workspace_add(Main *bmain, const char *name)
{
- WorkSpace *new_workspace = BKE_libblock_alloc(bmain, ID_WS, name);
+ WorkSpace *new_workspace = BKE_libblock_alloc(bmain, ID_WS, name, 0);
return new_workspace;
}
diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c
index 363c36e644d..cbe00e3bbc6 100644
--- a/source/blender/blenkernel/intern/world.c
+++ b/source/blender/blenkernel/intern/world.c
@@ -112,43 +112,59 @@ World *add_world(Main *bmain, const char *name)
{
World *wrld;
- wrld = BKE_libblock_alloc(bmain, ID_WO, name);
+ wrld = BKE_libblock_alloc(bmain, ID_WO, name, 0);
BKE_world_init(wrld);
return wrld;
}
-World *BKE_world_copy(Main *bmain, const World *wrld)
+/**
+ * Only copy internal data of World ID from source to already allocated/initialized destination.
+ * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
+ *
+ * WARNING! This function will not handle ID user count!
+ *
+ * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
+ */
+void BKE_world_copy_data(Main *bmain, World *wrld_dst, const World *wrld_src, const int flag)
{
- World *wrldn;
- int a;
-
- wrldn = BKE_libblock_copy(bmain, &wrld->id);
-
- for (a = 0; a < MAX_MTEX; a++) {
- if (wrld->mtex[a]) {
- wrldn->mtex[a] = MEM_mallocN(sizeof(MTex), "BKE_world_copy");
- memcpy(wrldn->mtex[a], wrld->mtex[a], sizeof(MTex));
- id_us_plus((ID *)wrldn->mtex[a]->tex);
+ for (int a = 0; a < MAX_MTEX; a++) {
+ if (wrld_src->mtex[a]) {
+ wrld_dst->mtex[a] = MEM_dupallocN(wrld_src->mtex[a]);
}
}
- if (wrld->nodetree) {
- wrldn->nodetree = ntreeCopyTree(bmain, wrld->nodetree);
+ if (wrld_src->nodetree) {
+ BKE_id_copy_ex(bmain, (ID *)wrld_src->nodetree, (ID **)&wrld_dst->nodetree, flag, false);
}
-
- BKE_previewimg_id_copy(&wrldn->id, &wrld->id);
- BLI_listbase_clear(&wrldn->gpumaterial);
+ BLI_listbase_clear(&wrld_dst->gpumaterial);
- BKE_id_copy_ensure_local(bmain, &wrld->id, &wrldn->id);
+ if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0) {
+ BKE_previewimg_id_copy(&wrld_dst->id, &wrld_src->id);
+ }
+ else {
+ wrld_dst->preview = NULL;
+ }
+}
- return wrldn;
+World *BKE_world_copy(Main *bmain, const World *wrld)
+{
+ World *wrld_copy;
+ BKE_id_copy_ex(bmain, &wrld->id, (ID **)&wrld_copy, 0, false);
+ return wrld_copy;
}
World *localize_world(World *wrld)
{
+ /* TODO replace with something like
+ * World *wrld_copy;
+ * BKE_id_copy_ex(bmain, &wrld->id, (ID **)&wrld_copy, LIB_ID_COPY_NO_MAIN | LIB_ID_COPY_NO_PREVIEW | LIB_ID_COPY_NO_USER_REFCOUNT, false);
+ * return wrld_copy;
+ *
+ * ... Once f*** nodes are fully converted to that too :( */
+
World *wrldn;
int a;
@@ -175,3 +191,14 @@ void BKE_world_make_local(Main *bmain, World *wrld, const bool lib_local)
{
BKE_id_make_local_generic(bmain, &wrld->id, true, lib_local);
}
+
+void BKE_world_eval(const struct EvaluationContext *UNUSED(eval_ctx), World *world)
+{
+ if (G.debug & G_DEBUG_DEPSGRAPH) {
+ printf("%s on %s (%p)\n", __func__, world->id.name, world);
+ }
+ if (!BLI_listbase_is_empty(&world->gpumaterial)) {
+ world->update_flag = 1;
+ GPU_material_uniform_buffer_tag_dirty(&world->gpumaterial);
+ }
+}
diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c
index 89b2caa5ac7..2fb4ed03603 100644
--- a/source/blender/blenkernel/intern/writeavi.c
+++ b/source/blender/blenkernel/intern/writeavi.c
@@ -80,10 +80,6 @@ static void *context_create_avi(void);
static void context_free_avi(void *context_v);
#endif /* WITH_AVI */
-#ifdef WITH_QUICKTIME
-# include "quicktime_export.h"
-#endif
-
#ifdef WITH_FFMPEG
# include "BKE_writeffmpeg.h"
#endif
@@ -115,16 +111,6 @@ bMovieHandle *BKE_movie_handle_get(const char imtype)
#endif
/* do the platform specific handles */
-#ifdef WITH_QUICKTIME
- if (imtype == R_IMF_IMTYPE_QUICKTIME) {
- mh.start_movie = start_qt;
- mh.append_movie = append_qt;
- mh.end_movie = end_qt;
- mh.get_movie_path = filepath_qt;
- mh.context_create = context_create_qt;
- mh.context_free = context_free_qt;
- }
-#endif
#ifdef WITH_FFMPEG
if (ELEM(imtype, R_IMF_IMTYPE_FFMPEG, R_IMF_IMTYPE_H264, R_IMF_IMTYPE_XVID, R_IMF_IMTYPE_THEORA)) {
mh.start_movie = BKE_ffmpeg_start;
diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c
index 156b74f5c3d..b47846cbdec 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -45,8 +45,8 @@
#include "BLI_blenlib.h"
#ifdef WITH_AUDASPACE
-# include AUD_DEVICE_H
-# include AUD_SPECIAL_H
+# include <AUD_Device.h>
+# include <AUD_Special.h>
#endif
#include "BLI_utildefines.h"
@@ -681,6 +681,7 @@ static AVStream *alloc_video_stream(FFMpegContext *context, RenderData *rd, int
/* xasp & yasp got float lately... */
st->sample_aspect_ratio = c->sample_aspect_ratio = av_d2q(((double) rd->xasp / (double) rd->yasp), 255);
+ st->avg_frame_rate = av_inv_q(c->time_base);
set_ffmpeg_properties(rd, c, "video", &opts);
diff --git a/source/blender/blenkernel/tracking_private.h b/source/blender/blenkernel/tracking_private.h
index 1a68a1cac6a..07236fb2096 100644
--- a/source/blender/blenkernel/tracking_private.h
+++ b/source/blender/blenkernel/tracking_private.h
@@ -125,6 +125,7 @@ typedef struct TrackingImageAccessor {
int num_tracks;
int start_frame;
struct libmv_FrameAccessor *libmv_accessor;
+ SpinLock cache_lock;
} TrackingImageAccessor;
TrackingImageAccessor *tracking_image_accessor_new(MovieClip *clips[MAX_ACCESSOR_CLIP],
diff --git a/source/blender/blenlib/BLI_array.h b/source/blender/blenlib/BLI_array.h
index 74f24c808ff..3ffca818c0d 100644
--- a/source/blender/blenlib/BLI_array.h
+++ b/source/blender/blenlib/BLI_array.h
@@ -135,11 +135,12 @@ void _bli_array_grow_func(void **arr_p, const void *arr_static,
#define BLI_array_append_ret(arr) \
(BLI_array_reserve(arr, 1), &arr[(_##arr##_count++)])
-#define BLI_array_free(arr) \
+#define BLI_array_free(arr) { \
if (arr && (char *)arr != _##arr##_static) { \
BLI_array_fake_user(arr); \
MEM_freeN(arr); \
- } (void)0
+ } \
+} ((void)0)
#define BLI_array_pop(arr) ( \
(arr && _##arr##_count) ? \
diff --git a/source/blender/blenlib/BLI_compiler_compat.h b/source/blender/blenlib/BLI_compiler_compat.h
index 01fc9d70207..0726e3bb343 100644
--- a/source/blender/blenlib/BLI_compiler_compat.h
+++ b/source/blender/blenlib/BLI_compiler_compat.h
@@ -48,12 +48,7 @@ extern "C++" {
#if defined(_MSC_VER)
# define BLI_INLINE static __forceinline
#else
-# if (defined(__APPLE__) && defined(__ppc__))
-/* static inline __attribute__ here breaks osx ppc gcc42 build */
-# define BLI_INLINE static __attribute__((always_inline)) __attribute__((__unused__))
-# else
-# define BLI_INLINE static inline __attribute__((always_inline)) __attribute__((__unused__))
-# endif
+# define BLI_INLINE static inline __attribute__((always_inline)) __attribute__((__unused__))
#endif
#endif /* __BLI_COMPILER_COMPAT_H__ */
diff --git a/source/blender/blenlib/BLI_dial.h b/source/blender/blenlib/BLI_dial.h
index ad7680fe03e..71ab57bb61a 100644
--- a/source/blender/blenlib/BLI_dial.h
+++ b/source/blender/blenlib/BLI_dial.h
@@ -52,8 +52,8 @@
typedef struct Dial Dial;
-Dial *BLI_dial_initialize(float start_position[2], float threshold);
+Dial *BLI_dial_initialize(const float start_position[2], float threshold);
-float BLI_dial_angle(Dial *dial, float current_position[2]);
+float BLI_dial_angle(Dial *dial, const float current_position[2]);
#endif /* __BLI_DIAL_H__ */
diff --git a/source/blender/blenlib/BLI_fnmatch.h b/source/blender/blenlib/BLI_fnmatch.h
index f69f5b39869..06fa5048622 100644
--- a/source/blender/blenlib/BLI_fnmatch.h
+++ b/source/blender/blenlib/BLI_fnmatch.h
@@ -28,7 +28,7 @@
extern "C" {
#endif
-#if defined WIN32 && !defined _LIBC || defined __sun
+#if defined WIN32 && !defined _LIBC
#if defined(__cplusplus) || (defined(__STDC__) && __STDC__)
#undef __P
@@ -53,7 +53,7 @@ extern "C" {
#define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */
#define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */
-#if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 2 || defined(_GNU_SOURCE) || defined(__SUNPRO_C)
+#if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 2 || defined(_GNU_SOURCE)
#define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */
#define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */
#define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */
@@ -72,7 +72,7 @@ extern int fnmatch __P((const char *__pattern, const char *__string,
# define _GNU_SOURCE
# endif
# include <fnmatch.h>
-#endif /* defined WIN32 && !defined _LIBC || defined __sun */
+#endif /* defined WIN32 && !defined _LIBC */
#ifdef __cplusplus
}
diff --git a/source/blender/blenlib/BLI_ghash.h b/source/blender/blenlib/BLI_ghash.h
index 8bf5c3da90d..3fde19b11e4 100644
--- a/source/blender/blenlib/BLI_ghash.h
+++ b/source/blender/blenlib/BLI_ghash.h
@@ -44,7 +44,7 @@ extern "C" {
#ifndef GHASH_INTERNAL_API
# ifdef __GNUC__
# undef _GHASH_INTERNAL_ATTR
-# define _GHASH_INTERNAL_ATTR __attribute__ ((deprecated))
+# define _GHASH_INTERNAL_ATTR __attribute__ ((deprecated)) /* not deprecated, just private. */
# endif
#endif
@@ -91,6 +91,7 @@ void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfre
void BLI_ghash_reserve(GHash *gh, const unsigned int nentries_reserve);
void BLI_ghash_insert(GHash *gh, void *key, void *val);
bool BLI_ghash_reinsert(GHash *gh, void *key, void *val, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp);
+void *BLI_ghash_replace_key(GHash *gh, void *key);
void *BLI_ghash_lookup(GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT;
void *BLI_ghash_lookup_default(GHash *gh, const void *key, void *val_default) ATTR_WARN_UNUSED_RESULT;
void **BLI_ghash_lookup_p(GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT;
@@ -249,6 +250,7 @@ void BLI_gset_insert(GSet *gh, void *key);
bool BLI_gset_add(GSet *gs, void *key);
bool BLI_gset_ensure_p_ex(GSet *gs, const void *key, void ***r_key);
bool BLI_gset_reinsert(GSet *gh, void *key, GSetKeyFreeFP keyfreefp);
+void *BLI_gset_replace_key(GSet *gs, void *key);
bool BLI_gset_haskey(GSet *gs, const void *key) ATTR_WARN_UNUSED_RESULT;
bool BLI_gset_pop(GSet *gs, GSetIterState *state, void **r_key) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
bool BLI_gset_remove(GSet *gs, const void *key, GSetKeyFreeFP keyfreefp);
diff --git a/source/blender/blenlib/BLI_kdtree.h b/source/blender/blenlib/BLI_kdtree.h
index aa54e1c823c..18908f8c551 100644
--- a/source/blender/blenlib/BLI_kdtree.h
+++ b/source/blender/blenlib/BLI_kdtree.h
@@ -66,6 +66,10 @@ void BLI_kdtree_range_search_cb(
const KDTree *tree, const float co[3], float range,
bool (*search_cb)(void *user_data, int index, const float co[3], float dist_sq), void *user_data);
+int BLI_kdtree_calc_duplicates_fast(
+ const KDTree *tree, const float range, bool use_index_order,
+ int *doubles);
+
/* Normal use is deprecated */
/* remove __normal functions when last users drop */
int BLI_kdtree_find_nearest_n__normal(
diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h
index 0126e30d900..e6a72298ae7 100644
--- a/source/blender/blenlib/BLI_math_base.h
+++ b/source/blender/blenlib/BLI_math_base.h
@@ -138,6 +138,9 @@ MINLINE int signum_i(float a);
MINLINE float power_of_2(float f);
+MINLINE int integer_digits_f(const float f);
+MINLINE int integer_digits_d(const double d);
+
/* these don't really fit anywhere but were being copied about a lot */
MINLINE int is_power_of_2_i(int n);
MINLINE int power_of_2_max_i(int n);
@@ -146,10 +149,37 @@ MINLINE int power_of_2_min_i(int n);
MINLINE unsigned int power_of_2_max_u(unsigned int x);
MINLINE unsigned int power_of_2_min_u(unsigned int x);
-MINLINE int iroundf(float a);
MINLINE int divide_round_i(int a, int b);
MINLINE int mod_i(int i, int n);
+MINLINE signed char round_fl_to_char(float a);
+MINLINE unsigned char round_fl_to_uchar(float a);
+MINLINE short round_fl_to_short(float a);
+MINLINE unsigned short round_fl_to_ushort(float a);
+MINLINE int round_fl_to_int(float a);
+MINLINE unsigned int round_fl_to_uint(float a);
+
+MINLINE signed char round_db_to_char(double a);
+MINLINE unsigned char round_db_to_uchar(double a);
+MINLINE short round_db_to_short(double a);
+MINLINE unsigned short round_db_to_ushort(double a);
+MINLINE int round_db_to_int(double a);
+MINLINE unsigned int round_db_to_uint(double a);
+
+MINLINE signed char round_fl_to_char_clamp(float a);
+MINLINE unsigned char round_fl_to_uchar_clamp(float a);
+MINLINE short round_fl_to_short_clamp(float a);
+MINLINE unsigned short round_fl_to_ushort_clamp(float a);
+MINLINE int round_fl_to_int_clamp(float a);
+MINLINE unsigned int round_fl_to_uint_clamp(float a);
+
+MINLINE signed char round_db_to_char_clamp(double a);
+MINLINE unsigned char round_db_to_uchar_clamp(double a);
+MINLINE short round_db_to_short_clamp(double a);
+MINLINE unsigned short round_db_to_ushort_clamp(double a);
+MINLINE int round_db_to_int_clamp(double a);
+MINLINE unsigned int round_db_to_uint_clamp(double a);
+
int pow_i(int base, int exp);
double double_round(double x, int ndigits);
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index f1d9c9571f2..933e31ba84b 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -119,6 +119,26 @@ float dist_squared_ray_to_seg_v3(
const float ray_origin[3], const float ray_direction[3],
const float v0[3], const float v1[3],
float r_point[3], float *r_depth);
+
+struct DistRayAABB_Precalc {
+ float ray_origin[3];
+ float ray_direction[3];
+ float ray_inv_dir[3];
+ bool sign[3];
+};
+void dist_squared_ray_to_aabb_v3_precalc(
+ struct DistRayAABB_Precalc *neasrest_precalc,
+ const float ray_origin[3], const float ray_direction[3]);
+float dist_squared_ray_to_aabb_v3(
+ const struct DistRayAABB_Precalc *data,
+ const float bb_min[3], const float bb_max[3],
+ float r_point[3], float *r_depth);
+/* when there is no advantage to precalc. */
+float dist_squared_ray_to_aabb_v3_simple(
+ const float ray_origin[3], const float ray_direction[3],
+ const float bb_min[3], const float bb_max[3],
+ float r_point[3], float *r_depth);
+
float closest_to_line_v2(float r_close[2], const float p[2], const float l1[2], const float l2[2]);
float closest_to_line_v3(float r_close[3], const float p[3], const float l1[3], const float l2[3]);
void closest_to_line_segment_v2(float r_close[2], const float p[2], const float l1[2], const float l2[2]);
@@ -166,8 +186,14 @@ void limit_dist_v3(float v1[3], float v2[3], const float dist);
int isect_seg_seg_v2(const float a1[2], const float a2[2], const float b1[2], const float b2[2]);
int isect_seg_seg_v2_int(const int a1[2], const int a2[2], const int b1[2], const int b2[2]);
-int isect_seg_seg_v2_point(const float v0[2], const float v1[2], const float v2[2], const float v3[2], float vi[2]);
-bool isect_seg_seg_v2_simple(const float v1[2], const float v2[2], const float v3[2], const float v4[2]);
+int isect_seg_seg_v2_point_ex(
+ const float v0[2], const float v1[2], const float v2[2], const float v3[2], const float endpoint_bias,
+ float vi[2]);
+int isect_seg_seg_v2_point(
+ const float v0[2], const float v1[2], const float v2[2], const float v3[2],
+ float vi[2]);
+bool isect_seg_seg_v2_simple(
+ const float v1[2], const float v2[2], const float v3[2], const float v4[2]);
int isect_line_sphere_v3(const float l1[3], const float l2[3], const float sp[3], const float r, float r_p1[3], float r_p2[3]);
int isect_line_sphere_v2(const float l1[2], const float l2[2], const float sp[2], const float r, float r_p1[2], float r_p2[2]);
@@ -381,23 +407,23 @@ void map_to_plane_axis_angle_v2_v3v3fl(float r_co[2], const float co[3], const f
/********************************** Normals **********************************/
-void accumulate_vertex_normals_tri(
+void accumulate_vertex_normals_tri_v3(
float n1[3], float n2[3], float n3[3],
const float f_no[3],
const float co1[3], const float co2[3], const float co3[3]);
-void accumulate_vertex_normals(
+void accumulate_vertex_normals_v3(
float n1[3], float n2[3], float n3[3], float n4[3],
const float f_no[3],
const float co1[3], const float co2[3], const float co3[3], const float co4[3]);
-void accumulate_vertex_normals_poly(
+void accumulate_vertex_normals_poly_v3(
float **vertnos, const float polyno[3],
const float **vertcos, float vdiffs[][3], const int nverts);
/********************************* Tangents **********************************/
-void tangent_from_uv(
+void tangent_from_uv_v3(
const float uv1[2], const float uv2[2], const float uv3[2],
const float co1[3], const float co2[3], const float co3[3],
const float n[3],
@@ -405,9 +431,9 @@ void tangent_from_uv(
/******************************** Vector Clouds ******************************/
-void vcloud_estimate_transform(int list_size, float (*pos)[3], float *weight,
- float (*rpos)[3], float *rweight,
- float lloc[3], float rloc[3], float lrot[3][3], float lscale[3][3]);
+void vcloud_estimate_transform_v3(
+ const int list_size, const float (*pos)[3], const float *weight, const float (*rpos)[3], const float *rweight,
+ float lloc[3], float rloc[3], float lrot[3][3], float lscale[3][3]);
/****************************** Spherical Harmonics *************************/
@@ -438,7 +464,7 @@ float form_factor_hemi_poly(float p[3], float n[3],
float v1[3], float v2[3], float v3[3], float v4[3]);
void axis_dominant_v3_to_m3_negate(float r_mat[3][3], const float normal[3]);
-void axis_dominant_v3_to_m3(float r_mat[3][3], const float normal[3]);
+void axis_dominant_v3_to_m3(float r_mat[3][3], const float normal[3]);
MINLINE void axis_dominant_v3(int *r_axis_a, int *r_axis_b, const float axis[3]);
MINLINE float axis_dominant_v3_max(int *r_axis_a, int *r_axis_b, const float axis[3]) ATTR_WARN_UNUSED_RESULT;
diff --git a/source/blender/blenlib/BLI_math_inline.h b/source/blender/blenlib/BLI_math_inline.h
index 840cf24f8cf..383abda5b2f 100644
--- a/source/blender/blenlib/BLI_math_inline.h
+++ b/source/blender/blenlib/BLI_math_inline.h
@@ -44,12 +44,7 @@ extern "C" {
# define MALWAYS_INLINE MINLINE
# else
# define MINLINE static inline
-# if (defined(__APPLE__) && defined(__ppc__))
- /* static inline __attribute__ here breaks osx ppc gcc42 build */
-# define MALWAYS_INLINE static __attribute__((always_inline)) __attribute__((unused))
-# else
-# define MALWAYS_INLINE static inline __attribute__((always_inline)) __attribute__((unused))
-# endif
+# define MALWAYS_INLINE static inline __attribute__((always_inline)) __attribute__((unused))
# endif
#else
# define MINLINE
diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h
index 90aff1fcbbc..a6f8f9a54e9 100644
--- a/source/blender/blenlib/BLI_math_matrix.h
+++ b/source/blender/blenlib/BLI_math_matrix.h
@@ -85,29 +85,47 @@ void mul_m4_m4_pre(float R[4][4], const float A[4][4]);
void mul_m4_m4_post(float R[4][4], const float B[4][4]);
/* mul_m3_series */
-void _va_mul_m3_series_3(float R[3][3], float M1[3][3], float M2[3][3]) ATTR_NONNULL();
-void _va_mul_m3_series_4(float R[3][3], float M1[3][3], float M2[3][3], float M3[3][3]) ATTR_NONNULL();
-void _va_mul_m3_series_5(float R[3][3], float M1[3][3], float M2[3][3], float M3[3][3], float M4[3][3]) ATTR_NONNULL();
-void _va_mul_m3_series_6(float R[3][3], float M1[3][3], float M2[3][3], float M3[3][3], float M4[3][3],
- float M5[3][3]) ATTR_NONNULL();
-void _va_mul_m3_series_7(float R[3][3], float M1[3][3], float M2[3][3], float M3[3][3], float M4[3][3],
- float M5[3][3], float M6[3][3]) ATTR_NONNULL();
-void _va_mul_m3_series_8(float R[3][3], float M1[3][3], float M2[3][3], float M3[3][3], float M4[3][3],
- float M5[3][3], float M6[3][3], float M7[3][3]) ATTR_NONNULL();
-void _va_mul_m3_series_9(float R[3][3], float M1[3][3], float M2[3][3], float M3[3][3], float M4[3][3],
- float M5[3][3], float M6[3][3], float M7[3][3], float M8[3][3]) ATTR_NONNULL();
+void _va_mul_m3_series_3(
+ float R[3][3], const float M1[3][3], const float M2[3][3]) ATTR_NONNULL();
+void _va_mul_m3_series_4(
+ float R[3][3], const float M1[3][3], const float M2[3][3], const float M3[3][3]) ATTR_NONNULL();
+void _va_mul_m3_series_5(
+ float R[3][3], const float M1[3][3], const float M2[3][3], const float M3[3][3],
+ const float M4[3][3]) ATTR_NONNULL();
+void _va_mul_m3_series_6(
+ float R[3][3], const float M1[3][3], const float M2[3][3], const float M3[3][3],
+ const float M4[3][3], const float M5[3][3]) ATTR_NONNULL();
+void _va_mul_m3_series_7(
+ float R[3][3], const float M1[3][3], const float M2[3][3], const float M3[3][3],
+ const float M4[3][3], const float M5[3][3], const float M6[3][3]) ATTR_NONNULL();
+void _va_mul_m3_series_8(
+ float R[3][3], const float M1[3][3], const float M2[3][3], const float M3[3][3],
+ const float M4[3][3], const float M5[3][3], const float M6[3][3], const float M7[3][3]) ATTR_NONNULL();
+void _va_mul_m3_series_9(
+ float R[3][3], const float M1[3][3], const float M2[3][3], const float M3[3][3],
+ const float M4[3][3], const float M5[3][3], const float M6[3][3], const float M7[3][3],
+ const float M8[3][3]) ATTR_NONNULL();
/* mul_m4_series */
-void _va_mul_m4_series_3(float R[4][4], float M1[4][4], float M2[4][4]) ATTR_NONNULL();
-void _va_mul_m4_series_4(float R[4][4], float M1[4][4], float M2[4][4], float M3[4][4]) ATTR_NONNULL();
-void _va_mul_m4_series_5(float R[4][4], float M1[4][4], float M2[4][4], float M3[4][4], float M4[4][4]) ATTR_NONNULL();
-void _va_mul_m4_series_6(float R[4][4], float M1[4][4], float M2[4][4], float M3[4][4], float M4[4][4],
- float M5[4][4]) ATTR_NONNULL();
-void _va_mul_m4_series_7(float R[4][4], float M1[4][4], float M2[4][4], float M3[4][4], float M4[4][4],
- float M5[4][4], float M6[4][4]) ATTR_NONNULL();
-void _va_mul_m4_series_8(float R[4][4], float M1[4][4], float M2[4][4], float M3[4][4], float M4[4][4],
- float M5[4][4], float M6[4][4], float M7[4][4]) ATTR_NONNULL();
-void _va_mul_m4_series_9(float R[4][4], float M1[4][4], float M2[4][4], float M3[4][4], float M4[4][4],
- float M5[4][4], float M6[4][4], float M7[4][4], float M8[4][4]) ATTR_NONNULL();
+void _va_mul_m4_series_3(
+ float R[4][4], const float M1[4][4], const float M2[4][4]) ATTR_NONNULL();
+void _va_mul_m4_series_4(
+ float R[4][4], const float M1[4][4], const float M2[4][4], const float M3[4][4]) ATTR_NONNULL();
+void _va_mul_m4_series_5(
+ float R[4][4], const float M1[4][4], const float M2[4][4], const float M3[4][4],
+ const float M4[4][4]) ATTR_NONNULL();
+void _va_mul_m4_series_6(
+ float R[4][4], const float M1[4][4], const float M2[4][4], const float M3[4][4],
+ const float M4[4][4], const float M5[4][4]) ATTR_NONNULL();
+void _va_mul_m4_series_7(
+ float R[4][4], const float M1[4][4], const float M2[4][4], const float M3[4][4],
+ const float M4[4][4], const float M5[4][4], const float M6[4][4]) ATTR_NONNULL();
+void _va_mul_m4_series_8(
+ float R[4][4], const float M1[4][4], const float M2[4][4], const float M3[4][4],
+ const float M4[4][4], const float M5[4][4], const float M6[4][4], const float M7[4][4]) ATTR_NONNULL();
+void _va_mul_m4_series_9(
+ float R[4][4], const float M1[4][4], const float M2[4][4], const float M3[4][4],
+ const float M4[4][4], const float M5[4][4], const float M6[4][4], const float M7[4][4],
+ const float M8[4][4]) ATTR_NONNULL();
#define mul_m3_series(...) VA_NARGS_CALL_OVERLOAD(_va_mul_m3_series_, __VA_ARGS__)
#define mul_m4_series(...) VA_NARGS_CALL_OVERLOAD(_va_mul_m4_series_, __VA_ARGS__)
@@ -177,7 +195,7 @@ void normalize_m3_m3(float R[3][3], const float A[3][3]) ATTR_NONNULL();
void normalize_m4_ex(float R[4][4], float r_scale[3]) ATTR_NONNULL();
void normalize_m4(float R[4][4]) ATTR_NONNULL();
void normalize_m4_m4_ex(float R[4][4], const float A[4][4], float r_scale[3]) ATTR_NONNULL();
-void normalize_m4_m4(float R[4][4],const float A[4][4]) ATTR_NONNULL();
+void normalize_m4_m4(float R[4][4], const float A[4][4]) ATTR_NONNULL();
void orthogonalize_m3(float R[3][3], int axis);
void orthogonalize_m4(float R[4][4], int axis);
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index 120f3bb5ac3..e4e0bf22de0 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -300,6 +300,8 @@ void angle_poly_v3(float *angles, const float *verts[3], int len);
void project_v2_v2v2(float out[2], const float p[2], const float v_proj[2]);
void project_v3_v3v3(float out[3], const float p[3], const float v_proj[3]);
+void project_v2_v2v2_normalized(float out[2], const float p[2], const float v_proj[2]);
+void project_v3_v3v3_normalized(float out[3], const float p[3], const float v_proj[3]);
void project_plane_v3_v3v3(float out[3], const float p[3], const float v_plane[3]);
void project_plane_v2_v2v2(float out[2], const float p[2], const float v_plane[2]);
void project_plane_normalized_v3_v3v3(float out[3], const float p[3], const float v_plane[3]);
diff --git a/source/blender/blenlib/BLI_memiter.h b/source/blender/blenlib/BLI_memiter.h
new file mode 100644
index 00000000000..b16f1ae8c43
--- /dev/null
+++ b/source/blender/blenlib/BLI_memiter.h
@@ -0,0 +1,73 @@
+/*
+ * ***** 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __BLI_MEMITER_H__
+#define __BLI_MEMITER_H__
+
+/** \file BLI_memiter.h
+ * \ingroup bli
+ */
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include "BLI_sys_types.h"
+#include "BLI_compiler_attrs.h"
+#include "BLI_compiler_compat.h"
+
+/* 512kb, good default for small elems. */
+#define BLI_MEMITER_DEFAULT_SIZE (1 << 19)
+
+struct BLI_memiter;
+struct BLI_memiter_chunk;
+
+typedef struct BLI_memiter BLI_memiter;
+
+/* warning, ATTR_MALLOC flag on BLI_memiter_alloc causes crash, see: D2756 */
+BLI_memiter *BLI_memiter_create(unsigned int chunk_size) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT;
+void *BLI_memiter_alloc(BLI_memiter *mi, unsigned int size) ATTR_RETURNS_NONNULL ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
+void BLI_memiter_alloc_from(BLI_memiter *mi, uint elem_size, const void *data_from) ATTR_NONNULL(1, 3);
+void *BLI_memiter_calloc(BLI_memiter *mi, unsigned int size) ATTR_RETURNS_NONNULL ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
+void BLI_memiter_destroy(BLI_memiter *mi) ATTR_NONNULL(1);
+void BLI_memiter_clear(BLI_memiter *mi) ATTR_NONNULL(1);
+unsigned int BLI_memiter_count(const BLI_memiter *mi) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
+
+/* utils */
+void *BLI_memiter_elem_first(BLI_memiter *mi);
+void *BLI_memiter_elem_first_size(BLI_memiter *mi, unsigned int *r_size);
+
+/* private structure */
+typedef struct BLI_memiter_handle {
+ struct BLI_memiter_elem *elem;
+ uint elem_left;
+} BLI_memiter_handle;
+
+void BLI_memiter_iter_init(BLI_memiter *mi, BLI_memiter_handle *iter) ATTR_NONNULL();
+bool BLI_memiter_iter_done(const BLI_memiter_handle *iter) ATTR_NONNULL();
+void *BLI_memiter_iter_step(BLI_memiter_handle *iter) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
+void *BLI_memiter_iter_step_size(BLI_memiter_handle *iter, uint *r_size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __BLI_MEMITER_H__ */
diff --git a/source/blender/blenlib/BLI_polyfill2d_beautify.h b/source/blender/blenlib/BLI_polyfill2d_beautify.h
index 20e53b080fe..29a900200bb 100644
--- a/source/blender/blenlib/BLI_polyfill2d_beautify.h
+++ b/source/blender/blenlib/BLI_polyfill2d_beautify.h
@@ -33,8 +33,12 @@ void BLI_polyfill_beautify(
/* structs for reuse */
struct MemArena *arena, struct Heap *eheap, struct EdgeHash *eh);
-float BLI_polyfill_beautify_quad_rotate_calc(
- const float v1[2], const float v2[2], const float v3[2], const float v4[2]);
+float BLI_polyfill_beautify_quad_rotate_calc_ex(
+ const float v1[2], const float v2[2], const float v3[2], const float v4[2],
+ const bool lock_degenerate);
+#define BLI_polyfill_beautify_quad_rotate_calc(v1, v2, v3, v4) \
+ BLI_polyfill_beautify_quad_rotate_calc_ex(v1, v2, v3, v4, false)
+
/* avoid realloc's when creating new structures for polyfill ngons */
#define BLI_POLYFILL_ALLOC_NGON_RESERVE 64
diff --git a/source/blender/blenlib/BLI_rand.h b/source/blender/blenlib/BLI_rand.h
index f36d2faa1b8..0ef971bf41f 100644
--- a/source/blender/blenlib/BLI_rand.h
+++ b/source/blender/blenlib/BLI_rand.h
@@ -101,4 +101,15 @@ RNG_THREAD_ARRAY *BLI_rng_threaded_new(void);
void BLI_rng_threaded_free(struct RNG_THREAD_ARRAY *rngarr) ATTR_NONNULL(1);
int BLI_rng_thread_rand(RNG_THREAD_ARRAY *rngarr, int thread) ATTR_WARN_UNUSED_RESULT;
+/** Low-discrepancy sequences **/
+
+/** Return the _n_th number of the given low-discrepancy sequence. */
+void BLI_halton_1D(unsigned int prime, double offset, int n, double *r);
+void BLI_halton_2D(unsigned int prime[2], double offset[2], int n, double *r);
+void BLI_hammersley_1D(unsigned int n, double *r);
+
+/** Return the whole low-discrepancy sequence up to _n_. */
+void BLI_halton_2D_sequence(unsigned int prime[2], double offset[2], int n, double *r);
+void BLI_hammersley_2D_sequence(unsigned int n, double *r);
+
#endif /* __BLI_RAND_H__ */
diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h
index 21b9c75ac35..471d875c9af 100644
--- a/source/blender/blenlib/BLI_rect.h
+++ b/source/blender/blenlib/BLI_rect.h
@@ -55,6 +55,8 @@ void BLI_rcti_do_minmax_v(struct rcti *rect, const int xy[2]);
void BLI_rctf_do_minmax_v(struct rctf *rect, const float xy[2]);
void BLI_rctf_transform_pt_v(const rctf *dst, const rctf *src, float xy_dst[2], const float xy_src[2]);
+void BLI_rctf_transform_calc_m4_pivot_min_ex(const rctf *dst, const rctf *src, float matrix[4][4], uint x, uint y);
+void BLI_rctf_transform_calc_m4_pivot_min(const rctf *dst, const rctf *src, float matrix[4][4]);
void BLI_rctf_translate(struct rctf *rect, float x, float y);
void BLI_rcti_translate(struct rcti *rect, int x, int y);
diff --git a/source/blender/blenlib/BLI_string_utils.h b/source/blender/blenlib/BLI_string_utils.h
index bb19ed574bb..5701bce51ea 100644
--- a/source/blender/blenlib/BLI_string_utils.h
+++ b/source/blender/blenlib/BLI_string_utils.h
@@ -39,6 +39,7 @@ extern "C" {
#endif
#include "BLI_compiler_attrs.h"
+#include "BLI_utildefines_variadic.h"
struct ListBase;
@@ -49,6 +50,24 @@ size_t BLI_split_name_num(char *left, int *nr, const char *name, const char deli
void BLI_string_split_suffix(const char *string, char *r_body, char *r_suf, const size_t str_len);
void BLI_string_split_prefix(const char *string, char *r_pre, char *r_body, const size_t str_len);
+/* Join strings, return newly allocated string. */
+char *BLI_string_join_arrayN(
+ const char *strings[], uint strings_len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
+char *BLI_string_join_array_by_sep_charN(
+ char sep, const char *strings[], uint strings_len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
+char *BLI_string_join_array_by_sep_char_with_tableN(
+ char sep, char *table[], const char *strings[], uint strings_len) ATTR_NONNULL();
+/* Take multiple arguments, pass as (array, length). */
+#define BLI_string_joinN(...) \
+ BLI_string_join_arrayN( \
+ ((const char *[]){__VA_ARGS__}), VA_NARGS_COUNT(__VA_ARGS__))
+#define BLI_string_join_by_sep_charN(sep, ...) \
+ BLI_string_join_array_by_sep_charN( \
+ sep, ((const char *[]){__VA_ARGS__}), VA_NARGS_COUNT(__VA_ARGS__))
+#define BLI_string_join_by_sep_char_with_tableN(sep, table, ...) \
+ BLI_string_join_array_by_sep_char_with_tableN( \
+ sep, table, ((const char *[]){__VA_ARGS__}), VA_NARGS_COUNT(__VA_ARGS__))
+
void BLI_string_flip_side_name(char *r_name, const char *from_name, const bool strip_number, const size_t name_len);
bool BLI_uniquename_cb(
diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h
index 72ac6bd0080..1186e4a0713 100644
--- a/source/blender/blenlib/BLI_utildefines.h
+++ b/source/blender/blenlib/BLI_utildefines.h
@@ -39,35 +39,12 @@ extern "C" {
/* avoid many includes for now */
#include "BLI_sys_types.h"
#include "BLI_compiler_compat.h"
+#include "BLI_utildefines_variadic.h"
#ifndef NDEBUG /* for BLI_assert */
#include <stdio.h>
#endif
-
-/* varargs macros (keep first so others can use) */
-/* --- internal helpers --- */
-#define _VA_NARGS_GLUE(x, y) x y
-#define _VA_NARGS_RETURN_COUNT(\
- _1_, _2_, _3_, _4_, _5_, _6_, _7_, _8_, _9_, _10_, _11_, _12_, _13_, _14_, _15_, _16_, \
- _17_, _18_, _19_, _20_, _21_, _22_, _23_, _24_, _25_, _26_, _27_, _28_, _29_, _30_, _31_, _32_, \
- _33_, _34_, _35_, _36_, _37_, _38_, _39_, _40_, _41_, _42_, _43_, _44_, _45_, _46_, _47_, _48_, \
- _49_, _50_, _51_, _52_, _53_, _54_, _55_, _56_, _57_, _58_, _59_, _60_, _61_, _62_, _63_, _64_, \
- count, ...) count
-#define _VA_NARGS_EXPAND(args) _VA_NARGS_RETURN_COUNT args
-/* 64 args max */
-#define _VA_NARGS_COUNT(...) _VA_NARGS_EXPAND((__VA_ARGS__, \
- 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, \
- 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, \
- 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, \
- 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0))
-#define _VA_NARGS_OVERLOAD_MACRO2(name, count) name##count
-#define _VA_NARGS_OVERLOAD_MACRO1(name, count) _VA_NARGS_OVERLOAD_MACRO2(name, count)
-#define _VA_NARGS_OVERLOAD_MACRO(name, count) _VA_NARGS_OVERLOAD_MACRO1(name, count)
-/* --- expose for re-use --- */
-#define VA_NARGS_CALL_OVERLOAD(name, ...) \
- _VA_NARGS_GLUE(_VA_NARGS_OVERLOAD_MACRO(name, _VA_NARGS_COUNT(__VA_ARGS__)), (__VA_ARGS__))
-
/* useful for finding bad use of min/max */
#if 0
/* gcc only */
diff --git a/source/blender/blenlib/BLI_utildefines_iter.h b/source/blender/blenlib/BLI_utildefines_iter.h
new file mode 100644
index 00000000000..094c1a4b3dc
--- /dev/null
+++ b/source/blender/blenlib/BLI_utildefines_iter.h
@@ -0,0 +1,52 @@
+/*
+ * ***** 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __BLI_UTILDEFINES_ITER_H__
+#define __BLI_UTILDEFINES_ITER_H__
+
+/** \file BLI_utildefines_iter.h
+ * \ingroup bli
+ *
+ * General looping helpers, use `BLI_FOREACH` prefix.
+ */
+
+/**
+ * Even value distribution.
+ *
+ * \a src must be larger than \a dst,
+ * \a dst defines the number of iterations, their values are evenly spaced.
+ *
+ * The following pairs represent (src, dst) arguments and the values they loop over.
+ * <pre>
+ * (19, 4) -> [2, 7, 11. 16]
+ * (100, 5) -> [9, 29, 49, 69, 89]
+ * (100, 3) -> [16, 49, 83]
+ * (100, 100) -> [0..99]
+ * </pre>
+ * \note this is mainly useful for numbers that might not divide evenly into eachother.
+ */
+#define BLI_FOREACH_SPARSE_RANGE(src, dst, i) \
+for (int _src = (src), _src2 = _src * 2, _dst2 = (dst) * 2, _error = _dst2 - _src, i = 0, _delta; \
+ ((void)(_delta = divide_floor_i(_error, _dst2)), \
+ (void)(i -= _delta), \
+ (i < _src)); \
+ _error -= (_delta * _dst2) + _src2)
+
+#endif /* __BLI_UTILDEFINES_ITER_H__ */
diff --git a/source/blender/blenlib/BLI_stackdefines.h b/source/blender/blenlib/BLI_utildefines_stack.h
index 42b11eb9a2b..15b0029e727 100644
--- a/source/blender/blenlib/BLI_stackdefines.h
+++ b/source/blender/blenlib/BLI_utildefines_stack.h
@@ -18,10 +18,10 @@
* ***** END GPL LICENSE BLOCK *****
*/
-#ifndef __BLI_STACKDEFINES_H__
-#define __BLI_STACKDEFINES_H__
+#ifndef __BLI_UTILDEFINES_STACK_H__
+#define __BLI_UTILDEFINES_STACK_H__
-/** \file BLI_stackdefines.h
+/** \file BLI_utildefines_stack.h
* \ingroup bli
*
* Macro's for a simple array based stack
@@ -86,4 +86,4 @@
} ((void)0)
#endif
-#endif /* __BLI_STACKDEFINES_H__ */
+#endif /* __BLI_UTILDEFINES_STACK_H__ */
diff --git a/source/blender/blenlib/BLI_utildefines_variadic.h b/source/blender/blenlib/BLI_utildefines_variadic.h
new file mode 100644
index 00000000000..7c15754fd83
--- /dev/null
+++ b/source/blender/blenlib/BLI_utildefines_variadic.h
@@ -0,0 +1,50 @@
+/*
+ * ***** 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __BLI_UTILDEFINES_VARIADIC_H__
+#define __BLI_UTILDEFINES_VARIADIC_H__
+
+/** \file BLI_utildefines_variadic.h
+ * \ingroup bli
+ */
+
+/* --- internal helpers --- */
+#define _VA_NARGS_GLUE(x, y) x y
+#define _VA_NARGS_RETURN_COUNT(\
+ _1_, _2_, _3_, _4_, _5_, _6_, _7_, _8_, _9_, _10_, _11_, _12_, _13_, _14_, _15_, _16_, \
+ _17_, _18_, _19_, _20_, _21_, _22_, _23_, _24_, _25_, _26_, _27_, _28_, _29_, _30_, _31_, _32_, \
+ _33_, _34_, _35_, _36_, _37_, _38_, _39_, _40_, _41_, _42_, _43_, _44_, _45_, _46_, _47_, _48_, \
+ _49_, _50_, _51_, _52_, _53_, _54_, _55_, _56_, _57_, _58_, _59_, _60_, _61_, _62_, _63_, _64_, \
+ count, ...) count
+#define _VA_NARGS_EXPAND(args) _VA_NARGS_RETURN_COUNT args
+#define _VA_NARGS_OVERLOAD_MACRO2(name, count) name##count
+#define _VA_NARGS_OVERLOAD_MACRO1(name, count) _VA_NARGS_OVERLOAD_MACRO2(name, count)
+#define _VA_NARGS_OVERLOAD_MACRO(name, count) _VA_NARGS_OVERLOAD_MACRO1(name, count)
+/* --- expose for re-use --- */
+/* 64 args max */
+#define VA_NARGS_COUNT(...) _VA_NARGS_EXPAND((__VA_ARGS__, \
+ 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, \
+ 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, \
+ 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, \
+ 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0))
+#define VA_NARGS_CALL_OVERLOAD(name, ...) \
+ _VA_NARGS_GLUE(_VA_NARGS_OVERLOAD_MACRO(name, VA_NARGS_COUNT(__VA_ARGS__)), (__VA_ARGS__))
+
+#endif /* __BLI_UTILDEFINES_VARIADIC_H__ */
diff --git a/source/blender/blenlib/BLI_vfontdata.h b/source/blender/blenlib/BLI_vfontdata.h
index 8a7079b6c5f..0cd50319a33 100644
--- a/source/blender/blenlib/BLI_vfontdata.h
+++ b/source/blender/blenlib/BLI_vfontdata.h
@@ -52,8 +52,10 @@ typedef struct VChar {
} VChar;
VFontData *BLI_vfontdata_from_freetypefont(struct PackedFile *pf);
+VFontData *BLI_vfontdata_copy(const VFontData *vfont_src, const int flag);
VChar *BLI_vfontchar_from_freetypefont(struct VFont *vfont, unsigned long character);
+VChar *BLI_vfontchar_copy(const VChar *vchar_src, const int flag);
#endif
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index dc81ce000ea..9e7b4ed8b6f 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -50,6 +50,7 @@ set(SRC
intern/BLI_kdtree.c
intern/BLI_linklist.c
intern/BLI_memarena.c
+ intern/BLI_memiter.c
intern/BLI_mempool.c
intern/DLRB_tree.c
intern/array_store.c
@@ -179,6 +180,7 @@ set(SRC
BLI_math_statistics.h
BLI_math_vector.h
BLI_memarena.h
+ BLI_memiter.h
BLI_memory_utils.h
BLI_mempool.h
BLI_noise.h
@@ -193,7 +195,6 @@ set(SRC
BLI_sort.h
BLI_sort_utils.h
BLI_stack.h
- BLI_stackdefines.h
BLI_strict_flags.h
BLI_string.h
BLI_string_cursor_utf8.h
@@ -205,6 +206,9 @@ set(SRC
BLI_threads.h
BLI_timecode.h
BLI_utildefines.h
+ BLI_utildefines_iter.h
+ BLI_utildefines_stack.h
+ BLI_utildefines_variadic.h
BLI_uvproject.h
BLI_vfontdata.h
BLI_voronoi.h
diff --git a/source/blender/blenlib/intern/BLI_dial.c b/source/blender/blenlib/intern/BLI_dial.c
index cfbb52847fd..89f18fa10b4 100644
--- a/source/blender/blenlib/intern/BLI_dial.c
+++ b/source/blender/blenlib/intern/BLI_dial.c
@@ -46,7 +46,7 @@ struct Dial {
};
-Dial *BLI_dial_initialize(float start_position[2], float threshold)
+Dial *BLI_dial_initialize(const float start_position[2], float threshold)
{
Dial *dial = MEM_callocN(sizeof(Dial), "dial");
@@ -56,7 +56,7 @@ Dial *BLI_dial_initialize(float start_position[2], float threshold)
return dial;
}
-float BLI_dial_angle(Dial *dial, float current_position[2])
+float BLI_dial_angle(Dial *dial, const float current_position[2])
{
float current_direction[2];
diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c
index 69dee12c713..1b2a27e33d8 100644
--- a/source/blender/blenlib/intern/BLI_ghash.c
+++ b/source/blender/blenlib/intern/BLI_ghash.c
@@ -763,6 +763,28 @@ bool BLI_ghash_reinsert(GHash *gh, void *key, void *val, GHashKeyFreeFP keyfreef
}
/**
+ * Replaces the key of an item in the \a gh.
+ *
+ * Use when a key is re-allocated or it's memory location is changed.
+ *
+ * \returns The previous key or NULL if not found, the caller may free if it's needed.
+ */
+void *BLI_ghash_replace_key(GHash *gh, void *key)
+{
+ const unsigned int hash = ghash_keyhash(gh, key);
+ const unsigned int bucket_index = ghash_bucket_index(gh, hash);
+ GHashEntry *e = (GHashEntry *)ghash_lookup_entry_ex(gh, key, bucket_index);
+ if (e != NULL) {
+ void *key_prev = e->e.key;
+ e->e.key = key;
+ return key_prev;
+ }
+ else {
+ return NULL;
+ }
+}
+
+/**
* Lookup the value of \a key in \a gh.
*
* \param key The key to lookup.
@@ -1434,6 +1456,18 @@ bool BLI_gset_reinsert(GSet *gs, void *key, GSetKeyFreeFP keyfreefp)
return ghash_insert_safe_keyonly((GHash *)gs, key, true, keyfreefp);
}
+/**
+ * Replaces the key to the set if it's found.
+ * Matching #BLI_ghash_replace_key
+ *
+ * \returns The old key or NULL if not found.
+ */
+void *BLI_gset_replace_key(GSet *gs, void *key)
+{
+ return BLI_ghash_replace_key((GHash *)gs, key);
+}
+
+
bool BLI_gset_remove(GSet *gs, const void *key, GSetKeyFreeFP keyfreefp)
{
return BLI_ghash_remove((GHash *)gs, key, keyfreefp, NULL);
diff --git a/source/blender/blenlib/intern/BLI_kdtree.c b/source/blender/blenlib/intern/BLI_kdtree.c
index a81f9b28b83..84ac339cc4d 100644
--- a/source/blender/blenlib/intern/BLI_kdtree.c
+++ b/source/blender/blenlib/intern/BLI_kdtree.c
@@ -674,3 +674,123 @@ finally:
if (stack != defaultstack)
MEM_freeN(stack);
}
+
+/**
+ * Use when we want to loop over nodes ordered by index.
+ * Requires indices to be aligned with nodes.
+ */
+static uint *kdtree_order(const KDTree *tree)
+{
+ const KDTreeNode *nodes = tree->nodes;
+ uint *order = MEM_mallocN(sizeof(uint) * tree->totnode, __func__);
+ for (uint i = 0; i < tree->totnode; i++) {
+ order[nodes[i].index] = i;
+ }
+ return order;
+}
+
+/* -------------------------------------------------------------------- */
+/** \name BLI_kdtree_calc_duplicates_fast
+ * \{ */
+
+struct DeDuplicateParams {
+ /* Static */
+ const KDTreeNode *nodes;
+ float range;
+ float range_sq;
+ int *duplicates;
+ int *duplicates_found;
+
+ /* Per Search */
+ float search_co[3];
+ int search;
+};
+
+static void deduplicate_recursive(const struct DeDuplicateParams *p, uint i)
+{
+ const KDTreeNode *node = &p->nodes[i];
+ if (p->search_co[node->d] + p->range <= node->co[node->d]) {
+ if (node->left != KD_NODE_UNSET) {
+ deduplicate_recursive(p, node->left);
+ }
+ }
+ else if (p->search_co[node->d] - p->range >= node->co[node->d]) {
+ if (node->right != KD_NODE_UNSET) {
+ deduplicate_recursive(p, node->right);
+ }
+ }
+ else {
+ if ((p->search != node->index) && (p->duplicates[node->index] == -1)) {
+ if (compare_len_squared_v3v3(node->co, p->search_co, p->range_sq)) {
+ p->duplicates[node->index] = (int)p->search;
+ *p->duplicates_found += 1;
+ }
+ }
+ if (node->left != KD_NODE_UNSET) {
+ deduplicate_recursive(p, node->left);
+ }
+ if (node->right != KD_NODE_UNSET) {
+ deduplicate_recursive(p, node->right);
+ }
+ }
+}
+
+/**
+ * Find duplicate points in \a range.
+ * Favors speed over quality since it doesn't find the best target vertex for merging.
+ * Nodes are looped over, duplicates are added when found.
+ * Nevertheless results are predictable.
+ *
+ * \param range: Coordinates in this range are candidates to be merged.
+ * \param use_index_order: Loop over the coordinates ordered by #KDTreeNode.index
+ * At the expense of some performance, this ensures the layout of the tree doesn't influence
+ * the iteration order.
+ * \param duplicates: An array of int's the length of #KDTree.totnode
+ * Values initialized to -1 are candidates to me merged.
+ * Setting the index to it's own position in the array prevents it from being touched,
+ * although it can still be used as a target.
+ * \returns The numebr of merges found (includes any merges already in the \a duplicates array).
+ *
+ * \note Merging is always a single step (target indices wont be marked for merging).
+ */
+int BLI_kdtree_calc_duplicates_fast(
+ const KDTree *tree, const float range, bool use_index_order,
+ int *duplicates)
+{
+ int found = 0;
+ struct DeDuplicateParams p = {
+ .nodes = tree->nodes,
+ .range = range,
+ .range_sq = range * range,
+ .duplicates = duplicates,
+ .duplicates_found = &found,
+ };
+
+ if (use_index_order) {
+ uint *order = kdtree_order(tree);
+ for (uint i = 0; i < tree->totnode; i++) {
+ const uint node_index = order[i];
+ const int index = (int)i;
+ if (ELEM(duplicates[index], -1, index)) {
+ p.search = index;
+ copy_v3_v3(p.search_co, tree->nodes[node_index].co);
+ deduplicate_recursive(&p, tree->root);
+ }
+ }
+ MEM_freeN(order);
+ }
+ else {
+ for (uint i = 0; i < tree->totnode; i++) {
+ const uint node_index = i;
+ const int index = p.nodes[node_index].index;
+ if (ELEM(duplicates[index], -1, index)) {
+ p.search = index;
+ copy_v3_v3(p.search_co, tree->nodes[node_index].co);
+ deduplicate_recursive(&p, tree->root);
+ }
+ }
+ }
+ return found;
+}
+
+/** \} */
diff --git a/source/blender/blenlib/intern/BLI_memiter.c b/source/blender/blenlib/intern/BLI_memiter.c
new file mode 100644
index 00000000000..9c5f026f836
--- /dev/null
+++ b/source/blender/blenlib/intern/BLI_memiter.c
@@ -0,0 +1,357 @@
+/*
+ * ***** 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/blenlib/intern/BLI_memiter.c
+ * \ingroup bli
+ *
+ * Simple, fast memory allocator for allocating many small elements of different sizes
+ * in fixed size memory chunks,
+ * although allocations bigger than the chunk size are supported.
+ * They will reduce the efficiency of this data-structure.
+ * Elements are pointer aligned.
+ *
+ * Supports:
+ *
+ * - Allocation of mixed sizes.
+ * - Iterating over allocations in-order.
+ * - Clearing for re-use.
+ *
+ * Unsupported:
+ *
+ * - Freeing individual elements.
+ *
+ * \note We could inline iteration stepping,
+ * but tests show this doesn't give noticeable speedup.
+ */
+
+#include <string.h>
+#include <stdlib.h>
+
+#include "BLI_utildefines.h"
+
+#include "BLI_memiter.h" /* own include */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_strict_flags.h" /* keep last */
+
+typedef uintptr_t data_t;
+typedef intptr_t offset_t;
+
+/* Write the chunk terminator on adding each element.
+ * typically we rely on the 'count' to avoid iterating past the end. */
+// #define USE_TERMINATE_PARANOID
+
+/* Currently totalloc isnt used. */
+ // #define USE_TOTALLOC
+
+/* pad must be power of two */
+#define PADUP(num, pad) (((num) + ((pad) - 1)) & ~((pad) - 1))
+
+typedef struct BLI_memiter_elem {
+ offset_t size;
+ data_t data[0];
+} BLI_memiter_elem;
+
+typedef struct BLI_memiter_chunk {
+ struct BLI_memiter_chunk *next;
+ /**
+ * internal format is:
+ * ``[next_pointer, size:data, size:data, ..., negative_offset]``
+ *
+ * Where negative offset rewinds to the start.
+ */
+ data_t data[0];
+} BLI_memiter_chunk;
+
+typedef struct BLI_memiter {
+ /* A pointer to 'head' is needed so we can iterate in the order allocated. */
+ struct BLI_memiter_chunk *head, *tail;
+ data_t *data_curr;
+ data_t *data_last;
+ /* Used unless a large element is requested.
+ * (which should be very rare!). */
+ uint chunk_size_in_bytes_min;
+ uint count;
+#ifdef USE_TOTALLOC
+ uint totalloc;
+#endif
+} BLI_memiter;
+
+
+BLI_INLINE uint data_offset_from_size(uint size)
+{
+ return (PADUP(size, (uint)sizeof(data_t))) / (uint)sizeof(data_t);
+}
+
+static void memiter_set_rewind_offset(BLI_memiter *mi)
+{
+ BLI_memiter_elem *elem = (BLI_memiter_elem *)mi->data_curr;
+ elem->size = (offset_t)(((data_t *)mi->tail) - mi->data_curr);
+ BLI_assert(elem->size < 0);
+}
+
+static void memiter_init(BLI_memiter *mi)
+{
+ mi->head = NULL;
+ mi->tail = NULL;
+ mi->data_curr = NULL;
+ mi->data_last = NULL;
+ mi->count = 0;
+#ifdef USE_TOTALLOC
+ mi->totalloc = 0;
+#endif
+}
+
+/* -------------------------------------------------------------------- */
+
+/** \name Public API's
+ * \{ */
+
+/**
+ * \param chunk_size_min: Should be a power of two and
+ * significantly larger than the average element size used.
+ *
+ * While allocations of any size are supported, they won't be efficient
+ * (effectively becoming a single-linked list).
+ *
+ * Its intended that many elements can be stored per chunk.
+ */
+BLI_memiter *BLI_memiter_create(uint chunk_size_min)
+{
+ BLI_memiter *mi = MEM_mallocN(sizeof(BLI_memiter), "BLI_memiter");
+ memiter_init(mi);
+
+ /* Small values are used for tests to check for correctness,
+ * but otherwise not that useful. */
+ const uint slop_space = (sizeof(BLI_memiter_chunk) + MEM_SIZE_OVERHEAD);
+ if (chunk_size_min >= 1024) {
+ /* As long as the input is a power of 2, this will give efficient sizes. */
+ chunk_size_min -= slop_space;
+ }
+
+ mi->chunk_size_in_bytes_min = chunk_size_min;
+ return mi;
+}
+
+void *BLI_memiter_alloc(BLI_memiter *mi, uint elem_size)
+{
+ const uint data_offset = data_offset_from_size(elem_size);
+ data_t *data_curr_next = mi->data_curr + (1 + data_offset);
+
+ if (UNLIKELY(mi->data_curr == NULL) || (data_curr_next > mi->data_last)) {
+
+#ifndef USE_TERMINATE_PARANOID
+ if (mi->data_curr != NULL) {
+ memiter_set_rewind_offset(mi);
+ }
+#endif
+
+ uint chunk_size_in_bytes = mi->chunk_size_in_bytes_min;
+ if (UNLIKELY(chunk_size_in_bytes < elem_size + (uint)sizeof(data_t[2]))) {
+ chunk_size_in_bytes = elem_size + (uint)sizeof(data_t[2]);
+ }
+ uint chunk_size = data_offset_from_size(chunk_size_in_bytes);
+ BLI_memiter_chunk *chunk = MEM_mallocN(
+ sizeof(BLI_memiter_chunk) +
+ (chunk_size * sizeof(data_t)),
+ "BLI_memiter_chunk");
+
+ if (mi->head == NULL) {
+ BLI_assert(mi->tail == NULL);
+ mi->head = chunk;
+ }
+ else {
+ mi->tail->next = chunk;
+ }
+ mi->tail = chunk;
+ chunk->next = NULL;
+
+ mi->data_curr = chunk->data;
+ mi->data_last = chunk->data + (chunk_size - 1);
+ data_curr_next = mi->data_curr + (1 + data_offset);
+ }
+
+ BLI_assert(data_curr_next <= mi->data_last);
+
+ BLI_memiter_elem *elem = (BLI_memiter_elem *)mi->data_curr;
+ elem->size = (offset_t)elem_size;
+ mi->data_curr = data_curr_next;
+
+#ifdef USE_TERMINATE_PARANOID
+ memiter_set_rewind_offset(mi);
+#endif
+
+ mi->count += 1;
+
+#ifdef USE_TOTALLOC
+ mi->totalloc += elem_size;
+#endif
+
+ return elem->data;
+}
+
+void *BLI_memiter_calloc(BLI_memiter *mi, uint elem_size)
+{
+ void *data = BLI_memiter_alloc(mi, elem_size);
+ memset(data, 0, elem_size);
+ return data;
+}
+
+void BLI_memiter_alloc_from(BLI_memiter *mi, uint elem_size, const void *data_from)
+{
+ void *data = BLI_memiter_alloc(mi, elem_size);
+ memcpy(data, data_from, elem_size);
+}
+
+static void memiter_free_data(BLI_memiter *mi)
+{
+ BLI_memiter_chunk *chunk = mi->head;
+ while (chunk) {
+ BLI_memiter_chunk *chunk_next = chunk->next;
+ MEM_freeN(chunk);
+ chunk = chunk_next;
+ }
+}
+
+void BLI_memiter_destroy(BLI_memiter *mi)
+{
+ memiter_free_data(mi);
+ MEM_freeN(mi);
+}
+
+void BLI_memiter_clear(BLI_memiter *mi)
+{
+ memiter_free_data(mi);
+ memiter_init(mi);
+}
+
+uint BLI_memiter_count(const BLI_memiter *mi)
+{
+ return mi->count;
+}
+
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+
+/** \name Helper API's
+ * \{ */
+
+/* Support direct lookup for first. */
+void *BLI_memiter_elem_first(BLI_memiter *mi)
+{
+ if (mi->head != NULL) {
+ BLI_memiter_chunk *chunk = mi->head;
+ BLI_memiter_elem *elem = (BLI_memiter_elem *)chunk->data;
+ return elem->data;
+ }
+ else {
+ return NULL;
+ }
+}
+
+void *BLI_memiter_elem_first_size(BLI_memiter *mi, uint *r_size)
+{
+ if (mi->head != NULL) {
+ BLI_memiter_chunk *chunk = mi->head;
+ BLI_memiter_elem *elem = (BLI_memiter_elem *)chunk->data;
+ *r_size = (uint)elem->size;
+ return elem->data;
+ }
+ else {
+ return NULL;
+ }
+}
+
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+
+/** \name Iterator API's
+ *
+ * \note We could loop over elements until a NULL chunk is found,
+ * however this means every allocation needs to preemptively run
+ * #memiter_set_rewind_offset (see #USE_TERMINATE_PARANOID).
+ * Unless we have a call to finalize allocation (which complicates usage).
+ * So use a counter instead.
+ *
+ * \{ */
+
+void BLI_memiter_iter_init(BLI_memiter *mi, BLI_memiter_handle *iter)
+{
+ iter->elem = mi->head ? (BLI_memiter_elem *)mi->head->data : NULL;
+ iter->elem_left = mi->count;
+}
+
+bool BLI_memiter_iter_done(const BLI_memiter_handle *iter)
+{
+ return iter->elem_left != 0;
+}
+
+BLI_INLINE void memiter_chunk_step(BLI_memiter_handle *iter)
+{
+ BLI_assert(iter->elem->size < 0);
+ BLI_memiter_chunk *chunk = (BLI_memiter_chunk *)(((data_t *)iter->elem) + iter->elem->size);
+ chunk = chunk->next;
+ iter->elem = chunk ? (BLI_memiter_elem *)chunk->data : NULL;
+ BLI_assert(iter->elem == NULL || iter->elem->size >= 0);
+}
+
+void *BLI_memiter_iter_step_size(BLI_memiter_handle *iter, uint *r_size)
+{
+ if (iter->elem_left != 0) {
+ iter->elem_left -= 1;
+ if (UNLIKELY(iter->elem->size < 0)) {
+ memiter_chunk_step(iter);
+ }
+ BLI_assert(iter->elem->size >= 0);
+ uint size = (uint)iter->elem->size;
+ *r_size = size; /* <-- only difference */
+ data_t *data = iter->elem->data;
+ iter->elem = (BLI_memiter_elem *)&data[data_offset_from_size(size)];
+ return (void *)data;
+ }
+ else {
+ return NULL;
+ }
+}
+
+void *BLI_memiter_iter_step(BLI_memiter_handle *iter)
+{
+ if (iter->elem_left != 0) {
+ iter->elem_left -= 1;
+ if (UNLIKELY(iter->elem->size < 0)) {
+ memiter_chunk_step(iter);
+ }
+ BLI_assert(iter->elem->size >= 0);
+ uint size = (uint)iter->elem->size;
+ data_t *data = iter->elem->data;
+ iter->elem = (BLI_memiter_elem *)&data[data_offset_from_size(size)];
+ return (void *)data;
+ }
+ else {
+ return NULL;
+ }
+}
+
+/** \} */
diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c
index 8719c92a2a6..e990f0b663c 100644
--- a/source/blender/blenlib/intern/freetypefont.c
+++ b/source/blender/blenlib/intern/freetypefont.c
@@ -481,6 +481,22 @@ VFontData *BLI_vfontdata_from_freetypefont(PackedFile *pf)
return vfd;
}
+static void *vfontdata_copy_characters_value_cb(const void *src)
+{
+ return BLI_vfontchar_copy(src, 0);
+}
+
+VFontData *BLI_vfontdata_copy(const VFontData *vfont_src, const int UNUSED(flag))
+{
+ VFontData *vfont_dst = MEM_dupallocN(vfont_src);
+
+ if (vfont_src->characters != NULL) {
+ vfont_dst->characters = BLI_ghash_copy(vfont_src->characters, NULL, vfontdata_copy_characters_value_cb);
+ }
+
+ return vfont_dst;
+}
+
VChar *BLI_vfontchar_from_freetypefont(VFont *vfont, unsigned long character)
{
VChar *che = NULL;
@@ -503,6 +519,20 @@ VChar *BLI_vfontchar_from_freetypefont(VFont *vfont, unsigned long character)
return che;
}
+/* Yeah, this is very bad... But why is this in BLI in the first place, since it uses Nurb data?
+ * Anyway, do not feel like duplicating whole Nurb copy code here, so unless someone has a better idea... */
+#include "../../blenkernel/BKE_curve.h"
+
+VChar *BLI_vfontchar_copy(const VChar *vchar_src, const int UNUSED(flag))
+{
+ VChar *vchar_dst = MEM_dupallocN(vchar_src);
+
+ BLI_listbase_clear(&vchar_dst->nurbsbase);
+ BKE_nurbList_duplicate(&vchar_dst->nurbsbase, &vchar_src->nurbsbase);
+
+ return vchar_dst;
+}
+
#if 0
/* Freetype2 Outline struct */
diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c
index 8d2d80c2a35..749c18fc0ce 100644
--- a/source/blender/blenlib/intern/math_base_inline.c
+++ b/source/blender/blenlib/intern/math_base_inline.c
@@ -33,6 +33,7 @@
#include <float.h>
#include <stdio.h>
#include <stdlib.h>
+#include <limits.h>
#ifdef __SSE2__
# include <emmintrin.h>
@@ -181,11 +182,59 @@ MINLINE unsigned power_of_2_min_u(unsigned x)
return x - (x >> 1);
}
-MINLINE int iroundf(float a)
-{
- return (int)floorf(a + 0.5f);
+/* rounding and clamping */
+
+#define _round_clamp_fl_impl(arg, ty, min, max) { \
+ float r = floorf(arg + 0.5f); \
+ if (UNLIKELY(r <= (float)min)) return (ty)min; \
+ else if (UNLIKELY(r >= (float)max)) return (ty)max; \
+ else return (ty)r; \
+}
+
+#define _round_clamp_db_impl(arg, ty, min, max) { \
+ double r = floor(arg + 0.5); \
+ if (UNLIKELY(r <= (double)min)) return (ty)min; \
+ else if (UNLIKELY(r >= (double)max)) return (ty)max; \
+ else return (ty)r; \
}
+#define _round_fl_impl(arg, ty) { return (ty)floorf(arg + 0.5f); }
+#define _round_db_impl(arg, ty) { return (ty)floor(arg + 0.5); }
+
+MINLINE signed char round_fl_to_char(float a) { _round_fl_impl(a, signed char) }
+MINLINE unsigned char round_fl_to_uchar(float a) { _round_fl_impl(a, unsigned char) }
+MINLINE short round_fl_to_short(float a) { _round_fl_impl(a, short) }
+MINLINE unsigned short round_fl_to_ushort(float a) { _round_fl_impl(a, unsigned short) }
+MINLINE int round_fl_to_int(float a) { _round_fl_impl(a, int) }
+MINLINE unsigned int round_fl_to_uint(float a) { _round_fl_impl(a, unsigned int) }
+
+MINLINE signed char round_db_to_char(double a) { _round_db_impl(a, signed char) }
+MINLINE unsigned char round_db_to_uchar(double a) { _round_db_impl(a, unsigned char) }
+MINLINE short round_db_to_short(double a) { _round_db_impl(a, short) }
+MINLINE unsigned short round_db_to_ushort(double a) { _round_db_impl(a, unsigned short) }
+MINLINE int round_db_to_int(double a) { _round_db_impl(a, int) }
+MINLINE unsigned int round_db_to_uint(double a) { _round_db_impl(a, unsigned int) }
+
+#undef _round_fl_impl
+#undef _round_db_impl
+
+MINLINE signed char round_fl_to_char_clamp(float a) { _round_clamp_fl_impl(a, signed char, SCHAR_MIN, SCHAR_MAX) }
+MINLINE unsigned char round_fl_to_uchar_clamp(float a) { _round_clamp_fl_impl(a, unsigned char, 0, UCHAR_MAX) }
+MINLINE short round_fl_to_short_clamp(float a) { _round_clamp_fl_impl(a, short, SHRT_MIN, SHRT_MAX) }
+MINLINE unsigned short round_fl_to_ushort_clamp(float a) { _round_clamp_fl_impl(a, unsigned short, 0, USHRT_MAX) }
+MINLINE int round_fl_to_int_clamp(float a) { _round_clamp_fl_impl(a, int, INT_MIN, INT_MAX) }
+MINLINE unsigned int round_fl_to_uint_clamp(float a) { _round_clamp_fl_impl(a, unsigned int, 0, UINT_MAX) }
+
+MINLINE signed char round_db_to_char_clamp(double a) { _round_clamp_db_impl(a, signed char, SCHAR_MIN, SCHAR_MAX) }
+MINLINE unsigned char round_db_to_uchar_clamp(double a) { _round_clamp_db_impl(a, unsigned char, 0, UCHAR_MAX) }
+MINLINE short round_db_to_short_clamp(double a) { _round_clamp_db_impl(a, short, SHRT_MIN, SHRT_MAX) }
+MINLINE unsigned short round_db_to_ushort_clamp(double a) { _round_clamp_db_impl(a, unsigned short, 0, USHRT_MAX) }
+MINLINE int round_db_to_int_clamp(double a) { _round_clamp_db_impl(a, int, INT_MIN, INT_MAX) }
+MINLINE unsigned int round_db_to_uint_clamp(double a) { _round_clamp_db_impl(a, unsigned int, 0, UINT_MAX) }
+
+#undef _round_clamp_fl_impl
+#undef _round_clamp_db_impl
+
/* integer division that rounds 0.5 up, particularly useful for color blending
* with integers, to avoid gradual darkening when rounding down */
MINLINE int divide_round_i(int a, int b)
@@ -194,6 +243,17 @@ MINLINE int divide_round_i(int a, int b)
}
/**
+ * Integer division that floors negative result.
+ * \note This works like Python's int division.
+ */
+MINLINE int divide_floor_i(int a, int b)
+{
+ int d = a / b;
+ int r = a % b; /* Optimizes into a single division. */
+ return r ? d - ((a < 0) ^ (b < 0)) : d;
+}
+
+/**
* modulo that handles negative numbers, works the same as Python's.
*/
MINLINE int mod_i(int i, int n)
@@ -314,6 +374,21 @@ MINLINE int signum_i(float a)
else return 0;
}
+/** Returns number of (base ten) *significant* digits of integer part of given float
+ * (negative in case of decimal-only floats, 0.01 returns -1 e.g.). */
+MINLINE int integer_digits_f(const float f)
+{
+ return (f == 0.0f) ? 0 : (int)floor(log10(fabs(f))) + 1;
+}
+
+/** Returns number of (base ten) *significant* digits of integer part of given double
+ * (negative in case of decimal-only floats, 0.01 returns -1 e.g.). */
+MINLINE int integer_digits_d(const double d)
+{
+ return (d == 0.0) ? 0 : (int)floor(log10(fabs(d))) + 1;
+}
+
+
/* Internal helpers for SSE2 implementation.
*
* NOTE: Are to be called ONLY from inside `#ifdef __SSE2__` !!!
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index bfe1aefcbbd..d3080e5530f 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -619,6 +619,152 @@ float dist_squared_ray_to_seg_v3(
return len_squared_v3(t) - SQUARE(*r_depth);
}
+/* -------------------------------------------------------------------- */
+/** \name dist_squared_to_ray_to_aabb and helpers
+ * \{ */
+
+void dist_squared_ray_to_aabb_v3_precalc(
+ struct DistRayAABB_Precalc *neasrest_precalc,
+ const float ray_origin[3], const float ray_direction[3])
+{
+ copy_v3_v3(neasrest_precalc->ray_origin, ray_origin);
+ copy_v3_v3(neasrest_precalc->ray_direction, ray_direction);
+
+ for (int i = 0; i < 3; i++) {
+ neasrest_precalc->ray_inv_dir[i] =
+ (neasrest_precalc->ray_direction[i] != 0.0f) ?
+ (1.0f / neasrest_precalc->ray_direction[i]) : FLT_MAX;
+ neasrest_precalc->sign[i] = (neasrest_precalc->ray_inv_dir[i] < 0.0f);
+ }
+}
+
+/**
+ * Returns the distance from a ray to a bound-box (projected on ray)
+ */
+float dist_squared_ray_to_aabb_v3(
+ const struct DistRayAABB_Precalc *data,
+ const float bb_min[3], const float bb_max[3],
+ float r_point[3], float *r_depth)
+{
+ // bool r_axis_closest[3];
+ float local_bvmin[3], local_bvmax[3];
+ if (data->sign[0]) {
+ local_bvmin[0] = bb_max[0];
+ local_bvmax[0] = bb_min[0];
+ }
+ else {
+ local_bvmin[0] = bb_min[0];
+ local_bvmax[0] = bb_max[0];
+ }
+ if (data->sign[1]) {
+ local_bvmin[1] = bb_max[1];
+ local_bvmax[1] = bb_min[1];
+ }
+ else {
+ local_bvmin[1] = bb_min[1];
+ local_bvmax[1] = bb_max[1];
+ }
+ if (data->sign[2]) {
+ local_bvmin[2] = bb_max[2];
+ local_bvmax[2] = bb_min[2];
+ }
+ else {
+ local_bvmin[2] = bb_min[2];
+ local_bvmax[2] = bb_max[2];
+ }
+
+ const float tmin[3] = {
+ (local_bvmin[0] - data->ray_origin[0]) * data->ray_inv_dir[0],
+ (local_bvmin[1] - data->ray_origin[1]) * data->ray_inv_dir[1],
+ (local_bvmin[2] - data->ray_origin[2]) * data->ray_inv_dir[2],
+ };
+ const float tmax[3] = {
+ (local_bvmax[0] - data->ray_origin[0]) * data->ray_inv_dir[0],
+ (local_bvmax[1] - data->ray_origin[1]) * data->ray_inv_dir[1],
+ (local_bvmax[2] - data->ray_origin[2]) * data->ray_inv_dir[2],
+ };
+ /* `va` and `vb` are the coordinates of the AABB edge closest to the ray */
+ float va[3], vb[3];
+ /* `rtmin` and `rtmax` are the minimum and maximum distances of the ray hits on the AABB */
+ float rtmin, rtmax;
+ int main_axis;
+
+ if ((tmax[0] <= tmax[1]) && (tmax[0] <= tmax[2])) {
+ rtmax = tmax[0];
+ va[0] = vb[0] = local_bvmax[0];
+ main_axis = 3;
+ // r_axis_closest[0] = data->sign[0];
+ }
+ else if ((tmax[1] <= tmax[0]) && (tmax[1] <= tmax[2])) {
+ rtmax = tmax[1];
+ va[1] = vb[1] = local_bvmax[1];
+ main_axis = 2;
+ // r_axis_closest[1] = data->sign[1];
+ }
+ else {
+ rtmax = tmax[2];
+ va[2] = vb[2] = local_bvmax[2];
+ main_axis = 1;
+ // r_axis_closest[2] = data->sign[2];
+ }
+
+ if ((tmin[0] >= tmin[1]) && (tmin[0] >= tmin[2])) {
+ rtmin = tmin[0];
+ va[0] = vb[0] = local_bvmin[0];
+ main_axis -= 3;
+ // r_axis_closest[0] = !data->sign[0];
+ }
+ else if ((tmin[1] >= tmin[0]) && (tmin[1] >= tmin[2])) {
+ rtmin = tmin[1];
+ va[1] = vb[1] = local_bvmin[1];
+ main_axis -= 1;
+ // r_axis_closest[1] = !data->sign[1];
+ }
+ else {
+ rtmin = tmin[2];
+ va[2] = vb[2] = local_bvmin[2];
+ main_axis -= 2;
+ // r_axis_closest[2] = !data->sign[2];
+ }
+ if (main_axis < 0) {
+ main_axis += 3;
+ }
+
+ /* if rtmin <= rtmax, ray intersect `AABB` */
+ if (rtmin <= rtmax) {
+ float dvec[3];
+ copy_v3_v3(r_point, local_bvmax);
+ sub_v3_v3v3(dvec, local_bvmax, data->ray_origin);
+ *r_depth = dot_v3v3(dvec, data->ray_direction);
+ return 0.0f;
+ }
+
+ if (data->sign[main_axis]) {
+ va[main_axis] = local_bvmax[main_axis];
+ vb[main_axis] = local_bvmin[main_axis];
+ }
+ else {
+ va[main_axis] = local_bvmin[main_axis];
+ vb[main_axis] = local_bvmax[main_axis];
+ }
+
+ return dist_squared_ray_to_seg_v3(
+ data->ray_origin, data->ray_direction, va, vb,
+ r_point, r_depth);
+}
+
+float dist_squared_ray_to_aabb_v3_simple(
+ const float ray_origin[3], const float ray_direction[3],
+ const float bbmin[3], const float bbmax[3],
+ float r_point[3], float *r_depth)
+{
+ struct DistRayAABB_Precalc data;
+ dist_squared_ray_to_aabb_v3_precalc(&data, ray_origin, ray_direction);
+ return dist_squared_ray_to_aabb_v3(&data, bbmin, bbmax, r_point, r_depth);
+}
+/** \} */
+
+
/* Adapted from "Real-Time Collision Detection" by Christer Ericson,
* published by Morgan Kaufmann Publishers, copyright 2005 Elsevier Inc.
*
@@ -765,18 +911,29 @@ int isect_seg_seg_v2(const float v1[2], const float v2[2], const float v3[2], co
return ISECT_LINE_LINE_NONE;
}
-/* get intersection point of two 2D segments and return intersection type:
- * -1: collinear
- * 1: intersection
+/**
+ * Get intersection point of two 2D segments.
+ *
+ * \param endpoint_bias: Bias to use when testing for end-point overlap.
+ * A positive value considers intersections that extend past the endpoints,
+ * negative values contract the endpoints.
+ * Note the bias is applied to a 0-1 factor, not scaled to the length of segments.
+ *
+ * \returns intersection type:
+ * - -1: collinear.
+ * - 1: intersection.
+ * - 0: no intersection.
*/
-int isect_seg_seg_v2_point(
+int isect_seg_seg_v2_point_ex(
const float v0[2], const float v1[2],
const float v2[2], const float v3[2],
+ const float endpoint_bias,
float r_vi[2])
{
float s10[2], s32[2], s30[2], d;
const float eps = 1e-6f;
- const float eps_sq = eps * eps;
+ const float endpoint_min = -endpoint_bias;
+ const float endpoint_max = endpoint_bias + 1.0f;
sub_v2_v2v2(s10, v1, v0);
sub_v2_v2v2(s32, v3, v2);
@@ -790,8 +947,8 @@ int isect_seg_seg_v2_point(
u = cross_v2v2(s30, s32) / d;
v = cross_v2v2(s10, s30) / d;
- if ((u >= -eps && u <= 1.0f + eps) &&
- (v >= -eps && v <= 1.0f + eps))
+ if ((u >= endpoint_min && u <= endpoint_max) &&
+ (v >= endpoint_min && v <= endpoint_max))
{
/* intersection */
float vi_test[2];
@@ -810,7 +967,7 @@ int isect_seg_seg_v2_point(
sub_v2_v2v2(s_vi_v2, vi_test, v2);
v = (dot_v2v2(s32, s_vi_v2) / dot_v2v2(s32, s32));
#endif
- if (v >= -eps && v <= 1.0f + eps) {
+ if (v >= endpoint_min && v <= endpoint_max) {
copy_v2_v2(r_vi, vi_test);
return 1;
}
@@ -828,7 +985,7 @@ int isect_seg_seg_v2_point(
float u_a, u_b;
if (equals_v2v2(v0, v1)) {
- if (len_squared_v2v2(v2, v3) > eps_sq) {
+ if (len_squared_v2v2(v2, v3) > SQUARE(eps)) {
/* use non-point segment as basis */
SWAP(const float *, v0, v2);
SWAP(const float *, v1, v3);
@@ -855,7 +1012,7 @@ int isect_seg_seg_v2_point(
if (u_a > u_b)
SWAP(float, u_a, u_b);
- if (u_a > 1.0f + eps || u_b < -eps) {
+ if (u_a > endpoint_max || u_b < endpoint_min) {
/* non-overlapping segments */
return -1;
}
@@ -871,6 +1028,15 @@ int isect_seg_seg_v2_point(
}
}
+int isect_seg_seg_v2_point(
+ const float v0[2], const float v1[2],
+ const float v2[2], const float v3[2],
+ float r_vi[2])
+{
+ const float endpoint_bias = 1e-6f;
+ return isect_seg_seg_v2_point_ex(v0, v1, v2, v3, endpoint_bias, r_vi);
+}
+
bool isect_seg_seg_v2_simple(const float v1[2], const float v2[2], const float v3[2], const float v4[2])
{
#define CCW(A, B, C) \
@@ -3887,7 +4053,7 @@ void map_to_plane_axis_angle_v2_v3v3fl(float r_co[2], const float co[3], const f
/********************************* Normals **********************************/
-void accumulate_vertex_normals_tri(
+void accumulate_vertex_normals_tri_v3(
float n1[3], float n2[3], float n3[3],
const float f_no[3],
const float co1[3], const float co2[3], const float co3[3])
@@ -3921,7 +4087,7 @@ void accumulate_vertex_normals_tri(
}
}
-void accumulate_vertex_normals(
+void accumulate_vertex_normals_v3(
float n1[3], float n2[3], float n3[3], float n4[3],
const float f_no[3],
const float co1[3], const float co2[3], const float co3[3], const float co4[3])
@@ -3965,7 +4131,7 @@ void accumulate_vertex_normals(
/* Add weighted face normal component into normals of the face vertices.
* Caller must pass pre-allocated vdiffs of nverts length. */
-void accumulate_vertex_normals_poly(float **vertnos, const float polyno[3],
+void accumulate_vertex_normals_poly_v3(float **vertnos, const float polyno[3],
const float **vertcos, float vdiffs[][3], const int nverts)
{
int i;
@@ -3996,7 +4162,7 @@ void accumulate_vertex_normals_poly(float **vertnos, const float polyno[3],
/********************************* Tangents **********************************/
-void tangent_from_uv(
+void tangent_from_uv_v3(
const float uv1[2], const float uv2[2], const float uv3[3],
const float co1[3], const float co2[3], const float co3[3],
const float n[3],
@@ -4038,30 +4204,28 @@ void tangent_from_uv(
/****************************** Vector Clouds ********************************/
/* vector clouds */
-/* void vcloud_estimate_transform(int list_size, float (*pos)[3], float *weight, float (*rpos)[3], float *rweight,
- * float lloc[3], float rloc[3], float lrot[3][3], float lscale[3][3])
- *
+/**
* input
- * (
- * int list_size
- * 4 lists as pointer to array[list_size]
- * 1. current pos array of 'new' positions
- * 2. current weight array of 'new'weights (may be NULL pointer if you have no weights )
- * 3. reference rpos array of 'old' positions
- * 4. reference rweight array of 'old'weights (may be NULL pointer if you have no weights )
- * )
+ *
+ * \param list_size: 4 lists as pointer to array[list_size]
+ * \param pos: current pos array of 'new' positions
+ * \param weight: current weight array of 'new'weights (may be NULL pointer if you have no weights)
+ * \param rpos: Reference rpos array of 'old' positions
+ * \param rweight: Reference rweight array of 'old'weights (may be NULL pointer if you have no weights).
+ *
* output
- * (
- * float lloc[3] center of mass pos
- * float rloc[3] center of mass rpos
- * float lrot[3][3] rotation matrix
- * float lscale[3][3] scale matrix
+ *
+ * \param lloc: Center of mass pos.
+ * \param rloc: Center of mass rpos.
+ * \param lrot: Rotation matrix.
+ * \param lscale: Scale matrix.
+ *
* pointers may be NULL if not needed
- * )
*/
-void vcloud_estimate_transform(int list_size, float (*pos)[3], float *weight, float (*rpos)[3], float *rweight,
- float lloc[3], float rloc[3], float lrot[3][3], float lscale[3][3])
+void vcloud_estimate_transform_v3(
+ const int list_size, const float (*pos)[3], const float *weight, const float (*rpos)[3], const float *rweight,
+ float lloc[3], float rloc[3], float lrot[3][3], float lscale[3][3])
{
float accu_com[3] = {0.0f, 0.0f, 0.0f}, accu_rcom[3] = {0.0f, 0.0f, 0.0f};
float accu_weight = 0.0f, accu_rweight = 0.0f;
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index 7677d545e07..3559500bf63 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -341,20 +341,20 @@ void mul_m4_m3m4(float m1[4][4], const float m3_[3][3], const float m2_[4][4])
* \{ */
void _va_mul_m3_series_3(
float r[3][3],
- float m1[3][3], float m2[3][3])
+ const float m1[3][3], const float m2[3][3])
{
mul_m3_m3m3(r, m1, m2);
}
void _va_mul_m3_series_4(
float r[3][3],
- float m1[3][3], float m2[3][3], float m3[3][3])
+ const float m1[3][3], const float m2[3][3], const float m3[3][3])
{
mul_m3_m3m3(r, m1, m2);
mul_m3_m3m3(r, r, m3);
}
void _va_mul_m3_series_5(
float r[3][3],
- float m1[3][3], float m2[3][3], float m3[3][3], float m4[3][3])
+ const float m1[3][3], const float m2[3][3], const float m3[3][3], const float m4[3][3])
{
mul_m3_m3m3(r, m1, m2);
mul_m3_m3m3(r, r, m3);
@@ -362,8 +362,8 @@ void _va_mul_m3_series_5(
}
void _va_mul_m3_series_6(
float r[3][3],
- float m1[3][3], float m2[3][3], float m3[3][3], float m4[3][3],
- float m5[3][3])
+ const float m1[3][3], const float m2[3][3], const float m3[3][3], const float m4[3][3],
+ const float m5[3][3])
{
mul_m3_m3m3(r, m1, m2);
mul_m3_m3m3(r, r, m3);
@@ -372,8 +372,8 @@ void _va_mul_m3_series_6(
}
void _va_mul_m3_series_7(
float r[3][3],
- float m1[3][3], float m2[3][3], float m3[3][3], float m4[3][3],
- float m5[3][3], float m6[3][3])
+ const float m1[3][3], const float m2[3][3], const float m3[3][3], const float m4[3][3],
+ const float m5[3][3], const float m6[3][3])
{
mul_m3_m3m3(r, m1, m2);
mul_m3_m3m3(r, r, m3);
@@ -383,8 +383,8 @@ void _va_mul_m3_series_7(
}
void _va_mul_m3_series_8(
float r[3][3],
- float m1[3][3], float m2[3][3], float m3[3][3], float m4[3][3],
- float m5[3][3], float m6[3][3], float m7[3][3])
+ const float m1[3][3], const float m2[3][3], const float m3[3][3], const float m4[3][3],
+ const float m5[3][3], const float m6[3][3], const float m7[3][3])
{
mul_m3_m3m3(r, m1, m2);
mul_m3_m3m3(r, r, m3);
@@ -395,8 +395,8 @@ void _va_mul_m3_series_8(
}
void _va_mul_m3_series_9(
float r[3][3],
- float m1[3][3], float m2[3][3], float m3[3][3], float m4[3][3],
- float m5[3][3], float m6[3][3], float m7[3][3], float m8[3][3])
+ const float m1[3][3], const float m2[3][3], const float m3[3][3], const float m4[3][3],
+ const float m5[3][3], const float m6[3][3], const float m7[3][3], const float m8[3][3])
{
mul_m3_m3m3(r, m1, m2);
mul_m3_m3m3(r, r, m3);
@@ -412,20 +412,20 @@ void _va_mul_m3_series_9(
* \{ */
void _va_mul_m4_series_3(
float r[4][4],
- float m1[4][4], float m2[4][4])
+ const float m1[4][4], const float m2[4][4])
{
mul_m4_m4m4(r, m1, m2);
}
void _va_mul_m4_series_4(
float r[4][4],
- float m1[4][4], float m2[4][4], float m3[4][4])
+ const float m1[4][4], const float m2[4][4], const float m3[4][4])
{
mul_m4_m4m4(r, m1, m2);
mul_m4_m4m4(r, r, m3);
}
void _va_mul_m4_series_5(
float r[4][4],
- float m1[4][4], float m2[4][4], float m3[4][4], float m4[4][4])
+ const float m1[4][4], const float m2[4][4], const float m3[4][4], const float m4[4][4])
{
mul_m4_m4m4(r, m1, m2);
mul_m4_m4m4(r, r, m3);
@@ -433,8 +433,8 @@ void _va_mul_m4_series_5(
}
void _va_mul_m4_series_6(
float r[4][4],
- float m1[4][4], float m2[4][4], float m3[4][4], float m4[4][4],
- float m5[4][4])
+ const float m1[4][4], const float m2[4][4], const float m3[4][4], const float m4[4][4],
+ const float m5[4][4])
{
mul_m4_m4m4(r, m1, m2);
mul_m4_m4m4(r, r, m3);
@@ -443,8 +443,8 @@ void _va_mul_m4_series_6(
}
void _va_mul_m4_series_7(
float r[4][4],
- float m1[4][4], float m2[4][4], float m3[4][4], float m4[4][4],
- float m5[4][4], float m6[4][4])
+ const float m1[4][4], const float m2[4][4], const float m3[4][4], const float m4[4][4],
+ const float m5[4][4], const float m6[4][4])
{
mul_m4_m4m4(r, m1, m2);
mul_m4_m4m4(r, r, m3);
@@ -454,8 +454,8 @@ void _va_mul_m4_series_7(
}
void _va_mul_m4_series_8(
float r[4][4],
- float m1[4][4], float m2[4][4], float m3[4][4], float m4[4][4],
- float m5[4][4], float m6[4][4], float m7[4][4])
+ const float m1[4][4], const float m2[4][4], const float m3[4][4], const float m4[4][4],
+ const float m5[4][4], const float m6[4][4], const float m7[4][4])
{
mul_m4_m4m4(r, m1, m2);
mul_m4_m4m4(r, r, m3);
@@ -466,8 +466,8 @@ void _va_mul_m4_series_8(
}
void _va_mul_m4_series_9(
float r[4][4],
- float m1[4][4], float m2[4][4], float m3[4][4], float m4[4][4],
- float m5[4][4], float m6[4][4], float m7[4][4], float m8[4][4])
+ const float m1[4][4], const float m2[4][4], const float m3[4][4], const float m4[4][4],
+ const float m5[4][4], const float m6[4][4], const float m7[4][4], const float m8[4][4])
{
mul_m4_m4m4(r, m1, m2);
mul_m4_m4m4(r, r, m3);
@@ -1728,6 +1728,9 @@ void rotate_m4(float mat[4][4], const char axis, const float angle)
mat[0][col] = temp;
}
break;
+ default:
+ BLI_assert(0);
+ break;
}
}
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c
index 40a78adcefe..05562502278 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -652,6 +652,31 @@ void project_v3_v3v3(float out[3], const float p[3], const float v_proj[3])
}
/**
+ * Project \a p onto a unit length \a v_proj
+ */
+void project_v2_v2v2_normalized(float out[2], const float p[2], const float v_proj[2])
+{
+ BLI_ASSERT_UNIT_V2(v_proj);
+ const float mul = dot_v2v2(p, v_proj);
+
+ out[0] = mul * v_proj[0];
+ out[1] = mul * v_proj[1];
+}
+
+/**
+ * Project \a p onto a unit length \a v_proj
+ */
+void project_v3_v3v3_normalized(float out[3], const float p[3], const float v_proj[3])
+{
+ BLI_ASSERT_UNIT_V3(v_proj);
+ const float mul = dot_v3v3(p, v_proj);
+
+ out[0] = mul * v_proj[0];
+ out[1] = mul * v_proj[1];
+ out[2] = mul * v_proj[2];
+}
+
+/**
* In this case plane is a 3D vector only (no 4th component).
*
* Projecting will make \a c a copy of \a v orthogonal to \a v_plane.
diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c
index f834c5b4c74..83012694ac0 100644
--- a/source/blender/blenlib/intern/noise.c
+++ b/source/blender/blenlib/intern/noise.c
@@ -1394,6 +1394,11 @@ static float voronoi_CrS(float x, float y, float z)
/* returns unsigned cellnoise */
static float cellNoiseU(float x, float y, float z)
{
+ /* avoid precision issues on unit coordinates */
+ x = (x + 0.000001f) * 1.00001f;
+ y = (y + 0.000001f) * 1.00001f;
+ z = (z + 0.000001f) * 1.00001f;
+
int xi = (int)(floor(x));
int yi = (int)(floor(y));
int zi = (int)(floor(z));
@@ -1411,6 +1416,11 @@ float cellNoise(float x, float y, float z)
/* returns a vector/point/color in ca, using point hasharray directly */
void cellNoiseV(float x, float y, float z, float ca[3])
{
+ /* avoid precision issues on unit coordinates */
+ x = (x + 0.000001f) * 1.00001f;
+ y = (y + 0.000001f) * 1.00001f;
+ z = (z + 0.000001f) * 1.00001f;
+
int xi = (int)(floor(x));
int yi = (int)(floor(y));
int zi = (int)(floor(z));
diff --git a/source/blender/blenlib/intern/polyfill2d.c b/source/blender/blenlib/intern/polyfill2d.c
index 5f9b92198a5..018e2f9be5a 100644
--- a/source/blender/blenlib/intern/polyfill2d.c
+++ b/source/blender/blenlib/intern/polyfill2d.c
@@ -411,11 +411,11 @@ static bool kdtree2d_isect_tri_recursive(
}
#define KDTREE2D_ISECT_TRI_RECURSE_NEG \
- (((node->neg != KDNODE_UNSET) && (co[node->axis] > bounds[node->axis].min)) && \
+ (((node->neg != KDNODE_UNSET) && (co[node->axis] >= bounds[node->axis].min)) && \
(kdtree2d_isect_tri_recursive(tree, tri_index, tri_coords, tri_center, bounds, \
&tree->nodes[node->neg])))
#define KDTREE2D_ISECT_TRI_RECURSE_POS \
- (((node->pos != KDNODE_UNSET) && (co[node->axis] < bounds[node->axis].max)) && \
+ (((node->pos != KDNODE_UNSET) && (co[node->axis] <= bounds[node->axis].max)) && \
(kdtree2d_isect_tri_recursive(tree, tri_index, tri_coords, tri_center, bounds, \
&tree->nodes[node->pos])))
@@ -698,12 +698,12 @@ static bool pf_ear_tip_check(PolyFill *pf, PolyIndex *pi_ear_tip)
/* check if counting is wrong */
{
uint coords_tot_concave_test = 0;
- uint i = pf->coords_tot;
- while (i--) {
- if (coords_sign[indices[i]] != CONVEX) {
+ PolyIndex *pi_iter = pi_ear_tip;
+ do {
+ if (pi_iter->sign != CONVEX) {
coords_tot_concave_test += 1;
}
- }
+ } while ((pi_iter = pi_iter->next) != pi_ear_tip);
BLI_assert(coords_tot_concave_test == pf->coords_tot_concave);
}
#endif
diff --git a/source/blender/blenlib/intern/polyfill2d_beautify.c b/source/blender/blenlib/intern/polyfill2d_beautify.c
index 896177f436c..5f6fb8e6cd4 100644
--- a/source/blender/blenlib/intern/polyfill2d_beautify.c
+++ b/source/blender/blenlib/intern/polyfill2d_beautify.c
@@ -121,45 +121,53 @@ BLI_INLINE bool is_boundary_edge(unsigned int i_a, unsigned int i_b, const unsig
* Assuming we have 2 triangles sharing an edge (2 - 4),
* check if the edge running from (1 - 3) gives better results.
*
+ * \param lock_degenerate: Use to avoid rotating out of a degenerate state.
+ * - When true, an existing zero area face on either side of the (2 - 4) split will return a positive value.
+ * - When false, the check must be non-biased towards either split direction.
+ *
* \return (negative number means the edge can be rotated, lager == better).
*/
-float BLI_polyfill_beautify_quad_rotate_calc(
- const float v1[2], const float v2[2], const float v3[2], const float v4[2])
+float BLI_polyfill_beautify_quad_rotate_calc_ex(
+ const float v1[2], const float v2[2], const float v3[2], const float v4[2],
+ const bool lock_degenerate)
{
/* not a loop (only to be able to break out) */
do {
- bool is_zero_a, is_zero_b;
-
+ /* Allow very small faces to be considered non-zero. */
+ const float eps_zero_area = 1e-12f;
const float area_2x_234 = cross_tri_v2(v2, v3, v4);
const float area_2x_241 = cross_tri_v2(v2, v4, v1);
const float area_2x_123 = cross_tri_v2(v1, v2, v3);
const float area_2x_134 = cross_tri_v2(v1, v3, v4);
- {
- BLI_assert((ELEM(v1, v2, v3, v4) == false) &&
- (ELEM(v2, v1, v3, v4) == false) &&
- (ELEM(v3, v1, v2, v4) == false) &&
- (ELEM(v4, v1, v2, v3) == false));
-
- is_zero_a = (fabsf(area_2x_234) <= FLT_EPSILON);
- is_zero_b = (fabsf(area_2x_241) <= FLT_EPSILON);
-
- if (is_zero_a && is_zero_b) {
- break;
- }
+ BLI_assert((ELEM(v1, v2, v3, v4) == false) &&
+ (ELEM(v2, v1, v3, v4) == false) &&
+ (ELEM(v3, v1, v2, v4) == false) &&
+ (ELEM(v4, v1, v2, v3) == false));
+ /*
+ * Test for unusable (1-3) state.
+ * - Area sign flipping to check faces aren't going to point in opposite directions.
+ * - Area epsilon check that the one of the faces won't be zero area.
+ */
+ if ((area_2x_123 >= 0.0f) != (area_2x_134 >= 0.0f)) {
+ break;
}
-
- /* one of the tri's was degenerate, check we're not rotating
- * into a different degenerate shape or flipping the face */
- if ((fabsf(area_2x_123) <= FLT_EPSILON) || (fabsf(area_2x_134) <= FLT_EPSILON)) {
- /* one of the new rotations is degenerate */
+ else if ((fabsf(area_2x_123) <= eps_zero_area) || (fabsf(area_2x_134) <= eps_zero_area)) {
break;
}
- if ((area_2x_123 >= 0.0f) != (area_2x_134 >= 0.0f)) {
- /* rotation would cause flipping */
- break;
+ /* Test for unusable (2-4) state (same as above). */
+ if ((area_2x_234 >= 0.0f) != (area_2x_241 >= 0.0f)) {
+ if (lock_degenerate) {
+ break;
+ }
+ else {
+ return -FLT_MAX; /* always rotate */
+ }
+ }
+ else if ((fabsf(area_2x_234) <= eps_zero_area) || (fabsf(area_2x_241) <= eps_zero_area)) {
+ return -FLT_MAX; /* always rotate */
}
{
diff --git a/source/blender/blenlib/intern/rand.c b/source/blender/blenlib/intern/rand.c
index 40d9a3da3d9..a501d38abb7 100644
--- a/source/blender/blenlib/intern/rand.c
+++ b/source/blender/blenlib/intern/rand.c
@@ -41,6 +41,9 @@
#include "BLI_rand.h"
#include "BLI_math.h"
+/* defines BLI_INLINE */
+#include "BLI_utildefines.h"
+
#include "BLI_sys_types.h"
#include "BLI_strict_flags.h"
@@ -353,3 +356,90 @@ int BLI_rng_thread_rand(RNG_THREAD_ARRAY *rngarr, int thread)
return BLI_rng_get_int(&rngarr->rng_tab[thread]);
}
+/* ********* Low-discrepancy sequences ************** */
+
+/* incremental halton sequence generator, from:
+ * "Instant Radiosity", Keller A. */
+BLI_INLINE double halton_ex(double invprimes, double *offset)
+{
+ double e = fabs((1.0 - *offset) - 1e-10);
+
+ if (invprimes >= e) {
+ double lasth;
+ double h = invprimes;
+
+ do {
+ lasth = h;
+ h *= invprimes;
+ } while (h >= e);
+
+ *offset += ((lasth + h) - 1.0);
+ }
+ else {
+ *offset += invprimes;
+ }
+
+ return *offset;
+}
+
+void BLI_halton_1D(unsigned int prime, double offset, int n, double *r)
+{
+ const double invprime = 1.0 / (double)prime;
+
+ for (int s = 0; s < n; s++) {
+ *r = halton_ex(invprime, &offset);
+ }
+}
+
+void BLI_halton_2D(unsigned int prime[2], double offset[2], int n, double *r)
+{
+ const double invprimes[2] = {1.0 / (double)prime[0], 1.0 / (double)prime[1]};
+
+ for (int s = 0; s < n; s++) {
+ for (int i = 0; i < 2; i++) {
+ r[i] = halton_ex(invprimes[i], &offset[i]);
+ }
+ }
+}
+
+void BLI_halton_2D_sequence(unsigned int prime[2], double offset[2], int n, double *r)
+{
+ const double invprimes[2] = {1.0 / (double)prime[0], 1.0 / (double)prime[1]};
+
+ for (int s = 0; s < n; s++) {
+ for (int i = 0; i < 2; i++) {
+ r[s * 2 + i] = halton_ex(invprimes[i], &offset[i]);
+ }
+ }
+}
+
+
+/* From "Sampling with Hammersley and Halton Points" TT Wong
+ * Appendix: Source Code 1 */
+BLI_INLINE double radical_inverse(unsigned int n)
+{
+ double u = 0;
+
+ /* This reverse the bitwise representation
+ * around the decimal point. */
+ for (double p = 0.5; n; p *= 0.5, n >>= 1) {
+ if (n & 1) {
+ u += p;
+ }
+ }
+
+ return u;
+}
+
+void BLI_hammersley_1D(unsigned int n, double *r)
+{
+ *r = radical_inverse(n);
+}
+
+void BLI_hammersley_2D_sequence(unsigned int n, double *r)
+{
+ for (unsigned int s = 0; s < n; s++) {
+ r[s * 2 + 0] = (double)(s + 0.5) / (double)n;
+ r[s * 2 + 1] = radical_inverse(s);
+ }
+} \ No newline at end of file
diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c
index e0c4cbe9990..3adc6b30f6e 100644
--- a/source/blender/blenlib/intern/rct.c
+++ b/source/blender/blenlib/intern/rct.c
@@ -32,6 +32,7 @@
* A minimalist lib for functions doing stuff with rectangle structs.
*/
+#include <stdlib.h>
#include <stdio.h>
#include <math.h>
@@ -41,6 +42,9 @@
#include "DNA_vec_types.h"
#include "BLI_rect.h"
+/* avoid including BLI_math */
+static void unit_m4(float m[4][4]);
+
/**
* Determine if a rect is empty. An empty
* rect is one with a zero (or negative)
@@ -405,6 +409,31 @@ void BLI_rctf_transform_pt_v(const rctf *dst, const rctf *src, float xy_dst[2],
xy_dst[1] = dst->ymin + ((dst->ymax - dst->ymin) * xy_dst[1]);
}
+/**
+ * Calculate a 4x4 matrix representing the transformation between two rectangles.
+ *
+ * \note Multiplying a vector by this matrix does *not* give the same value as #BLI_rctf_transform_pt_v.
+ */
+void BLI_rctf_transform_calc_m4_pivot_min_ex(
+ const rctf *dst, const rctf *src, float matrix[4][4],
+ uint x, uint y)
+{
+ BLI_assert(x < 3 && y < 3);
+
+ unit_m4(matrix);
+
+ matrix[x][x] = BLI_rctf_size_x(src) / BLI_rctf_size_x(dst);
+ matrix[y][y] = BLI_rctf_size_y(src) / BLI_rctf_size_y(dst);
+ matrix[3][x] = (src->xmin - dst->xmin) * matrix[x][x];
+ matrix[3][y] = (src->ymin - dst->ymin) * matrix[y][y];
+}
+
+void BLI_rctf_transform_calc_m4_pivot_min(
+ const rctf *dst, const rctf *src, float matrix[4][4])
+{
+ BLI_rctf_transform_calc_m4_pivot_min_ex(dst, src, matrix, 0, 1);
+}
+
void BLI_rcti_translate(rcti *rect, int x, int y)
{
rect->xmin += x;
@@ -763,3 +792,12 @@ void BLI_rctf_rotate_expand(rctf *dst, const rctf *src, const float angle)
#undef ROTATE_SINCOS
/** \} */
+
+static void unit_m4(float m[4][4])
+{
+ m[0][0] = m[1][1] = m[2][2] = m[3][3] = 1.0f;
+ m[0][1] = m[0][2] = m[0][3] = 0.0f;
+ m[1][0] = m[1][2] = m[1][3] = 0.0f;
+ m[2][0] = m[2][1] = m[2][3] = 0.0f;
+ m[3][0] = m[3][1] = m[3][2] = 0.0f;
+}
diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c
index b819c513fbd..a48c8b074dd 100644
--- a/source/blender/blenlib/intern/storage.c
+++ b/source/blender/blenlib/intern/storage.c
@@ -37,14 +37,10 @@
#include <sys/stat.h>
-#if defined(__NetBSD__) || defined(__DragonFly__) || defined(__sun__) || defined(__sun)
+#if defined(__NetBSD__) || defined(__DragonFly__)
/* Other modern unix os's should probably use this also */
# include <sys/statvfs.h>
# define USE_STATFS_STATVFS
-#elif (defined(__sparc) || defined(__sparc__)) && !defined(__FreeBSD__) && !defined(__linux__)
-# include <sys/statfs.h>
- /* 4 argument version (not common) */
-# define USE_STATFS_4ARGS
#endif
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
diff --git a/source/blender/blenlib/intern/string_utils.c b/source/blender/blenlib/intern/string_utils.c
index 8d91a55a5ad..a693463a302 100644
--- a/source/blender/blenlib/intern/string_utils.c
+++ b/source/blender/blenlib/intern/string_utils.c
@@ -383,3 +383,91 @@ bool BLI_uniquename(ListBase *list, void *vlink, const char *defname, char delim
return BLI_uniquename_cb(uniquename_unique_check, &data, defname, delim, GIVE_STRADDR(vlink, name_offs), name_len);
}
+
+/* ------------------------------------------------------------------------- */
+/** \name Join Strings
+ *
+ * For non array versions of these functions, use the macros:
+ * - #BLI_string_joinN
+ * - #BLI_string_join_by_sep_charN
+ * - #BLI_string_join_by_sep_char_with_tableN
+ *
+ * \{ */
+
+/**
+ * Join an array of strings into a newly allocated, null terminated string.
+ */
+char *BLI_string_join_arrayN(
+ const char *strings[], uint strings_len)
+{
+ uint total_len = 1;
+ for (uint i = 0; i < strings_len; i++) {
+ total_len += strlen(strings[i]);
+ }
+ char *result = MEM_mallocN(sizeof(char) * total_len, __func__);
+ char *c = result;
+ for (uint i = 0; i < strings_len; i++) {
+ c += BLI_strcpy_rlen(c, strings[i]);
+ }
+ return result;
+}
+
+/**
+ * A version of #BLI_string_joinN that takes a separator which can be any character including '\0'.
+ */
+char *BLI_string_join_array_by_sep_charN(
+ char sep, const char *strings[], uint strings_len)
+{
+ uint total_len = 0;
+ for (uint i = 0; i < strings_len; i++) {
+ total_len += strlen(strings[i]) + 1;
+ }
+ if (total_len == 0) {
+ total_len = 1;
+ }
+
+ char *result = MEM_mallocN(sizeof(char) * total_len, __func__);
+ char *c = result;
+ if (strings_len != 0) {
+ for (uint i = 0; i < strings_len; i++) {
+ c += BLI_strcpy_rlen(c, strings[i]);
+ *c = sep;
+ c++;
+ }
+ c--;
+ }
+ *c = '\0';
+ return result;
+}
+
+/**
+ * A version of #BLI_string_join_array_by_sep_charN that takes a table array.
+ * The new location of each string is written into this array.
+ */
+char *BLI_string_join_array_by_sep_char_with_tableN(
+ char sep, char *table[], const char *strings[], uint strings_len)
+{
+ uint total_len = 0;
+ for (uint i = 0; i < strings_len; i++) {
+ total_len += strlen(strings[i]) + 1;
+ }
+ if (total_len == 0) {
+ total_len = 1;
+ }
+
+ char *result = MEM_mallocN(sizeof(char) * total_len, __func__);
+ char *c = result;
+ if (strings_len != 0) {
+ for (uint i = 0; i < strings_len; i++) {
+ table[i] = c; /* <-- only difference to BLI_string_join_array_by_sep_charN. */
+ c += BLI_strcpy_rlen(c, strings[i]);
+ *c = sep;
+ c++;
+ }
+ c--;
+ }
+ *c = '\0';
+ return result;
+}
+
+/** \} */
diff --git a/source/blender/blenlib/intern/timecode.c b/source/blender/blenlib/intern/timecode.c
index e755a7ae52c..7856bad4d99 100644
--- a/source/blender/blenlib/intern/timecode.c
+++ b/source/blender/blenlib/intern/timecode.c
@@ -94,11 +94,11 @@ size_t BLI_timecode_string_from_time(
* to cope with 'half' frames, etc., which should be fine in most cases
*/
seconds = (int)time;
- frames = iroundf((float)(((double)time - (double)seconds) * fps));
+ frames = round_fl_to_int((float)(((double)time - (double)seconds) * fps));
}
else {
/* seconds (with pixel offset rounding) */
- seconds = iroundf(time);
+ seconds = round_fl_to_int(time);
}
switch (timecode_style) {
@@ -169,7 +169,7 @@ size_t BLI_timecode_string_from_time(
/* precision of decimal part */
const int ms_dp = (power <= 0) ? (1 - power) : 1;
- const int ms = iroundf((time - (float)seconds) * 1000.0f);
+ const int ms = round_fl_to_int((time - (float)seconds) * 1000.0f);
rlen = BLI_snprintf_rlen(
str, maxncpy, "%s%02d:%02d:%02d,%0*d", neg, hours, minutes, seconds, ms_dp, ms);
@@ -183,7 +183,7 @@ size_t BLI_timecode_string_from_time(
rlen = BLI_snprintf_rlen(str, maxncpy, "%.*f", 1 - power, time_seconds);
}
else {
- rlen = BLI_snprintf_rlen(str, maxncpy, "%d", iroundf(time_seconds));
+ rlen = BLI_snprintf_rlen(str, maxncpy, "%d", round_fl_to_int(time_seconds));
}
break;
}
@@ -250,7 +250,7 @@ size_t BLI_timecode_string_from_time_seconds(
rlen = BLI_snprintf_rlen(str, maxncpy, "%.*f", 1 - power, time_seconds);
}
else {
- rlen = BLI_snprintf_rlen(str, maxncpy, "%d", iroundf(time_seconds));
+ rlen = BLI_snprintf_rlen(str, maxncpy, "%d", round_fl_to_int(time_seconds));
}
return rlen;
diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt
index 0a678cfe6f8..61d1aa18b3c 100644
--- a/source/blender/blenloader/CMakeLists.txt
+++ b/source/blender/blenloader/CMakeLists.txt
@@ -81,6 +81,10 @@ if(WITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
endif()
+if(WITH_CLAY_ENGINE)
+ add_definitions(-DWITH_CLAY_ENGINE)
+endif()
+
if(WITH_CODEC_FFMPEG)
add_definitions(-DWITH_FFMPEG)
endif()
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index fc97beb2c7e..a421abd852d 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -649,7 +649,7 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab
/* Add library datablock itself to 'main' Main, since libraries are **never** linked data.
* Fixes bug where you could end with all ID_LI datablocks having the same name... */
- lib = BKE_libblock_alloc(mainlist->first, ID_LI, "Lib");
+ lib = BKE_libblock_alloc(mainlist->first, ID_LI, "Lib", 0);
lib->id.us = ID_FAKE_USERS(lib); /* Important, consistency with main ID reading code from read_libblock(). */
BLI_strncpy(lib->name, filepath, sizeof(lib->name));
BLI_strncpy(lib->filepath, name1, sizeof(lib->filepath));
@@ -2221,6 +2221,7 @@ static void direct_link_id(FileData *fd, ID *id)
/* this case means the data was written incorrectly, it should not happen */
IDP_DirectLinkGroup_OrFree(&id->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
}
+ id->py_instance = NULL;
}
/* ************ READ CurveMapping *************** */
@@ -4793,7 +4794,15 @@ static void lib_link_object(FileData *fd, Main *main)
ob->parent = newlibadr(fd, ob->id.lib, ob->parent);
ob->track = newlibadr(fd, ob->id.lib, ob->track);
ob->poselib = newlibadr_us(fd, ob->id.lib, ob->poselib);
- ob->dup_group = newlibadr_us(fd, ob->id.lib, ob->dup_group);
+
+ /* 2.8x drops support for non-empty dupli instances. */
+ if (ob->type == OB_EMPTY) {
+ ob->dup_group = newlibadr_us(fd, ob->id.lib, ob->dup_group);
+ }
+ else {
+ ob->dup_group = NULL;
+ ob->transflag &= ~OB_DUPLIGROUP;
+ }
ob->proxy = newlibadr_us(fd, ob->id.lib, ob->proxy);
if (ob->proxy) {
@@ -6085,7 +6094,7 @@ static void direct_link_scene(FileData *fd, Scene *sce, Main *bmain)
SceneRenderLayer *srl;
sce->theDag = NULL;
- sce->depsgraph = NULL;
+ sce->depsgraph_legacy = NULL;
sce->obedit = NULL;
sce->fps_info = NULL;
sce->customdata_mask_modal = 0;
@@ -6121,16 +6130,6 @@ static void direct_link_scene(FileData *fd, Scene *sce, Main *bmain)
sce->toolsettings->particle.scene_layer = NULL;
sce->toolsettings->particle.object = NULL;
sce->toolsettings->gp_sculpt.paintcursor = NULL;
-
- /* in rare cases this is needed, see [#33806] */
- if (sce->toolsettings->vpaint) {
- sce->toolsettings->vpaint->vpaint_prev = NULL;
- sce->toolsettings->vpaint->tot = 0;
- }
- if (sce->toolsettings->wpaint) {
- sce->toolsettings->wpaint->wpaint_prev = NULL;
- sce->toolsettings->wpaint->tot = 0;
- }
/* relink grease pencil drawing brushes */
link_list(fd, &sce->toolsettings->gp_brushes);
@@ -6280,11 +6279,6 @@ static void direct_link_scene(FileData *fd, Scene *sce, Main *bmain)
sce->r.avicodecdata->lpFormat = newdataadr(fd, sce->r.avicodecdata->lpFormat);
sce->r.avicodecdata->lpParms = newdataadr(fd, sce->r.avicodecdata->lpParms);
}
-
- sce->r.qtcodecdata = newdataadr(fd, sce->r.qtcodecdata);
- if (sce->r.qtcodecdata) {
- sce->r.qtcodecdata->cdParms = newdataadr(fd, sce->r.qtcodecdata->cdParms);
- }
if (sce->r.ffcodecdata.properties) {
sce->r.ffcodecdata.properties = newdataadr(fd, sce->r.ffcodecdata.properties);
IDP_DirectLinkGroup_OrFree(&sce->r.ffcodecdata.properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
@@ -10116,6 +10110,7 @@ void BLO_expand_main(void *fdhandle, Main *mainvar)
break;
case ID_WS:
expand_workspace(fd, mainvar, (WorkSpace *)id);
+ default:
break;
}
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index db32b48c717..b945f5bdcd3 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -60,6 +60,7 @@
#include "DNA_genfile.h"
#include "BKE_animsys.h"
+#include "BKE_brush.h"
#include "BKE_colortools.h"
#include "BKE_library.h"
#include "BKE_main.h"
@@ -1236,12 +1237,19 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
SEQ_BEGIN (scene->ed, seq)
{
- if (seq->type == SEQ_TYPE_TEXT) {
- TextVars *data = seq->effectdata;
- if (data->color[3] == 0.0f) {
- copy_v4_fl(data->color, 1.0f);
- data->shadow_color[3] = 1.0f;
- }
+ if (seq->type != SEQ_TYPE_TEXT) {
+ continue;
+ }
+
+ if (seq->effectdata == NULL) {
+ struct SeqEffectHandle effect_handle = BKE_sequence_get_effect(seq);
+ effect_handle.init(seq);
+ }
+
+ TextVars *data = seq->effectdata;
+ if (data->color[3] == 0.0f) {
+ copy_v4_fl(data->color, 1.0f);
+ data->shadow_color[3] = 1.0f;
}
}
SEQ_END
@@ -1652,7 +1660,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
} FOREACH_NODETREE_END
}
- {
+ if (!MAIN_VERSION_ATLEAST(main, 279, 0)) {
for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
if (scene->r.im_format.exr_codec == R_IMF_EXR_CODEC_DWAB) {
scene->r.im_format.exr_codec = R_IMF_EXR_CODEC_DWAA;
@@ -1685,12 +1693,44 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
}
+
+ {
+ /* Fix for invalid state of screen due to bug in older versions. */
+ for (bScreen *sc = main->screen.first; sc; sc = sc->id.next) {
+ for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
+ if (sa->full && sc->state == SCREENNORMAL) {
+ sa->full = NULL;
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "Brush", "float", "falloff_angle")) {
+ for (Brush *br = main->brush.first; br; br = br->id.next) {
+ br->falloff_angle = DEG2RADF(80);
+ br->flag &= ~(
+ BRUSH_FLAG_DEPRECATED_1 | BRUSH_FLAG_DEPRECATED_2 |
+ BRUSH_FLAG_DEPRECATED_3 | BRUSH_FLAG_DEPRECATED_4 |
+ BRUSH_FRONTFACE_FALLOFF);
+ }
+
+ for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ ToolSettings *ts = scene->toolsettings;
+ for (int i = 0; i < 2; i++) {
+ VPaint *vp = i ? ts->vpaint : ts->wpaint;
+ if (vp != NULL) {
+ /* remove all other flags */
+ vp->flag &= (VP_FLAG_VGROUP_RESTRICT);
+ }
+ }
+ }
+ }
+ }
}
void do_versions_after_linking_270(Main *main)
{
/* To be added to next subversion bump! */
- {
+ if (!MAIN_VERSION_ATLEAST(main, 279, 0)) {
FOREACH_NODETREE(main, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
ntreeSetTypes(NULL, ntree);
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 664f1e07f71..ba46c8f81b8 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -85,7 +85,7 @@ static void do_version_workspaces_create_from_screens(Main *bmain)
for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
const bScreen *screen_parent = screen_parent_find(screen);
WorkSpace *workspace;
- SceneLayer *layer = BKE_scene_layer_render_active(screen->scene);
+ SceneLayer *layer = BKE_scene_layer_from_scene_get(screen->scene);
ListBase *transform_orientations;
if (screen_parent) {
@@ -287,7 +287,7 @@ void do_versions_after_linking_280(Main *main)
if (!MAIN_VERSION_ATLEAST(main, 280, 0)) {
for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
/* same render-layer as do_version_workspaces_after_lib_link will activate,
- * so same layer as BKE_scene_layer_context_active would return */
+ * so same layer as BKE_scene_layer_from_workspace_get would return */
SceneLayer *layer = screen->scene->render_layers.first;
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
@@ -345,7 +345,18 @@ static void do_version_layer_collections_idproperties(ListBase *lb)
void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
{
+
if (!MAIN_VERSION_ATLEAST(main, 280, 0)) {
+ for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ if (STREQ(scene->r.engine, RE_engine_id_BLENDER_RENDER)) {
+#ifdef WITH_CLAY_ENGINE
+ BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_CLAY, sizeof(scene->r.engine));
+#else
+ BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine));
+#endif
+ }
+ }
+
if (!DNA_struct_elem_find(fd->filesdna, "Scene", "ListBase", "render_layers")) {
for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
/* Master Collection */
@@ -366,13 +377,13 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
}
if (!MAIN_VERSION_ATLEAST(main, 280, 1)) {
- if (!DNA_struct_elem_find(fd->filesdna, "Lamp", "float", "bleedexp")) {
+ if (!DNA_struct_elem_find(fd->filesdna, "Lamp", "float", "bleedexp")) {
for (Lamp *la = main->lamp.first; la; la = la->id.next) {
la->bleedexp = 120.0f;
}
}
- if (!DNA_struct_elem_find(fd->filesdna, "GPUDOFSettings", "float", "ratio")) {
+ if (!DNA_struct_elem_find(fd->filesdna, "GPUDOFSettings", "float", "ratio")) {
for (Camera *ca = main->camera.first; ca; ca = ca->id.next) {
ca->gpu_dof.ratio = 1.0f;
}
@@ -422,30 +433,81 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
}
{
- {
- /* Eevee shader nodes renamed because of the output node system.
- * Note that a new output node is not being added here, because it would be overkill
- * to handle this case in lib_verify_nodetree. */
- bool error = false;
- FOREACH_NODETREE(main, ntree, id) {
- if (ntree->type == NTREE_SHADER) {
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
- if (node->type == SH_NODE_EEVEE_METALLIC && STREQ(node->idname, "ShaderNodeOutputMetallic")) {
- BLI_strncpy(node->idname, "ShaderNodeEeveeMetallic", sizeof(node->idname));
- error = true;
- }
+ if (!DNA_struct_elem_find(fd->filesdna, "Lamp", "float", "cascade_max_dist")) {
+ for (Lamp *la = main->lamp.first; la; la = la->id.next) {
+ la->cascade_max_dist = 1000.0f;
+ la->cascade_count = 4;
+ la->cascade_exponent = 0.8f;
+ la->cascade_fade = 0.1f;
+ }
+ }
- if (node->type == SH_NODE_EEVEE_SPECULAR && STREQ(node->idname, "ShaderNodeOutputSpecular")) {
- BLI_strncpy(node->idname, "ShaderNodeEeveeSpecular", sizeof(node->idname));
- error = true;
- }
+ if (!DNA_struct_elem_find(fd->filesdna, "Lamp", "float", "contact_dist")) {
+ for (Lamp *la = main->lamp.first; la; la = la->id.next) {
+ la->contact_dist = 1.0f;
+ la->contact_bias = 0.03f;
+ la->contact_spread = 0.2f;
+ la->contact_thickness = 0.5f;
+ }
+ }
+ }
+
+ {
+ typedef enum eNTreeDoVersionErrors {
+ NTREE_DOVERSION_NO_ERROR = 0,
+ NTREE_DOVERSION_NEED_OUTPUT = (1 << 0),
+ NTREE_DOVERSION_TRANSPARENCY_EMISSION = (1 << 1),
+ } eNTreeDoVersionErrors;
+
+ /* Eevee shader nodes renamed because of the output node system.
+ * Note that a new output node is not being added here, because it would be overkill
+ * to handle this case in lib_verify_nodetree.
+ *
+ * Also, metallic node is now unified into the principled node. */
+ eNTreeDoVersionErrors error = NTREE_DOVERSION_NO_ERROR;
+
+ FOREACH_NODETREE(main, ntree, id) {
+ if (ntree->type == NTREE_SHADER) {
+ for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == 194 /* SH_NODE_EEVEE_METALLIC */ &&
+ STREQ(node->idname, "ShaderNodeOutputMetallic"))
+ {
+ BLI_strncpy(node->idname, "ShaderNodeEeveeMetallic", sizeof(node->idname));
+ error |= NTREE_DOVERSION_NEED_OUTPUT;
+ }
+
+ else if (node->type == SH_NODE_EEVEE_SPECULAR && STREQ(node->idname, "ShaderNodeOutputSpecular")) {
+ BLI_strncpy(node->idname, "ShaderNodeEeveeSpecular", sizeof(node->idname));
+ error |= NTREE_DOVERSION_NEED_OUTPUT;
+ }
+
+ else if (node->type == 196 /* SH_NODE_OUTPUT_EEVEE_MATERIAL */ &&
+ STREQ(node->idname, "ShaderNodeOutputEeveeMaterial"))
+ {
+ node->type = SH_NODE_OUTPUT_MATERIAL;
+ BLI_strncpy(node->idname, "ShaderNodeOutputMaterial", sizeof(node->idname));
+ }
+
+ else if (node->type == 194 /* SH_NODE_EEVEE_METALLIC */ &&
+ STREQ(node->idname, "ShaderNodeEeveeMetallic"))
+ {
+ node->type = SH_NODE_BSDF_PRINCIPLED;
+ BLI_strncpy(node->idname, "ShaderNodeBsdfPrincipled", sizeof(node->idname));
+ node->custom1 = SHD_GLOSSY_MULTI_GGX;
+ error |= NTREE_DOVERSION_TRANSPARENCY_EMISSION;
}
}
- } FOREACH_NODETREE_END
- if (error) {
- BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console");
- printf("You need to connect Eevee Metallic and Specular shader nodes to new material output nodes.\n");
}
+ } FOREACH_NODETREE_END
+
+ if (error & NTREE_DOVERSION_NEED_OUTPUT) {
+ BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console");
+ printf("You need to connect Principled and Eevee Specular shader nodes to new material output nodes.\n");
+ }
+
+ if (error & NTREE_DOVERSION_TRANSPARENCY_EMISSION) {
+ BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console");
+ printf("You need to combine transparency and emission shaders to the converted Principled shader nodes.\n");
}
}
}
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index 50f96a6d438..54ed29ab6fa 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -61,6 +61,9 @@ void BLO_update_defaults_userpref_blend(void)
U.uiflag |= USER_QUIT_PROMPT;
U.uiflag |= USER_CONTINUOUS_MOUSE;
+ /* See T45301 */
+ U.uiflag |= USER_LOCK_CURSOR_ADJUST;
+
U.versions = 1;
U.savetime = 2;
@@ -137,6 +140,16 @@ void BLO_update_defaults_startup_blend(Main *bmain)
sculpt->detail_size = 12;
}
+ if (ts->vpaint) {
+ VPaint *vp = ts->vpaint;
+ vp->radial_symm[0] = vp->radial_symm[1] = vp->radial_symm[2] = 1;
+ }
+
+ if (ts->wpaint) {
+ VPaint *wp = ts->wpaint;
+ wp->radial_symm[0] = wp->radial_symm[1] = wp->radial_symm[2] = 1;
+ }
+
if (ts->gp_sculpt.brush[0].size == 0) {
GP_BrushEdit_Settings *gset = &ts->gp_sculpt;
GP_EditBrush_Data *brush;
@@ -262,6 +275,20 @@ void BLO_update_defaults_startup_blend(Main *bmain)
br->ob_mode = OB_MODE_TEXTURE_PAINT;
}
+ /* Vertex/Weight Paint */
+ br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Average");
+ if (!br) {
+ br = BKE_brush_add(bmain, "Average", OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT);
+ br->vertexpaint_tool = PAINT_BLEND_AVERAGE;
+ br->ob_mode = OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT;
+ }
+ br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Smear");
+ if (!br) {
+ br = BKE_brush_add(bmain, "Smear", OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT);
+ br->vertexpaint_tool = PAINT_BLEND_SMEAR;
+ br->ob_mode = OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT;
+ }
+
br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Mask");
if (br) {
br->imagepaint_tool = PAINT_TOOL_MASK;
diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c
index 67b629222a2..55219cbaad7 100644
--- a/source/blender/blenloader/intern/versioning_legacy.c
+++ b/source/blender/blenloader/intern/versioning_legacy.c
@@ -2838,12 +2838,12 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
Scene *sce;
for (sce = main->scene.first; sce; sce = sce->id.next) {
if (sce->toolsettings->skgen_subdivisions[0] == sce->toolsettings->skgen_subdivisions[1] ||
- sce->toolsettings->skgen_subdivisions[0] == sce->toolsettings->skgen_subdivisions[2] ||
- sce->toolsettings->skgen_subdivisions[1] == sce->toolsettings->skgen_subdivisions[2])
+ sce->toolsettings->skgen_subdivisions[0] == sce->toolsettings->skgen_subdivisions[2] ||
+ sce->toolsettings->skgen_subdivisions[1] == sce->toolsettings->skgen_subdivisions[2])
{
- sce->toolsettings->skgen_subdivisions[0] = SKGEN_SUB_CORRELATION;
- sce->toolsettings->skgen_subdivisions[1] = SKGEN_SUB_LENGTH;
- sce->toolsettings->skgen_subdivisions[2] = SKGEN_SUB_ANGLE;
+ sce->toolsettings->skgen_subdivisions[0] = SKGEN_SUB_CORRELATION;
+ sce->toolsettings->skgen_subdivisions[1] = SKGEN_SUB_LENGTH;
+ sce->toolsettings->skgen_subdivisions[2] = SKGEN_SUB_ANGLE;
}
}
}
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 9acd868daba..bfffcbdcae6 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2739,13 +2739,6 @@ static void write_scene(WriteData *wd, Scene *sce)
writedata(wd, DATA, sce->r.avicodecdata->cbParms, sce->r.avicodecdata->lpParms);
}
}
-
- if (sce->r.qtcodecdata) {
- writestruct(wd, DATA, QuicktimeCodecData, 1, sce->r.qtcodecdata);
- if (sce->r.qtcodecdata->cdParms) {
- writedata(wd, DATA, sce->r.qtcodecdata->cdSize, sce->r.qtcodecdata->cdParms);
- }
- }
if (sce->r.ffcodecdata.properties) {
IDP_WriteProperty(sce->r.ffcodecdata.properties, wd);
}
@@ -3946,6 +3939,9 @@ static bool write_file_handle(
}
for (; id; id = id->next) {
+ /* We should never attempt to write non-regular IDs (i.e. all kind of temp/runtime ones). */
+ BLI_assert((id->tag & (LIB_TAG_NO_MAIN | LIB_TAG_NO_USER_REFCOUNT | LIB_TAG_NOT_ALLOCATED)) == 0);
+
switch ((ID_Type)GS(id->name)) {
case ID_WM:
write_windowmanager(wd, (wmWindowManager *)id);
diff --git a/source/blender/blentranslation/CMakeLists.txt b/source/blender/blentranslation/CMakeLists.txt
index c0dce5b4f0d..320a784ea25 100644
--- a/source/blender/blentranslation/CMakeLists.txt
+++ b/source/blender/blentranslation/CMakeLists.txt
@@ -61,4 +61,6 @@ endif()
blender_add_lib(bf_blentranslation "${SRC}" "${INC}" "${INC_SYS}")
-add_subdirectory(msgfmt)
+if(WITH_INTERNATIONAL)
+ add_subdirectory(msgfmt)
+endif()
diff --git a/source/blender/blentranslation/msgfmt/msgfmt.c b/source/blender/blentranslation/msgfmt/msgfmt.c
index 487d9fee7b4..3abce7b1d3f 100644
--- a/source/blender/blentranslation/msgfmt/msgfmt.c
+++ b/source/blender/blentranslation/msgfmt/msgfmt.c
@@ -160,7 +160,8 @@ static char **get_keys_sorted(GHash *messages, const uint32_t num_keys)
return keys;
}
-BLI_INLINE size_t uint32_to_bytes(const int value, char *bytes) {
+BLI_INLINE size_t uint32_to_bytes(const int value, char *bytes)
+{
size_t i;
for (i = 0; i < sizeof(value); i++) {
bytes[i] = (char) ((value >> ((int)i * 8)) & 0xff);
@@ -168,7 +169,8 @@ BLI_INLINE size_t uint32_to_bytes(const int value, char *bytes) {
return i;
}
-BLI_INLINE size_t msg_to_bytes(char *msg, char *bytes, uint32_t size) {
+BLI_INLINE size_t msg_to_bytes(char *msg, char *bytes, uint32_t size)
+{
/* Note that we also perform replacing of our NULLSEP placeholder by real NULL char... */
size_t i;
for (i = 0; i < size; i++, msg++, bytes++) {
@@ -452,7 +454,8 @@ static int make(const char *input_file_name, const char *output_file_name)
return EXIT_SUCCESS;
}
-int main(int argc, char **argv) {
+int main(int argc, char **argv)
+{
if (argc != 3) {
printf("Usage: %s <input.po> <output.mo>\n", argv[0]);
return EXIT_FAILURE;
diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c
index 4fe14fdf5c9..c7ff93cf504 100644
--- a/source/blender/bmesh/intern/bmesh_core.c
+++ b/source/blender/bmesh/intern/bmesh_core.c
@@ -32,7 +32,7 @@
#include "BLI_array.h"
#include "BLI_alloca.h"
#include "BLI_linklist_stack.h"
-#include "BLI_stackdefines.h"
+#include "BLI_utildefines_stack.h"
#include "BLT_translation.h"
@@ -2415,7 +2415,8 @@ static void bmesh_kernel_vert_separate__cleanup(BMesh *bm, LinkNode *edges_separ
/* don't visit again */
n_prev->next = n_step->next;
}
- } while ((n_prev = n_step),
+ } while ((void)
+ (n_prev = n_step),
(n_step = n_step->next));
} while ((n_orig = n_orig->next) && n_orig->next);
diff --git a/source/blender/bmesh/intern/bmesh_edgeloop.c b/source/blender/bmesh/intern/bmesh_edgeloop.c
index 5780dc57d78..b3b23933d2f 100644
--- a/source/blender/bmesh/intern/bmesh_edgeloop.c
+++ b/source/blender/bmesh/intern/bmesh_edgeloop.c
@@ -32,6 +32,7 @@
#include "BLI_math_vector.h"
#include "BLI_listbase.h"
#include "BLI_mempool.h"
+#include "BLI_utildefines_iter.h"
#include "bmesh.h"
@@ -708,21 +709,16 @@ void BM_edgeloop_expand(
}
if (el_store->len < el_store_len) {
- const int step = max_ii(1, el_store->len / (el_store->len % el_store_len));
- LinkData *node_first = el_store->verts.first;
- LinkData *node_curr = node_first;
+ LinkData *node_curr = el_store->verts.first;
- do {
- LinkData *node_curr_init = node_curr;
- LinkData *node_curr_copy;
- int i = 0;
- BLI_LISTBASE_CIRCULAR_FORWARD_BEGIN (&el_store->verts, node_curr, node_curr_init) {
- if (i++ < step) {
- break;
- }
+ int iter_prev = 0;
+ BLI_FOREACH_SPARSE_RANGE(el_store->len, (el_store_len - el_store->len), iter) {
+ while (iter_prev < iter) {
+ node_curr = node_curr->next;
+ iter_prev += 1;
}
- BLI_LISTBASE_CIRCULAR_FORWARD_END (&el_store->verts, node_curr, node_curr_init);
+ LinkData *node_curr_copy;
node_curr_copy = MEM_dupallocN(node_curr);
if (split == false) {
BLI_insertlinkafter(&el_store->verts, node_curr, node_curr_copy);
@@ -730,7 +726,8 @@ void BM_edgeloop_expand(
}
else {
if (node_curr->next || (el_store->flag & BM_EDGELOOP_IS_CLOSED)) {
- EDGE_SPLIT(node_curr_copy, node_curr->next ? node_curr->next : (LinkData *)el_store->verts.first);
+ EDGE_SPLIT(node_curr_copy,
+ node_curr->next ? node_curr->next : (LinkData *)el_store->verts.first);
BLI_insertlinkafter(&el_store->verts, node_curr, node_curr_copy);
node_curr = node_curr_copy->next;
}
@@ -742,9 +739,11 @@ void BM_edgeloop_expand(
split_swap = !split_swap;
}
el_store->len++;
- } while (el_store->len < el_store_len);
+ iter_prev += 1;
+ }
}
+#undef BKE_FOREACH_SUBSET_OF_RANGE
#undef EDGE_SPLIT
BLI_assert(el_store->len == el_store_len);
diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c
index d5d9e4abe2c..2ff670c770e 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -775,7 +775,7 @@ static void bm_mesh_loops_calc_normals(
}
{
- /* Code similar to accumulate_vertex_normals_poly. */
+ /* Code similar to accumulate_vertex_normals_poly_v3. */
/* Calculate angle between the two poly edges incident on this vertex. */
const BMFace *f = lfan_pivot->f;
const float fac = saacos(dot_v3v3(vec_next, vec_curr));
diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.c b/source/blender/bmesh/intern/bmesh_mesh_conv.c
index 49f055e1827..6cc1f37db43 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_conv.c
+++ b/source/blender/bmesh/intern/bmesh_mesh_conv.c
@@ -183,6 +183,11 @@ static BMFace *bm_face_create_from_mpoly(
/**
* \brief Mesh -> BMesh
+ * \param bm: The mesh to write into, while this is typically a newly created BMesh,
+ * merging into existing data is supported.
+ * Note the custom-data layout isn't used.
+ * If more comprehensive merging is needed we should move this into a separate function
+ * since this should be kept fast for edit-mode switching and storing undo steps.
*
* \warning This function doesn't calculate face normals.
*/
@@ -190,6 +195,9 @@ void BM_mesh_bm_from_me(
BMesh *bm, Mesh *me,
const struct BMeshFromMeshParams *params)
{
+ const bool is_new =
+ !(bm->totvert ||
+ (bm->vdata.totlayer || bm->edata.totlayer || bm->pdata.totlayer || bm->ldata.totlayer));
MVert *mvert;
MEdge *medge;
MLoop *mloop;
@@ -197,19 +205,12 @@ void BM_mesh_bm_from_me(
KeyBlock *actkey, *block;
BMVert *v, **vtable = NULL;
BMEdge *e, **etable = NULL;
- BMFace *f;
+ BMFace *f, **ftable = NULL;
float (*keyco)[3] = NULL;
- int totloops, i, j;
-
- /* free custom data */
- /* this isnt needed in most cases but do just incase */
- CustomData_free(&bm->vdata, bm->totvert);
- CustomData_free(&bm->edata, bm->totedge);
- CustomData_free(&bm->ldata, bm->totloop);
- CustomData_free(&bm->pdata, bm->totface);
+ int totloops, i;
if (!me || !me->totvert) {
- if (me) { /*no verts? still copy customdata layout*/
+ if (me && is_new) { /*no verts? still copy customdata layout*/
CustomData_copy(&me->vdata, &bm->vdata, CD_MASK_BMESH, CD_ASSIGN, 0);
CustomData_copy(&me->edata, &bm->edata, CD_MASK_BMESH, CD_ASSIGN, 0);
CustomData_copy(&me->ldata, &bm->ldata, CD_MASK_BMESH, CD_ASSIGN, 0);
@@ -223,12 +224,20 @@ void BM_mesh_bm_from_me(
return; /* sanity check */
}
- vtable = MEM_mallocN(sizeof(void **) * me->totvert, "mesh to bmesh vtable");
+ if (is_new) {
+ CustomData_copy(&me->vdata, &bm->vdata, CD_MASK_BMESH, CD_CALLOC, 0);
+ CustomData_copy(&me->edata, &bm->edata, CD_MASK_BMESH, CD_CALLOC, 0);
+ CustomData_copy(&me->ldata, &bm->ldata, CD_MASK_BMESH, CD_CALLOC, 0);
+ CustomData_copy(&me->pdata, &bm->pdata, CD_MASK_BMESH, CD_CALLOC, 0);
+ }
- CustomData_copy(&me->vdata, &bm->vdata, CD_MASK_BMESH, CD_CALLOC, 0);
- CustomData_copy(&me->edata, &bm->edata, CD_MASK_BMESH, CD_CALLOC, 0);
- CustomData_copy(&me->ldata, &bm->ldata, CD_MASK_BMESH, CD_CALLOC, 0);
- CustomData_copy(&me->pdata, &bm->pdata, CD_MASK_BMESH, CD_CALLOC, 0);
+ /* -------------------------------------------------------------------- */
+ /* Shape Key */
+ int tot_shape_keys = me->key ? BLI_listbase_count(&me->key->block) : 0;
+ if (is_new == false) {
+ tot_shape_keys = min_ii(tot_shape_keys, CustomData_number_of_layers(&bm->vdata, CD_SHAPEKEY));
+ }
+ const float (**shape_key_table)[3] = tot_shape_keys ? BLI_array_alloca(shape_key_table, tot_shape_keys) : NULL;
if ((params->active_shapekey != 0) && (me->key != NULL)) {
actkey = BLI_findlink(&me->key->block, params->active_shapekey - 1);
@@ -237,63 +246,68 @@ void BM_mesh_bm_from_me(
actkey = NULL;
}
- const int tot_shape_keys = me->key ? BLI_listbase_count(&me->key->block) : 0;
- const float (**shape_key_table)[3] = tot_shape_keys ? BLI_array_alloca(shape_key_table, tot_shape_keys) : NULL;
-
- if (tot_shape_keys || params->add_key_index) {
- CustomData_add_layer(&bm->vdata, CD_SHAPE_KEYINDEX, CD_ASSIGN, NULL, 0);
+ if (is_new) {
+ if (tot_shape_keys || params->add_key_index) {
+ CustomData_add_layer(&bm->vdata, CD_SHAPE_KEYINDEX, CD_ASSIGN, NULL, 0);
+ }
}
if (tot_shape_keys) {
- /* check if we need to generate unique ids for the shapekeys.
- * this also exists in the file reading code, but is here for
- * a sanity check */
- if (!me->key->uidgen) {
- fprintf(stderr,
- "%s had to generate shape key uid's in a situation we shouldn't need to! "
- "(bmesh internal error)\n",
- __func__);
-
- me->key->uidgen = 1;
- for (block = me->key->block.first; block; block = block->next) {
- block->uid = me->key->uidgen++;
+ if (is_new) {
+ /* check if we need to generate unique ids for the shapekeys.
+ * this also exists in the file reading code, but is here for
+ * a sanity check */
+ if (!me->key->uidgen) {
+ fprintf(stderr,
+ "%s had to generate shape key uid's in a situation we shouldn't need to! "
+ "(bmesh internal error)\n",
+ __func__);
+
+ me->key->uidgen = 1;
+ for (block = me->key->block.first; block; block = block->next) {
+ block->uid = me->key->uidgen++;
+ }
}
}
if (actkey && actkey->totelem == me->totvert) {
- keyco = actkey->data;
- bm->shapenr = params->active_shapekey;
+ keyco = params->use_shapekey ? actkey->data : NULL;
+ if (is_new) {
+ bm->shapenr = params->active_shapekey;
+ }
}
- for (i = 0, block = me->key->block.first; block; block = block->next, i++) {
- CustomData_add_layer_named(&bm->vdata, CD_SHAPEKEY,
- CD_ASSIGN, NULL, 0, block->name);
-
- j = CustomData_get_layer_index_n(&bm->vdata, CD_SHAPEKEY, i);
- bm->vdata.layers[j].uid = block->uid;
-
+ for (i = 0, block = me->key->block.first; i < tot_shape_keys; block = block->next, i++) {
+ if (is_new) {
+ CustomData_add_layer_named(&bm->vdata, CD_SHAPEKEY,
+ CD_ASSIGN, NULL, 0, block->name);
+ int j = CustomData_get_layer_index_n(&bm->vdata, CD_SHAPEKEY, i);
+ bm->vdata.layers[j].uid = block->uid;
+ }
shape_key_table[i] = (const float (*)[3])block->data;
}
}
- CustomData_bmesh_init_pool(&bm->vdata, me->totvert, BM_VERT);
- CustomData_bmesh_init_pool(&bm->edata, me->totedge, BM_EDGE);
- CustomData_bmesh_init_pool(&bm->ldata, me->totloop, BM_LOOP);
- CustomData_bmesh_init_pool(&bm->pdata, me->totpoly, BM_FACE);
+ if (is_new) {
+ CustomData_bmesh_init_pool(&bm->vdata, me->totvert, BM_VERT);
+ CustomData_bmesh_init_pool(&bm->edata, me->totedge, BM_EDGE);
+ CustomData_bmesh_init_pool(&bm->ldata, me->totloop, BM_LOOP);
+ CustomData_bmesh_init_pool(&bm->pdata, me->totpoly, BM_FACE);
- BM_mesh_cd_flag_apply(bm, me->cd_flag);
+ BM_mesh_cd_flag_apply(bm, me->cd_flag);
+ }
const int cd_vert_bweight_offset = CustomData_get_offset(&bm->vdata, CD_BWEIGHT);
const int cd_edge_bweight_offset = CustomData_get_offset(&bm->edata, CD_BWEIGHT);
const int cd_edge_crease_offset = CustomData_get_offset(&bm->edata, CD_CREASE);
const int cd_shape_key_offset = me->key ? CustomData_get_offset(&bm->vdata, CD_SHAPEKEY) : -1;
- const int cd_shape_keyindex_offset = (tot_shape_keys || params->add_key_index) ?
+ const int cd_shape_keyindex_offset = is_new && (tot_shape_keys || params->add_key_index) ?
CustomData_get_offset(&bm->vdata, CD_SHAPE_KEYINDEX) : -1;
+ vtable = MEM_mallocN(sizeof(BMVert **) * me->totvert, __func__);
+
for (i = 0, mvert = me->mvert; i < me->totvert; i++, mvert++) {
- v = vtable[i] = BM_vert_create(
- bm, keyco && params->use_shapekey ? keyco[i] : mvert->co, NULL,
- BM_CREATE_SKIP_CD);
+ v = vtable[i] = BM_vert_create(bm, keyco ? keyco[i] : mvert->co, NULL, BM_CREATE_SKIP_CD);
BM_elem_index_set(v, i); /* set_ok */
/* transfer flag */
@@ -317,20 +331,16 @@ void BM_mesh_bm_from_me(
/* set shapekey data */
if (tot_shape_keys) {
float (*co_dst)[3] = BM_ELEM_CD_GET_VOID_P(v, cd_shape_key_offset);
- for (j = 0; j < tot_shape_keys; j++, co_dst++) {
+ for (int j = 0; j < tot_shape_keys; j++, co_dst++) {
copy_v3_v3(*co_dst, shape_key_table[j][i]);
}
}
}
-
- bm->elem_index_dirty &= ~BM_VERT; /* added in order, clear dirty flag */
-
- if (!me->totedge) {
- MEM_freeN(vtable);
- return;
+ if (is_new) {
+ bm->elem_index_dirty &= ~BM_VERT; /* added in order, clear dirty flag */
}
- etable = MEM_mallocN(sizeof(void **) * me->totedge, "mesh to bmesh etable");
+ etable = MEM_mallocN(sizeof(BMEdge **) * me->totedge, __func__);
medge = me->medge;
for (i = 0; i < me->totedge; i++, medge++) {
@@ -352,8 +362,14 @@ void BM_mesh_bm_from_me(
if (cd_edge_crease_offset != -1) BM_ELEM_CD_SET_FLOAT(e, cd_edge_crease_offset, (float)medge->crease / 255.0f);
}
+ if (is_new) {
+ bm->elem_index_dirty &= ~BM_EDGE; /* added in order, clear dirty flag */
+ }
- bm->elem_index_dirty &= ~BM_EDGE; /* added in order, clear dirty flag */
+ /* only needed for selection. */
+ if (me->mselect && me->totselect != 0) {
+ ftable = MEM_mallocN(sizeof(BMFace **) * me->totpoly, __func__);
+ }
mloop = me->mloop;
mp = me->mpoly;
@@ -363,6 +379,9 @@ void BM_mesh_bm_from_me(
f = bm_face_create_from_mpoly(mp, mloop + mp->loopstart,
bm, vtable, etable);
+ if (ftable != NULL) {
+ ftable[i] = f;
+ }
if (UNLIKELY(f == NULL)) {
printf("%s: Warning! Bad face in mesh"
@@ -385,7 +404,7 @@ void BM_mesh_bm_from_me(
f->mat_nr = mp->mat_nr;
if (i == me->act_face) bm->act_face = f;
- j = mp->loopstart;
+ int j = mp->loopstart;
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
do {
/* don't use 'j' since we may have skipped some faces, hence some loops. */
@@ -402,54 +421,49 @@ void BM_mesh_bm_from_me(
BM_face_normal_update(f);
}
}
+ if (is_new) {
+ bm->elem_index_dirty &= ~(BM_FACE | BM_LOOP); /* added in order, clear dirty flag */
+ }
- bm->elem_index_dirty &= ~(BM_FACE | BM_LOOP); /* added in order, clear dirty flag */
+ /* -------------------------------------------------------------------- */
+ /* MSelect clears the array elements (avoid adding multiple times).
+ *
+ * Take care to keep this last and not use (v/e/ftable) after this.
+ */
if (me->mselect && me->totselect != 0) {
-
- BMVert **vert_array = MEM_mallocN(sizeof(BMVert *) * bm->totvert, "VSelConv");
- BMEdge **edge_array = MEM_mallocN(sizeof(BMEdge *) * bm->totedge, "ESelConv");
- BMFace **face_array = MEM_mallocN(sizeof(BMFace *) * bm->totface, "FSelConv");
MSelect *msel;
-
-#pragma omp parallel sections if (bm->totvert + bm->totedge + bm->totface >= BM_OMP_LIMIT)
- {
-#pragma omp section
- { BM_iter_as_array(bm, BM_VERTS_OF_MESH, NULL, (void **)vert_array, bm->totvert); }
-#pragma omp section
- { BM_iter_as_array(bm, BM_EDGES_OF_MESH, NULL, (void **)edge_array, bm->totedge); }
-#pragma omp section
- { BM_iter_as_array(bm, BM_FACES_OF_MESH, NULL, (void **)face_array, bm->totface); }
- }
-
for (i = 0, msel = me->mselect; i < me->totselect; i++, msel++) {
+ BMElem **ele_p;
switch (msel->type) {
case ME_VSEL:
- BM_select_history_store(bm, (BMElem *)vert_array[msel->index]);
+ ele_p = (BMElem **)&vtable[msel->index];
break;
case ME_ESEL:
- BM_select_history_store(bm, (BMElem *)edge_array[msel->index]);
+ ele_p = (BMElem **)&etable[msel->index];
break;
case ME_FSEL:
- BM_select_history_store(bm, (BMElem *)face_array[msel->index]);
+ ele_p = (BMElem **)&ftable[msel->index];
break;
+ default:
+ continue;
}
- }
- MEM_freeN(vert_array);
- MEM_freeN(edge_array);
- MEM_freeN(face_array);
+ if (*ele_p != NULL) {
+ BM_select_history_store_notest(bm, *ele_p);
+ *ele_p = NULL;
+ }
+ }
}
else {
- me->totselect = 0;
- if (me->mselect) {
- MEM_freeN(me->mselect);
- me->mselect = NULL;
- }
+ BM_select_history_clear(bm);
}
MEM_freeN(vtable);
MEM_freeN(etable);
+ if (ftable) {
+ MEM_freeN(ftable);
+ }
}
diff --git a/source/blender/bmesh/intern/bmesh_mesh_validate.c b/source/blender/bmesh/intern/bmesh_mesh_validate.c
index 7c9ebc800a3..3a6a3543bc8 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_validate.c
+++ b/source/blender/bmesh/intern/bmesh_mesh_validate.c
@@ -41,7 +41,7 @@
/* macro which inserts the function name */
-#if defined __GNUC__ || defined __sun
+#if defined __GNUC__
# define ERRMSG(format, args...) { fprintf(stderr, "%s: " format ", " AT "\n", __func__, ##args); errtot++; } (void)0
#else
# define ERRMSG(format, ...) { fprintf(stderr, "%s: " format ", " AT "\n", __func__, __VA_ARGS__); errtot++; } (void)0
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c
index 200a31b1a57..4f48dafd211 100644
--- a/source/blender/bmesh/intern/bmesh_opdefines.c
+++ b/source/blender/bmesh/intern/bmesh_opdefines.c
@@ -1037,7 +1037,7 @@ static BMOpDefine bmo_extrude_face_region_def = {
/* slots_in */
{{"geom", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT | BM_EDGE | BM_FACE}}, /* edges and faces */
{"edges_exclude", BMO_OP_SLOT_MAPPING, {(int)BMO_OP_SLOT_SUBTYPE_MAP_EMPTY}},
- {"use_keep_orig", BMO_OP_SLOT_BOOL}, /* keep original geometry */
+ {"use_keep_orig", BMO_OP_SLOT_BOOL}, /* keep original geometry (requires ``geom`` to include edges). */
{"use_select_history", BMO_OP_SLOT_BOOL}, /* pass to duplicate */
{{'\0'}},
},
@@ -1684,7 +1684,7 @@ static BMOpDefine bmo_create_circle_def = {
{{"cap_ends", BMO_OP_SLOT_BOOL}, /* whether or not to fill in the ends with faces */
{"cap_tris", BMO_OP_SLOT_BOOL}, /* fill ends with triangles instead of ngons */
{"segments", BMO_OP_SLOT_INT},
- {"diameter", BMO_OP_SLOT_FLT}, /* diameter of one end */
+ {"radius", BMO_OP_SLOT_FLT}, /* Radius of the circle. */
{"matrix", BMO_OP_SLOT_MAT}, /* matrix to multiply the new geometry with */
{"calc_uvs", BMO_OP_SLOT_BOOL}, /* calculate default UVs */
{{'\0'}},
diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c
index a4621b45fe6..7b9d17b27b5 100644
--- a/source/blender/bmesh/intern/bmesh_polygon.c
+++ b/source/blender/bmesh/intern/bmesh_polygon.c
@@ -39,6 +39,8 @@
#include "BLI_polyfill2d.h"
#include "BLI_polyfill2d_beautify.h"
#include "BLI_linklist.h"
+#include "BLI_edgehash.h"
+#include "BLI_heap.h"
#include "bmesh.h"
#include "bmesh_tools.h"
@@ -1474,3 +1476,147 @@ void BM_mesh_calc_tessellation(BMesh *bm, BMLoop *(*looptris)[3], int *r_looptri
#undef USE_TESSFACE_SPEEDUP
}
+
+
+/**
+ * A version of #BM_mesh_calc_tessellation that avoids degenerate triangles.
+ */
+void BM_mesh_calc_tessellation_beauty(BMesh *bm, BMLoop *(*looptris)[3], int *r_looptris_tot)
+{
+ /* this assumes all faces can be scan-filled, which isn't always true,
+ * worst case we over alloc a little which is acceptable */
+#ifndef NDEBUG
+ const int looptris_tot = poly_to_tri_count(bm->totface, bm->totloop);
+#endif
+
+ BMIter iter;
+ BMFace *efa;
+ int i = 0;
+
+ MemArena *pf_arena = NULL;
+
+ /* use_beauty */
+ Heap *pf_heap = NULL;
+ EdgeHash *pf_ehash = NULL;
+
+ BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
+ /* don't consider two-edged faces */
+ if (UNLIKELY(efa->len < 3)) {
+ /* do nothing */
+ }
+ else if (efa->len == 3) {
+ BMLoop *l;
+ BMLoop **l_ptr = looptris[i++];
+ l_ptr[0] = l = BM_FACE_FIRST_LOOP(efa);
+ l_ptr[1] = l = l->next;
+ l_ptr[2] = l->next;
+ }
+ else if (efa->len == 4) {
+ BMLoop *l_v1 = BM_FACE_FIRST_LOOP(efa);
+ BMLoop *l_v2 = l_v1->next;
+ BMLoop *l_v3 = l_v2->next;
+ BMLoop *l_v4 = l_v1->prev;
+
+ /* #BM_verts_calc_rotate_beauty performs excessive checks we don't need!
+ * It's meant for rotating edges, it also calculates a new normal.
+ *
+ * Use #BLI_polyfill_beautify_quad_rotate_calc since we have the normal.
+ */
+#if 0
+ const bool split_13 = (BM_verts_calc_rotate_beauty(
+ l_v1->v, l_v2->v, l_v3->v, l_v4->v, 0, 0) < 0.0f);
+#else
+ float axis_mat[3][3], v_quad[4][2];
+ axis_dominant_v3_to_m3(axis_mat, efa->no);
+ mul_v2_m3v3(v_quad[0], axis_mat, l_v1->v->co);
+ mul_v2_m3v3(v_quad[1], axis_mat, l_v2->v->co);
+ mul_v2_m3v3(v_quad[2], axis_mat, l_v3->v->co);
+ mul_v2_m3v3(v_quad[3], axis_mat, l_v4->v->co);
+
+ const bool split_13 = BLI_polyfill_beautify_quad_rotate_calc(
+ v_quad[0], v_quad[1], v_quad[2], v_quad[3]) < 0.0f;
+#endif
+
+ BMLoop **l_ptr_a = looptris[i++];
+ BMLoop **l_ptr_b = looptris[i++];
+ if (split_13) {
+ l_ptr_a[0] = l_v1;
+ l_ptr_a[1] = l_v2;
+ l_ptr_a[2] = l_v3;
+
+ l_ptr_b[0] = l_v1;
+ l_ptr_b[1] = l_v3;
+ l_ptr_b[2] = l_v4;
+ }
+ else {
+ l_ptr_a[0] = l_v1;
+ l_ptr_a[1] = l_v2;
+ l_ptr_a[2] = l_v4;
+
+ l_ptr_b[0] = l_v2;
+ l_ptr_b[1] = l_v3;
+ l_ptr_b[2] = l_v4;
+ }
+ }
+ else {
+ int j;
+
+ BMLoop *l_iter;
+ BMLoop *l_first;
+ BMLoop **l_arr;
+
+ float axis_mat[3][3];
+ float (*projverts)[2];
+ unsigned int (*tris)[3];
+
+ const int totfilltri = efa->len - 2;
+
+ if (UNLIKELY(pf_arena == NULL)) {
+ pf_arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);
+ pf_heap = BLI_heap_new_ex(BLI_POLYFILL_ALLOC_NGON_RESERVE);
+ pf_ehash = BLI_edgehash_new_ex(__func__, BLI_POLYFILL_ALLOC_NGON_RESERVE);
+ }
+
+ tris = BLI_memarena_alloc(pf_arena, sizeof(*tris) * totfilltri);
+ l_arr = BLI_memarena_alloc(pf_arena, sizeof(*l_arr) * efa->len);
+ projverts = BLI_memarena_alloc(pf_arena, sizeof(*projverts) * efa->len);
+
+ axis_dominant_v3_to_m3_negate(axis_mat, efa->no);
+
+ j = 0;
+ l_iter = l_first = BM_FACE_FIRST_LOOP(efa);
+ do {
+ l_arr[j] = l_iter;
+ mul_v2_m3v3(projverts[j], axis_mat, l_iter->v->co);
+ j++;
+ } while ((l_iter = l_iter->next) != l_first);
+
+ BLI_polyfill_calc_arena((const float (*)[2])projverts, efa->len, 1, tris, pf_arena);
+
+ BLI_polyfill_beautify((const float (*)[2])projverts, efa->len, tris, pf_arena, pf_heap, pf_ehash);
+
+ for (j = 0; j < totfilltri; j++) {
+ BMLoop **l_ptr = looptris[i++];
+ unsigned int *tri = tris[j];
+
+ l_ptr[0] = l_arr[tri[0]];
+ l_ptr[1] = l_arr[tri[1]];
+ l_ptr[2] = l_arr[tri[2]];
+ }
+
+ BLI_memarena_clear(pf_arena);
+ }
+ }
+
+ if (pf_arena) {
+ BLI_memarena_free(pf_arena);
+
+ BLI_heap_free(pf_heap, NULL);
+ BLI_edgehash_free(pf_ehash, NULL);
+ }
+
+ *r_looptris_tot = i;
+
+ BLI_assert(i <= looptris_tot);
+
+}
diff --git a/source/blender/bmesh/intern/bmesh_polygon.h b/source/blender/bmesh/intern/bmesh_polygon.h
index d944f3a8bc5..313caac1243 100644
--- a/source/blender/bmesh/intern/bmesh_polygon.h
+++ b/source/blender/bmesh/intern/bmesh_polygon.h
@@ -33,6 +33,7 @@ struct Heap;
#include "BLI_compiler_attrs.h"
void BM_mesh_calc_tessellation(BMesh *bm, BMLoop *(*looptris)[3], int *r_looptris_tot);
+void BM_mesh_calc_tessellation_beauty(BMesh *bm, BMLoop *(*looptris)[3], int *r_looptris_tot);
void BM_face_calc_tessellation(
const BMFace *f, const bool use_fixed_quad,
diff --git a/source/blender/bmesh/intern/bmesh_polygon_edgenet.c b/source/blender/bmesh/intern/bmesh_polygon_edgenet.c
index e515f9af63f..8a3cb329610 100644
--- a/source/blender/bmesh/intern/bmesh_polygon_edgenet.c
+++ b/source/blender/bmesh/intern/bmesh_polygon_edgenet.c
@@ -32,7 +32,7 @@
#include "BLI_memarena.h"
#include "BLI_array.h"
#include "BLI_alloca.h"
-#include "BLI_stackdefines.h"
+#include "BLI_utildefines_stack.h"
#include "BLI_linklist_stack.h"
#include "BLI_sort.h"
#include "BLI_sort_utils.h"
@@ -725,10 +725,30 @@ BLI_INLINE bool edge_isect_verts_point_2d(
const BMEdge *e, const BMVert *v_a, const BMVert *v_b,
float r_isect[2])
{
- return ((isect_seg_seg_v2_point(v_a->co, v_b->co, e->v1->co, e->v2->co, r_isect) == 1) &&
+ /* This bias seems like it could be too large,
+ * mostly its not needed, see T52329 for example where it is. */
+ const float endpoint_bias = 1e-4f;
+ return ((isect_seg_seg_v2_point_ex(v_a->co, v_b->co, e->v1->co, e->v2->co, endpoint_bias, r_isect) == 1) &&
((e->v1 != v_a) && (e->v2 != v_a) && (e->v1 != v_b) && (e->v2 != v_b)));
}
+BLI_INLINE int axis_pt_cmp(const float pt_a[2], const float pt_b[2])
+{
+ if (pt_a[0] < pt_b[0]) {
+ return -1;
+ }
+ if (pt_a[0] > pt_b[0]) {
+ return 1;
+ }
+ if (pt_a[1] < pt_b[1]) {
+ return -1;
+ }
+ if (pt_a[1] > pt_b[1]) {
+ return 1;
+ }
+ return 0;
+}
+
/**
* Represents isolated edge-links,
* each island owns contiguous slices of the vert array.
@@ -749,7 +769,8 @@ struct EdgeGroupIsland {
struct {
BMVert *min, *max;
/* used for sorting only */
- float min_axis;
+ float min_axis[2];
+ float max_axis[2];
} vert_span;
};
@@ -758,12 +779,11 @@ static int group_min_cmp_fn(const void *p1, const void *p2)
const struct EdgeGroupIsland *g1 = *(struct EdgeGroupIsland **)p1;
const struct EdgeGroupIsland *g2 = *(struct EdgeGroupIsland **)p2;
/* min->co[SORT_AXIS] hasn't been applied yet */
- const float f1 = g1->vert_span.min_axis;
- const float f2 = g2->vert_span.min_axis;
-
- if (f1 < f2) return -1;
- if (f1 > f2) return 1;
- else return 0;
+ int test = axis_pt_cmp(g1->vert_span.min_axis, g2->vert_span.min_axis);
+ if (UNLIKELY(test == 0)) {
+ test = axis_pt_cmp(g1->vert_span.max_axis, g2->vert_span.max_axis);
+ }
+ return test;
}
struct Edges_VertVert_BVHTreeTest {
@@ -993,8 +1013,8 @@ static int bm_face_split_edgenet_find_connection(
for (int j = 0; j < 2; j++) {
BMVert *v_iter = v_pair[j];
if (BM_elem_flag_test(v_iter, VERT_IS_VALID)) {
- if (direction_sign ? (v_iter->co[SORT_AXIS] >= v_origin->co[SORT_AXIS]) :
- (v_iter->co[SORT_AXIS] <= v_origin->co[SORT_AXIS]))
+ if (direction_sign ? (v_iter->co[SORT_AXIS] > v_origin->co[SORT_AXIS]) :
+ (v_iter->co[SORT_AXIS] < v_origin->co[SORT_AXIS]))
{
BLI_SMALLSTACK_PUSH(vert_search, v_iter);
BLI_SMALLSTACK_PUSH(vert_blacklist, v_iter);
@@ -1360,8 +1380,8 @@ bool BM_face_split_edgenet_connect_islands(
/* init with *any* different verts */
g->vert_span.min = ((BMEdge *)edge_links->link)->v1;
g->vert_span.max = ((BMEdge *)edge_links->link)->v2;
- float min_axis = FLT_MAX;
- float max_axis = -FLT_MAX;
+ float min_axis[2] = {FLT_MAX, FLT_MAX};
+ float max_axis[2] = {-FLT_MAX, -FLT_MAX};
do {
BMEdge *e = edge_links->link;
@@ -1372,24 +1392,29 @@ bool BM_face_split_edgenet_connect_islands(
BLI_assert(v_iter->head.htype == BM_VERT);
/* ideally we could use 'v_iter->co[SORT_AXIS]' here,
* but we need to sort the groups before setting the vertex array order */
+ const float axis_value[2] = {
#if SORT_AXIS == 0
- const float axis_value = dot_m3_v3_row_x(axis_mat, v_iter->co);
+ dot_m3_v3_row_x(axis_mat, v_iter->co),
+ dot_m3_v3_row_y(axis_mat, v_iter->co),
#else
- const float axis_value = dot_m3_v3_row_y(axis_mat, v_iter->co);
+ dot_m3_v3_row_y(axis_mat, v_iter->co),
+ dot_m3_v3_row_x(axis_mat, v_iter->co),
#endif
+ };
- if (axis_value < min_axis) {
+ if (axis_pt_cmp(axis_value, min_axis) == -1) {
g->vert_span.min = v_iter;
- min_axis = axis_value;
+ copy_v2_v2(min_axis, axis_value);
}
- if (axis_value > max_axis ) {
+ if (axis_pt_cmp(axis_value, max_axis) == 1) {
g->vert_span.max = v_iter;
- max_axis = axis_value;
+ copy_v2_v2(max_axis, axis_value);
}
}
} while ((edge_links = edge_links->next));
- g->vert_span.min_axis = min_axis;
+ copy_v2_v2(g->vert_span.min_axis, min_axis);
+ copy_v2_v2(g->vert_span.max_axis, max_axis);
g->has_prev_edge = false;
@@ -1449,8 +1474,10 @@ bool BM_face_split_edgenet_connect_islands(
bm->elem_index_dirty |= BM_VERT;
- /* Now create bvh tree*/
- BVHTree *bvhtree = BLI_bvhtree_new(edge_arr_len, 0.0f, 8, 8);
+ /* Now create bvh tree
+ *
+ * Note that a large epsilon is used because meshes with dimensions of around 100+ need it. see T52329. */
+ BVHTree *bvhtree = BLI_bvhtree_new(edge_arr_len, 1e-4f, 8, 8);
for (uint i = 0; i < edge_arr_len; i++) {
const float e_cos[2][3] = {
{UNPACK2(edge_arr[i]->v1->co), 0.0f},
diff --git a/source/blender/bmesh/intern/bmesh_private.h b/source/blender/bmesh/intern/bmesh_private.h
index 4161fbe90fb..4dcf97e3f35 100644
--- a/source/blender/bmesh/intern/bmesh_private.h
+++ b/source/blender/bmesh/intern/bmesh_private.h
@@ -44,13 +44,14 @@
# define BM_CHECK_ELEMENT(el) (void)(el)
#else
int bmesh_elem_check(void *element, const char htype);
-# define BM_CHECK_ELEMENT(el) \
+# define BM_CHECK_ELEMENT(el) { \
if (bmesh_elem_check(el, ((BMHeader *)el)->htype)) { \
printf("check_element failure, with code %i on line %i in file\n" \
" \"%s\"\n\n", \
bmesh_elem_check(el, ((BMHeader *)el)->htype), \
__LINE__, __FILE__); \
- } (void)0
+ } \
+} ((void)0)
#endif
int bmesh_radial_length(const BMLoop *l);
diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c
index f5c14304ea3..5bdc3927e16 100644
--- a/source/blender/bmesh/intern/bmesh_queries.c
+++ b/source/blender/bmesh/intern/bmesh_queries.c
@@ -36,7 +36,7 @@
#include "BLI_math.h"
#include "BLI_alloca.h"
#include "BLI_linklist.h"
-#include "BLI_stackdefines.h"
+#include "BLI_utildefines_stack.h"
#include "BKE_customdata.h"
@@ -754,6 +754,22 @@ bool BM_vert_is_edge_pair(const BMVert *v)
}
/**
+ * Fast alternative to ``(BM_vert_edge_count(v) == 2)``
+ * that checks both edges connect to the same faces.
+ */
+bool BM_vert_is_edge_pair_manifold(const BMVert *v)
+{
+ const BMEdge *e = v->e;
+ if (e) {
+ BMEdge *e_other = BM_DISK_EDGE_NEXT(e, v);
+ if (((e_other != e) && (BM_DISK_EDGE_NEXT(e_other, v) == e))) {
+ return BM_edge_is_manifold(e) && BM_edge_is_manifold(e_other);
+ }
+ }
+ return false;
+}
+
+/**
* Access a verts 2 connected edges.
*
* \return true when only 2 verts are found.
@@ -1511,12 +1527,11 @@ float BM_loop_calc_face_angle(const BMLoop *l)
* Calculate the normal at this loop corner or fallback to the face normal on straight lines.
*
* \param l The loop to calculate the normal at
+ * \param epsilon: Value to avoid numeric errors (1e-5f works well).
* \param r_normal Resulting normal
*/
-void BM_loop_calc_face_normal(const BMLoop *l, float r_normal[3])
+float BM_loop_calc_face_normal_safe_ex(const BMLoop *l, const float epsilon_sq, float r_normal[3])
{
-#define FEPSILON 1e-5f
-
/* Note: we cannot use result of normal_tri_v3 here to detect colinear vectors (vertex on a straight line)
* from zero value, because it does not normalize both vectors before making crossproduct.
* Instead of adding two costly normalize computations, just check ourselves for colinear case. */
@@ -1525,20 +1540,55 @@ void BM_loop_calc_face_normal(const BMLoop *l, float r_normal[3])
sub_v3_v3v3(v1, l->prev->v->co, l->v->co);
sub_v3_v3v3(v2, l->next->v->co, l->v->co);
- const float fac = (v2[0] == 0.0f) ? ((v2[1] == 0.0f) ? ((v2[2] == 0.0f) ? 0.0f : v1[2] / v2[2]) : v1[1] / v2[1]) : v1[0] / v2[0];
+ const float fac =
+ ((v2[0] == 0.0f) ?
+ ((v2[1] == 0.0f) ?
+ ((v2[2] == 0.0f) ? 0.0f : v1[2] / v2[2]) : v1[1] / v2[1]) : v1[0] / v2[0]);
mul_v3_v3fl(v_tmp, v2, fac);
sub_v3_v3(v_tmp, v1);
- if (fac != 0.0f && !is_zero_v3(v1) && len_manhattan_v3(v_tmp) > FEPSILON) {
+ if (fac != 0.0f && !is_zero_v3(v1) && len_squared_v3(v_tmp) > epsilon_sq) {
/* Not co-linear, we can compute crossproduct and normalize it into normal. */
cross_v3_v3v3(r_normal, v1, v2);
- normalize_v3(r_normal);
+ return normalize_v3(r_normal);
}
else {
copy_v3_v3(r_normal, l->f->no);
+ return 0.0f;
}
+}
-#undef FEPSILON
+/**
+ * #BM_loop_calc_face_normal_safe_ex with pre-defined sane epsilon.
+ *
+ * Since this doesn't scale baed on triangle size, fixed value works well.
+ */
+float BM_loop_calc_face_normal_safe(const BMLoop *l, float r_normal[3])
+{
+ return BM_loop_calc_face_normal_safe_ex(l, 1e-5f, r_normal);
+}
+
+/**
+ * \brief BM_loop_calc_face_normal
+ *
+ * Calculate the normal at this loop corner or fallback to the face normal on straight lines.
+ *
+ * \param l The loop to calculate the normal at
+ * \param r_normal Resulting normal
+ * \return The length of the cross product (double the area).
+ */
+float BM_loop_calc_face_normal(const BMLoop *l, float r_normal[3])
+{
+ float v1[3], v2[3];
+ sub_v3_v3v3(v1, l->prev->v->co, l->v->co);
+ sub_v3_v3v3(v2, l->next->v->co, l->v->co);
+
+ cross_v3_v3v3(r_normal, v1, v2);
+ const float len = normalize_v3(r_normal);
+ if (UNLIKELY(len == 0.0f)) {
+ copy_v3_v3(r_normal, l->f->no);
+ }
+ return len;
}
/**
diff --git a/source/blender/bmesh/intern/bmesh_queries.h b/source/blender/bmesh/intern/bmesh_queries.h
index 903fdc59cb8..c9fce96c798 100644
--- a/source/blender/bmesh/intern/bmesh_queries.h
+++ b/source/blender/bmesh/intern/bmesh_queries.h
@@ -85,6 +85,7 @@ int BM_vert_face_count(const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL
BMEdge *BM_vert_other_disk_edge(BMVert *v, BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
bool BM_vert_is_edge_pair(const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
+bool BM_vert_is_edge_pair_manifold(const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
bool BM_vert_edge_pair(BMVert *v, BMEdge **r_e_a, BMEdge **r_e_b);
bool BM_vert_face_check(const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
bool BM_vert_is_wire(const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
@@ -113,7 +114,9 @@ BMLoop *BM_loop_find_prev_nodouble(BMLoop *l, BMLoop *l_stop, const float eps_sq
BMLoop *BM_loop_find_next_nodouble(BMLoop *l, BMLoop *l_stop, const float eps_sq);
float BM_loop_calc_face_angle(const BMLoop *l) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
-void BM_loop_calc_face_normal(const BMLoop *l, float r_normal[3]) ATTR_NONNULL();
+float BM_loop_calc_face_normal(const BMLoop *l, float r_normal[3]) ATTR_NONNULL();
+float BM_loop_calc_face_normal_safe(const BMLoop *l, float r_normal[3]) ATTR_NONNULL();
+float BM_loop_calc_face_normal_safe_ex(const BMLoop *l, const float epsilon, float r_normal[3]) ATTR_NONNULL();
void BM_loop_calc_face_direction(const BMLoop *l, float r_normal[3]);
void BM_loop_calc_face_tangent(const BMLoop *l, float r_tangent[3]);
diff --git a/source/blender/bmesh/operators/bmo_bisect_plane.c b/source/blender/bmesh/operators/bmo_bisect_plane.c
index 2c80ff651b8..ed232e81b82 100644
--- a/source/blender/bmesh/operators/bmo_bisect_plane.c
+++ b/source/blender/bmesh/operators/bmo_bisect_plane.c
@@ -29,7 +29,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
-#include "BLI_stackdefines.h"
+#include "BLI_utildefines_stack.h"
#include "BLI_math.h"
#include "bmesh.h"
diff --git a/source/blender/bmesh/operators/bmo_connect.c b/source/blender/bmesh/operators/bmo_connect.c
index c5c4ac959a9..0b5f1bb9ca1 100644
--- a/source/blender/bmesh/operators/bmo_connect.c
+++ b/source/blender/bmesh/operators/bmo_connect.c
@@ -27,7 +27,7 @@
*/
#include "BLI_utildefines.h"
-#include "BLI_stackdefines.h"
+#include "BLI_utildefines_stack.h"
#include "BLI_alloca.h"
#include "BLI_linklist_stack.h"
diff --git a/source/blender/bmesh/operators/bmo_create.c b/source/blender/bmesh/operators/bmo_create.c
index a980baf8626..fa08d009d40 100644
--- a/source/blender/bmesh/operators/bmo_create.c
+++ b/source/blender/bmesh/operators/bmo_create.c
@@ -74,13 +74,13 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
BMVert *verts[2];
BMEdge *e;
- BMO_iter_as_array(op->slots_in, "geom", BM_VERT, (void **)verts, 2);
-
- /* create edge */
- e = BM_edge_create(bm, verts[0], verts[1], NULL, BM_CREATE_NO_DOUBLE);
- BMO_edge_flag_enable(bm, e, ELE_OUT);
- tote += 1;
- BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "edges.out", BM_EDGE, ELE_OUT);
+ if (BMO_iter_as_array(op->slots_in, "geom", BM_VERT, (void **)verts, 2) == 2) {
+ /* create edge */
+ e = BM_edge_create(bm, verts[0], verts[1], NULL, BM_CREATE_NO_DOUBLE);
+ BMO_edge_flag_enable(bm, e, ELE_OUT);
+ tote += 1;
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "edges.out", BM_EDGE, ELE_OUT);
+ }
return;
}
@@ -283,13 +283,13 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
*/
if (totv > 2) {
/* TODO, some of these vertes may be connected by edges,
- * this connectivity could be used rather then treating
+ * this connectivity could be used rather than treating
* them as a bunch of isolated verts. */
BMVert **vert_arr = MEM_mallocN(sizeof(BMVert *) * totv, __func__);
BMFace *f;
- BMO_iter_as_array(op->slots_in, "geom", BM_VERT, (void **)vert_arr, totv);
+ totv = BMO_iter_as_array(op->slots_in, "geom", BM_VERT, (void **)vert_arr, totv);
BM_verts_sort_radial_plane(vert_arr, totv);
diff --git a/source/blender/bmesh/operators/bmo_offset_edgeloops.c b/source/blender/bmesh/operators/bmo_offset_edgeloops.c
index a9840a72fc9..269f933f27f 100644
--- a/source/blender/bmesh/operators/bmo_offset_edgeloops.c
+++ b/source/blender/bmesh/operators/bmo_offset_edgeloops.c
@@ -33,7 +33,7 @@
#include "BLI_math.h"
#include "BLI_alloca.h"
-#include "BLI_stackdefines.h"
+#include "BLI_utildefines_stack.h"
#include "BKE_customdata.h"
diff --git a/source/blender/bmesh/operators/bmo_primitive.c b/source/blender/bmesh/operators/bmo_primitive.c
index cca0f7387cd..95d61763902 100644
--- a/source/blender/bmesh/operators/bmo_primitive.c
+++ b/source/blender/bmesh/operators/bmo_primitive.c
@@ -839,7 +839,7 @@ void BM_mesh_calc_uvs_grid(
const float dx = 1.0f / (float)(x_segments - 1);
const float dy = 1.0f / (float)(y_segments - 1);
float x = 0.0f;
- float y = 0.0f;
+ float y = dy;
int loop_index;
@@ -854,16 +854,16 @@ void BM_mesh_calc_uvs_grid(
switch (loop_index) {
case 0:
- x += dx;
+ y -= dy;
break;
case 1:
- y += dy;
+ x += dx;
break;
case 2:
- x -= dx;
+ y += dy;
break;
case 3:
- y -= dy;
+ x -= dx;
break;
default:
break;
@@ -1285,7 +1285,7 @@ void bmo_create_monkey_exec(BMesh *bm, BMOperator *op)
void bmo_create_circle_exec(BMesh *bm, BMOperator *op)
{
- const float dia = BMO_slot_float_get(op->slots_in, "diameter");
+ const float radius = BMO_slot_float_get(op->slots_in, "radius");
const int segs = BMO_slot_int_get(op->slots_in, "segments");
const bool cap_ends = BMO_slot_bool_get(op->slots_in, "cap_ends");
const bool cap_tris = BMO_slot_bool_get(op->slots_in, "cap_tris");
@@ -1315,8 +1315,8 @@ void bmo_create_circle_exec(BMesh *bm, BMOperator *op)
for (a = 0; a < segs; a++, phi += phid) {
/* Going this way ends up with normal(s) upward */
- vec[0] = -dia * sinf(phi);
- vec[1] = dia * cosf(phi);
+ vec[0] = -radius * sinf(phi);
+ vec[1] = radius * cosf(phi);
vec[2] = 0.0f;
mul_m4_v3(mat, vec);
v1 = BM_vert_create(bm, vec, NULL, BM_CREATE_NOP);
@@ -1351,7 +1351,7 @@ void bmo_create_circle_exec(BMesh *bm, BMOperator *op)
BMO_face_flag_enable(bm, f, FACE_NEW);
if (calc_uvs) {
- BM_mesh_calc_uvs_circle(bm, mat, dia, FACE_NEW, cd_loop_uv_offset);
+ BM_mesh_calc_uvs_circle(bm, mat, radius, FACE_NEW, cd_loop_uv_offset);
}
}
diff --git a/source/blender/bmesh/operators/bmo_removedoubles.c b/source/blender/bmesh/operators/bmo_removedoubles.c
index 7d19d90807a..e85751531ae 100644
--- a/source/blender/bmesh/operators/bmo_removedoubles.c
+++ b/source/blender/bmesh/operators/bmo_removedoubles.c
@@ -30,7 +30,8 @@
#include "BLI_math.h"
#include "BLI_alloca.h"
-#include "BLI_stackdefines.h"
+#include "BLI_kdtree.h"
+#include "BLI_utildefines_stack.h"
#include "BLI_stack.h"
#include "BKE_customdata.h"
@@ -277,22 +278,7 @@ void bmo_weld_verts_exec(BMesh *bm, BMOperator *op)
BMO_mesh_delete_oflag_context(bm, ELE_DEL, DEL_ONLYTAGGED);
}
-static int vergaverco(const void *e1, const void *e2)
-{
- const BMVert *v1 = *(const void **)e1, *v2 = *(const void **)e2;
- float x1 = v1->co[0] + v1->co[1] + v1->co[2];
- float x2 = v2->co[0] + v2->co[1] + v2->co[2];
-
- if (x1 > x2) return 1;
- else if (x1 < x2) return -1;
- else return 0;
-}
-
-// #define VERT_TESTED 1 // UNUSED
-#define VERT_DOUBLE 2
-#define VERT_TARGET 4
#define VERT_KEEP 8
-// #define VERT_MARK 16 // UNUSED
#define VERT_IN 32
#define EDGE_MARK 1
@@ -584,77 +570,62 @@ static void bmesh_find_doubles_common(
BMesh *bm, BMOperator *op,
BMOperator *optarget, BMOpSlot *optarget_slot)
{
- BMVert **verts;
- int verts_len;
+ const BMOpSlot *slot_verts = BMO_slot_get(op->slots_in, "verts");
+ BMVert * const *verts = (BMVert **)slot_verts->data.buf;
+ const int verts_len = slot_verts->len;
- int i, j, keepvert = 0;
+ bool has_keep_vert = false;
+ bool found_duplicates = false;
const float dist = BMO_slot_float_get(op->slots_in, "dist");
- const float dist_sq = dist * dist;
- const float dist3 = ((float)M_SQRT3 + 0.00005f) * dist; /* Just above sqrt(3) */
/* Test whether keep_verts arg exists and is non-empty */
if (BMO_slot_exists(op->slots_in, "keep_verts")) {
BMOIter oiter;
- keepvert = BMO_iter_new(&oiter, op->slots_in, "keep_verts", BM_VERT) != NULL;
+ has_keep_vert = BMO_iter_new(&oiter, op->slots_in, "keep_verts", BM_VERT) != NULL;
}
- /* get the verts as an array we can sort */
- verts = BMO_slot_as_arrayN(op->slots_in, "verts", &verts_len);
-
- /* sort by vertex coordinates added together */
- qsort(verts, verts_len, sizeof(BMVert *), vergaverco);
-
/* Flag keep_verts */
- if (keepvert) {
+ if (has_keep_vert) {
BMO_slot_buffer_flag_enable(bm, op->slots_in, "keep_verts", BM_VERT, VERT_KEEP);
}
- for (i = 0; i < verts_len; i++) {
- BMVert *v_check = verts[i];
-
- if (BMO_vert_flag_test(bm, v_check, VERT_DOUBLE | VERT_TARGET)) {
- continue;
+ int *duplicates = MEM_mallocN(sizeof(int) * verts_len, __func__);
+ {
+ KDTree *tree = BLI_kdtree_new(verts_len);
+ for (int i = 0; i < verts_len; i++) {
+ BLI_kdtree_insert(tree, i, verts[i]->co);
+ if (has_keep_vert && BMO_vert_flag_test(bm, verts[i], VERT_KEEP)) {
+ duplicates[i] = i;
+ }
+ else {
+ duplicates[i] = -1;
+ }
}
- for (j = i + 1; j < verts_len; j++) {
- BMVert *v_other = verts[j];
-
- /* a match has already been found, (we could check which is best, for now don't) */
- if (BMO_vert_flag_test(bm, v_other, VERT_DOUBLE | VERT_TARGET)) {
- continue;
- }
+ BLI_kdtree_balance(tree);
+ found_duplicates = BLI_kdtree_calc_duplicates_fast(tree, dist, false, duplicates) != 0;
+ BLI_kdtree_free(tree);
+ }
- /* 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 ((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 (found_duplicates) {
+ for (int i = 0; i < verts_len; i++) {
+ BMVert *v_check = verts[i];
+ if (duplicates[i] == -1) {
+ /* nop (others can use as target) */
}
-
- if (keepvert) {
- if (BMO_vert_flag_test(bm, v_other, VERT_KEEP) == BMO_vert_flag_test(bm, v_check, VERT_KEEP))
- continue;
+ else if (duplicates[i] == i) {
+ /* keep (others can use as target) */
}
-
- if (compare_len_squared_v3v3(v_check->co, v_other->co, dist_sq)) {
-
- /* If one vert is marked as keep, make sure it will be the target */
- if (BMO_vert_flag_test(bm, v_other, VERT_KEEP)) {
- SWAP(BMVert *, v_check, v_other);
- }
-
- BMO_vert_flag_enable(bm, v_other, VERT_DOUBLE);
- BMO_vert_flag_enable(bm, v_check, VERT_TARGET);
-
- BMO_slot_map_elem_insert(optarget, optarget_slot, v_other, v_check);
+ else {
+ BMVert *v_other = verts[duplicates[i]];
+ BLI_assert(ELEM(duplicates[duplicates[i]], -1, duplicates[i]));
+ BMO_slot_map_elem_insert(optarget, optarget_slot, v_check, v_other);
}
}
}
- MEM_freeN(verts);
+ MEM_freeN(duplicates);
}
void bmo_remove_doubles_exec(BMesh *bm, BMOperator *op)
diff --git a/source/blender/bmesh/operators/bmo_subdivide_edgering.c b/source/blender/bmesh/operators/bmo_subdivide_edgering.c
index 94b60a51f68..adcc0c71629 100644
--- a/source/blender/bmesh/operators/bmo_subdivide_edgering.c
+++ b/source/blender/bmesh/operators/bmo_subdivide_edgering.c
@@ -40,7 +40,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
-#include "BLI_stackdefines.h"
+#include "BLI_utildefines_stack.h"
#include "BLI_alloca.h"
#include "BLI_math.h"
#include "BLI_listbase.h"
diff --git a/source/blender/bmesh/tools/bmesh_beautify.c b/source/blender/bmesh/tools/bmesh_beautify.c
index f08f21a2c88..6e6242fc9f9 100644
--- a/source/blender/bmesh/tools/bmesh_beautify.c
+++ b/source/blender/bmesh/tools/bmesh_beautify.c
@@ -150,7 +150,7 @@ static float bm_edge_calc_rotate_beauty__area(
(ELEM(v4, v1, v2, v3) == false));
add_v3_v3v3(no, no_a, no_b);
- if (UNLIKELY((no_scale = normalize_v3(no)) <= FLT_EPSILON)) {
+ if (UNLIKELY((no_scale = normalize_v3(no)) == 0.0f)) {
break;
}
@@ -182,7 +182,12 @@ static float bm_edge_calc_rotate_beauty__area(
}
}
- return BLI_polyfill_beautify_quad_rotate_calc(v1_xy, v2_xy, v3_xy, v4_xy);
+ /**
+ * Important to lock degenerate here,
+ * since the triangle pars will be projected into different 2D spaces.
+ * Allowing to rotate out of a degenerate state can flip the faces (when performed iteratively).
+ */
+ return BLI_polyfill_beautify_quad_rotate_calc_ex(v1_xy, v2_xy, v3_xy, v4_xy, true);
} while (false);
return FLT_MAX;
diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c
index 6673c5d25cf..51a0fa4b2cc 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -234,7 +234,7 @@ static bool nearly_parallel(const float d1[3], const float d2[3])
float ang;
ang = angle_v3v3(d1, d2);
- return (fabsf(ang) < BEVEL_EPSILON_ANG) || (fabsf(ang - M_PI) < BEVEL_EPSILON_ANG);
+ return (fabsf(ang) < BEVEL_EPSILON_ANG) || (fabsf(ang - (float)M_PI) < BEVEL_EPSILON_ANG);
}
/* Make a new BoundVert of the given kind, insert it at the end of the circular linked
@@ -4531,53 +4531,198 @@ static void set_profile_spacing(BevelParams *bp)
}
/*
- * Calculate and return an offset that is the lesser of the current
+ * Assume we have a situation like:
+ *
+ * a d
+ * \ /
+ * A \ / C
+ * \ th1 th2/
+ * b---------c
+ * B
+ *
+ * where edges are A, B, and C,
+ * following a face around vertices a, b, c, d;
+ * th1 is angle abc and th2 is angle bcd;
+ * and the argument EdgeHalf eb is B, going from b to c.
+ * In general case, edge offset specs for A, B, C have
+ * the form ka*t, kb*t, kc*t where ka, kb, kc are some factors
+ * (may be 0) and t is the current bp->offset.
+ * We want to calculate t at which the clone of B parallel
+ * to it collapses. This can be calculated using trig.
+ * Another case of geometry collision that can happen is
+ * When B slides along A because A is unbeveled.
+ * Then it might collide with a. Similarly for B sliding along C.
+ */
+static float geometry_collide_offset(BevelParams *bp, EdgeHalf *eb)
+{
+ EdgeHalf *ea, *ec, *ebother;
+ BevVert *bvc;
+ BMLoop *lb;
+ BMVert *va, *vb, *vc, *vd;
+ float ka, kb, kc, g, h, t, den, no_collide_offset, th1, th2, sin1, sin2, tan1, tan2, limit;
+
+ limit = no_collide_offset = bp->offset + 1e6;
+ if (bp->offset == 0.0f)
+ return no_collide_offset;
+ kb = eb->offset_l_spec;
+ ea = eb->next; /* note: this is in direction b --> a */
+ ka = ea->offset_r_spec;
+ if (eb->is_rev) {
+ vc = eb->e->v1;
+ vb = eb->e->v2;
+ }
+ else {
+ vb = eb->e->v1;
+ vc = eb->e->v2;
+ }
+ va = ea->is_rev ? ea->e->v1 : ea->e->v2;
+ bvc = NULL;
+ ebother = find_other_end_edge_half(bp, eb, &bvc);
+ if (ebother != NULL) {
+ ec = ebother->prev; /* note: this is in direction c --> d*/
+ vc = bvc->v;
+ kc = ec->offset_l_spec;
+ vd = ec->is_rev ? ec->e->v1 : ec->e->v2;
+ }
+ else {
+ /* No bevvert for w, so C can't be beveled */
+ kc = 0.0f;
+ ec = NULL;
+ /* Find an edge from c that has same face */
+ lb = BM_face_edge_share_loop(eb->fnext, eb->e);
+ if (!lb) {
+ return no_collide_offset;
+ }
+ if (lb->next->v == vc)
+ vd = lb->next->next->v;
+ else if (lb->v == vc)
+ vd = lb->prev->v;
+ else {
+ return no_collide_offset;
+ }
+ }
+ if (ea->e == eb->e || (ec && ec->e == eb->e))
+ return no_collide_offset;
+ ka = ka / bp->offset;
+ kb = kb / bp->offset;
+ kc = kc / bp->offset;
+ th1 = angle_v3v3v3(va->co, vb->co, vc->co);
+ th2 = angle_v3v3v3(vb->co, vc->co, vd->co);
+
+ /* First calculate offset at which edge B collapses, which happens
+ * when advancing clones of A, B, C all meet at a point.
+ * This only happens if at least two of those three edges have non-zero k's */
+ sin1 = sinf(th1);
+ sin2 = sinf(th2);
+ if ((ka > 0.0f) + (kb > 0.0f) + (kc > 0.0f) >= 2) {
+ tan1 = tanf(th1);
+ tan2 = tanf(th2);
+ g = tan1 * tan2;
+ h = sin1 * sin2;
+ den = g * (ka * sin2 + kc * sin1) + kb * h * (tan1 + tan2);
+ if (den != 0.0f) {
+ t = BM_edge_calc_length(eb->e);
+ t *= g * h / den;
+ if (t >= 0.0f)
+ limit = t;
+ }
+ }
+
+ /* Now check edge slide cases */
+ if (kb > 0.0f && ka == 0.0f /*&& bvb->selcount == 1 && bvb->edgecount > 2*/) {
+ t = BM_edge_calc_length(ea->e);
+ t *= sin1 / kb;
+ if (t >= 0.0f && t < limit)
+ limit = t;
+ }
+ if (kb > 0.0f && kc == 0.0f /* && bvc && ec && bvc->selcount == 1 && bvc->edgecount > 2 */) {
+ t = BM_edge_calc_length(ec->e);
+ t *= sin2 / kb;
+ if (t >= 0.0f && t < limit)
+ limit = t;
+ }
+ return limit;
+}
+
+/*
+ * We have an edge A between vertices a and b,
+ * where EdgeHalf ea is the half of A that starts at a.
+ * For vertex-only bevels, the new vertices slide from a at a rate ka*t
+ * and from b at a rate kb*t.
+ * We want to calculate the t at which the two meet.
+ */
+static float vertex_collide_offset(BevelParams *bp, EdgeHalf *ea)
+{
+ float limit, ka, kb, no_collide_offset, la, kab;
+ EdgeHalf *eb;
+
+ limit = no_collide_offset = bp->offset + 1e6;
+ if (bp->offset == 0.0f)
+ return no_collide_offset;
+ ka = ea->offset_l_spec / bp->offset;
+ eb = find_other_end_edge_half(bp, ea, NULL);
+ kb = eb ? eb->offset_l_spec / bp->offset : 0.0f;
+ kab = ka + kb;
+ la = BM_edge_calc_length(ea->e);
+ if (kab <= 0.0f)
+ return no_collide_offset;
+ limit = la / kab;
+ return limit;
+}
+
+/*
+ * Calculate an offset that is the lesser of the current
* bp.offset and the maximum possible offset before geometry
* collisions happen.
- * Currently this is a quick and dirty estimate of the max
- * possible: half the minimum edge length of any vertex involved
- * in a bevel. This is usually conservative.
- * The correct calculation is quite complicated.
- * TODO: implement this correctly.
+ * If the offset changes as a result of this, adjust the
+ * current edge offset specs to reflect this clamping,
+ * and store the new offset in bp.offset.
*/
-static float bevel_limit_offset(BMesh *bm, BevelParams *bp)
+static void bevel_limit_offset(BevelParams *bp)
{
- BMVert *v;
- BMEdge *e;
- BMIter v_iter, e_iter;
- float limited_offset, half_elen;
- bool vbeveled;
+ BevVert *bv;
+ EdgeHalf *eh;
+ GHashIterator giter;
+ float limited_offset, offset_factor, collision_offset;
+ int i;
limited_offset = bp->offset;
- if (bp->offset_type == BEVEL_AMT_PERCENT) {
- if (limited_offset > 50.0f)
- limited_offset = 50.0f;
- return limited_offset;
- }
- BM_ITER_MESH (v, &v_iter, bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
+ GHASH_ITER(giter, bp->vert_hash) {
+ bv = BLI_ghashIterator_getValue(&giter);
+ for (i = 0; i < bv->edgecount; i++) {
+ eh = &bv->edges[i];
if (bp->vertex_only) {
- vbeveled = true;
+ collision_offset = vertex_collide_offset(bp, eh);
+ if (collision_offset < limited_offset)
+ limited_offset = collision_offset;
}
else {
- vbeveled = false;
- BM_ITER_ELEM (e, &e_iter, v, BM_EDGES_OF_VERT) {
- if (BM_elem_flag_test(BM_edge_other_vert(e, v), BM_ELEM_TAG)) {
- vbeveled = true;
- break;
- }
- }
+ collision_offset = geometry_collide_offset(bp, eh);
+ if (collision_offset < limited_offset)
+ limited_offset = collision_offset;
}
- if (vbeveled) {
- BM_ITER_ELEM (e, &e_iter, v, BM_EDGES_OF_VERT) {
- half_elen = 0.5f * BM_edge_calc_length(e);
- if (half_elen < limited_offset)
- limited_offset = half_elen;
- }
+ }
+ }
+
+ if (limited_offset < bp->offset) {
+ /* All current offset specs have some number times bp->offset,
+ * so we can just multiply them all by the reduction factor
+ * of the offset to have the effect of recalculating the specs
+ * with the new limited_offset.
+ */
+ offset_factor = limited_offset / bp->offset;
+ GHASH_ITER(giter, bp->vert_hash) {
+ bv = BLI_ghashIterator_getValue(&giter);
+ for (i = 0; i < bv->edgecount; i++) {
+ eh = &bv->edges[i];
+ eh->offset_l_spec *= offset_factor;
+ eh->offset_r_spec *= offset_factor;
+ eh->offset_l *= offset_factor;
+ eh->offset_r *= offset_factor;
}
}
+ bp->offset = limited_offset;
}
- return limited_offset;
}
/**
@@ -4604,6 +4749,7 @@ void BM_mesh_bevel(
BMEdge *e;
BevVert *bv;
BevelParams bp = {NULL};
+ GHashIterator giter;
bp.offset = offset;
bp.offset_type = offset_type;
@@ -4627,24 +4773,33 @@ void BM_mesh_bevel(
BLI_memarena_use_calloc(bp.mem_arena);
set_profile_spacing(&bp);
- if (limit_offset)
- bp.offset = bevel_limit_offset(bm, &bp);
-
/* Analyze input vertices, sorting edges and assigning initial new vertex positions */
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
bv = bevel_vert_construct(bm, &bp, v);
- if (bv)
+ if (!limit_offset && bv)
build_boundary(&bp, bv, true);
}
}
+ /* Perhaps clamp offset to avoid geometry colliisions */
+ if (limit_offset) {
+ bevel_limit_offset(&bp);
+
+ /* Assign initial new vertex positions */
+ GHASH_ITER(giter, bp.vert_hash) {
+ bv = BLI_ghashIterator_getValue(&giter);
+ build_boundary(&bp, bv, true);
+ }
+ }
+
/* Perhaps do a pass to try to even out widths */
if (!bp.vertex_only) {
adjust_offsets(&bp);
}
/* Build the meshes around vertices, now that positions are final */
+ /* Note: could use GHASH_ITER over bp.vert_hash when backward compatibility no longer matters */
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
bv = find_bevvert(&bp, v);
diff --git a/source/blender/bmesh/tools/bmesh_bisect_plane.c b/source/blender/bmesh/tools/bmesh_bisect_plane.c
index 676a8de94c8..f3927a3ff67 100644
--- a/source/blender/bmesh/tools/bmesh_bisect_plane.c
+++ b/source/blender/bmesh/tools/bmesh_bisect_plane.c
@@ -38,7 +38,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
-#include "BLI_stackdefines.h"
+#include "BLI_utildefines_stack.h"
#include "BLI_alloca.h"
#include "BLI_linklist.h"
#include "BLI_linklist_stack.h"
diff --git a/source/blender/bmesh/tools/bmesh_decimate_collapse.c b/source/blender/bmesh/tools/bmesh_decimate_collapse.c
index c417131d588..36ae7231f94 100644
--- a/source/blender/bmesh/tools/bmesh_decimate_collapse.c
+++ b/source/blender/bmesh/tools/bmesh_decimate_collapse.c
@@ -40,7 +40,7 @@
#include "BLI_edgehash.h"
#include "BLI_polyfill2d.h"
#include "BLI_polyfill2d_beautify.h"
-#include "BLI_stackdefines.h"
+#include "BLI_utildefines_stack.h"
#include "BKE_customdata.h"
diff --git a/source/blender/bmesh/tools/bmesh_intersect.c b/source/blender/bmesh/tools/bmesh_intersect.c
index cfb43181703..82545a5e011 100644
--- a/source/blender/bmesh/tools/bmesh_intersect.c
+++ b/source/blender/bmesh/tools/bmesh_intersect.c
@@ -44,7 +44,7 @@
#include "BLI_sort_utils.h"
#include "BLI_linklist_stack.h"
-#include "BLI_stackdefines.h"
+#include "BLI_utildefines_stack.h"
#ifndef NDEBUG
# include "BLI_array_utils.h"
#endif
diff --git a/source/blender/bmesh/tools/bmesh_path.c b/source/blender/bmesh/tools/bmesh_path.c
index 30b083cacda..85c591b6684 100644
--- a/source/blender/bmesh/tools/bmesh_path.c
+++ b/source/blender/bmesh/tools/bmesh_path.c
@@ -38,24 +38,34 @@
/* -------------------------------------------------------------------- */
/* Generic Helpers */
-static float step_cost_3_v3(const float v1[3], const float v2[3], const float v3[3])
+/**
+ * Use skip options when we want to start measuring from a boundary.
+ */
+static float step_cost_3_v3_ex(
+ const float v1[3], const float v2[3], const float v3[3],
+ bool skip_12, bool skip_23)
{
- float cost, d1[3], d2[3];
-
+ float d1[3], d2[3];
/* The cost is based on the simple sum of the length of the two edgees... */
sub_v3_v3v3(d1, v2, v1);
sub_v3_v3v3(d2, v3, v2);
- cost = normalize_v3(d1) + normalize_v3(d2);
+ const float cost_12 = normalize_v3(d1);
+ const float cost_23 = normalize_v3(d2);
+ const float cost = ((skip_12 ? 0.0f : cost_12) +
+ (skip_23 ? 0.0f : cost_23));
/* but is biased to give higher values to sharp turns, so that it will take
* paths with fewer "turns" when selecting between equal-weighted paths between
* the two edges */
- cost = cost * (1.0f + 0.5f * (2.0f - sqrtf(fabsf(dot_v3v3(d1, d2)))));
-
- return cost;
+ return cost * (1.0f + 0.5f * (2.0f - sqrtf(fabsf(dot_v3v3(d1, d2)))));
}
+static float step_cost_3_v3(
+ const float v1[3], const float v2[3], const float v3[3])
+{
+ return step_cost_3_v3_ex(v1, v2, v3, false, false);
+}
/* -------------------------------------------------------------------- */
@@ -364,7 +374,7 @@ LinkNode *BM_mesh_calc_path_edge(
/* -------------------------------------------------------------------- */
/* BM_mesh_calc_path_face */
-static float facetag_cut_cost_edge(BMFace *f_a, BMFace *f_b, BMEdge *e)
+static float facetag_cut_cost_edge(BMFace *f_a, BMFace *f_b, BMEdge *e, const void * const f_endpoints[2])
{
float f_a_cent[3];
float f_b_cent[3];
@@ -392,10 +402,12 @@ static float facetag_cut_cost_edge(BMFace *f_a, BMFace *f_b, BMEdge *e)
}
#endif
- return step_cost_3_v3(f_a_cent, e_cent, f_b_cent);
+ return step_cost_3_v3_ex(
+ f_a_cent, e_cent, f_b_cent,
+ (f_a == f_endpoints[0]), (f_b == f_endpoints[1]));
}
-static float facetag_cut_cost_vert(BMFace *f_a, BMFace *f_b, BMVert *v)
+static float facetag_cut_cost_vert(BMFace *f_a, BMFace *f_b, BMVert *v, const void * const f_endpoints[2])
{
float f_a_cent[3];
float f_b_cent[3];
@@ -403,12 +415,14 @@ static float facetag_cut_cost_vert(BMFace *f_a, BMFace *f_b, BMVert *v)
BM_face_calc_center_mean_weighted(f_a, f_a_cent);
BM_face_calc_center_mean_weighted(f_b, f_b_cent);
- return step_cost_3_v3(f_a_cent, v->co, f_b_cent);
+ return step_cost_3_v3_ex(
+ f_a_cent, v->co, f_b_cent,
+ (f_a == f_endpoints[0]), (f_b == f_endpoints[1]));
}
static void facetag_add_adjacent(
Heap *heap, BMFace *f_a, BMFace **faces_prev, float *cost,
- const struct BMCalcPathParams *params)
+ const void * const f_endpoints[2], const struct BMCalcPathParams *params)
{
const int f_a_index = BM_elem_index_get(f_a);
@@ -427,7 +441,7 @@ static void facetag_add_adjacent(
/* we know 'f_b' is not visited, check it out! */
const int f_b_index = BM_elem_index_get(f_b);
const float cost_cut = params->use_topology_distance ?
- 1.0f : facetag_cut_cost_edge(f_a, f_b, l_iter->e);
+ 1.0f : facetag_cut_cost_edge(f_a, f_b, l_iter->e, f_endpoints);
const float cost_new = cost[f_a_index] + cost_cut;
if (cost[f_b_index] > cost_new) {
@@ -454,7 +468,7 @@ static void facetag_add_adjacent(
/* we know 'f_b' is not visited, check it out! */
const int f_b_index = BM_elem_index_get(f_b);
const float cost_cut = params->use_topology_distance ?
- 1.0f : facetag_cut_cost_vert(f_a, f_b, l_a->v);
+ 1.0f : facetag_cut_cost_vert(f_a, f_b, l_a->v, f_endpoints);
const float cost_new = cost[f_a_index] + cost_cut;
if (cost[f_b_index] > cost_new) {
@@ -482,6 +496,9 @@ LinkNode *BM_mesh_calc_path_face(
BMFace **faces_prev;
int i, totface;
+ /* Start measuring face path at the face edges, ignoring their centers. */
+ const void * const f_endpoints[2] = {f_src, f_dst};
+
/* note, would pass BM_EDGE except we are looping over all faces anyway */
// BM_mesh_elem_index_ensure(bm, BM_VERT /* | BM_EDGE */); // NOT NEEDED FOR FACETAG
@@ -522,7 +539,7 @@ LinkNode *BM_mesh_calc_path_face(
if (!BM_elem_flag_test(f, BM_ELEM_TAG)) {
BM_elem_flag_enable(f, BM_ELEM_TAG);
- facetag_add_adjacent(heap, f, faces_prev, cost, params);
+ facetag_add_adjacent(heap, f, faces_prev, cost, f_endpoints, params);
}
}
diff --git a/source/blender/bmesh/tools/bmesh_path_region.c b/source/blender/bmesh/tools/bmesh_path_region.c
index aad1f9c5a49..d23ea537d82 100644
--- a/source/blender/bmesh/tools/bmesh_path_region.c
+++ b/source/blender/bmesh/tools/bmesh_path_region.c
@@ -29,22 +29,32 @@
#include "BLI_math.h"
#include "BLI_linklist.h"
-#include "BLI_stackdefines.h"
+#include "BLI_utildefines_stack.h"
#include "BLI_alloca.h"
#include "bmesh.h"
#include "bmesh_path_region.h" /* own include */
-/* Special handling of vertices with 2 edges
- * (act as if the edge-chain is a single edge). */
+/**
+ * Special handling of vertices with 2 edges
+ * (act as if the edge-chain is a single edge).
+ *
+ * \note Regarding manifold edge stepping: #BM_vert_is_edge_pair_manifold usage.
+ * Logic to skip a chain of vertices is not applied at boundaries because it gives
+ * strange behavior from a user perspective especially with boundary quads, see: T52701
+ *
+ * Restrict walking over a vertex chain to cases where the edges share the same faces.
+ * This is more typical of what a user would consider a vertex chain.
+ */
#define USE_EDGE_CHAIN
#ifdef USE_EDGE_CHAIN
/**
- * Takes a vertex with 2 edge users and fills in the vertices at each end-point,
- * or nothing if if the edges loop back to its self.
+ * Takes a vertex with 2 edge users and assigns the vertices at each end-point,
+ *
+ * \return Success when \a v_end_pair values are set or false if the edges loop back on themselves.
*/
static bool bm_vert_pair_ends(BMVert *v_pivot, BMVert *v_end_pair[2])
{
@@ -53,7 +63,7 @@ static bool bm_vert_pair_ends(BMVert *v_pivot, BMVert *v_end_pair[2])
do {
BMEdge *e_chain = e;
BMVert *v_other = BM_edge_other_vert(e_chain, v_pivot);
- while (BM_vert_is_edge_pair(v_other)) {
+ while (BM_vert_is_edge_pair_manifold(v_other)) {
BMEdge *e_chain_next = BM_DISK_EDGE_NEXT(e_chain, v_other);
BLI_assert(BM_DISK_EDGE_NEXT(e_chain_next, v_other) == e_chain);
v_other = BM_edge_other_vert(e_chain_next, v_other);
@@ -88,7 +98,7 @@ static bool bm_vert_region_test_chain(BMVert *v, int * const depths[2], const in
if (bm_vert_region_test(v, depths, pass)) {
return true;
}
- else if (BM_vert_is_edge_pair(v) &&
+ else if (BM_vert_is_edge_pair_manifold(v) &&
bm_vert_pair_ends(v, v_end_pair) &&
bm_vert_region_test(v_end_pair[0], depths, pass) &&
bm_vert_region_test(v_end_pair[1], depths, pass))
@@ -206,7 +216,7 @@ static LinkNode *mesh_calc_path_region_elem(
for (int i = 0; i < ele_verts_len[side]; i++) {
BMVert *v = ele_verts[side][i];
BMVert *v_end_pair[2];
- if (BM_vert_is_edge_pair(v) && bm_vert_pair_ends(v, v_end_pair)) {
+ if (BM_vert_is_edge_pair_manifold(v) && bm_vert_pair_ends(v, v_end_pair)) {
for (int j = 0; j < 2; j++) {
const int v_end_index = BM_elem_index_get(v_end_pair[j]);
if (depths[side][v_end_index] == -1) {
@@ -239,7 +249,7 @@ static LinkNode *mesh_calc_path_region_elem(
/* Walk along the chain, fill in values until we reach a vertex with 3+ edges. */
{
BMEdge *e_chain = e;
- while (BM_vert_is_edge_pair(v_b) &&
+ while (BM_vert_is_edge_pair_manifold(v_b) &&
((depths[side][v_b_index] == -1)))
{
depths[side][v_b_index] = pass;
@@ -256,7 +266,7 @@ static LinkNode *mesh_calc_path_region_elem(
/* Add the other vertex to the stack, to be traversed in the next pass. */
if (depths[side][v_b_index] == -1) {
#ifdef USE_EDGE_CHAIN
- BLI_assert(!BM_vert_is_edge_pair(v_b));
+ BLI_assert(!BM_vert_is_edge_pair_manifold(v_b));
#endif
BLI_assert(pass == depths[side][BM_elem_index_get(v_a)] + 1);
depths[side][v_b_index] = pass;
diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp
index 707aaea0b65..299c94a6a81 100644
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@ -34,10 +34,11 @@ void forEachObjectInExportSet(Scene *sce, Functor &f, LinkNode *export_set)
}
}
-bool AnimationExporter::exportAnimations(Scene *sce)
+bool AnimationExporter::exportAnimations(const struct EvaluationContext *eval_ctx, Scene *sce)
{
bool has_animations = hasAnimations(sce);
if (has_animations) {
+ this->eval_ctx = eval_ctx;
this->scene = sce;
openLibrary();
@@ -312,12 +313,12 @@ void AnimationExporter::dae_animation(Object *ob, FCurve *fcu, char *transformNa
if (ob->type == OB_ARMATURE) {
ob_name = getObjectBoneName(ob, fcu);
BLI_snprintf(
- anim_id,
- sizeof(anim_id),
- "%s_%s.%s",
- (char *)translate_id(ob_name).c_str(),
- (char *)translate_id(transformName).c_str(),
- axis_name);
+ anim_id,
+ sizeof(anim_id),
+ "%s_%s.%s",
+ (char *)translate_id(ob_name).c_str(),
+ (char *)translate_id(transformName).c_str(),
+ axis_name);
}
else {
if (ma)
@@ -326,12 +327,12 @@ void AnimationExporter::dae_animation(Object *ob, FCurve *fcu, char *transformNa
ob_name = id_name(ob);
BLI_snprintf(
- anim_id,
- sizeof(anim_id),
- "%s_%s_%s",
- (char *)translate_id(ob_name).c_str(),
- (char *)getAnimationPathId(fcu).c_str(),
- axis_name);
+ anim_id,
+ sizeof(anim_id),
+ "%s_%s_%s",
+ (char *)translate_id(ob_name).c_str(),
+ (char *)getAnimationPathId(fcu).c_str(),
+ axis_name);
}
openAnimation(anim_id, COLLADABU::Utils::EMPTY_STRING);
@@ -480,7 +481,7 @@ void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, B
if (flag & ARM_RESTPOS) {
arm->flag &= ~ARM_RESTPOS;
- BKE_pose_where_is(scene, ob_arm);
+ BKE_pose_where_is(eval_ctx, scene, ob_arm);
}
if (fra.size()) {
@@ -489,7 +490,7 @@ void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, B
if (flag & ARM_RESTPOS)
arm->flag = flag;
- BKE_pose_where_is(scene, ob_arm);
+ BKE_pose_where_is(eval_ctx, scene, ob_arm);
}
void AnimationExporter::dae_baked_animation(std::vector<float> &fra, Object *ob_arm, Bone *bone)
@@ -530,7 +531,7 @@ void AnimationExporter::dae_baked_animation(std::vector<float> &fra, Object *ob_
addSampler(sampler);
- std::string target = translate_id(bone_name) + "/transform";
+ std::string target = get_joint_id(bone, ob_arm) + "/transform";
addChannel(COLLADABU::URI(empty, sampler_id), target);
closeAnimation();
@@ -945,10 +946,10 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames, Obj
if (pchan->flag & POSE_CHAIN) {
enable_fcurves(ob->adt->action, NULL);
BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, ctime, ADT_RECALC_ALL);
- BKE_pose_where_is(scene, ob);
+ BKE_pose_where_is(eval_ctx, scene, ob);
}
else {
- BKE_pose_where_is_bone(scene, ob, pchan, ctime, 1);
+ BKE_pose_where_is_bone(eval_ctx, scene, ob, pchan, ctime, 1);
}
// compute bone local mat
@@ -1438,7 +1439,7 @@ void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bo
// exit rest position
if (flag & ARM_RESTPOS) {
arm->flag &= ~ARM_RESTPOS;
- BKE_pose_where_is(scene, ob_arm);
+ BKE_pose_where_is(eval_ctx, scene, ob_arm);
}
//v array will hold all values which will be exported.
if (fra.size()) {
@@ -1468,7 +1469,7 @@ void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bo
// restore restpos
if (flag & ARM_RESTPOS)
arm->flag = flag;
- BKE_pose_where_is(scene, ob_arm);
+ BKE_pose_where_is(eval_ctx, scene, ob_arm);
}
void AnimationExporter::sample_animation(float *v, std::vector<float> &frames, int type, Bone *bone, Object *ob_arm, bPoseChannel *pchan)
@@ -1493,7 +1494,7 @@ void AnimationExporter::sample_animation(float *v, std::vector<float> &frames, i
BKE_animsys_evaluate_animdata(scene, &ob_arm->id, ob_arm->adt, ctime, ADT_RECALC_ANIM);
- BKE_pose_where_is_bone(scene, ob_arm, pchan, ctime, 1);
+ BKE_pose_where_is_bone(eval_ctx, scene, ob_arm, pchan, ctime, 1);
// compute bone local mat
if (bone->parent) {
@@ -1554,7 +1555,7 @@ void AnimationExporter::calc_ob_mat_at_time(Object *ob, float ctime , float mat[
if (obtar) {
BKE_animsys_evaluate_animdata(scene, &obtar->id, obtar->adt, ctime, ADT_RECALC_ANIM);
- BKE_object_where_is_calc_time(scene, obtar, ctime);
+ BKE_object_where_is_calc_time(eval_ctx, scene, obtar, ctime);
}
}
@@ -1562,7 +1563,7 @@ void AnimationExporter::calc_ob_mat_at_time(Object *ob, float ctime , float mat[
cti->flush_constraint_targets(con, &targets, 1);
}
}
- BKE_object_where_is_calc_time(scene, ob, ctime);
+ BKE_object_where_is_calc_time(eval_ctx, scene, ob, ctime);
copy_m4_m4(mat, ob->obmat);
}
diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h
index 4736361ad13..5af5d884455 100644
--- a/source/blender/collada/AnimationExporter.h
+++ b/source/blender/collada/AnimationExporter.h
@@ -79,12 +79,13 @@ extern "C"
#include <vector>
#include <algorithm> // std::find
-
+struct EvaluationContext;
class AnimationExporter: COLLADASW::LibraryAnimations
{
private:
Scene *scene;
+ const struct EvaluationContext *eval_ctx;
COLLADASW::StreamWriter *sw;
public:
@@ -94,7 +95,7 @@ public:
{ this->sw = sw; }
- bool exportAnimations(Scene *sce);
+ bool exportAnimations(const struct EvaluationContext *eval_ctx, Scene *sce);
// called for each exported object
void operator() (Object *ob);
diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp
index 9348f3b3285..844be2dd60b 100644
--- a/source/blender/collada/ArmatureExporter.cpp
+++ b/source/blender/collada/ArmatureExporter.cpp
@@ -62,8 +62,8 @@ ArmatureExporter::ArmatureExporter(COLLADASW::StreamWriter *sw, const ExportSett
}
// write bone nodes
-void ArmatureExporter::add_armature_bones(Object *ob_arm, Scene *sce,
- SceneExporter *se,
+void ArmatureExporter::add_armature_bones(const EvaluationContext *eval_ctx, Object *ob_arm,
+ Scene *sce, SceneExporter *se,
std::list<Object *>& child_objects)
{
// write bone nodes
@@ -77,7 +77,7 @@ void ArmatureExporter::add_armature_bones(Object *ob_arm, Scene *sce,
for (Bone *bone = (Bone *)armature->bonebase.first; bone; bone = bone->next) {
// start from root bones
if (!bone->parent)
- add_bone_node(bone, ob_arm, sce, se, child_objects);
+ add_bone_node(eval_ctx, bone, ob_arm, sce, se, child_objects);
}
if (!is_edited) {
@@ -157,7 +157,7 @@ void ArmatureExporter::find_objects_using_armature(Object *ob_arm, std::vector<O
#endif
// parent_mat is armature-space
-void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm, Scene *sce,
+void ArmatureExporter::add_bone_node(const EvaluationContext *eval_ctx, Bone *bone, Object *ob_arm, Scene *sce,
SceneExporter *se,
std::list<Object *>& child_objects)
{
@@ -231,7 +231,7 @@ void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm, Scene *sce,
mul_m4_m4m4((*i)->parentinv, temp, (*i)->parentinv);
}
- se->writeNodes(*i, sce);
+ se->writeNodes(eval_ctx, *i, sce);
copy_m4_m4((*i)->parentinv, backup_parinv);
child_objects.erase(i++);
@@ -240,13 +240,13 @@ void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm, Scene *sce,
}
for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) {
- add_bone_node(child, ob_arm, sce, se, child_objects);
+ add_bone_node(eval_ctx, child, ob_arm, sce, se, child_objects);
}
node.end();
}
else {
for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) {
- add_bone_node(child, ob_arm, sce, se, child_objects);
+ add_bone_node(eval_ctx, child, ob_arm, sce, se, child_objects);
}
}
}
diff --git a/source/blender/collada/ArmatureExporter.h b/source/blender/collada/ArmatureExporter.h
index d271b505aa9..a3ed97c3a43 100644
--- a/source/blender/collada/ArmatureExporter.h
+++ b/source/blender/collada/ArmatureExporter.h
@@ -60,7 +60,7 @@ public:
ArmatureExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings);
// write bone nodes
- void add_armature_bones(Object *ob_arm, Scene *sce, SceneExporter *se,
+ void add_armature_bones(const struct EvaluationContext *eval_ctx, Object *ob_arm, Scene *sce, SceneExporter *se,
std::list<Object *>& child_objects);
bool add_instance_controller(Object *ob);
@@ -85,7 +85,7 @@ private:
// Scene, SceneExporter and the list of child_objects
// are required for writing bone parented objects
- void add_bone_node(Bone *bone, Object *ob_arm, Scene *sce, SceneExporter *se,
+ void add_bone_node(const struct EvaluationContext *eval_ctx, Bone *bone, Object *ob_arm, Scene *sce, SceneExporter *se,
std::list<Object *>& child_objects);
void add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW::Node& node);
diff --git a/source/blender/collada/ControllerExporter.cpp b/source/blender/collada/ControllerExporter.cpp
index 1c2642e8313..f413651167c 100644
--- a/source/blender/collada/ControllerExporter.cpp
+++ b/source/blender/collada/ControllerExporter.cpp
@@ -104,8 +104,9 @@ bool ControllerExporter::add_instance_controller(Object *ob)
return true;
}
-void ControllerExporter::export_controllers(Scene *sce)
+void ControllerExporter::export_controllers(const struct EvaluationContext *eval_ctx, Scene *sce)
{
+ this->eval_ctx = eval_ctx;
scene = sce;
openLibrary();
@@ -197,7 +198,7 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm)
bool use_instantiation = this->export_settings->use_object_instantiation;
Mesh *me;
- me = bc_get_mesh_copy(scene,
+ me = bc_get_mesh_copy(eval_ctx, scene,
ob,
this->export_settings->export_mesh_type,
this->export_settings->apply_modifiers,
@@ -299,7 +300,7 @@ void ControllerExporter::export_morph_controller(Object *ob, Key *key)
bool use_instantiation = this->export_settings->use_object_instantiation;
Mesh *me;
- me = bc_get_mesh_copy(scene,
+ me = bc_get_mesh_copy(eval_ctx, scene,
ob,
this->export_settings->export_mesh_type,
this->export_settings->apply_modifiers,
@@ -494,7 +495,7 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm, ListBas
// put armature in rest position
if (!(arm->flag & ARM_RESTPOS)) {
arm->flag |= ARM_RESTPOS;
- BKE_pose_where_is(scene, ob_arm);
+ BKE_pose_where_is(eval_ctx, scene, ob_arm);
}
for (bDeformGroup *def = (bDeformGroup *)defbase->first; def; def = def->next) {
@@ -542,7 +543,7 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm, ListBas
// back from rest positon
if (!(flag & ARM_RESTPOS)) {
arm->flag = flag;
- BKE_pose_where_is(scene, ob_arm);
+ BKE_pose_where_is(eval_ctx, scene, ob_arm);
}
source.finish();
diff --git a/source/blender/collada/ControllerExporter.h b/source/blender/collada/ControllerExporter.h
index 80b858ca6dd..a1d46c5aafb 100644
--- a/source/blender/collada/ControllerExporter.h
+++ b/source/blender/collada/ControllerExporter.h
@@ -54,6 +54,7 @@
#include "BKE_key.h"
+struct EvaluationContext;
class SceneExporter;
class ControllerExporter : public COLLADASW::LibraryControllers, protected TransformWriter, protected InstanceWriter
@@ -65,11 +66,12 @@ public:
bool add_instance_controller(Object *ob);
- void export_controllers(Scene *sce);
+ void export_controllers(const struct EvaluationContext *eval_ctx, Scene *sce);
void operator()(Object *ob);
private:
+ const struct EvaluationContext *eval_ctx;
Scene *scene;
UnitConverter converter;
const ExportSettings *export_settings;
diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp
index bd32e989ae3..88bc5c3c295 100644
--- a/source/blender/collada/DocumentExporter.cpp
+++ b/source/blender/collada/DocumentExporter.cpp
@@ -179,7 +179,7 @@ static COLLADABU::NativeString make_temp_filepath(const char *name, const char *
// COLLADA allows this through multiple <channel>s in <animation>.
// For this to work, we need to know objects that use a certain action.
-int DocumentExporter::exportCurrentScene(Scene *sce)
+int DocumentExporter::exportCurrentScene(const EvaluationContext *eval_ctx, Scene *sce)
{
PointerRNA sceneptr, unit_settings;
PropertyRNA *system; /* unused , *scale; */
@@ -285,25 +285,28 @@ int DocumentExporter::exportCurrentScene(Scene *sce)
// <library_geometries>
if (bc_has_object_type(export_set, OB_MESH)) {
GeometryExporter ge(writer, this->export_settings);
- ge.exportGeom(sce);
+ ge.exportGeom(eval_ctx, sce);
}
// <library_animations>
AnimationExporter ae(writer, this->export_settings);
- bool has_animations = ae.exportAnimations(sce);
+ bool has_animations = ae.exportAnimations(eval_ctx, sce);
// <library_controllers>
ArmatureExporter arm_exporter(writer, this->export_settings);
ControllerExporter controller_exporter(writer, this->export_settings);
if (bc_has_object_type(export_set, OB_ARMATURE) || this->export_settings->include_shapekeys)
{
- controller_exporter.export_controllers(sce);
+ controller_exporter.export_controllers(eval_ctx, sce);
}
// <library_visual_scenes>
SceneExporter se(writer, &arm_exporter, this->export_settings);
-
+#if 0
+ /* The following code seems to be an obsolete workaround
+ Comment out until it proofs correct that we no longer need it.
+ */
if (has_animations && this->export_settings->export_transformation_type == BC_TRANSFORMATION_TYPE_MATRIX) {
// channels adressing <matrix> objects is not (yet) supported
// So we force usage of <location>, <translation> and <scale>
@@ -315,8 +318,10 @@ int DocumentExporter::exportCurrentScene(Scene *sce)
else {
se.setExportTransformationType(this->export_settings->export_transformation_type);
}
-
- se.exportScene(sce);
+#else
+ se.setExportTransformationType(this->export_settings->export_transformation_type);
+#endif
+ se.exportScene(eval_ctx, sce);
// <scene>
std::string scene_name(translate_id(id_name(sce)));
diff --git a/source/blender/collada/DocumentExporter.h b/source/blender/collada/DocumentExporter.h
index 6e3c1ecd7cd..895787c7bbc 100644
--- a/source/blender/collada/DocumentExporter.h
+++ b/source/blender/collada/DocumentExporter.h
@@ -39,7 +39,7 @@ class DocumentExporter
{
public:
DocumentExporter(const ExportSettings *export_settings);
- int exportCurrentScene(Scene *sce);
+ int exportCurrentScene(const struct EvaluationContext *eval_ctx, Scene *sce);
void exportScenes(const char *filename);
private:
const ExportSettings *export_settings;
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp
index 2d428d6fe5d..39a36781e0e 100644
--- a/source/blender/collada/DocumentImporter.cpp
+++ b/source/blender/collada/DocumentImporter.cpp
@@ -511,9 +511,9 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA
std::vector<Object *> *root_objects = new std::vector<Object *>();
fprintf(stderr,
- "Writing node id='%s', name='%s'\n",
- id.c_str(),
- name.c_str());
+ "Writing node id='%s', name='%s'\n",
+ id.c_str(),
+ name.c_str());
if (is_joint) {
if (parent_node == NULL && !is_library_node) {
diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp
index 7c7c57f3305..587f30b6eb8 100644
--- a/source/blender/collada/GeometryExporter.cpp
+++ b/source/blender/collada/GeometryExporter.cpp
@@ -57,10 +57,11 @@ GeometryExporter::GeometryExporter(COLLADASW::StreamWriter *sw, const ExportSett
{
}
-void GeometryExporter::exportGeom(Scene *sce)
+void GeometryExporter::exportGeom(const struct EvaluationContext *eval_ctx, Scene *sce)
{
openLibrary();
+ mEvalCtx = eval_ctx;
mScene = sce;
GeometryFunctor gf;
gf.forEachMeshObjectInExportSet<GeometryExporter>(sce, *this, this->export_settings->export_set);
@@ -76,7 +77,7 @@ void GeometryExporter::operator()(Object *ob)
#endif
bool use_instantiation = this->export_settings->use_object_instantiation;
- Mesh *me = bc_get_mesh_copy( mScene,
+ Mesh *me = bc_get_mesh_copy(mEvalCtx, mScene,
ob,
this->export_settings->export_mesh_type,
this->export_settings->apply_modifiers,
@@ -479,12 +480,13 @@ void GeometryExporter::createVertexColorSource(std::string geom_id, Mesh *me)
source.setArrayId(layer_id + ARRAY_ID_SUFFIX);
source.setAccessorCount(me->totloop);
- source.setAccessorStride(3);
+ source.setAccessorStride(4);
COLLADASW::SourceBase::ParameterNameList &param = source.getParameterNameList();
param.push_back("R");
param.push_back("G");
param.push_back("B");
+ param.push_back("A");
source.prepareToAppendValues();
@@ -496,7 +498,8 @@ void GeometryExporter::createVertexColorSource(std::string geom_id, Mesh *me)
source.appendValues(
mlc->r / 255.0f,
mlc->g / 255.0f,
- mlc->b / 255.0f
+ mlc->b / 255.0f,
+ mlc->a / 255.0f
);
}
}
diff --git a/source/blender/collada/GeometryExporter.h b/source/blender/collada/GeometryExporter.h
index 69d1067e6f4..7527195fdd8 100644
--- a/source/blender/collada/GeometryExporter.h
+++ b/source/blender/collada/GeometryExporter.h
@@ -46,6 +46,8 @@
#include "BKE_key.h"
+struct EvaluationContext;
+
extern Object *bc_get_highest_selected_ancestor_or_self(Object *ob);
class Normal
@@ -72,12 +74,13 @@ class GeometryExporter : COLLADASW::LibraryGeometries
Normal n;
+ const struct EvaluationContext *mEvalCtx;
Scene *mScene;
public:
GeometryExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings);
- void exportGeom(Scene *sce);
+ void exportGeom(const struct EvaluationContext *eval_ctx, Scene *sce);
void operator()(Object *ob);
diff --git a/source/blender/collada/SceneExporter.cpp b/source/blender/collada/SceneExporter.cpp
index 30cd6ddf197..aa98f2ee96c 100644
--- a/source/blender/collada/SceneExporter.cpp
+++ b/source/blender/collada/SceneExporter.cpp
@@ -43,17 +43,17 @@ void SceneExporter::setExportTransformationType(BC_export_transformation_type tr
this->transformation_type = transformation_type;
}
-void SceneExporter::exportScene(Scene *sce)
+void SceneExporter::exportScene(const EvaluationContext *eval_ctx, Scene *sce)
{
// <library_visual_scenes> <visual_scene>
std::string id_naming = id_name(sce);
openVisualScene(translate_id(id_naming), id_naming);
- exportHierarchy(sce);
+ exportHierarchy(eval_ctx, sce);
closeVisualScene();
closeLibrary();
}
-void SceneExporter::exportHierarchy(Scene *sce)
+void SceneExporter::exportHierarchy(const EvaluationContext *eval_ctx, Scene *sce)
{
LinkNode *node;
std::vector<Object *> base_objects;
@@ -85,13 +85,13 @@ void SceneExporter::exportHierarchy(Scene *sce)
Object *ob = base_objects[index];
if (bc_is_marked(ob)) {
bc_remove_mark(ob);
- writeNodes(ob, sce);
+ writeNodes(eval_ctx, ob, sce);
}
}
}
-void SceneExporter::writeNodes(Object *ob, Scene *sce)
+void SceneExporter::writeNodes(const EvaluationContext *eval_ctx, Object *ob, Scene *sce)
{
// Add associated armature first if available
bool armature_exported = false;
@@ -100,7 +100,7 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce)
armature_exported = bc_is_in_Export_set(this->export_settings->export_set, ob_arm);
if (armature_exported && bc_is_marked(ob_arm)) {
bc_remove_mark(ob_arm);
- writeNodes(ob_arm, sce);
+ writeNodes(eval_ctx, ob_arm, sce);
armature_exported = true;
}
}
@@ -159,7 +159,7 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce)
// <instance_controller>
else if (ob->type == OB_ARMATURE) {
- arm_exporter->add_armature_bones(ob, sce, this, child_objects);
+ arm_exporter->add_armature_bones(eval_ctx, ob, sce, this, child_objects);
}
// <instance_camera>
@@ -237,7 +237,7 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce)
for (std::list<Object *>::iterator i = child_objects.begin(); i != child_objects.end(); ++i) {
if (bc_is_marked(*i)) {
bc_remove_mark(*i);
- writeNodes(*i, sce);
+ writeNodes(eval_ctx, *i, sce);
}
}
diff --git a/source/blender/collada/SceneExporter.h b/source/blender/collada/SceneExporter.h
index c7c15dba2cb..ded48983bd9 100644
--- a/source/blender/collada/SceneExporter.h
+++ b/source/blender/collada/SceneExporter.h
@@ -96,15 +96,15 @@ class SceneExporter: COLLADASW::LibraryVisualScenes, protected TransformWriter,
{
public:
SceneExporter(COLLADASW::StreamWriter *sw, ArmatureExporter *arm, const ExportSettings *export_settings);
- void exportScene(Scene *sce);
+ void exportScene(const struct EvaluationContext *eval_ctx, Scene *sce);
void setExportTransformationType(BC_export_transformation_type transformation_type);
private:
BC_export_transformation_type transformation_type;
// required for writeNodes() for bone-parented objects
friend class ArmatureExporter;
- void exportHierarchy(Scene *sce);
- void writeNodes(Object *ob, Scene *sce);
+ void exportHierarchy(const struct EvaluationContext *eval_ctx, Scene *sce);
+ void writeNodes(const struct EvaluationContext *eval_ctx, Object *ob, Scene *sce);
ArmatureExporter *arm_exporter;
const ExportSettings *export_settings;
diff --git a/source/blender/collada/TransformWriter.cpp b/source/blender/collada/TransformWriter.cpp
index b7eeff3b074..84817d76073 100644
--- a/source/blender/collada/TransformWriter.cpp
+++ b/source/blender/collada/TransformWriter.cpp
@@ -61,7 +61,8 @@ void TransformWriter::add_node_transform(COLLADASW::Node& node, float mat[4][4],
}
}
-void TransformWriter::add_node_transform_ob(COLLADASW::Node& node, Object *ob, BC_export_transformation_type transformation_type)
+void TransformWriter::add_node_transform_ob(COLLADASW::Node& node, Object *ob,
+ BC_export_transformation_type transformation_type)
{
#if 0
float rot[3], loc[3], scale[3];
diff --git a/source/blender/collada/TransformWriter.h b/source/blender/collada/TransformWriter.h
index 5bb13d4aac9..580430911f7 100644
--- a/source/blender/collada/TransformWriter.h
+++ b/source/blender/collada/TransformWriter.h
@@ -41,7 +41,8 @@ class TransformWriter
protected:
void add_node_transform(COLLADASW::Node& node, float mat[4][4], float parent_mat[4][4]);
- void add_node_transform_ob(COLLADASW::Node& node, Object *ob, BC_export_transformation_type transformation_type);
+ void add_node_transform_ob(COLLADASW::Node& node, Object *ob,
+ BC_export_transformation_type transformation_type);
void add_node_transform_identity(COLLADASW::Node& node);
diff --git a/source/blender/collada/collada.cpp b/source/blender/collada/collada.cpp
index 9cb0b414721..e9285bf24ff 100644
--- a/source/blender/collada/collada.cpp
+++ b/source/blender/collada/collada.cpp
@@ -67,7 +67,8 @@ int collada_import(bContext *C,
return 0;
}
-int collada_export(Scene *sce,
+int collada_export(const EvaluationContext *eval_ctx,
+ Scene *sce,
SceneLayer *scene_layer,
const char *filepath,
@@ -140,7 +141,7 @@ int collada_export(Scene *sce,
}
DocumentExporter exporter(&export_settings);
- int status = exporter.exportCurrentScene(sce);
+ int status = exporter.exportCurrentScene(eval_ctx, sce);
BLI_linklist_free(export_settings.export_set, NULL);
diff --git a/source/blender/collada/collada.h b/source/blender/collada/collada.h
index 9aba51ef18a..1cec6a53922 100644
--- a/source/blender/collada/collada.h
+++ b/source/blender/collada/collada.h
@@ -49,6 +49,7 @@ typedef enum BC_export_transformation_type {
struct bContext;
struct Scene;
struct SceneLayer;
+struct EvaluationContext;
/*
* both return 1 on success, 0 on error
@@ -63,7 +64,8 @@ int collada_import(struct bContext *C,
int keep_bind_info);
-int collada_export(struct Scene *sce,
+int collada_export(const struct EvaluationContext *eval_ctx,
+ struct Scene *sce,
struct SceneLayer *scene_layer,
const char *filepath,
int apply_modifiers,
diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp
index 0f39b27316c..3bdd22a53f8 100644
--- a/source/blender/collada/collada_utils.cpp
+++ b/source/blender/collada/collada_utils.cpp
@@ -93,6 +93,9 @@ int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space)
{
Object workob;
Scene *sce = CTX_data_scene(C);
+ EvaluationContext eval_ctx;
+
+ CTX_data_eval_ctx(C, &eval_ctx);
if (!par || bc_test_parent_loop(par, ob))
return false;
@@ -105,7 +108,7 @@ int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space)
if (is_parent_space) {
float mat[4][4];
// calc par->obmat
- BKE_object_where_is_calc(sce, par);
+ BKE_object_where_is_calc(&eval_ctx, sce, par);
// move child obmat into world space
mul_m4_m4m4(mat, par->obmat, ob->obmat);
@@ -116,7 +119,7 @@ int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space)
BKE_object_apply_mat4(ob, ob->obmat, 0, 0);
// compute parentinv
- BKE_object_workob_calc_parent(sce, ob, &workob);
+ BKE_object_workob_calc_parent(&eval_ctx, sce, ob, &workob);
invert_m4_m4(ob->parentinv, workob.obmat);
DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA);
@@ -144,7 +147,7 @@ Object *bc_add_object(Scene *scene, int type, const char *name)
return ob;
}
-Mesh *bc_get_mesh_copy(Scene *scene, Object *ob, BC_export_mesh_type export_mesh_type, bool apply_modifiers, bool triangulate)
+Mesh *bc_get_mesh_copy(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, BC_export_mesh_type export_mesh_type, bool apply_modifiers, bool triangulate)
{
Mesh *tmpmesh;
CustomDataMask mask = CD_MASK_MESH;
@@ -154,12 +157,12 @@ Mesh *bc_get_mesh_copy(Scene *scene, Object *ob, BC_export_mesh_type export_mesh
switch (export_mesh_type) {
case BC_MESH_TYPE_VIEW:
{
- dm = mesh_create_derived_view(scene, ob, mask);
+ dm = mesh_create_derived_view(eval_ctx, scene, ob, mask);
break;
}
case BC_MESH_TYPE_RENDER:
{
- dm = mesh_create_derived_render(scene, ob, mask);
+ dm = mesh_create_derived_render(eval_ctx, scene, ob, mask);
break;
}
}
diff --git a/source/blender/collada/collada_utils.h b/source/blender/collada/collada_utils.h
index 38c0bd5096a..75e9fb5dcea 100644
--- a/source/blender/collada/collada_utils.h
+++ b/source/blender/collada/collada_utils.h
@@ -60,13 +60,15 @@ extern "C" {
#include "ExportSettings.h"
#include "collada_internal.h"
+struct EvaluationContext;
+
typedef std::map<COLLADAFW::TextureMapId, std::vector<MTex *> > TexIndexTextureArrayMap;
extern float bc_get_float_value(const COLLADAFW::FloatOrDoubleArray& array, unsigned int index);
extern int bc_test_parent_loop(Object *par, Object *ob);
extern int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space = true);
extern Object *bc_add_object(Scene *scene, int type, const char *name);
-extern Mesh *bc_get_mesh_copy(Scene *scene, Object *ob, BC_export_mesh_type export_mesh_type, bool apply_modifiers, bool triangulate);
+extern Mesh *bc_get_mesh_copy(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, BC_export_mesh_type export_mesh_type, bool apply_modifiers, bool triangulate);
extern Object *bc_get_assigned_armature(Object *ob);
extern Object *bc_get_highest_selected_ancestor_or_self(LinkNode *export_set, Object *ob);
diff --git a/source/blender/compositor/intern/COM_Debug.cpp b/source/blender/compositor/intern/COM_Debug.cpp
index a7b464cde29..68439ff8469 100644
--- a/source/blender/compositor/intern/COM_Debug.cpp
+++ b/source/blender/compositor/intern/COM_Debug.cpp
@@ -28,9 +28,11 @@
#include <vector>
extern "C" {
+#include "BLI_sys_types.h"
#include "BLI_fileops.h"
#include "BLI_path_util.h"
#include "BLI_string.h"
+
#include "DNA_node_types.h"
#include "BKE_appdir.h"
#include "BKE_node.h"
@@ -174,7 +176,7 @@ int DebugInfo::graphviz_operation(const ExecutionSystem *system, const NodeOpera
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "%s\\n(%s)", m_op_names[operation].c_str(), typeid(*operation).name());
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, " (%d,%d)", operation->getWidth(), operation->getHeight());
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, " (%u,%u)", operation->getWidth(), operation->getHeight());
int totoutputs = operation->getNumberOfOutputSockets();
if (totoutputs != 0) {
diff --git a/source/blender/compositor/intern/COM_compositor.cpp b/source/blender/compositor/intern/COM_compositor.cpp
index e3dfd69d8ec..40db5efda27 100644
--- a/source/blender/compositor/intern/COM_compositor.cpp
+++ b/source/blender/compositor/intern/COM_compositor.cpp
@@ -64,9 +64,21 @@ void COM_execute(RenderData *rd, Scene *scene, bNodeTree *editingtree, int rende
/* Make sure node tree has previews.
* Don't create previews in advance, this is done when adding preview operations.
* Reserved preview size is determined by render output for now.
+ *
+ * We fit the aspect into COM_PREVIEW_SIZE x COM_PREVIEW_SIZE image to avoid
+ * insane preview resolution, which might even overflow preview dimensions.
*/
- float aspect = rd->xsch > 0 ? (float)rd->ysch / (float)rd->xsch : 1.0f;
- BKE_node_preview_init_tree(editingtree, COM_PREVIEW_SIZE, (int)(COM_PREVIEW_SIZE * aspect), false);
+ const float aspect = rd->xsch > 0 ? (float)rd->ysch / (float)rd->xsch : 1.0f;
+ int preview_width, preview_height;
+ if (aspect < 1.0f) {
+ preview_width = COM_PREVIEW_SIZE;
+ preview_height = (int)(COM_PREVIEW_SIZE * aspect);
+ }
+ else {
+ preview_width = (int)(COM_PREVIEW_SIZE / aspect);
+ preview_height = COM_PREVIEW_SIZE;
+ }
+ BKE_node_preview_init_tree(editingtree, preview_width, preview_height, false);
/* initialize workscheduler, will check if already done. TODO deinitialize somewhere */
bool use_opencl = (editingtree->flag & NTREE_COM_OPENCL) != 0;
diff --git a/source/blender/compositor/nodes/COM_CompositorNode.cpp b/source/blender/compositor/nodes/COM_CompositorNode.cpp
index 9e8b40d8af4..4754f23a167 100644
--- a/source/blender/compositor/nodes/COM_CompositorNode.cpp
+++ b/source/blender/compositor/nodes/COM_CompositorNode.cpp
@@ -41,6 +41,7 @@ void CompositorNode::convertToOperations(NodeConverter &converter, const Composi
NodeInput *depthSocket = this->getInputSocket(2);
CompositorOperation *compositorOperation = new CompositorOperation();
+ compositorOperation->setScene(context.getScene());
compositorOperation->setSceneName(context.getScene()->id.name);
compositorOperation->setRenderData(context.getRenderData());
compositorOperation->setViewName(context.getViewName());
diff --git a/source/blender/compositor/nodes/COM_RenderLayersNode.cpp b/source/blender/compositor/nodes/COM_RenderLayersNode.cpp
index 75128de2d84..2286db81860 100644
--- a/source/blender/compositor/nodes/COM_RenderLayersNode.cpp
+++ b/source/blender/compositor/nodes/COM_RenderLayersNode.cpp
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor:
- * Jeroen Bakker
+ * Contributor:
+ * Jeroen Bakker
* Monique Dewanchand
*/
@@ -25,16 +25,22 @@
#include "COM_TranslateOperation.h"
#include "COM_RotateOperation.h"
#include "COM_ScaleOperation.h"
+#include "COM_SetColorOperation.h"
#include "COM_SetValueOperation.h"
+#include "COM_SetVectorOperation.h"
RenderLayersNode::RenderLayersNode(bNode *editorNode) : Node(editorNode)
{
/* pass */
}
-void RenderLayersNode::testSocketLink(NodeConverter &converter, const CompositorContext &context,
- NodeOutput *output, RenderLayersProg *operation,
- Scene *scene, int layerId, bool is_preview) const
+void RenderLayersNode::testSocketLink(NodeConverter &converter,
+ const CompositorContext &context,
+ NodeOutput *output,
+ RenderLayersProg *operation,
+ Scene *scene,
+ int layerId,
+ bool is_preview) const
{
operation->setScene(scene);
operation->setLayerId(layerId);
@@ -43,45 +49,140 @@ void RenderLayersNode::testSocketLink(NodeConverter &converter, const Compositor
converter.mapOutputSocket(output, operation->getOutputSocket());
converter.addOperation(operation);
-
+
if (is_preview) /* only for image socket */
converter.addPreview(operation->getOutputSocket());
}
-void RenderLayersNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+void RenderLayersNode::testRenderLink(NodeConverter &converter,
+ const CompositorContext &context,
+ Render *re) const
{
Scene *scene = (Scene *)this->getbNode()->id;
- short layerId = this->getbNode()->custom1;
- Render *re = (scene) ? RE_GetRender(scene->id.name) : NULL;
- int numberOfOutputs = this->getNumberOfOutputSockets();
-
- if (re) {
- RenderResult *rr = RE_AcquireResultRead(re);
- if (rr) {
- SceneRenderLayer *srl = (SceneRenderLayer *)BLI_findlink(&scene->r.layers, layerId);
- if (srl) {
- RenderLayer *rl = RE_GetRenderLayer(rr, srl->name);
- if (rl) {
- for (int i = 0; i < numberOfOutputs; i++) {
- NodeOutput *output = this->getOutputSocket(i);
- NodeImageLayer *storage = (NodeImageLayer*) output->getbNodeSocket()->storage;
- RenderPass *rpass = (RenderPass*) BLI_findstring(&rl->passes, storage->pass_name, offsetof(RenderPass, name));
- if (rpass) {
- if (STREQ(rpass->name, RE_PASSNAME_COMBINED) && STREQ(output->getbNodeSocket()->name, "Alpha")) {
- testSocketLink(converter, context, output, new RenderLayersAlphaProg(rpass->name, COM_DT_VALUE, rpass->channels), scene, layerId, false);
- }
- else if (STREQ(rpass->name, RE_PASSNAME_Z)) {
- testSocketLink(converter, context, output, new RenderLayersDepthProg(rpass->name, COM_DT_VALUE, rpass->channels), scene, layerId, false);
- }
- else {
- DataType type = ((rpass->channels == 4)? COM_DT_COLOR : ((rpass->channels == 3)? COM_DT_VECTOR : COM_DT_VALUE));
- testSocketLink(converter, context, output, new RenderLayersProg(rpass->name, type, rpass->channels), scene, layerId, STREQ(output->getbNodeSocket()->name, "Image"));
- }
- }
- }
- }
+ const short layerId = this->getbNode()->custom1;
+ RenderResult *rr = RE_AcquireResultRead(re);
+ if (rr == NULL) {
+ missingRenderLink(converter);
+ return;
+ }
+ SceneRenderLayer *srl = (SceneRenderLayer *)BLI_findlink(&scene->r.layers, layerId);
+ if (srl == NULL) {
+ missingRenderLink(converter);
+ return;
+ }
+ RenderLayer *rl = RE_GetRenderLayer(rr, srl->name);
+ if (rl == NULL) {
+ missingRenderLink(converter);
+ return;
+ }
+ const int num_outputs = this->getNumberOfOutputSockets();
+ for (int i = 0; i < num_outputs; i++) {
+ NodeOutput *output = this->getOutputSocket(i);
+ NodeImageLayer *storage = (NodeImageLayer*) output->getbNodeSocket()->storage;
+ RenderPass *rpass = (RenderPass*) BLI_findstring(
+ &rl->passes,
+ storage->pass_name,
+ offsetof(RenderPass, name));
+ if (rpass == NULL) {
+ missingSocketLink(converter, output);
+ continue;
+ }
+ RenderLayersProg *operation;
+ bool is_preview;
+ if (STREQ(rpass->name, RE_PASSNAME_COMBINED) &&
+ STREQ(output->getbNodeSocket()->name, "Alpha"))
+ {
+ operation = new RenderLayersAlphaProg(rpass->name,
+ COM_DT_VALUE,
+ rpass->channels);
+ is_preview = false;
+ }
+ else if (STREQ(rpass->name, RE_PASSNAME_Z)) {
+ operation = new RenderLayersDepthProg(rpass->name,
+ COM_DT_VALUE,
+ rpass->channels);
+ is_preview = false;
+ }
+ else {
+ DataType type;
+ switch (rpass->channels) {
+ case 4: type = COM_DT_COLOR; break;
+ case 3: type = COM_DT_VECTOR; break;
+ case 1: type = COM_DT_VALUE; break;
+ default:
+ BLI_assert(!"Unexpected number of channels for pass");
+ type = COM_DT_VALUE;
+ break;
}
+ operation = new RenderLayersProg(rpass->name,
+ type,
+ rpass->channels);
+ is_preview = STREQ(output->getbNodeSocket()->name, "Image");
+ }
+ testSocketLink(converter,
+ context,
+ output,
+ operation,
+ scene,
+ layerId,
+ is_preview);
+ }
+}
+
+void RenderLayersNode::missingSocketLink(NodeConverter &converter,
+ NodeOutput *output) const
+{
+ NodeOperation *operation;
+ switch (output->getDataType()) {
+ case COM_DT_COLOR:
+ {
+ const float color[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ SetColorOperation *color_operation = new SetColorOperation();
+ color_operation->setChannels(color);
+ operation = color_operation;
+ break;
+ }
+ case COM_DT_VECTOR:
+ {
+ const float vector[3] = {0.0f, 0.0f, 0.0f};
+ SetVectorOperation *vector_operation = new SetVectorOperation();
+ vector_operation->setVector(vector);
+ operation = vector_operation;
+ break;
+ }
+ case COM_DT_VALUE:
+ {
+ SetValueOperation *value_operation = new SetValueOperation();
+ value_operation->setValue(0.0f);
+ operation = value_operation;
+ break;
}
+ }
+
+ converter.mapOutputSocket(output, operation->getOutputSocket());
+ converter.addOperation(operation);
+}
+
+void RenderLayersNode::missingRenderLink(NodeConverter &converter) const
+{
+ const int num_outputs = this->getNumberOfOutputSockets();
+ for (int i = 0; i < num_outputs; i++) {
+ NodeOutput *output = this->getOutputSocket(i);
+ missingSocketLink(converter, output);
+ }
+}
+
+void RenderLayersNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext &context) const
+{
+ Scene *scene = (Scene *)this->getbNode()->id;
+ Render *re = (scene) ? RE_GetSceneRender(scene) : NULL;
+
+ if (re != NULL) {
+ testRenderLink(converter, context, re);
RE_ReleaseResult(re);
}
+ else {
+ missingRenderLink(converter);
+ }
}
diff --git a/source/blender/compositor/nodes/COM_RenderLayersNode.h b/source/blender/compositor/nodes/COM_RenderLayersNode.h
index 1f733a9f4bb..5c6c5e17d1f 100644
--- a/source/blender/compositor/nodes/COM_RenderLayersNode.h
+++ b/source/blender/compositor/nodes/COM_RenderLayersNode.h
@@ -24,6 +24,8 @@
#include "DNA_node_types.h"
#include "COM_RenderLayersProg.h"
+struct Render;
+
/**
* @brief RenderLayersNode
* @ingroup Node
@@ -31,7 +33,8 @@
class RenderLayersNode : public Node {
public:
RenderLayersNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ void convertToOperations(NodeConverter &converter,
+ const CompositorContext &context) const;
private:
void testSocketLink(NodeConverter &converter,
const CompositorContext &context,
@@ -40,4 +43,11 @@ private:
Scene *scene,
int layerId,
bool is_preview) const;
+ void testRenderLink(NodeConverter &converter,
+ const CompositorContext &context,
+ Render *re) const;
+
+ void missingSocketLink(NodeConverter &converter,
+ NodeOutput *output) const;
+ void missingRenderLink(NodeConverter &converter) const;
};
diff --git a/source/blender/compositor/nodes/COM_ScaleNode.cpp b/source/blender/compositor/nodes/COM_ScaleNode.cpp
index 61eea9227dc..ef4128a78b4 100644
--- a/source/blender/compositor/nodes/COM_ScaleNode.cpp
+++ b/source/blender/compositor/nodes/COM_ScaleNode.cpp
@@ -52,6 +52,9 @@ void ScaleNode::convertToOperations(NodeConverter &converter, const CompositorCo
converter.mapInputSocket(inputXSocket, operation->getInputSocket(1));
converter.mapInputSocket(inputYSocket, operation->getInputSocket(2));
converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
+
+ operation->setVariableSize(inputXSocket->isLinked() ||
+ inputYSocket->isLinked());
break;
}
case CMP_SCALE_SCENEPERCENT:
@@ -67,6 +70,10 @@ void ScaleNode::convertToOperations(NodeConverter &converter, const CompositorCo
converter.addLink(scaleFactorOperation->getOutputSocket(), operation->getInputSocket(1));
converter.addLink(scaleFactorOperation->getOutputSocket(), operation->getInputSocket(2));
converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
+
+ operation->setVariableSize(inputXSocket->isLinked() ||
+ inputYSocket->isLinked());
+
break;
}
case CMP_SCALE_RENDERPERCENT:
@@ -81,9 +88,13 @@ void ScaleNode::convertToOperations(NodeConverter &converter, const CompositorCo
operation->setNewHeight(rd->ysch * rd->size / 100.0f);
operation->getInputSocket(0)->setResizeMode(COM_SC_NO_RESIZE);
converter.addOperation(operation);
-
+
converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
+
+ operation->setVariableSize(inputXSocket->isLinked() ||
+ inputYSocket->isLinked());
+
break;
}
case CMP_SCALE_ABSOLUTE:
@@ -91,11 +102,15 @@ void ScaleNode::convertToOperations(NodeConverter &converter, const CompositorCo
/* TODO: what is the use of this one.... perhaps some issues when the ui was updated... */
ScaleAbsoluteOperation *operation = new ScaleAbsoluteOperation();
converter.addOperation(operation);
-
+
converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
converter.mapInputSocket(inputXSocket, operation->getInputSocket(1));
converter.mapInputSocket(inputYSocket, operation->getInputSocket(2));
converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
+
+ operation->setVariableSize(inputXSocket->isLinked() ||
+ inputYSocket->isLinked());
+
break;
}
}
diff --git a/source/blender/compositor/operations/COM_CompositorOperation.cpp b/source/blender/compositor/operations/COM_CompositorOperation.cpp
index 76f74c144f6..15ffff2fc90 100644
--- a/source/blender/compositor/operations/COM_CompositorOperation.cpp
+++ b/source/blender/compositor/operations/COM_CompositorOperation.cpp
@@ -51,6 +51,7 @@ CompositorOperation::CompositorOperation() : NodeOperation()
this->m_useAlphaInput = false;
this->m_active = false;
+ this->m_scene = NULL;
this->m_sceneName[0] = '\0';
this->m_viewName = NULL;
}
@@ -78,7 +79,7 @@ void CompositorOperation::deinitExecution()
return;
if (!isBreaked()) {
- Render *re = RE_GetRender(this->m_sceneName);
+ Render *re = RE_GetSceneRender(this->m_scene);
RenderResult *rr = RE_AcquireResultWrite(re);
if (rr) {
@@ -217,7 +218,7 @@ void CompositorOperation::determineResolution(unsigned int resolution[2], unsign
// check actual render resolution with cropping it may differ with cropped border.rendering
// FIX for: [31777] Border Crop gives black (easy)
- Render *re = RE_GetRender(this->m_sceneName);
+ Render *re = RE_GetSceneRender(this->m_scene);
if (re) {
RenderResult *rr = RE_AcquireResultRead(re);
if (rr) {
diff --git a/source/blender/compositor/operations/COM_CompositorOperation.h b/source/blender/compositor/operations/COM_CompositorOperation.h
index e81ba520695..269a065a793 100644
--- a/source/blender/compositor/operations/COM_CompositorOperation.h
+++ b/source/blender/compositor/operations/COM_CompositorOperation.h
@@ -26,11 +26,14 @@
#include "BLI_rect.h"
#include "BLI_string.h"
+struct Scene;
+
/**
* @brief Compositor output operation
*/
class CompositorOperation : public NodeOperation {
private:
+ const struct Scene *m_scene;
/**
* @brief Scene name, used for getting the render output, includes 'SC' prefix.
*/
@@ -84,6 +87,7 @@ public:
CompositorOperation();
const bool isActiveCompositorOutput() const { return this->m_active; }
void executeRegion(rcti *rect, unsigned int tileNumber);
+ void setScene(const struct Scene *scene) { m_scene = scene; }
void setSceneName(const char *sceneName) { BLI_strncpy(this->m_sceneName, sceneName, sizeof(this->m_sceneName)); }
void setViewName(const char *viewName) { this->m_viewName = viewName; }
void setRenderData(const RenderData *rd) { this->m_rd = rd; }
diff --git a/source/blender/compositor/operations/COM_GlareSimpleStarOperation.cpp b/source/blender/compositor/operations/COM_GlareSimpleStarOperation.cpp
index 57aa3a1bac2..94f407dad86 100644
--- a/source/blender/compositor/operations/COM_GlareSimpleStarOperation.cpp
+++ b/source/blender/compositor/operations/COM_GlareSimpleStarOperation.cpp
@@ -65,10 +65,10 @@ void GlareSimpleStarOperation::generateGlare(float *data, MemoryBuffer *inputTil
}
}
// // B
- for (y = tbuf1->getHeight() - 1 && (!breaked); y >= 0; y--) {
+ for (y = this->getHeight() - 1; y >= 0 && (!breaked); y--) {
ym = y - i;
yp = y + i;
- for (x = tbuf1->getWidth() - 1; x >= 0; x--) {
+ for (x = this->getWidth() - 1; x >= 0; x--) {
xm = x - i;
xp = x + i;
tbuf1->read(c, x, y);
diff --git a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp
index 41f7da7c49f..0c2da8415f8 100644
--- a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp
+++ b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp
@@ -28,55 +28,58 @@ extern "C" {
MovieClipAttributeOperation::MovieClipAttributeOperation() : NodeOperation()
{
this->addOutputSocket(COM_DT_VALUE);
- this->m_valueSet = false;
this->m_framenumber = 0;
this->m_attribute = MCA_X;
this->m_invert = false;
}
-void MovieClipAttributeOperation::executePixelSampled(float output[4],
- float /*x*/, float /*y*/,
- PixelSampler /*sampler*/)
+void MovieClipAttributeOperation::initExecution()
{
- /* TODO(sergey): This code isn't really thread-safe. */
- if (!this->m_valueSet) {
- float loc[2], scale, angle;
- loc[0] = 0.0f;
- loc[1] = 0.0f;
- scale = 1.0f;
- angle = 0.0f;
- if (this->m_clip) {
- int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(this->m_clip, this->m_framenumber);
- BKE_tracking_stabilization_data_get(this->m_clip, clip_framenr, getWidth(), getHeight(), loc, &scale, &angle);
- }
- switch (this->m_attribute) {
- case MCA_SCALE:
- this->m_value = scale;
- break;
- case MCA_ANGLE:
- this->m_value = angle;
- break;
- case MCA_X:
- this->m_value = loc[0];
- break;
- case MCA_Y:
- this->m_value = loc[1];
- break;
+ float loc[2], scale, angle;
+ loc[0] = 0.0f;
+ loc[1] = 0.0f;
+ scale = 1.0f;
+ angle = 0.0f;
+ int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(
+ this->m_clip, this->m_framenumber);
+ BKE_tracking_stabilization_data_get(this->m_clip,
+ clip_framenr,
+ getWidth(), getHeight(),
+ loc, &scale, &angle);
+ switch (this->m_attribute) {
+ case MCA_SCALE:
+ this->m_value = scale;
+ break;
+ case MCA_ANGLE:
+ this->m_value = angle;
+ break;
+ case MCA_X:
+ this->m_value = loc[0];
+ break;
+ case MCA_Y:
+ this->m_value = loc[1];
+ break;
+ }
+ if (this->m_invert) {
+ if (this->m_attribute != MCA_SCALE) {
+ this->m_value = -this->m_value;
}
- if (this->m_invert) {
- if (this->m_attribute != MCA_SCALE) {
- this->m_value = -this->m_value;
- }
- else {
- this->m_value = 1.0f / this->m_value;
- }
+ else {
+ this->m_value = 1.0f / this->m_value;
}
- this->m_valueSet = true;
}
+}
+
+void MovieClipAttributeOperation::executePixelSampled(float output[4],
+ float /*x*/, float /*y*/,
+ PixelSampler /*sampler*/)
+{
output[0] = this->m_value;
}
-void MovieClipAttributeOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
+void MovieClipAttributeOperation::determineResolution(
+ unsigned int resolution[2],
+ unsigned int preferredResolution[2])
{
resolution[0] = preferredResolution[0];
resolution[1] = preferredResolution[1];
diff --git a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h
index 731b9debaf0..659f54c1ca2 100644
--- a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h
+++ b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h
@@ -39,16 +39,18 @@ class MovieClipAttributeOperation : public NodeOperation {
private:
MovieClip *m_clip;
float m_value;
- bool m_valueSet;
int m_framenumber;
bool m_invert;
MovieClipAttribute m_attribute;
+
public:
/**
* Default constructor
*/
MovieClipAttributeOperation();
-
+
+ void initExecution();
+
/**
* the inner loop of this program
*/
diff --git a/source/blender/compositor/operations/COM_RenderLayersProg.cpp b/source/blender/compositor/operations/COM_RenderLayersProg.cpp
index f2f1b211a97..d1c654ddb6c 100644
--- a/source/blender/compositor/operations/COM_RenderLayersProg.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersProg.cpp
@@ -48,7 +48,7 @@ RenderLayersProg::RenderLayersProg(const char *passName, DataType type, int elem
void RenderLayersProg::initExecution()
{
Scene *scene = this->getScene();
- Render *re = (scene) ? RE_GetRender(scene->id.name) : NULL;
+ Render *re = (scene) ? RE_GetSceneRender(scene) : NULL;
RenderResult *rr = NULL;
if (re)
@@ -179,7 +179,7 @@ void RenderLayersProg::deinitExecution()
void RenderLayersProg::determineResolution(unsigned int resolution[2], unsigned int /*preferredResolution*/[2])
{
Scene *sce = this->getScene();
- Render *re = (sce) ? RE_GetRender(sce->id.name) : NULL;
+ Render *re = (sce) ? RE_GetSceneRender(sce) : NULL;
RenderResult *rr = NULL;
resolution[0] = 0;
@@ -246,4 +246,4 @@ void RenderLayersDepthProg::executePixelSampled(float output[4], float x, float
unsigned int offset = (iy * this->getWidth() + ix);
output[0] = inputBuffer[offset];
}
-} \ No newline at end of file
+}
diff --git a/source/blender/compositor/operations/COM_ScaleOperation.cpp b/source/blender/compositor/operations/COM_ScaleOperation.cpp
index 117ae743ee7..b498b359144 100644
--- a/source/blender/compositor/operations/COM_ScaleOperation.cpp
+++ b/source/blender/compositor/operations/COM_ScaleOperation.cpp
@@ -36,6 +36,7 @@ BaseScaleOperation::BaseScaleOperation()
#else
m_sampler = -1;
#endif
+ m_variable_size = false;
}
ScaleOperation::ScaleOperation() : BaseScaleOperation()
@@ -87,20 +88,27 @@ void ScaleOperation::executePixelSampled(float output[4], float x, float y, Pixe
bool ScaleOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
rcti newInput;
- float scaleX[4];
- float scaleY[4];
-
- this->m_inputXOperation->readSampled(scaleX, 0, 0, COM_PS_NEAREST);
- this->m_inputYOperation->readSampled(scaleY, 0, 0, COM_PS_NEAREST);
+ if (!m_variable_size) {
+ float scaleX[4];
+ float scaleY[4];
- const float scx = scaleX[0];
- const float scy = scaleY[0];
+ this->m_inputXOperation->readSampled(scaleX, 0, 0, COM_PS_NEAREST);
+ this->m_inputYOperation->readSampled(scaleY, 0, 0, COM_PS_NEAREST);
- newInput.xmax = this->m_centerX + (input->xmax - this->m_centerX) / scx;
- newInput.xmin = this->m_centerX + (input->xmin - this->m_centerX) / scx;
- newInput.ymax = this->m_centerY + (input->ymax - this->m_centerY) / scy;
- newInput.ymin = this->m_centerY + (input->ymin - this->m_centerY) / scy;
+ const float scx = scaleX[0];
+ const float scy = scaleY[0];
+ newInput.xmax = this->m_centerX + (input->xmax - this->m_centerX) / scx;
+ newInput.xmin = this->m_centerX + (input->xmin - this->m_centerX) / scx;
+ newInput.ymax = this->m_centerY + (input->ymax - this->m_centerY) / scy;
+ newInput.ymin = this->m_centerY + (input->ymin - this->m_centerY) / scy;
+ }
+ else {
+ newInput.xmax = this->getWidth();
+ newInput.xmin = 0;
+ newInput.ymax = this->getHeight();
+ newInput.ymin = 0;
+ }
return BaseScaleOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
@@ -162,24 +170,32 @@ void ScaleAbsoluteOperation::executePixelSampled(float output[4], float x, float
bool ScaleAbsoluteOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
rcti newInput;
- float scaleX[4];
- float scaleY[4];
-
- this->m_inputXOperation->readSampled(scaleX, 0, 0, COM_PS_NEAREST);
- this->m_inputYOperation->readSampled(scaleY, 0, 0, COM_PS_NEAREST);
-
- const float scx = scaleX[0];
- const float scy = scaleY[0];
- const float width = this->getWidth();
- const float height = this->getHeight();
- //div
- float relateveXScale = scx / width;
- float relateveYScale = scy / height;
-
- newInput.xmax = this->m_centerX + (input->xmax - this->m_centerX) / relateveXScale;
- newInput.xmin = this->m_centerX + (input->xmin - this->m_centerX) / relateveXScale;
- newInput.ymax = this->m_centerY + (input->ymax - this->m_centerY) / relateveYScale;
- newInput.ymin = this->m_centerY + (input->ymin - this->m_centerY) / relateveYScale;
+ if (!m_variable_size) {
+ float scaleX[4];
+ float scaleY[4];
+
+ this->m_inputXOperation->readSampled(scaleX, 0, 0, COM_PS_NEAREST);
+ this->m_inputYOperation->readSampled(scaleY, 0, 0, COM_PS_NEAREST);
+
+ const float scx = scaleX[0];
+ const float scy = scaleY[0];
+ const float width = this->getWidth();
+ const float height = this->getHeight();
+ //div
+ float relateveXScale = scx / width;
+ float relateveYScale = scy / height;
+
+ newInput.xmax = this->m_centerX + (input->xmax - this->m_centerX) / relateveXScale;
+ newInput.xmin = this->m_centerX + (input->xmin - this->m_centerX) / relateveXScale;
+ newInput.ymax = this->m_centerY + (input->ymax - this->m_centerY) / relateveYScale;
+ newInput.ymin = this->m_centerY + (input->ymin - this->m_centerY) / relateveYScale;
+ }
+ else {
+ newInput.xmax = this->getWidth();
+ newInput.xmin = 0;
+ newInput.ymax = this->getHeight();
+ newInput.ymin = 0;
+ }
return BaseScaleOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
@@ -271,9 +287,9 @@ bool ScaleFixedSizeOperation::determineDependingAreaOfInterest(rcti *input, Read
{
rcti newInput;
- newInput.xmax = (input->xmax - m_offsetX) * this->m_relX;
+ newInput.xmax = (input->xmax - m_offsetX) * this->m_relX + 1;
newInput.xmin = (input->xmin - m_offsetX) * this->m_relX;
- newInput.ymax = (input->ymax - m_offsetY) * this->m_relY;
+ newInput.ymax = (input->ymax - m_offsetY) * this->m_relY + 1;
newInput.ymin = (input->ymin - m_offsetY) * this->m_relY;
return BaseScaleOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
diff --git a/source/blender/compositor/operations/COM_ScaleOperation.h b/source/blender/compositor/operations/COM_ScaleOperation.h
index 706a5898027..17cd31f9710 100644
--- a/source/blender/compositor/operations/COM_ScaleOperation.h
+++ b/source/blender/compositor/operations/COM_ScaleOperation.h
@@ -28,6 +28,7 @@
class BaseScaleOperation : public NodeOperation {
public:
void setSampler(PixelSampler sampler) { this->m_sampler = (int) sampler; }
+ void setVariableSize(bool variable_size) { m_variable_size = variable_size; };
protected:
BaseScaleOperation();
@@ -35,6 +36,7 @@ protected:
PixelSampler getEffectiveSampler(PixelSampler sampler) { return (m_sampler == -1) ? sampler : (PixelSampler) m_sampler; }
int m_sampler;
+ bool m_variable_size;
};
class ScaleOperation : public BaseScaleOperation {
diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
index 1ec52571be8..9ff0bf9ce12 100644
--- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
@@ -286,9 +286,9 @@ void InverseSearchRadiusOperation::initExecution()
this->m_inputRadius = this->getInputSocketReader(0);
}
-voi *InverseSearchRadiusOperation::initializeTileData(rcti *rect)
+void *InverseSearchRadiusOperation::initializeTileData(rcti *rect)
{
- MemoryBuffer * data = new MemoryBuffer(NULL, rect);
+ MemoryBuffer * data = new MemoryBuffer(COM_DT_COLOR, rect);
float *buffer = data->getBuffer();
int x, y;
int width = this->m_inputRadius->getWidth();
@@ -343,7 +343,7 @@ voi *InverseSearchRadiusOperation::initializeTileData(rcti *rect)
void InverseSearchRadiusOperation::executePixelChunk(float output[4], int x, int y, void *data)
{
MemoryBuffer *buffer = (MemoryBuffer *)data;
- buffer->readNoCheck(color, x, y);
+ buffer->readNoCheck(output, x, y);
}
void InverseSearchRadiusOperation::deinitializeTileData(rcti *rect, void *data)
diff --git a/source/blender/datatoc/datatoc.c b/source/blender/datatoc/datatoc.c
index 4e49a9a7694..ffccca98f99 100644
--- a/source/blender/datatoc/datatoc.c
+++ b/source/blender/datatoc/datatoc.c
@@ -91,6 +91,11 @@ int main(int argc, char **argv)
}
fprintf(fpout, "/* DataToC output of file <%s> */\n\n", argv[1]);
+
+ /* Quiet 'missing-variable-declarations' warning. */
+ fprintf(fpout, "extern int datatoc_%s_size;\n", argv[1]);
+ fprintf(fpout, "extern char datatoc_%s[];\n\n", argv[1]);
+
fprintf(fpout, "int datatoc_%s_size = %d;\n", argv[1], (int)size);
fprintf(fpout, "char datatoc_%s[] = {\n", argv[1]);
while (size--) {
diff --git a/source/blender/depsgraph/DEG_depsgraph.h b/source/blender/depsgraph/DEG_depsgraph.h
index 9caf7635ccf..932a7c51286 100644
--- a/source/blender/depsgraph/DEG_depsgraph.h
+++ b/source/blender/depsgraph/DEG_depsgraph.h
@@ -65,6 +65,14 @@ struct Main;
struct PointerRNA;
struct PropertyRNA;
+struct Scene;
+struct SceneLayer;
+
+typedef enum eEvaluationMode {
+ DAG_EVAL_VIEWPORT = 0, /* evaluate for OpenGL viewport */
+ DAG_EVAL_PREVIEW = 1, /* evaluate for render with preview settings */
+ DAG_EVAL_RENDER = 2, /* evaluate for render purposes */
+} eEvaluationMode;
/* Dependency graph evaluation context
*
@@ -72,15 +80,11 @@ struct PropertyRNA;
* which is needed for it's evaluation,
*/
typedef struct EvaluationContext {
- int mode;
+ eEvaluationMode mode;
float ctime;
-} EvaluationContext;
-typedef enum eEvaluationMode {
- DAG_EVAL_VIEWPORT = 0, /* evaluate for OpenGL viewport */
- DAG_EVAL_PREVIEW = 1, /* evaluate for render with preview settings */
- DAG_EVAL_RENDER = 2, /* evaluate for render purposes */
-} eEvaluationMode;
+ struct SceneLayer *scene_layer;
+} EvaluationContext;
/* DagNode->eval_flags */
enum {
@@ -136,13 +140,6 @@ void DEG_graph_on_visible_update(struct Main *bmain, struct Scene *scene);
/* Update all dependency graphs when visible scenes/layers changes. */
void DEG_on_visible_update(struct Main *bmain, const bool do_time);
-/* Tag node(s) associated with changed data for later updates */
-void DEG_graph_id_tag_update(struct Main *bmain,
- Depsgraph *graph,
- struct ID *id);
-void DEG_graph_data_tag_update(Depsgraph *graph, const struct PointerRNA *ptr);
-void DEG_graph_property_tag_update(Depsgraph *graph, const struct PointerRNA *ptr, const struct PropertyRNA *prop);
-
/* Tag given ID for an update in all the dependency graphs. */
enum {
/* Object transformation changed, corresponds to OB_RECALC_OB. */
@@ -164,6 +161,11 @@ enum {
/* Update copy on write component without flushing down the road. */
DEG_TAG_COPY_ON_WRITE = (1 << 8),
+
+ /* Tag shading components for update.
+ * Only parameters of material changed).
+ */
+ DEG_TAG_SHADING_UPDATE = (1 << 9),
};
void DEG_id_tag_update(struct ID *id, int flag);
void DEG_id_tag_update_ex(struct Main *bmain,
@@ -175,7 +177,7 @@ void DEG_id_tag_update_ex(struct Main *bmain,
* Used by all sort of render engines to quickly check if
* IDs of a given type need to be checked for update.
*/
-void DEG_id_type_tag(struct Main *bmain, short idtype);
+void DEG_id_type_tag(struct Main *bmain, short id_type);
void DEG_ids_clear_recalc(struct Main *bmain);
@@ -184,6 +186,9 @@ void DEG_ids_clear_recalc(struct Main *bmain);
/* Flush updates for all IDs */
void DEG_ids_flush_tagged(struct Main *bmain);
+/* Flush updates for IDs in a single scene. */
+void DEG_scene_flush_update(struct Main *bmain, struct Scene *scene);
+
/* Check if something was changed in the database and inform
* editors about this.
*/
@@ -197,13 +202,18 @@ void DEG_ids_check_recalc(struct Main *bmain,
/* Evaluation Context ---------------------------- */
/* Create new evaluation context. */
-struct EvaluationContext *DEG_evaluation_context_new(int mode);
+struct EvaluationContext *DEG_evaluation_context_new(eEvaluationMode mode);
/* Initialize evaluation context.
* Used by the areas which currently overrides the context or doesn't have
* access to a proper one.
*/
-void DEG_evaluation_context_init(struct EvaluationContext *eval_ctx, int mode);
+void DEG_evaluation_context_init(struct EvaluationContext *eval_ctx,
+ eEvaluationMode mode);
+void DEG_evaluation_context_init_from_scene(struct EvaluationContext *eval_ctx,
+ struct Scene *scene,
+ struct SceneLayer *scene_layer,
+ eEvaluationMode mode);
/* Free evaluation context. */
void DEG_evaluation_context_free(struct EvaluationContext *eval_ctx);
diff --git a/source/blender/depsgraph/DEG_depsgraph_build.h b/source/blender/depsgraph/DEG_depsgraph_build.h
index 8c3ddec40a4..0e29f24f454 100644
--- a/source/blender/depsgraph/DEG_depsgraph_build.h
+++ b/source/blender/depsgraph/DEG_depsgraph_build.h
@@ -42,6 +42,7 @@ struct Depsgraph;
struct CacheFile;
struct EffectorWeights;
+struct EvaluationContext;
struct Group;
struct Main;
struct ModifierData;
diff --git a/source/blender/depsgraph/DEG_depsgraph_query.h b/source/blender/depsgraph/DEG_depsgraph_query.h
index 674389ddd6c..1020d4e606e 100644
--- a/source/blender/depsgraph/DEG_depsgraph_query.h
+++ b/source/blender/depsgraph/DEG_depsgraph_query.h
@@ -50,19 +50,19 @@ extern "C" {
#endif
/* Check if given ID type was tagged for update. */
-bool DEG_id_type_tagged(struct Main *bmain, short idtype);
+bool DEG_id_type_tagged(struct Main *bmain, short id_type);
/* Get additional evaluation flags for the given ID. */
short DEG_get_eval_flags_for_id(struct Depsgraph *graph, struct ID *id);
/* Get scene the despgraph is created for. */
-struct Scene *DEG_get_scene(struct Depsgraph *graph);
+struct Scene *DEG_get_evaluated_scene(struct Depsgraph *graph);
/* Get scene layer the despgraph is created for. */
-struct SceneLayer *DEG_get_scene_layer(struct Depsgraph *graph);
+struct SceneLayer *DEG_get_evaluated_scene_layer(struct Depsgraph *graph);
-/* Get the object as properly evaluated by depsgraph. */
-struct Object *DEG_get_object(struct Depsgraph *depsgraph, struct Object *ob);
+/* Get evaluated version of object for given original one. */
+struct Object *DEG_get_evaluated_object(struct Depsgraph *depsgraph, struct Object *object);
/* Get evaluated version of given ID datablock. */
struct ID *DEG_get_evaluated_id(struct Depsgraph *depsgraph, struct ID *id);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc b/source/blender/depsgraph/intern/builder/deg_builder.cc
index 92c79388657..deee2227f81 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder.cc
@@ -41,6 +41,8 @@
#include "intern/depsgraph_types.h"
#include "intern/nodes/deg_node.h"
+#include "DEG_depsgraph.h"
+
namespace DEG {
void deg_graph_build_finalize(Depsgraph *graph)
@@ -61,11 +63,9 @@ void deg_graph_build_finalize(Depsgraph *graph)
id_node->tag_update(graph);
}
}
- /* XXX: This is only so we've got proper COW IDs after rebuild. */
- /* TODO(sergey): Ideally we'll need to copy evaluated CoW from previous
- * depsgraph, so we don't need to re-tag anything what we already have.
- */
- id_node->tag_update(graph);
+#ifdef WITH_COPY_ON_WRITE
+ DEG_id_tag_update_ex(graph->bmain, id_node->id_orig, DEG_TAG_COPY_ON_WRITE);
+#endif
}
GHASH_FOREACH_END();
}
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index 1fc107f0437..02d20913177 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -81,6 +81,7 @@ extern "C" {
#include "BKE_lattice.h"
#include "BKE_library.h"
#include "BKE_main.h"
+#include "BKE_mask.h"
#include "BKE_material.h"
#include "BKE_mesh.h"
#include "BKE_mball.h"
@@ -144,6 +145,12 @@ void constraint_walk(bConstraint * /*con*/,
}
}
+void free_copy_on_write_datablock(void *id_v)
+{
+ ID *id = (ID *)id_v;
+ deg_free_copy_on_write_datablock(id);
+}
+
} /* namespace */
/* ************ */
@@ -153,18 +160,30 @@ void constraint_walk(bConstraint * /*con*/,
DepsgraphNodeBuilder::DepsgraphNodeBuilder(Main *bmain, Depsgraph *graph) :
m_bmain(bmain),
- m_graph(graph)
+ m_graph(graph),
+ m_cow_id_hash(NULL)
{
}
DepsgraphNodeBuilder::~DepsgraphNodeBuilder()
{
+ if (m_cow_id_hash != NULL) {
+ BLI_ghash_free(m_cow_id_hash, NULL, free_copy_on_write_datablock);
+ }
}
-IDDepsNode *DepsgraphNodeBuilder::add_id_node(ID *id)
+IDDepsNode *DepsgraphNodeBuilder::add_id_node(ID *id, bool do_tag)
{
- IDDepsNode *id_node = m_graph->add_id_node(id, id->name);
#ifdef WITH_COPY_ON_WRITE
+ IDDepsNode *id_node = NULL;
+ ID *id_cow = (ID *)BLI_ghash_lookup(m_cow_id_hash, id);
+ if (id_cow != NULL) {
+ /* TODO(sergey): Is it possible to lookup and pop element from GHash
+ * at the same time?
+ */
+ BLI_ghash_remove(m_cow_id_hash, id, NULL, NULL);
+ }
+ id_node = m_graph->add_id_node(id, do_tag, id_cow);
/* Currently all ID nodes are supposed to have copy-on-write logic.
*
* NOTE: Zero number of components indicates that ID node was just created.
@@ -178,6 +197,9 @@ IDDepsNode *DepsgraphNodeBuilder::add_id_node(ID *id)
"", -1);
m_graph->operations.push_back(op_cow);
}
+#else
+ IDDepsNode *id_node = m_graph->add_id_node(id);
+ UNUSED_VARS(do_tag);
#endif
return id_node;
}
@@ -295,6 +317,27 @@ ID *DepsgraphNodeBuilder::get_cow_id(const ID *id_orig) const
return m_graph->get_cow_id(id_orig);
}
+ID *DepsgraphNodeBuilder::ensure_cow_id(ID *id_orig)
+{
+ if (id_orig->tag & LIB_TAG_COPY_ON_WRITE) {
+ /* ID is already remapped to copy-on-write. */
+ return id_orig;
+ }
+ IDDepsNode *id_node = add_id_node(id_orig, false);
+ return id_node->id_cow;
+}
+
+ID *DepsgraphNodeBuilder::expand_cow_id(IDDepsNode *id_node)
+{
+ return deg_expand_copy_on_write_datablock(m_graph, id_node, this, true);
+}
+
+ID *DepsgraphNodeBuilder::expand_cow_id(ID *id_orig)
+{
+ IDDepsNode *id_node = add_id_node(id_orig);
+ return expand_cow_id(id_node);
+}
+
/* **** Build functions for entity nodes **** */
void DepsgraphNodeBuilder::begin_build(Main *bmain) {
@@ -307,11 +350,36 @@ void DepsgraphNodeBuilder::begin_build(Main *bmain) {
/* XXX nested node trees are not included in tag-clearing above,
* so we need to do this manually.
*/
- FOREACH_NODETREE(bmain, nodetree, id) {
+ FOREACH_NODETREE(bmain, nodetree, id)
+ {
if (id != (ID *)nodetree) {
nodetree->id.tag &= ~LIB_TAG_DOIT;
}
- } FOREACH_NODETREE_END
+ }
+ FOREACH_NODETREE_END;
+
+#ifdef WITH_COPY_ON_WRITE
+ /* Store existing copy-on-write versions of datablock, so we can re-use
+ * them for new ID nodes.
+ */
+ m_cow_id_hash = BLI_ghash_ptr_new("Depsgraph id hash");
+ GHASH_FOREACH_BEGIN(IDDepsNode *, id_node, m_graph->id_hash)
+ {
+ if (GS(id_node->id_orig->name) != ID_SCE) {
+ continue;
+ }
+ if (deg_copy_on_write_is_expanded(id_node->id_cow)) {
+ BLI_ghash_insert(m_cow_id_hash, id_node->id_orig, id_node->id_cow);
+ id_node->id_cow = NULL;
+ }
+ }
+ GHASH_FOREACH_END();
+#endif
+
+ /* Make sure graph has no nodes left from previous state. */
+ m_graph->clear_all_nodes();
+ m_graph->operations.clear();
+ BLI_gset_clear(m_graph->entry_tags, NULL);
}
void DepsgraphNodeBuilder::build_group(Scene *scene, Group *group)
@@ -445,39 +513,41 @@ void DepsgraphNodeBuilder::build_object(Scene *scene, Object *ob)
void DepsgraphNodeBuilder::build_object_transform(Scene *scene, Object *ob)
{
OperationDepsNode *op_node;
+ Scene *scene_cow = get_cow_datablock(scene);
+ Object *ob_cow = get_cow_datablock(ob);
/* local transforms (from transform channels - loc/rot/scale + deltas) */
op_node = add_operation_node(&ob->id, DEG_NODE_TYPE_TRANSFORM,
- function_bind(BKE_object_eval_local_transform, _1, scene, ob),
+ function_bind(BKE_object_eval_local_transform,
+ _1,
+ scene_cow, ob_cow),
DEG_OPCODE_TRANSFORM_LOCAL);
op_node->set_as_entry();
/* object parent */
- if (ob->parent) {
+ if (ob->parent != NULL) {
add_operation_node(&ob->id, DEG_NODE_TYPE_TRANSFORM,
- function_bind(BKE_object_eval_parent, _1, scene, ob),
+ function_bind(BKE_object_eval_parent,
+ _1,
+ scene_cow, ob_cow),
DEG_OPCODE_TRANSFORM_PARENT);
}
/* object constraints */
- if (ob->constraints.first) {
+ if (ob->constraints.first != NULL) {
build_object_constraints(scene, ob);
}
- /* Temporary uber-update node, which does everything.
- * It is for the being we're porting old dependencies into the new system.
- * We'll get rid of this node as soon as all the granular update functions
- * are filled in.
- *
- * TODO(sergey): Get rid of this node.
- */
+ /* Rest of transformation update. */
add_operation_node(&ob->id, DEG_NODE_TYPE_TRANSFORM,
- function_bind(BKE_object_eval_uber_transform, _1, scene, ob),
- DEG_OPCODE_OBJECT_UBEREVAL);
+ function_bind(BKE_object_eval_uber_transform,
+ _1,
+ scene_cow, ob_cow),
+ DEG_OPCODE_TRANSFORM_OBJECT_UBEREVAL);
/* object transform is done */
op_node = add_operation_node(&ob->id, DEG_NODE_TYPE_TRANSFORM,
- function_bind(BKE_object_eval_done, _1, ob),
+ function_bind(BKE_object_eval_done, _1, ob_cow),
DEG_OPCODE_TRANSFORM_FINAL);
op_node->set_as_exit();
}
@@ -503,7 +573,9 @@ void DepsgraphNodeBuilder::build_object_constraints(Scene *scene, Object *ob)
{
/* create node for constraint stack */
add_operation_node(&ob->id, DEG_NODE_TYPE_TRANSFORM,
- function_bind(BKE_object_eval_constraints, _1, scene, ob),
+ function_bind(BKE_object_eval_constraints, _1,
+ get_cow_datablock(scene),
+ get_cow_datablock(ob)),
DEG_OPCODE_TRANSFORM_CONSTRAINTS);
}
@@ -514,23 +586,31 @@ void DepsgraphNodeBuilder::build_object_constraints(Scene *scene, Object *ob)
void DepsgraphNodeBuilder::build_animdata(ID *id)
{
AnimData *adt = BKE_animdata_from_id(id);
-
- if (adt == NULL)
+ if (adt == NULL) {
return;
+ }
/* animation */
if (adt->action || adt->nla_tracks.first || adt->drivers.first) {
- // XXX: Hook up specific update callbacks for special properties which may need it...
+ (void) add_id_node(id);
+ ID *id_cow = get_cow_id(id);
+
+ // XXX: Hook up specific update callbacks for special properties which
+ // may need it...
- /* actions and NLA - as a single unit for now, as it gets complicated to schedule otherwise */
+ /* actions and NLA - as a single unit for now, as it gets complicated to
+ * schedule otherwise.
+ */
if ((adt->action) || (adt->nla_tracks.first)) {
/* create the node */
add_operation_node(id, DEG_NODE_TYPE_ANIMATION,
- function_bind(BKE_animsys_eval_animdata, _1, id),
+ function_bind(BKE_animsys_eval_animdata, _1, id_cow),
DEG_OPCODE_ANIMATION, id->name);
- // TODO: for each channel affected, we might also want to add some support for running RNA update callbacks on them
- // (which will be needed for proper handling of drivers later)
+ /* TODO: for each channel affected, we might also want to add some
+ * support for running RNA update callbacks on them
+ * (which will be needed for proper handling of drivers later)
+ */
}
/* drivers */
@@ -548,7 +628,7 @@ void DepsgraphNodeBuilder::build_animdata(ID *id)
*/
OperationDepsNode *DepsgraphNodeBuilder::build_driver(ID *id, FCurve *fcu)
{
- ChannelDriver *driver = fcu->driver;
+ ID *id_cow = get_cow_id(id);
/* Create data node for this driver */
/* TODO(sergey): Avoid creating same operation multiple times,
@@ -562,19 +642,15 @@ OperationDepsNode *DepsgraphNodeBuilder::build_driver(ID *id, FCurve *fcu)
fcu->array_index);
if (driver_op == NULL) {
+ /* TODO(sergey): Shall we use COW of fcu itself here? */
driver_op = add_operation_node(id,
DEG_NODE_TYPE_PARAMETERS,
- function_bind(BKE_animsys_eval_driver, _1, id, fcu),
+ function_bind(BKE_animsys_eval_driver, _1, id_cow, fcu),
DEG_OPCODE_DRIVER,
fcu->rna_path ? fcu->rna_path : "",
fcu->array_index);
}
- /* tag "scripted expression" drivers as needing Python (due to GIL issues, etc.) */
- if (driver->type == DRIVER_TYPE_PYTHON) {
- driver_op->flag |= DEPSOP_FLAG_USES_PYTHON;
- }
-
/* return driver node created */
return driver_op;
}
@@ -590,10 +666,10 @@ void DepsgraphNodeBuilder::build_world(World *world)
build_animdata(world_id);
/* world itself */
- add_component_node(world_id, DEG_NODE_TYPE_PARAMETERS);
-
- add_operation_node(world_id, DEG_NODE_TYPE_PARAMETERS, NULL,
- DEG_OPCODE_PLACEHOLDER, "Parameters Eval");
+ add_operation_node(world_id,
+ DEG_NODE_TYPE_SHADING,
+ function_bind(BKE_world_eval, _1, world),
+ DEG_OPCODE_WORLD_UPDATE);
/* textures */
build_texture_stack(world->mtex);
@@ -608,43 +684,49 @@ void DepsgraphNodeBuilder::build_world(World *world)
void DepsgraphNodeBuilder::build_rigidbody(Scene *scene)
{
RigidBodyWorld *rbw = scene->rigidbody_world;
+ Scene *scene_cow = get_cow_datablock(scene);
/**
* Rigidbody Simulation Nodes
* ==========================
*
* There are 3 nodes related to Rigidbody Simulation:
- * 1) "Initialize/Rebuild World" - this is called sparingly, only when the simulation
- * needs to be rebuilt (mainly after file reload, or moving back to start frame)
- * 2) "Do Simulation" - perform a simulation step - interleaved between the evaluation
- * steps for clusters of objects (i.e. between those affected and/or not affected by
- * the sim for instance)
+ * 1) "Initialize/Rebuild World" - this is called sparingly, only when the
+ * simulation needs to be rebuilt (mainly after file reload, or moving
+ * back to start frame)
+ * 2) "Do Simulation" - perform a simulation step - interleaved between the
+ * evaluation steps for clusters of objects (i.e. between those affected
+ * and/or not affected by the sim for instance).
*
- * 3) "Pull Results" - grab the specific transforms applied for a specific object -
- * performed as part of object's transform-stack building
+ * 3) "Pull Results" - grab the specific transforms applied for a specific
+ * object - performed as part of object's transform-stack building.
*/
- /* create nodes ------------------------------------------------------------------------ */
- /* XXX: is this the right component, or do we want to use another one instead? */
+ /* Create nodes --------------------------------------------------------- */
+
+ /* XXX: is this the right component, or do we want to use another one
+ * instead?
+ */
/* init/rebuild operation */
- /*OperationDepsNode *init_node =*/ add_operation_node(&scene->id, DEG_NODE_TYPE_TRANSFORM,
- function_bind(BKE_rigidbody_rebuild_sim, _1, scene),
- DEG_OPCODE_RIGIDBODY_REBUILD);
+ /*OperationDepsNode *init_node =*/ add_operation_node(
+ &scene->id, DEG_NODE_TYPE_TRANSFORM,
+ function_bind(BKE_rigidbody_rebuild_sim, _1, scene_cow),
+ DEG_OPCODE_RIGIDBODY_REBUILD);
/* do-sim operation */
// XXX: what happens if we need to split into several groups?
- OperationDepsNode *sim_node = add_operation_node(&scene->id, DEG_NODE_TYPE_TRANSFORM,
- function_bind(BKE_rigidbody_eval_simulation, _1, scene),
- DEG_OPCODE_RIGIDBODY_SIM);
+ OperationDepsNode *sim_node = add_operation_node(
+ &scene->id, DEG_NODE_TYPE_TRANSFORM,
+ function_bind(BKE_rigidbody_eval_simulation, _1, scene_cow),
+ DEG_OPCODE_RIGIDBODY_SIM);
- /* XXX: For now, the sim node is the only one that really matters here. If any other
- * sims get added later, we may have to remove these hacks...
+ /* XXX: For now, the sim node is the only one that really matters here.
+ * If any other sims get added later, we may have to remove these hacks...
*/
sim_node->owner->entry_operation = sim_node;
sim_node->owner->exit_operation = sim_node;
-
/* objects - simulation participants */
if (rbw->group) {
LINKLIST_FOREACH (GroupObject *, go, &rbw->group->gobject) {
@@ -654,10 +736,14 @@ void DepsgraphNodeBuilder::build_rigidbody(Scene *scene)
continue;
/* 2) create operation for flushing results */
- /* object's transform component - where the rigidbody operation lives */
+ /* object's transform component - where the rigidbody operation
+ * lives. */
add_operation_node(&ob->id, DEG_NODE_TYPE_TRANSFORM,
- function_bind(BKE_rigidbody_object_sync_transforms, _1, scene, ob),
- DEG_OPCODE_TRANSFORM_RIGIDBODY);
+ function_bind(BKE_rigidbody_object_sync_transforms,
+ _1,
+ scene_cow,
+ get_cow_datablock(ob)),
+ DEG_OPCODE_RIGIDBODY_TRANSFORM_COPY);
}
}
}
@@ -683,39 +769,78 @@ void DepsgraphNodeBuilder::build_particles(Scene *scene, Object *ob)
ComponentDepsNode *psys_comp =
add_component_node(&ob->id, DEG_NODE_TYPE_EVAL_PARTICLES);
+ /* TODO(sergey): Need to get COW of PSYS. */
+ Scene *scene_cow = get_cow_datablock(scene);
+ Object *ob_cow = get_cow_datablock(ob);
+
+ add_operation_node(psys_comp,
+ function_bind(BKE_particle_system_eval_init,
+ _1,
+ scene_cow,
+ ob_cow),
+ DEG_OPCODE_PARTICLE_SYSTEM_EVAL_INIT);
+
/* particle systems */
LINKLIST_FOREACH (ParticleSystem *, psys, &ob->particlesystem) {
ParticleSettings *part = psys->part;
- /* particle settings */
- // XXX: what if this is used more than once!
- build_animdata(&part->id);
+ /* Build particle settings operations.
+ *
+ * NOTE: The call itself ensures settings are only build once.
+ */
+ build_particle_settings(part);
- /* this particle system */
- // TODO: for now, this will just be a placeholder "ubereval" node
+ /* Update on particle settings change. */
add_operation_node(psys_comp,
- function_bind(BKE_particle_system_eval,
+ function_bind(BKE_particle_system_settings_eval,
_1,
- scene,
- ob,
psys),
- DEG_OPCODE_PSYS_EVAL,
+ DEG_OPCODE_PARTICLE_SETTINGS_EVAL,
+ psys->name);
+
+ /* Particle system evaluation. */
+ add_operation_node(psys_comp,
+ NULL,
+ DEG_OPCODE_PARTICLE_SYSTEM_EVAL,
psys->name);
}
- /* pointcache */
- // TODO...
+ /* TODO(sergey): Do we need a point cache operations here? */
+}
+
+void DepsgraphNodeBuilder::build_particle_settings(ParticleSettings *part) {
+ ID *part_id = &part->id;
+ if (part_id->tag & LIB_TAG_DOIT) {
+ return;
+ }
+ part_id->tag |= LIB_TAG_DOIT;
+ /* Animation data. */
+ build_animdata(part_id);
+ /* Parameters change. */
+ add_operation_node(part_id,
+ DEG_NODE_TYPE_PARAMETERS,
+ NULL,
+ DEG_OPCODE_PARTICLE_SETTINGS_EVAL);
+ add_operation_node(part_id,
+ DEG_NODE_TYPE_PARAMETERS,
+ function_bind(BKE_particle_system_settings_recalc_clear,
+ _1,
+ part),
+ DEG_OPCODE_PARTICLE_SETTINGS_RECALC_CLEAR);
}
void DepsgraphNodeBuilder::build_cloth(Scene *scene, Object *object)
{
+ Scene *scene_cow = get_cow_datablock(scene);
+ Object *object_cow = get_cow_datablock(object);
+
ComponentDepsNode *cache_comp = add_component_node(&object->id,
DEG_NODE_TYPE_CACHE);
add_operation_node(cache_comp,
function_bind(BKE_object_eval_cloth,
_1,
- scene,
- object),
+ scene_cow,
+ object_cow),
DEG_OPCODE_PLACEHOLDER,
"Cloth Modifier");
}
@@ -733,8 +858,9 @@ void DepsgraphNodeBuilder::build_shapekeys(Key *key)
// XXX: what happens if the datablock is shared!
void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob)
{
- ID *obdata = (ID *)ob->data;
OperationDepsNode *op_node;
+ Scene *scene_cow = get_cow_datablock(scene);
+ Object *object_cow = get_cow_datablock(ob);
/* TODO(sergey): This way using this object's properties as driver target
* works fine.
@@ -744,8 +870,7 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob)
op_node = add_operation_node(&ob->id,
DEG_NODE_TYPE_PARAMETERS,
NULL,
- DEG_OPCODE_PLACEHOLDER,
- "Parameters Eval");
+ DEG_OPCODE_PARAMETERS_EVAL);
op_node->set_as_exit();
/* Temporary uber-update node, which does everything.
@@ -759,8 +884,8 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob)
DEG_NODE_TYPE_GEOMETRY,
function_bind(BKE_object_eval_uber_data,
_1,
- (Scene *)get_cow_id(&scene->id),
- (Object *)get_cow_id(&ob->id)),
+ scene_cow,
+ object_cow),
DEG_OPCODE_GEOMETRY_UBEREVAL);
op_node->set_as_exit();
@@ -781,10 +906,20 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob)
}
/* materials */
- for (int a = 1; a <= ob->totcol; a++) {
- Material *ma = give_current_material(ob, a);
- if (ma != NULL) {
- build_material(ma);
+ if (ob->totcol != 0) {
+ if (ob->type == OB_MESH) {
+ add_operation_node(&ob->id,
+ DEG_NODE_TYPE_SHADING,
+ function_bind(BKE_object_eval_update_shading, _1,
+ object_cow),
+ DEG_OPCODE_SHADING);
+ }
+
+ for (int a = 1; a <= ob->totcol; a++) {
+ Material *ma = give_current_material(ob, a);
+ if (ma != NULL) {
+ build_material(ma);
+ }
}
}
@@ -793,9 +928,14 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob)
// add geometry collider relations
}
+ ID *obdata = (ID *)ob->data;
if (obdata->tag & LIB_TAG_DOIT) {
return;
}
+ obdata->tag |= LIB_TAG_DOIT;
+ /* Make sure we've got an ID node before requesting CoW pointer. */
+ (void) add_id_node((ID *)obdata);
+ ID *obdata_cow = get_cow_id(obdata);
/* ShapeKeys */
Key *key = BKE_key_from_object(ob);
@@ -818,7 +958,7 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob)
DEG_NODE_TYPE_GEOMETRY,
function_bind(BKE_mesh_eval_geometry,
_1,
- (Mesh *)obdata),
+ (Mesh *)obdata_cow),
DEG_OPCODE_PLACEHOLDER,
"Geometry Eval");
op_node->set_as_entry();
@@ -837,7 +977,7 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob)
DEG_NODE_TYPE_GEOMETRY,
function_bind(BKE_mball_eval_geometry,
_1,
- (MetaBall *)obdata),
+ (MetaBall *)obdata_cow),
DEG_OPCODE_PLACEHOLDER,
"Geometry Eval");
op_node->set_as_entry();
@@ -855,22 +995,10 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob)
DEG_NODE_TYPE_GEOMETRY,
function_bind(BKE_curve_eval_geometry,
_1,
- (Curve *)obdata),
+ (Curve *)obdata_cow),
DEG_OPCODE_PLACEHOLDER,
"Geometry Eval");
op_node->set_as_entry();
-
- /* Calculate curve path - this is used by constraints, etc. */
- if (ELEM(ob->type, OB_CURVE, OB_FONT)) {
- add_operation_node(obdata,
- DEG_NODE_TYPE_GEOMETRY,
- function_bind(BKE_curve_eval_path,
- _1,
- (Curve *)obdata),
- DEG_OPCODE_GEOMETRY_PATH,
- "Path");
- }
-
/* Make sure objects used for bevel.taper are in the graph.
* NOTE: This objects might be not linked to the scene.
*/
@@ -894,7 +1022,7 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob)
DEG_NODE_TYPE_GEOMETRY,
function_bind(BKE_lattice_eval_geometry,
_1,
- (Lattice *)obdata),
+ (Lattice *)obdata_cow),
DEG_OPCODE_PLACEHOLDER,
"Geometry Eval");
op_node->set_as_entry();
@@ -907,14 +1035,24 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob)
op_node->set_as_exit();
/* Parameters for driver sources. */
- add_operation_node(obdata, DEG_NODE_TYPE_PARAMETERS, NULL,
- DEG_OPCODE_PLACEHOLDER, "Parameters Eval");
+ add_operation_node(obdata,
+ DEG_NODE_TYPE_PARAMETERS,
+ NULL,
+ DEG_OPCODE_PARAMETERS_EVAL);
}
/* Cameras */
void DepsgraphNodeBuilder::build_camera(Object *ob)
{
- /* TODO: Link scene-camera links in somehow... */
+ /* Object itself. */
+ add_operation_node(&ob->id,
+ DEG_NODE_TYPE_PARAMETERS,
+ NULL,
+ DEG_OPCODE_PARAMETERS_EVAL,
+ "Camera Parameters");
+
+ /* Object data. */
+ /* TODO: Link scene-camera links in somehow. */
Camera *cam = (Camera *)ob->data;
ID *camera_id = &cam->id;
if (camera_id->tag & LIB_TAG_DOIT) {
@@ -923,19 +1061,23 @@ void DepsgraphNodeBuilder::build_camera(Object *ob)
build_animdata(&cam->id);
- add_operation_node(camera_id, DEG_NODE_TYPE_PARAMETERS, NULL,
- DEG_OPCODE_PLACEHOLDER, "Parameters Eval");
-
- if (cam->dof_ob != NULL) {
- /* TODO(sergey): For now parametrs are on object level. */
- add_operation_node(&ob->id, DEG_NODE_TYPE_PARAMETERS, NULL,
- DEG_OPCODE_PLACEHOLDER, "Camera DOF");
- }
+ add_operation_node(camera_id,
+ DEG_NODE_TYPE_PARAMETERS,
+ NULL,
+ DEG_OPCODE_PARAMETERS_EVAL);
}
/* Lamps */
void DepsgraphNodeBuilder::build_lamp(Object *ob)
{
+ /* Object itself. */
+ add_operation_node(&ob->id,
+ DEG_NODE_TYPE_PARAMETERS,
+ NULL,
+ DEG_OPCODE_PARAMETERS_EVAL,
+ "Lamp Parameters");
+
+ /* Object data. */
Lamp *la = (Lamp *)ob->data;
ID *lamp_id = &la->id;
if (lamp_id->tag & LIB_TAG_DOIT) {
@@ -945,11 +1087,10 @@ void DepsgraphNodeBuilder::build_lamp(Object *ob)
build_animdata(&la->id);
/* node for obdata */
- add_component_node(lamp_id, DEG_NODE_TYPE_PARAMETERS);
-
- /* TODO(sergey): Is it really how we're supposed to work with drivers? */
- add_operation_node(lamp_id, DEG_NODE_TYPE_PARAMETERS, NULL,
- DEG_OPCODE_PLACEHOLDER, "Parameters Eval");
+ add_operation_node(lamp_id,
+ DEG_NODE_TYPE_PARAMETERS,
+ NULL,
+ DEG_OPCODE_PARAMETERS_EVAL);
/* lamp's nodetree */
if (la->nodetree) {
@@ -962,25 +1103,30 @@ void DepsgraphNodeBuilder::build_lamp(Object *ob)
void DepsgraphNodeBuilder::build_nodetree(bNodeTree *ntree)
{
- if (!ntree)
+ if (ntree == NULL) {
return;
-
+ }
/* nodetree itself */
ID *ntree_id = &ntree->id;
- OperationDepsNode *op_node;
-
+ add_id_node(ntree_id);
+ bNodeTree *ntree_cow = get_cow_datablock(ntree);
+ /* Animation, */
build_animdata(ntree_id);
-
- /* Parameters for drivers. */
- op_node = add_operation_node(ntree_id, DEG_NODE_TYPE_PARAMETERS, NULL,
- DEG_OPCODE_PLACEHOLDER, "Parameters Eval");
- op_node->set_as_exit();
-
+ /* Shading update. */
+ add_operation_node(ntree_id,
+ DEG_NODE_TYPE_SHADING,
+ NULL,
+ DEG_OPCODE_MATERIAL_UPDATE);
+ add_operation_node(ntree_id,
+ DEG_NODE_TYPE_SHADING_PARAMETERS,
+ function_bind(BKE_nodetree_shading_params_eval,
+ _1, ntree_cow, ntree),
+ DEG_OPCODE_MATERIAL_UPDATE);
/* nodetree's nodes... */
LINKLIST_FOREACH (bNode *, bnode, &ntree->nodes) {
ID *id = bnode->id;
if (id != NULL) {
- short id_type = GS(id->name);
+ ID_Type id_type = GS(id->name);
if (id_type == ID_MA) {
build_material((Material *)id);
}
@@ -1003,27 +1149,27 @@ void DepsgraphNodeBuilder::build_nodetree(bNodeTree *ntree)
}
/* Recursively build graph for material */
-void DepsgraphNodeBuilder::build_material(Material *ma)
+void DepsgraphNodeBuilder::build_material(Material *material)
{
- ID *ma_id = &ma->id;
- if (ma_id->tag & LIB_TAG_DOIT) {
+ ID *material_id = &material->id;
+ if (material_id->tag & LIB_TAG_DOIT) {
return;
}
-
- /* material itself */
- add_id_node(ma_id);
-
- add_operation_node(ma_id, DEG_NODE_TYPE_SHADING, NULL,
- DEG_OPCODE_PLACEHOLDER, "Material Update");
-
- /* material animation */
- build_animdata(ma_id);
-
- /* textures */
- build_texture_stack(ma->mtex);
-
- /* material's nodetree */
- build_nodetree(ma->nodetree);
+ material_id->tag |= LIB_TAG_DOIT;
+ /* Material itself. */
+ add_id_node(material_id);
+ Material *material_cow = get_cow_datablock(material);
+ /* Shading update. */
+ add_operation_node(material_id,
+ DEG_NODE_TYPE_SHADING,
+ function_bind(BKE_material_eval, _1, material_cow),
+ DEG_OPCODE_MATERIAL_UPDATE);
+ /* Material animation. */
+ build_animdata(material_id);
+ /* Textures. */
+ build_texture_stack(material->mtex);
+ /* Material's nodetree. */
+ build_nodetree(material->nodetree);
}
/* Texture-stack attached to some shading datablock */
@@ -1117,7 +1263,18 @@ void DepsgraphNodeBuilder::build_mask(Mask *mask)
{
ID *mask_id = &mask->id;
add_id_node(mask_id);
+ /* F-Curve based animation/ */
build_animdata(mask_id);
+ /* Animation based on mask's shapes. */
+ add_operation_node(mask_id,
+ DEG_NODE_TYPE_ANIMATION,
+ function_bind(BKE_mask_eval_animation, _1, mask),
+ DEG_OPCODE_MASK_ANIMATION);
+ /* Final mask evaluation. */
+ add_operation_node(mask_id,
+ DEG_NODE_TYPE_PARAMETERS,
+ function_bind(BKE_mask_eval_update, _1, mask),
+ DEG_OPCODE_MASK_EVAL);
}
void DepsgraphNodeBuilder::build_movieclip(MovieClip *clip)
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
index 54ad1bd5d8a..7e28df1276d 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
@@ -49,6 +49,7 @@ struct MTex;
struct MovieClip;
struct bNodeTree;
struct Object;
+struct ParticleSettings;
struct Probe;
struct bPoseChannel;
struct bConstraint;
@@ -71,11 +72,42 @@ struct DepsgraphNodeBuilder {
DepsgraphNodeBuilder(Main *bmain, Depsgraph *graph);
~DepsgraphNodeBuilder();
- void begin_build(Main *bmain);
-
+ /* For given original ID get ID which is created by CoW system. */
ID *get_cow_id(const ID *id_orig) const;
+ /* Similar to above, but for the cases when there is no ID node we create
+ * one.
+ */
+ ID *ensure_cow_id(ID *id_orig);
+
+ /* Helper wrapper function which wraps get_cow_id with a needed type cast. */
+ template<typename T>
+ T *get_cow_datablock(const T *orig) const {
+ return (T *)get_cow_id(&orig->id);
+ }
+
+ /* Get fully expanded (ready for use) copy-on-write datablock for the given
+ * original datablock.
+ */
+ ID *expand_cow_id(IDDepsNode *id_node);
+ ID *expand_cow_id(ID *id_orig);
+ template<typename T>
+ T *expand_cow_datablock(T *orig) {
+ return (T *)expand_cow_id(&orig->id);
+ }
+
+ /* For a given COW datablock get corresponding original one. */
+ template<typename T>
+ T *get_orig_datablock(const T *cow) const {
+#ifdef WITH_COPY_ON_WRITE
+ return (T *)cow->id.newid;
+#else
+ return (T *)cow;
+#endif
+ }
+
+ void begin_build(Main *bmain);
- IDDepsNode *add_id_node(ID *id);
+ IDDepsNode *add_id_node(ID *id, bool do_tag = true);
TimeSourceDepsNode *add_time_source();
ComponentDepsNode *add_component_node(ID *id,
@@ -129,6 +161,7 @@ struct DepsgraphNodeBuilder {
void build_pose_constraints(Scene *scene, Object *ob, bPoseChannel *pchan);
void build_rigidbody(Scene *scene);
void build_particles(Scene *scene, Object *ob);
+ void build_particle_settings(ParticleSettings *part);
void build_cloth(Scene *scene, Object *object);
void build_animdata(ID *id);
OperationDepsNode *build_driver(ID *id, FCurve *fcurve);
@@ -173,6 +206,7 @@ struct DepsgraphNodeBuilder {
protected:
Main *m_bmain;
Depsgraph *m_graph;
+ GHash *m_cow_id_hash;
};
} // namespace DEG
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_layer.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_layer.cc
index b6df176545e..b3a88d8ac4d 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_layer.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_layer.cc
@@ -24,7 +24,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc
+/** \file blender/depsgraph/intern/builder/deg_builder_nodes_layer.cc
* \ingroup depsgraph
*
* Methods for constructing depsgraph's nodes
@@ -98,9 +98,7 @@ void DepsgraphNodeBuilder::build_scene_layer_collections(Scene *scene)
{
#ifdef WITH_COPY_ON_WRITE
/* Make sure we've got ID node, so we can get pointer to CoW datablock. */
- IDDepsNode *id_node = add_id_node(&scene->id);
- Scene *scene_cow = (Scene *)deg_expand_copy_on_write_datablock(m_graph,
- id_node);
+ Scene *scene_cow = expand_cow_datablock(scene);
#else
Scene *scene_cow = scene;
#endif
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc
index 51b27912298..d610dc51080 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc
@@ -46,6 +46,7 @@ extern "C" {
#include "DNA_armature_types.h"
#include "DNA_constraint_types.h"
#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
#include "BKE_action.h"
#include "BKE_armature.h"
@@ -55,6 +56,7 @@ extern "C" {
#include "DEG_depsgraph_build.h"
#include "intern/builder/deg_builder.h"
+#include "intern/eval/deg_eval_copy_on_write.h"
#include "intern/nodes/deg_node.h"
#include "intern/nodes/deg_node_component.h"
#include "intern/nodes/deg_node_operation.h"
@@ -64,16 +66,25 @@ extern "C" {
namespace DEG {
-void DepsgraphNodeBuilder::build_pose_constraints(Scene *scene, Object *ob, bPoseChannel *pchan)
+void DepsgraphNodeBuilder::build_pose_constraints(Scene *scene,
+ Object *ob,
+ bPoseChannel *pchan)
{
/* create node for constraint stack */
add_operation_node(&ob->id, DEG_NODE_TYPE_BONE, pchan->name,
- function_bind(BKE_pose_constraints_evaluate, _1, scene, ob, pchan),
+ function_bind(BKE_pose_constraints_evaluate,
+ _1,
+ get_cow_datablock(scene),
+ get_cow_datablock(ob),
+ pchan),
DEG_OPCODE_BONE_CONSTRAINTS);
}
/* IK Solver Eval Steps */
-void DepsgraphNodeBuilder::build_ik_pose(Scene *scene, Object *ob, bPoseChannel *pchan, bConstraint *con)
+void DepsgraphNodeBuilder::build_ik_pose(Scene *scene,
+ Object *ob,
+ bPoseChannel *pchan,
+ bConstraint *con)
{
bKinematicConstraint *data = (bKinematicConstraint *)con->data;
@@ -88,12 +99,18 @@ void DepsgraphNodeBuilder::build_ik_pose(Scene *scene, Object *ob, bPoseChannel
/* Operation node for evaluating/running IK Solver. */
add_operation_node(&ob->id, DEG_NODE_TYPE_EVAL_POSE, rootchan->name,
- function_bind(BKE_pose_iktree_evaluate, _1, scene, ob, rootchan),
+ function_bind(BKE_pose_iktree_evaluate, _1,
+ get_cow_datablock(scene),
+ get_cow_datablock(ob),
+ rootchan),
DEG_OPCODE_POSE_IK_SOLVER);
}
/* Spline IK Eval Steps */
-void DepsgraphNodeBuilder::build_splineik_pose(Scene *scene, Object *ob, bPoseChannel *pchan, bConstraint *con)
+void DepsgraphNodeBuilder::build_splineik_pose(Scene *scene,
+ Object *ob,
+ bPoseChannel *pchan,
+ bConstraint *con)
{
bSplineIKConstraint *data = (bSplineIKConstraint *)con->data;
@@ -101,30 +118,51 @@ void DepsgraphNodeBuilder::build_splineik_pose(Scene *scene, Object *ob, bPoseCh
bPoseChannel *rootchan = BKE_armature_splineik_solver_find_root(pchan, data);
/* Operation node for evaluating/running Spline IK Solver.
- * Store the "root bone" of this chain in the solver, so it knows where to start.
+ * Store the "root bone" of this chain in the solver, so it knows where to
+ * start.
*/
add_operation_node(&ob->id, DEG_NODE_TYPE_EVAL_POSE, rootchan->name,
- function_bind(BKE_pose_splineik_evaluate, _1, scene, ob, rootchan),
+ function_bind(BKE_pose_splineik_evaluate,
+ _1,
+ get_cow_datablock(scene),
+ get_cow_datablock(ob),
+ rootchan),
DEG_OPCODE_POSE_SPLINE_IK_SOLVER);
}
/* Pose/Armature Bones Graph */
-void DepsgraphNodeBuilder::build_rig(Scene *scene, Object *ob)
+void DepsgraphNodeBuilder::build_rig(Scene *scene, Object *object)
{
- bArmature *arm = (bArmature *)ob->data;
+ bArmature *armature = (bArmature *)object->data;
+ const short armature_tag = armature->id.tag;
+#ifdef WITH_COPY_ON_WRITE
+ /* NOTE: We need to expand both object and armature, so this way we can
+ * safely create object level pose.
+ */
+ Scene *scene_cow = get_cow_datablock(scene);
+ Object *object_cow = expand_cow_datablock(object);
+ bArmature *armature_cow = expand_cow_datablock(armature);
+#else
+ Scene *scene_cow = scene;
+ Object *object_cow = object;
+ bArmature *armature_cow = armature;
+#endif
OperationDepsNode *op_node;
- /* animation and/or drivers linking posebones to base-armature used to define them
+ /* Animation and/or drivers linking posebones to base-armature used to
+ * define them.
+ *
* NOTE: AnimData here is really used to control animated deform properties,
- * which ideally should be able to be unique across different instances.
- * Eventually, we need some type of proxy/isolation mechanism in-between here
- * to ensure that we can use same rig multiple times in same scene...
+ * which ideally should be able to be unique across different
+ * instances. Eventually, we need some type of proxy/isolation
+ * mechanism in-between here to ensure that we can use same rig
+ * multiple times in same scene.
*/
- if ((arm->id.tag & LIB_TAG_DOIT) == 0) {
- build_animdata(&arm->id);
+ if ((armature_tag & LIB_TAG_DOIT) == 0) {
+ build_animdata(&armature->id);
/* Make sure pose is up-to-date with armature updates. */
- add_operation_node(&arm->id,
+ add_operation_node(&armature->id,
DEG_NODE_TYPE_PARAMETERS,
NULL,
DEG_OPCODE_PLACEHOLDER,
@@ -132,22 +170,22 @@ void DepsgraphNodeBuilder::build_rig(Scene *scene, Object *ob)
}
/* Rebuild pose if not up to date. */
- if (ob->pose == NULL || (ob->pose->flag & POSE_RECALC)) {
- BKE_pose_rebuild(ob, arm);
+ if (object_cow->pose == NULL || (object->pose->flag & POSE_RECALC)) {
+ BKE_pose_rebuild(object_cow, armature_cow);
/* XXX: Without this animation gets lost in certain circumstances
* after loading file. Need to investigate further since it does
* not happen with simple scenes..
*/
- if (ob->adt) {
- ob->adt->recalc |= ADT_RECALC_ANIM;
+ if (object_cow->adt) {
+ object_cow->adt->recalc |= ADT_RECALC_ANIM;
}
}
/* speed optimization for animation lookups */
- if (ob->pose) {
- BKE_pose_channels_hash_make(ob->pose);
- if (ob->pose->flag & POSE_CONSTRAINTS_NEED_UPDATE_FLAGS) {
- BKE_pose_update_constraint_flags(ob->pose);
+ if (object_cow->pose != NULL) {
+ BKE_pose_channels_hash_make(object_cow->pose);
+ if (object_cow->pose->flag & POSE_CONSTRAINTS_NEED_UPDATE_FLAGS) {
+ BKE_pose_update_constraint_flags(object_cow->pose);
}
}
@@ -168,74 +206,99 @@ void DepsgraphNodeBuilder::build_rig(Scene *scene, Object *ob)
* - Used for representing each bone within the rig
* - Acts to encapsulate the evaluation operations (base matrix + parenting,
* and constraint stack) so that they can be easily found.
- * - Everything else which depends on bone-results hook up to the component only
- * so that we can redirect those to point at either the the post-IK/
+ * - Everything else which depends on bone-results hook up to the component
+ * only so that we can redirect those to point at either the the post-IK/
* post-constraint/post-matrix steps, as needed.
*/
/* pose eval context */
- op_node = add_operation_node(&ob->id,
+ op_node = add_operation_node(&object->id,
DEG_NODE_TYPE_EVAL_POSE,
- function_bind(BKE_pose_eval_init, _1, scene, ob, ob->pose),
+ function_bind(BKE_pose_eval_init,
+ _1,
+ scene_cow,
+ object_cow,
+ object_cow->pose),
DEG_OPCODE_POSE_INIT);
op_node->set_as_entry();
- op_node = add_operation_node(&ob->id,
+ op_node = add_operation_node(&object->id,
DEG_NODE_TYPE_EVAL_POSE,
- function_bind(BKE_pose_eval_flush, _1, scene, ob, ob->pose),
+ function_bind(BKE_pose_eval_init_ik,
+ _1,
+ scene_cow,
+ object_cow,
+ object_cow->pose),
+ DEG_OPCODE_POSE_INIT_IK);
+
+ op_node = add_operation_node(&object->id,
+ DEG_NODE_TYPE_EVAL_POSE,
+ function_bind(BKE_pose_eval_flush,
+ _1,
+ scene_cow,
+ object_cow,
+ object_cow->pose),
DEG_OPCODE_POSE_DONE);
op_node->set_as_exit();
/* bones */
- LINKLIST_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
+ LINKLIST_FOREACH (bPoseChannel *, pchan, &object_cow->pose->chanbase) {
/* node for bone eval */
- op_node = add_operation_node(&ob->id, DEG_NODE_TYPE_BONE, pchan->name, NULL,
- DEG_OPCODE_BONE_LOCAL);
+ op_node = add_operation_node(&object->id, DEG_NODE_TYPE_BONE,
+ pchan->name, NULL, DEG_OPCODE_BONE_LOCAL);
op_node->set_as_entry();
- add_operation_node(&ob->id, DEG_NODE_TYPE_BONE, pchan->name,
- function_bind(BKE_pose_eval_bone, _1, scene, ob, pchan),
+ add_operation_node(&object->id, DEG_NODE_TYPE_BONE, pchan->name,
+ function_bind(BKE_pose_eval_bone, _1,
+ scene_cow,
+ object_cow,
+ pchan),
DEG_OPCODE_BONE_POSE_PARENT);
- add_operation_node(&ob->id, DEG_NODE_TYPE_BONE, pchan->name,
- NULL, /* NOTE: dedicated noop for easier relationship construction */
+ /* NOTE: Dedicated noop for easier relationship construction. */
+ add_operation_node(&object->id, DEG_NODE_TYPE_BONE, pchan->name,
+ NULL,
DEG_OPCODE_BONE_READY);
- op_node = add_operation_node(&ob->id, DEG_NODE_TYPE_BONE, pchan->name,
+ op_node = add_operation_node(&object->id, DEG_NODE_TYPE_BONE, pchan->name,
function_bind(BKE_pose_bone_done, _1, pchan),
DEG_OPCODE_BONE_DONE);
op_node->set_as_exit();
-
- /* constraints */
+ /* Build constraints. */
if (pchan->constraints.first != NULL) {
- build_pose_constraints(scene, ob, pchan);
+ build_pose_constraints(scene, object, pchan);
}
-
/**
- * IK Solvers...
+ * IK Solvers.
*
* - These require separate processing steps are pose-level
* to be executed between chains of bones (i.e. once the
* base transforms of a bunch of bones is done)
*
* Unsolved Issues:
- * - Care is needed to ensure that multi-headed trees work out the same as in ik-tree building
- * - Animated chain-lengths are a problem...
+ * - Care is needed to ensure that multi-headed trees work out the same
+ * as in ik-tree building
+ * - Animated chain-lengths are a problem.
*/
LINKLIST_FOREACH (bConstraint *, con, &pchan->constraints) {
switch (con->type) {
case CONSTRAINT_TYPE_KINEMATIC:
- build_ik_pose(scene, ob, pchan, con);
+ build_ik_pose(scene, object, pchan, con);
break;
case CONSTRAINT_TYPE_SPLINEIK:
- build_splineik_pose(scene, ob, pchan, con);
+ build_splineik_pose(scene, object, pchan, con);
break;
default:
break;
}
}
+ /* Custom shape. */
+ /* NOTE: Custom shape datablock is already remapped to CoW version. */
+ if (pchan->custom != NULL) {
+ build_object(scene, get_orig_datablock(pchan->custom));
+ }
}
}
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc
index f24d4e8d3f2..a8acc88f7f3 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc
@@ -89,6 +89,9 @@ void DepsgraphNodeBuilder::build_scene(Main *bmain, Scene *scene)
base->object->select_color = select_color++;
}
}
+ if (scene->camera != NULL) {
+ build_object(scene, scene->camera);
+ }
/* rigidbody */
if (scene->rigidbody_world) {
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 006358ea9e1..0c5150f2f42 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -324,7 +324,7 @@ void DepsgraphRelationBuilder::add_collision_relations(const OperationKey &key,
void DepsgraphRelationBuilder::add_forcefield_relations(const OperationKey &key, Scene *scene, Object *ob, ParticleSystem *psys, EffectorWeights *eff, bool add_absorption, const char *name)
{
- ListBase *effectors = pdInitEffectors(scene, ob, psys, eff, false);
+ ListBase *effectors = pdInitEffectors(NULL, scene, ob, psys, eff, false);
if (effectors) {
for (EffectorCache *eff = (EffectorCache *)effectors->first; eff; eff = eff->next) {
@@ -343,7 +343,7 @@ void DepsgraphRelationBuilder::add_forcefield_relations(const OperationKey &key,
add_relation(mod_key, key, name);
}
else if (eff->psys != psys) {
- OperationKey eff_key(&eff->ob->id, DEG_NODE_TYPE_EVAL_PARTICLES, DEG_OPCODE_PSYS_EVAL, eff->psys->name);
+ OperationKey eff_key(&eff->ob->id, DEG_NODE_TYPE_EVAL_PARTICLES, DEG_OPCODE_PARTICLE_SYSTEM_EVAL, eff->psys->name);
add_relation(eff_key, key, name);
}
}
@@ -423,7 +423,7 @@ void DepsgraphRelationBuilder::build_object(Main *bmain, Scene *scene, Object *o
OperationKey parent_transform_key(&ob->id, DEG_NODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_PARENT);
OperationKey final_transform_key(&ob->id, DEG_NODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_FINAL);
- OperationKey ob_ubereval_key(&ob->id, DEG_NODE_TYPE_TRANSFORM, DEG_OPCODE_OBJECT_UBEREVAL);
+ OperationKey ob_ubereval_key(&ob->id, DEG_NODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_OBJECT_UBEREVAL);
/* parenting */
if (ob->parent != NULL) {
@@ -521,7 +521,7 @@ void DepsgraphRelationBuilder::build_object(Main *bmain, Scene *scene, Object *o
build_proxy_rig(ob);
}
else {
- build_rig(scene, ob);
+ build_rig(bmain, scene, ob);
}
break;
@@ -666,58 +666,74 @@ void DepsgraphRelationBuilder::build_object_parent(Object *ob)
}
}
-void DepsgraphRelationBuilder::build_constraints(Scene *scene, ID *id, eDepsNode_Type component_type, const char *component_subdata,
- ListBase *constraints, RootPChanMap *root_map)
+void DepsgraphRelationBuilder::build_constraints(Scene *scene, ID *id,
+ eDepsNode_Type component_type,
+ const char *component_subdata,
+ ListBase *constraints,
+ RootPChanMap *root_map)
{
- OperationKey constraint_op_key(id, component_type, component_subdata,
- (component_type == DEG_NODE_TYPE_BONE) ? DEG_OPCODE_BONE_CONSTRAINTS : DEG_OPCODE_TRANSFORM_CONSTRAINTS);
-
- /* add dependencies for each constraint in turn */
+ OperationKey constraint_op_key(
+ id,
+ component_type,
+ component_subdata,
+ (component_type == DEG_NODE_TYPE_BONE)
+ ? DEG_OPCODE_BONE_CONSTRAINTS
+ : DEG_OPCODE_TRANSFORM_CONSTRAINTS);
+ /* Add dependencies for each constraint in turn. */
for (bConstraint *con = (bConstraint *)constraints->first; con; con = con->next) {
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
-
- /* invalid constraint type... */
- if (cti == NULL)
+ /* Invalid constraint type. */
+ if (cti == NULL) {
continue;
-
- /* special case for camera tracking -- it doesn't use targets to define relations */
- // TODO: we can now represent dependencies in a much richer manner, so review how this is done...
- if (ELEM(cti->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_CAMERASOLVER, CONSTRAINT_TYPE_OBJECTSOLVER)) {
+ }
+ /* Special case for camera tracking -- it doesn't use targets to
+ * define relations.
+ */
+ /* TODO: we can now represent dependencies in a much richer manner,
+ * so review how this is done.
+ */
+ if (ELEM(cti->type,
+ CONSTRAINT_TYPE_FOLLOWTRACK,
+ CONSTRAINT_TYPE_CAMERASOLVER,
+ CONSTRAINT_TYPE_OBJECTSOLVER))
+ {
bool depends_on_camera = false;
-
if (cti->type == CONSTRAINT_TYPE_FOLLOWTRACK) {
bFollowTrackConstraint *data = (bFollowTrackConstraint *)con->data;
-
- if (((data->clip) || (data->flag & FOLLOWTRACK_ACTIVECLIP)) && data->track[0])
+ if (((data->clip) ||
+ (data->flag & FOLLOWTRACK_ACTIVECLIP)) && data->track[0])
+ {
depends_on_camera = true;
-
+ }
if (data->depth_ob) {
- // DAG_RL_DATA_OB | DAG_RL_OB_OB
- ComponentKey depth_key(&data->depth_ob->id, DEG_NODE_TYPE_TRANSFORM);
- add_relation(depth_key, constraint_op_key, cti->name);
+ ComponentKey depth_transform_key(&data->depth_ob->id,
+ DEG_NODE_TYPE_TRANSFORM);
+ ComponentKey depth_geometry_key(&data->depth_ob->id,
+ DEG_NODE_TYPE_GEOMETRY);
+ add_relation(depth_transform_key, constraint_op_key, cti->name);
+ add_relation(depth_geometry_key, constraint_op_key, cti->name);
}
}
else if (cti->type == CONSTRAINT_TYPE_OBJECTSOLVER) {
depends_on_camera = true;
}
-
if (depends_on_camera && scene->camera) {
- // DAG_RL_DATA_OB | DAG_RL_OB_OB
ComponentKey camera_key(&scene->camera->id, DEG_NODE_TYPE_TRANSFORM);
add_relation(camera_key, constraint_op_key, cti->name);
}
-
- /* TODO(sergey): This is more a TimeSource -> MovieClip -> Constraint dependency chain. */
+ /* TODO(sergey): This is more a TimeSource -> MovieClip ->
+ * Constraint dependency chain.
+ */
TimeSourceKey time_src_key;
add_relation(time_src_key, constraint_op_key, "[TimeSrc -> Animation]");
}
else if (cti->type == CONSTRAINT_TYPE_TRANSFORM_CACHE) {
- /* TODO(kevin): This is more a TimeSource -> CacheFile -> Constraint dependency chain. */
+ /* TODO(kevin): This is more a TimeSource -> CacheFile -> Constraint
+ * dependency chain.
+ */
TimeSourceKey time_src_key;
add_relation(time_src_key, constraint_op_key, "[TimeSrc -> Animation]");
-
bTransformCacheConstraint *data = (bTransformCacheConstraint *)con->data;
-
if (data->cache_file) {
ComponentKey cache_key(&data->cache_file->id, DEG_NODE_TYPE_CACHE);
add_relation(cache_key, constraint_op_key, cti->name);
@@ -726,52 +742,73 @@ void DepsgraphRelationBuilder::build_constraints(Scene *scene, ID *id, eDepsNode
else if (cti->get_constraint_targets) {
ListBase targets = {NULL, NULL};
cti->get_constraint_targets(con, &targets);
-
LINKLIST_FOREACH (bConstraintTarget *, ct, &targets) {
if (ct->tar == NULL) {
continue;
}
-
- if (ELEM(con->type, CONSTRAINT_TYPE_KINEMATIC, CONSTRAINT_TYPE_SPLINEIK)) {
- /* ignore IK constraints - these are handled separately (on pose level) */
+ if (ELEM(con->type,
+ CONSTRAINT_TYPE_KINEMATIC,
+ CONSTRAINT_TYPE_SPLINEIK))
+ {
+ /* Ignore IK constraints - these are handled separately
+ * (on pose level).
+ */
}
- else if (ELEM(con->type, CONSTRAINT_TYPE_FOLLOWPATH, CONSTRAINT_TYPE_CLAMPTO)) {
- /* these constraints require path geometry data... */
+ else if (ELEM(con->type,
+ CONSTRAINT_TYPE_FOLLOWPATH,
+ CONSTRAINT_TYPE_CLAMPTO))
+ {
+ /* These constraints require path geometry data. */
ComponentKey target_key(&ct->tar->id, DEG_NODE_TYPE_GEOMETRY);
- add_relation(target_key, constraint_op_key, cti->name); // XXX: type = geom_transform
- // TODO: path dependency
+ add_relation(target_key, constraint_op_key, cti->name);
+ ComponentKey target_transform_key(&ct->tar->id,
+ DEG_NODE_TYPE_TRANSFORM);
+ add_relation(target_transform_key, constraint_op_key, cti->name);
}
else if ((ct->tar->type == OB_ARMATURE) && (ct->subtarget[0])) {
/* bone */
if (&ct->tar->id == id) {
/* same armature */
eDepsOperation_Code target_key_opcode;
-
- /* Using "done" here breaks in-chain deps, while using "ready" here breaks most production rigs instead...
- * So, we do a compromise here, and only do this when an IK chain conflict may occur
+ /* Using "done" here breaks in-chain deps, while using
+ * "ready" here breaks most production rigs instead.
+ * So, we do a compromise here, and only do this when an
+ * IK chain conflict may occur.
*/
- if (root_map->has_common_root(component_subdata, ct->subtarget)) {
+ if (root_map->has_common_root(component_subdata,
+ ct->subtarget))
+ {
target_key_opcode = DEG_OPCODE_BONE_READY;
}
else {
target_key_opcode = DEG_OPCODE_BONE_DONE;
}
-
- OperationKey target_key(&ct->tar->id, DEG_NODE_TYPE_BONE, ct->subtarget, target_key_opcode);
+ OperationKey target_key(&ct->tar->id,
+ DEG_NODE_TYPE_BONE,
+ ct->subtarget,
+ target_key_opcode);
add_relation(target_key, constraint_op_key, cti->name);
}
else {
- /* different armature - we can safely use the result of that */
- OperationKey target_key(&ct->tar->id, DEG_NODE_TYPE_BONE, ct->subtarget, DEG_OPCODE_BONE_DONE);
+ /* Different armature - we can safely use the result
+ * of that.
+ */
+ OperationKey target_key(&ct->tar->id,
+ DEG_NODE_TYPE_BONE,
+ ct->subtarget,
+ DEG_OPCODE_BONE_DONE);
add_relation(target_key, constraint_op_key, cti->name);
}
}
- else if (ELEM(ct->tar->type, OB_MESH, OB_LATTICE) && (ct->subtarget[0])) {
- /* vertex group */
- /* NOTE: for now, we don't need to represent vertex groups separately... */
+ else if (ELEM(ct->tar->type, OB_MESH, OB_LATTICE) &&
+ (ct->subtarget[0]))
+ {
+ /* Vertex group. */
+ /* NOTE: for now, we don't need to represent vertex groups
+ * separately.
+ */
ComponentKey target_key(&ct->tar->id, DEG_NODE_TYPE_GEOMETRY);
add_relation(target_key, constraint_op_key, cti->name);
-
if (ct->tar->type == OB_MESH) {
OperationDepsNode *node2 = find_operation_node(target_key);
if (node2 != NULL) {
@@ -783,37 +820,48 @@ void DepsgraphRelationBuilder::build_constraints(Scene *scene, ID *id, eDepsNode
/* Constraints which requires the target object surface. */
ComponentKey target_key(&ct->tar->id, DEG_NODE_TYPE_GEOMETRY);
add_relation(target_key, constraint_op_key, cti->name);
-
- /* NOTE: obdata eval now doesn't necessarily depend on the object's transform... */
- ComponentKey target_transform_key(&ct->tar->id, DEG_NODE_TYPE_TRANSFORM);
+ /* NOTE: obdata eval now doesn't necessarily depend on the
+ * object's transform.
+ */
+ ComponentKey target_transform_key(&ct->tar->id,
+ DEG_NODE_TYPE_TRANSFORM);
add_relation(target_transform_key, constraint_op_key, cti->name);
}
else {
- /* standard object relation */
+ /* Standard object relation. */
// TODO: loc vs rot vs scale?
if (&ct->tar->id == id) {
/* Constraint targetting own object:
- * - This case is fine IFF we're dealing with a bone constraint pointing to
- * its own armature. In that case, it's just transform -> bone.
- * - If however it is a real self targetting case, just make it depend on the
- * previous constraint (or the pre-constraint state)...
+ * - This case is fine IFF we're dealing with a bone
+ * constraint pointing to its own armature. In that
+ * case, it's just transform -> bone.
+ * - If however it is a real self targetting case, just
+ * make it depend on the previous constraint (or the
+ * pre-constraint state).
*/
- if ((ct->tar->type == OB_ARMATURE) && (component_type == DEG_NODE_TYPE_BONE)) {
- OperationKey target_key(&ct->tar->id, DEG_NODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_FINAL);
+ if ((ct->tar->type == OB_ARMATURE) &&
+ (component_type == DEG_NODE_TYPE_BONE))
+ {
+ OperationKey target_key(&ct->tar->id,
+ DEG_NODE_TYPE_TRANSFORM,
+ DEG_OPCODE_TRANSFORM_FINAL);
add_relation(target_key, constraint_op_key, cti->name);
}
else {
- OperationKey target_key(&ct->tar->id, DEG_NODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_LOCAL);
+ OperationKey target_key(&ct->tar->id,
+ DEG_NODE_TYPE_TRANSFORM,
+ DEG_OPCODE_TRANSFORM_LOCAL);
add_relation(target_key, constraint_op_key, cti->name);
}
}
else {
- /* normal object dependency */
- OperationKey target_key(&ct->tar->id, DEG_NODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_FINAL);
+ /* Normal object dependency. */
+ OperationKey target_key(&ct->tar->id,
+ DEG_NODE_TYPE_TRANSFORM,
+ DEG_OPCODE_TRANSFORM_FINAL);
add_relation(target_key, constraint_op_key, cti->name);
}
}
-
/* Constraints which needs world's matrix for transform.
* TODO(sergey): More constraints here?
*/
@@ -824,14 +872,14 @@ void DepsgraphRelationBuilder::build_constraints(Scene *scene, ID *id, eDepsNode
CONSTRAINT_TYPE_TRANSLIKE))
{
/* TODO(sergey): Add used space check. */
- ComponentKey target_transform_key(&ct->tar->id, DEG_NODE_TYPE_TRANSFORM);
+ ComponentKey target_transform_key(&ct->tar->id,
+ DEG_NODE_TYPE_TRANSFORM);
add_relation(target_transform_key, constraint_op_key, cti->name);
}
-
}
-
- if (cti->flush_constraint_targets)
+ if (cti->flush_constraint_targets) {
cti->flush_constraint_targets(con, &targets, 1);
+ }
}
}
}
@@ -929,32 +977,35 @@ void DepsgraphRelationBuilder::build_driver(ID *id, FCurve *fcu)
fcu->rna_path ? fcu->rna_path : "",
fcu->array_index);
bPoseChannel *pchan = NULL;
-
const char *rna_path = fcu->rna_path ? fcu->rna_path : "";
+ const ID_Type id_type = GS(id->name);
- /* create dependency between driver and data affected by it */
+ /* Create dependency between driver and data affected by it. */
/* - direct property relationship... */
//RNAPathKey affected_key(id, fcu->rna_path);
//add_relation(driver_key, affected_key, "[Driver -> Data] DepsRel");
- /* driver -> data components (for interleaved evaluation - bones/constraints/modifiers) */
- // XXX: this probably should probably be moved out into a separate function
+ /* Driver -> data components (for interleaved evaluation
+ * bones/constraints/modifiers).
+ */
+ // XXX: this probably should probably be moved out into a separate function.
if (strstr(rna_path, "pose.bones[") != NULL) {
/* interleaved drivers during bone eval */
- // TODO: ideally, if this is for a constraint, it goes to said constraint
+ /* TODO: ideally, if this is for a constraint, it goes to said
+ * constraint.
+ */
Object *ob = (Object *)id;
- char *bone_name;
-
- bone_name = BLI_str_quoted_substrN(rna_path, "pose.bones[");
+ char *bone_name = BLI_str_quoted_substrN(rna_path, "pose.bones[");
pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
-
- if (bone_name) {
+ if (bone_name != NULL) {
MEM_freeN(bone_name);
bone_name = NULL;
}
-
- if (pchan) {
- OperationKey bone_key(id, DEG_NODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_LOCAL);
+ if (pchan != NULL) {
+ OperationKey bone_key(id,
+ DEG_NODE_TYPE_BONE,
+ pchan->name,
+ DEG_OPCODE_BONE_LOCAL);
add_relation(driver_key, bone_key, "[Driver -> Bone]");
}
else {
@@ -963,31 +1014,36 @@ void DepsgraphRelationBuilder::build_driver(ID *id, FCurve *fcu)
rna_path);
}
}
- else if (GS(id->name) == ID_AR && strstr(rna_path, "bones[")) {
- /* drivers on armature-level bone settings (i.e. bbone stuff),
- * which will affect the evaluation of corresponding pose bones
+ else if (id_type == ID_AR && strstr(rna_path, "bones[")) {
+ /* Drivers on armature-level bone settings (i.e. bbone stuff),
+ * which will affect the evaluation of corresponding pose bones.
*/
IDDepsNode *arm_node = m_graph->find_id_node(id);
char *bone_name = BLI_str_quoted_substrN(rna_path, "bones[");
-
- if (arm_node && bone_name) {
- /* find objects which use this, and make their eval callbacks depend on this */
+ if (arm_node != NULL && bone_name != NULL) {
+ /* Find objects which use this, and make their eval callbacks
+ * depend on this.
+ */
foreach (DepsRelation *rel, arm_node->outlinks) {
IDDepsNode *to_node = (IDDepsNode *)rel->to;
-
- /* we only care about objects with pose data which use this... */
+ /* We only care about objects with pose data which use this. */
if (GS(to_node->id_orig->name) == ID_OB) {
Object *ob = (Object *)to_node->id_orig;
- bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, bone_name); // NOTE: ob->pose may be NULL
-
- if (pchan) {
- OperationKey bone_key(&ob->id, DEG_NODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_LOCAL);
- add_relation(driver_key, bone_key, "[Arm Bone -> Driver -> Bone]");
+ // NOTE: ob->pose may be NULL
+ bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose,
+ bone_name);
+ if (pchan != NULL) {
+ OperationKey bone_key(&ob->id,
+ DEG_NODE_TYPE_BONE,
+ pchan->name,
+ DEG_OPCODE_BONE_LOCAL);
+ add_relation(driver_key,
+ bone_key,
+ "[Arm Bone -> Driver -> Bone]");
}
}
}
-
- /* free temp data */
+ /* Free temp data. */
MEM_freeN(bone_name);
bone_name = NULL;
}
@@ -997,8 +1053,10 @@ void DepsgraphRelationBuilder::build_driver(ID *id, FCurve *fcu)
rna_path);
}
}
- else if (GS(id->name) == ID_OB && strstr(rna_path, "modifiers[")) {
- OperationKey modifier_key(id, DEG_NODE_TYPE_GEOMETRY, DEG_OPCODE_GEOMETRY_UBEREVAL);
+ else if (id_type == ID_OB && strstr(rna_path, "modifiers[")) {
+ OperationKey modifier_key(id,
+ DEG_NODE_TYPE_GEOMETRY,
+ DEG_OPCODE_GEOMETRY_UBEREVAL);
if (has_node(modifier_key)) {
add_relation(driver_key, modifier_key, "[Driver -> Modifier]");
}
@@ -1006,11 +1064,10 @@ void DepsgraphRelationBuilder::build_driver(ID *id, FCurve *fcu)
printf("Unexisting driver RNA path: %s\n", rna_path);
}
}
- else if (GS(id->name) == ID_KE && strstr(rna_path, "key_blocks[")) {
- /* shape key driver - hook into the base geometry operation */
+ else if (id_type == ID_KE && strstr(rna_path, "key_blocks[")) {
+ /* Shape key driver - hook into the base geometry operation. */
// XXX: double check where this points
Key *shape_key = (Key *)id;
-
ComponentKey geometry_key(shape_key->from, DEG_NODE_TYPE_GEOMETRY);
add_relation(driver_key, geometry_key, "[Driver -> ShapeKey Geom]");
}
@@ -1019,35 +1076,62 @@ void DepsgraphRelationBuilder::build_driver(ID *id, FCurve *fcu)
add_relation(driver_key, geometry_key, "[Driver -> ShapeKey Geom]");
}
else {
- if (GS(id->name) == ID_OB) {
- /* assume that driver affects a transform... */
- OperationKey local_transform_key(id, DEG_NODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_LOCAL);
- add_relation(driver_key, local_transform_key, "[Driver -> Transform]");
- }
- else if (GS(id->name) == ID_KE) {
- ComponentKey geometry_key(id, DEG_NODE_TYPE_GEOMETRY);
- add_relation(driver_key, geometry_key, "[Driver -> Shapekey Geometry]");
+ switch (id_type) {
+ case ID_OB:
+ {
+ /* Assume that driver affects a transform. */
+ OperationKey local_transform_key(id,
+ DEG_NODE_TYPE_TRANSFORM,
+ DEG_OPCODE_TRANSFORM_LOCAL);
+ add_relation(driver_key,
+ local_transform_key,
+ "[Driver -> Transform]");
+ break;
+ }
+ case ID_KE:
+ {
+ ComponentKey geometry_key(id, DEG_NODE_TYPE_GEOMETRY);
+ add_relation(driver_key,
+ geometry_key,
+ "[Driver -> Shapekey Geometry]");
+ break;
+ }
+ case ID_NT:
+ {
+ ComponentKey ntree_key(id, DEG_NODE_TYPE_SHADING);
+ add_relation(driver_key,
+ ntree_key,
+ "[Driver -> NTree Shading Update]");
+ break;
+ }
+ default:
+ break;
}
}
-
- /* ensure that affected prop's update callbacks will be triggered once done */
- // TODO: implement this once the functionality to add these links exists in RNA
- // XXX: the data itself could also set this, if it were to be truly initialised later?
-
- /* loop over variables to get the target relationships */
+ /* Ensure that affected prop's update callbacks will be triggered once
+ * done.
+ */
+ /* TODO: Implement this once the functionality to add these links exists
+ * RNA.
+ */
+ /* XXX: the data itself could also set this, if it were to be truly
+ * initialised later?
+ */
+ /* Loop over variables to get the target relationships. */
LINKLIST_FOREACH (DriverVar *, dvar, &driver->variables) {
- /* only used targets */
+ /* Only used targets. */
DRIVER_TARGETS_USED_LOOPER(dvar)
{
- if (dtar->id == NULL)
+ if (dtar->id == NULL) {
continue;
-
- /* special handling for directly-named bones */
+ }
+ /* Special handling for directly-named bones. */
if ((dtar->flag & DTAR_FLAG_STRUCT_REF) && (dtar->pchan_name[0])) {
Object *ob = (Object *)dtar->id;
- bPoseChannel *target_pchan = BKE_pose_channel_find_name(ob->pose, dtar->pchan_name);
+ bPoseChannel *target_pchan =
+ BKE_pose_channel_find_name(ob->pose, dtar->pchan_name);
if (target_pchan != NULL) {
- /* get node associated with bone */
+ /* Get node associated with bone. */
// XXX: watch the space!
/* Some cases can't use final bone transform, for example:
* - Driving the bone with itself (addressed here)
@@ -1059,55 +1143,75 @@ void DepsgraphRelationBuilder::build_driver(ID *id, FCurve *fcu)
{
continue;
}
- OperationKey target_key(dtar->id, DEG_NODE_TYPE_BONE, target_pchan->name, DEG_OPCODE_BONE_DONE);
- add_relation(target_key, driver_key, "[Bone Target -> Driver]");
+ OperationKey target_key(dtar->id,
+ DEG_NODE_TYPE_BONE,
+ target_pchan->name,
+ DEG_OPCODE_BONE_DONE);
+ add_relation(target_key,
+ driver_key,
+ "[Bone Target -> Driver]");
}
}
else if (dtar->flag & DTAR_FLAG_STRUCT_REF) {
- /* get node associated with the object's transforms */
- OperationKey target_key(dtar->id, DEG_NODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_FINAL);
+ /* Get node associated with the object's transforms. */
+ if (dtar->id == id) {
+ /* Ignore input dependency if we're driving properties of
+ * the same ID, otherwise we'll be ending up in a cyclic
+ * dependency here.
+ */
+ continue;
+ }
+ OperationKey target_key(dtar->id,
+ DEG_NODE_TYPE_TRANSFORM,
+ DEG_OPCODE_TRANSFORM_FINAL);
add_relation(target_key, driver_key, "[Target -> Driver]");
}
else if (dtar->rna_path && strstr(dtar->rna_path, "pose.bones[")) {
- /* workaround for ensuring that local bone transforms don't end up
- * having to wait for pose eval to finish (to prevent cycles)
+ /* Workaround for ensuring that local bone transforms don't end
+ * up having to wait for pose eval to finish (to prevent cycles).
*/
Object *ob = (Object *)dtar->id;
- char *bone_name = BLI_str_quoted_substrN(dtar->rna_path, "pose.bones[");
- bPoseChannel *target_pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
- if (bone_name) {
+ char *bone_name = BLI_str_quoted_substrN(dtar->rna_path,
+ "pose.bones[");
+ bPoseChannel *target_pchan =
+ BKE_pose_channel_find_name(ob->pose, bone_name);
+ if (bone_name != NULL) {
MEM_freeN(bone_name);
bone_name = NULL;
}
- if (target_pchan) {
+ if (target_pchan != NULL) {
if (dtar->id == id &&
pchan != NULL &&
STREQ(pchan->name, target_pchan->name))
{
continue;
}
- OperationKey bone_key(dtar->id, DEG_NODE_TYPE_BONE, target_pchan->name, DEG_OPCODE_BONE_LOCAL);
+ OperationKey bone_key(dtar->id,
+ DEG_NODE_TYPE_BONE,
+ target_pchan->name,
+ DEG_OPCODE_BONE_LOCAL);
add_relation(bone_key, driver_key, "[RNA Bone -> Driver]");
}
}
else {
if (dtar->id == id) {
- /* Ignore input dependency if we're driving properties of the same ID,
- * otherwise we'll be ending up in a cyclic dependency here.
+ /* Ignore input dependency if we're driving properties of
+ * the same ID, otherwise we'll be ending up in a cyclic
+ * dependency here.
*/
continue;
}
- /* resolve path to get node */
- RNAPathKey target_key(dtar->id, dtar->rna_path ? dtar->rna_path : "");
+ /* Resolve path to get node. */
+ RNAPathKey target_key(dtar->id,
+ dtar->rna_path ? dtar->rna_path : "");
add_relation(target_key, driver_key, "[RNA Target -> Driver]");
}
}
DRIVER_TARGETS_LOOPER_END
}
-
- /* It's quite tricky to detect if the driver actually depends on time or not,
- * so for now we'll be quite conservative here about optimization and consider
- * all python drivers to be depending on time.
+ /* It's quite tricky to detect if the driver actually depends on time or
+ * not, so for now we'll be quite conservative here about optimization and
+ * consider all python drivers to be depending on time.
*/
if ((driver->type == DRIVER_TYPE_PYTHON) &&
python_driver_depends_on_time(driver))
@@ -1135,9 +1239,9 @@ void DepsgraphRelationBuilder::build_world(World *world)
/* world's nodetree */
if (world->nodetree != NULL) {
build_nodetree(world->nodetree);
- ComponentKey ntree_key(&world->nodetree->id, DEG_NODE_TYPE_PARAMETERS);
- ComponentKey world_key(world_id, DEG_NODE_TYPE_PARAMETERS);
- add_relation(ntree_key, world_key, "NTree->World Parameters");
+ ComponentKey ntree_key(&world->nodetree->id, DEG_NODE_TYPE_SHADING);
+ ComponentKey world_key(world_id, DEG_NODE_TYPE_SHADING);
+ add_relation(ntree_key, world_key, "NTree->World Shading Update");
}
}
@@ -1173,7 +1277,7 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene)
* XXX: there's probably a difference between passive and active
* - passive don't change, so may need to know full transform...
*/
- OperationKey rbo_key(&ob->id, DEG_NODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_RIGIDBODY);
+ OperationKey rbo_key(&ob->id, DEG_NODE_TYPE_TRANSFORM, DEG_OPCODE_RIGIDBODY_TRANSFORM_COPY);
eDepsOperation_Code trans_opcode = ob->parent ? DEG_OPCODE_TRANSFORM_PARENT : DEG_OPCODE_TRANSFORM_LOCAL;
OperationKey trans_op(&ob->id, DEG_NODE_TYPE_TRANSFORM, trans_opcode);
@@ -1202,7 +1306,7 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene)
*/
OperationKey uber_key(&ob->id,
DEG_NODE_TYPE_TRANSFORM,
- DEG_OPCODE_OBJECT_UBEREVAL);
+ DEG_OPCODE_TRANSFORM_OBJECT_UBEREVAL);
add_relation(rbo_key, uber_key, "RBO Sync -> Uber (Temp)");
}
@@ -1225,8 +1329,8 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene)
* constraint affects the physics sim for these objects
*/
ComponentKey trans_key(&ob->id, DEG_NODE_TYPE_TRANSFORM);
- OperationKey ob1_key(&rbc->ob1->id, DEG_NODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_RIGIDBODY);
- OperationKey ob2_key(&rbc->ob2->id, DEG_NODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_RIGIDBODY);
+ OperationKey ob1_key(&rbc->ob1->id, DEG_NODE_TYPE_TRANSFORM, DEG_OPCODE_RIGIDBODY_TRANSFORM_COPY);
+ OperationKey ob2_key(&rbc->ob2->id, DEG_NODE_TYPE_TRANSFORM, DEG_OPCODE_RIGIDBODY_TRANSFORM_COPY);
/* - constrained-objects sync depends on the constraint-holder */
add_relation(trans_key, ob1_key, "RigidBodyConstraint -> RBC.Object_1");
@@ -1244,25 +1348,53 @@ void DepsgraphRelationBuilder::build_particles(Scene *scene, Object *ob)
OperationKey obdata_ubereval_key(&ob->id,
DEG_NODE_TYPE_GEOMETRY,
DEG_OPCODE_GEOMETRY_UBEREVAL);
+ OperationKey eval_init_key(&ob->id,
+ DEG_NODE_TYPE_EVAL_PARTICLES,
+ DEG_OPCODE_PARTICLE_SYSTEM_EVAL_INIT);
+ /* TODO(sergey): Are all particle systems depends on time?
+ * Hair without dynamics i.e.
+ */
+ add_relation(time_src_key, eval_init_key, "TimeSrc -> PSys");
/* particle systems */
LINKLIST_FOREACH (ParticleSystem *, psys, &ob->particlesystem) {
ParticleSettings *part = psys->part;
- /* particle settings */
- build_animdata(&part->id);
-
- /* this particle system */
- OperationKey psys_key(&ob->id, DEG_NODE_TYPE_EVAL_PARTICLES, DEG_OPCODE_PSYS_EVAL, psys->name);
+ /* Build particle settings relations.
+ *
+ * NOTE: The call itself ensures settings are only build once.
+ */
+ build_particle_settings(part);
+
+ /* This particle system. */
+ OperationKey psys_key(&ob->id,
+ DEG_NODE_TYPE_EVAL_PARTICLES,
+ DEG_OPCODE_PARTICLE_SYSTEM_EVAL,
+ psys->name);
+
+ /* Update particle system when settings changes. */
+ OperationKey particle_settings_key(&part->id,
+ DEG_NODE_TYPE_PARAMETERS,
+ DEG_OPCODE_PARTICLE_SETTINGS_EVAL);
+ OperationKey particle_settings_recalc_clear_key(
+ &part->id,
+ DEG_NODE_TYPE_PARAMETERS,
+ DEG_OPCODE_PARTICLE_SETTINGS_RECALC_CLEAR);
+ OperationKey psys_settings_key(&ob->id,
+ DEG_NODE_TYPE_EVAL_PARTICLES,
+ DEG_OPCODE_PARTICLE_SETTINGS_EVAL,
+ psys->name);
+ add_relation(particle_settings_key, psys_settings_key, "Particle Settings Change");
+ add_relation(psys_settings_key, psys_key, "Particle Settings Update");
+ add_relation(psys_key,
+ particle_settings_recalc_clear_key,
+ "Particle Settings Recalc Clear");
/* XXX: if particle system is later re-enabled, we must do full rebuild? */
if (!psys_check_enabled(ob, psys, G.is_rendering))
continue;
- /* TODO(sergey): Are all particle systems depends on time?
- * Hair without dynamics i.e.
- */
- add_relation(time_src_key, psys_key, "TimeSrc -> PSys");
+ add_relation(eval_init_key, psys_key, "Init -> PSys");
/* TODO(sergey): Currently particle update is just a placeholder,
* hook it to the ubereval node so particle system is getting updated
@@ -1272,14 +1404,33 @@ void DepsgraphRelationBuilder::build_particles(Scene *scene, Object *ob)
/* collisions */
if (part->type != PART_HAIR) {
- add_collision_relations(psys_key, scene, ob, part->collision_group, true, "Particle Collision");
+ add_collision_relations(psys_key,
+ scene,
+ ob,
+ part->collision_group,
+ true,
+ "Particle Collision");
}
- else if ((psys->flag & PSYS_HAIR_DYNAMICS) && psys->clmd && psys->clmd->coll_parms) {
- add_collision_relations(psys_key, scene, ob, psys->clmd->coll_parms->group, true, "Hair Collision");
+ else if ((psys->flag & PSYS_HAIR_DYNAMICS) &&
+ psys->clmd != NULL &&
+ psys->clmd->coll_parms != NULL)
+ {
+ add_collision_relations(psys_key,
+ scene,
+ ob,
+ psys->clmd->coll_parms->group,
+ true,
+ "Hair Collision");
}
/* effectors */
- add_forcefield_relations(psys_key, scene, ob, psys, part->effector_weights, part->type == PART_HAIR, "Particle Field");
+ add_forcefield_relations(psys_key,
+ scene,
+ ob,
+ psys,
+ part->effector_weights,
+ part->type == PART_HAIR,
+ "Particle Field");
/* boids */
if (part->boids) {
@@ -1314,8 +1465,27 @@ void DepsgraphRelationBuilder::build_particles(Scene *scene, Object *ob)
ComponentKey transform_key(&ob->id, DEG_NODE_TYPE_TRANSFORM);
add_relation(transform_key, obdata_ubereval_key, "Partcile Eval");
- /* pointcache */
- // TODO...
+ /* TODO(sergey): Do we need a point cache operations here? */
+}
+
+void DepsgraphRelationBuilder::build_particle_settings(ParticleSettings *part)
+{
+ ID *part_id = &part->id;
+ if (part_id->tag & LIB_TAG_DOIT) {
+ return;
+ }
+ part_id->tag |= LIB_TAG_DOIT;
+
+ /* Animation data relations. */
+ build_animdata(&part->id);
+
+ OperationKey eval_key(part_id,
+ DEG_NODE_TYPE_PARAMETERS,
+ DEG_OPCODE_PARTICLE_SETTINGS_EVAL);
+ OperationKey recalc_clear_key(part_id,
+ DEG_NODE_TYPE_PARAMETERS,
+ DEG_OPCODE_PARTICLE_SETTINGS_RECALC_CLEAR);
+ add_relation(eval_key, recalc_clear_key, "Particle Settings Clear Recalc");
}
void DepsgraphRelationBuilder::build_cloth(Scene * /*scene*/,
@@ -1448,6 +1618,14 @@ void DepsgraphRelationBuilder::build_obdata_geom(Main *bmain, Scene *scene, Obje
Material *ma = give_current_material(ob, a);
if (ma != NULL) {
build_material(ma);
+
+ if (ob->type == OB_MESH) {
+ OperationKey material_key(&ma->id,
+ DEG_NODE_TYPE_SHADING,
+ DEG_OPCODE_MATERIAL_UPDATE);
+ OperationKey shading_key(&ob->id, DEG_NODE_TYPE_SHADING, DEG_OPCODE_SHADING);
+ add_relation(material_key, shading_key, "Material Update");
+ }
}
}
}
@@ -1480,6 +1658,19 @@ void DepsgraphRelationBuilder::build_obdata_geom(Main *bmain, Scene *scene, Obje
/* type-specific node/links */
switch (ob->type) {
case OB_MESH:
+ /* NOTE: This is compatibility code to support particle systems
+ *
+ * for viewport being properly rendered in final render mode.
+ * This relation is similar to what dag_object_time_update_flags()
+ * was doing for mesh objects with particle system/
+ *
+ * Ideally we need to get rid of this relation.
+ */
+ if (ob->particlesystem.first != NULL) {
+ TimeSourceKey time_key;
+ OperationKey obdata_ubereval_key(&ob->id, DEG_NODE_TYPE_GEOMETRY, DEG_OPCODE_GEOMETRY_UBEREVAL);
+ add_relation(time_key, obdata_ubereval_key, "Legacy particle time");
+ }
break;
case OB_MBALL:
@@ -1563,18 +1754,21 @@ void DepsgraphRelationBuilder::build_camera(Object *ob)
}
camera_id->tag |= LIB_TAG_DOIT;
- ComponentKey parameters_key(camera_id, DEG_NODE_TYPE_PARAMETERS);
+ ComponentKey object_parameters_key(&ob->id, DEG_NODE_TYPE_PARAMETERS);
+ ComponentKey camera_parameters_key(camera_id, DEG_NODE_TYPE_PARAMETERS);
+
+ add_relation(camera_parameters_key, object_parameters_key,
+ "Camera -> Object");
if (needs_animdata_node(camera_id)) {
ComponentKey animation_key(camera_id, DEG_NODE_TYPE_ANIMATION);
- add_relation(animation_key, parameters_key, "Camera Parameters");
+ add_relation(animation_key, camera_parameters_key, "Camera Parameters");
}
/* DOF */
- if (cam->dof_ob) {
- ComponentKey ob_param_key(&ob->id, DEG_NODE_TYPE_PARAMETERS);
+ if (cam->dof_ob != NULL) {
ComponentKey dof_ob_key(&cam->dof_ob->id, DEG_NODE_TYPE_TRANSFORM);
- add_relation(dof_ob_key, ob_param_key, "Camera DOF");
+ add_relation(dof_ob_key, object_parameters_key, "Camera DOF");
}
}
@@ -1588,38 +1782,49 @@ void DepsgraphRelationBuilder::build_lamp(Object *ob)
}
lamp_id->tag |= LIB_TAG_DOIT;
- ComponentKey parameters_key(lamp_id, DEG_NODE_TYPE_PARAMETERS);
+ ComponentKey object_parameters_key(&ob->id, DEG_NODE_TYPE_PARAMETERS);
+ ComponentKey lamp_parameters_key(lamp_id, DEG_NODE_TYPE_PARAMETERS);
+
+ add_relation(lamp_parameters_key, object_parameters_key,
+ "Lamp -> Object");
if (needs_animdata_node(lamp_id)) {
ComponentKey animation_key(lamp_id, DEG_NODE_TYPE_ANIMATION);
- add_relation(animation_key, parameters_key, "Lamp Parameters");
+ add_relation(animation_key, lamp_parameters_key, "Lamp Parameters");
}
/* lamp's nodetree */
if (la->nodetree) {
build_nodetree(la->nodetree);
- ComponentKey nodetree_key(&la->nodetree->id, DEG_NODE_TYPE_PARAMETERS);
- add_relation(nodetree_key, parameters_key, "NTree->Lamp Parameters");
+ ComponentKey nodetree_key(&la->nodetree->id, DEG_NODE_TYPE_SHADING);
+ add_relation(nodetree_key, lamp_parameters_key, "NTree->Lamp Parameters");
}
/* textures */
build_texture_stack(la->mtex);
+
+#ifdef WITH_COPY_ON_WRITE
+ /* Make sure copy on write of lamp data is always properly updated for
+ * visible lamps.
+ */
+ OperationKey ob_copy_on_write_key(&ob->id,
+ DEG_NODE_TYPE_COPY_ON_WRITE,
+ DEG_OPCODE_COPY_ON_WRITE);
+ OperationKey lamp_copy_on_write_key(lamp_id,
+ DEG_NODE_TYPE_COPY_ON_WRITE,
+ DEG_OPCODE_COPY_ON_WRITE);
+ add_relation(lamp_copy_on_write_key, ob_copy_on_write_key, "Eval Order");
+#endif
}
void DepsgraphRelationBuilder::build_nodetree(bNodeTree *ntree)
{
- if (!ntree)
+ if (ntree == NULL) {
return;
-
+ }
ID *ntree_id = &ntree->id;
-
build_animdata(ntree_id);
-
- OperationKey parameters_key(ntree_id,
- DEG_NODE_TYPE_PARAMETERS,
- DEG_OPCODE_PLACEHOLDER,
- "Parameters Eval");
-
+ ComponentKey shading_key(ntree_id, DEG_NODE_TYPE_SHADING);
/* nodetree's nodes... */
LINKLIST_FOREACH (bNode *, bnode, &ntree->nodes) {
if (bnode->id) {
@@ -1635,19 +1840,25 @@ void DepsgraphRelationBuilder::build_nodetree(bNodeTree *ntree)
build_nodetree(group_ntree);
group_ntree->id.tag |= LIB_TAG_DOIT;
}
- OperationKey group_parameters_key(&group_ntree->id,
- DEG_NODE_TYPE_PARAMETERS,
- DEG_OPCODE_PLACEHOLDER,
- "Parameters Eval");
- add_relation(group_parameters_key, parameters_key, "Group Node");
+ ComponentKey group_shading_key(&group_ntree->id,
+ DEG_NODE_TYPE_SHADING);
+ add_relation(group_shading_key, shading_key, "Group Node");
}
}
}
if (needs_animdata_node(ntree_id)) {
ComponentKey animation_key(ntree_id, DEG_NODE_TYPE_ANIMATION);
- add_relation(animation_key, parameters_key, "NTree Parameters");
+ add_relation(animation_key, shading_key, "NTree Parameters");
}
+
+ OperationKey shading_update_key(ntree_id,
+ DEG_NODE_TYPE_SHADING,
+ DEG_OPCODE_MATERIAL_UPDATE);
+ OperationKey shading_parameters_key(ntree_id,
+ DEG_NODE_TYPE_SHADING_PARAMETERS,
+ DEG_OPCODE_MATERIAL_UPDATE);
+ add_relation(shading_parameters_key, shading_update_key, "NTree Shading Parameters");
}
/* Recursively build graph for material */
@@ -1669,13 +1880,11 @@ void DepsgraphRelationBuilder::build_material(Material *ma)
if (ma->nodetree != NULL) {
build_nodetree(ma->nodetree);
OperationKey ntree_key(&ma->nodetree->id,
- DEG_NODE_TYPE_PARAMETERS,
- DEG_OPCODE_PLACEHOLDER,
- "Parameters Eval");
+ DEG_NODE_TYPE_SHADING,
+ DEG_OPCODE_MATERIAL_UPDATE);
OperationKey material_key(&ma->id,
DEG_NODE_TYPE_SHADING,
- DEG_OPCODE_PLACEHOLDER,
- "Material Update");
+ DEG_OPCODE_MATERIAL_UPDATE);
add_relation(ntree_key, material_key, "Material's NTree");
}
}
@@ -1739,8 +1948,18 @@ void DepsgraphRelationBuilder::build_cachefile(CacheFile *cache_file) {
void DepsgraphRelationBuilder::build_mask(Mask *mask)
{
- /* Animation. */
- build_animdata(&mask->id);
+ ID *mask_id = &mask->id;
+ /* F-Curve animation. */
+ build_animdata(mask_id);
+ /* Own mask animation. */
+ OperationKey mask_animation_key(mask_id,
+ DEG_NODE_TYPE_ANIMATION,
+ DEG_OPCODE_MASK_ANIMATION);
+ TimeSourceKey time_src_key;
+ add_relation(time_src_key, mask_animation_key, "TimeSrc -> Mask Animation");
+ /* Final mask evaluation. */
+ ComponentKey parameters_key(mask_id, DEG_NODE_TYPE_PARAMETERS);
+ add_relation(mask_animation_key, parameters_key, "Mask Animation -> Mask Eval");
}
void DepsgraphRelationBuilder::build_movieclip(MovieClip *clip)
@@ -1788,7 +2007,7 @@ void DepsgraphRelationBuilder::build_copy_on_write_relations(IDDepsNode *id_node
DEG_NODE_TYPE_COPY_ON_WRITE,
DEG_OPCODE_COPY_ON_WRITE);
/* XXX: This is a quick hack to make Alt-A to work. */
- add_relation(time_source_key, copy_on_write_key, "Fluxgate capacitor hack");
+ // add_relation(time_source_key, copy_on_write_key, "Fluxgate capacitor hack");
/* Resat of code is using rather low level trickery, so need to get some
* explicit pointers.
*/
@@ -1801,6 +2020,10 @@ void DepsgraphRelationBuilder::build_copy_on_write_relations(IDDepsNode *id_node
/* Copy-on-write component never depends on itself. */
continue;
}
+ if (!comp_node->depends_on_cow()) {
+ /* Component explicitly requests to not add relation. */
+ continue;
+ }
/* All entry operations of each component should wait for a proper
* copy of ID.
*/
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
index 8a53bf4a6bf..e8bdc662bd6 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
@@ -70,6 +70,7 @@ struct Tex;
struct World;
struct EffectorWeights;
struct ParticleSystem;
+struct ParticleSettings;
struct PropertyRNA;
@@ -199,6 +200,7 @@ struct DepsgraphRelationBuilder
void build_world(World *world);
void build_rigidbody(Scene *scene);
void build_particles(Scene *scene, Object *ob);
+ void build_particle_settings(ParticleSettings *part);
void build_cloth(Scene *scene, Object *object, ModifierData *md);
void build_ik_pose(Object *ob,
bPoseChannel *pchan,
@@ -208,7 +210,7 @@ struct DepsgraphRelationBuilder
bPoseChannel *pchan,
bConstraint *con,
RootPChanMap *root_map);
- void build_rig(Scene *scene, Object *ob);
+ void build_rig(Main *bmain, Scene *scene, Object *ob);
void build_proxy_rig(Object *ob);
void build_shapekeys(ID *obdata, Key *key);
void build_obdata_geom(Main *bmain, Scene *scene, Object *ob);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_layer.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_layer.cc
index a6c9fdfc6bc..1e57a98d6f7 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_layer.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_layer.cc
@@ -24,7 +24,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/depsgraph/intern/builder/deg_builder_relations_scene.cc
+/** \file blender/depsgraph/intern/builder/deg_builder_relations_layer.cc
* \ingroup depsgraph
*
* Methods for constructing depsgraph
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
index be666165a0b..88477e512d1 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
@@ -83,7 +83,15 @@ void DepsgraphRelationBuilder::build_ik_pose(Object *ob,
* - see notes on direction of rel below...
*/
bPoseChannel *rootchan = BKE_armature_ik_solver_find_root(pchan, data);
- OperationKey solver_key(&ob->id, DEG_NODE_TYPE_EVAL_POSE, rootchan->name, DEG_OPCODE_POSE_IK_SOLVER);
+ OperationKey pchan_local_key(&ob->id, DEG_NODE_TYPE_BONE,
+ pchan->name, DEG_OPCODE_BONE_LOCAL);
+ OperationKey init_ik_key(&ob->id, DEG_NODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_INIT_IK);
+ OperationKey solver_key(&ob->id, DEG_NODE_TYPE_EVAL_POSE,
+ rootchan->name,
+ DEG_OPCODE_POSE_IK_SOLVER);
+
+ add_relation(pchan_local_key, init_ik_key, "IK Constraint -> Init IK Tree");
+ add_relation(init_ik_key, solver_key, "Init IK -> IK Solver");
/* IK target */
// XXX: this should get handled as part of the constraint code
@@ -291,7 +299,7 @@ void DepsgraphRelationBuilder::build_splineik_pose(Object *ob,
}
/* Pose/Armature Bones Graph */
-void DepsgraphRelationBuilder::build_rig(Scene *scene, Object *ob)
+void DepsgraphRelationBuilder::build_rig(Main *bmain, Scene *scene, Object *ob)
{
/* Armature-Data */
bArmature *arm = (bArmature *)ob->data;
@@ -300,9 +308,11 @@ void DepsgraphRelationBuilder::build_rig(Scene *scene, Object *ob)
/* attach links between pose operations */
OperationKey init_key(&ob->id, DEG_NODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_INIT);
+ OperationKey init_ik_key(&ob->id, DEG_NODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_INIT_IK);
OperationKey flush_key(&ob->id, DEG_NODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_DONE);
- add_relation(init_key, flush_key, "[Pose Init -> Pose Cleanup]");
+ add_relation(init_key, init_ik_key, "Pose Init -> Pose Init IK");
+ add_relation(init_ik_key, flush_key, "Pose Init IK -> Pose Cleanup");
/* Make sure pose is up-to-date with armature updates. */
OperationKey armature_key(&arm->id,
@@ -379,16 +389,12 @@ void DepsgraphRelationBuilder::build_rig(Scene *scene, Object *ob)
OperationKey bone_pose_key(&ob->id, DEG_NODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_POSE_PARENT);
OperationKey bone_ready_key(&ob->id, DEG_NODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_READY);
OperationKey bone_done_key(&ob->id, DEG_NODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_DONE);
-
pchan->flag &= ~POSE_DONE;
-
- /* pose init to bone local */
+ /* Pose init to bone local. */
add_relation(init_key, bone_local_key, "PoseEval Source-Bone Link");
-
- /* local to pose parenting operation */
+ /* Local to pose parenting operation. */
add_relation(bone_local_key, bone_pose_key, "Bone Local - PoseSpace Link");
-
- /* parent relation */
+ /* Parent relation. */
if (pchan->parent != NULL) {
eDepsOperation_Code parent_key_opcode;
@@ -403,8 +409,7 @@ void DepsgraphRelationBuilder::build_rig(Scene *scene, Object *ob)
OperationKey parent_key(&ob->id, DEG_NODE_TYPE_BONE, pchan->parent->name, parent_key_opcode);
add_relation(parent_key, bone_pose_key, "[Parent Bone -> Child Bone]");
}
-
- /* constraints */
+ /* Buil constraints. */
if (pchan->constraints.first != NULL) {
/* constraints stack and constraint dependencies */
build_constraints(scene, &ob->id, DEG_NODE_TYPE_BONE, pchan->name, &pchan->constraints, &root_map);
@@ -431,6 +436,10 @@ void DepsgraphRelationBuilder::build_rig(Scene *scene, Object *ob)
/* assume that all bones must be done for the pose to be ready (for deformers) */
add_relation(bone_done_key, flush_key, "PoseEval Result-Bone Link");
+ /* Custom shape. */
+ if (pchan->custom != NULL) {
+ build_object(bmain, scene, pchan->custom);
+ }
}
}
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc
index 43204d5fe98..deed46339bb 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc
@@ -75,6 +75,7 @@ void DepsgraphRelationBuilder::build_scene(Main *bmain, Scene *scene)
}
/* XXX store scene to access from DAG_get_scene */
+ m_graph->bmain = bmain;
m_graph->scene = scene;
/* scene objects */
@@ -83,6 +84,9 @@ void DepsgraphRelationBuilder::build_scene(Main *bmain, Scene *scene)
build_object(bmain, scene, base->object);
}
}
+ if (scene->camera != NULL) {
+ build_object(bmain, scene, scene->camera);
+ }
/* rigidbody */
if (scene->rigidbody_world) {
diff --git a/source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc b/source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc
index 66b63f861ee..ce3a4182a0f 100644
--- a/source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc
+++ b/source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc
@@ -88,9 +88,10 @@ static const int deg_debug_node_type_color_map[][2] = {
{DEG_NODE_TYPE_GEOMETRY, 6},
{DEG_NODE_TYPE_SEQUENCER, 7},
{DEG_NODE_TYPE_SHADING, 8},
- {DEG_NODE_TYPE_CACHE, 9},
- {DEG_NODE_TYPE_LAYER_COLLECTIONS, 10},
- {DEG_NODE_TYPE_COPY_ON_WRITE, 11},
+ {DEG_NODE_TYPE_SHADING_PARAMETERS, 9},
+ {DEG_NODE_TYPE_CACHE, 10},
+ {DEG_NODE_TYPE_LAYER_COLLECTIONS, 11},
+ {DEG_NODE_TYPE_COPY_ON_WRITE, 12},
{-1, 0}
};
#endif
@@ -377,6 +378,7 @@ static void deg_debug_graphviz_node(const DebugContext &ctx,
case DEG_NODE_TYPE_EVAL_POSE:
case DEG_NODE_TYPE_BONE:
case DEG_NODE_TYPE_SHADING:
+ case DEG_NODE_TYPE_SHADING_PARAMETERS:
case DEG_NODE_TYPE_CACHE:
case DEG_NODE_TYPE_LAYER_COLLECTIONS:
case DEG_NODE_TYPE_EVAL_PARTICLES:
@@ -395,7 +397,9 @@ static void deg_debug_graphviz_node(const DebugContext &ctx,
}
break;
}
- default:
+ case DEG_NODE_TYPE_UNDEFINED:
+ case DEG_NODE_TYPE_TIMESOURCE:
+ case DEG_NODE_TYPE_OPERATION:
deg_debug_graphviz_node_single(ctx, node);
break;
}
diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc
index dc3174751bd..81a4f2bc0cc 100644
--- a/source/blender/depsgraph/intern/depsgraph.cc
+++ b/source/blender/depsgraph/intern/depsgraph.cc
@@ -53,6 +53,8 @@ extern "C" {
#include "DEG_depsgraph.h"
+#include "intern/eval/deg_eval_copy_on_write.h"
+
#include "intern/nodes/deg_node.h"
#include "intern/nodes/deg_node_component.h"
#include "intern/nodes/deg_node_operation.h"
@@ -250,11 +252,13 @@ DepsNode *Depsgraph::find_node_from_pointer(const PointerRNA *ptr,
/* Node Management ---------------------------- */
+#ifndef WITH_COPY_ON_WRITE
static void id_node_deleter(void *value)
{
IDDepsNode *id_node = reinterpret_cast<IDDepsNode *>(value);
OBJECT_GUARDED_DELETE(id_node, IDDepsNode);
}
+#endif
TimeSourceDepsNode *Depsgraph::add_time_source()
{
@@ -275,13 +279,17 @@ IDDepsNode *Depsgraph::find_id_node(const ID *id) const
return reinterpret_cast<IDDepsNode *>(BLI_ghash_lookup(id_hash, id));
}
-IDDepsNode *Depsgraph::add_id_node(ID *id, const char *name)
+IDDepsNode *Depsgraph::add_id_node(ID *id, bool do_tag, ID *id_cow_hint)
{
+ BLI_assert((id->tag & LIB_TAG_COPY_ON_WRITE) == 0);
IDDepsNode *id_node = find_id_node(id);
if (!id_node) {
DepsNodeFactory *factory = deg_get_node_factory(DEG_NODE_TYPE_ID_REF);
- id_node = (IDDepsNode *)factory->create_node(id, "", name);
- id->tag |= LIB_TAG_DOIT;
+ id_node = (IDDepsNode *)factory->create_node(id, "", id->name);
+ id_node->init_copy_on_write(id_cow_hint);
+ if (do_tag) {
+ id->tag |= LIB_TAG_DOIT;
+ }
/* Register node in ID hash.
*
* NOTE: We address ID nodes by the original ID pointer they are
@@ -289,12 +297,41 @@ IDDepsNode *Depsgraph::add_id_node(ID *id, const char *name)
*/
BLI_ghash_insert(id_hash, id, id_node);
}
+ else if (do_tag) {
+ id->tag |= LIB_TAG_DOIT;
+ }
return id_node;
}
void Depsgraph::clear_id_nodes()
{
+#ifndef WITH_COPY_ON_WRITE
BLI_ghash_clear(id_hash, NULL, id_node_deleter);
+#else
+ /* Stupid workaround to ensure we free IDs in a proper order. */
+ GHASH_FOREACH_BEGIN(IDDepsNode *, id_node, id_hash)
+ {
+ if (id_node->id_cow == NULL) {
+ /* This means builder "stole" ownership of the copy-on-written
+ * datablock for her own dirty needs.
+ */
+ continue;
+ }
+ if (!deg_copy_on_write_is_expanded(id_node->id_cow)) {
+ continue;
+ }
+ const ID_Type id_type = GS(id_node->id_cow->name);
+ if (id_type != ID_PA) {
+ id_node->destroy();
+ }
+ }
+ GHASH_FOREACH_END();
+ GHASH_FOREACH_BEGIN(IDDepsNode *, id_node, id_hash)
+ {
+ OBJECT_GUARDED_DELETE(id_node, IDDepsNode);
+ }
+ GHASH_FOREACH_END();
+#endif
}
/* Add new relationship between two nodes. */
@@ -389,9 +426,9 @@ DepsRelation::~DepsRelation()
void Depsgraph::add_entry_tag(OperationDepsNode *node)
{
/* Sanity check. */
- if (!node)
+ if (node == NULL) {
return;
-
+ }
/* Add to graph-level set of directly modified nodes to start searching from.
* NOTE: this is necessary since we have several thousand nodes to play with...
*/
@@ -412,6 +449,25 @@ ID *Depsgraph::get_cow_id(const ID *id_orig) const
{
IDDepsNode *id_node = find_id_node(id_orig);
if (id_node == NULL) {
+ /* This function is used from places where we expect ID to be either
+ * already a copy-on-write version or have a corresponding copy-on-write
+ * version.
+ *
+ * We try to enforce that in debug builds, for for release we play a bit
+ * safer game here.
+ */
+ if ((id_orig->tag & LIB_TAG_COPY_ON_WRITE) == 0) {
+ /* TODO(sergey): This is nice sanity check to have, but it fails
+ * in following situations:
+ *
+ * - Material has link to texture, which is not needed by new
+ * shading system and hence can be ignored at construction.
+ * - Object or mesh has material at a slot which is not used (for
+ * example, object has material slot by materials are set to
+ * object data).
+ */
+ // BLI_assert(!"Request for non-existing copy-on-write ID");
+ }
return (ID *)id_orig;
}
return id_node->id_cow;
diff --git a/source/blender/depsgraph/intern/depsgraph.h b/source/blender/depsgraph/intern/depsgraph.h
index 9785d2f90d0..823a1935e18 100644
--- a/source/blender/depsgraph/intern/depsgraph.h
+++ b/source/blender/depsgraph/intern/depsgraph.h
@@ -42,6 +42,7 @@
struct ID;
struct GHash;
+struct Main;
struct GSet;
struct PointerRNA;
struct PropertyRNA;
@@ -101,7 +102,8 @@ struct Depsgraph {
* Convenience wrapper to find node given just pointer + property.
*
* \param ptr: pointer to the data that node will represent
- * \param prop: optional property affected - providing this effectively results in inner nodes being returned
+ * \param prop: optional property affected - providing this effectively
+ * results in inner nodes being returned
*
* \return A node matching the required characteristics if it exists
* or NULL if no such node exists in the graph
@@ -112,7 +114,7 @@ struct Depsgraph {
TimeSourceDepsNode *find_time_source() const;
IDDepsNode *find_id_node(const ID *id) const;
- IDDepsNode *add_id_node(ID *id, const char *name = "");
+ IDDepsNode *add_id_node(ID *id, bool do_tag = true, ID *id_cow_hint = NULL);
void clear_id_nodes();
/* Add new relationship between two nodes. */
@@ -164,8 +166,8 @@ struct Depsgraph {
SpinLock lock;
// XXX: additional stuff like eval contexts, mempools for allocating nodes from, etc.
-
- Scene *scene; /* XXX: We really shouldn't do that, but it's required for shader preview */
+ Main *bmain; /* XXX: For until depsgraph has proper ownership. */
+ Scene *scene; /* XXX: We really shouldn't do that, but it's required for shader preview. */
};
} // namespace DEG
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc
index 88ff1ac0a9c..e21c3d29aa5 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cc
+++ b/source/blender/depsgraph/intern/depsgraph_build.cc
@@ -257,12 +257,13 @@ void DEG_graph_tag_relations_update(Depsgraph *graph)
/* Tag all relations for update. */
void DEG_relations_tag_update(Main *bmain)
{
+ DEG_DEBUG_PRINTF("%s: Tagging relations for update.\n", __func__);
for (Scene *scene = (Scene *)bmain->scene.first;
scene != NULL;
scene = (Scene *)scene->id.next)
{
- if (scene->depsgraph != NULL) {
- DEG_graph_tag_relations_update(scene->depsgraph);
+ if (scene->depsgraph_legacy != NULL) {
+ DEG_graph_tag_relations_update(scene->depsgraph_legacy);
}
}
}
@@ -272,24 +273,19 @@ void DEG_relations_tag_update(Main *bmain)
*/
void DEG_scene_relations_update(Main *bmain, Scene *scene)
{
- if (scene->depsgraph == NULL) {
+ if (scene->depsgraph_legacy == NULL) {
/* Rebuild graph from scratch and exit. */
- scene->depsgraph = DEG_graph_new();
- DEG_graph_build_from_scene(scene->depsgraph, bmain, scene);
+ scene->depsgraph_legacy = DEG_graph_new();
+ DEG_graph_build_from_scene(scene->depsgraph_legacy, bmain, scene);
return;
}
- DEG::Depsgraph *graph = reinterpret_cast<DEG::Depsgraph *>(scene->depsgraph);
+ DEG::Depsgraph *graph = reinterpret_cast<DEG::Depsgraph *>(scene->depsgraph_legacy);
if (!graph->need_update) {
/* Graph is up to date, nothing to do. */
return;
}
- /* Clear all previous nodes and operations. */
- graph->clear_all_nodes();
- graph->operations.clear();
- BLI_gset_clear(graph->entry_tags, NULL);
-
/* Build new nodes and relations. */
DEG_graph_build_from_scene(reinterpret_cast< ::Depsgraph * >(graph),
bmain,
@@ -301,17 +297,17 @@ void DEG_scene_relations_update(Main *bmain, Scene *scene)
/* Rebuild dependency graph only for a given scene. */
void DEG_scene_relations_rebuild(Main *bmain, Scene *scene)
{
- if (scene->depsgraph != NULL) {
- DEG_graph_tag_relations_update(scene->depsgraph);
+ if (scene->depsgraph_legacy != NULL) {
+ DEG_graph_tag_relations_update(scene->depsgraph_legacy);
}
DEG_scene_relations_update(bmain, scene);
}
void DEG_scene_graph_free(Scene *scene)
{
- if (scene->depsgraph) {
- DEG_graph_free(scene->depsgraph);
- scene->depsgraph = NULL;
+ if (scene->depsgraph_legacy) {
+ DEG_graph_free(scene->depsgraph_legacy);
+ scene->depsgraph_legacy = NULL;
}
}
@@ -348,7 +344,7 @@ void DEG_add_forcefield_relations(DepsNodeHandle *handle,
int skip_forcefield,
const char *name)
{
- ListBase *effectors = pdInitEffectors(scene, ob, NULL, effector_weights, false);
+ ListBase *effectors = pdInitEffectors(NULL, scene, ob, NULL, effector_weights, false);
if (effectors) {
for (EffectorCache *eff = (EffectorCache*)effectors->first; eff; eff = eff->next) {
diff --git a/source/blender/depsgraph/intern/depsgraph_debug.cc b/source/blender/depsgraph/intern/depsgraph_debug.cc
index 388b692d742..453bd2aa75f 100644
--- a/source/blender/depsgraph/intern/depsgraph_debug.cc
+++ b/source/blender/depsgraph/intern/depsgraph_debug.cc
@@ -91,7 +91,7 @@ bool DEG_debug_scene_relations_validate(Main *bmain,
Depsgraph *depsgraph = DEG_graph_new();
bool valid = true;
DEG_graph_build_from_scene(depsgraph, bmain, scene);
- if (!DEG_debug_compare(depsgraph, scene->depsgraph)) {
+ if (!DEG_debug_compare(depsgraph, scene->depsgraph_legacy)) {
fprintf(stderr, "ERROR! Depsgraph wasn't tagged for update when it should have!\n");
BLI_assert(!"This should not happen!");
valid = false;
diff --git a/source/blender/depsgraph/intern/depsgraph_eval.cc b/source/blender/depsgraph/intern/depsgraph_eval.cc
index 73a0428c264..77a32740524 100644
--- a/source/blender/depsgraph/intern/depsgraph_eval.cc
+++ b/source/blender/depsgraph/intern/depsgraph_eval.cc
@@ -56,7 +56,7 @@ extern "C" {
/* Evaluation Context */
/* Create new evaluation context. */
-EvaluationContext *DEG_evaluation_context_new(int mode)
+EvaluationContext *DEG_evaluation_context_new(eEvaluationMode mode)
{
EvaluationContext *eval_ctx =
(EvaluationContext *)MEM_callocN(sizeof(EvaluationContext),
@@ -70,11 +70,22 @@ EvaluationContext *DEG_evaluation_context_new(int mode)
* Used by the areas which currently overrides the context or doesn't have
* access to a proper one.
*/
-void DEG_evaluation_context_init(EvaluationContext *eval_ctx, int mode)
+void DEG_evaluation_context_init(EvaluationContext *eval_ctx,
+ eEvaluationMode mode)
{
eval_ctx->mode = mode;
}
+void DEG_evaluation_context_init_from_scene(EvaluationContext *eval_ctx,
+ Scene *scene,
+ SceneLayer *scene_layer,
+ eEvaluationMode mode)
+{
+ DEG_evaluation_context_init(eval_ctx, mode);
+ eval_ctx->scene_layer = scene_layer;
+ eval_ctx->ctime = BKE_scene_frame_get(scene);
+}
+
/* Free evaluation context. */
void DEG_evaluation_context_free(EvaluationContext *eval_ctx)
{
diff --git a/source/blender/depsgraph/intern/depsgraph_intern.h b/source/blender/depsgraph/intern/depsgraph_intern.h
index 2d8e7dc841c..5ab090f3b3d 100644
--- a/source/blender/depsgraph/intern/depsgraph_intern.h
+++ b/source/blender/depsgraph/intern/depsgraph_intern.h
@@ -113,11 +113,23 @@ void deg_editors_id_update(struct Main *bmain, struct ID *id);
void deg_editors_scene_update(struct Main *bmain, struct Scene *scene, bool updated);
-#define DEG_DEBUG_PRINTF(...) \
- do { \
- if (G.debug & G_DEBUG_DEPSGRAPH) { \
- fprintf(stderr, __VA_ARGS__); \
- } \
+/* Tagging helpers ------------------------------------------------------ */
+
+void lib_id_recalc_tag(struct Main *bmain, struct ID *id);
+void lib_id_recalc_data_tag(struct Main *bmain, struct ID *id);
+
+#define DEG_DEBUG_PRINTF(...) \
+ do { \
+ if (G.debug & G_DEBUG_DEPSGRAPH) { \
+ fprintf(stderr, __VA_ARGS__); \
+ fflush(stderr); \
+ } \
+ } while (0)
+
+#define DEG_ERROR_PRINTF(...) \
+ do { \
+ fprintf(stderr, __VA_ARGS__); \
+ fflush(stderr); \
} while (0)
} // namespace DEG
diff --git a/source/blender/depsgraph/intern/depsgraph_query.cc b/source/blender/depsgraph/intern/depsgraph_query.cc
index 3dfa6bf5e9d..9e9a2c38993 100644
--- a/source/blender/depsgraph/intern/depsgraph_query.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query.cc
@@ -53,9 +53,9 @@ extern "C" {
# include "intern/eval/deg_eval_copy_on_write.h"
#endif
-bool DEG_id_type_tagged(Main *bmain, short idtype)
+bool DEG_id_type_tagged(Main *bmain, short id_type)
{
- return bmain->id_tag_update[BKE_idcode_to_index(idtype)] != 0;
+ return bmain->id_tag_update[BKE_idcode_to_index(id_type)] != 0;
}
short DEG_get_eval_flags_for_id(Depsgraph *graph, ID *id)
@@ -81,32 +81,39 @@ short DEG_get_eval_flags_for_id(Depsgraph *graph, ID *id)
return id_node->eval_flags;
}
-Scene *DEG_get_scene(Depsgraph *graph)
+Scene *DEG_get_evaluated_scene(Depsgraph *graph)
{
DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph);
Scene *scene_orig = deg_graph->scene;
return reinterpret_cast<Scene *>(deg_graph->get_cow_id(&scene_orig->id));
}
-SceneLayer *DEG_get_scene_layer(Depsgraph *graph)
+SceneLayer *DEG_get_evaluated_scene_layer(Depsgraph *graph)
{
- Scene *scene = DEG_get_scene(graph);
- if (scene) {
- return BKE_scene_layer_render_active(scene);
+ Scene *scene = DEG_get_evaluated_scene(graph);
+ if (scene != NULL) {
+ return BKE_scene_layer_context_active_PLACEHOLDER(scene);
}
return NULL;
}
-Object *DEG_get_object(Depsgraph *depsgraph, Object *ob)
+Object *DEG_get_evaluated_object(Depsgraph *depsgraph, Object *object)
{
- DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph);
- return (Object *)deg_graph->get_cow_id(&ob->id);
+ return (Object *)DEG_get_evaluated_id(depsgraph, &object->id);
}
ID *DEG_get_evaluated_id(struct Depsgraph *depsgraph, ID *id)
{
- DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph);
- return deg_graph->get_cow_id(id);
+ /* TODO(sergey): This is a duplicate of Depsgraph::get_cow_id(),
+ * but here we never do assert, since we don't know nature of the
+ * incoming ID datablock.
+ */
+ DEG::Depsgraph *deg_graph = (DEG::Depsgraph *)depsgraph;
+ DEG::IDDepsNode *id_node = deg_graph->find_id_node(id);
+ if (id_node == NULL) {
+ return id;
+ }
+ return id_node->id_cow;
}
/* ************************ DAG ITERATORS ********************* */
@@ -116,12 +123,12 @@ ID *DEG_get_evaluated_id(struct Depsgraph *depsgraph, ID *id)
void DEG_objects_iterator_begin(BLI_Iterator *iter, DEGObjectsIteratorData *data)
{
Depsgraph *graph = data->graph;
- SceneLayer *scene_layer = DEG_get_scene_layer(graph);
+ SceneLayer *scene_layer = DEG_get_evaluated_scene_layer(graph);
iter->data = data;
iter->valid = true;
- data->scene = DEG_get_scene(graph);
+ data->scene = DEG_get_evaluated_scene(graph);
DEG_evaluation_context_init(&data->eval_ctx, DAG_EVAL_RENDER);
/* TODO(sergey): It's really confusing to store pointer to a local data. */
@@ -204,33 +211,29 @@ void DEG_objects_iterator_next(BLI_Iterator *iter)
}
base = data->base->next;
- while (base != NULL) {
- if ((base->flag & BASE_VISIBLED) != 0) {
- // Object *ob = DEG_get_object(data->graph, base->object);
- Object *ob = base->object;
- iter->current = ob;
- data->base = base;
-
- BLI_assert(DEG::deg_validate_copy_on_write_datablock(&ob->id));
-
- /* Make sure we have the base collection settings is already populated.
- * This will fail when BKE_layer_eval_layer_collection_pre hasn't run yet
- * Which usually means a missing call to DAG_id_tag_update(). */
- BLI_assert(!BLI_listbase_is_empty(&base->collection_properties->data.group));
-
- /* Flushing depsgraph data. */
- deg_flush_base_flags_and_settings(ob,
- base,
- data->base_flag);
-
- if ((data->flag & DEG_OBJECT_ITER_FLAG_DUPLI) && (ob->transflag & OB_DUPLI)) {
- data->dupli_parent = ob;
- data->dupli_list = object_duplilist(&data->eval_ctx, data->scene, ob);
- data->dupli_object_next = (DupliObject *)data->dupli_list->first;
- }
- return;
+ if (base != NULL) {
+ // Object *ob = DEG_get_evaluated_object(data->graph, base->object);
+ Object *ob = base->object;
+ iter->current = ob;
+ data->base = base;
+
+ BLI_assert(DEG::deg_validate_copy_on_write_datablock(&ob->id));
+
+ /* Make sure we have the base collection settings is already populated.
+ * This will fail when BKE_layer_eval_layer_collection_pre hasn't run yet
+ * Which usually means a missing call to DEG_id_tag_update(). */
+ BLI_assert(!BLI_listbase_is_empty(&base->collection_properties->data.group));
+
+ /* Flushing depsgraph data. */
+ deg_flush_base_flags_and_settings(
+ ob, base, data->base_flag);
+
+ if ((data->flag & DEG_OBJECT_ITER_FLAG_DUPLI) && (ob->transflag & OB_DUPLI)) {
+ data->dupli_parent = ob;
+ data->dupli_list = object_duplilist(&data->eval_ctx, data->scene, ob);
+ data->dupli_object_next = (DupliObject *)data->dupli_list->first;
}
- base = base->next;
+ return;
}
/* Look for an object in the next set. */
@@ -240,7 +243,7 @@ void DEG_objects_iterator_next(BLI_Iterator *iter)
data->base_flag = ~(BASE_SELECTED | BASE_SELECTABLED);
/* For the sets we use the layer used for rendering. */
- scene_layer = BKE_scene_layer_render_active(data->scene);
+ scene_layer = BKE_scene_layer_from_scene_get(data->scene);
/* TODO(sergey): It's really confusing to store pointer to a local data. */
Base base = {(Base *)scene_layer->object_bases.first, NULL};
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc
index 80fa89bbb97..0df2420d662 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -67,18 +67,17 @@ extern "C" {
#include "intern/depsgraph_intern.h"
#include "util/deg_util_foreach.h"
+/* Define this in order to have more strict sanitization of what tagging flags
+ * are used for ID databnlocks. Ideally, we would always want this, but there
+ * are cases in generic modules (like IR remapping) where we don't want to spent
+ * lots of time trying to guess which components are to be updated.
+ */
+// #define STRICT_COMPONENT_TAGGING
+
/* *********************** */
/* Update Tagging/Flushing */
-/* Legacy depsgraph did some special trickery for things like particle systems
- * when tagging ID for an update. Ideally that tagging needs to become obsolete
- * in favor of havng dedicated node for that which gets tagged, but for until
- * design of those areas is more clear we'll do the same legacy code here.
- * - sergey -
- */
-#define DEPSGRAPH_USE_LEGACY_TAGGING
-
-namespace {
+namespace DEG {
/* Data-Based Tagging ------------------------------- */
@@ -94,124 +93,312 @@ void lib_id_recalc_data_tag(Main *bmain, ID *id)
DEG_id_type_tag(bmain, GS(id->name));
}
+namespace {
+
+void deg_graph_id_tag_update(Main *bmain, Depsgraph *graph, ID *id, int flag);
+
void lib_id_recalc_tag_flag(Main *bmain, ID *id, int flag)
{
+ /* This bit of code ensures legacy object->recalc flags are still filled in
+ * the same way as it was expected with the old dependency graph.
+ *
+ * This is because some areas like motion paths and likely some other
+ * physics baking process are doing manual scene update on all the frames,
+ * trying to minimize number of updates.
+ *
+ * But this flag will also let us to re-construct entry nodes for update
+ * after relations update and after layer visibility changes.
+ */
if (flag) {
- /* This bit of code ensures legacy object->recalc flags
- * are still filled in the same way as it was expected
- * with the old dependency graph.
- *
- * This is because some areas like motion paths and likely
- * some other physics baking process are doing manual scene
- * update on all the frames, trying to minimize number of
- * updates.
- *
- * But this flag will also let us to re-construct entry
- * nodes for update after relations update and after layer
- * visibility changes.
- */
- short idtype = GS(id->name);
- if (idtype == ID_OB) {
+ ID_Type id_type = GS(id->name);
+ if (id_type == ID_OB) {
Object *object = (Object *)id;
object->recalc |= (flag & OB_RECALC_ALL);
}
-
- if (flag & OB_RECALC_OB)
+ if (flag & OB_RECALC_OB) {
lib_id_recalc_tag(bmain, id);
- if (flag & (OB_RECALC_DATA | PSYS_RECALC))
+ }
+ if (flag & (OB_RECALC_DATA | PSYS_RECALC)) {
lib_id_recalc_data_tag(bmain, id);
+ }
}
else {
lib_id_recalc_tag(bmain, id);
}
}
-#ifdef DEPSGRAPH_USE_LEGACY_TAGGING
-void depsgraph_legacy_handle_update_tag(Main *bmain, ID *id, int flag)
+/* Special tagging */
+void id_tag_update_special_zero_flag(Depsgraph *graph, IDDepsNode *id_node)
{
- if (flag) {
- Object *object;
- short idtype = GS(id->name);
- if (idtype == ID_PA) {
- ParticleSystem *psys;
- for (object = (Object *)bmain->object.first;
- object != NULL;
- object = (Object *)object->id.next)
- {
- for (psys = (ParticleSystem *)object->particlesystem.first;
- psys != NULL;
- psys = (ParticleSystem *)psys->next)
- {
- if (&psys->part->id == id) {
- DEG_id_tag_update_ex(bmain, &object->id, flag & OB_RECALC_ALL);
- psys->recalc |= (flag & PSYS_RECALC);
- }
- }
+ /* NOTE: Full ID node update for now, need to minimize that i9n the future. */
+ id_node->tag_update(graph);
+}
+
+/* Tag corresponding to OB_RECALC_OB. */
+void id_tag_update_object_transform(Depsgraph *graph, IDDepsNode *id_node)
+{
+ ComponentDepsNode *transform_comp =
+ id_node->find_component(DEG_NODE_TYPE_TRANSFORM);
+ if (transform_comp == NULL) {
+#ifdef STRICT_COMPONENT_TAGGING
+ DEG_ERROR_PRINTF("ERROR: Unable to find transform component for %s\n",
+ id_node->id_orig->name);
+ BLI_assert(!"This is not supposed to happen!");
+#endif
+ return;
+ }
+ transform_comp->tag_update(graph);
+}
+
+/* Tag corresponding to OB_RECALC_DATA. */
+void id_tag_update_object_data(Depsgraph *graph, IDDepsNode *id_node)
+{
+ const ID_Type id_type = GS(id_node->id_orig->name);
+ ComponentDepsNode *data_comp = NULL;
+ switch (id_type) {
+ case ID_OB:
+ {
+ const Object *object = (Object *)id_node->id_orig;
+ switch (object->type) {
+ case OB_MESH:
+ case OB_CURVE:
+ case OB_SURF:
+ case OB_FONT:
+ case OB_MBALL:
+ data_comp = id_node->find_component(DEG_NODE_TYPE_GEOMETRY);
+ break;
+ case OB_ARMATURE:
+ data_comp = id_node->find_component(DEG_NODE_TYPE_EVAL_POSE);
+ break;
+ /* TODO(sergey): More cases here? */
}
+ break;
}
+ case ID_ME:
+ data_comp = id_node->find_component(DEG_NODE_TYPE_GEOMETRY);
+ break;
+ case ID_PA:
+ return;
+ case ID_LP:
+ data_comp = id_node->find_component(DEG_NODE_TYPE_PARAMETERS);
+ break;
+ default:
+ break;
+ }
+ if (data_comp == NULL) {
+#ifdef STRICT_COMPONENT_TAGGING
+ DEG_ERROR_PRINTF("ERROR: Unable to find data component for %s\n",
+ id_node->id_orig->name);
+ BLI_assert(!"This is not supposed to happen!");
+#endif
+ return;
}
+ data_comp->tag_update(graph);
+ /* Special legacy compatibility code, tag data ID for update when object
+ * is tagged for data update.
+ */
+ if (id_type == ID_OB) {
+ Object *object = (Object *)id_node->id_orig;
+ ID *data_id = (ID *)object->data;
+ if (data_id != NULL) {
+ IDDepsNode *data_id_node = graph->find_id_node(data_id);
+ // BLI_assert(data_id_node != NULL);
+ /* TODO(sergey): Do we want more granular tags here? */
+ /* TODO(sergey): Hrm, during some operations it's possible to have
+ * object node existing but not it's data. For example, when making
+ * objects local. This is valid situation, but how can we distinguish
+ * that from someone trying to do stupid things with dependency
+ * graph?
+ */
+ if (data_id_node != NULL) {
+ data_id_node->tag_update(graph);
+ }
+ }
+ }
+}
+
+/* Tag corresponding to OB_RECALC_TIME. */
+void id_tag_update_object_time(Depsgraph *graph, IDDepsNode *id_node)
+{
+ ComponentDepsNode *animation_comp =
+ id_node->find_component(DEG_NODE_TYPE_ANIMATION);
+ if (animation_comp == NULL) {
+ /* It's not necessarily we've got animation component in cases when
+ * we are tagging for time updates.
+ */
+ return;
+ }
+ animation_comp->tag_update(graph);
+ /* TODO(sergey): More components to tag here? */
+}
+
+void id_tag_update_particle(Depsgraph *graph, IDDepsNode *id_node, int tag)
+{
+ ComponentDepsNode *particle_comp =
+ id_node->find_component(DEG_NODE_TYPE_PARAMETERS);
+ ParticleSettings *particle_settings = (ParticleSettings *)id_node->id_orig;
+ particle_settings->recalc |= (tag & PSYS_RECALC);
+ if (particle_comp == NULL) {
+#ifdef STRICT_COMPONENT_TAGGING
+ DEG_ERROR_PRINTF("ERROR: Unable to find particle component for %s\n",
+ id_node->id_orig->name);
+ BLI_assert(!"This is not supposed to happen!");
+#endif
+ return;
+ }
+ particle_comp->tag_update(graph);
}
+
+void id_tag_update_shading(Depsgraph *graph, IDDepsNode *id_node)
+{
+ ComponentDepsNode *shading_comp;
+ if (GS(id_node->id_orig->name) == ID_NT) {
+ shading_comp = id_node->find_component(DEG_NODE_TYPE_SHADING_PARAMETERS);
+ }
+ else {
+ shading_comp = id_node->find_component(DEG_NODE_TYPE_SHADING);
+ }
+ if (shading_comp == NULL) {
+#ifdef STRICT_COMPONENT_TAGGING
+ DEG_ERROR_PRINTF("ERROR: Unable to find shading component for %s\n",
+ id_node->id_orig->name);
+ BLI_assert(!"This is not supposed to happen!");
#endif
+ return;
+ }
+ shading_comp->tag_update(graph);
+}
#ifdef WITH_COPY_ON_WRITE
-void id_tag_copy_on_write_update(Main *bmain, Depsgraph *graph, ID *id)
+/* Tag corresponding to DEG_TAG_COPY_ON_WRITE. */
+void id_tag_update_copy_on_write(Depsgraph *graph, IDDepsNode *id_node)
{
- lib_id_recalc_tag(bmain, id);
- DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph);
- DEG::IDDepsNode *id_node = deg_graph->find_id_node(id);
- DEG::ComponentDepsNode *cow_comp =
- id_node->find_component(DEG::DEG_NODE_TYPE_COPY_ON_WRITE);
- DEG::OperationDepsNode *cow_node = cow_comp->get_entry_operation();
- cow_node->tag_update(deg_graph);
- cow_node->flag |= DEG::DEPSOP_FLAG_SKIP_FLUSH;
+ ComponentDepsNode *cow_comp =
+ id_node->find_component(DEG_NODE_TYPE_COPY_ON_WRITE);
+ OperationDepsNode *cow_node = cow_comp->get_entry_operation();
+ cow_node->tag_update(graph);
}
#endif
-} /* namespace */
-
-/* Tag all nodes in ID-block for update.
- * This is a crude measure, but is most convenient for old code.
- */
-void DEG_graph_id_tag_update(Main *bmain, Depsgraph *graph, ID *id)
+void id_tag_update_ntree_special(Main *bmain, Depsgraph *graph, ID *id, int flag)
{
- DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph);
- DEG::IDDepsNode *node = deg_graph->find_id_node(id);
- lib_id_recalc_tag(bmain, id);
- if (node != NULL) {
- node->tag_update(deg_graph);
+ bNodeTree *ntree = NULL;
+ switch (GS(id->name)) {
+ case ID_MA:
+ ntree = ((Material *)id)->nodetree;
+ break;
+ default:
+ break;
+ }
+ if (ntree == NULL) {
+ return;
+ }
+ IDDepsNode *id_node = graph->find_id_node(&ntree->id);
+ if (id_node != NULL) {
+ deg_graph_id_tag_update(bmain, graph, id_node->id_orig, flag);
}
}
-/* Tag nodes related to a specific piece of data */
-void DEG_graph_data_tag_update(Depsgraph *graph, const PointerRNA *ptr)
+void deg_graph_id_tag_update(Main *bmain, Depsgraph *graph, ID *id, int flag)
{
- DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph);
- DEG::DepsNode *node = deg_graph->find_node_from_pointer(ptr, NULL);
- if (node != NULL) {
- node->tag_update(deg_graph);
+ Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph);
+ IDDepsNode *id_node = deg_graph->find_id_node(id);
+ /* Make sure legacy flags are all nicely update. */
+ lib_id_recalc_tag_flag(bmain, id, flag);
+ if (id_node == NULL) {
+ /* Shouldn't happen, but better be sure here. */
+ return;
}
- else {
- printf("Missing node in %s\n", __func__);
- BLI_assert(!"Shouldn't happens since it'll miss crucial update.");
+ /* Tag components based on flags. */
+ if (flag == 0) {
+ id_tag_update_special_zero_flag(graph, id_node);
+ id_tag_update_ntree_special(bmain, graph, id, flag);
+ return;
+ }
+ if (flag & OB_RECALC_OB) {
+ id_tag_update_object_transform(graph, id_node);
}
+ if (flag & OB_RECALC_DATA) {
+ id_tag_update_object_data(graph, id_node);
+#ifdef WITH_COPY_ON_WRITE
+ if (flag & DEG_TAG_COPY_ON_WRITE) {
+ const ID_Type id_type = GS(id_node->id_orig->name);
+ if (id_type == ID_OB) {
+ Object *object = (Object *)id_node->id_orig;
+ ID *ob_data = (ID *)object->data;
+ DEG_id_tag_update_ex(bmain, ob_data, flag);
+ }
+ }
+#endif
+ }
+ if (flag & OB_RECALC_TIME) {
+ id_tag_update_object_time(graph, id_node);
+ }
+ if (flag & PSYS_RECALC) {
+ id_tag_update_particle(graph, id_node, flag);
+ }
+ if (flag & DEG_TAG_SHADING_UPDATE) {
+ id_tag_update_shading(graph, id_node);
+ }
+#ifdef WITH_COPY_ON_WRITE
+ if (flag & DEG_TAG_COPY_ON_WRITE) {
+ id_tag_update_copy_on_write(graph, id_node);
+ }
+#endif
+ id_tag_update_ntree_special(bmain, graph, id, flag);
}
-/* Tag nodes related to a specific property. */
-void DEG_graph_property_tag_update(Depsgraph *graph,
- const PointerRNA *ptr,
- const PropertyRNA *prop)
+void deg_id_tag_update(Main *bmain, ID *id, int flag)
{
- DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph);
- DEG::DepsNode *node = deg_graph->find_node_from_pointer(ptr, prop);
- if (node != NULL) {
- node->tag_update(deg_graph);
+ lib_id_recalc_tag_flag(bmain, id, flag);
+ for (Scene *scene = (Scene *)bmain->scene.first;
+ scene != NULL;
+ scene = (Scene *)scene->id.next)
+ {
+ if (scene->depsgraph_legacy != NULL) {
+ Depsgraph *graph = (Depsgraph *)scene->depsgraph_legacy;
+ deg_graph_id_tag_update(bmain, graph, id, flag);
+ }
}
- else {
- printf("Missing node in %s\n", __func__);
- BLI_assert(!"Shouldn't happens since it'll miss crucial update.");
+}
+
+void deg_graph_on_visible_update(Main *bmain, Scene *scene, Depsgraph *graph)
+{
+ /* Make sure objects are up to date. */
+ GHASH_FOREACH_BEGIN(DEG::IDDepsNode *, id_node, graph->id_hash)
+ {
+ const ID_Type id_type = GS(id_node->id_orig->name);
+ /* TODO(sergey): Special exception for now. */
+ if (id_type == ID_MSK) {
+ deg_graph_id_tag_update(bmain, graph, id_node->id_orig, 0);
+ }
+ if (id_type != ID_OB) {
+ /* Ignore non-object nodes on visibility changes. */
+ continue;
+ }
+ int flag = 0;
+ /* We only tag components which needs an update. Tagging everything is
+ * not a good idea because that might reset particles cache (or any
+ * other type of cache).
+ *
+ * TODO(sergey): Need to generalize this somehow.
+ */
+ if (id_type == ID_OB) {
+ flag |= OB_RECALC_OB | OB_RECALC_DATA | DEG_TAG_COPY_ON_WRITE;
+ }
+ deg_graph_id_tag_update(bmain, graph, id_node->id_orig, flag);
}
+ GHASH_FOREACH_END();
+ /* Make sure collection properties are up to date. */
+ IDDepsNode *scene_id_node = graph->find_id_node(&scene->id);
+ BLI_assert(scene_id_node != NULL);
+ scene_id_node->tag_update(graph);
}
+} /* namespace */
+
+} // namespace DEG
+
/* Tag given ID for an update in all the dependency graphs. */
void DEG_id_tag_update(ID *id, int flag)
{
@@ -225,56 +412,13 @@ void DEG_id_tag_update_ex(Main *bmain, ID *id, int flag)
return;
}
DEG_DEBUG_PRINTF("%s: id=%s flag=%d\n", __func__, id->name, flag);
- lib_id_recalc_tag_flag(bmain, id, flag);
- for (Scene *scene = (Scene *)bmain->scene.first;
- scene != NULL;
- scene = (Scene *)scene->id.next)
- {
- if (scene->depsgraph) {
- Depsgraph *graph = scene->depsgraph;
- if (flag == 0) {
- /* TODO(sergey): Currently blender is still tagging IDs
- * for recalc just using flag=0. This isn't totally correct
- * but we'd better deal with such cases and don't fail.
- */
- DEG_graph_id_tag_update(bmain, graph, id);
- continue;
- }
- if (flag & OB_RECALC_DATA && GS(id->name) == ID_OB) {
- Object *object = (Object *)id;
- if (object->data != NULL) {
- DEG_graph_id_tag_update(bmain,
- graph,
- (ID *)object->data);
- }
- }
- if (flag & (OB_RECALC_OB | OB_RECALC_DATA)) {
- DEG_graph_id_tag_update(bmain, graph, id);
- }
- else if (flag & OB_RECALC_TIME) {
- DEG_graph_id_tag_update(bmain, graph, id);
- }
- else if (flag & DEG_TAG_COPY_ON_WRITE) {
-#ifdef WITH_COPY_ON_WRITE
- id_tag_copy_on_write_update(bmain, graph, id);
-#endif
- }
- }
- }
-
-#ifdef DEPSGRAPH_USE_LEGACY_TAGGING
- /* Special handling from the legacy depsgraph.
- * TODO(sergey): Need to get rid of those once all the areas
- * are re-formulated in terms of franular nodes.
- */
- depsgraph_legacy_handle_update_tag(bmain, id, flag);
-#endif
+ DEG::deg_id_tag_update(bmain, id, flag);
}
/* Tag given ID type for update. */
-void DEG_id_type_tag(Main *bmain, short idtype)
+void DEG_id_type_tag(Main *bmain, short id_type)
{
- if (idtype == ID_NT) {
+ if (id_type == ID_NT) {
/* Stupid workaround so parent datablocks of nested nodetree get looped
* over when we loop over tagged datablock types.
*/
@@ -285,7 +429,7 @@ void DEG_id_type_tag(Main *bmain, short idtype)
DEG_id_type_tag(bmain, ID_SCE);
}
- bmain->id_tag_update[BKE_idcode_to_index(idtype)] = 1;
+ bmain->id_tag_update[BKE_idcode_to_index(id_type)] = 1;
}
/* Recursively push updates out to all nodes dependent on this,
@@ -297,25 +441,25 @@ void DEG_ids_flush_tagged(Main *bmain)
scene != NULL;
scene = (Scene *)scene->id.next)
{
- /* TODO(sergey): Only visible scenes? */
- if (scene->depsgraph != NULL) {
- DEG::deg_graph_flush_updates(
- bmain,
- reinterpret_cast<DEG::Depsgraph *>(scene->depsgraph));
- }
+ DEG_scene_flush_update(bmain, scene);
+ }
+}
+
+void DEG_scene_flush_update(Main *bmain, Scene *scene)
+{
+ if (scene->depsgraph_legacy == NULL) {
+ return;
}
+ DEG::deg_graph_flush_updates(
+ bmain,
+ reinterpret_cast<DEG::Depsgraph *>(scene->depsgraph_legacy));
}
/* Update dependency graph when visible scenes/layers changes. */
void DEG_graph_on_visible_update(Main *bmain, Scene *scene)
{
- (void) bmain;
- DEG::Depsgraph *graph = reinterpret_cast<DEG::Depsgraph *>(scene->depsgraph);
- GHASH_FOREACH_BEGIN(DEG::IDDepsNode *, id_node, graph->id_hash)
- {
- id_node->tag_update(graph);
- }
- GHASH_FOREACH_END();
+ DEG::Depsgraph *graph = (DEG::Depsgraph *)scene->depsgraph_legacy;
+ DEG::deg_graph_on_visible_update(bmain, scene, graph);
}
void DEG_on_visible_update(Main *bmain, const bool UNUSED(do_time))
@@ -324,7 +468,7 @@ void DEG_on_visible_update(Main *bmain, const bool UNUSED(do_time))
scene != NULL;
scene = (Scene *)scene->id.next)
{
- if (scene->depsgraph != NULL) {
+ if (scene->depsgraph_legacy != NULL) {
DEG_graph_on_visible_update(bmain, scene);
}
}
diff --git a/source/blender/depsgraph/intern/depsgraph_type_defines.cc b/source/blender/depsgraph/intern/depsgraph_type_defines.cc
index bb75a85eea4..0d42acf382a 100644
--- a/source/blender/depsgraph/intern/depsgraph_type_defines.cc
+++ b/source/blender/depsgraph/intern/depsgraph_type_defines.cc
@@ -98,36 +98,55 @@ static const char *stringify_opcode(eDepsOperation_Code opcode)
{
switch (opcode) {
#define STRINGIFY_OPCODE(name) case DEG_OPCODE_##name: return #name
+ /* Generic Operations. */
STRINGIFY_OPCODE(OPERATION);
+ STRINGIFY_OPCODE(PARAMETERS_EVAL);
STRINGIFY_OPCODE(PLACEHOLDER);
+ /* Animation, Drivers, etc. */
STRINGIFY_OPCODE(ANIMATION);
STRINGIFY_OPCODE(DRIVER);
+ /* Transform. */
STRINGIFY_OPCODE(TRANSFORM_LOCAL);
STRINGIFY_OPCODE(TRANSFORM_PARENT);
STRINGIFY_OPCODE(TRANSFORM_CONSTRAINTS);
+ STRINGIFY_OPCODE(TRANSFORM_FINAL);
+ STRINGIFY_OPCODE(TRANSFORM_OBJECT_UBEREVAL);
+ /* Rigid body. */
STRINGIFY_OPCODE(RIGIDBODY_REBUILD);
STRINGIFY_OPCODE(RIGIDBODY_SIM);
- STRINGIFY_OPCODE(TRANSFORM_RIGIDBODY);
- STRINGIFY_OPCODE(TRANSFORM_FINAL);
- STRINGIFY_OPCODE(OBJECT_UBEREVAL);
+ STRINGIFY_OPCODE(RIGIDBODY_TRANSFORM_COPY);
+ /* Geometry. */
STRINGIFY_OPCODE(GEOMETRY_UBEREVAL);
- STRINGIFY_OPCODE(GEOMETRY_PATH);
+ /* Pose. */
STRINGIFY_OPCODE(POSE_INIT);
+ STRINGIFY_OPCODE(POSE_INIT_IK);
STRINGIFY_OPCODE(POSE_DONE);
STRINGIFY_OPCODE(POSE_IK_SOLVER);
STRINGIFY_OPCODE(POSE_SPLINE_IK_SOLVER);
+ /* Bone. */
STRINGIFY_OPCODE(BONE_LOCAL);
STRINGIFY_OPCODE(BONE_POSE_PARENT);
STRINGIFY_OPCODE(BONE_CONSTRAINTS);
STRINGIFY_OPCODE(BONE_READY);
STRINGIFY_OPCODE(BONE_DONE);
- STRINGIFY_OPCODE(PSYS_EVAL);
-
+ /* Particles. */
+ STRINGIFY_OPCODE(PARTICLE_SYSTEM_EVAL_INIT);
+ STRINGIFY_OPCODE(PARTICLE_SYSTEM_EVAL);
+ STRINGIFY_OPCODE(PARTICLE_SETTINGS_EVAL);
+ STRINGIFY_OPCODE(PARTICLE_SETTINGS_RECALC_CLEAR);
+ /* Masks. */
+ STRINGIFY_OPCODE(MASK_ANIMATION);
+ STRINGIFY_OPCODE(MASK_EVAL);
+ /* Collections. */
STRINGIFY_OPCODE(SCENE_LAYER_INIT);
STRINGIFY_OPCODE(SCENE_LAYER_EVAL);
STRINGIFY_OPCODE(SCENE_LAYER_DONE);
-
+ /* Copy on write. */
STRINGIFY_OPCODE(COPY_ON_WRITE);
+ /* Shading. */
+ STRINGIFY_OPCODE(SHADING);
+ STRINGIFY_OPCODE(MATERIAL_UPDATE);
+ STRINGIFY_OPCODE(WORLD_UPDATE);
case DEG_NUM_OPCODES: return "SpecialCase";
#undef STRINGIFY_OPCODE
diff --git a/source/blender/depsgraph/intern/depsgraph_types.h b/source/blender/depsgraph/intern/depsgraph_types.h
index 737452549ec..abdedd8adb6 100644
--- a/source/blender/depsgraph/intern/depsgraph_types.h
+++ b/source/blender/depsgraph/intern/depsgraph_types.h
@@ -130,17 +130,21 @@ typedef enum eDepsNode_Type {
DEG_NODE_TYPE_EVAL_PARTICLES,
/* Material Shading Component */
DEG_NODE_TYPE_SHADING,
+ DEG_NODE_TYPE_SHADING_PARAMETERS,
/* Cache Component */
DEG_NODE_TYPE_CACHE,
} eDepsNode_Type;
/* Identifiers for common operations (as an enum). */
typedef enum eDepsOperation_Code {
- /* Generic Operations ------------------------------ */
+ /* Generic Operations. ------------------------------ */
/* Placeholder for operations which don't need special mention */
DEG_OPCODE_OPERATION = 0,
+ /* Generic parameters evaluation. */
+ DEG_OPCODE_PARAMETERS_EVAL,
+
// XXX: Placeholder while porting depsgraph code
DEG_OPCODE_PLACEHOLDER,
@@ -150,7 +154,7 @@ typedef enum eDepsOperation_Code {
/* Driver */
DEG_OPCODE_DRIVER,
- /* Transform --------------------------------------- */
+ /* Transform. -------------------------------------- */
/* Transform entry point - local transforms only */
DEG_OPCODE_TRANSFORM_LOCAL,
/* Parenting */
@@ -160,31 +164,31 @@ typedef enum eDepsOperation_Code {
/* Transform exit point */
DEG_OPCODE_TRANSFORM_FINAL,
/* Handle object-level updates, mainly proxies hacks and recalc flags. */
- DEG_OPCODE_OBJECT_UBEREVAL,
+ DEG_OPCODE_TRANSFORM_OBJECT_UBEREVAL,
- /* Rigid body -------------------------------------- */
+ /* Rigid body. -------------------------------------- */
/* Perform Simulation */
DEG_OPCODE_RIGIDBODY_REBUILD,
DEG_OPCODE_RIGIDBODY_SIM,
/* Copy results to object */
- DEG_OPCODE_TRANSFORM_RIGIDBODY,
+ DEG_OPCODE_RIGIDBODY_TRANSFORM_COPY,
- /* Geometry ---------------------------------------- */
+ /* Geometry. ---------------------------------------- */
/* Evaluate the whole geometry, including modifiers. */
DEG_OPCODE_GEOMETRY_UBEREVAL,
- /* Curve Objects - Path Calculation (used for path-following tools, */
- DEG_OPCODE_GEOMETRY_PATH,
- /* Pose -------------------------------------------- */
- /* Init IK Trees, etc. */
+ /* Pose. -------------------------------------------- */
+ /* Init pose, clear flags, etc. */
DEG_OPCODE_POSE_INIT,
+ /* Initialize IK solver related pose stuff. */
+ DEG_OPCODE_POSE_INIT_IK,
/* Free IK Trees + Compute Deform Matrices */
DEG_OPCODE_POSE_DONE,
/* IK/Spline Solvers */
DEG_OPCODE_POSE_IK_SOLVER,
DEG_OPCODE_POSE_SPLINE_IK_SOLVER,
- /* Bone -------------------------------------------- */
+ /* Bone. -------------------------------------------- */
/* Bone local transforms - entry point */
DEG_OPCODE_BONE_LOCAL,
/* Pose-space conversion (includes parent + restpose, */
@@ -205,18 +209,30 @@ typedef enum eDepsOperation_Code {
DEG_OPCODE_BONE_READY,
DEG_OPCODE_BONE_DONE,
- /* Particles --------------------------------------- */
+ /* Particles. --------------------------------------- */
/* Particle System evaluation. */
- DEG_OPCODE_PSYS_EVAL,
+ DEG_OPCODE_PARTICLE_SYSTEM_EVAL_INIT,
+ DEG_OPCODE_PARTICLE_SYSTEM_EVAL,
+ DEG_OPCODE_PARTICLE_SETTINGS_EVAL,
+ DEG_OPCODE_PARTICLE_SETTINGS_RECALC_CLEAR,
- /* Collections ------------------------------------- */
+ /* Collections. ------------------------------------- */
DEG_OPCODE_SCENE_LAYER_INIT,
DEG_OPCODE_SCENE_LAYER_EVAL,
DEG_OPCODE_SCENE_LAYER_DONE,
- /* Copy on Write ------------------------- */
+ /* Copy on Write. ------------------------------------ */
DEG_OPCODE_COPY_ON_WRITE,
+ /* Shading. ------------------------------------------- */
+ DEG_OPCODE_SHADING,
+ DEG_OPCODE_MATERIAL_UPDATE,
+ DEG_OPCODE_WORLD_UPDATE,
+
+ /* Masks ------------------------------------------- */
+ DEG_OPCODE_MASK_ANIMATION,
+ DEG_OPCODE_MASK_EVAL,
+
DEG_NUM_OPCODES,
} eDepsOperation_Code;
diff --git a/source/blender/depsgraph/intern/eval/deg_eval.cc b/source/blender/depsgraph/intern/eval/deg_eval.cc
index 15ad6b8054d..120785ac548 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval.cc
@@ -38,7 +38,10 @@
#include "BLI_task.h"
#include "BLI_ghash.h"
+#include "DNA_object_types.h"
+
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "atomic_ops.h"
@@ -275,6 +278,7 @@ void deg_evaluate_on_refresh(EvaluationContext *eval_ctx,
/* Set time for the current graph evaluation context. */
TimeSourceDepsNode *time_src = graph->find_time_source();
+ eval_ctx->scene_layer = DEG_get_evaluated_scene_layer((::Depsgraph *)graph);
eval_ctx->ctime = time_src->cfra;
/* XXX could use a separate pool for each eval context */
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
index e2c1ef5c220..03be601ce2c 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
@@ -25,7 +25,7 @@
*/
-/** \file blender/depsgraph/intern/eval/deg_eval_copy_on_write.h
+/** \file blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
* \ingroup depsgraph
*/
@@ -65,18 +65,19 @@ extern "C" {
# include "DNA_lamp_types.h"
# include "DNA_linestyle_types.h"
# include "DNA_material_types.h"
-# include "DNA_mesh_types.h"
# include "DNA_node_types.h"
-# include "DNA_scene_types.h"
# include "DNA_texture_types.h"
# include "DNA_world_types.h"
#endif
+#include "BKE_action.h"
#include "BKE_editmesh.h"
#include "BKE_library_query.h"
+#include "BKE_object.h"
}
#include "intern/depsgraph.h"
+#include "intern/builder/deg_builder_nodes.h"
#include "intern/nodes/deg_node.h"
namespace DEG {
@@ -110,7 +111,17 @@ void nested_id_hack_discard_pointers(ID *id_cow)
SPECIAL_CASE(ID_LS, FreestyleLineStyle, nodetree)
SPECIAL_CASE(ID_LA, Lamp, nodetree)
SPECIAL_CASE(ID_MA, Material, nodetree)
+#if 0
SPECIAL_CASE(ID_SCE, Scene, nodetree)
+#else
+ case ID_SCE:
+ {
+ Scene *scene_cow = (Scene *)id_cow;
+ scene_cow->nodetree = NULL;
+ BLI_listbase_clear(&scene_cow->base);
+ break;
+ }
+#endif
SPECIAL_CASE(ID_TE, Tex, nodetree)
SPECIAL_CASE(ID_WO, World, nodetree)
@@ -142,7 +153,17 @@ const ID *nested_id_hack_get_discarded_pointers(NestedIDHackTempStorage *storage
SPECIAL_CASE(ID_LS, FreestyleLineStyle, nodetree, linestyle)
SPECIAL_CASE(ID_LA, Lamp, nodetree, lamp)
SPECIAL_CASE(ID_MA, Material, nodetree, material)
+#if 0
SPECIAL_CASE(ID_SCE, Scene, nodetree, scene)
+#else
+ case ID_SCE:
+ {
+ storage->scene = *(Scene *)id;
+ storage->scene.nodetree = NULL;
+ BLI_listbase_clear(&storage->scene.base);
+ return &storage->scene.id;
+ }
+#endif
SPECIAL_CASE(ID_TE, Tex, nodetree, tex)
SPECIAL_CASE(ID_WO, World, nodetree, world)
@@ -286,19 +307,114 @@ Scene *scene_copy_no_main(Scene *scene)
return new_scene;
}
+/* Check whether given ID is expanded or still a shallow copy. */
+BLI_INLINE bool check_datablock_expanded(const ID *id_cow)
+{
+ return (id_cow->name[0] != '\0');
+}
+
+/* Check whether datablock was already expanded during depsgraph
+ * construction.
+ */
+static bool check_datablock_expanded_at_construction(const ID *id_orig)
+{
+ const ID_Type id_type = GS(id_orig->name);
+ return (id_type == ID_SCE) ||
+ (id_type == ID_OB && ((Object *)id_orig)->type == OB_ARMATURE) ||
+ (id_type == ID_AR);
+}
+
+/* Those are datablocks which are not covered by dependency graph and hence
+ * does not need any remapping or anything.
+ *
+ * TODO(sergey): How to make it more robust for the future, so we don't have
+ * to maintain exception lists all over the code?
+ */
+static bool check_datablocks_copy_on_writable(const ID *id_orig)
+{
+ const ID_Type id_type = GS(id_orig->name);
+ /* We shouldn't bother if copied ID is same as original one. */
+ if (!deg_copy_on_write_is_needed(id_orig)) {
+ return false;
+ }
+ return !ELEM(id_type, ID_BR,
+ ID_LS,
+ ID_AC,
+ ID_GR,
+ ID_PAL);
+}
+
/* Callback for BKE_library_foreach_ID_link which remaps original ID pointer
* with the one created by CoW system.
*/
-int foreach_libblock_remap_callback(void *user_data,
- ID * /*id_self*/,
+
+struct RemapCallbackUserData {
+ /* Dependency graph for which remapping is happening. */
+ const Depsgraph *depsgraph;
+ /* Temporarily allocated memory for copying purposes. This ID will
+ * be discarded after expanding is done, so need to make sure temp_id
+ * is replaced with proper real_id.
+ *
+ * NOTE: This is due to our logic of "inplace" duplication, where we
+ * use generic duplication routines (which gives us new ID) which then
+ * is followed with copying data to a placeholder we prepared before and
+ * discarding pointer returned by duplication routines.
+ */
+ const ID *temp_id;
+ ID *real_id;
+ /* Create placeholder for ID nodes for cases when we need to remap original
+ * ID to it[s CoW version but we don't have required ID node yet.
+ *
+ * This happens when expansion happens a ta construction time.
+ */
+ DepsgraphNodeBuilder *node_builder;
+ bool create_placeholders;
+};
+
+int foreach_libblock_remap_callback(void *user_data_v,
+ ID *id_self,
ID **id_p,
int /*cb_flag*/)
{
- Depsgraph *depsgraph = (Depsgraph *)user_data;
+ RemapCallbackUserData *user_data = (RemapCallbackUserData *)user_data_v;
+ const Depsgraph *depsgraph = user_data->depsgraph;
if (*id_p != NULL) {
- const ID *id_orig = *id_p;
- ID *id_cow = depsgraph->get_cow_id(id_orig);
- if (id_cow != NULL) {
+ ID *id_orig = *id_p;
+ if (id_orig == user_data->temp_id) {
+ DEG_COW_PRINT(" Remapping datablock for %s: id_temp=%p id_cow=%p\n",
+ id_orig->name, id_orig, user_data->real_id);
+ *id_p = user_data->real_id;
+ }
+ else if (check_datablocks_copy_on_writable(id_orig)) {
+ ID *id_cow;
+ if (user_data->create_placeholders) {
+ /* Special workaround to stop creating temp datablocks for
+ * objects which are coming from scene's collection and which
+ * are never linked to any of layers.
+ *
+ * TODO(sergey): Ideally we need to tell ID looper to ignore
+ * those or at least make it more reliable check where the
+ * pointer is coming from.
+ */
+ const ID_Type id_type = GS(id_orig->name);
+ const ID_Type id_type_self = GS(id_self->name);
+ if (id_type == ID_OB && id_type_self == ID_SCE) {
+ IDDepsNode *id_node = depsgraph->find_id_node(id_orig);
+ if (id_node == NULL) {
+ id_cow = id_orig;
+ }
+ else {
+ id_cow = id_node->id_cow;
+ }
+ }
+ else {
+ id_cow = user_data->node_builder->ensure_cow_id(id_orig);
+ }
+ }
+ else {
+ id_cow = depsgraph->get_cow_id(id_orig);
+ }
+ BLI_assert(id_cow != NULL);
DEG_COW_PRINT(" Remapping datablock for %s: id_orig=%p id_cow=%p\n",
id_orig->name, id_orig, id_cow);
*id_p = id_cow;
@@ -307,12 +423,6 @@ int foreach_libblock_remap_callback(void *user_data,
return IDWALK_RET_NOP;
}
-/* Check whether given ID is expanded or still a shallow copy. */
-BLI_INLINE bool check_datablock_expanded(ID *id_cow)
-{
- return (id_cow->name[0] != '\0');
-}
-
/* Do some special treatment of data transfer from original ID to it's
* CoW complementary part.
*
@@ -321,7 +431,7 @@ BLI_INLINE bool check_datablock_expanded(ID *id_cow)
void update_special_pointers(const Depsgraph *depsgraph,
const ID *id_orig, ID *id_cow)
{
- const short type = GS(id_orig->name);
+ const ID_Type type = GS(id_orig->name);
switch (type) {
case ID_OB:
{
@@ -329,14 +439,16 @@ void update_special_pointers(const Depsgraph *depsgraph,
* new copy of the object.
*/
Object *object_cow = (Object *)id_cow;
+ const Object *object_orig = (const Object *)id_orig;
(void) object_cow; /* Ignored for release builds. */
BLI_assert(object_cow->derivedFinal == NULL);
BLI_assert(object_cow->derivedDeform == NULL);
+ object_cow->mode = object_orig->mode;
break;
}
case ID_ME:
{
- /* For meshes we need to update edit_brtmesh to make it to point
+ /* For meshes we need to update edit_btmesh to make it to point
* to the CoW version of object.
*
* This is kind of confusing, because actual bmesh is not owned by
@@ -366,7 +478,76 @@ void update_special_pointers(const Depsgraph *depsgraph,
}
break;
}
+ default:
+ break;
+ }
+}
+
+/* Update copy-on-write version of scene from original scene. */
+void update_copy_on_write_scene(const Depsgraph *depsgraph,
+ Scene *scene_cow,
+ const Scene *scene_orig)
+{
+ // Some non-pointer data sync, current frame for now.
+ // TODO(sergey): Are we missing something here?
+ scene_cow->r.cfra = scene_orig->r.cfra;
+ scene_cow->r.subframe = scene_orig->r.subframe;
+ // Update bases.
+ const SceneLayer *sl_orig = (SceneLayer *)scene_orig->render_layers.first;
+ SceneLayer *sl_cow = (SceneLayer *)scene_cow->render_layers.first;
+ while (sl_orig != NULL) {
+ // Update pointers to active base.
+ if (sl_orig->basact == NULL) {
+ sl_cow->basact = NULL;
+ }
+ else {
+ const Object *obact_orig = sl_orig->basact->object;
+ Object *obact_cow = (Object *)depsgraph->get_cow_id(&obact_orig->id);
+ sl_cow->basact = BKE_scene_layer_base_find(sl_cow, obact_cow);
+ }
+ // Update base flags.
+ //
+ // TODO(sergey): We should probably check visibled/selectabled
+ // flag here?
+ const Base *base_orig = (Base *)sl_orig->object_bases.first;
+ Base *base_cow = (Base *)sl_cow->object_bases.first;;
+ while (base_orig != NULL) {
+ base_cow->flag = base_orig->flag;
+ base_orig = base_orig->next;
+ base_cow = base_cow->next;
+ }
+ sl_orig = sl_orig->next;
+ sl_cow = sl_cow->next;
+ }
+ // Update edit object pointer.
+ if (scene_orig->obedit != NULL) {
+ scene_cow->obedit = (Object *)depsgraph->get_cow_id(&scene_orig->obedit->id);
}
+ else {
+ scene_cow->obedit = NULL;
+ }
+ /* Synchronize active render engine. */
+ BLI_strncpy_utf8(scene_cow->r.engine,
+ scene_orig->r.engine,
+ sizeof(scene_cow->r.engine));
+ /* TODO(sergey): What else do we need here? */
+}
+
+/* Update copy-on-write version of armature object from original scene. */
+void update_copy_on_write_object(const Depsgraph * /*depsgraph*/,
+ Object *object_cow,
+ const Object *object_orig)
+{
+ /* TODO(sergey): This function might be split into a smaller ones,
+ * reused for different updates. And maybe even moved to BKE.
+ */
+ /* Update armature/pose related flags. */
+ bPose *pose_cow = object_cow->pose;
+ const bPose *pose_orig = object_orig->pose;
+ extract_pose_from_pose(pose_cow, pose_orig);
+ /* Update object itself. */
+ BKE_object_transform_copy(object_cow, object_orig);
+ object_cow->mode = object_orig->mode;
}
/* Update copy-on-write version of datablock from it's original ID without re-building
@@ -378,50 +559,37 @@ void update_special_pointers(const Depsgraph *depsgraph,
void update_copy_on_write_datablock(const Depsgraph *depsgraph,
const ID *id_orig, ID *id_cow)
{
- if (GS(id_orig->name) == ID_SCE) {
- const Scene *scene_orig = (const Scene *)id_orig;
- Scene *scene_cow = (Scene *)id_cow;
- // Some non-pointer data sync, current frame for now.
- // TODO(sergey): Are we missing something here?
- scene_cow->r.cfra = scene_orig->r.cfra;
- scene_cow->r.subframe = scene_orig->r.subframe;
- // Update bases.
- const SceneLayer *sl_orig = (SceneLayer *)scene_orig->render_layers.first;
- SceneLayer *sl_cow = (SceneLayer *)scene_cow->render_layers.first;
- while (sl_orig != NULL) {
- // Update pointers to active base.
- if (sl_orig->basact == NULL) {
- sl_cow->basact = NULL;
- }
- else {
- const Object *obact_orig = sl_orig->basact->object;
- Object *obact_cow = (Object *)depsgraph->get_cow_id(&obact_orig->id);
- sl_cow->basact = BKE_scene_layer_base_find(sl_cow, obact_cow);
- }
- // Update base flags.
- //
- // TODO(sergey): We should probably check visibled/selectabled
- // flag here?
- const Base *base_orig = (Base *)sl_orig->object_bases.first;
- Base *base_cow = (Base *)sl_cow->object_bases.first;;
- while (base_orig != NULL) {
- base_cow->flag = base_orig->flag;
- base_orig = base_orig->next;
- base_cow = base_cow->next;
- }
- sl_orig = sl_orig->next;
- sl_cow = sl_cow->next;
- }
- // Update edit object pointer.
- if (scene_orig->obedit != NULL) {
- scene_cow->obedit = (Object *)depsgraph->get_cow_id(&scene_orig->obedit->id);
+ bool ok = false;
+ const ID_Type id_type = GS(id_orig->name);
+ switch (id_type) {
+ case ID_SCE: {
+ const Scene *scene_orig = (const Scene *)id_orig;
+ Scene *scene_cow = (Scene *)id_cow;
+ update_copy_on_write_scene(depsgraph, scene_cow, scene_orig);
+ ok = true;
+ break;
}
- else {
- scene_cow->obedit = NULL;
+ case ID_OB: {
+ const Object *object_orig = (const Object *)id_orig;
+ Object *object_cow = (Object *)id_cow;
+ if (object_orig->type == OB_ARMATURE) {
+ update_copy_on_write_object(depsgraph,
+ object_cow,
+ object_orig);
+ ok = true;
+ }
+ break;
}
- // TODO(sergey): Things which are still missing here:
- // - Active render engine.
- // - Something else?
+ case ID_AR:
+ /* Nothing to do currently. */
+ ok = true;
+ break;
+ default:
+ break;
+ }
+ // TODO(sergey): Other ID types here.
+ if (!ok) {
+ BLI_assert(!"Missing update logic of expanded datablock");
}
}
@@ -437,7 +605,7 @@ int foreach_libblock_validate_callback(void *user_data,
if (*id_p != NULL) {
if (!check_datablock_expanded(*id_p)) {
data->is_valid = false;
- /* TODO(sergey_: Store which is is not valid? */
+ /* TODO(sergey): Store which is is not valid? */
}
}
return IDWALK_RET_NOP;
@@ -451,14 +619,30 @@ int foreach_libblock_validate_callback(void *user_data,
* NOTE: Expects that CoW datablock is empty.
*/
ID *deg_expand_copy_on_write_datablock(const Depsgraph *depsgraph,
- const IDDepsNode *id_node)
+ const IDDepsNode *id_node,
+ DepsgraphNodeBuilder *node_builder,
+ bool create_placeholders)
{
+ BLI_assert(!create_placeholders ||
+ check_datablock_expanded_at_construction(id_node->id_orig));
const ID *id_orig = id_node->id_orig;
ID *id_cow = id_node->id_cow;
+ /* No need to expand such datablocks, their copied ID is same as original
+ * one already.
+ */
+ if (!deg_copy_on_write_is_needed(id_orig)) {
+ return id_cow;
+ }
DEG_COW_PRINT("Expanding datablock for %s: id_orig=%p id_cow=%p\n",
id_orig->name, id_orig, id_cow);
/* Sanity checks. */
- BLI_assert(check_datablock_expanded(id_cow) == false);
+ /* NOTE: Disabled for now, conflicts when re-using evaluated datablock when
+ * rebuilding dependencies.
+ */
+ if (check_datablock_expanded(id_cow) && create_placeholders) {
+ deg_free_copy_on_write_datablock(id_cow);
+ }
+ // BLI_assert(check_datablock_expanded(id_cow) == false);
/* Copy data from original ID to a copied version. */
/* TODO(sergey): Avoid doing full ID copy somehow, make Mesh to reference
* original geometry arrays for until those are modified.
@@ -472,12 +656,17 @@ ID *deg_expand_copy_on_write_datablock(const Depsgraph *depsgraph,
* - We don't want bmain's content to be freed when main is freed.
*/
bool done = false;
+ /* Need to make sure the possibly temporary allocated memory is correct for
+ * until we are fully done with remapping original pointers with copied on
+ * write ones.
+ */
+ ID *newid = NULL;
/* First we handle special cases which are not covered by id_copy() yet.
* or cases where we want to do something smarter than simple datablock
* copy.
*/
- const short type = GS(id_orig->name);
- switch (type) {
+ const ID_Type id_type = GS(id_orig->name);
+ switch (id_type) {
case ID_SCE:
{
Scene *new_scene = scene_copy_no_main((Scene *)id_orig);
@@ -493,9 +682,10 @@ ID *deg_expand_copy_on_write_datablock(const Depsgraph *depsgraph,
*/
break;
}
+ default:
+ break;
}
if (!done) {
- ID *newid;
if (id_copy_no_main(id_orig, &newid)) {
/* We copy contents of new ID to our CoW placeholder and free ID memory
* returned by id_copy().
@@ -505,7 +695,6 @@ ID *deg_expand_copy_on_write_datablock(const Depsgraph *depsgraph,
*/
const size_t size = BKE_libblock_get_alloc_info(GS(newid->name), NULL);
memcpy(id_cow, newid, size);
- MEM_freeN(newid);
done = true;
}
}
@@ -519,37 +708,62 @@ ID *deg_expand_copy_on_write_datablock(const Depsgraph *depsgraph,
#ifdef NESTED_ID_NASTY_WORKAROUND
ntree_hack_remap_pointers(depsgraph, id_cow);
#endif
-
+ /* Do it now, so remapping will understand that possibly remapped self ID
+ * is not to be remapped again.
+ */
+ deg_tag_copy_on_write_id(id_cow, id_orig);
+ /* Perform remapping of the nodes. */
+ RemapCallbackUserData user_data;
+ user_data.depsgraph = depsgraph;
+ user_data.temp_id = newid;
+ user_data.real_id = id_cow;
+ user_data.node_builder = node_builder;
+ user_data.create_placeholders = create_placeholders;
BKE_library_foreach_ID_link(NULL,
id_cow,
foreach_libblock_remap_callback,
- (void *)depsgraph,
+ (void *)&user_data,
IDWALK_NOP);
/* Correct or tweak some pointers which are not taken care by foreach
* from above.
*/
update_special_pointers(depsgraph, id_orig, id_cow);
+ /* Now we can safely discard temporary memory used for copying. */
+ if (newid != NULL) {
+ MEM_freeN(newid);
+ }
return id_cow;
}
/* NOTE: Depsgraph is supposed to have ID node already. */
-ID *deg_expand_copy_on_write_datablock(const Depsgraph *depsgraph, ID *id_orig)
+ID *deg_expand_copy_on_write_datablock(const Depsgraph *depsgraph,
+ ID *id_orig,
+ DepsgraphNodeBuilder *node_builder,
+ bool create_placeholders)
{
DEG::IDDepsNode *id_node = depsgraph->find_id_node(id_orig);
BLI_assert(id_node != NULL);
- return deg_expand_copy_on_write_datablock(depsgraph, id_node);
+ return deg_expand_copy_on_write_datablock(depsgraph,
+ id_node,
+ node_builder,
+ create_placeholders);
}
ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph,
const IDDepsNode *id_node)
{
const ID *id_orig = id_node->id_orig;
+ const ID_Type id_type = GS(id_orig->name);
ID *id_cow = id_node->id_cow;
+ /* Similar to expansion, no need to do anything here. */
+ if (!deg_copy_on_write_is_needed(id_orig)) {
+ return id_cow;
+ }
/* Special case for datablocks which are expanded at the dependency graph
* construction time. This datablocks must never change pointers of their
* nested data since it is used for function bindings.
*/
- if (GS(id_orig->name) == ID_SCE) {
+ if (check_datablock_expanded_at_construction(id_orig)) {
BLI_assert(check_datablock_expanded(id_cow) == true);
update_copy_on_write_datablock(depsgraph, id_orig, id_cow);
return id_cow;
@@ -557,14 +771,82 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph,
/* For the rest if datablock types we use simple logic:
* - Free previously expanded data, if any.
* - Perform full datablock copy.
+ *
+ * Note that we never free GPU materials from here since that's not
+ * safe for threading and GPU materials are likely to be re-used.
*/
+ ListBase gpumaterial_backup;
+ ListBase *gpumaterial_ptr = NULL;
+ Mesh *mesh_evaluated = NULL;
+ if (check_datablock_expanded(id_cow)) {
+ switch (id_type) {
+ case ID_MA:
+ {
+ Material *material = (Material *)id_cow;
+ gpumaterial_ptr = &material->gpumaterial;
+ break;
+ }
+ case ID_WO:
+ {
+ World *world = (World *)id_cow;
+ gpumaterial_ptr = &world->gpumaterial;
+ break;
+ }
+ case ID_OB:
+ {
+ Object *object = (Object *)id_cow;
+ /* Store evaluated mesh, make sure we don't free it. */
+ mesh_evaluated = object->mesh_evaluated;
+ object->mesh_evaluated = NULL;
+ /* Currently object update will override actual object->data
+ * to an evaluated version. Need to make sure we don't have
+ * data set to evaluated one before free anything.
+ */
+ if (mesh_evaluated != NULL) {
+ if (object->data == mesh_evaluated) {
+ object->data = mesh_evaluated->id.newid;
+ }
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ if (gpumaterial_ptr != NULL) {
+ gpumaterial_backup = *gpumaterial_ptr;
+ gpumaterial_ptr->first = gpumaterial_ptr->last = NULL;
+ }
+ }
deg_free_copy_on_write_datablock(id_cow);
deg_expand_copy_on_write_datablock(depsgraph, id_node);
+ /* Restore GPU materials. */
+ if (gpumaterial_ptr != NULL) {
+ *gpumaterial_ptr = gpumaterial_backup;
+ }
+ if (id_type == ID_OB) {
+ if (mesh_evaluated != NULL) {
+ Object *object = (Object *)id_cow;
+ object->mesh_evaluated = mesh_evaluated;
+ /* Do same thing as object update: override actual object data
+ * pointer with evaluated datablock.
+ */
+ if (object->type == OB_MESH) {
+ object->data = mesh_evaluated;
+ /* Evaluated mesh simply copied edit_btmesh pointer from
+ * original mesh during update, need to make sure no dead
+ * pointers are left behind.
+ */
+ mesh_evaluated->edit_btmesh =
+ ((Mesh *)mesh_evaluated->id.newid)->edit_btmesh;
+ }
+ }
+ }
return id_cow;
}
/* NOTE: Depsgraph is supposed to have ID node already. */
-ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph, ID *id_orig)
+ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph,
+ ID *id_orig)
{
DEG::IDDepsNode *id_node = depsgraph->find_id_node(id_orig);
BLI_assert(id_node != NULL);
@@ -584,7 +866,10 @@ void deg_free_copy_on_write_datablock(ID *id_cow)
*/
return;
}
- const short type = GS(id_cow->name);
+ const ID_Type type = GS(id_cow->name);
+#ifdef NESTED_ID_NASTY_WORKAROUND
+ nested_id_hack_discard_pointers(id_cow);
+#endif
switch (type) {
case ID_OB:
{
@@ -611,22 +896,22 @@ void deg_free_copy_on_write_datablock(ID *id_cow)
/* Special case for scene: we use explicit function call which
* ensures no access to other datablocks is done.
*/
- BKE_scene_free_ex((Scene *)id_cow, false);
+ Scene *scene = (Scene *)id_cow;
+ BKE_scene_free_ex(scene, false);
BKE_libblock_free_data(id_cow, false);
id_cow->name[0] = '\0';
return;
}
+ default:
+ break;
}
-#ifdef NESTED_ID_NASTY_WORKAROUND
- nested_id_hack_discard_pointers(id_cow);
-#endif
- BKE_libblock_free_datablock(id_cow);
+ BKE_libblock_free_datablock(id_cow, 0);
BKE_libblock_free_data(id_cow, false);
/* Signal datablock as not being expanded. */
id_cow->name[0] = '\0';
}
-void deg_evaluate_copy_on_write(EvaluationContext * /*eval_ctx*/,
+void deg_evaluate_copy_on_write(const EvaluationContext * /*eval_ctx*/,
const Depsgraph *depsgraph,
const IDDepsNode *id_node)
{
@@ -649,4 +934,22 @@ bool deg_validate_copy_on_write_datablock(ID *id_cow)
return data.is_valid;
}
+void deg_tag_copy_on_write_id(ID *id_cow, const ID *id_orig)
+{
+ id_cow->tag |= LIB_TAG_COPY_ON_WRITE;
+ /* TODO(sergey): Is it safe to re-use newid for original ID link? */
+ id_cow->newid = (ID *)id_orig;
+}
+
+bool deg_copy_on_write_is_expanded(const ID *id_cow)
+{
+ return check_datablock_expanded(id_cow);
+}
+
+bool deg_copy_on_write_is_needed(const ID *id_orig)
+{
+ const ID_Type id_type = GS(id_orig->name);
+ return !ELEM(id_type, ID_IM);
+}
+
} // namespace DEG
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h
index 0e1b6642002..a2b57cb7198 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h
+++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h
@@ -30,6 +30,8 @@
#pragma once
+#include <stddef.h>
+
struct EvaluationContext;
struct ID;
@@ -48,20 +50,25 @@ struct ID;
namespace DEG {
struct Depsgraph;
+struct DepsgraphNodeBuilder;
struct IDDepsNode;
/* Get fully expanded (ready for use) copy-on-write datablock for the given
* original datablock.
*/
-ID *deg_expand_copy_on_write_datablock(const Depsgraph *depsgraph,
- const IDDepsNode *id_node);
ID *deg_expand_copy_on_write_datablock(const struct Depsgraph *depsgraph,
- struct ID *id_orig);
+ const IDDepsNode *id_node,
+ DepsgraphNodeBuilder *node_builder = NULL,
+ bool create_placeholders = false);
+ID *deg_expand_copy_on_write_datablock(const struct Depsgraph *depsgraph,
+ struct ID *id_orig,
+ DepsgraphNodeBuilder *node_builder = NULL,
+ bool create_placeholders = false);
/* Makes sure given CoW datablock is brought back to state of the original
* datablock.
*/
-ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph,
+ID *deg_update_copy_on_write_datablock(const struct Depsgraph *depsgraph,
const IDDepsNode *id_node);
ID *deg_update_copy_on_write_datablock(const struct Depsgraph *depsgraph,
struct ID *id_orig);
@@ -72,7 +79,7 @@ void deg_free_copy_on_write_datablock(struct ID *id_cow);
/* Callback function for depsgraph operation node which ensures copy-on-write
* datablock is ready for use by further evaluation routines.
*/
-void deg_evaluate_copy_on_write(struct EvaluationContext *eval_ctx,
+void deg_evaluate_copy_on_write(const struct EvaluationContext *eval_ctx,
const struct Depsgraph *depsgraph,
const struct IDDepsNode *id_node);
@@ -81,4 +88,22 @@ void deg_evaluate_copy_on_write(struct EvaluationContext *eval_ctx,
*/
bool deg_validate_copy_on_write_datablock(ID *id_cow);
+/* Tag given ID block as being copy-on-wtritten. */
+void deg_tag_copy_on_write_id(struct ID *id_cow, const struct ID *id_orig);
+
+/* Check whether ID datablock is expanded.
+ *
+ * TODO(sergey): Make it an inline function or a macro.
+ */
+bool deg_copy_on_write_is_expanded(const struct ID *id_cow);
+
+/* Check whether copy-on-write datablock is needed for given ID.
+ *
+ * There are some exceptions on datablocks which are covered by dependency graph
+ * but which we don't want to start duplicating.
+ *
+ * This includes images.
+ */
+bool deg_copy_on_write_is_needed(const ID *id_orig);
+
} // namespace DEG
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
index 605ca990e07..54a3a499e36 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
@@ -50,26 +50,16 @@ extern "C" {
#include "intern/nodes/deg_node_operation.h"
#include "intern/depsgraph_intern.h"
+#include "intern/eval/deg_eval_copy_on_write.h"
#include "util/deg_util_foreach.h"
namespace DEG {
-namespace {
-
-// TODO(sergey): De-duplicate with depsgraph_tag,cc
-void lib_id_recalc_tag(Main *bmain, ID *id)
-{
- id->tag |= LIB_TAG_ID_RECALC;
- DEG_id_type_tag(bmain, GS(id->name));
-}
-
-void lib_id_recalc_data_tag(Main *bmain, ID *id)
-{
- id->tag |= LIB_TAG_ID_RECALC_DATA;
- DEG_id_type_tag(bmain, GS(id->name));
-}
-
-} /* namespace */
+enum {
+ COMPONENT_STATE_NONE = 0,
+ COMPONENT_STATE_SCHEDULED = 1,
+ COMPONENT_STATE_DONE = 2,
+};
typedef std::deque<OperationDepsNode *> FlushQueue;
@@ -83,7 +73,7 @@ static void flush_init_func(void *data_v, int i)
ComponentDepsNode *comp_node = node->owner;
IDDepsNode *id_node = comp_node->owner;
id_node->done = 0;
- comp_node->done = 0;
+ comp_node->done = COMPONENT_STATE_NONE;
node->scheduled = false;
}
@@ -122,10 +112,8 @@ void deg_graph_flush_updates(Main *bmain, Depsgraph *graph)
*/
GSET_FOREACH_BEGIN(OperationDepsNode *, op_node, graph->entry_tags)
{
- if ((op_node->flag & DEPSOP_FLAG_SKIP_FLUSH) == 0) {
- queue.push_back(op_node);
- op_node->scheduled = true;
- }
+ queue.push_back(op_node);
+ op_node->scheduled = true;
}
GSET_FOREACH_END();
@@ -141,34 +129,51 @@ void deg_graph_flush_updates(Main *bmain, Depsgraph *graph)
IDDepsNode *id_node = comp_node->owner;
/* TODO(sergey): Do we need to pass original or evaluated ID here? */
- ID *id = id_node->id_orig;
+ ID *id_orig = id_node->id_orig;
+ ID *id_cow = id_node->id_cow;
if (id_node->done == 0) {
- deg_editors_id_update(bmain, id);
- lib_id_recalc_tag(bmain, id);
+ /* Copy tag from original data to CoW storage.
+ * This is because DEG_id_tag_update() sets tags on original
+ * data.
+ */
+ id_cow->tag |= (id_orig->tag & LIB_TAG_ID_RECALC_ALL);
+ if (deg_copy_on_write_is_expanded(id_cow)) {
+ deg_editors_id_update(bmain, id_cow);
+ }
+ lib_id_recalc_tag(bmain, id_orig);
/* TODO(sergey): For until we've got proper data nodes in the graph. */
- lib_id_recalc_data_tag(bmain, id);
+ lib_id_recalc_data_tag(bmain, id_orig);
+ }
+ if (comp_node->done != COMPONENT_STATE_DONE) {
#ifdef WITH_COPY_ON_WRITE
/* Currently this is needed to get ob->mesh to be replaced with
* original mesh (rather than being evaluated_mesh).
*
* TODO(sergey): This is something we need to avoid.
*/
- ComponentDepsNode *cow_comp =
- id_node->find_component(DEG_NODE_TYPE_COPY_ON_WRITE);
- cow_comp->tag_update(graph);
+ if (comp_node->depends_on_cow()) {
+ ComponentDepsNode *cow_comp =
+ id_node->find_component(DEG_NODE_TYPE_COPY_ON_WRITE);
+ cow_comp->tag_update(graph);
+ }
#endif
- }
-
- if (comp_node->done == 0) {
Object *object = NULL;
- if (GS(id->name) == ID_OB) {
- object = (Object *)id;
+ if (GS(id_orig->name) == ID_OB) {
+ object = (Object *)id_orig;
if (id_node->done == 0) {
++num_flushed_objects;
}
}
foreach (OperationDepsNode *op, comp_node->operations) {
+ /* We don't want to flush tags in "upstream" direction for
+ * certain types of operations.
+ *
+ * TODO(sergey): Need a more generic solution for this.
+ */
+ if (op->opcode == DEG_OPCODE_PARTICLE_SETTINGS_EVAL) {
+ continue;
+ }
op->flag |= DEPSOP_FLAG_NEEDS_UPDATE;
}
if (object != NULL) {
@@ -204,15 +209,29 @@ void deg_graph_flush_updates(Main *bmain, Depsgraph *graph)
case DEG_NODE_TYPE_PROXY:
object->recalc |= OB_RECALC_DATA;
break;
+ case DEG_NODE_TYPE_SHADING_PARAMETERS:
+ break;
}
/* TODO : replace with more granular flags */
object->deg_update_flag |= DEG_RUNTIME_DATA_UPDATE;
}
+ /* When some target changes bone, we might need to re-run the
+ * whole IK solver, otherwise result might be unpredictable.
+ */
+ if (comp_node->type == DEG_NODE_TYPE_BONE) {
+ ComponentDepsNode *pose_comp =
+ id_node->find_component(DEG_NODE_TYPE_EVAL_POSE);
+ BLI_assert(pose_comp != NULL);
+ if (pose_comp->done == COMPONENT_STATE_NONE) {
+ queue.push_front(pose_comp->get_entry_operation());
+ pose_comp->done = COMPONENT_STATE_SCHEDULED;
+ }
+ }
}
id_node->done = 1;
- comp_node->done = 1;
+ comp_node->done = COMPONENT_STATE_DONE;
/* Flush to nodes along links... */
/* TODO(sergey): This is mainly giving speedup due ot less queue pushes, which
diff --git a/source/blender/depsgraph/intern/nodes/deg_node.cc b/source/blender/depsgraph/intern/nodes/deg_node.cc
index 548911dcfa9..5e7ed249365 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node.cc
+++ b/source/blender/depsgraph/intern/nodes/deg_node.cc
@@ -128,8 +128,8 @@ IDDepsNode::ComponentIDKey::ComponentIDKey(eDepsNode_Type type,
bool IDDepsNode::ComponentIDKey::operator== (const ComponentIDKey &other) const
{
- return type == other.type &&
- STREQ(name, other.name);
+ return type == other.type &&
+ STREQ(name, other.name);
}
static unsigned int id_deps_node_hash_key(const void *key_v)
@@ -165,24 +165,43 @@ static void id_deps_node_hash_value_free(void *value_v)
/* Initialize 'id' node - from pointer data given. */
void IDDepsNode::init(const ID *id, const char *UNUSED(subdata))
{
- /* Store ID-pointer. */
BLI_assert(id != NULL);
- this->id_orig = (ID *)id;
- this->eval_flags = 0;
+ /* Store ID-pointer. */
+ id_orig = (ID *)id;
+ eval_flags = 0;
components = BLI_ghash_new(id_deps_node_hash_key,
id_deps_node_hash_key_cmp,
"Depsgraph id components hash");
+}
+void IDDepsNode::init_copy_on_write(ID *id_cow_hint)
+{
#ifdef WITH_COPY_ON_WRITE
/* Create pointer as early as possible, so we can use it for function
* bindings. Rest of data we'll be copying to the new datablock when
* it is actually needed.
*/
- id_cow = (ID *)BKE_libblock_alloc_notest(GS(id->name));
- DEG_COW_PRINT("Create shallow copy for %s: id_orig=%p id_cow=%p\n",
- id_orig->name, id_orig, id_cow);
+ if (id_cow_hint != NULL) {
+ // BLI_assert(deg_copy_on_write_is_needed(id_orig));
+ if (deg_copy_on_write_is_needed(id_orig)) {
+ id_cow = id_cow_hint;
+ }
+ else {
+ id_cow = id_orig;
+ }
+ }
+ else if (deg_copy_on_write_is_needed(id_orig)) {
+ id_cow = (ID *)BKE_libblock_alloc_notest(GS(id_orig->name));
+ DEG_COW_PRINT("Create shallow copy for %s: id_orig=%p id_cow=%p\n",
+ id_orig->name, id_orig, id_cow);
+ deg_tag_copy_on_write_id(id_cow, id_orig);
+ }
+ else {
+ id_cow = id_orig;
+ }
#else
+ UNUSED_VARS(id_cow_hint);
id_cow = id_orig;
#endif
}
@@ -190,17 +209,30 @@ void IDDepsNode::init(const ID *id, const char *UNUSED(subdata))
/* Free 'id' node. */
IDDepsNode::~IDDepsNode()
{
+ destroy();
+}
+
+void IDDepsNode::destroy()
+{
+ if (id_orig == NULL) {
+ return;
+ }
+
BLI_ghash_free(components,
id_deps_node_hash_key_free,
id_deps_node_hash_value_free);
#ifdef WITH_COPY_ON_WRITE
/* Free memory used by this CoW ID. */
- deg_free_copy_on_write_datablock(id_cow);
- MEM_freeN(id_cow);
- DEG_COW_PRINT("Destroy CoW for %s: id_orig=%p id_cow=%p\n",
- id_orig->name, id_orig, id_cow);
+ if (id_cow != id_orig && id_cow != NULL) {
+ deg_free_copy_on_write_datablock(id_cow);
+ MEM_freeN(id_cow);
+ DEG_COW_PRINT("Destroy CoW for %s: id_orig=%p id_cow=%p\n",
+ id_orig->name, id_orig, id_cow);
+ }
#endif
+ /* Tag that the node is freed. */
+ id_orig = NULL;
}
ComponentDepsNode *IDDepsNode::find_component(eDepsNode_Type type,
@@ -239,6 +271,23 @@ void IDDepsNode::tag_update(Depsgraph *graph)
do_component_tag = true;
}
}
+ else if (comp_node->type == DEG_NODE_TYPE_SHADING) {
+ /* TODO(sergey): For until we properly handle granular flags for DEG_id_tag_update()
+ * we skip flushing here to keep Luca happy.
+ */
+ if (GS(id_orig->name) != ID_MA &&
+ GS(id_orig->name) != ID_WO)
+ {
+ do_component_tag = false;
+ }
+ }
+ else if (comp_node->type == DEG_NODE_TYPE_SHADING_PARAMETERS) {
+ do_component_tag = false;
+ }
+ else if (comp_node->type == DEG_NODE_TYPE_EVAL_PARTICLES) {
+ /* Only do explicit particle settings tagging. */
+ do_component_tag = false;
+ }
if (do_component_tag) {
comp_node->tag_update(graph);
}
diff --git a/source/blender/depsgraph/intern/nodes/deg_node.h b/source/blender/depsgraph/intern/nodes/deg_node.h
index 4e03072d486..16e75b2b5e7 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node.h
+++ b/source/blender/depsgraph/intern/nodes/deg_node.h
@@ -138,7 +138,9 @@ struct IDDepsNode : public DepsNode {
};
void init(const ID *id, const char *subdata);
+ void init_copy_on_write(ID *id_cow_hint = NULL);
~IDDepsNode();
+ void destroy();
ComponentDepsNode *find_component(eDepsNode_Type type,
const char *name = "") const;
diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.cc b/source/blender/depsgraph/intern/nodes/deg_node_component.cc
index bd9583a7b67..a250dce1239 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node_component.cc
+++ b/source/blender/depsgraph/intern/nodes/deg_node_component.cc
@@ -396,6 +396,11 @@ static DepsNodeFactoryImpl<ParticlesComponentDepsNode> DNTI_EVAL_PARTICLES;
DEG_DEPSNODE_DEFINE(ShadingComponentDepsNode, DEG_NODE_TYPE_SHADING, "Shading Component");
static DepsNodeFactoryImpl<ShadingComponentDepsNode> DNTI_SHADING;
+/* Shading Parameters Component Defines ============================ */
+
+DEG_DEPSNODE_DEFINE(ShadingParametersComponentDepsNode, DEG_NODE_TYPE_SHADING_PARAMETERS, "Shading Parameters Component");
+static DepsNodeFactoryImpl<ShadingParametersComponentDepsNode> DNTI_SHADING_PARAMETERS;
+
/* Cache Component Defines ============================ */
DEG_DEPSNODE_DEFINE(CacheComponentDepsNode, DEG_NODE_TYPE_CACHE, "Cache Component");
@@ -426,7 +431,9 @@ void deg_register_component_depsnodes()
deg_register_node_typeinfo(&DNTI_BONE);
deg_register_node_typeinfo(&DNTI_EVAL_PARTICLES);
+
deg_register_node_typeinfo(&DNTI_SHADING);
+ deg_register_node_typeinfo(&DNTI_SHADING_PARAMETERS);
deg_register_node_typeinfo(&DNTI_CACHE);
diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.h b/source/blender/depsgraph/intern/nodes/deg_node_component.h
index 955d197b33a..d2a375421fd 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node_component.h
+++ b/source/blender/depsgraph/intern/nodes/deg_node_component.h
@@ -151,6 +151,7 @@ struct ComponentDepsNode : public DepsNode {
OperationDepsNode *exit_operation;
// XXX: a poll() callback to check if component's first node can be started?
+ virtual bool depends_on_cow() { return true; }
};
/* ---------------------------------------- */
@@ -200,6 +201,11 @@ struct ShadingComponentDepsNode : public ComponentDepsNode {
DEG_DEPSNODE_DECLARE;
};
+struct ShadingParametersComponentDepsNode : public ComponentDepsNode {
+ DEG_DEPSNODE_DECLARE;
+ virtual bool depends_on_cow() { return false; }
+};
+
struct CacheComponentDepsNode : public ComponentDepsNode {
DEG_DEPSNODE_DECLARE;
};
@@ -210,6 +216,8 @@ struct LayerCollectionsDepsNode : public ComponentDepsNode {
struct CopyOnWriteDepsNode : public ComponentDepsNode {
DEG_DEPSNODE_DECLARE;
+
+ virtual bool depends_on_cow() { return false; }
};
diff --git a/source/blender/depsgraph/intern/nodes/deg_node_operation.cc b/source/blender/depsgraph/intern/nodes/deg_node_operation.cc
index 84b3d33f494..7467264f612 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node_operation.cc
+++ b/source/blender/depsgraph/intern/nodes/deg_node_operation.cc
@@ -76,9 +76,6 @@ string OperationDepsNode::full_identifier() const
void OperationDepsNode::tag_update(Depsgraph *graph)
{
- if (flag & DEPSOP_FLAG_SKIP_FLUSH) {
- flag &= ~DEPSOP_FLAG_SKIP_FLUSH;
- }
if (flag & DEPSOP_FLAG_NEEDS_UPDATE) {
return;
}
diff --git a/source/blender/depsgraph/intern/nodes/deg_node_operation.h b/source/blender/depsgraph/intern/nodes/deg_node_operation.h
index 8a1fadd9c6c..d8203540fc5 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node_operation.h
+++ b/source/blender/depsgraph/intern/nodes/deg_node_operation.h
@@ -45,16 +45,6 @@ typedef enum eDepsOperation_Flag {
/* node was directly modified, causing need for update */
DEPSOP_FLAG_DIRECTLY_MODIFIED = (1 << 1),
-
- /* Operation is evaluated using CPython; has GIL and security
- * implications...
- */
- DEPSOP_FLAG_USES_PYTHON = (1 << 2),
-
- /* Special flag which indicates that update tag sohuld not be flushed
- * up to the dependent nodes.
- */
- DEPSOP_FLAG_SKIP_FLUSH = (1 << 3),
} eDepsOperation_Flag;
/* Atomic Operation - Base type for all operations */
diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt
index eb3a016f295..64edd76c257 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -63,6 +63,7 @@ set(SRC
intern/draw_common.c
intern/draw_manager.c
intern/draw_manager_text.c
+ intern/draw_manager_profiling.c
intern/draw_view.c
modes/edit_armature_mode.c
modes/edit_curve_mode.c
@@ -94,6 +95,7 @@ set(SRC
intern/draw_cache_impl.h
intern/draw_common.h
intern/draw_manager_text.h
+ intern/draw_manager_profiling.h
intern/draw_view.h
modes/draw_mode_engines.h
engines/basic/basic_engine.h
@@ -115,11 +117,13 @@ data_to_c_simple(engines/clay/shaders/clay_particle_strand_frag.glsl SRC)
data_to_c_simple(engines/clay/shaders/ssao_alchemy.glsl SRC)
data_to_c_simple(engines/clay/shaders/ssao_groundtruth.glsl SRC)
+data_to_c_simple(engines/eevee/shaders/ambient_occlusion_lib.glsl SRC)
data_to_c_simple(engines/eevee/shaders/default_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/default_world_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/background_vert.glsl SRC)
-data_to_c_simple(engines/eevee/shaders/ambient_occlusion_lib.glsl SRC)
-data_to_c_simple(engines/eevee/shaders/effect_minmaxz_frag.glsl SRC)
+data_to_c_simple(engines/eevee/shaders/concentric_samples_lib.glsl SRC)
+data_to_c_simple(engines/eevee/shaders/lamps_lib.glsl SRC)
+data_to_c_simple(engines/eevee/shaders/lightprobe_lib.glsl SRC)
data_to_c_simple(engines/eevee/shaders/lightprobe_filter_glossy_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/lightprobe_filter_diffuse_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/lightprobe_geom.glsl SRC)
@@ -128,6 +132,7 @@ data_to_c_simple(engines/eevee/shaders/lightprobe_cube_display_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/lightprobe_cube_display_vert.glsl SRC)
data_to_c_simple(engines/eevee/shaders/lightprobe_grid_display_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/lightprobe_grid_display_vert.glsl SRC)
+data_to_c_simple(engines/eevee/shaders/lightprobe_grid_fill_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/lightprobe_planar_display_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/lightprobe_planar_display_vert.glsl SRC)
data_to_c_simple(engines/eevee/shaders/lit_surface_frag.glsl SRC)
@@ -136,24 +141,37 @@ data_to_c_simple(engines/eevee/shaders/effect_bloom_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/effect_dof_vert.glsl SRC)
data_to_c_simple(engines/eevee/shaders/effect_dof_geom.glsl SRC)
data_to_c_simple(engines/eevee/shaders/effect_dof_frag.glsl SRC)
+data_to_c_simple(engines/eevee/shaders/effect_downsample_frag.glsl SRC)
+data_to_c_simple(engines/eevee/shaders/effect_downsample_cube_frag.glsl SRC)
+data_to_c_simple(engines/eevee/shaders/effect_gtao_frag.glsl SRC)
+data_to_c_simple(engines/eevee/shaders/effect_minmaxz_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/effect_motion_blur_frag.glsl SRC)
+data_to_c_simple(engines/eevee/shaders/effect_ssr_frag.glsl SRC)
+data_to_c_simple(engines/eevee/shaders/effect_temporal_aa.glsl SRC)
+data_to_c_simple(engines/eevee/shaders/lightprobe_planar_downsample_frag.glsl SRC)
+data_to_c_simple(engines/eevee/shaders/lightprobe_planar_downsample_geom.glsl SRC)
+data_to_c_simple(engines/eevee/shaders/lightprobe_planar_downsample_vert.glsl SRC)
data_to_c_simple(engines/eevee/shaders/prepass_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/prepass_vert.glsl SRC)
data_to_c_simple(engines/eevee/shaders/shadow_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/shadow_geom.glsl SRC)
data_to_c_simple(engines/eevee/shaders/shadow_vert.glsl SRC)
data_to_c_simple(engines/eevee/shaders/shadow_store_frag.glsl SRC)
-data_to_c_simple(engines/eevee/shaders/shadow_store_geom.glsl SRC)
-data_to_c_simple(engines/eevee/shaders/shadow_store_vert.glsl SRC)
+data_to_c_simple(engines/eevee/shaders/shadow_copy_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/bsdf_lut_frag.glsl SRC)
+data_to_c_simple(engines/eevee/shaders/btdf_lut_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/bsdf_direct_lib.glsl SRC)
data_to_c_simple(engines/eevee/shaders/bsdf_common_lib.glsl SRC)
data_to_c_simple(engines/eevee/shaders/irradiance_lib.glsl SRC)
data_to_c_simple(engines/eevee/shaders/octahedron_lib.glsl SRC)
data_to_c_simple(engines/eevee/shaders/bsdf_sampling_lib.glsl SRC)
+data_to_c_simple(engines/eevee/shaders/raytrace_lib.glsl SRC)
data_to_c_simple(engines/eevee/shaders/ltc_lib.glsl SRC)
+data_to_c_simple(engines/eevee/shaders/ssr_lib.glsl SRC)
+data_to_c_simple(engines/eevee/shaders/volumetric_frag.glsl SRC)
data_to_c_simple(modes/shaders/common_globals_lib.glsl SRC)
+data_to_c_simple(modes/shaders/common_fxaa_lib.glsl SRC)
data_to_c_simple(modes/shaders/edit_mesh_overlay_frag.glsl SRC)
data_to_c_simple(modes/shaders/edit_mesh_overlay_vert.glsl SRC)
data_to_c_simple(modes/shaders/edit_mesh_overlay_geom_tri.glsl SRC)
@@ -177,6 +195,7 @@ data_to_c_simple(modes/shaders/object_outline_expand_frag.glsl SRC)
data_to_c_simple(modes/shaders/object_outline_detect_frag.glsl SRC)
data_to_c_simple(modes/shaders/object_grid_frag.glsl SRC)
data_to_c_simple(modes/shaders/object_grid_vert.glsl SRC)
+data_to_c_simple(modes/shaders/object_lightprobe_grid_vert.glsl SRC)
data_to_c_simple(modes/shaders/object_particle_prim_vert.glsl SRC)
data_to_c_simple(modes/shaders/object_particle_prim_frag.glsl SRC)
data_to_c_simple(modes/shaders/object_particle_dot_vert.glsl SRC)
diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h
index b780e86b9ec..646d8716094 100644
--- a/source/blender/draw/DRW_engine.h
+++ b/source/blender/draw/DRW_engine.h
@@ -48,11 +48,14 @@ struct GPUOffScreen;
/* Buffer and textures used by the viewport by default */
typedef struct DefaultFramebufferList {
struct GPUFrameBuffer *default_fb;
+ struct GPUFrameBuffer *multisample_fb;
} DefaultFramebufferList;
typedef struct DefaultTextureList {
struct GPUTexture *color;
struct GPUTexture *depth;
+ struct GPUTexture *multisample_color;
+ struct GPUTexture *multisample_depth;
} DefaultTextureList;
void DRW_engines_register(void);
@@ -63,6 +66,8 @@ void DRW_engine_viewport_data_size_get(
const void *engine_type,
int *r_fbl_len, int *r_txl_len, int *r_psl_len, int *r_stl_len);
+void DRW_notify_view_update(const struct bContext *C);
+
void DRW_draw_view(const struct bContext *C);
void DRW_draw_render_loop_ex(
diff --git a/source/blender/draw/engines/basic/basic_engine.c b/source/blender/draw/engines/basic/basic_engine.c
index d1afb0b4a1e..16678beec4d 100644
--- a/source/blender/draw/engines/basic/basic_engine.c
+++ b/source/blender/draw/engines/basic/basic_engine.c
@@ -19,7 +19,7 @@
*
*/
-/** \file basic_engine.h
+/** \file basic_engine.c
* \ingroup draw_engine
*
* Simple engine for drawing color and/or depth.
@@ -206,21 +206,42 @@ static void BASIC_draw_scene(void *vedata)
BASIC_PassList *psl = ((BASIC_Data *)vedata)->psl;
BASIC_FramebufferList *fbl = ((BASIC_Data *)vedata)->fbl;
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
+ const bool is_select = DRW_state_is_select();
+
+ bool use_color = true;
+ bool use_depth = true;
+ bool use_depth_cull = true;
+
+ if (is_select) {
+ /* Needed for depth-picking,
+ * for other selection types there are no need for extra passes either. */
+ use_color = false;
+ use_depth_cull = false;
+ }
#ifdef USE_DEPTH
/* Pass 1 : Depth pre-pass */
- DRW_draw_pass(psl->depth_pass);
- DRW_draw_pass(psl->depth_pass_cull);
+ if (use_depth) {
+ DRW_draw_pass(psl->depth_pass);
+ }
+
+ if (use_depth_cull) {
+ DRW_draw_pass(psl->depth_pass_cull);
+ }
/* Pass 2 : Duplicate depth */
- /* Unless we go for deferred shading we need this to avoid manual depth test and artifacts */
- if (DRW_state_is_fbo()) {
- DRW_framebuffer_blit(dfbl->default_fb, fbl->dupli_depth, true);
+ if (use_depth || use_depth_cull) {
+ /* Unless we go for deferred shading we need this to avoid manual depth test and artifacts */
+ if (DRW_state_is_fbo()) {
+ DRW_framebuffer_blit(dfbl->default_fb, fbl->dupli_depth, true);
+ }
}
#endif
/* Pass 3 : Shading */
- DRW_draw_pass(psl->color_pass);
+ if (use_color) {
+ DRW_draw_pass(psl->color_pass);
+ }
}
static void BASIC_engine_free(void)
@@ -240,7 +261,8 @@ DrawEngineType draw_engine_basic_type = {
&BASIC_cache_populate,
&BASIC_cache_finish,
NULL,
- &BASIC_draw_scene
+ &BASIC_draw_scene,
+ NULL,
};
/* Note: currently unused, we may want to register so we can see this when debugging the view. */
diff --git a/source/blender/draw/engines/clay/clay_engine.c b/source/blender/draw/engines/clay/clay_engine.c
index f39438e660c..937cf7579c6 100644
--- a/source/blender/draw/engines/clay/clay_engine.c
+++ b/source/blender/draw/engines/clay/clay_engine.c
@@ -40,9 +40,10 @@
#include "UI_interface_icons.h"
#include "clay_engine.h"
-#include "../eevee/eevee_lut.h" /* TODO find somewhere to share blue noise Table */
#ifdef WITH_CLAY_ENGINE
+#include "../eevee/eevee_lut.h" /* TODO find somewhere to share blue noise Table */
+
/* Shaders */
#define CLAY_ENGINE "BLENDER_CLAY"
@@ -276,19 +277,6 @@ static int matcap_to_index(int matcap)
return 0;
}
-/* Van der Corput sequence */
-/* TODO this is duplicated code from eevee_lightprobes.c */
- /* From http://holger.dammertz.org/stuff/notes_HammersleyOnHemisphere.html */
-static float radical_inverse(int i) {
- unsigned int bits = (unsigned int)i;
- bits = (bits << 16u) | (bits >> 16u);
- bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
- bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
- bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
- bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
- return (float)bits * 2.3283064365386963e-10f;
-}
-
/* Using Hammersley distribution */
static float *create_disk_samples(int num_samples)
{
@@ -298,7 +286,10 @@ static float *create_disk_samples(int num_samples)
for (int i = 0; i < num_samples; i++) {
float r = (i + 0.5f) * num_samples_inv;
- float phi = radical_inverse(i) * 2.0f * M_PI;
+ double dphi;
+ BLI_hammersley_1D(i, &dphi);
+
+ float phi = (float)dphi * 2.0f * M_PI;
texels[i][0] = cosf(phi);
texels[i][1] = sinf(phi);
/* This deliberatly distribute more samples
@@ -325,7 +316,7 @@ static struct GPUTexture *create_jitter_texture(int num_samples)
jitter[i][2] = bn * num_samples_inv;
}
- UNUSED_VARS(bsdf_split_sum_ggx, ltc_mag_ggx, ltc_mat_ggx);
+ UNUSED_VARS(bsdf_split_sum_ggx, btdf_split_sum_ggx, ltc_mag_ggx, ltc_mat_ggx);
return DRW_texture_create_2D(64, 64, DRW_TEX_RGB_16, DRW_TEX_FILTER | DRW_TEX_WRAP, &jitter[0][0]);
}
@@ -432,7 +423,7 @@ static void CLAY_engine_init(void *vedata)
/* SSAO setup */
{
const DRWContextState *draw_ctx = DRW_context_state_get();
- SceneLayer *scene_layer = draw_ctx->sl;
+ SceneLayer *scene_layer = draw_ctx->scene_layer;
IDProperty *props = BKE_scene_layer_engine_evaluated_get(
scene_layer, COLLECTION_MODE_NONE, RE_engine_id_BLENDER_CLAY);
int ssao_samples = BKE_collection_engine_property_value_get_int(props, "ssao_samples");
@@ -502,8 +493,9 @@ static void CLAY_engine_init(void *vedata)
}
}
-static DRWShadingGroup *CLAY_shgroup_create(CLAY_Data *UNUSED(vedata), DRWPass *pass, int *material_id, bool use_flat)
+static DRWShadingGroup *CLAY_shgroup_create(CLAY_Data *vedata, DRWPass *pass, int *material_id, bool use_flat)
{
+ CLAY_StorageList *stl = vedata->stl;
CLAY_SceneLayerData *sldata = CLAY_scene_layer_data_get();
DRWShadingGroup *grp = DRW_shgroup_create(use_flat ? e_data.clay_flat_sh : e_data.clay_sh, pass);
@@ -519,16 +511,19 @@ static DRWShadingGroup *CLAY_shgroup_create(CLAY_Data *UNUSED(vedata), DRWPass *
DRW_shgroup_uniform_texture(grp, "ssao_jitter", sldata->jitter_tx);
DRW_shgroup_uniform_block(grp, "samples_block", sldata->sampling_ubo);
+ DRW_shgroup_uniform_block(grp, "material_block", stl->mat_ubo);
return grp;
}
-static DRWShadingGroup *CLAY_hair_shgroup_create(DRWPass *pass, int *material_id)
+static DRWShadingGroup *CLAY_hair_shgroup_create(CLAY_Data *vedata, DRWPass *pass, int *material_id)
{
+ CLAY_StorageList *stl = vedata->stl;
DRWShadingGroup *grp = DRW_shgroup_create(e_data.hair_sh, pass);
DRW_shgroup_uniform_texture(grp, "matcaps", e_data.matcap_array);
DRW_shgroup_uniform_int(grp, "mat_id", material_id, 1);
+ DRW_shgroup_uniform_block(grp, "material_block", stl->mat_ubo);
return grp;
}
@@ -678,16 +673,12 @@ static DRWShadingGroup *CLAY_object_shgrp_get(
if (shgrps[id] == NULL) {
shgrps[id] = CLAY_shgroup_create(
vedata, use_flat ? psl->clay_pass_flat : psl->clay_pass, &e_data.ubo_mat_idxs[id], use_flat);
- /* if it's the first shgrp, pass bind the material UBO */
- if (stl->storage->ubo_current_id == 1) {
- DRW_shgroup_uniform_block(shgrps[0], "material_block", stl->mat_ubo);
- }
}
return shgrps[id];
}
-static DRWShadingGroup *CLAY_hair_shgrp_get(Object *ob, CLAY_StorageList *stl, CLAY_PassList *psl)
+static DRWShadingGroup *CLAY_hair_shgrp_get(CLAY_Data *vedata, Object *ob, CLAY_StorageList *stl, CLAY_PassList *psl)
{
DRWShadingGroup **hair_shgrps = stl->storage->hair_shgrps;
@@ -697,11 +688,7 @@ static DRWShadingGroup *CLAY_hair_shgrp_get(Object *ob, CLAY_StorageList *stl, C
int hair_id = hair_mat_in_ubo(stl->storage, &hair_mat_ubo_test);
if (hair_shgrps[hair_id] == NULL) {
- hair_shgrps[hair_id] = CLAY_hair_shgroup_create(psl->hair_pass, &e_data.ubo_mat_idxs[hair_id]);
- /* if it's the first shgrp, pass bind the material UBO */
- if (stl->storage->hair_ubo_current_id == 1) {
- DRW_shgroup_uniform_block(hair_shgrps[0], "material_block", stl->hair_mat_ubo);
- }
+ hair_shgrps[hair_id] = CLAY_hair_shgroup_create(vedata, psl->hair_pass, &e_data.ubo_mat_idxs[hair_id]);
}
return hair_shgrps[hair_id];
@@ -771,7 +758,7 @@ static void CLAY_cache_populate(void *vedata, Object *ob)
const DRWContextState *draw_ctx = DRW_context_state_get();
const bool is_active = (ob == draw_ctx->obact);
if (is_active) {
- if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) {
+ if (DRW_object_is_mode_shade(ob) == true) {
return;
}
}
@@ -828,8 +815,8 @@ static void CLAY_cache_populate(void *vedata, Object *ob)
unit_m4(mat);
if (draw_as == PART_DRAW_PATH) {
- geom = DRW_cache_particles_get_hair(psys);
- hair_shgrp = CLAY_hair_shgrp_get(ob, stl, psl);
+ geom = DRW_cache_particles_get_hair(psys, NULL);
+ hair_shgrp = CLAY_hair_shgrp_get(vedata, ob, stl, psl);
DRW_shgroup_call_add(hair_shgrp, geom, mat);
}
}
@@ -926,7 +913,8 @@ DrawEngineType draw_engine_clay_type = {
&CLAY_cache_populate,
&CLAY_cache_finish,
NULL,
- &CLAY_draw_scene
+ &CLAY_draw_scene,
+ NULL,
};
RenderEngineType DRW_engine_viewport_clay_type = {
diff --git a/source/blender/draw/engines/eevee/eevee_data.c b/source/blender/draw/engines/eevee/eevee_data.c
index 8893a8c62e9..92a992f578b 100644
--- a/source/blender/draw/engines/eevee/eevee_data.c
+++ b/source/blender/draw/engines/eevee/eevee_data.c
@@ -39,15 +39,13 @@ static void eevee_scene_layer_data_free(void *storage)
DRW_UBO_FREE_SAFE(sldata->light_ubo);
DRW_UBO_FREE_SAFE(sldata->shadow_ubo);
DRW_UBO_FREE_SAFE(sldata->shadow_render_ubo);
- DRW_FRAMEBUFFER_FREE_SAFE(sldata->shadow_cube_target_fb);
- DRW_FRAMEBUFFER_FREE_SAFE(sldata->shadow_cube_fb);
- DRW_FRAMEBUFFER_FREE_SAFE(sldata->shadow_map_fb);
- DRW_FRAMEBUFFER_FREE_SAFE(sldata->shadow_cascade_fb);
- DRW_TEXTURE_FREE_SAFE(sldata->shadow_depth_cube_target);
- DRW_TEXTURE_FREE_SAFE(sldata->shadow_color_cube_target);
- DRW_TEXTURE_FREE_SAFE(sldata->shadow_depth_cube_pool);
- DRW_TEXTURE_FREE_SAFE(sldata->shadow_depth_map_pool);
- DRW_TEXTURE_FREE_SAFE(sldata->shadow_depth_cascade_pool);
+ DRW_FRAMEBUFFER_FREE_SAFE(sldata->shadow_target_fb);
+ DRW_FRAMEBUFFER_FREE_SAFE(sldata->shadow_store_fb);
+ DRW_TEXTURE_FREE_SAFE(sldata->shadow_cube_target);
+ DRW_TEXTURE_FREE_SAFE(sldata->shadow_cube_blur);
+ DRW_TEXTURE_FREE_SAFE(sldata->shadow_cascade_target);
+ DRW_TEXTURE_FREE_SAFE(sldata->shadow_cascade_blur);
+ DRW_TEXTURE_FREE_SAFE(sldata->shadow_pool);
BLI_freelistN(&sldata->shadow_casters);
/* Probes */
@@ -61,6 +59,9 @@ static void eevee_scene_layer_data_free(void *storage)
DRW_TEXTURE_FREE_SAFE(sldata->probe_pool);
DRW_TEXTURE_FREE_SAFE(sldata->irradiance_pool);
DRW_TEXTURE_FREE_SAFE(sldata->irradiance_rt);
+
+ /* Volumetrics */
+ MEM_SAFE_FREE(sldata->volumetrics);
}
static void eevee_lamp_data_free(void *storage)
diff --git a/source/blender/draw/engines/eevee/eevee_effects.c b/source/blender/draw/engines/eevee/eevee_effects.c
index 4191c21eea1..13d141bf4bf 100644
--- a/source/blender/draw/engines/eevee/eevee_effects.c
+++ b/source/blender/draw/engines/eevee/eevee_effects.c
@@ -32,29 +32,51 @@
#include "DNA_camera_types.h"
#include "DNA_screen_types.h"
#include "DNA_view3d_types.h"
+#include "DNA_world_types.h"
+#include "BKE_global.h" /* for G.debug_value */
#include "BKE_camera.h"
#include "BKE_object.h"
#include "BKE_animsys.h"
#include "BKE_screen.h"
+#include "DEG_depsgraph.h"
+
+#include "BLI_dynstr.h"
+#include "BLI_rand.h"
+
#include "eevee_private.h"
#include "GPU_texture.h"
+#include "GPU_framebuffer.h"
+
+#define SHADER_DEFINES \
+ "#define EEVEE_ENGINE\n" \
+ "#define MAX_PROBE " STRINGIFY(MAX_PROBE) "\n" \
+ "#define MAX_GRID " STRINGIFY(MAX_GRID) "\n" \
+ "#define MAX_PLANAR " STRINGIFY(MAX_PLANAR) "\n"
typedef struct EEVEE_LightProbeData {
short probe_id, shadow_id;
} EEVEE_LightProbeData;
-/* TODO Option */
-#define ENABLE_EFFECT_MOTION_BLUR 1
-#define ENABLE_EFFECT_BLOOM 1
-#define ENABLE_EFFECT_DOF 1
+/* SSR shader variations */
+enum {
+ SSR_SAMPLES = (1 << 0) | (1 << 1),
+ SSR_RESOLVE = (1 << 2),
+ SSR_FULL_TRACE = (1 << 3),
+ SSR_MAX_SHADER = (1 << 4),
+};
static struct {
/* Downsample Depth */
- struct GPUShader *minmaxz_downlevel_sh;
- struct GPUShader *minmaxz_downdepth_sh;
- struct GPUShader *minmaxz_copydepth_sh;
+ struct GPUShader *minz_downlevel_sh;
+ struct GPUShader *maxz_downlevel_sh;
+ struct GPUShader *minz_downdepth_sh;
+ struct GPUShader *maxz_downdepth_sh;
+ struct GPUShader *minz_downdepth_layer_sh;
+ struct GPUShader *maxz_downdepth_layer_sh;
+ struct GPUShader *minz_copydepth_sh;
+ struct GPUShader *maxz_copydepth_sh;
/* Motion Blur */
struct GPUShader *motion_blur_sh;
@@ -70,20 +92,57 @@ static struct {
struct GPUShader *dof_scatter_sh;
struct GPUShader *dof_resolve_sh;
- struct GPUTexture *minmmaxz_depth_src;
+ /* Volumetric */
+ struct GPUShader *volumetric_upsample_sh;
+
+ /* Screen Space Reflection */
+ struct GPUShader *ssr_sh[SSR_MAX_SHADER];
+
+ /* Simple Downsample */
+ struct GPUShader *downsample_sh;
+ struct GPUShader *downsample_cube_sh;
+
+ /* Ground Truth Ambient Occlusion */
+ struct GPUShader *gtao_sh;
+ struct GPUShader *gtao_debug_sh;
+
+ /* Temporal Anti Aliasing */
+ struct GPUShader *taa_resolve_sh;
+
+ /* Theses are just references, not actually allocated */
+ struct GPUTexture *depth_src;
+ struct GPUTexture *color_src;
+
+ int depth_src_layer;
+ float cube_texel_size;
} e_data = {NULL}; /* Engine data */
+extern char datatoc_ambient_occlusion_lib_glsl[];
+extern char datatoc_bsdf_common_lib_glsl[];
+extern char datatoc_bsdf_sampling_lib_glsl[];
+extern char datatoc_octahedron_lib_glsl[];
+extern char datatoc_effect_temporal_aa_glsl[];
+extern char datatoc_effect_ssr_frag_glsl[];
extern char datatoc_effect_minmaxz_frag_glsl[];
extern char datatoc_effect_motion_blur_frag_glsl[];
extern char datatoc_effect_bloom_frag_glsl[];
extern char datatoc_effect_dof_vert_glsl[];
extern char datatoc_effect_dof_geom_glsl[];
extern char datatoc_effect_dof_frag_glsl[];
+extern char datatoc_effect_downsample_frag_glsl[];
+extern char datatoc_effect_downsample_cube_frag_glsl[];
+extern char datatoc_effect_gtao_frag_glsl[];
+extern char datatoc_lightprobe_lib_glsl[];
+extern char datatoc_lightprobe_vert_glsl[];
+extern char datatoc_lightprobe_geom_glsl[];
+extern char datatoc_raytrace_lib_glsl[];
extern char datatoc_tonemap_frag_glsl[];
+extern char datatoc_volumetric_frag_glsl[];
static void eevee_motion_blur_camera_get_matrix_at_time(
- Scene *scene, ARegion *ar, RegionView3D *rv3d, View3D *v3d, Object *camera, float time, float r_mat[4][4])
+ const bContext *C, Scene *scene, ARegion *ar, RegionView3D *rv3d, View3D *v3d, Object *camera, float time, float r_mat[4][4])
{
+ EvaluationContext eval_ctx;
float obmat[4][4];
/* HACK */
@@ -92,12 +151,14 @@ static void eevee_motion_blur_camera_get_matrix_at_time(
memcpy(&camdata_cpy, camera->data, sizeof(camdata_cpy));
cam_cpy.data = &camdata_cpy;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
/* Past matrix */
/* FIXME : This is a temporal solution that does not take care of parent animations */
/* Recalc Anim manualy */
BKE_animsys_evaluate_animdata(scene, &cam_cpy.id, cam_cpy.adt, time, ADT_RECALC_ALL);
BKE_animsys_evaluate_animdata(scene, &camdata_cpy.id, camdata_cpy.adt, time, ADT_RECALC_ALL);
- BKE_object_where_is_calc_time(scene, &cam_cpy, time);
+ BKE_object_where_is_calc_time(&eval_ctx, scene, &cam_cpy, time);
/* Compute winmat */
CameraParams params;
@@ -132,7 +193,47 @@ static void eevee_motion_blur_camera_get_matrix_at_time(
mul_m4_m4m4(r_mat, params.winmat, obmat);
}
-void EEVEE_effects_init(EEVEE_Data *vedata)
+static struct GPUShader *eevee_effects_ssr_shader_get(int options)
+{
+ if (e_data.ssr_sh[options] == NULL) {
+ DynStr *ds_frag = BLI_dynstr_new();
+ BLI_dynstr_append(ds_frag, datatoc_bsdf_common_lib_glsl);
+ BLI_dynstr_append(ds_frag, datatoc_bsdf_sampling_lib_glsl);
+ BLI_dynstr_append(ds_frag, datatoc_octahedron_lib_glsl);
+ BLI_dynstr_append(ds_frag, datatoc_lightprobe_lib_glsl);
+ BLI_dynstr_append(ds_frag, datatoc_ambient_occlusion_lib_glsl);
+ BLI_dynstr_append(ds_frag, datatoc_raytrace_lib_glsl);
+ BLI_dynstr_append(ds_frag, datatoc_effect_ssr_frag_glsl);
+ char *ssr_shader_str = BLI_dynstr_get_cstring(ds_frag);
+ BLI_dynstr_free(ds_frag);
+
+ int samples = (SSR_SAMPLES & options) + 1;
+
+ DynStr *ds_defines = BLI_dynstr_new();
+ BLI_dynstr_appendf(ds_defines, SHADER_DEFINES);
+ BLI_dynstr_appendf(ds_defines, "#define RAY_COUNT %d\n", samples);
+ if (options & SSR_RESOLVE) {
+ BLI_dynstr_appendf(ds_defines, "#define STEP_RESOLVE\n");
+ }
+ else {
+ BLI_dynstr_appendf(ds_defines, "#define STEP_RAYTRACE\n");
+ }
+ if (options & SSR_FULL_TRACE) {
+ BLI_dynstr_appendf(ds_defines, "#define FULLRES\n");
+ }
+ char *ssr_define_str = BLI_dynstr_get_cstring(ds_defines);
+ BLI_dynstr_free(ds_defines);
+
+ e_data.ssr_sh[options] = DRW_shader_create_fullscreen(ssr_shader_str, ssr_define_str);
+
+ MEM_freeN(ssr_shader_str);
+ MEM_freeN(ssr_define_str);
+ }
+
+ return e_data.ssr_sh[options];
+}
+
+void EEVEE_effects_init(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata)
{
EEVEE_StorageList *stl = vedata->stl;
EEVEE_FramebufferList *fbl = vedata->fbl;
@@ -140,7 +241,7 @@ void EEVEE_effects_init(EEVEE_Data *vedata)
EEVEE_EffectsInfo *effects;
const DRWContextState *draw_ctx = DRW_context_state_get();
- SceneLayer *scene_layer = draw_ctx->sl;
+ SceneLayer *scene_layer = draw_ctx->scene_layer;
Scene *scene = draw_ctx->scene;
View3D *v3d = draw_ctx->v3d;
RegionView3D *rv3d = draw_ctx->rv3d;
@@ -151,10 +252,45 @@ void EEVEE_effects_init(EEVEE_Data *vedata)
/* Shaders */
if (!e_data.motion_blur_sh) {
- e_data.minmaxz_downlevel_sh = DRW_shader_create_fullscreen(datatoc_effect_minmaxz_frag_glsl, NULL);
- e_data.minmaxz_downdepth_sh = DRW_shader_create_fullscreen(datatoc_effect_minmaxz_frag_glsl, "#define INPUT_DEPTH\n");
- e_data.minmaxz_copydepth_sh = DRW_shader_create_fullscreen(datatoc_effect_minmaxz_frag_glsl, "#define INPUT_DEPTH\n"
- "#define COPY_DEPTH\n");
+ DynStr *ds_frag = BLI_dynstr_new();
+ BLI_dynstr_append(ds_frag, datatoc_bsdf_common_lib_glsl);
+ BLI_dynstr_append(ds_frag, datatoc_ambient_occlusion_lib_glsl);
+ BLI_dynstr_append(ds_frag, datatoc_effect_gtao_frag_glsl);
+ char *frag_str = BLI_dynstr_get_cstring(ds_frag);
+ BLI_dynstr_free(ds_frag);
+
+ e_data.gtao_sh = DRW_shader_create_fullscreen(frag_str, NULL);
+ e_data.gtao_debug_sh = DRW_shader_create_fullscreen(frag_str, "#define DEBUG_AO\n");
+
+ MEM_freeN(frag_str);
+
+ e_data.taa_resolve_sh = DRW_shader_create_fullscreen(datatoc_effect_temporal_aa_glsl, NULL);
+
+ e_data.downsample_sh = DRW_shader_create_fullscreen(datatoc_effect_downsample_frag_glsl, NULL);
+ e_data.downsample_cube_sh = DRW_shader_create(datatoc_lightprobe_vert_glsl,
+ datatoc_lightprobe_geom_glsl,
+ datatoc_effect_downsample_cube_frag_glsl, NULL);
+
+ e_data.volumetric_upsample_sh = DRW_shader_create_fullscreen(datatoc_volumetric_frag_glsl, "#define STEP_UPSAMPLE\n");
+
+ e_data.minz_downlevel_sh = DRW_shader_create_fullscreen(datatoc_effect_minmaxz_frag_glsl, "#define MIN_PASS\n");
+ e_data.maxz_downlevel_sh = DRW_shader_create_fullscreen(datatoc_effect_minmaxz_frag_glsl, "#define MAX_PASS\n");
+ e_data.minz_downdepth_sh = DRW_shader_create_fullscreen(datatoc_effect_minmaxz_frag_glsl, "#define MIN_PASS\n"
+ "#define INPUT_DEPTH\n");
+ e_data.maxz_downdepth_sh = DRW_shader_create_fullscreen(datatoc_effect_minmaxz_frag_glsl, "#define MAX_PASS\n"
+ "#define INPUT_DEPTH\n");
+ e_data.minz_downdepth_layer_sh = DRW_shader_create_fullscreen(datatoc_effect_minmaxz_frag_glsl, "#define MIN_PASS\n"
+ "#define LAYERED\n"
+ "#define INPUT_DEPTH\n");
+ e_data.maxz_downdepth_layer_sh = DRW_shader_create_fullscreen(datatoc_effect_minmaxz_frag_glsl, "#define MAX_PASS\n"
+ "#define LAYERED\n"
+ "#define INPUT_DEPTH\n");
+ e_data.minz_copydepth_sh = DRW_shader_create_fullscreen(datatoc_effect_minmaxz_frag_glsl, "#define MIN_PASS\n"
+ "#define INPUT_DEPTH\n"
+ "#define COPY_DEPTH\n");
+ e_data.maxz_copydepth_sh = DRW_shader_create_fullscreen(datatoc_effect_minmaxz_frag_glsl, "#define MAX_PASS\n"
+ "#define INPUT_DEPTH\n"
+ "#define COPY_DEPTH\n");
e_data.motion_blur_sh = DRW_shader_create_fullscreen(datatoc_effect_motion_blur_frag_glsl, NULL);
@@ -190,8 +326,7 @@ void EEVEE_effects_init(EEVEE_Data *vedata)
int enabled_effects = 0;
-#if ENABLE_EFFECT_MOTION_BLUR
- if (BKE_collection_engine_property_value_get_bool(props, "motion_blur_enable")) {
+ if (BKE_collection_engine_property_value_get_bool(props, "motion_blur_enable") && (draw_ctx->evil_C != NULL)) {
/* Update Motion Blur Matrices */
if (rv3d->persp == RV3D_CAMOB && v3d->camera) {
float persmat[4][4];
@@ -199,7 +334,7 @@ void EEVEE_effects_init(EEVEE_Data *vedata)
float delta = BKE_collection_engine_property_value_get_float(props, "motion_blur_shutter");
/* Current matrix */
- eevee_motion_blur_camera_get_matrix_at_time(scene, ar, rv3d, v3d, v3d->camera, ctime, effects->current_ndc_to_world);
+ eevee_motion_blur_camera_get_matrix_at_time(draw_ctx->evil_C, scene, ar, rv3d, v3d, v3d->camera, ctime, effects->current_ndc_to_world);
/* Viewport Matrix */
DRW_viewport_matrix_get(persmat, DRW_MAT_PERS);
@@ -208,7 +343,7 @@ void EEVEE_effects_init(EEVEE_Data *vedata)
if (compare_m4m4(persmat, effects->current_ndc_to_world, 0.0001f)) {
/* Past matrix */
- eevee_motion_blur_camera_get_matrix_at_time(scene, ar, rv3d, v3d, v3d->camera, ctime - delta, effects->past_world_to_ndc);
+ eevee_motion_blur_camera_get_matrix_at_time(draw_ctx->evil_C, scene, ar, rv3d, v3d, v3d->camera, ctime - delta, effects->past_world_to_ndc);
#if 0 /* for future high quality blur */
/* Future matrix */
@@ -221,9 +356,7 @@ void EEVEE_effects_init(EEVEE_Data *vedata)
}
}
}
-#endif /* ENABLE_EFFECT_MOTION_BLUR */
-#if ENABLE_EFFECT_BLOOM
if (BKE_collection_engine_property_value_get_bool(props, "bloom_enable")) {
/* Bloom */
int blitsize[2], texsize[2];
@@ -247,7 +380,9 @@ void EEVEE_effects_init(EEVEE_Data *vedata)
float threshold = BKE_collection_engine_property_value_get_float(props, "bloom_threshold");
float knee = BKE_collection_engine_property_value_get_float(props, "bloom_knee");
float intensity = BKE_collection_engine_property_value_get_float(props, "bloom_intensity");
+ const float *color = BKE_collection_engine_property_value_get_float_array(props, "bloom_color");
float radius = BKE_collection_engine_property_value_get_float(props, "bloom_radius");
+ effects->bloom_clamp = BKE_collection_engine_property_value_get_float(props, "bloom_clamp");
/* determine the iteration count */
const float minDim = (float)MIN2(blitsize[0], blitsize[1]);
@@ -261,7 +396,8 @@ void EEVEE_effects_init(EEVEE_Data *vedata)
effects->bloom_curve_threshold[1] = knee * 2.0f;
effects->bloom_curve_threshold[2] = 0.25f / max_ff(1e-5f, knee);
effects->bloom_curve_threshold[3] = threshold;
- effects->bloom_intensity = intensity;
+
+ mul_v3_v3fl(effects->bloom_color, color, intensity);
/* Downsample buffers */
copy_v2_v2_int(texsize, blitsize);
@@ -294,9 +430,7 @@ void EEVEE_effects_init(EEVEE_Data *vedata)
enabled_effects |= EFFECT_BLOOM;
}
-#endif /* ENABLE_EFFECT_BLOOM */
-#if ENABLE_EFFECT_DOF
if (BKE_collection_engine_property_value_get_bool(props, "dof_enable")) {
/* Depth Of Field */
if (rv3d->persp == RV3D_CAMOB && v3d->camera) {
@@ -375,7 +509,75 @@ void EEVEE_effects_init(EEVEE_Data *vedata)
enabled_effects |= EFFECT_DOF;
}
}
-#endif /* ENABLE_EFFECT_DOF */
+
+ if (BKE_collection_engine_property_value_get_int(props, "taa_samples") != 1) {
+ float persmat[4][4], viewmat[4][4];
+
+ enabled_effects |= EFFECT_TAA | EFFECT_DOUBLE_BUFFER;
+
+ /* Until we support reprojection, we need to make sure
+ * that the history buffer contains correct information. */
+ bool view_is_valid = stl->g_data->valid_double_buffer;
+
+ view_is_valid = view_is_valid && (stl->g_data->view_updated == false);
+
+ effects->taa_total_sample = BKE_collection_engine_property_value_get_int(props, "taa_samples");
+ MAX2(effects->taa_total_sample, 0);
+
+ DRW_viewport_matrix_get(persmat, DRW_MAT_PERS);
+ DRW_viewport_matrix_get(viewmat, DRW_MAT_VIEW);
+ DRW_viewport_matrix_get(effects->overide_winmat, DRW_MAT_WIN);
+ view_is_valid = view_is_valid && compare_m4m4(persmat, effects->prev_drw_persmat, FLT_MIN);
+ copy_m4_m4(effects->prev_drw_persmat, persmat);
+
+ /* Prevent ghosting from probe data. */
+ view_is_valid = view_is_valid && (effects->prev_drw_support == DRW_state_draw_support());
+ effects->prev_drw_support = DRW_state_draw_support();
+
+ if (view_is_valid &&
+ ((effects->taa_total_sample == 0) ||
+ (effects->taa_current_sample < effects->taa_total_sample)))
+ {
+ effects->taa_current_sample += 1;
+
+ effects->taa_alpha = 1.0f / (float)(effects->taa_current_sample);
+
+ double ht_point[2];
+ double ht_offset[2] = {0.0, 0.0};
+ unsigned int ht_primes[2] = {2, 3};
+
+ BLI_halton_2D(ht_primes, ht_offset, effects->taa_current_sample - 1, ht_point);
+
+ window_translate_m4(
+ effects->overide_winmat, persmat,
+ ((float)(ht_point[0]) * 2.0f - 1.0f) / viewport_size[0],
+ ((float)(ht_point[1]) * 2.0f - 1.0f) / viewport_size[1]);
+
+ mul_m4_m4m4(effects->overide_persmat, effects->overide_winmat, viewmat);
+ invert_m4_m4(effects->overide_persinv, effects->overide_persmat);
+ invert_m4_m4(effects->overide_wininv, effects->overide_winmat);
+
+ DRW_viewport_matrix_override_set(effects->overide_persmat, DRW_MAT_PERS);
+ DRW_viewport_matrix_override_set(effects->overide_persinv, DRW_MAT_PERSINV);
+ DRW_viewport_matrix_override_set(effects->overide_winmat, DRW_MAT_WIN);
+ DRW_viewport_matrix_override_set(effects->overide_wininv, DRW_MAT_WININV);
+ }
+ else {
+ effects->taa_current_sample = 1;
+ }
+
+ DRWFboTexture tex_double_buffer = {&txl->depth_double_buffer, DRW_TEX_DEPTH_24};
+
+ DRW_framebuffer_init(&fbl->depth_double_buffer_fb, &draw_engine_eevee_type,
+ (int)viewport_size[0], (int)viewport_size[1],
+ &tex_double_buffer, 1);
+ }
+ else {
+ /* Cleanup to release memory */
+ DRW_TEXTURE_FREE_SAFE(txl->depth_double_buffer);
+ DRW_FRAMEBUFFER_FREE_SAFE(fbl->depth_double_buffer_fb);
+ }
+
effects->enabled_effects = enabled_effects;
@@ -389,21 +591,264 @@ void EEVEE_effects_init(EEVEE_Data *vedata)
&tex, 1);
}
- {
+ if (BKE_collection_engine_property_value_get_bool(props, "gtao_enable")) {
/* Ambient Occlusion*/
- stl->effects->ao_dist = BKE_collection_engine_property_value_get_float(props, "gtao_distance");
- stl->effects->ao_samples = BKE_collection_engine_property_value_get_int(props, "gtao_samples");
- stl->effects->ao_factor = BKE_collection_engine_property_value_get_float(props, "gtao_factor");
+ effects->enabled_effects |= EFFECT_GTAO;
+
+ effects->ao_dist = BKE_collection_engine_property_value_get_float(props, "gtao_distance");
+ effects->ao_factor = BKE_collection_engine_property_value_get_float(props, "gtao_factor");
+ effects->ao_quality = 1.0f - BKE_collection_engine_property_value_get_float(props, "gtao_quality");
+ effects->ao_samples = BKE_collection_engine_property_value_get_int(props, "gtao_samples");
+ effects->ao_samples_inv = 1.0f / effects->ao_samples;
+
+ effects->ao_settings = 1.0; /* USE_AO */
+ if (BKE_collection_engine_property_value_get_bool(props, "gtao_use_bent_normals")) {
+ effects->ao_settings += 2.0; /* USE_BENT_NORMAL */
+ }
+ if (BKE_collection_engine_property_value_get_bool(props, "gtao_denoise")) {
+ effects->ao_settings += 4.0; /* USE_DENOISE */
+ }
+
+ effects->ao_bounce_fac = (float)BKE_collection_engine_property_value_get_bool(props, "gtao_bounce");
+
+ effects->ao_texsize[0] = ((int)viewport_size[0]);
+ effects->ao_texsize[1] = ((int)viewport_size[1]);
+
+ /* Round up to multiple of 2 */
+ if ((effects->ao_texsize[0] & 0x1) != 0) {
+ effects->ao_texsize[0] += 1;
+ }
+ if ((effects->ao_texsize[1] & 0x1) != 0) {
+ effects->ao_texsize[1] += 1;
+ }
+
+ CLAMP(effects->ao_samples, 1, 32);
+
+ if (effects->hori_tex_layers != effects->ao_samples) {
+ DRW_TEXTURE_FREE_SAFE(txl->gtao_horizons);
+ }
+
+ if (txl->gtao_horizons == NULL) {
+ effects->hori_tex_layers = effects->ao_samples;
+ txl->gtao_horizons = DRW_texture_create_2D_array((int)viewport_size[0], (int)viewport_size[1], effects->hori_tex_layers, DRW_TEX_RG_8, 0, NULL);
+ }
+
+ DRWFboTexture tex = {&txl->gtao_horizons, DRW_TEX_RG_8, 0};
+
+ DRW_framebuffer_init(&fbl->gtao_fb, &draw_engine_eevee_type,
+ effects->ao_texsize[0], effects->ao_texsize[1],
+ &tex, 1);
+
+ if (G.debug_value == 6) {
+ DRWFboTexture tex_debug = {&stl->g_data->gtao_horizons_debug, DRW_TEX_RGBA_8, DRW_TEX_TEMP};
+
+ DRW_framebuffer_init(&fbl->gtao_debug_fb, &draw_engine_eevee_type,
+ (int)viewport_size[0], (int)viewport_size[1],
+ &tex_debug, 1);
+ }
+ }
+ else {
+ /* Cleanup */
+ DRW_TEXTURE_FREE_SAFE(txl->gtao_horizons);
+ DRW_FRAMEBUFFER_FREE_SAFE(fbl->gtao_fb);
+ effects->ao_settings = 0.0f;
}
/* MinMax Pyramid */
- /* TODO reduce precision */
- DRWFboTexture tex = {&stl->g_data->minmaxz, DRW_TEX_RG_32, DRW_TEX_MIPMAP | DRW_TEX_TEMP};
+ DRWFboTexture texmin = {&stl->g_data->minzbuffer, DRW_TEX_DEPTH_24, DRW_TEX_MIPMAP | DRW_TEX_TEMP};
- DRW_framebuffer_init(&fbl->minmaxz_fb, &draw_engine_eevee_type,
+ DRW_framebuffer_init(&fbl->downsample_fb, &draw_engine_eevee_type,
(int)viewport_size[0] / 2, (int)viewport_size[1] / 2,
- &tex, 1);
+ &texmin, 1);
+
+ /* Cannot define 2 depth texture for one framebuffer. So allocate ourself. */
+ if (txl->maxzbuffer == NULL) {
+ txl->maxzbuffer = DRW_texture_create_2D((int)viewport_size[0] / 2, (int)viewport_size[1] / 2, DRW_TEX_DEPTH_24, DRW_TEX_MIPMAP, NULL);
+ }
+
+ /* Compute Mipmap texel alignement. */
+ for (int i = 0; i < 10; ++i) {
+ float mip_size[2] = {viewport_size[0], viewport_size[1]};
+ for (int j = 0; j < i; ++j) {
+ mip_size[0] = floorf(fmaxf(1.0f, mip_size[0] / 2.0f));
+ mip_size[1] = floorf(fmaxf(1.0f, mip_size[1] / 2.0f));
+ }
+ stl->g_data->mip_ratio[i][0] = viewport_size[0] / (mip_size[0] * powf(2.0f, floorf(log2f(floorf(viewport_size[0] / mip_size[0])))));
+ stl->g_data->mip_ratio[i][1] = viewport_size[1] / (mip_size[1] * powf(2.0f, floorf(log2f(floorf(viewport_size[1] / mip_size[1])))));
+ }
+
+ if (BKE_collection_engine_property_value_get_bool(props, "volumetric_enable")) {
+ World *wo = scene->world;
+
+ /* TODO: this will not be the case if we support object volumetrics */
+ if ((wo != NULL) && (wo->use_nodes) && (wo->nodetree != NULL)) {
+ effects->enabled_effects |= EFFECT_VOLUMETRIC;
+
+ if (sldata->volumetrics == NULL) {
+ sldata->volumetrics = MEM_callocN(sizeof(EEVEE_VolumetricsInfo), "EEVEE_VolumetricsInfo");
+ }
+
+ EEVEE_VolumetricsInfo *volumetrics = sldata->volumetrics;
+ bool last_use_colored_transmit = volumetrics->use_colored_transmit; /* Save to compare */
+ volumetrics->integration_start = BKE_collection_engine_property_value_get_float(props, "volumetric_start");
+ volumetrics->integration_end = BKE_collection_engine_property_value_get_float(props, "volumetric_end");
+
+ if (DRW_viewport_is_persp_get()) {
+ /* Negate */
+ volumetrics->integration_start = -volumetrics->integration_start;
+ volumetrics->integration_end = -volumetrics->integration_end;
+ }
+ else {
+ const float clip_start = stl->g_data->viewvecs[0][2];
+ const float clip_end = stl->g_data->viewvecs[1][2];
+ volumetrics->integration_start = min_ff(volumetrics->integration_end, clip_start);
+ volumetrics->integration_end = max_ff(-volumetrics->integration_end, clip_end);
+ }
+
+ volumetrics->sample_distribution = BKE_collection_engine_property_value_get_float(props, "volumetric_sample_distribution");
+ volumetrics->integration_step_count = (float)BKE_collection_engine_property_value_get_int(props, "volumetric_samples");
+ volumetrics->shadow_step_count = (float)BKE_collection_engine_property_value_get_int(props, "volumetric_shadow_samples");
+ volumetrics->light_clamp = BKE_collection_engine_property_value_get_float(props, "volumetric_light_clamp");
+
+ /* Disable clamp if equal to 0. */
+ if (volumetrics->light_clamp == 0.0) {
+ volumetrics->light_clamp = FLT_MAX;
+ }
+
+ volumetrics->use_lights = BKE_collection_engine_property_value_get_bool(props, "volumetric_lights");
+ volumetrics->use_volume_shadows = BKE_collection_engine_property_value_get_bool(props, "volumetric_shadows");
+ volumetrics->use_colored_transmit = BKE_collection_engine_property_value_get_bool(props, "volumetric_colored_transmittance");
+
+ if (last_use_colored_transmit != volumetrics->use_colored_transmit) {
+ if (fbl->volumetric_fb != NULL) {
+ DRW_framebuffer_free(fbl->volumetric_fb);
+ fbl->volumetric_fb = NULL;
+ }
+ }
+
+ /* Integration result buffer(s) */
+ if (volumetrics->use_colored_transmit == false) {
+ /* Monocromatic transmittance in alpha */
+ DRWFboTexture tex_vol = {&stl->g_data->volumetric, DRW_TEX_RGBA_16, DRW_TEX_MIPMAP | DRW_TEX_FILTER | DRW_TEX_TEMP};
+
+ DRW_framebuffer_init(&fbl->volumetric_fb, &draw_engine_eevee_type,
+ (int)viewport_size[0] / 2, (int)viewport_size[1] / 2,
+ &tex_vol, 1);
+ }
+ else {
+ /* Transmittance is separated, No need for alpha and DRW_TEX_RGB_11_11_10 gives the same vram usage */
+ /* Hint ! Could reuse this for transparency! */
+ DRWFboTexture tex_vol[2] = {{&stl->g_data->volumetric, DRW_TEX_RGB_11_11_10, DRW_TEX_MIPMAP | DRW_TEX_FILTER | DRW_TEX_TEMP},
+ {&stl->g_data->volumetric_transmit, DRW_TEX_RGB_11_11_10, DRW_TEX_MIPMAP | DRW_TEX_FILTER | DRW_TEX_TEMP}};
+
+ DRW_framebuffer_init(&fbl->volumetric_fb, &draw_engine_eevee_type,
+ (int)viewport_size[0] / 2, (int)viewport_size[1] / 2,
+ tex_vol, 2);
+ }
+ }
+ }
+
+ /* Compute pixel size, (shared with contact shadows) */
+ copy_v2_v2(effects->ssr_pixelsize, viewport_size);
+ invert_v2(effects->ssr_pixelsize);
+
+ if (BKE_collection_engine_property_value_get_bool(props, "ssr_enable")) {
+ effects->enabled_effects |= EFFECT_SSR;
+
+ if (BKE_collection_engine_property_value_get_bool(props, "ssr_refraction")) {
+ effects->enabled_effects |= EFFECT_REFRACT;
+
+ DRWFboTexture tex = {&txl->refract_color, DRW_TEX_RGB_11_11_10, DRW_TEX_FILTER | DRW_TEX_MIPMAP};
+
+ DRW_framebuffer_init(&fbl->refract_fb, &draw_engine_eevee_type, (int)viewport_size[0], (int)viewport_size[1], &tex, 1);
+ }
+
+ /* Enable double buffering to be able to read previous frame color */
+ effects->enabled_effects |= EFFECT_DOUBLE_BUFFER;
+
+ effects->ssr_ray_count = BKE_collection_engine_property_value_get_int(props, "ssr_ray_count");
+ effects->reflection_trace_full = !BKE_collection_engine_property_value_get_bool(props, "ssr_halfres");
+ effects->ssr_use_normalization = BKE_collection_engine_property_value_get_bool(props, "ssr_normalize_weight");
+ effects->ssr_quality = 1.0f - BKE_collection_engine_property_value_get_float(props, "ssr_quality");
+ effects->ssr_thickness = BKE_collection_engine_property_value_get_float(props, "ssr_thickness");
+ effects->ssr_border_fac = BKE_collection_engine_property_value_get_float(props, "ssr_border_fade");
+ effects->ssr_firefly_fac = BKE_collection_engine_property_value_get_float(props, "ssr_firefly_fac");
+ effects->ssr_max_roughness = BKE_collection_engine_property_value_get_float(props, "ssr_max_roughness");
+
+ if (effects->ssr_firefly_fac < 1e-8f) {
+ effects->ssr_firefly_fac = FLT_MAX;
+ }
+
+ /* Important, can lead to breakage otherwise. */
+ CLAMP(effects->ssr_ray_count, 1, 4);
+
+ const int divisor = (effects->reflection_trace_full) ? 1 : 2;
+ int tracing_res[2] = {(int)viewport_size[0] / divisor, (int)viewport_size[1] / divisor};
+ const bool high_qual_input = true; /* TODO dither low quality input */
+
+ /* MRT for the shading pass in order to output needed data for the SSR pass. */
+ /* TODO create one texture layer per lobe */
+ if (txl->ssr_specrough_input == NULL) {
+ DRWTextureFormat specrough_format = (high_qual_input) ? DRW_TEX_RGBA_16 : DRW_TEX_RGBA_8;
+ txl->ssr_specrough_input = DRW_texture_create_2D((int)viewport_size[0], (int)viewport_size[1], specrough_format, 0, NULL);
+ }
+
+ /* Reattach textures to the right buffer (because we are alternating between buffers) */
+ /* TODO multiple FBO per texture!!!! */
+ DRW_framebuffer_texture_detach(txl->ssr_specrough_input);
+ DRW_framebuffer_texture_attach(fbl->main, txl->ssr_specrough_input, 2, 0);
+
+ /* Raytracing output */
+ /* TODO try integer format for hit coord to increase precision */
+ DRWFboTexture tex_output[4] = {{&stl->g_data->ssr_hit_output[0], DRW_TEX_RGBA_16, DRW_TEX_TEMP},
+ {&stl->g_data->ssr_hit_output[1], DRW_TEX_RGBA_16, DRW_TEX_TEMP},
+ {&stl->g_data->ssr_hit_output[2], DRW_TEX_RGBA_16, DRW_TEX_TEMP},
+ {&stl->g_data->ssr_hit_output[3], DRW_TEX_RGBA_16, DRW_TEX_TEMP}};
+
+ DRW_framebuffer_init(&fbl->screen_tracing_fb, &draw_engine_eevee_type, tracing_res[0], tracing_res[1], tex_output, effects->ssr_ray_count);
+ }
+ else {
+ /* Cleanup to release memory */
+ DRW_TEXTURE_FREE_SAFE(txl->ssr_specrough_input);
+ DRW_FRAMEBUFFER_FREE_SAFE(fbl->screen_tracing_fb);
+ for (int i = 0; i < 4; ++i) {
+ stl->g_data->ssr_hit_output[i] = NULL;
+ }
+ }
+
+ /* Normal buffer for deferred passes. */
+ if ((((effects->enabled_effects & EFFECT_GTAO) != 0) && G.debug_value == 6) ||
+ ((effects->enabled_effects & EFFECT_SSR) != 0))
+ {
+ if (txl->ssr_normal_input == NULL) {
+ DRWTextureFormat nor_format = DRW_TEX_RG_16;
+ txl->ssr_normal_input = DRW_texture_create_2D((int)viewport_size[0], (int)viewport_size[1], nor_format, 0, NULL);
+ }
+
+ /* Reattach textures to the right buffer (because we are alternating between buffers) */
+ /* TODO multiple FBO per texture!!!! */
+ DRW_framebuffer_texture_detach(txl->ssr_normal_input);
+ DRW_framebuffer_texture_attach(fbl->main, txl->ssr_normal_input, 1, 0);
+ }
+ else {
+ /* Cleanup to release memory */
+ DRW_TEXTURE_FREE_SAFE(txl->ssr_normal_input);
+ }
+
+ /* Setup double buffer so we can access last frame as it was before post processes */
+ if ((effects->enabled_effects & EFFECT_DOUBLE_BUFFER) != 0) {
+ DRWFboTexture tex_double_buffer = {&txl->color_double_buffer, DRW_TEX_RGB_11_11_10, DRW_TEX_FILTER | DRW_TEX_MIPMAP};
+
+ DRW_framebuffer_init(&fbl->double_buffer, &draw_engine_eevee_type,
+ (int)viewport_size[0], (int)viewport_size[1],
+ &tex_double_buffer, 1);
+ }
+ else {
+ /* Cleanup to release memory */
+ DRW_TEXTURE_FREE_SAFE(txl->color_double_buffer);
+ DRW_FRAMEBUFFER_FREE_SAFE(fbl->double_buffer);
+ }
}
static DRWShadingGroup *eevee_create_bloom_pass(const char *name, EEVEE_EffectsInfo *effects, struct GPUShader *sh, DRWPass **pass, bool upsample)
@@ -424,7 +869,7 @@ static DRWShadingGroup *eevee_create_bloom_pass(const char *name, EEVEE_EffectsI
return grp;
}
-void EEVEE_effects_cache_init(EEVEE_Data *vedata)
+void EEVEE_effects_cache_init(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata)
{
EEVEE_PassList *psl = vedata->psl;
EEVEE_StorageList *stl = vedata->stl;
@@ -434,20 +879,233 @@ void EEVEE_effects_cache_init(EEVEE_Data *vedata)
struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get();
+ if ((effects->enabled_effects & EFFECT_TAA) != 0) {
+ psl->taa_resolve = DRW_pass_create("Temporal AA Resolve", DRW_STATE_WRITE_COLOR);
+ DRWShadingGroup *grp = DRW_shgroup_create(e_data.taa_resolve_sh, psl->taa_resolve);
+
+ DRW_shgroup_uniform_buffer(grp, "historyBuffer", &txl->color_double_buffer);
+ DRW_shgroup_uniform_buffer(grp, "colorBuffer", &txl->color);
+ DRW_shgroup_uniform_float(grp, "alpha", &effects->taa_alpha, 1);
+ DRW_shgroup_call_add(grp, quad, NULL);
+ }
+
+ if ((effects->enabled_effects & EFFECT_VOLUMETRIC) != 0) {
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ Scene *scene = draw_ctx->scene;
+ struct World *wo = scene->world; /* Already checked non NULL */
+ EEVEE_VolumetricsInfo *volumetrics = sldata->volumetrics;
+
+ struct GPUMaterial *mat = EEVEE_material_world_volume_get(
+ scene, wo, volumetrics->use_lights, volumetrics->use_volume_shadows,
+ false, volumetrics->use_colored_transmit, sldata->lamps->shadow_method);
+
+ psl->volumetric_integrate_ps = DRW_pass_create("Volumetric Integration", DRW_STATE_WRITE_COLOR);
+ DRWShadingGroup *grp = DRW_shgroup_material_create(mat, psl->volumetric_integrate_ps);
+
+ if (grp != NULL) {
+ DRW_shgroup_uniform_buffer(grp, "depthFull", &e_data.depth_src);
+ DRW_shgroup_uniform_buffer(grp, "shadowTexture", &sldata->shadow_pool);
+ DRW_shgroup_uniform_buffer(grp, "irradianceGrid", &sldata->irradiance_pool);
+ DRW_shgroup_uniform_block(grp, "light_block", sldata->light_ubo);
+ DRW_shgroup_uniform_block(grp, "grid_block", sldata->grid_ubo);
+ DRW_shgroup_uniform_block(grp, "shadow_block", sldata->shadow_ubo);
+ DRW_shgroup_uniform_int(grp, "light_count", &sldata->lamps->num_light, 1);
+ DRW_shgroup_uniform_int(grp, "grid_count", &sldata->probes->num_render_grid, 1);
+ DRW_shgroup_uniform_texture(grp, "utilTex", EEVEE_materials_get_util_tex());
+ DRW_shgroup_uniform_vec4(grp, "viewvecs[0]", (float *)stl->g_data->viewvecs, 2);
+ DRW_shgroup_uniform_vec2(grp, "volume_start_end", &sldata->volumetrics->integration_start, 1);
+ DRW_shgroup_uniform_vec4(grp, "volume_samples_clamp", &sldata->volumetrics->integration_step_count, 1);
+ DRW_shgroup_call_add(grp, quad, NULL);
+
+ if (volumetrics->use_colored_transmit == false) { /* Monochromatic transmittance */
+ psl->volumetric_resolve_ps = DRW_pass_create("Volumetric Resolve", DRW_STATE_WRITE_COLOR | DRW_STATE_TRANSMISSION);
+ grp = DRW_shgroup_create(e_data.volumetric_upsample_sh, psl->volumetric_resolve_ps);
+ DRW_shgroup_uniform_vec4(grp, "viewvecs[0]", (float *)stl->g_data->viewvecs, 2);
+ DRW_shgroup_uniform_buffer(grp, "depthFull", &e_data.depth_src);
+ DRW_shgroup_uniform_buffer(grp, "volumetricBuffer", &stl->g_data->volumetric);
+ DRW_shgroup_call_add(grp, quad, NULL);
+ }
+ else {
+ psl->volumetric_resolve_transmit_ps = DRW_pass_create("Volumetric Transmittance Resolve", DRW_STATE_WRITE_COLOR | DRW_STATE_MULTIPLY);
+ grp = DRW_shgroup_create(e_data.volumetric_upsample_sh, psl->volumetric_resolve_transmit_ps);
+ DRW_shgroup_uniform_vec4(grp, "viewvecs[0]", (float *)stl->g_data->viewvecs, 2);
+ DRW_shgroup_uniform_buffer(grp, "depthFull", &e_data.depth_src);
+ DRW_shgroup_uniform_buffer(grp, "volumetricBuffer", &stl->g_data->volumetric_transmit);
+ DRW_shgroup_call_add(grp, quad, NULL);
+
+ psl->volumetric_resolve_ps = DRW_pass_create("Volumetric Resolve", DRW_STATE_WRITE_COLOR | DRW_STATE_ADDITIVE);
+ grp = DRW_shgroup_create(e_data.volumetric_upsample_sh, psl->volumetric_resolve_ps);
+ DRW_shgroup_uniform_vec4(grp, "viewvecs[0]", (float *)stl->g_data->viewvecs, 2);
+ DRW_shgroup_uniform_buffer(grp, "depthFull", &e_data.depth_src);
+ DRW_shgroup_uniform_buffer(grp, "volumetricBuffer", &stl->g_data->volumetric);
+ DRW_shgroup_call_add(grp, quad, NULL);
+ }
+ }
+ else {
+ /* Compilation failled */
+ effects->enabled_effects &= ~EFFECT_VOLUMETRIC;
+ }
+ }
+
+ if ((effects->enabled_effects & EFFECT_SSR) != 0) {
+ int options = (effects->reflection_trace_full) ? SSR_FULL_TRACE : 0;
+ options |= (effects->ssr_ray_count - 1);
+
+ struct GPUShader *trace_shader = eevee_effects_ssr_shader_get(options);
+ struct GPUShader *resolve_shader = eevee_effects_ssr_shader_get(SSR_RESOLVE | options);
+
+ psl->ssr_raytrace = DRW_pass_create("SSR Raytrace", DRW_STATE_WRITE_COLOR);
+ DRWShadingGroup *grp = DRW_shgroup_create(trace_shader, psl->ssr_raytrace);
+ DRW_shgroup_uniform_buffer(grp, "depthBuffer", &e_data.depth_src);
+ DRW_shgroup_uniform_buffer(grp, "normalBuffer", &txl->ssr_normal_input);
+ DRW_shgroup_uniform_buffer(grp, "specroughBuffer", &txl->ssr_specrough_input);
+ DRW_shgroup_uniform_texture(grp, "utilTex", EEVEE_materials_get_util_tex());
+ DRW_shgroup_uniform_buffer(grp, "maxzBuffer", &txl->maxzbuffer);
+ DRW_shgroup_uniform_buffer(grp, "minzBuffer", &stl->g_data->minzbuffer);
+ DRW_shgroup_uniform_vec4(grp, "viewvecs[0]", (float *)stl->g_data->viewvecs, 2);
+ DRW_shgroup_uniform_vec2(grp, "mipRatio[0]", (float *)stl->g_data->mip_ratio, 10);
+ DRW_shgroup_uniform_vec4(grp, "ssrParameters", &effects->ssr_quality, 1);
+ DRW_shgroup_uniform_int(grp, "planar_count", &sldata->probes->num_planar, 1);
+ DRW_shgroup_uniform_float(grp, "maxRoughness", &effects->ssr_max_roughness, 1);
+ DRW_shgroup_uniform_buffer(grp, "planarDepth", &vedata->txl->planar_depth);
+ DRW_shgroup_uniform_block(grp, "planar_block", sldata->planar_ubo);
+ DRW_shgroup_call_add(grp, quad, NULL);
+
+ psl->ssr_resolve = DRW_pass_create("SSR Resolve", DRW_STATE_WRITE_COLOR | DRW_STATE_ADDITIVE);
+ grp = DRW_shgroup_create(resolve_shader, psl->ssr_resolve);
+ DRW_shgroup_uniform_buffer(grp, "depthBuffer", &e_data.depth_src);
+ DRW_shgroup_uniform_buffer(grp, "normalBuffer", &txl->ssr_normal_input);
+ DRW_shgroup_uniform_buffer(grp, "specroughBuffer", &txl->ssr_specrough_input);
+ DRW_shgroup_uniform_texture(grp, "utilTex", EEVEE_materials_get_util_tex());
+ DRW_shgroup_uniform_buffer(grp, "prevColorBuffer", &txl->color_double_buffer);
+ DRW_shgroup_uniform_mat4(grp, "PastViewProjectionMatrix", (float *)stl->g_data->prev_persmat);
+ DRW_shgroup_uniform_vec4(grp, "viewvecs[0]", (float *)stl->g_data->viewvecs, 2);
+ DRW_shgroup_uniform_int(grp, "planar_count", &sldata->probes->num_planar, 1);
+ DRW_shgroup_uniform_int(grp, "probe_count", &sldata->probes->num_render_cube, 1);
+ DRW_shgroup_uniform_vec2(grp, "mipRatio[0]", (float *)stl->g_data->mip_ratio, 10);
+ DRW_shgroup_uniform_float(grp, "borderFadeFactor", &effects->ssr_border_fac, 1);
+ DRW_shgroup_uniform_float(grp, "maxRoughness", &effects->ssr_max_roughness, 1);
+ DRW_shgroup_uniform_float(grp, "lodCubeMax", &sldata->probes->lod_cube_max, 1);
+ DRW_shgroup_uniform_float(grp, "lodPlanarMax", &sldata->probes->lod_planar_max, 1);
+ DRW_shgroup_uniform_float(grp, "fireflyFactor", &effects->ssr_firefly_fac, 1);
+ DRW_shgroup_uniform_block(grp, "probe_block", sldata->probe_ubo);
+ DRW_shgroup_uniform_block(grp, "planar_block", sldata->planar_ubo);
+ DRW_shgroup_uniform_buffer(grp, "probeCubes", &sldata->probe_pool);
+ DRW_shgroup_uniform_buffer(grp, "probePlanars", &vedata->txl->planar_pool);
+ DRW_shgroup_uniform_buffer(grp, "hitBuffer0", &stl->g_data->ssr_hit_output[0]);
+ if (effects->ssr_ray_count > 1) {
+ DRW_shgroup_uniform_buffer(grp, "hitBuffer1", &stl->g_data->ssr_hit_output[1]);
+ }
+ if (effects->ssr_ray_count > 2) {
+ DRW_shgroup_uniform_buffer(grp, "hitBuffer2", &stl->g_data->ssr_hit_output[2]);
+ }
+ if (effects->ssr_ray_count > 3) {
+ DRW_shgroup_uniform_buffer(grp, "hitBuffer3", &stl->g_data->ssr_hit_output[3]);
+ }
+
+ DRW_shgroup_uniform_vec4(grp, "aoParameters[0]", &effects->ao_dist, 2);
+ if (effects->use_ao) {
+ DRW_shgroup_uniform_buffer(grp, "horizonBuffer", &vedata->txl->gtao_horizons);
+ DRW_shgroup_uniform_ivec2(grp, "aoHorizonTexSize", (int *)vedata->stl->effects->ao_texsize, 1);
+ }
+ else {
+ /* Use shadow_pool as fallback to avoid sampling problem on certain platform, see: T52593 */
+ DRW_shgroup_uniform_buffer(grp, "horizonBuffer", &sldata->shadow_pool);
+ }
+
+ DRW_shgroup_call_add(grp, quad, NULL);
+ }
+
+ {
+ psl->color_downsample_ps = DRW_pass_create("Downsample", DRW_STATE_WRITE_COLOR);
+ DRWShadingGroup *grp = DRW_shgroup_create(e_data.downsample_sh, psl->color_downsample_ps);
+ DRW_shgroup_uniform_buffer(grp, "source", &e_data.color_src);
+ DRW_shgroup_uniform_float(grp, "fireflyFactor", &effects->ssr_firefly_fac, 1);
+ DRW_shgroup_call_add(grp, quad, NULL);
+ }
+
+ {
+ static int zero = 0;
+ psl->color_downsample_cube_ps = DRW_pass_create("Downsample Cube", DRW_STATE_WRITE_COLOR);
+ DRWShadingGroup *grp = DRW_shgroup_instance_create(e_data.downsample_cube_sh, psl->color_downsample_cube_ps, quad);
+ DRW_shgroup_uniform_buffer(grp, "source", &e_data.color_src);
+ DRW_shgroup_uniform_float(grp, "texelSize", &e_data.cube_texel_size, 1);
+ DRW_shgroup_uniform_int(grp, "Layer", &zero, 1);
+ for (int i = 0; i < 6; ++i)
+ DRW_shgroup_call_dynamic_add_empty(grp);
+ }
+
{
- psl->minmaxz_downlevel = DRW_pass_create("HiZ Down Level", DRW_STATE_WRITE_COLOR);
- DRWShadingGroup *grp = DRW_shgroup_create(e_data.minmaxz_downlevel_sh, psl->minmaxz_downlevel);
- DRW_shgroup_uniform_buffer(grp, "depthBuffer", &stl->g_data->minmaxz);
+ /* Perform min/max downsample */
+ psl->minz_downlevel_ps = DRW_pass_create("HiZ Min Down Level", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_ALWAYS);
+ DRWShadingGroup *grp = DRW_shgroup_create(e_data.minz_downlevel_sh, psl->minz_downlevel_ps);
+ DRW_shgroup_uniform_buffer(grp, "depthBuffer", &stl->g_data->minzbuffer);
+ DRW_shgroup_call_add(grp, quad, NULL);
+
+ psl->maxz_downlevel_ps = DRW_pass_create("HiZ Max Down Level", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_ALWAYS);
+ grp = DRW_shgroup_create(e_data.maxz_downlevel_sh, psl->maxz_downlevel_ps);
+ DRW_shgroup_uniform_buffer(grp, "depthBuffer", &txl->maxzbuffer);
+ DRW_shgroup_call_add(grp, quad, NULL);
+
+ /* Copy depth buffer to halfres top level of HiZ */
+ psl->minz_downdepth_ps = DRW_pass_create("HiZ Min Copy Depth Halfres", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_ALWAYS);
+ grp = DRW_shgroup_create(e_data.minz_downdepth_sh, psl->minz_downdepth_ps);
+ DRW_shgroup_uniform_buffer(grp, "depthBuffer", &e_data.depth_src);
+ DRW_shgroup_call_add(grp, quad, NULL);
+
+ psl->maxz_downdepth_ps = DRW_pass_create("HiZ Max Copy Depth Halfres", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_ALWAYS);
+ grp = DRW_shgroup_create(e_data.maxz_downdepth_sh, psl->maxz_downdepth_ps);
+ DRW_shgroup_uniform_buffer(grp, "depthBuffer", &e_data.depth_src);
+ DRW_shgroup_call_add(grp, quad, NULL);
+
+ psl->minz_downdepth_layer_ps = DRW_pass_create("HiZ Min Copy DepthLayer Halfres", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_ALWAYS);
+ grp = DRW_shgroup_create(e_data.minz_downdepth_layer_sh, psl->minz_downdepth_layer_ps);
+ DRW_shgroup_uniform_buffer(grp, "depthBuffer", &e_data.depth_src);
+ DRW_shgroup_uniform_int(grp, "depthLayer", &e_data.depth_src_layer, 1);
DRW_shgroup_call_add(grp, quad, NULL);
- psl->minmaxz_downdepth = DRW_pass_create("HiZ Down Depth", DRW_STATE_WRITE_COLOR);
- grp = DRW_shgroup_create(e_data.minmaxz_downdepth_sh, psl->minmaxz_downdepth);
- DRW_shgroup_uniform_buffer(grp, "depthBuffer", &e_data.minmmaxz_depth_src);
+ psl->maxz_downdepth_layer_ps = DRW_pass_create("HiZ Max Copy DepthLayer Halfres", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_ALWAYS);
+ grp = DRW_shgroup_create(e_data.maxz_downdepth_layer_sh, psl->maxz_downdepth_layer_ps);
+ DRW_shgroup_uniform_buffer(grp, "depthBuffer", &e_data.depth_src);
+ DRW_shgroup_uniform_int(grp, "depthLayer", &e_data.depth_src_layer, 1);
DRW_shgroup_call_add(grp, quad, NULL);
- psl->minmaxz_copydepth = DRW_pass_create("HiZ Copy Depth", DRW_STATE_WRITE_COLOR);
- grp = DRW_shgroup_create(e_data.minmaxz_copydepth_sh, psl->minmaxz_copydepth);
- DRW_shgroup_uniform_buffer(grp, "depthBuffer", &e_data.minmmaxz_depth_src);
+ /* Copy depth buffer to halfres top level of HiZ */
+ psl->minz_copydepth_ps = DRW_pass_create("HiZ Min Copy Depth Fullres", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_ALWAYS);
+ grp = DRW_shgroup_create(e_data.minz_copydepth_sh, psl->minz_copydepth_ps);
+ DRW_shgroup_uniform_buffer(grp, "depthBuffer", &e_data.depth_src);
+ DRW_shgroup_call_add(grp, quad, NULL);
+
+ psl->maxz_copydepth_ps = DRW_pass_create("HiZ Max Copy Depth Fullres", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_ALWAYS);
+ grp = DRW_shgroup_create(e_data.maxz_copydepth_sh, psl->maxz_copydepth_ps);
+ DRW_shgroup_uniform_buffer(grp, "depthBuffer", &e_data.depth_src);
+ DRW_shgroup_call_add(grp, quad, NULL);
+ }
+
+ {
+ psl->ao_horizon_search = DRW_pass_create("GTAO Horizon Search", DRW_STATE_WRITE_COLOR);
+ DRWShadingGroup *grp = DRW_shgroup_create(e_data.gtao_sh, psl->ao_horizon_search);
+ DRW_shgroup_uniform_buffer(grp, "maxzBuffer", &txl->maxzbuffer);
+ DRW_shgroup_uniform_buffer(grp, "depthBuffer", &e_data.depth_src);
+ DRW_shgroup_uniform_vec4(grp, "viewvecs[0]", (float *)stl->g_data->viewvecs, 2);
+ DRW_shgroup_uniform_vec2(grp, "mipRatio[0]", (float *)stl->g_data->mip_ratio, 10);
+ DRW_shgroup_uniform_vec4(grp, "aoParameters[0]", &stl->effects->ao_dist, 2);
+ DRW_shgroup_uniform_float(grp, "sampleNbr", &stl->effects->ao_sample_nbr, 1);
+ DRW_shgroup_uniform_ivec2(grp, "aoHorizonTexSize", (int *)stl->effects->ao_texsize, 1);
+ DRW_shgroup_uniform_texture(grp, "utilTex", EEVEE_materials_get_util_tex());
+ DRW_shgroup_call_add(grp, quad, NULL);
+
+ psl->ao_horizon_debug = DRW_pass_create("GTAO Horizon Debug", DRW_STATE_WRITE_COLOR);
+ grp = DRW_shgroup_create(e_data.gtao_debug_sh, psl->ao_horizon_debug);
+ DRW_shgroup_uniform_buffer(grp, "maxzBuffer", &txl->maxzbuffer);
+ DRW_shgroup_uniform_buffer(grp, "depthBuffer", &e_data.depth_src);
+ DRW_shgroup_uniform_buffer(grp, "normalBuffer", &txl->ssr_normal_input);
+ DRW_shgroup_uniform_buffer(grp, "horizonBuffer", &txl->gtao_horizons);
+ DRW_shgroup_uniform_vec4(grp, "viewvecs[0]", (float *)stl->g_data->viewvecs, 2);
+ DRW_shgroup_uniform_vec2(grp, "mipRatio[0]", (float *)stl->g_data->mip_ratio, 10);
+ DRW_shgroup_uniform_vec4(grp, "aoParameters[0]", &stl->effects->ao_dist, 2);
+ DRW_shgroup_uniform_ivec2(grp, "aoHorizonTexSize", (int *)stl->effects->ao_texsize, 1);
+ DRW_shgroup_uniform_texture(grp, "utilTex", EEVEE_materials_get_util_tex());
DRW_shgroup_call_add(grp, quad, NULL);
}
@@ -500,8 +1158,9 @@ void EEVEE_effects_cache_init(EEVEE_Data *vedata)
eevee_create_bloom_pass("Bloom Upsample", effects, e_data.bloom_upsample_sh[use_highres], &psl->bloom_upsample, true);
grp = eevee_create_bloom_pass("Bloom Blit", effects, e_data.bloom_blit_sh[use_antiflicker], &psl->bloom_blit, false);
DRW_shgroup_uniform_vec4(grp, "curveThreshold", effects->bloom_curve_threshold, 1);
+ DRW_shgroup_uniform_float(grp, "clampIntensity", &effects->bloom_clamp, 1);
grp = eevee_create_bloom_pass("Bloom Resolve", effects, e_data.bloom_resolve_sh[use_highres], &psl->bloom_resolve, true);
- DRW_shgroup_uniform_float(grp, "bloomIntensity", &effects->bloom_intensity, 1);
+ DRW_shgroup_uniform_vec3(grp, "bloomColor", effects->bloom_color, 1);
}
{
@@ -530,7 +1189,7 @@ void EEVEE_effects_cache_init(EEVEE_Data *vedata)
/* This create an empty batch of N triangles to be positioned
* by the vertex shader 0.4ms against 6ms with instancing */
const float *viewport_size = DRW_viewport_size_get();
- const int sprite_ct = ((int)viewport_size[0]/2) * ((int)viewport_size[1]/2); /* brackets matters */
+ const int sprite_ct = ((int)viewport_size[0] / 2) * ((int)viewport_size[1] / 2); /* brackets matters */
grp = DRW_shgroup_empty_tri_batch_create(e_data.dof_scatter_sh, psl->dof_scatter, sprite_ct);
DRW_shgroup_uniform_buffer(grp, "colorBuffer", &effects->unf_source_buffer);
@@ -551,41 +1210,258 @@ void EEVEE_effects_cache_init(EEVEE_Data *vedata)
}
}
-#define SWAP_BUFFERS() { \
- if (effects->source_buffer == txl->color) { \
- effects->source_buffer = txl->color_post; \
- effects->target_buffer = fbl->main; \
- } \
- else { \
- effects->source_buffer = txl->color; \
- effects->target_buffer = fbl->effect_fb; \
- } \
-} ((void)0)
+static void min_downsample_cb(void *vedata, int UNUSED(level))
+{
+ EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl;
+ DRW_draw_pass(psl->minz_downlevel_ps);
+}
-static void minmax_downsample_cb(void *vedata, int UNUSED(level))
+static void max_downsample_cb(void *vedata, int UNUSED(level))
{
EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl;
- DRW_draw_pass(psl->minmaxz_downlevel);
+ DRW_draw_pass(psl->maxz_downlevel_ps);
}
-void EEVEE_create_minmax_buffer(EEVEE_Data *vedata, GPUTexture *depth_src)
+static void simple_downsample_cb(void *vedata, int UNUSED(level))
+{
+ EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl;
+ DRW_draw_pass(psl->color_downsample_ps);
+}
+
+static void simple_downsample_cube_cb(void *vedata, int level)
+{
+ EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl;
+ e_data.cube_texel_size = (float)(1 << level) / (float)GPU_texture_width(e_data.color_src);
+ DRW_draw_pass(psl->color_downsample_cube_ps);
+}
+
+void EEVEE_create_minmax_buffer(EEVEE_Data *vedata, GPUTexture *depth_src, int layer)
{
EEVEE_PassList *psl = vedata->psl;
EEVEE_FramebufferList *fbl = vedata->fbl;
EEVEE_StorageList *stl = vedata->stl;
+ EEVEE_TextureList *txl = vedata->txl;
- e_data.minmmaxz_depth_src = depth_src;
+ e_data.depth_src = depth_src;
+ e_data.depth_src_layer = layer;
- /* Copy depth buffer to minmax texture top level */
- DRW_framebuffer_texture_attach(fbl->minmaxz_fb, stl->g_data->minmaxz, 0, 0);
- DRW_framebuffer_bind(fbl->minmaxz_fb);
- DRW_draw_pass(psl->minmaxz_downdepth);
- DRW_framebuffer_texture_detach(stl->g_data->minmaxz);
+ DRW_stats_group_start("Min buffer");
+ /* Copy depth buffer to min texture top level */
+ DRW_framebuffer_texture_attach(fbl->downsample_fb, stl->g_data->minzbuffer, 0, 0);
+ DRW_framebuffer_bind(fbl->downsample_fb);
+ if (layer >= 0) {
+ DRW_draw_pass(psl->minz_downdepth_layer_ps);
+ }
+ else {
+ DRW_draw_pass(psl->minz_downdepth_ps);
+ }
+ DRW_framebuffer_texture_detach(stl->g_data->minzbuffer);
+
+ /* Create lower levels */
+ DRW_framebuffer_recursive_downsample(fbl->downsample_fb, stl->g_data->minzbuffer, 8, &min_downsample_cb, vedata);
+ DRW_stats_group_end();
+
+ DRW_stats_group_start("Max buffer");
+ /* Copy depth buffer to max texture top level */
+ DRW_framebuffer_texture_attach(fbl->downsample_fb, txl->maxzbuffer, 0, 0);
+ DRW_framebuffer_bind(fbl->downsample_fb);
+ if (layer >= 0) {
+ DRW_draw_pass(psl->maxz_downdepth_layer_ps);
+ }
+ else {
+ DRW_draw_pass(psl->maxz_downdepth_ps);
+ }
+ DRW_framebuffer_texture_detach(txl->maxzbuffer);
/* Create lower levels */
- DRW_framebuffer_recursive_downsample(fbl->minmaxz_fb, stl->g_data->minmaxz, 6, &minmax_downsample_cb, vedata);
+ DRW_framebuffer_recursive_downsample(fbl->downsample_fb, txl->maxzbuffer, 8, &max_downsample_cb, vedata);
+ DRW_stats_group_end();
+}
+
+/**
+ * Simple downsampling algorithm. Reconstruct mip chain up to mip level.
+ **/
+void EEVEE_downsample_buffer(EEVEE_Data *vedata, struct GPUFrameBuffer *fb_src, GPUTexture *texture_src, int level)
+{
+ e_data.color_src = texture_src;
+
+ DRW_stats_group_start("Downsample buffer");
+ /* Create lower levels */
+ DRW_framebuffer_recursive_downsample(fb_src, texture_src, level, &simple_downsample_cb, vedata);
+ DRW_stats_group_end();
+}
+
+/**
+ * Simple downsampling algorithm for cubemap. Reconstruct mip chain up to mip level.
+ **/
+void EEVEE_downsample_cube_buffer(EEVEE_Data *vedata, struct GPUFrameBuffer *fb_src, GPUTexture *texture_src, int level)
+{
+ e_data.color_src = texture_src;
+
+ DRW_stats_group_start("Downsample Cube buffer");
+ /* Create lower levels */
+ DRW_framebuffer_recursive_downsample(fb_src, texture_src, level, &simple_downsample_cube_cb, vedata);
+ DRW_stats_group_end();
+}
+
+void EEVEE_effects_do_volumetrics(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata)
+{
+ EEVEE_PassList *psl = vedata->psl;
+ EEVEE_FramebufferList *fbl = vedata->fbl;
+ EEVEE_StorageList *stl = vedata->stl;
+ EEVEE_EffectsInfo *effects = stl->effects;
+
+ if ((effects->enabled_effects & EFFECT_VOLUMETRIC) != 0) {
+ DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
+
+ e_data.depth_src = dtxl->depth;
+
+ /* Compute volumetric integration at halfres. */
+ DRW_framebuffer_texture_attach(fbl->volumetric_fb, stl->g_data->volumetric, 0, 0);
+ if (sldata->volumetrics->use_colored_transmit) {
+ DRW_framebuffer_texture_attach(fbl->volumetric_fb, stl->g_data->volumetric_transmit, 1, 0);
+ }
+ DRW_framebuffer_bind(fbl->volumetric_fb);
+ DRW_draw_pass(psl->volumetric_integrate_ps);
+
+ /* Resolve at fullres */
+ DRW_framebuffer_texture_detach(dtxl->depth);
+ DRW_framebuffer_bind(fbl->main);
+ if (sldata->volumetrics->use_colored_transmit) {
+ DRW_draw_pass(psl->volumetric_resolve_transmit_ps);
+ }
+ DRW_draw_pass(psl->volumetric_resolve_ps);
+
+ /* Restore */
+ DRW_framebuffer_texture_attach(fbl->main, dtxl->depth, 0, 0);
+ DRW_framebuffer_texture_detach(stl->g_data->volumetric);
+ if (sldata->volumetrics->use_colored_transmit) {
+ DRW_framebuffer_texture_detach(stl->g_data->volumetric_transmit);
+ }
+
+ /* Rebind main buffer after attach/detach operations */
+ DRW_framebuffer_bind(fbl->main);
+ }
}
+void EEVEE_effects_do_refraction(EEVEE_SceneLayerData *UNUSED(sldata), EEVEE_Data *vedata)
+{
+ EEVEE_FramebufferList *fbl = vedata->fbl;
+ EEVEE_TextureList *txl = vedata->txl;
+ EEVEE_StorageList *stl = vedata->stl;
+ EEVEE_EffectsInfo *effects = stl->effects;
+
+ if ((effects->enabled_effects & EFFECT_REFRACT) != 0) {
+ DRW_framebuffer_texture_attach(fbl->refract_fb, txl->refract_color, 0, 0);
+ DRW_framebuffer_blit(fbl->main, fbl->refract_fb, false);
+ EEVEE_downsample_buffer(vedata, fbl->downsample_fb, txl->refract_color, 9);
+ }
+}
+
+void EEVEE_effects_do_ssr(EEVEE_SceneLayerData *UNUSED(sldata), EEVEE_Data *vedata)
+{
+ EEVEE_PassList *psl = vedata->psl;
+ EEVEE_FramebufferList *fbl = vedata->fbl;
+ EEVEE_StorageList *stl = vedata->stl;
+ EEVEE_TextureList *txl = vedata->txl;
+ EEVEE_EffectsInfo *effects = stl->effects;
+
+ if (((effects->enabled_effects & EFFECT_SSR) != 0) && stl->g_data->valid_double_buffer) {
+ DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
+ e_data.depth_src = dtxl->depth;
+
+ for (int i = 0; i < effects->ssr_ray_count; ++i) {
+ DRW_framebuffer_texture_attach(fbl->screen_tracing_fb, stl->g_data->ssr_hit_output[i], i, 0);
+ }
+ DRW_framebuffer_bind(fbl->screen_tracing_fb);
+
+ /* Raytrace. */
+ DRW_draw_pass(psl->ssr_raytrace);
+
+ for (int i = 0; i < effects->ssr_ray_count; ++i) {
+ DRW_framebuffer_texture_detach(stl->g_data->ssr_hit_output[i]);
+ }
+
+ EEVEE_downsample_buffer(vedata, fbl->downsample_fb, txl->color_double_buffer, 9);
+
+ /* Resolve at fullres */
+ DRW_framebuffer_texture_detach(dtxl->depth);
+ DRW_framebuffer_texture_detach(txl->ssr_normal_input);
+ DRW_framebuffer_texture_detach(txl->ssr_specrough_input);
+ DRW_framebuffer_bind(fbl->main);
+ DRW_draw_pass(psl->ssr_resolve);
+
+ /* Restore */
+ DRW_framebuffer_texture_attach(fbl->main, dtxl->depth, 0, 0);
+ DRW_framebuffer_texture_attach(fbl->main, txl->ssr_normal_input, 1, 0);
+ DRW_framebuffer_texture_attach(fbl->main, txl->ssr_specrough_input, 2, 0);
+ }
+
+ if ((effects->enabled_effects & EFFECT_GTAO) != 0 && G.debug_value == 6) {
+ /* GTAO Debug */
+ DRW_framebuffer_texture_attach(fbl->gtao_debug_fb, stl->g_data->gtao_horizons_debug, 0, 0);
+ DRW_framebuffer_bind(fbl->gtao_debug_fb);
+
+ DRW_draw_pass(psl->ao_horizon_debug);
+
+ /* Restore */
+ DRW_framebuffer_texture_detach(stl->g_data->gtao_horizons_debug);
+ }
+
+ DRW_framebuffer_bind(fbl->main);
+}
+
+void EEVEE_effects_do_gtao(EEVEE_SceneLayerData *UNUSED(sldata), EEVEE_Data *vedata)
+{
+ EEVEE_PassList *psl = vedata->psl;
+ EEVEE_TextureList *txl = vedata->txl;
+ EEVEE_FramebufferList *fbl = vedata->fbl;
+ EEVEE_StorageList *stl = vedata->stl;
+ EEVEE_EffectsInfo *effects = stl->effects;
+
+ if ((effects->enabled_effects & EFFECT_GTAO) != 0) {
+ DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
+ e_data.depth_src = dtxl->depth;
+
+ DRW_stats_group_start("GTAO Horizon Scan");
+ for (effects->ao_sample_nbr = 0.0;
+ effects->ao_sample_nbr < effects->ao_samples;
+ ++effects->ao_sample_nbr)
+ {
+ DRW_framebuffer_texture_detach(txl->gtao_horizons);
+ DRW_framebuffer_texture_layer_attach(fbl->gtao_fb, txl->gtao_horizons, 0, (int)effects->ao_sample_nbr, 0);
+ DRW_framebuffer_bind(fbl->gtao_fb);
+
+ DRW_draw_pass(psl->ao_horizon_search);
+ }
+ DRW_stats_group_end();
+
+ /* Restore */
+ DRW_framebuffer_bind(fbl->main);
+ }
+}
+
+#define SWAP_DOUBLE_BUFFERS() { \
+ if (swap_double_buffer) { \
+ SWAP(struct GPUFrameBuffer *, fbl->main, fbl->double_buffer); \
+ SWAP(GPUTexture *, txl->color, txl->color_double_buffer); \
+ swap_double_buffer = false; \
+ } \
+} ((void)0)
+
+#define SWAP_BUFFERS() { \
+ if (effects->target_buffer != fbl->main) { \
+ SWAP_DOUBLE_BUFFERS(); \
+ effects->source_buffer = txl->color_post; \
+ effects->target_buffer = fbl->main; \
+ } \
+ else { \
+ SWAP_DOUBLE_BUFFERS(); \
+ effects->source_buffer = txl->color; \
+ effects->target_buffer = fbl->effect_fb; \
+ } \
+} ((void)0)
+
void EEVEE_draw_effects(EEVEE_Data *vedata)
{
EEVEE_PassList *psl = vedata->psl;
@@ -594,6 +1470,9 @@ void EEVEE_draw_effects(EEVEE_Data *vedata)
EEVEE_StorageList *stl = vedata->stl;
EEVEE_EffectsInfo *effects = stl->effects;
+ /* only once per frame after the first post process */
+ bool swap_double_buffer = ((effects->enabled_effects & EFFECT_DOUBLE_BUFFER) != 0);
+
/* Default framebuffer and texture */
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
@@ -602,6 +1481,37 @@ void EEVEE_draw_effects(EEVEE_Data *vedata)
effects->source_buffer = txl->color; /* latest updated texture */
effects->target_buffer = fbl->effect_fb; /* next target to render to */
+ /* Temporal Anti-Aliasing */
+ /* MUST COME FIRST. */
+ if ((effects->enabled_effects & EFFECT_TAA) != 0) {
+ if (effects->taa_current_sample != 1) {
+ DRW_framebuffer_bind(fbl->effect_fb);
+ DRW_draw_pass(psl->taa_resolve);
+
+ /* Restore the depth from sample 1. */
+ DRW_framebuffer_blit(fbl->depth_double_buffer_fb, fbl->main, true);
+
+ /* Special Swap */
+ SWAP(struct GPUFrameBuffer *, fbl->effect_fb, fbl->double_buffer);
+ SWAP(GPUTexture *, txl->color_post, txl->color_double_buffer);
+ swap_double_buffer = false;
+ effects->source_buffer = txl->color_double_buffer;
+ effects->target_buffer = fbl->main;
+ }
+ else {
+ /* Save the depth buffer for the next frame.
+ * This saves us from doing anything special
+ * in the other mode engines. */
+ DRW_framebuffer_blit(fbl->main, fbl->depth_double_buffer_fb, true);
+ }
+
+ if ((effects->taa_total_sample == 0) ||
+ (effects->taa_current_sample < effects->taa_total_sample))
+ {
+ DRW_viewport_request_redraw();
+ }
+ }
+
/* Detach depth for effects to use it */
DRW_framebuffer_texture_detach(dtxl->depth);
@@ -667,7 +1577,7 @@ void EEVEE_draw_effects(EEVEE_Data *vedata)
last = txl->bloom_downsample[0];
for (int i = 1; i < effects->bloom_iteration_ct; ++i) {
- copy_v2_v2(effects->unf_source_texel_size, effects->downsamp_texel_size[i-1]);
+ copy_v2_v2(effects->unf_source_texel_size, effects->downsamp_texel_size[i - 1]);
effects->unf_source_buffer = last;
DRW_framebuffer_bind(fbl->bloom_down_fb[i]);
@@ -705,13 +1615,77 @@ void EEVEE_draw_effects(EEVEE_Data *vedata)
/* Tonemapping */
DRW_transform_to_display(effects->source_buffer);
+
+ /* Debug : Ouput buffer to view. */
+ if ((G.debug_value > 0) && (G.debug_value <= 6)) {
+ switch (G.debug_value) {
+ case 1:
+ if (txl->maxzbuffer) DRW_transform_to_display(txl->maxzbuffer);
+ break;
+ case 2:
+ if (stl->g_data->ssr_hit_output[0]) DRW_transform_to_display(stl->g_data->ssr_hit_output[0]);
+ break;
+ case 3:
+ if (txl->ssr_normal_input) DRW_transform_to_display(txl->ssr_normal_input);
+ break;
+ case 4:
+ if (txl->ssr_specrough_input) DRW_transform_to_display(txl->ssr_specrough_input);
+ break;
+ case 5:
+ if (txl->color_double_buffer) DRW_transform_to_display(txl->color_double_buffer);
+ break;
+ case 6:
+ if (stl->g_data->gtao_horizons_debug) DRW_transform_to_display(stl->g_data->gtao_horizons_debug);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /* If no post processes is enabled, buffers are still not swapped, do it now. */
+ SWAP_DOUBLE_BUFFERS();
+
+ if (!stl->g_data->valid_double_buffer &&
+ ((effects->enabled_effects & EFFECT_DOUBLE_BUFFER) != 0) &&
+ (DRW_state_is_image_render() == false))
+ {
+ /* If history buffer is not valid request another frame.
+ * This fix black reflections on area resize. */
+ DRW_viewport_request_redraw();
+ }
+
+ /* Record pers matrix for the next frame. */
+ DRW_viewport_matrix_get(stl->g_data->prev_persmat, DRW_MAT_PERS);
+
+ /* Update double buffer status if render mode. */
+ if (DRW_state_is_image_render()) {
+ stl->g_data->valid_double_buffer = (txl->color_double_buffer != NULL);
+ }
}
void EEVEE_effects_free(void)
{
- DRW_SHADER_FREE_SAFE(e_data.minmaxz_downlevel_sh);
- DRW_SHADER_FREE_SAFE(e_data.minmaxz_downdepth_sh);
- DRW_SHADER_FREE_SAFE(e_data.minmaxz_copydepth_sh);
+ for (int i = 0; i < SSR_MAX_SHADER; ++i) {
+ DRW_SHADER_FREE_SAFE(e_data.ssr_sh[i]);
+ }
+ DRW_SHADER_FREE_SAFE(e_data.downsample_sh);
+ DRW_SHADER_FREE_SAFE(e_data.downsample_cube_sh);
+
+ DRW_SHADER_FREE_SAFE(e_data.taa_resolve_sh);
+
+ DRW_SHADER_FREE_SAFE(e_data.gtao_sh);
+ DRW_SHADER_FREE_SAFE(e_data.gtao_debug_sh);
+
+ DRW_SHADER_FREE_SAFE(e_data.volumetric_upsample_sh);
+
+ DRW_SHADER_FREE_SAFE(e_data.minz_downlevel_sh);
+ DRW_SHADER_FREE_SAFE(e_data.maxz_downlevel_sh);
+ DRW_SHADER_FREE_SAFE(e_data.minz_downdepth_sh);
+ DRW_SHADER_FREE_SAFE(e_data.maxz_downdepth_sh);
+ DRW_SHADER_FREE_SAFE(e_data.minz_downdepth_layer_sh);
+ DRW_SHADER_FREE_SAFE(e_data.maxz_downdepth_layer_sh);
+ DRW_SHADER_FREE_SAFE(e_data.minz_copydepth_sh);
+ DRW_SHADER_FREE_SAFE(e_data.maxz_copydepth_sh);
DRW_SHADER_FREE_SAFE(e_data.motion_blur_sh);
DRW_SHADER_FREE_SAFE(e_data.dof_downsample_sh);
@@ -726,4 +1700,4 @@ void EEVEE_effects_free(void)
DRW_SHADER_FREE_SAFE(e_data.bloom_downsample_sh[1]);
DRW_SHADER_FREE_SAFE(e_data.bloom_upsample_sh[1]);
DRW_SHADER_FREE_SAFE(e_data.bloom_resolve_sh[1]);
-} \ No newline at end of file
+}
diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c
index c024eb609b3..0014cf7bf1e 100644
--- a/source/blender/draw/engines/eevee/eevee_engine.c
+++ b/source/blender/draw/engines/eevee/eevee_engine.c
@@ -29,6 +29,8 @@
#include "BLI_dynstr.h"
#include "BLI_rand.h"
+#include "BKE_object.h"
+
#include "GPU_material.h"
#include "GPU_glew.h"
@@ -49,68 +51,94 @@ static void EEVEE_engine_init(void *ved)
EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl;
EEVEE_SceneLayerData *sldata = EEVEE_scene_layer_data_get();
- DRWFboTexture tex = {&txl->color, DRW_TEX_RGB_11_11_10, DRW_TEX_FILTER};
+ if (!stl->g_data) {
+ /* Alloc transient pointers */
+ stl->g_data = MEM_callocN(sizeof(*stl->g_data), __func__);
+ }
+ stl->g_data->background_alpha = 1.0f;
+ stl->g_data->valid_double_buffer = (txl->color_double_buffer != NULL);
+
+ DRWFboTexture tex = {&txl->color, DRW_TEX_RGB_11_11_10, DRW_TEX_FILTER | DRW_TEX_MIPMAP};
const float *viewport_size = DRW_viewport_size_get();
DRW_framebuffer_init(&fbl->main, &draw_engine_eevee_type,
(int)viewport_size[0], (int)viewport_size[1],
&tex, 1);
- if (!stl->g_data) {
- /* Alloc transient pointers */
- stl->g_data = MEM_mallocN(sizeof(*stl->g_data), __func__);
- }
- stl->g_data->background_alpha = 1.0f;
+ /* EEVEE_effects_init needs to go first for TAA */
+ EEVEE_effects_init(sldata, vedata);
- EEVEE_materials_init();
+ EEVEE_materials_init(stl);
EEVEE_lights_init(sldata);
EEVEE_lightprobes_init(sldata, vedata);
- EEVEE_effects_init(vedata);
+
+ if (stl->effects->taa_current_sample > 1) {
+ /* XXX otherwise it would break the other engines. */
+ DRW_viewport_matrix_override_unset(DRW_MAT_PERS);
+ DRW_viewport_matrix_override_unset(DRW_MAT_PERSINV);
+ DRW_viewport_matrix_override_unset(DRW_MAT_WIN);
+ DRW_viewport_matrix_override_unset(DRW_MAT_WININV);
+ }
}
static void EEVEE_cache_init(void *vedata)
{
EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl;
- EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl;
EEVEE_SceneLayerData *sldata = EEVEE_scene_layer_data_get();
EEVEE_materials_cache_init(vedata);
EEVEE_lights_cache_init(sldata, psl);
- EEVEE_lightprobes_cache_init(sldata, psl, stl);
- EEVEE_effects_cache_init(vedata);
+ EEVEE_lightprobes_cache_init(sldata, vedata);
+ EEVEE_effects_cache_init(sldata, vedata);
}
static void EEVEE_cache_populate(void *vedata, Object *ob)
{
- EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl;
EEVEE_SceneLayerData *sldata = EEVEE_scene_layer_data_get();
const DRWContextState *draw_ctx = DRW_context_state_get();
const bool is_active = (ob == draw_ctx->obact);
if (is_active) {
- if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) {
+ if (DRW_object_is_mode_shade(ob) == true) {
return;
}
}
- struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob);
- if (geom) {
- EEVEE_materials_cache_populate(vedata, sldata, ob, geom);
+ if (ELEM(ob->type, OB_MESH)) {
+ if (!BKE_object_is_visible(ob)) {
+ return;
+ }
+
+ EEVEE_materials_cache_populate(vedata, sldata, ob);
const bool cast_shadow = true;
if (cast_shadow) {
- EEVEE_lights_cache_shcaster_add(sldata, psl, geom, ob->obmat);
- BLI_addtail(&sldata->shadow_casters, BLI_genericNodeN(ob));
- EEVEE_ObjectEngineData *oedata = EEVEE_object_data_get(ob);
- oedata->need_update = ((ob->deg_update_flag & DEG_RUNTIME_DATA_UPDATE) != 0);
+ if ((ob->base_flag & BASE_FROMDUPLI) != 0) {
+ /* TODO: Special case for dupli objects because we cannot save the object pointer. */
+ }
+ else {
+ BLI_addtail(&sldata->shadow_casters, BLI_genericNodeN(ob));
+ EEVEE_ObjectEngineData *oedata = EEVEE_object_data_get(ob);
+ oedata->need_update = ((ob->deg_update_flag & DEG_RUNTIME_DATA_UPDATE) != 0);
+ }
}
}
else if (ob->type == OB_LIGHTPROBE) {
- EEVEE_lightprobes_cache_add(sldata, ob);
+ if ((ob->base_flag & BASE_FROMDUPLI) != 0) {
+ /* TODO: Special case for dupli objects because we cannot save the object pointer. */
+ }
+ else {
+ EEVEE_lightprobes_cache_add(sldata, ob);
+ }
}
else if (ob->type == OB_LAMP) {
- EEVEE_lights_cache_add(sldata, ob);
+ if ((ob->base_flag & BASE_FROMDUPLI) != 0) {
+ /* TODO: Special case for dupli objects because we cannot save the object pointer. */
+ }
+ else {
+ EEVEE_lights_cache_add(sldata, ob);
+ }
}
}
@@ -126,43 +154,138 @@ static void EEVEE_cache_finish(void *vedata)
static void EEVEE_draw_scene(void *vedata)
{
EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl;
+ EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl;
EEVEE_FramebufferList *fbl = ((EEVEE_Data *)vedata)->fbl;
EEVEE_SceneLayerData *sldata = EEVEE_scene_layer_data_get();
/* Default framebuffer and texture */
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
- /* Refresh shadows */
- EEVEE_draw_shadows(sldata, psl);
+ /* Number of iteration: needed for all temporal effect (SSR, TAA)
+ * when using opengl render. */
+ int loop_ct = DRW_state_is_image_render() ? 4 : 1;
- /* Refresh Probes */
- EEVEE_lightprobes_refresh(sldata, vedata);
+ static float rand = 0.0f;
- /* Attach depth to the hdr buffer and bind it */
- DRW_framebuffer_texture_detach(dtxl->depth);
- DRW_framebuffer_texture_attach(fbl->main, dtxl->depth, 0, 0);
- DRW_framebuffer_bind(fbl->main);
- DRW_framebuffer_clear(false, true, false, NULL, 1.0f);
+ /* XXX temp for denoising render. TODO plug number of samples here */
+ if (DRW_state_is_image_render()) {
+ rand += 1.0f / 16.0f;
+ rand = rand - floorf(rand);
- DRW_draw_pass(psl->background_pass);
+ /* Set jitter offset */
+ EEVEE_update_util_texture(rand);
+ }
+ else if (((stl->effects->enabled_effects & EFFECT_TAA) != 0) && (stl->effects->taa_current_sample > 1)) {
+ double r;
+ BLI_halton_1D(2, 0.0, stl->effects->taa_current_sample - 1, &r);
- /* Depth prepass */
- DRW_draw_pass(psl->depth_pass);
- DRW_draw_pass(psl->depth_pass_cull);
+ /* Set jitter offset */
+ /* PERF This is killing perf ! */
+ EEVEE_update_util_texture((float)r);
+ }
- /* Create minmax texture */
- EEVEE_create_minmax_buffer(vedata, dtxl->depth);
+ while (loop_ct--) {
+
+ /* Refresh Probes */
+ DRW_stats_group_start("Probes Refresh");
+ EEVEE_lightprobes_refresh(sldata, vedata);
+ DRW_stats_group_end();
+
+ /* Refresh shadows */
+ DRW_stats_group_start("Shadows");
+ EEVEE_draw_shadows(sldata, psl);
+ DRW_stats_group_end();
+
+ /* Attach depth to the hdr buffer and bind it */
+ DRW_framebuffer_texture_detach(dtxl->depth);
+ DRW_framebuffer_texture_attach(fbl->main, dtxl->depth, 0, 0);
+ DRW_framebuffer_bind(fbl->main);
+ DRW_framebuffer_clear(false, true, false, NULL, 1.0f);
+
+ if (((stl->effects->enabled_effects & EFFECT_TAA) != 0) && stl->effects->taa_current_sample > 1) {
+ DRW_viewport_matrix_override_set(stl->effects->overide_persmat, DRW_MAT_PERS);
+ DRW_viewport_matrix_override_set(stl->effects->overide_persinv, DRW_MAT_PERSINV);
+ DRW_viewport_matrix_override_set(stl->effects->overide_winmat, DRW_MAT_WIN);
+ DRW_viewport_matrix_override_set(stl->effects->overide_wininv, DRW_MAT_WININV);
+ }
- /* Restore main FB */
- DRW_framebuffer_bind(fbl->main);
+ /* Depth prepass */
+ DRW_stats_group_start("Prepass");
+ DRW_draw_pass(psl->depth_pass);
+ DRW_draw_pass(psl->depth_pass_cull);
+ DRW_stats_group_end();
+
+ /* Create minmax texture */
+ DRW_stats_group_start("Main MinMax buffer");
+ EEVEE_create_minmax_buffer(vedata, dtxl->depth, -1);
+ DRW_stats_group_end();
+
+ /* Compute GTAO Horizons */
+ EEVEE_effects_do_gtao(sldata, vedata);
+
+ /* Restore main FB */
+ DRW_framebuffer_bind(fbl->main);
+
+ /* Shading pass */
+ DRW_stats_group_start("Shading");
+ DRW_draw_pass(psl->background_pass);
+ EEVEE_draw_default_passes(psl);
+ DRW_draw_pass(psl->material_pass);
+ DRW_stats_group_end();
+
+ /* Screen Space Reflections */
+ DRW_stats_group_start("SSR");
+ EEVEE_effects_do_ssr(sldata, vedata);
+ DRW_stats_group_end();
+
+ DRW_draw_pass(psl->probe_display);
+
+ /* Prepare Refraction */
+ EEVEE_effects_do_refraction(sldata, vedata);
+
+ /* Restore main FB */
+ DRW_framebuffer_bind(fbl->main);
+
+ /* Opaque refraction */
+ DRW_stats_group_start("Opaque Refraction");
+ DRW_draw_pass(psl->refract_depth_pass);
+ DRW_draw_pass(psl->refract_depth_pass_cull);
+ DRW_draw_pass(psl->refract_pass);
+ DRW_stats_group_end();
+
+ /* Transparent */
+ DRW_pass_sort_shgroup_z(psl->transparent_pass);
+ DRW_stats_group_start("Transparent");
+ DRW_draw_pass(psl->transparent_pass);
+ DRW_stats_group_end();
+
+ /* Volumetrics */
+ DRW_stats_group_start("Volumetrics");
+ EEVEE_effects_do_volumetrics(sldata, vedata);
+ DRW_stats_group_end();
+
+ /* Post Process */
+ DRW_stats_group_start("Post FX");
+ EEVEE_draw_effects(vedata);
+ DRW_stats_group_end();
+
+ if (stl->effects->taa_current_sample > 1) {
+ DRW_viewport_matrix_override_unset(DRW_MAT_PERS);
+ DRW_viewport_matrix_override_unset(DRW_MAT_PERSINV);
+ DRW_viewport_matrix_override_unset(DRW_MAT_WIN);
+ DRW_viewport_matrix_override_unset(DRW_MAT_WININV);
+ }
+ }
- /* Shading pass */
- DRW_draw_pass(psl->probe_display);
- EEVEE_draw_default_passes(psl);
- DRW_draw_pass(psl->material_pass);
+ stl->g_data->view_updated = false;
+}
- /* Post Process */
- EEVEE_draw_effects(vedata);
+static void EEVEE_view_update(void *vedata)
+{
+ EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl;
+ if (stl->g_data) {
+ stl->g_data->view_updated = true;
+ }
}
static void EEVEE_engine_free(void)
@@ -188,25 +311,60 @@ static void EEVEE_scene_layer_settings_create(RenderEngine *UNUSED(engine), IDPr
props->type == IDP_GROUP &&
props->subtype == IDP_GROUP_SUB_ENGINE_RENDER);
+ BKE_collection_engine_property_add_int(props, "gi_diffuse_bounces", 3);
+
+ BKE_collection_engine_property_add_int(props, "taa_samples", 8);
+
+ BKE_collection_engine_property_add_bool(props, "ssr_enable", false);
+ BKE_collection_engine_property_add_bool(props, "ssr_refraction", false);
+ BKE_collection_engine_property_add_bool(props, "ssr_halfres", true);
+ BKE_collection_engine_property_add_int(props, "ssr_ray_count", 1);
+ BKE_collection_engine_property_add_float(props, "ssr_quality", 0.25f);
+ BKE_collection_engine_property_add_float(props, "ssr_max_roughness", 0.5f);
+ BKE_collection_engine_property_add_float(props, "ssr_thickness", 0.2f);
+ BKE_collection_engine_property_add_float(props, "ssr_border_fade", 0.075f);
+ BKE_collection_engine_property_add_float(props, "ssr_firefly_fac", 10.0f);
+
+ BKE_collection_engine_property_add_bool(props, "volumetric_enable", false);
+ BKE_collection_engine_property_add_float(props, "volumetric_start", 0.1f);
+ BKE_collection_engine_property_add_float(props, "volumetric_end", 100.0f);
+ BKE_collection_engine_property_add_int(props, "volumetric_samples", 64);
+ BKE_collection_engine_property_add_float(props, "volumetric_sample_distribution", 0.8f);
+ BKE_collection_engine_property_add_bool(props, "volumetric_lights", true);
+ BKE_collection_engine_property_add_float(props, "volumetric_light_clamp", 0.0f);
+ BKE_collection_engine_property_add_bool(props, "volumetric_shadows", false);
+ BKE_collection_engine_property_add_int(props, "volumetric_shadow_samples", 16);
+ BKE_collection_engine_property_add_bool(props, "volumetric_colored_transmittance", true);
+
BKE_collection_engine_property_add_bool(props, "gtao_enable", false);
BKE_collection_engine_property_add_bool(props, "gtao_use_bent_normals", true);
+ BKE_collection_engine_property_add_bool(props, "gtao_denoise", true);
+ BKE_collection_engine_property_add_bool(props, "gtao_bounce", true);
BKE_collection_engine_property_add_float(props, "gtao_distance", 0.2f);
BKE_collection_engine_property_add_float(props, "gtao_factor", 1.0f);
+ BKE_collection_engine_property_add_float(props, "gtao_quality", 0.25f);
BKE_collection_engine_property_add_int(props, "gtao_samples", 2);
BKE_collection_engine_property_add_bool(props, "dof_enable", false);
BKE_collection_engine_property_add_float(props, "bokeh_max_size", 100.0f);
BKE_collection_engine_property_add_float(props, "bokeh_threshold", 1.0f);
+ float default_bloom_color[3] = {1.0f, 1.0f, 1.0f};
BKE_collection_engine_property_add_bool(props, "bloom_enable", false);
+ BKE_collection_engine_property_add_float_array(props, "bloom_color", default_bloom_color, 3);
BKE_collection_engine_property_add_float(props, "bloom_threshold", 0.8f);
BKE_collection_engine_property_add_float(props, "bloom_knee", 0.5f);
BKE_collection_engine_property_add_float(props, "bloom_intensity", 0.8f);
BKE_collection_engine_property_add_float(props, "bloom_radius", 6.5f);
+ BKE_collection_engine_property_add_float(props, "bloom_clamp", 1.0f);
BKE_collection_engine_property_add_bool(props, "motion_blur_enable", false);
BKE_collection_engine_property_add_int(props, "motion_blur_samples", 8);
BKE_collection_engine_property_add_float(props, "motion_blur_shutter", 1.0f);
+
+ BKE_collection_engine_property_add_int(props, "shadow_method", SHADOW_ESM);
+ BKE_collection_engine_property_add_int(props, "shadow_size", 512);
+ BKE_collection_engine_property_add_bool(props, "shadow_high_bitdepth", false);
}
static const DrawEngineDataSize EEVEE_data_size = DRW_VIEWPORT_DATA_SIZE(EEVEE_Data);
@@ -221,7 +379,8 @@ DrawEngineType draw_engine_eevee_type = {
&EEVEE_cache_populate,
&EEVEE_cache_finish,
&EEVEE_draw_scene,
- NULL//&EEVEE_draw_scene
+ NULL, //&EEVEE_draw_scene
+ &EEVEE_view_update,
};
RenderEngineType DRW_engine_viewport_eevee_type = {
diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c
index 8ec603030c5..a8178f86a7e 100644
--- a/source/blender/draw/engines/eevee/eevee_lightprobes.c
+++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c
@@ -19,7 +19,7 @@
*
*/
-/** \file eevee_lights.c
+/** \file eevee_lightprobes.c
* \ingroup DNA
*/
@@ -32,11 +32,10 @@
#include "BKE_object.h"
#include "BLI_dynstr.h"
+#include "BLI_rand.h"
#include "ED_screen.h"
-#include "DRW_render.h"
-
#include "GPU_material.h"
#include "GPU_texture.h"
#include "GPU_glew.h"
@@ -55,34 +54,42 @@ static struct {
struct GPUShader *probe_default_sh;
struct GPUShader *probe_filter_glossy_sh;
struct GPUShader *probe_filter_diffuse_sh;
+ struct GPUShader *probe_grid_fill_sh;
struct GPUShader *probe_grid_display_sh;
struct GPUShader *probe_planar_display_sh;
+ struct GPUShader *probe_planar_downsample_sh;
struct GPUShader *probe_cube_display_sh;
struct GPUTexture *hammersley;
- struct GPUTexture *planar_depth;
struct GPUTexture *planar_minmaxz;
struct GPUTexture *planar_pool_placeholder;
+ struct GPUTexture *depth_placeholder;
+ struct GPUTexture *depth_array_placeholder;
struct GPUTexture *cube_face_depth;
struct GPUTexture *cube_face_minmaxz;
- bool update_world;
+ int update_world;
bool world_ready_to_shade;
} e_data = {NULL}; /* Engine data */
+extern char datatoc_background_vert_glsl[];
extern char datatoc_default_world_frag_glsl[];
-extern char datatoc_fullscreen_vert_glsl[];
extern char datatoc_lightprobe_filter_glossy_frag_glsl[];
extern char datatoc_lightprobe_filter_diffuse_frag_glsl[];
extern char datatoc_lightprobe_geom_glsl[];
extern char datatoc_lightprobe_vert_glsl[];
extern char datatoc_lightprobe_planar_display_frag_glsl[];
extern char datatoc_lightprobe_planar_display_vert_glsl[];
+extern char datatoc_lightprobe_planar_downsample_frag_glsl[];
+extern char datatoc_lightprobe_planar_downsample_geom_glsl[];
+extern char datatoc_lightprobe_planar_downsample_vert_glsl[];
extern char datatoc_lightprobe_cube_display_frag_glsl[];
extern char datatoc_lightprobe_cube_display_vert_glsl[];
extern char datatoc_lightprobe_grid_display_frag_glsl[];
extern char datatoc_lightprobe_grid_display_vert_glsl[];
+extern char datatoc_lightprobe_grid_fill_frag_glsl[];
extern char datatoc_irradiance_lib_glsl[];
+extern char datatoc_lightprobe_lib_glsl[];
extern char datatoc_octahedron_lib_glsl[];
extern char datatoc_bsdf_common_lib_glsl[];
extern char datatoc_bsdf_sampling_lib_glsl[];
@@ -91,18 +98,6 @@ extern GlobalsUboStorage ts;
/* *********** FUNCTIONS *********** */
-/* Van der Corput sequence */
- /* From http://holger.dammertz.org/stuff/notes_HammersleyOnHemisphere.html */
-static float radical_inverse(int i) {
- unsigned int bits = (unsigned int)i;
- bits = (bits << 16u) | (bits >> 16u);
- bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
- bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
- bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
- bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
- return (float)bits * 2.3283064365386963e-10f;
-}
-
static struct GPUTexture *create_hammersley_sample_texture(int samples)
{
struct GPUTexture *tex;
@@ -110,7 +105,9 @@ static struct GPUTexture *create_hammersley_sample_texture(int samples)
int i;
for (i = 0; i < samples; i++) {
- float phi = radical_inverse(i) * 2.0f * M_PI;
+ double dphi;
+ BLI_hammersley_1D(i, &dphi);
+ float phi = (float)dphi * 2.0f * M_PI;
texels[i][0] = cosf(phi);
texels[i][1] = sinf(phi);
}
@@ -142,11 +139,14 @@ static void planar_pool_ensure_alloc(EEVEE_Data *vedata, int num_planar_ref)
if (!txl->planar_pool) {
if (num_planar_ref > 0) {
txl->planar_pool = DRW_texture_create_2D_array(width, height, max_ff(1, num_planar_ref),
- DRW_TEX_RGBA_16, DRW_TEX_FILTER | DRW_TEX_MIPMAP, NULL);
+ DRW_TEX_RGB_11_11_10, DRW_TEX_FILTER | DRW_TEX_MIPMAP, NULL);
+ txl->planar_depth = DRW_texture_create_2D_array(width, height, max_ff(1, num_planar_ref),
+ DRW_TEX_DEPTH_24, 0, NULL);
}
else if (num_planar_ref == 0) {
/* Makes Opengl Happy : Create a placeholder texture that will never be sampled but still bound to shader. */
txl->planar_pool = DRW_texture_create_2D_array(1, 1, 1, DRW_TEX_RGBA_8, DRW_TEX_FILTER | DRW_TEX_MIPMAP, NULL);
+ txl->planar_depth = DRW_texture_create_2D_array(1, 1, 1, DRW_TEX_DEPTH_24, 0, NULL);
}
}
@@ -159,16 +159,15 @@ static void planar_pool_ensure_alloc(EEVEE_Data *vedata, int num_planar_ref)
DRWFboTexture tex_minmaxz = {&e_data.planar_minmaxz, DRW_TEX_RG_32, DRW_TEX_MIPMAP | DRW_TEX_TEMP};
DRW_framebuffer_init(&fbl->planarref_fb, &draw_engine_eevee_type,
width / 2, height / 2, &tex_minmaxz, 1);
-
- /* Note: this is not the configuration used when rendering. */
- DRWFboTexture tex = {&e_data.planar_depth, DRW_TEX_DEPTH_24, DRW_TEX_TEMP};
- DRW_framebuffer_init(&fbl->planarref_fb, &draw_engine_eevee_type,
- width, height, &tex, 1);
}
}
void EEVEE_lightprobes_init(EEVEE_SceneLayerData *sldata, EEVEE_Data *UNUSED(vedata))
{
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ SceneLayer *scene_layer = draw_ctx->scene_layer;
+ IDProperty *props = BKE_scene_layer_engine_evaluated_get(scene_layer, COLLECTION_MODE_NONE, RE_engine_id_BLENDER_EEVEE);
+
/* Shaders */
if (!e_data.probe_filter_glossy_sh) {
char *shader_str = NULL;
@@ -186,7 +185,7 @@ void EEVEE_lightprobes_init(EEVEE_SceneLayerData *sldata, EEVEE_Data *UNUSED(ved
"#define NOISE_SIZE 64\n");
e_data.probe_default_sh = DRW_shader_create(
- datatoc_lightprobe_vert_glsl, datatoc_lightprobe_geom_glsl, datatoc_default_world_frag_glsl, NULL);
+ datatoc_background_vert_glsl, NULL, datatoc_default_world_frag_glsl, NULL);
MEM_freeN(shader_str);
@@ -213,7 +212,9 @@ void EEVEE_lightprobes_init(EEVEE_SceneLayerData *sldata, EEVEE_Data *UNUSED(ved
ds_frag = BLI_dynstr_new();
BLI_dynstr_append(ds_frag, datatoc_octahedron_lib_glsl);
+ BLI_dynstr_append(ds_frag, datatoc_bsdf_common_lib_glsl);
BLI_dynstr_append(ds_frag, datatoc_irradiance_lib_glsl);
+ BLI_dynstr_append(ds_frag, datatoc_lightprobe_lib_glsl);
BLI_dynstr_append(ds_frag, datatoc_lightprobe_grid_display_frag_glsl);
shader_str = BLI_dynstr_get_cstring(ds_frag);
BLI_dynstr_free(ds_frag);
@@ -231,8 +232,20 @@ void EEVEE_lightprobes_init(EEVEE_SceneLayerData *sldata, EEVEE_Data *UNUSED(ved
MEM_freeN(shader_str);
+ e_data.probe_grid_fill_sh = DRW_shader_create_fullscreen(datatoc_lightprobe_grid_fill_frag_glsl,
+#if defined(IRRADIANCE_SH_L2)
+ "#define IRRADIANCE_SH_L2\n"
+#elif defined(IRRADIANCE_CUBEMAP)
+ "#define IRRADIANCE_CUBEMAP\n"
+#elif defined(IRRADIANCE_HL2)
+ "#define IRRADIANCE_HL2\n"
+#endif
+ );
+
ds_frag = BLI_dynstr_new();
BLI_dynstr_append(ds_frag, datatoc_octahedron_lib_glsl);
+ BLI_dynstr_append(ds_frag, datatoc_bsdf_common_lib_glsl);
+ BLI_dynstr_append(ds_frag, datatoc_lightprobe_lib_glsl);
BLI_dynstr_append(ds_frag, datatoc_lightprobe_cube_display_frag_glsl);
shader_str = BLI_dynstr_get_cstring(ds_frag);
BLI_dynstr_free(ds_frag);
@@ -242,17 +255,15 @@ void EEVEE_lightprobes_init(EEVEE_SceneLayerData *sldata, EEVEE_Data *UNUSED(ved
MEM_freeN(shader_str);
- ds_frag = BLI_dynstr_new();
- BLI_dynstr_append(ds_frag, datatoc_bsdf_common_lib_glsl);
- BLI_dynstr_append(ds_frag, datatoc_lightprobe_planar_display_frag_glsl);
- shader_str = BLI_dynstr_get_cstring(ds_frag);
- BLI_dynstr_free(ds_frag);
-
e_data.probe_planar_display_sh = DRW_shader_create(
- datatoc_lightprobe_planar_display_vert_glsl, NULL, shader_str,
- "#define MAX_PLANAR " STRINGIFY(MAX_PLANAR) "\n");
+ datatoc_lightprobe_planar_display_vert_glsl, NULL,
+ datatoc_lightprobe_planar_display_frag_glsl, NULL);
- MEM_freeN(shader_str);
+ e_data.probe_planar_downsample_sh = DRW_shader_create(
+ datatoc_lightprobe_planar_downsample_vert_glsl,
+ datatoc_lightprobe_planar_downsample_geom_glsl,
+ datatoc_lightprobe_planar_downsample_frag_glsl,
+ NULL);
e_data.hammersley = create_hammersley_sample_texture(1024);
}
@@ -260,11 +271,22 @@ void EEVEE_lightprobes_init(EEVEE_SceneLayerData *sldata, EEVEE_Data *UNUSED(ved
if (!sldata->probes) {
sldata->probes = MEM_callocN(sizeof(EEVEE_LightProbesInfo), "EEVEE_LightProbesInfo");
sldata->probes->specular_toggle = true;
+ sldata->probes->ssr_toggle = true;
+ sldata->probes->grid_initialized = false;
sldata->probe_ubo = DRW_uniformbuffer_create(sizeof(EEVEE_LightProbe) * MAX_PROBE, NULL);
sldata->grid_ubo = DRW_uniformbuffer_create(sizeof(EEVEE_LightGrid) * MAX_GRID, NULL);
sldata->planar_ubo = DRW_uniformbuffer_create(sizeof(EEVEE_PlanarReflection) * MAX_PLANAR, NULL);
}
+ int prop_bounce_num = BKE_collection_engine_property_value_get_int(props, "gi_diffuse_bounces");
+ /* Update all probes if number of bounces mismatch. */
+ if (sldata->probes->num_bounce != prop_bounce_num) {
+ e_data.update_world |= PROBE_UPDATE_ALL;
+ sldata->probes->updated_bounce = 0;
+ sldata->probes->grid_initialized = false;
+ }
+ sldata->probes->num_bounce = prop_bounce_num;
+
/* Setup Render Target Cubemap */
/* We do this detach / attach dance to not generate an invalid framebuffer (mixed cubemap / 2D map) */
@@ -286,18 +308,27 @@ void EEVEE_lightprobes_init(EEVEE_SceneLayerData *sldata, EEVEE_Data *UNUSED(ved
}
/* Minmaxz Pyramid */
- /* Highjacking the minmaxz_fb but that's ok because it's reconfigured before usage. */
// DRWFboTexture tex_minmaxz = {&e_data.cube_face_minmaxz, DRW_TEX_RG_32, DRW_TEX_MIPMAP | DRW_TEX_TEMP};
- // DRW_framebuffer_init(&vedata->fbl->minmaxz_fb, &draw_engine_eevee_type, PROBE_RT_SIZE / 2, PROBE_RT_SIZE / 2, &tex_minmaxz, 1);
+ // DRW_framebuffer_init(&vedata->fbl->downsample_fb, &draw_engine_eevee_type, PROBE_RT_SIZE / 2, PROBE_RT_SIZE / 2, &tex_minmaxz, 1);
/* Placeholder planar pool: used when rendering planar reflections (avoid dependency loop). */
if (!e_data.planar_pool_placeholder) {
e_data.planar_pool_placeholder = DRW_texture_create_2D_array(1, 1, 1, DRW_TEX_RGBA_8, DRW_TEX_FILTER, NULL);
}
+
+ if (!e_data.depth_placeholder) {
+ e_data.depth_placeholder = DRW_texture_create_2D(1, 1, DRW_TEX_DEPTH_24, 0, NULL);
+ }
+ if (!e_data.depth_array_placeholder) {
+ e_data.depth_array_placeholder = DRW_texture_create_2D_array(1, 1, 1, DRW_TEX_DEPTH_24, 0, NULL);
+ }
}
-void EEVEE_lightprobes_cache_init(EEVEE_SceneLayerData *sldata, EEVEE_PassList *psl, EEVEE_StorageList *stl)
+void EEVEE_lightprobes_cache_init(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata)
{
+ EEVEE_TextureList *txl = vedata->txl;
+ EEVEE_PassList *psl = vedata->psl;
+ EEVEE_StorageList *stl = vedata->stl;
EEVEE_LightProbesInfo *pinfo = sldata->probes;
pinfo->num_cube = 1; /* at least one for the world */
@@ -308,7 +339,7 @@ void EEVEE_lightprobes_cache_init(EEVEE_SceneLayerData *sldata, EEVEE_PassList *
memset(pinfo->probes_planar_ref, 0, sizeof(pinfo->probes_planar_ref));
{
- psl->probe_background = DRW_pass_create("World Probe Pass", DRW_STATE_WRITE_COLOR);
+ psl->probe_background = DRW_pass_create("World Probe Background Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL);
struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get();
DRWShadingGroup *grp = NULL;
@@ -317,23 +348,24 @@ void EEVEE_lightprobes_cache_init(EEVEE_SceneLayerData *sldata, EEVEE_PassList *
Scene *scene = draw_ctx->scene;
World *wo = scene->world;
- static int zero = 0;
float *col = ts.colorBackground;
if (wo) {
col = &wo->horr;
- e_data.update_world = (wo->update_flag != 0);
+ if (wo->update_flag != 0) {
+ e_data.update_world |= PROBE_UPDATE_ALL;
+ pinfo->updated_bounce = 0;
+ pinfo->grid_initialized = false;
+ }
wo->update_flag = 0;
if (wo->use_nodes && wo->nodetree) {
struct GPUMaterial *gpumat = EEVEE_material_world_lightprobe_get(scene, wo);
- grp = DRW_shgroup_material_instance_create(gpumat, psl->probe_background, geom);
+ grp = DRW_shgroup_material_create(gpumat, psl->probe_background);
if (grp) {
- DRW_shgroup_uniform_int(grp, "Layer", &zero, 1);
-
- for (int i = 0; i < 6; ++i)
- DRW_shgroup_call_dynamic_add_empty(grp);
+ DRW_shgroup_uniform_float(grp, "backgroundAlpha", &stl->g_data->background_alpha, 1);
+ DRW_shgroup_call_add(grp, geom, NULL);
}
else {
/* Shader failed : pink background */
@@ -345,12 +377,10 @@ void EEVEE_lightprobes_cache_init(EEVEE_SceneLayerData *sldata, EEVEE_PassList *
/* Fallback if shader fails or if not using nodetree. */
if (grp == NULL) {
- grp = DRW_shgroup_instance_create(e_data.probe_default_sh, psl->probe_background, geom);
+ grp = DRW_shgroup_create(e_data.probe_default_sh, psl->probe_background);
DRW_shgroup_uniform_vec3(grp, "color", col, 1);
- DRW_shgroup_uniform_int(grp, "Layer", &zero, 1);
-
- for (int i = 0; i < 6; ++i)
- DRW_shgroup_call_dynamic_add_empty(grp);
+ DRW_shgroup_uniform_float(grp, "backgroundAlpha", &stl->g_data->background_alpha, 1);
+ DRW_shgroup_call_add(grp, geom, NULL);
}
}
@@ -364,7 +394,7 @@ void EEVEE_lightprobes_cache_init(EEVEE_SceneLayerData *sldata, EEVEE_PassList *
DRW_shgroup_uniform_float(grp, "invSampleCount", &sldata->probes->invsamples_ct, 1);
DRW_shgroup_uniform_float(grp, "roughnessSquared", &sldata->probes->roughness, 1);
DRW_shgroup_uniform_float(grp, "lodFactor", &sldata->probes->lodfactor, 1);
- DRW_shgroup_uniform_float(grp, "lodMax", &sldata->probes->lodmax, 1);
+ DRW_shgroup_uniform_float(grp, "lodMax", &sldata->probes->lod_rt_max, 1);
DRW_shgroup_uniform_float(grp, "texelSize", &sldata->probes->texel_size, 1);
DRW_shgroup_uniform_float(grp, "paddingSize", &sldata->probes->padding_size, 1);
DRW_shgroup_uniform_int(grp, "Layer", &sldata->probes->layer, 1);
@@ -385,7 +415,7 @@ void EEVEE_lightprobes_cache_init(EEVEE_SceneLayerData *sldata, EEVEE_PassList *
DRW_shgroup_uniform_float(grp, "sampleCount", &sldata->probes->samples_ct, 1);
DRW_shgroup_uniform_float(grp, "invSampleCount", &sldata->probes->invsamples_ct, 1);
DRW_shgroup_uniform_float(grp, "lodFactor", &sldata->probes->lodfactor, 1);
- DRW_shgroup_uniform_float(grp, "lodMax", &sldata->probes->lodmax, 1);
+ DRW_shgroup_uniform_float(grp, "lodMax", &sldata->probes->lod_rt_max, 1);
DRW_shgroup_uniform_texture(grp, "texHammersley", e_data.hammersley);
#endif
DRW_shgroup_uniform_texture(grp, "probeHdr", sldata->probe_rt);
@@ -395,6 +425,16 @@ void EEVEE_lightprobes_cache_init(EEVEE_SceneLayerData *sldata, EEVEE_PassList *
}
{
+ psl->probe_grid_fill = DRW_pass_create("LightProbe Grid Floodfill", DRW_STATE_WRITE_COLOR);
+
+ DRWShadingGroup *grp = DRW_shgroup_create(e_data.probe_grid_fill_sh, psl->probe_grid_fill);
+ DRW_shgroup_uniform_buffer(grp, "gridTexture", &sldata->irradiance_pool);
+
+ struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get();
+ DRW_shgroup_call_add(grp, geom, NULL);
+ }
+
+ {
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_CULL_BACK;
psl->probe_display = DRW_pass_create("LightProbe Display", state);
@@ -403,8 +443,24 @@ void EEVEE_lightprobes_cache_init(EEVEE_SceneLayerData *sldata, EEVEE_PassList *
DRW_shgroup_attrib_float(grp, "probe_id", 1); /* XXX this works because we are still uploading 4bytes and using the right stride */
DRW_shgroup_attrib_float(grp, "probe_location", 3);
DRW_shgroup_attrib_float(grp, "sphere_size", 1);
- DRW_shgroup_uniform_float(grp, "lodMax", &sldata->probes->lodmax, 1);
+ DRW_shgroup_uniform_float(grp, "lodCubeMax", &sldata->probes->lod_cube_max, 1);
DRW_shgroup_uniform_buffer(grp, "probeCubes", &sldata->probe_pool);
+
+ geom = DRW_cache_quad_get();
+ grp = stl->g_data->planar_display_shgrp = DRW_shgroup_instance_create(e_data.probe_planar_display_sh, psl->probe_display, geom);
+ DRW_shgroup_attrib_float(grp, "probe_id", 1); /* XXX this works because we are still uploading 4bytes and using the right stride */
+ DRW_shgroup_attrib_float(grp, "probe_mat", 16);
+ DRW_shgroup_uniform_buffer(grp, "probePlanars", &txl->planar_pool);
+ }
+
+ {
+ psl->probe_planar_downsample_ps = DRW_pass_create("LightProbe Planar Downsample", DRW_STATE_WRITE_COLOR);
+
+ struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get();
+ DRWShadingGroup *grp = stl->g_data->planar_downsample = DRW_shgroup_instance_create(e_data.probe_planar_downsample_sh, psl->probe_planar_downsample_ps, geom);
+ DRW_shgroup_uniform_buffer(grp, "source", &txl->planar_pool);
+ DRW_shgroup_uniform_float(grp, "fireflyFactor", &stl->effects->ssr_firefly_fac, 1);
+ DRW_shgroup_uniform_vec2(grp, "texelSize", stl->g_data->texel_size, 1);
}
}
@@ -415,7 +471,7 @@ void EEVEE_lightprobes_cache_add(EEVEE_SceneLayerData *sldata, Object *ob)
/* Step 1 find all lamps in the scene and setup them */
if ((probe->type == LIGHTPROBE_TYPE_CUBE && pinfo->num_cube >= MAX_PROBE) ||
- (probe->type == LIGHTPROBE_TYPE_GRID && pinfo->num_grid >= MAX_PROBE))
+ (probe->type == LIGHTPROBE_TYPE_GRID && pinfo->num_grid >= MAX_PROBE))
{
printf("Too much probes in the scene !!!\n");
return;
@@ -431,15 +487,17 @@ void EEVEE_lightprobes_cache_add(EEVEE_SceneLayerData *sldata, Object *ob)
if (probe->type == LIGHTPROBE_TYPE_GRID) {
ped->updated_cells = 0;
+ ped->updated_lvl = 0;
pinfo->updated_bounce = 0;
+ pinfo->grid_initialized = false;
}
}
if (e_data.update_world) {
ped->need_update = true;
ped->updated_cells = 0;
+ ped->updated_lvl = 0;
ped->probe_id = 0;
- pinfo->updated_bounce = 0;
}
if (probe->type == LIGHTPROBE_TYPE_CUBE) {
@@ -463,7 +521,7 @@ static void scale_m4_v3(float R[4][4], float v[3])
mul_v3_v3(R[i], v);
}
-static void EEVEE_planar_reflections_updates(EEVEE_SceneLayerData *sldata, EEVEE_PassList *psl, EEVEE_TextureList *txl)
+static void EEVEE_planar_reflections_updates(EEVEE_SceneLayerData *sldata, EEVEE_StorageList *stl)
{
EEVEE_LightProbesInfo *pinfo = sldata->probes;
Object *ob;
@@ -559,15 +617,11 @@ static void EEVEE_planar_reflections_updates(EEVEE_SceneLayerData *sldata, EEVEE
eplanar->attenuation_bias = max_dist * -eplanar->attenuation_scale;
/* Debug Display */
- if ((probe->flag & LIGHTPROBE_FLAG_SHOW_DATA) != 0) {
- DRWShadingGroup *grp = DRW_shgroup_create(e_data.probe_planar_display_sh, psl->probe_display);
-
- DRW_shgroup_uniform_int(grp, "probeIdx", &ped->probe_id, 1);
- DRW_shgroup_uniform_buffer(grp, "probePlanars", &txl->planar_pool);
- DRW_shgroup_uniform_block(grp, "planar_block", sldata->planar_ubo);
-
- struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get();
- DRW_shgroup_call_add(grp, geom, ob->obmat);
+ if (BKE_object_is_visible(ob) &&
+ DRW_state_draw_support() &&
+ (probe->flag & LIGHTPROBE_FLAG_SHOW_DATA))
+ {
+ DRW_shgroup_call_dynamic_add(stl->g_data->planar_display_shgrp, &ped->probe_id, ob->obmat);
}
}
}
@@ -612,8 +666,13 @@ static void EEVEE_lightprobes_updates(EEVEE_SceneLayerData *sldata, EEVEE_PassLi
invert_m4(eprobe->parallaxmat);
/* Debug Display */
- if ((probe->flag & LIGHTPROBE_FLAG_SHOW_DATA) != 0) {
- DRW_shgroup_call_dynamic_add(stl->g_data->cube_display_shgrp, &ped->probe_id, ob->obmat[3], &probe->data_draw_size);
+ if (BKE_object_is_visible(ob) &&
+ DRW_state_draw_support() &&
+ (probe->flag & LIGHTPROBE_FLAG_SHOW_DATA))
+ {
+ ped->probe_size = probe->data_draw_size * 0.1f;
+ DRW_shgroup_call_dynamic_add(
+ stl->g_data->cube_display_shgrp, &ped->probe_id, ob->obmat[3], &ped->probe_size);
}
}
@@ -624,6 +683,11 @@ static void EEVEE_lightprobes_updates(EEVEE_SceneLayerData *sldata, EEVEE_PassLi
EEVEE_LightGrid *egrid = &pinfo->grid_data[i];
EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_get(ob);
+ /* Add one for level 0 */
+ ped->max_lvl = 1.0f + floorf(log2f((float)MAX3(probe->grid_resolution_x,
+ probe->grid_resolution_y,
+ probe->grid_resolution_z)));
+
egrid->offset = offset;
float fac = 1.0f / max_ff(1e-8f, probe->falloff);
egrid->attenuation_scale = fac / max_ff(1e-8f, probe->distinf);
@@ -670,7 +734,10 @@ static void EEVEE_lightprobes_updates(EEVEE_SceneLayerData *sldata, EEVEE_PassLi
copy_v3_v3_int(egrid->resolution, &probe->grid_resolution_x);
/* Debug Display */
- if ((probe->flag & LIGHTPROBE_FLAG_SHOW_DATA) != 0) {
+ if (BKE_object_is_visible(ob) &&
+ DRW_state_draw_support() &&
+ (probe->flag & LIGHTPROBE_FLAG_SHOW_DATA))
+ {
struct Gwn_Batch *geom = DRW_cache_sphere_get();
DRWShadingGroup *grp = DRW_shgroup_instance_create(e_data.probe_grid_display_sh, psl->probe_display, geom);
DRW_shgroup_set_instance_count(grp, ped->num_cell);
@@ -688,6 +755,7 @@ static void EEVEE_lightprobes_updates(EEVEE_SceneLayerData *sldata, EEVEE_PassLi
void EEVEE_lightprobes_cache_finish(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata)
{
+ EEVEE_StorageList *stl = vedata->stl;
EEVEE_LightProbesInfo *pinfo = sldata->probes;
Object *ob;
@@ -699,12 +767,16 @@ void EEVEE_lightprobes_cache_finish(EEVEE_SceneLayerData *sldata, EEVEE_Data *ve
if (pinfo->num_planar != pinfo->cache_num_planar) {
DRW_TEXTURE_FREE_SAFE(vedata->txl->planar_pool);
+ DRW_TEXTURE_FREE_SAFE(vedata->txl->planar_depth);
pinfo->cache_num_planar = pinfo->num_planar;
}
/* XXX this should be run each frame as it ensure planar_depth is set */
planar_pool_ensure_alloc(vedata, pinfo->num_planar);
+ /* Setup planar filtering pass */
+ DRW_shgroup_set_instance_count(stl->g_data->planar_downsample, pinfo->num_planar);
+
if (!sldata->probe_pool) {
sldata->probe_pool = DRW_texture_create_2D_array(PROBE_OCTAHEDRON_SIZE, PROBE_OCTAHEDRON_SIZE, max_ff(1, pinfo->num_cube),
DRW_TEX_RGB_11_11_10, DRW_TEX_FILTER | DRW_TEX_MIPMAP, NULL);
@@ -713,10 +785,9 @@ void EEVEE_lightprobes_cache_finish(EEVEE_SceneLayerData *sldata, EEVEE_Data *ve
}
/* Tag probes to refresh */
- e_data.update_world = true;
+ e_data.update_world |= PROBE_UPDATE_CUBE;
e_data.world_ready_to_shade = false;
pinfo->num_render_cube = 0;
- pinfo->update_flag |= PROBE_UPDATE_CUBE;
pinfo->cache_num_cube = pinfo->num_cube;
for (int i = 1; (ob = pinfo->probes_cube_ref[i]) && (i < MAX_PROBE); i++) {
@@ -740,22 +811,17 @@ void EEVEE_lightprobes_cache_finish(EEVEE_SceneLayerData *sldata, EEVEE_Data *ve
#endif
/* TODO Allocate bigger storage if needed. */
- if (!sldata->irradiance_pool) {
- sldata->irradiance_pool = DRW_texture_create_2D(IRRADIANCE_POOL_SIZE, IRRADIANCE_POOL_SIZE, irradiance_format, DRW_TEX_FILTER, NULL);
- pinfo->num_render_grid = 0;
- pinfo->updated_bounce = 0;
-
- for (int i = 1; (ob = pinfo->probes_grid_ref[i]) && (i < MAX_PROBE); i++) {
- EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_get(ob);
- ped->need_update = true;
- ped->updated_cells = 0;
+ if (!sldata->irradiance_pool || !sldata->irradiance_rt) {
+ if (!sldata->irradiance_pool) {
+ sldata->irradiance_pool = DRW_texture_create_2D(IRRADIANCE_POOL_SIZE, IRRADIANCE_POOL_SIZE, irradiance_format, DRW_TEX_FILTER, NULL);
+ }
+ if (!sldata->irradiance_rt) {
+ sldata->irradiance_rt = DRW_texture_create_2D(IRRADIANCE_POOL_SIZE, IRRADIANCE_POOL_SIZE, irradiance_format, DRW_TEX_FILTER, NULL);
}
- }
-
- if (!sldata->irradiance_rt) {
- sldata->irradiance_rt = DRW_texture_create_2D(IRRADIANCE_POOL_SIZE, IRRADIANCE_POOL_SIZE, irradiance_format, DRW_TEX_FILTER, NULL);
pinfo->num_render_grid = 0;
pinfo->updated_bounce = 0;
+ pinfo->grid_initialized = false;
+ e_data.update_world |= PROBE_UPDATE_GRID;
for (int i = 1; (ob = pinfo->probes_grid_ref[i]) && (i < MAX_PROBE); i++) {
EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_get(ob);
@@ -765,22 +831,43 @@ void EEVEE_lightprobes_cache_finish(EEVEE_SceneLayerData *sldata, EEVEE_Data *ve
}
EEVEE_lightprobes_updates(sldata, vedata->psl, vedata->stl);
- EEVEE_planar_reflections_updates(sldata, vedata->psl, vedata->txl);
+ EEVEE_planar_reflections_updates(sldata, vedata->stl);
DRW_uniformbuffer_update(sldata->probe_ubo, &sldata->probes->probe_data);
DRW_uniformbuffer_update(sldata->grid_ubo, &sldata->probes->grid_data);
DRW_uniformbuffer_update(sldata->planar_ubo, &sldata->probes->planar_data);
}
+static void downsample_planar(void *vedata, int level)
+{
+ EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl;
+ EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl;
+
+ const float *size = DRW_viewport_size_get();
+ copy_v2_v2(stl->g_data->texel_size, size);
+ for (int i = 0; i < level - 1; ++i) {
+ stl->g_data->texel_size[0] /= 2.0f;
+ stl->g_data->texel_size[1] /= 2.0f;
+ min_ff(floorf(stl->g_data->texel_size[0]), 1.0f);
+ min_ff(floorf(stl->g_data->texel_size[1]), 1.0f);
+ }
+ invert_v2(stl->g_data->texel_size);
+
+ DRW_draw_pass(psl->probe_planar_downsample_ps);
+}
+
/* Glossy filter probe_rt to probe_pool at index probe_idx */
-static void glossy_filter_probe(EEVEE_SceneLayerData *sldata, EEVEE_PassList *psl, int probe_idx)
+static void glossy_filter_probe(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata, EEVEE_PassList *psl, int probe_idx)
{
EEVEE_LightProbesInfo *pinfo = sldata->probes;
+ /* Max lod used from the render target probe */
+ pinfo->lod_rt_max = floorf(log2f(PROBE_RT_SIZE)) - 2.0f;
+
/* 2 - Let gpu create Mipmaps for Filtered Importance Sampling. */
/* Bind next framebuffer to be able to gen. mips for probe_rt. */
DRW_framebuffer_bind(sldata->probe_filter_fb);
- DRW_texture_generate_mipmaps(sldata->probe_rt);
+ EEVEE_downsample_cube_buffer(vedata, sldata->probe_filter_fb, sldata->probe_rt, (int)(pinfo->lod_rt_max));
/* 3 - Render to probe array to the specified layer, do prefiltering. */
/* Detach to rebind the right mipmap. */
@@ -789,7 +876,7 @@ static void glossy_filter_probe(EEVEE_SceneLayerData *sldata, EEVEE_PassList *ps
const int maxlevel = (int)floorf(log2f(PROBE_OCTAHEDRON_SIZE));
const int min_lod_level = 3;
for (int i = 0; i < maxlevel - min_lod_level; i++) {
- float bias = (i == 0) ? 0.0f : 1.0f;
+ float bias = (i == 0) ? -1.0f : 1.0f;
pinfo->texel_size = 1.0f / mipsize;
pinfo->padding_size = powf(2.0f, (float)(maxlevel - min_lod_level - 1 - i));
/* XXX : WHY THE HECK DO WE NEED THIS ??? */
@@ -826,7 +913,6 @@ static void glossy_filter_probe(EEVEE_SceneLayerData *sldata, EEVEE_PassList *ps
pinfo->invsamples_ct = 1.0f / pinfo->samples_ct;
pinfo->lodfactor = bias + 0.5f * log((float)(PROBE_RT_SIZE * PROBE_RT_SIZE) * pinfo->invsamples_ct) / log(2);
- pinfo->lodmax = floorf(log2f(PROBE_RT_SIZE)) - 2.0f;
DRW_framebuffer_texture_attach(sldata->probe_filter_fb, sldata->probe_pool, 0, i);
DRW_framebuffer_viewport_size(sldata->probe_filter_fb, 0, 0, mipsize, mipsize);
@@ -837,29 +923,17 @@ static void glossy_filter_probe(EEVEE_SceneLayerData *sldata, EEVEE_PassList *ps
CLAMP_MIN(mipsize, 1);
}
/* For shading, save max level of the octahedron map */
- pinfo->lodmax = (float)(maxlevel - min_lod_level) - 1.0f;
+ pinfo->lod_cube_max = (float)(maxlevel - min_lod_level) - 1.0f;
/* reattach to have a valid framebuffer. */
DRW_framebuffer_texture_attach(sldata->probe_filter_fb, sldata->probe_pool, 0, 0);
}
/* Diffuse filter probe_rt to irradiance_pool at index probe_idx */
-static void diffuse_filter_probe(EEVEE_SceneLayerData *sldata, EEVEE_PassList *psl, int offset)
+static void diffuse_filter_probe(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata, EEVEE_PassList *psl, int offset)
{
EEVEE_LightProbesInfo *pinfo = sldata->probes;
- /* TODO do things properly */
- float lodmax = pinfo->lodmax;
-
- /* 4 - Compute spherical harmonics */
- /* Tweaking parameters to balance perf. vs precision */
- DRW_framebuffer_bind(sldata->probe_filter_fb);
- DRW_texture_generate_mipmaps(sldata->probe_rt);
-
- /* Bind the right texture layer (one layer per irradiance grid) */
- DRW_framebuffer_texture_detach(sldata->probe_pool);
- DRW_framebuffer_texture_attach(sldata->probe_filter_fb, sldata->irradiance_rt, 0, 0);
-
/* find cell position on the virtual 3D texture */
/* NOTE : Keep in sync with load_irradiance_cell() */
#if defined(IRRADIANCE_SH_L2)
@@ -877,24 +951,29 @@ static void diffuse_filter_probe(EEVEE_SceneLayerData *sldata, EEVEE_PassList *p
int y = size[1] * (offset / cell_per_row);
#ifndef IRRADIANCE_SH_L2
+ /* Tweaking parameters to balance perf. vs precision */
const float bias = 0.0f;
pinfo->invsamples_ct = 1.0f / pinfo->samples_ct;
pinfo->lodfactor = bias + 0.5f * log((float)(PROBE_RT_SIZE * PROBE_RT_SIZE) * pinfo->invsamples_ct) / log(2);
- pinfo->lodmax = floorf(log2f(PROBE_RT_SIZE)) - 2.0f;
+ pinfo->lod_rt_max = floorf(log2f(PROBE_RT_SIZE)) - 2.0f;
#else
pinfo->shres = 32; /* Less texture fetches & reduce branches */
- pinfo->lodmax = 2.0f; /* Improve cache reuse */
+ pinfo->lod_rt_max = 2.0f; /* Improve cache reuse */
#endif
+ /* 4 - Compute spherical harmonics */
+ DRW_framebuffer_bind(sldata->probe_filter_fb);
+ EEVEE_downsample_cube_buffer(vedata, sldata->probe_filter_fb, sldata->probe_rt, (int)(pinfo->lod_rt_max));
+
+ DRW_framebuffer_texture_detach(sldata->probe_pool);
+ DRW_framebuffer_texture_attach(sldata->probe_filter_fb, sldata->irradiance_rt, 0, 0);
+
DRW_framebuffer_viewport_size(sldata->probe_filter_fb, x, y, size[0], size[1]);
DRW_draw_pass(psl->probe_diffuse_compute);
/* reattach to have a valid framebuffer. */
DRW_framebuffer_texture_detach(sldata->irradiance_rt);
DRW_framebuffer_texture_attach(sldata->probe_filter_fb, sldata->probe_pool, 0, 0);
-
- /* restore */
- pinfo->lodmax = lodmax;
}
/* Render the scene to the probe_rt texture. */
@@ -907,7 +986,7 @@ static void render_scene_to_probe(
EEVEE_StorageList *stl = vedata->stl;
EEVEE_LightProbesInfo *pinfo = sldata->probes;
- float winmat[4][4], posmat[4][4], tmp_ao_dist, tmp_ao_samples;
+ float winmat[4][4], wininv[4][4], posmat[4][4], tmp_ao_dist, tmp_ao_samples, tmp_ao_settings;
unit_m4(posmat);
@@ -916,12 +995,13 @@ static void render_scene_to_probe(
/* Disable specular lighting when rendering probes to avoid feedback loops (looks bad). */
sldata->probes->specular_toggle = false;
+ sldata->probes->ssr_toggle = false;
/* Disable AO until we find a way to hide really bad discontinuities between cubefaces. */
tmp_ao_dist = stl->effects->ao_dist;
tmp_ao_samples = stl->effects->ao_samples;
- stl->effects->ao_dist = 0.0f;
- stl->effects->ao_samples = 0.0f;
+ tmp_ao_settings = stl->effects->ao_settings;
+ stl->effects->ao_settings = 0.0f; /* Disable AO */
/* 1 - Render to each cubeface individually.
* We do this instead of using geometry shader because a) it's faster,
@@ -932,9 +1012,11 @@ static void render_scene_to_probe(
/* Avoid using the texture attached to framebuffer when rendering. */
/* XXX */
GPUTexture *tmp_planar_pool = txl->planar_pool;
- GPUTexture *tmp_minmaxz = stl->g_data->minmaxz;
+ GPUTexture *tmp_minz = stl->g_data->minzbuffer;
+ GPUTexture *tmp_maxz = txl->maxzbuffer;
txl->planar_pool = e_data.planar_pool_placeholder;
- // stl->g_data->minmaxz = e_data.cube_face_minmaxz;
+ stl->g_data->minzbuffer = e_data.depth_placeholder;
+ txl->maxzbuffer = e_data.depth_placeholder;
/* Detach to rebind the right cubeface. */
DRW_framebuffer_bind(sldata->probe_fb);
@@ -944,29 +1026,34 @@ static void render_scene_to_probe(
float viewmat[4][4], persmat[4][4];
float viewinv[4][4], persinv[4][4];
- DRW_framebuffer_cubeface_attach(sldata->probe_fb, sldata->probe_rt, 0, i, 0);
- DRW_framebuffer_viewport_size(sldata->probe_fb, 0, 0, PROBE_RT_SIZE, PROBE_RT_SIZE);
-
- DRW_framebuffer_clear(false, true, false, NULL, 1.0);
-
/* Setup custom matrices */
mul_m4_m4m4(viewmat, cubefacemat[i], posmat);
mul_m4_m4m4(persmat, winmat, viewmat);
invert_m4_m4(persinv, persmat);
invert_m4_m4(viewinv, viewmat);
+ invert_m4_m4(wininv, winmat);
DRW_viewport_matrix_override_set(persmat, DRW_MAT_PERS);
DRW_viewport_matrix_override_set(persinv, DRW_MAT_PERSINV);
DRW_viewport_matrix_override_set(viewmat, DRW_MAT_VIEW);
DRW_viewport_matrix_override_set(viewinv, DRW_MAT_VIEWINV);
DRW_viewport_matrix_override_set(winmat, DRW_MAT_WIN);
+ DRW_viewport_matrix_override_set(wininv, DRW_MAT_WININV);
+
+ /* Be sure that cascaded shadow maps are updated. */
+ EEVEE_draw_shadows(sldata, psl);
+
+ DRW_framebuffer_cubeface_attach(sldata->probe_fb, sldata->probe_rt, 0, i, 0);
+ DRW_framebuffer_viewport_size(sldata->probe_fb, 0, 0, PROBE_RT_SIZE, PROBE_RT_SIZE);
- DRW_draw_pass(psl->background_pass);
+ DRW_framebuffer_clear(false, true, false, NULL, 1.0);
/* Depth prepass */
DRW_draw_pass(psl->depth_pass);
DRW_draw_pass(psl->depth_pass_cull);
+ DRW_draw_pass(psl->probe_background);
+
// EEVEE_create_minmax_buffer(vedata, e_data.cube_face_depth);
/* Rebind Planar FB */
@@ -986,24 +1073,27 @@ static void render_scene_to_probe(
DRW_viewport_matrix_override_unset(DRW_MAT_VIEW);
DRW_viewport_matrix_override_unset(DRW_MAT_VIEWINV);
DRW_viewport_matrix_override_unset(DRW_MAT_WIN);
+ DRW_viewport_matrix_override_unset(DRW_MAT_WININV);
/* Restore */
sldata->probes->specular_toggle = true;
+ sldata->probes->ssr_toggle = true;
txl->planar_pool = tmp_planar_pool;
- stl->g_data->minmaxz = tmp_minmaxz;
+ stl->g_data->minzbuffer = tmp_minz;
+ txl->maxzbuffer = tmp_maxz;
stl->effects->ao_dist = tmp_ao_dist;
stl->effects->ao_samples = tmp_ao_samples;
+ stl->effects->ao_settings = tmp_ao_settings;
}
static void render_scene_to_planar(
- EEVEE_Data *vedata, int layer,
+ EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata, int layer,
float (*viewmat)[4], float (*persmat)[4],
float clip_plane[4])
{
EEVEE_FramebufferList *fbl = vedata->fbl;
EEVEE_TextureList *txl = vedata->txl;
EEVEE_PassList *psl = vedata->psl;
- EEVEE_StorageList *stl = vedata->stl;
float viewinv[4][4];
float persinv[4][4];
@@ -1011,39 +1101,49 @@ static void render_scene_to_planar(
invert_m4_m4(viewinv, viewmat);
invert_m4_m4(persinv, persmat);
+ DRW_viewport_matrix_override_set(persmat, DRW_MAT_PERS);
+ DRW_viewport_matrix_override_set(persinv, DRW_MAT_PERSINV);
+ DRW_viewport_matrix_override_set(viewmat, DRW_MAT_VIEW);
+ DRW_viewport_matrix_override_set(viewinv, DRW_MAT_VIEWINV);
+
+ /* Since we are rendering with an inverted view matrix, we need
+ * to invert the facing for backface culling to be the same. */
+ DRW_state_invert_facing();
+
+ /* Be sure that cascaded shadow maps are updated. */
+ EEVEE_draw_shadows(sldata, psl);
+
+ DRW_state_clip_planes_add(clip_plane);
+
/* Attach depth here since it's a DRW_TEX_TEMP */
- DRW_framebuffer_texture_attach(fbl->planarref_fb, e_data.planar_depth, 0, 0);
+ DRW_framebuffer_texture_layer_attach(fbl->planarref_fb, txl->planar_depth, 0, layer, 0);
DRW_framebuffer_texture_layer_attach(fbl->planarref_fb, txl->planar_pool, 0, layer, 0);
DRW_framebuffer_bind(fbl->planarref_fb);
DRW_framebuffer_clear(false, true, false, NULL, 1.0);
+ /* Turn off ssr to avoid black specular */
+ /* TODO : Enable SSR in planar reflections? (Would be very heavy) */
+ sldata->probes->ssr_toggle = false;
+
/* Avoid using the texture attached to framebuffer when rendering. */
/* XXX */
GPUTexture *tmp_planar_pool = txl->planar_pool;
- GPUTexture *tmp_minmaxz = stl->g_data->minmaxz;
+ GPUTexture *tmp_planar_depth = txl->planar_depth;
txl->planar_pool = e_data.planar_pool_placeholder;
- stl->g_data->minmaxz = e_data.planar_minmaxz;
- stl->g_data->background_alpha = FLT_MAX; /* Alpha is distance for planar reflections. */
-
- DRW_viewport_matrix_override_set(persmat, DRW_MAT_PERS);
- DRW_viewport_matrix_override_set(persinv, DRW_MAT_PERSINV);
- DRW_viewport_matrix_override_set(viewmat, DRW_MAT_VIEW);
- DRW_viewport_matrix_override_set(viewinv, DRW_MAT_VIEWINV);
-
- /* Background */
- DRW_draw_pass(psl->background_pass);
-
- /* Since we are rendering with an inverted view matrix, we need
- * to invert the facing for backface culling to be the same. */
- DRW_state_invert_facing();
- DRW_state_clip_planes_add(clip_plane);
+ txl->planar_depth = e_data.depth_array_placeholder;
/* Depth prepass */
DRW_draw_pass(psl->depth_pass_clip);
DRW_draw_pass(psl->depth_pass_clip_cull);
- EEVEE_create_minmax_buffer(vedata, e_data.planar_depth);
+ /* Background */
+ DRW_draw_pass(psl->probe_background);
+
+ EEVEE_create_minmax_buffer(vedata, tmp_planar_depth, layer);
+
+ /* Compute GTAO Horizons */
+ EEVEE_effects_do_gtao(sldata, vedata);
/* Rebind Planar FB */
DRW_framebuffer_bind(fbl->planarref_fb);
@@ -1056,37 +1156,78 @@ static void render_scene_to_planar(
DRW_state_clip_planes_reset();
/* Restore */
+ sldata->probes->ssr_toggle = true;
txl->planar_pool = tmp_planar_pool;
- stl->g_data->minmaxz = tmp_minmaxz;
- stl->g_data->background_alpha = 1.0;
+ txl->planar_depth = tmp_planar_depth;
DRW_viewport_matrix_override_unset(DRW_MAT_PERS);
DRW_viewport_matrix_override_unset(DRW_MAT_PERSINV);
DRW_viewport_matrix_override_unset(DRW_MAT_VIEW);
DRW_viewport_matrix_override_unset(DRW_MAT_VIEWINV);
DRW_framebuffer_texture_detach(txl->planar_pool);
- DRW_framebuffer_texture_detach(e_data.planar_depth);
+ DRW_framebuffer_texture_detach(txl->planar_depth);
}
static void render_world_to_probe(EEVEE_SceneLayerData *sldata, EEVEE_PassList *psl)
{
EEVEE_LightProbesInfo *pinfo = sldata->probes;
+ float winmat[4][4], wininv[4][4];
/* 1 - Render to cubemap target using geometry shader. */
/* For world probe, we don't need to clear since we render the background directly. */
pinfo->layer = 0;
+ perspective_m4(winmat, -0.1f, 0.1f, -0.1f, 0.1f, 0.1f, 1.0f);
+ invert_m4_m4(wininv, winmat);
+
+ /* Detach to rebind the right cubeface. */
DRW_framebuffer_bind(sldata->probe_fb);
- DRW_draw_pass(psl->probe_background);
+ DRW_framebuffer_texture_detach(sldata->probe_rt);
+ for (int i = 0; i < 6; ++i) {
+ float viewmat[4][4], persmat[4][4];
+ float viewinv[4][4], persinv[4][4];
+
+ DRW_framebuffer_cubeface_attach(sldata->probe_fb, sldata->probe_rt, 0, i, 0);
+ DRW_framebuffer_viewport_size(sldata->probe_fb, 0, 0, PROBE_RT_SIZE, PROBE_RT_SIZE);
+
+ /* Setup custom matrices */
+ copy_m4_m4(viewmat, cubefacemat[i]);
+ mul_m4_m4m4(persmat, winmat, viewmat);
+ invert_m4_m4(persinv, persmat);
+ invert_m4_m4(viewinv, viewmat);
+
+ DRW_viewport_matrix_override_set(persmat, DRW_MAT_PERS);
+ DRW_viewport_matrix_override_set(persinv, DRW_MAT_PERSINV);
+ DRW_viewport_matrix_override_set(viewmat, DRW_MAT_VIEW);
+ DRW_viewport_matrix_override_set(viewinv, DRW_MAT_VIEWINV);
+ DRW_viewport_matrix_override_set(winmat, DRW_MAT_WIN);
+ DRW_viewport_matrix_override_set(wininv, DRW_MAT_WININV);
+
+ DRW_draw_pass(psl->probe_background);
+
+ DRW_framebuffer_texture_detach(sldata->probe_rt);
+ }
+ DRW_framebuffer_texture_attach(sldata->probe_fb, sldata->probe_rt, 0, 0);
+
+ DRW_viewport_matrix_override_unset(DRW_MAT_PERS);
+ DRW_viewport_matrix_override_unset(DRW_MAT_PERSINV);
+ DRW_viewport_matrix_override_unset(DRW_MAT_VIEW);
+ DRW_viewport_matrix_override_unset(DRW_MAT_VIEWINV);
+ DRW_viewport_matrix_override_unset(DRW_MAT_WIN);
+ DRW_viewport_matrix_override_unset(DRW_MAT_WININV);
}
-static void lightprobe_cell_location_get(EEVEE_LightGrid *egrid, int cell_idx, float r_pos[3])
+static void lightprobe_cell_grid_location_get(EEVEE_LightGrid *egrid, int cell_idx, float r_local_cell[3])
{
- float tmp[3], local_cell[3];
/* Keep in sync with lightprobe_grid_display_vert */
- local_cell[2] = (float)(cell_idx % egrid->resolution[2]);
- local_cell[1] = (float)((cell_idx / egrid->resolution[2]) % egrid->resolution[1]);
- local_cell[0] = (float)(cell_idx / (egrid->resolution[2] * egrid->resolution[1]));
+ r_local_cell[2] = (float)(cell_idx % egrid->resolution[2]);
+ r_local_cell[1] = (float)((cell_idx / egrid->resolution[2]) % egrid->resolution[1]);
+ r_local_cell[0] = (float)(cell_idx / (egrid->resolution[2] * egrid->resolution[1]));
+}
+
+static void lightprobe_cell_world_location_get(EEVEE_LightGrid *egrid, float local_cell[3], float r_pos[3])
+{
+ float tmp[3];
copy_v3_v3(r_pos, egrid->corner);
mul_v3_v3fl(tmp, egrid->increment_x, local_cell[0]);
@@ -1099,7 +1240,9 @@ static void lightprobe_cell_location_get(EEVEE_LightGrid *egrid, int cell_idx, f
void EEVEE_lightprobes_refresh(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata)
{
+ EEVEE_TextureList *txl = vedata->txl;
EEVEE_PassList *psl = vedata->psl;
+ EEVEE_StorageList *stl = vedata->stl;
EEVEE_LightProbesInfo *pinfo = sldata->probes;
Object *ob;
const DRWContextState *draw_ctx = DRW_context_state_get();
@@ -1108,15 +1251,26 @@ void EEVEE_lightprobes_refresh(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata)
/* Render world in priority */
if (e_data.update_world) {
render_world_to_probe(sldata, psl);
- glossy_filter_probe(sldata, psl, 0);
- diffuse_filter_probe(sldata, psl, 0);
- /* Swap and redo prefiltering for other rendertarget.
- * This way we have world lighting waiting for irradiance grids to catch up. */
- SWAP(GPUTexture *, sldata->irradiance_pool, sldata->irradiance_rt);
- diffuse_filter_probe(sldata, psl, 0);
+ if (e_data.update_world & PROBE_UPDATE_CUBE) {
+ glossy_filter_probe(sldata, vedata, psl, 0);
+ }
+
+ if (e_data.update_world & PROBE_UPDATE_GRID) {
+ diffuse_filter_probe(sldata, vedata, psl, 0);
+
+ SWAP(GPUTexture *, sldata->irradiance_pool, sldata->irradiance_rt);
+
+ DRW_framebuffer_texture_detach(sldata->probe_pool);
+
+ DRW_framebuffer_texture_attach(sldata->probe_filter_fb, sldata->irradiance_rt, 0, 0);
+ DRW_draw_pass(psl->probe_grid_fill);
+ DRW_framebuffer_texture_detach(sldata->irradiance_rt);
+
+ DRW_framebuffer_texture_attach(sldata->probe_filter_fb, sldata->probe_pool, 0, 0);
+ }
- e_data.update_world = false;
+ e_data.update_world = 0;
if (!e_data.world_ready_to_shade) {
e_data.world_ready_to_shade = true;
@@ -1136,9 +1290,31 @@ void EEVEE_lightprobes_refresh(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata)
}
}
- /* Reflection probes depend on diffuse lighting thus on irradiance grid */
- const int max_bounce = 3;
- while (pinfo->updated_bounce < max_bounce) {
+ if (!pinfo->grid_initialized) {
+ DRW_framebuffer_texture_detach(sldata->probe_pool);
+
+ /* Flood fill with world irradiance. */
+ DRW_framebuffer_texture_attach(sldata->probe_filter_fb, sldata->irradiance_rt, 0, 0);
+ DRW_draw_pass(psl->probe_grid_fill);
+ DRW_framebuffer_texture_detach(sldata->irradiance_rt);
+
+ SWAP(GPUTexture *, sldata->irradiance_pool, sldata->irradiance_rt);
+
+ DRW_framebuffer_texture_attach(sldata->probe_filter_fb, sldata->irradiance_rt, 0, 0);
+ DRW_draw_pass(psl->probe_grid_fill);
+ DRW_framebuffer_texture_detach(sldata->irradiance_rt);
+
+ SWAP(GPUTexture *, sldata->irradiance_pool, sldata->irradiance_rt);
+
+ /* reattach to have a valid framebuffer. */
+ DRW_framebuffer_texture_attach(sldata->probe_filter_fb, sldata->probe_pool, 0, 0);
+
+ pinfo->grid_initialized = true;
+ }
+
+ /* Reflection probes depend on diffuse lighting thus on irradiance grid,
+ * so update them first. */
+ while (pinfo->updated_bounce < pinfo->num_bounce) {
pinfo->num_render_grid = pinfo->num_grid;
for (int i = 1; (ob = pinfo->probes_grid_ref[i]) && (i < MAX_GRID); i++) {
@@ -1147,7 +1323,43 @@ void EEVEE_lightprobes_refresh(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata)
if (ped->need_update) {
EEVEE_LightGrid *egrid = &pinfo->grid_data[i];
LightProbe *prb = (LightProbe *)ob->data;
+
+ /* Find the next cell corresponding to the current level. */
+ bool valid_cell = false;
int cell_id = ped->updated_cells;
+ float pos[3], grid_loc[3];
+
+ /* Other levels */
+ int current_stride = 1 << max_ii(0, ped->max_lvl - ped->updated_lvl);
+ int prev_stride = current_stride << 1;
+
+ while (!valid_cell) {
+ cell_id = ped->updated_cells;
+ lightprobe_cell_grid_location_get(egrid, cell_id, grid_loc);
+
+ if (ped->updated_lvl == 0 && cell_id == 0) {
+ valid_cell = true;
+ ped->updated_cells = ped->num_cell;
+ continue;
+ }
+ else if (((((int)grid_loc[0] % current_stride) == 0) &&
+ (((int)grid_loc[1] % current_stride) == 0) &&
+ (((int)grid_loc[2] % current_stride) == 0)) &&
+ !((((int)grid_loc[0] % prev_stride) == 0) &&
+ (((int)grid_loc[1] % prev_stride) == 0) &&
+ (((int)grid_loc[2] % prev_stride) == 0)))
+ {
+ valid_cell = true;
+ }
+
+ ped->updated_cells++;
+
+ if (ped->updated_cells > ped->num_cell) {
+ goto skip_rendering;
+ }
+ }
+
+ lightprobe_cell_world_location_get(egrid, grid_loc, pos);
SWAP(GPUTexture *, sldata->irradiance_pool, sldata->irradiance_rt);
@@ -1163,27 +1375,39 @@ void EEVEE_lightprobes_refresh(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata)
pinfo->num_render_grid = 0;
}
- float pos[3];
- lightprobe_cell_location_get(egrid, cell_id, pos);
-
render_scene_to_probe(sldata, vedata, pos, prb->clipsta, prb->clipend);
- diffuse_filter_probe(sldata, psl, egrid->offset + cell_id);
+ diffuse_filter_probe(sldata, vedata, psl, egrid->offset + cell_id);
+
+ /* To see what is going on. */
+ SWAP(GPUTexture *, sldata->irradiance_pool, sldata->irradiance_rt);
/* Restore */
pinfo->num_render_grid = tmp_num_render_grid;
pinfo->num_render_cube = tmp_num_render_cube;
pinfo->num_planar = tmp_num_planar;
- /* To see what is going on. */
- SWAP(GPUTexture *, sldata->irradiance_pool, sldata->irradiance_rt);
+skip_rendering:
- ped->updated_cells++;
if (ped->updated_cells >= ped->num_cell) {
- ped->need_update = false;
- }
+ ped->updated_lvl++;
+ ped->updated_cells = 0;
+ if (ped->updated_lvl > ped->max_lvl) {
+ ped->need_update = false;
+ }
+
+ egrid->level_bias = (float)(1 << max_ii(0, ped->max_lvl - ped->updated_lvl + 1));
+ DRW_uniformbuffer_update(sldata->grid_ubo, &sldata->probes->grid_data);
+ }
+#if 0
+ printf("Updated Grid %d : cell %d / %d, bounce %d / %d\n",
+ i, ped->updated_cells, ped->num_cell, pinfo->updated_bounce + 1, pinfo->num_bounce);
+#endif
/* Only do one probe per frame */
DRW_viewport_request_redraw();
+ /* Do not let this frame accumulate. */
+ stl->effects->taa_current_sample = 1;
+
goto update_planar;
}
}
@@ -1191,14 +1415,25 @@ void EEVEE_lightprobes_refresh(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata)
pinfo->updated_bounce++;
pinfo->num_render_grid = pinfo->num_grid;
- if (pinfo->updated_bounce < max_bounce) {
+ if (pinfo->updated_bounce < pinfo->num_bounce) {
/* Retag all grids to update for next bounce */
for (int i = 1; (ob = pinfo->probes_grid_ref[i]) && (i < MAX_GRID); i++) {
EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_get(ob);
ped->need_update = true;
ped->updated_cells = 0;
+ ped->updated_lvl = 0;
}
+
SWAP(GPUTexture *, sldata->irradiance_pool, sldata->irradiance_rt);
+
+ /* Reset the next buffer so we can see the progress. */
+ DRW_framebuffer_texture_detach(sldata->probe_pool);
+
+ DRW_framebuffer_texture_attach(sldata->probe_filter_fb, sldata->irradiance_rt, 0, 0);
+ DRW_draw_pass(psl->probe_grid_fill);
+ DRW_framebuffer_texture_detach(sldata->irradiance_rt);
+
+ DRW_framebuffer_texture_attach(sldata->probe_filter_fb, sldata->probe_pool, 0, 0);
}
}
@@ -1209,7 +1444,7 @@ void EEVEE_lightprobes_refresh(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata)
LightProbe *prb = (LightProbe *)ob->data;
render_scene_to_probe(sldata, vedata, ob->obmat[3], prb->clipsta, prb->clipend);
- glossy_filter_probe(sldata, psl, i);
+ glossy_filter_probe(sldata, vedata, psl, i);
ped->need_update = false;
ped->probe_id = i;
@@ -1218,8 +1453,12 @@ void EEVEE_lightprobes_refresh(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata)
pinfo->num_render_cube++;
ped->ready_to_shade = true;
}
-
+#if 0
+ printf("Update Cubemap %d\n", i);
+#endif
DRW_viewport_request_redraw();
+ /* Do not let this frame accumulate. */
+ stl->effects->taa_current_sample = 1;
/* Only do one probe per frame */
goto update_planar;
@@ -1237,7 +1476,7 @@ update_planar:
int tmp_num_planar = pinfo->num_planar;
pinfo->num_planar = 0;
- render_scene_to_planar(vedata, i, ped->viewmat, ped->persmat, ped->planer_eq_offset);
+ render_scene_to_planar(sldata, vedata, i, ped->viewmat, ped->persmat, ped->planer_eq_offset);
/* Restore */
pinfo->num_planar = tmp_num_planar;
@@ -1246,6 +1485,16 @@ update_planar:
ped->probe_id = i;
}
}
+
+ /* If there is at least one planar probe */
+ if (pinfo->num_planar > 0 && (vedata->stl->effects->enabled_effects & EFFECT_SSR) != 0) {
+ const int max_lod = 9;
+ DRW_stats_group_start("Planar Probe Downsample");
+ DRW_framebuffer_recursive_downsample(vedata->fbl->downsample_fb, txl->planar_pool, max_lod, &downsample_planar, vedata);
+ /* For shading, save max level of the planar map */
+ pinfo->lod_planar_max = (float)(max_lod);
+ DRW_stats_group_end();
+ }
}
void EEVEE_lightprobes_free(void)
@@ -1253,9 +1502,13 @@ void EEVEE_lightprobes_free(void)
DRW_SHADER_FREE_SAFE(e_data.probe_default_sh);
DRW_SHADER_FREE_SAFE(e_data.probe_filter_glossy_sh);
DRW_SHADER_FREE_SAFE(e_data.probe_filter_diffuse_sh);
+ DRW_SHADER_FREE_SAFE(e_data.probe_grid_fill_sh);
DRW_SHADER_FREE_SAFE(e_data.probe_grid_display_sh);
DRW_SHADER_FREE_SAFE(e_data.probe_planar_display_sh);
+ DRW_SHADER_FREE_SAFE(e_data.probe_planar_downsample_sh);
DRW_SHADER_FREE_SAFE(e_data.probe_cube_display_sh);
DRW_TEXTURE_FREE_SAFE(e_data.hammersley);
DRW_TEXTURE_FREE_SAFE(e_data.planar_pool_placeholder);
+ DRW_TEXTURE_FREE_SAFE(e_data.depth_placeholder);
+ DRW_TEXTURE_FREE_SAFE(e_data.depth_array_placeholder);
}
diff --git a/source/blender/draw/engines/eevee/eevee_lights.c b/source/blender/draw/engines/eevee/eevee_lights.c
index c6436d5b923..1fa5aae4492 100644
--- a/source/blender/draw/engines/eevee/eevee_lights.c
+++ b/source/blender/draw/engines/eevee/eevee_lights.c
@@ -25,6 +25,8 @@
#include "DRW_render.h"
+#include "BLI_dynstr.h"
+
#include "BKE_object.h"
#include "eevee_engine.h"
@@ -38,18 +40,13 @@ typedef struct EEVEE_LightData {
} EEVEE_LightData;
typedef struct EEVEE_ShadowCubeData {
- short light_id, shadow_id;
- float viewprojmat[6][4][4];
+ short light_id, shadow_id, cube_id, layer_id;
} EEVEE_ShadowCubeData;
-typedef struct EEVEE_ShadowMapData {
- short light_id, shadow_id;
- float viewprojmat[4][4]; /* World->Lamp->NDC : used for rendering the shadow map. */
-} EEVEE_ShadowMapData;
-
typedef struct EEVEE_ShadowCascadeData {
- short light_id, shadow_id;
+ short light_id, shadow_id, cascade_id, layer_id;
float viewprojmat[MAX_CASCADE_NUM][4][4]; /* World->Lamp->NDC : used for rendering the shadow map. */
+ float radius[MAX_CASCADE_NUM];
} EEVEE_ShadowCascadeData;
typedef struct ShadowCaster {
@@ -60,30 +57,62 @@ typedef struct ShadowCaster {
static struct {
struct GPUShader *shadow_sh;
- struct GPUShader *shadow_store_sh;
+ struct GPUShader *shadow_store_cube_sh[SHADOW_METHOD_MAX];
+ struct GPUShader *shadow_store_cascade_sh[SHADOW_METHOD_MAX];
+ struct GPUShader *shadow_copy_cube_sh[SHADOW_METHOD_MAX];
+ struct GPUShader *shadow_copy_cascade_sh[SHADOW_METHOD_MAX];
} e_data = {NULL}; /* Engine data */
extern char datatoc_shadow_vert_glsl[];
extern char datatoc_shadow_geom_glsl[];
extern char datatoc_shadow_frag_glsl[];
-extern char datatoc_shadow_store_vert_glsl[];
-extern char datatoc_shadow_store_geom_glsl[];
extern char datatoc_shadow_store_frag_glsl[];
+extern char datatoc_shadow_copy_frag_glsl[];
+extern char datatoc_concentric_samples_lib_glsl[];
/* *********** FUNCTIONS *********** */
void EEVEE_lights_init(EEVEE_SceneLayerData *sldata)
{
- const unsigned int shadow_ubo_size = sizeof(EEVEE_ShadowCube) * MAX_SHADOW_CUBE +
- sizeof(EEVEE_ShadowMap) * MAX_SHADOW_MAP +
+ const unsigned int shadow_ubo_size = sizeof(EEVEE_Shadow) * MAX_SHADOW +
+ sizeof(EEVEE_ShadowCube) * MAX_SHADOW_CUBE +
sizeof(EEVEE_ShadowCascade) * MAX_SHADOW_CASCADE;
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ SceneLayer *scene_layer = draw_ctx->scene_layer;
+ IDProperty *props = BKE_scene_layer_engine_evaluated_get(scene_layer, COLLECTION_MODE_NONE, RE_engine_id_BLENDER_EEVEE);
+
if (!e_data.shadow_sh) {
e_data.shadow_sh = DRW_shader_create(
datatoc_shadow_vert_glsl, datatoc_shadow_geom_glsl, datatoc_shadow_frag_glsl, NULL);
- e_data.shadow_store_sh = DRW_shader_create(
- datatoc_shadow_store_vert_glsl, datatoc_shadow_store_geom_glsl, datatoc_shadow_store_frag_glsl, NULL);
+ DynStr *ds_frag = BLI_dynstr_new();
+ BLI_dynstr_append(ds_frag, datatoc_concentric_samples_lib_glsl);
+ BLI_dynstr_append(ds_frag, datatoc_shadow_store_frag_glsl);
+ char *store_shadow_shader_str = BLI_dynstr_get_cstring(ds_frag);
+ BLI_dynstr_free(ds_frag);
+
+ e_data.shadow_store_cube_sh[SHADOW_ESM] = DRW_shader_create_fullscreen(store_shadow_shader_str, "#define ESM\n");
+ e_data.shadow_store_cascade_sh[SHADOW_ESM] = DRW_shader_create_fullscreen(store_shadow_shader_str, "#define ESM\n"
+ "#define CSM\n");
+
+ e_data.shadow_store_cube_sh[SHADOW_VSM] = DRW_shader_create_fullscreen(store_shadow_shader_str, "#define VSM\n");
+ e_data.shadow_store_cascade_sh[SHADOW_VSM] = DRW_shader_create_fullscreen(store_shadow_shader_str, "#define VSM\n"
+ "#define CSM\n");
+
+ MEM_freeN(store_shadow_shader_str);
+
+ e_data.shadow_copy_cube_sh[SHADOW_ESM] = DRW_shader_create_fullscreen(datatoc_shadow_copy_frag_glsl, "#define ESM\n"
+ "#define COPY\n");
+ e_data.shadow_copy_cascade_sh[SHADOW_ESM] = DRW_shader_create_fullscreen(datatoc_shadow_copy_frag_glsl, "#define ESM\n"
+ "#define COPY\n"
+ "#define CSM\n");
+
+ e_data.shadow_copy_cube_sh[SHADOW_VSM] = DRW_shader_create_fullscreen(datatoc_shadow_copy_frag_glsl, "#define VSM\n"
+ "#define COPY\n");
+ e_data.shadow_copy_cascade_sh[SHADOW_VSM] = DRW_shader_create_fullscreen(datatoc_shadow_copy_frag_glsl, "#define VSM\n"
+ "#define COPY\n"
+ "#define CSM\n");
}
if (!sldata->lamps) {
@@ -92,24 +121,92 @@ void EEVEE_lights_init(EEVEE_SceneLayerData *sldata)
sldata->shadow_ubo = DRW_uniformbuffer_create(shadow_ubo_size, NULL);
sldata->shadow_render_ubo = DRW_uniformbuffer_create(sizeof(EEVEE_ShadowRender), NULL);
}
+
+ int sh_method = BKE_collection_engine_property_value_get_int(props, "shadow_method");
+ int sh_size = BKE_collection_engine_property_value_get_int(props, "shadow_size");
+ int sh_high_bitdepth = BKE_collection_engine_property_value_get_int(props, "shadow_high_bitdepth");
+
+ EEVEE_LampsInfo *linfo = sldata->lamps;
+ if ((linfo->shadow_size != sh_size) ||
+ (linfo->shadow_method != sh_method) ||
+ (linfo->shadow_high_bitdepth != sh_high_bitdepth))
+ {
+ BLI_assert((sh_size > 0) && (sh_size <= 8192));
+ DRW_TEXTURE_FREE_SAFE(sldata->shadow_pool);
+ DRW_TEXTURE_FREE_SAFE(sldata->shadow_cube_target);
+ DRW_TEXTURE_FREE_SAFE(sldata->shadow_cascade_target);
+ DRW_TEXTURE_FREE_SAFE(sldata->shadow_cube_blur);
+ DRW_TEXTURE_FREE_SAFE(sldata->shadow_cascade_blur);
+
+ linfo->shadow_high_bitdepth = sh_high_bitdepth;
+ linfo->shadow_method = sh_method;
+ linfo->shadow_size = sh_size;
+ linfo->shadow_render_data.stored_texel_size = 1.0 / (float)linfo->shadow_size;
+
+ /* Compute adequate size for the cubemap render target.
+ * The 3.0f factor is here to make sure there is no under sampling between
+ * the octahedron mapping and the cubemap. */
+ int new_cube_target_size = (int)ceil(sqrt((float)(sh_size * sh_size) / 6.0f) * 3.0f);
+
+ CLAMP(new_cube_target_size, 1, 4096);
+
+ linfo->shadow_cube_target_size = new_cube_target_size;
+ linfo->shadow_render_data.cube_texel_size = 1.0 / (float)linfo->shadow_cube_target_size;
+ }
}
void EEVEE_lights_cache_init(EEVEE_SceneLayerData *sldata, EEVEE_PassList *psl)
{
EEVEE_LampsInfo *linfo = sldata->lamps;
- linfo->num_light = linfo->num_cube = linfo->num_map = linfo->num_cascade = 0;
+ linfo->num_light = 0;
+ linfo->num_layer = 0;
+ linfo->gpu_cube_ct = linfo->gpu_cascade_ct = linfo->gpu_shadow_ct = 0;
+ linfo->cpu_cube_ct = linfo->cpu_cascade_ct = 0;
memset(linfo->light_ref, 0, sizeof(linfo->light_ref));
memset(linfo->shadow_cube_ref, 0, sizeof(linfo->shadow_cube_ref));
- memset(linfo->shadow_map_ref, 0, sizeof(linfo->shadow_map_ref));
memset(linfo->shadow_cascade_ref, 0, sizeof(linfo->shadow_cascade_ref));
{
psl->shadow_cube_store_pass = DRW_pass_create("Shadow Storage Pass", DRW_STATE_WRITE_COLOR);
- DRWShadingGroup *grp = DRW_shgroup_create(e_data.shadow_store_sh, psl->shadow_cube_store_pass);
- DRW_shgroup_uniform_buffer(grp, "shadowCube", &sldata->shadow_color_cube_target);
+ DRWShadingGroup *grp = DRW_shgroup_create(e_data.shadow_store_cube_sh[linfo->shadow_method], psl->shadow_cube_store_pass);
+ DRW_shgroup_uniform_buffer(grp, "shadowTexture", &sldata->shadow_cube_blur);
DRW_shgroup_uniform_block(grp, "shadow_render_block", sldata->shadow_render_ubo);
+ DRW_shgroup_uniform_float(grp, "shadowFilterSize", &linfo->filter_size, 1);
+ DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL);
+ }
+
+ {
+ psl->shadow_cascade_store_pass = DRW_pass_create("Shadow Cascade Storage Pass", DRW_STATE_WRITE_COLOR);
+
+ DRWShadingGroup *grp = DRW_shgroup_create(e_data.shadow_store_cascade_sh[linfo->shadow_method], psl->shadow_cascade_store_pass);
+ DRW_shgroup_uniform_buffer(grp, "shadowTexture", &sldata->shadow_cascade_blur);
+ DRW_shgroup_uniform_block(grp, "shadow_render_block", sldata->shadow_render_ubo);
+ DRW_shgroup_uniform_int(grp, "cascadeId", &linfo->current_shadow_cascade, 1);
+ DRW_shgroup_uniform_float(grp, "shadowFilterSize", &linfo->filter_size, 1);
+ DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL);
+ }
+
+ {
+ psl->shadow_cube_copy_pass = DRW_pass_create("Shadow Copy Pass", DRW_STATE_WRITE_COLOR);
+
+ DRWShadingGroup *grp = DRW_shgroup_create(e_data.shadow_copy_cube_sh[linfo->shadow_method], psl->shadow_cube_copy_pass);
+ DRW_shgroup_uniform_buffer(grp, "shadowTexture", &sldata->shadow_cube_target);
+ DRW_shgroup_uniform_block(grp, "shadow_render_block", sldata->shadow_render_ubo);
+ DRW_shgroup_uniform_float(grp, "shadowFilterSize", &linfo->filter_size, 1);
+ DRW_shgroup_uniform_int(grp, "faceId", &linfo->current_shadow_face, 1);
+ DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL);
+ }
+
+ {
+ psl->shadow_cascade_copy_pass = DRW_pass_create("Shadow Cascade Copy Pass", DRW_STATE_WRITE_COLOR);
+
+ DRWShadingGroup *grp = DRW_shgroup_create(e_data.shadow_copy_cascade_sh[linfo->shadow_method], psl->shadow_cascade_copy_pass);
+ DRW_shgroup_uniform_buffer(grp, "shadowTexture", &sldata->shadow_cascade_target);
+ DRW_shgroup_uniform_block(grp, "shadow_render_block", sldata->shadow_render_ubo);
+ DRW_shgroup_uniform_float(grp, "shadowFilterSize", &linfo->filter_size, 1);
+ DRW_shgroup_uniform_int(grp, "cascadeId", &linfo->current_shadow_cascade, 1);
DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL);
}
@@ -118,7 +215,7 @@ void EEVEE_lights_cache_init(EEVEE_SceneLayerData *sldata, EEVEE_PassList *psl)
}
{
- psl->shadow_cascade_pass = DRW_pass_create("Shadow Cascade Pass", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
+ psl->shadow_cascade_pass = DRW_pass_create("Shadow Cascade Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
}
/* Reset shadow casters list */
@@ -130,9 +227,9 @@ void EEVEE_lights_cache_add(EEVEE_SceneLayerData *sldata, Object *ob)
EEVEE_LampsInfo *linfo = sldata->lamps;
/* Step 1 find all lamps in the scene and setup them */
- if (linfo->num_light > MAX_LIGHT) {
+ if (linfo->num_light >= MAX_LIGHT) {
printf("Too much lamps in the scene !!!\n");
- linfo->num_light = MAX_LIGHT;
+ linfo->num_light = MAX_LIGHT - 1;
}
else {
Lamp *la = (Lamp *)ob->data;
@@ -144,28 +241,54 @@ void EEVEE_lights_cache_add(EEVEE_SceneLayerData *sldata, Object *ob)
MEM_SAFE_FREE(led->storage);
-#if 1 /* TODO Waiting for notified refresh. only on scene change. Else too much perf cost. */
if (la->mode & (LA_SHAD_BUF | LA_SHAD_RAY)) {
- if (la->type == LA_SUN && linfo->num_cascade < MAX_SHADOW_CASCADE) {
-#if 0 /* TODO filter cascaded shadow map */
- led->storage = MEM_mallocN(sizeof(EEVEE_ShadowCascadeData), "EEVEE_ShadowCascadeData");
- ((EEVEE_ShadowCascadeData *)led->storage)->shadow_id = linfo->num_cascade;
- linfo->shadow_cascade_ref[linfo->num_cascade] = ob;
- linfo->num_cascade++;
-#endif
+ if (la->type == LA_SUN) {
+ int sh_nbr = 1; /* TODO : MSM */
+ int cascade_nbr = MAX_CASCADE_NUM; /* TODO : Custom cascade number */
+
+ if ((linfo->gpu_cascade_ct + sh_nbr) <= MAX_SHADOW_CASCADE) {
+ /* Save Light object. */
+ linfo->shadow_cascade_ref[linfo->cpu_cascade_ct] = ob;
+
+ /* Create storage and store indices. */
+ EEVEE_ShadowCascadeData *data = MEM_mallocN(sizeof(EEVEE_ShadowCascadeData), "EEVEE_ShadowCascadeData");
+ data->shadow_id = linfo->gpu_shadow_ct;
+ data->cascade_id = linfo->gpu_cascade_ct;
+ data->layer_id = linfo->num_layer;
+ led->storage = data;
+
+ /* Increment indices. */
+ linfo->gpu_shadow_ct += 1;
+ linfo->gpu_cascade_ct += sh_nbr;
+ linfo->num_layer += sh_nbr * cascade_nbr;
+
+ linfo->cpu_cascade_ct += 1;
+ }
}
- else if ((la->type == LA_SPOT || la->type == LA_LOCAL || la->type == LA_AREA)
- && linfo->num_cube < MAX_SHADOW_CUBE) {
- led->storage = MEM_mallocN(sizeof(EEVEE_ShadowCubeData), "EEVEE_ShadowCubeData");
- ((EEVEE_ShadowCubeData *)led->storage)->shadow_id = linfo->num_cube;
- linfo->shadow_cube_ref[linfo->num_cube] = ob;
- linfo->num_cube++;
+ else if (la->type == LA_SPOT || la->type == LA_LOCAL || la->type == LA_AREA) {
+ int sh_nbr = 1; /* TODO : MSM */
+
+ if ((linfo->gpu_cube_ct + sh_nbr) <= MAX_SHADOW_CUBE) {
+ /* Save Light object. */
+ linfo->shadow_cube_ref[linfo->cpu_cube_ct] = ob;
+
+ /* Create storage and store indices. */
+ EEVEE_ShadowCubeData *data = MEM_mallocN(sizeof(EEVEE_ShadowCubeData), "EEVEE_ShadowCubeData");
+ data->shadow_id = linfo->gpu_shadow_ct;
+ data->cube_id = linfo->gpu_cube_ct;
+ data->layer_id = linfo->num_layer;
+ led->storage = data;
+
+ /* Increment indices. */
+ linfo->gpu_shadow_ct += 1;
+ linfo->gpu_cube_ct += sh_nbr;
+ linfo->num_layer += sh_nbr;
+
+ linfo->cpu_cube_ct += 1;
+ }
}
-
}
-#else
- UNUSED_VARS(la);
-#endif
+
/* Default light without shadows */
if (!led->storage) {
led->storage = MEM_mallocN(sizeof(EEVEE_LightData), "EEVEE_LightData");
@@ -196,73 +319,92 @@ void EEVEE_lights_cache_shcaster_add(EEVEE_SceneLayerData *sldata, EEVEE_PassLis
DRW_shgroup_call_dynamic_add_empty(grp);
}
+void EEVEE_lights_cache_shcaster_material_add(
+ EEVEE_SceneLayerData *sldata, EEVEE_PassList *psl, struct GPUMaterial *gpumat,
+ struct Gwn_Batch *geom, struct Object *ob, float (*obmat)[4], float *alpha_threshold)
+{
+ DRWShadingGroup *grp = DRW_shgroup_material_instance_create(gpumat, psl->shadow_cube_pass, geom, ob);
+
+ if (grp == NULL) return;
+
+ DRW_shgroup_uniform_block(grp, "shadow_render_block", sldata->shadow_render_ubo);
+ DRW_shgroup_uniform_mat4(grp, "ShadowModelMatrix", (float *)obmat);
+
+ if (alpha_threshold != NULL)
+ DRW_shgroup_uniform_float(grp, "alphaThreshold", alpha_threshold, 1);
+
+ for (int i = 0; i < 6; ++i)
+ DRW_shgroup_call_dynamic_add_empty(grp);
+
+ grp = DRW_shgroup_material_instance_create(gpumat, psl->shadow_cascade_pass, geom, ob);
+ DRW_shgroup_uniform_block(grp, "shadow_render_block", sldata->shadow_render_ubo);
+ DRW_shgroup_uniform_mat4(grp, "ShadowModelMatrix", (float *)obmat);
+
+ if (alpha_threshold != NULL)
+ DRW_shgroup_uniform_float(grp, "alphaThreshold", alpha_threshold, 1);
+
+ for (int i = 0; i < MAX_CASCADE_NUM; ++i)
+ DRW_shgroup_call_dynamic_add_empty(grp);
+}
+
void EEVEE_lights_cache_finish(EEVEE_SceneLayerData *sldata)
{
EEVEE_LampsInfo *linfo = sldata->lamps;
+ DRWTextureFormat shadow_pool_format;
/* Setup enough layers. */
/* Free textures if number mismatch. */
- if (linfo->num_cube != linfo->cache_num_cube) {
- DRW_TEXTURE_FREE_SAFE(sldata->shadow_depth_cube_pool);
- linfo->cache_num_cube = linfo->num_cube;
+ if (linfo->num_layer != linfo->cache_num_layer) {
+ DRW_TEXTURE_FREE_SAFE(sldata->shadow_pool);
+ linfo->cache_num_layer = linfo->num_layer;
linfo->update_flag |= LIGHT_UPDATE_SHADOW_CUBE;
}
- if (linfo->num_map != linfo->cache_num_map) {
- DRW_TEXTURE_FREE_SAFE(sldata->shadow_depth_map_pool);
- linfo->cache_num_map = linfo->num_map;
- }
- if (linfo->num_cascade != linfo->cache_num_cascade) {
- DRW_TEXTURE_FREE_SAFE(sldata->shadow_depth_cascade_pool);
- linfo->cache_num_cascade = linfo->num_cascade;
- }
- /* Initialize Textures Arrays first so DRW_framebuffer_init just bind them. */
- if (!sldata->shadow_depth_cube_target) {
- /* Render Cubemap */
- sldata->shadow_depth_cube_target = DRW_texture_create_cube(512, DRW_TEX_DEPTH_24, 0, NULL);
- sldata->shadow_color_cube_target = DRW_texture_create_cube(512, DRW_TEX_R_32, DRW_TEX_FILTER, NULL);
- if (sldata->shadow_cube_fb) {
- DRW_framebuffer_texture_attach(sldata->shadow_cube_fb, sldata->shadow_depth_cube_target, 0, 0);
- DRW_framebuffer_texture_attach(sldata->shadow_cube_fb, sldata->shadow_color_cube_target, 0, 0);
- }
+ switch (linfo->shadow_method) {
+ case SHADOW_ESM: shadow_pool_format = ((linfo->shadow_high_bitdepth) ? DRW_TEX_R_32 : DRW_TEX_R_16); break;
+ case SHADOW_VSM: shadow_pool_format = ((linfo->shadow_high_bitdepth) ? DRW_TEX_RG_32 : DRW_TEX_RG_16); break;
+ default:
+ BLI_assert(!"Incorrect Shadow Method");
+ break;
}
- if (!sldata->shadow_depth_cube_pool) {
- /* Cubemap / octahedral map pool */
- /* TODO Cubemap array */
- sldata->shadow_depth_cube_pool = DRW_texture_create_2D_array(
- 512, 512, max_ff(1, linfo->num_cube), DRW_TEX_R_16,
- DRW_TEX_FILTER | DRW_TEX_COMPARE, NULL);
- if (sldata->shadow_cube_fb) {
- DRW_framebuffer_texture_attach(sldata->shadow_cube_fb, sldata->shadow_depth_cube_pool, 0, 0);
- }
+
+ if (!sldata->shadow_cube_target) {
+ /* TODO render everything on the same 2d render target using clip planes and no Geom Shader. */
+ /* Cubemaps */
+ sldata->shadow_cube_target = DRW_texture_create_cube(linfo->shadow_cube_target_size, DRW_TEX_DEPTH_24, 0, NULL);
+ sldata->shadow_cube_blur = DRW_texture_create_cube(linfo->shadow_cube_target_size, shadow_pool_format, DRW_TEX_FILTER, NULL);
}
- if (!sldata->shadow_depth_map_pool) {
- sldata->shadow_depth_map_pool = DRW_texture_create_2D_array(
- 512, 512, max_ff(1, linfo->num_map), DRW_TEX_DEPTH_24,
- DRW_TEX_FILTER | DRW_TEX_COMPARE, NULL);
- if (sldata->shadow_map_fb) {
- DRW_framebuffer_texture_attach(sldata->shadow_map_fb, sldata->shadow_depth_map_pool, 0, 0);
- }
+
+ if (!sldata->shadow_cascade_target) {
+ /* CSM */
+ sldata->shadow_cascade_target = DRW_texture_create_2D_array(
+ linfo->shadow_size, linfo->shadow_size, MAX_CASCADE_NUM, DRW_TEX_DEPTH_24, 0, NULL);
+ sldata->shadow_cascade_blur = DRW_texture_create_2D_array(
+ linfo->shadow_size, linfo->shadow_size, MAX_CASCADE_NUM, shadow_pool_format, DRW_TEX_FILTER, NULL);
}
- if (!sldata->shadow_depth_cascade_pool) {
- sldata->shadow_depth_cascade_pool = DRW_texture_create_2D_array(
- 512, 512, max_ff(1, linfo->num_cascade * MAX_CASCADE_NUM), DRW_TEX_DEPTH_24,
- DRW_TEX_FILTER | DRW_TEX_COMPARE, NULL);
- if (sldata->shadow_cascade_fb) {
- DRW_framebuffer_texture_attach(sldata->shadow_cascade_fb, sldata->shadow_depth_map_pool, 0, 0);
- }
+
+ /* Initialize Textures Array first so DRW_framebuffer_init just bind them. */
+ if (!sldata->shadow_pool) {
+ /* All shadows fit in this array */
+ sldata->shadow_pool = DRW_texture_create_2D_array(
+ linfo->shadow_size, linfo->shadow_size, max_ff(1, linfo->num_layer),
+ shadow_pool_format, DRW_TEX_FILTER, NULL);
}
- DRWFboTexture tex_cube_target[2] = {
- {&sldata->shadow_depth_cube_target, DRW_TEX_DEPTH_24, 0},
- {&sldata->shadow_color_cube_target, DRW_TEX_R_16, DRW_TEX_FILTER}};
- DRW_framebuffer_init(&sldata->shadow_cube_target_fb, &draw_engine_eevee_type, 512, 512, tex_cube_target, 2);
+ /* Render FB */
+ DRWFboTexture tex_cascade = {&sldata->shadow_cube_target, DRW_TEX_DEPTH_24, 0};
+ DRW_framebuffer_init(&sldata->shadow_target_fb, &draw_engine_eevee_type,
+ linfo->shadow_size, linfo->shadow_size,
+ &tex_cascade, 1);
- DRWFboTexture tex_cube = {&sldata->shadow_depth_cube_pool, DRW_TEX_R_16, DRW_TEX_FILTER};
- DRW_framebuffer_init(&sldata->shadow_cube_fb, &draw_engine_eevee_type, 512, 512, &tex_cube, 1);
+ /* Storage FB */
+ DRWFboTexture tex_pool = {&sldata->shadow_pool, shadow_pool_format, DRW_TEX_FILTER};
+ DRW_framebuffer_init(&sldata->shadow_store_fb, &draw_engine_eevee_type,
+ linfo->shadow_size, linfo->shadow_size,
+ &tex_pool, 1);
- DRWFboTexture tex_cascade = {&sldata->shadow_depth_cascade_pool, DRW_TEX_DEPTH_24, DRW_TEX_FILTER | DRW_TEX_COMPARE};
- DRW_framebuffer_init(&sldata->shadow_cascade_fb, &draw_engine_eevee_type, 512, 512, &tex_cascade, 1);
+ /* Restore */
+ DRW_framebuffer_texture_detach(sldata->shadow_cube_target);
/* Update Lamps UBOs. */
EEVEE_lights_update(sldata);
@@ -321,12 +463,12 @@ static void eevee_light_setup(Object *ob, EEVEE_LampsInfo *linfo, EEVEE_LampEngi
/* Make illumination power constant */
if (la->type == LA_AREA) {
- power = 1.0f / (evli->sizex * evli->sizey * 4.0f * M_PI) /* 1/(w*h*Pi) */
- * 80.0f; /* XXX : Empirical, Fit cycles power */
+ power = 1.0f / (evli->sizex * evli->sizey * 4.0f * M_PI) * /* 1/(w*h*Pi) */
+ 80.0f; /* XXX : Empirical, Fit cycles power */
}
else if (la->type == LA_SPOT || la->type == LA_LOCAL) {
- power = 1.0f / (4.0f * evli->radius * evli->radius * M_PI * M_PI) /* 1/(4*r²*Pi²) */
- * M_PI * M_PI * M_PI * 10.0; /* XXX : Empirical, Fit cycles power */
+ power = 1.0f / (4.0f * evli->radius * evli->radius * M_PI * M_PI) * /* 1/(4*r²*Pi²) */
+ M_PI * M_PI * M_PI * 10.0; /* XXX : Empirical, Fit cycles power */
/* for point lights (a.k.a radius == 0.0) */
// power = M_PI * M_PI * 0.78; /* XXX : Empirical, Fit cycles power */
@@ -345,54 +487,33 @@ static void eevee_light_setup(Object *ob, EEVEE_LampsInfo *linfo, EEVEE_LampEngi
static void eevee_shadow_cube_setup(Object *ob, EEVEE_LampsInfo *linfo, EEVEE_LampEngineData *led)
{
- float projmat[4][4];
-
- EEVEE_ShadowCubeData *evsmp = (EEVEE_ShadowCubeData *)led->storage;
- EEVEE_Light *evli = linfo->light_data + evsmp->light_id;
- EEVEE_ShadowCube *evsh = linfo->shadow_cube_data + evsmp->shadow_id;
+ EEVEE_ShadowCubeData *sh_data = (EEVEE_ShadowCubeData *)led->storage;
+ EEVEE_Light *evli = linfo->light_data + sh_data->light_id;
+ EEVEE_Shadow *ubo_data = linfo->shadow_data + sh_data->shadow_id;
+ EEVEE_ShadowCube *cube_data = linfo->shadow_cube_data + sh_data->cube_id;
Lamp *la = (Lamp *)ob->data;
- perspective_m4(projmat, -la->clipsta, la->clipsta, -la->clipsta, la->clipsta, la->clipsta, la->clipend);
+ int sh_nbr = 1; /* TODO: MSM */
- for (int i = 0; i < 6; ++i) {
- float tmp[4][4];
- unit_m4(tmp);
- negate_v3_v3(tmp[3], ob->obmat[3]);
- mul_m4_m4m4(tmp, cubefacemat[i], tmp);
- mul_m4_m4m4(evsmp->viewprojmat[i], projmat, tmp);
+ for (int i = 0; i < sh_nbr; ++i) {
+ /* TODO : choose MSM sample point here. */
+ copy_v3_v3(cube_data->position, ob->obmat[3]);
}
- evsh->bias = 0.05f * la->bias;
- evsh->near = la->clipsta;
- evsh->far = la->clipend;
- evsh->exp = la->bleedexp;
-
- evli->shadowid = (float)(evsmp->shadow_id);
-}
-
-static void eevee_shadow_map_setup(Object *ob, EEVEE_LampsInfo *linfo, EEVEE_LampEngineData *led)
-{
- float viewmat[4][4], projmat[4][4];
-
- EEVEE_ShadowMapData *evsmp = (EEVEE_ShadowMapData *)led->storage;
- EEVEE_Light *evli = linfo->light_data + evsmp->light_id;
- EEVEE_ShadowMap *evsh = linfo->shadow_map_data + evsmp->shadow_id;
- Lamp *la = (Lamp *)ob->data;
-
- invert_m4_m4(viewmat, ob->obmat);
- normalize_v3(viewmat[0]);
- normalize_v3(viewmat[1]);
- normalize_v3(viewmat[2]);
+ ubo_data->bias = 0.05f * la->bias;
+ ubo_data->near = la->clipsta;
+ ubo_data->far = la->clipend;
+ ubo_data->exp = (linfo->shadow_method == SHADOW_VSM) ? la->bleedbias : la->bleedexp;
- float wsize = la->shadow_frustum_size;
- orthographic_m4(projmat, -wsize, wsize, -wsize, wsize, la->clipsta, la->clipend);
+ evli->shadowid = (float)(sh_data->shadow_id);
+ ubo_data->shadow_start = (float)(sh_data->layer_id);
+ ubo_data->data_start = (float)(sh_data->cube_id);
+ ubo_data->multi_shadow_count = (float)(sh_nbr);
- mul_m4_m4m4(evsmp->viewprojmat, projmat, viewmat);
- mul_m4_m4m4(evsh->shadowmat, texcomat, evsmp->viewprojmat);
-
- evsh->bias = 0.005f * la->bias;
-
- evli->shadowid = (float)(MAX_SHADOW_CUBE + evsmp->shadow_id);
+ ubo_data->contact_dist = (la->mode & LA_SHAD_CONTACT) ? la->contact_dist : 0.0f;
+ ubo_data->contact_bias = 0.05f * la->contact_bias;
+ ubo_data->contact_spread = la->contact_spread;
+ ubo_data->contact_thickness = la->contact_thickness;
}
#define LERP(t, a, b) ((a) + (t) * ((b) - (a)))
@@ -404,7 +525,7 @@ static void frustum_min_bounding_sphere(const float corners[8][4], float r_cente
/* compute the bounding box */
INIT_MINMAX(minvec, maxvec);
- for (int i = 0; i < 8; ++i) {
+ for (int i = 0; i < 8; ++i) {
minmax_v3v3_v3(minvec, maxvec, corners[i]);
}
@@ -421,7 +542,7 @@ static void frustum_min_bounding_sphere(const float corners[8][4], float r_cente
/* Search the largest distance between the sphere center
* and the front plane corners. */
for (int i = 0; i < 4; ++i) {
- float rad = len_v3v3(corners[4+i], r_center);
+ float rad = len_v3v3(corners[4 + i], r_center);
if (rad > *r_radius) {
*r_radius = rad;
}
@@ -431,10 +552,12 @@ static void frustum_min_bounding_sphere(const float corners[8][4], float r_cente
static void eevee_shadow_cascade_setup(Object *ob, EEVEE_LampsInfo *linfo, EEVEE_LampEngineData *led)
{
+ Lamp *la = (Lamp *)ob->data;
+
/* Camera Matrices */
float persmat[4][4], persinv[4][4];
float viewprojmat[4][4], projinv[4][4];
- float near, far;
+ float view_near, view_far;
float near_v[4] = {0.0f, 0.0f, -1.0f, 1.0f};
float far_v[4] = {0.0f, 0.0f, 1.0f, 1.0f};
bool is_persp = DRW_viewport_is_persp_get();
@@ -445,99 +568,160 @@ static void eevee_shadow_cascade_setup(Object *ob, EEVEE_LampsInfo *linfo, EEVEE
invert_m4_m4(projinv, viewprojmat);
mul_m4_v4(projinv, near_v);
mul_m4_v4(projinv, far_v);
- near = near_v[2];
- far = far_v[2]; /* TODO: Should be a shadow parameter */
+ view_near = near_v[2];
+ view_far = far_v[2]; /* TODO: Should be a shadow parameter */
if (is_persp) {
- near /= near_v[3];
- far /= far_v[3];
+ view_near /= near_v[3];
+ view_far /= far_v[3];
}
/* Lamps Matrices */
float viewmat[4][4], projmat[4][4];
- int cascade_ct = MAX_CASCADE_NUM;
- float shadow_res = 512.0f; /* TODO parameter */
+ int sh_nbr = 1; /* TODO : MSM */
+ int cascade_nbr = la->cascade_count;
- EEVEE_ShadowCascadeData *evscp = (EEVEE_ShadowCascadeData *)led->storage;
- EEVEE_Light *evli = linfo->light_data + evscp->light_id;
- EEVEE_ShadowCascade *evsh = linfo->shadow_cascade_data + evscp->shadow_id;
- Lamp *la = (Lamp *)ob->data;
+ EEVEE_ShadowCascadeData *sh_data = (EEVEE_ShadowCascadeData *)led->storage;
+ EEVEE_Light *evli = linfo->light_data + sh_data->light_id;
+ EEVEE_Shadow *ubo_data = linfo->shadow_data + sh_data->shadow_id;
+ EEVEE_ShadowCascade *cascade_data = linfo->shadow_cascade_data + sh_data->cascade_id;
/* The technique consists into splitting
* the view frustum into several sub-frustum
* that are individually receiving one shadow map */
+ float csm_start, csm_end;
+
+ if (is_persp) {
+ csm_start = view_near;
+ csm_end = max_ff(view_far, -la->cascade_max_dist);
+ /* Avoid artifacts */
+ csm_end = min_ff(view_near, csm_end);
+ }
+ else {
+ csm_start = -view_far;
+ csm_end = view_far;
+ }
+
/* init near/far */
for (int c = 0; c < MAX_CASCADE_NUM; ++c) {
- evsh->split[c] = far;
+ cascade_data->split_start[c] = csm_end;
+ cascade_data->split_end[c] = csm_end;
}
/* Compute split planes */
- float splits_ndc[MAX_CASCADE_NUM + 1];
- splits_ndc[0] = -1.0f;
- splits_ndc[cascade_ct] = 1.0f;
- for (int c = 1; c < cascade_ct; ++c) {
- const float lambda = 0.8f; /* TODO : Parameter */
+ float splits_start_ndc[MAX_CASCADE_NUM];
+ float splits_end_ndc[MAX_CASCADE_NUM];
+ {
+ /* Nearest plane */
+ float p[4] = {1.0f, 1.0f, csm_start, 1.0f};
+ /* TODO: we don't need full m4 multiply here */
+ mul_m4_v4(viewprojmat, p);
+ splits_start_ndc[0] = p[2];
+ if (is_persp) {
+ splits_start_ndc[0] /= p[3];
+ }
+ }
+
+ {
+ /* Farthest plane */
+ float p[4] = {1.0f, 1.0f, csm_end, 1.0f};
+ /* TODO: we don't need full m4 multiply here */
+ mul_m4_v4(viewprojmat, p);
+ splits_end_ndc[cascade_nbr - 1] = p[2];
+ if (is_persp) {
+ splits_end_ndc[cascade_nbr - 1] /= p[3];
+ }
+ }
+
+ cascade_data->split_start[0] = csm_start;
+ cascade_data->split_end[cascade_nbr - 1] = csm_end;
+
+ for (int c = 1; c < cascade_nbr; ++c) {
/* View Space */
- float linear_split = LERP(((float)(c) / (float)cascade_ct), near, far);
- float exp_split = near * powf(far / near, (float)(c) / (float)cascade_ct);
+ float linear_split = LERP(((float)(c) / (float)cascade_nbr), csm_start, csm_end);
+ float exp_split = csm_start * powf(csm_end / csm_start, (float)(c) / (float)cascade_nbr);
if (is_persp) {
- evsh->split[c-1] = LERP(lambda, linear_split, exp_split);
+ cascade_data->split_start[c] = LERP(la->cascade_exponent, linear_split, exp_split);
}
else {
- evsh->split[c-1] = linear_split;
+ cascade_data->split_start[c] = linear_split;
}
+ cascade_data->split_end[c - 1] = cascade_data->split_start[c];
+
+ /* Add some overlap for smooth transition */
+ cascade_data->split_start[c] = LERP(la->cascade_fade, cascade_data->split_end[c - 1],
+ (c > 1) ? cascade_data->split_end[c - 2] : cascade_data->split_start[0]);
/* NDC Space */
- float p[4] = {1.0f, 1.0f, evsh->split[c-1], 1.0f};
- mul_m4_v4(viewprojmat, p);
- splits_ndc[c] = p[2];
+ {
+ float p[4] = {1.0f, 1.0f, cascade_data->split_start[c], 1.0f};
+ /* TODO: we don't need full m4 multiply here */
+ mul_m4_v4(viewprojmat, p);
+ splits_start_ndc[c] = p[2];
+
+ if (is_persp) {
+ splits_start_ndc[c] /= p[3];
+ }
+ }
- if (is_persp) {
- splits_ndc[c] /= p[3];
+ {
+ float p[4] = {1.0f, 1.0f, cascade_data->split_end[c - 1], 1.0f};
+ /* TODO: we don't need full m4 multiply here */
+ mul_m4_v4(viewprojmat, p);
+ splits_end_ndc[c - 1] = p[2];
+
+ if (is_persp) {
+ splits_end_ndc[c - 1] /= p[3];
+ }
}
}
+ /* Set last cascade split fade distance into the first split_start. */
+ float prev_split = (cascade_nbr > 1) ? cascade_data->split_end[cascade_nbr - 2] : cascade_data->split_start[0];
+ cascade_data->split_start[0] = LERP(la->cascade_fade, cascade_data->split_end[cascade_nbr - 1], prev_split);
+
/* For each cascade */
- for (int c = 0; c < cascade_ct; ++c) {
- /* Given 8 frustrum corners */
+ for (int c = 0; c < cascade_nbr; ++c) {
+ /* Given 8 frustum corners */
float corners[8][4] = {
/* Near Cap */
- {-1.0f, -1.0f, splits_ndc[c], 1.0f},
- { 1.0f, -1.0f, splits_ndc[c], 1.0f},
- {-1.0f, 1.0f, splits_ndc[c], 1.0f},
- { 1.0f, 1.0f, splits_ndc[c], 1.0f},
+ {-1.0f, -1.0f, splits_start_ndc[c], 1.0f},
+ { 1.0f, -1.0f, splits_start_ndc[c], 1.0f},
+ {-1.0f, 1.0f, splits_start_ndc[c], 1.0f},
+ { 1.0f, 1.0f, splits_start_ndc[c], 1.0f},
/* Far Cap */
- {-1.0f, -1.0f, splits_ndc[c+1], 1.0f},
- { 1.0f, -1.0f, splits_ndc[c+1], 1.0f},
- {-1.0f, 1.0f, splits_ndc[c+1], 1.0f},
- { 1.0f, 1.0f, splits_ndc[c+1], 1.0f}
+ {-1.0f, -1.0f, splits_end_ndc[c], 1.0f},
+ { 1.0f, -1.0f, splits_end_ndc[c], 1.0f},
+ {-1.0f, 1.0f, splits_end_ndc[c], 1.0f},
+ { 1.0f, 1.0f, splits_end_ndc[c], 1.0f}
};
/* Transform them into world space */
- for (int i = 0; i < 8; ++i) {
+ for (int i = 0; i < 8; ++i) {
mul_m4_v4(persinv, corners[i]);
mul_v3_fl(corners[i], 1.0f / corners[i][3]);
corners[i][3] = 1.0f;
}
+
/* Project them into light space */
invert_m4_m4(viewmat, ob->obmat);
normalize_v3(viewmat[0]);
normalize_v3(viewmat[1]);
normalize_v3(viewmat[2]);
- for (int i = 0; i < 8; ++i) {
+ for (int i = 0; i < 8; ++i) {
mul_m4_v4(viewmat, corners[i]);
}
- float center[3], radius;
- frustum_min_bounding_sphere(corners, center, &radius);
+ float center[3];
+ frustum_min_bounding_sphere(corners, center, &(sh_data->radius[c]));
- /* Snap projection center to nearest texel to cancel shimering. */
+ /* Snap projection center to nearest texel to cancel shimmering. */
float shadow_origin[2], shadow_texco[2];
- mul_v2_v2fl(shadow_origin, center, shadow_res / (2.0f * radius)); /* Light to texture space. */
+ mul_v2_v2fl(shadow_origin, center, linfo->shadow_size / (2.0f * sh_data->radius[c])); /* Light to texture space. */
/* Find the nearest texel. */
shadow_texco[0] = round(shadow_origin[0]);
@@ -545,27 +729,37 @@ static void eevee_shadow_cascade_setup(Object *ob, EEVEE_LampsInfo *linfo, EEVEE
/* Compute offset. */
sub_v2_v2(shadow_texco, shadow_origin);
- mul_v2_fl(shadow_texco, (2.0f * radius) / shadow_res); /* Texture to light space. */
+ mul_v2_fl(shadow_texco, (2.0f * sh_data->radius[c]) / linfo->shadow_size); /* Texture to light space. */
/* Apply offset. */
add_v2_v2(center, shadow_texco);
/* Expand the projection to cover frustum range */
orthographic_m4(projmat,
- center[0] - radius,
- center[0] + radius,
- center[1] - radius,
- center[1] + radius,
+ center[0] - sh_data->radius[c],
+ center[0] + sh_data->radius[c],
+ center[1] - sh_data->radius[c],
+ center[1] + sh_data->radius[c],
la->clipsta, la->clipend);
- mul_m4_m4m4(evscp->viewprojmat[c], projmat, viewmat);
- mul_m4_m4m4(evsh->shadowmat[c], texcomat, evscp->viewprojmat[c]);
-
- /* TODO modify bias depending on the cascade radius */
- evsh->bias[c] = 0.005f * la->bias;
+ mul_m4_m4m4(sh_data->viewprojmat[c], projmat, viewmat);
+ mul_m4_m4m4(cascade_data->shadowmat[c], texcomat, sh_data->viewprojmat[c]);
}
- evli->shadowid = (float)(MAX_SHADOW_CUBE + MAX_SHADOW_MAP + evscp->shadow_id);
+ ubo_data->bias = 0.05f * la->bias;
+ ubo_data->near = la->clipsta;
+ ubo_data->far = la->clipend;
+ ubo_data->exp = (linfo->shadow_method == SHADOW_VSM) ? la->bleedbias : la->bleedexp;
+
+ evli->shadowid = (float)(sh_data->shadow_id);
+ ubo_data->shadow_start = (float)(sh_data->layer_id);
+ ubo_data->data_start = (float)(sh_data->cascade_id);
+ ubo_data->multi_shadow_count = (float)(sh_nbr);
+
+ ubo_data->contact_dist = (la->mode & LA_SHAD_CONTACT) ? la->contact_dist : 0.0f;
+ ubo_data->contact_bias = 0.05f * la->contact_bias;
+ ubo_data->contact_spread = la->contact_spread;
+ ubo_data->contact_thickness = la->contact_thickness;
}
/* Used for checking if object is inside the shadow volume. */
@@ -585,8 +779,8 @@ static bool cube_bbox_intersect(const float cube_center[3], float cube_half_dim,
minmax_v3v3_v3(min, max, vec);
}
- if (MAX3(max[0], max[1], max[2]) < -cube_half_dim) return false;
- if (MIN3(min[0], min[1], min[2]) > cube_half_dim) return false;
+ if (MAX3(max[0], max[1], max[2]) < -cube_half_dim) return false;
+ if (MIN3(min[0], min[1], min[2]) > cube_half_dim) return false;
return true;
}
@@ -690,19 +884,6 @@ void EEVEE_lights_update(EEVEE_SceneLayerData *sldata)
eevee_shadow_cube_setup(ob, linfo, led);
delete_pruned_shadowcaster(led);
}
-
- for (i = 0; (ob = linfo->shadow_map_ref[i]) && (i < MAX_SHADOW_MAP); i++) {
- EEVEE_LampEngineData *led = EEVEE_lamp_data_get(ob);
- eevee_shadow_map_setup(ob, linfo, led);
- }
-
- for (i = 0; (ob = linfo->shadow_cascade_ref[i]) && (i < MAX_SHADOW_CASCADE); i++) {
- EEVEE_LampEngineData *led = EEVEE_lamp_data_get(ob);
- eevee_shadow_cascade_setup(ob, linfo, led);
- }
-
- DRW_uniformbuffer_update(sldata->light_ubo, &linfo->light_data);
- DRW_uniformbuffer_update(sldata->shadow_ubo, &linfo->shadow_cube_data); /* Update all data at once */
}
/* this refresh lamps shadow buffers */
@@ -711,33 +892,83 @@ void EEVEE_draw_shadows(EEVEE_SceneLayerData *sldata, EEVEE_PassList *psl)
EEVEE_LampsInfo *linfo = sldata->lamps;
Object *ob;
int i;
- float clear_color[4] = {FLT_MAX, FLT_MAX, FLT_MAX, 0.0f};
+ float clear_col[4] = {FLT_MAX};
/* Cube Shadow Maps */
+ DRW_stats_group_start("Cube Shadow Maps");
+ DRW_framebuffer_texture_attach(sldata->shadow_target_fb, sldata->shadow_cube_target, 0, 0);
/* Render each shadow to one layer of the array */
for (i = 0; (ob = linfo->shadow_cube_ref[i]) && (i < MAX_SHADOW_CUBE); i++) {
EEVEE_LampEngineData *led = EEVEE_lamp_data_get(ob);
Lamp *la = (Lamp *)ob->data;
+ float cube_projmat[4][4];
+ perspective_m4(cube_projmat, -la->clipsta, la->clipsta, -la->clipsta, la->clipsta, la->clipsta, la->clipend);
+
if (led->need_update) {
- EEVEE_ShadowCubeData *evscd = (EEVEE_ShadowCubeData *)led->storage;
EEVEE_ShadowRender *srd = &linfo->shadow_render_data;
+ EEVEE_ShadowCubeData *evscd = (EEVEE_ShadowCubeData *)led->storage;
- srd->layer = i;
- srd->exponent = la->bleedexp;
+ srd->clip_near = la->clipsta;
+ srd->clip_far = la->clipend;
copy_v3_v3(srd->position, ob->obmat[3]);
- for (int j = 0; j < 6; ++j) {
- copy_m4_m4(srd->shadowmat[j], evscd->viewprojmat[j]);
+ for (int j = 0; j < 6; j++) {
+ float tmp[4][4];
+
+ unit_m4(tmp);
+ negate_v3_v3(tmp[3], ob->obmat[3]);
+ mul_m4_m4m4(srd->viewmat[j], cubefacemat[j], tmp);
+
+ mul_m4_m4m4(srd->shadowmat[j], cube_projmat, srd->viewmat[j]);
}
- DRW_uniformbuffer_update(sldata->shadow_render_ubo, &linfo->shadow_render_data);
+ DRW_uniformbuffer_update(sldata->shadow_render_ubo, srd);
+
+ DRW_framebuffer_bind(sldata->shadow_target_fb);
+ DRW_framebuffer_clear(true, true, false, clear_col, 1.0f);
- DRW_framebuffer_bind(sldata->shadow_cube_target_fb);
- DRW_framebuffer_clear(true, true, false, clear_color, 1.0);
/* Render shadow cube */
DRW_draw_pass(psl->shadow_cube_pass);
+ /* 0.001f is arbitrary, but it should be relatively small so that filter size is not too big. */
+ float filter_texture_size = la->soft * 0.001f;
+ float filter_pixel_size = ceil(filter_texture_size / linfo->shadow_render_data.cube_texel_size);
+ linfo->filter_size = linfo->shadow_render_data.cube_texel_size * ((filter_pixel_size > 1.0f) ? 1.5f : 0.0f);
+
+ /* TODO: OPTI: Filter all faces in one/two draw call */
+ for (linfo->current_shadow_face = 0;
+ linfo->current_shadow_face < 6;
+ linfo->current_shadow_face++)
+ {
+ /* Copy using a small 3x3 box filter */
+ DRW_framebuffer_cubeface_attach(sldata->shadow_store_fb, sldata->shadow_cube_blur, 0, linfo->current_shadow_face, 0);
+ DRW_framebuffer_bind(sldata->shadow_store_fb);
+ DRW_draw_pass(psl->shadow_cube_copy_pass);
+ DRW_framebuffer_texture_detach(sldata->shadow_cube_blur);
+ }
+
/* Push it to shadowmap array */
- DRW_framebuffer_bind(sldata->shadow_cube_fb);
+
+ /* Adjust constants if concentric samples change. */
+ const float max_filter_size = 7.5f;
+ const float previous_box_filter_size = 9.0f; /* Dunno why but that works. */
+ const int max_sample = 256;
+
+ if (filter_pixel_size > 2.0f) {
+ linfo->filter_size = linfo->shadow_render_data.cube_texel_size * max_filter_size * previous_box_filter_size;
+ filter_pixel_size = max_ff(0.0f, filter_pixel_size - 3.0f);
+ /* Compute number of concentric samples. Depends directly on filter size. */
+ float pix_size_sqr = filter_pixel_size * filter_pixel_size;
+ srd->shadow_samples_ct = min_ii(max_sample, 4 + 8 * (int)filter_pixel_size + 4 * (int)(pix_size_sqr));
+ }
+ else {
+ linfo->filter_size = 0.0f;
+ srd->shadow_samples_ct = 4;
+ }
+ srd->shadow_inv_samples_ct = 1.0f / (float)srd->shadow_samples_ct;
+ DRW_uniformbuffer_update(sldata->shadow_render_ubo, srd);
+
+ DRW_framebuffer_texture_layer_attach(sldata->shadow_store_fb, sldata->shadow_pool, 0, evscd->layer_id, 0);
+ DRW_framebuffer_bind(sldata->shadow_store_fb);
DRW_draw_pass(psl->shadow_cube_store_pass);
led->need_update = false;
@@ -745,44 +976,92 @@ void EEVEE_draw_shadows(EEVEE_SceneLayerData *sldata, EEVEE_PassList *psl)
}
linfo->update_flag &= ~LIGHT_UPDATE_SHADOW_CUBE;
-#if 0
- /* Standard Shadow Maps */
- DRW_framebuffer_bind(fbl->shadow_map_fb);
- DRW_framebuffer_clear(false, true, false, NULL, 1.0);
+ DRW_framebuffer_texture_detach(sldata->shadow_cube_target);
+ DRW_stats_group_end();
- /* Render each shadow to one layer of the array */
- for (i = 0; (ob = linfo->shadow_map_ref[i]) && (i < MAX_SHADOW_MAP); i++) {
+ /* Cascaded Shadow Maps */
+ DRW_stats_group_start("Cascaded Shadow Maps");
+ DRW_framebuffer_texture_attach(sldata->shadow_target_fb, sldata->shadow_cascade_target, 0, 0);
+ for (i = 0; (ob = linfo->shadow_cascade_ref[i]) && (i < MAX_SHADOW_CASCADE); i++) {
EEVEE_LampEngineData *led = EEVEE_lamp_data_get(ob);
- EEVEE_ShadowMapData *evsmd = (EEVEE_ShadowMapData *)led->storage;
+ Lamp *la = (Lamp *)ob->data;
+
+ EEVEE_ShadowCascadeData *evscd = (EEVEE_ShadowCascadeData *)led->storage;
+ EEVEE_ShadowRender *srd = &linfo->shadow_render_data;
+
+ eevee_shadow_cascade_setup(ob, linfo, led);
+
+ srd->clip_near = la->clipsta;
+ srd->clip_far = la->clipend;
+ for (int j = 0; j < la->cascade_count; ++j) {
+ copy_m4_m4(srd->shadowmat[j], evscd->viewprojmat[j]);
+ }
+ DRW_uniformbuffer_update(sldata->shadow_render_ubo, &linfo->shadow_render_data);
+
+ DRW_framebuffer_bind(sldata->shadow_target_fb);
+ DRW_framebuffer_clear(false, true, false, NULL, 1.0);
+
+ /* Render shadow cascades */
+ DRW_draw_pass(psl->shadow_cascade_pass);
+
+ /* TODO: OPTI: Filter all cascade in one/two draw call */
+ for (linfo->current_shadow_cascade = 0;
+ linfo->current_shadow_cascade < la->cascade_count;
+ ++linfo->current_shadow_cascade)
+ {
+ /* 0.01f factor to convert to percentage */
+ float filter_texture_size = la->soft * 0.01f / evscd->radius[linfo->current_shadow_cascade];
+ float filter_pixel_size = ceil(linfo->shadow_size * filter_texture_size);
+
+ /* Copy using a small 3x3 box filter */
+ linfo->filter_size = linfo->shadow_render_data.stored_texel_size * ((filter_pixel_size > 1.0f) ? 1.0f : 0.0f);
+ DRW_framebuffer_texture_layer_attach(sldata->shadow_store_fb, sldata->shadow_cascade_blur, 0, linfo->current_shadow_cascade, 0);
+ DRW_framebuffer_bind(sldata->shadow_store_fb);
+ DRW_draw_pass(psl->shadow_cascade_copy_pass);
+ DRW_framebuffer_texture_detach(sldata->shadow_cascade_blur);
+
+ /* Push it to shadowmap array and blur more */
+
+ /* Adjust constants if concentric samples change. */
+ const float max_filter_size = 7.5f;
+ const float previous_box_filter_size = 3.2f; /* Arbitrary: less banding */
+ const int max_sample = 256;
+
+ if (filter_pixel_size > 2.0f) {
+ linfo->filter_size = linfo->shadow_render_data.stored_texel_size * max_filter_size * previous_box_filter_size;
+ filter_pixel_size = max_ff(0.0f, filter_pixel_size - 3.0f);
+ /* Compute number of concentric samples. Depends directly on filter size. */
+ float pix_size_sqr = filter_pixel_size * filter_pixel_size;
+ srd->shadow_samples_ct = min_ii(max_sample, 4 + 8 * (int)filter_pixel_size + 4 * (int)(pix_size_sqr));
+ }
+ else {
+ linfo->filter_size = 0.0f;
+ srd->shadow_samples_ct = 4;
+ }
+ srd->shadow_inv_samples_ct = 1.0f / (float)srd->shadow_samples_ct;
+ DRW_uniformbuffer_update(sldata->shadow_render_ubo, &linfo->shadow_render_data);
- linfo->layer = i;
- copy_m4_m4(linfo->shadowmat, evsmd->viewprojmat);
- DRW_draw_pass(vedata->psl->shadow_pass);
+ int layer = evscd->layer_id + linfo->current_shadow_cascade;
+ DRW_framebuffer_texture_layer_attach(sldata->shadow_store_fb, sldata->shadow_pool, 0, layer, 0);
+ DRW_framebuffer_bind(sldata->shadow_store_fb);
+ DRW_draw_pass(psl->shadow_cascade_store_pass);
+ }
}
-#endif
- /* Cascaded Shadow Maps */
-// DRW_framebuffer_bind(fbl->shadow_cascade_fb);
-// DRW_framebuffer_clear(false, true, false, NULL, 1.0);
-
-// /* Render each shadow to one layer of the array */
-// for (i = 0; (ob = linfo->shadow_cascade_ref[i]) && (i < MAX_SHADOW_CASCADE); i++) {
-// EEVEE_LampEngineData *led = EEVEE_lamp_data_get(ob);
-// EEVEE_ShadowCascadeData *evscd = (EEVEE_ShadowCascadeData *)led->storage;
-// EEVEE_ShadowRender *srd = &linfo->shadow_render_data;
-
-// srd->layer = i;
-// for (int j = 0; j < MAX_CASCADE_NUM; ++j) {
-// copy_m4_m4(srd->shadowmat[j], evscd->viewprojmat[j]);
-// }
-// DRW_uniformbuffer_update(sldata->shadow_render_ubo, &linfo->shadow_render_data);
-
-// DRW_draw_pass(psl->shadow_cascade_pass);
-// }
+ DRW_framebuffer_texture_detach(sldata->shadow_cascade_target);
+ DRW_stats_group_end();
+
+ DRW_uniformbuffer_update(sldata->light_ubo, &linfo->light_data);
+ DRW_uniformbuffer_update(sldata->shadow_ubo, &linfo->shadow_data); /* Update all data at once */
}
void EEVEE_lights_free(void)
{
DRW_SHADER_FREE_SAFE(e_data.shadow_sh);
- DRW_SHADER_FREE_SAFE(e_data.shadow_store_sh);
+ for (int i = 0; i < SHADOW_METHOD_MAX; ++i) {
+ DRW_SHADER_FREE_SAFE(e_data.shadow_store_cube_sh[i]);
+ DRW_SHADER_FREE_SAFE(e_data.shadow_store_cascade_sh[i]);
+ DRW_SHADER_FREE_SAFE(e_data.shadow_copy_cube_sh[i]);
+ DRW_SHADER_FREE_SAFE(e_data.shadow_copy_cascade_sh[i]);
+ }
} \ No newline at end of file
diff --git a/source/blender/draw/engines/eevee/eevee_lut.h b/source/blender/draw/engines/eevee/eevee_lut.h
index 711defee35d..d706110351e 100644
--- a/source/blender/draw/engines/eevee/eevee_lut.h
+++ b/source/blender/draw/engines/eevee/eevee_lut.h
@@ -25,7 +25,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file eeveee_lut.h
+/** \file eevee_lut.h
* \ingroup gpu
*/
@@ -3345,6 +3345,11017 @@ static float bsdf_split_sum_ggx[64 * 64 * 2] = {
0.626953f, 0.023544f, 0.616699f, 0.022186f, 0.605957f, 0.020920f, 0.594727f, 0.019730f
};
+static float btdf_split_sum_ggx[32][64 * 64] = {
+ {
+ 0.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f,
+ 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.999512f, 1.000000f, 0.999512f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.999512f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.999512f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 0.999512f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 0.999512f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 0.999512f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.039917f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.999512f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 0.999512f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 0.999512f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f,
+ 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 0.999512f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 0.999512f, 1.000000f, 1.000000f,
+ 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.999512f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.999512f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 0.999512f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 0.999512f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 0.999512f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ },
+ {
+ 0.000122f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000122f, 0.004147f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f,
+ 0.897949f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f,
+ 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000732f, 0.996094f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 1.000000f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.002439f,
+ 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 1.000000f, 1.000000f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000366f, 0.078308f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f,
+ 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.001098f, 0.992188f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 0.999512f,
+ 1.000000f, 1.000000f, 0.999512f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.005001f, 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 1.000000f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 0.999512f,
+ 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 0.999512f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000732f, 0.902344f, 0.999023f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000122f, 0.000122f, 0.000122f, 0.002928f, 0.997070f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 1.000000f, 0.999512f, 0.999512f, 1.000000f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000732f, 0.301758f, 0.999023f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 0.999512f, 1.000000f,
+ 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.002562f, 0.996094f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000732f, 0.433594f, 0.999023f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000244f, 0.004021f, 0.996582f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.001098f, 0.949219f, 0.999023f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000610f,
+ 0.012039f, 0.998047f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.002073f, 0.993652f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000854f, 0.725586f,
+ 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000610f, 0.011856f, 0.998047f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000243f, 0.002905f, 0.995117f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.001098f, 0.978027f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000732f, 0.314941f, 0.999023f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000731f, 0.017670f, 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000366f, 0.005852f, 0.997559f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.003050f,
+ 0.996094f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.001957f, 0.993652f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.001586f, 0.990234f, 0.999023f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.001220f, 0.986816f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.001220f, 0.984375f, 0.999023f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000120f, 0.000122f, 0.000122f, 0.000122f,
+ 0.001098f, 0.985352f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.001220f, 0.989258f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.001341f, 0.993652f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000122f, 0.000122f, 0.000122f, 0.001586f, 0.996094f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.002802f, 0.997559f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000117f, 0.000122f, 0.000122f,
+ 0.000243f, 0.006088f, 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000366f, 0.026321f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000732f, 0.892578f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000975f, 0.993652f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.002317f, 0.998535f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f,
+ 0.000122f, 0.017944f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000731f, 0.983887f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000119f, 0.000122f, 0.000122f, 0.001653f, 0.998535f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000122f, 0.000122f, 0.000122f, 0.026108f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000732f, 0.995605f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f,
+ 0.003777f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000365f, 0.991211f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.002195f, 0.999023f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000122f, 0.000364f, 0.993164f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.002672f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000360f, 0.998047f,
+ 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000122f, 0.000122f, 0.017075f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000731f, 0.999512f, 0.999512f, 0.999512f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f,
+ 0.997070f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.006874f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000480f, 0.999512f, 0.999512f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000122f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.996582f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000067f, 0.005440f, 0.999512f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000365f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000121f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.995605f, 0.995117f,
+ 0.995117f, 0.995605f, 0.995117f, 0.995117f,
+ },
+ {
+ 0.003168f, 0.995605f, 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f,
+ 1.000000f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f,
+ 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.999512f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000976f, 0.053314f, 0.994629f, 0.998535f, 0.999023f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000122f, 0.000122f, 0.000732f, 0.003660f,
+ 0.653809f, 0.995117f, 0.998047f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000488f, 0.001463f, 0.010452f, 0.947266f, 0.995605f, 0.998535f, 0.999023f, 0.999023f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000365f, 0.000853f, 0.002928f, 0.037750f,
+ 0.980957f, 0.996582f, 0.998535f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000243f, 0.000610f, 0.001342f, 0.006100f, 0.314453f, 0.989746f, 0.997070f, 0.998535f, 0.999023f, 0.999023f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000487f, 0.001091f, 0.002317f, 0.015839f, 0.910645f,
+ 0.993652f, 0.997559f, 0.998535f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f,
+ 0.999512f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000366f, 0.000732f, 0.001463f, 0.005302f, 0.068909f, 0.977539f, 0.995605f, 0.998047f, 0.999023f, 0.999023f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000244f, 0.000732f, 0.001098f, 0.002560f, 0.011551f, 0.658691f, 0.989746f,
+ 0.997070f, 0.998535f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000366f,
+ 0.000732f, 0.001585f, 0.004868f, 0.041077f, 0.958984f, 0.994141f, 0.997559f, 0.998535f, 0.999023f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000244f, 0.000732f, 0.001215f, 0.002802f, 0.010834f, 0.441895f, 0.987305f, 0.996094f,
+ 0.998535f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000242f, 0.000488f, 0.000850f,
+ 0.001586f, 0.004753f, 0.039154f, 0.948242f, 0.993652f, 0.997559f, 0.998535f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000366f, 0.000732f, 0.001220f, 0.003159f, 0.012032f, 0.480713f, 0.985840f, 0.996094f, 0.998047f,
+ 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000240f, 0.000731f, 0.001097f, 0.001950f,
+ 0.005966f, 0.054413f, 0.957520f, 0.994141f, 0.997070f, 0.998535f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000486f, 0.000732f, 0.001534f, 0.003536f, 0.016937f, 0.726562f, 0.988281f, 0.996582f, 0.998047f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000365f, 0.000732f, 0.001098f, 0.002192f, 0.008278f,
+ 0.125244f, 0.974121f, 0.994629f, 0.997559f, 0.998535f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000365f, 0.000731f, 0.000947f, 0.001828f, 0.005314f, 0.031677f, 0.916016f, 0.991699f, 0.997070f, 0.998535f, 0.999023f, 0.999023f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000488f, 0.000732f, 0.001339f, 0.003294f, 0.014389f, 0.562012f,
+ 0.985840f, 0.996094f, 0.998047f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000487f,
+ 0.000732f, 0.001098f, 0.002310f, 0.008163f, 0.123779f, 0.973633f, 0.994629f, 0.997559f, 0.998535f, 0.999023f, 0.999023f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000120f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000365f, 0.000732f, 0.001097f, 0.002071f, 0.005669f, 0.041199f, 0.937988f, 0.992676f,
+ 0.997070f, 0.998535f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000118f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000366f, 0.000728f, 0.000732f,
+ 0.001585f, 0.004143f, 0.020813f, 0.813965f, 0.989746f, 0.996582f, 0.998535f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000116f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000488f, 0.000732f, 0.001220f, 0.003292f, 0.012581f, 0.446533f, 0.984863f, 0.996094f, 0.998047f,
+ 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000471f, 0.000732f, 0.001220f, 0.002796f,
+ 0.009338f, 0.161865f, 0.977051f, 0.995117f, 0.997559f, 0.998535f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000365f, 0.000732f, 0.001098f, 0.002285f, 0.006870f, 0.074097f, 0.965820f, 0.994141f, 0.997559f, 0.998535f, 0.999023f,
+ 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000366f, 0.000731f, 0.001086f, 0.001945f, 0.005238f, 0.043732f,
+ 0.947754f, 0.993652f, 0.997559f, 0.998535f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000120f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000366f,
+ 0.000730f, 0.000893f, 0.001826f, 0.004871f, 0.030411f, 0.922852f, 0.992188f, 0.997559f, 0.998535f, 0.999023f, 0.999023f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000120f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000243f, 0.000609f, 0.000732f, 0.001407f, 0.004375f, 0.023758f, 0.892090f, 0.992188f,
+ 0.997070f, 0.998535f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000605f, 0.000732f,
+ 0.001579f, 0.003941f, 0.020767f, 0.862793f, 0.991699f, 0.997559f, 0.998535f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000238f, 0.000483f, 0.000732f, 0.001449f, 0.003654f, 0.018951f, 0.847656f, 0.991699f, 0.997559f, 0.998535f,
+ 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000233f, 0.000485f, 0.000732f, 0.001308f, 0.003353f,
+ 0.018997f, 0.855469f, 0.991699f, 0.997559f, 0.998535f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000118f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000487f, 0.000732f, 0.001292f, 0.003649f, 0.019791f, 0.881836f, 0.992188f, 0.997559f, 0.998535f, 0.999023f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000120f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000432f, 0.000732f, 0.001220f, 0.003635f, 0.021912f, 0.916992f,
+ 0.993652f, 0.997559f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000116f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000487f,
+ 0.000732f, 0.001245f, 0.004002f, 0.028107f, 0.946289f, 0.994141f, 0.998047f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000085f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000475f, 0.000732f, 0.001611f, 0.004581f, 0.040466f, 0.966309f, 0.995605f, 0.998535f,
+ 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000487f, 0.000732f, 0.001703f,
+ 0.005589f, 0.073486f, 0.979980f, 0.996094f, 0.998535f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000475f, 0.000732f, 0.001706f, 0.006809f, 0.198730f, 0.987305f, 0.997559f, 0.998535f, 0.999023f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000121f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000488f, 0.000732f, 0.002071f, 0.009590f, 0.647949f,
+ 0.992188f, 0.997559f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000120f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000710f, 0.001093f, 0.002541f, 0.015533f, 0.922852f, 0.995117f, 0.998535f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000116f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000242f, 0.000728f, 0.001218f, 0.003387f, 0.034454f, 0.975586f, 0.996582f, 0.998535f,
+ 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000365f, 0.000731f, 0.001219f,
+ 0.004959f, 0.161865f, 0.989746f, 0.998047f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000366f, 0.000731f, 0.001767f, 0.009331f, 0.849121f, 0.994629f, 0.998535f, 0.999023f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000121f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000487f, 0.000732f, 0.002644f, 0.024231f, 0.977051f,
+ 0.997559f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000685f, 0.001217f, 0.004139f, 0.195435f, 0.992676f, 0.998535f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000121f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000362f, 0.000731f, 0.001570f, 0.010086f, 0.944824f, 0.997070f, 0.999023f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000365f, 0.000745f, 0.002781f,
+ 0.051758f, 0.990723f, 0.998535f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000599f, 0.001176f, 0.006641f, 0.899414f, 0.997070f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000120f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000731f, 0.002066f, 0.032654f, 0.991211f, 0.998535f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000119f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000448f,
+ 0.001088f, 0.005440f, 0.918457f, 0.997070f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000119f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000725f, 0.001822f, 0.038452f, 0.994141f, 0.999023f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000120f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000329f, 0.000848f, 0.005672f, 0.972168f,
+ 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000120f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000581f, 0.001982f, 0.155273f, 0.997070f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000120f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000330f, 0.000848f, 0.009247f, 0.992676f, 0.999023f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000120f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000589f, 0.002625f,
+ 0.958496f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000121f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.001199f, 0.083374f, 0.998047f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000716f, 0.007244f, 0.996582f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000121f, 0.000122f, 0.000122f, 0.000122f,
+ 0.002277f, 0.991211f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000070f, 0.000121f, 0.000122f, 0.000122f, 0.000854f, 0.950684f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000111f, 0.000121f, 0.000122f, 0.000475f, 0.067139f, 0.999512f, 0.999023f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000118f, 0.000122f,
+ 0.000002f, 0.005859f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000120f, 0.000014f, 0.001376f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000121f, 0.000572f, 0.998535f, 0.998535f,
+ 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000077f, 0.000002f, 0.997070f, 0.997070f, 0.997070f, 0.997070f, 0.997070f, 0.997070f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000103f, 0.992188f, 0.991699f, 0.991699f, 0.992188f, 0.992188f, 0.991699f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.940430f, 0.940430f,
+ 0.940918f, 0.940918f, 0.940430f, 0.940430f,
+ },
+ {
+ 0.014023f, 0.979492f, 0.994629f, 0.997070f, 0.998047f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f,
+ 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000488f, 0.004757f, 0.163330f, 0.975098f, 0.993164f, 0.996582f, 0.997559f, 0.998535f,
+ 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000610f, 0.002928f, 0.017166f,
+ 0.563965f, 0.978027f, 0.992676f, 0.996094f, 0.997559f, 0.998047f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000364f, 0.000732f, 0.002192f, 0.006573f, 0.044952f, 0.830566f, 0.980957f, 0.992676f, 0.996094f, 0.997070f, 0.998047f,
+ 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000366f, 0.000854f, 0.001586f, 0.004253f, 0.014313f, 0.130371f,
+ 0.919922f, 0.984375f, 0.993652f, 0.996094f, 0.997070f, 0.998047f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000488f,
+ 0.000854f, 0.001342f, 0.003025f, 0.007305f, 0.028870f, 0.407715f, 0.954590f, 0.987305f, 0.993652f, 0.996094f, 0.997070f, 0.998047f,
+ 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000609f, 0.000842f, 0.000976f, 0.002193f, 0.005112f, 0.012505f, 0.066589f, 0.768066f,
+ 0.970703f, 0.989746f, 0.994629f, 0.996582f, 0.997070f, 0.998047f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000244f, 0.000599f, 0.000609f, 0.000976f,
+ 0.001829f, 0.003046f, 0.007256f, 0.023499f, 0.194946f, 0.908691f, 0.979980f, 0.991699f, 0.995117f, 0.996582f, 0.997559f, 0.998535f,
+ 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000244f, 0.000488f, 0.000609f, 0.000976f, 0.001583f, 0.002647f, 0.004726f, 0.012169f, 0.050537f, 0.568359f, 0.954102f,
+ 0.985840f, 0.993164f, 0.995605f, 0.997070f, 0.998047f, 0.998047f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000244f, 0.000488f, 0.000610f, 0.000975f, 0.001211f, 0.001946f,
+ 0.003532f, 0.007793f, 0.022446f, 0.139648f, 0.856445f, 0.974121f, 0.989746f, 0.994141f, 0.996094f, 0.997559f, 0.998047f, 0.998535f,
+ 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 1.000000f, 1.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000241f,
+ 0.000310f, 0.000609f, 0.000807f, 0.001098f, 0.001822f, 0.002794f, 0.005699f, 0.012878f, 0.047821f, 0.469238f, 0.941406f, 0.982910f,
+ 0.991699f, 0.995117f, 0.996582f, 0.997559f, 0.998047f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000244f, 0.000244f, 0.000609f, 0.000732f, 0.001098f, 0.001461f, 0.002274f, 0.004025f,
+ 0.008247f, 0.023254f, 0.135254f, 0.833984f, 0.969727f, 0.987793f, 0.993652f, 0.995605f, 0.997070f, 0.998047f, 0.998535f, 0.998535f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000207f, 0.000244f, 0.000609f,
+ 0.000610f, 0.001096f, 0.001098f, 0.002071f, 0.003370f, 0.006172f, 0.014442f, 0.052795f, 0.486572f, 0.940430f, 0.981934f, 0.991699f,
+ 0.994629f, 0.996582f, 0.997559f, 0.998047f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 1.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000244f, 0.000485f, 0.000610f, 0.001080f, 0.001098f, 0.001742f, 0.002668f, 0.004692f, 0.010147f,
+ 0.028076f, 0.168701f, 0.854004f, 0.970703f, 0.988770f, 0.993652f, 0.996094f, 0.997070f, 0.998047f, 0.998047f, 0.998535f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000244f, 0.000487f, 0.000610f, 0.000731f,
+ 0.001098f, 0.001413f, 0.002411f, 0.003895f, 0.007072f, 0.017242f, 0.069580f, 0.605957f, 0.948730f, 0.983398f, 0.992188f, 0.995117f,
+ 0.996582f, 0.997559f, 0.998047f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000244f, 0.000244f, 0.000609f, 0.000610f, 0.001094f, 0.001337f, 0.001828f, 0.003275f, 0.005814f, 0.012054f, 0.036987f,
+ 0.270752f, 0.899414f, 0.975586f, 0.989746f, 0.993652f, 0.996094f, 0.997070f, 0.998047f, 0.998535f, 0.998535f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 1.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000241f, 0.000365f, 0.000597f, 0.000610f, 0.000970f, 0.001098f,
+ 0.001815f, 0.002771f, 0.005009f, 0.008888f, 0.023804f, 0.115845f, 0.775879f, 0.962891f, 0.986328f, 0.993164f, 0.995605f, 0.997070f,
+ 0.997559f, 0.998047f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000244f, 0.000536f, 0.000731f, 0.000937f, 0.001203f, 0.001581f, 0.002186f, 0.004005f, 0.007061f, 0.016830f, 0.061218f, 0.522949f,
+ 0.940430f, 0.981934f, 0.991211f, 0.994629f, 0.996582f, 0.997559f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f,
+ 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000363f, 0.000487f, 0.000731f, 0.000732f, 0.001097f, 0.001339f, 0.002071f,
+ 0.003498f, 0.005947f, 0.012390f, 0.037964f, 0.268799f, 0.896973f, 0.975586f, 0.989258f, 0.994141f, 0.996094f, 0.997070f, 0.998047f,
+ 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 1.000000f, 1.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000244f, 0.000366f,
+ 0.000609f, 0.000610f, 0.001094f, 0.001215f, 0.002056f, 0.003183f, 0.004742f, 0.009880f, 0.026337f, 0.139526f, 0.813477f, 0.966309f,
+ 0.986816f, 0.993164f, 0.996094f, 0.997070f, 0.997559f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000163f, 0.000363f, 0.000600f, 0.000731f, 0.001088f, 0.001216f, 0.001616f, 0.002640f, 0.004402f,
+ 0.008156f, 0.019669f, 0.083191f, 0.664062f, 0.953125f, 0.984375f, 0.992188f, 0.995117f, 0.997070f, 0.998047f, 0.998535f, 0.998535f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000243f, 0.000244f, 0.000523f, 0.000731f,
+ 0.000732f, 0.001097f, 0.001690f, 0.002169f, 0.003998f, 0.006939f, 0.015808f, 0.055634f, 0.471191f, 0.935059f, 0.980957f, 0.991211f,
+ 0.995117f, 0.996582f, 0.997559f, 0.998047f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000336f, 0.000486f, 0.000731f, 0.000732f, 0.001097f, 0.001558f, 0.002069f, 0.003525f, 0.006058f, 0.013062f,
+ 0.040894f, 0.306396f, 0.910156f, 0.978027f, 0.990234f, 0.994141f, 0.996582f, 0.997559f, 0.998535f, 0.998535f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000113f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000360f, 0.000515f, 0.000731f, 0.000731f, 0.001094f,
+ 0.001219f, 0.002148f, 0.003159f, 0.005577f, 0.011360f, 0.031952f, 0.203979f, 0.874512f, 0.973633f, 0.989258f, 0.994141f, 0.996582f,
+ 0.997559f, 0.998047f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000120f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000325f, 0.000366f, 0.000731f, 0.000731f, 0.001093f, 0.001219f, 0.001820f, 0.002916f, 0.005291f, 0.009758f, 0.026352f, 0.145020f,
+ 0.832520f, 0.969238f, 0.988281f, 0.993652f, 0.996094f, 0.997559f, 0.998047f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000121f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000244f, 0.000440f, 0.000605f, 0.000731f, 0.001086f, 0.001097f, 0.001646f,
+ 0.002670f, 0.004230f, 0.008835f, 0.022415f, 0.112183f, 0.786133f, 0.966309f, 0.987793f, 0.993652f, 0.996094f, 0.997559f, 0.998047f,
+ 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000120f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000272f, 0.000358f,
+ 0.000565f, 0.000731f, 0.000790f, 0.001210f, 0.001573f, 0.002434f, 0.004360f, 0.008102f, 0.020660f, 0.092896f, 0.741699f, 0.962891f,
+ 0.987305f, 0.993164f, 0.996094f, 0.997070f, 0.998047f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000364f, 0.000723f, 0.000731f, 0.000731f, 0.001216f, 0.001698f, 0.002510f, 0.003998f,
+ 0.007484f, 0.018463f, 0.082336f, 0.709961f, 0.961426f, 0.986816f, 0.993652f, 0.996094f, 0.997559f, 0.998535f, 0.998535f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000242f, 0.000362f, 0.000704f, 0.000730f,
+ 0.000845f, 0.001096f, 0.001513f, 0.002302f, 0.003941f, 0.007168f, 0.017746f, 0.076782f, 0.693848f, 0.961426f, 0.987305f, 0.993652f,
+ 0.996094f, 0.997559f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000120f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000364f, 0.000579f, 0.000728f, 0.000731f, 0.001096f, 0.001491f, 0.002069f, 0.003899f, 0.007195f, 0.017059f,
+ 0.075439f, 0.701172f, 0.962402f, 0.987793f, 0.993652f, 0.996094f, 0.997559f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000119f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000357f, 0.000482f, 0.000730f, 0.000731f, 0.001094f,
+ 0.001334f, 0.002230f, 0.003708f, 0.007217f, 0.017410f, 0.079163f, 0.730469f, 0.965820f, 0.988281f, 0.994141f, 0.996582f, 0.998047f,
+ 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000112f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000238f,
+ 0.000243f, 0.000365f, 0.000729f, 0.000731f, 0.001095f, 0.001330f, 0.002066f, 0.003637f, 0.007118f, 0.018112f, 0.087708f, 0.775391f,
+ 0.969238f, 0.989258f, 0.994629f, 0.997070f, 0.997559f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000073f, 0.000121f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000323f, 0.000390f, 0.000729f, 0.000731f, 0.001094f, 0.001332f, 0.002275f,
+ 0.003782f, 0.007252f, 0.019379f, 0.105042f, 0.827637f, 0.973145f, 0.990723f, 0.994629f, 0.997070f, 0.998047f, 0.998535f, 0.999023f,
+ 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000114f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000240f, 0.000369f,
+ 0.000729f, 0.000731f, 0.001093f, 0.001330f, 0.002209f, 0.003937f, 0.007896f, 0.021805f, 0.137207f, 0.876953f, 0.979004f, 0.991699f,
+ 0.995605f, 0.997559f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000119f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000272f, 0.000479f, 0.000727f, 0.000731f, 0.001085f, 0.001331f, 0.002291f, 0.004105f, 0.008446f,
+ 0.025024f, 0.202271f, 0.916504f, 0.982910f, 0.993164f, 0.996094f, 0.997559f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000120f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000360f, 0.000469f, 0.000681f, 0.000731f,
+ 0.001092f, 0.001331f, 0.002184f, 0.004227f, 0.009521f, 0.030899f, 0.335205f, 0.945312f, 0.986816f, 0.993652f, 0.996582f, 0.998535f,
+ 0.998535f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000116f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000241f, 0.000429f, 0.000726f, 0.000731f, 0.001091f, 0.001649f, 0.002464f, 0.004810f, 0.010895f, 0.041931f, 0.563477f,
+ 0.963867f, 0.989746f, 0.995117f, 0.997070f, 0.998535f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000101f, 0.000120f,
+ 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000288f, 0.000481f, 0.000720f, 0.000731f, 0.001093f, 0.001571f,
+ 0.002735f, 0.005405f, 0.013199f, 0.064880f, 0.786133f, 0.976562f, 0.992188f, 0.995605f, 0.997559f, 0.998535f, 0.999023f, 0.999023f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000112f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000240f,
+ 0.000481f, 0.000727f, 0.000731f, 0.001093f, 0.001655f, 0.003132f, 0.005909f, 0.017181f, 0.123169f, 0.904297f, 0.984375f, 0.993652f,
+ 0.996582f, 0.998047f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000110f, 0.000120f, 0.000121f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000264f, 0.000392f, 0.000727f, 0.000835f, 0.001196f, 0.001765f, 0.003252f, 0.007343f,
+ 0.024521f, 0.304199f, 0.954102f, 0.989258f, 0.995605f, 0.997559f, 0.998535f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000034f, 0.000119f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000235f, 0.000375f, 0.000728f,
+ 0.000822f, 0.001095f, 0.002024f, 0.003952f, 0.009193f, 0.040894f, 0.694824f, 0.975586f, 0.992676f, 0.996582f, 0.998047f, 0.999023f,
+ 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000112f, 0.000121f, 0.000121f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000307f, 0.000475f, 0.000728f, 0.000943f, 0.001216f, 0.002283f, 0.004829f, 0.013008f, 0.092224f, 0.908203f,
+ 0.986328f, 0.995117f, 0.997559f, 0.998535f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000073f, 0.000118f, 0.000121f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000240f, 0.000576f, 0.000728f, 0.001073f, 0.001569f,
+ 0.002668f, 0.005947f, 0.020889f, 0.331543f, 0.965820f, 0.992188f, 0.996582f, 0.998047f, 0.998535f, 0.999023f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000100f, 0.000120f, 0.000121f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000362f, 0.000630f, 0.000729f, 0.001087f, 0.001567f, 0.003241f, 0.008240f, 0.043793f, 0.824219f, 0.984375f, 0.994629f, 0.997559f,
+ 0.998535f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000075f, 0.000119f, 0.000121f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000363f, 0.000689f, 0.000730f, 0.001185f, 0.002022f, 0.004108f, 0.013702f,
+ 0.161011f, 0.957031f, 0.991699f, 0.996582f, 0.998047f, 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000003f, 0.000105f, 0.000120f, 0.000121f, 0.000121f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000156f, 0.000372f, 0.000689f,
+ 0.000730f, 0.001198f, 0.002651f, 0.006214f, 0.028854f, 0.750000f, 0.984375f, 0.995605f, 0.998047f, 0.998535f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000102f,
+ 0.000118f, 0.000120f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000472f, 0.000724f, 0.000966f, 0.001658f, 0.003397f, 0.010582f, 0.116028f, 0.959473f, 0.993164f,
+ 0.997559f, 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000111f, 0.000119f, 0.000121f, 0.000121f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000130f, 0.000479f, 0.000726f, 0.001163f, 0.002157f,
+ 0.004829f, 0.024338f, 0.776855f, 0.987793f, 0.996582f, 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000097f, 0.000117f,
+ 0.000120f, 0.000121f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000219f, 0.000580f, 0.000728f, 0.001203f, 0.002872f, 0.009109f, 0.130371f, 0.972168f, 0.995117f, 0.998047f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000112f, 0.000118f, 0.000121f, 0.000121f, 0.000121f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000333f, 0.000681f, 0.000940f, 0.001629f, 0.004120f, 0.025467f, 0.890625f,
+ 0.991699f, 0.997559f, 0.999512f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000083f, 0.000116f, 0.000120f,
+ 0.000121f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000353f, 0.000722f,
+ 0.000961f, 0.002403f, 0.009354f, 0.295166f, 0.985840f, 0.997070f, 0.999512f, 0.999023f, 0.999512f, 0.999023f, 0.999512f, 0.999512f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000105f, 0.000118f, 0.000120f, 0.000121f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000130f, 0.000427f, 0.000605f, 0.001345f, 0.004620f, 0.041229f, 0.966797f, 0.996094f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000074f, 0.000114f, 0.000119f, 0.000121f,
+ 0.000121f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000089f, 0.000562f, 0.000942f, 0.002352f, 0.012459f,
+ 0.854004f, 0.994141f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000103f, 0.000117f, 0.000120f, 0.000121f, 0.000121f, 0.000121f, 0.000122f, 0.000122f, 0.000007f, 0.000002f,
+ 0.000231f, 0.000596f, 0.001180f, 0.005474f, 0.211426f, 0.991211f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000111f, 0.000118f, 0.000120f, 0.000121f,
+ 0.000121f, 0.000122f, 0.000029f, 0.000004f, 0.000001f, 0.000348f, 0.000896f, 0.002764f, 0.032562f, 0.984375f, 0.998535f, 0.998535f,
+ 0.999023f, 0.998535f, 0.999023f, 0.999023f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000089f, 0.000116f, 0.000119f, 0.000121f, 0.000121f, 0.000121f, 0.000013f, 0.000003f, 0.000075f, 0.000586f, 0.001508f,
+ 0.010292f, 0.963379f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000006f, 0.000107f, 0.000118f, 0.000120f, 0.000121f, 0.000116f,
+ 0.000008f, 0.000002f, 0.000233f, 0.000857f, 0.004566f, 0.834961f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000083f, 0.000114f, 0.000119f, 0.000120f, 0.000060f, 0.000005f, 0.000001f, 0.000557f, 0.002064f, 0.182373f, 0.997559f, 0.997559f,
+ 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000103f, 0.000117f, 0.000120f, 0.000024f, 0.000003f, 0.000168f,
+ 0.000968f, 0.026428f, 0.996582f, 0.997070f, 0.996582f, 0.996582f, 0.996582f, 0.997070f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000047f,
+ 0.000110f, 0.000118f, 0.000017f, 0.000002f, 0.000513f, 0.006870f, 0.995605f, 0.995605f, 0.995117f, 0.995117f, 0.995117f, 0.995117f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000096f, 0.000115f, 0.000011f, 0.000042f, 0.001919f, 0.992676f, 0.992676f,
+ 0.992676f, 0.992676f, 0.992676f, 0.992676f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000044f, 0.000109f,
+ 0.000008f, 0.000314f, 0.985840f, 0.985840f, 0.985840f, 0.985840f, 0.986328f, 0.985840f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000089f, 0.000060f, 0.964355f, 0.964355f, 0.963867f, 0.963867f, 0.963379f, 0.964355f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000022f, 0.818848f, 0.819824f,
+ 0.819336f, 0.819824f, 0.819824f, 0.819824f,
+ },
+ {
+ 0.038849f, 0.941406f, 0.984375f, 0.992188f, 0.994141f, 0.996094f, 0.996582f, 0.997070f, 0.998047f, 0.998047f, 0.998047f, 0.998535f,
+ 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 1.000000f, 1.000000f, 1.000000f, 0.999512f, 0.001582f, 0.014984f, 0.262451f, 0.930664f, 0.979980f, 0.989258f, 0.993164f, 0.995117f,
+ 0.996094f, 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 0.999512f, 0.000244f, 0.002317f, 0.009003f, 0.047180f,
+ 0.524902f, 0.936523f, 0.978027f, 0.988281f, 0.992188f, 0.994629f, 0.995605f, 0.996582f, 0.997070f, 0.997559f, 0.998047f, 0.998047f,
+ 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 1.000000f,
+ 0.000122f, 0.001098f, 0.002560f, 0.006824f, 0.020493f, 0.108826f, 0.715820f, 0.946289f, 0.978516f, 0.988281f, 0.992188f, 0.994141f,
+ 0.995605f, 0.996582f, 0.997070f, 0.997559f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000607f, 0.001098f, 0.002310f, 0.005646f, 0.012825f, 0.040131f, 0.231201f,
+ 0.825195f, 0.954590f, 0.979980f, 0.988281f, 0.992188f, 0.994141f, 0.995117f, 0.996582f, 0.996582f, 0.997559f, 0.998047f, 0.998047f,
+ 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 0.000000f, 0.000244f, 0.000609f, 0.001341f,
+ 0.002310f, 0.004208f, 0.008865f, 0.021591f, 0.074585f, 0.439209f, 0.885742f, 0.962402f, 0.981934f, 0.989258f, 0.992676f, 0.994141f,
+ 0.995605f, 0.996582f, 0.997070f, 0.997070f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 0.999512f,
+ 0.000000f, 0.000122f, 0.000483f, 0.000610f, 0.001460f, 0.002192f, 0.003994f, 0.007030f, 0.013847f, 0.036316f, 0.146362f, 0.661621f,
+ 0.921875f, 0.969238f, 0.983398f, 0.989746f, 0.993164f, 0.994141f, 0.995605f, 0.996582f, 0.996582f, 0.997559f, 0.998047f, 0.998047f,
+ 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 1.000000f, 0.000000f, 0.000000f, 0.000243f, 0.000604f, 0.000730f, 0.001307f, 0.001944f, 0.003017f,
+ 0.004997f, 0.009834f, 0.021606f, 0.063416f, 0.295410f, 0.808594f, 0.944336f, 0.974609f, 0.985352f, 0.990234f, 0.993652f, 0.995117f,
+ 0.995605f, 0.996582f, 0.997070f, 0.997559f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000119f, 0.000366f,
+ 0.000495f, 0.000731f, 0.001217f, 0.001823f, 0.002796f, 0.004398f, 0.007656f, 0.015366f, 0.035828f, 0.119263f, 0.531738f, 0.886230f,
+ 0.958496f, 0.979004f, 0.986816f, 0.991699f, 0.993652f, 0.995117f, 0.996094f, 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.998535f,
+ 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000244f, 0.000366f, 0.000607f, 0.000731f, 0.001211f, 0.001650f, 0.002441f, 0.003975f, 0.006207f,
+ 0.011536f, 0.023315f, 0.060822f, 0.242798f, 0.744141f, 0.927734f, 0.969238f, 0.982422f, 0.989258f, 0.992188f, 0.994141f, 0.995605f,
+ 0.996094f, 0.996582f, 0.997559f, 0.997559f, 0.998047f, 0.998535f, 0.998535f, 0.999023f, 0.998535f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000211f, 0.000455f, 0.000486f, 0.000853f,
+ 0.001081f, 0.001810f, 0.002426f, 0.003759f, 0.005501f, 0.009094f, 0.016876f, 0.037109f, 0.114075f, 0.475586f, 0.862305f, 0.951172f,
+ 0.975586f, 0.985840f, 0.990234f, 0.992676f, 0.995117f, 0.995605f, 0.996582f, 0.997070f, 0.997559f, 0.998047f, 0.998047f, 0.998535f,
+ 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000364f, 0.000366f, 0.000464f, 0.000731f, 0.001093f, 0.001577f, 0.002235f, 0.002798f, 0.004841f, 0.007637f, 0.013008f,
+ 0.025635f, 0.063965f, 0.238403f, 0.720215f, 0.919434f, 0.965820f, 0.981445f, 0.987793f, 0.991211f, 0.993652f, 0.995117f, 0.996094f,
+ 0.996582f, 0.997070f, 0.997559f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000238f, 0.000609f, 0.000712f, 0.000974f, 0.000976f, 0.001507f,
+ 0.002031f, 0.002680f, 0.004066f, 0.006294f, 0.010284f, 0.018326f, 0.040924f, 0.124146f, 0.485596f, 0.859375f, 0.949707f, 0.975586f,
+ 0.984375f, 0.989746f, 0.992676f, 0.994629f, 0.995605f, 0.996582f, 0.997070f, 0.997070f, 0.998047f, 0.998047f, 0.998535f, 0.998535f,
+ 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000113f, 0.000487f,
+ 0.000488f, 0.000610f, 0.000961f, 0.000976f, 0.001337f, 0.001705f, 0.002663f, 0.003521f, 0.005417f, 0.008408f, 0.014809f, 0.028793f,
+ 0.073120f, 0.270996f, 0.741699f, 0.922363f, 0.965332f, 0.980957f, 0.987793f, 0.991699f, 0.993652f, 0.995117f, 0.996094f, 0.997070f,
+ 0.997070f, 0.998047f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000122f, 0.000244f, 0.000224f, 0.000486f, 0.000609f, 0.000610f, 0.000973f, 0.000975f, 0.001306f, 0.001703f, 0.002350f,
+ 0.003239f, 0.004848f, 0.007122f, 0.011955f, 0.021820f, 0.048859f, 0.152710f, 0.554199f, 0.875977f, 0.953125f, 0.976562f, 0.985352f,
+ 0.990234f, 0.993164f, 0.994629f, 0.995605f, 0.996582f, 0.997070f, 0.997559f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000234f, 0.000244f, 0.000485f, 0.000488f, 0.000610f,
+ 0.000969f, 0.000975f, 0.001335f, 0.001693f, 0.001991f, 0.002811f, 0.004097f, 0.006397f, 0.009903f, 0.017303f, 0.035034f, 0.094421f,
+ 0.354736f, 0.795898f, 0.933594f, 0.969238f, 0.981934f, 0.988281f, 0.991699f, 0.993652f, 0.995117f, 0.996094f, 0.997070f, 0.997559f,
+ 0.998047f, 0.998047f, 0.998047f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000244f, 0.000244f, 0.000480f, 0.000608f, 0.000488f, 0.000922f, 0.000975f, 0.000976f, 0.001339f, 0.001827f, 0.002674f, 0.003891f,
+ 0.005688f, 0.008324f, 0.014320f, 0.026917f, 0.064392f, 0.216431f, 0.668945f, 0.904785f, 0.959961f, 0.978516f, 0.986816f, 0.990723f,
+ 0.993652f, 0.994141f, 0.996094f, 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000188f, 0.000220f, 0.000480f, 0.000608f, 0.000609f, 0.000876f, 0.000975f,
+ 0.000976f, 0.001454f, 0.002068f, 0.002649f, 0.003481f, 0.004757f, 0.007801f, 0.012230f, 0.021698f, 0.046814f, 0.138306f, 0.506348f,
+ 0.859375f, 0.947754f, 0.974121f, 0.984375f, 0.989746f, 0.992188f, 0.994141f, 0.995605f, 0.996582f, 0.997070f, 0.997559f, 0.998047f,
+ 0.998047f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000244f,
+ 0.000446f, 0.000487f, 0.000609f, 0.000731f, 0.000973f, 0.000975f, 0.001310f, 0.001823f, 0.002304f, 0.002869f, 0.004890f, 0.006813f,
+ 0.010475f, 0.017731f, 0.036163f, 0.095337f, 0.353516f, 0.792480f, 0.932129f, 0.968262f, 0.982422f, 0.988770f, 0.992188f, 0.993652f,
+ 0.995605f, 0.996094f, 0.997070f, 0.997559f, 0.998047f, 0.998047f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000243f, 0.000241f, 0.000362f, 0.000487f, 0.000609f, 0.000609f, 0.000973f, 0.001213f, 0.001419f,
+ 0.001807f, 0.002068f, 0.002794f, 0.004070f, 0.005917f, 0.009140f, 0.015129f, 0.029053f, 0.070068f, 0.242554f, 0.700684f, 0.911621f,
+ 0.961914f, 0.979492f, 0.987305f, 0.991211f, 0.993164f, 0.995117f, 0.995605f, 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.998535f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000243f, 0.000243f, 0.000483f, 0.000603f,
+ 0.000609f, 0.000730f, 0.001076f, 0.000975f, 0.001327f, 0.001598f, 0.002056f, 0.002848f, 0.003519f, 0.005589f, 0.008041f, 0.013321f,
+ 0.024155f, 0.054718f, 0.171875f, 0.590332f, 0.885742f, 0.955566f, 0.977051f, 0.985840f, 0.990723f, 0.993164f, 0.994629f, 0.995605f,
+ 0.997070f, 0.997070f, 0.997559f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000192f, 0.000122f, 0.000244f, 0.000483f, 0.000606f, 0.000608f, 0.000731f, 0.000953f, 0.001095f, 0.001258f, 0.001575f, 0.002066f,
+ 0.002594f, 0.003857f, 0.004734f, 0.007683f, 0.011642f, 0.021179f, 0.044464f, 0.127930f, 0.476807f, 0.850586f, 0.947266f, 0.974121f,
+ 0.984375f, 0.989746f, 0.992676f, 0.994141f, 0.995605f, 0.996582f, 0.997070f, 0.997559f, 0.998535f, 0.998535f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000229f, 0.000239f, 0.000244f, 0.000343f, 0.000483f, 0.000608f, 0.000609f,
+ 0.000857f, 0.000973f, 0.001097f, 0.001571f, 0.002041f, 0.002399f, 0.002922f, 0.004471f, 0.006836f, 0.010643f, 0.018661f, 0.037354f,
+ 0.100037f, 0.378418f, 0.810547f, 0.937988f, 0.971191f, 0.983887f, 0.989258f, 0.992188f, 0.994141f, 0.995605f, 0.996582f, 0.997070f,
+ 0.997559f, 0.998047f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000161f,
+ 0.000230f, 0.000244f, 0.000486f, 0.000607f, 0.000609f, 0.000819f, 0.000972f, 0.000975f, 0.001431f, 0.001945f, 0.002283f, 0.003031f,
+ 0.004238f, 0.006424f, 0.009995f, 0.016068f, 0.032104f, 0.081360f, 0.302246f, 0.765625f, 0.928223f, 0.968750f, 0.982422f, 0.988770f,
+ 0.992676f, 0.994629f, 0.995605f, 0.996582f, 0.997070f, 0.997559f, 0.998047f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000240f, 0.000240f, 0.000244f, 0.000450f, 0.000607f, 0.000609f, 0.000731f, 0.001084f,
+ 0.000974f, 0.001341f, 0.001910f, 0.002254f, 0.003216f, 0.004017f, 0.005692f, 0.008980f, 0.014832f, 0.028854f, 0.069641f, 0.248657f,
+ 0.719238f, 0.918945f, 0.965820f, 0.981445f, 0.988770f, 0.992188f, 0.994629f, 0.995605f, 0.996094f, 0.997070f, 0.997559f, 0.998535f,
+ 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000243f, 0.000360f,
+ 0.000461f, 0.000607f, 0.000608f, 0.000731f, 0.001086f, 0.001202f, 0.001307f, 0.001592f, 0.002066f, 0.003134f, 0.003990f, 0.005611f,
+ 0.008133f, 0.013680f, 0.025986f, 0.061462f, 0.211670f, 0.676758f, 0.910156f, 0.963867f, 0.980957f, 0.988281f, 0.991699f, 0.994629f,
+ 0.995605f, 0.996582f, 0.997070f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000240f, 0.000243f, 0.000482f, 0.000604f, 0.000608f, 0.000730f, 0.001040f, 0.001188f, 0.001287f,
+ 0.001574f, 0.002064f, 0.002613f, 0.003721f, 0.005428f, 0.008018f, 0.013161f, 0.024200f, 0.055573f, 0.186401f, 0.642578f, 0.904785f,
+ 0.962402f, 0.980469f, 0.987793f, 0.991699f, 0.994141f, 0.995605f, 0.996582f, 0.997070f, 0.998047f, 0.998535f, 0.998535f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999512f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000243f, 0.000480f, 0.000602f,
+ 0.000721f, 0.000705f, 0.000907f, 0.001094f, 0.001096f, 0.001493f, 0.002058f, 0.002607f, 0.003639f, 0.004826f, 0.007595f, 0.012413f,
+ 0.022171f, 0.051697f, 0.171143f, 0.619629f, 0.899414f, 0.961426f, 0.980957f, 0.987793f, 0.992188f, 0.994629f, 0.995605f, 0.996582f,
+ 0.997559f, 0.998047f, 0.998047f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000172f, 0.000232f, 0.000243f, 0.000244f, 0.000576f, 0.000711f, 0.000608f, 0.000767f, 0.001089f, 0.001213f, 0.001509f, 0.002029f,
+ 0.002684f, 0.003550f, 0.005161f, 0.007107f, 0.011871f, 0.021545f, 0.049347f, 0.163086f, 0.609863f, 0.900391f, 0.962891f, 0.980957f,
+ 0.988281f, 0.992676f, 0.994629f, 0.996094f, 0.996582f, 0.997559f, 0.998047f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000210f, 0.000122f, 0.000337f, 0.000290f, 0.000594f, 0.000726f, 0.000730f,
+ 0.000731f, 0.001090f, 0.001212f, 0.001506f, 0.002029f, 0.002335f, 0.003489f, 0.005077f, 0.007000f, 0.011398f, 0.021027f, 0.048218f,
+ 0.161133f, 0.614258f, 0.903809f, 0.963379f, 0.981934f, 0.988770f, 0.992188f, 0.994629f, 0.996094f, 0.997070f, 0.997559f, 0.998047f,
+ 0.998047f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000281f, 0.000440f, 0.000683f, 0.000726f, 0.000730f, 0.000731f, 0.001087f, 0.001095f, 0.001485f, 0.001793f, 0.002214f, 0.002991f,
+ 0.004951f, 0.006912f, 0.011162f, 0.020905f, 0.048187f, 0.165527f, 0.633789f, 0.910156f, 0.965820f, 0.982422f, 0.989746f, 0.993164f,
+ 0.995117f, 0.996094f, 0.997070f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000241f, 0.000243f, 0.000480f, 0.000725f, 0.000697f, 0.000731f, 0.001007f,
+ 0.001094f, 0.001360f, 0.001795f, 0.002161f, 0.003244f, 0.004871f, 0.006966f, 0.011330f, 0.020706f, 0.049591f, 0.178345f, 0.667969f,
+ 0.918457f, 0.968262f, 0.983887f, 0.990234f, 0.993652f, 0.995605f, 0.996582f, 0.997559f, 0.998047f, 0.998047f, 0.998535f, 0.998535f,
+ 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000086f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000243f, 0.000243f,
+ 0.000465f, 0.000592f, 0.000729f, 0.000730f, 0.001079f, 0.001093f, 0.001332f, 0.001885f, 0.002129f, 0.003254f, 0.004818f, 0.006889f,
+ 0.011429f, 0.021957f, 0.052521f, 0.201294f, 0.714355f, 0.929199f, 0.972168f, 0.985352f, 0.991211f, 0.994141f, 0.995605f, 0.997070f,
+ 0.997559f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000000f, 0.000000f, 0.000115f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000184f, 0.000241f, 0.000347f, 0.000453f, 0.000579f, 0.000728f, 0.000729f, 0.001034f, 0.001093f, 0.001292f,
+ 0.001857f, 0.002131f, 0.003296f, 0.004826f, 0.006958f, 0.011726f, 0.023071f, 0.057983f, 0.239258f, 0.767578f, 0.939453f, 0.976074f,
+ 0.987305f, 0.992676f, 0.994629f, 0.996094f, 0.997070f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.999023f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000088f, 0.000119f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000191f, 0.000242f, 0.000425f, 0.000558f,
+ 0.000723f, 0.000730f, 0.001058f, 0.001092f, 0.001297f, 0.001653f, 0.002352f, 0.003124f, 0.004860f, 0.007072f, 0.012131f, 0.024551f,
+ 0.066406f, 0.300537f, 0.820312f, 0.951172f, 0.979492f, 0.988281f, 0.993164f, 0.995117f, 0.996582f, 0.997070f, 0.998047f, 0.998535f,
+ 0.998535f, 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000119f,
+ 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000227f, 0.000239f, 0.000341f, 0.000359f, 0.000587f, 0.000605f, 0.000729f, 0.001040f, 0.001185f, 0.001275f, 0.001849f, 0.002390f,
+ 0.003399f, 0.005001f, 0.007404f, 0.012871f, 0.027237f, 0.079529f, 0.395264f, 0.868164f, 0.960938f, 0.982910f, 0.990234f, 0.993164f,
+ 0.995605f, 0.997070f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000119f, 0.000120f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000211f, 0.000239f, 0.000307f, 0.000394f, 0.000704f, 0.000711f, 0.000728f,
+ 0.001001f, 0.001088f, 0.001204f, 0.001713f, 0.002367f, 0.003151f, 0.004639f, 0.007820f, 0.014084f, 0.030609f, 0.102722f, 0.527344f,
+ 0.906250f, 0.969727f, 0.985840f, 0.991699f, 0.994629f, 0.996094f, 0.997559f, 0.998047f, 0.998535f, 0.998535f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000117f, 0.000115f, 0.000121f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000196f,
+ 0.000332f, 0.000363f, 0.000686f, 0.000719f, 0.000723f, 0.000963f, 0.001089f, 0.001290f, 0.001849f, 0.002394f, 0.003458f, 0.004833f,
+ 0.008301f, 0.015579f, 0.036926f, 0.143188f, 0.676270f, 0.934570f, 0.976562f, 0.988281f, 0.992676f, 0.995605f, 0.996582f, 0.998047f,
+ 0.998047f, 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000102f, 0.000120f, 0.000121f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000311f, 0.000345f, 0.000479f, 0.000723f, 0.000728f, 0.000934f, 0.001085f,
+ 0.001282f, 0.001821f, 0.002399f, 0.003355f, 0.005524f, 0.008881f, 0.017807f, 0.047058f, 0.222046f, 0.803223f, 0.954102f, 0.981445f,
+ 0.990723f, 0.994141f, 0.996582f, 0.997559f, 0.998047f, 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000090f, 0.000116f, 0.000121f, 0.000121f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000201f, 0.000239f, 0.000358f,
+ 0.000618f, 0.000719f, 0.000727f, 0.000863f, 0.001087f, 0.001350f, 0.001945f, 0.002689f, 0.003731f, 0.005817f, 0.010033f, 0.021332f,
+ 0.064514f, 0.374512f, 0.885254f, 0.969238f, 0.986328f, 0.992676f, 0.995605f, 0.996582f, 0.998047f, 0.998535f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000086f, 0.000117f, 0.000121f, 0.000121f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000164f, 0.000238f, 0.000353f, 0.000596f, 0.000591f, 0.000727f, 0.000901f, 0.001085f, 0.001266f, 0.001767f,
+ 0.002663f, 0.003914f, 0.006153f, 0.011612f, 0.026871f, 0.100525f, 0.605957f, 0.934082f, 0.978027f, 0.989746f, 0.994141f, 0.996094f,
+ 0.997559f, 0.998535f, 0.999023f, 0.999512f, 0.999512f, 0.999023f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000107f, 0.000120f, 0.000120f, 0.000121f, 0.000121f, 0.000121f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000195f, 0.000323f, 0.000339f, 0.000461f, 0.000706f,
+ 0.000726f, 0.000845f, 0.001086f, 0.001298f, 0.001843f, 0.003027f, 0.004387f, 0.007011f, 0.013832f, 0.036530f, 0.183228f, 0.805664f,
+ 0.959961f, 0.984863f, 0.991699f, 0.995605f, 0.997070f, 0.998047f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000117f, 0.000120f, 0.000120f, 0.000121f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000224f, 0.000336f, 0.000464f, 0.000708f, 0.000726f, 0.000965f, 0.001083f, 0.001458f, 0.002180f, 0.003096f, 0.004425f,
+ 0.008377f, 0.017639f, 0.056610f, 0.390869f, 0.909180f, 0.975586f, 0.989746f, 0.994141f, 0.996582f, 0.998047f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000110f, 0.000113f, 0.000120f, 0.000121f, 0.000121f, 0.000121f, 0.000121f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000135f, 0.000336f, 0.000467f, 0.000713f, 0.000725f, 0.000959f,
+ 0.001191f, 0.001287f, 0.001939f, 0.003231f, 0.005306f, 0.009888f, 0.024414f, 0.105835f, 0.709961f, 0.955078f, 0.984863f, 0.993164f,
+ 0.996094f, 0.997559f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000061f, 0.000089f,
+ 0.000118f, 0.000120f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000309f,
+ 0.000299f, 0.000460f, 0.000710f, 0.000724f, 0.000997f, 0.001073f, 0.001410f, 0.002117f, 0.003506f, 0.006031f, 0.012863f, 0.038391f,
+ 0.260742f, 0.892090f, 0.975098f, 0.990723f, 0.995117f, 0.997559f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000085f, 0.000110f, 0.000118f, 0.000120f, 0.000120f, 0.000121f, 0.000121f, 0.000121f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000317f, 0.000499f, 0.000706f, 0.000599f, 0.000851f, 0.001069f, 0.001633f,
+ 0.002367f, 0.003918f, 0.007580f, 0.017929f, 0.074646f, 0.645508f, 0.956055f, 0.986328f, 0.994141f, 0.996582f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000099f, 0.000113f,
+ 0.000119f, 0.000119f, 0.000120f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000160f, 0.000326f, 0.000308f,
+ 0.000578f, 0.000602f, 0.000921f, 0.001071f, 0.001807f, 0.002783f, 0.004620f, 0.010017f, 0.029465f, 0.211792f, 0.896484f, 0.979004f,
+ 0.992188f, 0.996094f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000027f, 0.000103f, 0.000114f, 0.000118f, 0.000120f, 0.000120f, 0.000121f, 0.000121f, 0.000121f,
+ 0.000121f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000090f, 0.000212f, 0.000309f, 0.000586f, 0.000602f, 0.000937f, 0.001147f, 0.002031f, 0.003237f, 0.006134f,
+ 0.014969f, 0.063171f, 0.665527f, 0.964355f, 0.989258f, 0.995117f, 0.999023f, 0.998535f, 0.999023f, 0.999023f, 0.998535f, 0.999023f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000018f, 0.000103f, 0.000113f,
+ 0.000117f, 0.000119f, 0.000120f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000004f, 0.000002f, 0.000199f, 0.000390f, 0.000586f, 0.000665f,
+ 0.000946f, 0.001365f, 0.002207f, 0.003767f, 0.008308f, 0.025955f, 0.227661f, 0.924316f, 0.984863f, 0.994141f, 0.998535f, 0.998535f,
+ 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000098f, 0.000109f, 0.000117f, 0.000119f, 0.000120f, 0.000120f, 0.000121f, 0.000121f,
+ 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000011f, 0.000005f, 0.000003f,
+ 0.000002f, 0.000193f, 0.000388f, 0.000586f, 0.000659f, 0.000952f, 0.001580f, 0.002762f, 0.005363f, 0.013153f, 0.066589f, 0.781738f,
+ 0.977051f, 0.993164f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000075f, 0.000112f,
+ 0.000116f, 0.000118f, 0.000119f, 0.000120f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000122f,
+ 0.000088f, 0.000026f, 0.000010f, 0.000005f, 0.000003f, 0.000002f, 0.000186f, 0.000407f, 0.000586f, 0.000760f, 0.000986f, 0.001796f,
+ 0.003275f, 0.007565f, 0.026794f, 0.363281f, 0.959473f, 0.990723f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000010f, 0.000090f, 0.000110f, 0.000115f, 0.000117f, 0.000119f, 0.000120f, 0.000120f, 0.000121f,
+ 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000077f, 0.000023f, 0.000011f, 0.000005f, 0.000003f, 0.000002f, 0.000158f,
+ 0.000407f, 0.000587f, 0.000826f, 0.001264f, 0.002174f, 0.004894f, 0.013359f, 0.098511f, 0.911133f, 0.987793f, 0.998047f, 0.998047f,
+ 0.998047f, 0.998047f, 0.998047f, 0.998047f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000084f, 0.000107f,
+ 0.000114f, 0.000117f, 0.000119f, 0.000119f, 0.000120f, 0.000120f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000093f, 0.000024f,
+ 0.000011f, 0.000005f, 0.000003f, 0.000002f, 0.000220f, 0.000476f, 0.000585f, 0.000913f, 0.001374f, 0.002951f, 0.007511f, 0.034973f,
+ 0.736328f, 0.982910f, 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000056f, 0.000102f, 0.000112f, 0.000116f, 0.000117f, 0.000119f, 0.000120f, 0.000120f,
+ 0.000121f, 0.000121f, 0.000121f, 0.000075f, 0.000025f, 0.000010f, 0.000005f, 0.000003f, 0.000034f, 0.000222f, 0.000491f, 0.000589f,
+ 0.001020f, 0.001881f, 0.004669f, 0.015717f, 0.298340f, 0.974609f, 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.997559f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000048f, 0.000095f,
+ 0.000106f, 0.000114f, 0.000117f, 0.000118f, 0.000119f, 0.000120f, 0.000120f, 0.000121f, 0.000089f, 0.000029f, 0.000012f, 0.000006f,
+ 0.000003f, 0.000002f, 0.000223f, 0.000525f, 0.000687f, 0.001122f, 0.002672f, 0.008255f, 0.079590f, 0.954590f, 0.996582f, 0.996582f,
+ 0.996582f, 0.996582f, 0.996582f, 0.996582f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000077f, 0.000104f, 0.000112f, 0.000115f, 0.000117f, 0.000119f, 0.000119f,
+ 0.000120f, 0.000109f, 0.000031f, 0.000013f, 0.000006f, 0.000003f, 0.000002f, 0.000254f, 0.000550f, 0.000846f, 0.001545f, 0.004223f,
+ 0.027771f, 0.901855f, 0.996094f, 0.996094f, 0.996094f, 0.996094f, 0.996094f, 0.996094f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000037f,
+ 0.000090f, 0.000107f, 0.000113f, 0.000116f, 0.000118f, 0.000119f, 0.000120f, 0.000041f, 0.000015f, 0.000007f, 0.000004f, 0.000002f,
+ 0.000271f, 0.000563f, 0.000786f, 0.002211f, 0.012207f, 0.711426f, 0.994629f, 0.994629f, 0.995117f, 0.994629f, 0.994629f, 0.994629f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000028f, 0.000083f, 0.000102f, 0.000110f, 0.000114f, 0.000117f, 0.000118f,
+ 0.000052f, 0.000019f, 0.000008f, 0.000004f, 0.000002f, 0.000314f, 0.000444f, 0.001049f, 0.005669f, 0.266846f, 0.993164f, 0.993652f,
+ 0.993164f, 0.993652f, 0.993164f, 0.993164f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000048f, 0.000089f, 0.000106f, 0.000112f, 0.000115f, 0.000077f, 0.000026f, 0.000010f, 0.000005f, 0.000079f, 0.000425f, 0.000405f,
+ 0.002468f, 0.064209f, 0.990234f, 0.990723f, 0.990234f, 0.990234f, 0.990234f, 0.991211f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000020f, 0.000075f, 0.000098f, 0.000108f, 0.000113f, 0.000044f,
+ 0.000016f, 0.000006f, 0.000027f, 0.000270f, 0.000825f, 0.018448f, 0.986328f, 0.986328f, 0.986328f, 0.986328f, 0.986328f, 0.986328f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000049f, 0.000085f, 0.000102f, 0.000070f, 0.000022f, 0.000008f, 0.000133f, 0.000295f, 0.005318f, 0.978516f, 0.979004f,
+ 0.977539f, 0.977539f, 0.978027f, 0.978516f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000066f, 0.000092f, 0.000036f, 0.000011f,
+ 0.000135f, 0.000925f, 0.959473f, 0.959961f, 0.959961f, 0.959473f, 0.959961f, 0.959473f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000027f, 0.000065f, 0.000016f, 0.000109f, 0.907715f, 0.907227f, 0.907715f, 0.907227f, 0.907715f, 0.907715f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000017f, 0.711914f, 0.712402f,
+ 0.711426f, 0.711426f, 0.711914f, 0.712402f,
+ },
+ {
+ 0.076172f, 0.877441f, 0.964355f, 0.980957f, 0.987305f, 0.990723f, 0.992676f, 0.993652f, 0.994629f, 0.995605f, 0.996094f, 0.996582f,
+ 0.997070f, 0.997070f, 0.997070f, 0.997559f, 0.998047f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f,
+ 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.003897f, 0.033173f, 0.320557f, 0.863770f, 0.953613f, 0.975586f, 0.984863f, 0.988770f,
+ 0.991211f, 0.992676f, 0.994141f, 0.995117f, 0.995605f, 0.996094f, 0.996582f, 0.996582f, 0.997559f, 0.997559f, 0.997559f, 0.998047f,
+ 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000975f, 0.005951f, 0.020935f, 0.093140f,
+ 0.501465f, 0.873047f, 0.950684f, 0.973145f, 0.981934f, 0.986816f, 0.990234f, 0.992188f, 0.993164f, 0.994629f, 0.995605f, 0.996094f,
+ 0.996582f, 0.997070f, 0.997070f, 0.997559f, 0.997559f, 0.997559f, 0.998047f, 0.998535f, 0.998047f, 0.998535f, 0.998535f, 0.998535f,
+ 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000610f, 0.002430f, 0.006081f, 0.015915f, 0.045593f, 0.179810f, 0.635254f, 0.889648f, 0.951172f, 0.972168f, 0.981445f, 0.986328f,
+ 0.989746f, 0.991699f, 0.993652f, 0.994629f, 0.995117f, 0.996094f, 0.996582f, 0.996582f, 0.997070f, 0.997559f, 0.997559f, 0.997559f,
+ 0.998047f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000244f, 0.001219f, 0.002796f, 0.006172f, 0.012848f, 0.028458f, 0.081177f, 0.301758f,
+ 0.733398f, 0.905273f, 0.953613f, 0.972168f, 0.981445f, 0.986328f, 0.989258f, 0.991699f, 0.993652f, 0.994141f, 0.995117f, 0.996094f,
+ 0.996094f, 0.996582f, 0.997070f, 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f,
+ 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000244f, 0.000731f, 0.001706f, 0.003166f,
+ 0.005470f, 0.010406f, 0.020813f, 0.047089f, 0.136719f, 0.449951f, 0.803223f, 0.919434f, 0.957520f, 0.973633f, 0.981934f, 0.986328f,
+ 0.989746f, 0.991699f, 0.993164f, 0.994629f, 0.995117f, 0.995605f, 0.996582f, 0.996582f, 0.997070f, 0.997070f, 0.997559f, 0.998047f,
+ 0.998047f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000244f, 0.000366f, 0.001214f, 0.001894f, 0.003159f, 0.005108f, 0.008720f, 0.015839f, 0.031586f, 0.074951f, 0.224121f, 0.596680f,
+ 0.851074f, 0.932617f, 0.962402f, 0.975586f, 0.982910f, 0.987305f, 0.989746f, 0.991699f, 0.993164f, 0.994141f, 0.995117f, 0.995605f,
+ 0.996094f, 0.996582f, 0.997070f, 0.997070f, 0.997559f, 0.998047f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f,
+ 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000366f, 0.000731f, 0.000976f, 0.001827f, 0.002987f, 0.004757f, 0.007988f,
+ 0.013023f, 0.023544f, 0.048431f, 0.120239f, 0.352783f, 0.717285f, 0.887207f, 0.943848f, 0.966309f, 0.978027f, 0.983887f, 0.987305f,
+ 0.990234f, 0.992188f, 0.993652f, 0.994629f, 0.995605f, 0.996094f, 0.996582f, 0.996582f, 0.997070f, 0.997070f, 0.998047f, 0.998047f,
+ 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000434f, 0.000488f, 0.000704f,
+ 0.001218f, 0.002190f, 0.002783f, 0.004723f, 0.006878f, 0.011040f, 0.018372f, 0.034241f, 0.073242f, 0.194336f, 0.510742f, 0.803711f,
+ 0.912598f, 0.952637f, 0.970703f, 0.979004f, 0.984863f, 0.988281f, 0.991211f, 0.992676f, 0.994141f, 0.994629f, 0.995605f, 0.996094f,
+ 0.996582f, 0.996582f, 0.997070f, 0.997070f, 0.998047f, 0.998047f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f,
+ 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000000f, 0.000243f, 0.000488f, 0.000488f, 0.000916f, 0.001219f, 0.002308f, 0.002914f, 0.004124f, 0.006523f, 0.009537f, 0.014793f,
+ 0.025833f, 0.050446f, 0.116089f, 0.312744f, 0.661133f, 0.860840f, 0.931641f, 0.960449f, 0.974121f, 0.981445f, 0.986328f, 0.989258f,
+ 0.991211f, 0.992676f, 0.994141f, 0.995117f, 0.995605f, 0.996094f, 0.996582f, 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.998047f,
+ 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000121f, 0.000356f, 0.000488f, 0.000609f, 0.000944f, 0.001339f, 0.002296f,
+ 0.002964f, 0.003880f, 0.005676f, 0.008476f, 0.012909f, 0.020874f, 0.036926f, 0.075500f, 0.187988f, 0.474854f, 0.774414f, 0.900391f,
+ 0.946289f, 0.966309f, 0.978027f, 0.983887f, 0.987793f, 0.990234f, 0.991699f, 0.993164f, 0.994141f, 0.995117f, 0.995605f, 0.996094f,
+ 0.997070f, 0.997070f, 0.997070f, 0.997559f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000244f, 0.000483f,
+ 0.000488f, 0.000731f, 0.001070f, 0.001551f, 0.002024f, 0.002520f, 0.003990f, 0.004738f, 0.007584f, 0.010834f, 0.016800f, 0.028763f,
+ 0.054535f, 0.120728f, 0.309082f, 0.642090f, 0.848145f, 0.926270f, 0.957031f, 0.971191f, 0.980469f, 0.985352f, 0.988770f, 0.990723f,
+ 0.992188f, 0.993652f, 0.994629f, 0.995605f, 0.996094f, 0.996582f, 0.996582f, 0.997070f, 0.997559f, 0.998047f, 0.998047f, 0.998047f,
+ 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000000f, 0.000000f, 0.000122f, 0.000242f, 0.000485f, 0.000608f, 0.000731f, 0.001091f, 0.001339f, 0.001943f, 0.002602f, 0.003466f,
+ 0.004845f, 0.006649f, 0.009529f, 0.014824f, 0.023407f, 0.041351f, 0.083496f, 0.199951f, 0.482422f, 0.770996f, 0.896484f, 0.944336f,
+ 0.965332f, 0.976562f, 0.982910f, 0.986816f, 0.990234f, 0.991699f, 0.993164f, 0.994141f, 0.995117f, 0.995117f, 0.996094f, 0.996582f,
+ 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000121f, 0.000243f, 0.000243f, 0.000602f, 0.000609f, 0.000799f,
+ 0.001088f, 0.001459f, 0.001822f, 0.002432f, 0.003033f, 0.004375f, 0.006042f, 0.008560f, 0.012810f, 0.019791f, 0.032715f, 0.061584f,
+ 0.135254f, 0.335693f, 0.660156f, 0.853027f, 0.926758f, 0.956543f, 0.972168f, 0.980469f, 0.984863f, 0.988281f, 0.991211f, 0.992676f,
+ 0.993652f, 0.994141f, 0.995605f, 0.996094f, 0.996094f, 0.996582f, 0.997070f, 0.997559f, 0.998047f, 0.998047f, 0.998047f, 0.998535f,
+ 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000119f,
+ 0.000243f, 0.000366f, 0.000605f, 0.000730f, 0.000731f, 0.001201f, 0.001458f, 0.001804f, 0.002428f, 0.003593f, 0.004234f, 0.005745f,
+ 0.007755f, 0.011139f, 0.016754f, 0.027054f, 0.047424f, 0.097107f, 0.231323f, 0.525879f, 0.791016f, 0.902832f, 0.945801f, 0.966797f,
+ 0.977051f, 0.982910f, 0.987793f, 0.990234f, 0.991699f, 0.993164f, 0.994629f, 0.995117f, 0.995605f, 0.996094f, 0.996582f, 0.997070f,
+ 0.997559f, 0.997559f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000116f, 0.000122f, 0.000365f, 0.000244f, 0.000602f, 0.000721f, 0.000730f, 0.000852f, 0.001451f,
+ 0.001842f, 0.002518f, 0.002993f, 0.004097f, 0.005253f, 0.007099f, 0.009865f, 0.014908f, 0.022827f, 0.038879f, 0.072815f, 0.163940f,
+ 0.396484f, 0.707031f, 0.869141f, 0.932129f, 0.960449f, 0.973145f, 0.980957f, 0.986328f, 0.988770f, 0.991211f, 0.992676f, 0.993652f,
+ 0.994629f, 0.995605f, 0.996094f, 0.996582f, 0.996582f, 0.997070f, 0.997559f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000110f, 0.000361f, 0.000242f, 0.000244f,
+ 0.000602f, 0.000728f, 0.000853f, 0.001260f, 0.001569f, 0.001704f, 0.002287f, 0.003103f, 0.003857f, 0.004848f, 0.006680f, 0.009003f,
+ 0.012978f, 0.019897f, 0.032135f, 0.057983f, 0.121033f, 0.291504f, 0.604980f, 0.827148f, 0.915039f, 0.953125f, 0.969238f, 0.978516f,
+ 0.984375f, 0.988281f, 0.991211f, 0.992188f, 0.993652f, 0.994141f, 0.995117f, 0.995605f, 0.996582f, 0.996582f, 0.997070f, 0.998047f,
+ 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000241f, 0.000241f, 0.000365f, 0.000365f, 0.000589f, 0.000852f, 0.000852f, 0.001246f, 0.001562f, 0.001812f, 0.002241f,
+ 0.002794f, 0.003633f, 0.004669f, 0.006069f, 0.008202f, 0.011772f, 0.016891f, 0.027618f, 0.047089f, 0.093506f, 0.216309f, 0.495605f,
+ 0.771484f, 0.894531f, 0.942383f, 0.965332f, 0.976074f, 0.982910f, 0.987305f, 0.989746f, 0.991699f, 0.993164f, 0.994629f, 0.995117f,
+ 0.995605f, 0.996094f, 0.996582f, 0.997070f, 0.997559f, 0.998047f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000121f, 0.000364f, 0.000242f, 0.000487f, 0.000737f, 0.000730f,
+ 0.000974f, 0.001083f, 0.001520f, 0.001701f, 0.001938f, 0.002768f, 0.003658f, 0.004227f, 0.005741f, 0.007671f, 0.010796f, 0.015511f,
+ 0.023529f, 0.040009f, 0.074158f, 0.165405f, 0.395264f, 0.703613f, 0.868164f, 0.932129f, 0.959473f, 0.973633f, 0.980957f, 0.985840f,
+ 0.988770f, 0.991699f, 0.992676f, 0.994141f, 0.995117f, 0.995117f, 0.996094f, 0.996582f, 0.997070f, 0.997559f, 0.998047f, 0.998047f,
+ 0.998047f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000100f, 0.000000f, 0.000241f,
+ 0.000224f, 0.000487f, 0.000488f, 0.000710f, 0.000972f, 0.000848f, 0.001181f, 0.001333f, 0.001910f, 0.001830f, 0.002661f, 0.003298f,
+ 0.004154f, 0.005386f, 0.007271f, 0.009735f, 0.013908f, 0.021149f, 0.034149f, 0.062042f, 0.130371f, 0.313477f, 0.627930f, 0.837402f,
+ 0.919922f, 0.954590f, 0.970215f, 0.979492f, 0.985352f, 0.988770f, 0.991211f, 0.992676f, 0.993652f, 0.995117f, 0.995605f, 0.996094f,
+ 0.996582f, 0.996582f, 0.997559f, 0.997559f, 0.998047f, 0.998047f, 0.998047f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000049f, 0.000242f, 0.000483f, 0.000606f, 0.000487f, 0.000695f, 0.000970f, 0.000974f, 0.001136f,
+ 0.001328f, 0.001694f, 0.002028f, 0.002617f, 0.002953f, 0.003847f, 0.004951f, 0.006653f, 0.009193f, 0.012672f, 0.018661f, 0.029968f,
+ 0.052673f, 0.106689f, 0.250977f, 0.549805f, 0.801758f, 0.907227f, 0.948242f, 0.967773f, 0.978027f, 0.984375f, 0.987793f, 0.990723f,
+ 0.992188f, 0.993652f, 0.994629f, 0.995605f, 0.996094f, 0.996582f, 0.996582f, 0.997559f, 0.998047f, 0.998047f, 0.998047f, 0.998535f,
+ 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000166f, 0.000243f, 0.000485f, 0.000487f,
+ 0.000487f, 0.000945f, 0.000834f, 0.000974f, 0.000974f, 0.001300f, 0.001810f, 0.002058f, 0.002573f, 0.002703f, 0.003761f, 0.004887f,
+ 0.006393f, 0.008514f, 0.011818f, 0.016937f, 0.026672f, 0.046051f, 0.089478f, 0.204712f, 0.476807f, 0.762207f, 0.891602f, 0.942383f,
+ 0.965820f, 0.976562f, 0.983398f, 0.987793f, 0.990234f, 0.992188f, 0.993652f, 0.994629f, 0.995605f, 0.996094f, 0.996582f, 0.997070f,
+ 0.997559f, 0.998047f, 0.998047f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000224f, 0.000358f, 0.000477f, 0.000486f, 0.000487f, 0.000580f, 0.000841f, 0.000973f, 0.001079f, 0.001255f, 0.001649f,
+ 0.002045f, 0.002241f, 0.002995f, 0.003841f, 0.004826f, 0.005920f, 0.007866f, 0.010925f, 0.015930f, 0.024109f, 0.040619f, 0.077454f,
+ 0.171509f, 0.412354f, 0.720215f, 0.876953f, 0.936035f, 0.962402f, 0.975098f, 0.982422f, 0.987305f, 0.990234f, 0.992188f, 0.993164f,
+ 0.994629f, 0.995117f, 0.996094f, 0.996582f, 0.997559f, 0.997559f, 0.998047f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f,
+ 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000165f, 0.000205f, 0.000411f, 0.000480f, 0.000486f, 0.000608f, 0.000688f,
+ 0.000966f, 0.000968f, 0.000974f, 0.001421f, 0.001489f, 0.001695f, 0.002090f, 0.002886f, 0.003326f, 0.004608f, 0.005604f, 0.007317f,
+ 0.010414f, 0.014862f, 0.022232f, 0.036469f, 0.067810f, 0.146973f, 0.359375f, 0.680664f, 0.861816f, 0.931152f, 0.959961f, 0.974609f,
+ 0.981934f, 0.986816f, 0.989746f, 0.991699f, 0.993652f, 0.994629f, 0.995605f, 0.996094f, 0.996582f, 0.997070f, 0.997559f, 0.998047f,
+ 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000242f,
+ 0.000453f, 0.000539f, 0.000486f, 0.000487f, 0.000487f, 0.000957f, 0.000969f, 0.001202f, 0.001139f, 0.001393f, 0.001986f, 0.002045f,
+ 0.002863f, 0.003216f, 0.004128f, 0.005417f, 0.007378f, 0.009689f, 0.013466f, 0.020432f, 0.033722f, 0.060883f, 0.129395f, 0.318115f,
+ 0.642090f, 0.847656f, 0.926270f, 0.958008f, 0.973145f, 0.981934f, 0.986328f, 0.989746f, 0.992188f, 0.993164f, 0.994629f, 0.995605f,
+ 0.996094f, 0.996582f, 0.997070f, 0.997559f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000243f, 0.000380f, 0.000482f, 0.000606f, 0.000607f, 0.000608f, 0.000829f, 0.000970f,
+ 0.000972f, 0.001070f, 0.001402f, 0.001812f, 0.002138f, 0.002619f, 0.003246f, 0.004082f, 0.005318f, 0.006699f, 0.009262f, 0.012764f,
+ 0.019318f, 0.031052f, 0.055878f, 0.116821f, 0.286621f, 0.610352f, 0.835938f, 0.922852f, 0.956543f, 0.973145f, 0.981445f, 0.986328f,
+ 0.989746f, 0.991699f, 0.993652f, 0.995117f, 0.995605f, 0.996582f, 0.996582f, 0.997070f, 0.997559f, 0.998047f, 0.998047f, 0.998535f,
+ 0.998535f, 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000243f, 0.000350f, 0.000480f,
+ 0.000605f, 0.000596f, 0.000608f, 0.000890f, 0.000963f, 0.000972f, 0.000974f, 0.001316f, 0.001798f, 0.002058f, 0.002560f, 0.002811f,
+ 0.003983f, 0.005108f, 0.006489f, 0.008888f, 0.012314f, 0.018021f, 0.029495f, 0.051941f, 0.107422f, 0.263428f, 0.585449f, 0.827148f,
+ 0.919434f, 0.956055f, 0.971680f, 0.981445f, 0.986816f, 0.989746f, 0.992188f, 0.994141f, 0.995117f, 0.995605f, 0.996582f, 0.996582f,
+ 0.997559f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000130f, 0.000176f, 0.000462f, 0.000483f, 0.000604f, 0.000607f, 0.000638f, 0.000922f, 0.000965f, 0.000971f, 0.001235f,
+ 0.001376f, 0.001769f, 0.002041f, 0.002575f, 0.003130f, 0.003487f, 0.004936f, 0.006264f, 0.008415f, 0.012047f, 0.017517f, 0.027786f,
+ 0.049164f, 0.101257f, 0.249512f, 0.568848f, 0.821777f, 0.918945f, 0.956055f, 0.972168f, 0.981445f, 0.986816f, 0.990234f, 0.992188f,
+ 0.993652f, 0.995117f, 0.995605f, 0.996582f, 0.997070f, 0.997559f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000130f, 0.000122f, 0.000242f, 0.000352f, 0.000560f, 0.000602f, 0.000604f,
+ 0.000606f, 0.000767f, 0.001046f, 0.001089f, 0.000973f, 0.001327f, 0.001583f, 0.002033f, 0.002272f, 0.002657f, 0.003563f, 0.004589f,
+ 0.006138f, 0.008194f, 0.011299f, 0.016861f, 0.026718f, 0.047119f, 0.097656f, 0.240967f, 0.562500f, 0.821289f, 0.919922f, 0.957031f,
+ 0.973145f, 0.981934f, 0.987305f, 0.990234f, 0.992676f, 0.994141f, 0.995605f, 0.996094f, 0.996582f, 0.997070f, 0.998047f, 0.998047f,
+ 0.998535f, 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000241f, 0.000314f, 0.000459f, 0.000600f, 0.000605f, 0.000598f, 0.000804f, 0.000958f, 0.001084f, 0.001104f, 0.001389f, 0.001709f,
+ 0.002041f, 0.002211f, 0.002645f, 0.003635f, 0.004467f, 0.005718f, 0.008072f, 0.011185f, 0.016846f, 0.026184f, 0.046112f, 0.094971f,
+ 0.239014f, 0.565430f, 0.825684f, 0.922363f, 0.958496f, 0.973633f, 0.983398f, 0.987793f, 0.990723f, 0.992676f, 0.994141f, 0.995605f,
+ 0.996582f, 0.997070f, 0.997559f, 0.997559f, 0.998535f, 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000238f, 0.000122f, 0.000173f, 0.000246f, 0.000387f, 0.000480f, 0.000604f, 0.000604f, 0.000701f,
+ 0.000951f, 0.000968f, 0.001184f, 0.001315f, 0.001597f, 0.001899f, 0.002268f, 0.002813f, 0.003716f, 0.004372f, 0.005886f, 0.007759f,
+ 0.010918f, 0.015915f, 0.025726f, 0.045685f, 0.095459f, 0.243774f, 0.579102f, 0.833984f, 0.926270f, 0.960449f, 0.976074f, 0.983887f,
+ 0.988770f, 0.991211f, 0.993164f, 0.994629f, 0.995605f, 0.996582f, 0.997070f, 0.997559f, 0.998047f, 0.998535f, 0.999512f, 0.999512f,
+ 0.999023f, 0.999512f, 0.999023f, 0.999023f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000238f, 0.000237f, 0.000242f,
+ 0.000463f, 0.000585f, 0.000587f, 0.000718f, 0.000607f, 0.000885f, 0.001081f, 0.001087f, 0.001299f, 0.001553f, 0.001982f, 0.002104f,
+ 0.002777f, 0.003494f, 0.004406f, 0.005798f, 0.007645f, 0.010750f, 0.016159f, 0.025467f, 0.045959f, 0.097778f, 0.256104f, 0.603516f,
+ 0.847168f, 0.931152f, 0.963379f, 0.977539f, 0.985352f, 0.989258f, 0.991699f, 0.993652f, 0.995117f, 0.996094f, 0.996582f, 0.997559f,
+ 0.998047f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.000000f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000231f, 0.000122f, 0.000242f, 0.000242f, 0.000400f, 0.000525f, 0.000495f, 0.000605f, 0.000607f, 0.000898f, 0.001075f,
+ 0.001191f, 0.001133f, 0.001420f, 0.001794f, 0.002041f, 0.002733f, 0.003548f, 0.004448f, 0.005585f, 0.007656f, 0.010735f, 0.015671f,
+ 0.025589f, 0.047363f, 0.102783f, 0.276855f, 0.637695f, 0.862793f, 0.938477f, 0.966797f, 0.979004f, 0.985840f, 0.990234f, 0.992676f,
+ 0.994141f, 0.995117f, 0.996582f, 0.997070f, 0.997559f, 0.998047f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000226f, 0.000242f, 0.000470f, 0.000469f,
+ 0.000547f, 0.000711f, 0.000723f, 0.000829f, 0.001024f, 0.001188f, 0.001081f, 0.001415f, 0.001765f, 0.002048f, 0.002708f, 0.003252f,
+ 0.004448f, 0.005711f, 0.007557f, 0.010780f, 0.016220f, 0.026398f, 0.048950f, 0.111267f, 0.309082f, 0.680664f, 0.880371f, 0.945801f,
+ 0.970703f, 0.980957f, 0.986816f, 0.990723f, 0.993164f, 0.994629f, 0.995605f, 0.996582f, 0.997559f, 0.998047f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000204f, 0.000239f, 0.000242f, 0.000283f, 0.000479f, 0.000594f, 0.000603f, 0.000606f, 0.000779f, 0.001068f, 0.001084f, 0.001118f,
+ 0.001515f, 0.001926f, 0.002098f, 0.002674f, 0.002975f, 0.004040f, 0.005478f, 0.007488f, 0.010651f, 0.016327f, 0.027222f, 0.052460f,
+ 0.123718f, 0.355713f, 0.729980f, 0.899902f, 0.952637f, 0.973145f, 0.983887f, 0.988770f, 0.991699f, 0.994141f, 0.995117f, 0.996094f,
+ 0.997070f, 0.998047f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.000122f, 0.000000f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000236f, 0.000207f, 0.000240f, 0.000435f, 0.000534f, 0.000594f, 0.000602f,
+ 0.000722f, 0.000727f, 0.000947f, 0.001081f, 0.001090f, 0.001471f, 0.001829f, 0.002010f, 0.002478f, 0.002956f, 0.004051f, 0.005753f,
+ 0.007717f, 0.011040f, 0.017105f, 0.028748f, 0.057159f, 0.142944f, 0.421387f, 0.780762f, 0.916992f, 0.960449f, 0.976562f, 0.985352f,
+ 0.989746f, 0.992676f, 0.994629f, 0.996094f, 0.997070f, 0.997559f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000224f, 0.000232f,
+ 0.000230f, 0.000382f, 0.000472f, 0.000576f, 0.000715f, 0.000721f, 0.000727f, 0.001046f, 0.001078f, 0.001186f, 0.001434f, 0.001674f,
+ 0.002066f, 0.002546f, 0.003407f, 0.004181f, 0.005634f, 0.007542f, 0.011330f, 0.017609f, 0.031189f, 0.064392f, 0.172729f, 0.506836f,
+ 0.828125f, 0.933105f, 0.966309f, 0.980469f, 0.987305f, 0.991211f, 0.993652f, 0.995117f, 0.996582f, 0.997070f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000232f, 0.000234f, 0.000352f, 0.000461f, 0.000535f, 0.000594f, 0.000722f, 0.000725f,
+ 0.000921f, 0.001116f, 0.001192f, 0.001416f, 0.001637f, 0.001911f, 0.002380f, 0.002949f, 0.003948f, 0.005589f, 0.007942f, 0.011650f,
+ 0.018631f, 0.034302f, 0.075867f, 0.219238f, 0.607422f, 0.870605f, 0.946777f, 0.972656f, 0.983887f, 0.989258f, 0.992676f, 0.995117f,
+ 0.996094f, 0.997070f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000239f, 0.000302f,
+ 0.000396f, 0.000564f, 0.000674f, 0.000617f, 0.000722f, 0.001003f, 0.001068f, 0.001084f, 0.001302f, 0.001598f, 0.001929f, 0.002375f,
+ 0.002935f, 0.004349f, 0.005714f, 0.007957f, 0.012306f, 0.020493f, 0.039001f, 0.092590f, 0.293213f, 0.711426f, 0.905762f, 0.958984f,
+ 0.978027f, 0.986328f, 0.990723f, 0.994141f, 0.995605f, 0.996582f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000232f, 0.000227f, 0.000240f, 0.000282f, 0.000542f, 0.000703f, 0.000718f, 0.000724f, 0.000833f, 0.001069f,
+ 0.001184f, 0.001346f, 0.001464f, 0.001898f, 0.002649f, 0.003164f, 0.004467f, 0.005863f, 0.008400f, 0.013199f, 0.022614f, 0.046051f,
+ 0.120605f, 0.406738f, 0.801270f, 0.931641f, 0.968262f, 0.982422f, 0.988770f, 0.992676f, 0.994629f, 0.996094f, 0.998535f, 0.998535f,
+ 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.000120f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000219f, 0.000237f, 0.000235f, 0.000241f, 0.000480f,
+ 0.000584f, 0.000715f, 0.000723f, 0.000775f, 0.001061f, 0.000959f, 0.001139f, 0.001526f, 0.001770f, 0.002546f, 0.003151f, 0.004250f,
+ 0.006195f, 0.009071f, 0.014595f, 0.026413f, 0.056763f, 0.169067f, 0.557617f, 0.869141f, 0.951172f, 0.976074f, 0.986328f, 0.990723f,
+ 0.994141f, 0.995605f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.000000f, 0.000120f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000216f, 0.000228f, 0.000285f, 0.000339f, 0.000454f, 0.000572f, 0.000595f, 0.000721f, 0.000604f, 0.000930f, 0.000958f, 0.001171f,
+ 0.001431f, 0.001888f, 0.002663f, 0.003256f, 0.004402f, 0.006527f, 0.009964f, 0.016281f, 0.031189f, 0.074524f, 0.258301f, 0.714355f,
+ 0.916016f, 0.965332f, 0.982422f, 0.989746f, 0.992676f, 0.995117f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f,
+ 0.000000f, 0.000063f, 0.000120f, 0.000121f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000194f, 0.000184f, 0.000228f, 0.000340f, 0.000396f, 0.000668f, 0.000571f,
+ 0.000478f, 0.000602f, 0.000919f, 0.000956f, 0.001061f, 0.001497f, 0.001888f, 0.002565f, 0.003523f, 0.004578f, 0.006935f, 0.010765f,
+ 0.018417f, 0.038635f, 0.107727f, 0.416260f, 0.832520f, 0.946289f, 0.975586f, 0.986328f, 0.991699f, 0.994629f, 0.998535f, 0.998535f,
+ 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.000000f, 0.000000f, 0.000045f, 0.000118f, 0.000121f, 0.000121f, 0.000121f, 0.000121f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000234f, 0.000294f, 0.000220f, 0.000486f, 0.000579f, 0.000588f, 0.000669f, 0.000878f, 0.001038f, 0.001135f, 0.001451f, 0.001820f,
+ 0.002529f, 0.003551f, 0.005199f, 0.007542f, 0.012230f, 0.022369f, 0.051910f, 0.174927f, 0.630859f, 0.905273f, 0.965332f, 0.982910f,
+ 0.990234f, 0.993652f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.000000f, 0.000000f, 0.000000f, 0.000091f,
+ 0.000117f, 0.000120f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000171f, 0.000151f, 0.000166f, 0.000195f, 0.000342f, 0.000452f, 0.000594f, 0.000599f,
+ 0.000862f, 0.001019f, 0.001135f, 0.001465f, 0.002031f, 0.002676f, 0.003714f, 0.005497f, 0.008286f, 0.014320f, 0.028854f, 0.077332f,
+ 0.322754f, 0.809082f, 0.946289f, 0.977051f, 0.987793f, 0.993164f, 0.998047f, 0.998535f, 0.998047f, 0.998047f, 0.998535f, 0.998047f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000079f, 0.000105f, 0.000120f, 0.000120f, 0.000121f, 0.000121f, 0.000121f,
+ 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000008f, 0.000006f, 0.000098f, 0.000137f,
+ 0.000233f, 0.000324f, 0.000566f, 0.000589f, 0.000618f, 0.000874f, 0.000941f, 0.001108f, 0.001621f, 0.001880f, 0.002726f, 0.003788f,
+ 0.005840f, 0.009583f, 0.017563f, 0.039368f, 0.133545f, 0.582520f, 0.906738f, 0.968262f, 0.984863f, 0.992188f, 0.998047f, 0.998047f,
+ 0.998047f, 0.998047f, 0.998047f, 0.998047f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000069f, 0.000114f,
+ 0.000117f, 0.000120f, 0.000120f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f,
+ 0.000121f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000021f,
+ 0.000013f, 0.000009f, 0.000006f, 0.000004f, 0.000090f, 0.000206f, 0.000305f, 0.000538f, 0.000585f, 0.000596f, 0.000869f, 0.000941f,
+ 0.001149f, 0.001516f, 0.002150f, 0.002729f, 0.004475f, 0.006660f, 0.011360f, 0.022690f, 0.061401f, 0.281494f, 0.813965f, 0.952148f,
+ 0.980957f, 0.990723f, 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000006f, 0.000085f, 0.000114f, 0.000117f, 0.000119f, 0.000119f, 0.000120f, 0.000120f, 0.000121f,
+ 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f,
+ 0.000122f, 0.000122f, 0.000077f, 0.000041f, 0.000022f, 0.000013f, 0.000009f, 0.000006f, 0.000066f, 0.000107f, 0.000223f, 0.000250f,
+ 0.000532f, 0.000576f, 0.000593f, 0.000784f, 0.000937f, 0.001126f, 0.001523f, 0.002306f, 0.003193f, 0.004574f, 0.007717f, 0.014191f,
+ 0.032410f, 0.116577f, 0.595215f, 0.921875f, 0.974609f, 0.988770f, 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.997559f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000056f, 0.000112f,
+ 0.000114f, 0.000118f, 0.000119f, 0.000120f, 0.000120f, 0.000120f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f,
+ 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000074f, 0.000038f, 0.000021f, 0.000013f, 0.000009f,
+ 0.000006f, 0.000004f, 0.000003f, 0.000179f, 0.000258f, 0.000367f, 0.000469f, 0.000583f, 0.000770f, 0.000932f, 0.001131f, 0.001758f,
+ 0.002483f, 0.003517f, 0.005432f, 0.009232f, 0.019302f, 0.054504f, 0.293457f, 0.853516f, 0.964844f, 0.986816f, 0.997070f, 0.997070f,
+ 0.997070f, 0.997070f, 0.997070f, 0.997070f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000015f, 0.000084f, 0.000107f, 0.000113f, 0.000117f, 0.000118f, 0.000119f, 0.000120f, 0.000120f,
+ 0.000120f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f,
+ 0.000076f, 0.000042f, 0.000023f, 0.000015f, 0.000009f, 0.000007f, 0.000005f, 0.000004f, 0.000147f, 0.000238f, 0.000457f, 0.000545f,
+ 0.000586f, 0.000821f, 0.000936f, 0.001139f, 0.001849f, 0.002665f, 0.003687f, 0.006367f, 0.011810f, 0.028931f, 0.120605f, 0.687988f,
+ 0.947754f, 0.982910f, 0.996094f, 0.996582f, 0.996582f, 0.996582f, 0.996582f, 0.996582f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000082f, 0.000095f,
+ 0.000111f, 0.000115f, 0.000117f, 0.000118f, 0.000119f, 0.000119f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000121f, 0.000121f,
+ 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000083f, 0.000042f, 0.000026f, 0.000015f, 0.000010f, 0.000007f, 0.000005f,
+ 0.000013f, 0.000086f, 0.000185f, 0.000309f, 0.000552f, 0.000577f, 0.000796f, 0.000925f, 0.001251f, 0.001838f, 0.002878f, 0.004509f,
+ 0.007572f, 0.016617f, 0.054932f, 0.391602f, 0.912109f, 0.978516f, 0.996094f, 0.996094f, 0.996094f, 0.996582f, 0.996094f, 0.996094f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000095f, 0.000106f, 0.000112f, 0.000113f, 0.000115f, 0.000118f, 0.000118f,
+ 0.000119f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000099f, 0.000048f,
+ 0.000027f, 0.000017f, 0.000011f, 0.000008f, 0.000006f, 0.000004f, 0.000089f, 0.000182f, 0.000347f, 0.000495f, 0.000570f, 0.000777f,
+ 0.000922f, 0.001316f, 0.001831f, 0.003004f, 0.005028f, 0.010078f, 0.028183f, 0.161865f, 0.833496f, 0.972168f, 0.995117f, 0.995605f,
+ 0.995605f, 0.995117f, 0.995117f, 0.995605f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000074f,
+ 0.000093f, 0.000107f, 0.000111f, 0.000115f, 0.000116f, 0.000117f, 0.000118f, 0.000119f, 0.000119f, 0.000119f, 0.000120f, 0.000120f,
+ 0.000120f, 0.000120f, 0.000120f, 0.000121f, 0.000057f, 0.000032f, 0.000021f, 0.000013f, 0.000008f, 0.000006f, 0.000005f, 0.000034f,
+ 0.000159f, 0.000267f, 0.000514f, 0.000566f, 0.000714f, 0.000888f, 0.001348f, 0.001995f, 0.003302f, 0.006447f, 0.015945f, 0.069153f,
+ 0.646484f, 0.960449f, 0.994629f, 0.995117f, 0.994629f, 0.995117f, 0.994629f, 0.995117f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000080f, 0.000095f, 0.000102f, 0.000109f, 0.000114f, 0.000115f,
+ 0.000116f, 0.000118f, 0.000118f, 0.000119f, 0.000119f, 0.000119f, 0.000120f, 0.000120f, 0.000120f, 0.000077f, 0.000044f, 0.000025f,
+ 0.000015f, 0.000011f, 0.000007f, 0.000005f, 0.000004f, 0.000106f, 0.000244f, 0.000476f, 0.000561f, 0.000622f, 0.000893f, 0.001266f,
+ 0.001968f, 0.003990f, 0.009476f, 0.033234f, 0.342529f, 0.940918f, 0.993652f, 0.993652f, 0.993652f, 0.993652f, 0.993652f, 0.993652f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000046f, 0.000079f, 0.000093f, 0.000104f, 0.000110f, 0.000111f, 0.000113f, 0.000116f, 0.000117f, 0.000118f, 0.000118f, 0.000119f,
+ 0.000119f, 0.000119f, 0.000092f, 0.000050f, 0.000029f, 0.000019f, 0.000012f, 0.000009f, 0.000006f, 0.000004f, 0.000061f, 0.000188f,
+ 0.000324f, 0.000456f, 0.000525f, 0.000657f, 0.001371f, 0.002445f, 0.005634f, 0.017563f, 0.135986f, 0.902832f, 0.992188f, 0.992188f,
+ 0.992676f, 0.992188f, 0.992676f, 0.992188f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000038f, 0.000075f, 0.000092f, 0.000100f, 0.000105f,
+ 0.000111f, 0.000112f, 0.000114f, 0.000116f, 0.000117f, 0.000117f, 0.000118f, 0.000118f, 0.000074f, 0.000041f, 0.000024f, 0.000016f,
+ 0.000010f, 0.000007f, 0.000005f, 0.000033f, 0.000167f, 0.000423f, 0.000410f, 0.000413f, 0.000575f, 0.001446f, 0.003387f, 0.009644f,
+ 0.056183f, 0.817383f, 0.990234f, 0.990234f, 0.990234f, 0.990723f, 0.990234f, 0.990723f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000011f, 0.000067f, 0.000084f, 0.000096f, 0.000103f, 0.000108f, 0.000110f, 0.000113f, 0.000115f, 0.000115f,
+ 0.000116f, 0.000104f, 0.000057f, 0.000035f, 0.000021f, 0.000013f, 0.000009f, 0.000006f, 0.000054f, 0.000161f, 0.000317f, 0.000332f,
+ 0.000393f, 0.000723f, 0.001760f, 0.005203f, 0.025345f, 0.617676f, 0.987793f, 0.987793f, 0.987793f, 0.988281f, 0.988281f, 0.988281f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000017f, 0.000052f, 0.000075f,
+ 0.000091f, 0.000097f, 0.000105f, 0.000108f, 0.000111f, 0.000113f, 0.000114f, 0.000085f, 0.000050f, 0.000031f, 0.000018f, 0.000012f,
+ 0.000008f, 0.000005f, 0.000095f, 0.000314f, 0.000306f, 0.000363f, 0.000813f, 0.002583f, 0.011734f, 0.308105f, 0.983887f, 0.984375f,
+ 0.984375f, 0.984375f, 0.983887f, 0.983887f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000037f, 0.000065f, 0.000083f, 0.000093f, 0.000099f, 0.000105f, 0.000108f,
+ 0.000110f, 0.000082f, 0.000045f, 0.000027f, 0.000017f, 0.000011f, 0.000007f, 0.000114f, 0.000245f, 0.000209f, 0.000379f, 0.001151f,
+ 0.005260f, 0.107971f, 0.977539f, 0.979004f, 0.978027f, 0.978027f, 0.978027f, 0.978027f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000007f, 0.000045f, 0.000069f, 0.000084f, 0.000093f, 0.000099f, 0.000104f, 0.000076f, 0.000044f, 0.000026f, 0.000016f, 0.000010f,
+ 0.000012f, 0.000152f, 0.000179f, 0.000373f, 0.001760f, 0.035522f, 0.969238f, 0.968750f, 0.968750f, 0.968750f, 0.968750f, 0.968750f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000014f, 0.000050f, 0.000070f, 0.000082f,
+ 0.000092f, 0.000075f, 0.000044f, 0.000026f, 0.000015f, 0.000009f, 0.000121f, 0.000117f, 0.000611f, 0.010231f, 0.951172f, 0.951172f,
+ 0.951172f, 0.951172f, 0.950684f, 0.951660f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000020f, 0.000047f, 0.000069f, 0.000077f, 0.000042f, 0.000024f, 0.000013f, 0.000078f,
+ 0.000130f, 0.001914f, 0.915039f, 0.915527f, 0.915039f, 0.915527f, 0.916016f, 0.915039f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000017f, 0.000047f, 0.000040f, 0.000019f, 0.000035f, 0.000188f, 0.833984f, 0.833496f, 0.833496f, 0.834473f, 0.834473f, 0.833984f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000014f, 0.000007f, 0.642578f, 0.643555f,
+ 0.643066f, 0.643555f, 0.642578f, 0.642578f,
+ },
+ {
+ 0.113464f, 0.797852f, 0.930176f, 0.961914f, 0.974609f, 0.980469f, 0.984863f, 0.987793f, 0.989258f, 0.991211f, 0.992188f, 0.993164f,
+ 0.993652f, 0.994141f, 0.995117f, 0.995117f, 0.995605f, 0.996094f, 0.996582f, 0.996582f, 0.997070f, 0.997070f, 0.997070f, 0.997559f,
+ 0.997559f, 0.997559f, 0.998047f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.007183f, 0.058716f, 0.349609f, 0.784668f, 0.912598f, 0.952148f, 0.968262f, 0.977539f,
+ 0.981934f, 0.985352f, 0.988281f, 0.990234f, 0.991211f, 0.992188f, 0.993652f, 0.993652f, 0.994141f, 0.995117f, 0.995605f, 0.995605f,
+ 0.996094f, 0.996582f, 0.996582f, 0.997070f, 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.998047f, 0.998047f, 0.998047f, 0.998535f,
+ 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.002432f, 0.011818f, 0.039581f, 0.143677f,
+ 0.482910f, 0.800293f, 0.908691f, 0.947266f, 0.964844f, 0.974609f, 0.980469f, 0.984375f, 0.987305f, 0.989258f, 0.990723f, 0.991699f,
+ 0.992676f, 0.993652f, 0.994141f, 0.995117f, 0.995605f, 0.996094f, 0.996094f, 0.996582f, 0.996582f, 0.997070f, 0.997070f, 0.997559f,
+ 0.997559f, 0.997559f, 0.998047f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.001096f, 0.005062f, 0.012482f, 0.030151f, 0.079956f, 0.239014f, 0.581055f, 0.819824f, 0.909180f, 0.946289f, 0.963379f, 0.973145f,
+ 0.979492f, 0.983398f, 0.986328f, 0.988281f, 0.990234f, 0.991699f, 0.992188f, 0.993164f, 0.994141f, 0.994629f, 0.995605f, 0.996094f,
+ 0.996582f, 0.996582f, 0.996582f, 0.996582f, 0.997070f, 0.997559f, 0.997559f, 0.997559f, 0.998047f, 0.998047f, 0.998535f, 0.998535f,
+ 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000610f, 0.002434f, 0.005779f, 0.012207f, 0.023972f, 0.052765f, 0.129883f, 0.342773f,
+ 0.660156f, 0.841309f, 0.914062f, 0.947266f, 0.963379f, 0.973145f, 0.979004f, 0.982910f, 0.985840f, 0.987793f, 0.989746f, 0.991211f,
+ 0.992188f, 0.993164f, 0.994141f, 0.994629f, 0.995605f, 0.995605f, 0.996094f, 0.996582f, 0.996582f, 0.997070f, 0.997070f, 0.997559f,
+ 0.997559f, 0.997559f, 0.998047f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000397f, 0.001559f, 0.003397f, 0.006058f,
+ 0.011177f, 0.020355f, 0.039307f, 0.083130f, 0.196777f, 0.452148f, 0.724121f, 0.862305f, 0.920410f, 0.949219f, 0.964355f, 0.973145f,
+ 0.979004f, 0.982910f, 0.985840f, 0.988770f, 0.989258f, 0.991211f, 0.992188f, 0.993164f, 0.994141f, 0.994629f, 0.995605f, 0.995605f,
+ 0.996094f, 0.996582f, 0.996582f, 0.997070f, 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.998047f, 0.998047f, 0.998047f, 0.998535f,
+ 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000366f, 0.001097f, 0.002163f, 0.003523f, 0.006268f, 0.010941f, 0.017487f, 0.030930f, 0.058411f, 0.122925f, 0.281738f, 0.556152f,
+ 0.776367f, 0.881348f, 0.928223f, 0.951660f, 0.966309f, 0.973633f, 0.979492f, 0.983398f, 0.986328f, 0.988281f, 0.989746f, 0.991211f,
+ 0.992188f, 0.993164f, 0.994141f, 0.994629f, 0.995605f, 0.995605f, 0.996094f, 0.996582f, 0.996582f, 0.997070f, 0.997070f, 0.997559f,
+ 0.998047f, 0.998047f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000244f, 0.000728f, 0.001340f, 0.002533f, 0.003813f, 0.006081f, 0.009750f, 0.015419f,
+ 0.025177f, 0.044067f, 0.084473f, 0.179077f, 0.384033f, 0.649902f, 0.818848f, 0.897949f, 0.935547f, 0.956055f, 0.967285f, 0.975098f,
+ 0.980957f, 0.983887f, 0.986328f, 0.988281f, 0.990234f, 0.991699f, 0.992676f, 0.993652f, 0.994141f, 0.995117f, 0.995605f, 0.996094f,
+ 0.996094f, 0.996582f, 0.996582f, 0.997070f, 0.997070f, 0.997559f, 0.998047f, 0.998047f, 0.998047f, 0.998047f, 0.998535f, 0.998535f,
+ 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000244f, 0.000609f, 0.000854f, 0.001898f,
+ 0.002781f, 0.004246f, 0.006218f, 0.008835f, 0.013504f, 0.021362f, 0.035400f, 0.062347f, 0.121460f, 0.255127f, 0.495361f, 0.726562f,
+ 0.852539f, 0.912598f, 0.943359f, 0.959473f, 0.969238f, 0.976562f, 0.981445f, 0.984375f, 0.987305f, 0.988770f, 0.990234f, 0.991699f,
+ 0.992676f, 0.993652f, 0.994629f, 0.995117f, 0.995605f, 0.996094f, 0.996582f, 0.996582f, 0.996582f, 0.997070f, 0.997070f, 0.997559f,
+ 0.998047f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000244f, 0.000244f, 0.000731f, 0.001295f, 0.002159f, 0.003092f, 0.004051f, 0.005836f, 0.008560f, 0.011925f, 0.018585f, 0.029373f,
+ 0.048950f, 0.088013f, 0.174194f, 0.354980f, 0.604492f, 0.788086f, 0.880371f, 0.925293f, 0.950195f, 0.963867f, 0.972168f, 0.978027f,
+ 0.982422f, 0.985840f, 0.987793f, 0.990234f, 0.991699f, 0.992188f, 0.993164f, 0.994141f, 0.994629f, 0.995117f, 0.995605f, 0.996094f,
+ 0.996094f, 0.996582f, 0.997070f, 0.997070f, 0.997070f, 0.997559f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.999023f,
+ 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000114f, 0.000244f, 0.000709f, 0.001089f, 0.001580f, 0.002100f, 0.002848f, 0.004028f,
+ 0.005646f, 0.008232f, 0.011276f, 0.016647f, 0.024948f, 0.039215f, 0.067566f, 0.125244f, 0.249878f, 0.471436f, 0.698242f, 0.834961f,
+ 0.902344f, 0.937012f, 0.955078f, 0.967773f, 0.974609f, 0.979492f, 0.983887f, 0.987305f, 0.988770f, 0.990723f, 0.991699f, 0.992676f,
+ 0.993652f, 0.994141f, 0.994629f, 0.995117f, 0.995605f, 0.996094f, 0.996094f, 0.996582f, 0.997070f, 0.997070f, 0.997559f, 0.997559f,
+ 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000244f, 0.000480f, 0.001081f,
+ 0.001216f, 0.001684f, 0.002287f, 0.003113f, 0.004246f, 0.005711f, 0.007412f, 0.010658f, 0.014900f, 0.021408f, 0.033173f, 0.053711f,
+ 0.094299f, 0.179688f, 0.351807f, 0.591309f, 0.774902f, 0.871582f, 0.919922f, 0.946289f, 0.961426f, 0.971191f, 0.977051f, 0.981934f,
+ 0.984863f, 0.987305f, 0.989258f, 0.991211f, 0.992188f, 0.993164f, 0.994141f, 0.994629f, 0.995117f, 0.995117f, 0.995605f, 0.996094f,
+ 0.996094f, 0.996582f, 0.997070f, 0.997559f, 0.998047f, 0.997559f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000000f, 0.000364f, 0.000366f, 0.000729f, 0.001195f, 0.001218f, 0.001693f, 0.002209f, 0.003038f, 0.004192f, 0.005249f, 0.006981f,
+ 0.009926f, 0.013405f, 0.019165f, 0.028473f, 0.044250f, 0.073975f, 0.134521f, 0.260010f, 0.476562f, 0.696289f, 0.830566f, 0.898438f,
+ 0.933594f, 0.954102f, 0.966309f, 0.974609f, 0.979492f, 0.982910f, 0.986328f, 0.988281f, 0.989746f, 0.991699f, 0.992676f, 0.993652f,
+ 0.994141f, 0.995117f, 0.995117f, 0.995605f, 0.996094f, 0.996094f, 0.996582f, 0.997070f, 0.997070f, 0.997559f, 0.998047f, 0.998047f,
+ 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000226f, 0.000365f, 0.000488f, 0.000731f, 0.001090f, 0.001245f, 0.002028f,
+ 0.002169f, 0.003023f, 0.003952f, 0.005043f, 0.006790f, 0.009026f, 0.012276f, 0.016754f, 0.024628f, 0.037384f, 0.060120f, 0.104431f,
+ 0.196045f, 0.372803f, 0.604980f, 0.779785f, 0.872070f, 0.919922f, 0.945312f, 0.960938f, 0.970703f, 0.977539f, 0.980957f, 0.984863f,
+ 0.987305f, 0.989258f, 0.991211f, 0.992188f, 0.993164f, 0.993652f, 0.994629f, 0.995117f, 0.995605f, 0.996094f, 0.996582f, 0.996582f,
+ 0.997070f, 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.999023f,
+ 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000364f, 0.000487f,
+ 0.000488f, 0.000608f, 0.001092f, 0.001323f, 0.001909f, 0.002028f, 0.002829f, 0.003754f, 0.004940f, 0.006329f, 0.008850f, 0.011353f,
+ 0.015572f, 0.022110f, 0.032196f, 0.050293f, 0.083984f, 0.151978f, 0.288574f, 0.507812f, 0.715332f, 0.839844f, 0.902832f, 0.936035f,
+ 0.955566f, 0.966797f, 0.974609f, 0.979492f, 0.983887f, 0.986816f, 0.988281f, 0.989746f, 0.991699f, 0.992676f, 0.993652f, 0.994141f,
+ 0.994629f, 0.995605f, 0.995605f, 0.996582f, 0.996582f, 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.998047f, 0.998047f, 0.998047f,
+ 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000000f, 0.000000f, 0.000341f, 0.000486f, 0.000487f, 0.000591f, 0.000846f, 0.001213f, 0.001407f, 0.002018f, 0.002306f, 0.003119f,
+ 0.003736f, 0.004700f, 0.005936f, 0.007858f, 0.010498f, 0.013939f, 0.019913f, 0.028564f, 0.043060f, 0.069275f, 0.120972f, 0.225830f,
+ 0.416748f, 0.642090f, 0.798828f, 0.881836f, 0.924805f, 0.948730f, 0.962891f, 0.971191f, 0.978516f, 0.982422f, 0.985352f, 0.987793f,
+ 0.989746f, 0.991211f, 0.992676f, 0.993164f, 0.994141f, 0.994629f, 0.995117f, 0.995605f, 0.996582f, 0.996582f, 0.996582f, 0.997070f,
+ 0.997559f, 0.998047f, 0.998047f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000121f, 0.000122f, 0.000475f, 0.000486f, 0.000487f, 0.000714f, 0.000913f,
+ 0.001296f, 0.001350f, 0.001884f, 0.002163f, 0.002871f, 0.003702f, 0.004578f, 0.005573f, 0.007278f, 0.009819f, 0.013039f, 0.017883f,
+ 0.025589f, 0.037445f, 0.058655f, 0.099243f, 0.180542f, 0.338867f, 0.563965f, 0.751465f, 0.857422f, 0.912109f, 0.941406f, 0.958496f,
+ 0.968262f, 0.976074f, 0.980957f, 0.984375f, 0.986816f, 0.989258f, 0.990723f, 0.992188f, 0.993164f, 0.994141f, 0.994629f, 0.995117f,
+ 0.995605f, 0.996582f, 0.996582f, 0.997070f, 0.997070f, 0.997559f, 0.998047f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f,
+ 0.998535f, 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000122f, 0.000242f,
+ 0.000417f, 0.000607f, 0.000602f, 0.000644f, 0.001016f, 0.001223f, 0.001337f, 0.002010f, 0.002087f, 0.002752f, 0.003380f, 0.004486f,
+ 0.005760f, 0.007523f, 0.009048f, 0.012169f, 0.016312f, 0.022949f, 0.033295f, 0.050812f, 0.082886f, 0.146851f, 0.275635f, 0.486572f,
+ 0.696777f, 0.828613f, 0.896484f, 0.933594f, 0.953613f, 0.965820f, 0.973633f, 0.979980f, 0.983887f, 0.986328f, 0.988770f, 0.990723f,
+ 0.992188f, 0.993164f, 0.993652f, 0.994141f, 0.995117f, 0.995605f, 0.996094f, 0.996582f, 0.996582f, 0.997559f, 0.997559f, 0.997559f,
+ 0.998047f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000262f, 0.000463f, 0.000603f, 0.000665f, 0.000716f, 0.001069f, 0.001322f, 0.001538f,
+ 0.001895f, 0.002293f, 0.003120f, 0.003323f, 0.004166f, 0.005638f, 0.006828f, 0.008942f, 0.011368f, 0.015465f, 0.021057f, 0.029663f,
+ 0.044861f, 0.070923f, 0.123169f, 0.228149f, 0.416504f, 0.640137f, 0.797363f, 0.880859f, 0.924805f, 0.948730f, 0.963379f, 0.971680f,
+ 0.978516f, 0.982422f, 0.985840f, 0.988281f, 0.990723f, 0.991699f, 0.992676f, 0.993652f, 0.994141f, 0.995117f, 0.995117f, 0.996094f,
+ 0.996582f, 0.997070f, 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000120f, 0.000172f, 0.000243f, 0.000365f, 0.000475f, 0.000607f,
+ 0.000608f, 0.000609f, 0.001013f, 0.001424f, 0.001456f, 0.001904f, 0.002411f, 0.002903f, 0.003145f, 0.004314f, 0.004944f, 0.006607f,
+ 0.008156f, 0.010719f, 0.014297f, 0.018906f, 0.027069f, 0.040070f, 0.062103f, 0.104858f, 0.191162f, 0.355469f, 0.581543f, 0.762695f,
+ 0.863281f, 0.915039f, 0.943848f, 0.960449f, 0.970703f, 0.977051f, 0.981445f, 0.985840f, 0.987793f, 0.989746f, 0.991211f, 0.992676f,
+ 0.993652f, 0.994141f, 0.995117f, 0.995605f, 0.996094f, 0.996094f, 0.997070f, 0.997070f, 0.998047f, 0.997559f, 0.998047f, 0.998535f,
+ 0.998535f, 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000000f, 0.000000f, 0.000096f,
+ 0.000239f, 0.000241f, 0.000336f, 0.000482f, 0.000719f, 0.000729f, 0.000831f, 0.001049f, 0.001552f, 0.001576f, 0.001710f, 0.002373f,
+ 0.002846f, 0.003254f, 0.004051f, 0.005035f, 0.006405f, 0.007706f, 0.009987f, 0.013092f, 0.017715f, 0.024872f, 0.035980f, 0.055328f,
+ 0.091248f, 0.163330f, 0.305664f, 0.524902f, 0.726562f, 0.845215f, 0.906250f, 0.938965f, 0.957031f, 0.969238f, 0.976074f, 0.981445f,
+ 0.984863f, 0.987305f, 0.989258f, 0.991211f, 0.992188f, 0.993164f, 0.994141f, 0.995117f, 0.995605f, 0.996094f, 0.996582f, 0.996582f,
+ 0.997559f, 0.997559f, 0.997559f, 0.998047f, 0.998535f, 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000118f, 0.000120f, 0.000351f, 0.000364f, 0.000421f, 0.000480f, 0.000606f, 0.000728f, 0.000852f,
+ 0.001175f, 0.001535f, 0.001673f, 0.001671f, 0.002277f, 0.002743f, 0.003220f, 0.003922f, 0.004868f, 0.005951f, 0.007488f, 0.009430f,
+ 0.012527f, 0.016266f, 0.022964f, 0.033142f, 0.049805f, 0.080688f, 0.141846f, 0.265625f, 0.473145f, 0.688477f, 0.825684f, 0.897949f,
+ 0.934082f, 0.954102f, 0.966797f, 0.975098f, 0.980469f, 0.984375f, 0.987305f, 0.989258f, 0.991211f, 0.992676f, 0.993164f, 0.993652f,
+ 0.995117f, 0.995605f, 0.996094f, 0.996582f, 0.997070f, 0.997070f, 0.997559f, 0.998047f, 0.998535f, 0.998535f, 0.999512f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999512f, 0.999023f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000058f, 0.000235f, 0.000360f, 0.000243f,
+ 0.000440f, 0.000583f, 0.000847f, 0.000851f, 0.000852f, 0.001189f, 0.001411f, 0.001645f, 0.001898f, 0.002417f, 0.002617f, 0.003435f,
+ 0.003695f, 0.004616f, 0.005733f, 0.007278f, 0.009216f, 0.012016f, 0.015701f, 0.021561f, 0.030396f, 0.045746f, 0.073120f, 0.125732f,
+ 0.233521f, 0.428223f, 0.653320f, 0.807617f, 0.887695f, 0.929688f, 0.951660f, 0.965820f, 0.974121f, 0.980469f, 0.984375f, 0.986816f,
+ 0.989746f, 0.991211f, 0.992676f, 0.993164f, 0.994141f, 0.995117f, 0.995605f, 0.996582f, 0.996582f, 0.997070f, 0.997559f, 0.998047f,
+ 0.998047f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000237f, 0.000237f, 0.000362f, 0.000365f, 0.000558f, 0.000814f, 0.000727f, 0.000729f, 0.000935f, 0.001189f, 0.001403f,
+ 0.001569f, 0.001989f, 0.002216f, 0.002533f, 0.003307f, 0.003906f, 0.004463f, 0.005646f, 0.006908f, 0.008980f, 0.011230f, 0.014755f,
+ 0.020020f, 0.028320f, 0.041931f, 0.065979f, 0.113098f, 0.209229f, 0.389648f, 0.620605f, 0.789551f, 0.879395f, 0.924805f, 0.950684f,
+ 0.964844f, 0.974121f, 0.979980f, 0.983398f, 0.987305f, 0.989258f, 0.991211f, 0.992676f, 0.993652f, 0.993652f, 0.995117f, 0.995605f,
+ 0.996582f, 0.997070f, 0.997559f, 0.998047f, 0.998047f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000120f, 0.000121f, 0.000241f, 0.000486f, 0.000575f, 0.000707f,
+ 0.000726f, 0.000971f, 0.000849f, 0.000966f, 0.001350f, 0.001660f, 0.001678f, 0.002224f, 0.002483f, 0.003197f, 0.003611f, 0.004200f,
+ 0.005318f, 0.006744f, 0.008476f, 0.010506f, 0.014145f, 0.019089f, 0.026627f, 0.039001f, 0.061096f, 0.103333f, 0.189819f, 0.358887f,
+ 0.591309f, 0.773438f, 0.872559f, 0.922363f, 0.948730f, 0.963867f, 0.973145f, 0.979492f, 0.983887f, 0.986816f, 0.989258f, 0.991211f,
+ 0.992188f, 0.993164f, 0.994629f, 0.995117f, 0.995605f, 0.996582f, 0.997070f, 0.997559f, 0.998047f, 0.998047f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000175f, 0.000361f,
+ 0.000481f, 0.000485f, 0.000364f, 0.000562f, 0.000703f, 0.000827f, 0.000842f, 0.000972f, 0.001172f, 0.001321f, 0.001675f, 0.001684f,
+ 0.002153f, 0.002455f, 0.003122f, 0.003391f, 0.004177f, 0.005314f, 0.006325f, 0.007896f, 0.010368f, 0.013527f, 0.018082f, 0.025162f,
+ 0.037140f, 0.057343f, 0.095886f, 0.175659f, 0.334473f, 0.567871f, 0.760742f, 0.866699f, 0.919922f, 0.947754f, 0.963379f, 0.972656f,
+ 0.979492f, 0.984375f, 0.987305f, 0.989258f, 0.991211f, 0.992676f, 0.993652f, 0.994629f, 0.995117f, 0.996094f, 0.996582f, 0.997070f,
+ 0.998047f, 0.998047f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000325f, 0.000311f, 0.000243f, 0.000484f, 0.000486f, 0.000536f, 0.000698f, 0.000723f, 0.000844f,
+ 0.000972f, 0.001081f, 0.001312f, 0.001658f, 0.001914f, 0.001932f, 0.002390f, 0.003017f, 0.003668f, 0.004353f, 0.005199f, 0.006336f,
+ 0.007812f, 0.009972f, 0.012802f, 0.017029f, 0.024200f, 0.035034f, 0.053833f, 0.090027f, 0.164185f, 0.316162f, 0.549805f, 0.751465f,
+ 0.863281f, 0.918457f, 0.947266f, 0.963379f, 0.974121f, 0.979492f, 0.984375f, 0.987793f, 0.989746f, 0.991699f, 0.993164f, 0.994141f,
+ 0.995117f, 0.995605f, 0.996094f, 0.997070f, 0.997559f, 0.997559f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000231f, 0.000453f, 0.000480f, 0.000484f,
+ 0.000485f, 0.000486f, 0.000917f, 0.000963f, 0.000969f, 0.000970f, 0.001043f, 0.001288f, 0.001523f, 0.001684f, 0.001885f, 0.002464f,
+ 0.002531f, 0.003565f, 0.004124f, 0.004745f, 0.006077f, 0.007580f, 0.009605f, 0.012634f, 0.016953f, 0.023346f, 0.033386f, 0.051697f,
+ 0.085632f, 0.156250f, 0.303955f, 0.537598f, 0.746582f, 0.860840f, 0.918457f, 0.947754f, 0.963867f, 0.973633f, 0.979980f, 0.984863f,
+ 0.987793f, 0.990234f, 0.991699f, 0.993652f, 0.994141f, 0.995117f, 0.996094f, 0.996582f, 0.997070f, 0.997559f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000235f, 0.000239f, 0.000359f, 0.000484f, 0.000485f, 0.000486f, 0.000628f, 0.000957f, 0.000967f, 0.000969f, 0.001065f,
+ 0.001288f, 0.001602f, 0.001850f, 0.001995f, 0.002409f, 0.002523f, 0.003462f, 0.003838f, 0.004993f, 0.005917f, 0.007233f, 0.009338f,
+ 0.012230f, 0.015610f, 0.022415f, 0.032288f, 0.049805f, 0.082947f, 0.151489f, 0.296631f, 0.532715f, 0.745117f, 0.862793f, 0.919434f,
+ 0.948242f, 0.964844f, 0.974609f, 0.980957f, 0.985352f, 0.988281f, 0.990723f, 0.992676f, 0.994141f, 0.994629f, 0.995605f, 0.996094f,
+ 0.996582f, 0.997070f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000187f, 0.000437f, 0.000473f, 0.000483f, 0.000485f, 0.000606f,
+ 0.000583f, 0.000711f, 0.000772f, 0.000968f, 0.001107f, 0.001287f, 0.001434f, 0.001662f, 0.001984f, 0.002449f, 0.002634f, 0.003145f,
+ 0.003777f, 0.004410f, 0.005722f, 0.007114f, 0.008926f, 0.011696f, 0.016006f, 0.021683f, 0.031342f, 0.048309f, 0.080750f, 0.149170f,
+ 0.294678f, 0.534668f, 0.749512f, 0.866211f, 0.922363f, 0.950684f, 0.966309f, 0.975586f, 0.981934f, 0.985840f, 0.989258f, 0.991699f,
+ 0.992676f, 0.994141f, 0.994629f, 0.996094f, 0.996582f, 0.997070f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000247f,
+ 0.000238f, 0.000407f, 0.000482f, 0.000484f, 0.000604f, 0.000869f, 0.000909f, 0.000721f, 0.000955f, 0.001000f, 0.001241f, 0.001342f,
+ 0.001655f, 0.001721f, 0.002329f, 0.002623f, 0.003086f, 0.003677f, 0.004349f, 0.005600f, 0.006962f, 0.008835f, 0.011581f, 0.015274f,
+ 0.021286f, 0.030884f, 0.047760f, 0.079895f, 0.148926f, 0.298584f, 0.543945f, 0.758301f, 0.872559f, 0.925781f, 0.953125f, 0.967773f,
+ 0.977051f, 0.982910f, 0.986816f, 0.989258f, 0.991211f, 0.993164f, 0.994629f, 0.995605f, 0.996094f, 0.996582f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000237f, 0.000410f, 0.000472f, 0.000481f, 0.000483f, 0.000485f, 0.000687f, 0.000913f,
+ 0.000956f, 0.000966f, 0.000997f, 0.001341f, 0.001415f, 0.001813f, 0.002029f, 0.002043f, 0.002594f, 0.003210f, 0.003641f, 0.004734f,
+ 0.005356f, 0.006882f, 0.008675f, 0.011360f, 0.014816f, 0.020920f, 0.030380f, 0.047485f, 0.080200f, 0.151733f, 0.308105f, 0.561523f,
+ 0.772949f, 0.881348f, 0.931152f, 0.956055f, 0.969727f, 0.978516f, 0.983887f, 0.987793f, 0.990234f, 0.992188f, 0.993652f, 0.994629f,
+ 0.995605f, 0.996094f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000254f, 0.000345f, 0.000468f,
+ 0.000585f, 0.000482f, 0.000603f, 0.000485f, 0.000862f, 0.000928f, 0.000965f, 0.001174f, 0.001162f, 0.001405f, 0.001761f, 0.002016f,
+ 0.002182f, 0.002733f, 0.002831f, 0.003504f, 0.004456f, 0.005440f, 0.006775f, 0.008553f, 0.011055f, 0.014694f, 0.020859f, 0.030334f,
+ 0.047852f, 0.081970f, 0.157593f, 0.325439f, 0.586914f, 0.790527f, 0.890137f, 0.936523f, 0.959473f, 0.973145f, 0.980469f, 0.985352f,
+ 0.988770f, 0.990723f, 0.992676f, 0.994141f, 0.995117f, 0.996094f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000241f, 0.000237f, 0.000340f, 0.000457f, 0.000580f, 0.000481f, 0.000601f, 0.000605f, 0.000742f, 0.000951f, 0.000953f,
+ 0.001131f, 0.001257f, 0.001396f, 0.001730f, 0.001936f, 0.002102f, 0.002682f, 0.002762f, 0.003733f, 0.004425f, 0.005344f, 0.006516f,
+ 0.008354f, 0.010971f, 0.014793f, 0.020859f, 0.030640f, 0.048859f, 0.085144f, 0.167358f, 0.350586f, 0.620117f, 0.811035f, 0.900391f,
+ 0.942383f, 0.963379f, 0.975098f, 0.981934f, 0.986816f, 0.989746f, 0.992188f, 0.993164f, 0.994629f, 0.995117f, 0.998535f, 0.998535f,
+ 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000131f, 0.000301f, 0.000430f, 0.000470f, 0.000593f,
+ 0.000571f, 0.000587f, 0.000693f, 0.000906f, 0.000959f, 0.000965f, 0.001094f, 0.001364f, 0.001522f, 0.001783f, 0.002094f, 0.002615f,
+ 0.003038f, 0.003365f, 0.004307f, 0.005135f, 0.006493f, 0.008347f, 0.011055f, 0.014824f, 0.020844f, 0.031204f, 0.050507f, 0.090027f,
+ 0.182129f, 0.385498f, 0.659668f, 0.834473f, 0.913086f, 0.949219f, 0.967285f, 0.978027f, 0.983887f, 0.987793f, 0.991211f, 0.992188f,
+ 0.994141f, 0.995117f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.000000f, 0.000000f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000189f, 0.000122f, 0.000122f,
+ 0.000241f, 0.000295f, 0.000425f, 0.000457f, 0.000592f, 0.000481f, 0.000603f, 0.000697f, 0.000926f, 0.000943f, 0.000960f, 0.001022f,
+ 0.001435f, 0.001632f, 0.001658f, 0.002024f, 0.002468f, 0.003010f, 0.003210f, 0.004124f, 0.005219f, 0.006351f, 0.008163f, 0.010933f,
+ 0.015030f, 0.021271f, 0.032257f, 0.053009f, 0.097534f, 0.203003f, 0.432373f, 0.704102f, 0.858887f, 0.924805f, 0.955566f, 0.970703f,
+ 0.979492f, 0.985840f, 0.989258f, 0.991699f, 0.993164f, 0.995117f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f,
+ 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000214f, 0.000201f, 0.000239f, 0.000241f, 0.000383f, 0.000461f, 0.000474f, 0.000479f, 0.000598f,
+ 0.000736f, 0.000905f, 0.000947f, 0.001072f, 0.001180f, 0.001376f, 0.001572f, 0.001752f, 0.001900f, 0.002258f, 0.002792f, 0.003487f,
+ 0.004055f, 0.005161f, 0.006424f, 0.008209f, 0.010933f, 0.015030f, 0.021942f, 0.033630f, 0.056671f, 0.107666f, 0.233276f, 0.492188f,
+ 0.752441f, 0.881836f, 0.937012f, 0.961914f, 0.975098f, 0.982910f, 0.987305f, 0.990234f, 0.992676f, 0.994629f, 0.998535f, 0.998535f,
+ 0.998535f, 0.998047f, 0.998535f, 0.998535f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000132f, 0.000224f, 0.000129f, 0.000237f, 0.000240f,
+ 0.000337f, 0.000430f, 0.000468f, 0.000579f, 0.000593f, 0.000602f, 0.000881f, 0.000936f, 0.000956f, 0.000963f, 0.001282f, 0.001519f,
+ 0.001607f, 0.001852f, 0.002150f, 0.002737f, 0.003508f, 0.003990f, 0.005077f, 0.006516f, 0.008179f, 0.011185f, 0.015511f, 0.022446f,
+ 0.035614f, 0.061859f, 0.122681f, 0.275879f, 0.563965f, 0.798828f, 0.903809f, 0.946777f, 0.967773f, 0.978516f, 0.984863f, 0.988770f,
+ 0.991699f, 0.993652f, 0.998047f, 0.998047f, 0.998047f, 0.998047f, 0.998047f, 0.998047f, 0.000000f, 0.000000f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000149f, 0.000122f, 0.000207f, 0.000371f, 0.000430f, 0.000573f, 0.000591f, 0.000598f, 0.000597f, 0.000804f,
+ 0.000901f, 0.000948f, 0.001053f, 0.001083f, 0.001376f, 0.001584f, 0.001878f, 0.002331f, 0.002529f, 0.003376f, 0.003944f, 0.005230f,
+ 0.006504f, 0.008537f, 0.011459f, 0.015747f, 0.024002f, 0.038361f, 0.069458f, 0.144409f, 0.336914f, 0.644043f, 0.841797f, 0.922363f,
+ 0.957520f, 0.972656f, 0.981934f, 0.987305f, 0.990234f, 0.993164f, 0.998047f, 0.998047f, 0.998047f, 0.998047f, 0.998047f, 0.998047f,
+ 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000230f, 0.000234f, 0.000235f, 0.000268f, 0.000400f,
+ 0.000448f, 0.000585f, 0.000590f, 0.000599f, 0.000641f, 0.000788f, 0.000930f, 0.000968f, 0.001107f, 0.001251f, 0.001656f, 0.001701f,
+ 0.002047f, 0.002691f, 0.003437f, 0.003998f, 0.004829f, 0.006329f, 0.008492f, 0.011757f, 0.016525f, 0.025345f, 0.042297f, 0.080200f,
+ 0.177490f, 0.420654f, 0.724121f, 0.878906f, 0.938965f, 0.964355f, 0.977539f, 0.984863f, 0.989746f, 0.992188f, 0.997559f, 0.997559f,
+ 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000214f, 0.000235f, 0.000228f, 0.000240f, 0.000429f, 0.000439f, 0.000574f, 0.000654f, 0.000583f, 0.000493f, 0.000788f, 0.000813f,
+ 0.000947f, 0.001062f, 0.001225f, 0.001569f, 0.001721f, 0.002048f, 0.002844f, 0.002979f, 0.003902f, 0.004997f, 0.006454f, 0.008698f,
+ 0.012192f, 0.018143f, 0.027634f, 0.047913f, 0.095886f, 0.228394f, 0.526855f, 0.796875f, 0.910156f, 0.953125f, 0.973145f, 0.982422f,
+ 0.987793f, 0.991699f, 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.000000f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000205f, 0.000236f, 0.000232f, 0.000299f, 0.000446f, 0.000417f,
+ 0.000466f, 0.000580f, 0.000508f, 0.000710f, 0.000800f, 0.000940f, 0.000954f, 0.001228f, 0.001496f, 0.001631f, 0.002043f, 0.002798f,
+ 0.003359f, 0.004139f, 0.004951f, 0.006680f, 0.008995f, 0.012764f, 0.018860f, 0.030823f, 0.056061f, 0.120911f, 0.307617f, 0.645508f,
+ 0.855957f, 0.934082f, 0.964355f, 0.978516f, 0.985840f, 0.990234f, 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.997559f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000226f,
+ 0.000122f, 0.000226f, 0.000373f, 0.000272f, 0.000325f, 0.000460f, 0.000471f, 0.000477f, 0.000673f, 0.000877f, 0.000929f, 0.000951f,
+ 0.001129f, 0.001446f, 0.001614f, 0.002096f, 0.002619f, 0.002939f, 0.003941f, 0.005363f, 0.006844f, 0.009491f, 0.013596f, 0.020905f,
+ 0.035370f, 0.068420f, 0.161743f, 0.426270f, 0.755859f, 0.900879f, 0.952148f, 0.973145f, 0.983398f, 0.989746f, 0.997070f, 0.997070f,
+ 0.997070f, 0.997070f, 0.997070f, 0.997070f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000111f, 0.000236f, 0.000297f, 0.000368f, 0.000449f, 0.000467f,
+ 0.000588f, 0.000641f, 0.000813f, 0.000924f, 0.001035f, 0.001124f, 0.001348f, 0.001764f, 0.001922f, 0.002439f, 0.003160f, 0.004005f,
+ 0.005280f, 0.007107f, 0.010109f, 0.014748f, 0.023148f, 0.041595f, 0.088440f, 0.232910f, 0.578125f, 0.841797f, 0.933594f, 0.965820f,
+ 0.980469f, 0.987305f, 0.996582f, 0.996582f, 0.996582f, 0.996582f, 0.996582f, 0.996582f, 0.000000f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000014f, 0.000011f, 0.000116f,
+ 0.000148f, 0.000128f, 0.000369f, 0.000418f, 0.000563f, 0.000470f, 0.000592f, 0.000776f, 0.000901f, 0.000937f, 0.001112f, 0.001348f,
+ 0.001743f, 0.001904f, 0.002470f, 0.003187f, 0.003986f, 0.005360f, 0.007557f, 0.010674f, 0.016068f, 0.026871f, 0.051666f, 0.122925f,
+ 0.356445f, 0.729492f, 0.901855f, 0.955078f, 0.976074f, 0.985840f, 0.996094f, 0.996582f, 0.996094f, 0.996582f, 0.996094f, 0.996582f,
+ 0.000122f, 0.000122f, 0.000121f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000028f, 0.000019f, 0.000014f, 0.000011f, 0.000033f, 0.000118f, 0.000247f, 0.000305f, 0.000412f, 0.000447f, 0.000576f, 0.000587f,
+ 0.000693f, 0.000850f, 0.000949f, 0.001083f, 0.001319f, 0.001557f, 0.001957f, 0.002424f, 0.003340f, 0.004417f, 0.005688f, 0.007774f,
+ 0.011497f, 0.017731f, 0.032257f, 0.068604f, 0.189575f, 0.541992f, 0.843262f, 0.938477f, 0.970703f, 0.983887f, 0.995605f, 0.996094f,
+ 0.996094f, 0.996094f, 0.996094f, 0.996094f, 0.000121f, 0.000118f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f,
+ 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f,
+ 0.000121f, 0.000121f, 0.000121f, 0.000067f, 0.000042f, 0.000028f, 0.000020f, 0.000015f, 0.000066f, 0.000009f, 0.000101f, 0.000118f,
+ 0.000260f, 0.000358f, 0.000520f, 0.000456f, 0.000563f, 0.000711f, 0.000872f, 0.000980f, 0.001059f, 0.001309f, 0.001699f, 0.002066f,
+ 0.002708f, 0.003248f, 0.004166f, 0.005836f, 0.008224f, 0.012619f, 0.021484f, 0.041260f, 0.101074f, 0.323486f, 0.733887f, 0.912109f,
+ 0.962402f, 0.980957f, 0.995117f, 0.995117f, 0.995605f, 0.995605f, 0.995605f, 0.995605f, 0.000000f, 0.000000f, 0.000119f, 0.000119f,
+ 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f,
+ 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000105f, 0.000067f, 0.000042f, 0.000029f, 0.000022f,
+ 0.000015f, 0.000011f, 0.000040f, 0.000033f, 0.000153f, 0.000204f, 0.000313f, 0.000501f, 0.000554f, 0.000575f, 0.000585f, 0.000778f,
+ 0.000925f, 0.000980f, 0.001245f, 0.001634f, 0.001989f, 0.002413f, 0.003433f, 0.004028f, 0.005989f, 0.008911f, 0.014374f, 0.026443f,
+ 0.057495f, 0.170166f, 0.549805f, 0.864746f, 0.951172f, 0.977051f, 0.994629f, 0.994629f, 0.994629f, 0.994629f, 0.995605f, 0.994629f,
+ 0.000000f, 0.000046f, 0.000088f, 0.000118f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000121f, 0.000121f, 0.000121f, 0.000121f,
+ 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f,
+ 0.000108f, 0.000069f, 0.000047f, 0.000030f, 0.000022f, 0.000016f, 0.000012f, 0.000052f, 0.000081f, 0.000100f, 0.000184f, 0.000226f,
+ 0.000400f, 0.000467f, 0.000452f, 0.000597f, 0.000807f, 0.000895f, 0.000942f, 0.001219f, 0.001611f, 0.002022f, 0.002352f, 0.003222f,
+ 0.004177f, 0.006481f, 0.009850f, 0.017517f, 0.034668f, 0.090637f, 0.331055f, 0.776367f, 0.932129f, 0.972656f, 0.994141f, 0.994141f,
+ 0.994629f, 0.994141f, 0.994629f, 0.994629f, 0.000000f, 0.000000f, 0.000000f, 0.000107f, 0.000115f, 0.000112f, 0.000119f, 0.000118f,
+ 0.000119f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f,
+ 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000117f, 0.000072f, 0.000049f, 0.000032f, 0.000023f, 0.000017f, 0.000013f,
+ 0.000011f, 0.000008f, 0.000075f, 0.000151f, 0.000207f, 0.000305f, 0.000509f, 0.000499f, 0.000560f, 0.000704f, 0.000863f, 0.000917f,
+ 0.001220f, 0.001505f, 0.001740f, 0.002174f, 0.003153f, 0.004559f, 0.007095f, 0.011826f, 0.022247f, 0.051147f, 0.173462f, 0.618652f,
+ 0.902344f, 0.966309f, 0.993164f, 0.993652f, 0.992676f, 0.992676f, 0.993164f, 0.993164f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000060f, 0.000102f, 0.000113f, 0.000117f, 0.000118f, 0.000119f, 0.000119f, 0.000119f, 0.000120f, 0.000120f, 0.000120f,
+ 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000078f,
+ 0.000052f, 0.000038f, 0.000027f, 0.000019f, 0.000015f, 0.000011f, 0.000054f, 0.000007f, 0.000085f, 0.000108f, 0.000258f, 0.000466f,
+ 0.000533f, 0.000560f, 0.000662f, 0.000849f, 0.000856f, 0.000965f, 0.001180f, 0.001678f, 0.002075f, 0.003193f, 0.005016f, 0.008095f,
+ 0.014343f, 0.030899f, 0.090820f, 0.401367f, 0.848145f, 0.956543f, 0.992188f, 0.992188f, 0.992188f, 0.992676f, 0.991699f, 0.992188f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000059f, 0.000096f, 0.000107f, 0.000112f, 0.000115f, 0.000116f,
+ 0.000117f, 0.000118f, 0.000118f, 0.000119f, 0.000119f, 0.000119f, 0.000119f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000120f,
+ 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000088f, 0.000059f, 0.000041f, 0.000031f, 0.000022f, 0.000017f, 0.000013f, 0.000010f,
+ 0.000056f, 0.000091f, 0.000183f, 0.000201f, 0.000309f, 0.000506f, 0.000547f, 0.000525f, 0.000629f, 0.000613f, 0.000817f, 0.001012f,
+ 0.001640f, 0.002420f, 0.003588f, 0.005520f, 0.009453f, 0.019119f, 0.050415f, 0.214722f, 0.751465f, 0.943848f, 0.990723f, 0.990723f,
+ 0.991211f, 0.991211f, 0.991211f, 0.991211f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000055f, 0.000095f, 0.000103f, 0.000105f, 0.000112f, 0.000114f, 0.000115f, 0.000117f, 0.000117f, 0.000117f, 0.000118f,
+ 0.000118f, 0.000119f, 0.000119f, 0.000119f, 0.000119f, 0.000119f, 0.000119f, 0.000120f, 0.000120f, 0.000105f, 0.000069f, 0.000048f,
+ 0.000035f, 0.000025f, 0.000019f, 0.000015f, 0.000011f, 0.000014f, 0.000008f, 0.000071f, 0.000193f, 0.000311f, 0.000315f, 0.000524f,
+ 0.000483f, 0.000558f, 0.000591f, 0.000705f, 0.000950f, 0.001389f, 0.002428f, 0.003494f, 0.006321f, 0.012306f, 0.029480f, 0.108948f,
+ 0.581543f, 0.924316f, 0.989746f, 0.989746f, 0.989258f, 0.989746f, 0.989258f, 0.989746f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000069f, 0.000096f, 0.000103f, 0.000107f,
+ 0.000109f, 0.000112f, 0.000113f, 0.000115f, 0.000115f, 0.000116f, 0.000117f, 0.000117f, 0.000118f, 0.000118f, 0.000118f, 0.000118f,
+ 0.000119f, 0.000119f, 0.000119f, 0.000084f, 0.000061f, 0.000042f, 0.000031f, 0.000023f, 0.000018f, 0.000014f, 0.000011f, 0.000009f,
+ 0.000095f, 0.000127f, 0.000223f, 0.000402f, 0.000432f, 0.000399f, 0.000494f, 0.000535f, 0.000557f, 0.000933f, 0.001474f, 0.002300f,
+ 0.004192f, 0.007919f, 0.017838f, 0.057068f, 0.360840f, 0.890625f, 0.986816f, 0.987793f, 0.987305f, 0.987305f, 0.987793f, 0.987305f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000035f, 0.000041f, 0.000088f, 0.000098f, 0.000103f, 0.000106f, 0.000110f, 0.000110f, 0.000113f, 0.000113f,
+ 0.000115f, 0.000116f, 0.000116f, 0.000117f, 0.000117f, 0.000117f, 0.000117f, 0.000118f, 0.000111f, 0.000074f, 0.000053f, 0.000038f,
+ 0.000029f, 0.000022f, 0.000016f, 0.000013f, 0.000010f, 0.000008f, 0.000073f, 0.000152f, 0.000296f, 0.000369f, 0.000365f, 0.000437f,
+ 0.000507f, 0.000661f, 0.000876f, 0.001451f, 0.002531f, 0.004898f, 0.010384f, 0.031113f, 0.183838f, 0.833008f, 0.984375f, 0.984863f,
+ 0.984863f, 0.984375f, 0.984863f, 0.984863f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000024f, 0.000044f, 0.000073f,
+ 0.000087f, 0.000097f, 0.000102f, 0.000105f, 0.000108f, 0.000110f, 0.000111f, 0.000113f, 0.000114f, 0.000114f, 0.000115f, 0.000115f,
+ 0.000116f, 0.000116f, 0.000101f, 0.000070f, 0.000052f, 0.000037f, 0.000027f, 0.000021f, 0.000016f, 0.000013f, 0.000010f, 0.000008f,
+ 0.000083f, 0.000183f, 0.000352f, 0.000355f, 0.000362f, 0.000365f, 0.000528f, 0.000790f, 0.001469f, 0.003029f, 0.005970f, 0.017242f,
+ 0.089050f, 0.728516f, 0.980957f, 0.981445f, 0.981445f, 0.980957f, 0.980957f, 0.981445f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000033f, 0.000041f, 0.000073f, 0.000083f, 0.000088f, 0.000097f, 0.000102f,
+ 0.000105f, 0.000108f, 0.000108f, 0.000111f, 0.000112f, 0.000113f, 0.000113f, 0.000114f, 0.000097f, 0.000068f, 0.000049f, 0.000038f,
+ 0.000028f, 0.000021f, 0.000016f, 0.000013f, 0.000010f, 0.000056f, 0.000151f, 0.000243f, 0.000264f, 0.000221f, 0.000328f, 0.000449f,
+ 0.000850f, 0.001612f, 0.003340f, 0.009361f, 0.043121f, 0.548340f, 0.976074f, 0.976562f, 0.975586f, 0.976074f, 0.976074f, 0.976562f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000019f, 0.000052f, 0.000065f, 0.000077f, 0.000088f, 0.000094f, 0.000098f, 0.000100f, 0.000104f, 0.000106f, 0.000108f,
+ 0.000109f, 0.000110f, 0.000095f, 0.000069f, 0.000052f, 0.000037f, 0.000028f, 0.000021f, 0.000017f, 0.000013f, 0.000025f, 0.000063f,
+ 0.000195f, 0.000233f, 0.000205f, 0.000264f, 0.000401f, 0.000789f, 0.001532f, 0.004520f, 0.020844f, 0.321289f, 0.969238f, 0.968750f,
+ 0.969238f, 0.968750f, 0.969238f, 0.969238f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000018f, 0.000039f, 0.000053f,
+ 0.000066f, 0.000079f, 0.000086f, 0.000090f, 0.000096f, 0.000100f, 0.000102f, 0.000105f, 0.000098f, 0.000074f, 0.000053f, 0.000041f,
+ 0.000031f, 0.000023f, 0.000017f, 0.000013f, 0.000028f, 0.000139f, 0.000189f, 0.000179f, 0.000219f, 0.000333f, 0.000840f, 0.002119f,
+ 0.009193f, 0.144775f, 0.958496f, 0.958496f, 0.958008f, 0.958496f, 0.958008f, 0.958008f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000025f, 0.000040f, 0.000052f, 0.000067f, 0.000077f, 0.000082f,
+ 0.000089f, 0.000093f, 0.000097f, 0.000079f, 0.000059f, 0.000044f, 0.000033f, 0.000024f, 0.000018f, 0.000014f, 0.000034f, 0.000084f,
+ 0.000157f, 0.000199f, 0.000309f, 0.000817f, 0.003424f, 0.054901f, 0.940918f, 0.940918f, 0.940918f, 0.940918f, 0.941406f, 0.940430f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000021f, 0.000040f, 0.000054f, 0.000063f, 0.000072f, 0.000078f, 0.000085f, 0.000065f, 0.000049f,
+ 0.000036f, 0.000026f, 0.000019f, 0.000014f, 0.000042f, 0.000114f, 0.000122f, 0.000276f, 0.001024f, 0.016357f, 0.912109f, 0.912598f,
+ 0.911621f, 0.912598f, 0.911621f, 0.913086f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000016f, 0.000032f, 0.000045f, 0.000056f, 0.000065f, 0.000054f, 0.000039f, 0.000028f, 0.000019f, 0.000013f, 0.000049f, 0.000079f,
+ 0.000226f, 0.003199f, 0.860840f, 0.859863f, 0.860352f, 0.860840f, 0.860840f, 0.860352f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000004f, 0.000021f, 0.000035f,
+ 0.000040f, 0.000027f, 0.000018f, 0.000013f, 0.000033f, 0.000333f, 0.764160f, 0.765137f, 0.764648f, 0.764648f, 0.764648f, 0.765137f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000006f, 0.000011f, 0.000009f, 0.600586f, 0.602051f,
+ 0.602051f, 0.601562f, 0.601074f, 0.601074f,
+ },
+ {
+ 0.142456f, 0.713867f, 0.883789f, 0.933105f, 0.953613f, 0.964844f, 0.972168f, 0.977539f, 0.980957f, 0.983398f, 0.985352f, 0.987305f,
+ 0.989258f, 0.989746f, 0.990723f, 0.991699f, 0.992676f, 0.993164f, 0.993652f, 0.993652f, 0.994141f, 0.995117f, 0.995117f, 0.995605f,
+ 0.995605f, 0.996094f, 0.996582f, 0.996582f, 0.997070f, 0.997070f, 0.997070f, 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.998047f,
+ 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.012886f, 0.087646f, 0.360840f, 0.709473f, 0.859863f, 0.916992f, 0.943848f, 0.958496f,
+ 0.967773f, 0.973633f, 0.978516f, 0.980957f, 0.984375f, 0.986328f, 0.987793f, 0.988770f, 0.990234f, 0.991211f, 0.992188f, 0.993164f,
+ 0.993164f, 0.993652f, 0.994141f, 0.994629f, 0.995117f, 0.995605f, 0.996094f, 0.996094f, 0.996094f, 0.996582f, 0.996582f, 0.997070f,
+ 0.997070f, 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f,
+ 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.003895f, 0.020126f, 0.063599f, 0.188721f,
+ 0.464844f, 0.727539f, 0.853027f, 0.909668f, 0.938477f, 0.954590f, 0.965332f, 0.971680f, 0.976562f, 0.979980f, 0.982910f, 0.985840f,
+ 0.986816f, 0.988770f, 0.990234f, 0.990723f, 0.991699f, 0.992188f, 0.993164f, 0.993652f, 0.994141f, 0.994629f, 0.995117f, 0.995605f,
+ 0.996094f, 0.996094f, 0.996582f, 0.996582f, 0.996582f, 0.997070f, 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.998047f, 0.998047f,
+ 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.002062f, 0.008438f, 0.021774f, 0.049713f, 0.117676f, 0.279541f, 0.541016f, 0.751465f, 0.855469f, 0.909180f, 0.936035f, 0.952637f,
+ 0.963379f, 0.970703f, 0.975098f, 0.979492f, 0.982910f, 0.984863f, 0.986328f, 0.987793f, 0.989258f, 0.990234f, 0.990723f, 0.992188f,
+ 0.992676f, 0.993164f, 0.993652f, 0.994629f, 0.995117f, 0.995117f, 0.996094f, 0.996094f, 0.996582f, 0.996582f, 0.996582f, 0.997070f,
+ 0.997070f, 0.997559f, 0.997559f, 0.997559f, 0.998047f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f,
+ 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.001335f, 0.004597f, 0.010628f, 0.020844f, 0.040283f, 0.082764f, 0.177612f, 0.366211f,
+ 0.605469f, 0.773926f, 0.863281f, 0.910156f, 0.936035f, 0.952148f, 0.962402f, 0.969727f, 0.975098f, 0.979004f, 0.982422f, 0.984863f,
+ 0.986328f, 0.988281f, 0.988770f, 0.989746f, 0.991211f, 0.991699f, 0.992676f, 0.993164f, 0.993652f, 0.994629f, 0.995117f, 0.995117f,
+ 0.996094f, 0.996094f, 0.996094f, 0.996582f, 0.997070f, 0.996582f, 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.998047f, 0.998047f,
+ 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000851f, 0.002769f, 0.006130f, 0.010994f,
+ 0.019394f, 0.034943f, 0.063293f, 0.122253f, 0.244019f, 0.448242f, 0.660156f, 0.798828f, 0.872559f, 0.914062f, 0.937988f, 0.954102f,
+ 0.961914f, 0.970215f, 0.974609f, 0.978516f, 0.981934f, 0.984375f, 0.986328f, 0.987793f, 0.988770f, 0.989746f, 0.991211f, 0.991699f,
+ 0.992676f, 0.993164f, 0.994141f, 0.994629f, 0.995117f, 0.995605f, 0.995605f, 0.996094f, 0.996582f, 0.996582f, 0.997070f, 0.997070f,
+ 0.997070f, 0.997559f, 0.998047f, 0.998047f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000466f, 0.001933f, 0.003809f, 0.007095f, 0.011353f, 0.018204f, 0.030029f, 0.050568f, 0.090759f, 0.170898f, 0.318848f, 0.526367f,
+ 0.708496f, 0.820801f, 0.884277f, 0.918457f, 0.940918f, 0.954102f, 0.963867f, 0.970215f, 0.975098f, 0.978516f, 0.981934f, 0.984863f,
+ 0.986328f, 0.988281f, 0.988770f, 0.990234f, 0.991211f, 0.991699f, 0.993164f, 0.993652f, 0.994141f, 0.994629f, 0.994629f, 0.995605f,
+ 0.996094f, 0.996094f, 0.996582f, 0.996582f, 0.996582f, 0.997070f, 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.998047f, 0.998535f,
+ 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000487f, 0.001685f, 0.002766f, 0.004467f, 0.007305f, 0.011215f, 0.017136f, 0.026489f,
+ 0.042419f, 0.071716f, 0.125244f, 0.228271f, 0.399658f, 0.599609f, 0.751953f, 0.842773f, 0.894531f, 0.924805f, 0.943359f, 0.955566f,
+ 0.965820f, 0.971191f, 0.976562f, 0.979980f, 0.981934f, 0.984863f, 0.986816f, 0.988281f, 0.989258f, 0.990723f, 0.991211f, 0.992188f,
+ 0.992676f, 0.993652f, 0.994141f, 0.995117f, 0.995117f, 0.995605f, 0.996094f, 0.996094f, 0.996094f, 0.996582f, 0.997070f, 0.997070f,
+ 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000244f, 0.000965f, 0.002024f, 0.003202f,
+ 0.005009f, 0.007050f, 0.011070f, 0.015869f, 0.023987f, 0.036835f, 0.058563f, 0.097168f, 0.169800f, 0.297852f, 0.484131f, 0.664062f,
+ 0.789062f, 0.861816f, 0.905273f, 0.930176f, 0.947266f, 0.958984f, 0.967285f, 0.972168f, 0.976562f, 0.980469f, 0.982910f, 0.984863f,
+ 0.986816f, 0.988770f, 0.989746f, 0.990723f, 0.992188f, 0.992188f, 0.993652f, 0.993652f, 0.994629f, 0.995117f, 0.995117f, 0.995605f,
+ 0.996094f, 0.996094f, 0.996582f, 0.996582f, 0.997070f, 0.997070f, 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.998047f, 0.998535f,
+ 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000244f, 0.000974f, 0.001576f, 0.002403f, 0.003510f, 0.005344f, 0.007332f, 0.010567f, 0.015099f, 0.022064f, 0.032104f, 0.048706f,
+ 0.078003f, 0.130249f, 0.224243f, 0.378174f, 0.566406f, 0.720703f, 0.820312f, 0.879883f, 0.915039f, 0.936523f, 0.951660f, 0.961426f,
+ 0.968262f, 0.974121f, 0.978027f, 0.980957f, 0.983887f, 0.985840f, 0.987793f, 0.989258f, 0.990234f, 0.991211f, 0.992188f, 0.992676f,
+ 0.993652f, 0.994141f, 0.994629f, 0.995117f, 0.995605f, 0.995605f, 0.996094f, 0.996094f, 0.996582f, 0.997070f, 0.997070f, 0.997070f,
+ 0.997559f, 0.997559f, 0.998047f, 0.998047f, 0.998535f, 0.998047f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000240f, 0.000609f, 0.001096f, 0.001580f, 0.002674f, 0.004131f, 0.005245f, 0.007660f,
+ 0.010757f, 0.014221f, 0.019775f, 0.028381f, 0.041870f, 0.064697f, 0.103638f, 0.173706f, 0.293945f, 0.466553f, 0.642090f, 0.769531f,
+ 0.849121f, 0.895996f, 0.924316f, 0.942871f, 0.956055f, 0.963867f, 0.970703f, 0.975098f, 0.979004f, 0.981934f, 0.984863f, 0.986328f,
+ 0.988770f, 0.989746f, 0.990723f, 0.991699f, 0.992676f, 0.993164f, 0.993652f, 0.994629f, 0.995117f, 0.995117f, 0.995605f, 0.996094f,
+ 0.996094f, 0.996094f, 0.996582f, 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.997559f, 0.998047f, 0.998047f, 0.998535f, 0.998535f,
+ 0.998535f, 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000000f, 0.000608f, 0.001062f, 0.001268f,
+ 0.002001f, 0.003099f, 0.003937f, 0.005379f, 0.007595f, 0.010078f, 0.013176f, 0.018524f, 0.025787f, 0.036896f, 0.054932f, 0.085327f,
+ 0.137573f, 0.229980f, 0.376953f, 0.555664f, 0.708984f, 0.810547f, 0.873047f, 0.909180f, 0.933594f, 0.948730f, 0.959961f, 0.967285f,
+ 0.973145f, 0.977539f, 0.980469f, 0.983398f, 0.985840f, 0.986816f, 0.988770f, 0.989746f, 0.991211f, 0.992188f, 0.993164f, 0.993652f,
+ 0.994141f, 0.994629f, 0.995117f, 0.995605f, 0.996094f, 0.996582f, 0.996094f, 0.996582f, 0.997070f, 0.997559f, 0.997559f, 0.998047f,
+ 0.998047f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000244f, 0.000606f, 0.000609f, 0.001317f, 0.001564f, 0.002674f, 0.003273f, 0.004402f, 0.005630f, 0.007141f, 0.009514f, 0.012398f,
+ 0.016678f, 0.023331f, 0.032776f, 0.047363f, 0.071594f, 0.112610f, 0.183960f, 0.303711f, 0.470215f, 0.639648f, 0.766113f, 0.844727f,
+ 0.892090f, 0.921875f, 0.941895f, 0.954590f, 0.963379f, 0.970215f, 0.975098f, 0.979004f, 0.981934f, 0.984863f, 0.986328f, 0.987793f,
+ 0.989746f, 0.991211f, 0.991699f, 0.992676f, 0.993652f, 0.994141f, 0.994629f, 0.995117f, 0.995605f, 0.995605f, 0.996094f, 0.996094f,
+ 0.996582f, 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000244f, 0.000244f, 0.000727f, 0.000803f, 0.001575f, 0.002035f, 0.002821f, 0.003527f,
+ 0.004475f, 0.005421f, 0.007023f, 0.009491f, 0.011879f, 0.015976f, 0.021530f, 0.029587f, 0.041809f, 0.061737f, 0.094360f, 0.150146f,
+ 0.246460f, 0.393066f, 0.566406f, 0.712891f, 0.812500f, 0.872070f, 0.909180f, 0.933105f, 0.948242f, 0.959961f, 0.967773f, 0.972656f,
+ 0.977539f, 0.980957f, 0.982910f, 0.986328f, 0.987305f, 0.988770f, 0.989746f, 0.991211f, 0.992188f, 0.993164f, 0.993652f, 0.994629f,
+ 0.994629f, 0.995117f, 0.995605f, 0.996094f, 0.996094f, 0.996582f, 0.997070f, 0.997559f, 0.997559f, 0.997559f, 0.998047f, 0.998535f,
+ 0.998535f, 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000244f, 0.000244f, 0.000471f, 0.000727f,
+ 0.000967f, 0.001572f, 0.002161f, 0.002680f, 0.003246f, 0.004337f, 0.005241f, 0.006950f, 0.009087f, 0.011497f, 0.015038f, 0.019913f,
+ 0.026688f, 0.037537f, 0.054352f, 0.080383f, 0.125122f, 0.202515f, 0.327148f, 0.493652f, 0.656250f, 0.774414f, 0.849609f, 0.895508f,
+ 0.923828f, 0.942383f, 0.954590f, 0.963867f, 0.971191f, 0.975586f, 0.979004f, 0.982422f, 0.984863f, 0.987305f, 0.988281f, 0.989746f,
+ 0.990723f, 0.992188f, 0.992676f, 0.993652f, 0.994141f, 0.995117f, 0.995117f, 0.995605f, 0.996094f, 0.996582f, 0.996582f, 0.997070f,
+ 0.997559f, 0.997559f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.999512f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999023f,
+ 0.000121f, 0.000244f, 0.000244f, 0.000715f, 0.001089f, 0.001278f, 0.001781f, 0.002275f, 0.002548f, 0.003334f, 0.004150f, 0.005314f,
+ 0.006824f, 0.008430f, 0.011200f, 0.014145f, 0.018631f, 0.024750f, 0.033905f, 0.047760f, 0.069885f, 0.106445f, 0.169312f, 0.273682f,
+ 0.426270f, 0.596191f, 0.732422f, 0.823242f, 0.879883f, 0.914062f, 0.936035f, 0.950684f, 0.960938f, 0.968750f, 0.973633f, 0.978516f,
+ 0.981934f, 0.984375f, 0.986328f, 0.988281f, 0.989258f, 0.990234f, 0.991699f, 0.992676f, 0.993652f, 0.994141f, 0.994629f, 0.995117f,
+ 0.995605f, 0.995605f, 0.996094f, 0.996582f, 0.997070f, 0.997559f, 0.997559f, 0.997559f, 0.998047f, 0.998535f, 0.999023f, 0.999512f,
+ 0.999023f, 0.999512f, 0.999512f, 0.999023f, 0.000241f, 0.000244f, 0.000365f, 0.000600f, 0.000961f, 0.000972f, 0.001621f, 0.001697f,
+ 0.002274f, 0.002684f, 0.003359f, 0.004238f, 0.005573f, 0.006691f, 0.008057f, 0.010529f, 0.013832f, 0.017593f, 0.022812f, 0.031174f,
+ 0.042786f, 0.061462f, 0.092407f, 0.143799f, 0.231201f, 0.366943f, 0.535645f, 0.688477f, 0.794922f, 0.861816f, 0.902832f, 0.928711f,
+ 0.945801f, 0.957520f, 0.966797f, 0.972656f, 0.976562f, 0.980469f, 0.983398f, 0.985840f, 0.987793f, 0.989258f, 0.990234f, 0.991699f,
+ 0.992676f, 0.993164f, 0.994141f, 0.994629f, 0.995117f, 0.995605f, 0.995605f, 0.996094f, 0.997070f, 0.997070f, 0.997559f, 0.997559f,
+ 0.998047f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.000000f, 0.000243f, 0.000365f, 0.000365f,
+ 0.000798f, 0.000968f, 0.001249f, 0.001528f, 0.001798f, 0.002457f, 0.002798f, 0.003494f, 0.004353f, 0.005306f, 0.006363f, 0.008141f,
+ 0.010147f, 0.012596f, 0.016006f, 0.021423f, 0.028503f, 0.039185f, 0.055420f, 0.081116f, 0.124390f, 0.198120f, 0.316895f, 0.478516f,
+ 0.641113f, 0.763672f, 0.842773f, 0.891113f, 0.921387f, 0.941406f, 0.954590f, 0.963867f, 0.970215f, 0.975586f, 0.979492f, 0.982910f,
+ 0.985352f, 0.987305f, 0.988770f, 0.989746f, 0.991211f, 0.992188f, 0.993164f, 0.993652f, 0.994141f, 0.994629f, 0.995117f, 0.995605f,
+ 0.996582f, 0.996582f, 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.000000f, 0.000238f, 0.000365f, 0.000365f, 0.000598f, 0.000820f, 0.001200f, 0.001279f, 0.001631f, 0.001736f, 0.002172f, 0.002874f,
+ 0.003576f, 0.004391f, 0.005096f, 0.006176f, 0.007545f, 0.009674f, 0.012505f, 0.015945f, 0.020187f, 0.026550f, 0.035706f, 0.049835f,
+ 0.072510f, 0.109253f, 0.171631f, 0.275391f, 0.426514f, 0.594238f, 0.730469f, 0.822754f, 0.877930f, 0.913574f, 0.936523f, 0.951172f,
+ 0.961426f, 0.969727f, 0.974609f, 0.978027f, 0.982422f, 0.984863f, 0.986816f, 0.988770f, 0.989746f, 0.991699f, 0.992188f, 0.993164f,
+ 0.993652f, 0.994629f, 0.994629f, 0.995117f, 0.996094f, 0.996094f, 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.000000f, 0.000000f, 0.000364f, 0.000486f, 0.000487f, 0.000562f, 0.000822f, 0.000967f,
+ 0.001213f, 0.001871f, 0.001803f, 0.002485f, 0.002796f, 0.003410f, 0.004242f, 0.005070f, 0.006153f, 0.007698f, 0.009262f, 0.011635f,
+ 0.014709f, 0.019104f, 0.024521f, 0.033295f, 0.045746f, 0.065674f, 0.096741f, 0.150635f, 0.241455f, 0.380127f, 0.548828f, 0.698242f,
+ 0.802246f, 0.867188f, 0.906738f, 0.931152f, 0.948242f, 0.959473f, 0.967285f, 0.973633f, 0.978516f, 0.981445f, 0.984375f, 0.986328f,
+ 0.988281f, 0.989258f, 0.990723f, 0.992188f, 0.993164f, 0.993652f, 0.994629f, 0.994629f, 0.995117f, 0.996094f, 0.996582f, 0.996582f,
+ 0.997559f, 0.997559f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.000000f, 0.000000f, 0.000350f, 0.000483f,
+ 0.000486f, 0.000604f, 0.000743f, 0.001093f, 0.001187f, 0.001297f, 0.001601f, 0.001921f, 0.002501f, 0.002922f, 0.003296f, 0.004200f,
+ 0.005211f, 0.006054f, 0.007603f, 0.008904f, 0.011169f, 0.014091f, 0.017685f, 0.023331f, 0.030991f, 0.042358f, 0.059326f, 0.087646f,
+ 0.134521f, 0.213867f, 0.341309f, 0.506348f, 0.665039f, 0.780762f, 0.854492f, 0.899414f, 0.927246f, 0.945312f, 0.957520f, 0.966309f,
+ 0.973145f, 0.977539f, 0.981445f, 0.984375f, 0.986328f, 0.988770f, 0.989746f, 0.991211f, 0.992188f, 0.993164f, 0.993652f, 0.994629f,
+ 0.995117f, 0.995605f, 0.996094f, 0.996582f, 0.997070f, 0.997070f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.000000f, 0.000000f, 0.000120f, 0.000360f, 0.000485f, 0.000486f, 0.000487f, 0.000604f, 0.000947f, 0.001201f, 0.001374f, 0.001715f,
+ 0.002127f, 0.002239f, 0.002876f, 0.003426f, 0.004063f, 0.005276f, 0.005810f, 0.006744f, 0.008713f, 0.010597f, 0.013680f, 0.016754f,
+ 0.021744f, 0.028778f, 0.039093f, 0.054901f, 0.079956f, 0.121399f, 0.191895f, 0.307861f, 0.468262f, 0.633301f, 0.760742f, 0.842285f,
+ 0.892090f, 0.923340f, 0.942383f, 0.956543f, 0.965332f, 0.972168f, 0.977539f, 0.980469f, 0.983887f, 0.985840f, 0.988281f, 0.989746f,
+ 0.990723f, 0.992188f, 0.993164f, 0.994141f, 0.994629f, 0.995117f, 0.996094f, 0.996582f, 0.997070f, 0.997070f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.000000f, 0.000000f, 0.000121f, 0.000219f, 0.000474f, 0.000484f, 0.000486f, 0.000487f,
+ 0.000720f, 0.001108f, 0.001199f, 0.001209f, 0.001689f, 0.002253f, 0.002489f, 0.002916f, 0.003714f, 0.004040f, 0.005054f, 0.006001f,
+ 0.006737f, 0.008713f, 0.010376f, 0.012665f, 0.016251f, 0.020615f, 0.027145f, 0.036499f, 0.050720f, 0.073181f, 0.110474f, 0.174072f,
+ 0.280518f, 0.434570f, 0.604980f, 0.742188f, 0.830566f, 0.885742f, 0.918945f, 0.940918f, 0.954102f, 0.964355f, 0.971680f, 0.977051f,
+ 0.980957f, 0.984375f, 0.986816f, 0.988281f, 0.989746f, 0.990723f, 0.992188f, 0.993652f, 0.994141f, 0.995117f, 0.995605f, 0.996094f,
+ 0.996582f, 0.997070f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.000000f, 0.000000f, 0.000120f, 0.000239f,
+ 0.000319f, 0.000475f, 0.000484f, 0.000485f, 0.000618f, 0.000844f, 0.001094f, 0.001201f, 0.001570f, 0.001782f, 0.002010f, 0.002407f,
+ 0.003046f, 0.003099f, 0.004208f, 0.004700f, 0.005882f, 0.006878f, 0.007980f, 0.009949f, 0.012344f, 0.015358f, 0.019821f, 0.026047f,
+ 0.034271f, 0.047455f, 0.067993f, 0.102112f, 0.160034f, 0.258057f, 0.406494f, 0.578613f, 0.723633f, 0.820312f, 0.880371f, 0.916016f,
+ 0.938965f, 0.953125f, 0.963867f, 0.971191f, 0.976562f, 0.980469f, 0.983887f, 0.985840f, 0.988770f, 0.989746f, 0.991699f, 0.992676f,
+ 0.993652f, 0.994629f, 0.995117f, 0.995605f, 0.996094f, 0.996582f, 0.999023f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000121f, 0.000242f, 0.000455f, 0.000481f, 0.000583f, 0.000601f, 0.000804f, 0.000912f, 0.001247f,
+ 0.001319f, 0.001571f, 0.001793f, 0.002337f, 0.002464f, 0.003099f, 0.003164f, 0.003809f, 0.004627f, 0.005764f, 0.006397f, 0.008118f,
+ 0.009605f, 0.011917f, 0.015083f, 0.018692f, 0.024384f, 0.032806f, 0.044983f, 0.063477f, 0.095337f, 0.148560f, 0.240112f, 0.382324f,
+ 0.556641f, 0.708984f, 0.812500f, 0.875488f, 0.913574f, 0.937500f, 0.953125f, 0.963867f, 0.971191f, 0.977051f, 0.980957f, 0.983887f,
+ 0.986816f, 0.988281f, 0.990234f, 0.992188f, 0.993164f, 0.993652f, 0.994141f, 0.995605f, 0.995605f, 0.996094f, 0.998535f, 0.998535f,
+ 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.000000f, 0.000000f, 0.000000f, 0.000121f, 0.000240f, 0.000242f, 0.000524f, 0.000597f,
+ 0.000604f, 0.000606f, 0.000674f, 0.001040f, 0.001238f, 0.001427f, 0.001637f, 0.001670f, 0.002104f, 0.002432f, 0.002775f, 0.003416f,
+ 0.003860f, 0.004482f, 0.005573f, 0.006374f, 0.007828f, 0.009384f, 0.011635f, 0.014175f, 0.018219f, 0.023224f, 0.031052f, 0.042603f,
+ 0.060730f, 0.089661f, 0.139526f, 0.225464f, 0.363525f, 0.538574f, 0.696289f, 0.806152f, 0.872559f, 0.912109f, 0.937012f, 0.952637f,
+ 0.963867f, 0.971191f, 0.976562f, 0.981445f, 0.984863f, 0.987305f, 0.988770f, 0.990723f, 0.992188f, 0.993164f, 0.994141f, 0.994629f,
+ 0.995117f, 0.996094f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.000000f, 0.000000f, 0.000000f, 0.000119f,
+ 0.000192f, 0.000240f, 0.000242f, 0.000535f, 0.000478f, 0.000600f, 0.000843f, 0.000925f, 0.001027f, 0.001236f, 0.001502f, 0.001490f,
+ 0.001658f, 0.002256f, 0.002430f, 0.002880f, 0.003056f, 0.003983f, 0.004292f, 0.005333f, 0.006264f, 0.007393f, 0.009064f, 0.011131f,
+ 0.013741f, 0.017242f, 0.022690f, 0.029922f, 0.040680f, 0.057831f, 0.085022f, 0.132446f, 0.214844f, 0.349121f, 0.524414f, 0.688477f,
+ 0.801758f, 0.871094f, 0.912109f, 0.937500f, 0.953125f, 0.964355f, 0.971680f, 0.977539f, 0.981445f, 0.985352f, 0.987305f, 0.989258f,
+ 0.991211f, 0.992188f, 0.993652f, 0.994629f, 0.995117f, 0.995605f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000119f, 0.000232f, 0.000233f, 0.000363f, 0.000457f, 0.000714f, 0.000724f, 0.000727f,
+ 0.000847f, 0.000992f, 0.001177f, 0.001525f, 0.001560f, 0.001740f, 0.002090f, 0.002329f, 0.002718f, 0.003372f, 0.003902f, 0.004307f,
+ 0.005184f, 0.005886f, 0.007446f, 0.008667f, 0.010574f, 0.013588f, 0.016556f, 0.021744f, 0.028854f, 0.039124f, 0.055176f, 0.081726f,
+ 0.127075f, 0.206421f, 0.338867f, 0.515625f, 0.683105f, 0.800293f, 0.870605f, 0.912598f, 0.937500f, 0.954590f, 0.965332f, 0.973145f,
+ 0.978516f, 0.982422f, 0.985840f, 0.988281f, 0.989746f, 0.991211f, 0.992676f, 0.993652f, 0.994141f, 0.995117f, 0.998535f, 0.998535f,
+ 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000103f, 0.000120f, 0.000240f, 0.000240f,
+ 0.000484f, 0.000574f, 0.000596f, 0.000837f, 0.000820f, 0.000859f, 0.000985f, 0.001070f, 0.001509f, 0.001554f, 0.001785f, 0.002214f,
+ 0.002476f, 0.002754f, 0.002991f, 0.003487f, 0.004303f, 0.005074f, 0.005920f, 0.007126f, 0.008743f, 0.010361f, 0.013023f, 0.016403f,
+ 0.021011f, 0.027817f, 0.037811f, 0.053375f, 0.079041f, 0.123291f, 0.201172f, 0.333252f, 0.511719f, 0.682129f, 0.801270f, 0.872070f,
+ 0.914062f, 0.939941f, 0.955078f, 0.966309f, 0.973633f, 0.979004f, 0.982910f, 0.986328f, 0.988770f, 0.990234f, 0.991699f, 0.992676f,
+ 0.993652f, 0.995117f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000079f, 0.000053f, 0.000118f, 0.000418f, 0.000358f, 0.000363f, 0.000678f, 0.000708f, 0.000825f, 0.000838f, 0.000878f, 0.001146f,
+ 0.000978f, 0.001483f, 0.001541f, 0.001769f, 0.001812f, 0.002434f, 0.002699f, 0.003225f, 0.003298f, 0.004002f, 0.004948f, 0.005932f,
+ 0.007084f, 0.008461f, 0.010414f, 0.012665f, 0.015915f, 0.020615f, 0.027023f, 0.036743f, 0.051941f, 0.077332f, 0.120789f, 0.198608f,
+ 0.331543f, 0.512695f, 0.686523f, 0.805664f, 0.875488f, 0.917480f, 0.941406f, 0.957031f, 0.968262f, 0.975098f, 0.980469f, 0.983887f,
+ 0.986816f, 0.989258f, 0.990723f, 0.992188f, 0.993164f, 0.994629f, 0.998047f, 0.998047f, 0.998535f, 0.998047f, 0.998535f, 0.998535f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000109f, 0.000232f, 0.000349f, 0.000478f, 0.000483f, 0.000483f, 0.000609f,
+ 0.000795f, 0.000835f, 0.000806f, 0.000726f, 0.001022f, 0.001222f, 0.001442f, 0.001536f, 0.001650f, 0.001714f, 0.002377f, 0.002588f,
+ 0.003159f, 0.003643f, 0.004036f, 0.004929f, 0.005718f, 0.006813f, 0.008072f, 0.009880f, 0.012527f, 0.015854f, 0.020035f, 0.026352f,
+ 0.035950f, 0.051178f, 0.076416f, 0.119751f, 0.198730f, 0.334229f, 0.519531f, 0.694824f, 0.812988f, 0.880859f, 0.920898f, 0.944336f,
+ 0.958984f, 0.969727f, 0.976562f, 0.980957f, 0.984863f, 0.987793f, 0.989746f, 0.991211f, 0.992676f, 0.993652f, 0.997559f, 0.998047f,
+ 0.998047f, 0.998047f, 0.998047f, 0.998047f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000068f, 0.000265f,
+ 0.000361f, 0.000478f, 0.000480f, 0.000479f, 0.000568f, 0.000693f, 0.000714f, 0.000806f, 0.000843f, 0.000919f, 0.001222f, 0.001376f,
+ 0.001531f, 0.001554f, 0.001987f, 0.002342f, 0.002558f, 0.002798f, 0.003132f, 0.004021f, 0.004864f, 0.005455f, 0.006664f, 0.008110f,
+ 0.009613f, 0.011955f, 0.015335f, 0.019608f, 0.025879f, 0.035522f, 0.050629f, 0.075623f, 0.120239f, 0.201416f, 0.342041f, 0.533203f,
+ 0.707031f, 0.821777f, 0.887695f, 0.925293f, 0.946777f, 0.961914f, 0.971680f, 0.977539f, 0.982422f, 0.985352f, 0.988281f, 0.989746f,
+ 0.992188f, 0.993164f, 0.997559f, 0.998047f, 0.998047f, 0.998047f, 0.998047f, 0.998047f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000122f, 0.000000f, 0.000122f, 0.000322f, 0.000241f, 0.000478f, 0.000480f, 0.000480f, 0.000510f, 0.000695f, 0.000710f,
+ 0.000958f, 0.000765f, 0.001075f, 0.001116f, 0.001318f, 0.001606f, 0.001546f, 0.001916f, 0.002306f, 0.002499f, 0.002905f, 0.003202f,
+ 0.003914f, 0.004498f, 0.005459f, 0.006611f, 0.007687f, 0.009331f, 0.011757f, 0.014923f, 0.019241f, 0.025833f, 0.035492f, 0.050507f,
+ 0.076233f, 0.122131f, 0.207153f, 0.355225f, 0.551758f, 0.724609f, 0.833496f, 0.894531f, 0.930664f, 0.951660f, 0.964844f, 0.973145f,
+ 0.979492f, 0.983887f, 0.986816f, 0.989258f, 0.991211f, 0.993164f, 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.997559f, 0.997559f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000351f, 0.000458f, 0.000476f,
+ 0.000480f, 0.000482f, 0.000528f, 0.000650f, 0.000704f, 0.000956f, 0.000828f, 0.000963f, 0.001111f, 0.001265f, 0.001474f, 0.001806f,
+ 0.001872f, 0.002308f, 0.002445f, 0.002701f, 0.003229f, 0.003851f, 0.004375f, 0.005356f, 0.006317f, 0.007458f, 0.009300f, 0.011574f,
+ 0.014725f, 0.019165f, 0.025696f, 0.035461f, 0.050812f, 0.077637f, 0.125977f, 0.216797f, 0.374756f, 0.576660f, 0.745117f, 0.848145f,
+ 0.904785f, 0.936523f, 0.956055f, 0.967773f, 0.975586f, 0.980957f, 0.984863f, 0.987793f, 0.990234f, 0.992188f, 0.997070f, 0.997559f,
+ 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000292f, 0.000224f, 0.000452f, 0.000453f, 0.000479f, 0.000480f, 0.000517f, 0.000614f, 0.000902f, 0.000712f, 0.000959f,
+ 0.000978f, 0.001100f, 0.001276f, 0.001461f, 0.001524f, 0.001651f, 0.002041f, 0.002350f, 0.002853f, 0.003433f, 0.003622f, 0.004166f,
+ 0.005043f, 0.006187f, 0.007534f, 0.009209f, 0.011551f, 0.014908f, 0.019012f, 0.025406f, 0.035461f, 0.051575f, 0.079651f, 0.131714f,
+ 0.230957f, 0.401367f, 0.607910f, 0.769531f, 0.863281f, 0.914062f, 0.942871f, 0.959961f, 0.970703f, 0.978027f, 0.982910f, 0.986816f,
+ 0.988770f, 0.991699f, 0.997070f, 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000238f, 0.000355f, 0.000449f, 0.000462f, 0.000474f, 0.000477f,
+ 0.000482f, 0.000846f, 0.000726f, 0.000706f, 0.000953f, 0.000889f, 0.001012f, 0.001259f, 0.001390f, 0.001755f, 0.001658f, 0.002060f,
+ 0.002369f, 0.002539f, 0.003170f, 0.003460f, 0.004131f, 0.004993f, 0.006008f, 0.007431f, 0.009109f, 0.011444f, 0.014252f, 0.019058f,
+ 0.025574f, 0.036011f, 0.053162f, 0.083435f, 0.140381f, 0.250488f, 0.436035f, 0.645996f, 0.795898f, 0.880371f, 0.924316f, 0.949219f,
+ 0.963867f, 0.973145f, 0.980469f, 0.984863f, 0.988281f, 0.990723f, 0.997070f, 0.997559f, 0.997070f, 0.997559f, 0.997559f, 0.997070f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000239f,
+ 0.000306f, 0.000440f, 0.000437f, 0.000474f, 0.000478f, 0.000481f, 0.000523f, 0.000664f, 0.000731f, 0.000802f, 0.000935f, 0.001022f,
+ 0.001173f, 0.001314f, 0.001504f, 0.001831f, 0.001984f, 0.002317f, 0.002472f, 0.003199f, 0.003370f, 0.004189f, 0.004868f, 0.005924f,
+ 0.007320f, 0.008926f, 0.011421f, 0.014595f, 0.019119f, 0.026260f, 0.036987f, 0.055176f, 0.088440f, 0.152466f, 0.277832f, 0.479980f,
+ 0.686523f, 0.823242f, 0.895508f, 0.933105f, 0.955566f, 0.969238f, 0.976562f, 0.982422f, 0.986816f, 0.989746f, 0.996582f, 0.997070f,
+ 0.997070f, 0.997070f, 0.997070f, 0.997070f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000194f, 0.000280f, 0.000417f, 0.000448f, 0.000468f, 0.000476f, 0.000479f, 0.000490f,
+ 0.000845f, 0.000688f, 0.000740f, 0.000945f, 0.000998f, 0.001148f, 0.001266f, 0.001414f, 0.001475f, 0.001667f, 0.002262f, 0.002537f,
+ 0.003019f, 0.003288f, 0.004223f, 0.004768f, 0.005890f, 0.007259f, 0.009026f, 0.011360f, 0.014297f, 0.019272f, 0.026474f, 0.038116f,
+ 0.058197f, 0.095032f, 0.168945f, 0.313965f, 0.533203f, 0.731445f, 0.850098f, 0.911133f, 0.942871f, 0.961914f, 0.972656f, 0.979980f,
+ 0.984863f, 0.988770f, 0.996582f, 0.996582f, 0.996582f, 0.996582f, 0.996582f, 0.996582f, 0.000000f, 0.000000f, 0.000122f, 0.000000f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000187f, 0.000233f, 0.000141f, 0.000271f, 0.000341f,
+ 0.000380f, 0.000465f, 0.000473f, 0.000590f, 0.000605f, 0.000798f, 0.000847f, 0.000934f, 0.000946f, 0.000836f, 0.001009f, 0.001142f,
+ 0.001430f, 0.001495f, 0.001850f, 0.002111f, 0.002541f, 0.003035f, 0.003300f, 0.004139f, 0.004913f, 0.005718f, 0.007141f, 0.008934f,
+ 0.011475f, 0.014832f, 0.019653f, 0.027573f, 0.039917f, 0.062225f, 0.104919f, 0.192017f, 0.362305f, 0.594238f, 0.775879f, 0.875977f,
+ 0.925293f, 0.952148f, 0.967773f, 0.977051f, 0.983398f, 0.988281f, 0.996094f, 0.996094f, 0.996094f, 0.996582f, 0.996094f, 0.996582f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000238f, 0.000243f, 0.000238f, 0.000424f, 0.000453f, 0.000467f, 0.000475f, 0.000581f, 0.000689f, 0.000795f,
+ 0.000634f, 0.000823f, 0.001014f, 0.000900f, 0.001083f, 0.001485f, 0.001731f, 0.001851f, 0.002056f, 0.002373f, 0.002621f, 0.003445f,
+ 0.004082f, 0.004578f, 0.005821f, 0.007217f, 0.008881f, 0.011330f, 0.014778f, 0.020416f, 0.028473f, 0.042419f, 0.067993f, 0.118286f,
+ 0.225342f, 0.425293f, 0.661621f, 0.818848f, 0.899902f, 0.939453f, 0.960449f, 0.973145f, 0.980957f, 0.985840f, 0.995605f, 0.996094f,
+ 0.996094f, 0.996094f, 0.996094f, 0.996094f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000205f, 0.000224f, 0.000122f, 0.000231f, 0.000245f, 0.000411f, 0.000520f,
+ 0.000463f, 0.000470f, 0.000587f, 0.000361f, 0.000712f, 0.000694f, 0.000815f, 0.000978f, 0.001055f, 0.001105f, 0.001390f, 0.001438f,
+ 0.001705f, 0.001984f, 0.002333f, 0.002546f, 0.003408f, 0.003876f, 0.004627f, 0.005783f, 0.007198f, 0.008995f, 0.011383f, 0.015396f,
+ 0.020828f, 0.030029f, 0.045654f, 0.075439f, 0.137451f, 0.271973f, 0.503418f, 0.728516f, 0.857910f, 0.920410f, 0.951172f, 0.968262f,
+ 0.977539f, 0.984375f, 0.995117f, 0.995605f, 0.995605f, 0.995605f, 0.995605f, 0.995605f, 0.000000f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000173f, 0.000150f, 0.000278f, 0.000376f, 0.000427f, 0.000470f, 0.000352f, 0.000356f, 0.000475f, 0.000441f, 0.000709f, 0.000774f,
+ 0.000970f, 0.001013f, 0.000998f, 0.001193f, 0.001397f, 0.001677f, 0.001957f, 0.002268f, 0.002529f, 0.003353f, 0.003874f, 0.004555f,
+ 0.005692f, 0.007160f, 0.008987f, 0.011543f, 0.015732f, 0.021896f, 0.032135f, 0.050140f, 0.086548f, 0.165894f, 0.337646f, 0.593750f,
+ 0.791504f, 0.892090f, 0.938477f, 0.961914f, 0.974609f, 0.982422f, 0.994629f, 0.995117f, 0.995117f, 0.995605f, 0.995117f, 0.995605f,
+ 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000187f, 0.000130f, 0.000231f, 0.000315f, 0.000298f, 0.000332f, 0.000343f,
+ 0.000465f, 0.000472f, 0.000579f, 0.000717f, 0.000839f, 0.000932f, 0.000817f, 0.001086f, 0.001090f, 0.001545f, 0.001735f, 0.001837f,
+ 0.002485f, 0.002493f, 0.003288f, 0.003828f, 0.004520f, 0.005833f, 0.007156f, 0.009193f, 0.012123f, 0.015839f, 0.022934f, 0.034760f,
+ 0.056488f, 0.102600f, 0.208862f, 0.427734f, 0.687988f, 0.846191f, 0.919434f, 0.952637f, 0.969727f, 0.979980f, 0.993652f, 0.994629f,
+ 0.994141f, 0.994629f, 0.994629f, 0.994629f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000133f,
+ 0.000141f, 0.000234f, 0.000300f, 0.000397f, 0.000436f, 0.000456f, 0.000465f, 0.000534f, 0.000663f, 0.000810f, 0.000796f, 0.000812f,
+ 0.001062f, 0.001237f, 0.001428f, 0.001565f, 0.001818f, 0.002182f, 0.002783f, 0.002943f, 0.003773f, 0.004715f, 0.005482f, 0.007195f,
+ 0.009285f, 0.012207f, 0.016922f, 0.024567f, 0.038483f, 0.066101f, 0.127563f, 0.274170f, 0.540527f, 0.774414f, 0.891113f, 0.940430f,
+ 0.965332f, 0.977539f, 0.993652f, 0.994141f, 0.994629f, 0.994141f, 0.994629f, 0.994141f, 0.000000f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000124f, 0.000116f, 0.000119f, 0.000125f, 0.000121f, 0.000197f, 0.000323f, 0.000418f, 0.000446f, 0.000433f,
+ 0.000467f, 0.000612f, 0.000710f, 0.000783f, 0.000911f, 0.000817f, 0.001161f, 0.001343f, 0.001514f, 0.001707f, 0.002081f, 0.002386f,
+ 0.002882f, 0.003609f, 0.004627f, 0.005478f, 0.007011f, 0.009384f, 0.012695f, 0.017960f, 0.026901f, 0.044067f, 0.080078f, 0.167114f,
+ 0.374023f, 0.664062f, 0.845703f, 0.923340f, 0.957031f, 0.974121f, 0.992676f, 0.993652f, 0.993164f, 0.993652f, 0.993652f, 0.993164f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000121f, 0.000121f, 0.000052f, 0.000039f, 0.000029f, 0.000054f, 0.000045f, 0.000118f,
+ 0.000128f, 0.000231f, 0.000387f, 0.000429f, 0.000446f, 0.000544f, 0.000539f, 0.000648f, 0.000749f, 0.000790f, 0.000978f, 0.001102f,
+ 0.001195f, 0.001501f, 0.001761f, 0.001978f, 0.002661f, 0.003170f, 0.003519f, 0.004509f, 0.005344f, 0.007004f, 0.009361f, 0.013229f,
+ 0.019196f, 0.030258f, 0.052002f, 0.102661f, 0.234131f, 0.511230f, 0.774902f, 0.898438f, 0.947754f, 0.970215f, 0.992188f, 0.992676f,
+ 0.993164f, 0.992676f, 0.992188f, 0.992188f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000070f, 0.000052f,
+ 0.000038f, 0.000030f, 0.000023f, 0.000060f, 0.000116f, 0.000121f, 0.000252f, 0.000337f, 0.000306f, 0.000435f, 0.000450f, 0.000562f,
+ 0.000584f, 0.000722f, 0.000858f, 0.000888f, 0.000969f, 0.001230f, 0.001429f, 0.001576f, 0.001827f, 0.002361f, 0.002863f, 0.003267f,
+ 0.004047f, 0.005394f, 0.007256f, 0.009781f, 0.013855f, 0.021439f, 0.035034f, 0.065063f, 0.141724f, 0.346680f, 0.665527f, 0.859375f,
+ 0.934570f, 0.965820f, 0.991699f, 0.991699f, 0.991699f, 0.992188f, 0.991699f, 0.991699f, 0.000000f, 0.000000f, 0.000122f, 0.000121f,
+ 0.000122f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f,
+ 0.000121f, 0.000121f, 0.000099f, 0.000069f, 0.000051f, 0.000039f, 0.000030f, 0.000023f, 0.000024f, 0.000115f, 0.000103f, 0.000224f,
+ 0.000204f, 0.000339f, 0.000407f, 0.000437f, 0.000452f, 0.000489f, 0.000663f, 0.000821f, 0.000922f, 0.001004f, 0.001086f, 0.001279f,
+ 0.001554f, 0.001651f, 0.001997f, 0.002390f, 0.003136f, 0.004223f, 0.005508f, 0.007339f, 0.010094f, 0.014854f, 0.024048f, 0.042664f,
+ 0.087036f, 0.213867f, 0.516113f, 0.799805f, 0.915527f, 0.958984f, 0.990723f, 0.991211f, 0.990723f, 0.990723f, 0.990723f, 0.991211f,
+ 0.000000f, 0.000122f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f,
+ 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000096f, 0.000073f, 0.000053f, 0.000040f, 0.000031f,
+ 0.000025f, 0.000020f, 0.000017f, 0.000105f, 0.000110f, 0.000135f, 0.000235f, 0.000380f, 0.000462f, 0.000513f, 0.000556f, 0.000638f,
+ 0.000804f, 0.000868f, 0.000897f, 0.001002f, 0.001079f, 0.001246f, 0.001596f, 0.002153f, 0.002213f, 0.003094f, 0.004158f, 0.005306f,
+ 0.007458f, 0.010887f, 0.017166f, 0.028748f, 0.055176f, 0.128174f, 0.350586f, 0.703613f, 0.888184f, 0.951172f, 0.988770f, 0.989746f,
+ 0.989746f, 0.989746f, 0.989746f, 0.989746f, 0.000122f, 0.000120f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f,
+ 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f,
+ 0.000101f, 0.000073f, 0.000057f, 0.000043f, 0.000033f, 0.000027f, 0.000021f, 0.000018f, 0.000105f, 0.000112f, 0.000111f, 0.000161f,
+ 0.000320f, 0.000390f, 0.000421f, 0.000438f, 0.000559f, 0.000665f, 0.000735f, 0.000719f, 0.000704f, 0.000887f, 0.001223f, 0.001384f,
+ 0.001867f, 0.002462f, 0.003216f, 0.004032f, 0.005367f, 0.007988f, 0.012054f, 0.019943f, 0.035919f, 0.078064f, 0.215332f, 0.566895f,
+ 0.845703f, 0.939941f, 0.987793f, 0.988281f, 0.987793f, 0.987793f, 0.988281f, 0.988281f, 0.000000f, 0.000120f, 0.000120f, 0.000120f,
+ 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000120f,
+ 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000103f, 0.000077f, 0.000061f, 0.000046f, 0.000037f, 0.000030f, 0.000023f,
+ 0.000019f, 0.000016f, 0.000039f, 0.000094f, 0.000181f, 0.000205f, 0.000350f, 0.000392f, 0.000423f, 0.000510f, 0.000619f, 0.000672f,
+ 0.000705f, 0.000632f, 0.000807f, 0.001038f, 0.001278f, 0.001894f, 0.002245f, 0.002758f, 0.003883f, 0.005863f, 0.008636f, 0.013672f,
+ 0.023880f, 0.048828f, 0.127441f, 0.400879f, 0.779297f, 0.925781f, 0.985840f, 0.986328f, 0.986328f, 0.985840f, 0.986328f, 0.986328f,
+ 0.000000f, 0.000100f, 0.000108f, 0.000118f, 0.000119f, 0.000118f, 0.000119f, 0.000119f, 0.000119f, 0.000119f, 0.000120f, 0.000120f,
+ 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000111f, 0.000086f,
+ 0.000066f, 0.000051f, 0.000041f, 0.000032f, 0.000026f, 0.000021f, 0.000018f, 0.000015f, 0.000086f, 0.000131f, 0.000190f, 0.000293f,
+ 0.000419f, 0.000481f, 0.000477f, 0.000438f, 0.000542f, 0.000564f, 0.000599f, 0.000700f, 0.000916f, 0.001122f, 0.001589f, 0.001997f,
+ 0.002678f, 0.004017f, 0.005814f, 0.009361f, 0.015808f, 0.031250f, 0.075989f, 0.250732f, 0.676758f, 0.904297f, 0.983887f, 0.983887f,
+ 0.983887f, 0.984375f, 0.984375f, 0.983887f, 0.000000f, 0.000000f, 0.000077f, 0.000112f, 0.000104f, 0.000115f, 0.000115f, 0.000117f,
+ 0.000117f, 0.000117f, 0.000118f, 0.000118f, 0.000118f, 0.000118f, 0.000119f, 0.000118f, 0.000119f, 0.000119f, 0.000119f, 0.000119f,
+ 0.000119f, 0.000119f, 0.000119f, 0.000119f, 0.000097f, 0.000076f, 0.000060f, 0.000046f, 0.000037f, 0.000030f, 0.000024f, 0.000020f,
+ 0.000045f, 0.000063f, 0.000091f, 0.000140f, 0.000202f, 0.000333f, 0.000305f, 0.000399f, 0.000462f, 0.000452f, 0.000535f, 0.000531f,
+ 0.000631f, 0.000866f, 0.000858f, 0.001307f, 0.001844f, 0.002823f, 0.004070f, 0.006264f, 0.010536f, 0.020035f, 0.045990f, 0.145996f,
+ 0.532227f, 0.874023f, 0.980957f, 0.981445f, 0.980957f, 0.981445f, 0.980957f, 0.981445f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000091f, 0.000103f, 0.000105f, 0.000106f, 0.000111f, 0.000113f, 0.000115f, 0.000114f, 0.000116f, 0.000116f, 0.000117f, 0.000117f,
+ 0.000117f, 0.000117f, 0.000117f, 0.000118f, 0.000118f, 0.000118f, 0.000118f, 0.000118f, 0.000118f, 0.000112f, 0.000084f, 0.000069f,
+ 0.000055f, 0.000043f, 0.000036f, 0.000028f, 0.000024f, 0.000020f, 0.000028f, 0.000039f, 0.000083f, 0.000141f, 0.000211f, 0.000262f,
+ 0.000413f, 0.000305f, 0.000370f, 0.000358f, 0.000489f, 0.000564f, 0.000599f, 0.000893f, 0.001084f, 0.001696f, 0.002697f, 0.004074f,
+ 0.006836f, 0.012878f, 0.028122f, 0.083496f, 0.364014f, 0.826660f, 0.976562f, 0.977539f, 0.977051f, 0.977539f, 0.978027f, 0.977051f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000015f, 0.000086f, 0.000077f, 0.000103f, 0.000100f, 0.000109f,
+ 0.000110f, 0.000111f, 0.000112f, 0.000112f, 0.000114f, 0.000114f, 0.000115f, 0.000115f, 0.000116f, 0.000115f, 0.000116f, 0.000116f,
+ 0.000117f, 0.000117f, 0.000117f, 0.000100f, 0.000079f, 0.000066f, 0.000053f, 0.000041f, 0.000035f, 0.000028f, 0.000023f, 0.000019f,
+ 0.000017f, 0.000034f, 0.000113f, 0.000174f, 0.000257f, 0.000325f, 0.000356f, 0.000324f, 0.000409f, 0.000454f, 0.000474f, 0.000659f,
+ 0.000778f, 0.001243f, 0.001575f, 0.002472f, 0.004105f, 0.007957f, 0.016800f, 0.047852f, 0.217529f, 0.755371f, 0.972656f, 0.973145f,
+ 0.973145f, 0.973145f, 0.973145f, 0.973145f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000028f, 0.000049f, 0.000085f, 0.000081f, 0.000096f, 0.000101f, 0.000104f, 0.000106f, 0.000108f, 0.000109f, 0.000110f,
+ 0.000111f, 0.000112f, 0.000113f, 0.000113f, 0.000114f, 0.000114f, 0.000114f, 0.000115f, 0.000115f, 0.000096f, 0.000078f, 0.000064f,
+ 0.000051f, 0.000043f, 0.000035f, 0.000029f, 0.000024f, 0.000020f, 0.000026f, 0.000055f, 0.000087f, 0.000135f, 0.000248f, 0.000261f,
+ 0.000274f, 0.000258f, 0.000296f, 0.000359f, 0.000474f, 0.000627f, 0.001012f, 0.001484f, 0.002630f, 0.004536f, 0.010277f, 0.027405f,
+ 0.119507f, 0.645996f, 0.966797f, 0.967285f, 0.967285f, 0.967285f, 0.966797f, 0.966797f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000014f, 0.000021f, 0.000065f, 0.000074f,
+ 0.000077f, 0.000091f, 0.000091f, 0.000099f, 0.000098f, 0.000103f, 0.000103f, 0.000106f, 0.000107f, 0.000108f, 0.000109f, 0.000110f,
+ 0.000111f, 0.000111f, 0.000112f, 0.000096f, 0.000079f, 0.000064f, 0.000053f, 0.000043f, 0.000036f, 0.000030f, 0.000024f, 0.000021f,
+ 0.000018f, 0.000028f, 0.000072f, 0.000125f, 0.000233f, 0.000243f, 0.000220f, 0.000258f, 0.000320f, 0.000353f, 0.000630f, 0.000932f,
+ 0.001324f, 0.002357f, 0.005402f, 0.014534f, 0.062561f, 0.493164f, 0.958008f, 0.958008f, 0.958984f, 0.958496f, 0.958496f, 0.958008f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000011f, 0.000035f, 0.000041f, 0.000064f, 0.000074f, 0.000081f, 0.000082f, 0.000090f,
+ 0.000092f, 0.000096f, 0.000099f, 0.000100f, 0.000102f, 0.000104f, 0.000105f, 0.000106f, 0.000107f, 0.000099f, 0.000082f, 0.000067f,
+ 0.000055f, 0.000047f, 0.000038f, 0.000031f, 0.000026f, 0.000022f, 0.000018f, 0.000037f, 0.000071f, 0.000111f, 0.000190f, 0.000204f,
+ 0.000153f, 0.000245f, 0.000299f, 0.000482f, 0.000790f, 0.001330f, 0.002619f, 0.007282f, 0.031097f, 0.318115f, 0.946289f, 0.946777f,
+ 0.946777f, 0.946777f, 0.946777f, 0.946777f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000008f, 0.000029f, 0.000044f, 0.000055f, 0.000063f, 0.000073f, 0.000075f, 0.000081f, 0.000087f, 0.000090f, 0.000092f,
+ 0.000094f, 0.000097f, 0.000099f, 0.000100f, 0.000087f, 0.000071f, 0.000059f, 0.000049f, 0.000040f, 0.000034f, 0.000028f, 0.000024f,
+ 0.000020f, 0.000016f, 0.000072f, 0.000114f, 0.000169f, 0.000147f, 0.000181f, 0.000246f, 0.000367f, 0.000626f, 0.001325f, 0.003117f,
+ 0.013741f, 0.167480f, 0.929688f, 0.929688f, 0.929688f, 0.930176f, 0.930664f, 0.930176f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000019f,
+ 0.000030f, 0.000044f, 0.000049f, 0.000062f, 0.000068f, 0.000072f, 0.000078f, 0.000081f, 0.000084f, 0.000087f, 0.000090f, 0.000079f,
+ 0.000065f, 0.000054f, 0.000044f, 0.000037f, 0.000030f, 0.000025f, 0.000021f, 0.000017f, 0.000052f, 0.000100f, 0.000132f, 0.000130f,
+ 0.000164f, 0.000297f, 0.000552f, 0.001273f, 0.005009f, 0.071594f, 0.903809f, 0.905273f, 0.904297f, 0.904785f, 0.904785f, 0.904785f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000013f, 0.000028f, 0.000036f,
+ 0.000045f, 0.000053f, 0.000060f, 0.000066f, 0.000071f, 0.000075f, 0.000071f, 0.000058f, 0.000049f, 0.000040f, 0.000033f, 0.000027f,
+ 0.000022f, 0.000018f, 0.000032f, 0.000078f, 0.000090f, 0.000123f, 0.000175f, 0.000441f, 0.001637f, 0.022537f, 0.865234f, 0.865234f,
+ 0.865723f, 0.865723f, 0.865234f, 0.864746f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000004f, 0.000017f, 0.000027f, 0.000036f, 0.000042f,
+ 0.000050f, 0.000056f, 0.000052f, 0.000043f, 0.000035f, 0.000028f, 0.000022f, 0.000018f, 0.000049f, 0.000055f, 0.000047f, 0.000108f,
+ 0.000342f, 0.004566f, 0.802734f, 0.803711f, 0.803711f, 0.803711f, 0.803711f, 0.803711f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000013f, 0.000022f, 0.000030f, 0.000033f, 0.000027f,
+ 0.000021f, 0.000015f, 0.000011f, 0.000031f, 0.000045f, 0.000449f, 0.708496f, 0.707520f, 0.708984f, 0.708496f, 0.707520f, 0.708008f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000004f, 0.000011f, 0.000006f, 0.000007f, 0.575195f, 0.575195f,
+ 0.575195f, 0.575195f, 0.575195f, 0.575195f,
+ },
+ {
+ 0.158813f, 0.632812f, 0.824219f, 0.891602f, 0.924805f, 0.942383f, 0.954102f, 0.962402f, 0.968262f, 0.972656f, 0.976074f, 0.978516f,
+ 0.980957f, 0.982910f, 0.984375f, 0.985840f, 0.986816f, 0.988770f, 0.989746f, 0.989746f, 0.990234f, 0.991211f, 0.992188f, 0.992676f,
+ 0.993652f, 0.993652f, 0.993652f, 0.994141f, 0.994629f, 0.995117f, 0.995605f, 0.995605f, 0.996094f, 0.996582f, 0.996582f, 0.996582f,
+ 0.997070f, 0.997070f, 0.997070f, 0.997070f, 0.997559f, 0.998047f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.019775f, 0.115845f, 0.361084f, 0.642578f, 0.798340f, 0.872559f, 0.911133f, 0.933594f,
+ 0.947266f, 0.957031f, 0.964355f, 0.968750f, 0.973145f, 0.976562f, 0.979492f, 0.981934f, 0.983398f, 0.984863f, 0.986816f, 0.987793f,
+ 0.988770f, 0.989258f, 0.990234f, 0.991211f, 0.991699f, 0.992676f, 0.993164f, 0.993164f, 0.993652f, 0.994141f, 0.995117f, 0.995117f,
+ 0.995605f, 0.995605f, 0.996094f, 0.996094f, 0.996094f, 0.996582f, 0.997070f, 0.997070f, 0.997559f, 0.997559f, 0.997559f, 0.998047f,
+ 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.006638f, 0.031082f, 0.089661f, 0.222168f,
+ 0.448242f, 0.663086f, 0.794434f, 0.864258f, 0.903320f, 0.926758f, 0.942383f, 0.953613f, 0.961426f, 0.966797f, 0.972168f, 0.975586f,
+ 0.978027f, 0.980469f, 0.982910f, 0.984375f, 0.985840f, 0.986816f, 0.988281f, 0.989258f, 0.990234f, 0.991211f, 0.991699f, 0.992188f,
+ 0.992676f, 0.993164f, 0.993652f, 0.994141f, 0.994629f, 0.995117f, 0.995605f, 0.995605f, 0.996094f, 0.996582f, 0.996582f, 0.996582f,
+ 0.997070f, 0.997070f, 0.997559f, 0.997559f, 0.997559f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.003246f, 0.013367f, 0.032806f, 0.072754f, 0.152954f, 0.304199f, 0.509766f, 0.687500f, 0.797852f, 0.862305f, 0.900391f, 0.923828f,
+ 0.940430f, 0.950684f, 0.959473f, 0.965820f, 0.970703f, 0.974121f, 0.977051f, 0.979492f, 0.981934f, 0.983887f, 0.985840f, 0.987305f,
+ 0.987793f, 0.989258f, 0.989746f, 0.990723f, 0.991211f, 0.992188f, 0.992188f, 0.993164f, 0.993652f, 0.993652f, 0.994629f, 0.995117f,
+ 0.995605f, 0.996094f, 0.996094f, 0.996094f, 0.996582f, 0.996582f, 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.998047f, 0.998047f,
+ 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.002029f, 0.007267f, 0.016678f, 0.032288f, 0.061462f, 0.115051f, 0.215088f, 0.376709f,
+ 0.562988f, 0.712891f, 0.807617f, 0.865234f, 0.901367f, 0.923828f, 0.939453f, 0.950684f, 0.958984f, 0.965332f, 0.970215f, 0.974609f,
+ 0.977051f, 0.979980f, 0.981934f, 0.983887f, 0.984863f, 0.986328f, 0.988281f, 0.988770f, 0.989746f, 0.990723f, 0.990723f, 0.991699f,
+ 0.992188f, 0.992676f, 0.993652f, 0.994141f, 0.994629f, 0.995117f, 0.995117f, 0.996094f, 0.996094f, 0.996094f, 0.996582f, 0.996582f,
+ 0.997070f, 0.997559f, 0.997559f, 0.997559f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.001274f, 0.004623f, 0.009880f, 0.017792f,
+ 0.030869f, 0.052673f, 0.091431f, 0.160645f, 0.277832f, 0.442383f, 0.610352f, 0.737793f, 0.819824f, 0.870605f, 0.902832f, 0.924805f,
+ 0.939941f, 0.950195f, 0.958496f, 0.964844f, 0.970215f, 0.973633f, 0.977051f, 0.979980f, 0.981934f, 0.983398f, 0.984863f, 0.986328f,
+ 0.987305f, 0.988770f, 0.989746f, 0.990723f, 0.991211f, 0.992188f, 0.992676f, 0.993164f, 0.993652f, 0.994141f, 0.994629f, 0.995117f,
+ 0.995605f, 0.996094f, 0.996094f, 0.996094f, 0.996582f, 0.996582f, 0.997070f, 0.997070f, 0.997559f, 0.998047f, 0.997559f, 0.998047f,
+ 0.998047f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000943f, 0.003231f, 0.006317f, 0.011040f, 0.018051f, 0.029190f, 0.046936f, 0.075867f, 0.125488f, 0.210449f, 0.341797f, 0.503906f,
+ 0.652344f, 0.761230f, 0.832031f, 0.877441f, 0.906738f, 0.927734f, 0.940918f, 0.951172f, 0.959473f, 0.965820f, 0.970703f, 0.974121f,
+ 0.977051f, 0.979492f, 0.981934f, 0.983398f, 0.985352f, 0.987305f, 0.988281f, 0.989258f, 0.990234f, 0.990723f, 0.991211f, 0.992188f,
+ 0.992676f, 0.993164f, 0.994141f, 0.994629f, 0.995117f, 0.995605f, 0.995605f, 0.996094f, 0.996094f, 0.996582f, 0.996582f, 0.996582f,
+ 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.997559f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000731f, 0.001970f, 0.004425f, 0.007351f, 0.011627f, 0.017975f, 0.027161f, 0.041779f,
+ 0.064270f, 0.101685f, 0.164917f, 0.265137f, 0.406494f, 0.561035f, 0.692383f, 0.785156f, 0.845703f, 0.884766f, 0.911621f, 0.930176f,
+ 0.942871f, 0.953125f, 0.959961f, 0.965332f, 0.970703f, 0.974121f, 0.977539f, 0.979492f, 0.982422f, 0.983887f, 0.985840f, 0.987305f,
+ 0.987793f, 0.989258f, 0.990234f, 0.991211f, 0.991699f, 0.992676f, 0.993164f, 0.993652f, 0.994141f, 0.995117f, 0.995117f, 0.995605f,
+ 0.995605f, 0.996094f, 0.996094f, 0.996582f, 0.997070f, 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.998047f, 0.998047f, 0.998535f,
+ 0.998535f, 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.000487f, 0.001872f, 0.003445f, 0.005367f,
+ 0.008400f, 0.012405f, 0.017822f, 0.025345f, 0.037964f, 0.056244f, 0.085327f, 0.132935f, 0.210327f, 0.325928f, 0.471924f, 0.615723f,
+ 0.729004f, 0.807617f, 0.859375f, 0.894043f, 0.916504f, 0.934570f, 0.945801f, 0.955078f, 0.961426f, 0.967285f, 0.972168f, 0.975586f,
+ 0.978516f, 0.980957f, 0.982422f, 0.984863f, 0.985840f, 0.986816f, 0.988770f, 0.989258f, 0.990723f, 0.991699f, 0.992188f, 0.992676f,
+ 0.993652f, 0.994141f, 0.994629f, 0.995117f, 0.995117f, 0.995605f, 0.996094f, 0.996094f, 0.996094f, 0.997070f, 0.997070f, 0.997559f,
+ 0.997559f, 0.998047f, 0.997559f, 0.998047f, 0.998535f, 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.000363f, 0.001300f, 0.002499f, 0.003784f, 0.006153f, 0.008896f, 0.012367f, 0.017227f, 0.024185f, 0.034241f, 0.049591f, 0.072754f,
+ 0.111023f, 0.170776f, 0.263184f, 0.391113f, 0.535645f, 0.665527f, 0.761719f, 0.828613f, 0.871582f, 0.902344f, 0.922852f, 0.937988f,
+ 0.949219f, 0.957031f, 0.963867f, 0.968750f, 0.972656f, 0.976074f, 0.979004f, 0.981445f, 0.983887f, 0.984863f, 0.986328f, 0.988281f,
+ 0.989258f, 0.990234f, 0.991211f, 0.991699f, 0.992676f, 0.993652f, 0.993652f, 0.994629f, 0.995117f, 0.995117f, 0.995605f, 0.996094f,
+ 0.996094f, 0.996094f, 0.996582f, 0.996582f, 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.998535f, 0.998535f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999023f, 0.999023f, 0.000365f, 0.000972f, 0.001874f, 0.003323f, 0.004669f, 0.006599f, 0.008919f, 0.012360f,
+ 0.016785f, 0.022720f, 0.031616f, 0.044647f, 0.064026f, 0.094055f, 0.141235f, 0.215332f, 0.323486f, 0.459229f, 0.597168f, 0.710449f,
+ 0.791992f, 0.847656f, 0.885254f, 0.910645f, 0.929199f, 0.941895f, 0.952148f, 0.960449f, 0.965332f, 0.970703f, 0.974121f, 0.977539f,
+ 0.979980f, 0.981934f, 0.984375f, 0.985840f, 0.987305f, 0.988770f, 0.989746f, 0.990723f, 0.991211f, 0.992188f, 0.993164f, 0.993164f,
+ 0.994141f, 0.994629f, 0.995117f, 0.995605f, 0.996094f, 0.996094f, 0.996094f, 0.996582f, 0.997070f, 0.997559f, 0.997559f, 0.997559f,
+ 0.998047f, 0.998535f, 0.999023f, 0.999512f, 0.999023f, 0.999512f, 0.999512f, 0.999023f, 0.000244f, 0.000764f, 0.001375f, 0.002415f,
+ 0.003582f, 0.004963f, 0.006973f, 0.008751f, 0.011726f, 0.016113f, 0.021683f, 0.029129f, 0.040283f, 0.057098f, 0.081421f, 0.119019f,
+ 0.178955f, 0.268311f, 0.390625f, 0.528809f, 0.654785f, 0.751465f, 0.820312f, 0.866211f, 0.896973f, 0.919434f, 0.935547f, 0.946777f,
+ 0.956055f, 0.962402f, 0.968262f, 0.972168f, 0.975098f, 0.979004f, 0.981445f, 0.983398f, 0.985352f, 0.986816f, 0.987793f, 0.989258f,
+ 0.990723f, 0.991211f, 0.992188f, 0.992188f, 0.993164f, 0.993652f, 0.994629f, 0.995117f, 0.995117f, 0.995605f, 0.996094f, 0.996094f,
+ 0.996582f, 0.997070f, 0.997559f, 0.997559f, 0.997559f, 0.998047f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.000122f, 0.000606f, 0.001439f, 0.002058f, 0.002743f, 0.004169f, 0.005035f, 0.006775f, 0.009010f, 0.012085f, 0.015717f, 0.020813f,
+ 0.027573f, 0.037170f, 0.050812f, 0.071472f, 0.102905f, 0.151489f, 0.225708f, 0.332031f, 0.463623f, 0.596191f, 0.707031f, 0.787598f,
+ 0.844238f, 0.881348f, 0.908691f, 0.927246f, 0.940918f, 0.951660f, 0.958984f, 0.965820f, 0.970215f, 0.974121f, 0.977539f, 0.979980f,
+ 0.982422f, 0.984375f, 0.985840f, 0.987305f, 0.988281f, 0.990234f, 0.990723f, 0.991699f, 0.992676f, 0.993164f, 0.993652f, 0.994141f,
+ 0.994629f, 0.995117f, 0.995605f, 0.995605f, 0.996094f, 0.996582f, 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.000118f, 0.000846f, 0.001303f, 0.001593f, 0.002180f, 0.003050f, 0.004353f, 0.005577f,
+ 0.006954f, 0.009331f, 0.011826f, 0.015007f, 0.019653f, 0.025391f, 0.034119f, 0.046112f, 0.063660f, 0.090210f, 0.130737f, 0.192139f,
+ 0.283203f, 0.404053f, 0.537598f, 0.658691f, 0.753418f, 0.818848f, 0.865234f, 0.896973f, 0.918945f, 0.934570f, 0.946289f, 0.955566f,
+ 0.962402f, 0.967285f, 0.972168f, 0.976074f, 0.979004f, 0.981445f, 0.983398f, 0.985840f, 0.986816f, 0.988281f, 0.989258f, 0.990723f,
+ 0.991211f, 0.992676f, 0.993164f, 0.993652f, 0.994141f, 0.994629f, 0.995117f, 0.995117f, 0.995605f, 0.996094f, 0.996582f, 0.997070f,
+ 0.997559f, 0.998047f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.000117f, 0.000487f, 0.000957f, 0.001514f,
+ 0.002008f, 0.002619f, 0.003424f, 0.004551f, 0.005836f, 0.007381f, 0.009155f, 0.011459f, 0.014366f, 0.018646f, 0.024017f, 0.031281f,
+ 0.042664f, 0.057068f, 0.080139f, 0.113586f, 0.165894f, 0.243164f, 0.352051f, 0.481934f, 0.610840f, 0.716309f, 0.793945f, 0.847168f,
+ 0.884766f, 0.910645f, 0.928223f, 0.942383f, 0.952637f, 0.959961f, 0.965332f, 0.970703f, 0.975098f, 0.978027f, 0.980957f, 0.983398f,
+ 0.984863f, 0.986816f, 0.988281f, 0.989258f, 0.990723f, 0.991211f, 0.992188f, 0.992676f, 0.993164f, 0.993652f, 0.994629f, 0.995117f,
+ 0.995605f, 0.996094f, 0.996094f, 0.996582f, 0.997559f, 0.997070f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.000000f, 0.000608f, 0.000952f, 0.001111f, 0.001660f, 0.002102f, 0.002817f, 0.003517f, 0.004742f, 0.005585f, 0.007080f, 0.008980f,
+ 0.011078f, 0.014191f, 0.017838f, 0.022614f, 0.029404f, 0.038940f, 0.052551f, 0.071533f, 0.100769f, 0.145020f, 0.211548f, 0.307373f,
+ 0.430176f, 0.561523f, 0.676758f, 0.764648f, 0.828613f, 0.872070f, 0.900879f, 0.921875f, 0.937012f, 0.948730f, 0.957520f, 0.964355f,
+ 0.969238f, 0.973633f, 0.977539f, 0.979980f, 0.982422f, 0.984863f, 0.986328f, 0.987793f, 0.988770f, 0.990234f, 0.991211f, 0.991699f,
+ 0.992676f, 0.993652f, 0.994141f, 0.994629f, 0.994629f, 0.995605f, 0.996094f, 0.996582f, 0.997070f, 0.997070f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.000244f, 0.000576f, 0.000727f, 0.001083f, 0.001186f, 0.001810f, 0.002558f, 0.002968f,
+ 0.003725f, 0.004913f, 0.005955f, 0.007011f, 0.008759f, 0.010918f, 0.013718f, 0.016953f, 0.021423f, 0.027832f, 0.035980f, 0.047913f,
+ 0.064941f, 0.090332f, 0.128174f, 0.185791f, 0.270264f, 0.384033f, 0.514160f, 0.638184f, 0.736328f, 0.807617f, 0.856934f, 0.891602f,
+ 0.915039f, 0.932617f, 0.945801f, 0.954102f, 0.962402f, 0.968262f, 0.972168f, 0.976562f, 0.979492f, 0.981445f, 0.983887f, 0.985840f,
+ 0.987305f, 0.988281f, 0.990234f, 0.990723f, 0.992188f, 0.992676f, 0.993164f, 0.994141f, 0.994629f, 0.995117f, 0.995605f, 0.996094f,
+ 0.996582f, 0.997070f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.000000f, 0.000244f, 0.000708f, 0.000903f,
+ 0.001129f, 0.001511f, 0.002031f, 0.002565f, 0.003189f, 0.004112f, 0.004696f, 0.005989f, 0.006954f, 0.008865f, 0.010826f, 0.013031f,
+ 0.016312f, 0.020493f, 0.026154f, 0.033966f, 0.044159f, 0.059845f, 0.081665f, 0.114929f, 0.164917f, 0.239624f, 0.343750f, 0.469971f,
+ 0.598145f, 0.706055f, 0.786133f, 0.842773f, 0.881348f, 0.908203f, 0.927246f, 0.941895f, 0.952148f, 0.959961f, 0.966797f, 0.971191f,
+ 0.976074f, 0.978516f, 0.981445f, 0.983887f, 0.985352f, 0.987305f, 0.988281f, 0.989258f, 0.990723f, 0.991699f, 0.992676f, 0.993652f,
+ 0.994141f, 0.994629f, 0.995605f, 0.996094f, 0.996094f, 0.996582f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f,
+ 0.000122f, 0.000244f, 0.000482f, 0.000674f, 0.001029f, 0.001440f, 0.001746f, 0.002153f, 0.002804f, 0.003206f, 0.003859f, 0.004948f,
+ 0.005722f, 0.007206f, 0.008568f, 0.010498f, 0.012413f, 0.015793f, 0.019989f, 0.024826f, 0.031799f, 0.041382f, 0.054932f, 0.074768f,
+ 0.103882f, 0.147949f, 0.213867f, 0.308838f, 0.429932f, 0.560059f, 0.675781f, 0.765625f, 0.827148f, 0.871582f, 0.901367f, 0.923340f,
+ 0.937988f, 0.949707f, 0.958496f, 0.965820f, 0.969727f, 0.974609f, 0.978027f, 0.980469f, 0.983398f, 0.985840f, 0.986816f, 0.988281f,
+ 0.989258f, 0.990723f, 0.992188f, 0.992676f, 0.993652f, 0.994141f, 0.994629f, 0.995117f, 0.995605f, 0.996582f, 0.998535f, 0.998535f,
+ 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.000244f, 0.000244f, 0.000363f, 0.000604f, 0.000834f, 0.001020f, 0.001548f, 0.001970f,
+ 0.002262f, 0.002548f, 0.003157f, 0.003914f, 0.004681f, 0.005962f, 0.006943f, 0.008263f, 0.010277f, 0.012589f, 0.015144f, 0.018951f,
+ 0.023788f, 0.030014f, 0.039001f, 0.051056f, 0.069092f, 0.094666f, 0.133911f, 0.192993f, 0.279053f, 0.394287f, 0.524414f, 0.646484f,
+ 0.743652f, 0.812988f, 0.861328f, 0.895020f, 0.917969f, 0.935547f, 0.947754f, 0.957520f, 0.963867f, 0.969238f, 0.974121f, 0.978027f,
+ 0.980469f, 0.983398f, 0.984863f, 0.987305f, 0.988281f, 0.989258f, 0.990723f, 0.991699f, 0.992676f, 0.993652f, 0.994141f, 0.994629f,
+ 0.995117f, 0.996094f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.000118f, 0.000244f, 0.000244f, 0.000584f,
+ 0.000837f, 0.000847f, 0.001295f, 0.001681f, 0.002018f, 0.002348f, 0.003014f, 0.003157f, 0.004124f, 0.004547f, 0.005432f, 0.006607f,
+ 0.008163f, 0.010071f, 0.011925f, 0.014786f, 0.017990f, 0.022659f, 0.028824f, 0.036621f, 0.047882f, 0.063477f, 0.087158f, 0.122559f,
+ 0.175781f, 0.254639f, 0.363037f, 0.492188f, 0.618652f, 0.722168f, 0.799805f, 0.852051f, 0.889648f, 0.914551f, 0.932129f, 0.944824f,
+ 0.955078f, 0.962891f, 0.968262f, 0.973633f, 0.977051f, 0.980469f, 0.982910f, 0.984863f, 0.987305f, 0.988281f, 0.990234f, 0.991211f,
+ 0.992188f, 0.993164f, 0.993652f, 0.994141f, 0.995117f, 0.995605f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f,
+ 0.000242f, 0.000243f, 0.000243f, 0.000481f, 0.000742f, 0.000843f, 0.000969f, 0.001348f, 0.001726f, 0.001791f, 0.002348f, 0.002853f,
+ 0.003452f, 0.003735f, 0.004757f, 0.005516f, 0.006744f, 0.008102f, 0.009621f, 0.011948f, 0.014320f, 0.017365f, 0.021698f, 0.027298f,
+ 0.034546f, 0.044891f, 0.059875f, 0.081055f, 0.112915f, 0.161255f, 0.234009f, 0.335693f, 0.462646f, 0.592285f, 0.702637f, 0.785645f,
+ 0.843750f, 0.883301f, 0.911133f, 0.929688f, 0.944336f, 0.954590f, 0.961914f, 0.967773f, 0.973633f, 0.977539f, 0.980469f, 0.982910f,
+ 0.985352f, 0.986816f, 0.988770f, 0.990234f, 0.991211f, 0.992188f, 0.993164f, 0.993652f, 0.994629f, 0.995117f, 0.998047f, 0.998535f,
+ 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.000100f, 0.000216f, 0.000243f, 0.000365f, 0.000517f, 0.000836f, 0.000964f, 0.001148f,
+ 0.001472f, 0.001674f, 0.001785f, 0.002438f, 0.002815f, 0.003490f, 0.004070f, 0.004837f, 0.005608f, 0.006630f, 0.008095f, 0.009483f,
+ 0.011551f, 0.013847f, 0.016953f, 0.020584f, 0.025879f, 0.033051f, 0.042664f, 0.055817f, 0.075500f, 0.105103f, 0.149536f, 0.216553f,
+ 0.312988f, 0.436768f, 0.568359f, 0.685059f, 0.773926f, 0.835449f, 0.878418f, 0.907227f, 0.927734f, 0.943359f, 0.953125f, 0.962402f,
+ 0.967285f, 0.973145f, 0.977051f, 0.980469f, 0.983887f, 0.985352f, 0.987305f, 0.989258f, 0.990234f, 0.991699f, 0.992188f, 0.993164f,
+ 0.994141f, 0.994629f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.000000f, 0.000150f, 0.000242f, 0.000364f,
+ 0.000441f, 0.000627f, 0.000916f, 0.000959f, 0.000968f, 0.001463f, 0.001671f, 0.002222f, 0.002577f, 0.002714f, 0.003479f, 0.004208f,
+ 0.004723f, 0.005669f, 0.006886f, 0.007637f, 0.009315f, 0.011154f, 0.013596f, 0.016205f, 0.019821f, 0.024963f, 0.031250f, 0.040375f,
+ 0.053009f, 0.071167f, 0.098511f, 0.139648f, 0.202271f, 0.293457f, 0.414307f, 0.548340f, 0.669434f, 0.762695f, 0.829590f, 0.874512f,
+ 0.904785f, 0.926758f, 0.941895f, 0.953613f, 0.961914f, 0.968262f, 0.973633f, 0.977539f, 0.980957f, 0.983398f, 0.985352f, 0.987793f,
+ 0.989258f, 0.990234f, 0.991211f, 0.992188f, 0.993164f, 0.994629f, 0.998047f, 0.998535f, 0.998047f, 0.998047f, 0.998047f, 0.998047f,
+ 0.000000f, 0.000231f, 0.000232f, 0.000363f, 0.000486f, 0.000503f, 0.000724f, 0.001104f, 0.001080f, 0.001271f, 0.001509f, 0.001976f,
+ 0.002247f, 0.002476f, 0.002895f, 0.003553f, 0.004192f, 0.004871f, 0.005623f, 0.006332f, 0.007584f, 0.008957f, 0.010849f, 0.012917f,
+ 0.015396f, 0.019226f, 0.023941f, 0.030060f, 0.038513f, 0.050385f, 0.067627f, 0.093140f, 0.131714f, 0.190674f, 0.278076f, 0.395752f,
+ 0.530273f, 0.655762f, 0.753906f, 0.823242f, 0.870605f, 0.903320f, 0.925781f, 0.941406f, 0.953125f, 0.961914f, 0.969238f, 0.974121f,
+ 0.978027f, 0.980957f, 0.983887f, 0.985840f, 0.988281f, 0.989258f, 0.990723f, 0.991699f, 0.992676f, 0.993652f, 0.997559f, 0.998047f,
+ 0.998047f, 0.998047f, 0.998047f, 0.998047f, 0.000000f, 0.000009f, 0.000116f, 0.000360f, 0.000484f, 0.000485f, 0.000536f, 0.000827f,
+ 0.000935f, 0.001077f, 0.001204f, 0.001561f, 0.001974f, 0.002136f, 0.002777f, 0.002964f, 0.003517f, 0.004192f, 0.004711f, 0.005505f,
+ 0.006283f, 0.007408f, 0.008713f, 0.010674f, 0.012375f, 0.015099f, 0.018677f, 0.022797f, 0.028732f, 0.036835f, 0.047974f, 0.064270f,
+ 0.088318f, 0.124634f, 0.180664f, 0.264893f, 0.380615f, 0.516113f, 0.645020f, 0.747559f, 0.819824f, 0.870117f, 0.902344f, 0.925293f,
+ 0.941406f, 0.953613f, 0.962402f, 0.969238f, 0.974121f, 0.978027f, 0.981934f, 0.984375f, 0.986328f, 0.988281f, 0.989746f, 0.990723f,
+ 0.992676f, 0.993164f, 0.997559f, 0.998047f, 0.998047f, 0.997559f, 0.998047f, 0.998047f, 0.000000f, 0.000000f, 0.000074f, 0.000337f,
+ 0.000481f, 0.000484f, 0.000485f, 0.000556f, 0.000823f, 0.001143f, 0.001187f, 0.001391f, 0.001781f, 0.002155f, 0.002327f, 0.002760f,
+ 0.003008f, 0.003433f, 0.004101f, 0.004681f, 0.005417f, 0.006443f, 0.007393f, 0.008560f, 0.010345f, 0.012177f, 0.014496f, 0.018127f,
+ 0.022125f, 0.027740f, 0.035736f, 0.046173f, 0.061920f, 0.084717f, 0.119324f, 0.173218f, 0.254883f, 0.368652f, 0.505371f, 0.637207f,
+ 0.742676f, 0.818359f, 0.868164f, 0.902832f, 0.925781f, 0.942383f, 0.953613f, 0.963379f, 0.970215f, 0.975098f, 0.979004f, 0.982422f,
+ 0.984863f, 0.986328f, 0.988770f, 0.990723f, 0.991699f, 0.992676f, 0.997070f, 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.997559f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000188f, 0.000358f, 0.000481f, 0.000484f, 0.000484f, 0.000704f, 0.000852f, 0.001165f, 0.001316f,
+ 0.001500f, 0.001685f, 0.001933f, 0.002079f, 0.002720f, 0.003136f, 0.003727f, 0.003723f, 0.004513f, 0.005207f, 0.006275f, 0.007236f,
+ 0.008453f, 0.010056f, 0.011848f, 0.014191f, 0.017212f, 0.021652f, 0.026978f, 0.034241f, 0.044678f, 0.058990f, 0.081421f, 0.114929f,
+ 0.167236f, 0.247070f, 0.360596f, 0.498291f, 0.632812f, 0.741211f, 0.818359f, 0.869629f, 0.903809f, 0.927734f, 0.943848f, 0.955566f,
+ 0.964355f, 0.970703f, 0.976074f, 0.979492f, 0.982422f, 0.985840f, 0.987793f, 0.989258f, 0.990723f, 0.992188f, 0.997070f, 0.997559f,
+ 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.000000f, 0.000000f, 0.000121f, 0.000120f, 0.000288f, 0.000357f, 0.000479f, 0.000483f,
+ 0.000535f, 0.000711f, 0.000862f, 0.001256f, 0.001351f, 0.001502f, 0.001719f, 0.002146f, 0.002037f, 0.002653f, 0.003248f, 0.003222f,
+ 0.003820f, 0.004456f, 0.005173f, 0.006008f, 0.007072f, 0.008247f, 0.009758f, 0.011826f, 0.013771f, 0.016861f, 0.020935f, 0.025986f,
+ 0.032928f, 0.043030f, 0.057587f, 0.078918f, 0.111755f, 0.162964f, 0.241943f, 0.355713f, 0.495117f, 0.632324f, 0.742676f, 0.819336f,
+ 0.871582f, 0.905762f, 0.929688f, 0.945312f, 0.957031f, 0.965332f, 0.972168f, 0.976562f, 0.980957f, 0.983887f, 0.986328f, 0.988281f,
+ 0.990234f, 0.991699f, 0.997070f, 0.997559f, 0.997070f, 0.997559f, 0.997559f, 0.997559f, 0.000000f, 0.000000f, 0.000000f, 0.000121f,
+ 0.000200f, 0.000412f, 0.000471f, 0.000599f, 0.000598f, 0.000596f, 0.000805f, 0.001099f, 0.001334f, 0.001417f, 0.001456f, 0.001723f,
+ 0.002102f, 0.002283f, 0.002579f, 0.003208f, 0.003233f, 0.003740f, 0.004574f, 0.005287f, 0.006012f, 0.006870f, 0.008018f, 0.009354f,
+ 0.011208f, 0.013542f, 0.016495f, 0.020370f, 0.025284f, 0.032410f, 0.041901f, 0.056183f, 0.077087f, 0.109558f, 0.160278f, 0.239380f,
+ 0.354492f, 0.496094f, 0.635254f, 0.747070f, 0.823730f, 0.875488f, 0.908691f, 0.931641f, 0.947266f, 0.958008f, 0.966309f, 0.972656f,
+ 0.978027f, 0.981445f, 0.984863f, 0.986816f, 0.989258f, 0.990723f, 0.996582f, 0.997070f, 0.997070f, 0.997070f, 0.997070f, 0.997070f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000117f, 0.000237f, 0.000239f, 0.000430f, 0.000465f, 0.000599f, 0.000724f, 0.000716f, 0.000815f,
+ 0.000981f, 0.001334f, 0.001299f, 0.001545f, 0.001617f, 0.001935f, 0.002110f, 0.002501f, 0.002823f, 0.003408f, 0.003790f, 0.004467f,
+ 0.005112f, 0.005848f, 0.006718f, 0.007942f, 0.009514f, 0.011093f, 0.013092f, 0.015945f, 0.019608f, 0.024689f, 0.031494f, 0.041046f,
+ 0.054901f, 0.075989f, 0.108032f, 0.158936f, 0.239014f, 0.356201f, 0.500488f, 0.642090f, 0.753418f, 0.830566f, 0.880859f, 0.912598f,
+ 0.935059f, 0.950195f, 0.960449f, 0.968262f, 0.975098f, 0.979980f, 0.982910f, 0.985352f, 0.987793f, 0.990234f, 0.996582f, 0.997070f,
+ 0.997070f, 0.996582f, 0.997070f, 0.996582f, 0.000000f, 0.000000f, 0.000000f, 0.000117f, 0.000120f, 0.000121f, 0.000312f, 0.000407f,
+ 0.000707f, 0.000597f, 0.000648f, 0.000720f, 0.000941f, 0.001008f, 0.001229f, 0.001289f, 0.001423f, 0.001726f, 0.002060f, 0.002211f,
+ 0.002506f, 0.002985f, 0.003036f, 0.003683f, 0.004066f, 0.004833f, 0.005592f, 0.006611f, 0.007675f, 0.008965f, 0.010811f, 0.012833f,
+ 0.015854f, 0.019485f, 0.024429f, 0.031036f, 0.040466f, 0.054108f, 0.074890f, 0.107727f, 0.159180f, 0.241699f, 0.362549f, 0.510742f,
+ 0.653809f, 0.763184f, 0.837891f, 0.887207f, 0.917480f, 0.938477f, 0.953613f, 0.962891f, 0.970703f, 0.976562f, 0.980469f, 0.984375f,
+ 0.986816f, 0.988770f, 0.996094f, 0.996582f, 0.996582f, 0.996582f, 0.996582f, 0.996582f, 0.000000f, 0.000000f, 0.000000f, 0.000117f,
+ 0.000118f, 0.000120f, 0.000129f, 0.000434f, 0.000536f, 0.000613f, 0.000716f, 0.000799f, 0.000720f, 0.000768f, 0.001024f, 0.001202f,
+ 0.001501f, 0.001530f, 0.001568f, 0.001897f, 0.002190f, 0.002502f, 0.002893f, 0.003105f, 0.003551f, 0.004021f, 0.004791f, 0.005405f,
+ 0.006313f, 0.007309f, 0.008720f, 0.010712f, 0.012657f, 0.015472f, 0.018982f, 0.023697f, 0.030579f, 0.040009f, 0.054138f, 0.075012f,
+ 0.107849f, 0.161377f, 0.247070f, 0.373047f, 0.525391f, 0.667969f, 0.776855f, 0.847656f, 0.894043f, 0.923340f, 0.942871f, 0.956543f,
+ 0.965820f, 0.973145f, 0.978027f, 0.982422f, 0.985352f, 0.987793f, 0.996094f, 0.996094f, 0.996582f, 0.996094f, 0.996582f, 0.996094f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000081f, 0.000116f, 0.000227f, 0.000360f, 0.000366f, 0.000642f, 0.000691f, 0.000711f,
+ 0.000806f, 0.000721f, 0.000925f, 0.000947f, 0.001155f, 0.001478f, 0.001554f, 0.001612f, 0.001929f, 0.002354f, 0.002291f, 0.002712f,
+ 0.003029f, 0.003441f, 0.003876f, 0.004452f, 0.005276f, 0.006256f, 0.007149f, 0.008568f, 0.010040f, 0.012566f, 0.015160f, 0.018677f,
+ 0.023376f, 0.030411f, 0.039642f, 0.053986f, 0.075134f, 0.109436f, 0.165527f, 0.255127f, 0.387695f, 0.544434f, 0.686523f, 0.791016f,
+ 0.858398f, 0.901367f, 0.928711f, 0.947266f, 0.959961f, 0.968262f, 0.975098f, 0.980469f, 0.983887f, 0.987305f, 0.995605f, 0.996094f,
+ 0.996094f, 0.996094f, 0.996094f, 0.996094f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000088f, 0.000085f, 0.000338f, 0.000351f,
+ 0.000359f, 0.000480f, 0.000539f, 0.000698f, 0.000798f, 0.000793f, 0.000834f, 0.000891f, 0.000941f, 0.001143f, 0.001422f, 0.001512f,
+ 0.001833f, 0.001955f, 0.002144f, 0.002426f, 0.002716f, 0.003262f, 0.003572f, 0.003860f, 0.004456f, 0.005173f, 0.006191f, 0.006939f,
+ 0.008545f, 0.010162f, 0.012375f, 0.014969f, 0.018555f, 0.023376f, 0.029953f, 0.039673f, 0.054077f, 0.076477f, 0.112000f, 0.171509f,
+ 0.268066f, 0.408203f, 0.569336f, 0.709961f, 0.808105f, 0.872070f, 0.910645f, 0.935059f, 0.951660f, 0.963379f, 0.971680f, 0.977539f,
+ 0.982422f, 0.985840f, 0.995117f, 0.995605f, 0.995605f, 0.995605f, 0.995605f, 0.995605f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000122f, 0.000116f, 0.000340f, 0.000353f, 0.000349f, 0.000480f, 0.000576f, 0.000668f, 0.000700f, 0.000818f, 0.000833f,
+ 0.000787f, 0.001125f, 0.001110f, 0.001407f, 0.001489f, 0.001563f, 0.001804f, 0.002073f, 0.002285f, 0.002409f, 0.002985f, 0.003052f,
+ 0.003853f, 0.004433f, 0.005100f, 0.006046f, 0.007046f, 0.008156f, 0.009827f, 0.012138f, 0.014740f, 0.018311f, 0.023071f, 0.029770f,
+ 0.040009f, 0.054810f, 0.078003f, 0.116150f, 0.180176f, 0.284668f, 0.434570f, 0.599121f, 0.735352f, 0.827637f, 0.885254f, 0.919922f,
+ 0.941895f, 0.957031f, 0.967285f, 0.975098f, 0.979980f, 0.984375f, 0.995117f, 0.995117f, 0.995117f, 0.995117f, 0.995117f, 0.995605f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000000f, 0.000122f, 0.000235f, 0.000320f, 0.000351f, 0.000353f, 0.000478f,
+ 0.000602f, 0.000651f, 0.000793f, 0.000706f, 0.000816f, 0.000814f, 0.000898f, 0.001062f, 0.001259f, 0.001441f, 0.001564f, 0.001772f,
+ 0.001743f, 0.002134f, 0.002512f, 0.002668f, 0.003193f, 0.003746f, 0.004341f, 0.004902f, 0.005909f, 0.006920f, 0.008125f, 0.009605f,
+ 0.011711f, 0.014549f, 0.018280f, 0.023163f, 0.030334f, 0.040375f, 0.055939f, 0.080566f, 0.122070f, 0.192383f, 0.307373f, 0.467773f,
+ 0.634277f, 0.763184f, 0.846191f, 0.897461f, 0.928711f, 0.948730f, 0.962402f, 0.971680f, 0.978516f, 0.982422f, 0.994141f, 0.994629f,
+ 0.994629f, 0.995117f, 0.995117f, 0.995117f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000185f, 0.000190f,
+ 0.000272f, 0.000281f, 0.000464f, 0.000466f, 0.000476f, 0.000521f, 0.000654f, 0.000680f, 0.000699f, 0.000815f, 0.000814f, 0.000890f,
+ 0.001110f, 0.001283f, 0.001311f, 0.001590f, 0.001727f, 0.001801f, 0.002020f, 0.002312f, 0.002897f, 0.003267f, 0.003592f, 0.004143f,
+ 0.004810f, 0.005844f, 0.006618f, 0.008018f, 0.009697f, 0.011597f, 0.014374f, 0.018127f, 0.023056f, 0.030258f, 0.041107f, 0.057373f,
+ 0.084045f, 0.129517f, 0.208618f, 0.337646f, 0.508789f, 0.673828f, 0.793457f, 0.866211f, 0.911133f, 0.938965f, 0.955566f, 0.967285f,
+ 0.975586f, 0.980469f, 0.994141f, 0.994141f, 0.994629f, 0.994629f, 0.994629f, 0.994141f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000226f, 0.000431f, 0.000456f, 0.000467f, 0.000352f, 0.000496f, 0.000588f,
+ 0.000891f, 0.000771f, 0.000803f, 0.000947f, 0.000972f, 0.001078f, 0.001033f, 0.001279f, 0.001436f, 0.001483f, 0.001831f, 0.002033f,
+ 0.002264f, 0.002710f, 0.002996f, 0.003582f, 0.004032f, 0.004665f, 0.005592f, 0.006527f, 0.007820f, 0.009323f, 0.011581f, 0.014328f,
+ 0.018219f, 0.023239f, 0.030777f, 0.042084f, 0.059448f, 0.089233f, 0.140869f, 0.230713f, 0.375977f, 0.556641f, 0.715332f, 0.822266f,
+ 0.885742f, 0.924316f, 0.947266f, 0.962402f, 0.972656f, 0.978516f, 0.993164f, 0.994141f, 0.994141f, 0.994141f, 0.994141f, 0.994141f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000283f, 0.000229f, 0.000425f,
+ 0.000303f, 0.000336f, 0.000469f, 0.000474f, 0.000728f, 0.000663f, 0.000883f, 0.000695f, 0.000679f, 0.000858f, 0.000919f, 0.000980f,
+ 0.001218f, 0.001330f, 0.001665f, 0.001637f, 0.002054f, 0.002335f, 0.002508f, 0.002880f, 0.003323f, 0.004055f, 0.004730f, 0.005463f,
+ 0.006485f, 0.007740f, 0.009293f, 0.011566f, 0.014175f, 0.017944f, 0.023346f, 0.031433f, 0.043304f, 0.063232f, 0.096313f, 0.155518f,
+ 0.260498f, 0.424561f, 0.611328f, 0.758789f, 0.852051f, 0.904785f, 0.937012f, 0.955566f, 0.968262f, 0.977051f, 0.992676f, 0.992676f,
+ 0.993164f, 0.993652f, 0.993164f, 0.993652f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000256f, 0.000216f, 0.000406f, 0.000426f, 0.000457f, 0.000453f, 0.000472f, 0.000651f, 0.000593f, 0.000876f,
+ 0.000571f, 0.000590f, 0.000819f, 0.000809f, 0.001000f, 0.001224f, 0.001293f, 0.001637f, 0.001790f, 0.001863f, 0.002298f, 0.002550f,
+ 0.002995f, 0.003201f, 0.003933f, 0.004677f, 0.005360f, 0.006447f, 0.007763f, 0.009377f, 0.011330f, 0.014420f, 0.017944f, 0.023560f,
+ 0.032196f, 0.045380f, 0.067383f, 0.105469f, 0.175659f, 0.301025f, 0.484375f, 0.669922f, 0.801270f, 0.879395f, 0.922852f, 0.948242f,
+ 0.963379f, 0.974121f, 0.992188f, 0.992188f, 0.992188f, 0.993164f, 0.992188f, 0.993164f, 0.000000f, 0.000000f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000230f, 0.000206f, 0.000355f, 0.000335f, 0.000305f,
+ 0.000461f, 0.000565f, 0.000474f, 0.000429f, 0.000520f, 0.000758f, 0.000777f, 0.000668f, 0.000821f, 0.001013f, 0.001089f, 0.001325f,
+ 0.001570f, 0.001787f, 0.001707f, 0.002037f, 0.002457f, 0.002892f, 0.003359f, 0.003881f, 0.004616f, 0.005203f, 0.006336f, 0.007477f,
+ 0.009048f, 0.011345f, 0.014015f, 0.018356f, 0.024307f, 0.033661f, 0.048279f, 0.073303f, 0.118774f, 0.204102f, 0.354492f, 0.554688f,
+ 0.729492f, 0.840332f, 0.902832f, 0.937988f, 0.958008f, 0.971191f, 0.991699f, 0.992188f, 0.992188f, 0.991699f, 0.992188f, 0.991699f,
+ 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000205f, 0.000248f, 0.000213f, 0.000344f, 0.000437f, 0.000351f, 0.000352f, 0.000359f, 0.000389f, 0.000482f, 0.000676f, 0.000560f,
+ 0.000806f, 0.000813f, 0.000927f, 0.001230f, 0.001392f, 0.001526f, 0.001627f, 0.001629f, 0.002047f, 0.002321f, 0.002661f, 0.003317f,
+ 0.003752f, 0.004406f, 0.005119f, 0.005936f, 0.007156f, 0.009003f, 0.010941f, 0.013985f, 0.018539f, 0.025131f, 0.035248f, 0.051880f,
+ 0.081543f, 0.137207f, 0.244507f, 0.424561f, 0.632812f, 0.787598f, 0.876465f, 0.924805f, 0.951172f, 0.966797f, 0.990723f, 0.991211f,
+ 0.991211f, 0.991211f, 0.991211f, 0.991211f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000224f, 0.000171f, 0.000276f, 0.000278f, 0.000288f, 0.000329f, 0.000365f,
+ 0.000459f, 0.000483f, 0.000626f, 0.000716f, 0.000767f, 0.000793f, 0.000800f, 0.000897f, 0.000976f, 0.001156f, 0.001322f, 0.001427f,
+ 0.001799f, 0.001997f, 0.002256f, 0.002773f, 0.002806f, 0.003515f, 0.004040f, 0.004910f, 0.005730f, 0.007046f, 0.008858f, 0.011124f,
+ 0.014374f, 0.018982f, 0.026123f, 0.037659f, 0.057129f, 0.093445f, 0.164062f, 0.301514f, 0.511230f, 0.712402f, 0.838867f, 0.906738f,
+ 0.942383f, 0.961914f, 0.989746f, 0.990234f, 0.989746f, 0.990234f, 0.989746f, 0.990234f, 0.000000f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000173f, 0.000140f,
+ 0.000138f, 0.000232f, 0.000291f, 0.000318f, 0.000338f, 0.000346f, 0.000422f, 0.000368f, 0.000680f, 0.000722f, 0.000765f, 0.000766f,
+ 0.000803f, 0.001069f, 0.001103f, 0.001185f, 0.001611f, 0.001593f, 0.001939f, 0.002211f, 0.002569f, 0.003008f, 0.003239f, 0.003952f,
+ 0.004681f, 0.005630f, 0.007008f, 0.008720f, 0.011200f, 0.014587f, 0.019653f, 0.027527f, 0.040955f, 0.064514f, 0.110413f, 0.204224f,
+ 0.381104f, 0.609863f, 0.785645f, 0.881836f, 0.931152f, 0.956543f, 0.988770f, 0.989258f, 0.989258f, 0.989258f, 0.989258f, 0.988770f,
+ 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000121f,
+ 0.000121f, 0.000123f, 0.000121f, 0.000090f, 0.000102f, 0.000063f, 0.000156f, 0.000248f, 0.000333f, 0.000321f, 0.000431f, 0.000392f,
+ 0.000349f, 0.000434f, 0.000674f, 0.000741f, 0.000776f, 0.000936f, 0.000888f, 0.001049f, 0.001179f, 0.001326f, 0.001686f, 0.001732f,
+ 0.002050f, 0.002150f, 0.002453f, 0.003016f, 0.003601f, 0.004444f, 0.005692f, 0.006741f, 0.008324f, 0.011093f, 0.014709f, 0.020752f,
+ 0.029800f, 0.045654f, 0.074951f, 0.136108f, 0.264893f, 0.486816f, 0.710938f, 0.848145f, 0.916992f, 0.950684f, 0.987305f, 0.987793f,
+ 0.987793f, 0.988281f, 0.987793f, 0.987793f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000100f, 0.000049f, 0.000039f, 0.000125f, 0.000121f,
+ 0.000184f, 0.000280f, 0.000366f, 0.000392f, 0.000333f, 0.000341f, 0.000477f, 0.000597f, 0.000607f, 0.000747f, 0.000767f, 0.000961f,
+ 0.000936f, 0.001056f, 0.001306f, 0.001388f, 0.001633f, 0.001836f, 0.001997f, 0.002348f, 0.002878f, 0.003332f, 0.004131f, 0.005165f,
+ 0.006519f, 0.008568f, 0.011444f, 0.015419f, 0.021881f, 0.032532f, 0.052032f, 0.091187f, 0.177246f, 0.357910f, 0.610352f, 0.800781f,
+ 0.897461f, 0.942871f, 0.985352f, 0.986328f, 0.986816f, 0.986328f, 0.986328f, 0.986328f, 0.000000f, 0.000000f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000099f, 0.000076f,
+ 0.000060f, 0.000108f, 0.000040f, 0.000127f, 0.000127f, 0.000121f, 0.000200f, 0.000265f, 0.000360f, 0.000316f, 0.000428f, 0.000455f,
+ 0.000456f, 0.000583f, 0.000682f, 0.000750f, 0.000773f, 0.000824f, 0.000937f, 0.001220f, 0.001262f, 0.001384f, 0.001622f, 0.001862f,
+ 0.002157f, 0.002817f, 0.003414f, 0.004082f, 0.004993f, 0.006561f, 0.008560f, 0.011696f, 0.016022f, 0.023529f, 0.036469f, 0.062286f,
+ 0.117126f, 0.245605f, 0.487549f, 0.732910f, 0.870605f, 0.933105f, 0.983887f, 0.984863f, 0.984863f, 0.984863f, 0.984375f, 0.984863f,
+ 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f,
+ 0.000121f, 0.000121f, 0.000121f, 0.000096f, 0.000075f, 0.000061f, 0.000083f, 0.000096f, 0.000034f, 0.000101f, 0.000121f, 0.000137f,
+ 0.000211f, 0.000324f, 0.000381f, 0.000373f, 0.000420f, 0.000472f, 0.000494f, 0.000690f, 0.000793f, 0.000768f, 0.000853f, 0.000867f,
+ 0.000978f, 0.001003f, 0.001145f, 0.001416f, 0.001888f, 0.002125f, 0.002491f, 0.003004f, 0.003864f, 0.005028f, 0.006500f, 0.008682f,
+ 0.011856f, 0.016922f, 0.025757f, 0.042603f, 0.078247f, 0.161743f, 0.358398f, 0.641602f, 0.833496f, 0.920410f, 0.981934f, 0.982910f,
+ 0.982910f, 0.982910f, 0.982910f, 0.982910f, 0.000122f, 0.000000f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f,
+ 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000120f, 0.000097f, 0.000078f, 0.000062f, 0.000051f,
+ 0.000043f, 0.000072f, 0.000030f, 0.000060f, 0.000109f, 0.000206f, 0.000216f, 0.000333f, 0.000347f, 0.000395f, 0.000415f, 0.000458f,
+ 0.000568f, 0.000664f, 0.000709f, 0.000598f, 0.000781f, 0.000628f, 0.001053f, 0.001046f, 0.001179f, 0.001579f, 0.001649f, 0.002386f,
+ 0.002857f, 0.003727f, 0.004894f, 0.006363f, 0.008789f, 0.012314f, 0.018616f, 0.029709f, 0.052429f, 0.105652f, 0.244385f, 0.524414f,
+ 0.782715f, 0.904785f, 0.979492f, 0.980957f, 0.979980f, 0.979980f, 0.980469f, 0.980469f, 0.000000f, 0.000121f, 0.000121f, 0.000121f,
+ 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000120f,
+ 0.000120f, 0.000097f, 0.000079f, 0.000065f, 0.000054f, 0.000045f, 0.000073f, 0.000032f, 0.000089f, 0.000038f, 0.000134f, 0.000138f,
+ 0.000211f, 0.000333f, 0.000370f, 0.000400f, 0.000420f, 0.000496f, 0.000566f, 0.000494f, 0.000584f, 0.000714f, 0.000708f, 0.000843f,
+ 0.001056f, 0.001019f, 0.001327f, 0.001812f, 0.001908f, 0.002798f, 0.003479f, 0.004578f, 0.006195f, 0.008881f, 0.012901f, 0.020599f,
+ 0.035339f, 0.069214f, 0.159058f, 0.394531f, 0.709961f, 0.882812f, 0.977051f, 0.978027f, 0.977539f, 0.976562f, 0.977051f, 0.977539f,
+ 0.000000f, 0.000121f, 0.000120f, 0.000121f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000120f,
+ 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000119f, 0.000120f, 0.000102f, 0.000084f, 0.000071f, 0.000059f, 0.000048f, 0.000041f,
+ 0.000035f, 0.000062f, 0.000026f, 0.000098f, 0.000103f, 0.000136f, 0.000230f, 0.000327f, 0.000356f, 0.000338f, 0.000387f, 0.000499f,
+ 0.000577f, 0.000627f, 0.000669f, 0.000611f, 0.000699f, 0.000904f, 0.000893f, 0.001340f, 0.001666f, 0.002068f, 0.002377f, 0.003105f,
+ 0.004345f, 0.006218f, 0.009178f, 0.013962f, 0.024170f, 0.045441f, 0.101868f, 0.271973f, 0.612305f, 0.853027f, 0.973145f, 0.974121f,
+ 0.973633f, 0.974121f, 0.973633f, 0.974121f, 0.000121f, 0.000120f, 0.000119f, 0.000120f, 0.000119f, 0.000119f, 0.000119f, 0.000119f,
+ 0.000119f, 0.000119f, 0.000119f, 0.000119f, 0.000119f, 0.000119f, 0.000119f, 0.000119f, 0.000119f, 0.000119f, 0.000119f, 0.000108f,
+ 0.000091f, 0.000075f, 0.000063f, 0.000053f, 0.000045f, 0.000039f, 0.000034f, 0.000040f, 0.000090f, 0.000068f, 0.000104f, 0.000127f,
+ 0.000220f, 0.000302f, 0.000412f, 0.000316f, 0.000444f, 0.000495f, 0.000428f, 0.000510f, 0.000463f, 0.000614f, 0.000726f, 0.000719f,
+ 0.001164f, 0.001533f, 0.001707f, 0.002079f, 0.002848f, 0.004189f, 0.006142f, 0.009491f, 0.016113f, 0.029343f, 0.064758f, 0.175415f,
+ 0.490723f, 0.812012f, 0.968750f, 0.969727f, 0.969238f, 0.969727f, 0.969727f, 0.969727f, 0.000000f, 0.000117f, 0.000117f, 0.000115f,
+ 0.000118f, 0.000118f, 0.000117f, 0.000117f, 0.000117f, 0.000117f, 0.000118f, 0.000117f, 0.000117f, 0.000118f, 0.000117f, 0.000117f,
+ 0.000117f, 0.000117f, 0.000117f, 0.000118f, 0.000117f, 0.000100f, 0.000082f, 0.000070f, 0.000060f, 0.000051f, 0.000043f, 0.000038f,
+ 0.000033f, 0.000053f, 0.000027f, 0.000089f, 0.000105f, 0.000137f, 0.000227f, 0.000277f, 0.000293f, 0.000284f, 0.000300f, 0.000420f,
+ 0.000367f, 0.000473f, 0.000467f, 0.000555f, 0.000625f, 0.000870f, 0.001177f, 0.001563f, 0.001982f, 0.002714f, 0.004051f, 0.006134f,
+ 0.010384f, 0.018967f, 0.040314f, 0.108887f, 0.358643f, 0.755859f, 0.962891f, 0.963867f, 0.964355f, 0.963867f, 0.963379f, 0.963379f,
+ 0.000000f, 0.000000f, 0.000098f, 0.000103f, 0.000111f, 0.000112f, 0.000112f, 0.000114f, 0.000113f, 0.000115f, 0.000114f, 0.000115f,
+ 0.000115f, 0.000115f, 0.000115f, 0.000115f, 0.000116f, 0.000116f, 0.000116f, 0.000116f, 0.000116f, 0.000116f, 0.000109f, 0.000094f,
+ 0.000078f, 0.000067f, 0.000058f, 0.000050f, 0.000043f, 0.000038f, 0.000033f, 0.000054f, 0.000025f, 0.000078f, 0.000091f, 0.000173f,
+ 0.000203f, 0.000252f, 0.000331f, 0.000277f, 0.000264f, 0.000407f, 0.000342f, 0.000444f, 0.000470f, 0.000542f, 0.000773f, 0.001081f,
+ 0.001245f, 0.001682f, 0.002602f, 0.003744f, 0.006248f, 0.011566f, 0.025040f, 0.065491f, 0.236938f, 0.678223f, 0.956055f, 0.956543f,
+ 0.956543f, 0.956543f, 0.957031f, 0.957031f, 0.000000f, 0.000000f, 0.000021f, 0.000080f, 0.000072f, 0.000089f, 0.000100f, 0.000099f,
+ 0.000105f, 0.000107f, 0.000107f, 0.000110f, 0.000109f, 0.000110f, 0.000111f, 0.000111f, 0.000112f, 0.000112f, 0.000112f, 0.000113f,
+ 0.000113f, 0.000113f, 0.000113f, 0.000113f, 0.000105f, 0.000090f, 0.000078f, 0.000067f, 0.000057f, 0.000050f, 0.000043f, 0.000038f,
+ 0.000033f, 0.000029f, 0.000025f, 0.000055f, 0.000091f, 0.000130f, 0.000225f, 0.000275f, 0.000254f, 0.000290f, 0.000259f, 0.000378f,
+ 0.000333f, 0.000362f, 0.000458f, 0.000587f, 0.000876f, 0.001062f, 0.001382f, 0.002398f, 0.003763f, 0.006603f, 0.014496f, 0.038300f,
+ 0.143677f, 0.573730f, 0.946777f, 0.947266f, 0.947266f, 0.947266f, 0.948242f, 0.947266f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000014f, 0.000036f, 0.000072f, 0.000082f, 0.000080f, 0.000094f, 0.000096f, 0.000099f, 0.000098f, 0.000103f, 0.000103f,
+ 0.000103f, 0.000106f, 0.000105f, 0.000107f, 0.000107f, 0.000108f, 0.000108f, 0.000109f, 0.000109f, 0.000109f, 0.000105f, 0.000090f,
+ 0.000078f, 0.000067f, 0.000059f, 0.000051f, 0.000045f, 0.000039f, 0.000034f, 0.000030f, 0.000026f, 0.000045f, 0.000086f, 0.000108f,
+ 0.000143f, 0.000212f, 0.000227f, 0.000204f, 0.000231f, 0.000263f, 0.000315f, 0.000354f, 0.000481f, 0.000702f, 0.000888f, 0.001257f,
+ 0.002018f, 0.003738f, 0.007675f, 0.021317f, 0.080933f, 0.444336f, 0.934082f, 0.935059f, 0.935059f, 0.935059f, 0.935059f, 0.935059f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000024f, 0.000038f, 0.000059f,
+ 0.000063f, 0.000076f, 0.000080f, 0.000085f, 0.000089f, 0.000091f, 0.000092f, 0.000095f, 0.000097f, 0.000099f, 0.000098f, 0.000101f,
+ 0.000101f, 0.000102f, 0.000103f, 0.000104f, 0.000104f, 0.000091f, 0.000080f, 0.000069f, 0.000062f, 0.000053f, 0.000046f, 0.000041f,
+ 0.000035f, 0.000032f, 0.000027f, 0.000039f, 0.000052f, 0.000103f, 0.000139f, 0.000178f, 0.000190f, 0.000178f, 0.000185f, 0.000247f,
+ 0.000274f, 0.000368f, 0.000528f, 0.000637f, 0.001027f, 0.001937f, 0.003853f, 0.010445f, 0.041718f, 0.304199f, 0.917480f, 0.917480f,
+ 0.917969f, 0.917480f, 0.918457f, 0.917969f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000023f, 0.000037f, 0.000048f, 0.000048f, 0.000063f, 0.000063f,
+ 0.000074f, 0.000077f, 0.000080f, 0.000083f, 0.000086f, 0.000088f, 0.000090f, 0.000091f, 0.000092f, 0.000094f, 0.000095f, 0.000096f,
+ 0.000084f, 0.000073f, 0.000064f, 0.000057f, 0.000049f, 0.000043f, 0.000037f, 0.000033f, 0.000029f, 0.000025f, 0.000060f, 0.000061f,
+ 0.000087f, 0.000118f, 0.000156f, 0.000131f, 0.000175f, 0.000226f, 0.000230f, 0.000373f, 0.000507f, 0.000992f, 0.001814f, 0.004639f,
+ 0.018799f, 0.176758f, 0.894043f, 0.894531f, 0.895508f, 0.895020f, 0.895020f, 0.895996f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000019f, 0.000028f, 0.000034f, 0.000043f, 0.000052f, 0.000057f, 0.000062f, 0.000067f,
+ 0.000070f, 0.000074f, 0.000075f, 0.000079f, 0.000081f, 0.000083f, 0.000085f, 0.000076f, 0.000068f, 0.000059f, 0.000051f, 0.000046f,
+ 0.000040f, 0.000035f, 0.000030f, 0.000026f, 0.000028f, 0.000038f, 0.000072f, 0.000100f, 0.000120f, 0.000107f, 0.000152f, 0.000156f,
+ 0.000254f, 0.000436f, 0.000722f, 0.001875f, 0.007088f, 0.083069f, 0.863281f, 0.862305f, 0.863281f, 0.862305f, 0.863281f, 0.862793f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000005f, 0.000015f, 0.000022f, 0.000030f, 0.000037f, 0.000042f, 0.000048f, 0.000053f, 0.000058f, 0.000060f,
+ 0.000064f, 0.000067f, 0.000069f, 0.000061f, 0.000053f, 0.000047f, 0.000041f, 0.000036f, 0.000031f, 0.000027f, 0.000023f, 0.000020f,
+ 0.000036f, 0.000063f, 0.000082f, 0.000081f, 0.000104f, 0.000149f, 0.000263f, 0.000616f, 0.002337f, 0.028168f, 0.816406f, 0.816895f,
+ 0.816895f, 0.816895f, 0.817383f, 0.816895f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000003f, 0.000011f, 0.000019f, 0.000026f, 0.000031f, 0.000036f, 0.000041f, 0.000045f, 0.000050f, 0.000047f,
+ 0.000041f, 0.000036f, 0.000031f, 0.000027f, 0.000023f, 0.000019f, 0.000028f, 0.000029f, 0.000053f, 0.000052f, 0.000072f, 0.000165f,
+ 0.000511f, 0.006050f, 0.751465f, 0.752441f, 0.752930f, 0.752441f, 0.752441f, 0.752930f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000004f, 0.000011f, 0.000017f, 0.000021f, 0.000027f, 0.000028f, 0.000024f, 0.000020f, 0.000017f,
+ 0.000013f, 0.000020f, 0.000021f, 0.000029f, 0.000057f, 0.000588f, 0.665039f, 0.664551f, 0.665527f, 0.665039f, 0.665039f, 0.665039f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000003f, 0.000009f, 0.000006f, 0.000004f, 0.000007f, 0.557129f, 0.558105f,
+ 0.557617f, 0.557617f, 0.558594f, 0.558105f,
+ },
+ {
+ 0.163818f, 0.558105f, 0.755859f, 0.841797f, 0.886230f, 0.912109f, 0.929199f, 0.941406f, 0.950195f, 0.957031f, 0.961914f, 0.966309f,
+ 0.970215f, 0.972656f, 0.975586f, 0.978027f, 0.979492f, 0.981445f, 0.982910f, 0.984375f, 0.985840f, 0.986328f, 0.987305f, 0.988770f,
+ 0.989258f, 0.989746f, 0.990234f, 0.991211f, 0.991699f, 0.992188f, 0.993164f, 0.993652f, 0.993652f, 0.993652f, 0.994141f, 0.995117f,
+ 0.995117f, 0.995117f, 0.995605f, 0.996094f, 0.996582f, 0.997070f, 0.997070f, 0.997070f, 0.997070f, 0.997559f, 0.998047f, 0.998047f,
+ 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.027023f, 0.138184f, 0.353760f, 0.583984f, 0.735352f, 0.819336f, 0.868652f, 0.898926f,
+ 0.918945f, 0.933594f, 0.943848f, 0.952148f, 0.958984f, 0.963867f, 0.967773f, 0.971680f, 0.974121f, 0.976562f, 0.978516f, 0.980469f,
+ 0.982422f, 0.983398f, 0.984863f, 0.986328f, 0.986816f, 0.988281f, 0.989258f, 0.989746f, 0.990723f, 0.990723f, 0.991699f, 0.992676f,
+ 0.993164f, 0.993164f, 0.993652f, 0.994141f, 0.994141f, 0.995117f, 0.995117f, 0.995605f, 0.996094f, 0.996094f, 0.996582f, 0.997070f,
+ 0.997070f, 0.997559f, 0.997559f, 0.997559f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.009819f, 0.044250f, 0.113525f, 0.244995f,
+ 0.430420f, 0.608887f, 0.733887f, 0.810547f, 0.860352f, 0.892578f, 0.913086f, 0.929688f, 0.940918f, 0.949219f, 0.956055f, 0.961426f,
+ 0.966309f, 0.970215f, 0.972656f, 0.975586f, 0.977539f, 0.979980f, 0.980957f, 0.983398f, 0.983887f, 0.985352f, 0.986328f, 0.987793f,
+ 0.988281f, 0.989746f, 0.989746f, 0.991211f, 0.991699f, 0.992188f, 0.992676f, 0.993164f, 0.993652f, 0.993652f, 0.994141f, 0.995117f,
+ 0.995605f, 0.996094f, 0.996094f, 0.996582f, 0.996582f, 0.996582f, 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.998047f, 0.998535f,
+ 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.004848f, 0.020447f, 0.046814f, 0.096313f, 0.183228f, 0.319092f, 0.484375f, 0.631836f, 0.739258f, 0.810547f, 0.857422f, 0.888672f,
+ 0.910645f, 0.925781f, 0.938965f, 0.947754f, 0.954590f, 0.960449f, 0.964355f, 0.968750f, 0.971191f, 0.974609f, 0.977051f, 0.979004f,
+ 0.980957f, 0.982422f, 0.983887f, 0.985840f, 0.986816f, 0.987793f, 0.988770f, 0.989258f, 0.990234f, 0.990723f, 0.991211f, 0.991699f,
+ 0.992676f, 0.992676f, 0.993652f, 0.993652f, 0.994141f, 0.994629f, 0.995117f, 0.996094f, 0.996094f, 0.996094f, 0.996582f, 0.996582f,
+ 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.003096f, 0.011017f, 0.024399f, 0.046600f, 0.083191f, 0.145386f, 0.243774f, 0.379395f,
+ 0.529297f, 0.656738f, 0.750977f, 0.813965f, 0.857910f, 0.887695f, 0.909668f, 0.925293f, 0.937500f, 0.946289f, 0.953613f, 0.959473f,
+ 0.964355f, 0.968262f, 0.971191f, 0.974121f, 0.976562f, 0.979004f, 0.980957f, 0.982910f, 0.984375f, 0.985840f, 0.986328f, 0.987793f,
+ 0.988281f, 0.989258f, 0.989746f, 0.991211f, 0.991699f, 0.991699f, 0.992676f, 0.993164f, 0.993652f, 0.994141f, 0.994629f, 0.995117f,
+ 0.995605f, 0.996094f, 0.996094f, 0.996582f, 0.996582f, 0.996582f, 0.997070f, 0.997559f, 0.997559f, 0.997559f, 0.998047f, 0.998047f,
+ 0.998535f, 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.001808f, 0.006992f, 0.014923f, 0.026413f,
+ 0.044403f, 0.073120f, 0.119446f, 0.193115f, 0.300537f, 0.433594f, 0.568848f, 0.680664f, 0.763184f, 0.821289f, 0.860840f, 0.890137f,
+ 0.909668f, 0.925293f, 0.937500f, 0.945801f, 0.953613f, 0.959473f, 0.963867f, 0.968262f, 0.971680f, 0.974609f, 0.977051f, 0.979004f,
+ 0.980957f, 0.982422f, 0.983887f, 0.984863f, 0.986816f, 0.987305f, 0.987793f, 0.989746f, 0.989746f, 0.991211f, 0.991699f, 0.992188f,
+ 0.992676f, 0.993652f, 0.994141f, 0.994629f, 0.994629f, 0.995605f, 0.996094f, 0.996094f, 0.996094f, 0.996582f, 0.997070f, 0.997070f,
+ 0.997559f, 0.997559f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.001668f, 0.005253f, 0.010010f, 0.016602f, 0.026459f, 0.042023f, 0.065369f, 0.101868f, 0.158081f, 0.241455f, 0.354248f, 0.483887f,
+ 0.606934f, 0.706055f, 0.777832f, 0.830566f, 0.867188f, 0.893066f, 0.912109f, 0.926270f, 0.938477f, 0.946289f, 0.953125f, 0.959473f,
+ 0.964355f, 0.968750f, 0.971680f, 0.975098f, 0.977051f, 0.979492f, 0.980957f, 0.982910f, 0.984375f, 0.985840f, 0.986328f, 0.987305f,
+ 0.988770f, 0.989746f, 0.990234f, 0.991211f, 0.992188f, 0.993164f, 0.993164f, 0.994141f, 0.994629f, 0.994629f, 0.995117f, 0.995605f,
+ 0.996094f, 0.996094f, 0.996094f, 0.996582f, 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.998047f, 0.998535f, 0.999023f, 0.999023f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999023f, 0.001086f, 0.003477f, 0.006756f, 0.011604f, 0.018066f, 0.027222f, 0.039978f, 0.059448f,
+ 0.088257f, 0.132690f, 0.198120f, 0.291504f, 0.408447f, 0.531250f, 0.641602f, 0.728516f, 0.793457f, 0.839844f, 0.873047f, 0.896973f,
+ 0.915527f, 0.929199f, 0.939941f, 0.948730f, 0.955566f, 0.960938f, 0.965332f, 0.969238f, 0.972168f, 0.975098f, 0.977539f, 0.979492f,
+ 0.981445f, 0.983398f, 0.984375f, 0.985840f, 0.986816f, 0.988281f, 0.989258f, 0.989746f, 0.990723f, 0.991699f, 0.992188f, 0.993164f,
+ 0.993652f, 0.994141f, 0.994629f, 0.994629f, 0.995605f, 0.995605f, 0.996094f, 0.996094f, 0.996582f, 0.996582f, 0.997559f, 0.997559f,
+ 0.997559f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.000982f, 0.002764f, 0.004925f, 0.008194f,
+ 0.012703f, 0.018417f, 0.026154f, 0.037964f, 0.053894f, 0.078552f, 0.113770f, 0.166626f, 0.242310f, 0.343262f, 0.460449f, 0.576660f,
+ 0.675293f, 0.753418f, 0.809570f, 0.851074f, 0.879883f, 0.902344f, 0.919434f, 0.931152f, 0.941895f, 0.950195f, 0.956055f, 0.960938f,
+ 0.965820f, 0.969727f, 0.973145f, 0.976074f, 0.978027f, 0.980469f, 0.981934f, 0.983887f, 0.985352f, 0.986328f, 0.987793f, 0.988770f,
+ 0.989746f, 0.990234f, 0.991211f, 0.991699f, 0.992676f, 0.993164f, 0.993652f, 0.994141f, 0.994629f, 0.995117f, 0.995605f, 0.996094f,
+ 0.996094f, 0.996582f, 0.996582f, 0.997559f, 0.997559f, 0.998047f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.000723f, 0.002268f, 0.003639f, 0.006371f, 0.009392f, 0.013046f, 0.018570f, 0.026016f, 0.035919f, 0.049957f, 0.070618f, 0.099609f,
+ 0.142212f, 0.204590f, 0.290039f, 0.396973f, 0.512207f, 0.619141f, 0.707520f, 0.775391f, 0.825195f, 0.860352f, 0.887207f, 0.907715f,
+ 0.923340f, 0.935547f, 0.944824f, 0.951660f, 0.958496f, 0.963379f, 0.967773f, 0.971191f, 0.974121f, 0.977051f, 0.979492f, 0.980957f,
+ 0.982910f, 0.984375f, 0.985352f, 0.987305f, 0.988281f, 0.989258f, 0.989746f, 0.990723f, 0.991699f, 0.992188f, 0.993164f, 0.993164f,
+ 0.994141f, 0.994629f, 0.994629f, 0.995117f, 0.995605f, 0.996094f, 0.996582f, 0.997070f, 0.997559f, 0.997559f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.000364f, 0.001690f, 0.003056f, 0.004982f, 0.007217f, 0.010124f, 0.013931f, 0.018738f,
+ 0.025177f, 0.034332f, 0.045990f, 0.063599f, 0.088501f, 0.124146f, 0.175781f, 0.248047f, 0.341797f, 0.451416f, 0.562012f, 0.659668f,
+ 0.738281f, 0.797852f, 0.841797f, 0.872559f, 0.896484f, 0.914062f, 0.928711f, 0.938477f, 0.947266f, 0.954590f, 0.959473f, 0.964844f,
+ 0.969238f, 0.972168f, 0.975098f, 0.977539f, 0.979980f, 0.981934f, 0.983398f, 0.985352f, 0.986816f, 0.987793f, 0.988770f, 0.989746f,
+ 0.990723f, 0.991211f, 0.992188f, 0.993164f, 0.993652f, 0.994141f, 0.994629f, 0.995117f, 0.995117f, 0.995605f, 0.996094f, 0.996582f,
+ 0.997070f, 0.997070f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.000365f, 0.001221f, 0.002531f, 0.003979f,
+ 0.005829f, 0.007874f, 0.010475f, 0.013962f, 0.018402f, 0.024368f, 0.032257f, 0.042847f, 0.057983f, 0.079346f, 0.109375f, 0.153198f,
+ 0.214233f, 0.295898f, 0.397705f, 0.506836f, 0.609863f, 0.698730f, 0.767578f, 0.817871f, 0.854980f, 0.883301f, 0.903809f, 0.920410f,
+ 0.933105f, 0.942871f, 0.950195f, 0.957031f, 0.962402f, 0.966797f, 0.970703f, 0.973633f, 0.976562f, 0.979004f, 0.981445f, 0.982910f,
+ 0.984375f, 0.985840f, 0.986816f, 0.988281f, 0.989746f, 0.989746f, 0.991211f, 0.992188f, 0.992676f, 0.993164f, 0.993652f, 0.994141f,
+ 0.994629f, 0.995117f, 0.995605f, 0.996094f, 0.996582f, 0.997070f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.000343f, 0.001357f, 0.002039f, 0.003130f, 0.004398f, 0.006432f, 0.008141f, 0.010925f, 0.014008f, 0.018326f, 0.023331f, 0.030655f,
+ 0.040558f, 0.053680f, 0.071960f, 0.098206f, 0.134644f, 0.187012f, 0.258057f, 0.349854f, 0.455566f, 0.562012f, 0.656738f, 0.734863f,
+ 0.792969f, 0.836914f, 0.868652f, 0.894043f, 0.912598f, 0.926758f, 0.937988f, 0.947266f, 0.954590f, 0.960449f, 0.964355f, 0.968750f,
+ 0.972656f, 0.975586f, 0.978027f, 0.980469f, 0.981934f, 0.983398f, 0.985840f, 0.986816f, 0.988281f, 0.989258f, 0.990723f, 0.990723f,
+ 0.991699f, 0.992676f, 0.993164f, 0.994141f, 0.994629f, 0.995117f, 0.995605f, 0.996094f, 0.996582f, 0.996582f, 0.998535f, 0.998535f,
+ 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.000244f, 0.001185f, 0.001561f, 0.002504f, 0.003990f, 0.005272f, 0.006573f, 0.008606f,
+ 0.010933f, 0.013878f, 0.017715f, 0.022415f, 0.029068f, 0.038086f, 0.049774f, 0.066162f, 0.088257f, 0.120361f, 0.164917f, 0.227173f,
+ 0.308838f, 0.407959f, 0.515137f, 0.615723f, 0.700684f, 0.767090f, 0.817383f, 0.854492f, 0.882812f, 0.904297f, 0.920898f, 0.932617f,
+ 0.943359f, 0.951172f, 0.957520f, 0.962891f, 0.967773f, 0.971191f, 0.974121f, 0.977539f, 0.979492f, 0.981445f, 0.983887f, 0.985352f,
+ 0.986816f, 0.988281f, 0.988770f, 0.989258f, 0.990723f, 0.991699f, 0.992188f, 0.993164f, 0.993652f, 0.994141f, 0.995117f, 0.995605f,
+ 0.995605f, 0.996582f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.000243f, 0.000847f, 0.001555f, 0.002224f,
+ 0.003141f, 0.004093f, 0.005264f, 0.006817f, 0.008850f, 0.010948f, 0.014053f, 0.017456f, 0.022339f, 0.028351f, 0.036011f, 0.046326f,
+ 0.060791f, 0.080444f, 0.107788f, 0.146851f, 0.201660f, 0.274658f, 0.366699f, 0.470215f, 0.574707f, 0.666016f, 0.740234f, 0.797363f,
+ 0.839355f, 0.871094f, 0.895508f, 0.913574f, 0.927734f, 0.938965f, 0.947754f, 0.955566f, 0.960449f, 0.965332f, 0.969727f, 0.973145f,
+ 0.976074f, 0.979004f, 0.981445f, 0.982910f, 0.984863f, 0.986328f, 0.987305f, 0.988770f, 0.989258f, 0.990723f, 0.991699f, 0.992188f,
+ 0.993164f, 0.993652f, 0.994141f, 0.994629f, 0.995117f, 0.996094f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f,
+ 0.000244f, 0.000767f, 0.001042f, 0.001934f, 0.002502f, 0.003588f, 0.004292f, 0.005558f, 0.006824f, 0.008667f, 0.010872f, 0.013802f,
+ 0.017426f, 0.021637f, 0.027176f, 0.033936f, 0.043304f, 0.056549f, 0.073914f, 0.098083f, 0.132446f, 0.180664f, 0.245239f, 0.330078f,
+ 0.429199f, 0.533203f, 0.631348f, 0.711914f, 0.775879f, 0.823242f, 0.860352f, 0.886230f, 0.907227f, 0.923340f, 0.935059f, 0.944824f,
+ 0.952148f, 0.958984f, 0.964844f, 0.968750f, 0.972168f, 0.975586f, 0.978516f, 0.980957f, 0.982422f, 0.983887f, 0.985840f, 0.987305f,
+ 0.988770f, 0.989746f, 0.990234f, 0.992188f, 0.992676f, 0.992676f, 0.994141f, 0.994141f, 0.995117f, 0.995605f, 0.998047f, 0.998535f,
+ 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.000000f, 0.000485f, 0.001062f, 0.001658f, 0.002398f, 0.002998f, 0.003805f, 0.004723f,
+ 0.006004f, 0.007084f, 0.009102f, 0.011093f, 0.013489f, 0.016876f, 0.020813f, 0.025803f, 0.032257f, 0.040924f, 0.052673f, 0.068298f,
+ 0.090149f, 0.120239f, 0.162598f, 0.221313f, 0.298096f, 0.392822f, 0.496582f, 0.597656f, 0.684082f, 0.754883f, 0.807617f, 0.848145f,
+ 0.877930f, 0.900391f, 0.917969f, 0.931641f, 0.941406f, 0.950684f, 0.957031f, 0.962402f, 0.967773f, 0.971680f, 0.974609f, 0.978027f,
+ 0.980469f, 0.982422f, 0.984375f, 0.985840f, 0.987305f, 0.988281f, 0.989746f, 0.990723f, 0.991699f, 0.992188f, 0.993164f, 0.993652f,
+ 0.994141f, 0.995117f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.000244f, 0.000477f, 0.000852f, 0.001439f,
+ 0.002045f, 0.002424f, 0.003101f, 0.004093f, 0.004887f, 0.005989f, 0.007751f, 0.008606f, 0.011002f, 0.013420f, 0.016251f, 0.020035f,
+ 0.024628f, 0.030579f, 0.039093f, 0.049255f, 0.063599f, 0.083191f, 0.109924f, 0.148071f, 0.200928f, 0.270996f, 0.359863f, 0.461670f,
+ 0.564453f, 0.656738f, 0.732910f, 0.791992f, 0.836426f, 0.869629f, 0.894531f, 0.913086f, 0.928223f, 0.939453f, 0.949219f, 0.956055f,
+ 0.961914f, 0.966797f, 0.970703f, 0.975098f, 0.977051f, 0.979492f, 0.982422f, 0.983887f, 0.985352f, 0.987305f, 0.988770f, 0.989746f,
+ 0.990723f, 0.991699f, 0.992676f, 0.993164f, 0.993652f, 0.994629f, 0.998047f, 0.998535f, 0.998535f, 0.998047f, 0.998047f, 0.998535f,
+ 0.000242f, 0.000650f, 0.000847f, 0.001138f, 0.001621f, 0.002239f, 0.002527f, 0.003325f, 0.004227f, 0.005165f, 0.006462f, 0.007389f,
+ 0.008904f, 0.011024f, 0.013130f, 0.015915f, 0.019272f, 0.023819f, 0.029205f, 0.036652f, 0.046417f, 0.059418f, 0.077209f, 0.101562f,
+ 0.136230f, 0.183350f, 0.248047f, 0.331055f, 0.429688f, 0.533203f, 0.630859f, 0.711426f, 0.776367f, 0.824219f, 0.861328f, 0.887695f,
+ 0.908691f, 0.924805f, 0.937500f, 0.946777f, 0.954102f, 0.960938f, 0.966309f, 0.970215f, 0.974121f, 0.977539f, 0.979492f, 0.981934f,
+ 0.983887f, 0.985840f, 0.987305f, 0.989258f, 0.989746f, 0.990723f, 0.991211f, 0.992676f, 0.993164f, 0.994141f, 0.997559f, 0.998047f,
+ 0.998047f, 0.998047f, 0.998047f, 0.998047f, 0.000089f, 0.000243f, 0.000827f, 0.000964f, 0.001418f, 0.001579f, 0.002296f, 0.002914f,
+ 0.003632f, 0.004280f, 0.005344f, 0.006130f, 0.007545f, 0.008949f, 0.010498f, 0.012733f, 0.015686f, 0.018646f, 0.023010f, 0.028229f,
+ 0.034851f, 0.044098f, 0.056122f, 0.072388f, 0.094788f, 0.125610f, 0.168945f, 0.228271f, 0.306396f, 0.401123f, 0.504883f, 0.604492f,
+ 0.691895f, 0.760742f, 0.813477f, 0.853027f, 0.881836f, 0.904297f, 0.921387f, 0.934570f, 0.944824f, 0.953125f, 0.959961f, 0.964844f,
+ 0.969727f, 0.973633f, 0.976562f, 0.979492f, 0.981934f, 0.983887f, 0.986328f, 0.987305f, 0.988281f, 0.989258f, 0.991211f, 0.992188f,
+ 0.992676f, 0.993652f, 0.997559f, 0.998047f, 0.998047f, 0.998047f, 0.998047f, 0.998047f, 0.000069f, 0.000461f, 0.000609f, 0.000933f,
+ 0.001088f, 0.001488f, 0.001900f, 0.002378f, 0.003101f, 0.003687f, 0.004547f, 0.005276f, 0.006233f, 0.007282f, 0.008820f, 0.010239f,
+ 0.012581f, 0.015312f, 0.018341f, 0.022095f, 0.027344f, 0.034027f, 0.041687f, 0.053467f, 0.067810f, 0.088440f, 0.117126f, 0.156616f,
+ 0.211426f, 0.284180f, 0.375977f, 0.478760f, 0.581543f, 0.672363f, 0.746094f, 0.802734f, 0.845703f, 0.877441f, 0.900879f, 0.918457f,
+ 0.933105f, 0.943848f, 0.951660f, 0.959473f, 0.964355f, 0.968750f, 0.974121f, 0.977051f, 0.979492f, 0.982422f, 0.984375f, 0.985840f,
+ 0.987305f, 0.988770f, 0.990234f, 0.991211f, 0.992188f, 0.993164f, 0.997070f, 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.997559f,
+ 0.000244f, 0.000348f, 0.000606f, 0.000737f, 0.001079f, 0.001458f, 0.001783f, 0.002192f, 0.002924f, 0.003231f, 0.003862f, 0.004551f,
+ 0.005169f, 0.006367f, 0.007381f, 0.008682f, 0.010590f, 0.012199f, 0.014900f, 0.017761f, 0.021530f, 0.026108f, 0.032349f, 0.039642f,
+ 0.050446f, 0.064392f, 0.083313f, 0.109436f, 0.145996f, 0.197021f, 0.266357f, 0.354248f, 0.455811f, 0.560059f, 0.654785f, 0.732910f,
+ 0.793457f, 0.837891f, 0.873047f, 0.897461f, 0.917480f, 0.931641f, 0.941895f, 0.951172f, 0.958984f, 0.964844f, 0.969727f, 0.973633f,
+ 0.977051f, 0.979980f, 0.981934f, 0.984375f, 0.985840f, 0.988281f, 0.989258f, 0.990234f, 0.991211f, 0.992676f, 0.997070f, 0.997559f,
+ 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.000244f, 0.000520f, 0.000592f, 0.000720f, 0.000812f, 0.001174f, 0.001500f, 0.001884f,
+ 0.002178f, 0.002831f, 0.003321f, 0.003885f, 0.004471f, 0.005436f, 0.006275f, 0.007584f, 0.008675f, 0.010521f, 0.012238f, 0.014557f,
+ 0.017197f, 0.020874f, 0.025467f, 0.030960f, 0.038208f, 0.047821f, 0.061249f, 0.078552f, 0.103149f, 0.136841f, 0.184937f, 0.249878f,
+ 0.334473f, 0.435059f, 0.539551f, 0.638184f, 0.720215f, 0.784668f, 0.832031f, 0.868164f, 0.894531f, 0.914062f, 0.929688f, 0.942383f,
+ 0.950684f, 0.958984f, 0.964844f, 0.970215f, 0.974121f, 0.977539f, 0.979980f, 0.982422f, 0.984863f, 0.985840f, 0.988281f, 0.989258f,
+ 0.990723f, 0.992188f, 0.997070f, 0.997070f, 0.997070f, 0.997070f, 0.997559f, 0.997559f, 0.000000f, 0.000243f, 0.000351f, 0.000603f,
+ 0.000708f, 0.001079f, 0.001493f, 0.001752f, 0.001936f, 0.002171f, 0.002911f, 0.003382f, 0.003906f, 0.004578f, 0.005222f, 0.006161f,
+ 0.007362f, 0.008850f, 0.010010f, 0.011971f, 0.014145f, 0.016983f, 0.020477f, 0.024582f, 0.029739f, 0.036804f, 0.045837f, 0.057648f,
+ 0.074829f, 0.097534f, 0.130127f, 0.174438f, 0.236572f, 0.318604f, 0.416992f, 0.523926f, 0.624023f, 0.709961f, 0.777344f, 0.827148f,
+ 0.865234f, 0.893066f, 0.914062f, 0.929688f, 0.941406f, 0.951660f, 0.958496f, 0.965820f, 0.969238f, 0.974609f, 0.977539f, 0.980469f,
+ 0.983398f, 0.985352f, 0.986816f, 0.988281f, 0.989746f, 0.990723f, 0.996582f, 0.997070f, 0.997070f, 0.997070f, 0.997070f, 0.997070f,
+ 0.000243f, 0.000244f, 0.000456f, 0.000592f, 0.000602f, 0.001025f, 0.001282f, 0.001656f, 0.001856f, 0.002073f, 0.002535f, 0.002768f,
+ 0.003487f, 0.003822f, 0.004574f, 0.005589f, 0.006519f, 0.007336f, 0.008453f, 0.009911f, 0.011581f, 0.013985f, 0.016373f, 0.019638f,
+ 0.023819f, 0.028473f, 0.035339f, 0.043945f, 0.055939f, 0.071350f, 0.093140f, 0.123474f, 0.165771f, 0.225342f, 0.304199f, 0.402344f,
+ 0.509277f, 0.612305f, 0.702148f, 0.771973f, 0.824219f, 0.863281f, 0.891113f, 0.913086f, 0.930176f, 0.942383f, 0.951660f, 0.959473f,
+ 0.965820f, 0.970215f, 0.974609f, 0.977539f, 0.980957f, 0.983887f, 0.985352f, 0.987305f, 0.988770f, 0.990723f, 0.996582f, 0.996582f,
+ 0.997070f, 0.997070f, 0.997070f, 0.997070f, 0.000000f, 0.000243f, 0.000276f, 0.000557f, 0.000594f, 0.000849f, 0.000845f, 0.001282f,
+ 0.001520f, 0.001774f, 0.002119f, 0.002499f, 0.002840f, 0.003252f, 0.004005f, 0.004555f, 0.005245f, 0.006168f, 0.007233f, 0.008301f,
+ 0.009911f, 0.011330f, 0.013748f, 0.015945f, 0.019089f, 0.023071f, 0.027786f, 0.034058f, 0.042542f, 0.053619f, 0.068237f, 0.089539f,
+ 0.117798f, 0.158325f, 0.215698f, 0.293213f, 0.389893f, 0.498291f, 0.603027f, 0.694824f, 0.767090f, 0.821777f, 0.862305f, 0.891113f,
+ 0.914062f, 0.930176f, 0.942383f, 0.952148f, 0.959473f, 0.965820f, 0.971680f, 0.975098f, 0.978516f, 0.981445f, 0.983887f, 0.985840f,
+ 0.988281f, 0.989258f, 0.996094f, 0.996094f, 0.996582f, 0.996582f, 0.996094f, 0.996582f, 0.000240f, 0.000240f, 0.000242f, 0.000365f,
+ 0.000678f, 0.000779f, 0.000957f, 0.001003f, 0.001390f, 0.001656f, 0.001828f, 0.002274f, 0.002455f, 0.003210f, 0.003704f, 0.004097f,
+ 0.004616f, 0.005409f, 0.006180f, 0.007092f, 0.008453f, 0.009521f, 0.011154f, 0.013397f, 0.015656f, 0.018509f, 0.022247f, 0.026810f,
+ 0.032928f, 0.041046f, 0.051727f, 0.065613f, 0.085205f, 0.113098f, 0.152832f, 0.208496f, 0.284424f, 0.380371f, 0.489258f, 0.596680f,
+ 0.690918f, 0.764648f, 0.821777f, 0.862305f, 0.892578f, 0.914551f, 0.931152f, 0.943848f, 0.953613f, 0.960938f, 0.967773f, 0.971680f,
+ 0.976074f, 0.979492f, 0.982422f, 0.984863f, 0.986816f, 0.988281f, 0.995605f, 0.996094f, 0.996094f, 0.996094f, 0.996582f, 0.996094f,
+ 0.000000f, 0.000242f, 0.000242f, 0.000364f, 0.000465f, 0.000803f, 0.000927f, 0.000956f, 0.001275f, 0.001335f, 0.001570f, 0.001968f,
+ 0.002184f, 0.002726f, 0.003069f, 0.003294f, 0.003906f, 0.004662f, 0.005245f, 0.006027f, 0.007191f, 0.008202f, 0.009460f, 0.010735f,
+ 0.012970f, 0.015404f, 0.018051f, 0.021484f, 0.026321f, 0.032135f, 0.039581f, 0.049805f, 0.063538f, 0.082458f, 0.109497f, 0.147827f,
+ 0.202393f, 0.277344f, 0.373535f, 0.483887f, 0.593262f, 0.688477f, 0.764648f, 0.821289f, 0.863281f, 0.894043f, 0.916016f, 0.932129f,
+ 0.944336f, 0.954590f, 0.962402f, 0.968262f, 0.973633f, 0.977051f, 0.980957f, 0.983398f, 0.985352f, 0.987793f, 0.995605f, 0.996094f,
+ 0.996094f, 0.996094f, 0.996094f, 0.996582f, 0.000000f, 0.000239f, 0.000360f, 0.000362f, 0.000363f, 0.000475f, 0.000767f, 0.000931f,
+ 0.000951f, 0.001211f, 0.001491f, 0.001634f, 0.002129f, 0.002457f, 0.002678f, 0.002995f, 0.003393f, 0.003922f, 0.004711f, 0.005135f,
+ 0.005955f, 0.006935f, 0.008072f, 0.009270f, 0.010841f, 0.012558f, 0.014618f, 0.017502f, 0.020828f, 0.025269f, 0.030884f, 0.038269f,
+ 0.048218f, 0.061554f, 0.080505f, 0.106567f, 0.144287f, 0.197998f, 0.272705f, 0.369141f, 0.480469f, 0.591797f, 0.690430f, 0.767090f,
+ 0.824707f, 0.866699f, 0.896484f, 0.918457f, 0.934570f, 0.946777f, 0.956543f, 0.963379f, 0.969727f, 0.974609f, 0.978027f, 0.981934f,
+ 0.984375f, 0.986328f, 0.995117f, 0.995605f, 0.995605f, 0.995605f, 0.995605f, 0.995605f, 0.000000f, 0.000208f, 0.000238f, 0.000362f,
+ 0.000363f, 0.000555f, 0.000600f, 0.000888f, 0.001140f, 0.001140f, 0.001272f, 0.001661f, 0.001811f, 0.002041f, 0.002550f, 0.002636f,
+ 0.002941f, 0.003492f, 0.004032f, 0.004593f, 0.005062f, 0.005875f, 0.007015f, 0.007965f, 0.009079f, 0.010300f, 0.012291f, 0.014229f,
+ 0.016937f, 0.020248f, 0.024689f, 0.030151f, 0.037354f, 0.047028f, 0.060211f, 0.078491f, 0.104431f, 0.141602f, 0.195068f, 0.270264f,
+ 0.367676f, 0.480957f, 0.594238f, 0.693848f, 0.770996f, 0.828613f, 0.869629f, 0.898438f, 0.921875f, 0.937012f, 0.949219f, 0.958008f,
+ 0.964844f, 0.971680f, 0.976074f, 0.979980f, 0.982422f, 0.985840f, 0.994629f, 0.995117f, 0.995605f, 0.995605f, 0.995117f, 0.995117f,
+ 0.000000f, 0.000000f, 0.000229f, 0.000358f, 0.000479f, 0.000362f, 0.000498f, 0.000634f, 0.000836f, 0.000927f, 0.001288f, 0.001244f,
+ 0.001605f, 0.001732f, 0.002106f, 0.002478f, 0.002613f, 0.003183f, 0.003510f, 0.004021f, 0.004528f, 0.005047f, 0.005768f, 0.006859f,
+ 0.007759f, 0.008865f, 0.009933f, 0.011742f, 0.013741f, 0.016678f, 0.019897f, 0.024017f, 0.029297f, 0.036469f, 0.045990f, 0.058990f,
+ 0.077026f, 0.102722f, 0.140015f, 0.193604f, 0.269531f, 0.369141f, 0.485107f, 0.600098f, 0.700195f, 0.777344f, 0.833984f, 0.873535f,
+ 0.903809f, 0.924316f, 0.940430f, 0.951172f, 0.960938f, 0.968262f, 0.973145f, 0.978027f, 0.980957f, 0.983887f, 0.994629f, 0.995117f,
+ 0.995117f, 0.995605f, 0.995117f, 0.995117f, 0.000000f, 0.000000f, 0.000078f, 0.000353f, 0.000354f, 0.000360f, 0.000482f, 0.000573f,
+ 0.000757f, 0.000923f, 0.001230f, 0.001266f, 0.001485f, 0.001679f, 0.001963f, 0.002161f, 0.002235f, 0.002739f, 0.003115f, 0.003563f,
+ 0.003933f, 0.004436f, 0.004917f, 0.005623f, 0.006599f, 0.007469f, 0.008484f, 0.010101f, 0.011665f, 0.013695f, 0.016403f, 0.019531f,
+ 0.023300f, 0.028870f, 0.035889f, 0.045135f, 0.058014f, 0.075928f, 0.101746f, 0.139160f, 0.193848f, 0.271729f, 0.374023f, 0.492920f,
+ 0.609863f, 0.709473f, 0.786133f, 0.842285f, 0.880859f, 0.908691f, 0.928711f, 0.943848f, 0.954102f, 0.963867f, 0.969727f, 0.975098f,
+ 0.979004f, 0.982422f, 0.994141f, 0.994629f, 0.994141f, 0.994141f, 0.994141f, 0.994629f, 0.000000f, 0.000000f, 0.000000f, 0.000330f,
+ 0.000336f, 0.000352f, 0.000478f, 0.000481f, 0.000676f, 0.000822f, 0.001072f, 0.001228f, 0.001283f, 0.001417f, 0.001621f, 0.001938f,
+ 0.001953f, 0.002377f, 0.002737f, 0.002914f, 0.003624f, 0.003721f, 0.004555f, 0.004845f, 0.005531f, 0.006325f, 0.007244f, 0.008255f,
+ 0.009911f, 0.011467f, 0.013496f, 0.016068f, 0.018951f, 0.022888f, 0.028183f, 0.035126f, 0.044617f, 0.057220f, 0.075134f, 0.101501f,
+ 0.139526f, 0.195679f, 0.276123f, 0.381592f, 0.503418f, 0.622070f, 0.721680f, 0.796387f, 0.850098f, 0.887207f, 0.914551f, 0.933594f,
+ 0.947266f, 0.957520f, 0.966797f, 0.972656f, 0.977539f, 0.980957f, 0.993164f, 0.994141f, 0.994141f, 0.994141f, 0.994141f, 0.994141f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000243f, 0.000466f, 0.000474f, 0.000475f, 0.000600f, 0.000740f, 0.000796f, 0.001130f,
+ 0.001333f, 0.001339f, 0.001440f, 0.001575f, 0.001961f, 0.002031f, 0.002388f, 0.002563f, 0.003174f, 0.003345f, 0.003555f, 0.004143f,
+ 0.004681f, 0.005333f, 0.006191f, 0.007111f, 0.008278f, 0.009666f, 0.011177f, 0.013451f, 0.015511f, 0.018707f, 0.022629f, 0.027847f,
+ 0.034515f, 0.043976f, 0.056671f, 0.075012f, 0.101685f, 0.140869f, 0.199341f, 0.282959f, 0.393311f, 0.519043f, 0.639160f, 0.736328f,
+ 0.809082f, 0.860352f, 0.896484f, 0.920898f, 0.939453f, 0.951660f, 0.961914f, 0.969238f, 0.975098f, 0.979492f, 0.993164f, 0.993652f,
+ 0.994141f, 0.993652f, 0.993652f, 0.993652f, 0.000000f, 0.000000f, 0.000000f, 0.000120f, 0.000120f, 0.000367f, 0.000448f, 0.000589f,
+ 0.000595f, 0.000719f, 0.000707f, 0.000809f, 0.000966f, 0.001217f, 0.001369f, 0.001405f, 0.001579f, 0.001786f, 0.002100f, 0.002260f,
+ 0.002600f, 0.002762f, 0.003023f, 0.003531f, 0.004219f, 0.004810f, 0.005409f, 0.006092f, 0.007053f, 0.008064f, 0.009163f, 0.010941f,
+ 0.012733f, 0.015251f, 0.018280f, 0.022202f, 0.027573f, 0.034271f, 0.043732f, 0.056458f, 0.075134f, 0.102661f, 0.143433f, 0.205078f,
+ 0.293701f, 0.409668f, 0.538574f, 0.658203f, 0.753418f, 0.823242f, 0.870605f, 0.905273f, 0.927734f, 0.943848f, 0.956055f, 0.964844f,
+ 0.972168f, 0.977539f, 0.992188f, 0.992676f, 0.993164f, 0.993652f, 0.993164f, 0.992676f, 0.000000f, 0.000000f, 0.000000f, 0.000111f,
+ 0.000224f, 0.000231f, 0.000314f, 0.000562f, 0.000589f, 0.000699f, 0.000717f, 0.000776f, 0.000926f, 0.000968f, 0.001242f, 0.001360f,
+ 0.001487f, 0.001564f, 0.001713f, 0.002073f, 0.002169f, 0.002380f, 0.002941f, 0.003229f, 0.003534f, 0.003914f, 0.004509f, 0.005127f,
+ 0.005939f, 0.006596f, 0.007812f, 0.009354f, 0.010559f, 0.012581f, 0.015007f, 0.018021f, 0.022079f, 0.027191f, 0.034119f, 0.043427f,
+ 0.057190f, 0.075623f, 0.104492f, 0.147949f, 0.213135f, 0.308105f, 0.430664f, 0.562500f, 0.681641f, 0.772949f, 0.839355f, 0.884277f,
+ 0.913574f, 0.934570f, 0.950195f, 0.961426f, 0.969238f, 0.975098f, 0.991211f, 0.992676f, 0.992676f, 0.992676f, 0.992676f, 0.992188f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000084f, 0.000117f, 0.000119f, 0.000367f, 0.000473f, 0.000555f, 0.000576f, 0.000674f, 0.000713f,
+ 0.000816f, 0.000913f, 0.001049f, 0.001168f, 0.001263f, 0.001473f, 0.001580f, 0.001781f, 0.002005f, 0.002123f, 0.002316f, 0.002674f,
+ 0.003094f, 0.003475f, 0.003967f, 0.004318f, 0.004833f, 0.005798f, 0.006699f, 0.007801f, 0.008888f, 0.010429f, 0.012268f, 0.014824f,
+ 0.017792f, 0.021790f, 0.026978f, 0.033844f, 0.043518f, 0.057068f, 0.077148f, 0.107605f, 0.154053f, 0.224609f, 0.326904f, 0.456543f,
+ 0.591797f, 0.708984f, 0.795410f, 0.855957f, 0.895508f, 0.923340f, 0.942383f, 0.955566f, 0.965332f, 0.973145f, 0.991211f, 0.991699f,
+ 0.992188f, 0.992188f, 0.992188f, 0.991699f, 0.000000f, 0.000000f, 0.000000f, 0.000092f, 0.000070f, 0.000236f, 0.000119f, 0.000376f,
+ 0.000433f, 0.000561f, 0.000688f, 0.000586f, 0.000742f, 0.000842f, 0.000881f, 0.000937f, 0.001141f, 0.001300f, 0.001434f, 0.001464f,
+ 0.001598f, 0.001829f, 0.002062f, 0.002338f, 0.002583f, 0.003036f, 0.003460f, 0.003704f, 0.004383f, 0.004986f, 0.005615f, 0.006439f,
+ 0.007267f, 0.008797f, 0.010330f, 0.012146f, 0.014473f, 0.017532f, 0.021622f, 0.026535f, 0.033539f, 0.043579f, 0.058044f, 0.079041f,
+ 0.111572f, 0.162109f, 0.239746f, 0.350830f, 0.488770f, 0.625000f, 0.737305f, 0.817871f, 0.871582f, 0.908203f, 0.932129f, 0.949219f,
+ 0.961914f, 0.970215f, 0.990234f, 0.991211f, 0.991211f, 0.991211f, 0.991211f, 0.991211f, 0.000000f, 0.000000f, 0.000000f, 0.000080f,
+ 0.000100f, 0.000115f, 0.000335f, 0.000350f, 0.000355f, 0.000473f, 0.000633f, 0.000678f, 0.000695f, 0.000694f, 0.000812f, 0.000733f,
+ 0.001109f, 0.001098f, 0.001260f, 0.001452f, 0.001377f, 0.001534f, 0.001972f, 0.001982f, 0.002232f, 0.002567f, 0.002764f, 0.003273f,
+ 0.003542f, 0.004181f, 0.004738f, 0.005466f, 0.006268f, 0.007126f, 0.008614f, 0.010170f, 0.012093f, 0.014359f, 0.017075f, 0.021042f,
+ 0.026459f, 0.033722f, 0.044159f, 0.059113f, 0.082092f, 0.117249f, 0.173218f, 0.259766f, 0.382080f, 0.526367f, 0.662598f, 0.768066f,
+ 0.840332f, 0.889648f, 0.920410f, 0.940918f, 0.956543f, 0.966309f, 0.989746f, 0.990234f, 0.990723f, 0.990723f, 0.990723f, 0.990723f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000191f, 0.000236f, 0.000335f, 0.000337f, 0.000466f, 0.000399f, 0.000608f,
+ 0.000626f, 0.000669f, 0.000696f, 0.000808f, 0.000859f, 0.000915f, 0.000903f, 0.001168f, 0.001245f, 0.001500f, 0.001525f, 0.001863f,
+ 0.001941f, 0.002121f, 0.002399f, 0.002861f, 0.002953f, 0.003632f, 0.004105f, 0.004745f, 0.005333f, 0.006317f, 0.007236f, 0.008255f,
+ 0.009857f, 0.011414f, 0.014015f, 0.016922f, 0.020828f, 0.026321f, 0.034149f, 0.044861f, 0.061279f, 0.085571f, 0.124878f, 0.187866f,
+ 0.285645f, 0.420654f, 0.570801f, 0.703125f, 0.799805f, 0.864258f, 0.905273f, 0.932129f, 0.950684f, 0.963379f, 0.988770f, 0.989258f,
+ 0.989746f, 0.989746f, 0.989746f, 0.989746f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000000f, 0.000122f, 0.000125f, 0.000232f,
+ 0.000360f, 0.000342f, 0.000463f, 0.000388f, 0.000569f, 0.000638f, 0.000671f, 0.000791f, 0.000774f, 0.000943f, 0.000774f, 0.001018f,
+ 0.001044f, 0.001245f, 0.001377f, 0.001410f, 0.001643f, 0.001970f, 0.002041f, 0.002316f, 0.002758f, 0.003023f, 0.003433f, 0.003859f,
+ 0.004444f, 0.005180f, 0.006134f, 0.006920f, 0.008102f, 0.009354f, 0.011475f, 0.013649f, 0.016739f, 0.021011f, 0.026566f, 0.034454f,
+ 0.046051f, 0.063843f, 0.090942f, 0.135498f, 0.207642f, 0.319580f, 0.467529f, 0.620605f, 0.745605f, 0.830566f, 0.886230f, 0.920898f,
+ 0.943848f, 0.958984f, 0.987793f, 0.988281f, 0.988770f, 0.988770f, 0.988281f, 0.988770f, 0.000000f, 0.000000f, 0.000000f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000188f, 0.000200f, 0.000332f, 0.000417f, 0.000338f, 0.000459f, 0.000349f, 0.000558f, 0.000642f, 0.000636f,
+ 0.000629f, 0.000807f, 0.000695f, 0.000747f, 0.000827f, 0.001058f, 0.001182f, 0.001269f, 0.001422f, 0.001472f, 0.001921f, 0.002100f,
+ 0.002337f, 0.002462f, 0.003073f, 0.003374f, 0.003708f, 0.004265f, 0.004826f, 0.005646f, 0.006596f, 0.007710f, 0.008926f, 0.011063f,
+ 0.013580f, 0.016495f, 0.020737f, 0.026459f, 0.035126f, 0.047791f, 0.066833f, 0.097778f, 0.149170f, 0.233887f, 0.363037f, 0.523438f,
+ 0.674805f, 0.788086f, 0.860352f, 0.906250f, 0.935547f, 0.954102f, 0.986328f, 0.987305f, 0.987305f, 0.987305f, 0.987305f, 0.987793f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000175f, 0.000155f, 0.000319f, 0.000241f, 0.000318f,
+ 0.000455f, 0.000462f, 0.000496f, 0.000593f, 0.000516f, 0.000564f, 0.000667f, 0.000668f, 0.000715f, 0.000749f, 0.000925f, 0.001111f,
+ 0.001246f, 0.001381f, 0.001443f, 0.001856f, 0.001997f, 0.002264f, 0.002363f, 0.002880f, 0.003212f, 0.003727f, 0.004208f, 0.004673f,
+ 0.005394f, 0.006367f, 0.007404f, 0.009003f, 0.010651f, 0.013138f, 0.016312f, 0.020767f, 0.027054f, 0.036377f, 0.050262f, 0.071655f,
+ 0.107361f, 0.167969f, 0.269287f, 0.418457f, 0.587402f, 0.730957f, 0.828125f, 0.888184f, 0.924805f, 0.948242f, 0.984863f, 0.986328f,
+ 0.986328f, 0.985840f, 0.986328f, 0.986328f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f,
+ 0.000202f, 0.000133f, 0.000215f, 0.000263f, 0.000304f, 0.000442f, 0.000332f, 0.000365f, 0.000403f, 0.000549f, 0.000607f, 0.000750f,
+ 0.000788f, 0.000802f, 0.000841f, 0.000958f, 0.001049f, 0.001188f, 0.001354f, 0.001318f, 0.001582f, 0.001928f, 0.002064f, 0.002321f,
+ 0.002594f, 0.003042f, 0.003222f, 0.003796f, 0.004440f, 0.005112f, 0.006081f, 0.007259f, 0.008736f, 0.010612f, 0.013077f, 0.016464f,
+ 0.020950f, 0.027664f, 0.037506f, 0.052795f, 0.077698f, 0.120361f, 0.194336f, 0.317627f, 0.486572f, 0.657227f, 0.785156f, 0.865234f,
+ 0.913086f, 0.942871f, 0.983887f, 0.984863f, 0.984375f, 0.984863f, 0.984375f, 0.984863f, 0.000000f, 0.000000f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000152f, 0.000257f, 0.000243f, 0.000288f, 0.000345f, 0.000228f,
+ 0.000358f, 0.000363f, 0.000432f, 0.000494f, 0.000530f, 0.000582f, 0.000762f, 0.000771f, 0.000913f, 0.000978f, 0.001100f, 0.001305f,
+ 0.001373f, 0.001706f, 0.001712f, 0.001922f, 0.002155f, 0.002569f, 0.002573f, 0.003094f, 0.003401f, 0.004272f, 0.004978f, 0.005829f,
+ 0.006924f, 0.008453f, 0.010452f, 0.012871f, 0.016617f, 0.021072f, 0.028427f, 0.039429f, 0.056732f, 0.086243f, 0.138916f, 0.231812f,
+ 0.381592f, 0.566406f, 0.726562f, 0.833496f, 0.896973f, 0.933594f, 0.981934f, 0.982910f, 0.982910f, 0.982910f, 0.982910f, 0.982910f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000121f, 0.000127f, 0.000215f,
+ 0.000159f, 0.000233f, 0.000284f, 0.000326f, 0.000339f, 0.000339f, 0.000352f, 0.000394f, 0.000623f, 0.000622f, 0.000731f, 0.000730f,
+ 0.000741f, 0.000829f, 0.000914f, 0.001017f, 0.001151f, 0.001469f, 0.001263f, 0.001480f, 0.001740f, 0.002069f, 0.002104f, 0.002443f,
+ 0.002831f, 0.003519f, 0.003929f, 0.004627f, 0.005455f, 0.006634f, 0.008316f, 0.009949f, 0.012596f, 0.016495f, 0.021729f, 0.029877f,
+ 0.042084f, 0.062805f, 0.098694f, 0.165283f, 0.284668f, 0.465088f, 0.654297f, 0.793945f, 0.877930f, 0.924805f, 0.979980f, 0.980957f,
+ 0.980957f, 0.981445f, 0.981445f, 0.980957f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000121f,
+ 0.000121f, 0.000121f, 0.000150f, 0.000163f, 0.000069f, 0.000057f, 0.000121f, 0.000231f, 0.000291f, 0.000304f, 0.000334f, 0.000339f,
+ 0.000346f, 0.000569f, 0.000648f, 0.000674f, 0.000649f, 0.000697f, 0.000772f, 0.000834f, 0.000972f, 0.001005f, 0.001189f, 0.001359f,
+ 0.001237f, 0.001567f, 0.001794f, 0.001963f, 0.002378f, 0.002712f, 0.002867f, 0.003853f, 0.004330f, 0.005196f, 0.006516f, 0.008026f,
+ 0.009888f, 0.012703f, 0.016479f, 0.022110f, 0.031158f, 0.045746f, 0.070557f, 0.117004f, 0.204956f, 0.360596f, 0.564453f, 0.740723f,
+ 0.852051f, 0.912598f, 0.977539f, 0.979492f, 0.979492f, 0.979004f, 0.979492f, 0.979004f, 0.000000f, 0.000000f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000098f, 0.000082f, 0.000067f, 0.000056f, 0.000124f,
+ 0.000193f, 0.000240f, 0.000258f, 0.000310f, 0.000326f, 0.000335f, 0.000341f, 0.000471f, 0.000613f, 0.000494f, 0.000716f, 0.000742f,
+ 0.000804f, 0.000873f, 0.000832f, 0.001070f, 0.001120f, 0.001146f, 0.001225f, 0.001696f, 0.001814f, 0.002041f, 0.002419f, 0.002941f,
+ 0.003433f, 0.004154f, 0.004818f, 0.006077f, 0.007652f, 0.009521f, 0.012444f, 0.017029f, 0.023193f, 0.033539f, 0.050690f, 0.082092f,
+ 0.144043f, 0.265869f, 0.463379f, 0.672363f, 0.818848f, 0.898438f, 0.975586f, 0.976562f, 0.976562f, 0.976562f, 0.976074f, 0.976562f,
+ 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000114f,
+ 0.000096f, 0.000079f, 0.000125f, 0.000056f, 0.000142f, 0.000120f, 0.000195f, 0.000246f, 0.000321f, 0.000305f, 0.000319f, 0.000395f,
+ 0.000442f, 0.000540f, 0.000642f, 0.000638f, 0.000696f, 0.000674f, 0.000687f, 0.000857f, 0.000955f, 0.001128f, 0.001224f, 0.001364f,
+ 0.001347f, 0.001555f, 0.001910f, 0.002245f, 0.002714f, 0.003229f, 0.003824f, 0.004673f, 0.005676f, 0.007225f, 0.009293f, 0.012802f,
+ 0.017273f, 0.024368f, 0.036682f, 0.058075f, 0.100952f, 0.188721f, 0.358154f, 0.587891f, 0.775879f, 0.881348f, 0.972168f, 0.972656f,
+ 0.972656f, 0.973145f, 0.973145f, 0.973633f, 0.000000f, 0.000000f, 0.000122f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f,
+ 0.000121f, 0.000121f, 0.000121f, 0.000120f, 0.000112f, 0.000093f, 0.000079f, 0.000067f, 0.000057f, 0.000049f, 0.000133f, 0.000137f,
+ 0.000163f, 0.000244f, 0.000328f, 0.000366f, 0.000356f, 0.000415f, 0.000436f, 0.000543f, 0.000555f, 0.000638f, 0.000597f, 0.000702f,
+ 0.000786f, 0.000648f, 0.000891f, 0.000804f, 0.001218f, 0.001070f, 0.001355f, 0.001731f, 0.002171f, 0.002352f, 0.002796f, 0.003546f,
+ 0.004189f, 0.005558f, 0.006939f, 0.009209f, 0.012337f, 0.017776f, 0.026016f, 0.040833f, 0.069946f, 0.130981f, 0.262207f, 0.489258f,
+ 0.719238f, 0.859375f, 0.968262f, 0.969238f, 0.969727f, 0.969727f, 0.969727f, 0.969727f, 0.000000f, 0.000122f, 0.000121f, 0.000121f,
+ 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000110f, 0.000093f, 0.000080f,
+ 0.000068f, 0.000094f, 0.000119f, 0.000117f, 0.000120f, 0.000123f, 0.000173f, 0.000263f, 0.000263f, 0.000359f, 0.000386f, 0.000390f,
+ 0.000401f, 0.000556f, 0.000549f, 0.000573f, 0.000502f, 0.000707f, 0.000789f, 0.000629f, 0.000847f, 0.001003f, 0.001024f, 0.001242f,
+ 0.001423f, 0.001877f, 0.002012f, 0.002571f, 0.003071f, 0.003925f, 0.005131f, 0.006767f, 0.009140f, 0.012672f, 0.018509f, 0.028992f,
+ 0.048309f, 0.089233f, 0.183838f, 0.383545f, 0.646973f, 0.830078f, 0.963867f, 0.964844f, 0.964844f, 0.965820f, 0.965820f, 0.965820f,
+ 0.000000f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000120f,
+ 0.000119f, 0.000119f, 0.000113f, 0.000095f, 0.000083f, 0.000070f, 0.000061f, 0.000054f, 0.000048f, 0.000042f, 0.000115f, 0.000112f,
+ 0.000151f, 0.000213f, 0.000309f, 0.000298f, 0.000359f, 0.000337f, 0.000382f, 0.000440f, 0.000576f, 0.000477f, 0.000453f, 0.000690f,
+ 0.000687f, 0.000795f, 0.000776f, 0.000911f, 0.001117f, 0.001119f, 0.001352f, 0.002001f, 0.002140f, 0.002832f, 0.003609f, 0.004715f,
+ 0.006302f, 0.008835f, 0.013115f, 0.020004f, 0.032867f, 0.060333f, 0.124512f, 0.281982f, 0.557617f, 0.794434f, 0.959473f, 0.959961f,
+ 0.960449f, 0.960449f, 0.960449f, 0.959961f, 0.000122f, 0.000121f, 0.000121f, 0.000120f, 0.000120f, 0.000120f, 0.000119f, 0.000119f,
+ 0.000119f, 0.000119f, 0.000119f, 0.000119f, 0.000118f, 0.000118f, 0.000118f, 0.000116f, 0.000098f, 0.000087f, 0.000076f, 0.000065f,
+ 0.000057f, 0.000050f, 0.000045f, 0.000091f, 0.000074f, 0.000106f, 0.000185f, 0.000193f, 0.000228f, 0.000328f, 0.000323f, 0.000399f,
+ 0.000429f, 0.000498f, 0.000552f, 0.000432f, 0.000542f, 0.000592f, 0.000599f, 0.000729f, 0.000734f, 0.000885f, 0.001304f, 0.001273f,
+ 0.001756f, 0.001931f, 0.002445f, 0.003120f, 0.004456f, 0.006165f, 0.008751f, 0.013466f, 0.022141f, 0.040192f, 0.082397f, 0.195679f,
+ 0.455322f, 0.745117f, 0.952637f, 0.953613f, 0.953613f, 0.954102f, 0.952637f, 0.953613f, 0.000000f, 0.000120f, 0.000120f, 0.000119f,
+ 0.000119f, 0.000119f, 0.000118f, 0.000118f, 0.000118f, 0.000118f, 0.000118f, 0.000117f, 0.000117f, 0.000117f, 0.000117f, 0.000117f,
+ 0.000117f, 0.000104f, 0.000092f, 0.000079f, 0.000071f, 0.000062f, 0.000055f, 0.000049f, 0.000044f, 0.000039f, 0.000099f, 0.000106f,
+ 0.000158f, 0.000169f, 0.000241f, 0.000274f, 0.000293f, 0.000389f, 0.000360f, 0.000399f, 0.000387f, 0.000446f, 0.000401f, 0.000530f,
+ 0.000565f, 0.000691f, 0.000722f, 0.000848f, 0.001147f, 0.001418f, 0.001677f, 0.002087f, 0.002972f, 0.004169f, 0.005623f, 0.008835f,
+ 0.014404f, 0.026077f, 0.053467f, 0.129395f, 0.346924f, 0.685059f, 0.943848f, 0.945801f, 0.945801f, 0.945312f, 0.945801f, 0.945801f,
+ 0.000000f, 0.000000f, 0.000117f, 0.000116f, 0.000117f, 0.000117f, 0.000116f, 0.000116f, 0.000115f, 0.000116f, 0.000115f, 0.000116f,
+ 0.000115f, 0.000115f, 0.000115f, 0.000115f, 0.000115f, 0.000115f, 0.000110f, 0.000097f, 0.000086f, 0.000077f, 0.000067f, 0.000060f,
+ 0.000053f, 0.000048f, 0.000043f, 0.000061f, 0.000090f, 0.000083f, 0.000139f, 0.000139f, 0.000216f, 0.000254f, 0.000307f, 0.000358f,
+ 0.000269f, 0.000377f, 0.000324f, 0.000369f, 0.000405f, 0.000455f, 0.000524f, 0.000706f, 0.000701f, 0.001012f, 0.001206f, 0.001316f,
+ 0.001663f, 0.002350f, 0.003571f, 0.005505f, 0.008873f, 0.016006f, 0.033234f, 0.081848f, 0.244751f, 0.605469f, 0.934082f, 0.935059f,
+ 0.936035f, 0.935547f, 0.935547f, 0.935547f, 0.000105f, 0.000114f, 0.000113f, 0.000113f, 0.000111f, 0.000111f, 0.000112f, 0.000111f,
+ 0.000112f, 0.000112f, 0.000112f, 0.000112f, 0.000111f, 0.000112f, 0.000112f, 0.000112f, 0.000112f, 0.000112f, 0.000112f, 0.000112f,
+ 0.000105f, 0.000093f, 0.000083f, 0.000074f, 0.000066f, 0.000059f, 0.000053f, 0.000048f, 0.000043f, 0.000062f, 0.000052f, 0.000063f,
+ 0.000092f, 0.000146f, 0.000176f, 0.000216f, 0.000227f, 0.000263f, 0.000244f, 0.000267f, 0.000370f, 0.000326f, 0.000360f, 0.000391f,
+ 0.000505f, 0.000618f, 0.000726f, 0.000969f, 0.001117f, 0.001651f, 0.002131f, 0.003090f, 0.005188f, 0.009499f, 0.019836f, 0.049042f,
+ 0.159180f, 0.509766f, 0.921875f, 0.922852f, 0.922852f, 0.922363f, 0.923340f, 0.922852f, 0.000000f, 0.000000f, 0.000065f, 0.000098f,
+ 0.000096f, 0.000101f, 0.000100f, 0.000104f, 0.000104f, 0.000103f, 0.000106f, 0.000106f, 0.000106f, 0.000105f, 0.000107f, 0.000107f,
+ 0.000106f, 0.000107f, 0.000107f, 0.000108f, 0.000107f, 0.000108f, 0.000104f, 0.000092f, 0.000082f, 0.000075f, 0.000067f, 0.000059f,
+ 0.000054f, 0.000048f, 0.000044f, 0.000039f, 0.000037f, 0.000058f, 0.000066f, 0.000122f, 0.000137f, 0.000175f, 0.000208f, 0.000194f,
+ 0.000208f, 0.000240f, 0.000270f, 0.000281f, 0.000323f, 0.000364f, 0.000479f, 0.000591f, 0.000712f, 0.000986f, 0.001224f, 0.001896f,
+ 0.002996f, 0.005196f, 0.010506f, 0.027527f, 0.095581f, 0.399658f, 0.905762f, 0.906738f, 0.906250f, 0.905762f, 0.905762f, 0.907227f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000017f, 0.000030f, 0.000054f, 0.000061f, 0.000081f, 0.000087f, 0.000088f, 0.000089f, 0.000093f,
+ 0.000093f, 0.000096f, 0.000096f, 0.000097f, 0.000098f, 0.000099f, 0.000098f, 0.000100f, 0.000100f, 0.000101f, 0.000100f, 0.000101f,
+ 0.000101f, 0.000092f, 0.000082f, 0.000074f, 0.000067f, 0.000060f, 0.000054f, 0.000049f, 0.000045f, 0.000040f, 0.000036f, 0.000037f,
+ 0.000059f, 0.000077f, 0.000093f, 0.000143f, 0.000155f, 0.000188f, 0.000178f, 0.000184f, 0.000231f, 0.000234f, 0.000272f, 0.000352f,
+ 0.000420f, 0.000525f, 0.000764f, 0.001091f, 0.001653f, 0.002705f, 0.005474f, 0.013939f, 0.051880f, 0.283691f, 0.883789f, 0.884766f,
+ 0.885254f, 0.885254f, 0.885742f, 0.885254f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000013f,
+ 0.000032f, 0.000046f, 0.000050f, 0.000060f, 0.000065f, 0.000065f, 0.000075f, 0.000078f, 0.000080f, 0.000079f, 0.000084f, 0.000083f,
+ 0.000087f, 0.000087f, 0.000089f, 0.000090f, 0.000091f, 0.000091f, 0.000092f, 0.000092f, 0.000083f, 0.000075f, 0.000068f, 0.000062f,
+ 0.000056f, 0.000050f, 0.000046f, 0.000042f, 0.000037f, 0.000039f, 0.000044f, 0.000072f, 0.000068f, 0.000089f, 0.000125f, 0.000124f,
+ 0.000126f, 0.000153f, 0.000183f, 0.000212f, 0.000219f, 0.000311f, 0.000363f, 0.000566f, 0.000846f, 0.001332f, 0.002522f, 0.006252f,
+ 0.023834f, 0.175415f, 0.855957f, 0.856934f, 0.856934f, 0.856934f, 0.857422f, 0.856934f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000007f, 0.000024f, 0.000028f,
+ 0.000040f, 0.000044f, 0.000051f, 0.000053f, 0.000060f, 0.000063f, 0.000064f, 0.000067f, 0.000071f, 0.000072f, 0.000074f, 0.000076f,
+ 0.000077f, 0.000079f, 0.000079f, 0.000075f, 0.000068f, 0.000062f, 0.000056f, 0.000051f, 0.000046f, 0.000042f, 0.000038f, 0.000034f,
+ 0.000031f, 0.000030f, 0.000045f, 0.000079f, 0.000081f, 0.000107f, 0.000114f, 0.000106f, 0.000144f, 0.000136f, 0.000171f, 0.000254f,
+ 0.000377f, 0.000531f, 0.001037f, 0.002504f, 0.009140f, 0.088379f, 0.818848f, 0.820801f, 0.819824f, 0.820312f, 0.819336f, 0.820801f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000007f, 0.000014f, 0.000021f, 0.000028f,
+ 0.000034f, 0.000036f, 0.000042f, 0.000046f, 0.000049f, 0.000052f, 0.000054f, 0.000056f, 0.000059f, 0.000061f, 0.000064f, 0.000061f,
+ 0.000055f, 0.000050f, 0.000045f, 0.000041f, 0.000037f, 0.000033f, 0.000030f, 0.000027f, 0.000024f, 0.000033f, 0.000060f, 0.000059f,
+ 0.000075f, 0.000073f, 0.000101f, 0.000089f, 0.000144f, 0.000226f, 0.000384f, 0.000847f, 0.003033f, 0.031860f, 0.770020f, 0.770996f,
+ 0.772461f, 0.771973f, 0.772461f, 0.771973f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000006f, 0.000010f, 0.000016f,
+ 0.000021f, 0.000023f, 0.000029f, 0.000032f, 0.000036f, 0.000039f, 0.000042f, 0.000044f, 0.000042f, 0.000038f, 0.000035f, 0.000031f,
+ 0.000028f, 0.000025f, 0.000022f, 0.000020f, 0.000017f, 0.000024f, 0.000040f, 0.000047f, 0.000053f, 0.000063f, 0.000087f, 0.000190f,
+ 0.000666f, 0.007278f, 0.708496f, 0.709961f, 0.710449f, 0.710938f, 0.710938f, 0.710449f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000001f,
+ 0.000005f, 0.000010f, 0.000014f, 0.000018f, 0.000021f, 0.000024f, 0.000024f, 0.000021f, 0.000018f, 0.000016f, 0.000014f, 0.000012f,
+ 0.000008f, 0.000020f, 0.000022f, 0.000025f, 0.000073f, 0.000744f, 0.632324f, 0.632812f, 0.633789f, 0.633789f, 0.633301f, 0.632812f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000003f, 0.000007f, 0.000006f, 0.000004f, 0.000005f, 0.000007f, 0.543945f, 0.545410f,
+ 0.545410f, 0.545410f, 0.546387f, 0.545898f,
+ },
+ {
+ 0.159546f, 0.492676f, 0.684570f, 0.783203f, 0.838379f, 0.873535f, 0.897949f, 0.913574f, 0.926270f, 0.936035f, 0.943359f, 0.950195f,
+ 0.955566f, 0.959473f, 0.963379f, 0.966797f, 0.969238f, 0.972168f, 0.973633f, 0.976562f, 0.978027f, 0.979492f, 0.980957f, 0.982422f,
+ 0.983887f, 0.984863f, 0.985840f, 0.986816f, 0.987793f, 0.988770f, 0.989258f, 0.989746f, 0.990234f, 0.990723f, 0.991699f, 0.992676f,
+ 0.993164f, 0.993652f, 0.993652f, 0.994141f, 0.994629f, 0.995117f, 0.995117f, 0.995605f, 0.996582f, 0.996582f, 0.997070f, 0.997070f,
+ 0.997070f, 0.997559f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.034119f, 0.154175f, 0.341309f, 0.532227f, 0.672363f, 0.763184f, 0.820801f, 0.858398f,
+ 0.885742f, 0.904297f, 0.918945f, 0.929199f, 0.938965f, 0.945801f, 0.951660f, 0.956543f, 0.961426f, 0.964355f, 0.968262f, 0.970703f,
+ 0.973145f, 0.975586f, 0.977539f, 0.979004f, 0.980469f, 0.981934f, 0.983398f, 0.984375f, 0.985352f, 0.986328f, 0.987305f, 0.988281f,
+ 0.988770f, 0.989746f, 0.990234f, 0.991211f, 0.991699f, 0.992676f, 0.993164f, 0.993164f, 0.993652f, 0.994141f, 0.994629f, 0.995117f,
+ 0.995605f, 0.996094f, 0.996582f, 0.996582f, 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.999023f,
+ 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.013390f, 0.056915f, 0.134155f, 0.257080f,
+ 0.412109f, 0.560547f, 0.675781f, 0.755859f, 0.812012f, 0.851074f, 0.877930f, 0.898926f, 0.913574f, 0.925781f, 0.935059f, 0.942871f,
+ 0.949707f, 0.954590f, 0.959473f, 0.963379f, 0.966797f, 0.969238f, 0.971680f, 0.975098f, 0.976562f, 0.978516f, 0.979980f, 0.980957f,
+ 0.982422f, 0.984375f, 0.985352f, 0.985840f, 0.987305f, 0.987793f, 0.988770f, 0.989746f, 0.990723f, 0.991211f, 0.991699f, 0.992188f,
+ 0.992676f, 0.993164f, 0.993652f, 0.994141f, 0.994629f, 0.995605f, 0.995605f, 0.995605f, 0.996582f, 0.996582f, 0.997070f, 0.997070f,
+ 0.997559f, 0.997559f, 0.998047f, 0.998535f, 0.998535f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f,
+ 0.006939f, 0.027863f, 0.061951f, 0.117859f, 0.204834f, 0.324707f, 0.460205f, 0.585449f, 0.684570f, 0.757324f, 0.810059f, 0.847168f,
+ 0.874023f, 0.895996f, 0.910645f, 0.922852f, 0.933105f, 0.940918f, 0.947754f, 0.953613f, 0.958496f, 0.961914f, 0.965820f, 0.968750f,
+ 0.971680f, 0.974121f, 0.976074f, 0.978027f, 0.979492f, 0.981445f, 0.982910f, 0.983887f, 0.984863f, 0.986328f, 0.987305f, 0.988281f,
+ 0.988770f, 0.989746f, 0.990234f, 0.990723f, 0.991699f, 0.992188f, 0.993164f, 0.993652f, 0.993652f, 0.994141f, 0.995117f, 0.995605f,
+ 0.996094f, 0.996094f, 0.996582f, 0.996582f, 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.998535f, 0.998535f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.004211f, 0.016022f, 0.034119f, 0.061432f, 0.104797f, 0.170288f, 0.262695f, 0.377686f,
+ 0.499756f, 0.608887f, 0.696777f, 0.762207f, 0.810547f, 0.847168f, 0.873535f, 0.893066f, 0.910156f, 0.922852f, 0.932617f, 0.939941f,
+ 0.946777f, 0.953125f, 0.958496f, 0.961914f, 0.965332f, 0.968750f, 0.971680f, 0.973633f, 0.975586f, 0.977539f, 0.979492f, 0.981445f,
+ 0.982910f, 0.984375f, 0.985840f, 0.986328f, 0.987793f, 0.987793f, 0.989258f, 0.989746f, 0.990723f, 0.991211f, 0.992188f, 0.992676f,
+ 0.992676f, 0.993652f, 0.994141f, 0.994629f, 0.995605f, 0.996094f, 0.996094f, 0.996094f, 0.996582f, 0.997070f, 0.997559f, 0.997559f,
+ 0.998047f, 0.998535f, 0.999512f, 0.999512f, 0.999023f, 0.999512f, 0.999023f, 0.999023f, 0.002724f, 0.010384f, 0.020813f, 0.036285f,
+ 0.059784f, 0.093933f, 0.145508f, 0.218018f, 0.313232f, 0.424072f, 0.534180f, 0.632812f, 0.709961f, 0.769531f, 0.815918f, 0.848145f,
+ 0.874512f, 0.894043f, 0.909668f, 0.922363f, 0.932129f, 0.939941f, 0.946777f, 0.953125f, 0.958008f, 0.961914f, 0.965332f, 0.968750f,
+ 0.971680f, 0.973633f, 0.976562f, 0.978516f, 0.979980f, 0.981445f, 0.982910f, 0.984863f, 0.985352f, 0.986816f, 0.987793f, 0.988281f,
+ 0.988770f, 0.989746f, 0.990723f, 0.991211f, 0.992188f, 0.992676f, 0.993652f, 0.994141f, 0.994629f, 0.995117f, 0.995605f, 0.996094f,
+ 0.996094f, 0.996582f, 0.996582f, 0.997559f, 0.997559f, 0.998047f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f,
+ 0.002113f, 0.007004f, 0.014091f, 0.023895f, 0.037811f, 0.057373f, 0.085632f, 0.127075f, 0.185425f, 0.263672f, 0.360596f, 0.465576f,
+ 0.566895f, 0.655762f, 0.725586f, 0.779297f, 0.822266f, 0.853516f, 0.877441f, 0.895996f, 0.911621f, 0.923828f, 0.933105f, 0.940918f,
+ 0.947754f, 0.953613f, 0.957520f, 0.962402f, 0.965820f, 0.968750f, 0.972168f, 0.974121f, 0.976074f, 0.978027f, 0.980469f, 0.981934f,
+ 0.983398f, 0.984863f, 0.985352f, 0.986328f, 0.988281f, 0.988281f, 0.989258f, 0.990234f, 0.991211f, 0.992188f, 0.992676f, 0.993164f,
+ 0.993652f, 0.994629f, 0.994629f, 0.995605f, 0.995605f, 0.996094f, 0.996582f, 0.997070f, 0.997559f, 0.998047f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.001575f, 0.005211f, 0.010040f, 0.016220f, 0.025665f, 0.037415f, 0.054138f, 0.078491f,
+ 0.112915f, 0.160156f, 0.225464f, 0.308594f, 0.405029f, 0.506348f, 0.599121f, 0.678711f, 0.743164f, 0.791016f, 0.829590f, 0.859375f,
+ 0.881836f, 0.899414f, 0.913086f, 0.924805f, 0.934570f, 0.942383f, 0.948730f, 0.955078f, 0.958984f, 0.963379f, 0.966797f, 0.970215f,
+ 0.972168f, 0.974609f, 0.977051f, 0.979004f, 0.980957f, 0.981934f, 0.983398f, 0.984863f, 0.986328f, 0.987305f, 0.988281f, 0.989258f,
+ 0.990234f, 0.991211f, 0.991699f, 0.992188f, 0.993164f, 0.993652f, 0.994629f, 0.994629f, 0.995117f, 0.995605f, 0.995605f, 0.996094f,
+ 0.996582f, 0.997559f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.000985f, 0.004086f, 0.007362f, 0.011887f,
+ 0.018127f, 0.026199f, 0.036804f, 0.052002f, 0.072754f, 0.101318f, 0.140747f, 0.195190f, 0.266113f, 0.352539f, 0.448730f, 0.543945f,
+ 0.630371f, 0.702637f, 0.759277f, 0.803711f, 0.839355f, 0.865234f, 0.886719f, 0.903320f, 0.916504f, 0.927734f, 0.936523f, 0.944336f,
+ 0.950195f, 0.955566f, 0.959961f, 0.964355f, 0.967773f, 0.970215f, 0.973145f, 0.975586f, 0.978027f, 0.979004f, 0.980957f, 0.982910f,
+ 0.984375f, 0.985352f, 0.987305f, 0.987305f, 0.988770f, 0.990234f, 0.990234f, 0.991699f, 0.991699f, 0.993164f, 0.993164f, 0.993652f,
+ 0.994629f, 0.995117f, 0.995605f, 0.996094f, 0.996582f, 0.997070f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.998535f, 0.999023f,
+ 0.000829f, 0.002878f, 0.005596f, 0.009109f, 0.013359f, 0.019089f, 0.026901f, 0.036774f, 0.049347f, 0.067200f, 0.091736f, 0.125854f,
+ 0.171631f, 0.232544f, 0.308594f, 0.397461f, 0.491455f, 0.581055f, 0.659668f, 0.724609f, 0.775879f, 0.817383f, 0.848633f, 0.873047f,
+ 0.892090f, 0.907715f, 0.920410f, 0.930664f, 0.939453f, 0.946289f, 0.951660f, 0.957520f, 0.960938f, 0.965820f, 0.968750f, 0.972168f,
+ 0.974609f, 0.976562f, 0.978516f, 0.980469f, 0.981934f, 0.983887f, 0.984863f, 0.986328f, 0.986816f, 0.988770f, 0.989746f, 0.990234f,
+ 0.991211f, 0.991699f, 0.992676f, 0.993164f, 0.994141f, 0.994629f, 0.995117f, 0.995605f, 0.995605f, 0.996582f, 0.998535f, 0.998535f,
+ 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.000836f, 0.002403f, 0.004837f, 0.006950f, 0.010269f, 0.014679f, 0.019699f, 0.026291f,
+ 0.035431f, 0.046875f, 0.062744f, 0.084045f, 0.113403f, 0.152588f, 0.204712f, 0.271729f, 0.353271f, 0.443115f, 0.532715f, 0.617188f,
+ 0.688477f, 0.748047f, 0.793945f, 0.829102f, 0.857422f, 0.880371f, 0.898438f, 0.912598f, 0.924316f, 0.934082f, 0.941406f, 0.948242f,
+ 0.954590f, 0.959473f, 0.963379f, 0.967285f, 0.970215f, 0.973145f, 0.975586f, 0.977539f, 0.979980f, 0.981445f, 0.982910f, 0.984375f,
+ 0.985840f, 0.987305f, 0.988281f, 0.988770f, 0.990234f, 0.990723f, 0.991699f, 0.992676f, 0.993164f, 0.993652f, 0.994141f, 0.995117f,
+ 0.995605f, 0.996094f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.000698f, 0.002052f, 0.003618f, 0.005703f,
+ 0.008430f, 0.011230f, 0.015083f, 0.019821f, 0.026474f, 0.034393f, 0.044922f, 0.059204f, 0.077698f, 0.102661f, 0.136963f, 0.182373f,
+ 0.241089f, 0.314941f, 0.398926f, 0.489014f, 0.575195f, 0.652344f, 0.717285f, 0.769043f, 0.810059f, 0.842773f, 0.869141f, 0.888672f,
+ 0.904785f, 0.917969f, 0.928711f, 0.936523f, 0.945312f, 0.951660f, 0.957031f, 0.961426f, 0.964844f, 0.968750f, 0.971680f, 0.974121f,
+ 0.976562f, 0.979004f, 0.980469f, 0.982422f, 0.983887f, 0.985352f, 0.986816f, 0.987793f, 0.988770f, 0.990234f, 0.990723f, 0.991699f,
+ 0.992676f, 0.993164f, 0.994141f, 0.994141f, 0.994629f, 0.995605f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f,
+ 0.000244f, 0.001565f, 0.002975f, 0.004433f, 0.006596f, 0.008957f, 0.012215f, 0.015533f, 0.020294f, 0.026062f, 0.033722f, 0.042816f,
+ 0.055237f, 0.071960f, 0.094543f, 0.124023f, 0.164185f, 0.216309f, 0.281738f, 0.360352f, 0.446533f, 0.534180f, 0.615234f, 0.686523f,
+ 0.743652f, 0.790527f, 0.825684f, 0.855957f, 0.878418f, 0.895996f, 0.911133f, 0.923340f, 0.933105f, 0.941406f, 0.948242f, 0.953613f,
+ 0.959473f, 0.963379f, 0.966797f, 0.970703f, 0.973145f, 0.976074f, 0.978516f, 0.980469f, 0.982422f, 0.983398f, 0.984863f, 0.986328f,
+ 0.987305f, 0.989258f, 0.989746f, 0.990723f, 0.991699f, 0.992676f, 0.993164f, 0.993652f, 0.994141f, 0.995117f, 0.998047f, 0.998535f,
+ 0.998535f, 0.998535f, 0.998535f, 0.998047f, 0.000365f, 0.001394f, 0.002546f, 0.004055f, 0.005394f, 0.007465f, 0.009674f, 0.012070f,
+ 0.015556f, 0.019913f, 0.025696f, 0.032623f, 0.041046f, 0.052643f, 0.067383f, 0.087463f, 0.113708f, 0.148315f, 0.194946f, 0.254395f,
+ 0.326416f, 0.408691f, 0.495117f, 0.579102f, 0.654297f, 0.716797f, 0.768066f, 0.809570f, 0.843262f, 0.868652f, 0.888184f, 0.904785f,
+ 0.918457f, 0.929199f, 0.937500f, 0.945801f, 0.951660f, 0.957520f, 0.961914f, 0.965820f, 0.969238f, 0.972656f, 0.975098f, 0.978027f,
+ 0.979492f, 0.981934f, 0.983398f, 0.984863f, 0.986328f, 0.987793f, 0.989258f, 0.989746f, 0.991211f, 0.991211f, 0.992188f, 0.993164f,
+ 0.993652f, 0.994629f, 0.997559f, 0.998047f, 0.998047f, 0.998047f, 0.998047f, 0.998047f, 0.000596f, 0.001077f, 0.001882f, 0.003033f,
+ 0.004559f, 0.006241f, 0.007805f, 0.010002f, 0.012840f, 0.015900f, 0.019974f, 0.025131f, 0.031250f, 0.039337f, 0.049988f, 0.063843f,
+ 0.080933f, 0.105164f, 0.135986f, 0.176880f, 0.230103f, 0.296631f, 0.374268f, 0.459961f, 0.544434f, 0.623535f, 0.691895f, 0.748535f,
+ 0.792969f, 0.829102f, 0.857422f, 0.880371f, 0.897949f, 0.913086f, 0.924805f, 0.934570f, 0.942383f, 0.949219f, 0.955566f, 0.960938f,
+ 0.964844f, 0.968750f, 0.971191f, 0.974121f, 0.977051f, 0.979004f, 0.980957f, 0.982910f, 0.984863f, 0.985840f, 0.987305f, 0.989258f,
+ 0.989746f, 0.991211f, 0.991211f, 0.992676f, 0.993164f, 0.993652f, 0.997559f, 0.998047f, 0.998047f, 0.998047f, 0.998047f, 0.998047f,
+ 0.000243f, 0.001173f, 0.001889f, 0.002661f, 0.003933f, 0.005131f, 0.006496f, 0.008324f, 0.010574f, 0.013115f, 0.015839f, 0.019913f,
+ 0.024445f, 0.030609f, 0.037781f, 0.047333f, 0.059906f, 0.075928f, 0.097229f, 0.124939f, 0.161743f, 0.209595f, 0.271240f, 0.343994f,
+ 0.426758f, 0.511719f, 0.592773f, 0.666504f, 0.727051f, 0.776855f, 0.815918f, 0.847656f, 0.871582f, 0.892090f, 0.907715f, 0.920898f,
+ 0.931152f, 0.940918f, 0.947754f, 0.953613f, 0.958496f, 0.963867f, 0.967773f, 0.970703f, 0.974121f, 0.976074f, 0.979004f, 0.980469f,
+ 0.982910f, 0.984375f, 0.985840f, 0.987305f, 0.988770f, 0.990234f, 0.990234f, 0.992188f, 0.992188f, 0.993164f, 0.997070f, 0.997559f,
+ 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.000351f, 0.000842f, 0.001560f, 0.002363f, 0.003258f, 0.004131f, 0.005272f, 0.007179f,
+ 0.008682f, 0.010643f, 0.013016f, 0.016037f, 0.019516f, 0.024078f, 0.029602f, 0.036591f, 0.045044f, 0.056641f, 0.071350f, 0.090576f,
+ 0.116211f, 0.149414f, 0.193237f, 0.248779f, 0.317871f, 0.396973f, 0.481201f, 0.564453f, 0.640137f, 0.705566f, 0.759766f, 0.802734f,
+ 0.836914f, 0.863281f, 0.885742f, 0.902832f, 0.916992f, 0.927734f, 0.937012f, 0.945801f, 0.952637f, 0.958008f, 0.961914f, 0.966309f,
+ 0.970703f, 0.974121f, 0.976074f, 0.978516f, 0.980957f, 0.982910f, 0.984863f, 0.985840f, 0.987305f, 0.988281f, 0.989746f, 0.990723f,
+ 0.991211f, 0.992676f, 0.997070f, 0.997559f, 0.997070f, 0.997559f, 0.997559f, 0.997559f, 0.000000f, 0.000886f, 0.001405f, 0.001915f,
+ 0.002651f, 0.003870f, 0.004845f, 0.006035f, 0.006912f, 0.008812f, 0.010887f, 0.013229f, 0.016022f, 0.019196f, 0.023590f, 0.028992f,
+ 0.035248f, 0.043304f, 0.053711f, 0.066956f, 0.085083f, 0.107727f, 0.138428f, 0.178589f, 0.229980f, 0.293945f, 0.370117f, 0.453369f,
+ 0.537109f, 0.616699f, 0.685059f, 0.743164f, 0.790039f, 0.826660f, 0.856445f, 0.878906f, 0.897949f, 0.913574f, 0.925293f, 0.935547f,
+ 0.943848f, 0.951172f, 0.957031f, 0.961914f, 0.966797f, 0.970215f, 0.973145f, 0.976562f, 0.979004f, 0.980469f, 0.982910f, 0.984375f,
+ 0.985840f, 0.987305f, 0.988770f, 0.989746f, 0.991211f, 0.992188f, 0.996582f, 0.997070f, 0.997070f, 0.997070f, 0.997070f, 0.997070f,
+ 0.000104f, 0.000719f, 0.001065f, 0.001970f, 0.002544f, 0.003149f, 0.004230f, 0.005138f, 0.006119f, 0.007580f, 0.009201f, 0.010902f,
+ 0.013260f, 0.015526f, 0.019272f, 0.022858f, 0.027512f, 0.033569f, 0.041199f, 0.050873f, 0.063782f, 0.079895f, 0.101135f, 0.128906f,
+ 0.165771f, 0.213745f, 0.273193f, 0.345703f, 0.427002f, 0.511719f, 0.592773f, 0.666016f, 0.727051f, 0.776367f, 0.817871f, 0.848633f,
+ 0.875000f, 0.894531f, 0.909668f, 0.922852f, 0.934082f, 0.942383f, 0.949707f, 0.956055f, 0.961914f, 0.966309f, 0.970215f, 0.973145f,
+ 0.976562f, 0.978516f, 0.980957f, 0.982910f, 0.984375f, 0.986328f, 0.987305f, 0.988281f, 0.989746f, 0.991211f, 0.996582f, 0.997070f,
+ 0.997070f, 0.997070f, 0.997070f, 0.997070f, 0.000240f, 0.000686f, 0.001052f, 0.001375f, 0.002308f, 0.002735f, 0.003510f, 0.004269f,
+ 0.005173f, 0.006649f, 0.007442f, 0.009109f, 0.011246f, 0.012886f, 0.015732f, 0.018829f, 0.022354f, 0.026672f, 0.032867f, 0.039764f,
+ 0.048492f, 0.060455f, 0.075806f, 0.095276f, 0.121033f, 0.155273f, 0.199097f, 0.255859f, 0.324463f, 0.404053f, 0.488525f, 0.571289f,
+ 0.646484f, 0.711426f, 0.765625f, 0.808105f, 0.841797f, 0.869141f, 0.890137f, 0.907227f, 0.920898f, 0.931641f, 0.940918f, 0.948730f,
+ 0.955078f, 0.960449f, 0.965820f, 0.969727f, 0.972656f, 0.976562f, 0.978516f, 0.980957f, 0.982910f, 0.984863f, 0.986328f, 0.987793f,
+ 0.989746f, 0.990723f, 0.996094f, 0.996582f, 0.996582f, 0.996582f, 0.997070f, 0.997070f, 0.000244f, 0.000597f, 0.000939f, 0.001369f,
+ 0.001999f, 0.002329f, 0.003105f, 0.003786f, 0.004395f, 0.005413f, 0.006474f, 0.007793f, 0.009254f, 0.010971f, 0.012970f, 0.015526f,
+ 0.018112f, 0.022049f, 0.026581f, 0.031586f, 0.038666f, 0.046967f, 0.057617f, 0.071777f, 0.089783f, 0.113953f, 0.145264f, 0.186646f,
+ 0.239990f, 0.305908f, 0.383301f, 0.467285f, 0.551270f, 0.629883f, 0.697266f, 0.754883f, 0.799805f, 0.835938f, 0.864258f, 0.886719f,
+ 0.905273f, 0.918945f, 0.931152f, 0.940918f, 0.948242f, 0.955078f, 0.961426f, 0.965332f, 0.969727f, 0.973633f, 0.976074f, 0.979004f,
+ 0.980957f, 0.983398f, 0.984863f, 0.987305f, 0.988281f, 0.989258f, 0.996094f, 0.996094f, 0.996582f, 0.996582f, 0.996582f, 0.996582f,
+ 0.000000f, 0.000475f, 0.000891f, 0.001390f, 0.001730f, 0.002060f, 0.002501f, 0.003109f, 0.003836f, 0.004837f, 0.005852f, 0.006859f,
+ 0.007740f, 0.009216f, 0.010918f, 0.012863f, 0.014915f, 0.017731f, 0.021317f, 0.025482f, 0.030930f, 0.037262f, 0.044891f, 0.055115f,
+ 0.068298f, 0.085510f, 0.107910f, 0.137207f, 0.176025f, 0.226929f, 0.289551f, 0.364746f, 0.447998f, 0.532715f, 0.613770f, 0.685547f,
+ 0.744629f, 0.791992f, 0.830078f, 0.860352f, 0.884277f, 0.903320f, 0.917969f, 0.930176f, 0.939941f, 0.947754f, 0.954590f, 0.961426f,
+ 0.966309f, 0.970215f, 0.973145f, 0.976562f, 0.979492f, 0.981445f, 0.983398f, 0.985352f, 0.987793f, 0.988281f, 0.995605f, 0.996094f,
+ 0.996094f, 0.996582f, 0.996094f, 0.996094f, 0.000102f, 0.000243f, 0.000844f, 0.001124f, 0.001554f, 0.002077f, 0.002098f, 0.002682f,
+ 0.003357f, 0.004280f, 0.005035f, 0.005764f, 0.006805f, 0.007633f, 0.009354f, 0.010872f, 0.012665f, 0.015099f, 0.017258f, 0.020599f,
+ 0.024887f, 0.029495f, 0.035522f, 0.042999f, 0.053070f, 0.065125f, 0.081299f, 0.102661f, 0.130371f, 0.166992f, 0.215088f, 0.275635f,
+ 0.348877f, 0.431641f, 0.517578f, 0.600098f, 0.672852f, 0.735352f, 0.785645f, 0.826172f, 0.856934f, 0.881836f, 0.900879f, 0.916992f,
+ 0.930176f, 0.940430f, 0.947754f, 0.955078f, 0.960938f, 0.966309f, 0.969238f, 0.973633f, 0.977051f, 0.979492f, 0.981934f, 0.983887f,
+ 0.986328f, 0.987793f, 0.995605f, 0.996094f, 0.996094f, 0.996094f, 0.996094f, 0.996094f, 0.000241f, 0.000242f, 0.000823f, 0.000956f,
+ 0.001225f, 0.001549f, 0.002031f, 0.002613f, 0.003124f, 0.003574f, 0.004467f, 0.004955f, 0.005672f, 0.006752f, 0.007603f, 0.009186f,
+ 0.010704f, 0.012741f, 0.014366f, 0.017487f, 0.020142f, 0.024002f, 0.028915f, 0.034943f, 0.041656f, 0.050964f, 0.062622f, 0.077881f,
+ 0.097961f, 0.124207f, 0.158936f, 0.204590f, 0.263184f, 0.334961f, 0.416748f, 0.502930f, 0.587891f, 0.664062f, 0.728516f, 0.780762f,
+ 0.822266f, 0.854492f, 0.879395f, 0.900879f, 0.916504f, 0.928711f, 0.940430f, 0.948730f, 0.955566f, 0.961914f, 0.967285f, 0.970215f,
+ 0.974121f, 0.977539f, 0.979980f, 0.982422f, 0.984863f, 0.986816f, 0.994629f, 0.995605f, 0.995605f, 0.995605f, 0.995605f, 0.995605f,
+ 0.000000f, 0.000473f, 0.000607f, 0.000921f, 0.000957f, 0.001448f, 0.001884f, 0.002270f, 0.002703f, 0.002998f, 0.003862f, 0.004307f,
+ 0.005074f, 0.005665f, 0.006737f, 0.007851f, 0.009216f, 0.010735f, 0.012459f, 0.014572f, 0.016998f, 0.019821f, 0.023605f, 0.027969f,
+ 0.033783f, 0.040192f, 0.049286f, 0.060303f, 0.074829f, 0.093750f, 0.118774f, 0.152222f, 0.195801f, 0.252441f, 0.322754f, 0.404053f,
+ 0.491943f, 0.577637f, 0.655273f, 0.722168f, 0.776367f, 0.820312f, 0.854004f, 0.878906f, 0.900879f, 0.916992f, 0.929688f, 0.940430f,
+ 0.949707f, 0.956055f, 0.962402f, 0.967285f, 0.971191f, 0.975586f, 0.978516f, 0.980957f, 0.983398f, 0.985352f, 0.994141f, 0.995117f,
+ 0.995117f, 0.995605f, 0.995117f, 0.995605f, 0.000000f, 0.000444f, 0.000605f, 0.000649f, 0.000926f, 0.001096f, 0.001624f, 0.001669f,
+ 0.002373f, 0.002716f, 0.003231f, 0.003769f, 0.004395f, 0.005005f, 0.005878f, 0.006710f, 0.007793f, 0.008957f, 0.010712f, 0.012230f,
+ 0.014244f, 0.016693f, 0.019531f, 0.022827f, 0.027100f, 0.032318f, 0.038971f, 0.047302f, 0.058105f, 0.072021f, 0.089966f, 0.114319f,
+ 0.146362f, 0.188965f, 0.244019f, 0.312988f, 0.394287f, 0.482178f, 0.569824f, 0.650391f, 0.718262f, 0.774414f, 0.819336f, 0.853027f,
+ 0.880371f, 0.900879f, 0.917969f, 0.930664f, 0.940918f, 0.950684f, 0.957031f, 0.962891f, 0.968262f, 0.972656f, 0.976562f, 0.979004f,
+ 0.981934f, 0.984375f, 0.994141f, 0.994629f, 0.994629f, 0.995117f, 0.994629f, 0.995117f, 0.000000f, 0.000336f, 0.000601f, 0.000712f,
+ 0.000810f, 0.001174f, 0.001286f, 0.001618f, 0.002037f, 0.002592f, 0.002920f, 0.003223f, 0.003847f, 0.004463f, 0.005119f, 0.006020f,
+ 0.006783f, 0.007957f, 0.008888f, 0.010590f, 0.012230f, 0.013885f, 0.016220f, 0.019318f, 0.022278f, 0.026474f, 0.031403f, 0.037781f,
+ 0.046021f, 0.055969f, 0.069397f, 0.086975f, 0.110413f, 0.140991f, 0.182739f, 0.236694f, 0.304932f, 0.385986f, 0.475586f, 0.563965f,
+ 0.646484f, 0.716797f, 0.772461f, 0.818359f, 0.853027f, 0.880859f, 0.901855f, 0.918945f, 0.932129f, 0.942383f, 0.951172f, 0.958496f,
+ 0.964355f, 0.969238f, 0.973633f, 0.977051f, 0.979980f, 0.982910f, 0.993652f, 0.994141f, 0.994629f, 0.994141f, 0.994141f, 0.994629f,
+ 0.000000f, 0.000244f, 0.000418f, 0.000597f, 0.000600f, 0.001085f, 0.001236f, 0.001535f, 0.001970f, 0.002096f, 0.002354f, 0.002834f,
+ 0.003323f, 0.003822f, 0.004463f, 0.005146f, 0.005798f, 0.006859f, 0.007587f, 0.008827f, 0.009956f, 0.011833f, 0.013725f, 0.015945f,
+ 0.018585f, 0.021988f, 0.025665f, 0.030807f, 0.036774f, 0.044373f, 0.054108f, 0.067383f, 0.084229f, 0.106812f, 0.137207f, 0.177734f,
+ 0.230835f, 0.299072f, 0.380127f, 0.470215f, 0.560547f, 0.644531f, 0.715820f, 0.774414f, 0.820312f, 0.854980f, 0.882324f, 0.903809f,
+ 0.921387f, 0.933594f, 0.944824f, 0.952637f, 0.960449f, 0.965820f, 0.971191f, 0.974609f, 0.978027f, 0.981934f, 0.993164f, 0.994629f,
+ 0.994141f, 0.994141f, 0.994141f, 0.994141f, 0.000000f, 0.000244f, 0.000411f, 0.000589f, 0.000820f, 0.000729f, 0.001086f, 0.001301f,
+ 0.001677f, 0.001935f, 0.002312f, 0.002678f, 0.002846f, 0.003590f, 0.003914f, 0.004578f, 0.005020f, 0.005753f, 0.006706f, 0.007710f,
+ 0.008911f, 0.010155f, 0.011528f, 0.013504f, 0.015747f, 0.018036f, 0.021408f, 0.024994f, 0.029816f, 0.035858f, 0.043152f, 0.053009f,
+ 0.065491f, 0.082031f, 0.104065f, 0.133789f, 0.174072f, 0.226929f, 0.294434f, 0.376465f, 0.467773f, 0.560059f, 0.644531f, 0.717285f,
+ 0.777344f, 0.823242f, 0.857910f, 0.885742f, 0.906738f, 0.922852f, 0.936523f, 0.947266f, 0.955078f, 0.961426f, 0.967285f, 0.972656f,
+ 0.976562f, 0.979980f, 0.992676f, 0.993164f, 0.993652f, 0.993652f, 0.993652f, 0.993652f, 0.000000f, 0.000243f, 0.000243f, 0.000442f,
+ 0.000695f, 0.000759f, 0.000837f, 0.001089f, 0.001625f, 0.001702f, 0.002045f, 0.002176f, 0.002756f, 0.003063f, 0.003687f, 0.003893f,
+ 0.004456f, 0.005337f, 0.006062f, 0.006523f, 0.007572f, 0.008430f, 0.009880f, 0.011612f, 0.013237f, 0.015114f, 0.017487f, 0.020584f,
+ 0.024445f, 0.028931f, 0.034729f, 0.042023f, 0.051788f, 0.063843f, 0.079956f, 0.102295f, 0.131592f, 0.171021f, 0.223877f, 0.292236f,
+ 0.375000f, 0.468018f, 0.562012f, 0.648438f, 0.721191f, 0.781250f, 0.826660f, 0.862305f, 0.888672f, 0.909668f, 0.926270f, 0.938965f,
+ 0.949707f, 0.957520f, 0.964355f, 0.969727f, 0.974121f, 0.978027f, 0.992676f, 0.993164f, 0.993164f, 0.992676f, 0.993164f, 0.993164f,
+ 0.000000f, 0.000242f, 0.000242f, 0.000242f, 0.000564f, 0.000692f, 0.000826f, 0.001094f, 0.001280f, 0.001457f, 0.001673f, 0.002232f,
+ 0.002411f, 0.002789f, 0.003174f, 0.003649f, 0.003859f, 0.004349f, 0.004990f, 0.005898f, 0.006622f, 0.007496f, 0.008209f, 0.009583f,
+ 0.011284f, 0.013062f, 0.014763f, 0.017120f, 0.020020f, 0.023804f, 0.028412f, 0.033905f, 0.041016f, 0.050140f, 0.062469f, 0.078552f,
+ 0.100159f, 0.129272f, 0.169067f, 0.222290f, 0.291504f, 0.376465f, 0.470703f, 0.566406f, 0.653320f, 0.728027f, 0.786621f, 0.832031f,
+ 0.866699f, 0.893555f, 0.914062f, 0.929688f, 0.942383f, 0.952148f, 0.959961f, 0.966797f, 0.972168f, 0.976074f, 0.991211f, 0.992188f,
+ 0.992676f, 0.992188f, 0.992676f, 0.992676f, 0.000241f, 0.000241f, 0.000240f, 0.000242f, 0.000486f, 0.000637f, 0.000916f, 0.000933f,
+ 0.001003f, 0.001284f, 0.001584f, 0.001925f, 0.002134f, 0.002502f, 0.002731f, 0.003134f, 0.003435f, 0.004036f, 0.004379f, 0.005077f,
+ 0.005688f, 0.006557f, 0.007347f, 0.007942f, 0.009506f, 0.010712f, 0.012527f, 0.014603f, 0.016693f, 0.019592f, 0.023285f, 0.027512f,
+ 0.033173f, 0.040283f, 0.049347f, 0.061432f, 0.077271f, 0.098938f, 0.128052f, 0.168091f, 0.222168f, 0.292725f, 0.379150f, 0.476807f,
+ 0.573730f, 0.662598f, 0.735840f, 0.794434f, 0.839844f, 0.873535f, 0.898926f, 0.918945f, 0.934082f, 0.945312f, 0.955566f, 0.962402f,
+ 0.969238f, 0.974609f, 0.990723f, 0.991699f, 0.992188f, 0.992188f, 0.992188f, 0.992188f, 0.000000f, 0.000238f, 0.000240f, 0.000362f,
+ 0.000362f, 0.000521f, 0.000631f, 0.000909f, 0.000937f, 0.001249f, 0.001373f, 0.001693f, 0.001746f, 0.002184f, 0.002436f, 0.002680f,
+ 0.003094f, 0.003576f, 0.003828f, 0.004463f, 0.004990f, 0.005589f, 0.006439f, 0.006943f, 0.008217f, 0.009384f, 0.010719f, 0.012184f,
+ 0.014130f, 0.016373f, 0.019241f, 0.022675f, 0.027161f, 0.032379f, 0.039307f, 0.048645f, 0.060455f, 0.076416f, 0.097778f, 0.127441f,
+ 0.168213f, 0.223633f, 0.296387f, 0.385986f, 0.485107f, 0.583984f, 0.673340f, 0.746582f, 0.804199f, 0.848633f, 0.880371f, 0.905273f,
+ 0.923828f, 0.938477f, 0.949707f, 0.958984f, 0.965820f, 0.972656f, 0.990234f, 0.991211f, 0.991211f, 0.991211f, 0.991211f, 0.991211f,
+ 0.000000f, 0.000234f, 0.000238f, 0.000236f, 0.000360f, 0.000482f, 0.000614f, 0.000786f, 0.000900f, 0.001056f, 0.001336f, 0.001466f,
+ 0.001671f, 0.001907f, 0.002333f, 0.002546f, 0.002871f, 0.003067f, 0.003500f, 0.003813f, 0.004425f, 0.004574f, 0.005459f, 0.006092f,
+ 0.006660f, 0.007660f, 0.008987f, 0.010071f, 0.011841f, 0.013847f, 0.016022f, 0.018829f, 0.022339f, 0.026779f, 0.031677f, 0.038910f,
+ 0.047913f, 0.059601f, 0.075684f, 0.097290f, 0.127319f, 0.169189f, 0.226807f, 0.302490f, 0.394775f, 0.497314f, 0.598633f, 0.686523f,
+ 0.759766f, 0.814941f, 0.857422f, 0.888672f, 0.912109f, 0.930176f, 0.943359f, 0.954102f, 0.962402f, 0.968750f, 0.988770f, 0.990234f,
+ 0.990234f, 0.990234f, 0.991211f, 0.990723f, 0.000000f, 0.000036f, 0.000166f, 0.000357f, 0.000356f, 0.000478f, 0.000566f, 0.000638f,
+ 0.000893f, 0.001146f, 0.001242f, 0.001330f, 0.001502f, 0.001773f, 0.001918f, 0.002024f, 0.002501f, 0.002604f, 0.003067f, 0.003334f,
+ 0.003708f, 0.004044f, 0.004646f, 0.005268f, 0.006241f, 0.006931f, 0.007774f, 0.008911f, 0.010277f, 0.011475f, 0.013542f, 0.015732f,
+ 0.018417f, 0.022049f, 0.026154f, 0.031189f, 0.038269f, 0.047119f, 0.059265f, 0.075256f, 0.097534f, 0.128906f, 0.172119f, 0.231934f,
+ 0.311035f, 0.407715f, 0.513184f, 0.615723f, 0.703613f, 0.773926f, 0.827637f, 0.867188f, 0.897461f, 0.919434f, 0.936035f, 0.948730f,
+ 0.958984f, 0.966309f, 0.988770f, 0.989746f, 0.989746f, 0.990234f, 0.989746f, 0.989746f, 0.000000f, 0.000028f, 0.000093f, 0.000334f,
+ 0.000465f, 0.000472f, 0.000373f, 0.000685f, 0.000695f, 0.001027f, 0.001128f, 0.001155f, 0.001419f, 0.001435f, 0.001760f, 0.001850f,
+ 0.002241f, 0.002373f, 0.002604f, 0.002821f, 0.003334f, 0.003666f, 0.004139f, 0.004627f, 0.005207f, 0.005886f, 0.006596f, 0.007580f,
+ 0.008705f, 0.009911f, 0.011520f, 0.013237f, 0.015427f, 0.017944f, 0.021423f, 0.025497f, 0.030945f, 0.037537f, 0.046692f, 0.058624f,
+ 0.075317f, 0.098267f, 0.130493f, 0.176025f, 0.239136f, 0.323242f, 0.424561f, 0.533691f, 0.636230f, 0.723145f, 0.790039f, 0.841797f,
+ 0.880371f, 0.906738f, 0.926758f, 0.941406f, 0.953613f, 0.963379f, 0.987793f, 0.988770f, 0.988770f, 0.989258f, 0.989258f, 0.989258f,
+ 0.000000f, 0.000000f, 0.000047f, 0.000321f, 0.000332f, 0.000351f, 0.000470f, 0.000596f, 0.000655f, 0.000727f, 0.001008f, 0.001112f,
+ 0.001350f, 0.001379f, 0.001380f, 0.001751f, 0.002008f, 0.002151f, 0.002327f, 0.002548f, 0.002691f, 0.003056f, 0.003475f, 0.003925f,
+ 0.004749f, 0.005161f, 0.005863f, 0.006538f, 0.007153f, 0.008453f, 0.009789f, 0.010986f, 0.013168f, 0.015121f, 0.017563f, 0.020966f,
+ 0.025009f, 0.030151f, 0.037048f, 0.046570f, 0.058624f, 0.075623f, 0.099243f, 0.133667f, 0.181641f, 0.249756f, 0.338623f, 0.445312f,
+ 0.556641f, 0.659180f, 0.744141f, 0.808594f, 0.855957f, 0.890137f, 0.916992f, 0.934570f, 0.949219f, 0.959473f, 0.986816f, 0.987793f,
+ 0.987793f, 0.987793f, 0.987793f, 0.988281f, 0.000000f, 0.000000f, 0.000000f, 0.000244f, 0.000429f, 0.000440f, 0.000348f, 0.000592f,
+ 0.000606f, 0.000755f, 0.000690f, 0.000935f, 0.001172f, 0.001257f, 0.001368f, 0.001458f, 0.001786f, 0.001809f, 0.002060f, 0.002274f,
+ 0.002478f, 0.002642f, 0.002987f, 0.003435f, 0.003866f, 0.004337f, 0.005066f, 0.005409f, 0.006355f, 0.007111f, 0.008011f, 0.009392f,
+ 0.011032f, 0.012321f, 0.014717f, 0.017319f, 0.020432f, 0.024551f, 0.029953f, 0.036835f, 0.045929f, 0.058716f, 0.076416f, 0.101562f,
+ 0.137695f, 0.189453f, 0.262451f, 0.358154f, 0.470215f, 0.584961f, 0.686523f, 0.767578f, 0.828125f, 0.871582f, 0.903809f, 0.926270f,
+ 0.941895f, 0.956055f, 0.985352f, 0.986328f, 0.986816f, 0.986816f, 0.986816f, 0.986816f, 0.000000f, 0.000000f, 0.000000f, 0.000119f,
+ 0.000237f, 0.000314f, 0.000570f, 0.000575f, 0.000583f, 0.000632f, 0.000651f, 0.000789f, 0.000947f, 0.001097f, 0.001300f, 0.001320f,
+ 0.001384f, 0.001443f, 0.001641f, 0.001869f, 0.002047f, 0.002396f, 0.002634f, 0.003025f, 0.003412f, 0.003757f, 0.004238f, 0.004620f,
+ 0.005463f, 0.006168f, 0.007072f, 0.008080f, 0.009155f, 0.010590f, 0.012306f, 0.014175f, 0.016769f, 0.020081f, 0.023972f, 0.029495f,
+ 0.036560f, 0.045959f, 0.059265f, 0.078125f, 0.104797f, 0.143677f, 0.199951f, 0.279785f, 0.382812f, 0.500977f, 0.616699f, 0.716309f,
+ 0.791992f, 0.847168f, 0.887207f, 0.915527f, 0.936523f, 0.950684f, 0.984375f, 0.985352f, 0.986328f, 0.985840f, 0.986328f, 0.985840f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000205f, 0.000239f, 0.000299f, 0.000537f, 0.000574f, 0.000696f, 0.000583f, 0.000740f,
+ 0.000778f, 0.000867f, 0.001013f, 0.001257f, 0.001325f, 0.001277f, 0.001416f, 0.001718f, 0.001965f, 0.002079f, 0.002356f, 0.002577f,
+ 0.002771f, 0.003305f, 0.003693f, 0.004028f, 0.004593f, 0.005234f, 0.005905f, 0.006802f, 0.007698f, 0.008553f, 0.009995f, 0.011635f,
+ 0.013824f, 0.016174f, 0.019547f, 0.023544f, 0.029114f, 0.036377f, 0.046417f, 0.060211f, 0.080017f, 0.108643f, 0.151611f, 0.213379f,
+ 0.301758f, 0.414062f, 0.537598f, 0.653320f, 0.748047f, 0.817871f, 0.868164f, 0.903320f, 0.928711f, 0.945801f, 0.982910f, 0.983887f,
+ 0.984375f, 0.984375f, 0.984863f, 0.984375f, 0.000000f, 0.000000f, 0.000045f, 0.000105f, 0.000114f, 0.000340f, 0.000371f, 0.000501f,
+ 0.000639f, 0.000554f, 0.000687f, 0.000675f, 0.000711f, 0.000738f, 0.000824f, 0.001092f, 0.001040f, 0.001185f, 0.001212f, 0.001408f,
+ 0.001624f, 0.001813f, 0.001982f, 0.002182f, 0.002634f, 0.002748f, 0.003252f, 0.003540f, 0.004089f, 0.004505f, 0.005001f, 0.005657f,
+ 0.006500f, 0.007195f, 0.008286f, 0.009750f, 0.011208f, 0.013420f, 0.015762f, 0.019226f, 0.023209f, 0.029144f, 0.036591f, 0.047150f,
+ 0.061615f, 0.082947f, 0.114014f, 0.161621f, 0.231323f, 0.329834f, 0.451416f, 0.579590f, 0.692871f, 0.780273f, 0.844238f, 0.888184f,
+ 0.917969f, 0.939453f, 0.981445f, 0.982422f, 0.982910f, 0.982910f, 0.982910f, 0.982910f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000208f, 0.000311f, 0.000238f, 0.000337f, 0.000524f, 0.000617f, 0.000533f, 0.000675f, 0.000665f, 0.000776f, 0.000840f, 0.000819f,
+ 0.000902f, 0.001169f, 0.001130f, 0.001178f, 0.001382f, 0.001571f, 0.001941f, 0.001932f, 0.002138f, 0.002306f, 0.002586f, 0.002937f,
+ 0.003468f, 0.003740f, 0.004292f, 0.004704f, 0.005444f, 0.006081f, 0.007019f, 0.008255f, 0.009521f, 0.010796f, 0.012840f, 0.015503f,
+ 0.018784f, 0.023178f, 0.029129f, 0.036774f, 0.047699f, 0.063416f, 0.086548f, 0.121399f, 0.175293f, 0.254883f, 0.365234f, 0.496582f,
+ 0.626953f, 0.733398f, 0.813477f, 0.869629f, 0.906738f, 0.933105f, 0.979980f, 0.980957f, 0.981445f, 0.981445f, 0.980957f, 0.981445f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000208f, 0.000312f, 0.000236f, 0.000343f, 0.000475f, 0.000496f, 0.000528f,
+ 0.000659f, 0.000582f, 0.000685f, 0.000710f, 0.000761f, 0.000784f, 0.000941f, 0.001013f, 0.001117f, 0.001339f, 0.001500f, 0.001623f,
+ 0.001769f, 0.002039f, 0.002298f, 0.002565f, 0.002802f, 0.003119f, 0.003471f, 0.003857f, 0.004658f, 0.005177f, 0.005836f, 0.006752f,
+ 0.007324f, 0.008911f, 0.010422f, 0.012527f, 0.015373f, 0.018585f, 0.022964f, 0.029037f, 0.037231f, 0.049072f, 0.066345f, 0.091492f,
+ 0.131470f, 0.193359f, 0.285645f, 0.409912f, 0.548828f, 0.676758f, 0.776367f, 0.845703f, 0.893066f, 0.924805f, 0.978027f, 0.979492f,
+ 0.979492f, 0.979004f, 0.979492f, 0.979492f, 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000166f, 0.000228f, 0.000227f,
+ 0.000369f, 0.000337f, 0.000368f, 0.000452f, 0.000500f, 0.000547f, 0.000543f, 0.000575f, 0.000623f, 0.000723f, 0.000783f, 0.000874f,
+ 0.001141f, 0.001226f, 0.001279f, 0.001336f, 0.001499f, 0.001655f, 0.001922f, 0.002090f, 0.002453f, 0.002298f, 0.003139f, 0.003181f,
+ 0.003674f, 0.004166f, 0.004814f, 0.005447f, 0.006348f, 0.007179f, 0.008736f, 0.010406f, 0.012321f, 0.014984f, 0.018219f, 0.022934f,
+ 0.028824f, 0.037598f, 0.050476f, 0.069397f, 0.098694f, 0.144775f, 0.218018f, 0.325439f, 0.464111f, 0.607910f, 0.729492f, 0.817383f,
+ 0.876953f, 0.915527f, 0.976562f, 0.977539f, 0.977539f, 0.977051f, 0.977051f, 0.977539f, 0.000000f, 0.000000f, 0.000000f, 0.000122f,
+ 0.000122f, 0.000122f, 0.000154f, 0.000200f, 0.000267f, 0.000316f, 0.000324f, 0.000449f, 0.000319f, 0.000379f, 0.000515f, 0.000519f,
+ 0.000558f, 0.000628f, 0.000645f, 0.000690f, 0.000777f, 0.000940f, 0.001096f, 0.001204f, 0.001278f, 0.001485f, 0.001670f, 0.001929f,
+ 0.001961f, 0.002016f, 0.002367f, 0.002785f, 0.003025f, 0.003248f, 0.003805f, 0.004539f, 0.004845f, 0.005733f, 0.006851f, 0.008278f,
+ 0.010017f, 0.011841f, 0.014542f, 0.017807f, 0.022705f, 0.029190f, 0.038544f, 0.052612f, 0.073853f, 0.108093f, 0.162842f, 0.250977f,
+ 0.377930f, 0.529785f, 0.672363f, 0.782715f, 0.855957f, 0.904297f, 0.973145f, 0.974121f, 0.974609f, 0.975586f, 0.974609f, 0.975098f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000158f, 0.000121f, 0.000190f, 0.000238f, 0.000397f, 0.000354f,
+ 0.000364f, 0.000365f, 0.000440f, 0.000474f, 0.000509f, 0.000612f, 0.000611f, 0.000648f, 0.000804f, 0.000755f, 0.000943f, 0.001050f,
+ 0.001221f, 0.001340f, 0.001338f, 0.001443f, 0.001635f, 0.001822f, 0.002083f, 0.002226f, 0.002480f, 0.002682f, 0.003185f, 0.003609f,
+ 0.003948f, 0.005074f, 0.005558f, 0.006741f, 0.007904f, 0.009384f, 0.011360f, 0.014000f, 0.017883f, 0.022675f, 0.029648f, 0.039917f,
+ 0.055695f, 0.080261f, 0.120728f, 0.188354f, 0.296143f, 0.443848f, 0.603027f, 0.737793f, 0.831055f, 0.891113f, 0.970703f, 0.971680f,
+ 0.972168f, 0.972656f, 0.971680f, 0.972168f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000122f, 0.000121f, 0.000121f,
+ 0.000121f, 0.000251f, 0.000260f, 0.000278f, 0.000315f, 0.000334f, 0.000235f, 0.000357f, 0.000442f, 0.000513f, 0.000504f, 0.000598f,
+ 0.000556f, 0.000771f, 0.000831f, 0.000886f, 0.000977f, 0.001145f, 0.001105f, 0.001244f, 0.001281f, 0.001431f, 0.001544f, 0.001850f,
+ 0.001986f, 0.002131f, 0.002537f, 0.002737f, 0.003252f, 0.003826f, 0.004555f, 0.005184f, 0.006199f, 0.007195f, 0.009041f, 0.011337f,
+ 0.013878f, 0.017395f, 0.022552f, 0.030502f, 0.041962f, 0.059875f, 0.089111f, 0.139404f, 0.224609f, 0.357910f, 0.524902f, 0.684082f,
+ 0.800781f, 0.875977f, 0.967773f, 0.968750f, 0.968262f, 0.968750f, 0.969238f, 0.969238f, 0.000000f, 0.000000f, 0.000122f, 0.000122f,
+ 0.000122f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000095f, 0.000081f, 0.000217f, 0.000149f, 0.000204f, 0.000212f, 0.000338f,
+ 0.000345f, 0.000348f, 0.000456f, 0.000463f, 0.000495f, 0.000570f, 0.000583f, 0.000748f, 0.000799f, 0.000731f, 0.000965f, 0.001041f,
+ 0.001071f, 0.001210f, 0.001318f, 0.001238f, 0.001410f, 0.001631f, 0.001932f, 0.002327f, 0.002577f, 0.003057f, 0.003452f, 0.003956f,
+ 0.004639f, 0.005714f, 0.006817f, 0.008446f, 0.010605f, 0.013443f, 0.017319f, 0.022964f, 0.031021f, 0.044281f, 0.065857f, 0.102112f,
+ 0.166504f, 0.277344f, 0.439941f, 0.617188f, 0.762207f, 0.856445f, 0.963379f, 0.964355f, 0.965332f, 0.964844f, 0.965332f, 0.965332f,
+ 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000107f, 0.000091f, 0.000161f,
+ 0.000119f, 0.000184f, 0.000266f, 0.000284f, 0.000314f, 0.000319f, 0.000334f, 0.000344f, 0.000565f, 0.000455f, 0.000488f, 0.000667f,
+ 0.000710f, 0.000713f, 0.000787f, 0.000755f, 0.000849f, 0.000972f, 0.001097f, 0.001286f, 0.001427f, 0.001556f, 0.001667f, 0.001687f,
+ 0.002155f, 0.002369f, 0.002674f, 0.003086f, 0.003710f, 0.004536f, 0.005585f, 0.006783f, 0.007957f, 0.010262f, 0.013115f, 0.017212f,
+ 0.023102f, 0.032715f, 0.047943f, 0.074158f, 0.121155f, 0.207520f, 0.353027f, 0.541504f, 0.715332f, 0.834473f, 0.959473f, 0.960449f,
+ 0.960938f, 0.960938f, 0.960938f, 0.961426f, 0.000000f, 0.000000f, 0.000122f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000121f,
+ 0.000120f, 0.000120f, 0.000103f, 0.000089f, 0.000077f, 0.000080f, 0.000121f, 0.000218f, 0.000209f, 0.000245f, 0.000303f, 0.000316f,
+ 0.000388f, 0.000341f, 0.000549f, 0.000594f, 0.000604f, 0.000679f, 0.000625f, 0.000628f, 0.000795f, 0.000883f, 0.000857f, 0.000991f,
+ 0.001166f, 0.000955f, 0.001194f, 0.001347f, 0.001548f, 0.001804f, 0.002048f, 0.002388f, 0.002911f, 0.003130f, 0.003933f, 0.004845f,
+ 0.006031f, 0.007385f, 0.009705f, 0.012688f, 0.017044f, 0.023788f, 0.034882f, 0.053284f, 0.086670f, 0.151123f, 0.271484f, 0.457031f,
+ 0.658203f, 0.805176f, 0.954102f, 0.955078f, 0.956055f, 0.956055f, 0.956055f, 0.955566f, 0.000000f, 0.000122f, 0.000121f, 0.000121f,
+ 0.000121f, 0.000121f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000116f, 0.000101f, 0.000088f, 0.000077f, 0.000131f, 0.000071f,
+ 0.000146f, 0.000200f, 0.000237f, 0.000270f, 0.000289f, 0.000302f, 0.000311f, 0.000441f, 0.000396f, 0.000588f, 0.000630f, 0.000570f,
+ 0.000575f, 0.000537f, 0.000589f, 0.000750f, 0.000721f, 0.001048f, 0.001122f, 0.000951f, 0.001243f, 0.001346f, 0.001703f, 0.001592f,
+ 0.001880f, 0.002340f, 0.002804f, 0.003637f, 0.004356f, 0.005329f, 0.006805f, 0.009094f, 0.012566f, 0.017181f, 0.025040f, 0.038147f,
+ 0.061249f, 0.107788f, 0.200195f, 0.369629f, 0.587891f, 0.771973f, 0.948242f, 0.949707f, 0.950195f, 0.949707f, 0.950195f, 0.950195f,
+ 0.000000f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000120f, 0.000120f, 0.000120f, 0.000120f, 0.000119f, 0.000119f, 0.000114f,
+ 0.000101f, 0.000088f, 0.000079f, 0.000070f, 0.000063f, 0.000136f, 0.000136f, 0.000183f, 0.000207f, 0.000277f, 0.000271f, 0.000291f,
+ 0.000369f, 0.000344f, 0.000494f, 0.000459f, 0.000515f, 0.000509f, 0.000532f, 0.000504f, 0.000716f, 0.000589f, 0.000691f, 0.000902f,
+ 0.000972f, 0.000968f, 0.001067f, 0.001483f, 0.001780f, 0.001652f, 0.002090f, 0.002602f, 0.003113f, 0.003738f, 0.004738f, 0.006420f,
+ 0.008522f, 0.012100f, 0.017334f, 0.026489f, 0.042786f, 0.074524f, 0.142578f, 0.283936f, 0.509277f, 0.729492f, 0.940918f, 0.941895f,
+ 0.942383f, 0.942383f, 0.942383f, 0.942871f, 0.000122f, 0.000121f, 0.000121f, 0.000120f, 0.000120f, 0.000120f, 0.000119f, 0.000119f,
+ 0.000119f, 0.000118f, 0.000118f, 0.000118f, 0.000116f, 0.000102f, 0.000090f, 0.000081f, 0.000091f, 0.000066f, 0.000059f, 0.000110f,
+ 0.000109f, 0.000155f, 0.000184f, 0.000227f, 0.000297f, 0.000333f, 0.000355f, 0.000349f, 0.000344f, 0.000421f, 0.000459f, 0.000561f,
+ 0.000600f, 0.000563f, 0.000630f, 0.000563f, 0.000682f, 0.000737f, 0.000892f, 0.001037f, 0.001026f, 0.001163f, 0.001743f, 0.001782f,
+ 0.002117f, 0.002573f, 0.003389f, 0.004429f, 0.005871f, 0.007942f, 0.011841f, 0.018066f, 0.029190f, 0.050842f, 0.098511f, 0.207397f,
+ 0.422363f, 0.677734f, 0.932129f, 0.933594f, 0.933594f, 0.934082f, 0.934082f, 0.934082f, 0.000000f, 0.000121f, 0.000120f, 0.000119f,
+ 0.000119f, 0.000119f, 0.000118f, 0.000118f, 0.000118f, 0.000117f, 0.000117f, 0.000117f, 0.000117f, 0.000116f, 0.000104f, 0.000093f,
+ 0.000084f, 0.000076f, 0.000069f, 0.000091f, 0.000057f, 0.000051f, 0.000112f, 0.000120f, 0.000179f, 0.000232f, 0.000225f, 0.000283f,
+ 0.000301f, 0.000308f, 0.000353f, 0.000437f, 0.000395f, 0.000523f, 0.000486f, 0.000504f, 0.000469f, 0.000614f, 0.000581f, 0.000755f,
+ 0.000789f, 0.001121f, 0.000981f, 0.001218f, 0.001565f, 0.001795f, 0.002296f, 0.002958f, 0.003866f, 0.005329f, 0.007675f, 0.011658f,
+ 0.019043f, 0.033478f, 0.065430f, 0.144043f, 0.331299f, 0.613770f, 0.921387f, 0.922852f, 0.923340f, 0.923340f, 0.923340f, 0.923340f,
+ 0.000000f, 0.000000f, 0.000119f, 0.000118f, 0.000118f, 0.000117f, 0.000116f, 0.000116f, 0.000116f, 0.000116f, 0.000115f, 0.000115f,
+ 0.000115f, 0.000115f, 0.000114f, 0.000108f, 0.000097f, 0.000087f, 0.000079f, 0.000072f, 0.000065f, 0.000060f, 0.000094f, 0.000050f,
+ 0.000104f, 0.000104f, 0.000121f, 0.000164f, 0.000195f, 0.000247f, 0.000265f, 0.000328f, 0.000290f, 0.000355f, 0.000395f, 0.000356f,
+ 0.000361f, 0.000459f, 0.000470f, 0.000515f, 0.000580f, 0.000624f, 0.000751f, 0.000964f, 0.001105f, 0.001279f, 0.001413f, 0.001823f,
+ 0.002441f, 0.003407f, 0.004852f, 0.007210f, 0.011803f, 0.021225f, 0.041473f, 0.095032f, 0.244019f, 0.537598f, 0.907715f, 0.910156f,
+ 0.910156f, 0.909180f, 0.909668f, 0.911133f, 0.000120f, 0.000118f, 0.000117f, 0.000116f, 0.000114f, 0.000114f, 0.000114f, 0.000113f,
+ 0.000113f, 0.000112f, 0.000112f, 0.000112f, 0.000111f, 0.000112f, 0.000111f, 0.000111f, 0.000111f, 0.000101f, 0.000093f, 0.000084f,
+ 0.000077f, 0.000070f, 0.000064f, 0.000059f, 0.000074f, 0.000079f, 0.000059f, 0.000087f, 0.000097f, 0.000128f, 0.000185f, 0.000213f,
+ 0.000265f, 0.000235f, 0.000239f, 0.000288f, 0.000299f, 0.000371f, 0.000341f, 0.000369f, 0.000460f, 0.000446f, 0.000490f, 0.000602f,
+ 0.000694f, 0.000904f, 0.001012f, 0.001234f, 0.001544f, 0.002096f, 0.002989f, 0.004299f, 0.006840f, 0.012383f, 0.024948f, 0.059204f,
+ 0.166626f, 0.452637f, 0.892578f, 0.894043f, 0.894043f, 0.894531f, 0.894531f, 0.894043f, 0.000115f, 0.000107f, 0.000108f, 0.000111f,
+ 0.000108f, 0.000109f, 0.000108f, 0.000108f, 0.000108f, 0.000107f, 0.000108f, 0.000107f, 0.000107f, 0.000106f, 0.000107f, 0.000107f,
+ 0.000106f, 0.000107f, 0.000106f, 0.000097f, 0.000090f, 0.000082f, 0.000075f, 0.000069f, 0.000063f, 0.000058f, 0.000053f, 0.000070f,
+ 0.000073f, 0.000085f, 0.000077f, 0.000088f, 0.000136f, 0.000168f, 0.000190f, 0.000204f, 0.000199f, 0.000252f, 0.000233f, 0.000270f,
+ 0.000325f, 0.000295f, 0.000348f, 0.000383f, 0.000435f, 0.000534f, 0.000581f, 0.000803f, 0.001004f, 0.001330f, 0.001812f, 0.002489f,
+ 0.003944f, 0.006832f, 0.013748f, 0.033997f, 0.104858f, 0.356689f, 0.873047f, 0.873047f, 0.875000f, 0.874023f, 0.874023f, 0.874023f,
+ 0.000000f, 0.000071f, 0.000063f, 0.000094f, 0.000092f, 0.000094f, 0.000093f, 0.000098f, 0.000098f, 0.000098f, 0.000098f, 0.000099f,
+ 0.000098f, 0.000099f, 0.000099f, 0.000099f, 0.000099f, 0.000099f, 0.000099f, 0.000100f, 0.000100f, 0.000094f, 0.000087f, 0.000080f,
+ 0.000074f, 0.000068f, 0.000062f, 0.000058f, 0.000053f, 0.000049f, 0.000059f, 0.000059f, 0.000045f, 0.000078f, 0.000082f, 0.000118f,
+ 0.000155f, 0.000160f, 0.000174f, 0.000180f, 0.000226f, 0.000213f, 0.000248f, 0.000258f, 0.000288f, 0.000352f, 0.000396f, 0.000465f,
+ 0.000566f, 0.000789f, 0.000941f, 0.001343f, 0.002199f, 0.003616f, 0.006912f, 0.017380f, 0.058960f, 0.259521f, 0.847656f, 0.849121f,
+ 0.850586f, 0.850098f, 0.849121f, 0.850586f, 0.000000f, 0.000000f, 0.000019f, 0.000044f, 0.000048f, 0.000061f, 0.000071f, 0.000073f,
+ 0.000076f, 0.000079f, 0.000079f, 0.000082f, 0.000082f, 0.000082f, 0.000085f, 0.000086f, 0.000087f, 0.000086f, 0.000088f, 0.000087f,
+ 0.000089f, 0.000089f, 0.000089f, 0.000090f, 0.000084f, 0.000078f, 0.000072f, 0.000067f, 0.000062f, 0.000057f, 0.000052f, 0.000049f,
+ 0.000045f, 0.000041f, 0.000038f, 0.000040f, 0.000062f, 0.000092f, 0.000100f, 0.000121f, 0.000144f, 0.000133f, 0.000137f, 0.000170f,
+ 0.000181f, 0.000168f, 0.000215f, 0.000286f, 0.000327f, 0.000397f, 0.000504f, 0.000738f, 0.001039f, 0.001729f, 0.003317f, 0.007721f,
+ 0.028458f, 0.166626f, 0.815430f, 0.818359f, 0.818359f, 0.817383f, 0.818848f, 0.818359f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000008f, 0.000016f, 0.000031f, 0.000035f, 0.000048f, 0.000050f, 0.000053f, 0.000058f, 0.000059f,
+ 0.000063f, 0.000064f, 0.000067f, 0.000067f, 0.000070f, 0.000071f, 0.000072f, 0.000073f, 0.000075f, 0.000075f, 0.000076f, 0.000075f,
+ 0.000069f, 0.000064f, 0.000060f, 0.000055f, 0.000051f, 0.000047f, 0.000043f, 0.000040f, 0.000037f, 0.000034f, 0.000040f, 0.000041f,
+ 0.000054f, 0.000069f, 0.000096f, 0.000111f, 0.000109f, 0.000113f, 0.000142f, 0.000136f, 0.000158f, 0.000196f, 0.000237f, 0.000349f,
+ 0.000423f, 0.000744f, 0.001380f, 0.003214f, 0.011124f, 0.088135f, 0.777344f, 0.779297f, 0.780273f, 0.779785f, 0.779785f, 0.779785f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000003f, 0.000007f, 0.000021f, 0.000023f, 0.000031f, 0.000034f, 0.000038f, 0.000041f, 0.000043f, 0.000047f,
+ 0.000049f, 0.000050f, 0.000053f, 0.000055f, 0.000056f, 0.000057f, 0.000059f, 0.000060f, 0.000055f, 0.000051f, 0.000048f, 0.000044f,
+ 0.000041f, 0.000038f, 0.000035f, 0.000032f, 0.000029f, 0.000028f, 0.000028f, 0.000037f, 0.000044f, 0.000064f, 0.000078f, 0.000072f,
+ 0.000089f, 0.000098f, 0.000104f, 0.000146f, 0.000200f, 0.000272f, 0.000479f, 0.001077f, 0.003733f, 0.033752f, 0.729492f, 0.730957f,
+ 0.732422f, 0.731934f, 0.732422f, 0.732422f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000002f, 0.000006f, 0.000009f, 0.000013f, 0.000019f, 0.000021f, 0.000025f, 0.000027f, 0.000030f,
+ 0.000033f, 0.000034f, 0.000037f, 0.000039f, 0.000041f, 0.000039f, 0.000036f, 0.000033f, 0.000031f, 0.000028f, 0.000026f, 0.000024f,
+ 0.000021f, 0.000019f, 0.000017f, 0.000023f, 0.000033f, 0.000041f, 0.000043f, 0.000058f, 0.000061f, 0.000081f, 0.000121f, 0.000248f,
+ 0.000821f, 0.008255f, 0.673340f, 0.674805f, 0.674316f, 0.674805f, 0.674805f, 0.673828f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000004f, 0.000006f, 0.000010f, 0.000013f,
+ 0.000015f, 0.000017f, 0.000020f, 0.000022f, 0.000021f, 0.000019f, 0.000017f, 0.000015f, 0.000013f, 0.000012f, 0.000010f, 0.000011f,
+ 0.000016f, 0.000019f, 0.000019f, 0.000036f, 0.000090f, 0.000897f, 0.606934f, 0.609863f, 0.609375f, 0.609863f, 0.609863f, 0.610352f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000001f, 0.000003f, 0.000006f, 0.000005f, 0.000004f, 0.000003f, 0.000004f, 0.000008f, 0.534668f, 0.536621f,
+ 0.537109f, 0.537109f, 0.536621f, 0.536621f,
+ },
+ {
+ 0.149292f, 0.432373f, 0.614258f, 0.719238f, 0.784180f, 0.826660f, 0.856934f, 0.879883f, 0.896484f, 0.909180f, 0.919922f, 0.928711f,
+ 0.936035f, 0.942383f, 0.947266f, 0.952148f, 0.956055f, 0.959473f, 0.962891f, 0.965820f, 0.968262f, 0.970703f, 0.972656f, 0.974609f,
+ 0.976562f, 0.978027f, 0.979492f, 0.980469f, 0.981934f, 0.983398f, 0.984863f, 0.985352f, 0.986328f, 0.987305f, 0.988281f, 0.989258f,
+ 0.989746f, 0.990234f, 0.990723f, 0.991699f, 0.992676f, 0.993164f, 0.993652f, 0.993652f, 0.994629f, 0.995117f, 0.995117f, 0.996094f,
+ 0.996582f, 0.997070f, 0.997070f, 0.997070f, 0.998047f, 0.998047f, 0.998535f, 0.998535f, 0.999023f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999512f, 0.999512f, 0.999512f, 0.999023f, 0.040161f, 0.161255f, 0.324951f, 0.486572f, 0.612305f, 0.704590f, 0.767090f, 0.811523f,
+ 0.844238f, 0.868652f, 0.887695f, 0.902344f, 0.913574f, 0.924316f, 0.932129f, 0.937988f, 0.944336f, 0.949707f, 0.954102f, 0.957520f,
+ 0.960938f, 0.964355f, 0.966797f, 0.969727f, 0.971191f, 0.973633f, 0.975586f, 0.977539f, 0.979004f, 0.980469f, 0.981445f, 0.982910f,
+ 0.983887f, 0.985352f, 0.985840f, 0.987305f, 0.987793f, 0.988770f, 0.989258f, 0.990234f, 0.991211f, 0.992188f, 0.992676f, 0.993164f,
+ 0.993164f, 0.993652f, 0.994141f, 0.995117f, 0.995605f, 0.996094f, 0.996582f, 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.998535f,
+ 0.999023f, 0.999023f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999023f, 0.017395f, 0.068542f, 0.149292f, 0.262451f,
+ 0.392822f, 0.518066f, 0.621582f, 0.700195f, 0.759766f, 0.803711f, 0.836426f, 0.862305f, 0.880859f, 0.896484f, 0.909668f, 0.919434f,
+ 0.929199f, 0.935547f, 0.941895f, 0.947754f, 0.952637f, 0.956055f, 0.959961f, 0.963867f, 0.965820f, 0.968750f, 0.970703f, 0.973145f,
+ 0.975098f, 0.977051f, 0.979004f, 0.979980f, 0.981934f, 0.983398f, 0.983887f, 0.984863f, 0.985840f, 0.986816f, 0.987793f, 0.989258f,
+ 0.989746f, 0.990234f, 0.991211f, 0.991699f, 0.992188f, 0.992676f, 0.993652f, 0.994141f, 0.994629f, 0.995605f, 0.996094f, 0.996094f,
+ 0.996582f, 0.997070f, 0.997559f, 0.997559f, 0.998047f, 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999512f, 0.999023f,
+ 0.009125f, 0.035492f, 0.075806f, 0.135864f, 0.219971f, 0.324707f, 0.437012f, 0.543457f, 0.633789f, 0.704102f, 0.758789f, 0.802246f,
+ 0.833496f, 0.857910f, 0.878418f, 0.894043f, 0.906738f, 0.917480f, 0.925781f, 0.933594f, 0.940918f, 0.946777f, 0.951172f, 0.954590f,
+ 0.959473f, 0.962891f, 0.965820f, 0.968262f, 0.971191f, 0.973145f, 0.975098f, 0.976562f, 0.978516f, 0.979980f, 0.981445f, 0.982422f,
+ 0.983887f, 0.985840f, 0.986328f, 0.987305f, 0.988281f, 0.988770f, 0.989746f, 0.990234f, 0.991699f, 0.992188f, 0.992676f, 0.993652f,
+ 0.994141f, 0.994629f, 0.995117f, 0.995605f, 0.996094f, 0.996094f, 0.996582f, 0.997559f, 0.997559f, 0.998047f, 0.999023f, 0.999023f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.005848f, 0.021225f, 0.043640f, 0.076782f, 0.124084f, 0.189575f, 0.274414f, 0.372559f,
+ 0.473633f, 0.567383f, 0.646973f, 0.711426f, 0.761230f, 0.801758f, 0.833496f, 0.857422f, 0.876953f, 0.893066f, 0.905273f, 0.916504f,
+ 0.925293f, 0.932617f, 0.939941f, 0.945801f, 0.950684f, 0.955566f, 0.958984f, 0.962402f, 0.965820f, 0.968262f, 0.970703f, 0.972656f,
+ 0.975098f, 0.977051f, 0.978516f, 0.980469f, 0.981934f, 0.982422f, 0.983887f, 0.985840f, 0.986328f, 0.987305f, 0.988281f, 0.989258f,
+ 0.989746f, 0.990723f, 0.991211f, 0.992188f, 0.993164f, 0.993652f, 0.994629f, 0.995117f, 0.995117f, 0.996094f, 0.996094f, 0.997070f,
+ 0.997559f, 0.997559f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.998535f, 0.998535f, 0.003937f, 0.014107f, 0.027664f, 0.047211f,
+ 0.075195f, 0.113953f, 0.166748f, 0.236328f, 0.320312f, 0.412354f, 0.504395f, 0.589844f, 0.661621f, 0.719727f, 0.768066f, 0.805664f,
+ 0.834961f, 0.858398f, 0.877441f, 0.893066f, 0.906738f, 0.916992f, 0.926270f, 0.933105f, 0.940430f, 0.946289f, 0.951172f, 0.955566f,
+ 0.959473f, 0.962891f, 0.965820f, 0.968262f, 0.970703f, 0.973145f, 0.975098f, 0.977051f, 0.979004f, 0.980469f, 0.981934f, 0.983398f,
+ 0.984375f, 0.985840f, 0.986328f, 0.987305f, 0.988770f, 0.989746f, 0.990723f, 0.991211f, 0.992188f, 0.992676f, 0.993652f, 0.994629f,
+ 0.994629f, 0.995117f, 0.995605f, 0.995605f, 0.996582f, 0.997070f, 0.998535f, 0.999023f, 0.999023f, 0.999023f, 0.998535f, 0.998535f,
+ 0.002962f, 0.009674f, 0.019348f, 0.031708f, 0.049255f, 0.072754f, 0.105164f, 0.149048f, 0.206665f, 0.278076f, 0.361572f, 0.448730f,
+ 0.534668f, 0.611816f, 0.677734f, 0.730957f, 0.775879f, 0.809570f, 0.837891f, 0.861328f, 0.879395f, 0.894531f, 0.907227f, 0.916992f,
+ 0.926270f, 0.934082f, 0.940918f, 0.946289f, 0.951172f, 0.956055f, 0.959473f, 0.962891f, 0.966797f, 0.969238f, 0.971191f, 0.973633f,
+ 0.976074f, 0.977539f, 0.979492f, 0.980957f, 0.982422f, 0.983398f, 0.984863f, 0.986328f, 0.986816f, 0.988281f, 0.989746f, 0.989746f,
+ 0.991211f, 0.991699f, 0.992676f, 0.993164f, 0.994141f, 0.994629f, 0.994629f, 0.995605f, 0.996094f, 0.997070f, 0.998535f, 0.999023f,
+ 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.001900f, 0.007225f, 0.013733f, 0.022552f, 0.033661f, 0.049164f, 0.070374f, 0.097534f,
+ 0.135132f, 0.183350f, 0.244507f, 0.317871f, 0.400146f, 0.483643f, 0.562988f, 0.633301f, 0.693848f, 0.743652f, 0.784180f, 0.816895f,
+ 0.842773f, 0.865234f, 0.882812f, 0.896973f, 0.908691f, 0.919434f, 0.927734f, 0.935547f, 0.942383f, 0.947266f, 0.952637f, 0.957031f,
+ 0.960938f, 0.964355f, 0.967285f, 0.969727f, 0.971680f, 0.974609f, 0.976074f, 0.978027f, 0.979980f, 0.981445f, 0.982910f, 0.984375f,
+ 0.985840f, 0.986328f, 0.988281f, 0.988770f, 0.989746f, 0.990723f, 0.991699f, 0.992188f, 0.993164f, 0.993652f, 0.994629f, 0.995117f,
+ 0.995605f, 0.996094f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998047f, 0.001921f, 0.005543f, 0.010223f, 0.016312f,
+ 0.024918f, 0.035217f, 0.049164f, 0.067017f, 0.091125f, 0.122986f, 0.164673f, 0.217896f, 0.282471f, 0.356934f, 0.436768f, 0.516602f,
+ 0.590820f, 0.656250f, 0.711426f, 0.757812f, 0.794922f, 0.825684f, 0.850098f, 0.870605f, 0.885742f, 0.900879f, 0.912109f, 0.921387f,
+ 0.929688f, 0.937500f, 0.943848f, 0.949219f, 0.953125f, 0.958496f, 0.961426f, 0.964844f, 0.967773f, 0.970703f, 0.973145f, 0.975098f,
+ 0.977539f, 0.979004f, 0.980957f, 0.982422f, 0.983887f, 0.985352f, 0.986328f, 0.987793f, 0.988770f, 0.989258f, 0.990723f, 0.991211f,
+ 0.992188f, 0.993164f, 0.993652f, 0.994141f, 0.994629f, 0.995117f, 0.998047f, 0.998535f, 0.998535f, 0.998535f, 0.998047f, 0.998047f,
+ 0.001360f, 0.004257f, 0.007988f, 0.013092f, 0.018753f, 0.026352f, 0.035645f, 0.048096f, 0.064270f, 0.085449f, 0.113770f, 0.149292f,
+ 0.195190f, 0.251953f, 0.320557f, 0.395020f, 0.474121f, 0.549316f, 0.618652f, 0.678223f, 0.729492f, 0.770996f, 0.805176f, 0.833496f,
+ 0.855957f, 0.875977f, 0.891113f, 0.904785f, 0.915039f, 0.924316f, 0.933105f, 0.939453f, 0.945312f, 0.950684f, 0.955078f, 0.959473f,
+ 0.962891f, 0.966309f, 0.969727f, 0.972168f, 0.974121f, 0.976562f, 0.978516f, 0.979980f, 0.981934f, 0.983398f, 0.984375f, 0.986328f,
+ 0.986816f, 0.988281f, 0.989746f, 0.990234f, 0.991699f, 0.992188f, 0.992676f, 0.994141f, 0.994141f, 0.994629f, 0.998047f, 0.998047f,
+ 0.998535f, 0.998047f, 0.998047f, 0.998047f, 0.001075f, 0.003492f, 0.006275f, 0.010223f, 0.014473f, 0.019821f, 0.026581f, 0.035492f,
+ 0.046967f, 0.061829f, 0.080750f, 0.105164f, 0.136475f, 0.177246f, 0.227783f, 0.288818f, 0.358154f, 0.433594f, 0.509277f, 0.581543f,
+ 0.645508f, 0.701172f, 0.747070f, 0.783691f, 0.817383f, 0.842773f, 0.864258f, 0.881836f, 0.896484f, 0.908691f, 0.918945f, 0.928223f,
+ 0.935547f, 0.941895f, 0.948730f, 0.952637f, 0.957031f, 0.962402f, 0.964844f, 0.967773f, 0.970703f, 0.973633f, 0.975586f, 0.977539f,
+ 0.979492f, 0.981445f, 0.982910f, 0.984375f, 0.985840f, 0.986816f, 0.988281f, 0.988770f, 0.990234f, 0.991211f, 0.992188f, 0.992676f,
+ 0.993164f, 0.994141f, 0.997559f, 0.997559f, 0.998047f, 0.997559f, 0.997559f, 0.998047f, 0.000967f, 0.002928f, 0.005283f, 0.007759f,
+ 0.011612f, 0.015823f, 0.020966f, 0.027802f, 0.035461f, 0.045959f, 0.059235f, 0.075928f, 0.097778f, 0.126099f, 0.162598f, 0.207153f,
+ 0.261963f, 0.326416f, 0.398193f, 0.471680f, 0.543945f, 0.612305f, 0.671875f, 0.722656f, 0.765137f, 0.799805f, 0.828125f, 0.854004f,
+ 0.872070f, 0.888184f, 0.902344f, 0.914062f, 0.923340f, 0.931641f, 0.938965f, 0.945312f, 0.950684f, 0.955566f, 0.958984f, 0.962891f,
+ 0.966309f, 0.969727f, 0.972168f, 0.974609f, 0.977051f, 0.978516f, 0.980469f, 0.982422f, 0.984375f, 0.985352f, 0.987305f, 0.987793f,
+ 0.988770f, 0.990234f, 0.991211f, 0.992188f, 0.992676f, 0.993164f, 0.997559f, 0.997559f, 0.997559f, 0.998047f, 0.997559f, 0.998047f,
+ 0.000602f, 0.002605f, 0.004345f, 0.006706f, 0.009590f, 0.012650f, 0.016617f, 0.021423f, 0.027893f, 0.035004f, 0.044495f, 0.056610f,
+ 0.072327f, 0.092285f, 0.116821f, 0.148926f, 0.189697f, 0.238892f, 0.298340f, 0.365723f, 0.437988f, 0.511230f, 0.579590f, 0.642090f,
+ 0.698242f, 0.744141f, 0.781738f, 0.814453f, 0.840332f, 0.861816f, 0.880371f, 0.895996f, 0.907715f, 0.918945f, 0.928223f, 0.935547f,
+ 0.942871f, 0.948730f, 0.953125f, 0.958008f, 0.961914f, 0.965332f, 0.968750f, 0.971680f, 0.973633f, 0.976562f, 0.978516f, 0.979980f,
+ 0.981934f, 0.983398f, 0.985352f, 0.986816f, 0.988281f, 0.988770f, 0.989746f, 0.990723f, 0.991699f, 0.992676f, 0.997070f, 0.997559f,
+ 0.997559f, 0.997070f, 0.997070f, 0.997070f, 0.000607f, 0.001955f, 0.003616f, 0.005772f, 0.007656f, 0.010269f, 0.013496f, 0.017273f,
+ 0.022018f, 0.027466f, 0.034729f, 0.043488f, 0.054932f, 0.068359f, 0.086365f, 0.108765f, 0.137939f, 0.174316f, 0.219360f, 0.273926f,
+ 0.336670f, 0.406494f, 0.478516f, 0.549316f, 0.614746f, 0.673340f, 0.722656f, 0.765137f, 0.800293f, 0.828125f, 0.853516f, 0.872070f,
+ 0.888672f, 0.902832f, 0.914551f, 0.924316f, 0.932129f, 0.940430f, 0.946289f, 0.951660f, 0.956055f, 0.960449f, 0.964355f, 0.967773f,
+ 0.970703f, 0.972656f, 0.975586f, 0.978027f, 0.980469f, 0.981934f, 0.983398f, 0.985352f, 0.986328f, 0.988281f, 0.988770f, 0.990234f,
+ 0.990723f, 0.992188f, 0.996582f, 0.997070f, 0.997070f, 0.997070f, 0.997070f, 0.997070f, 0.000600f, 0.001813f, 0.003101f, 0.004559f,
+ 0.006580f, 0.008873f, 0.011047f, 0.014091f, 0.017639f, 0.022049f, 0.027557f, 0.033997f, 0.042297f, 0.052704f, 0.065369f, 0.081238f,
+ 0.101929f, 0.127930f, 0.161255f, 0.202515f, 0.252686f, 0.311523f, 0.378174f, 0.449707f, 0.519531f, 0.587891f, 0.647949f, 0.701660f,
+ 0.746582f, 0.784668f, 0.817383f, 0.843262f, 0.864746f, 0.882324f, 0.896973f, 0.910156f, 0.920898f, 0.929688f, 0.937012f, 0.943848f,
+ 0.949707f, 0.955078f, 0.959473f, 0.963379f, 0.966797f, 0.970215f, 0.973145f, 0.975098f, 0.978027f, 0.980469f, 0.982422f, 0.983887f,
+ 0.984863f, 0.986328f, 0.987793f, 0.988770f, 0.989746f, 0.991211f, 0.996582f, 0.997070f, 0.997070f, 0.997070f, 0.997070f, 0.997070f,
+ 0.000604f, 0.001429f, 0.002676f, 0.003708f, 0.005745f, 0.006973f, 0.009270f, 0.011452f, 0.014503f, 0.018295f, 0.022369f, 0.027222f,
+ 0.033417f, 0.040833f, 0.050171f, 0.062744f, 0.077454f, 0.095886f, 0.119995f, 0.150391f, 0.187622f, 0.234253f, 0.289307f, 0.353027f,
+ 0.421631f, 0.492676f, 0.561523f, 0.625488f, 0.681152f, 0.730469f, 0.770996f, 0.806152f, 0.833984f, 0.857422f, 0.876465f, 0.893066f,
+ 0.906250f, 0.916992f, 0.926758f, 0.935059f, 0.942871f, 0.948242f, 0.954102f, 0.958496f, 0.962891f, 0.966309f, 0.969727f, 0.972168f,
+ 0.975098f, 0.977539f, 0.979492f, 0.981934f, 0.983398f, 0.984863f, 0.986328f, 0.987793f, 0.989258f, 0.990234f, 0.996094f, 0.996582f,
+ 0.996582f, 0.996582f, 0.996582f, 0.996582f, 0.000365f, 0.001367f, 0.002123f, 0.003353f, 0.004692f, 0.006054f, 0.007675f, 0.009819f,
+ 0.012314f, 0.014862f, 0.018066f, 0.022064f, 0.026901f, 0.032471f, 0.039764f, 0.048584f, 0.060089f, 0.073730f, 0.090698f, 0.112854f,
+ 0.140381f, 0.175415f, 0.218018f, 0.269775f, 0.329834f, 0.396240f, 0.467285f, 0.537598f, 0.603516f, 0.662109f, 0.712891f, 0.757324f,
+ 0.793945f, 0.823730f, 0.849121f, 0.869629f, 0.887695f, 0.902344f, 0.914062f, 0.924805f, 0.932129f, 0.940430f, 0.947266f, 0.952148f,
+ 0.957031f, 0.962402f, 0.966309f, 0.969238f, 0.972656f, 0.975586f, 0.977051f, 0.979492f, 0.981934f, 0.983398f, 0.984863f, 0.986328f,
+ 0.988281f, 0.988770f, 0.995605f, 0.996094f, 0.996094f, 0.996094f, 0.996094f, 0.996094f, 0.000356f, 0.001341f, 0.001913f, 0.002897f,
+ 0.003983f, 0.005322f, 0.006607f, 0.008514f, 0.010399f, 0.012451f, 0.015282f, 0.018356f, 0.021912f, 0.026443f, 0.031982f, 0.038635f,
+ 0.047150f, 0.057495f, 0.070007f, 0.086609f, 0.106689f, 0.131714f, 0.164429f, 0.203613f, 0.252441f, 0.310059f, 0.374512f, 0.444092f,
+ 0.514160f, 0.582031f, 0.643066f, 0.697266f, 0.743652f, 0.783691f, 0.814941f, 0.842773f, 0.865234f, 0.882812f, 0.897949f, 0.910645f,
+ 0.922363f, 0.931152f, 0.938965f, 0.945801f, 0.952148f, 0.957520f, 0.961426f, 0.965820f, 0.969727f, 0.972168f, 0.975098f, 0.977539f,
+ 0.979980f, 0.981934f, 0.983887f, 0.985352f, 0.986816f, 0.988281f, 0.995117f, 0.995605f, 0.996094f, 0.996094f, 0.996094f, 0.996094f,
+ 0.000243f, 0.000937f, 0.001662f, 0.002617f, 0.003527f, 0.004555f, 0.005642f, 0.007217f, 0.008820f, 0.010483f, 0.012383f, 0.015175f,
+ 0.018341f, 0.022049f, 0.026245f, 0.031067f, 0.037903f, 0.045563f, 0.054962f, 0.066956f, 0.082092f, 0.101074f, 0.124939f, 0.154663f,
+ 0.191528f, 0.237305f, 0.291992f, 0.354492f, 0.422852f, 0.492676f, 0.562012f, 0.625488f, 0.682617f, 0.731934f, 0.772949f, 0.807129f,
+ 0.835449f, 0.859863f, 0.878906f, 0.895020f, 0.908203f, 0.920898f, 0.929199f, 0.937988f, 0.945312f, 0.951660f, 0.957031f, 0.961914f,
+ 0.965332f, 0.968750f, 0.972656f, 0.975098f, 0.977539f, 0.979980f, 0.982422f, 0.983887f, 0.986328f, 0.987793f, 0.995117f, 0.995605f,
+ 0.995605f, 0.995605f, 0.995605f, 0.995605f, 0.000362f, 0.000970f, 0.001489f, 0.002251f, 0.002892f, 0.003727f, 0.004978f, 0.006264f,
+ 0.007530f, 0.009125f, 0.010551f, 0.012756f, 0.015259f, 0.018097f, 0.021637f, 0.025986f, 0.030594f, 0.036804f, 0.044006f, 0.053162f,
+ 0.064148f, 0.078003f, 0.096130f, 0.118042f, 0.146118f, 0.181030f, 0.224487f, 0.276123f, 0.336670f, 0.403320f, 0.473633f, 0.543457f,
+ 0.609375f, 0.667480f, 0.719238f, 0.763184f, 0.799316f, 0.829590f, 0.854492f, 0.875488f, 0.892578f, 0.906738f, 0.918945f, 0.928711f,
+ 0.937012f, 0.944336f, 0.951172f, 0.956543f, 0.961426f, 0.965820f, 0.968750f, 0.972656f, 0.975098f, 0.978027f, 0.980469f, 0.982910f,
+ 0.984375f, 0.985840f, 0.994629f, 0.995117f, 0.995117f, 0.995117f, 0.995117f, 0.995117f, 0.000346f, 0.000923f, 0.001273f, 0.002010f,
+ 0.002619f, 0.003689f, 0.004452f, 0.005177f, 0.006290f, 0.007561f, 0.009033f, 0.010902f, 0.012970f, 0.015495f, 0.018280f, 0.021576f,
+ 0.024948f, 0.030304f, 0.035400f, 0.042480f, 0.051086f, 0.061401f, 0.074890f, 0.091187f, 0.112427f, 0.138794f, 0.171631f, 0.212158f,
+ 0.262451f, 0.320557f, 0.385986f, 0.456055f, 0.525391f, 0.593262f, 0.654297f, 0.708984f, 0.754883f, 0.792969f, 0.824707f, 0.850098f,
+ 0.872070f, 0.890137f, 0.904785f, 0.917480f, 0.927734f, 0.937012f, 0.944336f, 0.951172f, 0.956055f, 0.961914f, 0.966309f, 0.969727f,
+ 0.973145f, 0.976074f, 0.978516f, 0.980469f, 0.982910f, 0.984863f, 0.993652f, 0.995117f, 0.994629f, 0.994629f, 0.994629f, 0.994629f,
+ 0.000242f, 0.000666f, 0.001081f, 0.001806f, 0.002512f, 0.003397f, 0.003866f, 0.004894f, 0.005566f, 0.006859f, 0.007957f, 0.009506f,
+ 0.011009f, 0.013046f, 0.015266f, 0.018173f, 0.021027f, 0.024811f, 0.029526f, 0.034790f, 0.041443f, 0.049835f, 0.059265f, 0.071899f,
+ 0.087769f, 0.107422f, 0.132202f, 0.163208f, 0.201782f, 0.249512f, 0.305908f, 0.370361f, 0.440430f, 0.511230f, 0.578613f, 0.642090f,
+ 0.698730f, 0.746582f, 0.787109f, 0.819824f, 0.848145f, 0.869141f, 0.888672f, 0.903809f, 0.916992f, 0.927246f, 0.936523f, 0.943848f,
+ 0.951660f, 0.957031f, 0.961426f, 0.965820f, 0.970215f, 0.973145f, 0.976074f, 0.979004f, 0.981445f, 0.983398f, 0.994141f, 0.994141f,
+ 0.994629f, 0.994141f, 0.994629f, 0.994141f, 0.000242f, 0.000709f, 0.000917f, 0.001194f, 0.002018f, 0.002634f, 0.003504f, 0.003918f,
+ 0.005020f, 0.005726f, 0.006935f, 0.008141f, 0.009666f, 0.011040f, 0.012848f, 0.014961f, 0.017624f, 0.020660f, 0.024368f, 0.028381f,
+ 0.033905f, 0.040283f, 0.047760f, 0.057312f, 0.069214f, 0.083984f, 0.102539f, 0.126221f, 0.155640f, 0.193359f, 0.238892f, 0.293701f,
+ 0.356689f, 0.425537f, 0.497070f, 0.568359f, 0.632812f, 0.690918f, 0.739746f, 0.782227f, 0.816406f, 0.845703f, 0.868652f, 0.887695f,
+ 0.903320f, 0.916992f, 0.927734f, 0.937012f, 0.944824f, 0.951660f, 0.957031f, 0.962891f, 0.966797f, 0.971191f, 0.973633f, 0.976562f,
+ 0.979492f, 0.981934f, 0.992676f, 0.993652f, 0.994141f, 0.993652f, 0.993652f, 0.994141f, 0.000244f, 0.000660f, 0.000918f, 0.001343f,
+ 0.002117f, 0.002407f, 0.002779f, 0.003626f, 0.004246f, 0.005207f, 0.005913f, 0.007145f, 0.008163f, 0.009438f, 0.011101f, 0.012871f,
+ 0.014999f, 0.017426f, 0.020096f, 0.024185f, 0.027725f, 0.032623f, 0.038910f, 0.046387f, 0.055298f, 0.066467f, 0.080627f, 0.098328f,
+ 0.120972f, 0.149658f, 0.184814f, 0.229492f, 0.282715f, 0.344727f, 0.414062f, 0.486084f, 0.556641f, 0.624023f, 0.683594f, 0.735352f,
+ 0.778320f, 0.814453f, 0.843750f, 0.867188f, 0.887207f, 0.903320f, 0.916504f, 0.928223f, 0.937500f, 0.945312f, 0.953125f, 0.958008f,
+ 0.964355f, 0.967285f, 0.971680f, 0.975098f, 0.978516f, 0.980957f, 0.992676f, 0.993652f, 0.994141f, 0.993652f, 0.993652f, 0.993164f,
+ 0.000200f, 0.000480f, 0.000808f, 0.001303f, 0.001680f, 0.002104f, 0.002510f, 0.002934f, 0.003468f, 0.004429f, 0.005539f, 0.006046f,
+ 0.006889f, 0.008438f, 0.009415f, 0.011108f, 0.012787f, 0.014572f, 0.017517f, 0.020279f, 0.023483f, 0.027359f, 0.031860f, 0.037964f,
+ 0.045227f, 0.053711f, 0.064148f, 0.077759f, 0.095093f, 0.116272f, 0.143311f, 0.177856f, 0.221191f, 0.273193f, 0.334473f, 0.403320f,
+ 0.476318f, 0.548828f, 0.617188f, 0.677734f, 0.730957f, 0.775879f, 0.812500f, 0.842285f, 0.866699f, 0.887695f, 0.903809f, 0.916992f,
+ 0.928711f, 0.938477f, 0.946777f, 0.953125f, 0.959473f, 0.963867f, 0.968750f, 0.972656f, 0.976074f, 0.979004f, 0.992188f, 0.992676f,
+ 0.993164f, 0.993164f, 0.992676f, 0.993164f, 0.000243f, 0.000469f, 0.000878f, 0.001158f, 0.001382f, 0.001801f, 0.002220f, 0.002699f,
+ 0.003273f, 0.004063f, 0.004715f, 0.005447f, 0.005917f, 0.007099f, 0.008385f, 0.009521f, 0.011032f, 0.012627f, 0.014870f, 0.016922f,
+ 0.019836f, 0.023010f, 0.026642f, 0.031174f, 0.036926f, 0.043549f, 0.051941f, 0.062561f, 0.075317f, 0.091553f, 0.112427f, 0.138428f,
+ 0.172485f, 0.213867f, 0.265381f, 0.326172f, 0.394775f, 0.467773f, 0.541504f, 0.610840f, 0.673340f, 0.728516f, 0.774414f, 0.812012f,
+ 0.842773f, 0.867676f, 0.887695f, 0.904297f, 0.918457f, 0.929688f, 0.939453f, 0.948242f, 0.955078f, 0.959961f, 0.965820f, 0.970215f,
+ 0.974121f, 0.977051f, 0.991211f, 0.993164f, 0.993164f, 0.992188f, 0.993164f, 0.992188f, 0.000000f, 0.000242f, 0.000799f, 0.000998f,
+ 0.001273f, 0.001671f, 0.002069f, 0.002485f, 0.003212f, 0.003578f, 0.003948f, 0.004559f, 0.005524f, 0.006321f, 0.007046f, 0.008438f,
+ 0.009438f, 0.010986f, 0.012390f, 0.014320f, 0.016663f, 0.019165f, 0.022476f, 0.025833f, 0.030487f, 0.035675f, 0.042358f, 0.050018f,
+ 0.060211f, 0.072693f, 0.088379f, 0.108948f, 0.134766f, 0.166626f, 0.208008f, 0.258545f, 0.318848f, 0.387451f, 0.461670f, 0.536621f,
+ 0.606934f, 0.671387f, 0.727539f, 0.773438f, 0.811523f, 0.843750f, 0.868164f, 0.889160f, 0.906250f, 0.920410f, 0.932617f, 0.941895f,
+ 0.949707f, 0.956055f, 0.962402f, 0.967285f, 0.971680f, 0.975586f, 0.990723f, 0.991699f, 0.991699f, 0.992188f, 0.992188f, 0.991699f,
+ 0.000237f, 0.000482f, 0.000772f, 0.000877f, 0.001109f, 0.001494f, 0.001991f, 0.002041f, 0.002537f, 0.002975f, 0.003469f, 0.004128f,
+ 0.004841f, 0.005550f, 0.006306f, 0.007359f, 0.008369f, 0.009415f, 0.010788f, 0.012306f, 0.014160f, 0.016571f, 0.018921f, 0.021896f,
+ 0.025497f, 0.029587f, 0.034576f, 0.041260f, 0.049011f, 0.058319f, 0.070557f, 0.086060f, 0.105774f, 0.130737f, 0.162720f, 0.203247f,
+ 0.252930f, 0.313477f, 0.382568f, 0.457275f, 0.532715f, 0.605469f, 0.671387f, 0.728027f, 0.774902f, 0.814453f, 0.844727f, 0.870605f,
+ 0.891113f, 0.909180f, 0.922852f, 0.934082f, 0.943359f, 0.951660f, 0.958008f, 0.964355f, 0.968750f, 0.973145f, 0.990234f, 0.990723f,
+ 0.991699f, 0.991211f, 0.991211f, 0.991211f, 0.000235f, 0.000461f, 0.000484f, 0.000891f, 0.001105f, 0.001346f, 0.001634f, 0.001936f,
+ 0.002438f, 0.002874f, 0.003353f, 0.003925f, 0.004189f, 0.004887f, 0.005684f, 0.006279f, 0.007298f, 0.008339f, 0.009384f, 0.010674f,
+ 0.012360f, 0.013901f, 0.016113f, 0.018677f, 0.021469f, 0.024841f, 0.029144f, 0.033783f, 0.039948f, 0.047272f, 0.056915f, 0.068726f,
+ 0.083801f, 0.102905f, 0.127563f, 0.159058f, 0.199341f, 0.248901f, 0.309570f, 0.379395f, 0.454834f, 0.532715f, 0.606934f, 0.672852f,
+ 0.729980f, 0.778320f, 0.817383f, 0.849121f, 0.874512f, 0.895020f, 0.911621f, 0.924805f, 0.937012f, 0.946289f, 0.954102f, 0.960938f,
+ 0.965820f, 0.971191f, 0.989258f, 0.990234f, 0.990723f, 0.991211f, 0.990723f, 0.990723f, 0.000000f, 0.000360f, 0.000477f, 0.000756f,
+ 0.000896f, 0.001065f, 0.001570f, 0.001622f, 0.002064f, 0.002525f, 0.002819f, 0.003004f, 0.003700f, 0.004356f, 0.005077f, 0.005428f,
+ 0.006283f, 0.007370f, 0.008339f, 0.009323f, 0.010567f, 0.012070f, 0.013672f, 0.015839f, 0.018066f, 0.020844f, 0.024002f, 0.028183f,
+ 0.033051f, 0.039246f, 0.046417f, 0.055450f, 0.067200f, 0.082031f, 0.100586f, 0.125122f, 0.156250f, 0.196167f, 0.245972f, 0.307129f,
+ 0.378174f, 0.454834f, 0.533203f, 0.608398f, 0.675781f, 0.734375f, 0.782715f, 0.821777f, 0.853516f, 0.878906f, 0.898926f, 0.915039f,
+ 0.929199f, 0.939941f, 0.948730f, 0.956055f, 0.963379f, 0.968262f, 0.988770f, 0.989746f, 0.990234f, 0.989746f, 0.989746f, 0.990234f,
+ 0.000000f, 0.000256f, 0.000467f, 0.000590f, 0.000772f, 0.001095f, 0.001356f, 0.001781f, 0.001984f, 0.002161f, 0.002546f, 0.002956f,
+ 0.003338f, 0.003899f, 0.004440f, 0.004986f, 0.005486f, 0.006310f, 0.006969f, 0.008148f, 0.009148f, 0.010284f, 0.011902f, 0.013573f,
+ 0.015465f, 0.017853f, 0.020340f, 0.023590f, 0.027298f, 0.032227f, 0.038208f, 0.045563f, 0.054047f, 0.065796f, 0.080322f, 0.098999f,
+ 0.122864f, 0.153809f, 0.193970f, 0.244629f, 0.306396f, 0.378662f, 0.457031f, 0.536621f, 0.613770f, 0.681641f, 0.740723f, 0.788574f,
+ 0.827637f, 0.858398f, 0.884277f, 0.903320f, 0.919922f, 0.932129f, 0.942871f, 0.951660f, 0.959961f, 0.965820f, 0.987305f, 0.988281f,
+ 0.989258f, 0.989258f, 0.989258f, 0.989258f, 0.000244f, 0.000243f, 0.000583f, 0.000585f, 0.000822f, 0.001073f, 0.001159f, 0.001452f,
+ 0.001525f, 0.002001f, 0.002201f, 0.002714f, 0.002932f, 0.003525f, 0.003904f, 0.004482f, 0.004997f, 0.005581f, 0.006233f, 0.006954f,
+ 0.007820f, 0.008949f, 0.009941f, 0.011482f, 0.013168f, 0.015099f, 0.017151f, 0.020111f, 0.022949f, 0.026947f, 0.031647f, 0.037354f,
+ 0.044342f, 0.053375f, 0.064331f, 0.078857f, 0.097351f, 0.121033f, 0.152588f, 0.192749f, 0.244263f, 0.307129f, 0.380615f, 0.461426f,
+ 0.543457f, 0.621582f, 0.690430f, 0.748047f, 0.796387f, 0.834961f, 0.865723f, 0.889160f, 0.908691f, 0.924316f, 0.937500f, 0.946777f,
+ 0.955078f, 0.962891f, 0.986328f, 0.987793f, 0.988770f, 0.988770f, 0.988770f, 0.988770f, 0.000000f, 0.000243f, 0.000308f, 0.000541f,
+ 0.000801f, 0.000827f, 0.001057f, 0.001280f, 0.001460f, 0.001781f, 0.002090f, 0.002481f, 0.002756f, 0.003054f, 0.003321f, 0.003948f,
+ 0.004303f, 0.004898f, 0.005306f, 0.006405f, 0.006954f, 0.007851f, 0.008537f, 0.009918f, 0.011208f, 0.012825f, 0.014534f, 0.016861f,
+ 0.019379f, 0.022629f, 0.026276f, 0.030838f, 0.036407f, 0.043488f, 0.051819f, 0.063416f, 0.077209f, 0.095825f, 0.119812f, 0.151489f,
+ 0.192749f, 0.245361f, 0.309814f, 0.385986f, 0.469238f, 0.552246f, 0.630859f, 0.699707f, 0.757324f, 0.805176f, 0.842773f, 0.873047f,
+ 0.895508f, 0.914062f, 0.929688f, 0.941406f, 0.952148f, 0.959473f, 0.985840f, 0.986816f, 0.987305f, 0.987305f, 0.987305f, 0.987305f,
+ 0.000000f, 0.000243f, 0.000242f, 0.000548f, 0.000695f, 0.000803f, 0.001053f, 0.001198f, 0.001363f, 0.001513f, 0.001886f, 0.002069f,
+ 0.002447f, 0.002676f, 0.003138f, 0.003551f, 0.003868f, 0.004261f, 0.004936f, 0.005337f, 0.005852f, 0.006615f, 0.007519f, 0.008575f,
+ 0.009705f, 0.010872f, 0.012688f, 0.014397f, 0.016479f, 0.019119f, 0.022064f, 0.025589f, 0.030304f, 0.035828f, 0.042603f, 0.050812f,
+ 0.062012f, 0.076355f, 0.094971f, 0.119263f, 0.151367f, 0.193726f, 0.247925f, 0.314941f, 0.393311f, 0.478271f, 0.563965f, 0.642578f,
+ 0.711914f, 0.769043f, 0.815430f, 0.851562f, 0.881348f, 0.902832f, 0.921387f, 0.934570f, 0.945801f, 0.955078f, 0.984375f, 0.986328f,
+ 0.986328f, 0.986328f, 0.986328f, 0.986328f, 0.000000f, 0.000234f, 0.000239f, 0.000308f, 0.000597f, 0.000690f, 0.000868f, 0.000937f,
+ 0.001189f, 0.001404f, 0.001696f, 0.001854f, 0.002180f, 0.002249f, 0.002672f, 0.002979f, 0.003494f, 0.003761f, 0.004257f, 0.004745f,
+ 0.005154f, 0.005821f, 0.006561f, 0.007557f, 0.008575f, 0.009575f, 0.010963f, 0.012238f, 0.014130f, 0.016113f, 0.018539f, 0.021545f,
+ 0.025162f, 0.029404f, 0.034851f, 0.041626f, 0.050354f, 0.061218f, 0.075562f, 0.094482f, 0.119507f, 0.152344f, 0.196167f, 0.252197f,
+ 0.322266f, 0.404053f, 0.490967f, 0.577637f, 0.658203f, 0.726074f, 0.782715f, 0.827637f, 0.861816f, 0.889648f, 0.910645f, 0.926758f,
+ 0.940918f, 0.950684f, 0.983398f, 0.985352f, 0.984863f, 0.985352f, 0.985840f, 0.985352f, 0.000000f, 0.000240f, 0.000237f, 0.000239f,
+ 0.000436f, 0.000648f, 0.000661f, 0.000892f, 0.001089f, 0.001484f, 0.001446f, 0.001586f, 0.001896f, 0.002176f, 0.002325f, 0.002634f,
+ 0.003057f, 0.003315f, 0.003561f, 0.004150f, 0.004578f, 0.005180f, 0.005768f, 0.006485f, 0.007286f, 0.008400f, 0.009453f, 0.010429f,
+ 0.011795f, 0.013680f, 0.015671f, 0.018005f, 0.020981f, 0.024521f, 0.028748f, 0.034119f, 0.040863f, 0.049622f, 0.060303f, 0.074829f,
+ 0.094116f, 0.119995f, 0.154297f, 0.199341f, 0.258301f, 0.331787f, 0.416504f, 0.507812f, 0.595703f, 0.675781f, 0.743164f, 0.797852f,
+ 0.840820f, 0.873535f, 0.899414f, 0.919434f, 0.934082f, 0.947266f, 0.982422f, 0.983887f, 0.983887f, 0.984375f, 0.984375f, 0.983887f,
+ 0.000136f, 0.000115f, 0.000237f, 0.000238f, 0.000358f, 0.000452f, 0.000759f, 0.000961f, 0.001026f, 0.001113f, 0.001433f, 0.001564f,
+ 0.001659f, 0.001955f, 0.002024f, 0.002384f, 0.002647f, 0.002974f, 0.003267f, 0.003611f, 0.003971f, 0.004498f, 0.005043f, 0.005539f,
+ 0.006344f, 0.007168f, 0.007942f, 0.009010f, 0.010353f, 0.011711f, 0.013458f, 0.015213f, 0.017548f, 0.020279f, 0.023926f, 0.028061f,
+ 0.033356f, 0.040283f, 0.048615f, 0.060455f, 0.074890f, 0.094727f, 0.121216f, 0.156860f, 0.204102f, 0.266846f, 0.344238f, 0.433105f,
+ 0.526855f, 0.616699f, 0.696289f, 0.761230f, 0.813965f, 0.854492f, 0.884766f, 0.909180f, 0.927734f, 0.941895f, 0.980957f, 0.982422f,
+ 0.982910f, 0.982422f, 0.982422f, 0.982910f, 0.000000f, 0.000103f, 0.000208f, 0.000356f, 0.000355f, 0.000400f, 0.000454f, 0.000861f,
+ 0.000922f, 0.001202f, 0.001088f, 0.001401f, 0.001493f, 0.001779f, 0.001881f, 0.002180f, 0.002329f, 0.002483f, 0.002846f, 0.003178f,
+ 0.003542f, 0.003914f, 0.004406f, 0.004871f, 0.005352f, 0.006119f, 0.006927f, 0.007904f, 0.008759f, 0.009972f, 0.011284f, 0.013046f,
+ 0.014938f, 0.016998f, 0.019943f, 0.023224f, 0.027161f, 0.032776f, 0.039917f, 0.048218f, 0.059937f, 0.075134f, 0.095642f, 0.123169f,
+ 0.160767f, 0.211670f, 0.278320f, 0.360352f, 0.454102f, 0.550293f, 0.640625f, 0.718262f, 0.781738f, 0.831055f, 0.869141f, 0.897461f,
+ 0.919434f, 0.936035f, 0.979492f, 0.980957f, 0.980957f, 0.981934f, 0.981445f, 0.981445f, 0.000000f, 0.000192f, 0.000191f, 0.000350f,
+ 0.000352f, 0.000354f, 0.000599f, 0.000721f, 0.000835f, 0.001044f, 0.000988f, 0.001141f, 0.001255f, 0.001479f, 0.001705f, 0.001815f,
+ 0.001843f, 0.002151f, 0.002369f, 0.002831f, 0.003067f, 0.003431f, 0.003698f, 0.004295f, 0.004738f, 0.005352f, 0.005859f, 0.006615f,
+ 0.007587f, 0.008583f, 0.009682f, 0.010735f, 0.012405f, 0.014381f, 0.016708f, 0.018921f, 0.022736f, 0.026947f, 0.032104f, 0.039032f,
+ 0.048004f, 0.059784f, 0.075500f, 0.096924f, 0.125977f, 0.166626f, 0.221069f, 0.292969f, 0.380371f, 0.479004f, 0.577637f, 0.667969f,
+ 0.743164f, 0.803711f, 0.849609f, 0.883789f, 0.910645f, 0.930176f, 0.977539f, 0.979492f, 0.979492f, 0.979492f, 0.979980f, 0.979492f,
+ 0.000000f, 0.000000f, 0.000191f, 0.000214f, 0.000441f, 0.000465f, 0.000351f, 0.000656f, 0.000672f, 0.000957f, 0.000881f, 0.001092f,
+ 0.001209f, 0.001259f, 0.001315f, 0.001583f, 0.001630f, 0.001834f, 0.002033f, 0.002367f, 0.002596f, 0.002924f, 0.003387f, 0.003693f,
+ 0.004063f, 0.004601f, 0.004986f, 0.005676f, 0.006557f, 0.006973f, 0.007801f, 0.008781f, 0.010475f, 0.012100f, 0.013817f, 0.015625f,
+ 0.018784f, 0.021927f, 0.026260f, 0.031677f, 0.038879f, 0.048004f, 0.059845f, 0.076233f, 0.098633f, 0.130005f, 0.173950f, 0.233032f,
+ 0.311035f, 0.405518f, 0.507812f, 0.608887f, 0.698242f, 0.769531f, 0.826172f, 0.868164f, 0.899414f, 0.922852f, 0.976074f, 0.977539f,
+ 0.977539f, 0.977051f, 0.978027f, 0.978027f, 0.000000f, 0.000000f, 0.000117f, 0.000211f, 0.000326f, 0.000573f, 0.000574f, 0.000583f,
+ 0.000584f, 0.000659f, 0.000901f, 0.001014f, 0.001064f, 0.001033f, 0.001163f, 0.001234f, 0.001546f, 0.001585f, 0.001894f, 0.002085f,
+ 0.002361f, 0.002504f, 0.003023f, 0.003147f, 0.003580f, 0.004032f, 0.004314f, 0.004936f, 0.005215f, 0.006081f, 0.006725f, 0.007927f,
+ 0.008743f, 0.009918f, 0.011642f, 0.013367f, 0.015404f, 0.018219f, 0.021545f, 0.025787f, 0.031174f, 0.038361f, 0.047577f, 0.060425f,
+ 0.077881f, 0.102051f, 0.135376f, 0.182861f, 0.249023f, 0.333984f, 0.436035f, 0.542969f, 0.644043f, 0.730469f, 0.798340f, 0.848633f,
+ 0.886719f, 0.914062f, 0.973633f, 0.974609f, 0.975098f, 0.976074f, 0.975098f, 0.976074f, 0.000000f, 0.000000f, 0.000114f, 0.000112f,
+ 0.000271f, 0.000510f, 0.000450f, 0.000565f, 0.000572f, 0.000581f, 0.000654f, 0.000825f, 0.000954f, 0.001085f, 0.001050f, 0.001087f,
+ 0.001282f, 0.001547f, 0.001585f, 0.001825f, 0.002066f, 0.002182f, 0.002384f, 0.002659f, 0.003172f, 0.003357f, 0.003721f, 0.004238f,
+ 0.004505f, 0.005024f, 0.005878f, 0.006512f, 0.007324f, 0.008293f, 0.009201f, 0.011040f, 0.012993f, 0.015007f, 0.017639f, 0.020920f,
+ 0.025131f, 0.030899f, 0.038269f, 0.047760f, 0.061188f, 0.079651f, 0.105469f, 0.142944f, 0.195801f, 0.268799f, 0.363525f, 0.472168f,
+ 0.582520f, 0.683594f, 0.765137f, 0.826660f, 0.872070f, 0.905273f, 0.972168f, 0.973633f, 0.973145f, 0.973633f, 0.973633f, 0.973633f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000111f, 0.000224f, 0.000412f, 0.000494f, 0.000543f, 0.000561f, 0.000680f, 0.000665f, 0.000675f,
+ 0.000679f, 0.000797f, 0.000926f, 0.001122f, 0.001132f, 0.001207f, 0.001375f, 0.001606f, 0.001838f, 0.001963f, 0.002163f, 0.002314f,
+ 0.002480f, 0.002956f, 0.003189f, 0.003489f, 0.003744f, 0.004311f, 0.004749f, 0.005276f, 0.005867f, 0.006962f, 0.008186f, 0.008987f,
+ 0.010498f, 0.012283f, 0.014374f, 0.017075f, 0.020355f, 0.024719f, 0.030640f, 0.037720f, 0.048309f, 0.062134f, 0.082336f, 0.110840f,
+ 0.151978f, 0.212891f, 0.294922f, 0.399170f, 0.515137f, 0.628418f, 0.724609f, 0.799805f, 0.854980f, 0.894043f, 0.968750f, 0.970215f,
+ 0.970703f, 0.971191f, 0.970703f, 0.970703f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000228f, 0.000233f, 0.000436f, 0.000457f,
+ 0.000621f, 0.000546f, 0.000622f, 0.000633f, 0.000576f, 0.000644f, 0.000717f, 0.000909f, 0.000994f, 0.001127f, 0.001179f, 0.001267f,
+ 0.001513f, 0.001628f, 0.001742f, 0.001974f, 0.002111f, 0.002403f, 0.002810f, 0.003139f, 0.003231f, 0.003466f, 0.004021f, 0.004459f,
+ 0.004971f, 0.005581f, 0.006809f, 0.007568f, 0.008759f, 0.010002f, 0.011665f, 0.013847f, 0.016342f, 0.019714f, 0.024368f, 0.030106f,
+ 0.037811f, 0.048706f, 0.063843f, 0.085327f, 0.118042f, 0.164917f, 0.234131f, 0.328125f, 0.443359f, 0.565430f, 0.677246f, 0.767578f,
+ 0.833496f, 0.882812f, 0.965820f, 0.967285f, 0.967773f, 0.968262f, 0.967773f, 0.968262f, 0.000000f, 0.000000f, 0.000000f, 0.000214f,
+ 0.000210f, 0.000296f, 0.000309f, 0.000386f, 0.000462f, 0.000482f, 0.000525f, 0.000572f, 0.000525f, 0.000558f, 0.000689f, 0.000685f,
+ 0.000841f, 0.000934f, 0.001008f, 0.001182f, 0.001271f, 0.001412f, 0.001757f, 0.001787f, 0.001769f, 0.002110f, 0.002321f, 0.002331f,
+ 0.002737f, 0.002951f, 0.003189f, 0.003588f, 0.004253f, 0.004627f, 0.005505f, 0.006119f, 0.006969f, 0.008018f, 0.009583f, 0.010971f,
+ 0.013245f, 0.015915f, 0.019257f, 0.023651f, 0.030014f, 0.038086f, 0.049683f, 0.066406f, 0.091125f, 0.127441f, 0.182617f, 0.262939f,
+ 0.370605f, 0.497070f, 0.623047f, 0.729004f, 0.810547f, 0.867188f, 0.962891f, 0.963867f, 0.964844f, 0.964844f, 0.964355f, 0.964355f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000200f, 0.000215f, 0.000229f, 0.000319f, 0.000330f, 0.000411f, 0.000491f, 0.000527f,
+ 0.000547f, 0.000560f, 0.000634f, 0.000648f, 0.000716f, 0.000778f, 0.000855f, 0.000998f, 0.001182f, 0.001111f, 0.001274f, 0.001625f,
+ 0.001584f, 0.001559f, 0.001864f, 0.002037f, 0.002296f, 0.002438f, 0.002600f, 0.002993f, 0.003290f, 0.003801f, 0.004467f, 0.005085f,
+ 0.005508f, 0.006519f, 0.007645f, 0.008743f, 0.010757f, 0.012558f, 0.014946f, 0.018661f, 0.023422f, 0.029556f, 0.038574f, 0.050964f,
+ 0.069702f, 0.097351f, 0.140015f, 0.205566f, 0.301025f, 0.424561f, 0.559082f, 0.683594f, 0.781250f, 0.852051f, 0.958496f, 0.960449f,
+ 0.960938f, 0.960938f, 0.960938f, 0.960449f, 0.000000f, 0.000000f, 0.000122f, 0.000122f, 0.000122f, 0.000194f, 0.000214f, 0.000251f,
+ 0.000302f, 0.000365f, 0.000370f, 0.000429f, 0.000495f, 0.000521f, 0.000504f, 0.000547f, 0.000632f, 0.000656f, 0.000695f, 0.000795f,
+ 0.000922f, 0.001074f, 0.001125f, 0.001192f, 0.001166f, 0.001303f, 0.001555f, 0.001575f, 0.001763f, 0.001970f, 0.002232f, 0.002560f,
+ 0.002657f, 0.003082f, 0.003559f, 0.003799f, 0.004620f, 0.005241f, 0.006081f, 0.007103f, 0.008385f, 0.009796f, 0.012192f, 0.014702f,
+ 0.018234f, 0.022934f, 0.029556f, 0.039307f, 0.053009f, 0.073547f, 0.106628f, 0.157715f, 0.237793f, 0.351318f, 0.490479f, 0.629883f,
+ 0.746094f, 0.832031f, 0.954590f, 0.956055f, 0.956055f, 0.957031f, 0.956543f, 0.956055f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000121f, 0.000146f, 0.000191f, 0.000200f, 0.000255f, 0.000232f, 0.000252f, 0.000359f, 0.000291f, 0.000342f, 0.000406f, 0.000498f,
+ 0.000520f, 0.000533f, 0.000632f, 0.000605f, 0.000689f, 0.000768f, 0.000908f, 0.001013f, 0.001087f, 0.001030f, 0.001211f, 0.001318f,
+ 0.001497f, 0.001609f, 0.001753f, 0.001957f, 0.002234f, 0.002352f, 0.002663f, 0.003040f, 0.003635f, 0.004082f, 0.004723f, 0.005516f,
+ 0.006367f, 0.007675f, 0.009224f, 0.011360f, 0.013695f, 0.017868f, 0.022598f, 0.029724f, 0.040222f, 0.055542f, 0.080078f, 0.119202f,
+ 0.182617f, 0.281738f, 0.417725f, 0.568848f, 0.705566f, 0.807129f, 0.948730f, 0.951172f, 0.951172f, 0.951172f, 0.951660f, 0.951660f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000203f, 0.000186f, 0.000184f, 0.000321f,
+ 0.000231f, 0.000337f, 0.000359f, 0.000430f, 0.000455f, 0.000531f, 0.000502f, 0.000517f, 0.000728f, 0.000643f, 0.000673f, 0.000816f,
+ 0.000930f, 0.000991f, 0.001028f, 0.001161f, 0.001284f, 0.001369f, 0.001474f, 0.001719f, 0.001781f, 0.001883f, 0.002258f, 0.002518f,
+ 0.002831f, 0.003201f, 0.003744f, 0.004349f, 0.005127f, 0.006130f, 0.007210f, 0.008423f, 0.010696f, 0.013405f, 0.017136f, 0.022522f,
+ 0.030029f, 0.041321f, 0.059631f, 0.089050f, 0.138062f, 0.218994f, 0.343750f, 0.500488f, 0.657227f, 0.780762f, 0.943848f, 0.945312f,
+ 0.945312f, 0.945801f, 0.945801f, 0.946289f, 0.000000f, 0.000000f, 0.000122f, 0.000121f, 0.000121f, 0.000121f, 0.000121f, 0.000120f,
+ 0.000118f, 0.000137f, 0.000139f, 0.000241f, 0.000202f, 0.000304f, 0.000313f, 0.000332f, 0.000357f, 0.000420f, 0.000435f, 0.000463f,
+ 0.000645f, 0.000544f, 0.000700f, 0.000717f, 0.000669f, 0.000834f, 0.000865f, 0.000916f, 0.001109f, 0.001193f, 0.001246f, 0.001300f,
+ 0.001488f, 0.001538f, 0.001806f, 0.001929f, 0.002001f, 0.002462f, 0.002666f, 0.003260f, 0.003904f, 0.004364f, 0.005325f, 0.006306f,
+ 0.008041f, 0.009720f, 0.012718f, 0.016525f, 0.022217f, 0.030579f, 0.043854f, 0.065247f, 0.101929f, 0.166016f, 0.273193f, 0.428223f,
+ 0.600586f, 0.748047f, 0.936523f, 0.938477f, 0.938965f, 0.939453f, 0.938965f, 0.938965f, 0.000000f, 0.000122f, 0.000121f, 0.000121f,
+ 0.000121f, 0.000120f, 0.000120f, 0.000120f, 0.000114f, 0.000102f, 0.000090f, 0.000096f, 0.000131f, 0.000245f, 0.000276f, 0.000257f,
+ 0.000307f, 0.000316f, 0.000322f, 0.000373f, 0.000411f, 0.000440f, 0.000433f, 0.000650f, 0.000578f, 0.000704f, 0.000746f, 0.000723f,
+ 0.000819f, 0.000756f, 0.000758f, 0.000878f, 0.001009f, 0.001270f, 0.001399f, 0.001530f, 0.001798f, 0.001803f, 0.002151f, 0.002317f,
+ 0.002728f, 0.003222f, 0.003782f, 0.004612f, 0.005951f, 0.006985f, 0.009308f, 0.011955f, 0.016052f, 0.022324f, 0.031525f, 0.047272f,
+ 0.073853f, 0.122192f, 0.209717f, 0.352783f, 0.537109f, 0.709473f, 0.928223f, 0.930664f, 0.931152f, 0.930664f, 0.931641f, 0.931152f,
+ 0.000000f, 0.000000f, 0.000121f, 0.000121f, 0.000120f, 0.000120f, 0.000120f, 0.000119f, 0.000119f, 0.000111f, 0.000100f, 0.000139f,
+ 0.000082f, 0.000154f, 0.000121f, 0.000216f, 0.000147f, 0.000271f, 0.000288f, 0.000298f, 0.000386f, 0.000463f, 0.000370f, 0.000485f,
+ 0.000555f, 0.000530f, 0.000578f, 0.000574f, 0.000612f, 0.000712f, 0.000776f, 0.000716f, 0.000931f, 0.000831f, 0.000967f, 0.001154f,
+ 0.001176f, 0.001284f, 0.001497f, 0.001884f, 0.002270f, 0.002415f, 0.002947f, 0.003412f, 0.004032f, 0.005066f, 0.006485f, 0.008400f,
+ 0.011215f, 0.015404f, 0.022079f, 0.033264f, 0.052124f, 0.087646f, 0.155029f, 0.279297f, 0.465820f, 0.664062f, 0.918945f, 0.921387f,
+ 0.921875f, 0.922363f, 0.922363f, 0.921875f, 0.000000f, 0.000121f, 0.000121f, 0.000120f, 0.000120f, 0.000119f, 0.000119f, 0.000119f,
+ 0.000118f, 0.000118f, 0.000110f, 0.000100f, 0.000091f, 0.000082f, 0.000075f, 0.000095f, 0.000166f, 0.000113f, 0.000163f, 0.000248f,
+ 0.000258f, 0.000277f, 0.000336f, 0.000301f, 0.000445f, 0.000495f, 0.000473f, 0.000505f, 0.000494f, 0.000470f, 0.000584f, 0.000752f,
+ 0.000821f, 0.000814f, 0.000845f, 0.000807f, 0.000932f, 0.000996f, 0.001380f, 0.001481f, 0.001507f, 0.001757f, 0.002146f, 0.002443f,
+ 0.002869f, 0.003546f, 0.004559f, 0.005878f, 0.007561f, 0.010475f, 0.015320f, 0.022675f, 0.036133f, 0.060883f, 0.110352f, 0.211670f,
+ 0.389160f, 0.610352f, 0.908691f, 0.909180f, 0.910645f, 0.912109f, 0.909668f, 0.910156f, 0.000000f, 0.000121f, 0.000120f, 0.000119f,
+ 0.000119f, 0.000118f, 0.000118f, 0.000117f, 0.000117f, 0.000117f, 0.000116f, 0.000110f, 0.000100f, 0.000099f, 0.000083f, 0.000077f,
+ 0.000071f, 0.000081f, 0.000087f, 0.000166f, 0.000177f, 0.000233f, 0.000238f, 0.000273f, 0.000325f, 0.000357f, 0.000292f, 0.000406f,
+ 0.000418f, 0.000440f, 0.000428f, 0.000568f, 0.000459f, 0.000628f, 0.000678f, 0.000688f, 0.000647f, 0.000830f, 0.000925f, 0.001111f,
+ 0.001011f, 0.001420f, 0.001504f, 0.001771f, 0.001997f, 0.002495f, 0.003147f, 0.003944f, 0.005077f, 0.006958f, 0.010040f, 0.015053f,
+ 0.023727f, 0.040680f, 0.075989f, 0.153076f, 0.312012f, 0.547363f, 0.894531f, 0.897461f, 0.897949f, 0.897949f, 0.897949f, 0.898438f,
+ 0.000000f, 0.000000f, 0.000119f, 0.000118f, 0.000118f, 0.000117f, 0.000116f, 0.000116f, 0.000115f, 0.000115f, 0.000114f, 0.000114f,
+ 0.000111f, 0.000101f, 0.000093f, 0.000086f, 0.000079f, 0.000095f, 0.000095f, 0.000090f, 0.000117f, 0.000109f, 0.000158f, 0.000199f,
+ 0.000207f, 0.000223f, 0.000286f, 0.000288f, 0.000267f, 0.000347f, 0.000368f, 0.000450f, 0.000377f, 0.000460f, 0.000504f, 0.000498f,
+ 0.000494f, 0.000616f, 0.000632f, 0.000699f, 0.000755f, 0.000938f, 0.000978f, 0.001222f, 0.001355f, 0.001673f, 0.002016f, 0.002539f,
+ 0.003258f, 0.004410f, 0.006332f, 0.009285f, 0.014847f, 0.025864f, 0.049042f, 0.104736f, 0.236572f, 0.477295f, 0.879395f, 0.881348f,
+ 0.882324f, 0.881836f, 0.882324f, 0.882324f, 0.000000f, 0.000119f, 0.000118f, 0.000116f, 0.000115f, 0.000114f, 0.000114f, 0.000113f,
+ 0.000112f, 0.000112f, 0.000111f, 0.000111f, 0.000110f, 0.000110f, 0.000103f, 0.000095f, 0.000088f, 0.000081f, 0.000076f, 0.000070f,
+ 0.000065f, 0.000100f, 0.000104f, 0.000099f, 0.000120f, 0.000145f, 0.000190f, 0.000204f, 0.000213f, 0.000230f, 0.000241f, 0.000279f,
+ 0.000325f, 0.000322f, 0.000328f, 0.000381f, 0.000351f, 0.000466f, 0.000452f, 0.000516f, 0.000591f, 0.000622f, 0.000733f, 0.000882f,
+ 0.000895f, 0.001092f, 0.001456f, 0.001765f, 0.002069f, 0.002821f, 0.003851f, 0.005558f, 0.008865f, 0.015579f, 0.029999f, 0.066895f,
+ 0.167480f, 0.400391f, 0.860352f, 0.862793f, 0.863281f, 0.864258f, 0.863281f, 0.863770f, 0.000119f, 0.000114f, 0.000113f, 0.000113f,
+ 0.000111f, 0.000110f, 0.000109f, 0.000109f, 0.000108f, 0.000107f, 0.000107f, 0.000107f, 0.000106f, 0.000105f, 0.000106f, 0.000105f,
+ 0.000098f, 0.000090f, 0.000084f, 0.000078f, 0.000073f, 0.000068f, 0.000063f, 0.000063f, 0.000066f, 0.000053f, 0.000080f, 0.000107f,
+ 0.000126f, 0.000150f, 0.000188f, 0.000187f, 0.000206f, 0.000205f, 0.000235f, 0.000242f, 0.000277f, 0.000340f, 0.000323f, 0.000308f,
+ 0.000417f, 0.000411f, 0.000445f, 0.000536f, 0.000622f, 0.000673f, 0.000887f, 0.000985f, 0.001289f, 0.001623f, 0.002337f, 0.003241f,
+ 0.004929f, 0.008560f, 0.016739f, 0.039307f, 0.109619f, 0.317383f, 0.837402f, 0.840332f, 0.841309f, 0.840820f, 0.840820f, 0.841309f,
+ 0.000000f, 0.000106f, 0.000099f, 0.000104f, 0.000102f, 0.000101f, 0.000100f, 0.000101f, 0.000101f, 0.000100f, 0.000099f, 0.000100f,
+ 0.000099f, 0.000099f, 0.000099f, 0.000098f, 0.000098f, 0.000098f, 0.000093f, 0.000086f, 0.000080f, 0.000075f, 0.000070f, 0.000065f,
+ 0.000061f, 0.000057f, 0.000059f, 0.000054f, 0.000061f, 0.000080f, 0.000087f, 0.000101f, 0.000136f, 0.000147f, 0.000163f, 0.000171f,
+ 0.000179f, 0.000205f, 0.000223f, 0.000237f, 0.000281f, 0.000272f, 0.000299f, 0.000364f, 0.000373f, 0.000448f, 0.000507f, 0.000643f,
+ 0.000801f, 0.001000f, 0.001276f, 0.001765f, 0.002712f, 0.004585f, 0.008492f, 0.020462f, 0.063721f, 0.233643f, 0.811035f, 0.813477f,
+ 0.814453f, 0.813965f, 0.813965f, 0.814453f, 0.000000f, 0.000057f, 0.000085f, 0.000085f, 0.000083f, 0.000085f, 0.000087f, 0.000086f,
+ 0.000087f, 0.000087f, 0.000086f, 0.000087f, 0.000087f, 0.000086f, 0.000087f, 0.000087f, 0.000088f, 0.000086f, 0.000088f, 0.000087f,
+ 0.000087f, 0.000081f, 0.000076f, 0.000071f, 0.000067f, 0.000063f, 0.000058f, 0.000055f, 0.000051f, 0.000048f, 0.000046f, 0.000042f,
+ 0.000051f, 0.000063f, 0.000081f, 0.000101f, 0.000122f, 0.000137f, 0.000147f, 0.000143f, 0.000157f, 0.000183f, 0.000205f, 0.000188f,
+ 0.000196f, 0.000249f, 0.000310f, 0.000329f, 0.000413f, 0.000534f, 0.000679f, 0.000944f, 0.001365f, 0.002199f, 0.004150f, 0.009369f,
+ 0.031677f, 0.153564f, 0.779297f, 0.781250f, 0.782227f, 0.782715f, 0.781738f, 0.781250f, 0.000000f, 0.000000f, 0.000000f, 0.000009f,
+ 0.000030f, 0.000048f, 0.000051f, 0.000054f, 0.000055f, 0.000059f, 0.000060f, 0.000065f, 0.000065f, 0.000066f, 0.000068f, 0.000068f,
+ 0.000070f, 0.000070f, 0.000071f, 0.000071f, 0.000072f, 0.000073f, 0.000073f, 0.000073f, 0.000071f, 0.000066f, 0.000062f, 0.000058f,
+ 0.000055f, 0.000051f, 0.000048f, 0.000045f, 0.000042f, 0.000039f, 0.000044f, 0.000036f, 0.000046f, 0.000056f, 0.000067f, 0.000085f,
+ 0.000099f, 0.000108f, 0.000107f, 0.000113f, 0.000139f, 0.000144f, 0.000165f, 0.000169f, 0.000196f, 0.000266f, 0.000311f, 0.000426f,
+ 0.000598f, 0.000948f, 0.001744f, 0.003975f, 0.012856f, 0.084351f, 0.739746f, 0.743164f, 0.743652f, 0.743652f, 0.743652f, 0.743164f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000012f, 0.000012f, 0.000020f,
+ 0.000028f, 0.000030f, 0.000033f, 0.000034f, 0.000041f, 0.000041f, 0.000045f, 0.000047f, 0.000048f, 0.000049f, 0.000051f, 0.000052f,
+ 0.000054f, 0.000054f, 0.000056f, 0.000057f, 0.000056f, 0.000052f, 0.000049f, 0.000046f, 0.000043f, 0.000041f, 0.000038f, 0.000035f,
+ 0.000033f, 0.000031f, 0.000029f, 0.000029f, 0.000036f, 0.000055f, 0.000048f, 0.000067f, 0.000067f, 0.000073f, 0.000075f, 0.000097f,
+ 0.000085f, 0.000111f, 0.000137f, 0.000191f, 0.000233f, 0.000371f, 0.000609f, 0.001319f, 0.004341f, 0.033844f, 0.696289f, 0.698730f,
+ 0.699219f, 0.698242f, 0.698730f, 0.698730f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000003f, 0.000007f,
+ 0.000009f, 0.000012f, 0.000015f, 0.000020f, 0.000022f, 0.000023f, 0.000026f, 0.000029f, 0.000030f, 0.000032f, 0.000033f, 0.000035f,
+ 0.000037f, 0.000037f, 0.000036f, 0.000034f, 0.000032f, 0.000030f, 0.000028f, 0.000026f, 0.000024f, 0.000022f, 0.000021f, 0.000019f,
+ 0.000024f, 0.000024f, 0.000029f, 0.000037f, 0.000043f, 0.000046f, 0.000059f, 0.000058f, 0.000075f, 0.000095f, 0.000160f, 0.000306f,
+ 0.001006f, 0.008865f, 0.643066f, 0.647461f, 0.647949f, 0.647461f, 0.647949f, 0.648438f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000001f, 0.000003f, 0.000005f, 0.000007f, 0.000010f, 0.000012f, 0.000013f, 0.000015f, 0.000017f,
+ 0.000019f, 0.000020f, 0.000018f, 0.000017f, 0.000015f, 0.000014f, 0.000013f, 0.000012f, 0.000010f, 0.000012f, 0.000014f, 0.000018f,
+ 0.000018f, 0.000025f, 0.000028f, 0.000045f, 0.000110f, 0.001030f, 0.586914f, 0.589844f, 0.590820f, 0.591309f, 0.591309f, 0.590820f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000002f, 0.000004f, 0.000005f, 0.000004f, 0.000004f, 0.000003f, 0.000003f, 0.000004f, 0.000009f, 0.527344f, 0.529785f,
+ 0.529785f, 0.530273f, 0.530762f, 0.530762f,
+ },
+ {
+ 0.135132f, 0.377441f, 0.544434f, 0.653320f, 0.724609f, 0.773926f, 0.811035f, 0.838867f, 0.860840f, 0.876465f, 0.891113f, 0.902832f,
+ 0.912109f, 0.920898f, 0.928223f, 0.934082f, 0.938965f, 0.943848f, 0.948242f, 0.952637f, 0.955566f, 0.958984f, 0.961914f, 0.964844f,
+ 0.966797f, 0.969238f, 0.971191f, 0.973145f, 0.975098f, 0.976562f, 0.978027f, 0.979492f, 0.980469f, 0.982422f, 0.983398f, 0.984863f,
+ 0.985840f, 0.986328f, 0.987793f, 0.988770f, 0.989746f, 0.989746f, 0.990234f, 0.991699f, 0.992676f, 0.993164f, 0.993652f, 0.994141f,
+ 0.994629f, 0.995605f, 0.996094f, 0.996582f, 0.997070f, 0.997559f, 0.998047f, 0.998535f, 0.999023f, 0.999512f, 0.999512f, 0.999512f,
+ 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.044891f, 0.163330f, 0.306885f, 0.444336f, 0.559570f, 0.645020f, 0.710938f, 0.760742f,
+ 0.797852f, 0.827148f, 0.850098f, 0.868652f, 0.883789f, 0.895996f, 0.907227f, 0.916016f, 0.923340f, 0.930176f, 0.936523f, 0.941406f,
+ 0.946777f, 0.950684f, 0.954102f, 0.957031f, 0.960938f, 0.963379f, 0.965820f, 0.968262f, 0.970703f, 0.972168f, 0.974609f, 0.976562f,
+ 0.977539f, 0.979492f, 0.980469f, 0.981934f, 0.982910f, 0.984375f, 0.985840f, 0.986816f, 0.987793f, 0.988770f, 0.988770f, 0.990234f,
+ 0.991211f, 0.991699f, 0.992676f, 0.993164f, 0.993164f, 0.994141f, 0.995605f, 0.995605f, 0.996094f, 0.996582f, 0.997070f, 0.997559f,
+ 0.998047f, 0.998535f, 0.999512f, 0.999512f, 0.999512f, 0.999023f, 0.999023f, 0.999023f, 0.020325f, 0.077820f, 0.158936f, 0.260498f,
+ 0.372314f, 0.479736f, 0.572754f, 0.648438f, 0.707520f, 0.754883f, 0.791016f, 0.820312f, 0.843750f, 0.862793f, 0.878906f, 0.891602f,
+ 0.903320f, 0.912598f, 0.920898f, 0.928223f, 0.933594f, 0.939941f, 0.944824f, 0.949219f, 0.952637f, 0.956543f, 0.959961f, 0.962402f,
+ 0.965332f, 0.967773f, 0.970215f, 0.971680f, 0.974121f, 0.976074f, 0.977539f, 0.979004f, 0.980957f, 0.981445f, 0.983398f, 0.984375f,
+ 0.985352f, 0.986328f, 0.987793f, 0.988770f, 0.989746f, 0.990234f, 0.991211f, 0.992188f, 0.992676f, 0.993164f, 0.994141f, 0.994629f,
+ 0.995605f, 0.996094f, 0.996582f, 0.996582f, 0.997559f, 0.998047f, 0.999023f, 0.999023f, 0.999023f, 0.999023f, 0.998535f, 0.998535f,
+ 0.012032f, 0.042908f, 0.088196f, 0.149292f, 0.228027f, 0.319824f, 0.415527f, 0.506348f, 0.586914f, 0.653809f, 0.709473f, 0.752441f,
+ 0.787598f, 0.817383f, 0.840820f, 0.860352f, 0.876465f, 0.889648f, 0.900879f, 0.910156f, 0.918945f, 0.926270f, 0.933105f, 0.938965f,
+ 0.944336f, 0.948730f, 0.952637f, 0.956055f, 0.958984f, 0.962402f, 0.965332f, 0.967773f, 0.970215f, 0.972656f, 0.974609f, 0.976562f,
+ 0.978027f, 0.979492f, 0.980957f, 0.982422f, 0.983887f, 0.984375f, 0.985352f, 0.986816f, 0.987793f, 0.988770f, 0.989746f, 0.990234f,
+ 0.991211f, 0.992188f, 0.993164f, 0.994141f, 0.994629f, 0.995117f, 0.996094f, 0.996094f, 0.996582f, 0.997559f, 0.998535f, 0.998535f,
+ 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.007637f, 0.026825f, 0.053436f, 0.090759f, 0.140137f, 0.203125f, 0.279053f, 0.363281f,
+ 0.449463f, 0.529785f, 0.601562f, 0.663574f, 0.713379f, 0.756348f, 0.789551f, 0.816895f, 0.840332f, 0.858887f, 0.875488f, 0.887695f,
+ 0.900391f, 0.909668f, 0.918945f, 0.926270f, 0.932617f, 0.938477f, 0.943848f, 0.948242f, 0.952148f, 0.955566f, 0.959473f, 0.962402f,
+ 0.965332f, 0.967773f, 0.970215f, 0.972168f, 0.974121f, 0.976562f, 0.978516f, 0.979492f, 0.980957f, 0.981934f, 0.984375f, 0.985352f,
+ 0.985840f, 0.987793f, 0.988281f, 0.989258f, 0.990723f, 0.991211f, 0.991699f, 0.992676f, 0.993652f, 0.994141f, 0.994629f, 0.995605f,
+ 0.996094f, 0.997070f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998535f, 0.998047f, 0.004784f, 0.018082f, 0.035400f, 0.058868f,
+ 0.089783f, 0.130981f, 0.183716f, 0.248047f, 0.321289f, 0.400391f, 0.478760f, 0.552734f, 0.617188f, 0.673828f, 0.720703f, 0.759766f,
+ 0.792480f, 0.818359f, 0.840820f, 0.859863f, 0.875000f, 0.888184f, 0.899902f, 0.910645f, 0.918945f, 0.926270f, 0.931641f, 0.938965f,
+ 0.943848f, 0.948242f, 0.952148f, 0.957031f, 0.959473f, 0.962891f, 0.965332f, 0.968262f, 0.970215f, 0.972656f, 0.975098f, 0.977051f,
+ 0.978516f, 0.979980f, 0.981445f, 0.982910f, 0.984863f, 0.985352f, 0.986328f, 0.987305f, 0.988770f, 0.989746f, 0.990723f, 0.991699f,
+ 0.992676f, 0.993164f, 0.994141f, 0.994629f, 0.995605f, 0.996094f, 0.998047f, 0.998535f, 0.998047f, 0.998047f, 0.998047f, 0.998047f,
+ 0.004044f, 0.012550f, 0.024628f, 0.040466f, 0.060760f, 0.087708f, 0.122742f, 0.167236f, 0.222534f, 0.287109f, 0.358643f, 0.432617f,
+ 0.506348f, 0.573242f, 0.632812f, 0.685059f, 0.728516f, 0.766602f, 0.797363f, 0.822266f, 0.843750f, 0.861328f, 0.877441f, 0.890625f,
+ 0.901367f, 0.910645f, 0.919434f, 0.926758f, 0.933105f, 0.940430f, 0.944824f, 0.948730f, 0.953125f, 0.957520f, 0.960449f, 0.963867f,
+ 0.966309f, 0.969238f, 0.970703f, 0.973633f, 0.976074f, 0.977539f, 0.979004f, 0.980469f, 0.982422f, 0.983398f, 0.984863f, 0.986816f,
+ 0.986816f, 0.988281f, 0.989746f, 0.990723f, 0.991211f, 0.992188f, 0.993164f, 0.994141f, 0.994629f, 0.995117f, 0.998047f, 0.998047f,
+ 0.998047f, 0.998047f, 0.998047f, 0.998047f, 0.002975f, 0.009315f, 0.017868f, 0.029129f, 0.043243f, 0.062012f, 0.084961f, 0.115540f,
+ 0.154419f, 0.201660f, 0.257812f, 0.322754f, 0.391846f, 0.463135f, 0.530762f, 0.594727f, 0.650391f, 0.698730f, 0.739258f, 0.773926f,
+ 0.803711f, 0.826660f, 0.847656f, 0.865723f, 0.879883f, 0.892090f, 0.903809f, 0.913086f, 0.921387f, 0.928223f, 0.935059f, 0.940918f,
+ 0.945801f, 0.950684f, 0.954102f, 0.958008f, 0.961426f, 0.964844f, 0.967285f, 0.970215f, 0.972168f, 0.974609f, 0.976074f, 0.978027f,
+ 0.979980f, 0.981934f, 0.983398f, 0.984375f, 0.985352f, 0.987305f, 0.988281f, 0.989258f, 0.990234f, 0.991211f, 0.992188f, 0.993164f,
+ 0.993652f, 0.994629f, 0.997559f, 0.998047f, 0.998047f, 0.997559f, 0.997559f, 0.997559f, 0.002329f, 0.007256f, 0.013611f, 0.021790f,
+ 0.032043f, 0.044617f, 0.061554f, 0.082336f, 0.108765f, 0.142578f, 0.184448f, 0.234375f, 0.292725f, 0.357422f, 0.424805f, 0.493164f,
+ 0.556641f, 0.615723f, 0.666504f, 0.711914f, 0.750977f, 0.782715f, 0.809570f, 0.832520f, 0.853516f, 0.868652f, 0.882812f, 0.895508f,
+ 0.905762f, 0.916016f, 0.923340f, 0.931152f, 0.936523f, 0.942383f, 0.947266f, 0.951172f, 0.956055f, 0.958984f, 0.962402f, 0.965820f,
+ 0.968750f, 0.971191f, 0.973633f, 0.975586f, 0.977539f, 0.979980f, 0.980957f, 0.982422f, 0.983887f, 0.985352f, 0.985840f, 0.988281f,
+ 0.989746f, 0.990234f, 0.991211f, 0.991699f, 0.993164f, 0.993652f, 0.997070f, 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.997559f,
+ 0.001871f, 0.006084f, 0.010963f, 0.016953f, 0.024277f, 0.033722f, 0.046234f, 0.060669f, 0.079224f, 0.103638f, 0.132812f, 0.169678f,
+ 0.214478f, 0.267090f, 0.326172f, 0.390137f, 0.456543f, 0.519531f, 0.581543f, 0.636230f, 0.685547f, 0.726562f, 0.762207f, 0.792969f,
+ 0.818359f, 0.839844f, 0.858398f, 0.874023f, 0.887695f, 0.898926f, 0.909668f, 0.918945f, 0.926270f, 0.933105f, 0.938965f, 0.944336f,
+ 0.949219f, 0.953613f, 0.958008f, 0.961426f, 0.964844f, 0.967773f, 0.969727f, 0.972168f, 0.974609f, 0.976074f, 0.979004f, 0.979980f,
+ 0.981934f, 0.983887f, 0.985352f, 0.986328f, 0.987793f, 0.989746f, 0.989746f, 0.990723f, 0.991211f, 0.992676f, 0.996582f, 0.997070f,
+ 0.997559f, 0.997070f, 0.997070f, 0.997070f, 0.001322f, 0.004795f, 0.008530f, 0.013504f, 0.018921f, 0.026154f, 0.035065f, 0.045807f,
+ 0.059662f, 0.076416f, 0.098267f, 0.124512f, 0.157715f, 0.197388f, 0.244873f, 0.299805f, 0.359619f, 0.423096f, 0.487549f, 0.549316f,
+ 0.605957f, 0.657715f, 0.703125f, 0.741211f, 0.774902f, 0.802734f, 0.827148f, 0.847656f, 0.865234f, 0.879883f, 0.893066f, 0.903320f,
+ 0.913086f, 0.920898f, 0.929199f, 0.935547f, 0.941406f, 0.947266f, 0.951172f, 0.956055f, 0.959473f, 0.962891f, 0.965332f, 0.969238f,
+ 0.971191f, 0.974121f, 0.976562f, 0.977539f, 0.979980f, 0.981445f, 0.982910f, 0.984863f, 0.986328f, 0.988281f, 0.988281f, 0.989746f,
+ 0.990723f, 0.991699f, 0.996582f, 0.996582f, 0.997070f, 0.997070f, 0.997070f, 0.996582f, 0.001077f, 0.003971f, 0.006985f, 0.010750f,
+ 0.015579f, 0.020920f, 0.027420f, 0.035522f, 0.045776f, 0.058228f, 0.074097f, 0.093140f, 0.117310f, 0.146851f, 0.182495f, 0.225952f,
+ 0.276611f, 0.332764f, 0.394287f, 0.456543f, 0.518555f, 0.577637f, 0.630371f, 0.679199f, 0.720703f, 0.756836f, 0.787598f, 0.813477f,
+ 0.836426f, 0.855469f, 0.872070f, 0.885742f, 0.897949f, 0.908203f, 0.917480f, 0.925293f, 0.933105f, 0.939453f, 0.944336f, 0.949219f,
+ 0.954590f, 0.957520f, 0.961426f, 0.964844f, 0.968262f, 0.970703f, 0.974121f, 0.975586f, 0.978027f, 0.979492f, 0.981445f, 0.983398f,
+ 0.984863f, 0.986328f, 0.987793f, 0.988770f, 0.989746f, 0.991211f, 0.996094f, 0.996582f, 0.996582f, 0.996582f, 0.996582f, 0.996582f,
+ 0.000954f, 0.003330f, 0.005733f, 0.008904f, 0.012505f, 0.016617f, 0.022446f, 0.028351f, 0.036041f, 0.045807f, 0.056854f, 0.071350f,
+ 0.088867f, 0.110596f, 0.137451f, 0.170654f, 0.209717f, 0.256592f, 0.309326f, 0.366943f, 0.427979f, 0.489502f, 0.549316f, 0.604980f,
+ 0.655762f, 0.700195f, 0.738770f, 0.772461f, 0.801270f, 0.825195f, 0.845703f, 0.864258f, 0.879395f, 0.893066f, 0.903809f, 0.914062f,
+ 0.922363f, 0.929688f, 0.936523f, 0.942871f, 0.947266f, 0.952148f, 0.956055f, 0.960449f, 0.963867f, 0.966797f, 0.969727f, 0.972656f,
+ 0.975586f, 0.976562f, 0.979004f, 0.981445f, 0.982910f, 0.984375f, 0.985840f, 0.986816f, 0.988770f, 0.989746f, 0.995605f, 0.996094f,
+ 0.996094f, 0.996094f, 0.996094f, 0.996094f, 0.000949f, 0.002804f, 0.004730f, 0.007236f, 0.010384f, 0.014160f, 0.018478f, 0.023102f,
+ 0.028992f, 0.036346f, 0.044647f, 0.055542f, 0.068481f, 0.085144f, 0.105286f, 0.130005f, 0.159668f, 0.195557f, 0.238647f, 0.287842f,
+ 0.343018f, 0.402588f, 0.463135f, 0.522949f, 0.580566f, 0.632812f, 0.680664f, 0.721680f, 0.757812f, 0.788574f, 0.814453f, 0.836914f,
+ 0.856934f, 0.872070f, 0.887207f, 0.899414f, 0.909668f, 0.918945f, 0.926758f, 0.933594f, 0.940430f, 0.946289f, 0.950684f, 0.954590f,
+ 0.959473f, 0.963379f, 0.966797f, 0.969238f, 0.972168f, 0.975098f, 0.977051f, 0.979492f, 0.980957f, 0.982910f, 0.984375f, 0.986328f,
+ 0.987793f, 0.988770f, 0.995117f, 0.996094f, 0.995605f, 0.996094f, 0.996094f, 0.995605f, 0.000828f, 0.002361f, 0.004116f, 0.006119f,
+ 0.008797f, 0.011391f, 0.014854f, 0.018890f, 0.023666f, 0.029083f, 0.036011f, 0.044434f, 0.053986f, 0.066589f, 0.081543f, 0.100159f,
+ 0.122314f, 0.149536f, 0.183350f, 0.222900f, 0.269043f, 0.321533f, 0.378418f, 0.438477f, 0.499023f, 0.556641f, 0.611328f, 0.661133f,
+ 0.703613f, 0.742188f, 0.775391f, 0.804199f, 0.828613f, 0.849121f, 0.866211f, 0.881348f, 0.894043f, 0.905762f, 0.916016f, 0.924316f,
+ 0.931641f, 0.938477f, 0.944336f, 0.949707f, 0.954590f, 0.958496f, 0.962402f, 0.966309f, 0.969238f, 0.972168f, 0.974121f, 0.977051f,
+ 0.979004f, 0.980957f, 0.982910f, 0.984863f, 0.985840f, 0.987793f, 0.995117f, 0.995605f, 0.995605f, 0.995605f, 0.995605f, 0.995605f,
+ 0.000606f, 0.001948f, 0.003483f, 0.005394f, 0.007290f, 0.009735f, 0.012352f, 0.015747f, 0.019485f, 0.023788f, 0.029358f, 0.035706f,
+ 0.043732f, 0.053162f, 0.064331f, 0.077942f, 0.094971f, 0.116089f, 0.140991f, 0.172485f, 0.209473f, 0.252686f, 0.302002f, 0.356934f,
+ 0.415283f, 0.475830f, 0.534180f, 0.589844f, 0.641602f, 0.687500f, 0.728516f, 0.763184f, 0.792969f, 0.819336f, 0.841309f, 0.860840f,
+ 0.876953f, 0.890625f, 0.902344f, 0.913086f, 0.921875f, 0.930176f, 0.937012f, 0.943359f, 0.948242f, 0.954102f, 0.958008f, 0.961914f,
+ 0.965820f, 0.969238f, 0.971680f, 0.974609f, 0.977051f, 0.979004f, 0.981445f, 0.983398f, 0.984863f, 0.986816f, 0.994141f, 0.994629f,
+ 0.995117f, 0.995117f, 0.995117f, 0.994629f, 0.000672f, 0.001569f, 0.002895f, 0.004528f, 0.006180f, 0.008324f, 0.010864f, 0.013161f,
+ 0.016357f, 0.020096f, 0.024216f, 0.029327f, 0.035583f, 0.042664f, 0.051453f, 0.062073f, 0.075012f, 0.091125f, 0.110291f, 0.134155f,
+ 0.162476f, 0.197266f, 0.238037f, 0.285156f, 0.337646f, 0.395020f, 0.454590f, 0.513672f, 0.570312f, 0.624023f, 0.672363f, 0.714844f,
+ 0.750977f, 0.783691f, 0.811035f, 0.834473f, 0.854004f, 0.872070f, 0.886230f, 0.899414f, 0.911133f, 0.918945f, 0.928223f, 0.936035f,
+ 0.942871f, 0.948242f, 0.953613f, 0.957031f, 0.961426f, 0.965820f, 0.968750f, 0.972168f, 0.974121f, 0.976562f, 0.979492f, 0.981445f,
+ 0.983398f, 0.985352f, 0.994141f, 0.994629f, 0.995117f, 0.995117f, 0.995117f, 0.994629f, 0.000413f, 0.001430f, 0.002577f, 0.004269f,
+ 0.005703f, 0.007137f, 0.008888f, 0.011124f, 0.013885f, 0.016891f, 0.020355f, 0.024384f, 0.029221f, 0.035217f, 0.041748f, 0.049988f,
+ 0.060059f, 0.072083f, 0.086914f, 0.105286f, 0.126953f, 0.154175f, 0.186523f, 0.224731f, 0.269287f, 0.320557f, 0.375732f, 0.434570f,
+ 0.493896f, 0.552246f, 0.606934f, 0.655762f, 0.701660f, 0.740723f, 0.774902f, 0.803711f, 0.827637f, 0.848633f, 0.867188f, 0.882812f,
+ 0.895996f, 0.908203f, 0.917969f, 0.926758f, 0.934570f, 0.941895f, 0.947266f, 0.952637f, 0.957520f, 0.960938f, 0.965820f, 0.968750f,
+ 0.971680f, 0.974609f, 0.977051f, 0.979980f, 0.981934f, 0.983887f, 0.993652f, 0.994629f, 0.994141f, 0.994141f, 0.994141f, 0.994141f,
+ 0.000240f, 0.001406f, 0.002373f, 0.003283f, 0.004620f, 0.006264f, 0.007744f, 0.009552f, 0.011711f, 0.014069f, 0.017273f, 0.020584f,
+ 0.024429f, 0.028946f, 0.034393f, 0.041046f, 0.048798f, 0.058289f, 0.070312f, 0.083618f, 0.100403f, 0.121338f, 0.146118f, 0.177002f,
+ 0.213257f, 0.255371f, 0.304443f, 0.358887f, 0.416504f, 0.476562f, 0.534668f, 0.590332f, 0.642090f, 0.688965f, 0.729492f, 0.766113f,
+ 0.796387f, 0.822754f, 0.844727f, 0.862305f, 0.880371f, 0.894043f, 0.905762f, 0.916992f, 0.926270f, 0.934082f, 0.940918f, 0.946777f,
+ 0.953125f, 0.956543f, 0.961426f, 0.964844f, 0.969238f, 0.972656f, 0.974609f, 0.977539f, 0.979980f, 0.982422f, 0.992676f, 0.994141f,
+ 0.993652f, 0.993652f, 0.993652f, 0.993652f, 0.000242f, 0.001257f, 0.001991f, 0.003138f, 0.004299f, 0.005302f, 0.006584f, 0.008308f,
+ 0.010048f, 0.012283f, 0.014526f, 0.017578f, 0.020340f, 0.023972f, 0.028671f, 0.033661f, 0.040161f, 0.047821f, 0.056213f, 0.067261f,
+ 0.080444f, 0.096191f, 0.115784f, 0.139771f, 0.168457f, 0.203125f, 0.243286f, 0.290527f, 0.343506f, 0.400879f, 0.459473f, 0.519043f,
+ 0.576172f, 0.629395f, 0.678223f, 0.721191f, 0.757324f, 0.789062f, 0.816895f, 0.839844f, 0.859863f, 0.877930f, 0.892578f, 0.904297f,
+ 0.915527f, 0.925293f, 0.933105f, 0.940430f, 0.946777f, 0.952148f, 0.957031f, 0.961914f, 0.965820f, 0.969238f, 0.973145f, 0.975586f,
+ 0.978516f, 0.980469f, 0.992188f, 0.993652f, 0.993164f, 0.993164f, 0.993652f, 0.993164f, 0.000434f, 0.001172f, 0.001865f, 0.002825f,
+ 0.003633f, 0.004757f, 0.005722f, 0.007175f, 0.009010f, 0.010651f, 0.012520f, 0.014412f, 0.017532f, 0.020599f, 0.024139f, 0.028488f,
+ 0.033356f, 0.039001f, 0.046295f, 0.054749f, 0.064758f, 0.077209f, 0.092834f, 0.111084f, 0.134033f, 0.160767f, 0.193604f, 0.233032f,
+ 0.278320f, 0.329590f, 0.386230f, 0.445068f, 0.504395f, 0.563477f, 0.617188f, 0.666504f, 0.711426f, 0.750000f, 0.783691f, 0.812500f,
+ 0.836426f, 0.857422f, 0.875488f, 0.891113f, 0.903809f, 0.915039f, 0.924805f, 0.933105f, 0.940430f, 0.947266f, 0.953125f, 0.958496f,
+ 0.962402f, 0.966309f, 0.969727f, 0.973145f, 0.976562f, 0.978516f, 0.991699f, 0.992188f, 0.992676f, 0.993164f, 0.993164f, 0.992676f,
+ 0.000358f, 0.000835f, 0.001738f, 0.002270f, 0.002996f, 0.004078f, 0.005157f, 0.006416f, 0.007904f, 0.009331f, 0.010826f, 0.012245f,
+ 0.014938f, 0.017303f, 0.020233f, 0.023926f, 0.027954f, 0.032715f, 0.038147f, 0.045166f, 0.053070f, 0.062561f, 0.074768f, 0.089661f,
+ 0.106689f, 0.128052f, 0.154175f, 0.185547f, 0.223022f, 0.266846f, 0.317383f, 0.373047f, 0.431152f, 0.491943f, 0.550293f, 0.606445f,
+ 0.658203f, 0.704102f, 0.744141f, 0.779297f, 0.809082f, 0.833984f, 0.855957f, 0.875000f, 0.889648f, 0.903320f, 0.915039f, 0.924805f,
+ 0.933594f, 0.940918f, 0.947754f, 0.954102f, 0.958984f, 0.962402f, 0.966797f, 0.970703f, 0.974121f, 0.977539f, 0.990723f, 0.992188f,
+ 0.992676f, 0.992676f, 0.992188f, 0.992676f, 0.000428f, 0.000789f, 0.001460f, 0.002172f, 0.002695f, 0.003561f, 0.004608f, 0.005848f,
+ 0.006886f, 0.007736f, 0.009560f, 0.011078f, 0.012817f, 0.015015f, 0.017563f, 0.020157f, 0.023666f, 0.027145f, 0.031891f, 0.037384f,
+ 0.044189f, 0.051788f, 0.061188f, 0.072327f, 0.085999f, 0.102966f, 0.123413f, 0.148071f, 0.178101f, 0.214478f, 0.256836f, 0.306396f,
+ 0.360840f, 0.419678f, 0.479736f, 0.540527f, 0.597656f, 0.649902f, 0.697754f, 0.738770f, 0.775391f, 0.805664f, 0.831543f, 0.854004f,
+ 0.873535f, 0.889160f, 0.902832f, 0.915039f, 0.925293f, 0.934082f, 0.941895f, 0.948730f, 0.954102f, 0.959961f, 0.963867f, 0.968262f,
+ 0.971680f, 0.975586f, 0.990723f, 0.991699f, 0.991699f, 0.991699f, 0.991699f, 0.991211f, 0.000237f, 0.000782f, 0.001245f, 0.001923f,
+ 0.002417f, 0.003225f, 0.004101f, 0.005062f, 0.005920f, 0.007030f, 0.008102f, 0.009743f, 0.011009f, 0.013054f, 0.015190f, 0.017380f,
+ 0.020126f, 0.023346f, 0.027161f, 0.031464f, 0.036316f, 0.042664f, 0.050110f, 0.058807f, 0.069946f, 0.083191f, 0.099121f, 0.118835f,
+ 0.142822f, 0.171997f, 0.206665f, 0.248413f, 0.296143f, 0.350586f, 0.408936f, 0.469727f, 0.530762f, 0.589844f, 0.643555f, 0.691895f,
+ 0.734375f, 0.772461f, 0.803223f, 0.830566f, 0.854492f, 0.873047f, 0.889648f, 0.903809f, 0.916016f, 0.926270f, 0.935059f, 0.943359f,
+ 0.949219f, 0.955566f, 0.960938f, 0.965332f, 0.969727f, 0.973145f, 0.989746f, 0.990723f, 0.990723f, 0.990723f, 0.991211f, 0.990723f,
+ 0.000243f, 0.000793f, 0.001210f, 0.001616f, 0.002260f, 0.003069f, 0.003649f, 0.004444f, 0.005322f, 0.006088f, 0.006954f, 0.008278f,
+ 0.009766f, 0.011139f, 0.012970f, 0.014908f, 0.016968f, 0.019897f, 0.023193f, 0.026962f, 0.030792f, 0.035522f, 0.041931f, 0.048920f,
+ 0.057404f, 0.067993f, 0.080383f, 0.095825f, 0.114929f, 0.137695f, 0.165771f, 0.199585f, 0.241089f, 0.287842f, 0.341553f, 0.400391f,
+ 0.462402f, 0.523438f, 0.583008f, 0.638184f, 0.687988f, 0.732422f, 0.770020f, 0.802246f, 0.830566f, 0.854004f, 0.873047f, 0.891113f,
+ 0.904785f, 0.916992f, 0.926758f, 0.936523f, 0.943848f, 0.951172f, 0.956543f, 0.961914f, 0.966797f, 0.971191f, 0.989258f, 0.990234f,
+ 0.990234f, 0.990234f, 0.990234f, 0.989746f, 0.000000f, 0.000484f, 0.000973f, 0.001453f, 0.001999f, 0.002689f, 0.003359f, 0.003864f,
+ 0.004726f, 0.005444f, 0.006516f, 0.007404f, 0.008461f, 0.009720f, 0.011261f, 0.012985f, 0.014908f, 0.017120f, 0.019699f, 0.022614f,
+ 0.026093f, 0.030228f, 0.034668f, 0.040619f, 0.047699f, 0.055756f, 0.066284f, 0.078308f, 0.092834f, 0.111328f, 0.133423f, 0.160889f,
+ 0.194214f, 0.233765f, 0.281006f, 0.334473f, 0.392822f, 0.455078f, 0.517090f, 0.578125f, 0.634766f, 0.686035f, 0.730957f, 0.768555f,
+ 0.803223f, 0.831055f, 0.854492f, 0.875488f, 0.892090f, 0.906250f, 0.918457f, 0.929688f, 0.937988f, 0.945801f, 0.952148f, 0.958496f,
+ 0.963867f, 0.968750f, 0.988281f, 0.989258f, 0.989746f, 0.989258f, 0.989746f, 0.989258f, 0.000241f, 0.000699f, 0.000835f, 0.001354f,
+ 0.002066f, 0.002405f, 0.003073f, 0.003466f, 0.003847f, 0.004868f, 0.005798f, 0.006325f, 0.007446f, 0.008553f, 0.009789f, 0.011375f,
+ 0.013031f, 0.014702f, 0.016937f, 0.019455f, 0.022171f, 0.025467f, 0.029541f, 0.034271f, 0.039734f, 0.046295f, 0.054291f, 0.063904f,
+ 0.075745f, 0.089966f, 0.107727f, 0.129395f, 0.156250f, 0.188965f, 0.228394f, 0.274658f, 0.327637f, 0.386963f, 0.449219f, 0.512695f,
+ 0.574707f, 0.632324f, 0.684570f, 0.730469f, 0.770508f, 0.804688f, 0.832520f, 0.857422f, 0.876953f, 0.893066f, 0.908691f, 0.920410f,
+ 0.931152f, 0.940430f, 0.947754f, 0.954590f, 0.960938f, 0.965820f, 0.986816f, 0.988770f, 0.988770f, 0.988770f, 0.988770f, 0.988770f,
+ 0.000122f, 0.000480f, 0.000793f, 0.001184f, 0.001847f, 0.002220f, 0.002459f, 0.003109f, 0.003740f, 0.004234f, 0.005127f, 0.005730f,
+ 0.006557f, 0.007458f, 0.008469f, 0.009911f, 0.011162f, 0.012848f, 0.014519f, 0.016693f, 0.019135f, 0.021820f, 0.025024f, 0.028931f,
+ 0.033508f, 0.038757f, 0.045135f, 0.052856f, 0.062042f, 0.073547f, 0.087646f, 0.104736f, 0.126099f, 0.152588f, 0.184570f, 0.223511f,
+ 0.269775f, 0.323242f, 0.382324f, 0.445801f, 0.510254f, 0.573242f, 0.631348f, 0.685059f, 0.731934f, 0.772461f, 0.806641f, 0.834961f,
+ 0.859375f, 0.879883f, 0.897461f, 0.911133f, 0.923828f, 0.933594f, 0.942383f, 0.950195f, 0.956055f, 0.962402f, 0.985840f, 0.987305f,
+ 0.987793f, 0.987793f, 0.988281f, 0.987793f, 0.000244f, 0.000471f, 0.000666f, 0.001267f, 0.001592f, 0.001838f, 0.002251f, 0.002855f,
+ 0.003225f, 0.003828f, 0.004372f, 0.005112f, 0.005695f, 0.006340f, 0.007534f, 0.008797f, 0.009895f, 0.011215f, 0.012604f, 0.014503f,
+ 0.016602f, 0.018738f, 0.021408f, 0.024567f, 0.028305f, 0.032654f, 0.037872f, 0.043732f, 0.051239f, 0.060669f, 0.071716f, 0.085510f,
+ 0.102356f, 0.123230f, 0.149170f, 0.180664f, 0.219849f, 0.265869f, 0.319092f, 0.379150f, 0.443604f, 0.508789f, 0.572754f, 0.633301f,
+ 0.686523f, 0.734863f, 0.775391f, 0.809570f, 0.838379f, 0.862305f, 0.883301f, 0.900391f, 0.914551f, 0.926270f, 0.937012f, 0.944824f,
+ 0.953125f, 0.959473f, 0.985352f, 0.986816f, 0.986816f, 0.986816f, 0.986816f, 0.986816f, 0.000242f, 0.000346f, 0.000827f, 0.001065f,
+ 0.001428f, 0.001572f, 0.001984f, 0.002367f, 0.002851f, 0.003277f, 0.003786f, 0.004501f, 0.005253f, 0.005955f, 0.006573f, 0.007736f,
+ 0.008659f, 0.009880f, 0.011177f, 0.012459f, 0.014153f, 0.016403f, 0.018173f, 0.020859f, 0.024017f, 0.027496f, 0.031708f, 0.036682f,
+ 0.042877f, 0.050446f, 0.059174f, 0.070068f, 0.083374f, 0.100159f, 0.120728f, 0.145874f, 0.177612f, 0.216187f, 0.262695f, 0.316650f,
+ 0.377686f, 0.443115f, 0.509766f, 0.575195f, 0.635742f, 0.691406f, 0.738281f, 0.779785f, 0.813965f, 0.843750f, 0.866699f, 0.887207f,
+ 0.904297f, 0.918945f, 0.930176f, 0.940918f, 0.948730f, 0.956055f, 0.984375f, 0.985840f, 0.985840f, 0.985840f, 0.986328f, 0.985840f,
+ 0.000242f, 0.000540f, 0.000708f, 0.000830f, 0.001143f, 0.001451f, 0.001861f, 0.002249f, 0.002661f, 0.003010f, 0.003435f, 0.003922f,
+ 0.004707f, 0.005165f, 0.005787f, 0.006840f, 0.007374f, 0.008545f, 0.009651f, 0.011147f, 0.012581f, 0.014084f, 0.015991f, 0.017899f,
+ 0.020325f, 0.023392f, 0.026978f, 0.031113f, 0.035919f, 0.042023f, 0.049103f, 0.057831f, 0.068420f, 0.081543f, 0.098145f, 0.118530f,
+ 0.143921f, 0.175293f, 0.213989f, 0.260742f, 0.316162f, 0.377441f, 0.444336f, 0.512207f, 0.579590f, 0.641113f, 0.696289f, 0.744629f,
+ 0.786621f, 0.820801f, 0.849609f, 0.872559f, 0.892578f, 0.908691f, 0.922363f, 0.934570f, 0.944336f, 0.951660f, 0.982910f, 0.984375f,
+ 0.984863f, 0.984863f, 0.985352f, 0.984863f, 0.000106f, 0.000477f, 0.000649f, 0.000901f, 0.001110f, 0.001206f, 0.001630f, 0.002121f,
+ 0.002192f, 0.002743f, 0.003128f, 0.003538f, 0.003941f, 0.004688f, 0.005276f, 0.005905f, 0.006546f, 0.007568f, 0.008461f, 0.009483f,
+ 0.010674f, 0.011864f, 0.013649f, 0.015549f, 0.017731f, 0.020111f, 0.023010f, 0.026199f, 0.030304f, 0.035278f, 0.040833f, 0.047821f,
+ 0.056580f, 0.066895f, 0.079895f, 0.096191f, 0.116760f, 0.141968f, 0.173584f, 0.212646f, 0.260498f, 0.316162f, 0.379883f, 0.447754f,
+ 0.517578f, 0.584961f, 0.647949f, 0.704102f, 0.752930f, 0.792969f, 0.827148f, 0.855957f, 0.877930f, 0.898438f, 0.914062f, 0.928223f,
+ 0.938965f, 0.948242f, 0.981445f, 0.983398f, 0.983887f, 0.983887f, 0.983887f, 0.983398f, 0.000208f, 0.000456f, 0.000582f, 0.000788f,
+ 0.001016f, 0.001428f, 0.001507f, 0.001769f, 0.002203f, 0.002525f, 0.002718f, 0.003187f, 0.003761f, 0.004238f, 0.004635f, 0.005348f,
+ 0.005901f, 0.006805f, 0.007500f, 0.008545f, 0.009270f, 0.010437f, 0.011742f, 0.013344f, 0.015198f, 0.017242f, 0.019516f, 0.022430f,
+ 0.025665f, 0.029922f, 0.034180f, 0.040161f, 0.046936f, 0.055420f, 0.065735f, 0.078552f, 0.094666f, 0.114563f, 0.140503f, 0.172485f,
+ 0.212646f, 0.260986f, 0.318359f, 0.383545f, 0.453125f, 0.524414f, 0.593750f, 0.656738f, 0.712891f, 0.761230f, 0.801270f, 0.835938f,
+ 0.862305f, 0.885742f, 0.904785f, 0.919922f, 0.933594f, 0.943359f, 0.980469f, 0.982422f, 0.982422f, 0.981934f, 0.982422f, 0.982422f,
+ 0.000170f, 0.000350f, 0.000583f, 0.000682f, 0.000845f, 0.001036f, 0.001265f, 0.001821f, 0.001953f, 0.002163f, 0.002525f, 0.002771f,
+ 0.003418f, 0.003729f, 0.004040f, 0.004871f, 0.005188f, 0.005726f, 0.006512f, 0.007130f, 0.008087f, 0.009018f, 0.010216f, 0.011490f,
+ 0.013084f, 0.014565f, 0.016891f, 0.019073f, 0.021851f, 0.025253f, 0.029022f, 0.033539f, 0.039124f, 0.045563f, 0.054230f, 0.064270f,
+ 0.077271f, 0.093323f, 0.113403f, 0.139648f, 0.172485f, 0.213379f, 0.262939f, 0.322266f, 0.389404f, 0.461426f, 0.534180f, 0.604492f,
+ 0.668457f, 0.724609f, 0.772461f, 0.812500f, 0.845703f, 0.872070f, 0.894043f, 0.911621f, 0.926758f, 0.938477f, 0.979004f, 0.980469f,
+ 0.980957f, 0.980957f, 0.980957f, 0.980957f, 0.000000f, 0.000332f, 0.000583f, 0.000583f, 0.000848f, 0.000959f, 0.001125f, 0.001425f,
+ 0.001810f, 0.001899f, 0.002300f, 0.002529f, 0.002996f, 0.003162f, 0.003607f, 0.004150f, 0.004761f, 0.005146f, 0.005791f, 0.006329f,
+ 0.007099f, 0.008110f, 0.008949f, 0.009941f, 0.011253f, 0.012756f, 0.014565f, 0.016434f, 0.018707f, 0.021271f, 0.024475f, 0.028290f,
+ 0.032745f, 0.037964f, 0.044769f, 0.052795f, 0.063416f, 0.076050f, 0.092102f, 0.113464f, 0.139526f, 0.172974f, 0.214600f, 0.266602f,
+ 0.327637f, 0.397461f, 0.471191f, 0.546387f, 0.617188f, 0.682129f, 0.737793f, 0.784668f, 0.823730f, 0.854980f, 0.881348f, 0.902344f,
+ 0.918945f, 0.933105f, 0.977539f, 0.979492f, 0.979492f, 0.979492f, 0.979492f, 0.979492f, 0.000000f, 0.000243f, 0.000553f, 0.000575f,
+ 0.000591f, 0.000798f, 0.000991f, 0.001234f, 0.001419f, 0.001812f, 0.001935f, 0.002186f, 0.002518f, 0.002975f, 0.003202f, 0.003614f,
+ 0.004047f, 0.004425f, 0.005013f, 0.005718f, 0.006172f, 0.007046f, 0.007740f, 0.008835f, 0.009819f, 0.011192f, 0.012444f, 0.014114f,
+ 0.015884f, 0.018204f, 0.020844f, 0.023392f, 0.027420f, 0.031921f, 0.037170f, 0.043610f, 0.052032f, 0.062408f, 0.075256f, 0.091675f,
+ 0.112610f, 0.140015f, 0.173950f, 0.217651f, 0.271973f, 0.335693f, 0.407715f, 0.484619f, 0.561035f, 0.633789f, 0.698242f, 0.752930f,
+ 0.798828f, 0.836426f, 0.867676f, 0.891602f, 0.911621f, 0.926270f, 0.975098f, 0.977539f, 0.978516f, 0.977539f, 0.977539f, 0.978027f,
+ 0.000121f, 0.000121f, 0.000241f, 0.000385f, 0.000684f, 0.000693f, 0.000932f, 0.001156f, 0.001410f, 0.001648f, 0.001893f, 0.002184f,
+ 0.002367f, 0.002579f, 0.002872f, 0.003319f, 0.003653f, 0.003922f, 0.004425f, 0.004925f, 0.005436f, 0.006180f, 0.006836f, 0.007645f,
+ 0.008278f, 0.009476f, 0.010788f, 0.012169f, 0.013695f, 0.015305f, 0.017319f, 0.020111f, 0.022858f, 0.026718f, 0.030975f, 0.036255f,
+ 0.042938f, 0.051270f, 0.061493f, 0.074768f, 0.091187f, 0.112976f, 0.140747f, 0.176392f, 0.222168f, 0.278809f, 0.345703f, 0.421387f,
+ 0.500488f, 0.578613f, 0.651855f, 0.715820f, 0.769531f, 0.813965f, 0.850586f, 0.878418f, 0.901855f, 0.920410f, 0.973633f, 0.975586f,
+ 0.976074f, 0.976562f, 0.976562f, 0.975098f, 0.000240f, 0.000120f, 0.000281f, 0.000333f, 0.000498f, 0.000680f, 0.000684f, 0.001083f,
+ 0.001312f, 0.001618f, 0.001606f, 0.001834f, 0.002087f, 0.002316f, 0.002735f, 0.002792f, 0.003084f, 0.003386f, 0.003944f, 0.004353f,
+ 0.004761f, 0.005390f, 0.005997f, 0.006615f, 0.007389f, 0.008324f, 0.008987f, 0.010284f, 0.011703f, 0.013382f, 0.014717f, 0.016953f,
+ 0.019424f, 0.022278f, 0.026047f, 0.030029f, 0.035492f, 0.042145f, 0.050446f, 0.060608f, 0.073975f, 0.091187f, 0.113831f, 0.142700f,
+ 0.180176f, 0.228271f, 0.288086f, 0.359131f, 0.437988f, 0.519531f, 0.600098f, 0.673340f, 0.735352f, 0.787598f, 0.830566f, 0.865234f,
+ 0.891602f, 0.913086f, 0.971680f, 0.974121f, 0.974121f, 0.974121f, 0.974121f, 0.974609f, 0.000000f, 0.000239f, 0.000236f, 0.000425f,
+ 0.000487f, 0.000608f, 0.000850f, 0.001012f, 0.001140f, 0.001260f, 0.001410f, 0.001640f, 0.001953f, 0.002003f, 0.002342f, 0.002434f,
+ 0.002686f, 0.002934f, 0.003305f, 0.003771f, 0.004169f, 0.004692f, 0.005028f, 0.005817f, 0.006371f, 0.007179f, 0.007919f, 0.008965f,
+ 0.009857f, 0.011261f, 0.012703f, 0.014229f, 0.016312f, 0.018494f, 0.021744f, 0.025024f, 0.029633f, 0.034790f, 0.041199f, 0.049561f,
+ 0.060242f, 0.073608f, 0.091675f, 0.114502f, 0.144897f, 0.185547f, 0.236328f, 0.300049f, 0.375732f, 0.458496f, 0.542969f, 0.624023f,
+ 0.696289f, 0.758301f, 0.808105f, 0.847656f, 0.879395f, 0.903809f, 0.968750f, 0.971191f, 0.972168f, 0.971680f, 0.972168f, 0.971680f,
+ 0.000000f, 0.000217f, 0.000235f, 0.000235f, 0.000321f, 0.000560f, 0.000588f, 0.000897f, 0.001034f, 0.001040f, 0.001246f, 0.001369f,
+ 0.001611f, 0.001692f, 0.001942f, 0.002153f, 0.002337f, 0.002638f, 0.002878f, 0.003330f, 0.003672f, 0.003986f, 0.004498f, 0.004826f,
+ 0.005535f, 0.006176f, 0.006561f, 0.007538f, 0.008362f, 0.009544f, 0.010612f, 0.011879f, 0.013794f, 0.015839f, 0.018326f, 0.020889f,
+ 0.024567f, 0.028625f, 0.033783f, 0.040527f, 0.049133f, 0.059998f, 0.073608f, 0.092041f, 0.116394f, 0.148682f, 0.191528f, 0.246582f,
+ 0.315186f, 0.395508f, 0.482910f, 0.570312f, 0.651367f, 0.722168f, 0.781738f, 0.828613f, 0.866211f, 0.895508f, 0.966797f, 0.968750f,
+ 0.969238f, 0.969727f, 0.969238f, 0.969238f, 0.000000f, 0.000108f, 0.000215f, 0.000346f, 0.000352f, 0.000501f, 0.000783f, 0.000828f,
+ 0.000954f, 0.000980f, 0.001130f, 0.001353f, 0.001429f, 0.001522f, 0.001690f, 0.001760f, 0.002172f, 0.002363f, 0.002522f, 0.002777f,
+ 0.003202f, 0.003550f, 0.004040f, 0.004364f, 0.004734f, 0.005192f, 0.005909f, 0.006271f, 0.007015f, 0.007957f, 0.008774f, 0.010185f,
+ 0.011681f, 0.013306f, 0.015327f, 0.017517f, 0.020264f, 0.023636f, 0.027740f, 0.033234f, 0.039856f, 0.048340f, 0.059387f, 0.074097f,
+ 0.093567f, 0.118896f, 0.153931f, 0.200073f, 0.260254f, 0.334473f, 0.420410f, 0.511719f, 0.601562f, 0.682129f, 0.750488f, 0.807617f,
+ 0.851074f, 0.884277f, 0.963867f, 0.966309f, 0.966797f, 0.966797f, 0.966797f, 0.966797f, 0.000000f, 0.000059f, 0.000292f, 0.000331f,
+ 0.000344f, 0.000613f, 0.000532f, 0.000703f, 0.000853f, 0.000915f, 0.000936f, 0.001102f, 0.001284f, 0.001430f, 0.001417f, 0.001475f,
+ 0.001791f, 0.001989f, 0.002161f, 0.002388f, 0.002775f, 0.003017f, 0.003357f, 0.003763f, 0.004124f, 0.004383f, 0.004917f, 0.005436f,
+ 0.005840f, 0.006733f, 0.007511f, 0.008667f, 0.009567f, 0.011032f, 0.012474f, 0.014610f, 0.016739f, 0.019379f, 0.022873f, 0.027252f,
+ 0.032410f, 0.039062f, 0.048065f, 0.059296f, 0.074646f, 0.094971f, 0.123108f, 0.161011f, 0.211426f, 0.277344f, 0.358154f, 0.450195f,
+ 0.545410f, 0.636230f, 0.715332f, 0.781250f, 0.832520f, 0.872070f, 0.960449f, 0.962402f, 0.963867f, 0.963379f, 0.962891f, 0.963379f,
+ 0.000000f, 0.000000f, 0.000098f, 0.000301f, 0.000315f, 0.000566f, 0.000587f, 0.000627f, 0.000643f, 0.000795f, 0.000974f, 0.001023f,
+ 0.000987f, 0.001031f, 0.001245f, 0.001470f, 0.001637f, 0.001820f, 0.001884f, 0.002146f, 0.002357f, 0.002630f, 0.002913f, 0.003164f,
+ 0.003380f, 0.003824f, 0.004189f, 0.004353f, 0.004940f, 0.005688f, 0.006409f, 0.007347f, 0.008018f, 0.009163f, 0.010559f, 0.012039f,
+ 0.013695f, 0.016144f, 0.018723f, 0.022354f, 0.026337f, 0.031433f, 0.038818f, 0.047546f, 0.059662f, 0.075623f, 0.097473f, 0.127808f,
+ 0.169556f, 0.225830f, 0.299072f, 0.387451f, 0.486084f, 0.583984f, 0.674805f, 0.751465f, 0.812012f, 0.859375f, 0.957031f, 0.958984f,
+ 0.959473f, 0.959961f, 0.959961f, 0.959961f, 0.000000f, 0.000000f, 0.000004f, 0.000078f, 0.000408f, 0.000432f, 0.000563f, 0.000560f,
+ 0.000566f, 0.000623f, 0.000782f, 0.000829f, 0.000896f, 0.000956f, 0.001056f, 0.001249f, 0.001414f, 0.001473f, 0.001646f, 0.001764f,
+ 0.002066f, 0.002230f, 0.002436f, 0.002651f, 0.003012f, 0.003252f, 0.003414f, 0.004055f, 0.004143f, 0.004784f, 0.005356f, 0.006077f,
+ 0.006870f, 0.007538f, 0.008728f, 0.009834f, 0.011322f, 0.013130f, 0.015427f, 0.017914f, 0.021271f, 0.025436f, 0.030960f, 0.038086f,
+ 0.047485f, 0.060303f, 0.077087f, 0.101196f, 0.134521f, 0.180786f, 0.244507f, 0.326172f, 0.423584f, 0.527832f, 0.628418f, 0.716797f,
+ 0.788086f, 0.843262f, 0.953125f, 0.955566f, 0.955566f, 0.956543f, 0.956055f, 0.956543f, 0.000000f, 0.000000f, 0.000000f, 0.000236f,
+ 0.000320f, 0.000484f, 0.000521f, 0.000549f, 0.000556f, 0.000584f, 0.000574f, 0.000690f, 0.000758f, 0.000841f, 0.001003f, 0.001013f,
+ 0.001169f, 0.001292f, 0.001437f, 0.001658f, 0.001830f, 0.002001f, 0.002081f, 0.002146f, 0.002434f, 0.002712f, 0.002964f, 0.003220f,
+ 0.003513f, 0.003963f, 0.004410f, 0.004875f, 0.005608f, 0.006245f, 0.007179f, 0.008118f, 0.009201f, 0.010582f, 0.012360f, 0.014343f,
+ 0.016968f, 0.020401f, 0.024628f, 0.030365f, 0.037567f, 0.047455f, 0.060913f, 0.079529f, 0.105774f, 0.143555f, 0.196167f, 0.268799f,
+ 0.361084f, 0.467041f, 0.576172f, 0.676758f, 0.760254f, 0.825195f, 0.948242f, 0.951660f, 0.951660f, 0.951660f, 0.951660f, 0.951660f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000122f, 0.000257f, 0.000334f, 0.000390f, 0.000496f, 0.000520f, 0.000539f, 0.000590f, 0.000602f,
+ 0.000646f, 0.000725f, 0.000909f, 0.000949f, 0.001023f, 0.001121f, 0.001181f, 0.001308f, 0.001474f, 0.001457f, 0.001714f, 0.002007f,
+ 0.001929f, 0.002039f, 0.002468f, 0.002672f, 0.003025f, 0.003317f, 0.003635f, 0.004047f, 0.004433f, 0.004864f, 0.005756f, 0.006493f,
+ 0.007515f, 0.008331f, 0.009697f, 0.011383f, 0.014000f, 0.016235f, 0.019653f, 0.024185f, 0.029465f, 0.037109f, 0.047699f, 0.062164f,
+ 0.082642f, 0.112488f, 0.155151f, 0.216919f, 0.300049f, 0.404541f, 0.520020f, 0.631836f, 0.728516f, 0.805664f, 0.943848f, 0.946289f,
+ 0.946777f, 0.946777f, 0.947266f, 0.947266f, 0.000000f, 0.000000f, 0.000122f, 0.000088f, 0.000219f, 0.000229f, 0.000355f, 0.000414f,
+ 0.000482f, 0.000545f, 0.000559f, 0.000568f, 0.000481f, 0.000668f, 0.000636f, 0.000728f, 0.000924f, 0.000980f, 0.001017f, 0.001109f,
+ 0.001258f, 0.001353f, 0.001451f, 0.001564f, 0.001621f, 0.001740f, 0.002066f, 0.002289f, 0.002459f, 0.002621f, 0.002975f, 0.003349f,
+ 0.003588f, 0.003998f, 0.004723f, 0.005116f, 0.006035f, 0.006859f, 0.007957f, 0.009064f, 0.010658f, 0.012711f, 0.015511f, 0.018555f,
+ 0.023026f, 0.028854f, 0.037140f, 0.048035f, 0.064026f, 0.086914f, 0.121033f, 0.171387f, 0.244141f, 0.341797f, 0.458740f, 0.580078f,
+ 0.691895f, 0.780762f, 0.937988f, 0.940430f, 0.941406f, 0.940918f, 0.941895f, 0.941406f, 0.000000f, 0.000000f, 0.000000f, 0.000080f,
+ 0.000211f, 0.000221f, 0.000225f, 0.000192f, 0.000352f, 0.000368f, 0.000397f, 0.000529f, 0.000510f, 0.000504f, 0.000540f, 0.000671f,
+ 0.000694f, 0.000763f, 0.000902f, 0.000998f, 0.001063f, 0.001074f, 0.001128f, 0.001407f, 0.001370f, 0.001449f, 0.001682f, 0.001635f,
+ 0.001976f, 0.002108f, 0.002335f, 0.002558f, 0.002905f, 0.003176f, 0.003637f, 0.003948f, 0.004650f, 0.005341f, 0.006237f, 0.007034f,
+ 0.008415f, 0.009811f, 0.012032f, 0.014565f, 0.017731f, 0.022324f, 0.028427f, 0.036713f, 0.048859f, 0.066406f, 0.092957f, 0.133057f,
+ 0.193848f, 0.281250f, 0.395508f, 0.524902f, 0.648926f, 0.754395f, 0.931152f, 0.934570f, 0.934570f, 0.934570f, 0.935547f, 0.935059f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000121f, 0.000181f, 0.000196f, 0.000236f, 0.000250f, 0.000226f, 0.000281f, 0.000335f, 0.000457f,
+ 0.000406f, 0.000511f, 0.000522f, 0.000593f, 0.000539f, 0.000663f, 0.000661f, 0.000779f, 0.000978f, 0.000855f, 0.000937f, 0.001128f,
+ 0.001163f, 0.001253f, 0.001241f, 0.001531f, 0.001595f, 0.001796f, 0.001888f, 0.002226f, 0.002350f, 0.002609f, 0.002787f, 0.003260f,
+ 0.003656f, 0.004303f, 0.004910f, 0.005577f, 0.006683f, 0.007603f, 0.009102f, 0.011017f, 0.013603f, 0.016968f, 0.021652f, 0.027939f,
+ 0.037109f, 0.050262f, 0.070374f, 0.101624f, 0.150391f, 0.225220f, 0.331543f, 0.463867f, 0.601074f, 0.723145f, 0.923828f, 0.927246f,
+ 0.927246f, 0.928223f, 0.927734f, 0.928223f, 0.000000f, 0.000000f, 0.000122f, 0.000121f, 0.000121f, 0.000174f, 0.000156f, 0.000204f,
+ 0.000180f, 0.000221f, 0.000246f, 0.000346f, 0.000313f, 0.000426f, 0.000468f, 0.000482f, 0.000559f, 0.000582f, 0.000536f, 0.000611f,
+ 0.000770f, 0.000666f, 0.000919f, 0.000947f, 0.001013f, 0.000948f, 0.001129f, 0.001169f, 0.001463f, 0.001579f, 0.001540f, 0.001555f,
+ 0.001888f, 0.002007f, 0.002390f, 0.002623f, 0.002708f, 0.003235f, 0.003584f, 0.004223f, 0.005001f, 0.005791f, 0.006905f, 0.008118f,
+ 0.010117f, 0.012512f, 0.015961f, 0.020798f, 0.027374f, 0.037628f, 0.052673f, 0.076172f, 0.114197f, 0.175659f, 0.270752f, 0.399658f,
+ 0.546875f, 0.687012f, 0.915527f, 0.918457f, 0.919434f, 0.919434f, 0.919434f, 0.919434f, 0.000000f, 0.000000f, 0.000121f, 0.000121f,
+ 0.000121f, 0.000120f, 0.000139f, 0.000141f, 0.000152f, 0.000186f, 0.000209f, 0.000222f, 0.000297f, 0.000330f, 0.000367f, 0.000403f,
+ 0.000433f, 0.000456f, 0.000457f, 0.000484f, 0.000521f, 0.000544f, 0.000594f, 0.000807f, 0.000790f, 0.000841f, 0.000784f, 0.001025f,
+ 0.001112f, 0.001014f, 0.001146f, 0.001287f, 0.001485f, 0.001541f, 0.001740f, 0.002014f, 0.002264f, 0.002460f, 0.002825f, 0.003124f,
+ 0.003683f, 0.004177f, 0.005024f, 0.006004f, 0.007454f, 0.009041f, 0.011833f, 0.014839f, 0.019791f, 0.027283f, 0.038361f, 0.055817f,
+ 0.084656f, 0.133057f, 0.213013f, 0.334717f, 0.488770f, 0.645996f, 0.905762f, 0.909668f, 0.909668f, 0.909180f, 0.910645f, 0.908691f,
+ 0.000000f, 0.000000f, 0.000121f, 0.000121f, 0.000120f, 0.000120f, 0.000119f, 0.000115f, 0.000104f, 0.000105f, 0.000203f, 0.000235f,
+ 0.000185f, 0.000290f, 0.000201f, 0.000306f, 0.000259f, 0.000370f, 0.000401f, 0.000428f, 0.000596f, 0.000617f, 0.000474f, 0.000593f,
+ 0.000641f, 0.000676f, 0.000682f, 0.000826f, 0.000897f, 0.000934f, 0.000972f, 0.000972f, 0.001213f, 0.001281f, 0.001410f, 0.001451f,
+ 0.001562f, 0.001786f, 0.002031f, 0.002417f, 0.002764f, 0.003162f, 0.003763f, 0.004406f, 0.005310f, 0.006454f, 0.008156f, 0.010849f,
+ 0.014305f, 0.019318f, 0.027328f, 0.039856f, 0.061310f, 0.097717f, 0.162354f, 0.270752f, 0.424805f, 0.599609f, 0.894043f, 0.897949f,
+ 0.898438f, 0.898438f, 0.898926f, 0.898438f, 0.000000f, 0.000121f, 0.000121f, 0.000120f, 0.000119f, 0.000119f, 0.000118f, 0.000118f,
+ 0.000112f, 0.000102f, 0.000094f, 0.000109f, 0.000131f, 0.000145f, 0.000232f, 0.000171f, 0.000278f, 0.000230f, 0.000347f, 0.000331f,
+ 0.000379f, 0.000381f, 0.000512f, 0.000427f, 0.000541f, 0.000566f, 0.000547f, 0.000613f, 0.000706f, 0.000660f, 0.000809f, 0.000941f,
+ 0.000950f, 0.001035f, 0.001069f, 0.001220f, 0.001149f, 0.001314f, 0.001603f, 0.001801f, 0.002062f, 0.002394f, 0.002737f, 0.003057f,
+ 0.003771f, 0.004471f, 0.005875f, 0.007217f, 0.009651f, 0.013344f, 0.018829f, 0.027710f, 0.043091f, 0.069214f, 0.119141f, 0.210571f,
+ 0.358398f, 0.544922f, 0.881348f, 0.883789f, 0.885254f, 0.885742f, 0.885254f, 0.885254f, 0.000000f, 0.000121f, 0.000120f, 0.000119f,
+ 0.000119f, 0.000118f, 0.000117f, 0.000116f, 0.000116f, 0.000110f, 0.000101f, 0.000094f, 0.000087f, 0.000157f, 0.000151f, 0.000168f,
+ 0.000146f, 0.000219f, 0.000214f, 0.000261f, 0.000313f, 0.000363f, 0.000311f, 0.000415f, 0.000476f, 0.000448f, 0.000429f, 0.000460f,
+ 0.000481f, 0.000560f, 0.000544f, 0.000695f, 0.000626f, 0.000789f, 0.000877f, 0.000894f, 0.000948f, 0.001177f, 0.001175f, 0.001366f,
+ 0.001487f, 0.001738f, 0.002008f, 0.002304f, 0.002663f, 0.003250f, 0.004002f, 0.004932f, 0.006416f, 0.008636f, 0.012344f, 0.018127f,
+ 0.028610f, 0.047150f, 0.083923f, 0.156860f, 0.291260f, 0.487305f, 0.866211f, 0.869141f, 0.870605f, 0.870117f, 0.871094f, 0.870117f,
+ 0.000000f, 0.000000f, 0.000119f, 0.000118f, 0.000117f, 0.000116f, 0.000115f, 0.000115f, 0.000114f, 0.000114f, 0.000109f, 0.000101f,
+ 0.000094f, 0.000087f, 0.000081f, 0.000085f, 0.000129f, 0.000150f, 0.000176f, 0.000193f, 0.000216f, 0.000257f, 0.000241f, 0.000302f,
+ 0.000259f, 0.000299f, 0.000397f, 0.000403f, 0.000384f, 0.000402f, 0.000425f, 0.000582f, 0.000467f, 0.000614f, 0.000660f, 0.000625f,
+ 0.000650f, 0.000819f, 0.000790f, 0.000879f, 0.001001f, 0.001140f, 0.001403f, 0.001555f, 0.001844f, 0.002213f, 0.002636f, 0.003235f,
+ 0.004082f, 0.005604f, 0.007896f, 0.011292f, 0.018005f, 0.030472f, 0.055786f, 0.109985f, 0.224976f, 0.421875f, 0.848145f, 0.852539f,
+ 0.853027f, 0.852539f, 0.852539f, 0.853027f, 0.000000f, 0.000119f, 0.000118f, 0.000116f, 0.000115f, 0.000114f, 0.000113f, 0.000112f,
+ 0.000111f, 0.000111f, 0.000110f, 0.000108f, 0.000101f, 0.000094f, 0.000088f, 0.000082f, 0.000077f, 0.000109f, 0.000068f, 0.000102f,
+ 0.000127f, 0.000158f, 0.000177f, 0.000192f, 0.000207f, 0.000214f, 0.000249f, 0.000278f, 0.000296f, 0.000320f, 0.000330f, 0.000342f,
+ 0.000415f, 0.000371f, 0.000389f, 0.000508f, 0.000463f, 0.000586f, 0.000606f, 0.000649f, 0.000724f, 0.000841f, 0.000910f, 0.001065f,
+ 0.001236f, 0.001475f, 0.001807f, 0.002138f, 0.002716f, 0.003622f, 0.004921f, 0.006950f, 0.010574f, 0.018433f, 0.034607f, 0.072449f,
+ 0.163818f, 0.352295f, 0.827637f, 0.831055f, 0.831543f, 0.832031f, 0.833008f, 0.832520f, 0.000120f, 0.000116f, 0.000114f, 0.000113f,
+ 0.000111f, 0.000110f, 0.000109f, 0.000108f, 0.000107f, 0.000106f, 0.000106f, 0.000105f, 0.000104f, 0.000101f, 0.000094f, 0.000088f,
+ 0.000083f, 0.000078f, 0.000073f, 0.000092f, 0.000064f, 0.000097f, 0.000073f, 0.000105f, 0.000125f, 0.000162f, 0.000179f, 0.000177f,
+ 0.000191f, 0.000221f, 0.000241f, 0.000235f, 0.000270f, 0.000277f, 0.000287f, 0.000329f, 0.000319f, 0.000428f, 0.000417f, 0.000409f,
+ 0.000524f, 0.000537f, 0.000612f, 0.000750f, 0.000770f, 0.000961f, 0.001153f, 0.001347f, 0.001702f, 0.002081f, 0.002903f, 0.003956f,
+ 0.006184f, 0.010368f, 0.019592f, 0.043427f, 0.109924f, 0.280518f, 0.803223f, 0.806152f, 0.807617f, 0.808594f, 0.809082f, 0.808105f,
+ 0.000000f, 0.000111f, 0.000106f, 0.000107f, 0.000104f, 0.000103f, 0.000101f, 0.000101f, 0.000101f, 0.000100f, 0.000099f, 0.000098f,
+ 0.000097f, 0.000097f, 0.000097f, 0.000094f, 0.000088f, 0.000083f, 0.000078f, 0.000073f, 0.000069f, 0.000070f, 0.000061f, 0.000068f,
+ 0.000059f, 0.000067f, 0.000084f, 0.000097f, 0.000128f, 0.000137f, 0.000165f, 0.000160f, 0.000176f, 0.000185f, 0.000217f, 0.000239f,
+ 0.000237f, 0.000238f, 0.000272f, 0.000281f, 0.000314f, 0.000372f, 0.000395f, 0.000430f, 0.000504f, 0.000578f, 0.000665f, 0.000856f,
+ 0.000969f, 0.001210f, 0.001594f, 0.002216f, 0.003370f, 0.005527f, 0.010170f, 0.023239f, 0.066101f, 0.207275f, 0.775391f, 0.779785f,
+ 0.780273f, 0.780762f, 0.780273f, 0.780762f, 0.000000f, 0.000094f, 0.000097f, 0.000095f, 0.000092f, 0.000091f, 0.000091f, 0.000090f,
+ 0.000089f, 0.000089f, 0.000088f, 0.000088f, 0.000087f, 0.000086f, 0.000087f, 0.000086f, 0.000086f, 0.000085f, 0.000081f, 0.000076f,
+ 0.000072f, 0.000068f, 0.000064f, 0.000060f, 0.000057f, 0.000054f, 0.000058f, 0.000048f, 0.000048f, 0.000069f, 0.000068f, 0.000092f,
+ 0.000110f, 0.000122f, 0.000133f, 0.000136f, 0.000146f, 0.000154f, 0.000175f, 0.000194f, 0.000204f, 0.000206f, 0.000238f, 0.000262f,
+ 0.000266f, 0.000338f, 0.000361f, 0.000432f, 0.000527f, 0.000659f, 0.000848f, 0.001183f, 0.001713f, 0.002661f, 0.004921f, 0.010887f,
+ 0.033936f, 0.138428f, 0.743652f, 0.747559f, 0.748047f, 0.748535f, 0.749512f, 0.749023f, 0.000045f, 0.000047f, 0.000059f, 0.000059f,
+ 0.000063f, 0.000068f, 0.000068f, 0.000068f, 0.000067f, 0.000069f, 0.000068f, 0.000070f, 0.000070f, 0.000070f, 0.000071f, 0.000070f,
+ 0.000071f, 0.000071f, 0.000071f, 0.000071f, 0.000071f, 0.000069f, 0.000065f, 0.000062f, 0.000058f, 0.000055f, 0.000052f, 0.000049f,
+ 0.000046f, 0.000044f, 0.000041f, 0.000050f, 0.000051f, 0.000048f, 0.000061f, 0.000070f, 0.000084f, 0.000095f, 0.000107f, 0.000104f,
+ 0.000111f, 0.000128f, 0.000143f, 0.000154f, 0.000157f, 0.000186f, 0.000198f, 0.000216f, 0.000268f, 0.000315f, 0.000414f, 0.000537f,
+ 0.000735f, 0.001149f, 0.002075f, 0.004669f, 0.014175f, 0.077881f, 0.707031f, 0.710449f, 0.712402f, 0.711914f, 0.712891f, 0.712402f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000012f, 0.000013f, 0.000029f, 0.000028f, 0.000037f, 0.000035f, 0.000039f,
+ 0.000043f, 0.000043f, 0.000045f, 0.000045f, 0.000048f, 0.000048f, 0.000050f, 0.000051f, 0.000052f, 0.000052f, 0.000053f, 0.000054f,
+ 0.000054f, 0.000053f, 0.000050f, 0.000048f, 0.000045f, 0.000043f, 0.000040f, 0.000038f, 0.000036f, 0.000034f, 0.000032f, 0.000030f,
+ 0.000028f, 0.000030f, 0.000038f, 0.000043f, 0.000057f, 0.000069f, 0.000072f, 0.000073f, 0.000082f, 0.000095f, 0.000101f, 0.000099f,
+ 0.000116f, 0.000130f, 0.000184f, 0.000211f, 0.000301f, 0.000443f, 0.000737f, 0.001601f, 0.004978f, 0.032593f, 0.666504f, 0.669922f,
+ 0.669922f, 0.672363f, 0.670898f, 0.670410f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000006f, 0.000010f, 0.000012f, 0.000015f, 0.000018f, 0.000021f,
+ 0.000022f, 0.000023f, 0.000025f, 0.000028f, 0.000029f, 0.000029f, 0.000031f, 0.000033f, 0.000033f, 0.000035f, 0.000035f, 0.000035f,
+ 0.000033f, 0.000031f, 0.000029f, 0.000028f, 0.000026f, 0.000024f, 0.000023f, 0.000021f, 0.000020f, 0.000019f, 0.000022f, 0.000022f,
+ 0.000030f, 0.000038f, 0.000042f, 0.000041f, 0.000052f, 0.000047f, 0.000064f, 0.000072f, 0.000078f, 0.000129f, 0.000201f, 0.000382f,
+ 0.001180f, 0.009117f, 0.620605f, 0.624512f, 0.625000f, 0.625000f, 0.625000f, 0.625488f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000003f, 0.000005f, 0.000007f, 0.000008f, 0.000010f, 0.000011f, 0.000012f, 0.000014f, 0.000016f, 0.000016f, 0.000018f, 0.000017f,
+ 0.000016f, 0.000015f, 0.000014f, 0.000013f, 0.000012f, 0.000011f, 0.000010f, 0.000009f, 0.000011f, 0.000014f, 0.000018f, 0.000018f,
+ 0.000021f, 0.000028f, 0.000035f, 0.000053f, 0.000136f, 0.001152f, 0.571777f, 0.575684f, 0.575684f, 0.576172f, 0.576660f, 0.576660f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000001f,
+ 0.000002f, 0.000004f, 0.000004f, 0.000004f, 0.000003f, 0.000003f, 0.000002f, 0.000004f, 0.000003f, 0.000011f, 0.520020f, 0.523926f,
+ 0.524902f, 0.524902f, 0.524902f, 0.524902f,
+ },
+ {
+ 0.119934f, 0.328857f, 0.480713f, 0.586914f, 0.663086f, 0.717773f, 0.759766f, 0.791504f, 0.818359f, 0.838867f, 0.856934f, 0.871094f,
+ 0.883301f, 0.894043f, 0.902832f, 0.911621f, 0.917969f, 0.924805f, 0.930664f, 0.936035f, 0.939941f, 0.944824f, 0.948242f, 0.951660f,
+ 0.954590f, 0.958008f, 0.961426f, 0.962891f, 0.966309f, 0.967285f, 0.970215f, 0.972656f, 0.973633f, 0.975586f, 0.977539f, 0.978516f,
+ 0.979980f, 0.981445f, 0.982910f, 0.984375f, 0.985352f, 0.986328f, 0.987793f, 0.988770f, 0.989746f, 0.990234f, 0.991699f, 0.992676f,
+ 0.993164f, 0.993652f, 0.994629f, 0.995117f, 0.996094f, 0.996582f, 0.997559f, 0.998047f, 0.998535f, 0.999023f, 0.999512f, 0.999023f,
+ 0.999023f, 0.998535f, 0.998535f, 0.998047f, 0.046875f, 0.160400f, 0.286621f, 0.405518f, 0.507812f, 0.590820f, 0.656250f, 0.708008f,
+ 0.748535f, 0.781250f, 0.809082f, 0.830566f, 0.848633f, 0.864258f, 0.877441f, 0.888672f, 0.898926f, 0.906738f, 0.915039f, 0.921387f,
+ 0.928223f, 0.933105f, 0.937988f, 0.942871f, 0.946777f, 0.950684f, 0.954102f, 0.957031f, 0.959961f, 0.962402f, 0.965332f, 0.966797f,
+ 0.969727f, 0.971191f, 0.973145f, 0.975098f, 0.977539f, 0.978027f, 0.980469f, 0.981934f, 0.982910f, 0.984375f, 0.985352f, 0.986816f,
+ 0.987793f, 0.988770f, 0.989258f, 0.990723f, 0.991699f, 0.992676f, 0.993164f, 0.993652f, 0.994629f, 0.995605f, 0.996582f, 0.996582f,
+ 0.997559f, 0.998047f, 0.999023f, 0.999023f, 0.999023f, 0.998535f, 0.998535f, 0.998047f, 0.023788f, 0.084473f, 0.163696f, 0.255615f,
+ 0.351807f, 0.445312f, 0.527832f, 0.597656f, 0.656738f, 0.703613f, 0.742676f, 0.775879f, 0.802734f, 0.824707f, 0.843262f, 0.858887f,
+ 0.873047f, 0.884766f, 0.895508f, 0.903809f, 0.913086f, 0.919434f, 0.925781f, 0.931641f, 0.937012f, 0.941406f, 0.945801f, 0.949707f,
+ 0.953125f, 0.956543f, 0.959473f, 0.962402f, 0.964844f, 0.967285f, 0.969238f, 0.972168f, 0.973633f, 0.975098f, 0.977539f, 0.979492f,
+ 0.980469f, 0.981445f, 0.982910f, 0.984375f, 0.985840f, 0.986816f, 0.988281f, 0.988770f, 0.989746f, 0.990723f, 0.992188f, 0.992676f,
+ 0.993652f, 0.994629f, 0.995605f, 0.996094f, 0.996582f, 0.997559f, 0.998535f, 0.998535f, 0.998535f, 0.998047f, 0.998047f, 0.997559f,
+ 0.014595f, 0.050110f, 0.097717f, 0.158569f, 0.230347f, 0.311523f, 0.394531f, 0.473145f, 0.544922f, 0.606934f, 0.660645f, 0.705566f,
+ 0.743164f, 0.775391f, 0.800781f, 0.822266f, 0.841309f, 0.856934f, 0.870605f, 0.883301f, 0.894043f, 0.902832f, 0.911133f, 0.918945f,
+ 0.925293f, 0.931152f, 0.936035f, 0.941406f, 0.945801f, 0.949707f, 0.953125f, 0.956055f, 0.959473f, 0.962402f, 0.964844f, 0.967285f,
+ 0.970215f, 0.972168f, 0.974121f, 0.975098f, 0.977539f, 0.979004f, 0.980957f, 0.981934f, 0.983398f, 0.984375f, 0.985840f, 0.987305f,
+ 0.988281f, 0.989258f, 0.990723f, 0.991699f, 0.992676f, 0.993652f, 0.994629f, 0.995117f, 0.995605f, 0.996582f, 0.998535f, 0.998535f,
+ 0.998535f, 0.998047f, 0.998047f, 0.997559f, 0.009178f, 0.032379f, 0.062561f, 0.102417f, 0.151611f, 0.210938f, 0.279785f, 0.352783f,
+ 0.426758f, 0.496826f, 0.561035f, 0.618164f, 0.666992f, 0.708496f, 0.744141f, 0.773926f, 0.800781f, 0.821777f, 0.840820f, 0.856445f,
+ 0.870117f, 0.882324f, 0.893066f, 0.901855f, 0.910645f, 0.918457f, 0.925293f, 0.930176f, 0.935547f, 0.941406f, 0.946289f, 0.949707f,
+ 0.953125f, 0.956543f, 0.959961f, 0.962891f, 0.965332f, 0.967773f, 0.969727f, 0.972656f, 0.974121f, 0.976074f, 0.977539f, 0.979492f,
+ 0.981445f, 0.982422f, 0.984375f, 0.985840f, 0.986328f, 0.987793f, 0.989258f, 0.990234f, 0.991211f, 0.992188f, 0.993164f, 0.994141f,
+ 0.994629f, 0.995605f, 0.998047f, 0.998047f, 0.998047f, 0.997559f, 0.997559f, 0.997559f, 0.006382f, 0.022430f, 0.042908f, 0.068970f,
+ 0.102844f, 0.144653f, 0.195557f, 0.253906f, 0.318848f, 0.386230f, 0.454590f, 0.518066f, 0.577148f, 0.628906f, 0.675293f, 0.714844f,
+ 0.748535f, 0.777344f, 0.802246f, 0.823730f, 0.841797f, 0.856934f, 0.871094f, 0.882812f, 0.893555f, 0.902832f, 0.911133f, 0.918457f,
+ 0.925293f, 0.930176f, 0.937012f, 0.940918f, 0.945801f, 0.950195f, 0.953613f, 0.957031f, 0.960449f, 0.963379f, 0.966309f, 0.968262f,
+ 0.970703f, 0.973145f, 0.974609f, 0.976562f, 0.978516f, 0.980469f, 0.981934f, 0.983398f, 0.984375f, 0.985840f, 0.988281f, 0.988770f,
+ 0.989746f, 0.990723f, 0.991699f, 0.992676f, 0.993652f, 0.994629f, 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.997559f, 0.997070f,
+ 0.004585f, 0.015961f, 0.030930f, 0.049133f, 0.072144f, 0.101013f, 0.137451f, 0.181519f, 0.232544f, 0.290039f, 0.352539f, 0.416748f,
+ 0.479736f, 0.538574f, 0.592773f, 0.641602f, 0.684570f, 0.723145f, 0.754395f, 0.782715f, 0.805176f, 0.825195f, 0.843750f, 0.859863f,
+ 0.872559f, 0.884766f, 0.895020f, 0.904297f, 0.912109f, 0.919922f, 0.926270f, 0.932129f, 0.937500f, 0.942383f, 0.946289f, 0.950195f,
+ 0.955078f, 0.958008f, 0.961426f, 0.964355f, 0.967285f, 0.969238f, 0.971680f, 0.974121f, 0.975586f, 0.977539f, 0.979492f, 0.980957f,
+ 0.982910f, 0.984375f, 0.985840f, 0.986328f, 0.988281f, 0.989746f, 0.990723f, 0.992188f, 0.992676f, 0.993164f, 0.997559f, 0.997559f,
+ 0.997070f, 0.997070f, 0.997070f, 0.997070f, 0.003483f, 0.012291f, 0.023209f, 0.036041f, 0.052429f, 0.073486f, 0.099182f, 0.131226f,
+ 0.169678f, 0.214844f, 0.266846f, 0.323242f, 0.383545f, 0.444580f, 0.503418f, 0.559082f, 0.609375f, 0.655762f, 0.695312f, 0.730957f,
+ 0.760254f, 0.788086f, 0.810059f, 0.829590f, 0.847168f, 0.862793f, 0.875488f, 0.886719f, 0.896973f, 0.906250f, 0.914551f, 0.921387f,
+ 0.927734f, 0.933594f, 0.938965f, 0.944336f, 0.948242f, 0.952148f, 0.956543f, 0.958984f, 0.961914f, 0.965332f, 0.968262f, 0.970703f,
+ 0.972656f, 0.974609f, 0.977051f, 0.979004f, 0.980469f, 0.981934f, 0.983887f, 0.985352f, 0.986328f, 0.987793f, 0.989746f, 0.990234f,
+ 0.991699f, 0.992676f, 0.996582f, 0.997070f, 0.997070f, 0.996582f, 0.996582f, 0.996094f, 0.002962f, 0.009613f, 0.017792f, 0.027481f,
+ 0.039429f, 0.055176f, 0.073914f, 0.096985f, 0.125610f, 0.159180f, 0.199707f, 0.246216f, 0.297607f, 0.353760f, 0.412842f, 0.470215f,
+ 0.526367f, 0.578613f, 0.626953f, 0.669434f, 0.707031f, 0.740723f, 0.769043f, 0.794922f, 0.814941f, 0.835449f, 0.851074f, 0.866699f,
+ 0.879395f, 0.890137f, 0.899902f, 0.909180f, 0.916992f, 0.924316f, 0.929688f, 0.936035f, 0.941406f, 0.945312f, 0.950195f, 0.953613f,
+ 0.957520f, 0.960938f, 0.963867f, 0.966797f, 0.969238f, 0.971680f, 0.974121f, 0.976562f, 0.979004f, 0.979980f, 0.981934f, 0.982910f,
+ 0.984375f, 0.986816f, 0.987793f, 0.988770f, 0.990234f, 0.991699f, 0.996582f, 0.996582f, 0.996582f, 0.996582f, 0.996094f, 0.996094f,
+ 0.002077f, 0.007637f, 0.013802f, 0.021606f, 0.031006f, 0.042419f, 0.055969f, 0.073242f, 0.094055f, 0.119446f, 0.150513f, 0.186401f,
+ 0.228638f, 0.276123f, 0.328857f, 0.384277f, 0.440674f, 0.496338f, 0.549805f, 0.598633f, 0.644043f, 0.683594f, 0.719727f, 0.750977f,
+ 0.779297f, 0.802246f, 0.823730f, 0.840820f, 0.855957f, 0.871582f, 0.882324f, 0.893555f, 0.903809f, 0.911621f, 0.920410f, 0.926758f,
+ 0.932617f, 0.938477f, 0.943359f, 0.947754f, 0.953125f, 0.955566f, 0.959473f, 0.962402f, 0.965332f, 0.968262f, 0.970703f, 0.972656f,
+ 0.976074f, 0.977051f, 0.979492f, 0.981445f, 0.983398f, 0.984863f, 0.986328f, 0.987793f, 0.989258f, 0.990723f, 0.995605f, 0.996094f,
+ 0.996094f, 0.996094f, 0.996094f, 0.995605f, 0.002014f, 0.006035f, 0.011299f, 0.017410f, 0.024368f, 0.033020f, 0.043701f, 0.056458f,
+ 0.072205f, 0.091431f, 0.114807f, 0.141968f, 0.174316f, 0.213257f, 0.256836f, 0.306152f, 0.358887f, 0.413330f, 0.468018f, 0.520996f,
+ 0.572266f, 0.618652f, 0.661621f, 0.699707f, 0.732910f, 0.762695f, 0.788574f, 0.810547f, 0.830078f, 0.848145f, 0.862305f, 0.875977f,
+ 0.887695f, 0.898438f, 0.907227f, 0.915527f, 0.922852f, 0.929199f, 0.936035f, 0.940918f, 0.946289f, 0.950684f, 0.953613f, 0.958496f,
+ 0.960938f, 0.964355f, 0.967285f, 0.970215f, 0.972656f, 0.975586f, 0.977539f, 0.979492f, 0.980957f, 0.982910f, 0.984863f, 0.986328f,
+ 0.987793f, 0.988770f, 0.995117f, 0.995605f, 0.995605f, 0.995605f, 0.995605f, 0.995605f, 0.001496f, 0.005196f, 0.009201f, 0.013985f,
+ 0.019806f, 0.026413f, 0.034943f, 0.044647f, 0.056641f, 0.070923f, 0.088623f, 0.109680f, 0.135254f, 0.164795f, 0.200073f, 0.240845f,
+ 0.285645f, 0.335449f, 0.387939f, 0.441650f, 0.495850f, 0.546875f, 0.595215f, 0.639160f, 0.679199f, 0.715820f, 0.746582f, 0.774414f,
+ 0.798828f, 0.819824f, 0.837402f, 0.854492f, 0.869629f, 0.881348f, 0.893066f, 0.902832f, 0.912109f, 0.918945f, 0.926758f, 0.933105f,
+ 0.938477f, 0.943359f, 0.948730f, 0.952637f, 0.956055f, 0.960449f, 0.963379f, 0.966797f, 0.969238f, 0.972656f, 0.975098f, 0.977051f,
+ 0.979004f, 0.981445f, 0.982910f, 0.984375f, 0.986328f, 0.987305f, 0.994629f, 0.995605f, 0.995117f, 0.995117f, 0.995117f, 0.994629f,
+ 0.001187f, 0.004314f, 0.007740f, 0.011337f, 0.016373f, 0.021759f, 0.028198f, 0.035889f, 0.045197f, 0.056580f, 0.069946f, 0.085938f,
+ 0.105408f, 0.128784f, 0.155884f, 0.187866f, 0.225830f, 0.268066f, 0.315186f, 0.365479f, 0.418213f, 0.471680f, 0.522949f, 0.572754f,
+ 0.617676f, 0.659668f, 0.697754f, 0.730957f, 0.760742f, 0.787109f, 0.809570f, 0.830078f, 0.846680f, 0.862793f, 0.875488f, 0.888184f,
+ 0.898926f, 0.907715f, 0.916016f, 0.923340f, 0.930664f, 0.936523f, 0.941895f, 0.947754f, 0.951660f, 0.955566f, 0.959473f, 0.963867f,
+ 0.966309f, 0.969238f, 0.972168f, 0.974121f, 0.976562f, 0.979004f, 0.980957f, 0.982910f, 0.984863f, 0.986816f, 0.994141f, 0.994629f,
+ 0.994629f, 0.994629f, 0.994629f, 0.994141f, 0.001187f, 0.003733f, 0.006496f, 0.009918f, 0.013634f, 0.017899f, 0.023026f, 0.029343f,
+ 0.036621f, 0.045227f, 0.055786f, 0.068298f, 0.083740f, 0.101135f, 0.122314f, 0.147827f, 0.177612f, 0.212891f, 0.252686f, 0.297119f,
+ 0.345215f, 0.395996f, 0.448730f, 0.500488f, 0.550781f, 0.597656f, 0.641113f, 0.680664f, 0.716309f, 0.747559f, 0.774414f, 0.799316f,
+ 0.820312f, 0.838867f, 0.855957f, 0.870117f, 0.883301f, 0.894531f, 0.904785f, 0.913086f, 0.920898f, 0.928223f, 0.935059f, 0.940430f,
+ 0.945312f, 0.950684f, 0.955566f, 0.958496f, 0.962891f, 0.965820f, 0.968750f, 0.971680f, 0.974609f, 0.976562f, 0.978516f, 0.980957f,
+ 0.982910f, 0.984863f, 0.994141f, 0.994141f, 0.994629f, 0.994141f, 0.994141f, 0.994629f, 0.000998f, 0.003178f, 0.005444f, 0.008179f,
+ 0.011337f, 0.015091f, 0.019058f, 0.024368f, 0.029587f, 0.037140f, 0.045197f, 0.055115f, 0.066772f, 0.080688f, 0.097229f, 0.117371f,
+ 0.140869f, 0.169312f, 0.201538f, 0.238770f, 0.280762f, 0.326660f, 0.376709f, 0.427490f, 0.479248f, 0.530273f, 0.578613f, 0.623535f,
+ 0.664551f, 0.701660f, 0.733887f, 0.763672f, 0.790039f, 0.812500f, 0.832520f, 0.849121f, 0.865234f, 0.878906f, 0.890625f, 0.901367f,
+ 0.910645f, 0.919434f, 0.926758f, 0.933105f, 0.939453f, 0.944824f, 0.949707f, 0.954590f, 0.958008f, 0.961914f, 0.965332f, 0.968750f,
+ 0.971680f, 0.974121f, 0.977051f, 0.979004f, 0.980957f, 0.982910f, 0.993164f, 0.993164f, 0.994141f, 0.993652f, 0.993652f, 0.993164f,
+ 0.000948f, 0.002638f, 0.004784f, 0.007153f, 0.009590f, 0.012505f, 0.016388f, 0.020599f, 0.025299f, 0.031097f, 0.037323f, 0.045197f,
+ 0.054047f, 0.065002f, 0.078674f, 0.094055f, 0.112305f, 0.134399f, 0.160889f, 0.191040f, 0.226318f, 0.265869f, 0.310303f, 0.358154f,
+ 0.409180f, 0.459473f, 0.510254f, 0.559082f, 0.606445f, 0.648926f, 0.687500f, 0.722168f, 0.753418f, 0.781250f, 0.804199f, 0.825684f,
+ 0.843262f, 0.860840f, 0.874512f, 0.886719f, 0.898926f, 0.907227f, 0.916992f, 0.924805f, 0.932129f, 0.937988f, 0.943848f, 0.949219f,
+ 0.954102f, 0.958496f, 0.961426f, 0.965332f, 0.968750f, 0.972168f, 0.974609f, 0.977051f, 0.979492f, 0.981445f, 0.992188f, 0.993164f,
+ 0.993164f, 0.993164f, 0.993164f, 0.992676f, 0.000696f, 0.002352f, 0.004002f, 0.006138f, 0.008446f, 0.010826f, 0.013840f, 0.017258f,
+ 0.021194f, 0.025970f, 0.031128f, 0.037140f, 0.044281f, 0.053436f, 0.063660f, 0.076050f, 0.090271f, 0.107727f, 0.128662f, 0.152832f,
+ 0.182007f, 0.214111f, 0.252930f, 0.295166f, 0.341553f, 0.390625f, 0.442139f, 0.492676f, 0.541992f, 0.589844f, 0.633301f, 0.674316f,
+ 0.710938f, 0.743652f, 0.772461f, 0.796875f, 0.819824f, 0.839355f, 0.854980f, 0.870605f, 0.884277f, 0.895508f, 0.906738f, 0.915527f,
+ 0.923828f, 0.931152f, 0.937500f, 0.944336f, 0.949219f, 0.953613f, 0.958008f, 0.962402f, 0.965332f, 0.968750f, 0.972168f, 0.974609f,
+ 0.977051f, 0.979980f, 0.991211f, 0.992676f, 0.992188f, 0.992188f, 0.992188f, 0.992676f, 0.000838f, 0.002033f, 0.003664f, 0.005077f,
+ 0.007282f, 0.009415f, 0.011749f, 0.014931f, 0.017853f, 0.021606f, 0.025864f, 0.031219f, 0.037231f, 0.044464f, 0.052338f, 0.062500f,
+ 0.073853f, 0.087463f, 0.104065f, 0.123230f, 0.146362f, 0.173340f, 0.205078f, 0.240845f, 0.281982f, 0.326660f, 0.374756f, 0.425049f,
+ 0.476807f, 0.526855f, 0.574219f, 0.620117f, 0.662598f, 0.699219f, 0.733398f, 0.764160f, 0.791016f, 0.813965f, 0.833984f, 0.851074f,
+ 0.867676f, 0.880859f, 0.893555f, 0.904785f, 0.914062f, 0.922852f, 0.930176f, 0.937012f, 0.942383f, 0.948242f, 0.953125f, 0.957520f,
+ 0.962402f, 0.966309f, 0.969238f, 0.973145f, 0.975098f, 0.978027f, 0.991699f, 0.991699f, 0.992676f, 0.992188f, 0.991699f, 0.992188f,
+ 0.000600f, 0.001687f, 0.003023f, 0.004963f, 0.006405f, 0.008163f, 0.010368f, 0.012718f, 0.015480f, 0.018311f, 0.022064f, 0.026169f,
+ 0.031097f, 0.036926f, 0.043457f, 0.051392f, 0.060669f, 0.071350f, 0.084473f, 0.100220f, 0.118103f, 0.140259f, 0.166016f, 0.195679f,
+ 0.230469f, 0.269531f, 0.313232f, 0.360596f, 0.410156f, 0.460693f, 0.511719f, 0.560547f, 0.607422f, 0.650879f, 0.689941f, 0.724609f,
+ 0.756348f, 0.784180f, 0.808594f, 0.828613f, 0.847656f, 0.864258f, 0.879395f, 0.892090f, 0.903320f, 0.912598f, 0.921875f, 0.929688f,
+ 0.936523f, 0.942871f, 0.947754f, 0.953125f, 0.957520f, 0.961914f, 0.966309f, 0.969238f, 0.972656f, 0.975586f, 0.990234f, 0.991211f,
+ 0.991211f, 0.991699f, 0.991211f, 0.991211f, 0.000269f, 0.001538f, 0.002800f, 0.003868f, 0.005524f, 0.007179f, 0.008987f, 0.011063f,
+ 0.013084f, 0.015747f, 0.019211f, 0.022324f, 0.026474f, 0.031311f, 0.036530f, 0.042969f, 0.050201f, 0.059174f, 0.069641f, 0.081543f,
+ 0.096680f, 0.114075f, 0.134644f, 0.158691f, 0.187622f, 0.220581f, 0.258301f, 0.300781f, 0.347168f, 0.395996f, 0.447266f, 0.498291f,
+ 0.547852f, 0.595215f, 0.640625f, 0.680176f, 0.717285f, 0.749512f, 0.778320f, 0.803223f, 0.825684f, 0.845215f, 0.862793f, 0.877441f,
+ 0.890625f, 0.901855f, 0.912109f, 0.920898f, 0.929688f, 0.937012f, 0.942871f, 0.949707f, 0.954102f, 0.958496f, 0.962402f, 0.966309f,
+ 0.970215f, 0.974121f, 0.989746f, 0.990234f, 0.990723f, 0.990723f, 0.990723f, 0.990234f, 0.000341f, 0.001337f, 0.002573f, 0.003475f,
+ 0.004765f, 0.006329f, 0.007717f, 0.009499f, 0.011642f, 0.014107f, 0.016556f, 0.019470f, 0.022491f, 0.026169f, 0.030945f, 0.036011f,
+ 0.042389f, 0.049042f, 0.057678f, 0.067993f, 0.079468f, 0.093384f, 0.110046f, 0.129883f, 0.152710f, 0.180420f, 0.212158f, 0.248291f,
+ 0.289551f, 0.334961f, 0.383301f, 0.434570f, 0.485596f, 0.536133f, 0.584473f, 0.630371f, 0.671875f, 0.710449f, 0.743652f, 0.773926f,
+ 0.799316f, 0.823242f, 0.843262f, 0.860352f, 0.875977f, 0.889648f, 0.901367f, 0.911621f, 0.921387f, 0.929688f, 0.937012f, 0.943848f,
+ 0.950195f, 0.955078f, 0.959473f, 0.963379f, 0.967773f, 0.971191f, 0.988770f, 0.989746f, 0.990234f, 0.990234f, 0.990234f, 0.990234f,
+ 0.000564f, 0.001324f, 0.002092f, 0.003191f, 0.004471f, 0.005348f, 0.007069f, 0.008438f, 0.010201f, 0.011810f, 0.014297f, 0.016586f,
+ 0.019470f, 0.022644f, 0.026428f, 0.030579f, 0.035797f, 0.041718f, 0.048248f, 0.056213f, 0.065857f, 0.076782f, 0.090271f, 0.106262f,
+ 0.125122f, 0.147095f, 0.173462f, 0.204224f, 0.239746f, 0.279785f, 0.323730f, 0.372314f, 0.422607f, 0.474121f, 0.526367f, 0.575195f,
+ 0.621582f, 0.664062f, 0.703613f, 0.738770f, 0.769043f, 0.796387f, 0.820312f, 0.841797f, 0.858887f, 0.875488f, 0.889648f, 0.900879f,
+ 0.912598f, 0.921875f, 0.930664f, 0.937500f, 0.944336f, 0.950195f, 0.955566f, 0.959961f, 0.964844f, 0.968750f, 0.987305f, 0.989258f,
+ 0.989258f, 0.989258f, 0.989258f, 0.988770f, 0.000369f, 0.001128f, 0.001871f, 0.002792f, 0.003712f, 0.004723f, 0.006016f, 0.007542f,
+ 0.008896f, 0.010773f, 0.012421f, 0.014381f, 0.016632f, 0.019791f, 0.022354f, 0.025955f, 0.030609f, 0.035065f, 0.040924f, 0.047333f,
+ 0.055084f, 0.064209f, 0.075012f, 0.087769f, 0.102966f, 0.120911f, 0.142456f, 0.167358f, 0.197144f, 0.231812f, 0.270752f, 0.314209f,
+ 0.362549f, 0.412598f, 0.464844f, 0.515625f, 0.566895f, 0.614258f, 0.657715f, 0.698730f, 0.734863f, 0.766602f, 0.794922f, 0.818848f,
+ 0.839844f, 0.858887f, 0.875000f, 0.889648f, 0.901855f, 0.912598f, 0.922852f, 0.931152f, 0.938965f, 0.945312f, 0.951660f, 0.957520f,
+ 0.961426f, 0.966309f, 0.986816f, 0.988281f, 0.988281f, 0.988770f, 0.988281f, 0.988281f, 0.000466f, 0.000900f, 0.001792f, 0.002695f,
+ 0.003458f, 0.004204f, 0.005356f, 0.006512f, 0.007896f, 0.009300f, 0.010895f, 0.012459f, 0.014786f, 0.016739f, 0.019424f, 0.022461f,
+ 0.026062f, 0.029831f, 0.034851f, 0.039764f, 0.046417f, 0.053711f, 0.062164f, 0.072388f, 0.085205f, 0.099365f, 0.117004f, 0.137573f,
+ 0.162231f, 0.190674f, 0.224121f, 0.262451f, 0.305664f, 0.353027f, 0.403809f, 0.456055f, 0.508301f, 0.559082f, 0.608398f, 0.652832f,
+ 0.694824f, 0.731445f, 0.764160f, 0.793945f, 0.817871f, 0.839355f, 0.858398f, 0.875488f, 0.890137f, 0.902832f, 0.913574f, 0.923828f,
+ 0.932617f, 0.940918f, 0.946777f, 0.953613f, 0.958984f, 0.963379f, 0.985840f, 0.987305f, 0.987305f, 0.987793f, 0.987305f, 0.987305f,
+ 0.000234f, 0.001040f, 0.001661f, 0.002392f, 0.003101f, 0.003681f, 0.004944f, 0.005844f, 0.007065f, 0.008217f, 0.009247f, 0.010925f,
+ 0.012894f, 0.014549f, 0.017090f, 0.019455f, 0.022385f, 0.025650f, 0.029449f, 0.033936f, 0.039215f, 0.045135f, 0.052612f, 0.060944f,
+ 0.070312f, 0.082397f, 0.096924f, 0.113525f, 0.133179f, 0.156860f, 0.184814f, 0.217773f, 0.255127f, 0.298340f, 0.345215f, 0.395996f,
+ 0.448242f, 0.501953f, 0.553223f, 0.603516f, 0.649414f, 0.691895f, 0.729980f, 0.763184f, 0.792480f, 0.818359f, 0.841309f, 0.858887f,
+ 0.877441f, 0.891113f, 0.904785f, 0.915527f, 0.925781f, 0.933594f, 0.941895f, 0.949219f, 0.955566f, 0.960449f, 0.984863f, 0.985840f,
+ 0.986328f, 0.986816f, 0.986328f, 0.986816f, 0.000241f, 0.000808f, 0.001395f, 0.001986f, 0.002731f, 0.003429f, 0.004131f, 0.005402f,
+ 0.006077f, 0.007347f, 0.008522f, 0.009544f, 0.011345f, 0.013046f, 0.014534f, 0.016953f, 0.019241f, 0.022339f, 0.025208f, 0.029175f,
+ 0.033691f, 0.038300f, 0.044067f, 0.051331f, 0.059143f, 0.068726f, 0.080322f, 0.093567f, 0.109802f, 0.129883f, 0.152466f, 0.179810f,
+ 0.211792f, 0.249390f, 0.291748f, 0.338623f, 0.389404f, 0.442139f, 0.496338f, 0.548340f, 0.599121f, 0.645996f, 0.689941f, 0.728516f,
+ 0.762695f, 0.792969f, 0.818848f, 0.842285f, 0.862793f, 0.878906f, 0.894043f, 0.906250f, 0.917969f, 0.927734f, 0.935547f, 0.944336f,
+ 0.951172f, 0.957031f, 0.983398f, 0.985352f, 0.985840f, 0.985352f, 0.985840f, 0.985352f, 0.000340f, 0.000735f, 0.001377f, 0.001853f,
+ 0.002382f, 0.003159f, 0.004021f, 0.004642f, 0.005604f, 0.006340f, 0.007298f, 0.008591f, 0.009895f, 0.011154f, 0.012871f, 0.014580f,
+ 0.016876f, 0.019180f, 0.022141f, 0.024979f, 0.028748f, 0.032745f, 0.037964f, 0.043213f, 0.050171f, 0.057831f, 0.066833f, 0.078247f,
+ 0.091553f, 0.107178f, 0.125977f, 0.148315f, 0.175415f, 0.207153f, 0.244019f, 0.286377f, 0.333008f, 0.383789f, 0.437744f, 0.491943f,
+ 0.545410f, 0.597168f, 0.645508f, 0.688965f, 0.729004f, 0.764160f, 0.794434f, 0.821289f, 0.843750f, 0.864258f, 0.881348f, 0.895996f,
+ 0.909180f, 0.920898f, 0.929199f, 0.938965f, 0.946777f, 0.952637f, 0.982910f, 0.983887f, 0.984863f, 0.984863f, 0.984375f, 0.984863f,
+ 0.000236f, 0.000605f, 0.001135f, 0.001415f, 0.002329f, 0.002747f, 0.003551f, 0.004158f, 0.004723f, 0.005535f, 0.006687f, 0.007534f,
+ 0.008545f, 0.009979f, 0.011375f, 0.012993f, 0.014656f, 0.016754f, 0.018921f, 0.021759f, 0.024506f, 0.028183f, 0.032043f, 0.036743f,
+ 0.042236f, 0.048645f, 0.056030f, 0.065125f, 0.075928f, 0.089050f, 0.104370f, 0.122681f, 0.145142f, 0.171509f, 0.202759f, 0.239258f,
+ 0.281250f, 0.328369f, 0.379639f, 0.433838f, 0.489014f, 0.543945f, 0.596191f, 0.645020f, 0.690430f, 0.730957f, 0.766113f, 0.797852f,
+ 0.824219f, 0.846680f, 0.867188f, 0.884766f, 0.899414f, 0.912109f, 0.923828f, 0.933105f, 0.942383f, 0.949707f, 0.980957f, 0.982910f,
+ 0.983398f, 0.983398f, 0.983887f, 0.982910f, 0.000214f, 0.000710f, 0.001021f, 0.001429f, 0.001858f, 0.002607f, 0.003220f, 0.003738f,
+ 0.004459f, 0.005032f, 0.005726f, 0.006748f, 0.007748f, 0.008659f, 0.010002f, 0.011368f, 0.012985f, 0.014656f, 0.016525f, 0.018921f,
+ 0.021286f, 0.024231f, 0.027649f, 0.031464f, 0.035858f, 0.041321f, 0.047363f, 0.054840f, 0.063538f, 0.074097f, 0.086609f, 0.101990f,
+ 0.120117f, 0.141846f, 0.168213f, 0.199219f, 0.235352f, 0.277344f, 0.324707f, 0.376953f, 0.432373f, 0.488037f, 0.543457f, 0.597168f,
+ 0.646973f, 0.692871f, 0.732910f, 0.769531f, 0.801270f, 0.828125f, 0.850586f, 0.871582f, 0.888184f, 0.903809f, 0.915527f, 0.927246f,
+ 0.936523f, 0.946289f, 0.979492f, 0.981445f, 0.981934f, 0.982422f, 0.981934f, 0.981934f, 0.000000f, 0.000468f, 0.001076f, 0.001489f,
+ 0.002048f, 0.002413f, 0.002853f, 0.003468f, 0.003952f, 0.004444f, 0.005211f, 0.005917f, 0.006733f, 0.007763f, 0.008713f, 0.010262f,
+ 0.011368f, 0.012733f, 0.014458f, 0.016296f, 0.018478f, 0.021072f, 0.023666f, 0.026810f, 0.030746f, 0.035278f, 0.040131f, 0.046295f,
+ 0.053711f, 0.062195f, 0.072327f, 0.084717f, 0.099487f, 0.117371f, 0.139038f, 0.164795f, 0.195923f, 0.232422f, 0.274414f, 0.322266f,
+ 0.374756f, 0.431641f, 0.488525f, 0.545410f, 0.599121f, 0.650879f, 0.697754f, 0.738770f, 0.774414f, 0.806641f, 0.832520f, 0.856445f,
+ 0.875488f, 0.893555f, 0.907715f, 0.920410f, 0.931152f, 0.940918f, 0.978027f, 0.980469f, 0.980469f, 0.980957f, 0.980957f, 0.980957f,
+ 0.000279f, 0.000497f, 0.000763f, 0.001353f, 0.001794f, 0.002079f, 0.002451f, 0.002956f, 0.003498f, 0.004150f, 0.004589f, 0.005310f,
+ 0.006130f, 0.006958f, 0.007828f, 0.008888f, 0.009895f, 0.011124f, 0.012772f, 0.014282f, 0.016235f, 0.018127f, 0.020630f, 0.022873f,
+ 0.026321f, 0.029938f, 0.034241f, 0.039368f, 0.045319f, 0.052338f, 0.060852f, 0.070801f, 0.082947f, 0.097595f, 0.115051f, 0.136353f,
+ 0.162231f, 0.193481f, 0.229858f, 0.272217f, 0.321777f, 0.375000f, 0.432373f, 0.490479f, 0.548340f, 0.604004f, 0.655762f, 0.702637f,
+ 0.743652f, 0.780273f, 0.812500f, 0.838867f, 0.862305f, 0.881348f, 0.897949f, 0.912598f, 0.925293f, 0.935547f, 0.976562f, 0.978516f,
+ 0.979492f, 0.979980f, 0.979492f, 0.979004f, 0.000110f, 0.000473f, 0.000781f, 0.001262f, 0.001584f, 0.001890f, 0.002270f, 0.002607f,
+ 0.003241f, 0.003704f, 0.004055f, 0.004795f, 0.005356f, 0.005997f, 0.006760f, 0.007896f, 0.008896f, 0.009918f, 0.011200f, 0.012451f,
+ 0.013802f, 0.015556f, 0.017838f, 0.020065f, 0.022751f, 0.025864f, 0.029358f, 0.033600f, 0.038574f, 0.044342f, 0.050995f, 0.059296f,
+ 0.069214f, 0.081116f, 0.095459f, 0.113159f, 0.133911f, 0.160400f, 0.191406f, 0.228638f, 0.272217f, 0.321289f, 0.375732f, 0.434326f,
+ 0.493896f, 0.552734f, 0.609863f, 0.662109f, 0.709961f, 0.750977f, 0.787598f, 0.819336f, 0.846680f, 0.868164f, 0.887695f, 0.904297f,
+ 0.917969f, 0.930176f, 0.975098f, 0.977539f, 0.977051f, 0.977539f, 0.977539f, 0.977539f, 0.000242f, 0.000464f, 0.000831f, 0.001027f,
+ 0.001271f, 0.001722f, 0.001965f, 0.002243f, 0.002714f, 0.003036f, 0.003651f, 0.004025f, 0.004902f, 0.005638f, 0.006176f, 0.006943f,
+ 0.007763f, 0.008789f, 0.009804f, 0.010872f, 0.012070f, 0.013695f, 0.015381f, 0.017395f, 0.019608f, 0.022232f, 0.025009f, 0.028885f,
+ 0.032623f, 0.037659f, 0.043182f, 0.050018f, 0.058167f, 0.067810f, 0.079224f, 0.093811f, 0.111328f, 0.132324f, 0.158569f, 0.190063f,
+ 0.228149f, 0.271973f, 0.322510f, 0.378906f, 0.438477f, 0.499756f, 0.560059f, 0.618164f, 0.671387f, 0.718750f, 0.760742f, 0.796875f,
+ 0.826660f, 0.854492f, 0.875000f, 0.894531f, 0.911133f, 0.923828f, 0.973145f, 0.976074f, 0.975586f, 0.976074f, 0.976074f, 0.977051f,
+ 0.000242f, 0.000552f, 0.000701f, 0.001063f, 0.001186f, 0.001462f, 0.001690f, 0.002340f, 0.002703f, 0.002728f, 0.003325f, 0.003828f,
+ 0.004333f, 0.004913f, 0.005474f, 0.006077f, 0.006943f, 0.007607f, 0.008553f, 0.009460f, 0.010582f, 0.011871f, 0.013451f, 0.015091f,
+ 0.016983f, 0.019165f, 0.021637f, 0.024673f, 0.027863f, 0.031525f, 0.036713f, 0.041962f, 0.048615f, 0.056396f, 0.066162f, 0.077942f,
+ 0.092590f, 0.110046f, 0.130981f, 0.157593f, 0.189331f, 0.228394f, 0.273926f, 0.325684f, 0.383301f, 0.444580f, 0.507324f, 0.569824f,
+ 0.627441f, 0.682129f, 0.729980f, 0.770508f, 0.807129f, 0.837402f, 0.863281f, 0.884766f, 0.902832f, 0.917969f, 0.971191f, 0.973633f,
+ 0.974609f, 0.974121f, 0.974609f, 0.974609f, 0.000239f, 0.000239f, 0.000658f, 0.000899f, 0.001204f, 0.001252f, 0.001629f, 0.001815f,
+ 0.002470f, 0.002430f, 0.003134f, 0.003321f, 0.003925f, 0.004238f, 0.004856f, 0.005341f, 0.006161f, 0.006615f, 0.007511f, 0.008224f,
+ 0.009277f, 0.010445f, 0.011818f, 0.013046f, 0.014473f, 0.016510f, 0.018814f, 0.021057f, 0.023834f, 0.027237f, 0.030853f, 0.035675f,
+ 0.040894f, 0.047241f, 0.055145f, 0.064758f, 0.076782f, 0.090942f, 0.108398f, 0.130371f, 0.157104f, 0.189819f, 0.229248f, 0.276367f,
+ 0.329834f, 0.390137f, 0.453125f, 0.517578f, 0.580566f, 0.640625f, 0.694336f, 0.741699f, 0.782715f, 0.817871f, 0.848145f, 0.872559f,
+ 0.893555f, 0.910645f, 0.969727f, 0.971191f, 0.972656f, 0.972168f, 0.972168f, 0.972168f, 0.000222f, 0.000463f, 0.000620f, 0.000837f,
+ 0.000900f, 0.001048f, 0.001381f, 0.001820f, 0.001957f, 0.002329f, 0.002747f, 0.002964f, 0.003330f, 0.003986f, 0.004322f, 0.004677f,
+ 0.005302f, 0.005760f, 0.006569f, 0.007359f, 0.008141f, 0.009293f, 0.010101f, 0.011452f, 0.012779f, 0.014496f, 0.016144f, 0.018097f,
+ 0.020157f, 0.023148f, 0.026611f, 0.029785f, 0.034515f, 0.039856f, 0.046478f, 0.054016f, 0.063843f, 0.075378f, 0.089233f, 0.107666f,
+ 0.129639f, 0.156860f, 0.190674f, 0.231445f, 0.280518f, 0.336426f, 0.398193f, 0.463379f, 0.530273f, 0.595215f, 0.654785f, 0.708984f,
+ 0.755371f, 0.796875f, 0.831543f, 0.860352f, 0.883789f, 0.903809f, 0.966797f, 0.968750f, 0.969727f, 0.970215f, 0.970215f, 0.969727f,
+ 0.000000f, 0.000345f, 0.000464f, 0.000686f, 0.000782f, 0.001030f, 0.001139f, 0.001598f, 0.001846f, 0.002237f, 0.002489f, 0.002684f,
+ 0.003067f, 0.003344f, 0.003895f, 0.004158f, 0.004845f, 0.005131f, 0.005886f, 0.006561f, 0.007195f, 0.007912f, 0.008965f, 0.009941f,
+ 0.010956f, 0.012383f, 0.013893f, 0.015602f, 0.017303f, 0.019623f, 0.022156f, 0.025452f, 0.028976f, 0.033722f, 0.038910f, 0.045288f,
+ 0.052887f, 0.062561f, 0.074097f, 0.088623f, 0.106812f, 0.129639f, 0.157715f, 0.192261f, 0.235107f, 0.285889f, 0.344482f, 0.408691f,
+ 0.476807f, 0.545410f, 0.610840f, 0.671387f, 0.725098f, 0.771484f, 0.811035f, 0.843750f, 0.871582f, 0.894043f, 0.964355f, 0.967285f,
+ 0.967285f, 0.967773f, 0.967773f, 0.967773f, 0.000000f, 0.000320f, 0.000576f, 0.000572f, 0.000767f, 0.000945f, 0.001066f, 0.001375f,
+ 0.001848f, 0.001980f, 0.002190f, 0.002399f, 0.002695f, 0.002943f, 0.003397f, 0.003664f, 0.004063f, 0.004566f, 0.005119f, 0.005688f,
+ 0.006130f, 0.007057f, 0.007778f, 0.008675f, 0.009590f, 0.010666f, 0.011971f, 0.013443f, 0.015129f, 0.016953f, 0.018875f, 0.021576f,
+ 0.024658f, 0.028488f, 0.032959f, 0.037811f, 0.043793f, 0.051819f, 0.061371f, 0.073181f, 0.088257f, 0.106506f, 0.129883f, 0.159180f,
+ 0.195679f, 0.240479f, 0.293457f, 0.355225f, 0.422852f, 0.492432f, 0.563477f, 0.629883f, 0.690918f, 0.743652f, 0.789062f, 0.827148f,
+ 0.858398f, 0.884277f, 0.961914f, 0.964844f, 0.964355f, 0.964844f, 0.964355f, 0.965332f, 0.000000f, 0.000242f, 0.000435f, 0.000547f,
+ 0.000688f, 0.000803f, 0.001175f, 0.001318f, 0.001593f, 0.001652f, 0.001961f, 0.002209f, 0.002481f, 0.002716f, 0.002911f, 0.003210f,
+ 0.003595f, 0.004005f, 0.004490f, 0.004894f, 0.005508f, 0.006107f, 0.006714f, 0.007462f, 0.008438f, 0.009277f, 0.010170f, 0.011436f,
+ 0.012756f, 0.014145f, 0.016205f, 0.018433f, 0.020966f, 0.023819f, 0.027405f, 0.031464f, 0.036713f, 0.043152f, 0.050842f, 0.060577f,
+ 0.071960f, 0.087219f, 0.106689f, 0.130371f, 0.161377f, 0.199585f, 0.246948f, 0.303467f, 0.367920f, 0.439697f, 0.512207f, 0.584473f,
+ 0.651855f, 0.712402f, 0.764160f, 0.808105f, 0.844727f, 0.875000f, 0.958008f, 0.961426f, 0.961914f, 0.961914f, 0.962402f, 0.961914f,
+ 0.000000f, 0.000237f, 0.000266f, 0.000387f, 0.000557f, 0.000691f, 0.000774f, 0.001221f, 0.001455f, 0.001492f, 0.001769f, 0.001896f,
+ 0.002151f, 0.002386f, 0.002529f, 0.002911f, 0.003147f, 0.003523f, 0.003862f, 0.004311f, 0.004848f, 0.005260f, 0.005795f, 0.006416f,
+ 0.007114f, 0.007942f, 0.008667f, 0.009666f, 0.010818f, 0.012184f, 0.013718f, 0.015541f, 0.017685f, 0.020126f, 0.023056f, 0.026306f,
+ 0.030853f, 0.035797f, 0.042053f, 0.049683f, 0.059784f, 0.072144f, 0.086914f, 0.106873f, 0.132202f, 0.164429f, 0.205200f, 0.255615f,
+ 0.315918f, 0.384521f, 0.458984f, 0.534668f, 0.607910f, 0.676758f, 0.735840f, 0.785645f, 0.828125f, 0.862305f, 0.955566f, 0.958008f,
+ 0.958984f, 0.958496f, 0.958984f, 0.958984f, 0.000000f, 0.000119f, 0.000234f, 0.000484f, 0.000603f, 0.000758f, 0.000934f, 0.000999f,
+ 0.001200f, 0.001343f, 0.001534f, 0.001725f, 0.001860f, 0.002056f, 0.002235f, 0.002445f, 0.002783f, 0.003115f, 0.003448f, 0.003757f,
+ 0.004192f, 0.004723f, 0.005077f, 0.005653f, 0.006172f, 0.006527f, 0.007328f, 0.008247f, 0.009140f, 0.010368f, 0.011711f, 0.013351f,
+ 0.014702f, 0.016937f, 0.019226f, 0.022156f, 0.025604f, 0.029877f, 0.034668f, 0.040710f, 0.048920f, 0.058624f, 0.071289f, 0.087219f,
+ 0.107727f, 0.134521f, 0.168701f, 0.212769f, 0.267090f, 0.331543f, 0.404785f, 0.482910f, 0.561523f, 0.635742f, 0.702637f, 0.760742f,
+ 0.809570f, 0.849121f, 0.951660f, 0.954590f, 0.955566f, 0.955566f, 0.956055f, 0.955566f, 0.000238f, 0.000218f, 0.000229f, 0.000242f,
+ 0.000313f, 0.000859f, 0.000623f, 0.000978f, 0.001021f, 0.001150f, 0.001320f, 0.001431f, 0.001546f, 0.001746f, 0.001895f, 0.002106f,
+ 0.002502f, 0.002630f, 0.002926f, 0.003296f, 0.003651f, 0.003918f, 0.004391f, 0.004910f, 0.005249f, 0.005558f, 0.006413f, 0.007114f,
+ 0.007866f, 0.008789f, 0.009872f, 0.011093f, 0.012413f, 0.013939f, 0.015945f, 0.018692f, 0.021225f, 0.024643f, 0.028687f, 0.033936f,
+ 0.040192f, 0.047791f, 0.058014f, 0.070923f, 0.087585f, 0.109131f, 0.137573f, 0.174683f, 0.222290f, 0.280762f, 0.350830f, 0.428955f,
+ 0.511230f, 0.592285f, 0.666992f, 0.733398f, 0.789062f, 0.834473f, 0.947754f, 0.951172f, 0.951660f, 0.951172f, 0.951660f, 0.951172f,
+ 0.000000f, 0.000205f, 0.000222f, 0.000344f, 0.000301f, 0.000775f, 0.000827f, 0.000719f, 0.000944f, 0.000976f, 0.001306f, 0.001249f,
+ 0.001404f, 0.001569f, 0.001604f, 0.001819f, 0.002182f, 0.002354f, 0.002569f, 0.002857f, 0.003113f, 0.003426f, 0.003649f, 0.004112f,
+ 0.004307f, 0.004925f, 0.005508f, 0.005802f, 0.006565f, 0.007450f, 0.008125f, 0.009079f, 0.010269f, 0.011665f, 0.013565f, 0.015213f,
+ 0.017410f, 0.020203f, 0.023743f, 0.028168f, 0.032684f, 0.039062f, 0.047058f, 0.057404f, 0.070984f, 0.088623f, 0.111389f, 0.142090f,
+ 0.182373f, 0.234253f, 0.298828f, 0.375000f, 0.458008f, 0.543945f, 0.627441f, 0.702148f, 0.765137f, 0.818359f, 0.942871f, 0.946289f,
+ 0.947266f, 0.947266f, 0.946777f, 0.947266f, 0.000064f, 0.000095f, 0.000197f, 0.000213f, 0.000459f, 0.000491f, 0.000647f, 0.000696f,
+ 0.000884f, 0.000911f, 0.001121f, 0.001115f, 0.001234f, 0.001371f, 0.001410f, 0.001743f, 0.001905f, 0.002016f, 0.002207f, 0.002438f,
+ 0.002714f, 0.002939f, 0.003183f, 0.003323f, 0.003727f, 0.004143f, 0.004555f, 0.005276f, 0.005531f, 0.006264f, 0.006702f, 0.007572f,
+ 0.008705f, 0.009712f, 0.011238f, 0.012650f, 0.014320f, 0.016815f, 0.019516f, 0.022400f, 0.026566f, 0.031799f, 0.038055f, 0.046417f,
+ 0.057037f, 0.071350f, 0.089722f, 0.114868f, 0.148193f, 0.192749f, 0.249878f, 0.321045f, 0.404053f, 0.493408f, 0.583008f, 0.666016f,
+ 0.739258f, 0.799316f, 0.937988f, 0.941406f, 0.941895f, 0.942383f, 0.942383f, 0.942383f, 0.000000f, 0.000007f, 0.000144f, 0.000427f,
+ 0.000443f, 0.000566f, 0.000589f, 0.000615f, 0.000725f, 0.000731f, 0.000896f, 0.000953f, 0.001062f, 0.001167f, 0.001344f, 0.001345f,
+ 0.001636f, 0.001774f, 0.001893f, 0.002069f, 0.002350f, 0.002457f, 0.002678f, 0.002743f, 0.003105f, 0.003513f, 0.003830f, 0.004227f,
+ 0.004589f, 0.005047f, 0.005669f, 0.006176f, 0.007153f, 0.007896f, 0.008911f, 0.010231f, 0.011818f, 0.013618f, 0.015465f, 0.018188f,
+ 0.021576f, 0.025452f, 0.030533f, 0.037048f, 0.045685f, 0.056915f, 0.071533f, 0.091675f, 0.118958f, 0.156006f, 0.205444f, 0.270020f,
+ 0.349609f, 0.439941f, 0.533691f, 0.625977f, 0.708984f, 0.778320f, 0.931641f, 0.936035f, 0.936523f, 0.937012f, 0.937012f, 0.937012f,
+ 0.000000f, 0.000000f, 0.000137f, 0.000262f, 0.000432f, 0.000437f, 0.000444f, 0.000590f, 0.000558f, 0.000606f, 0.000817f, 0.000877f,
+ 0.000909f, 0.000951f, 0.001191f, 0.001244f, 0.001373f, 0.001506f, 0.001702f, 0.001690f, 0.001955f, 0.001940f, 0.002283f, 0.002340f,
+ 0.002571f, 0.002871f, 0.003265f, 0.003475f, 0.003910f, 0.004181f, 0.004608f, 0.005112f, 0.005833f, 0.006416f, 0.007145f, 0.008209f,
+ 0.009636f, 0.010750f, 0.012642f, 0.014481f, 0.017197f, 0.020203f, 0.024353f, 0.029694f, 0.036041f, 0.045105f, 0.056702f, 0.072388f,
+ 0.094482f, 0.124329f, 0.166504f, 0.223022f, 0.295898f, 0.384766f, 0.482910f, 0.582031f, 0.675293f, 0.754883f, 0.926270f, 0.929688f,
+ 0.930664f, 0.930664f, 0.931152f, 0.930664f, 0.000000f, 0.000000f, 0.000000f, 0.000232f, 0.000357f, 0.000411f, 0.000513f, 0.000527f,
+ 0.000490f, 0.000504f, 0.000653f, 0.000750f, 0.000780f, 0.000976f, 0.000942f, 0.000967f, 0.001180f, 0.001252f, 0.001385f, 0.001425f,
+ 0.001559f, 0.001801f, 0.001886f, 0.002144f, 0.002111f, 0.002354f, 0.002645f, 0.002827f, 0.003187f, 0.003414f, 0.003792f, 0.004360f,
+ 0.004662f, 0.005146f, 0.005875f, 0.006783f, 0.007610f, 0.008797f, 0.010033f, 0.011566f, 0.013565f, 0.016006f, 0.019165f, 0.023163f,
+ 0.028320f, 0.035400f, 0.044647f, 0.057129f, 0.074402f, 0.098572f, 0.132812f, 0.180542f, 0.245728f, 0.330078f, 0.428955f, 0.535156f,
+ 0.638184f, 0.728516f, 0.919434f, 0.922852f, 0.923828f, 0.923828f, 0.923828f, 0.924316f, 0.000000f, 0.000000f, 0.000000f, 0.000114f,
+ 0.000248f, 0.000359f, 0.000386f, 0.000342f, 0.000465f, 0.000461f, 0.000490f, 0.000609f, 0.000638f, 0.000694f, 0.000807f, 0.000923f,
+ 0.000961f, 0.001074f, 0.001123f, 0.001268f, 0.001311f, 0.001494f, 0.001537f, 0.001754f, 0.001899f, 0.001917f, 0.002199f, 0.002241f,
+ 0.002583f, 0.002769f, 0.003101f, 0.003441f, 0.003775f, 0.004200f, 0.004787f, 0.005272f, 0.006062f, 0.006702f, 0.007732f, 0.009102f,
+ 0.010582f, 0.012466f, 0.014984f, 0.017990f, 0.021957f, 0.027222f, 0.034332f, 0.044128f, 0.057434f, 0.076538f, 0.104126f, 0.143799f,
+ 0.199829f, 0.275879f, 0.373047f, 0.482422f, 0.594727f, 0.698730f, 0.910645f, 0.914551f, 0.916504f, 0.916016f, 0.916504f, 0.915527f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000121f, 0.000221f, 0.000222f, 0.000392f, 0.000402f, 0.000396f, 0.000434f, 0.000476f, 0.000548f,
+ 0.000536f, 0.000644f, 0.000642f, 0.000793f, 0.000795f, 0.000912f, 0.000953f, 0.000989f, 0.001164f, 0.001197f, 0.001285f, 0.001480f,
+ 0.001511f, 0.001674f, 0.001703f, 0.001901f, 0.002075f, 0.002340f, 0.002499f, 0.002800f, 0.003019f, 0.003296f, 0.003695f, 0.004093f,
+ 0.004780f, 0.005260f, 0.006207f, 0.006939f, 0.008034f, 0.009598f, 0.011353f, 0.013702f, 0.016678f, 0.020874f, 0.026062f, 0.033539f,
+ 0.044006f, 0.058746f, 0.080139f, 0.111877f, 0.158447f, 0.226318f, 0.317627f, 0.428711f, 0.548828f, 0.665039f, 0.901367f, 0.907227f,
+ 0.907715f, 0.908203f, 0.908203f, 0.907227f, 0.000000f, 0.000000f, 0.000122f, 0.000173f, 0.000191f, 0.000215f, 0.000224f, 0.000261f,
+ 0.000340f, 0.000374f, 0.000380f, 0.000496f, 0.000416f, 0.000535f, 0.000592f, 0.000622f, 0.000701f, 0.000772f, 0.000742f, 0.000774f,
+ 0.000990f, 0.000945f, 0.001088f, 0.001105f, 0.001348f, 0.001231f, 0.001460f, 0.001620f, 0.001758f, 0.001941f, 0.002008f, 0.002092f,
+ 0.002430f, 0.002615f, 0.002886f, 0.003208f, 0.003519f, 0.004112f, 0.004704f, 0.005371f, 0.006149f, 0.007351f, 0.008659f, 0.010201f,
+ 0.012550f, 0.015549f, 0.019577f, 0.025436f, 0.032928f, 0.044220f, 0.060608f, 0.084961f, 0.123474f, 0.180664f, 0.263184f, 0.372314f,
+ 0.498291f, 0.626465f, 0.892578f, 0.895996f, 0.896973f, 0.896973f, 0.897949f, 0.897949f, 0.000000f, 0.000000f, 0.000121f, 0.000121f,
+ 0.000120f, 0.000192f, 0.000201f, 0.000222f, 0.000222f, 0.000276f, 0.000295f, 0.000344f, 0.000433f, 0.000470f, 0.000485f, 0.000549f,
+ 0.000555f, 0.000558f, 0.000566f, 0.000639f, 0.000678f, 0.000757f, 0.000840f, 0.000905f, 0.000999f, 0.000946f, 0.001018f, 0.001309f,
+ 0.001402f, 0.001417f, 0.001624f, 0.001692f, 0.001869f, 0.002003f, 0.002184f, 0.002602f, 0.002851f, 0.003157f, 0.003595f, 0.004063f,
+ 0.004734f, 0.005398f, 0.006275f, 0.007542f, 0.009148f, 0.011383f, 0.014275f, 0.018250f, 0.024063f, 0.032135f, 0.044922f, 0.063721f,
+ 0.093811f, 0.139648f, 0.211914f, 0.314697f, 0.444092f, 0.584961f, 0.879883f, 0.884766f, 0.885254f, 0.885742f, 0.886230f, 0.885742f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000120f, 0.000120f, 0.000154f, 0.000150f, 0.000160f, 0.000202f, 0.000217f, 0.000308f, 0.000319f,
+ 0.000278f, 0.000392f, 0.000362f, 0.000432f, 0.000416f, 0.000448f, 0.000495f, 0.000526f, 0.000710f, 0.000754f, 0.000657f, 0.000755f,
+ 0.000806f, 0.000919f, 0.000815f, 0.001080f, 0.001152f, 0.001207f, 0.001218f, 0.001373f, 0.001320f, 0.001685f, 0.001764f, 0.001819f,
+ 0.002068f, 0.002380f, 0.002668f, 0.003033f, 0.003584f, 0.003979f, 0.004829f, 0.005402f, 0.006630f, 0.008080f, 0.010254f, 0.013069f,
+ 0.017044f, 0.023422f, 0.031647f, 0.046417f, 0.068604f, 0.104919f, 0.165161f, 0.258789f, 0.387207f, 0.537598f, 0.867188f, 0.871582f,
+ 0.872559f, 0.872559f, 0.872559f, 0.873047f, 0.000000f, 0.000121f, 0.000120f, 0.000120f, 0.000119f, 0.000118f, 0.000122f, 0.000108f,
+ 0.000143f, 0.000149f, 0.000184f, 0.000194f, 0.000189f, 0.000210f, 0.000321f, 0.000282f, 0.000376f, 0.000420f, 0.000533f, 0.000437f,
+ 0.000467f, 0.000477f, 0.000587f, 0.000519f, 0.000673f, 0.000662f, 0.000679f, 0.000845f, 0.000881f, 0.000863f, 0.001016f, 0.001093f,
+ 0.001176f, 0.001191f, 0.001336f, 0.001561f, 0.001573f, 0.001754f, 0.001919f, 0.002264f, 0.002596f, 0.002911f, 0.003372f, 0.003870f,
+ 0.004723f, 0.005733f, 0.007092f, 0.008965f, 0.011650f, 0.015701f, 0.022339f, 0.032043f, 0.048370f, 0.076050f, 0.124084f, 0.204834f,
+ 0.328369f, 0.485596f, 0.852539f, 0.856934f, 0.858887f, 0.858887f, 0.858887f, 0.858398f, 0.000000f, 0.000121f, 0.000120f, 0.000119f,
+ 0.000118f, 0.000117f, 0.000116f, 0.000114f, 0.000105f, 0.000110f, 0.000165f, 0.000133f, 0.000157f, 0.000240f, 0.000256f, 0.000257f,
+ 0.000249f, 0.000303f, 0.000342f, 0.000346f, 0.000485f, 0.000510f, 0.000398f, 0.000493f, 0.000492f, 0.000524f, 0.000590f, 0.000585f,
+ 0.000601f, 0.000740f, 0.000647f, 0.000871f, 0.000834f, 0.000969f, 0.001020f, 0.001190f, 0.001244f, 0.001432f, 0.001393f, 0.001702f,
+ 0.001912f, 0.002171f, 0.002445f, 0.002958f, 0.003330f, 0.004025f, 0.004860f, 0.006161f, 0.007896f, 0.010742f, 0.014671f, 0.021378f,
+ 0.032928f, 0.052612f, 0.089050f, 0.155884f, 0.268555f, 0.430664f, 0.836426f, 0.841309f, 0.841309f, 0.842285f, 0.842773f, 0.842285f,
+ 0.000000f, 0.000000f, 0.000119f, 0.000117f, 0.000116f, 0.000115f, 0.000114f, 0.000114f, 0.000111f, 0.000103f, 0.000097f, 0.000118f,
+ 0.000115f, 0.000130f, 0.000176f, 0.000130f, 0.000223f, 0.000235f, 0.000244f, 0.000252f, 0.000274f, 0.000389f, 0.000309f, 0.000430f,
+ 0.000340f, 0.000399f, 0.000408f, 0.000459f, 0.000514f, 0.000501f, 0.000519f, 0.000657f, 0.000588f, 0.000775f, 0.000813f, 0.000789f,
+ 0.000904f, 0.001076f, 0.001027f, 0.001170f, 0.001342f, 0.001425f, 0.001662f, 0.002005f, 0.002298f, 0.002699f, 0.003227f, 0.003990f,
+ 0.005062f, 0.006855f, 0.009415f, 0.013504f, 0.020905f, 0.034424f, 0.060333f, 0.112000f, 0.210693f, 0.371094f, 0.816406f, 0.822754f,
+ 0.822754f, 0.823242f, 0.823242f, 0.823730f, 0.000000f, 0.000119f, 0.000117f, 0.000116f, 0.000114f, 0.000113f, 0.000112f, 0.000111f,
+ 0.000110f, 0.000109f, 0.000102f, 0.000095f, 0.000090f, 0.000084f, 0.000093f, 0.000103f, 0.000118f, 0.000165f, 0.000162f, 0.000190f,
+ 0.000204f, 0.000218f, 0.000223f, 0.000237f, 0.000256f, 0.000272f, 0.000344f, 0.000365f, 0.000365f, 0.000396f, 0.000386f, 0.000412f,
+ 0.000530f, 0.000466f, 0.000492f, 0.000615f, 0.000611f, 0.000748f, 0.000712f, 0.000795f, 0.000908f, 0.000971f, 0.001106f, 0.001353f,
+ 0.001572f, 0.001822f, 0.002251f, 0.002676f, 0.003290f, 0.004349f, 0.005951f, 0.008316f, 0.012543f, 0.021149f, 0.038025f, 0.075500f,
+ 0.156006f, 0.308838f, 0.794922f, 0.800293f, 0.800781f, 0.801270f, 0.801758f, 0.802246f, 0.000121f, 0.000116f, 0.000114f, 0.000113f,
+ 0.000111f, 0.000109f, 0.000108f, 0.000107f, 0.000106f, 0.000104f, 0.000104f, 0.000100f, 0.000094f, 0.000088f, 0.000083f, 0.000078f,
+ 0.000074f, 0.000105f, 0.000078f, 0.000122f, 0.000113f, 0.000153f, 0.000174f, 0.000175f, 0.000207f, 0.000216f, 0.000225f, 0.000215f,
+ 0.000262f, 0.000308f, 0.000297f, 0.000287f, 0.000307f, 0.000342f, 0.000363f, 0.000411f, 0.000401f, 0.000453f, 0.000522f, 0.000555f,
+ 0.000680f, 0.000701f, 0.000751f, 0.000873f, 0.000966f, 0.001181f, 0.001445f, 0.001666f, 0.002077f, 0.002512f, 0.003359f, 0.004856f,
+ 0.007347f, 0.012001f, 0.022049f, 0.046417f, 0.107117f, 0.245361f, 0.770508f, 0.775879f, 0.776367f, 0.776855f, 0.777344f, 0.777832f,
+ 0.000000f, 0.000113f, 0.000108f, 0.000107f, 0.000104f, 0.000103f, 0.000101f, 0.000100f, 0.000099f, 0.000098f, 0.000097f, 0.000096f,
+ 0.000095f, 0.000091f, 0.000086f, 0.000081f, 0.000077f, 0.000073f, 0.000069f, 0.000079f, 0.000084f, 0.000091f, 0.000074f, 0.000100f,
+ 0.000117f, 0.000140f, 0.000144f, 0.000166f, 0.000174f, 0.000178f, 0.000225f, 0.000197f, 0.000234f, 0.000239f, 0.000273f, 0.000289f,
+ 0.000283f, 0.000293f, 0.000338f, 0.000386f, 0.000386f, 0.000432f, 0.000459f, 0.000525f, 0.000625f, 0.000691f, 0.000800f, 0.001004f,
+ 0.001227f, 0.001479f, 0.001984f, 0.002745f, 0.003983f, 0.006413f, 0.011642f, 0.025269f, 0.066040f, 0.182495f, 0.743164f, 0.748535f,
+ 0.749023f, 0.749512f, 0.750000f, 0.749512f, 0.000000f, 0.000102f, 0.000101f, 0.000098f, 0.000094f, 0.000093f, 0.000092f, 0.000090f,
+ 0.000089f, 0.000088f, 0.000087f, 0.000086f, 0.000085f, 0.000084f, 0.000085f, 0.000082f, 0.000078f, 0.000074f, 0.000070f, 0.000066f,
+ 0.000063f, 0.000060f, 0.000057f, 0.000056f, 0.000061f, 0.000060f, 0.000073f, 0.000087f, 0.000100f, 0.000105f, 0.000124f, 0.000136f,
+ 0.000140f, 0.000140f, 0.000159f, 0.000179f, 0.000186f, 0.000205f, 0.000214f, 0.000229f, 0.000248f, 0.000267f, 0.000299f, 0.000344f,
+ 0.000367f, 0.000422f, 0.000496f, 0.000557f, 0.000639f, 0.000837f, 0.001037f, 0.001419f, 0.002081f, 0.003202f, 0.005730f, 0.012199f,
+ 0.034943f, 0.122925f, 0.711426f, 0.716797f, 0.718750f, 0.718262f, 0.718262f, 0.718750f, 0.000094f, 0.000079f, 0.000078f, 0.000074f,
+ 0.000074f, 0.000075f, 0.000074f, 0.000073f, 0.000071f, 0.000072f, 0.000070f, 0.000071f, 0.000071f, 0.000070f, 0.000070f, 0.000069f,
+ 0.000070f, 0.000069f, 0.000068f, 0.000065f, 0.000062f, 0.000059f, 0.000056f, 0.000053f, 0.000050f, 0.000048f, 0.000045f, 0.000044f,
+ 0.000041f, 0.000050f, 0.000050f, 0.000061f, 0.000068f, 0.000085f, 0.000091f, 0.000101f, 0.000102f, 0.000107f, 0.000119f, 0.000129f,
+ 0.000144f, 0.000151f, 0.000160f, 0.000184f, 0.000212f, 0.000213f, 0.000235f, 0.000294f, 0.000315f, 0.000392f, 0.000505f, 0.000637f,
+ 0.000880f, 0.001400f, 0.002462f, 0.005333f, 0.015160f, 0.070312f, 0.678223f, 0.683105f, 0.684082f, 0.684570f, 0.684570f, 0.684570f,
+ 0.000000f, 0.000000f, 0.000023f, 0.000034f, 0.000032f, 0.000038f, 0.000037f, 0.000044f, 0.000043f, 0.000047f, 0.000045f, 0.000047f,
+ 0.000049f, 0.000049f, 0.000049f, 0.000048f, 0.000051f, 0.000050f, 0.000051f, 0.000051f, 0.000052f, 0.000052f, 0.000052f, 0.000049f,
+ 0.000047f, 0.000045f, 0.000042f, 0.000040f, 0.000038f, 0.000036f, 0.000035f, 0.000033f, 0.000031f, 0.000029f, 0.000038f, 0.000037f,
+ 0.000042f, 0.000051f, 0.000055f, 0.000067f, 0.000074f, 0.000073f, 0.000083f, 0.000093f, 0.000088f, 0.000102f, 0.000122f, 0.000122f,
+ 0.000142f, 0.000169f, 0.000206f, 0.000265f, 0.000355f, 0.000531f, 0.000897f, 0.001822f, 0.005493f, 0.030579f, 0.640137f, 0.644531f,
+ 0.647461f, 0.647949f, 0.647461f, 0.648438f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000001f, 0.000000f, 0.000008f, 0.000012f, 0.000014f, 0.000014f, 0.000019f, 0.000021f, 0.000022f, 0.000024f, 0.000026f, 0.000027f,
+ 0.000027f, 0.000028f, 0.000029f, 0.000031f, 0.000031f, 0.000032f, 0.000032f, 0.000033f, 0.000033f, 0.000032f, 0.000030f, 0.000029f,
+ 0.000027f, 0.000026f, 0.000024f, 0.000023f, 0.000022f, 0.000021f, 0.000019f, 0.000018f, 0.000021f, 0.000024f, 0.000028f, 0.000033f,
+ 0.000043f, 0.000041f, 0.000046f, 0.000053f, 0.000050f, 0.000059f, 0.000068f, 0.000094f, 0.000096f, 0.000140f, 0.000239f, 0.000447f,
+ 0.001340f, 0.009087f, 0.600098f, 0.605957f, 0.606934f, 0.606934f, 0.607422f, 0.606934f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000002f, 0.000004f, 0.000006f, 0.000006f,
+ 0.000009f, 0.000010f, 0.000011f, 0.000012f, 0.000013f, 0.000014f, 0.000015f, 0.000016f, 0.000017f, 0.000016f, 0.000015f, 0.000014f,
+ 0.000013f, 0.000012f, 0.000012f, 0.000011f, 0.000010f, 0.000009f, 0.000008f, 0.000012f, 0.000014f, 0.000018f, 0.000017f, 0.000022f,
+ 0.000022f, 0.000026f, 0.000040f, 0.000060f, 0.000157f, 0.001244f, 0.557129f, 0.563477f, 0.563477f, 0.564941f, 0.564941f, 0.564941f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000001f, 0.000002f, 0.000003f,
+ 0.000003f, 0.000004f, 0.000003f, 0.000003f, 0.000003f, 0.000002f, 0.000003f, 0.000003f, 0.000003f, 0.000012f, 0.513672f, 0.520020f,
+ 0.520020f, 0.520508f, 0.521484f, 0.521484f,
+ },
+ {
+ 0.103943f, 0.284912f, 0.422119f, 0.523438f, 0.600586f, 0.659668f, 0.705078f, 0.741699f, 0.771484f, 0.795898f, 0.816895f, 0.834961f,
+ 0.850586f, 0.862793f, 0.874512f, 0.884277f, 0.894043f, 0.901855f, 0.909180f, 0.915039f, 0.921387f, 0.926270f, 0.932129f, 0.936035f,
+ 0.940430f, 0.944336f, 0.948242f, 0.951660f, 0.954590f, 0.957520f, 0.959961f, 0.962891f, 0.965332f, 0.967285f, 0.969727f, 0.971680f,
+ 0.973145f, 0.975586f, 0.977051f, 0.979004f, 0.979980f, 0.981934f, 0.983887f, 0.984375f, 0.985840f, 0.986816f, 0.988770f, 0.989258f,
+ 0.990723f, 0.992188f, 0.992676f, 0.993652f, 0.994629f, 0.995605f, 0.996582f, 0.997559f, 0.998535f, 0.999023f, 0.999512f, 0.999023f,
+ 0.998535f, 0.998047f, 0.997559f, 0.997070f, 0.046997f, 0.153564f, 0.264160f, 0.369385f, 0.460205f, 0.538574f, 0.602051f, 0.654785f,
+ 0.697754f, 0.733398f, 0.762695f, 0.787598f, 0.809082f, 0.827637f, 0.843262f, 0.856934f, 0.868652f, 0.880859f, 0.889648f, 0.898438f,
+ 0.906738f, 0.912598f, 0.918945f, 0.924805f, 0.929688f, 0.935059f, 0.938965f, 0.943359f, 0.947266f, 0.951172f, 0.954102f, 0.956543f,
+ 0.959961f, 0.961914f, 0.964844f, 0.966797f, 0.969727f, 0.971191f, 0.974121f, 0.975098f, 0.977051f, 0.979492f, 0.980469f, 0.981934f,
+ 0.983887f, 0.985352f, 0.985840f, 0.987305f, 0.989258f, 0.990234f, 0.991211f, 0.992188f, 0.993164f, 0.994141f, 0.995117f, 0.996094f,
+ 0.996582f, 0.997559f, 0.999023f, 0.998535f, 0.998047f, 0.997559f, 0.997070f, 0.997070f, 0.025940f, 0.088501f, 0.162964f, 0.246094f,
+ 0.331055f, 0.411865f, 0.486328f, 0.550293f, 0.606934f, 0.655762f, 0.695312f, 0.729980f, 0.758301f, 0.783691f, 0.804199f, 0.823730f,
+ 0.838867f, 0.853027f, 0.865723f, 0.877441f, 0.887207f, 0.895996f, 0.904785f, 0.911133f, 0.916992f, 0.923828f, 0.928223f, 0.933594f,
+ 0.937988f, 0.942871f, 0.946777f, 0.950195f, 0.953613f, 0.956543f, 0.959473f, 0.962402f, 0.964844f, 0.967285f, 0.970215f, 0.971680f,
+ 0.973633f, 0.976074f, 0.977539f, 0.979492f, 0.980469f, 0.982422f, 0.984863f, 0.985352f, 0.986816f, 0.987793f, 0.989258f, 0.990234f,
+ 0.991699f, 0.992676f, 0.994141f, 0.995117f, 0.995605f, 0.996582f, 0.998535f, 0.998047f, 0.998047f, 0.997559f, 0.997070f, 0.996582f,
+ 0.016159f, 0.055176f, 0.104126f, 0.162720f, 0.229126f, 0.300781f, 0.372803f, 0.442871f, 0.506836f, 0.563477f, 0.613281f, 0.657715f,
+ 0.696289f, 0.729004f, 0.757324f, 0.782227f, 0.802734f, 0.821289f, 0.837402f, 0.852539f, 0.865234f, 0.875977f, 0.885742f, 0.895508f,
+ 0.903320f, 0.910156f, 0.917480f, 0.922852f, 0.928711f, 0.934082f, 0.937988f, 0.942871f, 0.947266f, 0.950195f, 0.954102f, 0.957031f,
+ 0.959473f, 0.962402f, 0.964844f, 0.968262f, 0.969727f, 0.972168f, 0.974121f, 0.976562f, 0.978516f, 0.979980f, 0.981934f, 0.982910f,
+ 0.983887f, 0.985840f, 0.986816f, 0.988770f, 0.989746f, 0.991211f, 0.992188f, 0.993652f, 0.994141f, 0.995117f, 0.998047f, 0.997559f,
+ 0.997559f, 0.997070f, 0.996582f, 0.996582f, 0.010841f, 0.036865f, 0.070007f, 0.110962f, 0.159546f, 0.214355f, 0.276367f, 0.340576f,
+ 0.405029f, 0.465820f, 0.523926f, 0.576172f, 0.623535f, 0.664062f, 0.699707f, 0.731445f, 0.758301f, 0.782227f, 0.803223f, 0.821289f,
+ 0.837891f, 0.852051f, 0.864258f, 0.875488f, 0.884766f, 0.894531f, 0.903320f, 0.910156f, 0.916992f, 0.923828f, 0.928223f, 0.933594f,
+ 0.938477f, 0.943359f, 0.947266f, 0.950684f, 0.954102f, 0.957520f, 0.960449f, 0.962891f, 0.965820f, 0.968750f, 0.971191f, 0.973145f,
+ 0.975586f, 0.977539f, 0.978516f, 0.980957f, 0.982422f, 0.984375f, 0.985352f, 0.987305f, 0.988281f, 0.989746f, 0.990723f, 0.992188f,
+ 0.993164f, 0.994141f, 0.997559f, 0.997559f, 0.997070f, 0.996582f, 0.996582f, 0.996094f, 0.007637f, 0.026566f, 0.049896f, 0.078247f,
+ 0.113403f, 0.154663f, 0.202637f, 0.255371f, 0.313232f, 0.372314f, 0.431152f, 0.488037f, 0.540039f, 0.588867f, 0.633301f, 0.670898f,
+ 0.704102f, 0.734375f, 0.761230f, 0.785156f, 0.804688f, 0.822754f, 0.838867f, 0.852539f, 0.864746f, 0.876953f, 0.886230f, 0.895996f,
+ 0.903320f, 0.910645f, 0.917480f, 0.923828f, 0.929199f, 0.935059f, 0.938965f, 0.943359f, 0.948730f, 0.952148f, 0.954590f, 0.958496f,
+ 0.961426f, 0.964355f, 0.966797f, 0.969238f, 0.971680f, 0.974121f, 0.976074f, 0.978027f, 0.979980f, 0.981445f, 0.982910f, 0.984863f,
+ 0.986816f, 0.987793f, 0.989258f, 0.990723f, 0.991699f, 0.993164f, 0.996582f, 0.996582f, 0.996094f, 0.996094f, 0.996094f, 0.995605f,
+ 0.005714f, 0.019485f, 0.036194f, 0.056976f, 0.082336f, 0.113342f, 0.149048f, 0.191284f, 0.238770f, 0.290039f, 0.344727f, 0.400391f,
+ 0.454590f, 0.507324f, 0.557129f, 0.602539f, 0.642578f, 0.679199f, 0.711426f, 0.740234f, 0.766602f, 0.788574f, 0.807617f, 0.825195f,
+ 0.841309f, 0.854980f, 0.867676f, 0.877930f, 0.888184f, 0.896484f, 0.904785f, 0.912109f, 0.918945f, 0.925293f, 0.930176f, 0.935547f,
+ 0.940918f, 0.944336f, 0.948730f, 0.952637f, 0.956055f, 0.959473f, 0.962402f, 0.965332f, 0.967773f, 0.970703f, 0.972656f, 0.975098f,
+ 0.977051f, 0.979004f, 0.981445f, 0.982910f, 0.984375f, 0.985840f, 0.987793f, 0.989258f, 0.990234f, 0.991211f, 0.996094f, 0.996094f,
+ 0.996094f, 0.996094f, 0.995605f, 0.995117f, 0.004505f, 0.014908f, 0.027634f, 0.043274f, 0.061707f, 0.084045f, 0.111694f, 0.143921f,
+ 0.180542f, 0.223877f, 0.270996f, 0.320557f, 0.373291f, 0.425781f, 0.478027f, 0.526855f, 0.573242f, 0.615723f, 0.654785f, 0.688965f,
+ 0.720215f, 0.747559f, 0.771973f, 0.793457f, 0.812500f, 0.829102f, 0.844238f, 0.858398f, 0.870117f, 0.881348f, 0.890625f, 0.898926f,
+ 0.906738f, 0.914062f, 0.921387f, 0.926758f, 0.932617f, 0.937500f, 0.942383f, 0.945801f, 0.950684f, 0.954102f, 0.958008f, 0.960938f,
+ 0.964355f, 0.966797f, 0.969727f, 0.972656f, 0.974609f, 0.976562f, 0.978516f, 0.980469f, 0.981934f, 0.984375f, 0.985840f, 0.987793f,
+ 0.988281f, 0.990234f, 0.995605f, 0.995605f, 0.995605f, 0.995605f, 0.995117f, 0.994629f, 0.003691f, 0.011925f, 0.021622f, 0.033203f,
+ 0.047241f, 0.065247f, 0.085266f, 0.109558f, 0.138550f, 0.172363f, 0.210205f, 0.253418f, 0.299805f, 0.348877f, 0.400146f, 0.450195f,
+ 0.499512f, 0.546387f, 0.589844f, 0.629883f, 0.666016f, 0.700195f, 0.728516f, 0.755371f, 0.778320f, 0.798828f, 0.817383f, 0.833984f,
+ 0.848145f, 0.861816f, 0.874023f, 0.883789f, 0.893555f, 0.902344f, 0.910645f, 0.916992f, 0.922852f, 0.929688f, 0.934570f, 0.938965f,
+ 0.944336f, 0.948730f, 0.951660f, 0.956543f, 0.959473f, 0.962891f, 0.965820f, 0.968262f, 0.970703f, 0.974121f, 0.976074f, 0.978516f,
+ 0.979980f, 0.981934f, 0.983887f, 0.985840f, 0.987305f, 0.988281f, 0.994629f, 0.995117f, 0.995117f, 0.994629f, 0.994629f, 0.994141f,
+ 0.002726f, 0.009560f, 0.017136f, 0.026871f, 0.037415f, 0.050079f, 0.066406f, 0.084717f, 0.107849f, 0.133423f, 0.164062f, 0.198853f,
+ 0.238281f, 0.281250f, 0.327148f, 0.375977f, 0.424805f, 0.473877f, 0.521973f, 0.564941f, 0.606934f, 0.644531f, 0.679199f, 0.710449f,
+ 0.738770f, 0.764160f, 0.786133f, 0.805664f, 0.824219f, 0.838867f, 0.853516f, 0.866211f, 0.876953f, 0.887695f, 0.896484f, 0.905762f,
+ 0.912598f, 0.919922f, 0.925781f, 0.932129f, 0.937500f, 0.942383f, 0.946777f, 0.951660f, 0.955078f, 0.958984f, 0.961426f, 0.965332f,
+ 0.967773f, 0.970703f, 0.972656f, 0.975586f, 0.978027f, 0.979492f, 0.981934f, 0.983887f, 0.984863f, 0.986816f, 0.994629f, 0.994629f,
+ 0.994629f, 0.994141f, 0.994141f, 0.993652f, 0.002487f, 0.007553f, 0.013863f, 0.021439f, 0.029755f, 0.040771f, 0.052643f, 0.067444f,
+ 0.084473f, 0.104980f, 0.128784f, 0.157227f, 0.189087f, 0.224609f, 0.265381f, 0.308838f, 0.354004f, 0.401611f, 0.450439f, 0.496582f,
+ 0.541992f, 0.583984f, 0.623047f, 0.660645f, 0.693359f, 0.722168f, 0.749512f, 0.772949f, 0.793457f, 0.812988f, 0.830078f, 0.845215f,
+ 0.859375f, 0.871094f, 0.882812f, 0.892090f, 0.900879f, 0.908691f, 0.916504f, 0.922852f, 0.930176f, 0.935547f, 0.940430f, 0.944824f,
+ 0.949219f, 0.952637f, 0.956543f, 0.960449f, 0.963867f, 0.967285f, 0.970215f, 0.972656f, 0.974609f, 0.977539f, 0.979492f, 0.981934f,
+ 0.983887f, 0.985352f, 0.993652f, 0.994141f, 0.994141f, 0.993652f, 0.993652f, 0.993164f, 0.001893f, 0.006641f, 0.011551f, 0.017319f,
+ 0.024612f, 0.032959f, 0.042023f, 0.053772f, 0.067444f, 0.083435f, 0.102356f, 0.123840f, 0.150024f, 0.179688f, 0.213501f, 0.250488f,
+ 0.291992f, 0.335938f, 0.381592f, 0.427246f, 0.473877f, 0.518555f, 0.563477f, 0.603027f, 0.640625f, 0.676270f, 0.707031f, 0.735352f,
+ 0.760254f, 0.782715f, 0.802734f, 0.821777f, 0.838379f, 0.851562f, 0.865234f, 0.876953f, 0.886719f, 0.896484f, 0.905273f, 0.913086f,
+ 0.921387f, 0.927734f, 0.933105f, 0.938477f, 0.942871f, 0.948242f, 0.951660f, 0.955566f, 0.959961f, 0.963867f, 0.966309f, 0.969238f,
+ 0.972168f, 0.975098f, 0.977539f, 0.979492f, 0.981934f, 0.983887f, 0.993164f, 0.993652f, 0.993164f, 0.993164f, 0.993164f, 0.992676f,
+ 0.001740f, 0.005634f, 0.009407f, 0.014992f, 0.020157f, 0.026840f, 0.035156f, 0.043793f, 0.054718f, 0.067505f, 0.082092f, 0.099731f,
+ 0.120239f, 0.143921f, 0.171265f, 0.202393f, 0.237915f, 0.276367f, 0.318848f, 0.362793f, 0.407959f, 0.454346f, 0.499023f, 0.542480f,
+ 0.583984f, 0.623535f, 0.659180f, 0.691895f, 0.721680f, 0.748047f, 0.772461f, 0.793457f, 0.812988f, 0.829102f, 0.845215f, 0.859863f,
+ 0.872559f, 0.883789f, 0.893555f, 0.902344f, 0.911133f, 0.918457f, 0.924805f, 0.930664f, 0.937012f, 0.941895f, 0.947266f, 0.951172f,
+ 0.956055f, 0.959473f, 0.962402f, 0.966309f, 0.968750f, 0.972168f, 0.974609f, 0.977051f, 0.979492f, 0.981934f, 0.992188f, 0.992676f,
+ 0.992676f, 0.992676f, 0.992188f, 0.992676f, 0.001502f, 0.004482f, 0.008278f, 0.012276f, 0.016800f, 0.022644f, 0.029129f, 0.036194f,
+ 0.045197f, 0.055298f, 0.067017f, 0.080750f, 0.096863f, 0.115906f, 0.138184f, 0.163940f, 0.192993f, 0.225952f, 0.262695f, 0.302490f,
+ 0.344971f, 0.389648f, 0.434814f, 0.480469f, 0.523926f, 0.566406f, 0.605957f, 0.643066f, 0.677246f, 0.708496f, 0.736816f, 0.761719f,
+ 0.784668f, 0.804688f, 0.823242f, 0.840332f, 0.854004f, 0.867188f, 0.878906f, 0.890137f, 0.898438f, 0.907715f, 0.916016f, 0.922852f,
+ 0.930176f, 0.935547f, 0.940918f, 0.946289f, 0.950684f, 0.955078f, 0.959473f, 0.961914f, 0.966309f, 0.969238f, 0.972168f, 0.974609f,
+ 0.977539f, 0.979492f, 0.991211f, 0.992188f, 0.991699f, 0.992188f, 0.991699f, 0.991211f, 0.001411f, 0.003645f, 0.007160f, 0.010414f,
+ 0.014397f, 0.018677f, 0.024338f, 0.030426f, 0.037384f, 0.045654f, 0.055054f, 0.066101f, 0.079529f, 0.094543f, 0.112793f, 0.133057f,
+ 0.157227f, 0.183960f, 0.215210f, 0.250488f, 0.288086f, 0.329102f, 0.372314f, 0.416992f, 0.461914f, 0.505859f, 0.549316f, 0.589355f,
+ 0.627930f, 0.664062f, 0.695801f, 0.725098f, 0.752441f, 0.775879f, 0.797363f, 0.815918f, 0.833984f, 0.849121f, 0.863281f, 0.875488f,
+ 0.886230f, 0.895996f, 0.904785f, 0.914062f, 0.920898f, 0.928223f, 0.935059f, 0.940918f, 0.945312f, 0.950195f, 0.954102f, 0.958984f,
+ 0.962402f, 0.966309f, 0.969238f, 0.972656f, 0.974609f, 0.977539f, 0.990234f, 0.992188f, 0.991211f, 0.991211f, 0.990723f, 0.991211f,
+ 0.000926f, 0.003523f, 0.006207f, 0.008949f, 0.012718f, 0.016312f, 0.020447f, 0.025467f, 0.031128f, 0.037994f, 0.045532f, 0.054901f,
+ 0.065430f, 0.077576f, 0.091797f, 0.109131f, 0.128418f, 0.151245f, 0.176636f, 0.206055f, 0.238525f, 0.275146f, 0.314697f, 0.357178f,
+ 0.400391f, 0.445312f, 0.489746f, 0.531738f, 0.574219f, 0.613281f, 0.650391f, 0.683594f, 0.714355f, 0.742188f, 0.768066f, 0.790039f,
+ 0.810059f, 0.828125f, 0.843262f, 0.858398f, 0.871582f, 0.883789f, 0.893555f, 0.903809f, 0.912598f, 0.919434f, 0.926758f, 0.933594f,
+ 0.939453f, 0.944336f, 0.950195f, 0.954590f, 0.958008f, 0.962402f, 0.966309f, 0.969727f, 0.972656f, 0.975586f, 0.989746f, 0.990723f,
+ 0.990723f, 0.990234f, 0.990234f, 0.990234f, 0.001140f, 0.003021f, 0.005527f, 0.008102f, 0.010445f, 0.013977f, 0.017349f, 0.021637f,
+ 0.026535f, 0.031677f, 0.038330f, 0.045776f, 0.054382f, 0.064392f, 0.076233f, 0.089844f, 0.105713f, 0.123840f, 0.145020f, 0.169556f,
+ 0.196899f, 0.229248f, 0.263672f, 0.302002f, 0.342529f, 0.385986f, 0.429932f, 0.473877f, 0.517578f, 0.560547f, 0.600586f, 0.638184f,
+ 0.672852f, 0.704590f, 0.733398f, 0.759277f, 0.782715f, 0.803711f, 0.823242f, 0.840820f, 0.854980f, 0.869141f, 0.881348f, 0.892090f,
+ 0.902344f, 0.910645f, 0.919922f, 0.927246f, 0.933105f, 0.938965f, 0.944824f, 0.949707f, 0.954102f, 0.959473f, 0.962891f, 0.966309f,
+ 0.969727f, 0.972168f, 0.988770f, 0.990234f, 0.989746f, 0.989746f, 0.989746f, 0.989258f, 0.000870f, 0.002666f, 0.004578f, 0.006737f,
+ 0.009430f, 0.012077f, 0.015381f, 0.018463f, 0.022293f, 0.027313f, 0.032654f, 0.038727f, 0.045746f, 0.053619f, 0.063232f, 0.074524f,
+ 0.087219f, 0.102356f, 0.119324f, 0.139648f, 0.162842f, 0.189941f, 0.219482f, 0.253174f, 0.289795f, 0.329346f, 0.372070f, 0.415039f,
+ 0.459717f, 0.503418f, 0.546387f, 0.587402f, 0.625977f, 0.661621f, 0.694336f, 0.725586f, 0.752441f, 0.776855f, 0.798828f, 0.818359f,
+ 0.837402f, 0.852539f, 0.866699f, 0.878906f, 0.891113f, 0.900879f, 0.910156f, 0.918457f, 0.926270f, 0.932617f, 0.938965f, 0.944824f,
+ 0.950195f, 0.955078f, 0.958984f, 0.962891f, 0.966797f, 0.970703f, 0.987793f, 0.988770f, 0.989258f, 0.989258f, 0.988770f, 0.988770f,
+ 0.000835f, 0.002302f, 0.004078f, 0.005802f, 0.008026f, 0.010490f, 0.013153f, 0.016235f, 0.019485f, 0.023636f, 0.027847f, 0.033081f,
+ 0.038849f, 0.045441f, 0.053253f, 0.062500f, 0.072571f, 0.085205f, 0.098999f, 0.115662f, 0.135254f, 0.156860f, 0.182373f, 0.211060f,
+ 0.243042f, 0.279053f, 0.318115f, 0.359619f, 0.402832f, 0.447021f, 0.490234f, 0.533691f, 0.575195f, 0.615234f, 0.651855f, 0.686035f,
+ 0.717285f, 0.746094f, 0.771484f, 0.793945f, 0.813965f, 0.833496f, 0.848633f, 0.864258f, 0.877930f, 0.889648f, 0.900391f, 0.909180f,
+ 0.918945f, 0.926270f, 0.932129f, 0.939453f, 0.945312f, 0.950684f, 0.955566f, 0.959473f, 0.963867f, 0.967773f, 0.987305f, 0.988281f,
+ 0.988281f, 0.988281f, 0.988281f, 0.987793f, 0.000815f, 0.001984f, 0.003475f, 0.005302f, 0.007103f, 0.009354f, 0.011528f, 0.013977f,
+ 0.017197f, 0.020111f, 0.023788f, 0.027771f, 0.033447f, 0.038452f, 0.045013f, 0.052704f, 0.061066f, 0.071228f, 0.082886f, 0.096313f,
+ 0.112488f, 0.130737f, 0.151245f, 0.175659f, 0.203125f, 0.234619f, 0.269043f, 0.306885f, 0.347656f, 0.390381f, 0.434570f, 0.478760f,
+ 0.522461f, 0.564453f, 0.605957f, 0.644043f, 0.678223f, 0.710449f, 0.739746f, 0.766602f, 0.791016f, 0.811035f, 0.831055f, 0.847168f,
+ 0.862793f, 0.875977f, 0.888672f, 0.899414f, 0.909180f, 0.917480f, 0.926270f, 0.933105f, 0.939941f, 0.945801f, 0.950684f, 0.955566f,
+ 0.960938f, 0.964844f, 0.985840f, 0.987305f, 0.987793f, 0.987305f, 0.987305f, 0.987305f, 0.000587f, 0.002005f, 0.003122f, 0.004707f,
+ 0.006283f, 0.007778f, 0.009972f, 0.012581f, 0.014435f, 0.017426f, 0.020691f, 0.024475f, 0.028519f, 0.033203f, 0.038513f, 0.044708f,
+ 0.051727f, 0.060028f, 0.069763f, 0.080627f, 0.093506f, 0.109009f, 0.125977f, 0.146362f, 0.169678f, 0.196533f, 0.226685f, 0.259766f,
+ 0.297119f, 0.337646f, 0.380127f, 0.424072f, 0.468018f, 0.512207f, 0.555176f, 0.596680f, 0.635254f, 0.671387f, 0.704590f, 0.734863f,
+ 0.762207f, 0.787109f, 0.809082f, 0.828613f, 0.846191f, 0.860840f, 0.875977f, 0.888184f, 0.899902f, 0.908691f, 0.918457f, 0.926270f,
+ 0.934082f, 0.940430f, 0.947266f, 0.951660f, 0.958008f, 0.961914f, 0.984863f, 0.986328f, 0.986816f, 0.986816f, 0.986328f, 0.986328f,
+ 0.000475f, 0.001671f, 0.003019f, 0.004379f, 0.005592f, 0.006882f, 0.008682f, 0.010757f, 0.012856f, 0.015343f, 0.018112f, 0.021164f,
+ 0.024353f, 0.028595f, 0.033020f, 0.038086f, 0.044006f, 0.050812f, 0.058594f, 0.067993f, 0.078735f, 0.091248f, 0.105530f, 0.122009f,
+ 0.142212f, 0.164062f, 0.189697f, 0.219238f, 0.251953f, 0.288330f, 0.328125f, 0.369629f, 0.413818f, 0.458008f, 0.503418f, 0.547363f,
+ 0.588867f, 0.628418f, 0.665039f, 0.699707f, 0.730469f, 0.758301f, 0.784668f, 0.807129f, 0.826660f, 0.844727f, 0.862305f, 0.875977f,
+ 0.888672f, 0.900879f, 0.910156f, 0.919434f, 0.927734f, 0.935059f, 0.941406f, 0.947754f, 0.953125f, 0.958496f, 0.983887f, 0.985352f,
+ 0.985352f, 0.985352f, 0.984863f, 0.985352f, 0.000325f, 0.001517f, 0.002554f, 0.003811f, 0.004990f, 0.006638f, 0.007706f, 0.009399f,
+ 0.011177f, 0.013580f, 0.015671f, 0.018478f, 0.021393f, 0.024612f, 0.028442f, 0.032990f, 0.037750f, 0.043427f, 0.050354f, 0.057861f,
+ 0.066101f, 0.076294f, 0.088684f, 0.102417f, 0.119080f, 0.137451f, 0.159058f, 0.183838f, 0.212524f, 0.244385f, 0.280273f, 0.319336f,
+ 0.361084f, 0.405029f, 0.449707f, 0.494873f, 0.539551f, 0.582031f, 0.622559f, 0.660156f, 0.695801f, 0.727539f, 0.756348f, 0.782715f,
+ 0.805664f, 0.826172f, 0.845215f, 0.861328f, 0.875977f, 0.889648f, 0.901367f, 0.910645f, 0.920410f, 0.928711f, 0.937012f, 0.942871f,
+ 0.949219f, 0.955078f, 0.982422f, 0.983887f, 0.984375f, 0.984375f, 0.983887f, 0.983887f, 0.000349f, 0.001533f, 0.002413f, 0.003326f,
+ 0.004463f, 0.005524f, 0.006954f, 0.008202f, 0.010025f, 0.011864f, 0.013924f, 0.015884f, 0.018478f, 0.021484f, 0.024658f, 0.028671f,
+ 0.032562f, 0.037170f, 0.042969f, 0.049194f, 0.056641f, 0.065063f, 0.074951f, 0.086182f, 0.099731f, 0.115662f, 0.133789f, 0.154175f,
+ 0.178589f, 0.206421f, 0.237671f, 0.272949f, 0.312012f, 0.352783f, 0.396973f, 0.442627f, 0.487793f, 0.532227f, 0.576660f, 0.617188f,
+ 0.657227f, 0.692383f, 0.725586f, 0.754395f, 0.780762f, 0.805664f, 0.826172f, 0.845215f, 0.861816f, 0.876465f, 0.890137f, 0.902344f,
+ 0.912598f, 0.921875f, 0.930176f, 0.937988f, 0.945312f, 0.952148f, 0.981445f, 0.982910f, 0.982910f, 0.983398f, 0.983398f, 0.983398f,
+ 0.000475f, 0.001141f, 0.002058f, 0.002846f, 0.004120f, 0.005013f, 0.006207f, 0.007664f, 0.009193f, 0.010368f, 0.012222f, 0.014404f,
+ 0.016403f, 0.018799f, 0.021439f, 0.024567f, 0.028076f, 0.032379f, 0.036652f, 0.042145f, 0.048157f, 0.055389f, 0.063660f, 0.073059f,
+ 0.083740f, 0.097046f, 0.112366f, 0.129517f, 0.149780f, 0.173584f, 0.200684f, 0.231812f, 0.266357f, 0.304688f, 0.346680f, 0.390137f,
+ 0.435547f, 0.481445f, 0.526367f, 0.572266f, 0.613770f, 0.653320f, 0.690430f, 0.723633f, 0.754395f, 0.781250f, 0.806152f, 0.826172f,
+ 0.847168f, 0.862793f, 0.878906f, 0.892090f, 0.904297f, 0.914551f, 0.924316f, 0.933105f, 0.940430f, 0.947754f, 0.979492f, 0.981934f,
+ 0.981934f, 0.981934f, 0.981445f, 0.981445f, 0.000239f, 0.000882f, 0.001744f, 0.002878f, 0.003819f, 0.004532f, 0.005550f, 0.006653f,
+ 0.007942f, 0.009277f, 0.010628f, 0.012421f, 0.014397f, 0.016312f, 0.018845f, 0.021576f, 0.024536f, 0.027817f, 0.031860f, 0.036346f,
+ 0.041595f, 0.047333f, 0.054138f, 0.062317f, 0.071350f, 0.081970f, 0.094299f, 0.109070f, 0.126221f, 0.146118f, 0.169067f, 0.195801f,
+ 0.226196f, 0.260742f, 0.298584f, 0.340088f, 0.384277f, 0.429688f, 0.476807f, 0.522461f, 0.568359f, 0.611328f, 0.651855f, 0.689453f,
+ 0.723633f, 0.754395f, 0.782715f, 0.807617f, 0.829590f, 0.848145f, 0.865723f, 0.880859f, 0.894531f, 0.906738f, 0.917969f, 0.927246f,
+ 0.936035f, 0.943359f, 0.978027f, 0.979980f, 0.980469f, 0.980469f, 0.980469f, 0.980469f, 0.000240f, 0.000948f, 0.001495f, 0.002592f,
+ 0.003241f, 0.004055f, 0.004856f, 0.006111f, 0.007133f, 0.008125f, 0.009445f, 0.011108f, 0.012474f, 0.014374f, 0.016586f, 0.018784f,
+ 0.021286f, 0.024475f, 0.027481f, 0.031403f, 0.035828f, 0.040710f, 0.046204f, 0.052704f, 0.060577f, 0.069519f, 0.079651f, 0.092224f,
+ 0.106506f, 0.122986f, 0.142456f, 0.165161f, 0.191284f, 0.221924f, 0.255615f, 0.293457f, 0.335205f, 0.379395f, 0.425537f, 0.472900f,
+ 0.519531f, 0.566406f, 0.610840f, 0.652344f, 0.689941f, 0.724609f, 0.755371f, 0.784180f, 0.808594f, 0.831055f, 0.851562f, 0.869141f,
+ 0.884277f, 0.897461f, 0.909668f, 0.920410f, 0.930176f, 0.937988f, 0.976562f, 0.979004f, 0.979492f, 0.979492f, 0.979492f, 0.979492f,
+ 0.000302f, 0.000863f, 0.001315f, 0.002195f, 0.002905f, 0.003592f, 0.004784f, 0.005478f, 0.006199f, 0.007389f, 0.008545f, 0.009811f,
+ 0.011185f, 0.012787f, 0.014603f, 0.016342f, 0.018784f, 0.021347f, 0.024033f, 0.027496f, 0.031006f, 0.034790f, 0.039856f, 0.045288f,
+ 0.051636f, 0.059052f, 0.067566f, 0.078003f, 0.089905f, 0.103760f, 0.119934f, 0.139282f, 0.161865f, 0.187622f, 0.217407f, 0.251221f,
+ 0.288818f, 0.330811f, 0.375244f, 0.422607f, 0.470703f, 0.518066f, 0.565430f, 0.609863f, 0.651855f, 0.691406f, 0.726562f, 0.758301f,
+ 0.787109f, 0.812500f, 0.835449f, 0.855957f, 0.872559f, 0.887695f, 0.901367f, 0.913574f, 0.923828f, 0.933105f, 0.975098f, 0.977539f,
+ 0.977539f, 0.977539f, 0.978027f, 0.977051f, 0.000240f, 0.000808f, 0.001537f, 0.002106f, 0.002493f, 0.003729f, 0.004036f, 0.004982f,
+ 0.005539f, 0.006454f, 0.007526f, 0.008690f, 0.009987f, 0.011421f, 0.012894f, 0.014618f, 0.016464f, 0.018539f, 0.021118f, 0.023865f,
+ 0.026794f, 0.030487f, 0.034241f, 0.038879f, 0.044067f, 0.050690f, 0.057678f, 0.066040f, 0.076111f, 0.087524f, 0.101379f, 0.117737f,
+ 0.136353f, 0.158325f, 0.183594f, 0.213501f, 0.247192f, 0.284912f, 0.327393f, 0.372803f, 0.420410f, 0.468750f, 0.518066f, 0.565430f,
+ 0.611328f, 0.654297f, 0.694336f, 0.729980f, 0.762207f, 0.791504f, 0.817383f, 0.839844f, 0.859863f, 0.876953f, 0.891602f, 0.905762f,
+ 0.917480f, 0.928711f, 0.973633f, 0.975098f, 0.976562f, 0.975586f, 0.976562f, 0.976562f, 0.000240f, 0.000587f, 0.001223f, 0.001691f,
+ 0.002499f, 0.003008f, 0.003643f, 0.004295f, 0.004795f, 0.005726f, 0.006649f, 0.007671f, 0.008766f, 0.010002f, 0.011307f, 0.012764f,
+ 0.014465f, 0.016388f, 0.018387f, 0.020599f, 0.023453f, 0.026291f, 0.029572f, 0.033417f, 0.037964f, 0.043427f, 0.049316f, 0.056519f,
+ 0.064819f, 0.074219f, 0.085693f, 0.099121f, 0.115112f, 0.133301f, 0.155273f, 0.180420f, 0.210205f, 0.244751f, 0.282715f, 0.324951f,
+ 0.371338f, 0.419434f, 0.468994f, 0.518555f, 0.566895f, 0.613770f, 0.658203f, 0.698242f, 0.735352f, 0.766602f, 0.796875f, 0.821289f,
+ 0.844238f, 0.863770f, 0.881836f, 0.896973f, 0.910156f, 0.922363f, 0.971191f, 0.974121f, 0.974609f, 0.974121f, 0.974609f, 0.974609f,
+ 0.000228f, 0.000671f, 0.001122f, 0.001607f, 0.002291f, 0.002836f, 0.003319f, 0.003817f, 0.004509f, 0.005253f, 0.005894f, 0.006840f,
+ 0.007820f, 0.008972f, 0.010086f, 0.011391f, 0.012848f, 0.014328f, 0.016266f, 0.018158f, 0.020447f, 0.022720f, 0.026031f, 0.029053f,
+ 0.032593f, 0.037109f, 0.042236f, 0.048340f, 0.055115f, 0.063049f, 0.072632f, 0.083801f, 0.097351f, 0.112488f, 0.130493f, 0.152222f,
+ 0.178101f, 0.208008f, 0.241943f, 0.280762f, 0.323730f, 0.370117f, 0.419434f, 0.470459f, 0.520996f, 0.570801f, 0.617676f, 0.663086f,
+ 0.704102f, 0.740234f, 0.773438f, 0.802246f, 0.829102f, 0.850098f, 0.870117f, 0.887695f, 0.902832f, 0.916016f, 0.969238f, 0.972168f,
+ 0.972168f, 0.972656f, 0.972656f, 0.972168f, 0.000121f, 0.000526f, 0.001092f, 0.001670f, 0.001744f, 0.002420f, 0.002945f, 0.003237f,
+ 0.004013f, 0.004894f, 0.005421f, 0.005932f, 0.006996f, 0.007904f, 0.008873f, 0.009995f, 0.011391f, 0.012756f, 0.014053f, 0.015884f,
+ 0.017715f, 0.019775f, 0.022324f, 0.025406f, 0.028290f, 0.032349f, 0.036560f, 0.041412f, 0.047058f, 0.053772f, 0.061493f, 0.070862f,
+ 0.081848f, 0.094666f, 0.110229f, 0.128662f, 0.150024f, 0.175903f, 0.205566f, 0.239990f, 0.279785f, 0.323486f, 0.370850f, 0.421143f,
+ 0.473633f, 0.524902f, 0.576172f, 0.625000f, 0.668457f, 0.710938f, 0.748535f, 0.781250f, 0.810059f, 0.835449f, 0.857910f, 0.877441f,
+ 0.894531f, 0.908691f, 0.966797f, 0.970215f, 0.970703f, 0.970703f, 0.970703f, 0.970215f, 0.000127f, 0.000521f, 0.001083f, 0.001460f,
+ 0.001684f, 0.002111f, 0.002563f, 0.003048f, 0.003618f, 0.004124f, 0.004936f, 0.005543f, 0.006340f, 0.007111f, 0.008049f, 0.008774f,
+ 0.009865f, 0.011162f, 0.012360f, 0.013840f, 0.015465f, 0.017181f, 0.019531f, 0.021973f, 0.024582f, 0.027847f, 0.031342f, 0.035706f,
+ 0.040100f, 0.045990f, 0.052521f, 0.060089f, 0.069214f, 0.080017f, 0.093079f, 0.108521f, 0.126709f, 0.148071f, 0.174072f, 0.204224f,
+ 0.239502f, 0.279541f, 0.324219f, 0.373047f, 0.424805f, 0.477295f, 0.530762f, 0.583008f, 0.632324f, 0.677246f, 0.719727f, 0.756348f,
+ 0.789551f, 0.819336f, 0.842773f, 0.866211f, 0.885742f, 0.901855f, 0.965332f, 0.967773f, 0.968262f, 0.967773f, 0.968750f, 0.968262f,
+ 0.000244f, 0.000397f, 0.001001f, 0.001181f, 0.001642f, 0.001872f, 0.002460f, 0.002712f, 0.003061f, 0.003723f, 0.004520f, 0.005043f,
+ 0.005547f, 0.006451f, 0.007057f, 0.007828f, 0.008942f, 0.009872f, 0.010857f, 0.012131f, 0.013557f, 0.015198f, 0.017059f, 0.019241f,
+ 0.021454f, 0.024048f, 0.027069f, 0.030594f, 0.034332f, 0.039001f, 0.044952f, 0.050873f, 0.058716f, 0.067505f, 0.078369f, 0.091309f,
+ 0.106506f, 0.124695f, 0.146484f, 0.172852f, 0.203369f, 0.239014f, 0.280273f, 0.326172f, 0.376465f, 0.429443f, 0.483643f, 0.538574f,
+ 0.591309f, 0.641602f, 0.687500f, 0.729492f, 0.766602f, 0.800293f, 0.828613f, 0.854004f, 0.874512f, 0.893555f, 0.961914f, 0.965332f,
+ 0.965820f, 0.966309f, 0.966309f, 0.965820f, 0.000243f, 0.000453f, 0.000888f, 0.001245f, 0.001342f, 0.001847f, 0.002060f, 0.002541f,
+ 0.002991f, 0.003355f, 0.003679f, 0.004379f, 0.005177f, 0.005413f, 0.006283f, 0.007038f, 0.007896f, 0.008507f, 0.009552f, 0.010628f,
+ 0.011909f, 0.013306f, 0.015038f, 0.016388f, 0.018433f, 0.020752f, 0.023254f, 0.026413f, 0.029617f, 0.033447f, 0.037842f, 0.043701f,
+ 0.049896f, 0.057190f, 0.066101f, 0.076660f, 0.089600f, 0.104553f, 0.123230f, 0.145386f, 0.171387f, 0.202637f, 0.239624f, 0.281982f,
+ 0.329346f, 0.380859f, 0.436035f, 0.491943f, 0.547852f, 0.602539f, 0.653809f, 0.699707f, 0.741699f, 0.778320f, 0.811035f, 0.838867f,
+ 0.862793f, 0.884766f, 0.959961f, 0.963379f, 0.963379f, 0.963379f, 0.964355f, 0.963379f, 0.000241f, 0.000452f, 0.000798f, 0.001119f,
+ 0.001220f, 0.001430f, 0.001902f, 0.002277f, 0.002737f, 0.002893f, 0.003624f, 0.003937f, 0.004436f, 0.005089f, 0.005669f, 0.006226f,
+ 0.006680f, 0.007519f, 0.008568f, 0.009384f, 0.010422f, 0.011795f, 0.012840f, 0.014526f, 0.016235f, 0.017929f, 0.020218f, 0.022736f,
+ 0.025146f, 0.028580f, 0.032684f, 0.036896f, 0.042511f, 0.048431f, 0.055634f, 0.064453f, 0.075317f, 0.088196f, 0.103333f, 0.121948f,
+ 0.144287f, 0.171143f, 0.203491f, 0.241577f, 0.285156f, 0.334229f, 0.387939f, 0.444580f, 0.501953f, 0.559570f, 0.614746f, 0.666504f,
+ 0.712402f, 0.755371f, 0.791504f, 0.823242f, 0.851074f, 0.875000f, 0.956543f, 0.959961f, 0.960938f, 0.960449f, 0.960449f, 0.960449f,
+ 0.000000f, 0.000263f, 0.000693f, 0.000873f, 0.001183f, 0.001447f, 0.001476f, 0.002068f, 0.002171f, 0.002857f, 0.003164f, 0.003542f,
+ 0.003778f, 0.004326f, 0.004906f, 0.005436f, 0.006126f, 0.006687f, 0.007229f, 0.008377f, 0.009232f, 0.010223f, 0.011436f, 0.012527f,
+ 0.013832f, 0.015747f, 0.017365f, 0.019363f, 0.021667f, 0.024231f, 0.027695f, 0.031769f, 0.035889f, 0.041016f, 0.047028f, 0.054504f,
+ 0.063110f, 0.073975f, 0.086487f, 0.101807f, 0.120972f, 0.143555f, 0.171753f, 0.204956f, 0.244263f, 0.289551f, 0.340576f, 0.396484f,
+ 0.455078f, 0.514648f, 0.573730f, 0.630371f, 0.681152f, 0.729004f, 0.770020f, 0.806641f, 0.837402f, 0.863770f, 0.953613f, 0.956543f,
+ 0.957520f, 0.957031f, 0.957031f, 0.958008f, 0.000000f, 0.000356f, 0.000641f, 0.000870f, 0.000998f, 0.001134f, 0.001495f, 0.001724f,
+ 0.002436f, 0.002478f, 0.002775f, 0.003113f, 0.003435f, 0.003864f, 0.004314f, 0.004704f, 0.005276f, 0.005886f, 0.006599f, 0.007309f,
+ 0.008003f, 0.008987f, 0.009987f, 0.010941f, 0.012192f, 0.013466f, 0.015030f, 0.016708f, 0.018906f, 0.021103f, 0.023788f, 0.026886f,
+ 0.030457f, 0.034943f, 0.040009f, 0.045959f, 0.053162f, 0.061920f, 0.072144f, 0.085205f, 0.101257f, 0.120422f, 0.143555f, 0.172363f,
+ 0.206909f, 0.248047f, 0.295410f, 0.349121f, 0.407715f, 0.468750f, 0.530762f, 0.589844f, 0.647949f, 0.699707f, 0.746094f, 0.786621f,
+ 0.823242f, 0.852051f, 0.950195f, 0.953125f, 0.954102f, 0.954102f, 0.954102f, 0.954102f, 0.000231f, 0.000449f, 0.000516f, 0.000760f,
+ 0.000868f, 0.001152f, 0.001403f, 0.001773f, 0.002165f, 0.002245f, 0.002550f, 0.002783f, 0.003277f, 0.003660f, 0.003782f, 0.004120f,
+ 0.004631f, 0.005268f, 0.005795f, 0.006344f, 0.007053f, 0.007835f, 0.008598f, 0.009460f, 0.010689f, 0.011551f, 0.012726f, 0.014359f,
+ 0.016052f, 0.017975f, 0.020218f, 0.022812f, 0.025803f, 0.029251f, 0.033386f, 0.038574f, 0.044556f, 0.051941f, 0.060577f, 0.071045f,
+ 0.084106f, 0.100342f, 0.119751f, 0.144043f, 0.174194f, 0.209961f, 0.253418f, 0.303467f, 0.359619f, 0.420898f, 0.483887f, 0.547852f,
+ 0.609375f, 0.667480f, 0.719727f, 0.765625f, 0.804688f, 0.839844f, 0.946289f, 0.949707f, 0.950195f, 0.950684f, 0.950684f, 0.950195f,
+ 0.000201f, 0.000336f, 0.000452f, 0.000627f, 0.000793f, 0.000966f, 0.001134f, 0.001578f, 0.001790f, 0.001896f, 0.002254f, 0.002464f,
+ 0.002825f, 0.003012f, 0.003414f, 0.003626f, 0.004131f, 0.004608f, 0.005058f, 0.005642f, 0.006191f, 0.006771f, 0.007378f, 0.008057f,
+ 0.009132f, 0.009918f, 0.010826f, 0.012314f, 0.013794f, 0.015381f, 0.017197f, 0.019257f, 0.021912f, 0.024841f, 0.028259f, 0.032318f,
+ 0.037262f, 0.043427f, 0.050537f, 0.059021f, 0.070007f, 0.083191f, 0.099609f, 0.120239f, 0.145508f, 0.176636f, 0.214600f, 0.260254f,
+ 0.313232f, 0.372803f, 0.437012f, 0.503418f, 0.568359f, 0.631836f, 0.688965f, 0.741211f, 0.786621f, 0.825195f, 0.941406f, 0.946289f,
+ 0.946289f, 0.946777f, 0.946289f, 0.947266f, 0.000000f, 0.000317f, 0.000445f, 0.000453f, 0.000781f, 0.000794f, 0.001183f, 0.001289f,
+ 0.001479f, 0.001832f, 0.001874f, 0.002256f, 0.002270f, 0.002716f, 0.002960f, 0.003273f, 0.003630f, 0.003948f, 0.004467f, 0.004833f,
+ 0.005451f, 0.005962f, 0.006367f, 0.007088f, 0.007717f, 0.008400f, 0.009506f, 0.010445f, 0.011658f, 0.012993f, 0.014618f, 0.016357f,
+ 0.018524f, 0.021210f, 0.023712f, 0.027252f, 0.031219f, 0.036041f, 0.041962f, 0.049194f, 0.057892f, 0.068604f, 0.082642f, 0.099304f,
+ 0.120728f, 0.147217f, 0.180054f, 0.221191f, 0.269287f, 0.325928f, 0.388916f, 0.457275f, 0.525391f, 0.593262f, 0.657715f, 0.714355f,
+ 0.766113f, 0.809082f, 0.937500f, 0.940918f, 0.941895f, 0.941895f, 0.941895f, 0.942383f, 0.000243f, 0.000238f, 0.000411f, 0.000532f,
+ 0.000530f, 0.000764f, 0.000853f, 0.001171f, 0.001417f, 0.001545f, 0.001799f, 0.001900f, 0.002094f, 0.002354f, 0.002577f, 0.002703f,
+ 0.003155f, 0.003428f, 0.003809f, 0.004227f, 0.004677f, 0.004997f, 0.005386f, 0.005913f, 0.006741f, 0.007225f, 0.008057f, 0.008873f,
+ 0.009819f, 0.011101f, 0.012253f, 0.013725f, 0.015488f, 0.017410f, 0.019791f, 0.022598f, 0.025635f, 0.030014f, 0.034973f, 0.040527f,
+ 0.047729f, 0.056702f, 0.067505f, 0.081848f, 0.099609f, 0.121521f, 0.149902f, 0.185181f, 0.228516f, 0.280762f, 0.341553f, 0.408936f,
+ 0.480225f, 0.552246f, 0.622070f, 0.686035f, 0.742188f, 0.792480f, 0.932129f, 0.935547f, 0.937012f, 0.937012f, 0.936523f, 0.937500f,
+ 0.000000f, 0.000232f, 0.000330f, 0.000512f, 0.000523f, 0.000907f, 0.000953f, 0.001018f, 0.001234f, 0.001344f, 0.001610f, 0.001612f,
+ 0.001845f, 0.002054f, 0.002218f, 0.002453f, 0.002829f, 0.003105f, 0.003300f, 0.003712f, 0.003853f, 0.004280f, 0.004631f, 0.005112f,
+ 0.005665f, 0.006279f, 0.006779f, 0.007481f, 0.008362f, 0.009270f, 0.010338f, 0.011505f, 0.012848f, 0.014549f, 0.016403f, 0.018936f,
+ 0.021622f, 0.024750f, 0.028900f, 0.033447f, 0.039185f, 0.046448f, 0.055603f, 0.067078f, 0.081238f, 0.100037f, 0.123230f, 0.153564f,
+ 0.191284f, 0.238525f, 0.295166f, 0.361084f, 0.432861f, 0.507812f, 0.582520f, 0.653320f, 0.717285f, 0.772461f, 0.926270f, 0.931152f,
+ 0.931152f, 0.932129f, 0.932129f, 0.932129f, 0.000118f, 0.000219f, 0.000227f, 0.000405f, 0.000689f, 0.000726f, 0.000910f, 0.000847f,
+ 0.001072f, 0.001114f, 0.001388f, 0.001447f, 0.001656f, 0.001811f, 0.001897f, 0.002253f, 0.002373f, 0.002617f, 0.002796f, 0.003054f,
+ 0.003414f, 0.003681f, 0.003929f, 0.004353f, 0.004902f, 0.005322f, 0.005863f, 0.006424f, 0.007000f, 0.007755f, 0.008675f, 0.009506f,
+ 0.010704f, 0.012215f, 0.013557f, 0.015686f, 0.017807f, 0.020630f, 0.023376f, 0.027328f, 0.032013f, 0.038177f, 0.045288f, 0.054626f,
+ 0.066284f, 0.081543f, 0.100891f, 0.125977f, 0.158447f, 0.199951f, 0.251465f, 0.313965f, 0.384521f, 0.461670f, 0.540527f, 0.617188f,
+ 0.688965f, 0.750977f, 0.920410f, 0.924805f, 0.925781f, 0.926270f, 0.926758f, 0.925781f, 0.000230f, 0.000198f, 0.000217f, 0.000338f,
+ 0.000584f, 0.000786f, 0.000699f, 0.000893f, 0.000954f, 0.000959f, 0.001153f, 0.001165f, 0.001375f, 0.001545f, 0.001752f, 0.001752f,
+ 0.002062f, 0.002235f, 0.002399f, 0.002699f, 0.002853f, 0.002995f, 0.003372f, 0.003603f, 0.003944f, 0.004513f, 0.004704f, 0.005226f,
+ 0.005878f, 0.006527f, 0.006992f, 0.007889f, 0.008919f, 0.010002f, 0.011124f, 0.012604f, 0.014526f, 0.016510f, 0.019104f, 0.022308f,
+ 0.026077f, 0.030701f, 0.036774f, 0.044098f, 0.053558f, 0.065735f, 0.081299f, 0.101990f, 0.129517f, 0.164917f, 0.210938f, 0.268066f,
+ 0.336914f, 0.413818f, 0.496094f, 0.579102f, 0.657227f, 0.727539f, 0.913574f, 0.917969f, 0.918945f, 0.919434f, 0.919922f, 0.919922f,
+ 0.000000f, 0.000101f, 0.000214f, 0.000208f, 0.000339f, 0.000461f, 0.000577f, 0.000780f, 0.000777f, 0.000840f, 0.000853f, 0.001064f,
+ 0.001198f, 0.001327f, 0.001489f, 0.001687f, 0.001809f, 0.001884f, 0.002008f, 0.002129f, 0.002434f, 0.002514f, 0.002949f, 0.003000f,
+ 0.003351f, 0.003674f, 0.003918f, 0.004356f, 0.004875f, 0.005310f, 0.005768f, 0.006458f, 0.007244f, 0.008255f, 0.008949f, 0.010361f,
+ 0.011589f, 0.013290f, 0.015335f, 0.017776f, 0.020828f, 0.024521f, 0.029236f, 0.035431f, 0.042694f, 0.052490f, 0.065369f, 0.082336f,
+ 0.104492f, 0.134277f, 0.173828f, 0.225464f, 0.290039f, 0.365234f, 0.449707f, 0.536133f, 0.623047f, 0.702637f, 0.905273f, 0.911133f,
+ 0.912598f, 0.913086f, 0.913086f, 0.913086f, 0.000000f, 0.000167f, 0.000167f, 0.000316f, 0.000432f, 0.000444f, 0.000608f, 0.000611f,
+ 0.000678f, 0.000750f, 0.000899f, 0.000925f, 0.001043f, 0.001125f, 0.001222f, 0.001343f, 0.001470f, 0.001608f, 0.001679f, 0.001804f,
+ 0.001976f, 0.002234f, 0.002361f, 0.002710f, 0.002748f, 0.003035f, 0.003290f, 0.003647f, 0.003990f, 0.004295f, 0.004745f, 0.005318f,
+ 0.005920f, 0.006618f, 0.007347f, 0.008270f, 0.009361f, 0.010719f, 0.012291f, 0.014221f, 0.016693f, 0.019592f, 0.023239f, 0.027969f,
+ 0.033752f, 0.041534f, 0.051666f, 0.065369f, 0.083618f, 0.108276f, 0.141357f, 0.186035f, 0.244141f, 0.316650f, 0.400635f, 0.491699f,
+ 0.585938f, 0.672852f, 0.897461f, 0.903320f, 0.904297f, 0.903809f, 0.903809f, 0.904297f, 0.000000f, 0.000098f, 0.000145f, 0.000289f,
+ 0.000399f, 0.000424f, 0.000429f, 0.000382f, 0.000529f, 0.000613f, 0.000660f, 0.000836f, 0.000907f, 0.000940f, 0.001005f, 0.001188f,
+ 0.001306f, 0.001451f, 0.001420f, 0.001554f, 0.001667f, 0.001783f, 0.001955f, 0.002125f, 0.002357f, 0.002493f, 0.002760f, 0.002867f,
+ 0.003298f, 0.003626f, 0.003878f, 0.004341f, 0.004704f, 0.005356f, 0.005905f, 0.006512f, 0.007435f, 0.008377f, 0.009598f, 0.011055f,
+ 0.012978f, 0.015388f, 0.018036f, 0.021698f, 0.026337f, 0.032532f, 0.040192f, 0.050995f, 0.065125f, 0.085510f, 0.113037f, 0.150513f,
+ 0.201538f, 0.268799f, 0.351318f, 0.444824f, 0.543457f, 0.641602f, 0.888672f, 0.894043f, 0.894531f, 0.895508f, 0.895020f, 0.895508f,
+ 0.000000f, 0.000000f, 0.000032f, 0.000169f, 0.000338f, 0.000372f, 0.000468f, 0.000471f, 0.000460f, 0.000493f, 0.000588f, 0.000715f,
+ 0.000762f, 0.000912f, 0.000831f, 0.001001f, 0.001043f, 0.001133f, 0.001242f, 0.001312f, 0.001446f, 0.001529f, 0.001647f, 0.001829f,
+ 0.001982f, 0.002121f, 0.002165f, 0.002438f, 0.002628f, 0.002865f, 0.003113f, 0.003424f, 0.003622f, 0.004131f, 0.004639f, 0.005222f,
+ 0.005875f, 0.006622f, 0.007496f, 0.008575f, 0.009987f, 0.011665f, 0.013985f, 0.016617f, 0.019913f, 0.024704f, 0.030960f, 0.039185f,
+ 0.050323f, 0.066284f, 0.088196f, 0.119568f, 0.163208f, 0.223511f, 0.302002f, 0.395752f, 0.499756f, 0.605957f, 0.878418f, 0.883301f,
+ 0.884766f, 0.884766f, 0.885254f, 0.885254f, 0.000000f, 0.000000f, 0.000000f, 0.000216f, 0.000237f, 0.000338f, 0.000387f, 0.000341f,
+ 0.000435f, 0.000441f, 0.000461f, 0.000577f, 0.000544f, 0.000720f, 0.000813f, 0.000823f, 0.000912f, 0.000936f, 0.000994f, 0.001026f,
+ 0.001240f, 0.001268f, 0.001365f, 0.001415f, 0.001590f, 0.001565f, 0.001870f, 0.001929f, 0.002123f, 0.002377f, 0.002430f, 0.002565f,
+ 0.002947f, 0.003384f, 0.003662f, 0.004105f, 0.004513f, 0.005047f, 0.005741f, 0.006550f, 0.007549f, 0.008865f, 0.010612f, 0.012466f,
+ 0.015350f, 0.018677f, 0.023270f, 0.029800f, 0.038361f, 0.050323f, 0.067932f, 0.092590f, 0.129395f, 0.181274f, 0.253418f, 0.345459f,
+ 0.452637f, 0.567383f, 0.866699f, 0.872559f, 0.873047f, 0.873535f, 0.873047f, 0.873535f, 0.000000f, 0.000000f, 0.000121f, 0.000182f,
+ 0.000187f, 0.000237f, 0.000264f, 0.000360f, 0.000360f, 0.000397f, 0.000398f, 0.000412f, 0.000432f, 0.000546f, 0.000575f, 0.000690f,
+ 0.000731f, 0.000727f, 0.000807f, 0.000843f, 0.000924f, 0.001034f, 0.001093f, 0.001111f, 0.001251f, 0.001249f, 0.001334f, 0.001612f,
+ 0.001717f, 0.001820f, 0.002090f, 0.002161f, 0.002354f, 0.002600f, 0.002787f, 0.003119f, 0.003586f, 0.003878f, 0.004452f, 0.004913f,
+ 0.005772f, 0.006508f, 0.007679f, 0.009285f, 0.011086f, 0.013840f, 0.016968f, 0.021820f, 0.028259f, 0.037628f, 0.050812f, 0.070129f,
+ 0.099670f, 0.143433f, 0.207031f, 0.294922f, 0.403076f, 0.525879f, 0.853516f, 0.859375f, 0.860840f, 0.860352f, 0.862305f, 0.861328f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000120f, 0.000181f, 0.000198f, 0.000181f, 0.000240f, 0.000275f, 0.000311f, 0.000427f, 0.000447f,
+ 0.000395f, 0.000472f, 0.000456f, 0.000557f, 0.000518f, 0.000562f, 0.000635f, 0.000664f, 0.000868f, 0.000887f, 0.000865f, 0.001025f,
+ 0.001014f, 0.001164f, 0.001096f, 0.001317f, 0.001382f, 0.001432f, 0.001445f, 0.001765f, 0.001744f, 0.002100f, 0.002144f, 0.002350f,
+ 0.002655f, 0.002947f, 0.003294f, 0.003780f, 0.004265f, 0.004971f, 0.005699f, 0.006786f, 0.007957f, 0.009636f, 0.011932f, 0.015823f,
+ 0.020142f, 0.026749f, 0.036530f, 0.051392f, 0.073792f, 0.109375f, 0.164185f, 0.244629f, 0.351562f, 0.479980f, 0.839355f, 0.844727f,
+ 0.846680f, 0.847656f, 0.847168f, 0.846680f, 0.000000f, 0.000121f, 0.000120f, 0.000119f, 0.000162f, 0.000133f, 0.000170f, 0.000201f,
+ 0.000204f, 0.000222f, 0.000258f, 0.000285f, 0.000324f, 0.000327f, 0.000422f, 0.000395f, 0.000431f, 0.000517f, 0.000632f, 0.000529f,
+ 0.000589f, 0.000592f, 0.000735f, 0.000714f, 0.000795f, 0.000778f, 0.000823f, 0.001063f, 0.001080f, 0.001141f, 0.001154f, 0.001308f,
+ 0.001439f, 0.001546f, 0.001689f, 0.001886f, 0.001978f, 0.002174f, 0.002377f, 0.002798f, 0.003277f, 0.003519f, 0.004181f, 0.004780f,
+ 0.005768f, 0.006863f, 0.008644f, 0.010750f, 0.014030f, 0.018448f, 0.025635f, 0.036194f, 0.053223f, 0.080811f, 0.125610f, 0.196533f,
+ 0.299316f, 0.430176f, 0.822754f, 0.830078f, 0.831055f, 0.831543f, 0.832031f, 0.831543f, 0.000000f, 0.000121f, 0.000120f, 0.000118f,
+ 0.000117f, 0.000120f, 0.000123f, 0.000151f, 0.000154f, 0.000175f, 0.000254f, 0.000190f, 0.000211f, 0.000306f, 0.000335f, 0.000358f,
+ 0.000394f, 0.000417f, 0.000443f, 0.000410f, 0.000565f, 0.000565f, 0.000491f, 0.000623f, 0.000616f, 0.000631f, 0.000738f, 0.000676f,
+ 0.000759f, 0.000924f, 0.000895f, 0.001030f, 0.001064f, 0.001176f, 0.001267f, 0.001438f, 0.001518f, 0.001704f, 0.001742f, 0.002028f,
+ 0.002384f, 0.002703f, 0.002972f, 0.003393f, 0.004051f, 0.004959f, 0.005993f, 0.007271f, 0.009277f, 0.012390f, 0.016968f, 0.024368f,
+ 0.036560f, 0.056610f, 0.091797f, 0.151245f, 0.246460f, 0.379639f, 0.805664f, 0.812500f, 0.813477f, 0.813965f, 0.813965f, 0.813965f,
+ 0.000000f, 0.000000f, 0.000118f, 0.000117f, 0.000116f, 0.000114f, 0.000113f, 0.000108f, 0.000127f, 0.000153f, 0.000133f, 0.000202f,
+ 0.000217f, 0.000223f, 0.000242f, 0.000186f, 0.000280f, 0.000304f, 0.000318f, 0.000342f, 0.000338f, 0.000473f, 0.000360f, 0.000484f,
+ 0.000422f, 0.000514f, 0.000527f, 0.000571f, 0.000633f, 0.000568f, 0.000639f, 0.000816f, 0.000789f, 0.000889f, 0.000891f, 0.000966f,
+ 0.001125f, 0.001276f, 0.001316f, 0.001496f, 0.001658f, 0.001818f, 0.002047f, 0.002502f, 0.002781f, 0.003201f, 0.003914f, 0.004795f,
+ 0.006096f, 0.007996f, 0.010918f, 0.015617f, 0.023697f, 0.037567f, 0.063477f, 0.111084f, 0.194824f, 0.324951f, 0.786133f, 0.792969f,
+ 0.794434f, 0.793945f, 0.794922f, 0.794434f, 0.000000f, 0.000119f, 0.000117f, 0.000115f, 0.000113f, 0.000112f, 0.000110f, 0.000109f,
+ 0.000104f, 0.000098f, 0.000099f, 0.000136f, 0.000112f, 0.000126f, 0.000175f, 0.000189f, 0.000196f, 0.000220f, 0.000216f, 0.000247f,
+ 0.000258f, 0.000274f, 0.000285f, 0.000309f, 0.000308f, 0.000321f, 0.000381f, 0.000390f, 0.000475f, 0.000511f, 0.000485f, 0.000501f,
+ 0.000641f, 0.000588f, 0.000652f, 0.000764f, 0.000808f, 0.000952f, 0.000906f, 0.001037f, 0.001110f, 0.001249f, 0.001411f, 0.001647f,
+ 0.001894f, 0.002159f, 0.002687f, 0.003223f, 0.004036f, 0.005150f, 0.006989f, 0.009644f, 0.014420f, 0.023361f, 0.040802f, 0.076050f,
+ 0.146362f, 0.269287f, 0.763184f, 0.770996f, 0.771973f, 0.771973f, 0.772461f, 0.772461f, 0.000121f, 0.000116f, 0.000114f, 0.000112f,
+ 0.000109f, 0.000108f, 0.000106f, 0.000105f, 0.000104f, 0.000101f, 0.000095f, 0.000090f, 0.000085f, 0.000083f, 0.000104f, 0.000097f,
+ 0.000094f, 0.000154f, 0.000127f, 0.000178f, 0.000197f, 0.000194f, 0.000233f, 0.000213f, 0.000279f, 0.000294f, 0.000293f, 0.000258f,
+ 0.000319f, 0.000394f, 0.000344f, 0.000369f, 0.000394f, 0.000410f, 0.000438f, 0.000509f, 0.000514f, 0.000580f, 0.000617f, 0.000684f,
+ 0.000807f, 0.000812f, 0.000914f, 0.001094f, 0.001183f, 0.001436f, 0.001639f, 0.002033f, 0.002523f, 0.003073f, 0.004063f, 0.005680f,
+ 0.008560f, 0.013466f, 0.024109f, 0.047791f, 0.102051f, 0.213867f, 0.740234f, 0.746582f, 0.748047f, 0.748535f, 0.749023f, 0.749023f,
+ 0.000000f, 0.000113f, 0.000108f, 0.000107f, 0.000104f, 0.000102f, 0.000099f, 0.000099f, 0.000097f, 0.000096f, 0.000095f, 0.000091f,
+ 0.000086f, 0.000081f, 0.000077f, 0.000073f, 0.000085f, 0.000091f, 0.000070f, 0.000102f, 0.000117f, 0.000131f, 0.000145f, 0.000148f,
+ 0.000171f, 0.000178f, 0.000178f, 0.000207f, 0.000225f, 0.000209f, 0.000285f, 0.000238f, 0.000260f, 0.000298f, 0.000331f, 0.000360f,
+ 0.000371f, 0.000346f, 0.000407f, 0.000443f, 0.000494f, 0.000516f, 0.000578f, 0.000662f, 0.000767f, 0.000847f, 0.001004f, 0.001149f,
+ 0.001451f, 0.001783f, 0.002310f, 0.003262f, 0.004593f, 0.007309f, 0.012985f, 0.026703f, 0.064026f, 0.158813f, 0.712891f, 0.719238f,
+ 0.722168f, 0.721680f, 0.722168f, 0.722656f, 0.000000f, 0.000105f, 0.000102f, 0.000098f, 0.000094f, 0.000092f, 0.000091f, 0.000089f,
+ 0.000088f, 0.000086f, 0.000085f, 0.000084f, 0.000083f, 0.000080f, 0.000076f, 0.000073f, 0.000069f, 0.000065f, 0.000062f, 0.000059f,
+ 0.000068f, 0.000063f, 0.000069f, 0.000074f, 0.000087f, 0.000102f, 0.000112f, 0.000130f, 0.000137f, 0.000129f, 0.000143f, 0.000168f,
+ 0.000180f, 0.000178f, 0.000189f, 0.000198f, 0.000222f, 0.000240f, 0.000262f, 0.000285f, 0.000304f, 0.000317f, 0.000339f, 0.000399f,
+ 0.000439f, 0.000490f, 0.000570f, 0.000658f, 0.000781f, 0.000988f, 0.001235f, 0.001674f, 0.002407f, 0.003725f, 0.006485f, 0.013199f,
+ 0.034546f, 0.107605f, 0.682129f, 0.691406f, 0.692871f, 0.691406f, 0.692871f, 0.692871f, 0.000105f, 0.000089f, 0.000085f, 0.000080f,
+ 0.000078f, 0.000078f, 0.000075f, 0.000074f, 0.000072f, 0.000072f, 0.000070f, 0.000071f, 0.000069f, 0.000069f, 0.000069f, 0.000068f,
+ 0.000066f, 0.000063f, 0.000060f, 0.000057f, 0.000054f, 0.000052f, 0.000049f, 0.000047f, 0.000046f, 0.000045f, 0.000048f, 0.000055f,
+ 0.000060f, 0.000068f, 0.000083f, 0.000087f, 0.000092f, 0.000103f, 0.000109f, 0.000117f, 0.000130f, 0.000150f, 0.000148f, 0.000142f,
+ 0.000167f, 0.000186f, 0.000210f, 0.000213f, 0.000232f, 0.000280f, 0.000292f, 0.000329f, 0.000391f, 0.000456f, 0.000596f, 0.000764f,
+ 0.001065f, 0.001633f, 0.002806f, 0.005909f, 0.015488f, 0.062378f, 0.651367f, 0.659668f, 0.661133f, 0.661133f, 0.660645f, 0.661621f,
+ 0.000034f, 0.000037f, 0.000048f, 0.000051f, 0.000047f, 0.000049f, 0.000047f, 0.000051f, 0.000049f, 0.000051f, 0.000049f, 0.000050f,
+ 0.000051f, 0.000050f, 0.000050f, 0.000049f, 0.000051f, 0.000050f, 0.000051f, 0.000050f, 0.000049f, 0.000047f, 0.000045f, 0.000043f,
+ 0.000041f, 0.000039f, 0.000037f, 0.000035f, 0.000033f, 0.000032f, 0.000030f, 0.000029f, 0.000034f, 0.000041f, 0.000046f, 0.000057f,
+ 0.000063f, 0.000067f, 0.000065f, 0.000072f, 0.000083f, 0.000093f, 0.000096f, 0.000102f, 0.000102f, 0.000135f, 0.000134f, 0.000151f,
+ 0.000184f, 0.000198f, 0.000245f, 0.000306f, 0.000425f, 0.000607f, 0.001032f, 0.002081f, 0.005886f, 0.027924f, 0.617188f, 0.625977f,
+ 0.627441f, 0.627930f, 0.626953f, 0.628418f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000006f, 0.000010f, 0.000014f,
+ 0.000016f, 0.000014f, 0.000019f, 0.000022f, 0.000022f, 0.000022f, 0.000025f, 0.000026f, 0.000027f, 0.000028f, 0.000029f, 0.000029f,
+ 0.000029f, 0.000030f, 0.000030f, 0.000031f, 0.000032f, 0.000032f, 0.000031f, 0.000030f, 0.000028f, 0.000027f, 0.000026f, 0.000024f,
+ 0.000023f, 0.000022f, 0.000021f, 0.000020f, 0.000019f, 0.000021f, 0.000022f, 0.000024f, 0.000027f, 0.000035f, 0.000041f, 0.000034f,
+ 0.000041f, 0.000052f, 0.000051f, 0.000051f, 0.000058f, 0.000070f, 0.000074f, 0.000103f, 0.000119f, 0.000169f, 0.000277f, 0.000510f,
+ 0.001495f, 0.008766f, 0.583008f, 0.590332f, 0.591797f, 0.591797f, 0.592285f, 0.592285f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000002f, 0.000003f, 0.000005f, 0.000006f, 0.000008f, 0.000009f, 0.000010f, 0.000010f,
+ 0.000012f, 0.000012f, 0.000013f, 0.000014f, 0.000015f, 0.000015f, 0.000015f, 0.000015f, 0.000014f, 0.000013f, 0.000013f, 0.000012f,
+ 0.000011f, 0.000010f, 0.000010f, 0.000009f, 0.000009f, 0.000014f, 0.000011f, 0.000015f, 0.000017f, 0.000017f, 0.000021f, 0.000020f,
+ 0.000026f, 0.000026f, 0.000042f, 0.000069f, 0.000178f, 0.001302f, 0.544434f, 0.553711f, 0.554688f, 0.554688f, 0.556152f, 0.556641f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000001f, 0.000001f, 0.000002f, 0.000003f, 0.000003f,
+ 0.000003f, 0.000003f, 0.000003f, 0.000002f, 0.000002f, 0.000001f, 0.000003f, 0.000003f, 0.000004f, 0.000014f, 0.506836f, 0.515137f,
+ 0.516113f, 0.516602f, 0.517090f, 0.517578f,
+ },
+ {
+ 0.089539f, 0.244873f, 0.368164f, 0.464355f, 0.539551f, 0.599121f, 0.648438f, 0.688477f, 0.721680f, 0.749512f, 0.772461f, 0.793945f,
+ 0.811523f, 0.826172f, 0.841309f, 0.854004f, 0.863770f, 0.874512f, 0.883301f, 0.891602f, 0.898438f, 0.906250f, 0.912109f, 0.917969f,
+ 0.922852f, 0.928223f, 0.932617f, 0.937012f, 0.940918f, 0.944336f, 0.948242f, 0.951660f, 0.954590f, 0.957520f, 0.960449f, 0.962891f,
+ 0.965820f, 0.967773f, 0.970215f, 0.972656f, 0.974609f, 0.976074f, 0.978516f, 0.979492f, 0.981934f, 0.983398f, 0.984863f, 0.986328f,
+ 0.987793f, 0.988770f, 0.990234f, 0.991699f, 0.993164f, 0.994141f, 0.995117f, 0.996582f, 0.997559f, 0.998535f, 0.999023f, 0.998535f,
+ 0.997559f, 0.997070f, 0.996582f, 0.995605f, 0.045563f, 0.143921f, 0.242798f, 0.334717f, 0.417969f, 0.489258f, 0.550293f, 0.602051f,
+ 0.646484f, 0.683594f, 0.715820f, 0.743652f, 0.767090f, 0.788086f, 0.805664f, 0.822266f, 0.836426f, 0.849609f, 0.861328f, 0.870117f,
+ 0.879883f, 0.889160f, 0.896973f, 0.903320f, 0.909668f, 0.916016f, 0.921875f, 0.926758f, 0.931641f, 0.936523f, 0.940430f, 0.943848f,
+ 0.947266f, 0.951172f, 0.954102f, 0.957520f, 0.960449f, 0.962891f, 0.965820f, 0.968262f, 0.970215f, 0.973145f, 0.974121f, 0.976074f,
+ 0.979004f, 0.980469f, 0.982422f, 0.983887f, 0.985352f, 0.986816f, 0.988281f, 0.989746f, 0.991211f, 0.992188f, 0.994141f, 0.995117f,
+ 0.996094f, 0.997070f, 0.998535f, 0.997559f, 0.997070f, 0.996582f, 0.996094f, 0.995117f, 0.026855f, 0.089233f, 0.159790f, 0.234619f,
+ 0.308838f, 0.381348f, 0.447754f, 0.507812f, 0.561035f, 0.606934f, 0.646484f, 0.683105f, 0.712402f, 0.740234f, 0.763184f, 0.784668f,
+ 0.802246f, 0.819336f, 0.833984f, 0.846680f, 0.857910f, 0.868652f, 0.878418f, 0.886719f, 0.895508f, 0.903320f, 0.909668f, 0.915527f,
+ 0.920410f, 0.926270f, 0.931152f, 0.935547f, 0.940430f, 0.943848f, 0.947754f, 0.951172f, 0.954590f, 0.958008f, 0.960449f, 0.963379f,
+ 0.966309f, 0.968750f, 0.971191f, 0.973145f, 0.975586f, 0.977051f, 0.979004f, 0.981445f, 0.982910f, 0.983887f, 0.985840f, 0.987305f,
+ 0.988770f, 0.990723f, 0.992188f, 0.993164f, 0.994629f, 0.996094f, 0.998047f, 0.997070f, 0.996582f, 0.996094f, 0.995605f, 0.995117f,
+ 0.017746f, 0.058746f, 0.108276f, 0.163818f, 0.224365f, 0.288086f, 0.351562f, 0.413086f, 0.470947f, 0.522949f, 0.569824f, 0.612793f,
+ 0.650879f, 0.684570f, 0.713867f, 0.739258f, 0.762695f, 0.783203f, 0.800781f, 0.817871f, 0.833008f, 0.845215f, 0.857422f, 0.868164f,
+ 0.877441f, 0.886230f, 0.894043f, 0.902832f, 0.908691f, 0.915039f, 0.921387f, 0.925781f, 0.930664f, 0.936035f, 0.939941f, 0.944336f,
+ 0.948242f, 0.951660f, 0.955078f, 0.957520f, 0.961426f, 0.964355f, 0.967285f, 0.968750f, 0.971680f, 0.974121f, 0.975586f, 0.978027f,
+ 0.979980f, 0.981934f, 0.983887f, 0.985352f, 0.987305f, 0.988770f, 0.989746f, 0.991211f, 0.992676f, 0.993652f, 0.997070f, 0.996582f,
+ 0.996582f, 0.996094f, 0.995117f, 0.994629f, 0.012337f, 0.041229f, 0.075928f, 0.117065f, 0.163208f, 0.214478f, 0.270020f, 0.327148f,
+ 0.383301f, 0.437500f, 0.490234f, 0.536621f, 0.581543f, 0.621094f, 0.656250f, 0.688477f, 0.716797f, 0.741699f, 0.763672f, 0.784668f,
+ 0.802246f, 0.818359f, 0.832520f, 0.845703f, 0.857422f, 0.868164f, 0.877930f, 0.886230f, 0.895020f, 0.902344f, 0.909668f, 0.915039f,
+ 0.921875f, 0.926758f, 0.931641f, 0.937012f, 0.940430f, 0.946289f, 0.949219f, 0.952637f, 0.956055f, 0.958984f, 0.961914f, 0.964844f,
+ 0.967773f, 0.970215f, 0.972656f, 0.974609f, 0.976562f, 0.979004f, 0.980957f, 0.982910f, 0.984863f, 0.986816f, 0.987793f, 0.989746f,
+ 0.990723f, 0.992676f, 0.996582f, 0.996094f, 0.995605f, 0.995117f, 0.994629f, 0.994141f, 0.009315f, 0.030411f, 0.055756f, 0.085632f,
+ 0.121094f, 0.160889f, 0.206055f, 0.254150f, 0.305664f, 0.357422f, 0.408447f, 0.459717f, 0.506836f, 0.551270f, 0.592773f, 0.629395f,
+ 0.662598f, 0.692871f, 0.719727f, 0.745117f, 0.767090f, 0.786133f, 0.804688f, 0.819336f, 0.834473f, 0.847168f, 0.858398f, 0.869629f,
+ 0.879395f, 0.888672f, 0.895020f, 0.903320f, 0.910156f, 0.916016f, 0.922363f, 0.928223f, 0.933105f, 0.937012f, 0.941406f, 0.946289f,
+ 0.950195f, 0.954102f, 0.957031f, 0.960449f, 0.963379f, 0.965820f, 0.969238f, 0.971191f, 0.974121f, 0.976074f, 0.978027f, 0.979980f,
+ 0.982422f, 0.984375f, 0.985840f, 0.987793f, 0.989258f, 0.990723f, 0.995605f, 0.995605f, 0.995117f, 0.994629f, 0.994629f, 0.993652f,
+ 0.006634f, 0.022736f, 0.041962f, 0.064026f, 0.090759f, 0.122192f, 0.157593f, 0.197510f, 0.240356f, 0.287354f, 0.335693f, 0.384766f,
+ 0.432373f, 0.479736f, 0.523438f, 0.565430f, 0.604004f, 0.639160f, 0.670898f, 0.699219f, 0.726562f, 0.749023f, 0.770508f, 0.790527f,
+ 0.806641f, 0.822754f, 0.836426f, 0.848633f, 0.859863f, 0.871582f, 0.881348f, 0.889160f, 0.897949f, 0.905273f, 0.912598f, 0.918945f,
+ 0.924316f, 0.929199f, 0.935059f, 0.938965f, 0.943848f, 0.947266f, 0.951660f, 0.955078f, 0.958496f, 0.961914f, 0.964844f, 0.967773f,
+ 0.970703f, 0.973145f, 0.975098f, 0.977539f, 0.979492f, 0.981445f, 0.983887f, 0.985352f, 0.987305f, 0.989258f, 0.995117f, 0.994629f,
+ 0.994141f, 0.994141f, 0.993652f, 0.993164f, 0.005428f, 0.017807f, 0.032166f, 0.049652f, 0.070007f, 0.093811f, 0.121765f, 0.153564f,
+ 0.189087f, 0.228516f, 0.270752f, 0.316162f, 0.362061f, 0.408936f, 0.453857f, 0.498779f, 0.540527f, 0.579590f, 0.615723f, 0.649902f,
+ 0.679688f, 0.707520f, 0.732422f, 0.755371f, 0.775391f, 0.794922f, 0.811035f, 0.826172f, 0.839844f, 0.852051f, 0.864258f, 0.875000f,
+ 0.883301f, 0.892578f, 0.899902f, 0.907715f, 0.914062f, 0.920410f, 0.926270f, 0.931641f, 0.936035f, 0.940918f, 0.945312f, 0.949219f,
+ 0.954102f, 0.957031f, 0.960938f, 0.963379f, 0.966797f, 0.969238f, 0.972168f, 0.974609f, 0.977051f, 0.979492f, 0.980957f, 0.983398f,
+ 0.985352f, 0.987305f, 0.994141f, 0.994141f, 0.994141f, 0.993652f, 0.993164f, 0.992676f, 0.004223f, 0.014046f, 0.025452f, 0.039062f,
+ 0.055115f, 0.073608f, 0.095642f, 0.120239f, 0.149292f, 0.182251f, 0.217529f, 0.257080f, 0.298828f, 0.342773f, 0.387207f, 0.431152f,
+ 0.474609f, 0.516602f, 0.556641f, 0.593750f, 0.628418f, 0.660156f, 0.689453f, 0.715820f, 0.740723f, 0.762207f, 0.782227f, 0.799805f,
+ 0.816406f, 0.830566f, 0.844727f, 0.855469f, 0.867188f, 0.877441f, 0.886230f, 0.895020f, 0.903809f, 0.910645f, 0.917480f, 0.923340f,
+ 0.928711f, 0.934570f, 0.939453f, 0.943848f, 0.948242f, 0.952148f, 0.956055f, 0.959473f, 0.961914f, 0.965820f, 0.968750f, 0.971680f,
+ 0.974121f, 0.975586f, 0.979004f, 0.980957f, 0.983398f, 0.985352f, 0.993652f, 0.993652f, 0.993164f, 0.993164f, 0.992676f, 0.991699f,
+ 0.003532f, 0.011536f, 0.020645f, 0.031342f, 0.044098f, 0.058624f, 0.075989f, 0.096252f, 0.119141f, 0.145386f, 0.175049f, 0.208130f,
+ 0.244385f, 0.283203f, 0.324463f, 0.367432f, 0.410400f, 0.453369f, 0.495361f, 0.534668f, 0.572266f, 0.607910f, 0.641602f, 0.672852f,
+ 0.700195f, 0.725098f, 0.748047f, 0.769531f, 0.789062f, 0.806152f, 0.821777f, 0.835938f, 0.848633f, 0.860352f, 0.872070f, 0.881836f,
+ 0.890625f, 0.898926f, 0.906738f, 0.913086f, 0.919922f, 0.925781f, 0.931641f, 0.936523f, 0.941406f, 0.946289f, 0.950684f, 0.954590f,
+ 0.958008f, 0.961426f, 0.964844f, 0.968262f, 0.970703f, 0.973633f, 0.976074f, 0.978516f, 0.980469f, 0.982910f, 0.992676f, 0.992676f,
+ 0.992188f, 0.992188f, 0.991699f, 0.990723f, 0.002850f, 0.009483f, 0.016647f, 0.025833f, 0.035889f, 0.047424f, 0.061646f, 0.076660f,
+ 0.095642f, 0.117065f, 0.141113f, 0.168457f, 0.198975f, 0.233032f, 0.269775f, 0.308838f, 0.349854f, 0.391357f, 0.432861f, 0.474121f,
+ 0.515625f, 0.552734f, 0.589355f, 0.622559f, 0.654785f, 0.683594f, 0.710938f, 0.735352f, 0.757812f, 0.777344f, 0.795898f, 0.812988f,
+ 0.827637f, 0.842285f, 0.854492f, 0.866211f, 0.876953f, 0.886719f, 0.895508f, 0.902832f, 0.911133f, 0.917969f, 0.924316f, 0.929688f,
+ 0.935059f, 0.940430f, 0.945312f, 0.949219f, 0.953125f, 0.958008f, 0.961426f, 0.964844f, 0.967285f, 0.970703f, 0.973633f, 0.975586f,
+ 0.978516f, 0.981445f, 0.991699f, 0.992188f, 0.991699f, 0.991211f, 0.991211f, 0.990723f, 0.002628f, 0.007713f, 0.014069f, 0.021484f,
+ 0.029709f, 0.038910f, 0.050201f, 0.063171f, 0.078186f, 0.094849f, 0.114563f, 0.137329f, 0.162720f, 0.190918f, 0.222656f, 0.257568f,
+ 0.293945f, 0.332764f, 0.372803f, 0.414551f, 0.455078f, 0.495361f, 0.533691f, 0.571289f, 0.606445f, 0.639160f, 0.668457f, 0.697754f,
+ 0.723633f, 0.746094f, 0.767090f, 0.787598f, 0.804199f, 0.820801f, 0.834473f, 0.848633f, 0.860352f, 0.872559f, 0.882324f, 0.891602f,
+ 0.899902f, 0.907715f, 0.915039f, 0.921387f, 0.927734f, 0.934082f, 0.938965f, 0.944824f, 0.948730f, 0.953125f, 0.956543f, 0.960938f,
+ 0.963867f, 0.967285f, 0.970215f, 0.973145f, 0.976074f, 0.978516f, 0.990234f, 0.990723f, 0.990723f, 0.991211f, 0.990234f, 0.990234f,
+ 0.002131f, 0.006535f, 0.012016f, 0.017670f, 0.024780f, 0.032837f, 0.041199f, 0.051819f, 0.063904f, 0.077759f, 0.093689f, 0.112610f,
+ 0.133057f, 0.156860f, 0.183472f, 0.213257f, 0.245605f, 0.281006f, 0.318115f, 0.357422f, 0.397217f, 0.437500f, 0.478271f, 0.516602f,
+ 0.554688f, 0.589844f, 0.623535f, 0.654785f, 0.684082f, 0.710938f, 0.734375f, 0.757812f, 0.777832f, 0.795898f, 0.813477f, 0.828613f,
+ 0.843262f, 0.855957f, 0.867676f, 0.878906f, 0.888184f, 0.897461f, 0.905273f, 0.912598f, 0.919922f, 0.926758f, 0.932129f, 0.937988f,
+ 0.942871f, 0.947754f, 0.951660f, 0.955566f, 0.960449f, 0.964355f, 0.967285f, 0.970215f, 0.973145f, 0.976074f, 0.989746f, 0.990234f,
+ 0.990234f, 0.990234f, 0.989746f, 0.988770f, 0.001566f, 0.005798f, 0.010231f, 0.015259f, 0.020920f, 0.027176f, 0.034607f, 0.043335f,
+ 0.052887f, 0.064392f, 0.077576f, 0.092712f, 0.109802f, 0.129639f, 0.151611f, 0.176758f, 0.204346f, 0.235474f, 0.269043f, 0.304688f,
+ 0.342529f, 0.381836f, 0.421143f, 0.460449f, 0.500488f, 0.538086f, 0.574219f, 0.608887f, 0.640625f, 0.670898f, 0.699219f, 0.725098f,
+ 0.748535f, 0.769043f, 0.788574f, 0.807129f, 0.823242f, 0.837402f, 0.850586f, 0.863281f, 0.874512f, 0.885254f, 0.894043f, 0.902832f,
+ 0.910645f, 0.917969f, 0.924805f, 0.931152f, 0.936523f, 0.941895f, 0.947266f, 0.951172f, 0.955566f, 0.960449f, 0.963867f, 0.966797f,
+ 0.970703f, 0.973145f, 0.988281f, 0.989258f, 0.989258f, 0.989258f, 0.988770f, 0.988281f, 0.001427f, 0.004749f, 0.008934f, 0.012833f,
+ 0.017670f, 0.023483f, 0.029114f, 0.036438f, 0.044556f, 0.054047f, 0.064453f, 0.077148f, 0.091309f, 0.107544f, 0.125854f, 0.146729f,
+ 0.170776f, 0.197266f, 0.226440f, 0.257568f, 0.292236f, 0.329346f, 0.367188f, 0.405762f, 0.445557f, 0.484619f, 0.522949f, 0.559570f,
+ 0.595215f, 0.627441f, 0.659180f, 0.687012f, 0.714355f, 0.739258f, 0.761719f, 0.781738f, 0.800781f, 0.817383f, 0.833984f, 0.847168f,
+ 0.859375f, 0.872070f, 0.882324f, 0.891602f, 0.900879f, 0.909668f, 0.916504f, 0.923828f, 0.930176f, 0.936523f, 0.941895f, 0.946777f,
+ 0.951172f, 0.956055f, 0.960449f, 0.963867f, 0.967285f, 0.970703f, 0.987305f, 0.988770f, 0.988281f, 0.987793f, 0.987793f, 0.987793f,
+ 0.001357f, 0.004501f, 0.007557f, 0.011284f, 0.015236f, 0.019791f, 0.025101f, 0.030838f, 0.037628f, 0.045532f, 0.054596f, 0.064636f,
+ 0.076355f, 0.089905f, 0.105042f, 0.122498f, 0.142334f, 0.164307f, 0.189697f, 0.217896f, 0.248413f, 0.281494f, 0.316406f, 0.354004f,
+ 0.391846f, 0.430664f, 0.469971f, 0.508301f, 0.545898f, 0.582031f, 0.615723f, 0.647461f, 0.677734f, 0.704590f, 0.731445f, 0.754395f,
+ 0.775391f, 0.794922f, 0.811523f, 0.829102f, 0.842773f, 0.856934f, 0.868652f, 0.880371f, 0.891113f, 0.899414f, 0.908203f, 0.915527f,
+ 0.922852f, 0.930176f, 0.936035f, 0.941406f, 0.947266f, 0.951660f, 0.957031f, 0.960449f, 0.963867f, 0.968262f, 0.986328f, 0.987305f,
+ 0.987793f, 0.987305f, 0.987305f, 0.986816f, 0.001239f, 0.003864f, 0.006699f, 0.009621f, 0.013008f, 0.017059f, 0.021805f, 0.026703f,
+ 0.032562f, 0.039185f, 0.045807f, 0.054352f, 0.064514f, 0.075439f, 0.088257f, 0.102478f, 0.119263f, 0.138306f, 0.159546f, 0.183228f,
+ 0.209961f, 0.239258f, 0.271484f, 0.305176f, 0.341797f, 0.379639f, 0.417480f, 0.456787f, 0.495605f, 0.532227f, 0.570801f, 0.604980f,
+ 0.637207f, 0.666992f, 0.696289f, 0.722656f, 0.746582f, 0.768555f, 0.789062f, 0.808105f, 0.824219f, 0.839844f, 0.854492f, 0.865723f,
+ 0.878418f, 0.888672f, 0.897461f, 0.906738f, 0.915039f, 0.922363f, 0.929199f, 0.935547f, 0.941895f, 0.946289f, 0.952148f, 0.956543f,
+ 0.960449f, 0.964844f, 0.985352f, 0.986816f, 0.986816f, 0.986328f, 0.986328f, 0.985840f, 0.001151f, 0.003429f, 0.005753f, 0.008400f,
+ 0.011391f, 0.014877f, 0.018494f, 0.022858f, 0.028046f, 0.033112f, 0.039642f, 0.046661f, 0.054565f, 0.064026f, 0.074280f, 0.086243f,
+ 0.100403f, 0.116150f, 0.133789f, 0.154053f, 0.176636f, 0.202393f, 0.230957f, 0.261719f, 0.295166f, 0.330322f, 0.367432f, 0.405518f,
+ 0.445312f, 0.483398f, 0.520996f, 0.558105f, 0.594238f, 0.626465f, 0.659668f, 0.688477f, 0.714844f, 0.740723f, 0.763672f, 0.784180f,
+ 0.804199f, 0.821289f, 0.837402f, 0.852051f, 0.864258f, 0.876465f, 0.886719f, 0.897949f, 0.906250f, 0.915039f, 0.922363f, 0.929199f,
+ 0.935547f, 0.941406f, 0.946777f, 0.952637f, 0.958008f, 0.961914f, 0.983887f, 0.985840f, 0.985352f, 0.985352f, 0.984863f, 0.984863f,
+ 0.001000f, 0.002768f, 0.005127f, 0.007515f, 0.010155f, 0.013283f, 0.016205f, 0.019714f, 0.023987f, 0.028854f, 0.033905f, 0.040161f,
+ 0.046814f, 0.054199f, 0.063110f, 0.073303f, 0.084839f, 0.098145f, 0.112854f, 0.129883f, 0.149292f, 0.171387f, 0.195435f, 0.222778f,
+ 0.252686f, 0.285400f, 0.320312f, 0.356689f, 0.394531f, 0.433105f, 0.471924f, 0.510742f, 0.547852f, 0.584473f, 0.617676f, 0.650879f,
+ 0.680664f, 0.708984f, 0.734375f, 0.759277f, 0.780762f, 0.799805f, 0.817383f, 0.834473f, 0.849121f, 0.862793f, 0.875488f, 0.886719f,
+ 0.896484f, 0.906250f, 0.915039f, 0.923828f, 0.930176f, 0.936035f, 0.942871f, 0.948242f, 0.953613f, 0.958008f, 0.982910f, 0.983887f,
+ 0.984375f, 0.983887f, 0.984375f, 0.983398f, 0.000799f, 0.002705f, 0.004459f, 0.006573f, 0.008842f, 0.011375f, 0.014099f, 0.017487f,
+ 0.020798f, 0.024963f, 0.029465f, 0.034637f, 0.039703f, 0.046478f, 0.054047f, 0.062256f, 0.072388f, 0.082947f, 0.095764f, 0.110229f,
+ 0.126099f, 0.144775f, 0.165771f, 0.189697f, 0.216187f, 0.244995f, 0.276123f, 0.310303f, 0.346191f, 0.384521f, 0.422607f, 0.461670f,
+ 0.500000f, 0.538574f, 0.575195f, 0.609863f, 0.643555f, 0.673828f, 0.702637f, 0.730469f, 0.754395f, 0.777344f, 0.797363f, 0.815430f,
+ 0.833008f, 0.848633f, 0.861328f, 0.875000f, 0.886719f, 0.896973f, 0.906738f, 0.915039f, 0.923340f, 0.930176f, 0.936523f, 0.943848f,
+ 0.948730f, 0.954102f, 0.981445f, 0.983398f, 0.982910f, 0.983398f, 0.982910f, 0.982910f, 0.000774f, 0.002554f, 0.003899f, 0.005875f,
+ 0.007759f, 0.009949f, 0.012733f, 0.015060f, 0.018280f, 0.021667f, 0.025574f, 0.029678f, 0.034698f, 0.040405f, 0.046570f, 0.053650f,
+ 0.061462f, 0.071106f, 0.081360f, 0.093323f, 0.107300f, 0.122864f, 0.140747f, 0.160522f, 0.183960f, 0.209229f, 0.237305f, 0.268799f,
+ 0.302002f, 0.337402f, 0.374023f, 0.413330f, 0.451904f, 0.490967f, 0.529785f, 0.567383f, 0.603027f, 0.636719f, 0.668457f, 0.698242f,
+ 0.725586f, 0.750977f, 0.773926f, 0.793945f, 0.813965f, 0.831543f, 0.847656f, 0.861816f, 0.874512f, 0.886719f, 0.897461f, 0.906738f,
+ 0.915527f, 0.923828f, 0.931641f, 0.937988f, 0.944824f, 0.949707f, 0.979980f, 0.981934f, 0.981934f, 0.981934f, 0.981934f, 0.981445f,
+ 0.000657f, 0.001934f, 0.003330f, 0.005280f, 0.006748f, 0.009079f, 0.010994f, 0.013763f, 0.015945f, 0.019150f, 0.022003f, 0.026001f,
+ 0.030350f, 0.034790f, 0.040253f, 0.045898f, 0.052795f, 0.060852f, 0.069641f, 0.079346f, 0.091187f, 0.104492f, 0.119751f, 0.136963f,
+ 0.156372f, 0.178345f, 0.203247f, 0.230957f, 0.260742f, 0.294189f, 0.328613f, 0.365723f, 0.403564f, 0.443115f, 0.482910f, 0.521484f,
+ 0.559570f, 0.596680f, 0.630859f, 0.664062f, 0.694336f, 0.722168f, 0.747559f, 0.771484f, 0.793457f, 0.813477f, 0.830078f, 0.846191f,
+ 0.861816f, 0.874023f, 0.887207f, 0.898438f, 0.908691f, 0.916992f, 0.925293f, 0.933594f, 0.939941f, 0.946777f, 0.978516f, 0.980469f,
+ 0.980469f, 0.980469f, 0.980469f, 0.980469f, 0.000818f, 0.001935f, 0.003246f, 0.004658f, 0.006229f, 0.007912f, 0.010017f, 0.012093f,
+ 0.014259f, 0.016586f, 0.019653f, 0.022659f, 0.026413f, 0.030289f, 0.034790f, 0.039917f, 0.045441f, 0.052338f, 0.059479f, 0.068115f,
+ 0.077759f, 0.089050f, 0.102051f, 0.116272f, 0.133179f, 0.152344f, 0.173340f, 0.197876f, 0.224243f, 0.254150f, 0.286621f, 0.321533f,
+ 0.357666f, 0.396729f, 0.436279f, 0.475830f, 0.514648f, 0.553711f, 0.590332f, 0.626465f, 0.659180f, 0.689941f, 0.719238f, 0.746094f,
+ 0.770020f, 0.792480f, 0.812500f, 0.830566f, 0.846680f, 0.862305f, 0.875977f, 0.888184f, 0.899414f, 0.910156f, 0.918945f, 0.927246f,
+ 0.935059f, 0.941895f, 0.977051f, 0.979004f, 0.979492f, 0.979004f, 0.979492f, 0.979004f, 0.000583f, 0.001696f, 0.003044f, 0.004276f,
+ 0.005394f, 0.007111f, 0.009048f, 0.010727f, 0.012802f, 0.014549f, 0.017319f, 0.019943f, 0.023132f, 0.026459f, 0.030212f, 0.034576f,
+ 0.039612f, 0.045105f, 0.051422f, 0.058594f, 0.066833f, 0.076416f, 0.087341f, 0.099792f, 0.113647f, 0.130005f, 0.147827f, 0.168945f,
+ 0.192261f, 0.218750f, 0.247803f, 0.280029f, 0.314209f, 0.351074f, 0.389404f, 0.429199f, 0.468750f, 0.508301f, 0.547852f, 0.585938f,
+ 0.622070f, 0.655762f, 0.687988f, 0.718262f, 0.744629f, 0.769531f, 0.792480f, 0.812500f, 0.832520f, 0.848633f, 0.863770f, 0.877441f,
+ 0.890137f, 0.901367f, 0.912109f, 0.921387f, 0.929199f, 0.937500f, 0.975586f, 0.978027f, 0.978027f, 0.977539f, 0.977539f, 0.977051f,
+ 0.000463f, 0.001634f, 0.002899f, 0.003574f, 0.004932f, 0.006233f, 0.007866f, 0.009644f, 0.011055f, 0.012894f, 0.015518f, 0.017792f,
+ 0.020279f, 0.023178f, 0.026657f, 0.030136f, 0.034271f, 0.039062f, 0.044586f, 0.050446f, 0.057739f, 0.065613f, 0.074646f, 0.084900f,
+ 0.097107f, 0.111023f, 0.126099f, 0.143921f, 0.164673f, 0.187500f, 0.213257f, 0.242065f, 0.273926f, 0.308594f, 0.344971f, 0.383301f,
+ 0.423340f, 0.463623f, 0.503906f, 0.543945f, 0.582520f, 0.619629f, 0.653809f, 0.686523f, 0.717285f, 0.744629f, 0.770020f, 0.792969f,
+ 0.814453f, 0.833496f, 0.850098f, 0.866211f, 0.879395f, 0.893066f, 0.904297f, 0.914551f, 0.923828f, 0.932129f, 0.973145f, 0.976074f,
+ 0.976562f, 0.976074f, 0.976074f, 0.976074f, 0.000472f, 0.001289f, 0.002508f, 0.003481f, 0.004459f, 0.005894f, 0.007042f, 0.008232f,
+ 0.009972f, 0.011719f, 0.013435f, 0.015884f, 0.017899f, 0.020386f, 0.023422f, 0.026428f, 0.030411f, 0.034180f, 0.038757f, 0.043854f,
+ 0.049652f, 0.056549f, 0.064270f, 0.073303f, 0.083252f, 0.095093f, 0.107910f, 0.123169f, 0.141113f, 0.160645f, 0.183472f, 0.208618f,
+ 0.237305f, 0.268799f, 0.302734f, 0.339600f, 0.377930f, 0.418457f, 0.459473f, 0.500000f, 0.540527f, 0.579102f, 0.617188f, 0.652832f,
+ 0.685547f, 0.716309f, 0.745117f, 0.771484f, 0.794922f, 0.815918f, 0.834961f, 0.853027f, 0.868652f, 0.882324f, 0.895996f, 0.907227f,
+ 0.916992f, 0.927246f, 0.972168f, 0.974121f, 0.975098f, 0.973633f, 0.974609f, 0.973633f, 0.000238f, 0.001453f, 0.002047f, 0.002985f,
+ 0.004227f, 0.005272f, 0.006096f, 0.007309f, 0.008957f, 0.010437f, 0.012184f, 0.014214f, 0.015793f, 0.018082f, 0.020538f, 0.023270f,
+ 0.026505f, 0.029648f, 0.033813f, 0.038300f, 0.043457f, 0.049042f, 0.055298f, 0.062744f, 0.070984f, 0.081299f, 0.092590f, 0.105591f,
+ 0.120361f, 0.137695f, 0.156982f, 0.179443f, 0.204346f, 0.232788f, 0.263672f, 0.297363f, 0.334229f, 0.373047f, 0.414307f, 0.455322f,
+ 0.497314f, 0.538086f, 0.578613f, 0.616211f, 0.653320f, 0.686523f, 0.718262f, 0.747559f, 0.773438f, 0.797363f, 0.818848f, 0.838867f,
+ 0.856934f, 0.871582f, 0.885742f, 0.898926f, 0.910645f, 0.920410f, 0.970215f, 0.971680f, 0.972656f, 0.972656f, 0.972168f, 0.972168f,
+ 0.000376f, 0.001075f, 0.002052f, 0.002823f, 0.003603f, 0.004509f, 0.005619f, 0.007008f, 0.008064f, 0.009132f, 0.010849f, 0.012314f,
+ 0.013817f, 0.015945f, 0.018188f, 0.020676f, 0.022995f, 0.026230f, 0.029587f, 0.033234f, 0.037598f, 0.042328f, 0.048004f, 0.054230f,
+ 0.061188f, 0.069824f, 0.079468f, 0.090454f, 0.103271f, 0.117493f, 0.134644f, 0.153931f, 0.175293f, 0.200806f, 0.228149f, 0.259277f,
+ 0.293945f, 0.330566f, 0.370117f, 0.410889f, 0.453369f, 0.495605f, 0.537109f, 0.578125f, 0.616699f, 0.653809f, 0.689453f, 0.721191f,
+ 0.750000f, 0.776855f, 0.800293f, 0.822754f, 0.841309f, 0.859863f, 0.876465f, 0.890137f, 0.902832f, 0.914062f, 0.967773f, 0.970703f,
+ 0.970703f, 0.970703f, 0.970703f, 0.970703f, 0.000237f, 0.000972f, 0.001674f, 0.002413f, 0.003336f, 0.003956f, 0.005093f, 0.006039f,
+ 0.007069f, 0.008202f, 0.009613f, 0.011017f, 0.012520f, 0.014282f, 0.016068f, 0.017853f, 0.020508f, 0.023117f, 0.025986f, 0.029160f,
+ 0.032898f, 0.036865f, 0.041565f, 0.046997f, 0.052887f, 0.060089f, 0.068176f, 0.077515f, 0.088257f, 0.100586f, 0.114929f, 0.131592f,
+ 0.150635f, 0.172241f, 0.196411f, 0.224731f, 0.255859f, 0.290039f, 0.327393f, 0.367188f, 0.409180f, 0.451172f, 0.493896f, 0.536621f,
+ 0.578613f, 0.618164f, 0.655762f, 0.691406f, 0.724121f, 0.753906f, 0.781738f, 0.805176f, 0.827637f, 0.847656f, 0.864746f, 0.880859f,
+ 0.895508f, 0.907715f, 0.965332f, 0.968262f, 0.968750f, 0.969238f, 0.967773f, 0.967773f, 0.000450f, 0.001033f, 0.001554f, 0.002131f,
+ 0.002939f, 0.003662f, 0.004551f, 0.005722f, 0.006405f, 0.007542f, 0.008484f, 0.009750f, 0.011017f, 0.012596f, 0.014046f, 0.015854f,
+ 0.017975f, 0.020264f, 0.022736f, 0.025497f, 0.028671f, 0.031952f, 0.036011f, 0.040741f, 0.045746f, 0.051910f, 0.058868f, 0.066772f,
+ 0.075867f, 0.086304f, 0.098328f, 0.112244f, 0.128784f, 0.147217f, 0.168945f, 0.193848f, 0.221558f, 0.252441f, 0.287109f, 0.324951f,
+ 0.365234f, 0.407715f, 0.450684f, 0.494629f, 0.539062f, 0.580566f, 0.621094f, 0.659668f, 0.695801f, 0.729004f, 0.758789f, 0.786133f,
+ 0.810547f, 0.833008f, 0.852539f, 0.870117f, 0.886719f, 0.900879f, 0.962891f, 0.966309f, 0.966309f, 0.966797f, 0.966797f, 0.966309f,
+ 0.000304f, 0.001050f, 0.001257f, 0.002295f, 0.002689f, 0.003885f, 0.004284f, 0.004726f, 0.005547f, 0.006721f, 0.007595f, 0.008667f,
+ 0.009811f, 0.011330f, 0.012642f, 0.014130f, 0.016098f, 0.017975f, 0.019867f, 0.022247f, 0.024811f, 0.028030f, 0.031403f, 0.035461f,
+ 0.039642f, 0.044800f, 0.050720f, 0.057495f, 0.065002f, 0.073914f, 0.084290f, 0.095947f, 0.109985f, 0.126343f, 0.144409f, 0.166138f,
+ 0.190918f, 0.218750f, 0.250244f, 0.285400f, 0.323730f, 0.364258f, 0.407471f, 0.452148f, 0.496338f, 0.540527f, 0.584473f, 0.625977f,
+ 0.665039f, 0.701172f, 0.735352f, 0.765137f, 0.792480f, 0.817383f, 0.840332f, 0.859863f, 0.876953f, 0.893066f, 0.959961f, 0.963379f,
+ 0.963867f, 0.964355f, 0.963867f, 0.963867f, 0.000228f, 0.000682f, 0.001293f, 0.001717f, 0.002352f, 0.003160f, 0.003626f, 0.004360f,
+ 0.005348f, 0.005871f, 0.006870f, 0.007660f, 0.008957f, 0.010002f, 0.011299f, 0.012375f, 0.014099f, 0.015900f, 0.017670f, 0.019363f,
+ 0.022034f, 0.024216f, 0.027420f, 0.030930f, 0.034454f, 0.038910f, 0.044006f, 0.049530f, 0.055878f, 0.063477f, 0.072083f, 0.082275f,
+ 0.094177f, 0.107666f, 0.123840f, 0.142090f, 0.163452f, 0.188477f, 0.216919f, 0.248047f, 0.283447f, 0.322754f, 0.364990f, 0.408447f,
+ 0.453613f, 0.500000f, 0.544922f, 0.589355f, 0.631348f, 0.671387f, 0.708008f, 0.742188f, 0.773438f, 0.800781f, 0.824219f, 0.846680f,
+ 0.866699f, 0.884277f, 0.958008f, 0.960938f, 0.961426f, 0.962402f, 0.961914f, 0.960938f, 0.000239f, 0.000731f, 0.001204f, 0.001637f,
+ 0.002144f, 0.002913f, 0.003521f, 0.003828f, 0.004517f, 0.005291f, 0.006203f, 0.006954f, 0.007740f, 0.008911f, 0.010239f, 0.011017f,
+ 0.012413f, 0.013863f, 0.015396f, 0.017181f, 0.019196f, 0.021439f, 0.024078f, 0.026993f, 0.030182f, 0.033752f, 0.038055f, 0.042664f,
+ 0.048004f, 0.054657f, 0.061920f, 0.070312f, 0.080688f, 0.092041f, 0.105774f, 0.121094f, 0.140015f, 0.161255f, 0.186523f, 0.214966f,
+ 0.246948f, 0.283203f, 0.322998f, 0.365967f, 0.410400f, 0.457275f, 0.503906f, 0.550781f, 0.596191f, 0.638672f, 0.678711f, 0.716797f,
+ 0.750488f, 0.781738f, 0.809082f, 0.833496f, 0.855469f, 0.874512f, 0.954590f, 0.958008f, 0.958984f, 0.958984f, 0.958984f, 0.958984f,
+ 0.000226f, 0.000663f, 0.001073f, 0.001420f, 0.002163f, 0.002567f, 0.003052f, 0.003433f, 0.004181f, 0.004734f, 0.005516f, 0.006424f,
+ 0.007050f, 0.008003f, 0.008659f, 0.009827f, 0.011086f, 0.012398f, 0.013649f, 0.015266f, 0.016891f, 0.018921f, 0.021118f, 0.023560f,
+ 0.026505f, 0.029556f, 0.032715f, 0.036865f, 0.041077f, 0.046570f, 0.053314f, 0.060150f, 0.068787f, 0.078552f, 0.090027f, 0.103638f,
+ 0.119690f, 0.138184f, 0.159546f, 0.184692f, 0.213745f, 0.245972f, 0.283203f, 0.324219f, 0.367920f, 0.414062f, 0.461914f, 0.509766f,
+ 0.557129f, 0.604492f, 0.647461f, 0.688965f, 0.727051f, 0.761230f, 0.791504f, 0.819824f, 0.844238f, 0.865234f, 0.951660f, 0.955566f,
+ 0.955566f, 0.956055f, 0.955078f, 0.956543f, 0.000156f, 0.000587f, 0.001056f, 0.001499f, 0.001647f, 0.002380f, 0.002594f, 0.003469f,
+ 0.003777f, 0.004112f, 0.004925f, 0.005699f, 0.006180f, 0.007019f, 0.007957f, 0.008942f, 0.009560f, 0.010727f, 0.011963f, 0.013123f,
+ 0.014885f, 0.016556f, 0.018494f, 0.020355f, 0.022766f, 0.025330f, 0.028320f, 0.031830f, 0.035736f, 0.040161f, 0.045532f, 0.052032f,
+ 0.059113f, 0.066833f, 0.076782f, 0.088501f, 0.101868f, 0.117310f, 0.136108f, 0.157959f, 0.183105f, 0.212769f, 0.247070f, 0.284424f,
+ 0.326660f, 0.371338f, 0.419189f, 0.468994f, 0.518066f, 0.567383f, 0.613770f, 0.658691f, 0.700684f, 0.738770f, 0.771973f, 0.803223f,
+ 0.829590f, 0.854492f, 0.947266f, 0.952637f, 0.952637f, 0.952637f, 0.953125f, 0.952637f, 0.000155f, 0.000358f, 0.000859f, 0.001402f,
+ 0.001830f, 0.002092f, 0.002499f, 0.002672f, 0.003410f, 0.003763f, 0.004375f, 0.005077f, 0.005535f, 0.006554f, 0.007004f, 0.007874f,
+ 0.008537f, 0.009529f, 0.010742f, 0.011749f, 0.013016f, 0.014427f, 0.015945f, 0.017929f, 0.019775f, 0.022018f, 0.024460f, 0.027618f,
+ 0.030640f, 0.034668f, 0.039154f, 0.044250f, 0.050293f, 0.057068f, 0.065491f, 0.074951f, 0.086487f, 0.099670f, 0.115906f, 0.134277f,
+ 0.156860f, 0.182495f, 0.213135f, 0.248047f, 0.286621f, 0.329834f, 0.376709f, 0.426025f, 0.476562f, 0.527832f, 0.577637f, 0.626465f,
+ 0.671387f, 0.713379f, 0.752441f, 0.784668f, 0.815430f, 0.841797f, 0.944336f, 0.948242f, 0.949219f, 0.949219f, 0.949219f, 0.949707f,
+ 0.000233f, 0.000639f, 0.000930f, 0.001277f, 0.001579f, 0.001916f, 0.002041f, 0.002625f, 0.003035f, 0.003571f, 0.004124f, 0.004375f,
+ 0.004978f, 0.005379f, 0.006348f, 0.006886f, 0.007526f, 0.008430f, 0.009216f, 0.010262f, 0.011436f, 0.012779f, 0.014160f, 0.015549f,
+ 0.017120f, 0.019089f, 0.021164f, 0.023621f, 0.026352f, 0.029724f, 0.033447f, 0.037842f, 0.042603f, 0.048737f, 0.055573f, 0.063721f,
+ 0.073364f, 0.084778f, 0.098206f, 0.114197f, 0.133423f, 0.155762f, 0.182739f, 0.213623f, 0.249512f, 0.289795f, 0.335205f, 0.383789f,
+ 0.434814f, 0.487305f, 0.540039f, 0.591797f, 0.640137f, 0.686035f, 0.727539f, 0.765137f, 0.800293f, 0.830078f, 0.940430f, 0.944336f,
+ 0.945312f, 0.946289f, 0.945801f, 0.945312f, 0.000217f, 0.000519f, 0.000848f, 0.001180f, 0.001366f, 0.001589f, 0.001986f, 0.002354f,
+ 0.002987f, 0.003170f, 0.003576f, 0.003901f, 0.004440f, 0.004738f, 0.005543f, 0.006058f, 0.006508f, 0.007511f, 0.008163f, 0.009132f,
+ 0.010078f, 0.011246f, 0.012390f, 0.013412f, 0.014938f, 0.016632f, 0.018433f, 0.020676f, 0.022995f, 0.025726f, 0.028702f, 0.032227f,
+ 0.036377f, 0.041992f, 0.047394f, 0.053986f, 0.062195f, 0.071716f, 0.082825f, 0.096802f, 0.112732f, 0.132202f, 0.155273f, 0.182861f,
+ 0.215210f, 0.252441f, 0.294678f, 0.341553f, 0.392090f, 0.445557f, 0.499512f, 0.553711f, 0.606445f, 0.656250f, 0.703125f, 0.745605f,
+ 0.782715f, 0.816895f, 0.935547f, 0.939941f, 0.941406f, 0.941406f, 0.941406f, 0.940918f, 0.000242f, 0.000678f, 0.000781f, 0.000928f,
+ 0.001200f, 0.001592f, 0.001694f, 0.002096f, 0.002703f, 0.002903f, 0.003170f, 0.003531f, 0.003918f, 0.004433f, 0.004955f, 0.005390f,
+ 0.005939f, 0.006454f, 0.007298f, 0.007782f, 0.008759f, 0.009567f, 0.010559f, 0.011650f, 0.013046f, 0.014420f, 0.015793f, 0.017715f,
+ 0.019699f, 0.021774f, 0.024460f, 0.027481f, 0.031082f, 0.035065f, 0.039917f, 0.045715f, 0.052246f, 0.060486f, 0.070129f, 0.081482f,
+ 0.095093f, 0.111755f, 0.131714f, 0.155273f, 0.183838f, 0.217285f, 0.256348f, 0.300781f, 0.350342f, 0.403076f, 0.458252f, 0.514160f,
+ 0.570312f, 0.624512f, 0.675781f, 0.722168f, 0.763672f, 0.800293f, 0.930664f, 0.935547f, 0.937500f, 0.937012f, 0.937500f, 0.937012f,
+ 0.000239f, 0.000297f, 0.000667f, 0.000785f, 0.001044f, 0.001269f, 0.001569f, 0.001950f, 0.002224f, 0.002419f, 0.002810f, 0.003063f,
+ 0.003626f, 0.003895f, 0.004261f, 0.004749f, 0.005066f, 0.005726f, 0.006260f, 0.007019f, 0.007771f, 0.008369f, 0.008919f, 0.009941f,
+ 0.011101f, 0.012375f, 0.013519f, 0.015190f, 0.016891f, 0.018631f, 0.021011f, 0.023590f, 0.026581f, 0.029892f, 0.033875f, 0.038757f,
+ 0.044281f, 0.051147f, 0.058746f, 0.068481f, 0.079834f, 0.094116f, 0.110779f, 0.131348f, 0.155884f, 0.185669f, 0.220825f, 0.261963f,
+ 0.308594f, 0.360352f, 0.416260f, 0.473877f, 0.532715f, 0.589844f, 0.645508f, 0.696289f, 0.743652f, 0.784668f, 0.925781f, 0.930664f,
+ 0.932129f, 0.932129f, 0.932129f, 0.932129f, 0.000226f, 0.000351f, 0.000434f, 0.000624f, 0.000887f, 0.001040f, 0.001246f, 0.001665f,
+ 0.001856f, 0.002384f, 0.002420f, 0.002842f, 0.002874f, 0.003471f, 0.003735f, 0.004078f, 0.004639f, 0.004910f, 0.005531f, 0.006065f,
+ 0.006664f, 0.007370f, 0.007690f, 0.008690f, 0.009544f, 0.010536f, 0.011795f, 0.012833f, 0.014183f, 0.015900f, 0.017899f, 0.019684f,
+ 0.022430f, 0.025253f, 0.028412f, 0.032410f, 0.037201f, 0.042633f, 0.049316f, 0.057159f, 0.066772f, 0.078186f, 0.092590f, 0.110107f,
+ 0.131348f, 0.156982f, 0.188232f, 0.225342f, 0.269043f, 0.318604f, 0.373535f, 0.431641f, 0.492188f, 0.554199f, 0.613281f, 0.668945f,
+ 0.720703f, 0.766602f, 0.919922f, 0.925781f, 0.926758f, 0.926758f, 0.927246f, 0.926758f, 0.000000f, 0.000340f, 0.000458f, 0.000715f,
+ 0.000823f, 0.000895f, 0.001165f, 0.001518f, 0.001636f, 0.001876f, 0.002190f, 0.002472f, 0.002640f, 0.002964f, 0.003340f, 0.003527f,
+ 0.004005f, 0.004227f, 0.004803f, 0.005260f, 0.005878f, 0.006042f, 0.006805f, 0.007500f, 0.008469f, 0.009132f, 0.009949f, 0.011009f,
+ 0.012077f, 0.013687f, 0.014938f, 0.016785f, 0.018997f, 0.021194f, 0.023895f, 0.027283f, 0.030945f, 0.035583f, 0.040955f, 0.047760f,
+ 0.055573f, 0.065247f, 0.077209f, 0.091736f, 0.109619f, 0.131470f, 0.159058f, 0.192017f, 0.231812f, 0.278076f, 0.331543f, 0.389404f,
+ 0.450928f, 0.513672f, 0.577637f, 0.638672f, 0.695801f, 0.746582f, 0.914062f, 0.919922f, 0.920898f, 0.921387f, 0.921387f, 0.921387f,
+ 0.000146f, 0.000319f, 0.000443f, 0.000458f, 0.000704f, 0.000894f, 0.001199f, 0.001324f, 0.001549f, 0.001592f, 0.002081f, 0.002092f,
+ 0.002237f, 0.002604f, 0.002815f, 0.003159f, 0.003510f, 0.003937f, 0.004147f, 0.004425f, 0.004814f, 0.005318f, 0.005878f, 0.006413f,
+ 0.006924f, 0.007782f, 0.008408f, 0.009239f, 0.010414f, 0.011505f, 0.012642f, 0.014015f, 0.015884f, 0.017563f, 0.019852f, 0.022598f,
+ 0.025650f, 0.029663f, 0.033875f, 0.039307f, 0.045898f, 0.053955f, 0.063782f, 0.075928f, 0.090820f, 0.109497f, 0.132690f, 0.161621f,
+ 0.196777f, 0.239624f, 0.290039f, 0.346436f, 0.408203f, 0.473633f, 0.540527f, 0.605957f, 0.667969f, 0.725586f, 0.907715f, 0.914062f,
+ 0.914062f, 0.915039f, 0.915039f, 0.915039f, 0.000121f, 0.000251f, 0.000506f, 0.000532f, 0.000665f, 0.000830f, 0.001190f, 0.001164f,
+ 0.001290f, 0.001413f, 0.001755f, 0.001900f, 0.002157f, 0.002319f, 0.002422f, 0.002853f, 0.003042f, 0.003254f, 0.003529f, 0.003725f,
+ 0.004288f, 0.004585f, 0.005043f, 0.005539f, 0.005970f, 0.006386f, 0.007126f, 0.007812f, 0.008652f, 0.009598f, 0.010651f, 0.011803f,
+ 0.013130f, 0.014702f, 0.016510f, 0.018814f, 0.021011f, 0.024368f, 0.028122f, 0.032379f, 0.037506f, 0.044128f, 0.052277f, 0.062042f,
+ 0.075073f, 0.090088f, 0.110107f, 0.134766f, 0.165405f, 0.203613f, 0.249268f, 0.303955f, 0.365234f, 0.431396f, 0.501465f, 0.571777f,
+ 0.638672f, 0.702148f, 0.900879f, 0.906738f, 0.907227f, 0.908203f, 0.907227f, 0.908203f, 0.000241f, 0.000122f, 0.000417f, 0.000505f,
+ 0.000741f, 0.000782f, 0.000916f, 0.001145f, 0.001189f, 0.001289f, 0.001331f, 0.001565f, 0.001779f, 0.002020f, 0.002171f, 0.002228f,
+ 0.002623f, 0.002752f, 0.002949f, 0.003157f, 0.003515f, 0.003847f, 0.004082f, 0.004429f, 0.004990f, 0.005405f, 0.006008f, 0.006603f,
+ 0.007103f, 0.007889f, 0.008789f, 0.009766f, 0.010605f, 0.012177f, 0.013672f, 0.015305f, 0.017487f, 0.019913f, 0.022781f, 0.026245f,
+ 0.030670f, 0.035980f, 0.042389f, 0.050812f, 0.060883f, 0.073792f, 0.090088f, 0.111145f, 0.138062f, 0.171143f, 0.212524f, 0.262695f,
+ 0.322266f, 0.388184f, 0.460205f, 0.533203f, 0.606445f, 0.676758f, 0.893066f, 0.898926f, 0.899414f, 0.899414f, 0.900879f, 0.900391f,
+ 0.000000f, 0.000114f, 0.000227f, 0.000407f, 0.000532f, 0.000732f, 0.000714f, 0.000922f, 0.000993f, 0.001072f, 0.001190f, 0.001412f,
+ 0.001569f, 0.001726f, 0.001959f, 0.002071f, 0.002159f, 0.002350f, 0.002565f, 0.002729f, 0.003090f, 0.003248f, 0.003702f, 0.003761f,
+ 0.004192f, 0.004585f, 0.004925f, 0.005272f, 0.005966f, 0.006405f, 0.007275f, 0.007965f, 0.008850f, 0.009872f, 0.011017f, 0.012383f,
+ 0.014275f, 0.015900f, 0.018463f, 0.021194f, 0.024673f, 0.028870f, 0.034271f, 0.040955f, 0.048981f, 0.059723f, 0.073059f, 0.090149f,
+ 0.112549f, 0.141357f, 0.178467f, 0.223755f, 0.280029f, 0.345215f, 0.417969f, 0.494385f, 0.572266f, 0.648438f, 0.884277f, 0.890137f,
+ 0.891602f, 0.891602f, 0.893066f, 0.892090f, 0.000000f, 0.000219f, 0.000211f, 0.000333f, 0.000559f, 0.000609f, 0.000788f, 0.000805f,
+ 0.000869f, 0.000903f, 0.001101f, 0.001166f, 0.001302f, 0.001399f, 0.001456f, 0.001668f, 0.001853f, 0.001999f, 0.002102f, 0.002256f,
+ 0.002447f, 0.002728f, 0.002943f, 0.003178f, 0.003515f, 0.003836f, 0.004074f, 0.004475f, 0.004745f, 0.005325f, 0.005970f, 0.006569f,
+ 0.007248f, 0.008102f, 0.008888f, 0.010132f, 0.011169f, 0.012947f, 0.014763f, 0.016891f, 0.019760f, 0.023087f, 0.027176f, 0.032562f,
+ 0.038940f, 0.047516f, 0.058167f, 0.072754f, 0.090698f, 0.114929f, 0.146851f, 0.187744f, 0.239258f, 0.301514f, 0.373291f, 0.452637f,
+ 0.535645f, 0.617676f, 0.874512f, 0.880859f, 0.882324f, 0.883301f, 0.883301f, 0.882324f, 0.000204f, 0.000207f, 0.000204f, 0.000322f,
+ 0.000435f, 0.000480f, 0.000556f, 0.000615f, 0.000747f, 0.000782f, 0.000844f, 0.001006f, 0.001159f, 0.001191f, 0.001231f, 0.001450f,
+ 0.001585f, 0.001633f, 0.001790f, 0.001919f, 0.002117f, 0.002298f, 0.002432f, 0.002651f, 0.002939f, 0.003172f, 0.003399f, 0.003614f,
+ 0.003944f, 0.004421f, 0.004704f, 0.005203f, 0.005886f, 0.006454f, 0.007160f, 0.008049f, 0.009041f, 0.010201f, 0.011627f, 0.013237f,
+ 0.015404f, 0.018097f, 0.021469f, 0.025284f, 0.030884f, 0.036987f, 0.045990f, 0.056915f, 0.072083f, 0.092163f, 0.119141f, 0.154419f,
+ 0.200928f, 0.259277f, 0.328857f, 0.409424f, 0.495605f, 0.584473f, 0.864258f, 0.871094f, 0.872070f, 0.873047f, 0.872559f, 0.873047f,
+ 0.000000f, 0.000044f, 0.000176f, 0.000290f, 0.000410f, 0.000390f, 0.000513f, 0.000546f, 0.000647f, 0.000680f, 0.000827f, 0.000858f,
+ 0.000958f, 0.001131f, 0.001102f, 0.001223f, 0.001367f, 0.001401f, 0.001525f, 0.001610f, 0.001826f, 0.001821f, 0.002039f, 0.002253f,
+ 0.002459f, 0.002617f, 0.002708f, 0.003036f, 0.003279f, 0.003431f, 0.003805f, 0.004219f, 0.004471f, 0.004929f, 0.005569f, 0.006310f,
+ 0.007107f, 0.007988f, 0.009003f, 0.010384f, 0.011856f, 0.014015f, 0.016418f, 0.019669f, 0.023666f, 0.028809f, 0.035583f, 0.044159f,
+ 0.056458f, 0.072571f, 0.094604f, 0.124329f, 0.164917f, 0.218018f, 0.284912f, 0.364746f, 0.454102f, 0.549316f, 0.853027f, 0.859863f,
+ 0.861328f, 0.861816f, 0.861816f, 0.861816f, 0.000000f, 0.000069f, 0.000120f, 0.000345f, 0.000371f, 0.000398f, 0.000452f, 0.000396f,
+ 0.000498f, 0.000530f, 0.000596f, 0.000648f, 0.000781f, 0.000921f, 0.000995f, 0.001007f, 0.001101f, 0.001146f, 0.001282f, 0.001278f,
+ 0.001471f, 0.001554f, 0.001710f, 0.001811f, 0.001995f, 0.001986f, 0.002314f, 0.002399f, 0.002499f, 0.002903f, 0.002975f, 0.003305f,
+ 0.003605f, 0.004086f, 0.004425f, 0.005081f, 0.005402f, 0.006035f, 0.006889f, 0.007755f, 0.009041f, 0.010422f, 0.012672f, 0.014885f,
+ 0.017746f, 0.021530f, 0.026733f, 0.033691f, 0.043060f, 0.055847f, 0.073181f, 0.097473f, 0.132324f, 0.179077f, 0.241821f, 0.320068f,
+ 0.410400f, 0.510742f, 0.839844f, 0.847656f, 0.849121f, 0.849609f, 0.849121f, 0.849609f, 0.000000f, 0.000000f, 0.000121f, 0.000243f,
+ 0.000321f, 0.000354f, 0.000341f, 0.000431f, 0.000423f, 0.000444f, 0.000473f, 0.000508f, 0.000595f, 0.000706f, 0.000737f, 0.000861f,
+ 0.000869f, 0.000926f, 0.001055f, 0.001104f, 0.001199f, 0.001306f, 0.001360f, 0.001433f, 0.001530f, 0.001555f, 0.001673f, 0.001942f,
+ 0.002138f, 0.002247f, 0.002562f, 0.002609f, 0.002911f, 0.003204f, 0.003466f, 0.003757f, 0.004192f, 0.004845f, 0.005482f, 0.006008f,
+ 0.006874f, 0.007904f, 0.009171f, 0.011124f, 0.013260f, 0.015839f, 0.019821f, 0.024872f, 0.031982f, 0.041534f, 0.055054f, 0.075012f,
+ 0.103516f, 0.143677f, 0.199951f, 0.273438f, 0.364502f, 0.469482f, 0.825684f, 0.834473f, 0.834961f, 0.835938f, 0.835938f, 0.835938f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000120f, 0.000199f, 0.000272f, 0.000265f, 0.000363f, 0.000379f, 0.000388f, 0.000489f, 0.000500f,
+ 0.000488f, 0.000569f, 0.000604f, 0.000700f, 0.000683f, 0.000720f, 0.000784f, 0.000844f, 0.001009f, 0.001047f, 0.001108f, 0.001258f,
+ 0.001276f, 0.001388f, 0.001410f, 0.001565f, 0.001592f, 0.001814f, 0.001800f, 0.002167f, 0.002192f, 0.002556f, 0.002665f, 0.002905f,
+ 0.003195f, 0.003574f, 0.004028f, 0.004513f, 0.005127f, 0.005859f, 0.006847f, 0.008018f, 0.009491f, 0.011452f, 0.014099f, 0.017792f,
+ 0.022995f, 0.030258f, 0.040588f, 0.055878f, 0.078308f, 0.111450f, 0.160278f, 0.229248f, 0.318359f, 0.425781f, 0.810547f, 0.818359f,
+ 0.820312f, 0.821777f, 0.821777f, 0.820801f, 0.000000f, 0.000121f, 0.000120f, 0.000172f, 0.000195f, 0.000171f, 0.000208f, 0.000272f,
+ 0.000316f, 0.000333f, 0.000348f, 0.000355f, 0.000412f, 0.000410f, 0.000515f, 0.000485f, 0.000545f, 0.000656f, 0.000777f, 0.000659f,
+ 0.000705f, 0.000762f, 0.000874f, 0.000927f, 0.000959f, 0.000978f, 0.001045f, 0.001228f, 0.001294f, 0.001398f, 0.001443f, 0.001637f,
+ 0.001752f, 0.001925f, 0.002005f, 0.002230f, 0.002407f, 0.002670f, 0.002895f, 0.003267f, 0.003933f, 0.004280f, 0.005051f, 0.005772f,
+ 0.006718f, 0.008141f, 0.010117f, 0.012383f, 0.015930f, 0.020920f, 0.028671f, 0.039673f, 0.056702f, 0.083313f, 0.124695f, 0.185791f,
+ 0.270996f, 0.379639f, 0.793457f, 0.801270f, 0.803711f, 0.803711f, 0.804688f, 0.804688f, 0.000000f, 0.000121f, 0.000119f, 0.000144f,
+ 0.000149f, 0.000166f, 0.000173f, 0.000167f, 0.000214f, 0.000245f, 0.000334f, 0.000287f, 0.000303f, 0.000391f, 0.000401f, 0.000440f,
+ 0.000469f, 0.000493f, 0.000534f, 0.000513f, 0.000690f, 0.000682f, 0.000645f, 0.000712f, 0.000715f, 0.000747f, 0.000842f, 0.000849f,
+ 0.000967f, 0.000995f, 0.001178f, 0.001167f, 0.001273f, 0.001395f, 0.001586f, 0.001748f, 0.001796f, 0.001986f, 0.002132f, 0.002476f,
+ 0.002893f, 0.003294f, 0.003653f, 0.004086f, 0.004890f, 0.005821f, 0.006927f, 0.008553f, 0.010857f, 0.014137f, 0.019211f, 0.027084f,
+ 0.039642f, 0.059448f, 0.092468f, 0.144775f, 0.224487f, 0.332764f, 0.775391f, 0.784668f, 0.786133f, 0.786133f, 0.787109f, 0.786621f,
+ 0.000000f, 0.000000f, 0.000118f, 0.000116f, 0.000115f, 0.000113f, 0.000140f, 0.000140f, 0.000149f, 0.000220f, 0.000171f, 0.000255f,
+ 0.000274f, 0.000292f, 0.000318f, 0.000295f, 0.000346f, 0.000352f, 0.000380f, 0.000406f, 0.000401f, 0.000533f, 0.000490f, 0.000551f,
+ 0.000558f, 0.000648f, 0.000628f, 0.000723f, 0.000788f, 0.000749f, 0.000836f, 0.000941f, 0.000997f, 0.001065f, 0.001112f, 0.001207f,
+ 0.001328f, 0.001535f, 0.001621f, 0.001840f, 0.002022f, 0.002163f, 0.002522f, 0.002825f, 0.003391f, 0.003830f, 0.004616f, 0.005665f,
+ 0.007172f, 0.009247f, 0.012482f, 0.017532f, 0.025970f, 0.040161f, 0.064941f, 0.107422f, 0.178833f, 0.283447f, 0.754883f, 0.764648f,
+ 0.766113f, 0.767090f, 0.767578f, 0.767090f, 0.000000f, 0.000119f, 0.000116f, 0.000114f, 0.000112f, 0.000110f, 0.000109f, 0.000117f,
+ 0.000114f, 0.000117f, 0.000125f, 0.000193f, 0.000141f, 0.000196f, 0.000221f, 0.000235f, 0.000259f, 0.000278f, 0.000308f, 0.000316f,
+ 0.000323f, 0.000315f, 0.000329f, 0.000351f, 0.000388f, 0.000422f, 0.000465f, 0.000512f, 0.000571f, 0.000568f, 0.000588f, 0.000633f,
+ 0.000747f, 0.000751f, 0.000829f, 0.000958f, 0.000914f, 0.001104f, 0.001145f, 0.001255f, 0.001337f, 0.001499f, 0.001701f, 0.001966f,
+ 0.002275f, 0.002609f, 0.003119f, 0.003773f, 0.004658f, 0.005920f, 0.007935f, 0.010948f, 0.015900f, 0.025284f, 0.042511f, 0.075012f,
+ 0.135010f, 0.234619f, 0.733398f, 0.743164f, 0.744629f, 0.745117f, 0.745605f, 0.745605f, 0.000000f, 0.000116f, 0.000113f, 0.000111f,
+ 0.000108f, 0.000106f, 0.000104f, 0.000103f, 0.000098f, 0.000092f, 0.000099f, 0.000085f, 0.000098f, 0.000105f, 0.000163f, 0.000162f,
+ 0.000128f, 0.000193f, 0.000203f, 0.000214f, 0.000284f, 0.000239f, 0.000303f, 0.000268f, 0.000327f, 0.000326f, 0.000329f, 0.000330f,
+ 0.000407f, 0.000486f, 0.000406f, 0.000454f, 0.000465f, 0.000495f, 0.000535f, 0.000592f, 0.000648f, 0.000727f, 0.000753f, 0.000807f,
+ 0.000956f, 0.000992f, 0.001108f, 0.001294f, 0.001418f, 0.001703f, 0.001978f, 0.002390f, 0.002930f, 0.003643f, 0.004753f, 0.006519f,
+ 0.009499f, 0.014824f, 0.025497f, 0.048065f, 0.095154f, 0.185425f, 0.709961f, 0.719727f, 0.721191f, 0.721191f, 0.721680f, 0.721680f,
+ 0.000000f, 0.000113f, 0.000107f, 0.000106f, 0.000102f, 0.000100f, 0.000097f, 0.000096f, 0.000095f, 0.000092f, 0.000087f, 0.000083f,
+ 0.000078f, 0.000098f, 0.000077f, 0.000091f, 0.000114f, 0.000128f, 0.000114f, 0.000147f, 0.000154f, 0.000162f, 0.000186f, 0.000174f,
+ 0.000220f, 0.000233f, 0.000235f, 0.000245f, 0.000250f, 0.000253f, 0.000321f, 0.000296f, 0.000311f, 0.000354f, 0.000417f, 0.000419f,
+ 0.000438f, 0.000443f, 0.000495f, 0.000513f, 0.000585f, 0.000634f, 0.000705f, 0.000778f, 0.000912f, 0.001002f, 0.001163f, 0.001379f,
+ 0.001745f, 0.002092f, 0.002697f, 0.003721f, 0.005230f, 0.008194f, 0.013870f, 0.027359f, 0.061066f, 0.138062f, 0.685547f, 0.694336f,
+ 0.696777f, 0.696289f, 0.697754f, 0.697754f, 0.000000f, 0.000106f, 0.000102f, 0.000097f, 0.000093f, 0.000091f, 0.000089f, 0.000087f,
+ 0.000085f, 0.000084f, 0.000082f, 0.000080f, 0.000076f, 0.000072f, 0.000069f, 0.000074f, 0.000076f, 0.000059f, 0.000075f, 0.000062f,
+ 0.000085f, 0.000091f, 0.000103f, 0.000111f, 0.000121f, 0.000135f, 0.000128f, 0.000159f, 0.000171f, 0.000160f, 0.000178f, 0.000193f,
+ 0.000196f, 0.000202f, 0.000220f, 0.000230f, 0.000273f, 0.000289f, 0.000312f, 0.000330f, 0.000335f, 0.000397f, 0.000408f, 0.000463f,
+ 0.000517f, 0.000577f, 0.000691f, 0.000771f, 0.000919f, 0.001150f, 0.001436f, 0.001955f, 0.002737f, 0.004185f, 0.007103f, 0.013863f,
+ 0.033661f, 0.093628f, 0.657227f, 0.667480f, 0.668945f, 0.669434f, 0.670898f, 0.669922f, 0.000108f, 0.000093f, 0.000087f, 0.000082f,
+ 0.000079f, 0.000078f, 0.000075f, 0.000073f, 0.000071f, 0.000070f, 0.000069f, 0.000069f, 0.000067f, 0.000066f, 0.000064f, 0.000061f,
+ 0.000059f, 0.000056f, 0.000053f, 0.000051f, 0.000053f, 0.000049f, 0.000044f, 0.000047f, 0.000055f, 0.000058f, 0.000071f, 0.000077f,
+ 0.000093f, 0.000094f, 0.000103f, 0.000102f, 0.000110f, 0.000126f, 0.000130f, 0.000138f, 0.000143f, 0.000166f, 0.000166f, 0.000178f,
+ 0.000194f, 0.000217f, 0.000228f, 0.000231f, 0.000265f, 0.000330f, 0.000341f, 0.000411f, 0.000459f, 0.000549f, 0.000705f, 0.000867f,
+ 0.001228f, 0.001863f, 0.003143f, 0.006283f, 0.015594f, 0.054993f, 0.628418f, 0.638184f, 0.640137f, 0.640137f, 0.641602f, 0.641602f,
+ 0.000071f, 0.000058f, 0.000059f, 0.000058f, 0.000054f, 0.000054f, 0.000051f, 0.000053f, 0.000051f, 0.000052f, 0.000050f, 0.000050f,
+ 0.000051f, 0.000050f, 0.000049f, 0.000049f, 0.000049f, 0.000049f, 0.000047f, 0.000045f, 0.000043f, 0.000041f, 0.000039f, 0.000038f,
+ 0.000036f, 0.000034f, 0.000035f, 0.000037f, 0.000033f, 0.000034f, 0.000038f, 0.000047f, 0.000054f, 0.000061f, 0.000064f, 0.000068f,
+ 0.000069f, 0.000076f, 0.000083f, 0.000092f, 0.000098f, 0.000103f, 0.000112f, 0.000129f, 0.000113f, 0.000139f, 0.000152f, 0.000185f,
+ 0.000204f, 0.000238f, 0.000282f, 0.000365f, 0.000503f, 0.000685f, 0.001178f, 0.002274f, 0.006100f, 0.025162f, 0.597656f, 0.607910f,
+ 0.610840f, 0.611816f, 0.610352f, 0.611328f, 0.000000f, 0.000000f, 0.000004f, 0.000012f, 0.000014f, 0.000020f, 0.000022f, 0.000023f,
+ 0.000024f, 0.000022f, 0.000025f, 0.000027f, 0.000027f, 0.000026f, 0.000028f, 0.000029f, 0.000029f, 0.000029f, 0.000030f, 0.000030f,
+ 0.000030f, 0.000030f, 0.000030f, 0.000030f, 0.000029f, 0.000028f, 0.000027f, 0.000026f, 0.000024f, 0.000023f, 0.000022f, 0.000021f,
+ 0.000020f, 0.000019f, 0.000018f, 0.000019f, 0.000023f, 0.000024f, 0.000027f, 0.000032f, 0.000038f, 0.000040f, 0.000041f, 0.000045f,
+ 0.000054f, 0.000052f, 0.000055f, 0.000060f, 0.000068f, 0.000089f, 0.000089f, 0.000115f, 0.000146f, 0.000198f, 0.000318f, 0.000586f,
+ 0.001614f, 0.008278f, 0.565918f, 0.576660f, 0.578125f, 0.579102f, 0.579590f, 0.580078f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000001f,
+ 0.000003f, 0.000003f, 0.000005f, 0.000005f, 0.000006f, 0.000007f, 0.000009f, 0.000009f, 0.000010f, 0.000011f, 0.000012f, 0.000012f,
+ 0.000013f, 0.000014f, 0.000014f, 0.000015f, 0.000014f, 0.000014f, 0.000013f, 0.000012f, 0.000012f, 0.000011f, 0.000011f, 0.000010f,
+ 0.000009f, 0.000009f, 0.000008f, 0.000010f, 0.000013f, 0.000013f, 0.000013f, 0.000017f, 0.000017f, 0.000022f, 0.000021f, 0.000023f,
+ 0.000031f, 0.000032f, 0.000049f, 0.000079f, 0.000204f, 0.001328f, 0.533203f, 0.543945f, 0.545410f, 0.546387f, 0.546875f, 0.546875f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000001f, 0.000002f, 0.000002f, 0.000003f, 0.000003f, 0.000003f,
+ 0.000003f, 0.000003f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000003f, 0.000003f, 0.000004f, 0.000016f, 0.499756f, 0.510254f,
+ 0.513184f, 0.513672f, 0.514160f, 0.514160f,
+ },
+ {
+ 0.076172f, 0.209839f, 0.320312f, 0.408691f, 0.481689f, 0.541016f, 0.591309f, 0.633789f, 0.668945f, 0.699707f, 0.727051f, 0.749512f,
+ 0.770020f, 0.788086f, 0.803711f, 0.817871f, 0.832520f, 0.843750f, 0.854492f, 0.864258f, 0.873535f, 0.881836f, 0.889160f, 0.895996f,
+ 0.903320f, 0.909180f, 0.914551f, 0.920410f, 0.925781f, 0.929199f, 0.933594f, 0.938965f, 0.942383f, 0.946289f, 0.949219f, 0.953125f,
+ 0.955566f, 0.959473f, 0.961914f, 0.964355f, 0.967285f, 0.970215f, 0.971680f, 0.974609f, 0.976562f, 0.978516f, 0.980469f, 0.982422f,
+ 0.984375f, 0.986328f, 0.987793f, 0.989746f, 0.990723f, 0.992676f, 0.993652f, 0.995117f, 0.996582f, 0.998047f, 0.999023f, 0.997559f,
+ 0.996582f, 0.995605f, 0.994629f, 0.993652f, 0.043396f, 0.133301f, 0.221313f, 0.303223f, 0.377441f, 0.442871f, 0.500000f, 0.550781f,
+ 0.595215f, 0.632812f, 0.666992f, 0.696777f, 0.723145f, 0.745605f, 0.765137f, 0.783691f, 0.799805f, 0.815430f, 0.828613f, 0.839844f,
+ 0.851562f, 0.861328f, 0.871582f, 0.879395f, 0.887207f, 0.894531f, 0.901855f, 0.907227f, 0.914062f, 0.919434f, 0.924316f, 0.928711f,
+ 0.933594f, 0.937988f, 0.942383f, 0.945801f, 0.949219f, 0.953125f, 0.956055f, 0.959473f, 0.962402f, 0.964355f, 0.967773f, 0.970215f,
+ 0.972656f, 0.975098f, 0.977051f, 0.979492f, 0.980957f, 0.983398f, 0.985352f, 0.986816f, 0.988281f, 0.990234f, 0.991699f, 0.993652f,
+ 0.995117f, 0.996094f, 0.998047f, 0.997070f, 0.996094f, 0.995117f, 0.994141f, 0.993164f, 0.027832f, 0.088440f, 0.153198f, 0.221313f,
+ 0.288086f, 0.352051f, 0.411621f, 0.466797f, 0.515625f, 0.561523f, 0.601074f, 0.637207f, 0.667969f, 0.695312f, 0.721680f, 0.743652f,
+ 0.763184f, 0.781738f, 0.797852f, 0.812500f, 0.826172f, 0.838867f, 0.850098f, 0.859863f, 0.869141f, 0.877930f, 0.886230f, 0.893555f,
+ 0.900879f, 0.907227f, 0.912598f, 0.918457f, 0.922852f, 0.928711f, 0.934082f, 0.938477f, 0.942383f, 0.946289f, 0.950195f, 0.953125f,
+ 0.956543f, 0.959961f, 0.962402f, 0.965820f, 0.968262f, 0.970703f, 0.973145f, 0.975586f, 0.978027f, 0.979980f, 0.982422f, 0.984375f,
+ 0.985840f, 0.987793f, 0.989746f, 0.991211f, 0.993164f, 0.994141f, 0.997559f, 0.996582f, 0.995605f, 0.994629f, 0.993652f, 0.993164f,
+ 0.018921f, 0.061493f, 0.109497f, 0.161987f, 0.217041f, 0.273438f, 0.330811f, 0.384521f, 0.437500f, 0.486084f, 0.530273f, 0.570312f,
+ 0.607910f, 0.640137f, 0.670410f, 0.697266f, 0.722656f, 0.743652f, 0.763672f, 0.781250f, 0.797363f, 0.812012f, 0.825684f, 0.837891f,
+ 0.848633f, 0.859863f, 0.869141f, 0.878418f, 0.886719f, 0.893066f, 0.900879f, 0.906738f, 0.913574f, 0.919434f, 0.924316f, 0.930176f,
+ 0.934082f, 0.939453f, 0.942871f, 0.946777f, 0.950684f, 0.954590f, 0.958008f, 0.960449f, 0.963379f, 0.966797f, 0.969238f, 0.971680f,
+ 0.974121f, 0.977051f, 0.978516f, 0.980957f, 0.983398f, 0.985352f, 0.987305f, 0.989258f, 0.991211f, 0.992676f, 0.996094f, 0.995605f,
+ 0.994629f, 0.993652f, 0.993164f, 0.992188f, 0.013596f, 0.044495f, 0.080017f, 0.119873f, 0.164307f, 0.211670f, 0.261475f, 0.311523f,
+ 0.362793f, 0.410645f, 0.458008f, 0.501953f, 0.542969f, 0.580078f, 0.614746f, 0.645996f, 0.674805f, 0.701172f, 0.723633f, 0.745117f,
+ 0.765625f, 0.782227f, 0.798828f, 0.812988f, 0.826172f, 0.838867f, 0.849609f, 0.861328f, 0.870605f, 0.878906f, 0.887695f, 0.895020f,
+ 0.901855f, 0.907715f, 0.914551f, 0.920898f, 0.925781f, 0.930664f, 0.934570f, 0.940918f, 0.943848f, 0.947754f, 0.951660f, 0.955566f,
+ 0.958984f, 0.961914f, 0.964844f, 0.967773f, 0.970703f, 0.973145f, 0.975586f, 0.978027f, 0.979980f, 0.982422f, 0.984863f, 0.986328f,
+ 0.988770f, 0.990234f, 0.995117f, 0.995117f, 0.994141f, 0.993652f, 0.992676f, 0.991699f, 0.010414f, 0.033203f, 0.060364f, 0.090942f,
+ 0.125610f, 0.163818f, 0.206421f, 0.250488f, 0.295898f, 0.341797f, 0.388428f, 0.433350f, 0.475830f, 0.517090f, 0.555176f, 0.589844f,
+ 0.622559f, 0.652344f, 0.680176f, 0.704590f, 0.729004f, 0.748535f, 0.767578f, 0.784668f, 0.800293f, 0.814941f, 0.828125f, 0.839844f,
+ 0.852051f, 0.861816f, 0.871582f, 0.879883f, 0.888672f, 0.895996f, 0.903320f, 0.909180f, 0.916016f, 0.921387f, 0.927246f, 0.931641f,
+ 0.937012f, 0.940918f, 0.946289f, 0.950195f, 0.953125f, 0.957520f, 0.960449f, 0.963867f, 0.966309f, 0.969238f, 0.972168f, 0.975098f,
+ 0.976562f, 0.979492f, 0.981934f, 0.983887f, 0.985840f, 0.988281f, 0.994629f, 0.994141f, 0.993652f, 0.992676f, 0.991699f, 0.990723f,
+ 0.007889f, 0.025772f, 0.046539f, 0.070312f, 0.097168f, 0.128540f, 0.162354f, 0.200195f, 0.239868f, 0.281738f, 0.325195f, 0.368896f,
+ 0.411621f, 0.453125f, 0.493652f, 0.531738f, 0.566406f, 0.601074f, 0.631836f, 0.659668f, 0.687988f, 0.709961f, 0.732422f, 0.753418f,
+ 0.770996f, 0.788086f, 0.804199f, 0.818359f, 0.831543f, 0.843750f, 0.854492f, 0.864746f, 0.873535f, 0.882812f, 0.890137f, 0.898438f,
+ 0.905273f, 0.912598f, 0.917969f, 0.923828f, 0.929199f, 0.934570f, 0.938477f, 0.942871f, 0.948242f, 0.951660f, 0.955078f, 0.958496f,
+ 0.961914f, 0.965332f, 0.968262f, 0.971680f, 0.973633f, 0.976562f, 0.979492f, 0.981445f, 0.983398f, 0.985352f, 0.993164f, 0.993164f,
+ 0.992676f, 0.991699f, 0.991211f, 0.990234f, 0.006332f, 0.020325f, 0.036438f, 0.055573f, 0.077026f, 0.101562f, 0.129028f, 0.160278f,
+ 0.194458f, 0.230347f, 0.268555f, 0.309326f, 0.350830f, 0.391846f, 0.432373f, 0.472412f, 0.509277f, 0.545410f, 0.579102f, 0.611816f,
+ 0.640625f, 0.668945f, 0.693848f, 0.716797f, 0.739258f, 0.758789f, 0.775879f, 0.793945f, 0.807617f, 0.821777f, 0.834961f, 0.846680f,
+ 0.857422f, 0.867676f, 0.877441f, 0.885742f, 0.893555f, 0.900391f, 0.908203f, 0.915039f, 0.920898f, 0.926270f, 0.931152f, 0.937012f,
+ 0.940918f, 0.946289f, 0.949219f, 0.954102f, 0.958008f, 0.960938f, 0.964355f, 0.967773f, 0.970703f, 0.973145f, 0.975586f, 0.978516f,
+ 0.981445f, 0.983398f, 0.992188f, 0.992188f, 0.991699f, 0.990723f, 0.990723f, 0.989746f, 0.005226f, 0.016647f, 0.029556f, 0.044434f,
+ 0.061523f, 0.081543f, 0.103760f, 0.129150f, 0.157837f, 0.188477f, 0.221924f, 0.257812f, 0.295654f, 0.334473f, 0.374023f, 0.412842f,
+ 0.451904f, 0.489990f, 0.525391f, 0.560059f, 0.593262f, 0.623047f, 0.651855f, 0.678223f, 0.702148f, 0.725098f, 0.745605f, 0.764160f,
+ 0.781738f, 0.799316f, 0.812500f, 0.827148f, 0.838867f, 0.851074f, 0.861328f, 0.871582f, 0.880371f, 0.889648f, 0.896973f, 0.904297f,
+ 0.911621f, 0.917480f, 0.923340f, 0.929688f, 0.934570f, 0.939941f, 0.943848f, 0.948242f, 0.951660f, 0.957031f, 0.959473f, 0.963379f,
+ 0.966797f, 0.969727f, 0.972656f, 0.976074f, 0.979004f, 0.980957f, 0.991699f, 0.991211f, 0.990723f, 0.990234f, 0.989746f, 0.988770f,
+ 0.004108f, 0.013542f, 0.023819f, 0.036194f, 0.050262f, 0.066223f, 0.084717f, 0.104797f, 0.128174f, 0.153809f, 0.182861f, 0.213989f,
+ 0.247437f, 0.282471f, 0.319580f, 0.357422f, 0.395508f, 0.433350f, 0.470947f, 0.506348f, 0.542480f, 0.575684f, 0.605957f, 0.635254f,
+ 0.662109f, 0.687988f, 0.711426f, 0.732910f, 0.753418f, 0.771973f, 0.789062f, 0.804688f, 0.819336f, 0.831543f, 0.843750f, 0.855469f,
+ 0.866211f, 0.875488f, 0.884766f, 0.893066f, 0.901367f, 0.907715f, 0.914062f, 0.921387f, 0.927246f, 0.932129f, 0.937012f, 0.942383f,
+ 0.946777f, 0.951660f, 0.956055f, 0.959473f, 0.962891f, 0.966309f, 0.969238f, 0.972168f, 0.975098f, 0.978027f, 0.989746f, 0.990234f,
+ 0.990234f, 0.989258f, 0.989258f, 0.988281f, 0.003597f, 0.011330f, 0.020065f, 0.029938f, 0.041412f, 0.054504f, 0.068970f, 0.086182f,
+ 0.105469f, 0.126709f, 0.151123f, 0.177612f, 0.206909f, 0.237915f, 0.271484f, 0.305664f, 0.342529f, 0.378906f, 0.416748f, 0.453125f,
+ 0.489502f, 0.524414f, 0.558105f, 0.589844f, 0.619629f, 0.646973f, 0.673828f, 0.698242f, 0.721191f, 0.742676f, 0.761230f, 0.778809f,
+ 0.796387f, 0.810547f, 0.824707f, 0.837891f, 0.850098f, 0.861328f, 0.871094f, 0.881348f, 0.889648f, 0.896973f, 0.904785f, 0.912109f,
+ 0.919434f, 0.924316f, 0.931152f, 0.936523f, 0.941895f, 0.946289f, 0.951172f, 0.955078f, 0.959473f, 0.962402f, 0.965820f, 0.969238f,
+ 0.972656f, 0.975586f, 0.988770f, 0.989258f, 0.989258f, 0.988770f, 0.987793f, 0.987305f, 0.002836f, 0.009857f, 0.016693f, 0.025208f,
+ 0.034668f, 0.045288f, 0.057617f, 0.071106f, 0.087463f, 0.104858f, 0.125000f, 0.147461f, 0.172119f, 0.199829f, 0.229248f, 0.260742f,
+ 0.294434f, 0.329102f, 0.365479f, 0.400879f, 0.437012f, 0.472656f, 0.508301f, 0.541992f, 0.574219f, 0.604980f, 0.634766f, 0.660645f,
+ 0.686523f, 0.709473f, 0.731445f, 0.751953f, 0.770996f, 0.789062f, 0.804199f, 0.817871f, 0.832520f, 0.844727f, 0.856445f, 0.867188f,
+ 0.876953f, 0.886719f, 0.895020f, 0.902832f, 0.909668f, 0.916504f, 0.923340f, 0.929688f, 0.935547f, 0.939941f, 0.944824f, 0.949707f,
+ 0.954102f, 0.958496f, 0.961914f, 0.965820f, 0.969238f, 0.972656f, 0.987793f, 0.988281f, 0.988281f, 0.987793f, 0.986816f, 0.986328f,
+ 0.002541f, 0.008118f, 0.014244f, 0.021194f, 0.029480f, 0.037811f, 0.048584f, 0.060028f, 0.073242f, 0.088196f, 0.104370f, 0.123047f,
+ 0.144531f, 0.167114f, 0.193237f, 0.220947f, 0.250977f, 0.282227f, 0.316162f, 0.351074f, 0.386719f, 0.422119f, 0.457520f, 0.492432f,
+ 0.526367f, 0.559082f, 0.590332f, 0.621094f, 0.648438f, 0.674316f, 0.698730f, 0.721191f, 0.742188f, 0.762207f, 0.780762f, 0.797363f,
+ 0.812500f, 0.826172f, 0.840332f, 0.852051f, 0.863770f, 0.873535f, 0.883301f, 0.892090f, 0.900391f, 0.908203f, 0.915039f, 0.922363f,
+ 0.928711f, 0.933594f, 0.939453f, 0.944824f, 0.950195f, 0.953125f, 0.958008f, 0.962402f, 0.965332f, 0.969238f, 0.986816f, 0.987305f,
+ 0.986816f, 0.986328f, 0.985840f, 0.984863f, 0.002115f, 0.007030f, 0.012138f, 0.017944f, 0.024521f, 0.032318f, 0.040955f, 0.050476f,
+ 0.061676f, 0.073914f, 0.087769f, 0.103271f, 0.121033f, 0.140747f, 0.162598f, 0.187256f, 0.213379f, 0.242065f, 0.272705f, 0.305176f,
+ 0.338623f, 0.373047f, 0.408691f, 0.443848f, 0.478760f, 0.512695f, 0.545898f, 0.577637f, 0.607910f, 0.636719f, 0.663086f, 0.688965f,
+ 0.712402f, 0.734863f, 0.754395f, 0.774414f, 0.791016f, 0.806641f, 0.822266f, 0.835449f, 0.848145f, 0.859863f, 0.870605f, 0.880371f,
+ 0.890137f, 0.898438f, 0.906250f, 0.914551f, 0.921387f, 0.926758f, 0.933594f, 0.938965f, 0.944336f, 0.949219f, 0.954102f, 0.958984f,
+ 0.961914f, 0.965820f, 0.985840f, 0.986328f, 0.985840f, 0.985352f, 0.985352f, 0.984375f, 0.001999f, 0.006226f, 0.010384f, 0.015594f,
+ 0.021027f, 0.027435f, 0.034637f, 0.042969f, 0.052124f, 0.062469f, 0.074097f, 0.087646f, 0.102173f, 0.119141f, 0.137695f, 0.158203f,
+ 0.181396f, 0.206543f, 0.233643f, 0.263184f, 0.295166f, 0.327148f, 0.360596f, 0.395264f, 0.430420f, 0.464600f, 0.499023f, 0.532227f,
+ 0.564941f, 0.595703f, 0.625000f, 0.651855f, 0.679199f, 0.703613f, 0.726074f, 0.747559f, 0.766602f, 0.784668f, 0.801758f, 0.816895f,
+ 0.831055f, 0.843750f, 0.856934f, 0.867188f, 0.878418f, 0.887207f, 0.896484f, 0.904785f, 0.913086f, 0.919922f, 0.926270f, 0.932617f,
+ 0.938477f, 0.944336f, 0.949707f, 0.953613f, 0.958496f, 0.962891f, 0.983887f, 0.984863f, 0.984863f, 0.984375f, 0.983887f, 0.983398f,
+ 0.001891f, 0.004959f, 0.009300f, 0.013786f, 0.018433f, 0.023560f, 0.029892f, 0.037018f, 0.044586f, 0.053284f, 0.062805f, 0.074341f,
+ 0.086975f, 0.100586f, 0.116760f, 0.133789f, 0.154175f, 0.176025f, 0.200317f, 0.226318f, 0.254395f, 0.284424f, 0.316650f, 0.349365f,
+ 0.383301f, 0.418213f, 0.452393f, 0.487061f, 0.520508f, 0.553223f, 0.584473f, 0.613770f, 0.643066f, 0.668945f, 0.695312f, 0.718262f,
+ 0.740234f, 0.761230f, 0.778809f, 0.797363f, 0.812988f, 0.827148f, 0.840332f, 0.854004f, 0.865723f, 0.875977f, 0.886230f, 0.895020f,
+ 0.904297f, 0.912598f, 0.919922f, 0.926270f, 0.932617f, 0.938965f, 0.943359f, 0.949219f, 0.955078f, 0.958984f, 0.982422f, 0.983887f,
+ 0.983398f, 0.982910f, 0.982910f, 0.981934f, 0.001368f, 0.004715f, 0.008041f, 0.011948f, 0.016235f, 0.020889f, 0.025848f, 0.031921f,
+ 0.038391f, 0.045563f, 0.054108f, 0.063477f, 0.074036f, 0.085815f, 0.099304f, 0.114563f, 0.131104f, 0.150146f, 0.170654f, 0.193970f,
+ 0.219360f, 0.246338f, 0.275146f, 0.306396f, 0.338867f, 0.372559f, 0.406494f, 0.440918f, 0.474609f, 0.508789f, 0.541992f, 0.574219f,
+ 0.604492f, 0.634277f, 0.661133f, 0.687500f, 0.710938f, 0.733887f, 0.754883f, 0.774414f, 0.792480f, 0.809570f, 0.824707f, 0.838379f,
+ 0.852051f, 0.862793f, 0.874023f, 0.885254f, 0.895020f, 0.903320f, 0.912109f, 0.919434f, 0.926758f, 0.932617f, 0.939941f, 0.945312f,
+ 0.951172f, 0.955078f, 0.980957f, 0.982910f, 0.982422f, 0.982422f, 0.981445f, 0.981445f, 0.001393f, 0.004227f, 0.007011f, 0.010323f,
+ 0.014107f, 0.018234f, 0.022766f, 0.027649f, 0.032898f, 0.039581f, 0.046539f, 0.054230f, 0.063293f, 0.073608f, 0.085144f, 0.097961f,
+ 0.112305f, 0.127930f, 0.146362f, 0.166260f, 0.188599f, 0.212524f, 0.238647f, 0.266846f, 0.297363f, 0.328369f, 0.361816f, 0.395752f,
+ 0.429932f, 0.464844f, 0.498535f, 0.531250f, 0.564453f, 0.596191f, 0.625488f, 0.653320f, 0.680176f, 0.704590f, 0.728027f, 0.750977f,
+ 0.770020f, 0.788574f, 0.805176f, 0.821289f, 0.835449f, 0.849609f, 0.862793f, 0.874023f, 0.884277f, 0.894043f, 0.903320f, 0.911621f,
+ 0.919434f, 0.926758f, 0.933594f, 0.939453f, 0.945312f, 0.951172f, 0.979492f, 0.980957f, 0.980957f, 0.980957f, 0.980469f, 0.979980f,
+ 0.001163f, 0.003527f, 0.006229f, 0.009323f, 0.012199f, 0.015808f, 0.019928f, 0.024200f, 0.028870f, 0.033997f, 0.040161f, 0.046967f,
+ 0.054871f, 0.063477f, 0.073181f, 0.083618f, 0.096252f, 0.109863f, 0.125122f, 0.142334f, 0.161743f, 0.182739f, 0.206421f, 0.232300f,
+ 0.259277f, 0.288086f, 0.320068f, 0.352783f, 0.386475f, 0.420410f, 0.454590f, 0.489258f, 0.521973f, 0.555176f, 0.586914f, 0.617188f,
+ 0.646484f, 0.673828f, 0.699707f, 0.723633f, 0.746094f, 0.766113f, 0.785645f, 0.803223f, 0.819336f, 0.834961f, 0.848633f, 0.861328f,
+ 0.873535f, 0.884766f, 0.893555f, 0.903809f, 0.911621f, 0.920410f, 0.928223f, 0.934082f, 0.939941f, 0.946777f, 0.978027f, 0.979492f,
+ 0.979492f, 0.979004f, 0.979004f, 0.978516f, 0.000981f, 0.002987f, 0.005329f, 0.008186f, 0.010895f, 0.013832f, 0.017532f, 0.021149f,
+ 0.025253f, 0.029999f, 0.035034f, 0.040985f, 0.047485f, 0.054993f, 0.063049f, 0.072510f, 0.082581f, 0.094421f, 0.107727f, 0.122498f,
+ 0.138794f, 0.157471f, 0.178467f, 0.200562f, 0.225586f, 0.251953f, 0.281250f, 0.311279f, 0.343750f, 0.377197f, 0.411621f, 0.445557f,
+ 0.479736f, 0.513672f, 0.546875f, 0.579590f, 0.610352f, 0.640625f, 0.668457f, 0.694336f, 0.718750f, 0.742188f, 0.762695f, 0.782715f,
+ 0.801270f, 0.817871f, 0.833496f, 0.847168f, 0.860840f, 0.872559f, 0.884277f, 0.894531f, 0.904297f, 0.912598f, 0.920898f, 0.928711f,
+ 0.935547f, 0.942383f, 0.976074f, 0.978027f, 0.978516f, 0.978027f, 0.977539f, 0.977051f, 0.000880f, 0.002707f, 0.005089f, 0.007305f,
+ 0.010147f, 0.012596f, 0.015160f, 0.018616f, 0.022507f, 0.026230f, 0.030777f, 0.035767f, 0.041351f, 0.047455f, 0.054565f, 0.062256f,
+ 0.071289f, 0.081299f, 0.092346f, 0.105408f, 0.119812f, 0.135620f, 0.153320f, 0.173462f, 0.195068f, 0.219482f, 0.245361f, 0.273682f,
+ 0.303711f, 0.335938f, 0.368896f, 0.402588f, 0.437500f, 0.472168f, 0.505859f, 0.539551f, 0.573242f, 0.604492f, 0.634766f, 0.663086f,
+ 0.689453f, 0.714844f, 0.738770f, 0.760254f, 0.780762f, 0.799316f, 0.817383f, 0.833496f, 0.847168f, 0.860840f, 0.873535f, 0.884766f,
+ 0.895508f, 0.905273f, 0.914062f, 0.922363f, 0.930176f, 0.937012f, 0.974609f, 0.976074f, 0.976074f, 0.976562f, 0.976074f, 0.975586f,
+ 0.000851f, 0.002659f, 0.004692f, 0.006466f, 0.008545f, 0.011055f, 0.013649f, 0.016403f, 0.019714f, 0.023056f, 0.026962f, 0.031235f,
+ 0.035828f, 0.041656f, 0.047699f, 0.054077f, 0.061859f, 0.070496f, 0.080200f, 0.091125f, 0.103088f, 0.116882f, 0.132446f, 0.149780f,
+ 0.168701f, 0.190430f, 0.213379f, 0.239258f, 0.267334f, 0.296631f, 0.328369f, 0.360840f, 0.395020f, 0.429932f, 0.464355f, 0.499512f,
+ 0.533203f, 0.566406f, 0.599121f, 0.629883f, 0.658203f, 0.687012f, 0.712402f, 0.735840f, 0.758789f, 0.779297f, 0.798828f, 0.816406f,
+ 0.832520f, 0.847168f, 0.861328f, 0.874023f, 0.886230f, 0.896973f, 0.907227f, 0.915527f, 0.924805f, 0.931641f, 0.972168f, 0.975586f,
+ 0.975586f, 0.974609f, 0.974121f, 0.973633f, 0.000762f, 0.002214f, 0.004040f, 0.005859f, 0.007790f, 0.009689f, 0.012161f, 0.014786f,
+ 0.017441f, 0.020493f, 0.023956f, 0.027618f, 0.031860f, 0.036255f, 0.041595f, 0.047394f, 0.053894f, 0.061188f, 0.069214f, 0.078735f,
+ 0.089050f, 0.101135f, 0.114441f, 0.129150f, 0.145874f, 0.164673f, 0.185303f, 0.208862f, 0.233765f, 0.260742f, 0.290283f, 0.321045f,
+ 0.354248f, 0.388184f, 0.422607f, 0.457764f, 0.493652f, 0.526855f, 0.561523f, 0.594238f, 0.625977f, 0.655273f, 0.683594f, 0.710449f,
+ 0.734863f, 0.758301f, 0.779297f, 0.798828f, 0.817383f, 0.833984f, 0.848145f, 0.862793f, 0.875488f, 0.887207f, 0.899414f, 0.908691f,
+ 0.917969f, 0.926270f, 0.970215f, 0.972656f, 0.974121f, 0.973145f, 0.972656f, 0.972168f, 0.000732f, 0.001928f, 0.003513f, 0.005234f,
+ 0.007042f, 0.008629f, 0.010620f, 0.012985f, 0.015244f, 0.018158f, 0.020935f, 0.024475f, 0.027908f, 0.032013f, 0.036316f, 0.041290f,
+ 0.046661f, 0.053040f, 0.060089f, 0.068115f, 0.077087f, 0.087463f, 0.099121f, 0.111633f, 0.126221f, 0.142578f, 0.160767f, 0.181396f,
+ 0.203003f, 0.228149f, 0.255127f, 0.284180f, 0.315186f, 0.347900f, 0.381836f, 0.416748f, 0.451904f, 0.487549f, 0.522949f, 0.556641f,
+ 0.590332f, 0.623047f, 0.652832f, 0.682129f, 0.708984f, 0.733887f, 0.757324f, 0.779785f, 0.799316f, 0.818359f, 0.835449f, 0.850586f,
+ 0.865234f, 0.877441f, 0.890137f, 0.901367f, 0.912109f, 0.920410f, 0.968262f, 0.970703f, 0.971191f, 0.970703f, 0.971191f, 0.971191f,
+ 0.000524f, 0.001758f, 0.003185f, 0.004864f, 0.006081f, 0.007820f, 0.009705f, 0.011467f, 0.013634f, 0.016068f, 0.018707f, 0.021378f,
+ 0.024597f, 0.028030f, 0.032135f, 0.036224f, 0.041016f, 0.046692f, 0.052399f, 0.059265f, 0.067505f, 0.076050f, 0.085510f, 0.096558f,
+ 0.109253f, 0.123657f, 0.138794f, 0.157227f, 0.176880f, 0.198730f, 0.223267f, 0.250000f, 0.278809f, 0.309326f, 0.342041f, 0.375977f,
+ 0.410889f, 0.447021f, 0.483154f, 0.518555f, 0.554199f, 0.586914f, 0.620117f, 0.650879f, 0.681641f, 0.708496f, 0.734375f, 0.757324f,
+ 0.780762f, 0.801270f, 0.819336f, 0.837891f, 0.852539f, 0.867188f, 0.880371f, 0.893066f, 0.903809f, 0.914551f, 0.966309f, 0.968750f,
+ 0.969238f, 0.969727f, 0.968750f, 0.968750f, 0.000503f, 0.001896f, 0.002653f, 0.004128f, 0.005627f, 0.007004f, 0.008797f, 0.010361f,
+ 0.012230f, 0.014175f, 0.016647f, 0.019348f, 0.021454f, 0.024872f, 0.028290f, 0.031830f, 0.036163f, 0.040649f, 0.045715f, 0.051941f,
+ 0.058319f, 0.065979f, 0.074402f, 0.083618f, 0.094360f, 0.106812f, 0.120239f, 0.135742f, 0.153320f, 0.172974f, 0.194824f, 0.218506f,
+ 0.245117f, 0.273926f, 0.304688f, 0.336426f, 0.371094f, 0.406982f, 0.442627f, 0.479492f, 0.514648f, 0.550781f, 0.584961f, 0.618652f,
+ 0.650879f, 0.681152f, 0.709473f, 0.735352f, 0.760742f, 0.782715f, 0.803711f, 0.821777f, 0.838867f, 0.855957f, 0.870605f, 0.884277f,
+ 0.895996f, 0.906738f, 0.964355f, 0.966309f, 0.967285f, 0.966797f, 0.966309f, 0.966309f, 0.000636f, 0.001421f, 0.002768f, 0.003761f,
+ 0.004944f, 0.006462f, 0.007889f, 0.009262f, 0.010780f, 0.013000f, 0.014946f, 0.017029f, 0.019516f, 0.022049f, 0.024933f, 0.028091f,
+ 0.031616f, 0.035553f, 0.040161f, 0.045380f, 0.051239f, 0.057281f, 0.064270f, 0.072693f, 0.081970f, 0.092468f, 0.104736f, 0.117859f,
+ 0.132690f, 0.150391f, 0.169189f, 0.190796f, 0.214233f, 0.240601f, 0.268555f, 0.299561f, 0.332520f, 0.367188f, 0.402344f, 0.438965f,
+ 0.476074f, 0.512695f, 0.549805f, 0.584473f, 0.619141f, 0.651367f, 0.681152f, 0.709961f, 0.737305f, 0.762695f, 0.785156f, 0.806641f,
+ 0.826172f, 0.843262f, 0.859375f, 0.874023f, 0.888184f, 0.900391f, 0.961426f, 0.964355f, 0.965332f, 0.964844f, 0.964355f, 0.964844f,
+ 0.000295f, 0.001419f, 0.002342f, 0.003471f, 0.004539f, 0.005821f, 0.006882f, 0.008354f, 0.010155f, 0.011574f, 0.013283f, 0.015129f,
+ 0.017090f, 0.019333f, 0.022125f, 0.024643f, 0.028122f, 0.031586f, 0.035522f, 0.039825f, 0.044586f, 0.050110f, 0.056091f, 0.063354f,
+ 0.071045f, 0.080078f, 0.090637f, 0.102112f, 0.115479f, 0.130127f, 0.147217f, 0.165649f, 0.186768f, 0.210571f, 0.236694f, 0.265137f,
+ 0.295654f, 0.328857f, 0.363770f, 0.399902f, 0.436523f, 0.474365f, 0.511230f, 0.548828f, 0.584961f, 0.619141f, 0.652344f, 0.684082f,
+ 0.712891f, 0.741211f, 0.766113f, 0.789062f, 0.810547f, 0.830078f, 0.848633f, 0.864258f, 0.879395f, 0.892578f, 0.958496f, 0.962402f,
+ 0.962402f, 0.962402f, 0.961914f, 0.962402f, 0.000464f, 0.001313f, 0.002159f, 0.003134f, 0.004463f, 0.005001f, 0.006466f, 0.007595f,
+ 0.008842f, 0.010277f, 0.011971f, 0.013550f, 0.015434f, 0.017242f, 0.019348f, 0.021805f, 0.024734f, 0.027817f, 0.031174f, 0.034821f,
+ 0.039124f, 0.043823f, 0.049164f, 0.055237f, 0.062164f, 0.069336f, 0.078430f, 0.088501f, 0.099976f, 0.112854f, 0.127319f, 0.143555f,
+ 0.162354f, 0.183350f, 0.207031f, 0.233032f, 0.260986f, 0.291992f, 0.325195f, 0.361084f, 0.397217f, 0.435059f, 0.473389f, 0.510742f,
+ 0.549316f, 0.586426f, 0.620605f, 0.654785f, 0.686523f, 0.716797f, 0.744629f, 0.769043f, 0.793945f, 0.815918f, 0.834961f, 0.852539f,
+ 0.869141f, 0.884277f, 0.955078f, 0.959473f, 0.959473f, 0.959473f, 0.959961f, 0.959961f, 0.000541f, 0.001223f, 0.002172f, 0.002886f,
+ 0.003679f, 0.004681f, 0.005512f, 0.006683f, 0.008049f, 0.009346f, 0.010704f, 0.012024f, 0.013626f, 0.015213f, 0.017227f, 0.019516f,
+ 0.022079f, 0.024612f, 0.027313f, 0.030731f, 0.034180f, 0.038239f, 0.042969f, 0.048187f, 0.053864f, 0.060516f, 0.068298f, 0.076843f,
+ 0.086670f, 0.097473f, 0.110107f, 0.124268f, 0.140869f, 0.159302f, 0.180420f, 0.203613f, 0.229614f, 0.258057f, 0.289062f, 0.323486f,
+ 0.358398f, 0.395996f, 0.434082f, 0.472900f, 0.511719f, 0.550293f, 0.587402f, 0.624023f, 0.658203f, 0.690918f, 0.721191f, 0.749512f,
+ 0.774902f, 0.799316f, 0.821289f, 0.840820f, 0.859375f, 0.875488f, 0.952637f, 0.956543f, 0.957520f, 0.957520f, 0.957520f, 0.957031f,
+ 0.000252f, 0.001056f, 0.001923f, 0.002523f, 0.003414f, 0.003960f, 0.005146f, 0.006172f, 0.007130f, 0.008179f, 0.009567f, 0.010735f,
+ 0.012077f, 0.013878f, 0.015640f, 0.017456f, 0.019638f, 0.021622f, 0.024170f, 0.026978f, 0.030121f, 0.033630f, 0.037445f, 0.042053f,
+ 0.047119f, 0.052826f, 0.059174f, 0.066711f, 0.075012f, 0.084473f, 0.095276f, 0.107727f, 0.122070f, 0.138184f, 0.156250f, 0.177246f,
+ 0.200928f, 0.226929f, 0.255371f, 0.286865f, 0.321289f, 0.356934f, 0.395264f, 0.434326f, 0.473877f, 0.514160f, 0.553711f, 0.591797f,
+ 0.628418f, 0.663574f, 0.696777f, 0.728027f, 0.755859f, 0.782715f, 0.806152f, 0.829102f, 0.847656f, 0.867188f, 0.949707f, 0.954102f,
+ 0.954590f, 0.954590f, 0.954102f, 0.954590f, 0.000365f, 0.000963f, 0.001581f, 0.002337f, 0.002996f, 0.003952f, 0.004608f, 0.005459f,
+ 0.006489f, 0.007351f, 0.008484f, 0.009544f, 0.011108f, 0.012413f, 0.013901f, 0.015388f, 0.017181f, 0.019012f, 0.021439f, 0.023727f,
+ 0.026520f, 0.029449f, 0.032898f, 0.036835f, 0.041046f, 0.045868f, 0.051575f, 0.058075f, 0.064758f, 0.073120f, 0.082520f, 0.093079f,
+ 0.105652f, 0.119385f, 0.135620f, 0.153687f, 0.174683f, 0.198364f, 0.224365f, 0.253662f, 0.285400f, 0.320557f, 0.357178f, 0.395752f,
+ 0.435791f, 0.476318f, 0.516602f, 0.557129f, 0.596191f, 0.633789f, 0.669434f, 0.703613f, 0.734375f, 0.763672f, 0.790039f, 0.812988f,
+ 0.836914f, 0.855957f, 0.946289f, 0.949707f, 0.951172f, 0.951172f, 0.951172f, 0.951172f, 0.000404f, 0.001028f, 0.001410f, 0.002098f,
+ 0.002657f, 0.003445f, 0.004391f, 0.005039f, 0.005665f, 0.006569f, 0.007549f, 0.008614f, 0.009743f, 0.011108f, 0.012390f, 0.013611f,
+ 0.015396f, 0.017044f, 0.018921f, 0.020874f, 0.023453f, 0.025833f, 0.028809f, 0.032501f, 0.036011f, 0.040161f, 0.044952f, 0.050018f,
+ 0.056091f, 0.063477f, 0.071533f, 0.080200f, 0.091064f, 0.103027f, 0.117065f, 0.133057f, 0.151489f, 0.171997f, 0.196045f, 0.222290f,
+ 0.251709f, 0.284424f, 0.319824f, 0.357422f, 0.397217f, 0.438232f, 0.479492f, 0.521484f, 0.562500f, 0.602051f, 0.641113f, 0.677734f,
+ 0.711914f, 0.743164f, 0.772461f, 0.799316f, 0.822754f, 0.845215f, 0.942383f, 0.946777f, 0.947754f, 0.947754f, 0.948242f, 0.948242f,
+ 0.000406f, 0.000992f, 0.001447f, 0.001986f, 0.002499f, 0.003149f, 0.003769f, 0.004272f, 0.005016f, 0.005981f, 0.006924f, 0.007675f,
+ 0.008766f, 0.009727f, 0.010765f, 0.011986f, 0.013588f, 0.014915f, 0.016724f, 0.018478f, 0.020508f, 0.022873f, 0.025497f, 0.028336f,
+ 0.031525f, 0.034882f, 0.038818f, 0.043243f, 0.048615f, 0.054626f, 0.061707f, 0.069214f, 0.078430f, 0.089111f, 0.101013f, 0.115112f,
+ 0.130859f, 0.148926f, 0.170166f, 0.193604f, 0.220947f, 0.250732f, 0.283936f, 0.320068f, 0.358887f, 0.400391f, 0.442139f, 0.483887f,
+ 0.527344f, 0.569824f, 0.610352f, 0.649414f, 0.686523f, 0.722168f, 0.753906f, 0.782227f, 0.809570f, 0.833496f, 0.938477f, 0.942871f,
+ 0.944824f, 0.944336f, 0.943848f, 0.943848f, 0.000235f, 0.000984f, 0.001204f, 0.001706f, 0.002239f, 0.002998f, 0.003462f, 0.004093f,
+ 0.004372f, 0.005371f, 0.006149f, 0.006962f, 0.007736f, 0.008766f, 0.009804f, 0.010780f, 0.011887f, 0.013336f, 0.014618f, 0.016159f,
+ 0.018158f, 0.020050f, 0.022232f, 0.024597f, 0.027313f, 0.030334f, 0.033752f, 0.037872f, 0.042389f, 0.047516f, 0.053192f, 0.059937f,
+ 0.067749f, 0.076599f, 0.086975f, 0.098755f, 0.112610f, 0.128662f, 0.146973f, 0.168091f, 0.192383f, 0.220215f, 0.250732f, 0.284668f,
+ 0.322021f, 0.361572f, 0.403564f, 0.446777f, 0.490723f, 0.534668f, 0.577637f, 0.619629f, 0.660156f, 0.697754f, 0.731934f, 0.764648f,
+ 0.794922f, 0.820312f, 0.934082f, 0.939453f, 0.939941f, 0.941406f, 0.940430f, 0.940918f, 0.000237f, 0.000591f, 0.001098f, 0.001619f,
+ 0.002241f, 0.002636f, 0.003176f, 0.003521f, 0.004101f, 0.004631f, 0.005398f, 0.006378f, 0.007000f, 0.007767f, 0.008713f, 0.009758f,
+ 0.010475f, 0.011734f, 0.013016f, 0.014404f, 0.015762f, 0.017517f, 0.019440f, 0.021469f, 0.023651f, 0.026199f, 0.029495f, 0.033112f,
+ 0.036499f, 0.040955f, 0.045959f, 0.051849f, 0.058197f, 0.065552f, 0.074585f, 0.085022f, 0.096680f, 0.110535f, 0.126709f, 0.145264f,
+ 0.166626f, 0.191406f, 0.219482f, 0.250488f, 0.286133f, 0.323975f, 0.365723f, 0.408447f, 0.453125f, 0.498779f, 0.542969f, 0.588379f,
+ 0.631836f, 0.671387f, 0.709473f, 0.745117f, 0.777344f, 0.807617f, 0.930176f, 0.935059f, 0.936523f, 0.936523f, 0.936523f, 0.936035f,
+ 0.000242f, 0.000761f, 0.000943f, 0.001624f, 0.001858f, 0.002390f, 0.002638f, 0.003054f, 0.003805f, 0.004559f, 0.005035f, 0.005493f,
+ 0.006157f, 0.006878f, 0.007687f, 0.008530f, 0.009178f, 0.010406f, 0.011406f, 0.012520f, 0.014053f, 0.015579f, 0.017105f, 0.018661f,
+ 0.020737f, 0.022903f, 0.025650f, 0.028259f, 0.031433f, 0.035065f, 0.039581f, 0.044342f, 0.049988f, 0.056366f, 0.064026f, 0.072632f,
+ 0.082825f, 0.094666f, 0.108582f, 0.124634f, 0.143799f, 0.165405f, 0.190796f, 0.219360f, 0.251953f, 0.287842f, 0.328125f, 0.370605f,
+ 0.415283f, 0.461670f, 0.507812f, 0.555176f, 0.600586f, 0.645020f, 0.685547f, 0.724121f, 0.759277f, 0.792969f, 0.924805f, 0.931152f,
+ 0.931641f, 0.932129f, 0.932129f, 0.931641f, 0.000240f, 0.000685f, 0.000955f, 0.001395f, 0.001768f, 0.002157f, 0.002533f, 0.002970f,
+ 0.003223f, 0.003813f, 0.004601f, 0.004993f, 0.005428f, 0.005981f, 0.006878f, 0.007484f, 0.008110f, 0.009132f, 0.009964f, 0.011208f,
+ 0.012138f, 0.013374f, 0.015099f, 0.016190f, 0.018112f, 0.020187f, 0.022202f, 0.024780f, 0.027573f, 0.030411f, 0.034119f, 0.037964f,
+ 0.042755f, 0.048553f, 0.054474f, 0.061890f, 0.070984f, 0.080688f, 0.092590f, 0.106812f, 0.123291f, 0.142456f, 0.164551f, 0.190430f,
+ 0.220459f, 0.253418f, 0.291504f, 0.332520f, 0.376709f, 0.423340f, 0.471436f, 0.520508f, 0.567383f, 0.614746f, 0.660156f, 0.702148f,
+ 0.741211f, 0.776367f, 0.920410f, 0.925293f, 0.926270f, 0.926758f, 0.927246f, 0.926758f, 0.000244f, 0.000431f, 0.000799f, 0.001309f,
+ 0.001587f, 0.001945f, 0.002317f, 0.002514f, 0.003290f, 0.003548f, 0.004082f, 0.004349f, 0.004707f, 0.005348f, 0.006027f, 0.006565f,
+ 0.007141f, 0.008011f, 0.008850f, 0.009552f, 0.010757f, 0.011650f, 0.012794f, 0.014145f, 0.015778f, 0.017303f, 0.019028f, 0.021088f,
+ 0.023575f, 0.026169f, 0.029175f, 0.032562f, 0.036713f, 0.041382f, 0.046448f, 0.052948f, 0.060303f, 0.068787f, 0.079041f, 0.090942f,
+ 0.105103f, 0.121643f, 0.141113f, 0.164185f, 0.190308f, 0.221191f, 0.256836f, 0.295898f, 0.339355f, 0.385010f, 0.433838f, 0.484619f,
+ 0.534668f, 0.583496f, 0.631348f, 0.678223f, 0.719727f, 0.759766f, 0.913574f, 0.920410f, 0.921387f, 0.921875f, 0.921875f, 0.921387f,
+ 0.000243f, 0.000496f, 0.000847f, 0.001157f, 0.001426f, 0.001634f, 0.002020f, 0.002338f, 0.002607f, 0.003035f, 0.003502f, 0.003872f,
+ 0.004459f, 0.004726f, 0.005402f, 0.005779f, 0.006325f, 0.007095f, 0.007767f, 0.008568f, 0.009331f, 0.010086f, 0.011009f, 0.012314f,
+ 0.013611f, 0.015060f, 0.016312f, 0.018158f, 0.020401f, 0.022476f, 0.024979f, 0.027863f, 0.031036f, 0.034943f, 0.039581f, 0.044830f,
+ 0.050903f, 0.058289f, 0.066895f, 0.076782f, 0.088989f, 0.103210f, 0.120422f, 0.140259f, 0.164185f, 0.191772f, 0.223877f, 0.260742f,
+ 0.301758f, 0.347168f, 0.395508f, 0.446533f, 0.497803f, 0.551270f, 0.601562f, 0.651855f, 0.697754f, 0.741211f, 0.908203f, 0.915039f,
+ 0.916016f, 0.916016f, 0.916504f, 0.915527f, 0.000239f, 0.000345f, 0.000690f, 0.000913f, 0.001250f, 0.001343f, 0.001579f, 0.002050f,
+ 0.002331f, 0.002861f, 0.003048f, 0.003616f, 0.003696f, 0.004211f, 0.004723f, 0.005074f, 0.005657f, 0.006100f, 0.006893f, 0.007290f,
+ 0.008118f, 0.008659f, 0.009552f, 0.010704f, 0.011681f, 0.012764f, 0.014114f, 0.015533f, 0.017227f, 0.018982f, 0.021286f, 0.023560f,
+ 0.026489f, 0.029861f, 0.033417f, 0.037933f, 0.043121f, 0.049286f, 0.056519f, 0.065002f, 0.075073f, 0.087158f, 0.101624f, 0.118835f,
+ 0.139648f, 0.164185f, 0.193481f, 0.226929f, 0.265625f, 0.309570f, 0.356934f, 0.408203f, 0.461426f, 0.516113f, 0.569824f, 0.623047f,
+ 0.674316f, 0.720703f, 0.902344f, 0.908203f, 0.909668f, 0.910645f, 0.910645f, 0.911133f, 0.000000f, 0.000281f, 0.000560f, 0.000977f,
+ 0.001063f, 0.001171f, 0.001569f, 0.001903f, 0.002075f, 0.002413f, 0.002695f, 0.003004f, 0.003399f, 0.003553f, 0.003998f, 0.004333f,
+ 0.004971f, 0.005314f, 0.005806f, 0.006340f, 0.007015f, 0.007492f, 0.008377f, 0.009186f, 0.010094f, 0.010910f, 0.012199f, 0.013351f,
+ 0.014618f, 0.016266f, 0.018082f, 0.019852f, 0.022491f, 0.025085f, 0.028168f, 0.031799f, 0.036041f, 0.041107f, 0.047394f, 0.054321f,
+ 0.062866f, 0.073181f, 0.085327f, 0.100525f, 0.118408f, 0.139648f, 0.165527f, 0.196411f, 0.231812f, 0.273193f, 0.318848f, 0.369629f,
+ 0.423828f, 0.480225f, 0.536621f, 0.592773f, 0.647949f, 0.699707f, 0.894043f, 0.900879f, 0.903809f, 0.903320f, 0.903320f, 0.902832f,
+ 0.000232f, 0.000227f, 0.000555f, 0.000656f, 0.000937f, 0.000985f, 0.001351f, 0.001723f, 0.001925f, 0.002010f, 0.002445f, 0.002625f,
+ 0.002760f, 0.003220f, 0.003551f, 0.003870f, 0.004303f, 0.004826f, 0.005028f, 0.005451f, 0.005985f, 0.006523f, 0.007000f, 0.007744f,
+ 0.008499f, 0.009361f, 0.010109f, 0.011185f, 0.012413f, 0.013603f, 0.015121f, 0.016891f, 0.018753f, 0.020920f, 0.023407f, 0.026764f,
+ 0.030197f, 0.034302f, 0.039429f, 0.044891f, 0.052368f, 0.060822f, 0.071167f, 0.083557f, 0.098877f, 0.117493f, 0.139893f, 0.167725f,
+ 0.200195f, 0.238037f, 0.281982f, 0.331543f, 0.385010f, 0.442627f, 0.501465f, 0.561523f, 0.620605f, 0.675781f, 0.887207f, 0.894531f,
+ 0.895020f, 0.896484f, 0.896484f, 0.895996f, 0.000000f, 0.000332f, 0.000577f, 0.000723f, 0.000720f, 0.001210f, 0.001469f, 0.001456f,
+ 0.001546f, 0.001775f, 0.002159f, 0.002291f, 0.002659f, 0.002916f, 0.003046f, 0.003439f, 0.003752f, 0.003883f, 0.004375f, 0.004635f,
+ 0.005241f, 0.005638f, 0.006054f, 0.006630f, 0.007191f, 0.007744f, 0.008545f, 0.009178f, 0.010498f, 0.011536f, 0.012802f, 0.013931f,
+ 0.015808f, 0.017548f, 0.019379f, 0.022110f, 0.025040f, 0.028473f, 0.032471f, 0.037323f, 0.043152f, 0.050476f, 0.058807f, 0.069214f,
+ 0.082520f, 0.098145f, 0.116821f, 0.141602f, 0.170044f, 0.204834f, 0.245728f, 0.293213f, 0.346436f, 0.403564f, 0.464111f, 0.527832f,
+ 0.589844f, 0.650879f, 0.878418f, 0.886719f, 0.888184f, 0.887695f, 0.888672f, 0.888672f, 0.000243f, 0.000307f, 0.000526f, 0.000561f,
+ 0.000923f, 0.000980f, 0.001143f, 0.001386f, 0.001414f, 0.001683f, 0.001735f, 0.001972f, 0.002232f, 0.002481f, 0.002657f, 0.002754f,
+ 0.003193f, 0.003359f, 0.003603f, 0.003956f, 0.004368f, 0.004692f, 0.005119f, 0.005596f, 0.005955f, 0.006634f, 0.007256f, 0.007881f,
+ 0.008652f, 0.009552f, 0.010376f, 0.011719f, 0.012634f, 0.014595f, 0.016113f, 0.018219f, 0.020554f, 0.023254f, 0.026520f, 0.030502f,
+ 0.035553f, 0.041168f, 0.048065f, 0.057190f, 0.067261f, 0.080811f, 0.097107f, 0.117737f, 0.143066f, 0.173950f, 0.211182f, 0.256592f,
+ 0.307129f, 0.364502f, 0.427002f, 0.491943f, 0.557617f, 0.624023f, 0.869629f, 0.877930f, 0.879883f, 0.879883f, 0.879883f, 0.880371f,
+ 0.000000f, 0.000270f, 0.000342f, 0.000509f, 0.000668f, 0.000989f, 0.000945f, 0.001105f, 0.001230f, 0.001335f, 0.001492f, 0.001757f,
+ 0.001917f, 0.002140f, 0.002386f, 0.002501f, 0.002644f, 0.002884f, 0.003199f, 0.003441f, 0.003620f, 0.003891f, 0.004337f, 0.004631f,
+ 0.005119f, 0.005520f, 0.006100f, 0.006504f, 0.007301f, 0.007771f, 0.008751f, 0.009521f, 0.010658f, 0.011765f, 0.013145f, 0.014641f,
+ 0.016785f, 0.018829f, 0.021545f, 0.024719f, 0.028381f, 0.033203f, 0.038849f, 0.046112f, 0.055084f, 0.065552f, 0.079529f, 0.096985f,
+ 0.118530f, 0.145630f, 0.179321f, 0.220337f, 0.269287f, 0.325439f, 0.387207f, 0.454102f, 0.524414f, 0.595215f, 0.859863f, 0.868652f,
+ 0.870605f, 0.869629f, 0.870117f, 0.870605f, 0.000000f, 0.000230f, 0.000334f, 0.000416f, 0.000700f, 0.000726f, 0.000921f, 0.001008f,
+ 0.001065f, 0.001186f, 0.001365f, 0.001471f, 0.001627f, 0.001796f, 0.001843f, 0.002069f, 0.002266f, 0.002438f, 0.002596f, 0.002831f,
+ 0.003000f, 0.003298f, 0.003597f, 0.003887f, 0.004265f, 0.004581f, 0.004986f, 0.005505f, 0.005947f, 0.006454f, 0.007069f, 0.007801f,
+ 0.008621f, 0.009575f, 0.010612f, 0.011848f, 0.013321f, 0.015259f, 0.017410f, 0.019775f, 0.022934f, 0.026550f, 0.031464f, 0.036713f,
+ 0.043945f, 0.052887f, 0.064209f, 0.078735f, 0.096924f, 0.120361f, 0.149536f, 0.186768f, 0.232422f, 0.285889f, 0.347656f, 0.415527f,
+ 0.488281f, 0.563965f, 0.849121f, 0.857910f, 0.859375f, 0.860840f, 0.860840f, 0.860352f, 0.000233f, 0.000225f, 0.000219f, 0.000431f,
+ 0.000579f, 0.000648f, 0.000671f, 0.000744f, 0.000946f, 0.000994f, 0.001091f, 0.001307f, 0.001364f, 0.001490f, 0.001561f, 0.001712f,
+ 0.001892f, 0.001999f, 0.002190f, 0.002369f, 0.002512f, 0.002733f, 0.003014f, 0.003145f, 0.003553f, 0.003822f, 0.004135f, 0.004326f,
+ 0.004799f, 0.005344f, 0.005718f, 0.006378f, 0.007008f, 0.007721f, 0.008400f, 0.009537f, 0.010597f, 0.011917f, 0.013542f, 0.015579f,
+ 0.018051f, 0.020889f, 0.024765f, 0.029236f, 0.034668f, 0.041779f, 0.051056f, 0.062439f, 0.077576f, 0.097595f, 0.122864f, 0.155273f,
+ 0.196655f, 0.247437f, 0.307617f, 0.375977f, 0.450684f, 0.531250f, 0.837891f, 0.847168f, 0.848633f, 0.849609f, 0.849121f, 0.849609f,
+ 0.000202f, 0.000180f, 0.000206f, 0.000339f, 0.000479f, 0.000536f, 0.000687f, 0.000739f, 0.000771f, 0.000849f, 0.001051f, 0.001060f,
+ 0.001154f, 0.001219f, 0.001389f, 0.001505f, 0.001469f, 0.001729f, 0.001858f, 0.001980f, 0.002209f, 0.002243f, 0.002483f, 0.002695f,
+ 0.002951f, 0.003149f, 0.003374f, 0.003654f, 0.004002f, 0.004154f, 0.004539f, 0.005032f, 0.005428f, 0.005989f, 0.006760f, 0.007549f,
+ 0.008423f, 0.009499f, 0.010620f, 0.012016f, 0.013992f, 0.016434f, 0.019135f, 0.022583f, 0.026840f, 0.032501f, 0.039551f, 0.048828f,
+ 0.061066f, 0.077393f, 0.098755f, 0.127075f, 0.163208f, 0.209717f, 0.267578f, 0.334961f, 0.411133f, 0.494629f, 0.825684f, 0.834473f,
+ 0.836426f, 0.837402f, 0.837402f, 0.837402f, 0.000000f, 0.000185f, 0.000184f, 0.000404f, 0.000408f, 0.000454f, 0.000480f, 0.000506f,
+ 0.000660f, 0.000694f, 0.000742f, 0.000801f, 0.000989f, 0.001111f, 0.001167f, 0.001250f, 0.001311f, 0.001424f, 0.001541f, 0.001574f,
+ 0.001712f, 0.001930f, 0.001982f, 0.002201f, 0.002375f, 0.002439f, 0.002792f, 0.002905f, 0.003065f, 0.003412f, 0.003653f, 0.003952f,
+ 0.004463f, 0.004723f, 0.005230f, 0.005936f, 0.006386f, 0.007092f, 0.008240f, 0.009247f, 0.010765f, 0.012344f, 0.014420f, 0.017090f,
+ 0.020493f, 0.024551f, 0.030014f, 0.037689f, 0.047302f, 0.060028f, 0.077820f, 0.100830f, 0.132812f, 0.174561f, 0.228516f, 0.294434f,
+ 0.371582f, 0.457031f, 0.812012f, 0.820801f, 0.823730f, 0.824219f, 0.824707f, 0.824219f, 0.000000f, 0.000053f, 0.000206f, 0.000360f,
+ 0.000379f, 0.000391f, 0.000379f, 0.000478f, 0.000549f, 0.000589f, 0.000626f, 0.000674f, 0.000762f, 0.000832f, 0.000894f, 0.001050f,
+ 0.001111f, 0.001155f, 0.001286f, 0.001345f, 0.001449f, 0.001564f, 0.001666f, 0.001750f, 0.001856f, 0.001925f, 0.002056f, 0.002359f,
+ 0.002542f, 0.002728f, 0.003042f, 0.003164f, 0.003460f, 0.003786f, 0.004116f, 0.004578f, 0.005116f, 0.005688f, 0.006508f, 0.007229f,
+ 0.008125f, 0.009232f, 0.010796f, 0.012741f, 0.015137f, 0.018158f, 0.022186f, 0.028030f, 0.035248f, 0.045593f, 0.059052f, 0.078308f,
+ 0.105042f, 0.141602f, 0.190308f, 0.252930f, 0.329102f, 0.417969f, 0.797852f, 0.807129f, 0.810059f, 0.810547f, 0.811035f, 0.810547f,
+ 0.000000f, 0.000000f, 0.000082f, 0.000195f, 0.000309f, 0.000336f, 0.000324f, 0.000414f, 0.000439f, 0.000460f, 0.000599f, 0.000643f,
+ 0.000637f, 0.000690f, 0.000733f, 0.000834f, 0.000821f, 0.000922f, 0.000989f, 0.001067f, 0.001207f, 0.001293f, 0.001327f, 0.001476f,
+ 0.001581f, 0.001663f, 0.001725f, 0.001906f, 0.001934f, 0.002180f, 0.002258f, 0.002602f, 0.002701f, 0.003019f, 0.003229f, 0.003502f,
+ 0.003847f, 0.004261f, 0.004795f, 0.005318f, 0.006130f, 0.007008f, 0.008118f, 0.009277f, 0.011024f, 0.013229f, 0.016205f, 0.020203f,
+ 0.025620f, 0.033020f, 0.043854f, 0.059021f, 0.080383f, 0.111206f, 0.154419f, 0.212646f, 0.287354f, 0.378418f, 0.781250f, 0.792480f,
+ 0.793457f, 0.795410f, 0.795898f, 0.794922f, 0.000000f, 0.000121f, 0.000120f, 0.000198f, 0.000275f, 0.000249f, 0.000290f, 0.000360f,
+ 0.000375f, 0.000379f, 0.000391f, 0.000438f, 0.000505f, 0.000534f, 0.000669f, 0.000629f, 0.000659f, 0.000754f, 0.000890f, 0.000833f,
+ 0.000849f, 0.000975f, 0.001029f, 0.001117f, 0.001193f, 0.001203f, 0.001269f, 0.001424f, 0.001594f, 0.001675f, 0.001737f, 0.001957f,
+ 0.002094f, 0.002319f, 0.002342f, 0.002609f, 0.002928f, 0.003248f, 0.003523f, 0.003967f, 0.004547f, 0.005138f, 0.005871f, 0.006760f,
+ 0.007912f, 0.009430f, 0.011528f, 0.014236f, 0.017899f, 0.023346f, 0.031235f, 0.042694f, 0.059235f, 0.084229f, 0.120972f, 0.173950f,
+ 0.245239f, 0.334473f, 0.764160f, 0.775391f, 0.777344f, 0.778809f, 0.777832f, 0.778809f, 0.000000f, 0.000121f, 0.000119f, 0.000182f,
+ 0.000177f, 0.000179f, 0.000262f, 0.000239f, 0.000309f, 0.000322f, 0.000404f, 0.000370f, 0.000361f, 0.000430f, 0.000458f, 0.000540f,
+ 0.000589f, 0.000615f, 0.000648f, 0.000632f, 0.000777f, 0.000782f, 0.000798f, 0.000871f, 0.000857f, 0.000925f, 0.001000f, 0.001045f,
+ 0.001191f, 0.001223f, 0.001426f, 0.001419f, 0.001512f, 0.001635f, 0.001884f, 0.002092f, 0.002100f, 0.002293f, 0.002577f, 0.003012f,
+ 0.003258f, 0.003761f, 0.004253f, 0.004814f, 0.005619f, 0.006676f, 0.008064f, 0.009750f, 0.012268f, 0.015854f, 0.021255f, 0.029282f,
+ 0.041687f, 0.061005f, 0.091370f, 0.136230f, 0.202759f, 0.291504f, 0.746582f, 0.757324f, 0.759277f, 0.760254f, 0.760254f, 0.760254f,
+ 0.000000f, 0.000000f, 0.000117f, 0.000126f, 0.000113f, 0.000146f, 0.000158f, 0.000155f, 0.000189f, 0.000288f, 0.000254f, 0.000336f,
+ 0.000347f, 0.000353f, 0.000370f, 0.000355f, 0.000390f, 0.000417f, 0.000456f, 0.000480f, 0.000525f, 0.000587f, 0.000596f, 0.000620f,
+ 0.000676f, 0.000740f, 0.000758f, 0.000852f, 0.000907f, 0.000947f, 0.001057f, 0.001122f, 0.001170f, 0.001293f, 0.001316f, 0.001437f,
+ 0.001531f, 0.001813f, 0.001952f, 0.002090f, 0.002346f, 0.002560f, 0.002974f, 0.003334f, 0.003899f, 0.004547f, 0.005360f, 0.006516f,
+ 0.008179f, 0.010468f, 0.013947f, 0.019241f, 0.027832f, 0.041443f, 0.064941f, 0.102600f, 0.162231f, 0.247437f, 0.726074f, 0.737793f,
+ 0.739258f, 0.740723f, 0.741211f, 0.741211f, 0.000000f, 0.000118f, 0.000115f, 0.000113f, 0.000110f, 0.000126f, 0.000121f, 0.000139f,
+ 0.000147f, 0.000160f, 0.000161f, 0.000233f, 0.000199f, 0.000266f, 0.000286f, 0.000297f, 0.000329f, 0.000313f, 0.000347f, 0.000358f,
+ 0.000364f, 0.000394f, 0.000435f, 0.000446f, 0.000489f, 0.000506f, 0.000546f, 0.000625f, 0.000648f, 0.000674f, 0.000723f, 0.000782f,
+ 0.000865f, 0.000918f, 0.000979f, 0.001104f, 0.001100f, 0.001196f, 0.001352f, 0.001488f, 0.001586f, 0.001749f, 0.001955f, 0.002275f,
+ 0.002644f, 0.003054f, 0.003563f, 0.004322f, 0.005314f, 0.006786f, 0.008980f, 0.012115f, 0.017319f, 0.026520f, 0.043121f, 0.072693f,
+ 0.123535f, 0.203613f, 0.705566f, 0.716797f, 0.719238f, 0.719727f, 0.720703f, 0.721191f, 0.000000f, 0.000000f, 0.000112f, 0.000109f,
+ 0.000106f, 0.000104f, 0.000102f, 0.000096f, 0.000091f, 0.000113f, 0.000147f, 0.000129f, 0.000155f, 0.000134f, 0.000196f, 0.000205f,
+ 0.000181f, 0.000239f, 0.000297f, 0.000255f, 0.000317f, 0.000273f, 0.000335f, 0.000299f, 0.000379f, 0.000385f, 0.000398f, 0.000402f,
+ 0.000473f, 0.000552f, 0.000489f, 0.000543f, 0.000557f, 0.000606f, 0.000662f, 0.000698f, 0.000747f, 0.000810f, 0.000902f, 0.000961f,
+ 0.001063f, 0.001166f, 0.001312f, 0.001523f, 0.001662f, 0.001908f, 0.002298f, 0.002758f, 0.003365f, 0.004135f, 0.005394f, 0.007290f,
+ 0.010490f, 0.015991f, 0.026215f, 0.047180f, 0.087646f, 0.160645f, 0.682617f, 0.695801f, 0.697266f, 0.697266f, 0.697266f, 0.698730f,
+ 0.000000f, 0.000112f, 0.000106f, 0.000104f, 0.000100f, 0.000098f, 0.000095f, 0.000094f, 0.000090f, 0.000085f, 0.000080f, 0.000081f,
+ 0.000085f, 0.000123f, 0.000123f, 0.000138f, 0.000151f, 0.000158f, 0.000147f, 0.000171f, 0.000183f, 0.000192f, 0.000242f, 0.000215f,
+ 0.000253f, 0.000256f, 0.000269f, 0.000278f, 0.000293f, 0.000315f, 0.000377f, 0.000357f, 0.000357f, 0.000423f, 0.000479f, 0.000493f,
+ 0.000489f, 0.000535f, 0.000579f, 0.000628f, 0.000683f, 0.000731f, 0.000833f, 0.000935f, 0.001068f, 0.001200f, 0.001347f, 0.001581f,
+ 0.001995f, 0.002419f, 0.003109f, 0.004147f, 0.005829f, 0.008919f, 0.014641f, 0.027405f, 0.056885f, 0.119385f, 0.658691f, 0.669922f,
+ 0.673828f, 0.673828f, 0.675293f, 0.675293f, 0.000000f, 0.000105f, 0.000101f, 0.000096f, 0.000092f, 0.000089f, 0.000087f, 0.000085f,
+ 0.000083f, 0.000081f, 0.000077f, 0.000073f, 0.000070f, 0.000066f, 0.000080f, 0.000084f, 0.000089f, 0.000068f, 0.000101f, 0.000094f,
+ 0.000116f, 0.000118f, 0.000125f, 0.000129f, 0.000150f, 0.000168f, 0.000153f, 0.000192f, 0.000195f, 0.000185f, 0.000200f, 0.000217f,
+ 0.000226f, 0.000247f, 0.000257f, 0.000262f, 0.000319f, 0.000334f, 0.000347f, 0.000376f, 0.000395f, 0.000447f, 0.000504f, 0.000544f,
+ 0.000590f, 0.000670f, 0.000789f, 0.000887f, 0.001069f, 0.001345f, 0.001670f, 0.002167f, 0.003065f, 0.004562f, 0.007660f, 0.014290f,
+ 0.032135f, 0.081299f, 0.632812f, 0.645996f, 0.648926f, 0.649414f, 0.648926f, 0.649902f, 0.000109f, 0.000094f, 0.000087f, 0.000082f,
+ 0.000078f, 0.000076f, 0.000074f, 0.000071f, 0.000069f, 0.000068f, 0.000067f, 0.000066f, 0.000064f, 0.000061f, 0.000058f, 0.000055f,
+ 0.000053f, 0.000050f, 0.000051f, 0.000046f, 0.000059f, 0.000056f, 0.000057f, 0.000068f, 0.000078f, 0.000088f, 0.000096f, 0.000096f,
+ 0.000105f, 0.000107f, 0.000128f, 0.000121f, 0.000133f, 0.000141f, 0.000156f, 0.000151f, 0.000160f, 0.000200f, 0.000209f, 0.000198f,
+ 0.000222f, 0.000242f, 0.000258f, 0.000275f, 0.000314f, 0.000352f, 0.000410f, 0.000468f, 0.000537f, 0.000639f, 0.000799f, 0.001002f,
+ 0.001390f, 0.002092f, 0.003466f, 0.006653f, 0.015305f, 0.048004f, 0.606934f, 0.618652f, 0.622559f, 0.623047f, 0.623535f, 0.624023f,
+ 0.000084f, 0.000067f, 0.000064f, 0.000062f, 0.000057f, 0.000056f, 0.000053f, 0.000054f, 0.000051f, 0.000052f, 0.000050f, 0.000050f,
+ 0.000050f, 0.000049f, 0.000048f, 0.000047f, 0.000046f, 0.000044f, 0.000042f, 0.000040f, 0.000039f, 0.000037f, 0.000035f, 0.000036f,
+ 0.000037f, 0.000031f, 0.000040f, 0.000041f, 0.000042f, 0.000051f, 0.000058f, 0.000063f, 0.000067f, 0.000069f, 0.000072f, 0.000079f,
+ 0.000085f, 0.000092f, 0.000093f, 0.000101f, 0.000107f, 0.000123f, 0.000125f, 0.000139f, 0.000147f, 0.000154f, 0.000181f, 0.000204f,
+ 0.000229f, 0.000270f, 0.000327f, 0.000425f, 0.000559f, 0.000772f, 0.001265f, 0.002462f, 0.006191f, 0.022415f, 0.578613f, 0.592285f,
+ 0.595215f, 0.596191f, 0.596191f, 0.597656f, 0.000008f, 0.000022f, 0.000022f, 0.000024f, 0.000024f, 0.000027f, 0.000028f, 0.000028f,
+ 0.000028f, 0.000026f, 0.000028f, 0.000029f, 0.000029f, 0.000028f, 0.000029f, 0.000029f, 0.000029f, 0.000029f, 0.000030f, 0.000030f,
+ 0.000030f, 0.000029f, 0.000028f, 0.000027f, 0.000026f, 0.000025f, 0.000024f, 0.000023f, 0.000022f, 0.000021f, 0.000020f, 0.000019f,
+ 0.000021f, 0.000020f, 0.000022f, 0.000026f, 0.000028f, 0.000033f, 0.000037f, 0.000036f, 0.000039f, 0.000045f, 0.000051f, 0.000046f,
+ 0.000056f, 0.000059f, 0.000061f, 0.000071f, 0.000084f, 0.000098f, 0.000110f, 0.000133f, 0.000169f, 0.000223f, 0.000356f, 0.000648f,
+ 0.001702f, 0.007713f, 0.550293f, 0.564453f, 0.566895f, 0.567871f, 0.568359f, 0.568848f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000002f, 0.000003f, 0.000004f, 0.000006f,
+ 0.000007f, 0.000007f, 0.000008f, 0.000008f, 0.000009f, 0.000010f, 0.000011f, 0.000011f, 0.000012f, 0.000012f, 0.000013f, 0.000013f,
+ 0.000013f, 0.000014f, 0.000014f, 0.000013f, 0.000012f, 0.000012f, 0.000011f, 0.000011f, 0.000010f, 0.000010f, 0.000009f, 0.000009f,
+ 0.000008f, 0.000008f, 0.000009f, 0.000011f, 0.000014f, 0.000017f, 0.000015f, 0.000018f, 0.000021f, 0.000022f, 0.000023f, 0.000026f,
+ 0.000035f, 0.000040f, 0.000056f, 0.000089f, 0.000225f, 0.001332f, 0.520996f, 0.535156f, 0.538086f, 0.540039f, 0.540039f, 0.540039f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000001f, 0.000001f, 0.000002f, 0.000002f, 0.000003f, 0.000003f, 0.000003f, 0.000003f,
+ 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000001f, 0.000002f, 0.000003f, 0.000003f, 0.000004f, 0.000017f, 0.491211f, 0.506348f,
+ 0.508789f, 0.510254f, 0.510254f, 0.510742f,
+ },
+ {
+ 0.064758f, 0.179688f, 0.277344f, 0.358398f, 0.427002f, 0.485107f, 0.535156f, 0.578613f, 0.615234f, 0.647949f, 0.677734f, 0.703125f,
+ 0.725586f, 0.745605f, 0.763672f, 0.780273f, 0.795410f, 0.810059f, 0.821777f, 0.833496f, 0.843750f, 0.854004f, 0.862793f, 0.871582f,
+ 0.879883f, 0.886719f, 0.894043f, 0.900879f, 0.906250f, 0.912109f, 0.917969f, 0.922852f, 0.927246f, 0.932129f, 0.936523f, 0.940918f,
+ 0.944824f, 0.948242f, 0.951660f, 0.955078f, 0.958496f, 0.961426f, 0.964844f, 0.967773f, 0.970215f, 0.973145f, 0.975586f, 0.977539f,
+ 0.979980f, 0.982422f, 0.984863f, 0.986328f, 0.988770f, 0.990234f, 0.992676f, 0.993652f, 0.995605f, 0.997559f, 0.998535f, 0.996582f,
+ 0.995117f, 0.993652f, 0.992188f, 0.990723f, 0.040344f, 0.121460f, 0.199341f, 0.272949f, 0.339600f, 0.401123f, 0.455078f, 0.501953f,
+ 0.546875f, 0.583984f, 0.618164f, 0.648926f, 0.676270f, 0.700195f, 0.723145f, 0.743164f, 0.761230f, 0.776855f, 0.793457f, 0.806641f,
+ 0.819336f, 0.831543f, 0.842285f, 0.852051f, 0.861328f, 0.869629f, 0.877930f, 0.886230f, 0.892578f, 0.899902f, 0.905273f, 0.911621f,
+ 0.917480f, 0.922852f, 0.927246f, 0.932129f, 0.936035f, 0.940430f, 0.945312f, 0.949219f, 0.952148f, 0.956055f, 0.958984f, 0.961914f,
+ 0.965332f, 0.967773f, 0.970703f, 0.973633f, 0.976074f, 0.978516f, 0.980957f, 0.983398f, 0.985840f, 0.987305f, 0.989258f, 0.991699f,
+ 0.993652f, 0.995117f, 0.997070f, 0.995605f, 0.994141f, 0.993164f, 0.991699f, 0.990234f, 0.027191f, 0.084961f, 0.145630f, 0.206177f,
+ 0.266113f, 0.323242f, 0.377930f, 0.428711f, 0.474609f, 0.517090f, 0.554688f, 0.591309f, 0.621582f, 0.650391f, 0.676758f, 0.700684f,
+ 0.723145f, 0.741699f, 0.760254f, 0.776855f, 0.791504f, 0.805664f, 0.818359f, 0.830566f, 0.841309f, 0.851074f, 0.861816f, 0.870117f,
+ 0.878418f, 0.885254f, 0.892090f, 0.899414f, 0.906250f, 0.912598f, 0.916992f, 0.922363f, 0.928223f, 0.932617f, 0.937500f, 0.941895f,
+ 0.945801f, 0.949219f, 0.953613f, 0.957031f, 0.960449f, 0.963379f, 0.966797f, 0.969727f, 0.971680f, 0.974609f, 0.977539f, 0.979980f,
+ 0.981934f, 0.984375f, 0.986328f, 0.989258f, 0.991211f, 0.992676f, 0.996094f, 0.994629f, 0.993652f, 0.992188f, 0.990723f, 0.989746f,
+ 0.019577f, 0.061340f, 0.108337f, 0.156860f, 0.207153f, 0.258789f, 0.310059f, 0.358887f, 0.405762f, 0.450928f, 0.491211f, 0.530273f,
+ 0.565430f, 0.597656f, 0.627441f, 0.654297f, 0.680176f, 0.702637f, 0.724121f, 0.743164f, 0.760742f, 0.776855f, 0.791992f, 0.806152f,
+ 0.817871f, 0.830078f, 0.841797f, 0.852539f, 0.861816f, 0.870117f, 0.878906f, 0.886230f, 0.893066f, 0.900391f, 0.906738f, 0.912598f,
+ 0.918457f, 0.923340f, 0.928223f, 0.933594f, 0.938477f, 0.942871f, 0.946777f, 0.950684f, 0.954590f, 0.958496f, 0.960938f, 0.964844f,
+ 0.967773f, 0.970703f, 0.973633f, 0.976074f, 0.979004f, 0.981445f, 0.983398f, 0.985840f, 0.987793f, 0.990234f, 0.995117f, 0.993652f,
+ 0.992676f, 0.991699f, 0.990234f, 0.989258f, 0.014397f, 0.046295f, 0.081543f, 0.120728f, 0.162842f, 0.206177f, 0.250977f, 0.296143f,
+ 0.342041f, 0.385986f, 0.427979f, 0.468262f, 0.506348f, 0.542480f, 0.575195f, 0.605469f, 0.633789f, 0.660156f, 0.684570f, 0.706543f,
+ 0.727539f, 0.745117f, 0.763184f, 0.778809f, 0.793945f, 0.807617f, 0.820312f, 0.833008f, 0.842773f, 0.852539f, 0.862305f, 0.872070f,
+ 0.879395f, 0.887207f, 0.894531f, 0.900879f, 0.907227f, 0.914551f, 0.919922f, 0.925293f, 0.930176f, 0.935547f, 0.938965f, 0.943359f,
+ 0.948730f, 0.952637f, 0.956055f, 0.959473f, 0.962891f, 0.966309f, 0.969238f, 0.972656f, 0.975098f, 0.977539f, 0.980957f, 0.982910f,
+ 0.984863f, 0.987793f, 0.994141f, 0.993164f, 0.991699f, 0.990723f, 0.989746f, 0.988281f, 0.010925f, 0.035828f, 0.063660f, 0.094360f,
+ 0.128174f, 0.164551f, 0.203247f, 0.244385f, 0.285645f, 0.326416f, 0.367432f, 0.409424f, 0.447998f, 0.484131f, 0.520508f, 0.553711f,
+ 0.584473f, 0.614258f, 0.641113f, 0.666016f, 0.689453f, 0.710938f, 0.730469f, 0.750488f, 0.766602f, 0.781250f, 0.796387f, 0.809570f,
+ 0.822266f, 0.833496f, 0.844727f, 0.854980f, 0.864258f, 0.873047f, 0.881348f, 0.889648f, 0.895996f, 0.903809f, 0.910156f, 0.916504f,
+ 0.921387f, 0.926758f, 0.932129f, 0.937500f, 0.941895f, 0.946777f, 0.950684f, 0.954102f, 0.958008f, 0.960938f, 0.965332f, 0.968262f,
+ 0.971680f, 0.975098f, 0.977539f, 0.979492f, 0.982422f, 0.984863f, 0.992676f, 0.991699f, 0.990723f, 0.989746f, 0.988770f, 0.987793f,
+ 0.008698f, 0.028244f, 0.049866f, 0.074463f, 0.102295f, 0.132935f, 0.165161f, 0.200073f, 0.236206f, 0.275391f, 0.313477f, 0.352051f,
+ 0.391113f, 0.428955f, 0.465088f, 0.500977f, 0.534180f, 0.565430f, 0.593750f, 0.622559f, 0.648438f, 0.671875f, 0.694824f, 0.715820f,
+ 0.734863f, 0.753906f, 0.771484f, 0.784668f, 0.799805f, 0.813477f, 0.825195f, 0.836914f, 0.847656f, 0.857910f, 0.866699f, 0.875488f,
+ 0.884766f, 0.892090f, 0.898438f, 0.906250f, 0.913086f, 0.918457f, 0.923828f, 0.929688f, 0.935059f, 0.939941f, 0.944336f, 0.948730f,
+ 0.952637f, 0.956055f, 0.959961f, 0.963379f, 0.967285f, 0.970703f, 0.973633f, 0.976074f, 0.979492f, 0.982422f, 0.991211f, 0.990723f,
+ 0.990234f, 0.988770f, 0.987793f, 0.986328f, 0.007210f, 0.022797f, 0.040039f, 0.060181f, 0.082153f, 0.107300f, 0.134155f, 0.164673f,
+ 0.196167f, 0.229492f, 0.265381f, 0.301025f, 0.338379f, 0.374756f, 0.411133f, 0.446533f, 0.481201f, 0.515625f, 0.546387f, 0.576660f,
+ 0.605957f, 0.631348f, 0.656738f, 0.681152f, 0.702148f, 0.722168f, 0.741699f, 0.758789f, 0.775391f, 0.791016f, 0.803711f, 0.817383f,
+ 0.829102f, 0.840820f, 0.851562f, 0.860840f, 0.871094f, 0.879395f, 0.887695f, 0.895020f, 0.901855f, 0.909180f, 0.915527f, 0.921387f,
+ 0.927734f, 0.932129f, 0.937500f, 0.941895f, 0.947266f, 0.950684f, 0.955078f, 0.958984f, 0.962891f, 0.966797f, 0.969727f, 0.973145f,
+ 0.976562f, 0.979004f, 0.990234f, 0.989746f, 0.988770f, 0.987793f, 0.986816f, 0.985840f, 0.005863f, 0.018936f, 0.032898f, 0.049377f,
+ 0.067261f, 0.088257f, 0.110535f, 0.135254f, 0.162231f, 0.191895f, 0.223389f, 0.255371f, 0.290039f, 0.324707f, 0.359863f, 0.395996f,
+ 0.429932f, 0.464355f, 0.497314f, 0.529297f, 0.559570f, 0.587891f, 0.616699f, 0.642090f, 0.665527f, 0.688965f, 0.709961f, 0.729492f,
+ 0.747559f, 0.765625f, 0.780762f, 0.794922f, 0.809082f, 0.822754f, 0.833984f, 0.844727f, 0.855957f, 0.864746f, 0.875000f, 0.883789f,
+ 0.891113f, 0.898926f, 0.906250f, 0.912598f, 0.918457f, 0.925293f, 0.930664f, 0.935059f, 0.940918f, 0.945312f, 0.950195f, 0.954590f,
+ 0.958496f, 0.962402f, 0.965820f, 0.969238f, 0.972656f, 0.976074f, 0.988770f, 0.988770f, 0.987793f, 0.986816f, 0.985840f, 0.984863f,
+ 0.004925f, 0.015518f, 0.027451f, 0.041199f, 0.055786f, 0.072998f, 0.091492f, 0.112427f, 0.135254f, 0.160767f, 0.187500f, 0.216919f,
+ 0.247314f, 0.280273f, 0.313477f, 0.346680f, 0.381592f, 0.415283f, 0.448730f, 0.481201f, 0.513184f, 0.543945f, 0.573242f, 0.601562f,
+ 0.627441f, 0.652344f, 0.675293f, 0.697754f, 0.718262f, 0.737793f, 0.754883f, 0.771973f, 0.787109f, 0.800781f, 0.815430f, 0.828125f,
+ 0.839844f, 0.851074f, 0.860840f, 0.870117f, 0.879883f, 0.887695f, 0.896484f, 0.902832f, 0.911133f, 0.916992f, 0.922852f, 0.928711f,
+ 0.934082f, 0.939941f, 0.944336f, 0.948730f, 0.954102f, 0.958008f, 0.961426f, 0.965332f, 0.969238f, 0.972168f, 0.987305f, 0.987305f,
+ 0.986816f, 0.985840f, 0.984863f, 0.983887f, 0.004139f, 0.012955f, 0.022781f, 0.034088f, 0.046997f, 0.061005f, 0.076538f, 0.094360f,
+ 0.113464f, 0.134888f, 0.158203f, 0.183716f, 0.210693f, 0.239990f, 0.270264f, 0.302734f, 0.334961f, 0.367676f, 0.400635f, 0.434082f,
+ 0.467041f, 0.497803f, 0.528809f, 0.558105f, 0.586426f, 0.614258f, 0.638672f, 0.663574f, 0.686035f, 0.707520f, 0.728027f, 0.745605f,
+ 0.762695f, 0.779297f, 0.794434f, 0.808594f, 0.821777f, 0.834473f, 0.845215f, 0.855957f, 0.866699f, 0.876465f, 0.884766f, 0.892090f,
+ 0.900391f, 0.908203f, 0.915039f, 0.920898f, 0.927246f, 0.932617f, 0.937988f, 0.943848f, 0.948730f, 0.952637f, 0.957520f, 0.961426f,
+ 0.965820f, 0.968750f, 0.985840f, 0.985840f, 0.985840f, 0.984375f, 0.983887f, 0.982910f, 0.003492f, 0.011307f, 0.019608f, 0.028793f,
+ 0.039246f, 0.051544f, 0.064392f, 0.078796f, 0.095337f, 0.113953f, 0.134033f, 0.155396f, 0.179688f, 0.205200f, 0.232300f, 0.261475f,
+ 0.291748f, 0.323730f, 0.355225f, 0.387939f, 0.420410f, 0.452637f, 0.483887f, 0.514648f, 0.544922f, 0.573730f, 0.601074f, 0.626953f,
+ 0.651367f, 0.675293f, 0.697266f, 0.717285f, 0.736816f, 0.755371f, 0.771973f, 0.786621f, 0.803223f, 0.815430f, 0.828613f, 0.840820f,
+ 0.851562f, 0.863281f, 0.873047f, 0.880859f, 0.890625f, 0.898438f, 0.905762f, 0.913086f, 0.919434f, 0.925781f, 0.931641f, 0.937500f,
+ 0.942871f, 0.947754f, 0.952637f, 0.957520f, 0.960938f, 0.965820f, 0.984375f, 0.984863f, 0.984375f, 0.983398f, 0.982422f, 0.981445f,
+ 0.002977f, 0.009415f, 0.016708f, 0.024811f, 0.033356f, 0.043457f, 0.054535f, 0.067017f, 0.080322f, 0.096130f, 0.113708f, 0.132080f,
+ 0.152710f, 0.175415f, 0.199829f, 0.226440f, 0.253662f, 0.282959f, 0.313232f, 0.343750f, 0.375000f, 0.406982f, 0.439453f, 0.471191f,
+ 0.501465f, 0.531738f, 0.560547f, 0.587891f, 0.615234f, 0.640625f, 0.664062f, 0.687500f, 0.708496f, 0.728516f, 0.747559f, 0.765137f,
+ 0.781738f, 0.795898f, 0.811523f, 0.824707f, 0.836426f, 0.847656f, 0.858887f, 0.869141f, 0.878906f, 0.887695f, 0.895996f, 0.904297f,
+ 0.911133f, 0.917969f, 0.925293f, 0.931152f, 0.937012f, 0.942383f, 0.947266f, 0.953125f, 0.957031f, 0.961426f, 0.982910f, 0.983398f,
+ 0.982910f, 0.982422f, 0.981445f, 0.980957f, 0.002743f, 0.008568f, 0.014305f, 0.021378f, 0.028732f, 0.037201f, 0.046387f, 0.057068f,
+ 0.068848f, 0.082336f, 0.096924f, 0.113159f, 0.130859f, 0.150146f, 0.171509f, 0.194824f, 0.219482f, 0.246338f, 0.273926f, 0.302734f,
+ 0.333496f, 0.364502f, 0.395752f, 0.426758f, 0.458252f, 0.489990f, 0.519531f, 0.548340f, 0.576660f, 0.604004f, 0.630859f, 0.654297f,
+ 0.678223f, 0.700684f, 0.720215f, 0.740234f, 0.758301f, 0.775391f, 0.790527f, 0.805176f, 0.818848f, 0.833008f, 0.844238f, 0.855469f,
+ 0.866699f, 0.876953f, 0.886230f, 0.894043f, 0.902832f, 0.910645f, 0.917480f, 0.924316f, 0.930664f, 0.937012f, 0.941895f, 0.947266f,
+ 0.952148f, 0.957031f, 0.981445f, 0.982422f, 0.981445f, 0.980957f, 0.980469f, 0.979004f, 0.002504f, 0.007004f, 0.012634f, 0.018555f,
+ 0.024933f, 0.032654f, 0.040283f, 0.048920f, 0.059357f, 0.070007f, 0.082642f, 0.096741f, 0.112122f, 0.128906f, 0.147339f, 0.167603f,
+ 0.189697f, 0.213257f, 0.238770f, 0.265869f, 0.293701f, 0.323242f, 0.354004f, 0.384766f, 0.415283f, 0.447021f, 0.478516f, 0.507812f,
+ 0.536621f, 0.565918f, 0.593750f, 0.620605f, 0.645508f, 0.668945f, 0.692383f, 0.712891f, 0.733398f, 0.751465f, 0.769531f, 0.785156f,
+ 0.801270f, 0.814941f, 0.828125f, 0.841797f, 0.853516f, 0.864746f, 0.874512f, 0.883789f, 0.893555f, 0.900879f, 0.910156f, 0.917480f,
+ 0.923340f, 0.930664f, 0.936523f, 0.942383f, 0.947754f, 0.952637f, 0.979492f, 0.980469f, 0.980469f, 0.979492f, 0.978516f, 0.978027f,
+ 0.002039f, 0.006287f, 0.010864f, 0.016129f, 0.021637f, 0.027786f, 0.034485f, 0.042450f, 0.051331f, 0.060760f, 0.071594f, 0.082886f,
+ 0.096313f, 0.110840f, 0.126587f, 0.145020f, 0.164185f, 0.185181f, 0.207520f, 0.232300f, 0.258301f, 0.285889f, 0.314941f, 0.344238f,
+ 0.374268f, 0.405029f, 0.436035f, 0.466797f, 0.498291f, 0.527344f, 0.555664f, 0.583984f, 0.611328f, 0.636230f, 0.661133f, 0.684082f,
+ 0.705566f, 0.726562f, 0.745605f, 0.764648f, 0.781250f, 0.797852f, 0.812500f, 0.825195f, 0.838867f, 0.851074f, 0.862305f, 0.873535f,
+ 0.883301f, 0.892578f, 0.901367f, 0.908203f, 0.916992f, 0.923828f, 0.931152f, 0.937012f, 0.942383f, 0.947266f, 0.978027f, 0.978516f,
+ 0.979004f, 0.978027f, 0.977051f, 0.977051f, 0.001762f, 0.005489f, 0.009804f, 0.013931f, 0.019028f, 0.024445f, 0.030518f, 0.036865f,
+ 0.044189f, 0.052460f, 0.061432f, 0.071960f, 0.083008f, 0.095642f, 0.109558f, 0.124756f, 0.141602f, 0.160156f, 0.180664f, 0.202148f,
+ 0.225952f, 0.250977f, 0.278076f, 0.305664f, 0.334961f, 0.364990f, 0.394775f, 0.425537f, 0.456543f, 0.487061f, 0.517090f, 0.546387f,
+ 0.575195f, 0.602539f, 0.627930f, 0.653809f, 0.676758f, 0.699707f, 0.721191f, 0.740723f, 0.759766f, 0.777832f, 0.793945f, 0.809082f,
+ 0.823242f, 0.836426f, 0.849609f, 0.861328f, 0.872070f, 0.881836f, 0.892578f, 0.900391f, 0.908691f, 0.916992f, 0.924316f, 0.931152f,
+ 0.937500f, 0.943359f, 0.976074f, 0.977051f, 0.977051f, 0.976562f, 0.976074f, 0.975098f, 0.001675f, 0.005020f, 0.008400f, 0.012253f,
+ 0.016724f, 0.021469f, 0.026428f, 0.032104f, 0.039062f, 0.045563f, 0.053741f, 0.062103f, 0.072205f, 0.082947f, 0.094666f, 0.107727f,
+ 0.122681f, 0.139038f, 0.156250f, 0.176514f, 0.197388f, 0.220581f, 0.244629f, 0.270752f, 0.297607f, 0.326172f, 0.355957f, 0.386475f,
+ 0.416748f, 0.447754f, 0.478027f, 0.507812f, 0.538086f, 0.566406f, 0.594727f, 0.621582f, 0.647461f, 0.671387f, 0.694336f, 0.716797f,
+ 0.737305f, 0.755859f, 0.773438f, 0.791016f, 0.807129f, 0.820801f, 0.834961f, 0.848145f, 0.860352f, 0.871582f, 0.881836f, 0.891602f,
+ 0.901367f, 0.909180f, 0.917480f, 0.925293f, 0.932129f, 0.938965f, 0.974609f, 0.975586f, 0.976074f, 0.974609f, 0.974121f, 0.973633f,
+ 0.001437f, 0.004513f, 0.007427f, 0.010994f, 0.014526f, 0.018829f, 0.023331f, 0.028229f, 0.034058f, 0.040192f, 0.046844f, 0.054321f,
+ 0.062683f, 0.071716f, 0.082397f, 0.093933f, 0.106567f, 0.120728f, 0.136230f, 0.153320f, 0.172485f, 0.192627f, 0.214233f, 0.237915f,
+ 0.263672f, 0.290527f, 0.318115f, 0.347412f, 0.377197f, 0.408203f, 0.438477f, 0.469482f, 0.499512f, 0.529785f, 0.558594f, 0.586914f,
+ 0.614258f, 0.641602f, 0.665527f, 0.689941f, 0.711914f, 0.732422f, 0.752930f, 0.771484f, 0.789062f, 0.805664f, 0.819824f, 0.833984f,
+ 0.847656f, 0.860840f, 0.871094f, 0.881836f, 0.891602f, 0.902344f, 0.910156f, 0.918457f, 0.926270f, 0.932617f, 0.972168f, 0.973633f,
+ 0.973633f, 0.973145f, 0.973145f, 0.971680f, 0.001390f, 0.003952f, 0.006779f, 0.009941f, 0.013062f, 0.017029f, 0.020905f, 0.024994f,
+ 0.029877f, 0.035187f, 0.041077f, 0.047119f, 0.055145f, 0.062500f, 0.071594f, 0.081543f, 0.092712f, 0.104736f, 0.118530f, 0.133179f,
+ 0.150024f, 0.168091f, 0.187378f, 0.209717f, 0.232178f, 0.256836f, 0.283447f, 0.311279f, 0.339844f, 0.369873f, 0.399658f, 0.429932f,
+ 0.461426f, 0.492188f, 0.521973f, 0.551758f, 0.580566f, 0.608887f, 0.635254f, 0.660645f, 0.685059f, 0.708008f, 0.729492f, 0.750488f,
+ 0.769043f, 0.786621f, 0.802734f, 0.818848f, 0.832520f, 0.846680f, 0.860352f, 0.871582f, 0.882324f, 0.892578f, 0.902832f, 0.911133f,
+ 0.919922f, 0.926758f, 0.970703f, 0.971680f, 0.971680f, 0.971680f, 0.971680f, 0.969238f, 0.001328f, 0.003641f, 0.006138f, 0.008690f,
+ 0.011444f, 0.014786f, 0.018311f, 0.022125f, 0.026337f, 0.031403f, 0.036011f, 0.041809f, 0.047943f, 0.054901f, 0.062622f, 0.071106f,
+ 0.081299f, 0.091614f, 0.103455f, 0.116333f, 0.130493f, 0.146484f, 0.164307f, 0.183228f, 0.204224f, 0.226685f, 0.251221f, 0.277100f,
+ 0.303711f, 0.332764f, 0.361572f, 0.391846f, 0.422852f, 0.454102f, 0.485352f, 0.515625f, 0.545410f, 0.574707f, 0.603027f, 0.630371f,
+ 0.656250f, 0.681641f, 0.705078f, 0.726562f, 0.747070f, 0.767578f, 0.784668f, 0.803223f, 0.818848f, 0.833008f, 0.847656f, 0.860352f,
+ 0.872559f, 0.883301f, 0.894043f, 0.903809f, 0.913574f, 0.921387f, 0.967773f, 0.970215f, 0.970215f, 0.968750f, 0.969238f, 0.968750f,
+ 0.001053f, 0.002905f, 0.005432f, 0.007912f, 0.010658f, 0.012901f, 0.016464f, 0.019363f, 0.023376f, 0.027237f, 0.031799f, 0.036346f,
+ 0.042145f, 0.048248f, 0.054871f, 0.062256f, 0.070618f, 0.079834f, 0.089844f, 0.101440f, 0.113831f, 0.128174f, 0.143433f, 0.160156f,
+ 0.179077f, 0.199707f, 0.222046f, 0.245483f, 0.271240f, 0.297363f, 0.325684f, 0.355469f, 0.385254f, 0.416016f, 0.447754f, 0.479004f,
+ 0.508789f, 0.539551f, 0.570312f, 0.598145f, 0.626465f, 0.652344f, 0.678223f, 0.702148f, 0.725098f, 0.746094f, 0.765625f, 0.785645f,
+ 0.803223f, 0.819336f, 0.834961f, 0.848145f, 0.861328f, 0.873535f, 0.884766f, 0.895508f, 0.905762f, 0.915527f, 0.965332f, 0.967773f,
+ 0.968262f, 0.967773f, 0.967285f, 0.966309f, 0.001106f, 0.002684f, 0.004913f, 0.006733f, 0.009300f, 0.011955f, 0.014435f, 0.017700f,
+ 0.020477f, 0.024124f, 0.028091f, 0.032532f, 0.037231f, 0.042511f, 0.048309f, 0.054596f, 0.061798f, 0.069885f, 0.078857f, 0.089050f,
+ 0.099915f, 0.112183f, 0.125488f, 0.140503f, 0.157104f, 0.175293f, 0.195068f, 0.216309f, 0.240356f, 0.265381f, 0.291748f, 0.319580f,
+ 0.348633f, 0.379150f, 0.410156f, 0.441406f, 0.472900f, 0.503418f, 0.534668f, 0.565430f, 0.594727f, 0.622070f, 0.649902f, 0.676270f,
+ 0.700195f, 0.723633f, 0.746094f, 0.766602f, 0.786133f, 0.802734f, 0.819824f, 0.835449f, 0.849609f, 0.863281f, 0.875977f, 0.887695f,
+ 0.898438f, 0.908203f, 0.962891f, 0.965820f, 0.966309f, 0.965332f, 0.964844f, 0.964355f, 0.000782f, 0.002707f, 0.004574f, 0.006184f,
+ 0.008286f, 0.010681f, 0.012878f, 0.015640f, 0.018478f, 0.021912f, 0.025208f, 0.028976f, 0.032867f, 0.037598f, 0.042938f, 0.048370f,
+ 0.054443f, 0.061432f, 0.069214f, 0.077515f, 0.087402f, 0.098145f, 0.109497f, 0.122803f, 0.137329f, 0.153564f, 0.171509f, 0.190918f,
+ 0.212158f, 0.235352f, 0.259766f, 0.286133f, 0.314209f, 0.343262f, 0.373535f, 0.404297f, 0.436279f, 0.467773f, 0.499512f, 0.530273f,
+ 0.561523f, 0.590820f, 0.620117f, 0.647461f, 0.674316f, 0.699219f, 0.722656f, 0.745605f, 0.766602f, 0.785645f, 0.804688f, 0.821777f,
+ 0.836426f, 0.852051f, 0.865234f, 0.878418f, 0.890625f, 0.901855f, 0.959961f, 0.962891f, 0.963867f, 0.963379f, 0.962402f, 0.962402f,
+ 0.000787f, 0.002195f, 0.004250f, 0.005775f, 0.007774f, 0.009445f, 0.011795f, 0.013725f, 0.016678f, 0.019531f, 0.022018f, 0.025665f,
+ 0.029495f, 0.033142f, 0.037598f, 0.042664f, 0.048248f, 0.053772f, 0.060699f, 0.067993f, 0.076416f, 0.085815f, 0.095764f, 0.107422f,
+ 0.120239f, 0.134277f, 0.150269f, 0.167358f, 0.186646f, 0.207764f, 0.230347f, 0.255127f, 0.281250f, 0.308838f, 0.337891f, 0.368408f,
+ 0.399414f, 0.431396f, 0.463135f, 0.495605f, 0.526855f, 0.558594f, 0.588379f, 0.618652f, 0.646973f, 0.673828f, 0.699707f, 0.723633f,
+ 0.746094f, 0.767090f, 0.788086f, 0.806641f, 0.823730f, 0.840332f, 0.854980f, 0.869141f, 0.881836f, 0.893555f, 0.957520f, 0.960938f,
+ 0.960938f, 0.961426f, 0.960449f, 0.959961f, 0.000765f, 0.002207f, 0.003666f, 0.005177f, 0.006973f, 0.008301f, 0.010704f, 0.012794f,
+ 0.015015f, 0.017303f, 0.020309f, 0.022568f, 0.026123f, 0.029587f, 0.033325f, 0.037659f, 0.042206f, 0.047516f, 0.053223f, 0.059814f,
+ 0.067017f, 0.075195f, 0.083801f, 0.094055f, 0.105042f, 0.117737f, 0.131470f, 0.146851f, 0.163940f, 0.182739f, 0.203369f, 0.225952f,
+ 0.250244f, 0.276367f, 0.304199f, 0.333008f, 0.364258f, 0.395264f, 0.427002f, 0.459961f, 0.491699f, 0.524414f, 0.555664f, 0.586914f,
+ 0.617676f, 0.645996f, 0.673340f, 0.699707f, 0.724121f, 0.748047f, 0.770020f, 0.790039f, 0.809082f, 0.827148f, 0.842773f, 0.858398f,
+ 0.873047f, 0.885742f, 0.954102f, 0.958008f, 0.958496f, 0.958496f, 0.958496f, 0.957520f, 0.000586f, 0.001937f, 0.003107f, 0.004745f,
+ 0.006168f, 0.007610f, 0.009590f, 0.011345f, 0.013321f, 0.015587f, 0.017593f, 0.020294f, 0.023346f, 0.026154f, 0.029205f, 0.033234f,
+ 0.037415f, 0.041962f, 0.046906f, 0.052673f, 0.058533f, 0.065796f, 0.073669f, 0.082642f, 0.092346f, 0.103027f, 0.115234f, 0.128784f,
+ 0.143799f, 0.160889f, 0.179199f, 0.199585f, 0.221802f, 0.246094f, 0.271973f, 0.299805f, 0.329102f, 0.359863f, 0.391357f, 0.423340f,
+ 0.456299f, 0.490234f, 0.522949f, 0.555176f, 0.586426f, 0.617188f, 0.645996f, 0.675293f, 0.701660f, 0.726074f, 0.750488f, 0.773926f,
+ 0.793945f, 0.812988f, 0.831543f, 0.847656f, 0.862793f, 0.877441f, 0.951660f, 0.955078f, 0.955566f, 0.955566f, 0.955078f, 0.954590f,
+ 0.000678f, 0.001864f, 0.003138f, 0.004333f, 0.005707f, 0.006893f, 0.008224f, 0.009850f, 0.012215f, 0.013954f, 0.015747f, 0.018219f,
+ 0.020584f, 0.023148f, 0.026047f, 0.029434f, 0.033020f, 0.037018f, 0.041626f, 0.046509f, 0.051910f, 0.058105f, 0.064636f, 0.072510f,
+ 0.080750f, 0.090149f, 0.100891f, 0.112549f, 0.126343f, 0.141113f, 0.157593f, 0.175537f, 0.195801f, 0.218018f, 0.242554f, 0.268311f,
+ 0.295898f, 0.325195f, 0.355713f, 0.388184f, 0.421143f, 0.454834f, 0.488281f, 0.522949f, 0.554199f, 0.587402f, 0.618164f, 0.648438f,
+ 0.676758f, 0.704102f, 0.730957f, 0.754395f, 0.776855f, 0.798340f, 0.817871f, 0.836426f, 0.852051f, 0.868164f, 0.948242f, 0.952637f,
+ 0.953125f, 0.952637f, 0.952148f, 0.951660f, 0.000470f, 0.001578f, 0.002934f, 0.003838f, 0.005032f, 0.006310f, 0.007725f, 0.008972f,
+ 0.010826f, 0.012657f, 0.014359f, 0.015991f, 0.018402f, 0.020721f, 0.023102f, 0.026230f, 0.029495f, 0.032867f, 0.036743f, 0.040680f,
+ 0.045654f, 0.050812f, 0.056763f, 0.063477f, 0.071045f, 0.078918f, 0.088440f, 0.098938f, 0.110657f, 0.123535f, 0.138062f, 0.154175f,
+ 0.172363f, 0.192627f, 0.214478f, 0.238770f, 0.264404f, 0.292236f, 0.322266f, 0.353271f, 0.385742f, 0.419189f, 0.453857f, 0.487549f,
+ 0.521484f, 0.555664f, 0.588867f, 0.621094f, 0.651367f, 0.680176f, 0.708008f, 0.733887f, 0.759766f, 0.780762f, 0.802734f, 0.821289f,
+ 0.840820f, 0.858398f, 0.943848f, 0.949219f, 0.949707f, 0.949707f, 0.949707f, 0.949219f, 0.000485f, 0.001689f, 0.002386f, 0.003698f,
+ 0.004547f, 0.005936f, 0.006851f, 0.008217f, 0.009834f, 0.011055f, 0.012810f, 0.014473f, 0.016449f, 0.018509f, 0.020950f, 0.023209f,
+ 0.025940f, 0.029114f, 0.032410f, 0.036133f, 0.040161f, 0.044861f, 0.050018f, 0.055664f, 0.061859f, 0.069153f, 0.077515f, 0.086365f,
+ 0.096680f, 0.108093f, 0.120605f, 0.135132f, 0.151489f, 0.169556f, 0.189209f, 0.211426f, 0.235352f, 0.261475f, 0.289307f, 0.319580f,
+ 0.351074f, 0.384521f, 0.418701f, 0.452881f, 0.487549f, 0.522461f, 0.556641f, 0.591309f, 0.623535f, 0.653809f, 0.684570f, 0.712891f,
+ 0.739258f, 0.764160f, 0.787109f, 0.809570f, 0.829102f, 0.847168f, 0.940918f, 0.945801f, 0.946289f, 0.946777f, 0.946777f, 0.945312f,
+ 0.000620f, 0.001351f, 0.002413f, 0.003273f, 0.004307f, 0.004971f, 0.006138f, 0.007542f, 0.008835f, 0.009972f, 0.011581f, 0.013069f,
+ 0.014717f, 0.016495f, 0.018738f, 0.020691f, 0.023315f, 0.025879f, 0.028793f, 0.031860f, 0.035309f, 0.039246f, 0.043762f, 0.048950f,
+ 0.054474f, 0.060669f, 0.067932f, 0.075378f, 0.084351f, 0.094055f, 0.105774f, 0.118469f, 0.132690f, 0.148315f, 0.166504f, 0.186401f,
+ 0.208130f, 0.232544f, 0.258789f, 0.287109f, 0.317627f, 0.349854f, 0.383057f, 0.417725f, 0.453125f, 0.488770f, 0.523926f, 0.559082f,
+ 0.594238f, 0.627441f, 0.659180f, 0.689941f, 0.719238f, 0.745117f, 0.770508f, 0.794434f, 0.815430f, 0.836914f, 0.936523f, 0.941895f,
+ 0.942871f, 0.942871f, 0.942871f, 0.942383f, 0.000404f, 0.001095f, 0.002087f, 0.002983f, 0.003986f, 0.004673f, 0.005844f, 0.006878f,
+ 0.007740f, 0.008873f, 0.010323f, 0.011757f, 0.013176f, 0.014915f, 0.016586f, 0.018585f, 0.020523f, 0.022720f, 0.025391f, 0.028244f,
+ 0.031219f, 0.034821f, 0.038788f, 0.042908f, 0.047943f, 0.053040f, 0.058960f, 0.066162f, 0.073547f, 0.082397f, 0.092285f, 0.102844f,
+ 0.115234f, 0.129883f, 0.146118f, 0.163452f, 0.183350f, 0.205688f, 0.229614f, 0.256592f, 0.285156f, 0.316162f, 0.348633f, 0.383057f,
+ 0.418457f, 0.454590f, 0.490967f, 0.526855f, 0.563477f, 0.598633f, 0.632812f, 0.665527f, 0.696777f, 0.726074f, 0.752930f, 0.779297f,
+ 0.803223f, 0.825684f, 0.933105f, 0.938477f, 0.938477f, 0.938965f, 0.938477f, 0.938477f, 0.000415f, 0.000864f, 0.001907f, 0.002775f,
+ 0.003519f, 0.004204f, 0.005352f, 0.006237f, 0.007019f, 0.008064f, 0.009239f, 0.010483f, 0.011742f, 0.013130f, 0.014877f, 0.016571f,
+ 0.018494f, 0.020126f, 0.022537f, 0.024826f, 0.027649f, 0.030701f, 0.033875f, 0.037964f, 0.042114f, 0.046356f, 0.051605f, 0.057587f,
+ 0.064209f, 0.071777f, 0.080261f, 0.089722f, 0.100952f, 0.113220f, 0.127075f, 0.143066f, 0.160767f, 0.180664f, 0.202759f, 0.227417f,
+ 0.254395f, 0.284180f, 0.315674f, 0.348633f, 0.383789f, 0.420166f, 0.457275f, 0.494385f, 0.531250f, 0.569336f, 0.605469f, 0.639160f,
+ 0.672363f, 0.705078f, 0.735352f, 0.762207f, 0.788574f, 0.811523f, 0.928711f, 0.934082f, 0.934570f, 0.935059f, 0.935059f, 0.935059f,
+ 0.000236f, 0.001136f, 0.001664f, 0.002502f, 0.003187f, 0.004082f, 0.004631f, 0.005386f, 0.006275f, 0.007385f, 0.008217f, 0.009453f,
+ 0.010567f, 0.011787f, 0.013115f, 0.014420f, 0.016083f, 0.017944f, 0.019867f, 0.022079f, 0.024414f, 0.026962f, 0.029755f, 0.033112f,
+ 0.036926f, 0.040771f, 0.045258f, 0.050232f, 0.056183f, 0.062500f, 0.069946f, 0.078430f, 0.087708f, 0.098389f, 0.110779f, 0.124634f,
+ 0.140259f, 0.158203f, 0.178223f, 0.200928f, 0.225708f, 0.253174f, 0.282715f, 0.315430f, 0.349365f, 0.385254f, 0.422363f, 0.460938f,
+ 0.499023f, 0.537109f, 0.574707f, 0.612305f, 0.646484f, 0.682129f, 0.713867f, 0.745117f, 0.772461f, 0.799316f, 0.923828f, 0.930176f,
+ 0.930664f, 0.931152f, 0.930664f, 0.930664f, 0.000229f, 0.000964f, 0.001582f, 0.002182f, 0.002838f, 0.003653f, 0.004341f, 0.004921f,
+ 0.005615f, 0.006626f, 0.007423f, 0.008545f, 0.009483f, 0.010666f, 0.011612f, 0.013000f, 0.014275f, 0.015900f, 0.017487f, 0.019333f,
+ 0.021484f, 0.023773f, 0.026276f, 0.028992f, 0.032135f, 0.035492f, 0.039398f, 0.044037f, 0.049072f, 0.054443f, 0.061035f, 0.067871f,
+ 0.076111f, 0.085632f, 0.096252f, 0.108154f, 0.122253f, 0.138306f, 0.156006f, 0.175903f, 0.199219f, 0.224243f, 0.251953f, 0.282715f,
+ 0.315918f, 0.350830f, 0.387451f, 0.425781f, 0.465332f, 0.504395f, 0.544434f, 0.583008f, 0.620117f, 0.657715f, 0.692383f, 0.725098f,
+ 0.755371f, 0.783691f, 0.919434f, 0.925781f, 0.926270f, 0.926758f, 0.926758f, 0.925781f, 0.000410f, 0.000856f, 0.001542f, 0.001844f,
+ 0.002565f, 0.003380f, 0.003971f, 0.004246f, 0.005047f, 0.005863f, 0.006653f, 0.007744f, 0.008568f, 0.009407f, 0.010529f, 0.011482f,
+ 0.012657f, 0.013924f, 0.015602f, 0.017105f, 0.018997f, 0.020859f, 0.022980f, 0.025192f, 0.028030f, 0.031036f, 0.034515f, 0.038300f,
+ 0.042236f, 0.047180f, 0.052795f, 0.059113f, 0.065857f, 0.074097f, 0.083374f, 0.094360f, 0.105896f, 0.119873f, 0.135620f, 0.154175f,
+ 0.174072f, 0.197632f, 0.223267f, 0.251465f, 0.283447f, 0.317139f, 0.353760f, 0.391113f, 0.431152f, 0.470703f, 0.512207f, 0.552734f,
+ 0.592285f, 0.631348f, 0.669434f, 0.704590f, 0.737793f, 0.768555f, 0.913574f, 0.919922f, 0.920898f, 0.920898f, 0.921387f, 0.921387f,
+ 0.000214f, 0.000619f, 0.001172f, 0.001941f, 0.002228f, 0.002960f, 0.003490f, 0.003994f, 0.004761f, 0.005180f, 0.005806f, 0.006622f,
+ 0.007565f, 0.008301f, 0.009262f, 0.010170f, 0.011208f, 0.012482f, 0.013855f, 0.015060f, 0.016739f, 0.018311f, 0.020248f, 0.022034f,
+ 0.024597f, 0.027084f, 0.030045f, 0.033051f, 0.036743f, 0.041016f, 0.045807f, 0.050964f, 0.056946f, 0.063904f, 0.071899f, 0.080994f,
+ 0.091675f, 0.103699f, 0.117920f, 0.133667f, 0.151978f, 0.172729f, 0.196533f, 0.222534f, 0.252197f, 0.284424f, 0.319580f, 0.356689f,
+ 0.396973f, 0.437500f, 0.479492f, 0.521484f, 0.562500f, 0.604004f, 0.644043f, 0.682129f, 0.718262f, 0.751465f, 0.907715f, 0.915039f,
+ 0.916016f, 0.916504f, 0.916504f, 0.916504f, 0.000405f, 0.000760f, 0.001116f, 0.001688f, 0.002180f, 0.002670f, 0.003313f, 0.003569f,
+ 0.003979f, 0.004543f, 0.005466f, 0.005985f, 0.006699f, 0.007359f, 0.008102f, 0.009094f, 0.009949f, 0.011055f, 0.012047f, 0.013412f,
+ 0.014488f, 0.016068f, 0.017532f, 0.019348f, 0.021210f, 0.023834f, 0.025986f, 0.028854f, 0.031891f, 0.035339f, 0.039490f, 0.043976f,
+ 0.049347f, 0.055084f, 0.061951f, 0.069763f, 0.078918f, 0.089478f, 0.101379f, 0.115479f, 0.131592f, 0.150024f, 0.171387f, 0.195068f,
+ 0.222900f, 0.252686f, 0.286621f, 0.323242f, 0.362061f, 0.402588f, 0.445312f, 0.488770f, 0.532715f, 0.575684f, 0.618652f, 0.659180f,
+ 0.698242f, 0.734375f, 0.901367f, 0.909180f, 0.911133f, 0.910645f, 0.911133f, 0.910645f, 0.000218f, 0.000539f, 0.001187f, 0.001617f,
+ 0.001987f, 0.002316f, 0.002666f, 0.003176f, 0.003841f, 0.004425f, 0.004917f, 0.005402f, 0.005768f, 0.006462f, 0.007233f, 0.008018f,
+ 0.008575f, 0.009758f, 0.010582f, 0.011520f, 0.012756f, 0.013832f, 0.015312f, 0.016968f, 0.018509f, 0.020279f, 0.022644f, 0.024857f,
+ 0.027740f, 0.030472f, 0.033783f, 0.037567f, 0.042175f, 0.047150f, 0.052979f, 0.059601f, 0.067505f, 0.076538f, 0.087158f, 0.099243f,
+ 0.113281f, 0.129272f, 0.148315f, 0.170532f, 0.194702f, 0.223267f, 0.254639f, 0.289795f, 0.327393f, 0.368408f, 0.410889f, 0.455322f,
+ 0.499756f, 0.544434f, 0.590332f, 0.633789f, 0.676270f, 0.716309f, 0.895508f, 0.902344f, 0.903809f, 0.905762f, 0.903809f, 0.904297f,
+ 0.000184f, 0.000612f, 0.001122f, 0.001464f, 0.001848f, 0.002150f, 0.002514f, 0.002651f, 0.003391f, 0.003666f, 0.004368f, 0.004677f,
+ 0.005219f, 0.005882f, 0.006531f, 0.007019f, 0.007675f, 0.008530f, 0.009224f, 0.010269f, 0.011017f, 0.012146f, 0.013321f, 0.014626f,
+ 0.016098f, 0.017639f, 0.019440f, 0.021317f, 0.023773f, 0.026123f, 0.029144f, 0.032410f, 0.036072f, 0.040314f, 0.045013f, 0.051086f,
+ 0.057587f, 0.065308f, 0.074402f, 0.084961f, 0.097107f, 0.111267f, 0.127930f, 0.147217f, 0.169556f, 0.195312f, 0.224365f, 0.257568f,
+ 0.294189f, 0.333496f, 0.375977f, 0.420166f, 0.467041f, 0.514160f, 0.561035f, 0.607422f, 0.652344f, 0.695312f, 0.888672f, 0.896484f,
+ 0.897461f, 0.897461f, 0.897949f, 0.897949f, 0.000159f, 0.000537f, 0.000830f, 0.001206f, 0.001578f, 0.001760f, 0.002050f, 0.002504f,
+ 0.002951f, 0.003397f, 0.003674f, 0.004238f, 0.004520f, 0.005245f, 0.005692f, 0.006138f, 0.006748f, 0.007240f, 0.008087f, 0.008728f,
+ 0.009636f, 0.010437f, 0.011543f, 0.012611f, 0.013763f, 0.015266f, 0.016617f, 0.018433f, 0.020248f, 0.022354f, 0.024887f, 0.027390f,
+ 0.030716f, 0.034454f, 0.038422f, 0.043365f, 0.048950f, 0.055511f, 0.062988f, 0.072021f, 0.082336f, 0.094727f, 0.109375f, 0.125977f,
+ 0.145874f, 0.169556f, 0.195679f, 0.226929f, 0.260986f, 0.299805f, 0.341309f, 0.385498f, 0.432129f, 0.480957f, 0.529297f, 0.579102f,
+ 0.627441f, 0.673828f, 0.881348f, 0.889160f, 0.890625f, 0.891113f, 0.891602f, 0.891113f, 0.000204f, 0.000566f, 0.000741f, 0.001033f,
+ 0.001378f, 0.001599f, 0.001961f, 0.002354f, 0.002609f, 0.002974f, 0.003300f, 0.003609f, 0.004101f, 0.004463f, 0.004906f, 0.005337f,
+ 0.006020f, 0.006290f, 0.007023f, 0.007656f, 0.008301f, 0.009140f, 0.009918f, 0.010933f, 0.011940f, 0.013107f, 0.014252f, 0.015656f,
+ 0.017136f, 0.019058f, 0.021057f, 0.023209f, 0.025940f, 0.029190f, 0.032715f, 0.036591f, 0.041138f, 0.046661f, 0.053253f, 0.060944f,
+ 0.069702f, 0.080444f, 0.092651f, 0.107788f, 0.124695f, 0.145630f, 0.169189f, 0.197632f, 0.229736f, 0.266113f, 0.306396f, 0.350586f,
+ 0.397217f, 0.447021f, 0.497803f, 0.549805f, 0.600586f, 0.650391f, 0.872559f, 0.881836f, 0.882812f, 0.883301f, 0.884277f, 0.884277f,
+ 0.000240f, 0.000349f, 0.000795f, 0.000892f, 0.001151f, 0.001377f, 0.001773f, 0.001984f, 0.002415f, 0.002602f, 0.002932f, 0.003168f,
+ 0.003483f, 0.003906f, 0.004257f, 0.004681f, 0.005173f, 0.005596f, 0.006119f, 0.006550f, 0.007126f, 0.007759f, 0.008522f, 0.009270f,
+ 0.010086f, 0.011108f, 0.012138f, 0.013199f, 0.014549f, 0.015884f, 0.017776f, 0.019623f, 0.022003f, 0.024384f, 0.027237f, 0.030624f,
+ 0.034515f, 0.039215f, 0.044342f, 0.050873f, 0.058411f, 0.067017f, 0.078003f, 0.090332f, 0.105530f, 0.123718f, 0.144775f, 0.170410f,
+ 0.200195f, 0.234131f, 0.272461f, 0.315674f, 0.362305f, 0.412354f, 0.465332f, 0.518555f, 0.572754f, 0.626465f, 0.863770f, 0.873047f,
+ 0.875488f, 0.875488f, 0.875977f, 0.875977f, 0.000102f, 0.000298f, 0.000604f, 0.000950f, 0.001089f, 0.001472f, 0.001760f, 0.001823f,
+ 0.001903f, 0.002325f, 0.002611f, 0.002775f, 0.003185f, 0.003405f, 0.003674f, 0.004005f, 0.004406f, 0.004814f, 0.005203f, 0.005665f,
+ 0.006062f, 0.006702f, 0.007317f, 0.007881f, 0.008560f, 0.009239f, 0.010193f, 0.010994f, 0.012161f, 0.013588f, 0.015068f, 0.016479f,
+ 0.018250f, 0.020386f, 0.022781f, 0.025665f, 0.028809f, 0.032501f, 0.037048f, 0.042297f, 0.048553f, 0.055908f, 0.065491f, 0.075378f,
+ 0.088501f, 0.104248f, 0.122742f, 0.145874f, 0.171997f, 0.203247f, 0.239990f, 0.281250f, 0.326904f, 0.376953f, 0.430176f, 0.486328f,
+ 0.542480f, 0.600586f, 0.855469f, 0.864746f, 0.866211f, 0.867188f, 0.867188f, 0.867188f, 0.000000f, 0.000357f, 0.000576f, 0.000692f,
+ 0.001013f, 0.001069f, 0.001383f, 0.001702f, 0.001789f, 0.002102f, 0.002182f, 0.002377f, 0.002686f, 0.002985f, 0.003347f, 0.003359f,
+ 0.003782f, 0.004036f, 0.004436f, 0.004749f, 0.005169f, 0.005672f, 0.006145f, 0.006649f, 0.007187f, 0.007828f, 0.008644f, 0.009529f,
+ 0.010269f, 0.011200f, 0.012337f, 0.013596f, 0.015038f, 0.017044f, 0.018784f, 0.021011f, 0.023727f, 0.026871f, 0.030457f, 0.034637f,
+ 0.039978f, 0.046478f, 0.053436f, 0.062622f, 0.073730f, 0.086792f, 0.102661f, 0.122437f, 0.146240f, 0.174561f, 0.208252f, 0.247437f,
+ 0.291748f, 0.341064f, 0.395020f, 0.451904f, 0.511230f, 0.571777f, 0.844238f, 0.854980f, 0.857422f, 0.858887f, 0.857910f, 0.857910f,
+ 0.000101f, 0.000326f, 0.000535f, 0.000683f, 0.000848f, 0.001161f, 0.001184f, 0.001284f, 0.001576f, 0.001701f, 0.001839f, 0.002167f,
+ 0.002321f, 0.002584f, 0.002645f, 0.002941f, 0.003141f, 0.003538f, 0.003817f, 0.004112f, 0.004395f, 0.004646f, 0.005165f, 0.005531f,
+ 0.006096f, 0.006496f, 0.007217f, 0.007767f, 0.008629f, 0.009163f, 0.010239f, 0.011276f, 0.012611f, 0.013779f, 0.015213f, 0.017120f,
+ 0.019379f, 0.021606f, 0.024994f, 0.028351f, 0.032379f, 0.037201f, 0.043640f, 0.050903f, 0.060120f, 0.071045f, 0.084900f, 0.101868f,
+ 0.122559f, 0.147827f, 0.178223f, 0.214722f, 0.257080f, 0.305664f, 0.358887f, 0.416992f, 0.478027f, 0.542969f, 0.834473f, 0.845215f,
+ 0.847656f, 0.847656f, 0.847656f, 0.848633f, 0.000092f, 0.000316f, 0.000410f, 0.000556f, 0.000808f, 0.000918f, 0.001094f, 0.001287f,
+ 0.001309f, 0.001411f, 0.001671f, 0.001780f, 0.001909f, 0.002092f, 0.002274f, 0.002523f, 0.002733f, 0.002974f, 0.003101f, 0.003401f,
+ 0.003677f, 0.003956f, 0.004311f, 0.004551f, 0.004940f, 0.005444f, 0.005768f, 0.006451f, 0.006977f, 0.007568f, 0.008270f, 0.009201f,
+ 0.010170f, 0.011230f, 0.012566f, 0.013939f, 0.015503f, 0.017761f, 0.020111f, 0.022873f, 0.025940f, 0.029938f, 0.035217f, 0.040985f,
+ 0.048431f, 0.057770f, 0.069092f, 0.083618f, 0.100891f, 0.123047f, 0.150146f, 0.183838f, 0.223633f, 0.269531f, 0.322510f, 0.381348f,
+ 0.444824f, 0.511719f, 0.823730f, 0.834473f, 0.835938f, 0.836914f, 0.836914f, 0.837402f, 0.000240f, 0.000273f, 0.000326f, 0.000564f,
+ 0.000682f, 0.000807f, 0.000854f, 0.000949f, 0.001139f, 0.001238f, 0.001404f, 0.001548f, 0.001637f, 0.001840f, 0.001893f, 0.002077f,
+ 0.002321f, 0.002434f, 0.002642f, 0.002821f, 0.003044f, 0.003271f, 0.003649f, 0.003763f, 0.004208f, 0.004448f, 0.004986f, 0.005169f,
+ 0.005657f, 0.006279f, 0.006680f, 0.007442f, 0.008194f, 0.008881f, 0.009895f, 0.010918f, 0.012138f, 0.013924f, 0.015915f, 0.018112f,
+ 0.020645f, 0.023743f, 0.027817f, 0.032745f, 0.038361f, 0.045990f, 0.055481f, 0.066895f, 0.082031f, 0.100769f, 0.124573f, 0.154541f,
+ 0.190796f, 0.235107f, 0.286133f, 0.344238f, 0.408936f, 0.478271f, 0.810547f, 0.822266f, 0.824707f, 0.825195f, 0.825684f, 0.825684f,
+ 0.000115f, 0.000222f, 0.000252f, 0.000524f, 0.000574f, 0.000673f, 0.000869f, 0.000928f, 0.000963f, 0.001022f, 0.001246f, 0.001292f,
+ 0.001404f, 0.001477f, 0.001652f, 0.001811f, 0.001822f, 0.002058f, 0.002237f, 0.002371f, 0.002588f, 0.002645f, 0.003019f, 0.003080f,
+ 0.003506f, 0.003689f, 0.003904f, 0.004383f, 0.004707f, 0.005020f, 0.005386f, 0.006023f, 0.006451f, 0.007038f, 0.007809f, 0.008911f,
+ 0.009949f, 0.011200f, 0.012222f, 0.014137f, 0.016068f, 0.018692f, 0.021683f, 0.025314f, 0.029861f, 0.035889f, 0.043335f, 0.052582f,
+ 0.065186f, 0.080627f, 0.101501f, 0.127441f, 0.159912f, 0.200806f, 0.250000f, 0.307129f, 0.371582f, 0.444580f, 0.798340f, 0.809570f,
+ 0.811523f, 0.812988f, 0.812988f, 0.812988f, 0.000000f, 0.000211f, 0.000204f, 0.000474f, 0.000555f, 0.000583f, 0.000600f, 0.000593f,
+ 0.000812f, 0.000865f, 0.000941f, 0.001013f, 0.001162f, 0.001348f, 0.001418f, 0.001465f, 0.001616f, 0.001722f, 0.001856f, 0.001888f,
+ 0.002048f, 0.002321f, 0.002396f, 0.002632f, 0.002821f, 0.002974f, 0.003265f, 0.003477f, 0.003632f, 0.004051f, 0.004299f, 0.004700f,
+ 0.005238f, 0.005592f, 0.006199f, 0.006756f, 0.007614f, 0.008324f, 0.009727f, 0.010811f, 0.012337f, 0.014168f, 0.016434f, 0.019257f,
+ 0.022858f, 0.027451f, 0.033295f, 0.040619f, 0.050690f, 0.063416f, 0.080261f, 0.102295f, 0.131104f, 0.168335f, 0.214355f, 0.270508f,
+ 0.334717f, 0.408936f, 0.783691f, 0.795898f, 0.798340f, 0.799316f, 0.800293f, 0.800293f, 0.000174f, 0.000090f, 0.000281f, 0.000397f,
+ 0.000401f, 0.000450f, 0.000488f, 0.000640f, 0.000674f, 0.000713f, 0.000753f, 0.000845f, 0.000872f, 0.001020f, 0.001115f, 0.001264f,
+ 0.001327f, 0.001373f, 0.001520f, 0.001616f, 0.001767f, 0.001875f, 0.001968f, 0.002090f, 0.002232f, 0.002333f, 0.002472f, 0.002802f,
+ 0.002926f, 0.003189f, 0.003569f, 0.003752f, 0.004009f, 0.004513f, 0.004860f, 0.005375f, 0.005997f, 0.006561f, 0.007378f, 0.008347f,
+ 0.009384f, 0.010612f, 0.012466f, 0.014526f, 0.017075f, 0.020447f, 0.024887f, 0.030533f, 0.038300f, 0.048584f, 0.062042f, 0.080383f,
+ 0.104736f, 0.137329f, 0.180176f, 0.232544f, 0.296875f, 0.371338f, 0.769043f, 0.781250f, 0.784180f, 0.784668f, 0.786133f, 0.786133f,
+ 0.000025f, 0.000135f, 0.000154f, 0.000260f, 0.000353f, 0.000364f, 0.000380f, 0.000520f, 0.000548f, 0.000587f, 0.000712f, 0.000735f,
+ 0.000772f, 0.000822f, 0.000886f, 0.001004f, 0.000946f, 0.001115f, 0.001177f, 0.001266f, 0.001454f, 0.001527f, 0.001575f, 0.001680f,
+ 0.001883f, 0.001961f, 0.002043f, 0.002193f, 0.002281f, 0.002520f, 0.002712f, 0.003021f, 0.003147f, 0.003561f, 0.003786f, 0.004116f,
+ 0.004570f, 0.005058f, 0.005634f, 0.006165f, 0.007095f, 0.008049f, 0.009201f, 0.010674f, 0.012550f, 0.014854f, 0.018051f, 0.022385f,
+ 0.027908f, 0.035522f, 0.046295f, 0.061035f, 0.081238f, 0.109131f, 0.146729f, 0.197021f, 0.258301f, 0.333008f, 0.752441f, 0.766113f,
+ 0.768555f, 0.769531f, 0.770020f, 0.769531f, 0.000000f, 0.000121f, 0.000209f, 0.000291f, 0.000337f, 0.000307f, 0.000324f, 0.000415f,
+ 0.000426f, 0.000453f, 0.000491f, 0.000573f, 0.000644f, 0.000650f, 0.000781f, 0.000746f, 0.000830f, 0.000803f, 0.000997f, 0.001017f,
+ 0.001020f, 0.001158f, 0.001241f, 0.001317f, 0.001375f, 0.001432f, 0.001524f, 0.001656f, 0.001858f, 0.001955f, 0.002050f, 0.002274f,
+ 0.002460f, 0.002724f, 0.002831f, 0.003050f, 0.003441f, 0.003790f, 0.004162f, 0.004623f, 0.005219f, 0.005951f, 0.006721f, 0.007729f,
+ 0.008926f, 0.010620f, 0.013000f, 0.015686f, 0.019852f, 0.025436f, 0.033295f, 0.044617f, 0.060608f, 0.083313f, 0.116211f, 0.161499f,
+ 0.220093f, 0.293945f, 0.734863f, 0.749512f, 0.752441f, 0.752930f, 0.753906f, 0.753906f, 0.000000f, 0.000121f, 0.000118f, 0.000246f,
+ 0.000233f, 0.000252f, 0.000338f, 0.000282f, 0.000353f, 0.000355f, 0.000448f, 0.000435f, 0.000464f, 0.000530f, 0.000578f, 0.000649f,
+ 0.000677f, 0.000710f, 0.000749f, 0.000792f, 0.000881f, 0.000903f, 0.000967f, 0.001049f, 0.001041f, 0.001100f, 0.001176f, 0.001254f,
+ 0.001402f, 0.001451f, 0.001697f, 0.001674f, 0.001804f, 0.001914f, 0.002195f, 0.002451f, 0.002474f, 0.002758f, 0.003029f, 0.003483f,
+ 0.003824f, 0.004272f, 0.004833f, 0.005573f, 0.006477f, 0.007629f, 0.009041f, 0.010918f, 0.013573f, 0.017319f, 0.022842f, 0.031036f,
+ 0.043030f, 0.061096f, 0.088440f, 0.127563f, 0.182861f, 0.254395f, 0.717285f, 0.731934f, 0.734863f, 0.735352f, 0.735840f, 0.736328f,
+ 0.000000f, 0.000000f, 0.000117f, 0.000163f, 0.000109f, 0.000208f, 0.000212f, 0.000208f, 0.000270f, 0.000356f, 0.000324f, 0.000377f,
+ 0.000391f, 0.000420f, 0.000449f, 0.000440f, 0.000484f, 0.000504f, 0.000534f, 0.000561f, 0.000639f, 0.000667f, 0.000715f, 0.000722f,
+ 0.000799f, 0.000845f, 0.000939f, 0.000945f, 0.001053f, 0.001149f, 0.001252f, 0.001310f, 0.001392f, 0.001507f, 0.001526f, 0.001710f,
+ 0.001773f, 0.002111f, 0.002300f, 0.002443f, 0.002661f, 0.002996f, 0.003376f, 0.003880f, 0.004482f, 0.005150f, 0.006115f, 0.007401f,
+ 0.009132f, 0.011696f, 0.015076f, 0.020416f, 0.029236f, 0.042389f, 0.063782f, 0.096802f, 0.146362f, 0.215576f, 0.698242f, 0.712891f,
+ 0.715332f, 0.716797f, 0.717285f, 0.717285f, 0.000000f, 0.000118f, 0.000115f, 0.000133f, 0.000144f, 0.000147f, 0.000162f, 0.000150f,
+ 0.000194f, 0.000215f, 0.000228f, 0.000299f, 0.000271f, 0.000313f, 0.000328f, 0.000358f, 0.000378f, 0.000360f, 0.000407f, 0.000438f,
+ 0.000441f, 0.000488f, 0.000515f, 0.000544f, 0.000576f, 0.000617f, 0.000659f, 0.000715f, 0.000741f, 0.000773f, 0.000850f, 0.000921f,
+ 0.000979f, 0.001066f, 0.001128f, 0.001292f, 0.001279f, 0.001400f, 0.001572f, 0.001668f, 0.001869f, 0.002029f, 0.002295f, 0.002607f,
+ 0.002985f, 0.003464f, 0.004066f, 0.004913f, 0.006023f, 0.007519f, 0.009827f, 0.013016f, 0.018524f, 0.027481f, 0.042847f, 0.068970f,
+ 0.111938f, 0.176392f, 0.675781f, 0.692871f, 0.695801f, 0.696777f, 0.698242f, 0.697754f, 0.000000f, 0.000000f, 0.000111f, 0.000108f,
+ 0.000104f, 0.000102f, 0.000118f, 0.000120f, 0.000134f, 0.000128f, 0.000188f, 0.000154f, 0.000197f, 0.000188f, 0.000245f, 0.000256f,
+ 0.000233f, 0.000266f, 0.000345f, 0.000281f, 0.000355f, 0.000322f, 0.000392f, 0.000358f, 0.000437f, 0.000425f, 0.000458f, 0.000477f,
+ 0.000564f, 0.000636f, 0.000578f, 0.000607f, 0.000668f, 0.000719f, 0.000769f, 0.000832f, 0.000880f, 0.000953f, 0.001060f, 0.001116f,
+ 0.001226f, 0.001363f, 0.001486f, 0.001760f, 0.001944f, 0.002216f, 0.002605f, 0.003107f, 0.003778f, 0.004715f, 0.005989f, 0.007942f,
+ 0.011292f, 0.016632f, 0.026550f, 0.045532f, 0.079956f, 0.138550f, 0.655762f, 0.671875f, 0.674805f, 0.675293f, 0.675781f, 0.678223f,
+ 0.000000f, 0.000112f, 0.000105f, 0.000102f, 0.000098f, 0.000095f, 0.000093f, 0.000088f, 0.000089f, 0.000085f, 0.000095f, 0.000126f,
+ 0.000109f, 0.000154f, 0.000153f, 0.000162f, 0.000176f, 0.000190f, 0.000202f, 0.000204f, 0.000212f, 0.000214f, 0.000266f, 0.000239f,
+ 0.000279f, 0.000293f, 0.000329f, 0.000329f, 0.000339f, 0.000365f, 0.000437f, 0.000424f, 0.000429f, 0.000474f, 0.000525f, 0.000596f,
+ 0.000572f, 0.000612f, 0.000666f, 0.000723f, 0.000791f, 0.000850f, 0.000977f, 0.001066f, 0.001225f, 0.001351f, 0.001555f, 0.001837f,
+ 0.002279f, 0.002760f, 0.003445f, 0.004612f, 0.006386f, 0.009438f, 0.015221f, 0.027008f, 0.052551f, 0.102966f, 0.633789f, 0.649414f,
+ 0.652832f, 0.653809f, 0.655273f, 0.655273f, 0.000000f, 0.000105f, 0.000099f, 0.000094f, 0.000090f, 0.000087f, 0.000084f, 0.000082f,
+ 0.000079f, 0.000075f, 0.000071f, 0.000068f, 0.000064f, 0.000072f, 0.000096f, 0.000105f, 0.000112f, 0.000088f, 0.000123f, 0.000129f,
+ 0.000132f, 0.000140f, 0.000147f, 0.000170f, 0.000188f, 0.000192f, 0.000171f, 0.000210f, 0.000217f, 0.000223f, 0.000237f, 0.000251f,
+ 0.000258f, 0.000294f, 0.000298f, 0.000316f, 0.000350f, 0.000382f, 0.000400f, 0.000437f, 0.000479f, 0.000514f, 0.000576f, 0.000620f,
+ 0.000688f, 0.000782f, 0.000916f, 0.001026f, 0.001219f, 0.001502f, 0.001892f, 0.002424f, 0.003359f, 0.004974f, 0.008118f, 0.014343f,
+ 0.030075f, 0.070068f, 0.610352f, 0.626953f, 0.629883f, 0.631348f, 0.632324f, 0.632324f, 0.000110f, 0.000094f, 0.000087f, 0.000081f,
+ 0.000077f, 0.000075f, 0.000072f, 0.000069f, 0.000067f, 0.000066f, 0.000064f, 0.000062f, 0.000058f, 0.000056f, 0.000053f, 0.000051f,
+ 0.000054f, 0.000047f, 0.000057f, 0.000055f, 0.000075f, 0.000078f, 0.000086f, 0.000093f, 0.000093f, 0.000102f, 0.000112f, 0.000113f,
+ 0.000130f, 0.000128f, 0.000142f, 0.000145f, 0.000156f, 0.000153f, 0.000180f, 0.000178f, 0.000183f, 0.000223f, 0.000230f, 0.000240f,
+ 0.000265f, 0.000276f, 0.000300f, 0.000332f, 0.000357f, 0.000411f, 0.000449f, 0.000540f, 0.000615f, 0.000741f, 0.000916f, 0.001144f,
+ 0.001566f, 0.002310f, 0.003731f, 0.006905f, 0.014793f, 0.041779f, 0.585938f, 0.603027f, 0.605957f, 0.608398f, 0.608398f, 0.609375f,
+ 0.000090f, 0.000071f, 0.000066f, 0.000062f, 0.000058f, 0.000056f, 0.000053f, 0.000053f, 0.000051f, 0.000051f, 0.000049f, 0.000048f,
+ 0.000048f, 0.000047f, 0.000045f, 0.000043f, 0.000042f, 0.000040f, 0.000038f, 0.000036f, 0.000036f, 0.000033f, 0.000034f, 0.000040f,
+ 0.000040f, 0.000040f, 0.000048f, 0.000053f, 0.000060f, 0.000064f, 0.000067f, 0.000070f, 0.000075f, 0.000081f, 0.000085f, 0.000090f,
+ 0.000091f, 0.000103f, 0.000106f, 0.000120f, 0.000134f, 0.000138f, 0.000142f, 0.000156f, 0.000174f, 0.000180f, 0.000212f, 0.000239f,
+ 0.000253f, 0.000310f, 0.000377f, 0.000479f, 0.000627f, 0.000875f, 0.001396f, 0.002623f, 0.006184f, 0.019897f, 0.560547f, 0.578125f,
+ 0.581543f, 0.583008f, 0.583984f, 0.583984f, 0.000038f, 0.000035f, 0.000031f, 0.000031f, 0.000030f, 0.000031f, 0.000031f, 0.000030f,
+ 0.000030f, 0.000028f, 0.000029f, 0.000030f, 0.000029f, 0.000028f, 0.000029f, 0.000029f, 0.000029f, 0.000029f, 0.000029f, 0.000028f,
+ 0.000027f, 0.000026f, 0.000025f, 0.000024f, 0.000023f, 0.000022f, 0.000021f, 0.000020f, 0.000019f, 0.000021f, 0.000019f, 0.000022f,
+ 0.000023f, 0.000027f, 0.000031f, 0.000035f, 0.000037f, 0.000039f, 0.000039f, 0.000043f, 0.000049f, 0.000052f, 0.000056f, 0.000050f,
+ 0.000068f, 0.000062f, 0.000070f, 0.000087f, 0.000094f, 0.000107f, 0.000122f, 0.000140f, 0.000191f, 0.000247f, 0.000388f, 0.000710f,
+ 0.001781f, 0.007076f, 0.535156f, 0.553223f, 0.556152f, 0.558105f, 0.559082f, 0.559082f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000003f, 0.000003f, 0.000005f, 0.000006f, 0.000007f, 0.000007f, 0.000009f,
+ 0.000009f, 0.000009f, 0.000010f, 0.000010f, 0.000011f, 0.000011f, 0.000012f, 0.000012f, 0.000012f, 0.000013f, 0.000013f, 0.000013f,
+ 0.000013f, 0.000012f, 0.000012f, 0.000011f, 0.000011f, 0.000010f, 0.000010f, 0.000009f, 0.000009f, 0.000009f, 0.000008f, 0.000009f,
+ 0.000009f, 0.000010f, 0.000011f, 0.000015f, 0.000017f, 0.000016f, 0.000018f, 0.000021f, 0.000020f, 0.000024f, 0.000024f, 0.000032f,
+ 0.000035f, 0.000045f, 0.000065f, 0.000105f, 0.000246f, 0.001313f, 0.508789f, 0.527344f, 0.530762f, 0.531738f, 0.532715f, 0.533691f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000001f, 0.000001f, 0.000002f, 0.000002f, 0.000002f, 0.000003f, 0.000003f, 0.000002f, 0.000002f, 0.000002f,
+ 0.000002f, 0.000002f, 0.000001f, 0.000001f, 0.000002f, 0.000002f, 0.000003f, 0.000003f, 0.000005f, 0.000018f, 0.481934f, 0.500977f,
+ 0.504883f, 0.505859f, 0.507324f, 0.507812f,
+ },
+ {
+ 0.053833f, 0.152832f, 0.239014f, 0.313477f, 0.377686f, 0.433838f, 0.481689f, 0.524414f, 0.562988f, 0.596680f, 0.626953f, 0.654785f,
+ 0.678711f, 0.700684f, 0.720703f, 0.739746f, 0.755859f, 0.771973f, 0.787109f, 0.798828f, 0.812012f, 0.823730f, 0.833984f, 0.844238f,
+ 0.853027f, 0.862793f, 0.870605f, 0.878418f, 0.885254f, 0.892090f, 0.898926f, 0.904297f, 0.910645f, 0.916504f, 0.921875f, 0.926270f,
+ 0.931641f, 0.936035f, 0.939941f, 0.944336f, 0.948242f, 0.952148f, 0.955566f, 0.959961f, 0.962402f, 0.966309f, 0.969238f, 0.972168f,
+ 0.975098f, 0.978027f, 0.980957f, 0.983398f, 0.985840f, 0.988281f, 0.990723f, 0.992676f, 0.995117f, 0.996582f, 0.998047f, 0.995117f,
+ 0.993164f, 0.990723f, 0.988770f, 0.986816f, 0.036804f, 0.109497f, 0.178589f, 0.244751f, 0.305908f, 0.361084f, 0.411621f, 0.457275f,
+ 0.498535f, 0.536133f, 0.569824f, 0.601562f, 0.629883f, 0.655273f, 0.679688f, 0.700195f, 0.720215f, 0.737793f, 0.755859f, 0.770508f,
+ 0.785645f, 0.798340f, 0.811035f, 0.822754f, 0.833008f, 0.843750f, 0.852539f, 0.861328f, 0.869629f, 0.877441f, 0.885742f, 0.892578f,
+ 0.898926f, 0.905273f, 0.911133f, 0.916504f, 0.921875f, 0.926758f, 0.931641f, 0.936523f, 0.940430f, 0.945312f, 0.949219f, 0.953613f,
+ 0.956543f, 0.960449f, 0.963867f, 0.967285f, 0.970703f, 0.973633f, 0.976562f, 0.979004f, 0.981934f, 0.984375f, 0.986816f, 0.989746f,
+ 0.992188f, 0.994141f, 0.996582f, 0.994141f, 0.992188f, 0.990234f, 0.988281f, 0.986328f, 0.025787f, 0.080383f, 0.136230f, 0.191650f,
+ 0.245239f, 0.297119f, 0.345947f, 0.392822f, 0.436035f, 0.476807f, 0.513184f, 0.547363f, 0.578125f, 0.607910f, 0.634766f, 0.658203f,
+ 0.681152f, 0.702637f, 0.721191f, 0.738770f, 0.755371f, 0.770508f, 0.784668f, 0.798828f, 0.810547f, 0.821777f, 0.833984f, 0.843262f,
+ 0.852539f, 0.861816f, 0.869629f, 0.877930f, 0.885254f, 0.893555f, 0.898926f, 0.906250f, 0.911621f, 0.917969f, 0.923340f, 0.928223f,
+ 0.933105f, 0.937500f, 0.941406f, 0.946289f, 0.950195f, 0.954102f, 0.958496f, 0.961914f, 0.965820f, 0.968750f, 0.971680f, 0.975098f,
+ 0.978027f, 0.980469f, 0.983887f, 0.985840f, 0.988770f, 0.991211f, 0.995117f, 0.993164f, 0.991211f, 0.989258f, 0.987305f, 0.985352f,
+ 0.019455f, 0.060944f, 0.104553f, 0.150513f, 0.196411f, 0.243164f, 0.289062f, 0.333740f, 0.376709f, 0.417725f, 0.454346f, 0.491211f,
+ 0.524414f, 0.556641f, 0.585938f, 0.613770f, 0.639160f, 0.662598f, 0.682617f, 0.703613f, 0.723633f, 0.740723f, 0.756836f, 0.771973f,
+ 0.787109f, 0.798828f, 0.812012f, 0.823242f, 0.833984f, 0.844238f, 0.853516f, 0.863281f, 0.871094f, 0.879395f, 0.886719f, 0.893555f,
+ 0.899902f, 0.907227f, 0.913086f, 0.918945f, 0.924805f, 0.928711f, 0.934082f, 0.938965f, 0.943848f, 0.947754f, 0.952637f, 0.955566f,
+ 0.959961f, 0.963867f, 0.966797f, 0.970215f, 0.973633f, 0.977051f, 0.979004f, 0.982422f, 0.985840f, 0.987793f, 0.993652f, 0.991699f,
+ 0.989746f, 0.988281f, 0.986328f, 0.984375f, 0.015221f, 0.047363f, 0.082092f, 0.119202f, 0.159058f, 0.199219f, 0.239380f, 0.280762f,
+ 0.321533f, 0.362061f, 0.400146f, 0.436768f, 0.472900f, 0.504883f, 0.536621f, 0.566406f, 0.594238f, 0.621094f, 0.645508f, 0.667969f,
+ 0.688477f, 0.707520f, 0.726562f, 0.742676f, 0.759277f, 0.773926f, 0.787598f, 0.800781f, 0.812988f, 0.825195f, 0.835938f, 0.846191f,
+ 0.856445f, 0.865234f, 0.872559f, 0.880859f, 0.888672f, 0.895020f, 0.902832f, 0.908203f, 0.914551f, 0.919922f, 0.926758f, 0.931152f,
+ 0.937012f, 0.941406f, 0.945312f, 0.949707f, 0.954102f, 0.958496f, 0.962402f, 0.965820f, 0.969238f, 0.972168f, 0.976074f, 0.978516f,
+ 0.981934f, 0.984863f, 0.992188f, 0.990723f, 0.988770f, 0.987305f, 0.985352f, 0.983887f, 0.011658f, 0.037170f, 0.065430f, 0.096008f,
+ 0.128784f, 0.162842f, 0.198975f, 0.235596f, 0.273926f, 0.310791f, 0.348145f, 0.385010f, 0.420410f, 0.454834f, 0.488037f, 0.519043f,
+ 0.548828f, 0.577148f, 0.603516f, 0.627441f, 0.650879f, 0.672363f, 0.693848f, 0.712402f, 0.729980f, 0.748535f, 0.762207f, 0.778809f,
+ 0.791504f, 0.804199f, 0.815918f, 0.827637f, 0.838867f, 0.848145f, 0.857910f, 0.866211f, 0.875977f, 0.883301f, 0.891602f, 0.898438f,
+ 0.905273f, 0.911133f, 0.917480f, 0.923340f, 0.928711f, 0.933594f, 0.938477f, 0.942871f, 0.948242f, 0.952637f, 0.956543f, 0.960449f,
+ 0.964355f, 0.968262f, 0.971191f, 0.974609f, 0.978027f, 0.980957f, 0.990723f, 0.989258f, 0.987793f, 0.985840f, 0.984375f, 0.983398f,
+ 0.009758f, 0.030121f, 0.052490f, 0.077576f, 0.104309f, 0.134277f, 0.164917f, 0.197510f, 0.231812f, 0.266113f, 0.301025f, 0.336426f,
+ 0.372070f, 0.405762f, 0.438721f, 0.471436f, 0.502441f, 0.531738f, 0.560059f, 0.587402f, 0.612793f, 0.634766f, 0.658691f, 0.679199f,
+ 0.699219f, 0.718262f, 0.735352f, 0.751953f, 0.767090f, 0.780762f, 0.794922f, 0.808105f, 0.820801f, 0.831055f, 0.842285f, 0.851562f,
+ 0.861328f, 0.870117f, 0.878906f, 0.886719f, 0.893555f, 0.900879f, 0.907715f, 0.913574f, 0.919434f, 0.926270f, 0.932129f, 0.936523f,
+ 0.941895f, 0.945801f, 0.951172f, 0.955078f, 0.959473f, 0.963867f, 0.966797f, 0.970703f, 0.974121f, 0.977539f, 0.989746f, 0.988281f,
+ 0.986328f, 0.984863f, 0.983398f, 0.982422f, 0.007744f, 0.024567f, 0.043365f, 0.063782f, 0.086487f, 0.111389f, 0.137451f, 0.166260f,
+ 0.195435f, 0.226929f, 0.259033f, 0.291748f, 0.324951f, 0.358398f, 0.391113f, 0.424316f, 0.456299f, 0.486328f, 0.516113f, 0.543945f,
+ 0.571289f, 0.597656f, 0.621094f, 0.644531f, 0.666504f, 0.686523f, 0.705078f, 0.724121f, 0.741211f, 0.757324f, 0.773438f, 0.786621f,
+ 0.801270f, 0.812988f, 0.823730f, 0.835938f, 0.846191f, 0.855957f, 0.865723f, 0.873047f, 0.882324f, 0.889648f, 0.897949f, 0.905762f,
+ 0.911133f, 0.917969f, 0.923828f, 0.929199f, 0.934082f, 0.940430f, 0.944824f, 0.949707f, 0.954102f, 0.958008f, 0.962891f, 0.966309f,
+ 0.970215f, 0.974121f, 0.987793f, 0.986816f, 0.985352f, 0.983887f, 0.981934f, 0.980469f, 0.006672f, 0.020828f, 0.035950f, 0.053345f,
+ 0.071594f, 0.092834f, 0.114624f, 0.139282f, 0.165649f, 0.192627f, 0.222290f, 0.252197f, 0.283203f, 0.314941f, 0.346680f, 0.377930f,
+ 0.409668f, 0.441650f, 0.471680f, 0.500977f, 0.529297f, 0.557129f, 0.583008f, 0.607422f, 0.630859f, 0.654297f, 0.674805f, 0.694824f,
+ 0.713867f, 0.731445f, 0.748535f, 0.763672f, 0.778320f, 0.791992f, 0.805664f, 0.817871f, 0.829590f, 0.840332f, 0.850098f, 0.860352f,
+ 0.869141f, 0.878906f, 0.886719f, 0.894043f, 0.901855f, 0.909180f, 0.915527f, 0.920898f, 0.927246f, 0.933105f, 0.938477f, 0.943848f,
+ 0.948730f, 0.953125f, 0.957520f, 0.961914f, 0.965820f, 0.970215f, 0.985840f, 0.985352f, 0.983887f, 0.981934f, 0.980957f, 0.979492f,
+ 0.005592f, 0.017181f, 0.030457f, 0.044739f, 0.060638f, 0.077454f, 0.097046f, 0.117981f, 0.140625f, 0.164673f, 0.190552f, 0.217896f,
+ 0.246582f, 0.275635f, 0.305176f, 0.336426f, 0.366943f, 0.397949f, 0.428711f, 0.457764f, 0.487061f, 0.515137f, 0.542480f, 0.568848f,
+ 0.593750f, 0.619141f, 0.641602f, 0.662598f, 0.683594f, 0.703613f, 0.721191f, 0.738281f, 0.755859f, 0.770996f, 0.784180f, 0.799316f,
+ 0.811035f, 0.823730f, 0.833984f, 0.845703f, 0.855957f, 0.865234f, 0.875000f, 0.883301f, 0.891602f, 0.898926f, 0.906738f, 0.912598f,
+ 0.919922f, 0.926270f, 0.931152f, 0.937988f, 0.942871f, 0.948242f, 0.952148f, 0.957520f, 0.961914f, 0.966309f, 0.984375f, 0.983398f,
+ 0.982422f, 0.981445f, 0.979492f, 0.978027f, 0.004829f, 0.014816f, 0.025711f, 0.037964f, 0.051300f, 0.065796f, 0.082458f, 0.100037f,
+ 0.120178f, 0.141357f, 0.163330f, 0.187622f, 0.213013f, 0.240601f, 0.268311f, 0.296387f, 0.325928f, 0.356445f, 0.385742f, 0.415771f,
+ 0.445557f, 0.474121f, 0.501465f, 0.530762f, 0.556152f, 0.581543f, 0.606445f, 0.630859f, 0.651855f, 0.672852f, 0.693359f, 0.712402f,
+ 0.730469f, 0.746582f, 0.762695f, 0.777832f, 0.791992f, 0.806152f, 0.818359f, 0.830566f, 0.840820f, 0.852051f, 0.862305f, 0.871094f,
+ 0.880371f, 0.888184f, 0.896484f, 0.904297f, 0.910645f, 0.917969f, 0.924316f, 0.931152f, 0.936035f, 0.942383f, 0.947266f, 0.951660f,
+ 0.957031f, 0.960938f, 0.982422f, 0.982422f, 0.981445f, 0.979492f, 0.978516f, 0.977051f, 0.004040f, 0.012436f, 0.022064f, 0.032440f,
+ 0.044006f, 0.056549f, 0.070068f, 0.085999f, 0.102539f, 0.120239f, 0.140625f, 0.161621f, 0.184448f, 0.208496f, 0.234253f, 0.260742f,
+ 0.288086f, 0.316406f, 0.345215f, 0.374512f, 0.404297f, 0.433350f, 0.462402f, 0.490234f, 0.518066f, 0.543945f, 0.570312f, 0.594727f,
+ 0.618652f, 0.642090f, 0.663086f, 0.683594f, 0.703613f, 0.721680f, 0.739258f, 0.755859f, 0.772461f, 0.786621f, 0.798828f, 0.812500f,
+ 0.825195f, 0.836914f, 0.848633f, 0.858887f, 0.869141f, 0.877441f, 0.886230f, 0.894531f, 0.902832f, 0.909668f, 0.916992f, 0.923340f,
+ 0.929688f, 0.935547f, 0.941406f, 0.947266f, 0.951660f, 0.957031f, 0.980469f, 0.980469f, 0.979492f, 0.978516f, 0.977051f, 0.976074f,
+ 0.003536f, 0.010872f, 0.018829f, 0.027893f, 0.037872f, 0.048492f, 0.060883f, 0.073425f, 0.088074f, 0.103638f, 0.120789f, 0.139038f,
+ 0.159912f, 0.181274f, 0.204102f, 0.227905f, 0.253906f, 0.280518f, 0.307861f, 0.335938f, 0.364746f, 0.393311f, 0.421631f, 0.451416f,
+ 0.479004f, 0.505859f, 0.533203f, 0.560059f, 0.584473f, 0.608398f, 0.631836f, 0.653320f, 0.674805f, 0.695801f, 0.714355f, 0.731934f,
+ 0.749512f, 0.765137f, 0.781250f, 0.794434f, 0.808594f, 0.821289f, 0.833496f, 0.844238f, 0.855469f, 0.866211f, 0.875000f, 0.883789f,
+ 0.892578f, 0.901855f, 0.908691f, 0.915527f, 0.922852f, 0.929199f, 0.935059f, 0.941406f, 0.947266f, 0.951172f, 0.978516f, 0.979004f,
+ 0.978027f, 0.977051f, 0.975586f, 0.974121f, 0.002989f, 0.009476f, 0.016785f, 0.024246f, 0.032745f, 0.041809f, 0.052246f, 0.063782f,
+ 0.076111f, 0.089722f, 0.104675f, 0.120605f, 0.138306f, 0.157959f, 0.178101f, 0.200073f, 0.223145f, 0.247192f, 0.273193f, 0.300293f,
+ 0.327148f, 0.354736f, 0.383545f, 0.411621f, 0.439941f, 0.468018f, 0.495605f, 0.522949f, 0.548828f, 0.574219f, 0.598145f, 0.622559f,
+ 0.645508f, 0.666016f, 0.687500f, 0.706543f, 0.725586f, 0.743164f, 0.759766f, 0.775391f, 0.791016f, 0.803711f, 0.817871f, 0.829590f,
+ 0.841797f, 0.852539f, 0.863281f, 0.873047f, 0.882812f, 0.891113f, 0.900391f, 0.906738f, 0.915039f, 0.922852f, 0.929688f, 0.936035f,
+ 0.941895f, 0.946777f, 0.976074f, 0.977051f, 0.976074f, 0.975586f, 0.974121f, 0.972656f, 0.002846f, 0.008568f, 0.014557f, 0.021484f,
+ 0.028442f, 0.036377f, 0.045074f, 0.055054f, 0.066101f, 0.077759f, 0.090759f, 0.104797f, 0.120483f, 0.136719f, 0.155029f, 0.175171f,
+ 0.196045f, 0.218262f, 0.241943f, 0.266357f, 0.292480f, 0.319336f, 0.345703f, 0.373535f, 0.402100f, 0.429932f, 0.457764f, 0.484863f,
+ 0.512207f, 0.539062f, 0.564941f, 0.589844f, 0.613281f, 0.636719f, 0.659180f, 0.680664f, 0.700684f, 0.718750f, 0.736816f, 0.754883f,
+ 0.770508f, 0.785645f, 0.799805f, 0.813965f, 0.826172f, 0.838867f, 0.850586f, 0.861328f, 0.871582f, 0.881836f, 0.890625f, 0.898926f,
+ 0.906738f, 0.915039f, 0.922363f, 0.928711f, 0.936035f, 0.941895f, 0.974609f, 0.975098f, 0.974609f, 0.973633f, 0.972656f, 0.971191f,
+ 0.002285f, 0.007290f, 0.012634f, 0.018280f, 0.024918f, 0.032074f, 0.039673f, 0.048157f, 0.057220f, 0.067810f, 0.078735f, 0.091248f,
+ 0.104370f, 0.119873f, 0.135742f, 0.152344f, 0.171631f, 0.191650f, 0.213501f, 0.236206f, 0.260010f, 0.285156f, 0.310547f, 0.338135f,
+ 0.364746f, 0.392578f, 0.420410f, 0.448242f, 0.476562f, 0.502441f, 0.529785f, 0.555664f, 0.581543f, 0.605469f, 0.629395f, 0.652344f,
+ 0.673340f, 0.693848f, 0.713867f, 0.732910f, 0.750000f, 0.767090f, 0.782715f, 0.797852f, 0.811035f, 0.825195f, 0.836914f, 0.848633f,
+ 0.860840f, 0.870605f, 0.880371f, 0.890137f, 0.898926f, 0.907227f, 0.915527f, 0.923340f, 0.929688f, 0.936523f, 0.972168f, 0.973145f,
+ 0.972656f, 0.972168f, 0.970703f, 0.969727f, 0.002064f, 0.006584f, 0.011154f, 0.016266f, 0.022263f, 0.028397f, 0.034973f, 0.042145f,
+ 0.050232f, 0.059235f, 0.069031f, 0.079346f, 0.091736f, 0.104553f, 0.118652f, 0.133789f, 0.150635f, 0.168457f, 0.188110f, 0.208984f,
+ 0.230225f, 0.253906f, 0.278076f, 0.303955f, 0.329346f, 0.356689f, 0.384033f, 0.411865f, 0.439941f, 0.467285f, 0.493896f, 0.520996f,
+ 0.547363f, 0.573730f, 0.597168f, 0.622559f, 0.645508f, 0.667969f, 0.688965f, 0.709473f, 0.728027f, 0.746094f, 0.762695f, 0.778809f,
+ 0.794922f, 0.809082f, 0.822754f, 0.834961f, 0.847168f, 0.858887f, 0.870117f, 0.880371f, 0.889648f, 0.898926f, 0.907227f, 0.915039f,
+ 0.923828f, 0.930176f, 0.970215f, 0.971680f, 0.970215f, 0.970215f, 0.968750f, 0.968262f, 0.001935f, 0.005634f, 0.010078f, 0.014389f,
+ 0.019669f, 0.024658f, 0.030716f, 0.037201f, 0.044098f, 0.051941f, 0.060333f, 0.070129f, 0.080383f, 0.091370f, 0.103638f, 0.116943f,
+ 0.131714f, 0.148193f, 0.165161f, 0.183838f, 0.203979f, 0.225220f, 0.247803f, 0.271240f, 0.296631f, 0.322510f, 0.349121f, 0.376221f,
+ 0.403076f, 0.431152f, 0.458984f, 0.485596f, 0.513672f, 0.540039f, 0.564941f, 0.590820f, 0.616211f, 0.638672f, 0.662109f, 0.683105f,
+ 0.704102f, 0.723633f, 0.741699f, 0.759766f, 0.776855f, 0.792480f, 0.807617f, 0.821777f, 0.833496f, 0.847168f, 0.858887f, 0.870117f,
+ 0.880859f, 0.889648f, 0.899414f, 0.908203f, 0.916992f, 0.924316f, 0.967285f, 0.968262f, 0.968750f, 0.968262f, 0.967285f, 0.966309f,
+ 0.001805f, 0.005119f, 0.009079f, 0.013023f, 0.017487f, 0.022278f, 0.027130f, 0.032684f, 0.038666f, 0.045959f, 0.052826f, 0.061401f,
+ 0.070801f, 0.080139f, 0.090698f, 0.102844f, 0.115845f, 0.130005f, 0.145264f, 0.162476f, 0.180176f, 0.199951f, 0.220459f, 0.242188f,
+ 0.265869f, 0.290283f, 0.315430f, 0.341309f, 0.368652f, 0.395752f, 0.423584f, 0.451416f, 0.479248f, 0.505859f, 0.532227f, 0.559082f,
+ 0.584961f, 0.609863f, 0.634277f, 0.656738f, 0.678711f, 0.700195f, 0.720703f, 0.738281f, 0.757324f, 0.774414f, 0.790527f, 0.805664f,
+ 0.820312f, 0.834473f, 0.846680f, 0.858887f, 0.869629f, 0.880859f, 0.890625f, 0.899902f, 0.909668f, 0.917969f, 0.964844f, 0.966797f,
+ 0.967285f, 0.965820f, 0.964844f, 0.963867f, 0.001437f, 0.004662f, 0.007919f, 0.011681f, 0.015404f, 0.019272f, 0.024261f, 0.029205f,
+ 0.034515f, 0.040619f, 0.046967f, 0.054138f, 0.061737f, 0.070496f, 0.080200f, 0.090271f, 0.101807f, 0.114136f, 0.127686f, 0.143188f,
+ 0.159058f, 0.176514f, 0.195190f, 0.215454f, 0.237305f, 0.260010f, 0.283936f, 0.309326f, 0.334717f, 0.361328f, 0.389160f, 0.416260f,
+ 0.444336f, 0.471436f, 0.499512f, 0.525879f, 0.552734f, 0.579590f, 0.604004f, 0.628906f, 0.651855f, 0.674805f, 0.696777f, 0.717773f,
+ 0.737305f, 0.755859f, 0.772949f, 0.789551f, 0.805664f, 0.819336f, 0.833984f, 0.847168f, 0.859375f, 0.871094f, 0.881836f, 0.892090f,
+ 0.902344f, 0.910156f, 0.962402f, 0.964355f, 0.964355f, 0.963867f, 0.962891f, 0.961914f, 0.001264f, 0.004036f, 0.007088f, 0.010170f,
+ 0.013672f, 0.017365f, 0.021423f, 0.025955f, 0.030533f, 0.035614f, 0.041321f, 0.047791f, 0.054626f, 0.062195f, 0.070679f, 0.080017f,
+ 0.089600f, 0.100769f, 0.112854f, 0.125977f, 0.139893f, 0.156128f, 0.172852f, 0.191650f, 0.211060f, 0.232056f, 0.254883f, 0.278076f,
+ 0.302979f, 0.328125f, 0.355225f, 0.381836f, 0.409912f, 0.437256f, 0.464844f, 0.492676f, 0.520508f, 0.547852f, 0.573242f, 0.599609f,
+ 0.625000f, 0.649414f, 0.672363f, 0.694336f, 0.714844f, 0.734863f, 0.753418f, 0.771484f, 0.788574f, 0.804688f, 0.820312f, 0.833496f,
+ 0.847656f, 0.859863f, 0.873047f, 0.883301f, 0.894043f, 0.903809f, 0.959961f, 0.961914f, 0.962402f, 0.960938f, 0.960449f, 0.959961f,
+ 0.001297f, 0.003721f, 0.006397f, 0.009308f, 0.012260f, 0.015808f, 0.019302f, 0.023010f, 0.027267f, 0.032013f, 0.037109f, 0.042419f,
+ 0.048523f, 0.054962f, 0.061920f, 0.070435f, 0.079407f, 0.088318f, 0.099121f, 0.111084f, 0.124023f, 0.137695f, 0.152832f, 0.169434f,
+ 0.187378f, 0.206421f, 0.227783f, 0.249268f, 0.272461f, 0.297363f, 0.322754f, 0.348389f, 0.376221f, 0.403809f, 0.431396f, 0.459229f,
+ 0.487305f, 0.515137f, 0.542480f, 0.569336f, 0.595215f, 0.621094f, 0.645996f, 0.669434f, 0.691406f, 0.712891f, 0.733887f, 0.753418f,
+ 0.770996f, 0.789062f, 0.805176f, 0.820801f, 0.835449f, 0.849121f, 0.861328f, 0.874512f, 0.885742f, 0.895508f, 0.956543f, 0.959473f,
+ 0.958984f, 0.958984f, 0.958008f, 0.957031f, 0.001267f, 0.003481f, 0.005955f, 0.008568f, 0.011185f, 0.014030f, 0.017151f, 0.020294f,
+ 0.024246f, 0.028427f, 0.032654f, 0.037476f, 0.042603f, 0.048523f, 0.054871f, 0.062408f, 0.070129f, 0.078552f, 0.087769f, 0.097534f,
+ 0.109192f, 0.121399f, 0.135010f, 0.150513f, 0.165894f, 0.183960f, 0.202881f, 0.222656f, 0.244385f, 0.267334f, 0.291260f, 0.317139f,
+ 0.343506f, 0.370605f, 0.397949f, 0.426025f, 0.454346f, 0.482666f, 0.511230f, 0.538086f, 0.565918f, 0.592285f, 0.618164f, 0.642578f,
+ 0.667480f, 0.690918f, 0.711914f, 0.732910f, 0.752930f, 0.771484f, 0.790039f, 0.806641f, 0.821777f, 0.837402f, 0.850586f, 0.864746f,
+ 0.875977f, 0.887695f, 0.953613f, 0.956543f, 0.957031f, 0.956055f, 0.956055f, 0.955078f, 0.001068f, 0.003025f, 0.005283f, 0.007442f,
+ 0.009857f, 0.012665f, 0.015930f, 0.018570f, 0.021820f, 0.025314f, 0.028931f, 0.033325f, 0.038147f, 0.042908f, 0.049011f, 0.055176f,
+ 0.061859f, 0.069397f, 0.077637f, 0.086792f, 0.096252f, 0.107117f, 0.119385f, 0.132690f, 0.147095f, 0.162720f, 0.180054f, 0.198486f,
+ 0.218384f, 0.239990f, 0.262207f, 0.287109f, 0.311523f, 0.337891f, 0.364990f, 0.392822f, 0.420654f, 0.449219f, 0.478027f, 0.505859f,
+ 0.535156f, 0.562012f, 0.588867f, 0.615723f, 0.641602f, 0.666016f, 0.688965f, 0.711914f, 0.732910f, 0.753906f, 0.773438f, 0.791016f,
+ 0.808594f, 0.823730f, 0.839355f, 0.854004f, 0.867188f, 0.879883f, 0.950195f, 0.954102f, 0.954102f, 0.953125f, 0.952637f, 0.952148f,
+ 0.000884f, 0.003082f, 0.004631f, 0.006931f, 0.008942f, 0.011513f, 0.013779f, 0.016663f, 0.019806f, 0.022934f, 0.026215f, 0.029999f,
+ 0.033813f, 0.038544f, 0.043365f, 0.048615f, 0.054352f, 0.061005f, 0.068420f, 0.076477f, 0.085022f, 0.095032f, 0.105469f, 0.117432f,
+ 0.130127f, 0.143799f, 0.159790f, 0.176270f, 0.194580f, 0.214478f, 0.235229f, 0.257568f, 0.281982f, 0.306641f, 0.332764f, 0.359863f,
+ 0.388184f, 0.416016f, 0.445557f, 0.474854f, 0.502441f, 0.531738f, 0.559570f, 0.586914f, 0.614258f, 0.640625f, 0.665039f, 0.689453f,
+ 0.712891f, 0.734863f, 0.755371f, 0.774902f, 0.793945f, 0.810547f, 0.827637f, 0.842773f, 0.857910f, 0.871094f, 0.946777f, 0.950684f,
+ 0.951172f, 0.950684f, 0.949707f, 0.949707f, 0.000848f, 0.002630f, 0.004330f, 0.006386f, 0.008148f, 0.010437f, 0.012436f, 0.014977f,
+ 0.017731f, 0.020645f, 0.023529f, 0.026413f, 0.030289f, 0.034302f, 0.038391f, 0.043365f, 0.048737f, 0.054413f, 0.060455f, 0.067383f,
+ 0.075134f, 0.083801f, 0.093262f, 0.103821f, 0.114746f, 0.127441f, 0.140991f, 0.156372f, 0.172729f, 0.190918f, 0.210449f, 0.231201f,
+ 0.253662f, 0.277344f, 0.302734f, 0.328857f, 0.355225f, 0.384033f, 0.413086f, 0.440918f, 0.471191f, 0.500488f, 0.529785f, 0.558594f,
+ 0.586426f, 0.613770f, 0.640137f, 0.666016f, 0.689453f, 0.714355f, 0.736328f, 0.757812f, 0.777832f, 0.796875f, 0.813965f, 0.831543f,
+ 0.847168f, 0.860840f, 0.943848f, 0.948242f, 0.947754f, 0.948242f, 0.946777f, 0.946777f, 0.000747f, 0.002462f, 0.004192f, 0.005573f,
+ 0.007454f, 0.009430f, 0.011253f, 0.013588f, 0.015762f, 0.018112f, 0.020859f, 0.023758f, 0.027084f, 0.030426f, 0.034332f, 0.038635f,
+ 0.042999f, 0.048340f, 0.053772f, 0.060028f, 0.066589f, 0.074402f, 0.082764f, 0.091553f, 0.101685f, 0.112854f, 0.125122f, 0.138184f,
+ 0.153320f, 0.169556f, 0.187500f, 0.206543f, 0.227539f, 0.249512f, 0.273193f, 0.298340f, 0.324463f, 0.351562f, 0.379883f, 0.409424f,
+ 0.438477f, 0.468750f, 0.498047f, 0.527832f, 0.556641f, 0.585449f, 0.614258f, 0.641113f, 0.666992f, 0.692383f, 0.716309f, 0.738281f,
+ 0.760742f, 0.780273f, 0.799805f, 0.818848f, 0.834473f, 0.851074f, 0.939941f, 0.944824f, 0.944336f, 0.944336f, 0.944336f, 0.943359f,
+ 0.000670f, 0.002079f, 0.003538f, 0.005146f, 0.006508f, 0.008247f, 0.010223f, 0.012260f, 0.014153f, 0.016479f, 0.018677f, 0.021515f,
+ 0.024323f, 0.027313f, 0.030518f, 0.034302f, 0.038422f, 0.042725f, 0.047760f, 0.053101f, 0.059113f, 0.065613f, 0.072937f, 0.080444f,
+ 0.089722f, 0.099426f, 0.110596f, 0.122314f, 0.135742f, 0.150513f, 0.166260f, 0.183716f, 0.202759f, 0.223633f, 0.245728f, 0.269287f,
+ 0.294189f, 0.320557f, 0.348633f, 0.376709f, 0.406494f, 0.436523f, 0.467285f, 0.497070f, 0.528320f, 0.557129f, 0.586426f, 0.614746f,
+ 0.642090f, 0.668945f, 0.694824f, 0.718750f, 0.742676f, 0.764648f, 0.786133f, 0.805176f, 0.823242f, 0.840820f, 0.936035f, 0.940918f,
+ 0.941406f, 0.941406f, 0.940430f, 0.939941f, 0.000645f, 0.001963f, 0.003384f, 0.004719f, 0.006042f, 0.007614f, 0.009384f, 0.011192f,
+ 0.012665f, 0.015083f, 0.016861f, 0.019165f, 0.021393f, 0.024445f, 0.027451f, 0.030716f, 0.034149f, 0.038116f, 0.042389f, 0.047028f,
+ 0.052277f, 0.058014f, 0.064270f, 0.071289f, 0.079041f, 0.087830f, 0.097351f, 0.108337f, 0.119995f, 0.132812f, 0.147217f, 0.163452f,
+ 0.180420f, 0.199585f, 0.219849f, 0.242065f, 0.265625f, 0.291260f, 0.318115f, 0.345703f, 0.375000f, 0.404541f, 0.434326f, 0.465820f,
+ 0.496582f, 0.526855f, 0.557617f, 0.587402f, 0.616699f, 0.645508f, 0.672363f, 0.698242f, 0.723145f, 0.747559f, 0.770020f, 0.791504f,
+ 0.810059f, 0.828613f, 0.931641f, 0.937012f, 0.937500f, 0.937500f, 0.937012f, 0.936523f, 0.000692f, 0.001705f, 0.003000f, 0.004238f,
+ 0.005798f, 0.006805f, 0.008659f, 0.009933f, 0.011681f, 0.013191f, 0.015259f, 0.017166f, 0.019379f, 0.021729f, 0.024796f, 0.027328f,
+ 0.030380f, 0.033661f, 0.037598f, 0.041718f, 0.046539f, 0.051270f, 0.056946f, 0.062988f, 0.069885f, 0.077271f, 0.085999f, 0.095398f,
+ 0.105652f, 0.117859f, 0.129883f, 0.144409f, 0.159912f, 0.177002f, 0.196045f, 0.216553f, 0.239014f, 0.262451f, 0.288086f, 0.314941f,
+ 0.343262f, 0.372314f, 0.403076f, 0.433594f, 0.465332f, 0.496826f, 0.527832f, 0.559082f, 0.589355f, 0.619629f, 0.648926f, 0.676758f,
+ 0.703125f, 0.728516f, 0.752930f, 0.775391f, 0.797363f, 0.817871f, 0.927246f, 0.933105f, 0.934082f, 0.933594f, 0.933594f, 0.933105f,
+ 0.000460f, 0.001622f, 0.002705f, 0.003983f, 0.004925f, 0.006363f, 0.007652f, 0.008965f, 0.010521f, 0.011963f, 0.013664f, 0.015480f,
+ 0.017258f, 0.019440f, 0.021912f, 0.024338f, 0.027084f, 0.030212f, 0.033356f, 0.037018f, 0.040833f, 0.045380f, 0.050110f, 0.055573f,
+ 0.061829f, 0.068359f, 0.075928f, 0.083984f, 0.093140f, 0.103333f, 0.115112f, 0.127441f, 0.141602f, 0.156982f, 0.174316f, 0.192871f,
+ 0.213257f, 0.235596f, 0.259766f, 0.285400f, 0.312256f, 0.341797f, 0.371094f, 0.402100f, 0.434082f, 0.465332f, 0.497314f, 0.529297f,
+ 0.562012f, 0.592773f, 0.623535f, 0.652832f, 0.681641f, 0.709473f, 0.735352f, 0.759766f, 0.783203f, 0.803711f, 0.922363f, 0.929199f,
+ 0.929688f, 0.929199f, 0.929688f, 0.928711f, 0.000341f, 0.001686f, 0.002537f, 0.003769f, 0.004745f, 0.005764f, 0.007034f, 0.008286f,
+ 0.009369f, 0.010742f, 0.012161f, 0.013931f, 0.015671f, 0.017563f, 0.019440f, 0.021851f, 0.024231f, 0.026672f, 0.029556f, 0.032776f,
+ 0.036255f, 0.040283f, 0.044464f, 0.049194f, 0.054413f, 0.060059f, 0.066589f, 0.074036f, 0.081909f, 0.091187f, 0.100769f, 0.112000f,
+ 0.124512f, 0.139038f, 0.154297f, 0.171265f, 0.189819f, 0.210571f, 0.232788f, 0.257324f, 0.283203f, 0.311035f, 0.339844f, 0.370850f,
+ 0.402100f, 0.433838f, 0.466797f, 0.499268f, 0.532227f, 0.565430f, 0.598145f, 0.628418f, 0.659180f, 0.687988f, 0.715820f, 0.742188f,
+ 0.767090f, 0.791504f, 0.917969f, 0.924805f, 0.925293f, 0.925293f, 0.924805f, 0.924805f, 0.000405f, 0.001282f, 0.002298f, 0.003269f,
+ 0.004448f, 0.005043f, 0.006294f, 0.007233f, 0.008606f, 0.009727f, 0.010849f, 0.012421f, 0.013885f, 0.015465f, 0.017426f, 0.019394f,
+ 0.021667f, 0.023819f, 0.026154f, 0.029175f, 0.032227f, 0.035706f, 0.039062f, 0.043427f, 0.047913f, 0.052856f, 0.058502f, 0.064880f,
+ 0.071960f, 0.079895f, 0.088867f, 0.098633f, 0.109619f, 0.122192f, 0.135742f, 0.151489f, 0.168457f, 0.187134f, 0.207764f, 0.230835f,
+ 0.254883f, 0.281494f, 0.310059f, 0.339355f, 0.370361f, 0.402588f, 0.435547f, 0.468994f, 0.502930f, 0.537109f, 0.569824f, 0.602051f,
+ 0.634766f, 0.665527f, 0.695801f, 0.724121f, 0.750488f, 0.776855f, 0.912598f, 0.919434f, 0.920410f, 0.920410f, 0.919922f, 0.920410f,
+ 0.000529f, 0.001217f, 0.002171f, 0.003035f, 0.003790f, 0.004784f, 0.005711f, 0.006756f, 0.007782f, 0.008987f, 0.009773f, 0.011185f,
+ 0.012650f, 0.013771f, 0.015656f, 0.017181f, 0.018890f, 0.021057f, 0.023239f, 0.025848f, 0.028488f, 0.031525f, 0.034607f, 0.038147f,
+ 0.042023f, 0.046539f, 0.051605f, 0.056793f, 0.063049f, 0.069946f, 0.078064f, 0.086548f, 0.096313f, 0.107117f, 0.119446f, 0.133301f,
+ 0.148560f, 0.165405f, 0.184570f, 0.205811f, 0.228394f, 0.253174f, 0.280029f, 0.308594f, 0.339111f, 0.370605f, 0.404053f, 0.437988f,
+ 0.471680f, 0.506348f, 0.541504f, 0.576172f, 0.609375f, 0.642578f, 0.674316f, 0.705078f, 0.734375f, 0.761719f, 0.907227f, 0.914062f,
+ 0.915527f, 0.915527f, 0.916016f, 0.915039f, 0.000402f, 0.001247f, 0.001841f, 0.002651f, 0.003414f, 0.004200f, 0.005337f, 0.005821f,
+ 0.006733f, 0.008041f, 0.008942f, 0.010201f, 0.011261f, 0.012749f, 0.013893f, 0.015472f, 0.016663f, 0.018829f, 0.020615f, 0.022873f,
+ 0.025299f, 0.027893f, 0.030533f, 0.033600f, 0.037140f, 0.040924f, 0.044983f, 0.049927f, 0.055359f, 0.061340f, 0.068176f, 0.075500f,
+ 0.084106f, 0.093933f, 0.104370f, 0.116638f, 0.130249f, 0.145996f, 0.162842f, 0.181885f, 0.203735f, 0.226562f, 0.251465f, 0.279297f,
+ 0.308594f, 0.339355f, 0.373047f, 0.406982f, 0.440918f, 0.477051f, 0.511719f, 0.548340f, 0.583496f, 0.618164f, 0.652344f, 0.684570f,
+ 0.715332f, 0.745605f, 0.901855f, 0.909180f, 0.910156f, 0.910645f, 0.910156f, 0.910156f, 0.000371f, 0.001090f, 0.001752f, 0.002409f,
+ 0.003042f, 0.003963f, 0.004898f, 0.005295f, 0.006077f, 0.006992f, 0.008102f, 0.009338f, 0.010101f, 0.011078f, 0.012375f, 0.013718f,
+ 0.015099f, 0.016403f, 0.018402f, 0.020203f, 0.022354f, 0.024475f, 0.026825f, 0.029388f, 0.032623f, 0.035522f, 0.039429f, 0.043762f,
+ 0.048462f, 0.053558f, 0.059265f, 0.065552f, 0.073120f, 0.081787f, 0.091431f, 0.102112f, 0.114136f, 0.127930f, 0.143066f, 0.160767f,
+ 0.179810f, 0.200928f, 0.224854f, 0.250732f, 0.279053f, 0.308838f, 0.340820f, 0.374756f, 0.410156f, 0.446045f, 0.482666f, 0.520020f,
+ 0.556152f, 0.593262f, 0.628906f, 0.663574f, 0.695801f, 0.728027f, 0.895508f, 0.903809f, 0.904297f, 0.904297f, 0.904297f, 0.904785f,
+ 0.000425f, 0.000937f, 0.001529f, 0.002129f, 0.002674f, 0.003696f, 0.004257f, 0.004990f, 0.005726f, 0.006161f, 0.007118f, 0.007919f,
+ 0.009109f, 0.009941f, 0.011055f, 0.011993f, 0.013191f, 0.014832f, 0.016281f, 0.017868f, 0.019562f, 0.021362f, 0.023514f, 0.025909f,
+ 0.028549f, 0.031189f, 0.034637f, 0.037994f, 0.042145f, 0.046570f, 0.051453f, 0.057129f, 0.063965f, 0.070984f, 0.079285f, 0.088806f,
+ 0.099426f, 0.111267f, 0.125366f, 0.140747f, 0.158203f, 0.178101f, 0.199585f, 0.223755f, 0.250732f, 0.279297f, 0.310059f, 0.343994f,
+ 0.377686f, 0.414307f, 0.451904f, 0.489258f, 0.527832f, 0.565918f, 0.603027f, 0.640137f, 0.675781f, 0.710449f, 0.888672f, 0.897461f,
+ 0.899902f, 0.900391f, 0.899414f, 0.899414f, 0.000317f, 0.000823f, 0.001386f, 0.002108f, 0.002684f, 0.003239f, 0.003883f, 0.004303f,
+ 0.004730f, 0.005569f, 0.006626f, 0.007214f, 0.008003f, 0.008865f, 0.009590f, 0.010948f, 0.011856f, 0.012871f, 0.014381f, 0.015640f,
+ 0.017075f, 0.018799f, 0.020569f, 0.022537f, 0.024704f, 0.027405f, 0.030090f, 0.033142f, 0.036346f, 0.040436f, 0.044830f, 0.049835f,
+ 0.055450f, 0.061584f, 0.068665f, 0.076904f, 0.086060f, 0.096741f, 0.109192f, 0.122559f, 0.138428f, 0.155762f, 0.176270f, 0.198242f,
+ 0.223145f, 0.250244f, 0.280518f, 0.312500f, 0.346680f, 0.382324f, 0.420410f, 0.458740f, 0.498779f, 0.538086f, 0.577637f, 0.616211f,
+ 0.654297f, 0.690918f, 0.881348f, 0.890625f, 0.892578f, 0.893066f, 0.893066f, 0.892578f, 0.000385f, 0.000766f, 0.001544f, 0.001925f,
+ 0.002359f, 0.002947f, 0.003176f, 0.003691f, 0.004288f, 0.005215f, 0.005917f, 0.006214f, 0.007019f, 0.007843f, 0.008469f, 0.009598f,
+ 0.010345f, 0.011559f, 0.012497f, 0.013634f, 0.014992f, 0.016373f, 0.017853f, 0.019608f, 0.021515f, 0.023788f, 0.026260f, 0.028931f,
+ 0.031860f, 0.034912f, 0.038635f, 0.042633f, 0.047638f, 0.053070f, 0.059540f, 0.066284f, 0.074524f, 0.083679f, 0.094177f, 0.106445f,
+ 0.120361f, 0.135620f, 0.154053f, 0.174072f, 0.197144f, 0.222900f, 0.251221f, 0.281982f, 0.315430f, 0.351318f, 0.388672f, 0.427734f,
+ 0.468506f, 0.508301f, 0.549805f, 0.591309f, 0.631348f, 0.670410f, 0.874512f, 0.884766f, 0.885742f, 0.886230f, 0.886230f, 0.886230f,
+ 0.000230f, 0.000832f, 0.001281f, 0.001865f, 0.002207f, 0.002605f, 0.003212f, 0.003284f, 0.004124f, 0.004597f, 0.005222f, 0.005703f,
+ 0.006260f, 0.007095f, 0.007790f, 0.008377f, 0.009010f, 0.010078f, 0.011009f, 0.011925f, 0.013153f, 0.014282f, 0.015610f, 0.017151f,
+ 0.018951f, 0.020416f, 0.022583f, 0.024826f, 0.027328f, 0.030136f, 0.033508f, 0.036835f, 0.040985f, 0.045410f, 0.050812f, 0.056854f,
+ 0.063965f, 0.071777f, 0.081177f, 0.091858f, 0.103699f, 0.117615f, 0.133423f, 0.152588f, 0.172974f, 0.196777f, 0.222900f, 0.252686f,
+ 0.284912f, 0.319824f, 0.356934f, 0.395996f, 0.436768f, 0.478516f, 0.521484f, 0.564453f, 0.607422f, 0.649414f, 0.866699f, 0.876953f,
+ 0.877930f, 0.879395f, 0.879883f, 0.878418f, 0.000228f, 0.000734f, 0.000993f, 0.001416f, 0.001935f, 0.002293f, 0.002541f, 0.003174f,
+ 0.003508f, 0.004040f, 0.004337f, 0.005039f, 0.005505f, 0.006054f, 0.006840f, 0.007366f, 0.008041f, 0.008644f, 0.009544f, 0.010460f,
+ 0.011238f, 0.012329f, 0.013542f, 0.014755f, 0.016083f, 0.017624f, 0.019424f, 0.021408f, 0.023422f, 0.025803f, 0.028366f, 0.031311f,
+ 0.034912f, 0.039124f, 0.043304f, 0.048492f, 0.054291f, 0.061188f, 0.069397f, 0.078552f, 0.089233f, 0.101074f, 0.115540f, 0.131226f,
+ 0.150757f, 0.172119f, 0.196533f, 0.224243f, 0.254883f, 0.288574f, 0.324707f, 0.364014f, 0.405029f, 0.447510f, 0.491699f, 0.536133f,
+ 0.581543f, 0.627441f, 0.858398f, 0.869141f, 0.870605f, 0.871582f, 0.871094f, 0.871582f, 0.000118f, 0.000713f, 0.000985f, 0.001328f,
+ 0.001612f, 0.001999f, 0.002399f, 0.002913f, 0.003139f, 0.003567f, 0.004055f, 0.004406f, 0.004986f, 0.005226f, 0.005856f, 0.006332f,
+ 0.007042f, 0.007553f, 0.008286f, 0.009064f, 0.009834f, 0.010696f, 0.011658f, 0.012726f, 0.013817f, 0.015289f, 0.016693f, 0.018265f,
+ 0.019699f, 0.021835f, 0.024307f, 0.026642f, 0.029770f, 0.033234f, 0.037048f, 0.041351f, 0.046478f, 0.052032f, 0.058960f, 0.066589f,
+ 0.075745f, 0.086182f, 0.099121f, 0.113037f, 0.129517f, 0.149048f, 0.171387f, 0.196899f, 0.225464f, 0.257812f, 0.293457f, 0.331787f,
+ 0.373291f, 0.416748f, 0.460938f, 0.507812f, 0.554688f, 0.602051f, 0.849609f, 0.859863f, 0.862793f, 0.863281f, 0.862793f, 0.862793f,
+ 0.000211f, 0.000522f, 0.000877f, 0.001204f, 0.001507f, 0.001724f, 0.002062f, 0.002426f, 0.002867f, 0.003157f, 0.003443f, 0.003752f,
+ 0.004192f, 0.004753f, 0.005154f, 0.005428f, 0.006065f, 0.006546f, 0.007210f, 0.007725f, 0.008530f, 0.009247f, 0.010025f, 0.010887f,
+ 0.011909f, 0.012970f, 0.014069f, 0.015335f, 0.017105f, 0.018433f, 0.020554f, 0.022552f, 0.025116f, 0.027802f, 0.031158f, 0.034485f,
+ 0.038971f, 0.044037f, 0.049469f, 0.055847f, 0.063843f, 0.072815f, 0.083618f, 0.095947f, 0.110840f, 0.128174f, 0.147949f, 0.171387f,
+ 0.198242f, 0.228271f, 0.262207f, 0.299805f, 0.340332f, 0.384277f, 0.430176f, 0.477295f, 0.527344f, 0.577637f, 0.839844f, 0.851074f,
+ 0.853516f, 0.854492f, 0.854980f, 0.854980f, 0.000218f, 0.000479f, 0.000706f, 0.001109f, 0.001245f, 0.001763f, 0.001800f, 0.002211f,
+ 0.002377f, 0.002783f, 0.003103f, 0.003223f, 0.003782f, 0.004089f, 0.004326f, 0.004711f, 0.005306f, 0.005569f, 0.006199f, 0.006653f,
+ 0.007168f, 0.007919f, 0.008560f, 0.009254f, 0.009979f, 0.010872f, 0.012054f, 0.012810f, 0.014221f, 0.015793f, 0.017181f, 0.018967f,
+ 0.021088f, 0.023361f, 0.026001f, 0.028915f, 0.032257f, 0.036469f, 0.040924f, 0.046875f, 0.053375f, 0.061218f, 0.070435f, 0.080811f,
+ 0.093628f, 0.108704f, 0.126709f, 0.147461f, 0.172241f, 0.199951f, 0.232788f, 0.268799f, 0.308594f, 0.351562f, 0.397705f, 0.447266f,
+ 0.498291f, 0.550293f, 0.830078f, 0.841797f, 0.843750f, 0.845215f, 0.845215f, 0.845703f, 0.000139f, 0.000379f, 0.000704f, 0.000896f,
+ 0.001095f, 0.001392f, 0.001649f, 0.002058f, 0.002235f, 0.002483f, 0.002621f, 0.002878f, 0.003214f, 0.003580f, 0.003820f, 0.004055f,
+ 0.004498f, 0.004791f, 0.005173f, 0.005692f, 0.006145f, 0.006691f, 0.007175f, 0.007874f, 0.008499f, 0.009239f, 0.010117f, 0.011032f,
+ 0.011864f, 0.012901f, 0.014282f, 0.015701f, 0.017242f, 0.019516f, 0.021469f, 0.024002f, 0.026749f, 0.029953f, 0.034027f, 0.038727f,
+ 0.044250f, 0.050568f, 0.058136f, 0.067139f, 0.078247f, 0.091614f, 0.106689f, 0.125366f, 0.147339f, 0.172974f, 0.202881f, 0.237671f,
+ 0.275879f, 0.318359f, 0.365234f, 0.415283f, 0.468018f, 0.521973f, 0.819336f, 0.832031f, 0.834473f, 0.834961f, 0.835449f, 0.835938f,
+ 0.000115f, 0.000396f, 0.000688f, 0.000885f, 0.000917f, 0.001393f, 0.001478f, 0.001590f, 0.001944f, 0.002123f, 0.002291f, 0.002644f,
+ 0.002666f, 0.003023f, 0.003197f, 0.003546f, 0.003714f, 0.004246f, 0.004551f, 0.004837f, 0.005108f, 0.005577f, 0.006054f, 0.006504f,
+ 0.007023f, 0.007633f, 0.008362f, 0.009148f, 0.009926f, 0.010742f, 0.011917f, 0.013062f, 0.014351f, 0.015991f, 0.017639f, 0.019455f,
+ 0.021729f, 0.024689f, 0.027740f, 0.031708f, 0.036102f, 0.041260f, 0.047882f, 0.055450f, 0.064392f, 0.075500f, 0.088928f, 0.104797f,
+ 0.124756f, 0.147949f, 0.175415f, 0.207275f, 0.244507f, 0.286133f, 0.332520f, 0.381836f, 0.436279f, 0.492432f, 0.808105f, 0.821289f,
+ 0.822754f, 0.824707f, 0.825195f, 0.824219f, 0.000209f, 0.000435f, 0.000493f, 0.000669f, 0.001040f, 0.001076f, 0.001254f, 0.001398f,
+ 0.001603f, 0.001697f, 0.001987f, 0.002140f, 0.002268f, 0.002472f, 0.002769f, 0.002991f, 0.003302f, 0.003572f, 0.003685f, 0.004002f,
+ 0.004337f, 0.004654f, 0.005062f, 0.005379f, 0.005871f, 0.006363f, 0.006733f, 0.007416f, 0.008102f, 0.008812f, 0.009727f, 0.010689f,
+ 0.011566f, 0.013145f, 0.014053f, 0.015762f, 0.017899f, 0.020096f, 0.022552f, 0.025528f, 0.028992f, 0.033325f, 0.038635f, 0.044952f,
+ 0.052582f, 0.061554f, 0.072998f, 0.086670f, 0.103577f, 0.124329f, 0.148804f, 0.178467f, 0.213501f, 0.253174f, 0.298828f, 0.348877f,
+ 0.403076f, 0.461914f, 0.795898f, 0.809570f, 0.812012f, 0.813477f, 0.813477f, 0.814453f, 0.000243f, 0.000322f, 0.000466f, 0.000710f,
+ 0.000863f, 0.000942f, 0.001051f, 0.001182f, 0.001369f, 0.001451f, 0.001716f, 0.001851f, 0.001968f, 0.002192f, 0.002323f, 0.002470f,
+ 0.002773f, 0.002850f, 0.003056f, 0.003399f, 0.003624f, 0.003832f, 0.004192f, 0.004467f, 0.004955f, 0.005276f, 0.005772f, 0.006084f,
+ 0.006672f, 0.007191f, 0.007828f, 0.008720f, 0.009575f, 0.010292f, 0.011505f, 0.012535f, 0.014114f, 0.016006f, 0.017838f, 0.020462f,
+ 0.023193f, 0.026489f, 0.030807f, 0.035858f, 0.041840f, 0.049652f, 0.059174f, 0.070435f, 0.084839f, 0.102783f, 0.124146f, 0.151489f,
+ 0.183472f, 0.221802f, 0.265137f, 0.315186f, 0.369629f, 0.430664f, 0.782715f, 0.796875f, 0.799805f, 0.800293f, 0.801758f, 0.801758f,
+ 0.000119f, 0.000369f, 0.000340f, 0.000595f, 0.000667f, 0.000841f, 0.001010f, 0.001086f, 0.001179f, 0.001225f, 0.001494f, 0.001555f,
+ 0.001654f, 0.001754f, 0.001965f, 0.002142f, 0.002197f, 0.002432f, 0.002619f, 0.002811f, 0.003021f, 0.003139f, 0.003567f, 0.003708f,
+ 0.004066f, 0.004360f, 0.004612f, 0.005123f, 0.005489f, 0.005878f, 0.006306f, 0.006824f, 0.007576f, 0.008286f, 0.008949f, 0.010155f,
+ 0.011322f, 0.012756f, 0.014046f, 0.015976f, 0.018250f, 0.020874f, 0.024094f, 0.027878f, 0.032867f, 0.039154f, 0.046509f, 0.055908f,
+ 0.068054f, 0.082886f, 0.102356f, 0.125732f, 0.155029f, 0.190674f, 0.232422f, 0.281006f, 0.335693f, 0.397949f, 0.770020f, 0.783691f,
+ 0.786621f, 0.787598f, 0.788086f, 0.789551f, 0.000000f, 0.000220f, 0.000275f, 0.000562f, 0.000618f, 0.000683f, 0.000733f, 0.000761f,
+ 0.000966f, 0.001022f, 0.001184f, 0.001237f, 0.001382f, 0.001552f, 0.001688f, 0.001724f, 0.001918f, 0.002024f, 0.002115f, 0.002243f,
+ 0.002403f, 0.002718f, 0.002840f, 0.003052f, 0.003330f, 0.003508f, 0.003860f, 0.004097f, 0.004314f, 0.004719f, 0.005074f, 0.005535f,
+ 0.006058f, 0.006584f, 0.007168f, 0.007874f, 0.008759f, 0.009651f, 0.011086f, 0.012459f, 0.013992f, 0.015945f, 0.018433f, 0.021408f,
+ 0.025192f, 0.029861f, 0.035950f, 0.043396f, 0.053406f, 0.065735f, 0.082031f, 0.102234f, 0.128052f, 0.160645f, 0.200073f, 0.247192f,
+ 0.301025f, 0.363281f, 0.755371f, 0.770996f, 0.772949f, 0.773926f, 0.775879f, 0.775879f, 0.000216f, 0.000102f, 0.000381f, 0.000487f,
+ 0.000429f, 0.000552f, 0.000579f, 0.000788f, 0.000804f, 0.000854f, 0.000937f, 0.000996f, 0.001078f, 0.001218f, 0.001315f, 0.001499f,
+ 0.001532f, 0.001642f, 0.001805f, 0.001825f, 0.002077f, 0.002178f, 0.002312f, 0.002396f, 0.002575f, 0.002735f, 0.002947f, 0.003317f,
+ 0.003428f, 0.003721f, 0.004185f, 0.004379f, 0.004704f, 0.005253f, 0.005650f, 0.006145f, 0.006870f, 0.007515f, 0.008415f, 0.009430f,
+ 0.010612f, 0.012093f, 0.013954f, 0.016052f, 0.018967f, 0.022476f, 0.027115f, 0.032898f, 0.040649f, 0.050690f, 0.063599f, 0.080811f,
+ 0.103210f, 0.132202f, 0.168823f, 0.213501f, 0.266602f, 0.329102f, 0.740234f, 0.756348f, 0.758789f, 0.760254f, 0.761230f, 0.761230f,
+ 0.000179f, 0.000181f, 0.000180f, 0.000289f, 0.000413f, 0.000458f, 0.000497f, 0.000620f, 0.000646f, 0.000688f, 0.000830f, 0.000868f,
+ 0.000904f, 0.000981f, 0.001024f, 0.001178f, 0.001146f, 0.001302f, 0.001382f, 0.001523f, 0.001679f, 0.001737f, 0.001824f, 0.001959f,
+ 0.002195f, 0.002283f, 0.002438f, 0.002579f, 0.002703f, 0.002939f, 0.003181f, 0.003454f, 0.003677f, 0.004051f, 0.004395f, 0.004738f,
+ 0.005283f, 0.005783f, 0.006420f, 0.007095f, 0.007988f, 0.009094f, 0.010384f, 0.011955f, 0.013939f, 0.016434f, 0.019836f, 0.024292f,
+ 0.030029f, 0.037659f, 0.048065f, 0.061890f, 0.080811f, 0.105774f, 0.138672f, 0.180542f, 0.231934f, 0.293213f, 0.724121f, 0.740234f,
+ 0.744141f, 0.745117f, 0.745605f, 0.746094f, 0.000000f, 0.000056f, 0.000263f, 0.000339f, 0.000369f, 0.000357f, 0.000376f, 0.000508f,
+ 0.000519f, 0.000558f, 0.000581f, 0.000678f, 0.000767f, 0.000775f, 0.000905f, 0.000849f, 0.000992f, 0.000942f, 0.001192f, 0.001169f,
+ 0.001204f, 0.001375f, 0.001439f, 0.001532f, 0.001634f, 0.001676f, 0.001799f, 0.001904f, 0.002165f, 0.002262f, 0.002377f, 0.002611f,
+ 0.002836f, 0.003103f, 0.003321f, 0.003550f, 0.004005f, 0.004356f, 0.004772f, 0.005295f, 0.005962f, 0.006756f, 0.007690f, 0.008690f,
+ 0.010078f, 0.011871f, 0.014252f, 0.017242f, 0.021393f, 0.027100f, 0.034851f, 0.046051f, 0.060455f, 0.081848f, 0.110474f, 0.148682f,
+ 0.197632f, 0.257568f, 0.706543f, 0.724121f, 0.727539f, 0.729492f, 0.729980f, 0.729492f, 0.000000f, 0.000130f, 0.000174f, 0.000312f,
+ 0.000290f, 0.000293f, 0.000372f, 0.000319f, 0.000397f, 0.000433f, 0.000550f, 0.000552f, 0.000564f, 0.000593f, 0.000638f, 0.000758f,
+ 0.000784f, 0.000797f, 0.000842f, 0.000937f, 0.001011f, 0.001068f, 0.001125f, 0.001231f, 0.001228f, 0.001288f, 0.001409f, 0.001465f,
+ 0.001644f, 0.001697f, 0.001965f, 0.001924f, 0.002136f, 0.002270f, 0.002436f, 0.002697f, 0.002916f, 0.003202f, 0.003492f, 0.003929f,
+ 0.004391f, 0.004887f, 0.005516f, 0.006233f, 0.007240f, 0.008461f, 0.010094f, 0.012070f, 0.014854f, 0.018585f, 0.024338f, 0.032379f,
+ 0.043884f, 0.060516f, 0.084656f, 0.118469f, 0.164185f, 0.222168f, 0.689941f, 0.708008f, 0.710449f, 0.711914f, 0.712891f, 0.712402f,
+ 0.000000f, 0.000000f, 0.000122f, 0.000226f, 0.000145f, 0.000282f, 0.000255f, 0.000247f, 0.000323f, 0.000389f, 0.000379f, 0.000435f,
+ 0.000461f, 0.000509f, 0.000535f, 0.000517f, 0.000557f, 0.000604f, 0.000649f, 0.000690f, 0.000757f, 0.000773f, 0.000836f, 0.000865f,
+ 0.000924f, 0.000957f, 0.001095f, 0.001104f, 0.001243f, 0.001361f, 0.001458f, 0.001486f, 0.001619f, 0.001745f, 0.001791f, 0.001993f,
+ 0.002100f, 0.002321f, 0.002539f, 0.002771f, 0.003084f, 0.003412f, 0.003866f, 0.004368f, 0.005062f, 0.005821f, 0.006882f, 0.008278f,
+ 0.010071f, 0.012756f, 0.016327f, 0.021774f, 0.029785f, 0.042206f, 0.061462f, 0.090149f, 0.131348f, 0.187378f, 0.669434f, 0.688965f,
+ 0.692383f, 0.694824f, 0.695801f, 0.695312f, 0.000000f, 0.000118f, 0.000113f, 0.000158f, 0.000158f, 0.000176f, 0.000224f, 0.000202f,
+ 0.000251f, 0.000260f, 0.000280f, 0.000332f, 0.000316f, 0.000365f, 0.000389f, 0.000419f, 0.000454f, 0.000435f, 0.000476f, 0.000494f,
+ 0.000516f, 0.000576f, 0.000609f, 0.000656f, 0.000678f, 0.000712f, 0.000792f, 0.000800f, 0.000852f, 0.000919f, 0.000961f, 0.001070f,
+ 0.001120f, 0.001238f, 0.001300f, 0.001480f, 0.001459f, 0.001634f, 0.001798f, 0.001947f, 0.002111f, 0.002377f, 0.002615f, 0.002966f,
+ 0.003410f, 0.003933f, 0.004585f, 0.005489f, 0.006706f, 0.008148f, 0.010757f, 0.013962f, 0.019257f, 0.027771f, 0.041931f, 0.065125f,
+ 0.101135f, 0.152832f, 0.650391f, 0.670898f, 0.674316f, 0.675293f, 0.675781f, 0.677246f, 0.000000f, 0.000000f, 0.000109f, 0.000106f,
+ 0.000121f, 0.000117f, 0.000130f, 0.000151f, 0.000161f, 0.000174f, 0.000234f, 0.000197f, 0.000205f, 0.000236f, 0.000272f, 0.000296f,
+ 0.000267f, 0.000296f, 0.000397f, 0.000344f, 0.000413f, 0.000395f, 0.000433f, 0.000434f, 0.000504f, 0.000488f, 0.000532f, 0.000550f,
+ 0.000602f, 0.000711f, 0.000675f, 0.000704f, 0.000752f, 0.000817f, 0.000896f, 0.000955f, 0.001009f, 0.001091f, 0.001223f, 0.001271f,
+ 0.001415f, 0.001560f, 0.001721f, 0.001989f, 0.002214f, 0.002508f, 0.002930f, 0.003504f, 0.004208f, 0.005169f, 0.006603f, 0.008606f,
+ 0.011864f, 0.017090f, 0.026367f, 0.043396f, 0.072571f, 0.119751f, 0.630859f, 0.650879f, 0.653809f, 0.656250f, 0.657227f, 0.657227f,
+ 0.000000f, 0.000111f, 0.000104f, 0.000100f, 0.000096f, 0.000094f, 0.000105f, 0.000096f, 0.000101f, 0.000115f, 0.000119f, 0.000155f,
+ 0.000129f, 0.000180f, 0.000186f, 0.000199f, 0.000208f, 0.000214f, 0.000232f, 0.000230f, 0.000237f, 0.000247f, 0.000303f, 0.000276f,
+ 0.000324f, 0.000332f, 0.000381f, 0.000371f, 0.000393f, 0.000428f, 0.000490f, 0.000468f, 0.000512f, 0.000540f, 0.000598f, 0.000670f,
+ 0.000673f, 0.000711f, 0.000767f, 0.000842f, 0.000894f, 0.000985f, 0.001120f, 0.001200f, 0.001416f, 0.001544f, 0.001768f, 0.002052f,
+ 0.002510f, 0.003044f, 0.003796f, 0.005016f, 0.006870f, 0.009918f, 0.015335f, 0.026077f, 0.048004f, 0.088745f, 0.610352f, 0.630859f,
+ 0.634277f, 0.636230f, 0.637207f, 0.638184f, 0.000000f, 0.000104f, 0.000098f, 0.000092f, 0.000087f, 0.000084f, 0.000081f, 0.000078f,
+ 0.000074f, 0.000070f, 0.000073f, 0.000075f, 0.000081f, 0.000081f, 0.000119f, 0.000124f, 0.000129f, 0.000115f, 0.000142f, 0.000169f,
+ 0.000155f, 0.000169f, 0.000172f, 0.000196f, 0.000209f, 0.000211f, 0.000203f, 0.000238f, 0.000245f, 0.000260f, 0.000282f, 0.000281f,
+ 0.000297f, 0.000333f, 0.000343f, 0.000374f, 0.000398f, 0.000428f, 0.000473f, 0.000494f, 0.000534f, 0.000591f, 0.000643f, 0.000708f,
+ 0.000790f, 0.000893f, 0.001040f, 0.001169f, 0.001381f, 0.001676f, 0.002123f, 0.002686f, 0.003658f, 0.005329f, 0.008347f, 0.014244f,
+ 0.027954f, 0.060638f, 0.587891f, 0.609375f, 0.613281f, 0.614746f, 0.616699f, 0.616211f, 0.000110f, 0.000094f, 0.000085f, 0.000079f,
+ 0.000075f, 0.000072f, 0.000069f, 0.000067f, 0.000065f, 0.000063f, 0.000059f, 0.000059f, 0.000054f, 0.000051f, 0.000055f, 0.000051f,
+ 0.000066f, 0.000066f, 0.000078f, 0.000074f, 0.000089f, 0.000091f, 0.000102f, 0.000109f, 0.000114f, 0.000126f, 0.000133f, 0.000130f,
+ 0.000141f, 0.000141f, 0.000156f, 0.000172f, 0.000180f, 0.000179f, 0.000206f, 0.000199f, 0.000214f, 0.000254f, 0.000247f, 0.000282f,
+ 0.000300f, 0.000324f, 0.000349f, 0.000374f, 0.000413f, 0.000459f, 0.000513f, 0.000619f, 0.000711f, 0.000823f, 0.001030f, 0.001269f,
+ 0.001724f, 0.002487f, 0.003948f, 0.007015f, 0.014122f, 0.036346f, 0.565430f, 0.586426f, 0.592285f, 0.592773f, 0.594238f, 0.594727f,
+ 0.000092f, 0.000073f, 0.000067f, 0.000062f, 0.000057f, 0.000055f, 0.000052f, 0.000052f, 0.000049f, 0.000049f, 0.000047f, 0.000046f,
+ 0.000046f, 0.000043f, 0.000041f, 0.000039f, 0.000038f, 0.000036f, 0.000039f, 0.000036f, 0.000039f, 0.000037f, 0.000039f, 0.000047f,
+ 0.000051f, 0.000057f, 0.000059f, 0.000060f, 0.000067f, 0.000071f, 0.000078f, 0.000085f, 0.000087f, 0.000091f, 0.000098f, 0.000095f,
+ 0.000102f, 0.000122f, 0.000122f, 0.000137f, 0.000143f, 0.000145f, 0.000168f, 0.000171f, 0.000197f, 0.000209f, 0.000234f, 0.000264f,
+ 0.000295f, 0.000349f, 0.000418f, 0.000520f, 0.000678f, 0.000958f, 0.001512f, 0.002745f, 0.006092f, 0.017456f, 0.542969f, 0.565430f,
+ 0.568848f, 0.569824f, 0.572266f, 0.572266f, 0.000052f, 0.000042f, 0.000037f, 0.000035f, 0.000033f, 0.000033f, 0.000032f, 0.000031f,
+ 0.000031f, 0.000029f, 0.000030f, 0.000030f, 0.000029f, 0.000028f, 0.000028f, 0.000028f, 0.000028f, 0.000028f, 0.000027f, 0.000026f,
+ 0.000024f, 0.000023f, 0.000022f, 0.000022f, 0.000021f, 0.000020f, 0.000019f, 0.000022f, 0.000020f, 0.000023f, 0.000024f, 0.000026f,
+ 0.000028f, 0.000035f, 0.000037f, 0.000038f, 0.000039f, 0.000043f, 0.000048f, 0.000050f, 0.000053f, 0.000055f, 0.000062f, 0.000059f,
+ 0.000072f, 0.000070f, 0.000087f, 0.000099f, 0.000100f, 0.000119f, 0.000142f, 0.000162f, 0.000217f, 0.000283f, 0.000425f, 0.000760f,
+ 0.001818f, 0.006405f, 0.519043f, 0.541504f, 0.546387f, 0.548828f, 0.549316f, 0.550781f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000004f, 0.000004f, 0.000006f, 0.000006f, 0.000008f, 0.000009f, 0.000009f, 0.000009f, 0.000010f,
+ 0.000010f, 0.000010f, 0.000011f, 0.000011f, 0.000011f, 0.000012f, 0.000012f, 0.000012f, 0.000012f, 0.000013f, 0.000012f, 0.000012f,
+ 0.000011f, 0.000011f, 0.000011f, 0.000010f, 0.000010f, 0.000009f, 0.000009f, 0.000008f, 0.000008f, 0.000008f, 0.000008f, 0.000011f,
+ 0.000011f, 0.000012f, 0.000015f, 0.000016f, 0.000016f, 0.000018f, 0.000018f, 0.000020f, 0.000022f, 0.000024f, 0.000028f, 0.000035f,
+ 0.000036f, 0.000052f, 0.000071f, 0.000117f, 0.000260f, 0.001269f, 0.495605f, 0.518555f, 0.523926f, 0.525879f, 0.526855f, 0.527344f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000001f, 0.000001f, 0.000001f, 0.000002f, 0.000002f, 0.000002f, 0.000003f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000002f,
+ 0.000002f, 0.000001f, 0.000001f, 0.000002f, 0.000002f, 0.000002f, 0.000003f, 0.000003f, 0.000005f, 0.000021f, 0.473145f, 0.495605f,
+ 0.500000f, 0.502441f, 0.503418f, 0.503906f,
+ },
+ {
+ 0.045868f, 0.130493f, 0.205322f, 0.272705f, 0.331787f, 0.384521f, 0.431885f, 0.473389f, 0.511719f, 0.545898f, 0.576660f, 0.605469f,
+ 0.631348f, 0.654785f, 0.676758f, 0.696289f, 0.714355f, 0.732422f, 0.749023f, 0.763184f, 0.777832f, 0.790527f, 0.802734f, 0.813477f,
+ 0.824219f, 0.834961f, 0.844238f, 0.853027f, 0.862305f, 0.869629f, 0.877441f, 0.884277f, 0.892090f, 0.898926f, 0.904297f, 0.910645f,
+ 0.916992f, 0.921875f, 0.926758f, 0.931641f, 0.937012f, 0.941406f, 0.945801f, 0.950195f, 0.954102f, 0.958496f, 0.962402f, 0.966309f,
+ 0.969238f, 0.973145f, 0.976074f, 0.979492f, 0.982422f, 0.985352f, 0.988281f, 0.991211f, 0.993652f, 0.996094f, 0.997070f, 0.993164f,
+ 0.990234f, 0.987305f, 0.984375f, 0.981445f, 0.033447f, 0.097717f, 0.160400f, 0.219238f, 0.273438f, 0.323486f, 0.371582f, 0.414062f,
+ 0.454834f, 0.491211f, 0.524414f, 0.555176f, 0.583984f, 0.610840f, 0.635254f, 0.658203f, 0.678223f, 0.697754f, 0.716309f, 0.732422f,
+ 0.749023f, 0.763184f, 0.776855f, 0.790527f, 0.802734f, 0.812988f, 0.824707f, 0.834473f, 0.844238f, 0.853516f, 0.862305f, 0.870117f,
+ 0.877930f, 0.884766f, 0.892090f, 0.897949f, 0.905762f, 0.910645f, 0.917480f, 0.923340f, 0.927734f, 0.933105f, 0.937988f, 0.942871f,
+ 0.947266f, 0.951172f, 0.955566f, 0.960449f, 0.963379f, 0.967285f, 0.970703f, 0.974609f, 0.978027f, 0.981445f, 0.984863f, 0.986816f,
+ 0.989746f, 0.993164f, 0.995605f, 0.992188f, 0.988770f, 0.986328f, 0.983398f, 0.980957f, 0.024796f, 0.075195f, 0.126221f, 0.176025f,
+ 0.224976f, 0.271729f, 0.317383f, 0.359375f, 0.399902f, 0.437744f, 0.472656f, 0.505371f, 0.536133f, 0.565430f, 0.591797f, 0.615723f,
+ 0.639648f, 0.660156f, 0.681152f, 0.699219f, 0.718262f, 0.734375f, 0.749512f, 0.764648f, 0.777832f, 0.791016f, 0.802734f, 0.813965f,
+ 0.825195f, 0.835449f, 0.844727f, 0.854004f, 0.862305f, 0.871094f, 0.878418f, 0.886230f, 0.893555f, 0.900391f, 0.906738f, 0.912598f,
+ 0.917969f, 0.923828f, 0.929688f, 0.935059f, 0.939941f, 0.943848f, 0.949219f, 0.953613f, 0.958008f, 0.961914f, 0.965332f, 0.969238f,
+ 0.972656f, 0.976074f, 0.979492f, 0.982910f, 0.986328f, 0.989258f, 0.993652f, 0.990723f, 0.987793f, 0.985352f, 0.982910f, 0.979980f,
+ 0.019119f, 0.058624f, 0.100220f, 0.142578f, 0.185303f, 0.227417f, 0.269287f, 0.310059f, 0.348877f, 0.385254f, 0.421875f, 0.455566f,
+ 0.489014f, 0.518555f, 0.546875f, 0.574707f, 0.598633f, 0.624023f, 0.645508f, 0.666016f, 0.684082f, 0.702637f, 0.720703f, 0.736816f,
+ 0.751465f, 0.766113f, 0.779785f, 0.792969f, 0.804199f, 0.815918f, 0.826660f, 0.836426f, 0.846191f, 0.855957f, 0.864746f, 0.872559f,
+ 0.880371f, 0.888184f, 0.895508f, 0.902344f, 0.908691f, 0.914062f, 0.919922f, 0.925293f, 0.932129f, 0.936035f, 0.941895f, 0.946289f,
+ 0.951172f, 0.955566f, 0.959473f, 0.963867f, 0.967773f, 0.970703f, 0.975586f, 0.978516f, 0.981934f, 0.985352f, 0.991699f, 0.988770f,
+ 0.986328f, 0.983887f, 0.981445f, 0.979004f, 0.015175f, 0.046997f, 0.080688f, 0.116028f, 0.152466f, 0.189819f, 0.227417f, 0.264404f,
+ 0.301758f, 0.338623f, 0.374268f, 0.407471f, 0.439941f, 0.471924f, 0.501465f, 0.529785f, 0.556641f, 0.582031f, 0.606445f, 0.629395f,
+ 0.649902f, 0.670898f, 0.688965f, 0.708496f, 0.725098f, 0.740723f, 0.755371f, 0.769531f, 0.782715f, 0.795410f, 0.807129f, 0.818848f,
+ 0.829590f, 0.839844f, 0.849121f, 0.857910f, 0.866699f, 0.875488f, 0.882812f, 0.890625f, 0.897461f, 0.904297f, 0.910645f, 0.916992f,
+ 0.922363f, 0.928223f, 0.933594f, 0.938477f, 0.944824f, 0.949707f, 0.953613f, 0.958008f, 0.962402f, 0.966309f, 0.970703f, 0.974121f,
+ 0.977539f, 0.981934f, 0.990234f, 0.987793f, 0.984863f, 0.982910f, 0.980469f, 0.978516f, 0.012215f, 0.038452f, 0.066101f, 0.095825f,
+ 0.126831f, 0.159180f, 0.192749f, 0.226685f, 0.260986f, 0.294922f, 0.328857f, 0.363037f, 0.394531f, 0.426270f, 0.457520f, 0.486572f,
+ 0.514648f, 0.541016f, 0.567871f, 0.590820f, 0.614746f, 0.636230f, 0.657227f, 0.676270f, 0.694336f, 0.711914f, 0.729492f, 0.744141f,
+ 0.759277f, 0.773438f, 0.786621f, 0.798340f, 0.811523f, 0.822266f, 0.833496f, 0.842773f, 0.851562f, 0.861816f, 0.869629f, 0.878418f,
+ 0.885742f, 0.893066f, 0.900879f, 0.907715f, 0.913574f, 0.919922f, 0.925781f, 0.932129f, 0.937012f, 0.942871f, 0.946777f, 0.951660f,
+ 0.957031f, 0.960938f, 0.965332f, 0.969727f, 0.973633f, 0.977051f, 0.988281f, 0.986328f, 0.983887f, 0.981445f, 0.979492f, 0.976562f,
+ 0.009903f, 0.031525f, 0.054626f, 0.078979f, 0.105408f, 0.133789f, 0.162720f, 0.192993f, 0.224976f, 0.256592f, 0.288330f, 0.320312f,
+ 0.352295f, 0.383545f, 0.414062f, 0.443848f, 0.473389f, 0.500488f, 0.526367f, 0.553223f, 0.577637f, 0.600586f, 0.622070f, 0.644043f,
+ 0.664551f, 0.683105f, 0.701660f, 0.718262f, 0.734375f, 0.750000f, 0.764648f, 0.778320f, 0.791016f, 0.802734f, 0.815430f, 0.826172f,
+ 0.836426f, 0.845703f, 0.855957f, 0.864258f, 0.874023f, 0.881348f, 0.889648f, 0.896973f, 0.904297f, 0.911621f, 0.917480f, 0.922852f,
+ 0.929199f, 0.935059f, 0.939941f, 0.944824f, 0.950195f, 0.954590f, 0.959961f, 0.964355f, 0.968262f, 0.972656f, 0.986328f, 0.984375f,
+ 0.981934f, 0.979980f, 0.978027f, 0.975586f, 0.008385f, 0.026154f, 0.045319f, 0.066467f, 0.089111f, 0.113220f, 0.138916f, 0.165405f,
+ 0.192871f, 0.222290f, 0.252197f, 0.281494f, 0.311279f, 0.342285f, 0.372314f, 0.402832f, 0.431641f, 0.459473f, 0.486572f, 0.513672f,
+ 0.539062f, 0.562988f, 0.587402f, 0.609863f, 0.631348f, 0.652344f, 0.671875f, 0.689941f, 0.708008f, 0.724609f, 0.740234f, 0.755371f,
+ 0.768066f, 0.783203f, 0.795410f, 0.808105f, 0.819336f, 0.830078f, 0.840332f, 0.851074f, 0.860352f, 0.869141f, 0.877930f, 0.885742f,
+ 0.893555f, 0.900879f, 0.907715f, 0.915039f, 0.920410f, 0.926758f, 0.933105f, 0.938965f, 0.944336f, 0.949707f, 0.953613f, 0.958984f,
+ 0.962891f, 0.967285f, 0.984375f, 0.982910f, 0.980957f, 0.978516f, 0.976562f, 0.974609f, 0.006992f, 0.022324f, 0.038544f, 0.056396f,
+ 0.075317f, 0.095947f, 0.117981f, 0.141968f, 0.166504f, 0.192627f, 0.219238f, 0.246704f, 0.275879f, 0.304443f, 0.333252f, 0.362305f,
+ 0.390869f, 0.419678f, 0.447266f, 0.474121f, 0.500977f, 0.525879f, 0.551270f, 0.574219f, 0.597656f, 0.620117f, 0.641602f, 0.661133f,
+ 0.680664f, 0.698242f, 0.715332f, 0.731934f, 0.746582f, 0.761230f, 0.775391f, 0.789551f, 0.802246f, 0.813477f, 0.825195f, 0.835938f,
+ 0.846191f, 0.855957f, 0.865723f, 0.873535f, 0.882324f, 0.890625f, 0.898438f, 0.905762f, 0.912598f, 0.918945f, 0.925781f, 0.931641f,
+ 0.937012f, 0.943848f, 0.948730f, 0.954102f, 0.957520f, 0.963379f, 0.981934f, 0.980957f, 0.979004f, 0.977051f, 0.975098f, 0.973145f,
+ 0.006260f, 0.018387f, 0.032684f, 0.047821f, 0.064636f, 0.082153f, 0.101318f, 0.122009f, 0.143921f, 0.166870f, 0.191406f, 0.216187f,
+ 0.243164f, 0.269287f, 0.297119f, 0.324951f, 0.352783f, 0.380859f, 0.408691f, 0.435547f, 0.462402f, 0.489258f, 0.514160f, 0.540039f,
+ 0.563965f, 0.585938f, 0.608398f, 0.629395f, 0.649414f, 0.669434f, 0.689453f, 0.705566f, 0.722656f, 0.739258f, 0.753418f, 0.769043f,
+ 0.783203f, 0.795898f, 0.807617f, 0.819824f, 0.830566f, 0.842285f, 0.852051f, 0.862305f, 0.871094f, 0.878906f, 0.888184f, 0.895996f,
+ 0.902832f, 0.910645f, 0.917480f, 0.924316f, 0.930176f, 0.936523f, 0.942383f, 0.946777f, 0.953613f, 0.958496f, 0.979980f, 0.979004f,
+ 0.977539f, 0.975586f, 0.973633f, 0.972168f, 0.005268f, 0.016418f, 0.028091f, 0.041107f, 0.055420f, 0.070435f, 0.087341f, 0.105347f,
+ 0.124512f, 0.144531f, 0.166260f, 0.189453f, 0.213989f, 0.238037f, 0.263184f, 0.290039f, 0.317139f, 0.344238f, 0.370850f, 0.398438f,
+ 0.425293f, 0.451660f, 0.477539f, 0.503418f, 0.528320f, 0.551270f, 0.576172f, 0.598145f, 0.619629f, 0.640137f, 0.659668f, 0.680176f,
+ 0.697754f, 0.714844f, 0.731934f, 0.748047f, 0.762695f, 0.776367f, 0.790039f, 0.803223f, 0.814453f, 0.827148f, 0.837891f, 0.847656f,
+ 0.858398f, 0.868164f, 0.876953f, 0.885742f, 0.893066f, 0.901855f, 0.908691f, 0.916504f, 0.922852f, 0.929199f, 0.935059f, 0.941895f,
+ 0.947754f, 0.953125f, 0.978027f, 0.977539f, 0.975586f, 0.973633f, 0.971680f, 0.969727f, 0.004372f, 0.013802f, 0.024185f, 0.036011f,
+ 0.047729f, 0.060944f, 0.075684f, 0.090820f, 0.107788f, 0.125488f, 0.144653f, 0.165771f, 0.187012f, 0.210205f, 0.233643f, 0.258545f,
+ 0.283447f, 0.309326f, 0.335449f, 0.362305f, 0.388672f, 0.415771f, 0.441650f, 0.468018f, 0.492920f, 0.518066f, 0.542480f, 0.564941f,
+ 0.587891f, 0.609863f, 0.630859f, 0.651855f, 0.670898f, 0.689453f, 0.707520f, 0.724609f, 0.740723f, 0.755859f, 0.770996f, 0.785156f,
+ 0.799316f, 0.809570f, 0.822754f, 0.834473f, 0.845215f, 0.855469f, 0.865723f, 0.874023f, 0.883301f, 0.892090f, 0.899902f, 0.907715f,
+ 0.915039f, 0.922363f, 0.928711f, 0.935059f, 0.941406f, 0.947266f, 0.975586f, 0.975098f, 0.973633f, 0.971680f, 0.969727f, 0.968262f,
+ 0.003809f, 0.012253f, 0.021240f, 0.030884f, 0.041473f, 0.052887f, 0.065308f, 0.079224f, 0.094177f, 0.109558f, 0.126709f, 0.145142f,
+ 0.163940f, 0.184814f, 0.207397f, 0.229736f, 0.252686f, 0.276855f, 0.302246f, 0.327881f, 0.353271f, 0.380127f, 0.405762f, 0.432129f,
+ 0.457520f, 0.482422f, 0.507324f, 0.531250f, 0.556152f, 0.578125f, 0.600586f, 0.622559f, 0.642578f, 0.662109f, 0.681641f, 0.700195f,
+ 0.716797f, 0.734375f, 0.750000f, 0.766113f, 0.779297f, 0.793457f, 0.807129f, 0.819336f, 0.830078f, 0.842285f, 0.853027f, 0.862793f,
+ 0.872559f, 0.881348f, 0.890625f, 0.899414f, 0.907227f, 0.914551f, 0.920898f, 0.928223f, 0.935059f, 0.941406f, 0.973633f, 0.973145f,
+ 0.971680f, 0.970215f, 0.968262f, 0.966797f, 0.003462f, 0.010796f, 0.018646f, 0.026962f, 0.036377f, 0.046173f, 0.057190f, 0.068665f,
+ 0.081726f, 0.095520f, 0.110962f, 0.127563f, 0.144897f, 0.162476f, 0.182373f, 0.202881f, 0.225342f, 0.248291f, 0.271729f, 0.294922f,
+ 0.320312f, 0.345459f, 0.370850f, 0.397217f, 0.422607f, 0.447998f, 0.473145f, 0.498291f, 0.522461f, 0.546875f, 0.569824f, 0.591797f,
+ 0.614258f, 0.635742f, 0.655273f, 0.674805f, 0.693359f, 0.711426f, 0.729492f, 0.745605f, 0.760742f, 0.775391f, 0.789551f, 0.803223f,
+ 0.816406f, 0.828125f, 0.839844f, 0.850586f, 0.861328f, 0.871094f, 0.880371f, 0.889648f, 0.898438f, 0.906250f, 0.915039f, 0.921875f,
+ 0.928223f, 0.935547f, 0.970703f, 0.970215f, 0.970215f, 0.967773f, 0.966309f, 0.965332f, 0.002872f, 0.009338f, 0.016174f, 0.024231f,
+ 0.031525f, 0.040558f, 0.050140f, 0.060455f, 0.071472f, 0.084167f, 0.097168f, 0.111450f, 0.127197f, 0.143433f, 0.160889f, 0.179565f,
+ 0.199463f, 0.220825f, 0.242554f, 0.265625f, 0.288818f, 0.312744f, 0.338135f, 0.362793f, 0.387939f, 0.414307f, 0.439453f, 0.464355f,
+ 0.489014f, 0.514648f, 0.537598f, 0.561523f, 0.583984f, 0.606445f, 0.627930f, 0.648926f, 0.667480f, 0.687988f, 0.705566f, 0.723633f,
+ 0.740234f, 0.756348f, 0.771484f, 0.786621f, 0.799805f, 0.812012f, 0.825195f, 0.836426f, 0.849121f, 0.859375f, 0.870605f, 0.879883f,
+ 0.888672f, 0.897461f, 0.905762f, 0.915039f, 0.921387f, 0.928711f, 0.967773f, 0.969238f, 0.966797f, 0.966797f, 0.964355f, 0.963379f,
+ 0.002750f, 0.008202f, 0.014519f, 0.021301f, 0.028183f, 0.035828f, 0.044342f, 0.053375f, 0.063354f, 0.074219f, 0.085876f, 0.098083f,
+ 0.111938f, 0.126343f, 0.142212f, 0.158936f, 0.177124f, 0.196411f, 0.216553f, 0.237427f, 0.260010f, 0.282715f, 0.306641f, 0.330811f,
+ 0.355957f, 0.381104f, 0.405518f, 0.431152f, 0.456543f, 0.480957f, 0.504883f, 0.529785f, 0.553223f, 0.577148f, 0.599121f, 0.620605f,
+ 0.642090f, 0.662598f, 0.682617f, 0.701172f, 0.718750f, 0.735352f, 0.751953f, 0.768066f, 0.783691f, 0.796875f, 0.810547f, 0.822754f,
+ 0.835938f, 0.847656f, 0.858398f, 0.869141f, 0.879395f, 0.888672f, 0.897949f, 0.906250f, 0.914551f, 0.922363f, 0.965820f, 0.966797f,
+ 0.965820f, 0.963867f, 0.963379f, 0.961426f, 0.002264f, 0.007446f, 0.012741f, 0.018494f, 0.024536f, 0.031769f, 0.039154f, 0.047424f,
+ 0.056122f, 0.065308f, 0.075623f, 0.087219f, 0.098755f, 0.111328f, 0.125854f, 0.140869f, 0.157349f, 0.174805f, 0.193115f, 0.212402f,
+ 0.233643f, 0.254883f, 0.276855f, 0.300293f, 0.324463f, 0.348389f, 0.374023f, 0.398193f, 0.423340f, 0.448242f, 0.473877f, 0.498291f,
+ 0.521973f, 0.545898f, 0.569824f, 0.592773f, 0.614258f, 0.635742f, 0.657227f, 0.676270f, 0.695801f, 0.714844f, 0.731445f, 0.749512f,
+ 0.765137f, 0.779785f, 0.793945f, 0.808594f, 0.821777f, 0.833496f, 0.846191f, 0.858398f, 0.868652f, 0.879395f, 0.888672f, 0.897949f,
+ 0.906738f, 0.916016f, 0.962402f, 0.963867f, 0.962891f, 0.961914f, 0.960938f, 0.958984f, 0.002377f, 0.006668f, 0.011467f, 0.016693f,
+ 0.021820f, 0.028091f, 0.034485f, 0.041748f, 0.049347f, 0.057678f, 0.066589f, 0.076538f, 0.086975f, 0.098816f, 0.111816f, 0.125366f,
+ 0.139404f, 0.155151f, 0.171875f, 0.190186f, 0.208496f, 0.228760f, 0.250244f, 0.271973f, 0.294189f, 0.317871f, 0.341797f, 0.365479f,
+ 0.391357f, 0.415771f, 0.440430f, 0.466797f, 0.491699f, 0.515625f, 0.539551f, 0.563477f, 0.585938f, 0.608887f, 0.630371f, 0.651855f,
+ 0.672363f, 0.692383f, 0.710449f, 0.729492f, 0.745605f, 0.762695f, 0.778320f, 0.792480f, 0.807129f, 0.820801f, 0.833984f, 0.846680f,
+ 0.857910f, 0.869141f, 0.879395f, 0.889648f, 0.899414f, 0.907715f, 0.959473f, 0.961426f, 0.960449f, 0.959961f, 0.958496f, 0.957031f,
+ 0.002062f, 0.006180f, 0.010201f, 0.015053f, 0.019531f, 0.025116f, 0.030960f, 0.037292f, 0.043915f, 0.051117f, 0.059570f, 0.067749f,
+ 0.076843f, 0.087708f, 0.099060f, 0.110352f, 0.123413f, 0.138062f, 0.153198f, 0.169067f, 0.186768f, 0.204956f, 0.224487f, 0.244873f,
+ 0.265625f, 0.288330f, 0.311768f, 0.335205f, 0.359863f, 0.384521f, 0.409668f, 0.434082f, 0.459717f, 0.483887f, 0.508789f, 0.533203f,
+ 0.557617f, 0.580566f, 0.603516f, 0.626465f, 0.646484f, 0.667969f, 0.687500f, 0.708008f, 0.726074f, 0.744141f, 0.760742f, 0.776367f,
+ 0.791504f, 0.806641f, 0.820312f, 0.833496f, 0.846191f, 0.858398f, 0.869629f, 0.879883f, 0.890625f, 0.900879f, 0.956543f, 0.958496f,
+ 0.958008f, 0.956543f, 0.955566f, 0.954102f, 0.001774f, 0.005459f, 0.009155f, 0.013290f, 0.017807f, 0.022537f, 0.027527f, 0.033081f,
+ 0.038818f, 0.045380f, 0.052643f, 0.060516f, 0.068420f, 0.077942f, 0.087952f, 0.098572f, 0.109863f, 0.122925f, 0.136230f, 0.150146f,
+ 0.166382f, 0.183105f, 0.201172f, 0.219482f, 0.240112f, 0.261230f, 0.283203f, 0.305664f, 0.329590f, 0.353027f, 0.377930f, 0.402344f,
+ 0.427490f, 0.453369f, 0.478516f, 0.502930f, 0.527832f, 0.552246f, 0.575684f, 0.598145f, 0.621094f, 0.643555f, 0.664551f, 0.685547f,
+ 0.704590f, 0.723633f, 0.742188f, 0.759277f, 0.775879f, 0.791016f, 0.806152f, 0.820801f, 0.833496f, 0.847168f, 0.859375f, 0.870605f,
+ 0.881348f, 0.893066f, 0.953125f, 0.956055f, 0.955566f, 0.954102f, 0.953125f, 0.951660f, 0.001655f, 0.004757f, 0.008308f, 0.011993f,
+ 0.015808f, 0.020187f, 0.024780f, 0.029434f, 0.034851f, 0.040741f, 0.046997f, 0.053650f, 0.061096f, 0.069397f, 0.078064f, 0.087280f,
+ 0.097351f, 0.108887f, 0.121033f, 0.134277f, 0.148560f, 0.163330f, 0.180054f, 0.197144f, 0.215332f, 0.235718f, 0.255859f, 0.277588f,
+ 0.300049f, 0.323730f, 0.347656f, 0.371826f, 0.396729f, 0.422607f, 0.447021f, 0.472168f, 0.497803f, 0.521973f, 0.547363f, 0.571289f,
+ 0.594238f, 0.618164f, 0.640137f, 0.662109f, 0.682617f, 0.702637f, 0.722168f, 0.739746f, 0.758301f, 0.774902f, 0.790527f, 0.806641f,
+ 0.820801f, 0.834961f, 0.848633f, 0.860352f, 0.872559f, 0.883789f, 0.949707f, 0.953125f, 0.952148f, 0.951172f, 0.950684f, 0.948730f,
+ 0.001418f, 0.004456f, 0.007584f, 0.010803f, 0.014450f, 0.018005f, 0.022186f, 0.026398f, 0.031342f, 0.036224f, 0.041687f, 0.048126f,
+ 0.054382f, 0.061676f, 0.069641f, 0.077759f, 0.086914f, 0.097168f, 0.107910f, 0.119263f, 0.132446f, 0.145752f, 0.161011f, 0.176758f,
+ 0.193726f, 0.211914f, 0.231201f, 0.251709f, 0.272705f, 0.294922f, 0.318604f, 0.342041f, 0.366455f, 0.390869f, 0.416992f, 0.441895f,
+ 0.467285f, 0.493164f, 0.517578f, 0.541992f, 0.566895f, 0.590820f, 0.614746f, 0.637207f, 0.660156f, 0.681152f, 0.701172f, 0.720703f,
+ 0.739746f, 0.758301f, 0.775391f, 0.791992f, 0.807617f, 0.821289f, 0.836426f, 0.850586f, 0.863281f, 0.874512f, 0.946777f, 0.949707f,
+ 0.949707f, 0.948730f, 0.947266f, 0.946289f, 0.001213f, 0.003864f, 0.006721f, 0.009796f, 0.012932f, 0.016037f, 0.020218f, 0.024231f,
+ 0.028275f, 0.032379f, 0.037567f, 0.042603f, 0.048584f, 0.054993f, 0.061798f, 0.069519f, 0.077637f, 0.086182f, 0.095703f, 0.106323f,
+ 0.117676f, 0.130127f, 0.143555f, 0.158203f, 0.173462f, 0.189941f, 0.207886f, 0.226807f, 0.247192f, 0.267822f, 0.290527f, 0.312500f,
+ 0.336670f, 0.360352f, 0.385742f, 0.410889f, 0.437256f, 0.462646f, 0.488281f, 0.513184f, 0.539062f, 0.563477f, 0.588379f, 0.612305f,
+ 0.636230f, 0.657715f, 0.679199f, 0.700195f, 0.720703f, 0.740234f, 0.758301f, 0.775879f, 0.793945f, 0.809082f, 0.824219f, 0.838867f,
+ 0.852539f, 0.865234f, 0.942871f, 0.946777f, 0.946777f, 0.945312f, 0.944824f, 0.943359f, 0.001063f, 0.003754f, 0.005909f, 0.008789f,
+ 0.011780f, 0.014671f, 0.017792f, 0.021378f, 0.025238f, 0.029221f, 0.033417f, 0.038300f, 0.043488f, 0.048828f, 0.054779f, 0.061554f,
+ 0.068604f, 0.076721f, 0.085388f, 0.094482f, 0.104614f, 0.115845f, 0.128296f, 0.141113f, 0.155029f, 0.170044f, 0.186401f, 0.204224f,
+ 0.222778f, 0.242188f, 0.263916f, 0.285156f, 0.308350f, 0.331787f, 0.355957f, 0.381348f, 0.407227f, 0.432617f, 0.459229f, 0.484619f,
+ 0.509277f, 0.536133f, 0.560547f, 0.585938f, 0.609863f, 0.633301f, 0.657715f, 0.678711f, 0.699707f, 0.721191f, 0.740723f, 0.759277f,
+ 0.777344f, 0.794922f, 0.811035f, 0.826660f, 0.841797f, 0.855469f, 0.939453f, 0.943359f, 0.943359f, 0.942871f, 0.941895f, 0.940918f,
+ 0.001175f, 0.003069f, 0.005558f, 0.007912f, 0.010712f, 0.013199f, 0.016235f, 0.019547f, 0.022659f, 0.026138f, 0.030151f, 0.034424f,
+ 0.038940f, 0.044067f, 0.049255f, 0.054993f, 0.061493f, 0.068359f, 0.075928f, 0.084290f, 0.093262f, 0.103760f, 0.114319f, 0.126099f,
+ 0.138550f, 0.152466f, 0.167114f, 0.183472f, 0.200439f, 0.219238f, 0.239014f, 0.259277f, 0.281250f, 0.303711f, 0.327148f, 0.351807f,
+ 0.376709f, 0.402344f, 0.428955f, 0.453857f, 0.480713f, 0.507324f, 0.533203f, 0.558594f, 0.583984f, 0.609375f, 0.633301f, 0.656738f,
+ 0.678711f, 0.700195f, 0.722168f, 0.742188f, 0.761719f, 0.780273f, 0.797852f, 0.813477f, 0.830078f, 0.845703f, 0.935547f, 0.939453f,
+ 0.939453f, 0.938965f, 0.937988f, 0.937012f, 0.001089f, 0.002945f, 0.005066f, 0.007225f, 0.009575f, 0.012016f, 0.014656f, 0.017288f,
+ 0.020142f, 0.023712f, 0.026764f, 0.030640f, 0.034637f, 0.039490f, 0.043854f, 0.048706f, 0.054688f, 0.060913f, 0.067871f, 0.075256f,
+ 0.083191f, 0.092163f, 0.101868f, 0.111938f, 0.123657f, 0.136108f, 0.149658f, 0.164185f, 0.179932f, 0.196777f, 0.215454f, 0.234375f,
+ 0.255371f, 0.276611f, 0.299805f, 0.323486f, 0.347656f, 0.373047f, 0.398682f, 0.425293f, 0.451172f, 0.477783f, 0.504883f, 0.530762f,
+ 0.557617f, 0.583008f, 0.607910f, 0.632812f, 0.657227f, 0.680664f, 0.702637f, 0.724121f, 0.743652f, 0.764160f, 0.783691f, 0.800781f,
+ 0.818848f, 0.833984f, 0.930664f, 0.936035f, 0.936035f, 0.935547f, 0.934570f, 0.933594f, 0.000847f, 0.002800f, 0.004562f, 0.006786f,
+ 0.008804f, 0.011017f, 0.013145f, 0.015640f, 0.018509f, 0.021255f, 0.024277f, 0.027603f, 0.030991f, 0.035248f, 0.039642f, 0.043854f,
+ 0.048798f, 0.054504f, 0.060516f, 0.067017f, 0.073914f, 0.082092f, 0.090515f, 0.099854f, 0.109863f, 0.121521f, 0.133545f, 0.146851f,
+ 0.161133f, 0.176514f, 0.192993f, 0.211426f, 0.230957f, 0.251465f, 0.272705f, 0.295410f, 0.319092f, 0.343994f, 0.369385f, 0.395020f,
+ 0.421631f, 0.448242f, 0.475342f, 0.501953f, 0.529785f, 0.556152f, 0.582031f, 0.608887f, 0.633789f, 0.658203f, 0.681152f, 0.704590f,
+ 0.726074f, 0.748535f, 0.768555f, 0.787109f, 0.804199f, 0.822754f, 0.926758f, 0.931641f, 0.932129f, 0.931641f, 0.931152f, 0.930176f,
+ 0.001035f, 0.002598f, 0.004147f, 0.006062f, 0.007942f, 0.009933f, 0.012405f, 0.014565f, 0.016174f, 0.019135f, 0.021988f, 0.024811f,
+ 0.028259f, 0.031616f, 0.035065f, 0.039429f, 0.043884f, 0.048615f, 0.053833f, 0.059723f, 0.065796f, 0.072693f, 0.080383f, 0.088745f,
+ 0.098206f, 0.107727f, 0.119080f, 0.130981f, 0.143677f, 0.157959f, 0.173218f, 0.189941f, 0.207642f, 0.226929f, 0.247437f, 0.269043f,
+ 0.291748f, 0.315674f, 0.340576f, 0.366211f, 0.392578f, 0.419434f, 0.446533f, 0.473877f, 0.502441f, 0.528320f, 0.556152f, 0.583008f,
+ 0.609375f, 0.635254f, 0.660156f, 0.684082f, 0.706543f, 0.729980f, 0.751953f, 0.771973f, 0.792480f, 0.810547f, 0.922363f, 0.927734f,
+ 0.928223f, 0.928223f, 0.927246f, 0.926758f, 0.000775f, 0.002325f, 0.003843f, 0.005573f, 0.007397f, 0.009163f, 0.010857f, 0.012939f,
+ 0.015312f, 0.017273f, 0.019684f, 0.022537f, 0.025070f, 0.028183f, 0.031616f, 0.035461f, 0.038940f, 0.043671f, 0.048096f, 0.053131f,
+ 0.058411f, 0.064941f, 0.071777f, 0.078857f, 0.086731f, 0.096130f, 0.105835f, 0.116760f, 0.128296f, 0.140747f, 0.154907f, 0.170410f,
+ 0.186646f, 0.204834f, 0.223633f, 0.243896f, 0.265625f, 0.288330f, 0.312012f, 0.337402f, 0.363037f, 0.389648f, 0.417480f, 0.444824f,
+ 0.473633f, 0.500000f, 0.529297f, 0.556641f, 0.583984f, 0.610840f, 0.638184f, 0.662598f, 0.687988f, 0.711914f, 0.734375f, 0.755859f,
+ 0.777832f, 0.798828f, 0.916992f, 0.922852f, 0.923828f, 0.923828f, 0.923340f, 0.922363f, 0.000617f, 0.002234f, 0.003510f, 0.005035f,
+ 0.006397f, 0.008156f, 0.010033f, 0.011665f, 0.013481f, 0.015717f, 0.017700f, 0.020004f, 0.022766f, 0.025391f, 0.028214f, 0.031586f,
+ 0.035217f, 0.038757f, 0.042999f, 0.047668f, 0.052368f, 0.057434f, 0.063538f, 0.070190f, 0.077698f, 0.085449f, 0.094299f, 0.103394f,
+ 0.113953f, 0.125610f, 0.137817f, 0.151855f, 0.167236f, 0.183228f, 0.200806f, 0.219971f, 0.240479f, 0.262451f, 0.285645f, 0.309570f,
+ 0.334961f, 0.360596f, 0.387939f, 0.416016f, 0.444092f, 0.473145f, 0.501465f, 0.529785f, 0.558105f, 0.585938f, 0.614258f, 0.640137f,
+ 0.666992f, 0.692383f, 0.716797f, 0.739746f, 0.763184f, 0.784180f, 0.912109f, 0.918457f, 0.919434f, 0.919434f, 0.918457f, 0.917969f,
+ 0.000665f, 0.002039f, 0.003386f, 0.004520f, 0.005989f, 0.007511f, 0.009262f, 0.010902f, 0.012314f, 0.014320f, 0.015869f, 0.018127f,
+ 0.020248f, 0.022476f, 0.025284f, 0.028122f, 0.030991f, 0.034668f, 0.038239f, 0.042206f, 0.046539f, 0.051361f, 0.056610f, 0.062347f,
+ 0.068604f, 0.075623f, 0.083313f, 0.092041f, 0.101379f, 0.111572f, 0.122986f, 0.135132f, 0.148926f, 0.164062f, 0.180054f, 0.197510f,
+ 0.216797f, 0.237183f, 0.259521f, 0.282227f, 0.307129f, 0.332764f, 0.358887f, 0.386475f, 0.415527f, 0.443604f, 0.473389f, 0.501465f,
+ 0.530762f, 0.560059f, 0.588867f, 0.617676f, 0.645020f, 0.671387f, 0.698242f, 0.722656f, 0.746094f, 0.770020f, 0.906738f, 0.913574f,
+ 0.915039f, 0.914551f, 0.914062f, 0.914062f, 0.000661f, 0.001754f, 0.002831f, 0.004066f, 0.005333f, 0.006668f, 0.008286f, 0.009773f,
+ 0.011124f, 0.012794f, 0.014320f, 0.016357f, 0.018036f, 0.020386f, 0.022766f, 0.025192f, 0.027924f, 0.030807f, 0.034027f, 0.037628f,
+ 0.041321f, 0.045349f, 0.050262f, 0.055328f, 0.060699f, 0.066833f, 0.073669f, 0.081360f, 0.089600f, 0.099060f, 0.108826f, 0.119995f,
+ 0.132324f, 0.145874f, 0.160889f, 0.176880f, 0.194702f, 0.213379f, 0.234497f, 0.256104f, 0.280029f, 0.304688f, 0.330811f, 0.358154f,
+ 0.385986f, 0.415039f, 0.444092f, 0.474609f, 0.503418f, 0.534180f, 0.563965f, 0.592773f, 0.621094f, 0.650391f, 0.678223f, 0.704590f,
+ 0.730469f, 0.754883f, 0.901855f, 0.908691f, 0.910156f, 0.909668f, 0.909668f, 0.908691f, 0.000653f, 0.001667f, 0.002666f, 0.003887f,
+ 0.004986f, 0.006359f, 0.007202f, 0.008751f, 0.010300f, 0.011757f, 0.012939f, 0.014595f, 0.016281f, 0.018234f, 0.020142f, 0.022415f,
+ 0.025101f, 0.027466f, 0.030182f, 0.033539f, 0.036865f, 0.040680f, 0.044342f, 0.048798f, 0.053619f, 0.059479f, 0.065491f, 0.071716f,
+ 0.079285f, 0.087341f, 0.096497f, 0.106445f, 0.117615f, 0.129395f, 0.142822f, 0.157959f, 0.174194f, 0.192139f, 0.210938f, 0.231567f,
+ 0.253906f, 0.277832f, 0.302979f, 0.329590f, 0.357422f, 0.385986f, 0.415283f, 0.446045f, 0.475830f, 0.506348f, 0.537109f, 0.567871f,
+ 0.599121f, 0.628418f, 0.657227f, 0.685547f, 0.712891f, 0.739746f, 0.895508f, 0.902344f, 0.904297f, 0.904785f, 0.904297f, 0.904297f,
+ 0.000372f, 0.001397f, 0.002384f, 0.003529f, 0.004509f, 0.005505f, 0.007015f, 0.008026f, 0.009201f, 0.010292f, 0.011536f, 0.013130f,
+ 0.014915f, 0.016266f, 0.018387f, 0.020218f, 0.022034f, 0.024399f, 0.026901f, 0.029617f, 0.032623f, 0.035950f, 0.039032f, 0.043030f,
+ 0.047577f, 0.052612f, 0.057556f, 0.063477f, 0.070007f, 0.077209f, 0.085083f, 0.094177f, 0.103821f, 0.114563f, 0.126709f, 0.140015f,
+ 0.154785f, 0.171143f, 0.188477f, 0.208252f, 0.229004f, 0.251709f, 0.275879f, 0.302002f, 0.328613f, 0.356445f, 0.385986f, 0.416504f,
+ 0.447510f, 0.478760f, 0.510254f, 0.542480f, 0.573730f, 0.604980f, 0.635742f, 0.665527f, 0.694336f, 0.722656f, 0.887695f, 0.897949f,
+ 0.898926f, 0.899414f, 0.897949f, 0.898438f, 0.000661f, 0.001222f, 0.002275f, 0.003313f, 0.004181f, 0.005119f, 0.006275f, 0.007126f,
+ 0.007988f, 0.009354f, 0.010300f, 0.012062f, 0.013313f, 0.014786f, 0.016251f, 0.018021f, 0.019516f, 0.021896f, 0.024017f, 0.026428f,
+ 0.029022f, 0.031799f, 0.034698f, 0.038422f, 0.042236f, 0.046265f, 0.050598f, 0.055786f, 0.061493f, 0.067871f, 0.074951f, 0.082458f,
+ 0.091187f, 0.101135f, 0.111694f, 0.123779f, 0.137207f, 0.151978f, 0.167969f, 0.186157f, 0.205688f, 0.226929f, 0.249756f, 0.274658f,
+ 0.301025f, 0.328613f, 0.357178f, 0.387207f, 0.418457f, 0.450195f, 0.482422f, 0.516113f, 0.548340f, 0.580566f, 0.612305f, 0.644043f,
+ 0.674805f, 0.705566f, 0.882812f, 0.890625f, 0.892578f, 0.893066f, 0.892578f, 0.893066f, 0.000379f, 0.001211f, 0.002066f, 0.003040f,
+ 0.003834f, 0.004616f, 0.005608f, 0.006550f, 0.007347f, 0.008408f, 0.009529f, 0.010452f, 0.011940f, 0.013039f, 0.014313f, 0.015961f,
+ 0.017746f, 0.019180f, 0.021210f, 0.023239f, 0.025482f, 0.028030f, 0.030640f, 0.033661f, 0.036987f, 0.040466f, 0.044617f, 0.048828f,
+ 0.053894f, 0.059235f, 0.065674f, 0.072632f, 0.079956f, 0.089050f, 0.098267f, 0.109009f, 0.120789f, 0.134521f, 0.148926f, 0.165405f,
+ 0.183228f, 0.202881f, 0.224731f, 0.248779f, 0.273193f, 0.300049f, 0.329346f, 0.358887f, 0.390381f, 0.421387f, 0.454590f, 0.488770f,
+ 0.521484f, 0.555176f, 0.588379f, 0.621582f, 0.654785f, 0.686523f, 0.875488f, 0.885254f, 0.886719f, 0.886230f, 0.886719f, 0.886230f,
+ 0.000282f, 0.001126f, 0.002010f, 0.002661f, 0.003340f, 0.004269f, 0.005192f, 0.005711f, 0.006638f, 0.007278f, 0.008377f, 0.009483f,
+ 0.010567f, 0.011742f, 0.012871f, 0.014061f, 0.015480f, 0.017242f, 0.018799f, 0.020584f, 0.022461f, 0.024490f, 0.027100f, 0.029434f,
+ 0.032532f, 0.035706f, 0.038971f, 0.042969f, 0.047241f, 0.052094f, 0.057373f, 0.063232f, 0.070007f, 0.077637f, 0.086243f, 0.095764f,
+ 0.106323f, 0.118164f, 0.131470f, 0.146118f, 0.162720f, 0.181030f, 0.200928f, 0.223022f, 0.247070f, 0.272705f, 0.300537f, 0.330322f,
+ 0.360107f, 0.393066f, 0.426270f, 0.459473f, 0.494629f, 0.529297f, 0.564453f, 0.598633f, 0.633789f, 0.666504f, 0.868652f, 0.878418f,
+ 0.879395f, 0.880371f, 0.879883f, 0.879395f, 0.000340f, 0.000963f, 0.001826f, 0.002459f, 0.003307f, 0.003847f, 0.004719f, 0.004936f,
+ 0.005802f, 0.006695f, 0.007748f, 0.008522f, 0.009506f, 0.010376f, 0.011383f, 0.012787f, 0.013901f, 0.015182f, 0.016663f, 0.018051f,
+ 0.019821f, 0.021759f, 0.023590f, 0.025818f, 0.028519f, 0.030975f, 0.034210f, 0.037811f, 0.040802f, 0.045349f, 0.050201f, 0.055298f,
+ 0.061310f, 0.067688f, 0.074768f, 0.083557f, 0.092590f, 0.103149f, 0.115479f, 0.128906f, 0.142944f, 0.160278f, 0.178345f, 0.198975f,
+ 0.221802f, 0.246094f, 0.272949f, 0.301514f, 0.331543f, 0.363525f, 0.396729f, 0.430908f, 0.466553f, 0.501953f, 0.538086f, 0.574707f,
+ 0.610840f, 0.646973f, 0.860352f, 0.870605f, 0.873047f, 0.873047f, 0.873535f, 0.872559f, 0.000225f, 0.001021f, 0.001653f, 0.002302f,
+ 0.002827f, 0.003448f, 0.003937f, 0.004486f, 0.004986f, 0.006252f, 0.007000f, 0.007416f, 0.008224f, 0.009300f, 0.009972f, 0.011322f,
+ 0.012115f, 0.013428f, 0.014557f, 0.015991f, 0.017532f, 0.018982f, 0.020706f, 0.022781f, 0.024567f, 0.027161f, 0.029770f, 0.032623f,
+ 0.035828f, 0.039551f, 0.043030f, 0.047852f, 0.052795f, 0.058716f, 0.065125f, 0.072266f, 0.080566f, 0.089661f, 0.100403f, 0.112854f,
+ 0.125732f, 0.140991f, 0.157349f, 0.176514f, 0.197510f, 0.220581f, 0.245850f, 0.273438f, 0.302979f, 0.334717f, 0.367676f, 0.401855f,
+ 0.437256f, 0.474609f, 0.512695f, 0.549316f, 0.588379f, 0.625000f, 0.853027f, 0.863281f, 0.866211f, 0.866211f, 0.866699f, 0.866211f,
+ 0.000324f, 0.000845f, 0.001534f, 0.002172f, 0.002474f, 0.003115f, 0.003824f, 0.003937f, 0.004848f, 0.005417f, 0.006222f, 0.006760f,
+ 0.007446f, 0.008186f, 0.009102f, 0.009888f, 0.010620f, 0.011551f, 0.012878f, 0.013954f, 0.015106f, 0.016495f, 0.018143f, 0.019669f,
+ 0.021713f, 0.023468f, 0.025818f, 0.028183f, 0.031021f, 0.033783f, 0.037445f, 0.041534f, 0.045532f, 0.050598f, 0.056152f, 0.062500f,
+ 0.069580f, 0.077698f, 0.086914f, 0.097717f, 0.108948f, 0.123047f, 0.138184f, 0.155273f, 0.174438f, 0.196167f, 0.219604f, 0.246094f,
+ 0.274902f, 0.305420f, 0.338379f, 0.372314f, 0.408936f, 0.445801f, 0.484131f, 0.523438f, 0.562988f, 0.604492f, 0.843262f, 0.856445f,
+ 0.857422f, 0.857910f, 0.858398f, 0.858398f, 0.000331f, 0.000944f, 0.001288f, 0.001833f, 0.002388f, 0.002769f, 0.003216f, 0.003664f,
+ 0.004276f, 0.004822f, 0.005173f, 0.005951f, 0.006531f, 0.007156f, 0.007896f, 0.008438f, 0.009430f, 0.010117f, 0.011208f, 0.012253f,
+ 0.012970f, 0.014297f, 0.015572f, 0.017059f, 0.018692f, 0.020264f, 0.022125f, 0.024323f, 0.026474f, 0.029343f, 0.032288f, 0.035461f,
+ 0.039062f, 0.043335f, 0.047821f, 0.053558f, 0.059509f, 0.067078f, 0.074341f, 0.083862f, 0.094360f, 0.106323f, 0.120117f, 0.135254f,
+ 0.153442f, 0.172852f, 0.195190f, 0.220337f, 0.246948f, 0.276611f, 0.308594f, 0.343262f, 0.379150f, 0.416992f, 0.455811f, 0.496582f,
+ 0.537598f, 0.579590f, 0.834473f, 0.847656f, 0.850098f, 0.850098f, 0.849609f, 0.850098f, 0.000316f, 0.000824f, 0.001088f, 0.001693f,
+ 0.002062f, 0.002403f, 0.003027f, 0.003460f, 0.003712f, 0.004166f, 0.004765f, 0.005138f, 0.005871f, 0.006218f, 0.006924f, 0.007431f,
+ 0.008255f, 0.008850f, 0.009781f, 0.010590f, 0.011391f, 0.012367f, 0.013474f, 0.014709f, 0.015823f, 0.017685f, 0.018982f, 0.020844f,
+ 0.022629f, 0.025070f, 0.027496f, 0.030380f, 0.033447f, 0.037140f, 0.041168f, 0.045654f, 0.050720f, 0.057251f, 0.063965f, 0.071777f,
+ 0.080811f, 0.091248f, 0.103638f, 0.117126f, 0.133179f, 0.151001f, 0.171631f, 0.194580f, 0.220337f, 0.248413f, 0.279785f, 0.313965f,
+ 0.349365f, 0.386963f, 0.426514f, 0.468262f, 0.510742f, 0.555176f, 0.825684f, 0.838379f, 0.839844f, 0.841309f, 0.841309f, 0.841309f,
+ 0.000210f, 0.000717f, 0.001084f, 0.001454f, 0.001882f, 0.002096f, 0.002468f, 0.002996f, 0.003395f, 0.003632f, 0.004066f, 0.004467f,
+ 0.005020f, 0.005569f, 0.005917f, 0.006474f, 0.006958f, 0.007576f, 0.008453f, 0.009140f, 0.010002f, 0.010689f, 0.011520f, 0.012596f,
+ 0.013695f, 0.014938f, 0.016220f, 0.017593f, 0.019424f, 0.020996f, 0.023331f, 0.025696f, 0.028427f, 0.031067f, 0.034668f, 0.038422f,
+ 0.042908f, 0.048096f, 0.054016f, 0.060699f, 0.068909f, 0.077515f, 0.088501f, 0.100464f, 0.114624f, 0.130615f, 0.149048f, 0.170654f,
+ 0.194214f, 0.222046f, 0.251465f, 0.283936f, 0.319580f, 0.357422f, 0.397461f, 0.440186f, 0.484375f, 0.528320f, 0.814941f, 0.828613f,
+ 0.830078f, 0.832031f, 0.831543f, 0.833008f, 0.000234f, 0.000576f, 0.000939f, 0.001362f, 0.001481f, 0.001999f, 0.002228f, 0.002714f,
+ 0.002846f, 0.003218f, 0.003555f, 0.003933f, 0.004356f, 0.004787f, 0.005169f, 0.005604f, 0.006145f, 0.006554f, 0.007275f, 0.007675f,
+ 0.008293f, 0.009201f, 0.009979f, 0.010651f, 0.011497f, 0.012527f, 0.013893f, 0.014771f, 0.016373f, 0.017975f, 0.019455f, 0.021683f,
+ 0.023895f, 0.026077f, 0.029114f, 0.032257f, 0.036072f, 0.040405f, 0.045197f, 0.050903f, 0.057770f, 0.065613f, 0.074524f, 0.085388f,
+ 0.097656f, 0.111694f, 0.128540f, 0.147949f, 0.170166f, 0.195435f, 0.223389f, 0.255127f, 0.289551f, 0.327393f, 0.367432f, 0.410400f,
+ 0.455078f, 0.502441f, 0.804199f, 0.818848f, 0.821289f, 0.822266f, 0.822754f, 0.822266f, 0.000213f, 0.000506f, 0.000756f, 0.001184f,
+ 0.001396f, 0.001697f, 0.002010f, 0.002474f, 0.002569f, 0.002918f, 0.003090f, 0.003496f, 0.003855f, 0.004139f, 0.004478f, 0.004852f,
+ 0.005253f, 0.005665f, 0.006100f, 0.006638f, 0.007080f, 0.007744f, 0.008293f, 0.009132f, 0.009750f, 0.010658f, 0.011536f, 0.012413f,
+ 0.013779f, 0.014908f, 0.016510f, 0.017990f, 0.019623f, 0.021637f, 0.024109f, 0.026718f, 0.029922f, 0.033539f, 0.037567f, 0.042572f,
+ 0.048279f, 0.054413f, 0.062042f, 0.071472f, 0.081909f, 0.094604f, 0.109436f, 0.127075f, 0.146484f, 0.170044f, 0.196533f, 0.226929f,
+ 0.260254f, 0.296875f, 0.337402f, 0.380615f, 0.426025f, 0.475342f, 0.792969f, 0.807617f, 0.811035f, 0.811523f, 0.812012f, 0.813477f,
+ 0.000119f, 0.000422f, 0.000883f, 0.001027f, 0.001189f, 0.001604f, 0.001783f, 0.001913f, 0.002228f, 0.002522f, 0.002645f, 0.003086f,
+ 0.003199f, 0.003534f, 0.003790f, 0.004105f, 0.004421f, 0.004902f, 0.005283f, 0.005589f, 0.006039f, 0.006401f, 0.007088f, 0.007519f,
+ 0.008217f, 0.008812f, 0.009712f, 0.010460f, 0.011337f, 0.012413f, 0.013596f, 0.014687f, 0.016159f, 0.018051f, 0.019913f, 0.022018f,
+ 0.024551f, 0.027359f, 0.030792f, 0.035065f, 0.039703f, 0.044983f, 0.051392f, 0.059204f, 0.068176f, 0.079102f, 0.092041f, 0.106873f,
+ 0.125000f, 0.145874f, 0.170532f, 0.198975f, 0.230835f, 0.267090f, 0.306641f, 0.349854f, 0.395508f, 0.445801f, 0.780762f, 0.796875f,
+ 0.799805f, 0.801270f, 0.801270f, 0.801270f, 0.000227f, 0.000521f, 0.000698f, 0.000817f, 0.001236f, 0.001359f, 0.001540f, 0.001619f,
+ 0.001940f, 0.002089f, 0.002430f, 0.002552f, 0.002655f, 0.002932f, 0.003241f, 0.003532f, 0.003841f, 0.004120f, 0.004292f, 0.004761f,
+ 0.005051f, 0.005459f, 0.005886f, 0.006290f, 0.006821f, 0.007320f, 0.007889f, 0.008652f, 0.009399f, 0.010063f, 0.010887f, 0.012215f,
+ 0.013206f, 0.014648f, 0.016037f, 0.017853f, 0.019958f, 0.022491f, 0.024994f, 0.028091f, 0.032135f, 0.036530f, 0.041809f, 0.048096f,
+ 0.055908f, 0.064941f, 0.076050f, 0.089050f, 0.104980f, 0.123596f, 0.146118f, 0.172363f, 0.203003f, 0.237183f, 0.276123f, 0.318359f,
+ 0.365479f, 0.416504f, 0.768555f, 0.784668f, 0.788086f, 0.789551f, 0.790039f, 0.790039f, 0.000000f, 0.000448f, 0.000566f, 0.000688f,
+ 0.000985f, 0.001144f, 0.001305f, 0.001437f, 0.001622f, 0.001731f, 0.001989f, 0.002174f, 0.002338f, 0.002552f, 0.002739f, 0.002924f,
+ 0.003239f, 0.003405f, 0.003628f, 0.003933f, 0.004200f, 0.004463f, 0.004948f, 0.005245f, 0.005615f, 0.006138f, 0.006699f, 0.006989f,
+ 0.007793f, 0.008247f, 0.008980f, 0.009918f, 0.010857f, 0.011795f, 0.013016f, 0.014244f, 0.015930f, 0.017868f, 0.019882f, 0.022659f,
+ 0.025543f, 0.029160f, 0.033417f, 0.038635f, 0.044983f, 0.052338f, 0.061859f, 0.072693f, 0.086487f, 0.102966f, 0.122864f, 0.146973f,
+ 0.175049f, 0.207764f, 0.245605f, 0.287842f, 0.334229f, 0.385986f, 0.755371f, 0.771973f, 0.775879f, 0.777344f, 0.777832f, 0.778809f,
+ 0.000000f, 0.000303f, 0.000512f, 0.000752f, 0.000828f, 0.001036f, 0.001184f, 0.001292f, 0.001281f, 0.001460f, 0.001717f, 0.001843f,
+ 0.001955f, 0.002060f, 0.002317f, 0.002476f, 0.002542f, 0.002869f, 0.003088f, 0.003313f, 0.003559f, 0.003693f, 0.004082f, 0.004318f,
+ 0.004696f, 0.005070f, 0.005245f, 0.005741f, 0.006126f, 0.006771f, 0.007298f, 0.007828f, 0.008583f, 0.009338f, 0.010246f, 0.011528f,
+ 0.012794f, 0.014160f, 0.015717f, 0.017853f, 0.019958f, 0.022995f, 0.026291f, 0.030533f, 0.035553f, 0.041565f, 0.048981f, 0.058350f,
+ 0.069824f, 0.083801f, 0.101685f, 0.122437f, 0.148438f, 0.178833f, 0.215454f, 0.256104f, 0.302490f, 0.354736f, 0.741699f, 0.758789f,
+ 0.762695f, 0.763672f, 0.764648f, 0.765625f, 0.000097f, 0.000306f, 0.000370f, 0.000618f, 0.000713f, 0.000810f, 0.000953f, 0.000920f,
+ 0.001167f, 0.001238f, 0.001406f, 0.001483f, 0.001540f, 0.001794f, 0.001970f, 0.002028f, 0.002264f, 0.002354f, 0.002459f, 0.002636f,
+ 0.002827f, 0.003096f, 0.003342f, 0.003544f, 0.003881f, 0.003948f, 0.004459f, 0.004742f, 0.005005f, 0.005394f, 0.005867f, 0.006374f,
+ 0.006901f, 0.007507f, 0.008202f, 0.008881f, 0.010017f, 0.010986f, 0.012451f, 0.013809f, 0.015511f, 0.017776f, 0.020325f, 0.023453f,
+ 0.027390f, 0.032349f, 0.038330f, 0.045624f, 0.055359f, 0.067078f, 0.082275f, 0.101013f, 0.123657f, 0.151611f, 0.185791f, 0.225342f,
+ 0.270752f, 0.322754f, 0.727051f, 0.746094f, 0.749512f, 0.750977f, 0.751953f, 0.751953f, 0.000228f, 0.000211f, 0.000504f, 0.000443f,
+ 0.000523f, 0.000672f, 0.000703f, 0.000902f, 0.000975f, 0.001010f, 0.001122f, 0.001178f, 0.001257f, 0.001424f, 0.001575f, 0.001631f,
+ 0.001789f, 0.001910f, 0.002090f, 0.002144f, 0.002411f, 0.002520f, 0.002703f, 0.002827f, 0.003010f, 0.003195f, 0.003403f, 0.003750f,
+ 0.003960f, 0.004276f, 0.004780f, 0.005005f, 0.005432f, 0.005981f, 0.006428f, 0.007015f, 0.007812f, 0.008537f, 0.009415f, 0.010658f,
+ 0.011963f, 0.013443f, 0.015396f, 0.017731f, 0.020782f, 0.024414f, 0.029083f, 0.034912f, 0.042572f, 0.052216f, 0.064392f, 0.080017f,
+ 0.100220f, 0.126099f, 0.157227f, 0.194946f, 0.239136f, 0.290283f, 0.712402f, 0.731445f, 0.734863f, 0.736816f, 0.737305f, 0.737793f,
+ 0.000211f, 0.000198f, 0.000195f, 0.000413f, 0.000517f, 0.000531f, 0.000586f, 0.000736f, 0.000769f, 0.000809f, 0.000970f, 0.001007f,
+ 0.001067f, 0.001134f, 0.001211f, 0.001348f, 0.001341f, 0.001534f, 0.001617f, 0.001734f, 0.001942f, 0.002010f, 0.002110f, 0.002268f,
+ 0.002523f, 0.002607f, 0.002829f, 0.003004f, 0.003113f, 0.003403f, 0.003681f, 0.003990f, 0.004257f, 0.004601f, 0.005039f, 0.005444f,
+ 0.005993f, 0.006561f, 0.007278f, 0.008026f, 0.009041f, 0.010124f, 0.011513f, 0.013222f, 0.015320f, 0.017914f, 0.021408f, 0.025833f,
+ 0.031433f, 0.039429f, 0.049255f, 0.062286f, 0.079102f, 0.101135f, 0.130005f, 0.164917f, 0.207764f, 0.258057f, 0.696289f, 0.716309f,
+ 0.720215f, 0.722168f, 0.722656f, 0.723145f, 0.000000f, 0.000080f, 0.000286f, 0.000374f, 0.000434f, 0.000457f, 0.000460f, 0.000568f,
+ 0.000610f, 0.000669f, 0.000715f, 0.000773f, 0.000877f, 0.000918f, 0.001030f, 0.000998f, 0.001148f, 0.001134f, 0.001305f, 0.001369f,
+ 0.001410f, 0.001534f, 0.001688f, 0.001780f, 0.001899f, 0.001963f, 0.002081f, 0.002199f, 0.002470f, 0.002563f, 0.002758f, 0.003006f,
+ 0.003273f, 0.003531f, 0.003817f, 0.004093f, 0.004532f, 0.004993f, 0.005463f, 0.006027f, 0.006657f, 0.007492f, 0.008537f, 0.009689f,
+ 0.011246f, 0.012985f, 0.015518f, 0.018539f, 0.022827f, 0.028534f, 0.036072f, 0.046234f, 0.060028f, 0.078918f, 0.103943f, 0.136353f,
+ 0.176514f, 0.225952f, 0.679199f, 0.699707f, 0.703613f, 0.706055f, 0.706543f, 0.708008f, 0.000089f, 0.000176f, 0.000232f, 0.000342f,
+ 0.000317f, 0.000319f, 0.000420f, 0.000382f, 0.000494f, 0.000515f, 0.000612f, 0.000650f, 0.000671f, 0.000701f, 0.000732f, 0.000859f,
+ 0.000888f, 0.000923f, 0.001002f, 0.001048f, 0.001170f, 0.001234f, 0.001292f, 0.001426f, 0.001414f, 0.001476f, 0.001622f, 0.001723f,
+ 0.001892f, 0.001976f, 0.002237f, 0.002239f, 0.002476f, 0.002645f, 0.002817f, 0.003092f, 0.003355f, 0.003626f, 0.003979f, 0.004459f,
+ 0.004948f, 0.005527f, 0.006256f, 0.007027f, 0.008026f, 0.009270f, 0.010918f, 0.013184f, 0.016098f, 0.019913f, 0.025253f, 0.033112f,
+ 0.043762f, 0.059113f, 0.079956f, 0.109009f, 0.146729f, 0.193726f, 0.660645f, 0.682129f, 0.688477f, 0.690430f, 0.689941f, 0.690918f,
+ 0.000000f, 0.000063f, 0.000194f, 0.000281f, 0.000187f, 0.000325f, 0.000278f, 0.000272f, 0.000386f, 0.000466f, 0.000462f, 0.000510f,
+ 0.000519f, 0.000587f, 0.000613f, 0.000603f, 0.000671f, 0.000709f, 0.000744f, 0.000808f, 0.000858f, 0.000913f, 0.000963f, 0.000999f,
+ 0.001062f, 0.001106f, 0.001262f, 0.001266f, 0.001431f, 0.001562f, 0.001672f, 0.001693f, 0.001810f, 0.001976f, 0.002090f, 0.002289f,
+ 0.002422f, 0.002666f, 0.002916f, 0.003166f, 0.003513f, 0.003862f, 0.004318f, 0.004936f, 0.005646f, 0.006493f, 0.007626f, 0.009048f,
+ 0.010826f, 0.013519f, 0.017166f, 0.022476f, 0.030258f, 0.041687f, 0.058807f, 0.083435f, 0.117737f, 0.162598f, 0.644043f, 0.666504f,
+ 0.670410f, 0.673340f, 0.674316f, 0.675293f, 0.000000f, 0.000117f, 0.000112f, 0.000178f, 0.000216f, 0.000222f, 0.000271f, 0.000229f,
+ 0.000280f, 0.000283f, 0.000326f, 0.000376f, 0.000376f, 0.000443f, 0.000456f, 0.000470f, 0.000499f, 0.000507f, 0.000547f, 0.000566f,
+ 0.000613f, 0.000667f, 0.000692f, 0.000749f, 0.000773f, 0.000803f, 0.000917f, 0.000924f, 0.000997f, 0.001055f, 0.001096f, 0.001236f,
+ 0.001261f, 0.001376f, 0.001466f, 0.001693f, 0.001695f, 0.001826f, 0.002077f, 0.002226f, 0.002411f, 0.002686f, 0.002985f, 0.003368f,
+ 0.003801f, 0.004353f, 0.005131f, 0.005974f, 0.007370f, 0.008842f, 0.011345f, 0.014717f, 0.019699f, 0.027893f, 0.040619f, 0.060730f,
+ 0.090454f, 0.132080f, 0.625488f, 0.649414f, 0.653809f, 0.655273f, 0.656250f, 0.658203f, 0.000000f, 0.000000f, 0.000108f, 0.000121f,
+ 0.000136f, 0.000154f, 0.000158f, 0.000191f, 0.000203f, 0.000213f, 0.000270f, 0.000223f, 0.000232f, 0.000270f, 0.000296f, 0.000342f,
+ 0.000324f, 0.000352f, 0.000453f, 0.000407f, 0.000450f, 0.000459f, 0.000486f, 0.000524f, 0.000545f, 0.000565f, 0.000630f, 0.000620f,
+ 0.000678f, 0.000803f, 0.000763f, 0.000813f, 0.000860f, 0.000937f, 0.001035f, 0.001101f, 0.001141f, 0.001254f, 0.001399f, 0.001449f,
+ 0.001616f, 0.001779f, 0.001942f, 0.002220f, 0.002493f, 0.002808f, 0.003258f, 0.003895f, 0.004623f, 0.005714f, 0.007111f, 0.009178f,
+ 0.012367f, 0.017319f, 0.025879f, 0.040741f, 0.065552f, 0.103577f, 0.606934f, 0.630371f, 0.635254f, 0.637695f, 0.638672f, 0.639648f,
+ 0.000000f, 0.000109f, 0.000102f, 0.000098f, 0.000105f, 0.000110f, 0.000113f, 0.000122f, 0.000117f, 0.000132f, 0.000147f, 0.000189f,
+ 0.000163f, 0.000212f, 0.000213f, 0.000222f, 0.000224f, 0.000233f, 0.000258f, 0.000262f, 0.000274f, 0.000305f, 0.000340f, 0.000329f,
+ 0.000358f, 0.000376f, 0.000445f, 0.000418f, 0.000447f, 0.000478f, 0.000546f, 0.000530f, 0.000594f, 0.000626f, 0.000679f, 0.000745f,
+ 0.000763f, 0.000804f, 0.000869f, 0.000952f, 0.001025f, 0.001119f, 0.001254f, 0.001359f, 0.001584f, 0.001728f, 0.001993f, 0.002295f,
+ 0.002790f, 0.003298f, 0.004135f, 0.005363f, 0.007267f, 0.010277f, 0.015350f, 0.024994f, 0.043518f, 0.076599f, 0.585938f, 0.611816f,
+ 0.616211f, 0.619141f, 0.619629f, 0.620605f, 0.000000f, 0.000102f, 0.000095f, 0.000090f, 0.000085f, 0.000081f, 0.000078f, 0.000073f,
+ 0.000075f, 0.000079f, 0.000087f, 0.000092f, 0.000095f, 0.000094f, 0.000133f, 0.000143f, 0.000152f, 0.000155f, 0.000161f, 0.000195f,
+ 0.000174f, 0.000183f, 0.000188f, 0.000216f, 0.000233f, 0.000241f, 0.000241f, 0.000257f, 0.000269f, 0.000302f, 0.000325f, 0.000321f,
+ 0.000350f, 0.000363f, 0.000405f, 0.000426f, 0.000456f, 0.000486f, 0.000539f, 0.000560f, 0.000614f, 0.000671f, 0.000722f, 0.000811f,
+ 0.000891f, 0.000989f, 0.001162f, 0.001312f, 0.001545f, 0.001863f, 0.002340f, 0.002920f, 0.003963f, 0.005615f, 0.008499f, 0.013931f,
+ 0.025833f, 0.052094f, 0.566406f, 0.591797f, 0.597168f, 0.599609f, 0.601074f, 0.601562f, 0.000110f, 0.000092f, 0.000084f, 0.000077f,
+ 0.000073f, 0.000070f, 0.000067f, 0.000064f, 0.000061f, 0.000058f, 0.000055f, 0.000064f, 0.000051f, 0.000054f, 0.000071f, 0.000059f,
+ 0.000082f, 0.000081f, 0.000090f, 0.000087f, 0.000099f, 0.000103f, 0.000127f, 0.000131f, 0.000135f, 0.000139f, 0.000142f, 0.000143f,
+ 0.000156f, 0.000162f, 0.000173f, 0.000194f, 0.000206f, 0.000201f, 0.000233f, 0.000225f, 0.000246f, 0.000294f, 0.000279f, 0.000313f,
+ 0.000333f, 0.000356f, 0.000395f, 0.000432f, 0.000459f, 0.000511f, 0.000577f, 0.000664f, 0.000770f, 0.000916f, 0.001114f, 0.001400f,
+ 0.001881f, 0.002665f, 0.004093f, 0.006966f, 0.013290f, 0.031525f, 0.545410f, 0.571777f, 0.577637f, 0.579102f, 0.580566f, 0.581055f,
+ 0.000093f, 0.000073f, 0.000066f, 0.000061f, 0.000056f, 0.000054f, 0.000051f, 0.000050f, 0.000048f, 0.000047f, 0.000045f, 0.000044f,
+ 0.000042f, 0.000040f, 0.000038f, 0.000036f, 0.000039f, 0.000033f, 0.000041f, 0.000040f, 0.000046f, 0.000048f, 0.000051f, 0.000057f,
+ 0.000060f, 0.000066f, 0.000062f, 0.000067f, 0.000080f, 0.000085f, 0.000088f, 0.000092f, 0.000092f, 0.000097f, 0.000109f, 0.000109f,
+ 0.000117f, 0.000132f, 0.000134f, 0.000147f, 0.000154f, 0.000156f, 0.000188f, 0.000197f, 0.000219f, 0.000234f, 0.000266f, 0.000286f,
+ 0.000335f, 0.000397f, 0.000472f, 0.000566f, 0.000751f, 0.001039f, 0.001626f, 0.002834f, 0.005909f, 0.015411f, 0.524414f, 0.551270f,
+ 0.557129f, 0.559570f, 0.561035f, 0.561523f, 0.000060f, 0.000046f, 0.000039f, 0.000037f, 0.000034f, 0.000034f, 0.000032f, 0.000032f,
+ 0.000031f, 0.000029f, 0.000029f, 0.000029f, 0.000028f, 0.000028f, 0.000028f, 0.000027f, 0.000026f, 0.000025f, 0.000024f, 0.000023f,
+ 0.000022f, 0.000021f, 0.000020f, 0.000021f, 0.000020f, 0.000018f, 0.000018f, 0.000023f, 0.000024f, 0.000028f, 0.000032f, 0.000033f,
+ 0.000032f, 0.000038f, 0.000039f, 0.000043f, 0.000046f, 0.000050f, 0.000052f, 0.000053f, 0.000057f, 0.000067f, 0.000073f, 0.000068f,
+ 0.000076f, 0.000083f, 0.000097f, 0.000110f, 0.000116f, 0.000127f, 0.000157f, 0.000185f, 0.000246f, 0.000319f, 0.000466f, 0.000810f,
+ 0.001841f, 0.005795f, 0.503418f, 0.531250f, 0.536621f, 0.539062f, 0.540039f, 0.540527f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000004f, 0.000005f, 0.000005f, 0.000008f, 0.000008f, 0.000009f, 0.000009f, 0.000010f, 0.000010f, 0.000010f, 0.000010f, 0.000011f,
+ 0.000011f, 0.000011f, 0.000011f, 0.000011f, 0.000012f, 0.000012f, 0.000012f, 0.000012f, 0.000012f, 0.000012f, 0.000011f, 0.000011f,
+ 0.000010f, 0.000010f, 0.000009f, 0.000009f, 0.000009f, 0.000008f, 0.000008f, 0.000008f, 0.000009f, 0.000009f, 0.000010f, 0.000012f,
+ 0.000013f, 0.000014f, 0.000015f, 0.000017f, 0.000020f, 0.000021f, 0.000018f, 0.000023f, 0.000023f, 0.000025f, 0.000030f, 0.000038f,
+ 0.000043f, 0.000059f, 0.000079f, 0.000131f, 0.000279f, 0.001210f, 0.481934f, 0.510254f, 0.516113f, 0.518555f, 0.520020f, 0.520508f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000001f, 0.000001f,
+ 0.000001f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000002f,
+ 0.000001f, 0.000001f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000003f, 0.000004f, 0.000006f, 0.000022f, 0.460449f, 0.489258f,
+ 0.495850f, 0.498291f, 0.499512f, 0.500000f,
+ },
+ {
+ 0.038544f, 0.111450f, 0.177368f, 0.237061f, 0.290771f, 0.339600f, 0.384277f, 0.425293f, 0.462402f, 0.497070f, 0.527344f, 0.556152f,
+ 0.583496f, 0.607910f, 0.630859f, 0.652344f, 0.672852f, 0.690918f, 0.708496f, 0.724609f, 0.740723f, 0.754883f, 0.768066f, 0.780273f,
+ 0.792480f, 0.803711f, 0.815430f, 0.825684f, 0.835449f, 0.844727f, 0.853516f, 0.861816f, 0.870117f, 0.877930f, 0.885254f, 0.892578f,
+ 0.899414f, 0.905762f, 0.912109f, 0.918945f, 0.923828f, 0.928711f, 0.934082f, 0.939941f, 0.944824f, 0.949707f, 0.953613f, 0.958496f,
+ 0.962402f, 0.967285f, 0.971191f, 0.974609f, 0.979004f, 0.982422f, 0.985352f, 0.989258f, 0.992188f, 0.996094f, 0.996094f, 0.990723f,
+ 0.986328f, 0.982422f, 0.978516f, 0.975098f, 0.029068f, 0.087219f, 0.142578f, 0.195190f, 0.244629f, 0.291016f, 0.334717f, 0.375000f,
+ 0.412842f, 0.446533f, 0.481201f, 0.511230f, 0.539062f, 0.565918f, 0.590820f, 0.614258f, 0.636719f, 0.656250f, 0.675293f, 0.693359f,
+ 0.710449f, 0.726562f, 0.741699f, 0.755371f, 0.769043f, 0.781738f, 0.793457f, 0.805176f, 0.815918f, 0.826660f, 0.835938f, 0.845703f,
+ 0.854980f, 0.862793f, 0.871582f, 0.879395f, 0.885742f, 0.894531f, 0.900879f, 0.907227f, 0.913086f, 0.919434f, 0.925293f, 0.931152f,
+ 0.936523f, 0.941406f, 0.946777f, 0.951172f, 0.956055f, 0.960449f, 0.964355f, 0.968750f, 0.972656f, 0.976562f, 0.980469f, 0.984375f,
+ 0.987793f, 0.991211f, 0.994141f, 0.989258f, 0.984863f, 0.981445f, 0.977539f, 0.974121f, 0.023346f, 0.069641f, 0.115601f, 0.160767f,
+ 0.205078f, 0.248047f, 0.289062f, 0.328125f, 0.365723f, 0.401367f, 0.435059f, 0.466309f, 0.495361f, 0.523926f, 0.550781f, 0.574707f,
+ 0.597168f, 0.620117f, 0.641113f, 0.660156f, 0.679688f, 0.696777f, 0.713379f, 0.728516f, 0.743652f, 0.757324f, 0.770996f, 0.784180f,
+ 0.795410f, 0.806641f, 0.817383f, 0.828125f, 0.837891f, 0.847168f, 0.855957f, 0.864258f, 0.873047f, 0.880859f, 0.888672f, 0.895996f,
+ 0.902832f, 0.909668f, 0.915039f, 0.921875f, 0.927246f, 0.934082f, 0.937988f, 0.943848f, 0.948242f, 0.953613f, 0.958496f, 0.962402f,
+ 0.967285f, 0.971191f, 0.975098f, 0.979492f, 0.983398f, 0.985840f, 0.992188f, 0.987305f, 0.983398f, 0.979980f, 0.977051f, 0.973633f,
+ 0.018600f, 0.056366f, 0.094299f, 0.133545f, 0.172729f, 0.211670f, 0.249756f, 0.285889f, 0.322021f, 0.356934f, 0.390869f, 0.421875f,
+ 0.452148f, 0.481201f, 0.509277f, 0.535156f, 0.560059f, 0.583496f, 0.605957f, 0.626465f, 0.647949f, 0.665527f, 0.684570f, 0.700684f,
+ 0.717285f, 0.731934f, 0.746582f, 0.760254f, 0.773926f, 0.786621f, 0.799316f, 0.809082f, 0.820312f, 0.830566f, 0.840332f, 0.850098f,
+ 0.858887f, 0.867188f, 0.875000f, 0.883789f, 0.890625f, 0.898926f, 0.904297f, 0.912109f, 0.916992f, 0.924316f, 0.930176f, 0.935547f,
+ 0.941406f, 0.945801f, 0.951172f, 0.956055f, 0.960938f, 0.964844f, 0.969727f, 0.974609f, 0.978516f, 0.981934f, 0.989746f, 0.985840f,
+ 0.981934f, 0.978516f, 0.975586f, 0.972168f, 0.015068f, 0.046143f, 0.077881f, 0.111816f, 0.145264f, 0.179688f, 0.214600f, 0.249023f,
+ 0.282715f, 0.316406f, 0.348389f, 0.380615f, 0.411133f, 0.440430f, 0.468018f, 0.494873f, 0.520508f, 0.546387f, 0.568848f, 0.591309f,
+ 0.613281f, 0.634277f, 0.653809f, 0.670898f, 0.688477f, 0.706055f, 0.721191f, 0.736328f, 0.751465f, 0.764648f, 0.776855f, 0.789551f,
+ 0.801270f, 0.812500f, 0.823730f, 0.833496f, 0.843262f, 0.853027f, 0.861328f, 0.869629f, 0.878418f, 0.885742f, 0.893555f, 0.900391f,
+ 0.908203f, 0.914551f, 0.921387f, 0.927246f, 0.932617f, 0.938965f, 0.943848f, 0.949219f, 0.953613f, 0.959473f, 0.963867f, 0.968262f,
+ 0.972656f, 0.977051f, 0.987305f, 0.983887f, 0.980957f, 0.977051f, 0.974121f, 0.970703f, 0.012444f, 0.037933f, 0.065613f, 0.093811f,
+ 0.123474f, 0.153809f, 0.185059f, 0.215820f, 0.247559f, 0.279297f, 0.310547f, 0.341309f, 0.370361f, 0.399658f, 0.428467f, 0.457031f,
+ 0.482910f, 0.507812f, 0.533203f, 0.556152f, 0.579590f, 0.600098f, 0.621094f, 0.641113f, 0.659668f, 0.676270f, 0.695312f, 0.710449f,
+ 0.726074f, 0.740723f, 0.756348f, 0.769043f, 0.780762f, 0.794434f, 0.805176f, 0.816895f, 0.827637f, 0.837891f, 0.847168f, 0.855957f,
+ 0.865723f, 0.873535f, 0.882324f, 0.889648f, 0.897949f, 0.904297f, 0.911133f, 0.917480f, 0.924316f, 0.930176f, 0.936523f, 0.941895f,
+ 0.947266f, 0.952637f, 0.958008f, 0.962891f, 0.967285f, 0.971680f, 0.984863f, 0.981934f, 0.978516f, 0.975586f, 0.972656f, 0.969238f,
+ 0.010353f, 0.032043f, 0.055359f, 0.079529f, 0.104980f, 0.131836f, 0.159424f, 0.187866f, 0.216431f, 0.245239f, 0.275146f, 0.304199f,
+ 0.333496f, 0.362061f, 0.390869f, 0.417969f, 0.445068f, 0.471191f, 0.496582f, 0.520508f, 0.543457f, 0.566895f, 0.588867f, 0.608398f,
+ 0.628906f, 0.648438f, 0.666992f, 0.684570f, 0.701660f, 0.716797f, 0.732422f, 0.746582f, 0.760254f, 0.773438f, 0.786133f, 0.798340f,
+ 0.810547f, 0.821777f, 0.832520f, 0.842773f, 0.851074f, 0.860352f, 0.869629f, 0.878906f, 0.886230f, 0.894043f, 0.901855f, 0.908691f,
+ 0.915527f, 0.922363f, 0.928223f, 0.935059f, 0.939941f, 0.945312f, 0.950684f, 0.956055f, 0.962402f, 0.966797f, 0.982910f, 0.979980f,
+ 0.977051f, 0.973633f, 0.970703f, 0.968262f, 0.008598f, 0.027328f, 0.046417f, 0.067871f, 0.089905f, 0.113220f, 0.137695f, 0.163330f,
+ 0.189087f, 0.216064f, 0.243164f, 0.270752f, 0.298340f, 0.326416f, 0.354004f, 0.381348f, 0.407715f, 0.434082f, 0.460205f, 0.484863f,
+ 0.508789f, 0.532227f, 0.555176f, 0.577637f, 0.598145f, 0.618652f, 0.637695f, 0.657227f, 0.674805f, 0.691406f, 0.708008f, 0.723633f,
+ 0.738770f, 0.751953f, 0.766113f, 0.779785f, 0.791992f, 0.804199f, 0.815918f, 0.825684f, 0.836914f, 0.846680f, 0.856934f, 0.866211f,
+ 0.874512f, 0.882324f, 0.890625f, 0.898438f, 0.905273f, 0.913086f, 0.919922f, 0.926758f, 0.933105f, 0.938477f, 0.944824f, 0.951172f,
+ 0.955566f, 0.960938f, 0.980469f, 0.978027f, 0.974609f, 0.972168f, 0.969238f, 0.966797f, 0.007561f, 0.023315f, 0.040344f, 0.058228f,
+ 0.077148f, 0.097534f, 0.119995f, 0.142212f, 0.165649f, 0.190063f, 0.214722f, 0.240601f, 0.266846f, 0.293457f, 0.319824f, 0.346924f,
+ 0.372314f, 0.398438f, 0.424561f, 0.449463f, 0.474609f, 0.498535f, 0.521973f, 0.544434f, 0.566895f, 0.587402f, 0.608398f, 0.628418f,
+ 0.645996f, 0.665039f, 0.683105f, 0.699219f, 0.716309f, 0.731445f, 0.745117f, 0.760254f, 0.772949f, 0.786133f, 0.799316f, 0.809570f,
+ 0.820801f, 0.832031f, 0.843262f, 0.852051f, 0.861816f, 0.871094f, 0.880371f, 0.887695f, 0.895996f, 0.904297f, 0.911133f, 0.917969f,
+ 0.924805f, 0.931641f, 0.937012f, 0.943848f, 0.949707f, 0.954590f, 0.978027f, 0.976074f, 0.973145f, 0.970215f, 0.967773f, 0.965332f,
+ 0.006416f, 0.020065f, 0.034943f, 0.050537f, 0.067078f, 0.084900f, 0.104065f, 0.123962f, 0.145264f, 0.166748f, 0.189575f, 0.213501f,
+ 0.237305f, 0.262451f, 0.288574f, 0.313477f, 0.338623f, 0.364502f, 0.389893f, 0.414551f, 0.440186f, 0.464600f, 0.487549f, 0.510742f,
+ 0.534668f, 0.556641f, 0.578613f, 0.598145f, 0.618652f, 0.637207f, 0.655273f, 0.674805f, 0.690430f, 0.707031f, 0.724121f, 0.739258f,
+ 0.752930f, 0.767090f, 0.779785f, 0.792969f, 0.805176f, 0.816895f, 0.827637f, 0.838379f, 0.849121f, 0.858398f, 0.868652f, 0.876465f,
+ 0.885742f, 0.894043f, 0.901855f, 0.909180f, 0.916992f, 0.923828f, 0.930176f, 0.937012f, 0.943359f, 0.949707f, 0.975586f, 0.973633f,
+ 0.971191f, 0.968262f, 0.965820f, 0.963379f, 0.005802f, 0.017502f, 0.030045f, 0.043823f, 0.058014f, 0.074280f, 0.090759f, 0.108459f,
+ 0.127197f, 0.146484f, 0.167725f, 0.189087f, 0.211304f, 0.234497f, 0.258301f, 0.282471f, 0.307373f, 0.331299f, 0.356689f, 0.381104f,
+ 0.405762f, 0.430420f, 0.455078f, 0.478516f, 0.502441f, 0.524414f, 0.545898f, 0.568359f, 0.588867f, 0.608887f, 0.628906f, 0.646973f,
+ 0.665527f, 0.684082f, 0.701172f, 0.715820f, 0.731934f, 0.746582f, 0.760742f, 0.774414f, 0.787598f, 0.800781f, 0.812500f, 0.823730f,
+ 0.834961f, 0.845703f, 0.855469f, 0.865234f, 0.874512f, 0.883789f, 0.892090f, 0.899902f, 0.908203f, 0.916016f, 0.922852f, 0.930176f,
+ 0.936523f, 0.942871f, 0.972656f, 0.971191f, 0.968750f, 0.966309f, 0.963867f, 0.961426f, 0.004734f, 0.014984f, 0.026169f, 0.038177f,
+ 0.051208f, 0.065186f, 0.079468f, 0.095276f, 0.111633f, 0.129639f, 0.148071f, 0.167969f, 0.188599f, 0.208984f, 0.231689f, 0.254639f,
+ 0.277832f, 0.301025f, 0.325439f, 0.349854f, 0.373779f, 0.397705f, 0.422607f, 0.446045f, 0.469727f, 0.492676f, 0.514648f, 0.537598f,
+ 0.559570f, 0.580078f, 0.600586f, 0.620117f, 0.639648f, 0.658203f, 0.676758f, 0.692871f, 0.708984f, 0.725586f, 0.740723f, 0.755859f,
+ 0.769531f, 0.783691f, 0.796875f, 0.808594f, 0.820801f, 0.832520f, 0.842285f, 0.852539f, 0.862793f, 0.872070f, 0.881836f, 0.890137f,
+ 0.898926f, 0.906738f, 0.915039f, 0.922363f, 0.929199f, 0.936523f, 0.969727f, 0.968750f, 0.966797f, 0.964355f, 0.961914f, 0.959473f,
+ 0.004055f, 0.013588f, 0.023132f, 0.033722f, 0.044891f, 0.057343f, 0.069763f, 0.083923f, 0.098389f, 0.114441f, 0.131226f, 0.148682f,
+ 0.167603f, 0.186768f, 0.207031f, 0.228516f, 0.250732f, 0.272949f, 0.295410f, 0.318604f, 0.342285f, 0.365967f, 0.390381f, 0.413574f,
+ 0.437744f, 0.460938f, 0.484131f, 0.506348f, 0.528320f, 0.550781f, 0.572266f, 0.592773f, 0.613281f, 0.632812f, 0.651367f, 0.669922f,
+ 0.687500f, 0.704102f, 0.720215f, 0.735840f, 0.751465f, 0.764160f, 0.778809f, 0.792480f, 0.803711f, 0.816895f, 0.829102f, 0.840332f,
+ 0.850586f, 0.860352f, 0.870605f, 0.880371f, 0.889648f, 0.897949f, 0.905762f, 0.914551f, 0.922363f, 0.929199f, 0.967285f, 0.966797f,
+ 0.964844f, 0.961426f, 0.959473f, 0.958008f, 0.003611f, 0.011971f, 0.020401f, 0.030029f, 0.039185f, 0.050415f, 0.061737f, 0.074341f,
+ 0.086975f, 0.101074f, 0.115845f, 0.131958f, 0.148682f, 0.166626f, 0.185059f, 0.205200f, 0.224854f, 0.245483f, 0.267334f, 0.290771f,
+ 0.312988f, 0.335449f, 0.359619f, 0.382080f, 0.406250f, 0.429443f, 0.452881f, 0.475830f, 0.498779f, 0.520996f, 0.542480f, 0.563477f,
+ 0.584473f, 0.604980f, 0.625977f, 0.643555f, 0.663086f, 0.681152f, 0.698242f, 0.714355f, 0.729980f, 0.746582f, 0.760742f, 0.774902f,
+ 0.788086f, 0.801758f, 0.814941f, 0.826660f, 0.838867f, 0.848633f, 0.859863f, 0.869141f, 0.879395f, 0.889160f, 0.897949f, 0.906250f,
+ 0.914551f, 0.922363f, 0.963867f, 0.964355f, 0.961914f, 0.959961f, 0.957520f, 0.955078f, 0.003393f, 0.010361f, 0.018494f, 0.026337f,
+ 0.035187f, 0.044556f, 0.054596f, 0.065186f, 0.077515f, 0.089783f, 0.102783f, 0.117249f, 0.132446f, 0.148071f, 0.165649f, 0.183838f,
+ 0.202026f, 0.221313f, 0.241943f, 0.262939f, 0.285156f, 0.307129f, 0.329102f, 0.352539f, 0.375977f, 0.398438f, 0.421875f, 0.445312f,
+ 0.468750f, 0.490723f, 0.512695f, 0.534668f, 0.556641f, 0.577637f, 0.598633f, 0.619141f, 0.637695f, 0.656738f, 0.674805f, 0.692383f,
+ 0.709473f, 0.726074f, 0.742188f, 0.756836f, 0.771973f, 0.786133f, 0.799316f, 0.812012f, 0.824707f, 0.835938f, 0.848145f, 0.858887f,
+ 0.868164f, 0.878906f, 0.888184f, 0.897949f, 0.906250f, 0.914551f, 0.960938f, 0.960938f, 0.959473f, 0.957520f, 0.955078f, 0.953125f,
+ 0.003084f, 0.009521f, 0.016144f, 0.023346f, 0.031204f, 0.039520f, 0.048523f, 0.057953f, 0.068359f, 0.079895f, 0.091309f, 0.104126f,
+ 0.117920f, 0.132324f, 0.147949f, 0.164062f, 0.181396f, 0.199219f, 0.218872f, 0.238403f, 0.258545f, 0.279541f, 0.301758f, 0.323486f,
+ 0.346191f, 0.368408f, 0.391846f, 0.414795f, 0.437256f, 0.460693f, 0.483643f, 0.505371f, 0.527832f, 0.550293f, 0.571289f, 0.591797f,
+ 0.612305f, 0.632324f, 0.651855f, 0.670898f, 0.687500f, 0.705566f, 0.722168f, 0.737793f, 0.753418f, 0.768555f, 0.783691f, 0.796875f,
+ 0.811035f, 0.823242f, 0.834473f, 0.846191f, 0.857422f, 0.868652f, 0.878418f, 0.887695f, 0.897949f, 0.906250f, 0.958008f, 0.958008f,
+ 0.957031f, 0.954590f, 0.952637f, 0.950684f, 0.002666f, 0.008293f, 0.014297f, 0.021225f, 0.027847f, 0.035156f, 0.043274f, 0.051666f,
+ 0.060791f, 0.070801f, 0.081543f, 0.092407f, 0.104858f, 0.118530f, 0.131836f, 0.146606f, 0.162598f, 0.179443f, 0.196777f, 0.215210f,
+ 0.234375f, 0.254150f, 0.274414f, 0.295898f, 0.317871f, 0.340088f, 0.362549f, 0.385010f, 0.407959f, 0.430664f, 0.454590f, 0.476562f,
+ 0.499268f, 0.521484f, 0.543945f, 0.564941f, 0.585938f, 0.606934f, 0.626465f, 0.646484f, 0.665527f, 0.683594f, 0.701660f, 0.717773f,
+ 0.735352f, 0.751465f, 0.766113f, 0.781738f, 0.794922f, 0.808105f, 0.821289f, 0.833496f, 0.846191f, 0.857910f, 0.868164f, 0.878906f,
+ 0.889160f, 0.899414f, 0.954102f, 0.955566f, 0.953613f, 0.952148f, 0.950195f, 0.948730f, 0.002396f, 0.007427f, 0.012978f, 0.018646f,
+ 0.025024f, 0.031403f, 0.038788f, 0.046112f, 0.054260f, 0.063354f, 0.072693f, 0.082886f, 0.093689f, 0.105469f, 0.118164f, 0.130859f,
+ 0.145996f, 0.161011f, 0.177124f, 0.193359f, 0.211670f, 0.230225f, 0.249634f, 0.270020f, 0.290771f, 0.311768f, 0.333740f, 0.356201f,
+ 0.378906f, 0.401855f, 0.424561f, 0.447754f, 0.470215f, 0.493408f, 0.515137f, 0.537109f, 0.559570f, 0.580078f, 0.601074f, 0.621582f,
+ 0.642090f, 0.661621f, 0.679688f, 0.697754f, 0.715820f, 0.732422f, 0.749512f, 0.765137f, 0.779785f, 0.794434f, 0.808594f, 0.821289f,
+ 0.833496f, 0.846191f, 0.857910f, 0.869141f, 0.879883f, 0.889648f, 0.950195f, 0.952637f, 0.950684f, 0.948730f, 0.947266f, 0.945801f,
+ 0.002029f, 0.006672f, 0.011658f, 0.016937f, 0.022476f, 0.028305f, 0.034332f, 0.041351f, 0.048584f, 0.056671f, 0.064697f, 0.073853f,
+ 0.083923f, 0.094482f, 0.105225f, 0.117798f, 0.130615f, 0.144287f, 0.159302f, 0.174683f, 0.190430f, 0.208740f, 0.226318f, 0.245483f,
+ 0.264893f, 0.285400f, 0.307129f, 0.328369f, 0.350342f, 0.372803f, 0.395264f, 0.418701f, 0.441650f, 0.462891f, 0.486816f, 0.509277f,
+ 0.532227f, 0.553711f, 0.575684f, 0.596680f, 0.617676f, 0.638672f, 0.657715f, 0.676758f, 0.695312f, 0.712402f, 0.729492f, 0.746582f,
+ 0.762695f, 0.778320f, 0.793457f, 0.807129f, 0.820801f, 0.833984f, 0.846191f, 0.858887f, 0.869629f, 0.881836f, 0.947266f, 0.949219f,
+ 0.947754f, 0.946289f, 0.944824f, 0.942871f, 0.002142f, 0.006401f, 0.010841f, 0.015251f, 0.019760f, 0.025055f, 0.031113f, 0.037201f,
+ 0.043671f, 0.050598f, 0.057892f, 0.066101f, 0.075012f, 0.084351f, 0.093994f, 0.105164f, 0.117432f, 0.129517f, 0.142822f, 0.157104f,
+ 0.172119f, 0.188110f, 0.204956f, 0.223145f, 0.241577f, 0.260498f, 0.280762f, 0.301758f, 0.322998f, 0.345215f, 0.366943f, 0.389893f,
+ 0.412842f, 0.435791f, 0.458008f, 0.482178f, 0.504395f, 0.526855f, 0.548828f, 0.571289f, 0.592285f, 0.612793f, 0.634277f, 0.654297f,
+ 0.673340f, 0.692383f, 0.710938f, 0.729004f, 0.745117f, 0.762207f, 0.777832f, 0.792480f, 0.807129f, 0.821289f, 0.834961f, 0.847168f,
+ 0.859863f, 0.871582f, 0.943359f, 0.946289f, 0.944824f, 0.943359f, 0.941895f, 0.940430f, 0.001760f, 0.005562f, 0.009621f, 0.013710f,
+ 0.018417f, 0.022736f, 0.027939f, 0.033264f, 0.039185f, 0.045166f, 0.052460f, 0.059143f, 0.067261f, 0.075745f, 0.084106f, 0.094177f,
+ 0.104980f, 0.116455f, 0.128174f, 0.141113f, 0.155151f, 0.169922f, 0.184937f, 0.201660f, 0.219238f, 0.237549f, 0.256348f, 0.276367f,
+ 0.296875f, 0.317871f, 0.339844f, 0.361572f, 0.383789f, 0.407227f, 0.430908f, 0.453857f, 0.476807f, 0.498779f, 0.521973f, 0.543945f,
+ 0.567383f, 0.589355f, 0.609863f, 0.631348f, 0.651855f, 0.671875f, 0.690918f, 0.709961f, 0.727539f, 0.744141f, 0.761719f, 0.777344f,
+ 0.793457f, 0.808594f, 0.823242f, 0.835449f, 0.848633f, 0.861328f, 0.938965f, 0.941895f, 0.941406f, 0.940430f, 0.938477f, 0.937012f,
+ 0.001594f, 0.005283f, 0.008789f, 0.012383f, 0.016342f, 0.020523f, 0.025284f, 0.029968f, 0.035217f, 0.040741f, 0.046417f, 0.052948f,
+ 0.060120f, 0.067566f, 0.076294f, 0.084534f, 0.093750f, 0.104614f, 0.115173f, 0.126831f, 0.139160f, 0.152832f, 0.166748f, 0.181885f,
+ 0.198853f, 0.215698f, 0.233521f, 0.252197f, 0.271973f, 0.291992f, 0.313477f, 0.334717f, 0.357178f, 0.379395f, 0.401855f, 0.425537f,
+ 0.448242f, 0.471924f, 0.495361f, 0.517578f, 0.541016f, 0.562988f, 0.585938f, 0.607422f, 0.627930f, 0.649414f, 0.670410f, 0.688965f,
+ 0.708496f, 0.727539f, 0.744629f, 0.761719f, 0.778809f, 0.794922f, 0.809082f, 0.824219f, 0.838379f, 0.851074f, 0.935059f, 0.938965f,
+ 0.937988f, 0.937012f, 0.936035f, 0.933594f, 0.001564f, 0.004665f, 0.007973f, 0.011276f, 0.014908f, 0.018600f, 0.022675f, 0.027176f,
+ 0.031464f, 0.036621f, 0.042023f, 0.047974f, 0.054108f, 0.060822f, 0.068237f, 0.075684f, 0.084229f, 0.093567f, 0.103210f, 0.113892f,
+ 0.125000f, 0.137329f, 0.150269f, 0.164307f, 0.179810f, 0.194946f, 0.212158f, 0.229248f, 0.247925f, 0.267578f, 0.287842f, 0.308350f,
+ 0.330322f, 0.352051f, 0.374756f, 0.397461f, 0.420654f, 0.444092f, 0.466797f, 0.490723f, 0.514160f, 0.537109f, 0.560059f, 0.582031f,
+ 0.604980f, 0.626953f, 0.648926f, 0.668457f, 0.688477f, 0.708008f, 0.727539f, 0.745117f, 0.763672f, 0.779297f, 0.795410f, 0.811523f,
+ 0.826660f, 0.840332f, 0.930664f, 0.934570f, 0.934082f, 0.933594f, 0.932129f, 0.930664f, 0.001424f, 0.004261f, 0.007122f, 0.010239f,
+ 0.013374f, 0.016693f, 0.020401f, 0.024368f, 0.028595f, 0.033325f, 0.037964f, 0.043152f, 0.048340f, 0.054962f, 0.060730f, 0.067749f,
+ 0.075684f, 0.083862f, 0.092041f, 0.102051f, 0.112305f, 0.123657f, 0.135376f, 0.148071f, 0.161987f, 0.176270f, 0.192139f, 0.208252f,
+ 0.226196f, 0.244141f, 0.263672f, 0.283447f, 0.304199f, 0.325195f, 0.346924f, 0.370605f, 0.392822f, 0.416260f, 0.439209f, 0.463623f,
+ 0.486084f, 0.511230f, 0.534180f, 0.558105f, 0.580566f, 0.603516f, 0.625000f, 0.647461f, 0.668457f, 0.688965f, 0.708496f, 0.727539f,
+ 0.746582f, 0.764160f, 0.781738f, 0.798340f, 0.813477f, 0.829590f, 0.926758f, 0.931152f, 0.930664f, 0.929199f, 0.928223f, 0.927246f,
+ 0.001294f, 0.004196f, 0.006538f, 0.009346f, 0.012306f, 0.015335f, 0.018845f, 0.022003f, 0.025558f, 0.029816f, 0.034149f, 0.038605f,
+ 0.043915f, 0.049042f, 0.054810f, 0.061188f, 0.067993f, 0.075256f, 0.083130f, 0.091553f, 0.100769f, 0.110779f, 0.121643f, 0.133057f,
+ 0.145630f, 0.159058f, 0.173218f, 0.188721f, 0.204590f, 0.222290f, 0.240234f, 0.259277f, 0.279053f, 0.299561f, 0.321533f, 0.343506f,
+ 0.365723f, 0.389404f, 0.412354f, 0.436035f, 0.459961f, 0.484131f, 0.508301f, 0.532227f, 0.555176f, 0.579102f, 0.601562f, 0.624512f,
+ 0.646484f, 0.668457f, 0.688965f, 0.709473f, 0.729004f, 0.748047f, 0.766602f, 0.784668f, 0.800293f, 0.817383f, 0.921875f, 0.926270f,
+ 0.926270f, 0.925781f, 0.924316f, 0.923340f, 0.001081f, 0.003603f, 0.006027f, 0.008575f, 0.010979f, 0.013847f, 0.016937f, 0.020020f,
+ 0.023315f, 0.026917f, 0.030930f, 0.035156f, 0.039429f, 0.044098f, 0.049622f, 0.054779f, 0.060791f, 0.067566f, 0.074341f, 0.082336f,
+ 0.090515f, 0.099548f, 0.109070f, 0.119263f, 0.130981f, 0.143188f, 0.156250f, 0.170288f, 0.185303f, 0.201294f, 0.218262f, 0.236450f,
+ 0.255615f, 0.275391f, 0.295654f, 0.316895f, 0.339111f, 0.362061f, 0.385498f, 0.408936f, 0.432861f, 0.457275f, 0.481689f, 0.505371f,
+ 0.529785f, 0.553711f, 0.577637f, 0.601074f, 0.624023f, 0.646484f, 0.669434f, 0.689941f, 0.711426f, 0.731445f, 0.750977f, 0.770020f,
+ 0.787598f, 0.804688f, 0.916992f, 0.922363f, 0.922363f, 0.921875f, 0.920898f, 0.918945f, 0.001064f, 0.003231f, 0.005322f, 0.007710f,
+ 0.010323f, 0.012489f, 0.015244f, 0.018051f, 0.020798f, 0.024338f, 0.027893f, 0.031738f, 0.035553f, 0.039795f, 0.044495f, 0.049133f,
+ 0.054657f, 0.060608f, 0.066895f, 0.073792f, 0.081421f, 0.089050f, 0.097717f, 0.106934f, 0.117554f, 0.128540f, 0.140503f, 0.153442f,
+ 0.167236f, 0.182129f, 0.197998f, 0.214966f, 0.232422f, 0.251465f, 0.271240f, 0.291992f, 0.313232f, 0.335693f, 0.358643f, 0.382080f,
+ 0.406006f, 0.430176f, 0.454590f, 0.479004f, 0.503906f, 0.528320f, 0.552734f, 0.577637f, 0.601562f, 0.625000f, 0.648438f, 0.670898f,
+ 0.691895f, 0.713867f, 0.733887f, 0.754883f, 0.774414f, 0.791992f, 0.912109f, 0.917969f, 0.918457f, 0.916992f, 0.916016f, 0.915039f,
+ 0.000998f, 0.003012f, 0.005123f, 0.007114f, 0.009438f, 0.011360f, 0.013763f, 0.016510f, 0.018951f, 0.022171f, 0.025101f, 0.028305f,
+ 0.031830f, 0.035736f, 0.039795f, 0.044067f, 0.048950f, 0.053864f, 0.059601f, 0.066345f, 0.072815f, 0.079956f, 0.087402f, 0.096375f,
+ 0.105835f, 0.115479f, 0.126343f, 0.138184f, 0.150635f, 0.164062f, 0.178711f, 0.194214f, 0.210815f, 0.229004f, 0.247314f, 0.267090f,
+ 0.288330f, 0.309570f, 0.332275f, 0.355469f, 0.378418f, 0.402832f, 0.427490f, 0.452637f, 0.477783f, 0.501953f, 0.527832f, 0.552734f,
+ 0.577637f, 0.602051f, 0.626465f, 0.649902f, 0.672852f, 0.695312f, 0.717773f, 0.737793f, 0.758789f, 0.778809f, 0.906250f, 0.913086f,
+ 0.913574f, 0.912598f, 0.911621f, 0.910645f, 0.001059f, 0.002985f, 0.004475f, 0.006496f, 0.008545f, 0.010300f, 0.012581f, 0.014969f,
+ 0.017471f, 0.019852f, 0.022507f, 0.025864f, 0.028824f, 0.032135f, 0.036041f, 0.039795f, 0.043884f, 0.048706f, 0.053680f, 0.059113f,
+ 0.064819f, 0.071472f, 0.078491f, 0.086365f, 0.094360f, 0.103577f, 0.113403f, 0.124023f, 0.135620f, 0.147705f, 0.160889f, 0.175537f,
+ 0.191284f, 0.207764f, 0.225464f, 0.244263f, 0.264160f, 0.284912f, 0.306641f, 0.329102f, 0.352295f, 0.376465f, 0.400635f, 0.426025f,
+ 0.451416f, 0.476562f, 0.502930f, 0.527344f, 0.553711f, 0.579102f, 0.603027f, 0.627930f, 0.652344f, 0.675781f, 0.700195f, 0.722168f,
+ 0.742676f, 0.764648f, 0.901367f, 0.907715f, 0.908691f, 0.908203f, 0.907227f, 0.906250f, 0.000988f, 0.002577f, 0.004124f, 0.006042f,
+ 0.007603f, 0.009506f, 0.011299f, 0.013680f, 0.015778f, 0.017883f, 0.020554f, 0.023102f, 0.025940f, 0.028946f, 0.031891f, 0.035431f,
+ 0.039825f, 0.043671f, 0.048157f, 0.053009f, 0.058075f, 0.063782f, 0.069885f, 0.077087f, 0.084839f, 0.092712f, 0.101379f, 0.110779f,
+ 0.121155f, 0.132446f, 0.144775f, 0.157837f, 0.172363f, 0.187744f, 0.204590f, 0.222290f, 0.240601f, 0.260254f, 0.281494f, 0.303223f,
+ 0.325439f, 0.349609f, 0.373535f, 0.399170f, 0.424561f, 0.450439f, 0.475586f, 0.501953f, 0.528320f, 0.554688f, 0.580566f, 0.605957f,
+ 0.630859f, 0.656250f, 0.680176f, 0.704102f, 0.727051f, 0.749512f, 0.895508f, 0.902344f, 0.903320f, 0.902832f, 0.901855f, 0.901855f,
+ 0.000842f, 0.002253f, 0.003597f, 0.005352f, 0.007195f, 0.008804f, 0.010460f, 0.012100f, 0.014130f, 0.016281f, 0.018341f, 0.021057f,
+ 0.023193f, 0.025742f, 0.029022f, 0.031830f, 0.035278f, 0.039246f, 0.042999f, 0.047211f, 0.052032f, 0.056946f, 0.062744f, 0.068848f,
+ 0.075195f, 0.082642f, 0.090332f, 0.099060f, 0.108215f, 0.118469f, 0.129517f, 0.141724f, 0.154907f, 0.169434f, 0.184448f, 0.201172f,
+ 0.218506f, 0.237427f, 0.257324f, 0.278320f, 0.300293f, 0.323242f, 0.347412f, 0.372070f, 0.397217f, 0.423340f, 0.449707f, 0.476807f,
+ 0.502930f, 0.529785f, 0.556641f, 0.582520f, 0.609863f, 0.635254f, 0.660645f, 0.686035f, 0.710938f, 0.733887f, 0.889648f, 0.897461f,
+ 0.898926f, 0.896973f, 0.896973f, 0.896484f, 0.000660f, 0.002014f, 0.003531f, 0.004951f, 0.006424f, 0.007935f, 0.009392f, 0.011322f,
+ 0.012924f, 0.014824f, 0.016754f, 0.018906f, 0.020935f, 0.023376f, 0.026245f, 0.028809f, 0.031860f, 0.034821f, 0.038330f, 0.042236f,
+ 0.046387f, 0.050812f, 0.056061f, 0.061279f, 0.066956f, 0.073547f, 0.080566f, 0.088074f, 0.096802f, 0.106079f, 0.116089f, 0.127075f,
+ 0.138672f, 0.151855f, 0.165649f, 0.180908f, 0.197754f, 0.215332f, 0.234375f, 0.254150f, 0.275391f, 0.298096f, 0.321533f, 0.344971f,
+ 0.370361f, 0.396973f, 0.422852f, 0.449219f, 0.477295f, 0.504395f, 0.532227f, 0.558594f, 0.586914f, 0.614258f, 0.640625f, 0.666016f,
+ 0.692871f, 0.718262f, 0.882812f, 0.891602f, 0.892578f, 0.892090f, 0.892090f, 0.890625f, 0.000623f, 0.002073f, 0.003298f, 0.004292f,
+ 0.005589f, 0.007401f, 0.008377f, 0.010315f, 0.011871f, 0.013596f, 0.015213f, 0.016632f, 0.018829f, 0.020920f, 0.023239f, 0.025726f,
+ 0.028381f, 0.031250f, 0.034241f, 0.037781f, 0.041473f, 0.045349f, 0.049469f, 0.054199f, 0.059448f, 0.065186f, 0.071716f, 0.078613f,
+ 0.085999f, 0.093872f, 0.103516f, 0.112976f, 0.123840f, 0.135620f, 0.148804f, 0.162720f, 0.178223f, 0.194824f, 0.212280f, 0.231079f,
+ 0.251953f, 0.273193f, 0.295410f, 0.319580f, 0.343994f, 0.370117f, 0.396729f, 0.422852f, 0.450684f, 0.478516f, 0.507324f, 0.534668f,
+ 0.562988f, 0.591797f, 0.619629f, 0.646484f, 0.674316f, 0.700195f, 0.875488f, 0.885254f, 0.886719f, 0.886719f, 0.885742f, 0.885254f,
+ 0.000583f, 0.001746f, 0.002840f, 0.004143f, 0.005234f, 0.006516f, 0.007835f, 0.009460f, 0.010788f, 0.012062f, 0.013428f, 0.015053f,
+ 0.017349f, 0.018753f, 0.021271f, 0.023163f, 0.025284f, 0.027924f, 0.030655f, 0.033478f, 0.036957f, 0.040527f, 0.044037f, 0.048309f,
+ 0.053223f, 0.058319f, 0.063660f, 0.069763f, 0.076172f, 0.083679f, 0.091431f, 0.100647f, 0.110229f, 0.120667f, 0.132690f, 0.145386f,
+ 0.159668f, 0.174805f, 0.191284f, 0.208984f, 0.228516f, 0.248535f, 0.270996f, 0.293701f, 0.317383f, 0.342529f, 0.369629f, 0.396240f,
+ 0.424072f, 0.452148f, 0.480957f, 0.509277f, 0.539551f, 0.567871f, 0.596680f, 0.625977f, 0.654785f, 0.682129f, 0.868652f, 0.878906f,
+ 0.880371f, 0.879883f, 0.879883f, 0.879395f, 0.000535f, 0.001538f, 0.002930f, 0.003725f, 0.004986f, 0.005920f, 0.006973f, 0.008247f,
+ 0.009575f, 0.010841f, 0.012115f, 0.013550f, 0.015343f, 0.016983f, 0.018814f, 0.020523f, 0.022568f, 0.024887f, 0.027206f, 0.029907f,
+ 0.032959f, 0.035828f, 0.039185f, 0.042877f, 0.046967f, 0.051605f, 0.056213f, 0.061432f, 0.067749f, 0.073730f, 0.081238f, 0.089111f,
+ 0.097656f, 0.107300f, 0.118042f, 0.129883f, 0.142334f, 0.156250f, 0.171875f, 0.187866f, 0.206665f, 0.225708f, 0.246704f, 0.268799f,
+ 0.291992f, 0.316650f, 0.342529f, 0.369629f, 0.397217f, 0.425537f, 0.454590f, 0.484131f, 0.513672f, 0.544434f, 0.574219f, 0.604492f,
+ 0.633789f, 0.664062f, 0.861328f, 0.871582f, 0.873535f, 0.874512f, 0.873047f, 0.872559f, 0.000581f, 0.001668f, 0.002563f, 0.003471f,
+ 0.004494f, 0.005562f, 0.006580f, 0.007782f, 0.008690f, 0.009766f, 0.011261f, 0.012314f, 0.013901f, 0.014969f, 0.016479f, 0.018265f,
+ 0.020294f, 0.022156f, 0.024353f, 0.026505f, 0.029053f, 0.031799f, 0.034607f, 0.037964f, 0.041382f, 0.045471f, 0.049591f, 0.054047f,
+ 0.059326f, 0.065186f, 0.071411f, 0.078735f, 0.086304f, 0.094971f, 0.104126f, 0.114807f, 0.126587f, 0.138916f, 0.153564f, 0.169067f,
+ 0.185669f, 0.203613f, 0.223389f, 0.244629f, 0.266602f, 0.291260f, 0.316406f, 0.342773f, 0.370361f, 0.398926f, 0.427734f, 0.458008f,
+ 0.488770f, 0.520020f, 0.550293f, 0.582031f, 0.613281f, 0.645020f, 0.854004f, 0.865234f, 0.866699f, 0.867188f, 0.866699f, 0.866699f,
+ 0.000571f, 0.001365f, 0.002483f, 0.003033f, 0.004120f, 0.005054f, 0.005981f, 0.006737f, 0.007603f, 0.008675f, 0.009789f, 0.011078f,
+ 0.012413f, 0.013626f, 0.014908f, 0.016174f, 0.017792f, 0.019699f, 0.021591f, 0.023499f, 0.025635f, 0.028000f, 0.030533f, 0.033417f,
+ 0.036499f, 0.039948f, 0.043762f, 0.047943f, 0.052460f, 0.057465f, 0.062622f, 0.068848f, 0.076111f, 0.083557f, 0.092102f, 0.101562f,
+ 0.111816f, 0.123230f, 0.135864f, 0.150024f, 0.165771f, 0.182373f, 0.200806f, 0.221191f, 0.242920f, 0.265869f, 0.290283f, 0.316406f,
+ 0.343262f, 0.371582f, 0.400879f, 0.431396f, 0.463623f, 0.494629f, 0.526367f, 0.558105f, 0.591309f, 0.624023f, 0.845215f, 0.856934f,
+ 0.859375f, 0.859375f, 0.859863f, 0.860352f, 0.000411f, 0.001296f, 0.002012f, 0.002808f, 0.003754f, 0.004543f, 0.005215f, 0.006012f,
+ 0.006725f, 0.007851f, 0.008888f, 0.009979f, 0.010994f, 0.012009f, 0.013062f, 0.014549f, 0.016113f, 0.017441f, 0.019073f, 0.020767f,
+ 0.022598f, 0.024689f, 0.026764f, 0.029358f, 0.032043f, 0.034760f, 0.038391f, 0.041779f, 0.045380f, 0.050110f, 0.055054f, 0.060394f,
+ 0.066650f, 0.073120f, 0.080688f, 0.089233f, 0.098450f, 0.108582f, 0.120178f, 0.133057f, 0.146973f, 0.162354f, 0.179565f, 0.198364f,
+ 0.218750f, 0.240967f, 0.264648f, 0.290039f, 0.316650f, 0.344971f, 0.374023f, 0.404541f, 0.435791f, 0.467773f, 0.500977f, 0.535156f,
+ 0.569336f, 0.601562f, 0.836914f, 0.850098f, 0.852051f, 0.852539f, 0.852539f, 0.852051f, 0.000408f, 0.001071f, 0.001857f, 0.002573f,
+ 0.003338f, 0.004078f, 0.004692f, 0.005379f, 0.006046f, 0.007275f, 0.007957f, 0.008606f, 0.009598f, 0.010864f, 0.011658f, 0.013084f,
+ 0.013977f, 0.015366f, 0.016724f, 0.018402f, 0.019669f, 0.021759f, 0.023697f, 0.025726f, 0.027954f, 0.030640f, 0.033356f, 0.036530f,
+ 0.039948f, 0.043701f, 0.047791f, 0.052704f, 0.057770f, 0.063782f, 0.070129f, 0.077881f, 0.085999f, 0.095337f, 0.105591f, 0.116882f,
+ 0.130005f, 0.143921f, 0.159302f, 0.177246f, 0.196411f, 0.217163f, 0.239746f, 0.263916f, 0.290039f, 0.317871f, 0.346924f, 0.377441f,
+ 0.408936f, 0.442139f, 0.476074f, 0.509766f, 0.545410f, 0.580078f, 0.828613f, 0.841309f, 0.843262f, 0.844238f, 0.843750f, 0.844238f,
+ 0.000322f, 0.001009f, 0.001674f, 0.002262f, 0.002949f, 0.003633f, 0.004250f, 0.004780f, 0.005478f, 0.006256f, 0.007248f, 0.007919f,
+ 0.008720f, 0.009552f, 0.010277f, 0.011391f, 0.012291f, 0.013466f, 0.014786f, 0.015976f, 0.017288f, 0.019043f, 0.020477f, 0.022385f,
+ 0.024292f, 0.026276f, 0.029175f, 0.031769f, 0.034546f, 0.037842f, 0.041626f, 0.045868f, 0.050293f, 0.055084f, 0.060669f, 0.067688f,
+ 0.074585f, 0.083008f, 0.092102f, 0.102234f, 0.113525f, 0.126587f, 0.140869f, 0.156860f, 0.174805f, 0.194214f, 0.215698f, 0.239014f,
+ 0.264404f, 0.291016f, 0.320068f, 0.350098f, 0.382080f, 0.414551f, 0.449463f, 0.485107f, 0.520996f, 0.557617f, 0.818848f, 0.833496f,
+ 0.836426f, 0.836914f, 0.836426f, 0.835938f, 0.000483f, 0.000841f, 0.001632f, 0.002142f, 0.002678f, 0.003359f, 0.003830f, 0.004333f,
+ 0.005077f, 0.005527f, 0.006104f, 0.006908f, 0.007675f, 0.008392f, 0.009216f, 0.009789f, 0.010880f, 0.011719f, 0.012817f, 0.013809f,
+ 0.015068f, 0.016357f, 0.017883f, 0.019485f, 0.021271f, 0.022995f, 0.025162f, 0.027359f, 0.029755f, 0.032806f, 0.036133f, 0.039459f,
+ 0.043091f, 0.047821f, 0.052368f, 0.058258f, 0.064514f, 0.071472f, 0.079224f, 0.088623f, 0.098694f, 0.109924f, 0.123230f, 0.137817f,
+ 0.154053f, 0.172363f, 0.192261f, 0.214478f, 0.238647f, 0.265137f, 0.292725f, 0.322998f, 0.354492f, 0.387695f, 0.422363f, 0.458740f,
+ 0.495605f, 0.533691f, 0.809570f, 0.824219f, 0.826660f, 0.827148f, 0.828125f, 0.827148f, 0.000240f, 0.000906f, 0.001379f, 0.001807f,
+ 0.002495f, 0.002916f, 0.003490f, 0.004139f, 0.004471f, 0.004898f, 0.005638f, 0.005978f, 0.006874f, 0.007313f, 0.007957f, 0.008698f,
+ 0.009560f, 0.010178f, 0.011345f, 0.012177f, 0.012985f, 0.014214f, 0.015274f, 0.016708f, 0.017929f, 0.019882f, 0.021393f, 0.023560f,
+ 0.025406f, 0.028137f, 0.030472f, 0.033752f, 0.036896f, 0.040619f, 0.044952f, 0.049622f, 0.055298f, 0.061249f, 0.068420f, 0.075928f,
+ 0.084900f, 0.095398f, 0.107300f, 0.119934f, 0.134766f, 0.151733f, 0.170410f, 0.191284f, 0.213867f, 0.238647f, 0.265869f, 0.295654f,
+ 0.326660f, 0.359863f, 0.394775f, 0.432129f, 0.469482f, 0.508789f, 0.798340f, 0.814941f, 0.817871f, 0.818359f, 0.818848f, 0.818848f,
+ 0.000376f, 0.000870f, 0.001291f, 0.001619f, 0.002251f, 0.002520f, 0.003016f, 0.003502f, 0.004036f, 0.004299f, 0.004723f, 0.005234f,
+ 0.005840f, 0.006512f, 0.006908f, 0.007595f, 0.008003f, 0.008797f, 0.009773f, 0.010536f, 0.011284f, 0.012161f, 0.013237f, 0.014465f,
+ 0.015579f, 0.016968f, 0.018402f, 0.019882f, 0.021759f, 0.023621f, 0.026138f, 0.028488f, 0.031738f, 0.034668f, 0.038239f, 0.042389f,
+ 0.046783f, 0.052094f, 0.058319f, 0.064941f, 0.072815f, 0.081726f, 0.092102f, 0.103516f, 0.117188f, 0.132202f, 0.149048f, 0.168091f,
+ 0.189941f, 0.213745f, 0.239990f, 0.268311f, 0.299316f, 0.332275f, 0.367188f, 0.403076f, 0.442871f, 0.483398f, 0.788086f, 0.805176f,
+ 0.808105f, 0.808594f, 0.809082f, 0.809082f, 0.000386f, 0.000765f, 0.000998f, 0.001537f, 0.001833f, 0.002407f, 0.002529f, 0.003113f,
+ 0.003334f, 0.003841f, 0.004192f, 0.004585f, 0.005096f, 0.005543f, 0.006073f, 0.006405f, 0.007118f, 0.007641f, 0.008278f, 0.008957f,
+ 0.009651f, 0.010498f, 0.011307f, 0.012184f, 0.013199f, 0.014343f, 0.015671f, 0.016678f, 0.018585f, 0.019852f, 0.021881f, 0.023987f,
+ 0.026398f, 0.029099f, 0.032227f, 0.035339f, 0.039246f, 0.043915f, 0.048859f, 0.054688f, 0.061554f, 0.069519f, 0.078247f, 0.088379f,
+ 0.100037f, 0.113770f, 0.129272f, 0.146606f, 0.166626f, 0.189575f, 0.214111f, 0.241577f, 0.271973f, 0.304199f, 0.339844f, 0.375977f,
+ 0.415527f, 0.457275f, 0.776855f, 0.794434f, 0.797363f, 0.797852f, 0.798828f, 0.799316f, 0.000232f, 0.000636f, 0.000996f, 0.001201f,
+ 0.001721f, 0.002029f, 0.002340f, 0.002802f, 0.003012f, 0.003462f, 0.003693f, 0.004059f, 0.004295f, 0.004822f, 0.005077f, 0.005623f,
+ 0.006126f, 0.006653f, 0.007027f, 0.007561f, 0.008049f, 0.008904f, 0.009399f, 0.010300f, 0.011200f, 0.012115f, 0.013092f, 0.014221f,
+ 0.015671f, 0.016891f, 0.018433f, 0.020294f, 0.022064f, 0.024277f, 0.026688f, 0.029678f, 0.032654f, 0.036499f, 0.040955f, 0.045715f,
+ 0.051514f, 0.058014f, 0.065674f, 0.074707f, 0.084717f, 0.096802f, 0.111023f, 0.126709f, 0.144775f, 0.165771f, 0.189209f, 0.215820f,
+ 0.244385f, 0.275879f, 0.310547f, 0.348145f, 0.387695f, 0.429932f, 0.765137f, 0.783203f, 0.787109f, 0.788574f, 0.788574f, 0.789551f,
+ 0.000171f, 0.000518f, 0.001106f, 0.001242f, 0.001475f, 0.001939f, 0.002092f, 0.002254f, 0.002607f, 0.002930f, 0.003084f, 0.003382f,
+ 0.003674f, 0.004040f, 0.004395f, 0.004780f, 0.005157f, 0.005653f, 0.006088f, 0.006355f, 0.006870f, 0.007420f, 0.008057f, 0.008667f,
+ 0.009361f, 0.010040f, 0.011101f, 0.011803f, 0.012711f, 0.013962f, 0.015343f, 0.016586f, 0.018036f, 0.020142f, 0.022079f, 0.024399f,
+ 0.027023f, 0.030075f, 0.033569f, 0.037750f, 0.042603f, 0.048096f, 0.054718f, 0.062134f, 0.071045f, 0.081299f, 0.093445f, 0.107605f,
+ 0.124268f, 0.142944f, 0.165405f, 0.189941f, 0.218262f, 0.249268f, 0.282227f, 0.319336f, 0.359375f, 0.402832f, 0.752930f, 0.771973f,
+ 0.775879f, 0.776855f, 0.777832f, 0.777832f, 0.000204f, 0.000608f, 0.000865f, 0.001011f, 0.001362f, 0.001632f, 0.001817f, 0.001930f,
+ 0.002274f, 0.002491f, 0.002796f, 0.002932f, 0.003139f, 0.003429f, 0.003736f, 0.004055f, 0.004448f, 0.004829f, 0.004971f, 0.005497f,
+ 0.005859f, 0.006298f, 0.006741f, 0.007080f, 0.007687f, 0.008308f, 0.009087f, 0.009880f, 0.010735f, 0.011528f, 0.012375f, 0.013664f,
+ 0.014862f, 0.016464f, 0.017868f, 0.019852f, 0.022156f, 0.024490f, 0.027435f, 0.030853f, 0.034637f, 0.039154f, 0.044495f, 0.050964f,
+ 0.058441f, 0.067383f, 0.077759f, 0.090332f, 0.104797f, 0.121826f, 0.142334f, 0.164795f, 0.191528f, 0.221313f, 0.254150f, 0.290771f,
+ 0.330078f, 0.374268f, 0.740234f, 0.759277f, 0.763672f, 0.766113f, 0.766602f, 0.766113f, 0.000150f, 0.000514f, 0.000666f, 0.000865f,
+ 0.001163f, 0.001389f, 0.001540f, 0.001672f, 0.001940f, 0.002110f, 0.002302f, 0.002419f, 0.002745f, 0.002974f, 0.003120f, 0.003366f,
+ 0.003695f, 0.003815f, 0.004173f, 0.004574f, 0.004879f, 0.005165f, 0.005646f, 0.006058f, 0.006481f, 0.006969f, 0.007626f, 0.007881f,
+ 0.008751f, 0.009445f, 0.010231f, 0.011246f, 0.012222f, 0.013268f, 0.014641f, 0.015976f, 0.017792f, 0.019867f, 0.021912f, 0.024704f,
+ 0.027786f, 0.031494f, 0.036011f, 0.041229f, 0.047363f, 0.054962f, 0.063904f, 0.074463f, 0.087036f, 0.102295f, 0.120483f, 0.141113f,
+ 0.166260f, 0.194214f, 0.226196f, 0.261719f, 0.301514f, 0.345459f, 0.727051f, 0.747070f, 0.751953f, 0.753418f, 0.754395f, 0.754883f,
+ 0.000103f, 0.000251f, 0.000628f, 0.000912f, 0.000978f, 0.001191f, 0.001365f, 0.001507f, 0.001513f, 0.001757f, 0.001980f, 0.002121f,
+ 0.002316f, 0.002373f, 0.002645f, 0.002909f, 0.003012f, 0.003305f, 0.003538f, 0.003775f, 0.004070f, 0.004246f, 0.004642f, 0.004986f,
+ 0.005394f, 0.005802f, 0.006031f, 0.006565f, 0.006969f, 0.007618f, 0.008293f, 0.008980f, 0.009766f, 0.010612f, 0.011528f, 0.012802f,
+ 0.014198f, 0.015671f, 0.017517f, 0.019592f, 0.021957f, 0.024918f, 0.028442f, 0.032562f, 0.037567f, 0.043762f, 0.051025f, 0.059753f,
+ 0.071045f, 0.084412f, 0.099792f, 0.119385f, 0.141846f, 0.167969f, 0.199341f, 0.233521f, 0.272461f, 0.315674f, 0.712891f, 0.733887f,
+ 0.738770f, 0.740234f, 0.741211f, 0.741699f, 0.000185f, 0.000434f, 0.000489f, 0.000732f, 0.000874f, 0.000968f, 0.001122f, 0.001124f,
+ 0.001371f, 0.001423f, 0.001639f, 0.001693f, 0.001805f, 0.002094f, 0.002241f, 0.002356f, 0.002567f, 0.002691f, 0.002871f, 0.003063f,
+ 0.003195f, 0.003582f, 0.003790f, 0.004089f, 0.004372f, 0.004536f, 0.005085f, 0.005314f, 0.005699f, 0.006153f, 0.006672f, 0.007202f,
+ 0.007805f, 0.008522f, 0.009216f, 0.010071f, 0.011086f, 0.012184f, 0.013596f, 0.015297f, 0.017014f, 0.019363f, 0.021988f, 0.025299f,
+ 0.029282f, 0.033936f, 0.040070f, 0.047028f, 0.056519f, 0.067932f, 0.080872f, 0.098083f, 0.118469f, 0.143188f, 0.171753f, 0.205200f,
+ 0.243286f, 0.286133f, 0.698730f, 0.721680f, 0.725098f, 0.727051f, 0.728027f, 0.728516f, 0.000116f, 0.000267f, 0.000565f, 0.000505f,
+ 0.000648f, 0.000772f, 0.000813f, 0.001031f, 0.001107f, 0.001184f, 0.001335f, 0.001391f, 0.001451f, 0.001633f, 0.001798f, 0.001874f,
+ 0.002090f, 0.002192f, 0.002392f, 0.002464f, 0.002707f, 0.002895f, 0.003044f, 0.003206f, 0.003468f, 0.003666f, 0.003887f, 0.004261f,
+ 0.004524f, 0.004898f, 0.005379f, 0.005711f, 0.006130f, 0.006721f, 0.007267f, 0.007912f, 0.008659f, 0.009575f, 0.010475f, 0.011749f,
+ 0.013252f, 0.014717f, 0.016815f, 0.019302f, 0.022369f, 0.025955f, 0.030502f, 0.036285f, 0.043579f, 0.052795f, 0.064453f, 0.078735f,
+ 0.096497f, 0.118591f, 0.145508f, 0.177368f, 0.213989f, 0.256592f, 0.683105f, 0.707031f, 0.710938f, 0.713379f, 0.714844f, 0.714844f,
+ 0.000223f, 0.000239f, 0.000286f, 0.000476f, 0.000580f, 0.000647f, 0.000715f, 0.000843f, 0.000914f, 0.000950f, 0.001090f, 0.001163f,
+ 0.001259f, 0.001328f, 0.001392f, 0.001560f, 0.001549f, 0.001775f, 0.001868f, 0.001999f, 0.002199f, 0.002235f, 0.002436f, 0.002575f,
+ 0.002842f, 0.002892f, 0.003111f, 0.003401f, 0.003563f, 0.003887f, 0.004196f, 0.004505f, 0.004791f, 0.005142f, 0.005684f, 0.006153f,
+ 0.006710f, 0.007378f, 0.008064f, 0.008881f, 0.009979f, 0.011177f, 0.012779f, 0.014435f, 0.016647f, 0.019150f, 0.022583f, 0.027252f,
+ 0.033051f, 0.040039f, 0.049561f, 0.061340f, 0.076843f, 0.096313f, 0.120544f, 0.150513f, 0.185547f, 0.227173f, 0.668457f, 0.692383f,
+ 0.696289f, 0.698242f, 0.699219f, 0.701172f, 0.000000f, 0.000109f, 0.000315f, 0.000449f, 0.000511f, 0.000507f, 0.000538f, 0.000653f,
+ 0.000724f, 0.000749f, 0.000830f, 0.000893f, 0.001007f, 0.001079f, 0.001189f, 0.001163f, 0.001335f, 0.001307f, 0.001502f, 0.001575f,
+ 0.001627f, 0.001778f, 0.001933f, 0.002029f, 0.002155f, 0.002254f, 0.002401f, 0.002535f, 0.002829f, 0.002943f, 0.003143f, 0.003422f,
+ 0.003710f, 0.003990f, 0.004318f, 0.004627f, 0.005108f, 0.005585f, 0.006142f, 0.006641f, 0.007378f, 0.008354f, 0.009430f, 0.010628f,
+ 0.012123f, 0.014015f, 0.016541f, 0.019836f, 0.023849f, 0.029312f, 0.036774f, 0.046356f, 0.058868f, 0.075562f, 0.097107f, 0.124634f,
+ 0.157837f, 0.197754f, 0.653320f, 0.677734f, 0.682129f, 0.684082f, 0.685547f, 0.684570f, 0.000166f, 0.000195f, 0.000256f, 0.000372f,
+ 0.000386f, 0.000415f, 0.000515f, 0.000432f, 0.000579f, 0.000606f, 0.000706f, 0.000745f, 0.000764f, 0.000837f, 0.000853f, 0.000993f,
+ 0.001034f, 0.001066f, 0.001156f, 0.001203f, 0.001339f, 0.001418f, 0.001470f, 0.001612f, 0.001614f, 0.001707f, 0.001850f, 0.001986f,
+ 0.002151f, 0.002254f, 0.002499f, 0.002560f, 0.002794f, 0.003000f, 0.003212f, 0.003510f, 0.003761f, 0.004086f, 0.004475f, 0.004967f,
+ 0.005428f, 0.006134f, 0.006840f, 0.007786f, 0.008858f, 0.010033f, 0.011909f, 0.014137f, 0.016907f, 0.020767f, 0.025894f, 0.033386f,
+ 0.043274f, 0.056854f, 0.075439f, 0.099548f, 0.130737f, 0.169434f, 0.634277f, 0.661133f, 0.667480f, 0.668945f, 0.669922f, 0.670898f,
+ 0.000115f, 0.000119f, 0.000230f, 0.000304f, 0.000221f, 0.000380f, 0.000322f, 0.000351f, 0.000453f, 0.000527f, 0.000535f, 0.000558f,
+ 0.000595f, 0.000675f, 0.000707f, 0.000670f, 0.000776f, 0.000812f, 0.000839f, 0.000911f, 0.000974f, 0.001033f, 0.001082f, 0.001154f,
+ 0.001209f, 0.001268f, 0.001416f, 0.001432f, 0.001607f, 0.001775f, 0.001877f, 0.001911f, 0.002041f, 0.002207f, 0.002380f, 0.002563f,
+ 0.002741f, 0.002956f, 0.003281f, 0.003513f, 0.003902f, 0.004353f, 0.004803f, 0.005405f, 0.006256f, 0.007072f, 0.008263f, 0.009659f,
+ 0.011627f, 0.014221f, 0.017792f, 0.022919f, 0.030075f, 0.040497f, 0.055878f, 0.076721f, 0.104980f, 0.141357f, 0.618652f, 0.644531f,
+ 0.650391f, 0.652832f, 0.653320f, 0.654785f, 0.000000f, 0.000122f, 0.000142f, 0.000227f, 0.000248f, 0.000246f, 0.000296f, 0.000254f,
+ 0.000308f, 0.000329f, 0.000387f, 0.000437f, 0.000443f, 0.000504f, 0.000515f, 0.000535f, 0.000566f, 0.000592f, 0.000618f, 0.000641f,
+ 0.000706f, 0.000746f, 0.000787f, 0.000839f, 0.000878f, 0.000920f, 0.001043f, 0.001041f, 0.001136f, 0.001199f, 0.001258f, 0.001393f,
+ 0.001428f, 0.001549f, 0.001632f, 0.001856f, 0.001945f, 0.002079f, 0.002310f, 0.002489f, 0.002708f, 0.002996f, 0.003315f, 0.003759f,
+ 0.004177f, 0.004803f, 0.005619f, 0.006527f, 0.007793f, 0.009468f, 0.011917f, 0.015152f, 0.019897f, 0.027298f, 0.038910f, 0.055908f,
+ 0.080811f, 0.114563f, 0.600586f, 0.628906f, 0.634277f, 0.636719f, 0.637207f, 0.638672f, 0.000000f, 0.000000f, 0.000106f, 0.000137f,
+ 0.000172f, 0.000211f, 0.000189f, 0.000226f, 0.000230f, 0.000248f, 0.000293f, 0.000251f, 0.000264f, 0.000321f, 0.000343f, 0.000399f,
+ 0.000368f, 0.000401f, 0.000499f, 0.000479f, 0.000498f, 0.000526f, 0.000550f, 0.000595f, 0.000631f, 0.000645f, 0.000726f, 0.000717f,
+ 0.000786f, 0.000902f, 0.000865f, 0.000916f, 0.000989f, 0.001059f, 0.001165f, 0.001246f, 0.001279f, 0.001408f, 0.001566f, 0.001628f,
+ 0.001808f, 0.001991f, 0.002165f, 0.002466f, 0.002766f, 0.003084f, 0.003534f, 0.004250f, 0.005016f, 0.006130f, 0.007584f, 0.009605f,
+ 0.012718f, 0.017395f, 0.025131f, 0.038269f, 0.058899f, 0.089661f, 0.582031f, 0.611328f, 0.616699f, 0.620117f, 0.621094f, 0.622559f,
+ 0.000000f, 0.000108f, 0.000104f, 0.000095f, 0.000117f, 0.000117f, 0.000122f, 0.000143f, 0.000147f, 0.000164f, 0.000174f, 0.000216f,
+ 0.000191f, 0.000227f, 0.000241f, 0.000250f, 0.000257f, 0.000271f, 0.000301f, 0.000298f, 0.000317f, 0.000344f, 0.000370f, 0.000392f,
+ 0.000404f, 0.000427f, 0.000491f, 0.000491f, 0.000519f, 0.000535f, 0.000611f, 0.000601f, 0.000668f, 0.000698f, 0.000767f, 0.000838f,
+ 0.000865f, 0.000895f, 0.000993f, 0.001066f, 0.001161f, 0.001242f, 0.001415f, 0.001521f, 0.001743f, 0.001901f, 0.002209f, 0.002523f,
+ 0.003038f, 0.003601f, 0.004478f, 0.005699f, 0.007545f, 0.010437f, 0.015175f, 0.023682f, 0.039429f, 0.066406f, 0.563477f, 0.593262f,
+ 0.598633f, 0.602051f, 0.602539f, 0.603516f, 0.000000f, 0.000101f, 0.000093f, 0.000087f, 0.000082f, 0.000078f, 0.000084f, 0.000087f,
+ 0.000093f, 0.000094f, 0.000099f, 0.000104f, 0.000114f, 0.000123f, 0.000158f, 0.000163f, 0.000166f, 0.000178f, 0.000177f, 0.000214f,
+ 0.000191f, 0.000208f, 0.000212f, 0.000247f, 0.000268f, 0.000263f, 0.000272f, 0.000287f, 0.000310f, 0.000336f, 0.000353f, 0.000368f,
+ 0.000396f, 0.000408f, 0.000453f, 0.000476f, 0.000511f, 0.000540f, 0.000615f, 0.000635f, 0.000682f, 0.000751f, 0.000812f, 0.000908f,
+ 0.000987f, 0.001116f, 0.001278f, 0.001431f, 0.001702f, 0.002047f, 0.002512f, 0.003126f, 0.004181f, 0.005817f, 0.008553f, 0.013489f,
+ 0.023697f, 0.045288f, 0.544922f, 0.575684f, 0.581543f, 0.584473f, 0.585938f, 0.587402f, 0.000109f, 0.000091f, 0.000081f, 0.000075f,
+ 0.000070f, 0.000067f, 0.000064f, 0.000061f, 0.000057f, 0.000054f, 0.000058f, 0.000075f, 0.000062f, 0.000064f, 0.000085f, 0.000068f,
+ 0.000092f, 0.000094f, 0.000103f, 0.000110f, 0.000113f, 0.000119f, 0.000141f, 0.000141f, 0.000148f, 0.000152f, 0.000159f, 0.000164f,
+ 0.000175f, 0.000188f, 0.000184f, 0.000218f, 0.000233f, 0.000223f, 0.000253f, 0.000265f, 0.000282f, 0.000321f, 0.000322f, 0.000351f,
+ 0.000371f, 0.000405f, 0.000443f, 0.000478f, 0.000515f, 0.000571f, 0.000652f, 0.000733f, 0.000856f, 0.001011f, 0.001227f, 0.001531f,
+ 0.002029f, 0.002817f, 0.004215f, 0.006874f, 0.012390f, 0.027405f, 0.525879f, 0.557129f, 0.563477f, 0.566895f, 0.568848f, 0.569824f,
+ 0.000094f, 0.000073f, 0.000065f, 0.000060f, 0.000055f, 0.000052f, 0.000049f, 0.000048f, 0.000046f, 0.000045f, 0.000042f, 0.000040f,
+ 0.000040f, 0.000037f, 0.000035f, 0.000035f, 0.000042f, 0.000036f, 0.000049f, 0.000051f, 0.000055f, 0.000056f, 0.000059f, 0.000062f,
+ 0.000064f, 0.000078f, 0.000071f, 0.000079f, 0.000088f, 0.000091f, 0.000093f, 0.000099f, 0.000103f, 0.000110f, 0.000125f, 0.000123f,
+ 0.000127f, 0.000151f, 0.000151f, 0.000161f, 0.000169f, 0.000179f, 0.000204f, 0.000219f, 0.000240f, 0.000267f, 0.000294f, 0.000321f,
+ 0.000378f, 0.000438f, 0.000524f, 0.000628f, 0.000818f, 0.001125f, 0.001693f, 0.002888f, 0.005638f, 0.013580f, 0.505859f, 0.539062f,
+ 0.544922f, 0.548340f, 0.550293f, 0.550781f, 0.000064f, 0.000048f, 0.000041f, 0.000037f, 0.000035f, 0.000034f, 0.000032f, 0.000031f,
+ 0.000030f, 0.000029f, 0.000028f, 0.000028f, 0.000027f, 0.000027f, 0.000026f, 0.000025f, 0.000024f, 0.000023f, 0.000022f, 0.000021f,
+ 0.000020f, 0.000019f, 0.000019f, 0.000023f, 0.000021f, 0.000022f, 0.000026f, 0.000029f, 0.000032f, 0.000031f, 0.000036f, 0.000037f,
+ 0.000036f, 0.000044f, 0.000046f, 0.000048f, 0.000052f, 0.000054f, 0.000056f, 0.000061f, 0.000070f, 0.000073f, 0.000076f, 0.000081f,
+ 0.000082f, 0.000095f, 0.000105f, 0.000120f, 0.000126f, 0.000143f, 0.000173f, 0.000203f, 0.000267f, 0.000346f, 0.000505f, 0.000853f,
+ 0.001829f, 0.005222f, 0.487061f, 0.519531f, 0.527344f, 0.529785f, 0.531738f, 0.532715f, 0.000000f, 0.000002f, 0.000003f, 0.000004f,
+ 0.000008f, 0.000008f, 0.000008f, 0.000010f, 0.000009f, 0.000010f, 0.000010f, 0.000011f, 0.000011f, 0.000011f, 0.000011f, 0.000011f,
+ 0.000012f, 0.000011f, 0.000012f, 0.000011f, 0.000012f, 0.000012f, 0.000012f, 0.000011f, 0.000011f, 0.000010f, 0.000010f, 0.000010f,
+ 0.000009f, 0.000009f, 0.000009f, 0.000008f, 0.000008f, 0.000007f, 0.000008f, 0.000009f, 0.000010f, 0.000012f, 0.000012f, 0.000015f,
+ 0.000013f, 0.000015f, 0.000018f, 0.000020f, 0.000021f, 0.000022f, 0.000022f, 0.000024f, 0.000026f, 0.000027f, 0.000034f, 0.000043f,
+ 0.000049f, 0.000065f, 0.000089f, 0.000138f, 0.000293f, 0.001143f, 0.466553f, 0.500488f, 0.508301f, 0.510742f, 0.512207f, 0.513672f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000001f, 0.000001f, 0.000001f, 0.000001f,
+ 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000001f, 0.000001f,
+ 0.000001f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000003f, 0.000004f, 0.000006f, 0.000023f, 0.446777f, 0.482178f,
+ 0.489746f, 0.492676f, 0.494629f, 0.496094f,
+ },
+ {
+ 0.032318f, 0.095032f, 0.152344f, 0.205322f, 0.254883f, 0.299316f, 0.342041f, 0.380859f, 0.416504f, 0.449707f, 0.481201f, 0.508789f,
+ 0.537109f, 0.562012f, 0.584961f, 0.608398f, 0.628418f, 0.648926f, 0.666504f, 0.684570f, 0.701172f, 0.716797f, 0.731934f, 0.746094f,
+ 0.759766f, 0.770996f, 0.784668f, 0.795898f, 0.806641f, 0.817871f, 0.827637f, 0.837402f, 0.846680f, 0.855469f, 0.863770f, 0.872559f,
+ 0.879883f, 0.887695f, 0.895508f, 0.901367f, 0.909180f, 0.915527f, 0.921387f, 0.927734f, 0.934082f, 0.939453f, 0.944824f, 0.950684f,
+ 0.955566f, 0.960449f, 0.965332f, 0.969238f, 0.974121f, 0.978516f, 0.982910f, 0.986816f, 0.990723f, 0.994629f, 0.994629f, 0.987793f,
+ 0.981934f, 0.976562f, 0.971680f, 0.966797f, 0.025833f, 0.076965f, 0.125854f, 0.173096f, 0.217896f, 0.259766f, 0.299561f, 0.338135f,
+ 0.372559f, 0.407471f, 0.437500f, 0.468262f, 0.496582f, 0.522949f, 0.547852f, 0.571289f, 0.593750f, 0.614746f, 0.633789f, 0.652832f,
+ 0.671387f, 0.687988f, 0.705078f, 0.719727f, 0.734863f, 0.749023f, 0.761719f, 0.774414f, 0.786621f, 0.797363f, 0.808594f, 0.818848f,
+ 0.829590f, 0.838867f, 0.848633f, 0.858398f, 0.865723f, 0.874512f, 0.881836f, 0.890137f, 0.897949f, 0.904297f, 0.910645f, 0.917480f,
+ 0.923828f, 0.929688f, 0.935547f, 0.941895f, 0.947266f, 0.952637f, 0.957520f, 0.962402f, 0.967285f, 0.971680f, 0.976562f, 0.980957f,
+ 0.984863f, 0.989258f, 0.992676f, 0.985840f, 0.979980f, 0.975098f, 0.970703f, 0.966309f, 0.020828f, 0.063049f, 0.104797f, 0.146606f,
+ 0.187134f, 0.225464f, 0.263916f, 0.299072f, 0.333252f, 0.366943f, 0.398438f, 0.429199f, 0.457031f, 0.484131f, 0.509766f, 0.534668f,
+ 0.559082f, 0.579590f, 0.600586f, 0.622070f, 0.640625f, 0.659180f, 0.676758f, 0.692383f, 0.708984f, 0.722656f, 0.737793f, 0.751465f,
+ 0.764648f, 0.776367f, 0.789062f, 0.801270f, 0.811523f, 0.821289f, 0.832031f, 0.841309f, 0.850586f, 0.860352f, 0.868652f, 0.876953f,
+ 0.884766f, 0.892090f, 0.899902f, 0.906738f, 0.913086f, 0.920410f, 0.927246f, 0.933105f, 0.938477f, 0.944336f, 0.950195f, 0.955078f,
+ 0.959961f, 0.965332f, 0.970215f, 0.975098f, 0.979492f, 0.983887f, 0.989746f, 0.983398f, 0.978516f, 0.973633f, 0.969238f, 0.964844f,
+ 0.017273f, 0.052429f, 0.088745f, 0.124207f, 0.160034f, 0.195068f, 0.230103f, 0.263916f, 0.297119f, 0.329102f, 0.360596f, 0.390625f,
+ 0.418945f, 0.446289f, 0.472656f, 0.498535f, 0.521973f, 0.545898f, 0.567871f, 0.588867f, 0.609375f, 0.629395f, 0.646973f, 0.664551f,
+ 0.681641f, 0.698242f, 0.712402f, 0.727539f, 0.741699f, 0.755371f, 0.768555f, 0.780762f, 0.792480f, 0.803711f, 0.814941f, 0.825195f,
+ 0.834961f, 0.844727f, 0.854004f, 0.863281f, 0.871094f, 0.879883f, 0.887695f, 0.895508f, 0.902832f, 0.909668f, 0.916504f, 0.923828f,
+ 0.929688f, 0.936035f, 0.941895f, 0.947754f, 0.952637f, 0.958496f, 0.963379f, 0.968750f, 0.973633f, 0.978027f, 0.986816f, 0.980957f,
+ 0.976562f, 0.972168f, 0.967285f, 0.963379f, 0.014076f, 0.043915f, 0.074951f, 0.106140f, 0.137573f, 0.169189f, 0.201416f, 0.233154f,
+ 0.264648f, 0.295166f, 0.324707f, 0.354248f, 0.381836f, 0.410156f, 0.436279f, 0.462891f, 0.487793f, 0.510742f, 0.534180f, 0.556152f,
+ 0.576660f, 0.598145f, 0.616211f, 0.636719f, 0.653320f, 0.670410f, 0.687500f, 0.703125f, 0.718262f, 0.733398f, 0.746582f, 0.760742f,
+ 0.772949f, 0.785156f, 0.796875f, 0.808105f, 0.818848f, 0.829590f, 0.838867f, 0.848145f, 0.857910f, 0.867188f, 0.875977f, 0.883301f,
+ 0.891602f, 0.899414f, 0.906738f, 0.913086f, 0.919922f, 0.926270f, 0.932617f, 0.938477f, 0.944824f, 0.951660f, 0.957520f, 0.961914f,
+ 0.967285f, 0.972168f, 0.984863f, 0.979004f, 0.974609f, 0.970215f, 0.966309f, 0.961914f, 0.012077f, 0.037445f, 0.063660f, 0.090881f,
+ 0.118774f, 0.147827f, 0.176636f, 0.206055f, 0.234253f, 0.262939f, 0.291504f, 0.320312f, 0.347168f, 0.374756f, 0.401367f, 0.427734f,
+ 0.451904f, 0.477051f, 0.500488f, 0.523438f, 0.545898f, 0.566406f, 0.587402f, 0.605957f, 0.624512f, 0.643555f, 0.662109f, 0.676758f,
+ 0.693848f, 0.708984f, 0.724609f, 0.738770f, 0.751465f, 0.765137f, 0.777344f, 0.790039f, 0.800781f, 0.812500f, 0.823242f, 0.833984f,
+ 0.842773f, 0.853027f, 0.861816f, 0.871094f, 0.879395f, 0.887695f, 0.895508f, 0.903320f, 0.910156f, 0.917969f, 0.924316f, 0.931152f,
+ 0.937988f, 0.943848f, 0.949219f, 0.955566f, 0.960449f, 0.966309f, 0.981445f, 0.977051f, 0.972168f, 0.968262f, 0.964355f, 0.960938f,
+ 0.010445f, 0.032562f, 0.054657f, 0.078613f, 0.103333f, 0.128540f, 0.153564f, 0.181274f, 0.207520f, 0.234619f, 0.261475f, 0.288818f,
+ 0.315674f, 0.342041f, 0.368408f, 0.394287f, 0.418945f, 0.443604f, 0.467773f, 0.490479f, 0.512695f, 0.534180f, 0.555664f, 0.575684f,
+ 0.596191f, 0.616211f, 0.633301f, 0.651855f, 0.668457f, 0.685547f, 0.701172f, 0.714844f, 0.729492f, 0.743652f, 0.758301f, 0.770996f,
+ 0.783203f, 0.794922f, 0.806641f, 0.817383f, 0.827637f, 0.838867f, 0.847656f, 0.857422f, 0.866699f, 0.875000f, 0.884277f, 0.892578f,
+ 0.900391f, 0.907227f, 0.914551f, 0.922363f, 0.929199f, 0.935059f, 0.941895f, 0.948242f, 0.953125f, 0.959473f, 0.978516f, 0.974609f,
+ 0.970215f, 0.966309f, 0.962402f, 0.958984f, 0.009117f, 0.027466f, 0.047424f, 0.067871f, 0.089783f, 0.112244f, 0.135376f, 0.159668f,
+ 0.184082f, 0.209106f, 0.233887f, 0.259277f, 0.285400f, 0.311523f, 0.336182f, 0.360840f, 0.385986f, 0.410889f, 0.435059f, 0.458252f,
+ 0.480713f, 0.503418f, 0.524902f, 0.546387f, 0.566895f, 0.586426f, 0.605469f, 0.624512f, 0.642578f, 0.659668f, 0.676758f, 0.692383f,
+ 0.708008f, 0.722168f, 0.736816f, 0.749512f, 0.763184f, 0.776855f, 0.789062f, 0.800781f, 0.812012f, 0.823730f, 0.833496f, 0.843750f,
+ 0.854004f, 0.863281f, 0.872559f, 0.880371f, 0.889648f, 0.896973f, 0.905762f, 0.912598f, 0.919922f, 0.927734f, 0.934082f, 0.940918f,
+ 0.946289f, 0.952637f, 0.976074f, 0.972168f, 0.967773f, 0.963867f, 0.960938f, 0.957031f, 0.007561f, 0.024231f, 0.041077f, 0.059631f,
+ 0.078369f, 0.098145f, 0.119507f, 0.140747f, 0.163208f, 0.185913f, 0.209839f, 0.233154f, 0.257324f, 0.281494f, 0.305908f, 0.330566f,
+ 0.354736f, 0.378906f, 0.402588f, 0.425781f, 0.449219f, 0.471924f, 0.494385f, 0.516602f, 0.536621f, 0.557617f, 0.576660f, 0.596680f,
+ 0.616211f, 0.632812f, 0.650879f, 0.668457f, 0.684082f, 0.700684f, 0.715332f, 0.729492f, 0.744141f, 0.757812f, 0.771973f, 0.783691f,
+ 0.796387f, 0.807129f, 0.818359f, 0.829590f, 0.840820f, 0.850098f, 0.859375f, 0.868652f, 0.877930f, 0.886719f, 0.894531f, 0.903320f,
+ 0.910645f, 0.918945f, 0.925781f, 0.932617f, 0.939453f, 0.945801f, 0.972656f, 0.969727f, 0.965820f, 0.961914f, 0.958496f, 0.955078f,
+ 0.006832f, 0.020676f, 0.036224f, 0.051758f, 0.069214f, 0.086609f, 0.105225f, 0.124146f, 0.144653f, 0.165527f, 0.186646f, 0.209106f,
+ 0.232178f, 0.254883f, 0.277588f, 0.301758f, 0.325195f, 0.348633f, 0.371826f, 0.395264f, 0.418213f, 0.440674f, 0.463135f, 0.485596f,
+ 0.506348f, 0.527832f, 0.548340f, 0.567871f, 0.587891f, 0.606934f, 0.625977f, 0.642578f, 0.660645f, 0.677734f, 0.692871f, 0.708008f,
+ 0.723633f, 0.737793f, 0.752441f, 0.765137f, 0.778320f, 0.791504f, 0.802734f, 0.814453f, 0.825684f, 0.835449f, 0.847168f, 0.856934f,
+ 0.866699f, 0.875488f, 0.884766f, 0.893066f, 0.901367f, 0.910156f, 0.917480f, 0.924805f, 0.932129f, 0.938965f, 0.970215f, 0.966797f,
+ 0.963379f, 0.959961f, 0.956543f, 0.953125f, 0.006050f, 0.018585f, 0.031860f, 0.045807f, 0.060883f, 0.076538f, 0.093323f, 0.109985f,
+ 0.128174f, 0.147949f, 0.167480f, 0.186768f, 0.208496f, 0.230591f, 0.252441f, 0.274170f, 0.297363f, 0.319824f, 0.342773f, 0.365723f,
+ 0.388672f, 0.411133f, 0.433350f, 0.455811f, 0.477295f, 0.498291f, 0.519531f, 0.539551f, 0.560059f, 0.580566f, 0.599121f, 0.617676f,
+ 0.635254f, 0.653320f, 0.669434f, 0.686523f, 0.702148f, 0.717773f, 0.732422f, 0.747070f, 0.760742f, 0.773926f, 0.786621f, 0.798340f,
+ 0.811035f, 0.822754f, 0.833008f, 0.843750f, 0.854004f, 0.863770f, 0.873047f, 0.882812f, 0.891602f, 0.900879f, 0.908691f, 0.916504f,
+ 0.924316f, 0.931152f, 0.966309f, 0.964355f, 0.961426f, 0.957520f, 0.954102f, 0.951172f, 0.005352f, 0.016388f, 0.027985f, 0.040222f,
+ 0.053436f, 0.067261f, 0.082520f, 0.098022f, 0.114319f, 0.131836f, 0.150146f, 0.167969f, 0.187744f, 0.208008f, 0.228271f, 0.249634f,
+ 0.270996f, 0.292969f, 0.314697f, 0.337158f, 0.359375f, 0.380859f, 0.403809f, 0.426025f, 0.447510f, 0.469482f, 0.490967f, 0.511719f,
+ 0.532227f, 0.552734f, 0.571777f, 0.591309f, 0.609375f, 0.628418f, 0.645508f, 0.663086f, 0.680664f, 0.696289f, 0.711426f, 0.727051f,
+ 0.741699f, 0.755859f, 0.768555f, 0.782227f, 0.795410f, 0.807617f, 0.818359f, 0.830078f, 0.841309f, 0.851074f, 0.861816f, 0.871582f,
+ 0.880859f, 0.890625f, 0.898438f, 0.907715f, 0.915527f, 0.923828f, 0.962402f, 0.961914f, 0.958496f, 0.955078f, 0.951172f, 0.948730f,
+ 0.004700f, 0.014397f, 0.025208f, 0.035675f, 0.047485f, 0.060120f, 0.073242f, 0.087097f, 0.102173f, 0.117249f, 0.133789f, 0.150513f,
+ 0.168823f, 0.186890f, 0.206665f, 0.225830f, 0.246216f, 0.267334f, 0.288574f, 0.309814f, 0.331299f, 0.353271f, 0.375244f, 0.396729f,
+ 0.418701f, 0.440674f, 0.461182f, 0.483398f, 0.504883f, 0.524902f, 0.544434f, 0.564941f, 0.584473f, 0.603027f, 0.621582f, 0.639648f,
+ 0.656738f, 0.673828f, 0.690430f, 0.705566f, 0.721680f, 0.736816f, 0.750977f, 0.764648f, 0.778809f, 0.791016f, 0.804688f, 0.815918f,
+ 0.826660f, 0.838867f, 0.850098f, 0.860840f, 0.870605f, 0.879883f, 0.889648f, 0.898438f, 0.907227f, 0.915527f, 0.959961f, 0.958496f,
+ 0.955078f, 0.952148f, 0.949219f, 0.946777f, 0.004238f, 0.013138f, 0.022202f, 0.031769f, 0.042358f, 0.053040f, 0.065613f, 0.077637f,
+ 0.090759f, 0.104980f, 0.119995f, 0.135498f, 0.151855f, 0.167725f, 0.186646f, 0.205078f, 0.224121f, 0.243042f, 0.263672f, 0.283936f,
+ 0.305176f, 0.326416f, 0.347168f, 0.369629f, 0.390625f, 0.411865f, 0.433350f, 0.454590f, 0.475830f, 0.497314f, 0.517578f, 0.537109f,
+ 0.557617f, 0.577637f, 0.596191f, 0.615723f, 0.632812f, 0.651367f, 0.668945f, 0.685059f, 0.701172f, 0.716797f, 0.732422f, 0.747559f,
+ 0.761230f, 0.775391f, 0.788574f, 0.800781f, 0.813965f, 0.824707f, 0.837402f, 0.848145f, 0.859375f, 0.869141f, 0.879395f, 0.889160f,
+ 0.897949f, 0.906250f, 0.956055f, 0.955566f, 0.952148f, 0.950195f, 0.947266f, 0.943848f, 0.003944f, 0.011490f, 0.019943f, 0.028748f,
+ 0.037964f, 0.047485f, 0.058014f, 0.069702f, 0.081360f, 0.093994f, 0.107361f, 0.121277f, 0.136353f, 0.151978f, 0.167480f, 0.185669f,
+ 0.202637f, 0.222168f, 0.240601f, 0.259766f, 0.279541f, 0.300293f, 0.321533f, 0.342285f, 0.362549f, 0.384033f, 0.405762f, 0.427002f,
+ 0.447998f, 0.469238f, 0.490479f, 0.510742f, 0.532227f, 0.551758f, 0.570312f, 0.589844f, 0.609375f, 0.628418f, 0.645508f, 0.662598f,
+ 0.680664f, 0.696777f, 0.712402f, 0.728516f, 0.744141f, 0.757812f, 0.771973f, 0.785156f, 0.798828f, 0.811523f, 0.824707f, 0.835449f,
+ 0.847168f, 0.858887f, 0.869141f, 0.878906f, 0.888672f, 0.897949f, 0.952148f, 0.952148f, 0.949219f, 0.946777f, 0.944336f, 0.941406f,
+ 0.003448f, 0.010574f, 0.017807f, 0.025558f, 0.033875f, 0.042633f, 0.052307f, 0.062134f, 0.073059f, 0.084045f, 0.096375f, 0.109192f,
+ 0.122803f, 0.136475f, 0.151367f, 0.167603f, 0.183960f, 0.201416f, 0.218506f, 0.237427f, 0.256104f, 0.275635f, 0.295410f, 0.315918f,
+ 0.336426f, 0.357178f, 0.378906f, 0.399414f, 0.421143f, 0.442139f, 0.462891f, 0.484375f, 0.504883f, 0.524902f, 0.544922f, 0.564941f,
+ 0.583984f, 0.603516f, 0.622070f, 0.640625f, 0.658691f, 0.675781f, 0.692871f, 0.709473f, 0.725098f, 0.740234f, 0.754883f, 0.769531f,
+ 0.783203f, 0.796875f, 0.809570f, 0.823242f, 0.834473f, 0.846191f, 0.857422f, 0.868164f, 0.878906f, 0.889160f, 0.948730f, 0.948242f,
+ 0.946289f, 0.944336f, 0.940918f, 0.938477f, 0.003017f, 0.009422f, 0.015900f, 0.023041f, 0.030380f, 0.038574f, 0.047150f, 0.055969f,
+ 0.065735f, 0.075684f, 0.086426f, 0.098267f, 0.110535f, 0.123047f, 0.136841f, 0.151489f, 0.166138f, 0.182495f, 0.198975f, 0.216553f,
+ 0.233765f, 0.252930f, 0.271484f, 0.291016f, 0.310547f, 0.331299f, 0.351562f, 0.372559f, 0.393555f, 0.415039f, 0.435059f, 0.457275f,
+ 0.477539f, 0.498047f, 0.519043f, 0.538574f, 0.559570f, 0.579102f, 0.598633f, 0.617188f, 0.635742f, 0.654297f, 0.672363f, 0.688965f,
+ 0.706055f, 0.721191f, 0.737793f, 0.752930f, 0.768066f, 0.782227f, 0.795898f, 0.809082f, 0.821289f, 0.833496f, 0.846191f, 0.857422f,
+ 0.869141f, 0.879883f, 0.944824f, 0.945312f, 0.942871f, 0.940918f, 0.938477f, 0.936035f, 0.002802f, 0.008575f, 0.014763f, 0.020844f,
+ 0.027557f, 0.034576f, 0.042084f, 0.050476f, 0.058990f, 0.067993f, 0.077942f, 0.087952f, 0.098999f, 0.111267f, 0.122803f, 0.136719f,
+ 0.150269f, 0.165527f, 0.180542f, 0.196533f, 0.213257f, 0.230591f, 0.248779f, 0.267334f, 0.286865f, 0.306152f, 0.325928f, 0.346436f,
+ 0.367188f, 0.387695f, 0.409424f, 0.429199f, 0.450195f, 0.471680f, 0.492920f, 0.513184f, 0.534180f, 0.553711f, 0.573730f, 0.593750f,
+ 0.612793f, 0.631836f, 0.649414f, 0.668457f, 0.685059f, 0.703125f, 0.719238f, 0.735352f, 0.750000f, 0.766113f, 0.781738f, 0.794434f,
+ 0.808105f, 0.821777f, 0.833984f, 0.846191f, 0.858398f, 0.870117f, 0.940918f, 0.941895f, 0.939941f, 0.937500f, 0.935059f, 0.932617f,
+ 0.002573f, 0.007603f, 0.013100f, 0.018799f, 0.024719f, 0.031372f, 0.038147f, 0.045105f, 0.052795f, 0.061127f, 0.069519f, 0.079529f,
+ 0.089355f, 0.099976f, 0.111084f, 0.123718f, 0.136353f, 0.148926f, 0.163574f, 0.178345f, 0.194214f, 0.210083f, 0.227783f, 0.245361f,
+ 0.263672f, 0.282471f, 0.301758f, 0.321533f, 0.341797f, 0.361816f, 0.383057f, 0.403320f, 0.424316f, 0.445557f, 0.466797f, 0.487061f,
+ 0.507812f, 0.528809f, 0.549805f, 0.569336f, 0.589844f, 0.608887f, 0.627930f, 0.646973f, 0.665527f, 0.682129f, 0.700195f, 0.717773f,
+ 0.732910f, 0.749512f, 0.765137f, 0.779785f, 0.794434f, 0.808105f, 0.821777f, 0.834473f, 0.847168f, 0.859375f, 0.936523f, 0.937988f,
+ 0.936035f, 0.933594f, 0.932129f, 0.929688f, 0.002409f, 0.007107f, 0.011833f, 0.017075f, 0.022278f, 0.028351f, 0.034088f, 0.040558f,
+ 0.047943f, 0.055389f, 0.063232f, 0.072021f, 0.080322f, 0.090454f, 0.100220f, 0.111389f, 0.122986f, 0.135010f, 0.148438f, 0.162109f,
+ 0.176270f, 0.191772f, 0.207642f, 0.224121f, 0.241699f, 0.259277f, 0.278076f, 0.297363f, 0.316650f, 0.336670f, 0.356934f, 0.377686f,
+ 0.397949f, 0.418701f, 0.439941f, 0.461914f, 0.482178f, 0.502930f, 0.524414f, 0.544922f, 0.565918f, 0.585938f, 0.605957f, 0.625000f,
+ 0.643066f, 0.662109f, 0.680176f, 0.698730f, 0.715820f, 0.731934f, 0.748047f, 0.764648f, 0.780273f, 0.794434f, 0.808594f, 0.821777f,
+ 0.836914f, 0.848145f, 0.932129f, 0.934082f, 0.932617f, 0.930176f, 0.928711f, 0.926270f, 0.002066f, 0.006329f, 0.010986f, 0.015541f,
+ 0.020294f, 0.025452f, 0.030975f, 0.037201f, 0.043152f, 0.049835f, 0.056824f, 0.064331f, 0.072998f, 0.081177f, 0.090637f, 0.100525f,
+ 0.110718f, 0.122131f, 0.134033f, 0.146851f, 0.159912f, 0.173584f, 0.189331f, 0.204468f, 0.221191f, 0.237671f, 0.255615f, 0.273682f,
+ 0.292969f, 0.312012f, 0.331543f, 0.352295f, 0.372314f, 0.393311f, 0.413818f, 0.435547f, 0.456055f, 0.477539f, 0.499023f, 0.520508f,
+ 0.540039f, 0.561523f, 0.581543f, 0.602051f, 0.622070f, 0.641113f, 0.659668f, 0.678223f, 0.697266f, 0.714844f, 0.731445f, 0.748535f,
+ 0.765137f, 0.778809f, 0.794922f, 0.810059f, 0.824219f, 0.837402f, 0.926758f, 0.930176f, 0.928711f, 0.926758f, 0.924805f, 0.922852f,
+ 0.001840f, 0.005703f, 0.009918f, 0.014099f, 0.018311f, 0.023026f, 0.028000f, 0.033508f, 0.038971f, 0.045044f, 0.051880f, 0.058289f,
+ 0.065796f, 0.073425f, 0.081482f, 0.090698f, 0.100464f, 0.110413f, 0.121216f, 0.132812f, 0.145142f, 0.158203f, 0.171997f, 0.186401f,
+ 0.201538f, 0.217651f, 0.234497f, 0.251465f, 0.269287f, 0.288330f, 0.307129f, 0.327148f, 0.346924f, 0.367920f, 0.388428f, 0.409668f,
+ 0.430420f, 0.451416f, 0.474121f, 0.494873f, 0.516113f, 0.537598f, 0.558105f, 0.579102f, 0.598633f, 0.619629f, 0.639160f, 0.657715f,
+ 0.677734f, 0.695801f, 0.713867f, 0.731934f, 0.748047f, 0.764160f, 0.781738f, 0.796875f, 0.810547f, 0.826172f, 0.922363f, 0.925781f,
+ 0.924805f, 0.922852f, 0.921387f, 0.919434f, 0.001621f, 0.005188f, 0.008888f, 0.012939f, 0.016724f, 0.021271f, 0.025772f, 0.029984f,
+ 0.035553f, 0.040741f, 0.046417f, 0.052490f, 0.059265f, 0.066528f, 0.074097f, 0.081482f, 0.090271f, 0.100220f, 0.109741f, 0.120178f,
+ 0.131226f, 0.143188f, 0.156006f, 0.169189f, 0.183716f, 0.198486f, 0.214233f, 0.230713f, 0.247925f, 0.265381f, 0.284424f, 0.303711f,
+ 0.322754f, 0.342773f, 0.363525f, 0.384277f, 0.405518f, 0.427002f, 0.447754f, 0.469727f, 0.491455f, 0.512207f, 0.534180f, 0.554688f,
+ 0.576172f, 0.597168f, 0.617188f, 0.636719f, 0.657227f, 0.677734f, 0.695312f, 0.713379f, 0.731934f, 0.749512f, 0.766113f, 0.782715f,
+ 0.798340f, 0.813477f, 0.917480f, 0.920898f, 0.920410f, 0.919922f, 0.916992f, 0.915039f, 0.001581f, 0.004616f, 0.008049f, 0.011917f,
+ 0.015556f, 0.019547f, 0.023270f, 0.027908f, 0.031860f, 0.036652f, 0.041992f, 0.047577f, 0.053528f, 0.060150f, 0.066772f, 0.073914f,
+ 0.082153f, 0.090088f, 0.099304f, 0.108887f, 0.118835f, 0.129517f, 0.141357f, 0.154297f, 0.166992f, 0.180908f, 0.195557f, 0.210815f,
+ 0.227173f, 0.244141f, 0.261963f, 0.279785f, 0.299072f, 0.318359f, 0.338379f, 0.358887f, 0.380127f, 0.401123f, 0.422607f, 0.443848f,
+ 0.466309f, 0.487793f, 0.509277f, 0.530762f, 0.553223f, 0.573730f, 0.594727f, 0.616699f, 0.636719f, 0.656250f, 0.676270f, 0.695801f,
+ 0.713867f, 0.733398f, 0.750488f, 0.767090f, 0.784180f, 0.801270f, 0.912598f, 0.916992f, 0.916504f, 0.914551f, 0.913086f, 0.911133f,
+ 0.001476f, 0.004410f, 0.007374f, 0.010620f, 0.013931f, 0.017258f, 0.021057f, 0.024979f, 0.029144f, 0.033478f, 0.037872f, 0.042969f,
+ 0.048737f, 0.053986f, 0.060150f, 0.066895f, 0.074036f, 0.081665f, 0.089417f, 0.098083f, 0.107361f, 0.117371f, 0.127930f, 0.139648f,
+ 0.151489f, 0.164062f, 0.178589f, 0.192627f, 0.208130f, 0.223755f, 0.240601f, 0.258057f, 0.275879f, 0.295654f, 0.314697f, 0.334961f,
+ 0.354980f, 0.375977f, 0.396729f, 0.418945f, 0.440430f, 0.462402f, 0.484619f, 0.506348f, 0.528809f, 0.550781f, 0.572266f, 0.593750f,
+ 0.615234f, 0.637207f, 0.656738f, 0.676758f, 0.696289f, 0.716309f, 0.734863f, 0.752930f, 0.770508f, 0.788574f, 0.906738f, 0.911621f,
+ 0.912109f, 0.910156f, 0.908691f, 0.907227f, 0.001204f, 0.003998f, 0.006786f, 0.009850f, 0.012642f, 0.015762f, 0.019226f, 0.022751f,
+ 0.026749f, 0.030502f, 0.034698f, 0.038940f, 0.044006f, 0.048615f, 0.054352f, 0.060608f, 0.066711f, 0.073059f, 0.080505f, 0.088318f,
+ 0.097290f, 0.105835f, 0.115845f, 0.126343f, 0.137085f, 0.148804f, 0.161377f, 0.175049f, 0.189331f, 0.204346f, 0.219604f, 0.236816f,
+ 0.253662f, 0.272217f, 0.291260f, 0.310547f, 0.330811f, 0.350830f, 0.372314f, 0.393799f, 0.415771f, 0.437500f, 0.459717f, 0.481934f,
+ 0.504883f, 0.527344f, 0.549316f, 0.571777f, 0.593750f, 0.615723f, 0.636230f, 0.657715f, 0.678223f, 0.697754f, 0.718262f, 0.737793f,
+ 0.756348f, 0.774902f, 0.900879f, 0.907227f, 0.906738f, 0.905762f, 0.904297f, 0.902832f, 0.001290f, 0.003807f, 0.006207f, 0.008652f,
+ 0.011368f, 0.014618f, 0.017792f, 0.020813f, 0.023849f, 0.027588f, 0.031036f, 0.035400f, 0.039917f, 0.044250f, 0.049408f, 0.054321f,
+ 0.059937f, 0.065918f, 0.072937f, 0.079773f, 0.087463f, 0.095703f, 0.104553f, 0.113892f, 0.124146f, 0.134888f, 0.146606f, 0.159058f,
+ 0.171753f, 0.185913f, 0.201416f, 0.216309f, 0.232910f, 0.250000f, 0.268555f, 0.287354f, 0.306885f, 0.326904f, 0.347412f, 0.369141f,
+ 0.390381f, 0.412842f, 0.434570f, 0.457764f, 0.479736f, 0.502930f, 0.525879f, 0.547852f, 0.570801f, 0.592773f, 0.615723f, 0.637207f,
+ 0.659180f, 0.680176f, 0.700684f, 0.720703f, 0.740234f, 0.759766f, 0.895996f, 0.901855f, 0.901855f, 0.900879f, 0.899414f, 0.897949f,
+ 0.001030f, 0.003561f, 0.005718f, 0.008301f, 0.010582f, 0.013283f, 0.015839f, 0.018753f, 0.022156f, 0.025314f, 0.028427f, 0.032318f,
+ 0.035889f, 0.040039f, 0.044434f, 0.048737f, 0.054077f, 0.059723f, 0.065613f, 0.072083f, 0.079224f, 0.086426f, 0.094238f, 0.102966f,
+ 0.111938f, 0.122253f, 0.132568f, 0.143555f, 0.155884f, 0.168945f, 0.182861f, 0.197510f, 0.213379f, 0.229492f, 0.246948f, 0.264648f,
+ 0.283203f, 0.303467f, 0.322998f, 0.343994f, 0.365479f, 0.387451f, 0.409912f, 0.432129f, 0.455078f, 0.478760f, 0.501465f, 0.523926f,
+ 0.547852f, 0.570801f, 0.593750f, 0.616211f, 0.639160f, 0.661133f, 0.682617f, 0.703613f, 0.725098f, 0.745117f, 0.888672f, 0.896484f,
+ 0.896973f, 0.895020f, 0.895508f, 0.893555f, 0.001051f, 0.002956f, 0.005398f, 0.007523f, 0.009613f, 0.012024f, 0.014725f, 0.017059f,
+ 0.019714f, 0.022537f, 0.025681f, 0.029236f, 0.032715f, 0.036102f, 0.040100f, 0.043945f, 0.048859f, 0.053772f, 0.058838f, 0.064880f,
+ 0.070862f, 0.077576f, 0.084839f, 0.092712f, 0.101013f, 0.110229f, 0.119446f, 0.130005f, 0.141113f, 0.153198f, 0.166016f, 0.179565f,
+ 0.193970f, 0.209351f, 0.225830f, 0.242920f, 0.261230f, 0.280273f, 0.299316f, 0.320068f, 0.341309f, 0.363037f, 0.384521f, 0.407227f,
+ 0.429443f, 0.453369f, 0.477051f, 0.500977f, 0.524414f, 0.547852f, 0.571777f, 0.595215f, 0.619141f, 0.641602f, 0.664062f, 0.686035f,
+ 0.707520f, 0.729004f, 0.882812f, 0.891602f, 0.891113f, 0.890625f, 0.889160f, 0.888184f, 0.000934f, 0.002998f, 0.004883f, 0.006859f,
+ 0.009102f, 0.010925f, 0.012871f, 0.015656f, 0.017853f, 0.020767f, 0.023422f, 0.026413f, 0.029251f, 0.032593f, 0.036011f, 0.039825f,
+ 0.044495f, 0.048645f, 0.053284f, 0.058258f, 0.063782f, 0.069885f, 0.076111f, 0.083313f, 0.090881f, 0.099060f, 0.107788f, 0.117126f,
+ 0.127075f, 0.138428f, 0.150391f, 0.162720f, 0.176270f, 0.190796f, 0.206177f, 0.222290f, 0.239624f, 0.257568f, 0.276367f, 0.296387f,
+ 0.316895f, 0.338623f, 0.360352f, 0.382812f, 0.404785f, 0.428467f, 0.452148f, 0.476562f, 0.500488f, 0.524902f, 0.548828f, 0.572754f,
+ 0.597168f, 0.621094f, 0.644531f, 0.667480f, 0.689941f, 0.712402f, 0.875977f, 0.883789f, 0.884766f, 0.884766f, 0.883301f, 0.883789f,
+ 0.001108f, 0.002474f, 0.004707f, 0.006248f, 0.007744f, 0.009888f, 0.011787f, 0.014244f, 0.016205f, 0.018631f, 0.021286f, 0.023758f,
+ 0.026535f, 0.029510f, 0.032654f, 0.035919f, 0.039825f, 0.043762f, 0.047852f, 0.052368f, 0.057373f, 0.062561f, 0.068604f, 0.074707f,
+ 0.081360f, 0.088623f, 0.096802f, 0.105103f, 0.114624f, 0.124573f, 0.135498f, 0.147217f, 0.159424f, 0.172729f, 0.187378f, 0.202881f,
+ 0.219116f, 0.235962f, 0.254639f, 0.273438f, 0.293945f, 0.314453f, 0.335449f, 0.358154f, 0.380371f, 0.403564f, 0.428223f, 0.452148f,
+ 0.476074f, 0.500977f, 0.525879f, 0.550293f, 0.575195f, 0.599609f, 0.625000f, 0.649414f, 0.672852f, 0.695801f, 0.870117f, 0.879395f,
+ 0.879883f, 0.879395f, 0.878906f, 0.877441f, 0.000877f, 0.002495f, 0.003918f, 0.005669f, 0.007484f, 0.009148f, 0.010895f, 0.012634f,
+ 0.014717f, 0.017014f, 0.019302f, 0.021347f, 0.023849f, 0.026443f, 0.029388f, 0.032532f, 0.035492f, 0.039185f, 0.042816f, 0.046906f,
+ 0.051453f, 0.056122f, 0.061310f, 0.066895f, 0.072937f, 0.079590f, 0.086548f, 0.094360f, 0.103027f, 0.111938f, 0.121643f, 0.132568f,
+ 0.144043f, 0.156006f, 0.169434f, 0.184204f, 0.199341f, 0.215698f, 0.233032f, 0.251221f, 0.269531f, 0.290039f, 0.311768f, 0.333740f,
+ 0.355957f, 0.379395f, 0.402344f, 0.426758f, 0.451172f, 0.476562f, 0.501465f, 0.526855f, 0.552246f, 0.578613f, 0.603516f, 0.629395f,
+ 0.653809f, 0.679199f, 0.863281f, 0.872559f, 0.874023f, 0.873535f, 0.872559f, 0.871094f, 0.000779f, 0.002241f, 0.003813f, 0.005371f,
+ 0.006763f, 0.008186f, 0.009827f, 0.011574f, 0.013260f, 0.015274f, 0.017303f, 0.019119f, 0.021362f, 0.023972f, 0.026505f, 0.029144f,
+ 0.031860f, 0.035126f, 0.038422f, 0.041809f, 0.045929f, 0.050323f, 0.054840f, 0.059631f, 0.065002f, 0.070984f, 0.077759f, 0.084656f,
+ 0.091736f, 0.100037f, 0.109436f, 0.118835f, 0.129272f, 0.140625f, 0.152832f, 0.166138f, 0.180786f, 0.195679f, 0.211914f, 0.229736f,
+ 0.247803f, 0.267822f, 0.287598f, 0.309326f, 0.331055f, 0.354492f, 0.377686f, 0.401855f, 0.426270f, 0.451660f, 0.477051f, 0.503418f,
+ 0.529785f, 0.555664f, 0.583008f, 0.608887f, 0.635254f, 0.661133f, 0.855957f, 0.865234f, 0.866699f, 0.867188f, 0.866211f, 0.865723f,
+ 0.000778f, 0.002155f, 0.003584f, 0.004871f, 0.006149f, 0.007519f, 0.008858f, 0.010498f, 0.012100f, 0.013977f, 0.015511f, 0.017303f,
+ 0.019363f, 0.021515f, 0.023880f, 0.026230f, 0.028564f, 0.031555f, 0.034241f, 0.037476f, 0.041138f, 0.044983f, 0.048859f, 0.053436f,
+ 0.058014f, 0.063232f, 0.069214f, 0.075195f, 0.081848f, 0.089417f, 0.097168f, 0.106201f, 0.115479f, 0.126343f, 0.137695f, 0.149658f,
+ 0.162476f, 0.177002f, 0.192993f, 0.209473f, 0.226440f, 0.245239f, 0.264404f, 0.285156f, 0.306885f, 0.330078f, 0.353271f, 0.376465f,
+ 0.402100f, 0.426758f, 0.453857f, 0.479492f, 0.505859f, 0.532715f, 0.560547f, 0.587402f, 0.614258f, 0.640137f, 0.847168f, 0.858398f,
+ 0.860352f, 0.859863f, 0.859863f, 0.858887f, 0.000673f, 0.002026f, 0.003120f, 0.004242f, 0.005390f, 0.006874f, 0.008087f, 0.009346f,
+ 0.011192f, 0.012642f, 0.013855f, 0.015511f, 0.017502f, 0.019394f, 0.021301f, 0.023331f, 0.025681f, 0.028137f, 0.030792f, 0.033295f,
+ 0.036804f, 0.039917f, 0.043488f, 0.047363f, 0.051880f, 0.056580f, 0.061646f, 0.066956f, 0.072998f, 0.079407f, 0.086609f, 0.094971f,
+ 0.103027f, 0.112793f, 0.122742f, 0.134399f, 0.146118f, 0.159058f, 0.173828f, 0.188599f, 0.205444f, 0.223633f, 0.241943f, 0.262451f,
+ 0.283203f, 0.304932f, 0.328369f, 0.352051f, 0.376953f, 0.402100f, 0.428467f, 0.454834f, 0.481934f, 0.509766f, 0.537598f, 0.566406f,
+ 0.594238f, 0.622559f, 0.838867f, 0.852051f, 0.853516f, 0.853027f, 0.853027f, 0.852051f, 0.000419f, 0.001721f, 0.003044f, 0.003881f,
+ 0.005161f, 0.006329f, 0.007500f, 0.009117f, 0.009941f, 0.011147f, 0.013023f, 0.014053f, 0.015869f, 0.017181f, 0.018906f, 0.020889f,
+ 0.023026f, 0.025085f, 0.027435f, 0.029724f, 0.032440f, 0.035492f, 0.038605f, 0.042175f, 0.045898f, 0.049988f, 0.054504f, 0.059143f,
+ 0.064697f, 0.070435f, 0.076721f, 0.083984f, 0.091675f, 0.100037f, 0.109009f, 0.119629f, 0.130737f, 0.143066f, 0.156250f, 0.170654f,
+ 0.186157f, 0.202393f, 0.220825f, 0.239990f, 0.259521f, 0.281250f, 0.303467f, 0.327148f, 0.351318f, 0.376953f, 0.402832f, 0.430664f,
+ 0.458252f, 0.485596f, 0.514648f, 0.543457f, 0.572754f, 0.602051f, 0.830566f, 0.844238f, 0.845703f, 0.845703f, 0.845703f, 0.845215f,
+ 0.000503f, 0.001644f, 0.002455f, 0.003765f, 0.004906f, 0.005901f, 0.006805f, 0.007744f, 0.008789f, 0.009972f, 0.011314f, 0.012688f,
+ 0.014160f, 0.015480f, 0.016953f, 0.018555f, 0.020325f, 0.022232f, 0.024338f, 0.026535f, 0.028717f, 0.031403f, 0.034119f, 0.037384f,
+ 0.040680f, 0.044128f, 0.047943f, 0.052551f, 0.057098f, 0.062134f, 0.067871f, 0.074158f, 0.081543f, 0.088684f, 0.097107f, 0.106262f,
+ 0.116028f, 0.127563f, 0.139404f, 0.152344f, 0.167358f, 0.182739f, 0.199951f, 0.217773f, 0.237427f, 0.257812f, 0.279541f, 0.303223f,
+ 0.327148f, 0.351807f, 0.377441f, 0.405518f, 0.433105f, 0.460449f, 0.491211f, 0.520020f, 0.550293f, 0.581543f, 0.821777f, 0.835938f,
+ 0.837891f, 0.838867f, 0.838867f, 0.837891f, 0.000649f, 0.001432f, 0.002455f, 0.003469f, 0.004162f, 0.005192f, 0.006046f, 0.007053f,
+ 0.007919f, 0.009148f, 0.010185f, 0.011490f, 0.012558f, 0.013748f, 0.015083f, 0.016663f, 0.018341f, 0.019897f, 0.021561f, 0.023376f,
+ 0.025513f, 0.027725f, 0.030075f, 0.032745f, 0.035583f, 0.038544f, 0.041901f, 0.045898f, 0.049896f, 0.054443f, 0.059784f, 0.065186f,
+ 0.071228f, 0.078247f, 0.085632f, 0.093872f, 0.103088f, 0.113098f, 0.123840f, 0.135986f, 0.148682f, 0.163696f, 0.179321f, 0.196533f,
+ 0.214722f, 0.234985f, 0.256104f, 0.278320f, 0.302246f, 0.326660f, 0.352783f, 0.379395f, 0.406738f, 0.436279f, 0.465820f, 0.496338f,
+ 0.527344f, 0.559082f, 0.813477f, 0.827148f, 0.829590f, 0.830566f, 0.830566f, 0.829590f, 0.000427f, 0.001431f, 0.002077f, 0.002947f,
+ 0.004009f, 0.004860f, 0.005501f, 0.006416f, 0.007008f, 0.008171f, 0.009155f, 0.010063f, 0.011154f, 0.012474f, 0.013336f, 0.014793f,
+ 0.016006f, 0.017471f, 0.019119f, 0.020630f, 0.022079f, 0.024078f, 0.026505f, 0.028687f, 0.031128f, 0.033813f, 0.036804f, 0.040283f,
+ 0.043732f, 0.047882f, 0.052094f, 0.057281f, 0.062500f, 0.068726f, 0.075012f, 0.082581f, 0.090393f, 0.099487f, 0.109375f, 0.120728f,
+ 0.131958f, 0.145508f, 0.160278f, 0.176025f, 0.193848f, 0.212891f, 0.232788f, 0.253906f, 0.277344f, 0.302002f, 0.327637f, 0.354248f,
+ 0.382080f, 0.411621f, 0.441162f, 0.472656f, 0.504395f, 0.536621f, 0.803223f, 0.818359f, 0.821777f, 0.821777f, 0.822266f, 0.821777f,
+ 0.000574f, 0.001416f, 0.001961f, 0.002621f, 0.003527f, 0.004250f, 0.004894f, 0.005653f, 0.006340f, 0.007263f, 0.008255f, 0.008965f,
+ 0.009819f, 0.010857f, 0.011864f, 0.012917f, 0.014114f, 0.015358f, 0.016678f, 0.018005f, 0.019669f, 0.021347f, 0.023239f, 0.025070f,
+ 0.027267f, 0.029434f, 0.032318f, 0.035156f, 0.038269f, 0.041534f, 0.045624f, 0.049469f, 0.054321f, 0.059479f, 0.065369f, 0.071655f,
+ 0.078857f, 0.086853f, 0.095886f, 0.105652f, 0.116943f, 0.128662f, 0.142090f, 0.156860f, 0.173096f, 0.190918f, 0.210327f, 0.231201f,
+ 0.253418f, 0.277100f, 0.302490f, 0.328369f, 0.356445f, 0.385254f, 0.415771f, 0.446533f, 0.479736f, 0.513184f, 0.794434f, 0.810547f,
+ 0.812500f, 0.813477f, 0.812988f, 0.813477f, 0.000417f, 0.001152f, 0.002066f, 0.002480f, 0.003115f, 0.003778f, 0.004543f, 0.005001f,
+ 0.005936f, 0.006420f, 0.007130f, 0.007881f, 0.008789f, 0.009666f, 0.010605f, 0.011276f, 0.012352f, 0.013367f, 0.014626f, 0.015732f,
+ 0.017090f, 0.018509f, 0.020096f, 0.021759f, 0.023895f, 0.025681f, 0.027740f, 0.030121f, 0.032776f, 0.036011f, 0.039276f, 0.042694f,
+ 0.046906f, 0.051575f, 0.056488f, 0.061951f, 0.068481f, 0.075684f, 0.083191f, 0.092102f, 0.101990f, 0.112915f, 0.125122f, 0.138672f,
+ 0.153564f, 0.170410f, 0.188477f, 0.208008f, 0.229980f, 0.252441f, 0.276855f, 0.303711f, 0.331055f, 0.360596f, 0.391357f, 0.422607f,
+ 0.456299f, 0.490234f, 0.783203f, 0.799805f, 0.803223f, 0.804688f, 0.804199f, 0.805176f, 0.000422f, 0.000885f, 0.001743f, 0.002075f,
+ 0.002930f, 0.003460f, 0.004105f, 0.004696f, 0.005257f, 0.005753f, 0.006550f, 0.006916f, 0.007805f, 0.008308f, 0.009109f, 0.010056f,
+ 0.010918f, 0.011627f, 0.012787f, 0.013725f, 0.014732f, 0.016113f, 0.017319f, 0.018906f, 0.020264f, 0.022324f, 0.023911f, 0.026230f,
+ 0.028183f, 0.030884f, 0.033661f, 0.036865f, 0.040314f, 0.044189f, 0.048615f, 0.053284f, 0.058838f, 0.065491f, 0.072205f, 0.079651f,
+ 0.088379f, 0.098389f, 0.109314f, 0.121765f, 0.135010f, 0.150513f, 0.167358f, 0.186035f, 0.206543f, 0.228516f, 0.252197f, 0.278320f,
+ 0.305176f, 0.333496f, 0.364746f, 0.396973f, 0.430176f, 0.465820f, 0.772949f, 0.790527f, 0.794434f, 0.794922f, 0.795410f, 0.794922f,
+ 0.000211f, 0.000970f, 0.001484f, 0.002035f, 0.002586f, 0.003040f, 0.003540f, 0.004086f, 0.004696f, 0.005016f, 0.005508f, 0.006100f,
+ 0.006763f, 0.007401f, 0.008011f, 0.008675f, 0.009247f, 0.010071f, 0.011009f, 0.011940f, 0.012802f, 0.013870f, 0.014771f, 0.016281f,
+ 0.017487f, 0.018890f, 0.020584f, 0.022171f, 0.024200f, 0.026505f, 0.028870f, 0.031372f, 0.034363f, 0.037659f, 0.041412f, 0.045685f,
+ 0.050262f, 0.055664f, 0.061768f, 0.068359f, 0.076172f, 0.084717f, 0.094666f, 0.105835f, 0.117798f, 0.131958f, 0.147095f, 0.164795f,
+ 0.184326f, 0.204956f, 0.228271f, 0.253174f, 0.279785f, 0.307861f, 0.338379f, 0.370361f, 0.404785f, 0.440430f, 0.761230f, 0.780273f,
+ 0.783691f, 0.785645f, 0.786133f, 0.785156f, 0.000281f, 0.000954f, 0.001275f, 0.001745f, 0.002159f, 0.002810f, 0.003002f, 0.003622f,
+ 0.003918f, 0.004471f, 0.004776f, 0.005352f, 0.005852f, 0.006298f, 0.006989f, 0.007339f, 0.008087f, 0.008698f, 0.009499f, 0.010208f,
+ 0.010986f, 0.011871f, 0.012802f, 0.013809f, 0.014923f, 0.016129f, 0.017624f, 0.018753f, 0.020645f, 0.022156f, 0.024399f, 0.026382f,
+ 0.029037f, 0.031769f, 0.034851f, 0.038513f, 0.042542f, 0.047180f, 0.052063f, 0.058136f, 0.064819f, 0.072205f, 0.080933f, 0.090698f,
+ 0.101685f, 0.114441f, 0.128784f, 0.144287f, 0.162476f, 0.182617f, 0.203979f, 0.228149f, 0.253906f, 0.282227f, 0.312744f, 0.344482f,
+ 0.378418f, 0.415039f, 0.749023f, 0.770020f, 0.773438f, 0.774902f, 0.775391f, 0.776367f, 0.000200f, 0.000790f, 0.001209f, 0.001475f,
+ 0.002022f, 0.002375f, 0.002754f, 0.003136f, 0.003532f, 0.003851f, 0.004253f, 0.004719f, 0.004864f, 0.005455f, 0.005749f, 0.006435f,
+ 0.007053f, 0.007557f, 0.007988f, 0.008614f, 0.009216f, 0.010101f, 0.010712f, 0.011604f, 0.012596f, 0.013588f, 0.014877f, 0.016052f,
+ 0.017334f, 0.018753f, 0.020401f, 0.022415f, 0.024338f, 0.026642f, 0.029282f, 0.032196f, 0.035461f, 0.039215f, 0.043854f, 0.048706f,
+ 0.054413f, 0.060913f, 0.068237f, 0.076965f, 0.086792f, 0.097961f, 0.110657f, 0.125488f, 0.141846f, 0.160278f, 0.180542f, 0.203857f,
+ 0.229004f, 0.256348f, 0.286133f, 0.317627f, 0.351807f, 0.388184f, 0.737305f, 0.757812f, 0.762695f, 0.763672f, 0.764160f, 0.764648f,
+ 0.000214f, 0.000700f, 0.001134f, 0.001480f, 0.001724f, 0.002056f, 0.002468f, 0.002672f, 0.003069f, 0.003412f, 0.003618f, 0.003883f,
+ 0.004265f, 0.004627f, 0.004971f, 0.005508f, 0.005817f, 0.006397f, 0.006866f, 0.007244f, 0.007812f, 0.008446f, 0.009003f, 0.009872f,
+ 0.010544f, 0.011345f, 0.012375f, 0.013321f, 0.014275f, 0.015587f, 0.017075f, 0.018372f, 0.020050f, 0.022186f, 0.024246f, 0.026596f,
+ 0.029388f, 0.032562f, 0.036285f, 0.040344f, 0.045197f, 0.050568f, 0.056946f, 0.064514f, 0.072876f, 0.082886f, 0.093933f, 0.107056f,
+ 0.122070f, 0.139404f, 0.158325f, 0.180176f, 0.204590f, 0.231201f, 0.260010f, 0.290771f, 0.325195f, 0.361816f, 0.726074f, 0.747070f,
+ 0.751465f, 0.753418f, 0.753906f, 0.754395f, 0.000187f, 0.000637f, 0.001095f, 0.001133f, 0.001488f, 0.001872f, 0.002007f, 0.002253f,
+ 0.002590f, 0.002880f, 0.003010f, 0.003420f, 0.003593f, 0.003914f, 0.004322f, 0.004650f, 0.005051f, 0.005424f, 0.005733f, 0.006134f,
+ 0.006683f, 0.007183f, 0.007671f, 0.008072f, 0.008720f, 0.009483f, 0.010201f, 0.011070f, 0.011871f, 0.012863f, 0.013924f, 0.015167f,
+ 0.016434f, 0.018143f, 0.019669f, 0.021851f, 0.024109f, 0.026749f, 0.029587f, 0.033020f, 0.037109f, 0.041718f, 0.047119f, 0.053192f,
+ 0.060516f, 0.068848f, 0.078857f, 0.090149f, 0.104004f, 0.119202f, 0.136841f, 0.157471f, 0.180420f, 0.205322f, 0.234009f, 0.264648f,
+ 0.297852f, 0.335449f, 0.711914f, 0.735352f, 0.740234f, 0.741211f, 0.742676f, 0.742676f, 0.000201f, 0.000676f, 0.000884f, 0.001044f,
+ 0.001369f, 0.001633f, 0.001786f, 0.002001f, 0.002237f, 0.002460f, 0.002680f, 0.002777f, 0.003117f, 0.003408f, 0.003632f, 0.003910f,
+ 0.004211f, 0.004375f, 0.004772f, 0.005226f, 0.005520f, 0.005909f, 0.006302f, 0.006882f, 0.007385f, 0.007858f, 0.008553f, 0.008919f,
+ 0.009827f, 0.010582f, 0.011398f, 0.012520f, 0.013611f, 0.014725f, 0.016190f, 0.017593f, 0.019424f, 0.021622f, 0.023941f, 0.026703f,
+ 0.029938f, 0.033539f, 0.038055f, 0.043243f, 0.049408f, 0.056519f, 0.065002f, 0.074951f, 0.086548f, 0.100403f, 0.116394f, 0.135132f,
+ 0.156860f, 0.181030f, 0.208252f, 0.238281f, 0.271240f, 0.307861f, 0.698730f, 0.722656f, 0.727539f, 0.729980f, 0.730957f, 0.730469f,
+ 0.000185f, 0.000371f, 0.000784f, 0.001028f, 0.001153f, 0.001304f, 0.001567f, 0.001792f, 0.001790f, 0.002028f, 0.002283f, 0.002424f,
+ 0.002640f, 0.002764f, 0.003044f, 0.003313f, 0.003445f, 0.003748f, 0.004044f, 0.004337f, 0.004677f, 0.004879f, 0.005207f, 0.005661f,
+ 0.006027f, 0.006481f, 0.006870f, 0.007454f, 0.007874f, 0.008583f, 0.009239f, 0.009880f, 0.010849f, 0.011871f, 0.012833f, 0.014153f,
+ 0.015656f, 0.017151f, 0.018967f, 0.021118f, 0.023621f, 0.026703f, 0.030197f, 0.034576f, 0.039368f, 0.045441f, 0.052460f, 0.061157f,
+ 0.070862f, 0.083069f, 0.097290f, 0.114441f, 0.134155f, 0.157104f, 0.182983f, 0.212158f, 0.244507f, 0.281250f, 0.684570f, 0.710449f,
+ 0.715332f, 0.717285f, 0.717773f, 0.718750f, 0.000109f, 0.000455f, 0.000558f, 0.000757f, 0.000986f, 0.001166f, 0.001298f, 0.001310f,
+ 0.001566f, 0.001614f, 0.001852f, 0.001933f, 0.002062f, 0.002327f, 0.002571f, 0.002699f, 0.002909f, 0.003057f, 0.003254f, 0.003496f,
+ 0.003643f, 0.004066f, 0.004295f, 0.004665f, 0.004822f, 0.005161f, 0.005722f, 0.006008f, 0.006424f, 0.006897f, 0.007435f, 0.008049f,
+ 0.008789f, 0.009529f, 0.010284f, 0.011177f, 0.012321f, 0.013466f, 0.014885f, 0.016586f, 0.018417f, 0.020844f, 0.023575f, 0.026810f,
+ 0.030655f, 0.035400f, 0.041412f, 0.048462f, 0.056976f, 0.067322f, 0.079712f, 0.094543f, 0.112610f, 0.133789f, 0.158691f, 0.186279f,
+ 0.217896f, 0.253418f, 0.670898f, 0.696777f, 0.702148f, 0.704590f, 0.705078f, 0.705566f, 0.000000f, 0.000317f, 0.000556f, 0.000619f,
+ 0.000759f, 0.000889f, 0.001012f, 0.001163f, 0.001282f, 0.001353f, 0.001531f, 0.001621f, 0.001681f, 0.001862f, 0.001976f, 0.002140f,
+ 0.002392f, 0.002502f, 0.002745f, 0.002838f, 0.003019f, 0.003311f, 0.003477f, 0.003639f, 0.003889f, 0.004166f, 0.004429f, 0.004784f,
+ 0.005119f, 0.005547f, 0.006042f, 0.006317f, 0.006901f, 0.007442f, 0.008110f, 0.008751f, 0.009583f, 0.010590f, 0.011566f, 0.012894f,
+ 0.014404f, 0.015930f, 0.018158f, 0.020569f, 0.023697f, 0.027374f, 0.031830f, 0.037567f, 0.044434f, 0.053009f, 0.063599f, 0.076538f,
+ 0.092346f, 0.111511f, 0.134521f, 0.161133f, 0.191772f, 0.227173f, 0.654297f, 0.684082f, 0.687988f, 0.690918f, 0.691895f, 0.691895f,
+ 0.000000f, 0.000275f, 0.000368f, 0.000572f, 0.000683f, 0.000731f, 0.000877f, 0.000979f, 0.001039f, 0.001091f, 0.001234f, 0.001332f,
+ 0.001447f, 0.001547f, 0.001601f, 0.001760f, 0.001790f, 0.002007f, 0.002119f, 0.002245f, 0.002493f, 0.002565f, 0.002747f, 0.002920f,
+ 0.003168f, 0.003235f, 0.003551f, 0.003830f, 0.004040f, 0.004368f, 0.004658f, 0.005001f, 0.005337f, 0.005798f, 0.006287f, 0.006794f,
+ 0.007488f, 0.008087f, 0.008865f, 0.009773f, 0.010963f, 0.012199f, 0.013649f, 0.015610f, 0.017822f, 0.020493f, 0.023849f, 0.028320f,
+ 0.033752f, 0.040466f, 0.049377f, 0.060028f, 0.073853f, 0.090698f, 0.111572f, 0.136841f, 0.166016f, 0.199341f, 0.640137f, 0.667969f,
+ 0.675781f, 0.676758f, 0.678223f, 0.678223f, 0.000017f, 0.000193f, 0.000383f, 0.000487f, 0.000586f, 0.000597f, 0.000618f, 0.000733f,
+ 0.000826f, 0.000863f, 0.000902f, 0.001037f, 0.001121f, 0.001244f, 0.001342f, 0.001329f, 0.001514f, 0.001506f, 0.001719f, 0.001793f,
+ 0.001851f, 0.002016f, 0.002182f, 0.002281f, 0.002432f, 0.002554f, 0.002708f, 0.002859f, 0.003168f, 0.003344f, 0.003563f, 0.003845f,
+ 0.004158f, 0.004478f, 0.004852f, 0.005154f, 0.005714f, 0.006207f, 0.006752f, 0.007370f, 0.008186f, 0.009155f, 0.010193f, 0.011490f,
+ 0.013016f, 0.015144f, 0.017517f, 0.020752f, 0.024811f, 0.029922f, 0.036835f, 0.045593f, 0.056946f, 0.071533f, 0.090576f, 0.113159f,
+ 0.140991f, 0.173340f, 0.624023f, 0.653809f, 0.660156f, 0.663574f, 0.664551f, 0.664062f, 0.000194f, 0.000227f, 0.000316f, 0.000451f,
+ 0.000449f, 0.000482f, 0.000610f, 0.000511f, 0.000654f, 0.000673f, 0.000804f, 0.000844f, 0.000880f, 0.000955f, 0.000961f, 0.001127f,
+ 0.001169f, 0.001210f, 0.001318f, 0.001330f, 0.001507f, 0.001592f, 0.001657f, 0.001771f, 0.001839f, 0.001953f, 0.002083f, 0.002214f,
+ 0.002399f, 0.002518f, 0.002815f, 0.002882f, 0.003132f, 0.003361f, 0.003605f, 0.003925f, 0.004177f, 0.004528f, 0.004963f, 0.005527f,
+ 0.006027f, 0.006783f, 0.007381f, 0.008469f, 0.009644f, 0.010849f, 0.012772f, 0.014748f, 0.017578f, 0.021332f, 0.026367f, 0.033142f,
+ 0.042389f, 0.054413f, 0.070129f, 0.091064f, 0.116943f, 0.147339f, 0.608887f, 0.640137f, 0.645996f, 0.647461f, 0.650391f, 0.651367f,
+ 0.000166f, 0.000146f, 0.000248f, 0.000320f, 0.000288f, 0.000446f, 0.000375f, 0.000407f, 0.000468f, 0.000514f, 0.000629f, 0.000638f,
+ 0.000681f, 0.000773f, 0.000806f, 0.000766f, 0.000883f, 0.000927f, 0.000959f, 0.001036f, 0.001097f, 0.001172f, 0.001224f, 0.001297f,
+ 0.001392f, 0.001425f, 0.001592f, 0.001631f, 0.001793f, 0.001965f, 0.002089f, 0.002157f, 0.002321f, 0.002495f, 0.002680f, 0.002874f,
+ 0.003054f, 0.003305f, 0.003632f, 0.003902f, 0.004314f, 0.004753f, 0.005306f, 0.005901f, 0.006828f, 0.007645f, 0.008896f, 0.010323f,
+ 0.012283f, 0.014816f, 0.018234f, 0.023010f, 0.029678f, 0.039276f, 0.052307f, 0.070190f, 0.093811f, 0.123474f, 0.591797f, 0.623535f,
+ 0.631348f, 0.633301f, 0.634766f, 0.635254f, 0.000000f, 0.000154f, 0.000184f, 0.000257f, 0.000265f, 0.000266f, 0.000323f, 0.000291f,
+ 0.000369f, 0.000384f, 0.000450f, 0.000472f, 0.000505f, 0.000572f, 0.000577f, 0.000604f, 0.000636f, 0.000675f, 0.000699f, 0.000736f,
+ 0.000787f, 0.000840f, 0.000890f, 0.000945f, 0.000988f, 0.001039f, 0.001165f, 0.001165f, 0.001266f, 0.001318f, 0.001410f, 0.001550f,
+ 0.001618f, 0.001743f, 0.001866f, 0.001997f, 0.002151f, 0.002319f, 0.002562f, 0.002779f, 0.002975f, 0.003298f, 0.003674f, 0.004131f,
+ 0.004604f, 0.005268f, 0.006065f, 0.007027f, 0.008316f, 0.009949f, 0.012390f, 0.015526f, 0.019852f, 0.026733f, 0.036682f, 0.051666f,
+ 0.072449f, 0.099792f, 0.574707f, 0.608398f, 0.614746f, 0.618164f, 0.619629f, 0.621094f, 0.000000f, 0.000008f, 0.000146f, 0.000181f,
+ 0.000203f, 0.000243f, 0.000206f, 0.000250f, 0.000257f, 0.000283f, 0.000335f, 0.000293f, 0.000304f, 0.000368f, 0.000373f, 0.000435f,
+ 0.000418f, 0.000468f, 0.000539f, 0.000540f, 0.000564f, 0.000598f, 0.000628f, 0.000657f, 0.000716f, 0.000724f, 0.000797f, 0.000807f,
+ 0.000883f, 0.001002f, 0.000974f, 0.001037f, 0.001104f, 0.001196f, 0.001316f, 0.001394f, 0.001445f, 0.001574f, 0.001746f, 0.001829f,
+ 0.002005f, 0.002222f, 0.002401f, 0.002699f, 0.003057f, 0.003372f, 0.003874f, 0.004505f, 0.005360f, 0.006500f, 0.007927f, 0.009972f,
+ 0.012878f, 0.017258f, 0.024155f, 0.035339f, 0.052795f, 0.077637f, 0.558105f, 0.592285f, 0.600586f, 0.602539f, 0.604004f, 0.605469f,
+ 0.000000f, 0.000107f, 0.000122f, 0.000093f, 0.000133f, 0.000142f, 0.000149f, 0.000174f, 0.000174f, 0.000184f, 0.000190f, 0.000234f,
+ 0.000214f, 0.000250f, 0.000273f, 0.000286f, 0.000292f, 0.000302f, 0.000329f, 0.000336f, 0.000366f, 0.000391f, 0.000408f, 0.000444f,
+ 0.000452f, 0.000495f, 0.000531f, 0.000559f, 0.000578f, 0.000611f, 0.000659f, 0.000675f, 0.000757f, 0.000771f, 0.000854f, 0.000906f,
+ 0.000957f, 0.001004f, 0.001102f, 0.001187f, 0.001267f, 0.001394f, 0.001546f, 0.001683f, 0.001922f, 0.002094f, 0.002420f, 0.002754f,
+ 0.003254f, 0.003878f, 0.004757f, 0.005997f, 0.007812f, 0.010544f, 0.014786f, 0.022324f, 0.035522f, 0.057465f, 0.541504f, 0.576172f,
+ 0.583984f, 0.585938f, 0.588379f, 0.590332f, 0.000000f, 0.000099f, 0.000091f, 0.000084f, 0.000084f, 0.000086f, 0.000089f, 0.000101f,
+ 0.000105f, 0.000109f, 0.000122f, 0.000124f, 0.000132f, 0.000146f, 0.000171f, 0.000172f, 0.000176f, 0.000198f, 0.000197f, 0.000239f,
+ 0.000218f, 0.000235f, 0.000240f, 0.000281f, 0.000309f, 0.000301f, 0.000312f, 0.000321f, 0.000347f, 0.000370f, 0.000387f, 0.000419f,
+ 0.000444f, 0.000458f, 0.000513f, 0.000536f, 0.000570f, 0.000607f, 0.000688f, 0.000703f, 0.000754f, 0.000834f, 0.000890f, 0.000997f,
+ 0.001100f, 0.001238f, 0.001410f, 0.001584f, 0.001859f, 0.002207f, 0.002665f, 0.003323f, 0.004353f, 0.005947f, 0.008492f, 0.012909f,
+ 0.021606f, 0.039368f, 0.522461f, 0.559082f, 0.566406f, 0.569824f, 0.572266f, 0.572754f, 0.000108f, 0.000089f, 0.000079f, 0.000072f,
+ 0.000068f, 0.000065f, 0.000061f, 0.000057f, 0.000061f, 0.000062f, 0.000063f, 0.000086f, 0.000070f, 0.000071f, 0.000095f, 0.000080f,
+ 0.000107f, 0.000113f, 0.000115f, 0.000124f, 0.000121f, 0.000130f, 0.000151f, 0.000154f, 0.000164f, 0.000170f, 0.000176f, 0.000189f,
+ 0.000193f, 0.000215f, 0.000211f, 0.000242f, 0.000252f, 0.000260f, 0.000280f, 0.000293f, 0.000312f, 0.000350f, 0.000359f, 0.000389f,
+ 0.000410f, 0.000452f, 0.000481f, 0.000535f, 0.000578f, 0.000643f, 0.000718f, 0.000812f, 0.000939f, 0.001107f, 0.001329f, 0.001644f,
+ 0.002155f, 0.002930f, 0.004284f, 0.006706f, 0.011452f, 0.023895f, 0.504395f, 0.542480f, 0.550293f, 0.553711f, 0.555664f, 0.557129f,
+ 0.000093f, 0.000072f, 0.000063f, 0.000058f, 0.000053f, 0.000050f, 0.000047f, 0.000046f, 0.000044f, 0.000042f, 0.000039f, 0.000037f,
+ 0.000042f, 0.000035f, 0.000036f, 0.000037f, 0.000051f, 0.000046f, 0.000057f, 0.000058f, 0.000061f, 0.000062f, 0.000066f, 0.000069f,
+ 0.000072f, 0.000087f, 0.000077f, 0.000088f, 0.000093f, 0.000099f, 0.000103f, 0.000109f, 0.000115f, 0.000122f, 0.000139f, 0.000134f,
+ 0.000142f, 0.000170f, 0.000175f, 0.000179f, 0.000192f, 0.000203f, 0.000228f, 0.000245f, 0.000265f, 0.000291f, 0.000326f, 0.000360f,
+ 0.000420f, 0.000481f, 0.000574f, 0.000686f, 0.000887f, 0.001203f, 0.001759f, 0.002892f, 0.005318f, 0.011955f, 0.487305f, 0.524902f,
+ 0.534180f, 0.538086f, 0.539551f, 0.540527f, 0.000066f, 0.000049f, 0.000041f, 0.000037f, 0.000034f, 0.000033f, 0.000032f, 0.000030f,
+ 0.000029f, 0.000028f, 0.000028f, 0.000027f, 0.000026f, 0.000025f, 0.000024f, 0.000023f, 0.000022f, 0.000021f, 0.000022f, 0.000023f,
+ 0.000019f, 0.000018f, 0.000019f, 0.000024f, 0.000026f, 0.000029f, 0.000032f, 0.000032f, 0.000036f, 0.000034f, 0.000040f, 0.000041f,
+ 0.000043f, 0.000049f, 0.000049f, 0.000050f, 0.000056f, 0.000059f, 0.000067f, 0.000067f, 0.000074f, 0.000078f, 0.000082f, 0.000092f,
+ 0.000094f, 0.000103f, 0.000120f, 0.000130f, 0.000141f, 0.000163f, 0.000191f, 0.000230f, 0.000286f, 0.000374f, 0.000543f, 0.000890f,
+ 0.001802f, 0.004650f, 0.468994f, 0.507812f, 0.516602f, 0.520508f, 0.522461f, 0.523926f, 0.000007f, 0.000008f, 0.000008f, 0.000008f,
+ 0.000011f, 0.000010f, 0.000010f, 0.000011f, 0.000011f, 0.000011f, 0.000011f, 0.000011f, 0.000011f, 0.000011f, 0.000011f, 0.000012f,
+ 0.000012f, 0.000011f, 0.000011f, 0.000011f, 0.000011f, 0.000011f, 0.000011f, 0.000010f, 0.000010f, 0.000010f, 0.000009f, 0.000009f,
+ 0.000008f, 0.000008f, 0.000009f, 0.000009f, 0.000009f, 0.000009f, 0.000010f, 0.000011f, 0.000012f, 0.000014f, 0.000013f, 0.000016f,
+ 0.000015f, 0.000018f, 0.000020f, 0.000021f, 0.000022f, 0.000025f, 0.000024f, 0.000025f, 0.000030f, 0.000031f, 0.000040f, 0.000046f,
+ 0.000052f, 0.000071f, 0.000099f, 0.000147f, 0.000306f, 0.001072f, 0.450439f, 0.491211f, 0.499756f, 0.503418f, 0.505859f, 0.507324f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000002f, 0.000002f,
+ 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000001f, 0.000001f, 0.000001f, 0.000001f,
+ 0.000001f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000003f, 0.000003f, 0.000004f, 0.000007f, 0.000024f, 0.432129f, 0.474121f,
+ 0.482666f, 0.486572f, 0.489014f, 0.490234f,
+ },
+ {
+ 0.027573f, 0.080750f, 0.130981f, 0.177734f, 0.222290f, 0.263672f, 0.302002f, 0.338623f, 0.373291f, 0.405029f, 0.435791f, 0.464111f,
+ 0.490967f, 0.516602f, 0.540039f, 0.563477f, 0.584961f, 0.605469f, 0.625000f, 0.644043f, 0.660645f, 0.677246f, 0.693848f, 0.708496f,
+ 0.724121f, 0.738281f, 0.751465f, 0.764648f, 0.776855f, 0.789062f, 0.799805f, 0.810547f, 0.821289f, 0.831055f, 0.840820f, 0.850098f,
+ 0.859863f, 0.867676f, 0.876953f, 0.884277f, 0.892578f, 0.900391f, 0.907227f, 0.914551f, 0.921875f, 0.928223f, 0.934082f, 0.940430f,
+ 0.946777f, 0.952637f, 0.957520f, 0.964355f, 0.968262f, 0.974121f, 0.979004f, 0.983887f, 0.989258f, 0.994141f, 0.993164f, 0.983398f,
+ 0.976074f, 0.969238f, 0.962891f, 0.957031f, 0.022873f, 0.067871f, 0.111511f, 0.153809f, 0.193359f, 0.232788f, 0.268799f, 0.303223f,
+ 0.337402f, 0.368652f, 0.399414f, 0.427734f, 0.455078f, 0.481201f, 0.506348f, 0.529785f, 0.552246f, 0.573242f, 0.593750f, 0.613281f,
+ 0.632324f, 0.650391f, 0.667480f, 0.683105f, 0.698730f, 0.713867f, 0.728516f, 0.741211f, 0.755371f, 0.767578f, 0.779785f, 0.791504f,
+ 0.803223f, 0.813477f, 0.823242f, 0.834473f, 0.843750f, 0.853027f, 0.861816f, 0.870605f, 0.878906f, 0.887695f, 0.895996f, 0.901855f,
+ 0.910645f, 0.917480f, 0.923828f, 0.930176f, 0.937012f, 0.943359f, 0.949707f, 0.955078f, 0.960938f, 0.966797f, 0.972656f, 0.977051f,
+ 0.982422f, 0.987305f, 0.989746f, 0.981445f, 0.973633f, 0.967773f, 0.961426f, 0.956055f, 0.019089f, 0.057007f, 0.095215f, 0.132202f,
+ 0.168823f, 0.204712f, 0.238281f, 0.272217f, 0.304688f, 0.334717f, 0.364502f, 0.392822f, 0.420898f, 0.446533f, 0.471924f, 0.495850f,
+ 0.518555f, 0.541992f, 0.562988f, 0.582520f, 0.602539f, 0.621094f, 0.639160f, 0.655762f, 0.672852f, 0.687988f, 0.703613f, 0.718262f,
+ 0.732422f, 0.746094f, 0.758789f, 0.771484f, 0.783203f, 0.795898f, 0.807129f, 0.817383f, 0.827637f, 0.837402f, 0.846680f, 0.856445f,
+ 0.865234f, 0.874023f, 0.882324f, 0.890137f, 0.898438f, 0.905273f, 0.913574f, 0.920410f, 0.927246f, 0.934082f, 0.940918f, 0.946777f,
+ 0.953125f, 0.958496f, 0.964844f, 0.969727f, 0.975586f, 0.980957f, 0.986816f, 0.979004f, 0.971680f, 0.965332f, 0.959961f, 0.954590f,
+ 0.016327f, 0.048676f, 0.081787f, 0.114807f, 0.147705f, 0.180176f, 0.211426f, 0.243652f, 0.273438f, 0.303223f, 0.332031f, 0.360107f,
+ 0.386963f, 0.412598f, 0.438477f, 0.462891f, 0.487305f, 0.510254f, 0.530762f, 0.552246f, 0.572754f, 0.590820f, 0.610352f, 0.629883f,
+ 0.647461f, 0.662598f, 0.679688f, 0.693848f, 0.709961f, 0.723633f, 0.737305f, 0.750977f, 0.763672f, 0.776367f, 0.788086f, 0.799316f,
+ 0.810059f, 0.820801f, 0.832031f, 0.841309f, 0.851074f, 0.860352f, 0.868652f, 0.877930f, 0.886230f, 0.894531f, 0.902832f, 0.910156f,
+ 0.916504f, 0.924316f, 0.930664f, 0.937500f, 0.943848f, 0.950684f, 0.957031f, 0.962891f, 0.968262f, 0.974121f, 0.983887f, 0.976074f,
+ 0.969727f, 0.963867f, 0.958496f, 0.953125f, 0.013573f, 0.041901f, 0.070801f, 0.100098f, 0.129517f, 0.159058f, 0.187866f, 0.217041f,
+ 0.246216f, 0.274414f, 0.302002f, 0.328857f, 0.354980f, 0.381592f, 0.406738f, 0.431641f, 0.455322f, 0.478271f, 0.500000f, 0.521484f,
+ 0.541992f, 0.563477f, 0.583008f, 0.600098f, 0.619141f, 0.636719f, 0.653320f, 0.671387f, 0.684570f, 0.699707f, 0.715332f, 0.729492f,
+ 0.743164f, 0.755371f, 0.768555f, 0.780762f, 0.792480f, 0.804199f, 0.814453f, 0.824707f, 0.835449f, 0.845215f, 0.854980f, 0.864746f,
+ 0.874023f, 0.882812f, 0.890137f, 0.898438f, 0.905762f, 0.914062f, 0.921387f, 0.928223f, 0.935059f, 0.941406f, 0.948242f, 0.955078f,
+ 0.961426f, 0.966797f, 0.980957f, 0.973633f, 0.967773f, 0.961914f, 0.956543f, 0.951660f, 0.011681f, 0.036316f, 0.061584f, 0.087524f,
+ 0.113342f, 0.140259f, 0.167358f, 0.194214f, 0.220947f, 0.247437f, 0.273926f, 0.300537f, 0.325684f, 0.351074f, 0.375732f, 0.400146f,
+ 0.423828f, 0.446533f, 0.469482f, 0.491943f, 0.512695f, 0.532715f, 0.553223f, 0.573242f, 0.592285f, 0.609863f, 0.627930f, 0.644531f,
+ 0.660156f, 0.676758f, 0.691406f, 0.706055f, 0.720215f, 0.734863f, 0.749023f, 0.762207f, 0.774414f, 0.786133f, 0.797852f, 0.809082f,
+ 0.820801f, 0.831055f, 0.840332f, 0.850098f, 0.859863f, 0.869629f, 0.878418f, 0.886719f, 0.895508f, 0.903809f, 0.910645f, 0.918945f,
+ 0.925781f, 0.932617f, 0.939453f, 0.947754f, 0.953613f, 0.958984f, 0.977539f, 0.970703f, 0.964844f, 0.959473f, 0.954102f, 0.949707f,
+ 0.010330f, 0.031525f, 0.053406f, 0.076538f, 0.100159f, 0.124084f, 0.148193f, 0.173096f, 0.197998f, 0.223267f, 0.247681f, 0.273193f,
+ 0.297607f, 0.322021f, 0.346924f, 0.370117f, 0.394043f, 0.417236f, 0.439697f, 0.462158f, 0.483887f, 0.504883f, 0.524902f, 0.545410f,
+ 0.563477f, 0.583008f, 0.602539f, 0.618652f, 0.636230f, 0.652344f, 0.669922f, 0.685059f, 0.699219f, 0.714355f, 0.729004f, 0.741211f,
+ 0.755371f, 0.767578f, 0.780762f, 0.792480f, 0.803711f, 0.815918f, 0.825195f, 0.836914f, 0.846191f, 0.855957f, 0.864746f, 0.874512f,
+ 0.883301f, 0.891602f, 0.900391f, 0.908203f, 0.916016f, 0.923828f, 0.931152f, 0.937988f, 0.945801f, 0.952148f, 0.974121f, 0.967773f,
+ 0.962891f, 0.957520f, 0.952637f, 0.947754f, 0.009186f, 0.027359f, 0.047302f, 0.067505f, 0.088806f, 0.109924f, 0.132202f, 0.154907f,
+ 0.177246f, 0.201050f, 0.224121f, 0.247925f, 0.271240f, 0.295410f, 0.318359f, 0.341797f, 0.365234f, 0.387939f, 0.410156f, 0.432861f,
+ 0.454590f, 0.475586f, 0.495850f, 0.517090f, 0.536621f, 0.556152f, 0.575195f, 0.592773f, 0.609863f, 0.628418f, 0.645020f, 0.661133f,
+ 0.677246f, 0.692383f, 0.707520f, 0.721191f, 0.735352f, 0.748047f, 0.762207f, 0.774414f, 0.786621f, 0.798828f, 0.810547f, 0.820801f,
+ 0.831543f, 0.842285f, 0.852539f, 0.862305f, 0.871094f, 0.880859f, 0.889648f, 0.898438f, 0.906738f, 0.914551f, 0.921875f, 0.929199f,
+ 0.936035f, 0.944824f, 0.971191f, 0.965332f, 0.959473f, 0.955078f, 0.950195f, 0.945801f, 0.008041f, 0.024384f, 0.041321f, 0.059631f,
+ 0.078003f, 0.097656f, 0.117554f, 0.138428f, 0.159912f, 0.181152f, 0.203003f, 0.224976f, 0.247070f, 0.269531f, 0.292480f, 0.314697f,
+ 0.337891f, 0.360352f, 0.382324f, 0.403809f, 0.426025f, 0.447998f, 0.468018f, 0.488770f, 0.508301f, 0.528320f, 0.547852f, 0.567383f,
+ 0.585449f, 0.603516f, 0.620605f, 0.637695f, 0.654297f, 0.670410f, 0.686523f, 0.700195f, 0.715820f, 0.729980f, 0.743164f, 0.756836f,
+ 0.769531f, 0.782715f, 0.794434f, 0.805664f, 0.816895f, 0.827637f, 0.838379f, 0.848633f, 0.859375f, 0.868164f, 0.877930f, 0.887695f,
+ 0.895996f, 0.905273f, 0.912598f, 0.920898f, 0.928711f, 0.936035f, 0.966797f, 0.962402f, 0.957031f, 0.952637f, 0.947754f, 0.943848f,
+ 0.007095f, 0.021515f, 0.036926f, 0.052704f, 0.069641f, 0.087463f, 0.105347f, 0.123413f, 0.143188f, 0.163452f, 0.183105f, 0.204102f,
+ 0.225220f, 0.246704f, 0.268066f, 0.290283f, 0.311768f, 0.333740f, 0.355225f, 0.376465f, 0.397949f, 0.419434f, 0.440430f, 0.461670f,
+ 0.481445f, 0.500977f, 0.520020f, 0.540527f, 0.559570f, 0.578125f, 0.595703f, 0.613770f, 0.630371f, 0.646973f, 0.663086f, 0.678223f,
+ 0.694336f, 0.709473f, 0.723145f, 0.736328f, 0.750000f, 0.764648f, 0.777344f, 0.790039f, 0.801270f, 0.812988f, 0.824707f, 0.834961f,
+ 0.846191f, 0.856934f, 0.865723f, 0.875977f, 0.884766f, 0.894531f, 0.903320f, 0.911621f, 0.919922f, 0.927734f, 0.962891f, 0.959473f,
+ 0.954102f, 0.949219f, 0.945312f, 0.941406f, 0.006138f, 0.019150f, 0.033051f, 0.047089f, 0.061829f, 0.077515f, 0.094299f, 0.111084f,
+ 0.128174f, 0.146729f, 0.165771f, 0.185059f, 0.205200f, 0.224731f, 0.245361f, 0.265625f, 0.286865f, 0.307861f, 0.328857f, 0.350098f,
+ 0.370605f, 0.392090f, 0.413086f, 0.433594f, 0.454346f, 0.474609f, 0.493896f, 0.513672f, 0.532227f, 0.552734f, 0.569824f, 0.588867f,
+ 0.605957f, 0.623047f, 0.640625f, 0.656738f, 0.672852f, 0.688477f, 0.703613f, 0.717773f, 0.732910f, 0.746582f, 0.759766f, 0.772461f,
+ 0.786621f, 0.798340f, 0.810059f, 0.820312f, 0.832520f, 0.842773f, 0.853516f, 0.863770f, 0.873535f, 0.883789f, 0.892578f, 0.901367f,
+ 0.910645f, 0.919434f, 0.958984f, 0.955566f, 0.951172f, 0.946777f, 0.942871f, 0.938965f, 0.005424f, 0.017059f, 0.029541f, 0.042023f,
+ 0.055389f, 0.069397f, 0.083984f, 0.099670f, 0.115601f, 0.132324f, 0.149292f, 0.167114f, 0.185547f, 0.204468f, 0.224121f, 0.243896f,
+ 0.262939f, 0.283691f, 0.304443f, 0.323486f, 0.345459f, 0.365479f, 0.386230f, 0.407471f, 0.426758f, 0.448486f, 0.467529f, 0.487061f,
+ 0.506348f, 0.526367f, 0.545410f, 0.563965f, 0.581543f, 0.600098f, 0.617676f, 0.634277f, 0.650391f, 0.666016f, 0.682617f, 0.697754f,
+ 0.712891f, 0.727539f, 0.741211f, 0.755859f, 0.769043f, 0.782227f, 0.793945f, 0.806152f, 0.818848f, 0.830566f, 0.840332f, 0.851074f,
+ 0.861328f, 0.872070f, 0.881836f, 0.892090f, 0.900879f, 0.910645f, 0.955566f, 0.952637f, 0.948730f, 0.943359f, 0.939941f, 0.935547f,
+ 0.004833f, 0.015442f, 0.026169f, 0.037689f, 0.049683f, 0.062164f, 0.075806f, 0.089539f, 0.103760f, 0.119263f, 0.134888f, 0.151978f,
+ 0.168335f, 0.186646f, 0.204102f, 0.223022f, 0.242065f, 0.260986f, 0.280518f, 0.300537f, 0.320801f, 0.340820f, 0.360107f, 0.381104f,
+ 0.401367f, 0.421387f, 0.441650f, 0.460449f, 0.480957f, 0.500000f, 0.519531f, 0.538574f, 0.557129f, 0.575684f, 0.593262f, 0.610840f,
+ 0.628906f, 0.645508f, 0.662109f, 0.677246f, 0.692871f, 0.708008f, 0.723145f, 0.738281f, 0.751465f, 0.766113f, 0.778320f, 0.791504f,
+ 0.802246f, 0.816406f, 0.827637f, 0.838867f, 0.850098f, 0.860352f, 0.871582f, 0.881348f, 0.890137f, 0.899902f, 0.951660f, 0.948730f,
+ 0.944824f, 0.940918f, 0.937012f, 0.933594f, 0.004269f, 0.013809f, 0.023911f, 0.033569f, 0.044342f, 0.056213f, 0.068054f, 0.080811f,
+ 0.093933f, 0.107910f, 0.122131f, 0.137451f, 0.152710f, 0.169434f, 0.185791f, 0.203979f, 0.221436f, 0.239990f, 0.257812f, 0.277344f,
+ 0.296631f, 0.316162f, 0.335693f, 0.355713f, 0.375244f, 0.395996f, 0.416016f, 0.436035f, 0.455078f, 0.474365f, 0.494629f, 0.513184f,
+ 0.532715f, 0.550781f, 0.569336f, 0.586914f, 0.604980f, 0.622559f, 0.639648f, 0.655762f, 0.672363f, 0.688477f, 0.704102f, 0.718750f,
+ 0.733887f, 0.747559f, 0.761230f, 0.775391f, 0.788574f, 0.800781f, 0.814453f, 0.825684f, 0.837402f, 0.848633f, 0.859375f, 0.870605f,
+ 0.880371f, 0.891113f, 0.947754f, 0.945312f, 0.941895f, 0.937988f, 0.934082f, 0.931152f, 0.004028f, 0.012581f, 0.021133f, 0.030396f,
+ 0.039948f, 0.050323f, 0.061523f, 0.072815f, 0.084961f, 0.096985f, 0.110535f, 0.124756f, 0.138916f, 0.153687f, 0.169800f, 0.185669f,
+ 0.202881f, 0.219116f, 0.237305f, 0.255615f, 0.273926f, 0.293213f, 0.311768f, 0.331055f, 0.351074f, 0.370605f, 0.390381f, 0.409668f,
+ 0.429688f, 0.449707f, 0.468994f, 0.487549f, 0.506836f, 0.526367f, 0.545898f, 0.562988f, 0.581543f, 0.599121f, 0.616699f, 0.634766f,
+ 0.651367f, 0.667480f, 0.683594f, 0.699707f, 0.714844f, 0.730957f, 0.744141f, 0.758789f, 0.772949f, 0.785645f, 0.799316f, 0.812500f,
+ 0.823730f, 0.836914f, 0.847168f, 0.859375f, 0.869629f, 0.880371f, 0.942383f, 0.941406f, 0.937500f, 0.934570f, 0.931152f, 0.927734f,
+ 0.003613f, 0.011391f, 0.018875f, 0.027679f, 0.036133f, 0.045624f, 0.055420f, 0.065491f, 0.076416f, 0.088135f, 0.099487f, 0.112427f,
+ 0.126099f, 0.139771f, 0.154419f, 0.169556f, 0.184814f, 0.201050f, 0.218262f, 0.234985f, 0.252441f, 0.271484f, 0.289062f, 0.308594f,
+ 0.326660f, 0.346924f, 0.365234f, 0.384521f, 0.404541f, 0.424072f, 0.443359f, 0.463135f, 0.482422f, 0.501953f, 0.521484f, 0.539551f,
+ 0.558594f, 0.576660f, 0.595215f, 0.612793f, 0.629883f, 0.647949f, 0.663574f, 0.679688f, 0.695801f, 0.711426f, 0.727539f, 0.741699f,
+ 0.757324f, 0.770996f, 0.785156f, 0.798828f, 0.811035f, 0.823730f, 0.835449f, 0.848145f, 0.858887f, 0.870605f, 0.937988f, 0.937988f,
+ 0.934570f, 0.931152f, 0.927734f, 0.924805f, 0.003248f, 0.010185f, 0.017395f, 0.025055f, 0.032928f, 0.041321f, 0.049957f, 0.059265f,
+ 0.069092f, 0.079407f, 0.090820f, 0.101746f, 0.113770f, 0.126953f, 0.140381f, 0.154053f, 0.168701f, 0.184082f, 0.199951f, 0.216431f,
+ 0.232788f, 0.250000f, 0.267578f, 0.285645f, 0.303955f, 0.322998f, 0.341553f, 0.361084f, 0.379150f, 0.399414f, 0.418701f, 0.437988f,
+ 0.457275f, 0.477051f, 0.496094f, 0.515137f, 0.534180f, 0.553223f, 0.571289f, 0.589844f, 0.606934f, 0.625488f, 0.643066f, 0.659668f,
+ 0.676758f, 0.692871f, 0.708984f, 0.725098f, 0.740234f, 0.753906f, 0.769043f, 0.782227f, 0.796387f, 0.810059f, 0.822266f, 0.834961f,
+ 0.847168f, 0.859375f, 0.933594f, 0.933594f, 0.931152f, 0.927246f, 0.923828f, 0.921387f, 0.002914f, 0.009361f, 0.015793f, 0.022659f,
+ 0.029938f, 0.037354f, 0.045593f, 0.053406f, 0.062988f, 0.072083f, 0.081665f, 0.092712f, 0.103943f, 0.114990f, 0.128174f, 0.140503f,
+ 0.153809f, 0.167725f, 0.182251f, 0.198242f, 0.213623f, 0.230225f, 0.246826f, 0.263672f, 0.281494f, 0.300049f, 0.318604f, 0.337158f,
+ 0.356201f, 0.374756f, 0.394531f, 0.413574f, 0.433105f, 0.451904f, 0.471680f, 0.491211f, 0.509766f, 0.529297f, 0.547852f, 0.566895f,
+ 0.584961f, 0.603516f, 0.621094f, 0.638672f, 0.656738f, 0.673340f, 0.689453f, 0.706543f, 0.722656f, 0.737793f, 0.752930f, 0.767578f,
+ 0.781250f, 0.796875f, 0.809082f, 0.823242f, 0.835449f, 0.847656f, 0.929199f, 0.929199f, 0.927246f, 0.923828f, 0.920898f, 0.917969f,
+ 0.002766f, 0.008736f, 0.014442f, 0.020691f, 0.027054f, 0.033905f, 0.040924f, 0.048645f, 0.056976f, 0.065674f, 0.074951f, 0.084229f,
+ 0.094116f, 0.105225f, 0.116333f, 0.127563f, 0.139771f, 0.153564f, 0.166626f, 0.181030f, 0.196411f, 0.211182f, 0.227417f, 0.243896f,
+ 0.260742f, 0.277588f, 0.295898f, 0.314209f, 0.332031f, 0.351562f, 0.370117f, 0.389404f, 0.408203f, 0.428223f, 0.447266f, 0.467041f,
+ 0.486084f, 0.505859f, 0.524414f, 0.543945f, 0.562012f, 0.581543f, 0.600098f, 0.617676f, 0.636230f, 0.654297f, 0.670898f, 0.687500f,
+ 0.704102f, 0.720703f, 0.736816f, 0.751465f, 0.766113f, 0.781738f, 0.796387f, 0.809082f, 0.823242f, 0.835938f, 0.923828f, 0.925781f,
+ 0.922852f, 0.920410f, 0.916992f, 0.914551f, 0.002483f, 0.007599f, 0.013161f, 0.018555f, 0.024551f, 0.030670f, 0.037476f, 0.044464f,
+ 0.051636f, 0.059174f, 0.067688f, 0.075928f, 0.085693f, 0.095093f, 0.105591f, 0.116394f, 0.127441f, 0.139648f, 0.152344f, 0.165527f,
+ 0.179565f, 0.193970f, 0.208862f, 0.224487f, 0.240356f, 0.256836f, 0.274658f, 0.291748f, 0.310059f, 0.328369f, 0.346680f, 0.365234f,
+ 0.384521f, 0.404297f, 0.423340f, 0.442139f, 0.462646f, 0.481445f, 0.500977f, 0.520020f, 0.540039f, 0.559082f, 0.577148f, 0.596191f,
+ 0.614746f, 0.632812f, 0.651367f, 0.669434f, 0.685059f, 0.702637f, 0.718750f, 0.734375f, 0.750488f, 0.766113f, 0.780762f, 0.795410f,
+ 0.811035f, 0.823730f, 0.919434f, 0.920898f, 0.918457f, 0.916016f, 0.913086f, 0.910645f, 0.002457f, 0.007114f, 0.011757f, 0.016708f,
+ 0.022125f, 0.027786f, 0.033752f, 0.040375f, 0.046661f, 0.053864f, 0.061584f, 0.069336f, 0.077515f, 0.086365f, 0.095947f, 0.105896f,
+ 0.116638f, 0.127075f, 0.138916f, 0.151245f, 0.164062f, 0.177490f, 0.191528f, 0.206177f, 0.221802f, 0.237427f, 0.253906f, 0.270508f,
+ 0.287842f, 0.305664f, 0.323730f, 0.342285f, 0.361572f, 0.379639f, 0.399170f, 0.418457f, 0.438965f, 0.458252f, 0.477295f, 0.497559f,
+ 0.516113f, 0.536133f, 0.554688f, 0.574707f, 0.593750f, 0.612305f, 0.630859f, 0.648926f, 0.666504f, 0.684082f, 0.701660f, 0.717773f,
+ 0.734863f, 0.751465f, 0.766602f, 0.781738f, 0.797852f, 0.812012f, 0.913086f, 0.916016f, 0.913574f, 0.911621f, 0.909180f, 0.906250f,
+ 0.002132f, 0.006493f, 0.010750f, 0.015717f, 0.020569f, 0.025604f, 0.030823f, 0.036682f, 0.043060f, 0.049286f, 0.055786f, 0.062988f,
+ 0.070557f, 0.078918f, 0.086914f, 0.096191f, 0.105530f, 0.116028f, 0.126953f, 0.138306f, 0.149902f, 0.162231f, 0.175537f, 0.189453f,
+ 0.203491f, 0.218628f, 0.234131f, 0.250000f, 0.266602f, 0.284180f, 0.301514f, 0.319580f, 0.338135f, 0.356689f, 0.375977f, 0.395020f,
+ 0.413818f, 0.434082f, 0.452881f, 0.473145f, 0.492920f, 0.512207f, 0.532227f, 0.552246f, 0.570801f, 0.591309f, 0.609375f, 0.629395f,
+ 0.646973f, 0.665527f, 0.683105f, 0.700684f, 0.717773f, 0.734863f, 0.751465f, 0.767578f, 0.782715f, 0.799316f, 0.908203f, 0.911133f,
+ 0.909180f, 0.907227f, 0.904785f, 0.902832f, 0.001891f, 0.006008f, 0.010025f, 0.014122f, 0.018616f, 0.023239f, 0.028442f, 0.033691f,
+ 0.038757f, 0.044556f, 0.050964f, 0.057465f, 0.064087f, 0.071167f, 0.079224f, 0.087463f, 0.096008f, 0.105591f, 0.115356f, 0.125488f,
+ 0.136597f, 0.148193f, 0.160278f, 0.173218f, 0.186768f, 0.200684f, 0.215332f, 0.231323f, 0.246338f, 0.262939f, 0.279785f, 0.297607f,
+ 0.314941f, 0.333984f, 0.353271f, 0.371094f, 0.391357f, 0.409668f, 0.430420f, 0.448975f, 0.469482f, 0.489746f, 0.509277f, 0.528809f,
+ 0.549316f, 0.568848f, 0.588379f, 0.607910f, 0.626953f, 0.645996f, 0.664062f, 0.683105f, 0.700684f, 0.718262f, 0.735840f, 0.751953f,
+ 0.768555f, 0.785645f, 0.902344f, 0.906250f, 0.904785f, 0.902832f, 0.900391f, 0.898438f, 0.001732f, 0.005573f, 0.009193f, 0.012932f,
+ 0.017075f, 0.021286f, 0.025406f, 0.030289f, 0.035675f, 0.040344f, 0.046326f, 0.052032f, 0.058411f, 0.064575f, 0.072205f, 0.079834f,
+ 0.087708f, 0.095947f, 0.104797f, 0.114380f, 0.124451f, 0.134888f, 0.146606f, 0.158691f, 0.170776f, 0.184082f, 0.197510f, 0.212524f,
+ 0.227417f, 0.243164f, 0.259521f, 0.276367f, 0.293457f, 0.311768f, 0.329590f, 0.348633f, 0.367188f, 0.386230f, 0.406006f, 0.425781f,
+ 0.446533f, 0.465332f, 0.486084f, 0.505859f, 0.526367f, 0.545898f, 0.567383f, 0.585938f, 0.605957f, 0.625977f, 0.645508f, 0.664551f,
+ 0.683105f, 0.701172f, 0.718750f, 0.736816f, 0.754395f, 0.770508f, 0.896484f, 0.900879f, 0.900391f, 0.897949f, 0.895996f, 0.894043f,
+ 0.001713f, 0.004684f, 0.008339f, 0.011818f, 0.015450f, 0.019409f, 0.023605f, 0.027832f, 0.032349f, 0.036865f, 0.041809f, 0.047302f,
+ 0.052673f, 0.058838f, 0.065613f, 0.072083f, 0.079407f, 0.087280f, 0.095337f, 0.104126f, 0.113037f, 0.122986f, 0.133667f, 0.144897f,
+ 0.156250f, 0.168579f, 0.181396f, 0.195068f, 0.208984f, 0.224243f, 0.239624f, 0.255859f, 0.272461f, 0.289551f, 0.307617f, 0.326172f,
+ 0.344482f, 0.363770f, 0.383301f, 0.402588f, 0.422607f, 0.443115f, 0.463135f, 0.483154f, 0.503418f, 0.523926f, 0.544434f, 0.564941f,
+ 0.584473f, 0.604980f, 0.624512f, 0.645508f, 0.664551f, 0.683594f, 0.701660f, 0.721191f, 0.738281f, 0.755859f, 0.889648f, 0.895996f,
+ 0.895020f, 0.893066f, 0.891602f, 0.889160f, 0.001545f, 0.004745f, 0.007710f, 0.010979f, 0.014450f, 0.017807f, 0.021469f, 0.025238f,
+ 0.029282f, 0.033661f, 0.038177f, 0.043182f, 0.048157f, 0.053436f, 0.059326f, 0.065674f, 0.072205f, 0.078857f, 0.086548f, 0.094604f,
+ 0.102905f, 0.111816f, 0.121521f, 0.131592f, 0.142334f, 0.153442f, 0.165894f, 0.178345f, 0.192139f, 0.205933f, 0.220703f, 0.236084f,
+ 0.251709f, 0.268555f, 0.285645f, 0.303467f, 0.321777f, 0.340332f, 0.359619f, 0.379150f, 0.398682f, 0.419189f, 0.440430f, 0.460449f,
+ 0.480957f, 0.501465f, 0.521973f, 0.543457f, 0.563477f, 0.584961f, 0.604492f, 0.625488f, 0.645508f, 0.665039f, 0.684082f, 0.704102f,
+ 0.723145f, 0.741211f, 0.885254f, 0.890137f, 0.889160f, 0.887695f, 0.886719f, 0.884277f, 0.001487f, 0.004356f, 0.006828f, 0.010162f,
+ 0.012993f, 0.016022f, 0.019333f, 0.023087f, 0.026886f, 0.030518f, 0.034668f, 0.039062f, 0.043671f, 0.048370f, 0.053741f, 0.059326f,
+ 0.065308f, 0.071655f, 0.078125f, 0.085693f, 0.093323f, 0.101807f, 0.110657f, 0.119507f, 0.129517f, 0.140137f, 0.151367f, 0.163330f,
+ 0.175781f, 0.188843f, 0.202759f, 0.217163f, 0.232666f, 0.248413f, 0.264893f, 0.282227f, 0.299805f, 0.318115f, 0.336914f, 0.356445f,
+ 0.375488f, 0.395996f, 0.416504f, 0.436279f, 0.457520f, 0.479004f, 0.499023f, 0.520508f, 0.541504f, 0.562988f, 0.583984f, 0.604492f,
+ 0.625488f, 0.646973f, 0.666504f, 0.687012f, 0.706055f, 0.725098f, 0.877441f, 0.885254f, 0.884766f, 0.882324f, 0.881836f, 0.880371f,
+ 0.001443f, 0.003807f, 0.006336f, 0.009171f, 0.011909f, 0.015007f, 0.018097f, 0.020905f, 0.024384f, 0.027893f, 0.031555f, 0.035370f,
+ 0.039581f, 0.044128f, 0.048889f, 0.053894f, 0.059174f, 0.065125f, 0.070984f, 0.077698f, 0.084656f, 0.091919f, 0.100037f, 0.108093f,
+ 0.117493f, 0.127563f, 0.137817f, 0.148438f, 0.159912f, 0.172485f, 0.185547f, 0.199585f, 0.213867f, 0.229248f, 0.244995f, 0.261230f,
+ 0.278564f, 0.296387f, 0.314697f, 0.333252f, 0.353271f, 0.372314f, 0.393311f, 0.413330f, 0.433594f, 0.455078f, 0.476318f, 0.497314f,
+ 0.519531f, 0.540527f, 0.562500f, 0.583496f, 0.605469f, 0.626953f, 0.648438f, 0.669434f, 0.689941f, 0.709961f, 0.870605f, 0.878906f,
+ 0.878418f, 0.877441f, 0.875488f, 0.873535f, 0.001302f, 0.003712f, 0.005859f, 0.008286f, 0.010910f, 0.013779f, 0.016235f, 0.019135f,
+ 0.021912f, 0.025345f, 0.029022f, 0.032166f, 0.036011f, 0.040131f, 0.044128f, 0.048492f, 0.053528f, 0.058533f, 0.064209f, 0.070129f,
+ 0.076355f, 0.083191f, 0.090149f, 0.098328f, 0.106628f, 0.115662f, 0.124817f, 0.134766f, 0.145630f, 0.157104f, 0.169678f, 0.182495f,
+ 0.195801f, 0.210205f, 0.225342f, 0.241455f, 0.257812f, 0.274902f, 0.292725f, 0.311035f, 0.330322f, 0.349365f, 0.369873f, 0.390137f,
+ 0.411133f, 0.432373f, 0.453369f, 0.474609f, 0.496826f, 0.519043f, 0.541504f, 0.563477f, 0.585449f, 0.606445f, 0.629395f, 0.650391f,
+ 0.672363f, 0.693848f, 0.863281f, 0.872070f, 0.872070f, 0.871582f, 0.869629f, 0.868164f, 0.001170f, 0.003151f, 0.005295f, 0.007812f,
+ 0.010132f, 0.012466f, 0.015076f, 0.017517f, 0.019943f, 0.023178f, 0.026443f, 0.029312f, 0.032471f, 0.036041f, 0.039978f, 0.044037f,
+ 0.048828f, 0.053070f, 0.057983f, 0.063232f, 0.068909f, 0.075378f, 0.081909f, 0.088745f, 0.096375f, 0.104309f, 0.113281f, 0.122437f,
+ 0.132202f, 0.142944f, 0.154419f, 0.166138f, 0.178955f, 0.192505f, 0.206421f, 0.221558f, 0.237183f, 0.253906f, 0.270996f, 0.289062f,
+ 0.308105f, 0.326904f, 0.346924f, 0.366455f, 0.387695f, 0.408936f, 0.430176f, 0.451416f, 0.474365f, 0.496582f, 0.518066f, 0.541016f,
+ 0.563965f, 0.585938f, 0.608887f, 0.630859f, 0.654297f, 0.675781f, 0.856934f, 0.865234f, 0.866211f, 0.864746f, 0.863281f, 0.862793f,
+ 0.001049f, 0.003254f, 0.005234f, 0.007263f, 0.009270f, 0.011307f, 0.013596f, 0.015869f, 0.018555f, 0.020844f, 0.023972f, 0.026566f,
+ 0.029739f, 0.033020f, 0.036316f, 0.039856f, 0.044159f, 0.048096f, 0.052277f, 0.057281f, 0.062439f, 0.067871f, 0.073792f, 0.079956f,
+ 0.087158f, 0.094055f, 0.102234f, 0.110535f, 0.119934f, 0.129517f, 0.140259f, 0.151245f, 0.162842f, 0.175537f, 0.189209f, 0.203369f,
+ 0.218262f, 0.233643f, 0.250488f, 0.268066f, 0.285645f, 0.304443f, 0.324219f, 0.343750f, 0.364014f, 0.385254f, 0.406494f, 0.428223f,
+ 0.450928f, 0.472656f, 0.495605f, 0.519043f, 0.541504f, 0.565918f, 0.588379f, 0.612305f, 0.635742f, 0.659180f, 0.850098f, 0.859863f,
+ 0.859863f, 0.858398f, 0.857910f, 0.856934f, 0.000914f, 0.002861f, 0.004742f, 0.006569f, 0.008415f, 0.010521f, 0.012596f, 0.014648f,
+ 0.016708f, 0.019089f, 0.021515f, 0.023865f, 0.026688f, 0.029572f, 0.032928f, 0.036377f, 0.039337f, 0.043365f, 0.047333f, 0.051544f,
+ 0.056305f, 0.061066f, 0.066406f, 0.071960f, 0.078247f, 0.084961f, 0.092163f, 0.099426f, 0.108215f, 0.116943f, 0.126831f, 0.136719f,
+ 0.148193f, 0.159302f, 0.171875f, 0.185669f, 0.199585f, 0.214478f, 0.230469f, 0.247070f, 0.264160f, 0.282471f, 0.301270f, 0.321045f,
+ 0.341553f, 0.362061f, 0.383545f, 0.404785f, 0.427734f, 0.449951f, 0.473389f, 0.496582f, 0.520020f, 0.543457f, 0.568359f, 0.592285f,
+ 0.615723f, 0.639648f, 0.840820f, 0.851074f, 0.853027f, 0.853027f, 0.852051f, 0.850586f, 0.000679f, 0.002518f, 0.004173f, 0.006149f,
+ 0.008064f, 0.009369f, 0.011551f, 0.013222f, 0.015175f, 0.017212f, 0.019592f, 0.021835f, 0.024048f, 0.026932f, 0.029846f, 0.032623f,
+ 0.035675f, 0.038940f, 0.042542f, 0.046295f, 0.050354f, 0.055054f, 0.059601f, 0.064880f, 0.070190f, 0.076233f, 0.082703f, 0.089661f,
+ 0.097229f, 0.105103f, 0.113831f, 0.123474f, 0.133423f, 0.144409f, 0.156006f, 0.168335f, 0.182495f, 0.196411f, 0.211304f, 0.227295f,
+ 0.243530f, 0.260986f, 0.279053f, 0.298828f, 0.318359f, 0.339111f, 0.360107f, 0.381348f, 0.403809f, 0.427490f, 0.449463f, 0.473633f,
+ 0.497803f, 0.521484f, 0.546875f, 0.570801f, 0.595703f, 0.620605f, 0.833008f, 0.845215f, 0.845703f, 0.845703f, 0.845215f, 0.843750f,
+ 0.000719f, 0.002470f, 0.003975f, 0.005337f, 0.007275f, 0.008713f, 0.010376f, 0.012032f, 0.013580f, 0.015793f, 0.017609f, 0.019501f,
+ 0.021530f, 0.024277f, 0.026657f, 0.029312f, 0.031982f, 0.035187f, 0.038086f, 0.041565f, 0.045288f, 0.049103f, 0.053436f, 0.058136f,
+ 0.062927f, 0.068054f, 0.073853f, 0.080383f, 0.087341f, 0.094666f, 0.102173f, 0.111084f, 0.120300f, 0.130859f, 0.141235f, 0.152954f,
+ 0.164429f, 0.178223f, 0.192749f, 0.207642f, 0.223145f, 0.239868f, 0.258301f, 0.276611f, 0.295654f, 0.316162f, 0.337402f, 0.358643f,
+ 0.380859f, 0.403320f, 0.427002f, 0.450684f, 0.474609f, 0.499756f, 0.523926f, 0.550781f, 0.575195f, 0.600586f, 0.824707f, 0.836914f,
+ 0.838379f, 0.838867f, 0.837402f, 0.837402f, 0.000683f, 0.002361f, 0.003649f, 0.005116f, 0.006416f, 0.008202f, 0.009460f, 0.010941f,
+ 0.012817f, 0.014099f, 0.015839f, 0.017593f, 0.019867f, 0.021988f, 0.023926f, 0.026276f, 0.028824f, 0.031311f, 0.034363f, 0.036957f,
+ 0.040375f, 0.043823f, 0.047546f, 0.051758f, 0.056183f, 0.061249f, 0.066162f, 0.071777f, 0.077942f, 0.084534f, 0.091553f, 0.099487f,
+ 0.107910f, 0.116882f, 0.127075f, 0.137451f, 0.148804f, 0.161499f, 0.174805f, 0.188721f, 0.203735f, 0.220093f, 0.237427f, 0.254639f,
+ 0.273926f, 0.293457f, 0.313965f, 0.334961f, 0.357666f, 0.379883f, 0.403076f, 0.427002f, 0.451660f, 0.476807f, 0.501953f, 0.527344f,
+ 0.553711f, 0.581055f, 0.815918f, 0.829102f, 0.831055f, 0.831055f, 0.831055f, 0.830566f, 0.000607f, 0.001863f, 0.003416f, 0.004528f,
+ 0.005943f, 0.007191f, 0.008781f, 0.009964f, 0.011337f, 0.012939f, 0.014458f, 0.015808f, 0.018051f, 0.019394f, 0.021332f, 0.023529f,
+ 0.025803f, 0.028168f, 0.030502f, 0.033020f, 0.036072f, 0.039032f, 0.042419f, 0.046082f, 0.049927f, 0.054321f, 0.058411f, 0.063538f,
+ 0.069336f, 0.075684f, 0.081787f, 0.088562f, 0.096436f, 0.104553f, 0.113281f, 0.123596f, 0.133667f, 0.145386f, 0.157471f, 0.171021f,
+ 0.185547f, 0.200562f, 0.216553f, 0.234619f, 0.251709f, 0.271240f, 0.291504f, 0.312012f, 0.333496f, 0.355957f, 0.379395f, 0.403076f,
+ 0.428223f, 0.453857f, 0.479492f, 0.506348f, 0.532715f, 0.560059f, 0.805664f, 0.820801f, 0.823730f, 0.822754f, 0.822754f, 0.822266f,
+ 0.000593f, 0.001862f, 0.002966f, 0.004341f, 0.005600f, 0.006516f, 0.007626f, 0.008995f, 0.010223f, 0.011292f, 0.012848f, 0.014427f,
+ 0.016098f, 0.017532f, 0.019165f, 0.021027f, 0.022842f, 0.024918f, 0.027115f, 0.029739f, 0.032013f, 0.034637f, 0.037506f, 0.040955f,
+ 0.044220f, 0.048065f, 0.051941f, 0.056305f, 0.061768f, 0.066528f, 0.072327f, 0.078979f, 0.085571f, 0.092834f, 0.101135f, 0.110229f,
+ 0.119690f, 0.130127f, 0.141602f, 0.153564f, 0.167114f, 0.181763f, 0.196899f, 0.213623f, 0.230957f, 0.249268f, 0.268555f, 0.289062f,
+ 0.310059f, 0.333252f, 0.355957f, 0.379883f, 0.404541f, 0.430176f, 0.456055f, 0.483887f, 0.510254f, 0.539062f, 0.797852f, 0.812988f,
+ 0.814941f, 0.815430f, 0.815918f, 0.814453f, 0.000556f, 0.001811f, 0.002998f, 0.003815f, 0.004658f, 0.005905f, 0.007099f, 0.008232f,
+ 0.009239f, 0.010483f, 0.011559f, 0.013016f, 0.014305f, 0.015671f, 0.017090f, 0.018646f, 0.020370f, 0.022369f, 0.024124f, 0.026062f,
+ 0.028458f, 0.030624f, 0.033264f, 0.036041f, 0.039307f, 0.042053f, 0.045807f, 0.049530f, 0.054016f, 0.058441f, 0.063904f, 0.069641f,
+ 0.075745f, 0.082520f, 0.089539f, 0.097717f, 0.106750f, 0.116150f, 0.126587f, 0.137817f, 0.150024f, 0.163452f, 0.177490f, 0.193359f,
+ 0.209717f, 0.227539f, 0.246704f, 0.266602f, 0.287598f, 0.309326f, 0.332520f, 0.355713f, 0.380371f, 0.406494f, 0.432861f, 0.459961f,
+ 0.488525f, 0.517090f, 0.787598f, 0.804199f, 0.806641f, 0.807617f, 0.807617f, 0.807129f, 0.000507f, 0.001697f, 0.002468f, 0.003351f,
+ 0.004425f, 0.005486f, 0.006325f, 0.007412f, 0.008156f, 0.009270f, 0.010239f, 0.011497f, 0.012520f, 0.013954f, 0.015182f, 0.016617f,
+ 0.018036f, 0.019714f, 0.021362f, 0.022934f, 0.024704f, 0.026886f, 0.029419f, 0.031525f, 0.034302f, 0.037292f, 0.040558f, 0.043701f,
+ 0.047577f, 0.051849f, 0.056183f, 0.061249f, 0.066467f, 0.072876f, 0.078918f, 0.086548f, 0.094116f, 0.102844f, 0.112427f, 0.122620f,
+ 0.133667f, 0.146362f, 0.159668f, 0.174438f, 0.190063f, 0.207153f, 0.225098f, 0.244263f, 0.264648f, 0.286377f, 0.308350f, 0.332275f,
+ 0.357178f, 0.382080f, 0.408936f, 0.436035f, 0.465820f, 0.495361f, 0.776855f, 0.794922f, 0.797852f, 0.799316f, 0.798828f, 0.798340f,
+ 0.000366f, 0.001644f, 0.002289f, 0.003046f, 0.004082f, 0.005032f, 0.005550f, 0.006599f, 0.007389f, 0.008369f, 0.009201f, 0.010315f,
+ 0.011276f, 0.012405f, 0.013466f, 0.014587f, 0.015991f, 0.017303f, 0.018692f, 0.020081f, 0.021851f, 0.023865f, 0.025726f, 0.027771f,
+ 0.030136f, 0.032532f, 0.035309f, 0.038422f, 0.041626f, 0.045044f, 0.048767f, 0.053375f, 0.057861f, 0.063477f, 0.069031f, 0.075684f,
+ 0.082336f, 0.090515f, 0.099182f, 0.107849f, 0.118958f, 0.130005f, 0.142212f, 0.156128f, 0.170898f, 0.186890f, 0.203857f, 0.222534f,
+ 0.241821f, 0.263428f, 0.285156f, 0.308105f, 0.332275f, 0.359131f, 0.385010f, 0.413086f, 0.441895f, 0.472168f, 0.767090f, 0.785645f,
+ 0.789062f, 0.789551f, 0.790527f, 0.789551f, 0.000340f, 0.001434f, 0.002129f, 0.002827f, 0.003696f, 0.004463f, 0.005112f, 0.005730f,
+ 0.006836f, 0.007465f, 0.008217f, 0.008972f, 0.009972f, 0.010887f, 0.011948f, 0.012794f, 0.013947f, 0.015030f, 0.016266f, 0.017670f,
+ 0.019165f, 0.020813f, 0.022415f, 0.024216f, 0.026047f, 0.028336f, 0.030594f, 0.033142f, 0.035858f, 0.039154f, 0.042328f, 0.046265f,
+ 0.050537f, 0.055237f, 0.059998f, 0.065918f, 0.072083f, 0.078918f, 0.086243f, 0.094788f, 0.104309f, 0.114807f, 0.125854f, 0.138672f,
+ 0.152222f, 0.166992f, 0.183716f, 0.200928f, 0.220459f, 0.240112f, 0.261719f, 0.284668f, 0.308838f, 0.333740f, 0.360840f, 0.388672f,
+ 0.418213f, 0.448730f, 0.756348f, 0.775391f, 0.779297f, 0.780273f, 0.781250f, 0.780273f, 0.000511f, 0.001174f, 0.002163f, 0.002554f,
+ 0.003391f, 0.003990f, 0.004547f, 0.005211f, 0.005993f, 0.006653f, 0.007462f, 0.007942f, 0.008781f, 0.009476f, 0.010323f, 0.011444f,
+ 0.012207f, 0.013062f, 0.014336f, 0.015427f, 0.016464f, 0.017929f, 0.019287f, 0.021164f, 0.022461f, 0.024567f, 0.026474f, 0.028885f,
+ 0.031067f, 0.033630f, 0.036835f, 0.040070f, 0.043488f, 0.047394f, 0.051910f, 0.056732f, 0.062378f, 0.068481f, 0.075073f, 0.082764f,
+ 0.090881f, 0.100403f, 0.110779f, 0.122009f, 0.134399f, 0.148560f, 0.163940f, 0.180298f, 0.198120f, 0.218140f, 0.239014f, 0.260986f,
+ 0.285645f, 0.310059f, 0.336182f, 0.364502f, 0.393311f, 0.424316f, 0.744629f, 0.765137f, 0.769531f, 0.770508f, 0.771484f, 0.771484f,
+ 0.000374f, 0.000983f, 0.001696f, 0.002279f, 0.002924f, 0.003571f, 0.004139f, 0.004742f, 0.005390f, 0.005817f, 0.006371f, 0.006981f,
+ 0.007648f, 0.008354f, 0.009041f, 0.009727f, 0.010536f, 0.011375f, 0.012398f, 0.013535f, 0.014389f, 0.015541f, 0.016602f, 0.018112f,
+ 0.019516f, 0.020996f, 0.022644f, 0.024582f, 0.026627f, 0.028748f, 0.031586f, 0.034210f, 0.037415f, 0.040588f, 0.044464f, 0.048676f,
+ 0.053192f, 0.058472f, 0.064880f, 0.070984f, 0.078674f, 0.086914f, 0.096191f, 0.106445f, 0.117859f, 0.130859f, 0.144775f, 0.160522f,
+ 0.177490f, 0.196411f, 0.215942f, 0.237793f, 0.261475f, 0.285645f, 0.312012f, 0.339111f, 0.368652f, 0.400391f, 0.733887f, 0.755371f,
+ 0.759766f, 0.760742f, 0.761719f, 0.761719f, 0.000298f, 0.000924f, 0.001542f, 0.002125f, 0.002439f, 0.003153f, 0.003502f, 0.004196f,
+ 0.004585f, 0.005039f, 0.005531f, 0.006054f, 0.006531f, 0.007217f, 0.007935f, 0.008362f, 0.009171f, 0.009773f, 0.010704f, 0.011505f,
+ 0.012207f, 0.013321f, 0.014381f, 0.015556f, 0.016586f, 0.017792f, 0.019608f, 0.020844f, 0.022583f, 0.024536f, 0.026566f, 0.028885f,
+ 0.031494f, 0.034332f, 0.037689f, 0.041260f, 0.045258f, 0.049927f, 0.054901f, 0.060699f, 0.067322f, 0.074768f, 0.082764f, 0.091675f,
+ 0.102173f, 0.113831f, 0.126831f, 0.141113f, 0.157104f, 0.175049f, 0.194580f, 0.215210f, 0.237305f, 0.261475f, 0.287598f, 0.314697f,
+ 0.344482f, 0.375977f, 0.721680f, 0.744629f, 0.749512f, 0.751465f, 0.751465f, 0.751465f, 0.000275f, 0.001002f, 0.001335f, 0.001704f,
+ 0.002264f, 0.002790f, 0.003202f, 0.003555f, 0.004017f, 0.004368f, 0.004894f, 0.005318f, 0.005592f, 0.006241f, 0.006611f, 0.007317f,
+ 0.007851f, 0.008560f, 0.009071f, 0.009758f, 0.010429f, 0.011375f, 0.011986f, 0.013130f, 0.013916f, 0.015205f, 0.016403f, 0.017624f,
+ 0.019119f, 0.020660f, 0.022278f, 0.024582f, 0.026474f, 0.029007f, 0.031738f, 0.034668f, 0.038025f, 0.041962f, 0.046417f, 0.051270f,
+ 0.056915f, 0.063110f, 0.070312f, 0.078369f, 0.087769f, 0.098145f, 0.109863f, 0.123352f, 0.137451f, 0.154785f, 0.172363f, 0.192261f,
+ 0.214233f, 0.237793f, 0.262939f, 0.289795f, 0.319336f, 0.351074f, 0.708984f, 0.733398f, 0.738281f, 0.740234f, 0.741211f, 0.740723f,
+ 0.000334f, 0.000805f, 0.001231f, 0.001640f, 0.002033f, 0.002277f, 0.002871f, 0.003115f, 0.003481f, 0.003895f, 0.004147f, 0.004379f,
+ 0.004841f, 0.005306f, 0.005653f, 0.006241f, 0.006630f, 0.007217f, 0.007721f, 0.008133f, 0.008842f, 0.009529f, 0.010010f, 0.011017f,
+ 0.011780f, 0.012733f, 0.013626f, 0.014824f, 0.015656f, 0.017212f, 0.018829f, 0.020248f, 0.021973f, 0.023926f, 0.026306f, 0.028900f,
+ 0.031616f, 0.034973f, 0.038605f, 0.042816f, 0.047424f, 0.052765f, 0.059021f, 0.066162f, 0.074219f, 0.083435f, 0.093994f, 0.105835f,
+ 0.119385f, 0.134277f, 0.151611f, 0.170532f, 0.191284f, 0.214233f, 0.239014f, 0.265381f, 0.293701f, 0.325684f, 0.696289f, 0.722168f,
+ 0.727051f, 0.729004f, 0.729980f, 0.729980f, 0.000215f, 0.000635f, 0.001184f, 0.001348f, 0.001758f, 0.002171f, 0.002249f, 0.002596f,
+ 0.003004f, 0.003325f, 0.003487f, 0.003906f, 0.004108f, 0.004494f, 0.004955f, 0.005241f, 0.005726f, 0.006134f, 0.006485f, 0.006916f,
+ 0.007496f, 0.008072f, 0.008629f, 0.009071f, 0.009857f, 0.010651f, 0.011375f, 0.012283f, 0.013283f, 0.014320f, 0.015350f, 0.016739f,
+ 0.017975f, 0.019852f, 0.021454f, 0.023712f, 0.025925f, 0.028717f, 0.031769f, 0.035217f, 0.038910f, 0.043396f, 0.048767f, 0.054901f,
+ 0.061707f, 0.069824f, 0.078613f, 0.089783f, 0.101685f, 0.115479f, 0.131104f, 0.149292f, 0.168823f, 0.190674f, 0.214844f, 0.241211f,
+ 0.269775f, 0.299561f, 0.683594f, 0.709961f, 0.715332f, 0.717773f, 0.718262f, 0.718750f, 0.000199f, 0.000826f, 0.001047f, 0.001288f,
+ 0.001600f, 0.001857f, 0.002014f, 0.002329f, 0.002535f, 0.002785f, 0.003027f, 0.003210f, 0.003580f, 0.003788f, 0.004025f, 0.004444f,
+ 0.004791f, 0.004974f, 0.005417f, 0.005909f, 0.006248f, 0.006672f, 0.007118f, 0.007664f, 0.008232f, 0.008759f, 0.009598f, 0.009964f,
+ 0.010956f, 0.011650f, 0.012665f, 0.013702f, 0.014832f, 0.016144f, 0.017654f, 0.019211f, 0.021118f, 0.023102f, 0.025681f, 0.028320f,
+ 0.031708f, 0.035370f, 0.039673f, 0.044739f, 0.050812f, 0.057800f, 0.065796f, 0.074768f, 0.085510f, 0.097961f, 0.112000f, 0.128662f,
+ 0.147217f, 0.168213f, 0.190796f, 0.216309f, 0.244751f, 0.274902f, 0.669922f, 0.698730f, 0.703613f, 0.705566f, 0.707031f, 0.707031f,
+ 0.000212f, 0.000458f, 0.000959f, 0.001192f, 0.001321f, 0.001500f, 0.001823f, 0.002064f, 0.002073f, 0.002293f, 0.002512f, 0.002768f,
+ 0.002981f, 0.003138f, 0.003431f, 0.003765f, 0.003918f, 0.004238f, 0.004482f, 0.004814f, 0.005245f, 0.005531f, 0.005871f, 0.006214f,
+ 0.006660f, 0.007236f, 0.007664f, 0.008331f, 0.008812f, 0.009628f, 0.010277f, 0.010979f, 0.012016f, 0.012978f, 0.014084f, 0.015495f,
+ 0.016937f, 0.018494f, 0.020386f, 0.022659f, 0.025208f, 0.028183f, 0.031860f, 0.036072f, 0.040894f, 0.046326f, 0.053009f, 0.061127f,
+ 0.070374f, 0.081238f, 0.094238f, 0.109314f, 0.126343f, 0.145874f, 0.167847f, 0.192505f, 0.219604f, 0.249634f, 0.656738f, 0.686035f,
+ 0.690430f, 0.694336f, 0.694336f, 0.696777f, 0.000151f, 0.000529f, 0.000692f, 0.000883f, 0.001153f, 0.001337f, 0.001380f, 0.001520f,
+ 0.001753f, 0.001886f, 0.002077f, 0.002243f, 0.002386f, 0.002556f, 0.002832f, 0.003029f, 0.003277f, 0.003447f, 0.003683f, 0.003952f,
+ 0.004135f, 0.004578f, 0.004833f, 0.005222f, 0.005417f, 0.005810f, 0.006355f, 0.006718f, 0.007076f, 0.007652f, 0.008293f, 0.008980f,
+ 0.009674f, 0.010422f, 0.011276f, 0.012283f, 0.013443f, 0.014664f, 0.016113f, 0.017853f, 0.019897f, 0.022156f, 0.024826f, 0.028275f,
+ 0.032135f, 0.036865f, 0.042389f, 0.049011f, 0.056732f, 0.066223f, 0.077576f, 0.090820f, 0.106384f, 0.124512f, 0.145264f, 0.169067f,
+ 0.195190f, 0.224976f, 0.642578f, 0.671387f, 0.679688f, 0.682617f, 0.682617f, 0.683594f, 0.000127f, 0.000376f, 0.000600f, 0.000721f,
+ 0.000901f, 0.001066f, 0.001180f, 0.001332f, 0.001455f, 0.001549f, 0.001709f, 0.001831f, 0.001947f, 0.002150f, 0.002245f, 0.002443f,
+ 0.002682f, 0.002844f, 0.002989f, 0.003201f, 0.003403f, 0.003683f, 0.003883f, 0.004097f, 0.004372f, 0.004665f, 0.004963f, 0.005348f,
+ 0.005711f, 0.006165f, 0.006672f, 0.007004f, 0.007610f, 0.008278f, 0.008873f, 0.009636f, 0.010475f, 0.011475f, 0.012634f, 0.014053f,
+ 0.015404f, 0.017242f, 0.019104f, 0.021774f, 0.024750f, 0.028458f, 0.032745f, 0.038391f, 0.044861f, 0.052795f, 0.062103f, 0.073914f,
+ 0.087830f, 0.104553f, 0.123718f, 0.145996f, 0.171509f, 0.200439f, 0.627930f, 0.658691f, 0.666504f, 0.668945f, 0.671387f, 0.671387f,
+ 0.000013f, 0.000374f, 0.000443f, 0.000688f, 0.000819f, 0.000844f, 0.001004f, 0.001132f, 0.001216f, 0.001259f, 0.001405f, 0.001523f,
+ 0.001566f, 0.001753f, 0.001842f, 0.001997f, 0.002022f, 0.002287f, 0.002377f, 0.002541f, 0.002787f, 0.002878f, 0.003096f, 0.003283f,
+ 0.003551f, 0.003651f, 0.003971f, 0.004272f, 0.004524f, 0.004887f, 0.005196f, 0.005527f, 0.005939f, 0.006386f, 0.006977f, 0.007526f,
+ 0.008148f, 0.008835f, 0.009689f, 0.010689f, 0.011810f, 0.013000f, 0.014641f, 0.016388f, 0.018799f, 0.021469f, 0.024734f, 0.029022f,
+ 0.034210f, 0.040588f, 0.048401f, 0.058319f, 0.070435f, 0.085205f, 0.102905f, 0.123901f, 0.147827f, 0.175903f, 0.612793f, 0.645508f,
+ 0.653320f, 0.656250f, 0.657227f, 0.657227f, 0.000113f, 0.000234f, 0.000465f, 0.000547f, 0.000646f, 0.000684f, 0.000711f, 0.000832f,
+ 0.000963f, 0.000999f, 0.001042f, 0.001183f, 0.001279f, 0.001402f, 0.001494f, 0.001513f, 0.001688f, 0.001716f, 0.001919f, 0.001993f,
+ 0.002081f, 0.002253f, 0.002441f, 0.002575f, 0.002714f, 0.002876f, 0.003050f, 0.003214f, 0.003531f, 0.003714f, 0.003956f, 0.004276f,
+ 0.004604f, 0.004967f, 0.005386f, 0.005718f, 0.006283f, 0.006790f, 0.007290f, 0.008133f, 0.008957f, 0.009987f, 0.010956f, 0.012375f,
+ 0.013916f, 0.015991f, 0.018311f, 0.021347f, 0.025253f, 0.030289f, 0.036560f, 0.044586f, 0.054779f, 0.067749f, 0.083252f, 0.102722f,
+ 0.125732f, 0.152100f, 0.597168f, 0.631836f, 0.639160f, 0.643555f, 0.643066f, 0.645508f, 0.000207f, 0.000175f, 0.000364f, 0.000507f,
+ 0.000496f, 0.000569f, 0.000683f, 0.000584f, 0.000737f, 0.000764f, 0.000885f, 0.000964f, 0.000999f, 0.001076f, 0.001085f, 0.001272f,
+ 0.001327f, 0.001354f, 0.001491f, 0.001494f, 0.001677f, 0.001781f, 0.001862f, 0.001976f, 0.002079f, 0.002190f, 0.002338f, 0.002481f,
+ 0.002691f, 0.002811f, 0.003117f, 0.003214f, 0.003422f, 0.003706f, 0.003990f, 0.004314f, 0.004608f, 0.004982f, 0.005379f, 0.006027f,
+ 0.006580f, 0.007351f, 0.008049f, 0.009041f, 0.010323f, 0.011551f, 0.013428f, 0.015419f, 0.018219f, 0.021713f, 0.026550f, 0.032715f,
+ 0.040833f, 0.051605f, 0.065552f, 0.082458f, 0.104004f, 0.129395f, 0.582031f, 0.618652f, 0.625488f, 0.627930f, 0.630859f, 0.631348f,
+ 0.000189f, 0.000160f, 0.000272f, 0.000387f, 0.000335f, 0.000486f, 0.000424f, 0.000469f, 0.000551f, 0.000589f, 0.000700f, 0.000727f,
+ 0.000772f, 0.000859f, 0.000891f, 0.000872f, 0.001000f, 0.001048f, 0.001076f, 0.001172f, 0.001224f, 0.001311f, 0.001376f, 0.001450f,
+ 0.001554f, 0.001591f, 0.001760f, 0.001838f, 0.001999f, 0.002180f, 0.002333f, 0.002388f, 0.002584f, 0.002777f, 0.002907f, 0.003162f,
+ 0.003368f, 0.003677f, 0.003979f, 0.004303f, 0.004715f, 0.005188f, 0.005787f, 0.006378f, 0.007313f, 0.008194f, 0.009407f, 0.010887f,
+ 0.012779f, 0.015198f, 0.018494f, 0.022888f, 0.029037f, 0.037659f, 0.048920f, 0.064270f, 0.083740f, 0.107300f, 0.565918f, 0.603516f,
+ 0.611328f, 0.614746f, 0.617188f, 0.618164f, 0.000000f, 0.000170f, 0.000207f, 0.000274f, 0.000292f, 0.000309f, 0.000381f, 0.000326f,
+ 0.000418f, 0.000439f, 0.000519f, 0.000519f, 0.000560f, 0.000574f, 0.000652f, 0.000678f, 0.000717f, 0.000756f, 0.000782f, 0.000820f,
+ 0.000893f, 0.000937f, 0.000991f, 0.001063f, 0.001112f, 0.001174f, 0.001284f, 0.001302f, 0.001408f, 0.001460f, 0.001586f, 0.001711f,
+ 0.001826f, 0.001959f, 0.002058f, 0.002207f, 0.002388f, 0.002565f, 0.002836f, 0.003046f, 0.003284f, 0.003567f, 0.004009f, 0.004463f,
+ 0.005001f, 0.005661f, 0.006451f, 0.007473f, 0.008751f, 0.010368f, 0.012611f, 0.015587f, 0.019730f, 0.025787f, 0.034729f, 0.047272f,
+ 0.064392f, 0.087097f, 0.550293f, 0.587891f, 0.596680f, 0.600586f, 0.602539f, 0.603516f, 0.000000f, 0.000057f, 0.000175f, 0.000210f,
+ 0.000221f, 0.000261f, 0.000224f, 0.000285f, 0.000296f, 0.000329f, 0.000374f, 0.000329f, 0.000344f, 0.000416f, 0.000421f, 0.000479f,
+ 0.000455f, 0.000530f, 0.000552f, 0.000598f, 0.000640f, 0.000670f, 0.000695f, 0.000740f, 0.000798f, 0.000806f, 0.000883f, 0.000908f,
+ 0.000983f, 0.001094f, 0.001083f, 0.001169f, 0.001242f, 0.001340f, 0.001440f, 0.001536f, 0.001601f, 0.001752f, 0.001893f, 0.002029f,
+ 0.002218f, 0.002424f, 0.002651f, 0.002934f, 0.003294f, 0.003681f, 0.004200f, 0.004833f, 0.005688f, 0.006863f, 0.008202f, 0.010178f,
+ 0.012955f, 0.016846f, 0.023163f, 0.032745f, 0.047150f, 0.067383f, 0.534180f, 0.574219f, 0.582031f, 0.584961f, 0.586914f, 0.589844f,
+ 0.000000f, 0.000105f, 0.000145f, 0.000101f, 0.000161f, 0.000163f, 0.000165f, 0.000193f, 0.000190f, 0.000202f, 0.000205f, 0.000260f,
+ 0.000251f, 0.000281f, 0.000305f, 0.000316f, 0.000323f, 0.000346f, 0.000364f, 0.000383f, 0.000413f, 0.000436f, 0.000461f, 0.000486f,
+ 0.000515f, 0.000564f, 0.000594f, 0.000616f, 0.000639f, 0.000677f, 0.000729f, 0.000748f, 0.000842f, 0.000861f, 0.000943f, 0.000970f,
+ 0.001054f, 0.001120f, 0.001219f, 0.001310f, 0.001398f, 0.001534f, 0.001709f, 0.001852f, 0.002096f, 0.002291f, 0.002594f, 0.002987f,
+ 0.003481f, 0.004128f, 0.004997f, 0.006218f, 0.007950f, 0.010445f, 0.014313f, 0.020874f, 0.032166f, 0.049866f, 0.517578f, 0.558105f,
+ 0.567383f, 0.570801f, 0.573730f, 0.574707f, 0.000000f, 0.000097f, 0.000089f, 0.000082f, 0.000092f, 0.000096f, 0.000092f, 0.000118f,
+ 0.000126f, 0.000130f, 0.000138f, 0.000138f, 0.000143f, 0.000163f, 0.000181f, 0.000187f, 0.000195f, 0.000228f, 0.000221f, 0.000261f,
+ 0.000243f, 0.000254f, 0.000274f, 0.000299f, 0.000334f, 0.000332f, 0.000345f, 0.000362f, 0.000394f, 0.000410f, 0.000433f, 0.000463f,
+ 0.000497f, 0.000510f, 0.000562f, 0.000594f, 0.000636f, 0.000670f, 0.000731f, 0.000777f, 0.000832f, 0.000927f, 0.000991f, 0.001101f,
+ 0.001210f, 0.001350f, 0.001513f, 0.001720f, 0.001999f, 0.002373f, 0.002815f, 0.003498f, 0.004478f, 0.006001f, 0.008347f, 0.012299f,
+ 0.019669f, 0.034210f, 0.501465f, 0.542969f, 0.552246f, 0.556641f, 0.559082f, 0.559570f, 0.000107f, 0.000087f, 0.000077f, 0.000070f,
+ 0.000065f, 0.000066f, 0.000059f, 0.000064f, 0.000065f, 0.000071f, 0.000070f, 0.000095f, 0.000081f, 0.000085f, 0.000110f, 0.000097f,
+ 0.000117f, 0.000126f, 0.000127f, 0.000133f, 0.000132f, 0.000141f, 0.000169f, 0.000173f, 0.000185f, 0.000183f, 0.000192f, 0.000215f,
+ 0.000216f, 0.000235f, 0.000236f, 0.000265f, 0.000278f, 0.000290f, 0.000313f, 0.000317f, 0.000347f, 0.000365f, 0.000400f, 0.000422f,
+ 0.000457f, 0.000494f, 0.000535f, 0.000586f, 0.000639f, 0.000700f, 0.000786f, 0.000888f, 0.001019f, 0.001207f, 0.001435f, 0.001746f,
+ 0.002258f, 0.003019f, 0.004299f, 0.006523f, 0.010612f, 0.020859f, 0.484619f, 0.527344f, 0.536621f, 0.541504f, 0.542969f, 0.544922f,
+ 0.000092f, 0.000070f, 0.000062f, 0.000056f, 0.000051f, 0.000048f, 0.000045f, 0.000044f, 0.000041f, 0.000039f, 0.000038f, 0.000037f,
+ 0.000047f, 0.000039f, 0.000041f, 0.000041f, 0.000058f, 0.000053f, 0.000062f, 0.000064f, 0.000068f, 0.000072f, 0.000076f, 0.000076f,
+ 0.000078f, 0.000092f, 0.000085f, 0.000101f, 0.000104f, 0.000110f, 0.000115f, 0.000118f, 0.000127f, 0.000133f, 0.000152f, 0.000150f,
+ 0.000163f, 0.000190f, 0.000190f, 0.000202f, 0.000213f, 0.000225f, 0.000249f, 0.000268f, 0.000296f, 0.000321f, 0.000354f, 0.000402f,
+ 0.000458f, 0.000520f, 0.000618f, 0.000744f, 0.000950f, 0.001263f, 0.001822f, 0.002865f, 0.005028f, 0.010544f, 0.468018f, 0.511230f,
+ 0.521484f, 0.524902f, 0.529297f, 0.529785f, 0.000067f, 0.000049f, 0.000041f, 0.000037f, 0.000034f, 0.000032f, 0.000031f, 0.000029f,
+ 0.000028f, 0.000027f, 0.000027f, 0.000026f, 0.000025f, 0.000023f, 0.000022f, 0.000021f, 0.000020f, 0.000020f, 0.000023f, 0.000024f,
+ 0.000021f, 0.000022f, 0.000025f, 0.000029f, 0.000030f, 0.000034f, 0.000036f, 0.000034f, 0.000039f, 0.000038f, 0.000045f, 0.000045f,
+ 0.000048f, 0.000051f, 0.000053f, 0.000055f, 0.000063f, 0.000070f, 0.000073f, 0.000073f, 0.000080f, 0.000084f, 0.000089f, 0.000102f,
+ 0.000107f, 0.000115f, 0.000128f, 0.000145f, 0.000156f, 0.000178f, 0.000213f, 0.000253f, 0.000311f, 0.000400f, 0.000572f, 0.000916f,
+ 0.001751f, 0.004158f, 0.450439f, 0.496338f, 0.505859f, 0.510742f, 0.513184f, 0.514648f, 0.000016f, 0.000013f, 0.000011f, 0.000010f,
+ 0.000012f, 0.000012f, 0.000011f, 0.000012f, 0.000011f, 0.000012f, 0.000011f, 0.000012f, 0.000012f, 0.000011f, 0.000011f, 0.000011f,
+ 0.000011f, 0.000011f, 0.000011f, 0.000011f, 0.000010f, 0.000010f, 0.000010f, 0.000009f, 0.000009f, 0.000009f, 0.000008f, 0.000008f,
+ 0.000008f, 0.000009f, 0.000009f, 0.000009f, 0.000009f, 0.000011f, 0.000012f, 0.000012f, 0.000015f, 0.000014f, 0.000014f, 0.000017f,
+ 0.000018f, 0.000020f, 0.000020f, 0.000022f, 0.000026f, 0.000027f, 0.000028f, 0.000027f, 0.000033f, 0.000036f, 0.000044f, 0.000051f,
+ 0.000057f, 0.000078f, 0.000103f, 0.000159f, 0.000315f, 0.000997f, 0.433350f, 0.479980f, 0.490234f, 0.495605f, 0.498291f, 0.499512f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000002f, 0.000002f,
+ 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f,
+ 0.000001f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000003f, 0.000004f, 0.000004f, 0.000007f, 0.000025f, 0.416016f, 0.464111f,
+ 0.474854f, 0.479248f, 0.481934f, 0.484375f,
+ },
+ {
+ 0.023209f, 0.069336f, 0.113037f, 0.154663f, 0.193726f, 0.231812f, 0.267578f, 0.301758f, 0.333740f, 0.364258f, 0.393555f, 0.421631f,
+ 0.447510f, 0.473145f, 0.497070f, 0.520020f, 0.541992f, 0.562988f, 0.583008f, 0.602539f, 0.620605f, 0.638184f, 0.655762f, 0.671387f,
+ 0.687500f, 0.702637f, 0.716309f, 0.729980f, 0.744141f, 0.757812f, 0.769531f, 0.782227f, 0.793945f, 0.804688f, 0.815918f, 0.826172f,
+ 0.836426f, 0.846191f, 0.855957f, 0.865234f, 0.874023f, 0.882812f, 0.891113f, 0.898926f, 0.907227f, 0.915039f, 0.922852f, 0.929688f,
+ 0.937012f, 0.943848f, 0.950684f, 0.956543f, 0.963379f, 0.969238f, 0.976074f, 0.981445f, 0.986816f, 0.992676f, 0.991211f, 0.978516f,
+ 0.968750f, 0.960449f, 0.952637f, 0.945312f, 0.019730f, 0.059631f, 0.098206f, 0.135864f, 0.172119f, 0.206421f, 0.239624f, 0.272461f,
+ 0.304932f, 0.333984f, 0.362549f, 0.389648f, 0.416016f, 0.441406f, 0.466309f, 0.489502f, 0.511230f, 0.533203f, 0.554199f, 0.573242f,
+ 0.593262f, 0.611816f, 0.629395f, 0.645508f, 0.662598f, 0.678711f, 0.693359f, 0.708496f, 0.722168f, 0.735840f, 0.750000f, 0.762207f,
+ 0.773926f, 0.786133f, 0.796875f, 0.808594f, 0.818848f, 0.829590f, 0.839355f, 0.850098f, 0.859863f, 0.868652f, 0.877441f, 0.886230f,
+ 0.895020f, 0.903809f, 0.911133f, 0.918457f, 0.925781f, 0.933105f, 0.940430f, 0.946777f, 0.954590f, 0.960938f, 0.966797f, 0.973145f,
+ 0.979004f, 0.984863f, 0.987793f, 0.976074f, 0.966797f, 0.958496f, 0.951172f, 0.943848f, 0.017151f, 0.051636f, 0.085510f, 0.119202f,
+ 0.152466f, 0.184814f, 0.216187f, 0.246582f, 0.276855f, 0.305664f, 0.332764f, 0.360107f, 0.385986f, 0.411621f, 0.435791f, 0.459473f,
+ 0.481445f, 0.502441f, 0.524414f, 0.546387f, 0.565430f, 0.583496f, 0.602051f, 0.619629f, 0.636719f, 0.653320f, 0.669434f, 0.684082f,
+ 0.699707f, 0.713867f, 0.728027f, 0.741211f, 0.754883f, 0.767090f, 0.779297f, 0.791016f, 0.802734f, 0.813965f, 0.824219f, 0.833984f,
+ 0.843750f, 0.854492f, 0.863281f, 0.873535f, 0.882324f, 0.890137f, 0.898926f, 0.906738f, 0.915039f, 0.922852f, 0.930176f, 0.937012f,
+ 0.944336f, 0.951172f, 0.958008f, 0.964844f, 0.970703f, 0.977051f, 0.983887f, 0.972656f, 0.964355f, 0.956543f, 0.949219f, 0.942383f,
+ 0.014885f, 0.044678f, 0.075195f, 0.104919f, 0.135254f, 0.165649f, 0.194702f, 0.223633f, 0.251221f, 0.279053f, 0.305420f, 0.331543f,
+ 0.357422f, 0.382568f, 0.406982f, 0.430420f, 0.453369f, 0.475586f, 0.496582f, 0.517090f, 0.536133f, 0.556641f, 0.575684f, 0.592773f,
+ 0.611328f, 0.628418f, 0.643555f, 0.661621f, 0.676270f, 0.691406f, 0.705566f, 0.720215f, 0.733887f, 0.746582f, 0.759766f, 0.772949f,
+ 0.784668f, 0.795898f, 0.807129f, 0.818359f, 0.828125f, 0.838867f, 0.848633f, 0.858887f, 0.867676f, 0.877441f, 0.886230f, 0.894531f,
+ 0.903320f, 0.911621f, 0.919434f, 0.927734f, 0.934570f, 0.940918f, 0.948730f, 0.956543f, 0.962402f, 0.969238f, 0.979980f, 0.970215f,
+ 0.961914f, 0.954102f, 0.947266f, 0.940918f, 0.013046f, 0.038940f, 0.066162f, 0.093323f, 0.120544f, 0.147583f, 0.174683f, 0.201538f,
+ 0.228516f, 0.254639f, 0.280518f, 0.304932f, 0.330566f, 0.354492f, 0.379395f, 0.402100f, 0.424561f, 0.446533f, 0.467529f, 0.488525f,
+ 0.509277f, 0.529297f, 0.547852f, 0.566895f, 0.585449f, 0.602539f, 0.620605f, 0.636230f, 0.653809f, 0.667480f, 0.684570f, 0.698242f,
+ 0.712891f, 0.726562f, 0.739746f, 0.753418f, 0.765625f, 0.777344f, 0.789551f, 0.801270f, 0.812500f, 0.823730f, 0.833984f, 0.844238f,
+ 0.854004f, 0.863770f, 0.874023f, 0.882324f, 0.891113f, 0.899902f, 0.908203f, 0.916504f, 0.924805f, 0.932129f, 0.939453f, 0.947266f,
+ 0.954102f, 0.960938f, 0.976562f, 0.967285f, 0.958984f, 0.951660f, 0.944824f, 0.938965f, 0.011696f, 0.034698f, 0.058807f, 0.083130f,
+ 0.107727f, 0.132324f, 0.156982f, 0.182251f, 0.207153f, 0.232178f, 0.256836f, 0.280762f, 0.304688f, 0.328369f, 0.352295f, 0.375244f,
+ 0.397461f, 0.419434f, 0.440430f, 0.461914f, 0.482178f, 0.501953f, 0.522461f, 0.540527f, 0.559570f, 0.577148f, 0.595703f, 0.613281f,
+ 0.628418f, 0.644531f, 0.661621f, 0.676270f, 0.691406f, 0.705078f, 0.719727f, 0.733887f, 0.746094f, 0.759766f, 0.771973f, 0.784180f,
+ 0.795898f, 0.807617f, 0.818359f, 0.829102f, 0.839844f, 0.850098f, 0.859375f, 0.869629f, 0.878906f, 0.887695f, 0.896484f, 0.905273f,
+ 0.914062f, 0.921875f, 0.929688f, 0.937988f, 0.944824f, 0.952637f, 0.973145f, 0.963379f, 0.956055f, 0.949219f, 0.942871f, 0.937012f,
+ 0.010094f, 0.030975f, 0.052063f, 0.073975f, 0.096069f, 0.118713f, 0.141479f, 0.164551f, 0.187866f, 0.211182f, 0.234985f, 0.258057f,
+ 0.280518f, 0.303467f, 0.326172f, 0.348145f, 0.370117f, 0.392822f, 0.413574f, 0.434814f, 0.455322f, 0.476074f, 0.495361f, 0.515137f,
+ 0.533203f, 0.551758f, 0.569824f, 0.586426f, 0.604492f, 0.621582f, 0.637695f, 0.654297f, 0.668945f, 0.683594f, 0.699219f, 0.712402f,
+ 0.728516f, 0.741699f, 0.753906f, 0.767090f, 0.778320f, 0.790527f, 0.802246f, 0.813965f, 0.824219f, 0.835449f, 0.846680f, 0.855957f,
+ 0.865723f, 0.875488f, 0.884766f, 0.894043f, 0.902832f, 0.911133f, 0.919434f, 0.927734f, 0.935547f, 0.943359f, 0.968750f, 0.960449f,
+ 0.953125f, 0.946289f, 0.940430f, 0.934570f, 0.008797f, 0.027466f, 0.045959f, 0.066223f, 0.086304f, 0.106506f, 0.127441f, 0.149170f,
+ 0.170532f, 0.192261f, 0.213867f, 0.236206f, 0.258057f, 0.280273f, 0.301758f, 0.323486f, 0.344727f, 0.367188f, 0.388184f, 0.408447f,
+ 0.429443f, 0.450439f, 0.469727f, 0.489014f, 0.508301f, 0.526855f, 0.545410f, 0.562500f, 0.581055f, 0.597656f, 0.613770f, 0.630859f,
+ 0.647461f, 0.663574f, 0.677734f, 0.693359f, 0.707031f, 0.720703f, 0.735352f, 0.748047f, 0.760254f, 0.772461f, 0.785156f, 0.797363f,
+ 0.810059f, 0.819824f, 0.831543f, 0.842285f, 0.852051f, 0.862793f, 0.873047f, 0.882324f, 0.891113f, 0.899902f, 0.909180f, 0.917969f,
+ 0.925781f, 0.934082f, 0.964355f, 0.957031f, 0.949707f, 0.943359f, 0.937988f, 0.932129f, 0.007927f, 0.024414f, 0.041077f, 0.059204f,
+ 0.077148f, 0.095581f, 0.115479f, 0.134644f, 0.154785f, 0.175293f, 0.196045f, 0.216553f, 0.236694f, 0.258057f, 0.278809f, 0.300049f,
+ 0.321289f, 0.342529f, 0.363281f, 0.383545f, 0.403564f, 0.424072f, 0.444092f, 0.463135f, 0.483154f, 0.501953f, 0.519531f, 0.539062f,
+ 0.555664f, 0.574707f, 0.591309f, 0.608398f, 0.624512f, 0.640137f, 0.655762f, 0.671875f, 0.686523f, 0.701172f, 0.715820f, 0.729004f,
+ 0.742676f, 0.755859f, 0.769043f, 0.781738f, 0.792969f, 0.805176f, 0.816895f, 0.827637f, 0.838867f, 0.849121f, 0.859375f, 0.870117f,
+ 0.879395f, 0.889160f, 0.898926f, 0.906738f, 0.916504f, 0.924805f, 0.960938f, 0.953125f, 0.947266f, 0.940430f, 0.935547f, 0.929688f,
+ 0.007080f, 0.022247f, 0.037445f, 0.053070f, 0.069336f, 0.086975f, 0.103577f, 0.121948f, 0.140503f, 0.158936f, 0.178833f, 0.198242f,
+ 0.217651f, 0.237793f, 0.257812f, 0.278076f, 0.297607f, 0.318604f, 0.338623f, 0.358643f, 0.378662f, 0.399170f, 0.418213f, 0.438721f,
+ 0.457520f, 0.477051f, 0.495361f, 0.513672f, 0.531250f, 0.549316f, 0.567383f, 0.583984f, 0.601562f, 0.617676f, 0.634277f, 0.650391f,
+ 0.666016f, 0.680176f, 0.695801f, 0.710449f, 0.723633f, 0.737305f, 0.750977f, 0.764648f, 0.776367f, 0.789551f, 0.802246f, 0.813477f,
+ 0.824219f, 0.835938f, 0.846680f, 0.857422f, 0.867188f, 0.876953f, 0.887207f, 0.895996f, 0.905762f, 0.915527f, 0.955566f, 0.949707f,
+ 0.943359f, 0.937988f, 0.932129f, 0.927246f, 0.006363f, 0.019516f, 0.033691f, 0.047577f, 0.062469f, 0.078186f, 0.093933f, 0.110657f,
+ 0.127563f, 0.144653f, 0.162598f, 0.181152f, 0.199707f, 0.218384f, 0.237427f, 0.257324f, 0.276367f, 0.295166f, 0.315674f, 0.335205f,
+ 0.355225f, 0.374756f, 0.393799f, 0.413574f, 0.432617f, 0.451904f, 0.470459f, 0.489258f, 0.508301f, 0.525879f, 0.543945f, 0.560059f,
+ 0.578613f, 0.595703f, 0.612793f, 0.628418f, 0.644531f, 0.659668f, 0.675293f, 0.689941f, 0.704590f, 0.719238f, 0.732910f, 0.747070f,
+ 0.759766f, 0.773438f, 0.785156f, 0.797852f, 0.809570f, 0.821289f, 0.833008f, 0.843750f, 0.854980f, 0.865723f, 0.875977f, 0.886230f,
+ 0.895508f, 0.904785f, 0.951660f, 0.945801f, 0.939941f, 0.934570f, 0.929199f, 0.924805f, 0.005985f, 0.017776f, 0.030212f, 0.043030f,
+ 0.056488f, 0.070190f, 0.085205f, 0.100342f, 0.115723f, 0.132446f, 0.148438f, 0.165771f, 0.183228f, 0.200684f, 0.218994f, 0.237183f,
+ 0.255859f, 0.274170f, 0.292725f, 0.313477f, 0.331299f, 0.351318f, 0.369873f, 0.389160f, 0.408936f, 0.426758f, 0.446533f, 0.464844f,
+ 0.483154f, 0.501465f, 0.519531f, 0.537598f, 0.555664f, 0.572754f, 0.589844f, 0.605957f, 0.622070f, 0.639648f, 0.654297f, 0.670898f,
+ 0.685059f, 0.700195f, 0.714844f, 0.728516f, 0.742188f, 0.754883f, 0.769043f, 0.781738f, 0.795410f, 0.808105f, 0.818359f, 0.830566f,
+ 0.841797f, 0.853027f, 0.863770f, 0.874023f, 0.884766f, 0.893555f, 0.947266f, 0.942383f, 0.936523f, 0.930664f, 0.926270f, 0.921387f,
+ 0.005173f, 0.016083f, 0.027359f, 0.038849f, 0.051056f, 0.063843f, 0.077026f, 0.091064f, 0.105591f, 0.120422f, 0.135498f, 0.150879f,
+ 0.167480f, 0.184326f, 0.201172f, 0.218384f, 0.236084f, 0.254395f, 0.272949f, 0.291260f, 0.309570f, 0.328125f, 0.346680f, 0.365967f,
+ 0.384766f, 0.403320f, 0.422119f, 0.440918f, 0.458984f, 0.477783f, 0.496094f, 0.513672f, 0.531738f, 0.548828f, 0.566406f, 0.583984f,
+ 0.600098f, 0.617188f, 0.632812f, 0.649902f, 0.665527f, 0.681152f, 0.694824f, 0.709473f, 0.724121f, 0.738770f, 0.752441f, 0.765137f,
+ 0.778809f, 0.791992f, 0.803711f, 0.815918f, 0.828125f, 0.839844f, 0.851562f, 0.862793f, 0.873535f, 0.883789f, 0.941895f, 0.938477f,
+ 0.933105f, 0.927246f, 0.922363f, 0.918457f, 0.004791f, 0.014610f, 0.024475f, 0.035126f, 0.046478f, 0.057922f, 0.069885f, 0.083008f,
+ 0.096069f, 0.109253f, 0.123840f, 0.137939f, 0.153076f, 0.168701f, 0.185059f, 0.200928f, 0.218262f, 0.234985f, 0.252686f, 0.270264f,
+ 0.288086f, 0.306396f, 0.324951f, 0.343018f, 0.362305f, 0.379883f, 0.398926f, 0.417236f, 0.435547f, 0.454346f, 0.472656f, 0.491211f,
+ 0.508301f, 0.526855f, 0.543457f, 0.561523f, 0.578125f, 0.595215f, 0.612305f, 0.628418f, 0.644043f, 0.660645f, 0.675781f, 0.691406f,
+ 0.706055f, 0.720215f, 0.735840f, 0.749023f, 0.762695f, 0.776855f, 0.789551f, 0.800781f, 0.814941f, 0.826172f, 0.838867f, 0.851074f,
+ 0.862305f, 0.872070f, 0.937500f, 0.933594f, 0.929199f, 0.923828f, 0.919434f, 0.915527f, 0.004387f, 0.013268f, 0.022385f, 0.031860f,
+ 0.041962f, 0.052612f, 0.063171f, 0.075073f, 0.086792f, 0.099854f, 0.113037f, 0.125977f, 0.140381f, 0.154663f, 0.169678f, 0.184814f,
+ 0.200562f, 0.217773f, 0.234131f, 0.250732f, 0.268066f, 0.284912f, 0.303223f, 0.321289f, 0.339355f, 0.357666f, 0.375488f, 0.394043f,
+ 0.411865f, 0.430664f, 0.448730f, 0.467041f, 0.485352f, 0.503418f, 0.520508f, 0.539062f, 0.556152f, 0.573242f, 0.590820f, 0.606934f,
+ 0.624512f, 0.640625f, 0.655762f, 0.672363f, 0.687500f, 0.702148f, 0.718750f, 0.731934f, 0.746582f, 0.759766f, 0.772949f, 0.787109f,
+ 0.800781f, 0.813477f, 0.825195f, 0.838379f, 0.850098f, 0.861816f, 0.932617f, 0.929688f, 0.925293f, 0.919922f, 0.915527f, 0.912109f,
+ 0.003941f, 0.011986f, 0.020630f, 0.029144f, 0.038544f, 0.048035f, 0.058075f, 0.068542f, 0.079590f, 0.090942f, 0.102661f, 0.115295f,
+ 0.128296f, 0.141602f, 0.155518f, 0.170654f, 0.185425f, 0.200684f, 0.216309f, 0.231812f, 0.249146f, 0.265137f, 0.282471f, 0.299072f,
+ 0.317139f, 0.334717f, 0.352783f, 0.371338f, 0.388916f, 0.406982f, 0.425537f, 0.443848f, 0.461914f, 0.479980f, 0.498291f, 0.515625f,
+ 0.533203f, 0.550293f, 0.568359f, 0.585449f, 0.603027f, 0.618652f, 0.635742f, 0.652344f, 0.668457f, 0.684082f, 0.699219f, 0.713867f,
+ 0.729004f, 0.743652f, 0.757812f, 0.771484f, 0.785645f, 0.798828f, 0.812012f, 0.824219f, 0.836914f, 0.850098f, 0.927246f, 0.925293f,
+ 0.920410f, 0.916504f, 0.912598f, 0.908203f, 0.003790f, 0.011009f, 0.018829f, 0.026779f, 0.035339f, 0.043762f, 0.053223f, 0.062408f,
+ 0.072693f, 0.082947f, 0.093689f, 0.105469f, 0.117554f, 0.130005f, 0.142822f, 0.156494f, 0.170166f, 0.184448f, 0.198975f, 0.213745f,
+ 0.230469f, 0.246460f, 0.262939f, 0.279541f, 0.296143f, 0.313721f, 0.331299f, 0.348633f, 0.367188f, 0.384521f, 0.402344f, 0.420410f,
+ 0.438965f, 0.457275f, 0.475830f, 0.493164f, 0.510742f, 0.528809f, 0.546387f, 0.564453f, 0.581055f, 0.598145f, 0.615234f, 0.631836f,
+ 0.647461f, 0.665527f, 0.680664f, 0.696289f, 0.711914f, 0.728027f, 0.741211f, 0.756836f, 0.770508f, 0.783691f, 0.798340f, 0.811523f,
+ 0.824219f, 0.837402f, 0.921387f, 0.920410f, 0.916504f, 0.913086f, 0.908691f, 0.904785f, 0.003479f, 0.009949f, 0.016937f, 0.024445f,
+ 0.031708f, 0.039948f, 0.048218f, 0.056793f, 0.066223f, 0.075928f, 0.085632f, 0.096313f, 0.107178f, 0.118958f, 0.130493f, 0.143311f,
+ 0.156494f, 0.170044f, 0.183960f, 0.197876f, 0.213501f, 0.228027f, 0.244019f, 0.260010f, 0.276611f, 0.293213f, 0.309814f, 0.327393f,
+ 0.344482f, 0.363037f, 0.379883f, 0.398438f, 0.416504f, 0.434082f, 0.451904f, 0.470215f, 0.488525f, 0.505859f, 0.523926f, 0.541504f,
+ 0.559570f, 0.577637f, 0.594238f, 0.611328f, 0.628418f, 0.645020f, 0.661133f, 0.677246f, 0.693848f, 0.709961f, 0.725586f, 0.739746f,
+ 0.755371f, 0.769531f, 0.783203f, 0.797852f, 0.810547f, 0.824707f, 0.916016f, 0.915527f, 0.912109f, 0.908691f, 0.904785f, 0.900879f,
+ 0.003014f, 0.008842f, 0.015640f, 0.022018f, 0.028885f, 0.036163f, 0.044250f, 0.051819f, 0.059967f, 0.069031f, 0.078247f, 0.088135f,
+ 0.098267f, 0.108337f, 0.119751f, 0.131470f, 0.143433f, 0.156006f, 0.169189f, 0.183105f, 0.196655f, 0.211304f, 0.226196f, 0.241211f,
+ 0.257080f, 0.273438f, 0.289307f, 0.306396f, 0.323975f, 0.340576f, 0.358398f, 0.375732f, 0.393799f, 0.411133f, 0.429688f, 0.447998f,
+ 0.466064f, 0.483887f, 0.501465f, 0.519531f, 0.537598f, 0.555664f, 0.573242f, 0.590820f, 0.607910f, 0.625000f, 0.642578f, 0.658203f,
+ 0.675293f, 0.691406f, 0.707520f, 0.724121f, 0.738770f, 0.753418f, 0.769531f, 0.783203f, 0.797363f, 0.811523f, 0.910156f, 0.910645f,
+ 0.907715f, 0.904785f, 0.900879f, 0.896973f, 0.002861f, 0.008591f, 0.014000f, 0.020203f, 0.026962f, 0.033203f, 0.040161f, 0.047485f,
+ 0.055237f, 0.062988f, 0.071594f, 0.080750f, 0.089905f, 0.099854f, 0.109741f, 0.120056f, 0.131592f, 0.143311f, 0.155640f, 0.167969f,
+ 0.181763f, 0.195190f, 0.209229f, 0.223877f, 0.238647f, 0.254150f, 0.269531f, 0.285889f, 0.302979f, 0.319824f, 0.336426f, 0.354004f,
+ 0.372070f, 0.389893f, 0.406982f, 0.424805f, 0.443359f, 0.461182f, 0.479492f, 0.498047f, 0.515625f, 0.533691f, 0.551270f, 0.569336f,
+ 0.587402f, 0.604492f, 0.622070f, 0.639160f, 0.656738f, 0.673828f, 0.689941f, 0.705566f, 0.722168f, 0.737793f, 0.753418f, 0.768066f,
+ 0.783203f, 0.798340f, 0.904297f, 0.905762f, 0.902832f, 0.899414f, 0.895996f, 0.893066f, 0.002535f, 0.007812f, 0.013252f, 0.018738f,
+ 0.024384f, 0.030548f, 0.036774f, 0.043427f, 0.050476f, 0.057556f, 0.065491f, 0.073425f, 0.082458f, 0.091370f, 0.100525f, 0.110413f,
+ 0.120605f, 0.131592f, 0.142822f, 0.154663f, 0.166870f, 0.180176f, 0.193237f, 0.207031f, 0.221191f, 0.236084f, 0.250732f, 0.266602f,
+ 0.282959f, 0.299072f, 0.315430f, 0.332520f, 0.350342f, 0.367676f, 0.385010f, 0.403076f, 0.421631f, 0.439209f, 0.457520f, 0.475342f,
+ 0.494141f, 0.512695f, 0.530273f, 0.547852f, 0.565918f, 0.584473f, 0.602051f, 0.619629f, 0.637207f, 0.655273f, 0.671387f, 0.688965f,
+ 0.706055f, 0.721191f, 0.737305f, 0.752930f, 0.769531f, 0.784668f, 0.898438f, 0.900879f, 0.897949f, 0.894531f, 0.891602f, 0.888672f,
+ 0.002411f, 0.007103f, 0.012161f, 0.017105f, 0.022385f, 0.027985f, 0.033203f, 0.039581f, 0.045532f, 0.052521f, 0.059814f, 0.067261f,
+ 0.074768f, 0.083313f, 0.092041f, 0.101013f, 0.110291f, 0.120361f, 0.130615f, 0.141724f, 0.153076f, 0.165283f, 0.177612f, 0.190918f,
+ 0.204346f, 0.218506f, 0.233154f, 0.247559f, 0.263428f, 0.279053f, 0.295166f, 0.312256f, 0.328857f, 0.345947f, 0.363281f, 0.381348f,
+ 0.398926f, 0.417236f, 0.435547f, 0.453369f, 0.471191f, 0.489502f, 0.508301f, 0.525879f, 0.545410f, 0.563477f, 0.581055f, 0.600098f,
+ 0.617676f, 0.635254f, 0.653809f, 0.670410f, 0.687500f, 0.705078f, 0.720703f, 0.736816f, 0.753418f, 0.769531f, 0.892090f, 0.895020f,
+ 0.892578f, 0.889648f, 0.887207f, 0.884277f, 0.002344f, 0.006565f, 0.011322f, 0.015686f, 0.020630f, 0.025574f, 0.030807f, 0.035980f,
+ 0.042084f, 0.048279f, 0.054352f, 0.061432f, 0.068848f, 0.076172f, 0.083618f, 0.092590f, 0.101135f, 0.109619f, 0.120178f, 0.130249f,
+ 0.140991f, 0.151978f, 0.163696f, 0.175781f, 0.188721f, 0.202026f, 0.215820f, 0.230103f, 0.244873f, 0.259766f, 0.275635f, 0.291504f,
+ 0.307617f, 0.324219f, 0.342041f, 0.358887f, 0.376709f, 0.394775f, 0.412354f, 0.431152f, 0.448975f, 0.468018f, 0.486328f, 0.504883f,
+ 0.523438f, 0.541992f, 0.560547f, 0.579102f, 0.597656f, 0.615234f, 0.633789f, 0.651855f, 0.669434f, 0.687500f, 0.704590f, 0.721680f,
+ 0.738770f, 0.755859f, 0.886719f, 0.889648f, 0.887695f, 0.884766f, 0.882812f, 0.879883f, 0.002003f, 0.006268f, 0.009987f, 0.014198f,
+ 0.018875f, 0.023605f, 0.028259f, 0.033203f, 0.038513f, 0.044495f, 0.049866f, 0.056152f, 0.062500f, 0.069458f, 0.076660f, 0.084473f,
+ 0.092163f, 0.100586f, 0.109741f, 0.119324f, 0.128662f, 0.139526f, 0.150146f, 0.161499f, 0.173706f, 0.185791f, 0.199341f, 0.212891f,
+ 0.227051f, 0.241455f, 0.256592f, 0.271729f, 0.288330f, 0.304199f, 0.321045f, 0.337891f, 0.355469f, 0.373291f, 0.391113f, 0.408936f,
+ 0.426758f, 0.446289f, 0.464600f, 0.483643f, 0.500977f, 0.520996f, 0.539551f, 0.558594f, 0.577148f, 0.595703f, 0.614746f, 0.632324f,
+ 0.650879f, 0.669434f, 0.687012f, 0.704590f, 0.722656f, 0.740234f, 0.880371f, 0.883301f, 0.881836f, 0.879883f, 0.877441f, 0.875000f,
+ 0.001739f, 0.005779f, 0.009598f, 0.013245f, 0.017334f, 0.021637f, 0.025955f, 0.030121f, 0.035217f, 0.040131f, 0.045990f, 0.051453f,
+ 0.056915f, 0.063354f, 0.070007f, 0.076965f, 0.084351f, 0.091980f, 0.100281f, 0.108826f, 0.117981f, 0.127441f, 0.137939f, 0.148315f,
+ 0.160034f, 0.171753f, 0.183594f, 0.196167f, 0.209961f, 0.223511f, 0.238037f, 0.252930f, 0.268066f, 0.284180f, 0.300537f, 0.317139f,
+ 0.333740f, 0.351074f, 0.368896f, 0.386719f, 0.405273f, 0.423584f, 0.442871f, 0.460938f, 0.479736f, 0.499512f, 0.517578f, 0.537109f,
+ 0.555664f, 0.575195f, 0.594238f, 0.613770f, 0.632324f, 0.650879f, 0.669922f, 0.687988f, 0.706055f, 0.724121f, 0.873047f, 0.876953f,
+ 0.875488f, 0.874023f, 0.872559f, 0.869141f, 0.001648f, 0.005039f, 0.008675f, 0.012161f, 0.015823f, 0.019760f, 0.023865f, 0.028015f,
+ 0.032318f, 0.036865f, 0.041504f, 0.046906f, 0.051758f, 0.057922f, 0.064087f, 0.070435f, 0.077209f, 0.084290f, 0.091736f, 0.099243f,
+ 0.108215f, 0.117004f, 0.126343f, 0.135620f, 0.146484f, 0.157349f, 0.168823f, 0.180908f, 0.193848f, 0.206909f, 0.220459f, 0.234619f,
+ 0.249634f, 0.264404f, 0.280273f, 0.296631f, 0.313232f, 0.329834f, 0.347412f, 0.365479f, 0.383545f, 0.401855f, 0.420166f, 0.438721f,
+ 0.458252f, 0.477783f, 0.496826f, 0.516602f, 0.535156f, 0.554199f, 0.574219f, 0.593750f, 0.612305f, 0.631836f, 0.651367f, 0.670410f,
+ 0.689453f, 0.708984f, 0.865234f, 0.872070f, 0.870605f, 0.868652f, 0.866699f, 0.863770f, 0.001492f, 0.004704f, 0.007973f, 0.011124f,
+ 0.014603f, 0.017792f, 0.021652f, 0.025314f, 0.029526f, 0.033722f, 0.038147f, 0.042694f, 0.047668f, 0.052673f, 0.057983f, 0.064209f,
+ 0.070068f, 0.076233f, 0.083313f, 0.090942f, 0.098572f, 0.106750f, 0.115295f, 0.124512f, 0.134277f, 0.144287f, 0.154663f, 0.166504f,
+ 0.178345f, 0.190063f, 0.203247f, 0.217041f, 0.231079f, 0.245850f, 0.260986f, 0.276611f, 0.293213f, 0.309570f, 0.326172f, 0.343994f,
+ 0.361816f, 0.379395f, 0.397949f, 0.417480f, 0.436523f, 0.455322f, 0.474854f, 0.493896f, 0.514160f, 0.533691f, 0.553711f, 0.573730f,
+ 0.593262f, 0.612793f, 0.632812f, 0.651855f, 0.672363f, 0.690918f, 0.857910f, 0.865723f, 0.864746f, 0.863281f, 0.860352f, 0.858887f,
+ 0.001657f, 0.004684f, 0.007290f, 0.010201f, 0.013657f, 0.016541f, 0.019989f, 0.023636f, 0.026932f, 0.030548f, 0.034576f, 0.039154f,
+ 0.043793f, 0.048126f, 0.053162f, 0.058319f, 0.063721f, 0.069885f, 0.076355f, 0.082947f, 0.089844f, 0.097046f, 0.105286f, 0.113281f,
+ 0.122559f, 0.131348f, 0.141357f, 0.152100f, 0.163330f, 0.175415f, 0.187256f, 0.199951f, 0.213501f, 0.227051f, 0.241943f, 0.257324f,
+ 0.273193f, 0.288818f, 0.305420f, 0.322754f, 0.340576f, 0.358643f, 0.375732f, 0.394775f, 0.414307f, 0.433105f, 0.453613f, 0.472168f,
+ 0.492188f, 0.512695f, 0.532715f, 0.552246f, 0.573242f, 0.593262f, 0.613770f, 0.632812f, 0.654785f, 0.673828f, 0.851074f, 0.859375f,
+ 0.858398f, 0.856934f, 0.855469f, 0.853027f, 0.001457f, 0.003944f, 0.006870f, 0.009392f, 0.012543f, 0.015190f, 0.018417f, 0.021576f,
+ 0.024811f, 0.028122f, 0.031708f, 0.035278f, 0.039398f, 0.043793f, 0.048218f, 0.052887f, 0.058044f, 0.063477f, 0.069397f, 0.075256f,
+ 0.081360f, 0.088318f, 0.095398f, 0.103210f, 0.111084f, 0.120361f, 0.129150f, 0.139038f, 0.149292f, 0.160645f, 0.172241f, 0.183716f,
+ 0.196533f, 0.209595f, 0.224121f, 0.238647f, 0.253174f, 0.268799f, 0.286133f, 0.302490f, 0.319092f, 0.337158f, 0.355225f, 0.373535f,
+ 0.392090f, 0.411133f, 0.430908f, 0.450928f, 0.470947f, 0.490967f, 0.511719f, 0.531250f, 0.551758f, 0.573730f, 0.594238f, 0.614746f,
+ 0.636230f, 0.656738f, 0.842773f, 0.852051f, 0.851562f, 0.851074f, 0.848633f, 0.846680f, 0.001404f, 0.003891f, 0.006233f, 0.008751f,
+ 0.011353f, 0.014175f, 0.017075f, 0.019592f, 0.022842f, 0.025772f, 0.028839f, 0.032410f, 0.036011f, 0.039764f, 0.043671f, 0.048126f,
+ 0.052704f, 0.057373f, 0.062561f, 0.067688f, 0.074158f, 0.080200f, 0.086853f, 0.093445f, 0.101379f, 0.109192f, 0.117432f, 0.126709f,
+ 0.136353f, 0.146484f, 0.157227f, 0.168823f, 0.180542f, 0.193115f, 0.206299f, 0.219727f, 0.234375f, 0.249756f, 0.265869f, 0.281738f,
+ 0.298096f, 0.315674f, 0.333252f, 0.352051f, 0.370850f, 0.389160f, 0.409180f, 0.428955f, 0.448730f, 0.469971f, 0.489502f, 0.510742f,
+ 0.531738f, 0.552246f, 0.574707f, 0.595215f, 0.617676f, 0.639160f, 0.835449f, 0.845215f, 0.845215f, 0.844238f, 0.843262f, 0.840332f,
+ 0.001275f, 0.003536f, 0.005600f, 0.007881f, 0.010628f, 0.012878f, 0.015610f, 0.018097f, 0.020996f, 0.023376f, 0.026443f, 0.029556f,
+ 0.032867f, 0.036163f, 0.039581f, 0.043915f, 0.047943f, 0.052216f, 0.056763f, 0.061981f, 0.067322f, 0.072449f, 0.078796f, 0.084717f,
+ 0.091919f, 0.098999f, 0.106995f, 0.115417f, 0.124084f, 0.133667f, 0.143433f, 0.154297f, 0.165161f, 0.177124f, 0.189697f, 0.202759f,
+ 0.216309f, 0.230713f, 0.245728f, 0.261719f, 0.278320f, 0.295410f, 0.312256f, 0.330566f, 0.349365f, 0.367676f, 0.386719f, 0.406494f,
+ 0.427246f, 0.447266f, 0.468506f, 0.489746f, 0.510742f, 0.532227f, 0.553711f, 0.575684f, 0.597656f, 0.619141f, 0.826172f, 0.837402f,
+ 0.837891f, 0.837402f, 0.835449f, 0.833984f, 0.001134f, 0.003105f, 0.005337f, 0.007462f, 0.009628f, 0.011833f, 0.014137f, 0.016113f,
+ 0.018875f, 0.021484f, 0.024063f, 0.026581f, 0.029709f, 0.032623f, 0.036194f, 0.039703f, 0.043335f, 0.047058f, 0.051422f, 0.055908f,
+ 0.060608f, 0.065491f, 0.071167f, 0.076843f, 0.083313f, 0.089661f, 0.097168f, 0.104492f, 0.112122f, 0.121155f, 0.130615f, 0.140137f,
+ 0.150757f, 0.161499f, 0.173462f, 0.185547f, 0.199341f, 0.212524f, 0.227051f, 0.242310f, 0.258057f, 0.274414f, 0.291016f, 0.309082f,
+ 0.327148f, 0.345459f, 0.364990f, 0.384521f, 0.404297f, 0.425781f, 0.445801f, 0.467285f, 0.489258f, 0.510254f, 0.533203f, 0.555664f,
+ 0.578125f, 0.601074f, 0.817871f, 0.830078f, 0.831055f, 0.830078f, 0.829102f, 0.828125f, 0.001101f, 0.003019f, 0.004818f, 0.006725f,
+ 0.008781f, 0.010864f, 0.013069f, 0.014801f, 0.017151f, 0.019531f, 0.021973f, 0.024429f, 0.026917f, 0.030121f, 0.033112f, 0.036041f,
+ 0.039337f, 0.042542f, 0.046509f, 0.050537f, 0.054596f, 0.058990f, 0.064209f, 0.069519f, 0.075134f, 0.080994f, 0.087158f, 0.094177f,
+ 0.102051f, 0.109741f, 0.117981f, 0.127319f, 0.136963f, 0.147095f, 0.158081f, 0.169434f, 0.182251f, 0.195557f, 0.208984f, 0.223267f,
+ 0.238281f, 0.254639f, 0.270996f, 0.288330f, 0.305908f, 0.324219f, 0.343018f, 0.362549f, 0.382324f, 0.402832f, 0.424805f, 0.445312f,
+ 0.467529f, 0.489258f, 0.511230f, 0.535645f, 0.558594f, 0.582031f, 0.809082f, 0.822266f, 0.824219f, 0.823242f, 0.821777f, 0.820801f,
+ 0.000987f, 0.002644f, 0.004562f, 0.006344f, 0.008133f, 0.009918f, 0.011696f, 0.013527f, 0.015572f, 0.017746f, 0.019714f, 0.021942f,
+ 0.024155f, 0.027069f, 0.029678f, 0.032288f, 0.035156f, 0.038574f, 0.041779f, 0.045319f, 0.049225f, 0.053284f, 0.057678f, 0.062225f,
+ 0.067505f, 0.072571f, 0.078613f, 0.084961f, 0.092041f, 0.098938f, 0.106506f, 0.115112f, 0.123779f, 0.133667f, 0.143311f, 0.154541f,
+ 0.165894f, 0.178345f, 0.191406f, 0.205200f, 0.219238f, 0.234985f, 0.250977f, 0.267578f, 0.284912f, 0.302734f, 0.321289f, 0.340332f,
+ 0.360352f, 0.380615f, 0.401611f, 0.423340f, 0.445312f, 0.467529f, 0.490967f, 0.514160f, 0.537598f, 0.561035f, 0.800293f, 0.814453f,
+ 0.815918f, 0.815918f, 0.814941f, 0.813965f, 0.000932f, 0.002567f, 0.004009f, 0.005722f, 0.007538f, 0.008812f, 0.010864f, 0.012413f,
+ 0.014290f, 0.015991f, 0.018051f, 0.019836f, 0.022247f, 0.024506f, 0.026520f, 0.029175f, 0.031769f, 0.034332f, 0.037689f, 0.040466f,
+ 0.043945f, 0.047607f, 0.051605f, 0.055817f, 0.060486f, 0.065125f, 0.070557f, 0.076111f, 0.081909f, 0.088806f, 0.095886f, 0.103210f,
+ 0.111755f, 0.120422f, 0.130249f, 0.140137f, 0.150513f, 0.162109f, 0.174561f, 0.187256f, 0.200928f, 0.215698f, 0.231323f, 0.246582f,
+ 0.264160f, 0.281982f, 0.299561f, 0.319092f, 0.338623f, 0.358643f, 0.379883f, 0.400879f, 0.423096f, 0.445557f, 0.468750f, 0.492188f,
+ 0.516113f, 0.541504f, 0.791016f, 0.805664f, 0.808105f, 0.808594f, 0.807129f, 0.806641f, 0.000871f, 0.002337f, 0.003727f, 0.005474f,
+ 0.006641f, 0.008377f, 0.009567f, 0.011154f, 0.012848f, 0.014610f, 0.016235f, 0.017960f, 0.019958f, 0.021729f, 0.023926f, 0.026154f,
+ 0.028351f, 0.030975f, 0.033722f, 0.036407f, 0.039459f, 0.042694f, 0.046082f, 0.049896f, 0.053833f, 0.058167f, 0.062744f, 0.067932f,
+ 0.073608f, 0.079468f, 0.085632f, 0.092651f, 0.100098f, 0.108521f, 0.116699f, 0.126099f, 0.136108f, 0.146606f, 0.157959f, 0.170410f,
+ 0.183594f, 0.197510f, 0.212280f, 0.227295f, 0.243652f, 0.260986f, 0.278564f, 0.297607f, 0.316406f, 0.336426f, 0.357178f, 0.378662f,
+ 0.400146f, 0.422852f, 0.446045f, 0.470215f, 0.494873f, 0.520020f, 0.781250f, 0.796875f, 0.800293f, 0.800781f, 0.799805f, 0.799316f,
+ 0.000782f, 0.002131f, 0.003649f, 0.004715f, 0.006054f, 0.007458f, 0.008759f, 0.010269f, 0.011711f, 0.012970f, 0.014664f, 0.016327f,
+ 0.017914f, 0.019699f, 0.021423f, 0.023499f, 0.025391f, 0.027374f, 0.029999f, 0.032501f, 0.035156f, 0.037872f, 0.040710f, 0.044403f,
+ 0.047791f, 0.051880f, 0.055969f, 0.060364f, 0.065247f, 0.070496f, 0.076172f, 0.082825f, 0.089294f, 0.096497f, 0.104431f, 0.112854f,
+ 0.122375f, 0.132202f, 0.142700f, 0.153931f, 0.166260f, 0.179565f, 0.193481f, 0.208008f, 0.223877f, 0.240479f, 0.257568f, 0.275879f,
+ 0.294922f, 0.314453f, 0.334961f, 0.355957f, 0.377686f, 0.400391f, 0.423828f, 0.448730f, 0.472900f, 0.498535f, 0.771484f, 0.789062f,
+ 0.791504f, 0.792480f, 0.791016f, 0.791016f, 0.000742f, 0.001822f, 0.003183f, 0.004444f, 0.005600f, 0.006550f, 0.008087f, 0.009247f,
+ 0.010559f, 0.011650f, 0.013184f, 0.014565f, 0.016083f, 0.017548f, 0.019119f, 0.020737f, 0.022644f, 0.024597f, 0.026627f, 0.028809f,
+ 0.031281f, 0.033539f, 0.036469f, 0.039429f, 0.042480f, 0.045654f, 0.049561f, 0.053406f, 0.057739f, 0.062469f, 0.067749f, 0.073364f,
+ 0.079773f, 0.086121f, 0.093262f, 0.100647f, 0.109253f, 0.118042f, 0.128174f, 0.138550f, 0.150024f, 0.162231f, 0.175171f, 0.189087f,
+ 0.204468f, 0.220215f, 0.236938f, 0.254639f, 0.273438f, 0.292236f, 0.312012f, 0.333252f, 0.355957f, 0.377686f, 0.401367f, 0.425781f,
+ 0.451416f, 0.476318f, 0.761230f, 0.779785f, 0.782227f, 0.782715f, 0.782715f, 0.782715f, 0.000632f, 0.001970f, 0.003042f, 0.004025f,
+ 0.005173f, 0.006435f, 0.007343f, 0.008522f, 0.009369f, 0.010475f, 0.011726f, 0.012962f, 0.014145f, 0.015411f, 0.016922f, 0.018478f,
+ 0.020111f, 0.021835f, 0.023682f, 0.025253f, 0.027466f, 0.029678f, 0.032196f, 0.034607f, 0.037415f, 0.040497f, 0.043610f, 0.047089f,
+ 0.051178f, 0.055573f, 0.059845f, 0.064758f, 0.070068f, 0.076111f, 0.082275f, 0.089417f, 0.096863f, 0.105286f, 0.114441f, 0.123535f,
+ 0.134399f, 0.145508f, 0.157959f, 0.171387f, 0.185425f, 0.200806f, 0.216919f, 0.233521f, 0.251953f, 0.270508f, 0.290527f, 0.310791f,
+ 0.332275f, 0.355469f, 0.378418f, 0.403564f, 0.428223f, 0.455322f, 0.750977f, 0.770996f, 0.774414f, 0.774414f, 0.774902f, 0.773926f,
+ 0.000517f, 0.001554f, 0.002741f, 0.003695f, 0.004669f, 0.005417f, 0.006466f, 0.007545f, 0.008453f, 0.009499f, 0.010468f, 0.011490f,
+ 0.012718f, 0.013985f, 0.014977f, 0.016235f, 0.017868f, 0.019211f, 0.020630f, 0.022263f, 0.024078f, 0.026291f, 0.028275f, 0.030380f,
+ 0.032928f, 0.035675f, 0.038513f, 0.041656f, 0.044769f, 0.048523f, 0.052216f, 0.057007f, 0.061493f, 0.066711f, 0.072510f, 0.078735f,
+ 0.085327f, 0.093201f, 0.101135f, 0.109619f, 0.119690f, 0.130371f, 0.141602f, 0.154053f, 0.167480f, 0.181396f, 0.197021f, 0.213623f,
+ 0.230835f, 0.248901f, 0.268066f, 0.289062f, 0.310303f, 0.332520f, 0.355225f, 0.379639f, 0.405273f, 0.432373f, 0.740234f, 0.760742f,
+ 0.763672f, 0.765625f, 0.765625f, 0.765625f, 0.000588f, 0.001405f, 0.002306f, 0.003370f, 0.004375f, 0.005116f, 0.005817f, 0.006630f,
+ 0.007797f, 0.008507f, 0.009216f, 0.010254f, 0.011246f, 0.012154f, 0.013191f, 0.014366f, 0.015503f, 0.016785f, 0.018127f, 0.019562f,
+ 0.021072f, 0.022919f, 0.024643f, 0.026749f, 0.028564f, 0.031006f, 0.033203f, 0.036072f, 0.039032f, 0.042114f, 0.045654f, 0.049561f,
+ 0.053650f, 0.058380f, 0.063049f, 0.068848f, 0.075256f, 0.081543f, 0.088562f, 0.096924f, 0.105652f, 0.115173f, 0.125977f, 0.137207f,
+ 0.149902f, 0.163208f, 0.177979f, 0.193726f, 0.210205f, 0.228027f, 0.247070f, 0.266602f, 0.287842f, 0.309326f, 0.333008f, 0.356934f,
+ 0.382568f, 0.408691f, 0.729004f, 0.751953f, 0.755371f, 0.756348f, 0.757324f, 0.756348f, 0.000431f, 0.001562f, 0.002253f, 0.003088f,
+ 0.003944f, 0.004536f, 0.005066f, 0.006020f, 0.006840f, 0.007542f, 0.008347f, 0.008949f, 0.009827f, 0.010719f, 0.011696f, 0.012756f,
+ 0.013649f, 0.014679f, 0.015808f, 0.017288f, 0.018356f, 0.019913f, 0.021332f, 0.023148f, 0.024719f, 0.026840f, 0.029007f, 0.031250f,
+ 0.033661f, 0.036469f, 0.039490f, 0.042969f, 0.046326f, 0.050293f, 0.054901f, 0.059845f, 0.064941f, 0.071289f, 0.077454f, 0.084656f,
+ 0.092529f, 0.101562f, 0.111145f, 0.121460f, 0.132935f, 0.145386f, 0.159302f, 0.174438f, 0.190186f, 0.206909f, 0.225098f, 0.244751f,
+ 0.265381f, 0.287109f, 0.310059f, 0.333984f, 0.359131f, 0.386230f, 0.716797f, 0.740723f, 0.744629f, 0.746582f, 0.747070f, 0.747070f,
+ 0.000576f, 0.001266f, 0.002028f, 0.002766f, 0.003317f, 0.004051f, 0.004742f, 0.005459f, 0.006054f, 0.006641f, 0.007240f, 0.007919f,
+ 0.008644f, 0.009300f, 0.010170f, 0.010925f, 0.011795f, 0.012733f, 0.013855f, 0.014885f, 0.015900f, 0.017212f, 0.018326f, 0.019684f,
+ 0.021469f, 0.023178f, 0.024734f, 0.026794f, 0.028946f, 0.031204f, 0.033844f, 0.036682f, 0.039948f, 0.043335f, 0.047150f, 0.051422f,
+ 0.055969f, 0.061066f, 0.067139f, 0.073242f, 0.080444f, 0.088440f, 0.096985f, 0.106445f, 0.116943f, 0.128906f, 0.141479f, 0.154907f,
+ 0.170410f, 0.186523f, 0.204102f, 0.222900f, 0.243774f, 0.264160f, 0.286865f, 0.310791f, 0.336182f, 0.362793f, 0.705078f, 0.730469f,
+ 0.735352f, 0.736816f, 0.737793f, 0.736816f, 0.000307f, 0.001126f, 0.001758f, 0.002436f, 0.002911f, 0.003540f, 0.004047f, 0.004711f,
+ 0.005245f, 0.005749f, 0.006302f, 0.006844f, 0.007355f, 0.008095f, 0.008835f, 0.009438f, 0.010139f, 0.010941f, 0.011963f, 0.012878f,
+ 0.013519f, 0.014847f, 0.015945f, 0.017029f, 0.018250f, 0.019669f, 0.021362f, 0.022675f, 0.024750f, 0.026657f, 0.028854f, 0.031219f,
+ 0.033844f, 0.036804f, 0.040222f, 0.043793f, 0.047791f, 0.052185f, 0.057251f, 0.062866f, 0.069275f, 0.075867f, 0.083923f, 0.092407f,
+ 0.102295f, 0.112366f, 0.124207f, 0.137085f, 0.151489f, 0.167114f, 0.183838f, 0.202148f, 0.221558f, 0.242065f, 0.263916f, 0.287842f,
+ 0.312256f, 0.339111f, 0.693848f, 0.719727f, 0.724609f, 0.726074f, 0.727539f, 0.727051f, 0.000428f, 0.000939f, 0.001581f, 0.002033f,
+ 0.002665f, 0.003222f, 0.003660f, 0.004059f, 0.004475f, 0.004997f, 0.005554f, 0.006031f, 0.006371f, 0.007080f, 0.007511f, 0.008263f,
+ 0.008820f, 0.009552f, 0.010124f, 0.010948f, 0.011665f, 0.012550f, 0.013397f, 0.014526f, 0.015388f, 0.016754f, 0.017960f, 0.019257f,
+ 0.020844f, 0.022583f, 0.024246f, 0.026642f, 0.028656f, 0.031128f, 0.033783f, 0.036865f, 0.040253f, 0.044312f, 0.048523f, 0.053314f,
+ 0.058655f, 0.064880f, 0.071594f, 0.079102f, 0.087891f, 0.097107f, 0.108276f, 0.119751f, 0.133179f, 0.148071f, 0.163818f, 0.180908f,
+ 0.199951f, 0.219849f, 0.241699f, 0.264160f, 0.288818f, 0.315918f, 0.680176f, 0.708496f, 0.713867f, 0.716309f, 0.716797f, 0.717285f,
+ 0.000467f, 0.001054f, 0.001476f, 0.001825f, 0.002386f, 0.002644f, 0.003218f, 0.003553f, 0.003866f, 0.004433f, 0.004700f, 0.004948f,
+ 0.005505f, 0.006023f, 0.006405f, 0.006920f, 0.007484f, 0.008057f, 0.008598f, 0.009178f, 0.009857f, 0.010551f, 0.011169f, 0.012199f,
+ 0.013092f, 0.014084f, 0.015091f, 0.016205f, 0.017303f, 0.018845f, 0.020538f, 0.021957f, 0.023773f, 0.025833f, 0.028152f, 0.030716f,
+ 0.033661f, 0.036896f, 0.040405f, 0.044708f, 0.049286f, 0.054321f, 0.060333f, 0.067322f, 0.074890f, 0.083435f, 0.092651f, 0.103516f,
+ 0.115784f, 0.129028f, 0.144287f, 0.160278f, 0.178345f, 0.197632f, 0.218994f, 0.241089f, 0.265869f, 0.292725f, 0.667969f, 0.697266f,
+ 0.702637f, 0.704590f, 0.706055f, 0.707031f, 0.000348f, 0.000841f, 0.001292f, 0.001580f, 0.001961f, 0.002508f, 0.002630f, 0.002993f,
+ 0.003458f, 0.003738f, 0.003952f, 0.004425f, 0.004639f, 0.005070f, 0.005547f, 0.005840f, 0.006462f, 0.006844f, 0.007214f, 0.007698f,
+ 0.008339f, 0.008980f, 0.009560f, 0.010094f, 0.010941f, 0.011711f, 0.012550f, 0.013565f, 0.014404f, 0.015579f, 0.016754f, 0.018082f,
+ 0.019592f, 0.021439f, 0.023209f, 0.025375f, 0.027863f, 0.030411f, 0.033478f, 0.037018f, 0.040680f, 0.045105f, 0.050476f, 0.056183f,
+ 0.062805f, 0.070251f, 0.078613f, 0.088196f, 0.099060f, 0.111450f, 0.125122f, 0.140869f, 0.158203f, 0.176880f, 0.197266f, 0.218506f,
+ 0.242798f, 0.268555f, 0.655273f, 0.686035f, 0.691406f, 0.694336f, 0.695312f, 0.695801f, 0.000170f, 0.000976f, 0.001161f, 0.001441f,
+ 0.001846f, 0.002144f, 0.002367f, 0.002632f, 0.002892f, 0.003178f, 0.003435f, 0.003618f, 0.004021f, 0.004292f, 0.004562f, 0.005028f,
+ 0.005405f, 0.005623f, 0.006069f, 0.006577f, 0.006973f, 0.007431f, 0.007904f, 0.008484f, 0.009018f, 0.009659f, 0.010559f, 0.010994f,
+ 0.012009f, 0.012840f, 0.013901f, 0.014915f, 0.016129f, 0.017502f, 0.019089f, 0.020676f, 0.022568f, 0.024673f, 0.027252f, 0.029984f,
+ 0.033234f, 0.037079f, 0.041016f, 0.045868f, 0.051758f, 0.058014f, 0.065613f, 0.073853f, 0.083801f, 0.094727f, 0.107483f, 0.121826f,
+ 0.137573f, 0.156006f, 0.175049f, 0.196167f, 0.219482f, 0.245850f, 0.641113f, 0.673340f, 0.679688f, 0.681641f, 0.683594f, 0.684082f,
+ 0.000293f, 0.000601f, 0.001049f, 0.001358f, 0.001532f, 0.001719f, 0.001882f, 0.002298f, 0.002317f, 0.002628f, 0.002750f, 0.003143f,
+ 0.003363f, 0.003559f, 0.003866f, 0.004204f, 0.004383f, 0.004753f, 0.005028f, 0.005348f, 0.005863f, 0.006176f, 0.006569f, 0.006954f,
+ 0.007401f, 0.008057f, 0.008537f, 0.009178f, 0.009735f, 0.010521f, 0.011208f, 0.011978f, 0.013130f, 0.014099f, 0.015289f, 0.016739f,
+ 0.018219f, 0.019821f, 0.021713f, 0.024200f, 0.026749f, 0.029785f, 0.033386f, 0.036987f, 0.041840f, 0.047089f, 0.053253f, 0.060760f,
+ 0.069214f, 0.079224f, 0.090515f, 0.103638f, 0.118652f, 0.135376f, 0.154175f, 0.174561f, 0.196777f, 0.222534f, 0.628906f, 0.660645f,
+ 0.668457f, 0.670410f, 0.672852f, 0.673340f, 0.000258f, 0.000656f, 0.000811f, 0.001049f, 0.001288f, 0.001462f, 0.001599f, 0.001740f,
+ 0.002012f, 0.002171f, 0.002367f, 0.002535f, 0.002705f, 0.002880f, 0.003115f, 0.003429f, 0.003666f, 0.003897f, 0.004116f, 0.004398f,
+ 0.004635f, 0.005066f, 0.005341f, 0.005779f, 0.006042f, 0.006454f, 0.006954f, 0.007450f, 0.007835f, 0.008400f, 0.009132f, 0.009819f,
+ 0.010536f, 0.011307f, 0.012245f, 0.013229f, 0.014580f, 0.015900f, 0.017303f, 0.019119f, 0.021103f, 0.023468f, 0.026123f, 0.029495f,
+ 0.033112f, 0.037628f, 0.042938f, 0.048859f, 0.056152f, 0.064941f, 0.074829f, 0.086548f, 0.100281f, 0.115967f, 0.133545f, 0.153198f,
+ 0.175171f, 0.199341f, 0.613770f, 0.648926f, 0.655273f, 0.658691f, 0.660645f, 0.662598f, 0.000176f, 0.000474f, 0.000602f, 0.000854f,
+ 0.001030f, 0.001240f, 0.001349f, 0.001505f, 0.001580f, 0.001738f, 0.001957f, 0.002068f, 0.002230f, 0.002420f, 0.002556f, 0.002705f,
+ 0.002998f, 0.003178f, 0.003345f, 0.003567f, 0.003811f, 0.004105f, 0.004284f, 0.004593f, 0.004848f, 0.005173f, 0.005527f, 0.005939f,
+ 0.006306f, 0.006817f, 0.007366f, 0.007729f, 0.008339f, 0.008995f, 0.009644f, 0.010551f, 0.011360f, 0.012344f, 0.013710f, 0.015030f,
+ 0.016510f, 0.018143f, 0.020279f, 0.022751f, 0.025650f, 0.029144f, 0.033508f, 0.038452f, 0.044556f, 0.052032f, 0.060364f, 0.070923f,
+ 0.082642f, 0.097290f, 0.113525f, 0.132446f, 0.153442f, 0.176880f, 0.600586f, 0.636719f, 0.644531f, 0.647461f, 0.648926f, 0.649414f,
+ 0.000121f, 0.000426f, 0.000509f, 0.000778f, 0.000931f, 0.000992f, 0.001135f, 0.001303f, 0.001359f, 0.001410f, 0.001519f, 0.001722f,
+ 0.001751f, 0.001951f, 0.002060f, 0.002218f, 0.002287f, 0.002487f, 0.002670f, 0.002848f, 0.003061f, 0.003233f, 0.003452f, 0.003664f,
+ 0.003883f, 0.004078f, 0.004379f, 0.004692f, 0.004982f, 0.005329f, 0.005756f, 0.006081f, 0.006504f, 0.007019f, 0.007599f, 0.008217f,
+ 0.008850f, 0.009628f, 0.010437f, 0.011597f, 0.012650f, 0.013931f, 0.015480f, 0.017380f, 0.019577f, 0.022247f, 0.025513f, 0.029617f,
+ 0.034363f, 0.040314f, 0.047241f, 0.056274f, 0.066711f, 0.079773f, 0.094482f, 0.112488f, 0.132446f, 0.154907f, 0.585449f, 0.624023f,
+ 0.630371f, 0.634277f, 0.636230f, 0.637207f, 0.000161f, 0.000263f, 0.000526f, 0.000627f, 0.000723f, 0.000775f, 0.000856f, 0.000960f,
+ 0.001079f, 0.001158f, 0.001208f, 0.001272f, 0.001441f, 0.001557f, 0.001657f, 0.001702f, 0.001897f, 0.001918f, 0.002151f, 0.002232f,
+ 0.002337f, 0.002522f, 0.002720f, 0.002865f, 0.003029f, 0.003193f, 0.003387f, 0.003601f, 0.003887f, 0.004124f, 0.004356f, 0.004639f,
+ 0.005070f, 0.005466f, 0.005863f, 0.006298f, 0.006874f, 0.007290f, 0.007965f, 0.008774f, 0.009560f, 0.010666f, 0.011719f, 0.013077f,
+ 0.014679f, 0.016693f, 0.019058f, 0.021881f, 0.025528f, 0.030121f, 0.036011f, 0.043396f, 0.052460f, 0.063477f, 0.076721f, 0.093079f,
+ 0.112305f, 0.133667f, 0.572266f, 0.609375f, 0.618164f, 0.622070f, 0.623535f, 0.625488f, 0.000109f, 0.000212f, 0.000404f, 0.000578f,
+ 0.000567f, 0.000655f, 0.000763f, 0.000676f, 0.000824f, 0.000869f, 0.000971f, 0.001064f, 0.001132f, 0.001210f, 0.001212f, 0.001398f,
+ 0.001486f, 0.001525f, 0.001653f, 0.001676f, 0.001867f, 0.001953f, 0.002062f, 0.002199f, 0.002295f, 0.002443f, 0.002586f, 0.002766f,
+ 0.002979f, 0.003128f, 0.003429f, 0.003551f, 0.003763f, 0.004074f, 0.004349f, 0.004688f, 0.005032f, 0.005470f, 0.005894f, 0.006519f,
+ 0.007092f, 0.007896f, 0.008629f, 0.009659f, 0.010910f, 0.012215f, 0.013962f, 0.015991f, 0.018646f, 0.021881f, 0.026428f, 0.032074f,
+ 0.039276f, 0.048645f, 0.060455f, 0.075256f, 0.092773f, 0.113220f, 0.554688f, 0.596191f, 0.605957f, 0.608887f, 0.610352f, 0.612305f,
+ 0.000202f, 0.000186f, 0.000312f, 0.000433f, 0.000382f, 0.000543f, 0.000482f, 0.000546f, 0.000621f, 0.000666f, 0.000789f, 0.000802f,
+ 0.000859f, 0.000950f, 0.000970f, 0.000975f, 0.001113f, 0.001162f, 0.001207f, 0.001312f, 0.001362f, 0.001433f, 0.001541f, 0.001618f,
+ 0.001720f, 0.001791f, 0.001966f, 0.002035f, 0.002199f, 0.002413f, 0.002546f, 0.002626f, 0.002855f, 0.003063f, 0.003204f, 0.003448f,
+ 0.003693f, 0.003986f, 0.004364f, 0.004684f, 0.005127f, 0.005619f, 0.006271f, 0.006870f, 0.007748f, 0.008713f, 0.009911f, 0.011368f,
+ 0.013191f, 0.015518f, 0.018646f, 0.022644f, 0.028107f, 0.035645f, 0.045471f, 0.058502f, 0.074646f, 0.093994f, 0.541016f, 0.583008f,
+ 0.591797f, 0.596191f, 0.599121f, 0.600098f, 0.000000f, 0.000179f, 0.000242f, 0.000318f, 0.000341f, 0.000345f, 0.000432f, 0.000364f,
+ 0.000475f, 0.000483f, 0.000572f, 0.000576f, 0.000619f, 0.000640f, 0.000716f, 0.000737f, 0.000791f, 0.000845f, 0.000871f, 0.000907f,
+ 0.000998f, 0.001025f, 0.001107f, 0.001181f, 0.001244f, 0.001303f, 0.001391f, 0.001462f, 0.001549f, 0.001631f, 0.001756f, 0.001906f,
+ 0.001984f, 0.002161f, 0.002264f, 0.002419f, 0.002613f, 0.002825f, 0.003103f, 0.003321f, 0.003584f, 0.003893f, 0.004349f, 0.004799f,
+ 0.005383f, 0.006020f, 0.006836f, 0.007858f, 0.009117f, 0.010674f, 0.012825f, 0.015533f, 0.019363f, 0.024780f, 0.032593f, 0.043274f,
+ 0.057770f, 0.076111f, 0.525879f, 0.569336f, 0.578613f, 0.583008f, 0.585449f, 0.586426f, 0.000000f, 0.000088f, 0.000192f, 0.000227f,
+ 0.000230f, 0.000286f, 0.000255f, 0.000317f, 0.000321f, 0.000371f, 0.000401f, 0.000373f, 0.000391f, 0.000457f, 0.000474f, 0.000530f,
+ 0.000509f, 0.000585f, 0.000625f, 0.000664f, 0.000707f, 0.000746f, 0.000772f, 0.000817f, 0.000877f, 0.000887f, 0.000978f, 0.001007f,
+ 0.001069f, 0.001202f, 0.001192f, 0.001290f, 0.001356f, 0.001464f, 0.001583f, 0.001678f, 0.001771f, 0.001929f, 0.002050f, 0.002230f,
+ 0.002424f, 0.002651f, 0.002888f, 0.003176f, 0.003534f, 0.003967f, 0.004475f, 0.005154f, 0.005993f, 0.007118f, 0.008469f, 0.010338f,
+ 0.012794f, 0.016403f, 0.021957f, 0.030090f, 0.042419f, 0.059052f, 0.510254f, 0.554199f, 0.564453f, 0.570312f, 0.572754f, 0.573242f,
+ 0.000000f, 0.000126f, 0.000180f, 0.000121f, 0.000178f, 0.000176f, 0.000177f, 0.000212f, 0.000210f, 0.000228f, 0.000238f, 0.000291f,
+ 0.000280f, 0.000298f, 0.000336f, 0.000350f, 0.000369f, 0.000387f, 0.000395f, 0.000427f, 0.000460f, 0.000476f, 0.000515f, 0.000536f,
+ 0.000573f, 0.000619f, 0.000650f, 0.000670f, 0.000703f, 0.000746f, 0.000798f, 0.000836f, 0.000902f, 0.000949f, 0.001031f, 0.001062f,
+ 0.001162f, 0.001227f, 0.001349f, 0.001442f, 0.001533f, 0.001690f, 0.001865f, 0.001995f, 0.002228f, 0.002495f, 0.002800f, 0.003191f,
+ 0.003653f, 0.004349f, 0.005203f, 0.006393f, 0.008026f, 0.010307f, 0.013710f, 0.019379f, 0.028854f, 0.043457f, 0.494873f, 0.541016f,
+ 0.550781f, 0.555664f, 0.558105f, 0.559570f, 0.000000f, 0.000095f, 0.000086f, 0.000079f, 0.000105f, 0.000124f, 0.000111f, 0.000137f,
+ 0.000141f, 0.000142f, 0.000147f, 0.000151f, 0.000160f, 0.000181f, 0.000202f, 0.000207f, 0.000214f, 0.000248f, 0.000244f, 0.000282f,
+ 0.000273f, 0.000283f, 0.000306f, 0.000334f, 0.000367f, 0.000378f, 0.000376f, 0.000399f, 0.000437f, 0.000459f, 0.000474f, 0.000516f,
+ 0.000552f, 0.000567f, 0.000616f, 0.000649f, 0.000693f, 0.000743f, 0.000805f, 0.000851f, 0.000918f, 0.000999f, 0.001085f, 0.001195f,
+ 0.001309f, 0.001466f, 0.001644f, 0.001850f, 0.002151f, 0.002487f, 0.002974f, 0.003654f, 0.004574f, 0.006001f, 0.008156f, 0.011452f,
+ 0.017853f, 0.029739f, 0.478271f, 0.526367f, 0.537109f, 0.541504f, 0.544434f, 0.545898f, 0.000106f, 0.000085f, 0.000074f, 0.000067f,
+ 0.000066f, 0.000070f, 0.000069f, 0.000073f, 0.000073f, 0.000080f, 0.000084f, 0.000109f, 0.000093f, 0.000098f, 0.000119f, 0.000108f,
+ 0.000128f, 0.000135f, 0.000137f, 0.000149f, 0.000150f, 0.000157f, 0.000182f, 0.000185f, 0.000207f, 0.000206f, 0.000214f, 0.000234f,
+ 0.000237f, 0.000253f, 0.000267f, 0.000289f, 0.000306f, 0.000313f, 0.000344f, 0.000352f, 0.000384f, 0.000406f, 0.000445f, 0.000467f,
+ 0.000503f, 0.000543f, 0.000593f, 0.000634f, 0.000697f, 0.000764f, 0.000850f, 0.000963f, 0.001105f, 0.001298f, 0.001536f, 0.001856f,
+ 0.002333f, 0.003069f, 0.004299f, 0.006271f, 0.009789f, 0.018234f, 0.462402f, 0.511719f, 0.522949f, 0.527344f, 0.530762f, 0.532715f,
+ 0.000091f, 0.000069f, 0.000060f, 0.000054f, 0.000049f, 0.000046f, 0.000043f, 0.000041f, 0.000040f, 0.000044f, 0.000040f, 0.000040f,
+ 0.000054f, 0.000044f, 0.000045f, 0.000044f, 0.000062f, 0.000062f, 0.000069f, 0.000071f, 0.000074f, 0.000079f, 0.000081f, 0.000081f,
+ 0.000085f, 0.000099f, 0.000098f, 0.000115f, 0.000115f, 0.000119f, 0.000125f, 0.000130f, 0.000140f, 0.000144f, 0.000165f, 0.000172f,
+ 0.000178f, 0.000191f, 0.000205f, 0.000222f, 0.000234f, 0.000251f, 0.000276f, 0.000293f, 0.000327f, 0.000354f, 0.000392f, 0.000437f,
+ 0.000494f, 0.000562f, 0.000662f, 0.000800f, 0.001005f, 0.001315f, 0.001852f, 0.002825f, 0.004723f, 0.009285f, 0.446533f, 0.497803f,
+ 0.508301f, 0.514160f, 0.516602f, 0.519043f, 0.000067f, 0.000048f, 0.000040f, 0.000036f, 0.000033f, 0.000031f, 0.000030f, 0.000028f,
+ 0.000027f, 0.000026f, 0.000025f, 0.000024f, 0.000023f, 0.000022f, 0.000021f, 0.000020f, 0.000019f, 0.000020f, 0.000024f, 0.000026f,
+ 0.000025f, 0.000027f, 0.000031f, 0.000032f, 0.000032f, 0.000037f, 0.000041f, 0.000038f, 0.000045f, 0.000042f, 0.000048f, 0.000049f,
+ 0.000053f, 0.000055f, 0.000059f, 0.000062f, 0.000071f, 0.000074f, 0.000077f, 0.000081f, 0.000086f, 0.000091f, 0.000098f, 0.000109f,
+ 0.000116f, 0.000125f, 0.000137f, 0.000158f, 0.000173f, 0.000193f, 0.000230f, 0.000273f, 0.000335f, 0.000425f, 0.000603f, 0.000935f,
+ 0.001694f, 0.003727f, 0.431396f, 0.481934f, 0.493652f, 0.499512f, 0.502930f, 0.504883f, 0.000021f, 0.000016f, 0.000013f, 0.000012f,
+ 0.000013f, 0.000012f, 0.000012f, 0.000012f, 0.000012f, 0.000012f, 0.000011f, 0.000012f, 0.000012f, 0.000011f, 0.000011f, 0.000011f,
+ 0.000011f, 0.000011f, 0.000011f, 0.000010f, 0.000010f, 0.000009f, 0.000009f, 0.000009f, 0.000008f, 0.000008f, 0.000008f, 0.000007f,
+ 0.000008f, 0.000009f, 0.000009f, 0.000010f, 0.000010f, 0.000013f, 0.000014f, 0.000013f, 0.000015f, 0.000016f, 0.000017f, 0.000019f,
+ 0.000019f, 0.000020f, 0.000023f, 0.000026f, 0.000027f, 0.000027f, 0.000032f, 0.000030f, 0.000036f, 0.000039f, 0.000050f, 0.000056f,
+ 0.000063f, 0.000082f, 0.000109f, 0.000168f, 0.000317f, 0.000922f, 0.415283f, 0.467773f, 0.479980f, 0.486328f, 0.489014f, 0.490723f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000002f, 0.000002f, 0.000002f, 0.000002f,
+ 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f,
+ 0.000001f, 0.000002f, 0.000002f, 0.000002f, 0.000003f, 0.000003f, 0.000004f, 0.000005f, 0.000008f, 0.000026f, 0.398926f, 0.452881f,
+ 0.465576f, 0.471436f, 0.474854f, 0.477051f,
+ },
+ {
+ 0.019653f, 0.058990f, 0.097473f, 0.134277f, 0.169189f, 0.203491f, 0.236450f, 0.267578f, 0.297852f, 0.326416f, 0.354004f, 0.380859f,
+ 0.406250f, 0.431641f, 0.455078f, 0.477539f, 0.500000f, 0.520996f, 0.541504f, 0.560547f, 0.580566f, 0.598633f, 0.615723f, 0.633301f,
+ 0.649902f, 0.666016f, 0.681641f, 0.695801f, 0.709961f, 0.724609f, 0.738770f, 0.751953f, 0.765137f, 0.775879f, 0.788574f, 0.799805f,
+ 0.812012f, 0.822754f, 0.833496f, 0.844238f, 0.854004f, 0.864258f, 0.874023f, 0.883301f, 0.891602f, 0.900391f, 0.909668f, 0.917969f,
+ 0.925781f, 0.934570f, 0.941895f, 0.949707f, 0.956543f, 0.963379f, 0.970703f, 0.977539f, 0.984863f, 0.991211f, 0.988770f, 0.972656f,
+ 0.960449f, 0.949707f, 0.940430f, 0.931641f, 0.017303f, 0.052399f, 0.086548f, 0.119446f, 0.153076f, 0.183594f, 0.214722f, 0.245117f,
+ 0.273193f, 0.301270f, 0.328613f, 0.354492f, 0.379883f, 0.404541f, 0.427979f, 0.450195f, 0.472656f, 0.494629f, 0.515137f, 0.534668f,
+ 0.554199f, 0.573242f, 0.591309f, 0.608887f, 0.625977f, 0.642578f, 0.658203f, 0.672852f, 0.688477f, 0.704102f, 0.717285f, 0.731445f,
+ 0.744629f, 0.756836f, 0.769531f, 0.782715f, 0.793945f, 0.805664f, 0.816406f, 0.828125f, 0.838379f, 0.849121f, 0.858887f, 0.868652f,
+ 0.877930f, 0.888184f, 0.896973f, 0.905762f, 0.915039f, 0.921875f, 0.930176f, 0.937988f, 0.946777f, 0.954102f, 0.960938f, 0.968750f,
+ 0.975586f, 0.982422f, 0.984375f, 0.969238f, 0.957520f, 0.947754f, 0.938477f, 0.930176f, 0.015221f, 0.045837f, 0.076843f, 0.107666f,
+ 0.136719f, 0.166504f, 0.196045f, 0.223999f, 0.250244f, 0.278320f, 0.303711f, 0.329346f, 0.353271f, 0.378906f, 0.401367f, 0.424316f,
+ 0.447266f, 0.468018f, 0.487793f, 0.508301f, 0.529297f, 0.547363f, 0.566406f, 0.583984f, 0.601562f, 0.618652f, 0.634766f, 0.650879f,
+ 0.666016f, 0.681641f, 0.695801f, 0.710449f, 0.724121f, 0.737305f, 0.750488f, 0.762695f, 0.775391f, 0.788086f, 0.799316f, 0.811035f,
+ 0.821777f, 0.833008f, 0.844238f, 0.854004f, 0.864258f, 0.874023f, 0.882812f, 0.892578f, 0.901367f, 0.910156f, 0.918457f, 0.926758f,
+ 0.936035f, 0.942871f, 0.950684f, 0.958496f, 0.965820f, 0.973145f, 0.980469f, 0.965820f, 0.955078f, 0.945312f, 0.936523f, 0.928223f,
+ 0.013420f, 0.041138f, 0.068359f, 0.096436f, 0.124023f, 0.150879f, 0.177246f, 0.204224f, 0.230103f, 0.255859f, 0.281494f, 0.305420f,
+ 0.329834f, 0.352783f, 0.376709f, 0.398682f, 0.420654f, 0.442627f, 0.462646f, 0.483887f, 0.502441f, 0.521484f, 0.540527f, 0.559082f,
+ 0.576172f, 0.595703f, 0.611328f, 0.627930f, 0.644043f, 0.659668f, 0.674316f, 0.688965f, 0.703613f, 0.717285f, 0.730957f, 0.744629f,
+ 0.756836f, 0.770020f, 0.781738f, 0.793945f, 0.805176f, 0.816895f, 0.828125f, 0.838379f, 0.849121f, 0.859375f, 0.869141f, 0.878418f,
+ 0.888184f, 0.897461f, 0.906738f, 0.915039f, 0.923828f, 0.932129f, 0.940430f, 0.947754f, 0.956543f, 0.963867f, 0.976074f, 0.962402f,
+ 0.951660f, 0.942383f, 0.934082f, 0.926758f, 0.012001f, 0.036591f, 0.061737f, 0.086670f, 0.112000f, 0.136719f, 0.161743f, 0.186768f,
+ 0.211792f, 0.235840f, 0.259521f, 0.283203f, 0.307129f, 0.329590f, 0.352295f, 0.374268f, 0.395996f, 0.416992f, 0.437744f, 0.457520f,
+ 0.477295f, 0.497314f, 0.515625f, 0.534180f, 0.553223f, 0.570312f, 0.588379f, 0.604492f, 0.621582f, 0.636719f, 0.653320f, 0.666992f,
+ 0.683105f, 0.697266f, 0.710449f, 0.724609f, 0.737793f, 0.750977f, 0.764160f, 0.775879f, 0.788086f, 0.799805f, 0.812012f, 0.823242f,
+ 0.833496f, 0.844238f, 0.854492f, 0.864746f, 0.875000f, 0.884277f, 0.894043f, 0.902832f, 0.911621f, 0.920898f, 0.929688f, 0.937500f,
+ 0.945801f, 0.953613f, 0.971191f, 0.958984f, 0.949219f, 0.939941f, 0.932129f, 0.924316f, 0.010612f, 0.032684f, 0.054810f, 0.077759f,
+ 0.100952f, 0.124023f, 0.146851f, 0.171021f, 0.193604f, 0.217163f, 0.239380f, 0.261963f, 0.284424f, 0.307129f, 0.328613f, 0.351318f,
+ 0.371826f, 0.392334f, 0.413574f, 0.432617f, 0.453613f, 0.472656f, 0.491943f, 0.510254f, 0.528320f, 0.546387f, 0.563965f, 0.580078f,
+ 0.598633f, 0.613770f, 0.629883f, 0.645996f, 0.661621f, 0.675293f, 0.688965f, 0.705078f, 0.718262f, 0.731934f, 0.745605f, 0.757812f,
+ 0.770996f, 0.782715f, 0.795410f, 0.807129f, 0.818359f, 0.829102f, 0.839844f, 0.851074f, 0.860840f, 0.871094f, 0.880859f, 0.891113f,
+ 0.900391f, 0.909668f, 0.917969f, 0.927246f, 0.935547f, 0.943848f, 0.966797f, 0.955566f, 0.945801f, 0.937012f, 0.929199f, 0.921875f,
+ 0.009483f, 0.029556f, 0.050140f, 0.070129f, 0.091797f, 0.112549f, 0.134155f, 0.156372f, 0.177368f, 0.198975f, 0.220825f, 0.243286f,
+ 0.263916f, 0.285645f, 0.306885f, 0.327393f, 0.348145f, 0.368896f, 0.389404f, 0.409424f, 0.429199f, 0.448730f, 0.467529f, 0.486572f,
+ 0.505371f, 0.522461f, 0.540039f, 0.558105f, 0.574219f, 0.591309f, 0.607422f, 0.623535f, 0.639648f, 0.654785f, 0.669922f, 0.685547f,
+ 0.698730f, 0.712891f, 0.726074f, 0.740234f, 0.752441f, 0.765625f, 0.778320f, 0.789551f, 0.802246f, 0.813477f, 0.825195f, 0.836426f,
+ 0.847168f, 0.856934f, 0.868164f, 0.877930f, 0.888184f, 0.897461f, 0.906738f, 0.915527f, 0.925293f, 0.935059f, 0.962402f, 0.951660f,
+ 0.942383f, 0.933594f, 0.926270f, 0.919434f, 0.008934f, 0.026581f, 0.044708f, 0.063354f, 0.082825f, 0.102844f, 0.122437f, 0.141968f,
+ 0.162720f, 0.183105f, 0.202515f, 0.224609f, 0.244995f, 0.265381f, 0.285645f, 0.306152f, 0.326416f, 0.346680f, 0.365967f, 0.385498f,
+ 0.406006f, 0.425293f, 0.444092f, 0.461914f, 0.480225f, 0.499268f, 0.517090f, 0.535156f, 0.552246f, 0.568359f, 0.585449f, 0.601562f,
+ 0.616699f, 0.633789f, 0.649414f, 0.663574f, 0.678711f, 0.693848f, 0.706543f, 0.721680f, 0.734375f, 0.746582f, 0.760742f, 0.773438f,
+ 0.786133f, 0.797852f, 0.809082f, 0.821777f, 0.832031f, 0.843262f, 0.854492f, 0.864746f, 0.875000f, 0.884766f, 0.895020f, 0.904785f,
+ 0.914062f, 0.922852f, 0.957520f, 0.947266f, 0.938965f, 0.930664f, 0.923340f, 0.916992f, 0.007668f, 0.024017f, 0.040405f, 0.057831f,
+ 0.075195f, 0.093079f, 0.111694f, 0.130127f, 0.148926f, 0.168213f, 0.187500f, 0.206543f, 0.226440f, 0.246460f, 0.265869f, 0.285400f,
+ 0.305176f, 0.324707f, 0.344238f, 0.363281f, 0.383057f, 0.401123f, 0.420166f, 0.439941f, 0.457764f, 0.475586f, 0.493164f, 0.511719f,
+ 0.528809f, 0.545898f, 0.562988f, 0.579590f, 0.596191f, 0.612305f, 0.627441f, 0.643555f, 0.658203f, 0.672363f, 0.687988f, 0.702637f,
+ 0.715332f, 0.728516f, 0.742676f, 0.756348f, 0.768555f, 0.781250f, 0.794434f, 0.806152f, 0.818359f, 0.828613f, 0.840332f, 0.851074f,
+ 0.861816f, 0.872559f, 0.882812f, 0.892578f, 0.903320f, 0.912598f, 0.952637f, 0.943848f, 0.935059f, 0.927246f, 0.920410f, 0.914062f,
+ 0.007263f, 0.021530f, 0.037048f, 0.052429f, 0.068909f, 0.084961f, 0.102112f, 0.119568f, 0.136475f, 0.154541f, 0.172852f, 0.191528f,
+ 0.209717f, 0.228638f, 0.246948f, 0.265869f, 0.284912f, 0.304199f, 0.322510f, 0.341309f, 0.360596f, 0.379639f, 0.397461f, 0.416504f,
+ 0.434570f, 0.452881f, 0.470947f, 0.489014f, 0.505859f, 0.523438f, 0.541016f, 0.557129f, 0.574219f, 0.590332f, 0.606445f, 0.622070f,
+ 0.637695f, 0.653809f, 0.667969f, 0.682129f, 0.697754f, 0.711426f, 0.724609f, 0.737793f, 0.750977f, 0.765625f, 0.777832f, 0.790039f,
+ 0.801270f, 0.813477f, 0.825684f, 0.837402f, 0.848145f, 0.859375f, 0.870117f, 0.880859f, 0.891602f, 0.900391f, 0.947754f, 0.938965f,
+ 0.931152f, 0.923828f, 0.917480f, 0.911133f, 0.006401f, 0.019730f, 0.033813f, 0.047729f, 0.062561f, 0.077515f, 0.093140f, 0.108948f,
+ 0.125366f, 0.141968f, 0.159058f, 0.175781f, 0.193726f, 0.212036f, 0.229980f, 0.247681f, 0.265869f, 0.284424f, 0.302734f, 0.320557f,
+ 0.339111f, 0.357910f, 0.376221f, 0.394287f, 0.412109f, 0.429688f, 0.448486f, 0.466064f, 0.483398f, 0.500977f, 0.517090f, 0.535156f,
+ 0.552246f, 0.568359f, 0.583984f, 0.600586f, 0.616699f, 0.632324f, 0.647949f, 0.662598f, 0.677246f, 0.692383f, 0.706543f, 0.719727f,
+ 0.734375f, 0.747070f, 0.761230f, 0.773926f, 0.786621f, 0.797852f, 0.811523f, 0.823242f, 0.834961f, 0.846680f, 0.857422f, 0.868652f,
+ 0.879395f, 0.890137f, 0.942383f, 0.934082f, 0.927246f, 0.919922f, 0.913574f, 0.908203f, 0.005836f, 0.018158f, 0.030746f, 0.043335f,
+ 0.057007f, 0.070801f, 0.085754f, 0.099548f, 0.115112f, 0.130127f, 0.146362f, 0.162354f, 0.178711f, 0.195801f, 0.212769f, 0.230103f,
+ 0.247925f, 0.264893f, 0.283203f, 0.300293f, 0.318604f, 0.336426f, 0.354492f, 0.372314f, 0.390137f, 0.408203f, 0.425537f, 0.443848f,
+ 0.461182f, 0.478271f, 0.496094f, 0.513184f, 0.529297f, 0.546387f, 0.563477f, 0.580566f, 0.595703f, 0.611816f, 0.626465f, 0.642090f,
+ 0.658691f, 0.671875f, 0.686523f, 0.702148f, 0.716797f, 0.729980f, 0.744629f, 0.757324f, 0.770020f, 0.783203f, 0.796875f, 0.808105f,
+ 0.820312f, 0.832520f, 0.844727f, 0.855957f, 0.867188f, 0.877930f, 0.937012f, 0.930176f, 0.922852f, 0.916504f, 0.910645f, 0.904785f,
+ 0.005486f, 0.016525f, 0.028030f, 0.039612f, 0.052185f, 0.064636f, 0.077576f, 0.091553f, 0.105347f, 0.119568f, 0.134521f, 0.149536f,
+ 0.164917f, 0.180664f, 0.197388f, 0.213623f, 0.230347f, 0.246826f, 0.264160f, 0.280518f, 0.298584f, 0.315674f, 0.334229f, 0.350830f,
+ 0.369141f, 0.386963f, 0.404053f, 0.422119f, 0.438477f, 0.456299f, 0.474121f, 0.491211f, 0.507812f, 0.524902f, 0.541504f, 0.557617f,
+ 0.574707f, 0.590820f, 0.606934f, 0.622559f, 0.637207f, 0.652832f, 0.668945f, 0.683105f, 0.698730f, 0.711914f, 0.726074f, 0.740723f,
+ 0.753906f, 0.766602f, 0.780273f, 0.792969f, 0.805664f, 0.818848f, 0.830566f, 0.842285f, 0.854492f, 0.866211f, 0.931641f, 0.925781f,
+ 0.918945f, 0.913086f, 0.907227f, 0.900879f, 0.004810f, 0.014847f, 0.025604f, 0.036621f, 0.047577f, 0.059174f, 0.071472f, 0.084106f,
+ 0.096985f, 0.109863f, 0.124146f, 0.137939f, 0.152954f, 0.167358f, 0.182495f, 0.197754f, 0.213745f, 0.230103f, 0.246216f, 0.262939f,
+ 0.279297f, 0.296387f, 0.313477f, 0.329834f, 0.348145f, 0.365479f, 0.382080f, 0.399658f, 0.417480f, 0.434082f, 0.452148f, 0.469238f,
+ 0.486084f, 0.502441f, 0.520020f, 0.536621f, 0.552734f, 0.569336f, 0.585938f, 0.601562f, 0.617676f, 0.632812f, 0.648438f, 0.664062f,
+ 0.679688f, 0.693848f, 0.708008f, 0.722656f, 0.735840f, 0.750488f, 0.765137f, 0.777832f, 0.791016f, 0.803711f, 0.816895f, 0.829102f,
+ 0.841309f, 0.853027f, 0.925781f, 0.921387f, 0.914551f, 0.908203f, 0.903320f, 0.897461f, 0.004494f, 0.013809f, 0.023331f, 0.033264f,
+ 0.043549f, 0.053833f, 0.065369f, 0.076660f, 0.088684f, 0.100708f, 0.113464f, 0.127075f, 0.140381f, 0.154419f, 0.169067f, 0.183472f,
+ 0.198975f, 0.213623f, 0.229370f, 0.245117f, 0.261475f, 0.277832f, 0.294678f, 0.311523f, 0.327148f, 0.344727f, 0.362061f, 0.378418f,
+ 0.395996f, 0.413086f, 0.430176f, 0.447021f, 0.464111f, 0.481689f, 0.498047f, 0.514648f, 0.531738f, 0.547363f, 0.565430f, 0.582031f,
+ 0.597656f, 0.612793f, 0.628418f, 0.644043f, 0.660645f, 0.674805f, 0.689941f, 0.705078f, 0.718750f, 0.734375f, 0.747559f, 0.761719f,
+ 0.775391f, 0.788086f, 0.803223f, 0.814453f, 0.828125f, 0.840332f, 0.919434f, 0.916504f, 0.909668f, 0.904785f, 0.898926f, 0.894043f,
+ 0.004120f, 0.012512f, 0.021423f, 0.030655f, 0.039673f, 0.049500f, 0.059845f, 0.070374f, 0.081543f, 0.093323f, 0.104614f, 0.116577f,
+ 0.129395f, 0.142456f, 0.156250f, 0.169434f, 0.183594f, 0.198364f, 0.213257f, 0.228638f, 0.244141f, 0.259766f, 0.275635f, 0.291748f,
+ 0.308105f, 0.324707f, 0.341309f, 0.359131f, 0.375244f, 0.391846f, 0.408447f, 0.426025f, 0.442871f, 0.459473f, 0.477051f, 0.494141f,
+ 0.510254f, 0.527344f, 0.543457f, 0.560059f, 0.577148f, 0.592773f, 0.608887f, 0.625977f, 0.640625f, 0.656738f, 0.671875f, 0.686523f,
+ 0.702637f, 0.716797f, 0.731445f, 0.746582f, 0.759277f, 0.773926f, 0.787598f, 0.800293f, 0.814453f, 0.827148f, 0.914062f, 0.911133f,
+ 0.905273f, 0.899902f, 0.895508f, 0.890625f, 0.004120f, 0.011566f, 0.019180f, 0.027969f, 0.036255f, 0.045746f, 0.054901f, 0.064941f,
+ 0.074707f, 0.085327f, 0.096436f, 0.107239f, 0.119324f, 0.131470f, 0.144165f, 0.157104f, 0.169922f, 0.183594f, 0.198242f, 0.212769f,
+ 0.227295f, 0.242188f, 0.257568f, 0.273193f, 0.289307f, 0.305420f, 0.321289f, 0.337891f, 0.354492f, 0.371094f, 0.387451f, 0.405029f,
+ 0.421143f, 0.438477f, 0.455322f, 0.472656f, 0.488525f, 0.505859f, 0.521973f, 0.539551f, 0.555664f, 0.572754f, 0.588867f, 0.605469f,
+ 0.621582f, 0.637207f, 0.653320f, 0.668945f, 0.684570f, 0.698242f, 0.714844f, 0.729492f, 0.745117f, 0.758301f, 0.771973f, 0.787109f,
+ 0.800781f, 0.813477f, 0.907715f, 0.905762f, 0.900879f, 0.895508f, 0.890625f, 0.886719f, 0.003464f, 0.010536f, 0.018143f, 0.025604f,
+ 0.033600f, 0.041992f, 0.050659f, 0.059631f, 0.068481f, 0.078552f, 0.088196f, 0.099060f, 0.110107f, 0.121033f, 0.133057f, 0.145020f,
+ 0.157349f, 0.170166f, 0.183838f, 0.197632f, 0.210938f, 0.225464f, 0.241089f, 0.255371f, 0.270508f, 0.286377f, 0.302246f, 0.317871f,
+ 0.334229f, 0.349854f, 0.367188f, 0.383789f, 0.399414f, 0.417236f, 0.433838f, 0.450928f, 0.468018f, 0.484131f, 0.501465f, 0.519043f,
+ 0.535156f, 0.551758f, 0.568359f, 0.585449f, 0.601074f, 0.617676f, 0.634277f, 0.649902f, 0.666016f, 0.681152f, 0.695801f, 0.711914f,
+ 0.727539f, 0.741699f, 0.756836f, 0.770508f, 0.785645f, 0.800293f, 0.901855f, 0.900391f, 0.895996f, 0.891113f, 0.886230f, 0.881836f,
+ 0.003197f, 0.009903f, 0.016525f, 0.023849f, 0.030853f, 0.038605f, 0.046265f, 0.054657f, 0.063232f, 0.072266f, 0.081543f, 0.090881f,
+ 0.100769f, 0.112061f, 0.123047f, 0.134155f, 0.145752f, 0.157471f, 0.170166f, 0.182861f, 0.196289f, 0.210327f, 0.223755f, 0.238525f,
+ 0.253418f, 0.268066f, 0.283203f, 0.299316f, 0.314697f, 0.330811f, 0.346680f, 0.363281f, 0.379639f, 0.396484f, 0.412842f, 0.429443f,
+ 0.446289f, 0.462891f, 0.480225f, 0.497559f, 0.514648f, 0.531250f, 0.547852f, 0.564453f, 0.581055f, 0.598145f, 0.615234f, 0.631836f,
+ 0.646484f, 0.663086f, 0.679199f, 0.694824f, 0.710449f, 0.726074f, 0.740234f, 0.755859f, 0.770508f, 0.784668f, 0.895020f, 0.894531f,
+ 0.890625f, 0.886719f, 0.881836f, 0.877441f, 0.003071f, 0.009163f, 0.015602f, 0.021729f, 0.028412f, 0.035522f, 0.042755f, 0.050598f,
+ 0.057983f, 0.066284f, 0.075317f, 0.083862f, 0.092773f, 0.102905f, 0.113342f, 0.123840f, 0.134399f, 0.145752f, 0.157593f, 0.169556f,
+ 0.182129f, 0.194702f, 0.207886f, 0.222046f, 0.235840f, 0.250977f, 0.265137f, 0.280273f, 0.295898f, 0.311279f, 0.326660f, 0.342773f,
+ 0.359375f, 0.375732f, 0.392090f, 0.409180f, 0.425049f, 0.441895f, 0.459473f, 0.476318f, 0.493652f, 0.510742f, 0.527344f, 0.544434f,
+ 0.561035f, 0.578125f, 0.595215f, 0.611328f, 0.628418f, 0.645020f, 0.661133f, 0.677246f, 0.693359f, 0.708496f, 0.724609f, 0.740723f,
+ 0.755859f, 0.771484f, 0.889160f, 0.889160f, 0.885254f, 0.881348f, 0.876953f, 0.873047f, 0.002748f, 0.008171f, 0.014084f, 0.019638f,
+ 0.026108f, 0.032318f, 0.039154f, 0.045990f, 0.053619f, 0.061066f, 0.068665f, 0.076477f, 0.085632f, 0.094727f, 0.104187f, 0.113831f,
+ 0.123535f, 0.134888f, 0.145508f, 0.157104f, 0.168701f, 0.181030f, 0.193481f, 0.206665f, 0.220093f, 0.233398f, 0.248169f, 0.262695f,
+ 0.277344f, 0.292236f, 0.307617f, 0.322998f, 0.339355f, 0.355469f, 0.371582f, 0.388184f, 0.404541f, 0.420410f, 0.438477f, 0.455322f,
+ 0.472656f, 0.489014f, 0.506348f, 0.523926f, 0.541016f, 0.557617f, 0.575195f, 0.591309f, 0.608887f, 0.625977f, 0.643555f, 0.659180f,
+ 0.674805f, 0.691406f, 0.707520f, 0.724121f, 0.739746f, 0.755371f, 0.882812f, 0.883789f, 0.879883f, 0.875977f, 0.872559f, 0.868652f,
+ 0.002491f, 0.007809f, 0.012764f, 0.018448f, 0.024094f, 0.029861f, 0.036102f, 0.042572f, 0.049500f, 0.056091f, 0.063293f, 0.070984f,
+ 0.079285f, 0.087036f, 0.095825f, 0.104858f, 0.114441f, 0.124084f, 0.133789f, 0.144653f, 0.156250f, 0.167480f, 0.179199f, 0.191650f,
+ 0.204102f, 0.217896f, 0.231445f, 0.245239f, 0.259521f, 0.274170f, 0.289307f, 0.304199f, 0.319580f, 0.334961f, 0.351074f, 0.367676f,
+ 0.384277f, 0.400635f, 0.417480f, 0.434570f, 0.451660f, 0.468994f, 0.485352f, 0.502441f, 0.520508f, 0.537109f, 0.554688f, 0.571777f,
+ 0.588867f, 0.605957f, 0.623047f, 0.639648f, 0.656738f, 0.673828f, 0.690430f, 0.708008f, 0.723633f, 0.739746f, 0.874023f, 0.876953f,
+ 0.874023f, 0.871582f, 0.867188f, 0.862793f, 0.002279f, 0.007130f, 0.012291f, 0.016922f, 0.022171f, 0.027847f, 0.033325f, 0.039185f,
+ 0.045349f, 0.051849f, 0.058411f, 0.064880f, 0.072144f, 0.080017f, 0.087891f, 0.096313f, 0.105103f, 0.114197f, 0.123779f, 0.134155f,
+ 0.144043f, 0.155151f, 0.166016f, 0.177246f, 0.189697f, 0.202271f, 0.214722f, 0.228271f, 0.242310f, 0.256592f, 0.270752f, 0.285400f,
+ 0.300537f, 0.315674f, 0.331543f, 0.347656f, 0.363525f, 0.379639f, 0.396729f, 0.414307f, 0.430908f, 0.447754f, 0.465088f, 0.482178f,
+ 0.499512f, 0.517090f, 0.533203f, 0.552246f, 0.568848f, 0.586426f, 0.603516f, 0.621582f, 0.639648f, 0.656250f, 0.673828f, 0.690918f,
+ 0.707520f, 0.724121f, 0.867676f, 0.870605f, 0.868164f, 0.865723f, 0.861328f, 0.857910f, 0.002220f, 0.006565f, 0.011238f, 0.015961f,
+ 0.020401f, 0.025558f, 0.030853f, 0.036133f, 0.041199f, 0.047180f, 0.053436f, 0.059723f, 0.066162f, 0.073853f, 0.080688f, 0.088440f,
+ 0.096436f, 0.105042f, 0.114319f, 0.123047f, 0.132446f, 0.142822f, 0.153198f, 0.164062f, 0.175659f, 0.187378f, 0.199463f, 0.212402f,
+ 0.225464f, 0.239014f, 0.252686f, 0.266846f, 0.281494f, 0.296631f, 0.312500f, 0.328369f, 0.343750f, 0.359863f, 0.376221f, 0.393066f,
+ 0.409668f, 0.426514f, 0.444336f, 0.461670f, 0.478760f, 0.496826f, 0.513672f, 0.532227f, 0.549316f, 0.567383f, 0.584961f, 0.602051f,
+ 0.620605f, 0.637207f, 0.655273f, 0.672363f, 0.689941f, 0.708008f, 0.860840f, 0.864746f, 0.862793f, 0.859375f, 0.855957f, 0.853027f,
+ 0.002190f, 0.005993f, 0.010117f, 0.014420f, 0.018738f, 0.023361f, 0.028015f, 0.033142f, 0.037781f, 0.043732f, 0.048920f, 0.054840f,
+ 0.061218f, 0.067810f, 0.074219f, 0.081299f, 0.088562f, 0.096130f, 0.104614f, 0.113098f, 0.122253f, 0.131714f, 0.141113f, 0.151245f,
+ 0.162109f, 0.173462f, 0.184692f, 0.196899f, 0.209473f, 0.222534f, 0.236206f, 0.249634f, 0.263672f, 0.277588f, 0.293213f, 0.308350f,
+ 0.323975f, 0.339844f, 0.355957f, 0.372070f, 0.389404f, 0.405762f, 0.422852f, 0.439941f, 0.458008f, 0.475098f, 0.492920f, 0.510742f,
+ 0.528320f, 0.546875f, 0.564453f, 0.583496f, 0.601074f, 0.619141f, 0.636719f, 0.654785f, 0.672852f, 0.691406f, 0.852539f, 0.858398f,
+ 0.856445f, 0.853516f, 0.850586f, 0.847656f, 0.001787f, 0.005753f, 0.009300f, 0.013611f, 0.017410f, 0.021576f, 0.025665f, 0.030533f,
+ 0.035126f, 0.040039f, 0.044952f, 0.050446f, 0.055817f, 0.061890f, 0.068054f, 0.074707f, 0.081482f, 0.088501f, 0.095764f, 0.103943f,
+ 0.112183f, 0.120850f, 0.130249f, 0.139526f, 0.149658f, 0.160400f, 0.171021f, 0.182007f, 0.194336f, 0.206421f, 0.219360f, 0.232666f,
+ 0.245850f, 0.260010f, 0.274170f, 0.289307f, 0.304443f, 0.319580f, 0.335693f, 0.352295f, 0.369141f, 0.385498f, 0.402344f, 0.419189f,
+ 0.437012f, 0.454346f, 0.472412f, 0.490234f, 0.507812f, 0.525879f, 0.545410f, 0.562500f, 0.581055f, 0.600098f, 0.618164f, 0.636719f,
+ 0.655273f, 0.674316f, 0.845703f, 0.852051f, 0.849609f, 0.847168f, 0.845215f, 0.841309f, 0.001766f, 0.005241f, 0.008881f, 0.012024f,
+ 0.016129f, 0.020233f, 0.024124f, 0.027664f, 0.032135f, 0.036835f, 0.041321f, 0.046173f, 0.051392f, 0.056946f, 0.062225f, 0.068604f,
+ 0.074524f, 0.080933f, 0.088135f, 0.095398f, 0.103210f, 0.110779f, 0.119263f, 0.128296f, 0.137695f, 0.147217f, 0.157349f, 0.168091f,
+ 0.179688f, 0.191284f, 0.203613f, 0.215942f, 0.228882f, 0.242554f, 0.255859f, 0.270508f, 0.285400f, 0.300537f, 0.316406f, 0.331787f,
+ 0.348877f, 0.364746f, 0.382080f, 0.398682f, 0.415771f, 0.434082f, 0.451416f, 0.469482f, 0.487793f, 0.505859f, 0.524414f, 0.542969f,
+ 0.562012f, 0.580566f, 0.598145f, 0.618652f, 0.637695f, 0.657227f, 0.837891f, 0.844727f, 0.843750f, 0.841309f, 0.838379f, 0.836426f,
+ 0.001598f, 0.004887f, 0.008217f, 0.011497f, 0.014786f, 0.018326f, 0.021652f, 0.025513f, 0.029541f, 0.033813f, 0.038086f, 0.042236f,
+ 0.046844f, 0.052032f, 0.057251f, 0.062622f, 0.068237f, 0.074280f, 0.080505f, 0.086975f, 0.094116f, 0.101074f, 0.109314f, 0.117554f,
+ 0.126587f, 0.135254f, 0.144775f, 0.155029f, 0.165405f, 0.176392f, 0.187744f, 0.199829f, 0.212646f, 0.224976f, 0.238647f, 0.252441f,
+ 0.267090f, 0.281738f, 0.296631f, 0.312256f, 0.328369f, 0.344971f, 0.361328f, 0.377686f, 0.395264f, 0.412842f, 0.430908f, 0.448730f,
+ 0.467041f, 0.485596f, 0.503906f, 0.522461f, 0.541504f, 0.561523f, 0.580078f, 0.599121f, 0.618164f, 0.639648f, 0.828613f, 0.837891f,
+ 0.836914f, 0.834473f, 0.833008f, 0.830566f, 0.001709f, 0.004494f, 0.007416f, 0.010628f, 0.013680f, 0.016785f, 0.020203f, 0.023712f,
+ 0.027435f, 0.031006f, 0.034424f, 0.038635f, 0.043182f, 0.047668f, 0.052307f, 0.057159f, 0.062042f, 0.067749f, 0.073730f, 0.079956f,
+ 0.086182f, 0.092773f, 0.100159f, 0.107727f, 0.115479f, 0.123962f, 0.132935f, 0.142578f, 0.151978f, 0.162476f, 0.173340f, 0.184570f,
+ 0.196411f, 0.208740f, 0.221436f, 0.235229f, 0.248779f, 0.262939f, 0.277832f, 0.293213f, 0.308105f, 0.324219f, 0.341309f, 0.357178f,
+ 0.374756f, 0.391846f, 0.409424f, 0.427490f, 0.446533f, 0.464844f, 0.483643f, 0.501953f, 0.521484f, 0.541504f, 0.561035f, 0.579590f,
+ 0.599609f, 0.620605f, 0.821289f, 0.830566f, 0.830078f, 0.828125f, 0.825684f, 0.823242f, 0.001367f, 0.004105f, 0.007023f, 0.009552f,
+ 0.012611f, 0.015289f, 0.018341f, 0.021652f, 0.024857f, 0.027878f, 0.031769f, 0.035614f, 0.039276f, 0.043610f, 0.047333f, 0.052155f,
+ 0.056549f, 0.061401f, 0.066895f, 0.072449f, 0.078613f, 0.084778f, 0.091309f, 0.098083f, 0.105774f, 0.113281f, 0.121399f, 0.130371f,
+ 0.139648f, 0.148926f, 0.159546f, 0.169922f, 0.180908f, 0.192749f, 0.204834f, 0.217651f, 0.231567f, 0.244385f, 0.259277f, 0.273926f,
+ 0.289307f, 0.304688f, 0.320557f, 0.336914f, 0.354248f, 0.371338f, 0.388184f, 0.406982f, 0.424316f, 0.443115f, 0.462646f, 0.481445f,
+ 0.501465f, 0.520508f, 0.541016f, 0.559570f, 0.580078f, 0.601074f, 0.812988f, 0.823242f, 0.823242f, 0.821289f, 0.819824f, 0.817383f,
+ 0.001398f, 0.003883f, 0.006351f, 0.008911f, 0.011559f, 0.014343f, 0.017212f, 0.020035f, 0.022797f, 0.026062f, 0.028793f, 0.031891f,
+ 0.035858f, 0.039368f, 0.043213f, 0.047607f, 0.051483f, 0.056030f, 0.060883f, 0.065979f, 0.071350f, 0.076843f, 0.083130f, 0.089172f,
+ 0.096069f, 0.103333f, 0.111023f, 0.119019f, 0.127319f, 0.136719f, 0.145996f, 0.156128f, 0.166138f, 0.177368f, 0.189453f, 0.201416f,
+ 0.213745f, 0.227295f, 0.240601f, 0.255371f, 0.269287f, 0.285400f, 0.301270f, 0.317139f, 0.333740f, 0.350586f, 0.367920f, 0.385986f,
+ 0.404297f, 0.422852f, 0.442383f, 0.460938f, 0.479980f, 0.500488f, 0.520508f, 0.541016f, 0.560547f, 0.582520f, 0.803711f, 0.814941f,
+ 0.815430f, 0.814453f, 0.812500f, 0.810547f, 0.001259f, 0.003464f, 0.006332f, 0.008286f, 0.010384f, 0.013000f, 0.015587f, 0.018234f,
+ 0.021027f, 0.023422f, 0.026566f, 0.029480f, 0.032379f, 0.035919f, 0.039215f, 0.043060f, 0.046997f, 0.050995f, 0.055267f, 0.059998f,
+ 0.065002f, 0.069946f, 0.075317f, 0.081299f, 0.087280f, 0.094116f, 0.101135f, 0.108276f, 0.116150f, 0.124695f, 0.133545f, 0.142700f,
+ 0.152222f, 0.162720f, 0.173950f, 0.185303f, 0.197754f, 0.210205f, 0.223022f, 0.237061f, 0.250732f, 0.265869f, 0.281250f, 0.297119f,
+ 0.313477f, 0.330322f, 0.347656f, 0.364746f, 0.383301f, 0.401367f, 0.420898f, 0.440186f, 0.459229f, 0.479736f, 0.499512f, 0.520996f,
+ 0.541016f, 0.562988f, 0.794434f, 0.807129f, 0.807617f, 0.807129f, 0.805176f, 0.803711f, 0.001070f, 0.003237f, 0.005432f, 0.007359f,
+ 0.009857f, 0.012337f, 0.014191f, 0.016586f, 0.019257f, 0.021561f, 0.024094f, 0.026901f, 0.029724f, 0.032745f, 0.035675f, 0.039368f,
+ 0.042572f, 0.045990f, 0.050354f, 0.054535f, 0.058746f, 0.063232f, 0.068420f, 0.073608f, 0.079529f, 0.085266f, 0.091370f, 0.098083f,
+ 0.105835f, 0.113159f, 0.121094f, 0.129639f, 0.139038f, 0.148926f, 0.159058f, 0.169678f, 0.181274f, 0.193481f, 0.205811f, 0.219482f,
+ 0.233032f, 0.247192f, 0.262207f, 0.277100f, 0.293213f, 0.309814f, 0.326660f, 0.344238f, 0.361816f, 0.380615f, 0.398926f, 0.418945f,
+ 0.438477f, 0.458008f, 0.479004f, 0.499512f, 0.520996f, 0.543945f, 0.784668f, 0.798828f, 0.800293f, 0.799805f, 0.797852f, 0.796875f,
+ 0.001074f, 0.002916f, 0.004955f, 0.007149f, 0.009033f, 0.011055f, 0.013268f, 0.015495f, 0.017365f, 0.019485f, 0.022095f, 0.024002f,
+ 0.026688f, 0.029633f, 0.032593f, 0.035370f, 0.038361f, 0.041870f, 0.045319f, 0.049225f, 0.052948f, 0.057068f, 0.061676f, 0.066345f,
+ 0.071167f, 0.076782f, 0.082581f, 0.088867f, 0.095886f, 0.102539f, 0.109802f, 0.118042f, 0.126709f, 0.135132f, 0.144897f, 0.155151f,
+ 0.165771f, 0.177368f, 0.189209f, 0.201904f, 0.215210f, 0.229370f, 0.242798f, 0.258057f, 0.274170f, 0.290039f, 0.306885f, 0.323242f,
+ 0.341309f, 0.359375f, 0.378418f, 0.397461f, 0.416260f, 0.437500f, 0.457031f, 0.479004f, 0.501465f, 0.522461f, 0.775391f, 0.790527f,
+ 0.791992f, 0.791504f, 0.791016f, 0.789551f, 0.000837f, 0.002916f, 0.004738f, 0.006477f, 0.008575f, 0.010170f, 0.012161f, 0.014023f,
+ 0.015808f, 0.017792f, 0.020111f, 0.022064f, 0.024414f, 0.026794f, 0.029251f, 0.032074f, 0.034698f, 0.037598f, 0.040741f, 0.043915f,
+ 0.047577f, 0.051361f, 0.055389f, 0.059692f, 0.064209f, 0.068787f, 0.074585f, 0.079712f, 0.085632f, 0.092346f, 0.099487f, 0.106323f,
+ 0.114929f, 0.122925f, 0.131958f, 0.141235f, 0.151123f, 0.161865f, 0.172974f, 0.184937f, 0.197632f, 0.210693f, 0.224854f, 0.239136f,
+ 0.254395f, 0.269531f, 0.285889f, 0.302979f, 0.320557f, 0.338623f, 0.356689f, 0.375977f, 0.395752f, 0.415527f, 0.436523f, 0.458252f,
+ 0.479248f, 0.501465f, 0.765137f, 0.781738f, 0.783691f, 0.784180f, 0.783203f, 0.781250f, 0.000854f, 0.002817f, 0.004089f, 0.005684f,
+ 0.007675f, 0.009277f, 0.010864f, 0.012413f, 0.014427f, 0.016235f, 0.017838f, 0.019913f, 0.021805f, 0.023987f, 0.026276f, 0.028915f,
+ 0.030960f, 0.033875f, 0.036652f, 0.039551f, 0.042816f, 0.045837f, 0.049591f, 0.053589f, 0.057526f, 0.061829f, 0.066650f, 0.071655f,
+ 0.077393f, 0.083008f, 0.088989f, 0.096008f, 0.103210f, 0.110657f, 0.119141f, 0.127930f, 0.137085f, 0.146973f, 0.157593f, 0.169312f,
+ 0.181274f, 0.193481f, 0.207031f, 0.220581f, 0.235229f, 0.250732f, 0.266357f, 0.282227f, 0.299805f, 0.317627f, 0.335449f, 0.354736f,
+ 0.374268f, 0.394531f, 0.415527f, 0.436279f, 0.458252f, 0.481689f, 0.754883f, 0.773438f, 0.775391f, 0.775879f, 0.774902f, 0.773926f,
+ 0.000852f, 0.002520f, 0.003937f, 0.005527f, 0.006836f, 0.008408f, 0.009773f, 0.011620f, 0.013039f, 0.014687f, 0.016327f, 0.017944f,
+ 0.019760f, 0.021774f, 0.023697f, 0.025894f, 0.027969f, 0.030121f, 0.032501f, 0.035370f, 0.038208f, 0.041046f, 0.044098f, 0.047791f,
+ 0.051453f, 0.055176f, 0.059570f, 0.064026f, 0.068787f, 0.074158f, 0.079834f, 0.085938f, 0.092590f, 0.099304f, 0.106873f, 0.114990f,
+ 0.124023f, 0.133301f, 0.143066f, 0.153687f, 0.164551f, 0.176392f, 0.189209f, 0.202637f, 0.216553f, 0.231323f, 0.246704f, 0.262451f,
+ 0.279297f, 0.296387f, 0.314697f, 0.333496f, 0.353516f, 0.373047f, 0.394775f, 0.415039f, 0.437500f, 0.460449f, 0.745117f, 0.763672f,
+ 0.766602f, 0.767090f, 0.767090f, 0.765625f, 0.000762f, 0.002342f, 0.003563f, 0.004787f, 0.006447f, 0.007648f, 0.009193f, 0.010353f,
+ 0.012016f, 0.013138f, 0.014557f, 0.016312f, 0.017929f, 0.019470f, 0.021103f, 0.023056f, 0.024918f, 0.026886f, 0.029099f, 0.031586f,
+ 0.034058f, 0.036499f, 0.039307f, 0.042450f, 0.045685f, 0.049072f, 0.052826f, 0.056915f, 0.061096f, 0.065918f, 0.070984f, 0.076538f,
+ 0.082520f, 0.088928f, 0.095520f, 0.102905f, 0.111206f, 0.119629f, 0.128662f, 0.138184f, 0.148682f, 0.160156f, 0.171997f, 0.184937f,
+ 0.198364f, 0.212524f, 0.227173f, 0.243042f, 0.259277f, 0.276611f, 0.294189f, 0.312500f, 0.331055f, 0.350830f, 0.372070f, 0.392334f,
+ 0.415771f, 0.438232f, 0.734375f, 0.754395f, 0.758789f, 0.758789f, 0.758789f, 0.757812f, 0.000848f, 0.002024f, 0.003553f, 0.004646f,
+ 0.005726f, 0.007050f, 0.008362f, 0.009438f, 0.010536f, 0.011810f, 0.013123f, 0.014481f, 0.015778f, 0.017242f, 0.018753f, 0.020447f,
+ 0.022278f, 0.023819f, 0.025940f, 0.027771f, 0.029999f, 0.032410f, 0.034851f, 0.037354f, 0.040375f, 0.043610f, 0.046631f, 0.050354f,
+ 0.054108f, 0.058563f, 0.062805f, 0.067871f, 0.073242f, 0.078796f, 0.085083f, 0.091797f, 0.098816f, 0.106689f, 0.115540f, 0.124207f,
+ 0.134155f, 0.144409f, 0.155762f, 0.167725f, 0.180664f, 0.193848f, 0.208618f, 0.223389f, 0.239746f, 0.256104f, 0.273438f, 0.291260f,
+ 0.310059f, 0.330078f, 0.349854f, 0.370850f, 0.393555f, 0.416992f, 0.724121f, 0.744629f, 0.748535f, 0.750000f, 0.749512f, 0.749512f,
+ 0.000736f, 0.001780f, 0.002937f, 0.004314f, 0.005211f, 0.006214f, 0.007423f, 0.008537f, 0.009392f, 0.010773f, 0.011726f, 0.012970f,
+ 0.014183f, 0.015373f, 0.016724f, 0.017990f, 0.019730f, 0.021194f, 0.022644f, 0.024368f, 0.026443f, 0.028610f, 0.030685f, 0.032898f,
+ 0.035583f, 0.038300f, 0.041351f, 0.044556f, 0.047638f, 0.051422f, 0.055359f, 0.059875f, 0.064392f, 0.069580f, 0.075195f, 0.080872f,
+ 0.087646f, 0.094849f, 0.102173f, 0.110596f, 0.119690f, 0.129761f, 0.139893f, 0.151367f, 0.163452f, 0.176147f, 0.190063f, 0.204590f,
+ 0.219238f, 0.235718f, 0.252441f, 0.270264f, 0.289062f, 0.307861f, 0.328613f, 0.350098f, 0.372314f, 0.395020f, 0.712402f, 0.734863f,
+ 0.739746f, 0.740723f, 0.740723f, 0.740234f, 0.000589f, 0.001616f, 0.002674f, 0.003841f, 0.004940f, 0.005676f, 0.006554f, 0.007442f,
+ 0.008812f, 0.009537f, 0.010277f, 0.011528f, 0.012634f, 0.013527f, 0.014671f, 0.016037f, 0.017136f, 0.018631f, 0.019943f, 0.021530f,
+ 0.023071f, 0.025146f, 0.026825f, 0.029037f, 0.030853f, 0.033447f, 0.035736f, 0.038849f, 0.041656f, 0.044922f, 0.048462f, 0.052277f,
+ 0.056519f, 0.061127f, 0.065796f, 0.071411f, 0.077148f, 0.083435f, 0.090393f, 0.097900f, 0.106079f, 0.115356f, 0.125122f, 0.135132f,
+ 0.146729f, 0.158936f, 0.171509f, 0.185059f, 0.200439f, 0.215576f, 0.232056f, 0.249756f, 0.267822f, 0.286621f, 0.306885f, 0.328125f,
+ 0.349854f, 0.373291f, 0.701172f, 0.725586f, 0.729980f, 0.730957f, 0.731934f, 0.730957f, 0.000547f, 0.001666f, 0.002367f, 0.003559f,
+ 0.004238f, 0.005028f, 0.005852f, 0.006859f, 0.007755f, 0.008530f, 0.009163f, 0.010056f, 0.010956f, 0.011978f, 0.013062f, 0.014076f,
+ 0.015053f, 0.016251f, 0.017471f, 0.018921f, 0.020233f, 0.021774f, 0.023315f, 0.025162f, 0.026871f, 0.029007f, 0.031204f, 0.033661f,
+ 0.036102f, 0.039062f, 0.042053f, 0.045380f, 0.048859f, 0.053040f, 0.057343f, 0.062225f, 0.067261f, 0.073120f, 0.079407f, 0.086243f,
+ 0.093567f, 0.101868f, 0.110596f, 0.120239f, 0.130859f, 0.141968f, 0.154053f, 0.167358f, 0.181274f, 0.196045f, 0.212158f, 0.229248f,
+ 0.247192f, 0.265381f, 0.285400f, 0.305664f, 0.327637f, 0.350586f, 0.689453f, 0.715820f, 0.720215f, 0.722168f, 0.722168f, 0.722168f,
+ 0.000492f, 0.001634f, 0.002342f, 0.003111f, 0.003866f, 0.004574f, 0.005417f, 0.005928f, 0.006588f, 0.007393f, 0.008041f, 0.008873f,
+ 0.009689f, 0.010391f, 0.011375f, 0.012146f, 0.013100f, 0.014183f, 0.015274f, 0.016479f, 0.017456f, 0.018768f, 0.020157f, 0.021606f,
+ 0.023300f, 0.024933f, 0.026855f, 0.028885f, 0.031143f, 0.033417f, 0.036133f, 0.039032f, 0.042236f, 0.045776f, 0.049713f, 0.053680f,
+ 0.058228f, 0.063232f, 0.069092f, 0.074829f, 0.081482f, 0.089050f, 0.096924f, 0.105591f, 0.115417f, 0.126221f, 0.137329f, 0.149658f,
+ 0.162964f, 0.176880f, 0.192505f, 0.208740f, 0.226318f, 0.244873f, 0.263428f, 0.283936f, 0.306396f, 0.329346f, 0.676270f, 0.705078f,
+ 0.709961f, 0.711914f, 0.712891f, 0.711914f, 0.000506f, 0.001342f, 0.002157f, 0.002813f, 0.003353f, 0.004105f, 0.004658f, 0.005344f,
+ 0.005871f, 0.006538f, 0.007050f, 0.007751f, 0.008247f, 0.009109f, 0.009865f, 0.010559f, 0.011269f, 0.012169f, 0.013290f, 0.014191f,
+ 0.015015f, 0.016312f, 0.017395f, 0.018570f, 0.019989f, 0.021439f, 0.023102f, 0.024536f, 0.026535f, 0.028702f, 0.030899f, 0.033356f,
+ 0.035980f, 0.039093f, 0.042328f, 0.046051f, 0.049927f, 0.054199f, 0.059052f, 0.064575f, 0.070496f, 0.076782f, 0.084412f, 0.092285f,
+ 0.100708f, 0.110779f, 0.121399f, 0.132690f, 0.145508f, 0.158813f, 0.173584f, 0.189453f, 0.205688f, 0.223755f, 0.242554f, 0.263184f,
+ 0.284180f, 0.306641f, 0.664551f, 0.693848f, 0.699707f, 0.702148f, 0.702637f, 0.703125f, 0.000500f, 0.001122f, 0.001810f, 0.002363f,
+ 0.002987f, 0.003576f, 0.004158f, 0.004620f, 0.005032f, 0.005627f, 0.006161f, 0.006721f, 0.007179f, 0.007790f, 0.008385f, 0.009163f,
+ 0.009758f, 0.010536f, 0.011284f, 0.011986f, 0.012878f, 0.013710f, 0.014725f, 0.015823f, 0.016937f, 0.018326f, 0.019547f, 0.020874f,
+ 0.022522f, 0.024399f, 0.026077f, 0.028427f, 0.030609f, 0.032990f, 0.035736f, 0.038788f, 0.042236f, 0.045990f, 0.050354f, 0.054901f,
+ 0.059967f, 0.065918f, 0.072205f, 0.079468f, 0.087219f, 0.096252f, 0.105713f, 0.116272f, 0.128174f, 0.140747f, 0.154419f, 0.169556f,
+ 0.186279f, 0.203125f, 0.221313f, 0.240601f, 0.261719f, 0.284424f, 0.652344f, 0.683105f, 0.688965f, 0.691406f, 0.692383f, 0.693359f,
+ 0.000482f, 0.001184f, 0.001604f, 0.002171f, 0.002562f, 0.003029f, 0.003656f, 0.003941f, 0.004410f, 0.004948f, 0.005325f, 0.005577f,
+ 0.006157f, 0.006702f, 0.007172f, 0.007751f, 0.008331f, 0.008904f, 0.009514f, 0.010063f, 0.010925f, 0.011719f, 0.012306f, 0.013321f,
+ 0.014275f, 0.015465f, 0.016510f, 0.017593f, 0.018845f, 0.020401f, 0.022095f, 0.023682f, 0.025513f, 0.027679f, 0.029968f, 0.032593f,
+ 0.035461f, 0.038757f, 0.042175f, 0.046326f, 0.050873f, 0.055939f, 0.061462f, 0.067444f, 0.074402f, 0.082520f, 0.091125f, 0.100830f,
+ 0.111572f, 0.123413f, 0.136719f, 0.150513f, 0.165894f, 0.182251f, 0.200684f, 0.219727f, 0.240234f, 0.261963f, 0.640137f, 0.671387f,
+ 0.679199f, 0.680664f, 0.682617f, 0.683105f, 0.000501f, 0.000919f, 0.001424f, 0.001853f, 0.002266f, 0.002789f, 0.002998f, 0.003397f,
+ 0.003902f, 0.004192f, 0.004417f, 0.004974f, 0.005207f, 0.005676f, 0.006134f, 0.006527f, 0.007179f, 0.007465f, 0.008018f, 0.008537f,
+ 0.009178f, 0.009888f, 0.010544f, 0.011093f, 0.011986f, 0.012794f, 0.013664f, 0.014717f, 0.015747f, 0.016983f, 0.018127f, 0.019470f,
+ 0.021103f, 0.022919f, 0.024826f, 0.026962f, 0.029358f, 0.031769f, 0.035065f, 0.038239f, 0.042297f, 0.046570f, 0.051422f, 0.056671f,
+ 0.062805f, 0.069763f, 0.077698f, 0.086182f, 0.095825f, 0.106812f, 0.119080f, 0.132568f, 0.147217f, 0.162598f, 0.180176f, 0.198730f,
+ 0.218628f, 0.241211f, 0.627441f, 0.660156f, 0.668457f, 0.669922f, 0.672363f, 0.671875f, 0.000235f, 0.001120f, 0.001356f, 0.001651f,
+ 0.002117f, 0.002441f, 0.002678f, 0.002993f, 0.003244f, 0.003519f, 0.003876f, 0.004086f, 0.004505f, 0.004787f, 0.005085f, 0.005604f,
+ 0.005985f, 0.006271f, 0.006783f, 0.007145f, 0.007679f, 0.008217f, 0.008728f, 0.009277f, 0.009956f, 0.010605f, 0.011490f, 0.012062f,
+ 0.013084f, 0.013962f, 0.014984f, 0.016113f, 0.017395f, 0.018829f, 0.020416f, 0.022125f, 0.023972f, 0.025955f, 0.028625f, 0.031616f,
+ 0.034515f, 0.038147f, 0.042114f, 0.046783f, 0.052094f, 0.058075f, 0.065002f, 0.072510f, 0.081604f, 0.091125f, 0.102539f, 0.114807f,
+ 0.128662f, 0.143921f, 0.160034f, 0.178467f, 0.198364f, 0.218750f, 0.613281f, 0.648926f, 0.657227f, 0.659668f, 0.661621f, 0.661621f,
+ 0.000382f, 0.000704f, 0.001099f, 0.001557f, 0.001774f, 0.001976f, 0.002132f, 0.002575f, 0.002634f, 0.002916f, 0.003103f, 0.003494f,
+ 0.003754f, 0.003956f, 0.004269f, 0.004684f, 0.004902f, 0.005234f, 0.005569f, 0.005890f, 0.006416f, 0.006786f, 0.007160f, 0.007645f,
+ 0.008118f, 0.008781f, 0.009346f, 0.010025f, 0.010658f, 0.011475f, 0.012230f, 0.013016f, 0.014122f, 0.015251f, 0.016342f, 0.017807f,
+ 0.019424f, 0.021103f, 0.023026f, 0.025436f, 0.027817f, 0.030914f, 0.034210f, 0.037750f, 0.042450f, 0.047455f, 0.053101f, 0.059998f,
+ 0.067688f, 0.076660f, 0.086670f, 0.097961f, 0.110779f, 0.125366f, 0.140747f, 0.158081f, 0.176880f, 0.197632f, 0.600098f, 0.637207f,
+ 0.644531f, 0.647949f, 0.649414f, 0.651855f, 0.000182f, 0.000738f, 0.000942f, 0.001220f, 0.001469f, 0.001634f, 0.001820f, 0.002005f,
+ 0.002291f, 0.002441f, 0.002636f, 0.002832f, 0.003019f, 0.003242f, 0.003502f, 0.003824f, 0.004017f, 0.004333f, 0.004570f, 0.004883f,
+ 0.005173f, 0.005615f, 0.005909f, 0.006317f, 0.006649f, 0.007160f, 0.007656f, 0.008156f, 0.008583f, 0.009209f, 0.009857f, 0.010696f,
+ 0.011322f, 0.012367f, 0.013229f, 0.014259f, 0.015686f, 0.016815f, 0.018402f, 0.020126f, 0.022095f, 0.024414f, 0.027176f, 0.030273f,
+ 0.033722f, 0.038086f, 0.042969f, 0.048645f, 0.055237f, 0.063171f, 0.071960f, 0.082031f, 0.093994f, 0.107300f, 0.122131f, 0.138550f,
+ 0.156494f, 0.177002f, 0.586426f, 0.625488f, 0.633789f, 0.637207f, 0.638672f, 0.639648f, 0.000199f, 0.000534f, 0.000745f, 0.000995f,
+ 0.001190f, 0.001387f, 0.001516f, 0.001691f, 0.001790f, 0.001941f, 0.002214f, 0.002346f, 0.002449f, 0.002686f, 0.002832f, 0.003042f,
+ 0.003304f, 0.003531f, 0.003662f, 0.003952f, 0.004181f, 0.004517f, 0.004704f, 0.005074f, 0.005352f, 0.005718f, 0.006096f, 0.006481f,
+ 0.006947f, 0.007454f, 0.007988f, 0.008484f, 0.009140f, 0.009804f, 0.010475f, 0.011307f, 0.012299f, 0.013268f, 0.014511f, 0.015823f,
+ 0.017410f, 0.018936f, 0.021225f, 0.023621f, 0.026367f, 0.029770f, 0.033661f, 0.038452f, 0.044067f, 0.050812f, 0.058411f, 0.067444f,
+ 0.077942f, 0.090149f, 0.104187f, 0.119812f, 0.137085f, 0.156372f, 0.572754f, 0.613770f, 0.621582f, 0.625977f, 0.627441f, 0.628906f,
+ 0.000165f, 0.000486f, 0.000618f, 0.000880f, 0.001063f, 0.001140f, 0.001258f, 0.001464f, 0.001498f, 0.001561f, 0.001707f, 0.001899f,
+ 0.001976f, 0.002171f, 0.002285f, 0.002474f, 0.002571f, 0.002764f, 0.002968f, 0.003170f, 0.003389f, 0.003580f, 0.003822f, 0.004036f,
+ 0.004269f, 0.004505f, 0.004738f, 0.005157f, 0.005474f, 0.005821f, 0.006279f, 0.006649f, 0.007107f, 0.007610f, 0.008240f, 0.008835f,
+ 0.009598f, 0.010361f, 0.011276f, 0.012299f, 0.013466f, 0.014740f, 0.016251f, 0.018021f, 0.020294f, 0.022797f, 0.025833f, 0.029739f,
+ 0.034058f, 0.039612f, 0.046021f, 0.053833f, 0.063110f, 0.074158f, 0.086914f, 0.101562f, 0.118164f, 0.136841f, 0.558594f, 0.601074f,
+ 0.608887f, 0.613281f, 0.615234f, 0.617188f, 0.000096f, 0.000348f, 0.000585f, 0.000707f, 0.000837f, 0.000866f, 0.000972f, 0.001095f,
+ 0.001198f, 0.001309f, 0.001355f, 0.001417f, 0.001615f, 0.001740f, 0.001863f, 0.001880f, 0.002048f, 0.002159f, 0.002380f, 0.002487f,
+ 0.002613f, 0.002777f, 0.003000f, 0.003143f, 0.003353f, 0.003521f, 0.003748f, 0.003963f, 0.004265f, 0.004490f, 0.004776f, 0.005093f,
+ 0.005577f, 0.005966f, 0.006321f, 0.006828f, 0.007320f, 0.007904f, 0.008575f, 0.009392f, 0.010231f, 0.011276f, 0.012321f, 0.013832f,
+ 0.015343f, 0.017242f, 0.019501f, 0.022247f, 0.025696f, 0.029922f, 0.035187f, 0.041779f, 0.049683f, 0.059387f, 0.070801f, 0.084106f,
+ 0.100037f, 0.117798f, 0.544434f, 0.588867f, 0.597656f, 0.602539f, 0.604492f, 0.605469f, 0.000123f, 0.000248f, 0.000443f, 0.000625f,
+ 0.000663f, 0.000733f, 0.000843f, 0.000780f, 0.000921f, 0.000986f, 0.001081f, 0.001178f, 0.001254f, 0.001348f, 0.001364f, 0.001515f,
+ 0.001565f, 0.001705f, 0.001824f, 0.001870f, 0.002066f, 0.002155f, 0.002274f, 0.002422f, 0.002525f, 0.002695f, 0.002863f, 0.003038f,
+ 0.003271f, 0.003441f, 0.003736f, 0.003901f, 0.004112f, 0.004478f, 0.004719f, 0.005093f, 0.005482f, 0.005913f, 0.006413f, 0.007019f,
+ 0.007626f, 0.008408f, 0.009201f, 0.010201f, 0.011436f, 0.012749f, 0.014389f, 0.016373f, 0.018906f, 0.022034f, 0.025909f, 0.031082f,
+ 0.037628f, 0.045715f, 0.055939f, 0.068176f, 0.082764f, 0.099365f, 0.529785f, 0.574707f, 0.584961f, 0.589844f, 0.591797f, 0.593750f,
+ 0.000210f, 0.000212f, 0.000365f, 0.000494f, 0.000438f, 0.000597f, 0.000538f, 0.000623f, 0.000638f, 0.000736f, 0.000866f, 0.000882f,
+ 0.000954f, 0.001040f, 0.001070f, 0.001086f, 0.001220f, 0.001274f, 0.001341f, 0.001457f, 0.001513f, 0.001598f, 0.001697f, 0.001781f,
+ 0.001898f, 0.001970f, 0.002131f, 0.002241f, 0.002401f, 0.002645f, 0.002783f, 0.002892f, 0.003120f, 0.003347f, 0.003508f, 0.003757f,
+ 0.004032f, 0.004314f, 0.004688f, 0.005066f, 0.005520f, 0.006012f, 0.006702f, 0.007332f, 0.008171f, 0.009140f, 0.010399f, 0.011787f,
+ 0.013496f, 0.015732f, 0.018509f, 0.022278f, 0.027267f, 0.033813f, 0.042328f, 0.053070f, 0.066406f, 0.082825f, 0.516602f, 0.562500f,
+ 0.573242f, 0.577637f, 0.580078f, 0.581543f, 0.000000f, 0.000216f, 0.000281f, 0.000346f, 0.000374f, 0.000388f, 0.000491f, 0.000416f,
+ 0.000516f, 0.000535f, 0.000635f, 0.000625f, 0.000681f, 0.000719f, 0.000790f, 0.000813f, 0.000879f, 0.000926f, 0.000968f, 0.001004f,
+ 0.001097f, 0.001135f, 0.001229f, 0.001300f, 0.001361f, 0.001431f, 0.001541f, 0.001610f, 0.001711f, 0.001802f, 0.001922f, 0.002094f,
+ 0.002169f, 0.002346f, 0.002468f, 0.002644f, 0.002844f, 0.003094f, 0.003368f, 0.003586f, 0.003883f, 0.004223f, 0.004662f, 0.005093f,
+ 0.005680f, 0.006348f, 0.007206f, 0.008202f, 0.009392f, 0.010895f, 0.012939f, 0.015465f, 0.018906f, 0.023682f, 0.030502f, 0.039825f,
+ 0.051331f, 0.066528f, 0.500977f, 0.548828f, 0.560059f, 0.564453f, 0.567871f, 0.569336f, 0.000000f, 0.000106f, 0.000201f, 0.000252f,
+ 0.000251f, 0.000322f, 0.000281f, 0.000340f, 0.000359f, 0.000428f, 0.000443f, 0.000419f, 0.000444f, 0.000500f, 0.000524f, 0.000590f,
+ 0.000574f, 0.000650f, 0.000693f, 0.000732f, 0.000778f, 0.000821f, 0.000848f, 0.000900f, 0.000965f, 0.000982f, 0.001072f, 0.001109f,
+ 0.001169f, 0.001307f, 0.001301f, 0.001409f, 0.001483f, 0.001610f, 0.001734f, 0.001835f, 0.001940f, 0.002098f, 0.002241f, 0.002426f,
+ 0.002634f, 0.002865f, 0.003136f, 0.003431f, 0.003763f, 0.004211f, 0.004742f, 0.005417f, 0.006229f, 0.007298f, 0.008621f, 0.010330f,
+ 0.012650f, 0.015808f, 0.020569f, 0.027908f, 0.037994f, 0.051514f, 0.485840f, 0.536133f, 0.547363f, 0.551758f, 0.554688f, 0.557617f,
+ 0.000026f, 0.000156f, 0.000201f, 0.000136f, 0.000188f, 0.000187f, 0.000192f, 0.000240f, 0.000245f, 0.000254f, 0.000262f, 0.000311f,
+ 0.000309f, 0.000331f, 0.000374f, 0.000385f, 0.000411f, 0.000431f, 0.000443f, 0.000461f, 0.000507f, 0.000522f, 0.000562f, 0.000596f,
+ 0.000634f, 0.000684f, 0.000718f, 0.000735f, 0.000776f, 0.000815f, 0.000875f, 0.000927f, 0.000982f, 0.001053f, 0.001123f, 0.001162f,
+ 0.001271f, 0.001346f, 0.001473f, 0.001577f, 0.001670f, 0.001838f, 0.002005f, 0.002161f, 0.002405f, 0.002670f, 0.002993f, 0.003399f,
+ 0.003860f, 0.004528f, 0.005386f, 0.006523f, 0.008003f, 0.010063f, 0.013206f, 0.017990f, 0.026031f, 0.038086f, 0.471191f, 0.522949f,
+ 0.534668f, 0.540039f, 0.543457f, 0.544922f, 0.000000f, 0.000093f, 0.000084f, 0.000085f, 0.000124f, 0.000145f, 0.000122f, 0.000149f,
+ 0.000152f, 0.000152f, 0.000158f, 0.000167f, 0.000186f, 0.000209f, 0.000217f, 0.000225f, 0.000231f, 0.000272f, 0.000273f, 0.000301f,
+ 0.000303f, 0.000310f, 0.000338f, 0.000361f, 0.000387f, 0.000423f, 0.000413f, 0.000436f, 0.000478f, 0.000503f, 0.000525f, 0.000570f,
+ 0.000608f, 0.000626f, 0.000677f, 0.000706f, 0.000753f, 0.000813f, 0.000884f, 0.000929f, 0.001000f, 0.001094f, 0.001183f, 0.001302f,
+ 0.001412f, 0.001563f, 0.001769f, 0.001974f, 0.002277f, 0.002626f, 0.003124f, 0.003761f, 0.004665f, 0.005993f, 0.007935f, 0.010818f,
+ 0.016205f, 0.026138f, 0.456299f, 0.509277f, 0.520996f, 0.527344f, 0.530762f, 0.532715f, 0.000105f, 0.000083f, 0.000072f, 0.000065f,
+ 0.000071f, 0.000072f, 0.000077f, 0.000084f, 0.000088f, 0.000093f, 0.000095f, 0.000120f, 0.000100f, 0.000108f, 0.000126f, 0.000118f,
+ 0.000139f, 0.000149f, 0.000153f, 0.000165f, 0.000169f, 0.000172f, 0.000194f, 0.000203f, 0.000233f, 0.000225f, 0.000233f, 0.000253f,
+ 0.000266f, 0.000275f, 0.000299f, 0.000319f, 0.000338f, 0.000345f, 0.000374f, 0.000384f, 0.000415f, 0.000448f, 0.000483f, 0.000511f,
+ 0.000543f, 0.000585f, 0.000647f, 0.000692f, 0.000755f, 0.000827f, 0.000924f, 0.001041f, 0.001186f, 0.001372f, 0.001608f, 0.001953f,
+ 0.002411f, 0.003098f, 0.004238f, 0.005989f, 0.009003f, 0.016006f, 0.441406f, 0.495361f, 0.508301f, 0.514160f, 0.518066f, 0.520508f,
+ 0.000090f, 0.000067f, 0.000058f, 0.000052f, 0.000047f, 0.000044f, 0.000044f, 0.000040f, 0.000042f, 0.000049f, 0.000042f, 0.000045f,
+ 0.000059f, 0.000047f, 0.000050f, 0.000054f, 0.000071f, 0.000073f, 0.000075f, 0.000078f, 0.000079f, 0.000084f, 0.000087f, 0.000090f,
+ 0.000097f, 0.000109f, 0.000108f, 0.000124f, 0.000124f, 0.000131f, 0.000138f, 0.000143f, 0.000155f, 0.000164f, 0.000178f, 0.000182f,
+ 0.000192f, 0.000209f, 0.000225f, 0.000244f, 0.000259f, 0.000274f, 0.000303f, 0.000321f, 0.000357f, 0.000385f, 0.000429f, 0.000470f,
+ 0.000537f, 0.000608f, 0.000710f, 0.000852f, 0.001052f, 0.001371f, 0.001877f, 0.002762f, 0.004406f, 0.008202f, 0.426270f, 0.483154f,
+ 0.495605f, 0.500977f, 0.505371f, 0.507324f, 0.000067f, 0.000047f, 0.000039f, 0.000035f, 0.000032f, 0.000030f, 0.000029f, 0.000027f,
+ 0.000026f, 0.000025f, 0.000024f, 0.000023f, 0.000021f, 0.000020f, 0.000019f, 0.000021f, 0.000020f, 0.000024f, 0.000028f, 0.000030f,
+ 0.000029f, 0.000032f, 0.000035f, 0.000034f, 0.000036f, 0.000044f, 0.000046f, 0.000040f, 0.000048f, 0.000047f, 0.000051f, 0.000053f,
+ 0.000059f, 0.000059f, 0.000064f, 0.000066f, 0.000077f, 0.000079f, 0.000081f, 0.000091f, 0.000094f, 0.000100f, 0.000108f, 0.000119f,
+ 0.000129f, 0.000137f, 0.000148f, 0.000173f, 0.000191f, 0.000210f, 0.000249f, 0.000292f, 0.000357f, 0.000448f, 0.000629f, 0.000943f,
+ 0.001630f, 0.003332f, 0.411377f, 0.468506f, 0.482910f, 0.488770f, 0.492188f, 0.495117f, 0.000025f, 0.000018f, 0.000015f, 0.000013f,
+ 0.000014f, 0.000013f, 0.000012f, 0.000012f, 0.000012f, 0.000012f, 0.000011f, 0.000011f, 0.000011f, 0.000011f, 0.000011f, 0.000011f,
+ 0.000011f, 0.000010f, 0.000010f, 0.000009f, 0.000009f, 0.000009f, 0.000008f, 0.000008f, 0.000008f, 0.000008f, 0.000008f, 0.000007f,
+ 0.000008f, 0.000010f, 0.000010f, 0.000010f, 0.000012f, 0.000014f, 0.000014f, 0.000014f, 0.000016f, 0.000018f, 0.000019f, 0.000021f,
+ 0.000020f, 0.000023f, 0.000025f, 0.000027f, 0.000027f, 0.000029f, 0.000035f, 0.000033f, 0.000040f, 0.000044f, 0.000052f, 0.000061f,
+ 0.000069f, 0.000087f, 0.000117f, 0.000174f, 0.000319f, 0.000847f, 0.395996f, 0.454834f, 0.468750f, 0.475586f, 0.479004f, 0.481689f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000001f,
+ 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000002f,
+ 0.000002f, 0.000002f, 0.000002f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000002f,
+ 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000003f, 0.000004f, 0.000004f, 0.000005f, 0.000009f, 0.000027f, 0.381348f, 0.441406f,
+ 0.455566f, 0.462891f, 0.466309f, 0.468994f,
+ },
+ {
+ 0.016769f, 0.050629f, 0.083740f, 0.116638f, 0.148071f, 0.178955f, 0.208374f, 0.236938f, 0.265137f, 0.291992f, 0.317871f, 0.343994f,
+ 0.368164f, 0.391846f, 0.415527f, 0.437988f, 0.459717f, 0.480469f, 0.501465f, 0.520996f, 0.540527f, 0.559082f, 0.577637f, 0.594727f,
+ 0.612305f, 0.628418f, 0.644531f, 0.661133f, 0.676270f, 0.691406f, 0.705566f, 0.719727f, 0.734375f, 0.747070f, 0.760254f, 0.773438f,
+ 0.786133f, 0.798828f, 0.810059f, 0.821777f, 0.833008f, 0.843262f, 0.854492f, 0.865234f, 0.875488f, 0.885254f, 0.895508f, 0.904297f,
+ 0.913574f, 0.923340f, 0.932617f, 0.940918f, 0.949707f, 0.958008f, 0.966309f, 0.974609f, 0.981934f, 0.990234f, 0.985352f, 0.965332f,
+ 0.950195f, 0.937500f, 0.926270f, 0.915527f, 0.015083f, 0.045929f, 0.075806f, 0.105408f, 0.135254f, 0.163208f, 0.191772f, 0.219238f,
+ 0.245239f, 0.271973f, 0.297363f, 0.321045f, 0.345947f, 0.369141f, 0.391846f, 0.414062f, 0.435791f, 0.456787f, 0.477295f, 0.497314f,
+ 0.516113f, 0.535645f, 0.554199f, 0.571777f, 0.588867f, 0.606445f, 0.623047f, 0.639160f, 0.654785f, 0.669434f, 0.685059f, 0.699219f,
+ 0.713379f, 0.728027f, 0.741211f, 0.754883f, 0.767578f, 0.780273f, 0.792480f, 0.804688f, 0.815918f, 0.826660f, 0.838867f, 0.850098f,
+ 0.859863f, 0.871094f, 0.880859f, 0.891113f, 0.900879f, 0.909180f, 0.919434f, 0.929688f, 0.937500f, 0.946289f, 0.954590f, 0.963379f,
+ 0.971191f, 0.979004f, 0.980469f, 0.961426f, 0.947266f, 0.935059f, 0.924316f, 0.914062f, 0.013573f, 0.040955f, 0.068848f, 0.096313f,
+ 0.123169f, 0.150635f, 0.175537f, 0.202026f, 0.228271f, 0.251709f, 0.276367f, 0.300781f, 0.323730f, 0.347168f, 0.369385f, 0.390625f,
+ 0.412354f, 0.433594f, 0.454346f, 0.473145f, 0.491943f, 0.512207f, 0.529785f, 0.549316f, 0.566406f, 0.583008f, 0.600586f, 0.616211f,
+ 0.633301f, 0.648438f, 0.663574f, 0.679199f, 0.693359f, 0.708008f, 0.721680f, 0.735840f, 0.748535f, 0.762207f, 0.773926f, 0.786621f,
+ 0.798340f, 0.811035f, 0.822754f, 0.833984f, 0.845215f, 0.855957f, 0.865723f, 0.876465f, 0.886719f, 0.895508f, 0.906738f, 0.916016f,
+ 0.925293f, 0.934570f, 0.943848f, 0.952148f, 0.960449f, 0.969238f, 0.976074f, 0.958008f, 0.944336f, 0.932617f, 0.921875f, 0.912109f,
+ 0.012329f, 0.037201f, 0.062164f, 0.087646f, 0.112488f, 0.137451f, 0.161865f, 0.187134f, 0.210938f, 0.234253f, 0.258301f, 0.281006f,
+ 0.303467f, 0.325195f, 0.347656f, 0.368652f, 0.389648f, 0.410400f, 0.430664f, 0.450928f, 0.470215f, 0.488770f, 0.507812f, 0.525391f,
+ 0.543457f, 0.560059f, 0.579102f, 0.593750f, 0.611816f, 0.627441f, 0.643066f, 0.658203f, 0.672363f, 0.687500f, 0.702148f, 0.715820f,
+ 0.729004f, 0.742676f, 0.755371f, 0.768066f, 0.781738f, 0.792969f, 0.805176f, 0.816895f, 0.829102f, 0.839844f, 0.850586f, 0.861816f,
+ 0.872559f, 0.882812f, 0.893066f, 0.902832f, 0.912109f, 0.921875f, 0.930664f, 0.940430f, 0.948242f, 0.958008f, 0.970703f, 0.953613f,
+ 0.940430f, 0.929199f, 0.919434f, 0.910156f, 0.010979f, 0.033752f, 0.056763f, 0.080139f, 0.103516f, 0.126221f, 0.149414f, 0.172485f,
+ 0.195435f, 0.218262f, 0.240356f, 0.261719f, 0.284180f, 0.306396f, 0.326416f, 0.347900f, 0.368408f, 0.389160f, 0.408691f, 0.427979f,
+ 0.447754f, 0.467041f, 0.484863f, 0.502441f, 0.520996f, 0.538086f, 0.555664f, 0.573242f, 0.589355f, 0.604980f, 0.622559f, 0.637207f,
+ 0.652832f, 0.666992f, 0.680664f, 0.695801f, 0.710938f, 0.724121f, 0.737305f, 0.750977f, 0.763672f, 0.776855f, 0.789062f, 0.799805f,
+ 0.812012f, 0.824219f, 0.835449f, 0.846680f, 0.857910f, 0.868164f, 0.878418f, 0.889160f, 0.898926f, 0.909180f, 0.917969f, 0.928223f,
+ 0.937012f, 0.946777f, 0.965820f, 0.949707f, 0.937012f, 0.926270f, 0.916504f, 0.907715f, 0.009941f, 0.030746f, 0.051514f, 0.073181f,
+ 0.094116f, 0.116028f, 0.137817f, 0.158691f, 0.180664f, 0.202637f, 0.223511f, 0.244873f, 0.265869f, 0.285889f, 0.307129f, 0.327881f,
+ 0.347412f, 0.367188f, 0.387207f, 0.405762f, 0.425537f, 0.444092f, 0.462646f, 0.481201f, 0.499756f, 0.516602f, 0.533691f, 0.550781f,
+ 0.567383f, 0.583984f, 0.599609f, 0.616211f, 0.630859f, 0.647461f, 0.661621f, 0.676758f, 0.689453f, 0.704590f, 0.718750f, 0.731934f,
+ 0.745117f, 0.757812f, 0.770996f, 0.783691f, 0.796387f, 0.807617f, 0.819824f, 0.831543f, 0.842773f, 0.854004f, 0.864258f, 0.875488f,
+ 0.885742f, 0.895508f, 0.905762f, 0.915527f, 0.925781f, 0.934570f, 0.960449f, 0.945312f, 0.933594f, 0.922852f, 0.913574f, 0.905273f,
+ 0.009003f, 0.027756f, 0.046997f, 0.066711f, 0.085999f, 0.106506f, 0.127075f, 0.146973f, 0.166992f, 0.187500f, 0.207886f, 0.228149f,
+ 0.248169f, 0.268311f, 0.287842f, 0.307861f, 0.327393f, 0.347656f, 0.365967f, 0.385010f, 0.404541f, 0.422363f, 0.441162f, 0.458740f,
+ 0.477783f, 0.495117f, 0.512207f, 0.529297f, 0.546387f, 0.562012f, 0.578613f, 0.595215f, 0.610840f, 0.625977f, 0.641113f, 0.656738f,
+ 0.670410f, 0.685059f, 0.699707f, 0.714355f, 0.727051f, 0.741699f, 0.752441f, 0.767090f, 0.778809f, 0.791504f, 0.803711f, 0.815430f,
+ 0.827148f, 0.838867f, 0.850098f, 0.860840f, 0.872070f, 0.881836f, 0.893066f, 0.903809f, 0.913574f, 0.923828f, 0.955078f, 0.940918f,
+ 0.929199f, 0.919922f, 0.911133f, 0.902344f, 0.008469f, 0.025375f, 0.043121f, 0.060944f, 0.079468f, 0.097961f, 0.116394f, 0.135620f,
+ 0.154541f, 0.174072f, 0.193115f, 0.212280f, 0.231689f, 0.250732f, 0.270264f, 0.289307f, 0.307861f, 0.327148f, 0.345215f, 0.364990f,
+ 0.382812f, 0.401123f, 0.418945f, 0.437012f, 0.455811f, 0.472900f, 0.490234f, 0.507812f, 0.524414f, 0.541016f, 0.558105f, 0.573242f,
+ 0.590332f, 0.605469f, 0.620117f, 0.636230f, 0.651367f, 0.665039f, 0.679688f, 0.694336f, 0.708496f, 0.722168f, 0.735840f, 0.750000f,
+ 0.762695f, 0.774902f, 0.787598f, 0.798828f, 0.811523f, 0.823730f, 0.834473f, 0.846191f, 0.857910f, 0.868652f, 0.879883f, 0.891113f,
+ 0.900391f, 0.911133f, 0.949219f, 0.937012f, 0.925293f, 0.916016f, 0.907227f, 0.899414f, 0.007618f, 0.023178f, 0.039490f, 0.055542f,
+ 0.072937f, 0.090271f, 0.107605f, 0.125122f, 0.142944f, 0.160889f, 0.178955f, 0.197510f, 0.216553f, 0.234497f, 0.252686f, 0.271240f,
+ 0.289795f, 0.307861f, 0.326172f, 0.344238f, 0.362549f, 0.380859f, 0.398438f, 0.416504f, 0.433838f, 0.452393f, 0.468994f, 0.485840f,
+ 0.502930f, 0.519531f, 0.536133f, 0.553223f, 0.569336f, 0.584473f, 0.599609f, 0.615234f, 0.631348f, 0.646484f, 0.659668f, 0.675293f,
+ 0.689941f, 0.703125f, 0.716797f, 0.730957f, 0.744141f, 0.756836f, 0.771484f, 0.782227f, 0.795898f, 0.807617f, 0.819824f, 0.831543f,
+ 0.843750f, 0.854980f, 0.866211f, 0.877441f, 0.888672f, 0.898438f, 0.943359f, 0.931641f, 0.921387f, 0.912109f, 0.903809f, 0.896484f,
+ 0.007118f, 0.021255f, 0.035889f, 0.051514f, 0.066895f, 0.083191f, 0.098999f, 0.115540f, 0.132324f, 0.149292f, 0.166260f, 0.183716f,
+ 0.200928f, 0.218628f, 0.236084f, 0.253906f, 0.272217f, 0.289795f, 0.307617f, 0.325439f, 0.342529f, 0.360596f, 0.378906f, 0.395996f,
+ 0.413330f, 0.430908f, 0.447510f, 0.465332f, 0.481934f, 0.497803f, 0.514648f, 0.531738f, 0.547852f, 0.562988f, 0.579102f, 0.595215f,
+ 0.610840f, 0.625977f, 0.641113f, 0.655273f, 0.670410f, 0.685059f, 0.698730f, 0.712891f, 0.726074f, 0.739258f, 0.753418f, 0.766113f,
+ 0.779785f, 0.791992f, 0.803711f, 0.816406f, 0.829102f, 0.839844f, 0.852539f, 0.863770f, 0.874512f, 0.886719f, 0.937988f, 0.926758f,
+ 0.917480f, 0.908203f, 0.900391f, 0.893066f, 0.006481f, 0.019775f, 0.032928f, 0.047272f, 0.061371f, 0.076233f, 0.091064f, 0.107117f,
+ 0.122559f, 0.138062f, 0.154663f, 0.170532f, 0.187256f, 0.204346f, 0.220947f, 0.237915f, 0.254883f, 0.272217f, 0.289062f, 0.306641f,
+ 0.323730f, 0.341064f, 0.358643f, 0.375732f, 0.393555f, 0.410645f, 0.426758f, 0.444580f, 0.461182f, 0.477783f, 0.494141f, 0.510254f,
+ 0.526855f, 0.543457f, 0.559082f, 0.574219f, 0.590332f, 0.605957f, 0.621094f, 0.634766f, 0.650879f, 0.665039f, 0.679688f, 0.694824f,
+ 0.708008f, 0.722656f, 0.736816f, 0.749023f, 0.762695f, 0.775391f, 0.788086f, 0.801270f, 0.813965f, 0.826172f, 0.838379f, 0.849121f,
+ 0.861328f, 0.873535f, 0.932129f, 0.921875f, 0.912598f, 0.904297f, 0.896484f, 0.889160f, 0.005924f, 0.017899f, 0.030426f, 0.043427f,
+ 0.056824f, 0.070435f, 0.084106f, 0.098755f, 0.112976f, 0.128052f, 0.143311f, 0.158936f, 0.174072f, 0.189575f, 0.206421f, 0.222534f,
+ 0.238403f, 0.255615f, 0.271729f, 0.288818f, 0.305908f, 0.322021f, 0.339355f, 0.356445f, 0.373291f, 0.390137f, 0.407227f, 0.423584f,
+ 0.440430f, 0.457031f, 0.472900f, 0.489502f, 0.506836f, 0.521973f, 0.538574f, 0.554688f, 0.570312f, 0.585449f, 0.601074f, 0.616211f,
+ 0.631348f, 0.646484f, 0.661621f, 0.675781f, 0.690430f, 0.704590f, 0.717285f, 0.731934f, 0.746094f, 0.759277f, 0.771973f, 0.785156f,
+ 0.798340f, 0.810547f, 0.823242f, 0.835938f, 0.848145f, 0.860352f, 0.925781f, 0.916504f, 0.908203f, 0.900391f, 0.893066f, 0.886719f,
+ 0.005573f, 0.016693f, 0.028366f, 0.040192f, 0.052277f, 0.064880f, 0.078064f, 0.090698f, 0.105042f, 0.118591f, 0.133057f, 0.147461f,
+ 0.162231f, 0.177612f, 0.192383f, 0.207886f, 0.223633f, 0.239502f, 0.255615f, 0.272217f, 0.288330f, 0.304932f, 0.320312f, 0.337646f,
+ 0.354004f, 0.369873f, 0.386719f, 0.403320f, 0.419922f, 0.437012f, 0.453369f, 0.469482f, 0.485596f, 0.501465f, 0.517578f, 0.534180f,
+ 0.549316f, 0.565918f, 0.581055f, 0.595703f, 0.611328f, 0.626953f, 0.641602f, 0.657227f, 0.671387f, 0.686523f, 0.699707f, 0.714355f,
+ 0.729004f, 0.742676f, 0.756348f, 0.769043f, 0.782715f, 0.795410f, 0.809082f, 0.821289f, 0.833984f, 0.846680f, 0.919434f, 0.911133f,
+ 0.903320f, 0.895508f, 0.888672f, 0.882324f, 0.005016f, 0.015396f, 0.026169f, 0.037231f, 0.048126f, 0.059937f, 0.071716f, 0.084167f,
+ 0.096680f, 0.109558f, 0.123169f, 0.136719f, 0.150269f, 0.164917f, 0.179077f, 0.194580f, 0.208984f, 0.223877f, 0.239746f, 0.255127f,
+ 0.270996f, 0.286377f, 0.302490f, 0.319336f, 0.335205f, 0.351318f, 0.367432f, 0.383545f, 0.399902f, 0.415771f, 0.432373f, 0.448975f,
+ 0.465088f, 0.481934f, 0.497314f, 0.513672f, 0.529785f, 0.544434f, 0.561035f, 0.576660f, 0.592285f, 0.607422f, 0.622559f, 0.638184f,
+ 0.652344f, 0.667480f, 0.681641f, 0.696777f, 0.711426f, 0.725586f, 0.738770f, 0.753418f, 0.766602f, 0.779297f, 0.793945f, 0.807129f,
+ 0.819824f, 0.833008f, 0.913086f, 0.906738f, 0.898438f, 0.890625f, 0.884277f, 0.878418f, 0.004738f, 0.014053f, 0.024017f, 0.033752f,
+ 0.044495f, 0.055328f, 0.066467f, 0.078064f, 0.089661f, 0.102051f, 0.114258f, 0.126831f, 0.139771f, 0.153564f, 0.167114f, 0.181030f,
+ 0.195190f, 0.209839f, 0.224731f, 0.239136f, 0.253906f, 0.269531f, 0.285156f, 0.300293f, 0.317139f, 0.332520f, 0.348145f, 0.364990f,
+ 0.380859f, 0.396240f, 0.412109f, 0.428711f, 0.444336f, 0.460938f, 0.477295f, 0.492676f, 0.509277f, 0.524902f, 0.540527f, 0.556641f,
+ 0.572266f, 0.587402f, 0.604004f, 0.618164f, 0.633301f, 0.648438f, 0.664062f, 0.678223f, 0.693359f, 0.708008f, 0.722656f, 0.736328f,
+ 0.750000f, 0.764160f, 0.777832f, 0.791016f, 0.805176f, 0.817871f, 0.907227f, 0.900879f, 0.894043f, 0.886719f, 0.880371f, 0.874512f,
+ 0.004105f, 0.012741f, 0.022491f, 0.031769f, 0.041107f, 0.051208f, 0.061249f, 0.071777f, 0.083069f, 0.093811f, 0.105896f, 0.117554f,
+ 0.129761f, 0.142212f, 0.155273f, 0.168579f, 0.182251f, 0.196167f, 0.210449f, 0.223755f, 0.238525f, 0.253662f, 0.268799f, 0.283447f,
+ 0.298828f, 0.313965f, 0.329834f, 0.344971f, 0.361328f, 0.376953f, 0.393066f, 0.408691f, 0.424561f, 0.441406f, 0.457031f, 0.472656f,
+ 0.488770f, 0.504883f, 0.520996f, 0.536133f, 0.551758f, 0.567871f, 0.583496f, 0.599121f, 0.614258f, 0.629395f, 0.645996f, 0.660156f,
+ 0.675781f, 0.689453f, 0.704102f, 0.719727f, 0.733398f, 0.747559f, 0.761719f, 0.776367f, 0.789062f, 0.803223f, 0.899902f, 0.895020f,
+ 0.888184f, 0.881836f, 0.875488f, 0.870117f, 0.003925f, 0.011978f, 0.020538f, 0.028763f, 0.038269f, 0.047028f, 0.056732f, 0.066223f,
+ 0.076904f, 0.086731f, 0.097900f, 0.109314f, 0.120483f, 0.132324f, 0.144653f, 0.156982f, 0.169678f, 0.183228f, 0.196289f, 0.209961f,
+ 0.223633f, 0.237427f, 0.251953f, 0.266602f, 0.281982f, 0.296875f, 0.312012f, 0.326660f, 0.342041f, 0.357910f, 0.373779f, 0.389404f,
+ 0.404785f, 0.420166f, 0.436768f, 0.452637f, 0.468506f, 0.484863f, 0.500977f, 0.516602f, 0.531738f, 0.546875f, 0.563965f, 0.579102f,
+ 0.595215f, 0.610840f, 0.625977f, 0.641602f, 0.657227f, 0.671387f, 0.687500f, 0.702148f, 0.716309f, 0.731445f, 0.746094f, 0.760742f,
+ 0.774414f, 0.788086f, 0.893066f, 0.889648f, 0.882812f, 0.876953f, 0.870605f, 0.865723f, 0.003704f, 0.011169f, 0.019165f, 0.026550f,
+ 0.035339f, 0.043488f, 0.052277f, 0.061066f, 0.071045f, 0.080933f, 0.090576f, 0.101074f, 0.111877f, 0.122925f, 0.134277f, 0.146118f,
+ 0.157837f, 0.170288f, 0.183105f, 0.195557f, 0.209351f, 0.222900f, 0.236328f, 0.250732f, 0.264893f, 0.279297f, 0.294189f, 0.308838f,
+ 0.323975f, 0.339844f, 0.354736f, 0.370117f, 0.385986f, 0.401367f, 0.416504f, 0.432861f, 0.448486f, 0.463867f, 0.480469f, 0.497070f,
+ 0.511719f, 0.527832f, 0.544434f, 0.559570f, 0.575684f, 0.591797f, 0.606934f, 0.623047f, 0.638184f, 0.654297f, 0.668945f, 0.684570f,
+ 0.699219f, 0.714355f, 0.729492f, 0.744629f, 0.758789f, 0.773926f, 0.886230f, 0.883301f, 0.877441f, 0.871582f, 0.866211f, 0.860840f,
+ 0.003500f, 0.010292f, 0.017395f, 0.024963f, 0.032440f, 0.040344f, 0.048462f, 0.057098f, 0.065063f, 0.074646f, 0.083679f, 0.093445f,
+ 0.103882f, 0.114136f, 0.124451f, 0.135498f, 0.146606f, 0.158447f, 0.170410f, 0.182739f, 0.195435f, 0.208008f, 0.221558f, 0.234863f,
+ 0.248657f, 0.262695f, 0.276855f, 0.291748f, 0.306152f, 0.320801f, 0.335693f, 0.350830f, 0.365967f, 0.382080f, 0.396973f, 0.413330f,
+ 0.429199f, 0.444336f, 0.459473f, 0.476074f, 0.492188f, 0.507812f, 0.524414f, 0.540039f, 0.555664f, 0.571777f, 0.586914f, 0.604004f,
+ 0.619629f, 0.635742f, 0.650391f, 0.666504f, 0.682129f, 0.697754f, 0.712891f, 0.728027f, 0.743164f, 0.758301f, 0.878906f, 0.877441f,
+ 0.871582f, 0.866699f, 0.860840f, 0.856445f, 0.003084f, 0.009697f, 0.016403f, 0.022659f, 0.029892f, 0.037354f, 0.044281f, 0.052338f,
+ 0.060516f, 0.068970f, 0.077515f, 0.086243f, 0.096069f, 0.105713f, 0.115356f, 0.125610f, 0.136353f, 0.147339f, 0.158081f, 0.170410f,
+ 0.181396f, 0.194458f, 0.207275f, 0.219482f, 0.232910f, 0.246704f, 0.260010f, 0.274170f, 0.288330f, 0.302979f, 0.317383f, 0.332764f,
+ 0.347656f, 0.363037f, 0.378174f, 0.392578f, 0.408936f, 0.424316f, 0.440430f, 0.456299f, 0.472656f, 0.488525f, 0.503906f, 0.519531f,
+ 0.535645f, 0.552734f, 0.568359f, 0.584961f, 0.600586f, 0.616699f, 0.633301f, 0.648438f, 0.663574f, 0.679199f, 0.694824f, 0.710938f,
+ 0.726074f, 0.742188f, 0.872559f, 0.870605f, 0.865723f, 0.860840f, 0.855957f, 0.851074f, 0.002913f, 0.008781f, 0.014938f, 0.021759f,
+ 0.027878f, 0.034393f, 0.041412f, 0.048737f, 0.055969f, 0.063599f, 0.072021f, 0.080200f, 0.088928f, 0.097839f, 0.106934f, 0.116150f,
+ 0.126587f, 0.136353f, 0.147095f, 0.157715f, 0.169189f, 0.181519f, 0.193481f, 0.205933f, 0.217773f, 0.231323f, 0.244629f, 0.257812f,
+ 0.271240f, 0.285400f, 0.299561f, 0.314453f, 0.329590f, 0.343506f, 0.358887f, 0.373779f, 0.389648f, 0.405029f, 0.420410f, 0.437012f,
+ 0.452393f, 0.468262f, 0.484375f, 0.500000f, 0.516113f, 0.532227f, 0.548828f, 0.564941f, 0.581055f, 0.597168f, 0.612793f, 0.629883f,
+ 0.645508f, 0.662109f, 0.678223f, 0.694336f, 0.709473f, 0.726074f, 0.863770f, 0.864258f, 0.859863f, 0.854980f, 0.850586f, 0.846191f,
+ 0.002815f, 0.008194f, 0.013954f, 0.019653f, 0.025696f, 0.031982f, 0.038177f, 0.044830f, 0.051819f, 0.058502f, 0.066162f, 0.073792f,
+ 0.082031f, 0.090393f, 0.098999f, 0.107605f, 0.117493f, 0.126709f, 0.137207f, 0.146729f, 0.157593f, 0.168579f, 0.179810f, 0.191772f,
+ 0.203369f, 0.215820f, 0.228882f, 0.241455f, 0.254395f, 0.268311f, 0.282227f, 0.296631f, 0.310303f, 0.325439f, 0.339844f, 0.354736f,
+ 0.370361f, 0.385742f, 0.400879f, 0.416504f, 0.432617f, 0.448486f, 0.464355f, 0.479980f, 0.496094f, 0.513184f, 0.528809f, 0.545410f,
+ 0.561035f, 0.578613f, 0.594727f, 0.611328f, 0.626953f, 0.643555f, 0.660156f, 0.676270f, 0.693359f, 0.709473f, 0.856445f, 0.858398f,
+ 0.854492f, 0.849121f, 0.845215f, 0.841309f, 0.002583f, 0.007492f, 0.012878f, 0.018417f, 0.023941f, 0.029495f, 0.035339f, 0.041779f,
+ 0.047577f, 0.054047f, 0.061523f, 0.068787f, 0.075562f, 0.083313f, 0.091858f, 0.099792f, 0.108521f, 0.117615f, 0.126709f, 0.136108f,
+ 0.146851f, 0.156860f, 0.166992f, 0.178345f, 0.189819f, 0.202148f, 0.213623f, 0.225830f, 0.238892f, 0.252197f, 0.265137f, 0.278809f,
+ 0.292480f, 0.306885f, 0.321045f, 0.336914f, 0.350830f, 0.366943f, 0.381348f, 0.396240f, 0.412354f, 0.428223f, 0.444336f, 0.460449f,
+ 0.476318f, 0.493408f, 0.509277f, 0.525879f, 0.542480f, 0.559082f, 0.574707f, 0.591797f, 0.608398f, 0.625488f, 0.642090f, 0.659180f,
+ 0.675781f, 0.691406f, 0.848145f, 0.851562f, 0.848145f, 0.843750f, 0.838867f, 0.835449f, 0.002512f, 0.007374f, 0.012115f, 0.016983f,
+ 0.022064f, 0.027359f, 0.032715f, 0.038147f, 0.044373f, 0.050354f, 0.056641f, 0.063293f, 0.070190f, 0.077026f, 0.084717f, 0.092041f,
+ 0.100342f, 0.108398f, 0.117554f, 0.126221f, 0.135742f, 0.145142f, 0.155151f, 0.165771f, 0.176758f, 0.187988f, 0.199341f, 0.210815f,
+ 0.223389f, 0.236206f, 0.249023f, 0.261719f, 0.275879f, 0.289062f, 0.303467f, 0.317627f, 0.332520f, 0.347412f, 0.361816f, 0.377197f,
+ 0.393066f, 0.407959f, 0.424072f, 0.440186f, 0.457031f, 0.473145f, 0.489502f, 0.505859f, 0.522461f, 0.540039f, 0.555664f, 0.572754f,
+ 0.589844f, 0.606445f, 0.623535f, 0.640625f, 0.658203f, 0.675781f, 0.840820f, 0.843750f, 0.841309f, 0.836914f, 0.833984f, 0.830566f,
+ 0.002369f, 0.006668f, 0.011093f, 0.015778f, 0.020523f, 0.025223f, 0.030701f, 0.035339f, 0.040710f, 0.046600f, 0.051971f, 0.058075f,
+ 0.064819f, 0.071228f, 0.077942f, 0.085205f, 0.092224f, 0.100464f, 0.108398f, 0.116882f, 0.125610f, 0.134155f, 0.143555f, 0.153564f,
+ 0.164062f, 0.174316f, 0.185303f, 0.196899f, 0.208496f, 0.220093f, 0.232666f, 0.245239f, 0.258057f, 0.271729f, 0.285645f, 0.299561f,
+ 0.313721f, 0.328613f, 0.342773f, 0.358154f, 0.373535f, 0.388916f, 0.405518f, 0.419922f, 0.437012f, 0.453125f, 0.469238f, 0.486328f,
+ 0.502930f, 0.519531f, 0.536133f, 0.553223f, 0.571289f, 0.588379f, 0.605469f, 0.623047f, 0.640137f, 0.656250f, 0.833008f, 0.837402f,
+ 0.834473f, 0.831055f, 0.827637f, 0.824219f, 0.002188f, 0.006027f, 0.010582f, 0.014297f, 0.018921f, 0.023270f, 0.028183f, 0.032593f,
+ 0.037781f, 0.042999f, 0.048584f, 0.053650f, 0.059601f, 0.065369f, 0.071899f, 0.078369f, 0.085449f, 0.092407f, 0.099609f, 0.107788f,
+ 0.115601f, 0.124451f, 0.133301f, 0.142212f, 0.151978f, 0.161865f, 0.172363f, 0.182617f, 0.193970f, 0.205566f, 0.217407f, 0.229858f,
+ 0.241943f, 0.254639f, 0.268311f, 0.281494f, 0.295654f, 0.310059f, 0.324219f, 0.339600f, 0.353760f, 0.369629f, 0.385010f, 0.400879f,
+ 0.417725f, 0.433594f, 0.449219f, 0.465820f, 0.482910f, 0.499512f, 0.517090f, 0.534180f, 0.551270f, 0.568848f, 0.586426f, 0.604004f,
+ 0.622559f, 0.639160f, 0.824219f, 0.830078f, 0.827637f, 0.824707f, 0.821777f, 0.818359f, 0.002098f, 0.005634f, 0.009354f, 0.013557f,
+ 0.017685f, 0.021576f, 0.025604f, 0.030380f, 0.034943f, 0.039429f, 0.044281f, 0.049255f, 0.055023f, 0.060577f, 0.066101f, 0.072144f,
+ 0.078491f, 0.085083f, 0.091858f, 0.098999f, 0.106873f, 0.114502f, 0.122498f, 0.131592f, 0.140137f, 0.149536f, 0.159424f, 0.169556f,
+ 0.180054f, 0.191162f, 0.202026f, 0.213989f, 0.226318f, 0.239136f, 0.250977f, 0.264648f, 0.278320f, 0.291748f, 0.305908f, 0.320557f,
+ 0.334961f, 0.350342f, 0.365479f, 0.381592f, 0.397461f, 0.413818f, 0.429199f, 0.446289f, 0.462891f, 0.479736f, 0.496338f, 0.514160f,
+ 0.530762f, 0.548828f, 0.566406f, 0.584473f, 0.602539f, 0.621582f, 0.815918f, 0.823730f, 0.821289f, 0.817871f, 0.815430f, 0.812500f,
+ 0.001772f, 0.005249f, 0.008995f, 0.012260f, 0.016251f, 0.020020f, 0.024216f, 0.027603f, 0.032196f, 0.036377f, 0.041199f, 0.045410f,
+ 0.050110f, 0.055603f, 0.061005f, 0.066406f, 0.072327f, 0.077820f, 0.084290f, 0.090942f, 0.098083f, 0.105164f, 0.113037f, 0.120789f,
+ 0.129272f, 0.138062f, 0.147339f, 0.156982f, 0.166626f, 0.176758f, 0.187866f, 0.199097f, 0.210449f, 0.222412f, 0.234985f, 0.247559f,
+ 0.260742f, 0.273682f, 0.287598f, 0.302002f, 0.316650f, 0.331299f, 0.346191f, 0.362061f, 0.377686f, 0.393066f, 0.409668f, 0.426514f,
+ 0.443115f, 0.459717f, 0.476807f, 0.494629f, 0.511230f, 0.529785f, 0.547852f, 0.565430f, 0.583984f, 0.602539f, 0.806152f, 0.814453f,
+ 0.813965f, 0.811035f, 0.809082f, 0.806641f, 0.001631f, 0.005131f, 0.008186f, 0.011673f, 0.014938f, 0.018463f, 0.021957f, 0.025635f,
+ 0.029083f, 0.033325f, 0.037445f, 0.041840f, 0.046478f, 0.050751f, 0.055634f, 0.060760f, 0.065979f, 0.071472f, 0.077515f, 0.083801f,
+ 0.090027f, 0.096802f, 0.104065f, 0.110840f, 0.119080f, 0.127197f, 0.135498f, 0.144775f, 0.153931f, 0.163574f, 0.173462f, 0.184570f,
+ 0.195312f, 0.207153f, 0.218506f, 0.230591f, 0.243652f, 0.256348f, 0.270020f, 0.283691f, 0.297852f, 0.312744f, 0.326904f, 0.342529f,
+ 0.357910f, 0.373535f, 0.389404f, 0.406494f, 0.421875f, 0.439941f, 0.457275f, 0.474365f, 0.492432f, 0.509766f, 0.527832f, 0.546875f,
+ 0.564941f, 0.584473f, 0.797852f, 0.807129f, 0.807129f, 0.804199f, 0.801758f, 0.799316f, 0.001632f, 0.004704f, 0.007912f, 0.010788f,
+ 0.013870f, 0.017105f, 0.020187f, 0.023483f, 0.026932f, 0.030563f, 0.034332f, 0.038086f, 0.042694f, 0.046631f, 0.050995f, 0.055725f,
+ 0.060486f, 0.065674f, 0.070862f, 0.076721f, 0.082825f, 0.088623f, 0.094910f, 0.102112f, 0.109070f, 0.116516f, 0.124695f, 0.133057f,
+ 0.141968f, 0.151001f, 0.160522f, 0.170776f, 0.181030f, 0.191650f, 0.202881f, 0.214722f, 0.227417f, 0.239624f, 0.252686f, 0.265625f,
+ 0.279785f, 0.293213f, 0.308350f, 0.323242f, 0.338867f, 0.354248f, 0.370117f, 0.386475f, 0.403076f, 0.420410f, 0.437012f, 0.454102f,
+ 0.471924f, 0.490234f, 0.508789f, 0.526855f, 0.545410f, 0.564453f, 0.788086f, 0.799316f, 0.798828f, 0.797852f, 0.794434f, 0.791992f,
+ 0.001594f, 0.004177f, 0.007122f, 0.010201f, 0.012344f, 0.015839f, 0.018372f, 0.021683f, 0.024857f, 0.028534f, 0.031464f, 0.035034f,
+ 0.038879f, 0.042572f, 0.046295f, 0.051056f, 0.055389f, 0.059723f, 0.064697f, 0.069763f, 0.075073f, 0.080750f, 0.087219f, 0.093445f,
+ 0.099548f, 0.107056f, 0.114136f, 0.121887f, 0.130249f, 0.138794f, 0.147217f, 0.157104f, 0.166748f, 0.177124f, 0.187988f, 0.199097f,
+ 0.210693f, 0.222778f, 0.235352f, 0.248169f, 0.261719f, 0.275635f, 0.289062f, 0.303955f, 0.319336f, 0.334717f, 0.350098f, 0.365479f,
+ 0.382324f, 0.398926f, 0.416016f, 0.433594f, 0.451904f, 0.469238f, 0.487549f, 0.506348f, 0.525391f, 0.544922f, 0.779297f, 0.791504f,
+ 0.791504f, 0.789551f, 0.788086f, 0.786133f, 0.001365f, 0.004173f, 0.006222f, 0.008842f, 0.011703f, 0.014366f, 0.017242f, 0.020218f,
+ 0.022903f, 0.025787f, 0.028824f, 0.032227f, 0.035522f, 0.038818f, 0.042511f, 0.046326f, 0.050507f, 0.054657f, 0.058594f, 0.063660f,
+ 0.068359f, 0.073914f, 0.078918f, 0.085083f, 0.091125f, 0.097534f, 0.104126f, 0.111511f, 0.118896f, 0.126831f, 0.135742f, 0.144043f,
+ 0.153564f, 0.163330f, 0.173462f, 0.184082f, 0.195068f, 0.206787f, 0.218628f, 0.231079f, 0.243896f, 0.257080f, 0.270996f, 0.285645f,
+ 0.300049f, 0.314941f, 0.330322f, 0.346191f, 0.362305f, 0.379395f, 0.395508f, 0.412842f, 0.431641f, 0.448975f, 0.468262f, 0.487549f,
+ 0.505371f, 0.525391f, 0.769531f, 0.783691f, 0.783691f, 0.782715f, 0.781250f, 0.778809f, 0.001230f, 0.003925f, 0.006268f, 0.008659f,
+ 0.010796f, 0.013145f, 0.015617f, 0.018234f, 0.021133f, 0.023682f, 0.026215f, 0.029251f, 0.032349f, 0.035400f, 0.038696f, 0.042206f,
+ 0.045807f, 0.049377f, 0.053925f, 0.057953f, 0.062500f, 0.067078f, 0.071777f, 0.077271f, 0.082703f, 0.088806f, 0.094910f, 0.101379f,
+ 0.109192f, 0.115967f, 0.123779f, 0.131470f, 0.140259f, 0.149536f, 0.159302f, 0.169312f, 0.180054f, 0.190674f, 0.202515f, 0.214722f,
+ 0.226562f, 0.239624f, 0.253174f, 0.266602f, 0.281738f, 0.295898f, 0.311035f, 0.326904f, 0.342529f, 0.359131f, 0.375732f, 0.393066f,
+ 0.410400f, 0.428467f, 0.447510f, 0.466064f, 0.485596f, 0.504883f, 0.759277f, 0.774902f, 0.775879f, 0.774902f, 0.773438f, 0.771973f,
+ 0.001031f, 0.003601f, 0.005604f, 0.007858f, 0.009880f, 0.012146f, 0.014549f, 0.016998f, 0.019043f, 0.021362f, 0.024475f, 0.026566f,
+ 0.029358f, 0.032196f, 0.035248f, 0.038391f, 0.041656f, 0.045044f, 0.048553f, 0.052582f, 0.056213f, 0.060669f, 0.065186f, 0.070068f,
+ 0.074768f, 0.080322f, 0.086060f, 0.092102f, 0.098877f, 0.105408f, 0.112366f, 0.120239f, 0.128540f, 0.136597f, 0.145874f, 0.155396f,
+ 0.165283f, 0.175537f, 0.186401f, 0.198120f, 0.210083f, 0.222534f, 0.235229f, 0.248657f, 0.262451f, 0.277344f, 0.291504f, 0.307617f,
+ 0.322998f, 0.339111f, 0.354980f, 0.372559f, 0.390625f, 0.408936f, 0.426758f, 0.445312f, 0.466064f, 0.485840f, 0.749512f, 0.765137f,
+ 0.767578f, 0.767090f, 0.765137f, 0.764648f, 0.001161f, 0.003078f, 0.005310f, 0.007282f, 0.009201f, 0.011330f, 0.013214f, 0.015404f,
+ 0.017273f, 0.019409f, 0.021988f, 0.024078f, 0.026550f, 0.029358f, 0.032043f, 0.034454f, 0.037415f, 0.040710f, 0.043854f, 0.047272f,
+ 0.050659f, 0.054840f, 0.058777f, 0.063293f, 0.067566f, 0.072449f, 0.077759f, 0.083069f, 0.088928f, 0.095886f, 0.102478f, 0.109070f,
+ 0.116760f, 0.124390f, 0.132935f, 0.141479f, 0.151123f, 0.161011f, 0.171143f, 0.182007f, 0.193726f, 0.205688f, 0.218018f, 0.230835f,
+ 0.244507f, 0.258789f, 0.272949f, 0.287109f, 0.303467f, 0.319336f, 0.335449f, 0.352539f, 0.369873f, 0.387939f, 0.406250f, 0.425049f,
+ 0.444824f, 0.464844f, 0.739258f, 0.756348f, 0.758789f, 0.758789f, 0.757324f, 0.756836f, 0.001004f, 0.002939f, 0.005005f, 0.006779f,
+ 0.008453f, 0.010323f, 0.012177f, 0.013870f, 0.016052f, 0.018051f, 0.019638f, 0.022141f, 0.023956f, 0.026413f, 0.028870f, 0.031281f,
+ 0.033661f, 0.036591f, 0.039429f, 0.042542f, 0.045776f, 0.049011f, 0.053009f, 0.056885f, 0.061035f, 0.065186f, 0.069885f, 0.075134f,
+ 0.080505f, 0.085999f, 0.091858f, 0.098633f, 0.105591f, 0.112732f, 0.120667f, 0.128662f, 0.137573f, 0.146729f, 0.156372f, 0.166748f,
+ 0.177490f, 0.189331f, 0.201294f, 0.213501f, 0.226807f, 0.239746f, 0.254150f, 0.268555f, 0.283936f, 0.298828f, 0.316162f, 0.332275f,
+ 0.349609f, 0.367432f, 0.385498f, 0.404053f, 0.423828f, 0.443848f, 0.728516f, 0.747559f, 0.750488f, 0.750488f, 0.749512f, 0.748047f,
+ 0.000970f, 0.002523f, 0.004665f, 0.006203f, 0.007759f, 0.009491f, 0.011070f, 0.012802f, 0.014336f, 0.016266f, 0.017944f, 0.019852f,
+ 0.021805f, 0.023911f, 0.025818f, 0.028137f, 0.030579f, 0.032837f, 0.035248f, 0.038055f, 0.041046f, 0.044189f, 0.047333f, 0.050842f,
+ 0.054504f, 0.058502f, 0.062866f, 0.067383f, 0.071960f, 0.077393f, 0.082642f, 0.088928f, 0.095093f, 0.101685f, 0.108765f, 0.116272f,
+ 0.124451f, 0.133423f, 0.142212f, 0.152100f, 0.162354f, 0.172729f, 0.184692f, 0.196411f, 0.209106f, 0.221802f, 0.235718f, 0.250000f,
+ 0.265137f, 0.280029f, 0.296143f, 0.312012f, 0.329346f, 0.346924f, 0.364990f, 0.384277f, 0.403564f, 0.423340f, 0.718262f, 0.738770f,
+ 0.741211f, 0.742188f, 0.741211f, 0.740234f, 0.000785f, 0.002600f, 0.004028f, 0.005390f, 0.007275f, 0.008774f, 0.010124f, 0.011620f,
+ 0.013306f, 0.014427f, 0.015991f, 0.017838f, 0.019577f, 0.021469f, 0.023254f, 0.024902f, 0.027115f, 0.029190f, 0.031677f, 0.034088f,
+ 0.036682f, 0.039307f, 0.042175f, 0.045410f, 0.048553f, 0.052002f, 0.055908f, 0.060028f, 0.064270f, 0.068909f, 0.074097f, 0.079163f,
+ 0.085022f, 0.091309f, 0.097473f, 0.104797f, 0.112183f, 0.120239f, 0.128662f, 0.137451f, 0.146973f, 0.157471f, 0.168213f, 0.179810f,
+ 0.191650f, 0.204468f, 0.217529f, 0.231201f, 0.245605f, 0.260254f, 0.275879f, 0.292236f, 0.308838f, 0.326416f, 0.344238f, 0.363037f,
+ 0.382080f, 0.403076f, 0.707031f, 0.729980f, 0.732422f, 0.733398f, 0.733398f, 0.732910f, 0.000775f, 0.002190f, 0.003696f, 0.005081f,
+ 0.006397f, 0.007858f, 0.009239f, 0.010323f, 0.011803f, 0.012978f, 0.014328f, 0.015915f, 0.017349f, 0.019058f, 0.020630f, 0.022339f,
+ 0.024445f, 0.025909f, 0.028275f, 0.030151f, 0.032532f, 0.035065f, 0.037476f, 0.040283f, 0.042969f, 0.046448f, 0.049469f, 0.053314f,
+ 0.056976f, 0.061371f, 0.065613f, 0.070435f, 0.075623f, 0.081360f, 0.087341f, 0.093628f, 0.100220f, 0.107788f, 0.115845f, 0.123901f,
+ 0.133057f, 0.142456f, 0.152832f, 0.163574f, 0.174561f, 0.187012f, 0.199463f, 0.212646f, 0.226562f, 0.241455f, 0.256836f, 0.272705f,
+ 0.288818f, 0.305664f, 0.323486f, 0.341797f, 0.362305f, 0.382080f, 0.695312f, 0.719238f, 0.722656f, 0.724121f, 0.724121f, 0.723633f,
+ 0.000906f, 0.002022f, 0.003521f, 0.004963f, 0.005756f, 0.006847f, 0.008446f, 0.009392f, 0.010437f, 0.012039f, 0.012863f, 0.014343f,
+ 0.015457f, 0.016876f, 0.018295f, 0.019730f, 0.021484f, 0.023102f, 0.024689f, 0.026581f, 0.028717f, 0.030945f, 0.032928f, 0.035370f,
+ 0.037872f, 0.040894f, 0.043915f, 0.047028f, 0.050415f, 0.054169f, 0.058167f, 0.062286f, 0.067078f, 0.071960f, 0.077209f, 0.082947f,
+ 0.089417f, 0.096008f, 0.103271f, 0.110718f, 0.119324f, 0.128052f, 0.137817f, 0.147705f, 0.158691f, 0.169922f, 0.181519f, 0.195435f,
+ 0.208496f, 0.222534f, 0.237305f, 0.252441f, 0.268799f, 0.285645f, 0.302979f, 0.322266f, 0.340332f, 0.360840f, 0.683594f, 0.708984f,
+ 0.714355f, 0.715332f, 0.715820f, 0.715332f, 0.000700f, 0.002043f, 0.003139f, 0.004219f, 0.005417f, 0.006477f, 0.007442f, 0.008415f,
+ 0.009499f, 0.010475f, 0.011497f, 0.012619f, 0.013824f, 0.014969f, 0.016190f, 0.017639f, 0.018799f, 0.020386f, 0.021896f, 0.023560f,
+ 0.025131f, 0.027176f, 0.028900f, 0.031067f, 0.033295f, 0.035919f, 0.038239f, 0.041229f, 0.044373f, 0.047394f, 0.050934f, 0.054871f,
+ 0.058838f, 0.063293f, 0.068115f, 0.073303f, 0.078857f, 0.084839f, 0.091309f, 0.098328f, 0.106079f, 0.114136f, 0.123230f, 0.132690f,
+ 0.143066f, 0.153442f, 0.165161f, 0.177368f, 0.190186f, 0.203979f, 0.218262f, 0.232910f, 0.248901f, 0.265381f, 0.282227f, 0.301025f,
+ 0.319580f, 0.339355f, 0.672852f, 0.699707f, 0.704590f, 0.706055f, 0.706543f, 0.706055f, 0.000762f, 0.001804f, 0.002762f, 0.003914f,
+ 0.004791f, 0.005764f, 0.006542f, 0.007622f, 0.008606f, 0.009232f, 0.010178f, 0.011093f, 0.012108f, 0.013191f, 0.014412f, 0.015289f,
+ 0.016510f, 0.017731f, 0.019119f, 0.020615f, 0.022049f, 0.023483f, 0.025345f, 0.027100f, 0.028885f, 0.031067f, 0.033417f, 0.035797f,
+ 0.038422f, 0.041382f, 0.044495f, 0.047638f, 0.051178f, 0.055267f, 0.059387f, 0.064026f, 0.069092f, 0.074585f, 0.080566f, 0.087097f,
+ 0.093811f, 0.101624f, 0.109619f, 0.117798f, 0.127319f, 0.137817f, 0.148682f, 0.160278f, 0.172607f, 0.185669f, 0.199097f, 0.214233f,
+ 0.229492f, 0.245850f, 0.261963f, 0.280273f, 0.299316f, 0.319580f, 0.660645f, 0.689453f, 0.694824f, 0.696777f, 0.697266f, 0.697266f,
+ 0.000499f, 0.001527f, 0.002565f, 0.003622f, 0.004429f, 0.005138f, 0.005955f, 0.006691f, 0.007317f, 0.008156f, 0.008949f, 0.009903f,
+ 0.010635f, 0.011452f, 0.012512f, 0.013451f, 0.014503f, 0.015610f, 0.016632f, 0.017746f, 0.019073f, 0.020355f, 0.021957f, 0.023453f,
+ 0.025208f, 0.026932f, 0.028732f, 0.030945f, 0.033142f, 0.035614f, 0.038300f, 0.041199f, 0.044464f, 0.047760f, 0.051514f, 0.055573f,
+ 0.059998f, 0.064819f, 0.070312f, 0.075867f, 0.082275f, 0.088806f, 0.096436f, 0.104797f, 0.113342f, 0.122559f, 0.132568f, 0.143799f,
+ 0.155396f, 0.167725f, 0.181274f, 0.195068f, 0.209961f, 0.225708f, 0.242310f, 0.259766f, 0.277832f, 0.297363f, 0.648926f, 0.678711f,
+ 0.685059f, 0.687500f, 0.687500f, 0.687988f, 0.000653f, 0.001627f, 0.002562f, 0.003166f, 0.003872f, 0.004562f, 0.005287f, 0.005905f,
+ 0.006557f, 0.007309f, 0.007835f, 0.008621f, 0.009140f, 0.010109f, 0.010773f, 0.011627f, 0.012428f, 0.013351f, 0.014488f, 0.015472f,
+ 0.016479f, 0.017578f, 0.018845f, 0.020157f, 0.021591f, 0.023132f, 0.024765f, 0.026337f, 0.028473f, 0.030594f, 0.032867f, 0.035309f,
+ 0.037933f, 0.041107f, 0.044403f, 0.047852f, 0.051666f, 0.055756f, 0.060455f, 0.065552f, 0.070740f, 0.077454f, 0.083862f, 0.091125f,
+ 0.099304f, 0.107971f, 0.117859f, 0.127808f, 0.139038f, 0.150757f, 0.163574f, 0.176880f, 0.191162f, 0.206665f, 0.222656f, 0.239258f,
+ 0.257568f, 0.277100f, 0.636230f, 0.667969f, 0.675293f, 0.677734f, 0.678223f, 0.678711f, 0.000393f, 0.001375f, 0.002174f, 0.002773f,
+ 0.003334f, 0.004070f, 0.004692f, 0.005047f, 0.005672f, 0.006298f, 0.006893f, 0.007454f, 0.007957f, 0.008636f, 0.009171f, 0.010002f,
+ 0.010674f, 0.011574f, 0.012451f, 0.013145f, 0.014091f, 0.014893f, 0.016083f, 0.017151f, 0.018402f, 0.019714f, 0.021042f, 0.022415f,
+ 0.024155f, 0.026108f, 0.027786f, 0.030212f, 0.032379f, 0.034698f, 0.037415f, 0.040436f, 0.043793f, 0.047455f, 0.051727f, 0.056030f,
+ 0.061218f, 0.066284f, 0.072571f, 0.079041f, 0.086121f, 0.094299f, 0.102844f, 0.112305f, 0.122925f, 0.134033f, 0.145752f, 0.158569f,
+ 0.172729f, 0.187378f, 0.203003f, 0.219238f, 0.237671f, 0.255859f, 0.624023f, 0.657227f, 0.664062f, 0.666992f, 0.668457f, 0.668457f,
+ 0.000379f, 0.001404f, 0.001893f, 0.002403f, 0.002840f, 0.003458f, 0.004021f, 0.004459f, 0.004894f, 0.005527f, 0.005844f, 0.006256f,
+ 0.006866f, 0.007423f, 0.007957f, 0.008476f, 0.009155f, 0.009735f, 0.010422f, 0.011078f, 0.011925f, 0.012787f, 0.013458f, 0.014526f,
+ 0.015541f, 0.016632f, 0.017838f, 0.019028f, 0.020248f, 0.021851f, 0.023514f, 0.024979f, 0.027054f, 0.029236f, 0.031555f, 0.034180f,
+ 0.036713f, 0.040375f, 0.043854f, 0.047607f, 0.051727f, 0.056549f, 0.061768f, 0.067627f, 0.073792f, 0.081116f, 0.089111f, 0.097595f,
+ 0.107056f, 0.117371f, 0.128906f, 0.141113f, 0.154053f, 0.168579f, 0.183960f, 0.199585f, 0.216309f, 0.235352f, 0.612793f, 0.647949f,
+ 0.652832f, 0.656250f, 0.658691f, 0.658203f, 0.000506f, 0.001164f, 0.001575f, 0.002136f, 0.002600f, 0.003054f, 0.003405f, 0.003735f,
+ 0.004364f, 0.004681f, 0.004944f, 0.005569f, 0.005810f, 0.006187f, 0.006813f, 0.007233f, 0.007881f, 0.008217f, 0.008850f, 0.009293f,
+ 0.010109f, 0.010788f, 0.011543f, 0.012161f, 0.012993f, 0.013931f, 0.014809f, 0.015945f, 0.016983f, 0.018234f, 0.019440f, 0.020813f,
+ 0.022491f, 0.024261f, 0.026169f, 0.028458f, 0.030701f, 0.033295f, 0.036560f, 0.039520f, 0.043121f, 0.047333f, 0.052032f, 0.056885f,
+ 0.062561f, 0.068909f, 0.076111f, 0.083496f, 0.092407f, 0.101929f, 0.112671f, 0.124451f, 0.136719f, 0.150146f, 0.165039f, 0.180786f,
+ 0.197510f, 0.215210f, 0.597656f, 0.636230f, 0.642578f, 0.647461f, 0.647949f, 0.649902f, 0.000344f, 0.001057f, 0.001456f, 0.001907f,
+ 0.002377f, 0.002735f, 0.002983f, 0.003359f, 0.003651f, 0.003960f, 0.004311f, 0.004471f, 0.005009f, 0.005283f, 0.005653f, 0.006145f,
+ 0.006592f, 0.006889f, 0.007469f, 0.007889f, 0.008423f, 0.008911f, 0.009567f, 0.010124f, 0.010788f, 0.011574f, 0.012466f, 0.013123f,
+ 0.014053f, 0.015091f, 0.016159f, 0.017288f, 0.018539f, 0.020111f, 0.021698f, 0.023285f, 0.025024f, 0.027405f, 0.029800f, 0.032501f,
+ 0.035583f, 0.039001f, 0.042908f, 0.047302f, 0.052185f, 0.057465f, 0.063843f, 0.070984f, 0.078857f, 0.087463f, 0.097168f, 0.108215f,
+ 0.120117f, 0.132812f, 0.146851f, 0.161865f, 0.177856f, 0.195557f, 0.585449f, 0.624023f, 0.633301f, 0.636230f, 0.637695f, 0.638672f,
+ 0.000516f, 0.000847f, 0.001210f, 0.001663f, 0.002012f, 0.002218f, 0.002424f, 0.002861f, 0.002947f, 0.003275f, 0.003469f, 0.003819f,
+ 0.004169f, 0.004337f, 0.004658f, 0.005169f, 0.005424f, 0.005795f, 0.006138f, 0.006500f, 0.007057f, 0.007458f, 0.007874f, 0.008369f,
+ 0.008888f, 0.009583f, 0.010147f, 0.010864f, 0.011589f, 0.012428f, 0.013161f, 0.013931f, 0.015076f, 0.016266f, 0.017456f, 0.018845f,
+ 0.020432f, 0.022232f, 0.024094f, 0.026459f, 0.028809f, 0.031586f, 0.034973f, 0.038513f, 0.042755f, 0.047485f, 0.052643f, 0.058929f,
+ 0.065796f, 0.073792f, 0.082581f, 0.092407f, 0.103516f, 0.115723f, 0.128906f, 0.142944f, 0.158813f, 0.175781f, 0.572266f, 0.613770f,
+ 0.621094f, 0.625977f, 0.626953f, 0.628418f, 0.000262f, 0.000864f, 0.001096f, 0.001409f, 0.001576f, 0.001852f, 0.002047f, 0.002247f,
+ 0.002518f, 0.002741f, 0.002956f, 0.003157f, 0.003359f, 0.003597f, 0.003872f, 0.004230f, 0.004406f, 0.004772f, 0.005035f, 0.005379f,
+ 0.005695f, 0.006153f, 0.006485f, 0.006935f, 0.007275f, 0.007801f, 0.008301f, 0.008789f, 0.009300f, 0.009949f, 0.010727f, 0.011482f,
+ 0.012245f, 0.013145f, 0.014236f, 0.015236f, 0.016525f, 0.017838f, 0.019348f, 0.021088f, 0.023010f, 0.025253f, 0.027878f, 0.031128f,
+ 0.034149f, 0.038269f, 0.042694f, 0.047852f, 0.053833f, 0.060852f, 0.068665f, 0.077698f, 0.087891f, 0.099182f, 0.111633f, 0.125732f,
+ 0.140381f, 0.157227f, 0.558105f, 0.601562f, 0.610840f, 0.614746f, 0.617188f, 0.619141f, 0.000270f, 0.000683f, 0.000851f, 0.001138f,
+ 0.001346f, 0.001561f, 0.001701f, 0.001884f, 0.001984f, 0.002193f, 0.002455f, 0.002609f, 0.002743f, 0.002993f, 0.003159f, 0.003361f,
+ 0.003593f, 0.003883f, 0.004044f, 0.004360f, 0.004532f, 0.004971f, 0.005169f, 0.005573f, 0.005863f, 0.006252f, 0.006653f, 0.007095f,
+ 0.007572f, 0.008110f, 0.008713f, 0.009056f, 0.009827f, 0.010574f, 0.011307f, 0.012070f, 0.013069f, 0.014122f, 0.015297f, 0.016678f,
+ 0.018234f, 0.019775f, 0.021835f, 0.024216f, 0.026917f, 0.030151f, 0.033875f, 0.038147f, 0.043121f, 0.049408f, 0.056091f, 0.064026f,
+ 0.073059f, 0.083801f, 0.095276f, 0.108459f, 0.122803f, 0.138794f, 0.545410f, 0.590332f, 0.599609f, 0.603516f, 0.606445f, 0.607422f,
+ 0.000190f, 0.000607f, 0.000724f, 0.000989f, 0.001171f, 0.001265f, 0.001416f, 0.001602f, 0.001666f, 0.001761f, 0.001893f, 0.002102f,
+ 0.002199f, 0.002413f, 0.002537f, 0.002743f, 0.002850f, 0.003027f, 0.003258f, 0.003494f, 0.003729f, 0.003937f, 0.004204f, 0.004410f,
+ 0.004616f, 0.004921f, 0.005192f, 0.005604f, 0.005936f, 0.006298f, 0.006836f, 0.007233f, 0.007694f, 0.008224f, 0.008827f, 0.009506f,
+ 0.010262f, 0.011055f, 0.011978f, 0.012955f, 0.014099f, 0.015434f, 0.017029f, 0.018677f, 0.020813f, 0.023193f, 0.026169f, 0.029541f,
+ 0.033783f, 0.038513f, 0.044403f, 0.051208f, 0.059387f, 0.068665f, 0.079468f, 0.091858f, 0.105774f, 0.120728f, 0.530762f, 0.578125f,
+ 0.588379f, 0.592773f, 0.595215f, 0.597168f, 0.000151f, 0.000443f, 0.000673f, 0.000793f, 0.000937f, 0.000987f, 0.001092f, 0.001192f,
+ 0.001324f, 0.001460f, 0.001495f, 0.001565f, 0.001778f, 0.001944f, 0.002054f, 0.002096f, 0.002254f, 0.002338f, 0.002594f, 0.002737f,
+ 0.002886f, 0.003048f, 0.003294f, 0.003460f, 0.003679f, 0.003868f, 0.004086f, 0.004322f, 0.004642f, 0.004894f, 0.005199f, 0.005554f,
+ 0.006035f, 0.006451f, 0.006836f, 0.007359f, 0.007820f, 0.008461f, 0.009163f, 0.009956f, 0.010803f, 0.011871f, 0.012917f, 0.014343f,
+ 0.015900f, 0.017670f, 0.019791f, 0.022400f, 0.025589f, 0.029404f, 0.034210f, 0.039948f, 0.046936f, 0.055298f, 0.064941f, 0.076172f,
+ 0.089172f, 0.103821f, 0.517090f, 0.565918f, 0.576172f, 0.582031f, 0.584961f, 0.586426f, 0.000203f, 0.000287f, 0.000531f, 0.000688f,
+ 0.000738f, 0.000820f, 0.000915f, 0.000875f, 0.001036f, 0.001117f, 0.001215f, 0.001317f, 0.001374f, 0.001476f, 0.001524f, 0.001682f,
+ 0.001726f, 0.001867f, 0.002014f, 0.002056f, 0.002209f, 0.002365f, 0.002495f, 0.002663f, 0.002775f, 0.002953f, 0.003134f, 0.003325f,
+ 0.003567f, 0.003736f, 0.004070f, 0.004261f, 0.004494f, 0.004845f, 0.005116f, 0.005459f, 0.005928f, 0.006329f, 0.006863f, 0.007458f,
+ 0.008087f, 0.008873f, 0.009689f, 0.010651f, 0.011826f, 0.013130f, 0.014732f, 0.016617f, 0.018890f, 0.021912f, 0.025482f, 0.029938f,
+ 0.035736f, 0.042847f, 0.051453f, 0.061615f, 0.074158f, 0.087952f, 0.504395f, 0.554199f, 0.565918f, 0.569336f, 0.573242f, 0.574219f,
+ 0.000215f, 0.000259f, 0.000423f, 0.000534f, 0.000499f, 0.000649f, 0.000622f, 0.000690f, 0.000717f, 0.000817f, 0.000937f, 0.000984f,
+ 0.001045f, 0.001148f, 0.001182f, 0.001211f, 0.001339f, 0.001406f, 0.001463f, 0.001590f, 0.001666f, 0.001759f, 0.001867f, 0.001949f,
+ 0.002064f, 0.002176f, 0.002342f, 0.002453f, 0.002619f, 0.002871f, 0.003033f, 0.003101f, 0.003389f, 0.003620f, 0.003794f, 0.004059f,
+ 0.004368f, 0.004681f, 0.005035f, 0.005466f, 0.005917f, 0.006405f, 0.007092f, 0.007744f, 0.008591f, 0.009506f, 0.010567f, 0.011993f,
+ 0.013710f, 0.015762f, 0.018326f, 0.021759f, 0.026077f, 0.031891f, 0.039124f, 0.048462f, 0.059570f, 0.072571f, 0.489258f, 0.542480f,
+ 0.553223f, 0.558594f, 0.562012f, 0.563965f, 0.000067f, 0.000253f, 0.000305f, 0.000367f, 0.000422f, 0.000431f, 0.000530f, 0.000466f,
+ 0.000565f, 0.000590f, 0.000702f, 0.000690f, 0.000746f, 0.000795f, 0.000859f, 0.000897f, 0.000962f, 0.001021f, 0.001069f, 0.001105f,
+ 0.001207f, 0.001257f, 0.001354f, 0.001424f, 0.001483f, 0.001570f, 0.001687f, 0.001750f, 0.001857f, 0.001982f, 0.002071f, 0.002281f,
+ 0.002361f, 0.002527f, 0.002684f, 0.002846f, 0.003092f, 0.003342f, 0.003622f, 0.003866f, 0.004173f, 0.004520f, 0.004955f, 0.005428f,
+ 0.006023f, 0.006687f, 0.007481f, 0.008446f, 0.009628f, 0.011047f, 0.012840f, 0.015205f, 0.018326f, 0.022629f, 0.028442f, 0.036102f,
+ 0.046051f, 0.058197f, 0.476318f, 0.529785f, 0.541992f, 0.547852f, 0.550293f, 0.553223f, 0.000000f, 0.000118f, 0.000216f, 0.000288f,
+ 0.000272f, 0.000350f, 0.000312f, 0.000374f, 0.000395f, 0.000470f, 0.000488f, 0.000477f, 0.000495f, 0.000548f, 0.000573f, 0.000646f,
+ 0.000636f, 0.000714f, 0.000763f, 0.000803f, 0.000852f, 0.000897f, 0.000930f, 0.000985f, 0.001056f, 0.001089f, 0.001163f, 0.001210f,
+ 0.001281f, 0.001432f, 0.001431f, 0.001548f, 0.001622f, 0.001743f, 0.001869f, 0.001991f, 0.002104f, 0.002262f, 0.002428f, 0.002632f,
+ 0.002815f, 0.003077f, 0.003344f, 0.003656f, 0.004002f, 0.004478f, 0.004974f, 0.005627f, 0.006435f, 0.007481f, 0.008713f, 0.010307f,
+ 0.012291f, 0.015289f, 0.019409f, 0.025497f, 0.033966f, 0.045013f, 0.461914f, 0.517090f, 0.529297f, 0.536133f, 0.539551f, 0.541504f,
+ 0.000073f, 0.000175f, 0.000165f, 0.000149f, 0.000200f, 0.000208f, 0.000215f, 0.000260f, 0.000268f, 0.000277f, 0.000292f, 0.000341f,
+ 0.000334f, 0.000370f, 0.000413f, 0.000424f, 0.000449f, 0.000474f, 0.000488f, 0.000507f, 0.000555f, 0.000574f, 0.000616f, 0.000652f,
+ 0.000696f, 0.000746f, 0.000780f, 0.000804f, 0.000849f, 0.000888f, 0.000949f, 0.001011f, 0.001075f, 0.001151f, 0.001225f, 0.001266f,
+ 0.001385f, 0.001466f, 0.001596f, 0.001699f, 0.001808f, 0.001980f, 0.002157f, 0.002329f, 0.002544f, 0.002850f, 0.003178f, 0.003593f,
+ 0.004047f, 0.004658f, 0.005508f, 0.006565f, 0.007935f, 0.009819f, 0.012527f, 0.016647f, 0.023514f, 0.033173f, 0.447510f, 0.503906f,
+ 0.517578f, 0.523926f, 0.527344f, 0.529297f, 0.000000f, 0.000106f, 0.000097f, 0.000099f, 0.000136f, 0.000157f, 0.000129f, 0.000162f,
+ 0.000167f, 0.000172f, 0.000180f, 0.000186f, 0.000209f, 0.000227f, 0.000232f, 0.000248f, 0.000260f, 0.000291f, 0.000300f, 0.000327f,
+ 0.000335f, 0.000343f, 0.000363f, 0.000395f, 0.000428f, 0.000459f, 0.000458f, 0.000477f, 0.000515f, 0.000549f, 0.000578f, 0.000621f,
+ 0.000659f, 0.000683f, 0.000741f, 0.000767f, 0.000818f, 0.000877f, 0.000952f, 0.001010f, 0.001085f, 0.001177f, 0.001275f, 0.001406f,
+ 0.001516f, 0.001664f, 0.001884f, 0.002096f, 0.002415f, 0.002745f, 0.003231f, 0.003843f, 0.004715f, 0.005936f, 0.007629f, 0.010139f,
+ 0.014763f, 0.022812f, 0.433350f, 0.491455f, 0.506348f, 0.511719f, 0.515625f, 0.518066f, 0.000104f, 0.000080f, 0.000069f, 0.000062f,
+ 0.000074f, 0.000074f, 0.000089f, 0.000097f, 0.000099f, 0.000102f, 0.000105f, 0.000126f, 0.000106f, 0.000119f, 0.000139f, 0.000135f,
+ 0.000154f, 0.000164f, 0.000166f, 0.000175f, 0.000188f, 0.000194f, 0.000211f, 0.000220f, 0.000252f, 0.000248f, 0.000260f, 0.000272f,
+ 0.000293f, 0.000301f, 0.000328f, 0.000347f, 0.000365f, 0.000371f, 0.000401f, 0.000422f, 0.000447f, 0.000489f, 0.000524f, 0.000553f,
+ 0.000588f, 0.000635f, 0.000701f, 0.000751f, 0.000816f, 0.000897f, 0.000997f, 0.001109f, 0.001265f, 0.001460f, 0.001686f, 0.002035f,
+ 0.002457f, 0.003130f, 0.004124f, 0.005676f, 0.008263f, 0.014114f, 0.418945f, 0.479492f, 0.493652f, 0.500000f, 0.503418f, 0.506836f,
+ 0.000089f, 0.000065f, 0.000056f, 0.000050f, 0.000045f, 0.000042f, 0.000046f, 0.000042f, 0.000043f, 0.000055f, 0.000046f, 0.000049f,
+ 0.000065f, 0.000055f, 0.000057f, 0.000063f, 0.000075f, 0.000080f, 0.000078f, 0.000084f, 0.000085f, 0.000092f, 0.000097f, 0.000102f,
+ 0.000108f, 0.000117f, 0.000118f, 0.000138f, 0.000135f, 0.000142f, 0.000151f, 0.000160f, 0.000172f, 0.000180f, 0.000195f, 0.000197f,
+ 0.000210f, 0.000230f, 0.000244f, 0.000266f, 0.000279f, 0.000299f, 0.000324f, 0.000352f, 0.000383f, 0.000414f, 0.000457f, 0.000509f,
+ 0.000575f, 0.000650f, 0.000756f, 0.000904f, 0.001103f, 0.001410f, 0.001880f, 0.002668f, 0.004112f, 0.007290f, 0.404541f, 0.466309f,
+ 0.481201f, 0.488037f, 0.492432f, 0.495361f, 0.000066f, 0.000046f, 0.000038f, 0.000034f, 0.000031f, 0.000029f, 0.000027f, 0.000026f,
+ 0.000025f, 0.000023f, 0.000022f, 0.000024f, 0.000020f, 0.000021f, 0.000021f, 0.000026f, 0.000024f, 0.000028f, 0.000031f, 0.000032f,
+ 0.000032f, 0.000035f, 0.000040f, 0.000038f, 0.000041f, 0.000047f, 0.000049f, 0.000043f, 0.000050f, 0.000052f, 0.000056f, 0.000059f,
+ 0.000066f, 0.000062f, 0.000067f, 0.000071f, 0.000082f, 0.000083f, 0.000089f, 0.000098f, 0.000104f, 0.000107f, 0.000116f, 0.000125f,
+ 0.000141f, 0.000149f, 0.000160f, 0.000183f, 0.000207f, 0.000228f, 0.000264f, 0.000311f, 0.000376f, 0.000469f, 0.000646f, 0.000937f,
+ 0.001554f, 0.002983f, 0.390381f, 0.454346f, 0.469727f, 0.476318f, 0.480713f, 0.484131f, 0.000028f, 0.000019f, 0.000015f, 0.000014f,
+ 0.000014f, 0.000013f, 0.000012f, 0.000012f, 0.000012f, 0.000012f, 0.000011f, 0.000011f, 0.000011f, 0.000011f, 0.000011f, 0.000010f,
+ 0.000010f, 0.000009f, 0.000009f, 0.000009f, 0.000008f, 0.000008f, 0.000008f, 0.000007f, 0.000008f, 0.000009f, 0.000009f, 0.000010f,
+ 0.000010f, 0.000011f, 0.000012f, 0.000011f, 0.000014f, 0.000015f, 0.000016f, 0.000016f, 0.000018f, 0.000019f, 0.000019f, 0.000022f,
+ 0.000023f, 0.000024f, 0.000026f, 0.000028f, 0.000029f, 0.000032f, 0.000037f, 0.000037f, 0.000042f, 0.000048f, 0.000056f, 0.000066f,
+ 0.000077f, 0.000091f, 0.000124f, 0.000183f, 0.000318f, 0.000779f, 0.376465f, 0.441406f, 0.457275f, 0.464600f, 0.468994f, 0.471924f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000001f, 0.000001f, 0.000001f,
+ 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000002f,
+ 0.000002f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000002f,
+ 0.000002f, 0.000002f, 0.000003f, 0.000003f, 0.000003f, 0.000004f, 0.000004f, 0.000005f, 0.000010f, 0.000027f, 0.363037f, 0.428223f,
+ 0.444580f, 0.452881f, 0.457031f, 0.459961f,
+ },
+ {
+ 0.014420f, 0.043488f, 0.072388f, 0.100830f, 0.129150f, 0.156494f, 0.183350f, 0.210327f, 0.235352f, 0.260986f, 0.285645f, 0.309082f,
+ 0.332764f, 0.355713f, 0.377441f, 0.399658f, 0.420898f, 0.441650f, 0.461914f, 0.481445f, 0.500977f, 0.520508f, 0.538574f, 0.556641f,
+ 0.574707f, 0.591797f, 0.608398f, 0.624512f, 0.641602f, 0.657227f, 0.672363f, 0.687500f, 0.702148f, 0.717285f, 0.730957f, 0.745117f,
+ 0.758789f, 0.772461f, 0.783203f, 0.797363f, 0.810547f, 0.822266f, 0.833984f, 0.845703f, 0.857422f, 0.868652f, 0.879395f, 0.890625f,
+ 0.901367f, 0.911621f, 0.921875f, 0.932129f, 0.941895f, 0.951660f, 0.960938f, 0.970215f, 0.979492f, 0.987793f, 0.981934f, 0.957031f,
+ 0.938965f, 0.923340f, 0.909668f, 0.897461f, 0.013199f, 0.039978f, 0.066284f, 0.093445f, 0.119324f, 0.145386f, 0.170410f, 0.195801f,
+ 0.220581f, 0.244019f, 0.268066f, 0.291260f, 0.314453f, 0.335938f, 0.358154f, 0.379639f, 0.399902f, 0.420898f, 0.441406f, 0.460938f,
+ 0.480225f, 0.498291f, 0.516602f, 0.535156f, 0.553223f, 0.570312f, 0.587891f, 0.603516f, 0.620117f, 0.636719f, 0.652832f, 0.667480f,
+ 0.682617f, 0.696777f, 0.711914f, 0.726074f, 0.739746f, 0.753418f, 0.766602f, 0.779785f, 0.791992f, 0.804688f, 0.817871f, 0.829102f,
+ 0.841309f, 0.852539f, 0.864258f, 0.875488f, 0.886230f, 0.896973f, 0.907227f, 0.917969f, 0.928223f, 0.937500f, 0.947266f, 0.957520f,
+ 0.966797f, 0.975586f, 0.976562f, 0.952637f, 0.935547f, 0.920898f, 0.907715f, 0.895996f, 0.011932f, 0.036499f, 0.061554f, 0.085999f,
+ 0.110962f, 0.135010f, 0.158813f, 0.182373f, 0.206421f, 0.229004f, 0.251221f, 0.274170f, 0.295654f, 0.317871f, 0.339111f, 0.360107f,
+ 0.379395f, 0.399414f, 0.420654f, 0.440430f, 0.458252f, 0.477295f, 0.496094f, 0.513672f, 0.531738f, 0.549805f, 0.566406f, 0.583984f,
+ 0.599121f, 0.616211f, 0.631348f, 0.647461f, 0.662598f, 0.677734f, 0.692383f, 0.705566f, 0.720703f, 0.734863f, 0.748047f, 0.761230f,
+ 0.774414f, 0.787598f, 0.799805f, 0.812500f, 0.824707f, 0.837402f, 0.848633f, 0.859375f, 0.871094f, 0.882324f, 0.892578f, 0.904297f,
+ 0.913574f, 0.924316f, 0.934570f, 0.943848f, 0.954102f, 0.963867f, 0.970703f, 0.948242f, 0.931641f, 0.917480f, 0.905273f, 0.894043f,
+ 0.011070f, 0.033478f, 0.056396f, 0.079529f, 0.101990f, 0.125244f, 0.147705f, 0.170410f, 0.192139f, 0.214111f, 0.235596f, 0.257812f,
+ 0.279053f, 0.300293f, 0.320557f, 0.340576f, 0.360596f, 0.381104f, 0.400635f, 0.420166f, 0.438965f, 0.458008f, 0.476562f, 0.493652f,
+ 0.511230f, 0.527832f, 0.545898f, 0.562012f, 0.579102f, 0.595703f, 0.610840f, 0.627930f, 0.642578f, 0.657227f, 0.672363f, 0.686523f,
+ 0.701660f, 0.715332f, 0.729492f, 0.742676f, 0.756348f, 0.769531f, 0.782227f, 0.795898f, 0.807617f, 0.820312f, 0.832031f, 0.843262f,
+ 0.855469f, 0.866699f, 0.877441f, 0.889648f, 0.899414f, 0.910156f, 0.920410f, 0.930664f, 0.940430f, 0.950684f, 0.964844f, 0.943848f,
+ 0.927734f, 0.914551f, 0.902344f, 0.891602f, 0.010010f, 0.031067f, 0.051880f, 0.073303f, 0.094421f, 0.116577f, 0.136963f, 0.157959f,
+ 0.180542f, 0.200684f, 0.221436f, 0.242676f, 0.262939f, 0.283447f, 0.303467f, 0.323242f, 0.342529f, 0.362305f, 0.381348f, 0.399414f,
+ 0.418701f, 0.437256f, 0.455322f, 0.472412f, 0.490479f, 0.507812f, 0.524902f, 0.541992f, 0.558105f, 0.574219f, 0.591309f, 0.606445f,
+ 0.622070f, 0.637695f, 0.652344f, 0.666504f, 0.683594f, 0.695801f, 0.710449f, 0.724121f, 0.737305f, 0.751465f, 0.765137f, 0.777344f,
+ 0.790039f, 0.802734f, 0.814941f, 0.827637f, 0.839355f, 0.851074f, 0.862305f, 0.874512f, 0.885254f, 0.895996f, 0.906738f, 0.917480f,
+ 0.927246f, 0.937988f, 0.958984f, 0.939453f, 0.923828f, 0.911133f, 0.899414f, 0.889160f, 0.009491f, 0.028305f, 0.047699f, 0.067810f,
+ 0.087341f, 0.107849f, 0.127686f, 0.147827f, 0.167725f, 0.187744f, 0.207886f, 0.227051f, 0.247314f, 0.266846f, 0.286377f, 0.305908f,
+ 0.324463f, 0.343262f, 0.361572f, 0.380371f, 0.399658f, 0.416748f, 0.435547f, 0.452881f, 0.470703f, 0.488281f, 0.503906f, 0.522461f,
+ 0.538086f, 0.554199f, 0.571289f, 0.586914f, 0.602051f, 0.617676f, 0.633789f, 0.647949f, 0.663086f, 0.677246f, 0.692871f, 0.705078f,
+ 0.718750f, 0.732910f, 0.746582f, 0.759766f, 0.773438f, 0.785645f, 0.798340f, 0.811035f, 0.823242f, 0.834961f, 0.847168f, 0.859863f,
+ 0.870117f, 0.881348f, 0.893066f, 0.903320f, 0.914551f, 0.924316f, 0.953125f, 0.934082f, 0.919434f, 0.906738f, 0.896484f, 0.885742f,
+ 0.008598f, 0.026245f, 0.044495f, 0.062622f, 0.081177f, 0.100098f, 0.119019f, 0.137817f, 0.156616f, 0.175903f, 0.194946f, 0.213745f,
+ 0.232788f, 0.251221f, 0.269775f, 0.288330f, 0.307129f, 0.325928f, 0.344238f, 0.362305f, 0.380371f, 0.397705f, 0.415771f, 0.433105f,
+ 0.450928f, 0.468262f, 0.484863f, 0.501953f, 0.518555f, 0.534668f, 0.550293f, 0.566406f, 0.582520f, 0.598145f, 0.612305f, 0.627930f,
+ 0.643555f, 0.657715f, 0.672852f, 0.687500f, 0.700684f, 0.715332f, 0.728516f, 0.742188f, 0.755371f, 0.769531f, 0.781738f, 0.794434f,
+ 0.807129f, 0.818359f, 0.831543f, 0.843262f, 0.855469f, 0.865723f, 0.877930f, 0.889160f, 0.900391f, 0.911621f, 0.946777f, 0.929199f,
+ 0.915039f, 0.903320f, 0.892578f, 0.883301f, 0.007896f, 0.024490f, 0.041138f, 0.057892f, 0.075439f, 0.092712f, 0.110229f, 0.128296f,
+ 0.146118f, 0.164429f, 0.181885f, 0.200562f, 0.218628f, 0.236572f, 0.255127f, 0.272949f, 0.291016f, 0.308594f, 0.326172f, 0.343994f,
+ 0.361816f, 0.380127f, 0.396973f, 0.414551f, 0.430908f, 0.447998f, 0.465576f, 0.481445f, 0.497559f, 0.514160f, 0.529785f, 0.546387f,
+ 0.562988f, 0.578613f, 0.593262f, 0.609375f, 0.623047f, 0.638672f, 0.653809f, 0.667480f, 0.681641f, 0.697266f, 0.710938f, 0.724121f,
+ 0.737305f, 0.752441f, 0.765625f, 0.776367f, 0.790527f, 0.803223f, 0.815918f, 0.827637f, 0.839844f, 0.851562f, 0.863281f, 0.875000f,
+ 0.886719f, 0.898926f, 0.940430f, 0.923828f, 0.910645f, 0.899414f, 0.889160f, 0.879883f, 0.007320f, 0.022369f, 0.038055f, 0.053925f,
+ 0.070190f, 0.086609f, 0.103027f, 0.119568f, 0.136475f, 0.153320f, 0.170532f, 0.187988f, 0.204834f, 0.223022f, 0.240112f, 0.257324f,
+ 0.275391f, 0.291504f, 0.308838f, 0.326904f, 0.344727f, 0.361572f, 0.378662f, 0.395020f, 0.411865f, 0.428711f, 0.445068f, 0.462646f,
+ 0.478271f, 0.494141f, 0.510254f, 0.525879f, 0.542480f, 0.557129f, 0.573242f, 0.588867f, 0.603516f, 0.618164f, 0.633789f, 0.648438f,
+ 0.663086f, 0.678223f, 0.691895f, 0.706543f, 0.720215f, 0.733398f, 0.746582f, 0.759766f, 0.774414f, 0.786621f, 0.799805f, 0.811523f,
+ 0.823730f, 0.836914f, 0.848145f, 0.860840f, 0.872070f, 0.884277f, 0.933594f, 0.918945f, 0.906250f, 0.895020f, 0.885254f, 0.876953f,
+ 0.006760f, 0.021011f, 0.034973f, 0.050049f, 0.065369f, 0.080261f, 0.095337f, 0.111633f, 0.127319f, 0.142822f, 0.159668f, 0.176514f,
+ 0.192383f, 0.209106f, 0.225586f, 0.242554f, 0.259277f, 0.275635f, 0.292480f, 0.309326f, 0.326904f, 0.343750f, 0.359619f, 0.376465f,
+ 0.393066f, 0.409424f, 0.426514f, 0.442871f, 0.458252f, 0.475586f, 0.490967f, 0.505859f, 0.522461f, 0.539062f, 0.554199f, 0.569336f,
+ 0.583984f, 0.600586f, 0.614258f, 0.630371f, 0.643555f, 0.658691f, 0.673340f, 0.687500f, 0.702148f, 0.715332f, 0.729980f, 0.743652f,
+ 0.756348f, 0.770020f, 0.782715f, 0.796387f, 0.808105f, 0.820801f, 0.833008f, 0.846680f, 0.857910f, 0.870117f, 0.927246f, 0.913574f,
+ 0.901367f, 0.891113f, 0.881348f, 0.873047f, 0.006367f, 0.019165f, 0.032379f, 0.046295f, 0.060089f, 0.074463f, 0.088867f, 0.103821f,
+ 0.118835f, 0.133911f, 0.149048f, 0.164673f, 0.180298f, 0.196289f, 0.212524f, 0.228516f, 0.244385f, 0.260742f, 0.277344f, 0.293213f,
+ 0.309570f, 0.326416f, 0.342773f, 0.358887f, 0.374512f, 0.391113f, 0.406982f, 0.423340f, 0.439453f, 0.455078f, 0.470947f, 0.487793f,
+ 0.502441f, 0.519043f, 0.533691f, 0.550293f, 0.564941f, 0.580078f, 0.595703f, 0.610840f, 0.625488f, 0.640137f, 0.654785f, 0.669434f,
+ 0.683594f, 0.696777f, 0.710938f, 0.725586f, 0.738770f, 0.752441f, 0.766113f, 0.778320f, 0.791016f, 0.805176f, 0.818359f, 0.830566f,
+ 0.842773f, 0.854980f, 0.920410f, 0.908203f, 0.896484f, 0.886230f, 0.877441f, 0.868652f, 0.005981f, 0.017914f, 0.030350f, 0.042908f,
+ 0.056213f, 0.069092f, 0.083008f, 0.096619f, 0.111084f, 0.124634f, 0.139526f, 0.154297f, 0.169312f, 0.184570f, 0.199951f, 0.215454f,
+ 0.230713f, 0.245728f, 0.261963f, 0.277588f, 0.293213f, 0.309326f, 0.325195f, 0.340820f, 0.356934f, 0.373047f, 0.388916f, 0.404785f,
+ 0.420410f, 0.436279f, 0.452148f, 0.468506f, 0.483154f, 0.499756f, 0.515137f, 0.530762f, 0.545898f, 0.560059f, 0.576172f, 0.590820f,
+ 0.606445f, 0.621094f, 0.635254f, 0.649902f, 0.663574f, 0.678223f, 0.692383f, 0.706543f, 0.720703f, 0.733887f, 0.748535f, 0.762695f,
+ 0.775391f, 0.789551f, 0.801758f, 0.814941f, 0.828125f, 0.840332f, 0.913574f, 0.902344f, 0.890625f, 0.881836f, 0.872559f, 0.865234f,
+ 0.005402f, 0.016617f, 0.028061f, 0.039948f, 0.051758f, 0.064270f, 0.076782f, 0.089600f, 0.102600f, 0.116455f, 0.130371f, 0.144165f,
+ 0.158936f, 0.172607f, 0.187744f, 0.201904f, 0.216431f, 0.232422f, 0.247192f, 0.261719f, 0.277100f, 0.292480f, 0.308838f, 0.323975f,
+ 0.339355f, 0.355469f, 0.371338f, 0.386230f, 0.402344f, 0.417725f, 0.433350f, 0.448486f, 0.464600f, 0.480225f, 0.495361f, 0.510742f,
+ 0.525879f, 0.541992f, 0.557129f, 0.571777f, 0.586914f, 0.601562f, 0.616211f, 0.631836f, 0.645508f, 0.661621f, 0.674805f, 0.688965f,
+ 0.703125f, 0.717773f, 0.731934f, 0.745605f, 0.757812f, 0.772949f, 0.785156f, 0.799316f, 0.812012f, 0.826172f, 0.906738f, 0.896484f,
+ 0.886230f, 0.876465f, 0.868164f, 0.860840f, 0.005264f, 0.015457f, 0.026474f, 0.037170f, 0.048157f, 0.059845f, 0.071594f, 0.083984f,
+ 0.096191f, 0.109070f, 0.121887f, 0.134766f, 0.148193f, 0.161255f, 0.175781f, 0.189209f, 0.203369f, 0.218384f, 0.233032f, 0.247681f,
+ 0.261963f, 0.277100f, 0.292480f, 0.307129f, 0.322998f, 0.337891f, 0.352539f, 0.368652f, 0.384033f, 0.399170f, 0.414307f, 0.430420f,
+ 0.445801f, 0.460693f, 0.475342f, 0.491211f, 0.506836f, 0.521973f, 0.537598f, 0.551758f, 0.567383f, 0.582520f, 0.598145f, 0.612305f,
+ 0.627441f, 0.642090f, 0.656738f, 0.670898f, 0.685059f, 0.698730f, 0.713867f, 0.728516f, 0.742188f, 0.755371f, 0.770020f, 0.782715f,
+ 0.796387f, 0.810547f, 0.899414f, 0.889648f, 0.879883f, 0.872070f, 0.863770f, 0.856445f, 0.004719f, 0.014229f, 0.024384f, 0.034607f,
+ 0.044708f, 0.055756f, 0.066895f, 0.077942f, 0.089600f, 0.101624f, 0.113525f, 0.125854f, 0.138428f, 0.151245f, 0.164673f, 0.177734f,
+ 0.191650f, 0.205078f, 0.219360f, 0.233154f, 0.247925f, 0.261475f, 0.276367f, 0.291504f, 0.305908f, 0.320312f, 0.335449f, 0.350098f,
+ 0.365723f, 0.380615f, 0.395996f, 0.411133f, 0.427002f, 0.441895f, 0.456543f, 0.472656f, 0.487793f, 0.502441f, 0.518555f, 0.533203f,
+ 0.547852f, 0.562988f, 0.577637f, 0.593262f, 0.607910f, 0.623535f, 0.638184f, 0.652344f, 0.666992f, 0.681641f, 0.696777f, 0.711426f,
+ 0.725098f, 0.738281f, 0.753418f, 0.766113f, 0.782227f, 0.794922f, 0.892090f, 0.884277f, 0.875000f, 0.866699f, 0.858887f, 0.852539f,
+ 0.004280f, 0.013329f, 0.022476f, 0.031982f, 0.042114f, 0.051849f, 0.062225f, 0.072449f, 0.083679f, 0.095032f, 0.105530f, 0.117676f,
+ 0.129517f, 0.141357f, 0.154297f, 0.166748f, 0.178711f, 0.192505f, 0.205933f, 0.219727f, 0.233521f, 0.247070f, 0.260986f, 0.275391f,
+ 0.290039f, 0.303955f, 0.319580f, 0.333740f, 0.347412f, 0.363037f, 0.377686f, 0.392822f, 0.408203f, 0.422852f, 0.437988f, 0.453125f,
+ 0.468506f, 0.483398f, 0.498779f, 0.514160f, 0.527832f, 0.543945f, 0.559570f, 0.574707f, 0.588867f, 0.604492f, 0.619141f, 0.634277f,
+ 0.648438f, 0.663086f, 0.678223f, 0.692383f, 0.707520f, 0.721680f, 0.735352f, 0.749512f, 0.764648f, 0.778320f, 0.884277f, 0.877441f,
+ 0.868652f, 0.861328f, 0.854492f, 0.847656f, 0.004280f, 0.012138f, 0.021103f, 0.029999f, 0.038940f, 0.048279f, 0.057831f, 0.067566f,
+ 0.077454f, 0.087524f, 0.098816f, 0.109558f, 0.120728f, 0.131958f, 0.143799f, 0.155762f, 0.168091f, 0.180176f, 0.193359f, 0.206177f,
+ 0.219360f, 0.232910f, 0.246338f, 0.260254f, 0.273682f, 0.287598f, 0.302246f, 0.316650f, 0.331299f, 0.344971f, 0.359863f, 0.374268f,
+ 0.389648f, 0.404297f, 0.419434f, 0.434326f, 0.449463f, 0.464844f, 0.479492f, 0.494141f, 0.509766f, 0.524414f, 0.540039f, 0.555176f,
+ 0.569824f, 0.584961f, 0.600098f, 0.615723f, 0.629883f, 0.645508f, 0.659668f, 0.675293f, 0.689453f, 0.704590f, 0.719238f, 0.732422f,
+ 0.748535f, 0.762207f, 0.876953f, 0.871582f, 0.863281f, 0.855957f, 0.849609f, 0.842773f, 0.003744f, 0.011436f, 0.019348f, 0.027893f,
+ 0.036102f, 0.044739f, 0.053711f, 0.063110f, 0.072205f, 0.081970f, 0.091919f, 0.101746f, 0.112732f, 0.122864f, 0.134521f, 0.145996f,
+ 0.157715f, 0.169434f, 0.181519f, 0.193848f, 0.206665f, 0.219360f, 0.231445f, 0.245361f, 0.259033f, 0.272217f, 0.286621f, 0.299805f,
+ 0.314209f, 0.328125f, 0.342285f, 0.357178f, 0.371826f, 0.386475f, 0.400635f, 0.415527f, 0.430420f, 0.445068f, 0.459717f, 0.476074f,
+ 0.490234f, 0.505371f, 0.521484f, 0.536133f, 0.551758f, 0.565430f, 0.581543f, 0.595703f, 0.611816f, 0.626465f, 0.641602f, 0.656738f,
+ 0.671875f, 0.686523f, 0.701172f, 0.715820f, 0.731445f, 0.746582f, 0.868652f, 0.864746f, 0.856934f, 0.851074f, 0.844727f, 0.837891f,
+ 0.003595f, 0.011093f, 0.018265f, 0.025711f, 0.033600f, 0.041656f, 0.050140f, 0.058350f, 0.067505f, 0.076416f, 0.085632f, 0.095093f,
+ 0.104919f, 0.115295f, 0.125610f, 0.136108f, 0.147583f, 0.157959f, 0.169800f, 0.181519f, 0.193359f, 0.205933f, 0.218140f, 0.231323f,
+ 0.243652f, 0.257324f, 0.270508f, 0.283447f, 0.297363f, 0.311523f, 0.325928f, 0.339111f, 0.353516f, 0.367432f, 0.382812f, 0.396973f,
+ 0.412109f, 0.426758f, 0.441406f, 0.456055f, 0.471436f, 0.486328f, 0.501953f, 0.516113f, 0.531738f, 0.546875f, 0.562500f, 0.577637f,
+ 0.592773f, 0.607910f, 0.622559f, 0.638184f, 0.653809f, 0.669434f, 0.684082f, 0.699219f, 0.714355f, 0.729492f, 0.860840f, 0.857422f,
+ 0.852051f, 0.844727f, 0.839355f, 0.832520f, 0.003349f, 0.009933f, 0.016754f, 0.024063f, 0.031204f, 0.038849f, 0.046356f, 0.054413f,
+ 0.062744f, 0.070984f, 0.080017f, 0.088989f, 0.097778f, 0.107361f, 0.117004f, 0.127197f, 0.137451f, 0.148071f, 0.159180f, 0.169922f,
+ 0.181519f, 0.192993f, 0.204956f, 0.217407f, 0.229980f, 0.242188f, 0.254883f, 0.267578f, 0.281494f, 0.294434f, 0.307861f, 0.321533f,
+ 0.335693f, 0.350098f, 0.364258f, 0.379150f, 0.393066f, 0.407715f, 0.422607f, 0.437500f, 0.452148f, 0.467041f, 0.482422f, 0.497314f,
+ 0.512695f, 0.527832f, 0.542969f, 0.558594f, 0.573730f, 0.589844f, 0.604004f, 0.619629f, 0.635254f, 0.651367f, 0.665527f, 0.681152f,
+ 0.696289f, 0.711914f, 0.852539f, 0.851562f, 0.846191f, 0.838867f, 0.832520f, 0.827637f, 0.003290f, 0.009415f, 0.015976f, 0.022095f,
+ 0.028946f, 0.036255f, 0.043396f, 0.050598f, 0.058502f, 0.066284f, 0.074036f, 0.082275f, 0.091187f, 0.099731f, 0.108826f, 0.118652f,
+ 0.128296f, 0.137939f, 0.148193f, 0.159302f, 0.170166f, 0.180786f, 0.191895f, 0.203491f, 0.215210f, 0.227661f, 0.240112f, 0.252686f,
+ 0.265625f, 0.278564f, 0.291748f, 0.305176f, 0.318604f, 0.332764f, 0.346924f, 0.360352f, 0.375000f, 0.389160f, 0.404297f, 0.418213f,
+ 0.433105f, 0.448486f, 0.463135f, 0.477783f, 0.493408f, 0.508301f, 0.523438f, 0.540039f, 0.554199f, 0.570312f, 0.585938f, 0.601074f,
+ 0.617188f, 0.633301f, 0.648926f, 0.664062f, 0.679688f, 0.695312f, 0.844727f, 0.844238f, 0.838867f, 0.833008f, 0.827148f, 0.822266f,
+ 0.002913f, 0.008621f, 0.014595f, 0.020950f, 0.027496f, 0.033600f, 0.040558f, 0.047119f, 0.054260f, 0.061615f, 0.068970f, 0.076782f,
+ 0.084717f, 0.093140f, 0.101562f, 0.109985f, 0.118591f, 0.129150f, 0.138306f, 0.148682f, 0.158447f, 0.169189f, 0.180054f, 0.191162f,
+ 0.202148f, 0.213379f, 0.225586f, 0.237305f, 0.250488f, 0.262939f, 0.275391f, 0.288086f, 0.302490f, 0.315186f, 0.329346f, 0.342529f,
+ 0.356934f, 0.370117f, 0.385742f, 0.400146f, 0.414795f, 0.429199f, 0.444336f, 0.459473f, 0.473389f, 0.489258f, 0.503906f, 0.519531f,
+ 0.535645f, 0.551270f, 0.566895f, 0.582520f, 0.598145f, 0.614258f, 0.629395f, 0.645996f, 0.661621f, 0.677734f, 0.837402f, 0.836914f,
+ 0.832520f, 0.826660f, 0.821777f, 0.816406f, 0.002748f, 0.008018f, 0.014168f, 0.019196f, 0.025040f, 0.031250f, 0.037506f, 0.043732f,
+ 0.050415f, 0.057098f, 0.063721f, 0.071167f, 0.078979f, 0.086609f, 0.094299f, 0.102783f, 0.111145f, 0.119812f, 0.128296f, 0.138306f,
+ 0.147583f, 0.157593f, 0.168213f, 0.178711f, 0.188843f, 0.200317f, 0.211792f, 0.223511f, 0.235352f, 0.247192f, 0.259521f, 0.272461f,
+ 0.285156f, 0.298584f, 0.312012f, 0.324707f, 0.339111f, 0.352783f, 0.366943f, 0.381348f, 0.395996f, 0.410889f, 0.425537f, 0.439941f,
+ 0.454834f, 0.470459f, 0.485352f, 0.501953f, 0.516113f, 0.531738f, 0.547363f, 0.563477f, 0.579102f, 0.595703f, 0.611328f, 0.626953f,
+ 0.642578f, 0.659668f, 0.828125f, 0.830566f, 0.825684f, 0.820801f, 0.815430f, 0.811035f, 0.002630f, 0.007412f, 0.012978f, 0.018356f,
+ 0.023758f, 0.028931f, 0.034729f, 0.040894f, 0.046631f, 0.053101f, 0.059143f, 0.065979f, 0.073669f, 0.080200f, 0.087585f, 0.095276f,
+ 0.102844f, 0.111633f, 0.119812f, 0.128296f, 0.137573f, 0.146729f, 0.156128f, 0.166382f, 0.176880f, 0.187256f, 0.197998f, 0.209351f,
+ 0.220581f, 0.232422f, 0.244385f, 0.256592f, 0.268799f, 0.281982f, 0.294922f, 0.308105f, 0.321045f, 0.334717f, 0.348633f, 0.363525f,
+ 0.378174f, 0.391846f, 0.406006f, 0.420898f, 0.436279f, 0.451660f, 0.466064f, 0.481934f, 0.496826f, 0.513184f, 0.528320f, 0.543945f,
+ 0.560059f, 0.576660f, 0.592285f, 0.608887f, 0.625000f, 0.640625f, 0.819336f, 0.822266f, 0.818848f, 0.813965f, 0.810059f, 0.805664f,
+ 0.002201f, 0.007240f, 0.011803f, 0.016617f, 0.021622f, 0.027344f, 0.032288f, 0.037598f, 0.043427f, 0.049194f, 0.055267f, 0.061462f,
+ 0.067566f, 0.073853f, 0.080872f, 0.088013f, 0.095703f, 0.103821f, 0.111145f, 0.119446f, 0.127563f, 0.136597f, 0.145752f, 0.155273f,
+ 0.165039f, 0.174683f, 0.185181f, 0.195801f, 0.206543f, 0.218140f, 0.229370f, 0.241455f, 0.253174f, 0.265381f, 0.278564f, 0.291504f,
+ 0.304199f, 0.317383f, 0.331299f, 0.344971f, 0.358643f, 0.373291f, 0.386963f, 0.402100f, 0.416016f, 0.431641f, 0.447266f, 0.462646f,
+ 0.477295f, 0.493652f, 0.509277f, 0.524902f, 0.541504f, 0.557617f, 0.574219f, 0.589844f, 0.605957f, 0.623047f, 0.810059f, 0.814453f,
+ 0.811035f, 0.807129f, 0.803223f, 0.798828f, 0.002293f, 0.006927f, 0.010994f, 0.015617f, 0.020584f, 0.025131f, 0.029663f, 0.034760f,
+ 0.040192f, 0.045532f, 0.050964f, 0.056793f, 0.062805f, 0.068726f, 0.074890f, 0.081482f, 0.088806f, 0.096069f, 0.103333f, 0.110535f,
+ 0.118896f, 0.126709f, 0.135254f, 0.144165f, 0.153442f, 0.162720f, 0.172119f, 0.182495f, 0.192749f, 0.203735f, 0.214600f, 0.225952f,
+ 0.237793f, 0.250000f, 0.261719f, 0.274170f, 0.287354f, 0.300293f, 0.313477f, 0.326904f, 0.340820f, 0.354980f, 0.369385f, 0.383545f,
+ 0.396973f, 0.411865f, 0.427734f, 0.442871f, 0.458740f, 0.473633f, 0.489502f, 0.505859f, 0.522461f, 0.537598f, 0.553711f, 0.572754f,
+ 0.588379f, 0.604492f, 0.802246f, 0.807617f, 0.804199f, 0.800781f, 0.797363f, 0.792969f, 0.002081f, 0.006172f, 0.010460f, 0.014503f,
+ 0.019104f, 0.023163f, 0.027832f, 0.032410f, 0.037354f, 0.041992f, 0.047211f, 0.052490f, 0.057831f, 0.063232f, 0.069458f, 0.075317f,
+ 0.082153f, 0.088257f, 0.094910f, 0.102295f, 0.110107f, 0.117554f, 0.125122f, 0.133667f, 0.142456f, 0.151001f, 0.160767f, 0.169922f,
+ 0.179443f, 0.190430f, 0.200562f, 0.211914f, 0.222412f, 0.234009f, 0.245850f, 0.258545f, 0.270752f, 0.283203f, 0.296387f, 0.309082f,
+ 0.322998f, 0.336670f, 0.350098f, 0.364990f, 0.378906f, 0.393311f, 0.408936f, 0.423096f, 0.438965f, 0.454834f, 0.470703f, 0.486572f,
+ 0.502441f, 0.518555f, 0.534668f, 0.551270f, 0.569336f, 0.585938f, 0.792480f, 0.799316f, 0.797363f, 0.793457f, 0.790039f, 0.786621f,
+ 0.002028f, 0.005669f, 0.009705f, 0.013565f, 0.017532f, 0.021286f, 0.025574f, 0.030197f, 0.034180f, 0.038757f, 0.043488f, 0.048737f,
+ 0.053497f, 0.058594f, 0.064026f, 0.070007f, 0.075623f, 0.081360f, 0.088135f, 0.094238f, 0.101379f, 0.108643f, 0.116028f, 0.123718f,
+ 0.131592f, 0.140137f, 0.149048f, 0.157715f, 0.167114f, 0.176636f, 0.187012f, 0.197388f, 0.208130f, 0.219238f, 0.230347f, 0.241943f,
+ 0.254150f, 0.266113f, 0.279053f, 0.291504f, 0.304932f, 0.318848f, 0.332031f, 0.345947f, 0.360107f, 0.375000f, 0.389404f, 0.404541f,
+ 0.419922f, 0.434814f, 0.450684f, 0.466553f, 0.482910f, 0.499023f, 0.516113f, 0.533203f, 0.550293f, 0.567383f, 0.783203f, 0.790527f,
+ 0.789551f, 0.786621f, 0.783691f, 0.780762f, 0.001852f, 0.005554f, 0.008957f, 0.012642f, 0.016296f, 0.020172f, 0.024033f, 0.027878f,
+ 0.031677f, 0.035919f, 0.040253f, 0.044952f, 0.049255f, 0.053955f, 0.058960f, 0.063965f, 0.069336f, 0.074951f, 0.080933f, 0.087219f,
+ 0.093201f, 0.100159f, 0.106689f, 0.114197f, 0.121521f, 0.129517f, 0.137817f, 0.146118f, 0.155151f, 0.164307f, 0.173462f, 0.183472f,
+ 0.193970f, 0.204224f, 0.215210f, 0.226562f, 0.238037f, 0.250244f, 0.262451f, 0.274902f, 0.287598f, 0.301025f, 0.314209f, 0.327393f,
+ 0.342041f, 0.356445f, 0.370850f, 0.385254f, 0.400879f, 0.415771f, 0.431396f, 0.446777f, 0.463379f, 0.480469f, 0.497314f, 0.514160f,
+ 0.530273f, 0.547363f, 0.774414f, 0.783203f, 0.782715f, 0.779297f, 0.776367f, 0.773438f, 0.001690f, 0.005207f, 0.008278f, 0.011696f,
+ 0.015068f, 0.018784f, 0.022186f, 0.025909f, 0.029221f, 0.033508f, 0.037109f, 0.041321f, 0.045471f, 0.049774f, 0.054108f, 0.058838f,
+ 0.063843f, 0.069214f, 0.074280f, 0.080078f, 0.086243f, 0.091980f, 0.098083f, 0.105164f, 0.111877f, 0.119446f, 0.126953f, 0.134888f,
+ 0.143555f, 0.151978f, 0.161133f, 0.170532f, 0.180176f, 0.189697f, 0.200684f, 0.211182f, 0.222412f, 0.234009f, 0.245972f, 0.257568f,
+ 0.270508f, 0.282959f, 0.295898f, 0.309570f, 0.323486f, 0.337158f, 0.351562f, 0.366211f, 0.381104f, 0.396729f, 0.411865f, 0.427490f,
+ 0.443604f, 0.459961f, 0.477051f, 0.494385f, 0.510742f, 0.529297f, 0.763184f, 0.774902f, 0.773438f, 0.771973f, 0.769043f, 0.767578f,
+ 0.001528f, 0.004692f, 0.007587f, 0.010956f, 0.014221f, 0.016907f, 0.020218f, 0.023407f, 0.027283f, 0.030273f, 0.033997f, 0.038055f,
+ 0.041809f, 0.045959f, 0.049683f, 0.053955f, 0.058838f, 0.063171f, 0.068176f, 0.073120f, 0.078491f, 0.084473f, 0.090332f, 0.096619f,
+ 0.102905f, 0.109619f, 0.116699f, 0.124207f, 0.131958f, 0.140503f, 0.148438f, 0.157349f, 0.166626f, 0.176392f, 0.186157f, 0.196045f,
+ 0.207031f, 0.218018f, 0.229736f, 0.241699f, 0.253174f, 0.265381f, 0.278320f, 0.291748f, 0.305176f, 0.318848f, 0.333496f, 0.347412f,
+ 0.362305f, 0.376709f, 0.392822f, 0.407715f, 0.424072f, 0.440430f, 0.457031f, 0.473633f, 0.491211f, 0.508789f, 0.753906f, 0.766602f,
+ 0.767090f, 0.764160f, 0.761719f, 0.759766f, 0.001261f, 0.004250f, 0.007389f, 0.010185f, 0.013023f, 0.015976f, 0.018692f, 0.021713f,
+ 0.024734f, 0.028183f, 0.031464f, 0.034943f, 0.038452f, 0.041870f, 0.045410f, 0.049561f, 0.054047f, 0.058044f, 0.062164f, 0.067017f,
+ 0.071838f, 0.077332f, 0.082581f, 0.088318f, 0.094360f, 0.100525f, 0.107117f, 0.114258f, 0.121643f, 0.128540f, 0.136841f, 0.144897f,
+ 0.153931f, 0.162476f, 0.171875f, 0.182007f, 0.192139f, 0.202637f, 0.213623f, 0.224854f, 0.237183f, 0.248657f, 0.260986f, 0.274170f,
+ 0.287354f, 0.300781f, 0.314453f, 0.328613f, 0.343018f, 0.358643f, 0.373291f, 0.388916f, 0.404785f, 0.420654f, 0.437744f, 0.454590f,
+ 0.471924f, 0.489990f, 0.744629f, 0.757812f, 0.757812f, 0.756836f, 0.754395f, 0.752441f, 0.001527f, 0.004047f, 0.006680f, 0.009369f,
+ 0.012024f, 0.014618f, 0.017288f, 0.020248f, 0.022705f, 0.025803f, 0.028778f, 0.031769f, 0.034912f, 0.038330f, 0.041595f, 0.045166f,
+ 0.048737f, 0.052673f, 0.056885f, 0.061218f, 0.065552f, 0.070251f, 0.075012f, 0.080505f, 0.086060f, 0.091614f, 0.097656f, 0.104065f,
+ 0.110901f, 0.118225f, 0.125366f, 0.133179f, 0.141357f, 0.149902f, 0.158569f, 0.168213f, 0.177734f, 0.187866f, 0.198364f, 0.208984f,
+ 0.220581f, 0.232422f, 0.244019f, 0.256836f, 0.269287f, 0.282471f, 0.296143f, 0.309326f, 0.324463f, 0.338379f, 0.353760f, 0.368652f,
+ 0.385498f, 0.400635f, 0.417725f, 0.434570f, 0.451660f, 0.469482f, 0.733887f, 0.749023f, 0.750977f, 0.749023f, 0.747070f, 0.744629f,
+ 0.001313f, 0.003803f, 0.006126f, 0.008507f, 0.011185f, 0.013550f, 0.015839f, 0.018219f, 0.021027f, 0.023438f, 0.026520f, 0.029129f,
+ 0.031738f, 0.034821f, 0.037964f, 0.041138f, 0.044434f, 0.048035f, 0.051636f, 0.055420f, 0.059540f, 0.063782f, 0.068176f, 0.073181f,
+ 0.077881f, 0.083496f, 0.088989f, 0.094849f, 0.101440f, 0.107849f, 0.114441f, 0.121887f, 0.129395f, 0.137207f, 0.145874f, 0.154419f,
+ 0.163574f, 0.173462f, 0.183228f, 0.193726f, 0.204712f, 0.216064f, 0.227661f, 0.239624f, 0.251709f, 0.264648f, 0.277832f, 0.291504f,
+ 0.305664f, 0.320312f, 0.334473f, 0.349854f, 0.365479f, 0.380615f, 0.397217f, 0.414551f, 0.432129f, 0.449951f, 0.722656f, 0.740234f,
+ 0.741699f, 0.741211f, 0.739746f, 0.737793f, 0.001137f, 0.003654f, 0.005871f, 0.007881f, 0.010262f, 0.012268f, 0.014496f, 0.017059f,
+ 0.018890f, 0.021317f, 0.023605f, 0.026291f, 0.029007f, 0.031494f, 0.034515f, 0.036987f, 0.040375f, 0.043457f, 0.046936f, 0.050385f,
+ 0.053925f, 0.058044f, 0.061981f, 0.066650f, 0.070679f, 0.075562f, 0.080994f, 0.085938f, 0.091919f, 0.098450f, 0.104370f, 0.110840f,
+ 0.118164f, 0.125366f, 0.133301f, 0.141357f, 0.150024f, 0.159546f, 0.168457f, 0.178711f, 0.189453f, 0.199707f, 0.211060f, 0.222656f,
+ 0.234741f, 0.247314f, 0.260010f, 0.272705f, 0.287354f, 0.300781f, 0.315674f, 0.330322f, 0.345947f, 0.362061f, 0.377441f, 0.394775f,
+ 0.412109f, 0.429199f, 0.712891f, 0.730957f, 0.733398f, 0.733398f, 0.731445f, 0.729492f, 0.001163f, 0.003218f, 0.005329f, 0.007542f,
+ 0.009331f, 0.011330f, 0.013367f, 0.015434f, 0.017685f, 0.019714f, 0.021515f, 0.024139f, 0.026062f, 0.028763f, 0.031204f, 0.033722f,
+ 0.036163f, 0.039398f, 0.041992f, 0.045624f, 0.048553f, 0.051971f, 0.056000f, 0.059937f, 0.063904f, 0.068054f, 0.072876f, 0.077820f,
+ 0.083374f, 0.088623f, 0.094116f, 0.100830f, 0.107117f, 0.114197f, 0.121399f, 0.129272f, 0.136963f, 0.145630f, 0.154785f, 0.163696f,
+ 0.173828f, 0.184204f, 0.194946f, 0.205933f, 0.217529f, 0.229614f, 0.242676f, 0.255859f, 0.269043f, 0.282471f, 0.296387f, 0.311523f,
+ 0.326172f, 0.341553f, 0.357910f, 0.374756f, 0.391846f, 0.409180f, 0.701660f, 0.721680f, 0.723633f, 0.724609f, 0.723145f, 0.722656f,
+ 0.001008f, 0.003147f, 0.004818f, 0.006882f, 0.008530f, 0.010468f, 0.012390f, 0.013832f, 0.016006f, 0.017899f, 0.019608f, 0.021866f,
+ 0.023849f, 0.025940f, 0.027847f, 0.030350f, 0.032806f, 0.035187f, 0.037994f, 0.040619f, 0.043732f, 0.046875f, 0.050110f, 0.053833f,
+ 0.057617f, 0.061371f, 0.065613f, 0.070068f, 0.074768f, 0.079895f, 0.085144f, 0.090637f, 0.096863f, 0.103149f, 0.110107f, 0.116943f,
+ 0.124634f, 0.132568f, 0.140991f, 0.149536f, 0.159302f, 0.169189f, 0.179443f, 0.189575f, 0.201538f, 0.213013f, 0.225342f, 0.236938f,
+ 0.250244f, 0.264160f, 0.278320f, 0.292236f, 0.307617f, 0.322021f, 0.337891f, 0.354248f, 0.371582f, 0.389160f, 0.689941f, 0.712891f,
+ 0.715820f, 0.715820f, 0.715820f, 0.714355f, 0.001126f, 0.002708f, 0.004486f, 0.006313f, 0.007927f, 0.009659f, 0.011238f, 0.012833f,
+ 0.014435f, 0.015823f, 0.017670f, 0.019485f, 0.021347f, 0.023453f, 0.025101f, 0.027161f, 0.029160f, 0.031525f, 0.033752f, 0.036560f,
+ 0.039154f, 0.041687f, 0.044891f, 0.047943f, 0.051453f, 0.054871f, 0.058655f, 0.062622f, 0.067078f, 0.071411f, 0.076355f, 0.081665f,
+ 0.086792f, 0.092957f, 0.098877f, 0.105713f, 0.112549f, 0.119995f, 0.127563f, 0.135864f, 0.144897f, 0.154297f, 0.164185f, 0.173828f,
+ 0.185059f, 0.196045f, 0.208008f, 0.219849f, 0.232666f, 0.245483f, 0.259033f, 0.273438f, 0.287842f, 0.302734f, 0.318604f, 0.334473f,
+ 0.351318f, 0.369385f, 0.679688f, 0.702637f, 0.707031f, 0.707031f, 0.707031f, 0.705566f, 0.000980f, 0.002733f, 0.004021f, 0.005688f,
+ 0.007084f, 0.008553f, 0.010345f, 0.011513f, 0.012962f, 0.014297f, 0.015823f, 0.017609f, 0.019119f, 0.020721f, 0.022568f, 0.024200f,
+ 0.026291f, 0.028000f, 0.030457f, 0.032410f, 0.034912f, 0.037476f, 0.039734f, 0.042786f, 0.045563f, 0.048920f, 0.052185f, 0.055817f,
+ 0.059662f, 0.063660f, 0.067993f, 0.072632f, 0.077759f, 0.083191f, 0.088623f, 0.094971f, 0.101135f, 0.107849f, 0.115479f, 0.122864f,
+ 0.131592f, 0.139893f, 0.149414f, 0.158447f, 0.169067f, 0.179443f, 0.191040f, 0.202393f, 0.214478f, 0.227539f, 0.240723f, 0.255127f,
+ 0.268555f, 0.283447f, 0.298828f, 0.315186f, 0.331787f, 0.348389f, 0.667480f, 0.693359f, 0.697754f, 0.698730f, 0.698242f, 0.697754f,
+ 0.000870f, 0.002420f, 0.003994f, 0.005165f, 0.006584f, 0.007763f, 0.009209f, 0.010468f, 0.011604f, 0.013336f, 0.013977f, 0.015442f,
+ 0.016830f, 0.018509f, 0.020065f, 0.021606f, 0.023224f, 0.024933f, 0.026672f, 0.028656f, 0.030914f, 0.033112f, 0.035187f, 0.037689f,
+ 0.040344f, 0.043335f, 0.046234f, 0.049438f, 0.052948f, 0.056427f, 0.060394f, 0.064331f, 0.069031f, 0.073853f, 0.078735f, 0.084412f,
+ 0.090271f, 0.096436f, 0.103455f, 0.110229f, 0.118042f, 0.126099f, 0.134766f, 0.143921f, 0.153198f, 0.163696f, 0.174438f, 0.185913f,
+ 0.197754f, 0.210083f, 0.222778f, 0.235962f, 0.250000f, 0.264648f, 0.279053f, 0.294922f, 0.311279f, 0.328613f, 0.655273f, 0.684082f,
+ 0.688477f, 0.689941f, 0.689941f, 0.689941f, 0.000790f, 0.002153f, 0.003576f, 0.004726f, 0.005966f, 0.007172f, 0.008186f, 0.009453f,
+ 0.010521f, 0.011482f, 0.012772f, 0.013771f, 0.015144f, 0.016434f, 0.017792f, 0.019226f, 0.020355f, 0.022049f, 0.023666f, 0.025375f,
+ 0.027145f, 0.029297f, 0.030975f, 0.033142f, 0.035339f, 0.037964f, 0.040405f, 0.043365f, 0.046478f, 0.049744f, 0.053101f, 0.057068f,
+ 0.060944f, 0.065063f, 0.069763f, 0.074646f, 0.079956f, 0.085938f, 0.091675f, 0.098083f, 0.105164f, 0.112732f, 0.121033f, 0.129395f,
+ 0.138428f, 0.148560f, 0.158325f, 0.169067f, 0.180664f, 0.192139f, 0.205078f, 0.217529f, 0.231934f, 0.246094f, 0.260010f, 0.275391f,
+ 0.292236f, 0.309570f, 0.644043f, 0.673340f, 0.678711f, 0.680664f, 0.680664f, 0.680176f, 0.000538f, 0.002022f, 0.003185f, 0.004456f,
+ 0.005360f, 0.006321f, 0.007286f, 0.008484f, 0.009422f, 0.010185f, 0.011177f, 0.012283f, 0.013191f, 0.014435f, 0.015587f, 0.016769f,
+ 0.017914f, 0.019302f, 0.020584f, 0.022171f, 0.023819f, 0.025391f, 0.027222f, 0.028992f, 0.030914f, 0.033234f, 0.035461f, 0.037903f,
+ 0.040649f, 0.043396f, 0.046326f, 0.049561f, 0.053131f, 0.056946f, 0.061279f, 0.065613f, 0.070374f, 0.075439f, 0.080811f, 0.086731f,
+ 0.093140f, 0.100037f, 0.107544f, 0.115662f, 0.124023f, 0.132935f, 0.143066f, 0.153320f, 0.163696f, 0.175415f, 0.187012f, 0.200195f,
+ 0.213013f, 0.227173f, 0.241455f, 0.256592f, 0.272461f, 0.288330f, 0.632812f, 0.663574f, 0.669434f, 0.670898f, 0.671387f, 0.671875f,
+ 0.000686f, 0.001864f, 0.002884f, 0.003883f, 0.004829f, 0.005592f, 0.006504f, 0.007454f, 0.008064f, 0.008995f, 0.009850f, 0.010948f,
+ 0.011711f, 0.012581f, 0.013763f, 0.014618f, 0.015701f, 0.016953f, 0.018112f, 0.019180f, 0.020691f, 0.021973f, 0.023560f, 0.025192f,
+ 0.026962f, 0.028717f, 0.030624f, 0.032959f, 0.035004f, 0.037567f, 0.040314f, 0.043121f, 0.046204f, 0.049713f, 0.053284f, 0.057129f,
+ 0.061157f, 0.065796f, 0.071167f, 0.076477f, 0.082214f, 0.088379f, 0.095276f, 0.102600f, 0.110596f, 0.118652f, 0.127808f, 0.137817f,
+ 0.147705f, 0.158569f, 0.170166f, 0.182251f, 0.195068f, 0.208008f, 0.222656f, 0.237671f, 0.252686f, 0.269287f, 0.620605f, 0.653320f,
+ 0.659180f, 0.661621f, 0.663086f, 0.663574f, 0.000782f, 0.001828f, 0.002949f, 0.003487f, 0.004421f, 0.005032f, 0.005878f, 0.006557f,
+ 0.007332f, 0.008110f, 0.008591f, 0.009537f, 0.010094f, 0.011147f, 0.011864f, 0.012779f, 0.013573f, 0.014549f, 0.015625f, 0.016846f,
+ 0.017822f, 0.018936f, 0.020279f, 0.021729f, 0.023117f, 0.024704f, 0.026505f, 0.028183f, 0.030289f, 0.032349f, 0.034546f, 0.037109f,
+ 0.039703f, 0.042786f, 0.045837f, 0.049133f, 0.053009f, 0.056763f, 0.061584f, 0.066284f, 0.071411f, 0.076843f, 0.083191f, 0.089722f,
+ 0.097290f, 0.104919f, 0.113647f, 0.122498f, 0.132324f, 0.142578f, 0.153809f, 0.164917f, 0.177612f, 0.190430f, 0.203857f, 0.218506f,
+ 0.233887f, 0.249390f, 0.606934f, 0.642578f, 0.649414f, 0.653320f, 0.652832f, 0.654785f, 0.000604f, 0.001636f, 0.002550f, 0.003180f,
+ 0.003799f, 0.004498f, 0.005051f, 0.005573f, 0.006325f, 0.006836f, 0.007607f, 0.008087f, 0.008820f, 0.009483f, 0.010132f, 0.010918f,
+ 0.011665f, 0.012527f, 0.013535f, 0.014297f, 0.015251f, 0.016190f, 0.017288f, 0.018433f, 0.019791f, 0.021133f, 0.022400f, 0.023865f,
+ 0.025742f, 0.027664f, 0.029373f, 0.031677f, 0.034027f, 0.036255f, 0.039032f, 0.042023f, 0.045197f, 0.048798f, 0.052643f, 0.056824f,
+ 0.061493f, 0.066467f, 0.072327f, 0.078308f, 0.084473f, 0.091858f, 0.099609f, 0.108032f, 0.117249f, 0.126831f, 0.137451f, 0.148193f,
+ 0.160034f, 0.172729f, 0.186035f, 0.199829f, 0.214722f, 0.229980f, 0.596680f, 0.632812f, 0.638672f, 0.642578f, 0.644531f, 0.645020f,
+ 0.000447f, 0.001384f, 0.001986f, 0.002697f, 0.003225f, 0.003828f, 0.004501f, 0.005009f, 0.005459f, 0.006027f, 0.006474f, 0.006935f,
+ 0.007591f, 0.008217f, 0.008644f, 0.009308f, 0.010025f, 0.010498f, 0.011330f, 0.012100f, 0.012909f, 0.013924f, 0.014618f, 0.015610f,
+ 0.016739f, 0.017807f, 0.019043f, 0.020340f, 0.021622f, 0.023178f, 0.024979f, 0.026520f, 0.028366f, 0.030640f, 0.032959f, 0.035492f,
+ 0.038239f, 0.041260f, 0.044495f, 0.048340f, 0.052399f, 0.056732f, 0.061768f, 0.067017f, 0.072754f, 0.079224f, 0.086304f, 0.093994f,
+ 0.102478f, 0.111511f, 0.121521f, 0.132080f, 0.143311f, 0.155518f, 0.168213f, 0.181763f, 0.196411f, 0.211548f, 0.583008f, 0.621094f,
+ 0.629395f, 0.632324f, 0.634766f, 0.635742f, 0.000375f, 0.001324f, 0.001728f, 0.002466f, 0.002872f, 0.003384f, 0.003685f, 0.004185f,
+ 0.004845f, 0.005184f, 0.005444f, 0.006130f, 0.006401f, 0.006844f, 0.007446f, 0.007957f, 0.008636f, 0.008965f, 0.009659f, 0.010139f,
+ 0.010971f, 0.011742f, 0.012497f, 0.013138f, 0.014099f, 0.014992f, 0.015900f, 0.017166f, 0.018143f, 0.019485f, 0.020676f, 0.022156f,
+ 0.023697f, 0.025528f, 0.027374f, 0.029556f, 0.031921f, 0.034424f, 0.037445f, 0.040375f, 0.044067f, 0.047577f, 0.052155f, 0.056824f,
+ 0.062042f, 0.067688f, 0.074158f, 0.081055f, 0.088745f, 0.097351f, 0.106323f, 0.116455f, 0.127075f, 0.138672f, 0.151123f, 0.164062f,
+ 0.177856f, 0.192871f, 0.570801f, 0.610840f, 0.619629f, 0.623047f, 0.625488f, 0.625977f, 0.000432f, 0.000921f, 0.001664f, 0.002056f,
+ 0.002697f, 0.003061f, 0.003326f, 0.003757f, 0.004044f, 0.004379f, 0.004761f, 0.004948f, 0.005463f, 0.005791f, 0.006199f, 0.006752f,
+ 0.007229f, 0.007526f, 0.008156f, 0.008621f, 0.009193f, 0.009712f, 0.010330f, 0.010994f, 0.011688f, 0.012466f, 0.013374f, 0.014153f,
+ 0.015099f, 0.016083f, 0.017212f, 0.018250f, 0.019623f, 0.021210f, 0.022614f, 0.024445f, 0.026321f, 0.028351f, 0.030762f, 0.033325f,
+ 0.036377f, 0.039642f, 0.043304f, 0.047485f, 0.051880f, 0.056885f, 0.062469f, 0.068542f, 0.075623f, 0.083374f, 0.091919f, 0.101135f,
+ 0.111389f, 0.122559f, 0.134277f, 0.146606f, 0.160278f, 0.174683f, 0.557617f, 0.600098f, 0.609375f, 0.612793f, 0.615723f, 0.616699f,
+ 0.000255f, 0.000997f, 0.001393f, 0.001908f, 0.002239f, 0.002512f, 0.002720f, 0.003166f, 0.003283f, 0.003616f, 0.003866f, 0.004223f,
+ 0.004597f, 0.004795f, 0.005127f, 0.005573f, 0.005939f, 0.006359f, 0.006657f, 0.007133f, 0.007687f, 0.008041f, 0.008545f, 0.009087f,
+ 0.009636f, 0.010300f, 0.010910f, 0.011757f, 0.012489f, 0.013313f, 0.014153f, 0.014954f, 0.016037f, 0.017258f, 0.018555f, 0.019867f,
+ 0.021530f, 0.023239f, 0.025055f, 0.027252f, 0.029663f, 0.032379f, 0.035339f, 0.038666f, 0.042664f, 0.047058f, 0.051849f, 0.057465f,
+ 0.063416f, 0.070557f, 0.078369f, 0.086731f, 0.096313f, 0.106384f, 0.117798f, 0.129761f, 0.143311f, 0.156982f, 0.544922f, 0.588867f,
+ 0.599121f, 0.602539f, 0.605469f, 0.606445f, 0.000353f, 0.000879f, 0.001276f, 0.001613f, 0.001785f, 0.002075f, 0.002300f, 0.002501f,
+ 0.002808f, 0.003010f, 0.003283f, 0.003487f, 0.003714f, 0.003967f, 0.004269f, 0.004597f, 0.004837f, 0.005230f, 0.005512f, 0.005878f,
+ 0.006203f, 0.006626f, 0.007030f, 0.007519f, 0.007866f, 0.008354f, 0.009010f, 0.009468f, 0.010017f, 0.010765f, 0.011444f, 0.012291f,
+ 0.013100f, 0.014030f, 0.015030f, 0.016098f, 0.017441f, 0.018646f, 0.020157f, 0.021912f, 0.023804f, 0.026047f, 0.028488f, 0.031342f,
+ 0.034424f, 0.037994f, 0.042206f, 0.046997f, 0.052338f, 0.058533f, 0.065369f, 0.073364f, 0.081787f, 0.091492f, 0.102356f, 0.113647f,
+ 0.126343f, 0.139526f, 0.531250f, 0.579102f, 0.587891f, 0.592773f, 0.595703f, 0.596680f, 0.000295f, 0.000784f, 0.000912f, 0.001261f,
+ 0.001517f, 0.001761f, 0.001893f, 0.002113f, 0.002211f, 0.002432f, 0.002676f, 0.002861f, 0.002993f, 0.003294f, 0.003479f, 0.003700f,
+ 0.003933f, 0.004242f, 0.004452f, 0.004745f, 0.004974f, 0.005428f, 0.005642f, 0.006081f, 0.006401f, 0.006817f, 0.007240f, 0.007641f,
+ 0.008209f, 0.008667f, 0.009361f, 0.009720f, 0.010506f, 0.011261f, 0.012024f, 0.012794f, 0.013840f, 0.014893f, 0.016113f, 0.017395f,
+ 0.018860f, 0.020493f, 0.022446f, 0.024658f, 0.027283f, 0.030228f, 0.033691f, 0.037659f, 0.042145f, 0.047546f, 0.053467f, 0.060547f,
+ 0.068359f, 0.077332f, 0.087158f, 0.098145f, 0.109741f, 0.123230f, 0.517090f, 0.566895f, 0.576660f, 0.581543f, 0.584961f, 0.587402f,
+ 0.000247f, 0.000702f, 0.000849f, 0.001033f, 0.001304f, 0.001416f, 0.001576f, 0.001754f, 0.001860f, 0.001953f, 0.002104f, 0.002327f,
+ 0.002419f, 0.002651f, 0.002785f, 0.003014f, 0.003134f, 0.003315f, 0.003584f, 0.003813f, 0.004078f, 0.004295f, 0.004555f, 0.004784f,
+ 0.005013f, 0.005329f, 0.005669f, 0.006069f, 0.006439f, 0.006821f, 0.007381f, 0.007797f, 0.008301f, 0.008812f, 0.009430f, 0.010139f,
+ 0.010948f, 0.011642f, 0.012573f, 0.013664f, 0.014671f, 0.016052f, 0.017502f, 0.019135f, 0.021255f, 0.023438f, 0.026199f, 0.029312f,
+ 0.033203f, 0.037476f, 0.042725f, 0.048828f, 0.055695f, 0.063721f, 0.072937f, 0.082947f, 0.094666f, 0.107117f, 0.504883f, 0.555664f,
+ 0.566406f, 0.572754f, 0.574707f, 0.577148f, 0.000217f, 0.000516f, 0.000750f, 0.000898f, 0.001011f, 0.001117f, 0.001203f, 0.001307f,
+ 0.001470f, 0.001604f, 0.001659f, 0.001750f, 0.001945f, 0.002121f, 0.002249f, 0.002316f, 0.002478f, 0.002581f, 0.002832f, 0.003000f,
+ 0.003164f, 0.003334f, 0.003593f, 0.003784f, 0.003990f, 0.004196f, 0.004440f, 0.004673f, 0.005035f, 0.005329f, 0.005642f, 0.005981f,
+ 0.006462f, 0.006916f, 0.007313f, 0.007805f, 0.008377f, 0.008987f, 0.009727f, 0.010521f, 0.011314f, 0.012421f, 0.013466f, 0.014755f,
+ 0.016235f, 0.017914f, 0.019913f, 0.022461f, 0.025330f, 0.028778f, 0.033081f, 0.038239f, 0.044189f, 0.051422f, 0.059662f, 0.069336f,
+ 0.080200f, 0.091980f, 0.492676f, 0.543945f, 0.555664f, 0.561035f, 0.564453f, 0.566406f, 0.000131f, 0.000355f, 0.000605f, 0.000759f,
+ 0.000832f, 0.000904f, 0.001018f, 0.000975f, 0.001144f, 0.001235f, 0.001336f, 0.001447f, 0.001518f, 0.001620f, 0.001668f, 0.001835f,
+ 0.001901f, 0.002045f, 0.002188f, 0.002270f, 0.002424f, 0.002577f, 0.002707f, 0.002893f, 0.003002f, 0.003223f, 0.003407f, 0.003572f,
+ 0.003851f, 0.004017f, 0.004391f, 0.004608f, 0.004833f, 0.005203f, 0.005497f, 0.005886f, 0.006351f, 0.006771f, 0.007278f, 0.007858f,
+ 0.008560f, 0.009315f, 0.010086f, 0.011078f, 0.012222f, 0.013443f, 0.015022f, 0.016769f, 0.018967f, 0.021591f, 0.024780f, 0.028931f,
+ 0.033875f, 0.039734f, 0.047241f, 0.056122f, 0.066101f, 0.077637f, 0.477783f, 0.532715f, 0.544922f, 0.551270f, 0.553711f, 0.555664f,
+ 0.000245f, 0.000303f, 0.000473f, 0.000498f, 0.000544f, 0.000707f, 0.000700f, 0.000767f, 0.000802f, 0.000892f, 0.001021f, 0.001086f,
+ 0.001140f, 0.001260f, 0.001303f, 0.001325f, 0.001462f, 0.001553f, 0.001603f, 0.001746f, 0.001816f, 0.001904f, 0.002043f, 0.002127f,
+ 0.002254f, 0.002356f, 0.002548f, 0.002672f, 0.002851f, 0.003092f, 0.003265f, 0.003374f, 0.003647f, 0.003891f, 0.004097f, 0.004360f,
+ 0.004669f, 0.004997f, 0.005390f, 0.005810f, 0.006226f, 0.006756f, 0.007450f, 0.008095f, 0.008934f, 0.009827f, 0.010902f, 0.012268f,
+ 0.013840f, 0.015701f, 0.018036f, 0.021072f, 0.024948f, 0.029800f, 0.035980f, 0.043945f, 0.053345f, 0.063843f, 0.465576f, 0.520996f,
+ 0.535645f, 0.540039f, 0.543457f, 0.545898f, 0.000108f, 0.000275f, 0.000332f, 0.000402f, 0.000462f, 0.000468f, 0.000580f, 0.000522f,
+ 0.000616f, 0.000657f, 0.000758f, 0.000762f, 0.000812f, 0.000870f, 0.000945f, 0.000978f, 0.001054f, 0.001109f, 0.001179f, 0.001213f,
+ 0.001311f, 0.001371f, 0.001473f, 0.001558f, 0.001629f, 0.001718f, 0.001837f, 0.001903f, 0.002016f, 0.002159f, 0.002258f, 0.002478f,
+ 0.002548f, 0.002731f, 0.002909f, 0.003086f, 0.003317f, 0.003580f, 0.003885f, 0.004116f, 0.004421f, 0.004818f, 0.005264f, 0.005745f,
+ 0.006294f, 0.006966f, 0.007748f, 0.008667f, 0.009766f, 0.011086f, 0.012787f, 0.014908f, 0.017746f, 0.021271f, 0.026382f, 0.032990f,
+ 0.041199f, 0.051239f, 0.452393f, 0.509277f, 0.522461f, 0.529297f, 0.533203f, 0.535156f, 0.000016f, 0.000143f, 0.000244f, 0.000315f,
+ 0.000309f, 0.000391f, 0.000344f, 0.000402f, 0.000429f, 0.000517f, 0.000522f, 0.000526f, 0.000546f, 0.000606f, 0.000628f, 0.000705f,
+ 0.000692f, 0.000781f, 0.000837f, 0.000868f, 0.000923f, 0.000969f, 0.001013f, 0.001070f, 0.001142f, 0.001186f, 0.001273f, 0.001326f,
+ 0.001397f, 0.001534f, 0.001561f, 0.001685f, 0.001775f, 0.001873f, 0.002024f, 0.002153f, 0.002272f, 0.002443f, 0.002611f, 0.002800f,
+ 0.003014f, 0.003250f, 0.003529f, 0.003868f, 0.004227f, 0.004692f, 0.005192f, 0.005836f, 0.006603f, 0.007587f, 0.008751f, 0.010193f,
+ 0.012001f, 0.014610f, 0.018219f, 0.023392f, 0.030594f, 0.039795f, 0.437744f, 0.498291f, 0.512207f, 0.517578f, 0.521484f, 0.525391f,
+ 0.000102f, 0.000186f, 0.000171f, 0.000181f, 0.000227f, 0.000229f, 0.000231f, 0.000278f, 0.000293f, 0.000304f, 0.000314f, 0.000375f,
+ 0.000365f, 0.000411f, 0.000446f, 0.000457f, 0.000496f, 0.000513f, 0.000533f, 0.000554f, 0.000603f, 0.000622f, 0.000669f, 0.000708f,
+ 0.000757f, 0.000789f, 0.000843f, 0.000875f, 0.000925f, 0.000964f, 0.001037f, 0.001094f, 0.001172f, 0.001243f, 0.001324f, 0.001373f,
+ 0.001497f, 0.001570f, 0.001712f, 0.001829f, 0.001947f, 0.002123f, 0.002291f, 0.002472f, 0.002703f, 0.003008f, 0.003342f, 0.003757f,
+ 0.004204f, 0.004810f, 0.005539f, 0.006554f, 0.007828f, 0.009537f, 0.011894f, 0.015442f, 0.021072f, 0.029282f, 0.424561f, 0.486084f,
+ 0.500488f, 0.506836f, 0.512207f, 0.514648f, 0.000014f, 0.000127f, 0.000112f, 0.000109f, 0.000143f, 0.000165f, 0.000141f, 0.000180f,
+ 0.000185f, 0.000191f, 0.000196f, 0.000203f, 0.000233f, 0.000252f, 0.000260f, 0.000274f, 0.000288f, 0.000314f, 0.000328f, 0.000363f,
+ 0.000362f, 0.000374f, 0.000400f, 0.000436f, 0.000464f, 0.000501f, 0.000504f, 0.000521f, 0.000563f, 0.000593f, 0.000635f, 0.000671f,
+ 0.000712f, 0.000740f, 0.000800f, 0.000837f, 0.000892f, 0.000955f, 0.001030f, 0.001092f, 0.001167f, 0.001270f, 0.001369f, 0.001491f,
+ 0.001626f, 0.001769f, 0.001993f, 0.002209f, 0.002523f, 0.002863f, 0.003325f, 0.003880f, 0.004715f, 0.005764f, 0.007320f, 0.009468f,
+ 0.013344f, 0.020187f, 0.410645f, 0.473877f, 0.489258f, 0.496826f, 0.500488f, 0.503906f, 0.000103f, 0.000078f, 0.000067f, 0.000065f,
+ 0.000086f, 0.000085f, 0.000101f, 0.000106f, 0.000106f, 0.000107f, 0.000115f, 0.000133f, 0.000118f, 0.000133f, 0.000154f, 0.000150f,
+ 0.000167f, 0.000177f, 0.000180f, 0.000190f, 0.000207f, 0.000213f, 0.000228f, 0.000238f, 0.000267f, 0.000277f, 0.000287f, 0.000298f,
+ 0.000313f, 0.000325f, 0.000347f, 0.000375f, 0.000393f, 0.000405f, 0.000440f, 0.000463f, 0.000486f, 0.000527f, 0.000562f, 0.000599f,
+ 0.000639f, 0.000688f, 0.000757f, 0.000807f, 0.000879f, 0.000961f, 0.001059f, 0.001180f, 0.001342f, 0.001533f, 0.001762f, 0.002102f,
+ 0.002502f, 0.003128f, 0.004028f, 0.005379f, 0.007591f, 0.012505f, 0.397217f, 0.462891f, 0.478760f, 0.485840f, 0.490479f, 0.492676f,
+ 0.000087f, 0.000063f, 0.000054f, 0.000048f, 0.000047f, 0.000044f, 0.000046f, 0.000047f, 0.000047f, 0.000060f, 0.000053f, 0.000056f,
+ 0.000072f, 0.000060f, 0.000064f, 0.000069f, 0.000078f, 0.000085f, 0.000084f, 0.000090f, 0.000094f, 0.000102f, 0.000105f, 0.000111f,
+ 0.000116f, 0.000126f, 0.000132f, 0.000150f, 0.000147f, 0.000158f, 0.000167f, 0.000178f, 0.000185f, 0.000192f, 0.000211f, 0.000216f,
+ 0.000226f, 0.000246f, 0.000265f, 0.000284f, 0.000299f, 0.000325f, 0.000349f, 0.000381f, 0.000415f, 0.000448f, 0.000490f, 0.000544f,
+ 0.000612f, 0.000694f, 0.000798f, 0.000943f, 0.001139f, 0.001436f, 0.001870f, 0.002586f, 0.003817f, 0.006474f, 0.383545f, 0.450195f,
+ 0.467041f, 0.474365f, 0.478760f, 0.482422f, 0.000065f, 0.000045f, 0.000037f, 0.000033f, 0.000030f, 0.000028f, 0.000026f, 0.000025f,
+ 0.000024f, 0.000022f, 0.000021f, 0.000025f, 0.000020f, 0.000021f, 0.000025f, 0.000029f, 0.000028f, 0.000031f, 0.000033f, 0.000034f,
+ 0.000036f, 0.000041f, 0.000045f, 0.000040f, 0.000045f, 0.000049f, 0.000051f, 0.000048f, 0.000055f, 0.000057f, 0.000061f, 0.000066f,
+ 0.000072f, 0.000068f, 0.000073f, 0.000078f, 0.000087f, 0.000089f, 0.000097f, 0.000104f, 0.000113f, 0.000115f, 0.000128f, 0.000137f,
+ 0.000148f, 0.000160f, 0.000174f, 0.000194f, 0.000221f, 0.000248f, 0.000283f, 0.000324f, 0.000396f, 0.000496f, 0.000657f, 0.000928f,
+ 0.001479f, 0.002684f, 0.371094f, 0.438477f, 0.455078f, 0.463867f, 0.468750f, 0.471191f, 0.000029f, 0.000019f, 0.000016f, 0.000014f,
+ 0.000014f, 0.000013f, 0.000012f, 0.000012f, 0.000012f, 0.000011f, 0.000011f, 0.000011f, 0.000011f, 0.000010f, 0.000010f, 0.000010f,
+ 0.000009f, 0.000009f, 0.000009f, 0.000008f, 0.000008f, 0.000007f, 0.000008f, 0.000007f, 0.000008f, 0.000009f, 0.000010f, 0.000011f,
+ 0.000012f, 0.000011f, 0.000012f, 0.000013f, 0.000015f, 0.000017f, 0.000018f, 0.000018f, 0.000020f, 0.000019f, 0.000021f, 0.000024f,
+ 0.000024f, 0.000026f, 0.000028f, 0.000031f, 0.000031f, 0.000035f, 0.000040f, 0.000041f, 0.000045f, 0.000052f, 0.000059f, 0.000071f,
+ 0.000083f, 0.000099f, 0.000132f, 0.000188f, 0.000315f, 0.000712f, 0.356934f, 0.426514f, 0.444824f, 0.452637f, 0.457520f, 0.460938f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f,
+ 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000001f,
+ 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000002f, 0.000001f, 0.000002f, 0.000002f,
+ 0.000002f, 0.000002f, 0.000003f, 0.000003f, 0.000003f, 0.000004f, 0.000004f, 0.000006f, 0.000010f, 0.000027f, 0.343750f, 0.414795f,
+ 0.433105f, 0.441895f, 0.446289f, 0.449951f,
+ },
+ {
+ 0.012436f, 0.037598f, 0.062805f, 0.087891f, 0.113037f, 0.137329f, 0.161621f, 0.185425f, 0.209717f, 0.232544f, 0.255371f, 0.278076f,
+ 0.300049f, 0.321289f, 0.343506f, 0.364014f, 0.385010f, 0.404785f, 0.424561f, 0.444824f, 0.463623f, 0.482422f, 0.501465f, 0.520020f,
+ 0.537598f, 0.554688f, 0.572266f, 0.589355f, 0.605957f, 0.622070f, 0.639648f, 0.655273f, 0.670410f, 0.685547f, 0.700684f, 0.715332f,
+ 0.730469f, 0.744629f, 0.758301f, 0.771973f, 0.785156f, 0.799316f, 0.812012f, 0.825684f, 0.837891f, 0.850586f, 0.863281f, 0.875000f,
+ 0.887207f, 0.898926f, 0.910156f, 0.921387f, 0.933105f, 0.944336f, 0.954102f, 0.964844f, 0.976074f, 0.985840f, 0.978027f, 0.947266f,
+ 0.925781f, 0.907715f, 0.892090f, 0.877930f, 0.011276f, 0.034546f, 0.058289f, 0.082031f, 0.105469f, 0.128662f, 0.152344f, 0.174805f,
+ 0.197876f, 0.219604f, 0.241455f, 0.263672f, 0.284912f, 0.306152f, 0.326416f, 0.347168f, 0.366699f, 0.387695f, 0.406494f, 0.426025f,
+ 0.444824f, 0.463379f, 0.481934f, 0.500000f, 0.518066f, 0.535645f, 0.552246f, 0.569824f, 0.586426f, 0.603027f, 0.619141f, 0.634766f,
+ 0.650391f, 0.666016f, 0.681152f, 0.695801f, 0.710938f, 0.725586f, 0.739258f, 0.753906f, 0.768066f, 0.781250f, 0.794922f, 0.807617f,
+ 0.821289f, 0.833496f, 0.846191f, 0.858398f, 0.870605f, 0.882812f, 0.894531f, 0.906250f, 0.917480f, 0.929199f, 0.939453f, 0.951660f,
+ 0.961426f, 0.972656f, 0.971680f, 0.942871f, 0.921875f, 0.904785f, 0.889160f, 0.875977f, 0.010628f, 0.032288f, 0.054932f, 0.076172f,
+ 0.099060f, 0.121216f, 0.142700f, 0.164795f, 0.186279f, 0.207642f, 0.229248f, 0.249756f, 0.269531f, 0.291016f, 0.310791f, 0.331543f,
+ 0.349609f, 0.369385f, 0.388916f, 0.409180f, 0.427246f, 0.444824f, 0.463135f, 0.480713f, 0.499512f, 0.516602f, 0.533203f, 0.550293f,
+ 0.567383f, 0.583496f, 0.599609f, 0.615723f, 0.630859f, 0.646973f, 0.661621f, 0.677246f, 0.691895f, 0.705566f, 0.720703f, 0.735352f,
+ 0.749512f, 0.763184f, 0.776367f, 0.790039f, 0.803223f, 0.816406f, 0.828613f, 0.842285f, 0.854492f, 0.867676f, 0.878418f, 0.890137f,
+ 0.902832f, 0.913086f, 0.925293f, 0.936035f, 0.947754f, 0.958008f, 0.964844f, 0.937500f, 0.917480f, 0.901367f, 0.886719f, 0.873535f,
+ 0.009926f, 0.030167f, 0.050995f, 0.071594f, 0.092346f, 0.113892f, 0.134399f, 0.154663f, 0.175537f, 0.195679f, 0.216309f, 0.235840f,
+ 0.256104f, 0.276611f, 0.295654f, 0.314453f, 0.333496f, 0.353027f, 0.370850f, 0.389404f, 0.408936f, 0.427490f, 0.445312f, 0.462891f,
+ 0.480225f, 0.497803f, 0.513672f, 0.531250f, 0.547363f, 0.563965f, 0.580078f, 0.597168f, 0.612305f, 0.627930f, 0.642578f, 0.658691f,
+ 0.673340f, 0.687500f, 0.702637f, 0.717285f, 0.731445f, 0.744629f, 0.758301f, 0.772461f, 0.786133f, 0.799316f, 0.811523f, 0.824707f,
+ 0.837891f, 0.849121f, 0.861816f, 0.874023f, 0.887207f, 0.898438f, 0.910156f, 0.920898f, 0.932617f, 0.943848f, 0.958008f, 0.932129f,
+ 0.913086f, 0.897461f, 0.883301f, 0.871094f, 0.009178f, 0.028107f, 0.047729f, 0.066895f, 0.086182f, 0.106384f, 0.125977f, 0.145386f,
+ 0.165527f, 0.184937f, 0.203857f, 0.224121f, 0.242676f, 0.261475f, 0.281006f, 0.300049f, 0.318604f, 0.336426f, 0.355469f, 0.372314f,
+ 0.391113f, 0.409424f, 0.426514f, 0.444092f, 0.461426f, 0.477783f, 0.495850f, 0.512207f, 0.528809f, 0.544434f, 0.561035f, 0.576660f,
+ 0.593262f, 0.608398f, 0.623047f, 0.638184f, 0.655273f, 0.668945f, 0.682617f, 0.697754f, 0.712402f, 0.726562f, 0.740234f, 0.753906f,
+ 0.768066f, 0.781250f, 0.794434f, 0.807617f, 0.820312f, 0.833496f, 0.845215f, 0.858398f, 0.870605f, 0.881836f, 0.894043f, 0.906738f,
+ 0.917480f, 0.928711f, 0.951172f, 0.926758f, 0.909180f, 0.893555f, 0.880859f, 0.868164f, 0.008667f, 0.025986f, 0.044922f, 0.062805f,
+ 0.081421f, 0.099854f, 0.118347f, 0.137085f, 0.155518f, 0.173828f, 0.193115f, 0.211304f, 0.229858f, 0.248413f, 0.266602f, 0.285400f,
+ 0.303223f, 0.321045f, 0.339111f, 0.357178f, 0.373779f, 0.391357f, 0.409424f, 0.426270f, 0.443115f, 0.460449f, 0.476807f, 0.494141f,
+ 0.510254f, 0.526855f, 0.541992f, 0.559082f, 0.574219f, 0.589355f, 0.605469f, 0.620117f, 0.636230f, 0.649902f, 0.664551f, 0.678711f,
+ 0.693848f, 0.707031f, 0.723145f, 0.736328f, 0.750977f, 0.762695f, 0.776855f, 0.790039f, 0.803223f, 0.816406f, 0.828613f, 0.842285f,
+ 0.853516f, 0.866211f, 0.878906f, 0.890625f, 0.902832f, 0.913574f, 0.944336f, 0.921875f, 0.903809f, 0.889160f, 0.876953f, 0.865234f,
+ 0.008057f, 0.024658f, 0.041321f, 0.058411f, 0.075989f, 0.093811f, 0.110535f, 0.128784f, 0.146729f, 0.164307f, 0.182007f, 0.200073f,
+ 0.217773f, 0.234619f, 0.252930f, 0.271240f, 0.288086f, 0.306152f, 0.322998f, 0.341064f, 0.357910f, 0.374756f, 0.391357f, 0.409180f,
+ 0.425293f, 0.442383f, 0.458496f, 0.475342f, 0.491455f, 0.507324f, 0.523438f, 0.539551f, 0.555176f, 0.570312f, 0.585938f, 0.601074f,
+ 0.616699f, 0.631836f, 0.646484f, 0.660645f, 0.676270f, 0.688477f, 0.704102f, 0.718262f, 0.731445f, 0.745117f, 0.760254f, 0.771484f,
+ 0.785156f, 0.799316f, 0.812500f, 0.824707f, 0.836914f, 0.850098f, 0.862793f, 0.874512f, 0.886719f, 0.898438f, 0.937500f, 0.915527f,
+ 0.899414f, 0.885254f, 0.872559f, 0.861816f, 0.007477f, 0.022919f, 0.038971f, 0.054901f, 0.070801f, 0.087646f, 0.104065f, 0.121155f,
+ 0.137573f, 0.155029f, 0.171875f, 0.188721f, 0.206177f, 0.222778f, 0.240112f, 0.257080f, 0.274170f, 0.290283f, 0.308350f, 0.324463f,
+ 0.342041f, 0.358154f, 0.375488f, 0.391113f, 0.407471f, 0.424561f, 0.440430f, 0.456787f, 0.474121f, 0.489746f, 0.505371f, 0.521484f,
+ 0.536133f, 0.552246f, 0.565918f, 0.582031f, 0.597168f, 0.613281f, 0.626953f, 0.642578f, 0.656738f, 0.670898f, 0.684570f, 0.699219f,
+ 0.712891f, 0.727539f, 0.741211f, 0.754395f, 0.768066f, 0.781738f, 0.794434f, 0.808105f, 0.820312f, 0.833984f, 0.846680f, 0.858887f,
+ 0.871582f, 0.883301f, 0.930176f, 0.910156f, 0.894043f, 0.880371f, 0.868652f, 0.858398f, 0.007023f, 0.021240f, 0.036224f, 0.051300f,
+ 0.066467f, 0.082092f, 0.097900f, 0.113892f, 0.129517f, 0.145752f, 0.161743f, 0.178223f, 0.194702f, 0.210327f, 0.227661f, 0.243408f,
+ 0.260986f, 0.276855f, 0.292725f, 0.309814f, 0.326172f, 0.342041f, 0.358398f, 0.375732f, 0.391113f, 0.406982f, 0.422852f, 0.438965f,
+ 0.454590f, 0.471191f, 0.486816f, 0.502441f, 0.517578f, 0.533203f, 0.548340f, 0.562988f, 0.578613f, 0.593750f, 0.609375f, 0.623535f,
+ 0.638184f, 0.652832f, 0.666992f, 0.680664f, 0.695312f, 0.708984f, 0.722656f, 0.736816f, 0.750000f, 0.764160f, 0.777344f, 0.789551f,
+ 0.803223f, 0.816895f, 0.830078f, 0.842773f, 0.854980f, 0.868652f, 0.922852f, 0.904297f, 0.889160f, 0.875977f, 0.864746f, 0.854492f,
+ 0.006458f, 0.019913f, 0.033691f, 0.048126f, 0.062744f, 0.077026f, 0.092224f, 0.106567f, 0.122192f, 0.137207f, 0.152222f, 0.167725f,
+ 0.183838f, 0.199951f, 0.215088f, 0.231323f, 0.246826f, 0.262695f, 0.279053f, 0.294678f, 0.310547f, 0.326172f, 0.342041f, 0.358887f,
+ 0.374268f, 0.389893f, 0.405518f, 0.421143f, 0.437012f, 0.452637f, 0.467773f, 0.483643f, 0.499512f, 0.513672f, 0.529785f, 0.545410f,
+ 0.560059f, 0.575195f, 0.590332f, 0.604980f, 0.618652f, 0.634277f, 0.648438f, 0.662598f, 0.676270f, 0.690918f, 0.704102f, 0.718750f,
+ 0.732422f, 0.745605f, 0.760254f, 0.773438f, 0.786621f, 0.801270f, 0.812988f, 0.826172f, 0.839844f, 0.851562f, 0.915527f, 0.897949f,
+ 0.883789f, 0.871094f, 0.860352f, 0.850586f, 0.006077f, 0.018921f, 0.031464f, 0.045258f, 0.058411f, 0.072144f, 0.085999f, 0.100220f,
+ 0.114258f, 0.129028f, 0.143677f, 0.158691f, 0.173584f, 0.188477f, 0.203247f, 0.219238f, 0.234497f, 0.249634f, 0.264893f, 0.280273f,
+ 0.295410f, 0.310791f, 0.326904f, 0.342285f, 0.357910f, 0.373535f, 0.388428f, 0.404053f, 0.420166f, 0.435303f, 0.450195f, 0.465332f,
+ 0.481201f, 0.496338f, 0.511230f, 0.525879f, 0.540527f, 0.556641f, 0.570312f, 0.585938f, 0.600098f, 0.614746f, 0.629883f, 0.644531f,
+ 0.657715f, 0.672363f, 0.687012f, 0.700684f, 0.714355f, 0.729004f, 0.742188f, 0.755371f, 0.769531f, 0.782227f, 0.796875f, 0.810059f,
+ 0.823242f, 0.836426f, 0.907715f, 0.891602f, 0.877930f, 0.866211f, 0.855957f, 0.846680f, 0.005596f, 0.017654f, 0.029587f, 0.041840f,
+ 0.055115f, 0.067871f, 0.080566f, 0.093994f, 0.107361f, 0.120911f, 0.134766f, 0.149414f, 0.163452f, 0.177979f, 0.192261f, 0.206787f,
+ 0.221191f, 0.236816f, 0.250732f, 0.266113f, 0.281250f, 0.295898f, 0.311279f, 0.326904f, 0.342041f, 0.356201f, 0.371826f, 0.387451f,
+ 0.402344f, 0.417236f, 0.432373f, 0.447266f, 0.462891f, 0.477539f, 0.492432f, 0.506836f, 0.522949f, 0.536621f, 0.551758f, 0.566895f,
+ 0.582031f, 0.596191f, 0.610352f, 0.625488f, 0.640625f, 0.653320f, 0.668457f, 0.682617f, 0.696777f, 0.710449f, 0.724609f, 0.739258f,
+ 0.751465f, 0.765625f, 0.780273f, 0.792480f, 0.806152f, 0.820801f, 0.899902f, 0.885742f, 0.872070f, 0.861328f, 0.851562f, 0.842285f,
+ 0.005451f, 0.016479f, 0.028259f, 0.039856f, 0.051331f, 0.063416f, 0.075867f, 0.088196f, 0.100952f, 0.113770f, 0.126953f, 0.140747f,
+ 0.153564f, 0.167847f, 0.181519f, 0.195679f, 0.210083f, 0.223633f, 0.237427f, 0.252197f, 0.267334f, 0.281738f, 0.296143f, 0.311035f,
+ 0.325928f, 0.340332f, 0.355469f, 0.370361f, 0.385010f, 0.400635f, 0.415039f, 0.429688f, 0.444092f, 0.459717f, 0.474121f, 0.489258f,
+ 0.503906f, 0.519043f, 0.533203f, 0.548828f, 0.562012f, 0.577637f, 0.591797f, 0.606445f, 0.621582f, 0.635742f, 0.650391f, 0.664551f,
+ 0.678223f, 0.692871f, 0.706055f, 0.721191f, 0.733887f, 0.747559f, 0.762207f, 0.775879f, 0.791016f, 0.804199f, 0.892090f, 0.878906f,
+ 0.866699f, 0.855957f, 0.846191f, 0.837891f, 0.004963f, 0.015343f, 0.026169f, 0.037079f, 0.047943f, 0.059570f, 0.070801f, 0.083008f,
+ 0.095093f, 0.106750f, 0.119507f, 0.132080f, 0.145142f, 0.158569f, 0.171143f, 0.184692f, 0.198730f, 0.211792f, 0.225830f, 0.239380f,
+ 0.253662f, 0.267578f, 0.281738f, 0.295898f, 0.309814f, 0.324219f, 0.340088f, 0.353760f, 0.368164f, 0.383057f, 0.397705f, 0.412842f,
+ 0.426758f, 0.441406f, 0.456787f, 0.470947f, 0.485352f, 0.500000f, 0.515137f, 0.529785f, 0.543945f, 0.559082f, 0.572754f, 0.588379f,
+ 0.602539f, 0.616699f, 0.631348f, 0.645996f, 0.659180f, 0.674805f, 0.689453f, 0.703125f, 0.716797f, 0.729980f, 0.744629f, 0.758789f,
+ 0.772461f, 0.786621f, 0.883789f, 0.872070f, 0.860840f, 0.850586f, 0.841309f, 0.833008f, 0.004726f, 0.014549f, 0.024109f, 0.034668f,
+ 0.044708f, 0.055573f, 0.066467f, 0.077820f, 0.088928f, 0.100342f, 0.112000f, 0.124390f, 0.136230f, 0.148804f, 0.161621f, 0.173950f,
+ 0.186768f, 0.200439f, 0.213623f, 0.226074f, 0.239868f, 0.253418f, 0.267090f, 0.281250f, 0.295410f, 0.309570f, 0.323486f, 0.337891f,
+ 0.352295f, 0.365967f, 0.381104f, 0.394775f, 0.409180f, 0.423828f, 0.438477f, 0.452881f, 0.467773f, 0.481689f, 0.496582f, 0.511230f,
+ 0.525391f, 0.539551f, 0.554199f, 0.568848f, 0.583984f, 0.599121f, 0.612305f, 0.627441f, 0.641113f, 0.656250f, 0.669922f, 0.684570f,
+ 0.699219f, 0.713379f, 0.727539f, 0.741699f, 0.755859f, 0.771484f, 0.875488f, 0.865723f, 0.854492f, 0.845215f, 0.836426f, 0.828613f,
+ 0.004452f, 0.013359f, 0.022690f, 0.032745f, 0.042297f, 0.051910f, 0.061920f, 0.072693f, 0.083496f, 0.094177f, 0.105408f, 0.116760f,
+ 0.128174f, 0.140137f, 0.151855f, 0.164185f, 0.176758f, 0.189087f, 0.201660f, 0.214478f, 0.227173f, 0.240356f, 0.253906f, 0.267578f,
+ 0.280273f, 0.294922f, 0.307373f, 0.321045f, 0.336670f, 0.350098f, 0.363770f, 0.378174f, 0.392334f, 0.406006f, 0.420410f, 0.434082f,
+ 0.448975f, 0.463623f, 0.478271f, 0.492676f, 0.506836f, 0.520996f, 0.536133f, 0.550781f, 0.565430f, 0.580078f, 0.593750f, 0.608887f,
+ 0.623047f, 0.638184f, 0.651367f, 0.666016f, 0.681152f, 0.695312f, 0.709473f, 0.723145f, 0.738281f, 0.752930f, 0.867676f, 0.858398f,
+ 0.848633f, 0.839355f, 0.831055f, 0.823730f, 0.004143f, 0.012794f, 0.021713f, 0.030396f, 0.039551f, 0.048645f, 0.058563f, 0.068176f,
+ 0.078308f, 0.088928f, 0.098328f, 0.109924f, 0.120728f, 0.131592f, 0.142944f, 0.154175f, 0.165771f, 0.178223f, 0.190186f, 0.202881f,
+ 0.214844f, 0.227417f, 0.240845f, 0.253906f, 0.265869f, 0.279541f, 0.293213f, 0.305908f, 0.320068f, 0.333496f, 0.347168f, 0.361816f,
+ 0.375000f, 0.389160f, 0.403320f, 0.417236f, 0.431396f, 0.444824f, 0.459473f, 0.473633f, 0.488525f, 0.503418f, 0.517578f, 0.532227f,
+ 0.545410f, 0.560547f, 0.575684f, 0.590332f, 0.604004f, 0.618652f, 0.632812f, 0.647949f, 0.663086f, 0.676758f, 0.691895f, 0.706543f,
+ 0.721191f, 0.735840f, 0.859375f, 0.852539f, 0.842773f, 0.833496f, 0.824707f, 0.818848f, 0.003839f, 0.012062f, 0.020126f, 0.028366f,
+ 0.036774f, 0.045593f, 0.054718f, 0.063416f, 0.073120f, 0.082825f, 0.092957f, 0.102966f, 0.113464f, 0.123535f, 0.134277f, 0.145020f,
+ 0.155762f, 0.167847f, 0.179199f, 0.190796f, 0.202393f, 0.214844f, 0.227417f, 0.239868f, 0.252197f, 0.264648f, 0.277588f, 0.291016f,
+ 0.304199f, 0.317383f, 0.330811f, 0.343750f, 0.357422f, 0.371826f, 0.385254f, 0.399902f, 0.413574f, 0.427246f, 0.441162f, 0.455566f,
+ 0.469971f, 0.484375f, 0.498535f, 0.514160f, 0.527344f, 0.541992f, 0.556152f, 0.570312f, 0.585449f, 0.600098f, 0.614746f, 0.629883f,
+ 0.645508f, 0.658203f, 0.673340f, 0.688477f, 0.703125f, 0.718262f, 0.851074f, 0.844727f, 0.835938f, 0.827637f, 0.820312f, 0.812988f,
+ 0.003786f, 0.011147f, 0.018921f, 0.026550f, 0.034729f, 0.042664f, 0.051117f, 0.060028f, 0.068298f, 0.077454f, 0.086914f, 0.096130f,
+ 0.105835f, 0.115662f, 0.126343f, 0.136475f, 0.146606f, 0.157715f, 0.168457f, 0.180176f, 0.191528f, 0.202759f, 0.215088f, 0.226929f,
+ 0.239014f, 0.251221f, 0.263428f, 0.275391f, 0.289062f, 0.301514f, 0.314941f, 0.328369f, 0.341797f, 0.354736f, 0.367676f, 0.382324f,
+ 0.395264f, 0.409912f, 0.423340f, 0.437012f, 0.451660f, 0.465576f, 0.480469f, 0.494629f, 0.508301f, 0.522949f, 0.538086f, 0.551758f,
+ 0.567383f, 0.582031f, 0.596191f, 0.610840f, 0.625977f, 0.639648f, 0.655273f, 0.670410f, 0.685547f, 0.700684f, 0.842285f, 0.837402f,
+ 0.829590f, 0.821289f, 0.813965f, 0.808105f, 0.003504f, 0.010445f, 0.017609f, 0.025131f, 0.032349f, 0.040314f, 0.047485f, 0.055756f,
+ 0.064026f, 0.072571f, 0.080872f, 0.089661f, 0.099426f, 0.108459f, 0.118286f, 0.127930f, 0.137817f, 0.147583f, 0.158203f, 0.169189f,
+ 0.180908f, 0.191040f, 0.203003f, 0.214111f, 0.225708f, 0.237549f, 0.249023f, 0.261475f, 0.273926f, 0.286865f, 0.299316f, 0.311768f,
+ 0.325684f, 0.338623f, 0.351562f, 0.364746f, 0.378418f, 0.392578f, 0.405518f, 0.419678f, 0.433105f, 0.447998f, 0.461670f, 0.475830f,
+ 0.490479f, 0.503906f, 0.519531f, 0.533203f, 0.547852f, 0.562988f, 0.576660f, 0.591797f, 0.606445f, 0.622070f, 0.636719f, 0.652344f,
+ 0.666504f, 0.682617f, 0.833496f, 0.830078f, 0.822754f, 0.815918f, 0.808594f, 0.802734f, 0.003447f, 0.009941f, 0.016373f, 0.023300f,
+ 0.030228f, 0.037689f, 0.044128f, 0.052551f, 0.059845f, 0.068115f, 0.076538f, 0.083862f, 0.092896f, 0.101440f, 0.110596f, 0.119995f,
+ 0.129028f, 0.138916f, 0.148926f, 0.158936f, 0.169189f, 0.180176f, 0.190308f, 0.201416f, 0.212769f, 0.224365f, 0.235962f, 0.247192f,
+ 0.259033f, 0.271973f, 0.283936f, 0.296631f, 0.309570f, 0.321777f, 0.334961f, 0.348389f, 0.361572f, 0.374756f, 0.388184f, 0.401611f,
+ 0.415771f, 0.429443f, 0.443359f, 0.457520f, 0.471436f, 0.486084f, 0.500977f, 0.514648f, 0.528809f, 0.543457f, 0.558594f, 0.573242f,
+ 0.588867f, 0.603516f, 0.617676f, 0.633301f, 0.648926f, 0.664551f, 0.824219f, 0.823242f, 0.815918f, 0.809082f, 0.802246f, 0.796387f,
+ 0.003141f, 0.009407f, 0.015251f, 0.021851f, 0.028107f, 0.034882f, 0.041779f, 0.048340f, 0.056244f, 0.062988f, 0.071106f, 0.078796f,
+ 0.087036f, 0.094910f, 0.103149f, 0.112305f, 0.121460f, 0.130371f, 0.139404f, 0.149048f, 0.159180f, 0.169189f, 0.179565f, 0.189087f,
+ 0.200317f, 0.211548f, 0.222412f, 0.233765f, 0.245117f, 0.257324f, 0.269043f, 0.281006f, 0.293213f, 0.305664f, 0.318848f, 0.331055f,
+ 0.343750f, 0.358398f, 0.369873f, 0.384033f, 0.397217f, 0.411865f, 0.424805f, 0.438965f, 0.453125f, 0.467529f, 0.481689f, 0.495850f,
+ 0.510254f, 0.524414f, 0.539551f, 0.554688f, 0.569824f, 0.584961f, 0.599121f, 0.614258f, 0.629883f, 0.645020f, 0.815430f, 0.814453f,
+ 0.809570f, 0.802734f, 0.796875f, 0.791504f, 0.002838f, 0.008461f, 0.014236f, 0.020676f, 0.026749f, 0.032593f, 0.039032f, 0.045715f,
+ 0.052216f, 0.059479f, 0.066467f, 0.073608f, 0.080933f, 0.088623f, 0.096619f, 0.104919f, 0.113098f, 0.121521f, 0.130493f, 0.139526f,
+ 0.148560f, 0.158203f, 0.167969f, 0.177979f, 0.187988f, 0.198730f, 0.208862f, 0.220093f, 0.231323f, 0.242798f, 0.253906f, 0.265869f,
+ 0.278320f, 0.289551f, 0.302246f, 0.314941f, 0.327393f, 0.340088f, 0.353516f, 0.365967f, 0.379883f, 0.392822f, 0.406738f, 0.420898f,
+ 0.434814f, 0.447998f, 0.462891f, 0.477539f, 0.491455f, 0.506836f, 0.520996f, 0.536133f, 0.550781f, 0.565918f, 0.581055f, 0.596680f,
+ 0.611816f, 0.627441f, 0.806152f, 0.807617f, 0.801270f, 0.796387f, 0.790039f, 0.784668f, 0.002689f, 0.008102f, 0.013618f, 0.019058f,
+ 0.024719f, 0.030548f, 0.036560f, 0.042725f, 0.048615f, 0.054779f, 0.061615f, 0.068604f, 0.075012f, 0.082703f, 0.090271f, 0.097900f,
+ 0.105530f, 0.113586f, 0.121826f, 0.130371f, 0.139282f, 0.147705f, 0.157349f, 0.166504f, 0.176147f, 0.186401f, 0.196289f, 0.207520f,
+ 0.217651f, 0.228394f, 0.239868f, 0.251465f, 0.262451f, 0.274414f, 0.286377f, 0.298828f, 0.311035f, 0.323730f, 0.336670f, 0.349121f,
+ 0.362549f, 0.375244f, 0.389160f, 0.402344f, 0.417236f, 0.429932f, 0.443848f, 0.458984f, 0.472168f, 0.487793f, 0.501953f, 0.517578f,
+ 0.531738f, 0.546875f, 0.561523f, 0.576660f, 0.593262f, 0.608398f, 0.797852f, 0.798828f, 0.794922f, 0.789551f, 0.784668f, 0.779297f,
+ 0.002666f, 0.007462f, 0.012596f, 0.018066f, 0.023026f, 0.028412f, 0.033813f, 0.039398f, 0.045166f, 0.051239f, 0.057587f, 0.063721f,
+ 0.070312f, 0.077148f, 0.084167f, 0.090820f, 0.098267f, 0.105591f, 0.113159f, 0.121460f, 0.129761f, 0.138428f, 0.147217f, 0.156128f,
+ 0.165283f, 0.174438f, 0.183960f, 0.194092f, 0.204834f, 0.214844f, 0.225830f, 0.236816f, 0.247925f, 0.259033f, 0.270752f, 0.282227f,
+ 0.294678f, 0.306641f, 0.319336f, 0.332031f, 0.344482f, 0.357910f, 0.371094f, 0.384033f, 0.398682f, 0.412109f, 0.425781f, 0.440186f,
+ 0.454102f, 0.468018f, 0.482910f, 0.497314f, 0.512207f, 0.528320f, 0.542969f, 0.558594f, 0.573242f, 0.589355f, 0.787598f, 0.791016f,
+ 0.787109f, 0.781738f, 0.777344f, 0.772461f, 0.002569f, 0.007069f, 0.012199f, 0.016739f, 0.021393f, 0.026672f, 0.031189f, 0.037109f,
+ 0.042480f, 0.047729f, 0.053345f, 0.059387f, 0.065430f, 0.071838f, 0.078186f, 0.084167f, 0.091492f, 0.098816f, 0.105774f, 0.112976f,
+ 0.121155f, 0.129028f, 0.136963f, 0.145508f, 0.153687f, 0.163086f, 0.172363f, 0.181885f, 0.191406f, 0.201782f, 0.211670f, 0.222412f,
+ 0.233032f, 0.244263f, 0.255371f, 0.266846f, 0.278809f, 0.290527f, 0.302734f, 0.314697f, 0.327393f, 0.340820f, 0.353027f, 0.366455f,
+ 0.380127f, 0.393799f, 0.406006f, 0.421143f, 0.435059f, 0.449707f, 0.463623f, 0.479248f, 0.494141f, 0.509277f, 0.523438f, 0.539551f,
+ 0.555176f, 0.570801f, 0.778320f, 0.783203f, 0.779785f, 0.775879f, 0.770996f, 0.767090f, 0.002398f, 0.006733f, 0.010918f, 0.015495f,
+ 0.020203f, 0.024963f, 0.029663f, 0.034485f, 0.039246f, 0.044678f, 0.049896f, 0.055267f, 0.060486f, 0.066345f, 0.072693f, 0.078857f,
+ 0.085083f, 0.091370f, 0.097961f, 0.105530f, 0.112244f, 0.119629f, 0.127563f, 0.135376f, 0.143799f, 0.152100f, 0.160889f, 0.169922f,
+ 0.178833f, 0.188843f, 0.198608f, 0.208496f, 0.218628f, 0.229492f, 0.240479f, 0.251953f, 0.262695f, 0.274902f, 0.286377f, 0.298340f,
+ 0.310547f, 0.323242f, 0.335693f, 0.349365f, 0.362061f, 0.375000f, 0.388916f, 0.402832f, 0.416748f, 0.430420f, 0.445068f, 0.459473f,
+ 0.474854f, 0.489258f, 0.504883f, 0.519531f, 0.535645f, 0.551758f, 0.769043f, 0.774902f, 0.771973f, 0.768555f, 0.764160f, 0.759766f,
+ 0.002062f, 0.006191f, 0.010384f, 0.014786f, 0.018402f, 0.023270f, 0.027435f, 0.031891f, 0.036163f, 0.041199f, 0.045685f, 0.051208f,
+ 0.056244f, 0.061371f, 0.066772f, 0.072510f, 0.078369f, 0.084656f, 0.091125f, 0.097290f, 0.104309f, 0.111145f, 0.118164f, 0.126221f,
+ 0.133301f, 0.141724f, 0.149658f, 0.157837f, 0.167236f, 0.176025f, 0.185547f, 0.195190f, 0.205444f, 0.215332f, 0.225830f, 0.236084f,
+ 0.247314f, 0.259033f, 0.270020f, 0.281982f, 0.293701f, 0.305908f, 0.318848f, 0.331787f, 0.344482f, 0.357178f, 0.370361f, 0.384521f,
+ 0.397461f, 0.411621f, 0.426025f, 0.440674f, 0.455322f, 0.470703f, 0.485596f, 0.500977f, 0.517578f, 0.532227f, 0.759277f, 0.766602f,
+ 0.764160f, 0.761230f, 0.757324f, 0.753418f, 0.002064f, 0.005859f, 0.009613f, 0.013626f, 0.017456f, 0.021606f, 0.025574f, 0.029526f,
+ 0.034302f, 0.038422f, 0.042938f, 0.047485f, 0.052155f, 0.056763f, 0.061951f, 0.067139f, 0.072754f, 0.078308f, 0.084167f, 0.090149f,
+ 0.096191f, 0.102722f, 0.109558f, 0.116699f, 0.123901f, 0.131104f, 0.139160f, 0.146729f, 0.155273f, 0.163940f, 0.173096f, 0.182129f,
+ 0.192017f, 0.201172f, 0.211060f, 0.221558f, 0.232544f, 0.243530f, 0.254150f, 0.266113f, 0.277588f, 0.289307f, 0.301758f, 0.313965f,
+ 0.326904f, 0.338867f, 0.352051f, 0.366211f, 0.379150f, 0.393066f, 0.407471f, 0.421875f, 0.436768f, 0.450439f, 0.466553f, 0.481201f,
+ 0.497314f, 0.513184f, 0.749512f, 0.758301f, 0.756348f, 0.753906f, 0.750000f, 0.746582f, 0.001851f, 0.005405f, 0.009109f, 0.012589f,
+ 0.016129f, 0.020020f, 0.023926f, 0.027481f, 0.031738f, 0.035492f, 0.039734f, 0.044128f, 0.048065f, 0.052765f, 0.057373f, 0.061859f,
+ 0.066711f, 0.072388f, 0.077393f, 0.083130f, 0.088745f, 0.094727f, 0.101135f, 0.107666f, 0.114380f, 0.121704f, 0.128540f, 0.136108f,
+ 0.144043f, 0.151733f, 0.160522f, 0.169678f, 0.178589f, 0.187622f, 0.197998f, 0.207397f, 0.217285f, 0.227905f, 0.238892f, 0.250000f,
+ 0.261230f, 0.272461f, 0.284180f, 0.296387f, 0.308838f, 0.321533f, 0.334473f, 0.347656f, 0.361328f, 0.375000f, 0.388672f, 0.402588f,
+ 0.417969f, 0.432617f, 0.447021f, 0.461914f, 0.478516f, 0.493652f, 0.739258f, 0.749512f, 0.749023f, 0.745605f, 0.742188f, 0.739746f,
+ 0.001666f, 0.005405f, 0.008575f, 0.011696f, 0.015327f, 0.018646f, 0.022293f, 0.025650f, 0.029327f, 0.032776f, 0.036530f, 0.040619f,
+ 0.044128f, 0.048828f, 0.052887f, 0.057098f, 0.061829f, 0.066467f, 0.071350f, 0.076355f, 0.081909f, 0.087341f, 0.092896f, 0.099304f,
+ 0.105469f, 0.112000f, 0.118835f, 0.125977f, 0.133545f, 0.140991f, 0.148438f, 0.156982f, 0.165771f, 0.174805f, 0.183960f, 0.193115f,
+ 0.203369f, 0.212891f, 0.223389f, 0.234497f, 0.244751f, 0.256348f, 0.268066f, 0.279541f, 0.291260f, 0.303955f, 0.316406f, 0.329590f,
+ 0.342529f, 0.355957f, 0.369385f, 0.384766f, 0.398926f, 0.413330f, 0.428467f, 0.442383f, 0.458740f, 0.474609f, 0.728516f, 0.740723f,
+ 0.740234f, 0.738281f, 0.735352f, 0.732910f, 0.001534f, 0.004936f, 0.007980f, 0.011223f, 0.013893f, 0.017212f, 0.020294f, 0.023361f,
+ 0.026688f, 0.030182f, 0.033600f, 0.037537f, 0.040924f, 0.044495f, 0.048340f, 0.052155f, 0.056732f, 0.061035f, 0.065430f, 0.069824f,
+ 0.075073f, 0.080078f, 0.085571f, 0.091003f, 0.096863f, 0.103271f, 0.109009f, 0.115723f, 0.123230f, 0.129639f, 0.137207f, 0.145264f,
+ 0.153320f, 0.161499f, 0.170410f, 0.179688f, 0.189087f, 0.198364f, 0.208740f, 0.218750f, 0.229126f, 0.240356f, 0.251465f, 0.263184f,
+ 0.274902f, 0.286621f, 0.299072f, 0.311768f, 0.324463f, 0.337402f, 0.351074f, 0.364746f, 0.378662f, 0.394287f, 0.408936f, 0.423096f,
+ 0.439453f, 0.455322f, 0.716797f, 0.731934f, 0.732422f, 0.729980f, 0.728027f, 0.725586f, 0.001639f, 0.004337f, 0.007439f, 0.009888f,
+ 0.013092f, 0.015717f, 0.018921f, 0.021805f, 0.024612f, 0.027542f, 0.030762f, 0.034088f, 0.037598f, 0.041107f, 0.044189f, 0.047699f,
+ 0.051666f, 0.055664f, 0.059723f, 0.064148f, 0.068542f, 0.073425f, 0.078003f, 0.083435f, 0.088806f, 0.094360f, 0.100159f, 0.106079f,
+ 0.112915f, 0.119690f, 0.125977f, 0.133667f, 0.141357f, 0.149414f, 0.157349f, 0.166260f, 0.175049f, 0.184326f, 0.193970f, 0.203735f,
+ 0.214355f, 0.224609f, 0.235352f, 0.246460f, 0.257568f, 0.269287f, 0.281738f, 0.294189f, 0.305908f, 0.319824f, 0.332520f, 0.346680f,
+ 0.360596f, 0.375244f, 0.389648f, 0.404297f, 0.419189f, 0.435791f, 0.707520f, 0.723145f, 0.723633f, 0.722656f, 0.720703f, 0.717773f,
+ 0.001469f, 0.004345f, 0.006844f, 0.009483f, 0.012428f, 0.014679f, 0.017166f, 0.019989f, 0.022949f, 0.025574f, 0.028320f, 0.031525f,
+ 0.034088f, 0.037323f, 0.040710f, 0.043762f, 0.047119f, 0.050873f, 0.054352f, 0.058441f, 0.062561f, 0.066711f, 0.071167f, 0.075989f,
+ 0.080627f, 0.086426f, 0.091553f, 0.097473f, 0.103210f, 0.109680f, 0.115723f, 0.122986f, 0.129761f, 0.137451f, 0.145142f, 0.153198f,
+ 0.161621f, 0.170654f, 0.179688f, 0.189087f, 0.198730f, 0.209229f, 0.219604f, 0.230225f, 0.241211f, 0.252197f, 0.264404f, 0.276367f,
+ 0.288574f, 0.301270f, 0.314453f, 0.328125f, 0.341309f, 0.354980f, 0.370117f, 0.385498f, 0.399902f, 0.415771f, 0.696289f, 0.714355f,
+ 0.715820f, 0.714355f, 0.712891f, 0.710449f, 0.001227f, 0.003862f, 0.006245f, 0.008644f, 0.010796f, 0.013344f, 0.015823f, 0.018448f,
+ 0.020645f, 0.023331f, 0.025681f, 0.028305f, 0.030975f, 0.033722f, 0.036987f, 0.039673f, 0.043121f, 0.046112f, 0.049774f, 0.053406f,
+ 0.056854f, 0.060760f, 0.064697f, 0.069397f, 0.073364f, 0.078369f, 0.083313f, 0.088257f, 0.094116f, 0.100098f, 0.105957f, 0.112122f,
+ 0.118774f, 0.125854f, 0.133057f, 0.140869f, 0.148682f, 0.157227f, 0.165405f, 0.174927f, 0.184082f, 0.193726f, 0.204102f, 0.214111f,
+ 0.225098f, 0.236328f, 0.247314f, 0.259277f, 0.270752f, 0.282959f, 0.296143f, 0.309082f, 0.322510f, 0.336426f, 0.350830f, 0.365479f,
+ 0.380371f, 0.396240f, 0.684570f, 0.705078f, 0.706543f, 0.706543f, 0.705078f, 0.703125f, 0.001069f, 0.003525f, 0.006062f, 0.008286f,
+ 0.010178f, 0.012589f, 0.014542f, 0.017075f, 0.019241f, 0.021179f, 0.023499f, 0.026047f, 0.028137f, 0.030762f, 0.033417f, 0.035889f,
+ 0.038757f, 0.041779f, 0.044586f, 0.048309f, 0.051056f, 0.054810f, 0.058777f, 0.062347f, 0.066528f, 0.070740f, 0.075256f, 0.080261f,
+ 0.085205f, 0.090393f, 0.095886f, 0.102478f, 0.108154f, 0.114441f, 0.121399f, 0.128784f, 0.135742f, 0.144165f, 0.151978f, 0.160767f,
+ 0.169434f, 0.178833f, 0.188721f, 0.198608f, 0.208984f, 0.220215f, 0.230957f, 0.241943f, 0.253906f, 0.265869f, 0.278564f, 0.291260f,
+ 0.304443f, 0.318359f, 0.332031f, 0.346680f, 0.361572f, 0.377197f, 0.673828f, 0.695801f, 0.698242f, 0.697754f, 0.697266f, 0.695312f,
+ 0.001211f, 0.003250f, 0.005112f, 0.007195f, 0.009651f, 0.011414f, 0.013641f, 0.015205f, 0.017334f, 0.019608f, 0.021164f, 0.023712f,
+ 0.025726f, 0.027863f, 0.029984f, 0.032410f, 0.035034f, 0.037689f, 0.040466f, 0.042938f, 0.046478f, 0.049591f, 0.052856f, 0.056274f,
+ 0.060089f, 0.063721f, 0.068115f, 0.072266f, 0.076904f, 0.081970f, 0.087036f, 0.092285f, 0.097961f, 0.104309f, 0.110535f, 0.117126f,
+ 0.124084f, 0.131226f, 0.139038f, 0.147095f, 0.155884f, 0.164429f, 0.174194f, 0.183228f, 0.192749f, 0.203491f, 0.214233f, 0.224976f,
+ 0.236206f, 0.247925f, 0.260498f, 0.272705f, 0.285889f, 0.299805f, 0.312988f, 0.327637f, 0.342529f, 0.356934f, 0.662598f, 0.686523f,
+ 0.689453f, 0.689453f, 0.688965f, 0.687500f, 0.001138f, 0.003206f, 0.005180f, 0.007309f, 0.008377f, 0.010635f, 0.012352f, 0.014153f,
+ 0.015640f, 0.017487f, 0.019272f, 0.021164f, 0.023026f, 0.025314f, 0.027222f, 0.029282f, 0.031433f, 0.033600f, 0.036041f, 0.038788f,
+ 0.041626f, 0.044281f, 0.047455f, 0.050507f, 0.054047f, 0.057556f, 0.061188f, 0.065063f, 0.069214f, 0.073486f, 0.078369f, 0.083191f,
+ 0.088196f, 0.093811f, 0.099609f, 0.106018f, 0.112305f, 0.119385f, 0.126343f, 0.134033f, 0.142090f, 0.150635f, 0.159546f, 0.168579f,
+ 0.177734f, 0.187500f, 0.198242f, 0.208618f, 0.219604f, 0.231812f, 0.242188f, 0.254883f, 0.267578f, 0.281494f, 0.294434f, 0.308350f,
+ 0.322998f, 0.338379f, 0.651367f, 0.676758f, 0.681152f, 0.680664f, 0.680664f, 0.679688f, 0.000977f, 0.002806f, 0.004559f, 0.006176f,
+ 0.008034f, 0.009476f, 0.011131f, 0.012741f, 0.014275f, 0.015732f, 0.017334f, 0.019104f, 0.020767f, 0.022293f, 0.024323f, 0.026016f,
+ 0.028198f, 0.030197f, 0.032257f, 0.034515f, 0.036957f, 0.039856f, 0.042084f, 0.044891f, 0.047791f, 0.051147f, 0.054535f, 0.058197f,
+ 0.061768f, 0.065674f, 0.069946f, 0.074585f, 0.079102f, 0.084412f, 0.089600f, 0.095398f, 0.101196f, 0.107544f, 0.114258f, 0.121094f,
+ 0.128662f, 0.137085f, 0.145020f, 0.153687f, 0.162720f, 0.172607f, 0.182129f, 0.192749f, 0.203125f, 0.214111f, 0.226074f, 0.237671f,
+ 0.249878f, 0.262207f, 0.275635f, 0.289551f, 0.304199f, 0.318848f, 0.639160f, 0.666992f, 0.671387f, 0.671875f, 0.671875f, 0.671387f,
+ 0.000968f, 0.002722f, 0.004318f, 0.005634f, 0.007393f, 0.008667f, 0.010139f, 0.011383f, 0.012856f, 0.014389f, 0.015427f, 0.016907f,
+ 0.018387f, 0.020081f, 0.021683f, 0.023315f, 0.025085f, 0.026840f, 0.028641f, 0.030624f, 0.032837f, 0.035065f, 0.037445f, 0.039948f,
+ 0.042542f, 0.045410f, 0.048340f, 0.051514f, 0.054840f, 0.058502f, 0.062408f, 0.066223f, 0.070679f, 0.075134f, 0.080078f, 0.085388f,
+ 0.090515f, 0.096436f, 0.102722f, 0.109314f, 0.116333f, 0.123352f, 0.131592f, 0.139526f, 0.147949f, 0.156860f, 0.166748f, 0.176758f,
+ 0.187134f, 0.197632f, 0.209106f, 0.220337f, 0.232666f, 0.244751f, 0.257568f, 0.270996f, 0.284912f, 0.300537f, 0.627441f, 0.657227f,
+ 0.662598f, 0.663574f, 0.663574f, 0.663086f, 0.001081f, 0.002466f, 0.003862f, 0.005348f, 0.006447f, 0.007927f, 0.009018f, 0.010490f,
+ 0.011436f, 0.012627f, 0.013916f, 0.015015f, 0.016449f, 0.017563f, 0.019165f, 0.020706f, 0.021973f, 0.023834f, 0.025467f, 0.027130f,
+ 0.029175f, 0.030991f, 0.033081f, 0.035156f, 0.037384f, 0.040039f, 0.042603f, 0.045502f, 0.048492f, 0.051636f, 0.054962f, 0.058716f,
+ 0.062439f, 0.066467f, 0.071045f, 0.075378f, 0.080811f, 0.085815f, 0.091492f, 0.098022f, 0.103943f, 0.111023f, 0.118164f, 0.125732f,
+ 0.133911f, 0.142456f, 0.151367f, 0.161011f, 0.170898f, 0.181396f, 0.192139f, 0.203247f, 0.214844f, 0.227173f, 0.239380f, 0.252441f,
+ 0.266602f, 0.281006f, 0.616699f, 0.647949f, 0.653320f, 0.655273f, 0.654785f, 0.655273f, 0.000735f, 0.002331f, 0.003601f, 0.005005f,
+ 0.005825f, 0.007061f, 0.008049f, 0.009148f, 0.010315f, 0.011131f, 0.012230f, 0.013367f, 0.014328f, 0.015541f, 0.016968f, 0.018234f,
+ 0.019257f, 0.020798f, 0.022202f, 0.023666f, 0.025452f, 0.027115f, 0.028885f, 0.030792f, 0.032715f, 0.035034f, 0.037323f, 0.039825f,
+ 0.042419f, 0.045258f, 0.048157f, 0.051422f, 0.054810f, 0.058411f, 0.062378f, 0.066528f, 0.071106f, 0.076233f, 0.081116f, 0.086853f,
+ 0.092407f, 0.098938f, 0.105469f, 0.112854f, 0.120361f, 0.128418f, 0.136841f, 0.145752f, 0.155273f, 0.165283f, 0.175537f, 0.186646f,
+ 0.197510f, 0.209473f, 0.221558f, 0.234619f, 0.248047f, 0.261719f, 0.603516f, 0.636719f, 0.644531f, 0.645020f, 0.645508f, 0.646484f,
+ 0.000837f, 0.002073f, 0.003357f, 0.004292f, 0.005409f, 0.006271f, 0.007271f, 0.007973f, 0.008873f, 0.009956f, 0.010811f, 0.012032f,
+ 0.012848f, 0.013664f, 0.014870f, 0.015839f, 0.017090f, 0.018280f, 0.019333f, 0.020691f, 0.022186f, 0.023453f, 0.025223f, 0.026779f,
+ 0.028595f, 0.030441f, 0.032410f, 0.034729f, 0.036743f, 0.039307f, 0.042023f, 0.044434f, 0.047791f, 0.050781f, 0.054413f, 0.058075f,
+ 0.061951f, 0.066711f, 0.071106f, 0.076355f, 0.081848f, 0.087341f, 0.093872f, 0.099854f, 0.107483f, 0.114441f, 0.122925f, 0.131104f,
+ 0.140381f, 0.149414f, 0.159180f, 0.170166f, 0.181152f, 0.192139f, 0.204468f, 0.216553f, 0.230103f, 0.244507f, 0.592773f, 0.626953f,
+ 0.635254f, 0.637207f, 0.636719f, 0.637695f, 0.000524f, 0.001863f, 0.003014f, 0.003777f, 0.004852f, 0.005516f, 0.006428f, 0.007111f,
+ 0.008095f, 0.008888f, 0.009476f, 0.010345f, 0.011063f, 0.012016f, 0.012810f, 0.013786f, 0.014648f, 0.015717f, 0.016891f, 0.017929f,
+ 0.019150f, 0.020401f, 0.021606f, 0.023193f, 0.024597f, 0.026276f, 0.027939f, 0.029770f, 0.031738f, 0.033936f, 0.036194f, 0.038574f,
+ 0.041107f, 0.043945f, 0.047180f, 0.050385f, 0.054291f, 0.057770f, 0.061981f, 0.066345f, 0.071167f, 0.076355f, 0.082153f, 0.088074f,
+ 0.094666f, 0.101685f, 0.109131f, 0.117249f, 0.125610f, 0.134399f, 0.143921f, 0.154175f, 0.164795f, 0.175659f, 0.187256f, 0.199341f,
+ 0.211670f, 0.225464f, 0.580078f, 0.617676f, 0.625000f, 0.627930f, 0.628906f, 0.628906f, 0.000657f, 0.001829f, 0.002909f, 0.003525f,
+ 0.004295f, 0.005051f, 0.005592f, 0.006123f, 0.006920f, 0.007553f, 0.008339f, 0.008888f, 0.009689f, 0.010262f, 0.011017f, 0.011848f,
+ 0.012634f, 0.013489f, 0.014572f, 0.015427f, 0.016449f, 0.017426f, 0.018539f, 0.019852f, 0.021133f, 0.022507f, 0.023834f, 0.025375f,
+ 0.027084f, 0.028976f, 0.030792f, 0.032959f, 0.035400f, 0.037720f, 0.040405f, 0.043243f, 0.046356f, 0.049530f, 0.053314f, 0.057190f,
+ 0.061554f, 0.066223f, 0.071472f, 0.076782f, 0.082825f, 0.089417f, 0.096191f, 0.103210f, 0.111633f, 0.119934f, 0.128662f, 0.138550f,
+ 0.148315f, 0.158813f, 0.170288f, 0.182373f, 0.194458f, 0.207642f, 0.567383f, 0.606445f, 0.615234f, 0.619141f, 0.620117f, 0.620117f,
+ 0.000584f, 0.001548f, 0.002333f, 0.003086f, 0.003660f, 0.004303f, 0.005020f, 0.005543f, 0.006042f, 0.006538f, 0.007118f, 0.007641f,
+ 0.008301f, 0.008919f, 0.009499f, 0.010147f, 0.010918f, 0.011414f, 0.012222f, 0.013084f, 0.013901f, 0.014954f, 0.015671f, 0.016724f,
+ 0.017914f, 0.019012f, 0.020325f, 0.021698f, 0.022949f, 0.024445f, 0.026215f, 0.027954f, 0.029755f, 0.032043f, 0.034210f, 0.036591f,
+ 0.039215f, 0.042297f, 0.045441f, 0.048676f, 0.052612f, 0.056580f, 0.061432f, 0.066040f, 0.071350f, 0.077332f, 0.083496f, 0.090393f,
+ 0.097717f, 0.105835f, 0.114380f, 0.123413f, 0.133301f, 0.143066f, 0.153931f, 0.165039f, 0.177124f, 0.190308f, 0.555176f, 0.597656f,
+ 0.604980f, 0.609375f, 0.609863f, 0.611328f, 0.000438f, 0.001456f, 0.001925f, 0.002811f, 0.003246f, 0.003731f, 0.004108f, 0.004669f,
+ 0.005344f, 0.005535f, 0.005913f, 0.006641f, 0.007038f, 0.007473f, 0.008049f, 0.008675f, 0.009361f, 0.009689f, 0.010513f, 0.011032f,
+ 0.011894f, 0.012695f, 0.013390f, 0.014183f, 0.015114f, 0.016037f, 0.016998f, 0.018280f, 0.019272f, 0.020645f, 0.022003f, 0.023361f,
+ 0.024796f, 0.026779f, 0.028656f, 0.030685f, 0.032928f, 0.035370f, 0.038147f, 0.040955f, 0.044403f, 0.047821f, 0.052032f, 0.056183f,
+ 0.060974f, 0.066162f, 0.071777f, 0.078125f, 0.084656f, 0.092102f, 0.100159f, 0.109009f, 0.117981f, 0.127563f, 0.138306f, 0.148804f,
+ 0.160645f, 0.173218f, 0.542969f, 0.586914f, 0.594727f, 0.599609f, 0.601074f, 0.601074f, 0.000520f, 0.001104f, 0.001921f, 0.002256f,
+ 0.002886f, 0.003389f, 0.003689f, 0.004063f, 0.004440f, 0.004829f, 0.005230f, 0.005466f, 0.005966f, 0.006332f, 0.006786f, 0.007347f,
+ 0.007835f, 0.008232f, 0.008812f, 0.009216f, 0.009865f, 0.010490f, 0.011124f, 0.011803f, 0.012573f, 0.013390f, 0.014275f, 0.015121f,
+ 0.016144f, 0.016953f, 0.018234f, 0.019257f, 0.020782f, 0.022064f, 0.023743f, 0.025360f, 0.027176f, 0.029327f, 0.031616f, 0.034058f,
+ 0.036957f, 0.039917f, 0.043182f, 0.047272f, 0.051025f, 0.055695f, 0.060913f, 0.066345f, 0.072693f, 0.079285f, 0.086548f, 0.094543f,
+ 0.103271f, 0.112793f, 0.122864f, 0.132812f, 0.144531f, 0.156616f, 0.530273f, 0.576660f, 0.585449f, 0.590332f, 0.592285f, 0.593262f,
+ 0.000366f, 0.001040f, 0.001583f, 0.002129f, 0.002522f, 0.002792f, 0.003012f, 0.003420f, 0.003630f, 0.003967f, 0.004246f, 0.004623f,
+ 0.005039f, 0.005253f, 0.005627f, 0.006096f, 0.006447f, 0.006939f, 0.007179f, 0.007710f, 0.008324f, 0.008698f, 0.009247f, 0.009796f,
+ 0.010414f, 0.011063f, 0.011627f, 0.012543f, 0.013191f, 0.014099f, 0.014938f, 0.015930f, 0.016983f, 0.018219f, 0.019440f, 0.020813f,
+ 0.022324f, 0.024002f, 0.025818f, 0.027969f, 0.030289f, 0.032898f, 0.035583f, 0.038727f, 0.042450f, 0.046234f, 0.050781f, 0.055695f,
+ 0.061157f, 0.067383f, 0.074158f, 0.081360f, 0.089478f, 0.098267f, 0.107788f, 0.117737f, 0.129028f, 0.140503f, 0.517578f, 0.566406f,
+ 0.575195f, 0.581055f, 0.582520f, 0.584473f, 0.000482f, 0.001008f, 0.001481f, 0.001818f, 0.002001f, 0.002296f, 0.002569f, 0.002781f,
+ 0.002998f, 0.003319f, 0.003620f, 0.003828f, 0.004082f, 0.004364f, 0.004658f, 0.004978f, 0.005257f, 0.005665f, 0.005993f, 0.006340f,
+ 0.006725f, 0.007160f, 0.007576f, 0.008095f, 0.008522f, 0.008980f, 0.009621f, 0.010170f, 0.010765f, 0.011543f, 0.012161f, 0.013023f,
+ 0.013840f, 0.014801f, 0.015869f, 0.016861f, 0.018127f, 0.019379f, 0.020859f, 0.022583f, 0.024261f, 0.026596f, 0.028839f, 0.031555f,
+ 0.034271f, 0.037628f, 0.041504f, 0.045837f, 0.050598f, 0.056000f, 0.062134f, 0.068726f, 0.076172f, 0.084656f, 0.093567f, 0.103088f,
+ 0.113586f, 0.125000f, 0.504883f, 0.554688f, 0.565918f, 0.570801f, 0.573242f, 0.574219f, 0.000400f, 0.000803f, 0.001046f, 0.001427f,
+ 0.001657f, 0.001952f, 0.002033f, 0.002337f, 0.002453f, 0.002678f, 0.002871f, 0.003120f, 0.003286f, 0.003605f, 0.003817f, 0.004036f,
+ 0.004299f, 0.004604f, 0.004848f, 0.005142f, 0.005428f, 0.005871f, 0.006107f, 0.006584f, 0.006908f, 0.007332f, 0.007736f, 0.008186f,
+ 0.008820f, 0.009308f, 0.009964f, 0.010422f, 0.011200f, 0.011993f, 0.012726f, 0.013512f, 0.014511f, 0.015610f, 0.016724f, 0.017914f,
+ 0.019440f, 0.021057f, 0.022827f, 0.024933f, 0.027466f, 0.030197f, 0.033295f, 0.036896f, 0.041077f, 0.045776f, 0.050995f, 0.056976f,
+ 0.063721f, 0.071167f, 0.079773f, 0.089172f, 0.098633f, 0.109314f, 0.491699f, 0.543457f, 0.555176f, 0.561035f, 0.563477f, 0.565430f,
+ 0.000279f, 0.000821f, 0.000974f, 0.001161f, 0.001382f, 0.001583f, 0.001670f, 0.001934f, 0.002064f, 0.002153f, 0.002306f, 0.002544f,
+ 0.002670f, 0.002909f, 0.003052f, 0.003288f, 0.003429f, 0.003624f, 0.003893f, 0.004082f, 0.004406f, 0.004635f, 0.004925f, 0.005196f,
+ 0.005444f, 0.005764f, 0.006134f, 0.006546f, 0.006947f, 0.007343f, 0.007858f, 0.008270f, 0.008858f, 0.009346f, 0.010010f, 0.010757f,
+ 0.011475f, 0.012260f, 0.013206f, 0.014214f, 0.015236f, 0.016479f, 0.017975f, 0.019623f, 0.021515f, 0.023590f, 0.026062f, 0.028976f,
+ 0.032471f, 0.036224f, 0.040833f, 0.046082f, 0.052094f, 0.059052f, 0.066650f, 0.075684f, 0.084778f, 0.094971f, 0.479492f, 0.532715f,
+ 0.545898f, 0.551270f, 0.553711f, 0.555664f, 0.000253f, 0.000612f, 0.000835f, 0.000998f, 0.001111f, 0.001228f, 0.001334f, 0.001452f,
+ 0.001619f, 0.001757f, 0.001837f, 0.001920f, 0.002140f, 0.002321f, 0.002453f, 0.002544f, 0.002670f, 0.002790f, 0.003086f, 0.003260f,
+ 0.003422f, 0.003620f, 0.003893f, 0.004101f, 0.004326f, 0.004528f, 0.004761f, 0.005051f, 0.005444f, 0.005756f, 0.006065f, 0.006435f,
+ 0.006882f, 0.007378f, 0.007763f, 0.008286f, 0.008865f, 0.009506f, 0.010162f, 0.011024f, 0.011826f, 0.012917f, 0.013916f, 0.015175f,
+ 0.016602f, 0.018204f, 0.020035f, 0.022293f, 0.024948f, 0.028076f, 0.031921f, 0.036377f, 0.041565f, 0.047577f, 0.054535f, 0.062622f,
+ 0.071777f, 0.081787f, 0.465576f, 0.522461f, 0.535645f, 0.541992f, 0.544922f, 0.546875f, 0.000155f, 0.000398f, 0.000680f, 0.000828f,
+ 0.000907f, 0.000989f, 0.001113f, 0.001081f, 0.001253f, 0.001350f, 0.001453f, 0.001573f, 0.001661f, 0.001777f, 0.001829f, 0.001978f,
+ 0.002062f, 0.002216f, 0.002346f, 0.002470f, 0.002644f, 0.002804f, 0.002930f, 0.003134f, 0.003265f, 0.003485f, 0.003674f, 0.003866f,
+ 0.004154f, 0.004333f, 0.004707f, 0.004910f, 0.005180f, 0.005581f, 0.005875f, 0.006283f, 0.006729f, 0.007164f, 0.007713f, 0.008270f,
+ 0.008934f, 0.009727f, 0.010513f, 0.011482f, 0.012520f, 0.013710f, 0.015152f, 0.016815f, 0.018799f, 0.021118f, 0.024048f, 0.027756f,
+ 0.032104f, 0.037201f, 0.043518f, 0.050903f, 0.059418f, 0.068420f, 0.453125f, 0.511719f, 0.525391f, 0.530762f, 0.535156f, 0.536621f,
+ 0.000303f, 0.000337f, 0.000498f, 0.000560f, 0.000603f, 0.000721f, 0.000782f, 0.000845f, 0.000880f, 0.000988f, 0.001119f, 0.001184f,
+ 0.001258f, 0.001377f, 0.001420f, 0.001446f, 0.001590f, 0.001666f, 0.001754f, 0.001889f, 0.001980f, 0.002073f, 0.002216f, 0.002308f,
+ 0.002447f, 0.002562f, 0.002758f, 0.002899f, 0.003084f, 0.003328f, 0.003506f, 0.003641f, 0.003922f, 0.004147f, 0.004391f, 0.004665f,
+ 0.004959f, 0.005322f, 0.005695f, 0.006119f, 0.006588f, 0.007072f, 0.007790f, 0.008392f, 0.009178f, 0.010056f, 0.011124f, 0.012383f,
+ 0.013832f, 0.015587f, 0.017685f, 0.020309f, 0.023926f, 0.028076f, 0.033447f, 0.039978f, 0.047638f, 0.056335f, 0.440186f, 0.500000f,
+ 0.514160f, 0.520996f, 0.524414f, 0.526855f, 0.000132f, 0.000296f, 0.000368f, 0.000444f, 0.000501f, 0.000519f, 0.000631f, 0.000580f,
+ 0.000675f, 0.000735f, 0.000820f, 0.000840f, 0.000882f, 0.000946f, 0.001029f, 0.001070f, 0.001164f, 0.001221f, 0.001286f, 0.001317f,
+ 0.001416f, 0.001494f, 0.001607f, 0.001681f, 0.001763f, 0.001863f, 0.001978f, 0.002069f, 0.002169f, 0.002348f, 0.002451f, 0.002661f,
+ 0.002754f, 0.002943f, 0.003130f, 0.003323f, 0.003553f, 0.003813f, 0.004124f, 0.004364f, 0.004669f, 0.005062f, 0.005493f, 0.005985f,
+ 0.006546f, 0.007172f, 0.007950f, 0.008850f, 0.009857f, 0.011116f, 0.012695f, 0.014603f, 0.016983f, 0.020157f, 0.024490f, 0.029968f,
+ 0.036957f, 0.045166f, 0.426025f, 0.488770f, 0.503906f, 0.511719f, 0.515137f, 0.517578f, 0.000063f, 0.000160f, 0.000267f, 0.000282f,
+ 0.000339f, 0.000417f, 0.000377f, 0.000433f, 0.000472f, 0.000570f, 0.000563f, 0.000578f, 0.000599f, 0.000663f, 0.000681f, 0.000759f,
+ 0.000760f, 0.000845f, 0.000910f, 0.000941f, 0.000997f, 0.001057f, 0.001110f, 0.001169f, 0.001238f, 0.001288f, 0.001381f, 0.001441f,
+ 0.001514f, 0.001655f, 0.001693f, 0.001815f, 0.001910f, 0.002028f, 0.002153f, 0.002308f, 0.002441f, 0.002607f, 0.002783f, 0.002962f,
+ 0.003214f, 0.003458f, 0.003744f, 0.004051f, 0.004444f, 0.004883f, 0.005402f, 0.006031f, 0.006699f, 0.007610f, 0.008766f, 0.009933f,
+ 0.011688f, 0.013931f, 0.017075f, 0.021454f, 0.027313f, 0.035004f, 0.414307f, 0.478271f, 0.493652f, 0.501465f, 0.505859f, 0.508301f,
+ 0.000120f, 0.000194f, 0.000194f, 0.000205f, 0.000245f, 0.000246f, 0.000251f, 0.000301f, 0.000322f, 0.000332f, 0.000343f, 0.000413f,
+ 0.000397f, 0.000448f, 0.000481f, 0.000494f, 0.000545f, 0.000556f, 0.000582f, 0.000601f, 0.000653f, 0.000676f, 0.000726f, 0.000767f,
+ 0.000821f, 0.000840f, 0.000919f, 0.000952f, 0.001011f, 0.001054f, 0.001116f, 0.001186f, 0.001263f, 0.001337f, 0.001418f, 0.001482f,
+ 0.001607f, 0.001685f, 0.001842f, 0.001965f, 0.002090f, 0.002235f, 0.002420f, 0.002613f, 0.002851f, 0.003159f, 0.003492f, 0.003887f,
+ 0.004345f, 0.004906f, 0.005600f, 0.006474f, 0.007645f, 0.009186f, 0.011230f, 0.014305f, 0.019135f, 0.025848f, 0.400635f, 0.466797f,
+ 0.483398f, 0.490967f, 0.495117f, 0.498047f, 0.000030f, 0.000140f, 0.000121f, 0.000114f, 0.000147f, 0.000178f, 0.000159f, 0.000195f,
+ 0.000199f, 0.000204f, 0.000216f, 0.000223f, 0.000255f, 0.000271f, 0.000288f, 0.000302f, 0.000314f, 0.000346f, 0.000357f, 0.000395f,
+ 0.000397f, 0.000408f, 0.000436f, 0.000470f, 0.000501f, 0.000542f, 0.000547f, 0.000566f, 0.000612f, 0.000641f, 0.000692f, 0.000722f,
+ 0.000767f, 0.000798f, 0.000861f, 0.000898f, 0.000963f, 0.001030f, 0.001107f, 0.001164f, 0.001255f, 0.001361f, 0.001464f, 0.001591f,
+ 0.001719f, 0.001871f, 0.002111f, 0.002312f, 0.002617f, 0.002964f, 0.003368f, 0.003902f, 0.004654f, 0.005653f, 0.006958f, 0.008888f,
+ 0.012161f, 0.017822f, 0.388672f, 0.456543f, 0.473389f, 0.481201f, 0.486328f, 0.489014f, 0.000102f, 0.000076f, 0.000076f, 0.000075f,
+ 0.000095f, 0.000092f, 0.000109f, 0.000111f, 0.000112f, 0.000113f, 0.000126f, 0.000147f, 0.000135f, 0.000144f, 0.000165f, 0.000161f,
+ 0.000179f, 0.000192f, 0.000198f, 0.000202f, 0.000224f, 0.000232f, 0.000248f, 0.000259f, 0.000278f, 0.000295f, 0.000308f, 0.000320f,
+ 0.000340f, 0.000353f, 0.000379f, 0.000402f, 0.000423f, 0.000440f, 0.000472f, 0.000503f, 0.000526f, 0.000564f, 0.000610f, 0.000644f,
+ 0.000690f, 0.000741f, 0.000810f, 0.000862f, 0.000946f, 0.001024f, 0.001121f, 0.001247f, 0.001407f, 0.001603f, 0.001822f, 0.002144f,
+ 0.002539f, 0.003098f, 0.003901f, 0.005096f, 0.006931f, 0.011024f, 0.375244f, 0.444092f, 0.462158f, 0.470215f, 0.475586f, 0.478760f,
+ 0.000085f, 0.000061f, 0.000052f, 0.000047f, 0.000049f, 0.000046f, 0.000047f, 0.000050f, 0.000055f, 0.000069f, 0.000060f, 0.000062f,
+ 0.000077f, 0.000066f, 0.000069f, 0.000075f, 0.000084f, 0.000093f, 0.000093f, 0.000098f, 0.000102f, 0.000108f, 0.000111f, 0.000121f,
+ 0.000129f, 0.000136f, 0.000142f, 0.000154f, 0.000162f, 0.000172f, 0.000182f, 0.000187f, 0.000197f, 0.000209f, 0.000225f, 0.000231f,
+ 0.000246f, 0.000262f, 0.000290f, 0.000306f, 0.000321f, 0.000349f, 0.000380f, 0.000402f, 0.000437f, 0.000480f, 0.000525f, 0.000579f,
+ 0.000649f, 0.000735f, 0.000842f, 0.000984f, 0.001173f, 0.001451f, 0.001855f, 0.002485f, 0.003542f, 0.005753f, 0.362305f, 0.434326f,
+ 0.451904f, 0.460693f, 0.465576f, 0.468506f, 0.000064f, 0.000044f, 0.000036f, 0.000032f, 0.000029f, 0.000027f, 0.000025f, 0.000024f,
+ 0.000022f, 0.000023f, 0.000021f, 0.000027f, 0.000023f, 0.000022f, 0.000028f, 0.000031f, 0.000030f, 0.000034f, 0.000036f, 0.000038f,
+ 0.000040f, 0.000045f, 0.000048f, 0.000042f, 0.000047f, 0.000053f, 0.000055f, 0.000054f, 0.000060f, 0.000062f, 0.000065f, 0.000072f,
+ 0.000078f, 0.000075f, 0.000079f, 0.000087f, 0.000093f, 0.000098f, 0.000106f, 0.000113f, 0.000121f, 0.000126f, 0.000136f, 0.000150f,
+ 0.000159f, 0.000173f, 0.000190f, 0.000209f, 0.000235f, 0.000265f, 0.000302f, 0.000343f, 0.000416f, 0.000515f, 0.000665f, 0.000917f,
+ 0.001396f, 0.002401f, 0.349854f, 0.421875f, 0.440918f, 0.449951f, 0.455811f, 0.458008f, 0.000030f, 0.000020f, 0.000016f, 0.000014f,
+ 0.000014f, 0.000013f, 0.000012f, 0.000012f, 0.000011f, 0.000011f, 0.000011f, 0.000011f, 0.000010f, 0.000010f, 0.000009f, 0.000009f,
+ 0.000009f, 0.000008f, 0.000008f, 0.000008f, 0.000007f, 0.000007f, 0.000008f, 0.000008f, 0.000009f, 0.000011f, 0.000011f, 0.000013f,
+ 0.000013f, 0.000012f, 0.000013f, 0.000014f, 0.000016f, 0.000018f, 0.000018f, 0.000019f, 0.000021f, 0.000021f, 0.000023f, 0.000027f,
+ 0.000025f, 0.000028f, 0.000031f, 0.000032f, 0.000033f, 0.000038f, 0.000043f, 0.000046f, 0.000050f, 0.000055f, 0.000062f, 0.000074f,
+ 0.000088f, 0.000106f, 0.000138f, 0.000191f, 0.000312f, 0.000653f, 0.337402f, 0.410645f, 0.431152f, 0.438965f, 0.445068f, 0.448975f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f,
+ 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000001f, 0.000001f, 0.000001f,
+ 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000002f, 0.000002f,
+ 0.000002f, 0.000002f, 0.000003f, 0.000003f, 0.000004f, 0.000004f, 0.000004f, 0.000006f, 0.000010f, 0.000026f, 0.324219f, 0.399902f,
+ 0.419922f, 0.429688f, 0.435059f, 0.438965f,
+ },
+ {
+ 0.010521f, 0.032043f, 0.054443f, 0.076843f, 0.098572f, 0.121216f, 0.142700f, 0.164062f, 0.185913f, 0.207275f, 0.229004f, 0.249268f,
+ 0.270508f, 0.290527f, 0.311035f, 0.331055f, 0.350586f, 0.370361f, 0.389648f, 0.408936f, 0.428223f, 0.446533f, 0.465088f, 0.482666f,
+ 0.500977f, 0.519043f, 0.536133f, 0.553223f, 0.570801f, 0.587891f, 0.604980f, 0.621582f, 0.637207f, 0.653320f, 0.668945f, 0.685547f,
+ 0.700684f, 0.716309f, 0.730957f, 0.745605f, 0.760254f, 0.774902f, 0.789551f, 0.803711f, 0.816895f, 0.831543f, 0.845703f, 0.858887f,
+ 0.871582f, 0.885254f, 0.897949f, 0.910645f, 0.923340f, 0.936035f, 0.948242f, 0.959961f, 0.972168f, 0.984375f, 0.972656f, 0.936035f,
+ 0.910645f, 0.890137f, 0.872070f, 0.855957f, 0.010048f, 0.030350f, 0.051392f, 0.072266f, 0.093506f, 0.114319f, 0.135620f, 0.155273f,
+ 0.177124f, 0.197144f, 0.217773f, 0.237915f, 0.257568f, 0.277588f, 0.298096f, 0.316895f, 0.336182f, 0.355225f, 0.374268f, 0.393311f,
+ 0.411865f, 0.430176f, 0.448486f, 0.466309f, 0.483398f, 0.501465f, 0.519043f, 0.535645f, 0.552734f, 0.570312f, 0.586426f, 0.602539f,
+ 0.618652f, 0.635254f, 0.650879f, 0.666016f, 0.682129f, 0.697266f, 0.712402f, 0.727539f, 0.741699f, 0.756836f, 0.770996f, 0.785645f,
+ 0.799805f, 0.812988f, 0.826660f, 0.840332f, 0.854004f, 0.867676f, 0.881348f, 0.893066f, 0.907715f, 0.919434f, 0.932617f, 0.943848f,
+ 0.955566f, 0.968262f, 0.965332f, 0.930664f, 0.906738f, 0.886719f, 0.869629f, 0.854004f, 0.009254f, 0.028961f, 0.048615f, 0.068054f,
+ 0.088562f, 0.108093f, 0.128540f, 0.147705f, 0.167236f, 0.188599f, 0.207886f, 0.227295f, 0.244873f, 0.265625f, 0.284668f, 0.303955f,
+ 0.322510f, 0.340820f, 0.358887f, 0.378662f, 0.396484f, 0.414307f, 0.431885f, 0.448975f, 0.466797f, 0.484619f, 0.500977f, 0.519043f,
+ 0.535645f, 0.551758f, 0.568359f, 0.584961f, 0.600586f, 0.616699f, 0.632324f, 0.647949f, 0.663086f, 0.678223f, 0.693848f, 0.708984f,
+ 0.723633f, 0.738281f, 0.752930f, 0.767578f, 0.780762f, 0.794922f, 0.809082f, 0.822754f, 0.835938f, 0.849609f, 0.863770f, 0.875488f,
+ 0.888672f, 0.902344f, 0.915527f, 0.927246f, 0.939453f, 0.952637f, 0.958008f, 0.925293f, 0.901855f, 0.882812f, 0.866211f, 0.851562f,
+ 0.008736f, 0.027039f, 0.045807f, 0.064514f, 0.083801f, 0.102844f, 0.121826f, 0.140869f, 0.159302f, 0.179077f, 0.197388f, 0.216064f,
+ 0.234741f, 0.253662f, 0.271729f, 0.290283f, 0.308350f, 0.327148f, 0.344238f, 0.362061f, 0.381836f, 0.398926f, 0.416016f, 0.432373f,
+ 0.450195f, 0.466797f, 0.484375f, 0.500977f, 0.517090f, 0.533691f, 0.550781f, 0.567871f, 0.582031f, 0.598145f, 0.613770f, 0.629395f,
+ 0.645020f, 0.659668f, 0.675781f, 0.689941f, 0.705566f, 0.719727f, 0.734375f, 0.749512f, 0.763184f, 0.776855f, 0.791016f, 0.804688f,
+ 0.818848f, 0.832031f, 0.845215f, 0.858398f, 0.872559f, 0.884766f, 0.897949f, 0.909668f, 0.922852f, 0.936035f, 0.950684f, 0.919434f,
+ 0.896973f, 0.878906f, 0.862793f, 0.848633f, 0.008339f, 0.025543f, 0.043427f, 0.060974f, 0.078979f, 0.097168f, 0.115051f, 0.133179f,
+ 0.151367f, 0.169678f, 0.187988f, 0.206055f, 0.223999f, 0.241821f, 0.260742f, 0.277832f, 0.295166f, 0.313232f, 0.331299f, 0.347412f,
+ 0.365479f, 0.383057f, 0.399902f, 0.416992f, 0.433350f, 0.450195f, 0.467773f, 0.484863f, 0.499756f, 0.515625f, 0.532715f, 0.548340f,
+ 0.564941f, 0.580566f, 0.596191f, 0.610840f, 0.626953f, 0.641602f, 0.656738f, 0.671875f, 0.686035f, 0.701660f, 0.714844f, 0.730469f,
+ 0.745117f, 0.759766f, 0.772461f, 0.786621f, 0.801270f, 0.814453f, 0.827637f, 0.841309f, 0.854004f, 0.867676f, 0.880859f, 0.893555f,
+ 0.907227f, 0.919434f, 0.943359f, 0.913086f, 0.891602f, 0.874512f, 0.858887f, 0.845703f, 0.008102f, 0.024002f, 0.040802f, 0.057098f,
+ 0.074768f, 0.091553f, 0.108826f, 0.126343f, 0.143921f, 0.161377f, 0.179077f, 0.195923f, 0.213745f, 0.230835f, 0.248047f, 0.265869f,
+ 0.282227f, 0.299561f, 0.316895f, 0.334473f, 0.350586f, 0.367920f, 0.384277f, 0.400391f, 0.417725f, 0.434326f, 0.450195f, 0.467285f,
+ 0.482910f, 0.498291f, 0.514648f, 0.530762f, 0.546387f, 0.561523f, 0.577637f, 0.593262f, 0.608398f, 0.623535f, 0.637695f, 0.654297f,
+ 0.668457f, 0.682617f, 0.698242f, 0.711914f, 0.727051f, 0.741211f, 0.754395f, 0.768066f, 0.782715f, 0.796387f, 0.810547f, 0.823730f,
+ 0.836426f, 0.849609f, 0.863770f, 0.876465f, 0.889648f, 0.902344f, 0.934570f, 0.907715f, 0.887207f, 0.870117f, 0.854980f, 0.842285f,
+ 0.007504f, 0.022812f, 0.038727f, 0.054871f, 0.070312f, 0.087097f, 0.103088f, 0.119446f, 0.136475f, 0.153442f, 0.169556f, 0.186523f,
+ 0.203369f, 0.219971f, 0.236450f, 0.253418f, 0.270264f, 0.287109f, 0.302979f, 0.319824f, 0.336182f, 0.353271f, 0.369141f, 0.386230f,
+ 0.402100f, 0.417725f, 0.433594f, 0.450684f, 0.466553f, 0.482178f, 0.498047f, 0.513184f, 0.528809f, 0.543945f, 0.559082f, 0.575195f,
+ 0.589844f, 0.605469f, 0.621094f, 0.634277f, 0.649414f, 0.665039f, 0.679688f, 0.694824f, 0.708496f, 0.722168f, 0.736816f, 0.750000f,
+ 0.763184f, 0.778809f, 0.791504f, 0.805664f, 0.819336f, 0.832520f, 0.845703f, 0.858887f, 0.872070f, 0.885742f, 0.927246f, 0.900879f,
+ 0.881836f, 0.864746f, 0.851074f, 0.838867f, 0.006836f, 0.021683f, 0.036224f, 0.051666f, 0.066772f, 0.081970f, 0.098022f, 0.113831f,
+ 0.129517f, 0.145264f, 0.161011f, 0.177856f, 0.193359f, 0.209106f, 0.226196f, 0.241821f, 0.257812f, 0.274414f, 0.290283f, 0.306641f,
+ 0.322754f, 0.338623f, 0.354492f, 0.370361f, 0.386230f, 0.402100f, 0.417725f, 0.433838f, 0.449463f, 0.465088f, 0.480469f, 0.495605f,
+ 0.511719f, 0.527344f, 0.541016f, 0.556641f, 0.571777f, 0.587402f, 0.601562f, 0.617676f, 0.631836f, 0.646484f, 0.660645f, 0.674805f,
+ 0.689941f, 0.704102f, 0.718262f, 0.731934f, 0.746582f, 0.760254f, 0.774414f, 0.786621f, 0.801758f, 0.815430f, 0.828125f, 0.842285f,
+ 0.854980f, 0.868652f, 0.918457f, 0.894531f, 0.875977f, 0.859863f, 0.846680f, 0.834961f, 0.006672f, 0.020401f, 0.034088f, 0.048462f,
+ 0.062927f, 0.077820f, 0.092529f, 0.107666f, 0.122803f, 0.137695f, 0.152954f, 0.169067f, 0.183716f, 0.199829f, 0.214722f, 0.230347f,
+ 0.246704f, 0.262207f, 0.277832f, 0.292969f, 0.308105f, 0.324219f, 0.339600f, 0.354492f, 0.371094f, 0.386963f, 0.401855f, 0.418457f,
+ 0.432861f, 0.449219f, 0.463379f, 0.478271f, 0.494385f, 0.508301f, 0.523438f, 0.539551f, 0.553711f, 0.568848f, 0.583984f, 0.598633f,
+ 0.612793f, 0.627441f, 0.642578f, 0.656250f, 0.670898f, 0.685547f, 0.698730f, 0.714355f, 0.728027f, 0.742188f, 0.755859f, 0.769531f,
+ 0.783691f, 0.795898f, 0.810059f, 0.824707f, 0.838379f, 0.850586f, 0.910645f, 0.887695f, 0.870117f, 0.854980f, 0.842285f, 0.831055f,
+ 0.006207f, 0.019211f, 0.032623f, 0.046112f, 0.059662f, 0.073181f, 0.087585f, 0.102051f, 0.116577f, 0.130249f, 0.145142f, 0.159790f,
+ 0.175171f, 0.189575f, 0.205322f, 0.219238f, 0.235474f, 0.249634f, 0.265137f, 0.280029f, 0.294678f, 0.310547f, 0.325928f, 0.340820f,
+ 0.356201f, 0.371094f, 0.386230f, 0.401367f, 0.416504f, 0.431885f, 0.446533f, 0.461670f, 0.476074f, 0.492188f, 0.507324f, 0.520996f,
+ 0.535645f, 0.550781f, 0.564941f, 0.580078f, 0.594727f, 0.609863f, 0.623535f, 0.637695f, 0.652832f, 0.667480f, 0.681152f, 0.695312f,
+ 0.709473f, 0.723633f, 0.737793f, 0.751953f, 0.765137f, 0.779297f, 0.793945f, 0.807129f, 0.819824f, 0.833496f, 0.901855f, 0.880859f,
+ 0.864258f, 0.850098f, 0.837891f, 0.826660f, 0.006020f, 0.018219f, 0.030579f, 0.043365f, 0.055908f, 0.069153f, 0.082336f, 0.096802f,
+ 0.109497f, 0.123535f, 0.137451f, 0.151855f, 0.165649f, 0.180054f, 0.194702f, 0.208252f, 0.223999f, 0.238037f, 0.252930f, 0.267334f,
+ 0.281982f, 0.296875f, 0.312012f, 0.326904f, 0.340820f, 0.355957f, 0.370850f, 0.385986f, 0.400391f, 0.415039f, 0.430176f, 0.445801f,
+ 0.459229f, 0.474365f, 0.489014f, 0.502441f, 0.518066f, 0.533203f, 0.547363f, 0.562012f, 0.576660f, 0.590820f, 0.605469f, 0.619629f,
+ 0.633789f, 0.647949f, 0.663574f, 0.676758f, 0.690918f, 0.705566f, 0.719238f, 0.733398f, 0.746582f, 0.760254f, 0.774414f, 0.788574f,
+ 0.802246f, 0.816406f, 0.894043f, 0.874023f, 0.858398f, 0.844238f, 0.832031f, 0.822266f, 0.005520f, 0.017059f, 0.028625f, 0.040649f,
+ 0.053131f, 0.065552f, 0.077698f, 0.091187f, 0.104065f, 0.117371f, 0.130859f, 0.143677f, 0.157349f, 0.171021f, 0.184814f, 0.198730f,
+ 0.213135f, 0.226807f, 0.241211f, 0.255127f, 0.269775f, 0.283691f, 0.298096f, 0.312744f, 0.326660f, 0.341553f, 0.355957f, 0.370117f,
+ 0.384766f, 0.399170f, 0.414307f, 0.427979f, 0.442627f, 0.457764f, 0.471924f, 0.486084f, 0.500488f, 0.515137f, 0.529785f, 0.543945f,
+ 0.558594f, 0.572754f, 0.587402f, 0.601074f, 0.615234f, 0.629395f, 0.644043f, 0.657715f, 0.672852f, 0.685547f, 0.700684f, 0.714844f,
+ 0.728027f, 0.743164f, 0.756348f, 0.770508f, 0.785645f, 0.798340f, 0.885254f, 0.867676f, 0.852051f, 0.839355f, 0.828125f, 0.817871f,
+ 0.005241f, 0.015854f, 0.027481f, 0.038605f, 0.050171f, 0.061859f, 0.073853f, 0.085693f, 0.098328f, 0.111206f, 0.123474f, 0.136475f,
+ 0.149658f, 0.162598f, 0.175293f, 0.188477f, 0.202148f, 0.216431f, 0.229858f, 0.242798f, 0.256104f, 0.270264f, 0.284668f, 0.298828f,
+ 0.312744f, 0.326904f, 0.341064f, 0.355469f, 0.369141f, 0.383057f, 0.396729f, 0.411621f, 0.426025f, 0.439697f, 0.454590f, 0.468506f,
+ 0.482666f, 0.497070f, 0.512207f, 0.525391f, 0.540527f, 0.555176f, 0.567871f, 0.582031f, 0.596191f, 0.610840f, 0.625488f, 0.639648f,
+ 0.653809f, 0.668457f, 0.681641f, 0.695801f, 0.710449f, 0.724121f, 0.738770f, 0.751953f, 0.766602f, 0.780273f, 0.876465f, 0.860352f,
+ 0.845703f, 0.833984f, 0.822754f, 0.812988f, 0.004982f, 0.015274f, 0.025681f, 0.036438f, 0.047119f, 0.058167f, 0.069397f, 0.081055f,
+ 0.092957f, 0.104492f, 0.116577f, 0.128418f, 0.141113f, 0.153442f, 0.166504f, 0.179321f, 0.192261f, 0.205200f, 0.218506f, 0.231934f,
+ 0.244629f, 0.258301f, 0.271729f, 0.284912f, 0.299072f, 0.312988f, 0.325684f, 0.340088f, 0.353271f, 0.367676f, 0.381836f, 0.395508f,
+ 0.408936f, 0.423584f, 0.438232f, 0.451416f, 0.466309f, 0.479736f, 0.493896f, 0.507812f, 0.521973f, 0.536133f, 0.550293f, 0.563965f,
+ 0.578613f, 0.592773f, 0.606934f, 0.620605f, 0.635254f, 0.649414f, 0.663086f, 0.677246f, 0.691406f, 0.706543f, 0.720703f, 0.734375f,
+ 0.748047f, 0.762695f, 0.868164f, 0.853027f, 0.839355f, 0.828125f, 0.817383f, 0.808105f, 0.004745f, 0.014290f, 0.024506f, 0.034393f,
+ 0.044617f, 0.054749f, 0.065308f, 0.076538f, 0.087646f, 0.098938f, 0.110535f, 0.121582f, 0.134155f, 0.145264f, 0.157837f, 0.170166f,
+ 0.182373f, 0.194824f, 0.207153f, 0.220337f, 0.233276f, 0.245728f, 0.259277f, 0.271973f, 0.285645f, 0.298584f, 0.311768f, 0.325684f,
+ 0.338623f, 0.352539f, 0.365967f, 0.379395f, 0.393066f, 0.406738f, 0.421143f, 0.434326f, 0.448730f, 0.462402f, 0.475586f, 0.490479f,
+ 0.503906f, 0.518066f, 0.532227f, 0.546387f, 0.560059f, 0.574219f, 0.588379f, 0.602539f, 0.616211f, 0.630371f, 0.644531f, 0.658691f,
+ 0.673340f, 0.686523f, 0.701660f, 0.715332f, 0.730469f, 0.745117f, 0.858887f, 0.845215f, 0.833008f, 0.821777f, 0.812012f, 0.802734f,
+ 0.004494f, 0.013550f, 0.022675f, 0.032227f, 0.042145f, 0.052002f, 0.061554f, 0.072205f, 0.082520f, 0.093323f, 0.104614f, 0.115112f,
+ 0.126099f, 0.137817f, 0.149536f, 0.160767f, 0.172607f, 0.184692f, 0.196167f, 0.208862f, 0.221924f, 0.233765f, 0.246216f, 0.258545f,
+ 0.272461f, 0.284424f, 0.297119f, 0.310547f, 0.323242f, 0.336914f, 0.350586f, 0.363281f, 0.376953f, 0.390869f, 0.403564f, 0.416992f,
+ 0.431152f, 0.444824f, 0.458496f, 0.472656f, 0.486084f, 0.500000f, 0.513672f, 0.527832f, 0.541504f, 0.555664f, 0.569824f, 0.583496f,
+ 0.598145f, 0.611816f, 0.626465f, 0.639648f, 0.654297f, 0.668457f, 0.683594f, 0.697754f, 0.711914f, 0.726562f, 0.849609f, 0.838867f,
+ 0.826172f, 0.815918f, 0.806641f, 0.796875f, 0.004288f, 0.012619f, 0.021713f, 0.030945f, 0.039368f, 0.048737f, 0.058533f, 0.067932f,
+ 0.077759f, 0.088013f, 0.098755f, 0.108398f, 0.119080f, 0.129639f, 0.141235f, 0.152466f, 0.163940f, 0.174927f, 0.186768f, 0.198608f,
+ 0.210205f, 0.222290f, 0.234131f, 0.246094f, 0.258789f, 0.270508f, 0.283203f, 0.296631f, 0.309326f, 0.321777f, 0.335449f, 0.348145f,
+ 0.361084f, 0.374023f, 0.386963f, 0.400391f, 0.414062f, 0.427734f, 0.441162f, 0.455078f, 0.467773f, 0.482422f, 0.495117f, 0.509277f,
+ 0.523926f, 0.536621f, 0.550781f, 0.564941f, 0.579102f, 0.593262f, 0.607422f, 0.621582f, 0.635742f, 0.649902f, 0.664551f, 0.678711f,
+ 0.693848f, 0.708008f, 0.840820f, 0.831055f, 0.819336f, 0.809570f, 0.801270f, 0.792969f, 0.004013f, 0.012070f, 0.019989f, 0.029190f,
+ 0.037415f, 0.045776f, 0.055023f, 0.064392f, 0.073669f, 0.083374f, 0.092224f, 0.102295f, 0.112610f, 0.122742f, 0.133057f, 0.143799f,
+ 0.155273f, 0.165527f, 0.176880f, 0.188110f, 0.199463f, 0.210815f, 0.222534f, 0.234619f, 0.245972f, 0.258301f, 0.270508f, 0.282715f,
+ 0.294678f, 0.307129f, 0.320557f, 0.333008f, 0.345947f, 0.358398f, 0.371826f, 0.384277f, 0.397461f, 0.410889f, 0.424561f, 0.437256f,
+ 0.451416f, 0.464600f, 0.477783f, 0.491455f, 0.504395f, 0.518555f, 0.532715f, 0.546875f, 0.560547f, 0.574219f, 0.588379f, 0.604004f,
+ 0.617188f, 0.631348f, 0.645020f, 0.660645f, 0.674316f, 0.689941f, 0.832031f, 0.823242f, 0.813477f, 0.803711f, 0.794922f, 0.787109f,
+ 0.003790f, 0.011559f, 0.019119f, 0.027069f, 0.035034f, 0.043762f, 0.052032f, 0.060059f, 0.069153f, 0.078369f, 0.087280f, 0.096741f,
+ 0.105957f, 0.115967f, 0.125732f, 0.135620f, 0.146118f, 0.156128f, 0.166992f, 0.177612f, 0.188965f, 0.199829f, 0.210815f, 0.222290f,
+ 0.233887f, 0.244873f, 0.257324f, 0.268799f, 0.281006f, 0.292969f, 0.305420f, 0.317627f, 0.329834f, 0.341797f, 0.355469f, 0.368164f,
+ 0.380859f, 0.393311f, 0.407227f, 0.419434f, 0.433350f, 0.446533f, 0.459961f, 0.473633f, 0.486328f, 0.500488f, 0.515625f, 0.528320f,
+ 0.541504f, 0.556152f, 0.570312f, 0.584473f, 0.598633f, 0.612305f, 0.626465f, 0.640625f, 0.655762f, 0.670410f, 0.822266f, 0.815918f,
+ 0.805664f, 0.796387f, 0.788574f, 0.782227f, 0.003599f, 0.010727f, 0.018219f, 0.025177f, 0.033203f, 0.041046f, 0.048981f, 0.057220f,
+ 0.065247f, 0.073792f, 0.082764f, 0.091064f, 0.100220f, 0.108826f, 0.118591f, 0.128052f, 0.137573f, 0.147705f, 0.158081f, 0.167603f,
+ 0.177979f, 0.188721f, 0.198975f, 0.210205f, 0.221924f, 0.232544f, 0.243774f, 0.255615f, 0.267090f, 0.278564f, 0.290039f, 0.302490f,
+ 0.314941f, 0.327393f, 0.338623f, 0.352295f, 0.364014f, 0.377441f, 0.390381f, 0.403564f, 0.415039f, 0.428955f, 0.441895f, 0.455078f,
+ 0.468994f, 0.482666f, 0.496094f, 0.509277f, 0.523926f, 0.537598f, 0.551270f, 0.565430f, 0.579590f, 0.594238f, 0.608887f, 0.622559f,
+ 0.637207f, 0.651855f, 0.813477f, 0.807617f, 0.798340f, 0.790527f, 0.782715f, 0.775391f, 0.003355f, 0.009918f, 0.017105f, 0.023911f,
+ 0.031281f, 0.038147f, 0.045990f, 0.053284f, 0.061493f, 0.069214f, 0.077026f, 0.085571f, 0.093567f, 0.102600f, 0.111755f, 0.120728f,
+ 0.129761f, 0.138916f, 0.148804f, 0.158447f, 0.167725f, 0.177979f, 0.188965f, 0.198608f, 0.209473f, 0.220215f, 0.231567f, 0.242554f,
+ 0.253906f, 0.264160f, 0.276123f, 0.287109f, 0.300049f, 0.312012f, 0.323975f, 0.336182f, 0.348145f, 0.360840f, 0.372803f, 0.385986f,
+ 0.398438f, 0.411621f, 0.424316f, 0.437256f, 0.450439f, 0.464844f, 0.478027f, 0.490723f, 0.504395f, 0.518066f, 0.532715f, 0.546387f,
+ 0.561523f, 0.575684f, 0.589355f, 0.604004f, 0.618164f, 0.632324f, 0.802246f, 0.800293f, 0.792480f, 0.783691f, 0.776367f, 0.769531f,
+ 0.003265f, 0.009575f, 0.016144f, 0.022415f, 0.029510f, 0.036316f, 0.042755f, 0.050812f, 0.057556f, 0.065002f, 0.072388f, 0.080200f,
+ 0.087952f, 0.096680f, 0.104858f, 0.113281f, 0.122070f, 0.130493f, 0.139771f, 0.148926f, 0.158447f, 0.168335f, 0.177612f, 0.187500f,
+ 0.198120f, 0.208130f, 0.218750f, 0.229492f, 0.240234f, 0.250732f, 0.262207f, 0.273682f, 0.285156f, 0.296143f, 0.308594f, 0.320068f,
+ 0.332520f, 0.344482f, 0.357178f, 0.368652f, 0.381836f, 0.394043f, 0.406494f, 0.420410f, 0.433105f, 0.445801f, 0.459717f, 0.473633f,
+ 0.486816f, 0.500000f, 0.513672f, 0.527832f, 0.541992f, 0.556152f, 0.570312f, 0.585449f, 0.598633f, 0.613770f, 0.794434f, 0.791504f,
+ 0.784180f, 0.776855f, 0.770020f, 0.764160f, 0.002954f, 0.008904f, 0.014961f, 0.021210f, 0.027420f, 0.033905f, 0.040619f, 0.047363f,
+ 0.053986f, 0.060883f, 0.068054f, 0.075378f, 0.082703f, 0.090515f, 0.098022f, 0.105896f, 0.114319f, 0.122742f, 0.131592f, 0.139771f,
+ 0.149170f, 0.157959f, 0.167480f, 0.177124f, 0.186768f, 0.196411f, 0.206543f, 0.216919f, 0.227539f, 0.237671f, 0.248413f, 0.259277f,
+ 0.270264f, 0.281738f, 0.292725f, 0.304443f, 0.315918f, 0.327637f, 0.340576f, 0.352539f, 0.364746f, 0.377930f, 0.390137f, 0.401855f,
+ 0.415039f, 0.428223f, 0.441406f, 0.454834f, 0.468506f, 0.481689f, 0.494873f, 0.509277f, 0.523438f, 0.537598f, 0.551758f, 0.565918f,
+ 0.580078f, 0.594727f, 0.783691f, 0.783203f, 0.776855f, 0.770508f, 0.763672f, 0.757324f, 0.002836f, 0.008659f, 0.014351f, 0.019913f,
+ 0.025772f, 0.032074f, 0.037933f, 0.044128f, 0.050903f, 0.057159f, 0.064026f, 0.070496f, 0.077698f, 0.085022f, 0.091919f, 0.099426f,
+ 0.107727f, 0.114990f, 0.123169f, 0.131226f, 0.140015f, 0.148682f, 0.157349f, 0.166260f, 0.175171f, 0.184692f, 0.194214f, 0.203979f,
+ 0.214355f, 0.224487f, 0.234985f, 0.245728f, 0.256104f, 0.267334f, 0.278320f, 0.288818f, 0.301025f, 0.312256f, 0.324219f, 0.335938f,
+ 0.347900f, 0.360596f, 0.372070f, 0.384521f, 0.397217f, 0.410400f, 0.423340f, 0.436279f, 0.449463f, 0.463135f, 0.476807f, 0.490723f,
+ 0.503906f, 0.517578f, 0.532227f, 0.546875f, 0.561035f, 0.575684f, 0.773926f, 0.775391f, 0.769043f, 0.763672f, 0.757812f, 0.751953f,
+ 0.002506f, 0.008080f, 0.013100f, 0.018738f, 0.024384f, 0.029953f, 0.035797f, 0.041473f, 0.047485f, 0.053558f, 0.059265f, 0.065918f,
+ 0.072693f, 0.079468f, 0.086426f, 0.093384f, 0.100708f, 0.108032f, 0.115417f, 0.122986f, 0.130615f, 0.139038f, 0.147827f, 0.156494f,
+ 0.165039f, 0.173828f, 0.182617f, 0.192139f, 0.201782f, 0.211426f, 0.221558f, 0.231323f, 0.242188f, 0.252686f, 0.263672f, 0.274414f,
+ 0.284912f, 0.296143f, 0.308105f, 0.319824f, 0.331543f, 0.343750f, 0.355225f, 0.367432f, 0.379883f, 0.393066f, 0.405273f, 0.418457f,
+ 0.431641f, 0.444580f, 0.457764f, 0.471924f, 0.485840f, 0.499268f, 0.512695f, 0.527344f, 0.542480f, 0.556641f, 0.764160f, 0.766602f,
+ 0.761719f, 0.756348f, 0.750488f, 0.745605f, 0.002640f, 0.007809f, 0.012497f, 0.017593f, 0.023102f, 0.028122f, 0.033569f, 0.038879f,
+ 0.044250f, 0.049988f, 0.055908f, 0.061615f, 0.067627f, 0.074036f, 0.080566f, 0.087524f, 0.093262f, 0.100769f, 0.107910f, 0.114929f,
+ 0.121948f, 0.130371f, 0.137939f, 0.146362f, 0.154297f, 0.163208f, 0.171509f, 0.180664f, 0.189697f, 0.199341f, 0.208618f, 0.218506f,
+ 0.228394f, 0.238892f, 0.248779f, 0.259277f, 0.270752f, 0.281250f, 0.292236f, 0.303467f, 0.315186f, 0.326660f, 0.338867f, 0.351074f,
+ 0.362305f, 0.374756f, 0.387939f, 0.400146f, 0.413330f, 0.426514f, 0.439209f, 0.452881f, 0.466553f, 0.480225f, 0.494141f, 0.508301f,
+ 0.522949f, 0.537109f, 0.753906f, 0.758301f, 0.754395f, 0.749023f, 0.743652f, 0.739258f, 0.002441f, 0.007088f, 0.011993f, 0.016266f,
+ 0.021255f, 0.026031f, 0.031189f, 0.036072f, 0.041260f, 0.046753f, 0.052155f, 0.057587f, 0.063232f, 0.068787f, 0.075623f, 0.081055f,
+ 0.087341f, 0.094177f, 0.100647f, 0.106689f, 0.113892f, 0.121399f, 0.129028f, 0.136841f, 0.144287f, 0.152222f, 0.160522f, 0.169312f,
+ 0.178101f, 0.186523f, 0.196045f, 0.205200f, 0.214966f, 0.224487f, 0.234863f, 0.244751f, 0.255371f, 0.265625f, 0.276367f, 0.287842f,
+ 0.298828f, 0.310303f, 0.321533f, 0.333984f, 0.345459f, 0.357666f, 0.370117f, 0.382568f, 0.394287f, 0.407959f, 0.421875f, 0.433838f,
+ 0.446777f, 0.461426f, 0.475098f, 0.488525f, 0.504395f, 0.517578f, 0.744141f, 0.749512f, 0.746094f, 0.741699f, 0.736816f, 0.732422f,
+ 0.002172f, 0.006695f, 0.011093f, 0.015266f, 0.020081f, 0.024521f, 0.029388f, 0.033966f, 0.038727f, 0.043427f, 0.048706f, 0.053772f,
+ 0.059418f, 0.064270f, 0.069580f, 0.075500f, 0.081421f, 0.087280f, 0.093262f, 0.099670f, 0.106567f, 0.113220f, 0.119995f, 0.127197f,
+ 0.134644f, 0.142212f, 0.150146f, 0.157959f, 0.166382f, 0.174927f, 0.184082f, 0.192505f, 0.201904f, 0.211792f, 0.220825f, 0.230713f,
+ 0.240601f, 0.251221f, 0.261719f, 0.272461f, 0.282715f, 0.294434f, 0.305420f, 0.316650f, 0.328369f, 0.340088f, 0.352783f, 0.364746f,
+ 0.377197f, 0.389648f, 0.402832f, 0.416016f, 0.429443f, 0.442627f, 0.456055f, 0.469971f, 0.484863f, 0.499268f, 0.733887f, 0.741211f,
+ 0.737793f, 0.734375f, 0.729980f, 0.725586f, 0.002045f, 0.006187f, 0.010406f, 0.014664f, 0.018570f, 0.022675f, 0.027176f, 0.031586f,
+ 0.035858f, 0.040253f, 0.045227f, 0.049774f, 0.054504f, 0.059692f, 0.065186f, 0.070374f, 0.075500f, 0.080627f, 0.086792f, 0.092285f,
+ 0.098999f, 0.104675f, 0.111816f, 0.118286f, 0.125610f, 0.132324f, 0.139771f, 0.147339f, 0.155029f, 0.163696f, 0.171631f, 0.180420f,
+ 0.189087f, 0.197754f, 0.207275f, 0.216309f, 0.226440f, 0.236694f, 0.246338f, 0.256836f, 0.267334f, 0.278320f, 0.289062f, 0.300537f,
+ 0.312012f, 0.323975f, 0.335449f, 0.347168f, 0.359375f, 0.372314f, 0.384521f, 0.396973f, 0.410400f, 0.423584f, 0.437500f, 0.450928f,
+ 0.465332f, 0.479736f, 0.723145f, 0.732422f, 0.729980f, 0.726562f, 0.722656f, 0.718750f, 0.002148f, 0.005802f, 0.009811f, 0.013565f,
+ 0.017578f, 0.021179f, 0.025040f, 0.029053f, 0.033417f, 0.037445f, 0.042114f, 0.046112f, 0.050720f, 0.055511f, 0.060028f, 0.065002f,
+ 0.069458f, 0.075134f, 0.080078f, 0.085693f, 0.091492f, 0.097290f, 0.103394f, 0.109802f, 0.116089f, 0.122925f, 0.129883f, 0.136963f,
+ 0.144165f, 0.151733f, 0.160156f, 0.167847f, 0.176392f, 0.184692f, 0.193848f, 0.203003f, 0.212402f, 0.221680f, 0.231689f, 0.242065f,
+ 0.251953f, 0.262207f, 0.273193f, 0.283936f, 0.295410f, 0.306152f, 0.318359f, 0.329590f, 0.342285f, 0.354248f, 0.366455f, 0.379150f,
+ 0.391846f, 0.405273f, 0.418701f, 0.432617f, 0.446289f, 0.460205f, 0.712891f, 0.723633f, 0.722168f, 0.718750f, 0.715332f, 0.712402f,
+ 0.001963f, 0.005642f, 0.009071f, 0.012756f, 0.016006f, 0.020020f, 0.023422f, 0.027679f, 0.030762f, 0.034943f, 0.038605f, 0.042969f,
+ 0.047028f, 0.051178f, 0.055542f, 0.060120f, 0.064575f, 0.069153f, 0.074280f, 0.079041f, 0.084595f, 0.089905f, 0.095276f, 0.101440f,
+ 0.107300f, 0.113586f, 0.119751f, 0.127075f, 0.134033f, 0.141357f, 0.148438f, 0.155884f, 0.164062f, 0.172729f, 0.180542f, 0.190063f,
+ 0.198364f, 0.207764f, 0.217163f, 0.226807f, 0.236938f, 0.247070f, 0.257324f, 0.268066f, 0.278320f, 0.289795f, 0.301025f, 0.312744f,
+ 0.324707f, 0.336182f, 0.347900f, 0.360840f, 0.372803f, 0.386230f, 0.399902f, 0.413574f, 0.427246f, 0.441162f, 0.702148f, 0.714355f,
+ 0.713867f, 0.711426f, 0.707520f, 0.704590f, 0.001995f, 0.005245f, 0.008553f, 0.011543f, 0.015015f, 0.018326f, 0.021881f, 0.025131f,
+ 0.028641f, 0.032349f, 0.035675f, 0.039520f, 0.043549f, 0.047089f, 0.051086f, 0.054962f, 0.059265f, 0.063782f, 0.068054f, 0.072571f,
+ 0.077759f, 0.082520f, 0.088013f, 0.093323f, 0.098755f, 0.104858f, 0.111145f, 0.117371f, 0.123840f, 0.130615f, 0.137207f, 0.144897f,
+ 0.152344f, 0.160278f, 0.167969f, 0.176514f, 0.185425f, 0.193848f, 0.202881f, 0.212524f, 0.221924f, 0.231323f, 0.241821f, 0.251953f,
+ 0.262451f, 0.272949f, 0.284424f, 0.295166f, 0.306396f, 0.319092f, 0.329590f, 0.343018f, 0.355225f, 0.368652f, 0.381348f, 0.393799f,
+ 0.408447f, 0.422852f, 0.691406f, 0.706055f, 0.706055f, 0.703125f, 0.700684f, 0.697754f, 0.001692f, 0.004898f, 0.007828f, 0.011070f,
+ 0.013992f, 0.017227f, 0.020187f, 0.023499f, 0.026520f, 0.029526f, 0.033081f, 0.036377f, 0.039459f, 0.043396f, 0.047028f, 0.050323f,
+ 0.054199f, 0.058350f, 0.062317f, 0.066711f, 0.071106f, 0.075928f, 0.080750f, 0.085510f, 0.090820f, 0.096497f, 0.102234f, 0.107727f,
+ 0.114075f, 0.120300f, 0.126587f, 0.133789f, 0.141113f, 0.148193f, 0.156006f, 0.163696f, 0.171753f, 0.180542f, 0.188965f, 0.198120f,
+ 0.207275f, 0.216797f, 0.226318f, 0.236206f, 0.246338f, 0.256836f, 0.267334f, 0.278809f, 0.289795f, 0.300781f, 0.313232f, 0.324707f,
+ 0.337402f, 0.349365f, 0.362305f, 0.376221f, 0.389404f, 0.403809f, 0.680176f, 0.696289f, 0.697266f, 0.695312f, 0.692871f, 0.689941f,
+ 0.001606f, 0.004543f, 0.007450f, 0.010269f, 0.012962f, 0.015900f, 0.018677f, 0.021591f, 0.024628f, 0.027618f, 0.030182f, 0.033783f,
+ 0.036194f, 0.039734f, 0.042725f, 0.046478f, 0.049652f, 0.053253f, 0.057251f, 0.060883f, 0.065186f, 0.069336f, 0.073730f, 0.078247f,
+ 0.083252f, 0.088501f, 0.093628f, 0.099182f, 0.104553f, 0.110718f, 0.116577f, 0.123108f, 0.129883f, 0.136719f, 0.143921f, 0.151367f,
+ 0.159302f, 0.167114f, 0.175415f, 0.183960f, 0.192871f, 0.202148f, 0.210938f, 0.221436f, 0.230713f, 0.240723f, 0.250977f, 0.261963f,
+ 0.272461f, 0.283691f, 0.295166f, 0.306885f, 0.319092f, 0.331055f, 0.343750f, 0.356689f, 0.370361f, 0.383545f, 0.669434f, 0.687500f,
+ 0.688965f, 0.687500f, 0.685547f, 0.682617f, 0.001701f, 0.004345f, 0.006802f, 0.009514f, 0.012283f, 0.014793f, 0.017288f, 0.019958f,
+ 0.022614f, 0.025177f, 0.027695f, 0.030487f, 0.033081f, 0.035858f, 0.039185f, 0.042236f, 0.045319f, 0.048523f, 0.051941f, 0.055847f,
+ 0.059326f, 0.063171f, 0.067139f, 0.071594f, 0.075928f, 0.080566f, 0.085571f, 0.090454f, 0.095520f, 0.101196f, 0.106567f, 0.112427f,
+ 0.119019f, 0.125610f, 0.132324f, 0.139282f, 0.146973f, 0.154419f, 0.161987f, 0.170532f, 0.178833f, 0.187134f, 0.196777f, 0.206177f,
+ 0.214966f, 0.225220f, 0.235352f, 0.246094f, 0.255615f, 0.266846f, 0.278320f, 0.290039f, 0.301270f, 0.313477f, 0.325195f, 0.338867f,
+ 0.352539f, 0.365234f, 0.657715f, 0.678711f, 0.679688f, 0.679199f, 0.677734f, 0.675293f, 0.001310f, 0.003979f, 0.006393f, 0.008522f,
+ 0.011223f, 0.013557f, 0.015976f, 0.018433f, 0.020737f, 0.022842f, 0.025421f, 0.027649f, 0.030289f, 0.032806f, 0.035645f, 0.038025f,
+ 0.041199f, 0.044220f, 0.047058f, 0.050720f, 0.053589f, 0.057281f, 0.061157f, 0.064941f, 0.068787f, 0.072998f, 0.077698f, 0.082153f,
+ 0.086975f, 0.092102f, 0.097229f, 0.103027f, 0.108826f, 0.114746f, 0.121094f, 0.127930f, 0.134521f, 0.141846f, 0.149292f, 0.157227f,
+ 0.164673f, 0.173218f, 0.182007f, 0.190552f, 0.199951f, 0.209717f, 0.219360f, 0.229004f, 0.239502f, 0.250244f, 0.260986f, 0.272461f,
+ 0.282959f, 0.295166f, 0.307373f, 0.320557f, 0.333252f, 0.346436f, 0.646973f, 0.668945f, 0.670898f, 0.671387f, 0.669922f, 0.668457f,
+ 0.001348f, 0.003523f, 0.005863f, 0.008133f, 0.010338f, 0.012520f, 0.014511f, 0.016464f, 0.018768f, 0.020920f, 0.022888f, 0.025665f,
+ 0.027588f, 0.029861f, 0.032135f, 0.034485f, 0.037140f, 0.040039f, 0.042725f, 0.045532f, 0.048859f, 0.051971f, 0.055237f, 0.058594f,
+ 0.062408f, 0.066101f, 0.070251f, 0.074280f, 0.078735f, 0.083435f, 0.088318f, 0.093567f, 0.098633f, 0.104431f, 0.110291f, 0.116455f,
+ 0.122986f, 0.129517f, 0.136963f, 0.143921f, 0.152222f, 0.159546f, 0.167358f, 0.176514f, 0.185181f, 0.194214f, 0.203857f, 0.213623f,
+ 0.223389f, 0.233521f, 0.244385f, 0.255127f, 0.266602f, 0.277832f, 0.289307f, 0.301758f, 0.314697f, 0.328613f, 0.635254f, 0.659668f,
+ 0.663086f, 0.663086f, 0.662109f, 0.660156f, 0.001084f, 0.003263f, 0.005554f, 0.007416f, 0.009445f, 0.011185f, 0.013161f, 0.015366f,
+ 0.017136f, 0.019058f, 0.020935f, 0.022781f, 0.024857f, 0.026886f, 0.029160f, 0.031097f, 0.033569f, 0.035858f, 0.038361f, 0.040924f,
+ 0.043427f, 0.046478f, 0.049500f, 0.052948f, 0.056122f, 0.059418f, 0.063293f, 0.067139f, 0.070923f, 0.075073f, 0.079712f, 0.084229f,
+ 0.089233f, 0.094604f, 0.100037f, 0.105774f, 0.111694f, 0.117798f, 0.124634f, 0.131226f, 0.139038f, 0.146484f, 0.154175f, 0.162231f,
+ 0.170654f, 0.179199f, 0.188599f, 0.197754f, 0.207153f, 0.217407f, 0.227295f, 0.238159f, 0.248657f, 0.260986f, 0.271973f, 0.284912f,
+ 0.296631f, 0.308838f, 0.623535f, 0.650391f, 0.653809f, 0.654297f, 0.653809f, 0.652832f, 0.001070f, 0.003069f, 0.005108f, 0.006855f,
+ 0.008522f, 0.010384f, 0.011993f, 0.013847f, 0.015549f, 0.016968f, 0.018677f, 0.020660f, 0.022079f, 0.024048f, 0.026077f, 0.027954f,
+ 0.030014f, 0.032135f, 0.034210f, 0.036560f, 0.038971f, 0.041840f, 0.044434f, 0.047089f, 0.049896f, 0.053284f, 0.056763f, 0.060120f,
+ 0.063477f, 0.067505f, 0.071533f, 0.075928f, 0.080261f, 0.085205f, 0.089905f, 0.095520f, 0.100830f, 0.106567f, 0.113159f, 0.119385f,
+ 0.126221f, 0.133301f, 0.140259f, 0.148560f, 0.156494f, 0.165039f, 0.173462f, 0.182861f, 0.192017f, 0.201172f, 0.211548f, 0.221802f,
+ 0.232666f, 0.243286f, 0.254639f, 0.265869f, 0.278809f, 0.291260f, 0.611816f, 0.640625f, 0.645508f, 0.645996f, 0.645508f, 0.645020f,
+ 0.001057f, 0.002815f, 0.004646f, 0.006187f, 0.007935f, 0.009583f, 0.011139f, 0.012428f, 0.013878f, 0.015404f, 0.016830f, 0.018433f,
+ 0.019836f, 0.021637f, 0.023300f, 0.024857f, 0.026855f, 0.028519f, 0.030533f, 0.032593f, 0.034790f, 0.037140f, 0.039520f, 0.041748f,
+ 0.044525f, 0.047302f, 0.050232f, 0.053497f, 0.056580f, 0.059998f, 0.063721f, 0.067627f, 0.071777f, 0.076111f, 0.080627f, 0.085571f,
+ 0.090698f, 0.096130f, 0.101624f, 0.107849f, 0.114258f, 0.120544f, 0.127686f, 0.135132f, 0.142700f, 0.150269f, 0.158813f, 0.167725f,
+ 0.176392f, 0.185791f, 0.195312f, 0.205444f, 0.216064f, 0.226562f, 0.237793f, 0.248657f, 0.260254f, 0.272949f, 0.600098f, 0.631348f,
+ 0.636230f, 0.637207f, 0.637695f, 0.636719f, 0.001022f, 0.002628f, 0.004486f, 0.005684f, 0.007179f, 0.008636f, 0.009911f, 0.011307f,
+ 0.012428f, 0.013771f, 0.015152f, 0.016342f, 0.017822f, 0.018997f, 0.020584f, 0.022263f, 0.023651f, 0.025482f, 0.027191f, 0.028793f,
+ 0.030960f, 0.032715f, 0.034912f, 0.036987f, 0.039368f, 0.041840f, 0.044495f, 0.047180f, 0.050110f, 0.053314f, 0.056580f, 0.060059f,
+ 0.063660f, 0.067383f, 0.071777f, 0.075928f, 0.081055f, 0.085938f, 0.091187f, 0.096619f, 0.102356f, 0.108826f, 0.115051f, 0.121948f,
+ 0.129150f, 0.136475f, 0.144653f, 0.152832f, 0.161621f, 0.170288f, 0.179932f, 0.189209f, 0.198730f, 0.209595f, 0.220459f, 0.231201f,
+ 0.242798f, 0.255615f, 0.588867f, 0.621094f, 0.626953f, 0.629883f, 0.629395f, 0.629883f, 0.001016f, 0.002304f, 0.003975f, 0.005024f,
+ 0.006584f, 0.007812f, 0.008926f, 0.009987f, 0.011024f, 0.012199f, 0.013321f, 0.014595f, 0.015617f, 0.016830f, 0.018326f, 0.019577f,
+ 0.020798f, 0.022293f, 0.023758f, 0.025253f, 0.027145f, 0.028656f, 0.030640f, 0.032501f, 0.034546f, 0.036682f, 0.039001f, 0.041412f,
+ 0.044037f, 0.046875f, 0.049622f, 0.052917f, 0.056030f, 0.059387f, 0.063354f, 0.067383f, 0.071655f, 0.075928f, 0.080750f, 0.085876f,
+ 0.091248f, 0.097168f, 0.102905f, 0.109497f, 0.116272f, 0.123413f, 0.130859f, 0.138550f, 0.147217f, 0.155518f, 0.164551f, 0.173828f,
+ 0.183350f, 0.193481f, 0.204102f, 0.214600f, 0.225342f, 0.237915f, 0.575684f, 0.611816f, 0.617188f, 0.621094f, 0.621582f, 0.620605f,
+ 0.000768f, 0.002398f, 0.003801f, 0.004875f, 0.005848f, 0.006889f, 0.008072f, 0.008820f, 0.009758f, 0.010910f, 0.011810f, 0.013023f,
+ 0.013878f, 0.014786f, 0.016083f, 0.017166f, 0.018402f, 0.019577f, 0.020691f, 0.022125f, 0.023743f, 0.025009f, 0.026779f, 0.028336f,
+ 0.030075f, 0.031921f, 0.033997f, 0.036255f, 0.038452f, 0.040833f, 0.043488f, 0.045959f, 0.049011f, 0.052216f, 0.055634f, 0.059052f,
+ 0.062744f, 0.066956f, 0.071289f, 0.075745f, 0.080566f, 0.086060f, 0.091614f, 0.097351f, 0.103821f, 0.110291f, 0.117432f, 0.124939f,
+ 0.132568f, 0.140869f, 0.149414f, 0.158325f, 0.168213f, 0.177368f, 0.187744f, 0.197876f, 0.208984f, 0.219849f, 0.563965f, 0.602051f,
+ 0.608887f, 0.610840f, 0.613770f, 0.612305f, 0.000764f, 0.002028f, 0.003302f, 0.004276f, 0.005325f, 0.006035f, 0.007034f, 0.007843f,
+ 0.008904f, 0.009628f, 0.010323f, 0.011192f, 0.012039f, 0.013092f, 0.013924f, 0.014854f, 0.015793f, 0.016953f, 0.018036f, 0.019211f,
+ 0.020355f, 0.021667f, 0.023010f, 0.024582f, 0.026016f, 0.027771f, 0.029434f, 0.031235f, 0.033264f, 0.035217f, 0.037628f, 0.039886f,
+ 0.042084f, 0.044952f, 0.048126f, 0.051392f, 0.054779f, 0.058197f, 0.062164f, 0.066223f, 0.070740f, 0.075439f, 0.080566f, 0.086182f,
+ 0.091919f, 0.098145f, 0.104431f, 0.111633f, 0.119080f, 0.126587f, 0.134888f, 0.143311f, 0.152710f, 0.162109f, 0.171631f, 0.182129f,
+ 0.192139f, 0.203491f, 0.552246f, 0.591309f, 0.599609f, 0.602539f, 0.604004f, 0.604980f, 0.000782f, 0.001970f, 0.003082f, 0.003859f,
+ 0.004635f, 0.005611f, 0.006123f, 0.006767f, 0.007595f, 0.008270f, 0.009140f, 0.009674f, 0.010490f, 0.011040f, 0.011902f, 0.012749f,
+ 0.013573f, 0.014526f, 0.015656f, 0.016541f, 0.017548f, 0.018631f, 0.019730f, 0.021103f, 0.022446f, 0.023758f, 0.025162f, 0.026611f,
+ 0.028458f, 0.030441f, 0.032074f, 0.034302f, 0.036316f, 0.038727f, 0.041138f, 0.044098f, 0.046997f, 0.050232f, 0.053711f, 0.057281f,
+ 0.061340f, 0.065491f, 0.070435f, 0.075256f, 0.080688f, 0.086426f, 0.092346f, 0.098694f, 0.105896f, 0.113098f, 0.120911f, 0.129028f,
+ 0.137695f, 0.146606f, 0.155884f, 0.165894f, 0.175903f, 0.186768f, 0.540527f, 0.582520f, 0.590332f, 0.593750f, 0.594727f, 0.596191f,
+ 0.000711f, 0.001649f, 0.002529f, 0.003332f, 0.004036f, 0.004799f, 0.005444f, 0.006050f, 0.006638f, 0.007160f, 0.007771f, 0.008331f,
+ 0.008980f, 0.009644f, 0.010307f, 0.010887f, 0.011787f, 0.012306f, 0.013176f, 0.014099f, 0.014915f, 0.015839f, 0.016708f, 0.017822f,
+ 0.019073f, 0.020233f, 0.021423f, 0.022690f, 0.024033f, 0.025589f, 0.027344f, 0.028976f, 0.030930f, 0.032990f, 0.035156f, 0.037445f,
+ 0.040131f, 0.042847f, 0.045776f, 0.049042f, 0.052551f, 0.056519f, 0.060486f, 0.064941f, 0.069458f, 0.074951f, 0.080444f, 0.086487f,
+ 0.092957f, 0.099915f, 0.107361f, 0.114929f, 0.123535f, 0.131714f, 0.140747f, 0.150513f, 0.160767f, 0.171265f, 0.527832f, 0.572754f,
+ 0.581543f, 0.583496f, 0.586426f, 0.587402f, 0.000504f, 0.001575f, 0.002235f, 0.003147f, 0.003641f, 0.004150f, 0.004570f, 0.005173f,
+ 0.005863f, 0.006016f, 0.006462f, 0.007111f, 0.007660f, 0.008156f, 0.008736f, 0.009354f, 0.010094f, 0.010475f, 0.011253f, 0.011879f,
+ 0.012657f, 0.013603f, 0.014267f, 0.015099f, 0.016144f, 0.017014f, 0.017990f, 0.019104f, 0.020416f, 0.021652f, 0.022919f, 0.024353f,
+ 0.025986f, 0.027710f, 0.029602f, 0.031494f, 0.033722f, 0.036102f, 0.038635f, 0.041412f, 0.044525f, 0.047729f, 0.051636f, 0.055511f,
+ 0.059540f, 0.064331f, 0.069580f, 0.075073f, 0.080750f, 0.087341f, 0.094116f, 0.101379f, 0.109558f, 0.117676f, 0.126221f, 0.135376f,
+ 0.145874f, 0.155518f, 0.516113f, 0.562012f, 0.571777f, 0.576172f, 0.578125f, 0.579102f, 0.000445f, 0.001304f, 0.002201f, 0.002535f,
+ 0.003126f, 0.003664f, 0.004047f, 0.004463f, 0.004887f, 0.005234f, 0.005711f, 0.005997f, 0.006500f, 0.006901f, 0.007389f, 0.007904f,
+ 0.008293f, 0.008919f, 0.009499f, 0.009941f, 0.010635f, 0.011269f, 0.011948f, 0.012589f, 0.013435f, 0.014252f, 0.015091f, 0.016052f,
+ 0.017059f, 0.017960f, 0.019241f, 0.020264f, 0.021667f, 0.022995f, 0.024628f, 0.026230f, 0.027985f, 0.029984f, 0.032288f, 0.034515f,
+ 0.037140f, 0.040009f, 0.043152f, 0.046722f, 0.050354f, 0.054504f, 0.059143f, 0.064026f, 0.069458f, 0.075256f, 0.081726f, 0.088562f,
+ 0.095825f, 0.103516f, 0.112000f, 0.120850f, 0.130005f, 0.140381f, 0.502441f, 0.551758f, 0.562012f, 0.566406f, 0.568848f, 0.571289f,
+ 0.000396f, 0.001226f, 0.001812f, 0.002357f, 0.002796f, 0.003094f, 0.003328f, 0.003763f, 0.003979f, 0.004364f, 0.004642f, 0.005051f,
+ 0.005489f, 0.005745f, 0.006126f, 0.006611f, 0.007004f, 0.007473f, 0.007771f, 0.008293f, 0.008919f, 0.009392f, 0.009941f, 0.010483f,
+ 0.011169f, 0.011765f, 0.012436f, 0.013344f, 0.014030f, 0.014908f, 0.015778f, 0.016769f, 0.017838f, 0.018997f, 0.020279f, 0.021622f,
+ 0.023056f, 0.024704f, 0.026474f, 0.028580f, 0.030579f, 0.033051f, 0.035706f, 0.038605f, 0.041840f, 0.045380f, 0.049500f, 0.053986f,
+ 0.058685f, 0.063843f, 0.069885f, 0.076050f, 0.083191f, 0.090576f, 0.098511f, 0.107056f, 0.115479f, 0.125122f, 0.491211f, 0.541504f,
+ 0.552734f, 0.557617f, 0.560547f, 0.562012f, 0.000559f, 0.001152f, 0.001668f, 0.001955f, 0.002234f, 0.002550f, 0.002821f, 0.003057f,
+ 0.003296f, 0.003635f, 0.003948f, 0.004189f, 0.004448f, 0.004761f, 0.005077f, 0.005417f, 0.005699f, 0.006142f, 0.006458f, 0.006844f,
+ 0.007271f, 0.007717f, 0.008156f, 0.008675f, 0.009132f, 0.009590f, 0.010277f, 0.010864f, 0.011482f, 0.012131f, 0.012901f, 0.013741f,
+ 0.014595f, 0.015549f, 0.016525f, 0.017563f, 0.018799f, 0.020111f, 0.021484f, 0.023087f, 0.024765f, 0.026840f, 0.028992f, 0.031403f,
+ 0.034119f, 0.037323f, 0.040680f, 0.044464f, 0.048584f, 0.053345f, 0.058838f, 0.064514f, 0.071045f, 0.078247f, 0.085571f, 0.093567f,
+ 0.101685f, 0.111023f, 0.477539f, 0.531738f, 0.542969f, 0.548340f, 0.552246f, 0.553711f, 0.000459f, 0.000939f, 0.001184f, 0.001600f,
+ 0.001761f, 0.002144f, 0.002258f, 0.002546f, 0.002708f, 0.002922f, 0.003157f, 0.003414f, 0.003588f, 0.003918f, 0.004154f, 0.004387f,
+ 0.004662f, 0.004993f, 0.005249f, 0.005566f, 0.005867f, 0.006252f, 0.006573f, 0.007061f, 0.007408f, 0.007858f, 0.008270f, 0.008713f,
+ 0.009361f, 0.009911f, 0.010513f, 0.011047f, 0.011841f, 0.012566f, 0.013252f, 0.014175f, 0.015182f, 0.016220f, 0.017258f, 0.018524f,
+ 0.019882f, 0.021454f, 0.023132f, 0.025146f, 0.027405f, 0.029877f, 0.032745f, 0.035919f, 0.039642f, 0.043823f, 0.048492f, 0.053619f,
+ 0.059235f, 0.065735f, 0.072693f, 0.080383f, 0.088867f, 0.097412f, 0.466309f, 0.520508f, 0.533691f, 0.539062f, 0.542480f, 0.543945f,
+ 0.000369f, 0.000915f, 0.001124f, 0.001297f, 0.001534f, 0.001741f, 0.001833f, 0.002111f, 0.002272f, 0.002369f, 0.002516f, 0.002766f,
+ 0.002920f, 0.003162f, 0.003317f, 0.003551f, 0.003723f, 0.003941f, 0.004211f, 0.004425f, 0.004757f, 0.004993f, 0.005306f, 0.005581f,
+ 0.005859f, 0.006203f, 0.006592f, 0.007015f, 0.007450f, 0.007828f, 0.008377f, 0.008797f, 0.009361f, 0.009895f, 0.010582f, 0.011322f,
+ 0.012016f, 0.012772f, 0.013687f, 0.014748f, 0.015778f, 0.016907f, 0.018326f, 0.019821f, 0.021622f, 0.023483f, 0.025742f, 0.028473f,
+ 0.031525f, 0.034943f, 0.038910f, 0.043457f, 0.048645f, 0.054749f, 0.061279f, 0.068420f, 0.076111f, 0.084778f, 0.453613f, 0.510742f,
+ 0.523926f, 0.529785f, 0.533203f, 0.536133f, 0.000186f, 0.000582f, 0.000925f, 0.001026f, 0.001228f, 0.001351f, 0.001470f, 0.001606f,
+ 0.001765f, 0.001908f, 0.001999f, 0.002104f, 0.002281f, 0.002476f, 0.002659f, 0.002766f, 0.002911f, 0.003040f, 0.003344f, 0.003475f,
+ 0.003683f, 0.003922f, 0.004185f, 0.004417f, 0.004673f, 0.004890f, 0.005123f, 0.005440f, 0.005817f, 0.006126f, 0.006481f, 0.006859f,
+ 0.007275f, 0.007740f, 0.008202f, 0.008728f, 0.009315f, 0.009972f, 0.010597f, 0.011391f, 0.012268f, 0.013252f, 0.014221f, 0.015388f,
+ 0.016724f, 0.018265f, 0.020004f, 0.022049f, 0.024445f, 0.027206f, 0.030762f, 0.034424f, 0.038971f, 0.044220f, 0.050262f, 0.056976f,
+ 0.064575f, 0.072083f, 0.441650f, 0.500488f, 0.514160f, 0.520020f, 0.524414f, 0.526855f, 0.000194f, 0.000467f, 0.000775f, 0.000911f,
+ 0.000994f, 0.001081f, 0.001221f, 0.001204f, 0.001368f, 0.001479f, 0.001582f, 0.001707f, 0.001801f, 0.001921f, 0.001993f, 0.002146f,
+ 0.002245f, 0.002398f, 0.002531f, 0.002674f, 0.002871f, 0.003033f, 0.003172f, 0.003374f, 0.003519f, 0.003742f, 0.003963f, 0.004158f,
+ 0.004448f, 0.004650f, 0.005032f, 0.005230f, 0.005550f, 0.005932f, 0.006241f, 0.006634f, 0.007088f, 0.007572f, 0.008110f, 0.008636f,
+ 0.009323f, 0.010071f, 0.010834f, 0.011757f, 0.012779f, 0.013863f, 0.015190f, 0.016769f, 0.018555f, 0.020706f, 0.023331f, 0.026352f,
+ 0.030182f, 0.034760f, 0.040039f, 0.046356f, 0.053406f, 0.060638f, 0.427979f, 0.489502f, 0.504883f, 0.511719f, 0.515137f, 0.518066f,
+ 0.000339f, 0.000388f, 0.000559f, 0.000617f, 0.000667f, 0.000795f, 0.000853f, 0.000938f, 0.000972f, 0.001079f, 0.001217f, 0.001274f,
+ 0.001369f, 0.001480f, 0.001536f, 0.001581f, 0.001711f, 0.001804f, 0.001900f, 0.002047f, 0.002129f, 0.002245f, 0.002394f, 0.002493f,
+ 0.002645f, 0.002773f, 0.002974f, 0.003124f, 0.003307f, 0.003559f, 0.003757f, 0.003893f, 0.004169f, 0.004353f, 0.004684f, 0.004963f,
+ 0.005272f, 0.005615f, 0.005981f, 0.006420f, 0.006878f, 0.007378f, 0.008080f, 0.008682f, 0.009438f, 0.010239f, 0.011299f, 0.012459f,
+ 0.013809f, 0.015305f, 0.017212f, 0.019501f, 0.022583f, 0.026245f, 0.030838f, 0.036255f, 0.042938f, 0.049988f, 0.416504f, 0.479492f,
+ 0.495361f, 0.501465f, 0.505859f, 0.508789f, 0.000148f, 0.000349f, 0.000414f, 0.000480f, 0.000554f, 0.000575f, 0.000675f, 0.000641f,
+ 0.000743f, 0.000809f, 0.000882f, 0.000919f, 0.000967f, 0.001019f, 0.001122f, 0.001156f, 0.001264f, 0.001322f, 0.001392f, 0.001431f,
+ 0.001529f, 0.001625f, 0.001735f, 0.001802f, 0.001912f, 0.002007f, 0.002131f, 0.002237f, 0.002338f, 0.002525f, 0.002638f, 0.002850f,
+ 0.002962f, 0.003130f, 0.003347f, 0.003536f, 0.003784f, 0.004063f, 0.004364f, 0.004623f, 0.004929f, 0.005314f, 0.005714f, 0.006191f,
+ 0.006760f, 0.007385f, 0.008080f, 0.008919f, 0.009933f, 0.011078f, 0.012390f, 0.014130f, 0.016251f, 0.019012f, 0.022720f, 0.027496f,
+ 0.033234f, 0.040192f, 0.403320f, 0.468994f, 0.485352f, 0.491943f, 0.497070f, 0.500000f, 0.000093f, 0.000191f, 0.000299f, 0.000284f,
+ 0.000367f, 0.000453f, 0.000420f, 0.000467f, 0.000519f, 0.000611f, 0.000607f, 0.000626f, 0.000647f, 0.000722f, 0.000741f, 0.000815f,
+ 0.000829f, 0.000910f, 0.000967f, 0.001023f, 0.001076f, 0.001138f, 0.001197f, 0.001260f, 0.001334f, 0.001393f, 0.001490f, 0.001562f,
+ 0.001633f, 0.001772f, 0.001831f, 0.001949f, 0.002056f, 0.002167f, 0.002312f, 0.002472f, 0.002607f, 0.002781f, 0.002972f, 0.003145f,
+ 0.003387f, 0.003647f, 0.003941f, 0.004253f, 0.004604f, 0.005051f, 0.005558f, 0.006165f, 0.006836f, 0.007660f, 0.008652f, 0.009796f,
+ 0.011284f, 0.013260f, 0.015945f, 0.019608f, 0.024734f, 0.031082f, 0.390625f, 0.459229f, 0.475586f, 0.482910f, 0.488037f, 0.490723f,
+ 0.000132f, 0.000208f, 0.000217f, 0.000221f, 0.000267f, 0.000272f, 0.000277f, 0.000320f, 0.000356f, 0.000372f, 0.000372f, 0.000446f,
+ 0.000436f, 0.000487f, 0.000514f, 0.000531f, 0.000587f, 0.000601f, 0.000629f, 0.000658f, 0.000707f, 0.000736f, 0.000784f, 0.000816f,
+ 0.000880f, 0.000909f, 0.000978f, 0.001035f, 0.001084f, 0.001135f, 0.001200f, 0.001278f, 0.001357f, 0.001429f, 0.001516f, 0.001588f,
+ 0.001724f, 0.001802f, 0.001949f, 0.002085f, 0.002230f, 0.002373f, 0.002554f, 0.002743f, 0.003000f, 0.003300f, 0.003611f, 0.003963f,
+ 0.004425f, 0.004967f, 0.005630f, 0.006424f, 0.007462f, 0.008812f, 0.010551f, 0.013184f, 0.017258f, 0.022980f, 0.377686f, 0.448242f,
+ 0.465820f, 0.474121f, 0.478760f, 0.481934f, 0.000041f, 0.000149f, 0.000126f, 0.000128f, 0.000158f, 0.000196f, 0.000174f, 0.000206f,
+ 0.000216f, 0.000223f, 0.000231f, 0.000244f, 0.000276f, 0.000291f, 0.000312f, 0.000326f, 0.000338f, 0.000374f, 0.000387f, 0.000423f,
+ 0.000430f, 0.000447f, 0.000471f, 0.000509f, 0.000538f, 0.000583f, 0.000591f, 0.000613f, 0.000659f, 0.000688f, 0.000743f, 0.000779f,
+ 0.000833f, 0.000865f, 0.000924f, 0.000966f, 0.001033f, 0.001106f, 0.001186f, 0.001245f, 0.001336f, 0.001453f, 0.001559f, 0.001685f,
+ 0.001807f, 0.001980f, 0.002207f, 0.002417f, 0.002689f, 0.003027f, 0.003418f, 0.003933f, 0.004604f, 0.005482f, 0.006641f, 0.008263f,
+ 0.011017f, 0.015778f, 0.364746f, 0.437256f, 0.456055f, 0.463623f, 0.469238f, 0.472656f, 0.000100f, 0.000089f, 0.000085f, 0.000081f,
+ 0.000101f, 0.000096f, 0.000116f, 0.000116f, 0.000119f, 0.000126f, 0.000141f, 0.000157f, 0.000149f, 0.000158f, 0.000179f, 0.000176f,
+ 0.000195f, 0.000206f, 0.000216f, 0.000222f, 0.000240f, 0.000246f, 0.000269f, 0.000279f, 0.000303f, 0.000320f, 0.000333f, 0.000345f,
+ 0.000365f, 0.000379f, 0.000409f, 0.000434f, 0.000453f, 0.000477f, 0.000511f, 0.000541f, 0.000569f, 0.000608f, 0.000656f, 0.000689f,
+ 0.000738f, 0.000795f, 0.000867f, 0.000918f, 0.001005f, 0.001087f, 0.001189f, 0.001312f, 0.001465f, 0.001656f, 0.001873f, 0.002171f,
+ 0.002546f, 0.003056f, 0.003767f, 0.004765f, 0.006390f, 0.009811f, 0.353516f, 0.426758f, 0.446045f, 0.455078f, 0.459717f, 0.464111f,
+ 0.000084f, 0.000059f, 0.000050f, 0.000049f, 0.000049f, 0.000047f, 0.000052f, 0.000058f, 0.000061f, 0.000075f, 0.000065f, 0.000066f,
+ 0.000080f, 0.000071f, 0.000076f, 0.000082f, 0.000092f, 0.000102f, 0.000100f, 0.000105f, 0.000110f, 0.000115f, 0.000121f, 0.000133f,
+ 0.000140f, 0.000146f, 0.000152f, 0.000164f, 0.000177f, 0.000185f, 0.000192f, 0.000202f, 0.000213f, 0.000224f, 0.000241f, 0.000252f,
+ 0.000268f, 0.000283f, 0.000310f, 0.000328f, 0.000348f, 0.000374f, 0.000406f, 0.000431f, 0.000470f, 0.000515f, 0.000560f, 0.000614f,
+ 0.000688f, 0.000771f, 0.000884f, 0.001019f, 0.001202f, 0.001466f, 0.001827f, 0.002369f, 0.003269f, 0.005184f, 0.341797f, 0.416016f,
+ 0.435791f, 0.445557f, 0.450928f, 0.455078f, 0.000062f, 0.000042f, 0.000035f, 0.000030f, 0.000028f, 0.000026f, 0.000024f, 0.000023f,
+ 0.000023f, 0.000023f, 0.000023f, 0.000030f, 0.000024f, 0.000024f, 0.000031f, 0.000034f, 0.000035f, 0.000037f, 0.000039f, 0.000040f,
+ 0.000043f, 0.000048f, 0.000050f, 0.000046f, 0.000051f, 0.000057f, 0.000059f, 0.000058f, 0.000063f, 0.000068f, 0.000070f, 0.000077f,
+ 0.000082f, 0.000082f, 0.000086f, 0.000093f, 0.000100f, 0.000106f, 0.000114f, 0.000120f, 0.000131f, 0.000136f, 0.000145f, 0.000161f,
+ 0.000171f, 0.000186f, 0.000204f, 0.000222f, 0.000251f, 0.000281f, 0.000318f, 0.000364f, 0.000430f, 0.000530f, 0.000672f, 0.000902f,
+ 0.001316f, 0.002153f, 0.329346f, 0.406006f, 0.426758f, 0.436035f, 0.441650f, 0.445801f, 0.000031f, 0.000020f, 0.000016f, 0.000014f,
+ 0.000014f, 0.000013f, 0.000012f, 0.000012f, 0.000011f, 0.000011f, 0.000010f, 0.000010f, 0.000010f, 0.000009f, 0.000009f, 0.000009f,
+ 0.000008f, 0.000008f, 0.000007f, 0.000007f, 0.000007f, 0.000008f, 0.000009f, 0.000010f, 0.000011f, 0.000012f, 0.000012f, 0.000014f,
+ 0.000014f, 0.000013f, 0.000015f, 0.000016f, 0.000018f, 0.000019f, 0.000019f, 0.000020f, 0.000023f, 0.000023f, 0.000025f, 0.000027f,
+ 0.000028f, 0.000031f, 0.000034f, 0.000034f, 0.000037f, 0.000041f, 0.000045f, 0.000049f, 0.000053f, 0.000059f, 0.000066f, 0.000079f,
+ 0.000093f, 0.000112f, 0.000144f, 0.000196f, 0.000307f, 0.000598f, 0.317383f, 0.394531f, 0.416504f, 0.425781f, 0.432129f, 0.436279f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000000f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f,
+ 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000002f, 0.000002f, 0.000002f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f,
+ 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000002f, 0.000002f, 0.000002f, 0.000002f,
+ 0.000002f, 0.000002f, 0.000003f, 0.000003f, 0.000004f, 0.000004f, 0.000004f, 0.000007f, 0.000010f, 0.000026f, 0.305420f, 0.384277f,
+ 0.405762f, 0.416504f, 0.423340f, 0.427246f,
+ },
+ {
+ 0.009338f, 0.028412f, 0.047394f, 0.066895f, 0.086548f, 0.105774f, 0.125854f, 0.145142f, 0.165039f, 0.184570f, 0.204712f, 0.223389f,
+ 0.243164f, 0.261719f, 0.280762f, 0.299805f, 0.318848f, 0.338135f, 0.356445f, 0.374512f, 0.393066f, 0.412354f, 0.429932f, 0.447510f,
+ 0.465576f, 0.483887f, 0.501465f, 0.518555f, 0.536133f, 0.553711f, 0.570312f, 0.587402f, 0.604492f, 0.621094f, 0.637695f, 0.653809f,
+ 0.670898f, 0.687012f, 0.702637f, 0.719238f, 0.734863f, 0.750488f, 0.765137f, 0.780762f, 0.795898f, 0.811523f, 0.825684f, 0.840820f,
+ 0.855469f, 0.870605f, 0.884277f, 0.899414f, 0.913086f, 0.926758f, 0.940918f, 0.955078f, 0.967773f, 0.981934f, 0.966797f, 0.923828f,
+ 0.894531f, 0.870605f, 0.850586f, 0.832520f, 0.008652f, 0.026825f, 0.045380f, 0.063965f, 0.082703f, 0.101807f, 0.120544f, 0.139282f,
+ 0.158569f, 0.177246f, 0.196167f, 0.214722f, 0.233521f, 0.252197f, 0.270508f, 0.289062f, 0.307861f, 0.325928f, 0.343994f, 0.361328f,
+ 0.380615f, 0.397705f, 0.415771f, 0.433594f, 0.450928f, 0.469238f, 0.485596f, 0.502930f, 0.520020f, 0.537598f, 0.553223f, 0.570801f,
+ 0.586914f, 0.603516f, 0.620117f, 0.636719f, 0.652832f, 0.668945f, 0.683594f, 0.700684f, 0.716309f, 0.731934f, 0.746582f, 0.762695f,
+ 0.777344f, 0.792480f, 0.807617f, 0.821777f, 0.836914f, 0.850586f, 0.865723f, 0.880371f, 0.894043f, 0.908691f, 0.921875f, 0.937012f,
+ 0.950195f, 0.963867f, 0.958496f, 0.917969f, 0.889648f, 0.867188f, 0.847656f, 0.830566f, 0.008293f, 0.025620f, 0.042999f, 0.061035f,
+ 0.079163f, 0.097656f, 0.115112f, 0.132812f, 0.151367f, 0.170532f, 0.188599f, 0.206787f, 0.223999f, 0.242920f, 0.259766f, 0.278809f,
+ 0.296143f, 0.313232f, 0.331055f, 0.349609f, 0.367432f, 0.385010f, 0.401611f, 0.418945f, 0.435791f, 0.453369f, 0.469727f, 0.487061f,
+ 0.503906f, 0.520508f, 0.537598f, 0.553223f, 0.569824f, 0.586426f, 0.603027f, 0.619141f, 0.634277f, 0.650879f, 0.666504f, 0.682129f,
+ 0.697754f, 0.713379f, 0.729004f, 0.743164f, 0.758301f, 0.773926f, 0.789062f, 0.803711f, 0.818359f, 0.833008f, 0.847168f, 0.862305f,
+ 0.875488f, 0.890137f, 0.903809f, 0.917480f, 0.931152f, 0.945801f, 0.950195f, 0.911133f, 0.884766f, 0.862793f, 0.844238f, 0.828125f,
+ 0.008148f, 0.024506f, 0.041016f, 0.058289f, 0.075256f, 0.092712f, 0.109802f, 0.127319f, 0.145020f, 0.162964f, 0.180298f, 0.198120f,
+ 0.215454f, 0.232300f, 0.250244f, 0.267822f, 0.285400f, 0.302734f, 0.318848f, 0.335693f, 0.354004f, 0.371582f, 0.388672f, 0.405029f,
+ 0.421143f, 0.438965f, 0.455078f, 0.472168f, 0.487549f, 0.503906f, 0.521484f, 0.537598f, 0.551758f, 0.568359f, 0.584961f, 0.601562f,
+ 0.616211f, 0.633301f, 0.648926f, 0.664062f, 0.679199f, 0.694824f, 0.709473f, 0.725098f, 0.740234f, 0.755371f, 0.770020f, 0.785156f,
+ 0.799805f, 0.813965f, 0.828125f, 0.842773f, 0.856934f, 0.871582f, 0.884766f, 0.898926f, 0.912598f, 0.926270f, 0.941895f, 0.905273f,
+ 0.879883f, 0.858887f, 0.840332f, 0.824707f, 0.007523f, 0.023010f, 0.039246f, 0.055542f, 0.072021f, 0.088257f, 0.105347f, 0.122070f,
+ 0.138306f, 0.155273f, 0.172852f, 0.189575f, 0.206421f, 0.223145f, 0.240112f, 0.256592f, 0.274170f, 0.291260f, 0.307617f, 0.323730f,
+ 0.340576f, 0.358154f, 0.374023f, 0.390137f, 0.406738f, 0.422852f, 0.440430f, 0.456543f, 0.472656f, 0.489014f, 0.504395f, 0.520996f,
+ 0.537109f, 0.552734f, 0.568848f, 0.584473f, 0.599121f, 0.615234f, 0.630859f, 0.645020f, 0.660645f, 0.677246f, 0.690918f, 0.706055f,
+ 0.721680f, 0.736328f, 0.750977f, 0.766113f, 0.780273f, 0.794922f, 0.809570f, 0.823730f, 0.837891f, 0.852539f, 0.866211f, 0.880371f,
+ 0.894531f, 0.908691f, 0.933105f, 0.898438f, 0.874023f, 0.853516f, 0.836426f, 0.821289f, 0.007339f, 0.021912f, 0.037170f, 0.052948f,
+ 0.068665f, 0.084412f, 0.100281f, 0.116333f, 0.133057f, 0.149048f, 0.164795f, 0.181274f, 0.198242f, 0.214233f, 0.230835f, 0.247314f,
+ 0.262939f, 0.279053f, 0.295898f, 0.312500f, 0.328613f, 0.344971f, 0.360107f, 0.376953f, 0.392578f, 0.408691f, 0.425293f, 0.441406f,
+ 0.456787f, 0.472656f, 0.488525f, 0.504883f, 0.520020f, 0.535156f, 0.550781f, 0.567383f, 0.582520f, 0.597656f, 0.612793f, 0.628418f,
+ 0.642578f, 0.657715f, 0.673340f, 0.688477f, 0.702637f, 0.718750f, 0.731445f, 0.748047f, 0.762207f, 0.775879f, 0.791016f, 0.804199f,
+ 0.818848f, 0.833008f, 0.847656f, 0.861328f, 0.875000f, 0.890625f, 0.924316f, 0.891602f, 0.868164f, 0.849121f, 0.832520f, 0.817871f,
+ 0.006817f, 0.021133f, 0.035675f, 0.050018f, 0.065186f, 0.080505f, 0.096069f, 0.111389f, 0.126831f, 0.142456f, 0.158203f, 0.174194f,
+ 0.189819f, 0.205444f, 0.220703f, 0.237183f, 0.253174f, 0.268555f, 0.284668f, 0.300049f, 0.316406f, 0.332275f, 0.347656f, 0.363281f,
+ 0.379395f, 0.394775f, 0.409668f, 0.426270f, 0.442139f, 0.457275f, 0.472656f, 0.488037f, 0.503906f, 0.518555f, 0.534668f, 0.548828f,
+ 0.564941f, 0.579590f, 0.595215f, 0.610352f, 0.625000f, 0.640137f, 0.654785f, 0.669434f, 0.685059f, 0.699707f, 0.713379f, 0.728027f,
+ 0.742676f, 0.758301f, 0.770996f, 0.786621f, 0.799316f, 0.813965f, 0.828613f, 0.842285f, 0.856445f, 0.871094f, 0.915527f, 0.884766f,
+ 0.862305f, 0.843750f, 0.827637f, 0.813965f, 0.006611f, 0.020111f, 0.033752f, 0.047974f, 0.062378f, 0.076843f, 0.091431f, 0.106262f,
+ 0.120911f, 0.136230f, 0.151123f, 0.166382f, 0.181396f, 0.196899f, 0.211670f, 0.227295f, 0.242554f, 0.257812f, 0.272705f, 0.288086f,
+ 0.304199f, 0.318848f, 0.334473f, 0.349609f, 0.365967f, 0.379883f, 0.395996f, 0.410889f, 0.426270f, 0.441895f, 0.457764f, 0.472412f,
+ 0.487061f, 0.502930f, 0.517090f, 0.532227f, 0.547363f, 0.563477f, 0.577637f, 0.592285f, 0.606934f, 0.621582f, 0.636230f, 0.651367f,
+ 0.665039f, 0.679688f, 0.694336f, 0.709473f, 0.724121f, 0.738770f, 0.752930f, 0.767578f, 0.780762f, 0.795410f, 0.809082f, 0.823242f,
+ 0.837891f, 0.852539f, 0.906250f, 0.877441f, 0.855957f, 0.838379f, 0.823242f, 0.809570f, 0.006153f, 0.019150f, 0.031952f, 0.045624f,
+ 0.059326f, 0.073303f, 0.087158f, 0.101562f, 0.115540f, 0.129395f, 0.144653f, 0.159180f, 0.173584f, 0.187866f, 0.203613f, 0.217651f,
+ 0.232300f, 0.247559f, 0.262207f, 0.277344f, 0.292969f, 0.307617f, 0.322021f, 0.336914f, 0.352051f, 0.367188f, 0.381592f, 0.396729f,
+ 0.411377f, 0.427002f, 0.440918f, 0.456787f, 0.471436f, 0.486572f, 0.500977f, 0.514648f, 0.530273f, 0.545410f, 0.560059f, 0.574219f,
+ 0.589355f, 0.604004f, 0.618164f, 0.632324f, 0.647461f, 0.661133f, 0.676270f, 0.691406f, 0.705078f, 0.719727f, 0.733887f, 0.748047f,
+ 0.763184f, 0.777344f, 0.791016f, 0.805176f, 0.819336f, 0.833496f, 0.896973f, 0.870117f, 0.849609f, 0.833008f, 0.818359f, 0.805176f,
+ 0.005947f, 0.018311f, 0.030731f, 0.043243f, 0.056732f, 0.069580f, 0.083435f, 0.096558f, 0.110474f, 0.123962f, 0.137695f, 0.152100f,
+ 0.166016f, 0.180054f, 0.194092f, 0.208862f, 0.222656f, 0.236816f, 0.251465f, 0.266113f, 0.281250f, 0.294922f, 0.309814f, 0.324219f,
+ 0.338623f, 0.352783f, 0.368164f, 0.382568f, 0.397461f, 0.411377f, 0.426025f, 0.441162f, 0.455078f, 0.469971f, 0.484131f, 0.499268f,
+ 0.513672f, 0.528320f, 0.542969f, 0.557129f, 0.571289f, 0.585449f, 0.599609f, 0.614258f, 0.628418f, 0.643066f, 0.657227f, 0.671875f,
+ 0.686523f, 0.700195f, 0.714355f, 0.729004f, 0.743164f, 0.756836f, 0.770996f, 0.785645f, 0.800293f, 0.814453f, 0.888184f, 0.862305f,
+ 0.843262f, 0.827148f, 0.813477f, 0.800781f, 0.005646f, 0.017136f, 0.029388f, 0.041534f, 0.053802f, 0.066162f, 0.078979f, 0.092285f,
+ 0.104980f, 0.118408f, 0.130981f, 0.144897f, 0.158203f, 0.172363f, 0.185547f, 0.199951f, 0.213501f, 0.226440f, 0.240356f, 0.254883f,
+ 0.269287f, 0.283691f, 0.297607f, 0.311279f, 0.325439f, 0.339600f, 0.353760f, 0.368408f, 0.382812f, 0.396973f, 0.410645f, 0.425049f,
+ 0.439697f, 0.454102f, 0.468262f, 0.482178f, 0.496094f, 0.510742f, 0.524902f, 0.539551f, 0.554199f, 0.568359f, 0.582031f, 0.596191f,
+ 0.610352f, 0.624023f, 0.639160f, 0.652832f, 0.667969f, 0.681152f, 0.696289f, 0.709961f, 0.723633f, 0.738770f, 0.752441f, 0.765625f,
+ 0.780273f, 0.794922f, 0.878418f, 0.855469f, 0.836914f, 0.821289f, 0.808105f, 0.796387f, 0.005478f, 0.016174f, 0.027740f, 0.038849f,
+ 0.051270f, 0.063293f, 0.075317f, 0.087402f, 0.099854f, 0.112793f, 0.125366f, 0.138184f, 0.151001f, 0.164307f, 0.177734f, 0.190918f,
+ 0.204102f, 0.217529f, 0.231079f, 0.244141f, 0.257324f, 0.271240f, 0.284668f, 0.299072f, 0.312744f, 0.326660f, 0.339600f, 0.354004f,
+ 0.368408f, 0.382324f, 0.395264f, 0.410156f, 0.423096f, 0.437500f, 0.452148f, 0.465332f, 0.480469f, 0.493408f, 0.507812f, 0.521484f,
+ 0.535645f, 0.549316f, 0.563477f, 0.578125f, 0.592285f, 0.605957f, 0.620605f, 0.634766f, 0.647949f, 0.662109f, 0.676758f, 0.691406f,
+ 0.705078f, 0.718750f, 0.732910f, 0.747559f, 0.762207f, 0.777344f, 0.869141f, 0.847656f, 0.830078f, 0.815430f, 0.802734f, 0.791504f,
+ 0.005005f, 0.015762f, 0.026657f, 0.037384f, 0.048218f, 0.059998f, 0.071594f, 0.083618f, 0.095215f, 0.107666f, 0.119141f, 0.131958f,
+ 0.144043f, 0.156128f, 0.169800f, 0.182129f, 0.194824f, 0.207031f, 0.219849f, 0.233032f, 0.247559f, 0.260010f, 0.272949f, 0.286133f,
+ 0.300293f, 0.313477f, 0.326172f, 0.339844f, 0.353516f, 0.367188f, 0.381592f, 0.394531f, 0.407959f, 0.422363f, 0.436279f, 0.449463f,
+ 0.462891f, 0.477539f, 0.490723f, 0.504395f, 0.518066f, 0.532227f, 0.545898f, 0.560059f, 0.574219f, 0.586914f, 0.602051f, 0.616211f,
+ 0.629395f, 0.644531f, 0.657227f, 0.671875f, 0.685547f, 0.699707f, 0.713867f, 0.728516f, 0.742676f, 0.756836f, 0.859375f, 0.840332f,
+ 0.823730f, 0.809082f, 0.797363f, 0.786621f, 0.004894f, 0.014786f, 0.025269f, 0.035614f, 0.045990f, 0.057129f, 0.068420f, 0.079224f,
+ 0.090698f, 0.102112f, 0.113708f, 0.125610f, 0.137817f, 0.149536f, 0.161377f, 0.174316f, 0.185791f, 0.198486f, 0.211670f, 0.223389f,
+ 0.236816f, 0.249512f, 0.261230f, 0.274414f, 0.287598f, 0.300537f, 0.313232f, 0.326904f, 0.340576f, 0.353027f, 0.366211f, 0.379883f,
+ 0.393066f, 0.406006f, 0.419678f, 0.433350f, 0.446289f, 0.460205f, 0.473633f, 0.487305f, 0.500977f, 0.515137f, 0.528320f, 0.542480f,
+ 0.554688f, 0.569824f, 0.583008f, 0.597656f, 0.610840f, 0.625488f, 0.638672f, 0.652832f, 0.666504f, 0.681152f, 0.694824f, 0.708984f,
+ 0.723145f, 0.737793f, 0.850098f, 0.833008f, 0.817383f, 0.802734f, 0.791992f, 0.780762f, 0.004536f, 0.014160f, 0.023972f, 0.033630f,
+ 0.043823f, 0.053955f, 0.064697f, 0.075195f, 0.086365f, 0.096802f, 0.108276f, 0.119751f, 0.130493f, 0.142212f, 0.153687f, 0.165405f,
+ 0.177246f, 0.189331f, 0.201538f, 0.213501f, 0.225464f, 0.237915f, 0.250244f, 0.262939f, 0.274902f, 0.288086f, 0.300781f, 0.312988f,
+ 0.326172f, 0.339600f, 0.352051f, 0.365479f, 0.377930f, 0.390625f, 0.403564f, 0.417480f, 0.430420f, 0.444092f, 0.457520f, 0.470215f,
+ 0.483643f, 0.497559f, 0.510742f, 0.524414f, 0.537598f, 0.551270f, 0.564941f, 0.579102f, 0.592285f, 0.605957f, 0.619629f, 0.633789f,
+ 0.647949f, 0.661621f, 0.675293f, 0.689453f, 0.704102f, 0.718262f, 0.840332f, 0.825195f, 0.809570f, 0.797363f, 0.786133f, 0.776367f,
+ 0.004433f, 0.013138f, 0.022720f, 0.032013f, 0.041199f, 0.051147f, 0.061462f, 0.071716f, 0.082336f, 0.091919f, 0.102722f, 0.113586f,
+ 0.124390f, 0.135010f, 0.145996f, 0.157837f, 0.168823f, 0.180054f, 0.192383f, 0.203491f, 0.215332f, 0.227417f, 0.239502f, 0.251221f,
+ 0.263672f, 0.275635f, 0.287842f, 0.300537f, 0.312500f, 0.324707f, 0.338135f, 0.350342f, 0.363037f, 0.375977f, 0.388672f, 0.401611f,
+ 0.413818f, 0.427246f, 0.440186f, 0.453613f, 0.466064f, 0.479736f, 0.492920f, 0.506836f, 0.519531f, 0.533203f, 0.546875f, 0.560059f,
+ 0.573242f, 0.587402f, 0.600098f, 0.614746f, 0.628418f, 0.642578f, 0.657227f, 0.670898f, 0.685059f, 0.699707f, 0.830566f, 0.816406f,
+ 0.802734f, 0.791016f, 0.780273f, 0.770996f, 0.004372f, 0.012619f, 0.021393f, 0.030350f, 0.039276f, 0.048523f, 0.058289f, 0.067505f,
+ 0.077393f, 0.087585f, 0.097290f, 0.107727f, 0.118225f, 0.128296f, 0.138550f, 0.149414f, 0.160278f, 0.171631f, 0.182739f, 0.193359f,
+ 0.205200f, 0.216187f, 0.228027f, 0.240234f, 0.251465f, 0.263428f, 0.275146f, 0.287598f, 0.298828f, 0.311523f, 0.323242f, 0.336182f,
+ 0.348633f, 0.360107f, 0.372803f, 0.385986f, 0.398682f, 0.411621f, 0.424072f, 0.436523f, 0.449951f, 0.462891f, 0.475098f, 0.488525f,
+ 0.501953f, 0.514648f, 0.527344f, 0.541992f, 0.555176f, 0.569336f, 0.582031f, 0.596191f, 0.609863f, 0.623047f, 0.637695f, 0.651855f,
+ 0.665527f, 0.679688f, 0.821289f, 0.808105f, 0.795410f, 0.784180f, 0.774902f, 0.765137f, 0.003937f, 0.012169f, 0.020477f, 0.028641f,
+ 0.037781f, 0.046448f, 0.055481f, 0.064209f, 0.073181f, 0.082458f, 0.092651f, 0.101990f, 0.111572f, 0.121948f, 0.132202f, 0.142212f,
+ 0.151978f, 0.162720f, 0.173340f, 0.184326f, 0.195312f, 0.206055f, 0.217163f, 0.228516f, 0.239990f, 0.250977f, 0.262695f, 0.274658f,
+ 0.285889f, 0.297363f, 0.308838f, 0.321045f, 0.333496f, 0.345459f, 0.357422f, 0.370117f, 0.382324f, 0.395020f, 0.407227f, 0.419922f,
+ 0.432617f, 0.444336f, 0.458008f, 0.470703f, 0.483398f, 0.497559f, 0.510254f, 0.522949f, 0.536133f, 0.550293f, 0.562988f, 0.577637f,
+ 0.590820f, 0.603516f, 0.618164f, 0.632324f, 0.645508f, 0.660645f, 0.811035f, 0.800293f, 0.788086f, 0.777832f, 0.768555f, 0.760254f,
+ 0.003868f, 0.011368f, 0.019257f, 0.027512f, 0.035431f, 0.043274f, 0.051880f, 0.060852f, 0.069214f, 0.078003f, 0.087524f, 0.096924f,
+ 0.105896f, 0.115112f, 0.124817f, 0.134766f, 0.144409f, 0.154663f, 0.164673f, 0.175415f, 0.184814f, 0.196289f, 0.206299f, 0.216797f,
+ 0.228394f, 0.239380f, 0.250244f, 0.260986f, 0.273193f, 0.284424f, 0.295410f, 0.307373f, 0.319092f, 0.331299f, 0.342285f, 0.354248f,
+ 0.366455f, 0.378662f, 0.390869f, 0.403809f, 0.415771f, 0.427734f, 0.440430f, 0.453369f, 0.466309f, 0.479736f, 0.492188f, 0.504883f,
+ 0.518066f, 0.531250f, 0.544922f, 0.558105f, 0.571777f, 0.584473f, 0.598633f, 0.612305f, 0.626465f, 0.641602f, 0.801758f, 0.792480f,
+ 0.781738f, 0.770508f, 0.761230f, 0.753906f, 0.003616f, 0.010872f, 0.018387f, 0.026077f, 0.033875f, 0.041351f, 0.049591f, 0.057434f,
+ 0.065674f, 0.073669f, 0.082153f, 0.091064f, 0.100098f, 0.109009f, 0.117981f, 0.127563f, 0.137207f, 0.146362f, 0.156494f, 0.165894f,
+ 0.176025f, 0.186157f, 0.196655f, 0.206421f, 0.216919f, 0.227539f, 0.237915f, 0.249268f, 0.260254f, 0.270752f, 0.282471f, 0.293945f,
+ 0.305176f, 0.316406f, 0.328125f, 0.338867f, 0.350342f, 0.361816f, 0.375244f, 0.387207f, 0.398926f, 0.411133f, 0.423584f, 0.436523f,
+ 0.448730f, 0.461182f, 0.474121f, 0.485840f, 0.499756f, 0.513672f, 0.525391f, 0.539062f, 0.552734f, 0.565918f, 0.580566f, 0.593750f,
+ 0.608398f, 0.621094f, 0.790527f, 0.783691f, 0.773926f, 0.764160f, 0.755859f, 0.747559f, 0.003450f, 0.010429f, 0.017487f, 0.024445f,
+ 0.031860f, 0.039581f, 0.046631f, 0.054718f, 0.061951f, 0.070251f, 0.078003f, 0.086121f, 0.094910f, 0.102905f, 0.111572f, 0.120300f,
+ 0.129761f, 0.138428f, 0.147217f, 0.156982f, 0.166992f, 0.176147f, 0.186157f, 0.196045f, 0.206299f, 0.216187f, 0.226318f, 0.236938f,
+ 0.247437f, 0.258301f, 0.268311f, 0.279785f, 0.290527f, 0.301758f, 0.312744f, 0.324219f, 0.335449f, 0.346680f, 0.359131f, 0.370605f,
+ 0.382812f, 0.394531f, 0.406982f, 0.419189f, 0.430908f, 0.443604f, 0.456055f, 0.468506f, 0.481445f, 0.494873f, 0.506836f, 0.520996f,
+ 0.534180f, 0.547363f, 0.561035f, 0.573730f, 0.588379f, 0.601074f, 0.780762f, 0.775879f, 0.766602f, 0.757324f, 0.748535f, 0.741699f,
+ 0.003281f, 0.009811f, 0.016174f, 0.023438f, 0.030060f, 0.037109f, 0.044464f, 0.051239f, 0.058441f, 0.066345f, 0.073792f, 0.081238f,
+ 0.089539f, 0.097229f, 0.105286f, 0.113647f, 0.122498f, 0.130615f, 0.139526f, 0.148438f, 0.157837f, 0.166626f, 0.176636f, 0.185547f,
+ 0.195312f, 0.204956f, 0.215088f, 0.224976f, 0.234863f, 0.245239f, 0.255859f, 0.266113f, 0.276367f, 0.287354f, 0.298096f, 0.309326f,
+ 0.320801f, 0.331787f, 0.343018f, 0.355225f, 0.366211f, 0.378418f, 0.389893f, 0.401611f, 0.413574f, 0.425781f, 0.438721f, 0.451416f,
+ 0.463135f, 0.476074f, 0.489014f, 0.501465f, 0.514648f, 0.528809f, 0.541992f, 0.554688f, 0.568848f, 0.582520f, 0.770508f, 0.767090f,
+ 0.758789f, 0.750488f, 0.743164f, 0.735352f, 0.002901f, 0.009422f, 0.015488f, 0.021729f, 0.028290f, 0.035278f, 0.041321f, 0.048523f,
+ 0.055420f, 0.062195f, 0.069336f, 0.076477f, 0.084412f, 0.091858f, 0.099609f, 0.107361f, 0.115112f, 0.123535f, 0.131592f, 0.140137f,
+ 0.148438f, 0.157715f, 0.166382f, 0.174927f, 0.184692f, 0.193970f, 0.203369f, 0.212646f, 0.222656f, 0.232910f, 0.242920f, 0.252197f,
+ 0.263184f, 0.273438f, 0.284180f, 0.294922f, 0.305664f, 0.316895f, 0.327881f, 0.338867f, 0.349854f, 0.361328f, 0.373291f, 0.385254f,
+ 0.397461f, 0.408691f, 0.420898f, 0.433350f, 0.445801f, 0.458252f, 0.470703f, 0.483154f, 0.496826f, 0.510254f, 0.522461f, 0.535645f,
+ 0.549805f, 0.562988f, 0.760742f, 0.758789f, 0.750488f, 0.743652f, 0.736328f, 0.729492f, 0.002861f, 0.008606f, 0.014488f, 0.021057f,
+ 0.026810f, 0.032898f, 0.038879f, 0.045532f, 0.051666f, 0.058319f, 0.065125f, 0.072449f, 0.079224f, 0.086426f, 0.093689f, 0.100830f,
+ 0.108276f, 0.116089f, 0.123962f, 0.131958f, 0.140625f, 0.148560f, 0.156494f, 0.164795f, 0.174194f, 0.183228f, 0.192017f, 0.201294f,
+ 0.210815f, 0.220093f, 0.229858f, 0.239746f, 0.249390f, 0.260010f, 0.270508f, 0.280518f, 0.290771f, 0.301758f, 0.312744f, 0.323486f,
+ 0.334473f, 0.345215f, 0.356934f, 0.368408f, 0.379883f, 0.391846f, 0.403564f, 0.416016f, 0.427490f, 0.439453f, 0.452881f, 0.465332f,
+ 0.478271f, 0.490234f, 0.503906f, 0.517090f, 0.529785f, 0.543945f, 0.750000f, 0.750000f, 0.743164f, 0.736328f, 0.729492f, 0.723145f,
+ 0.002977f, 0.008492f, 0.013931f, 0.019745f, 0.024948f, 0.030991f, 0.036804f, 0.042755f, 0.048889f, 0.055267f, 0.061737f, 0.067932f,
+ 0.074829f, 0.081116f, 0.087646f, 0.095215f, 0.102356f, 0.109436f, 0.116760f, 0.124023f, 0.131714f, 0.139648f, 0.147461f, 0.155762f,
+ 0.164185f, 0.172485f, 0.181152f, 0.189697f, 0.198730f, 0.208130f, 0.217285f, 0.226685f, 0.236572f, 0.245850f, 0.255859f, 0.265869f,
+ 0.276367f, 0.286377f, 0.297607f, 0.307861f, 0.318359f, 0.329102f, 0.340576f, 0.351807f, 0.363281f, 0.374023f, 0.386230f, 0.397949f,
+ 0.409668f, 0.422119f, 0.434082f, 0.446777f, 0.459229f, 0.471924f, 0.484863f, 0.497803f, 0.511230f, 0.525391f, 0.739746f, 0.741211f,
+ 0.735352f, 0.729004f, 0.722656f, 0.717285f, 0.002441f, 0.007896f, 0.013443f, 0.018402f, 0.023911f, 0.029343f, 0.034454f, 0.040375f,
+ 0.045868f, 0.051453f, 0.057800f, 0.063721f, 0.070068f, 0.075928f, 0.082520f, 0.089233f, 0.095703f, 0.102478f, 0.109314f, 0.116638f,
+ 0.123596f, 0.131348f, 0.138550f, 0.145996f, 0.153809f, 0.162109f, 0.170044f, 0.179199f, 0.187866f, 0.196045f, 0.205078f, 0.213745f,
+ 0.223389f, 0.233032f, 0.242554f, 0.252197f, 0.261963f, 0.271973f, 0.281982f, 0.292236f, 0.303223f, 0.312988f, 0.324463f, 0.335693f,
+ 0.346191f, 0.357910f, 0.368652f, 0.380371f, 0.391846f, 0.404541f, 0.415527f, 0.428467f, 0.440674f, 0.453369f, 0.466553f, 0.479248f,
+ 0.491455f, 0.505371f, 0.729492f, 0.732422f, 0.727539f, 0.721191f, 0.716309f, 0.709961f, 0.002457f, 0.007553f, 0.012489f, 0.017548f,
+ 0.022217f, 0.027405f, 0.032471f, 0.037689f, 0.043060f, 0.048553f, 0.054230f, 0.059631f, 0.065369f, 0.071533f, 0.077393f, 0.083069f,
+ 0.089417f, 0.096069f, 0.102356f, 0.108398f, 0.115417f, 0.122925f, 0.130127f, 0.137451f, 0.144531f, 0.152100f, 0.160156f, 0.168091f,
+ 0.176514f, 0.184570f, 0.192871f, 0.201660f, 0.210571f, 0.219238f, 0.229126f, 0.238281f, 0.248413f, 0.257812f, 0.267578f, 0.277588f,
+ 0.287354f, 0.298096f, 0.308594f, 0.319336f, 0.329590f, 0.340820f, 0.351318f, 0.363770f, 0.375732f, 0.386963f, 0.397949f, 0.409912f,
+ 0.422363f, 0.434326f, 0.446533f, 0.459473f, 0.473145f, 0.486084f, 0.718750f, 0.723633f, 0.719727f, 0.713867f, 0.708984f, 0.703613f,
+ 0.002436f, 0.006939f, 0.011612f, 0.016113f, 0.021072f, 0.025497f, 0.030640f, 0.035339f, 0.040222f, 0.045441f, 0.050690f, 0.055725f,
+ 0.060669f, 0.066589f, 0.072144f, 0.077881f, 0.083740f, 0.089294f, 0.095215f, 0.101501f, 0.108032f, 0.114868f, 0.121643f, 0.128052f,
+ 0.135010f, 0.142334f, 0.150024f, 0.157349f, 0.164917f, 0.173340f, 0.181274f, 0.189697f, 0.198120f, 0.206909f, 0.215698f, 0.224365f,
+ 0.234497f, 0.243652f, 0.252930f, 0.262695f, 0.272461f, 0.282471f, 0.292480f, 0.302979f, 0.313721f, 0.324463f, 0.335205f, 0.346436f,
+ 0.357666f, 0.369141f, 0.380859f, 0.391602f, 0.404541f, 0.416016f, 0.428467f, 0.440918f, 0.454102f, 0.466553f, 0.708496f, 0.715820f,
+ 0.711426f, 0.706055f, 0.701660f, 0.696777f, 0.002188f, 0.006599f, 0.011032f, 0.015068f, 0.019897f, 0.024048f, 0.028656f, 0.033264f,
+ 0.037720f, 0.042236f, 0.047028f, 0.051941f, 0.056824f, 0.062012f, 0.067444f, 0.072449f, 0.077942f, 0.083374f, 0.088867f, 0.094727f,
+ 0.100769f, 0.106750f, 0.112732f, 0.119263f, 0.126099f, 0.133179f, 0.139648f, 0.146729f, 0.154175f, 0.161987f, 0.170044f, 0.177612f,
+ 0.185791f, 0.194214f, 0.203125f, 0.211670f, 0.220581f, 0.229370f, 0.238770f, 0.248047f, 0.257812f, 0.267822f, 0.277344f, 0.287109f,
+ 0.297363f, 0.307861f, 0.318848f, 0.329590f, 0.341064f, 0.351562f, 0.363037f, 0.374512f, 0.385498f, 0.397461f, 0.409668f, 0.422363f,
+ 0.434326f, 0.447021f, 0.697266f, 0.706543f, 0.703125f, 0.698730f, 0.694336f, 0.689941f, 0.002024f, 0.006165f, 0.010399f, 0.014481f,
+ 0.018555f, 0.022797f, 0.026627f, 0.030869f, 0.035187f, 0.039459f, 0.043732f, 0.047943f, 0.052917f, 0.057434f, 0.062622f, 0.067261f,
+ 0.071838f, 0.077454f, 0.082581f, 0.087891f, 0.093628f, 0.099182f, 0.105469f, 0.111206f, 0.117126f, 0.123779f, 0.130371f, 0.137085f,
+ 0.143921f, 0.151001f, 0.158691f, 0.166016f, 0.173950f, 0.181641f, 0.190063f, 0.198120f, 0.206909f, 0.215698f, 0.224976f, 0.233398f,
+ 0.242798f, 0.252197f, 0.262207f, 0.271973f, 0.281738f, 0.291992f, 0.302734f, 0.313477f, 0.323242f, 0.334229f, 0.345459f, 0.355957f,
+ 0.368652f, 0.380615f, 0.391602f, 0.403809f, 0.415771f, 0.428467f, 0.686523f, 0.696777f, 0.695312f, 0.691895f, 0.687500f, 0.683105f,
+ 0.001931f, 0.005970f, 0.009651f, 0.013557f, 0.017136f, 0.021088f, 0.024902f, 0.028748f, 0.032623f, 0.036743f, 0.040833f, 0.044983f,
+ 0.049591f, 0.053467f, 0.057800f, 0.062500f, 0.066833f, 0.071533f, 0.076538f, 0.081238f, 0.086670f, 0.092224f, 0.097290f, 0.103088f,
+ 0.108887f, 0.114990f, 0.120972f, 0.127197f, 0.134277f, 0.140503f, 0.147705f, 0.154663f, 0.162231f, 0.169922f, 0.177612f, 0.185303f,
+ 0.193604f, 0.201904f, 0.210815f, 0.219238f, 0.228516f, 0.237427f, 0.247070f, 0.256592f, 0.265869f, 0.275879f, 0.285645f, 0.295898f,
+ 0.306396f, 0.317139f, 0.328369f, 0.338623f, 0.350342f, 0.362305f, 0.374023f, 0.385010f, 0.397461f, 0.410156f, 0.675781f, 0.687988f,
+ 0.687012f, 0.683594f, 0.680664f, 0.676270f, 0.001725f, 0.005436f, 0.009171f, 0.012589f, 0.016190f, 0.019485f, 0.023132f, 0.026978f,
+ 0.030899f, 0.034180f, 0.037659f, 0.041565f, 0.045074f, 0.049438f, 0.053345f, 0.057739f, 0.061768f, 0.065918f, 0.070679f, 0.075073f,
+ 0.080078f, 0.084656f, 0.089966f, 0.095215f, 0.100464f, 0.106445f, 0.112000f, 0.117615f, 0.124207f, 0.130737f, 0.136719f, 0.144043f,
+ 0.151123f, 0.158081f, 0.165405f, 0.173096f, 0.181152f, 0.189087f, 0.197510f, 0.205688f, 0.214600f, 0.223145f, 0.232178f, 0.241699f,
+ 0.250732f, 0.260254f, 0.270264f, 0.279785f, 0.289795f, 0.300293f, 0.310791f, 0.322510f, 0.333496f, 0.344238f, 0.355713f, 0.367188f,
+ 0.379395f, 0.392090f, 0.664551f, 0.678711f, 0.678223f, 0.675781f, 0.672852f, 0.669922f, 0.001741f, 0.005077f, 0.008522f, 0.011810f,
+ 0.014946f, 0.018524f, 0.021332f, 0.024872f, 0.028519f, 0.031799f, 0.034973f, 0.038727f, 0.041992f, 0.045654f, 0.049072f, 0.052856f,
+ 0.056671f, 0.060638f, 0.064819f, 0.069092f, 0.073425f, 0.078125f, 0.082886f, 0.087280f, 0.092651f, 0.098206f, 0.103638f, 0.109192f,
+ 0.114563f, 0.120667f, 0.126709f, 0.133057f, 0.139771f, 0.146851f, 0.153931f, 0.160767f, 0.168457f, 0.175903f, 0.183838f, 0.192505f,
+ 0.200195f, 0.208618f, 0.217407f, 0.226562f, 0.236084f, 0.245239f, 0.254639f, 0.263672f, 0.273926f, 0.283447f, 0.294189f, 0.304932f,
+ 0.315674f, 0.326172f, 0.337402f, 0.348877f, 0.360107f, 0.373291f, 0.653809f, 0.670410f, 0.669922f, 0.667480f, 0.665527f, 0.662109f,
+ 0.001639f, 0.004951f, 0.007996f, 0.010857f, 0.013779f, 0.016968f, 0.019974f, 0.023392f, 0.026001f, 0.029373f, 0.032013f, 0.035370f,
+ 0.038513f, 0.041992f, 0.044586f, 0.048706f, 0.052124f, 0.055634f, 0.059723f, 0.063354f, 0.067444f, 0.071289f, 0.075745f, 0.080444f,
+ 0.085022f, 0.089722f, 0.095032f, 0.100220f, 0.105347f, 0.111206f, 0.117126f, 0.123108f, 0.129395f, 0.135620f, 0.142090f, 0.148682f,
+ 0.156372f, 0.163574f, 0.170898f, 0.178711f, 0.186890f, 0.194580f, 0.203613f, 0.211426f, 0.220459f, 0.229492f, 0.238281f, 0.248169f,
+ 0.257324f, 0.267578f, 0.277832f, 0.287354f, 0.298340f, 0.308350f, 0.319824f, 0.331543f, 0.342041f, 0.354248f, 0.641602f, 0.660645f,
+ 0.662109f, 0.660645f, 0.658203f, 0.654785f, 0.001569f, 0.004539f, 0.007538f, 0.010368f, 0.013359f, 0.016006f, 0.018539f, 0.021210f,
+ 0.024384f, 0.026855f, 0.029892f, 0.032471f, 0.035034f, 0.038177f, 0.041199f, 0.044434f, 0.047485f, 0.050781f, 0.054321f, 0.057953f,
+ 0.061523f, 0.065430f, 0.069275f, 0.073547f, 0.077820f, 0.082092f, 0.086731f, 0.091736f, 0.096985f, 0.101990f, 0.107361f, 0.112549f,
+ 0.118774f, 0.124878f, 0.131104f, 0.137573f, 0.144409f, 0.150635f, 0.157837f, 0.165283f, 0.173340f, 0.181274f, 0.188599f, 0.197510f,
+ 0.205933f, 0.214600f, 0.223633f, 0.232056f, 0.241577f, 0.251709f, 0.261230f, 0.270996f, 0.281250f, 0.291260f, 0.302246f, 0.313477f,
+ 0.323730f, 0.336182f, 0.630859f, 0.651855f, 0.652832f, 0.652344f, 0.650391f, 0.647461f, 0.001558f, 0.004139f, 0.007103f, 0.009560f,
+ 0.012077f, 0.014313f, 0.016983f, 0.019653f, 0.021988f, 0.024490f, 0.027023f, 0.029526f, 0.031891f, 0.034821f, 0.037903f, 0.040192f,
+ 0.043457f, 0.046417f, 0.049316f, 0.052795f, 0.055725f, 0.059357f, 0.063354f, 0.066895f, 0.070740f, 0.074890f, 0.078979f, 0.083801f,
+ 0.088440f, 0.093018f, 0.097961f, 0.103394f, 0.108704f, 0.114563f, 0.120239f, 0.126343f, 0.132690f, 0.139038f, 0.145874f, 0.152710f,
+ 0.159912f, 0.168091f, 0.175537f, 0.183228f, 0.191650f, 0.199707f, 0.208130f, 0.216797f, 0.226074f, 0.235352f, 0.244507f, 0.254395f,
+ 0.264404f, 0.274414f, 0.285156f, 0.296631f, 0.307373f, 0.318604f, 0.619141f, 0.643066f, 0.644531f, 0.644043f, 0.642578f, 0.639648f,
+ 0.001314f, 0.004002f, 0.006603f, 0.009056f, 0.011490f, 0.013184f, 0.015587f, 0.017883f, 0.020157f, 0.022415f, 0.024582f, 0.027206f,
+ 0.029160f, 0.031677f, 0.034088f, 0.036530f, 0.039337f, 0.042206f, 0.044891f, 0.047729f, 0.050751f, 0.053955f, 0.057312f, 0.060486f,
+ 0.064148f, 0.068054f, 0.071960f, 0.075867f, 0.079895f, 0.084595f, 0.089172f, 0.094238f, 0.098999f, 0.104492f, 0.109802f, 0.115173f,
+ 0.121338f, 0.127686f, 0.134033f, 0.140991f, 0.147095f, 0.154541f, 0.161865f, 0.169800f, 0.177368f, 0.185547f, 0.193848f, 0.201904f,
+ 0.211060f, 0.219116f, 0.229004f, 0.238525f, 0.248047f, 0.257812f, 0.267822f, 0.277832f, 0.289062f, 0.300537f, 0.607910f, 0.633301f,
+ 0.636230f, 0.635742f, 0.634766f, 0.633301f, 0.001217f, 0.003571f, 0.005947f, 0.008011f, 0.010391f, 0.012207f, 0.014313f, 0.016617f,
+ 0.018280f, 0.020523f, 0.022537f, 0.024475f, 0.026443f, 0.028778f, 0.030884f, 0.032867f, 0.035553f, 0.037872f, 0.040375f, 0.042938f,
+ 0.045593f, 0.048431f, 0.051605f, 0.054688f, 0.057953f, 0.061279f, 0.065002f, 0.068665f, 0.072266f, 0.076294f, 0.080872f, 0.085083f,
+ 0.089783f, 0.094482f, 0.099915f, 0.104736f, 0.110901f, 0.116272f, 0.122314f, 0.128784f, 0.134888f, 0.142090f, 0.148560f, 0.155884f,
+ 0.163574f, 0.171753f, 0.179077f, 0.187500f, 0.195679f, 0.204346f, 0.213745f, 0.222656f, 0.231812f, 0.241455f, 0.250977f, 0.261230f,
+ 0.272461f, 0.282959f, 0.596680f, 0.623535f, 0.627441f, 0.627930f, 0.627441f, 0.625000f, 0.001111f, 0.003542f, 0.005569f, 0.007504f,
+ 0.009338f, 0.011452f, 0.012939f, 0.015030f, 0.016678f, 0.018326f, 0.020203f, 0.022217f, 0.023788f, 0.025604f, 0.027771f, 0.029877f,
+ 0.031860f, 0.033813f, 0.036102f, 0.038605f, 0.040985f, 0.043579f, 0.046448f, 0.049042f, 0.051849f, 0.055054f, 0.058319f, 0.061615f,
+ 0.065125f, 0.068909f, 0.072815f, 0.076843f, 0.080872f, 0.085571f, 0.089905f, 0.095398f, 0.100159f, 0.105713f, 0.111206f, 0.116882f,
+ 0.122925f, 0.129517f, 0.135742f, 0.142822f, 0.149902f, 0.157349f, 0.165161f, 0.172852f, 0.181152f, 0.189331f, 0.198120f, 0.206909f,
+ 0.215820f, 0.225342f, 0.235474f, 0.245239f, 0.254883f, 0.266602f, 0.584473f, 0.614746f, 0.619141f, 0.619629f, 0.619141f, 0.618164f,
+ 0.001149f, 0.003147f, 0.004826f, 0.006886f, 0.008629f, 0.010452f, 0.012024f, 0.013359f, 0.015175f, 0.016647f, 0.018143f, 0.019882f,
+ 0.021332f, 0.023026f, 0.024902f, 0.026550f, 0.028397f, 0.030045f, 0.032318f, 0.034393f, 0.036682f, 0.038910f, 0.041107f, 0.043671f,
+ 0.046295f, 0.048950f, 0.051819f, 0.054993f, 0.058258f, 0.061523f, 0.065063f, 0.068481f, 0.072510f, 0.076965f, 0.081055f, 0.085510f,
+ 0.090393f, 0.095093f, 0.100342f, 0.105774f, 0.111694f, 0.117371f, 0.124084f, 0.130371f, 0.136963f, 0.143921f, 0.151245f, 0.159058f,
+ 0.166626f, 0.174927f, 0.182983f, 0.191650f, 0.200195f, 0.209473f, 0.218750f, 0.228149f, 0.238037f, 0.249146f, 0.572266f, 0.604980f,
+ 0.609863f, 0.611328f, 0.610352f, 0.611328f, 0.001009f, 0.003059f, 0.004620f, 0.006283f, 0.007881f, 0.009415f, 0.010864f, 0.011940f,
+ 0.013443f, 0.014847f, 0.016403f, 0.017700f, 0.019012f, 0.020493f, 0.021927f, 0.023697f, 0.025177f, 0.026947f, 0.028732f, 0.030472f,
+ 0.032654f, 0.034302f, 0.036591f, 0.038757f, 0.041046f, 0.043488f, 0.045837f, 0.048706f, 0.051544f, 0.054810f, 0.057770f, 0.061188f,
+ 0.064331f, 0.068237f, 0.072083f, 0.076416f, 0.080872f, 0.085388f, 0.090149f, 0.095276f, 0.100403f, 0.105896f, 0.111877f, 0.117798f,
+ 0.124329f, 0.130859f, 0.138062f, 0.145020f, 0.152710f, 0.160034f, 0.168335f, 0.176514f, 0.185059f, 0.193481f, 0.203125f, 0.212158f,
+ 0.221924f, 0.232178f, 0.562500f, 0.594727f, 0.601074f, 0.602539f, 0.603516f, 0.602539f, 0.000865f, 0.002674f, 0.004444f, 0.005615f,
+ 0.007233f, 0.008430f, 0.009827f, 0.010880f, 0.011917f, 0.013206f, 0.014412f, 0.015717f, 0.016876f, 0.018173f, 0.019501f, 0.020950f,
+ 0.022217f, 0.023773f, 0.025284f, 0.026749f, 0.028610f, 0.030151f, 0.032166f, 0.034149f, 0.036041f, 0.038330f, 0.040558f, 0.042877f,
+ 0.045532f, 0.048157f, 0.050934f, 0.053894f, 0.056946f, 0.060303f, 0.063843f, 0.067566f, 0.071472f, 0.075806f, 0.080261f, 0.084778f,
+ 0.089600f, 0.094971f, 0.100220f, 0.105896f, 0.111877f, 0.118103f, 0.125000f, 0.131348f, 0.138550f, 0.146362f, 0.153687f, 0.161987f,
+ 0.169678f, 0.178223f, 0.187134f, 0.196045f, 0.205811f, 0.215698f, 0.549805f, 0.584961f, 0.592773f, 0.594238f, 0.593750f, 0.595215f,
+ 0.000951f, 0.002476f, 0.003956f, 0.005062f, 0.006268f, 0.007637f, 0.008888f, 0.009666f, 0.010628f, 0.011810f, 0.012856f, 0.013878f,
+ 0.014946f, 0.015900f, 0.017227f, 0.018356f, 0.019592f, 0.020889f, 0.022003f, 0.023438f, 0.025101f, 0.026489f, 0.028122f, 0.029739f,
+ 0.031555f, 0.033295f, 0.035431f, 0.037537f, 0.039795f, 0.041962f, 0.044647f, 0.047302f, 0.049957f, 0.052979f, 0.056122f, 0.059387f,
+ 0.062927f, 0.066956f, 0.070679f, 0.074951f, 0.079468f, 0.084167f, 0.089294f, 0.094482f, 0.100098f, 0.106018f, 0.112061f, 0.118835f,
+ 0.125366f, 0.132446f, 0.139893f, 0.147827f, 0.155762f, 0.163574f, 0.172607f, 0.180786f, 0.190063f, 0.199951f, 0.536621f, 0.576172f,
+ 0.583496f, 0.586914f, 0.587402f, 0.586914f, 0.000788f, 0.002115f, 0.003592f, 0.004780f, 0.005939f, 0.006615f, 0.007740f, 0.008598f,
+ 0.009514f, 0.010376f, 0.011200f, 0.012138f, 0.013016f, 0.014069f, 0.014977f, 0.015961f, 0.016922f, 0.018036f, 0.019043f, 0.020447f,
+ 0.021606f, 0.022995f, 0.024323f, 0.025864f, 0.027344f, 0.028946f, 0.030731f, 0.032593f, 0.034515f, 0.036530f, 0.038910f, 0.041016f,
+ 0.043274f, 0.046021f, 0.048981f, 0.051819f, 0.055176f, 0.058472f, 0.062012f, 0.065857f, 0.069946f, 0.074219f, 0.078796f, 0.083801f,
+ 0.088806f, 0.094299f, 0.100281f, 0.106018f, 0.112793f, 0.119446f, 0.126343f, 0.133545f, 0.141357f, 0.149292f, 0.157104f, 0.165894f,
+ 0.174683f, 0.184326f, 0.524902f, 0.566895f, 0.575195f, 0.576660f, 0.579102f, 0.579590f, 0.000661f, 0.001961f, 0.003382f, 0.004311f,
+ 0.005161f, 0.006062f, 0.006737f, 0.007427f, 0.008286f, 0.008995f, 0.009857f, 0.010368f, 0.011230f, 0.011955f, 0.012833f, 0.013786f,
+ 0.014565f, 0.015480f, 0.016647f, 0.017578f, 0.018677f, 0.019806f, 0.020950f, 0.022263f, 0.023651f, 0.024994f, 0.026306f, 0.027863f,
+ 0.029724f, 0.031525f, 0.033325f, 0.035370f, 0.037292f, 0.039673f, 0.042114f, 0.044769f, 0.047546f, 0.050537f, 0.053680f, 0.057098f,
+ 0.060852f, 0.064514f, 0.069031f, 0.073303f, 0.078064f, 0.083069f, 0.088379f, 0.094238f, 0.100220f, 0.106689f, 0.113342f, 0.120300f,
+ 0.127563f, 0.135132f, 0.142700f, 0.151245f, 0.160034f, 0.168823f, 0.512695f, 0.557129f, 0.566406f, 0.569824f, 0.569824f, 0.571289f,
+ 0.000757f, 0.001709f, 0.002844f, 0.003582f, 0.004448f, 0.005192f, 0.005989f, 0.006519f, 0.007038f, 0.007801f, 0.008453f, 0.009071f,
+ 0.009727f, 0.010391f, 0.011009f, 0.011726f, 0.012650f, 0.013184f, 0.014107f, 0.014977f, 0.015900f, 0.016800f, 0.017776f, 0.018936f,
+ 0.020172f, 0.021271f, 0.022446f, 0.023697f, 0.025055f, 0.026703f, 0.028397f, 0.030014f, 0.031921f, 0.033905f, 0.035919f, 0.038177f,
+ 0.040680f, 0.043243f, 0.045898f, 0.049072f, 0.052216f, 0.055725f, 0.059784f, 0.063538f, 0.067688f, 0.072327f, 0.077271f, 0.082764f,
+ 0.088379f, 0.094299f, 0.100708f, 0.107239f, 0.114136f, 0.121582f, 0.128906f, 0.136963f, 0.145630f, 0.153564f, 0.500977f, 0.547852f,
+ 0.556641f, 0.561523f, 0.562500f, 0.563965f, 0.000704f, 0.001769f, 0.002542f, 0.003523f, 0.004036f, 0.004562f, 0.005032f, 0.005661f,
+ 0.006176f, 0.006542f, 0.007072f, 0.007698f, 0.008339f, 0.008827f, 0.009323f, 0.010094f, 0.010757f, 0.011276f, 0.012093f, 0.012733f,
+ 0.013489f, 0.014488f, 0.015244f, 0.016006f, 0.017151f, 0.017975f, 0.018967f, 0.020142f, 0.021255f, 0.022552f, 0.023880f, 0.025314f,
+ 0.026840f, 0.028503f, 0.030441f, 0.032166f, 0.034424f, 0.036438f, 0.039001f, 0.041656f, 0.044464f, 0.047455f, 0.050842f, 0.054443f,
+ 0.058167f, 0.062286f, 0.066956f, 0.071899f, 0.076904f, 0.082458f, 0.088501f, 0.094482f, 0.101196f, 0.108337f, 0.115662f, 0.123352f,
+ 0.130981f, 0.139282f, 0.489746f, 0.538574f, 0.547852f, 0.551270f, 0.554688f, 0.555176f, 0.000579f, 0.001450f, 0.002396f, 0.002857f,
+ 0.003454f, 0.004032f, 0.004356f, 0.004791f, 0.005333f, 0.005718f, 0.006130f, 0.006485f, 0.007042f, 0.007473f, 0.007988f, 0.008476f,
+ 0.008865f, 0.009613f, 0.010086f, 0.010651f, 0.011345f, 0.012047f, 0.012764f, 0.013435f, 0.014282f, 0.015144f, 0.015884f, 0.016846f,
+ 0.017868f, 0.018814f, 0.020050f, 0.021164f, 0.022507f, 0.023773f, 0.025192f, 0.026978f, 0.028564f, 0.030640f, 0.032623f, 0.034882f,
+ 0.037231f, 0.039886f, 0.042786f, 0.046143f, 0.049286f, 0.052979f, 0.057098f, 0.061279f, 0.066223f, 0.071167f, 0.076660f, 0.082581f,
+ 0.088989f, 0.095581f, 0.102661f, 0.109863f, 0.117737f, 0.125488f, 0.476807f, 0.528320f, 0.538574f, 0.543945f, 0.546875f, 0.546875f,
+ 0.000510f, 0.001428f, 0.002037f, 0.002613f, 0.003086f, 0.003290f, 0.003672f, 0.004108f, 0.004345f, 0.004768f, 0.005035f, 0.005470f,
+ 0.005959f, 0.006207f, 0.006599f, 0.007095f, 0.007568f, 0.008003f, 0.008377f, 0.008904f, 0.009575f, 0.010010f, 0.010643f, 0.011131f,
+ 0.011871f, 0.012535f, 0.013199f, 0.014038f, 0.014839f, 0.015640f, 0.016586f, 0.017502f, 0.018585f, 0.019745f, 0.021088f, 0.022354f,
+ 0.023727f, 0.025253f, 0.026962f, 0.028870f, 0.030762f, 0.033051f, 0.035492f, 0.038177f, 0.041229f, 0.044403f, 0.048004f, 0.051880f,
+ 0.056213f, 0.060516f, 0.065857f, 0.071045f, 0.077271f, 0.083374f, 0.090027f, 0.096863f, 0.104492f, 0.112183f, 0.463623f, 0.518066f,
+ 0.529785f, 0.535156f, 0.538086f, 0.540039f, 0.000473f, 0.001222f, 0.001771f, 0.002117f, 0.002323f, 0.002796f, 0.003096f, 0.003355f,
+ 0.003601f, 0.003975f, 0.004295f, 0.004543f, 0.004833f, 0.005142f, 0.005455f, 0.005848f, 0.006165f, 0.006535f, 0.006947f, 0.007370f,
+ 0.007809f, 0.008240f, 0.008690f, 0.009216f, 0.009758f, 0.010223f, 0.010925f, 0.011536f, 0.012146f, 0.012833f, 0.013573f, 0.014389f,
+ 0.015244f, 0.016220f, 0.017120f, 0.018219f, 0.019379f, 0.020599f, 0.021988f, 0.023514f, 0.025131f, 0.027054f, 0.029037f, 0.031311f,
+ 0.033752f, 0.036591f, 0.039520f, 0.042999f, 0.046661f, 0.050873f, 0.055603f, 0.060333f, 0.066101f, 0.071960f, 0.078491f, 0.084961f,
+ 0.091797f, 0.099426f, 0.452148f, 0.508301f, 0.520508f, 0.526367f, 0.528809f, 0.530273f, 0.000299f, 0.001057f, 0.001329f, 0.001771f,
+ 0.001957f, 0.002350f, 0.002483f, 0.002697f, 0.002964f, 0.003181f, 0.003441f, 0.003653f, 0.003904f, 0.004238f, 0.004501f, 0.004738f,
+ 0.005024f, 0.005390f, 0.005657f, 0.005985f, 0.006279f, 0.006714f, 0.007053f, 0.007507f, 0.007881f, 0.008369f, 0.008774f, 0.009300f,
+ 0.009888f, 0.010483f, 0.011093f, 0.011627f, 0.012398f, 0.013130f, 0.013855f, 0.014717f, 0.015686f, 0.016739f, 0.017761f, 0.018890f,
+ 0.020248f, 0.021698f, 0.023376f, 0.025131f, 0.027237f, 0.029556f, 0.032166f, 0.035004f, 0.038208f, 0.041962f, 0.045868f, 0.050507f,
+ 0.055359f, 0.060852f, 0.066772f, 0.073242f, 0.080017f, 0.087097f, 0.440674f, 0.498047f, 0.511719f, 0.517090f, 0.520508f, 0.522949f,
+ 0.000427f, 0.001020f, 0.001253f, 0.001431f, 0.001690f, 0.001900f, 0.002018f, 0.002304f, 0.002481f, 0.002569f, 0.002731f, 0.002998f,
+ 0.003157f, 0.003424f, 0.003592f, 0.003838f, 0.004017f, 0.004253f, 0.004551f, 0.004776f, 0.005100f, 0.005379f, 0.005699f, 0.005932f,
+ 0.006290f, 0.006630f, 0.007038f, 0.007465f, 0.007927f, 0.008286f, 0.008858f, 0.009293f, 0.009888f, 0.010429f, 0.011086f, 0.011765f,
+ 0.012482f, 0.013298f, 0.014168f, 0.015068f, 0.016129f, 0.017288f, 0.018585f, 0.019943f, 0.021622f, 0.023361f, 0.025436f, 0.027847f,
+ 0.030655f, 0.033447f, 0.037079f, 0.041229f, 0.045776f, 0.050568f, 0.056061f, 0.062317f, 0.068726f, 0.075684f, 0.427734f, 0.488525f,
+ 0.502441f, 0.508789f, 0.513184f, 0.513672f, 0.000255f, 0.000597f, 0.001032f, 0.001150f, 0.001353f, 0.001493f, 0.001608f, 0.001750f,
+ 0.001933f, 0.002062f, 0.002178f, 0.002302f, 0.002474f, 0.002670f, 0.002872f, 0.002995f, 0.003147f, 0.003298f, 0.003565f, 0.003729f,
+ 0.003941f, 0.004219f, 0.004436f, 0.004719f, 0.005005f, 0.005230f, 0.005489f, 0.005806f, 0.006191f, 0.006496f, 0.006897f, 0.007267f,
+ 0.007671f, 0.008179f, 0.008636f, 0.009163f, 0.009766f, 0.010368f, 0.011047f, 0.011810f, 0.012611f, 0.013527f, 0.014519f, 0.015640f,
+ 0.016800f, 0.018265f, 0.019897f, 0.021698f, 0.023895f, 0.026260f, 0.029175f, 0.032715f, 0.036682f, 0.041168f, 0.045929f, 0.051758f,
+ 0.057922f, 0.064575f, 0.415771f, 0.478271f, 0.493652f, 0.500000f, 0.503906f, 0.505859f, 0.000255f, 0.000544f, 0.000863f, 0.000994f,
+ 0.001086f, 0.001183f, 0.001317f, 0.001328f, 0.001491f, 0.001608f, 0.001716f, 0.001851f, 0.001943f, 0.002075f, 0.002161f, 0.002319f,
+ 0.002426f, 0.002596f, 0.002741f, 0.002884f, 0.003088f, 0.003265f, 0.003391f, 0.003620f, 0.003777f, 0.004005f, 0.004215f, 0.004452f,
+ 0.004734f, 0.004963f, 0.005341f, 0.005577f, 0.005875f, 0.006271f, 0.006603f, 0.006996f, 0.007450f, 0.007919f, 0.008446f, 0.009003f,
+ 0.009674f, 0.010338f, 0.011101f, 0.011909f, 0.012917f, 0.013977f, 0.015190f, 0.016495f, 0.018112f, 0.020325f, 0.022415f, 0.025146f,
+ 0.028473f, 0.032349f, 0.036804f, 0.041992f, 0.047913f, 0.054077f, 0.404541f, 0.468506f, 0.484131f, 0.490967f, 0.495361f, 0.498291f,
+ 0.000377f, 0.000440f, 0.000606f, 0.000685f, 0.000735f, 0.000876f, 0.000929f, 0.001035f, 0.001068f, 0.001157f, 0.001307f, 0.001381f,
+ 0.001473f, 0.001595f, 0.001664f, 0.001708f, 0.001850f, 0.001957f, 0.002043f, 0.002195f, 0.002291f, 0.002422f, 0.002571f, 0.002687f,
+ 0.002842f, 0.002979f, 0.003183f, 0.003345f, 0.003532f, 0.003794f, 0.004002f, 0.004154f, 0.004429f, 0.004635f, 0.004967f, 0.005253f,
+ 0.005573f, 0.005909f, 0.006275f, 0.006695f, 0.007183f, 0.007660f, 0.008316f, 0.008934f, 0.009644f, 0.010429f, 0.011360f, 0.012497f,
+ 0.013634f, 0.014977f, 0.016663f, 0.018875f, 0.021423f, 0.024643f, 0.028549f, 0.033020f, 0.038483f, 0.044525f, 0.391602f, 0.458984f,
+ 0.474854f, 0.482178f, 0.488037f, 0.489990f, 0.000159f, 0.000401f, 0.000450f, 0.000522f, 0.000605f, 0.000634f, 0.000728f, 0.000702f,
+ 0.000808f, 0.000882f, 0.000959f, 0.000991f, 0.001043f, 0.001112f, 0.001205f, 0.001245f, 0.001357f, 0.001419f, 0.001513f, 0.001546f,
+ 0.001648f, 0.001752f, 0.001863f, 0.001942f, 0.002056f, 0.002159f, 0.002289f, 0.002392f, 0.002506f, 0.002697f, 0.002827f, 0.003023f,
+ 0.003172f, 0.003330f, 0.003542f, 0.003750f, 0.004017f, 0.004292f, 0.004559f, 0.004871f, 0.005161f, 0.005539f, 0.005932f, 0.006416f,
+ 0.006973f, 0.007526f, 0.008232f, 0.008980f, 0.009918f, 0.010895f, 0.012085f, 0.013680f, 0.015472f, 0.017975f, 0.021103f, 0.025146f,
+ 0.029938f, 0.035645f, 0.379395f, 0.448486f, 0.465820f, 0.473633f, 0.478760f, 0.481689f, 0.000112f, 0.000220f, 0.000321f, 0.000322f,
+ 0.000401f, 0.000489f, 0.000469f, 0.000510f, 0.000568f, 0.000653f, 0.000659f, 0.000676f, 0.000703f, 0.000789f, 0.000811f, 0.000886f,
+ 0.000888f, 0.000994f, 0.001048f, 0.001096f, 0.001155f, 0.001220f, 0.001289f, 0.001357f, 0.001431f, 0.001496f, 0.001599f, 0.001675f,
+ 0.001759f, 0.001894f, 0.001965f, 0.002083f, 0.002193f, 0.002310f, 0.002464f, 0.002634f, 0.002758f, 0.002949f, 0.003134f, 0.003319f,
+ 0.003551f, 0.003830f, 0.004120f, 0.004440f, 0.004784f, 0.005188f, 0.005680f, 0.006222f, 0.006886f, 0.007614f, 0.008461f, 0.009529f,
+ 0.010864f, 0.012596f, 0.014961f, 0.018097f, 0.022263f, 0.027466f, 0.367920f, 0.438232f, 0.456543f, 0.465332f, 0.470215f, 0.472900f,
+ 0.000140f, 0.000219f, 0.000241f, 0.000245f, 0.000290f, 0.000291f, 0.000302f, 0.000342f, 0.000380f, 0.000409f, 0.000408f, 0.000485f,
+ 0.000473f, 0.000527f, 0.000556f, 0.000575f, 0.000630f, 0.000642f, 0.000673f, 0.000711f, 0.000762f, 0.000800f, 0.000852f, 0.000886f,
+ 0.000952f, 0.000982f, 0.001049f, 0.001108f, 0.001159f, 0.001220f, 0.001281f, 0.001369f, 0.001454f, 0.001522f, 0.001595f, 0.001695f,
+ 0.001839f, 0.001928f, 0.002068f, 0.002209f, 0.002337f, 0.002504f, 0.002686f, 0.002876f, 0.003139f, 0.003437f, 0.003723f, 0.004078f,
+ 0.004509f, 0.005009f, 0.005615f, 0.006332f, 0.007317f, 0.008461f, 0.009926f, 0.012154f, 0.015640f, 0.020325f, 0.356445f, 0.429199f,
+ 0.447266f, 0.456299f, 0.462158f, 0.464844f, 0.000048f, 0.000154f, 0.000141f, 0.000147f, 0.000174f, 0.000207f, 0.000188f, 0.000221f,
+ 0.000233f, 0.000242f, 0.000248f, 0.000271f, 0.000299f, 0.000312f, 0.000337f, 0.000350f, 0.000367f, 0.000403f, 0.000416f, 0.000458f,
+ 0.000465f, 0.000483f, 0.000507f, 0.000546f, 0.000576f, 0.000625f, 0.000637f, 0.000659f, 0.000705f, 0.000742f, 0.000797f, 0.000837f,
+ 0.000890f, 0.000925f, 0.000978f, 0.001036f, 0.001103f, 0.001181f, 0.001253f, 0.001329f, 0.001421f, 0.001529f, 0.001647f, 0.001782f,
+ 0.001906f, 0.002075f, 0.002291f, 0.002483f, 0.002758f, 0.003059f, 0.003450f, 0.003906f, 0.004536f, 0.005306f, 0.006325f, 0.007713f,
+ 0.010101f, 0.014084f, 0.343262f, 0.418457f, 0.437744f, 0.447510f, 0.452881f, 0.456543f, 0.000099f, 0.000100f, 0.000091f, 0.000085f,
+ 0.000105f, 0.000099f, 0.000127f, 0.000127f, 0.000130f, 0.000137f, 0.000152f, 0.000164f, 0.000164f, 0.000172f, 0.000195f, 0.000186f,
+ 0.000209f, 0.000222f, 0.000231f, 0.000241f, 0.000258f, 0.000266f, 0.000290f, 0.000301f, 0.000324f, 0.000343f, 0.000357f, 0.000369f,
+ 0.000392f, 0.000409f, 0.000440f, 0.000463f, 0.000484f, 0.000513f, 0.000544f, 0.000578f, 0.000607f, 0.000650f, 0.000702f, 0.000737f,
+ 0.000787f, 0.000846f, 0.000918f, 0.000977f, 0.001062f, 0.001146f, 0.001259f, 0.001379f, 0.001524f, 0.001701f, 0.001924f, 0.002207f,
+ 0.002542f, 0.003006f, 0.003628f, 0.004494f, 0.005821f, 0.008774f, 0.332031f, 0.409180f, 0.428467f, 0.438965f, 0.444336f, 0.447998f,
+ 0.000082f, 0.000057f, 0.000048f, 0.000051f, 0.000055f, 0.000054f, 0.000057f, 0.000064f, 0.000066f, 0.000079f, 0.000070f, 0.000070f,
+ 0.000084f, 0.000078f, 0.000084f, 0.000091f, 0.000099f, 0.000108f, 0.000108f, 0.000114f, 0.000119f, 0.000124f, 0.000129f, 0.000144f,
+ 0.000151f, 0.000158f, 0.000163f, 0.000176f, 0.000188f, 0.000196f, 0.000208f, 0.000220f, 0.000227f, 0.000239f, 0.000259f, 0.000273f,
+ 0.000290f, 0.000303f, 0.000331f, 0.000351f, 0.000376f, 0.000402f, 0.000432f, 0.000460f, 0.000500f, 0.000547f, 0.000593f, 0.000648f,
+ 0.000720f, 0.000805f, 0.000918f, 0.001045f, 0.001225f, 0.001462f, 0.001788f, 0.002264f, 0.003029f, 0.004623f, 0.320801f, 0.398682f,
+ 0.419922f, 0.430420f, 0.436279f, 0.440674f, 0.000061f, 0.000041f, 0.000033f, 0.000029f, 0.000026f, 0.000025f, 0.000024f, 0.000024f,
+ 0.000023f, 0.000023f, 0.000025f, 0.000032f, 0.000026f, 0.000027f, 0.000035f, 0.000037f, 0.000039f, 0.000041f, 0.000041f, 0.000041f,
+ 0.000044f, 0.000050f, 0.000054f, 0.000051f, 0.000055f, 0.000060f, 0.000061f, 0.000062f, 0.000069f, 0.000074f, 0.000075f, 0.000081f,
+ 0.000087f, 0.000090f, 0.000093f, 0.000098f, 0.000108f, 0.000114f, 0.000123f, 0.000130f, 0.000142f, 0.000144f, 0.000156f, 0.000173f,
+ 0.000179f, 0.000200f, 0.000218f, 0.000237f, 0.000267f, 0.000299f, 0.000335f, 0.000382f, 0.000448f, 0.000544f, 0.000677f, 0.000883f,
+ 0.001233f, 0.001933f, 0.309570f, 0.388672f, 0.410889f, 0.421143f, 0.427246f, 0.431885f, 0.000031f, 0.000020f, 0.000016f, 0.000014f,
+ 0.000013f, 0.000012f, 0.000012f, 0.000011f, 0.000011f, 0.000010f, 0.000010f, 0.000010f, 0.000009f, 0.000009f, 0.000008f, 0.000009f,
+ 0.000009f, 0.000007f, 0.000007f, 0.000007f, 0.000008f, 0.000009f, 0.000011f, 0.000012f, 0.000012f, 0.000012f, 0.000013f, 0.000015f,
+ 0.000015f, 0.000014f, 0.000016f, 0.000017f, 0.000019f, 0.000020f, 0.000020f, 0.000022f, 0.000025f, 0.000023f, 0.000026f, 0.000029f,
+ 0.000031f, 0.000034f, 0.000036f, 0.000037f, 0.000040f, 0.000044f, 0.000048f, 0.000052f, 0.000056f, 0.000063f, 0.000068f, 0.000083f,
+ 0.000098f, 0.000117f, 0.000149f, 0.000201f, 0.000301f, 0.000544f, 0.297607f, 0.379150f, 0.400879f, 0.411865f, 0.419189f, 0.423340f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f,
+ 0.000000f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f,
+ 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f,
+ 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000002f,
+ 0.000002f, 0.000002f, 0.000003f, 0.000004f, 0.000004f, 0.000004f, 0.000005f, 0.000007f, 0.000011f, 0.000026f, 0.286621f, 0.368896f,
+ 0.391846f, 0.402588f, 0.409912f, 0.414551f,
+ },
+ {
+ 0.007935f, 0.024429f, 0.041290f, 0.058838f, 0.076355f, 0.093933f, 0.111145f, 0.128174f, 0.146606f, 0.164429f, 0.182617f, 0.200562f,
+ 0.218750f, 0.236206f, 0.254150f, 0.271729f, 0.289551f, 0.308105f, 0.325684f, 0.342773f, 0.360596f, 0.379150f, 0.396240f, 0.414795f,
+ 0.431641f, 0.450439f, 0.468018f, 0.484619f, 0.502441f, 0.520020f, 0.536621f, 0.554688f, 0.571777f, 0.588379f, 0.605469f, 0.622559f,
+ 0.640137f, 0.657227f, 0.672852f, 0.689941f, 0.707031f, 0.723633f, 0.740234f, 0.756836f, 0.773926f, 0.789551f, 0.805664f, 0.821777f,
+ 0.838379f, 0.854980f, 0.870117f, 0.885742f, 0.901855f, 0.917480f, 0.932617f, 0.948730f, 0.963379f, 0.979492f, 0.960449f, 0.909668f,
+ 0.876465f, 0.850098f, 0.827637f, 0.807617f, 0.007530f, 0.023422f, 0.039764f, 0.056610f, 0.073303f, 0.090149f, 0.107300f, 0.124084f,
+ 0.141968f, 0.158569f, 0.176392f, 0.193604f, 0.210815f, 0.228760f, 0.246094f, 0.262695f, 0.280518f, 0.298340f, 0.315430f, 0.333252f,
+ 0.350586f, 0.367432f, 0.384766f, 0.402344f, 0.419678f, 0.436768f, 0.453613f, 0.471436f, 0.488037f, 0.504883f, 0.521973f, 0.538574f,
+ 0.556641f, 0.573242f, 0.589844f, 0.605957f, 0.623535f, 0.639160f, 0.656250f, 0.673340f, 0.688477f, 0.706055f, 0.721680f, 0.738770f,
+ 0.754883f, 0.770508f, 0.786133f, 0.803711f, 0.817871f, 0.834473f, 0.850586f, 0.866211f, 0.881348f, 0.896973f, 0.913086f, 0.928223f,
+ 0.942871f, 0.958984f, 0.951172f, 0.903320f, 0.871094f, 0.845703f, 0.824219f, 0.805664f, 0.007320f, 0.022552f, 0.038391f, 0.054260f,
+ 0.070312f, 0.086792f, 0.103271f, 0.120178f, 0.136841f, 0.153564f, 0.170410f, 0.187256f, 0.203735f, 0.220825f, 0.237793f, 0.255127f,
+ 0.271240f, 0.288086f, 0.305420f, 0.322021f, 0.339844f, 0.356689f, 0.373047f, 0.390137f, 0.406738f, 0.423340f, 0.440186f, 0.456787f,
+ 0.474121f, 0.490967f, 0.507324f, 0.523926f, 0.540527f, 0.557129f, 0.573242f, 0.590332f, 0.606445f, 0.623047f, 0.638672f, 0.655273f,
+ 0.671875f, 0.687500f, 0.703613f, 0.720215f, 0.735840f, 0.751953f, 0.767578f, 0.783203f, 0.799316f, 0.814941f, 0.830078f, 0.845703f,
+ 0.861328f, 0.877441f, 0.892090f, 0.908203f, 0.922852f, 0.938477f, 0.941895f, 0.895996f, 0.865723f, 0.841309f, 0.820801f, 0.802734f,
+ 0.007008f, 0.021667f, 0.036865f, 0.052216f, 0.067871f, 0.083862f, 0.099426f, 0.115479f, 0.131470f, 0.148315f, 0.164551f, 0.180298f,
+ 0.196899f, 0.213379f, 0.229370f, 0.246460f, 0.262695f, 0.279541f, 0.295410f, 0.311523f, 0.329102f, 0.345215f, 0.360840f, 0.378174f,
+ 0.394043f, 0.410156f, 0.427246f, 0.443115f, 0.459717f, 0.476318f, 0.493652f, 0.508789f, 0.524902f, 0.541016f, 0.557129f, 0.573242f,
+ 0.589844f, 0.605469f, 0.621582f, 0.638672f, 0.652832f, 0.669434f, 0.685547f, 0.701660f, 0.717285f, 0.731934f, 0.749023f, 0.764160f,
+ 0.779785f, 0.794922f, 0.810059f, 0.826172f, 0.841309f, 0.856445f, 0.872070f, 0.886719f, 0.902344f, 0.917480f, 0.932129f, 0.889648f,
+ 0.859863f, 0.835938f, 0.816895f, 0.799316f, 0.006817f, 0.020645f, 0.035156f, 0.050110f, 0.065247f, 0.080383f, 0.096313f, 0.111450f,
+ 0.126587f, 0.142456f, 0.158447f, 0.174316f, 0.189819f, 0.205566f, 0.221802f, 0.237427f, 0.253662f, 0.269775f, 0.285889f, 0.301514f,
+ 0.317627f, 0.333740f, 0.349609f, 0.366211f, 0.381348f, 0.397705f, 0.414307f, 0.429932f, 0.447266f, 0.462646f, 0.477539f, 0.494385f,
+ 0.509766f, 0.525879f, 0.541992f, 0.557617f, 0.571777f, 0.588379f, 0.605469f, 0.619629f, 0.636230f, 0.651855f, 0.666992f, 0.681152f,
+ 0.698242f, 0.714355f, 0.729980f, 0.745117f, 0.759766f, 0.775391f, 0.790527f, 0.806152f, 0.821289f, 0.835938f, 0.850586f, 0.866211f,
+ 0.882324f, 0.896484f, 0.922363f, 0.882324f, 0.854004f, 0.831543f, 0.812500f, 0.795898f, 0.006378f, 0.019989f, 0.034027f, 0.048004f,
+ 0.062744f, 0.077148f, 0.091980f, 0.107178f, 0.122192f, 0.137207f, 0.152466f, 0.167603f, 0.183960f, 0.199097f, 0.214111f, 0.229736f,
+ 0.244995f, 0.260254f, 0.276367f, 0.291504f, 0.306641f, 0.322998f, 0.338623f, 0.354248f, 0.369629f, 0.385254f, 0.400879f, 0.416504f,
+ 0.432617f, 0.447510f, 0.464111f, 0.479492f, 0.494141f, 0.511230f, 0.525879f, 0.541016f, 0.556641f, 0.572754f, 0.586914f, 0.602051f,
+ 0.617676f, 0.633789f, 0.648926f, 0.665039f, 0.679688f, 0.695312f, 0.710449f, 0.726074f, 0.739746f, 0.755859f, 0.771484f, 0.785645f,
+ 0.800781f, 0.815918f, 0.831055f, 0.846680f, 0.860840f, 0.875977f, 0.912598f, 0.874512f, 0.847656f, 0.826172f, 0.807617f, 0.791504f,
+ 0.006603f, 0.019287f, 0.032776f, 0.046356f, 0.060272f, 0.073914f, 0.088135f, 0.102905f, 0.117554f, 0.132690f, 0.147095f, 0.161377f,
+ 0.176636f, 0.191162f, 0.205444f, 0.221680f, 0.236572f, 0.251465f, 0.267090f, 0.281250f, 0.296875f, 0.312256f, 0.327393f, 0.342285f,
+ 0.357666f, 0.373291f, 0.388184f, 0.403076f, 0.418457f, 0.433838f, 0.448975f, 0.465088f, 0.479980f, 0.494385f, 0.509277f, 0.525879f,
+ 0.540039f, 0.555176f, 0.570801f, 0.586426f, 0.601074f, 0.616211f, 0.631348f, 0.646484f, 0.661133f, 0.676270f, 0.692383f, 0.705078f,
+ 0.720215f, 0.735352f, 0.751953f, 0.766602f, 0.781250f, 0.796387f, 0.810059f, 0.825684f, 0.840820f, 0.855469f, 0.902344f, 0.866699f,
+ 0.841797f, 0.820312f, 0.803223f, 0.787598f, 0.006111f, 0.018433f, 0.031097f, 0.044739f, 0.057892f, 0.071472f, 0.085205f, 0.099304f,
+ 0.113037f, 0.127319f, 0.141357f, 0.156128f, 0.169678f, 0.183838f, 0.198608f, 0.213745f, 0.227661f, 0.243652f, 0.257324f, 0.272705f,
+ 0.286865f, 0.301025f, 0.316406f, 0.331543f, 0.345703f, 0.360107f, 0.375000f, 0.390625f, 0.405762f, 0.420410f, 0.435303f, 0.449951f,
+ 0.465088f, 0.479492f, 0.494141f, 0.509277f, 0.523926f, 0.538574f, 0.553711f, 0.569336f, 0.583496f, 0.598145f, 0.612793f, 0.628418f,
+ 0.642578f, 0.657227f, 0.671387f, 0.687012f, 0.702637f, 0.716797f, 0.731934f, 0.745605f, 0.761230f, 0.775391f, 0.790527f, 0.805176f,
+ 0.819824f, 0.834961f, 0.892578f, 0.858887f, 0.834473f, 0.814941f, 0.798340f, 0.783203f, 0.005756f, 0.017761f, 0.029907f, 0.042572f,
+ 0.055481f, 0.068420f, 0.081482f, 0.095276f, 0.108826f, 0.122070f, 0.135620f, 0.149902f, 0.163330f, 0.177368f, 0.191284f, 0.206421f,
+ 0.219482f, 0.233521f, 0.247925f, 0.262451f, 0.277100f, 0.290771f, 0.304688f, 0.319580f, 0.334229f, 0.348389f, 0.362549f, 0.377441f,
+ 0.391602f, 0.406250f, 0.421143f, 0.435791f, 0.450439f, 0.463867f, 0.478760f, 0.493164f, 0.507812f, 0.521973f, 0.537109f, 0.551270f,
+ 0.565430f, 0.580078f, 0.594727f, 0.609863f, 0.624023f, 0.638672f, 0.653320f, 0.668457f, 0.682129f, 0.697266f, 0.711914f, 0.726562f,
+ 0.740723f, 0.755859f, 0.770996f, 0.785156f, 0.799805f, 0.814453f, 0.882812f, 0.851562f, 0.827148f, 0.808594f, 0.792969f, 0.778809f,
+ 0.005741f, 0.017166f, 0.029053f, 0.041138f, 0.053345f, 0.065796f, 0.078674f, 0.091248f, 0.104614f, 0.117004f, 0.130737f, 0.143921f,
+ 0.156860f, 0.170288f, 0.183960f, 0.197754f, 0.211304f, 0.224976f, 0.238892f, 0.251953f, 0.266357f, 0.280273f, 0.294922f, 0.308594f,
+ 0.322021f, 0.336914f, 0.350098f, 0.364502f, 0.378174f, 0.393066f, 0.407471f, 0.420166f, 0.435059f, 0.449219f, 0.463135f, 0.477295f,
+ 0.491699f, 0.506348f, 0.520996f, 0.534668f, 0.549316f, 0.563477f, 0.577148f, 0.591309f, 0.605469f, 0.620605f, 0.634766f, 0.648438f,
+ 0.663086f, 0.677734f, 0.691895f, 0.706543f, 0.720215f, 0.734863f, 0.750488f, 0.765137f, 0.779297f, 0.793945f, 0.872559f, 0.843262f,
+ 0.820801f, 0.803223f, 0.787598f, 0.773926f, 0.005283f, 0.016052f, 0.028030f, 0.039246f, 0.050751f, 0.063232f, 0.074829f, 0.087341f,
+ 0.099976f, 0.112732f, 0.125122f, 0.138062f, 0.150757f, 0.163696f, 0.176758f, 0.189697f, 0.203125f, 0.216553f, 0.229614f, 0.243286f,
+ 0.256592f, 0.269775f, 0.283203f, 0.297119f, 0.310547f, 0.324463f, 0.337891f, 0.351807f, 0.365234f, 0.378662f, 0.392822f, 0.406738f,
+ 0.419922f, 0.434814f, 0.448730f, 0.461182f, 0.476562f, 0.489746f, 0.502930f, 0.517578f, 0.531738f, 0.545410f, 0.559082f, 0.573730f,
+ 0.587402f, 0.602051f, 0.615723f, 0.629395f, 0.644043f, 0.658203f, 0.672363f, 0.686523f, 0.701660f, 0.714844f, 0.729980f, 0.743652f,
+ 0.758301f, 0.774414f, 0.862305f, 0.835449f, 0.813965f, 0.796875f, 0.782227f, 0.769043f, 0.005272f, 0.015427f, 0.026230f, 0.037506f,
+ 0.049164f, 0.060516f, 0.072021f, 0.083740f, 0.095825f, 0.108521f, 0.120361f, 0.132324f, 0.144897f, 0.156738f, 0.169922f, 0.182373f,
+ 0.195068f, 0.208008f, 0.220459f, 0.233887f, 0.246948f, 0.260254f, 0.272461f, 0.285889f, 0.299561f, 0.312500f, 0.325684f, 0.338867f,
+ 0.352783f, 0.365479f, 0.378906f, 0.392334f, 0.406006f, 0.419189f, 0.432861f, 0.446777f, 0.460693f, 0.473877f, 0.486572f, 0.500977f,
+ 0.515137f, 0.528809f, 0.542480f, 0.555176f, 0.569824f, 0.583984f, 0.597656f, 0.611328f, 0.625000f, 0.639648f, 0.653320f, 0.667480f,
+ 0.681641f, 0.695801f, 0.709961f, 0.723633f, 0.738281f, 0.752930f, 0.852539f, 0.827148f, 0.807129f, 0.790527f, 0.776367f, 0.764160f,
+ 0.004822f, 0.014885f, 0.025360f, 0.035767f, 0.046570f, 0.057587f, 0.068726f, 0.080139f, 0.091736f, 0.103577f, 0.115479f, 0.126709f,
+ 0.138672f, 0.150879f, 0.162231f, 0.174805f, 0.187622f, 0.199951f, 0.212524f, 0.224854f, 0.236694f, 0.249878f, 0.262207f, 0.275391f,
+ 0.287842f, 0.300293f, 0.313477f, 0.326904f, 0.340088f, 0.353027f, 0.365479f, 0.378174f, 0.391602f, 0.404541f, 0.417236f, 0.431641f,
+ 0.444336f, 0.457764f, 0.470703f, 0.484375f, 0.497803f, 0.510742f, 0.524902f, 0.537598f, 0.552246f, 0.564941f, 0.579590f, 0.592285f,
+ 0.606445f, 0.621094f, 0.634277f, 0.646973f, 0.662109f, 0.675781f, 0.689453f, 0.704102f, 0.718262f, 0.733398f, 0.842285f, 0.818848f,
+ 0.799805f, 0.784180f, 0.770996f, 0.758301f, 0.004745f, 0.014427f, 0.024277f, 0.034546f, 0.044800f, 0.055176f, 0.066040f, 0.076477f,
+ 0.087341f, 0.099060f, 0.110474f, 0.121216f, 0.132690f, 0.144165f, 0.156006f, 0.167358f, 0.179688f, 0.191284f, 0.203247f, 0.216187f,
+ 0.227905f, 0.239868f, 0.252441f, 0.264648f, 0.277100f, 0.289307f, 0.301270f, 0.314453f, 0.326660f, 0.338867f, 0.352539f, 0.364990f,
+ 0.377686f, 0.390137f, 0.403076f, 0.416016f, 0.428467f, 0.441406f, 0.453857f, 0.468262f, 0.480957f, 0.494385f, 0.507324f, 0.520020f,
+ 0.534180f, 0.547363f, 0.560059f, 0.573730f, 0.586914f, 0.601074f, 0.615234f, 0.628418f, 0.641602f, 0.656250f, 0.669434f, 0.683594f,
+ 0.697754f, 0.712402f, 0.832520f, 0.809570f, 0.792480f, 0.778320f, 0.764160f, 0.753906f, 0.004612f, 0.013840f, 0.023483f, 0.033081f,
+ 0.042999f, 0.052490f, 0.063049f, 0.073303f, 0.083801f, 0.094238f, 0.105042f, 0.115967f, 0.127319f, 0.138062f, 0.149048f, 0.160645f,
+ 0.171875f, 0.183228f, 0.194946f, 0.206665f, 0.218384f, 0.230347f, 0.241699f, 0.253906f, 0.265869f, 0.277832f, 0.290039f, 0.301758f,
+ 0.314209f, 0.326660f, 0.339111f, 0.351074f, 0.363281f, 0.375977f, 0.388428f, 0.401123f, 0.413330f, 0.426270f, 0.439453f, 0.451904f,
+ 0.464111f, 0.478027f, 0.489746f, 0.503418f, 0.515625f, 0.529297f, 0.542480f, 0.556152f, 0.569336f, 0.582031f, 0.595215f, 0.608887f,
+ 0.622559f, 0.636230f, 0.649902f, 0.663574f, 0.677246f, 0.691895f, 0.821289f, 0.802246f, 0.785645f, 0.771484f, 0.758789f, 0.748047f,
+ 0.004345f, 0.012985f, 0.022156f, 0.030884f, 0.040802f, 0.050568f, 0.060303f, 0.069946f, 0.079956f, 0.090393f, 0.100403f, 0.111084f,
+ 0.120667f, 0.131714f, 0.142700f, 0.153198f, 0.164429f, 0.175659f, 0.186523f, 0.197876f, 0.208496f, 0.220337f, 0.231567f, 0.243286f,
+ 0.254639f, 0.266113f, 0.277832f, 0.289795f, 0.301758f, 0.313477f, 0.325439f, 0.337402f, 0.349609f, 0.361328f, 0.373779f, 0.385986f,
+ 0.398193f, 0.410889f, 0.423340f, 0.435059f, 0.447998f, 0.460205f, 0.473389f, 0.486084f, 0.499023f, 0.511230f, 0.524414f, 0.537109f,
+ 0.549805f, 0.563477f, 0.576172f, 0.589355f, 0.603027f, 0.616699f, 0.629883f, 0.644531f, 0.658691f, 0.670898f, 0.811035f, 0.792969f,
+ 0.777832f, 0.764648f, 0.752441f, 0.742676f, 0.004002f, 0.012718f, 0.021210f, 0.029877f, 0.039246f, 0.048431f, 0.057281f, 0.067078f,
+ 0.076538f, 0.086121f, 0.096008f, 0.105957f, 0.115540f, 0.125732f, 0.136475f, 0.146729f, 0.157227f, 0.167236f, 0.177979f, 0.189819f,
+ 0.200195f, 0.210693f, 0.221802f, 0.232788f, 0.243896f, 0.255127f, 0.266602f, 0.278320f, 0.289062f, 0.300293f, 0.312012f, 0.323975f,
+ 0.335449f, 0.347168f, 0.359131f, 0.371094f, 0.382812f, 0.394775f, 0.406982f, 0.419434f, 0.431152f, 0.443604f, 0.455566f, 0.468506f,
+ 0.481445f, 0.493408f, 0.506348f, 0.519043f, 0.531738f, 0.544922f, 0.558105f, 0.570801f, 0.583984f, 0.597168f, 0.610352f, 0.624512f,
+ 0.637695f, 0.651855f, 0.800293f, 0.785156f, 0.770508f, 0.757812f, 0.747070f, 0.737305f, 0.003967f, 0.011940f, 0.020203f, 0.028931f,
+ 0.037109f, 0.045898f, 0.054840f, 0.063477f, 0.073059f, 0.082214f, 0.090942f, 0.100647f, 0.110535f, 0.120178f, 0.129639f, 0.139648f,
+ 0.149902f, 0.160156f, 0.170044f, 0.180786f, 0.190674f, 0.201416f, 0.211792f, 0.222412f, 0.233521f, 0.244751f, 0.255615f, 0.266113f,
+ 0.276855f, 0.288574f, 0.299561f, 0.311279f, 0.322266f, 0.333984f, 0.344727f, 0.356934f, 0.368164f, 0.379395f, 0.390869f, 0.403076f,
+ 0.415283f, 0.427246f, 0.439453f, 0.451172f, 0.464111f, 0.476807f, 0.488281f, 0.500977f, 0.513672f, 0.526367f, 0.538574f, 0.551758f,
+ 0.564453f, 0.577637f, 0.590820f, 0.604492f, 0.618164f, 0.631836f, 0.790039f, 0.775879f, 0.763184f, 0.750977f, 0.740723f, 0.731445f,
+ 0.003679f, 0.011749f, 0.019135f, 0.027237f, 0.035431f, 0.043884f, 0.052399f, 0.060577f, 0.069153f, 0.077881f, 0.086731f, 0.095947f,
+ 0.104797f, 0.114380f, 0.123535f, 0.133057f, 0.142700f, 0.152588f, 0.162231f, 0.171753f, 0.182129f, 0.192261f, 0.202026f, 0.212524f,
+ 0.222900f, 0.233643f, 0.243896f, 0.254395f, 0.264893f, 0.276123f, 0.286621f, 0.297119f, 0.308105f, 0.319336f, 0.331299f, 0.341553f,
+ 0.353027f, 0.364258f, 0.375977f, 0.387451f, 0.399414f, 0.410645f, 0.422607f, 0.434814f, 0.445801f, 0.458984f, 0.470703f, 0.482910f,
+ 0.495361f, 0.508301f, 0.520020f, 0.532227f, 0.545410f, 0.558594f, 0.570801f, 0.584961f, 0.597656f, 0.611816f, 0.778809f, 0.768066f,
+ 0.754883f, 0.743652f, 0.733887f, 0.725098f, 0.003525f, 0.010956f, 0.018433f, 0.026260f, 0.033295f, 0.041870f, 0.049377f, 0.057709f,
+ 0.065735f, 0.074463f, 0.082764f, 0.091736f, 0.099976f, 0.108582f, 0.118103f, 0.126465f, 0.135742f, 0.144775f, 0.154175f, 0.164307f,
+ 0.173218f, 0.182983f, 0.192505f, 0.202759f, 0.212646f, 0.221924f, 0.232910f, 0.242188f, 0.252930f, 0.262939f, 0.273926f, 0.284180f,
+ 0.294922f, 0.305420f, 0.316162f, 0.327637f, 0.338867f, 0.349609f, 0.361084f, 0.371826f, 0.382812f, 0.395020f, 0.406494f, 0.417725f,
+ 0.429688f, 0.441406f, 0.452637f, 0.465088f, 0.477783f, 0.489258f, 0.501953f, 0.514160f, 0.527344f, 0.539062f, 0.551758f, 0.564941f,
+ 0.578125f, 0.591797f, 0.768555f, 0.759277f, 0.748047f, 0.736816f, 0.728027f, 0.718750f, 0.003363f, 0.010353f, 0.017548f, 0.024765f,
+ 0.032196f, 0.039673f, 0.046936f, 0.054565f, 0.062561f, 0.070496f, 0.078308f, 0.086731f, 0.094910f, 0.103333f, 0.111633f, 0.120422f,
+ 0.129150f, 0.137695f, 0.146973f, 0.155762f, 0.164673f, 0.173950f, 0.183228f, 0.193359f, 0.201782f, 0.212036f, 0.221436f, 0.231323f,
+ 0.241699f, 0.251221f, 0.261719f, 0.271729f, 0.281494f, 0.291992f, 0.302734f, 0.312988f, 0.323730f, 0.334961f, 0.345459f, 0.357666f,
+ 0.367432f, 0.378662f, 0.389893f, 0.401855f, 0.412842f, 0.424316f, 0.435791f, 0.447266f, 0.459473f, 0.471436f, 0.482910f, 0.495605f,
+ 0.507324f, 0.520508f, 0.533203f, 0.545898f, 0.558594f, 0.570801f, 0.757812f, 0.750488f, 0.740234f, 0.729980f, 0.720703f, 0.712402f,
+ 0.003254f, 0.010048f, 0.016815f, 0.023453f, 0.030609f, 0.037537f, 0.044617f, 0.051971f, 0.059265f, 0.066833f, 0.074280f, 0.082153f,
+ 0.089905f, 0.097717f, 0.106018f, 0.113770f, 0.122131f, 0.131104f, 0.139282f, 0.147705f, 0.155762f, 0.165161f, 0.173950f, 0.183228f,
+ 0.192139f, 0.200928f, 0.210693f, 0.220093f, 0.229736f, 0.239258f, 0.248657f, 0.259277f, 0.268799f, 0.279053f, 0.288574f, 0.299561f,
+ 0.309814f, 0.319580f, 0.330322f, 0.340820f, 0.352783f, 0.362549f, 0.374023f, 0.385010f, 0.395752f, 0.407471f, 0.418701f, 0.429688f,
+ 0.441650f, 0.453125f, 0.465088f, 0.477539f, 0.489014f, 0.500977f, 0.513184f, 0.526855f, 0.539062f, 0.552246f, 0.747559f, 0.741699f,
+ 0.731934f, 0.722656f, 0.714355f, 0.707031f, 0.003345f, 0.009262f, 0.015900f, 0.022614f, 0.029282f, 0.035522f, 0.042633f, 0.048981f,
+ 0.056000f, 0.063110f, 0.070801f, 0.077454f, 0.084839f, 0.092590f, 0.100281f, 0.107849f, 0.116089f, 0.123169f, 0.131348f, 0.139648f,
+ 0.148193f, 0.156616f, 0.164795f, 0.173584f, 0.182617f, 0.191284f, 0.200073f, 0.208740f, 0.218140f, 0.227417f, 0.236694f, 0.246338f,
+ 0.255859f, 0.265381f, 0.275146f, 0.285889f, 0.294922f, 0.305420f, 0.315918f, 0.325928f, 0.336670f, 0.347412f, 0.358154f, 0.368652f,
+ 0.378662f, 0.390381f, 0.402100f, 0.412842f, 0.424316f, 0.435059f, 0.447021f, 0.458984f, 0.470459f, 0.482422f, 0.494873f, 0.508301f,
+ 0.520020f, 0.532227f, 0.737305f, 0.732910f, 0.723633f, 0.715820f, 0.708008f, 0.700195f, 0.003195f, 0.009010f, 0.015137f, 0.021225f,
+ 0.027466f, 0.033844f, 0.040161f, 0.046417f, 0.053497f, 0.059875f, 0.066711f, 0.073425f, 0.080505f, 0.087280f, 0.094788f, 0.102173f,
+ 0.109070f, 0.117004f, 0.124634f, 0.132446f, 0.139893f, 0.147705f, 0.155884f, 0.163940f, 0.172729f, 0.180908f, 0.189697f, 0.198242f,
+ 0.206665f, 0.215820f, 0.225220f, 0.233765f, 0.243408f, 0.251953f, 0.262207f, 0.271484f, 0.281494f, 0.291260f, 0.300537f, 0.311035f,
+ 0.320801f, 0.332520f, 0.341797f, 0.352051f, 0.362305f, 0.373535f, 0.384521f, 0.395264f, 0.406494f, 0.417480f, 0.429443f, 0.440430f,
+ 0.451904f, 0.463867f, 0.476074f, 0.487793f, 0.499268f, 0.513184f, 0.726562f, 0.723633f, 0.716309f, 0.708496f, 0.700684f, 0.694336f,
+ 0.002859f, 0.008507f, 0.014366f, 0.020203f, 0.026123f, 0.031891f, 0.038025f, 0.044281f, 0.050354f, 0.056519f, 0.062683f, 0.069275f,
+ 0.075195f, 0.082458f, 0.088806f, 0.095947f, 0.102783f, 0.110046f, 0.117065f, 0.124878f, 0.132080f, 0.139282f, 0.146851f, 0.154907f,
+ 0.162598f, 0.171265f, 0.178833f, 0.187500f, 0.195435f, 0.204590f, 0.213013f, 0.221680f, 0.231079f, 0.239502f, 0.248047f, 0.258301f,
+ 0.267334f, 0.277100f, 0.286133f, 0.296387f, 0.306641f, 0.316162f, 0.326416f, 0.336426f, 0.346924f, 0.357422f, 0.367188f, 0.378418f,
+ 0.389160f, 0.400391f, 0.411865f, 0.422852f, 0.433594f, 0.445557f, 0.457520f, 0.468994f, 0.481445f, 0.493408f, 0.715332f, 0.715332f,
+ 0.708984f, 0.700684f, 0.693848f, 0.687988f, 0.002701f, 0.008080f, 0.013718f, 0.019058f, 0.024582f, 0.030197f, 0.035675f, 0.041748f,
+ 0.047302f, 0.053589f, 0.059082f, 0.065308f, 0.071777f, 0.077576f, 0.084106f, 0.090332f, 0.097107f, 0.103577f, 0.110046f, 0.117493f,
+ 0.124146f, 0.131470f, 0.138550f, 0.145508f, 0.153564f, 0.161377f, 0.169067f, 0.176880f, 0.184814f, 0.192627f, 0.201294f, 0.209717f,
+ 0.218140f, 0.226929f, 0.235229f, 0.245117f, 0.253418f, 0.262939f, 0.272705f, 0.281738f, 0.290771f, 0.300781f, 0.310791f, 0.321289f,
+ 0.330566f, 0.341064f, 0.351562f, 0.361572f, 0.372559f, 0.382568f, 0.393066f, 0.405273f, 0.415771f, 0.426758f, 0.438721f, 0.450439f,
+ 0.461670f, 0.474121f, 0.704102f, 0.706543f, 0.700195f, 0.693359f, 0.687012f, 0.681152f, 0.002546f, 0.007771f, 0.012985f, 0.017975f,
+ 0.023392f, 0.028976f, 0.034180f, 0.039368f, 0.044556f, 0.050110f, 0.055847f, 0.061218f, 0.066895f, 0.072815f, 0.078674f, 0.085083f,
+ 0.091309f, 0.097168f, 0.103516f, 0.110107f, 0.116821f, 0.123413f, 0.130371f, 0.137329f, 0.144165f, 0.151733f, 0.158813f, 0.166382f,
+ 0.174438f, 0.182129f, 0.190063f, 0.197510f, 0.206055f, 0.214355f, 0.222778f, 0.231812f, 0.240723f, 0.249023f, 0.258789f, 0.267578f,
+ 0.276855f, 0.285889f, 0.295654f, 0.305420f, 0.315430f, 0.324463f, 0.334961f, 0.345215f, 0.354492f, 0.365234f, 0.376221f, 0.387451f,
+ 0.398926f, 0.409424f, 0.419678f, 0.432129f, 0.443848f, 0.455566f, 0.693848f, 0.697266f, 0.691895f, 0.686523f, 0.680176f, 0.674805f,
+ 0.002542f, 0.007271f, 0.012337f, 0.017181f, 0.021744f, 0.026840f, 0.031555f, 0.037231f, 0.042236f, 0.046906f, 0.051941f, 0.057709f,
+ 0.063049f, 0.068542f, 0.073853f, 0.079712f, 0.085266f, 0.091064f, 0.096985f, 0.103027f, 0.109009f, 0.115417f, 0.122192f, 0.128540f,
+ 0.135132f, 0.141846f, 0.148926f, 0.156250f, 0.163696f, 0.171387f, 0.178223f, 0.186035f, 0.194580f, 0.202271f, 0.210327f, 0.218994f,
+ 0.227173f, 0.235596f, 0.244385f, 0.252930f, 0.262451f, 0.271240f, 0.280762f, 0.290771f, 0.299805f, 0.309082f, 0.318359f, 0.329102f,
+ 0.338623f, 0.348633f, 0.358643f, 0.370117f, 0.379639f, 0.390869f, 0.401611f, 0.413330f, 0.425293f, 0.436523f, 0.682129f, 0.688477f,
+ 0.684082f, 0.678711f, 0.673340f, 0.667969f, 0.002300f, 0.007076f, 0.011505f, 0.016251f, 0.020401f, 0.025665f, 0.029816f, 0.034790f,
+ 0.039368f, 0.044159f, 0.048798f, 0.053955f, 0.059174f, 0.064148f, 0.069153f, 0.074463f, 0.079346f, 0.085266f, 0.090759f, 0.096191f,
+ 0.102112f, 0.108032f, 0.114075f, 0.120117f, 0.126587f, 0.133057f, 0.139648f, 0.146240f, 0.153442f, 0.160400f, 0.167725f, 0.174683f,
+ 0.182739f, 0.190308f, 0.198120f, 0.206177f, 0.214355f, 0.222656f, 0.230713f, 0.239258f, 0.248413f, 0.257080f, 0.265869f, 0.274658f,
+ 0.284424f, 0.292725f, 0.302490f, 0.313232f, 0.321777f, 0.331787f, 0.341797f, 0.352295f, 0.363281f, 0.373535f, 0.383545f, 0.395264f,
+ 0.405762f, 0.416992f, 0.671387f, 0.679688f, 0.675293f, 0.670898f, 0.666016f, 0.661133f, 0.002104f, 0.006474f, 0.010506f, 0.015099f,
+ 0.018875f, 0.023911f, 0.028534f, 0.032715f, 0.036652f, 0.041290f, 0.046021f, 0.050171f, 0.054535f, 0.059570f, 0.064575f, 0.069458f,
+ 0.074341f, 0.079346f, 0.084351f, 0.089844f, 0.095032f, 0.100830f, 0.106628f, 0.112122f, 0.117859f, 0.124084f, 0.130249f, 0.136841f,
+ 0.143188f, 0.149780f, 0.157349f, 0.163940f, 0.171021f, 0.178345f, 0.186279f, 0.193848f, 0.201172f, 0.209717f, 0.217529f, 0.225464f,
+ 0.233765f, 0.242676f, 0.251221f, 0.260254f, 0.268311f, 0.278076f, 0.287109f, 0.296143f, 0.305908f, 0.315674f, 0.325195f, 0.335449f,
+ 0.344971f, 0.355469f, 0.365967f, 0.377441f, 0.387939f, 0.398193f, 0.660645f, 0.670410f, 0.667969f, 0.663086f, 0.659180f, 0.654785f,
+ 0.002085f, 0.006306f, 0.010506f, 0.014107f, 0.018448f, 0.022293f, 0.026215f, 0.029953f, 0.034515f, 0.038391f, 0.042786f, 0.046844f,
+ 0.051361f, 0.055573f, 0.059784f, 0.064331f, 0.068970f, 0.073425f, 0.078430f, 0.083313f, 0.088318f, 0.093567f, 0.098816f, 0.104126f,
+ 0.109924f, 0.115662f, 0.121521f, 0.127197f, 0.133545f, 0.139771f, 0.146729f, 0.153076f, 0.160278f, 0.166992f, 0.174316f, 0.181274f,
+ 0.188965f, 0.196045f, 0.204468f, 0.212036f, 0.220459f, 0.228638f, 0.237183f, 0.245483f, 0.254150f, 0.262451f, 0.271484f, 0.281250f,
+ 0.290283f, 0.299561f, 0.308350f, 0.318115f, 0.328369f, 0.337158f, 0.349121f, 0.358887f, 0.370117f, 0.380615f, 0.649414f, 0.661133f,
+ 0.659668f, 0.655762f, 0.651855f, 0.647949f, 0.001922f, 0.005867f, 0.009399f, 0.013565f, 0.017380f, 0.020859f, 0.024551f, 0.028442f,
+ 0.032318f, 0.035980f, 0.039551f, 0.043488f, 0.047333f, 0.051239f, 0.055573f, 0.059875f, 0.063660f, 0.067810f, 0.072876f, 0.077087f,
+ 0.081726f, 0.086304f, 0.091370f, 0.096863f, 0.101746f, 0.107483f, 0.112732f, 0.117920f, 0.124329f, 0.130005f, 0.136108f, 0.142822f,
+ 0.149170f, 0.155396f, 0.162598f, 0.169434f, 0.176636f, 0.183838f, 0.191772f, 0.198975f, 0.206665f, 0.214478f, 0.222290f, 0.230835f,
+ 0.239258f, 0.247803f, 0.256836f, 0.264893f, 0.274414f, 0.283203f, 0.292725f, 0.301758f, 0.311035f, 0.321289f, 0.332275f, 0.340820f,
+ 0.351562f, 0.363037f, 0.637695f, 0.652832f, 0.651367f, 0.647949f, 0.644531f, 0.641602f, 0.002052f, 0.005253f, 0.009117f, 0.012482f,
+ 0.016113f, 0.019302f, 0.022842f, 0.026230f, 0.029831f, 0.033447f, 0.036682f, 0.040588f, 0.044189f, 0.047333f, 0.051178f, 0.055267f,
+ 0.058807f, 0.062683f, 0.067200f, 0.070984f, 0.075195f, 0.079895f, 0.084534f, 0.088806f, 0.093933f, 0.098999f, 0.104309f, 0.109619f,
+ 0.114807f, 0.120422f, 0.126587f, 0.132080f, 0.138550f, 0.144775f, 0.151245f, 0.157837f, 0.164551f, 0.171387f, 0.178467f, 0.186157f,
+ 0.193359f, 0.201294f, 0.208740f, 0.216797f, 0.224854f, 0.233398f, 0.241211f, 0.250000f, 0.258545f, 0.267822f, 0.276855f, 0.286133f,
+ 0.295410f, 0.304932f, 0.314697f, 0.324463f, 0.334229f, 0.344238f, 0.626953f, 0.642578f, 0.643066f, 0.641113f, 0.637695f, 0.634277f,
+ 0.001711f, 0.005424f, 0.008347f, 0.012024f, 0.014977f, 0.018066f, 0.021500f, 0.024399f, 0.027756f, 0.030869f, 0.034058f, 0.037048f,
+ 0.040558f, 0.044006f, 0.046906f, 0.050690f, 0.054169f, 0.057983f, 0.061584f, 0.065247f, 0.069336f, 0.073425f, 0.077576f, 0.082092f,
+ 0.086670f, 0.091064f, 0.095886f, 0.101196f, 0.105957f, 0.111267f, 0.116943f, 0.122559f, 0.128174f, 0.133789f, 0.140259f, 0.146118f,
+ 0.153076f, 0.159424f, 0.166016f, 0.173462f, 0.180542f, 0.187744f, 0.195435f, 0.203003f, 0.209961f, 0.218994f, 0.226562f, 0.234619f,
+ 0.243286f, 0.251709f, 0.260742f, 0.269531f, 0.277832f, 0.287354f, 0.297363f, 0.306885f, 0.316406f, 0.326660f, 0.615234f, 0.633789f,
+ 0.634277f, 0.632812f, 0.630371f, 0.626953f, 0.001721f, 0.004829f, 0.008034f, 0.010857f, 0.013893f, 0.016953f, 0.019806f, 0.022705f,
+ 0.025589f, 0.028793f, 0.031616f, 0.034180f, 0.036926f, 0.039978f, 0.043213f, 0.046356f, 0.049744f, 0.052887f, 0.056305f, 0.059906f,
+ 0.063416f, 0.067322f, 0.070862f, 0.075134f, 0.079285f, 0.083435f, 0.088074f, 0.092712f, 0.097534f, 0.102173f, 0.107544f, 0.112305f,
+ 0.118225f, 0.123657f, 0.129272f, 0.135376f, 0.141602f, 0.147705f, 0.153931f, 0.160889f, 0.167847f, 0.174683f, 0.181885f, 0.189209f,
+ 0.196533f, 0.204224f, 0.212524f, 0.219727f, 0.228271f, 0.236572f, 0.245483f, 0.253418f, 0.261719f, 0.270996f, 0.280029f, 0.289307f,
+ 0.300537f, 0.309326f, 0.604004f, 0.625000f, 0.626953f, 0.625000f, 0.622559f, 0.620117f, 0.001624f, 0.004730f, 0.007412f, 0.010300f,
+ 0.013199f, 0.015717f, 0.018448f, 0.020935f, 0.023163f, 0.026138f, 0.028687f, 0.031204f, 0.033875f, 0.036743f, 0.039825f, 0.042389f,
+ 0.045166f, 0.048523f, 0.051422f, 0.054535f, 0.057953f, 0.061249f, 0.064880f, 0.068542f, 0.072388f, 0.076355f, 0.080505f, 0.084534f,
+ 0.089294f, 0.093750f, 0.098389f, 0.103210f, 0.108337f, 0.113647f, 0.118896f, 0.124817f, 0.130737f, 0.135986f, 0.142212f, 0.148560f,
+ 0.155151f, 0.162109f, 0.168579f, 0.175415f, 0.183105f, 0.190552f, 0.197998f, 0.205322f, 0.213623f, 0.221436f, 0.229370f, 0.237915f,
+ 0.246216f, 0.254883f, 0.264160f, 0.273438f, 0.282471f, 0.292236f, 0.593262f, 0.615723f, 0.618164f, 0.617188f, 0.615234f, 0.612793f,
+ 0.001355f, 0.004463f, 0.007061f, 0.009506f, 0.011612f, 0.014381f, 0.016830f, 0.019394f, 0.021576f, 0.023697f, 0.026428f, 0.028778f,
+ 0.030975f, 0.033386f, 0.035950f, 0.038513f, 0.041260f, 0.044067f, 0.046967f, 0.049622f, 0.052612f, 0.055847f, 0.059052f, 0.062164f,
+ 0.065918f, 0.069397f, 0.073242f, 0.077271f, 0.081055f, 0.085327f, 0.089661f, 0.094177f, 0.098877f, 0.103455f, 0.108582f, 0.113647f,
+ 0.119812f, 0.125000f, 0.130981f, 0.137085f, 0.142944f, 0.149414f, 0.156006f, 0.162354f, 0.169434f, 0.176514f, 0.183716f, 0.191284f,
+ 0.198975f, 0.206421f, 0.214844f, 0.222412f, 0.231323f, 0.238647f, 0.247437f, 0.256592f, 0.265625f, 0.276367f, 0.581055f, 0.606445f,
+ 0.609863f, 0.608887f, 0.607910f, 0.606445f, 0.001413f, 0.004128f, 0.006180f, 0.008781f, 0.010994f, 0.013496f, 0.015427f, 0.017654f,
+ 0.019684f, 0.021881f, 0.024139f, 0.025879f, 0.028137f, 0.030334f, 0.032471f, 0.034821f, 0.037354f, 0.039642f, 0.042236f, 0.044708f,
+ 0.047394f, 0.050079f, 0.053223f, 0.056244f, 0.059479f, 0.062622f, 0.066223f, 0.069946f, 0.073608f, 0.077209f, 0.081604f, 0.085632f,
+ 0.089722f, 0.094360f, 0.098999f, 0.103943f, 0.108826f, 0.114319f, 0.119568f, 0.125122f, 0.131104f, 0.137085f, 0.143433f, 0.150024f,
+ 0.156494f, 0.163330f, 0.170044f, 0.177490f, 0.184326f, 0.191895f, 0.199707f, 0.207764f, 0.215698f, 0.223755f, 0.231812f, 0.240845f,
+ 0.249756f, 0.258789f, 0.568848f, 0.598145f, 0.601562f, 0.600586f, 0.600586f, 0.599121f, 0.001182f, 0.003773f, 0.005970f, 0.008293f,
+ 0.010277f, 0.012512f, 0.014030f, 0.016129f, 0.017929f, 0.019791f, 0.021683f, 0.023590f, 0.025452f, 0.027328f, 0.029404f, 0.031677f,
+ 0.033539f, 0.035583f, 0.037903f, 0.040314f, 0.042877f, 0.045319f, 0.048126f, 0.050690f, 0.053436f, 0.056519f, 0.059723f, 0.062744f,
+ 0.066284f, 0.069702f, 0.073608f, 0.077209f, 0.081055f, 0.085754f, 0.089783f, 0.094421f, 0.099060f, 0.103821f, 0.109192f, 0.114563f,
+ 0.119934f, 0.125488f, 0.131104f, 0.137695f, 0.144043f, 0.149780f, 0.156738f, 0.163940f, 0.170654f, 0.177856f, 0.185181f, 0.192871f,
+ 0.200439f, 0.208740f, 0.216675f, 0.225342f, 0.233521f, 0.242554f, 0.557617f, 0.587891f, 0.592285f, 0.592773f, 0.592285f, 0.592285f,
+ 0.001198f, 0.003677f, 0.005547f, 0.007561f, 0.009468f, 0.011253f, 0.012833f, 0.014465f, 0.016205f, 0.017792f, 0.019394f, 0.021240f,
+ 0.022751f, 0.024475f, 0.026260f, 0.028015f, 0.030136f, 0.031708f, 0.034088f, 0.036102f, 0.038361f, 0.040497f, 0.042816f, 0.045288f,
+ 0.047882f, 0.050476f, 0.053284f, 0.056183f, 0.059174f, 0.062500f, 0.065796f, 0.069153f, 0.072998f, 0.076904f, 0.080994f, 0.085083f,
+ 0.089478f, 0.094116f, 0.098633f, 0.103394f, 0.108704f, 0.113953f, 0.119934f, 0.125366f, 0.131348f, 0.137329f, 0.143555f, 0.150391f,
+ 0.157227f, 0.163818f, 0.170776f, 0.178467f, 0.185791f, 0.193359f, 0.201538f, 0.209717f, 0.218018f, 0.226807f, 0.544922f, 0.578613f,
+ 0.583984f, 0.584961f, 0.585449f, 0.584473f, 0.001067f, 0.003101f, 0.004974f, 0.006855f, 0.008522f, 0.009949f, 0.011635f, 0.012985f,
+ 0.014595f, 0.016052f, 0.017685f, 0.019012f, 0.020264f, 0.021851f, 0.023346f, 0.025146f, 0.026688f, 0.028336f, 0.030304f, 0.031860f,
+ 0.034119f, 0.035889f, 0.038025f, 0.040283f, 0.042450f, 0.044952f, 0.047302f, 0.050049f, 0.052765f, 0.055908f, 0.058594f, 0.061859f,
+ 0.064880f, 0.068481f, 0.072327f, 0.076172f, 0.080200f, 0.084290f, 0.088684f, 0.093262f, 0.098145f, 0.102905f, 0.108337f, 0.113708f,
+ 0.119080f, 0.125000f, 0.131348f, 0.137329f, 0.143921f, 0.150391f, 0.157593f, 0.164551f, 0.171753f, 0.179077f, 0.186768f, 0.194702f,
+ 0.203003f, 0.210815f, 0.534180f, 0.569336f, 0.575684f, 0.577637f, 0.577637f, 0.577148f, 0.001196f, 0.003178f, 0.004601f, 0.006241f,
+ 0.007782f, 0.009262f, 0.010391f, 0.011795f, 0.012955f, 0.014198f, 0.015518f, 0.016785f, 0.018097f, 0.019409f, 0.020782f, 0.022247f,
+ 0.023544f, 0.025269f, 0.026749f, 0.028152f, 0.030045f, 0.031555f, 0.033630f, 0.035645f, 0.037567f, 0.039642f, 0.041992f, 0.044281f,
+ 0.046692f, 0.049042f, 0.052094f, 0.054779f, 0.057831f, 0.060760f, 0.064209f, 0.067627f, 0.071228f, 0.075256f, 0.079224f, 0.083557f,
+ 0.087891f, 0.092468f, 0.097168f, 0.102356f, 0.107605f, 0.113098f, 0.119019f, 0.124878f, 0.130859f, 0.137451f, 0.144287f, 0.150635f,
+ 0.157471f, 0.164917f, 0.171997f, 0.179932f, 0.187378f, 0.196899f, 0.521973f, 0.560547f, 0.566895f, 0.569824f, 0.570312f, 0.568848f,
+ 0.001242f, 0.002674f, 0.004421f, 0.005573f, 0.006882f, 0.008354f, 0.009491f, 0.010559f, 0.011406f, 0.012695f, 0.013893f, 0.014908f,
+ 0.015854f, 0.017044f, 0.018234f, 0.019501f, 0.020752f, 0.022003f, 0.023254f, 0.024689f, 0.026154f, 0.027802f, 0.029434f, 0.031113f,
+ 0.032898f, 0.034668f, 0.036774f, 0.038910f, 0.040802f, 0.043030f, 0.045593f, 0.048065f, 0.050873f, 0.053680f, 0.056458f, 0.059692f,
+ 0.062866f, 0.066467f, 0.069946f, 0.074036f, 0.077942f, 0.082275f, 0.086731f, 0.091614f, 0.096313f, 0.101562f, 0.106934f, 0.112671f,
+ 0.118591f, 0.124634f, 0.130859f, 0.137207f, 0.144043f, 0.151123f, 0.157593f, 0.165283f, 0.173218f, 0.180664f, 0.510254f, 0.550781f,
+ 0.558105f, 0.561035f, 0.562012f, 0.562012f, 0.000842f, 0.002552f, 0.003769f, 0.005333f, 0.006149f, 0.007298f, 0.008362f, 0.009224f,
+ 0.010254f, 0.011230f, 0.012108f, 0.013092f, 0.014000f, 0.014992f, 0.016006f, 0.016953f, 0.017990f, 0.019196f, 0.020142f, 0.021622f,
+ 0.022827f, 0.024216f, 0.025513f, 0.026993f, 0.028564f, 0.030212f, 0.032013f, 0.033813f, 0.035706f, 0.037598f, 0.039703f, 0.041840f,
+ 0.044159f, 0.046539f, 0.049347f, 0.052155f, 0.055084f, 0.058228f, 0.061554f, 0.065002f, 0.068909f, 0.072693f, 0.076599f, 0.081238f,
+ 0.085388f, 0.090515f, 0.095764f, 0.100891f, 0.106689f, 0.112366f, 0.118103f, 0.124634f, 0.130859f, 0.137573f, 0.144287f, 0.151855f,
+ 0.158447f, 0.166260f, 0.498535f, 0.541992f, 0.549805f, 0.553711f, 0.554199f, 0.554688f, 0.000874f, 0.002186f, 0.003445f, 0.004807f,
+ 0.005562f, 0.006607f, 0.007378f, 0.008102f, 0.008919f, 0.009666f, 0.010513f, 0.011131f, 0.012039f, 0.012848f, 0.013779f, 0.014671f,
+ 0.015465f, 0.016464f, 0.017517f, 0.018585f, 0.019730f, 0.020798f, 0.022018f, 0.023300f, 0.024612f, 0.026093f, 0.027374f, 0.029022f,
+ 0.030624f, 0.032440f, 0.034180f, 0.036285f, 0.038116f, 0.040344f, 0.042725f, 0.045349f, 0.047913f, 0.050476f, 0.053406f, 0.056488f,
+ 0.059998f, 0.063354f, 0.067383f, 0.071289f, 0.075562f, 0.079834f, 0.084656f, 0.089478f, 0.094849f, 0.100342f, 0.106140f, 0.111877f,
+ 0.118042f, 0.124573f, 0.130981f, 0.137451f, 0.144653f, 0.152588f, 0.486816f, 0.531738f, 0.541016f, 0.545410f, 0.547363f, 0.546875f,
+ 0.000667f, 0.002001f, 0.003244f, 0.003895f, 0.004936f, 0.005608f, 0.006477f, 0.006901f, 0.007648f, 0.008354f, 0.009132f, 0.009766f,
+ 0.010490f, 0.011177f, 0.011780f, 0.012543f, 0.013420f, 0.014084f, 0.015045f, 0.015961f, 0.016876f, 0.017822f, 0.018768f, 0.019958f,
+ 0.021255f, 0.022232f, 0.023560f, 0.024780f, 0.026108f, 0.027634f, 0.029221f, 0.030762f, 0.032684f, 0.034576f, 0.036621f, 0.038605f,
+ 0.040985f, 0.043488f, 0.046021f, 0.049042f, 0.051727f, 0.054901f, 0.058441f, 0.061981f, 0.065552f, 0.069885f, 0.074097f, 0.078857f,
+ 0.083923f, 0.088623f, 0.094360f, 0.099854f, 0.105957f, 0.111694f, 0.118164f, 0.124817f, 0.131836f, 0.138794f, 0.474365f, 0.522949f,
+ 0.532227f, 0.536621f, 0.538574f, 0.539062f, 0.000876f, 0.002020f, 0.002857f, 0.003855f, 0.004436f, 0.005009f, 0.005482f, 0.006130f,
+ 0.006588f, 0.007084f, 0.007656f, 0.008286f, 0.008949f, 0.009506f, 0.010025f, 0.010803f, 0.011444f, 0.012047f, 0.012802f, 0.013512f,
+ 0.014305f, 0.015282f, 0.016052f, 0.016846f, 0.017914f, 0.018829f, 0.019882f, 0.021027f, 0.022232f, 0.023453f, 0.024689f, 0.026169f,
+ 0.027573f, 0.029327f, 0.031036f, 0.032806f, 0.034882f, 0.036743f, 0.039032f, 0.041626f, 0.044312f, 0.046936f, 0.050018f, 0.053253f,
+ 0.056610f, 0.060272f, 0.064392f, 0.068542f, 0.072937f, 0.078003f, 0.082886f, 0.088318f, 0.093933f, 0.099670f, 0.106140f, 0.112000f,
+ 0.118713f, 0.125732f, 0.463135f, 0.513672f, 0.524414f, 0.528809f, 0.530762f, 0.532227f, 0.000573f, 0.001698f, 0.002670f, 0.003082f,
+ 0.003735f, 0.004318f, 0.004673f, 0.005161f, 0.005779f, 0.006203f, 0.006565f, 0.007015f, 0.007591f, 0.007965f, 0.008583f, 0.009094f,
+ 0.009491f, 0.010239f, 0.010780f, 0.011353f, 0.012047f, 0.012787f, 0.013504f, 0.014206f, 0.015060f, 0.015915f, 0.016708f, 0.017685f,
+ 0.018677f, 0.019653f, 0.020828f, 0.021866f, 0.023224f, 0.024445f, 0.025818f, 0.027557f, 0.029114f, 0.030991f, 0.032928f, 0.035034f,
+ 0.037201f, 0.039581f, 0.042328f, 0.045166f, 0.048157f, 0.051392f, 0.054962f, 0.058685f, 0.062988f, 0.067444f, 0.072021f, 0.077148f,
+ 0.082520f, 0.088196f, 0.093750f, 0.100403f, 0.106201f, 0.112976f, 0.450928f, 0.503906f, 0.515137f, 0.520020f, 0.522949f, 0.524414f,
+ 0.000643f, 0.001637f, 0.002197f, 0.002800f, 0.003376f, 0.003613f, 0.003914f, 0.004391f, 0.004742f, 0.005150f, 0.005466f, 0.005924f,
+ 0.006344f, 0.006645f, 0.007046f, 0.007591f, 0.008118f, 0.008560f, 0.008934f, 0.009529f, 0.010147f, 0.010651f, 0.011276f, 0.011787f,
+ 0.012543f, 0.013229f, 0.013916f, 0.014740f, 0.015564f, 0.016388f, 0.017258f, 0.018188f, 0.019257f, 0.020355f, 0.021729f, 0.022766f,
+ 0.024277f, 0.025696f, 0.027237f, 0.029022f, 0.030945f, 0.033020f, 0.035248f, 0.037689f, 0.040405f, 0.043182f, 0.046295f, 0.049866f,
+ 0.053528f, 0.057526f, 0.061920f, 0.066284f, 0.071716f, 0.077209f, 0.082703f, 0.088196f, 0.094177f, 0.101074f, 0.438965f, 0.494629f,
+ 0.507324f, 0.512207f, 0.515137f, 0.516113f, 0.000484f, 0.001272f, 0.001968f, 0.002327f, 0.002573f, 0.003054f, 0.003338f, 0.003660f,
+ 0.003906f, 0.004303f, 0.004658f, 0.004921f, 0.005222f, 0.005547f, 0.005878f, 0.006290f, 0.006542f, 0.007015f, 0.007442f, 0.007851f,
+ 0.008339f, 0.008713f, 0.009247f, 0.009811f, 0.010345f, 0.010849f, 0.011490f, 0.012123f, 0.012733f, 0.013428f, 0.014183f, 0.014961f,
+ 0.015839f, 0.016815f, 0.017731f, 0.018768f, 0.019821f, 0.021072f, 0.022385f, 0.023727f, 0.025345f, 0.027084f, 0.028946f, 0.030914f,
+ 0.033295f, 0.035614f, 0.038513f, 0.041473f, 0.044678f, 0.048462f, 0.052338f, 0.056671f, 0.061310f, 0.066101f, 0.071533f, 0.077148f,
+ 0.083069f, 0.089172f, 0.427246f, 0.485352f, 0.498535f, 0.503906f, 0.508301f, 0.509766f, 0.000416f, 0.001121f, 0.001410f, 0.001959f,
+ 0.002159f, 0.002558f, 0.002724f, 0.002939f, 0.003220f, 0.003447f, 0.003733f, 0.003944f, 0.004219f, 0.004578f, 0.004810f, 0.005100f,
+ 0.005402f, 0.005783f, 0.006077f, 0.006382f, 0.006729f, 0.007141f, 0.007526f, 0.007965f, 0.008354f, 0.008858f, 0.009300f, 0.009789f,
+ 0.010452f, 0.010986f, 0.011658f, 0.012131f, 0.012833f, 0.013702f, 0.014435f, 0.015266f, 0.016113f, 0.017136f, 0.018143f, 0.019241f,
+ 0.020493f, 0.021820f, 0.023346f, 0.025085f, 0.027023f, 0.028976f, 0.031174f, 0.033966f, 0.036743f, 0.039856f, 0.043396f, 0.047180f,
+ 0.051605f, 0.056152f, 0.061127f, 0.066284f, 0.072021f, 0.078247f, 0.415283f, 0.475586f, 0.490234f, 0.496338f, 0.499756f, 0.501953f,
+ 0.000493f, 0.001126f, 0.001391f, 0.001574f, 0.001786f, 0.002073f, 0.002188f, 0.002417f, 0.002657f, 0.002785f, 0.002964f, 0.003189f,
+ 0.003384f, 0.003687f, 0.003859f, 0.004124f, 0.004330f, 0.004555f, 0.004890f, 0.005119f, 0.005451f, 0.005749f, 0.006054f, 0.006348f,
+ 0.006683f, 0.007050f, 0.007458f, 0.007889f, 0.008339f, 0.008751f, 0.009323f, 0.009766f, 0.010353f, 0.010887f, 0.011520f, 0.012192f,
+ 0.012932f, 0.013748f, 0.014542f, 0.015434f, 0.016434f, 0.017471f, 0.018723f, 0.019989f, 0.021500f, 0.023117f, 0.024948f, 0.027100f,
+ 0.029770f, 0.032166f, 0.035248f, 0.038696f, 0.042633f, 0.046875f, 0.051605f, 0.056427f, 0.061859f, 0.067688f, 0.403320f, 0.467041f,
+ 0.480957f, 0.487793f, 0.491699f, 0.494385f, 0.000336f, 0.000673f, 0.001150f, 0.001274f, 0.001482f, 0.001630f, 0.001748f, 0.001904f,
+ 0.002087f, 0.002232f, 0.002306f, 0.002497f, 0.002672f, 0.002872f, 0.003092f, 0.003225f, 0.003387f, 0.003553f, 0.003819f, 0.003979f,
+ 0.004230f, 0.004517f, 0.004738f, 0.005016f, 0.005322f, 0.005569f, 0.005848f, 0.006184f, 0.006573f, 0.006851f, 0.007271f, 0.007660f,
+ 0.008064f, 0.008568f, 0.009048f, 0.009567f, 0.010139f, 0.010788f, 0.011391f, 0.012161f, 0.012939f, 0.013763f, 0.014694f, 0.015717f,
+ 0.016815f, 0.018097f, 0.019714f, 0.021149f, 0.023270f, 0.025421f, 0.028015f, 0.030991f, 0.034271f, 0.038116f, 0.042328f, 0.046997f,
+ 0.052094f, 0.057770f, 0.391113f, 0.457031f, 0.472412f, 0.479736f, 0.484375f, 0.486816f, 0.000309f, 0.000612f, 0.000953f, 0.001086f,
+ 0.001191f, 0.001281f, 0.001351f, 0.001442f, 0.001610f, 0.001733f, 0.001783f, 0.001991f, 0.002087f, 0.002232f, 0.002337f, 0.002495f,
+ 0.002611f, 0.002775f, 0.002935f, 0.003101f, 0.003302f, 0.003496f, 0.003622f, 0.003839f, 0.004047f, 0.004265f, 0.004494f, 0.004738f,
+ 0.005039f, 0.005272f, 0.005650f, 0.005898f, 0.006210f, 0.006588f, 0.006950f, 0.007332f, 0.007782f, 0.008240f, 0.008766f, 0.009331f,
+ 0.009964f, 0.010612f, 0.011314f, 0.012062f, 0.013023f, 0.014038f, 0.015007f, 0.016251f, 0.017761f, 0.019501f, 0.021530f, 0.023926f,
+ 0.026718f, 0.030106f, 0.033905f, 0.038361f, 0.043060f, 0.048370f, 0.379395f, 0.446777f, 0.464111f, 0.471191f, 0.475586f, 0.479492f,
+ 0.000439f, 0.000476f, 0.000672f, 0.000752f, 0.000810f, 0.000949f, 0.001011f, 0.001121f, 0.001160f, 0.001249f, 0.001408f, 0.001493f,
+ 0.001591f, 0.001719f, 0.001788f, 0.001845f, 0.001982f, 0.002106f, 0.002201f, 0.002357f, 0.002460f, 0.002598f, 0.002724f, 0.002869f,
+ 0.003036f, 0.003187f, 0.003397f, 0.003569f, 0.003763f, 0.004017f, 0.004211f, 0.004414f, 0.004704f, 0.004890f, 0.005234f, 0.005524f,
+ 0.005825f, 0.006187f, 0.006535f, 0.006977f, 0.007423f, 0.007874f, 0.008553f, 0.009079f, 0.009857f, 0.010567f, 0.011360f, 0.012306f,
+ 0.013390f, 0.014702f, 0.016220f, 0.017960f, 0.020157f, 0.022995f, 0.026352f, 0.030212f, 0.034790f, 0.039459f, 0.368408f, 0.437744f,
+ 0.455322f, 0.463379f, 0.468018f, 0.471436f, 0.000202f, 0.000437f, 0.000488f, 0.000579f, 0.000664f, 0.000692f, 0.000792f, 0.000762f,
+ 0.000875f, 0.000949f, 0.001038f, 0.001068f, 0.001116f, 0.001196f, 0.001300f, 0.001352f, 0.001458f, 0.001529f, 0.001623f, 0.001667f,
+ 0.001770f, 0.001884f, 0.001989f, 0.002071f, 0.002203f, 0.002310f, 0.002445f, 0.002556f, 0.002680f, 0.002876f, 0.002991f, 0.003206f,
+ 0.003365f, 0.003531f, 0.003759f, 0.003956f, 0.004227f, 0.004513f, 0.004768f, 0.005074f, 0.005402f, 0.005756f, 0.006142f, 0.006603f,
+ 0.007160f, 0.007645f, 0.008339f, 0.008987f, 0.009819f, 0.010780f, 0.011803f, 0.013153f, 0.014763f, 0.016876f, 0.019623f, 0.022995f,
+ 0.026978f, 0.031708f, 0.356445f, 0.428223f, 0.446533f, 0.455078f, 0.460449f, 0.463379f, 0.000126f, 0.000241f, 0.000344f, 0.000353f,
+ 0.000437f, 0.000522f, 0.000513f, 0.000552f, 0.000613f, 0.000699f, 0.000717f, 0.000727f, 0.000763f, 0.000848f, 0.000877f, 0.000956f,
+ 0.000963f, 0.001068f, 0.001128f, 0.001170f, 0.001238f, 0.001311f, 0.001385f, 0.001454f, 0.001534f, 0.001603f, 0.001714f, 0.001779f,
+ 0.001885f, 0.002016f, 0.002092f, 0.002214f, 0.002331f, 0.002460f, 0.002613f, 0.002777f, 0.002924f, 0.003120f, 0.003298f, 0.003496f,
+ 0.003708f, 0.004009f, 0.004292f, 0.004601f, 0.004951f, 0.005341f, 0.005772f, 0.006260f, 0.006901f, 0.007572f, 0.008324f, 0.009300f,
+ 0.010445f, 0.011848f, 0.013870f, 0.016678f, 0.020218f, 0.024536f, 0.345703f, 0.419189f, 0.437500f, 0.447021f, 0.452393f, 0.455811f,
+ 0.000146f, 0.000240f, 0.000268f, 0.000268f, 0.000310f, 0.000311f, 0.000331f, 0.000366f, 0.000410f, 0.000447f, 0.000446f, 0.000517f,
+ 0.000511f, 0.000571f, 0.000596f, 0.000618f, 0.000674f, 0.000691f, 0.000723f, 0.000762f, 0.000822f, 0.000856f, 0.000912f, 0.000950f,
+ 0.001014f, 0.001049f, 0.001128f, 0.001188f, 0.001237f, 0.001303f, 0.001371f, 0.001466f, 0.001532f, 0.001623f, 0.001701f, 0.001805f,
+ 0.001945f, 0.002035f, 0.002186f, 0.002329f, 0.002460f, 0.002632f, 0.002819f, 0.003012f, 0.003271f, 0.003550f, 0.003819f, 0.004162f,
+ 0.004539f, 0.005024f, 0.005585f, 0.006233f, 0.007050f, 0.008072f, 0.009331f, 0.011269f, 0.014160f, 0.018112f, 0.333740f, 0.408447f,
+ 0.428711f, 0.438232f, 0.443359f, 0.447510f, 0.000053f, 0.000163f, 0.000155f, 0.000160f, 0.000191f, 0.000228f, 0.000206f, 0.000233f,
+ 0.000248f, 0.000263f, 0.000267f, 0.000294f, 0.000324f, 0.000335f, 0.000364f, 0.000378f, 0.000396f, 0.000435f, 0.000445f, 0.000490f,
+ 0.000502f, 0.000522f, 0.000543f, 0.000582f, 0.000619f, 0.000665f, 0.000679f, 0.000705f, 0.000755f, 0.000797f, 0.000856f, 0.000887f,
+ 0.000953f, 0.000988f, 0.001043f, 0.001103f, 0.001177f, 0.001256f, 0.001331f, 0.001410f, 0.001508f, 0.001612f, 0.001734f, 0.001873f,
+ 0.001999f, 0.002163f, 0.002378f, 0.002565f, 0.002827f, 0.003119f, 0.003479f, 0.003899f, 0.004463f, 0.005116f, 0.005951f, 0.007153f,
+ 0.009163f, 0.012535f, 0.322510f, 0.400146f, 0.420654f, 0.430176f, 0.436523f, 0.440430f, 0.000097f, 0.000107f, 0.000095f, 0.000087f,
+ 0.000107f, 0.000110f, 0.000137f, 0.000139f, 0.000140f, 0.000147f, 0.000168f, 0.000175f, 0.000177f, 0.000184f, 0.000210f, 0.000200f,
+ 0.000224f, 0.000239f, 0.000246f, 0.000258f, 0.000278f, 0.000288f, 0.000312f, 0.000324f, 0.000347f, 0.000368f, 0.000382f, 0.000395f,
+ 0.000418f, 0.000440f, 0.000471f, 0.000495f, 0.000521f, 0.000547f, 0.000577f, 0.000620f, 0.000649f, 0.000695f, 0.000749f, 0.000785f,
+ 0.000838f, 0.000897f, 0.000972f, 0.001028f, 0.001118f, 0.001204f, 0.001316f, 0.001432f, 0.001580f, 0.001748f, 0.001961f, 0.002207f,
+ 0.002533f, 0.002941f, 0.003487f, 0.004223f, 0.005371f, 0.007809f, 0.311523f, 0.390381f, 0.411377f, 0.421875f, 0.428467f, 0.432617f,
+ 0.000000f, 0.000055f, 0.000046f, 0.000054f, 0.000060f, 0.000058f, 0.000060f, 0.000068f, 0.000068f, 0.000082f, 0.000076f, 0.000078f,
+ 0.000092f, 0.000087f, 0.000091f, 0.000097f, 0.000105f, 0.000115f, 0.000118f, 0.000124f, 0.000128f, 0.000133f, 0.000139f, 0.000154f,
+ 0.000160f, 0.000172f, 0.000175f, 0.000191f, 0.000201f, 0.000211f, 0.000221f, 0.000238f, 0.000242f, 0.000257f, 0.000277f, 0.000295f,
+ 0.000309f, 0.000326f, 0.000351f, 0.000375f, 0.000400f, 0.000428f, 0.000459f, 0.000490f, 0.000535f, 0.000579f, 0.000626f, 0.000683f,
+ 0.000754f, 0.000836f, 0.000952f, 0.001064f, 0.001237f, 0.001460f, 0.001751f, 0.002157f, 0.002800f, 0.004189f, 0.299561f, 0.380127f,
+ 0.403076f, 0.413574f, 0.419922f, 0.424072f, 0.000059f, 0.000039f, 0.000032f, 0.000028f, 0.000025f, 0.000025f, 0.000025f, 0.000024f,
+ 0.000023f, 0.000024f, 0.000026f, 0.000034f, 0.000029f, 0.000031f, 0.000038f, 0.000040f, 0.000042f, 0.000043f, 0.000042f, 0.000043f,
+ 0.000048f, 0.000054f, 0.000058f, 0.000056f, 0.000060f, 0.000062f, 0.000066f, 0.000069f, 0.000072f, 0.000078f, 0.000082f, 0.000085f,
+ 0.000093f, 0.000096f, 0.000099f, 0.000106f, 0.000116f, 0.000123f, 0.000132f, 0.000140f, 0.000150f, 0.000154f, 0.000167f, 0.000184f,
+ 0.000192f, 0.000212f, 0.000231f, 0.000251f, 0.000282f, 0.000314f, 0.000350f, 0.000401f, 0.000463f, 0.000554f, 0.000679f, 0.000861f,
+ 0.001157f, 0.001750f, 0.289307f, 0.371582f, 0.394043f, 0.406006f, 0.412109f, 0.417236f, 0.000031f, 0.000020f, 0.000016f, 0.000014f,
+ 0.000013f, 0.000012f, 0.000011f, 0.000011f, 0.000010f, 0.000010f, 0.000010f, 0.000009f, 0.000009f, 0.000008f, 0.000008f, 0.000009f,
+ 0.000009f, 0.000007f, 0.000008f, 0.000008f, 0.000010f, 0.000011f, 0.000012f, 0.000013f, 0.000013f, 0.000013f, 0.000014f, 0.000017f,
+ 0.000017f, 0.000016f, 0.000018f, 0.000019f, 0.000021f, 0.000021f, 0.000022f, 0.000025f, 0.000027f, 0.000025f, 0.000028f, 0.000030f,
+ 0.000033f, 0.000036f, 0.000038f, 0.000040f, 0.000042f, 0.000047f, 0.000052f, 0.000057f, 0.000060f, 0.000068f, 0.000073f, 0.000089f,
+ 0.000104f, 0.000124f, 0.000153f, 0.000204f, 0.000293f, 0.000497f, 0.278076f, 0.362793f, 0.385498f, 0.397705f, 0.405029f, 0.409912f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000001f, 0.000001f,
+ 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f,
+ 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f,
+ 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000002f,
+ 0.000002f, 0.000003f, 0.000003f, 0.000004f, 0.000004f, 0.000005f, 0.000005f, 0.000008f, 0.000012f, 0.000026f, 0.267822f, 0.353027f,
+ 0.376953f, 0.388916f, 0.395996f, 0.401367f,
+ },
+ {
+ 0.006824f, 0.021286f, 0.036285f, 0.051208f, 0.066467f, 0.082825f, 0.098694f, 0.114563f, 0.130737f, 0.146973f, 0.162720f, 0.179932f,
+ 0.196411f, 0.212646f, 0.229370f, 0.246338f, 0.263184f, 0.279785f, 0.297363f, 0.314209f, 0.331055f, 0.348389f, 0.365479f, 0.383301f,
+ 0.400146f, 0.417725f, 0.435303f, 0.451904f, 0.469971f, 0.486816f, 0.503906f, 0.521484f, 0.539551f, 0.556641f, 0.573730f, 0.592285f,
+ 0.609375f, 0.627441f, 0.644531f, 0.662598f, 0.679688f, 0.696777f, 0.714355f, 0.731934f, 0.749512f, 0.768066f, 0.784180f, 0.802246f,
+ 0.820312f, 0.837891f, 0.854980f, 0.871582f, 0.889648f, 0.906738f, 0.924805f, 0.941406f, 0.959473f, 0.976074f, 0.953125f, 0.895020f,
+ 0.857422f, 0.827637f, 0.803223f, 0.781738f, 0.006741f, 0.020706f, 0.035187f, 0.049866f, 0.065125f, 0.079895f, 0.095581f, 0.111206f,
+ 0.126953f, 0.142822f, 0.158569f, 0.174561f, 0.190796f, 0.207031f, 0.223511f, 0.239380f, 0.256104f, 0.272705f, 0.289307f, 0.305664f,
+ 0.322754f, 0.338867f, 0.356201f, 0.372314f, 0.389404f, 0.406494f, 0.423828f, 0.440430f, 0.457520f, 0.474854f, 0.491211f, 0.508789f,
+ 0.525391f, 0.541992f, 0.559082f, 0.576660f, 0.594238f, 0.610840f, 0.627930f, 0.645508f, 0.662598f, 0.679199f, 0.696289f, 0.713379f,
+ 0.731445f, 0.747559f, 0.765137f, 0.782715f, 0.799805f, 0.816895f, 0.834473f, 0.851074f, 0.868164f, 0.884766f, 0.902344f, 0.919434f,
+ 0.936523f, 0.953613f, 0.942871f, 0.887695f, 0.851562f, 0.823730f, 0.799805f, 0.779297f, 0.006504f, 0.020004f, 0.033875f, 0.048676f,
+ 0.063110f, 0.077759f, 0.092712f, 0.108032f, 0.123230f, 0.138672f, 0.153931f, 0.170044f, 0.185791f, 0.200806f, 0.217041f, 0.233276f,
+ 0.248901f, 0.265137f, 0.280762f, 0.297363f, 0.313721f, 0.329834f, 0.346680f, 0.363037f, 0.378418f, 0.395752f, 0.411621f, 0.428467f,
+ 0.445312f, 0.461670f, 0.479004f, 0.494873f, 0.511230f, 0.527832f, 0.544434f, 0.561523f, 0.578613f, 0.594727f, 0.611328f, 0.628906f,
+ 0.645508f, 0.662109f, 0.679199f, 0.695312f, 0.712402f, 0.729004f, 0.746094f, 0.762695f, 0.779297f, 0.796387f, 0.812500f, 0.829590f,
+ 0.846191f, 0.863281f, 0.879395f, 0.896973f, 0.914062f, 0.930176f, 0.932129f, 0.879395f, 0.845703f, 0.818848f, 0.795898f, 0.776367f,
+ 0.006226f, 0.019318f, 0.032959f, 0.046631f, 0.060699f, 0.075745f, 0.089966f, 0.104553f, 0.119385f, 0.134277f, 0.149292f, 0.164917f,
+ 0.179932f, 0.195190f, 0.210693f, 0.226562f, 0.242188f, 0.257568f, 0.273438f, 0.289062f, 0.304932f, 0.320557f, 0.336426f, 0.352539f,
+ 0.368652f, 0.384766f, 0.400391f, 0.417236f, 0.433105f, 0.448730f, 0.465088f, 0.481689f, 0.497559f, 0.513672f, 0.528809f, 0.546875f,
+ 0.562500f, 0.578613f, 0.595215f, 0.612793f, 0.627930f, 0.645508f, 0.661621f, 0.677246f, 0.693848f, 0.709961f, 0.726562f, 0.743164f,
+ 0.759766f, 0.774902f, 0.791992f, 0.808594f, 0.825195f, 0.841309f, 0.856934f, 0.874023f, 0.890625f, 0.907715f, 0.921387f, 0.872070f,
+ 0.839355f, 0.813477f, 0.791504f, 0.772461f, 0.005928f, 0.018997f, 0.031830f, 0.045380f, 0.059235f, 0.072754f, 0.087463f, 0.101562f,
+ 0.115723f, 0.130371f, 0.145264f, 0.159668f, 0.175049f, 0.189453f, 0.204468f, 0.219482f, 0.234497f, 0.250000f, 0.266113f, 0.280273f,
+ 0.295410f, 0.311768f, 0.327393f, 0.343018f, 0.357422f, 0.373779f, 0.389404f, 0.404785f, 0.421143f, 0.437012f, 0.452881f, 0.468262f,
+ 0.484375f, 0.499512f, 0.515137f, 0.531738f, 0.546875f, 0.562500f, 0.579102f, 0.595215f, 0.610840f, 0.627441f, 0.643555f, 0.659180f,
+ 0.674805f, 0.691406f, 0.708008f, 0.723145f, 0.738770f, 0.755371f, 0.771484f, 0.787598f, 0.803711f, 0.819824f, 0.835449f, 0.851562f,
+ 0.867676f, 0.884277f, 0.910156f, 0.864258f, 0.832520f, 0.808105f, 0.787109f, 0.769043f, 0.005939f, 0.018066f, 0.030991f, 0.043488f,
+ 0.057312f, 0.070557f, 0.084473f, 0.098328f, 0.112610f, 0.126587f, 0.140259f, 0.154907f, 0.169678f, 0.184326f, 0.198608f, 0.213379f,
+ 0.227783f, 0.242065f, 0.257568f, 0.272705f, 0.287109f, 0.302246f, 0.318115f, 0.333252f, 0.347656f, 0.362549f, 0.378418f, 0.393555f,
+ 0.408936f, 0.423828f, 0.439697f, 0.455078f, 0.471191f, 0.484863f, 0.500488f, 0.517578f, 0.532227f, 0.547363f, 0.562500f, 0.579102f,
+ 0.594727f, 0.610352f, 0.625488f, 0.641602f, 0.657227f, 0.671875f, 0.687500f, 0.704102f, 0.719238f, 0.733887f, 0.750488f, 0.767090f,
+ 0.782715f, 0.798340f, 0.813965f, 0.830566f, 0.845215f, 0.862305f, 0.899902f, 0.855469f, 0.825684f, 0.801758f, 0.782227f, 0.764648f,
+ 0.005684f, 0.017639f, 0.030334f, 0.042572f, 0.055298f, 0.068054f, 0.081787f, 0.095276f, 0.108765f, 0.122192f, 0.136353f, 0.150513f,
+ 0.164307f, 0.178467f, 0.192627f, 0.206665f, 0.221436f, 0.234985f, 0.249634f, 0.264404f, 0.278564f, 0.293213f, 0.308350f, 0.321533f,
+ 0.337646f, 0.353027f, 0.367432f, 0.381592f, 0.395996f, 0.411865f, 0.426758f, 0.441895f, 0.456543f, 0.471680f, 0.485840f, 0.501465f,
+ 0.517090f, 0.531738f, 0.546387f, 0.562012f, 0.576660f, 0.592773f, 0.608398f, 0.623047f, 0.638672f, 0.654297f, 0.668457f, 0.684082f,
+ 0.699707f, 0.714844f, 0.730469f, 0.745605f, 0.761230f, 0.777832f, 0.791504f, 0.807617f, 0.823242f, 0.839355f, 0.889160f, 0.847656f,
+ 0.818848f, 0.796387f, 0.776855f, 0.760254f, 0.005417f, 0.017136f, 0.028778f, 0.041016f, 0.054047f, 0.066528f, 0.079590f, 0.092102f,
+ 0.105225f, 0.118652f, 0.131714f, 0.145630f, 0.158813f, 0.172607f, 0.186523f, 0.200317f, 0.213745f, 0.227905f, 0.242188f, 0.256104f,
+ 0.270020f, 0.283936f, 0.299072f, 0.312744f, 0.327148f, 0.341797f, 0.355957f, 0.369629f, 0.384766f, 0.399414f, 0.413574f, 0.427490f,
+ 0.443115f, 0.457764f, 0.472656f, 0.487061f, 0.501465f, 0.516602f, 0.530762f, 0.545898f, 0.560547f, 0.574707f, 0.589844f, 0.605469f,
+ 0.619629f, 0.633301f, 0.648926f, 0.665527f, 0.679688f, 0.694824f, 0.709961f, 0.725586f, 0.739746f, 0.755371f, 0.770020f, 0.786133f,
+ 0.802246f, 0.817383f, 0.877930f, 0.838867f, 0.812012f, 0.790039f, 0.771973f, 0.755371f, 0.005520f, 0.016464f, 0.027695f, 0.039948f,
+ 0.051575f, 0.063965f, 0.076660f, 0.089111f, 0.101807f, 0.114319f, 0.126953f, 0.140381f, 0.153564f, 0.166992f, 0.180298f, 0.193970f,
+ 0.207153f, 0.220337f, 0.234131f, 0.248169f, 0.261475f, 0.275146f, 0.288818f, 0.302734f, 0.316162f, 0.330566f, 0.345459f, 0.358887f,
+ 0.372803f, 0.386719f, 0.401367f, 0.415527f, 0.429199f, 0.443848f, 0.458008f, 0.472412f, 0.486572f, 0.500977f, 0.515137f, 0.529785f,
+ 0.544434f, 0.558105f, 0.572754f, 0.587891f, 0.601074f, 0.617188f, 0.631836f, 0.645020f, 0.660645f, 0.674805f, 0.689453f, 0.704590f,
+ 0.719727f, 0.734375f, 0.750000f, 0.764160f, 0.780273f, 0.794922f, 0.866699f, 0.830566f, 0.804688f, 0.784180f, 0.766113f, 0.750977f,
+ 0.005222f, 0.016022f, 0.026962f, 0.038086f, 0.050049f, 0.061798f, 0.074158f, 0.085876f, 0.098145f, 0.110718f, 0.122986f, 0.135864f,
+ 0.148438f, 0.161133f, 0.173584f, 0.187378f, 0.199707f, 0.213501f, 0.226440f, 0.240112f, 0.252441f, 0.266113f, 0.279785f, 0.292725f,
+ 0.306152f, 0.320068f, 0.333984f, 0.347900f, 0.361572f, 0.374512f, 0.387695f, 0.402344f, 0.416504f, 0.429688f, 0.443604f, 0.458008f,
+ 0.471680f, 0.485596f, 0.499023f, 0.513184f, 0.527832f, 0.541016f, 0.555664f, 0.569336f, 0.583984f, 0.598633f, 0.612793f, 0.626465f,
+ 0.641602f, 0.656250f, 0.669922f, 0.684570f, 0.698730f, 0.713867f, 0.728516f, 0.742188f, 0.757812f, 0.771484f, 0.855957f, 0.822266f,
+ 0.797852f, 0.777832f, 0.760742f, 0.746094f, 0.004944f, 0.015327f, 0.026230f, 0.037201f, 0.048187f, 0.059448f, 0.071167f, 0.082642f,
+ 0.094727f, 0.106506f, 0.119019f, 0.130371f, 0.143555f, 0.155640f, 0.167725f, 0.180908f, 0.193604f, 0.206177f, 0.218506f, 0.231812f,
+ 0.244873f, 0.257568f, 0.270996f, 0.283203f, 0.296387f, 0.309814f, 0.322754f, 0.336670f, 0.348877f, 0.362061f, 0.376465f, 0.389893f,
+ 0.402588f, 0.415283f, 0.429443f, 0.443115f, 0.457031f, 0.470459f, 0.483887f, 0.497314f, 0.511230f, 0.524414f, 0.538574f, 0.551758f,
+ 0.565918f, 0.579590f, 0.593750f, 0.606934f, 0.621094f, 0.635254f, 0.649902f, 0.664062f, 0.678223f, 0.692871f, 0.707031f, 0.721191f,
+ 0.735840f, 0.750488f, 0.846191f, 0.813477f, 0.790527f, 0.770996f, 0.754883f, 0.740723f, 0.004951f, 0.014656f, 0.025253f, 0.035309f,
+ 0.046417f, 0.057465f, 0.068665f, 0.079773f, 0.091370f, 0.102844f, 0.114441f, 0.126099f, 0.138062f, 0.150391f, 0.161987f, 0.174561f,
+ 0.186523f, 0.198730f, 0.211060f, 0.223267f, 0.235352f, 0.248779f, 0.260986f, 0.274414f, 0.286621f, 0.298584f, 0.312256f, 0.324463f,
+ 0.337158f, 0.350342f, 0.363281f, 0.376953f, 0.389404f, 0.402344f, 0.415283f, 0.428955f, 0.441162f, 0.455322f, 0.467285f, 0.481201f,
+ 0.493896f, 0.507324f, 0.520996f, 0.534668f, 0.547852f, 0.561035f, 0.575195f, 0.588867f, 0.603027f, 0.616211f, 0.630371f, 0.643555f,
+ 0.658203f, 0.671875f, 0.686035f, 0.699707f, 0.714844f, 0.729492f, 0.833984f, 0.804688f, 0.782227f, 0.764160f, 0.749512f, 0.735352f,
+ 0.004700f, 0.014343f, 0.024200f, 0.034515f, 0.044586f, 0.055176f, 0.066162f, 0.077209f, 0.087830f, 0.098816f, 0.110413f, 0.121826f,
+ 0.132690f, 0.144897f, 0.156372f, 0.168213f, 0.179443f, 0.191650f, 0.203369f, 0.215088f, 0.227661f, 0.239990f, 0.251709f, 0.263916f,
+ 0.276611f, 0.289551f, 0.301270f, 0.313965f, 0.325928f, 0.338135f, 0.350586f, 0.363037f, 0.376465f, 0.388428f, 0.401123f, 0.414062f,
+ 0.426514f, 0.439209f, 0.452393f, 0.465088f, 0.478271f, 0.491455f, 0.503906f, 0.517090f, 0.530273f, 0.543457f, 0.556641f, 0.570312f,
+ 0.583008f, 0.597168f, 0.610352f, 0.624512f, 0.638184f, 0.651367f, 0.665527f, 0.679199f, 0.692871f, 0.708496f, 0.823242f, 0.796387f,
+ 0.774902f, 0.757812f, 0.742676f, 0.729980f, 0.004395f, 0.013802f, 0.023499f, 0.033173f, 0.043121f, 0.053345f, 0.063538f, 0.073730f,
+ 0.085083f, 0.095581f, 0.106140f, 0.116760f, 0.127930f, 0.139160f, 0.150757f, 0.161621f, 0.173096f, 0.184814f, 0.196289f, 0.207520f,
+ 0.219971f, 0.231201f, 0.242920f, 0.254150f, 0.266602f, 0.278320f, 0.290527f, 0.302490f, 0.314209f, 0.326904f, 0.338867f, 0.349854f,
+ 0.362305f, 0.375488f, 0.387451f, 0.400146f, 0.412354f, 0.424805f, 0.436768f, 0.449219f, 0.461914f, 0.475098f, 0.487061f, 0.500000f,
+ 0.512695f, 0.525391f, 0.538574f, 0.551758f, 0.564453f, 0.577148f, 0.590820f, 0.604004f, 0.618164f, 0.631348f, 0.644531f, 0.658203f,
+ 0.672363f, 0.686523f, 0.812500f, 0.786621f, 0.767090f, 0.750977f, 0.736816f, 0.724609f, 0.004425f, 0.013405f, 0.022385f, 0.032043f,
+ 0.041565f, 0.051605f, 0.061340f, 0.071106f, 0.081116f, 0.091125f, 0.101868f, 0.112671f, 0.123169f, 0.133667f, 0.144897f, 0.155029f,
+ 0.166748f, 0.177246f, 0.188599f, 0.199585f, 0.211182f, 0.222046f, 0.233643f, 0.245361f, 0.255615f, 0.268066f, 0.279053f, 0.291260f,
+ 0.303223f, 0.314209f, 0.325684f, 0.338379f, 0.349854f, 0.361572f, 0.374023f, 0.385254f, 0.397949f, 0.409912f, 0.421143f, 0.434082f,
+ 0.445801f, 0.457764f, 0.470215f, 0.482910f, 0.495361f, 0.508301f, 0.520996f, 0.534180f, 0.546387f, 0.560059f, 0.572266f, 0.584961f,
+ 0.597168f, 0.610840f, 0.624023f, 0.638184f, 0.650879f, 0.666016f, 0.801270f, 0.778320f, 0.760254f, 0.744141f, 0.730469f, 0.719238f,
+ 0.004261f, 0.012543f, 0.021591f, 0.031052f, 0.039734f, 0.049164f, 0.058838f, 0.068420f, 0.077881f, 0.087402f, 0.098145f, 0.108276f,
+ 0.118225f, 0.128784f, 0.138550f, 0.149292f, 0.159790f, 0.170654f, 0.181519f, 0.191772f, 0.203003f, 0.213623f, 0.225098f, 0.235107f,
+ 0.247070f, 0.257324f, 0.269287f, 0.280273f, 0.291260f, 0.302246f, 0.313721f, 0.325439f, 0.336670f, 0.348145f, 0.359619f, 0.371338f,
+ 0.382812f, 0.395020f, 0.406738f, 0.418213f, 0.429932f, 0.442139f, 0.454102f, 0.466309f, 0.479004f, 0.490723f, 0.502930f, 0.515625f,
+ 0.526855f, 0.540527f, 0.552246f, 0.565918f, 0.578613f, 0.591309f, 0.604492f, 0.617188f, 0.630859f, 0.644043f, 0.790039f, 0.769531f,
+ 0.751953f, 0.737305f, 0.724121f, 0.713379f, 0.003983f, 0.012329f, 0.020538f, 0.029312f, 0.038452f, 0.047241f, 0.056244f, 0.065552f,
+ 0.075195f, 0.084290f, 0.094238f, 0.103638f, 0.113403f, 0.123413f, 0.133057f, 0.143066f, 0.153076f, 0.163696f, 0.173584f, 0.184204f,
+ 0.194580f, 0.204834f, 0.215332f, 0.225952f, 0.237305f, 0.247803f, 0.258545f, 0.269531f, 0.280518f, 0.291260f, 0.301758f, 0.312988f,
+ 0.324219f, 0.335205f, 0.346191f, 0.357178f, 0.368896f, 0.380127f, 0.391113f, 0.403076f, 0.414551f, 0.426270f, 0.437500f, 0.449951f,
+ 0.460938f, 0.473389f, 0.485596f, 0.497314f, 0.509277f, 0.522461f, 0.533691f, 0.546875f, 0.558594f, 0.571289f, 0.583496f, 0.596680f,
+ 0.608887f, 0.623047f, 0.778809f, 0.761230f, 0.744141f, 0.730957f, 0.718262f, 0.707031f, 0.003717f, 0.012016f, 0.020142f, 0.028137f,
+ 0.036682f, 0.045441f, 0.053711f, 0.062927f, 0.071777f, 0.080627f, 0.090210f, 0.099060f, 0.108643f, 0.118164f, 0.127808f, 0.137329f,
+ 0.147095f, 0.156128f, 0.166748f, 0.175903f, 0.186157f, 0.196655f, 0.206909f, 0.216797f, 0.227417f, 0.236816f, 0.247559f, 0.258301f,
+ 0.268799f, 0.278809f, 0.289795f, 0.299805f, 0.310547f, 0.321777f, 0.333008f, 0.343262f, 0.354492f, 0.365234f, 0.376953f, 0.387939f,
+ 0.398438f, 0.410400f, 0.421387f, 0.433105f, 0.444824f, 0.455811f, 0.467529f, 0.479736f, 0.491943f, 0.502930f, 0.515625f, 0.527344f,
+ 0.540039f, 0.551758f, 0.563965f, 0.576660f, 0.589844f, 0.602539f, 0.767578f, 0.751465f, 0.736328f, 0.723633f, 0.711914f, 0.701660f,
+ 0.003813f, 0.011337f, 0.019028f, 0.027252f, 0.035583f, 0.043396f, 0.051849f, 0.060028f, 0.068481f, 0.077026f, 0.086121f, 0.095093f,
+ 0.103821f, 0.112610f, 0.121765f, 0.131470f, 0.140503f, 0.149780f, 0.159058f, 0.168701f, 0.178711f, 0.187744f, 0.197998f, 0.207397f,
+ 0.217651f, 0.227661f, 0.236694f, 0.246704f, 0.257080f, 0.267334f, 0.277832f, 0.288330f, 0.298584f, 0.308838f, 0.319336f, 0.329590f,
+ 0.340332f, 0.351318f, 0.361816f, 0.372559f, 0.383301f, 0.395020f, 0.405273f, 0.416260f, 0.427734f, 0.439209f, 0.450195f, 0.462158f,
+ 0.473389f, 0.485107f, 0.497314f, 0.508301f, 0.520996f, 0.533203f, 0.544922f, 0.557617f, 0.568848f, 0.582031f, 0.757324f, 0.742676f,
+ 0.729004f, 0.716309f, 0.705566f, 0.695801f, 0.003633f, 0.011040f, 0.018280f, 0.026062f, 0.033569f, 0.041229f, 0.049591f, 0.057373f,
+ 0.065308f, 0.073975f, 0.082214f, 0.090393f, 0.099243f, 0.107544f, 0.116028f, 0.125854f, 0.134155f, 0.143311f, 0.151978f, 0.160767f,
+ 0.170410f, 0.179321f, 0.188477f, 0.198242f, 0.207764f, 0.217896f, 0.227051f, 0.236328f, 0.246338f, 0.256104f, 0.265869f, 0.276123f,
+ 0.285645f, 0.295898f, 0.306152f, 0.316162f, 0.326172f, 0.336914f, 0.347412f, 0.358154f, 0.368164f, 0.378906f, 0.389648f, 0.400146f,
+ 0.410889f, 0.421631f, 0.432861f, 0.444824f, 0.456055f, 0.466797f, 0.479004f, 0.490234f, 0.501465f, 0.514160f, 0.525879f, 0.537598f,
+ 0.549316f, 0.561523f, 0.745605f, 0.733887f, 0.721191f, 0.708496f, 0.699219f, 0.689453f, 0.003469f, 0.010429f, 0.017609f, 0.024612f,
+ 0.032135f, 0.039520f, 0.047516f, 0.055206f, 0.062347f, 0.070618f, 0.078308f, 0.085938f, 0.094727f, 0.102417f, 0.111511f, 0.119446f,
+ 0.127441f, 0.136475f, 0.144897f, 0.154175f, 0.162476f, 0.171509f, 0.180054f, 0.189697f, 0.198486f, 0.207886f, 0.216553f, 0.225830f,
+ 0.235229f, 0.244873f, 0.254395f, 0.263428f, 0.273193f, 0.283203f, 0.292969f, 0.302734f, 0.312744f, 0.322510f, 0.333008f, 0.342773f,
+ 0.353027f, 0.363037f, 0.374023f, 0.384521f, 0.395264f, 0.405762f, 0.416260f, 0.427002f, 0.438232f, 0.449219f, 0.460449f, 0.471924f,
+ 0.482910f, 0.494629f, 0.506348f, 0.517578f, 0.529785f, 0.541504f, 0.734375f, 0.725098f, 0.712891f, 0.701660f, 0.692383f, 0.683594f,
+ 0.003328f, 0.009804f, 0.016373f, 0.023727f, 0.030746f, 0.037994f, 0.044952f, 0.052032f, 0.059998f, 0.067383f, 0.074707f, 0.082214f,
+ 0.089783f, 0.097961f, 0.105774f, 0.114197f, 0.122131f, 0.129517f, 0.137695f, 0.146118f, 0.154419f, 0.163330f, 0.171997f, 0.180664f,
+ 0.188477f, 0.197388f, 0.206055f, 0.215332f, 0.224365f, 0.233765f, 0.242798f, 0.251709f, 0.260986f, 0.270020f, 0.279785f, 0.289062f,
+ 0.299561f, 0.308594f, 0.318115f, 0.328613f, 0.338135f, 0.348877f, 0.358154f, 0.368408f, 0.378174f, 0.388916f, 0.399658f, 0.410156f,
+ 0.420898f, 0.431885f, 0.442871f, 0.453369f, 0.463867f, 0.475342f, 0.486572f, 0.498535f, 0.510742f, 0.521973f, 0.723633f, 0.715820f,
+ 0.705078f, 0.694336f, 0.686035f, 0.677246f, 0.003090f, 0.009628f, 0.016129f, 0.022644f, 0.029068f, 0.036407f, 0.042633f, 0.049866f,
+ 0.056946f, 0.063904f, 0.071167f, 0.078186f, 0.085327f, 0.092896f, 0.100098f, 0.107788f, 0.115662f, 0.123230f, 0.131104f, 0.139160f,
+ 0.146973f, 0.154907f, 0.162964f, 0.171265f, 0.179565f, 0.188110f, 0.196777f, 0.204834f, 0.213745f, 0.222168f, 0.231079f, 0.239868f,
+ 0.248779f, 0.258057f, 0.267090f, 0.276611f, 0.285645f, 0.294434f, 0.304688f, 0.314209f, 0.323242f, 0.332520f, 0.342773f, 0.353027f,
+ 0.362549f, 0.373047f, 0.383057f, 0.393311f, 0.404053f, 0.414307f, 0.424561f, 0.435059f, 0.445801f, 0.456787f, 0.467773f, 0.479004f,
+ 0.490479f, 0.501953f, 0.712891f, 0.707031f, 0.696777f, 0.687500f, 0.679199f, 0.671387f, 0.003096f, 0.009026f, 0.015450f, 0.021606f,
+ 0.027695f, 0.034302f, 0.040833f, 0.047455f, 0.054077f, 0.060669f, 0.067444f, 0.074097f, 0.081604f, 0.088501f, 0.095337f, 0.102295f,
+ 0.109375f, 0.116821f, 0.124146f, 0.131592f, 0.139404f, 0.147217f, 0.155029f, 0.162231f, 0.170288f, 0.177979f, 0.186646f, 0.194092f,
+ 0.203247f, 0.211670f, 0.219604f, 0.228149f, 0.236816f, 0.245605f, 0.254639f, 0.263184f, 0.272217f, 0.281250f, 0.290527f, 0.299805f,
+ 0.308838f, 0.318604f, 0.327637f, 0.337646f, 0.347900f, 0.356934f, 0.367432f, 0.376953f, 0.387451f, 0.397217f, 0.407227f, 0.417480f,
+ 0.427979f, 0.439209f, 0.449463f, 0.459717f, 0.470947f, 0.482666f, 0.701172f, 0.698242f, 0.688477f, 0.680176f, 0.671875f, 0.665039f,
+ 0.002831f, 0.008789f, 0.014702f, 0.020523f, 0.026642f, 0.032684f, 0.038757f, 0.044708f, 0.051666f, 0.057312f, 0.063660f, 0.070190f,
+ 0.076904f, 0.083435f, 0.090454f, 0.097046f, 0.103821f, 0.110535f, 0.117981f, 0.124817f, 0.131714f, 0.138916f, 0.146606f, 0.153687f,
+ 0.161011f, 0.168823f, 0.176270f, 0.184570f, 0.192139f, 0.200317f, 0.208008f, 0.216309f, 0.224609f, 0.233032f, 0.241821f, 0.250244f,
+ 0.258789f, 0.268066f, 0.276611f, 0.285400f, 0.294678f, 0.303223f, 0.312500f, 0.322021f, 0.331787f, 0.340088f, 0.350830f, 0.360596f,
+ 0.369385f, 0.380371f, 0.389893f, 0.399658f, 0.410645f, 0.420654f, 0.430908f, 0.442383f, 0.452148f, 0.464111f, 0.690430f, 0.688965f,
+ 0.681152f, 0.672852f, 0.665039f, 0.658691f, 0.002712f, 0.008553f, 0.013878f, 0.019638f, 0.025360f, 0.030716f, 0.037231f, 0.042633f,
+ 0.048615f, 0.054810f, 0.060638f, 0.066650f, 0.072205f, 0.078796f, 0.085083f, 0.091492f, 0.097961f, 0.104065f, 0.110718f, 0.117859f,
+ 0.124207f, 0.130981f, 0.138550f, 0.145142f, 0.152588f, 0.160156f, 0.166992f, 0.174561f, 0.181885f, 0.189453f, 0.197754f, 0.205444f,
+ 0.213013f, 0.220825f, 0.229004f, 0.237061f, 0.246094f, 0.254639f, 0.262939f, 0.271484f, 0.280273f, 0.288818f, 0.298584f, 0.307129f,
+ 0.316162f, 0.325195f, 0.334229f, 0.344482f, 0.353516f, 0.363525f, 0.372803f, 0.382812f, 0.392822f, 0.402344f, 0.412842f, 0.423096f,
+ 0.433350f, 0.444092f, 0.679199f, 0.679688f, 0.672852f, 0.665039f, 0.658203f, 0.651855f, 0.002674f, 0.007828f, 0.013290f, 0.018723f,
+ 0.023743f, 0.029160f, 0.034790f, 0.040100f, 0.045929f, 0.051544f, 0.057068f, 0.063110f, 0.068359f, 0.074280f, 0.080078f, 0.086243f,
+ 0.092346f, 0.098206f, 0.104919f, 0.110779f, 0.117493f, 0.123291f, 0.130005f, 0.136963f, 0.143677f, 0.150635f, 0.157471f, 0.164307f,
+ 0.171631f, 0.179199f, 0.186279f, 0.193604f, 0.201904f, 0.209229f, 0.217163f, 0.224976f, 0.233154f, 0.240967f, 0.249634f, 0.258301f,
+ 0.266113f, 0.274414f, 0.283691f, 0.291748f, 0.301025f, 0.310059f, 0.319336f, 0.327148f, 0.337402f, 0.347168f, 0.355957f, 0.364746f,
+ 0.375488f, 0.385498f, 0.394043f, 0.405273f, 0.415283f, 0.426025f, 0.667969f, 0.670410f, 0.664551f, 0.657227f, 0.651367f, 0.645508f,
+ 0.002731f, 0.007622f, 0.012627f, 0.017868f, 0.022781f, 0.028107f, 0.032959f, 0.037811f, 0.043121f, 0.048615f, 0.053925f, 0.059235f,
+ 0.064514f, 0.070007f, 0.075562f, 0.080688f, 0.086914f, 0.092102f, 0.098083f, 0.104309f, 0.110107f, 0.115906f, 0.122314f, 0.128540f,
+ 0.135010f, 0.141479f, 0.147949f, 0.154663f, 0.161865f, 0.168579f, 0.175415f, 0.182739f, 0.191040f, 0.197510f, 0.205200f, 0.212891f,
+ 0.219971f, 0.228638f, 0.236328f, 0.244263f, 0.252686f, 0.260498f, 0.268799f, 0.278076f, 0.286133f, 0.294434f, 0.303223f, 0.312500f,
+ 0.320801f, 0.329834f, 0.339844f, 0.347656f, 0.357910f, 0.367676f, 0.376709f, 0.386963f, 0.396729f, 0.406982f, 0.656738f, 0.662598f,
+ 0.656738f, 0.649902f, 0.644531f, 0.638672f, 0.002411f, 0.007168f, 0.012238f, 0.016739f, 0.021957f, 0.026184f, 0.031311f, 0.035583f,
+ 0.041016f, 0.045685f, 0.050568f, 0.055573f, 0.060791f, 0.065735f, 0.070557f, 0.076111f, 0.081238f, 0.086792f, 0.092163f, 0.097534f,
+ 0.103271f, 0.108887f, 0.114563f, 0.120605f, 0.126587f, 0.132446f, 0.139038f, 0.145508f, 0.152100f, 0.158447f, 0.165527f, 0.171997f,
+ 0.178833f, 0.186035f, 0.193481f, 0.200928f, 0.207886f, 0.215820f, 0.222900f, 0.230713f, 0.238770f, 0.246948f, 0.255127f, 0.262695f,
+ 0.271484f, 0.280029f, 0.287842f, 0.296631f, 0.305420f, 0.313965f, 0.322754f, 0.331787f, 0.340576f, 0.350342f, 0.359375f, 0.369385f,
+ 0.379150f, 0.388184f, 0.645508f, 0.652832f, 0.648438f, 0.643066f, 0.637695f, 0.632324f, 0.002480f, 0.006691f, 0.011452f, 0.015900f,
+ 0.020828f, 0.024734f, 0.029327f, 0.033752f, 0.038513f, 0.042999f, 0.047638f, 0.052429f, 0.056671f, 0.061859f, 0.066040f, 0.071289f,
+ 0.075684f, 0.080688f, 0.086243f, 0.091248f, 0.096436f, 0.101562f, 0.107300f, 0.112366f, 0.118347f, 0.124146f, 0.130249f, 0.135864f,
+ 0.141968f, 0.148438f, 0.155029f, 0.161377f, 0.167969f, 0.174683f, 0.181641f, 0.188599f, 0.195679f, 0.203247f, 0.210449f, 0.217529f,
+ 0.225342f, 0.233398f, 0.241577f, 0.249023f, 0.256592f, 0.264893f, 0.273193f, 0.281494f, 0.289795f, 0.297607f, 0.306885f, 0.315430f,
+ 0.323730f, 0.333496f, 0.342529f, 0.351318f, 0.360840f, 0.370605f, 0.634766f, 0.643555f, 0.640625f, 0.635742f, 0.630859f, 0.625488f,
+ 0.002230f, 0.006477f, 0.010582f, 0.014870f, 0.019073f, 0.023270f, 0.027893f, 0.031860f, 0.036072f, 0.040253f, 0.044373f, 0.048706f,
+ 0.052856f, 0.057312f, 0.061859f, 0.066406f, 0.070984f, 0.075317f, 0.080139f, 0.084839f, 0.089661f, 0.094910f, 0.099792f, 0.104858f,
+ 0.110718f, 0.115356f, 0.121399f, 0.126831f, 0.132690f, 0.138672f, 0.145142f, 0.151001f, 0.157471f, 0.164185f, 0.170532f, 0.177002f,
+ 0.184082f, 0.191040f, 0.197876f, 0.205200f, 0.212402f, 0.219604f, 0.227295f, 0.234985f, 0.242188f, 0.250244f, 0.257812f, 0.266113f,
+ 0.274170f, 0.282471f, 0.290771f, 0.299072f, 0.307373f, 0.316162f, 0.326416f, 0.333984f, 0.343750f, 0.353271f, 0.622070f, 0.634277f,
+ 0.631836f, 0.627930f, 0.623535f, 0.619141f, 0.002220f, 0.006039f, 0.010353f, 0.014328f, 0.017838f, 0.022141f, 0.025742f, 0.029510f,
+ 0.033600f, 0.037781f, 0.041443f, 0.045502f, 0.049469f, 0.053436f, 0.057190f, 0.061462f, 0.065735f, 0.069946f, 0.074524f, 0.078674f,
+ 0.083069f, 0.087830f, 0.092468f, 0.097412f, 0.102783f, 0.107910f, 0.112793f, 0.118164f, 0.123901f, 0.129395f, 0.135132f, 0.140991f,
+ 0.147339f, 0.152954f, 0.159302f, 0.165527f, 0.172363f, 0.178589f, 0.185425f, 0.191895f, 0.199219f, 0.206665f, 0.213989f, 0.221069f,
+ 0.228516f, 0.236206f, 0.243042f, 0.251709f, 0.258789f, 0.266846f, 0.275146f, 0.283203f, 0.291260f, 0.300537f, 0.308350f, 0.317627f,
+ 0.326904f, 0.335938f, 0.611816f, 0.625000f, 0.624023f, 0.620117f, 0.616211f, 0.612793f, 0.001965f, 0.005882f, 0.009613f, 0.013184f,
+ 0.016785f, 0.020370f, 0.024384f, 0.027664f, 0.031311f, 0.035126f, 0.038727f, 0.042572f, 0.046112f, 0.049347f, 0.053253f, 0.056915f,
+ 0.060883f, 0.064697f, 0.068909f, 0.072693f, 0.076843f, 0.081055f, 0.085754f, 0.090088f, 0.094849f, 0.099609f, 0.104614f, 0.109741f,
+ 0.114746f, 0.119995f, 0.125488f, 0.130981f, 0.136719f, 0.142700f, 0.148315f, 0.154541f, 0.160522f, 0.166870f, 0.173828f, 0.179932f,
+ 0.186768f, 0.193604f, 0.200439f, 0.207764f, 0.214844f, 0.221802f, 0.228882f, 0.236328f, 0.244385f, 0.252197f, 0.259277f, 0.268066f,
+ 0.275635f, 0.283447f, 0.292236f, 0.301270f, 0.309570f, 0.318848f, 0.600098f, 0.616211f, 0.615234f, 0.612793f, 0.609375f, 0.605469f,
+ 0.001966f, 0.005653f, 0.009109f, 0.012428f, 0.015945f, 0.018967f, 0.022537f, 0.025894f, 0.029175f, 0.032440f, 0.035797f, 0.038818f,
+ 0.042389f, 0.046051f, 0.049072f, 0.052521f, 0.056335f, 0.059906f, 0.063293f, 0.067017f, 0.070923f, 0.075134f, 0.078979f, 0.083496f,
+ 0.087646f, 0.091980f, 0.096619f, 0.101196f, 0.105957f, 0.111145f, 0.116028f, 0.121277f, 0.126831f, 0.132080f, 0.137817f, 0.143311f,
+ 0.149780f, 0.155029f, 0.161621f, 0.167847f, 0.173950f, 0.180786f, 0.187622f, 0.194214f, 0.201050f, 0.207764f, 0.215210f, 0.222046f,
+ 0.229370f, 0.236816f, 0.244751f, 0.251953f, 0.260010f, 0.268311f, 0.276123f, 0.284180f, 0.293213f, 0.301514f, 0.588379f, 0.606934f,
+ 0.607422f, 0.604980f, 0.602051f, 0.599609f, 0.001963f, 0.005333f, 0.008377f, 0.011589f, 0.014450f, 0.017593f, 0.021133f, 0.023972f,
+ 0.027145f, 0.030075f, 0.033295f, 0.035858f, 0.038818f, 0.041992f, 0.045288f, 0.048279f, 0.051849f, 0.054840f, 0.058289f, 0.061737f,
+ 0.065186f, 0.068848f, 0.072632f, 0.076721f, 0.080505f, 0.084717f, 0.088806f, 0.093079f, 0.097717f, 0.102356f, 0.106934f, 0.111755f,
+ 0.116882f, 0.121887f, 0.127319f, 0.132935f, 0.138306f, 0.144287f, 0.149902f, 0.156250f, 0.162109f, 0.168579f, 0.174316f, 0.180908f,
+ 0.187500f, 0.194458f, 0.201538f, 0.208252f, 0.215210f, 0.222656f, 0.229980f, 0.237061f, 0.244629f, 0.252441f, 0.260254f, 0.267334f,
+ 0.276123f, 0.284180f, 0.576660f, 0.597656f, 0.599609f, 0.598145f, 0.595215f, 0.591797f, 0.001631f, 0.004906f, 0.007805f, 0.010826f,
+ 0.013802f, 0.016983f, 0.019485f, 0.022079f, 0.024750f, 0.027939f, 0.030136f, 0.033112f, 0.035797f, 0.038727f, 0.041443f, 0.044281f,
+ 0.047058f, 0.050018f, 0.053253f, 0.056396f, 0.059662f, 0.063049f, 0.066406f, 0.069946f, 0.073730f, 0.077454f, 0.081360f, 0.085388f,
+ 0.089417f, 0.093750f, 0.098267f, 0.102844f, 0.107727f, 0.112244f, 0.117615f, 0.122253f, 0.127441f, 0.133057f, 0.138550f, 0.144287f,
+ 0.150024f, 0.156250f, 0.161987f, 0.167969f, 0.174805f, 0.181274f, 0.187744f, 0.194580f, 0.201294f, 0.208374f, 0.215210f, 0.222412f,
+ 0.229736f, 0.237183f, 0.244629f, 0.252197f, 0.260010f, 0.269287f, 0.566406f, 0.588867f, 0.590820f, 0.590332f, 0.587891f, 0.585938f,
+ 0.001858f, 0.004318f, 0.007465f, 0.010246f, 0.012550f, 0.015793f, 0.018143f, 0.020782f, 0.022980f, 0.025116f, 0.027924f, 0.030106f,
+ 0.032623f, 0.035126f, 0.037720f, 0.040283f, 0.042847f, 0.045380f, 0.048492f, 0.051300f, 0.054321f, 0.057373f, 0.060516f, 0.063599f,
+ 0.067139f, 0.070496f, 0.074219f, 0.078003f, 0.081848f, 0.085754f, 0.089783f, 0.093994f, 0.098267f, 0.102783f, 0.107239f, 0.112366f,
+ 0.117371f, 0.122498f, 0.127686f, 0.132935f, 0.138428f, 0.144043f, 0.150024f, 0.155884f, 0.161865f, 0.168091f, 0.174316f, 0.180664f,
+ 0.187622f, 0.194214f, 0.200928f, 0.207520f, 0.214966f, 0.221680f, 0.229370f, 0.236816f, 0.244751f, 0.252441f, 0.553223f, 0.579102f,
+ 0.583496f, 0.582031f, 0.581055f, 0.579590f, 0.001425f, 0.004284f, 0.007019f, 0.009521f, 0.011894f, 0.014191f, 0.016632f, 0.018723f,
+ 0.021210f, 0.023209f, 0.025482f, 0.027344f, 0.029617f, 0.032043f, 0.034210f, 0.036407f, 0.039001f, 0.041077f, 0.043976f, 0.046448f,
+ 0.049133f, 0.051819f, 0.054932f, 0.057770f, 0.060730f, 0.063965f, 0.067322f, 0.070862f, 0.074280f, 0.077698f, 0.082031f, 0.085571f,
+ 0.089844f, 0.093994f, 0.098022f, 0.102722f, 0.107178f, 0.111877f, 0.116821f, 0.121887f, 0.127075f, 0.132446f, 0.138062f, 0.143799f,
+ 0.149414f, 0.155518f, 0.161377f, 0.167480f, 0.173950f, 0.180176f, 0.186890f, 0.193481f, 0.200562f, 0.207397f, 0.214355f, 0.221313f,
+ 0.229492f, 0.237427f, 0.541504f, 0.570801f, 0.575195f, 0.575195f, 0.573730f, 0.572266f, 0.001613f, 0.004181f, 0.006252f, 0.008774f,
+ 0.011108f, 0.013054f, 0.015152f, 0.016937f, 0.019150f, 0.021011f, 0.023163f, 0.024826f, 0.026993f, 0.028793f, 0.030823f, 0.033081f,
+ 0.035156f, 0.037201f, 0.039612f, 0.041748f, 0.044464f, 0.046814f, 0.049438f, 0.052155f, 0.054840f, 0.057831f, 0.060699f, 0.063599f,
+ 0.067078f, 0.070374f, 0.073853f, 0.077087f, 0.081177f, 0.085083f, 0.089111f, 0.093262f, 0.097473f, 0.101929f, 0.106689f, 0.111023f,
+ 0.116455f, 0.121277f, 0.126343f, 0.132080f, 0.137573f, 0.142700f, 0.148682f, 0.154907f, 0.161133f, 0.167236f, 0.173340f, 0.179688f,
+ 0.186768f, 0.193115f, 0.200684f, 0.207275f, 0.214233f, 0.221924f, 0.530273f, 0.561523f, 0.565430f, 0.567383f, 0.564941f, 0.564941f,
+ 0.001237f, 0.003775f, 0.006348f, 0.008141f, 0.010117f, 0.012184f, 0.013763f, 0.015656f, 0.017319f, 0.018967f, 0.020645f, 0.022507f,
+ 0.023926f, 0.025757f, 0.027573f, 0.029449f, 0.031677f, 0.033325f, 0.035645f, 0.037659f, 0.039734f, 0.041809f, 0.044189f, 0.046692f,
+ 0.049133f, 0.051697f, 0.054504f, 0.057251f, 0.060059f, 0.063110f, 0.066467f, 0.069763f, 0.072937f, 0.076477f, 0.080505f, 0.084290f,
+ 0.088013f, 0.092407f, 0.096436f, 0.101013f, 0.105713f, 0.110352f, 0.115356f, 0.120605f, 0.125488f, 0.130981f, 0.136353f, 0.142090f,
+ 0.148438f, 0.153931f, 0.159912f, 0.166260f, 0.172485f, 0.179321f, 0.185791f, 0.193115f, 0.199463f, 0.206665f, 0.520020f, 0.552246f,
+ 0.558105f, 0.559570f, 0.559082f, 0.557617f, 0.001151f, 0.003399f, 0.005611f, 0.007439f, 0.009354f, 0.010925f, 0.012489f, 0.014061f,
+ 0.015610f, 0.017258f, 0.018845f, 0.020248f, 0.021484f, 0.023193f, 0.024796f, 0.026459f, 0.028183f, 0.029785f, 0.031738f, 0.033386f,
+ 0.035309f, 0.037384f, 0.039368f, 0.041626f, 0.043701f, 0.046204f, 0.048553f, 0.051178f, 0.053955f, 0.056488f, 0.059418f, 0.062256f,
+ 0.065308f, 0.068542f, 0.071899f, 0.075623f, 0.079224f, 0.082947f, 0.087097f, 0.091064f, 0.095520f, 0.099854f, 0.104736f, 0.109314f,
+ 0.114136f, 0.119324f, 0.124756f, 0.130127f, 0.135498f, 0.141113f, 0.146973f, 0.153198f, 0.159180f, 0.165527f, 0.172241f, 0.178711f,
+ 0.185425f, 0.192749f, 0.507324f, 0.543945f, 0.549316f, 0.552246f, 0.551270f, 0.551270f, 0.001070f, 0.002996f, 0.004986f, 0.006851f,
+ 0.008514f, 0.009850f, 0.011330f, 0.012596f, 0.014015f, 0.015259f, 0.016586f, 0.017731f, 0.019287f, 0.020676f, 0.022079f, 0.023468f,
+ 0.024765f, 0.026489f, 0.028030f, 0.029465f, 0.031311f, 0.032898f, 0.034851f, 0.036743f, 0.038940f, 0.040833f, 0.043091f, 0.045074f,
+ 0.047729f, 0.050079f, 0.052673f, 0.055389f, 0.058136f, 0.061188f, 0.064087f, 0.067261f, 0.070618f, 0.074158f, 0.077942f, 0.081726f,
+ 0.085815f, 0.089783f, 0.094055f, 0.098572f, 0.103088f, 0.107971f, 0.113037f, 0.118164f, 0.123413f, 0.128784f, 0.134521f, 0.140137f,
+ 0.146118f, 0.152100f, 0.158325f, 0.164307f, 0.171387f, 0.177368f, 0.496094f, 0.534668f, 0.541992f, 0.543945f, 0.544434f, 0.544434f,
+ 0.001086f, 0.003069f, 0.004463f, 0.006256f, 0.007393f, 0.009026f, 0.010178f, 0.011276f, 0.012260f, 0.013542f, 0.014648f, 0.015808f,
+ 0.016861f, 0.017899f, 0.019333f, 0.020599f, 0.021942f, 0.023117f, 0.024384f, 0.025833f, 0.027344f, 0.028992f, 0.030579f, 0.032318f,
+ 0.034149f, 0.035828f, 0.037842f, 0.039764f, 0.041901f, 0.044037f, 0.046539f, 0.048645f, 0.051147f, 0.053894f, 0.056641f, 0.059631f,
+ 0.062500f, 0.065735f, 0.069031f, 0.072754f, 0.076294f, 0.080139f, 0.083984f, 0.088379f, 0.092712f, 0.097229f, 0.101929f, 0.106873f,
+ 0.111694f, 0.117004f, 0.122314f, 0.127930f, 0.133789f, 0.139282f, 0.145142f, 0.151367f, 0.157349f, 0.163818f, 0.484619f, 0.525391f,
+ 0.534180f, 0.536621f, 0.536133f, 0.536621f, 0.001125f, 0.002892f, 0.003883f, 0.005867f, 0.006603f, 0.007935f, 0.009026f, 0.009911f,
+ 0.010956f, 0.012077f, 0.012909f, 0.013901f, 0.014977f, 0.015671f, 0.016983f, 0.018021f, 0.019058f, 0.020279f, 0.021225f, 0.022598f,
+ 0.023941f, 0.025299f, 0.026535f, 0.028107f, 0.029755f, 0.031113f, 0.033020f, 0.034668f, 0.036682f, 0.038483f, 0.040527f, 0.042511f,
+ 0.044708f, 0.046936f, 0.049744f, 0.052216f, 0.054840f, 0.057800f, 0.060791f, 0.064087f, 0.067505f, 0.071045f, 0.074463f, 0.078491f,
+ 0.082397f, 0.086609f, 0.091248f, 0.095581f, 0.100342f, 0.105530f, 0.110474f, 0.116272f, 0.120972f, 0.126953f, 0.132812f, 0.138672f,
+ 0.144287f, 0.150513f, 0.472412f, 0.516113f, 0.524902f, 0.528809f, 0.529785f, 0.529785f, 0.000859f, 0.002470f, 0.003815f, 0.005226f,
+ 0.005913f, 0.007206f, 0.007942f, 0.008652f, 0.009583f, 0.010406f, 0.011223f, 0.011971f, 0.012856f, 0.013664f, 0.014664f, 0.015549f,
+ 0.016464f, 0.017487f, 0.018478f, 0.019592f, 0.020767f, 0.021774f, 0.023117f, 0.024338f, 0.025604f, 0.027008f, 0.028519f, 0.029953f,
+ 0.031525f, 0.033173f, 0.034943f, 0.036865f, 0.038696f, 0.040863f, 0.042969f, 0.045471f, 0.048004f, 0.050293f, 0.052979f, 0.055847f,
+ 0.058960f, 0.062042f, 0.065491f, 0.069153f, 0.072937f, 0.076660f, 0.080750f, 0.085144f, 0.089539f, 0.094177f, 0.099304f, 0.104187f,
+ 0.109741f, 0.114807f, 0.120483f, 0.125977f, 0.131836f, 0.138306f, 0.460449f, 0.507812f, 0.516602f, 0.520020f, 0.522461f, 0.522949f,
+ 0.000906f, 0.002359f, 0.003643f, 0.004356f, 0.005310f, 0.005989f, 0.007030f, 0.007507f, 0.008255f, 0.009010f, 0.009834f, 0.010483f,
+ 0.011230f, 0.011887f, 0.012573f, 0.013367f, 0.014252f, 0.014954f, 0.015900f, 0.016785f, 0.017776f, 0.018631f, 0.019775f, 0.020874f,
+ 0.022110f, 0.023117f, 0.024368f, 0.025589f, 0.026932f, 0.028549f, 0.029938f, 0.031525f, 0.033325f, 0.035187f, 0.037109f, 0.038971f,
+ 0.041138f, 0.043396f, 0.045715f, 0.048370f, 0.051025f, 0.053772f, 0.057129f, 0.060089f, 0.063416f, 0.067261f, 0.070679f, 0.075012f,
+ 0.079285f, 0.083618f, 0.088379f, 0.093018f, 0.098083f, 0.102478f, 0.108093f, 0.114380f, 0.119507f, 0.125488f, 0.448975f, 0.498291f,
+ 0.508789f, 0.513672f, 0.514648f, 0.516113f, 0.000728f, 0.001932f, 0.003067f, 0.003990f, 0.004784f, 0.005295f, 0.005974f, 0.006584f,
+ 0.007099f, 0.007652f, 0.008255f, 0.008904f, 0.009491f, 0.010109f, 0.010658f, 0.011497f, 0.012131f, 0.012718f, 0.013535f, 0.014336f,
+ 0.015083f, 0.016083f, 0.016785f, 0.017761f, 0.018738f, 0.019669f, 0.020691f, 0.021805f, 0.023010f, 0.024170f, 0.025467f, 0.026794f,
+ 0.028336f, 0.029922f, 0.031555f, 0.033203f, 0.035034f, 0.036987f, 0.039062f, 0.041290f, 0.043671f, 0.046143f, 0.048920f, 0.051880f,
+ 0.054901f, 0.058228f, 0.061615f, 0.065369f, 0.069214f, 0.073425f, 0.077637f, 0.082214f, 0.087097f, 0.091797f, 0.096497f, 0.102356f,
+ 0.107483f, 0.113464f, 0.437256f, 0.489746f, 0.500977f, 0.504883f, 0.507812f, 0.509277f, 0.000724f, 0.001842f, 0.002728f, 0.003332f,
+ 0.004101f, 0.004707f, 0.005020f, 0.005497f, 0.006245f, 0.006603f, 0.007027f, 0.007515f, 0.008156f, 0.008537f, 0.009125f, 0.009659f,
+ 0.010101f, 0.010864f, 0.011482f, 0.012070f, 0.012756f, 0.013496f, 0.014236f, 0.014931f, 0.015808f, 0.016632f, 0.017487f, 0.018433f,
+ 0.019379f, 0.020416f, 0.021530f, 0.022583f, 0.023804f, 0.024979f, 0.026443f, 0.027939f, 0.029526f, 0.031235f, 0.033020f, 0.035004f,
+ 0.037018f, 0.039185f, 0.041595f, 0.044159f, 0.046783f, 0.049866f, 0.052856f, 0.056274f, 0.059906f, 0.063721f, 0.067749f, 0.072327f,
+ 0.076172f, 0.081299f, 0.085938f, 0.091309f, 0.096558f, 0.101807f, 0.426270f, 0.480469f, 0.492676f, 0.498047f, 0.500488f, 0.501953f,
+ 0.000673f, 0.001715f, 0.002426f, 0.002953f, 0.003588f, 0.003944f, 0.004200f, 0.004776f, 0.005131f, 0.005527f, 0.005886f, 0.006371f,
+ 0.006790f, 0.007076f, 0.007538f, 0.008133f, 0.008644f, 0.009140f, 0.009483f, 0.010071f, 0.010689f, 0.011230f, 0.011879f, 0.012474f,
+ 0.013222f, 0.013916f, 0.014587f, 0.015411f, 0.016190f, 0.016983f, 0.017883f, 0.018845f, 0.019867f, 0.020935f, 0.022141f, 0.023270f,
+ 0.024567f, 0.026001f, 0.027481f, 0.029114f, 0.030777f, 0.032684f, 0.034698f, 0.036865f, 0.039337f, 0.041748f, 0.044647f, 0.047882f,
+ 0.050964f, 0.054260f, 0.058258f, 0.062195f, 0.066528f, 0.070679f, 0.075623f, 0.080505f, 0.085510f, 0.090515f, 0.414307f, 0.472168f,
+ 0.484131f, 0.490234f, 0.492920f, 0.495850f, 0.000484f, 0.001445f, 0.002169f, 0.002569f, 0.002836f, 0.003317f, 0.003569f, 0.003952f,
+ 0.004215f, 0.004623f, 0.004959f, 0.005306f, 0.005592f, 0.005951f, 0.006306f, 0.006737f, 0.007004f, 0.007492f, 0.007942f, 0.008331f,
+ 0.008865f, 0.009270f, 0.009781f, 0.010338f, 0.010887f, 0.011429f, 0.012047f, 0.012726f, 0.013336f, 0.014030f, 0.014771f, 0.015572f,
+ 0.016418f, 0.017258f, 0.018234f, 0.019196f, 0.020279f, 0.021423f, 0.022675f, 0.023987f, 0.025375f, 0.027039f, 0.028702f, 0.030563f,
+ 0.032623f, 0.034698f, 0.037262f, 0.040039f, 0.042664f, 0.046051f, 0.049194f, 0.052948f, 0.057129f, 0.061371f, 0.065613f, 0.070007f,
+ 0.075317f, 0.080200f, 0.402588f, 0.462402f, 0.476807f, 0.482666f, 0.485107f, 0.487061f, 0.000459f, 0.001265f, 0.001572f, 0.002138f,
+ 0.002365f, 0.002775f, 0.002920f, 0.003189f, 0.003454f, 0.003723f, 0.003986f, 0.004250f, 0.004536f, 0.004906f, 0.005150f, 0.005463f,
+ 0.005787f, 0.006172f, 0.006481f, 0.006794f, 0.007156f, 0.007542f, 0.007980f, 0.008430f, 0.008827f, 0.009361f, 0.009796f, 0.010300f,
+ 0.010910f, 0.011497f, 0.012161f, 0.012672f, 0.013336f, 0.014183f, 0.014893f, 0.015640f, 0.016541f, 0.017517f, 0.018448f, 0.019485f,
+ 0.020676f, 0.021912f, 0.023392f, 0.024979f, 0.026627f, 0.028351f, 0.030457f, 0.032806f, 0.035034f, 0.037933f, 0.041229f, 0.044373f,
+ 0.047821f, 0.052002f, 0.056244f, 0.060547f, 0.065247f, 0.069885f, 0.390869f, 0.453857f, 0.468018f, 0.475098f, 0.478027f, 0.480469f,
+ 0.000332f, 0.001075f, 0.001464f, 0.001721f, 0.001911f, 0.002235f, 0.002375f, 0.002558f, 0.002834f, 0.002998f, 0.003185f, 0.003441f,
+ 0.003647f, 0.003952f, 0.004139f, 0.004421f, 0.004631f, 0.004879f, 0.005180f, 0.005447f, 0.005795f, 0.006115f, 0.006416f, 0.006718f,
+ 0.007099f, 0.007462f, 0.007881f, 0.008331f, 0.008797f, 0.009140f, 0.009735f, 0.010223f, 0.010803f, 0.011337f, 0.011986f, 0.012611f,
+ 0.013283f, 0.014076f, 0.014847f, 0.015732f, 0.016693f, 0.017700f, 0.018784f, 0.019897f, 0.021317f, 0.022873f, 0.024429f, 0.026306f,
+ 0.028473f, 0.030960f, 0.033600f, 0.036407f, 0.039856f, 0.043549f, 0.047119f, 0.051392f, 0.055969f, 0.060394f, 0.379639f, 0.444580f,
+ 0.458984f, 0.467529f, 0.470947f, 0.472900f, 0.000408f, 0.000770f, 0.001271f, 0.001390f, 0.001601f, 0.001762f, 0.001848f, 0.002052f,
+ 0.002247f, 0.002401f, 0.002491f, 0.002684f, 0.002878f, 0.003086f, 0.003304f, 0.003452f, 0.003626f, 0.003805f, 0.004074f, 0.004257f,
+ 0.004513f, 0.004807f, 0.005039f, 0.005299f, 0.005638f, 0.005905f, 0.006191f, 0.006516f, 0.006927f, 0.007206f, 0.007645f, 0.008034f,
+ 0.008415f, 0.008911f, 0.009384f, 0.009941f, 0.010483f, 0.011116f, 0.011711f, 0.012428f, 0.013191f, 0.013969f, 0.014862f, 0.015854f,
+ 0.016785f, 0.017975f, 0.019348f, 0.020721f, 0.022461f, 0.024445f, 0.026733f, 0.029175f, 0.032227f, 0.035248f, 0.038788f, 0.042755f,
+ 0.046967f, 0.051636f, 0.367920f, 0.435059f, 0.452148f, 0.459229f, 0.463623f, 0.466797f, 0.000382f, 0.000669f, 0.001037f, 0.001185f,
+ 0.001293f, 0.001379f, 0.001470f, 0.001565f, 0.001729f, 0.001864f, 0.001928f, 0.002138f, 0.002237f, 0.002398f, 0.002510f, 0.002672f,
+ 0.002802f, 0.002966f, 0.003134f, 0.003319f, 0.003517f, 0.003723f, 0.003870f, 0.004089f, 0.004311f, 0.004532f, 0.004772f, 0.005013f,
+ 0.005314f, 0.005573f, 0.005924f, 0.006203f, 0.006523f, 0.006897f, 0.007240f, 0.007660f, 0.008041f, 0.008530f, 0.009048f, 0.009621f,
+ 0.010201f, 0.010841f, 0.011467f, 0.012192f, 0.013138f, 0.013969f, 0.014931f, 0.016113f, 0.017380f, 0.018936f, 0.020630f, 0.022751f,
+ 0.025208f, 0.027924f, 0.031311f, 0.034851f, 0.038879f, 0.043274f, 0.356689f, 0.426270f, 0.443848f, 0.451660f, 0.456055f, 0.459473f,
+ 0.000482f, 0.000542f, 0.000723f, 0.000822f, 0.000881f, 0.001025f, 0.001100f, 0.001209f, 0.001249f, 0.001355f, 0.001522f, 0.001599f,
+ 0.001708f, 0.001836f, 0.001918f, 0.001970f, 0.002129f, 0.002251f, 0.002357f, 0.002522f, 0.002636f, 0.002768f, 0.002911f, 0.003056f,
+ 0.003237f, 0.003393f, 0.003605f, 0.003771f, 0.003994f, 0.004234f, 0.004444f, 0.004635f, 0.004932f, 0.005150f, 0.005486f, 0.005779f,
+ 0.006081f, 0.006458f, 0.006775f, 0.007179f, 0.007668f, 0.008110f, 0.008690f, 0.009209f, 0.009926f, 0.010551f, 0.011330f, 0.012184f,
+ 0.013184f, 0.014297f, 0.015610f, 0.017181f, 0.019165f, 0.021500f, 0.024384f, 0.027618f, 0.031372f, 0.035614f, 0.345459f, 0.417236f,
+ 0.435303f, 0.443604f, 0.448730f, 0.451904f, 0.000240f, 0.000479f, 0.000533f, 0.000625f, 0.000716f, 0.000746f, 0.000857f, 0.000835f,
+ 0.000941f, 0.001024f, 0.001104f, 0.001155f, 0.001204f, 0.001282f, 0.001396f, 0.001453f, 0.001554f, 0.001627f, 0.001737f, 0.001787f,
+ 0.001894f, 0.002012f, 0.002119f, 0.002218f, 0.002335f, 0.002453f, 0.002611f, 0.002714f, 0.002848f, 0.003050f, 0.003168f, 0.003395f,
+ 0.003529f, 0.003740f, 0.003963f, 0.004158f, 0.004429f, 0.004688f, 0.004982f, 0.005280f, 0.005600f, 0.005959f, 0.006340f, 0.006775f,
+ 0.007252f, 0.007748f, 0.008369f, 0.008980f, 0.009705f, 0.010513f, 0.011513f, 0.012665f, 0.014069f, 0.015869f, 0.018158f, 0.020950f,
+ 0.024338f, 0.028366f, 0.335205f, 0.408203f, 0.427002f, 0.435547f, 0.441162f, 0.445312f, 0.000138f, 0.000265f, 0.000381f, 0.000386f,
+ 0.000465f, 0.000556f, 0.000558f, 0.000597f, 0.000659f, 0.000748f, 0.000770f, 0.000786f, 0.000829f, 0.000904f, 0.000940f, 0.001021f,
+ 0.001043f, 0.001139f, 0.001201f, 0.001253f, 0.001327f, 0.001396f, 0.001481f, 0.001555f, 0.001637f, 0.001712f, 0.001813f, 0.001899f,
+ 0.002005f, 0.002140f, 0.002220f, 0.002348f, 0.002462f, 0.002600f, 0.002733f, 0.002932f, 0.003075f, 0.003279f, 0.003452f, 0.003630f,
+ 0.003872f, 0.004166f, 0.004436f, 0.004742f, 0.005077f, 0.005459f, 0.005848f, 0.006310f, 0.006874f, 0.007492f, 0.008171f, 0.009026f,
+ 0.009995f, 0.011307f, 0.013008f, 0.015343f, 0.018265f, 0.021881f, 0.323486f, 0.399170f, 0.418945f, 0.428467f, 0.434326f, 0.437988f,
+ 0.000165f, 0.000260f, 0.000287f, 0.000296f, 0.000331f, 0.000339f, 0.000360f, 0.000395f, 0.000442f, 0.000482f, 0.000487f, 0.000551f,
+ 0.000546f, 0.000611f, 0.000640f, 0.000667f, 0.000711f, 0.000742f, 0.000775f, 0.000816f, 0.000876f, 0.000916f, 0.000974f, 0.001015f,
+ 0.001081f, 0.001123f, 0.001195f, 0.001267f, 0.001317f, 0.001388f, 0.001459f, 0.001558f, 0.001630f, 0.001718f, 0.001804f, 0.001916f,
+ 0.002033f, 0.002148f, 0.002295f, 0.002455f, 0.002583f, 0.002754f, 0.002941f, 0.003134f, 0.003386f, 0.003639f, 0.003910f, 0.004215f,
+ 0.004597f, 0.005013f, 0.005520f, 0.006130f, 0.006821f, 0.007690f, 0.008789f, 0.010452f, 0.012909f, 0.016174f, 0.312012f, 0.390381f,
+ 0.410645f, 0.420654f, 0.426270f, 0.430664f, 0.000057f, 0.000171f, 0.000164f, 0.000170f, 0.000211f, 0.000213f, 0.000229f, 0.000247f,
+ 0.000267f, 0.000279f, 0.000289f, 0.000317f, 0.000349f, 0.000364f, 0.000390f, 0.000407f, 0.000427f, 0.000467f, 0.000476f, 0.000521f,
+ 0.000537f, 0.000561f, 0.000578f, 0.000626f, 0.000667f, 0.000714f, 0.000729f, 0.000753f, 0.000806f, 0.000855f, 0.000911f, 0.000945f,
+ 0.001004f, 0.001054f, 0.001112f, 0.001172f, 0.001251f, 0.001333f, 0.001406f, 0.001489f, 0.001595f, 0.001694f, 0.001811f, 0.001952f,
+ 0.002090f, 0.002243f, 0.002453f, 0.002638f, 0.002888f, 0.003143f, 0.003489f, 0.003870f, 0.004353f, 0.004921f, 0.005672f, 0.006664f,
+ 0.008423f, 0.011230f, 0.301758f, 0.381104f, 0.402832f, 0.413330f, 0.418457f, 0.423828f, 0.000096f, 0.000112f, 0.000097f, 0.000090f,
+ 0.000113f, 0.000119f, 0.000144f, 0.000149f, 0.000151f, 0.000158f, 0.000181f, 0.000184f, 0.000179f, 0.000201f, 0.000224f, 0.000216f,
+ 0.000237f, 0.000255f, 0.000263f, 0.000276f, 0.000297f, 0.000308f, 0.000332f, 0.000347f, 0.000369f, 0.000395f, 0.000408f, 0.000422f,
+ 0.000447f, 0.000471f, 0.000500f, 0.000531f, 0.000554f, 0.000583f, 0.000617f, 0.000660f, 0.000690f, 0.000739f, 0.000795f, 0.000833f,
+ 0.000885f, 0.000948f, 0.001022f, 0.001085f, 0.001175f, 0.001262f, 0.001371f, 0.001487f, 0.001633f, 0.001778f, 0.001986f, 0.002218f,
+ 0.002502f, 0.002865f, 0.003330f, 0.003979f, 0.004932f, 0.007000f, 0.291260f, 0.372070f, 0.394043f, 0.404541f, 0.412109f, 0.416260f,
+ 0.000000f, 0.000056f, 0.000049f, 0.000061f, 0.000064f, 0.000061f, 0.000062f, 0.000071f, 0.000072f, 0.000088f, 0.000083f, 0.000086f,
+ 0.000097f, 0.000094f, 0.000098f, 0.000105f, 0.000116f, 0.000122f, 0.000126f, 0.000134f, 0.000137f, 0.000143f, 0.000150f, 0.000164f,
+ 0.000171f, 0.000183f, 0.000188f, 0.000204f, 0.000214f, 0.000224f, 0.000236f, 0.000255f, 0.000258f, 0.000277f, 0.000293f, 0.000315f,
+ 0.000328f, 0.000349f, 0.000376f, 0.000396f, 0.000426f, 0.000454f, 0.000486f, 0.000521f, 0.000563f, 0.000605f, 0.000657f, 0.000714f,
+ 0.000791f, 0.000866f, 0.000977f, 0.001085f, 0.001243f, 0.001441f, 0.001703f, 0.002058f, 0.002573f, 0.003740f, 0.280029f, 0.362793f,
+ 0.385742f, 0.397217f, 0.404297f, 0.408936f, 0.000058f, 0.000038f, 0.000031f, 0.000027f, 0.000025f, 0.000026f, 0.000025f, 0.000024f,
+ 0.000024f, 0.000027f, 0.000030f, 0.000038f, 0.000032f, 0.000035f, 0.000040f, 0.000041f, 0.000044f, 0.000045f, 0.000045f, 0.000047f,
+ 0.000052f, 0.000058f, 0.000061f, 0.000059f, 0.000065f, 0.000067f, 0.000069f, 0.000073f, 0.000078f, 0.000083f, 0.000089f, 0.000091f,
+ 0.000099f, 0.000103f, 0.000106f, 0.000114f, 0.000124f, 0.000132f, 0.000141f, 0.000150f, 0.000158f, 0.000164f, 0.000180f, 0.000193f,
+ 0.000205f, 0.000225f, 0.000245f, 0.000267f, 0.000297f, 0.000329f, 0.000365f, 0.000416f, 0.000479f, 0.000563f, 0.000676f, 0.000839f,
+ 0.001088f, 0.001589f, 0.270264f, 0.353760f, 0.377197f, 0.390137f, 0.396973f, 0.402100f, 0.000030f, 0.000019f, 0.000016f, 0.000014f,
+ 0.000013f, 0.000012f, 0.000011f, 0.000011f, 0.000010f, 0.000010f, 0.000009f, 0.000009f, 0.000009f, 0.000008f, 0.000007f, 0.000009f,
+ 0.000009f, 0.000008f, 0.000009f, 0.000010f, 0.000011f, 0.000012f, 0.000012f, 0.000014f, 0.000014f, 0.000014f, 0.000015f, 0.000018f,
+ 0.000017f, 0.000017f, 0.000019f, 0.000020f, 0.000022f, 0.000022f, 0.000023f, 0.000026f, 0.000028f, 0.000027f, 0.000030f, 0.000032f,
+ 0.000035f, 0.000038f, 0.000040f, 0.000042f, 0.000045f, 0.000049f, 0.000055f, 0.000060f, 0.000065f, 0.000074f, 0.000078f, 0.000095f,
+ 0.000109f, 0.000129f, 0.000160f, 0.000205f, 0.000284f, 0.000452f, 0.259766f, 0.345703f, 0.369629f, 0.382812f, 0.390625f, 0.395264f,
+ 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000001f, 0.000001f, 0.000001f, 0.000001f,
+ 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f,
+ 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f,
+ 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000001f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000002f, 0.000002f,
+ 0.000002f, 0.000003f, 0.000003f, 0.000004f, 0.000004f, 0.000005f, 0.000006f, 0.000009f, 0.000012f, 0.000026f, 0.249878f, 0.336182f,
+ 0.362061f, 0.374512f, 0.382080f, 0.387695f,
+ }
+};
+
/* 4 different blue noise, one per channel */
static float blue_noise[64 * 64][4] = {
{0.367188f, 0.855469f, 0.523438f, 0.375000f}, {0.242188f, 0.699219f, 0.164062f, 0.292969f},
diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c
index 6126aab1014..91bdda39876 100644
--- a/source/blender/draw/engines/eevee/eevee_materials.c
+++ b/source/blender/draw/engines/eevee/eevee_materials.c
@@ -26,11 +26,16 @@
#include "DRW_render.h"
#include "DNA_world_types.h"
+#include "DNA_modifier_types.h"
+#include "DNA_view3d_types.h"
#include "BLI_dynstr.h"
#include "BLI_ghash.h"
+#include "BLI_alloca.h"
#include "BKE_particle.h"
+#include "BKE_paint.h"
+#include "BKE_pbvh.h"
#include "GPU_material.h"
@@ -52,8 +57,8 @@
"#define MAX_GRID " STRINGIFY(MAX_GRID) "\n" \
"#define MAX_PLANAR " STRINGIFY(MAX_PLANAR) "\n" \
"#define MAX_LIGHT " STRINGIFY(MAX_LIGHT) "\n" \
+ "#define MAX_SHADOW " STRINGIFY(MAX_SHADOW) "\n" \
"#define MAX_SHADOW_CUBE " STRINGIFY(MAX_SHADOW_CUBE) "\n" \
- "#define MAX_SHADOW_MAP " STRINGIFY(MAX_SHADOW_MAP) "\n" \
"#define MAX_SHADOW_CASCADE " STRINGIFY(MAX_SHADOW_CASCADE) "\n" \
"#define MAX_CASCADE_NUM " STRINGIFY(MAX_CASCADE_NUM) "\n" \
SHADER_IRRADIANCE
@@ -61,6 +66,7 @@
/* *********** STATIC *********** */
static struct {
char *frag_shader_lib;
+ char *volume_shader_lib;
struct GPUShader *default_prepass_sh;
struct GPUShader *default_prepass_clip_sh;
@@ -75,6 +81,8 @@ static struct {
float viewvecs[2][4];
} e_data = {NULL}; /* Engine data */
+extern char datatoc_lamps_lib_glsl[];
+extern char datatoc_lightprobe_lib_glsl[];
extern char datatoc_ambient_occlusion_lib_glsl[];
extern char datatoc_prepass_frag_glsl[];
extern char datatoc_prepass_vert_glsl[];
@@ -82,6 +90,7 @@ extern char datatoc_default_frag_glsl[];
extern char datatoc_default_world_frag_glsl[];
extern char datatoc_ltc_lib_glsl[];
extern char datatoc_bsdf_lut_frag_glsl[];
+extern char datatoc_btdf_lut_frag_glsl[];
extern char datatoc_bsdf_common_lib_glsl[];
extern char datatoc_bsdf_direct_lib_glsl[];
extern char datatoc_bsdf_sampling_lib_glsl[];
@@ -89,12 +98,14 @@ extern char datatoc_irradiance_lib_glsl[];
extern char datatoc_octahedron_lib_glsl[];
extern char datatoc_lit_surface_frag_glsl[];
extern char datatoc_lit_surface_vert_glsl[];
-extern char datatoc_shadow_frag_glsl[];
-extern char datatoc_shadow_geom_glsl[];
+extern char datatoc_raytrace_lib_glsl[];
+extern char datatoc_ssr_lib_glsl[];
extern char datatoc_shadow_vert_glsl[];
+extern char datatoc_shadow_geom_glsl[];
extern char datatoc_lightprobe_geom_glsl[];
extern char datatoc_lightprobe_vert_glsl[];
extern char datatoc_background_vert_glsl[];
+extern char datatoc_volumetric_frag_glsl[];
extern Material defmaterial;
extern GlobalsUboStorage ts;
@@ -161,14 +172,120 @@ static struct GPUTexture *create_ggx_lut_texture(int UNUSED(w), int UNUSED(h))
return tex;
}
+
+static struct GPUTexture *create_ggx_refraction_lut_texture(int w, int h)
+{
+ struct GPUTexture *tex;
+ struct GPUTexture *hammersley = create_hammersley_sample_texture(8192);
+ struct GPUFrameBuffer *fb = NULL;
+ static float samples_ct = 8192.0f;
+ static float a2 = 0.0f;
+ static float inv_samples_ct = 1.0f / 8192.0f;
+
+ char *frag_str = NULL;
+
+ DynStr *ds_vert = BLI_dynstr_new();
+ BLI_dynstr_append(ds_vert, datatoc_bsdf_common_lib_glsl);
+ BLI_dynstr_append(ds_vert, datatoc_bsdf_sampling_lib_glsl);
+ BLI_dynstr_append(ds_vert, datatoc_btdf_lut_frag_glsl);
+ frag_str = BLI_dynstr_get_cstring(ds_vert);
+ BLI_dynstr_free(ds_vert);
+
+ struct GPUShader *sh = DRW_shader_create_fullscreen(frag_str,
+ "#define HAMMERSLEY_SIZE 8192\n"
+ "#define BRDF_LUT_SIZE 64\n"
+ "#define NOISE_SIZE 64\n"
+ "#define LUT_SIZE 64\n");
+
+ MEM_freeN(frag_str);
+
+ DRWPass *pass = DRW_pass_create("LightProbe Filtering", DRW_STATE_WRITE_COLOR);
+ DRWShadingGroup *grp = DRW_shgroup_create(sh, pass);
+ DRW_shgroup_uniform_float(grp, "a2", &a2, 1);
+ DRW_shgroup_uniform_float(grp, "sampleCount", &samples_ct, 1);
+ DRW_shgroup_uniform_float(grp, "invSampleCount", &inv_samples_ct, 1);
+ DRW_shgroup_uniform_texture(grp, "texHammersley", hammersley);
+ DRW_shgroup_uniform_texture(grp, "utilTex", e_data.util_tex);
+
+ struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get();
+ DRW_shgroup_call_add(grp, geom, NULL);
+
+ float *texels = MEM_mallocN(sizeof(float[2]) * w * h, "lut");
+
+ tex = DRW_texture_create_2D(w, h, DRW_TEX_R_16, DRW_TEX_FILTER, (float *)texels);
+
+ DRWFboTexture tex_filter = {&tex, DRW_TEX_R_16, DRW_TEX_FILTER};
+ DRW_framebuffer_init(&fb, &draw_engine_eevee_type, w, h, &tex_filter, 1);
+
+ DRW_framebuffer_bind(fb);
+
+ float *data = MEM_mallocN(sizeof(float[3]) * w * h, "lut");
+
+ float inc = 1.0f / 31.0f;
+ float roughness = 1e-8f - inc;
+ FILE *f = BLI_fopen("btdf_split_sum_ggx.h", "w");
+ fprintf(f, "static float btdf_split_sum_ggx[32][64 * 64] = {\n");
+ do {
+ roughness += inc;
+ CLAMP(roughness, 1e-4f, 1.0f);
+ a2 = powf(roughness, 4.0f);
+ DRW_draw_pass(pass);
+
+ DRW_framebuffer_read_data(0, 0, w, h, 3, 0, data);
+
+#if 1
+ fprintf(f, "\t{\n\t\t");
+ for (int i = 0; i < w*h * 3; i+=3) {
+ fprintf(f, "%ff,", data[i]);
+ if (((i/3)+1) % 12 == 0) fprintf(f, "\n\t\t");
+ else fprintf(f, " ");
+ }
+ fprintf(f, "\n\t},\n");
+#else
+ for (int i = 0; i < w*h * 3; i+=3) {
+ if (data[i] < 0.01) printf(" ");
+ else if (data[i] < 0.3) printf(".");
+ else if (data[i] < 0.6) printf("+");
+ else if (data[i] < 0.9) printf("%%");
+ else printf("#");
+ if ((i/3+1) % 64 == 0) printf("\n");
+ }
#endif
+ } while (roughness < 1.0f);
+ fprintf(f, "\n};\n");
+
+ fclose(f);
+
+ MEM_freeN(texels);
+ MEM_freeN(data);
+
+ return tex;
+}
+#endif
+/* XXX TODO define all shared resources in a shared place without duplication */
+struct GPUTexture *EEVEE_materials_get_util_tex(void)
+{
+ return e_data.util_tex;
+}
+
+static int eevee_material_shadow_option(int shadow_method)
+{
+ switch (shadow_method) {
+ case SHADOW_ESM: return VAR_MAT_ESM;
+ case SHADOW_VSM: return VAR_MAT_VSM;
+ default:
+ BLI_assert(!"Incorrect Shadow Method");
+ break;
+ }
+
+ return 0;
+}
+
static char *eevee_get_defines(int options)
{
char *str = NULL;
- BLI_assert(options < VAR_MAT_MAX);
-
DynStr *ds = BLI_dynstr_new();
BLI_dynstr_appendf(ds, SHADER_DEFINES);
@@ -181,14 +298,32 @@ static char *eevee_get_defines(int options)
if ((options & VAR_MAT_PROBE) != 0) {
BLI_dynstr_appendf(ds, "#define PROBE_CAPTURE\n");
}
- if ((options & VAR_MAT_AO) != 0) {
- BLI_dynstr_appendf(ds, "#define USE_AO\n");
- }
if ((options & VAR_MAT_FLAT) != 0) {
BLI_dynstr_appendf(ds, "#define USE_FLAT_NORMAL\n");
}
- if ((options & VAR_MAT_BENT) != 0) {
- BLI_dynstr_appendf(ds, "#define USE_BENT_NORMAL\n");
+ if ((options & VAR_MAT_CLIP) != 0) {
+ BLI_dynstr_appendf(ds, "#define USE_ALPHA_CLIP\n");
+ }
+ if ((options & VAR_MAT_SHADOW) != 0) {
+ BLI_dynstr_appendf(ds, "#define SHADOW_SHADER\n");
+ }
+ if ((options & VAR_MAT_HASH) != 0) {
+ BLI_dynstr_appendf(ds, "#define USE_ALPHA_HASH\n");
+ }
+ if ((options & VAR_MAT_BLEND) != 0) {
+ BLI_dynstr_appendf(ds, "#define USE_ALPHA_BLEND\n");
+ }
+ if ((options & VAR_MAT_MULT) != 0) {
+ BLI_dynstr_appendf(ds, "#define USE_MULTIPLY\n");
+ }
+ if ((options & VAR_MAT_REFRACT) != 0) {
+ BLI_dynstr_appendf(ds, "#define USE_REFRACTION\n");
+ }
+ if ((options & VAR_MAT_VSM) != 0) {
+ BLI_dynstr_appendf(ds, "#define SHADOW_VSM\n");
+ }
+ if ((options & VAR_MAT_ESM) != 0) {
+ BLI_dynstr_appendf(ds, "#define SHADOW_ESM\n");
}
str = BLI_dynstr_get_cstring(ds);
@@ -197,8 +332,44 @@ static char *eevee_get_defines(int options)
return str;
}
-static void add_standard_uniforms(DRWShadingGroup *shgrp, EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata)
+static char *eevee_get_volume_defines(int options)
{
+ char *str = NULL;
+
+ DynStr *ds = BLI_dynstr_new();
+ BLI_dynstr_appendf(ds, SHADER_DEFINES);
+ BLI_dynstr_appendf(ds, "#define VOLUMETRICS\n");
+
+ if ((options & VAR_VOLUME_SHADOW) != 0) {
+ BLI_dynstr_appendf(ds, "#define VOLUME_SHADOW\n");
+ }
+ if ((options & VAR_VOLUME_HOMO) != 0) {
+ BLI_dynstr_appendf(ds, "#define VOLUME_HOMOGENEOUS\n");
+ }
+ if ((options & VAR_VOLUME_LIGHT) != 0) {
+ BLI_dynstr_appendf(ds, "#define VOLUME_LIGHTING\n");
+ }
+ if ((options & VAR_VOLUME_COLOR) != 0) {
+ BLI_dynstr_appendf(ds, "#define COLOR_TRANSMITTANCE\n");
+ }
+
+ str = BLI_dynstr_get_cstring(ds);
+ BLI_dynstr_free(ds);
+
+ return str;
+}
+
+/**
+ * ssr_id can be null to disable ssr contribution.
+ **/
+static void add_standard_uniforms(
+ DRWShadingGroup *shgrp, EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata,
+ int *ssr_id, float *refract_depth, bool use_ssrefraction)
+{
+ if (ssr_id == NULL || !vedata->stl->g_data->valid_double_buffer) {
+ static int no_ssr = -1.0f;
+ ssr_id = &no_ssr;
+ }
DRW_shgroup_uniform_block(shgrp, "probe_block", sldata->probe_ubo);
DRW_shgroup_uniform_block(shgrp, "grid_block", sldata->grid_ubo);
DRW_shgroup_uniform_block(shgrp, "planar_block", sldata->planar_ubo);
@@ -209,17 +380,36 @@ static void add_standard_uniforms(DRWShadingGroup *shgrp, EEVEE_SceneLayerData *
DRW_shgroup_uniform_int(shgrp, "grid_count", &sldata->probes->num_render_grid, 1);
DRW_shgroup_uniform_int(shgrp, "planar_count", &sldata->probes->num_planar, 1);
DRW_shgroup_uniform_bool(shgrp, "specToggle", &sldata->probes->specular_toggle, 1);
- DRW_shgroup_uniform_float(shgrp, "lodMax", &sldata->probes->lodmax, 1);
+ DRW_shgroup_uniform_bool(shgrp, "ssrToggle", &sldata->probes->ssr_toggle, 1);
+ DRW_shgroup_uniform_float(shgrp, "lodCubeMax", &sldata->probes->lod_cube_max, 1);
+ DRW_shgroup_uniform_float(shgrp, "lodPlanarMax", &sldata->probes->lod_planar_max, 1);
DRW_shgroup_uniform_texture(shgrp, "utilTex", e_data.util_tex);
DRW_shgroup_uniform_buffer(shgrp, "probeCubes", &sldata->probe_pool);
DRW_shgroup_uniform_buffer(shgrp, "probePlanars", &vedata->txl->planar_pool);
DRW_shgroup_uniform_buffer(shgrp, "irradianceGrid", &sldata->irradiance_pool);
- DRW_shgroup_uniform_buffer(shgrp, "shadowCubes", &sldata->shadow_depth_cube_pool);
- DRW_shgroup_uniform_buffer(shgrp, "shadowCascades", &sldata->shadow_depth_cascade_pool);
+ DRW_shgroup_uniform_buffer(shgrp, "shadowTexture", &sldata->shadow_pool);
+ DRW_shgroup_uniform_int(shgrp, "outputSsrId", ssr_id, 1);
+ DRW_shgroup_uniform_vec4(shgrp, "aoParameters[0]", &vedata->stl->effects->ao_dist, 2);
+ DRW_shgroup_uniform_vec4(shgrp, "viewvecs[0]", (float *)vedata->stl->g_data->viewvecs, 2);
+ DRW_shgroup_uniform_buffer(shgrp, "maxzBuffer", &vedata->txl->maxzbuffer);
+ DRW_shgroup_uniform_vec2(shgrp, "mipRatio[0]", (float *)vedata->stl->g_data->mip_ratio, 10);
+ DRW_shgroup_uniform_vec4(shgrp, "ssrParameters", &vedata->stl->effects->ssr_quality, 1);
+ if (refract_depth != NULL) {
+ DRW_shgroup_uniform_float(shgrp, "refractionDepth", refract_depth, 1);
+ }
+ if (use_ssrefraction) {
+ DRW_shgroup_uniform_buffer(shgrp, "colorBuffer", &vedata->txl->refract_color);
+ DRW_shgroup_uniform_float(shgrp, "borderFadeFactor", &vedata->stl->effects->ssr_border_fac, 1);
+ DRW_shgroup_uniform_float(shgrp, "maxRoughness", &vedata->stl->effects->ssr_max_roughness, 1);
+ DRW_shgroup_uniform_int(shgrp, "rayCount", &vedata->stl->effects->ssr_ray_count, 1);
+ }
if (vedata->stl->effects->use_ao) {
- DRW_shgroup_uniform_vec4(shgrp, "viewvecs[0]", (float *)e_data.viewvecs, 2);
- DRW_shgroup_uniform_buffer(shgrp, "minMaxDepthTex", &vedata->stl->g_data->minmaxz);
- DRW_shgroup_uniform_vec3(shgrp, "aoParameters", &vedata->stl->effects->ao_dist, 1);
+ DRW_shgroup_uniform_buffer(shgrp, "horizonBuffer", &vedata->txl->gtao_horizons);
+ DRW_shgroup_uniform_ivec2(shgrp, "aoHorizonTexSize", (int *)vedata->stl->effects->ao_texsize, 1);
+ }
+ else {
+ /* Use shadow_pool as fallback to avoid sampling problem on certain platform, see: T52593 */
+ DRW_shgroup_uniform_buffer(shgrp, "horizonBuffer", &sldata->shadow_pool);
}
}
@@ -239,7 +429,63 @@ static void create_default_shader(int options)
MEM_freeN(frag_str);
}
-void EEVEE_materials_init(void)
+void EEVEE_update_util_texture(float offset)
+{
+
+ /* TODO: split this into 2 functions : one for init,
+ * and the other one that updates the noise with the offset. */
+ const int layers = 3 + 16;
+ float (*texels)[4] = MEM_mallocN(sizeof(float[4]) * 64 * 64 * layers, "utils texels");
+ float (*texels_layer)[4] = texels;
+
+ /* Copy ltc_mat_ggx into 1st layer */
+ memcpy(texels_layer, ltc_mat_ggx, sizeof(float[4]) * 64 * 64);
+ texels_layer += 64 * 64;
+
+ /* Copy bsdf_split_sum_ggx into 2nd layer red and green channels.
+ Copy ltc_mag_ggx into 2nd layer blue channel. */
+ for (int i = 0; i < 64 * 64; i++) {
+ texels_layer[i][0] = bsdf_split_sum_ggx[i * 2 + 0];
+ texels_layer[i][1] = bsdf_split_sum_ggx[i * 2 + 1];
+ texels_layer[i][2] = ltc_mag_ggx[i];
+ }
+ texels_layer += 64 * 64;
+
+ /* Copy blue noise in 3rd layer */
+ for (int i = 0; i < 64 * 64; i++) {
+ float noise;
+ noise = fmod(blue_noise[i][0] + offset, 1.0f);
+ texels_layer[i][0] = noise;
+
+ noise = fmod(blue_noise[i][1] + offset, 1.0f);
+ texels_layer[i][1] = noise * 0.5f + 0.5f;
+ texels_layer[i][2] = cosf(noise * 2.0f * M_PI);
+ texels_layer[i][3] = sinf(noise * 2.0f * M_PI);
+ }
+ texels_layer += 64 * 64;
+
+ /* Copy Refraction GGX LUT in layer 4 - 20 */
+ for (int j = 0; j < 16; ++j) {
+ for (int i = 0; i < 64 * 64; i++) {
+ texels_layer[i][0] = btdf_split_sum_ggx[j * 2][i];
+ texels_layer[i][1] = btdf_split_sum_ggx[j * 2][i];
+ texels_layer[i][2] = btdf_split_sum_ggx[j * 2][i];
+ texels_layer[i][3] = btdf_split_sum_ggx[j * 2][i];
+ }
+ texels_layer += 64 * 64;
+ }
+
+ if (e_data.util_tex == NULL) {
+ e_data.util_tex = DRW_texture_create_2D_array(64, 64, layers, DRW_TEX_RGBA_16, DRW_TEX_FILTER | DRW_TEX_WRAP, (float *)texels);
+ }
+ else {
+ DRW_texture_update(e_data.util_tex, (float *)texels);
+ }
+
+ MEM_freeN(texels);
+}
+
+void EEVEE_materials_init(EEVEE_StorageList *stl)
{
if (!e_data.frag_shader_lib) {
char *frag_str = NULL;
@@ -247,23 +493,42 @@ void EEVEE_materials_init(void)
/* Shaders */
DynStr *ds_frag = BLI_dynstr_new();
BLI_dynstr_append(ds_frag, datatoc_bsdf_common_lib_glsl);
+ BLI_dynstr_append(ds_frag, datatoc_bsdf_sampling_lib_glsl);
BLI_dynstr_append(ds_frag, datatoc_ambient_occlusion_lib_glsl);
+ BLI_dynstr_append(ds_frag, datatoc_raytrace_lib_glsl);
+ BLI_dynstr_append(ds_frag, datatoc_ssr_lib_glsl);
BLI_dynstr_append(ds_frag, datatoc_octahedron_lib_glsl);
BLI_dynstr_append(ds_frag, datatoc_irradiance_lib_glsl);
+ BLI_dynstr_append(ds_frag, datatoc_lightprobe_lib_glsl);
BLI_dynstr_append(ds_frag, datatoc_ltc_lib_glsl);
BLI_dynstr_append(ds_frag, datatoc_bsdf_direct_lib_glsl);
+ BLI_dynstr_append(ds_frag, datatoc_lamps_lib_glsl);
BLI_dynstr_append(ds_frag, datatoc_lit_surface_frag_glsl);
e_data.frag_shader_lib = BLI_dynstr_get_cstring(ds_frag);
BLI_dynstr_free(ds_frag);
ds_frag = BLI_dynstr_new();
+ BLI_dynstr_append(ds_frag, datatoc_bsdf_common_lib_glsl);
+ BLI_dynstr_append(ds_frag, datatoc_ambient_occlusion_lib_glsl);
+ BLI_dynstr_append(ds_frag, datatoc_octahedron_lib_glsl);
+ BLI_dynstr_append(ds_frag, datatoc_irradiance_lib_glsl);
+ BLI_dynstr_append(ds_frag, datatoc_lightprobe_lib_glsl);
+ BLI_dynstr_append(ds_frag, datatoc_ltc_lib_glsl);
+ BLI_dynstr_append(ds_frag, datatoc_bsdf_direct_lib_glsl);
+ BLI_dynstr_append(ds_frag, datatoc_lamps_lib_glsl);
+ BLI_dynstr_append(ds_frag, datatoc_volumetric_frag_glsl);
+ e_data.volume_shader_lib = BLI_dynstr_get_cstring(ds_frag);
+ BLI_dynstr_free(ds_frag);
+
+ ds_frag = BLI_dynstr_new();
BLI_dynstr_append(ds_frag, e_data.frag_shader_lib);
BLI_dynstr_append(ds_frag, datatoc_default_frag_glsl);
frag_str = BLI_dynstr_get_cstring(ds_frag);
BLI_dynstr_free(ds_frag);
- e_data.default_background = DRW_shader_create_fullscreen(
- datatoc_default_world_frag_glsl, NULL);
+ e_data.default_background = DRW_shader_create(
+ datatoc_background_vert_glsl, NULL, datatoc_default_world_frag_glsl,
+ NULL);
e_data.default_prepass_sh = DRW_shader_create(
datatoc_prepass_vert_glsl, NULL, datatoc_prepass_frag_glsl,
@@ -275,33 +540,7 @@ void EEVEE_materials_init(void)
MEM_freeN(frag_str);
- /* Textures */
- const int layers = 3;
- float (*texels)[4] = MEM_mallocN(sizeof(float[4]) * 64 * 64 * layers, "utils texels");
- float (*texels_layer)[4] = texels;
-
- /* Copy ltc_mat_ggx into 1st layer */
- memcpy(texels_layer, ltc_mat_ggx, sizeof(float[4]) * 64 * 64);
- texels_layer += 64 * 64;
-
- /* Copy bsdf_split_sum_ggx into 2nd layer red and green channels.
- Copy ltc_mag_ggx into 2nd layer blue channel. */
- for (int i = 0; i < 64 * 64; i++) {
- texels_layer[i][0] = bsdf_split_sum_ggx[i*2 + 0];
- texels_layer[i][1] = bsdf_split_sum_ggx[i*2 + 1];
- texels_layer[i][2] = ltc_mag_ggx[i];
- }
- texels_layer += 64 * 64;
-
- for (int i = 0; i < 64 * 64; i++) {
- texels_layer[i][0] = blue_noise[i][0];
- texels_layer[i][1] = blue_noise[i][1] * 0.5 + 0.5;
- texels_layer[i][2] = blue_noise[i][2];
- texels_layer[i][3] = blue_noise[i][3];
- }
-
- e_data.util_tex = DRW_texture_create_2D_array(64, 64, layers, DRW_TEX_RGBA_16, DRW_TEX_FILTER | DRW_TEX_WRAP, (float *)texels);
- MEM_freeN(texels);
+ EEVEE_update_util_texture(0.0f);
}
{
@@ -331,100 +570,225 @@ void EEVEE_materials_init(void)
viewvecs[i][3] = 1.0;
}
- copy_v4_v4(e_data.viewvecs[0], viewvecs[0]);
- copy_v4_v4(e_data.viewvecs[1], viewvecs[1]);
+ copy_v4_v4(stl->g_data->viewvecs[0], viewvecs[0]);
+ copy_v4_v4(stl->g_data->viewvecs[1], viewvecs[1]);
/* we need to store the differences */
- e_data.viewvecs[1][0] -= viewvecs[0][0];
- e_data.viewvecs[1][1] = viewvecs[2][1] - viewvecs[0][1];
+ stl->g_data->viewvecs[1][0] -= viewvecs[0][0];
+ stl->g_data->viewvecs[1][1] = viewvecs[2][1] - viewvecs[0][1];
/* calculate a depth offset as well */
if (!is_persp) {
float vec_far[] = {-1.0f, -1.0f, 1.0f, 1.0f};
mul_m4_v4(invproj, vec_far);
mul_v3_fl(vec_far, 1.0f / vec_far[3]);
- e_data.viewvecs[1][2] = vec_far[2] - viewvecs[0][2];
+ stl->g_data->viewvecs[1][2] = vec_far[2] - viewvecs[0][2];
}
}
}
struct GPUMaterial *EEVEE_material_world_lightprobe_get(struct Scene *scene, World *wo)
{
+ const void *engine = &DRW_engine_viewport_eevee_type;
+ const int options = VAR_WORLD_PROBE;
+
+ GPUMaterial *mat = GPU_material_from_nodetree_find(&wo->gpumaterial, engine, options);
+ if (mat != NULL) {
+ return mat;
+ }
return GPU_material_from_nodetree(
- scene, wo->nodetree, &wo->gpumaterial, &DRW_engine_viewport_eevee_type,
- VAR_WORLD_PROBE,
- datatoc_lightprobe_vert_glsl, datatoc_lightprobe_geom_glsl, e_data.frag_shader_lib,
- SHADER_DEFINES "#define PROBE_CAPTURE\n");
+ scene, wo->nodetree, &wo->gpumaterial, engine, options,
+ datatoc_background_vert_glsl, NULL, e_data.frag_shader_lib,
+ SHADER_DEFINES "#define PROBE_CAPTURE\n");
}
struct GPUMaterial *EEVEE_material_world_background_get(struct Scene *scene, World *wo)
{
+ const void *engine = &DRW_engine_viewport_eevee_type;
+ int options = VAR_WORLD_BACKGROUND;
+
+ GPUMaterial *mat = GPU_material_from_nodetree_find(&wo->gpumaterial, engine, options);
+ if (mat != NULL) {
+ return mat;
+ }
return GPU_material_from_nodetree(
- scene, wo->nodetree, &wo->gpumaterial, &DRW_engine_viewport_eevee_type,
- VAR_WORLD_BACKGROUND,
- datatoc_background_vert_glsl, NULL, e_data.frag_shader_lib,
- SHADER_DEFINES "#define WORLD_BACKGROUND\n");
+ scene, wo->nodetree, &wo->gpumaterial, engine, options,
+ datatoc_background_vert_glsl, NULL, e_data.frag_shader_lib,
+ SHADER_DEFINES "#define WORLD_BACKGROUND\n");
+}
+
+struct GPUMaterial *EEVEE_material_world_volume_get(
+ struct Scene *scene, World *wo,
+ bool use_lights, bool use_volume_shadows, bool is_homogeneous, bool use_color_transmit, int shadow_method)
+{
+ const void *engine = &DRW_engine_viewport_eevee_type;
+ int options = VAR_WORLD_VOLUME;
+
+ if (use_lights) options |= VAR_VOLUME_LIGHT;
+ if (is_homogeneous) options |= VAR_VOLUME_HOMO;
+ if (use_volume_shadows) options |= VAR_VOLUME_SHADOW;
+ if (use_color_transmit) options |= VAR_VOLUME_COLOR;
+
+ options |= eevee_material_shadow_option(shadow_method);
+
+ GPUMaterial *mat = GPU_material_from_nodetree_find(&wo->gpumaterial, engine, options);
+ if (mat != NULL) {
+ return mat;
+ }
+
+ char *defines = eevee_get_volume_defines(options);
+
+ mat = GPU_material_from_nodetree(
+ scene, wo->nodetree, &wo->gpumaterial, engine, options,
+ datatoc_background_vert_glsl, NULL, e_data.volume_shader_lib,
+ defines);
+
+ MEM_freeN(defines);
+
+ return mat;
}
struct GPUMaterial *EEVEE_material_mesh_get(
struct Scene *scene, Material *ma,
- bool use_ao, bool use_bent_normals)
+ bool use_blend, bool use_multiply, bool use_refract, int shadow_method)
{
- struct GPUMaterial *mat;
-
+ const void *engine = &DRW_engine_viewport_eevee_type;
int options = VAR_MAT_MESH;
- if (use_ao) options |= VAR_MAT_AO;
- if (use_bent_normals) options |= VAR_MAT_BENT;
+ if (use_blend) options |= VAR_MAT_BLEND;
+ if (use_multiply) options |= VAR_MAT_MULT;
+ if (use_refract) options |= VAR_MAT_REFRACT;
+
+ options |= eevee_material_shadow_option(shadow_method);
+
+ GPUMaterial *mat = GPU_material_from_nodetree_find(&ma->gpumaterial, engine, options);
+ if (mat) {
+ return mat;
+ }
char *defines = eevee_get_defines(options);
mat = GPU_material_from_nodetree(
- scene, ma->nodetree, &ma->gpumaterial, &DRW_engine_viewport_eevee_type,
- options,
- datatoc_lit_surface_vert_glsl, NULL, e_data.frag_shader_lib,
- defines);
+ scene, ma->nodetree, &ma->gpumaterial, engine, options,
+ datatoc_lit_surface_vert_glsl, NULL, e_data.frag_shader_lib,
+ defines);
MEM_freeN(defines);
return mat;
}
-struct GPUMaterial *EEVEE_material_hair_get(
+struct GPUMaterial *EEVEE_material_mesh_depth_get(
struct Scene *scene, Material *ma,
- bool use_ao, bool use_bent_normals)
+ bool use_hashed_alpha, bool is_shadow)
{
- struct GPUMaterial *mat;
+ const void *engine = &DRW_engine_viewport_eevee_type;
+ int options = VAR_MAT_MESH;
+
+ if (use_hashed_alpha) {
+ options |= VAR_MAT_HASH;
+ }
+ else {
+ options |= VAR_MAT_CLIP;
+ }
+
+ if (is_shadow)
+ options |= VAR_MAT_SHADOW;
+
+ GPUMaterial *mat = GPU_material_from_nodetree_find(&ma->gpumaterial, engine, options);
+ if (mat) {
+ return mat;
+ }
+
+ char *defines = eevee_get_defines(options);
+
+ DynStr *ds_frag = BLI_dynstr_new();
+ BLI_dynstr_append(ds_frag, e_data.frag_shader_lib);
+ BLI_dynstr_append(ds_frag, datatoc_prepass_frag_glsl);
+ char *frag_str = BLI_dynstr_get_cstring(ds_frag);
+ BLI_dynstr_free(ds_frag);
+
+ mat = GPU_material_from_nodetree(
+ scene, ma->nodetree, &ma->gpumaterial, engine, options,
+ (is_shadow) ? datatoc_shadow_vert_glsl : datatoc_lit_surface_vert_glsl,
+ (is_shadow) ? datatoc_shadow_geom_glsl : NULL,
+ frag_str,
+ defines);
+
+ MEM_freeN(frag_str);
+ MEM_freeN(defines);
+
+ return mat;
+}
+struct GPUMaterial *EEVEE_material_hair_get(
+ struct Scene *scene, Material *ma, int shadow_method)
+{
+ const void *engine = &DRW_engine_viewport_eevee_type;
int options = VAR_MAT_MESH | VAR_MAT_HAIR;
- if (use_ao) options |= VAR_MAT_AO;
- if (use_bent_normals) options |= VAR_MAT_BENT;
+ options |= eevee_material_shadow_option(shadow_method);
+
+ GPUMaterial *mat = GPU_material_from_nodetree_find(&ma->gpumaterial, engine, options);
+ if (mat) {
+ return mat;
+ }
char *defines = eevee_get_defines(options);
mat = GPU_material_from_nodetree(
- scene, ma->nodetree, &ma->gpumaterial, &DRW_engine_viewport_eevee_type,
- options,
- datatoc_lit_surface_vert_glsl, NULL, e_data.frag_shader_lib,
- defines);
+ scene, ma->nodetree, &ma->gpumaterial, engine, options,
+ datatoc_lit_surface_vert_glsl, NULL, e_data.frag_shader_lib,
+ defines);
MEM_freeN(defines);
return mat;
}
+/**
+ * Create a default shading group inside the given pass.
+ **/
+static struct DRWShadingGroup *EEVEE_default_shading_group_create(
+ EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata, DRWPass *pass,
+ bool is_hair, bool is_flat_normal, bool use_blend, bool use_ssr, int shadow_method)
+{
+ static int ssr_id;
+ ssr_id = (use_ssr) ? 0 : -1;
+ int options = VAR_MAT_MESH;
+
+ if (is_hair) options |= VAR_MAT_HAIR;
+ if (is_flat_normal) options |= VAR_MAT_FLAT;
+ if (use_blend) options |= VAR_MAT_BLEND;
+
+ options |= eevee_material_shadow_option(shadow_method);
+
+ if (e_data.default_lit[options] == NULL) {
+ create_default_shader(options);
+ }
+
+ DRWShadingGroup *shgrp = DRW_shgroup_create(e_data.default_lit[options], pass);
+ add_standard_uniforms(shgrp, sldata, vedata, &ssr_id, NULL, false);
+
+ return shgrp;
+}
+
+/**
+ * Create a default shading group inside the default pass without standard uniforms.
+ **/
static struct DRWShadingGroup *EEVEE_default_shading_group_get(
EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata,
- bool is_hair, bool is_flat_normal, bool use_ao, bool use_bent_normals)
+ bool is_hair, bool is_flat_normal, bool use_ssr, int shadow_method)
{
+ static int ssr_id;
+ ssr_id = (use_ssr) ? 0 : -1;
int options = VAR_MAT_MESH;
if (is_hair) options |= VAR_MAT_HAIR;
- if (use_ao) options |= VAR_MAT_AO;
- if (use_bent_normals) options |= VAR_MAT_BENT;
if (is_flat_normal) options |= VAR_MAT_FLAT;
+ options |= eevee_material_shadow_option(shadow_method);
+
if (e_data.default_lit[options] == NULL) {
create_default_shader(options);
}
@@ -434,7 +798,7 @@ static struct DRWShadingGroup *EEVEE_default_shading_group_get(
vedata->psl->default_pass[options] = DRW_pass_create("Default Lit Pass", state);
DRWShadingGroup *shgrp = DRW_shgroup_create(e_data.default_lit[options], vedata->psl->default_pass[options]);
- add_standard_uniforms(shgrp, sldata, vedata);
+ add_standard_uniforms(shgrp, sldata, vedata, &ssr_id, NULL, false);
}
return DRW_shgroup_create(e_data.default_lit[options], vedata->psl->default_pass[options]);
@@ -446,12 +810,14 @@ void EEVEE_materials_cache_init(EEVEE_Data *vedata)
EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl;
{
- /* Global AO Switch*/
const DRWContextState *draw_ctx = DRW_context_state_get();
- SceneLayer *scene_layer = draw_ctx->sl;
+ SceneLayer *scene_layer = draw_ctx->scene_layer;
IDProperty *props = BKE_scene_layer_engine_evaluated_get(scene_layer, COLLECTION_MODE_NONE, RE_engine_id_BLENDER_EEVEE);
+ /* Global AO Switch*/
stl->effects->use_ao = BKE_collection_engine_property_value_get_bool(props, "gtao_enable");
stl->effects->use_bent_normals = BKE_collection_engine_property_value_get_bool(props, "gtao_use_bent_normals");
+ /* SSR switch */
+ stl->effects->use_ssr = BKE_collection_engine_property_value_get_bool(props, "ssr_enable");
}
/* Create Material Ghash */
@@ -461,7 +827,7 @@ void EEVEE_materials_cache_init(EEVEE_Data *vedata)
}
{
- psl->background_pass = DRW_pass_create("Background Pass", DRW_STATE_WRITE_DEPTH | DRW_STATE_WRITE_COLOR);
+ psl->background_pass = DRW_pass_create("Background Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL);
struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get();
DRWShadingGroup *grp = NULL;
@@ -522,10 +888,38 @@ void EEVEE_materials_cache_init(EEVEE_Data *vedata)
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_CLIP_PLANES | DRW_STATE_WIRE;
psl->material_pass = DRW_pass_create("Material Shader Pass", state);
}
+
+ {
+ DRWState state = DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_WIRE;
+ psl->refract_depth_pass = DRW_pass_create("Refract Depth Pass", state);
+ stl->g_data->refract_depth_shgrp = DRW_shgroup_create(e_data.default_prepass_sh, psl->refract_depth_pass);
+
+ state = DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_CULL_BACK;
+ psl->refract_depth_pass_cull = DRW_pass_create("Refract Depth Pass Cull", state);
+ stl->g_data->refract_depth_shgrp_cull = DRW_shgroup_create(e_data.default_prepass_sh, psl->refract_depth_pass_cull);
+
+ state = DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_CLIP_PLANES | DRW_STATE_WIRE;
+ psl->refract_depth_pass_clip = DRW_pass_create("Refract Depth Pass Clip", state);
+ stl->g_data->refract_depth_shgrp_clip = DRW_shgroup_create(e_data.default_prepass_clip_sh, psl->refract_depth_pass_clip);
+
+ state = DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_CLIP_PLANES | DRW_STATE_CULL_BACK;
+ psl->refract_depth_pass_clip_cull = DRW_pass_create("Refract Depth Pass Cull Clip", state);
+ stl->g_data->refract_depth_shgrp_clip_cull = DRW_shgroup_create(e_data.default_prepass_clip_sh, psl->refract_depth_pass_clip_cull);
+ }
+
+ {
+ DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_CLIP_PLANES | DRW_STATE_WIRE;
+ psl->refract_pass = DRW_pass_create("Opaque Refraction Pass", state);
+ }
+
+ {
+ DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS | DRW_STATE_CLIP_PLANES | DRW_STATE_WIRE;
+ psl->transparent_pass = DRW_pass_create("Material Transparent Pass", state);
+ }
}
#define ADD_SHGROUP_CALL(shgrp, ob, geom) do { \
- if (is_sculpt_mode) { \
+ if (is_sculpt_mode_draw) { \
DRW_shgroup_call_sculpt_add(shgrp, ob, ob->obmat); \
} \
else { \
@@ -533,90 +927,335 @@ void EEVEE_materials_cache_init(EEVEE_Data *vedata)
} \
} while (0)
-void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_SceneLayerData *sldata, Object *ob, struct Gwn_Batch *geom)
+#define ADD_SHGROUP_CALL_SAFE(shgrp, ob, geom) do { \
+ if (shgrp) { \
+ ADD_SHGROUP_CALL(shgrp, ob, geom); \
+ } \
+} while (0)
+
+typedef struct EeveeMaterialShadingGroups {
+ struct DRWShadingGroup *shading_grp;
+ struct DRWShadingGroup *depth_grp;
+ struct DRWShadingGroup *depth_clip_grp;
+} EeveeMaterialShadingGroups;
+
+static void material_opaque(
+ Material *ma, GHash *material_hash, EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata,
+ bool do_cull, bool use_flat_nor, struct GPUMaterial **gpumat, struct GPUMaterial **gpumat_depth,
+ struct DRWShadingGroup **shgrp, struct DRWShadingGroup **shgrp_depth, struct DRWShadingGroup **shgrp_depth_clip)
+{
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ Scene *scene = draw_ctx->scene;
+ EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl;
+ EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl;
+ EEVEE_LampsInfo *linfo = sldata->lamps;
+
+ float *color_p = &ma->r;
+ float *metal_p = &ma->ray_mirror;
+ float *spec_p = &ma->spec;
+ float *rough_p = &ma->gloss_mir;
+
+ const bool use_gpumat = (ma->use_nodes && ma->nodetree);
+ const bool use_refract = ((ma->blend_flag & MA_BL_SS_REFRACTION) != 0) && ((stl->effects->enabled_effects & EFFECT_REFRACT) != 0);
+
+ EeveeMaterialShadingGroups *emsg = BLI_ghash_lookup(material_hash, (const void *)ma);
+
+ if (emsg) {
+ *shgrp = emsg->shading_grp;
+ *shgrp_depth = emsg->depth_grp;
+ *shgrp_depth_clip = emsg->depth_clip_grp;
+
+ /* This will have been created already, just perform a lookup. */
+ *gpumat = (use_gpumat) ? EEVEE_material_mesh_get(
+ scene, ma, false, false, use_refract, linfo->shadow_method) : NULL;
+ *gpumat_depth = (use_gpumat) ? EEVEE_material_mesh_depth_get(
+ scene, ma, (ma->blend_method == MA_BM_HASHED), false) : NULL;
+ return;
+ }
+
+ if (use_gpumat) {
+ /* Shading */
+ *gpumat = EEVEE_material_mesh_get(scene, ma, false, false, use_refract, linfo->shadow_method);
+
+ *shgrp = DRW_shgroup_material_create(*gpumat, use_refract ? psl->refract_pass : psl->material_pass);
+ if (*shgrp) {
+ static int no_ssr = -1;
+ static int first_ssr = 0;
+ int *ssr_id = (stl->effects->use_ssr && !use_refract) ? &first_ssr : &no_ssr;
+ add_standard_uniforms(*shgrp, sldata, vedata, ssr_id, &ma->refract_depth, use_refract);
+ }
+ else {
+ /* Shader failed : pink color */
+ static float col[3] = {1.0f, 0.0f, 1.0f};
+ static float half = 0.5f;
+
+ color_p = col;
+ metal_p = spec_p = rough_p = &half;
+ }
+
+ /* Alpha CLipped : Discard pixel from depth pass, then
+ * fail the depth test for shading. */
+ if (ELEM(ma->blend_method, MA_BM_CLIP, MA_BM_HASHED)) {
+ *gpumat_depth = EEVEE_material_mesh_depth_get(scene, ma,
+ (ma->blend_method == MA_BM_HASHED), false);
+
+ if (use_refract) {
+ *shgrp_depth = DRW_shgroup_material_create(*gpumat_depth, (do_cull) ? psl->refract_depth_pass_cull : psl->refract_depth_pass);
+ *shgrp_depth_clip = DRW_shgroup_material_create(*gpumat_depth, (do_cull) ? psl->refract_depth_pass_clip_cull : psl->refract_depth_pass_clip);
+ }
+ else {
+ *shgrp_depth = DRW_shgroup_material_create(*gpumat_depth, (do_cull) ? psl->depth_pass_cull : psl->depth_pass);
+ *shgrp_depth_clip = DRW_shgroup_material_create(*gpumat_depth, (do_cull) ? psl->depth_pass_clip_cull : psl->depth_pass_clip);
+ }
+
+ if (*shgrp != NULL) {
+ if (ma->blend_method == MA_BM_CLIP) {
+ DRW_shgroup_uniform_float(*shgrp_depth, "alphaThreshold", &ma->alpha_threshold, 1);
+ DRW_shgroup_uniform_float(*shgrp_depth_clip, "alphaThreshold", &ma->alpha_threshold, 1);
+ }
+ }
+ }
+ }
+
+ /* Fallback to default shader */
+ if (*shgrp == NULL) {
+ *shgrp = EEVEE_default_shading_group_get(sldata, vedata, false, use_flat_nor, stl->effects->use_ssr, linfo->shadow_method);
+ DRW_shgroup_uniform_vec3(*shgrp, "basecol", color_p, 1);
+ DRW_shgroup_uniform_float(*shgrp, "metallic", metal_p, 1);
+ DRW_shgroup_uniform_float(*shgrp, "specular", spec_p, 1);
+ DRW_shgroup_uniform_float(*shgrp, "roughness", rough_p, 1);
+ }
+
+ /* Fallback default depth prepass */
+ if (*shgrp_depth == NULL) {
+ if (use_refract) {
+ *shgrp_depth = (do_cull) ? stl->g_data->refract_depth_shgrp_cull : stl->g_data->refract_depth_shgrp;
+ *shgrp_depth_clip = (do_cull) ? stl->g_data->refract_depth_shgrp_clip_cull : stl->g_data->refract_depth_shgrp_clip;
+ }
+ else {
+ *shgrp_depth = (do_cull) ? stl->g_data->depth_shgrp_cull : stl->g_data->depth_shgrp;
+ *shgrp_depth_clip = (do_cull) ? stl->g_data->depth_shgrp_clip_cull : stl->g_data->depth_shgrp_clip;
+ }
+ }
+
+ emsg = MEM_mallocN(sizeof("EeveeMaterialShadingGroups"), "EeveeMaterialShadingGroups");
+ emsg->shading_grp = *shgrp;
+ emsg->depth_grp = *shgrp_depth;
+ emsg->depth_clip_grp = *shgrp_depth_clip;
+ BLI_ghash_insert(material_hash, ma, emsg);
+}
+
+static void material_transparent(
+ Material *ma, EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata,
+ bool do_cull, bool use_flat_nor, struct GPUMaterial **gpumat, struct DRWShadingGroup **shgrp, struct DRWShadingGroup **shgrp_depth)
+{
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ Scene *scene = draw_ctx->scene;
+ EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl;
+ EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl;
+ EEVEE_LampsInfo *linfo = sldata->lamps;
+
+ const bool use_refract = ((ma->blend_flag & MA_BL_SS_REFRACTION) != 0) && ((stl->effects->enabled_effects & EFFECT_REFRACT) != 0);
+
+ float *color_p = &ma->r;
+ float *metal_p = &ma->ray_mirror;
+ float *spec_p = &ma->spec;
+ float *rough_p = &ma->gloss_mir;
+
+ if (ma->use_nodes && ma->nodetree) {
+ /* Shading */
+ *gpumat = EEVEE_material_mesh_get(scene, ma, true, (ma->blend_method == MA_BM_MULTIPLY), use_refract, linfo->shadow_method);
+
+ *shgrp = DRW_shgroup_material_create(*gpumat, psl->transparent_pass);
+ if (*shgrp) {
+ static int ssr_id = -1; /* TODO transparent SSR */
+ add_standard_uniforms(*shgrp, sldata, vedata, &ssr_id, &ma->refract_depth, use_refract);
+ }
+ else {
+ /* Shader failed : pink color */
+ static float col[3] = {1.0f, 0.0f, 1.0f};
+ static float half = 0.5f;
+
+ color_p = col;
+ metal_p = spec_p = rough_p = &half;
+ }
+ }
+
+ /* Fallback to default shader */
+ if (*shgrp == NULL) {
+ *shgrp = EEVEE_default_shading_group_create(
+ sldata, vedata, psl->transparent_pass,
+ false, use_flat_nor, true, false, linfo->shadow_method);
+ DRW_shgroup_uniform_vec3(*shgrp, "basecol", color_p, 1);
+ DRW_shgroup_uniform_float(*shgrp, "metallic", metal_p, 1);
+ DRW_shgroup_uniform_float(*shgrp, "specular", spec_p, 1);
+ DRW_shgroup_uniform_float(*shgrp, "roughness", rough_p, 1);
+ }
+
+ const bool use_prepass = ((ma->blend_flag & MA_BL_HIDE_BACKSIDE) != 0);
+
+ DRWState all_state = DRW_STATE_WRITE_DEPTH | DRW_STATE_WRITE_COLOR | DRW_STATE_CULL_BACK | DRW_STATE_DEPTH_LESS | DRW_STATE_DEPTH_EQUAL |
+ DRW_STATE_BLEND | DRW_STATE_ADDITIVE | DRW_STATE_MULTIPLY;
+
+ DRWState cur_state = DRW_STATE_WRITE_COLOR;
+ cur_state |= (use_prepass) ? DRW_STATE_DEPTH_EQUAL : DRW_STATE_DEPTH_LESS;
+ cur_state |= (do_cull) ? DRW_STATE_CULL_BACK : 0;
+
+ switch (ma->blend_method) {
+ case MA_BM_ADD:
+ cur_state |= DRW_STATE_ADDITIVE;
+ break;
+ case MA_BM_MULTIPLY:
+ cur_state |= DRW_STATE_MULTIPLY;
+ break;
+ case MA_BM_BLEND:
+ cur_state |= DRW_STATE_BLEND;
+ break;
+ default:
+ BLI_assert(0);
+ break;
+ }
+
+ /* Disable other blend modes and use the one we want. */
+ DRW_shgroup_state_disable(*shgrp, all_state);
+ DRW_shgroup_state_enable(*shgrp, cur_state);
+
+ /* Depth prepass */
+ if (use_prepass) {
+ *shgrp_depth = DRW_shgroup_create(e_data.default_prepass_clip_sh, psl->transparent_pass);
+
+ cur_state = DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS;
+ cur_state |= (do_cull) ? DRW_STATE_CULL_BACK : 0;
+
+ DRW_shgroup_state_disable(*shgrp_depth, all_state);
+ DRW_shgroup_state_enable(*shgrp_depth, cur_state);
+ }
+}
+
+void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_SceneLayerData *sldata, Object *ob)
{
EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl;
EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl;
const DRWContextState *draw_ctx = DRW_context_state_get();
+ Scene *scene = draw_ctx->scene;
GHash *material_hash = stl->g_data->material_hash;
IDProperty *ces_mode_ob = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_OBJECT, "");
const bool do_cull = BKE_collection_engine_property_value_get_bool(ces_mode_ob, "show_backface_culling");
const bool is_active = (ob == draw_ctx->obact);
const bool is_sculpt_mode = is_active && (ob->mode & OB_MODE_SCULPT) != 0;
+#if 0
+ const bool is_sculpt_mode_draw = is_sculpt_mode && (draw_ctx->v3d->flag2 & V3D_SHOW_MODE_SHADE_OVERRIDE) == 0;
+#else
+ /* For now just force fully shaded with eevee when supported. */
+ const bool is_sculpt_mode_draw =
+ is_sculpt_mode &&
+ ((ob->sculpt && ob->sculpt->pbvh) && (BKE_pbvh_type(ob->sculpt->pbvh) != PBVH_FACES));
+#endif
const bool is_default_mode_shader = is_sculpt_mode;
- /* Depth Prepass */
- DRWShadingGroup *depth_shgrp = do_cull ? stl->g_data->depth_shgrp_cull : stl->g_data->depth_shgrp;
- DRWShadingGroup *depth_clip_shgrp = do_cull ? stl->g_data->depth_shgrp_clip_cull : stl->g_data->depth_shgrp_clip;
- ADD_SHGROUP_CALL(depth_shgrp, ob, geom);
- ADD_SHGROUP_CALL(depth_clip_shgrp, ob, geom);
+ /* First get materials for this mesh. */
+ if (ELEM(ob->type, OB_MESH)) {
+ const int materials_len = MAX2(1, (is_sculpt_mode_draw ? 1 : ob->totcol));
+
+ struct DRWShadingGroup **shgrp_array = BLI_array_alloca(shgrp_array, materials_len);
+ struct DRWShadingGroup **shgrp_depth_array = BLI_array_alloca(shgrp_depth_array, materials_len);
+ struct DRWShadingGroup **shgrp_depth_clip_array = BLI_array_alloca(shgrp_depth_clip_array, materials_len);
+
+ struct GPUMaterial **gpumat_array = BLI_array_alloca(gpumat_array, materials_len);
+ struct GPUMaterial **gpumat_depth_array = BLI_array_alloca(gpumat_array, materials_len);
- /* Get per-material split surface */
- struct Gwn_Batch **mat_geom = DRW_cache_object_surface_material_get(ob);
- if (mat_geom) {
bool use_flat_nor = false;
if (is_default_mode_shader) {
- if (is_sculpt_mode) {
+ if (is_sculpt_mode_draw) {
use_flat_nor = DRW_object_is_flat_normal(ob);
}
}
- for (int i = 0; i < MAX2(1, (is_sculpt_mode ? 1 : ob->totcol)); ++i) {
- DRWShadingGroup *shgrp = NULL;
- Material *ma = give_current_material(ob, i + 1);
+ for (int i = 0; i < materials_len; ++i) {
+ Material *ma;
+
+ if (is_sculpt_mode_draw) {
+ ma = NULL;
+ }
+ else {
+ ma = give_current_material(ob, i + 1);
+ }
+
+ gpumat_array[i] = NULL;
+ gpumat_depth_array[i] = NULL;
+ shgrp_array[i] = NULL;
+ shgrp_depth_array[i] = NULL;
+ shgrp_depth_clip_array[i] = NULL;
if (ma == NULL)
ma = &defmaterial;
- float *color_p = &ma->r;
- float *metal_p = &ma->ray_mirror;
- float *spec_p = &ma->spec;
- float *rough_p = &ma->gloss_mir;
-
- shgrp = BLI_ghash_lookup(material_hash, (const void *)ma);
- if (shgrp) {
- ADD_SHGROUP_CALL(shgrp, ob, mat_geom[i]);
- continue;
+ switch (ma->blend_method) {
+ case MA_BM_SOLID:
+ case MA_BM_CLIP:
+ case MA_BM_HASHED:
+ material_opaque(ma, material_hash, sldata, vedata, do_cull, use_flat_nor,
+ &gpumat_array[i], &gpumat_depth_array[i],
+ &shgrp_array[i], &shgrp_depth_array[i], &shgrp_depth_clip_array[i]);
+ break;
+ case MA_BM_ADD:
+ case MA_BM_MULTIPLY:
+ case MA_BM_BLEND:
+ material_transparent(ma, sldata, vedata, do_cull, use_flat_nor,
+ &gpumat_array[i], &shgrp_array[i], &shgrp_depth_array[i]);
+ break;
+ default:
+ BLI_assert(0);
+ break;
}
+ }
- if (ma->use_nodes && ma->nodetree) {
- Scene *scene = draw_ctx->scene;
- struct GPUMaterial *gpumat = EEVEE_material_mesh_get(scene, ma,
- stl->effects->use_ao, stl->effects->use_bent_normals);
-
- shgrp = DRW_shgroup_material_create(gpumat, psl->material_pass);
- if (shgrp) {
- add_standard_uniforms(shgrp, sldata, vedata);
-
- BLI_ghash_insert(material_hash, ma, shgrp);
+ if (is_sculpt_mode && is_sculpt_mode_draw == false) {
+ DRW_cache_mesh_sculpt_coords_ensure(ob);
+ }
- ADD_SHGROUP_CALL(shgrp, ob, mat_geom[i]);
+ /* Get per-material split surface */
+ struct Gwn_Batch **mat_geom = DRW_cache_object_surface_material_get(ob, gpumat_array, materials_len);
+ if (mat_geom) {
+ for (int i = 0; i < materials_len; ++i) {
+ Material *ma = give_current_material(ob, i + 1);
+
+ if (ma == NULL)
+ ma = &defmaterial;
+
+ /* Shading pass */
+ ADD_SHGROUP_CALL(shgrp_array[i], ob, mat_geom[i]);
+
+ /* Depth Prepass */
+ ADD_SHGROUP_CALL_SAFE(shgrp_depth_array[i], ob, mat_geom[i]);
+ ADD_SHGROUP_CALL_SAFE(shgrp_depth_clip_array[i], ob, mat_geom[i]);
+
+ /* Shadow Pass */
+ if (ma->use_nodes && ma->nodetree && (ma->blend_method != MA_BM_SOLID)) {
+ struct GPUMaterial *gpumat;
+ switch (ma->blend_shadow) {
+ case MA_BS_SOLID:
+ EEVEE_lights_cache_shcaster_add(sldata, psl, mat_geom[i], ob->obmat);
+ break;
+ case MA_BS_CLIP:
+ gpumat = EEVEE_material_mesh_depth_get(scene, ma, false, true);
+ EEVEE_lights_cache_shcaster_material_add(sldata, psl, gpumat, mat_geom[i], ob, ob->obmat, &ma->alpha_threshold);
+ break;
+ case MA_BS_HASHED:
+ gpumat = EEVEE_material_mesh_depth_get(scene, ma, true, true);
+ EEVEE_lights_cache_shcaster_material_add(sldata, psl, gpumat, mat_geom[i], ob, ob->obmat, NULL);
+ break;
+ case MA_BS_NONE:
+ default:
+ break;
+ }
}
else {
- /* Shader failed : pink color */
- static float col[3] = {1.0f, 0.0f, 1.0f};
- static float half = 0.5f;
-
- color_p = col;
- metal_p = spec_p = rough_p = &half;
+ EEVEE_lights_cache_shcaster_add(sldata, psl, mat_geom[i], ob->obmat);
}
}
-
- /* Fallback to default shader */
- if (shgrp == NULL) {
- shgrp = EEVEE_default_shading_group_get(sldata, vedata, false, use_flat_nor,
- stl->effects->use_ao, stl->effects->use_bent_normals);
- DRW_shgroup_uniform_vec3(shgrp, "basecol", color_p, 1);
- DRW_shgroup_uniform_float(shgrp, "metallic", metal_p, 1);
- DRW_shgroup_uniform_float(shgrp, "specular", spec_p, 1);
- DRW_shgroup_uniform_float(shgrp, "roughness", rough_p, 1);
-
- BLI_ghash_insert(material_hash, ma, shgrp);
-
- ADD_SHGROUP_CALL(shgrp, ob, mat_geom[i]);
- }
}
}
@@ -624,72 +1263,73 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_SceneLayerData *sl
if (ob != draw_ctx->scene->obedit) {
material_hash = stl->g_data->hair_material_hash;
- for (ParticleSystem *psys = ob->particlesystem.first; psys; psys = psys->next) {
- if (psys_check_enabled(ob, psys, false)) {
- ParticleSettings *part = psys->part;
- int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
+ for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_ParticleSystem) {
+ ParticleSystem *psys = ((ParticleSystemModifierData *)md)->psys;
- if (draw_as == PART_DRAW_PATH && (psys->pathcache || psys->childcache)) {
- struct Gwn_Batch *hair_geom = DRW_cache_particles_get_hair(psys);
- DRWShadingGroup *shgrp = NULL;
- Material *ma = give_current_material(ob, part->omat);
- static float mat[4][4];
+ if (psys_check_enabled(ob, psys, false)) {
+ ParticleSettings *part = psys->part;
+ int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
- unit_m4(mat);
+ if (draw_as == PART_DRAW_PATH && (psys->pathcache || psys->childcache)) {
+ struct Gwn_Batch *hair_geom = DRW_cache_particles_get_hair(psys, md);
+ DRWShadingGroup *shgrp = NULL;
+ Material *ma = give_current_material(ob, part->omat);
+ static float mat[4][4];
- if (ma == NULL) {
- ma = &defmaterial;
- }
+ unit_m4(mat);
- float *color_p = &ma->r;
- float *metal_p = &ma->ray_mirror;
- float *spec_p = &ma->spec;
- float *rough_p = &ma->gloss_mir;
+ if (ma == NULL) {
+ ma = &defmaterial;
+ }
- DRW_shgroup_call_add(stl->g_data->depth_shgrp, hair_geom, mat);
- DRW_shgroup_call_add(stl->g_data->depth_shgrp_clip, hair_geom, mat);
+ float *color_p = &ma->r;
+ float *metal_p = &ma->ray_mirror;
+ float *spec_p = &ma->spec;
+ float *rough_p = &ma->gloss_mir;
- shgrp = BLI_ghash_lookup(material_hash, (const void *)ma);
+ DRW_shgroup_call_add(stl->g_data->depth_shgrp, hair_geom, mat);
+ DRW_shgroup_call_add(stl->g_data->depth_shgrp_clip, hair_geom, mat);
- if (shgrp) {
- DRW_shgroup_call_add(shgrp, hair_geom, mat);
- }
- else {
- if (ma->use_nodes && ma->nodetree) {
- Scene *scene = draw_ctx->scene;
- struct GPUMaterial *gpumat = EEVEE_material_hair_get(scene, ma,
- stl->effects->use_ao, stl->effects->use_bent_normals);
+ shgrp = BLI_ghash_lookup(material_hash, (const void *)ma);
+
+ if (shgrp) {
+ DRW_shgroup_call_add(shgrp, hair_geom, mat);
+ }
+ else {
+ if (ma->use_nodes && ma->nodetree) {
+ struct GPUMaterial *gpumat = EEVEE_material_hair_get(scene, ma, sldata->lamps->shadow_method);
+
+ shgrp = DRW_shgroup_material_create(gpumat, psl->material_pass);
+ if (shgrp) {
+ add_standard_uniforms(shgrp, sldata, vedata, NULL, NULL, false);
+
+ BLI_ghash_insert(material_hash, ma, shgrp);
+
+ DRW_shgroup_call_add(shgrp, hair_geom, mat);
+ }
+ else {
+ /* Shader failed : pink color */
+ static float col[3] = {1.0f, 0.0f, 1.0f};
+ static float half = 0.5f;
+
+ color_p = col;
+ metal_p = spec_p = rough_p = &half;
+ }
+ }
- shgrp = DRW_shgroup_material_create(gpumat, psl->material_pass);
- if (shgrp) {
- add_standard_uniforms(shgrp, sldata, vedata);
+ /* Fallback to default shader */
+ if (shgrp == NULL) {
+ shgrp = EEVEE_default_shading_group_get(sldata, vedata, true, false, stl->effects->use_ssr, sldata->lamps->shadow_method);
+ DRW_shgroup_uniform_vec3(shgrp, "basecol", color_p, 1);
+ DRW_shgroup_uniform_float(shgrp, "metallic", metal_p, 1);
+ DRW_shgroup_uniform_float(shgrp, "specular", spec_p, 1);
+ DRW_shgroup_uniform_float(shgrp, "roughness", rough_p, 1);
BLI_ghash_insert(material_hash, ma, shgrp);
DRW_shgroup_call_add(shgrp, hair_geom, mat);
}
- else {
- /* Shader failed : pink color */
- static float col[3] = {1.0f, 0.0f, 1.0f};
- static float half = 0.5f;
-
- color_p = col;
- metal_p = spec_p = rough_p = &half;
- }
- }
-
- /* Fallback to default shader */
- if (shgrp == NULL) {
- shgrp = EEVEE_default_shading_group_get(sldata, vedata, true, false,
- stl->effects->use_ao, stl->effects->use_bent_normals);
- DRW_shgroup_uniform_vec3(shgrp, "basecol", color_p, 1);
- DRW_shgroup_uniform_float(shgrp, "metallic", metal_p, 1);
- DRW_shgroup_uniform_float(shgrp, "specular", spec_p, 1);
- DRW_shgroup_uniform_float(shgrp, "roughness", rough_p, 1);
-
- BLI_ghash_insert(material_hash, ma, shgrp);
-
- DRW_shgroup_call_add(shgrp, hair_geom, mat);
}
}
}
@@ -703,7 +1343,7 @@ void EEVEE_materials_cache_finish(EEVEE_Data *vedata)
{
EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl;
- BLI_ghash_free(stl->g_data->material_hash, NULL, NULL);
+ BLI_ghash_free(stl->g_data->material_hash, NULL, MEM_freeN);
BLI_ghash_free(stl->g_data->hair_material_hash, NULL, NULL);
}
@@ -713,6 +1353,7 @@ void EEVEE_materials_free(void)
DRW_SHADER_FREE_SAFE(e_data.default_lit[i]);
}
MEM_SAFE_FREE(e_data.frag_shader_lib);
+ MEM_SAFE_FREE(e_data.volume_shader_lib);
DRW_SHADER_FREE_SAFE(e_data.default_prepass_sh);
DRW_SHADER_FREE_SAFE(e_data.default_prepass_clip_sh);
DRW_SHADER_FREE_SAFE(e_data.default_background);
diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h
index a1abb6c71e2..45dabc37e06 100644
--- a/source/blender/draw/engines/eevee/eevee_private.h
+++ b/source/blender/draw/engines/eevee/eevee_private.h
@@ -35,10 +35,10 @@ extern struct DrawEngineType draw_engine_eevee_type;
#define MAX_GRID 64 /* TODO : find size by dividing UBO max size by grid data size */
#define MAX_PLANAR 16 /* TODO : find size by dividing UBO max size by grid data size */
#define MAX_LIGHT 128 /* TODO : find size by dividing UBO max size by light data size */
-#define MAX_SHADOW_CUBE 42 /* TODO : Make this depends on GL_MAX_ARRAY_TEXTURE_LAYERS */
-#define MAX_SHADOW_MAP 64
-#define MAX_SHADOW_CASCADE 8
#define MAX_CASCADE_NUM 4
+#define MAX_SHADOW 256 /* TODO : Make this depends on GL_MAX_ARRAY_TEXTURE_LAYERS */
+#define MAX_SHADOW_CASCADE 8
+#define MAX_SHADOW_CUBE (MAX_SHADOW - MAX_CASCADE_NUM * MAX_SHADOW_CASCADE)
#define MAX_BLOOM_STEP 16
/* Only define one of these. */
@@ -48,8 +48,14 @@ extern struct DrawEngineType draw_engine_eevee_type;
/* World shader variations */
enum {
- VAR_WORLD_BACKGROUND,
- VAR_WORLD_PROBE,
+ VAR_WORLD_BACKGROUND = 0,
+ VAR_WORLD_PROBE = 1,
+ VAR_WORLD_VOLUME = 2,
+
+ VAR_VOLUME_SHADOW = (1 << 2),
+ VAR_VOLUME_HOMO = (1 << 3),
+ VAR_VOLUME_LIGHT = (1 << 4),
+ VAR_VOLUME_COLOR = (1 << 5),
};
/* Material shader variations */
@@ -57,29 +63,51 @@ enum {
VAR_MAT_MESH = (1 << 0),
VAR_MAT_PROBE = (1 << 1),
VAR_MAT_HAIR = (1 << 2),
- VAR_MAT_AO = (1 << 3),
- VAR_MAT_FLAT = (1 << 4),
- VAR_MAT_BENT = (1 << 5),
+ VAR_MAT_FLAT = (1 << 3),
+ VAR_MAT_BLEND = (1 << 4),
+ VAR_MAT_VSM = (1 << 5),
+ VAR_MAT_ESM = (1 << 6),
/* Max number of variation */
/* IMPORTANT : Leave it last and set
* it's value accordingly. */
- VAR_MAT_MAX = (1 << 6)
+ VAR_MAT_MAX = (1 << 7),
+ /* These are options that are not counted in VAR_MAT_MAX
+ * because they are not cumulative with the others above. */
+ VAR_MAT_CLIP = (1 << 8),
+ VAR_MAT_HASH = (1 << 9),
+ VAR_MAT_MULT = (1 << 10),
+ VAR_MAT_SHADOW = (1 << 11),
+ VAR_MAT_REFRACT = (1 << 12),
+};
+
+/* Shadow Technique */
+enum {
+ SHADOW_ESM = 1,
+ SHADOW_VSM = 2,
+ SHADOW_METHOD_MAX = 3,
};
typedef struct EEVEE_PassList {
/* Shadows */
struct DRWPass *shadow_pass;
struct DRWPass *shadow_cube_pass;
+ struct DRWPass *shadow_cube_copy_pass;
struct DRWPass *shadow_cube_store_pass;
struct DRWPass *shadow_cascade_pass;
+ struct DRWPass *shadow_cascade_copy_pass;
+ struct DRWPass *shadow_cascade_store_pass;
/* Probes */
struct DRWPass *probe_background;
struct DRWPass *probe_glossy_compute;
struct DRWPass *probe_diffuse_compute;
+ struct DRWPass *probe_grid_fill;
struct DRWPass *probe_display;
+ struct DRWPass *probe_planar_downsample_ps;
/* Effects */
+ struct DRWPass *ao_horizon_search;
+ struct DRWPass *ao_horizon_debug;
struct DRWPass *motion_blur;
struct DRWPass *bloom_blit;
struct DRWPass *bloom_downsample_first;
@@ -89,33 +117,61 @@ typedef struct EEVEE_PassList {
struct DRWPass *dof_down;
struct DRWPass *dof_scatter;
struct DRWPass *dof_resolve;
- struct DRWPass *minmaxz_downlevel;
- struct DRWPass *minmaxz_downdepth;
- struct DRWPass *minmaxz_copydepth;
+ struct DRWPass *volumetric_integrate_ps;
+ struct DRWPass *volumetric_resolve_ps;
+ struct DRWPass *volumetric_resolve_transmit_ps;
+ struct DRWPass *ssr_raytrace;
+ struct DRWPass *ssr_resolve;
+ struct DRWPass *color_downsample_ps;
+ struct DRWPass *color_downsample_cube_ps;
+ struct DRWPass *taa_resolve;
+
+ /* HiZ */
+ struct DRWPass *minz_downlevel_ps;
+ struct DRWPass *maxz_downlevel_ps;
+ struct DRWPass *minz_downdepth_ps;
+ struct DRWPass *maxz_downdepth_ps;
+ struct DRWPass *minz_downdepth_layer_ps;
+ struct DRWPass *maxz_downdepth_layer_ps;
+ struct DRWPass *minz_copydepth_ps;
+ struct DRWPass *maxz_copydepth_ps;
struct DRWPass *depth_pass;
struct DRWPass *depth_pass_cull;
struct DRWPass *depth_pass_clip;
struct DRWPass *depth_pass_clip_cull;
+ struct DRWPass *refract_depth_pass;
+ struct DRWPass *refract_depth_pass_cull;
+ struct DRWPass *refract_depth_pass_clip;
+ struct DRWPass *refract_depth_pass_clip_cull;
struct DRWPass *default_pass[VAR_MAT_MAX];
struct DRWPass *material_pass;
+ struct DRWPass *refract_pass;
+ struct DRWPass *transparent_pass;
struct DRWPass *background_pass;
} EEVEE_PassList;
typedef struct EEVEE_FramebufferList {
/* Effects */
- struct GPUFrameBuffer *minmaxz_fb;
- struct GPUFrameBuffer *effect_fb; /* HDR */
- struct GPUFrameBuffer *bloom_blit_fb; /* HDR */
- struct GPUFrameBuffer *bloom_down_fb[MAX_BLOOM_STEP]; /* HDR */
- struct GPUFrameBuffer *bloom_accum_fb[MAX_BLOOM_STEP-1]; /* HDR */
+ struct GPUFrameBuffer *gtao_fb;
+ struct GPUFrameBuffer *gtao_debug_fb;
+ struct GPUFrameBuffer *downsample_fb;
+ struct GPUFrameBuffer *effect_fb;
+ struct GPUFrameBuffer *bloom_blit_fb;
+ struct GPUFrameBuffer *bloom_down_fb[MAX_BLOOM_STEP];
+ struct GPUFrameBuffer *bloom_accum_fb[MAX_BLOOM_STEP - 1];
struct GPUFrameBuffer *dof_down_fb;
struct GPUFrameBuffer *dof_scatter_far_fb;
struct GPUFrameBuffer *dof_scatter_near_fb;
+ struct GPUFrameBuffer *volumetric_fb;
+ struct GPUFrameBuffer *screen_tracing_fb;
+ struct GPUFrameBuffer *refract_fb;
struct GPUFrameBuffer *planarref_fb;
- struct GPUFrameBuffer *main; /* HDR */
+ struct GPUFrameBuffer *main;
+ struct GPUFrameBuffer *double_buffer;
+ struct GPUFrameBuffer *depth_double_buffer_fb;
} EEVEE_FramebufferList;
typedef struct EEVEE_TextureList {
@@ -128,11 +184,21 @@ typedef struct EEVEE_TextureList {
struct GPUTexture *dof_far_blur; /* R16_G16_B16_A16 */
struct GPUTexture *bloom_blit; /* R16_G16_B16 */
struct GPUTexture *bloom_downsample[MAX_BLOOM_STEP]; /* R16_G16_B16 */
- struct GPUTexture *bloom_upsample[MAX_BLOOM_STEP-1]; /* R16_G16_B16 */
+ struct GPUTexture *bloom_upsample[MAX_BLOOM_STEP - 1]; /* R16_G16_B16 */
+ struct GPUTexture *ssr_normal_input;
+ struct GPUTexture *ssr_specrough_input;
+ struct GPUTexture *refract_color;
struct GPUTexture *planar_pool;
+ struct GPUTexture *planar_depth;
+
+ struct GPUTexture *gtao_horizons;
+
+ struct GPUTexture *maxzbuffer;
struct GPUTexture *color; /* R16_G16_B16 */
+ struct GPUTexture *color_double_buffer;
+ struct GPUTexture *depth_double_buffer;
} EEVEE_TextureList;
typedef struct EEVEE_StorageList {
@@ -152,47 +218,64 @@ typedef struct EEVEE_Light {
float forwardvec[3], lamptype;
} EEVEE_Light;
-typedef struct EEVEE_ShadowCube {
+typedef struct EEVEE_Shadow {
float near, far, bias, exp;
-} EEVEE_ShadowCube;
+ float shadow_start, data_start, multi_shadow_count, pad;
+ float contact_dist, contact_bias, contact_spread, contact_thickness;
+} EEVEE_Shadow;
-typedef struct EEVEE_ShadowMap {
- float shadowmat[4][4]; /* World->Lamp->NDC->Tex : used for sampling the shadow map. */
- float near, far, bias, pad;
-} EEVEE_ShadowMap;
+typedef struct EEVEE_ShadowCube {
+ float position[3], pad;
+} EEVEE_ShadowCube;
typedef struct EEVEE_ShadowCascade {
float shadowmat[MAX_CASCADE_NUM][4][4]; /* World->Lamp->NDC->Tex : used for sampling the shadow map. */
- float split[4];
- float bias[4];
+ float split_start[4];
+ float split_end[4];
} EEVEE_ShadowCascade;
typedef struct EEVEE_ShadowRender {
- float shadowmat[6][4][4]; /* World->Lamp->NDC : used to render the shadow map. 6 frustrum for cubemap shadow */
- float position[3];
- float pad;
- int layer;
- float exponent;
+ float shadowmat[6][4][4]; /* World->Lamp->NDC : used to render the shadow map. 6 frustum for cubemap shadow */
+ float viewmat[6][4][4]; /* World->Lamp : used to render the shadow map. 6 viewmat for cubemap shadow */
+ float position[3], pad;
+ float cube_texel_size;
+ float stored_texel_size;
+ float clip_near;
+ float clip_far;
+ int shadow_samples_ct;
+ float shadow_inv_samples_ct;
} EEVEE_ShadowRender;
+/* ************ VOLUME DATA ************ */
+typedef struct EEVEE_VolumetricsInfo {
+ float integration_step_count, shadow_step_count, sample_distribution, light_clamp;
+ float integration_start, integration_end;
+ bool use_lights, use_volume_shadows, use_colored_transmit;
+} EEVEE_VolumetricsInfo;
+
/* ************ LIGHT DATA ************* */
typedef struct EEVEE_LampsInfo {
int num_light, cache_num_light;
- int num_cube, cache_num_cube;
- int num_map, cache_num_map;
- int num_cascade, cache_num_cascade;
+ int num_layer, cache_num_layer;
+ int gpu_cube_ct, gpu_cascade_ct, gpu_shadow_ct;
+ int cpu_cube_ct, cpu_cascade_ct;
int update_flag;
+ int shadow_size, shadow_method;
+ bool shadow_high_bitdepth;
+ int shadow_cube_target_size;
+ int current_shadow_cascade;
+ int current_shadow_face;
+ float filter_size;
/* List of lights in the scene. */
/* XXX This is fragile, can get out of sync quickly. */
struct Object *light_ref[MAX_LIGHT];
struct Object *shadow_cube_ref[MAX_SHADOW_CUBE];
- struct Object *shadow_map_ref[MAX_SHADOW_MAP];
struct Object *shadow_cascade_ref[MAX_SHADOW_CASCADE];
/* UBO Storage : data used by UBO */
struct EEVEE_Light light_data[MAX_LIGHT];
struct EEVEE_ShadowRender shadow_render_data;
+ struct EEVEE_Shadow shadow_data[MAX_SHADOW];
struct EEVEE_ShadowCube shadow_cube_data[MAX_SHADOW_CUBE];
- struct EEVEE_ShadowMap shadow_map_data[MAX_SHADOW_MAP];
struct EEVEE_ShadowCascade shadow_cascade_data[MAX_SHADOW_CASCADE];
} EEVEE_LampsInfo;
@@ -216,7 +299,7 @@ typedef struct EEVEE_LightGrid {
int resolution[3], offset;
float corner[3], attenuation_scale;
float increment_x[3], attenuation_bias; /* world space vector between 2 opposite cells */
- float increment_y[3], pad3;
+ float increment_y[3], level_bias;
float increment_z[3], pad4;
} EEVEE_LightGrid;
@@ -237,6 +320,8 @@ typedef struct EEVEE_LightProbesInfo {
int num_planar, cache_num_planar;
int update_flag;
int updated_bounce;
+ int num_bounce;
+ int grid_initialized;
/* Actual number of probes that have datas. */
int num_render_cube;
int num_render_grid;
@@ -249,10 +334,11 @@ typedef struct EEVEE_LightProbesInfo {
float invsamples_ct;
float roughness;
float lodfactor;
- float lodmax;
+ float lod_rt_max, lod_cube_max, lod_planar_max;
int shres;
int shnbr;
bool specular_toggle;
+ bool ssr_toggle;
/* List of probes in the scene. */
/* XXX This is fragile, can get out of sync quickly. */
struct Object *probes_cube_ref[MAX_PROBE];
@@ -267,15 +353,43 @@ typedef struct EEVEE_LightProbesInfo {
/* EEVEE_LightProbesInfo->update_flag */
enum {
PROBE_UPDATE_CUBE = (1 << 0),
+ PROBE_UPDATE_GRID = (1 << 1),
+ PROBE_UPDATE_ALL = 0xFFFFFF,
};
/* ************ EFFECTS DATA ************* */
typedef struct EEVEE_EffectsInfo {
int enabled_effects;
+ /* SSR */
+ bool use_ssr;
+ bool reflection_trace_full;
+ bool ssr_use_normalization;
+ int ssr_ray_count;
+ float ssr_firefly_fac;
+ float ssr_border_fac;
+ float ssr_max_roughness;
+ float ssr_quality;
+ float ssr_thickness;
+ float ssr_pixelsize[2];
+
+ /* Temporal Anti Aliasing */
+ int taa_current_sample;
+ int taa_total_sample;
+ float taa_alpha;
+ bool prev_drw_support;
+ float prev_drw_persmat[4][4];
+ float overide_persmat[4][4];
+ float overide_persinv[4][4];
+ float overide_winmat[4][4];
+ float overide_wininv[4][4];
+
/* Ambient Occlusion */
bool use_ao, use_bent_normals;
- float ao_dist, ao_samples, ao_factor;
+ float ao_dist, ao_samples, ao_factor, ao_samples_inv;
+ float ao_offset, ao_bounce_fac, ao_quality, ao_settings;
+ float ao_sample_nbr;
+ int ao_texsize[2], hori_tex_layers;
/* Motion Blur */
float current_ndc_to_world[4][4];
@@ -295,7 +409,8 @@ typedef struct EEVEE_EffectsInfo {
float source_texel_size[2];
float blit_texel_size[2];
float downsamp_texel_size[MAX_BLOOM_STEP][2];
- float bloom_intensity;
+ float bloom_color[3];
+ float bloom_clamp;
float bloom_sample_scale;
float bloom_curve_threshold[4];
float unf_source_texel_size[2];
@@ -311,6 +426,12 @@ enum {
EFFECT_MOTION_BLUR = (1 << 0),
EFFECT_BLOOM = (1 << 1),
EFFECT_DOF = (1 << 2),
+ EFFECT_VOLUMETRIC = (1 << 3),
+ EFFECT_SSR = (1 << 4),
+ EFFECT_DOUBLE_BUFFER = (1 << 5), /* Not really an effect but a feature */
+ EFFECT_REFRACT = (1 << 6),
+ EFFECT_GTAO = (1 << 7),
+ EFFECT_TAA = (1 << 8),
};
/* ************** SCENE LAYER DATA ************** */
@@ -321,17 +442,16 @@ typedef struct EEVEE_SceneLayerData {
struct GPUUniformBuffer *light_ubo;
struct GPUUniformBuffer *shadow_ubo;
struct GPUUniformBuffer *shadow_render_ubo;
+ struct GPUUniformBuffer *shadow_samples_ubo;
- struct GPUFrameBuffer *shadow_cube_target_fb;
- struct GPUFrameBuffer *shadow_cube_fb;
- struct GPUFrameBuffer *shadow_map_fb;
- struct GPUFrameBuffer *shadow_cascade_fb;
+ struct GPUFrameBuffer *shadow_target_fb;
+ struct GPUFrameBuffer *shadow_store_fb;
- struct GPUTexture *shadow_depth_cube_target;
- struct GPUTexture *shadow_color_cube_target;
- struct GPUTexture *shadow_depth_cube_pool;
- struct GPUTexture *shadow_depth_map_pool;
- struct GPUTexture *shadow_depth_cascade_pool;
+ struct GPUTexture *shadow_cube_target;
+ struct GPUTexture *shadow_cube_blur;
+ struct GPUTexture *shadow_cascade_target;
+ struct GPUTexture *shadow_cascade_blur;
+ struct GPUTexture *shadow_pool;
struct ListBase shadow_casters; /* Shadow casters gathered during cache iteration */
@@ -351,6 +471,9 @@ typedef struct EEVEE_SceneLayerData {
struct GPUTexture *irradiance_rt;
struct ListBase probe_queue; /* List of probes to update */
+
+ /* Volumetrics */
+ struct EEVEE_VolumetricsInfo *volumetrics;
} EEVEE_SceneLayerData;
/* ************ OBJECT DATA ************ */
@@ -364,8 +487,11 @@ typedef struct EEVEE_LightProbeEngineData {
bool need_update;
bool ready_to_shade;
int updated_cells;
+ int updated_lvl;
int num_cell;
+ int max_lvl;
int probe_id; /* Only used for display data */
+ float probe_size; /* Only used for display data */
/* For planar reflection rendering */
float viewmat[4][4];
float persmat[4][4];
@@ -393,11 +519,30 @@ typedef struct EEVEE_PrivateData {
struct DRWShadingGroup *depth_shgrp_cull;
struct DRWShadingGroup *depth_shgrp_clip;
struct DRWShadingGroup *depth_shgrp_clip_cull;
+ struct DRWShadingGroup *refract_depth_shgrp;
+ struct DRWShadingGroup *refract_depth_shgrp_cull;
+ struct DRWShadingGroup *refract_depth_shgrp_clip;
+ struct DRWShadingGroup *refract_depth_shgrp_clip_cull;
struct DRWShadingGroup *cube_display_shgrp;
+ struct DRWShadingGroup *planar_display_shgrp;
+ struct DRWShadingGroup *planar_downsample;
struct GHash *material_hash;
struct GHash *hair_material_hash;
- struct GPUTexture *minmaxz;
+ struct GPUTexture *minzbuffer;
+ struct GPUTexture *ssr_hit_output[4];
+ struct GPUTexture *volumetric;
+ struct GPUTexture *volumetric_transmit;
+ struct GPUTexture *gtao_horizons_debug;
float background_alpha; /* TODO find a better place for this. */
+ float viewvecs[2][4];
+ /* For planar probes */
+ float texel_size[2];
+ /* To correct mip level texel mis-alignement */
+ float mip_ratio[10][2]; /* TODO put in a UBO */
+ /* For double buffering */
+ bool view_updated;
+ bool valid_double_buffer;
+ float prev_persmat[4][4];
} EEVEE_PrivateData; /* Transient data */
/* eevee_data.c */
@@ -407,23 +552,34 @@ EEVEE_LightProbeEngineData *EEVEE_lightprobe_data_get(Object *ob);
EEVEE_LampEngineData *EEVEE_lamp_data_get(Object *ob);
/* eevee_materials.c */
-void EEVEE_materials_init(void);
+struct GPUTexture *EEVEE_materials_get_util_tex(void); /* XXX */
+void EEVEE_materials_init(EEVEE_StorageList *stl);
void EEVEE_materials_cache_init(EEVEE_Data *vedata);
-void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_SceneLayerData *sldata, Object *ob, struct Gwn_Batch *geom);
+void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_SceneLayerData *sldata, Object *ob);
void EEVEE_materials_cache_finish(EEVEE_Data *vedata);
struct GPUMaterial *EEVEE_material_world_lightprobe_get(struct Scene *scene, struct World *wo);
struct GPUMaterial *EEVEE_material_world_background_get(struct Scene *scene, struct World *wo);
-struct GPUMaterial *EEVEE_material_mesh_lightprobe_get(struct Scene *scene, Material *ma);
-struct GPUMaterial *EEVEE_material_mesh_get(struct Scene *scene, Material *ma, bool use_ao, bool use_bent_normals);
-struct GPUMaterial *EEVEE_material_hair_get(struct Scene *scene, Material *ma, bool use_ao, bool use_bent_normals);
+struct GPUMaterial *EEVEE_material_world_volume_get(
+ struct Scene *scene, struct World *wo, bool use_lights, bool use_volume_shadows, bool is_homogeneous, bool use_color_transmit,
+ int shadow_method);
+struct GPUMaterial *EEVEE_material_mesh_get(
+ struct Scene *scene, Material *ma, bool use_blend, bool use_multiply, bool use_refract, int shadow_method);
+struct GPUMaterial *EEVEE_material_mesh_depth_get(struct Scene *scene, Material *ma, bool use_hashed_alpha, bool is_shadow);
+struct GPUMaterial *EEVEE_material_hair_get(struct Scene *scene, Material *ma, int shadow_method);
void EEVEE_materials_free(void);
void EEVEE_draw_default_passes(EEVEE_PassList *psl);
+void EEVEE_update_util_texture(float offset);
/* eevee_lights.c */
void EEVEE_lights_init(EEVEE_SceneLayerData *sldata);
void EEVEE_lights_cache_init(EEVEE_SceneLayerData *sldata, EEVEE_PassList *psl);
void EEVEE_lights_cache_add(EEVEE_SceneLayerData *sldata, struct Object *ob);
-void EEVEE_lights_cache_shcaster_add(EEVEE_SceneLayerData *sldata, EEVEE_PassList *psl, struct Gwn_Batch *geom, float (*obmat)[4]);
+void EEVEE_lights_cache_shcaster_add(
+ EEVEE_SceneLayerData *sldata, EEVEE_PassList *psl, struct Gwn_Batch *geom, float (*obmat)[4]);
+void EEVEE_lights_cache_shcaster_material_add(
+ EEVEE_SceneLayerData *sldata, EEVEE_PassList *psl,
+ struct GPUMaterial *gpumat, struct Gwn_Batch *geom, struct Object *ob,
+ float (*obmat)[4], float *alpha_threshold);
void EEVEE_lights_cache_finish(EEVEE_SceneLayerData *sldata);
void EEVEE_lights_update(EEVEE_SceneLayerData *sldata);
void EEVEE_draw_shadows(EEVEE_SceneLayerData *sldata, EEVEE_PassList *psl);
@@ -431,59 +587,65 @@ void EEVEE_lights_free(void);
/* eevee_lightprobes.c */
void EEVEE_lightprobes_init(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata);
-void EEVEE_lightprobes_cache_init(EEVEE_SceneLayerData *sldata, EEVEE_PassList *psl, EEVEE_StorageList *stl);
+void EEVEE_lightprobes_cache_init(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata);
void EEVEE_lightprobes_cache_add(EEVEE_SceneLayerData *sldata, Object *ob);
void EEVEE_lightprobes_cache_finish(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata);
void EEVEE_lightprobes_refresh(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata);
void EEVEE_lightprobes_free(void);
/* eevee_effects.c */
-void EEVEE_effects_init(EEVEE_Data *vedata);
-void EEVEE_effects_cache_init(EEVEE_Data *vedata);
-void EEVEE_create_minmax_buffer(EEVEE_Data *vedata, struct GPUTexture *depth_src);
+void EEVEE_effects_init(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata);
+void EEVEE_effects_cache_init(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata);
+void EEVEE_create_minmax_buffer(EEVEE_Data *vedata, struct GPUTexture *depth_src, int layer);
+void EEVEE_downsample_buffer(EEVEE_Data *vedata, struct GPUFrameBuffer *fb_src, struct GPUTexture *texture_src, int level);
+void EEVEE_downsample_cube_buffer(EEVEE_Data *vedata, struct GPUFrameBuffer *fb_src, struct GPUTexture *texture_src, int level);
+void EEVEE_effects_do_volumetrics(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata);
+void EEVEE_effects_do_ssr(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata);
+void EEVEE_effects_do_refraction(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata);
+void EEVEE_effects_do_gtao(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata);
void EEVEE_draw_effects(EEVEE_Data *vedata);
void EEVEE_effects_free(void);
/* Shadow Matrix */
static const float texcomat[4][4] = { /* From NDC to TexCo */
- {0.5, 0.0, 0.0, 0.0},
- {0.0, 0.5, 0.0, 0.0},
- {0.0, 0.0, 0.5, 0.0},
- {0.5, 0.5, 0.5, 1.0}
+ {0.5f, 0.0f, 0.0f, 0.0f},
+ {0.0f, 0.5f, 0.0f, 0.0f},
+ {0.0f, 0.0f, 0.5f, 0.0f},
+ {0.5f, 0.5f, 0.5f, 1.0f}
};
/* Cubemap Matrices */
static const float cubefacemat[6][4][4] = {
/* Pos X */
- {{0.0, 0.0, -1.0, 0.0},
- {0.0, -1.0, 0.0, 0.0},
- {-1.0, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 1.0}},
+ {{0.0f, 0.0f, -1.0f, 0.0f},
+ {0.0f, -1.0f, 0.0f, 0.0f},
+ {-1.0f, 0.0f, 0.0f, 0.0f},
+ {0.0f, 0.0f, 0.0f, 1.0f}},
/* Neg X */
- {{0.0, 0.0, 1.0, 0.0},
- {0.0, -1.0, 0.0, 0.0},
- {1.0, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 1.0}},
+ {{0.0f, 0.0f, 1.0f, 0.0f},
+ {0.0f, -1.0f, 0.0f, 0.0f},
+ {1.0f, 0.0f, 0.0f, 0.0f},
+ {0.0f, 0.0f, 0.0f, 1.0f}},
/* Pos Y */
- {{1.0, 0.0, 0.0, 0.0},
- {0.0, 0.0, -1.0, 0.0},
- {0.0, 1.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 1.0}},
+ {{1.0f, 0.0f, 0.0f, 0.0f},
+ {0.0f, 0.0f, -1.0f, 0.0f},
+ {0.0f, 1.0f, 0.0f, 0.0f},
+ {0.0f, 0.0f, 0.0f, 1.0f}},
/* Neg Y */
- {{1.0, 0.0, 0.0, 0.0},
- {0.0, 0.0, 1.0, 0.0},
- {0.0, -1.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 1.0}},
+ {{1.0f, 0.0f, 0.0f, 0.0f},
+ {0.0f, 0.0f, 1.0f, 0.0f},
+ {0.0f, -1.0f, 0.0f, 0.0f},
+ {0.0f, 0.0f, 0.0f, 1.0f}},
/* Pos Z */
- {{1.0, 0.0, 0.0, 0.0},
- {0.0, -1.0, 0.0, 0.0},
- {0.0, 0.0, -1.0, 0.0},
- {0.0, 0.0, 0.0, 1.0}},
+ {{1.0f, 0.0f, 0.0f, 0.0f},
+ {0.0f, -1.0f, 0.0f, 0.0f},
+ {0.0f, 0.0f, -1.0f, 0.0f},
+ {0.0f, 0.0f, 0.0f, 1.0f}},
/* Neg Z */
- {{-1.0, 0.0, 0.0, 0.0},
- {0.0, -1.0, 0.0, 0.0},
- {0.0, 0.0, 1.0, 0.0},
- {0.0, 0.0, 0.0, 1.0}},
+ {{-1.0f, 0.0f, 0.0f, 0.0f},
+ {0.0f, -1.0f, 0.0f, 0.0f},
+ {0.0f, 0.0f, 1.0f, 0.0f},
+ {0.0f, 0.0f, 0.0f, 1.0f}},
};
#endif /* __EEVEE_PRIVATE_H__ */
diff --git a/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl b/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
index 5a7e893deb6..b490f24eeae 100644
--- a/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
@@ -3,209 +3,330 @@
* http://blog.selfshadow.com/publications/s2016-shading-course/activision/s2016_pbs_activision_occlusion.pdf
* http://blog.selfshadow.com/publications/s2016-shading-course/activision/s2016_pbs_activision_occlusion.pptx */
+#if defined(MESH_SHADER)
+# if !defined(USE_ALPHA_HASH)
+# if !defined(USE_ALPHA_CLIP)
+# if !defined(SHADOW_SHADER)
+# if !defined(USE_MULTIPLY)
+# if !defined(USE_ALPHA_BLEND)
+# define ENABLE_DEFERED_AO
+# endif
+# endif
+# endif
+# endif
+# endif
+#endif
+
+#ifndef ENABLE_DEFERED_AO
+# if defined(STEP_RESOLVE)
+# define ENABLE_DEFERED_AO
+# endif
+#endif
+
#define MAX_PHI_STEP 32
-/* NOTICE : this is multiplied by 2 */
-#define MAX_THETA_STEP 12
+#define MAX_SEARCH_ITER 32
+#define MAX_LOD 6.0
-uniform sampler2D minMaxDepthTex;
-uniform vec3 aoParameters;
+#ifndef UTIL_TEX
+#define UTIL_TEX
+uniform sampler2DArray utilTex;
+#endif /* UTIL_TEX */
-#define aoDistance aoParameters.x
-#define aoSamples aoParameters.y
-#define aoFactor aoParameters.z
+uniform vec4 aoParameters[2];
+uniform sampler2DArray horizonBuffer;
-float get_max_horizon(vec2 co, vec3 x, float h, float lod)
-{
- float depth = textureLod(minMaxDepthTex, co, floor(lod)).g;
+/* Cannot use textureSize(horizonBuffer) when rendering to it */
+uniform ivec2 aoHorizonTexSize;
- /* Background case */
- /* this is really slow and is only a problem
- * if the far clip plane is near enough to notice */
- // depth += step(1.0, depth) * 1e20;
+#define aoDistance aoParameters[0].x
+#define aoSamples aoParameters[0].y
+#define aoFactor aoParameters[0].z
+#define aoInvSamples aoParameters[0].w
- vec3 s = get_view_space_from_depth(co, depth); /* s View coordinate */
- vec3 omega_s = s - x;
- float len = length(omega_s);
+#define aoOffset aoParameters[1].x /* UNUSED */
+#define aoBounceFac aoParameters[1].y
+#define aoQuality aoParameters[1].z
+#define aoSettings aoParameters[1].w
- float max_h = max(h, omega_s.z / len);
- /* Blend weight after half the aoDistance to fade artifacts */
- float blend = saturate((1.0 - len / aoDistance) * 2.0);
+#define USE_AO 1
+#define USE_BENT_NORMAL 2
+#define USE_DENOISE 4
- return mix(h, max_h, blend);
-}
+vec2 pack_horizons(vec2 v) { return v * 0.5 + 0.5; }
+vec2 unpack_horizons(vec2 v) { return v * 2.0 - 1.0; }
-void search_step(
- vec2 t_phi, vec3 x, vec2 x_, float rand, vec2 pixel_ratio,
- inout float j, inout float ofs, inout float h1, inout float h2)
+/* Returns the texel coordinate in horizonBuffer
+ * for a given fullscreen coord */
+ivec2 get_hr_co(ivec2 fs_co)
{
- ofs += ofs; /* Step size is doubled each iteration */
+ bvec2 quarter = notEqual(fs_co & ivec2(1), ivec2(0));
+
+ ivec2 hr_co = fs_co / 2;
+ hr_co += ivec2(quarter) * (aoHorizonTexSize / 2);
- vec2 s_ = t_phi * ofs * rand * pixel_ratio; /* s^ Screen coordinate */
- vec2 co;
+ return hr_co;
+}
- co = x_ + s_;
- h1 = get_max_horizon(co, x, h1, j);
+/* Returns the texel coordinate in fullscreen (depthBuffer)
+ * for a given horizonBuffer coord */
+ivec2 get_fs_co(ivec2 hr_co)
+{
+ hr_co *= 2;
+ bvec2 quarter = greaterThanEqual(hr_co, aoHorizonTexSize);
- co = x_ - s_;
- h2 = get_max_horizon(co, x, h2, j);
+ hr_co -= ivec2(quarter) * (aoHorizonTexSize - 1);
- j += 0.5;
+ return hr_co;
}
-void search_horizon(
- vec2 t_phi, vec3 x, vec2 x_, float rand,
- float max_dist, vec2 pixel_ratio, float pixel_len,
- inout float h1, inout float h2)
+/* Returns the phi angle in horizonBuffer
+ * for a given horizonBuffer coord */
+float get_phi(ivec2 hr_co, ivec2 fs_co, float sample)
{
- float ofs = 1.5 * pixel_len;
- float j = 0.0;
-
-#if 0 /* manually unrolled bellow */
- for (int i = 0; i < MAX_THETA_STEP; i++) {
- search_step(t_phi, x, x_, rand, pixel_ratio, j, ofs, h1, h2);
- if (ofs > max_dist)
- return;
+ bvec2 quarter = greaterThanEqual(hr_co, aoHorizonTexSize / 2);
+ ivec2 tex_co = ((int(aoSettings) & USE_DENOISE) != 0) ? hr_co - ivec2(quarter) * (aoHorizonTexSize / 2) : fs_co;
+ float blue_noise = texture(utilTex, vec3((vec2(tex_co) + 0.5) / LUT_SIZE, 2.0)).r;
+
+ float phi = sample * aoInvSamples;
+
+ if ((int(aoSettings) & USE_DENOISE) != 0) {
+ /* Interleaved jitter for spatial 2x2 denoising */
+ phi += 0.25 * aoInvSamples * (float(quarter.x) + 2.0 * float(quarter.y));
+ blue_noise *= 0.25;
}
-#endif
- search_step(t_phi, x, x_, rand, pixel_ratio, j, ofs, h1, h2);
- if (ofs > max_dist) return;
+ /* Blue noise is scaled to cover the rest of the range. */
+ phi += aoInvSamples * blue_noise;
+ phi *= M_PI;
- search_step(t_phi, x, x_, rand, pixel_ratio, j, ofs, h1, h2);
- if (ofs > max_dist) return;
+ return phi;
+}
- search_step(t_phi, x, x_, rand, pixel_ratio, j, ofs, h1, h2);
- if (ofs > max_dist) return;
+/* Returns direction jittered offset for a given fullscreen coord */
+float get_offset(ivec2 fs_co, float sample)
+{
+ float offset = sample * aoInvSamples;
- search_step(t_phi, x, x_, rand, pixel_ratio, j, ofs, h1, h2);
- if (ofs > max_dist) return;
+ /* Interleaved jitter for spatial 2x2 denoising */
+ offset += 0.25 * dot(vec2(1.0), vec2(fs_co & 1));
+ offset += texture(utilTex, vec3((vec2(fs_co / 2) + 0.5 + 16.0) / LUT_SIZE, 2.0)).r;
+ return offset;
+}
- search_step(t_phi, x, x_, rand, pixel_ratio, j, ofs, h1, h2);
- if (ofs > max_dist) return;
+/* Returns maximum screen distance an AO ray can travel for a given view depth */
+vec2 get_max_dir(float view_depth)
+{
+ float homcco = ProjectionMatrix[2][3] * view_depth + ProjectionMatrix[3][3];
+ float max_dist = aoDistance / homcco;
+ return vec2(ProjectionMatrix[0][0], ProjectionMatrix[1][1]) * max_dist;
+}
- search_step(t_phi, x, x_, rand, pixel_ratio, j, ofs, h1, h2);
- if (ofs > max_dist) return;
+void get_max_horizon_grouped(vec4 co1, vec4 co2, vec3 x, float lod, inout float h)
+{
+ co1 *= mipRatio[int(lod + 1.0)].xyxy; /* +1 because we are using half res top level */
+ co2 *= mipRatio[int(lod + 1.0)].xyxy; /* +1 because we are using half res top level */
+
+ float depth1 = textureLod(maxzBuffer, co1.xy, floor(lod)).r;
+ float depth2 = textureLod(maxzBuffer, co1.zw, floor(lod)).r;
+ float depth3 = textureLod(maxzBuffer, co2.xy, floor(lod)).r;
+ float depth4 = textureLod(maxzBuffer, co2.zw, floor(lod)).r;
- search_step(t_phi, x, x_, rand, pixel_ratio, j, ofs, h1, h2);
- if (ofs > max_dist) return;
+ vec4 len, s_h;
- search_step(t_phi, x, x_, rand, pixel_ratio, j, ofs, h1, h2);
- if (ofs > max_dist) return;
+ vec3 s1 = get_view_space_from_depth(co1.xy, depth1); /* s View coordinate */
+ vec3 omega_s1 = s1 - x;
+ len.x = length(omega_s1);
+ s_h.x = omega_s1.z / len.x;
- search_step(t_phi, x, x_, rand, pixel_ratio, j, ofs, h1, h2);
- if (ofs > max_dist) return;
+ vec3 s2 = get_view_space_from_depth(co1.zw, depth2); /* s View coordinate */
+ vec3 omega_s2 = s2 - x;
+ len.y = length(omega_s2);
+ s_h.y = omega_s2.z / len.y;
- search_step(t_phi, x, x_, rand, pixel_ratio, j, ofs, h1, h2);
- if (ofs > max_dist) return;
+ vec3 s3 = get_view_space_from_depth(co2.xy, depth3); /* s View coordinate */
+ vec3 omega_s3 = s3 - x;
+ len.z = length(omega_s3);
+ s_h.z = omega_s3.z / len.z;
- search_step(t_phi, x, x_, rand, pixel_ratio, j, ofs, h1, h2);
- if (ofs > max_dist) return;
+ vec3 s4 = get_view_space_from_depth(co2.zw, depth4); /* s View coordinate */
+ vec3 omega_s4 = s4 - x;
+ len.w = length(omega_s4);
+ s_h.w = omega_s4.z / len.w;
- search_step(t_phi, x, x_, rand, pixel_ratio, j, ofs, h1, h2);
+ /* Blend weight after half the aoDistance to fade artifacts */
+ vec4 blend = saturate((1.0 - len / aoDistance) * 2.0);
+
+ h = mix(h, max(h, s_h.x), blend.x);
+ h = mix(h, max(h, s_h.y), blend.y);
+ h = mix(h, max(h, s_h.z), blend.z);
+ h = mix(h, max(h, s_h.w), blend.w);
}
-void integrate_slice(
- float iter, vec3 x, vec3 normal, vec2 x_, vec2 noise,
- float max_dist, vec2 pixel_ratio, float pixel_len,
- inout float visibility, inout vec3 bent_normal)
+vec2 search_horizon_sweep(float phi, vec3 pos, vec2 uvs, float jitter, vec2 max_dir)
{
- float phi = M_PI * ((noise.r + iter) / aoSamples);
-
- /* Rotate with random direction to get jittered result. */
vec2 t_phi = vec2(cos(phi), sin(phi)); /* Screen space direction */
- /* Search maximum horizon angles h1 and h2 */
- float h1 = -1.0, h2 = -1.0; /* init at cos(pi) */
- search_horizon(t_phi, x, x_, noise.g, max_dist, pixel_ratio, pixel_len, h1, h2);
+ max_dir *= max_v2(abs(t_phi));
- /* (Slide 54) */
- h1 = -fast_acos(h1);
- h2 = fast_acos(h2);
+ /* Convert to pixel space. */
+ t_phi /= vec2(textureSize(maxzBuffer, 0));
+
+ /* Avoid division by 0 */
+ t_phi += vec2(1e-5);
+
+ jitter *= 0.25;
+
+ /* Compute end points */
+ vec2 corner1 = min(vec2(1.0) - uvs, max_dir); /* Top right */
+ vec2 corner2 = max(vec2(0.0) - uvs, -max_dir); /* Bottom left */
+ vec2 iter1 = corner1 / t_phi;
+ vec2 iter2 = corner2 / t_phi;
+
+ vec2 min_iter = max(-iter1, -iter2);
+ vec2 max_iter = max( iter1, iter2);
+
+ vec2 times = vec2(-min_v2(min_iter), min_v2(max_iter));
+
+ vec2 h = vec2(-1.0); /* init at cos(pi) */
+
+ /* This is freaking sexy optimized. */
+ for (float i = 0.0, ofs = 4.0, time = -1.0;
+ i < MAX_SEARCH_ITER && time > times.x;
+ i++, time -= ofs, ofs = min(exp2(MAX_LOD) * 4.0, ofs + ofs * aoQuality))
+ {
+ vec4 t = max(times.xxxx, vec4(time) - (vec4(0.25, 0.5, 0.75, 1.0) - jitter) * ofs);
+ vec4 cos1 = uvs.xyxy + t_phi.xyxy * t.xxyy;
+ vec4 cos2 = uvs.xyxy + t_phi.xyxy * t.zzww;
+ float lod = min(MAX_LOD, max(i - jitter * 4.0, 0.0) * aoQuality);
+ get_max_horizon_grouped(cos1, cos2, pos, lod, h.y);
+ }
+
+ for (float i = 0.0, ofs = 4.0, time = 1.0;
+ i < MAX_SEARCH_ITER && time < times.y;
+ i++, time += ofs, ofs = min(exp2(MAX_LOD) * 4.0, ofs + ofs * aoQuality))
+ {
+ vec4 t = min(times.yyyy, vec4(time) + (vec4(0.25, 0.5, 0.75, 1.0) - jitter) * ofs);
+ vec4 cos1 = uvs.xyxy + t_phi.xyxy * t.xxyy;
+ vec4 cos2 = uvs.xyxy + t_phi.xyxy * t.zzww;
+ float lod = min(MAX_LOD, max(i - jitter * 4.0, 0.0) * aoQuality);
+ get_max_horizon_grouped(cos1, cos2, pos, lod, h.x);
+ }
+
+ return h;
+}
+
+void integrate_slice(vec3 normal, float phi, vec2 horizons, inout float visibility, inout vec3 bent_normal)
+{
+ /* TODO OPTI Could be precomputed. */
+ vec2 t_phi = vec2(cos(phi), sin(phi)); /* Screen space direction */
/* Projecting Normal to Plane P defined by t_phi and omega_o */
- vec3 h = vec3(t_phi.y, -t_phi.x, 0.0); /* Normal vector to Integration plane */
+ vec3 np = vec3(t_phi.y, -t_phi.x, 0.0); /* Normal vector to Integration plane */
vec3 t = vec3(-t_phi, 0.0);
- vec3 n_proj = normal - h * dot(h, normal);
+ vec3 n_proj = normal - np * dot(np, normal);
float n_proj_len = max(1e-16, length(n_proj));
- /* Clamping thetas (slide 58) */
float cos_n = clamp(n_proj.z / n_proj_len, -1.0, 1.0);
float n = sign(dot(n_proj, t)) * fast_acos(cos_n); /* Angle between view vec and normal */
- h1 = n + max(h1 - n, -M_PI_2);
- h2 = n + min(h2 - n, M_PI_2);
+
+ /* (Slide 54) */
+ vec2 h = fast_acos(horizons);
+ h.x = -h.x;
+
+ /* Clamping thetas (slide 58) */
+ h.x = n + max(h.x - n, -M_PI_2);
+ h.y = n + min(h.y - n, M_PI_2);
/* Solving inner integral */
- float sin_n = sin(n);
- float h1_2 = 2.0 * h1;
- float h2_2 = 2.0 * h2;
- float vd = (-cos(h1_2 - n) + cos_n + h1_2 * sin_n) + (-cos(h2_2 - n) + cos_n + h2_2 * sin_n);
- vd *= 0.25 * n_proj_len;
- visibility += vd;
-
-#ifdef USE_BENT_NORMAL
+ vec2 h_2 = 2.0 * h;
+ vec2 vd = -cos(h_2 - n) + cos_n + h_2 * sin(n);
+ float vis = (vd.x + vd.y) * 0.25 * n_proj_len;
+
+ visibility += vis;
+
/* Finding Bent normal */
- float b_angle = (h1 + h2) / 2.0;
+ float b_angle = (h.x + h.y) * 0.5;
/* The 0.5 factor below is here to equilibrate the accumulated vectors.
* (sin(b_angle) * -t_phi) will accumulate to (phi_step * result_nor.xy * 0.5).
* (cos(b_angle) * 0.5) will accumulate to (phi_step * result_nor.z * 0.5). */
- /* Weight sample by vd */
- bent_normal += vec3(sin(b_angle) * -t_phi, cos(b_angle) * 0.5) * vd;
-#endif
+ bent_normal += vec3(sin(b_angle) * -t_phi, cos(b_angle) * 0.5);
}
-void gtao(vec3 normal, vec3 position, vec2 noise, out float visibility
-#ifdef USE_BENT_NORMAL
- , out vec3 bent_normal
-#endif
- )
+void denoise_ao(vec3 normal, float frag_depth, inout float visibility, inout vec3 bent_normal)
+{
+ vec2 d_sign = vec2(ivec2(gl_FragCoord.xy) & 1) - 0.5;
+
+ if ((int(aoSettings) & USE_DENOISE) == 0) {
+ d_sign *= 0.0;
+ }
+
+ /* 2x2 Bilateral Filter using derivatives. */
+ vec2 n_step = step(-0.2, -abs(vec2(length(dFdx(normal)), length(dFdy(normal)))));
+ vec2 z_step = step(-0.1, -abs(vec2(dFdx(frag_depth), dFdy(frag_depth))));
+
+ visibility -= dFdx(visibility) * d_sign.x * z_step.x * n_step.x;
+ visibility -= dFdy(visibility) * d_sign.y * z_step.y * n_step.y;
+
+ bent_normal -= dFdx(bent_normal) * d_sign.x * z_step.x * n_step.x;
+ bent_normal -= dFdy(bent_normal) * d_sign.y * z_step.y * n_step.y;
+}
+
+void gtao_deferred(vec3 normal, vec3 position, float frag_depth, out float visibility, out vec3 bent_normal)
{
- vec2 screenres = vec2(textureSize(minMaxDepthTex, 0)) * 2.0;
- vec2 pixel_size = vec2(1.0) / screenres.xy;
+ vec2 uvs = get_uvs_from_view(position);
+
+ vec4 texel_size = vec4(-1.0, -1.0, 1.0, 1.0) / vec2(textureSize(depthBuffer, 0)).xyxy;
- /* Renaming */
- vec2 x_ = gl_FragCoord.xy * pixel_size; /* x^ Screen coordinate */
- vec3 x = position; /* x view space coordinate */
+ ivec2 fs_co = ivec2(gl_FragCoord.xy);
+ ivec2 hr_co = get_hr_co(fs_co);
- /* NOTE : We set up integration domain around the camera forward axis
- * and not the view vector like in the paper.
- * This allows us to save a lot of dot products. */
- /* omega_o = vec3(0.0, 0.0, 1.0); */
+ bent_normal = vec3(0.0);
+ visibility = 0.0;
+
+ for (float i = 0.0; i < MAX_PHI_STEP; i++) {
+ if (i >= aoSamples) break;
+
+ vec2 horiz = unpack_horizons(texelFetch(horizonBuffer, ivec3(hr_co, int(i)), 0).rg);
+ float phi = get_phi(hr_co, fs_co, i);
+
+ integrate_slice(normal, phi, horiz.xy, visibility, bent_normal);
+ }
+
+ visibility *= aoInvSamples;
+ bent_normal = normalize(bent_normal);
+}
+
+void gtao(vec3 normal, vec3 position, vec2 noise, out float visibility, out vec3 bent_normal)
+{
+ vec2 uvs = get_uvs_from_view(position);
- vec2 pixel_ratio = vec2(screenres.y / screenres.x, 1.0);
- float pixel_len = length(pixel_size);
float homcco = ProjectionMatrix[2][3] * position.z + ProjectionMatrix[3][3];
float max_dist = aoDistance / homcco; /* Search distance */
+ vec2 max_dir = max_dist * vec2(ProjectionMatrix[0][0], ProjectionMatrix[1][1]);
- /* Integral over PI */
- visibility = 0.0;
-#ifdef USE_BENT_NORMAL
bent_normal = vec3(0.0);
-#else
- vec3 bent_normal = vec3(0.0);
-#endif
+ visibility = 0.0;
+
for (float i = 0.0; i < MAX_PHI_STEP; i++) {
if (i >= aoSamples) break;
- integrate_slice(i, x, normal, x_, noise, max_dist, pixel_ratio, pixel_len, visibility, bent_normal);
- }
- visibility = clamp(visibility / aoSamples, 1e-8, 1.0);
+ float phi = M_PI * (i + noise.x) * aoInvSamples;
+ vec2 horizons = search_horizon_sweep(phi, position, uvs, noise.g, max_dir);
-#ifdef USE_BENT_NORMAL
- /* The bent normal will show the facet look of the mesh. Try to minimize this. */
- bent_normal = normalize(mix(bent_normal / visibility, normal, visibility * visibility * visibility));
-#endif
+ integrate_slice(normal, phi, horizons, visibility, bent_normal);
+ }
- /* Scale by user factor */
- visibility = pow(visibility, aoFactor);
+ visibility *= aoInvSamples;
+ bent_normal = normalize(bent_normal);
}
/* Multibounce approximation base on surface albedo.
* Page 78 in the .pdf version. */
float gtao_multibounce(float visibility, vec3 albedo)
{
+ if (aoBounceFac == 0.0) return visibility;
+
/* Median luminance. Because Colored multibounce looks bad. */
- float lum = albedo.x * 0.3333;
- lum += albedo.y * 0.3333;
- lum += albedo.z * 0.3333;
+ float lum = dot(albedo, vec3(0.3333));
float a = 2.0404 * lum - 0.3324;
float b = -4.7951 * lum + 0.6417;
@@ -213,4 +334,43 @@ float gtao_multibounce(float visibility, vec3 albedo)
float x = visibility;
return max(x, ((x * a + b) * x + c) * x);
-} \ No newline at end of file
+}
+
+/* Use the right occlusion */
+float occlusion_compute(vec3 N, vec3 vpos, float user_occlusion, vec2 randuv, out vec3 bent_normal)
+{
+ if ((int(aoSettings) & USE_AO) == 0) {
+ bent_normal = N;
+ return user_occlusion;
+ }
+ else {
+ float visibility;
+ vec3 vnor = mat3(ViewMatrix) * N;
+
+#ifdef ENABLE_DEFERED_AO
+ gtao_deferred(vnor, vpos, gl_FragCoord.z, visibility, bent_normal);
+#else
+ gtao(vnor, vpos, randuv, visibility, bent_normal);
+#endif
+ denoise_ao(vnor, gl_FragCoord.z, visibility, bent_normal);
+
+ /* Prevent some problems down the road. */
+ visibility = max(1e-3, visibility);
+
+ if ((int(aoSettings) & USE_BENT_NORMAL) != 0) {
+ /* The bent normal will show the facet look of the mesh. Try to minimize this. */
+ float mix_fac = visibility * visibility;
+ bent_normal = normalize(mix(bent_normal, vnor, mix_fac));
+
+ bent_normal = transform_direction(ViewMatrixInverse, bent_normal);
+ }
+ else {
+ bent_normal = N;
+ }
+
+ /* Scale by user factor */
+ visibility = pow(visibility, aoFactor);
+
+ return min(visibility, user_occlusion);
+ }
+}
diff --git a/source/blender/draw/engines/eevee/shaders/background_vert.glsl b/source/blender/draw/engines/eevee/shaders/background_vert.glsl
index 9b43d563d7c..b81aae9bcda 100644
--- a/source/blender/draw/engines/eevee/shaders/background_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/background_vert.glsl
@@ -5,9 +5,12 @@ out vec3 varposition;
out vec3 varnormal;
out vec3 viewPosition;
+#ifndef VOLUMETRICS
/* necessary for compilation*/
out vec3 worldPosition;
out vec3 worldNormal;
+out vec3 viewNormal;
+#endif
void main()
{
diff --git a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
index 2aa51039e71..3e0e36cad24 100644
--- a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
@@ -1,5 +1,6 @@
#define M_PI 3.14159265358979323846 /* pi */
+#define M_2PI 6.28318530717958647692 /* 2*pi */
#define M_PI_2 1.57079632679489661923 /* pi/2 */
#define M_1_PI 0.318309886183790671538 /* 1/pi */
#define M_1_2PI 0.159154943091895335768 /* 1/(2*pi) */
@@ -8,62 +9,45 @@
#define LUT_SIZE 64
uniform mat4 ProjectionMatrix;
+uniform mat4 ViewProjectionMatrix;
+uniform mat4 ViewMatrixInverse;
uniform vec4 viewvecs[2];
+#ifndef SHADOW_SHADER
+uniform mat4 ViewMatrix;
+#else
+layout(std140) uniform shadow_render_block {
+ mat4 ShadowMatrix[6];
+ mat4 FaceViewMatrix[6];
+ vec4 lampPosition;
+ float cubeTexelSize;
+ float storedTexelSize;
+ float nearClip;
+ float farClip;
+ int shadowSampleCount;
+ float shadowInvSampleCount;
+};
-/* ------- Structures -------- */
+flat in int shFace; /* Shadow layer we are rendering to. */
+#define ViewMatrix FaceViewMatrix[shFace]
+#endif
-struct ProbeData {
- vec4 position_type;
- vec4 attenuation_fac_type;
- mat4 influencemat;
- mat4 parallaxmat;
-};
+uniform vec2 mipRatio[10];
-#define PROBE_PARALLAX_BOX 1.0
-#define PROBE_ATTENUATION_BOX 1.0
-
-#define p_position position_type.xyz
-#define p_parallax_type position_type.w
-#define p_atten_fac attenuation_fac_type.x
-#define p_atten_type attenuation_fac_type.y
-
-struct PlanarData {
- vec4 plane_equation;
- vec4 clip_vec_x_fade_scale;
- vec4 clip_vec_y_fade_bias;
- vec4 clip_edges;
- vec4 facing_scale_bias;
- mat4 reflectionmat; /* transform world space into reflection texture space */
-};
+/* Buffers */
+uniform sampler2D colorBuffer;
+uniform sampler2D depthBuffer;
+uniform sampler2D maxzBuffer;
+uniform sampler2D minzBuffer;
+uniform sampler2DArray planarDepth;
-#define pl_plane_eq plane_equation
-#define pl_normal plane_equation.xyz
-#define pl_facing_scale facing_scale_bias.x
-#define pl_facing_bias facing_scale_bias.y
-#define pl_fade_scale clip_vec_x_fade_scale.w
-#define pl_fade_bias clip_vec_y_fade_bias.w
-#define pl_clip_pos_x clip_vec_x_fade_scale.xyz
-#define pl_clip_pos_y clip_vec_y_fade_bias.xyz
-#define pl_clip_edges clip_edges
-
-struct GridData {
- mat4 localmat;
- ivec4 resolution_offset;
- vec4 ws_corner_atten_scale; /* world space corner position */
- vec4 ws_increment_x_atten_bias; /* world space vector between 2 opposite cells */
- vec4 ws_increment_y;
- vec4 ws_increment_z;
-};
+#define cameraForward normalize(ViewMatrixInverse[2].xyz)
+#define cameraPos ViewMatrixInverse[3].xyz
+#define cameraVec ((ProjectionMatrix[3][3] == 0.0) ? normalize(cameraPos - worldPosition) : cameraForward)
+#define viewCameraVec ((ProjectionMatrix[3][3] == 0.0) ? normalize(-viewPosition) : vec3(0.0, 0.0, 1.0))
-#define g_corner ws_corner_atten_scale.xyz
-#define g_atten_scale ws_corner_atten_scale.w
-#define g_atten_bias ws_increment_x_atten_bias.w
-#define g_increment_x ws_increment_x_atten_bias.xyz
-#define g_increment_y ws_increment_y.xyz
-#define g_increment_z ws_increment_z.xyz
-#define g_resolution resolution_offset.xyz
-#define g_offset resolution_offset.w
+/* ------- Structures -------- */
+/* ------ Lights ----- */
struct LightData {
vec4 position_influence; /* w : InfluenceRadius */
vec4 color_spec; /* w : Spec Intensity */
@@ -89,52 +73,56 @@ struct LightData {
#define l_radius spotdata_radius_shadow.z
#define l_shadowid spotdata_radius_shadow.w
+/* ------ Shadows ----- */
+#ifndef MAX_CASCADE_NUM
+#define MAX_CASCADE_NUM 4
+#endif
-struct ShadowCubeData {
+struct ShadowData {
vec4 near_far_bias_exp;
+ vec4 shadow_data_start_end;
+ vec4 contact_shadow_data;
};
-/* convenience aliases */
-#define sh_cube_near near_far_bias_exp.x
-#define sh_cube_far near_far_bias_exp.y
-#define sh_cube_bias near_far_bias_exp.z
-#define sh_cube_exp near_far_bias_exp.w
-
-
-struct ShadowMapData {
- mat4 shadowmat;
- vec4 near_far_bias;
+struct ShadowCubeData {
+ vec4 position;
};
-/* convenience aliases */
-#define sh_map_near near_far_bias.x
-#define sh_map_far near_far_bias.y
-#define sh_map_bias near_far_bias.z
-
-#ifndef MAX_CASCADE_NUM
-#define MAX_CASCADE_NUM 4
-#endif
-
struct ShadowCascadeData {
mat4 shadowmat[MAX_CASCADE_NUM];
- /* arrays of float are not aligned so use vec4 */
- vec4 split_distances;
- vec4 bias;
+ vec4 split_start_distances;
+ vec4 split_end_distances;
};
-struct ShadingData {
- vec3 V; /* View vector */
- vec3 N; /* World Normal of the fragment */
- vec3 W; /* World Position of the fragment */
- vec3 l_vector; /* Current Light vector */
-};
+/* convenience aliases */
+#define sh_near near_far_bias_exp.x
+#define sh_far near_far_bias_exp.y
+#define sh_bias near_far_bias_exp.z
+#define sh_exp near_far_bias_exp.w
+#define sh_bleed near_far_bias_exp.w
+#define sh_tex_start shadow_data_start_end.x
+#define sh_data_start shadow_data_start_end.y
+#define sh_multi_nbr shadow_data_start_end.z
+#define sh_contact_dist contact_shadow_data.x
+#define sh_contact_offset contact_shadow_data.y
+#define sh_contact_spread contact_shadow_data.z
+#define sh_contact_thickness contact_shadow_data.w
/* ------- Convenience functions --------- */
vec3 mul(mat3 m, vec3 v) { return m * v; }
mat3 mul(mat3 m1, mat3 m2) { return m1 * m2; }
+vec3 transform_direction(mat4 m, vec3 v) { return mat3(m) * v; }
+vec3 transform_point(mat4 m, vec3 v) { return (m * vec4(v, 1.0)).xyz; }
+vec3 project_point(mat4 m, vec3 v) {
+ vec4 tmp = m * vec4(v, 1.0);
+ return tmp.xyz / tmp.w;
+}
+float min_v2(vec2 v) { return min(v.x, v.y); }
float min_v3(vec3 v) { return min(v.x, min(v.y, v.z)); }
+float max_v2(vec2 v) { return max(v.x, v.y); }
+float max_v3(vec3 v) { return max(v.x, max(v.y, v.z)); }
float saturate(float a) { return clamp(a, 0.0, 1.0); }
vec2 saturate(vec2 a) { return clamp(a, 0.0, 1.0); }
@@ -147,20 +135,43 @@ float len_squared(vec3 a) { return dot(a, a); }
float inverse_distance(vec3 V) { return max( 1 / length(V), 1e-8); }
+vec2 mip_ratio_interp(float mip) {
+ float low_mip = floor(mip);
+ return mix(mipRatio[int(low_mip)], mipRatio[int(low_mip + 1.0)], mip - low_mip);
+}
/* ------- Fast Math ------- */
/* [Drobot2014a] Low Level Optimizations for GCN */
-float fast_sqrt(float x)
+float fast_sqrt(float v)
{
- return intBitsToFloat(0x1fbd1df5 + (floatBitsToInt(x) >> 1));
+ return intBitsToFloat(0x1fbd1df5 + (floatBitsToInt(v) >> 1));
+}
+
+vec2 fast_sqrt(vec2 v)
+{
+ return intBitsToFloat(0x1fbd1df5 + (floatBitsToInt(v) >> 1));
}
/* [Eberly2014] GPGPU Programming for Games and Science */
-float fast_acos(float x)
+float fast_acos(float v)
+{
+ float res = -0.156583 * abs(v) + M_PI_2;
+ res *= fast_sqrt(1.0 - abs(v));
+ return (v >= 0) ? res : M_PI - res;
+}
+
+vec2 fast_acos(vec2 v)
{
- float res = -0.156583 * abs(x) + M_PI_2;
- res *= fast_sqrt(1.0 - abs(x));
- return (x >= 0) ? res : M_PI - res;
+ vec2 res = -0.156583 * abs(v) + M_PI_2;
+ res *= fast_sqrt(1.0 - abs(v));
+ v.x = (v.x >= 0) ? res.x : M_PI - res.x;
+ v.y = (v.y >= 0) ? res.y : M_PI - res.y;
+ return v;
+}
+
+float point_plane_projection_dist(vec3 lineorigin, vec3 planeorigin, vec3 planenormal)
+{
+ return dot(planenormal, planeorigin - lineorigin);
}
float line_plane_intersect_dist(vec3 lineorigin, vec3 linedirection, vec3 planeorigin, vec3 planenormal)
@@ -181,6 +192,12 @@ vec3 line_plane_intersect(vec3 lineorigin, vec3 linedirection, vec3 planeorigin,
return lineorigin + linedirection * dist;
}
+vec3 line_plane_intersect(vec3 lineorigin, vec3 linedirection, vec4 plane)
+{
+ float dist = line_plane_intersect_dist(lineorigin, linedirection, plane);
+ return lineorigin + linedirection * dist;
+}
+
float line_aligned_plane_intersect_dist(vec3 lineorigin, vec3 linedirection, vec3 planeorigin)
{
/* aligned plane normal */
@@ -275,20 +292,41 @@ float buffer_depth(bool is_persp, float z, float zf, float zn)
}
}
-vec3 get_view_space_from_depth(vec2 uvcoords, float depth)
+float get_view_z_from_depth(float depth)
{
if (ProjectionMatrix[3][3] == 0.0) {
float d = 2.0 * depth - 1.0;
- float zview = -ProjectionMatrix[3][2] / (d + ProjectionMatrix[2][2]);
- return (viewvecs[0].xyz + vec3(uvcoords, 0.0) * viewvecs[1].xyz) * zview;
+ return -ProjectionMatrix[3][2] / (d + ProjectionMatrix[2][2]);
+ }
+ else {
+ return viewvecs[0].z + depth * viewvecs[1].z;
+ }
+}
+
+vec2 get_uvs_from_view(vec3 view)
+{
+ vec3 ndc = project_point(ProjectionMatrix, view);
+ return ndc.xy * 0.5 + 0.5;
+}
+
+vec3 get_view_space_from_depth(vec2 uvcoords, float depth)
+{
+ if (ProjectionMatrix[3][3] == 0.0) {
+ return (viewvecs[0].xyz + vec3(uvcoords, 0.0) * viewvecs[1].xyz) * get_view_z_from_depth(depth);
}
else {
return viewvecs[0].xyz + vec3(uvcoords, depth) * viewvecs[1].xyz;
}
}
-vec3 get_specular_dominant_dir(vec3 N, vec3 R, float roughness)
+vec3 get_world_space_from_depth(vec2 uvcoords, float depth)
+{
+ return (ViewMatrixInverse * vec4(get_view_space_from_depth(uvcoords, depth), 1.0)).xyz;
+}
+
+vec3 get_specular_reflection_dominant_dir(vec3 N, vec3 V, float roughness)
{
+ vec3 R = -reflect(V, N);
float smoothness = 1.0 - roughness;
float fac = smoothness * (sqrt(smoothness) + roughness);
return normalize(mix(N, R, fac));
@@ -299,14 +337,125 @@ float specular_occlusion(float NV, float AO, float roughness)
return saturate(pow(NV + AO, roughness) - 1.0 + AO);
}
+/* --- Refraction utils --- */
+
+float ior_from_f0(float f0)
+{
+ float f = sqrt(f0);
+ return (-f - 1.0) / (f - 1.0);
+}
+
+float f0_from_ior(float eta)
+{
+ float A = (eta - 1.0) / (eta + 1.0);
+ return A * A;
+}
+
+vec3 get_specular_refraction_dominant_dir(vec3 N, vec3 V, float roughness, float ior)
+{
+ /* TODO: This a bad approximation. Better approximation should fit
+ * the refracted vector and roughness into the best prefiltered reflection
+ * lobe. */
+ /* Correct the IOR for ior < 1.0 to not see the abrupt delimitation or the TIR */
+ ior = (ior < 1.0) ? mix(ior, 1.0, roughness) : ior;
+ float eta = 1.0 / ior;
+
+ float NV = dot(N, -V);
+
+ /* Custom Refraction. */
+ float k = 1.0 - eta * eta * (1.0 - NV * NV);
+ k = max(0.0, k); /* Only this changes. */
+ vec3 R = eta * -V - (eta * NV + sqrt(k)) * N;
+
+ return R;
+}
+
+float get_btdf_lut(sampler2DArray btdf_lut_tex, float NV, float roughness, float ior)
+{
+ const vec3 lut_scale_bias_texel_size = vec3((LUT_SIZE - 1.0), 0.5, 1.5) / LUT_SIZE;
+
+ vec3 coords;
+ /* Try to compensate for the low resolution and interpolation error. */
+ coords.x = (ior > 1.0)
+ ? (0.9 + lut_scale_bias_texel_size.z) + (0.1 - lut_scale_bias_texel_size.z) * f0_from_ior(ior)
+ : (0.9 + lut_scale_bias_texel_size.z) * ior * ior;
+ coords.y = 1.0 - saturate(NV);
+ coords.xy *= lut_scale_bias_texel_size.x;
+ coords.xy += lut_scale_bias_texel_size.y;
+
+ const float lut_lvl_ofs = 4.0; /* First texture lvl of roughness. */
+ const float lut_lvl_scale = 16.0; /* How many lvl of roughness in the lut. */
+
+ float mip = roughness * lut_lvl_scale;
+ float mip_floor = floor(mip);
+
+ coords.z = lut_lvl_ofs + mip_floor + 1.0;
+ float btdf_high = textureLod(btdf_lut_tex, coords, 0.0).r;
+
+ coords.z -= 1.0;
+ float btdf_low = textureLod(btdf_lut_tex, coords, 0.0).r;
+
+ float btdf = (ior == 1.0) ? 1.0 : mix(btdf_low, btdf_high, mip - coords.z);
+
+ return btdf;
+}
+
+/* ---- Encode / Decode Normal buffer data ---- */
+/* From http://aras-p.info/texts/CompactNormalStorage.html
+ * Using Method #4: Spheremap Transform */
+vec2 normal_encode(vec3 n, vec3 view)
+{
+ float p = sqrt(n.z * 8.0 + 8.0);
+ return n.xy / p + 0.5;
+}
+
+vec3 normal_decode(vec2 enc, vec3 view)
+{
+ vec2 fenc = enc * 4.0 - 2.0;
+ float f = dot(fenc, fenc);
+ float g = sqrt(1.0 - f / 4.0);
+ vec3 n;
+ n.xy = fenc*g;
+ n.z = 1 - f / 2;
+ return n;
+}
+
+/* Fresnel monochromatic, perfect mirror */
+float F_eta(float eta, float cos_theta)
+{
+ /* compute fresnel reflectance without explicitly computing
+ * the refracted direction */
+ float c = abs(cos_theta);
+ float g = eta * eta - 1.0 + c * c;
+ float result;
+
+ if (g > 0.0) {
+ g = sqrt(g);
+ vec2 g_c = vec2(g) + vec2(c, -c);
+ float A = g_c.y / g_c.x;
+ A *= A;
+ g_c *= c;
+ float B = (g_c.y - 1.0) / (g_c.x + 1.0);
+ B *= B;
+ result = 0.5 * A * (1.0 + B);
+ }
+ else {
+ result = 1.0; /* TIR (no refracted component) */
+ }
+
+ return result;
+}
+
/* Fresnel */
vec3 F_schlick(vec3 f0, float cos_theta)
{
- float fac = pow(1.0 - cos_theta, 5);
+ float fac = 1.0 - cos_theta;
+ float fac2 = fac * fac;
+ fac = fac2 * fac2 * fac;
/* Unreal specular matching : if specular color is below 2% intensity,
* (using green channel for intensity) treat as shadowning */
- return saturate(50.0 * f0.g) * fac + (1.0 - fac) * f0;
+ return saturate(50.0 * dot(f0, vec3(0.3, 0.6, 0.1))) * fac + (1.0 - fac) * f0;
}
/* Fresnel approximation for LTC area lights (not MRP) */
@@ -315,16 +464,16 @@ vec3 F_area(vec3 f0, vec2 lut)
vec2 fac = normalize(lut.xy);
/* Unreal specular matching : if specular color is below 2% intensity,
- * (using green channel for intensity) treat as shadowning */
- return saturate(50.0 * f0.g) * fac.y + fac.x * f0;
+ * treat as shadowning */
+ return saturate(50.0 * dot(f0, vec3(0.3, 0.6, 0.1))) * fac.y + fac.x * f0;
}
-/* Fresnel approximation for LTC area lights (not MRP) */
+/* Fresnel approximation for IBL */
vec3 F_ibl(vec3 f0, vec2 lut)
{
/* Unreal specular matching : if specular color is below 2% intensity,
- * (using green channel for intensity) treat as shadowning */
- return saturate(50.0 * f0.g) * lut.y + lut.x * f0;
+ * treat as shadowning */
+ return saturate(50.0 * dot(f0, vec3(0.3, 0.6, 0.1))) * lut.y + lut.x * f0;
}
/* GGX */
@@ -361,3 +510,140 @@ float bsdf_ggx(vec3 N, vec3 L, vec3 V, float roughness)
/* bsdf = D * G / (4.0 * NL * NV); /* Reference function */
return NL * a2 / (D * G); /* NL to Fit cycles Equation : line. 345 in bsdf_microfacet.h */
}
+
+void accumulate_light(vec3 light, float fac, inout vec4 accum)
+{
+ accum += vec4(light, 1.0) * min(fac, (1.0 - accum.a));
+}
+
+/* ----------- Cone Apperture Approximation --------- */
+
+/* Return a fitted cone angle given the input roughness */
+float cone_cosine(float r)
+{
+ /* Using phong gloss
+ * roughness = sqrt(2/(gloss+2)) */
+ float gloss = -2 + 2 / (r * r);
+ /* Drobot 2014 in GPUPro5 */
+ // return cos(2.0 * sqrt(2.0 / (gloss + 2)));
+ /* Uludag 2014 in GPUPro5 */
+ // return pow(0.244, 1 / (gloss + 1));
+ /* Jimenez 2016 in Practical Realtime Strategies for Accurate Indirect Occlusion*/
+ return exp2(-3.32193 * r * r);
+}
+
+/* --------- Closure ---------- */
+#ifdef VOLUMETRICS
+
+struct Closure {
+ vec3 absorption;
+ vec3 scatter;
+ vec3 emission;
+ float anisotropy;
+};
+
+#define CLOSURE_DEFAULT Closure(vec3(0.0), vec3(0.0), vec3(0.0), 0.0)
+
+Closure closure_mix(Closure cl1, Closure cl2, float fac)
+{
+ Closure cl;
+ cl.absorption = mix(cl1.absorption, cl2.absorption, fac);
+ cl.scatter = mix(cl1.scatter, cl2.scatter, fac);
+ cl.emission = mix(cl1.emission, cl2.emission, fac);
+ cl.anisotropy = mix(cl1.anisotropy, cl2.anisotropy, fac);
+ return cl;
+}
+
+Closure closure_add(Closure cl1, Closure cl2)
+{
+ Closure cl;
+ cl.absorption = cl1.absorption + cl2.absorption;
+ cl.scatter = cl1.scatter + cl2.scatter;
+ cl.emission = cl1.emission + cl2.emission;
+ cl.anisotropy = (cl1.anisotropy + cl2.anisotropy) / 2.0; /* Average phase (no multi lobe) */
+ return cl;
+}
+#else
+
+struct Closure {
+ vec3 radiance;
+ float opacity;
+ vec4 ssr_data;
+ vec2 ssr_normal;
+ int ssr_id;
+};
+
+/* This is hacking ssr_id to tag transparent bsdf */
+#define TRANSPARENT_CLOSURE_FLAG -2
+#define REFRACT_CLOSURE_FLAG -3
+
+#define CLOSURE_DEFAULT Closure(vec3(0.0), 1.0, vec4(0.0), vec2(0.0), -1)
+
+uniform int outputSsrId;
+
+Closure closure_mix(Closure cl1, Closure cl2, float fac)
+{
+ Closure cl;
+ if (cl1.ssr_id == outputSsrId) {
+ cl.ssr_data = mix(cl1.ssr_data.xyzw, vec4(vec3(0.0), cl1.ssr_data.w), fac); /* do not blend roughness */
+ cl.ssr_normal = cl1.ssr_normal;
+ cl.ssr_id = cl1.ssr_id;
+ }
+ else {
+ cl.ssr_data = mix(vec4(vec3(0.0), cl2.ssr_data.w), cl2.ssr_data.xyzw, fac); /* do not blend roughness */
+ cl.ssr_normal = cl2.ssr_normal;
+ cl.ssr_id = cl2.ssr_id;
+ }
+ if (cl1.ssr_id == TRANSPARENT_CLOSURE_FLAG) {
+ cl1.radiance = cl2.radiance;
+ }
+ if (cl2.ssr_id == TRANSPARENT_CLOSURE_FLAG) {
+ cl2.radiance = cl1.radiance;
+ }
+ cl.radiance = mix(cl1.radiance, cl2.radiance, fac);
+ cl.opacity = mix(cl1.opacity, cl2.opacity, fac);
+ return cl;
+}
+
+Closure closure_add(Closure cl1, Closure cl2)
+{
+ Closure cl = (cl1.ssr_id == outputSsrId) ? cl1 : cl2;
+ cl.radiance = cl1.radiance + cl2.radiance;
+ cl.opacity = cl1.opacity + cl2.opacity;
+ return cl;
+}
+
+#if defined(MESH_SHADER) && !defined(USE_ALPHA_HASH) && !defined(USE_ALPHA_CLIP) && !defined(SHADOW_SHADER) && !defined(USE_MULTIPLY)
+layout(location = 0) out vec4 fragColor;
+layout(location = 1) out vec4 ssrNormals;
+layout(location = 2) out vec4 ssrData;
+
+Closure nodetree_exec(void); /* Prototype */
+
+#define NODETREE_EXEC
+void main()
+{
+ Closure cl = nodetree_exec();
+ fragColor = vec4(cl.radiance, cl.opacity);
+ ssrNormals = cl.ssr_normal.xyyy;
+ ssrData = cl.ssr_data;
+}
+
+#endif /* MESH_SHADER && !SHADOW_SHADER */
+
+#endif /* VOLUMETRICS */
+
+Closure nodetree_exec(void); /* Prototype */
+
+/* TODO find a better place */
+#ifdef USE_MULTIPLY
+
+out vec4 fragColor;
+
+#define NODETREE_EXEC
+void main()
+{
+ Closure cl = nodetree_exec();
+ fragColor = vec4(mix(vec3(1.0), cl.radiance, cl.opacity), 1.0);
+}
+#endif \ No newline at end of file
diff --git a/source/blender/draw/engines/eevee/shaders/bsdf_direct_lib.glsl b/source/blender/draw/engines/eevee/shaders/bsdf_direct_lib.glsl
index a1a5fab03af..d0a365f5a3e 100644
--- a/source/blender/draw/engines/eevee/shaders/bsdf_direct_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/bsdf_direct_lib.glsl
@@ -11,32 +11,32 @@
/* ------------ Diffuse ------------- */
-float direct_diffuse_point(LightData ld, ShadingData sd)
+float direct_diffuse_point(vec3 N, vec4 l_vector)
{
- float dist = length(sd.l_vector);
- vec3 L = sd.l_vector / dist;
- float bsdf = max(0.0, dot(sd.N, L));
+ float dist = l_vector.w;
+ vec3 L = l_vector.xyz / dist;
+ float bsdf = max(0.0, dot(N, L));
bsdf /= dist * dist;
return bsdf;
}
/* infinitly far away point source, no decay */
-float direct_diffuse_sun(LightData ld, ShadingData sd)
+float direct_diffuse_sun(LightData ld, vec3 N)
{
- float bsdf = max(0.0, dot(sd.N, -ld.l_forward));
+ float bsdf = max(0.0, dot(N, -ld.l_forward));
bsdf *= M_1_PI; /* Normalize */
return bsdf;
}
/* From Frostbite PBR Course
- * Analitical irradiance from a sphere with correct horizon handling
+ * Analytical irradiance from a sphere with correct horizon handling
* http://www.frostbite.com/wp-content/uploads/2014/11/course_notes_moving_frostbite_to_pbr.pdf */
-float direct_diffuse_sphere(LightData ld, ShadingData sd)
+float direct_diffuse_sphere(LightData ld, vec3 N, vec4 l_vector)
{
- float dist = length(sd.l_vector);
- vec3 L = sd.l_vector / dist;
+ float dist = l_vector.w;
+ vec3 L = l_vector.xyz / dist;
float radius = max(ld.l_sizex, 0.0001);
- float costheta = clamp(dot(sd.N, L), -0.999, 0.999);
+ float costheta = clamp(dot(N, L), -0.999, 0.999);
float h = min(ld.l_radius / dist , 0.9999);
float h2 = h*h;
float costheta2 = costheta * costheta;
@@ -61,15 +61,15 @@ float direct_diffuse_sphere(LightData ld, ShadingData sd)
/* From Frostbite PBR Course
* http://www.frostbite.com/wp-content/uploads/2014/11/course_notes_moving_frostbite_to_pbr.pdf */
-float direct_diffuse_rectangle(LightData ld, ShadingData sd)
+float direct_diffuse_rectangle(LightData ld, vec3 N, vec3 V, vec4 l_vector)
{
vec3 corners[4];
- corners[0] = sd.l_vector + ld.l_right * -ld.l_sizex + ld.l_up * ld.l_sizey;
- corners[1] = sd.l_vector + ld.l_right * -ld.l_sizex + ld.l_up * -ld.l_sizey;
- corners[2] = sd.l_vector + ld.l_right * ld.l_sizex + ld.l_up * -ld.l_sizey;
- corners[3] = sd.l_vector + ld.l_right * ld.l_sizex + ld.l_up * ld.l_sizey;
+ corners[0] = l_vector.xyz + ld.l_right * -ld.l_sizex + ld.l_up * ld.l_sizey;
+ corners[1] = l_vector.xyz + ld.l_right * -ld.l_sizex + ld.l_up * -ld.l_sizey;
+ corners[2] = l_vector.xyz + ld.l_right * ld.l_sizex + ld.l_up * -ld.l_sizey;
+ corners[3] = l_vector.xyz + ld.l_right * ld.l_sizex + ld.l_up * ld.l_sizey;
- float bsdf = ltc_evaluate(sd.N, sd.V, mat3(1.0), corners);
+ float bsdf = ltc_evaluate(N, V, mat3(1.0), corners);
bsdf *= M_1_2PI;
return bsdf;
}
@@ -83,35 +83,37 @@ float direct_diffuse_unit_disc(vec3 N, vec3 L)
#endif
/* ----------- GGx ------------ */
-vec3 direct_ggx_point(ShadingData sd, float roughness, vec3 f0)
+vec3 direct_ggx_point(vec3 N, vec3 V, vec4 l_vector, float roughness, vec3 f0)
{
- float dist = length(sd.l_vector);
- vec3 L = sd.l_vector / dist;
- float bsdf = bsdf_ggx(sd.N, L, sd.V, roughness);
+ roughness = max(1e-3, roughness);
+ float dist = l_vector.w;
+ vec3 L = l_vector.xyz / dist;
+ float bsdf = bsdf_ggx(N, L, V, roughness);
bsdf /= dist * dist;
/* Fresnel */
- float VH = max(dot(sd.V, normalize(sd.V + L)), 0.0);
+ float VH = max(dot(V, normalize(V + L)), 0.0);
return F_schlick(f0, VH) * bsdf;
}
-vec3 direct_ggx_sun(LightData ld, ShadingData sd, float roughness, vec3 f0)
+vec3 direct_ggx_sun(LightData ld, vec3 N, vec3 V, float roughness, vec3 f0)
{
- float bsdf = bsdf_ggx(sd.N, -ld.l_forward, sd.V, roughness);
- float VH = max(dot(sd.V, normalize(sd.V - ld.l_forward)), 0.0);
+ roughness = max(1e-3, roughness);
+ float bsdf = bsdf_ggx(N, -ld.l_forward, V, roughness);
+ float VH = dot(V, -ld.l_forward) * 0.5 + 0.5;
return F_schlick(f0, VH) * bsdf;
}
-vec3 direct_ggx_sphere(LightData ld, ShadingData sd, float roughness, vec3 f0)
+vec3 direct_ggx_sphere(LightData ld, vec3 N, vec3 V, vec4 l_vector, float roughness, vec3 f0)
{
- vec3 L = normalize(sd.l_vector);
- vec3 spec_dir = get_specular_dominant_dir(sd.N, reflect(-sd.V, sd.N), roughness);
- vec3 P = line_aligned_plane_intersect(vec3(0.0), spec_dir, sd.l_vector);
+ vec3 L = l_vector.xyz / l_vector.w;
+ vec3 spec_dir = get_specular_reflection_dominant_dir(N, V, roughness);
+ vec3 P = line_aligned_plane_intersect(vec3(0.0), spec_dir, l_vector.xyz);
- vec3 Px = normalize(P - sd.l_vector) * ld.l_radius;
+ vec3 Px = normalize(P - l_vector.xyz) * ld.l_radius;
vec3 Py = cross(Px, L);
- vec2 uv = lut_coords(dot(sd.N, sd.V), sqrt(roughness));
+ vec2 uv = lut_coords(dot(N, V), sqrt(roughness));
vec3 brdf_lut = texture(utilTex, vec3(uv, 1.0)).rgb;
vec4 ltc_lut = texture(utilTex, vec3(uv, 0.0)).rgba;
mat3 ltc_mat = ltc_matrix(ltc_lut);
@@ -123,22 +125,22 @@ vec3 direct_ggx_sphere(LightData ld, ShadingData sd, float roughness, vec3 f0)
/* counter clockwise */
vec3 points[8];
- points[0] = sd.l_vector + Px;
- points[1] = sd.l_vector - Pxy2;
- points[2] = sd.l_vector - Py;
- points[3] = sd.l_vector - Pxy1;
- points[4] = sd.l_vector - Px;
- points[5] = sd.l_vector + Pxy2;
- points[6] = sd.l_vector + Py;
- points[7] = sd.l_vector + Pxy1;
- float bsdf = ltc_evaluate_circle(sd.N, sd.V, ltc_mat, points);
+ points[0] = l_vector.xyz + Px;
+ points[1] = l_vector.xyz - Pxy2;
+ points[2] = l_vector.xyz - Py;
+ points[3] = l_vector.xyz - Pxy1;
+ points[4] = l_vector.xyz - Px;
+ points[5] = l_vector.xyz + Pxy2;
+ points[6] = l_vector.xyz + Py;
+ points[7] = l_vector.xyz + Pxy1;
+ float bsdf = ltc_evaluate_circle(N, V, ltc_mat, points);
#else
vec3 points[4];
- points[0] = sd.l_vector + Px;
- points[1] = sd.l_vector - Py;
- points[2] = sd.l_vector - Px;
- points[3] = sd.l_vector + Py;
- float bsdf = ltc_evaluate(sd.N, sd.V, ltc_mat, points);
+ points[0] = l_vector.xyz + Px;
+ points[1] = l_vector.xyz - Py;
+ points[2] = l_vector.xyz - Px;
+ points[3] = l_vector.xyz + Py;
+ float bsdf = ltc_evaluate(N, V, ltc_mat, points);
/* sqrt(pi/2) difference between square and disk area */
bsdf *= 1.25331413731;
#endif
@@ -151,19 +153,19 @@ vec3 direct_ggx_sphere(LightData ld, ShadingData sd, float roughness, vec3 f0)
return spec;
}
-vec3 direct_ggx_rectangle(LightData ld, ShadingData sd, float roughness, vec3 f0)
+vec3 direct_ggx_rectangle(LightData ld, vec3 N, vec3 V, vec4 l_vector, float roughness, vec3 f0)
{
vec3 corners[4];
- corners[0] = sd.l_vector + ld.l_right * -ld.l_sizex + ld.l_up * ld.l_sizey;
- corners[1] = sd.l_vector + ld.l_right * -ld.l_sizex + ld.l_up * -ld.l_sizey;
- corners[2] = sd.l_vector + ld.l_right * ld.l_sizex + ld.l_up * -ld.l_sizey;
- corners[3] = sd.l_vector + ld.l_right * ld.l_sizex + ld.l_up * ld.l_sizey;
+ corners[0] = l_vector.xyz + ld.l_right * -ld.l_sizex + ld.l_up * ld.l_sizey;
+ corners[1] = l_vector.xyz + ld.l_right * -ld.l_sizex + ld.l_up * -ld.l_sizey;
+ corners[2] = l_vector.xyz + ld.l_right * ld.l_sizex + ld.l_up * -ld.l_sizey;
+ corners[3] = l_vector.xyz + ld.l_right * ld.l_sizex + ld.l_up * ld.l_sizey;
- vec2 uv = lut_coords(dot(sd.N, sd.V), sqrt(roughness));
+ vec2 uv = lut_coords(dot(N, V), sqrt(roughness));
vec3 brdf_lut = texture(utilTex, vec3(uv, 1.0)).rgb;
vec4 ltc_lut = texture(utilTex, vec3(uv, 0.0)).rgba;
mat3 ltc_mat = ltc_matrix(ltc_lut);
- float bsdf = ltc_evaluate(sd.N, sd.V, ltc_mat, corners);
+ float bsdf = ltc_evaluate(N, V, ltc_mat, corners);
bsdf *= brdf_lut.b; /* Bsdf intensity */
bsdf *= M_1_2PI;
diff --git a/source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl b/source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl
index 3997de7a22d..f58dac6c0a0 100644
--- a/source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl
@@ -6,11 +6,18 @@ uniform float invSampleCount;
vec2 jitternoise = vec2(0.0);
+#ifndef UTIL_TEX
+#define UTIL_TEX
+uniform sampler2DArray utilTex;
+#endif /* UTIL_TEX */
+
void setup_noise(void)
{
- jitternoise = texture(texJitter, gl_FragCoord.xy / NOISE_SIZE).rg; /* Global variable */
+ jitternoise = texture(utilTex, vec3(gl_FragCoord.xy / LUT_SIZE, 2.0)).rg; /* Global variable */
+ jitternoise.g = (jitternoise.g - 0.5) * 2.0;
}
+#ifdef HAMMERSLEY_SIZE
vec3 hammersley_3d(float i, float invsamplenbr)
{
vec3 Xi; /* Theta, cos(Phi), sin(Phi) */
@@ -29,6 +36,7 @@ vec3 hammersley_3d(float i)
{
return hammersley_3d(i, invSampleCount);
}
+#endif
/* -------------- BSDFS -------------- */
@@ -42,19 +50,30 @@ float pdf_hemisphere()
return 0.5 * M_1_PI;
}
-vec3 sample_ggx(float nsample, float a2, vec3 N, vec3 T, vec3 B)
+vec3 sample_ggx(vec3 rand, float a2)
{
- vec3 Xi = hammersley_3d(nsample);
-
/* Theta is the aperture angle of the cone */
- float z = sqrt( (1.0 - Xi.x) / ( 1.0 + a2 * Xi.x - Xi.x ) ); /* cos theta */
+ float z = sqrt( (1.0 - rand.x) / ( 1.0 + a2 * rand.x - rand.x ) ); /* cos theta */
float r = sqrt( 1.0 - z * z ); /* sin theta */
- float x = r * Xi.y;
- float y = r * Xi.z;
+ float x = r * rand.y;
+ float y = r * rand.z;
/* Microfacet Normal */
- vec3 Ht = vec3(x, y, z);
+ return vec3(x, y, z);
+}
+vec3 sample_ggx(vec3 rand, float a2, vec3 N, vec3 T, vec3 B, out float NH)
+{
+ vec3 Ht = sample_ggx(rand, a2);
+ NH = Ht.z;
+ return tangent_to_world(Ht, N, T, B);
+}
+
+#ifdef HAMMERSLEY_SIZE
+vec3 sample_ggx(float nsample, float a2, vec3 N, vec3 T, vec3 B)
+{
+ vec3 Xi = hammersley_3d(nsample);
+ vec3 Ht = sample_ggx(Xi, a2);
return tangent_to_world(Ht, N, T, B);
}
@@ -70,4 +89,5 @@ vec3 sample_hemisphere(float nsample, vec3 N, vec3 T, vec3 B)
vec3 Ht = vec3(x, y, z);
return tangent_to_world(Ht, N, T, B);
-} \ No newline at end of file
+}
+#endif \ No newline at end of file
diff --git a/source/blender/draw/engines/eevee/shaders/btdf_lut_frag.glsl b/source/blender/draw/engines/eevee/shaders/btdf_lut_frag.glsl
new file mode 100644
index 00000000000..2c604d69641
--- /dev/null
+++ b/source/blender/draw/engines/eevee/shaders/btdf_lut_frag.glsl
@@ -0,0 +1,59 @@
+
+uniform float a2;
+
+out vec4 FragColor;
+
+void main() {
+ vec3 N, T, B, V;
+
+ float x = gl_FragCoord.x / BRDF_LUT_SIZE;
+ float y = gl_FragCoord.y / BRDF_LUT_SIZE;
+ /* There is little variation if ior > 1.0 so we
+ * maximize LUT precision for ior < 1.0 */
+ x = x * 1.1;
+ float ior = (x > 1.0) ? ior_from_f0((x-1.0) * 10.0) : sqrt(x);
+ float NV = (1.0 - (clamp(y, 1e-4, 0.9999)));
+
+ N = vec3(0.0, 0.0, 1.0);
+ T = vec3(1.0, 0.0, 0.0);
+ B = vec3(0.0, 1.0, 0.0);
+ V = vec3(sqrt(1.0 - NV * NV), 0.0, NV);
+
+ setup_noise();
+
+ /* Integrating BTDF */
+ float btdf_accum = 0.0;
+ for (float i = 0.0; i < sampleCount; i++) {
+ vec3 H = sample_ggx(i, a2, N, T, B); /* Microfacet normal */
+
+ float VH = dot(V, H);
+
+ /* Check if there is total internal reflections. */
+ float c = abs(VH);
+ float g = ior * ior - 1.0 + c * c;
+
+ float eta = 1.0/ior;
+ if (dot(H, V) < 0.0) {
+ H = -H;
+ eta = ior;
+ }
+
+ vec3 L = refract(-V, H, eta);
+ float NL = -dot(N, L);
+
+ if ((NL > 0.0) && (g > 0.0)) {
+ float LH = dot(L, H);
+
+ float G1_l = NL * 2.0 / G1_Smith_GGX(NL, a2); /* Balancing the adjustments made in G1_Smith */
+
+ /* btdf = abs(VH*LH) * (ior*ior) * D * G(V) * G(L) / (Ht2 * NV)
+ * pdf = (VH * abs(LH)) * (ior*ior) * D * G(V) / (Ht2 * NV) */
+ float btdf = G1_l * abs(VH*LH) / (VH * abs(LH));
+
+ btdf_accum += btdf;
+ }
+ }
+ btdf_accum /= sampleCount;
+
+ FragColor = vec4(btdf_accum, 0.0, 0.0, 1.0);
+} \ No newline at end of file
diff --git a/source/blender/draw/engines/eevee/shaders/concentric_samples_lib.glsl b/source/blender/draw/engines/eevee/shaders/concentric_samples_lib.glsl
new file mode 100644
index 00000000000..67bcf603a81
--- /dev/null
+++ b/source/blender/draw/engines/eevee/shaders/concentric_samples_lib.glsl
@@ -0,0 +1,267 @@
+/* Precomputed table of concentric samples.
+ * Generated using this algorithm http://l2program.co.uk/900/concentric-disk-sampling
+ * Sorted by radius then by rotation angle.
+ * This way it's better for cache usage and for
+ * easily restricting to a certain number of
+ * sample while still having a circular kernel. */
+
+#define CONCENTRIC_SAMPLE_NUM 256
+const vec2 concentric[CONCENTRIC_SAMPLE_NUM] =
+vec2[CONCENTRIC_SAMPLE_NUM](
+ vec2(0.0441941738242, 0.0441941738242),
+ vec2(-0.0441941738242, -0.0441941738242),
+ vec2(-0.0441941738242, 0.0441941738242),
+ vec2(0.0441941738242, -0.0441941738242),
+ vec2(0.181111092429, 0.0485285709567),
+ vec2(0.132582521472, 0.132582521472),
+ vec2(-0.181111092429, 0.0485285709567),
+ vec2(0.0485285709567, 0.181111092429),
+ vec2(-0.181111092429, -0.0485285709567),
+ vec2(-0.0485285709567, 0.181111092429),
+ vec2(-0.132582521472, -0.132582521472),
+ vec2(-0.132582521472, 0.132582521472),
+ vec2(-0.0485285709567, -0.181111092429),
+ vec2(0.0485285709567, -0.181111092429),
+ vec2(0.132582521472, -0.132582521472),
+ vec2(0.181111092429, -0.0485285709567),
+ vec2(0.308652606436, 0.0488857703251),
+ vec2(0.278439538809, 0.141872031169),
+ vec2(0.220970869121, 0.220970869121),
+ vec2(-0.278439538809, 0.141872031169),
+ vec2(0.141872031169, 0.278439538809),
+ vec2(-0.308652606436, 0.0488857703251),
+ vec2(0.0488857703251, 0.308652606436),
+ vec2(-0.308652606436, -0.0488857703251),
+ vec2(-0.0488857703251, 0.308652606436),
+ vec2(-0.278439538809, -0.141872031169),
+ vec2(-0.141872031169, 0.278439538809),
+ vec2(-0.220970869121, -0.220970869121),
+ vec2(-0.220970869121, 0.220970869121),
+ vec2(-0.141872031169, -0.278439538809),
+ vec2(-0.0488857703251, -0.308652606436),
+ vec2(0.0488857703251, -0.308652606436),
+ vec2(0.141872031169, -0.278439538809),
+ vec2(0.220970869121, -0.220970869121),
+ vec2(0.278439538809, -0.141872031169),
+ vec2(0.308652606436, -0.0488857703251),
+ vec2(0.434749091828, 0.0489844582952),
+ vec2(0.41294895701, 0.144497089605),
+ vec2(0.370441837162, 0.232764033475),
+ vec2(0.309359216769, 0.309359216769),
+ vec2(-0.370441837162, 0.232764033475),
+ vec2(0.232764033475, 0.370441837162),
+ vec2(-0.41294895701, 0.144497089605),
+ vec2(0.144497089605, 0.41294895701),
+ vec2(-0.434749091828, 0.0489844582952),
+ vec2(0.0489844582952, 0.434749091828),
+ vec2(-0.434749091828, -0.0489844582952),
+ vec2(-0.0489844582952, 0.434749091828),
+ vec2(-0.41294895701, -0.144497089605),
+ vec2(-0.144497089605, 0.41294895701),
+ vec2(-0.370441837162, -0.232764033475),
+ vec2(-0.232764033475, 0.370441837162),
+ vec2(-0.309359216769, -0.309359216769),
+ vec2(-0.309359216769, 0.309359216769),
+ vec2(-0.232764033475, -0.370441837162),
+ vec2(-0.144497089605, -0.41294895701),
+ vec2(-0.0489844582952, -0.434749091828),
+ vec2(0.0489844582952, -0.434749091828),
+ vec2(0.144497089605, -0.41294895701),
+ vec2(0.232764033475, -0.370441837162),
+ vec2(0.309359216769, -0.309359216769),
+ vec2(0.370441837162, -0.232764033475),
+ vec2(0.41294895701, -0.144497089605),
+ vec2(0.434749091828, -0.0489844582952),
+ vec2(0.560359517677, 0.0490251052956),
+ vec2(0.543333277288, 0.14558571287),
+ vec2(0.509798130208, 0.237722772229),
+ vec2(0.460773024913, 0.322636745447),
+ vec2(0.397747564417, 0.397747564417),
+ vec2(-0.460773024913, 0.322636745447),
+ vec2(0.322636745447, 0.460773024913),
+ vec2(-0.509798130208, 0.237722772229),
+ vec2(0.237722772229, 0.509798130208),
+ vec2(-0.543333277288, 0.14558571287),
+ vec2(0.14558571287, 0.543333277288),
+ vec2(-0.560359517677, 0.0490251052956),
+ vec2(0.0490251052956, 0.560359517677),
+ vec2(-0.560359517677, -0.0490251052956),
+ vec2(-0.0490251052956, 0.560359517677),
+ vec2(-0.543333277288, -0.14558571287),
+ vec2(-0.14558571287, 0.543333277288),
+ vec2(-0.509798130208, -0.237722772229),
+ vec2(-0.237722772229, 0.509798130208),
+ vec2(-0.460773024913, -0.322636745447),
+ vec2(-0.322636745447, 0.460773024913),
+ vec2(-0.397747564417, -0.397747564417),
+ vec2(-0.397747564417, 0.397747564417),
+ vec2(-0.322636745447, -0.460773024913),
+ vec2(-0.237722772229, -0.509798130208),
+ vec2(-0.14558571287, -0.543333277288),
+ vec2(-0.0490251052956, -0.560359517677),
+ vec2(0.0490251052956, -0.560359517677),
+ vec2(0.14558571287, -0.543333277288),
+ vec2(0.237722772229, -0.509798130208),
+ vec2(0.322636745447, -0.460773024913),
+ vec2(0.397747564417, -0.397747564417),
+ vec2(0.460773024913, -0.322636745447),
+ vec2(0.509798130208, -0.237722772229),
+ vec2(0.543333277288, -0.14558571287),
+ vec2(0.560359517677, -0.0490251052956),
+ vec2(0.685748328795, 0.0490456884495),
+ vec2(0.671788470355, 0.146138636568),
+ vec2(0.644152935937, 0.240256623474),
+ vec2(0.603404305327, 0.32948367837),
+ vec2(0.550372103135, 0.412003395727),
+ vec2(0.486135912066, 0.486135912066),
+ vec2(-0.550372103135, 0.412003395727),
+ vec2(0.412003395727, 0.550372103135),
+ vec2(-0.603404305327, 0.32948367837),
+ vec2(0.32948367837, 0.603404305327),
+ vec2(-0.644152935937, 0.240256623474),
+ vec2(0.240256623474, 0.644152935937),
+ vec2(-0.671788470355, 0.146138636568),
+ vec2(0.146138636568, 0.671788470355),
+ vec2(-0.685748328795, 0.0490456884495),
+ vec2(0.0490456884495, 0.685748328795),
+ vec2(-0.685748328795, -0.0490456884495),
+ vec2(-0.0490456884495, 0.685748328795),
+ vec2(-0.671788470355, -0.146138636568),
+ vec2(-0.146138636568, 0.671788470355),
+ vec2(-0.644152935937, -0.240256623474),
+ vec2(-0.240256623474, 0.644152935937),
+ vec2(-0.603404305327, -0.32948367837),
+ vec2(-0.32948367837, 0.603404305327),
+ vec2(-0.550372103135, -0.412003395727),
+ vec2(-0.412003395727, 0.550372103135),
+ vec2(-0.486135912066, -0.486135912066),
+ vec2(-0.486135912066, 0.486135912066),
+ vec2(-0.412003395727, -0.550372103135),
+ vec2(-0.32948367837, -0.603404305327),
+ vec2(-0.240256623474, -0.644152935937),
+ vec2(-0.146138636568, -0.671788470355),
+ vec2(-0.0490456884495, -0.685748328795),
+ vec2(0.0490456884495, -0.685748328795),
+ vec2(0.146138636568, -0.671788470355),
+ vec2(0.240256623474, -0.644152935937),
+ vec2(0.32948367837, -0.603404305327),
+ vec2(0.412003395727, -0.550372103135),
+ vec2(0.486135912066, -0.486135912066),
+ vec2(0.550372103135, -0.412003395727),
+ vec2(0.603404305327, -0.32948367837),
+ vec2(0.644152935937, -0.240256623474),
+ vec2(0.671788470355, -0.146138636568),
+ vec2(0.685748328795, -0.0490456884495),
+ vec2(0.811017637806, 0.0490575291556),
+ vec2(0.799191174395, 0.146457218224),
+ vec2(0.775710704038, 0.241721231257),
+ vec2(0.740918624869, 0.33346040443),
+ vec2(0.695322283745, 0.420336974019),
+ vec2(0.639586577995, 0.501084084011),
+ vec2(0.574524259714, 0.574524259714),
+ vec2(-0.639586577995, 0.501084084011),
+ vec2(0.501084084011, 0.639586577995),
+ vec2(-0.695322283745, 0.420336974019),
+ vec2(0.420336974019, 0.695322283745),
+ vec2(-0.740918624869, 0.33346040443),
+ vec2(0.33346040443, 0.740918624869),
+ vec2(-0.775710704038, 0.241721231257),
+ vec2(0.241721231257, 0.775710704038),
+ vec2(-0.799191174395, 0.146457218224),
+ vec2(0.146457218224, 0.799191174395),
+ vec2(-0.811017637806, 0.0490575291556),
+ vec2(0.0490575291556, 0.811017637806),
+ vec2(-0.811017637806, -0.0490575291556),
+ vec2(-0.0490575291556, 0.811017637806),
+ vec2(-0.799191174395, -0.146457218224),
+ vec2(-0.146457218224, 0.799191174395),
+ vec2(-0.775710704038, -0.241721231257),
+ vec2(-0.241721231257, 0.775710704038),
+ vec2(-0.740918624869, -0.33346040443),
+ vec2(-0.33346040443, 0.740918624869),
+ vec2(-0.695322283745, -0.420336974019),
+ vec2(-0.420336974019, 0.695322283745),
+ vec2(-0.639586577995, -0.501084084011),
+ vec2(-0.501084084011, 0.639586577995),
+ vec2(-0.574524259714, -0.574524259714),
+ vec2(-0.574524259714, 0.574524259714),
+ vec2(-0.501084084011, -0.639586577995),
+ vec2(-0.420336974019, -0.695322283745),
+ vec2(-0.33346040443, -0.740918624869),
+ vec2(-0.241721231257, -0.775710704038),
+ vec2(-0.146457218224, -0.799191174395),
+ vec2(-0.0490575291556, -0.811017637806),
+ vec2(0.0490575291556, -0.811017637806),
+ vec2(0.146457218224, -0.799191174395),
+ vec2(0.241721231257, -0.775710704038),
+ vec2(0.33346040443, -0.740918624869),
+ vec2(0.420336974019, -0.695322283745),
+ vec2(0.501084084011, -0.639586577995),
+ vec2(0.574524259714, -0.574524259714),
+ vec2(0.639586577995, -0.501084084011),
+ vec2(0.695322283745, -0.420336974019),
+ vec2(0.740918624869, -0.33346040443),
+ vec2(0.775710704038, -0.241721231257),
+ vec2(0.799191174395, -0.146457218224),
+ vec2(0.811017637806, -0.0490575291556),
+ vec2(0.936215188832, 0.0490649589778),
+ vec2(0.925957819308, 0.146657310975),
+ vec2(0.905555462146, 0.242642854784),
+ vec2(0.875231649841, 0.335969952699),
+ vec2(0.835318616427, 0.425616093506),
+ vec2(0.786253657449, 0.510599095327),
+ vec2(0.728574338866, 0.589987866609),
+ vec2(0.662912607362, 0.662912607362),
+ vec2(-0.728574338866, 0.589987866609),
+ vec2(0.589987866609, 0.728574338866),
+ vec2(-0.786253657449, 0.510599095327),
+ vec2(0.510599095327, 0.786253657449),
+ vec2(-0.835318616427, 0.425616093506),
+ vec2(0.425616093506, 0.835318616427),
+ vec2(-0.875231649841, 0.335969952699),
+ vec2(0.335969952699, 0.875231649841),
+ vec2(-0.905555462146, 0.242642854784),
+ vec2(0.242642854784, 0.905555462146),
+ vec2(-0.925957819308, 0.146657310975),
+ vec2(0.146657310975, 0.925957819308),
+ vec2(-0.936215188832, 0.0490649589778),
+ vec2(0.0490649589778, 0.936215188832),
+ vec2(-0.936215188832, -0.0490649589778),
+ vec2(-0.0490649589778, 0.936215188832),
+ vec2(-0.925957819308, -0.146657310975),
+ vec2(-0.146657310975, 0.925957819308),
+ vec2(-0.905555462146, -0.242642854784),
+ vec2(-0.242642854784, 0.905555462146),
+ vec2(-0.875231649841, -0.335969952699),
+ vec2(-0.335969952699, 0.875231649841),
+ vec2(-0.835318616427, -0.425616093506),
+ vec2(-0.425616093506, 0.835318616427),
+ vec2(-0.786253657449, -0.510599095327),
+ vec2(-0.510599095327, 0.786253657449),
+ vec2(-0.728574338866, -0.589987866609),
+ vec2(-0.589987866609, 0.728574338866),
+ vec2(-0.662912607362, -0.662912607362),
+ vec2(-0.662912607362, 0.662912607362),
+ vec2(-0.589987866609, -0.728574338866),
+ vec2(-0.510599095327, -0.786253657449),
+ vec2(-0.425616093506, -0.835318616427),
+ vec2(-0.335969952699, -0.875231649841),
+ vec2(-0.242642854784, -0.905555462146),
+ vec2(-0.146657310975, -0.925957819308),
+ vec2(-0.0490649589778, -0.936215188832),
+ vec2(0.0490649589778, -0.936215188832),
+ vec2(0.146657310975, -0.925957819308),
+ vec2(0.242642854784, -0.905555462146),
+ vec2(0.335969952699, -0.875231649841),
+ vec2(0.425616093506, -0.835318616427),
+ vec2(0.510599095327, -0.786253657449),
+ vec2(0.589987866609, -0.728574338866),
+ vec2(0.662912607362, -0.662912607362),
+ vec2(0.728574338866, -0.589987866609),
+ vec2(0.786253657449, -0.510599095327),
+ vec2(0.835318616427, -0.425616093506),
+ vec2(0.875231649841, -0.335969952699),
+ vec2(0.905555462146, -0.242642854784),
+ vec2(0.925957819308, -0.146657310975),
+ vec2(0.936215188832, -0.0490649589778)
+); \ No newline at end of file
diff --git a/source/blender/draw/engines/eevee/shaders/default_frag.glsl b/source/blender/draw/engines/eevee/shaders/default_frag.glsl
index 004db999149..4ba4192abbd 100644
--- a/source/blender/draw/engines/eevee/shaders/default_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/default_frag.glsl
@@ -4,12 +4,15 @@ uniform float metallic;
uniform float specular;
uniform float roughness;
-out vec4 FragColor;
-
-void main()
+Closure nodetree_exec(void)
{
vec3 dielectric = vec3(0.034) * specular * 2.0;
vec3 diffuse = mix(basecol, vec3(0.0), metallic);
vec3 f0 = mix(dielectric, basecol, metallic);
- FragColor = vec4(eevee_surface_lit((gl_FrontFacing) ? worldNormal : -worldNormal, diffuse, f0, roughness, 1.0), length(viewPosition));
+ vec3 ssr_spec;
+ vec3 radiance = eevee_surface_lit((gl_FrontFacing) ? worldNormal : -worldNormal, diffuse, f0, roughness, 1.0, 0, ssr_spec);
+
+ Closure result = Closure(radiance, 1.0, vec4(ssr_spec, roughness), normal_encode(normalize(viewNormal), viewCameraVec), 0);
+
+ return result;
}
diff --git a/source/blender/draw/engines/eevee/shaders/effect_bloom_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_bloom_frag.glsl
index 52b1cc406d2..29543e82f43 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_bloom_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_bloom_frag.glsl
@@ -31,6 +31,7 @@ uniform vec2 sourceBufferTexelSize;
/* Step Blit */
uniform vec4 curveThreshold;
+uniform float clampIntensity;
/* Step Upsample */
uniform sampler2D baseBuffer; /* Previous accumulation buffer */
@@ -38,7 +39,7 @@ uniform vec2 baseBufferTexelSize;
uniform float sampleScale;
/* Step Resolve */
-uniform float bloomIntensity;
+uniform vec3 bloomColor;
in vec4 uvcoordsvar;
@@ -46,15 +47,21 @@ out vec4 FragColor;
/* -------------- Utils ------------- */
+vec3 safe_color(vec3 c)
+{
+ /* Clamp to avoid black square artifacts if a pixel goes NaN. */
+ return clamp(c, vec3(0.0), vec3(1e20)); /* 1e20 arbitrary. */
+}
+
float brightness(vec3 c)
{
- return max(max(c.r, c.g), c.b);
+ return max(max(c.r, c.g), c.b);
}
/* 3-tap median filter */
vec3 median(vec3 a, vec3 b, vec3 c)
{
- return a + b + c - min(min(a, b), c) - max(max(a, b), c);
+ return a + b + c - min(min(a, b), c) - max(max(a, b), c);
}
/* ------------- Filters ------------ */
@@ -64,10 +71,10 @@ vec3 downsample_filter_high(sampler2D tex, vec2 uv, vec2 texelSize)
/* Downsample with a 4x4 box filter + anti-flicker filter */
vec4 d = texelSize.xyxy * vec4(-1, -1, +1, +1);
- vec3 s1 = texture(tex, uv + d.xy).rgb;
- vec3 s2 = texture(tex, uv + d.zy).rgb;
- vec3 s3 = texture(tex, uv + d.xw).rgb;
- vec3 s4 = texture(tex, uv + d.zw).rgb;
+ vec3 s1 = textureLod(tex, uv + d.xy, 0.0).rgb;
+ vec3 s2 = textureLod(tex, uv + d.zy, 0.0).rgb;
+ vec3 s3 = textureLod(tex, uv + d.xw, 0.0).rgb;
+ vec3 s4 = textureLod(tex, uv + d.zw, 0.0).rgb;
/* Karis's luma weighted average (using brightness instead of luma) */
float s1w = 1.0 / (brightness(s1) + 1.0);
@@ -85,10 +92,10 @@ vec3 downsample_filter(sampler2D tex, vec2 uv, vec2 texelSize)
vec4 d = texelSize.xyxy * vec4(-1, -1, +1, +1);
vec3 s;
- s = texture(tex, uv + d.xy).rgb;
- s += texture(tex, uv + d.zy).rgb;
- s += texture(tex, uv + d.xw).rgb;
- s += texture(tex, uv + d.zw).rgb;
+ s = textureLod(tex, uv + d.xy, 0.0).rgb;
+ s += textureLod(tex, uv + d.zy, 0.0).rgb;
+ s += textureLod(tex, uv + d.xw, 0.0).rgb;
+ s += textureLod(tex, uv + d.zw, 0.0).rgb;
return s * (1.0 / 4);
}
@@ -99,17 +106,17 @@ vec3 upsample_filter_high(sampler2D tex, vec2 uv, vec2 texelSize)
vec4 d = texelSize.xyxy * vec4(1, 1, -1, 0) * sampleScale;
vec3 s;
- s = texture(tex, uv - d.xy).rgb;
- s += texture(tex, uv - d.wy).rgb * 2;
- s += texture(tex, uv - d.zy).rgb;
+ s = textureLod(tex, uv - d.xy, 0.0).rgb;
+ s += textureLod(tex, uv - d.wy, 0.0).rgb * 2;
+ s += textureLod(tex, uv - d.zy, 0.0).rgb;
- s += texture(tex, uv + d.zw).rgb * 2;
- s += texture(tex, uv ).rgb * 4;
- s += texture(tex, uv + d.xw).rgb * 2;
+ s += textureLod(tex, uv + d.zw, 0.0).rgb * 2;
+ s += textureLod(tex, uv , 0.0).rgb * 4;
+ s += textureLod(tex, uv + d.xw, 0.0).rgb * 2;
- s += texture(tex, uv + d.zy).rgb;
- s += texture(tex, uv + d.wy).rgb * 2;
- s += texture(tex, uv + d.xy).rgb;
+ s += textureLod(tex, uv + d.zy, 0.0).rgb;
+ s += textureLod(tex, uv + d.wy, 0.0).rgb * 2;
+ s += textureLod(tex, uv + d.xy, 0.0).rgb;
return s * (1.0 / 16.0);
}
@@ -120,10 +127,10 @@ vec3 upsample_filter(sampler2D tex, vec2 uv, vec2 texelSize)
vec4 d = texelSize.xyxy * vec4(-1, -1, +1, +1) * (sampleScale * 0.5);
vec3 s;
- s = texture(tex, uv + d.xy).rgb;
- s += texture(tex, uv + d.zy).rgb;
- s += texture(tex, uv + d.xw).rgb;
- s += texture(tex, uv + d.zw).rgb;
+ s = textureLod(tex, uv + d.xy, 0.0).rgb;
+ s += textureLod(tex, uv + d.zy, 0.0).rgb;
+ s += textureLod(tex, uv + d.xw, 0.0).rgb;
+ s += textureLod(tex, uv + d.zw, 0.0).rgb;
return s * (1.0 / 4.0);
}
@@ -136,14 +143,14 @@ vec4 step_blit(void)
#ifdef HIGH_QUALITY /* Anti flicker */
vec3 d = sourceBufferTexelSize.xyx * vec3(1, 1, 0);
- vec3 s0 = texture(sourceBuffer, uvcoordsvar.xy).rgb;
- vec3 s1 = texture(sourceBuffer, uvcoordsvar.xy - d.xz).rgb;
- vec3 s2 = texture(sourceBuffer, uvcoordsvar.xy + d.xz).rgb;
- vec3 s3 = texture(sourceBuffer, uvcoordsvar.xy - d.zy).rgb;
- vec3 s4 = texture(sourceBuffer, uvcoordsvar.xy + d.zy).rgb;
+ vec3 s0 = safe_color(textureLod(sourceBuffer, uvcoordsvar.xy, 0.0).rgb);
+ vec3 s1 = safe_color(textureLod(sourceBuffer, uvcoordsvar.xy - d.xz, 0.0).rgb);
+ vec3 s2 = safe_color(textureLod(sourceBuffer, uvcoordsvar.xy + d.xz, 0.0).rgb);
+ vec3 s3 = safe_color(textureLod(sourceBuffer, uvcoordsvar.xy - d.zy, 0.0).rgb);
+ vec3 s4 = safe_color(textureLod(sourceBuffer, uvcoordsvar.xy + d.zy, 0.0).rgb);
vec3 m = median(median(s0.rgb, s1, s2), s3, s4);
#else
- vec3 s0 = texture(sourceBuffer, uvcoordsvar.xy).rgb;
+ vec3 s0 = safe_color(textureLod(sourceBuffer, uvcoordsvar.xy, 0.0).rgb);
vec3 m = s0.rgb;
#endif
@@ -155,7 +162,11 @@ vec4 step_blit(void)
rq = curveThreshold.z * rq * rq;
/* Combine and apply the brightness response curve. */
- m *= max(rq, br - curveThreshold.w) / max(br, 1e-5);
+ m *= max(rq, br - curveThreshold.w) / max(1e-5, br);
+
+ /* Clamp pixel intensity */
+ br = max(1e-5, brightness(m));
+ m *= 1.0 - max(0.0, br - clampIntensity) / br;
return vec4(m, 1.0);
}
@@ -177,7 +188,7 @@ vec4 step_upsample(void)
#else
vec3 blur = upsample_filter(sourceBuffer, uvcoordsvar.xy, sourceBufferTexelSize);
#endif
- vec3 base = texture(baseBuffer, uvcoordsvar.xy).rgb;
+ vec3 base = textureLod(baseBuffer, uvcoordsvar.xy, 0.0).rgb;
return vec4(base + blur, 1.0);
}
@@ -188,8 +199,8 @@ vec4 step_resolve(void)
#else
vec3 blur = upsample_filter(sourceBuffer, uvcoordsvar.xy, sourceBufferTexelSize);
#endif
- vec4 base = texture(baseBuffer, uvcoordsvar.xy);
- vec3 cout = base.rgb + blur * bloomIntensity;
+ vec4 base = textureLod(baseBuffer, uvcoordsvar.xy, 0.0);
+ vec3 cout = base.rgb + blur * bloomColor;
return vec4(cout, base.a);
}
diff --git a/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl
index 2f5143390ce..04648f62688 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl
@@ -180,17 +180,17 @@ vec4 upsample_filter_high(sampler2D tex, vec2 uv, vec2 texelSize)
vec4 d = texelSize.xyxy * vec4(1, 1, -1, 0);
vec4 s;
- s = texture(tex, uv - d.xy);
- s += texture(tex, uv - d.wy) * 2;
- s += texture(tex, uv - d.zy);
+ s = textureLod(tex, uv - d.xy, 0.0);
+ s += textureLod(tex, uv - d.wy, 0.0) * 2;
+ s += textureLod(tex, uv - d.zy, 0.0);
- s += texture(tex, uv + d.zw) * 2;
- s += texture(tex, uv ) * 4;
- s += texture(tex, uv + d.xw) * 2;
+ s += textureLod(tex, uv + d.zw, 0.0) * 2;
+ s += textureLod(tex, uv , 0.0) * 4;
+ s += textureLod(tex, uv + d.xw, 0.0) * 2;
- s += texture(tex, uv + d.zy);
- s += texture(tex, uv + d.wy) * 2;
- s += texture(tex, uv + d.xy);
+ s += textureLod(tex, uv + d.zy, 0.0);
+ s += textureLod(tex, uv + d.wy, 0.0) * 2;
+ s += textureLod(tex, uv + d.xy, 0.0);
return s * (1.0 / 16.0);
}
@@ -201,10 +201,10 @@ vec4 upsample_filter(sampler2D tex, vec2 uv, vec2 texelSize)
vec4 d = texelSize.xyxy * vec4(-1, -1, +1, +1) * 0.5;
vec4 s;
- s = texture(tex, uv + d.xy);
- s += texture(tex, uv + d.zy);
- s += texture(tex, uv + d.xw);
- s += texture(tex, uv + d.zw);
+ s = textureLod(tex, uv + d.xy, 0.0);
+ s += textureLod(tex, uv + d.zy, 0.0);
+ s += textureLod(tex, uv + d.xw, 0.0);
+ s += textureLod(tex, uv + d.zw, 0.0);
return s * (1.0 / 4.0);
}
@@ -213,7 +213,7 @@ vec4 upsample_filter(sampler2D tex, vec2 uv, vec2 texelSize)
void step_resolve(void)
{
/* Recompute Near / Far CoC */
- float depth = texture(depthBuffer, uvcoord).r;
+ float depth = textureLod(depthBuffer, uvcoord, 0.0).r;
float zdepth = linear_depth(depth);
float coc_signed = calculate_coc(zdepth);
float coc_far = max(-coc_signed, 0.0);
@@ -221,7 +221,7 @@ void step_resolve(void)
/* Recompute Near / Far CoC */
vec2 texelSize = 1.0 / vec2(textureSize(farBuffer, 0));
- vec4 srccolor = texture(colorBuffer, uvcoord);
+ vec4 srccolor = textureLod(colorBuffer, uvcoord, 0.0);
vec4 farcolor = upsample_filter_high(farBuffer, uvcoord, texelSize);
vec4 nearcolor = upsample_filter_high(nearBuffer, uvcoord, texelSize);
diff --git a/source/blender/draw/engines/eevee/shaders/effect_downsample_cube_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_downsample_cube_frag.glsl
new file mode 100644
index 00000000000..eb463d51146
--- /dev/null
+++ b/source/blender/draw/engines/eevee/shaders/effect_downsample_cube_frag.glsl
@@ -0,0 +1,30 @@
+/**
+ * Simple downsample shader. Takes the average of the 4 texels of lower mip.
+ **/
+
+uniform samplerCube source;
+uniform float texelSize;
+
+flat in int fFace;
+
+out vec4 FragColor;
+
+const vec3 maj_axes[6] = vec3[6](vec3(1.0, 0.0, 0.0), vec3(-1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), vec3(0.0, -1.0, 0.0), vec3( 0.0, 0.0, 1.0), vec3( 0.0, 0.0, -1.0));
+const vec3 x_axis[6] = vec3[6](vec3(0.0, 0.0, -1.0), vec3( 0.0, 0.0, 1.0), vec3(1.0, 0.0, 0.0), vec3(1.0, 0.0, 0.0), vec3( 1.0, 0.0, 0.0), vec3(-1.0, 0.0, 0.0));
+const vec3 y_axis[6] = vec3[6](vec3(0.0, -1.0, 0.0), vec3( 0.0, -1.0, 0.0), vec3(0.0, 0.0, 1.0), vec3(0.0, 0.0, -1.0), vec3( 0.0, -1.0, 0.0), vec3( 0.0, -1.0, 0.0));
+
+float brightness(vec3 c)
+{
+ return max(max(c.r, c.g), c.b);
+}
+
+void main()
+{
+ vec2 uvs = gl_FragCoord.xy * texelSize;
+
+ uvs = 2.0 * uvs - 1.0;
+
+ vec3 cubevec = x_axis[fFace] * uvs.x + y_axis[fFace] * uvs.y + maj_axes[fFace];
+
+ FragColor = textureLod(source, cubevec, 0.0);
+} \ No newline at end of file
diff --git a/source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl
new file mode 100644
index 00000000000..156be108a14
--- /dev/null
+++ b/source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl
@@ -0,0 +1,37 @@
+/**
+ * Simple downsample shader. Takes the average of the 4 texels of lower mip.
+ **/
+
+uniform sampler2D source;
+uniform float fireflyFactor;
+
+out vec4 FragColor;
+
+float brightness(vec3 c)
+{
+ return max(max(c.r, c.g), c.b);
+}
+
+void main()
+{
+#if 0
+ /* Reconstructing Target uvs like this avoid missing pixels if NPO2 */
+ vec2 uvs = gl_FragCoord.xy * 2.0 / vec2(textureSize(source, 0));
+
+ FragColor = textureLod(source, uvs, 0.0);
+#else
+ vec2 texel_size = 1.0 / vec2(textureSize(source, 0));
+ vec2 uvs = gl_FragCoord.xy * 2.0 * texel_size;
+ vec4 ofs = texel_size.xyxy * vec4(0.75, 0.75, -0.75, -0.75);
+
+ FragColor = textureLod(source, uvs + ofs.xy, 0.0);
+ FragColor += textureLod(source, uvs + ofs.xw, 0.0);
+ FragColor += textureLod(source, uvs + ofs.zy, 0.0);
+ FragColor += textureLod(source, uvs + ofs.zw, 0.0);
+ FragColor *= 0.25;
+
+ /* Clamped brightness. */
+ float luma = max(1e-8, brightness(FragColor.rgb));
+ FragColor *= 1.0 - max(0.0, luma - fireflyFactor) / luma;
+#endif
+} \ No newline at end of file
diff --git a/source/blender/draw/engines/eevee/shaders/effect_gtao_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_gtao_frag.glsl
new file mode 100644
index 00000000000..1c63051c65b
--- /dev/null
+++ b/source/blender/draw/engines/eevee/shaders/effect_gtao_frag.glsl
@@ -0,0 +1,69 @@
+/**
+ * This shader only compute maximum horizon angles for each directions.
+ * The final integration is done at the resolve stage with the shading normal.
+ **/
+
+uniform float rotationOffset;
+
+out vec4 FragColor;
+
+#ifdef DEBUG_AO
+uniform sampler2D normalBuffer;
+
+void main()
+{
+ vec4 texel_size = 1.0 / vec2(textureSize(depthBuffer, 0)).xyxy;
+ vec2 uvs = saturate(gl_FragCoord.xy * texel_size.xy);
+
+ float depth = textureLod(depthBuffer, uvs, 0.0).r;
+
+ vec3 viewPosition = get_view_space_from_depth(uvs, depth);
+ vec3 V = viewCameraVec;
+ vec3 normal = normal_decode(texture(normalBuffer, uvs).rg, V);
+
+ vec3 bent_normal;
+ float visibility;
+#if 1
+ gtao_deferred(normal, viewPosition, depth, visibility, bent_normal);
+#else
+ vec2 rand = vec2((1.0 / 4.0) * float((int(gl_FragCoord.y) & 0x1) * 2 + (int(gl_FragCoord.x) & 0x1)), 0.5);
+ rand = fract(rand.x + texture(utilTex, vec3(floor(gl_FragCoord.xy * 0.5) / LUT_SIZE, 2.0)).rg);
+ gtao(normal, viewPosition, rand, visibility, bent_normal);
+#endif
+ denoise_ao(normal, depth, visibility, bent_normal);
+
+ FragColor = vec4(visibility);
+}
+
+#else
+uniform float sampleNbr;
+
+void main()
+{
+ ivec2 hr_co = ivec2(gl_FragCoord.xy);
+ ivec2 fs_co = get_fs_co(hr_co);
+
+ vec2 uvs = saturate((vec2(fs_co) + 0.5) / vec2(textureSize(depthBuffer, 0)));
+ float depth = textureLod(depthBuffer, uvs, 0.0).r;
+
+ if (depth == 1.0) {
+ /* Do not trace for background */
+ FragColor = vec4(0.0);
+ return;
+ }
+
+ /* Avoid self shadowing. */
+ depth = saturate(depth - 3e-6); /* Tweaked for 24bit depth buffer. */
+
+ vec3 viewPosition = get_view_space_from_depth(uvs, depth);
+
+ float phi = get_phi(hr_co, fs_co, sampleNbr);
+ float offset = get_offset(fs_co, sampleNbr);
+ vec2 max_dir = get_max_dir(viewPosition.z);
+
+ FragColor.xy = search_horizon_sweep(phi, viewPosition, uvs, offset, max_dir);
+
+ /* Resize output for integer texture. */
+ FragColor = pack_horizons(FragColor.xy).xyxy;
+}
+#endif
diff --git a/source/blender/draw/engines/eevee/shaders/effect_minmaxz_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_minmaxz_frag.glsl
index 9f81206070b..ce6f3568cdf 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_minmaxz_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_minmaxz_frag.glsl
@@ -4,63 +4,62 @@
* Adapted from http://rastergrid.com/blog/2010/10/hierarchical-z-map-based-occlusion-culling/
**/
+#ifdef LAYERED
+uniform sampler2DArray depthBuffer;
+uniform int depthLayer;
+#else
uniform sampler2D depthBuffer;
+#endif
-out vec4 FragMinMax;
-
-vec2 sampleLowerMip(ivec2 texel)
-{
-#ifdef INPUT_DEPTH
- return texelFetch(depthBuffer, texel, 0).rr;
+#ifdef LAYERED
+#define sampleLowerMip(t) texelFetch(depthBuffer, ivec3(t, depthLayer), 0).r
#else
- return texelFetch(depthBuffer, texel, 0).rg;
+#define sampleLowerMip(t) texelFetch(depthBuffer, t, 0).r
#endif
-}
-void minmax(inout vec2 val[2])
-{
- val[0].x = min(val[0].x, val[1].x);
- val[0].y = max(val[0].y, val[1].y);
-}
+#ifdef MIN_PASS
+#define minmax(a, b) min(a, b)
+#else /* MAX_PASS */
+#define minmax(a, b) max(a, b)
+#endif
void main()
{
- vec2 val[2];
ivec2 texelPos = ivec2(gl_FragCoord.xy);
- ivec2 mipsize = textureSize(depthBuffer, 0);
+ ivec2 mipsize = textureSize(depthBuffer, 0).xy;
+
#ifndef COPY_DEPTH
texelPos *= 2;
#endif
- val[0] = sampleLowerMip(texelPos);
+ float val = sampleLowerMip(texelPos);
#ifndef COPY_DEPTH
- val[1] = sampleLowerMip(texelPos + ivec2(1, 0));
- minmax(val);
- val[1] = sampleLowerMip(texelPos + ivec2(1, 1));
- minmax(val);
- val[1] = sampleLowerMip(texelPos + ivec2(0, 1));
- minmax(val);
+ float val2 = sampleLowerMip(texelPos + ivec2(1, 0));
+ float val3 = sampleLowerMip(texelPos + ivec2(1, 1));
+ float val4 = sampleLowerMip(texelPos + ivec2(0, 1));
+ val = minmax(val, val2);
+ val = minmax(val, val3);
+ val = minmax(val, val4);
/* if we are reducing an odd-width texture then fetch the edge texels */
- if (((mipsize.x & 1) != 0) && (int(gl_FragCoord.x) == mipsize.x-3)) {
+ if (((mipsize.x & 1) != 0) && (texelPos.x == mipsize.x - 3)) {
/* if both edges are odd, fetch the top-left corner texel */
- if (((mipsize.y & 1) != 0) && (int(gl_FragCoord.y) == mipsize.y-3)) {
- val[1] = sampleLowerMip(texelPos + ivec2(-1, -1));
- minmax(val);
+ if (((mipsize.y & 1) != 0) && (texelPos.y == mipsize.y - 3)) {
+ val = minmax(val, sampleLowerMip(texelPos + ivec2(2, 2)));
}
- val[1] = sampleLowerMip(texelPos + ivec2(0, -1));
- minmax(val);
- val[1] = sampleLowerMip(texelPos + ivec2(1, -1));
- minmax(val);
+ float val2 = sampleLowerMip(texelPos + ivec2(2, 0));
+ float val3 = sampleLowerMip(texelPos + ivec2(2, 1));
+ val = minmax(val, val2);
+ val = minmax(val, val3);
}
/* if we are reducing an odd-height texture then fetch the edge texels */
- else if (((mipsize.y & 1) != 0) && (int(gl_FragCoord.y) == mipsize.y-3)) {
- val[1] = sampleLowerMip(texelPos + ivec2(0, -1));
- minmax(val);
- val[1] = sampleLowerMip(texelPos + ivec2(1, -1));
- minmax(val);
+ if (((mipsize.y & 1) != 0) && (texelPos.y == mipsize.y - 3)) {
+ float val2 = sampleLowerMip(texelPos + ivec2(0, 2));
+ float val3 = sampleLowerMip(texelPos + ivec2(1, 2));
+ val = minmax(val, val2);
+ val = minmax(val, val3);
}
#endif
- FragMinMax = vec4(val[0], 0.0, 1.0);
+ gl_FragDepth = val;
} \ No newline at end of file
diff --git a/source/blender/draw/engines/eevee/shaders/effect_motion_blur_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_motion_blur_frag.glsl
index 045fcd11fae..1a01db3a1a3 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_motion_blur_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_motion_blur_frag.glsl
@@ -59,7 +59,7 @@ void main()
FragColor = vec4(0.0, 0.0, 0.0, 1.0);
for (int j = 0; j < samples && j < MAX_SAMPLE; j++) {
- FragColor += texture(colorBuffer, uvcoordsvar.xy + motion * i) * inv_samples;
+ FragColor += textureLod(colorBuffer, uvcoordsvar.xy + motion * i, 0.0) * inv_samples;
i += inc;
}
}
diff --git a/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl
new file mode 100644
index 00000000000..7a501964fae
--- /dev/null
+++ b/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl
@@ -0,0 +1,453 @@
+
+/* Based on Stochastic Screen Space Reflections
+ * https://www.ea.com/frostbite/news/stochastic-screen-space-reflections */
+
+#ifndef UTIL_TEX
+#define UTIL_TEX
+uniform sampler2DArray utilTex;
+#endif /* UTIL_TEX */
+
+#define BRDF_BIAS 0.7
+#define MAX_MIP 9.0
+
+uniform float fireflyFactor;
+uniform float maxRoughness;
+
+#ifdef STEP_RAYTRACE
+
+uniform sampler2D normalBuffer;
+uniform sampler2D specroughBuffer;
+
+uniform int planar_count;
+uniform float noiseOffset;
+
+layout(location = 0) out vec4 hitData0;
+layout(location = 1) out vec4 hitData1;
+layout(location = 2) out vec4 hitData2;
+layout(location = 3) out vec4 hitData3;
+
+vec4 do_planar_ssr(int index, vec3 V, vec3 N, vec3 T, vec3 B, vec3 planeNormal, vec3 viewPosition, float a2, vec3 rand, float ofs)
+{
+ float pdf, NH;
+ float jitter = fract(rand.x + ofs);
+
+ /* Importance sampling bias */
+ rand.x = mix(rand.x, 0.0, BRDF_BIAS);
+
+ vec3 H = sample_ggx(rand, a2, N, T, B, NH); /* Microfacet normal */
+ pdf = pdf_ggx_reflect(NH, a2);
+
+ vec3 R = reflect(-V, H);
+ R = reflect(R, planeNormal);
+
+ /* If ray is bad (i.e. going below the plane) regenerate. */
+ if (dot(R, planeNormal) > 0.0) {
+ vec3 H = sample_ggx(rand * vec3(1.0, -1.0, -1.0), a2, N, T, B, NH); /* Microfacet normal */
+ pdf = pdf_ggx_reflect(NH, a2);
+
+ R = reflect(-V, H);
+ R = reflect(R, planeNormal);
+ }
+
+ pdf = min(1024e32, pdf); /* Theoretical limit of 16bit float */
+ pdf *= -1.0; /* Tag as planar ray. */
+
+ /* Since viewspace hit position can land behind the camera in this case,
+ * we save the reflected view position (visualize it as the hit position
+ * below the reflection plane). This way it's garanted that the hit will
+ * be in front of the camera. That let us tag the bad rays with a negative
+ * sign in the Z component. */
+ vec3 hit_pos = raycast(index, viewPosition, R * 1e16, 1e16, jitter, ssrQuality, a2);
+
+ return vec4(hit_pos, pdf);
+}
+
+vec4 do_ssr(vec3 V, vec3 N, vec3 T, vec3 B, vec3 viewPosition, float a2, vec3 rand, float ofs)
+{
+ float pdf, NH;
+ float jitter = fract(rand.x + ofs);
+
+ /* Importance sampling bias */
+ rand.x = mix(rand.x, 0.0, BRDF_BIAS);
+
+ vec3 H = sample_ggx(rand, a2, N, T, B, NH); /* Microfacet normal */
+ pdf = pdf_ggx_reflect(NH, a2);
+
+ vec3 R = reflect(-V, H);
+ pdf = min(1024e32, pdf); /* Theoretical limit of 16bit float */
+
+ vec3 hit_pos = raycast(-1, viewPosition, R * 1e16, ssrThickness, jitter, ssrQuality, a2);
+
+ return vec4(hit_pos, pdf);
+}
+
+void main()
+{
+#ifdef FULLRES
+ ivec2 fullres_texel = ivec2(gl_FragCoord.xy);
+ ivec2 halfres_texel = fullres_texel;
+#else
+ ivec2 fullres_texel = ivec2(gl_FragCoord.xy) * 2;
+ ivec2 halfres_texel = ivec2(gl_FragCoord.xy);
+#endif
+
+ float depth = texelFetch(depthBuffer, fullres_texel, 0).r;
+
+ /* Early out */
+ if (depth == 1.0)
+ discard;
+
+ vec2 uvs = gl_FragCoord.xy / vec2(textureSize(depthBuffer, 0));
+#ifndef FULLRES
+ uvs *= 2.0;
+#endif
+
+ /* Using view space */
+ vec3 viewPosition = get_view_space_from_depth(uvs, depth);
+ vec3 V = viewCameraVec;
+ vec3 N = normal_decode(texelFetch(normalBuffer, fullres_texel, 0).rg, V);
+
+ /* Retrieve pixel data */
+ vec4 speccol_roughness = texelFetch(specroughBuffer, fullres_texel, 0).rgba;
+
+ /* Early out */
+ if (dot(speccol_roughness.rgb, vec3(1.0)) == 0.0)
+ discard;
+
+ float roughness = speccol_roughness.a;
+ float roughnessSquared = max(1e-3, roughness * roughness);
+ float a2 = roughnessSquared * roughnessSquared;
+
+ if (roughness > maxRoughness + 0.2) {
+ hitData0 = hitData1 = hitData2 = hitData3 = vec4(0.0);
+ return;
+ }
+
+ vec3 rand = texelFetch(utilTex, ivec3(halfres_texel % LUT_SIZE, 2), 0).rba;
+
+ vec3 worldPosition = transform_point(ViewMatrixInverse, viewPosition);
+ vec3 wN = transform_direction(ViewMatrixInverse, N);
+
+ vec3 T, B;
+ make_orthonormal_basis(N, T, B); /* Generate tangent space */
+
+ /* Planar Reflections */
+ for (int i = 0; i < MAX_PLANAR && i < planar_count; ++i) {
+ PlanarData pd = planars_data[i];
+
+ float fade = probe_attenuation_planar(pd, worldPosition, wN, 0.0);
+
+ if (fade > 0.5) {
+ /* Find view vector / reflection plane intersection. */
+ /* TODO optimize, use view space for all. */
+ vec3 tracePosition = line_plane_intersect(worldPosition, cameraVec, pd.pl_plane_eq);
+ tracePosition = transform_point(ViewMatrix, tracePosition);
+ vec3 planeNormal = transform_direction(ViewMatrix, pd.pl_normal);
+
+ hitData0 = do_planar_ssr(i, V, N, T, B, planeNormal, tracePosition, a2, rand, 0.0);
+#if (RAY_COUNT > 1)
+ hitData1 = do_planar_ssr(i, V, N, T, B, planeNormal, tracePosition, a2, rand.xyz * vec3(1.0, -1.0, -1.0), 1.0 / float(RAY_COUNT));
+#endif
+#if (RAY_COUNT > 2)
+ hitData2 = do_planar_ssr(i, V, N, T, B, planeNormal, tracePosition, a2, rand.xzy * vec3(1.0, 1.0, -1.0), 2.0 / float(RAY_COUNT));
+#endif
+#if (RAY_COUNT > 3)
+ hitData3 = do_planar_ssr(i, V, N, T, B, planeNormal, tracePosition, a2, rand.xzy * vec3(1.0, -1.0, 1.0), 3.0 / float(RAY_COUNT));
+#endif
+ return;
+ }
+ }
+
+ /* TODO : Raytrace together if textureGather is supported. */
+ hitData0 = do_ssr(V, N, T, B, viewPosition, a2, rand, 0.0);
+#if (RAY_COUNT > 1)
+ hitData1 = do_ssr(V, N, T, B, viewPosition, a2, rand.xyz * vec3(1.0, -1.0, -1.0), 1.0 / float(RAY_COUNT));
+#endif
+#if (RAY_COUNT > 2)
+ hitData2 = do_ssr(V, N, T, B, viewPosition, a2, rand.xzy * vec3(1.0, 1.0, -1.0), 2.0 / float(RAY_COUNT));
+#endif
+#if (RAY_COUNT > 3)
+ hitData3 = do_ssr(V, N, T, B, viewPosition, a2, rand.xzy * vec3(1.0, -1.0, 1.0), 3.0 / float(RAY_COUNT));
+#endif
+}
+
+#else /* STEP_RESOLVE */
+
+uniform sampler2D prevColorBuffer; /* previous frame */
+uniform sampler2D normalBuffer;
+uniform sampler2D specroughBuffer;
+
+uniform sampler2D hitBuffer0;
+uniform sampler2D hitBuffer1;
+uniform sampler2D hitBuffer2;
+uniform sampler2D hitBuffer3;
+
+uniform int probe_count;
+uniform int planar_count;
+
+uniform mat4 PastViewProjectionMatrix;
+
+out vec4 fragColor;
+
+void fallback_cubemap(vec3 N, vec3 V, vec3 W, vec3 viewPosition, float roughness, float roughnessSquared, inout vec4 spec_accum)
+{
+ /* Specular probes */
+ vec3 spec_dir = get_specular_reflection_dominant_dir(N, V, roughnessSquared);
+
+ vec4 rand = texture(utilTex, vec3(gl_FragCoord.xy / LUT_SIZE, 2.0));
+ vec3 bent_normal;
+ float final_ao = occlusion_compute(N, viewPosition, 1.0, rand.rg, bent_normal);
+ final_ao = specular_occlusion(dot(N, V), final_ao, roughness);
+
+ /* Starts at 1 because 0 is world probe */
+ for (int i = 1; i < MAX_PROBE && i < probe_count && spec_accum.a < 0.999; ++i) {
+ CubeData cd = probes_data[i];
+
+ float fade = probe_attenuation_cube(cd, W);
+
+ if (fade > 0.0) {
+ vec3 spec = final_ao * probe_evaluate_cube(float(i), cd, W, spec_dir, roughness);
+ accumulate_light(spec, fade, spec_accum);
+ }
+ }
+
+ /* World Specular */
+ if (spec_accum.a < 0.999) {
+ vec3 spec = final_ao * probe_evaluate_world_spec(spec_dir, roughness);
+ accumulate_light(spec, 1.0, spec_accum);
+ }
+}
+
+#if 0 /* Finish reprojection with motion vectors */
+vec3 get_motion_vector(vec3 pos)
+{
+}
+
+/* http://bitsquid.blogspot.fr/2017/06/reprojecting-reflections_22.html */
+vec3 find_reflection_incident_point(vec3 cam, vec3 hit, vec3 pos, vec3 N)
+{
+ float d_cam = point_plane_projection_dist(cam, pos, N);
+ float d_hit = point_plane_projection_dist(hit, pos, N);
+
+ if (d_hit < d_cam) {
+ /* Swap */
+ float tmp = d_cam;
+ d_cam = d_hit;
+ d_hit = tmp;
+ }
+
+ vec3 proj_cam = cam - (N * d_cam);
+ vec3 proj_hit = hit - (N * d_hit);
+
+ return (proj_hit - proj_cam) * d_cam / (d_cam + d_hit) + proj_cam;
+}
+#endif
+
+float brightness(vec3 c)
+{
+ return max(max(c.r, c.g), c.b);
+}
+
+vec2 get_reprojected_reflection(vec3 hit, vec3 pos, vec3 N)
+{
+ /* TODO real reprojection with motion vectors, etc... */
+ return project_point(PastViewProjectionMatrix, hit).xy * 0.5 + 0.5;
+}
+
+vec4 get_ssr_sample(
+ sampler2D hitBuffer, PlanarData pd, float planar_index, vec3 worldPosition, vec3 N, vec3 V, float roughnessSquared,
+ float cone_tan, vec2 source_uvs, vec2 texture_size, ivec2 target_texel,
+ inout float weight_acc)
+{
+ vec4 hit_co_pdf = texelFetch(hitBuffer, target_texel, 0).rgba;
+ bool has_hit = (hit_co_pdf.z > 0.0);
+ bool is_planar = (hit_co_pdf.w < 0.0);
+ hit_co_pdf.z = abs(hit_co_pdf.z);
+ hit_co_pdf.w = abs(hit_co_pdf.w);
+
+ /* Hit position in world space. */
+ hit_co_pdf.xyz = get_view_space_from_depth(hit_co_pdf.xy, hit_co_pdf.z);
+ vec3 hit_pos = transform_point(ViewMatrixInverse, hit_co_pdf.xyz);
+
+ vec2 ref_uvs;
+ vec3 hit_vec;
+ float mask = 1.0;
+ if (is_planar) {
+ /* Reflect back the hit position to have it in non-reflected world space */
+ vec3 trace_pos = line_plane_intersect(worldPosition, V, pd.pl_plane_eq);
+ hit_vec = hit_pos - trace_pos;
+ hit_vec = reflect(hit_vec, pd.pl_normal);
+ ref_uvs = project_point(ProjectionMatrix, hit_co_pdf.xyz).xy * 0.5 + 0.5;
+ }
+ else {
+ /* Find hit position in previous frame. */
+ ref_uvs = get_reprojected_reflection(hit_pos, worldPosition, N);
+ hit_vec = hit_pos - worldPosition;
+ mask = screen_border_mask(gl_FragCoord.xy / texture_size);
+ }
+ mask = min(mask, screen_border_mask(ref_uvs));
+ mask *= float(has_hit);
+
+ float hit_dist = max(1e-8, length(hit_vec));
+ vec3 L = hit_vec / hit_dist;
+
+ float cone_footprint = hit_dist * cone_tan;
+
+ /* Compute cone footprint in screen space. */
+ float homcoord = ProjectionMatrix[2][3] * hit_co_pdf.z + ProjectionMatrix[3][3];
+ cone_footprint = BRDF_BIAS * 0.5 * cone_footprint * max(ProjectionMatrix[0][0], ProjectionMatrix[1][1]) / homcoord;
+
+ /* Estimate a cone footprint to sample a corresponding mipmap level. */
+ float mip = clamp(log2(cone_footprint * max(texture_size.x, texture_size.y)), 0.0, MAX_MIP);
+
+ /* Correct UVs for mipmaping mis-alignment */
+ ref_uvs *= mip_ratio_interp(mip);
+
+ /* Slide 54 */
+ float bsdf = bsdf_ggx(N, L, V, roughnessSquared);
+ float weight = step(1e-8, hit_co_pdf.w) * bsdf / max(1e-8, hit_co_pdf.w);
+ weight_acc += weight;
+
+ vec3 sample;
+ if (is_planar) {
+ sample = textureLod(probePlanars, vec3(ref_uvs, planar_index), mip).rgb;
+ }
+ else {
+ sample = textureLod(prevColorBuffer, ref_uvs, mip).rgb;
+ }
+
+ /* Clamped brightness. */
+ float luma = max(1e-8, brightness(sample));
+ sample *= 1.0 - max(0.0, luma - fireflyFactor) / luma;
+
+ /* Do not add light if ray has failed. */
+ sample *= float(has_hit);
+
+ /* Protection against NaNs in the history buffer.
+ * This could be removed if some previous pass has already
+ * sanitized the input. */
+ if (any(isnan(sample))) {
+ sample = vec3(0.0);
+ weight = 0.0;
+ }
+
+ return vec4(sample, mask) * weight;
+}
+
+#define NUM_NEIGHBORS 4
+
+void main()
+{
+ ivec2 fullres_texel = ivec2(gl_FragCoord.xy);
+#ifdef FULLRES
+ ivec2 halfres_texel = fullres_texel;
+#else
+ ivec2 halfres_texel = ivec2(gl_FragCoord.xy / 2.0);
+#endif
+ vec2 texture_size = vec2(textureSize(depthBuffer, 0));
+ vec2 uvs = gl_FragCoord.xy / texture_size;
+ vec3 rand = texelFetch(utilTex, ivec3(fullres_texel % LUT_SIZE, 2), 0).rba;
+
+ float depth = textureLod(depthBuffer, uvs, 0.0).r;
+
+ /* Early out */
+ if (depth == 1.0)
+ discard;
+
+ /* Using world space */
+ vec3 viewPosition = get_view_space_from_depth(uvs, depth); /* Needed for viewCameraVec */
+ vec3 worldPosition = transform_point(ViewMatrixInverse, viewPosition);
+ vec3 V = cameraVec;
+ vec3 vN = normal_decode(texelFetch(normalBuffer, fullres_texel, 0).rg, viewCameraVec);
+ vec3 N = transform_direction(ViewMatrixInverse, vN);
+ vec4 speccol_roughness = texelFetch(specroughBuffer, fullres_texel, 0).rgba;
+
+ /* Early out */
+ if (dot(speccol_roughness.rgb, vec3(1.0)) == 0.0)
+ discard;
+
+ /* Find Planar Reflections affecting this pixel */
+ PlanarData pd;
+ float planar_index;
+ for (int i = 0; i < MAX_PLANAR && i < planar_count; ++i) {
+ pd = planars_data[i];
+
+ float fade = probe_attenuation_planar(pd, worldPosition, N, 0.0);
+
+ if (fade > 0.5) {
+ planar_index = float(i);
+ break;
+ }
+ }
+
+ float roughness = speccol_roughness.a;
+ float roughnessSquared = max(1e-3, roughness * roughness);
+
+ vec4 spec_accum = vec4(0.0);
+
+ /* Resolve SSR */
+ float cone_cos = cone_cosine(roughnessSquared);
+ float cone_tan = sqrt(1 - cone_cos * cone_cos) / cone_cos;
+ cone_tan *= mix(saturate(dot(N, -V) * 2.0), 1.0, roughness); /* Elongation fit */
+
+ vec2 source_uvs = project_point(PastViewProjectionMatrix, worldPosition).xy * 0.5 + 0.5;
+
+ vec4 ssr_accum = vec4(0.0);
+ float weight_acc = 0.0;
+ const ivec2 neighbors[9] = ivec2[9](
+ ivec2(0, 0),
+
+ ivec2(0, 1),
+ ivec2(-1, -1), ivec2(1, -1),
+
+ ivec2(-1, 1), ivec2(1, 1),
+ ivec2(0, -1),
+
+ ivec2(-1, 0), ivec2(1, 0)
+ );
+ ivec2 invert_neighbor;
+ invert_neighbor.x = ((fullres_texel.x & 0x1) == 0) ? 1 : -1;
+ invert_neighbor.y = ((fullres_texel.y & 0x1) == 0) ? 1 : -1;
+
+ if (roughness < maxRoughness + 0.2) {
+ for (int i = 0; i < NUM_NEIGHBORS; i++) {
+ ivec2 target_texel = halfres_texel + neighbors[i] * invert_neighbor;
+
+ ssr_accum += get_ssr_sample(hitBuffer0, pd, planar_index, worldPosition, N, V,
+ roughnessSquared, cone_tan, source_uvs,
+ texture_size, target_texel, weight_acc);
+#if (RAY_COUNT > 1)
+ ssr_accum += get_ssr_sample(hitBuffer1, pd, planar_index, worldPosition, N, V,
+ roughnessSquared, cone_tan, source_uvs,
+ texture_size, target_texel, weight_acc);
+#endif
+#if (RAY_COUNT > 2)
+ ssr_accum += get_ssr_sample(hitBuffer2, pd, planar_index, worldPosition, N, V,
+ roughnessSquared, cone_tan, source_uvs,
+ texture_size, target_texel, weight_acc);
+#endif
+#if (RAY_COUNT > 3)
+ ssr_accum += get_ssr_sample(hitBuffer3, pd, planar_index, worldPosition, N, V,
+ roughnessSquared, cone_tan, source_uvs,
+ texture_size, target_texel, weight_acc);
+#endif
+ }
+ }
+
+ /* Compute SSR contribution */
+ if (weight_acc > 0.0) {
+ ssr_accum /= weight_acc;
+ /* fade between 0.5 and 1.0 roughness */
+ ssr_accum.a *= smoothstep(maxRoughness + 0.2, maxRoughness, roughness);
+ accumulate_light(ssr_accum.rgb, ssr_accum.a, spec_accum);
+ }
+
+ /* If SSR contribution is not 1.0, blend with cubemaps */
+ if (spec_accum.a < 1.0) {
+ fallback_cubemap(N, V, worldPosition, viewPosition, roughness, roughnessSquared, spec_accum);
+ }
+
+ fragColor = vec4(spec_accum.rgb * speccol_roughness.rgb, 1.0);
+}
+
+#endif
diff --git a/source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl b/source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl
new file mode 100644
index 00000000000..f3df1864317
--- /dev/null
+++ b/source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl
@@ -0,0 +1,14 @@
+
+uniform sampler2D colorBuffer;
+uniform sampler2D historyBuffer;
+uniform float alpha;
+
+out vec4 FragColor;
+
+void main()
+{
+ /* TODO History buffer Reprojection */
+ vec4 history = texelFetch(historyBuffer, ivec2(gl_FragCoord.xy), 0).rgba;
+ vec4 color = texelFetch(colorBuffer, ivec2(gl_FragCoord.xy), 0).rgba;
+ FragColor = mix(history, color, alpha);
+} \ No newline at end of file
diff --git a/source/blender/draw/engines/eevee/shaders/irradiance_lib.glsl b/source/blender/draw/engines/eevee/shaders/irradiance_lib.glsl
index 0f95d552d1f..95e7af41398 100644
--- a/source/blender/draw/engines/eevee/shaders/irradiance_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/irradiance_lib.glsl
@@ -1,6 +1,8 @@
uniform sampler2D irradianceGrid;
+#define IRRADIANCE_LIB
+
#ifdef IRRADIANCE_CUBEMAP
struct IrradianceData {
vec3 color;
@@ -132,10 +134,8 @@ vec3 compute_irradiance(vec3 N, IrradianceData ird)
#endif
}
-vec3 get_cell_color(ivec3 localpos, ivec3 gridres, int offset, vec3 ir_dir)
+vec3 irradiance_from_cell_get(int cell, vec3 ir_dir)
{
- /* Keep in sync with update_irradiance_probe */
- int cell = offset + localpos.z + localpos.y * gridres.z + localpos.x * gridres.z * gridres.y;
IrradianceData ir_data = load_irradiance_cell(cell, ir_dir);
return compute_irradiance(ir_dir, ir_data);
}
diff --git a/source/blender/draw/engines/eevee/shaders/lamps_lib.glsl b/source/blender/draw/engines/eevee/shaders/lamps_lib.glsl
new file mode 100644
index 00000000000..c879e9c37f3
--- /dev/null
+++ b/source/blender/draw/engines/eevee/shaders/lamps_lib.glsl
@@ -0,0 +1,301 @@
+
+uniform sampler2DArray shadowTexture;
+
+layout(std140) uniform shadow_block {
+ ShadowData shadows_data[MAX_SHADOW];
+ ShadowCubeData shadows_cube_data[MAX_SHADOW_CUBE];
+ ShadowCascadeData shadows_cascade_data[MAX_SHADOW_CASCADE];
+};
+
+layout(std140) uniform light_block {
+ LightData lights_data[MAX_LIGHT];
+};
+
+/* type */
+#define POINT 0.0
+#define SUN 1.0
+#define SPOT 2.0
+#define HEMI 3.0
+#define AREA 4.0
+
+/* ----------------------------------------------------------- */
+/* ----------------------- Shadow tests ---------------------- */
+/* ----------------------------------------------------------- */
+
+float shadow_test_esm(float z, float dist, float exponent)
+{
+ return saturate(exp(exponent * (z - dist)));
+}
+
+float shadow_test_pcf(float z, float dist)
+{
+ return step(0, z - dist);
+}
+
+float shadow_test_vsm(vec2 moments, float dist, float bias, float bleed_bias)
+{
+ float p = 0.0;
+
+ if (dist <= moments.x)
+ p = 1.0;
+
+ float variance = moments.y - (moments.x * moments.x);
+ variance = max(variance, bias / 10.0);
+
+ float d = moments.x - dist;
+ float p_max = variance / (variance + d * d);
+
+ /* Now reduce light-bleeding by removing the [0, x] tail and linearly rescaling (x, 1] */
+ p_max = clamp((p_max - bleed_bias) / (1.0 - bleed_bias), 0.0, 1.0);
+
+ return max(p, p_max);
+}
+
+
+/* ----------------------------------------------------------- */
+/* ----------------------- Shadow types ---------------------- */
+/* ----------------------------------------------------------- */
+
+float shadow_cubemap(ShadowData sd, ShadowCubeData scd, float texid, vec3 W)
+{
+ vec3 cubevec = W - scd.position.xyz;
+ float dist = length(cubevec);
+
+ /* If fragment is out of shadowmap range, do not occlude */
+ /* XXX : we check radial distance against a cubeface distance.
+ * We loose quite a bit of valid area. */
+ if (dist > sd.sh_far)
+ return 1.0;
+
+ cubevec /= dist;
+
+#if defined(SHADOW_VSM)
+ vec2 moments = texture_octahedron(shadowTexture, vec4(cubevec, texid)).rg;
+#else
+ float z = texture_octahedron(shadowTexture, vec4(cubevec, texid)).r;
+#endif
+
+#if defined(SHADOW_VSM)
+ return shadow_test_vsm(moments, dist, sd.sh_bias, sd.sh_bleed);
+#elif defined(SHADOW_ESM)
+ return shadow_test_esm(z, dist - sd.sh_bias, sd.sh_exp);
+#else
+ return shadow_test_pcf(z, dist - sd.sh_bias);
+#endif
+}
+
+float evaluate_cascade(ShadowData sd, mat4 shadowmat, vec3 W, float range, float texid)
+{
+ vec4 shpos = shadowmat * vec4(W, 1.0);
+ float dist = shpos.z * range;
+
+#if defined(SHADOW_VSM)
+ vec2 moments = texture(shadowTexture, vec3(shpos.xy, texid)).rg;
+#else
+ float z = texture(shadowTexture, vec3(shpos.xy, texid)).r;
+#endif
+
+ float vis;
+#if defined(SHADOW_VSM)
+ vis = shadow_test_vsm(moments, dist, sd.sh_bias, sd.sh_bleed);
+#elif defined(SHADOW_ESM)
+ vis = shadow_test_esm(z, dist - sd.sh_bias, sd.sh_exp);
+#else
+ vis = shadow_test_pcf(z, dist - sd.sh_bias);
+#endif
+
+ /* If fragment is out of shadowmap range, do not occlude */
+ if (shpos.z < 1.0 && shpos.z > 0.0) {
+ return vis;
+ }
+ else {
+ return 1.0;
+ }
+}
+
+float shadow_cascade(ShadowData sd, ShadowCascadeData scd, float texid, vec3 W)
+{
+ vec4 view_z = vec4(dot(W - cameraPos, cameraForward));
+ vec4 weights = smoothstep(scd.split_end_distances, scd.split_start_distances.yzwx, view_z);
+ weights.yzw -= weights.xyz;
+
+ vec4 vis = vec4(1.0);
+ float range = abs(sd.sh_far - sd.sh_near); /* Same factor as in get_cascade_world_distance(). */
+
+ /* Branching using (weights > 0.0) is reaally slooow on intel so avoid it for now. */
+ vis.x = evaluate_cascade(sd, scd.shadowmat[0], W, range, texid + 0);
+ vis.y = evaluate_cascade(sd, scd.shadowmat[1], W, range, texid + 1);
+ vis.z = evaluate_cascade(sd, scd.shadowmat[2], W, range, texid + 2);
+ vis.w = evaluate_cascade(sd, scd.shadowmat[3], W, range, texid + 3);
+
+ float weight_sum = dot(vec4(1.0), weights);
+ if (weight_sum > 0.9999) {
+ float vis_sum = dot(vec4(1.0), vis * weights);
+ return vis_sum / weight_sum;
+ }
+ else {
+ float vis_sum = dot(vec4(1.0), vis * step(0.001, weights));
+ return mix(1.0, vis_sum, weight_sum);
+ }
+}
+
+/* ----------------------------------------------------------- */
+/* --------------------- Light Functions --------------------- */
+/* ----------------------------------------------------------- */
+#define MAX_MULTI_SHADOW 4
+
+float light_visibility(LightData ld, vec3 W,
+#ifndef VOLUMETRICS
+ vec3 viewPosition,
+ vec3 viewNormal,
+#endif
+ vec4 l_vector)
+{
+ float vis = 1.0;
+
+ if (ld.l_type == SPOT) {
+ float z = dot(ld.l_forward, l_vector.xyz);
+ vec3 lL = l_vector.xyz / z;
+ float x = dot(ld.l_right, lL) / ld.l_sizex;
+ float y = dot(ld.l_up, lL) / ld.l_sizey;
+
+ float ellipse = 1.0 / sqrt(1.0 + x * x + y * y);
+
+ float spotmask = smoothstep(0.0, 1.0, (ellipse - ld.l_spot_size) / ld.l_spot_blend);
+
+ vis *= spotmask;
+ vis *= step(0.0, -dot(l_vector.xyz, ld.l_forward));
+ }
+ else if (ld.l_type == AREA) {
+ vis *= step(0.0, -dot(l_vector.xyz, ld.l_forward));
+ }
+
+#if !defined(VOLUMETRICS) || defined(VOLUME_SHADOW)
+ /* shadowing */
+ if (ld.l_shadowid >= 0.0) {
+ ShadowData data = shadows_data[int(ld.l_shadowid)];
+
+ if (ld.l_type == SUN) {
+ /* TODO : MSM */
+ // for (int i = 0; i < MAX_MULTI_SHADOW; ++i) {
+ vis *= shadow_cascade(
+ data, shadows_cascade_data[int(data.sh_data_start)],
+ data.sh_tex_start, W);
+ // }
+ }
+ else {
+ /* TODO : MSM */
+ // for (int i = 0; i < MAX_MULTI_SHADOW; ++i) {
+ vis *= shadow_cubemap(
+ data, shadows_cube_data[int(data.sh_data_start)],
+ data.sh_tex_start, W);
+ // }
+ }
+
+#ifndef VOLUMETRICS
+ /* Only compute if not already in shadow. */
+ if ((vis > 0.001) && (data.sh_contact_dist > 0.0)) {
+ vec4 L = (ld.l_type != SUN) ? l_vector : vec4(-ld.l_forward, 1.0);
+ float trace_distance = (ld.l_type != SUN) ? min(data.sh_contact_dist, l_vector.w) : data.sh_contact_dist;
+
+ vec3 T, B;
+ make_orthonormal_basis(L.xyz / L.w, T, B);
+
+ vec3 rand = texture(utilTex, vec3(gl_FragCoord.xy / LUT_SIZE, 2.0)).xzw;
+ rand.yz *= rand.x * data.sh_contact_spread;
+
+ /* We use the full l_vector.xyz so that the spread is minimize
+ * if the shading point is further away from the light source */
+ vec3 ray_dir = L.xyz + T * rand.y + B * rand.z;
+ ray_dir = transform_direction(ViewMatrix, ray_dir);
+ ray_dir = normalize(ray_dir);
+ vec3 ray_origin = viewPosition + viewNormal * data.sh_contact_offset;
+ vec3 hit_pos = raycast(-1, ray_origin, ray_dir * trace_distance, data.sh_contact_thickness, rand.x, 0.75, 0.01);
+
+ if (hit_pos.z > 0.0) {
+ hit_pos = get_view_space_from_depth(hit_pos.xy, hit_pos.z);
+ float hit_dist = distance(viewPosition, hit_pos);
+ float dist_ratio = hit_dist / trace_distance;
+ return mix(0.0, vis, dist_ratio * dist_ratio * dist_ratio);
+ }
+ }
+#endif
+ }
+#endif
+
+ return vis;
+}
+
+float light_diffuse(LightData ld, vec3 N, vec3 V, vec4 l_vector)
+{
+#ifdef USE_LTC
+ if (ld.l_type == SUN) {
+ /* TODO disk area light */
+ return direct_diffuse_sun(ld, N);
+ }
+ else if (ld.l_type == AREA) {
+ return direct_diffuse_rectangle(ld, N, V, l_vector);
+ }
+ else {
+ return direct_diffuse_sphere(ld, N, l_vector);
+ }
+#else
+ if (ld.l_type == SUN) {
+ return direct_diffuse_sun(ld, N, V);
+ }
+ else {
+ return direct_diffuse_point(N, l_vector);
+ }
+#endif
+}
+
+vec3 light_specular(LightData ld, vec3 N, vec3 V, vec4 l_vector, float roughness, vec3 f0)
+{
+#ifdef USE_LTC
+ if (ld.l_type == SUN) {
+ /* TODO disk area light */
+ return direct_ggx_sun(ld, N, V, roughness, f0);
+ }
+ else if (ld.l_type == AREA) {
+ return direct_ggx_rectangle(ld, N, V, l_vector, roughness, f0);
+ }
+ else {
+ return direct_ggx_sphere(ld, N, V, l_vector, roughness, f0);
+ }
+#else
+ if (ld.l_type == SUN) {
+ return direct_ggx_sun(ld, N, V, roughness, f0);
+ }
+ else {
+ return direct_ggx_point(N, V, l_vector, roughness, f0);
+ }
+#endif
+}
+
+#ifdef HAIR_SHADER
+void light_hair_common(
+ LightData ld, vec3 N, vec3 V, vec4 l_vector, vec3 norm_view,
+ out float occlu_trans, out float occlu,
+ out vec3 norm_lamp, out vec3 view_vec)
+{
+ const float transmission = 0.3; /* Uniform internal scattering factor */
+
+ vec3 lamp_vec;
+
+ if (ld.l_type == SUN || ld.l_type == AREA) {
+ lamp_vec = ld.l_forward;
+ }
+ else {
+ lamp_vec = -l_vector.xyz;
+ }
+
+ norm_lamp = cross(lamp_vec, N);
+ norm_lamp = normalize(cross(N, norm_lamp)); /* Normal facing lamp */
+
+ /* Rotate view vector onto the cross(tangent, light) plane */
+ view_vec = normalize(norm_lamp * dot(norm_view, V) + N * dot(N, V));
+
+ occlu = (dot(norm_view, norm_lamp) * 0.5 + 0.5);
+ occlu_trans = transmission + (occlu * (1.0 - transmission)); /* Includes transmission component */
+}
+#endif
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_frag.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_frag.glsl
index d651a866433..fc0b5b9548b 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_frag.glsl
@@ -1,24 +1,15 @@
-uniform mat4 ProjectionMatrix;
-uniform mat4 ViewMatrixInverse;
-
-uniform sampler2DArray probeCubes;
-uniform float lodMax;
-
flat in int pid;
in vec3 worldNormal;
in vec3 worldPosition;
out vec4 FragColor;
-#define cameraForward normalize(ViewMatrixInverse[2].xyz)
-#define cameraPos ViewMatrixInverse[3].xyz
-
void main()
{
vec3 V = (ProjectionMatrix[3][3] == 0.0) /* if perspective */
? normalize(cameraPos - worldPosition)
: cameraForward;
vec3 N = normalize(worldNormal);
- FragColor = vec4(textureLod_octahedron(probeCubes, vec4(reflect(-V, N), pid), 0.0, lodMax).rgb, 1.0);
+ FragColor = vec4(textureLod_octahedron(probeCubes, vec4(reflect(-V, N), pid), 0.0, lodCubeMax).rgb, 1.0);
}
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_vert.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_vert.glsl
index b943a59feeb..202b27be0ef 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_vert.glsl
@@ -1,6 +1,5 @@
in vec3 pos;
-in vec3 nor;
/* Instance attrib */
in int probe_id;
@@ -16,7 +15,14 @@ out vec3 worldPosition;
void main()
{
pid = probe_id;
- worldPosition = pos * 0.1 * sphere_size + probe_location;
- gl_Position = ViewProjectionMatrix * vec4(worldPosition, 1.0);
- worldNormal = normalize(nor);
+
+ /* While this is not performant, we do this to
+ * match the object mode engine instancing shader. */
+ mat4 offsetmat = mat4(1.0); /* Identity */
+ offsetmat[3].xyz = probe_location;
+
+ vec4 wpos = offsetmat * vec4(pos * sphere_size, 1.0);
+ worldPosition = wpos.xyz;
+ gl_Position = ViewProjectionMatrix * wpos;
+ worldNormal = normalize(pos);
} \ No newline at end of file
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_geom.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_geom.glsl
index ee5983d523a..7e63f4cdaf7 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_geom.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_geom.glsl
@@ -6,22 +6,27 @@ uniform int Layer;
in vec4 vPos[];
flat in int face[];
+flat out int fFace;
out vec3 worldPosition;
out vec3 viewPosition; /* Required. otherwise generate linking error. */
out vec3 worldNormal; /* Required. otherwise generate linking error. */
+out vec3 viewNormal; /* Required. otherwise generate linking error. */
const vec3 maj_axes[6] = vec3[6](vec3(1.0, 0.0, 0.0), vec3(-1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), vec3(0.0, -1.0, 0.0), vec3( 0.0, 0.0, 1.0), vec3( 0.0, 0.0, -1.0));
const vec3 x_axis[6] = vec3[6](vec3(0.0, 0.0, -1.0), vec3( 0.0, 0.0, 1.0), vec3(1.0, 0.0, 0.0), vec3(1.0, 0.0, 0.0), vec3( 1.0, 0.0, 0.0), vec3(-1.0, 0.0, 0.0));
const vec3 y_axis[6] = vec3[6](vec3(0.0, -1.0, 0.0), vec3( 0.0, -1.0, 0.0), vec3(0.0, 0.0, 1.0), vec3(0.0, 0.0, -1.0), vec3( 0.0, -1.0, 0.0), vec3( 0.0, -1.0, 0.0));
void main() {
- int f = face[0];
- gl_Layer = Layer + f;
+ fFace = face[0];
+ gl_Layer = Layer + fFace;
for (int v = 0; v < 3; ++v) {
gl_Position = vPos[v];
- worldPosition = x_axis[f] * vPos[v].x + y_axis[f] * vPos[v].y + maj_axes[f];
+ worldPosition = x_axis[fFace] * vPos[v].x + y_axis[fFace] * vPos[v].y + maj_axes[fFace];
+#ifdef ATTRIB
+ pass_attrib(v);
+#endif
EmitVertex();
}
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl
index 121859c98f1..fd200ec5984 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl
@@ -1,6 +1,5 @@
in vec3 pos;
-in vec3 nor;
uniform mat4 ViewProjectionMatrix;
@@ -31,5 +30,5 @@ void main()
increment_z * ls_cell_location.z);
gl_Position = ViewProjectionMatrix * vec4(pos * 0.02 * sphere_size + ws_cell_location, 1.0);
- worldNormal = normalize(nor);
+ worldNormal = normalize(pos);
} \ No newline at end of file
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_grid_fill_frag.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_grid_fill_frag.glsl
new file mode 100644
index 00000000000..cea1ca5e7b0
--- /dev/null
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_grid_fill_frag.glsl
@@ -0,0 +1,20 @@
+uniform sampler2D gridTexture;
+
+out vec4 FragColor;
+
+void main()
+{
+#if defined(IRRADIANCE_SH_L2)
+ const ivec2 data_size = ivec2(3, 3);
+#elif defined(IRRADIANCE_CUBEMAP)
+ const ivec2 data_size = ivec2(8, 8);
+#elif defined(IRRADIANCE_HL2)
+ const ivec2 data_size = ivec2(3, 2);
+#endif
+ ivec2 coord = ivec2(gl_FragCoord.xy) % data_size;
+ FragColor = texelFetch(gridTexture, coord, 0);
+
+ if (any(greaterThanEqual(ivec2(gl_FragCoord.xy), data_size))) {
+ FragColor = vec4(0.0, 0.0, 0.0, 1.0);
+ }
+} \ No newline at end of file
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl
new file mode 100644
index 00000000000..834bacc118b
--- /dev/null
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl
@@ -0,0 +1,254 @@
+/* ----------- Uniforms --------- */
+
+uniform sampler2DArray probePlanars;
+uniform float lodPlanarMax;
+
+uniform sampler2DArray probeCubes;
+uniform float lodCubeMax;
+
+/* ----------- Structures --------- */
+
+struct CubeData {
+ vec4 position_type;
+ vec4 attenuation_fac_type;
+ mat4 influencemat;
+ mat4 parallaxmat;
+};
+
+#define PROBE_PARALLAX_BOX 1.0
+#define PROBE_ATTENUATION_BOX 1.0
+
+#define p_position position_type.xyz
+#define p_parallax_type position_type.w
+#define p_atten_fac attenuation_fac_type.x
+#define p_atten_type attenuation_fac_type.y
+
+struct PlanarData {
+ vec4 plane_equation;
+ vec4 clip_vec_x_fade_scale;
+ vec4 clip_vec_y_fade_bias;
+ vec4 clip_edges;
+ vec4 facing_scale_bias;
+ mat4 reflectionmat; /* transform world space into reflection texture space */
+};
+
+#define pl_plane_eq plane_equation
+#define pl_normal plane_equation.xyz
+#define pl_facing_scale facing_scale_bias.x
+#define pl_facing_bias facing_scale_bias.y
+#define pl_fade_scale clip_vec_x_fade_scale.w
+#define pl_fade_bias clip_vec_y_fade_bias.w
+#define pl_clip_pos_x clip_vec_x_fade_scale.xyz
+#define pl_clip_pos_y clip_vec_y_fade_bias.xyz
+#define pl_clip_edges clip_edges
+
+struct GridData {
+ mat4 localmat;
+ ivec4 resolution_offset;
+ vec4 ws_corner_atten_scale; /* world space corner position */
+ vec4 ws_increment_x_atten_bias; /* world space vector between 2 opposite cells */
+ vec4 ws_increment_y_lvl_bias;
+ vec4 ws_increment_z;
+};
+
+#define g_corner ws_corner_atten_scale.xyz
+#define g_atten_scale ws_corner_atten_scale.w
+#define g_atten_bias ws_increment_x_atten_bias.w
+#define g_level_bias ws_increment_y_lvl_bias.w
+#define g_increment_x ws_increment_x_atten_bias.xyz
+#define g_increment_y ws_increment_y_lvl_bias.xyz
+#define g_increment_z ws_increment_z.xyz
+#define g_resolution resolution_offset.xyz
+#define g_offset resolution_offset.w
+
+#ifndef MAX_PROBE
+#define MAX_PROBE 1
+#endif
+#ifndef MAX_GRID
+#define MAX_GRID 1
+#endif
+#ifndef MAX_PLANAR
+#define MAX_PLANAR 1
+#endif
+
+layout(std140) uniform probe_block {
+ CubeData probes_data[MAX_PROBE];
+};
+
+layout(std140) uniform grid_block {
+ GridData grids_data[MAX_GRID];
+};
+
+layout(std140) uniform planar_block {
+ PlanarData planars_data[MAX_PLANAR];
+};
+
+/* ----------- Functions --------- */
+
+float probe_attenuation_cube(CubeData pd, vec3 W)
+{
+ vec3 localpos = transform_point(pd.influencemat, W);
+
+ float fac;
+ if (pd.p_atten_type == PROBE_ATTENUATION_BOX) {
+ vec3 axes_fac = saturate(pd.p_atten_fac - pd.p_atten_fac * abs(localpos));
+ fac = min_v3(axes_fac);
+ }
+ else {
+ fac = saturate(pd.p_atten_fac - pd.p_atten_fac * length(localpos));
+ }
+
+ return fac;
+}
+
+float probe_attenuation_planar(PlanarData pd, vec3 W, vec3 N, float roughness)
+{
+ /* Normal Facing */
+ float fac = saturate(dot(pd.pl_normal, N) * pd.pl_facing_scale + pd.pl_facing_bias);
+
+ /* Distance from plane */
+ fac *= saturate(abs(dot(pd.pl_plane_eq, vec4(W, 1.0))) * pd.pl_fade_scale + pd.pl_fade_bias);
+
+ /* Fancy fast clipping calculation */
+ vec2 dist_to_clip;
+ dist_to_clip.x = dot(pd.pl_clip_pos_x, W);
+ dist_to_clip.y = dot(pd.pl_clip_pos_y, W);
+ fac *= step(2.0, dot(step(pd.pl_clip_edges, dist_to_clip.xxyy), vec2(-1.0, 1.0).xyxy)); /* compare and add all tests */
+
+ /* Decrease influence for high roughness */
+ fac *= saturate(1.0 - roughness * 10.0);
+
+ return fac;
+}
+
+float probe_attenuation_grid(GridData gd, vec3 W, out vec3 localpos)
+{
+ localpos = transform_point(gd.localmat, W);
+
+ float fade = min(1.0, min_v3(1.0 - abs(localpos)));
+ return saturate(fade * gd.g_atten_scale + gd.g_atten_bias);
+}
+
+vec3 probe_evaluate_cube(float id, CubeData cd, vec3 W, vec3 R, float roughness)
+{
+ /* Correct reflection ray using parallax volume intersection. */
+ vec3 localpos = transform_point(cd.parallaxmat, W);
+ vec3 localray = transform_direction(cd.parallaxmat, R);
+
+ float dist;
+ if (cd.p_parallax_type == PROBE_PARALLAX_BOX) {
+ dist = line_unit_box_intersect_dist(localpos, localray);
+ }
+ else {
+ dist = line_unit_sphere_intersect_dist(localpos, localray);
+ }
+
+ /* Use Distance in WS directly to recover intersection */
+ vec3 intersection = W + R * dist - cd.p_position;
+
+ /* From Frostbite PBR Course
+ * Distance based roughness
+ * http://www.frostbite.com/wp-content/uploads/2014/11/course_notes_moving_frostbite_to_pbr.pdf */
+ float original_roughness = roughness;
+ float linear_roughness = sqrt(roughness);
+ float distance_roughness = saturate(dist * linear_roughness / length(intersection));
+ linear_roughness = mix(distance_roughness, linear_roughness, linear_roughness);
+ roughness = linear_roughness * linear_roughness;
+
+ float fac = saturate(original_roughness * 2.0 - 1.0);
+ R = mix(intersection, R, fac * fac);
+
+ return textureLod_octahedron(probeCubes, vec4(R, id), roughness * lodCubeMax, lodCubeMax).rgb;
+}
+
+vec3 probe_evaluate_world_spec(vec3 R, float roughness)
+{
+ return textureLod_octahedron(probeCubes, vec4(R, 0.0), roughness * lodCubeMax, lodCubeMax).rgb;
+}
+
+vec3 probe_evaluate_planar(
+ float id, PlanarData pd, vec3 W, vec3 N, vec3 V,
+ float roughness, inout float fade)
+{
+ /* Find view vector / reflection plane intersection. */
+ vec3 point_on_plane = line_plane_intersect(W, V, pd.pl_plane_eq);
+
+ /* How far the pixel is from the plane. */
+ float ref_depth = 1.0; /* TODO parameter */
+
+ /* Compute distorded reflection vector based on the distance to the reflected object.
+ * In other words find intersection between reflection vector and the sphere center
+ * around point_on_plane. */
+ vec3 proj_ref = reflect(reflect(-V, N) * ref_depth, pd.pl_normal);
+
+ /* Final point in world space. */
+ vec3 ref_pos = point_on_plane + proj_ref;
+
+ /* Reproject to find texture coords. */
+ vec4 refco = ViewProjectionMatrix * vec4(ref_pos, 1.0);
+ refco.xy /= refco.w;
+
+ /* TODO: If we support non-ssr planar reflection, we should blur them with gaussian
+ * and chose the right mip depending on the cone footprint after projection */
+ vec3 sample = textureLod(probePlanars, vec3(refco.xy * 0.5 + 0.5, id), 0.0).rgb;
+
+ return sample;
+}
+
+#ifdef IRRADIANCE_LIB
+vec3 probe_evaluate_grid(GridData gd, vec3 W, vec3 N, vec3 localpos)
+{
+ localpos = localpos * 0.5 + 0.5;
+ localpos = localpos * vec3(gd.g_resolution) - 0.5;
+
+ vec3 localpos_floored = floor(localpos);
+ vec3 trilinear_weight = fract(localpos);
+
+ float weight_accum = 0.0;
+ vec3 irradiance_accum = vec3(0.0);
+
+ /* For each neighboor cells */
+ for (int i = 0; i < 8; ++i) {
+ ivec3 offset = ivec3(i, i >> 1, i >> 2) & ivec3(1);
+ vec3 cell_cos = clamp(localpos_floored + vec3(offset), vec3(0.0), vec3(gd.g_resolution) - 1.0);
+
+ /* Keep in sync with update_irradiance_probe */
+ ivec3 icell_cos = ivec3(gd.g_level_bias * floor(cell_cos / gd.g_level_bias));
+ int cell = gd.g_offset + icell_cos.z
+ + icell_cos.y * gd.g_resolution.z
+ + icell_cos.x * gd.g_resolution.z * gd.g_resolution.y;
+
+ vec3 color = irradiance_from_cell_get(cell, N);
+
+ /* We need this because we render probes in world space (so we need light vector in WS).
+ * And rendering them in local probe space is too much problem. */
+ vec3 ws_cell_location = gd.g_corner +
+ (gd.g_increment_x * cell_cos.x +
+ gd.g_increment_y * cell_cos.y +
+ gd.g_increment_z * cell_cos.z);
+
+ // vec3 ws_point_to_cell = ws_cell_location - W;
+ // vec3 ws_light = normalize(ws_point_to_cell);
+
+ vec3 trilinear = mix(1 - trilinear_weight, trilinear_weight, offset);
+ float weight = trilinear.x * trilinear.y * trilinear.z;
+
+ /* Smooth backface test */
+ // weight *= sqrt(max(0.002, dot(ws_light, N)));
+
+ /* Avoid zero weight */
+ weight = max(0.00001, weight);
+
+ weight_accum += weight;
+ irradiance_accum += color * weight;
+ }
+
+ return irradiance_accum / weight_accum;
+}
+
+vec3 probe_evaluate_world_diff(vec3 N)
+{
+ return irradiance_from_cell_get(0, N);
+}
+
+#endif /* IRRADIANCE_LIB */
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_frag.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_frag.glsl
index 338dc3bf9c0..655cc626bba 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_frag.glsl
@@ -1,30 +1,15 @@
-uniform int probeIdx;
+uniform mat4 ViewProjectionMatrix;
uniform sampler2DArray probePlanars;
-layout(std140) uniform planar_block {
- PlanarData planars_data[MAX_PLANAR];
-};
-
in vec3 worldPosition;
+flat in int probeIdx;
out vec4 FragColor;
void main()
{
- PlanarData pd = planars_data[probeIdx];
-
- /* Fancy fast clipping calculation */
- vec2 dist_to_clip;
- dist_to_clip.x = dot(pd.pl_clip_pos_x, worldPosition);
- dist_to_clip.y = dot(pd.pl_clip_pos_y, worldPosition);
- float fac = dot(step(pd.pl_clip_edges, dist_to_clip.xxyy), vec2(-1.0, 1.0).xyxy); /* compare and add all tests */
-
- if (fac != 2.0) {
- discard;
- }
-
- vec4 refco = pd.reflectionmat * vec4(worldPosition, 1.0);
+ vec4 refco = ViewProjectionMatrix * vec4(worldPosition, 1.0);
refco.xy /= refco.w;
- FragColor = vec4(textureLod(probePlanars, vec3(refco.xy, float(probeIdx)), 0.0).rgb, 1.0);
+ FragColor = vec4(textureLod(probePlanars, vec3(refco.xy * 0.5 + 0.5, float(probeIdx)), 0.0).rgb, 1.0);
}
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_vert.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_vert.glsl
index 3c620982273..a9716332eb5 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_vert.glsl
@@ -1,13 +1,17 @@
in vec3 pos;
-uniform mat4 ModelViewProjectionMatrix;
-uniform mat4 ModelMatrix;
+in int probe_id;
+in mat4 probe_mat;
+
+uniform mat4 ViewProjectionMatrix;
out vec3 worldPosition;
+flat out int probeIdx;
void main()
{
- gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
- worldPosition = (ModelMatrix * vec4(pos, 1.0)).xyz;
+ gl_Position = ViewProjectionMatrix * probe_mat * vec4(pos, 1.0);
+ worldPosition = (probe_mat * vec4(pos, 1.0)).xyz;
+ probeIdx = probe_id;
} \ No newline at end of file
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_planar_downsample_frag.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_planar_downsample_frag.glsl
new file mode 100644
index 00000000000..3b3abdef00c
--- /dev/null
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_planar_downsample_frag.glsl
@@ -0,0 +1,40 @@
+/**
+ * Simple downsample shader. Takes the average of the 4 texels of lower mip.
+ **/
+
+uniform sampler2DArray source;
+uniform float fireflyFactor;
+
+in vec2 uvs;
+flat in float layer;
+
+out vec4 FragColor;
+
+float brightness(vec3 c)
+{
+ return max(max(c.r, c.g), c.b);
+}
+
+void main()
+{
+#if 0
+ /* Reconstructing Target uvs like this avoid missing pixels if NPO2 */
+ vec2 uvs = gl_FragCoord.xy * 2.0 / vec2(textureSize(source, 0));
+
+ FragColor = textureLod(source, vec3(uvs, layer), 0.0);
+#else
+ vec2 texel_size = 1.0 / vec2(textureSize(source, 0));
+ vec2 uvs = gl_FragCoord.xy * 2.0 * texel_size;
+ vec4 ofs = texel_size.xyxy * vec4(0.75, 0.75, -0.75, -0.75);
+
+ FragColor = textureLod(source, vec3(uvs + ofs.xy, layer), 0.0);
+ FragColor += textureLod(source, vec3(uvs + ofs.xw, layer), 0.0);
+ FragColor += textureLod(source, vec3(uvs + ofs.zy, layer), 0.0);
+ FragColor += textureLod(source, vec3(uvs + ofs.zw, layer), 0.0);
+ FragColor *= 0.25;
+
+ /* Clamped brightness. */
+ float luma = max(1e-8, brightness(FragColor.rgb));
+ FragColor *= 1.0 - max(0.0, luma - fireflyFactor) / luma;
+#endif
+} \ No newline at end of file
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_planar_downsample_geom.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_planar_downsample_geom.glsl
new file mode 100644
index 00000000000..40b04c986f3
--- /dev/null
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_planar_downsample_geom.glsl
@@ -0,0 +1,24 @@
+
+layout(triangles) in;
+layout(triangle_strip, max_vertices=3) out;
+
+in int instance[];
+in vec2 vPos[];
+
+flat out float layer;
+
+void main() {
+ gl_Layer = instance[0];
+ layer = float(instance[0]);
+
+ gl_Position = vec4(vPos[0], 0.0, 0.0);
+ EmitVertex();
+
+ gl_Position = vec4(vPos[1], 0.0, 0.0);
+ EmitVertex();
+
+ gl_Position = vec4(vPos[2], 0.0, 0.0);
+ EmitVertex();
+
+ EndPrimitive();
+} \ No newline at end of file
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_planar_downsample_vert.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_planar_downsample_vert.glsl
new file mode 100644
index 00000000000..ac4e3da4158
--- /dev/null
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_planar_downsample_vert.glsl
@@ -0,0 +1,10 @@
+
+in vec2 pos;
+
+out int instance;
+out vec2 vPos;
+
+void main() {
+ instance = gl_InstanceID;
+ vPos = pos;
+} \ No newline at end of file
diff --git a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl b/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
index 5b6f30a116b..f63a9665810 100644
--- a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
@@ -3,45 +3,17 @@ uniform int light_count;
uniform int probe_count;
uniform int grid_count;
uniform int planar_count;
-uniform mat4 ViewMatrix;
-uniform mat4 ViewMatrixInverse;
-uniform sampler2DArray probePlanars;
-
-uniform sampler2DArray probeCubes;
-uniform float lodMax;
uniform bool specToggle;
+uniform bool ssrToggle;
+
+uniform float refractionDepth;
#ifndef UTIL_TEX
#define UTIL_TEX
uniform sampler2DArray utilTex;
#endif /* UTIL_TEX */
-uniform sampler2DArray shadowCubes;
-uniform sampler2DArrayShadow shadowCascades;
-
-layout(std140) uniform probe_block {
- ProbeData probes_data[MAX_PROBE];
-};
-
-layout(std140) uniform grid_block {
- GridData grids_data[MAX_GRID];
-};
-
-layout(std140) uniform planar_block {
- PlanarData planars_data[MAX_PLANAR];
-};
-
-layout(std140) uniform light_block {
- LightData lights_data[MAX_LIGHT];
-};
-
-layout(std140) uniform shadow_block {
- ShadowCubeData shadows_cube_data[MAX_SHADOW_CUBE];
- ShadowMapData shadows_map_data[MAX_SHADOW_MAP];
- ShadowCascadeData shadows_cascade_data[MAX_SHADOW_CASCADE];
-};
-
in vec3 worldPosition;
in vec3 viewPosition;
@@ -53,470 +25,788 @@ in vec3 worldNormal;
in vec3 viewNormal;
#endif
-#define cameraForward normalize(ViewMatrixInverse[2].xyz)
-#define cameraPos ViewMatrixInverse[3].xyz
+uniform float maxRoughness;
+uniform int rayCount;
-/* type */
-#define POINT 0.0
-#define SUN 1.0
-#define SPOT 2.0
-#define HEMI 3.0
-#define AREA 4.0
+/* ----------- default ----------- */
-#ifdef HAIR_SHADER
-vec3 light_diffuse(LightData ld, ShadingData sd, vec3 albedo)
+vec3 eevee_surface_lit(vec3 N, vec3 albedo, vec3 f0, float roughness, float ao, int ssr_id, out vec3 ssr_spec)
{
- if (ld.l_type == SUN) {
- return direct_diffuse_sun(ld, sd) * albedo;
- }
- else if (ld.l_type == AREA) {
- return direct_diffuse_rectangle(ld, sd) * albedo;
- }
- else {
- return direct_diffuse_sphere(ld, sd) * albedo;
- }
-}
+ /* Zero length vectors cause issues, see: T51979. */
+#if 0
+ N = normalize(N);
+#else
+ {
+ float len = length(N);
+ if (isnan(len)) {
+ return vec3(0.0);
+ }
+ N /= len;
+ }
+#endif
-vec3 light_specular(LightData ld, ShadingData sd, float roughness, vec3 f0)
-{
- if (ld.l_type == SUN) {
- return direct_ggx_sun(ld, sd, roughness, f0);
- }
- else if (ld.l_type == AREA) {
- return direct_ggx_rectangle(ld, sd, roughness, f0);
- }
- else {
- return direct_ggx_sphere(ld, sd, roughness, f0);
- }
-}
+ roughness = clamp(roughness, 1e-8, 0.9999);
+ float roughnessSquared = roughness * roughness;
-void light_shade(
- LightData ld, ShadingData sd, vec3 albedo, float roughness, vec3 f0,
- out vec3 diffuse, out vec3 specular)
-{
- const float transmission = 0.3; /* Uniform internal scattering factor */
- ShadingData sd_new = sd;
+ vec3 V = cameraVec;
- vec3 lamp_vec;
+ /* ---------------- SCENE LAMPS LIGHTING ----------------- */
- if (ld.l_type == SUN || ld.l_type == AREA) {
- lamp_vec = ld.l_forward;
- }
- else {
- lamp_vec = -sd.l_vector;
- }
+#ifdef HAIR_SHADER
+ vec3 norm_view = cross(V, N);
+ norm_view = normalize(cross(norm_view, N)); /* Normal facing view */
+#endif
- vec3 norm_view = cross(sd.V, sd.N);
- norm_view = normalize(cross(norm_view, sd.N)); /* Normal facing view */
+ vec3 diff = vec3(0.0);
+ vec3 spec = vec3(0.0);
+ for (int i = 0; i < MAX_LIGHT && i < light_count; ++i) {
+ LightData ld = lights_data[i];
- vec3 norm_lamp = cross(lamp_vec, sd.N);
- norm_lamp = normalize(cross(sd.N, norm_lamp)); /* Normal facing lamp */
+ vec4 l_vector; /* Non-Normalized Light Vector with length in last component. */
+ l_vector.xyz = ld.l_position - worldPosition;
+ l_vector.w = length(l_vector.xyz);
- /* Rotate view vector onto the cross(tangent, light) plane */
- vec3 view_vec = normalize(norm_lamp * dot(norm_view, sd.V) + sd.N * dot(sd.N, sd.V));
+ vec3 l_color_vis = ld.l_color * light_visibility(ld, worldPosition, viewPosition, viewNormal, l_vector);
- float occlusion = (dot(norm_view, norm_lamp) * 0.5 + 0.5);
- float occltrans = transmission + (occlusion * (1.0 - transmission)); /* Includes transmission component */
+#ifdef HAIR_SHADER
+ vec3 norm_lamp, view_vec;
+ float occlu_trans, occlu;
+ light_hair_common(ld, N, V, l_vector, norm_view, occlu_trans, occlu, norm_lamp, view_vec);
- sd_new.N = -norm_lamp;
+ diff += l_color_vis * light_diffuse(ld, -norm_lamp, V, l_vector) * occlu_trans;
+ spec += l_color_vis * light_specular(ld, N, view_vec, l_vector, roughnessSquared, f0) * occlu;
+#else
+ diff += l_color_vis * light_diffuse(ld, N, V, l_vector);
+ spec += l_color_vis * light_specular(ld, N, V, l_vector, roughnessSquared, f0);
+#endif
+ }
- diffuse = light_diffuse(ld, sd_new, albedo) * occltrans;
+ /* Accumulate outgoing radiance */
+ vec3 out_light = diff * albedo + spec * float(specToggle);
- sd_new.V = view_vec;
+#ifdef HAIR_SHADER
+ N = -norm_view;
+#endif
- specular = light_specular(ld, sd_new, roughness, f0) * occlusion;
-}
-#else
-void light_shade(
- LightData ld, ShadingData sd, vec3 albedo, float roughness, vec3 f0,
- out vec3 diffuse, out vec3 specular)
-{
-#ifdef USE_LTC
- if (ld.l_type == SUN) {
- /* TODO disk area light */
- diffuse = direct_diffuse_sun(ld, sd) * albedo;
- specular = direct_ggx_sun(ld, sd, roughness, f0);
+ /* ---------------- SPECULAR ENVIRONMENT LIGHTING ----------------- */
+
+ /* Accumulate light from all sources until accumulator is full. Then apply Occlusion and BRDF. */
+ vec4 spec_accum = vec4(0.0);
+
+ /* SSR lobe is applied later in a defered style */
+ if (!(ssrToggle && ssr_id == outputSsrId)) {
+ /* Planar Reflections */
+ for (int i = 0; i < MAX_PLANAR && i < planar_count && spec_accum.a < 0.999; ++i) {
+ PlanarData pd = planars_data[i];
+
+ float fade = probe_attenuation_planar(pd, worldPosition, N, roughness);
+
+ if (fade > 0.0) {
+ vec3 spec = probe_evaluate_planar(float(i), pd, worldPosition, N, V, roughness, fade);
+ accumulate_light(spec, fade, spec_accum);
+ }
+ }
+
+ /* Specular probes */
+ vec3 spec_dir = get_specular_reflection_dominant_dir(N, V, roughnessSquared);
+
+ /* Starts at 1 because 0 is world probe */
+ for (int i = 1; i < MAX_PROBE && i < probe_count && spec_accum.a < 0.999; ++i) {
+ CubeData cd = probes_data[i];
+
+ float fade = probe_attenuation_cube(cd, worldPosition);
+
+ if (fade > 0.0) {
+ vec3 spec = probe_evaluate_cube(float(i), cd, worldPosition, spec_dir, roughness);
+ accumulate_light(spec, fade, spec_accum);
+ }
+ }
+
+ /* World Specular */
+ if (spec_accum.a < 0.999) {
+ vec3 spec = probe_evaluate_world_spec(spec_dir, roughness);
+ accumulate_light(spec, 1.0, spec_accum);
+ }
}
- else if (ld.l_type == AREA) {
- diffuse = direct_diffuse_rectangle(ld, sd) * albedo;
- specular = direct_ggx_rectangle(ld, sd, roughness, f0);
+
+ vec4 rand = texture(utilTex, vec3(gl_FragCoord.xy / LUT_SIZE, 2.0));
+
+ /* Ambient Occlusion */
+ vec3 bent_normal;
+ float final_ao = occlusion_compute(N, viewPosition, ao, rand.rg, bent_normal);
+
+ /* Get Brdf intensity */
+ vec2 uv = lut_coords(dot(N, V), roughness);
+ vec2 brdf_lut = texture(utilTex, vec3(uv, 1.0)).rg;
+
+ ssr_spec = F_ibl(f0, brdf_lut);
+ if (!(ssrToggle && ssr_id == outputSsrId)) {
+ ssr_spec *= specular_occlusion(dot(N, V), final_ao, roughness);
}
- else {
- diffuse = direct_diffuse_sphere(ld, sd) * albedo;
- specular = direct_ggx_sphere(ld, sd, roughness, f0);
+ out_light += spec_accum.rgb * ssr_spec * float(specToggle);
+
+ /* ---------------- DIFFUSE ENVIRONMENT LIGHTING ----------------- */
+
+ /* Accumulate light from all sources until accumulator is full. Then apply Occlusion and BRDF. */
+ vec4 diff_accum = vec4(0.0);
+
+ /* Start at 1 because 0 is world irradiance */
+ for (int i = 1; i < MAX_GRID && i < grid_count && diff_accum.a < 0.999; ++i) {
+ GridData gd = grids_data[i];
+
+ vec3 localpos;
+ float fade = probe_attenuation_grid(gd, worldPosition, localpos);
+
+ if (fade > 0.0) {
+ vec3 diff = probe_evaluate_grid(gd, worldPosition, bent_normal, localpos);
+ accumulate_light(diff, fade, diff_accum);
+ }
}
-#else
- if (ld.l_type == SUN) {
- diffuse = direct_diffuse_sun(ld, sd) * albedo;
- specular = direct_ggx_sun(ld, sd, roughness, f0);
+
+ /* World Diffuse */
+ if (diff_accum.a < 0.999 && grid_count > 0) {
+ vec3 diff = probe_evaluate_world_diff(bent_normal);
+ accumulate_light(diff, 1.0, diff_accum);
}
- else {
- diffuse = direct_diffuse_point(ld, sd) * albedo;
- specular = direct_ggx_point(sd, roughness, f0);
+
+ out_light += diff_accum.rgb * albedo * gtao_multibounce(final_ao, albedo);
+
+ return out_light;
+}
+
+/* ----------- CLEAR COAT ----------- */
+
+vec3 eevee_surface_clearcoat_lit(
+ vec3 N, vec3 albedo, vec3 f0, float roughness,
+ vec3 C_N, float C_intensity, float C_roughness, /* Clearcoat params */
+ float ao, int ssr_id, out vec3 ssr_spec)
+{
+ roughness = clamp(roughness, 1e-8, 0.9999);
+ float roughnessSquared = roughness * roughness;
+ C_roughness = clamp(C_roughness, 1e-8, 0.9999);
+ float C_roughnessSquared = C_roughness * C_roughness;
+
+ /* Zero length vectors cause issues, see: T51979. */
+#if 0
+ N = normalize(N);
+ C_N = normalize(C_N);
+#else
+ {
+ float len = length(N);
+ if (isnan(len)) {
+ return vec3(0.0);
+ }
+ N /= len;
+
+ len = length(C_N);
+ if (isnan(len)) {
+ return vec3(0.0);
+ }
+ C_N /= len;
}
#endif
- specular *= float(specToggle);
-}
+ vec3 V = cameraVec;
+
+ /* ---------------- SCENE LAMPS LIGHTING ----------------- */
+
+#ifdef HAIR_SHADER
+ vec3 norm_view = cross(V, N);
+ norm_view = normalize(cross(norm_view, N)); /* Normal facing view */
#endif
-void light_visibility(LightData ld, ShadingData sd, out float vis)
-{
- vis = 1.0;
+ vec3 diff = vec3(0.0);
+ vec3 spec = vec3(0.0);
+ for (int i = 0; i < MAX_LIGHT && i < light_count; ++i) {
+ LightData ld = lights_data[i];
- if (ld.l_type == SPOT) {
- float z = dot(ld.l_forward, sd.l_vector);
- vec3 lL = sd.l_vector / z;
- float x = dot(ld.l_right, lL) / ld.l_sizex;
- float y = dot(ld.l_up, lL) / ld.l_sizey;
+ vec4 l_vector; /* Non-Normalized Light Vector with length in last component. */
+ l_vector.xyz = ld.l_position - worldPosition;
+ l_vector.w = length(l_vector.xyz);
- float ellipse = 1.0 / sqrt(1.0 + x * x + y * y);
+ vec3 l_color_vis = ld.l_color * light_visibility(ld, worldPosition, viewPosition, viewNormal, l_vector);
- float spotmask = smoothstep(0.0, 1.0, (ellipse - ld.l_spot_size) / ld.l_spot_blend);
+#ifdef HAIR_SHADER
+ vec3 norm_lamp, view_vec;
+ float occlu_trans, occlu;
+ light_hair_common(ld, N, V, l_vector, norm_view, occlu_trans, occlu, norm_lamp, view_vec);
- vis *= spotmask;
- vis *= step(0.0, -dot(sd.l_vector, ld.l_forward));
- }
- else if (ld.l_type == AREA) {
- vis *= step(0.0, -dot(sd.l_vector, ld.l_forward));
+ diff += l_color_vis * light_diffuse(ld, -norm_lamp, V, l_vector) * occlu_trans;
+ spec += l_color_vis * light_specular(ld, N, view_vec, l_vector, roughnessSquared, f0) * occlu;
+ spec += l_color_vis * light_specular(ld, C_N, view_vec, l_vector, C_roughnessSquared, f0) * C_intensity * occlu;
+#else
+ diff += l_color_vis * light_diffuse(ld, N, V, l_vector);
+ spec += l_color_vis * light_specular(ld, N, V, l_vector, roughnessSquared, f0);
+ spec += l_color_vis * light_specular(ld, C_N, V, l_vector, C_roughnessSquared, f0) * C_intensity;
+#endif
}
- /* shadowing */
- if (ld.l_shadowid >= (MAX_SHADOW_MAP + MAX_SHADOW_CUBE)) {
- /* Shadow Cascade */
- float shid = ld.l_shadowid - (MAX_SHADOW_CUBE + MAX_SHADOW_MAP);
- ShadowCascadeData smd = shadows_cascade_data[int(shid)];
+ /* Accumulate outgoing radiance */
+ vec3 out_light = diff * albedo + spec * float(specToggle);
- /* Finding Cascade index */
- vec4 z = vec4(-dot(cameraPos - worldPosition, cameraForward));
- vec4 comp = step(z, smd.split_distances);
- float cascade = dot(comp, comp);
- mat4 shadowmat;
- float bias;
+#ifdef HAIR_SHADER
+ N = -norm_view;
+#endif
- /* Manual Unrolling of a loop for better performance.
- * Doing fetch directly with cascade index leads to
- * major performance impact. (0.27ms -> 10.0ms for 1 light) */
- if (cascade == 0.0) {
- shadowmat = smd.shadowmat[0];
- bias = smd.bias[0];
- }
- else if (cascade == 1.0) {
- shadowmat = smd.shadowmat[1];
- bias = smd.bias[1];
- }
- else if (cascade == 2.0) {
- shadowmat = smd.shadowmat[2];
- bias = smd.bias[2];
- }
- else {
- shadowmat = smd.shadowmat[3];
- bias = smd.bias[3];
- }
+ /* ---------------- SPECULAR ENVIRONMENT LIGHTING ----------------- */
+
+ /* Accumulate light from all sources until accumulator is full. Then apply Occlusion and BRDF. */
+ vec4 spec_accum = vec4(0.0);
+ vec4 C_spec_accum = vec4(0.0);
- vec4 shpos = shadowmat * vec4(sd.W, 1.0);
- shpos.z -= bias * shpos.w;
- shpos.xyz /= shpos.w;
+ /* Planar Reflections */
+ for (int i = 0; i < MAX_PLANAR && i < planar_count && spec_accum.a < 0.999; ++i) {
+ PlanarData pd = planars_data[i];
- vis *= texture(shadowCascades, vec4(shpos.xy, shid * float(MAX_CASCADE_NUM) + cascade, shpos.z));
+ /* Fade on geometric normal. */
+ float fade = probe_attenuation_planar(pd, worldPosition, worldNormal, roughness);
+
+ if (fade > 0.0) {
+ if (!(ssrToggle && ssr_id == outputSsrId)) {
+ vec3 spec = probe_evaluate_planar(float(i), pd, worldPosition, N, V, roughness, fade);
+ accumulate_light(spec, fade, spec_accum);
+ }
+
+ vec3 C_spec = probe_evaluate_planar(float(i), pd, worldPosition, C_N, V, C_roughness, fade);
+ accumulate_light(C_spec, fade, C_spec_accum);
+ }
}
- else if (ld.l_shadowid >= 0.0) {
- /* Shadow Cube */
- float shid = ld.l_shadowid;
- ShadowCubeData scd = shadows_cube_data[int(shid)];
- vec3 cubevec = sd.W - ld.l_position;
- float dist = length(cubevec) - scd.sh_cube_bias;
+ /* Specular probes */
+ vec3 spec_dir = get_specular_reflection_dominant_dir(N, V, roughnessSquared);
+ vec3 C_spec_dir = get_specular_reflection_dominant_dir(C_N, V, C_roughnessSquared);
- float z = texture_octahedron(shadowCubes, vec4(cubevec, shid)).r;
+ /* Starts at 1 because 0 is world probe */
+ for (int i = 1; i < MAX_PROBE && i < probe_count && spec_accum.a < 0.999; ++i) {
+ CubeData cd = probes_data[i];
- float esm_test = saturate(exp(scd.sh_cube_exp * (z - dist)));
- float sh_test = step(0, z - dist);
+ float fade = probe_attenuation_cube(cd, worldPosition);
- vis *= esm_test;
+ if (fade > 0.0) {
+ if (!(ssrToggle && ssr_id == outputSsrId)) {
+ vec3 spec = probe_evaluate_cube(float(i), cd, worldPosition, spec_dir, roughness);
+ accumulate_light(spec, fade, spec_accum);
+ }
+
+ vec3 C_spec = probe_evaluate_cube(float(i), cd, worldPosition, C_spec_dir, C_roughness);
+ accumulate_light(C_spec, fade, C_spec_accum);
+ }
}
-}
-vec3 probe_parallax_correction(vec3 W, vec3 spec_dir, ProbeData pd, inout float roughness)
-{
- vec3 localpos = (pd.parallaxmat * vec4(W, 1.0)).xyz;
- vec3 localray = (pd.parallaxmat * vec4(spec_dir, 0.0)).xyz;
+ /* World Specular */
+ if (spec_accum.a < 0.999) {
+ if (!(ssrToggle && ssr_id == outputSsrId)) {
+ vec3 spec = probe_evaluate_world_spec(spec_dir, roughness);
+ accumulate_light(spec, 1.0, spec_accum);
+ }
- float dist;
- if (pd.p_parallax_type == PROBE_PARALLAX_BOX) {
- dist = line_unit_box_intersect_dist(localpos, localray);
+ vec3 C_spec = probe_evaluate_world_spec(C_spec_dir, C_roughness);
+ accumulate_light(C_spec, 1.0, C_spec_accum);
}
- else {
- dist = line_unit_sphere_intersect_dist(localpos, localray);
+
+ vec4 rand = texture(utilTex, vec3(gl_FragCoord.xy / LUT_SIZE, 2.0));
+
+ /* Ambient Occlusion */
+ vec3 bent_normal;
+ float final_ao = occlusion_compute(N, viewPosition, ao, rand.rg, bent_normal);
+
+ /* Get Brdf intensity */
+ vec2 uv = lut_coords(dot(N, V), roughness);
+ vec2 brdf_lut = texture(utilTex, vec3(uv, 1.0)).rg;
+
+ ssr_spec = F_ibl(f0, brdf_lut);
+ if (!(ssrToggle && ssr_id == outputSsrId)) {
+ ssr_spec *= specular_occlusion(dot(N, V), final_ao, roughness);
}
+ out_light += spec_accum.rgb * ssr_spec * float(specToggle);
- /* Use Distance in WS directly to recover intersection */
- vec3 intersection = W + spec_dir * dist - pd.p_position;
+ uv = lut_coords(dot(C_N, V), C_roughness);
+ brdf_lut = texture(utilTex, vec3(uv, 1.0)).rg;
- /* From Frostbite PBR Course
- * Distance based roughness
- * http://www.frostbite.com/wp-content/uploads/2014/11/course_notes_moving_frostbite_to_pbr.pdf */
- float original_roughness = roughness;
- float linear_roughness = sqrt(roughness);
- float distance_roughness = saturate(dist * linear_roughness / length(intersection));
- linear_roughness = mix(distance_roughness, linear_roughness, linear_roughness);
- roughness = linear_roughness * linear_roughness;
+ out_light += C_spec_accum.rgb * F_ibl(vec3(0.04), brdf_lut) * specular_occlusion(dot(C_N, V), final_ao, C_roughness) * float(specToggle) * C_intensity;
- float fac = saturate(original_roughness * 2.0 - 1.0);
- return mix(intersection, spec_dir, fac * fac);
-}
+ /* ---------------- DIFFUSE ENVIRONMENT LIGHTING ----------------- */
-float probe_attenuation(vec3 W, ProbeData pd)
-{
- vec3 localpos = (pd.influencemat * vec4(W, 1.0)).xyz;
+ /* Accumulate light from all sources until accumulator is full. Then apply Occlusion and BRDF. */
+ vec4 diff_accum = vec4(0.0);
+
+ /* Start at 1 because 0 is world irradiance */
+ for (int i = 1; i < MAX_GRID && i < grid_count && diff_accum.a < 0.999; ++i) {
+ GridData gd = grids_data[i];
- float fac;
- if (pd.p_atten_type == PROBE_ATTENUATION_BOX) {
- vec3 axes_fac = saturate(pd.p_atten_fac - pd.p_atten_fac * abs(localpos));
- fac = min_v3(axes_fac);
+ vec3 localpos;
+ float fade = probe_attenuation_grid(gd, worldPosition, localpos);
+
+ if (fade > 0.0) {
+ vec3 diff = probe_evaluate_grid(gd, worldPosition, bent_normal, localpos);
+ accumulate_light(diff, fade, diff_accum);
+ }
}
- else {
- fac = saturate(pd.p_atten_fac - pd.p_atten_fac * length(localpos));
+
+ /* World Diffuse */
+ if (diff_accum.a < 0.999 && grid_count > 0) {
+ vec3 diff = probe_evaluate_world_diff(bent_normal);
+ accumulate_light(diff, 1.0, diff_accum);
}
- return fac;
+ out_light += diff_accum.rgb * albedo * gtao_multibounce(final_ao, albedo);
+
+ return out_light;
}
-float planar_attenuation(vec3 W, vec3 N, PlanarData pd)
+/* ----------- Diffuse ----------- */
+
+vec3 eevee_surface_diffuse_lit(vec3 N, vec3 albedo, float ao)
{
- float fac;
+ vec3 V = cameraVec;
- /* Normal Facing */
- fac = saturate(dot(pd.pl_normal, N) * pd.pl_facing_scale + pd.pl_facing_bias);
+ /* Zero length vectors cause issues, see: T51979. */
+#if 0
+ N = normalize(N);
+#else
+ {
+ float len = length(N);
+ if (isnan(len)) {
+ return vec3(0.0);
+ }
+ N /= len;
+ }
+#endif
- /* Distance from plane */
- fac *= saturate(abs(dot(pd.pl_plane_eq, vec4(W, 1.0))) * pd.pl_fade_scale + pd.pl_fade_bias);
+ /* ---------------- SCENE LAMPS LIGHTING ----------------- */
- /* Fancy fast clipping calculation */
- vec2 dist_to_clip;
- dist_to_clip.x = dot(pd.pl_clip_pos_x, W);
- dist_to_clip.y = dot(pd.pl_clip_pos_y, W);
- fac *= step(2.0, dot(step(pd.pl_clip_edges, dist_to_clip.xxyy), vec2(-1.0, 1.0).xyxy)); /* compare and add all tests */
+#ifdef HAIR_SHADER
+ vec3 norm_view = cross(V, N);
+ norm_view = normalize(cross(norm_view, N)); /* Normal facing view */
+#endif
- return fac;
-}
+ vec3 diff = vec3(0.0);
+ for (int i = 0; i < MAX_LIGHT && i < light_count; ++i) {
+ LightData ld = lights_data[i];
-float compute_occlusion(vec3 N, float micro_occlusion, vec2 randuv, out vec3 bent_normal)
-{
-#ifdef USE_AO /* Screen Space Occlusion */
+ vec4 l_vector; /* Non-Normalized Light Vector with length in last component. */
+ l_vector.xyz = ld.l_position - worldPosition;
+ l_vector.w = length(l_vector.xyz);
+
+ vec3 l_color_vis = ld.l_color * light_visibility(ld, worldPosition, viewPosition, viewNormal, l_vector);
- float macro_occlusion;
- vec3 vnor = mat3(ViewMatrix) * N;
+#ifdef HAIR_SHADER
+ vec3 norm_lamp, view_vec;
+ float occlu_trans, occlu;
+ light_hair_common(ld, N, V, l_vector, norm_view, occlu_trans, occlu, norm_lamp, view_vec);
-#ifdef USE_BENT_NORMAL
- gtao(vnor, viewPosition, randuv, macro_occlusion, bent_normal);
- bent_normal = mat3(ViewMatrixInverse) * bent_normal;
+ diff += l_color_vis * light_diffuse(ld, -norm_lamp, V, l_vector) * occlu_trans;
#else
- gtao(vnor, viewPosition, randuv, macro_occlusion);
- bent_normal = N;
+ diff += l_color_vis * light_diffuse(ld, N, V, l_vector);
#endif
- return min(macro_occlusion, micro_occlusion);
-
-#else /* No added Occlusion. */
+ }
- bent_normal = N;
- return micro_occlusion;
+ /* Accumulate outgoing radiance */
+ vec3 out_light = diff * albedo;
+#ifdef HAIR_SHADER
+ N = -norm_view;
#endif
+
+ /* ---------------- DIFFUSE ENVIRONMENT LIGHTING ----------------- */
+
+ vec4 rand = texture(utilTex, vec3(gl_FragCoord.xy / LUT_SIZE, 2.0));
+
+ /* Ambient Occlusion */
+ vec3 bent_normal;
+ float final_ao = occlusion_compute(N, viewPosition, ao, rand.rg, bent_normal);
+
+ /* Accumulate light from all sources until accumulator is full. Then apply Occlusion and BRDF. */
+ vec4 diff_accum = vec4(0.0);
+
+ /* Start at 1 because 0 is world irradiance */
+ for (int i = 1; i < MAX_GRID && i < grid_count && diff_accum.a < 0.999; ++i) {
+ GridData gd = grids_data[i];
+
+ vec3 localpos;
+ float fade = probe_attenuation_grid(gd, worldPosition, localpos);
+
+ if (fade > 0.0) {
+ vec3 diff = probe_evaluate_grid(gd, worldPosition, bent_normal, localpos);
+ accumulate_light(diff, fade, diff_accum);
+ }
+ }
+
+ /* World Diffuse */
+ if (diff_accum.a < 0.999 && grid_count > 0) {
+ vec3 diff = probe_evaluate_world_diff(bent_normal);
+ accumulate_light(diff, 1.0, diff_accum);
+ }
+
+ out_light += diff_accum.rgb * albedo * gtao_multibounce(final_ao, albedo);
+
+ return out_light;
}
-vec3 eevee_surface_lit(vec3 world_normal, vec3 albedo, vec3 f0, float roughness, float ao)
+/* ----------- Glossy ----------- */
+
+vec3 eevee_surface_glossy_lit(vec3 N, vec3 f0, float roughness, float ao, int ssr_id, out vec3 ssr_spec)
{
roughness = clamp(roughness, 1e-8, 0.9999);
float roughnessSquared = roughness * roughness;
- ShadingData sd;
- sd.N = normalize(world_normal);
- sd.V = (ProjectionMatrix[3][3] == 0.0) /* if perspective */
- ? normalize(cameraPos - worldPosition)
- : cameraForward;
- sd.W = worldPosition;
+ vec3 V = cameraVec;
- vec3 radiance = vec3(0.0);
+ /* Zero length vectors cause issues, see: T51979. */
+#if 0
+ N = normalize(N);
+#else
+ {
+ float len = length(N);
+ if (isnan(len)) {
+ return vec3(0.0);
+ }
+ N /= len;
+ }
+#endif
+
+ /* ---------------- SCENE LAMPS LIGHTING ----------------- */
#ifdef HAIR_SHADER
- /* View facing normal */
- vec3 norm_view = cross(sd.V, sd.N);
- norm_view = normalize(cross(norm_view, sd.N)); /* Normal facing view */
+ vec3 norm_view = cross(V, N);
+ norm_view = normalize(cross(norm_view, N)); /* Normal facing view */
#endif
-
- /* Analytic Lights */
+ vec3 spec = vec3(0.0);
for (int i = 0; i < MAX_LIGHT && i < light_count; ++i) {
LightData ld = lights_data[i];
- vec3 diff, spec;
- float vis = 1.0;
- sd.l_vector = ld.l_position - worldPosition;
+ vec4 l_vector; /* Non-Normalized Light Vector with length in last component. */
+ l_vector.xyz = ld.l_position - worldPosition;
+ l_vector.w = length(l_vector.xyz);
-#ifndef HAIR_SHADER
- light_visibility(ld, sd, vis);
-#endif
- light_shade(ld, sd, albedo, roughnessSquared, f0, diff, spec);
+ vec3 l_color_vis = ld.l_color * light_visibility(ld, worldPosition, viewPosition, viewNormal, l_vector);
- radiance += vis * (diff + spec) * ld.l_color;
+#ifdef HAIR_SHADER
+ vec3 norm_lamp, view_vec;
+ float occlu_trans, occlu;
+ light_hair_common(ld, N, V, l_vector, norm_view, occlu_trans, occlu, norm_lamp, view_vec);
+
+ spec += l_color_vis * light_specular(ld, N, view_vec, l_vector, roughnessSquared, f0) * occlu;
+#else
+ spec += l_color_vis * light_specular(ld, N, V, l_vector, roughnessSquared, f0);
+#endif
}
+ /* Accumulate outgoing radiance */
+ vec3 out_light = spec * float(specToggle);
+
#ifdef HAIR_SHADER
- sd.N = -norm_view;
+ N = -norm_view;
#endif
- vec3 bent_normal;
- vec4 rand = textureLod(utilTex, vec3(gl_FragCoord.xy / LUT_SIZE, 2.0), 0.0).rgba;
- float final_ao = compute_occlusion(sd.N, ao, rand.rg, bent_normal);
-
- /* Envmaps */
- vec3 R = reflect(-sd.V, sd.N);
- vec3 spec_dir = get_specular_dominant_dir(sd.N, R, roughnessSquared);
- vec2 uv = lut_coords(dot(sd.N, sd.V), roughness);
- vec2 brdf_lut = texture(utilTex, vec3(uv, 1.0)).rg;
+ /* ---------------- SPECULAR ENVIRONMENT LIGHTING ----------------- */
+ /* Accumulate light from all sources until accumulator is full. Then apply Occlusion and BRDF. */
vec4 spec_accum = vec4(0.0);
- vec4 diff_accum = vec4(0.0);
- /* Planar Reflections */
- for (int i = 0; i < MAX_PLANAR && i < planar_count && spec_accum.a < 0.999; ++i) {
- PlanarData pd = planars_data[i];
+ if (!(ssrToggle && ssr_id == outputSsrId)) {
+ /* Planar Reflections */
+ for (int i = 0; i < MAX_PLANAR && i < planar_count && spec_accum.a < 0.999; ++i) {
+ PlanarData pd = planars_data[i];
+
+ float fade = probe_attenuation_planar(pd, worldPosition, N, roughness);
+
+ if (fade > 0.0) {
+ vec3 spec = probe_evaluate_planar(float(i), pd, worldPosition, N, V, roughness, fade);
+ accumulate_light(spec, fade, spec_accum);
+ }
+ }
+
+ /* Specular probes */
+ vec3 spec_dir = get_specular_reflection_dominant_dir(N, V, roughnessSquared);
- float influence = planar_attenuation(sd.W, sd.N, pd);
+ /* Starts at 1 because 0 is world probe */
+ for (int i = 1; i < MAX_PROBE && i < probe_count && spec_accum.a < 0.999; ++i) {
+ CubeData cd = probes_data[i];
- if (influence > 0.0) {
- float influ_spec = min(influence, (1.0 - spec_accum.a));
+ float fade = probe_attenuation_cube(cd, worldPosition);
- /* Sample reflection depth. */
- vec4 refco = pd.reflectionmat * vec4(sd.W, 1.0);
- refco.xy /= refco.w;
- float ref_depth = textureLod(probePlanars, vec3(refco.xy, i), 0.0).a;
+ if (fade > 0.0) {
+ vec3 spec = probe_evaluate_cube(float(i), cd, worldPosition, spec_dir, roughness);
+ accumulate_light(spec, fade, spec_accum);
+ }
+ }
+
+ /* World Specular */
+ if (spec_accum.a < 0.999) {
+ vec3 spec = probe_evaluate_world_spec(spec_dir, roughness);
+ accumulate_light(spec, 1.0, spec_accum);
+ }
+ }
- /* Find view vector / reflection plane intersection. (dist_to_plane is negative) */
- float dist_to_plane = line_plane_intersect_dist(cameraPos, sd.V, pd.pl_plane_eq);
- vec3 point_on_plane = cameraPos + sd.V * dist_to_plane;
+ vec4 rand = texture(utilTex, vec3(gl_FragCoord.xy / LUT_SIZE, 2.0));
- /* How far the pixel is from the plane. */
- ref_depth = ref_depth + dist_to_plane;
+ /* Get Brdf intensity */
+ vec2 uv = lut_coords(dot(N, V), roughness);
+ vec2 brdf_lut = texture(utilTex, vec3(uv, 1.0)).rg;
- /* Compute distorded reflection vector based on the distance to the reflected object.
- * In other words find intersection between reflection vector and the sphere center
- * around point_on_plane. */
- vec3 proj_ref = reflect(R * ref_depth, pd.pl_normal);
+ ssr_spec = F_ibl(f0, brdf_lut);
+ if (!(ssrToggle && ssr_id == outputSsrId)) {
+ /* Ambient Occlusion */
+ vec3 bent_normal;
+ float final_ao = occlusion_compute(N, viewPosition, ao, rand.rg, bent_normal);
- /* Final point in world space. */
- vec3 ref_pos = point_on_plane + proj_ref;
+ ssr_spec *= specular_occlusion(dot(N, V), final_ao, roughness);
+ }
+ out_light += spec_accum.rgb * ssr_spec * float(specToggle);
- /* Reproject to find texture coords. */
- refco = pd.reflectionmat * vec4(ref_pos, 1.0);
- refco.xy /= refco.w;
+ return out_light;
+}
- vec3 sample = textureLod(probePlanars, vec3(refco.xy, i), 0.0).rgb;
+/* ----------- Transmission ----------- */
- spec_accum.rgb += sample * influ_spec;
- spec_accum.a += influ_spec;
+vec3 eevee_surface_refraction(vec3 N, vec3 f0, float roughness, float ior)
+{
+ /* Zero length vectors cause issues, see: T51979. */
+#if 0
+ N = normalize(N);
+#else
+ {
+ float len = length(N);
+ if (isnan(len)) {
+ return vec3(0.0);
}
+ N /= len;
}
+#endif
+ vec3 V = cameraVec;
+ ior = (gl_FrontFacing) ? ior : 1.0 / ior;
+
+ roughness = clamp(roughness, 1e-8, 0.9999);
+ float roughnessSquared = roughness * roughness;
+
+ /* ---------------- SCENE LAMPS LIGHTING ----------------- */
+
+ /* No support for now. Supporting LTCs mean having a 3D LUT.
+ * We could support point lights easily though. */
+
+ /* ---------------- SPECULAR ENVIRONMENT LIGHTING ----------------- */
+
+ /* Accumulate light from all sources until accumulator is full. Then apply Occlusion and BRDF. */
+ vec4 trans_accum = vec4(0.0);
+
+ /* Refract the view vector using the depth heuristic.
+ * Then later Refract a second time the already refracted
+ * ray using the inverse ior. */
+ float final_ior = (refractionDepth > 0.0) ? 1.0 / ior : ior;
+ vec3 refr_V = (refractionDepth > 0.0) ? -refract(-V, N, final_ior) : V;
+ vec3 refr_pos = (refractionDepth > 0.0) ? line_plane_intersect(worldPosition, refr_V, worldPosition - N * refractionDepth, N) : worldPosition;
+
+#ifdef USE_REFRACTION
+ /* Screen Space Refraction */
+ if (ssrToggle && roughness < maxRoughness + 0.2) {
+ vec3 rand = texture(utilTex, vec3(gl_FragCoord.xy / LUT_SIZE, 2.0)).xzw;
+
+ /* Find approximated position of the 2nd refraction event. */
+ vec3 refr_vpos = (refractionDepth > 0.0) ? transform_point(ViewMatrix, refr_pos) : viewPosition;
+
+ float ray_ofs = 1.0 / float(rayCount);
+ vec4 spec = screen_space_refraction(refr_vpos, N, refr_V, final_ior, roughnessSquared, rand, 0.0);
+ if (rayCount > 1) spec += screen_space_refraction(refr_vpos, N, refr_V, final_ior, roughnessSquared, rand.xyz * vec3(1.0, -1.0, -1.0), 1.0 * ray_ofs);
+ if (rayCount > 2) spec += screen_space_refraction(refr_vpos, N, refr_V, final_ior, roughnessSquared, rand.xzy * vec3(1.0, 1.0, -1.0), 2.0 * ray_ofs);
+ if (rayCount > 3) spec += screen_space_refraction(refr_vpos, N, refr_V, final_ior, roughnessSquared, rand.xzy * vec3(1.0, -1.0, 1.0), 3.0 * ray_ofs);
+ spec /= float(rayCount);
+ spec.a *= smoothstep(maxRoughness + 0.2, maxRoughness, roughness);
+ accumulate_light(spec.rgb, spec.a, trans_accum);
+ }
+#endif
/* Specular probes */
- /* Start at 1 because 0 is world probe */
- for (int i = 1; i < MAX_PROBE && i < probe_count && spec_accum.a < 0.999; ++i) {
- ProbeData pd = probes_data[i];
+ /* NOTE: This bias the IOR */
+ vec3 refr_dir = get_specular_refraction_dominant_dir(N, refr_V, roughness, final_ior);
- float dist_attenuation = probe_attenuation(sd.W, pd);
+ /* Starts at 1 because 0 is world probe */
+ for (int i = 1; i < MAX_PROBE && i < probe_count && trans_accum.a < 0.999; ++i) {
+ CubeData cd = probes_data[i];
- if (dist_attenuation > 0.0) {
- float roughness_copy = roughness;
+ float fade = probe_attenuation_cube(cd, worldPosition);
- vec3 sample_vec = probe_parallax_correction(sd.W, spec_dir, pd, roughness_copy);
- vec4 sample = textureLod_octahedron(probeCubes, vec4(sample_vec, i), roughness_copy * lodMax, lodMax).rgba;
+ if (fade > 0.0) {
+ vec3 spec = probe_evaluate_cube(float(i), cd, refr_pos, refr_dir, roughnessSquared);
+ accumulate_light(spec, fade, trans_accum);
+ }
+ }
+
+ /* World Specular */
+ if (trans_accum.a < 0.999) {
+ vec3 spec = probe_evaluate_world_spec(refr_dir, roughnessSquared);
+ accumulate_light(spec, 1.0, trans_accum);
+ }
+
+ float btdf = get_btdf_lut(utilTex, dot(N, V), roughness, ior);
- float influ_spec = min(dist_attenuation, (1.0 - spec_accum.a));
+ return trans_accum.rgb * btdf;
+}
- spec_accum.rgb += sample.rgb * influ_spec;
- spec_accum.a += influ_spec;
+vec3 eevee_surface_glass(vec3 N, vec3 transmission_col, float roughness, float ior, int ssr_id, out vec3 ssr_spec)
+{
+ /* Zero length vectors cause issues, see: T51979. */
+#if 0
+ N = normalize(N);
+#else
+ {
+ float len = length(N);
+ if (isnan(len)) {
+ return vec3(0.0);
}
+ N /= len;
}
+#endif
+ vec3 V = cameraVec;
+ ior = (gl_FrontFacing) ? ior : 1.0 / ior;
- /* Start at 1 because 0 is world irradiance */
- for (int i = 1; i < MAX_GRID && i < grid_count && diff_accum.a < 0.999; ++i) {
- GridData gd = grids_data[i];
+ if (!specToggle) return vec3(0.0);
- vec3 localpos = (gd.localmat * vec4(sd.W, 1.0)).xyz;
+ roughness = clamp(roughness, 1e-8, 0.9999);
+ float roughnessSquared = roughness * roughness;
- float fade = min(1.0, min_v3(1.0 - abs(localpos)));
- fade = saturate(fade * gd.g_atten_scale + gd.g_atten_bias);
+ /* ---------------- SCENE LAMPS LIGHTING ----------------- */
- if (fade > 0.0) {
- localpos = localpos * 0.5 + 0.5;
- localpos = localpos * vec3(gd.g_resolution) - 0.5;
+#ifdef HAIR_SHADER
+ vec3 norm_view = cross(V, N);
+ norm_view = normalize(cross(norm_view, N)); /* Normal facing view */
+#endif
- vec3 localpos_floored = floor(localpos);
- vec3 trilinear_weight = fract(localpos);
+ vec3 spec = vec3(0.0);
+ for (int i = 0; i < MAX_LIGHT && i < light_count; ++i) {
+ LightData ld = lights_data[i];
- float weight_accum = 0.0;
- vec3 irradiance_accum = vec3(0.0);
+ vec4 l_vector; /* Non-Normalized Light Vector with length in last component. */
+ l_vector.xyz = ld.l_position - worldPosition;
+ l_vector.w = length(l_vector.xyz);
- /* For each neighboor cells */
- for (int i = 0; i < 8; ++i) {
- ivec3 offset = ivec3(i, i >> 1, i >> 2) & ivec3(1);
- vec3 cell_cos = clamp(localpos_floored + vec3(offset), vec3(0.0), vec3(gd.g_resolution) - 1.0);
+ vec3 l_color_vis = ld.l_color * light_visibility(ld, worldPosition, viewPosition, viewNormal, l_vector);
- /* We need this because we render probes in world space (so we need light vector in WS).
- * And rendering them in local probe space is too much problem. */
- vec3 ws_cell_location = gd.g_corner +
- (gd.g_increment_x * cell_cos.x +
- gd.g_increment_y * cell_cos.y +
- gd.g_increment_z * cell_cos.z);
- vec3 ws_point_to_cell = ws_cell_location - sd.W;
- vec3 ws_light = normalize(ws_point_to_cell);
+#ifdef HAIR_SHADER
+ vec3 norm_lamp, view_vec;
+ float occlu_trans, occlu;
+ light_hair_common(ld, N, V, l_vector, norm_view, occlu_trans, occlu, norm_lamp, view_vec);
- vec3 trilinear = mix(1 - trilinear_weight, trilinear_weight, offset);
- float weight = trilinear.x * trilinear.y * trilinear.z;
+ spec += l_color_vis * light_specular(ld, N, view_vec, l_vector, roughnessSquared, vec3(1.0)) * occlu;
+#else
+ spec += l_color_vis * light_specular(ld, N, V, l_vector, roughnessSquared, vec3(1.0));
+#endif
+ }
- /* Smooth backface test */
- // weight *= sqrt(max(0.002, dot(ws_light, sd.N)));
+ /* Accumulate outgoing radiance */
+ vec3 out_light = spec;
- /* Avoid zero weight */
- weight = max(0.00001, weight);
+#ifdef HAIR_SHADER
+ N = -norm_view;
+#endif
+
+
+ /* ---------------- SPECULAR ENVIRONMENT LIGHTING ----------------- */
+
+ /* Accumulate light from all sources until accumulator is full. Then apply Occlusion and BRDF. */
+ vec4 spec_accum = vec4(0.0);
+
+ /* Planar Reflections */
+ if (!(ssrToggle && ssr_id == outputSsrId)) {
+ for (int i = 0; i < MAX_PLANAR && i < planar_count && spec_accum.a < 0.999 && roughness < 0.1; ++i) {
+ PlanarData pd = planars_data[i];
- vec3 color = get_cell_color(ivec3(cell_cos), gd.g_resolution, gd.g_offset, bent_normal);
+ float fade = probe_attenuation_planar(pd, worldPosition, N, roughness);
- weight_accum += weight;
- irradiance_accum += color * weight;
+ if (fade > 0.0) {
+ vec3 spec = probe_evaluate_planar(float(i), pd, worldPosition, N, V, roughness, fade);
+ accumulate_light(spec, fade, spec_accum);
}
+ }
+ }
+
+ /* Refract the view vector using the depth heuristic.
+ * Then later Refract a second time the already refracted
+ * ray using the inverse ior. */
+ float final_ior = (refractionDepth > 0.0) ? 1.0 / ior : ior;
+ vec3 refr_V = (refractionDepth > 0.0) ? -refract(-V, N, final_ior) : V;
+ vec3 refr_pos = (refractionDepth > 0.0) ? line_plane_intersect(worldPosition, refr_V, worldPosition - N * refractionDepth, N) : worldPosition;
+
+ vec4 trans_accum = vec4(0.0);
+
+#ifdef USE_REFRACTION
+ /* Screen Space Refraction */
+ if (ssrToggle && roughness < maxRoughness + 0.2) {
+ vec3 rand = texture(utilTex, vec3(gl_FragCoord.xy / LUT_SIZE, 2.0)).xzw;
+
+ /* Find approximated position of the 2nd refraction event. */
+ vec3 refr_vpos = (refractionDepth > 0.0) ? transform_point(ViewMatrix, refr_pos) : viewPosition;
+
+ float ray_ofs = 1.0 / float(rayCount);
+ vec4 spec = screen_space_refraction(refr_vpos, N, refr_V, final_ior, roughnessSquared, rand, 0.0);
+ if (rayCount > 1) spec += screen_space_refraction(refr_vpos, N, refr_V, final_ior, roughnessSquared, rand.xyz * vec3(1.0, -1.0, -1.0), 1.0 * ray_ofs);
+ if (rayCount > 2) spec += screen_space_refraction(refr_vpos, N, refr_V, final_ior, roughnessSquared, rand.xzy * vec3(1.0, 1.0, -1.0), 2.0 * ray_ofs);
+ if (rayCount > 3) spec += screen_space_refraction(refr_vpos, N, refr_V, final_ior, roughnessSquared, rand.xzy * vec3(1.0, -1.0, 1.0), 3.0 * ray_ofs);
+ spec /= float(rayCount);
+ spec.a *= smoothstep(maxRoughness + 0.2, maxRoughness, roughness);
+ accumulate_light(spec.rgb, spec.a, trans_accum);
+ }
+#endif
- vec3 indirect_diffuse = irradiance_accum / weight_accum;
+ /* Specular probes */
+ vec3 refr_dir = get_specular_refraction_dominant_dir(N, refr_V, roughness, final_ior);
+ vec3 spec_dir = get_specular_reflection_dominant_dir(N, V, roughnessSquared);
+
+ /* Starts at 1 because 0 is world probe */
+ for (int i = 1; i < MAX_PROBE && i < probe_count && (spec_accum.a < 0.999 || trans_accum.a < 0.999); ++i) {
+ CubeData cd = probes_data[i];
- float influ_diff = min(fade, (1.0 - diff_accum.a));
+ float fade = probe_attenuation_cube(cd, worldPosition);
- diff_accum.rgb += indirect_diffuse * influ_diff;
- diff_accum.a += influ_diff;
+ if (fade > 0.0) {
+ if (!(ssrToggle && ssr_id == outputSsrId)) {
+ vec3 spec = probe_evaluate_cube(float(i), cd, worldPosition, spec_dir, roughness);
+ accumulate_light(spec, fade, spec_accum);
+ }
- /* For Debug purpose */
- // return texture(irradianceGrid, sd.W.xy).rgb;
+ spec = probe_evaluate_cube(float(i), cd, refr_pos, refr_dir, roughnessSquared);
+ accumulate_light(spec, fade, trans_accum);
}
}
- /* World probe */
- if (diff_accum.a < 1.0 && grid_count > 0) {
- IrradianceData ir_data = load_irradiance_cell(0, bent_normal);
+ /* World Specular */
+ if (spec_accum.a < 0.999) {
+ if (!(ssrToggle && ssr_id == outputSsrId)) {
+ vec3 spec = probe_evaluate_world_spec(spec_dir, roughness);
+ accumulate_light(spec, 1.0, spec_accum);
+ }
+ }
- vec3 diff = compute_irradiance(bent_normal, ir_data);
- diff_accum.rgb += diff * (1.0 - diff_accum.a);
+ if (trans_accum.a < 0.999) {
+ spec = probe_evaluate_world_spec(refr_dir, roughnessSquared);
+ accumulate_light(spec, 1.0, trans_accum);
}
- if (spec_accum.a < 1.0) {
- ProbeData pd = probes_data[0];
+ /* Ambient Occlusion */
+ /* TODO : when AO will be cheaper */
+ float final_ao = 1.0;
+
+ float NV = dot(N, V);
+ /* Get Brdf intensity */
+ vec2 uv = lut_coords(NV, roughness);
+ vec2 brdf_lut = texture(utilTex, vec3(uv, 1.0)).rg;
+
+ float fresnel = F_eta(ior, NV);
+
+ /* Apply fresnel on lamps. */
+ out_light *= vec3(fresnel);
- vec3 spec = textureLod_octahedron(probeCubes, vec4(spec_dir, 0), roughness * lodMax, lodMax).rgb;
- spec_accum.rgb += spec * (1.0 - spec_accum.a);
+ ssr_spec = vec3(fresnel) * F_ibl(vec3(1.0), brdf_lut);
+ if (!(ssrToggle && ssr_id == outputSsrId)) {
+ ssr_spec *= specular_occlusion(dot(N, V), final_ao, roughness);
}
+ out_light += spec_accum.rgb * ssr_spec;
+
+
+ float btdf = get_btdf_lut(utilTex, NV, roughness, ior);
- vec3 indirect_radiance =
- spec_accum.rgb * F_ibl(f0, brdf_lut) * float(specToggle) * specular_occlusion(dot(sd.N, sd.V), final_ao, roughness) +
- diff_accum.rgb * albedo * gtao_multibounce(final_ao, albedo);
+ out_light += vec3(1.0 - fresnel) * transmission_col * trans_accum.rgb * btdf;
- return radiance + indirect_radiance;
+ return out_light;
}
diff --git a/source/blender/draw/engines/eevee/shaders/ltc_lib.glsl b/source/blender/draw/engines/eevee/shaders/ltc_lib.glsl
index f296eedc3ee..ffaa81c3638 100644
--- a/source/blender/draw/engines/eevee/shaders/ltc_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/ltc_lib.glsl
@@ -161,9 +161,12 @@ mat3 ltc_matrix(vec4 lut)
float ltc_evaluate(vec3 N, vec3 V, mat3 Minv, vec3 corners[4])
{
+ /* Avoid dot(N, V) == 1 in ortho mode, leading T1 normalize to fail. */
+ V = normalize(V + 1e-8);
+
/* construct orthonormal basis around N */
vec3 T1, T2;
- T1 = normalize(V - N*dot(V, N));
+ T1 = normalize(V - N * dot(N, V));
T2 = cross(N, T1);
/* rotate area light in (T1, T2, R) basis */
@@ -206,9 +209,12 @@ float ltc_evaluate(vec3 N, vec3 V, mat3 Minv, vec3 corners[4])
#define LTC_CIRCLE_RES 8
float ltc_evaluate_circle(vec3 N, vec3 V, mat3 Minv, vec3 p[LTC_CIRCLE_RES])
{
+ /* Avoid dot(N, V) == 1 in ortho mode, leading T1 normalize to fail. */
+ V = normalize(V + 1e-8);
+
/* construct orthonormal basis around N */
vec3 T1, T2;
- T1 = normalize(V - N*dot(V, N));
+ T1 = normalize(V - N * dot(V, N));
T2 = cross(N, T1);
/* rotate area light in (T1, T2, R) basis */
diff --git a/source/blender/draw/engines/eevee/shaders/prepass_frag.glsl b/source/blender/draw/engines/eevee/shaders/prepass_frag.glsl
index 6317dcea0e9..f921d56e3bc 100644
--- a/source/blender/draw/engines/eevee/shaders/prepass_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/prepass_frag.glsl
@@ -1,7 +1,85 @@
+#ifdef USE_ALPHA_HASH
+
+/* From the paper "Hashed Alpha Testing" by Chris Wyman and Morgan McGuire */
+float hash(vec2 a) {
+ return fract(1e4 * sin(17.0 * a.x + 0.1 * a.y) * (0.1 + abs(sin(13.0 * a.y + a.x))));
+}
+
+float hash3d(vec3 a) {
+ return hash(vec2(hash(a.xy), a.z));
+}
+
+//uniform float hashScale;
+float hashScale = 0.001;
+
+float hashed_alpha_threshold(vec3 co)
+{
+ /* Find the discretized derivatives of our coordinates. */
+ float max_deriv = max(length(dFdx(co)), length(dFdy(co)));
+ float pix_scale = 1.0 / (hashScale * max_deriv);
+
+ /* Find two nearest log-discretized noise scales. */
+ float pix_scale_log = log2(pix_scale);
+ vec2 pix_scales;
+ pix_scales.x = exp2(floor(pix_scale_log));
+ pix_scales.y = exp2(ceil(pix_scale_log));
+
+ /* Compute alpha thresholds at our two noise scales. */
+ vec2 alpha;
+ alpha.x = hash3d(floor(pix_scales.x * co));
+ alpha.y = hash3d(floor(pix_scales.y * co));
+
+ /* Factor to interpolate lerp with. */
+ float fac = fract(log2(pix_scale));
+
+ /* Interpolate alpha threshold from noise at two scales. */
+ float x = mix(alpha.x, alpha.y, fac);
+
+ /* Pass into CDF to compute uniformly distrib threshold. */
+ float a = min(fac, 1.0 - fac);
+ float one_a = 1.0 - a;
+ float denom = 1.0 / (2 * a * one_a);
+ float one_x = (1 - x);
+ vec3 cases = vec3(
+ (x * x) * denom,
+ (x - 0.5 * a) / one_a,
+ 1.0 - (one_x * one_x * denom)
+ );
+
+ /* Find our final, uniformly distributed alpha threshold. */
+ float threshold = (x < one_a) ? ((x < a) ? cases.x : cases.y) : cases.z;
+
+ /* Avoids threshold == 0. */
+ threshold = clamp(threshold, 1.0e-6, 1.0);
+
+ return threshold;
+}
+
+#endif
+
+#ifdef USE_ALPHA_CLIP
+uniform float alphaThreshold;
+#endif
+
void main()
{
/* For now do nothing.
- * In the future, output object motion blur.
- * This pass could also be controlled but nodetree (pixel depth offset, stochastic transparency). */
+ * In the future, output object motion blur. */
+
+#if defined(USE_ALPHA_HASH) || defined(USE_ALPHA_CLIP)
+#define NODETREE_EXEC
+
+ Closure cl = nodetree_exec();
+
+#if defined(USE_ALPHA_HASH)
+ /* Hashed Alpha Testing */
+ if (cl.opacity < hashed_alpha_threshold(worldPosition))
+ discard;
+#elif defined(USE_ALPHA_CLIP)
+ /* Alpha clip */
+ if (cl.opacity <= alphaThreshold)
+ discard;
+#endif
+#endif
}
diff --git a/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl b/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
new file mode 100644
index 00000000000..c1d6b7537ff
--- /dev/null
+++ b/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
@@ -0,0 +1,230 @@
+#define MAX_STEP 256
+
+uniform vec4 ssrParameters;
+
+#define ssrQuality ssrParameters.x
+#define ssrThickness ssrParameters.y
+#define ssrPixelSize ssrParameters.zw
+
+uniform float borderFadeFactor;
+
+float sample_depth(vec2 uv, int index, float lod)
+{
+ if (index > -1) {
+ return textureLod(planarDepth, vec3(uv, index), 0.0).r;
+ }
+ else {
+ /* Correct UVs for mipmaping mis-alignment */
+ uv *= mipRatio[int(lod + 1.0)];
+ return textureLod(maxzBuffer, uv, lod).r;
+ }
+}
+
+vec4 sample_depth_grouped(vec4 uv1, vec4 uv2, int index, float lod)
+{
+ vec4 depths;
+ if (index > -1) {
+ depths.x = textureLod(planarDepth, vec3(uv1.xy, index), 0.0).r;
+ depths.y = textureLod(planarDepth, vec3(uv1.zw, index), 0.0).r;
+ depths.z = textureLod(planarDepth, vec3(uv2.xy, index), 0.0).r;
+ depths.w = textureLod(planarDepth, vec3(uv2.zw, index), 0.0).r;
+ }
+ else {
+ depths.x = textureLod(maxzBuffer, uv1.xy, lod).r;
+ depths.y = textureLod(maxzBuffer, uv1.zw, lod).r;
+ depths.z = textureLod(maxzBuffer, uv2.xy, lod).r;
+ depths.w = textureLod(maxzBuffer, uv2.zw, lod).r;
+ }
+ return depths;
+}
+
+float refine_isect(float prev_delta, float curr_delta)
+{
+ /**
+ * Simplification of 2D intersection :
+ * r0 = (0.0, prev_ss_ray.z);
+ * r1 = (1.0, curr_ss_ray.z);
+ * d0 = (0.0, prev_hit_depth_sample);
+ * d1 = (1.0, curr_hit_depth_sample);
+ * vec2 r = r1 - r0;
+ * vec2 d = d1 - d0;
+ * vec2 isect = ((d * cross(r1, r0)) - (r * cross(d1, d0))) / cross(r,d);
+ *
+ * We only want isect.x to know how much stride we need. So it simplifies :
+ *
+ * isect_x = (cross(r1, r0) - cross(d1, d0)) / cross(r,d);
+ * isect_x = (prev_ss_ray.z - prev_hit_depth_sample.z) / cross(r,d);
+ */
+ return saturate(prev_delta / (prev_delta - curr_delta));
+}
+
+void prepare_raycast(vec3 ray_origin, vec3 ray_end, float thickness, out vec4 ss_step, out vec4 ss_ray, out float max_time)
+{
+ /* Negate the ray direction if it goes towards the camera.
+ * This way we don't need to care if the projected point
+ * is behind the near plane. */
+ float z_sign = -sign(ray_end.z);
+ ray_end = z_sign * ray_end + ray_origin;
+
+ /* Project into screen space. */
+ vec4 ss_start, ss_end;
+ ss_start.xyz = project_point(ProjectionMatrix, ray_origin);
+ ss_end.xyz = project_point(ProjectionMatrix, ray_end);
+
+ /* We interpolate the ray Z + thickness values to check if depth is within threshold. */
+ ray_origin.z -= thickness;
+ ray_end.z -= thickness;
+ ss_start.w = project_point(ProjectionMatrix, ray_origin).z;
+ ss_end.w = project_point(ProjectionMatrix, ray_end).z;
+
+ /* XXX This is a hack a better method is welcome ! */
+ /* We take the delta between the offseted depth and the depth and substract it from the ray depth.
+ * This will change the world space thickness appearance a bit but we can have negative
+ * values without worries. We cannot do this in viewspace because of the perspective division. */
+ ss_start.w = 2.0 * ss_start.z - ss_start.w;
+ ss_end.w = 2.0 * ss_end.z - ss_end.w;
+
+ ss_step = ss_end - ss_start;
+ max_time = length(ss_step.xyz);
+ ss_step = z_sign * ss_step / length(ss_step.xyz);
+
+ /* If the line is degenerate, make it cover at least one pixel
+ * to not have to handle zero-pixel extent as a special case later */
+ ss_step.xy += vec2((dot(ss_step.xy, ss_step.xy) < 0.000001) ? 0.001 : 0.0);
+
+ /* Make ss_step cover one pixel. */
+ ss_step /= max(abs(ss_step.x), abs(ss_step.y));
+ ss_step *= ((abs(ss_step.x) > abs(ss_step.y)) ? ssrPixelSize.x : ssrPixelSize.y);
+
+ /* Clip to segment's end. */
+ max_time /= length(ss_step.xyz);
+
+ /* Clipping to frustum sides. */
+ max_time = min(max_time, line_unit_box_intersect_dist(ss_start.xyz, ss_step.xyz));
+
+ /* Convert to texture coords. Z component included
+ * since this is how it's stored in the depth buffer.
+ * 4th component how far we are on the ray */
+ ss_ray = ss_start * 0.5 + 0.5;
+ ss_step *= 0.5;
+}
+
+/* See times_and_deltas. */
+#define curr_time times_and_deltas.x
+#define prev_time times_and_deltas.y
+#define curr_delta times_and_deltas.z
+#define prev_delta times_and_deltas.w
+
+// #define GROUPED_FETCHES /* is still slower, need to see where is the bottleneck. */
+/* Return the hit position, and negate the z component (making it positive) if not hit occured. */
+/* __ray_end__ is the ray direction premultiplied by it's maximum length */
+vec3 raycast(int index, vec3 ray_origin, vec3 ray_end, float thickness, float ray_jitter, float trace_quality, float roughness)
+{
+ vec4 ss_step, ss_start;
+ float max_time;
+ prepare_raycast(ray_origin, ray_end, thickness, ss_step, ss_start, max_time);
+
+ float max_trace_time = max(0.001, max_time - 0.01);
+
+#ifdef GROUPED_FETCHES
+ ray_jitter *= 0.25;
+#endif
+
+ /* x : current_time, y: previous_time, z: current_delta, w: previous_delta */
+ vec4 times_and_deltas = vec4(0.0);
+
+ float ray_time = 0.0;
+ float depth_sample = sample_depth(ss_start.xy, index, 0.0);
+ curr_delta = depth_sample - ss_start.z;
+
+ float lod_fac = saturate(fast_sqrt(roughness) * 2.0 - 0.4);
+ bool hit = false;
+ float iter;
+ for (iter = 1.0; !hit && (ray_time < max_time) && (iter < MAX_STEP); iter++) {
+ /* Minimum stride of 2 because we are using half res minmax zbuffer. */
+ float stride = max(1.0, iter * trace_quality) * 2.0;
+ float lod = log2(stride * 0.5 * trace_quality) * lod_fac;
+ ray_time += stride;
+
+ /* Save previous values. */
+ times_and_deltas.xyzw = times_and_deltas.yxwz;
+
+#ifdef GROUPED_FETCHES
+ stride *= 4.0;
+ vec4 jit_stride = mix(vec4(2.0), vec4(stride), vec4(0.0, 0.25, 0.5, 0.75) + ray_jitter);
+
+ vec4 times = min(vec4(ray_time) + jit_stride, vec4(max_trace_time));
+
+ vec4 uv1 = ss_start.xyxy + ss_step.xyxy * times.xxyy;
+ vec4 uv2 = ss_start.xyxy + ss_step.xyxy * times.zzww;
+
+ vec4 depth_samples = sample_depth_grouped(uv1, uv2, index, lod);
+
+ vec4 ray_z = ss_start.zzzz + ss_step.zzzz * times.xyzw;
+ vec4 ray_w = ss_start.wwww + ss_step.wwww * vec4(prev_time, times.xyz);
+
+ vec4 deltas = depth_samples - ray_z;
+ /* Same as component wise (curr_delta <= 0.0) && (prev_w <= depth_sample). */
+ bvec4 test = equal(step(deltas, vec4(0.0)) * step(ray_w, depth_samples), vec4(1.0));
+ hit = any(test);
+
+ if (hit) {
+ vec2 m = vec2(1.0, 0.0); /* Mask */
+
+ vec4 ret_times_and_deltas = times.wzzz * m.xxyy + deltas.wwwz * m.yyxx;
+ ret_times_and_deltas = (test.z) ? times.zyyy * m.xxyy + deltas.zzzy * m.yyxx : ret_times_and_deltas;
+ ret_times_and_deltas = (test.y) ? times.yxxx * m.xxyy + deltas.yyyx * m.yyxx : ret_times_and_deltas;
+ times_and_deltas = (test.x) ? times.xxxx * m.xyyy + deltas.xxxx * m.yyxy + times_and_deltas.yyww * m.yxyx : ret_times_and_deltas;
+
+ depth_sample = depth_samples.w;
+ depth_sample = (test.z) ? depth_samples.z : depth_sample;
+ depth_sample = (test.y) ? depth_samples.y : depth_sample;
+ depth_sample = (test.x) ? depth_samples.x : depth_sample;
+ }
+ else {
+ curr_time = times.w;
+ curr_delta = deltas.w;
+ }
+#else
+ float jit_stride = mix(2.0, stride, ray_jitter);
+
+ curr_time = min(ray_time + jit_stride, max_trace_time);
+ vec4 ss_ray = ss_start + ss_step * curr_time;
+
+ depth_sample = sample_depth(ss_ray.xy, index, lod);
+
+ float prev_w = ss_start.w + ss_step.w * prev_time;
+ curr_delta = depth_sample - ss_ray.z;
+ hit = (curr_delta <= 0.0) && (prev_w <= depth_sample);
+#endif
+ }
+
+ /* Discard backface hits */
+ hit = hit && (prev_delta > 0.0);
+
+ /* Reject hit if background. */
+ hit = hit && (depth_sample != 1.0);
+
+ curr_time = (hit) ? mix(prev_time, curr_time, refine_isect(prev_delta, curr_delta)) : curr_time;
+ ray_time = (hit) ? curr_time : ray_time;
+
+ /* Clip to frustum. */
+ ray_time = max(0.001, min(ray_time, max_time - 1.5));
+
+ vec4 ss_ray = ss_start + ss_step * ray_time;
+
+ /* Tag Z if ray failed. */
+ ss_ray.z *= (hit) ? 1.0 : -1.0;
+ return ss_ray.xyz;
+}
+
+float screen_border_mask(vec2 hit_co)
+{
+ const float margin = 0.003;
+ float atten = borderFadeFactor + margin; /* Screen percentage */
+ hit_co = smoothstep(margin, atten, hit_co) * (1 - smoothstep(1.0 - atten, 1.0 - margin, hit_co));
+
+ float screenfade = hit_co.x * hit_co.y;
+
+ return screenfade;
+}
diff --git a/source/blender/draw/engines/eevee/shaders/shadow_copy_frag.glsl b/source/blender/draw/engines/eevee/shaders/shadow_copy_frag.glsl
new file mode 100644
index 00000000000..67b0fc2bdfc
--- /dev/null
+++ b/source/blender/draw/engines/eevee/shaders/shadow_copy_frag.glsl
@@ -0,0 +1,210 @@
+/* Copy the depth only shadowmap into another texture while converting
+ * to linear depth (or other storage method) and doing a 3x3 box filter. */
+
+layout(std140) uniform shadow_render_block {
+ mat4 ShadowMatrix[6];
+ mat4 FaceViewMatrix[6];
+ vec4 lampPosition;
+ float cubeTexelSize;
+ float storedTexelSize;
+ float nearClip;
+ float farClip;
+ int shadowSampleCount;
+ float shadowInvSampleCount;
+};
+
+#ifdef CSM
+uniform sampler2DArray shadowTexture;
+uniform int cascadeId;
+#else
+uniform samplerCube shadowTexture;
+uniform int faceId;
+#endif
+uniform float shadowFilterSize;
+
+out vec4 FragColor;
+
+float linear_depth(float z)
+{
+ return (nearClip * farClip) / (z * (nearClip - farClip) + farClip);
+}
+
+vec4 linear_depth(vec4 z)
+{
+ return (nearClip * farClip) / (z * (nearClip - farClip) + farClip);
+}
+
+#ifdef CSM
+vec4 get_world_distance(vec4 depths, vec3 cos[4])
+{
+ /* Background case */
+ vec4 is_background = step(vec4(0.99999), depths);
+ depths *= abs(farClip - nearClip); /* Same factor as in shadow_cascade(). */
+ depths += 1e1 * is_background;
+ return depths;
+}
+
+float get_world_distance(float depth, vec3 cos)
+{
+ /* Background case */
+ float is_background = step(0.9999, depth);
+ depth *= abs(farClip - nearClip); /* Same factor as in shadow_cascade(). */
+ depth += 1e1 * is_background;
+ return depth;
+}
+#else /* CUBEMAP */
+vec4 get_world_distance(vec4 depths, vec3 cos[4])
+{
+ vec4 is_background = step(vec4(1.0), depths);
+ depths = linear_depth(depths);
+ depths += vec4(1e1) * is_background;
+ cos[0] = normalize(abs(cos[0]));
+ cos[1] = normalize(abs(cos[1]));
+ cos[2] = normalize(abs(cos[2]));
+ cos[3] = normalize(abs(cos[3]));
+ vec4 cos_vec;
+ cos_vec.x = max(cos[0].x, max(cos[0].y, cos[0].z));
+ cos_vec.y = max(cos[1].x, max(cos[1].y, cos[1].z));
+ cos_vec.z = max(cos[2].x, max(cos[2].y, cos[2].z));
+ cos_vec.w = max(cos[3].x, max(cos[3].y, cos[3].z));
+ return depths / cos_vec;
+}
+
+float get_world_distance(float depth, vec3 cos)
+{
+ float is_background = step(1.0, depth);
+ depth = linear_depth(depth);
+ depth += 1e1 * is_background;
+ cos = normalize(abs(cos));
+ float cos_vec = max(cos.x, max(cos.y, cos.z));
+ return depth / cos_vec;
+}
+#endif
+
+/* Marco Salvi's GDC 2008 presentation about shadow maps pre-filtering techniques slide 24 */
+float ln_space_prefilter(float w0, float x, float w1, float y)
+{
+ return x + log(w0 + w1 * exp(y - x));
+}
+
+#define SAMPLE_WEIGHT 0.11111
+
+#ifdef ESM
+void prefilter(vec4 depths, inout float accum)
+{
+ accum = ln_space_prefilter(1.0, accum, SAMPLE_WEIGHT, depths.x);
+ accum = ln_space_prefilter(1.0, accum, SAMPLE_WEIGHT, depths.y);
+ accum = ln_space_prefilter(1.0, accum, SAMPLE_WEIGHT, depths.z);
+ accum = ln_space_prefilter(1.0, accum, SAMPLE_WEIGHT, depths.w);
+}
+#else /* VSM */
+void prefilter(vec4 depths, inout vec2 accum)
+{
+ vec4 depths_sqr = depths * depths;
+ accum += vec2(dot(vec4(1.0), depths), dot(vec4(1.0), depths_sqr)) * SAMPLE_WEIGHT;
+}
+#endif
+
+#ifdef CSM
+vec3 get_texco(vec2 uvs, vec2 ofs)
+{
+ return vec3(uvs + ofs, float(cascadeId));
+}
+#else /* CUBEMAP */
+const vec3 minorAxisX[6] = vec3[6](
+ vec3(0.0f, 0.0f, -1.0f),
+ vec3(0.0f, 0.0f, 1.0f),
+ vec3(1.0f, 0.0f, 0.0f),
+ vec3(1.0f, 0.0f, 0.0f),
+ vec3(1.0f, 0.0f, 0.0f),
+ vec3(-1.0f, 0.0f, 0.0f)
+);
+
+const vec3 minorAxisY[6] = vec3[6](
+ vec3(0.0f, -1.0f, 0.0f),
+ vec3(0.0f, -1.0f, 0.0f),
+ vec3(0.0f, 0.0f, 1.0f),
+ vec3(0.0f, 0.0f, -1.0f),
+ vec3(0.0f, -1.0f, 0.0f),
+ vec3(0.0f, -1.0f, 0.0f)
+);
+
+const vec3 majorAxis[6] = vec3[6](
+ vec3(1.0f, 0.0f, 0.0f),
+ vec3(-1.0f, 0.0f, 0.0f),
+ vec3(0.0f, 1.0f, 0.0f),
+ vec3(0.0f, -1.0f, 0.0f),
+ vec3(0.0f, 0.0f, 1.0f),
+ vec3(0.0f, 0.0f, -1.0f)
+);
+
+vec3 get_texco(vec2 uvs, vec2 ofs)
+{
+ uvs += ofs;
+ return majorAxis[faceId] + uvs.x * minorAxisX[faceId] + uvs.y * minorAxisY[faceId];
+}
+#endif
+
+void main() {
+ /* Copy the depth only shadowmap into another texture while converting
+ * to linear depth and do a 3x3 box blur. */
+
+#ifdef CSM
+ vec2 uvs = gl_FragCoord.xy * storedTexelSize;
+#else /* CUBEMAP */
+ vec2 uvs = gl_FragCoord.xy * cubeTexelSize * 2.0 - 1.0;
+#endif
+
+ /* Center texel */
+ vec3 co = get_texco(uvs, vec2(0.0));
+ float depth = texture(shadowTexture, co).r;
+ depth = get_world_distance(depth, co);
+
+ if (shadowFilterSize == 0.0) {
+#ifdef ESM
+ FragColor = vec4(depth);
+#else /* VSM */
+ FragColor = vec2(depth, depth * depth).xyxy;
+#endif
+ return;
+ }
+
+#ifdef ESM
+ float accum = ln_space_prefilter(0.0, 0.0, SAMPLE_WEIGHT, depth);
+#else /* VSM */
+ vec2 accum = vec2(depth, depth * depth) * SAMPLE_WEIGHT;
+#endif
+
+#ifdef CSM
+ vec3 ofs = vec3(1.0, 0.0, -1.0) * shadowFilterSize;
+#else /* CUBEMAP */
+ vec3 ofs = vec3(1.0, 0.0, -1.0) * shadowFilterSize;
+#endif
+
+ vec3 cos[4];
+ cos[0] = get_texco(uvs, ofs.zz);
+ cos[1] = get_texco(uvs, ofs.yz);
+ cos[2] = get_texco(uvs, ofs.xz);
+ cos[3] = get_texco(uvs, ofs.zy);
+
+ vec4 depths;
+ depths.x = texture(shadowTexture, cos[0]).r;
+ depths.y = texture(shadowTexture, cos[1]).r;
+ depths.z = texture(shadowTexture, cos[2]).r;
+ depths.w = texture(shadowTexture, cos[3]).r;
+ depths = get_world_distance(depths, cos);
+ prefilter(depths, accum);
+
+ cos[0] = get_texco(uvs, ofs.xy);
+ cos[1] = get_texco(uvs, ofs.zx);
+ cos[2] = get_texco(uvs, ofs.yx);
+ cos[3] = get_texco(uvs, ofs.xx);
+ depths.x = texture(shadowTexture, cos[0]).r;
+ depths.y = texture(shadowTexture, cos[1]).r;
+ depths.z = texture(shadowTexture, cos[2]).r;
+ depths.w = texture(shadowTexture, cos[3]).r;
+ depths = get_world_distance(depths, cos);
+ prefilter(depths, accum);
+
+ FragColor = vec2(accum).xyxy;
+}
diff --git a/source/blender/draw/engines/eevee/shaders/shadow_frag.glsl b/source/blender/draw/engines/eevee/shaders/shadow_frag.glsl
index 3fc3c146c66..160fcee4c73 100644
--- a/source/blender/draw/engines/eevee/shaders/shadow_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/shadow_frag.glsl
@@ -1,16 +1,4 @@
-layout(std140) uniform shadow_render_block {
- mat4 ShadowMatrix[6];
- vec4 lampPosition;
- int layer;
- float exponent;
-};
-
-in vec3 worldPosition;
-
-out vec4 FragColor;
-
void main() {
- float dist = distance(lampPosition.xyz, worldPosition.xyz);
- FragColor = vec4(dist, 0.0, 0.0, 1.0);
+ /* Do nothing */
}
diff --git a/source/blender/draw/engines/eevee/shaders/shadow_geom.glsl b/source/blender/draw/engines/eevee/shaders/shadow_geom.glsl
index afc78c4a8f8..ea51fa73a65 100644
--- a/source/blender/draw/engines/eevee/shaders/shadow_geom.glsl
+++ b/source/blender/draw/engines/eevee/shaders/shadow_geom.glsl
@@ -1,9 +1,14 @@
layout(std140) uniform shadow_render_block {
mat4 ShadowMatrix[6];
+ mat4 FaceViewMatrix[6];
vec4 lampPosition;
- int layer;
- float exponent;
+ float cubeTexelSize;
+ float storedTexelSize;
+ float nearClip;
+ float farClip;
+ int shadowSampleCount;
+ float shadowInvSampleCount;
};
layout(triangles) in;
@@ -12,15 +17,35 @@ layout(triangle_strip, max_vertices=3) out;
in vec4 vPos[];
flat in int face[];
+#ifdef MESH_SHADER
+in vec3 vNor[];
+#endif
+
out vec3 worldPosition;
+#ifdef MESH_SHADER
+out vec3 viewPosition; /* Required. otherwise generate linking error. */
+out vec3 worldNormal; /* Required. otherwise generate linking error. */
+out vec3 viewNormal; /* Required. otherwise generate linking error. */
+flat out int shFace;
+#else
+int shFace;
+#endif
void main() {
- int f = face[0];
- gl_Layer = f;
+ shFace = face[0];
+ gl_Layer = shFace;
for (int v = 0; v < 3; ++v) {
- gl_Position = ShadowMatrix[f] * vPos[v];
+ gl_Position = ShadowMatrix[shFace] * vPos[v];
worldPosition = vPos[v].xyz;
+#ifdef MESH_SHADER
+ worldNormal = vNor[v];
+ viewPosition = (FaceViewMatrix[shFace] * vec4(worldPosition, 1.0)).xyz;
+ viewNormal = (FaceViewMatrix[shFace] * vec4(worldNormal, 0.0)).xyz;
+#ifdef ATTRIB
+ pass_attrib(v);
+#endif
+#endif
EmitVertex();
}
diff --git a/source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl b/source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl
index 40b980b3904..fcc304ca289 100644
--- a/source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl
@@ -1,12 +1,23 @@
layout(std140) uniform shadow_render_block {
mat4 ShadowMatrix[6];
+ mat4 FaceViewMatrix[6];
vec4 lampPosition;
- int layer;
- float exponent;
+ float cubeTexelSize;
+ float storedTexelSize;
+ float nearClip;
+ float farClip;
+ int shadowSampleCount;
+ float shadowInvSampleCount;
};
-uniform samplerCube shadowCube;
+#ifdef CSM
+uniform sampler2DArray shadowTexture;
+uniform int cascadeId;
+#else
+uniform samplerCube shadowTexture;
+#endif
+uniform float shadowFilterSize;
out vec4 FragColor;
@@ -24,89 +35,112 @@ vec3 octahedral_to_cubemap_proj(vec2 co)
return v;
}
-void make_orthonormal_basis(vec3 N, out vec3 T, out vec3 B)
+/* Marco Salvi's GDC 2008 presentation about shadow maps pre-filtering techniques slide 24 */
+float ln_space_prefilter(float w0, float x, float w1, float y)
{
- vec3 UpVector = abs(N.z) < 0.99999 ? vec3(0.0,0.0,1.0) : vec3(1.0,0.0,0.0);
- T = normalize( cross(UpVector, N) );
- B = cross(N, T);
+ return x + log(w0 + w1 * exp(y - x));
}
-#define NUM_SAMPLE 32
-vec2 poisson_disc[32] = vec2[32](
- vec2( 0.476, 0.854), vec2(-0.659, -0.670),
- vec2( 0.905, -0.270), vec2( 0.215, -0.133),
- vec2(-0.595, 0.242), vec2(-0.146, 0.519),
- vec2( 0.108, -0.930), vec2( 0.807, 0.449),
-
- vec2(-0.476, -0.854), vec2( 0.659, 0.670),
- vec2(-0.905, 0.270), vec2(-0.215, 0.133),
- vec2( 0.595, -0.242), vec2( 0.146, -0.519),
- vec2(-0.108, 0.930), vec2(-0.807, -0.449),
-
- vec2(-0.854, 0.476), vec2( 0.670, -0.659),
- vec2( 0.270, 0.905), vec2( 0.133, 0.215),
- vec2(-0.242, -0.595), vec2(-0.519, -0.146),
- vec2( 0.930, 0.108), vec2(-0.449, 0.807),
-
- vec2( 0.854, -0.476), vec2(-0.670, 0.659),
- vec2(-0.270, -0.905), vec2(-0.133, -0.215),
- vec2( 0.242, 0.595), vec2( 0.519, 0.146),
- vec2(-0.930, -0.108), vec2( 0.449, -0.807)
-);
-
-/* Marco Salvi's GDC 2008 presentation about shadow maps pre-filtering techniques slide 24 */
-float ln_space_prefilter(float w0, float x, float w1, float y)
+vec4 ln_space_prefilter(float w0, vec4 x, float w1, vec4 y)
{
return x + log(w0 + w1 * exp(y - x));
}
+#ifdef CSM
+vec3 get_texco(vec3 cos, vec2 ofs)
+{
+ cos.xy += ofs * shadowFilterSize;
+ return cos;
+}
+#else /* CUBEMAP */
+/* global vars */
+vec3 T = vec3(0.0);
+vec3 B = vec3(0.0);
+
+void make_orthonormal_basis(vec3 N)
+{
+ vec3 UpVector = (abs(N.z) < 0.999) ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
+ T = normalize(cross(UpVector, N));
+ B = cross(N, T);
+}
+
+vec3 get_texco(vec3 cos, vec2 ofs)
+{
+ return cos + ofs.x * T + ofs.y * B;
+}
+
+#endif
+
void main() {
- const vec2 texelSize = vec2(1.0 / 512.0);
+ vec3 cos;
- vec2 uvs = gl_FragCoord.xy * texelSize;
+ cos.xy = gl_FragCoord.xy * storedTexelSize;
+#ifdef CSM
+ cos.z = float(cascadeId);
+#else /* CUBEMAP */
/* add a 2 pixel border to ensure filtering is correct */
- uvs.xy *= 1.0 + texelSize * 2.0;
- uvs.xy -= texelSize;
+ cos.xy *= 1.0 + storedTexelSize * 2.0;
+ cos.xy -= storedTexelSize;
float pattern = 1.0;
/* edge mirroring : only mirror if directly adjacent
* (not diagonally adjacent) */
- vec2 m = abs(uvs - 0.5) + 0.5;
+ vec2 m = abs(cos.xy - 0.5) + 0.5;
vec2 f = floor(m);
if (f.x - f.y != 0.0) {
- uvs.xy = 1.0 - uvs.xy;
+ cos.xy = 1.0 - cos.xy;
}
/* clamp to [0-1] */
- uvs.xy = fract(uvs.xy);
+ cos.xy = fract(cos.xy);
/* get cubemap vector */
- vec3 cubevec = octahedral_to_cubemap_proj(uvs.xy);
-
- vec3 T, B;
- make_orthonormal_basis(cubevec, T, B);
-
- /* get cubemap shadow value */
- const float blur_radius = 5.0 / 512.0; /* Totally arbitrary */
- const float weight = 1.0 / float(NUM_SAMPLE);
- float accum = 0.0;
-
- /* Poisson disc blur in log space. */
- vec2 offsetvec = poisson_disc[0].xy * blur_radius;
- float depth1 = texture(shadowCube, cubevec + offsetvec.x * T + offsetvec.y * B).r;
-
- offsetvec = poisson_disc[1].xy * blur_radius;
- float depth2 = texture(shadowCube, cubevec + offsetvec.x * T + offsetvec.y * B).r;
-
- accum = ln_space_prefilter(weight, depth1, weight, depth2);
+ cos = normalize(octahedral_to_cubemap_proj(cos.xy));
+ make_orthonormal_basis(cos);
+
+ T *= shadowFilterSize;
+ B *= shadowFilterSize;
+#endif
+
+#ifdef ESM
+ vec4 accum = vec4(0.0);
+
+ /* disc blur in log space. */
+ vec4 depths;
+ depths.x = texture(shadowTexture, get_texco(cos, concentric[0])).r;
+ depths.y = texture(shadowTexture, get_texco(cos, concentric[1])).r;
+ depths.z = texture(shadowTexture, get_texco(cos, concentric[2])).r;
+ depths.w = texture(shadowTexture, get_texco(cos, concentric[3])).r;
+ accum = ln_space_prefilter(0.0, accum, shadowInvSampleCount, depths);
+
+ for (int i = 4; i < shadowSampleCount && i < CONCENTRIC_SAMPLE_NUM; i += 4) {
+ depths.x = texture(shadowTexture, get_texco(cos, concentric[i+0])).r;
+ depths.y = texture(shadowTexture, get_texco(cos, concentric[i+1])).r;
+ depths.z = texture(shadowTexture, get_texco(cos, concentric[i+2])).r;
+ depths.w = texture(shadowTexture, get_texco(cos, concentric[i+3])).r;
+ accum = ln_space_prefilter(1.0, accum, shadowInvSampleCount, depths);
+ }
- for (int i = 2; i < NUM_SAMPLE; ++i) {
- vec2 offsetvec = poisson_disc[i].xy * blur_radius;
- depth1 = texture(shadowCube, cubevec + offsetvec.x * T + offsetvec.y * B).r;
- accum = ln_space_prefilter(1.0, accum, weight, depth1);
+ accum.x = ln_space_prefilter(1.0, accum.x, 1.0, accum.y);
+ accum.x = ln_space_prefilter(1.0, accum.x, 1.0, accum.z);
+ accum.x = ln_space_prefilter(1.0, accum.x, 1.0, accum.w);
+ FragColor = accum.xxxx;
+
+#else /* VSM */
+ vec2 accum = vec2(0.0);
+
+ /* disc blur. */
+ vec4 depths1, depths2;
+ for (int i = 0; i < shadowSampleCount && i < CONCENTRIC_SAMPLE_NUM; i += 4) {
+ depths1.xy = texture(shadowTexture, get_texco(cos, concentric[i+0])).rg;
+ depths1.zw = texture(shadowTexture, get_texco(cos, concentric[i+1])).rg;
+ depths2.xy = texture(shadowTexture, get_texco(cos, concentric[i+2])).rg;
+ depths2.zw = texture(shadowTexture, get_texco(cos, concentric[i+3])).rg;
+ accum += depths1.xy + depths1.zw + depths2.xy + depths2.zw;
}
- FragColor = vec4(accum, accum, accum, 1.0);
+ FragColor = accum.xyxy * shadowInvSampleCount;
+#endif
} \ No newline at end of file
diff --git a/source/blender/draw/engines/eevee/shaders/shadow_store_geom.glsl b/source/blender/draw/engines/eevee/shaders/shadow_store_geom.glsl
deleted file mode 100644
index 1d456095e02..00000000000
--- a/source/blender/draw/engines/eevee/shaders/shadow_store_geom.glsl
+++ /dev/null
@@ -1,23 +0,0 @@
-
-layout(std140) uniform shadow_render_block {
- mat4 ShadowMatrix[6];
- vec4 lampPosition;
- int layer;
- float exponent;
-};
-
-layout(triangles) in;
-layout(triangle_strip, max_vertices=3) out;
-
-in vec4 vPos[];
-
-void main() {
- gl_Layer = layer;
-
- for (int v = 0; v < 3; ++v) {
- gl_Position = vPos[v];
- EmitVertex();
- }
-
- EndPrimitive();
-} \ No newline at end of file
diff --git a/source/blender/draw/engines/eevee/shaders/shadow_store_vert.glsl b/source/blender/draw/engines/eevee/shaders/shadow_store_vert.glsl
deleted file mode 100644
index dee020f19b4..00000000000
--- a/source/blender/draw/engines/eevee/shaders/shadow_store_vert.glsl
+++ /dev/null
@@ -1,8 +0,0 @@
-
-in vec3 pos;
-
-out vec4 vPos;
-
-void main() {
- vPos = vec4(pos, 1.0);
-} \ No newline at end of file
diff --git a/source/blender/draw/engines/eevee/shaders/shadow_vert.glsl b/source/blender/draw/engines/eevee/shaders/shadow_vert.glsl
index 288098ba771..777902ccba8 100644
--- a/source/blender/draw/engines/eevee/shaders/shadow_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/shadow_vert.glsl
@@ -1,13 +1,29 @@
uniform mat4 ShadowModelMatrix;
+#ifdef MESH_SHADER
+uniform mat3 WorldNormalMatrix;
+#endif
in vec3 pos;
+#ifdef MESH_SHADER
+in vec3 nor;
+#endif
out vec4 vPos;
+#ifdef MESH_SHADER
+out vec3 vNor;
+#endif
flat out int face;
void main() {
vPos = ShadowModelMatrix * vec4(pos, 1.0);
face = gl_InstanceID;
-} \ No newline at end of file
+
+#ifdef MESH_SHADER
+ vNor = WorldNormalMatrix * nor;
+#ifdef ATTRIB
+ pass_attrib(pos);
+#endif
+#endif
+}
diff --git a/source/blender/draw/engines/eevee/shaders/ssr_lib.glsl b/source/blender/draw/engines/eevee/shaders/ssr_lib.glsl
new file mode 100644
index 00000000000..d3d6b8dc80f
--- /dev/null
+++ b/source/blender/draw/engines/eevee/shaders/ssr_lib.glsl
@@ -0,0 +1,73 @@
+/* ------------ Refraction ------------ */
+
+#define BTDF_BIAS 0.85
+
+vec4 screen_space_refraction(vec3 viewPosition, vec3 N, vec3 V, float ior, float roughnessSquared, vec3 rand, float ofs)
+{
+ float a2 = max(5e-6, roughnessSquared * roughnessSquared);
+ float jitter = fract(rand.x + ofs);
+
+ /* Importance sampling bias */
+ rand.x = mix(rand.x, 0.0, BTDF_BIAS);
+
+ vec3 T, B;
+ float NH;
+ make_orthonormal_basis(N, T, B);
+ vec3 H = sample_ggx(rand, a2, N, T, B, NH); /* Microfacet normal */
+ float pdf = pdf_ggx_reflect(NH, a2);
+
+ /* If ray is bad (i.e. going below the plane) regenerate. */
+ if (F_eta(ior, dot(H, V)) < 1.0) {
+ H = sample_ggx(rand * vec3(1.0, -1.0, -1.0), a2, N, T, B, NH); /* Microfacet normal */
+ pdf = pdf_ggx_reflect(NH, a2);
+ }
+
+ vec3 vV = viewCameraVec;
+ float eta = 1.0/ior;
+ if (dot(H, V) < 0.0) {
+ H = -H;
+ eta = ior;
+ }
+
+ vec3 R = refract(-V, H, 1.0 / ior);
+
+ R = transform_direction(ViewMatrix, R);
+
+ vec3 hit_pos = raycast(-1, viewPosition, R * 1e16, ssrThickness, jitter, ssrQuality, roughnessSquared);
+
+ if ((hit_pos.z > 0.0) && (F_eta(ior, dot(H, V)) < 1.0)) {
+ hit_pos = get_view_space_from_depth(hit_pos.xy, hit_pos.z);
+ float hit_dist = distance(hit_pos, viewPosition);
+
+ float cone_cos = cone_cosine(roughnessSquared);
+ float cone_tan = sqrt(1 - cone_cos * cone_cos) / cone_cos;
+
+ /* Empirical fit for refraction. */
+ /* TODO find a better fit or precompute inside the LUT. */
+ cone_tan *= 0.5 * fast_sqrt(f0_from_ior((ior < 1.0) ? 1.0 / ior : ior));
+
+ float cone_footprint = hit_dist * cone_tan;
+
+ /* find the offset in screen space by multiplying a point
+ * in camera space at the depth of the point by the projection matrix. */
+ float homcoord = ProjectionMatrix[2][3] * hit_pos.z + ProjectionMatrix[3][3];
+ /* UV space footprint */
+ cone_footprint = BTDF_BIAS * 0.5 * max(ProjectionMatrix[0][0], ProjectionMatrix[1][1]) * cone_footprint / homcoord;
+
+ vec2 hit_uvs = project_point(ProjectionMatrix, hit_pos).xy * 0.5 + 0.5;
+
+ /* Texel footprint */
+ vec2 texture_size = vec2(textureSize(colorBuffer, 0).xy);
+ float mip = clamp(log2(cone_footprint * max(texture_size.x, texture_size.y)), 0.0, 9.0);
+
+ /* Correct UVs for mipmaping mis-alignment */
+ hit_uvs *= mip_ratio_interp(mip);
+
+ vec3 spec = textureLod(colorBuffer, hit_uvs, mip).xyz;
+ float mask = screen_border_mask(hit_uvs);
+
+ return vec4(spec, mask);
+ }
+
+ return vec4(0.0);
+}
diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_frag.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_frag.glsl
new file mode 100644
index 00000000000..7f44dd53163
--- /dev/null
+++ b/source/blender/draw/engines/eevee/shaders/volumetric_frag.glsl
@@ -0,0 +1,396 @@
+
+#ifdef VOLUMETRICS
+
+#define NODETREE_EXEC
+
+#define VOLUMETRIC_INTEGRATION_MAX_STEP 256
+#define VOLUMETRIC_SHADOW_MAX_STEP 128
+
+uniform int light_count;
+uniform vec2 volume_start_end;
+uniform vec4 volume_samples_clamp;
+
+#define volume_start volume_start_end.x
+#define volume_end volume_start_end.y
+
+#define volume_integration_steps volume_samples_clamp.x
+#define volume_shadows_steps volume_samples_clamp.y
+#define volume_sample_distribution volume_samples_clamp.z
+#define volume_light_clamp volume_samples_clamp.w
+
+#ifdef COLOR_TRANSMITTANCE
+layout(location = 0) out vec4 outScattering;
+layout(location = 1) out vec4 outTransmittance;
+#else
+out vec4 outScatteringTransmittance;
+#endif
+
+/* Warning: theses are not attributes, theses are global vars. */
+vec3 worldPosition = vec3(0.0);
+vec3 viewPosition = vec3(0.0);
+vec3 viewNormal = vec3(0.0);
+
+uniform sampler2D depthFull;
+
+void participating_media_properties(vec3 wpos, out vec3 extinction, out vec3 scattering, out vec3 emission, out float anisotropy)
+{
+#ifndef VOLUME_HOMOGENEOUS
+ worldPosition = wpos;
+ viewPosition = (ViewMatrix * vec4(wpos, 1.0)).xyz; /* warning, Perf. */
+#endif
+
+ Closure cl = nodetree_exec();
+
+ scattering = cl.scatter;
+ emission = cl.emission;
+ anisotropy = cl.anisotropy;
+ extinction = max(vec3(1e-4), cl.absorption + cl.scatter);
+}
+
+vec3 participating_media_extinction(vec3 wpos)
+{
+#ifndef VOLUME_HOMOGENEOUS
+ worldPosition = wpos;
+ viewPosition = (ViewMatrix * vec4(wpos, 1.0)).xyz; /* warning, Perf. */
+#endif
+
+ Closure cl = nodetree_exec();
+
+ return max(vec3(1e-4), cl.absorption + cl.scatter);
+}
+
+float phase_function_isotropic()
+{
+ return 1.0 / (4.0 * M_PI);
+}
+
+float phase_function(vec3 v, vec3 l, float g)
+{
+#ifndef VOLUME_ISOTROPIC /* TODO Use this flag when only isotropic closures are used */
+ /* Henyey-Greenstein */
+ float cos_theta = dot(v, l);
+ g = clamp(g, -1.0 + 1e-3, 1.0 - 1e-3);
+ float sqr_g = g * g;
+ return (1- sqr_g) / (4.0 * M_PI * pow(1 + sqr_g - 2 * g * cos_theta, 3.0 / 2.0));
+#else
+ return phase_function_isotropic();
+#endif
+}
+
+float light_volume(LightData ld, vec4 l_vector)
+{
+ float power;
+ float dist = max(1e-4, abs(l_vector.w - ld.l_radius));
+ /* TODO : Area lighting ? */
+ /* Removing Area Power. */
+ /* TODO : put this out of the shader. */
+ if (ld.l_type == AREA) {
+ power = 0.0962 * (ld.l_sizex * ld.l_sizey * 4.0f * M_PI);
+ }
+ else {
+ power = 0.0248 * (4.0 * ld.l_radius * ld.l_radius * M_PI * M_PI);
+ }
+ return min(power / (l_vector.w * l_vector.w), volume_light_clamp);
+}
+
+vec3 irradiance_volumetric(vec3 wpos)
+{
+ IrradianceData ir_data = load_irradiance_cell(0, vec3(1.0));
+ vec3 irradiance = ir_data.cubesides[0] + ir_data.cubesides[1] + ir_data.cubesides[2];
+ ir_data = load_irradiance_cell(0, vec3(-1.0));
+ irradiance += ir_data.cubesides[0] + ir_data.cubesides[1] + ir_data.cubesides[2];
+ irradiance *= 0.16666666; /* 1/6 */
+ return irradiance;
+}
+
+vec3 light_volume_shadow(LightData ld, vec3 ray_wpos, vec4 l_vector, vec3 s_extinction)
+{
+#ifdef VOLUME_SHADOW
+
+#ifdef VOLUME_HOMOGENEOUS
+ /* Simple extinction */
+ return exp(-s_extinction * l_vector.w);
+#else
+ /* Heterogeneous volume shadows */
+ float dd = l_vector.w / volume_shadows_steps;
+ vec3 L = l_vector.xyz * l_vector.w;
+ vec3 shadow = vec3(1.0);
+ for (float s = 0.5; s < VOLUMETRIC_SHADOW_MAX_STEP && s < (volume_shadows_steps - 0.1); s += 1.0) {
+ vec3 pos = ray_wpos + L * (s / volume_shadows_steps);
+ vec3 s_extinction = participating_media_extinction(pos);
+ shadow *= exp(-s_extinction * dd);
+ }
+ return shadow;
+#endif /* VOLUME_HOMOGENEOUS */
+
+#else
+ return vec3(1.0);
+#endif /* VOLUME_SHADOW */
+}
+
+float find_next_step(float iter, float noise)
+{
+ float progress = (iter + noise) / volume_integration_steps;
+
+ float linear_split = mix(volume_start, volume_end, progress);
+
+ if (ProjectionMatrix[3][3] == 0.0) {
+ float exp_split = volume_start * pow(volume_end / volume_start, progress);
+ return mix(linear_split, exp_split, volume_sample_distribution);
+ }
+ else {
+ return linear_split;
+ }
+}
+
+/* Based on Frosbite Unified Volumetric.
+ * https://www.ea.com/frostbite/news/physically-based-unified-volumetric-rendering-in-frostbite */
+void main()
+{
+ vec2 uv = (gl_FragCoord.xy * 2.0) / ivec2(textureSize(depthFull, 0));
+ float scene_depth = texelFetch(depthFull, ivec2(gl_FragCoord.xy) * 2, 0).r; /* use the same depth as in the upsample step */
+ vec3 vpos = get_view_space_from_depth(uv, scene_depth);
+ vec3 wpos = (ViewMatrixInverse * vec4(vpos, 1.0)).xyz;
+ vec3 wdir = (ProjectionMatrix[3][3] == 0.0) ? normalize(cameraPos - wpos) : cameraForward;
+
+ /* Note: this is NOT the distance to the camera. */
+ float max_z = vpos.z;
+
+ /* project ray to clip plane so we can integrate in even steps in clip space. */
+ vec3 wdir_proj = wdir / abs(dot(cameraForward, wdir));
+ float wlen = length(wdir_proj);
+
+ /* Transmittance: How much light can get through. */
+ vec3 transmittance = vec3(1.0);
+
+ /* Scattering: Light that has been accumulated from scattered light sources. */
+ vec3 scattering = vec3(0.0);
+
+ vec3 ray_origin = (ProjectionMatrix[3][3] == 0.0)
+ ? cameraPos
+ : (ViewMatrixInverse * vec4(get_view_space_from_depth(uv, 0.5), 1.0)).xyz;
+
+#ifdef VOLUME_HOMOGENEOUS
+ /* Put it out of the loop for homogeneous media. */
+ vec3 s_extinction, s_scattering, s_emission;
+ float s_anisotropy;
+ participating_media_properties(vec3(0.0), s_extinction, s_scattering, s_emission, s_anisotropy);
+#endif
+
+ /* Start from near clip. TODO make start distance an option. */
+ float rand = texture(utilTex, vec3(gl_FragCoord.xy / LUT_SIZE, 2.0)).r;
+ /* Less noisy but noticeable patterns, could work better with temporal AA. */
+ // float rand = (1.0 / 16.0) * float(((int(gl_FragCoord.x + gl_FragCoord.y) & 0x3) << 2) + (int(gl_FragCoord.x) & 0x3));
+ float dist = volume_start;
+ for (float i = 0.5; i < VOLUMETRIC_INTEGRATION_MAX_STEP && i < (volume_integration_steps - 0.1); ++i) {
+ float new_dist = max(max_z, find_next_step(rand, i));
+ float step = dist - new_dist; /* Marching step */
+ dist = new_dist;
+
+ vec3 ray_wpos = ray_origin + wdir_proj * dist;
+
+#ifndef VOLUME_HOMOGENEOUS
+ vec3 s_extinction, s_scattering, s_emission;
+ float s_anisotropy;
+ participating_media_properties(ray_wpos, s_extinction, s_scattering, s_emission, s_anisotropy);
+#endif
+
+ /* Evaluate each light */
+ vec3 Lscat = s_emission;
+
+#ifdef VOLUME_LIGHTING /* Lights */
+ for (int i = 0; i < MAX_LIGHT && i < light_count; ++i) {
+ LightData ld = lights_data[i];
+
+ vec4 l_vector;
+ l_vector.xyz = ld.l_position - ray_wpos;
+ l_vector.w = length(l_vector.xyz);
+
+ float Vis = light_visibility(ld, ray_wpos, l_vector);
+
+ vec3 Li = ld.l_color * light_volume(ld, l_vector) * light_volume_shadow(ld, ray_wpos, l_vector, s_extinction);
+
+ Lscat += Li * Vis * s_scattering * phase_function(-wdir, l_vector.xyz / l_vector.w, s_anisotropy);
+ }
+#endif
+
+ /* Environment : Average color. */
+ Lscat += irradiance_volumetric(wpos) * s_scattering * phase_function_isotropic();
+
+ /* Evaluate Scattering */
+ float s_len = wlen * step;
+ vec3 Tr = exp(-s_extinction * s_len);
+
+ /* integrate along the current step segment */
+ Lscat = (Lscat - Lscat * Tr) / s_extinction;
+ /* accumulate and also take into account the transmittance from previous steps */
+ scattering += transmittance * Lscat;
+
+ /* Evaluate transmittance to view independantely */
+ transmittance *= Tr;
+
+ if (dist <= max_z)
+ break;
+ }
+
+#ifdef COLOR_TRANSMITTANCE
+ outScattering = vec4(scattering, 1.0);
+ outTransmittance = vec4(transmittance, 1.0);
+#else
+ float mono_transmittance = dot(transmittance, vec3(1.0)) / 3.0;
+
+ outScatteringTransmittance = vec4(scattering, mono_transmittance);
+#endif
+}
+
+#else /* STEP_UPSAMPLE */
+
+out vec4 FragColor;
+
+uniform sampler2D depthFull;
+uniform sampler2D volumetricBuffer;
+
+uniform mat4 ProjectionMatrix;
+
+vec4 get_view_z_from_depth(vec4 depth)
+{
+ vec4 d = 2.0 * depth - 1.0;
+ return -ProjectionMatrix[3][2] / (d + ProjectionMatrix[2][2]);
+}
+
+void main()
+{
+#if 0 /* 2 x 2 with bilinear */
+
+ const vec4 bilinear_weights[4] = vec4[4](
+ vec4(9.0 / 16.0, 3.0 / 16.0, 3.0 / 16.0, 1.0 / 16.0 ),
+ vec4(3.0 / 16.0, 9.0 / 16.0, 1.0 / 16.0, 3.0 / 16.0 ),
+ vec4(3.0 / 16.0, 1.0 / 16.0, 9.0 / 16.0, 3.0 / 16.0 ),
+ vec4(1.0 / 16.0, 3.0 / 16.0, 3.0 / 16.0, 9.0 / 16.0 )
+ );
+
+ /* Depth aware upsampling */
+ vec4 depths;
+ ivec2 texel_co = ivec2(gl_FragCoord.xy * 0.5) * 2;
+
+ /* TODO use textureGather on glsl 4.0 */
+ depths.x = texelFetchOffset(depthFull, texel_co, 0, ivec2(0, 0)).r;
+ depths.y = texelFetchOffset(depthFull, texel_co, 0, ivec2(2, 0)).r;
+ depths.z = texelFetchOffset(depthFull, texel_co, 0, ivec2(0, 2)).r;
+ depths.w = texelFetchOffset(depthFull, texel_co, 0, ivec2(2, 2)).r;
+
+ vec4 target_depth = texelFetch(depthFull, ivec2(gl_FragCoord.xy), 0).rrrr;
+
+ depths = get_view_z_from_depth(depths);
+ target_depth = get_view_z_from_depth(target_depth);
+
+ vec4 weights = 1.0 - step(0.05, abs(depths - target_depth));
+
+ /* Index in range [0-3] */
+ int pix_id = int(dot(mod(ivec2(gl_FragCoord.xy), 2), ivec2(1, 2)));
+ weights *= bilinear_weights[pix_id];
+
+ float weight_sum = dot(weights, vec4(1.0));
+
+ if (weight_sum == 0.0) {
+ weights.x = 1.0;
+ weight_sum = 1.0;
+ }
+
+ texel_co = ivec2(gl_FragCoord.xy * 0.5);
+
+ vec4 integration_result;
+ integration_result = texelFetchOffset(volumetricBuffer, texel_co, 0, ivec2(0, 0)) * weights.x;
+ integration_result += texelFetchOffset(volumetricBuffer, texel_co, 0, ivec2(1, 0)) * weights.y;
+ integration_result += texelFetchOffset(volumetricBuffer, texel_co, 0, ivec2(0, 1)) * weights.z;
+ integration_result += texelFetchOffset(volumetricBuffer, texel_co, 0, ivec2(1, 1)) * weights.w;
+
+#else /* 4 x 4 */
+
+ /* Depth aware upsampling */
+ vec4 depths[4];
+ ivec2 texel_co = ivec2(gl_FragCoord.xy * 0.5) * 2;
+
+ /* TODO use textureGather on glsl 4.0 */
+ texel_co += ivec2(-2, -2);
+ depths[0].x = texelFetchOffset(depthFull, texel_co, 0, ivec2(0, 0)).r;
+ depths[0].y = texelFetchOffset(depthFull, texel_co, 0, ivec2(2, 0)).r;
+ depths[0].z = texelFetchOffset(depthFull, texel_co, 0, ivec2(0, 2)).r;
+ depths[0].w = texelFetchOffset(depthFull, texel_co, 0, ivec2(2, 2)).r;
+
+ texel_co += ivec2(4, 0);
+ depths[1].x = texelFetchOffset(depthFull, texel_co, 0, ivec2(0, 0)).r;
+ depths[1].y = texelFetchOffset(depthFull, texel_co, 0, ivec2(2, 0)).r;
+ depths[1].z = texelFetchOffset(depthFull, texel_co, 0, ivec2(0, 2)).r;
+ depths[1].w = texelFetchOffset(depthFull, texel_co, 0, ivec2(2, 2)).r;
+
+ texel_co += ivec2(-4, 4);
+ depths[2].x = texelFetchOffset(depthFull, texel_co, 0, ivec2(0, 0)).r;
+ depths[2].y = texelFetchOffset(depthFull, texel_co, 0, ivec2(2, 0)).r;
+ depths[2].z = texelFetchOffset(depthFull, texel_co, 0, ivec2(0, 2)).r;
+ depths[2].w = texelFetchOffset(depthFull, texel_co, 0, ivec2(2, 2)).r;
+
+ texel_co += ivec2(4, 0);
+ depths[3].x = texelFetchOffset(depthFull, texel_co, 0, ivec2(0, 0)).r;
+ depths[3].y = texelFetchOffset(depthFull, texel_co, 0, ivec2(2, 0)).r;
+ depths[3].z = texelFetchOffset(depthFull, texel_co, 0, ivec2(0, 2)).r;
+ depths[3].w = texelFetchOffset(depthFull, texel_co, 0, ivec2(2, 2)).r;
+
+ vec4 target_depth = texelFetch(depthFull, ivec2(gl_FragCoord.xy), 0).rrrr;
+
+ depths[0] = get_view_z_from_depth(depths[0]);
+ depths[1] = get_view_z_from_depth(depths[1]);
+ depths[2] = get_view_z_from_depth(depths[2]);
+ depths[3] = get_view_z_from_depth(depths[3]);
+
+ target_depth = get_view_z_from_depth(target_depth);
+
+ vec4 weights[4];
+ weights[0] = 1.0 - step(0.05, abs(depths[0] - target_depth));
+ weights[1] = 1.0 - step(0.05, abs(depths[1] - target_depth));
+ weights[2] = 1.0 - step(0.05, abs(depths[2] - target_depth));
+ weights[3] = 1.0 - step(0.05, abs(depths[3] - target_depth));
+
+ float weight_sum;
+ weight_sum = dot(weights[0], vec4(1.0));
+ weight_sum += dot(weights[1], vec4(1.0));
+ weight_sum += dot(weights[2], vec4(1.0));
+ weight_sum += dot(weights[3], vec4(1.0));
+
+ if (weight_sum == 0.0) {
+ weights[0].x = 1.0;
+ weight_sum = 1.0;
+ }
+
+ texel_co = ivec2(gl_FragCoord.xy * 0.5);
+
+ vec4 integration_result;
+
+ texel_co += ivec2(-1, -1);
+ integration_result = texelFetchOffset(volumetricBuffer, texel_co, 0, ivec2(0, 0)) * weights[0].x;
+ integration_result += texelFetchOffset(volumetricBuffer, texel_co, 0, ivec2(1, 0)) * weights[0].y;
+ integration_result += texelFetchOffset(volumetricBuffer, texel_co, 0, ivec2(0, 1)) * weights[0].z;
+ integration_result += texelFetchOffset(volumetricBuffer, texel_co, 0, ivec2(1, 1)) * weights[0].w;
+
+ texel_co += ivec2(2, 0);
+ integration_result += texelFetchOffset(volumetricBuffer, texel_co, 0, ivec2(0, 0)) * weights[1].x;
+ integration_result += texelFetchOffset(volumetricBuffer, texel_co, 0, ivec2(1, 0)) * weights[1].y;
+ integration_result += texelFetchOffset(volumetricBuffer, texel_co, 0, ivec2(0, 1)) * weights[1].z;
+ integration_result += texelFetchOffset(volumetricBuffer, texel_co, 0, ivec2(1, 1)) * weights[1].w;
+
+ texel_co += ivec2(-2, 2);
+ integration_result += texelFetchOffset(volumetricBuffer, texel_co, 0, ivec2(0, 0)) * weights[2].x;
+ integration_result += texelFetchOffset(volumetricBuffer, texel_co, 0, ivec2(1, 0)) * weights[2].y;
+ integration_result += texelFetchOffset(volumetricBuffer, texel_co, 0, ivec2(0, 1)) * weights[2].z;
+ integration_result += texelFetchOffset(volumetricBuffer, texel_co, 0, ivec2(1, 1)) * weights[2].w;
+
+ texel_co += ivec2(2, 0);
+ integration_result += texelFetchOffset(volumetricBuffer, texel_co, 0, ivec2(0, 0)) * weights[3].x;
+ integration_result += texelFetchOffset(volumetricBuffer, texel_co, 0, ivec2(1, 0)) * weights[3].y;
+ integration_result += texelFetchOffset(volumetricBuffer, texel_co, 0, ivec2(0, 1)) * weights[3].z;
+ integration_result += texelFetchOffset(volumetricBuffer, texel_co, 0, ivec2(1, 1)) * weights[3].w;
+#endif
+
+ FragColor = integration_result / weight_sum;
+}
+#endif
diff --git a/source/blender/draw/engines/external/external_engine.c b/source/blender/draw/engines/external/external_engine.c
index e487b29ebfd..f4b38b7ebbf 100644
--- a/source/blender/draw/engines/external/external_engine.c
+++ b/source/blender/draw/engines/external/external_engine.c
@@ -19,7 +19,7 @@
*
*/
-/** \file external_engine.h
+/** \file external_engine.c
* \ingroup draw_engine
*
* Base engine for external render engines.
@@ -216,7 +216,8 @@ DrawEngineType draw_engine_external_type = {
&EXTERNAL_cache_populate,
&EXTERNAL_cache_finish,
NULL,
- &EXTERNAL_draw_scene
+ &EXTERNAL_draw_scene,
+ NULL,
};
/* Note: currently unused, we should not register unless we want to see this when debugging the view. */
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index de2099806e3..428bea17f7c 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -49,6 +49,8 @@
#include "draw_cache.h"
#include "draw_view.h"
+#include "draw_manager_profiling.h"
+
#include "MEM_guardedalloc.h"
#include "RE_engine.h"
@@ -88,6 +90,29 @@ typedef char DRWViewportEmptyList;
DRW_VIEWPORT_LIST_SIZE(*(((ty *)NULL)->stl)) \
}
+/* Use of multisample framebuffers. */
+#define MULTISAMPLE_SYNC_ENABLE(dfbl) { \
+ if (dfbl->multisample_fb != NULL) { \
+ DRW_stats_query_start("Multisample Blit"); \
+ DRW_framebuffer_blit(dfbl->default_fb, dfbl->multisample_fb, false); \
+ DRW_framebuffer_blit(dfbl->default_fb, dfbl->multisample_fb, true); \
+ DRW_framebuffer_bind(dfbl->multisample_fb); \
+ DRW_stats_query_end(); \
+ } \
+}
+
+#define MULTISAMPLE_SYNC_DISABLE(dfbl) { \
+ if (dfbl->multisample_fb != NULL) { \
+ DRW_stats_query_start("Multisample Resolve"); \
+ DRW_framebuffer_blit(dfbl->multisample_fb, dfbl->default_fb, false); \
+ DRW_framebuffer_blit(dfbl->multisample_fb, dfbl->default_fb, true); \
+ DRW_framebuffer_bind(dfbl->default_fb); \
+ DRW_stats_query_end(); \
+ } \
+}
+
+
+
typedef struct DrawEngineDataSize {
int fbl_len;
int txl_len;
@@ -111,17 +136,22 @@ typedef struct DrawEngineType {
void (*draw_background)(void *vedata);
void (*draw_scene)(void *vedata);
+
+ void (*view_update)(void *vedata);
} DrawEngineType;
#ifndef __DRW_ENGINE_H__
/* Buffer and textures used by the viewport by default */
typedef struct DefaultFramebufferList {
struct GPUFrameBuffer *default_fb;
+ struct GPUFrameBuffer *multisample_fb;
} DefaultFramebufferList;
typedef struct DefaultTextureList {
struct GPUTexture *color;
struct GPUTexture *depth;
+ struct GPUTexture *multisample_color;
+ struct GPUTexture *multisample_depth;
} DefaultTextureList;
#endif
@@ -163,6 +193,7 @@ struct GPUTexture *DRW_texture_create_2D_array(
struct GPUTexture *DRW_texture_create_cube(
int w, DRWTextureFormat format, DRWTextureFlag flags, const float *fpixels);
void DRW_texture_generate_mipmaps(struct GPUTexture *tex);
+void DRW_texture_update(struct GPUTexture *tex, const float *pixels);
void DRW_texture_free(struct GPUTexture *tex);
#define DRW_TEXTURE_FREE_SAFE(tex) do { \
if (tex != NULL) { \
@@ -253,7 +284,8 @@ typedef enum {
DRW_STATE_BLEND = (1 << 14),
DRW_STATE_ADDITIVE = (1 << 15),
DRW_STATE_MULTIPLY = (1 << 16),
- DRW_STATE_CLIP_PLANES = (1 << 17),
+ DRW_STATE_TRANSMISSION = (1 << 17),
+ DRW_STATE_CLIP_PLANES = (1 << 18),
DRW_STATE_WRITE_STENCIL_SELECT = (1 << 27),
DRW_STATE_WRITE_STENCIL_ACTIVE = (1 << 28),
@@ -266,7 +298,8 @@ typedef enum {
DRWShadingGroup *DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass);
DRWShadingGroup *DRW_shgroup_material_create(struct GPUMaterial *material, DRWPass *pass);
-DRWShadingGroup *DRW_shgroup_material_instance_create(struct GPUMaterial *material, DRWPass *pass, struct Gwn_Batch *geom);
+DRWShadingGroup *DRW_shgroup_material_instance_create(
+ struct GPUMaterial *material, DRWPass *pass, struct Gwn_Batch *geom, struct Object *ob);
DRWShadingGroup *DRW_shgroup_instance_create(struct GPUShader *shader, DRWPass *pass, struct Gwn_Batch *geom);
DRWShadingGroup *DRW_shgroup_point_batch_create(struct GPUShader *shader, DRWPass *pass);
DRWShadingGroup *DRW_shgroup_line_batch_create(struct GPUShader *shader, DRWPass *pass);
@@ -296,6 +329,7 @@ void DRW_shgroup_call_dynamic_add_array(DRWShadingGroup *shgroup, const void *at
void DRW_shgroup_set_instance_count(DRWShadingGroup *shgroup, int count);
void DRW_shgroup_state_enable(DRWShadingGroup *shgroup, DRWState state);
+void DRW_shgroup_state_disable(DRWShadingGroup *shgroup, DRWState state);
void DRW_shgroup_attrib_float(DRWShadingGroup *shgroup, const char *name, int size);
void DRW_shgroup_uniform_texture(DRWShadingGroup *shgroup, const char *name, const struct GPUTexture *tex);
@@ -317,6 +351,7 @@ void DRW_shgroup_uniform_mat4(DRWShadingGroup *shgroup, const char *name, const
/* Passes */
DRWPass *DRW_pass_create(const char *name, DRWState state);
void DRW_pass_foreach_shgroup(DRWPass *pass, void (*callback)(void *userData, DRWShadingGroup *shgrp), void *userData);
+void DRW_pass_sort_shgroup_z(DRWPass *pass);
/* Viewport */
typedef enum {
@@ -353,10 +388,12 @@ void DRW_lamp_engine_data_free(struct LampEngineData *led);
/* Settings */
bool DRW_object_is_renderable(struct Object *ob);
-bool DRW_object_is_flat_normal(struct Object *ob);
+bool DRW_object_is_flat_normal(const struct Object *ob);
+int DRW_object_is_mode_shade(const struct Object *ob);
/* Draw commands */
void DRW_draw_pass(DRWPass *pass);
+void DRW_draw_pass_subset(DRWPass *pass, DRWShadingGroup *start_group, DRWShadingGroup *end_group);
void DRW_draw_text_cache_queue(struct DRWTextStore *dt);
@@ -385,6 +422,7 @@ bool DRW_state_is_depth(void);
bool DRW_state_is_image_render(void);
bool DRW_state_is_scene_render(void);
bool DRW_state_show_text(void);
+bool DRW_state_draw_support(void);
struct DRWTextStore *DRW_state_text_cache_get(void);
@@ -395,7 +433,7 @@ typedef struct DRWContextState {
struct View3D *v3d; /* 'CTX_wm_view3d(C)' */
struct Scene *scene; /* 'CTX_data_scene(C)' */
- struct SceneLayer *sl; /* 'CTX_data_scene_layer(C)' */
+ struct SceneLayer *scene_layer; /* 'CTX_data_scene_layer(C)' */
/* Use 'scene->obedit' for edit-mode */
struct Object *obact; /* 'OBACT_NEW' */
@@ -405,7 +443,6 @@ typedef struct DRWContextState {
const struct bContext *evil_C;
} DRWContextState;
-void DRW_context_state_init(const struct bContext *C, DRWContextState *r_draw_ctx);
const DRWContextState *DRW_context_state_get(void);
#endif /* __DRW_RENDER_H__ */
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c
index 4dfb9f960c2..13df65cf741 100644
--- a/source/blender/draw/intern/draw_cache.c
+++ b/source/blender/draw/intern/draw_cache.c
@@ -29,6 +29,8 @@
#include "DNA_curve_types.h"
#include "DNA_object_types.h"
#include "DNA_particle_types.h"
+#include "DNA_modifier_types.h"
+#include "DNA_lattice_types.h"
#include "BLI_utildefines.h"
#include "BLI_math.h"
@@ -38,9 +40,11 @@
#include "draw_cache.h"
#include "draw_cache_impl.h"
+/* Batch's only (free'd as an array) */
static struct DRWShapeCache {
Gwn_Batch *drw_single_vertice;
Gwn_Batch *drw_fullscreen_quad;
+ Gwn_Batch *drw_quad;
Gwn_Batch *drw_screenspace_circle;
Gwn_Batch *drw_plain_axes;
Gwn_Batch *drw_single_arrow;
@@ -67,7 +71,9 @@ static struct DRWShapeCache {
Gwn_Batch *drw_lamp_spot;
Gwn_Batch *drw_lamp_spot_square;
Gwn_Batch *drw_speaker;
- Gwn_Batch *drw_lightprobe;
+ Gwn_Batch *drw_lightprobe_cube;
+ Gwn_Batch *drw_lightprobe_planar;
+ Gwn_Batch *drw_lightprobe_grid;
Gwn_Batch *drw_bone_octahedral;
Gwn_Batch *drw_bone_octahedral_wire;
Gwn_Batch *drw_bone_box;
@@ -90,52 +96,12 @@ static struct DRWShapeCache {
void DRW_shape_cache_free(void)
{
- BATCH_DISCARD_ALL_SAFE(SHC.drw_single_vertice);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_fullscreen_quad);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_plain_axes);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_single_arrow);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_cube);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_circle);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_square);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_line);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_line_endpoints);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_empty_sphere);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_empty_cone);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_arrows);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_axis_names);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_image_plane);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_image_plane_wire);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_field_wind);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_field_force);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_field_vortex);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_field_tube_limit);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_field_cone_limit);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_lamp);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_lamp_sunrays);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_lamp_area);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_lamp_hemi);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_lamp_spot);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_lamp_spot_square);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_speaker);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_lightprobe);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_bone_octahedral);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_bone_octahedral_wire);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_bone_box);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_bone_box_wire);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_bone_wire_wire);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_bone_envelope);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_bone_envelope_distance);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_bone_envelope_wire);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_bone_envelope_head_wire);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_bone_point);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_bone_point_wire);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_bone_arrows);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_camera);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_camera_tria);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_camera_focus);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_particle_cross);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_particle_circle);
- BATCH_DISCARD_ALL_SAFE(SHC.drw_particle_axis);
+ uint i = sizeof(SHC) / sizeof(Gwn_Batch *);
+ Gwn_Batch **batch = (Gwn_Batch **)&SHC;
+ while (i--) {
+ GWN_BATCH_DISCARD_SAFE(*batch);
+ batch++;
+ }
}
@@ -264,6 +230,7 @@ static Gwn_VertBuf *sphere_wire_vbo(const float rad)
}
/* Quads */
+/* Use this one for rendering fullscreen passes. For 3D objects use DRW_cache_quad_get(). */
Gwn_Batch *DRW_cache_fullscreen_quad_get(void)
{
if (!SHC.drw_fullscreen_quad) {
@@ -283,20 +250,49 @@ Gwn_Batch *DRW_cache_fullscreen_quad_get(void)
Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
GWN_vertbuf_data_alloc(vbo, 3);
- for (int i = 0; i < 3; ++i) {
+ for (int i = 0; i < 3; ++i) {
GWN_vertbuf_attr_set(vbo, attr_id.pos, i, pos[i]);
GWN_vertbuf_attr_set(vbo, attr_id.uvs, i, uvs[i]);
}
- SHC.drw_fullscreen_quad = GWN_batch_create(GWN_PRIM_TRIS, vbo, NULL);
+ SHC.drw_fullscreen_quad = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_fullscreen_quad;
}
+/* Just a regular quad with 4 vertices. */
+Gwn_Batch *DRW_cache_quad_get(void)
+{
+ if (!SHC.drw_quad) {
+ /* Use a triangle instead of a real quad */
+ float pos[4][2] = {{-1.0f, -1.0f}, { 1.0f, -1.0f}, {1.0f, 1.0f}, {-1.0f, 1.0f}};
+ float uvs[4][2] = {{ 0.0f, 0.0f}, { 1.0f, 0.0f}, {1.0f, 1.0f}, { 0.0f, 1.0f}};
+
+ /* Position Only 2D format */
+ static Gwn_VertFormat format = { 0 };
+ static struct { uint pos, uvs; } attr_id;
+ if (format.attrib_ct == 0) {
+ attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ attr_id.uvs = GWN_vertformat_attr_add(&format, "uvs", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ }
+
+ Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
+ GWN_vertbuf_data_alloc(vbo, 4);
+
+ for (int i = 0; i < 4; ++i) {
+ GWN_vertbuf_attr_set(vbo, attr_id.pos, i, pos[i]);
+ GWN_vertbuf_attr_set(vbo, attr_id.uvs, i, uvs[i]);
+ }
+
+ SHC.drw_quad = GWN_batch_create_ex(GWN_PRIM_TRI_FAN, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ }
+ return SHC.drw_quad;
+}
+
/* Sphere */
Gwn_Batch *DRW_cache_sphere_get(void)
{
- return Batch_get_sphere(2);
+ return GPU_batch_preset_sphere(2);
}
/** \} */
@@ -336,7 +332,7 @@ Gwn_Batch *DRW_cache_cube_get(void)
GWN_vertbuf_attr_set(vbo, attr_id.pos, i, verts[indices[i]]);
}
- SHC.drw_cube = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ SHC.drw_cube = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_cube;
}
@@ -369,7 +365,7 @@ Gwn_Batch *DRW_cache_circle_get(void)
GWN_vertbuf_attr_set(vbo, attr_id.pos, a * 2 + 1, v);
}
- SHC.drw_circle = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ SHC.drw_circle = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_circle;
#undef CIRCLE_RESOL
@@ -395,10 +391,10 @@ Gwn_Batch *DRW_cache_square_get(void)
for (int i = 0; i < 4; i++) {
GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 2, p[i % 4]);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 2 + 1, p[(i+1) % 4]);
+ GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 2 + 1, p[(i + 1) % 4]);
}
- SHC.drw_square = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ SHC.drw_square = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_square;
}
@@ -423,7 +419,7 @@ Gwn_Batch *DRW_cache_single_line_get(void)
GWN_vertbuf_attr_set(vbo, attr_id.pos, 0, v1);
GWN_vertbuf_attr_set(vbo, attr_id.pos, 1, v2);
- SHC.drw_line = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ SHC.drw_line = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_line;
}
@@ -448,7 +444,7 @@ Gwn_Batch *DRW_cache_single_line_endpoints_get(void)
GWN_vertbuf_attr_set(vbo, attr_id.pos, 0, v1);
GWN_vertbuf_attr_set(vbo, attr_id.pos, 1, v2);
- SHC.drw_line_endpoints = GWN_batch_create(GWN_PRIM_POINTS, vbo, NULL);
+ SHC.drw_line_endpoints = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_line_endpoints;
}
@@ -475,7 +471,7 @@ Gwn_Batch *DRW_cache_screenspace_circle_get(void)
GWN_vertbuf_attr_set(vbo, attr_id.pos, a, v);
}
- SHC.drw_screenspace_circle = GWN_batch_create(GWN_PRIM_LINE_STRIP, vbo, NULL);
+ SHC.drw_screenspace_circle = GWN_batch_create_ex(GWN_PRIM_LINE_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_screenspace_circle;
#undef CIRCLE_RESOL
@@ -516,11 +512,12 @@ Gwn_Batch *DRW_cache_object_surface_get(Object *ob)
}
}
-Gwn_Batch **DRW_cache_object_surface_material_get(struct Object *ob)
+Gwn_Batch **DRW_cache_object_surface_material_get(
+ struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len)
{
switch (ob->type) {
case OB_MESH:
- return DRW_cache_mesh_surface_shaded_get(ob);
+ return DRW_cache_mesh_surface_shaded_get(ob, gpumat_array, gpumat_array_len);
default:
return NULL;
}
@@ -562,7 +559,7 @@ Gwn_Batch *DRW_cache_plain_axes_get(void)
v1[axis] = v2[axis] = 0.0f;
}
- SHC.drw_plain_axes = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ SHC.drw_plain_axes = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_plain_axes;
}
@@ -602,7 +599,7 @@ Gwn_Batch *DRW_cache_single_arrow_get(void)
GWN_vertbuf_attr_set(vbo, attr_id.pos, sides * 3 + 2, v3);
}
- SHC.drw_single_arrow = GWN_batch_create(GWN_PRIM_TRIS, vbo, NULL);
+ SHC.drw_single_arrow = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_single_arrow;
}
@@ -611,7 +608,7 @@ Gwn_Batch *DRW_cache_empty_sphere_get(void)
{
if (!SHC.drw_empty_sphere) {
Gwn_VertBuf *vbo = sphere_wire_vbo(1.0f);
- SHC.drw_empty_sphere = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ SHC.drw_empty_sphere = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_empty_sphere;
}
@@ -658,7 +655,7 @@ Gwn_Batch *DRW_cache_empty_cone_get(void)
GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 3, v);
}
- SHC.drw_empty_cone = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ SHC.drw_empty_cone = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_empty_cone;
#undef NSEGMENTS
@@ -669,7 +666,7 @@ Gwn_Batch *DRW_cache_arrows_get(void)
if (!SHC.drw_arrows) {
Gwn_VertBuf *vbo = fill_arrows_vbo(1.0f);
- SHC.drw_arrows = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ SHC.drw_arrows = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_arrows;
}
@@ -730,7 +727,7 @@ Gwn_Batch *DRW_cache_axis_names_get(void)
GWN_vertbuf_attr_set(vbo, attr_id.pos, 12, v1);
GWN_vertbuf_attr_set(vbo, attr_id.pos, 13, v2);
- SHC.drw_axis_names = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ SHC.drw_axis_names = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_axis_names;
}
@@ -751,7 +748,7 @@ Gwn_Batch *DRW_cache_image_plane_get(void)
GWN_vertbuf_attr_set(vbo, attr_id.pos, j, quad[j]);
GWN_vertbuf_attr_set(vbo, attr_id.texCoords, j, quad[j]);
}
- SHC.drw_image_plane = GWN_batch_create(GWN_PRIM_TRI_FAN, vbo, NULL);
+ SHC.drw_image_plane = GWN_batch_create_ex(GWN_PRIM_TRI_FAN, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_image_plane;
}
@@ -770,7 +767,7 @@ Gwn_Batch *DRW_cache_image_plane_wire_get(void)
for (uint j = 0; j < 4; j++) {
GWN_vertbuf_attr_set(vbo, attr_id.pos, j, quad[j]);
}
- SHC.drw_image_plane_wire = GWN_batch_create(GWN_PRIM_LINE_LOOP, vbo, NULL);
+ SHC.drw_image_plane_wire = GWN_batch_create_ex(GWN_PRIM_LINE_LOOP, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_image_plane_wire;
}
@@ -807,7 +804,7 @@ Gwn_Batch *DRW_cache_field_wind_get(void)
}
}
- SHC.drw_field_wind = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ SHC.drw_field_wind = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_field_wind;
#undef CIRCLE_RESOL
@@ -844,7 +841,7 @@ Gwn_Batch *DRW_cache_field_force_get(void)
}
}
- SHC.drw_field_force = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ SHC.drw_field_force = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_field_force;
#undef CIRCLE_RESOL
@@ -881,7 +878,7 @@ Gwn_Batch *DRW_cache_field_vortex_get(void)
GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v);
}
- SHC.drw_field_vortex = GWN_batch_create(GWN_PRIM_LINE_STRIP, vbo, NULL);
+ SHC.drw_field_vortex = GWN_batch_create_ex(GWN_PRIM_LINE_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_field_vortex;
#undef SPIRAL_RESOL
@@ -930,7 +927,7 @@ Gwn_Batch *DRW_cache_field_tube_limit_get(void)
}
}
- SHC.drw_field_tube_limit = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ SHC.drw_field_tube_limit = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_field_tube_limit;
#undef CIRCLE_RESOL
@@ -979,7 +976,7 @@ Gwn_Batch *DRW_cache_field_cone_limit_get(void)
}
}
- SHC.drw_field_cone_limit = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ SHC.drw_field_cone_limit = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_field_cone_limit;
#undef CIRCLE_RESOL
@@ -1018,7 +1015,7 @@ Gwn_Batch *DRW_cache_lamp_get(void)
GWN_vertbuf_attr_set(vbo, attr_id.pos, a * 2 + 1, v);
}
- SHC.drw_lamp = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ SHC.drw_lamp = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_lamp;
#undef NSEGMENTS
@@ -1050,7 +1047,7 @@ Gwn_Batch *DRW_cache_lamp_sunrays_get(void)
GWN_vertbuf_attr_set(vbo, attr_id.pos, a * 2 + 1, v2);
}
- SHC.drw_lamp_sunrays = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ SHC.drw_lamp_sunrays = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_lamp_sunrays;
}
@@ -1084,7 +1081,7 @@ Gwn_Batch *DRW_cache_lamp_area_get(void)
v1[1] = 0.5f;
GWN_vertbuf_attr_set(vbo, attr_id.pos, 7, v1);
- SHC.drw_lamp_area = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ SHC.drw_lamp_area = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_lamp_area;
}
@@ -1146,7 +1143,7 @@ Gwn_Batch *DRW_cache_lamp_hemi_get(void)
}
- SHC.drw_lamp_hemi = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ SHC.drw_lamp_hemi = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_lamp_hemi;
#undef CIRCLE_RESOL
@@ -1199,8 +1196,8 @@ Gwn_Batch *DRW_cache_lamp_spot_get(void)
GWN_vertbuf_attr_set(vbo, attr_id.n1, i * 4, n[(i) % NSEGMENTS]);
GWN_vertbuf_attr_set(vbo, attr_id.n1, i * 4 + 1, n[(i) % NSEGMENTS]);
- GWN_vertbuf_attr_set(vbo, attr_id.n2, i * 4, n[(i+1) % NSEGMENTS]);
- GWN_vertbuf_attr_set(vbo, attr_id.n2, i * 4 + 1, n[(i+1) % NSEGMENTS]);
+ GWN_vertbuf_attr_set(vbo, attr_id.n2, i * 4, n[(i + 1) % NSEGMENTS]);
+ GWN_vertbuf_attr_set(vbo, attr_id.n2, i * 4 + 1, n[(i + 1) % NSEGMENTS]);
/* end ring */
v[0] = cv[0], v[1] = cv[1], v[2] = -1.0f;
@@ -1216,7 +1213,7 @@ Gwn_Batch *DRW_cache_lamp_spot_get(void)
GWN_vertbuf_attr_set(vbo, attr_id.n2, i * 4 + 3, neg[(i) % NSEGMENTS]);
}
- SHC.drw_lamp_spot = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ SHC.drw_lamp_spot = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_lamp_spot;
#undef NSEGMENTS
@@ -1248,11 +1245,11 @@ Gwn_Batch *DRW_cache_lamp_spot_square_get(void)
GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, p[0]);
GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, p[i]);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, p[(i % 4)+1]);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, p[((i+1) % 4)+1]);
+ GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, p[(i % 4) + 1]);
+ GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, p[((i + 1) % 4) + 1]);
}
- SHC.drw_lamp_spot_square = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ SHC.drw_lamp_spot_square = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_lamp_spot_square;
}
@@ -1316,7 +1313,7 @@ Gwn_Batch *DRW_cache_speaker_get(void)
}
}
- SHC.drw_speaker = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ SHC.drw_speaker = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_speaker;
}
@@ -1328,13 +1325,21 @@ Gwn_Batch *DRW_cache_speaker_get(void)
/** \name Probe
* \{ */
-Gwn_Batch *DRW_cache_lightprobe_get(void)
+Gwn_Batch *DRW_cache_lightprobe_cube_get(void)
{
-#define CIRCLE_RESOL 16
- if (!SHC.drw_lightprobe) {
+ if (!SHC.drw_lightprobe_cube) {
int v_idx = 0;
- float v[3] = {0.0f, 1.0f, 0.0f};
- /* TODO something nicer than just a circle */
+ const float sin_pi_3 = 0.86602540378f;
+ const float cos_pi_3 = 0.5f;
+ float v[7][3] = {
+ {0.0f, 1.0f, 0.0f},
+ {sin_pi_3, cos_pi_3, 0.0f},
+ {sin_pi_3, -cos_pi_3, 0.0f},
+ {0.0f, -1.0f, 0.0f},
+ {-sin_pi_3, -cos_pi_3, 0.0f},
+ {-sin_pi_3, cos_pi_3, 0.0f},
+ {0.0f, 0.0f, 0.0f},
+ };
/* Position Only 3D format */
static Gwn_VertFormat format = { 0 };
@@ -1344,35 +1349,114 @@ Gwn_Batch *DRW_cache_lightprobe_get(void)
}
Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, CIRCLE_RESOL * 2 + 8);
+ GWN_vertbuf_data_alloc(vbo, (6 + 3) * 2);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v);
- for (int a = 1; a < CIRCLE_RESOL; a++) {
- v[0] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
- v[1] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v);
+ for (int i = 0; i < 6; ++i) {
+ GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[i]);
+ GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[(i + 1) % 6]);
+ }
- if ((a % 2 == 0) && (a % 4 != 0)) {
- v[0] *= 0.5f;
- v[1] *= 0.5f;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v);
- v[0] *= 3.0f;
- v[1] *= 3.0f;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v);
- v[0] /= 1.5f;
- v[1] /= 1.5f;
+ GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[1]);
+ GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]);
+
+ GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[5]);
+ GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]);
+
+ GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[3]);
+ GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]);
+
+ SHC.drw_lightprobe_cube = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ }
+ return SHC.drw_lightprobe_cube;
+}
+
+Gwn_Batch *DRW_cache_lightprobe_grid_get(void)
+{
+ if (!SHC.drw_lightprobe_grid) {
+ int v_idx = 0;
+ const float sin_pi_3 = 0.86602540378f;
+ const float cos_pi_3 = 0.5f;
+ const float v[7][3] = {
+ {0.0f, 1.0f, 0.0f},
+ {sin_pi_3, cos_pi_3, 0.0f},
+ {sin_pi_3, -cos_pi_3, 0.0f},
+ {0.0f, -1.0f, 0.0f},
+ {-sin_pi_3, -cos_pi_3, 0.0f},
+ {-sin_pi_3, cos_pi_3, 0.0f},
+ {0.0f, 0.0f, 0.0f},
+ };
+
+ /* Position Only 3D format */
+ static Gwn_VertFormat format = { 0 };
+ static struct { uint pos; } attr_id;
+ if (format.attrib_ct == 0) {
+ attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ }
+
+ Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
+ GWN_vertbuf_data_alloc(vbo, (6 * 2 + 3) * 2);
+
+ for (int i = 0; i < 6; ++i) {
+ float tmp_v1[3], tmp_v2[3], tmp_tr[3];
+ copy_v3_v3(tmp_v1, v[i]);
+ copy_v3_v3(tmp_v2, v[(i + 1) % 6]);
+ GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, tmp_v1);
+ GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, tmp_v2);
+
+ /* Internal wires. */
+ for (int j = 1; j < 2; ++j) {
+ mul_v3_v3fl(tmp_tr, v[(i / 2) * 2 + 1], -0.5f * j);
+ add_v3_v3v3(tmp_v1, v[i], tmp_tr);
+ add_v3_v3v3(tmp_v2, v[(i + 1) % 6], tmp_tr);
+ GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, tmp_v1);
+ GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, tmp_v2);
}
+ }
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v);
+ GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[1]);
+ GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]);
+
+ GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[5]);
+ GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]);
+
+ GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[3]);
+ GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]);
+
+ SHC.drw_lightprobe_grid = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ }
+ return SHC.drw_lightprobe_grid;
+}
+
+Gwn_Batch *DRW_cache_lightprobe_planar_get(void)
+{
+ if (!SHC.drw_lightprobe_planar) {
+ int v_idx = 0;
+ const float sin_pi_3 = 0.86602540378f;
+ float v[4][3] = {
+ {0.0f, 0.5f, 0.0f},
+ {sin_pi_3, 0.0f, 0.0f},
+ {0.0f, -0.5f, 0.0f},
+ {-sin_pi_3, 0.0f, 0.0f},
+ };
+
+ /* Position Only 3D format */
+ static Gwn_VertFormat format = { 0 };
+ static struct { uint pos; } attr_id;
+ if (format.attrib_ct == 0) {
+ attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ }
+
+ Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
+ GWN_vertbuf_data_alloc(vbo, 4 * 2);
+
+ for (int i = 0; i < 4; ++i) {
+ GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[i]);
+ GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[(i + 1) % 4]);
}
- v[0] = 0.0f;
- v[1] = 1.0f;
- GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v);
- SHC.drw_lightprobe = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ SHC.drw_lightprobe_planar = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
- return SHC.drw_lightprobe;
-#undef CIRCLE_RESOL
+ return SHC.drw_lightprobe_planar;
}
/** \} */
@@ -1454,7 +1538,7 @@ Gwn_Batch *DRW_cache_bone_octahedral_get(void)
GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, bone_octahedral_verts[bone_octahedral_solid_tris[i][2]]);
}
- SHC.drw_bone_octahedral = GWN_batch_create(GWN_PRIM_TRIS, vbo, NULL);
+ SHC.drw_bone_octahedral = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_bone_octahedral;
}
@@ -1484,7 +1568,7 @@ Gwn_Batch *DRW_cache_bone_octahedral_wire_outline_get(void)
add_fancy_edge(vbo, attr_id.pos, attr_id.n1, attr_id.n2, &v_idx, co1, co2, n1, n2);
}
- SHC.drw_bone_octahedral_wire = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ SHC.drw_bone_octahedral_wire = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_bone_octahedral_wire;
}
@@ -1539,7 +1623,7 @@ static const unsigned int bone_box_solid_tris[12][3] = {
/* aligned with bone_octahedral_solid_tris */
static const float bone_box_solid_normals[12][3] = {
{ 0.0f, -1.0f, 0.0f},
- { 0.0f, -1.0f, 0.0f},
+ { 0.0f, -1.0f, 0.0f},
{ 1.0f, 0.0f, 0.0f},
{ 1.0f, 0.0f, 0.0f},
@@ -1580,7 +1664,7 @@ Gwn_Batch *DRW_cache_bone_box_get(void)
}
}
- SHC.drw_bone_box = GWN_batch_create(GWN_PRIM_TRIS, vbo, NULL);
+ SHC.drw_bone_box = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_bone_box;
}
@@ -1610,7 +1694,7 @@ Gwn_Batch *DRW_cache_bone_box_wire_outline_get(void)
add_fancy_edge(vbo, attr_id.pos, attr_id.n1, attr_id.n2, &v_idx, co1, co2, n1, n2);
}
- SHC.drw_bone_box_wire = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ SHC.drw_bone_box_wire = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_bone_box_wire;
}
@@ -1638,7 +1722,7 @@ Gwn_Batch *DRW_cache_bone_wire_wire_outline_get(void)
const float n[3] = {1.0f, 0.0f, 0.0f};
add_fancy_edge(vbo, attr_id.pos, attr_id.n1, attr_id.n2, &v_idx, co1, co2, n, n);
- SHC.drw_bone_wire_wire = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ SHC.drw_bone_wire_wire = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_bone_wire_wire;
}
@@ -1698,10 +1782,10 @@ Gwn_Batch *DRW_cache_bone_envelope_solid_get(void)
float co1[3], co2[3], co3[3], co4[3];
for (int j = 0; j < lat_res; j++, lat += lat_inc) {
- benv_lat_lon_to_co(lat , lon , co1);
- benv_lat_lon_to_co(lat , lon + lon_inc, co2);
+ benv_lat_lon_to_co(lat, lon, co1);
+ benv_lat_lon_to_co(lat, lon + lon_inc, co2);
benv_lat_lon_to_co(lat + lat_inc, lon + lon_inc, co3);
- benv_lat_lon_to_co(lat + lat_inc, lon , co4);
+ benv_lat_lon_to_co(lat + lat_inc, lon, co4);
if (j != 0) { /* At pole, n1 and n2 are identical. */
benv_add_tri(vbo, attr_id.pos, &v_idx, co1, co2, co3);
@@ -1730,7 +1814,7 @@ Gwn_Batch *DRW_cache_bone_envelope_solid_get(void)
}
}
- SHC.drw_bone_envelope = GWN_batch_create(GWN_PRIM_TRIS, vbo, NULL);
+ SHC.drw_bone_envelope = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_bone_envelope;
}
@@ -1769,7 +1853,7 @@ Gwn_Batch *DRW_cache_bone_envelope_distance_outline_get(void)
}
}
- SHC.drw_bone_envelope_distance = GWN_batch_create(GWN_PRIM_TRI_STRIP, vbo, NULL);
+ SHC.drw_bone_envelope_distance = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_bone_envelope_distance;
#undef CIRCLE_RESOL
@@ -1800,7 +1884,7 @@ Gwn_Batch *DRW_cache_bone_envelope_wire_outline_get(void)
GWN_vertbuf_attr_set(vbo, pos_id, v_idx++, (const float[4]){-1.0f, 0.0f, 0.0f, 0.0f});
GWN_vertbuf_attr_set(vbo, pos_id, v_idx++, (const float[4]){-1.0f, 0.0f, 1.0f, 0.0f});
- SHC.drw_bone_envelope_wire = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ SHC.drw_bone_envelope_wire = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_bone_envelope_wire;
}
@@ -1834,7 +1918,7 @@ Gwn_Batch *DRW_cache_bone_envelope_head_wire_outline_get(void)
GWN_vertbuf_attr_set(vbo, pos_id, v_idx++, (const float[4]){ x, y, 0.0f, 0.0f});
}
- SHC.drw_bone_envelope_head_wire = GWN_batch_create(GWN_PRIM_LINE_LOOP, vbo, NULL);
+ SHC.drw_bone_envelope_head_wire = GWN_batch_create_ex(GWN_PRIM_LINE_LOOP, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_bone_envelope_head_wire;
#undef CIRCLE_RESOL
@@ -1880,7 +1964,7 @@ Gwn_Batch *DRW_cache_bone_point_get(void)
}
}
- SHC.drw_bone_point = GWN_batch_create(GWN_PRIM_TRIS, vbo, NULL);
+ SHC.drw_bone_point = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_bone_point;
}
@@ -1889,7 +1973,7 @@ Gwn_Batch *DRW_cache_bone_point_wire_outline_get(void)
{
if (!SHC.drw_bone_point_wire) {
Gwn_VertBuf *vbo = sphere_wire_vbo(0.05f);
- SHC.drw_bone_point_wire = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ SHC.drw_bone_point_wire = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_bone_point_wire;
}
@@ -1898,7 +1982,7 @@ Gwn_Batch *DRW_cache_bone_arrows_get(void)
{
if (!SHC.drw_bone_arrows) {
Gwn_VertBuf *vbo = fill_arrows_vbo(0.25f);
- SHC.drw_bone_arrows = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ SHC.drw_bone_arrows = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_bone_arrows;
}
@@ -1971,7 +2055,7 @@ Gwn_Batch *DRW_cache_camera_get(void)
GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, &v7);
GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, &v5);
- SHC.drw_camera = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ SHC.drw_camera = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_camera;
}
@@ -2002,7 +2086,7 @@ Gwn_Batch *DRW_cache_camera_tria_get(void)
GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, &v6);
GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, &v7);
- SHC.drw_camera_tria = GWN_batch_create(GWN_PRIM_TRIS, vbo, NULL);
+ SHC.drw_camera_tria = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_camera_tria;
}
@@ -2032,7 +2116,7 @@ Gwn_Batch *DRW_cache_single_vert_get(void)
GWN_vertbuf_attr_set(vbo, attr_id.pos, 0, v1);
- SHC.drw_single_vertice = GWN_batch_create(GWN_PRIM_POINTS, vbo, NULL);
+ SHC.drw_single_vertice = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_single_vertice;
}
@@ -2119,12 +2203,13 @@ Gwn_Batch *DRW_cache_mesh_surface_vert_colors_get(Object *ob)
}
/* Return list of batches */
-Gwn_Batch **DRW_cache_mesh_surface_shaded_get(Object *ob)
+Gwn_Batch **DRW_cache_mesh_surface_shaded_get(
+ Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len)
{
BLI_assert(ob->type == OB_MESH);
Mesh *me = ob->data;
- return DRW_mesh_batch_cache_get_surface_shaded(me);
+ return DRW_mesh_batch_cache_get_surface_shaded(me, gpumat_array, gpumat_array_len);
}
/* Return list of batches */
@@ -2192,6 +2277,14 @@ Gwn_Batch *DRW_cache_mesh_verts_weight_overlay_get(Object *ob)
return DRW_mesh_batch_cache_get_weight_overlay_verts(me);
}
+void DRW_cache_mesh_sculpt_coords_ensure(Object *ob)
+{
+ BLI_assert(ob->type == OB_MESH);
+
+ Mesh *me = ob->data;
+ DRW_mesh_cache_sculpt_coords_ensure(me);
+}
+
/** \} */
/* -------------------------------------------------------------------- */
@@ -2308,12 +2401,18 @@ Gwn_Batch *DRW_cache_lattice_verts_get(Object *ob)
return DRW_lattice_batch_cache_get_all_verts(lt);
}
-Gwn_Batch *DRW_cache_lattice_wire_get(Object *ob)
+Gwn_Batch *DRW_cache_lattice_wire_get(Object *ob, bool use_weight)
{
BLI_assert(ob->type == OB_LATTICE);
- struct Lattice *lt = ob->data;
- return DRW_lattice_batch_cache_get_all_edges(lt);
+ Lattice *lt = ob->data;
+ int actdef = -1;
+
+ if (use_weight && ob->defbase.first && lt->editlatt->latt->dvert) {
+ actdef = ob->actdef - 1;
+ }
+
+ return DRW_lattice_batch_cache_get_all_edges(lt, use_weight, actdef);
}
Gwn_Batch *DRW_cache_lattice_vert_overlay_get(Object *ob)
@@ -2331,9 +2430,9 @@ Gwn_Batch *DRW_cache_lattice_vert_overlay_get(Object *ob)
/** \name Particles
* \{ */
-Gwn_Batch *DRW_cache_particles_get_hair(ParticleSystem *psys)
+Gwn_Batch *DRW_cache_particles_get_hair(ParticleSystem *psys, ModifierData *md)
{
- return DRW_particles_batch_cache_get_hair(psys);
+ return DRW_particles_batch_cache_get_hair(psys, md);
}
Gwn_Batch *DRW_cache_particles_get_dots(ParticleSystem *psys)
@@ -2387,7 +2486,7 @@ Gwn_Batch *DRW_cache_particles_get_prim(int type)
GWN_vertbuf_attr_set(vbo, pos_id, 5, co);
GWN_vertbuf_attr_set(vbo, axis_id, 5, &axis);
- SHC.drw_particle_cross = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ SHC.drw_particle_cross = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_particle_cross;
@@ -2434,7 +2533,7 @@ Gwn_Batch *DRW_cache_particles_get_prim(int type)
GWN_vertbuf_attr_set(vbo, pos_id, 5, co);
GWN_vertbuf_attr_set(vbo, axis_id, 5, &axis);
- SHC.drw_particle_axis = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ SHC.drw_particle_axis = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_particle_axis;
@@ -2463,7 +2562,7 @@ Gwn_Batch *DRW_cache_particles_get_prim(int type)
GWN_vertbuf_attr_set(vbo, axis_id, a, &axis);
}
- SHC.drw_particle_circle = GWN_batch_create(GWN_PRIM_LINE_LOOP, vbo, NULL);
+ SHC.drw_particle_circle = GWN_batch_create_ex(GWN_PRIM_LINE_LOOP, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return SHC.drw_particle_circle;
diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h
index a4fac3fe71f..54b840edfe6 100644
--- a/source/blender/draw/intern/draw_cache.h
+++ b/source/blender/draw/intern/draw_cache.h
@@ -27,12 +27,15 @@
#define __DRAW_CACHE_H__
struct Gwn_Batch;
+struct GPUMaterial;
struct Object;
+struct ModifierData;
void DRW_shape_cache_free(void);
/* Common Shapes */
struct Gwn_Batch *DRW_cache_fullscreen_quad_get(void);
+struct Gwn_Batch *DRW_cache_quad_get(void);
struct Gwn_Batch *DRW_cache_sphere_get(void);
struct Gwn_Batch *DRW_cache_single_vert_get(void);
struct Gwn_Batch *DRW_cache_single_line_get(void);
@@ -42,7 +45,8 @@ struct Gwn_Batch *DRW_cache_screenspace_circle_get(void);
/* Common Object */
struct Gwn_Batch *DRW_cache_object_wire_outline_get(struct Object *ob);
struct Gwn_Batch *DRW_cache_object_surface_get(struct Object *ob);
-struct Gwn_Batch **DRW_cache_object_surface_material_get(struct Object *ob);
+struct Gwn_Batch **DRW_cache_object_surface_material_get(
+ struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len);
/* Empties */
struct Gwn_Batch *DRW_cache_plain_axes_get(void);
@@ -80,7 +84,9 @@ struct Gwn_Batch *DRW_cache_camera_tria_get(void);
struct Gwn_Batch *DRW_cache_speaker_get(void);
/* Probe */
-struct Gwn_Batch *DRW_cache_lightprobe_get(void);
+struct Gwn_Batch *DRW_cache_lightprobe_cube_get(void);
+struct Gwn_Batch *DRW_cache_lightprobe_grid_get(void);
+struct Gwn_Batch *DRW_cache_lightprobe_planar_get(void);
/* Bones */
struct Gwn_Batch *DRW_cache_bone_octahedral_get(void);
@@ -115,10 +121,13 @@ struct Gwn_Batch *DRW_cache_mesh_verts_get(struct Object *ob);
struct Gwn_Batch *DRW_cache_mesh_edges_paint_overlay_get(struct Object *ob, bool use_wire, bool use_sel);
struct Gwn_Batch *DRW_cache_mesh_faces_weight_overlay_get(struct Object *ob);
struct Gwn_Batch *DRW_cache_mesh_verts_weight_overlay_get(struct Object *ob);
-struct Gwn_Batch **DRW_cache_mesh_surface_shaded_get(struct Object *ob);
+struct Gwn_Batch **DRW_cache_mesh_surface_shaded_get(
+ struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len);
struct Gwn_Batch **DRW_cache_mesh_surface_texpaint_get(struct Object *ob);
struct Gwn_Batch *DRW_cache_mesh_surface_texpaint_single_get(struct Object *ob);
+void DRW_cache_mesh_sculpt_coords_ensure(struct Object *ob);
+
/* Curve */
struct Gwn_Batch *DRW_cache_curve_surface_get(struct Object *ob);
struct Gwn_Batch *DRW_cache_curve_surface_verts_get(struct Object *ob);
@@ -140,11 +149,11 @@ struct Gwn_Batch *DRW_cache_surf_surface_get(struct Object *ob);
/* Lattice */
struct Gwn_Batch *DRW_cache_lattice_verts_get(struct Object *ob);
-struct Gwn_Batch *DRW_cache_lattice_wire_get(struct Object *ob);
+struct Gwn_Batch *DRW_cache_lattice_wire_get(struct Object *ob, bool use_weight);
struct Gwn_Batch *DRW_cache_lattice_vert_overlay_get(struct Object *ob);
/* Particles */
-struct Gwn_Batch *DRW_cache_particles_get_hair(struct ParticleSystem *psys);
+struct Gwn_Batch *DRW_cache_particles_get_hair(struct ParticleSystem *psys, struct ModifierData *md);
struct Gwn_Batch *DRW_cache_particles_get_dots(struct ParticleSystem *psys);
struct Gwn_Batch *DRW_cache_particles_get_prim(int type);
diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h
index 066ca9f60e0..82972b9f75b 100644
--- a/source/blender/draw/intern/draw_cache_impl.h
+++ b/source/blender/draw/intern/draw_cache_impl.h
@@ -27,9 +27,11 @@
#define __DRAW_CACHE_IMPL_H__
struct Gwn_Batch;
+struct GPUMaterial;
struct ListBase;
struct CurveCache;
struct ParticleSystem;
+struct ModifierData;
struct Curve;
struct Lattice;
@@ -65,13 +67,14 @@ struct Gwn_Batch *DRW_curve_batch_cache_get_overlay_select(struct Curve *cu);
struct Gwn_Batch *BLI_displist_batch_calc_surface(struct ListBase *lb);
/* Lattice */
-struct Gwn_Batch *DRW_lattice_batch_cache_get_all_edges(struct Lattice *lt);
+struct Gwn_Batch *DRW_lattice_batch_cache_get_all_edges(struct Lattice *lt, bool use_weight, const int actdef);
struct Gwn_Batch *DRW_lattice_batch_cache_get_all_verts(struct Lattice *lt);
struct Gwn_Batch *DRW_lattice_batch_cache_get_overlay_verts(struct Lattice *lt);
/* Mesh */
-struct Gwn_Batch **DRW_mesh_batch_cache_get_surface_shaded(struct Mesh *me);
+struct Gwn_Batch **DRW_mesh_batch_cache_get_surface_shaded(
+ struct Mesh *me, struct GPUMaterial **gpumat_array, uint gpumat_array_len);
struct Gwn_Batch **DRW_mesh_batch_cache_get_surface_texpaint(struct Mesh *me);
struct Gwn_Batch *DRW_mesh_batch_cache_get_surface_texpaint_single(struct Mesh *me);
struct Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_edges(struct Mesh *me, bool use_wire, bool use_sel);
@@ -82,7 +85,8 @@ struct Gwn_Batch *DRW_mesh_batch_cache_get_all_triangles(struct Mesh *me);
struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals(struct Mesh *me);
struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(struct Mesh *me, int defgroup);
struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(struct Mesh *me);
-struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_id(struct Mesh *me, bool use_hide);
+struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_id(struct Mesh *me, bool use_hide, uint select_id_offset);
+struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_mask(struct Mesh *me, bool use_hide);
struct Gwn_Batch *DRW_mesh_batch_cache_get_points_with_normals(struct Mesh *me);
struct Gwn_Batch *DRW_mesh_batch_cache_get_all_verts(struct Mesh *me);
struct Gwn_Batch *DRW_mesh_batch_cache_get_fancy_edges(struct Mesh *me);
@@ -92,9 +96,15 @@ struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_edges(struct Mesh *me);
struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_edges_nor(struct Mesh *me);
struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_verts(struct Mesh *me);
struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_facedots(struct Mesh *me);
+/* edit-mesh selection (use generic function for faces) */
+struct Gwn_Batch *DRW_mesh_batch_cache_get_facedots_with_select_id(struct Mesh *me, uint select_id_offset);
+struct Gwn_Batch *DRW_mesh_batch_cache_get_edges_with_select_id(struct Mesh *me, uint select_id_offset);
+struct Gwn_Batch *DRW_mesh_batch_cache_get_verts_with_select_id(struct Mesh *me, uint select_id_offset);
+
+void DRW_mesh_cache_sculpt_coords_ensure(struct Mesh *me);
/* Particles */
-struct Gwn_Batch *DRW_particles_batch_cache_get_hair(struct ParticleSystem *psys);
+struct Gwn_Batch *DRW_particles_batch_cache_get_hair(struct ParticleSystem *psys, struct ModifierData *md);
struct Gwn_Batch *DRW_particles_batch_cache_get_dots(struct ParticleSystem *psys);
#endif /* __DRAW_CACHE_IMPL_H__ */
diff --git a/source/blender/draw/intern/draw_cache_impl_curve.c b/source/blender/draw/intern/draw_cache_impl_curve.c
index 9ff9fab4c64..e6e52fe4579 100644
--- a/source/blender/draw/intern/draw_cache_impl_curve.c
+++ b/source/blender/draw/intern/draw_cache_impl_curve.c
@@ -422,12 +422,12 @@ void DRW_curve_batch_cache_dirty(Curve *cu, int mode)
break;
case BKE_CURVE_BATCH_DIRTY_SELECT:
/* editnurb */
- BATCH_DISCARD_ALL_SAFE(cache->overlay.verts);
- BATCH_DISCARD_ALL_SAFE(cache->overlay.edges);
+ GWN_BATCH_DISCARD_SAFE(cache->overlay.verts);
+ GWN_BATCH_DISCARD_SAFE(cache->overlay.edges);
/* editfont */
- BATCH_DISCARD_ALL_SAFE(cache->text.select);
- BATCH_DISCARD_ALL_SAFE(cache->text.cursor);
+ GWN_BATCH_DISCARD_SAFE(cache->text.select);
+ GWN_BATCH_DISCARD_SAFE(cache->text.cursor);
break;
default:
BLI_assert(0);
@@ -441,38 +441,26 @@ static void curve_batch_cache_clear(Curve *cu)
return;
}
- BATCH_DISCARD_ALL_SAFE(cache->overlay.verts);
- BATCH_DISCARD_ALL_SAFE(cache->overlay.edges);
+ GWN_BATCH_DISCARD_SAFE(cache->overlay.verts);
+ GWN_BATCH_DISCARD_SAFE(cache->overlay.edges);
- BATCH_DISCARD_ALL_SAFE(cache->surface.batch);
+ GWN_BATCH_DISCARD_SAFE(cache->surface.batch);
- if (cache->wire.batch) {
- BATCH_DISCARD_ALL_SAFE(cache->wire.batch);
- cache->wire.verts = NULL;
- cache->wire.edges = NULL;
- cache->wire.elem = NULL;
- }
- else {
- GWN_VERTBUF_DISCARD_SAFE(cache->wire.verts);
- GWN_VERTBUF_DISCARD_SAFE(cache->wire.edges);
- GWN_INDEXBUF_DISCARD_SAFE(cache->wire.elem);
- }
+ /* don't own vbo & elems */
+ GWN_BATCH_DISCARD_SAFE(cache->wire.batch);
+ GWN_VERTBUF_DISCARD_SAFE(cache->wire.verts);
+ GWN_VERTBUF_DISCARD_SAFE(cache->wire.edges);
+ GWN_INDEXBUF_DISCARD_SAFE(cache->wire.elem);
- if (cache->normal.batch) {
- BATCH_DISCARD_ALL_SAFE(cache->normal.batch);
- cache->normal.verts = NULL;
- cache->normal.edges = NULL;
- cache->normal.elem = NULL;
- }
- else {
- GWN_VERTBUF_DISCARD_SAFE(cache->normal.verts);
- GWN_VERTBUF_DISCARD_SAFE(cache->normal.edges);
- GWN_INDEXBUF_DISCARD_SAFE(cache->normal.elem);
- }
+ /* don't own vbo & elems */
+ GWN_BATCH_DISCARD_SAFE(cache->normal.batch);
+ GWN_VERTBUF_DISCARD_SAFE(cache->normal.verts);
+ GWN_VERTBUF_DISCARD_SAFE(cache->normal.edges);
+ GWN_INDEXBUF_DISCARD_SAFE(cache->normal.elem);
/* 3d text */
- BATCH_DISCARD_ALL_SAFE(cache->text.cursor);
- BATCH_DISCARD_ALL_SAFE(cache->text.select);
+ GWN_BATCH_DISCARD_SAFE(cache->text.cursor);
+ GWN_BATCH_DISCARD_SAFE(cache->text.select);
}
void DRW_curve_batch_cache_free(Curve *cu)
@@ -726,7 +714,7 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu)
GWN_vertbuf_data_resize(vbo, vbo_len_used);
}
- cache->overlay.verts = GWN_batch_create(GWN_PRIM_POINTS, vbo, NULL);
+ cache->overlay.verts = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
@@ -798,7 +786,7 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu)
GWN_vertbuf_data_resize(vbo, vbo_len_used);
}
- cache->overlay.edges = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ cache->overlay.edges = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
curve_render_data_free(rdata);
@@ -892,7 +880,7 @@ static Gwn_Batch *curve_batch_cache_get_overlay_select(CurveRenderData *rdata, C
GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[3]);
}
BLI_assert(vbo_len_used == vbo_len_capacity);
- cache->text.select = GWN_batch_create(GWN_PRIM_TRIS, vbo, NULL);
+ cache->text.select = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return cache->text.select;
}
@@ -913,7 +901,7 @@ static Gwn_Batch *curve_batch_cache_get_overlay_cursor(CurveRenderData *rdata, C
for (int i = 0; i < 4; i++) {
GWN_vertbuf_attr_set(vbo, attr_id.pos, i, rdata->text.edit_font->textcurs[i]);
}
- cache->text.cursor = GWN_batch_create(GWN_PRIM_TRI_FAN, vbo, NULL);
+ cache->text.cursor = GWN_batch_create_ex(GWN_PRIM_TRI_FAN, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
return cache->text.cursor;
}
@@ -950,7 +938,8 @@ Gwn_Batch *DRW_curve_batch_cache_get_normal_edge(Curve *cu, CurveCache *ob_curve
if (cache->normal.batch != NULL) {
cache->normal_size = normal_size;
if (cache->normal_size != normal_size) {
- BATCH_DISCARD_ALL_SAFE(cache->normal.batch);
+ GWN_BATCH_DISCARD_SAFE(cache->normal.batch);
+ GWN_VERTBUF_DISCARD_SAFE(cache->normal.edges);
}
}
cache->normal_size = normal_size;
diff --git a/source/blender/draw/intern/draw_cache_impl_displist.c b/source/blender/draw/intern/draw_cache_impl_displist.c
index fd36b7ad4a3..e051d61d056 100644
--- a/source/blender/draw/intern/draw_cache_impl_displist.c
+++ b/source/blender/draw/intern/draw_cache_impl_displist.c
@@ -163,6 +163,8 @@ Gwn_Batch *BLI_displist_batch_calc_surface(ListBase *lb)
}
}
- return GWN_batch_create(GWN_PRIM_TRIS, vbo, GWN_indexbuf_build(&elb));
+ return GWN_batch_create_ex(
+ GWN_PRIM_TRIS, vbo, GWN_indexbuf_build(&elb),
+ GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX);
}
}
diff --git a/source/blender/draw/intern/draw_cache_impl_lattice.c b/source/blender/draw/intern/draw_cache_impl_lattice.c
index dfba2aedcda..20698fe6592 100644
--- a/source/blender/draw/intern/draw_cache_impl_lattice.c
+++ b/source/blender/draw/intern/draw_cache_impl_lattice.c
@@ -36,8 +36,12 @@
#include "DNA_curve_types.h"
#include "DNA_lattice_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_userdef_types.h"
#include "BKE_lattice.h"
+#include "BKE_deform.h"
+#include "BKE_texture.h"
#include "GPU_batch.h"
@@ -130,6 +134,8 @@ typedef struct LatticeRenderData {
BPoint *bp;
int actbp;
+
+ struct MDeformVert *dvert;
} LatticeRenderData;
enum {
@@ -149,6 +155,8 @@ static LatticeRenderData *lattice_render_data_create(Lattice *lt, const int type
rdata->edit_latt = editlatt;
+ rdata->dvert = lt->dvert;
+
if (types & (LR_DATATYPE_VERT)) {
rdata->vert_len = lattice_render_verts_len_get(lt);
}
@@ -160,6 +168,8 @@ static LatticeRenderData *lattice_render_data_create(Lattice *lt, const int type
}
}
else {
+ rdata->dvert = NULL;
+
if (types & (LR_DATATYPE_VERT)) {
rdata->vert_len = lattice_render_verts_len_get(lt);
}
@@ -209,6 +219,60 @@ static const BPoint *lattice_render_data_vert_bpoint(const LatticeRenderData *rd
return &rdata->bp[vert_idx];
}
+/* TODO, move into shader? */
+static void rgb_from_weight(float r_rgb[3], const float weight)
+{
+ const float blend = ((weight / 2.0f) + 0.5f);
+
+ if (weight <= 0.25f) { /* blue->cyan */
+ r_rgb[0] = 0.0f;
+ r_rgb[1] = blend * weight * 4.0f;
+ r_rgb[2] = blend;
+ }
+ else if (weight <= 0.50f) { /* cyan->green */
+ r_rgb[0] = 0.0f;
+ r_rgb[1] = blend;
+ r_rgb[2] = blend * (1.0f - ((weight - 0.25f) * 4.0f));
+ }
+ else if (weight <= 0.75f) { /* green->yellow */
+ r_rgb[0] = blend * ((weight - 0.50f) * 4.0f);
+ r_rgb[1] = blend;
+ r_rgb[2] = 0.0f;
+ }
+ else if (weight <= 1.0f) { /* yellow->red */
+ r_rgb[0] = blend;
+ r_rgb[1] = blend * (1.0f - ((weight - 0.75f) * 4.0f));
+ r_rgb[2] = 0.0f;
+ }
+ else {
+ /* exceptional value, unclamped or nan,
+ * avoid uninitialized memory use */
+ r_rgb[0] = 1.0f;
+ r_rgb[1] = 0.0f;
+ r_rgb[2] = 1.0f;
+ }
+}
+
+static void lattice_render_data_weight_col_get(const LatticeRenderData *rdata, const int vert_idx,
+ const int actdef, float r_col[4])
+{
+ if (actdef > -1) {
+ float weight = defvert_find_weight(rdata->dvert + vert_idx, actdef);
+
+ if (U.flag & USER_CUSTOM_RANGE) {
+ do_colorband(&U.coba_weight, weight, r_col);
+ }
+ else {
+ rgb_from_weight(r_col, weight);
+ }
+
+ r_col[3] = 1.0f;
+ }
+ else {
+ zero_v4(r_col);
+ }
+}
+
enum {
VFLAG_VERTEX_SELECTED = 1 << 0,
VFLAG_VERTEX_ACTIVE = 1 << 1,
@@ -312,7 +376,7 @@ void DRW_lattice_batch_cache_dirty(Lattice *lt, int mode)
break;
case BKE_LATTICE_BATCH_DIRTY_SELECT:
/* TODO Separate Flag vbo */
- BATCH_DISCARD_ALL_SAFE(cache->overlay_verts);
+ GWN_BATCH_DISCARD_SAFE(cache->overlay_verts);
break;
default:
BLI_assert(0);
@@ -328,7 +392,7 @@ static void lattice_batch_cache_clear(Lattice *lt)
GWN_BATCH_DISCARD_SAFE(cache->all_verts);
GWN_BATCH_DISCARD_SAFE(cache->all_edges);
- BATCH_DISCARD_ALL_SAFE(cache->overlay_verts);
+ GWN_BATCH_DISCARD_SAFE(cache->overlay_verts);
GWN_VERTBUF_DISCARD_SAFE(cache->pos);
GWN_INDEXBUF_DISCARD_SAFE(cache->edges);
@@ -341,16 +405,22 @@ void DRW_lattice_batch_cache_free(Lattice *lt)
}
/* Gwn_Batch cache usage. */
-static Gwn_VertBuf *lattice_batch_cache_get_pos(LatticeRenderData *rdata, LatticeBatchCache *cache)
+static Gwn_VertBuf *lattice_batch_cache_get_pos(LatticeRenderData *rdata, LatticeBatchCache *cache,
+ bool use_weight, const int actdef)
{
BLI_assert(rdata->types & LR_DATATYPE_VERT);
if (cache->pos == NULL) {
static Gwn_VertFormat format = { 0 };
- static struct { uint pos; } attr_id;
- if (format.attrib_ct == 0) {
- /* initialize vertex format */
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ static struct { uint pos, col; } attr_id;
+
+ GWN_vertformat_clear(&format);
+
+ /* initialize vertex format */
+ attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+
+ if (use_weight) {
+ attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
}
const int vert_len = lattice_render_data_verts_len_get(rdata);
@@ -360,6 +430,13 @@ static Gwn_VertBuf *lattice_batch_cache_get_pos(LatticeRenderData *rdata, Lattic
for (int i = 0; i < vert_len; ++i) {
const BPoint *bp = lattice_render_data_vert_bpoint(rdata, i);
GWN_vertbuf_attr_set(cache->pos, attr_id.pos, i, bp->vec);
+
+ if (use_weight) {
+ float w_col[4];
+ lattice_render_data_weight_col_get(rdata, i, actdef, w_col);
+
+ GWN_vertbuf_attr_set(cache->pos, attr_id.col, i, w_col);
+ }
}
}
@@ -460,13 +537,13 @@ static void lattice_batch_cache_create_overlay_batches(Lattice *lt)
GWN_vertbuf_attr_set(vbo, attr_id.data, i, &vflag);
}
- cache->overlay_verts = GWN_batch_create(GWN_PRIM_POINTS, vbo, NULL);
+ cache->overlay_verts = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
lattice_render_data_free(rdata);
}
-Gwn_Batch *DRW_lattice_batch_cache_get_all_edges(Lattice *lt)
+Gwn_Batch *DRW_lattice_batch_cache_get_all_edges(Lattice *lt, bool use_weight, const int actdef)
{
LatticeBatchCache *cache = lattice_batch_cache_get(lt);
@@ -474,7 +551,7 @@ Gwn_Batch *DRW_lattice_batch_cache_get_all_edges(Lattice *lt)
/* create batch from Lattice */
LatticeRenderData *rdata = lattice_render_data_create(lt, LR_DATATYPE_VERT | LR_DATATYPE_EDGE);
- cache->all_edges = GWN_batch_create(GWN_PRIM_LINES, lattice_batch_cache_get_pos(rdata, cache),
+ cache->all_edges = GWN_batch_create(GWN_PRIM_LINES, lattice_batch_cache_get_pos(rdata, cache, use_weight, actdef),
lattice_batch_cache_get_edges(rdata, cache));
lattice_render_data_free(rdata);
@@ -490,7 +567,7 @@ Gwn_Batch *DRW_lattice_batch_cache_get_all_verts(Lattice *lt)
if (cache->all_verts == NULL) {
LatticeRenderData *rdata = lattice_render_data_create(lt, LR_DATATYPE_VERT);
- cache->all_verts = GWN_batch_create(GWN_PRIM_POINTS, lattice_batch_cache_get_pos(rdata, cache), NULL);
+ cache->all_verts = GWN_batch_create(GWN_PRIM_POINTS, lattice_batch_cache_get_pos(rdata, cache, false, -1), NULL);
lattice_render_data_free(rdata);
}
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index 524ee22f577..33d7cab285f 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -33,7 +33,9 @@
#include "BLI_utildefines.h"
#include "BLI_math_vector.h"
+#include "BLI_math_bits.h"
#include "BLI_string.h"
+#include "BLI_alloca.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
@@ -52,6 +54,7 @@
#include "GPU_batch.h"
#include "GPU_draw.h"
+#include "GPU_material.h"
#include "draw_cache_impl.h" /* own include */
@@ -146,6 +149,7 @@ typedef struct MeshRenderData {
int vcol_active;
float (**tangent)[4];
+ int tangent_len;
int tangent_active;
bool *auto_vcol;
@@ -170,7 +174,7 @@ typedef struct MeshRenderData {
struct {
CustomData ldata;
/* grr, special case variable (use in place of 'dm->tangent_mask') */
- char tangent_mask;
+ short tangent_mask;
} output;
} cd;
@@ -187,8 +191,8 @@ typedef struct MeshRenderData {
float (*poly_normals)[3];
float (*vert_weight_color)[3];
char (*vert_color)[3];
- short (*poly_normals_short)[3];
- short (*vert_normals_short)[3];
+ Gwn_PackedNormal *poly_normals_pack;
+ Gwn_PackedNormal *vert_normals_pack;
bool *edge_select_bool;
} MeshRenderData;
@@ -235,7 +239,113 @@ static bool bm_edge_has_visible_face(const BMEdge *e)
}
-static MeshRenderData *mesh_render_data_create(Mesh *me, const int types)
+static void mesh_cd_calc_used_gpu_layers(
+ CustomData *UNUSED(cd_vdata), uchar cd_vused[CD_NUMTYPES],
+ CustomData *cd_ldata, ushort cd_lused[CD_NUMTYPES],
+ struct GPUMaterial **gpumat_array, int gpumat_array_len)
+{
+ /* See: DM_vertex_attributes_from_gpu for similar logic */
+ GPUVertexAttribs gattribs = {{{0}}};
+
+ for (int i = 0; i < gpumat_array_len; i++) {
+ GPUMaterial *gpumat = gpumat_array[i];
+ if (gpumat) {
+ GPU_material_vertex_attributes(gpumat, &gattribs);
+ for (int j = 0; j < gattribs.totlayer; j++) {
+ const char *name = gattribs.layer[j].name;
+ int type = gattribs.layer[j].type;
+ int layer = -1;
+
+ if (type == CD_AUTO_FROM_NAME) {
+ /* We need to deduct what exact layer is used.
+ *
+ * We do it based on the specified name.
+ */
+ if (name[0] != '\0') {
+ layer = CustomData_get_named_layer(cd_ldata, CD_MLOOPUV, name);
+ type = CD_MTFACE;
+
+ if (layer == -1) {
+ layer = CustomData_get_named_layer(cd_ldata, CD_MLOOPCOL, name);
+ type = CD_MCOL;
+ }
+#if 0 /* Tangents are always from UV's - this will never happen. */
+ if (layer == -1) {
+ layer = CustomData_get_named_layer(cd_ldata, CD_TANGENT, name);
+ type = CD_TANGENT;
+ }
+#endif
+ if (layer == -1) {
+ continue;
+ }
+ }
+ else {
+ /* Fall back to the UV layer, which matches old behavior. */
+ type = CD_MTFACE;
+ }
+ }
+
+ switch (type) {
+ case CD_MTFACE:
+ {
+ if (layer == -1) {
+ layer = (name[0] != '\0') ?
+ CustomData_get_named_layer(cd_ldata, CD_MLOOPUV, name) :
+ CustomData_get_active_layer(cd_ldata, CD_MLOOPUV);
+ }
+ if (layer != -1) {
+ cd_lused[CD_MLOOPUV] |= (1 << layer);
+ }
+ break;
+ }
+ case CD_TANGENT:
+ {
+ if (layer == -1) {
+ layer = (name[0] != '\0') ?
+ CustomData_get_named_layer(cd_ldata, CD_MLOOPUV, name) :
+ CustomData_get_active_layer(cd_ldata, CD_MLOOPUV);
+ }
+ if (layer != -1) {
+ cd_lused[CD_TANGENT] |= (1 << layer);
+ }
+ else {
+ /* no UV layers at all => requesting orco */
+ cd_lused[CD_TANGENT] |= DM_TANGENT_MASK_ORCO;
+ cd_vused[CD_ORCO] |= 1;
+ }
+ break;
+ }
+ case CD_MCOL:
+ {
+ if (layer == -1) {
+ layer = (name[0] != '\0') ?
+ CustomData_get_named_layer(cd_ldata, CD_MLOOPCOL, name) :
+ CustomData_get_active_layer(cd_ldata, CD_MLOOPCOL);
+ }
+ if (layer != -1) {
+ cd_lused[CD_MLOOPCOL] |= (1 << layer);
+ }
+ break;
+ }
+ case CD_ORCO:
+ {
+ cd_vused[CD_ORCO] |= 1;
+ break;
+ }
+ }
+ }
+ }
+ }
+}
+
+/**
+ * TODO(campbell): 'gpumat_array' may include materials linked to the object.
+ * While not default, object materials should be supported.
+ * Although this only impacts the data thats generated, not the materials that display.
+ */
+static MeshRenderData *mesh_render_data_create_ex(
+ Mesh *me, const int types,
+ struct GPUMaterial **gpumat_array, uint gpumat_array_len)
{
MeshRenderData *rdata = MEM_callocN(sizeof(*rdata), __func__);
rdata->types = types;
@@ -370,28 +480,58 @@ static MeshRenderData *mesh_render_data_create(Mesh *me, const int types)
cd_ldata = &me->ldata;
}
- rdata->orco = CustomData_get_layer(cd_vdata, CD_ORCO);
- /* If orco is not available compute it ourselves */
- if (!rdata->orco) {
- if (me->edit_btmesh) {
- BMesh *bm = me->edit_btmesh->bm;
- rdata->orco = MEM_mallocN(sizeof(*rdata->orco) * rdata->vert_len, "orco mesh");
- BLI_assert((bm->elem_table_dirty & BM_VERT) == 0);
- BMVert **vtable = bm->vtable;
- for (int i = 0; i < bm->totvert; i++) {
- copy_v3_v3(rdata->orco[i], vtable[i]->co);
+ /* Add edge/poly if we need them */
+ uchar cd_vused[CD_NUMTYPES] = {0};
+ ushort cd_lused[CD_NUMTYPES] = {0};
+
+ mesh_cd_calc_used_gpu_layers(
+ cd_vdata, cd_vused,
+ cd_ldata, cd_lused,
+ gpumat_array, gpumat_array_len);
+
+
+ rdata->cd.layers.uv_active = CustomData_get_active_layer(cd_ldata, CD_MLOOPUV);
+ rdata->cd.layers.vcol_active = CustomData_get_active_layer(cd_ldata, CD_MLOOPCOL);
+ rdata->cd.layers.tangent_active = rdata->cd.layers.uv_active;
+
+#define CD_VALIDATE_ACTIVE_LAYER(active_index, used) \
+ if ((active_index != -1) && (used & (1 << active_index)) == 0) { \
+ active_index = -1; \
+ } ((void)0)
+
+ CD_VALIDATE_ACTIVE_LAYER(rdata->cd.layers.uv_active, cd_lused[CD_MLOOPUV]);
+ CD_VALIDATE_ACTIVE_LAYER(rdata->cd.layers.tangent_active, cd_lused[CD_TANGENT]);
+ CD_VALIDATE_ACTIVE_LAYER(rdata->cd.layers.vcol_active, cd_lused[CD_MLOOPCOL]);
+
+#undef CD_VALIDATE_ACTIVE_LAYER
+
+ if (cd_vused[CD_ORCO] & 1) {
+ rdata->orco = CustomData_get_layer(cd_vdata, CD_ORCO);
+ /* If orco is not available compute it ourselves */
+ if (!rdata->orco) {
+ if (me->edit_btmesh) {
+ BMesh *bm = me->edit_btmesh->bm;
+ rdata->orco = MEM_mallocN(sizeof(*rdata->orco) * rdata->vert_len, "orco mesh");
+ BLI_assert((bm->elem_table_dirty & BM_VERT) == 0);
+ BMVert **vtable = bm->vtable;
+ for (int i = 0; i < bm->totvert; i++) {
+ copy_v3_v3(rdata->orco[i], vtable[i]->co);
+ }
+ BKE_mesh_orco_verts_transform(me, rdata->orco, rdata->vert_len, 0);
}
- BKE_mesh_orco_verts_transform(me, rdata->orco, rdata->vert_len, 0);
- }
- else {
- rdata->orco = MEM_mallocN(sizeof(*rdata->orco) * rdata->vert_len, "orco mesh");
- MVert *mvert = rdata->mvert;
- for (int a = 0; a < rdata->vert_len; a++, mvert++) {
- copy_v3_v3(rdata->orco[a], mvert->co);
+ else {
+ rdata->orco = MEM_mallocN(sizeof(*rdata->orco) * rdata->vert_len, "orco mesh");
+ MVert *mvert = rdata->mvert;
+ for (int a = 0; a < rdata->vert_len; a++, mvert++) {
+ copy_v3_v3(rdata->orco[a], mvert->co);
+ }
+ BKE_mesh_orco_verts_transform(me, rdata->orco, rdata->vert_len, 0);
}
- BKE_mesh_orco_verts_transform(me, rdata->orco, rdata->vert_len, 0);
}
}
+ else {
+ rdata->orco = NULL;
+ }
const bool is_auto_smooth = (me->flag & ME_AUTOSMOOTH) != 0;
@@ -399,17 +539,25 @@ static MeshRenderData *mesh_render_data_create(Mesh *me, const int types)
#define me DONT_USE_THIS
#ifdef me /* quiet warning */
#endif
+ struct {
+ uint uv_len;
+ uint vcol_len;
+ } cd_layers_src = {
+ .uv_len = CustomData_number_of_layers(cd_ldata, CD_MLOOPUV),
+ .vcol_len = CustomData_number_of_layers(cd_ldata, CD_MLOOPCOL),
+ };
- rdata->cd.layers.uv_len = CustomData_number_of_layers(cd_ldata, CD_MLOOPUV);
- rdata->cd.layers.vcol_len = CustomData_number_of_layers(cd_ldata, CD_MLOOPCOL);
+ rdata->cd.layers.uv_len = count_bits_i(cd_lused[CD_MLOOPUV]);
+ rdata->cd.layers.tangent_len = count_bits_i(cd_lused[CD_TANGENT]);
+ rdata->cd.layers.vcol_len = count_bits_i(cd_lused[CD_MLOOPCOL]);
rdata->cd.layers.uv = MEM_mallocN(sizeof(*rdata->cd.layers.uv) * rdata->cd.layers.uv_len, __func__);
rdata->cd.layers.vcol = MEM_mallocN(sizeof(*rdata->cd.layers.vcol) * rdata->cd.layers.vcol_len, __func__);
- rdata->cd.layers.tangent = MEM_mallocN(sizeof(*rdata->cd.layers.tangent) * rdata->cd.layers.uv_len, __func__);
+ rdata->cd.layers.tangent = MEM_mallocN(sizeof(*rdata->cd.layers.tangent) * rdata->cd.layers.tangent_len, __func__);
rdata->cd.uuid.uv = MEM_mallocN(sizeof(*rdata->cd.uuid.uv) * rdata->cd.layers.uv_len, __func__);
rdata->cd.uuid.vcol = MEM_mallocN(sizeof(*rdata->cd.uuid.vcol) * rdata->cd.layers.vcol_len, __func__);
- rdata->cd.uuid.tangent = MEM_mallocN(sizeof(*rdata->cd.uuid.tangent) * rdata->cd.layers.uv_len, __func__);
+ rdata->cd.uuid.tangent = MEM_mallocN(sizeof(*rdata->cd.uuid.tangent) * rdata->cd.layers.tangent_len, __func__);
rdata->cd.offset.uv = MEM_mallocN(sizeof(*rdata->cd.offset.uv) * rdata->cd.layers.uv_len, __func__);
rdata->cd.offset.vcol = MEM_mallocN(sizeof(*rdata->cd.offset.vcol) * rdata->cd.layers.vcol_len, __func__);
@@ -427,129 +575,181 @@ static MeshRenderData *mesh_render_data_create(Mesh *me, const int types)
* One solution to hash collision would be to format the cd layer name
* to a safe glsl var name, but without name clash.
* NOTE 2 : Replicate changes to code_generate_vertex_new() in gpu_codegen.c */
- for (int i = 0; i < rdata->cd.layers.vcol_len; ++i) {
- const char *name = CustomData_get_layer_name(cd_ldata, CD_MLOOPCOL, i);
- unsigned int hash = BLI_ghashutil_strhash_p(name);
- BLI_snprintf(rdata->cd.uuid.vcol[i], sizeof(*rdata->cd.uuid.vcol), "c%u", hash);
- rdata->cd.layers.vcol[i] = CustomData_get_layer_n(cd_ldata, CD_MLOOPCOL, i);
- if (rdata->edit_bmesh) {
- rdata->cd.offset.vcol[i] = CustomData_get_n_offset(&rdata->edit_bmesh->bm->ldata, CD_MLOOPCOL, i);
- }
+ if (rdata->cd.layers.vcol_len != 0) {
+ for (int i_src = 0, i_dst = 0; i_src < cd_layers_src.vcol_len; i_src++, i_dst++) {
+ if ((cd_lused[CD_MLOOPCOL] & (1 << i_src)) == 0) {
+ i_dst--;
+ if (rdata->cd.layers.vcol_active >= i_src) {
+ rdata->cd.layers.vcol_active--;
+ }
+ }
+ else {
+ const char *name = CustomData_get_layer_name(cd_ldata, CD_MLOOPCOL, i_src);
+ unsigned int hash = BLI_ghashutil_strhash_p(name);
+ BLI_snprintf(rdata->cd.uuid.vcol[i_dst], sizeof(*rdata->cd.uuid.vcol), "c%u", hash);
+ rdata->cd.layers.vcol[i_dst] = CustomData_get_layer_n(cd_ldata, CD_MLOOPCOL, i_src);
+ if (rdata->edit_bmesh) {
+ rdata->cd.offset.vcol[i_dst] = CustomData_get_n_offset(
+ &rdata->edit_bmesh->bm->ldata, CD_MLOOPCOL, i_src);
+ }
- /* Gather number of auto layers. */
- /* We only do vcols that are not overridden by uvs */
- if (CustomData_get_named_layer_index(cd_ldata, CD_MLOOPUV, name) == -1) {
- BLI_snprintf(
- rdata->cd.uuid.auto_mix[rdata->cd.layers.uv_len + i],
- sizeof(*rdata->cd.uuid.auto_mix), "a%u", hash);
- rdata->cd.layers.auto_vcol[i] = true;
+ /* Gather number of auto layers. */
+ /* We only do vcols that are not overridden by uvs */
+ if (CustomData_get_named_layer_index(cd_ldata, CD_MLOOPUV, name) == -1) {
+ BLI_snprintf(
+ rdata->cd.uuid.auto_mix[rdata->cd.layers.uv_len + i_dst],
+ sizeof(*rdata->cd.uuid.auto_mix), "a%u", hash);
+ rdata->cd.layers.auto_vcol[i_dst] = true;
+ }
+ }
}
}
/* Start Fresh */
+ CustomData_free_layers(cd_ldata, CD_TANGENT, rdata->loop_len);
CustomData_free_layers(cd_ldata, CD_MLOOPTANGENT, rdata->loop_len);
- for (int i = 0; i < rdata->cd.layers.uv_len; ++i) {
- const char *name = CustomData_get_layer_name(cd_ldata, CD_MLOOPUV, i);
- unsigned int hash = BLI_ghashutil_strhash_p(name);
- {
- /* UVs */
- BLI_snprintf(rdata->cd.uuid.uv[i], sizeof(*rdata->cd.uuid.uv), "u%u", hash);
- rdata->cd.layers.uv[i] = CustomData_get_layer_n(cd_ldata, CD_MLOOPUV, i);
- if (rdata->edit_bmesh) {
- rdata->cd.offset.uv[i] = CustomData_get_n_offset(&rdata->edit_bmesh->bm->ldata, CD_MLOOPUV, i);
+ if (rdata->cd.layers.uv_len != 0) {
+ for (int i_src = 0, i_dst = 0; i_src < cd_layers_src.uv_len; i_src++, i_dst++) {
+ if ((cd_lused[CD_MLOOPUV] & (1 << i_src)) == 0) {
+ i_dst--;
+ if (rdata->cd.layers.uv_active >= i_src) {
+ rdata->cd.layers.uv_active--;
+ }
}
- BLI_snprintf(rdata->cd.uuid.auto_mix[i], sizeof(*rdata->cd.uuid.auto_mix), "a%u", hash);
- }
+ else {
+ const char *name = CustomData_get_layer_name(cd_ldata, CD_MLOOPUV, i_src);
+ unsigned int hash = BLI_ghashutil_strhash_p(name);
- {
- /* Tangents*/
- BLI_snprintf(rdata->cd.uuid.tangent[i], sizeof(*rdata->cd.uuid.tangent), "t%u", hash);
-
- if (!CustomData_has_layer(&rdata->cd.output.ldata, CD_MLOOPTANGENT)) {
-
- /* Tangent Names */
- char tangent_names[MAX_MTFACE][MAX_NAME];
- int tangent_names_len = 0;
- for (tangent_names_len = 0; tangent_names_len < rdata->cd.layers.uv_len; tangent_names_len++) {
- BLI_strncpy(
- tangent_names[tangent_names_len],
- CustomData_get_layer_name(cd_ldata, CD_MLOOPUV, tangent_names_len), MAX_NAME);
+ BLI_snprintf(rdata->cd.uuid.uv[i_dst], sizeof(*rdata->cd.uuid.uv), "u%u", hash);
+ rdata->cd.layers.uv[i_dst] = CustomData_get_layer_n(cd_ldata, CD_MLOOPUV, i_src);
+ if (rdata->edit_bmesh) {
+ rdata->cd.offset.uv[i_dst] = CustomData_get_n_offset(
+ &rdata->edit_bmesh->bm->ldata, CD_MLOOPUV, i_src);
}
+ BLI_snprintf(rdata->cd.uuid.auto_mix[i_dst], sizeof(*rdata->cd.uuid.auto_mix), "a%u", hash);
+ }
+ }
+ }
- if (rdata->edit_bmesh) {
- BMEditMesh *em = rdata->edit_bmesh;
- BMesh *bm = em->bm;
+ if (rdata->cd.layers.tangent_len != 0) {
- if (is_auto_smooth) {
- /* TODO: split normals, see below */
- }
+ /* -------------------------------------------------------------------- */
+ /* Pre-calculate tangents into 'rdata->cd.output.ldata' */
- bool calc_active_tangent = false;
- float (*poly_normals)[3] = rdata->poly_normals;
- float (*loop_normals)[3] = CustomData_get_layer(cd_ldata, CD_NORMAL);
-
- BKE_editmesh_loop_tangent_calc(
- em, calc_active_tangent,
- tangent_names, tangent_names_len,
- poly_normals, loop_normals,
- rdata->orco,
- &rdata->cd.output.ldata, bm->totloop,
- &rdata->cd.output.tangent_mask);
- }
- else {
+ BLI_assert(!CustomData_has_layer(&rdata->cd.output.ldata, CD_TANGENT));
+
+ /* Tangent Names */
+ char tangent_names[MAX_MTFACE][MAX_NAME];
+ for (int i_src = 0, i_dst = 0; i_src < cd_layers_src.uv_len; i_src++, i_dst++) {
+ if ((cd_lused[CD_TANGENT] & (1 << i_src)) == 0) {
+ i_dst--;
+ }
+ else {
+ BLI_strncpy(
+ tangent_names[i_dst],
+ CustomData_get_layer_name(cd_ldata, CD_MLOOPUV, i_src), MAX_NAME);
+ }
+ }
+
+ /* If tangent from orco is requested, decrement tangent_len */
+ int actual_tangent_len = (cd_lused[CD_TANGENT] & DM_TANGENT_MASK_ORCO) ?
+ rdata->cd.layers.tangent_len - 1 : rdata->cd.layers.tangent_len;
+ if (rdata->edit_bmesh) {
+ BMEditMesh *em = rdata->edit_bmesh;
+ BMesh *bm = em->bm;
+
+ if (is_auto_smooth) {
+ /* TODO: split normals, see below */
+ }
+
+ bool calc_active_tangent = false;
+ float (*poly_normals)[3] = rdata->poly_normals;
+ float (*loop_normals)[3] = CustomData_get_layer(cd_ldata, CD_NORMAL);
+
+ BKE_editmesh_loop_tangent_calc(
+ em, calc_active_tangent,
+ tangent_names, actual_tangent_len,
+ poly_normals, loop_normals,
+ rdata->orco,
+ &rdata->cd.output.ldata, bm->totloop,
+ &rdata->cd.output.tangent_mask);
+ }
+ else {
#undef me
- if (is_auto_smooth) {
- if (!CustomData_has_layer(cd_ldata, CD_NORMAL)) {
- BKE_mesh_calc_normals_split(me);
- }
- }
+ if (is_auto_smooth) {
+ if (!CustomData_has_layer(cd_ldata, CD_NORMAL)) {
+ BKE_mesh_calc_normals_split(me);
+ }
+ }
- bool calc_active_tangent = false;
- const float (*poly_normals)[3] = rdata->poly_normals;
- const float (*loop_normals)[3] = CustomData_get_layer(cd_ldata, CD_NORMAL);
-
- BKE_mesh_calc_loop_tangent_ex(
- me->mvert,
- me->mpoly, me->totpoly,
- me->mloop,
- rdata->mlooptri, rdata->tri_len,
- cd_ldata,
- calc_active_tangent,
- tangent_names, tangent_names_len,
- poly_normals, loop_normals,
- rdata->orco,
- &rdata->cd.output.ldata, me->totloop,
- &rdata->cd.output.tangent_mask);
-
- /* If we store tangents in the mesh, set temporary. */
+ bool calc_active_tangent = false;
+ const float (*poly_normals)[3] = rdata->poly_normals;
+ const float (*loop_normals)[3] = CustomData_get_layer(cd_ldata, CD_NORMAL);
+
+ BKE_mesh_calc_loop_tangent_ex(
+ me->mvert,
+ me->mpoly, me->totpoly,
+ me->mloop,
+ rdata->mlooptri, rdata->tri_len,
+ cd_ldata,
+ calc_active_tangent,
+ tangent_names, actual_tangent_len,
+ poly_normals, loop_normals,
+ rdata->orco,
+ &rdata->cd.output.ldata, me->totloop,
+ &rdata->cd.output.tangent_mask);
+
+ /* If we store tangents in the mesh, set temporary. */
#if 0
- CustomData_set_layer_flag(cd_ldata, CD_MLOOPTANGENT, CD_FLAG_TEMPORARY);
+ CustomData_set_layer_flag(cd_ldata, CD_TANGENT, CD_FLAG_TEMPORARY);
#endif
#define me DONT_USE_THIS
#ifdef me /* quiet warning */
#endif
+ }
+
+ /* End tangent calculation */
+ /* -------------------------------------------------------------------- */
+
+ BLI_assert(CustomData_number_of_layers(&rdata->cd.output.ldata, CD_TANGENT) == rdata->cd.layers.tangent_len);
+
+ int i_dst = 0;
+ for (int i_src = 0; i_src < cd_layers_src.uv_len; i_src++, i_dst++) {
+ if ((cd_lused[CD_TANGENT] & (1 << i_src)) == 0) {
+ i_dst--;
+ if (rdata->cd.layers.tangent_active >= i_src) {
+ rdata->cd.layers.tangent_active--;
}
}
- /* Done adding tangents. */
+ else {
+ const char *name = CustomData_get_layer_name(cd_ldata, CD_MLOOPUV, i_src);
+ unsigned int hash = BLI_ghashutil_strhash_p(name);
- /* note: BKE_editmesh_loop_tangent_calc calculates 'CD_TANGENT',
- * not 'CD_MLOOPTANGENT' (as done below). It's OK, they're compatible. */
- rdata->cd.layers.tangent[i] = CustomData_get_layer_n(&rdata->cd.output.ldata, CD_TANGENT, i);
- if (rdata->tri_len != 0) {
- BLI_assert(rdata->cd.layers.tangent[i] != NULL);
+ BLI_snprintf(rdata->cd.uuid.tangent[i_dst], sizeof(*rdata->cd.uuid.tangent), "t%u", hash);
+
+ /* Done adding tangents. */
+
+ /* note: BKE_editmesh_loop_tangent_calc calculates 'CD_TANGENT',
+ * not 'CD_MLOOPTANGENT' (as done below). It's OK, they're compatible. */
+
+ /* note: normally we'd use 'i_src' here, but 'i_dst' is in sync with 'rdata->cd.output' */
+ rdata->cd.layers.tangent[i_dst] = CustomData_get_layer_n(&rdata->cd.output.ldata, CD_TANGENT, i_dst);
+ if (rdata->tri_len != 0) {
+ BLI_assert(rdata->cd.layers.tangent[i_dst] != NULL);
+ }
}
}
- }
+ if (cd_lused[CD_TANGENT] & DM_TANGENT_MASK_ORCO) {
+ const char *name = CustomData_get_layer_name(&rdata->cd.output.ldata, CD_TANGENT, i_dst);
+ unsigned int hash = BLI_ghashutil_strhash_p(name);
+ BLI_snprintf(rdata->cd.uuid.tangent[i_dst], sizeof(*rdata->cd.uuid.tangent), "t%u", hash);
- rdata->cd.layers.uv_active = CustomData_get_active_layer_index(
- cd_ldata, CD_MLOOPUV) - CustomData_get_layer_index(cd_ldata, CD_MLOOPUV);
- rdata->cd.layers.vcol_active = CustomData_get_active_layer_index(
- cd_ldata, CD_MLOOPCOL) - CustomData_get_layer_index(cd_ldata, CD_MLOOPCOL);
- rdata->cd.layers.tangent_active = CustomData_get_active_layer_index(
- cd_ldata, CD_MLOOPTANGENT) - CustomData_get_layer_index(cd_ldata, CD_MLOOPTANGENT);
+ rdata->cd.layers.tangent[i_dst] = CustomData_get_layer_n(&rdata->cd.output.ldata, CD_TANGENT, i_dst);
+ }
+ }
#undef me
}
@@ -575,8 +775,8 @@ static void mesh_render_data_free(MeshRenderData *rdata)
MEM_SAFE_FREE(rdata->edges_adjacent_polys);
MEM_SAFE_FREE(rdata->mlooptri);
MEM_SAFE_FREE(rdata->poly_normals);
- MEM_SAFE_FREE(rdata->poly_normals_short);
- MEM_SAFE_FREE(rdata->vert_normals_short);
+ MEM_SAFE_FREE(rdata->poly_normals_pack);
+ MEM_SAFE_FREE(rdata->vert_normals_pack);
MEM_SAFE_FREE(rdata->vert_weight_color);
MEM_SAFE_FREE(rdata->edge_select_bool);
MEM_SAFE_FREE(rdata->vert_color);
@@ -586,6 +786,11 @@ static void mesh_render_data_free(MeshRenderData *rdata)
MEM_freeN(rdata);
}
+static MeshRenderData *mesh_render_data_create(Mesh *me, const int types)
+{
+ return mesh_render_data_create_ex(me, types, NULL, 0);
+}
+
/** \} */
@@ -680,20 +885,20 @@ static int mesh_render_data_polys_len_get(const MeshRenderData *rdata)
/** \name Internal Cache (Lazy Initialization)
* \{ */
-/** Ensure #MeshRenderData.poly_normals_short */
-static void mesh_render_data_ensure_poly_normals_short(MeshRenderData *rdata)
+/** Ensure #MeshRenderData.poly_normals_pack */
+static void mesh_render_data_ensure_poly_normals_pack(MeshRenderData *rdata)
{
- short (*pnors_short)[3] = rdata->poly_normals_short;
- if (pnors_short == NULL) {
+ Gwn_PackedNormal *pnors_pack = rdata->poly_normals_pack;
+ if (pnors_pack == NULL) {
if (rdata->edit_bmesh) {
BMesh *bm = rdata->edit_bmesh->bm;
BMIter fiter;
BMFace *efa;
int i;
- pnors_short = rdata->poly_normals_short = MEM_mallocN(sizeof(*pnors_short) * rdata->poly_len, __func__);
+ pnors_pack = rdata->poly_normals_pack = MEM_mallocN(sizeof(*pnors_pack) * rdata->poly_len, __func__);
BM_ITER_MESH_INDEX(efa, &fiter, bm, BM_FACES_OF_MESH, i) {
- normal_float_to_short_v3(pnors_short[i], efa->no);
+ pnors_pack[i] = GWN_normal_convert_i10_v3(efa->no);
}
}
else {
@@ -706,28 +911,28 @@ static void mesh_render_data_ensure_poly_normals_short(MeshRenderData *rdata)
rdata->mloop, rdata->mpoly, rdata->loop_len, rdata->poly_len, pnors, true);
}
- pnors_short = rdata->poly_normals_short = MEM_mallocN(sizeof(*pnors_short) * rdata->poly_len, __func__);
+ pnors_pack = rdata->poly_normals_pack = MEM_mallocN(sizeof(*pnors_pack) * rdata->poly_len, __func__);
for (int i = 0; i < rdata->poly_len; i++) {
- normal_float_to_short_v3(pnors_short[i], pnors[i]);
+ pnors_pack[i] = GWN_normal_convert_i10_v3(pnors[i]);
}
}
}
}
-/** Ensure #MeshRenderData.vert_normals_short */
-static void mesh_render_data_ensure_vert_normals_short(MeshRenderData *rdata)
+/** Ensure #MeshRenderData.vert_normals_pack */
+static void mesh_render_data_ensure_vert_normals_pack(MeshRenderData *rdata)
{
- short (*vnors_short)[3] = rdata->vert_normals_short;
- if (vnors_short == NULL) {
+ Gwn_PackedNormal *vnors_pack = rdata->vert_normals_pack;
+ if (vnors_pack == NULL) {
if (rdata->edit_bmesh) {
BMesh *bm = rdata->edit_bmesh->bm;
BMIter viter;
BMVert *eve;
int i;
- vnors_short = rdata->vert_normals_short = MEM_mallocN(sizeof(*vnors_short) * rdata->vert_len, __func__);
+ vnors_pack = rdata->vert_normals_pack = MEM_mallocN(sizeof(*vnors_pack) * rdata->vert_len, __func__);
BM_ITER_MESH_INDEX(eve, &viter, bm, BM_VERT, i) {
- normal_float_to_short_v3(vnors_short[i], eve->no);
+ vnors_pack[i] = GWN_normal_convert_i10_v3(eve->no);
}
}
else {
@@ -935,7 +1140,7 @@ static bool mesh_render_data_pnors_pcenter_select_get(
return false;
}
BM_face_calc_center_mean(efa, r_center);
- BM_face_calc_normal(efa, r_pnors);
+ copy_v3_v3(r_pnors, efa->no);
*r_selected = (BM_elem_flag_test(efa, BM_ELEM_SELECT) != 0) ? true : false;
}
else {
@@ -1024,116 +1229,6 @@ static bool mesh_render_data_edge_vcos_manifold_pnors(
return true;
}
-static void mesh_render_data_looptri_uvs_get(
- MeshRenderData *rdata, const int tri_idx, const int uv_layer,
- float *(*r_vert_uvs)[3])
-{
- if (rdata->edit_bmesh) {
- const BMLoop **bm_looptri = (const BMLoop **)rdata->edit_bmesh->looptris[tri_idx];
- (*r_vert_uvs)[0] = ((MLoopUV *)BM_ELEM_CD_GET_VOID_P(bm_looptri[0], rdata->cd.offset.uv[uv_layer]))->uv;
- (*r_vert_uvs)[1] = ((MLoopUV *)BM_ELEM_CD_GET_VOID_P(bm_looptri[1], rdata->cd.offset.uv[uv_layer]))->uv;
- (*r_vert_uvs)[2] = ((MLoopUV *)BM_ELEM_CD_GET_VOID_P(bm_looptri[2], rdata->cd.offset.uv[uv_layer]))->uv;
- }
- else {
- const MLoopTri *mlt = &rdata->mlooptri[tri_idx];
- (*r_vert_uvs)[0] = rdata->cd.layers.uv[uv_layer][mlt->tri[0]].uv;
- (*r_vert_uvs)[1] = rdata->cd.layers.uv[uv_layer][mlt->tri[1]].uv;
- (*r_vert_uvs)[2] = rdata->cd.layers.uv[uv_layer][mlt->tri[2]].uv;
- }
-}
-
-static void mesh_render_data_looptri_cols_get(
- MeshRenderData *rdata, const int tri_idx, const int vcol_layer,
- unsigned char *(*r_vert_cols)[3])
-{
- if (rdata->edit_bmesh) {
- const BMLoop **bm_looptri = (const BMLoop **)rdata->edit_bmesh->looptris[tri_idx];
- (*r_vert_cols)[0] = &((MLoopCol *)BM_ELEM_CD_GET_VOID_P(bm_looptri[0], rdata->cd.offset.vcol[vcol_layer]))->r;
- (*r_vert_cols)[1] = &((MLoopCol *)BM_ELEM_CD_GET_VOID_P(bm_looptri[1], rdata->cd.offset.vcol[vcol_layer]))->r;
- (*r_vert_cols)[2] = &((MLoopCol *)BM_ELEM_CD_GET_VOID_P(bm_looptri[2], rdata->cd.offset.vcol[vcol_layer]))->r;
- }
- else {
- const MLoopTri *mlt = &rdata->mlooptri[tri_idx];
- (*r_vert_cols)[0] = &rdata->cd.layers.vcol[vcol_layer][mlt->tri[0]].r;
- (*r_vert_cols)[1] = &rdata->cd.layers.vcol[vcol_layer][mlt->tri[1]].r;
- (*r_vert_cols)[2] = &rdata->cd.layers.vcol[vcol_layer][mlt->tri[2]].r;
- }
-}
-
-static void mesh_render_data_looptri_tans_get(
- MeshRenderData *rdata, const int tri_idx, const int tangent_layer,
- float *(*r_vert_tans)[3])
-{
- if (rdata->edit_bmesh) {
- const BMLoop **bm_looptri = (const BMLoop **)rdata->edit_bmesh->looptris[tri_idx];
- (*r_vert_tans)[0] = rdata->cd.layers.tangent[tangent_layer][BM_elem_index_get(bm_looptri[0])];
- (*r_vert_tans)[1] = rdata->cd.layers.tangent[tangent_layer][BM_elem_index_get(bm_looptri[1])];
- (*r_vert_tans)[2] = rdata->cd.layers.tangent[tangent_layer][BM_elem_index_get(bm_looptri[2])];
- }
- else {
- const MLoopTri *mlt = &rdata->mlooptri[tri_idx];
- (*r_vert_tans)[0] = rdata->cd.layers.tangent[tangent_layer][mlt->tri[0]];
- (*r_vert_tans)[1] = rdata->cd.layers.tangent[tangent_layer][mlt->tri[1]];
- (*r_vert_tans)[2] = rdata->cd.layers.tangent[tangent_layer][mlt->tri[2]];
- }
-}
-
-static bool mesh_render_data_looptri_cos_nors_smooth_get(
- MeshRenderData *rdata, const int tri_idx, const bool use_hide,
- float *(*r_vert_cos)[3], short **r_tri_nor, short *(*r_vert_nors)[3], bool *r_is_smooth)
-{
- BLI_assert(rdata->types & MR_DATATYPE_VERT);
- BLI_assert(rdata->types & MR_DATATYPE_LOOPTRI);
- BLI_assert(rdata->types & MR_DATATYPE_LOOP);
- BLI_assert(rdata->types & MR_DATATYPE_POLY);
-
- if (rdata->edit_bmesh) {
- const BMLoop **bm_looptri = (const BMLoop **)rdata->edit_bmesh->looptris[tri_idx];
-
- /* Assume 'use_hide' */
- if (BM_elem_flag_test(bm_looptri[0]->f, BM_ELEM_HIDDEN)) {
- return false;
- }
-
- mesh_render_data_ensure_poly_normals_short(rdata);
- mesh_render_data_ensure_vert_normals_short(rdata);
-
- short (*pnors_short)[3] = rdata->poly_normals_short;
- short (*vnors_short)[3] = rdata->vert_normals_short;
-
- (*r_vert_cos)[0] = bm_looptri[0]->v->co;
- (*r_vert_cos)[1] = bm_looptri[1]->v->co;
- (*r_vert_cos)[2] = bm_looptri[2]->v->co;
- *r_tri_nor = pnors_short[BM_elem_index_get(bm_looptri[0]->f)];
- (*r_vert_nors)[0] = vnors_short[BM_elem_index_get(bm_looptri[0]->v)];
- (*r_vert_nors)[1] = vnors_short[BM_elem_index_get(bm_looptri[1]->v)];
- (*r_vert_nors)[2] = vnors_short[BM_elem_index_get(bm_looptri[2]->v)];
-
- *r_is_smooth = BM_elem_flag_test_bool(bm_looptri[0]->f, BM_ELEM_SMOOTH);
- }
- else {
- const MLoopTri *mlt = &rdata->mlooptri[tri_idx];
-
- if (use_hide && (rdata->mpoly[mlt->poly].flag & ME_HIDE)) {
- return false;
- }
-
- mesh_render_data_ensure_poly_normals_short(rdata);
-
- short (*pnors_short)[3] = rdata->poly_normals_short;
-
- (*r_vert_cos)[0] = rdata->mvert[rdata->mloop[mlt->tri[0]].v].co;
- (*r_vert_cos)[1] = rdata->mvert[rdata->mloop[mlt->tri[1]].v].co;
- (*r_vert_cos)[2] = rdata->mvert[rdata->mloop[mlt->tri[2]].v].co;
- *r_tri_nor = pnors_short[mlt->poly];
- (*r_vert_nors)[0] = rdata->mvert[rdata->mloop[mlt->tri[0]].v].no;
- (*r_vert_nors)[1] = rdata->mvert[rdata->mloop[mlt->tri[1]].v].no;
- (*r_vert_nors)[2] = rdata->mvert[rdata->mloop[mlt->tri[2]].v].no;
-
- *r_is_smooth = (rdata->mpoly[mlt->poly].flag & ME_SMOOTH) != 0;
- }
- return true;
-}
/* First 2 bytes are bit flags
* 3rd is for sharp edges
@@ -1235,9 +1330,9 @@ static void add_overlay_tri(
if (vbo_nor) {
/* TODO real loop normal */
- PackedNormal lnor = convert_i10_v3(bm_looptri[0]->f->no);
+ Gwn_PackedNormal lnor = GWN_normal_convert_i10_v3(bm_looptri[0]->f->no);
for (uint i = 0; i < 3; i++) {
- PackedNormal vnor = convert_i10_v3(bm_looptri[i]->v->no);
+ Gwn_PackedNormal vnor = GWN_normal_convert_i10_v3(bm_looptri[i]->v->no);
GWN_vertbuf_attr_set(vbo_nor, vnor_id, base_vert_idx + i, &vnor);
GWN_vertbuf_attr_set(vbo_nor, lnor_id, base_vert_idx + i, &lnor);
}
@@ -1275,7 +1370,7 @@ static void add_overlay_loose_edge(
if (vbo_nor) {
for (int i = 0; i < 2; ++i) {
- PackedNormal vnor = convert_i10_v3((&eed->v1)[i]->no);
+ Gwn_PackedNormal vnor = GWN_normal_convert_i10_v3((&eed->v1)[i]->no);
GWN_vertbuf_attr_set(vbo_nor, vnor_id, base_vert_idx + i, &vnor);
}
}
@@ -1301,7 +1396,7 @@ static void add_overlay_loose_vert(
}
if (vbo_nor) {
- PackedNormal vnor = convert_i10_v3(eve->no);
+ Gwn_PackedNormal vnor = GWN_normal_convert_i10_v3(eve->no);
GWN_vertbuf_attr_set(vbo_nor, vnor_id, base_vert_idx, &vnor);
}
@@ -1325,28 +1420,39 @@ typedef struct MeshBatchCache {
Gwn_VertBuf *nor_in_order;
Gwn_IndexBuf *edges_in_order;
Gwn_IndexBuf *triangles_in_order;
- Gwn_IndexBuf *overlay_triangles_vpaint;
Gwn_Batch *all_verts;
Gwn_Batch *all_edges;
Gwn_Batch *all_triangles;
Gwn_VertBuf *pos_with_normals;
- Gwn_VertBuf *pos_with_normals_visible_only; /* for paint modes with vert/face hide support. */
- Gwn_VertBuf *tri_aligned_weights;
- Gwn_VertBuf *tri_aligned_vert_colors;
- Gwn_VertBuf *tri_aligned_select_id;
Gwn_VertBuf *tri_aligned_uv; /* Active UV layer (mloopuv) */
- Gwn_VertBuf *edge_pos_with_select_bool;
- Gwn_VertBuf *pos_with_select_bool;
+
+ /**
+ * Other uses are all positions or loose elements.
+ * This stores all visible elements, needed for selection.
+ */
+ Gwn_VertBuf *ed_fcenter_pos_with_nor_and_sel;
+ Gwn_VertBuf *ed_edge_pos;
+ Gwn_VertBuf *ed_vert_pos;
+
Gwn_Batch *triangles_with_normals;
- /* Skip hidden (depending on paint select mode),
- * 'pos_with_normals' or 'pos_with_normals_visible_only'. */
+ /* Skip hidden (depending on paint select mode) */
Gwn_Batch *triangles_with_weights;
Gwn_Batch *triangles_with_vert_colors;
/* Always skip hidden */
+ Gwn_Batch *triangles_with_select_mask;
Gwn_Batch *triangles_with_select_id;
+ uint triangles_with_select_id_offset;
+
+ Gwn_Batch *facedot_with_select_id; /* shares vbo with 'overlay_facedots' */
+ Gwn_Batch *edges_with_select_id;
+ Gwn_Batch *verts_with_select_id;
+
+ uint facedot_with_select_id_offset;
+ uint edges_with_select_id_offset;
+ uint verts_with_select_id_offset;
Gwn_Batch *points_with_normals;
Gwn_Batch *fancy_edges; /* owns its vertex buffer (not shared) */
@@ -1376,9 +1482,6 @@ typedef struct MeshBatchCache {
Gwn_VertBuf *ed_lvert_nor; /* VertNor */
Gwn_VertBuf *ed_lvert_data;
- Gwn_VertBuf *ed_fcenter_pos;
- Gwn_VertBuf *ed_fcenter_nor;
-
Gwn_Batch *overlay_triangles;
Gwn_Batch *overlay_triangles_nor; /* GWN_PRIM_POINTS */
Gwn_Batch *overlay_loose_edges;
@@ -1391,14 +1494,17 @@ typedef struct MeshBatchCache {
Gwn_Batch *overlay_paint_edges;
/* settings to determine if cache is invalid */
- bool is_dirty;
- bool is_paint_dirty;
+ bool is_maybe_dirty;
+ bool is_dirty; /* Instantly invalidates cache, skipping mesh check */
int edge_len;
int tri_len;
int poly_len;
int vert_len;
int mat_len;
bool is_editmode;
+
+ /* XXX, only keep for as long as sculpt mode uses shaded drawing. */
+ bool is_sculpt_points_tag;
} MeshBatchCache;
/* Gwn_Batch cache management. */
@@ -1413,18 +1519,18 @@ static bool mesh_batch_cache_valid(Mesh *me)
/* XXX find another place for this */
if (cache->mat_len != mesh_render_mat_len_get(me)) {
- cache->is_dirty = true;
+ cache->is_maybe_dirty = true;
}
if (cache->is_editmode != (me->edit_btmesh != NULL)) {
return false;
}
- if (cache->is_paint_dirty) {
+ if (cache->is_dirty) {
return false;
}
- if (cache->is_dirty == false) {
+ if (cache->is_maybe_dirty == false) {
return true;
}
else {
@@ -1466,8 +1572,8 @@ static void mesh_batch_cache_init(Mesh *me)
cache->mat_len = mesh_render_mat_len_get(me);
+ cache->is_maybe_dirty = false;
cache->is_dirty = false;
- cache->is_paint_dirty = false;
}
static MeshBatchCache *mesh_batch_cache_get(Mesh *me)
@@ -1486,22 +1592,36 @@ void DRW_mesh_batch_cache_dirty(Mesh *me, int mode)
return;
}
switch (mode) {
- case BKE_MESH_BATCH_DIRTY_ALL:
- cache->is_dirty = true;
+ case BKE_MESH_BATCH_DIRTY_MAYBE_ALL:
+ cache->is_maybe_dirty = true;
break;
case BKE_MESH_BATCH_DIRTY_SELECT:
GWN_VERTBUF_DISCARD_SAFE(cache->ed_tri_data);
GWN_VERTBUF_DISCARD_SAFE(cache->ed_ledge_data);
GWN_VERTBUF_DISCARD_SAFE(cache->ed_lvert_data);
- GWN_VERTBUF_DISCARD_SAFE(cache->ed_fcenter_nor); /* Contains select flag */
+ GWN_VERTBUF_DISCARD_SAFE(cache->ed_fcenter_pos_with_nor_and_sel); /* Contains select flag */
+ GWN_VERTBUF_DISCARD_SAFE(cache->ed_edge_pos);
+ GWN_VERTBUF_DISCARD_SAFE(cache->ed_vert_pos);
+
GWN_BATCH_DISCARD_SAFE(cache->overlay_triangles);
GWN_BATCH_DISCARD_SAFE(cache->overlay_loose_verts);
GWN_BATCH_DISCARD_SAFE(cache->overlay_loose_edges);
-
- BATCH_DISCARD_ALL_SAFE(cache->overlay_facedots);
+ GWN_BATCH_DISCARD_SAFE(cache->overlay_facedots);
+ /* Edit mode selection. */
+ GWN_BATCH_DISCARD_SAFE(cache->facedot_with_select_id);
+ GWN_BATCH_DISCARD_SAFE(cache->edges_with_select_id);
+ GWN_BATCH_DISCARD_SAFE(cache->verts_with_select_id);
break;
- case BKE_MESH_BATCH_DIRTY_PAINT:
- cache->is_paint_dirty = true;
+ case BKE_MESH_BATCH_DIRTY_ALL:
+ cache->is_dirty = true;
+ break;
+ case BKE_MESH_BATCH_DIRTY_SHADING:
+ /* TODO: This should only update UV and tangent data,
+ * and not free the entire cache. */
+ cache->is_dirty = true;
+ break;
+ case BKE_MESH_BATCH_DIRTY_SCULPT_COORDS:
+ cache->is_sculpt_points_tag = true;
break;
default:
BLI_assert(0);
@@ -1520,10 +1640,8 @@ static void mesh_batch_cache_clear(Mesh *me)
GWN_BATCH_DISCARD_SAFE(cache->all_triangles);
GWN_VERTBUF_DISCARD_SAFE(cache->pos_in_order);
- GWN_VERTBUF_DISCARD_SAFE(cache->pos_with_select_bool);
GWN_INDEXBUF_DISCARD_SAFE(cache->edges_in_order);
GWN_INDEXBUF_DISCARD_SAFE(cache->triangles_in_order);
- GWN_INDEXBUF_DISCARD_SAFE(cache->overlay_triangles_vpaint);
GWN_VERTBUF_DISCARD_SAFE(cache->ed_tri_pos);
GWN_VERTBUF_DISCARD_SAFE(cache->ed_tri_nor);
@@ -1534,8 +1652,6 @@ static void mesh_batch_cache_clear(Mesh *me)
GWN_VERTBUF_DISCARD_SAFE(cache->ed_lvert_pos);
GWN_VERTBUF_DISCARD_SAFE(cache->ed_lvert_nor);
GWN_VERTBUF_DISCARD_SAFE(cache->ed_lvert_data);
- GWN_VERTBUF_DISCARD_SAFE(cache->ed_fcenter_pos);
- GWN_VERTBUF_DISCARD_SAFE(cache->ed_fcenter_nor);
GWN_BATCH_DISCARD_SAFE(cache->overlay_triangles);
GWN_BATCH_DISCARD_SAFE(cache->overlay_triangles_nor);
GWN_BATCH_DISCARD_SAFE(cache->overlay_loose_verts);
@@ -1544,22 +1660,25 @@ static void mesh_batch_cache_clear(Mesh *me)
GWN_BATCH_DISCARD_SAFE(cache->overlay_weight_faces);
GWN_BATCH_DISCARD_SAFE(cache->overlay_weight_verts);
- BATCH_DISCARD_ALL_SAFE(cache->overlay_paint_edges);
- BATCH_DISCARD_ALL_SAFE(cache->overlay_facedots);
+ GWN_BATCH_DISCARD_SAFE(cache->overlay_paint_edges);
+ GWN_BATCH_DISCARD_SAFE(cache->overlay_facedots);
GWN_BATCH_DISCARD_SAFE(cache->triangles_with_normals);
GWN_BATCH_DISCARD_SAFE(cache->points_with_normals);
GWN_VERTBUF_DISCARD_SAFE(cache->pos_with_normals);
- GWN_VERTBUF_DISCARD_SAFE(cache->pos_with_normals_visible_only);
- GWN_VERTBUF_DISCARD_SAFE(cache->tri_aligned_vert_colors);
- GWN_VERTBUF_DISCARD_SAFE(cache->tri_aligned_weights);
GWN_BATCH_DISCARD_SAFE(cache->triangles_with_weights);
GWN_BATCH_DISCARD_SAFE(cache->triangles_with_vert_colors);
- GWN_VERTBUF_DISCARD_SAFE(cache->tri_aligned_select_id);
GWN_VERTBUF_DISCARD_SAFE(cache->tri_aligned_uv);
+ GWN_VERTBUF_DISCARD_SAFE(cache->ed_fcenter_pos_with_nor_and_sel);
+ GWN_VERTBUF_DISCARD_SAFE(cache->ed_edge_pos);
+ GWN_VERTBUF_DISCARD_SAFE(cache->ed_vert_pos);
+ GWN_BATCH_DISCARD_SAFE(cache->triangles_with_select_mask);
GWN_BATCH_DISCARD_SAFE(cache->triangles_with_select_id);
+ GWN_BATCH_DISCARD_SAFE(cache->facedot_with_select_id);
+ GWN_BATCH_DISCARD_SAFE(cache->edges_with_select_id);
+ GWN_BATCH_DISCARD_SAFE(cache->verts_with_select_id);
- BATCH_DISCARD_ALL_SAFE(cache->fancy_edges);
+ GWN_BATCH_DISCARD_SAFE(cache->fancy_edges);
GWN_VERTBUF_DISCARD_SAFE(cache->shaded_triangles_data);
if (cache->shaded_triangles_in_order) {
@@ -1601,10 +1720,12 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata,
#define USE_COMP_MESH_DATA
if (cache->shaded_triangles_data == NULL) {
- unsigned int vidx = 0;
- const char *attrib_name;
+ const uint uv_len = rdata->cd.layers.uv_len;
+ const uint tangent_len = rdata->cd.layers.tangent_len;
+ const uint vcol_len = rdata->cd.layers.vcol_len;
+ const uint layers_combined_len = uv_len + vcol_len + tangent_len;
- if (rdata->cd.layers.uv_len + rdata->cd.layers.vcol_len == 0) {
+ if (layers_combined_len == 0) {
return NULL;
}
@@ -1613,13 +1734,19 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata,
GWN_vertformat_clear(format);
/* initialize vertex format */
- unsigned int *uv_id = MEM_mallocN(sizeof(*uv_id) * rdata->cd.layers.uv_len, "UV attrib format");
- unsigned int *vcol_id = MEM_mallocN(sizeof(*vcol_id) * rdata->cd.layers.vcol_len, "Vcol attrib format");
- unsigned int *tangent_id = MEM_mallocN(sizeof(*tangent_id) * rdata->cd.layers.uv_len, "Tangent attrib format");
+ uint *layers_combined_id = BLI_array_alloca(layers_combined_id, layers_combined_len);
+ uint *uv_id = layers_combined_id;
+ uint *tangent_id = uv_id + uv_len;
+ uint *vcol_id = tangent_id + tangent_len;
- for (int i = 0; i < rdata->cd.layers.uv_len; i++) {
+ /* Not needed, just for sanity. */
+ if (uv_len == 0) { uv_id = NULL; }
+ if (tangent_len == 0) { tangent_id = NULL; }
+ if (vcol_len == 0) { vcol_id = NULL; }
+
+ for (uint i = 0; i < uv_len; i++) {
/* UV */
- attrib_name = mesh_render_data_uv_layer_uuid_get(rdata, i);
+ const char *attrib_name = mesh_render_data_uv_layer_uuid_get(rdata, i);
#if defined(USE_COMP_MESH_DATA) && 0 /* these are clamped. Maybe use them as an option in the future */
uv_id[i] = GWN_vertformat_attr_add(format, attrib_name, GWN_COMP_I16, 2, GWN_FETCH_INT_TO_FLOAT_UNIT);
#else
@@ -1633,9 +1760,10 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata,
if (i == rdata->cd.layers.uv_active) {
GWN_vertformat_alias_add(format, "u");
}
+ }
- /* Tangent */
- attrib_name = mesh_render_data_tangent_layer_uuid_get(rdata, i);
+ for (uint i = 0; i < tangent_len; i++) {
+ const char *attrib_name = mesh_render_data_tangent_layer_uuid_get(rdata, i);
/* WATCH IT : only specifying 3 component instead of 4 (4th is sign).
* That may cause some problem but I could not make it to fail (fclem) */
#ifdef USE_COMP_MESH_DATA
@@ -1645,13 +1773,13 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata,
tangent_id[i] = GWN_vertformat_attr_add(format, attrib_name, GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
#endif
- if (i == rdata->cd.layers.uv_active) {
+ if (i == rdata->cd.layers.tangent_active) {
GWN_vertformat_alias_add(format, "t");
}
}
- for (int i = 0; i < rdata->cd.layers.vcol_len; i++) {
- attrib_name = mesh_render_data_vcol_layer_uuid_get(rdata, i);
+ for (uint i = 0; i < vcol_len; i++) {
+ const char *attrib_name = mesh_render_data_vcol_layer_uuid_get(rdata, i);
vcol_id[i] = GWN_vertformat_attr_add(format, attrib_name, GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
/* Auto layer */
@@ -1665,7 +1793,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata,
}
}
- const int tri_len = mesh_render_data_looptri_len_get(rdata);
+ const uint tri_len = mesh_render_data_looptri_len_get(rdata);
Gwn_VertBuf *vbo = cache->shaded_triangles_data = GWN_vertbuf_create_with_format(format);
@@ -1673,67 +1801,110 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata,
int vbo_len_used = 0;
GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
+ Gwn_VertBufRaw *layers_combined_step = BLI_array_alloca(layers_combined_step, layers_combined_len);
+
+ Gwn_VertBufRaw *uv_step = layers_combined_step;
+ Gwn_VertBufRaw *tangent_step = uv_step + uv_len;
+ Gwn_VertBufRaw *vcol_step = tangent_step + tangent_len;
+
+ /* Not needed, just for sanity. */
+ if (uv_len == 0) { uv_step = NULL; }
+ if (tangent_len == 0) { tangent_step = NULL; }
+ if (vcol_len == 0) { vcol_step = NULL; }
+
+ for (uint i = 0; i < uv_len; i++) {
+ GWN_vertbuf_attr_get_raw_data(vbo, uv_id[i], &uv_step[i]);
+ }
+ for (uint i = 0; i < tangent_len; i++) {
+ GWN_vertbuf_attr_get_raw_data(vbo, tangent_id[i], &tangent_step[i]);
+ }
+ for (uint i = 0; i < vcol_len; i++) {
+ GWN_vertbuf_attr_get_raw_data(vbo, vcol_id[i], &vcol_step[i]);
+ }
+
/* TODO deduplicate all verts and make use of Gwn_IndexBuf in
* mesh_batch_cache_get_triangles_in_order_split_by_material. */
- for (int i = 0; i < tri_len; i++) {
- float *tri_uvs[3], *tri_tans[3];
- unsigned char *tri_cols[3];
-
- if (rdata->edit_bmesh == NULL ||
- BM_elem_flag_test((rdata->edit_bmesh->looptris[i])[0]->f, BM_ELEM_HIDDEN) == 0)
- {
- /* UVs & TANGENTs */
- for (int j = 0; j < rdata->cd.layers.uv_len; j++) {
- /* UVs */
- mesh_render_data_looptri_uvs_get(rdata, i, j, &tri_uvs);
-#if defined(USE_COMP_MESH_DATA) && 0 /* these are clamped. Maybe use them as an option in the future */
- short s_uvs[3][2];
- normal_float_to_short_v2(s_uvs[0], tri_uvs[0]);
- normal_float_to_short_v2(s_uvs[1], tri_uvs[1]);
- normal_float_to_short_v2(s_uvs[2], tri_uvs[2]);
-#else
- float **s_uvs = tri_uvs;
-#endif
- GWN_vertbuf_attr_set(vbo, uv_id[j], vidx + 0, s_uvs[0]);
- GWN_vertbuf_attr_set(vbo, uv_id[j], vidx + 1, s_uvs[1]);
- GWN_vertbuf_attr_set(vbo, uv_id[j], vidx + 2, s_uvs[2]);
+ if (rdata->edit_bmesh) {
+ for (uint i = 0; i < tri_len; i++) {
+ const BMLoop **bm_looptri = (const BMLoop **)rdata->edit_bmesh->looptris[i];
+ if (BM_elem_flag_test(bm_looptri[0]->f, BM_ELEM_HIDDEN)) {
+ continue;
+ }
+ /* UVs */
+ for (uint j = 0; j < uv_len; j++) {
+ const uint layer_offset = rdata->cd.offset.uv[j];
+ for (uint t = 0; t < 3; t++) {
+ const float *elem = ((MLoopUV *)BM_ELEM_CD_GET_VOID_P(bm_looptri[t], layer_offset))->uv;
+ copy_v2_v2(GWN_vertbuf_raw_step(&uv_step[j]), elem);
+ }
+ }
+ /* TANGENTs */
+ for (uint j = 0; j < tangent_len; j++) {
+ float (*layer_data)[4] = rdata->cd.layers.tangent[j];
+ for (uint t = 0; t < 3; t++) {
+ const float *elem = layer_data[BM_elem_index_get(bm_looptri[t])];
+ normal_float_to_short_v3(GWN_vertbuf_raw_step(&tangent_step[j]), elem);
+ }
+ }
+ /* VCOLs */
+ for (uint j = 0; j < vcol_len; j++) {
+ const uint layer_offset = rdata->cd.offset.vcol[j];
+ for (uint t = 0; t < 3; t++) {
+ const uchar *elem = &((MLoopCol *)BM_ELEM_CD_GET_VOID_P(bm_looptri[t], layer_offset))->r;
+ copy_v3_v3_uchar(GWN_vertbuf_raw_step(&vcol_step[j]), elem);
+ }
+ }
+ }
+ }
+ else {
+ for (uint i = 0; i < tri_len; i++) {
+ const MLoopTri *mlt = &rdata->mlooptri[i];
- /* Tangent */
- mesh_render_data_looptri_tans_get(rdata, i, j, &tri_tans);
+ /* UVs */
+ for (uint j = 0; j < uv_len; j++) {
+ const MLoopUV *layer_data = rdata->cd.layers.uv[j];
+ for (uint t = 0; t < 3; t++) {
+ const float *elem = layer_data[mlt->tri[t]].uv;
+ copy_v2_v2(GWN_vertbuf_raw_step(&uv_step[j]), elem);
+ }
+ }
+ /* TANGENTs */
+ for (uint j = 0; j < tangent_len; j++) {
+ float (*layer_data)[4] = rdata->cd.layers.tangent[j];
+ for (uint t = 0; t < 3; t++) {
+ const float *elem = layer_data[mlt->tri[t]];
#ifdef USE_COMP_MESH_DATA
- /* Tangents need more precision than 10_10_10 */
- short s_tan[3][3];
- normal_float_to_short_v3(s_tan[0], tri_tans[0]);
- normal_float_to_short_v3(s_tan[1], tri_tans[1]);
- normal_float_to_short_v3(s_tan[2], tri_tans[2]);
+ normal_float_to_short_v3(GWN_vertbuf_raw_step(&tangent_step[j]), elem);
#else
- float **s_tan = tri_tans;
+ copy_v3_v3(GWN_vertbuf_raw_step(&tangent_step[j]), elem);
#endif
- GWN_vertbuf_attr_set(vbo, tangent_id[j], vidx + 0, s_tan[0]);
- GWN_vertbuf_attr_set(vbo, tangent_id[j], vidx + 1, s_tan[1]);
- GWN_vertbuf_attr_set(vbo, tangent_id[j], vidx + 2, s_tan[2]);
+ }
}
-
/* VCOLs */
- for (int j = 0; j < rdata->cd.layers.vcol_len; j++) {
- mesh_render_data_looptri_cols_get(rdata, i, j, &tri_cols);
- GWN_vertbuf_attr_set(vbo, vcol_id[j], vidx + 0, tri_cols[0]);
- GWN_vertbuf_attr_set(vbo, vcol_id[j], vidx + 1, tri_cols[1]);
- GWN_vertbuf_attr_set(vbo, vcol_id[j], vidx + 2, tri_cols[2]);
+ for (uint j = 0; j < vcol_len; j++) {
+ const MLoopCol *layer_data = rdata->cd.layers.vcol[j];
+ for (uint t = 0; t < 3; t++) {
+ const uchar *elem = &layer_data[mlt->tri[t]].r;
+ copy_v3_v3_uchar(GWN_vertbuf_raw_step(&vcol_step[j]), elem);
+ }
}
+ }
+ }
+
+ vbo_len_used = GWN_vertbuf_raw_used(&layers_combined_step[0]);
- vidx += 3;
+#ifndef NDEBUG
+ /* Check all layers are write aligned. */
+ if (layers_combined_len > 1) {
+ for (uint i = 1; i < layers_combined_len; i++) {
+ BLI_assert(vbo_len_used == GWN_vertbuf_raw_used(&layers_combined_step[i]));
}
}
- vbo_len_used = vidx;
+#endif
if (vbo_len_capacity != vbo_len_used) {
GWN_vertbuf_data_resize(vbo, vbo_len_used);
}
-
- MEM_freeN(uv_id);
- MEM_freeN(vcol_id);
- MEM_freeN(tangent_id);
}
#undef USE_COMP_MESH_DATA
@@ -1775,6 +1946,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_uv_active(
vbo_len_used = vidx;
BLI_assert(vbo_len_capacity == vbo_len_used);
+ UNUSED_VARS_NDEBUG(vbo_len_used);
}
return cache->tri_aligned_uv;
@@ -1787,8 +1959,6 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_pos_and_normals_ex(
BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY));
if (*r_vbo == NULL) {
- unsigned int vidx = 0, nidx = 0;
-
static Gwn_VertFormat format = { 0 };
static struct { uint pos, nor; } attr_id;
if (format.attrib_ct == 0) {
@@ -1804,41 +1974,90 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_pos_and_normals_ex(
int vbo_len_used = 0;
GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
- for (int i = 0; i < tri_len; i++) {
- float *tri_vert_cos[3];
- short *tri_nor, *tri_vert_nors[3];
- bool is_smooth;
+ Gwn_VertBufRaw pos_step, nor_step;
+ GWN_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step);
+ GWN_vertbuf_attr_get_raw_data(vbo, attr_id.nor, &nor_step);
- if (mesh_render_data_looptri_cos_nors_smooth_get(
- rdata, i, use_hide, &tri_vert_cos, &tri_nor, &tri_vert_nors, &is_smooth))
- {
- if (is_smooth) {
- PackedNormal snor_pack[3] = {
- convert_i10_s3(tri_vert_nors[0]),
- convert_i10_s3(tri_vert_nors[1]),
- convert_i10_s3(tri_vert_nors[2])
- };
- PackedNormal *snor[3] = { &snor_pack[0], &snor_pack[1], &snor_pack[2] };
-
- GWN_vertbuf_attr_set(vbo, attr_id.nor, nidx++, snor[0]);
- GWN_vertbuf_attr_set(vbo, attr_id.nor, nidx++, snor[1]);
- GWN_vertbuf_attr_set(vbo, attr_id.nor, nidx++, snor[2]);
+ if (rdata->edit_bmesh) {
+ mesh_render_data_ensure_poly_normals_pack(rdata);
+ mesh_render_data_ensure_vert_normals_pack(rdata);
+
+ Gwn_PackedNormal *pnors_pack = rdata->poly_normals_pack;
+ Gwn_PackedNormal *vnors_pack = rdata->vert_normals_pack;
+
+ for (int i = 0; i < tri_len; i++) {
+ const BMLoop **bm_looptri = (const BMLoop **)rdata->edit_bmesh->looptris[i];
+ const BMFace *bm_face = bm_looptri[0]->f;
+
+ /* use_hide always for edit-mode */
+ if (BM_elem_flag_test(bm_face, BM_ELEM_HIDDEN)) {
+ continue;
+ }
+
+ const uint vtri[3] = {
+ BM_elem_index_get(bm_looptri[0]->v),
+ BM_elem_index_get(bm_looptri[1]->v),
+ BM_elem_index_get(bm_looptri[2]->v),
+ };
+
+ if (BM_elem_flag_test(bm_face, BM_ELEM_SMOOTH)) {
+ for (uint t = 0; t < 3; t++) {
+ *((Gwn_PackedNormal *)GWN_vertbuf_raw_step(&nor_step)) = vnors_pack[vtri[t]];
+ }
}
else {
- PackedNormal snor_pack = convert_i10_s3(tri_nor);
- PackedNormal *snor = &snor_pack;
+ const Gwn_PackedNormal *snor_pack = &pnors_pack[BM_elem_index_get(bm_face)];
+ for (uint t = 0; t < 3; t++) {
+ *((Gwn_PackedNormal *)GWN_vertbuf_raw_step(&nor_step)) = *snor_pack;
+ }
+ }
- GWN_vertbuf_attr_set(vbo, attr_id.nor, nidx++, snor);
- GWN_vertbuf_attr_set(vbo, attr_id.nor, nidx++, snor);
- GWN_vertbuf_attr_set(vbo, attr_id.nor, nidx++, snor);
+ for (uint t = 0; t < 3; t++) {
+ copy_v3_v3(GWN_vertbuf_raw_step(&pos_step), bm_looptri[t]->v->co);
+ }
+ }
+ }
+ else {
+
+ /* Use normals from vertex */
+ mesh_render_data_ensure_poly_normals_pack(rdata);
+
+ for (int i = 0; i < tri_len; i++) {
+ const MLoopTri *mlt = &rdata->mlooptri[i];
+ const MPoly *mp = &rdata->mpoly[mlt->poly];
+
+ if (use_hide && (mp->flag & ME_HIDE)) {
+ continue;
}
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, tri_vert_cos[0]);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, tri_vert_cos[1]);
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, tri_vert_cos[2]);
+ const uint vtri[3] = {
+ rdata->mloop[mlt->tri[0]].v,
+ rdata->mloop[mlt->tri[1]].v,
+ rdata->mloop[mlt->tri[2]].v,
+ };
+
+ if (mp->flag & ME_SMOOTH) {
+ for (uint t = 0; t < 3; t++) {
+ const MVert *mv = &rdata->mvert[vtri[t]];
+ *((Gwn_PackedNormal *)GWN_vertbuf_raw_step(&nor_step)) = GWN_normal_convert_i10_s3(mv->no);
+ }
+ }
+ else {
+ const Gwn_PackedNormal *pnors_pack = &rdata->poly_normals_pack[mlt->poly];
+ for (uint t = 0; t < 3; t++) {
+ *((Gwn_PackedNormal *)GWN_vertbuf_raw_step(&nor_step)) = *pnors_pack;
+ }
+ }
+
+ for (uint t = 0; t < 3; t++) {
+ const MVert *mv = &rdata->mvert[vtri[t]];
+ copy_v3_v3(GWN_vertbuf_raw_step(&pos_step), mv->co);
+ }
}
}
- vbo_len_used = vidx;
+
+ vbo_len_used = GWN_vertbuf_raw_used(&pos_step);
+ BLI_assert(vbo_len_used == GWN_vertbuf_raw_used(&nor_step));
if (vbo_len_capacity != vbo_len_used) {
GWN_vertbuf_data_resize(vbo, vbo_len_used);
@@ -1854,22 +2073,317 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_pos_and_normals(
rdata, false,
&cache->pos_with_normals);
}
-static Gwn_VertBuf *mesh_batch_cache_get_tri_pos_and_normals_visible_only(
- MeshRenderData *rdata, MeshBatchCache *cache)
+static Gwn_VertBuf *mesh_create_tri_pos_and_normals_visible_only(
+ MeshRenderData *rdata)
{
+ Gwn_VertBuf *vbo_dummy = NULL;
return mesh_batch_cache_get_tri_pos_and_normals_ex(
rdata, true,
- &cache->pos_with_normals_visible_only);
+ &vbo_dummy);
+}
+
+static Gwn_VertBuf *mesh_batch_cache_get_facedot_pos_with_normals_and_flag(
+ MeshRenderData *rdata, MeshBatchCache *cache)
+{
+ BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_POLY));
+
+ if (cache->ed_fcenter_pos_with_nor_and_sel == NULL) {
+ static Gwn_VertFormat format = { 0 };
+ static struct { uint pos, data; } attr_id;
+ if (format.attrib_ct == 0) {
+ attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ attr_id.data = GWN_vertformat_attr_add(&format, "norAndFlag", GWN_COMP_I10, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ }
+
+ const int vbo_len_capacity = mesh_render_data_polys_len_get(rdata);
+ int vidx = 0;
+
+ Gwn_VertBuf *vbo = cache->ed_fcenter_pos_with_nor_and_sel = GWN_vertbuf_create_with_format(&format);
+ GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
+ for (int i = 0; i < vbo_len_capacity; ++i) {
+ float pcenter[3], pnor[3];
+ bool selected = false;
+
+ if (mesh_render_data_pnors_pcenter_select_get(rdata, i, pnor, pcenter, &selected)) {
+
+ Gwn_PackedNormal nor = { .x = 0, .y = 0, .z = -511 };
+ nor = GWN_normal_convert_i10_v3(pnor);
+ nor.w = selected ? 1 : 0;
+ GWN_vertbuf_attr_set(vbo, attr_id.data, vidx, &nor);
+
+ GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx, pcenter);
+
+ vidx += 1;
+ }
+ }
+ const int vbo_len_used = vidx;
+ if (vbo_len_used != vbo_len_capacity) {
+ GWN_vertbuf_data_resize(vbo, vbo_len_used);
+ }
+ BLI_assert(vbo_len_capacity == vbo_len_used);
+ UNUSED_VARS_NDEBUG(vbo_len_used);
+ }
+
+ return cache->ed_fcenter_pos_with_nor_and_sel;
+}
+
+static Gwn_VertBuf *mesh_batch_cache_get_edges_visible(
+ MeshRenderData *rdata, MeshBatchCache *cache)
+{
+ BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_EDGE));
+
+ if (cache->ed_edge_pos == NULL) {
+ static Gwn_VertFormat format = { 0 };
+ static struct { uint pos, data; } attr_id;
+ if (format.attrib_ct == 0) {
+ attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ }
+
+ const int vbo_len_capacity = mesh_render_data_edges_len_get(rdata) * 2;
+ int vidx = 0;
+
+ Gwn_VertBuf *vbo = cache->ed_edge_pos = GWN_vertbuf_create_with_format(&format);
+ GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
+ if (rdata->edit_bmesh) {
+ BMesh *bm = rdata->edit_bmesh->bm;
+ BMIter iter;
+ BMEdge *eed;
+
+ BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) {
+ if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
+ GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx, eed->v1->co);
+ vidx += 1;
+ GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx, eed->v2->co);
+ vidx += 1;
+ }
+ }
+ }
+ else {
+ /* not yet done! */
+ BLI_assert(0);
+ }
+ const int vbo_len_used = vidx;
+ if (vbo_len_used != vbo_len_capacity) {
+ GWN_vertbuf_data_resize(vbo, vbo_len_used);
+ }
+ UNUSED_VARS_NDEBUG(vbo_len_used);
+ }
+
+ return cache->ed_edge_pos;
+}
+
+static Gwn_VertBuf *mesh_batch_cache_get_verts_visible(
+ MeshRenderData *rdata, MeshBatchCache *cache)
+{
+ BLI_assert(rdata->types & MR_DATATYPE_VERT);
+
+ if (cache->ed_vert_pos == NULL) {
+ static Gwn_VertFormat format = { 0 };
+ static struct { uint pos, data; } attr_id;
+ if (format.attrib_ct == 0) {
+ attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ }
+
+ const int vbo_len_capacity = mesh_render_data_verts_len_get(rdata);
+ uint vidx = 0;
+
+ Gwn_VertBuf *vbo = cache->ed_vert_pos = GWN_vertbuf_create_with_format(&format);
+ GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
+ if (rdata->edit_bmesh) {
+ BMesh *bm = rdata->edit_bmesh->bm;
+ BMIter iter;
+ BMVert *eve;
+
+ BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
+ if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
+ GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx, eve->co);
+ vidx += 1;
+ }
+ }
+ }
+ else {
+ for (int i = 0; i < vbo_len_capacity; i++) {
+ const MVert *mv = &rdata->mvert[i];
+ if (!(mv->flag & ME_HIDE)) {
+ GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx, mv->co);
+ vidx += 1;
+ }
+ }
+ }
+ const uint vbo_len_used = vidx;
+ if (vbo_len_used != vbo_len_capacity) {
+ GWN_vertbuf_data_resize(vbo, vbo_len_used);
+ }
+
+ UNUSED_VARS_NDEBUG(vbo_len_used);
+ }
+
+ return cache->ed_vert_pos;
+}
+
+static Gwn_VertBuf *mesh_create_facedot_select_id(
+ MeshRenderData *rdata, uint select_id_offset)
+{
+ BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_POLY));
+
+ Gwn_VertBuf *vbo;
+ {
+ static Gwn_VertFormat format = { 0 };
+ static struct { uint pos, col; } attr_id;
+ if (format.attrib_ct == 0) {
+ attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_I32, 1, GWN_FETCH_INT);
+ }
+
+ const int vbo_len_capacity = mesh_render_data_polys_len_get(rdata);
+ int vidx = 0;
+
+ vbo = GWN_vertbuf_create_with_format(&format);
+ GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
+ uint select_index = select_id_offset;
+
+ if (rdata->edit_bmesh) {
+ BMesh *bm = rdata->edit_bmesh->bm;
+ BMIter iter;
+ BMEdge *efa;
+
+ BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
+ if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
+ int select_id;
+ GPU_select_index_get(select_index, &select_id);
+ GWN_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id);
+ vidx += 1;
+ }
+ select_index += 1;
+ }
+ }
+ else {
+ /* not yet done! */
+ BLI_assert(0);
+ }
+ const int vbo_len_used = vidx;
+ if (vbo_len_used != vbo_len_capacity) {
+ GWN_vertbuf_data_resize(vbo, vbo_len_used);
+ }
+ }
+
+ return vbo;
+}
+
+static Gwn_VertBuf *mesh_create_edges_select_id(
+ MeshRenderData *rdata, uint select_id_offset)
+{
+ BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_EDGE));
+
+ Gwn_VertBuf *vbo;
+ {
+ static Gwn_VertFormat format = { 0 };
+ static struct { uint pos, col; } attr_id;
+ if (format.attrib_ct == 0) {
+ attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_I32, 1, GWN_FETCH_INT);
+ }
+
+ const int vbo_len_capacity = mesh_render_data_edges_len_get(rdata) * 2;
+ int vidx = 0;
+
+ vbo = GWN_vertbuf_create_with_format(&format);
+ GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
+ uint select_index = select_id_offset;
+
+ if (rdata->edit_bmesh) {
+ BMesh *bm = rdata->edit_bmesh->bm;
+ BMIter iter;
+ BMEdge *eed;
+
+ BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) {
+ if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
+ int select_id;
+ GPU_select_index_get(select_index, &select_id);
+ GWN_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id);
+ vidx += 1;
+ GWN_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id);
+ vidx += 1;
+ }
+ select_index += 1;
+ }
+ }
+ else {
+ /* not yet done! */
+ BLI_assert(0);
+ }
+ const int vbo_len_used = vidx;
+ if (vbo_len_used != vbo_len_capacity) {
+ GWN_vertbuf_data_resize(vbo, vbo_len_used);
+ }
+ }
+
+ return vbo;
+}
+
+static Gwn_VertBuf *mesh_create_verts_select_id(
+ MeshRenderData *rdata, uint select_id_offset)
+{
+ BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_POLY));
+
+ Gwn_VertBuf *vbo;
+ {
+ static Gwn_VertFormat format = { 0 };
+ static struct { uint pos, col; } attr_id;
+ if (format.attrib_ct == 0) {
+ attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_I32, 1, GWN_FETCH_INT);
+ }
+
+ const int vbo_len_capacity = mesh_render_data_verts_len_get(rdata);
+ int vidx = 0;
+
+ vbo = GWN_vertbuf_create_with_format(&format);
+ GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
+ uint select_index = select_id_offset;
+
+ if (rdata->edit_bmesh) {
+ BMesh *bm = rdata->edit_bmesh->bm;
+ BMIter iter;
+ BMVert *eve;
+
+ BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
+ if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
+ int select_id;
+ GPU_select_index_get(select_index, &select_id);
+ GWN_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id);
+ vidx += 1;
+ }
+ select_index += 1;
+ }
+ }
+ else {
+ for (int i = 0; i < vbo_len_capacity; i++) {
+ const MVert *mv = &rdata->mvert[i];
+ if (!(mv->flag & ME_HIDE)) {
+ int select_id;
+ GPU_select_index_get(select_index, &select_id);
+ GWN_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id);
+ vidx += 1;
+ }
+ select_index += 1;
+ }
+ }
+ const int vbo_len_used = vidx;
+ if (vbo_len_used != vbo_len_capacity) {
+ GWN_vertbuf_data_resize(vbo, vbo_len_used);
+ }
+ }
+
+ return vbo;
}
-static Gwn_VertBuf *mesh_batch_cache_get_tri_weights(
- MeshRenderData *rdata, MeshBatchCache *cache, bool use_hide, int defgroup)
+static Gwn_VertBuf *mesh_create_tri_weights(
+ MeshRenderData *rdata, bool use_hide, int defgroup)
{
BLI_assert(
rdata->types &
(MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_DVERT));
- if (cache->tri_aligned_weights == NULL) {
+ Gwn_VertBuf *vbo;
+ {
unsigned int cidx = 0;
static Gwn_VertFormat format = { 0 };
@@ -1878,10 +2392,9 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_weights(
attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
}
- const int tri_len = mesh_render_data_looptri_len_get(rdata);
-
- Gwn_VertBuf *vbo = cache->tri_aligned_weights = GWN_vertbuf_create_with_format(&format);
+ vbo = GWN_vertbuf_create_with_format(&format);
+ const int tri_len = mesh_render_data_looptri_len_get(rdata);
const int vbo_len_capacity = tri_len * 3;
int vbo_len_used = 0;
GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
@@ -1919,17 +2432,18 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_weights(
}
}
- return cache->tri_aligned_weights;
+ return vbo;
}
-static Gwn_VertBuf *mesh_batch_cache_get_tri_vert_colors(
- MeshRenderData *rdata, MeshBatchCache *cache, bool use_hide)
+static Gwn_VertBuf *mesh_create_tri_vert_colors(
+ MeshRenderData *rdata, bool use_hide)
{
BLI_assert(
rdata->types &
(MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_LOOPCOL));
- if (cache->tri_aligned_vert_colors == NULL) {
+ Gwn_VertBuf *vbo;
+ {
unsigned int cidx = 0;
static Gwn_VertFormat format = { 0 };
@@ -1940,7 +2454,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_vert_colors(
const int tri_len = mesh_render_data_looptri_len_get(rdata);
- Gwn_VertBuf *vbo = cache->tri_aligned_vert_colors = GWN_vertbuf_create_with_format(&format);
+ vbo = GWN_vertbuf_create_with_format(&format);
const uint vbo_len_capacity = tri_len * 3;
GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
@@ -1978,17 +2492,18 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_vert_colors(
}
}
- return cache->tri_aligned_vert_colors;
+ return vbo;
}
-static Gwn_VertBuf *mesh_batch_cache_get_tri_select_id(
- MeshRenderData *rdata, MeshBatchCache *cache, bool use_hide)
+static Gwn_VertBuf *mesh_create_tri_select_id(
+ MeshRenderData *rdata, bool use_hide, uint select_id_offset)
{
BLI_assert(
rdata->types &
(MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY));
- if (cache->tri_aligned_select_id == NULL) {
+ Gwn_VertBuf *vbo;
+ {
unsigned int cidx = 0;
static Gwn_VertFormat format = { 0 };
@@ -1999,7 +2514,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_select_id(
const int tri_len = mesh_render_data_looptri_len_get(rdata);
- Gwn_VertBuf *vbo = cache->tri_aligned_select_id = GWN_vertbuf_create_with_format(&format);
+ vbo = GWN_vertbuf_create_with_format(&format);
const int vbo_len_capacity = tri_len * 3;
int vbo_len_used = 0;
@@ -2012,7 +2527,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_select_id(
if (!BM_elem_flag_test(ltri[0]->f, BM_ELEM_HIDDEN)) {
const int poly_index = BM_elem_index_get(ltri[0]->f);
int select_id;
- GPU_select_index_get(poly_index + 1, &select_id);
+ GPU_select_index_get(poly_index + select_id_offset, &select_id);
for (uint tri_corner = 0; tri_corner < 3; tri_corner++) {
GWN_vertbuf_attr_set(vbo, attr_id.col, cidx++, &select_id);
}
@@ -2025,7 +2540,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_select_id(
const int poly_index = mlt->poly;
if (!(use_hide && (rdata->mpoly[poly_index].flag & ME_HIDE))) {
int select_id;
- GPU_select_index_get(poly_index + 1, &select_id);
+ GPU_select_index_get(poly_index + select_id_offset, &select_id);
for (uint tri_corner = 0; tri_corner < 3; tri_corner++) {
GWN_vertbuf_attr_set(vbo, attr_id.col, cidx++, &select_id);
}
@@ -2038,8 +2553,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_select_id(
GWN_vertbuf_data_resize(vbo, vbo_len_used);
}
}
-
- return cache->tri_aligned_select_id;
+ return vbo;
}
static Gwn_VertBuf *mesh_batch_cache_get_vert_pos_and_nor_in_order(
@@ -2574,13 +3088,14 @@ static Gwn_IndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material(
return cache->shaded_triangles_in_order;
}
-static Gwn_VertBuf *mesh_batch_cache_get_edge_pos_with_sel(
- MeshRenderData *rdata, MeshBatchCache *cache, bool use_wire, bool use_select_bool)
+static Gwn_VertBuf *mesh_create_edge_pos_with_sel(
+ MeshRenderData *rdata, bool use_wire, bool use_select_bool)
{
BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_POLY | MR_DATATYPE_LOOP));
BLI_assert(rdata->edit_bmesh == NULL);
- if (!cache->edge_pos_with_select_bool) {
+ Gwn_VertBuf *vbo;
+ {
unsigned int vidx = 0, cidx = 0;
static Gwn_VertFormat format = { 0 };
@@ -2592,7 +3107,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edge_pos_with_sel(
const int edge_len = mesh_render_data_edges_len_get(rdata);
- Gwn_VertBuf *vbo = cache->edge_pos_with_select_bool = GWN_vertbuf_create_with_format(&format);
+ vbo = GWN_vertbuf_create_with_format(&format);
const int vbo_len_capacity = edge_len * 2;
int vbo_len_used = 0;
@@ -2630,15 +3145,15 @@ static Gwn_VertBuf *mesh_batch_cache_get_edge_pos_with_sel(
}
}
- return cache->edge_pos_with_select_bool;
+ return vbo;
}
-static Gwn_IndexBuf *mesh_batch_cache_get_tri_overlay_weight_faces(
- MeshRenderData *rdata, MeshBatchCache *cache)
+static Gwn_IndexBuf *mesh_create_tri_overlay_weight_faces(
+ MeshRenderData *rdata)
{
BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI));
- if (cache->overlay_triangles_vpaint == NULL) {
+ {
const int vert_len = mesh_render_data_verts_len_get(rdata);
const int tri_len = mesh_render_data_looptri_len_get(rdata);
@@ -2653,22 +3168,21 @@ static Gwn_IndexBuf *mesh_batch_cache_get_tri_overlay_weight_faces(
}
}
}
- cache->overlay_triangles_vpaint = GWN_indexbuf_build(&elb);
+ return GWN_indexbuf_build(&elb);
}
-
- return cache->overlay_triangles_vpaint;
}
/**
* Non-edit mode vertices (only used for weight-paint mode).
*/
-static Gwn_VertBuf *mesh_batch_cache_get_vert_pos_with_overlay_data(
- MeshRenderData *rdata, MeshBatchCache *cache)
+static Gwn_VertBuf *mesh_create_vert_pos_with_overlay_data(
+ MeshRenderData *rdata)
{
BLI_assert(rdata->types & (MR_DATATYPE_VERT));
BLI_assert(rdata->edit_bmesh == NULL);
- if (cache->pos_with_select_bool == NULL) {
+ Gwn_VertBuf *vbo;
+ {
unsigned int cidx = 0;
static Gwn_VertFormat format = { 0 };
@@ -2679,7 +3193,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_vert_pos_with_overlay_data(
const int vert_len = mesh_render_data_verts_len_get(rdata);
- Gwn_VertBuf *vbo = cache->pos_with_select_bool = GWN_vertbuf_create_with_format(&format);
+ vbo = GWN_vertbuf_create_with_format(&format);
const int vbo_len_capacity = vert_len;
int vbo_len_used = 0;
@@ -2696,8 +3210,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_vert_pos_with_overlay_data(
GWN_vertbuf_data_resize(vbo, vbo_len_used);
}
}
-
- return cache->pos_with_select_bool;
+ return vbo;
}
/** \} */
@@ -2773,14 +3286,14 @@ Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(Mesh *me,
MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_DVERT;
MeshRenderData *rdata = mesh_render_data_create(me, datatype);
- cache->triangles_with_weights = GWN_batch_create(
- GWN_PRIM_TRIS, mesh_batch_cache_get_tri_weights(rdata, cache, use_hide, defgroup), NULL);
+ cache->triangles_with_weights = GWN_batch_create_ex(
+ GWN_PRIM_TRIS, mesh_create_tri_weights(rdata, use_hide, defgroup), NULL, GWN_BATCH_OWNS_VBO);
Gwn_VertBuf *vbo_tris = use_hide ?
- mesh_batch_cache_get_tri_pos_and_normals_visible_only(rdata, cache) :
+ mesh_create_tri_pos_and_normals_visible_only(rdata) :
mesh_batch_cache_get_tri_pos_and_normals(rdata, cache);
- GWN_batch_vertbuf_add(cache->triangles_with_weights, vbo_tris);
+ GWN_batch_vertbuf_add_ex(cache->triangles_with_weights, vbo_tris, use_hide);
mesh_render_data_free(rdata);
}
@@ -2798,13 +3311,13 @@ Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(Mesh
MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_LOOPCOL;
MeshRenderData *rdata = mesh_render_data_create(me, datatype);
- cache->triangles_with_vert_colors = GWN_batch_create(
- GWN_PRIM_TRIS, mesh_batch_cache_get_tri_vert_colors(rdata, cache, use_hide), NULL);
+ cache->triangles_with_vert_colors = GWN_batch_create_ex(
+ GWN_PRIM_TRIS, mesh_create_tri_vert_colors(rdata, use_hide), NULL, GWN_BATCH_OWNS_VBO);
Gwn_VertBuf *vbo_tris = use_hide ?
- mesh_batch_cache_get_tri_pos_and_normals_visible_only(rdata, cache) :
+ mesh_create_tri_pos_and_normals_visible_only(rdata) :
mesh_batch_cache_get_tri_pos_and_normals(rdata, cache);
- GWN_batch_vertbuf_add(cache->triangles_with_vert_colors, vbo_tris);
+ GWN_batch_vertbuf_add_ex(cache->triangles_with_vert_colors, vbo_tris, use_hide);
mesh_render_data_free(rdata);
}
@@ -2813,22 +3326,28 @@ Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(Mesh
}
-struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_id(struct Mesh *me, bool use_hide)
+struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_id(
+ struct Mesh *me, bool use_hide, uint select_id_offset)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
+ if (cache->triangles_with_select_id_offset != select_id_offset) {
+ cache->triangles_with_select_id_offset = select_id_offset;
+ GWN_BATCH_DISCARD_SAFE(cache->triangles_with_select_id);
+ }
+
if (cache->triangles_with_select_id == NULL) {
const int datatype =
MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY;
MeshRenderData *rdata = mesh_render_data_create(me, datatype);
- cache->triangles_with_select_id = GWN_batch_create(
- GWN_PRIM_TRIS, mesh_batch_cache_get_tri_select_id(rdata, cache, use_hide), NULL);
+ cache->triangles_with_select_id = GWN_batch_create_ex(
+ GWN_PRIM_TRIS, mesh_create_tri_select_id(rdata, use_hide, select_id_offset), NULL, GWN_BATCH_OWNS_VBO);
Gwn_VertBuf *vbo_tris = use_hide ?
- mesh_batch_cache_get_tri_pos_and_normals_visible_only(rdata, cache) :
+ mesh_create_tri_pos_and_normals_visible_only(rdata) :
mesh_batch_cache_get_tri_pos_and_normals(rdata, cache);
- GWN_batch_vertbuf_add(cache->triangles_with_select_id, vbo_tris);
+ GWN_batch_vertbuf_add_ex(cache->triangles_with_select_id, vbo_tris, use_hide);
mesh_render_data_free(rdata);
}
@@ -2836,6 +3355,31 @@ struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_id(struct Mesh
return cache->triangles_with_select_id;
}
+/**
+ * Same as #DRW_mesh_batch_cache_get_triangles_with_select_id
+ * without the ID's, use to mask out geometry, eg - dont select face-dots behind other faces.
+ */
+struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_mask(struct Mesh *me, bool use_hide)
+{
+ MeshBatchCache *cache = mesh_batch_cache_get(me);
+ if (cache->triangles_with_select_mask == NULL) {
+ const int datatype =
+ MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY;
+ MeshRenderData *rdata = mesh_render_data_create(me, datatype);
+
+ Gwn_VertBuf *vbo_tris = use_hide ?
+ mesh_create_tri_pos_and_normals_visible_only(rdata) :
+ mesh_batch_cache_get_tri_pos_and_normals(rdata, cache);
+
+ cache->triangles_with_select_mask = GWN_batch_create_ex(
+ GWN_PRIM_TRIS, vbo_tris, NULL, use_hide ? GWN_BATCH_OWNS_VBO : 0);
+
+ mesh_render_data_free(rdata);
+ }
+
+ return cache->triangles_with_select_mask;
+}
+
Gwn_Batch *DRW_mesh_batch_cache_get_points_with_normals(Mesh *me)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
@@ -2901,16 +3445,16 @@ Gwn_Batch *DRW_mesh_batch_cache_get_fancy_edges(Mesh *me)
if (mesh_render_data_edge_vcos_manifold_pnors(rdata, i, &vcos1, &vcos2, &pnor1, &pnor2, &is_manifold)) {
- PackedNormal n1value = { .x = 0, .y = 0, .z = +511 };
- PackedNormal n2value = { .x = 0, .y = 0, .z = -511 };
+ Gwn_PackedNormal n1value = { .x = 0, .y = 0, .z = +511 };
+ Gwn_PackedNormal n2value = { .x = 0, .y = 0, .z = -511 };
if (is_manifold) {
- n1value = convert_i10_v3(pnor1);
- n2value = convert_i10_v3(pnor2);
+ n1value = GWN_normal_convert_i10_v3(pnor1);
+ n2value = GWN_normal_convert_i10_v3(pnor2);
}
- const PackedNormal *n1 = &n1value;
- const PackedNormal *n2 = &n2value;
+ const Gwn_PackedNormal *n1 = &n1value;
+ const Gwn_PackedNormal *n2 = &n2value;
GWN_vertbuf_attr_set(vbo, attr_id.pos, 2 * i, vcos1);
GWN_vertbuf_attr_set(vbo, attr_id.n1, 2 * i, n1);
@@ -2927,7 +3471,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_fancy_edges(Mesh *me)
GWN_vertbuf_data_resize(vbo, vbo_len_used);
}
- cache->fancy_edges = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ cache->fancy_edges = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
mesh_render_data_free(rdata);
}
@@ -3045,49 +3589,94 @@ Gwn_Batch *DRW_mesh_batch_cache_get_overlay_facedots(Mesh *me)
if (cache->overlay_facedots == NULL) {
MeshRenderData *rdata = mesh_render_data_create(me, MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_POLY);
- static Gwn_VertFormat format = { 0 };
- static struct { uint pos, data; } attr_id;
- if (format.attrib_ct == 0) {
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- attr_id.data = GWN_vertformat_attr_add(&format, "norAndFlag", GWN_COMP_I10, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
- }
+ cache->overlay_facedots = GWN_batch_create(
+ GWN_PRIM_POINTS, mesh_batch_cache_get_facedot_pos_with_normals_and_flag(rdata, cache), NULL);
- const int vbo_len_capacity = mesh_render_data_polys_len_get(rdata);
- int vidx = 0;
+ mesh_render_data_free(rdata);
+ }
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
- for (int i = 0; i < vbo_len_capacity; ++i) {
- float pcenter[3], pnor[3];
- bool selected = false;
+ return cache->overlay_facedots;
+}
- if (mesh_render_data_pnors_pcenter_select_get(rdata, i, pnor, pcenter, &selected)) {
+Gwn_Batch *DRW_mesh_batch_cache_get_facedots_with_select_id(Mesh *me, uint select_id_offset)
+{
+ MeshBatchCache *cache = mesh_batch_cache_get(me);
- PackedNormal nor = { .x = 0, .y = 0, .z = -511 };
- nor = convert_i10_v3(pnor);
- nor.w = selected ? 1 : 0;
- GWN_vertbuf_attr_set(vbo, attr_id.data, vidx, &nor);
+ if (cache->facedot_with_select_id_offset != select_id_offset) {
+ cache->facedot_with_select_id_offset = select_id_offset;
+ GWN_BATCH_DISCARD_SAFE(cache->edges_with_select_id);
+ }
- GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx, pcenter);
+ if (cache->facedot_with_select_id == NULL) {
+ MeshRenderData *rdata = mesh_render_data_create(me, MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_POLY);
- vidx += 1;
+ /* We only want the 'pos', not the normals or flag.
+ * Use since this is almost certainly already created. */
+ cache->facedot_with_select_id = GWN_batch_create(
+ GWN_PRIM_POINTS, mesh_batch_cache_get_facedot_pos_with_normals_and_flag(rdata, cache), NULL);
- }
- }
- const int vbo_len_used = vidx;
- if (vbo_len_used != vbo_len_capacity) {
- GWN_vertbuf_data_resize(vbo, vbo_len_used);
- }
+ GWN_batch_vertbuf_add_ex(
+ cache->facedot_with_select_id,
+ mesh_create_facedot_select_id(rdata, select_id_offset), true);
+
+ mesh_render_data_free(rdata);
+ }
+
+ return cache->facedot_with_select_id;
+}
- cache->overlay_facedots = GWN_batch_create(GWN_PRIM_POINTS, vbo, NULL);
+Gwn_Batch *DRW_mesh_batch_cache_get_edges_with_select_id(Mesh *me, uint select_id_offset)
+{
+ MeshBatchCache *cache = mesh_batch_cache_get(me);
+
+ if (cache->edges_with_select_id_offset != select_id_offset) {
+ cache->edges_with_select_id_offset = select_id_offset;
+ GWN_BATCH_DISCARD_SAFE(cache->edges_with_select_id);
+ }
+
+ if (cache->edges_with_select_id == NULL) {
+ MeshRenderData *rdata = mesh_render_data_create(me, MR_DATATYPE_VERT | MR_DATATYPE_EDGE);
+
+ cache->edges_with_select_id = GWN_batch_create(
+ GWN_PRIM_LINES, mesh_batch_cache_get_edges_visible(rdata, cache), NULL);
+
+ GWN_batch_vertbuf_add_ex(
+ cache->edges_with_select_id,
+ mesh_create_edges_select_id(rdata, select_id_offset), true);
mesh_render_data_free(rdata);
}
- return cache->overlay_facedots;
+ return cache->edges_with_select_id;
+}
+
+Gwn_Batch *DRW_mesh_batch_cache_get_verts_with_select_id(Mesh *me, uint select_id_offset)
+{
+ MeshBatchCache *cache = mesh_batch_cache_get(me);
+
+ if (cache->verts_with_select_id_offset != select_id_offset) {
+ cache->verts_with_select_id_offset = select_id_offset;
+ GWN_BATCH_DISCARD_SAFE(cache->verts_with_select_id);
+ }
+
+ if (cache->verts_with_select_id == NULL) {
+ MeshRenderData *rdata = mesh_render_data_create(me, MR_DATATYPE_VERT);
+
+ cache->verts_with_select_id = GWN_batch_create(
+ GWN_PRIM_POINTS, mesh_batch_cache_get_verts_visible(rdata, cache), NULL);
+
+ GWN_batch_vertbuf_add_ex(
+ cache->verts_with_select_id,
+ mesh_create_verts_select_id(rdata, select_id_offset), true);
+
+ mesh_render_data_free(rdata);
+ }
+
+ return cache->verts_with_select_id;
}
-Gwn_Batch **DRW_mesh_batch_cache_get_surface_shaded(Mesh *me)
+Gwn_Batch **DRW_mesh_batch_cache_get_surface_shaded(
+ Mesh *me, struct GPUMaterial **gpumat_array, uint gpumat_array_len)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
@@ -3096,7 +3685,7 @@ Gwn_Batch **DRW_mesh_batch_cache_get_surface_shaded(Mesh *me)
const int datatype =
MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_LOOPTRI |
MR_DATATYPE_POLY | MR_DATATYPE_SHADING;
- MeshRenderData *rdata = mesh_render_data_create(me, datatype);
+ MeshRenderData *rdata = mesh_render_data_create_ex(me, datatype, gpumat_array, gpumat_array_len);
const int mat_len = mesh_render_data_mat_len_get(rdata);
@@ -3184,8 +3773,8 @@ Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_edges(Mesh *me, bool use_wire
const int datatype = MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_POLY | MR_DATATYPE_LOOP;
MeshRenderData *rdata = mesh_render_data_create(me, datatype);
- cache->overlay_paint_edges = GWN_batch_create(
- GWN_PRIM_LINES, mesh_batch_cache_get_edge_pos_with_sel(rdata, cache, use_wire, use_sel), NULL);
+ cache->overlay_paint_edges = GWN_batch_create_ex(
+ GWN_PRIM_LINES, mesh_create_edge_pos_with_sel(rdata, use_wire, use_sel), NULL, GWN_BATCH_OWNS_VBO);
mesh_render_data_free(rdata);
}
@@ -3202,9 +3791,9 @@ Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_faces(Mesh *me)
const int datatype = MR_DATATYPE_VERT | MR_DATATYPE_POLY | MR_DATATYPE_LOOP | MR_DATATYPE_LOOPTRI;
MeshRenderData *rdata = mesh_render_data_create(me, datatype);
- cache->overlay_weight_faces = GWN_batch_create(
+ cache->overlay_weight_faces = GWN_batch_create_ex(
GWN_PRIM_TRIS, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache),
- mesh_batch_cache_get_tri_overlay_weight_faces(rdata, cache));
+ mesh_create_tri_overlay_weight_faces(rdata), GWN_BATCH_OWNS_INDEX);
mesh_render_data_free(rdata);
}
@@ -3223,15 +3812,43 @@ Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_verts(Mesh *me)
cache->overlay_weight_verts = GWN_batch_create(
GWN_PRIM_POINTS, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), NULL);
- GWN_batch_vertbuf_add(
+ GWN_batch_vertbuf_add_ex(
cache->overlay_weight_verts,
- mesh_batch_cache_get_vert_pos_with_overlay_data(rdata, cache));
+ mesh_create_vert_pos_with_overlay_data(rdata), true);
mesh_render_data_free(rdata);
}
return cache->overlay_weight_verts;
}
+/**
+ * Needed for when we draw with shaded data.
+ */
+void DRW_mesh_cache_sculpt_coords_ensure(Mesh *me)
+{
+ if (me->batch_cache) {
+ MeshBatchCache *cache = mesh_batch_cache_get(me);
+ if (cache && cache->pos_with_normals && cache->is_sculpt_points_tag) {
+
+ const int datatype = MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY;
+ MeshRenderData *rdata = mesh_render_data_create(me, datatype);
+
+ Gwn_VertBuf *pos_with_normals = cache->pos_with_normals;
+ cache->pos_with_normals = NULL;
+ GWN_vertbuf_clear(pos_with_normals);
+ Gwn_VertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache);
+ *pos_with_normals = *vbo;
+ GWN_vertformat_copy(&pos_with_normals->format, &vbo->format);
+
+ free(vbo);
+ cache->pos_with_normals = pos_with_normals;
+
+ mesh_render_data_free(rdata);
+ }
+ cache->is_sculpt_points_tag = false;
+ }
+}
+
/** \} */
#undef MESH_RENDER_FUNCTION
diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c
index 6b15bd673c9..afee6ea182b 100644
--- a/source/blender/draw/intern/draw_cache_impl_particles.c
+++ b/source/blender/draw/intern/draw_cache_impl_particles.c
@@ -33,10 +33,13 @@
#include "BLI_utildefines.h"
#include "BLI_math_vector.h"
+#include "BLI_ghash.h"
+#include "DNA_modifier_types.h"
#include "DNA_particle_types.h"
#include "BKE_particle.h"
+#include "BKE_DerivedMesh.h"
#include "GPU_batch.h"
@@ -170,21 +173,46 @@ static void ensure_seg_pt_count(ParticleSystem *psys, ParticleBatchCache *cache)
}
/* Gwn_Batch cache usage. */
-static void particle_batch_cache_ensure_pos_and_seg(ParticleSystem *psys, ParticleBatchCache *cache)
+static void particle_batch_cache_ensure_pos_and_seg(ParticleSystem *psys, ModifierData *md, ParticleBatchCache *cache)
{
if (cache->pos == NULL || cache->segments == NULL) {
int curr_point = 0;
+ ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md;
GWN_VERTBUF_DISCARD_SAFE(cache->pos);
GWN_INDEXBUF_DISCARD_SAFE(cache->segments);
static Gwn_VertFormat format = { 0 };
static struct { uint pos, tan, ind; } attr_id;
- if (format.attrib_ct == 0) {
- /* initialize vertex format */
- attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- attr_id.tan = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- attr_id.ind = GWN_vertformat_attr_add(&format, "ind", GWN_COMP_I32, 1, GWN_FETCH_INT);
+ unsigned int *uv_id = NULL;
+ int uv_layers = 0;
+ MTFace **mtfaces = NULL;
+ float (**parent_uvs)[2] = NULL;
+ bool simple = psys->part->childtype == PART_CHILD_PARTICLES;
+
+ if (psmd) {
+ if (CustomData_has_layer(&psmd->dm_final->loopData, CD_MLOOPUV)) {
+ uv_layers = CustomData_number_of_layers(&psmd->dm_final->loopData, CD_MLOOPUV);
+ }
+ }
+
+ GWN_vertformat_clear(&format);
+
+ /* initialize vertex format */
+ attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ attr_id.tan = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ attr_id.ind = GWN_vertformat_attr_add(&format, "ind", GWN_COMP_I32, 1, GWN_FETCH_INT);
+
+ if (psmd) {
+ uv_id = MEM_mallocN(sizeof(*uv_id) * uv_layers, "UV attrib format");
+
+ for (int i = 0; i < uv_layers; i++) {
+ const char *name = CustomData_get_layer_name(&psmd->dm_final->loopData, CD_MLOOPUV, i);
+ char uuid[32];
+
+ BLI_snprintf(uuid, sizeof(uuid), "u%u", BLI_ghashutil_strhash_p(name));
+ uv_id[i] = GWN_vertformat_attr_add(&format, uuid, GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ }
}
cache->pos = GWN_vertbuf_create_with_format(&format);
@@ -193,12 +221,55 @@ static void particle_batch_cache_ensure_pos_and_seg(ParticleSystem *psys, Partic
Gwn_IndexBufBuilder elb;
GWN_indexbuf_init(&elb, GWN_PRIM_LINES, cache->segment_count, cache->point_count);
+ if (uv_layers) {
+ DM_ensure_tessface(psmd->dm_final);
+
+ mtfaces = MEM_mallocN(sizeof(*mtfaces) * uv_layers, "Faces UV layers");
+
+ for (int i = 0; i < uv_layers; i++) {
+ mtfaces[i] = (MTFace *)CustomData_get_layer_n(&psmd->dm_final->faceData, CD_MTFACE, i);
+ }
+ }
+
if (psys->pathcache && (!psys->childcache || (psys->part->draw & PART_DRAW_PARENT))) {
+ if (simple) {
+ parent_uvs = MEM_callocN(sizeof(*parent_uvs) * psys->totpart, "Parent particle UVs");
+ }
+
for (int i = 0; i < psys->totpart; i++) {
ParticleCacheKey *path = psys->pathcache[i];
if (path->segments > 0) {
float tangent[3];
+ int from = psmd ? psmd->psys->part->from : 0;
+ float (*uv)[2] = NULL;
+
+ if (psmd) {
+ uv = MEM_callocN(sizeof(*uv) * uv_layers, "Particle UVs");
+
+ if (simple) {
+ parent_uvs[i] = uv;
+ }
+ }
+
+ if (ELEM(from, PART_FROM_FACE, PART_FROM_VOLUME)) {
+ ParticleData *particle = &psys->particles[i];
+ int num = particle->num_dmcache;
+
+ if (num == DMCACHE_NOTFOUND) {
+ if (particle->num < psmd->dm_final->getNumTessFaces(psmd->dm_final)) {
+ num = particle->num;
+ }
+ }
+
+ if (num != DMCACHE_NOTFOUND) {
+ MFace *mface = psmd->dm_final->getTessFaceData(psmd->dm_final, num, CD_MFACE);
+
+ for (int j = 0; j < uv_layers; j++) {
+ psys_interpolate_uvs(mtfaces[j] + num, mface->v4, particle->fuv, uv[j]);
+ }
+ }
+ }
for (int j = 0; j < path->segments; j++) {
if (j == 0) {
@@ -212,6 +283,12 @@ static void particle_batch_cache_ensure_pos_and_seg(ParticleSystem *psys, Partic
GWN_vertbuf_attr_set(cache->pos, attr_id.tan, curr_point, tangent);
GWN_vertbuf_attr_set(cache->pos, attr_id.ind, curr_point, &i);
+ if (psmd) {
+ for (int k = 0; k < uv_layers; k++) {
+ GWN_vertbuf_attr_set(cache->pos, uv_id[k], curr_point, uv[k]);
+ }
+ }
+
GWN_indexbuf_add_line_verts(&elb, curr_point, curr_point + 1);
curr_point++;
@@ -223,6 +300,16 @@ static void particle_batch_cache_ensure_pos_and_seg(ParticleSystem *psys, Partic
GWN_vertbuf_attr_set(cache->pos, attr_id.tan, curr_point, tangent);
GWN_vertbuf_attr_set(cache->pos, attr_id.ind, curr_point, &i);
+ if (psmd) {
+ for (int k = 0; k < uv_layers; k++) {
+ GWN_vertbuf_attr_set(cache->pos, uv_id[k], curr_point, uv[k]);
+ }
+
+ if (!simple) {
+ MEM_freeN(uv);
+ }
+ }
+
curr_point++;
}
}
@@ -231,11 +318,61 @@ static void particle_batch_cache_ensure_pos_and_seg(ParticleSystem *psys, Partic
if (psys->childcache) {
int child_count = psys->totchild * psys->part->disp / 100;
+ if (simple && !parent_uvs) {
+ parent_uvs = MEM_callocN(sizeof(*parent_uvs) * psys->totpart, "Parent particle UVs");
+ }
+
for (int i = 0, x = psys->totpart; i < child_count; i++, x++) {
ParticleCacheKey *path = psys->childcache[i];
float tangent[3];
if (path->segments > 0) {
+ int from = psmd ? psmd->psys->part->from : 0;
+ float (*uv)[2] = NULL;
+
+ if (!simple) {
+ if (psmd) {
+ uv = MEM_callocN(sizeof(*uv) * uv_layers, "Particle UVs");
+ }
+
+ if (ELEM(from, PART_FROM_FACE, PART_FROM_VOLUME)) {
+ ChildParticle *particle = &psys->child[i];
+ int num = particle->num;
+
+ if (num != DMCACHE_NOTFOUND) {
+ MFace *mface = psmd->dm_final->getTessFaceData(psmd->dm_final, num, CD_MFACE);
+
+ for (int j = 0; j < uv_layers; j++) {
+ psys_interpolate_uvs(mtfaces[j] + num, mface->v4, particle->fuv, uv[j]);
+ }
+ }
+ }
+ }
+ else if (!parent_uvs[psys->child[i].parent]) {
+ if (psmd) {
+ parent_uvs[psys->child[i].parent] = MEM_callocN(sizeof(*uv) * uv_layers, "Particle UVs");
+ }
+
+ if (ELEM(from, PART_FROM_FACE, PART_FROM_VOLUME)) {
+ ParticleData *particle = &psys->particles[psys->child[i].parent];
+ int num = particle->num_dmcache;
+
+ if (num == DMCACHE_NOTFOUND) {
+ if (particle->num < psmd->dm_final->getNumTessFaces(psmd->dm_final)) {
+ num = particle->num;
+ }
+ }
+
+ if (num != DMCACHE_NOTFOUND) {
+ MFace *mface = psmd->dm_final->getTessFaceData(psmd->dm_final, num, CD_MFACE);
+
+ for (int j = 0; j < uv_layers; j++) {
+ psys_interpolate_uvs(mtfaces[j] + num, mface->v4, particle->fuv, parent_uvs[psys->child[i].parent][j]);
+ }
+ }
+ }
+ }
+
for (int j = 0; j < path->segments; j++) {
if (j == 0) {
sub_v3_v3v3(tangent, path[j + 1].co, path[j].co);
@@ -248,6 +385,13 @@ static void particle_batch_cache_ensure_pos_and_seg(ParticleSystem *psys, Partic
GWN_vertbuf_attr_set(cache->pos, attr_id.tan, curr_point, tangent);
GWN_vertbuf_attr_set(cache->pos, attr_id.ind, curr_point, &x);
+ if (psmd) {
+ for (int k = 0; k < uv_layers; k++) {
+ GWN_vertbuf_attr_set(cache->pos, uv_id[k], curr_point,
+ simple ? parent_uvs[psys->child[i].parent][k] : uv[k]);
+ }
+ }
+
GWN_indexbuf_add_line_verts(&elb, curr_point, curr_point + 1);
curr_point++;
@@ -259,11 +403,38 @@ static void particle_batch_cache_ensure_pos_and_seg(ParticleSystem *psys, Partic
GWN_vertbuf_attr_set(cache->pos, attr_id.tan, curr_point, tangent);
GWN_vertbuf_attr_set(cache->pos, attr_id.ind, curr_point, &x);
+ if (psmd) {
+ for (int k = 0; k < uv_layers; k++) {
+ GWN_vertbuf_attr_set(cache->pos, uv_id[k], curr_point,
+ simple ? parent_uvs[psys->child[i].parent][k] : uv[k]);
+ }
+
+ if (!simple) {
+ MEM_freeN(uv);
+ }
+ }
+
curr_point++;
}
}
}
+ if (parent_uvs) {
+ for (int i = 0; i < psys->totpart; i++) {
+ MEM_SAFE_FREE(parent_uvs[i]);
+ }
+
+ MEM_freeN(parent_uvs);
+ }
+
+ if (uv_layers) {
+ MEM_freeN(mtfaces);
+ }
+
+ if (psmd) {
+ MEM_freeN(uv_id);
+ }
+
cache->segments = GWN_indexbuf_build(&elb);
}
}
@@ -322,13 +493,13 @@ static void particle_batch_cache_ensure_pos(ParticleSystem *psys, ParticleBatchC
}
}
-Gwn_Batch *DRW_particles_batch_cache_get_hair(ParticleSystem *psys)
+Gwn_Batch *DRW_particles_batch_cache_get_hair(ParticleSystem *psys, ModifierData *md)
{
ParticleBatchCache *cache = particle_batch_cache_get(psys);
if (cache->hairs == NULL) {
ensure_seg_pt_count(psys, cache);
- particle_batch_cache_ensure_pos_and_seg(psys, cache);
+ particle_batch_cache_ensure_pos_and_seg(psys, md, cache);
cache->hairs = GWN_batch_create(GWN_PRIM_LINES, cache->pos, cache->segments);
}
diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c
index c3d95d700a0..1050594318f 100644
--- a/source/blender/draw/intern/draw_common.c
+++ b/source/blender/draw/intern/draw_common.c
@@ -84,10 +84,11 @@ void DRW_globals_update(void)
/* Grid */
UI_GetThemeColorShade4fv(TH_GRID, 10, ts.colorGrid);
/* emphasise division lines lighter instead of darker, if background is darker than grid */
- UI_GetThemeColorShade4fv(TH_GRID,
- (ts.colorGrid[0] + ts.colorGrid[1] + ts.colorGrid[2] + 0.12 >
- ts.colorBackground[0] + ts.colorBackground[1] + ts.colorBackground[2])
- ? 20 : -10, ts.colorGridEmphasise);
+ UI_GetThemeColorShade4fv(
+ TH_GRID,
+ (ts.colorGrid[0] + ts.colorGrid[1] + ts.colorGrid[2] + 0.12f >
+ ts.colorBackground[0] + ts.colorBackground[1] + ts.colorBackground[2]) ?
+ 20 : -10, ts.colorGridEmphasise);
/* Grid Axis */
UI_GetThemeColorBlendShade4fv(TH_GRID, TH_AXIS_X, 0.5f, -10, ts.colorGridAxisX);
UI_GetThemeColorBlendShade4fv(TH_GRID, TH_AXIS_Y, 0.5f, -10, ts.colorGridAxisY);
@@ -102,10 +103,10 @@ void DRW_globals_update(void)
ts.sizeLampCircleShadow = ts.sizeLampCircle + U.pixelsize * 3.0f;
/* M_SQRT2 to be at least the same size of the old square */
- ts.sizeVertex = ceil(UI_GetThemeValuef(TH_VERTEX_SIZE) * M_SQRT2 / 2.0f);
- ts.sizeFaceDot = ceil(UI_GetThemeValuef(TH_FACEDOT_SIZE) * M_SQRT2);
+ ts.sizeVertex = ceilf(UI_GetThemeValuef(TH_VERTEX_SIZE) * (float)M_SQRT2 / 2.0f);
+ ts.sizeFaceDot = ceilf(UI_GetThemeValuef(TH_FACEDOT_SIZE) * (float)M_SQRT2);
ts.sizeEdge = 1.0f / 2.0f; /* TODO Theme */
- ts.sizeEdgeFix = 0.5f + 2.0f * (2.0f * (MAX2(ts.sizeVertex, ts.sizeEdge)) * M_SQRT1_2);
+ ts.sizeEdgeFix = 0.5f + 2.0f * (2.0f * (MAX2(ts.sizeVertex, ts.sizeEdge)) * (float)M_SQRT1_2);
/* TODO Waiting for notifiers to invalidate cache */
if (globals_ubo) {
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index bcbd4e5eb31..38a767b7e34 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -69,8 +69,6 @@
#include "IMB_colormanagement.h"
-#include "PIL_time.h"
-
#include "RE_engine.h"
#include "UI_interface.h"
@@ -80,6 +78,7 @@
#include "WM_types.h"
#include "draw_manager_text.h"
+#include "draw_manager_profiling.h"
/* only for callbacks */
#include "draw_cache_impl.h"
@@ -93,19 +92,63 @@
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
-#define MAX_ATTRIB_NAME 32
-#define MAX_PASS_NAME 32
-#define MAX_CLIP_PLANES 6 /* GL_MAX_CLIP_PLANES is at least 6 */
+/* -------------------------------------------------------------------- */
+/** \name Local Features
+ * \{ */
+
+#define USE_PROFILE
+
+#ifdef USE_PROFILE
+#include "PIL_time.h"
+
+#define PROFILE_TIMER_FALLOFF 0.1
+
+#define PROFILE_START(time_start) \
+ double time_start = PIL_check_seconds_timer();
+
+#define PROFILE_END_ACCUM(time_accum, time_start) { \
+ time_accum += (PIL_check_seconds_timer() - time_start) * 1e3; \
+} ((void)0)
+
+/* exp average */
+#define PROFILE_END_UPDATE(time_update, time_start) { \
+ double _time_delta = (PIL_check_seconds_timer() - time_start) * 1e3; \
+ time_update = (time_update * (1.0 - PROFILE_TIMER_FALLOFF)) + \
+ (_time_delta * PROFILE_TIMER_FALLOFF); \
+} ((void)0)
+
+#else
+
+#define PROFILE_START(time_start) ((void)0)
+#define PROFILE_END_ACCUM(time_accum, time_start) ((void)0)
+#define PROFILE_END_UPDATE(time_update, time_start) ((void)0)
+
+#endif /* USE_PROFILE */
+
/* Use draw manager to call GPU_select, see: DRW_draw_select_loop */
#define USE_GPU_SELECT
+/* Use BLI_memiter */
+#define USE_MEM_ITER
+
+#ifdef USE_MEM_ITER
+#include "BLI_memiter.h"
+#endif
+
#ifdef USE_GPU_SELECT
# include "ED_view3d.h"
# include "ED_armature.h"
# include "GPU_select.h"
#endif
+/** \} */
+
+
+#define MAX_ATTRIB_NAME 32
+#define MAX_PASS_NAME 32
+#define MAX_CLIP_PLANES 6 /* GL_MAX_CLIP_PLANES is at least 6 */
+
extern char datatoc_gpu_shader_2D_vert_glsl[];
extern char datatoc_gpu_shader_3D_vert_glsl[];
extern char datatoc_gpu_shader_fullscreen_vert_glsl[];
@@ -138,7 +181,6 @@ struct DRWUniform {
int location;
int length;
int arraysize;
- int bindloc;
const void *value;
};
@@ -176,10 +218,6 @@ struct DRWInterface {
int orcotexfac;
int eye;
int clipplanes;
- /* Textures */
- int tex_bind; /* next texture binding point */
- /* UBO */
- int ubo_bind; /* next ubo binding point */
/* Dynamic batch */
Gwn_Batch *instance_batch; /* contains instances attributes */
GLuint instance_vbo; /* same as instance_batch but generated from DRWCalls */
@@ -191,16 +229,13 @@ struct DRWPass {
ListBase shgroups; /* DRWShadingGroup */
DRWState state;
char name[MAX_PASS_NAME];
- /* use two query to not stall the cpu waiting for queries to complete */
- unsigned int timer_queries[2];
- /* alternate between front and back query */
- unsigned int front_idx;
- unsigned int back_idx;
- bool wasdrawn; /* if it was drawn during this frame */
};
typedef struct DRWCallHeader {
+#ifndef USE_MEM_ITER
void *next, *prev;
+#endif
+
#ifdef USE_GPU_SELECT
int select_id;
#endif
@@ -237,10 +272,19 @@ struct DRWShadingGroup {
GPUShader *shader; /* Shader to bind */
DRWInterface *interface; /* Uniforms pointers */
- ListBase calls; /* DRWCall or DRWCallDynamic depending of type */
+
+ /* DRWCall or DRWCallDynamic depending of type */
+#ifdef USE_MEM_ITER
+ BLI_memiter *calls;
+#else
+ ListBase calls;
+#endif
+
DRWState state_extra; /* State changes for this batch only (or'd with the pass's state) */
+ DRWState state_extra_disable; /* State changes for this batch only (and'd with the pass's state) */
int type;
+ ID *instance_data; /* Object->data to instance */
Gwn_Batch *instance_geom; /* Geometry to instance */
Gwn_Batch *batch_geom; /* Result of call batching */
@@ -275,12 +319,10 @@ enum {
STENCIL_ACTIVE = (1 << 1),
};
-/* Render State */
+/** Render State: No persistent data between draw calls. */
static struct DRWGlobalState {
/* Rendering state */
GPUShader *shader;
- ListBase bound_texs;
- int tex_bind_id;
/* Managed by `DRW_state_set`, `DRW_state_reset` */
DRWState state;
@@ -312,8 +354,21 @@ static struct DRWGlobalState {
struct DRWTextStore **text_store_p;
ListBase enabled_engines; /* RenderEngineType */
+
+ /* Profiling */
+ double cache_time;
} DST = {NULL};
+/** GPU Resource State: Memory storage between drawing. */
+static struct DRWResourceState {
+ GPUTexture **bound_texs;
+
+ bool *bound_tex_slots;
+
+ int bind_tex_inc;
+ int bind_ubo_inc;
+} RST = {NULL};
+
static struct DRWMatrixOveride {
float mat[6][4][4];
bool override[6];
@@ -337,27 +392,29 @@ void DRW_select_load_id(unsigned int id)
/** \name Textures (DRW_texture)
* \{ */
-static void drw_texture_get_format(DRWTextureFormat format, GPUTextureFormat *data_type, int *channels)
+static void drw_texture_get_format(
+ DRWTextureFormat format,
+ GPUTextureFormat *r_data_type, int *r_channels)
{
switch (format) {
- case DRW_TEX_RGBA_8: *data_type = GPU_RGBA8; break;
- case DRW_TEX_RGBA_16: *data_type = GPU_RGBA16F; break;
- case DRW_TEX_RGB_16: *data_type = GPU_RGB16F; break;
- case DRW_TEX_RGB_11_11_10: *data_type = GPU_R11F_G11F_B10F; break;
- case DRW_TEX_RG_16: *data_type = GPU_RG16F; break;
- case DRW_TEX_RG_32: *data_type = GPU_RG32F; break;
- case DRW_TEX_R_8: *data_type = GPU_R8; break;
- case DRW_TEX_R_16: *data_type = GPU_R16F; break;
- case DRW_TEX_R_32: *data_type = GPU_R32F; break;
+ case DRW_TEX_RGBA_8: *r_data_type = GPU_RGBA8; break;
+ case DRW_TEX_RGBA_16: *r_data_type = GPU_RGBA16F; break;
+ case DRW_TEX_RGB_16: *r_data_type = GPU_RGB16F; break;
+ case DRW_TEX_RGB_11_11_10: *r_data_type = GPU_R11F_G11F_B10F; break;
+ case DRW_TEX_RG_8: *r_data_type = GPU_RG8; break;
+ case DRW_TEX_RG_16: *r_data_type = GPU_RG16F; break;
+ case DRW_TEX_RG_32: *r_data_type = GPU_RG32F; break;
+ case DRW_TEX_R_8: *r_data_type = GPU_R8; break;
+ case DRW_TEX_R_16: *r_data_type = GPU_R16F; break;
+ case DRW_TEX_R_32: *r_data_type = GPU_R32F; break;
#if 0
- case DRW_TEX_RGBA_32: *data_type = GPU_RGBA32F; break;
- case DRW_TEX_RGB_8: *data_type = GPU_RGB8; break;
- case DRW_TEX_RGB_32: *data_type = GPU_RGB32F; break;
- case DRW_TEX_RG_8: *data_type = GPU_RG8; break;
+ case DRW_TEX_RGBA_32: *r_data_type = GPU_RGBA32F; break;
+ case DRW_TEX_RGB_8: *r_data_type = GPU_RGB8; break;
+ case DRW_TEX_RGB_32: *r_data_type = GPU_RGB32F; break;
#endif
- case DRW_TEX_DEPTH_16: *data_type = GPU_DEPTH_COMPONENT16; break;
- case DRW_TEX_DEPTH_24: *data_type = GPU_DEPTH_COMPONENT24; break;
- case DRW_TEX_DEPTH_32: *data_type = GPU_DEPTH_COMPONENT32F; break;
+ case DRW_TEX_DEPTH_16: *r_data_type = GPU_DEPTH_COMPONENT16; break;
+ case DRW_TEX_DEPTH_24: *r_data_type = GPU_DEPTH_COMPONENT24; break;
+ case DRW_TEX_DEPTH_32: *r_data_type = GPU_DEPTH_COMPONENT32F; break;
default :
/* file type not supported you must uncomment it from above */
BLI_assert(false);
@@ -368,21 +425,21 @@ static void drw_texture_get_format(DRWTextureFormat format, GPUTextureFormat *da
case DRW_TEX_RGBA_8:
case DRW_TEX_RGBA_16:
case DRW_TEX_RGBA_32:
- *channels = 4;
+ *r_channels = 4;
break;
case DRW_TEX_RGB_8:
case DRW_TEX_RGB_16:
case DRW_TEX_RGB_32:
case DRW_TEX_RGB_11_11_10:
- *channels = 3;
+ *r_channels = 3;
break;
case DRW_TEX_RG_8:
case DRW_TEX_RG_16:
case DRW_TEX_RG_32:
- *channels = 2;
+ *r_channels = 2;
break;
default:
- *channels = 1;
+ *r_channels = 1;
break;
}
}
@@ -462,6 +519,11 @@ void DRW_texture_generate_mipmaps(GPUTexture *tex)
GPU_texture_unbind(tex);
}
+void DRW_texture_update(GPUTexture *tex, const float *pixels)
+{
+ GPU_texture_update(tex, pixels);
+}
+
void DRW_texture_free(GPUTexture *tex)
{
GPU_texture_free(tex);
@@ -579,30 +641,28 @@ static DRWInterface *DRW_interface_create(GPUShader *shader)
{
DRWInterface *interface = MEM_mallocN(sizeof(DRWInterface), "DRWInterface");
- interface->model = GPU_shader_get_uniform(shader, "ModelMatrix");
- interface->modelinverse = GPU_shader_get_uniform(shader, "ModelMatrixInverse");
- interface->modelview = GPU_shader_get_uniform(shader, "ModelViewMatrix");
- interface->modelviewinverse = GPU_shader_get_uniform(shader, "ModelViewMatrixInverse");
- interface->projection = GPU_shader_get_uniform(shader, "ProjectionMatrix");
- interface->projectioninverse = GPU_shader_get_uniform(shader, "ProjectionMatrixInverse");
- interface->view = GPU_shader_get_uniform(shader, "ViewMatrix");
- interface->viewinverse = GPU_shader_get_uniform(shader, "ViewMatrixInverse");
- interface->viewprojection = GPU_shader_get_uniform(shader, "ViewProjectionMatrix");
- interface->viewprojectioninverse = GPU_shader_get_uniform(shader, "ViewProjectionMatrixInverse");
- interface->modelviewprojection = GPU_shader_get_uniform(shader, "ModelViewProjectionMatrix");
- interface->normal = GPU_shader_get_uniform(shader, "NormalMatrix");
- interface->worldnormal = GPU_shader_get_uniform(shader, "WorldNormalMatrix");
- interface->camtexfac = GPU_shader_get_uniform(shader, "CameraTexCoFactors");
- interface->orcotexfac = GPU_shader_get_uniform(shader, "OrcoTexCoFactors[0]");
- interface->eye = GPU_shader_get_uniform(shader, "eye");
- interface->clipplanes = GPU_shader_get_uniform(shader, "ClipPlanes[0]");
+ interface->model = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_MODEL);
+ interface->modelinverse = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_MODEL_INV);
+ interface->modelview = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_MODELVIEW);
+ interface->modelviewinverse = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_MODELVIEW_INV);
+ interface->projection = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_PROJECTION);
+ interface->projectioninverse = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_PROJECTION_INV);
+ interface->view = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_VIEW);
+ interface->viewinverse = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_VIEW_INV);
+ interface->viewprojection = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_VIEWPROJECTION);
+ interface->viewprojectioninverse = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_VIEWPROJECTION_INV);
+ interface->modelviewprojection = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_MVP);
+ interface->normal = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_NORMAL);
+ interface->worldnormal = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_WORLDNORMAL);
+ interface->camtexfac = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_CAMERATEXCO);
+ interface->orcotexfac = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_ORCO);
+ interface->clipplanes = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_CLIPPLANES);
+ interface->eye = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_EYE);
interface->instance_count = 0;
interface->attribs_count = 0;
interface->attribs_stride = 0;
interface->instance_vbo = 0;
interface->instance_batch = NULL;
- interface->tex_bind = GPU_max_textures() - 1;
- interface->ubo_bind = GPU_max_ubo_binds() - 1;
memset(&interface->vbo_format, 0, sizeof(Gwn_VertFormat));
@@ -623,34 +683,34 @@ static DRWInterface *DRW_interface_duplicate(DRWInterface *interface_src)
#endif
static void DRW_interface_uniform(DRWShadingGroup *shgroup, const char *name,
- DRWUniformType type, const void *value, int length, int arraysize, int bindloc)
+ DRWUniformType type, const void *value, int length, int arraysize)
{
- DRWUniform *uni = MEM_mallocN(sizeof(DRWUniform), "DRWUniform");
-
+ int location;
if (type == DRW_UNIFORM_BLOCK) {
- uni->location = GPU_shader_get_uniform_block(shgroup->shader, name);
+ location = GPU_shader_get_uniform_block(shgroup->shader, name);
}
else {
- uni->location = GPU_shader_get_uniform(shgroup->shader, name);
+ location = GPU_shader_get_uniform(shgroup->shader, name);
}
- BLI_assert(arraysize > 0);
-
- uni->type = type;
- uni->value = value;
- uni->length = length;
- uni->arraysize = arraysize;
- uni->bindloc = bindloc; /* for textures */
-
- if (uni->location == -1) {
+ if (location == -1) {
if (G.debug & G_DEBUG)
fprintf(stderr, "Uniform '%s' not found!\n", name);
/* Nice to enable eventually, for now eevee uses uniforms that might not exist. */
// BLI_assert(0);
- MEM_freeN(uni);
return;
}
+ DRWUniform *uni = MEM_mallocN(sizeof(DRWUniform), "DRWUniform");
+
+ BLI_assert(arraysize > 0);
+
+ uni->location = location;
+ uni->type = type;
+ uni->value = value;
+ uni->length = length;
+ uni->arraysize = arraysize;
+
BLI_addtail(&shgroup->interface->uniforms, uni);
}
@@ -696,16 +756,22 @@ static void DRW_interface_attrib(DRWShadingGroup *shgroup, const char *name, DRW
DRWShadingGroup *DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass)
{
DRWShadingGroup *shgroup = MEM_mallocN(sizeof(DRWShadingGroup), "DRWShadingGroup");
+ BLI_addtail(&pass->shgroups, shgroup);
shgroup->type = DRW_SHG_NORMAL;
shgroup->shader = shader;
shgroup->interface = DRW_interface_create(shader);
shgroup->state_extra = 0;
+ shgroup->state_extra_disable = ~0x0;
shgroup->batch_geom = NULL;
shgroup->instance_geom = NULL;
+ shgroup->instance_data = NULL;
- BLI_addtail(&pass->shgroups, shgroup);
+#ifdef USE_MEM_ITER
+ shgroup->calls = BLI_memiter_create(BLI_MEMITER_DEFAULT_SIZE);
+#else
BLI_listbase_clear(&shgroup->calls);
+#endif
#ifdef USE_GPU_SELECT
shgroup->pass_parent = pass;
@@ -737,7 +803,8 @@ DRWShadingGroup *DRW_shgroup_material_create(struct GPUMaterial *material, DRWPa
for (GPUInput *input = inputs->first; input; input = input->next) {
/* Textures */
if (input->ima) {
- GPUTexture *tex = GPU_texture_from_blender(input->ima, input->iuser, input->textarget, input->image_isdata, time, 1);
+ GPUTexture *tex = GPU_texture_from_blender(
+ input->ima, input->iuser, input->textarget, input->image_isdata, time, 1);
if (input->bindtex) {
DRW_shgroup_uniform_texture(grp, input->shadername, tex);
@@ -750,22 +817,22 @@ DRWShadingGroup *DRW_shgroup_material_create(struct GPUMaterial *material, DRWPa
/* Floats */
else {
switch (input->type) {
- case 1:
+ case GPU_FLOAT:
DRW_shgroup_uniform_float(grp, input->shadername, (float *)input->dynamicvec, 1);
break;
- case 2:
+ case GPU_VEC2:
DRW_shgroup_uniform_vec2(grp, input->shadername, (float *)input->dynamicvec, 1);
break;
- case 3:
+ case GPU_VEC3:
DRW_shgroup_uniform_vec3(grp, input->shadername, (float *)input->dynamicvec, 1);
break;
- case 4:
+ case GPU_VEC4:
DRW_shgroup_uniform_vec4(grp, input->shadername, (float *)input->dynamicvec, 1);
break;
- case 9:
+ case GPU_MAT3:
DRW_shgroup_uniform_mat3(grp, input->shadername, (float *)input->dynamicvec);
break;
- case 16:
+ case GPU_MAT4:
DRW_shgroup_uniform_mat4(grp, input->shadername, (float *)input->dynamicvec);
break;
default:
@@ -774,16 +841,23 @@ DRWShadingGroup *DRW_shgroup_material_create(struct GPUMaterial *material, DRWPa
}
}
+ GPUUniformBuffer *ubo = GPU_material_get_uniform_buffer(material);
+ if (ubo != NULL) {
+ DRW_shgroup_uniform_block(grp, GPU_UBO_BLOCK_NAME, ubo);
+ }
+
return grp;
}
-DRWShadingGroup *DRW_shgroup_material_instance_create(struct GPUMaterial *material, DRWPass *pass, Gwn_Batch *geom)
+DRWShadingGroup *DRW_shgroup_material_instance_create(
+ struct GPUMaterial *material, DRWPass *pass, Gwn_Batch *geom, Object *ob)
{
DRWShadingGroup *shgroup = DRW_shgroup_material_create(material, pass);
if (shgroup) {
shgroup->type = DRW_SHG_INSTANCE;
shgroup->instance_geom = geom;
+ shgroup->instance_data = ob->data;
}
return shgroup;
@@ -835,19 +909,24 @@ DRWShadingGroup *DRW_shgroup_empty_tri_batch_create(struct GPUShader *shader, DR
void DRW_shgroup_free(struct DRWShadingGroup *shgroup)
{
+#ifdef USE_MEM_ITER
+ BLI_memiter_destroy(shgroup->calls);
+#else
BLI_freelistN(&shgroup->calls);
+#endif
+
BLI_freelistN(&shgroup->interface->uniforms);
BLI_freelistN(&shgroup->interface->attribs);
if (shgroup->interface->instance_vbo &&
- (shgroup->interface->instance_batch == 0))
+ (shgroup->interface->instance_batch == 0))
{
glDeleteBuffers(1, &shgroup->interface->instance_vbo);
}
MEM_freeN(shgroup->interface);
- BATCH_DISCARD_ALL_SAFE(shgroup->batch_geom);
+ GWN_BATCH_DISCARD_SAFE(shgroup->batch_geom);
}
void DRW_shgroup_instance_batch(DRWShadingGroup *shgroup, struct Gwn_Batch *instances)
@@ -862,7 +941,14 @@ void DRW_shgroup_call_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, float (*obm
{
BLI_assert(geom != NULL);
- DRWCall *call = MEM_callocN(sizeof(DRWCall), "DRWCall");
+ DRWCall *call;
+
+#ifdef USE_MEM_ITER
+ call = BLI_memiter_calloc(shgroup->calls, sizeof(DRWCall));
+#else
+ call = MEM_callocN(sizeof(DRWCall), "DRWCall");
+ BLI_addtail(&shgroup->calls, call);
+#endif
call->head.type = DRW_CALL_SINGLE;
#ifdef USE_GPU_SELECT
@@ -874,15 +960,20 @@ void DRW_shgroup_call_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, float (*obm
}
call->geometry = geom;
-
- BLI_addtail(&shgroup->calls, call);
}
void DRW_shgroup_call_object_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, Object *ob)
{
BLI_assert(geom != NULL);
- DRWCall *call = MEM_callocN(sizeof(DRWCall), "DRWCall");
+ DRWCall *call;
+
+#ifdef USE_MEM_ITER
+ call = BLI_memiter_calloc(shgroup->calls, sizeof(DRWCall));
+#else
+ call = MEM_callocN(sizeof(DRWCall), "DRWCall");
+ BLI_addtail(&shgroup->calls, call);
+#endif
call->head.type = DRW_CALL_SINGLE;
#ifdef USE_GPU_SELECT
@@ -892,8 +983,6 @@ void DRW_shgroup_call_object_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, Obje
copy_m4_m4(call->obmat, ob->obmat);
call->geometry = geom;
call->ob_data = ob->data;
-
- BLI_addtail(&shgroup->calls, call);
}
void DRW_shgroup_call_generate_add(
@@ -903,7 +992,14 @@ void DRW_shgroup_call_generate_add(
{
BLI_assert(geometry_fn != NULL);
- DRWCallGenerate *call = MEM_callocN(sizeof(DRWCallGenerate), "DRWCallGenerate");
+ DRWCallGenerate *call;
+
+#ifdef USE_MEM_ITER
+ call = BLI_memiter_calloc(shgroup->calls, sizeof(DRWCallGenerate));
+#else
+ call = MEM_callocN(sizeof(DRWCallGenerate), "DRWCallGenerate");
+ BLI_addtail(&shgroup->calls, call);
+#endif
call->head.type = DRW_CALL_GENERATE;
#ifdef USE_GPU_SELECT
@@ -916,8 +1012,6 @@ void DRW_shgroup_call_generate_add(
call->geometry_fn = geometry_fn;
call->user_data = user_data;
-
- BLI_addtail(&shgroup->calls, call);
}
static void sculpt_draw_cb(
@@ -947,7 +1041,12 @@ void DRW_shgroup_call_dynamic_add_array(DRWShadingGroup *shgroup, const void *at
#ifdef USE_GPU_SELECT
if ((G.f & G_PICKSEL) && (interface->instance_count > 0)) {
shgroup = MEM_dupallocN(shgroup);
+
+#ifdef USE_MEM_ITER
+ shgroup->calls = BLI_memiter_create(BLI_MEMITER_DEFAULT_SIZE);
+#else
BLI_listbase_clear(&shgroup->calls);
+#endif
shgroup->interface = interface = DRW_interface_duplicate(interface);
interface->instance_count = 0;
@@ -959,7 +1058,16 @@ void DRW_shgroup_call_dynamic_add_array(DRWShadingGroup *shgroup, const void *at
unsigned int data_size = sizeof(void *) * interface->attribs_count;
int size = sizeof(DRWCallDynamic) + data_size;
- DRWCallDynamic *call = MEM_callocN(size, "DRWCallDynamic");
+ DRWCallDynamic *call;
+
+#ifdef USE_MEM_ITER
+ call = BLI_memiter_alloc(shgroup->calls, size);
+#else
+ call = MEM_mallocN(size, "DRWCallDynamic");
+ BLI_addtail(&shgroup->calls, call);
+#endif
+
+ memset(call, 0x0, sizeof(DRWCallDynamic));
BLI_assert(attr_len == interface->attribs_count);
UNUSED_VARS_NDEBUG(attr_len);
@@ -974,8 +1082,6 @@ void DRW_shgroup_call_dynamic_add_array(DRWShadingGroup *shgroup, const void *at
}
interface->instance_count += 1;
-
- BLI_addtail(&shgroup->calls, call);
}
/* Used for instancing with no attributes */
@@ -991,14 +1097,17 @@ void DRW_shgroup_set_instance_count(DRWShadingGroup *shgroup, int count)
/**
* State is added to #Pass.state while drawing.
* Use to temporarily enable draw options.
- *
- * Currently there is no way to disable (could add if needed).
*/
void DRW_shgroup_state_enable(DRWShadingGroup *shgroup, DRWState state)
{
shgroup->state_extra |= state;
}
+void DRW_shgroup_state_disable(DRWShadingGroup *shgroup, DRWState state)
+{
+ shgroup->state_extra_disable &= ~state;
+}
+
void DRW_shgroup_attrib_float(DRWShadingGroup *shgroup, const char *name, int size)
{
DRW_interface_attrib(shgroup, name, DRW_ATTRIB_FLOAT, size, false);
@@ -1006,102 +1115,77 @@ void DRW_shgroup_attrib_float(DRWShadingGroup *shgroup, const char *name, int si
void DRW_shgroup_uniform_texture(DRWShadingGroup *shgroup, const char *name, const GPUTexture *tex)
{
- DRWInterface *interface = shgroup->interface;
-
- if (interface->tex_bind < 0) {
- /* TODO alert user */
- printf("Not enough texture slot for %s\n", name);
- return;
- }
-
- DRW_interface_uniform(shgroup, name, DRW_UNIFORM_TEXTURE, tex, 0, 1, interface->tex_bind--);
+ DRW_interface_uniform(shgroup, name, DRW_UNIFORM_TEXTURE, tex, 0, 1);
}
void DRW_shgroup_uniform_block(DRWShadingGroup *shgroup, const char *name, const GPUUniformBuffer *ubo)
{
- DRWInterface *interface = shgroup->interface;
-
- /* Be carefull: there is also a limit per shader stage. Usually 1/3 of normal limit. */
- if (interface->ubo_bind < 0) {
- /* TODO alert user */
- printf("Not enough ubo slots for %s\n", name);
- return;
- }
-
- DRW_interface_uniform(shgroup, name, DRW_UNIFORM_BLOCK, ubo, 0, 1, interface->ubo_bind--);
+ DRW_interface_uniform(shgroup, name, DRW_UNIFORM_BLOCK, ubo, 0, 1);
}
void DRW_shgroup_uniform_buffer(DRWShadingGroup *shgroup, const char *name, GPUTexture **tex)
{
- DRWInterface *interface = shgroup->interface;
-
- if (interface->tex_bind < 0) {
- /* TODO alert user */
- printf("Not enough texture slot for %s\n", name);
- return;
- }
-
- DRW_interface_uniform(shgroup, name, DRW_UNIFORM_BUFFER, tex, 0, 1, interface->tex_bind--);
+ DRW_interface_uniform(shgroup, name, DRW_UNIFORM_BUFFER, tex, 0, 1);
}
void DRW_shgroup_uniform_bool(DRWShadingGroup *shgroup, const char *name, const bool *value, int arraysize)
{
- DRW_interface_uniform(shgroup, name, DRW_UNIFORM_BOOL, value, 1, arraysize, 0);
+ DRW_interface_uniform(shgroup, name, DRW_UNIFORM_BOOL, value, 1, arraysize);
}
void DRW_shgroup_uniform_float(DRWShadingGroup *shgroup, const char *name, const float *value, int arraysize)
{
- DRW_interface_uniform(shgroup, name, DRW_UNIFORM_FLOAT, value, 1, arraysize, 0);
+ DRW_interface_uniform(shgroup, name, DRW_UNIFORM_FLOAT, value, 1, arraysize);
}
void DRW_shgroup_uniform_vec2(DRWShadingGroup *shgroup, const char *name, const float *value, int arraysize)
{
- DRW_interface_uniform(shgroup, name, DRW_UNIFORM_FLOAT, value, 2, arraysize, 0);
+ DRW_interface_uniform(shgroup, name, DRW_UNIFORM_FLOAT, value, 2, arraysize);
}
void DRW_shgroup_uniform_vec3(DRWShadingGroup *shgroup, const char *name, const float *value, int arraysize)
{
- DRW_interface_uniform(shgroup, name, DRW_UNIFORM_FLOAT, value, 3, arraysize, 0);
+ DRW_interface_uniform(shgroup, name, DRW_UNIFORM_FLOAT, value, 3, arraysize);
}
void DRW_shgroup_uniform_vec4(DRWShadingGroup *shgroup, const char *name, const float *value, int arraysize)
{
- DRW_interface_uniform(shgroup, name, DRW_UNIFORM_FLOAT, value, 4, arraysize, 0);
+ DRW_interface_uniform(shgroup, name, DRW_UNIFORM_FLOAT, value, 4, arraysize);
}
void DRW_shgroup_uniform_short_to_int(DRWShadingGroup *shgroup, const char *name, const short *value, int arraysize)
{
- DRW_interface_uniform(shgroup, name, DRW_UNIFORM_SHORT_TO_INT, value, 1, arraysize, 0);
+ DRW_interface_uniform(shgroup, name, DRW_UNIFORM_SHORT_TO_INT, value, 1, arraysize);
}
void DRW_shgroup_uniform_short_to_float(DRWShadingGroup *shgroup, const char *name, const short *value, int arraysize)
{
- DRW_interface_uniform(shgroup, name, DRW_UNIFORM_SHORT_TO_FLOAT, value, 1, arraysize, 0);
+ DRW_interface_uniform(shgroup, name, DRW_UNIFORM_SHORT_TO_FLOAT, value, 1, arraysize);
}
void DRW_shgroup_uniform_int(DRWShadingGroup *shgroup, const char *name, const int *value, int arraysize)
{
- DRW_interface_uniform(shgroup, name, DRW_UNIFORM_INT, value, 1, arraysize, 0);
+ DRW_interface_uniform(shgroup, name, DRW_UNIFORM_INT, value, 1, arraysize);
}
void DRW_shgroup_uniform_ivec2(DRWShadingGroup *shgroup, const char *name, const int *value, int arraysize)
{
- DRW_interface_uniform(shgroup, name, DRW_UNIFORM_INT, value, 2, arraysize, 0);
+ DRW_interface_uniform(shgroup, name, DRW_UNIFORM_INT, value, 2, arraysize);
}
void DRW_shgroup_uniform_ivec3(DRWShadingGroup *shgroup, const char *name, const int *value, int arraysize)
{
- DRW_interface_uniform(shgroup, name, DRW_UNIFORM_INT, value, 3, arraysize, 0);
+ DRW_interface_uniform(shgroup, name, DRW_UNIFORM_INT, value, 3, arraysize);
}
void DRW_shgroup_uniform_mat3(DRWShadingGroup *shgroup, const char *name, const float *value)
{
- DRW_interface_uniform(shgroup, name, DRW_UNIFORM_MAT3, value, 9, 1, 0);
+ DRW_interface_uniform(shgroup, name, DRW_UNIFORM_MAT3, value, 9, 1);
}
void DRW_shgroup_uniform_mat4(DRWShadingGroup *shgroup, const char *name, const float *value)
{
- DRW_interface_uniform(shgroup, name, DRW_UNIFORM_MAT4, value, 16, 1, 0);
+ DRW_interface_uniform(shgroup, name, DRW_UNIFORM_MAT4, value, 16, 1);
}
/* Creates a VBO containing OGL primitives for all DRWCallDynamic */
@@ -1138,7 +1222,14 @@ static void shgroup_dynamic_batch(DRWShadingGroup *shgroup)
GWN_vertbuf_data_alloc(vbo, nbr);
int j = 0;
- for (DRWCallDynamic *call = shgroup->calls.first; call; call = call->head.next, j++) {
+#ifdef USE_MEM_ITER
+ BLI_memiter_handle calls_iter;
+ BLI_memiter_iter_init(shgroup->calls, &calls_iter);
+ for (DRWCallDynamic *call; (call = BLI_memiter_iter_step(&calls_iter)); j++)
+#else
+ for (DRWCallDynamic *call = shgroup->calls.first; call; call = call->head.next, j++)
+#endif
+ {
int i = 0;
for (DRWAttrib *attrib = interface->attribs.first; attrib; attrib = attrib->next, i++) {
GWN_vertbuf_attr_set(vbo, attrib->format_id, j, call->data[i]);
@@ -1147,9 +1238,9 @@ static void shgroup_dynamic_batch(DRWShadingGroup *shgroup)
/* TODO make the batch dynamic instead of freeing it every times */
if (shgroup->batch_geom)
- GWN_batch_discard_all(shgroup->batch_geom);
+ GWN_batch_discard(shgroup->batch_geom);
- shgroup->batch_geom = GWN_batch_create(type, vbo, NULL);
+ shgroup->batch_geom = GWN_batch_create_ex(type, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
static void shgroup_dynamic_instance(DRWShadingGroup *shgroup)
@@ -1186,7 +1277,14 @@ static void shgroup_dynamic_instance(DRWShadingGroup *shgroup)
buffer_size = sizeof(float) * interface->attribs_stride * interface->instance_count;
float *data = MEM_mallocN(buffer_size, "Instance VBO data");
- for (DRWCallDynamic *call = shgroup->calls.first; call; call = call->head.next) {
+#ifdef USE_MEM_ITER
+ BLI_memiter_handle calls_iter;
+ BLI_memiter_iter_init(shgroup->calls, &calls_iter);
+ for (DRWCallDynamic *call; (call = BLI_memiter_iter_step(&calls_iter)); )
+#else
+ for (DRWCallDynamic *call = shgroup->calls.first; call; call = call->head.next)
+#endif
+ {
for (int j = 0; j < interface->attribs_count; ++j) {
memcpy(data + offset, call->data[j], sizeof(float) * interface->attribs_size[j]);
offset += interface->attribs_size[j];
@@ -1247,7 +1345,6 @@ void DRW_pass_free(DRWPass *pass)
DRW_shgroup_free(shgroup);
}
- glDeleteQueries(2, pass->timer_queries);
BLI_freelistN(&pass->shgroups);
}
@@ -1258,6 +1355,65 @@ void DRW_pass_foreach_shgroup(DRWPass *pass, void (*callback)(void *userData, DR
}
}
+typedef struct ZSortData {
+ float *axis;
+ float *origin;
+} ZSortData;
+
+static int pass_shgroup_dist_sort(void *thunk, const void *a, const void *b)
+{
+ const ZSortData *zsortdata = (ZSortData *)thunk;
+ const DRWShadingGroup *shgrp_a = (const DRWShadingGroup *)a;
+ const DRWShadingGroup *shgrp_b = (const DRWShadingGroup *)b;
+
+ const DRWCall *call_a;
+ const DRWCall *call_b;
+
+#ifdef USE_MEM_ITER
+ call_a = BLI_memiter_elem_first(shgrp_a->calls);
+ call_b = BLI_memiter_elem_first(shgrp_b->calls);
+#else
+ call_a = shgrp_a->calls.first;
+ call_b = shgrp_b->calls.first;
+#endif
+
+
+ float tmp[3];
+ sub_v3_v3v3(tmp, zsortdata->origin, call_a->obmat[3]);
+ const float a_sq = dot_v3v3(zsortdata->axis, tmp);
+ sub_v3_v3v3(tmp, zsortdata->origin, call_b->obmat[3]);
+ const float b_sq = dot_v3v3(zsortdata->axis, tmp);
+
+ if (a_sq < b_sq) return 1;
+ else if (a_sq > b_sq) return -1;
+ else {
+ /* If there is a depth prepass put it before */
+ if ((shgrp_a->state_extra & DRW_STATE_WRITE_DEPTH) != 0) {
+ return -1;
+ }
+ else if ((shgrp_b->state_extra & DRW_STATE_WRITE_DEPTH) != 0) {
+ return 1;
+ }
+ else return 0;
+ }
+}
+
+/**
+ * Sort Shading groups by decreasing Z of their first draw call.
+ * This is usefull for order dependant effect such as transparency.
+ **/
+void DRW_pass_sort_shgroup_z(DRWPass *pass)
+{
+ RegionView3D *rv3d = DST.draw_ctx.rv3d;
+
+ float (*viewinv)[4];
+ viewinv = (viewport_matrix_override.override[DRW_MAT_VIEWINV])
+ ? viewport_matrix_override.mat[DRW_MAT_VIEWINV] : rv3d->viewinv;
+
+ ZSortData zsortdata = {viewinv[2], viewinv[3]};
+ BLI_listbase_sort_r(&pass->shgroups, pass_shgroup_dist_sort, &zsortdata);
+}
+
/** \} */
@@ -1401,7 +1557,7 @@ static void DRW_state_set(DRWState state)
{
int test;
if (CHANGED_ANY_STORE_VAR(
- DRW_STATE_BLEND | DRW_STATE_ADDITIVE | DRW_STATE_MULTIPLY,
+ DRW_STATE_BLEND | DRW_STATE_ADDITIVE | DRW_STATE_MULTIPLY | DRW_STATE_TRANSMISSION,
test))
{
if (test) {
@@ -1413,8 +1569,11 @@ static void DRW_state_set(DRWState state)
else if ((state & DRW_STATE_MULTIPLY) != 0) {
glBlendFunc(GL_DST_COLOR, GL_ZERO);
}
+ else if ((state & DRW_STATE_TRANSMISSION) != 0) {
+ glBlendFunc(GL_ONE, GL_SRC_ALPHA);
+ }
else if ((state & DRW_STATE_ADDITIVE) != 0) {
- glBlendFunc(GL_ONE, GL_ONE);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE);
}
else {
BLI_assert(0);
@@ -1566,12 +1725,10 @@ static void draw_geometry_prepare(
? viewport_matrix_override.mat[DRW_MAT_VIEWINV] : rv3d->viewinv;
winmat = (viewport_matrix_override.override[DRW_MAT_WIN])
? viewport_matrix_override.mat[DRW_MAT_WIN] : rv3d->winmat;
+ wininv = viewport_matrix_override.mat[DRW_MAT_WININV];
if (do_pi) {
- if (viewport_matrix_override.override[DRW_MAT_WININV]) {
- wininv = viewport_matrix_override.mat[DRW_MAT_WININV];
- }
- else {
+ if (!viewport_matrix_override.override[DRW_MAT_WININV]) {
invert_m4_m4(pi, winmat);
wininv = pi;
}
@@ -1646,12 +1803,16 @@ static void draw_geometry_execute(DRWShadingGroup *shgroup, Gwn_Batch *geom)
GWN_batch_draw_stupid_instanced_with_batch(geom, interface->instance_batch);
}
else if (interface->instance_vbo) {
- GWN_batch_draw_stupid_instanced(geom, interface->instance_vbo, interface->instance_count, interface->attribs_count,
- interface->attribs_stride, interface->attribs_size, interface->attribs_loc);
+ GWN_batch_draw_stupid_instanced(
+ geom, interface->instance_vbo, interface->instance_count, interface->attribs_count,
+ interface->attribs_stride, interface->attribs_size, interface->attribs_loc);
}
else {
GWN_batch_draw_stupid(geom);
}
+ /* XXX this just tells gawain we are done with the shader.
+ * This does not unbind the shader. */
+ GWN_batch_program_unset(geom);
}
static void draw_geometry(DRWShadingGroup *shgroup, Gwn_Batch *geom, const float (*obmat)[4], ID *ob_data)
@@ -1661,10 +1822,11 @@ static void draw_geometry(DRWShadingGroup *shgroup, Gwn_Batch *geom, const float
if (ob_data != NULL) {
switch (GS(ob_data->name)) {
- case OB_MESH:
+ case ID_ME:
BKE_mesh_texspace_get_reference((Mesh *)ob_data, NULL, &texcoloc, NULL, &texcosize);
- /* TODO, curve, metaball? */
+ break;
default:
+ /* TODO, curve, metaball? */
break;
}
}
@@ -1674,6 +1836,54 @@ static void draw_geometry(DRWShadingGroup *shgroup, Gwn_Batch *geom, const float
draw_geometry_execute(shgroup, geom);
}
+static void bind_texture(GPUTexture *tex)
+{
+ int bind_num = GPU_texture_bound_number(tex);
+ if (bind_num == -1) {
+ for (int i = 0; i < GPU_max_textures(); ++i) {
+ RST.bind_tex_inc = (RST.bind_tex_inc + 1) % GPU_max_textures();
+ if (RST.bound_tex_slots[RST.bind_tex_inc] == false) {
+ if (RST.bound_texs[RST.bind_tex_inc] != NULL) {
+ GPU_texture_unbind(RST.bound_texs[RST.bind_tex_inc]);
+ }
+ GPU_texture_bind(tex, RST.bind_tex_inc);
+ RST.bound_texs[RST.bind_tex_inc] = tex;
+ RST.bound_tex_slots[RST.bind_tex_inc] = true;
+ return;
+ }
+ }
+
+ printf("Not enough texture slots! Reduce number of textures used by your shader.\n");
+ }
+ RST.bound_tex_slots[bind_num] = true;
+}
+
+static void bind_ubo(GPUUniformBuffer *ubo)
+{
+ if (RST.bind_ubo_inc < GPU_max_ubo_binds()) {
+ GPU_uniformbuffer_bind(ubo, RST.bind_ubo_inc);
+ RST.bind_ubo_inc++;
+ }
+ else {
+ /* This is not depending on user input.
+ * It is our responsability to make sure there enough slots. */
+ BLI_assert(0 && "Not enough ubo slots! This should not happen!\n");
+
+ /* printf so user can report bad behaviour */
+ printf("Not enough ubo slots! This should not happen!\n");
+ }
+}
+
+static void release_texture_slots(void)
+{
+ memset(RST.bound_tex_slots, 0x0, sizeof(bool) * GPU_max_textures());
+}
+
+static void release_ubo_slots(void)
+{
+ RST.bind_ubo_inc = 0;
+}
+
static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
{
BLI_assert(shgroup->shader);
@@ -1681,6 +1891,7 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
DRWInterface *interface = shgroup->interface;
GPUTexture *tex;
+ GPUUniformBuffer *ubo;
int val;
float fval;
@@ -1696,13 +1907,15 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
shgroup_dynamic_batch_from_calls(shgroup);
}
- DRW_state_set(pass_state | shgroup->state_extra);
+ release_texture_slots();
+ release_ubo_slots();
+
+ DRW_state_set((pass_state & shgroup->state_extra_disable) | shgroup->state_extra);
+
/* Binding Uniform */
/* Don't check anything, Interface should already contain the least uniform as possible */
for (DRWUniform *uni = interface->uniforms.first; uni; uni = uni->next) {
- DRWBoundTexture *bound_tex;
-
switch (uni->type) {
case DRW_UNIFORM_SHORT_TO_INT:
val = (int)*((short *)uni->value);
@@ -1728,12 +1941,7 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
case DRW_UNIFORM_TEXTURE:
tex = (GPUTexture *)uni->value;
BLI_assert(tex);
- GPU_texture_bind(tex, uni->bindloc);
-
- bound_tex = MEM_callocN(sizeof(DRWBoundTexture), "DRWBoundTexture");
- bound_tex->tex = tex;
- BLI_addtail(&DST.bound_texs, bound_tex);
-
+ bind_texture(tex);
GPU_shader_uniform_texture(shgroup->shader, uni->location, tex);
break;
case DRW_UNIFORM_BUFFER:
@@ -1742,17 +1950,13 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
}
tex = *((GPUTexture **)uni->value);
BLI_assert(tex);
- GPU_texture_bind(tex, uni->bindloc);
-
- bound_tex = MEM_callocN(sizeof(DRWBoundTexture), "DRWBoundTexture");
- bound_tex->tex = tex;
- BLI_addtail(&DST.bound_texs, bound_tex);
-
+ bind_texture(tex);
GPU_shader_uniform_texture(shgroup->shader, uni->location, tex);
break;
case DRW_UNIFORM_BLOCK:
- GPU_uniformbuffer_bind((GPUUniformBuffer *)uni->value, uni->bindloc);
- GPU_shader_uniform_buffer(shgroup->shader, uni->location, (GPUUniformBuffer *)uni->value);
+ ubo = (GPUUniformBuffer *)uni->value;
+ bind_ubo(ubo);
+ GPU_shader_uniform_buffer(shgroup->shader, uni->location, ubo);
break;
}
}
@@ -1763,11 +1967,24 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
if ((G.f & G_PICKSEL) && (_call)) { \
GPU_select_load_id((_call)->head.select_id); \
} ((void)0)
+
+#ifdef USE_MEM_ITER
+# define GPU_SELECT_LOAD_IF_PICKSEL_LIST(_call_ls) \
+ if (G.f & G_PICKSEL) { \
+ DRWCall *call_test = BLI_memiter_elem_first(*(_call_ls)); \
+ if (call_test != NULL) { \
+ BLI_assert(BLI_memiter_count(*(_call_ls)) == 1); \
+ GPU_select_load_id(call_test->head.select_id); \
+ } \
+ } ((void)0)
+#else
# define GPU_SELECT_LOAD_IF_PICKSEL_LIST(_call_ls) \
if ((G.f & G_PICKSEL) && (_call_ls)->first) { \
BLI_assert(BLI_listbase_is_single(_call_ls)); \
GPU_select_load_id(((DRWCall *)(_call_ls)->first)->head.select_id); \
} ((void)0)
+#endif
+
#else
# define GPU_SELECT_LOAD_IF_PICKSEL(call)
# define GPU_SELECT_LOAD_IF_PICKSEL_LIST(call)
@@ -1780,10 +1997,10 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
unit_m4(obmat);
if (shgroup->type == DRW_SHG_INSTANCE &&
- (interface->instance_count > 0 || interface->instance_batch != NULL))
+ (interface->instance_count > 0 || interface->instance_batch != NULL))
{
GPU_SELECT_LOAD_IF_PICKSEL_LIST(&shgroup->calls);
- draw_geometry(shgroup, shgroup->instance_geom, obmat, NULL);
+ draw_geometry(shgroup, shgroup->instance_geom, obmat, shgroup->instance_data);
}
else {
/* Some dynamic batch can have no geom (no call to aggregate) */
@@ -1794,7 +2011,14 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
}
}
else {
- for (DRWCall *call = shgroup->calls.first; call; call = call->head.next) {
+#ifdef USE_MEM_ITER
+ BLI_memiter_handle calls_iter;
+ BLI_memiter_iter_init(shgroup->calls, &calls_iter);
+ for (DRWCall *call; (call = BLI_memiter_iter_step(&calls_iter)); )
+#else
+ for (DRWCall *call = shgroup->calls.first; call; call = call->head.next)
+#endif
+ {
bool neg_scale = is_negative_m4(call->obmat);
/* Negative scale objects */
@@ -1825,59 +2049,48 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
DRW_state_reset();
}
-void DRW_draw_pass(DRWPass *pass)
+static void DRW_draw_pass_ex(DRWPass *pass, DRWShadingGroup *start_group, DRWShadingGroup *end_group)
{
/* Start fresh */
DST.shader = NULL;
- DST.tex_bind_id = 0;
DRW_state_set(pass->state);
- BLI_listbase_clear(&DST.bound_texs);
- /* Init Timer queries */
- if (pass->timer_queries[0] == 0) {
- pass->front_idx = 0;
- pass->back_idx = 1;
+ DRW_stats_query_start(pass->name);
- glGenQueries(2, pass->timer_queries);
-
- /* dummy query, avoid gl error */
- glBeginQuery(GL_TIME_ELAPSED, pass->timer_queries[pass->front_idx]);
- glEndQuery(GL_TIME_ELAPSED);
- }
- else {
- /* swap indices */
- unsigned int tmp = pass->back_idx;
- pass->back_idx = pass->front_idx;
- pass->front_idx = tmp;
- }
-
- if (!pass->wasdrawn) {
- /* issue query for the next frame */
- glBeginQuery(GL_TIME_ELAPSED, pass->timer_queries[pass->back_idx]);
- }
-
- for (DRWShadingGroup *shgroup = pass->shgroups.first; shgroup; shgroup = shgroup->next) {
+ for (DRWShadingGroup *shgroup = start_group; shgroup; shgroup = shgroup->next) {
draw_shgroup(shgroup, pass->state);
+ /* break if upper limit */
+ if (shgroup == end_group) {
+ break;
+ }
}
/* Clear Bound textures */
- for (DRWBoundTexture *bound_tex = DST.bound_texs.first; bound_tex; bound_tex = bound_tex->next) {
- GPU_texture_unbind(bound_tex->tex);
+ for (int i = 0; i < GPU_max_textures(); i++) {
+ if (RST.bound_texs[i] != NULL) {
+ GPU_texture_unbind(RST.bound_texs[i]);
+ RST.bound_texs[i] = NULL;
+ }
}
- DST.tex_bind_id = 0;
- BLI_freelistN(&DST.bound_texs);
if (DST.shader) {
GPU_shader_unbind();
DST.shader = NULL;
}
- if (!pass->wasdrawn) {
- glEndQuery(GL_TIME_ELAPSED);
- }
+ DRW_stats_query_end();
+}
+
+void DRW_draw_pass(DRWPass *pass)
+{
+ DRW_draw_pass_ex(pass, pass->shgroups.first, pass->shgroups.last);
+}
- pass->wasdrawn = true;
+/* Draw only a subset of shgroups. Used in special situations as grease pencil strokes */
+void DRW_draw_pass_subset(DRWPass *pass, DRWShadingGroup *start_group, DRWShadingGroup *end_group)
+{
+ DRW_draw_pass_ex(pass, start_group, end_group);
}
void DRW_draw_callbacks_pre_scene(void)
@@ -1905,6 +2118,9 @@ void DRW_state_reset_ex(DRWState state)
void DRW_state_reset(void)
{
+ /* Reset blending function */
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
DRW_state_reset_ex(DRW_STATE_DEFAULT);
}
@@ -1953,6 +2169,10 @@ bool DRW_object_is_renderable(Object *ob)
Scene *scene = DST.draw_ctx.scene;
Object *obedit = scene->obedit;
+ if (!BKE_object_is_visible(ob)) {
+ return false;
+ }
+
if (ob->type == OB_MESH) {
if (ob == obedit) {
IDProperty *props = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_EDIT, "");
@@ -1970,11 +2190,10 @@ bool DRW_object_is_renderable(Object *ob)
return true;
}
-
-bool DRW_object_is_flat_normal(Object *ob)
+bool DRW_object_is_flat_normal(const Object *ob)
{
if (ob->type == OB_MESH) {
- Mesh *me = ob->data;
+ const Mesh *me = ob->data;
if (me->mpoly && me->mpoly[0].flag & ME_SMOOTH) {
return false;
}
@@ -1982,6 +2201,26 @@ bool DRW_object_is_flat_normal(Object *ob)
return true;
}
+
+/**
+ * Return true if the object has its own draw mode.
+ * Caller must check this is active */
+int DRW_object_is_mode_shade(const Object *ob)
+{
+ BLI_assert(ob == DST.draw_ctx.obact);
+ if ((ob->mode & OB_MODE_EDIT) == 0) {
+ if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) {
+ if ((DST.draw_ctx.v3d->flag2 & V3D_SHOW_MODE_SHADE_OVERRIDE) == 0) {
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+ }
+ return -1;
+}
+
/** \} */
@@ -1990,23 +2229,28 @@ bool DRW_object_is_flat_normal(Object *ob)
/** \name Framebuffers (DRW_framebuffer)
* \{ */
-static GPUTextureFormat convert_tex_format(int fbo_format, int *channels, bool *is_depth)
+static GPUTextureFormat convert_tex_format(
+ int fbo_format,
+ int *r_channels, bool *r_is_depth)
{
- *is_depth = ELEM(fbo_format, DRW_TEX_DEPTH_16, DRW_TEX_DEPTH_24);
+ *r_is_depth = ELEM(fbo_format, DRW_TEX_DEPTH_16, DRW_TEX_DEPTH_24);
switch (fbo_format) {
- case DRW_TEX_R_16: *channels = 1; return GPU_R16F;
- case DRW_TEX_R_32: *channels = 1; return GPU_R32F;
- case DRW_TEX_RG_16: *channels = 2; return GPU_RG16F;
- case DRW_TEX_RG_32: *channels = 2; return GPU_RG32F;
- case DRW_TEX_RGBA_8: *channels = 4; return GPU_RGBA8;
- case DRW_TEX_RGBA_16: *channels = 4; return GPU_RGBA16F;
- case DRW_TEX_RGBA_32: *channels = 4; return GPU_RGBA32F;
- case DRW_TEX_DEPTH_24: *channels = 1; return GPU_DEPTH_COMPONENT24;
- case DRW_TEX_RGB_11_11_10: *channels = 3; return GPU_R11F_G11F_B10F;
+ case DRW_TEX_R_16: *r_channels = 1; return GPU_R16F;
+ case DRW_TEX_R_32: *r_channels = 1; return GPU_R32F;
+ case DRW_TEX_RG_8: *r_channels = 2; return GPU_RG8;
+ case DRW_TEX_RG_16: *r_channels = 2; return GPU_RG16F;
+ case DRW_TEX_RG_32: *r_channels = 2; return GPU_RG32F;
+ case DRW_TEX_RGBA_8: *r_channels = 4; return GPU_RGBA8;
+ case DRW_TEX_RGBA_16: *r_channels = 4; return GPU_RGBA16F;
+ case DRW_TEX_RGBA_32: *r_channels = 4; return GPU_RGBA32F;
+ case DRW_TEX_DEPTH_16: *r_channels = 1; return GPU_DEPTH_COMPONENT16;
+ case DRW_TEX_DEPTH_24: *r_channels = 1; return GPU_DEPTH_COMPONENT24;
+ case DRW_TEX_DEPTH_32: *r_channels = 1; return GPU_DEPTH_COMPONENT32F;
+ case DRW_TEX_RGB_11_11_10: *r_channels = 3; return GPU_R11F_G11F_B10F;
default:
BLI_assert(false && "Texture format unsupported as render target!");
- *channels = 4; return GPU_RGBA8;
+ *r_channels = 4; return GPU_RGBA8;
}
}
@@ -2036,10 +2280,12 @@ void DRW_framebuffer_init(
if (!*fbotex.tex || is_temp) {
/* Temp textures need to be queried each frame, others not. */
if (is_temp) {
- *fbotex.tex = GPU_viewport_texture_pool_query(DST.viewport, engine_type, width, height, channels, gpu_format);
+ *fbotex.tex = GPU_viewport_texture_pool_query(
+ DST.viewport, engine_type, width, height, channels, gpu_format);
}
else if (create_fb) {
- *fbotex.tex = GPU_texture_create_2D_custom(width, height, channels, gpu_format, NULL, NULL);
+ *fbotex.tex = GPU_texture_create_2D_custom(
+ width, height, channels, gpu_format, NULL, NULL);
}
}
@@ -2164,8 +2410,14 @@ void DRW_transform_to_display(GPUTexture *tex)
bool use_ocio = false;
- if (DST.draw_ctx.evil_C != NULL) {
- use_ocio = IMB_colormanagement_setup_glsl_draw_from_space_ctx(DST.draw_ctx.evil_C, NULL, dither, false);
+ {
+ Scene *scene = DST.draw_ctx.scene;
+ /* View transform is already applied for offscreen, don't apply again, see: T52046 */
+ ColorManagedViewSettings *view_settings =
+ (DST.options.is_image_render && !DST.options.is_scene_render) ?
+ NULL : &scene->view_settings;
+ use_ocio = IMB_colormanagement_setup_glsl_draw_from_space(
+ view_settings, &scene->display_settings, NULL, dither, false);
}
if (!use_ocio) {
@@ -2291,34 +2543,50 @@ static void DRW_viewport_var_init(void)
DST.frontface = GL_CCW;
DST.backface = GL_CW;
glFrontFace(DST.frontface);
+
+ /* Alloc array of texture reference. */
+ if (RST.bound_texs == NULL) {
+ RST.bound_texs = MEM_callocN(sizeof(GPUTexture *) * GPU_max_textures(), "Bound GPUTexture refs");
+ }
+ if (RST.bound_tex_slots == NULL) {
+ RST.bound_tex_slots = MEM_callocN(sizeof(bool) * GPU_max_textures(), "Bound Texture Slots");
+ }
+
+ memset(viewport_matrix_override.override, 0x0, sizeof(viewport_matrix_override.override));
}
void DRW_viewport_matrix_get(float mat[4][4], DRWViewportMatrixType type)
{
RegionView3D *rv3d = DST.draw_ctx.rv3d;
+ BLI_assert(type >= DRW_MAT_PERS && type <= DRW_MAT_WININV);
- switch (type) {
- case DRW_MAT_PERS:
- copy_m4_m4(mat, rv3d->persmat);
- break;
- case DRW_MAT_PERSINV:
- copy_m4_m4(mat, rv3d->persinv);
- break;
- case DRW_MAT_VIEW:
- copy_m4_m4(mat, rv3d->viewmat);
- break;
- case DRW_MAT_VIEWINV:
- copy_m4_m4(mat, rv3d->viewinv);
- break;
- case DRW_MAT_WIN:
- copy_m4_m4(mat, rv3d->winmat);
- break;
- case DRW_MAT_WININV:
- invert_m4_m4(mat, rv3d->winmat);
- break;
- default:
- BLI_assert(!"Matrix type invalid");
- break;
+ if (viewport_matrix_override.override[type]) {
+ copy_m4_m4(mat, viewport_matrix_override.mat[type]);
+ }
+ else {
+ switch (type) {
+ case DRW_MAT_PERS:
+ copy_m4_m4(mat, rv3d->persmat);
+ break;
+ case DRW_MAT_PERSINV:
+ copy_m4_m4(mat, rv3d->persinv);
+ break;
+ case DRW_MAT_VIEW:
+ copy_m4_m4(mat, rv3d->viewmat);
+ break;
+ case DRW_MAT_VIEWINV:
+ copy_m4_m4(mat, rv3d->viewinv);
+ break;
+ case DRW_MAT_WIN:
+ copy_m4_m4(mat, rv3d->winmat);
+ break;
+ case DRW_MAT_WININV:
+ invert_m4_m4(mat, rv3d->winmat);
+ break;
+ default:
+ BLI_assert(!"Matrix type invalid");
+ break;
+ }
}
}
@@ -2351,8 +2619,7 @@ DefaultTextureList *DRW_viewport_texture_list_get(void)
void DRW_viewport_request_redraw(void)
{
- /* XXXXXXXXXXX HAAAAAAAACKKKK */
- WM_main_add_notifier(NC_MATERIAL | ND_SHADING_DRAW, NULL);
+ GPU_viewport_tag_update(DST.viewport);
}
/** \} */
@@ -2366,7 +2633,7 @@ void **DRW_scene_layer_engine_data_get(DrawEngineType *engine_type, void (*callb
{
SceneLayerEngineData *sled;
- for (sled = DST.draw_ctx.sl->drawdata.first; sled; sled = sled->next) {
+ for (sled = DST.draw_ctx.scene_layer->drawdata.first; sled; sled = sled->next) {
if (sled->engine_type == engine_type) {
return &sled->storage;
}
@@ -2375,7 +2642,7 @@ void **DRW_scene_layer_engine_data_get(DrawEngineType *engine_type, void (*callb
sled = MEM_callocN(sizeof(SceneLayerEngineData), "SceneLayerEngineData");
sled->engine_type = engine_type;
sled->free = callback;
- BLI_addtail(&DST.draw_ctx.sl->drawdata, sled);
+ BLI_addtail(&DST.draw_ctx.scene_layer->drawdata, sled);
return &sled->storage;
}
@@ -2433,21 +2700,18 @@ void DRW_lamp_engine_data_free(LampEngineData *led)
/** \name Rendering (DRW_engines)
* \{ */
-#define TIMER_FALLOFF 0.1f
-
static void DRW_engines_init(void)
{
for (LinkData *link = DST.enabled_engines.first; link; link = link->next) {
DrawEngineType *engine = link->data;
ViewportEngineData *data = DRW_viewport_engine_data_get(engine);
- double stime = PIL_check_seconds_timer();
+ PROFILE_START(stime);
if (engine->engine_init) {
engine->engine_init(data);
}
- double ftime = (PIL_check_seconds_timer() - stime) * 1e3;
- data->init_time = data->init_time * (1.0f - TIMER_FALLOFF) + ftime * TIMER_FALLOFF; /* exp average */
+ PROFILE_END_UPDATE(data->init_time, stime);
}
}
@@ -2465,14 +2729,9 @@ static void DRW_engines_cache_init(void)
DST.text_store_p = &data->text_draw_cache;
}
- double stime = PIL_check_seconds_timer();
- data->cache_time = 0.0;
-
if (engine->cache_init) {
engine->cache_init(data);
}
-
- data->cache_time += (PIL_check_seconds_timer() - stime) * 1e3;
}
}
@@ -2481,13 +2740,10 @@ static void DRW_engines_cache_populate(Object *ob)
for (LinkData *link = DST.enabled_engines.first; link; link = link->next) {
DrawEngineType *engine = link->data;
ViewportEngineData *data = DRW_viewport_engine_data_get(engine);
- double stime = PIL_check_seconds_timer();
if (engine->cache_populate) {
engine->cache_populate(data, ob);
}
-
- data->cache_time += (PIL_check_seconds_timer() - stime) * 1e3;
}
}
@@ -2496,13 +2752,10 @@ static void DRW_engines_cache_finish(void)
for (LinkData *link = DST.enabled_engines.first; link; link = link->next) {
DrawEngineType *engine = link->data;
ViewportEngineData *data = DRW_viewport_engine_data_get(engine);
- double stime = PIL_check_seconds_timer();
if (engine->cache_finish) {
engine->cache_finish(data);
}
-
- data->cache_time += (PIL_check_seconds_timer() - stime) * 1e3;
}
}
@@ -2511,15 +2764,17 @@ static void DRW_engines_draw_background(void)
for (LinkData *link = DST.enabled_engines.first; link; link = link->next) {
DrawEngineType *engine = link->data;
ViewportEngineData *data = DRW_viewport_engine_data_get(engine);
- double stime = PIL_check_seconds_timer();
if (engine->draw_background) {
+ PROFILE_START(stime);
+
+ DRW_stats_group_start(engine->idname);
engine->draw_background(data);
+ DRW_stats_group_end();
+
+ PROFILE_END_UPDATE(data->background_time, stime);
return;
}
-
- double ftime = (PIL_check_seconds_timer() - stime) * 1e3;
- data->background_time = data->background_time * (1.0f - TIMER_FALLOFF) + ftime * TIMER_FALLOFF; /* exp average */
}
/* No draw_background found, doing default background */
@@ -2531,14 +2786,15 @@ static void DRW_engines_draw_scene(void)
for (LinkData *link = DST.enabled_engines.first; link; link = link->next) {
DrawEngineType *engine = link->data;
ViewportEngineData *data = DRW_viewport_engine_data_get(engine);
- double stime = PIL_check_seconds_timer();
+ PROFILE_START(stime);
if (engine->draw_scene) {
+ DRW_stats_group_start(engine->idname);
engine->draw_scene(data);
+ DRW_stats_group_end();
}
- double ftime = (PIL_check_seconds_timer() - stime) * 1e3;
- data->render_time = data->render_time * (1.0f - TIMER_FALLOFF) + ftime * TIMER_FALLOFF; /* exp average */
+ PROFILE_END_UPDATE(data->render_time, stime);
}
}
@@ -2547,14 +2803,13 @@ static void DRW_engines_draw_text(void)
for (LinkData *link = DST.enabled_engines.first; link; link = link->next) {
DrawEngineType *engine = link->data;
ViewportEngineData *data = DRW_viewport_engine_data_get(engine);
- double stime = PIL_check_seconds_timer();
+ PROFILE_START(stime);
if (data->text_draw_cache) {
DRW_text_cache_draw(data->text_draw_cache, DST.draw_ctx.v3d, DST.draw_ctx.ar, false);
}
- double ftime = (PIL_check_seconds_timer() - stime) * 1e3;
- data->render_time = data->render_time * (1.0f - TIMER_FALLOFF) + ftime * TIMER_FALLOFF; /* exp average */
+ PROFILE_END_UPDATE(data->render_time, stime);
}
}
@@ -2590,7 +2845,8 @@ int DRW_draw_region_engine_info_offset(void)
void DRW_draw_region_engine_info(void)
{
const char *info_array_final[MAX_INFO_LINES + 1];
- char info_array[MAX_INFO_LINES][GPU_INFO_SIZE]; /* This should be maxium number of engines running at the same time. */
+ /* This should be maxium number of engines running at the same time. */
+ char info_array[MAX_INFO_LINES][GPU_INFO_SIZE];
int i = 0;
const DRWContextState *draw_ctx = DRW_context_state_get();
@@ -2734,14 +2990,13 @@ static void DRW_engines_enable_external(void)
use_drw_engine(DRW_engine_viewport_external_type.draw_engine);
}
-static void DRW_engines_enable(const Scene *scene, SceneLayer *sl, const View3D *v3d)
+static void DRW_engines_enable(const Scene *scene, SceneLayer *sl)
{
- const int mode = CTX_data_mode_enum_ex(scene->obedit, OBACT_NEW);
+ Object *obact = OBACT_NEW(sl);
+ const int mode = CTX_data_mode_enum_ex(scene->obedit, obact);
DRW_engines_enable_from_engine(scene);
- if ((DRW_state_is_scene_render() == false) &&
- (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0)
- {
+ if (DRW_state_draw_support()) {
DRW_engines_enable_from_object_mode();
DRW_engines_enable_from_mode(mode);
}
@@ -2768,7 +3023,7 @@ static unsigned int DRW_engines_get_hash(void)
static void draw_stat(rcti *rect, int u, int v, const char *txt, const int size)
{
BLF_draw_default_ascii(rect->xmin + (1 + u * 5) * U.widget_unit,
- rect->ymax - (3 + v++) * U.widget_unit, 0.0f,
+ rect->ymax - (3 + v) * U.widget_unit, 0.0f,
txt, size);
}
@@ -2776,7 +3031,7 @@ static void draw_stat(rcti *rect, int u, int v, const char *txt, const int size)
static void DRW_debug_cpu_stats(void)
{
int u, v;
- double cache_tot_time = 0.0, init_tot_time = 0.0, background_tot_time = 0.0, render_tot_time = 0.0, tot_time = 0.0;
+ double init_tot_time = 0.0, background_tot_time = 0.0, render_tot_time = 0.0, tot_time = 0.0;
/* local coordinate visible rect inside region, to accomodate overlapping ui */
rcti rect;
struct ARegion *ar = DST.draw_ctx.ar;
@@ -2790,8 +3045,6 @@ static void DRW_debug_cpu_stats(void)
char col_label[32];
sprintf(col_label, "Engine");
draw_stat(&rect, u++, v, col_label, sizeof(col_label));
- sprintf(col_label, "Cache");
- draw_stat(&rect, u++, v, col_label, sizeof(col_label));
sprintf(col_label, "Init");
draw_stat(&rect, u++, v, col_label, sizeof(col_label));
sprintf(col_label, "Background");
@@ -2811,10 +3064,6 @@ static void DRW_debug_cpu_stats(void)
draw_stat(&rect, u++, v, engine->idname, sizeof(engine->idname));
- cache_tot_time += data->cache_time;
- sprintf(time_to_txt, "%.2fms", data->cache_time);
- draw_stat(&rect, u++, v, time_to_txt, sizeof(time_to_txt));
-
init_tot_time += data->init_time;
sprintf(time_to_txt, "%.2fms", data->init_time);
draw_stat(&rect, u++, v, time_to_txt, sizeof(time_to_txt));
@@ -2837,8 +3086,6 @@ static void DRW_debug_cpu_stats(void)
u = 0;
sprintf(col_label, "Sub Total");
draw_stat(&rect, u++, v, col_label, sizeof(col_label));
- sprintf(time_to_txt, "%.2fms", cache_tot_time);
- draw_stat(&rect, u++, v, time_to_txt, sizeof(time_to_txt));
sprintf(time_to_txt, "%.2fms", init_tot_time);
draw_stat(&rect, u++, v, time_to_txt, sizeof(time_to_txt));
sprintf(time_to_txt, "%.2fms", background_tot_time);
@@ -2847,6 +3094,13 @@ static void DRW_debug_cpu_stats(void)
draw_stat(&rect, u++, v, time_to_txt, sizeof(time_to_txt));
sprintf(time_to_txt, "%.2fms", tot_time);
draw_stat(&rect, u++, v, time_to_txt, sizeof(time_to_txt));
+ v += 2;
+
+ u = 0;
+ sprintf(col_label, "Cache Time");
+ draw_stat(&rect, u++, v, col_label, sizeof(col_label));
+ sprintf(time_to_txt, "%.2fms", DST.cache_time);
+ draw_stat(&rect, u++, v, time_to_txt, sizeof(time_to_txt));
}
/* Display GPU time for each passes */
@@ -2859,68 +3113,78 @@ static void DRW_debug_gpu_stats(void)
UI_FontThemeColor(BLF_default(), TH_TEXT_HI);
- char time_to_txt[16];
- char pass_name[MAX_PASS_NAME + 16];
- int v = BLI_listbase_count(&DST.enabled_engines) + 3;
- GLuint64 tot_time = 0;
+ int v = BLI_listbase_count(&DST.enabled_engines) + 5;
- if (G.debug_value > 666) {
- for (LinkData *link = DST.enabled_engines.first; link; link = link->next) {
- GLuint64 engine_time = 0;
- DrawEngineType *engine = link->data;
- ViewportEngineData *data = DRW_viewport_engine_data_get(engine);
- int vsta = v;
+ char stat_string[32];
- draw_stat(&rect, 0, v, engine->idname, sizeof(engine->idname));
- v++;
+ /* Memory Stats */
+ unsigned int tex_mem = GPU_texture_memory_usage_get();
+ unsigned int vbo_mem = GWN_vertbuf_get_memory_usage();
- for (int i = 0; i < engine->vedata_size->psl_len; ++i) {
- DRWPass *pass = data->psl->passes[i];
- if (pass != NULL && pass->wasdrawn) {
- GLuint64 time;
- glGetQueryObjectui64v(pass->timer_queries[pass->front_idx], GL_QUERY_RESULT, &time);
+ sprintf(stat_string, "GPU Memory");
+ draw_stat(&rect, 0, v, stat_string, sizeof(stat_string));
+ sprintf(stat_string, "%.2fMB", (double)(tex_mem + vbo_mem) / 1000000.0);
+ draw_stat(&rect, 1, v++, stat_string, sizeof(stat_string));
+ sprintf(stat_string, " |--> Textures");
+ draw_stat(&rect, 0, v, stat_string, sizeof(stat_string));
+ sprintf(stat_string, "%.2fMB", (double)tex_mem / 1000000.0);
+ draw_stat(&rect, 1, v++, stat_string, sizeof(stat_string));
+ sprintf(stat_string, " |--> Meshes");
+ draw_stat(&rect, 0, v, stat_string, sizeof(stat_string));
+ sprintf(stat_string, "%.2fMB", (double)vbo_mem / 1000000.0);
+ draw_stat(&rect, 1, v++, stat_string, sizeof(stat_string));
- sprintf(pass_name, " |--> %s", pass->name);
- draw_stat(&rect, 0, v, pass_name, sizeof(pass_name));
+ /* Pre offset for stats_draw */
+ rect.ymax -= (3 + ++v) * U.widget_unit;
- sprintf(time_to_txt, "%.2fms", time / 1000000.0);
- engine_time += time;
- tot_time += time;
+ /* Rendering Stats */
+ DRW_stats_draw(&rect);
+}
- draw_stat(&rect, 2, v++, time_to_txt, sizeof(time_to_txt));
+/* -------------------------------------------------------------------- */
- pass->wasdrawn = false;
- }
- }
- /* engine total time */
- sprintf(time_to_txt, "%.2fms", engine_time / 1000000.0);
- draw_stat(&rect, 2, vsta, time_to_txt, sizeof(time_to_txt));
- v++;
- }
+/** \name View Update
+ * \{ */
- sprintf(pass_name, "Total GPU time %.2fms (%.1f fps)", tot_time / 1000000.0, 1000000000.0 / tot_time);
- draw_stat(&rect, 0, v++, pass_name, sizeof(pass_name));
- v++;
+void DRW_notify_view_update(const bContext *C)
+{
+ struct Depsgraph *graph = CTX_data_depsgraph(C);
+ ARegion *ar = CTX_wm_region(C);
+ View3D *v3d = CTX_wm_view3d(C);
+ RegionView3D *rv3d = ar->regiondata;
+ Scene *scene = DEG_get_evaluated_scene(graph);
+ SceneLayer *sl = DEG_get_evaluated_scene_layer(graph);
+
+ if (rv3d->viewport == NULL) {
+ return;
}
- /* Memory Stats */
- unsigned int tex_mem = GPU_texture_memory_usage_get();
- unsigned int vbo_mem = GWN_vertbuf_get_memory_usage();
- sprintf(pass_name, "GPU Memory");
- draw_stat(&rect, 0, v, pass_name, sizeof(pass_name));
- sprintf(pass_name, "%.2fMB", (float)(tex_mem + vbo_mem) / 1000000.0);
- draw_stat(&rect, 1, v++, pass_name, sizeof(pass_name));
- sprintf(pass_name, " |--> Textures");
- draw_stat(&rect, 0, v, pass_name, sizeof(pass_name));
- sprintf(pass_name, "%.2fMB", (float)tex_mem / 1000000.0);
- draw_stat(&rect, 1, v++, pass_name, sizeof(pass_name));
- sprintf(pass_name, " |--> Meshes");
- draw_stat(&rect, 0, v, pass_name, sizeof(pass_name));
- sprintf(pass_name, "%.2fMB", (float)vbo_mem / 1000000.0);
- draw_stat(&rect, 1, v++, pass_name, sizeof(pass_name));
+ /* Reset before using it. */
+ memset(&DST, 0x0, sizeof(DST));
+
+ DST.viewport = rv3d->viewport;
+ DST.draw_ctx = (DRWContextState){
+ ar, rv3d, v3d, scene, sl, OBACT_NEW(sl), C,
+ };
+
+ DRW_engines_enable(scene, sl);
+
+ for (LinkData *link = DST.enabled_engines.first; link; link = link->next) {
+ DrawEngineType *engine = link->data;
+ ViewportEngineData *data = DRW_viewport_engine_data_get(engine);
+
+ if (engine->view_update) {
+ engine->view_update(data);
+ }
+ }
+
+ DST.viewport = NULL;
+
+ DRW_engines_disable();
}
+/** \} */
/* -------------------------------------------------------------------- */
@@ -2950,8 +3214,8 @@ void DRW_draw_render_loop_ex(
ARegion *ar, View3D *v3d,
const bContext *evil_C)
{
- Scene *scene = DEG_get_scene(graph);
- SceneLayer *sl = DEG_get_scene_layer(graph);
+ Scene *scene = DEG_get_evaluated_scene(graph);
+ SceneLayer *sl = DEG_get_evaluated_scene_layer(graph);
RegionView3D *rv3d = ar->regiondata;
DST.draw_ctx.evil_C = evil_C;
@@ -2960,20 +3224,20 @@ void DRW_draw_render_loop_ex(
DST.viewport = rv3d->viewport;
v3d->zbuf = true;
- /* Get list of enabled engines */
- DRW_engines_enable(scene, sl, v3d);
-
/* Setup viewport */
cache_is_dirty = GPU_viewport_cache_validate(DST.viewport, DRW_engines_get_hash());
DST.draw_ctx = (DRWContextState){
- ar, rv3d, v3d, scene, sl, OBACT_NEW,
+ ar, rv3d, v3d, scene, sl, OBACT_NEW(sl),
/* reuse if caller sets */
DST.draw_ctx.evil_C,
};
DRW_viewport_var_init();
+ /* Get list of enabled engines */
+ DRW_engines_enable(scene, sl);
+
/* Update ubos */
DRW_globals_update();
@@ -2984,6 +3248,7 @@ void DRW_draw_render_loop_ex(
/* ideally only refresh when objects are added/removed */
/* or render properties / materials change */
if (cache_is_dirty) {
+ PROFILE_START(stime);
DRW_engines_cache_init();
DEG_OBJECT_ITER(graph, ob, DEG_OBJECT_ITER_FLAG_ALL);
@@ -2995,8 +3260,11 @@ void DRW_draw_render_loop_ex(
DEG_OBJECT_ITER_END
DRW_engines_cache_finish();
+ PROFILE_END_ACCUM(DST.cache_time, stime);
}
+ DRW_stats_begin();
+
/* Start Drawing */
DRW_state_reset();
DRW_engines_draw_background();
@@ -3026,6 +3294,8 @@ void DRW_draw_render_loop_ex(
DRW_draw_region_info();
}
+ DRW_stats_reset();
+
if (G.debug_value > 20) {
DRW_debug_cpu_stats();
DRW_debug_gpu_stats();
@@ -3089,8 +3359,8 @@ void DRW_draw_select_loop(
ARegion *ar, View3D *v3d,
bool UNUSED(use_obedit_skip), bool UNUSED(use_nearest), const rcti *rect)
{
- Scene *scene = DEG_get_scene(graph);
- SceneLayer *sl = DEG_get_scene_layer(graph);
+ Scene *scene = DEG_get_evaluated_scene(graph);
+ SceneLayer *sl = DEG_get_evaluated_scene_layer(graph);
#ifndef USE_GPU_SELECT
UNUSED_VARS(vc, scene, sl, v3d, ar, rect);
#else
@@ -3142,7 +3412,7 @@ void DRW_draw_select_loop(
/* Instead of 'DRW_context_state_init(C, &DST.draw_ctx)', assign from args */
DST.draw_ctx = (DRWContextState){
- ar, rv3d, v3d, scene, sl, OBACT_NEW, (bContext *)NULL,
+ ar, rv3d, v3d, scene, sl, OBACT_NEW(sl), (bContext *)NULL,
};
DRW_viewport_var_init();
@@ -3207,8 +3477,8 @@ void DRW_draw_depth_loop(
Depsgraph *graph,
ARegion *ar, View3D *v3d)
{
- Scene *scene = DEG_get_scene(graph);
- SceneLayer *sl = DEG_get_scene_layer(graph);
+ Scene *scene = DEG_get_evaluated_scene(graph);
+ SceneLayer *sl = DEG_get_evaluated_scene_layer(graph);
RegionView3D *rv3d = ar->regiondata;
/* backup (_never_ use rv3d->viewport) */
@@ -3238,7 +3508,7 @@ void DRW_draw_depth_loop(
/* Instead of 'DRW_context_state_init(C, &DST.draw_ctx)', assign from args */
DST.draw_ctx = (DRWContextState){
- ar, rv3d, v3d, scene, sl, OBACT_NEW, (bContext *)NULL,
+ ar, rv3d, v3d, scene, sl, OBACT_NEW(sl), (bContext *)NULL,
};
DRW_viewport_var_init();
@@ -3351,6 +3621,18 @@ bool DRW_state_show_text(void)
(DST.options.is_scene_render) == 0;
}
+/**
+ * Should draw support elements
+ * Objects center, selection outline, probe data, ...
+ */
+bool DRW_state_draw_support(void)
+{
+ View3D *v3d = DST.draw_ctx.v3d;
+ return (DRW_state_is_scene_render() == false) &&
+ (v3d != NULL) &&
+ ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0);
+}
+
/** \} */
@@ -3359,21 +3641,6 @@ bool DRW_state_show_text(void)
/** \name Context State (DRW_context_state)
* \{ */
-void DRW_context_state_init(const bContext *C, DRWContextState *r_draw_ctx)
-{
- r_draw_ctx->ar = CTX_wm_region(C);
- r_draw_ctx->rv3d = CTX_wm_region_view3d(C);
- r_draw_ctx->v3d = CTX_wm_view3d(C);
-
- r_draw_ctx->scene = CTX_data_scene(C);
- r_draw_ctx->sl = CTX_data_scene_layer(C);
- r_draw_ctx->obact = r_draw_ctx->sl->basact ? r_draw_ctx->sl->basact->object : NULL;
-
- /* grr, cant avoid! */
- r_draw_ctx->evil_C = C;
-}
-
-
const DRWContextState *DRW_context_state_get(void)
{
return &DST.draw_ctx;
@@ -3448,6 +3715,7 @@ extern struct GPUTexture *globals_ramp; /* draw_common.c */
void DRW_engines_free(void)
{
DRW_shape_cache_free();
+ DRW_stats_free();
DrawEngineType *next;
for (DrawEngineType *type = DRW_engines.first; type; type = next) {
@@ -3465,6 +3733,9 @@ void DRW_engines_free(void)
if (globals_ramp)
GPU_texture_free(globals_ramp);
+ MEM_SAFE_FREE(RST.bound_texs);
+ MEM_SAFE_FREE(RST.bound_tex_slots);
+
#ifdef WITH_CLAY_ENGINE
BLI_remlink(&R_engines, &DRW_engine_viewport_clay_type);
#endif
diff --git a/source/blender/draw/intern/draw_manager_profiling.c b/source/blender/draw/intern/draw_manager_profiling.c
new file mode 100644
index 00000000000..f9fbbac2e2e
--- /dev/null
+++ b/source/blender/draw/intern/draw_manager_profiling.c
@@ -0,0 +1,242 @@
+/*
+ * Copyright 2016, 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.
+ *
+ * Contributor(s): Blender Institute
+ *
+ */
+
+/** \file draw_manager_profiling.c
+ * \ingroup draw
+ */
+
+#include "BLI_rect.h"
+#include "BLI_string.h"
+
+#include "BKE_global.h"
+
+#include "BLF_api.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "GPU_glew.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "draw_manager_profiling.h"
+
+#define MAX_TIMER_NAME 32
+#define MAX_NESTED_TIMER 8
+#define CHUNK_SIZE 8
+#define GPU_TIMER_FALLOFF 0.1
+
+typedef struct DRWTimer {
+ GLuint query[2];
+ GLuint64 time_average;
+ char name[MAX_TIMER_NAME];
+ int lvl; /* Hierarchy level for nested timer. */
+ bool is_query; /* Does this timer actually perform queries or is it just a group. */
+} DRWTimer;
+
+static struct DRWTimerPool {
+ DRWTimer *timers;
+ int chunk_count; /* Number of chunk allocated. */
+ int timer_count; /* chunk_count * CHUNK_SIZE */
+ int timer_increment; /* Keep track of where we are in the stack. */
+ int end_increment; /* Keep track of bad usage. */
+ bool is_recording; /* Are we in the render loop? */
+ bool is_querying; /* Keep track of bad usage. */
+} DTP = {NULL};
+
+void DRW_stats_free(void)
+{
+ if (DTP.timers != NULL) {
+ for (int i = 0; i < DTP.timer_count; ++i) {
+ DRWTimer *timer = &DTP.timers[i];
+ glDeleteQueries(2, timer->query);
+ }
+ MEM_freeN(DTP.timers);
+ DTP.timers = NULL;
+ }
+}
+
+void DRW_stats_begin(void)
+{
+ if (G.debug_value > 20) {
+ DTP.is_recording = true;
+ }
+
+ if (DTP.is_recording && DTP.timers == NULL) {
+ DTP.chunk_count = 1;
+ DTP.timer_count = DTP.chunk_count * CHUNK_SIZE;
+ DTP.timers = MEM_callocN(sizeof(DRWTimer) * DTP.timer_count, "DRWTimer stack");
+ }
+ else if (!DTP.is_recording && DTP.timers != NULL) {
+ DRW_stats_free();
+ }
+
+ DTP.is_querying = false;
+ DTP.timer_increment = 0;
+ DTP.end_increment = 0;
+}
+
+static DRWTimer *drw_stats_timer_get(void)
+{
+ if (UNLIKELY(DTP.timer_increment >= DTP.timer_count)) {
+ /* Resize the stack. */
+ DTP.chunk_count++;
+ DTP.timer_count = DTP.chunk_count * CHUNK_SIZE;
+ DTP.timers = MEM_recallocN(DTP.timers, sizeof(DRWTimer) * DTP.timer_count);
+ }
+
+ return &DTP.timers[DTP.timer_increment++];
+}
+
+static void drw_stats_timer_start_ex(const char *name, const bool is_query)
+{
+ if (DTP.is_recording) {
+ DRWTimer *timer = drw_stats_timer_get();
+ BLI_strncpy(timer->name, name, MAX_TIMER_NAME);
+ timer->lvl = DTP.timer_increment - DTP.end_increment - 1;
+ timer->is_query = is_query;
+
+ /* Queries cannot be nested or interleaved. */
+ BLI_assert(!DTP.is_querying);
+ if (timer->is_query) {
+ if (timer->query[0] == 0) {
+ glGenQueries(1, timer->query);
+ }
+
+ /* Issue query for the next frame */
+ glBeginQuery(GL_TIME_ELAPSED, timer->query[0]);
+ DTP.is_querying = true;
+ }
+ }
+}
+
+/* Use this to group the queries. It does NOT keep track
+ * of the time, it only sum what the queries inside it. */
+void DRW_stats_group_start(const char *name)
+{
+ drw_stats_timer_start_ex(name, false);
+}
+
+void DRW_stats_group_end(void)
+{
+ if (DTP.is_recording) {
+ BLI_assert(!DTP.is_querying);
+ DTP.end_increment++;
+ }
+}
+
+/* NOTE: Only call this when no sub timer will be called. */
+void DRW_stats_query_start(const char *name)
+{
+ drw_stats_timer_start_ex(name, true);
+}
+
+void DRW_stats_query_end(void)
+{
+ if (DTP.is_recording) {
+ DTP.end_increment++;
+ BLI_assert(DTP.is_querying);
+ glEndQuery(GL_TIME_ELAPSED);
+ DTP.is_querying = false;
+ }
+}
+
+void DRW_stats_reset(void)
+{
+ BLI_assert((DTP.timer_increment - DTP.end_increment) <= 0 && "You forgot a DRW_stats_group/query_end somewhere!");
+ BLI_assert((DTP.timer_increment - DTP.end_increment) >= 0 && "You forgot a DRW_stats_group/query_start somewhere!");
+
+ if (DTP.is_recording) {
+ GLuint64 lvl_time[MAX_NESTED_TIMER] = {0};
+
+ /* Swap queries for the next frame and sum up each lvl time. */
+ for (int i = DTP.timer_increment - 1; i >= 0; --i) {
+ DRWTimer *timer = &DTP.timers[i];
+ SWAP(GLuint, timer->query[0], timer->query[1]);
+
+ BLI_assert(timer->lvl < MAX_NESTED_TIMER);
+
+ if (timer->is_query) {
+ GLuint64 time;
+ if (timer->query[0] != 0) {
+ glGetQueryObjectui64v(timer->query[0], GL_QUERY_RESULT, &time);
+ }
+ else {
+ time = 1000000000; /* 1ms default */
+ }
+
+ timer->time_average = timer->time_average * (1.0 - GPU_TIMER_FALLOFF) + time * GPU_TIMER_FALLOFF;
+ timer->time_average = MIN2(timer->time_average, 1000000000);
+ }
+ else {
+ timer->time_average = lvl_time[timer->lvl + 1];
+ lvl_time[timer->lvl + 1] = 0;
+ }
+
+ lvl_time[timer->lvl] += timer->time_average;
+ }
+
+ DTP.is_recording = false;
+ }
+}
+
+void DRW_stats_draw(rcti *rect)
+{
+ char stat_string[64];
+ int lvl_index[MAX_NESTED_TIMER];
+ int v = 0;
+
+ BLI_snprintf(stat_string, sizeof(stat_string), "GPU Render Stats");
+ BLF_draw_default_ascii(rect->xmin + 1 * U.widget_unit, rect->ymax - v++ * U.widget_unit, 0.0f, stat_string, sizeof(stat_string));
+
+ for (int i = 0; i < DTP.timer_increment; ++i) {
+ double time_ms, time_percent;
+ DRWTimer *timer = &DTP.timers[i];
+ DRWTimer *timer_parent = (timer->lvl > 0) ? &DTP.timers[lvl_index[timer->lvl - 1]] : NULL;
+
+ /* Only display a number of lvl at a time */
+ if ((G.debug_value - 21) < timer->lvl) continue;
+
+ BLI_assert(timer->lvl < MAX_NESTED_TIMER);
+ lvl_index[timer->lvl] = i;
+
+ time_ms = timer->time_average / 1000000.0;
+
+ if (timer_parent != NULL) {
+ time_percent = ((double)timer->time_average / (double)timer_parent->time_average) * 100.0;
+ }
+ else {
+ time_percent = 100.0;
+ }
+
+ /* avoid very long number */
+ time_ms = MIN2(time_ms, 999.0);
+ time_percent = MIN2(time_percent, 100.0);
+
+ BLI_snprintf(stat_string, sizeof(stat_string), "%s", timer->name);
+ BLF_draw_default_ascii(rect->xmin + (1 + timer->lvl) * U.widget_unit, rect->ymax - v * U.widget_unit, 0.0f, stat_string, sizeof(stat_string));
+ BLI_snprintf(stat_string, sizeof(stat_string), "%.2fms", time_ms);
+ BLF_draw_default_ascii(rect->xmin + (13 + timer->lvl) * U.widget_unit, rect->ymax - v * U.widget_unit, 0.0f, stat_string, sizeof(stat_string));
+ BLI_snprintf(stat_string, sizeof(stat_string), "%.0f", time_percent);
+ BLF_draw_default_ascii(rect->xmin + (17 + timer->lvl) * U.widget_unit, rect->ymax - v * U.widget_unit, 0.0f, stat_string, sizeof(stat_string));
+ v++;
+ }
+} \ No newline at end of file
diff --git a/source/blender/draw/intern/draw_manager_profiling.h b/source/blender/draw/intern/draw_manager_profiling.h
new file mode 100644
index 00000000000..233cd3878d2
--- /dev/null
+++ b/source/blender/draw/intern/draw_manager_profiling.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2016, 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.
+ *
+ * Contributor(s): Blender Institute
+ *
+ */
+
+/** \file draw_manager_profiling.h
+ * \ingroup draw
+ */
+
+#ifndef __DRAW_MANAGER_PROFILING_H__
+#define __DRAW_MANAGER_PROFILING_H__
+
+struct rcti;
+
+void DRW_stats_free(void);
+void DRW_stats_begin(void);
+void DRW_stats_reset(void);
+
+void DRW_stats_group_start(const char *name);
+void DRW_stats_group_end(void);
+
+void DRW_stats_query_start(const char *name);
+void DRW_stats_query_end(void);
+
+void DRW_stats_draw(rcti *rect);
+
+#endif /* __DRAW_MANAGER_PROFILING_H__ */
diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c
index 6d7fcc61702..ea1d93a6a85 100644
--- a/source/blender/draw/intern/draw_view.c
+++ b/source/blender/draw/intern/draw_view.c
@@ -613,7 +613,7 @@ void DRW_draw_background(void)
static bool is_cursor_visible(Scene *scene, SceneLayer *sl)
{
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
/* don't draw cursor in paint modes, but with a few exceptions */
if (ob && ob->mode & OB_MODE_ALL_PAINT) {
@@ -647,7 +647,7 @@ void DRW_draw_cursor(void)
View3D *v3d = draw_ctx->v3d;
RegionView3D *rv3d = draw_ctx->rv3d;
Scene *scene = draw_ctx->scene;
- SceneLayer *sl = draw_ctx->sl;
+ SceneLayer *sl = draw_ctx->scene_layer;
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glDepthMask(GL_FALSE);
@@ -680,7 +680,7 @@ void DRW_draw_cursor(void)
immAttrib3fv(wpos, co);
for (int i = 0; i < segments; ++i) {
- float angle = 2 * M_PI * ((float)i / (float)segments);
+ float angle = (float)(2 * M_PI) * ((float)i / (float)segments);
float x = f10 * cosf(angle);
float y = f10 * sinf(angle);
@@ -728,5 +728,29 @@ void DRW_draw_manipulator(void)
/* draw depth culled manipulators - manipulators need to be updated *after* view matrix was set up */
/* TODO depth culling manipulators is not yet supported, just drawing _3D here, should
* later become _IN_SCENE (and draw _3D separate) */
- WM_manipulatormap_draw(ar->manipulator_map, draw_ctx->evil_C, WM_MANIPULATORMAP_DRAWSTEP_3D);
+ WM_manipulatormap_draw(
+ ar->manipulator_map, draw_ctx->evil_C,
+ WM_MANIPULATORMAP_DRAWSTEP_3D);
+
+ /* We may want to split this into a separate pass.
+ * or maintain a stage in the draw manager where all pixel-space drawing happens. */
+ {
+ float original_proj[4][4];
+ gpuGetProjectionMatrix(original_proj);
+ wmOrtho2_region_pixelspace(ar);
+
+ gpuPushMatrix();
+ gpuLoadIdentity();
+
+ glDepthMask(GL_FALSE);
+
+ WM_manipulatormap_draw(
+ ar->manipulator_map, draw_ctx->evil_C,
+ WM_MANIPULATORMAP_DRAWSTEP_2D);
+
+ glDepthMask(GL_TRUE);
+
+ gpuPopMatrix();
+ gpuLoadProjectionMatrix(original_proj);
+ }
}
diff --git a/source/blender/draw/modes/edit_armature_mode.c b/source/blender/draw/modes/edit_armature_mode.c
index 3487ceba141..4deb4f86692 100644
--- a/source/blender/draw/modes/edit_armature_mode.c
+++ b/source/blender/draw/modes/edit_armature_mode.c
@@ -92,7 +92,9 @@ static void EDIT_ARMATURE_cache_init(void *vedata)
{
/* Non Meshes Pass (Camera, empties, lamps ...) */
- DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_BLEND | DRW_STATE_WIRE;
+ DRWState state =
+ DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS |
+ DRW_STATE_BLEND | DRW_STATE_WIRE;
psl->relationship = DRW_pass_create("Bone Relationship Pass", state);
/* Relationship Lines */
@@ -118,11 +120,16 @@ static void EDIT_ARMATURE_cache_populate(void *vedata, Object *ob)
static void EDIT_ARMATURE_draw_scene(void *vedata)
{
EDIT_ARMATURE_PassList *psl = ((EDIT_ARMATURE_Data *)vedata)->psl;
+ DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
+
+ MULTISAMPLE_SYNC_ENABLE(dfbl)
DRW_draw_pass(psl->bone_envelope);
DRW_draw_pass(psl->bone_solid);
DRW_draw_pass(psl->bone_wire);
DRW_draw_pass(psl->relationship);
+
+ MULTISAMPLE_SYNC_DISABLE(dfbl)
}
#if 0
@@ -145,5 +152,6 @@ DrawEngineType draw_engine_edit_armature_type = {
&EDIT_ARMATURE_cache_populate,
NULL,
NULL,
- &EDIT_ARMATURE_draw_scene
+ &EDIT_ARMATURE_draw_scene,
+ NULL,
};
diff --git a/source/blender/draw/modes/edit_curve_mode.c b/source/blender/draw/modes/edit_curve_mode.c
index dc81725d19a..1d542fc8e7e 100644
--- a/source/blender/draw/modes/edit_curve_mode.c
+++ b/source/blender/draw/modes/edit_curve_mode.c
@@ -264,7 +264,9 @@ static void EDIT_CURVE_draw_scene(void *vedata)
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
- UNUSED_VARS(fbl, dfbl, dtxl);
+ UNUSED_VARS(fbl, dtxl);
+
+ MULTISAMPLE_SYNC_ENABLE(dfbl)
/* Show / hide entire passes, swap framebuffers ... whatever you fancy */
/*
@@ -280,6 +282,8 @@ static void EDIT_CURVE_draw_scene(void *vedata)
DRW_draw_pass(psl->overlay_edge_pass);
DRW_draw_pass(psl->overlay_vert_pass);
+ MULTISAMPLE_SYNC_DISABLE(dfbl)
+
/* If you changed framebuffer, double check you rebind
* the default one with its textures attached before finishing */
}
@@ -325,5 +329,6 @@ DrawEngineType draw_engine_edit_curve_type = {
&EDIT_CURVE_cache_populate,
&EDIT_CURVE_cache_finish,
NULL, /* draw_background but not needed by mode engines */
- &EDIT_CURVE_draw_scene
+ &EDIT_CURVE_draw_scene,
+ NULL,
};
diff --git a/source/blender/draw/modes/edit_lattice_mode.c b/source/blender/draw/modes/edit_lattice_mode.c
index b3a20075f0e..675ea925a39 100644
--- a/source/blender/draw/modes/edit_lattice_mode.c
+++ b/source/blender/draw/modes/edit_lattice_mode.c
@@ -144,7 +144,7 @@ static void EDIT_LATTICE_engine_init(void *vedata)
*/
if (!e_data.wire_sh) {
- e_data.wire_sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
+ e_data.wire_sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_SMOOTH_COLOR);
}
if (!e_data.overlay_vert_sh) {
@@ -177,6 +177,8 @@ static void EDIT_LATTICE_cache_init(void *vedata)
"Lattice Verts",
DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_POINT);
stl->g_data->vert_shgrp = DRW_shgroup_create(e_data.overlay_vert_sh, psl->vert_pass);
+
+ DRW_shgroup_uniform_block(stl->g_data->vert_shgrp, "globalsBlock", globals_ubo);
}
}
@@ -196,7 +198,7 @@ static void EDIT_LATTICE_cache_populate(void *vedata, Object *ob)
/* Get geometry cache */
struct Gwn_Batch *geom;
- geom = DRW_cache_lattice_wire_get(ob);
+ geom = DRW_cache_lattice_wire_get(ob, true);
DRW_shgroup_call_add(stl->g_data->wire_shgrp, geom, ob->obmat);
geom = DRW_cache_lattice_vert_overlay_get(ob);
@@ -225,7 +227,9 @@ static void EDIT_LATTICE_draw_scene(void *vedata)
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
- UNUSED_VARS(fbl, dfbl, dtxl);
+ UNUSED_VARS(fbl, dtxl);
+
+ MULTISAMPLE_SYNC_ENABLE(dfbl)
/* Show / hide entire passes, swap framebuffers ... whatever you fancy */
/*
@@ -240,6 +244,8 @@ static void EDIT_LATTICE_draw_scene(void *vedata)
DRW_draw_pass(psl->wire_pass);
DRW_draw_pass(psl->vert_pass);
+ MULTISAMPLE_SYNC_DISABLE(dfbl)
+
/* If you changed framebuffer, double check you rebind
* the default one with its textures attached before finishing */
}
@@ -286,5 +292,6 @@ DrawEngineType draw_engine_edit_lattice_type = {
&EDIT_LATTICE_cache_populate,
&EDIT_LATTICE_cache_finish,
NULL, /* draw_background but not needed by mode engines */
- &EDIT_LATTICE_draw_scene
+ &EDIT_LATTICE_draw_scene,
+ NULL,
};
diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c
index c06a2976ac7..08310d75a57 100644
--- a/source/blender/draw/modes/edit_mesh_mode.c
+++ b/source/blender/draw/modes/edit_mesh_mode.c
@@ -152,14 +152,19 @@ static void EDIT_MESH_engine_init(void *vedata)
datatoc_edit_mesh_overlay_vert_glsl,
datatoc_edit_mesh_overlay_geom_tri_glsl,
datatoc_edit_mesh_overlay_frag_glsl,
- datatoc_common_globals_lib_glsl, "#define EDGE_FIX\n");
+ datatoc_common_globals_lib_glsl,
+ "#define EDGE_FIX\n"
+ "#define ANTI_ALIASING\n"
+ "#define VERTEX_FACING");
}
if (!e_data.overlay_tri_fast_sh) {
e_data.overlay_tri_fast_sh = DRW_shader_create_with_lib(
datatoc_edit_mesh_overlay_vert_glsl,
datatoc_edit_mesh_overlay_geom_tri_glsl,
datatoc_edit_mesh_overlay_frag_glsl,
- datatoc_common_globals_lib_glsl, NULL);
+ datatoc_common_globals_lib_glsl,
+ "#define ANTI_ALIASING\n"
+ "#define VERTEX_FACING\n");
}
if (!e_data.overlay_tri_vcol_sh) {
e_data.overlay_tri_vcol_sh = DRW_shader_create_with_lib(
@@ -168,7 +173,9 @@ static void EDIT_MESH_engine_init(void *vedata)
datatoc_edit_mesh_overlay_frag_glsl,
datatoc_common_globals_lib_glsl,
"#define EDGE_FIX\n"
- "#define VERTEX_SELECTION\n");
+ "#define VERTEX_SELECTION\n"
+ "#define ANTI_ALIASING\n"
+ "#define VERTEX_FACING\n");
}
if (!e_data.overlay_tri_vcol_fast_sh) {
e_data.overlay_tri_vcol_fast_sh = DRW_shader_create_with_lib(
@@ -176,14 +183,18 @@ static void EDIT_MESH_engine_init(void *vedata)
datatoc_edit_mesh_overlay_geom_tri_glsl,
datatoc_edit_mesh_overlay_frag_glsl,
datatoc_common_globals_lib_glsl,
- "#define VERTEX_SELECTION\n");
+ "#define VERTEX_SELECTION\n"
+ "#define ANTI_ALIASING\n"
+ "#define VERTEX_FACING\n");
}
if (!e_data.overlay_edge_sh) {
e_data.overlay_edge_sh = DRW_shader_create_with_lib(
datatoc_edit_mesh_overlay_vert_glsl,
datatoc_edit_mesh_overlay_geom_edge_glsl,
datatoc_edit_mesh_overlay_frag_glsl,
- datatoc_common_globals_lib_glsl, NULL);
+ datatoc_common_globals_lib_glsl,
+ "#define ANTI_ALIASING\n"
+ "#define VERTEX_FACING\n");
}
if (!e_data.overlay_edge_vcol_sh) {
e_data.overlay_edge_vcol_sh = DRW_shader_create_with_lib(
@@ -191,7 +202,8 @@ static void EDIT_MESH_engine_init(void *vedata)
datatoc_edit_mesh_overlay_geom_edge_glsl,
datatoc_edit_mesh_overlay_frag_glsl,
datatoc_common_globals_lib_glsl,
- "#define VERTEX_SELECTION\n");
+ "#define VERTEX_SELECTION\n"
+ "#define VERTEX_FACING\n");
}
if (!e_data.overlay_vert_sh) {
e_data.overlay_vert_sh = DRW_shader_create_with_lib(
@@ -204,7 +216,8 @@ static void EDIT_MESH_engine_init(void *vedata)
e_data.overlay_facedot_sh = DRW_shader_create_with_lib(
datatoc_edit_mesh_overlay_facedot_vert_glsl, NULL,
datatoc_edit_mesh_overlay_facedot_frag_glsl,
- datatoc_common_globals_lib_glsl, NULL);
+ datatoc_common_globals_lib_glsl,
+ "#define VERTEX_FACING\n");
}
if (!e_data.overlay_mix_sh) {
e_data.overlay_mix_sh = DRW_shader_create_fullscreen(datatoc_edit_mesh_overlay_mix_frag_glsl, NULL);
@@ -580,5 +593,6 @@ DrawEngineType draw_engine_edit_mesh_type = {
&EDIT_MESH_cache_populate,
NULL,
NULL,
- &EDIT_MESH_draw_scene
+ &EDIT_MESH_draw_scene,
+ NULL,
};
diff --git a/source/blender/draw/modes/edit_metaball_mode.c b/source/blender/draw/modes/edit_metaball_mode.c
index 4e9e1cb5b56..202e520193b 100644
--- a/source/blender/draw/modes/edit_metaball_mode.c
+++ b/source/blender/draw/modes/edit_metaball_mode.c
@@ -264,5 +264,6 @@ DrawEngineType draw_engine_edit_metaball_type = {
&EDIT_METABALL_cache_populate,
&EDIT_METABALL_cache_finish,
NULL, /* draw_background but not needed by mode engines */
- &EDIT_METABALL_draw_scene
+ &EDIT_METABALL_draw_scene,
+ NULL,
};
diff --git a/source/blender/draw/modes/edit_surface_mode.c b/source/blender/draw/modes/edit_surface_mode.c
index c8dbbd90754..e99973144aa 100644
--- a/source/blender/draw/modes/edit_surface_mode.c
+++ b/source/blender/draw/modes/edit_surface_mode.c
@@ -264,5 +264,6 @@ DrawEngineType draw_engine_edit_surface_type = {
&EDIT_SURFACE_cache_populate,
&EDIT_SURFACE_cache_finish,
NULL, /* draw_background but not needed by mode engines */
- &EDIT_SURFACE_draw_scene
+ &EDIT_SURFACE_draw_scene,
+ NULL,
};
diff --git a/source/blender/draw/modes/edit_text_mode.c b/source/blender/draw/modes/edit_text_mode.c
index 938ab2f3fbc..476a2ab9ac2 100644
--- a/source/blender/draw/modes/edit_text_mode.c
+++ b/source/blender/draw/modes/edit_text_mode.c
@@ -307,5 +307,6 @@ DrawEngineType draw_engine_edit_text_type = {
&EDIT_TEXT_cache_populate,
&EDIT_TEXT_cache_finish,
NULL, /* draw_background but not needed by mode engines */
- &EDIT_TEXT_draw_scene
+ &EDIT_TEXT_draw_scene,
+ NULL,
};
diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index f6220a70f9c..db0ac5a1d11 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -43,12 +43,12 @@
#include "BKE_camera.h"
#include "BKE_curve.h"
#include "BKE_global.h"
+#include "BKE_object.h"
#include "BKE_particle.h"
#include "BKE_image.h"
#include "BKE_texture.h"
#include "ED_view3d.h"
-#include "ED_view3d.h"
#include "GPU_shader.h"
#include "GPU_texture.h"
@@ -70,11 +70,15 @@ extern char datatoc_object_grid_frag_glsl[];
extern char datatoc_object_grid_vert_glsl[];
extern char datatoc_object_empty_image_frag_glsl[];
extern char datatoc_object_empty_image_vert_glsl[];
+extern char datatoc_object_lightprobe_grid_vert_glsl[];
extern char datatoc_object_particle_prim_vert_glsl[];
extern char datatoc_object_particle_prim_frag_glsl[];
extern char datatoc_object_particle_dot_vert_glsl[];
extern char datatoc_object_particle_dot_frag_glsl[];
extern char datatoc_common_globals_lib_glsl[];
+extern char datatoc_common_fxaa_lib_glsl[];
+extern char datatoc_gpu_shader_fullscreen_vert_glsl[];
+extern char datatoc_gpu_shader_uniform_color_frag_glsl[];
/* *********** LISTS *********** */
typedef struct OBJECT_PassList {
@@ -83,17 +87,14 @@ typedef struct OBJECT_PassList {
struct DRWPass *outlines;
struct DRWPass *outlines_search;
struct DRWPass *outlines_expand;
- struct DRWPass *outlines_fade1;
- struct DRWPass *outlines_fade2;
- struct DRWPass *outlines_fade3;
- struct DRWPass *outlines_fade4;
- struct DRWPass *outlines_fade5;
+ struct DRWPass *outlines_bleed;
struct DRWPass *outlines_resolve;
struct DRWPass *grid;
struct DRWPass *bone_solid;
struct DRWPass *bone_wire;
struct DRWPass *bone_envelope;
struct DRWPass *particle;
+ struct DRWPass *lightprobes;
/* use for empty/background images */
struct DRWPass *reference_image;
} OBJECT_PassList;
@@ -117,7 +118,7 @@ typedef struct OBJECT_Data {
/* *********** STATIC *********** */
-typedef struct OBJECT_PrivateData{
+typedef struct OBJECT_PrivateData {
/* Empties */
DRWShadingGroup *plain_axes;
DRWShadingGroup *cube;
@@ -143,8 +144,10 @@ typedef struct OBJECT_PrivateData{
/* Speaker */
DRWShadingGroup *speaker;
- /* Speaker */
- DRWShadingGroup *probe;
+ /* Probe */
+ DRWShadingGroup *probe_cube;
+ DRWShadingGroup *probe_planar;
+ DRWShadingGroup *probe_grid;
/* Lamps */
DRWShadingGroup *lamp_center;
@@ -190,6 +193,10 @@ typedef struct OBJECT_PrivateData{
DRWShadingGroup *outlines_select_group;
DRWShadingGroup *outlines_transform;
+ /* Lightprobes */
+ DRWShadingGroup *lightprobes_cube;
+ DRWShadingGroup *lightprobes_planar;
+
/* Wire */
DRWShadingGroup *wire;
DRWShadingGroup *wire_active;
@@ -202,6 +209,7 @@ typedef struct OBJECT_PrivateData{
static struct {
/* fullscreen shaders */
GPUShader *outline_resolve_sh;
+ GPUShader *outline_resolve_aa_sh;
GPUShader *outline_detect_sh;
GPUShader *outline_fade_sh;
@@ -212,6 +220,7 @@ static struct {
GPUShader *part_dot_sh;
GPUShader *part_prim_sh;
GPUShader *part_axis_sh;
+ GPUShader *lightprobe_grid_sh;
float camera_pos[3];
float screenvecs[3][4];
float grid_settings[5];
@@ -223,6 +232,7 @@ static struct {
int zneg_flag;
float zplane_normal[3];
float zplane_axes[3];
+ float inv_viewport_size[2];
bool draw_grid;
/* Temp buffer textures */
struct GPUTexture *outlines_depth_tx;
@@ -273,6 +283,15 @@ static void OBJECT_engine_init(void *vedata)
e_data.outline_resolve_sh = DRW_shader_create_fullscreen(datatoc_object_outline_resolve_frag_glsl, NULL);
}
+ if (!e_data.outline_resolve_aa_sh) {
+ e_data.outline_resolve_aa_sh = DRW_shader_create_with_lib(
+ datatoc_gpu_shader_fullscreen_vert_glsl, NULL,
+ datatoc_object_outline_resolve_frag_glsl,
+ datatoc_common_fxaa_lib_glsl,
+ "#define FXAA_ALPHA\n"
+ "#define USE_FXAA\n");
+ }
+
if (!e_data.outline_detect_sh) {
e_data.outline_detect_sh = DRW_shader_create_fullscreen(datatoc_object_outline_detect_frag_glsl, NULL);
}
@@ -304,15 +323,24 @@ static void OBJECT_engine_init(void *vedata)
}
if (!e_data.part_prim_sh) {
- e_data.part_prim_sh = DRW_shader_create(datatoc_object_particle_prim_vert_glsl, NULL, datatoc_object_particle_prim_frag_glsl, NULL);
+ e_data.part_prim_sh = DRW_shader_create(
+ datatoc_object_particle_prim_vert_glsl, NULL, datatoc_object_particle_prim_frag_glsl, NULL);
}
if (!e_data.part_axis_sh) {
- e_data.part_axis_sh = DRW_shader_create(datatoc_object_particle_prim_vert_glsl, NULL, datatoc_object_particle_prim_frag_glsl, "#define USE_AXIS\n");
+ e_data.part_axis_sh = DRW_shader_create(
+ datatoc_object_particle_prim_vert_glsl, NULL, datatoc_object_particle_prim_frag_glsl,
+ "#define USE_AXIS\n");
}
if (!e_data.part_dot_sh) {
- e_data.part_dot_sh = DRW_shader_create(datatoc_object_particle_dot_vert_glsl, NULL, datatoc_object_particle_dot_frag_glsl, NULL);
+ e_data.part_dot_sh = DRW_shader_create(
+ datatoc_object_particle_dot_vert_glsl, NULL, datatoc_object_particle_dot_frag_glsl, NULL);
+ }
+
+ if (!e_data.lightprobe_grid_sh) {
+ e_data.lightprobe_grid_sh = DRW_shader_create(
+ datatoc_object_lightprobe_grid_vert_glsl, NULL, datatoc_gpu_shader_uniform_color_frag_glsl, NULL);
}
{
@@ -458,7 +486,8 @@ static void OBJECT_engine_init(void *vedata)
/* Persp : If camera is below floor plane, we switch clipping
* Ortho : If eye vector is looking up, we switch clipping */
if (((winmat[3][3] == 0.0f) && (e_data.camera_pos[2] > 0.0f)) ||
- ((winmat[3][3] != 0.0f) && (zvec[2] < 0.0f))) {
+ ((winmat[3][3] != 0.0f) && (zvec[2] < 0.0f)))
+ {
e_data.zpos_flag |= CLIP_ZPOS;
e_data.zneg_flag |= CLIP_ZNEG;
}
@@ -490,13 +519,17 @@ static void OBJECT_engine_init(void *vedata)
e_data.grid_settings[1] = grid_res; /* gridResolution */
e_data.grid_settings[2] = grid_scale; /* gridScale */
e_data.grid_settings[3] = v3d->gridsubdiv; /* gridSubdiv */
- e_data.grid_settings[4] = (v3d->gridsubdiv > 1) ? 1.0f / log(v3d->gridsubdiv) : 0.0; /* 1/log(gridSubdiv) */
+ e_data.grid_settings[4] = (v3d->gridsubdiv > 1) ? 1.0f / logf(v3d->gridsubdiv) : 0.0f; /* 1/log(gridSubdiv) */
}
+
+ copy_v2_v2(e_data.inv_viewport_size, DRW_viewport_size_get());
+ invert_v2(e_data.inv_viewport_size);
}
static void OBJECT_engine_free(void)
{
DRW_SHADER_FREE_SAFE(e_data.outline_resolve_sh);
+ DRW_SHADER_FREE_SAFE(e_data.outline_resolve_aa_sh);
DRW_SHADER_FREE_SAFE(e_data.outline_detect_sh);
DRW_SHADER_FREE_SAFE(e_data.outline_fade_sh);
DRW_SHADER_FREE_SAFE(e_data.object_empty_image_sh);
@@ -505,6 +538,7 @@ static void OBJECT_engine_free(void)
DRW_SHADER_FREE_SAFE(e_data.part_prim_sh);
DRW_SHADER_FREE_SAFE(e_data.part_axis_sh);
DRW_SHADER_FREE_SAFE(e_data.part_dot_sh);
+ DRW_SHADER_FREE_SAFE(e_data.lightprobe_grid_sh);
}
static DRWShadingGroup *shgroup_outline(DRWPass *pass, const float col[4], GPUShader *sh)
@@ -690,7 +724,7 @@ static void OBJECT_cache_init(void *vedata)
{
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_WIRE;
- psl->outlines = DRW_pass_create("Outlines Pass", state);
+ psl->outlines = DRW_pass_create("Outlines Depth Pass", state);
GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
@@ -707,19 +741,24 @@ static void OBJECT_cache_init(void *vedata)
}
{
+ DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS;
+ psl->lightprobes = DRW_pass_create("Object Probe Pass", state);
+
+ /* Cubemap */
+ stl->g_data->lightprobes_cube = shgroup_instance(psl->lightprobes, DRW_cache_sphere_get());
+
+ /* Planar */
+ stl->g_data->lightprobes_planar = shgroup_instance(psl->lightprobes, DRW_cache_quad_get());
+ }
+
+ {
DRWState state = DRW_STATE_WRITE_COLOR;
struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get();
static float alphaOcclu = 0.35f;
- static float one = 1.0f;
- static float alpha1 = 5.0f / 6.0f;
- static float alpha2 = 4.0f / 5.0f;
- static float alpha3 = 3.0f / 4.0f;
- static float alpha4 = 2.0f / 3.0f;
- static float alpha5 = 1.0f / 2.0f;
static bool bTrue = true;
static bool bFalse = false;
- psl->outlines_search = DRW_pass_create("Outlines Expand Pass", state);
+ psl->outlines_search = DRW_pass_create("Outlines Detect Pass", state);
DRWShadingGroup *grp = DRW_shgroup_create(e_data.outline_detect_sh, psl->outlines_search);
DRW_shgroup_uniform_buffer(grp, "outlineColor", &e_data.outlines_color_tx);
@@ -732,53 +771,13 @@ static void OBJECT_cache_init(void *vedata)
grp = DRW_shgroup_create(e_data.outline_fade_sh, psl->outlines_expand);
DRW_shgroup_uniform_buffer(grp, "outlineColor", &e_data.outlines_blur_tx);
- DRW_shgroup_uniform_buffer(grp, "outlineDepth", &e_data.outlines_depth_tx);
- DRW_shgroup_uniform_float(grp, "alpha", &one, 1);
DRW_shgroup_uniform_bool(grp, "doExpand", &bTrue, 1);
DRW_shgroup_call_add(grp, quad, NULL);
- psl->outlines_fade1 = DRW_pass_create("Outlines Fade 1 Pass", state);
+ psl->outlines_bleed = DRW_pass_create("Outlines Bleed Pass", state);
- grp = DRW_shgroup_create(e_data.outline_fade_sh, psl->outlines_fade1);
+ grp = DRW_shgroup_create(e_data.outline_fade_sh, psl->outlines_bleed);
DRW_shgroup_uniform_buffer(grp, "outlineColor", &e_data.outlines_color_tx);
- DRW_shgroup_uniform_buffer(grp, "outlineDepth", &e_data.outlines_depth_tx);
- DRW_shgroup_uniform_float(grp, "alpha", &alpha1, 1);
- DRW_shgroup_uniform_bool(grp, "doExpand", &bFalse, 1);
- DRW_shgroup_call_add(grp, quad, NULL);
-
- psl->outlines_fade2 = DRW_pass_create("Outlines Fade 2 Pass", state);
-
- grp = DRW_shgroup_create(e_data.outline_fade_sh, psl->outlines_fade2);
- DRW_shgroup_uniform_buffer(grp, "outlineColor", &e_data.outlines_blur_tx);
- DRW_shgroup_uniform_buffer(grp, "outlineDepth", &e_data.outlines_depth_tx);
- DRW_shgroup_uniform_float(grp, "alpha", &alpha2, 1);
- DRW_shgroup_uniform_bool(grp, "doExpand", &bFalse, 1);
- DRW_shgroup_call_add(grp, quad, NULL);
-
- psl->outlines_fade3 = DRW_pass_create("Outlines Fade 3 Pass", state);
-
- grp = DRW_shgroup_create(e_data.outline_fade_sh, psl->outlines_fade3);
- DRW_shgroup_uniform_buffer(grp, "outlineColor", &e_data.outlines_color_tx);
- DRW_shgroup_uniform_buffer(grp, "outlineDepth", &e_data.outlines_depth_tx);
- DRW_shgroup_uniform_float(grp, "alpha", &alpha3, 1);
- DRW_shgroup_uniform_bool(grp, "doExpand", &bFalse, 1);
- DRW_shgroup_call_add(grp, quad, NULL);
-
- psl->outlines_fade4 = DRW_pass_create("Outlines Fade 4 Pass", state);
-
- grp = DRW_shgroup_create(e_data.outline_fade_sh, psl->outlines_fade4);
- DRW_shgroup_uniform_buffer(grp, "outlineColor", &e_data.outlines_blur_tx);
- DRW_shgroup_uniform_buffer(grp, "outlineDepth", &e_data.outlines_depth_tx);
- DRW_shgroup_uniform_float(grp, "alpha", &alpha4, 1);
- DRW_shgroup_uniform_bool(grp, "doExpand", &bFalse, 1);
- DRW_shgroup_call_add(grp, quad, NULL);
-
- psl->outlines_fade5 = DRW_pass_create("Outlines Fade 5 Pass", state);
-
- grp = DRW_shgroup_create(e_data.outline_fade_sh, psl->outlines_fade5);
- DRW_shgroup_uniform_buffer(grp, "outlineColor", &e_data.outlines_color_tx);
- DRW_shgroup_uniform_buffer(grp, "outlineDepth", &e_data.outlines_depth_tx);
- DRW_shgroup_uniform_float(grp, "alpha", &alpha5, 1);
DRW_shgroup_uniform_bool(grp, "doExpand", &bFalse, 1);
DRW_shgroup_call_add(grp, quad, NULL);
}
@@ -789,8 +788,9 @@ static void OBJECT_cache_init(void *vedata)
struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get();
- DRWShadingGroup *grp = DRW_shgroup_create(e_data.outline_resolve_sh, psl->outlines_resolve);
+ DRWShadingGroup *grp = DRW_shgroup_create(e_data.outline_resolve_aa_sh, psl->outlines_resolve);
DRW_shgroup_uniform_buffer(grp, "outlineBluredColor", &e_data.outlines_blur_tx);
+ DRW_shgroup_uniform_vec2(grp, "rcpDimensions", e_data.inv_viewport_size, 1);
DRW_shgroup_call_add(grp, quad, NULL);
}
@@ -821,12 +821,14 @@ static void OBJECT_cache_init(void *vedata)
DRW_shgroup_uniform_int(grp, "gridFlag", &e_data.grid_flag, 1);
DRW_shgroup_uniform_vec3(grp, "planeNormal", e_data.grid_normal, 1);
DRW_shgroup_uniform_vec3(grp, "planeAxes", e_data.grid_axes, 1);
+ DRW_shgroup_uniform_block(grp, "globalsBlock", globals_ubo);
DRW_shgroup_call_add(grp, quad, mat);
grp = DRW_shgroup_create(e_data.grid_sh, psl->grid);
DRW_shgroup_uniform_int(grp, "gridFlag", &e_data.zpos_flag, 1);
DRW_shgroup_uniform_vec3(grp, "planeNormal", e_data.zplane_normal, 1);
DRW_shgroup_uniform_vec3(grp, "planeAxes", e_data.zplane_axes, 1);
+ DRW_shgroup_uniform_block(grp, "globalsBlock", globals_ubo);
DRW_shgroup_call_add(grp, quad, mat);
}
@@ -907,9 +909,16 @@ static void OBJECT_cache_init(void *vedata)
stl->g_data->speaker = shgroup_instance(psl->non_meshes, geom);
/* Probe */
- static float probeSize = 10.0f;
- geom = DRW_cache_lightprobe_get();
- stl->g_data->probe = shgroup_instance_screenspace(psl->non_meshes, geom, &probeSize);
+ static float probeSize = 14.0f;
+ geom = DRW_cache_lightprobe_cube_get();
+ stl->g_data->probe_cube = shgroup_instance_screenspace(psl->non_meshes, geom, &probeSize);
+
+ geom = DRW_cache_lightprobe_grid_get();
+ stl->g_data->probe_grid = shgroup_instance_screenspace(psl->non_meshes, geom, &probeSize);
+
+ static float probePlanarSize = 20.0f;
+ geom = DRW_cache_lightprobe_planar_get();
+ stl->g_data->probe_planar = shgroup_instance_screenspace(psl->non_meshes, geom, &probePlanarSize);
/* Camera */
geom = DRW_cache_camera_get();
@@ -1063,7 +1072,10 @@ static void OBJECT_cache_init(void *vedata)
{
/* Particle Pass */
- psl->particle = DRW_pass_create("Particle Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_POINT | DRW_STATE_BLEND);
+ psl->particle = DRW_pass_create(
+ "Particle Pass",
+ DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS |
+ DRW_STATE_POINT | DRW_STATE_BLEND);
}
{
@@ -1131,7 +1143,7 @@ static void DRW_shgroup_lamp(OBJECT_StorageList *stl, Object *ob, SceneLayer *sl
size[0] = size[1] = blend; size[2] = 1.0f;
size_to_mat4(sizemat, size);
translate_m4(sizemat, 0.0f, 0.0f, -1.0f);
- rotate_m4(sizemat, 'X', M_PI / 2.0f);
+ rotate_m4(sizemat, 'X', (float)(M_PI / 2));
mul_m4_m4m4(spotblendmat, shapemat, sizemat);
if (la->mode & LA_SQUARE) {
@@ -1408,31 +1420,117 @@ static void DRW_shgroup_speaker(OBJECT_StorageList *stl, Object *ob, SceneLayer
DRW_shgroup_call_dynamic_add(stl->g_data->speaker, color, &one, ob->obmat);
}
-static void DRW_shgroup_lightprobe(OBJECT_StorageList *stl, Object *ob, SceneLayer *sl)
+typedef struct OBJECT_LightProbeEngineData {
+ float prb_mats[6][4][4];
+ float probe_cube_mat[4][4];
+ float draw_size;
+ float increment_x[3];
+ float increment_y[3];
+ float increment_z[3];
+ float corner[3];
+} OBJECT_LightProbeEngineData;
+
+static void DRW_shgroup_lightprobe(OBJECT_StorageList *stl, OBJECT_PassList *psl, Object *ob, SceneLayer *sl)
{
float *color;
static float one = 1.0f;
LightProbe *prb = (LightProbe *)ob->data;
+ bool do_outlines = ((ob->base_flag & BASE_SELECTED) != 0);
DRW_object_wire_theme_get(ob, sl, &color);
- DRW_shgroup_call_dynamic_add(stl->g_data->probe, ob->obmat[3], color);
+ OBJECT_LightProbeEngineData *prb_data;
+ OBJECT_LightProbeEngineData **prb_data_pt = (OBJECT_LightProbeEngineData **)DRW_object_engine_data_get(ob, &draw_engine_object_type, NULL);
+ if (*prb_data_pt == NULL) {
+ *prb_data_pt = MEM_mallocN(sizeof(OBJECT_LightProbeEngineData), "Probe Clip distances Matrices");
+ }
- float **prb_mats = (float **)DRW_object_engine_data_get(ob, &draw_engine_object_type, NULL);
- if (*prb_mats == NULL) {
- /* we need 6 matrices */
- *prb_mats = MEM_mallocN(sizeof(float) * 16 * 6, "Probe Clip distances Matrices");
+ prb_data = *prb_data_pt;
+
+ if ((DRW_state_is_select() || do_outlines) && ((prb->flag & LIGHTPROBE_FLAG_SHOW_DATA) != 0)) {
+
+ if (prb->type == LIGHTPROBE_TYPE_GRID) {
+ /* Update transforms */
+ float cell_dim[3], half_cell_dim[3];
+ cell_dim[0] = 2.0f / (float)(prb->grid_resolution_x);
+ cell_dim[1] = 2.0f / (float)(prb->grid_resolution_y);
+ cell_dim[2] = 2.0f / (float)(prb->grid_resolution_z);
+
+ mul_v3_v3fl(half_cell_dim, cell_dim, 0.5f);
+
+ /* First cell. */
+ copy_v3_fl(prb_data->corner, -1.0f);
+ add_v3_v3(prb_data->corner, half_cell_dim);
+ mul_m4_v3(ob->obmat, prb_data->corner);
+
+ /* Opposite neighbor cell. */
+ copy_v3_fl3(prb_data->increment_x, cell_dim[0], 0.0f, 0.0f);
+ add_v3_v3(prb_data->increment_x, half_cell_dim);
+ add_v3_fl(prb_data->increment_x, -1.0f);
+ mul_m4_v3(ob->obmat, prb_data->increment_x);
+ sub_v3_v3(prb_data->increment_x, prb_data->corner);
+
+ copy_v3_fl3(prb_data->increment_y, 0.0f, cell_dim[1], 0.0f);
+ add_v3_v3(prb_data->increment_y, half_cell_dim);
+ add_v3_fl(prb_data->increment_y, -1.0f);
+ mul_m4_v3(ob->obmat, prb_data->increment_y);
+ sub_v3_v3(prb_data->increment_y, prb_data->corner);
+
+ copy_v3_fl3(prb_data->increment_z, 0.0f, 0.0f, cell_dim[2]);
+ add_v3_v3(prb_data->increment_z, half_cell_dim);
+ add_v3_fl(prb_data->increment_z, -1.0f);
+ mul_m4_v3(ob->obmat, prb_data->increment_z);
+ sub_v3_v3(prb_data->increment_z, prb_data->corner);
+
+ DRWShadingGroup *grp = DRW_shgroup_instance_create(e_data.lightprobe_grid_sh, psl->lightprobes, DRW_cache_sphere_get());
+ /* Dummy call just to save select ID */
+ DRW_shgroup_call_dynamic_add_empty(grp);
+ /* Then overide the instance count */
+ DRW_shgroup_set_instance_count(grp, prb->grid_resolution_x * prb->grid_resolution_y * prb->grid_resolution_z);
+ DRW_shgroup_uniform_vec4(grp, "color", color, 1);
+ DRW_shgroup_uniform_vec3(grp, "corner", prb_data->corner, 1);
+ DRW_shgroup_uniform_vec3(grp, "increment_x", prb_data->increment_x, 1);
+ DRW_shgroup_uniform_vec3(grp, "increment_y", prb_data->increment_y, 1);
+ DRW_shgroup_uniform_vec3(grp, "increment_z", prb_data->increment_z, 1);
+ DRW_shgroup_uniform_ivec3(grp, "grid_resolution", &prb->grid_resolution_x, 1);
+ DRW_shgroup_uniform_float(grp, "sphere_size", &prb->data_draw_size, 1);
+ }
+ else if (prb->type == LIGHTPROBE_TYPE_CUBE) {
+ prb_data->draw_size = prb->data_draw_size * 0.1f;
+ unit_m4(prb_data->probe_cube_mat);
+ copy_v3_v3(prb_data->probe_cube_mat[3], ob->obmat[3]);
+ DRW_shgroup_call_dynamic_add(stl->g_data->lightprobes_cube, color, &prb_data->draw_size, prb_data->probe_cube_mat);
+ }
+ else {
+ prb_data->draw_size = 1.0f;
+ DRW_shgroup_call_dynamic_add(stl->g_data->lightprobes_planar, color, &prb_data->draw_size, ob->obmat);
+ }
}
+ switch (prb->type) {
+ case LIGHTPROBE_TYPE_PLANAR:
+ DRW_shgroup_call_dynamic_add(stl->g_data->probe_planar, ob->obmat[3], color);
+ break;
+ case LIGHTPROBE_TYPE_GRID:
+ DRW_shgroup_call_dynamic_add(stl->g_data->probe_grid, ob->obmat[3], color);
+ break;
+ case LIGHTPROBE_TYPE_CUBE:
+ default:
+ DRW_shgroup_call_dynamic_add(stl->g_data->probe_cube, ob->obmat[3], color);
+ break;
+ }
+
+
+
if (prb->type == LIGHTPROBE_TYPE_PLANAR) {
float (*mat)[4];
- mat = (float (*)[4])(*prb_mats);
+ mat = (float (*)[4])(prb_data->prb_mats[0]);
copy_m4_m4(mat, ob->obmat);
normalize_m4(mat);
DRW_shgroup_call_dynamic_add(stl->g_data->single_arrow, color, &ob->empty_drawsize, mat);
DRW_shgroup_call_dynamic_add(stl->g_data->single_arrow_line, color, &ob->empty_drawsize, mat);
- mat = (float (*)[4])(*prb_mats + 16);
+ mat = (float (*)[4])(prb_data->prb_mats[1]);
copy_m4_m4(mat, ob->obmat);
zero_v3(mat[2]);
@@ -1450,21 +1548,21 @@ static void DRW_shgroup_lightprobe(OBJECT_StorageList *stl, Object *ob, SceneLay
}
if (prb->type == LIGHTPROBE_TYPE_GRID ||
- prb->attenuation_type == LIGHTPROBE_SHAPE_BOX)
+ prb->attenuation_type == LIGHTPROBE_SHAPE_BOX)
{
DRW_shgroup_call_dynamic_add(stl->g_data->cube, color, &prb->distgridinf, ob->obmat);
DRW_shgroup_call_dynamic_add(stl->g_data->cube, color, &prb->distfalloff, ob->obmat);
}
else if (prb->type == LIGHTPROBE_TYPE_PLANAR) {
float (*rangemat)[4];
- rangemat = (float (*)[4])(*prb_mats + 32);
+ rangemat = (float (*)[4])(prb_data->prb_mats[2]);
copy_m4_m4(rangemat, ob->obmat);
normalize_v3(rangemat[2]);
mul_v3_fl(rangemat[2], prb->distinf);
DRW_shgroup_call_dynamic_add(stl->g_data->cube, color, &one, rangemat);
- rangemat = (float (*)[4])(*prb_mats + 64);
+ rangemat = (float (*)[4])(prb_data->prb_mats[3]);
copy_m4_m4(rangemat, ob->obmat);
normalize_v3(rangemat[2]);
mul_v3_fl(rangemat[2], prb->distfalloff);
@@ -1492,10 +1590,10 @@ static void DRW_shgroup_lightprobe(OBJECT_StorageList *stl, Object *ob, SceneLay
}
if (prb->parallax_type == LIGHTPROBE_SHAPE_BOX) {
- DRW_shgroup_call_dynamic_add(stl->g_data->cube, color, &dist, obmat);
+ DRW_shgroup_call_dynamic_add(stl->g_data->cube, color, dist, obmat);
}
else {
- DRW_shgroup_call_dynamic_add(stl->g_data->sphere, color, &dist, obmat);
+ DRW_shgroup_call_dynamic_add(stl->g_data->sphere, color, dist, obmat);
}
}
}
@@ -1513,7 +1611,7 @@ static void DRW_shgroup_lightprobe(OBJECT_StorageList *stl, Object *ob, SceneLay
for (int i = 0; i < 6; ++i) {
float (*clipmat)[4];
- clipmat = (float (*)[4])(*prb_mats + 16 * i);
+ clipmat = (float (*)[4])(prb_data->prb_mats[i]);
normalize_m4_m4(clipmat, ob->obmat);
mul_m4_m4m4(clipmat, clipmat, cubefacemat[i]);
@@ -1523,7 +1621,6 @@ static void DRW_shgroup_lightprobe(OBJECT_StorageList *stl, Object *ob, SceneLay
}
}
}
- DRW_shgroup_call_dynamic_add(stl->g_data->lamp_center_group, ob->obmat[3]);
/* Line and point going to the ground */
if (prb->type == LIGHTPROBE_TYPE_CUBE) {
@@ -1534,7 +1631,7 @@ static void DRW_shgroup_lightprobe(OBJECT_StorageList *stl, Object *ob, SceneLay
static void DRW_shgroup_relationship_lines(OBJECT_StorageList *stl, Object *ob)
{
- if (ob->parent && ((ob->parent->base_flag & BASE_VISIBLED) != 0)) {
+ if (ob->parent && BKE_object_is_visible(ob->parent)) {
DRW_shgroup_call_dynamic_add(stl->g_data->relationship_lines, ob->obmat[3]);
DRW_shgroup_call_dynamic_add(stl->g_data->relationship_lines, ob->parent->obmat[3]);
}
@@ -1545,7 +1642,7 @@ static void DRW_shgroup_object_center(OBJECT_StorageList *stl, Object *ob, Scene
const bool is_library = ob->id.us > 1 || ID_IS_LINKED_DATABLOCK(ob);
DRWShadingGroup *shgroup;
- if (ob == OBACT_NEW) {
+ if (ob == OBACT_NEW(sl)) {
shgroup = stl->g_data->center_active;
}
else if (ob->base_flag & BASE_SELECTED) {
@@ -1606,19 +1703,22 @@ static void OBJECT_cache_populate_particles(Object *ob,
DRW_shgroup_call_add(shgrp, geom, mat);
break;
case PART_DRAW_CROSS:
- shgrp = DRW_shgroup_instance_create(e_data.part_prim_sh, psl->particle, DRW_cache_particles_get_prim(PART_DRAW_CROSS));
+ shgrp = DRW_shgroup_instance_create(
+ e_data.part_prim_sh, psl->particle, DRW_cache_particles_get_prim(PART_DRAW_CROSS));
DRW_shgroup_uniform_texture(shgrp, "ramp", globals_ramp);
DRW_shgroup_uniform_vec3(shgrp, "color", ma ? &ma->r : def_prim_col, 1);
DRW_shgroup_uniform_int(shgrp, "screen_space", &screen_space[0], 1);
break;
case PART_DRAW_CIRC:
- shgrp = DRW_shgroup_instance_create(e_data.part_prim_sh, psl->particle, DRW_cache_particles_get_prim(PART_DRAW_CIRC));
+ shgrp = DRW_shgroup_instance_create(
+ e_data.part_prim_sh, psl->particle, DRW_cache_particles_get_prim(PART_DRAW_CIRC));
DRW_shgroup_uniform_texture(shgrp, "ramp", globals_ramp);
DRW_shgroup_uniform_vec3(shgrp, "color", ma ? &ma->r : def_prim_col, 1);
DRW_shgroup_uniform_int(shgrp, "screen_space", &screen_space[1], 1);
break;
case PART_DRAW_AXIS:
- shgrp = DRW_shgroup_instance_create(e_data.part_axis_sh, psl->particle, DRW_cache_particles_get_prim(PART_DRAW_AXIS));
+ shgrp = DRW_shgroup_instance_create(
+ e_data.part_axis_sh, psl->particle, DRW_cache_particles_get_prim(PART_DRAW_AXIS));
DRW_shgroup_uniform_int(shgrp, "screen_space", &screen_space[0], 1);
break;
default:
@@ -1642,10 +1742,14 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
OBJECT_StorageList *stl = ((OBJECT_Data *)vedata)->stl;
const DRWContextState *draw_ctx = DRW_context_state_get();
Scene *scene = draw_ctx->scene;
- SceneLayer *sl = draw_ctx->sl;
+ SceneLayer *sl = draw_ctx->scene_layer;
View3D *v3d = draw_ctx->v3d;
int theme_id = TH_UNDEFINED;
+ if (!BKE_object_is_visible(ob)) {
+ return;
+ }
+
//CollectionEngineSettings *ces_mode_ob = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_OBJECT, "");
//bool do_wire = BKE_collection_engine_property_value_get_bool(ces_mode_ob, "show_wire");
@@ -1693,7 +1797,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
{
Object *obedit = scene->obedit;
if (ob != obedit) {
- struct Gwn_Batch *geom = DRW_cache_lattice_wire_get(ob);
+ struct Gwn_Batch *geom = DRW_cache_lattice_wire_get(ob, false);
if (theme_id == TH_UNDEFINED) {
theme_id = DRW_object_wire_theme_get(ob, sl, NULL);
}
@@ -1730,7 +1834,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
DRW_shgroup_speaker(stl, ob, sl);
break;
case OB_LIGHTPROBE:
- DRW_shgroup_lightprobe(stl, ob, sl);
+ DRW_shgroup_lightprobe(stl, psl, ob, sl);
break;
case OB_ARMATURE:
{
@@ -1776,23 +1880,17 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
}
}
-static void OBJECT_cache_finish(void *vedata)
-{
- OBJECT_StorageList *stl = ((OBJECT_Data *)vedata)->stl;
- if (stl->g_data->image_plane_map) {
- BLI_ghash_free(stl->g_data->image_plane_map, NULL, MEM_freeN);
- }
-}
-
static void OBJECT_draw_scene(void *vedata)
{
OBJECT_PassList *psl = ((OBJECT_Data *)vedata)->psl;
+ OBJECT_StorageList *stl = ((OBJECT_Data *)vedata)->stl;
OBJECT_FramebufferList *fbl = ((OBJECT_Data *)vedata)->fbl;
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
float clearcol[4] = {0.0f, 0.0f, 0.0f, 0.0f};
if (DRW_state_is_fbo()) {
+ DRW_stats_group_start("Outlines");
/* attach temp textures */
DRW_framebuffer_texture_attach(fbl->outlines, e_data.outlines_depth_tx, 0, 0);
DRW_framebuffer_texture_attach(fbl->outlines, e_data.outlines_color_tx, 0, 0);
@@ -1802,6 +1900,7 @@ static void OBJECT_draw_scene(void *vedata)
DRW_framebuffer_bind(fbl->outlines);
DRW_framebuffer_clear(true, true, false, clearcol, 1.0f);
DRW_draw_pass(psl->outlines);
+ DRW_draw_pass(psl->lightprobes);
/* detach textures */
DRW_framebuffer_texture_detach(e_data.outlines_depth_tx);
@@ -1810,24 +1909,13 @@ static void OBJECT_draw_scene(void *vedata)
DRW_framebuffer_bind(fbl->blur);
DRW_draw_pass(psl->outlines_search);
- /* Expand and fade gradually */
+ /* Expand outline to form a 3px wide line */
DRW_framebuffer_bind(fbl->outlines);
DRW_draw_pass(psl->outlines_expand);
+ /* Bleed color so the AA can do it's stuff */
DRW_framebuffer_bind(fbl->blur);
- DRW_draw_pass(psl->outlines_fade1);
-
- DRW_framebuffer_bind(fbl->outlines);
- DRW_draw_pass(psl->outlines_fade2);
-
- DRW_framebuffer_bind(fbl->blur);
- DRW_draw_pass(psl->outlines_fade3);
-
- DRW_framebuffer_bind(fbl->outlines);
- DRW_draw_pass(psl->outlines_fade4);
-
- DRW_framebuffer_bind(fbl->blur);
- DRW_draw_pass(psl->outlines_fade5);
+ DRW_draw_pass(psl->outlines_bleed);
/* detach temp textures */
DRW_framebuffer_texture_detach(e_data.outlines_color_tx);
@@ -1835,17 +1923,27 @@ static void OBJECT_draw_scene(void *vedata)
/* restore main framebuffer */
DRW_framebuffer_bind(dfbl->default_fb);
+ DRW_stats_group_end();
+ }
+ else if (DRW_state_is_select()) {
+ /* Render probes spheres/planes so we can select them. */
+ DRW_draw_pass(psl->lightprobes);
}
+ MULTISAMPLE_SYNC_ENABLE(dfbl)
+
/* This needs to be drawn after the oultine */
// DRW_draw_pass(psl->bone_envelope); /* Never drawn in Object mode currently. */
DRW_draw_pass(psl->bone_wire);
DRW_draw_pass(psl->bone_solid);
DRW_draw_pass(psl->non_meshes);
- DRW_draw_pass(psl->ob_center);
DRW_draw_pass(psl->particle);
DRW_draw_pass(psl->reference_image);
+ MULTISAMPLE_SYNC_DISABLE(dfbl)
+
+ DRW_draw_pass(psl->ob_center);
+
if (!DRW_state_is_select()) {
if (e_data.draw_grid) {
DRW_draw_pass(psl->grid);
@@ -1854,6 +1952,11 @@ static void OBJECT_draw_scene(void *vedata)
/* Combine with scene buffer last */
DRW_draw_pass(psl->outlines_resolve);
}
+
+ /* This has to be freed only after drawing empties! */
+ if (stl->g_data->image_plane_map) {
+ BLI_ghash_free(stl->g_data->image_plane_map, NULL, MEM_freeN);
+ }
}
void OBJECT_collection_settings_create(IDProperty *props)
@@ -1875,7 +1978,8 @@ DrawEngineType draw_engine_object_type = {
&OBJECT_engine_free,
&OBJECT_cache_init,
&OBJECT_cache_populate,
- &OBJECT_cache_finish,
NULL,
- &OBJECT_draw_scene
+ NULL,
+ &OBJECT_draw_scene,
+ NULL,
};
diff --git a/source/blender/draw/modes/paint_texture_mode.c b/source/blender/draw/modes/paint_texture_mode.c
index 795b0bae02b..f898770acef 100644
--- a/source/blender/draw/modes/paint_texture_mode.c
+++ b/source/blender/draw/modes/paint_texture_mode.c
@@ -178,8 +178,7 @@ static void PAINT_TEXTURE_engine_init(void *vedata)
e_data.face_overlay_shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
}
}
-#include "BKE_global.h"
-#include "BKE_main.h"
+
/* Here init all passes and shading groups
* Assume that all Passes are NULL */
static void PAINT_TEXTURE_cache_init(void *vedata)
@@ -199,12 +198,6 @@ static void PAINT_TEXTURE_cache_init(void *vedata)
DRW_STATE_BLEND | DRW_STATE_WIRE;
psl->image_faces = DRW_pass_create("Image Color Pass", state);
- /* Create a shadingGroup using a function in draw_common.c or custom one */
- /*
- * stl->g_data->group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
- * -- or --
- * stl->g_data->group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
- */
stl->g_data->shgroup_fallback = DRW_shgroup_create(e_data.fallback_sh, psl->image_faces);
/* Uniforms need a pointer to it's value so be sure it's accessible at
@@ -218,7 +211,7 @@ static void PAINT_TEXTURE_cache_init(void *vedata)
Object *ob = draw_ctx->obact;
if (ob && ob->type == OB_MESH) {
Scene *scene = draw_ctx->scene;
- bool use_material_slots = (scene->toolsettings->imapaint.mode == IMAGEPAINT_MODE_MATERIAL);
+ const bool use_material_slots = (scene->toolsettings->imapaint.mode == IMAGEPAINT_MODE_MATERIAL);
const Mesh *me = ob->data;
stl->g_data->shgroup_image_array = MEM_mallocN(
@@ -292,41 +285,44 @@ static void PAINT_TEXTURE_cache_populate(void *vedata, Object *ob)
/* Get geometry cache */
const Mesh *me = ob->data;
Scene *scene = draw_ctx->scene;
- bool use_material_slots = (scene->toolsettings->imapaint.mode == IMAGEPAINT_MODE_MATERIAL);
+ const bool use_surface = DRW_object_is_mode_shade(ob) == true;
+ const bool use_material_slots = (scene->toolsettings->imapaint.mode == IMAGEPAINT_MODE_MATERIAL);
bool ok = false;
- if (me->mloopuv != NULL) {
- if (use_material_slots) {
- struct Gwn_Batch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL;
- if ((me->totcol == 0) || (geom_array == NULL)) {
- struct Gwn_Batch *geom = DRW_cache_mesh_surface_get(ob);
- DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom, ob->obmat);
- ok = true;
+ if (use_surface) {
+ if (me->mloopuv != NULL) {
+ if (use_material_slots) {
+ struct Gwn_Batch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL;
+ if ((me->totcol == 0) || (geom_array == NULL)) {
+ struct Gwn_Batch *geom = DRW_cache_mesh_surface_get(ob);
+ DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom, ob->obmat);
+ ok = true;
+ }
+ else {
+ for (int i = 0; i < me->totcol; i++) {
+ if (stl->g_data->shgroup_image_array[i]) {
+ DRW_shgroup_call_add(stl->g_data->shgroup_image_array[i], geom_array[i], ob->obmat);
+ }
+ else {
+ DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom_array[i], ob->obmat);
+ }
+ ok = true;
+ }
+ }
}
else {
- for (int i = 0; i < me->totcol; i++) {
- if (stl->g_data->shgroup_image_array[i]) {
- DRW_shgroup_call_add(stl->g_data->shgroup_image_array[i], geom_array[i], ob->obmat);
- }
- else {
- DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom_array[i], ob->obmat);
- }
+ struct Gwn_Batch *geom = DRW_cache_mesh_surface_texpaint_single_get(ob);
+ if (geom && stl->g_data->shgroup_image_array[0]) {
+ DRW_shgroup_call_add(stl->g_data->shgroup_image_array[0], geom, ob->obmat);
ok = true;
}
}
}
- else {
- struct Gwn_Batch *geom = DRW_cache_mesh_surface_texpaint_single_get(ob);
- if (geom && stl->g_data->shgroup_image_array[0]) {
- DRW_shgroup_call_add(stl->g_data->shgroup_image_array[0], geom, ob->obmat);
- ok = true;
- }
- }
- }
- if (!ok) {
- struct Gwn_Batch *geom = DRW_cache_mesh_surface_get(ob);
- DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom, ob->obmat);
+ if (!ok) {
+ struct Gwn_Batch *geom = DRW_cache_mesh_surface_get(ob);
+ DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom, ob->obmat);
+ }
}
/* Face Mask */
@@ -416,5 +412,6 @@ DrawEngineType draw_engine_paint_texture_type = {
&PAINT_TEXTURE_cache_populate,
&PAINT_TEXTURE_cache_finish,
NULL, /* draw_background but not needed by mode engines */
- &PAINT_TEXTURE_draw_scene
+ &PAINT_TEXTURE_draw_scene,
+ NULL,
};
diff --git a/source/blender/draw/modes/paint_vertex_mode.c b/source/blender/draw/modes/paint_vertex_mode.c
index ac3b82e9418..e430fca5742 100644
--- a/source/blender/draw/modes/paint_vertex_mode.c
+++ b/source/blender/draw/modes/paint_vertex_mode.c
@@ -110,7 +110,9 @@ static void PAINT_VERTEX_cache_init(void *vedata)
{
/* Create a pass */
- psl->vcolor_faces = DRW_pass_create("Vert Color Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
+ psl->vcolor_faces = DRW_pass_create(
+ "Vert Color Pass",
+ DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
stl->g_data->fvcolor_shgrp = DRW_shgroup_create(e_data.vcolor_face_shader, psl->vcolor_faces);
@@ -122,13 +124,17 @@ static void PAINT_VERTEX_cache_init(void *vedata)
}
{
- psl->wire_overlay = DRW_pass_create("Wire Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
+ psl->wire_overlay = DRW_pass_create(
+ "Wire Pass",
+ DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
stl->g_data->lwire_shgrp = DRW_shgroup_create(e_data.wire_overlay_shader, psl->wire_overlay);
}
{
- psl->face_overlay = DRW_pass_create("Face Mask Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_BLEND);
+ psl->face_overlay = DRW_pass_create(
+ "Face Mask Pass",
+ DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_BLEND);
stl->g_data->face_shgrp = DRW_shgroup_create(e_data.face_overlay_shader, psl->face_overlay);
@@ -144,15 +150,18 @@ static void PAINT_VERTEX_cache_populate(void *vedata, Object *ob)
if ((ob->type == OB_MESH) && (ob == draw_ctx->obact)) {
IDProperty *ces_mode_pw = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_PAINT_VERTEX, "");
- bool use_wire = BKE_collection_engine_property_value_get_bool(ces_mode_pw, "use_wire");
const Mesh *me = ob->data;
+ const bool use_wire = BKE_collection_engine_property_value_get_bool(ces_mode_pw, "use_wire");
+ const bool use_surface = DRW_object_is_mode_shade(ob) == true;
const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
struct Gwn_Batch *geom;
world_light = BKE_collection_engine_property_value_get_bool(ces_mode_pw, "use_shading") ? 0.5f : 1.0f;
- geom = DRW_cache_mesh_surface_vert_colors_get(ob);
- DRW_shgroup_call_add(stl->g_data->fvcolor_shgrp, geom, ob->obmat);
+ if (use_surface) {
+ geom = DRW_cache_mesh_surface_vert_colors_get(ob);
+ DRW_shgroup_call_add(stl->g_data->fvcolor_shgrp, geom, ob->obmat);
+ }
if (use_face_sel || use_wire) {
geom = DRW_cache_mesh_edges_paint_overlay_get(ob, use_wire, use_face_sel);
@@ -202,5 +211,6 @@ DrawEngineType draw_engine_paint_vertex_type = {
&PAINT_VERTEX_cache_populate,
NULL,
NULL,
- &PAINT_VERTEX_draw_scene
+ &PAINT_VERTEX_draw_scene,
+ NULL,
};
diff --git a/source/blender/draw/modes/paint_weight_mode.c b/source/blender/draw/modes/paint_weight_mode.c
index 270566b6cc6..e139b4af97f 100644
--- a/source/blender/draw/modes/paint_weight_mode.c
+++ b/source/blender/draw/modes/paint_weight_mode.c
@@ -92,7 +92,7 @@ static void PAINT_WEIGHT_engine_init(void *UNUSED(vedata))
if (e_data.actdef != draw_ctx->obact->actdef) {
e_data.actdef = draw_ctx->obact->actdef;
- BKE_mesh_batch_cache_dirty(draw_ctx->obact->data, BKE_MESH_BATCH_DIRTY_PAINT);
+ BKE_mesh_batch_cache_dirty(draw_ctx->obact->data, BKE_MESH_BATCH_DIRTY_ALL);
}
if (!e_data.weight_face_shader) {
@@ -180,16 +180,19 @@ static void PAINT_WEIGHT_cache_populate(void *vedata, Object *ob)
if ((ob->type == OB_MESH) && (ob == draw_ctx->obact)) {
IDProperty *ces_mode_pw = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_PAINT_WEIGHT, "");
- bool use_wire = BKE_collection_engine_property_value_get_bool(ces_mode_pw, "use_wire");
const Mesh *me = ob->data;
+ const bool use_wire = BKE_collection_engine_property_value_get_bool(ces_mode_pw, "use_wire");
+ const bool use_surface = DRW_object_is_mode_shade(ob) == true;
const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
const bool use_vert_sel = (me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0;
struct Gwn_Batch *geom;
world_light = BKE_collection_engine_property_value_get_bool(ces_mode_pw, "use_shading") ? 0.5f : 1.0f;
- geom = DRW_cache_mesh_surface_weights_get(ob);
- DRW_shgroup_call_add(stl->g_data->fweights_shgrp, geom, ob->obmat);
+ if (use_surface) {
+ geom = DRW_cache_mesh_surface_weights_get(ob);
+ DRW_shgroup_call_add(stl->g_data->fweights_shgrp, geom, ob->obmat);
+ }
if (use_face_sel || use_wire) {
geom = DRW_cache_mesh_edges_paint_overlay_get(ob, use_wire, use_face_sel);
@@ -246,5 +249,6 @@ DrawEngineType draw_engine_paint_weight_type = {
&PAINT_WEIGHT_cache_populate,
NULL,
NULL,
- &PAINT_WEIGHT_draw_scene
+ &PAINT_WEIGHT_draw_scene,
+ NULL,
};
diff --git a/source/blender/draw/modes/particle_mode.c b/source/blender/draw/modes/particle_mode.c
index dd22a5c6d8f..be076815f4c 100644
--- a/source/blender/draw/modes/particle_mode.c
+++ b/source/blender/draw/modes/particle_mode.c
@@ -259,5 +259,6 @@ DrawEngineType draw_engine_particle_type = {
&PARTICLE_cache_populate,
&PARTICLE_cache_finish,
NULL, /* draw_background but not needed by mode engines */
- &PARTICLE_draw_scene
+ &PARTICLE_draw_scene,
+ NULL,
};
diff --git a/source/blender/draw/modes/pose_mode.c b/source/blender/draw/modes/pose_mode.c
index d3233d713a1..1c2acd56085 100644
--- a/source/blender/draw/modes/pose_mode.c
+++ b/source/blender/draw/modes/pose_mode.c
@@ -101,7 +101,9 @@ static void POSE_cache_init(void *vedata)
{
/* Non Meshes Pass (Camera, empties, lamps ...) */
- DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_BLEND | DRW_STATE_WIRE;
+ DRWState state =
+ DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS |
+ DRW_STATE_BLEND | DRW_STATE_WIRE;
psl->relationship = DRW_pass_create("Bone Relationship Pass", state);
/* Relationship Lines */
@@ -191,5 +193,6 @@ DrawEngineType draw_engine_pose_type = {
&POSE_cache_populate,
NULL,
NULL,
- &POSE_draw_scene
+ &POSE_draw_scene,
+ NULL,
};
diff --git a/source/blender/draw/modes/sculpt_mode.c b/source/blender/draw/modes/sculpt_mode.c
index a3f29b5bb8f..f38e6565065 100644
--- a/source/blender/draw/modes/sculpt_mode.c
+++ b/source/blender/draw/modes/sculpt_mode.c
@@ -33,6 +33,8 @@
#include "BKE_pbvh.h"
#include "BKE_paint.h"
+#include "DEG_depsgraph.h"
+
/* If builtin shaders are needed */
#include "GPU_shader.h"
#include "GPU_matrix.h"
@@ -191,6 +193,9 @@ static void SCULPT_cache_populate(void *vedata, Object *ob)
if (ob->type == OB_MESH) {
const DRWContextState *draw_ctx = DRW_context_state_get();
+ EvaluationContext eval_ctx;
+
+ CTX_data_eval_ctx(draw_ctx->evil_C, &eval_ctx);
if (ob->sculpt && (ob == draw_ctx->obact)) {
@@ -201,7 +206,7 @@ static void SCULPT_cache_populate(void *vedata, Object *ob)
* but this avoids waiting on first stroke) */
Scene *scene = draw_ctx->scene;
- BKE_sculpt_update_mesh_elements(scene, scene->toolsettings->sculpt, ob, false, false);
+ BKE_sculpt_update_mesh_elements(&eval_ctx, scene, scene->toolsettings->sculpt, ob, false, false);
}
PBVH *pbvh = ob->sculpt->pbvh;
@@ -295,5 +300,6 @@ DrawEngineType draw_engine_sculpt_type = {
&SCULPT_cache_populate,
&SCULPT_cache_finish,
NULL, /* draw_background but not needed by mode engines */
- &SCULPT_draw_scene
+ &SCULPT_draw_scene,
+ NULL,
};
diff --git a/source/blender/draw/modes/shaders/common_fxaa_lib.glsl b/source/blender/draw/modes/shaders/common_fxaa_lib.glsl
new file mode 100644
index 00000000000..8158437b943
--- /dev/null
+++ b/source/blender/draw/modes/shaders/common_fxaa_lib.glsl
@@ -0,0 +1,678 @@
+//----------------------------------------------------------------------------------
+// File: es3-kepler\FXAA/FXAA3_11.h
+// SDK Version: v3.00
+// Email: gameworks@nvidia.com
+// Site: http://developer.nvidia.com/
+//
+// Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.
+//
+// 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 NVIDIA CORPORATION 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 ``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.
+//
+//----------------------------------------------------------------------------------
+
+/* BLENDER MODIFICATIONS:
+ *
+ * - (#B1#) Compute luma on the fly using BT. 709 luma function
+ * - (#B2#) main function instead of #include, due to lack of
+ * ARB_shading_language_include in 3.3
+ * - (#B3#) version and extension directives
+ * - removed "FXAA Console" algorithm support and shader parameters
+ * - removed HLSL support shims
+ * - (#B4#) change luma sampling to compute, not use A channel
+ * (this also removes GATHER4_ALPHA support)
+ * - removed all the console shaders (only remaining algorithm is "FXAA PC
+ * Quality")
+ *
+ * Note that this file doesn't follow the coding style guidelines.
+ */
+
+/*============================================================================
+ FXAA QUALITY - TUNING KNOBS
+------------------------------------------------------------------------------
+NOTE the other tuning knobs are now in the shader function inputs!
+============================================================================*/
+#ifndef FXAA_QUALITY__PRESET
+ //
+ // Choose the quality preset.
+ // This needs to be compiled into the shader as it effects code.
+ // Best option to include multiple presets is to
+ // in each shader define the preset, then include this file.
+ //
+ // OPTIONS
+ // -----------------------------------------------------------------------
+ // 10 to 15 - default medium dither (10=fastest, 15=highest quality)
+ // 20 to 29 - less dither, more expensive (20=fastest, 29=highest quality)
+ // 39 - no dither, very expensive
+ //
+ // NOTES
+ // -----------------------------------------------------------------------
+ // 12 = slightly faster then FXAA 3.9 and higher edge quality (default)
+ // 13 = about same speed as FXAA 3.9 and better than 12
+ // 23 = closest to FXAA 3.9 visually and performance wise
+ // _ = the lowest digit is directly related to performance
+ // _ = the highest digit is directly related to style
+ //
+ #define FXAA_QUALITY__PRESET 12
+#endif
+
+/*============================================================================
+
+ FXAA QUALITY - PRESETS
+
+============================================================================*/
+
+/*============================================================================
+ FXAA QUALITY - MEDIUM DITHER PRESETS
+============================================================================*/
+#if (FXAA_QUALITY__PRESET == 10)
+ #define FXAA_QUALITY__PS 3
+ #define FXAA_QUALITY__P0 1.5
+ #define FXAA_QUALITY__P1 3.0
+ #define FXAA_QUALITY__P2 12.0
+#endif
+/*--------------------------------------------------------------------------*/
+#if (FXAA_QUALITY__PRESET == 11)
+ #define FXAA_QUALITY__PS 4
+ #define FXAA_QUALITY__P0 1.0
+ #define FXAA_QUALITY__P1 1.5
+ #define FXAA_QUALITY__P2 3.0
+ #define FXAA_QUALITY__P3 12.0
+#endif
+/*--------------------------------------------------------------------------*/
+#if (FXAA_QUALITY__PRESET == 12)
+ #define FXAA_QUALITY__PS 5
+ #define FXAA_QUALITY__P0 1.0
+ #define FXAA_QUALITY__P1 1.5
+ #define FXAA_QUALITY__P2 2.0
+ #define FXAA_QUALITY__P3 4.0
+ #define FXAA_QUALITY__P4 12.0
+#endif
+/*--------------------------------------------------------------------------*/
+#if (FXAA_QUALITY__PRESET == 13)
+ #define FXAA_QUALITY__PS 6
+ #define FXAA_QUALITY__P0 1.0
+ #define FXAA_QUALITY__P1 1.5
+ #define FXAA_QUALITY__P2 2.0
+ #define FXAA_QUALITY__P3 2.0
+ #define FXAA_QUALITY__P4 4.0
+ #define FXAA_QUALITY__P5 12.0
+#endif
+/*--------------------------------------------------------------------------*/
+#if (FXAA_QUALITY__PRESET == 14)
+ #define FXAA_QUALITY__PS 7
+ #define FXAA_QUALITY__P0 1.0
+ #define FXAA_QUALITY__P1 1.5
+ #define FXAA_QUALITY__P2 2.0
+ #define FXAA_QUALITY__P3 2.0
+ #define FXAA_QUALITY__P4 2.0
+ #define FXAA_QUALITY__P5 4.0
+ #define FXAA_QUALITY__P6 12.0
+#endif
+/*--------------------------------------------------------------------------*/
+#if (FXAA_QUALITY__PRESET == 15)
+ #define FXAA_QUALITY__PS 8
+ #define FXAA_QUALITY__P0 1.0
+ #define FXAA_QUALITY__P1 1.5
+ #define FXAA_QUALITY__P2 2.0
+ #define FXAA_QUALITY__P3 2.0
+ #define FXAA_QUALITY__P4 2.0
+ #define FXAA_QUALITY__P5 2.0
+ #define FXAA_QUALITY__P6 4.0
+ #define FXAA_QUALITY__P7 12.0
+#endif
+
+/*============================================================================
+ FXAA QUALITY - LOW DITHER PRESETS
+============================================================================*/
+#if (FXAA_QUALITY__PRESET == 20)
+ #define FXAA_QUALITY__PS 3
+ #define FXAA_QUALITY__P0 1.5
+ #define FXAA_QUALITY__P1 2.0
+ #define FXAA_QUALITY__P2 8.0
+#endif
+/*--------------------------------------------------------------------------*/
+#if (FXAA_QUALITY__PRESET == 21)
+ #define FXAA_QUALITY__PS 4
+ #define FXAA_QUALITY__P0 1.0
+ #define FXAA_QUALITY__P1 1.5
+ #define FXAA_QUALITY__P2 2.0
+ #define FXAA_QUALITY__P3 8.0
+#endif
+/*--------------------------------------------------------------------------*/
+#if (FXAA_QUALITY__PRESET == 22)
+ #define FXAA_QUALITY__PS 5
+ #define FXAA_QUALITY__P0 1.0
+ #define FXAA_QUALITY__P1 1.5
+ #define FXAA_QUALITY__P2 2.0
+ #define FXAA_QUALITY__P3 2.0
+ #define FXAA_QUALITY__P4 8.0
+#endif
+/*--------------------------------------------------------------------------*/
+#if (FXAA_QUALITY__PRESET == 23)
+ #define FXAA_QUALITY__PS 6
+ #define FXAA_QUALITY__P0 1.0
+ #define FXAA_QUALITY__P1 1.5
+ #define FXAA_QUALITY__P2 2.0
+ #define FXAA_QUALITY__P3 2.0
+ #define FXAA_QUALITY__P4 2.0
+ #define FXAA_QUALITY__P5 8.0
+#endif
+/*--------------------------------------------------------------------------*/
+#if (FXAA_QUALITY__PRESET == 24)
+ #define FXAA_QUALITY__PS 7
+ #define FXAA_QUALITY__P0 1.0
+ #define FXAA_QUALITY__P1 1.5
+ #define FXAA_QUALITY__P2 2.0
+ #define FXAA_QUALITY__P3 2.0
+ #define FXAA_QUALITY__P4 2.0
+ #define FXAA_QUALITY__P5 3.0
+ #define FXAA_QUALITY__P6 8.0
+#endif
+/*--------------------------------------------------------------------------*/
+#if (FXAA_QUALITY__PRESET == 25)
+ #define FXAA_QUALITY__PS 8
+ #define FXAA_QUALITY__P0 1.0
+ #define FXAA_QUALITY__P1 1.5
+ #define FXAA_QUALITY__P2 2.0
+ #define FXAA_QUALITY__P3 2.0
+ #define FXAA_QUALITY__P4 2.0
+ #define FXAA_QUALITY__P5 2.0
+ #define FXAA_QUALITY__P6 4.0
+ #define FXAA_QUALITY__P7 8.0
+#endif
+/*--------------------------------------------------------------------------*/
+#if (FXAA_QUALITY__PRESET == 26)
+ #define FXAA_QUALITY__PS 9
+ #define FXAA_QUALITY__P0 1.0
+ #define FXAA_QUALITY__P1 1.5
+ #define FXAA_QUALITY__P2 2.0
+ #define FXAA_QUALITY__P3 2.0
+ #define FXAA_QUALITY__P4 2.0
+ #define FXAA_QUALITY__P5 2.0
+ #define FXAA_QUALITY__P6 2.0
+ #define FXAA_QUALITY__P7 4.0
+ #define FXAA_QUALITY__P8 8.0
+#endif
+/*--------------------------------------------------------------------------*/
+#if (FXAA_QUALITY__PRESET == 27)
+ #define FXAA_QUALITY__PS 10
+ #define FXAA_QUALITY__P0 1.0
+ #define FXAA_QUALITY__P1 1.5
+ #define FXAA_QUALITY__P2 2.0
+ #define FXAA_QUALITY__P3 2.0
+ #define FXAA_QUALITY__P4 2.0
+ #define FXAA_QUALITY__P5 2.0
+ #define FXAA_QUALITY__P6 2.0
+ #define FXAA_QUALITY__P7 2.0
+ #define FXAA_QUALITY__P8 4.0
+ #define FXAA_QUALITY__P9 8.0
+#endif
+/*--------------------------------------------------------------------------*/
+#if (FXAA_QUALITY__PRESET == 28)
+ #define FXAA_QUALITY__PS 11
+ #define FXAA_QUALITY__P0 1.0
+ #define FXAA_QUALITY__P1 1.5
+ #define FXAA_QUALITY__P2 2.0
+ #define FXAA_QUALITY__P3 2.0
+ #define FXAA_QUALITY__P4 2.0
+ #define FXAA_QUALITY__P5 2.0
+ #define FXAA_QUALITY__P6 2.0
+ #define FXAA_QUALITY__P7 2.0
+ #define FXAA_QUALITY__P8 2.0
+ #define FXAA_QUALITY__P9 4.0
+ #define FXAA_QUALITY__P10 8.0
+#endif
+/*--------------------------------------------------------------------------*/
+#if (FXAA_QUALITY__PRESET == 29)
+ #define FXAA_QUALITY__PS 12
+ #define FXAA_QUALITY__P0 1.0
+ #define FXAA_QUALITY__P1 1.5
+ #define FXAA_QUALITY__P2 2.0
+ #define FXAA_QUALITY__P3 2.0
+ #define FXAA_QUALITY__P4 2.0
+ #define FXAA_QUALITY__P5 2.0
+ #define FXAA_QUALITY__P6 2.0
+ #define FXAA_QUALITY__P7 2.0
+ #define FXAA_QUALITY__P8 2.0
+ #define FXAA_QUALITY__P9 2.0
+ #define FXAA_QUALITY__P10 4.0
+ #define FXAA_QUALITY__P11 8.0
+#endif
+
+/*============================================================================
+ FXAA QUALITY - EXTREME QUALITY
+============================================================================*/
+#if (FXAA_QUALITY__PRESET == 39)
+ #define FXAA_QUALITY__PS 12
+ #define FXAA_QUALITY__P0 1.0
+ #define FXAA_QUALITY__P1 1.0
+ #define FXAA_QUALITY__P2 1.0
+ #define FXAA_QUALITY__P3 1.0
+ #define FXAA_QUALITY__P4 1.0
+ #define FXAA_QUALITY__P5 1.5
+ #define FXAA_QUALITY__P6 2.0
+ #define FXAA_QUALITY__P7 2.0
+ #define FXAA_QUALITY__P8 2.0
+ #define FXAA_QUALITY__P9 2.0
+ #define FXAA_QUALITY__P10 4.0
+ #define FXAA_QUALITY__P11 8.0
+#endif
+
+#define FxaaSat(x) clamp(x, 0.0, 1.0)
+
+#ifdef FXAA_ALPHA
+
+#define FxaaTexTop(t, p) textureLod(t, p, 0.0).aaaa
+#define FxaaTexOff(t, p, o, r) textureLodOffset(t, p, 0.0, o).aaaa
+#define FxaaLuma(rgba) rgba.a
+
+#else
+
+#define FxaaTexTop(t, p) textureLod(t, p, 0.0)
+#define FxaaTexOff(t, p, o, r) textureLodOffset(t, p, 0.0, o)
+
+/* (#B1#) */
+float FxaaLuma(vec4 rgba) {
+ // note: sqrt because the sampled colors are in a linear colorspace!
+ // this approximates a perceptual conversion, which is good enough for the
+ // algorithm
+ return sqrt(dot(rgba.rgb, vec3(0.2126, 0.7152, 0.0722)));
+}
+
+#endif
+
+/*============================================================================
+
+ FXAA3 QUALITY - PC
+
+============================================================================*/
+/*--------------------------------------------------------------------------*/
+vec4 FxaaPixelShader(
+ //
+ // Use noperspective interpolation here (turn off perspective interpolation).
+ // {xy} = center of pixel
+ vec2 pos,
+ //
+ // Input color texture.
+ // {rgb_} = color in linear or perceptual color space
+ sampler2D tex,
+ //
+ // Only used on FXAA Quality.
+ // This must be from a constant/uniform.
+ // {x_} = 1.0/screenWidthInPixels
+ // {_y} = 1.0/screenHeightInPixels
+ vec2 fxaaQualityRcpFrame,
+ //
+ // Only used on FXAA Quality.
+ // This used to be the FXAA_QUALITY__SUBPIX define.
+ // It is here now to allow easier tuning.
+ // Choose the amount of sub-pixel aliasing removal.
+ // This can effect sharpness.
+ // 1.00 - upper limit (softer)
+ // 0.75 - default amount of filtering
+ // 0.50 - lower limit (sharper, less sub-pixel aliasing removal)
+ // 0.25 - almost off
+ // 0.00 - completely off
+ float fxaaQualitySubpix,
+ //
+ // Only used on FXAA Quality.
+ // This used to be the FXAA_QUALITY__EDGE_THRESHOLD define.
+ // It is here now to allow easier tuning.
+ // The minimum amount of local contrast required to apply algorithm.
+ // 0.333 - too little (faster)
+ // 0.250 - low quality
+ // 0.166 - default
+ // 0.125 - high quality
+ // 0.063 - overkill (slower)
+ float fxaaQualityEdgeThreshold,
+ //
+ // Only used on FXAA Quality.
+ // This used to be the FXAA_QUALITY__EDGE_THRESHOLD_MIN define.
+ // It is here now to allow easier tuning.
+ // Trims the algorithm from processing darks.
+ // 0.0833 - upper limit (default, the start of visible unfiltered edges)
+ // 0.0625 - high quality (faster)
+ // 0.0312 - visible limit (slower)
+ float fxaaQualityEdgeThresholdMin
+) {
+/*--------------------------------------------------------------------------*/
+ vec2 posM;
+ posM.x = pos.x;
+ posM.y = pos.y;
+ vec4 rgbyM = FxaaTexTop(tex, posM);
+ float lumaM = FxaaLuma(rgbyM); // (#B4#)
+ float lumaS = FxaaLuma(FxaaTexOff(tex, posM, ivec2( 0, 1), fxaaQualityRcpFrame.xy));
+ float lumaE = FxaaLuma(FxaaTexOff(tex, posM, ivec2( 1, 0), fxaaQualityRcpFrame.xy));
+ float lumaN = FxaaLuma(FxaaTexOff(tex, posM, ivec2( 0,-1), fxaaQualityRcpFrame.xy));
+ float lumaW = FxaaLuma(FxaaTexOff(tex, posM, ivec2(-1, 0), fxaaQualityRcpFrame.xy));
+/*--------------------------------------------------------------------------*/
+ float maxSM = max(lumaS, lumaM);
+ float minSM = min(lumaS, lumaM);
+ float maxESM = max(lumaE, maxSM);
+ float minESM = min(lumaE, minSM);
+ float maxWN = max(lumaN, lumaW);
+ float minWN = min(lumaN, lumaW);
+ float rangeMax = max(maxWN, maxESM);
+ float rangeMin = min(minWN, minESM);
+ float rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;
+ float range = rangeMax - rangeMin;
+ float rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);
+ bool earlyExit = range < rangeMaxClamped;
+/*--------------------------------------------------------------------------*/
+ if(earlyExit) {
+ return rgbyM;
+ }
+/*--------------------------------------------------------------------------*/
+ float lumaNW = FxaaLuma(FxaaTexOff(tex, posM, ivec2(-1,-1), fxaaQualityRcpFrame.xy));
+ float lumaSE = FxaaLuma(FxaaTexOff(tex, posM, ivec2( 1, 1), fxaaQualityRcpFrame.xy));
+ float lumaNE = FxaaLuma(FxaaTexOff(tex, posM, ivec2( 1,-1), fxaaQualityRcpFrame.xy));
+ float lumaSW = FxaaLuma(FxaaTexOff(tex, posM, ivec2(-1, 1), fxaaQualityRcpFrame.xy));
+/*--------------------------------------------------------------------------*/
+ float lumaNS = lumaN + lumaS;
+ float lumaWE = lumaW + lumaE;
+ float subpixRcpRange = 1.0/range;
+ float subpixNSWE = lumaNS + lumaWE;
+ float edgeHorz1 = (-2.0 * lumaM) + lumaNS;
+ float edgeVert1 = (-2.0 * lumaM) + lumaWE;
+/*--------------------------------------------------------------------------*/
+ float lumaNESE = lumaNE + lumaSE;
+ float lumaNWNE = lumaNW + lumaNE;
+ float edgeHorz2 = (-2.0 * lumaE) + lumaNESE;
+ float edgeVert2 = (-2.0 * lumaN) + lumaNWNE;
+/*--------------------------------------------------------------------------*/
+ float lumaNWSW = lumaNW + lumaSW;
+ float lumaSWSE = lumaSW + lumaSE;
+ float edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);
+ float edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);
+ float edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;
+ float edgeVert3 = (-2.0 * lumaS) + lumaSWSE;
+ float edgeHorz = abs(edgeHorz3) + edgeHorz4;
+ float edgeVert = abs(edgeVert3) + edgeVert4;
+/*--------------------------------------------------------------------------*/
+ float subpixNWSWNESE = lumaNWSW + lumaNESE;
+ float lengthSign = fxaaQualityRcpFrame.x;
+ bool horzSpan = edgeHorz >= edgeVert;
+ float subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;
+/*--------------------------------------------------------------------------*/
+ if(!horzSpan) lumaN = lumaW;
+ if(!horzSpan) lumaS = lumaE;
+ if(horzSpan) lengthSign = fxaaQualityRcpFrame.y;
+ float subpixB = (subpixA * (1.0/12.0)) - lumaM;
+/*--------------------------------------------------------------------------*/
+ float gradientN = lumaN - lumaM;
+ float gradientS = lumaS - lumaM;
+ float lumaNN = lumaN + lumaM;
+ float lumaSS = lumaS + lumaM;
+ bool pairN = abs(gradientN) >= abs(gradientS);
+ float gradient = max(abs(gradientN), abs(gradientS));
+ if(pairN) lengthSign = -lengthSign;
+ float subpixC = FxaaSat(abs(subpixB) * subpixRcpRange);
+/*--------------------------------------------------------------------------*/
+ vec2 posB;
+ posB.x = posM.x;
+ posB.y = posM.y;
+ vec2 offNP;
+ offNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;
+ offNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;
+ if(!horzSpan) posB.x += lengthSign * 0.5;
+ if( horzSpan) posB.y += lengthSign * 0.5;
+/*--------------------------------------------------------------------------*/
+ vec2 posN;
+ posN.x = posB.x - offNP.x * FXAA_QUALITY__P0;
+ posN.y = posB.y - offNP.y * FXAA_QUALITY__P0;
+ vec2 posP;
+ posP.x = posB.x + offNP.x * FXAA_QUALITY__P0;
+ posP.y = posB.y + offNP.y * FXAA_QUALITY__P0;
+ float subpixD = ((-2.0)*subpixC) + 3.0;
+ float lumaEndN = FxaaLuma(FxaaTexTop(tex, posN));
+ float subpixE = subpixC * subpixC;
+ float lumaEndP = FxaaLuma(FxaaTexTop(tex, posP));
+/*--------------------------------------------------------------------------*/
+ if(!pairN) lumaNN = lumaSS;
+ float gradientScaled = gradient * 1.0/4.0;
+ float lumaMM = lumaM - lumaNN * 0.5;
+ float subpixF = subpixD * subpixE;
+ bool lumaMLTZero = lumaMM < 0.0;
+/*--------------------------------------------------------------------------*/
+ lumaEndN -= lumaNN * 0.5;
+ lumaEndP -= lumaNN * 0.5;
+ bool doneN = abs(lumaEndN) >= gradientScaled;
+ bool doneP = abs(lumaEndP) >= gradientScaled;
+ if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P1;
+ if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P1;
+ bool doneNP = (!doneN) || (!doneP);
+ if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P1;
+ if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P1;
+/*--------------------------------------------------------------------------*/
+ if(doneNP) {
+ if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
+ if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
+ if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
+ if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
+ doneN = abs(lumaEndN) >= gradientScaled;
+ doneP = abs(lumaEndP) >= gradientScaled;
+ if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P2;
+ if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P2;
+ doneNP = (!doneN) || (!doneP);
+ if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P2;
+ if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P2;
+/*--------------------------------------------------------------------------*/
+ #if (FXAA_QUALITY__PS > 3)
+ if(doneNP) {
+ if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
+ if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
+ if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
+ if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
+ doneN = abs(lumaEndN) >= gradientScaled;
+ doneP = abs(lumaEndP) >= gradientScaled;
+ if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P3;
+ if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P3;
+ doneNP = (!doneN) || (!doneP);
+ if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P3;
+ if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P3;
+/*--------------------------------------------------------------------------*/
+ #if (FXAA_QUALITY__PS > 4)
+ if(doneNP) {
+ if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
+ if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
+ if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
+ if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
+ doneN = abs(lumaEndN) >= gradientScaled;
+ doneP = abs(lumaEndP) >= gradientScaled;
+ if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P4;
+ if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P4;
+ doneNP = (!doneN) || (!doneP);
+ if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P4;
+ if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P4;
+/*--------------------------------------------------------------------------*/
+ #if (FXAA_QUALITY__PS > 5)
+ if(doneNP) {
+ if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
+ if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
+ if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
+ if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
+ doneN = abs(lumaEndN) >= gradientScaled;
+ doneP = abs(lumaEndP) >= gradientScaled;
+ if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P5;
+ if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P5;
+ doneNP = (!doneN) || (!doneP);
+ if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P5;
+ if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P5;
+/*--------------------------------------------------------------------------*/
+ #if (FXAA_QUALITY__PS > 6)
+ if(doneNP) {
+ if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
+ if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
+ if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
+ if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
+ doneN = abs(lumaEndN) >= gradientScaled;
+ doneP = abs(lumaEndP) >= gradientScaled;
+ if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P6;
+ if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P6;
+ doneNP = (!doneN) || (!doneP);
+ if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P6;
+ if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P6;
+/*--------------------------------------------------------------------------*/
+ #if (FXAA_QUALITY__PS > 7)
+ if(doneNP) {
+ if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
+ if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
+ if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
+ if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
+ doneN = abs(lumaEndN) >= gradientScaled;
+ doneP = abs(lumaEndP) >= gradientScaled;
+ if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P7;
+ if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P7;
+ doneNP = (!doneN) || (!doneP);
+ if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P7;
+ if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P7;
+/*--------------------------------------------------------------------------*/
+ #if (FXAA_QUALITY__PS > 8)
+ if(doneNP) {
+ if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
+ if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
+ if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
+ if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
+ doneN = abs(lumaEndN) >= gradientScaled;
+ doneP = abs(lumaEndP) >= gradientScaled;
+ if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P8;
+ if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P8;
+ doneNP = (!doneN) || (!doneP);
+ if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P8;
+ if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P8;
+/*--------------------------------------------------------------------------*/
+ #if (FXAA_QUALITY__PS > 9)
+ if(doneNP) {
+ if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
+ if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
+ if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
+ if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
+ doneN = abs(lumaEndN) >= gradientScaled;
+ doneP = abs(lumaEndP) >= gradientScaled;
+ if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P9;
+ if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P9;
+ doneNP = (!doneN) || (!doneP);
+ if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P9;
+ if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P9;
+/*--------------------------------------------------------------------------*/
+ #if (FXAA_QUALITY__PS > 10)
+ if(doneNP) {
+ if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
+ if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
+ if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
+ if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
+ doneN = abs(lumaEndN) >= gradientScaled;
+ doneP = abs(lumaEndP) >= gradientScaled;
+ if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P10;
+ if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P10;
+ doneNP = (!doneN) || (!doneP);
+ if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P10;
+ if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P10;
+/*--------------------------------------------------------------------------*/
+ #if (FXAA_QUALITY__PS > 11)
+ if(doneNP) {
+ if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
+ if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
+ if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
+ if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
+ doneN = abs(lumaEndN) >= gradientScaled;
+ doneP = abs(lumaEndP) >= gradientScaled;
+ if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P11;
+ if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P11;
+ doneNP = (!doneN) || (!doneP);
+ if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P11;
+ if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P11;
+/*--------------------------------------------------------------------------*/
+ #if (FXAA_QUALITY__PS > 12)
+ if(doneNP) {
+ if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
+ if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
+ if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
+ if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
+ doneN = abs(lumaEndN) >= gradientScaled;
+ doneP = abs(lumaEndP) >= gradientScaled;
+ if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P12;
+ if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P12;
+ doneNP = (!doneN) || (!doneP);
+ if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P12;
+ if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P12;
+/*--------------------------------------------------------------------------*/
+ }
+ #endif
+/*--------------------------------------------------------------------------*/
+ }
+ #endif
+/*--------------------------------------------------------------------------*/
+ }
+ #endif
+/*--------------------------------------------------------------------------*/
+ }
+ #endif
+/*--------------------------------------------------------------------------*/
+ }
+ #endif
+/*--------------------------------------------------------------------------*/
+ }
+ #endif
+/*--------------------------------------------------------------------------*/
+ }
+ #endif
+/*--------------------------------------------------------------------------*/
+ }
+ #endif
+/*--------------------------------------------------------------------------*/
+ }
+ #endif
+/*--------------------------------------------------------------------------*/
+ }
+ #endif
+/*--------------------------------------------------------------------------*/
+ }
+/*--------------------------------------------------------------------------*/
+ float dstN = posM.x - posN.x;
+ float dstP = posP.x - posM.x;
+ if(!horzSpan) dstN = posM.y - posN.y;
+ if(!horzSpan) dstP = posP.y - posM.y;
+/*--------------------------------------------------------------------------*/
+ bool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;
+ float spanLength = (dstP + dstN);
+ bool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;
+ float spanLengthRcp = 1.0/spanLength;
+/*--------------------------------------------------------------------------*/
+ bool directionN = dstN < dstP;
+ float dst = min(dstN, dstP);
+ bool goodSpan = directionN ? goodSpanN : goodSpanP;
+ float subpixG = subpixF * subpixF;
+ float pixelOffset = (dst * (-spanLengthRcp)) + 0.5;
+ float subpixH = subpixG * fxaaQualitySubpix;
+/*--------------------------------------------------------------------------*/
+ float pixelOffsetGood = goodSpan ? pixelOffset : 0.0;
+ float pixelOffsetSubpix = max(pixelOffsetGood, subpixH);
+ if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;
+ if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;
+ return vec4(FxaaTexTop(tex, posM).xyz, lumaM);
+}
+/*==========================================================================*/
+
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_facedot_frag.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_facedot_frag.glsl
index 9b3fe6286e8..07b36079884 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_facedot_frag.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_facedot_frag.glsl
@@ -1,5 +1,8 @@
flat in int isSelected;
+#ifdef VERTEX_FACING
+flat in float facing;
+#endif
out vec4 FragColor;
@@ -9,4 +12,8 @@ void main()
FragColor = colorFaceDot;
else
FragColor = colorWireEdit;
+
+#ifdef VERTEX_FACING
+ FragColor.a *= 1.0 - abs(facing) * 0.4;
+#endif
}
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_facedot_vert.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_facedot_vert.glsl
index 2e541fa75e6..fa3934c4b77 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_facedot_vert.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_facedot_vert.glsl
@@ -6,9 +6,26 @@ in vec4 norAndFlag;
flat out int isSelected;
+#ifdef VERTEX_FACING
+uniform mat4 ProjectionMatrix;
+uniform mat4 ModelViewMatrix;
+uniform mat3 NormalMatrix;
+
+flat out float facing;
+#endif
+
void main()
{
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
+ /* Bias Facedot Z position in clipspace. */
+ gl_Position.z -= 0.0002;
gl_PointSize = sizeFaceDot;
isSelected = int(norAndFlag.w);
+#ifdef VERTEX_FACING
+ vec3 view_normal = normalize(NormalMatrix * norAndFlag.xyz);
+ vec3 view_vec = (ProjectionMatrix[3][3] == 0.0)
+ ? normalize((ModelViewMatrix * vec4(pos, 1.0)).xyz)
+ : vec3(0.0, 0.0, 1.0);
+ facing = dot(view_vec, view_normal);
+#endif
}
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl
index a8f74ac3e0f..ed7421c1b1d 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl
@@ -15,6 +15,9 @@ flat in int clipCase;
#ifdef VERTEX_SELECTION
in vec3 vertexColor;
#endif
+#ifdef VERTEX_FACING
+in float facing;
+#endif
/* We use a vec4[2] interface to pass edge data
* (without fragmenting memory accesses)
@@ -88,6 +91,15 @@ float distToEdge(vec2 o, vec2 dir)
return sqrt(abs(dot(af, af) - daf * daf));
}
+#ifdef ANTI_ALIASING
+void colorDistEdge(vec4 color, float dist)
+{
+ FragColor = mix(color, FragColor, clamp(dist, 0.0, 1.0));
+}
+#else
+#define colorDistEdge colorDist
+#endif
+
void main()
{
vec3 e, p;
@@ -143,27 +155,33 @@ void main()
/* Edges */
for (int v = 0; v < 3; ++v) {
if ((flag[v] & EDGE_EXISTS) != 0) {
- float largeEdge = e[v] - sizeEdge * 2.0;
+ /* Outer large edge */
+ float largeEdge = e[v] - sizeEdge * 3.0;
+
+ vec4 large_edge_color = vec4(0.0);
+ large_edge_color = ((flag[v] & EDGE_SHARP) != 0) ? colorEdgeSharp : large_edge_color;
+ large_edge_color = (edgesCrease[v] > 0.0) ? vec4(colorEdgeCrease.rgb, edgesCrease[v]) : large_edge_color;
+ large_edge_color = (edgesBweight[v] > 0.0) ? vec4(colorEdgeBWeight.rgb, edgesBweight[v]) : large_edge_color;
+ large_edge_color = ((flag[v] & EDGE_SEAM) != 0) ? colorEdgeSeam : large_edge_color;
+
+ if (large_edge_color.a != 0.0) {
+ colorDistEdge(large_edge_color, largeEdge);
+ }
+
+ /* Inner thin edge */
float innerEdge = e[v] - sizeEdge;
+#ifdef ANTI_ALIASING
+ innerEdge += 0.125;
+#endif
- if ((flag[v] & EDGE_SEAM) != 0)
- colorDist(colorEdgeSeam, largeEdge);
- else if (edgesBweight[v] > 0.0)
- colorDist(vec4(colorEdgeBWeight.rgb, edgesBweight[v]), largeEdge);
- else if (edgesCrease[v] > 0.0)
- colorDist(vec4(colorEdgeCrease.rgb, edgesCrease[v]), largeEdge);
- else if ((flag[v] & EDGE_SHARP) != 0)
- colorDist(colorEdgeSharp, largeEdge);
-#ifndef VERTEX_SELECTION
- else
- colorDist(colorWireEdit, innerEdge);
-
- if ((flag[v] & EDGE_ACTIVE) != 0)
- colorDist(vec4(colorEditMeshActive.xyz, 1.0), innerEdge);
- else if ((flag[v] & EDGE_SELECTED) != 0)
- colorDist(colorEdgeSelect, innerEdge);
+#ifdef VERTEX_SELECTION
+ colorDistEdge(vec4(vertexColor, 1.0), innerEdge);
#else
- colorDist(vec4(vertexColor, 1.0), innerEdge);
+ vec4 inner_edge_color = colorWireEdit;
+ inner_edge_color = ((flag[v] & EDGE_SELECTED) != 0) ? colorEdgeSelect : inner_edge_color;
+ inner_edge_color = ((flag[v] & EDGE_ACTIVE) != 0) ? vec4(colorEditMeshActive.xyz, 1.0) : inner_edge_color;
+
+ colorDistEdge(inner_edge_color, innerEdge);
#endif
}
}
@@ -173,15 +191,18 @@ void main()
for (int v = 0; v < 3; ++v) {
float size = p[v] - sizeVertex;
- if ((flag[v] & VERTEX_ACTIVE) != 0)
- colorDist(vec4(colorEditMeshActive.xyz, 1.0), size);
- else if ((flag[v] & VERTEX_SELECTED) != 0)
- colorDist(colorVertexSelect, size);
- else
- colorDist(colorVertex, size);
+ vec4 point_color = colorVertex;
+ point_color = ((flag[v] & VERTEX_SELECTED) != 0) ? colorVertexSelect : point_color;
+ point_color = ((flag[v] & VERTEX_ACTIVE) != 0) ? vec4(colorEditMeshActive.xyz, 1.0) : point_color;
+
+ colorDist(point_color, size);
}
#endif
+#ifdef VERTEX_FACING
+ FragColor.a *= 1.0 - abs(facing) * 0.4;
+#endif
+
/* don't write depth if not opaque */
- if (FragColor.a == 0.0) discard;
+ if (FragColor.a == 0.0) discard;
}
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_edge.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_edge.glsl
index 5e3ecd59cb4..7d71e1540d5 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_edge.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_edge.glsl
@@ -14,6 +14,9 @@ uniform vec2 viewportSize;
in vec4 vPos[];
in vec4 pPos[];
in ivec4 vData[];
+#ifdef VERTEX_FACING
+in float vFacing[];
+#endif
/* these are the same for all vertices
* and does not need interpolation */
@@ -25,6 +28,9 @@ flat out int clipCase;
#ifdef VERTEX_SELECTION
out vec3 vertexColor;
#endif
+#ifdef VERTEX_FACING
+out float facing;
+#endif
/* See fragment shader */
noperspective out vec4 eData1;
@@ -79,6 +85,10 @@ void doVertex(int v, vec4 pos)
vertexColor = getVertexColor(v);
#endif
+#ifdef VERTEX_FACING
+ facing = vFacing[v];
+#endif
+
gl_Position = pos;
EmitVertex();
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl
index 64809a37d11..f83402e3869 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl
@@ -29,6 +29,9 @@ uniform vec2 viewportSize;
in vec4 vPos[];
in vec4 pPos[];
in ivec4 vData[];
+#ifdef VERTEX_FACING
+in float vFacing[];
+#endif
/* these are the same for all vertices
* and does not need interpolation */
@@ -40,6 +43,9 @@ flat out int clipCase;
#ifdef VERTEX_SELECTION
out vec3 vertexColor;
#endif
+#ifdef VERTEX_FACING
+out float facing;
+#endif
/* See fragment shader */
noperspective out vec4 eData1;
@@ -103,11 +109,21 @@ void doVertex(int v, vec4 pos)
vertexColor = getVertexColor(v);
#endif
+#ifdef VERTEX_FACING
+ facing = vFacing[v];
+#endif
+
gl_Position = pos;
EmitVertex();
}
+#ifdef ANTI_ALIASING
+#define Z_OFFSET 0.008
+#else
+#define Z_OFFSET 0.0
+#endif
+
void main()
{
/* First we detect which case we are in */
@@ -214,7 +230,7 @@ void main()
}
/* to not let face color bleed */
- faceColor = vec4(0.0);
+ faceColor.a = 0.0;
/* we don't want other edges : make them far */
eData1 = vec4(1e10);
@@ -231,7 +247,7 @@ void main()
eData1.zw = pos[vbe];
doVertex(v, pPos[v]);
- doVertex(v, pPos[v] + vec4(fixvec[v], 0.0, 0.0));
+ doVertex(v, pPos[v] + vec4(fixvec[v], Z_OFFSET, 0.0));
/* Now one triangle only shade one edge
* so we use the edge distance calculated
@@ -247,19 +263,19 @@ void main()
edgesBweight[2] = ebweight[vbe];
doVertex(vaf, pPos[vaf]);
- doVertex(vaf, pPos[vaf] + vec4(fixvecaf[v], 0.0, 0.0));
+ doVertex(vaf, pPos[vaf] + vec4(fixvecaf[v], Z_OFFSET, 0.0));
/* corner vertices should not draw edges but draw point only */
flag[2] = (vData[vbe].x << 8);
#ifdef VERTEX_SELECTION
doVertex(vaf, pPos[vaf]);
- doVertex(vaf, pPos[vaf] + vec4(cornervec[vaf], 0.0, 0.0));
+ doVertex(vaf, pPos[vaf] + vec4(cornervec[vaf], Z_OFFSET, 0.0));
#endif
}
/* finish the loop strip */
doVertex(2, pPos[2]);
- doVertex(2, pPos[2] + vec4(fixvec[2], 0.0, 0.0));
+ doVertex(2, pPos[2] + vec4(fixvec[2], Z_OFFSET, 0.0));
#endif
}
/* Harder case : compute visible edges vectors */
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_mix_frag.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_mix_frag.glsl
index f567a3a5cbd..8f94a105332 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_mix_frag.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_mix_frag.glsl
@@ -15,10 +15,8 @@ void main()
FragColor = wire_color;
- /* this works because not rendered depth is 1.0 and the
- * following test is always true even when no wires */
- if ((wire_depth > scene_depth) && (wire_color.a > 0)) {
- /* Note : Using wire_color.a * alpha produce unwanted result */
- FragColor.a = alpha;
+ /* Modulate alpha if occluded */
+ if (wire_depth > scene_depth) {
+ FragColor.a *= alpha;
}
}
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl
index 5bc9a8bef85..8ebfa4376f0 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl
@@ -15,9 +15,24 @@ out vec4 vPos;
out vec4 pPos;
out ivec4 vData;
+#ifdef VERTEX_FACING
+uniform mat4 ProjectionMatrix;
+uniform mat3 NormalMatrix;
+
+in vec3 vnor;
+out float vFacing;
+#endif
+
void main()
{
vPos = ModelViewMatrix * vec4(pos, 1.0);
pPos = ModelViewProjectionMatrix * vec4(pos, 1.0);
vData = data;
+#ifdef VERTEX_FACING
+ vec3 view_normal = normalize(NormalMatrix * vnor);
+ vec3 view_vec = (ProjectionMatrix[3][3] == 0.0)
+ ? normalize(vPos.xyz)
+ : vec3(0.0, 0.0, 1.0);
+ vFacing = dot(view_vec, view_normal);
+#endif
}
diff --git a/source/blender/draw/modes/shaders/object_grid_frag.glsl b/source/blender/draw/modes/shaders/object_grid_frag.glsl
index 0196b1a6f98..61bd4d58a4a 100644
--- a/source/blender/draw/modes/shaders/object_grid_frag.glsl
+++ b/source/blender/draw/modes/shaders/object_grid_frag.glsl
@@ -75,7 +75,11 @@ vec3 get_floor_pos(vec2 uv, out vec3 wPos)
camera_vec = normalize(eye);
}
- float p = -dot(planeNormal, camera_pos) / dot(planeNormal, camera_vec);
+ float plane_normal_dot_camera_vec = dot(planeNormal, camera_vec);
+ float p = -dot(planeNormal, camera_pos);
+ if (plane_normal_dot_camera_vec != 0) {
+ p /= plane_normal_dot_camera_vec;
+ }
vec3 plane = camera_pos + camera_vec * p;
/* fix residual imprecision */
diff --git a/source/blender/draw/modes/shaders/object_lightprobe_grid_vert.glsl b/source/blender/draw/modes/shaders/object_lightprobe_grid_vert.glsl
new file mode 100644
index 00000000000..b47b3ee1cf4
--- /dev/null
+++ b/source/blender/draw/modes/shaders/object_lightprobe_grid_vert.glsl
@@ -0,0 +1,28 @@
+
+in vec3 pos;
+in vec3 nor;
+
+uniform mat4 ViewProjectionMatrix;
+
+uniform float sphere_size;
+uniform ivec3 grid_resolution;
+uniform vec3 corner;
+uniform vec3 increment_x;
+uniform vec3 increment_y;
+uniform vec3 increment_z;
+
+void main()
+{
+ vec3 ls_cell_location;
+ /* Keep in sync with update_irradiance_probe */
+ ls_cell_location.z = float(gl_InstanceID % grid_resolution.z);
+ ls_cell_location.y = float((gl_InstanceID / grid_resolution.z) % grid_resolution.y);
+ ls_cell_location.x = float(gl_InstanceID / (grid_resolution.z * grid_resolution.y));
+
+ vec3 ws_cell_location = corner +
+ (increment_x * ls_cell_location.x +
+ increment_y * ls_cell_location.y +
+ increment_z * ls_cell_location.z);
+
+ gl_Position = ViewProjectionMatrix * vec4(pos * 0.02 * sphere_size + ws_cell_location, 1.0);
+} \ No newline at end of file
diff --git a/source/blender/draw/modes/shaders/object_outline_detect_frag.glsl b/source/blender/draw/modes/shaders/object_outline_detect_frag.glsl
index 5565a0f1e09..dc0ea938436 100644
--- a/source/blender/draw/modes/shaders/object_outline_detect_frag.glsl
+++ b/source/blender/draw/modes/shaders/object_outline_detect_frag.glsl
@@ -32,30 +32,48 @@ void search_outline(ivec2 uv, vec4 ref_col, inout bool ref_occlu, inout bool out
void main()
{
ivec2 uv = ivec2(gl_FragCoord.xy);
+
+ vec4 color[4];
+ /* Idea : Use a 16bit ID to identify the color
+ * and store the colors in a UBO. And fetch all ids
+ * for discontinuity check with one textureGather \o/ */
vec4 ref_col = texelFetch(outlineColor, uv, 0).rgba;
+ color[0] = texelFetchOffset(outlineColor, uv, 0, ivec2( 1, 0)).rgba;
+ color[1] = texelFetchOffset(outlineColor, uv, 0, ivec2( 0, 1)).rgba;
+ color[2] = texelFetchOffset(outlineColor, uv, 0, ivec2(-1, 0)).rgba;
+ color[3] = texelFetchOffset(outlineColor, uv, 0, ivec2( 0, -1)).rgba;
+ /* TODO GATHER */
+ vec4 depths;
float depth = texelFetch(outlineDepth, uv, 0).r;
- /* Modulate color if occluded */
+ depths.x = texelFetchOffset(outlineDepth, uv, 0, ivec2( 1, 0)).r;
+ depths.y = texelFetchOffset(outlineDepth, uv, 0, ivec2( 0, 1)).r;
+ depths.z = texelFetchOffset(outlineDepth, uv, 0, ivec2(-1, 0)).r;
+ depths.w = texelFetchOffset(outlineDepth, uv, 0, ivec2( 0, -1)).r;
+
+ vec4 scene_depths;
float scene_depth = texelFetch(sceneDepth, uv, 0).r;
+ scene_depths.x = texelFetchOffset(sceneDepth, uv, 0, ivec2( 1, 0)).r;
+ scene_depths.y = texelFetchOffset(sceneDepth, uv, 0, ivec2( 0, 1)).r;
+ scene_depths.z = texelFetchOffset(sceneDepth, uv, 0, ivec2(-1, 0)).r;
+ scene_depths.w = texelFetchOffset(sceneDepth, uv, 0, ivec2( 0, -1)).r;
bool ref_occlu = (depth > scene_depth);
-
bool outline = false;
+#if 1
+ bvec4 occlu = (!ref_occlu) ? notEqual(greaterThan(depths, scene_depths), bvec4(ref_occlu)) : bvec4(false);
+ outline = (!outline) ? (color[0] != ref_col) || occlu.x : true;
+ outline = (!outline) ? (color[1] != ref_col) || occlu.y : true;
+ outline = (!outline) ? (color[2] != ref_col) || occlu.z : true;
+ outline = (!outline) ? (color[3] != ref_col) || occlu.w : true;
+#else
search_outline(uv + ivec2( 1, 0), ref_col, ref_occlu, outline);
search_outline(uv + ivec2( 0, 1), ref_col, ref_occlu, outline);
search_outline(uv + ivec2(-1, 0), ref_col, ref_occlu, outline);
search_outline(uv + ivec2( 0, -1), ref_col, ref_occlu, outline);
+#endif
FragColor = ref_col;
-
- /* We Hit something ! */
- if (outline) {
- if (ref_occlu) {
- FragColor.a *= alphaOcclu;
- }
- }
- else {
- FragColor.a = 0.0;
- }
+ FragColor.a *= (outline) ? (ref_occlu) ? alphaOcclu : 1.0 : 0.0;
}
diff --git a/source/blender/draw/modes/shaders/object_outline_expand_frag.glsl b/source/blender/draw/modes/shaders/object_outline_expand_frag.glsl
index e0568d1157a..7e288cde236 100644
--- a/source/blender/draw/modes/shaders/object_outline_expand_frag.glsl
+++ b/source/blender/draw/modes/shaders/object_outline_expand_frag.glsl
@@ -4,42 +4,34 @@ in vec4 uvcoordsvar;
out vec4 FragColor;
uniform sampler2D outlineColor;
-uniform sampler2D outlineDepth;
uniform float alpha;
uniform bool doExpand;
-void search_outline(ivec2 uv, inout bool found_edge)
-{
- if (!found_edge) {
- vec4 color = texelFetch(outlineColor, uv, 0).rgba;
- if (color.a != 0.0) {
- if (doExpand || color.a != 1.0) {
- FragColor = color;
- found_edge = true;
- }
- }
- }
-}
-
void main()
{
ivec2 uv = ivec2(gl_FragCoord.xy);
FragColor = texelFetch(outlineColor, uv, 0).rgba;
- float depth = texelFetch(outlineDepth, uv, 0).r;
- if (FragColor.a != 0.0 || (depth == 1.0 && !doExpand))
- return;
+ vec4 color[4];
+ color[0] = texelFetchOffset(outlineColor, uv, 0, ivec2( 1, 0)).rgba;
+ color[1] = texelFetchOffset(outlineColor, uv, 0, ivec2( 0, 1)).rgba;
+ color[2] = texelFetchOffset(outlineColor, uv, 0, ivec2(-1, 0)).rgba;
+ color[3] = texelFetchOffset(outlineColor, uv, 0, ivec2( 0, -1)).rgba;
- bool found_edge = false;
- search_outline(uv + ivec2( 1, 0), found_edge);
- search_outline(uv + ivec2( 0, 1), found_edge);
- search_outline(uv + ivec2(-1, 0), found_edge);
- search_outline(uv + ivec2( 0, -1), found_edge);
+ vec4 values = vec4(color[0].a, color[1].a, color[2].a, color[3].a);
- /* We Hit something ! */
- if (found_edge) {
- /* only change alpha */
- FragColor.a *= alpha;
+ vec4 tests = step(vec4(1e-6), values); /* (color.a != 0.0) */
+ bvec4 btests = equal(tests, vec4(1.0));
+
+ if (FragColor.a != 0.0) {
+ return;
}
+
+ FragColor = (btests.x) ? color[0] : FragColor;
+ FragColor = (btests.y) ? color[1] : FragColor;
+ FragColor = (btests.z) ? color[2] : FragColor;
+ FragColor = (btests.w) ? color[3] : FragColor;
+
+ FragColor.a *= (!doExpand) ? 0.0 : 1.0;
}
diff --git a/source/blender/draw/modes/shaders/object_outline_resolve_frag.glsl b/source/blender/draw/modes/shaders/object_outline_resolve_frag.glsl
index 3937828eca2..964ebe72e81 100644
--- a/source/blender/draw/modes/shaders/object_outline_resolve_frag.glsl
+++ b/source/blender/draw/modes/shaders/object_outline_resolve_frag.glsl
@@ -4,8 +4,24 @@ in vec4 uvcoordsvar;
out vec4 FragColor;
uniform sampler2D outlineBluredColor;
+uniform vec2 rcpDimensions;
void main()
{
- FragColor = texture(outlineBluredColor, uvcoordsvar.st).rgba;
+#ifdef USE_FXAA
+ float aa_alpha = FxaaPixelShader(
+ uvcoordsvar.st,
+ outlineBluredColor,
+ rcpDimensions,
+ 1.0,
+ 0.166,
+ 0.0833
+ ).r;
+#endif
+
+ FragColor = texture(outlineBluredColor, uvcoordsvar.st).rgba;
+
+#ifdef USE_FXAA
+ FragColor.a = aa_alpha;
+#endif
}
diff --git a/source/blender/draw/modes/shaders/object_particle_prim_vert.glsl b/source/blender/draw/modes/shaders/object_particle_prim_vert.glsl
index a950a9b86ba..54ae319307a 100644
--- a/source/blender/draw/modes/shaders/object_particle_prim_vert.glsl
+++ b/source/blender/draw/modes/shaders/object_particle_prim_vert.glsl
@@ -39,16 +39,18 @@ void main()
}
#ifdef USE_AXIS
- finalColor.rgb = vec3(0.0);
- finalColor[axis] = 1.0;
+ if (axis == 0)
+ finalColor = vec4(1.0, 0.0, 0.0, 1.0);
+ else if (axis == 1)
+ finalColor = vec4(0.0, 1.0, 0.0, 1.0);
+ else
+ finalColor = vec4(0.0, 0.0, 1.0, 1.0);
#else
if (val < 0.0) {
- finalColor.rgb = color;
+ finalColor = vec4(color, 1.0);
}
else {
- finalColor.rgb = texture(ramp, val).rgb;
+ finalColor = vec4(texture(ramp, val).rgb, 1.0);
}
#endif
-
- finalColor.a = 1.0;
}
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index 69e8f708e3d..4f76571a485 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -4481,8 +4481,8 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle
* a callback available (e.g. broken F-Curve rename)
*/
if (acf->name_prop(ale, &ptr, &prop)) {
- const short margin_x = 3 * iroundf(UI_DPI_FAC);
- const short channel_height = iroundf(ymaxc - yminc);
+ const short margin_x = 3 * round_fl_to_int(UI_DPI_FAC);
+ const short channel_height = round_fl_to_int(ymaxc - yminc);
const short width = ac->ar->winx - offset - (margin_x * 2);
uiBut *but;
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index 5b7ae216c55..90830223077 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -136,7 +136,7 @@ static Key *actedit_get_shapekeys(bAnimContext *ac)
Object *ob;
Key *key;
- ob = OBACT_NEW;
+ ob = OBACT_NEW(sl);
if (ob == NULL)
return NULL;
@@ -2251,6 +2251,8 @@ static void animfilter_modifier_idpoin_cb(void *afm_ptr, Object *ob, ID **idpoin
}
/* TODO: images? */
+ default:
+ break;
}
}
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index 064879bdd70..8cf0e203a41 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -152,7 +152,7 @@ int ED_markers_post_apply_transform(ListBase *markers, Scene *scene, int mode, f
(side == 'L' && marker->frame < cfra) ||
(side == 'R' && marker->frame >= cfra))
{
- marker->frame += iroundf(value);
+ marker->frame += round_fl_to_int(value);
changed_tot++;
}
break;
@@ -160,7 +160,7 @@ int ED_markers_post_apply_transform(ListBase *markers, Scene *scene, int mode, f
case TFM_TIME_SCALE:
{
/* rescale the distance between the marker and the current frame */
- marker->frame = cfra + iroundf((float)(marker->frame - cfra) * value);
+ marker->frame = cfra + round_fl_to_int((float)(marker->frame - cfra) * value);
changed_tot++;
break;
}
@@ -198,7 +198,7 @@ TimeMarker *ED_markers_find_nearest_marker(ListBase *markers, float x)
int ED_markers_find_nearest_marker_time(ListBase *markers, float x)
{
TimeMarker *nearest = ED_markers_find_nearest_marker(markers, x);
- return (nearest) ? (nearest->frame) : iroundf(x);
+ return (nearest) ? (nearest->frame) : round_fl_to_int(x);
}
@@ -354,7 +354,7 @@ static void draw_marker(
Gwn_VertFormat *format = immVertexFormat();
uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
@@ -913,7 +913,7 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, const wmEvent *even
case PADENTER:
case LEFTMOUSE:
case MIDDLEMOUSE:
- if (WM_modal_tweak_exit(event, mm->event_type)) {
+ if (WM_event_is_modal_tweak_exit(event, mm->event_type)) {
ed_marker_move_exit(C, op);
WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL);
diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c
index 0eb6508f7b2..fcdd45d4ac3 100644
--- a/source/blender/editors/animation/anim_ops.c
+++ b/source/blender/editors/animation/anim_ops.c
@@ -108,7 +108,7 @@ static void change_frame_apply(bContext *C, wmOperator *op)
SUBFRA = frame - (int)frame;
}
else {
- CFRA = iroundf(frame);
+ CFRA = round_fl_to_int(frame);
SUBFRA = 0.0f;
}
FRAMENUMBER_MIN_CLAMP(CFRA);
@@ -301,8 +301,8 @@ static int previewrange_define_exec(bContext *C, wmOperator *op)
if (efra < sfra) efra = sfra;
scene->r.flag |= SCER_PRV_RANGE;
- scene->r.psfra = iroundf(sfra);
- scene->r.pefra = iroundf(efra);
+ scene->r.psfra = round_fl_to_int(sfra);
+ scene->r.pefra = round_fl_to_int(efra);
/* send notifiers */
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c
index 7bda7f0522c..1a3d82e5002 100644
--- a/source/blender/editors/animation/drivers.c
+++ b/source/blender/editors/animation/drivers.c
@@ -40,6 +40,7 @@
#include "BLI_string.h"
#include "DNA_anim_types.h"
+#include "DNA_object_types.h"
#include "DNA_texture_types.h"
#include "BKE_animsys.h"
@@ -47,6 +48,7 @@
#include "BKE_context.h"
#include "BKE_report.h"
+#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
#include "ED_keyframing.h"
@@ -1030,6 +1032,11 @@ static int paste_driver_button_exec(bContext *C, wmOperator *op)
UI_context_update_anim_flag(C);
+ DEG_relations_tag_update(CTX_data_main(C));
+ DEG_id_tag_update(ptr.id.data, OB_RECALC_OB | OB_RECALC_DATA);
+
+ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); // XXX
+
MEM_freeN(path);
}
}
diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c
index 97e5597326e..8d7c32846b3 100644
--- a/source/blender/editors/animation/keyframes_draw.c
+++ b/source/blender/editors/animation/keyframes_draw.c
@@ -492,7 +492,7 @@ void draw_keyframe_shape(float x, float y, float size, bool sel, short key_type,
break;
default:
- size -= 0.5f * key_type;
+ size -= 0.8f * key_type;
}
unsigned char fill_col[4];
diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c
index c1e82583521..071c5fab9d7 100644
--- a/source/blender/editors/animation/keyframes_general.c
+++ b/source/blender/editors/animation/keyframes_general.c
@@ -52,6 +52,7 @@
#include "BKE_deform.h"
#include "RNA_access.h"
+#include "RNA_enum_types.h"
#include "ED_anim_api.h"
#include "ED_keyframing.h"
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index d29c0d722b5..66872c77b04 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -1075,10 +1075,11 @@ short insert_keyframe(ReportList *reports, ID *id, bAction *act, const char grou
/* for Loc/Rot/Scale and also Color F-Curves, the color of the F-Curve in the Graph Editor,
* is determined by the array index for the F-Curve
*/
- if (ELEM(RNA_property_subtype(prop), PROP_TRANSLATION, PROP_XYZ, PROP_EULER, PROP_COLOR, PROP_COORDS)) {
+ PropertySubType prop_subtype = RNA_property_subtype(prop);
+ if (ELEM(prop_subtype, PROP_TRANSLATION, PROP_XYZ, PROP_EULER, PROP_COLOR, PROP_COORDS)) {
fcu->color_mode = FCURVE_COLOR_AUTO_RGB;
}
- else if (RNA_property_subtype(prop), PROP_QUATERNION) {
+ else if (ELEM(prop_subtype, PROP_QUATERNION)) {
fcu->color_mode = FCURVE_COLOR_AUTO_YRGB;
}
}
@@ -1787,7 +1788,9 @@ static int insert_key_button_exec(bContext *C, wmOperator *op)
NlaStrip *strip = (NlaStrip *)ptr.data;
FCurve *fcu = list_find_fcurve(&strip->fcurves, RNA_property_identifier(prop), index);
- success = insert_keyframe_direct(op->reports, ptr, prop, fcu, cfra, ts->keyframe_type, 0);
+ if (fcu) {
+ success = insert_keyframe_direct(op->reports, ptr, prop, fcu, cfra, ts->keyframe_type, 0);
+ }
}
else if (UI_but_flag_is_set(but, UI_BUT_DRIVEN)) {
/* Driven property - Find driver */
@@ -1892,27 +1895,27 @@ static int delete_key_button_exec(bContext *C, wmOperator *op)
NlaStrip *strip = (NlaStrip *)ptr.data;
FCurve *fcu = list_find_fcurve(&strip->fcurves, RNA_property_identifier(prop), 0);
- BLI_assert(fcu != NULL); /* NOTE: This should be true, or else we wouldn't be able to get here */
-
- if (BKE_fcurve_is_protected(fcu)) {
- BKE_reportf(op->reports, RPT_WARNING,
- "Not deleting keyframe for locked F-Curve for NLA Strip influence on %s - %s '%s'",
- strip->name, BKE_idcode_to_name(GS(id->name)), id->name + 2);
- }
- else {
- /* remove the keyframe directly
- * NOTE: cannot use delete_keyframe_fcurve(), as that will free the curve,
- * and delete_keyframe() expects the FCurve to be part of an action
- */
- bool found = false;
- int i;
-
- /* try to find index of beztriple to get rid of */
- i = binarysearch_bezt_index(fcu->bezt, cfra, fcu->totvert, &found);
- if (found) {
- /* delete the key at the index (will sanity check + do recalc afterwards) */
- delete_fcurve_key(fcu, i, 1);
- success = true;
+ if (fcu) {
+ if (BKE_fcurve_is_protected(fcu)) {
+ BKE_reportf(op->reports, RPT_WARNING,
+ "Not deleting keyframe for locked F-Curve for NLA Strip influence on %s - %s '%s'",
+ strip->name, BKE_idcode_to_name(GS(id->name)), id->name + 2);
+ }
+ else {
+ /* remove the keyframe directly
+ * NOTE: cannot use delete_keyframe_fcurve(), as that will free the curve,
+ * and delete_keyframe() expects the FCurve to be part of an action
+ */
+ bool found = false;
+ int i;
+
+ /* try to find index of beztriple to get rid of */
+ i = binarysearch_bezt_index(fcu->bezt, cfra, fcu->totvert, &found);
+ if (found) {
+ /* delete the key at the index (will sanity check + do recalc afterwards) */
+ delete_fcurve_key(fcu, i, 1);
+ success = true;
+ }
}
}
}
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c
index fd73a27c9f6..ce1379f760d 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -1053,6 +1053,8 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe
DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
break;
}
+ default:
+ break;
}
/* send notifiers for updates (this doesn't require context to work!) */
diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c
index 47e73f9b777..51b76563c72 100644
--- a/source/blender/editors/armature/armature_edit.c
+++ b/source/blender/editors/armature/armature_edit.c
@@ -66,7 +66,7 @@
/* ************************** Object Tools Exports ******************************* */
/* NOTE: these functions are exported to the Object module to be called from the tools there */
-void ED_armature_apply_transform(Object *ob, float mat[4][4])
+void ED_armature_apply_transform(Object *ob, float mat[4][4], const bool do_props)
{
bArmature *arm = ob->data;
@@ -74,14 +74,14 @@ void ED_armature_apply_transform(Object *ob, float mat[4][4])
ED_armature_to_edit(arm);
/* Transform the bones */
- ED_armature_transform_bones(arm, mat);
+ ED_armature_transform_bones(arm, mat, do_props);
/* Turn the list into an armature */
ED_armature_from_edit(arm);
ED_armature_edit_free(arm);
}
-void ED_armature_transform_bones(struct bArmature *arm, float mat[4][4])
+void ED_armature_transform_bones(struct bArmature *arm, float mat[4][4], const bool do_props)
{
EditBone *ebone;
float scale = mat4_to_scale(mat); /* store the scale of the matrix here to use on envelopes */
@@ -106,27 +106,29 @@ void ED_armature_transform_bones(struct bArmature *arm, float mat[4][4])
/* apply the transformed roll back */
mat3_to_vec_roll(tmat, NULL, &ebone->roll);
- ebone->rad_head *= scale;
- ebone->rad_tail *= scale;
- ebone->dist *= scale;
-
- /* we could be smarter and scale by the matrix along the x & z axis */
- ebone->xwidth *= scale;
- ebone->zwidth *= scale;
+ if (do_props) {
+ ebone->rad_head *= scale;
+ ebone->rad_tail *= scale;
+ ebone->dist *= scale;
+
+ /* we could be smarter and scale by the matrix along the x & z axis */
+ ebone->xwidth *= scale;
+ ebone->zwidth *= scale;
+ }
}
}
-void ED_armature_transform(struct bArmature *arm, float mat[4][4])
+void ED_armature_transform(struct bArmature *arm, float mat[4][4], const bool do_props)
{
if (arm->edbo) {
- ED_armature_transform_bones(arm, mat);
+ ED_armature_transform_bones(arm, mat, do_props);
}
else {
/* Put the armature into editmode */
ED_armature_to_edit(arm);
/* Transform the bones */
- ED_armature_transform_bones(arm, mat);
+ ED_armature_transform_bones(arm, mat, do_props);
/* Go back to object mode*/
ED_armature_from_edit(arm);
@@ -220,7 +222,7 @@ float ED_rollBoneToVector(EditBone *bone, const float align_axis[3], const bool
vec_roll_to_mat3_normalized(nor, 0.0f, mat);
/* project the new_up_axis along the normal */
- project_v3_v3v3(vec, align_axis, nor);
+ project_v3_v3v3_normalized(vec, align_axis, nor);
sub_v3_v3v3(align_axis_proj, align_axis, vec);
if (axis_only) {
diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c
index a6f63548c96..99907e9e6ae 100644
--- a/source/blender/editors/armature/armature_relations.c
+++ b/source/blender/editors/armature/armature_relations.c
@@ -383,7 +383,7 @@ int join_armature_exec(bContext *C, wmOperator *op)
if (base->object->adt) {
if (ob->adt == NULL) {
/* no animdata, so just use a copy of the whole thing */
- ob->adt = BKE_animdata_copy(base->object->adt, false);
+ ob->adt = BKE_animdata_copy(bmain, base->object->adt, false);
}
else {
/* merge in data - we'll fix the drivers manually */
@@ -394,7 +394,7 @@ int join_armature_exec(bContext *C, wmOperator *op)
if (curarm->adt) {
if (arm->adt == NULL) {
/* no animdata, so just use a copy of the whole thing */
- arm->adt = BKE_animdata_copy(curarm->adt, false);
+ arm->adt = BKE_animdata_copy(bmain, curarm->adt, false);
}
else {
/* merge in data - we'll fix the drivers manually */
diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c
index 17dc8eac38c..cbf16d38f6b 100644
--- a/source/blender/editors/armature/armature_select.c
+++ b/source/blender/editors/armature/armature_select.c
@@ -53,6 +53,8 @@
#include "ED_screen.h"
#include "ED_view3d.h"
+#include "DEG_depsgraph.h"
+
#include "armature_intern.h"
/* utility macros for storing a temp int in the bone (selection flag) */
@@ -166,18 +168,20 @@ void *get_bone_from_selectbuffer(
/* x and y are mouse coords (area space) */
void *get_nearest_bone(bContext *C, const int xy[2], bool findunsel)
{
+ EvaluationContext eval_ctx;
ViewContext vc;
rcti rect;
unsigned int buffer[MAXPICKBUF];
short hits;
-
+
+ CTX_data_eval_ctx(C, &eval_ctx);
view3d_set_viewcontext(C, &vc);
// rect.xmin = ... mouseco!
rect.xmin = rect.xmax = xy[0];
rect.ymin = rect.ymax = xy[1];
- hits = view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect, VIEW3D_SELECT_PICK_NEAREST);
+ hits = view3d_opengl_select(&eval_ctx, &vc, buffer, MAXPICKBUF, &rect, VIEW3D_SELECT_PICK_NEAREST);
if (hits > 0)
return get_bone_from_selectbuffer(vc.scene, vc.scene_layer->basact, buffer, hits, findunsel, true);
@@ -291,7 +295,7 @@ static int selectbuffer_ret_hits_5(unsigned int *buffer, const int hits12, const
/* does bones and points */
/* note that BONE ROOT only gets drawn for root bones (or without IK) */
static EditBone *get_nearest_editbonepoint(
- ViewContext *vc, const int mval[2],
+ const EvaluationContext *eval_ctx, ViewContext *vc, const int mval[2],
ListBase *edbo, bool findunsel, bool use_cycle, int *r_selmask)
{
bArmature *arm = (bArmature *)vc->obedit->data;
@@ -344,7 +348,7 @@ static EditBone *get_nearest_editbonepoint(
view3d_opengl_select_cache_begin();
BLI_rcti_init_pt_radius(&rect, mval, 12);
- hits12 = view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect, select_mode);
+ hits12 = view3d_opengl_select(eval_ctx, vc, buffer, MAXPICKBUF, &rect, select_mode);
if (hits12 == 1) {
hits = selectbuffer_ret_hits_12(buffer, hits12);
goto cache_end;
@@ -354,7 +358,7 @@ static EditBone *get_nearest_editbonepoint(
offs = 4 * hits12;
BLI_rcti_init_pt_radius(&rect, mval, 5);
- hits5 = view3d_opengl_select(vc, buffer + offs, MAXPICKBUF - offs, &rect, select_mode);
+ hits5 = view3d_opengl_select(eval_ctx, vc, buffer + offs, MAXPICKBUF - offs, &rect, select_mode);
if (hits5 == 1) {
hits = selectbuffer_ret_hits_5(buffer, hits12, hits5);
@@ -482,17 +486,19 @@ bool ED_armature_select_pick(bContext *C, const int mval[2], bool extend, bool d
{
Object *obedit = CTX_data_edit_object(C);
bArmature *arm = obedit->data;
+ EvaluationContext eval_ctx;
ViewContext vc;
EditBone *nearBone = NULL;
int selmask;
+ CTX_data_eval_ctx(C, &eval_ctx);
view3d_set_viewcontext(C, &vc);
-
+
if (BIF_sk_selectStroke(C, mval, extend)) {
return true;
}
- nearBone = get_nearest_editbonepoint(&vc, mval, arm->edbo, true, true, &selmask);
+ nearBone = get_nearest_editbonepoint(&eval_ctx, &vc, mval, arm->edbo, true, true, &selmask);
if (nearBone) {
if (!extend && !deselect && !toggle) {
diff --git a/source/blender/editors/armature/armature_skinning.c b/source/blender/editors/armature/armature_skinning.c
index e8d41f722d7..72b4837c1b8 100644
--- a/source/blender/editors/armature/armature_skinning.c
+++ b/source/blender/editors/armature/armature_skinning.c
@@ -43,12 +43,15 @@
#include "BKE_action.h"
#include "BKE_armature.h"
+#include "BKE_context.h"
#include "BKE_deform.h"
#include "BKE_object_deform.h"
#include "BKE_report.h"
#include "BKE_subsurf.h"
#include "BKE_modifier.h"
+#include "DEG_depsgraph.h"
+
#include "ED_armature.h"
#include "ED_mesh.h"
@@ -247,8 +250,9 @@ static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], i
}
}
-static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, Object *par,
- int heat, const bool mirror)
+static void add_verts_to_dgroups(
+ ReportList *reports, const EvaluationContext *eval_ctx, Scene *scene, Object *ob, Object *par,
+ int heat, const bool mirror)
{
/* This functions implements the automatic computation of vertex group
* weights, either through envelopes or using a heat equilibrium.
@@ -372,7 +376,7 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob,
if (wpmode) {
/* if in weight paint mode, use final verts from derivedmesh */
- DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
+ DerivedMesh *dm = mesh_get_derived_final(eval_ctx, scene, ob, CD_MASK_BAREMESH);
if (dm->foreachMappedVert) {
mesh_get_mapped_verts_coords(dm, verts, mesh->totvert);
@@ -424,8 +428,9 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob,
MEM_freeN(verts);
}
-void create_vgroups_from_armature(ReportList *reports, Scene *scene, Object *ob, Object *par,
- const int mode, const bool mirror)
+void create_vgroups_from_armature(
+ ReportList *reports, const EvaluationContext *eval_ctx, Scene *scene, Object *ob, Object *par,
+ const int mode, const bool mirror)
{
/* Lets try to create some vertex groups
* based on the bones of the parent armature.
@@ -451,6 +456,6 @@ void create_vgroups_from_armature(ReportList *reports, Scene *scene, Object *ob,
* that are populated with the vertices for which the
* bone is closest.
*/
- add_verts_to_dgroups(reports, scene, ob, par, (mode == ARM_GROUPS_AUTO), mirror);
+ add_verts_to_dgroups(reports, eval_ctx, scene, ob, par, (mode == ARM_GROUPS_AUTO), mirror);
}
}
diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c
index 20fb7b5e693..41c1c73e49c 100644
--- a/source/blender/editors/armature/editarmature_sketch.c
+++ b/source/blender/editors/armature/editarmature_sketch.c
@@ -50,6 +50,8 @@
#include "ED_transform.h"
#include "ED_transform_snap_object_context.h"
+#include "DEG_depsgraph.h"
+
#include "WM_api.h"
#include "WM_types.h"
@@ -448,8 +450,8 @@ static void sk_drawPoint(SK_Point *pt, float size, float color[4])
gpuScaleUniform(sk_clampPointSize(pt, size));
- batch = Batch_get_sphere(0);
- Batch_set_builtin_program(batch, GPU_SHADER_3D_UNIFORM_COLOR);
+ batch = GPU_batch_preset_sphere(0);
+ GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR);
GWN_batch_uniform_4fv(batch, "color", color);
GWN_batch_draw(batch);
@@ -1922,16 +1924,18 @@ static void sk_applyGesture(bContext *C, SK_Sketch *sketch)
static bool sk_selectStroke(bContext *C, SK_Sketch *sketch, const int mval[2], const bool extend)
{
+ EvaluationContext eval_ctx;
ViewContext vc;
rcti rect;
unsigned int buffer[MAXPICKBUF];
short hits;
+ CTX_data_eval_ctx(C, &eval_ctx);
view3d_set_viewcontext(C, &vc);
BLI_rcti_init_pt_radius(&rect, mval, 5);
- hits = view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect, VIEW3D_SELECT_PICK_NEAREST);
+ hits = view3d_opengl_select(&eval_ctx, &vc, buffer, MAXPICKBUF, &rect, VIEW3D_SELECT_PICK_NEAREST);
if (hits > 0) {
int besthitresult = -1;
@@ -2029,12 +2033,12 @@ static void sk_drawSketch(Scene *scene, View3D *UNUSED(v3d), SK_Sketch *sketch,
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
switch (sketch->next_point.mode) {
- case PT_SNAP:
- copy_v4_fl4(tmp_color, 0.0f, 1.0f, 0.0f, 1.0f);
- break;
- case PT_PROJECT:
- copy_v4_fl4(tmp_color, 0.0f, 0.0f, 0.0f, 1.0f);
- break;
+ case PT_SNAP:
+ copy_v4_fl4(tmp_color, 0.0f, 1.0f, 0.0f, 1.0f);
+ break;
+ case PT_PROJECT:
+ copy_v4_fl4(tmp_color, 0.0f, 0.0f, 0.0f, 1.0f);
+ break;
}
sk_drawPoint(&sketch->next_point, 0.1, tmp_color);
diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c
index 736329d29bf..7a8b89899a7 100644
--- a/source/blender/editors/armature/pose_edit.c
+++ b/source/blender/editors/armature/pose_edit.c
@@ -96,7 +96,8 @@ void ED_armature_enter_posemode(bContext *C, Base *base)
case OB_ARMATURE:
ob->restore_mode = ob->mode;
ob->mode |= OB_MODE_POSE;
-
+ /* Inform all CoW versions that we changed the mode. */
+ DEG_id_tag_update_ex(CTX_data_main(C), &ob->id, DEG_TAG_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_POSE, NULL);
break;
@@ -115,7 +116,10 @@ void ED_armature_exit_posemode(bContext *C, Base *base)
ob->restore_mode = ob->mode;
ob->mode &= ~OB_MODE_POSE;
-
+
+ /* Inform all CoW versions that we changed the mode. */
+ DEG_id_tag_update_ex(CTX_data_main(C), &ob->id, DEG_TAG_COPY_ON_WRITE);
+
WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL);
}
}
@@ -155,7 +159,7 @@ static bool pose_has_protected_selected(Object *ob, short warn)
*
* To be called from various tools that do incremental updates
*/
-void ED_pose_recalculate_paths(Scene *scene, Object *ob)
+void ED_pose_recalculate_paths(bContext *C, Scene *scene, Object *ob)
{
ListBase targets = {NULL, NULL};
@@ -164,7 +168,7 @@ void ED_pose_recalculate_paths(Scene *scene, Object *ob)
animviz_get_object_motionpaths(ob, &targets);
/* recalculate paths, then free */
- animviz_calc_motionpaths(scene, &targets);
+ animviz_calc_motionpaths(C, scene, &targets);
BLI_freelistN(&targets);
}
@@ -227,7 +231,7 @@ static int pose_calculate_paths_exec(bContext *C, wmOperator *op)
/* calculate the bones that now have motionpaths... */
/* TODO: only make for the selected bones? */
- ED_pose_recalculate_paths(scene, ob);
+ ED_pose_recalculate_paths(C, scene, ob);
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
@@ -283,7 +287,7 @@ static int pose_update_paths_exec(bContext *C, wmOperator *UNUSED(op))
/* calculate the bones that now have motionpaths... */
/* TODO: only make for the selected bones? */
- ED_pose_recalculate_paths(scene, ob);
+ ED_pose_recalculate_paths(C, scene, ob);
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c
index c4336338176..f11168525c0 100644
--- a/source/blender/editors/armature/pose_lib.c
+++ b/source/blender/editors/armature/pose_lib.c
@@ -329,7 +329,7 @@ static int poselib_sanitize_exec(bContext *C, wmOperator *op)
/* add pose to poselib */
marker = MEM_callocN(sizeof(TimeMarker), "ActionMarker");
- BLI_strncpy(marker->name, "Pose", sizeof(marker->name));
+ BLI_snprintf(marker->name, sizeof(marker->name), "F%d Pose", (int)ak->cfra);
marker->frame = (int)ak->cfra;
marker->flag = -1;
@@ -1069,6 +1069,9 @@ static void poselib_keytag_pose(bContext *C, Scene *scene, tPoseLib_PreviewData
static void poselib_preview_apply(bContext *C, wmOperator *op)
{
tPoseLib_PreviewData *pld = (tPoseLib_PreviewData *)op->customdata;
+ EvaluationContext eval_ctx;
+
+ CTX_data_eval_ctx(C, &eval_ctx);
/* only recalc pose (and its dependencies) if pose has changed */
if (pld->redraw == PL_PREVIEW_REDRAWALL) {
@@ -1093,7 +1096,7 @@ static void poselib_preview_apply(bContext *C, wmOperator *op)
if ((pld->arm->flag & ARM_DELAYDEFORM) == 0)
DEG_id_tag_update(&pld->ob->id, OB_RECALC_DATA); /* sets recalc flags */
else
- BKE_pose_where_is(pld->scene, pld->ob);
+ BKE_pose_where_is(&eval_ctx, pld->scene, pld->ob);
}
/* do header print - if interactively previewing */
@@ -1584,6 +1587,9 @@ static void poselib_preview_cleanup(bContext *C, wmOperator *op)
bArmature *arm = pld->arm;
bAction *act = pld->act;
TimeMarker *marker = pld->marker;
+ EvaluationContext eval_ctx;
+
+ CTX_data_eval_ctx(C, &eval_ctx);
/* redraw the header so that it doesn't show any of our stuff anymore */
ED_area_headerprint(pld->sa, NULL);
@@ -1601,7 +1607,7 @@ static void poselib_preview_cleanup(bContext *C, wmOperator *op)
if ((arm->flag & ARM_DELAYDEFORM) == 0)
DEG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */
else
- BKE_pose_where_is(scene, ob);
+ BKE_pose_where_is(&eval_ctx, scene, ob);
}
else if (pld->state == PL_PREVIEW_CONFIRM) {
/* tag poses as appropriate */
@@ -1619,7 +1625,7 @@ static void poselib_preview_cleanup(bContext *C, wmOperator *op)
//remake_action_ipos(ob->action);
}
else
- BKE_pose_where_is(scene, ob);
+ BKE_pose_where_is(&eval_ctx, scene, ob);
}
/* Request final redraw of the view. */
diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c
index 0d1752e07a1..e43212c7bde 100644
--- a/source/blender/editors/armature/pose_select.c
+++ b/source/blender/editors/armature/pose_select.c
@@ -146,7 +146,7 @@ bool ED_do_pose_selectbuffer(
/* if the bone cannot be affected, don't do anything */
if ((nearBone) && !(nearBone->flag & BONE_UNSELECTABLE)) {
- Object *ob_act = OBACT_NEW;
+ Object *ob_act = OBACT_NEW(sl);
bArmature *arm = ob->data;
/* since we do unified select, we don't shift+select a bone if the
diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c
index 8dfcd5acab8..f62073d56ef 100644
--- a/source/blender/editors/armature/pose_slide.c
+++ b/source/blender/editors/armature/pose_slide.c
@@ -39,6 +39,7 @@
#include "DNA_scene_types.h"
#include "BKE_fcurve.h"
+#include "BKE_nla.h"
#include "BKE_context.h"
#include "BKE_object.h"
@@ -94,9 +95,13 @@ typedef struct tPoseSlideOp {
ListBase pfLinks; /* links between posechannels and f-curves */
DLRBT_Tree keys; /* binary tree for quicker searching for keyframes (when applicable) */
- int cframe; /* current frame number */
- int prevFrame; /* frame before current frame (blend-from) */
- int nextFrame; /* frame after current frame (blend-to) */
+ int cframe; /* current frame number - global time */
+
+ int prevFrame; /* frame before current frame (blend-from) - global time */
+ int nextFrame; /* frame after current frame (blend-to) - global time */
+
+ float prevFrameF; /* prevFrame, but in local action time (for F-Curve lookups to work) */
+ float nextFrameF; /* nextFrame, but in local action time (for F-Curve lookups to work) */
short mode; /* sliding mode (ePoseSlide_Modes) */
short flag; /* unused for now, but can later get used for storing runtime settings.... */
@@ -189,11 +194,15 @@ static int pose_slide_init(bContext *C, wmOperator *op, short mode)
pso->channels = RNA_enum_get(op->ptr, "channels");
pso->axislock = RNA_enum_get(op->ptr, "axis_lock");
- /* check the settings from the context */
+ /* ensure validity of the settings from the context */
if (ELEM(NULL, pso->ob, pso->arm, pso->ob->adt, pso->ob->adt->action))
return 0;
- else
- act = pso->ob->adt->action;
+
+ act = pso->ob->adt->action;
+
+ /* apply NLA mapping corrections so the frame lookups work */
+ pso->prevFrameF = BKE_nla_tweakedit_remap(pso->ob->adt, pso->prevFrame, NLATIME_CONVERT_UNMAP);
+ pso->nextFrameF = BKE_nla_tweakedit_remap(pso->ob->adt, pso->nextFrame, NLATIME_CONVERT_UNMAP);
/* for each Pose-Channel which gets affected, get the F-Curves for that channel
* and set the relevant transform flags...
@@ -259,9 +268,9 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, float *val)
/* get keyframe values for endpoint poses to blend with */
/* previous/start */
- sVal = evaluate_fcurve(fcu, (float)pso->prevFrame);
+ sVal = evaluate_fcurve(fcu, pso->prevFrameF);
/* next/end */
- eVal = evaluate_fcurve(fcu, (float)pso->nextFrame);
+ eVal = evaluate_fcurve(fcu, pso->nextFrameF);
/* if both values are equal, don't do anything */
if (IS_EQF(sVal, eVal)) {
@@ -483,15 +492,15 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
float quat_prev[4], quat_next[4];
/* get 2 quats */
- quat_prev[0] = evaluate_fcurve(fcu_w, pso->prevFrame);
- quat_prev[1] = evaluate_fcurve(fcu_x, pso->prevFrame);
- quat_prev[2] = evaluate_fcurve(fcu_y, pso->prevFrame);
- quat_prev[3] = evaluate_fcurve(fcu_z, pso->prevFrame);
+ quat_prev[0] = evaluate_fcurve(fcu_w, pso->prevFrameF);
+ quat_prev[1] = evaluate_fcurve(fcu_x, pso->prevFrameF);
+ quat_prev[2] = evaluate_fcurve(fcu_y, pso->prevFrameF);
+ quat_prev[3] = evaluate_fcurve(fcu_z, pso->prevFrameF);
- quat_next[0] = evaluate_fcurve(fcu_w, pso->nextFrame);
- quat_next[1] = evaluate_fcurve(fcu_x, pso->nextFrame);
- quat_next[2] = evaluate_fcurve(fcu_y, pso->nextFrame);
- quat_next[3] = evaluate_fcurve(fcu_z, pso->nextFrame);
+ quat_next[0] = evaluate_fcurve(fcu_w, pso->nextFrameF);
+ quat_next[1] = evaluate_fcurve(fcu_x, pso->nextFrameF);
+ quat_next[2] = evaluate_fcurve(fcu_y, pso->nextFrameF);
+ quat_next[3] = evaluate_fcurve(fcu_z, pso->nextFrameF);
/* perform blending */
if (pso->mode == POSESLIDE_BREAKDOWN) {
@@ -543,6 +552,10 @@ static void pose_slide_apply(bContext *C, tPoseSlideOp *pso)
/* move out one step either side */
pso->prevFrame--;
pso->nextFrame++;
+
+ /* apply NLA mapping corrections so the frame lookups work */
+ pso->prevFrameF = BKE_nla_tweakedit_remap(pso->ob->adt, pso->prevFrame, NLATIME_CONVERT_UNMAP);
+ pso->nextFrameF = BKE_nla_tweakedit_remap(pso->ob->adt, pso->nextFrame, NLATIME_CONVERT_UNMAP);
}
/* for each link, handle each set of transforms */
@@ -746,6 +759,10 @@ static int pose_slide_invoke_common(bContext *C, wmOperator *op, tPoseSlideOp *p
pso->nextFrame = (ak->next) ? (ak->next->cfra) : (pso->cframe + 1);
RNA_int_set(op->ptr, "next_frame", pso->nextFrame);
}
+
+ /* apply NLA mapping corrections so the frame lookups work */
+ pso->prevFrameF = BKE_nla_tweakedit_remap(pso->ob->adt, pso->prevFrame, NLATIME_CONVERT_UNMAP);
+ pso->nextFrameF = BKE_nla_tweakedit_remap(pso->ob->adt, pso->nextFrame, NLATIME_CONVERT_UNMAP);
}
else {
BKE_report(op->reports, RPT_ERROR, "No keyframes to slide between");
@@ -1464,7 +1481,7 @@ static void pose_propagate_fcurve(wmOperator *op, Object *ob, FCurve *fcu,
/* stop on matching marker if there is one */
for (ce = modeData.sel_markers.first; ce; ce = ce->next) {
- if (ce->cfra == iroundf(bezt->vec[1][0]))
+ if (ce->cfra == round_fl_to_int(bezt->vec[1][0]))
break;
}
diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c
index c2f66db63f8..49e16794588 100644
--- a/source/blender/editors/armature/pose_transform.c
+++ b/source/blender/editors/armature/pose_transform.c
@@ -71,9 +71,12 @@
/* Pose Apply */
/* helper for apply_armature_pose2bones - fixes parenting of objects that are bone-parented to armature */
-static void applyarmature_fix_boneparents(Scene *scene, Object *armob)
+static void applyarmature_fix_boneparents(const bContext *C, Scene *scene, Object *armob)
{
Object workob, *ob;
+ EvaluationContext eval_ctx;
+
+ CTX_data_eval_ctx(C, &eval_ctx);
/* go through all objects in database */
for (ob = G.main->object.first; ob; ob = ob->id.next) {
@@ -84,7 +87,7 @@ static void applyarmature_fix_boneparents(Scene *scene, Object *armob)
*/
BKE_object_apply_mat4(ob, ob->obmat, false, false);
- BKE_object_workob_calc_parent(scene, ob, &workob);
+ BKE_object_workob_calc_parent(&eval_ctx, scene, ob, &workob);
invert_m4_m4(ob->parentinv, workob.obmat);
}
}
@@ -95,10 +98,13 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); // must be active object, not edit-object
+ EvaluationContext eval_ctx;
bArmature *arm = BKE_armature_from_object(ob);
bPose *pose;
bPoseChannel *pchan;
EditBone *curbone;
+
+ CTX_data_eval_ctx(C, &eval_ctx);
/* don't check if editmode (should be done by caller) */
if (ob->type != OB_ARMATURE)
@@ -168,10 +174,10 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
ED_armature_edit_free(arm);
/* flush positions of posebones */
- BKE_pose_where_is(scene, ob);
+ BKE_pose_where_is(&eval_ctx, scene, ob);
/* fix parenting of objects which are bone-parented */
- applyarmature_fix_boneparents(scene, ob);
+ applyarmature_fix_boneparents(C, scene, ob);
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
@@ -758,7 +764,7 @@ static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op,
/* now recalculate paths */
if ((ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS))
- ED_pose_recalculate_paths(scene, ob);
+ ED_pose_recalculate_paths(C, scene, ob);
}
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
diff --git a/source/blender/editors/armature/pose_utils.c b/source/blender/editors/armature/pose_utils.c
index 124cf24f12b..b17cc286333 100644
--- a/source/blender/editors/armature/pose_utils.c
+++ b/source/blender/editors/armature/pose_utils.c
@@ -182,6 +182,9 @@ void poseAnim_mapping_free(ListBase *pfLinks)
void poseAnim_mapping_refresh(bContext *C, Scene *scene, Object *ob)
{
bArmature *arm = (bArmature *)ob->data;
+ EvaluationContext eval_ctx;
+
+ CTX_data_eval_ctx(C, &eval_ctx);
/* old optimize trick... this enforces to bypass the depgraph
* - note: code copied from transform_generics.c -> recalcData()
@@ -190,7 +193,7 @@ void poseAnim_mapping_refresh(bContext *C, Scene *scene, Object *ob)
if ((arm->flag & ARM_DELAYDEFORM) == 0)
DEG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */
else
- BKE_pose_where_is(scene, ob);
+ BKE_pose_where_is(&eval_ctx, scene, ob);
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
@@ -263,7 +266,7 @@ void poseAnim_mapping_autoKeyframe(bContext *C, Scene *scene, Object *ob, ListBa
*/
if (ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS) {
//ED_pose_clear_paths(C, ob); // XXX for now, don't need to clear
- ED_pose_recalculate_paths(scene, ob);
+ ED_pose_recalculate_paths(C, scene, ob);
}
}
}
diff --git a/source/blender/editors/curve/curve_intern.h b/source/blender/editors/curve/curve_intern.h
index 856573ffab0..02c76a840f1 100644
--- a/source/blender/editors/curve/curve_intern.h
+++ b/source/blender/editors/curve/curve_intern.h
@@ -40,7 +40,7 @@ struct wmOperatorType;
struct ViewContext;
/* editfont.c */
-enum { DEL_ALL, DEL_NEXT_CHAR, DEL_PREV_CHAR, DEL_SELECTION, DEL_NEXT_SEL, DEL_PREV_SEL };
+enum { DEL_NEXT_CHAR, DEL_PREV_CHAR, DEL_NEXT_WORD, DEL_PREV_WORD, DEL_SELECTION, DEL_NEXT_SEL, DEL_PREV_SEL };
enum { CASE_LOWER, CASE_UPPER };
enum { LINE_BEGIN, LINE_END, PREV_CHAR, NEXT_CHAR, PREV_WORD, NEXT_WORD,
PREV_LINE, NEXT_LINE, PREV_PAGE, NEXT_PAGE };
diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c
index fce6425b9be..5d637b113d8 100644
--- a/source/blender/editors/curve/curve_ops.c
+++ b/source/blender/editors/curve/curve_ops.c
@@ -178,9 +178,10 @@ void ED_keymap_curve(wmKeyConfig *keyconf)
RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_style_toggle", PKEY, KM_PRESS, KM_CTRL, 0)->ptr, "style", CU_CHINFO_SMALLCAPS);
RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_delete", DELKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_NEXT_SEL);
+ RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_delete", DELKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_NEXT_WORD);
RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_delete", BACKSPACEKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_PREV_SEL);
RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_delete", BACKSPACEKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", DEL_PREV_SEL); /* same as above [#26623] */
- RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_delete", BACKSPACEKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_ALL);
+ RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_delete", BACKSPACEKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_PREV_WORD);
RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move", HOMEKEY, KM_PRESS, 0, 0)->ptr, "type", LINE_BEGIN);
RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move", ENDKEY, KM_PRESS, 0, 0)->ptr, "type", LINE_END);
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index b3f1f4f59be..6327dbb8fae 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -6275,12 +6275,15 @@ static int match_texture_space_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
Object *object = CTX_data_active_object(C);
+ EvaluationContext eval_ctx;
Curve *curve = (Curve *) object->data;
float min[3], max[3], size[3], loc[3];
int a;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
if (object->curve_cache == NULL) {
- BKE_displist_make_curveTypes(scene, object, false);
+ BKE_displist_make_curveTypes(&eval_ctx, scene, object, false);
}
INIT_MINMAX(min, max);
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c
index 6d29d2def97..f6bbff2f5d4 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -75,94 +75,6 @@
/* Distance between start/end points to consider cyclic */
#define STROKE_CYCLIC_DIST_PX 8
-
-/* -------------------------------------------------------------------- */
-
-/** \name Depth Utilities
- * \{ */
-
-
-static float depth_read_zbuf(const ViewContext *vc, int x, int y)
-{
- ViewDepths *vd = vc->rv3d->depths;
-
- if (vd && vd->depths && x > 0 && y > 0 && x < vd->w && y < vd->h)
- return vd->depths[y * vd->w + x];
- else
- return -1.0f;
-}
-
-static bool depth_unproject(
- const ARegion *ar,
- const int mval[2], const double depth,
- float r_location_world[3])
-{
- float centx = (float)mval[0] + 0.5f;
- float centy = (float)mval[1] + 0.5f;
- return ED_view3d_unproject(ar, centx, centy, depth, r_location_world);
-}
-
-static bool depth_read_normal(
- const ViewContext *vc, const int mval[2],
- float r_normal[3])
-{
- /* pixels surrounding */
- bool depths_valid[9] = {false};
- float coords[9][3] = {{0}};
-
- ARegion *ar = vc->ar;
- const ViewDepths *depths = vc->rv3d->depths;
-
- for (int x = 0, i = 0; x < 2; x++) {
- for (int y = 0; y < 2; y++) {
- const int mval_ofs[2] = {mval[0] + (x - 1), mval[1] + (y - 1)};
-
- const double depth = (double)depth_read_zbuf(vc, mval_ofs[0], mval_ofs[1]);
- if ((depth > depths->depth_range[0]) && (depth < depths->depth_range[1])) {
- if (depth_unproject(ar, mval_ofs, depth, coords[i])) {
- depths_valid[i] = true;
- }
- }
- i++;
- }
- }
-
- const int edges[2][6][2] = {
- /* x edges */
- {{0, 1}, {1, 2},
- {3, 4}, {4, 5},
- {6, 7}, {7, 8}},
- /* y edges */
- {{0, 3}, {3, 6},
- {1, 4}, {4, 7},
- {2, 5}, {5, 8}},
- };
-
- float cross[2][3] = {{0.0f}};
-
- for (int i = 0; i < 6; i++) {
- for (int axis = 0; axis < 2; axis++) {
- if (depths_valid[edges[axis][i][0]] && depths_valid[edges[axis][i][1]]) {
- float delta[3];
- sub_v3_v3v3(delta, coords[edges[axis][i][0]], coords[edges[axis][i][1]]);
- add_v3_v3(cross[axis], delta);
- }
- }
- }
-
- cross_v3_v3v3(r_normal, cross[0], cross[1]);
-
- if (normalize_v3(r_normal) != 0.0f) {
- return true;
- }
- else {
- return false;
- }
-}
-
-/** \} */
-
-
/* -------------------------------------------------------------------- */
/** \name StrokeElem / #RNA_OperatorStrokeElement Conversion Functions
@@ -304,9 +216,9 @@ static bool stroke_elem_project(
((unsigned int)mval_i[0] < depths->w) &&
((unsigned int)mval_i[1] < depths->h))
{
- const double depth = (double)depth_read_zbuf(&cdd->vc, mval_i[0], mval_i[1]);
+ const double depth = (double)ED_view3d_depth_read_cached(&cdd->vc, mval_i);
if ((depth > depths->depth_range[0]) && (depth < depths->depth_range[1])) {
- if (depth_unproject(ar, mval_i, depth, r_location_world)) {
+ if (ED_view3d_depth_unproject(ar, mval_i, depth, r_location_world)) {
is_location_world_set = true;
if (r_normal_world) {
zero_v3(r_normal_world);
@@ -315,7 +227,7 @@ static bool stroke_elem_project(
if (surface_offset != 0.0f) {
const float offset = cdd->project.use_surface_offset_absolute ? 1.0f : radius;
float normal[3];
- if (depth_read_normal(&cdd->vc, mval_i, normal)) {
+ if (ED_view3d_depth_read_cached_normal(&cdd->vc, mval_i, normal)) {
madd_v3_v3fl(r_location_world, normal, offset * surface_offset);
if (r_normal_world) {
copy_v3_v3(r_normal_world, normal);
@@ -471,8 +383,8 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS
float color[3];
UI_GetThemeColor3fv(TH_WIRE, color);
- Gwn_Batch *sphere = Batch_get_sphere(0);
- Batch_set_builtin_program(sphere, GPU_SHADER_3D_UNIFORM_COLOR);
+ Gwn_Batch *sphere = GPU_batch_preset_sphere(0);
+ GWN_batch_program_set_builtin(sphere, GPU_SHADER_3D_UNIFORM_COLOR);
GWN_batch_uniform_3fv(sphere, "color", color);
/* scale to edit-mode space */
@@ -642,7 +554,7 @@ static void curve_draw_event_add_first(wmOperator *op, const wmEvent *event)
CURVE_PAINT_SURFACE_PLANE_NORMAL_VIEW,
CURVE_PAINT_SURFACE_PLANE_NORMAL_SURFACE))
{
- if (depth_read_normal(&cdd->vc, event->mval, normal)) {
+ if (ED_view3d_depth_read_cached_normal(&cdd->vc, event->mval, normal)) {
if (cps->surface_plane == CURVE_PAINT_SURFACE_PLANE_NORMAL_VIEW) {
float cross_a[3], cross_b[3];
cross_v3_v3v3(cross_a, rv3d->viewinv[2], normal);
@@ -1179,10 +1091,13 @@ static int curve_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event)
if ((cps->depth_mode == CURVE_PAINT_PROJECT_SURFACE) &&
(v3d->drawtype > OB_WIRE))
{
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
/* needed or else the draw matrix can be incorrect */
view3d_operator_needs_opengl(C);
- ED_view3d_autodist_init(cdd->vc.depsgraph, cdd->vc.ar, cdd->vc.v3d, 0);
+ ED_view3d_autodist_init(&eval_ctx, cdd->vc.depsgraph, cdd->vc.ar, cdd->vc.v3d, 0);
if (cdd->vc.rv3d->depths) {
cdd->vc.rv3d->depths->damaged = true;
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c
index c18f1408387..e6447bf100c 100644
--- a/source/blender/editors/curve/editfont.c
+++ b/source/blender/editors/curve/editfont.c
@@ -424,6 +424,7 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, const
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
SceneLayer *sl = CTX_data_scene_layer(C);
+ EvaluationContext eval_ctx;
Curve *cu;
Object *obedit;
Base *base;
@@ -433,13 +434,15 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, const
int a;
float rot[3] = {0.f, 0.f, 0.f};
+ CTX_data_eval_ctx(C, &eval_ctx);
+
obedit = BKE_object_add(bmain, scene, sl, OB_FONT, NULL);
base = sl->basact;
/* seems to assume view align ? TODO - look into this, could be an operator option */
ED_object_base_init_transform(C, base, NULL, rot);
- BKE_object_where_is_calc(scene, obedit);
+ BKE_object_where_is_calc(&eval_ctx, scene, obedit);
add_v3_v3(obedit->loc, offset);
@@ -1174,9 +1177,10 @@ void FONT_OT_line_break(wmOperatorType *ot)
/******************* delete operator **********************/
static EnumPropertyItem delete_type_items[] = {
- {DEL_ALL, "ALL", 0, "All", ""},
{DEL_NEXT_CHAR, "NEXT_CHARACTER", 0, "Next Character", ""},
{DEL_PREV_CHAR, "PREVIOUS_CHARACTER", 0, "Previous Character", ""},
+ {DEL_NEXT_WORD, "NEXT_WORD", 0, "Next Word", ""},
+ {DEL_PREV_WORD, "PREVIOUS_WORD", 0, "Previous Word", ""},
{DEL_SELECTION, "SELECTION", 0, "Selection", ""},
{DEL_NEXT_SEL, "NEXT_OR_SELECTION", 0, "Next or Selection", ""},
{DEL_PREV_SEL, "PREVIOUS_OR_SELECTION", 0, "Previous or Selection", ""},
@@ -1187,7 +1191,9 @@ static int delete_exec(bContext *C, wmOperator *op)
Object *obedit = CTX_data_edit_object(C);
Curve *cu = obedit->data;
EditFont *ef = cu->editfont;
- int x, selstart, selend, type = RNA_enum_get(op->ptr, "type");
+ int selstart, selend, type = RNA_enum_get(op->ptr, "type");
+ int range[2] = {0, 0};
+ bool has_select = false;
if (ef->len == 0)
return OPERATOR_CANCELLED;
@@ -1195,6 +1201,7 @@ static int delete_exec(bContext *C, wmOperator *op)
if (BKE_vfont_select_get(obedit, &selstart, &selend)) {
if (type == DEL_NEXT_SEL) type = DEL_SELECTION;
else if (type == DEL_PREV_SEL) type = DEL_SELECTION;
+ has_select = true;
}
else {
if (type == DEL_NEXT_SEL) type = DEL_NEXT_CHAR;
@@ -1202,10 +1209,6 @@ static int delete_exec(bContext *C, wmOperator *op)
}
switch (type) {
- case DEL_ALL:
- ef->len = ef->pos = 0;
- ef->textbuf[0] = 0;
- break;
case DEL_SELECTION:
if (!kill_selection(obedit, 0))
return OPERATOR_CANCELLED;
@@ -1214,29 +1217,69 @@ static int delete_exec(bContext *C, wmOperator *op)
if (ef->pos <= 0)
return OPERATOR_CANCELLED;
- for (x = ef->pos; x <= ef->len; x++)
- ef->textbuf[x - 1] = ef->textbuf[x];
- for (x = ef->pos; x <= ef->len; x++)
- ef->textbufinfo[x - 1] = ef->textbufinfo[x];
+ range[0] = ef->pos - 1;
+ range[1] = ef->pos;
ef->pos--;
- ef->textbuf[--ef->len] = '\0';
break;
case DEL_NEXT_CHAR:
if (ef->pos >= ef->len)
return OPERATOR_CANCELLED;
- for (x = ef->pos; x < ef->len; x++)
- ef->textbuf[x] = ef->textbuf[x + 1];
- for (x = ef->pos; x < ef->len; x++)
- ef->textbufinfo[x] = ef->textbufinfo[x + 1];
+ range[0] = ef->pos;
+ range[1] = ef->pos + 1;
+ break;
+ case DEL_NEXT_WORD:
+ {
+ int pos = ef->pos;
+ BLI_str_cursor_step_wchar(ef->textbuf, ef->len, &pos, STRCUR_DIR_NEXT, STRCUR_JUMP_DELIM, true);
+ range[0] = ef->pos;
+ range[1] = pos;
+ break;
+ }
- ef->textbuf[--ef->len] = '\0';
+ case DEL_PREV_WORD:
+ {
+ int pos = ef->pos;
+ BLI_str_cursor_step_wchar(ef->textbuf, ef->len, &pos, STRCUR_DIR_PREV, STRCUR_JUMP_DELIM, true);
+ range[0] = pos;
+ range[1] = ef->pos;
+ ef->pos = pos;
break;
+ }
default:
return OPERATOR_CANCELLED;
}
+ if (range[0] != range[1]) {
+ BLI_assert(range[0] < range[1]);
+ int len_remove = range[1] - range[0];
+ int len_tail = ef->len - range[1];
+ if (has_select) {
+ for (int i = 0; i < 2; i++) {
+ int *sel = i ? &ef->selend : &ef->selstart;
+ if (*sel <= range[0]) {
+ /* pass */
+ }
+ else if (*sel >= range[1]) {
+ *sel -= len_remove;
+ }
+ else if (*sel < range[1]) {
+ /* pass */
+ *sel = range[0];
+ }
+ }
+ }
+
+ memmove(&ef->textbuf[range[0]], &ef->textbuf[range[1]], sizeof(*ef->textbuf) * len_tail);
+ memmove(&ef->textbufinfo[range[0]], &ef->textbufinfo[range[1]], sizeof(*ef->textbufinfo) * len_tail);
+
+ ef->len -= len_remove;
+ ef->textbuf[ef->len] = '\0';
+
+ BKE_vfont_select_clamp(obedit);
+ }
+
text_update_edited(C, obedit, FO_EDIT);
return OPERATOR_FINISHED;
@@ -1257,7 +1300,7 @@ void FONT_OT_delete(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
- RNA_def_enum(ot->srna, "type", delete_type_items, DEL_ALL, "Type", "Which part of the text to delete");
+ RNA_def_enum(ot->srna, "type", delete_type_items, DEL_PREV_CHAR, "Type", "Which part of the text to delete");
}
/*********************** insert text operator *************************/
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index 96f9959af02..63c15744388 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -1702,10 +1702,10 @@ void ED_gpencil_draw_view3d(wmWindowManager *wm, Scene *scene, View3D *v3d, AReg
rctf rectf;
ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &rectf, true); /* no shift */
- offsx = iroundf(rectf.xmin);
- offsy = iroundf(rectf.ymin);
- winx = iroundf(rectf.xmax - rectf.xmin);
- winy = iroundf(rectf.ymax - rectf.ymin);
+ offsx = round_fl_to_int(rectf.xmin);
+ offsy = round_fl_to_int(rectf.ymin);
+ winx = round_fl_to_int(rectf.xmax - rectf.xmin);
+ winy = round_fl_to_int(rectf.ymax - rectf.ymin);
}
else {
offsx = 0;
diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c
index bd4856f1b93..90d44503013 100644
--- a/source/blender/editors/gpencil/editaction_gpencil.c
+++ b/source/blender/editors/gpencil/editaction_gpencil.c
@@ -252,8 +252,10 @@ bool ED_gplayer_frames_delete(bGPDlayer *gpl)
for (gpf = gpl->frames.first; gpf; gpf = gpfn) {
gpfn = gpf->next;
- if (gpf->flag & GP_FRAME_SELECT)
- changed |= BKE_gpencil_layer_delframe(gpl, gpf);
+ if (gpf->flag & GP_FRAME_SELECT) {
+ BKE_gpencil_layer_delframe(gpl, gpf);
+ changed = true;
+ }
}
return changed;
@@ -314,7 +316,7 @@ void ED_gplayer_frames_keytype_set(bGPDlayer *gpl, short type)
*/
/* globals for copy/paste data (like for other copy/paste buffers) */
-ListBase gp_anim_copybuf = {NULL, NULL};
+static ListBase gp_anim_copybuf = {NULL, NULL};
static int gp_anim_copy_firstframe = 999999999;
static int gp_anim_copy_lastframe = -999999999;
static int gp_anim_copy_cfra = 0;
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index f478596deec..1cee8db792a 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -710,7 +710,7 @@ static bool gp_brush_randomize_apply(tGP_BrushEditData *gso, bGPDstroke *gps, in
}
else {
/* ERROR */
- BLI_assert("3D stroke being sculpted in non-3D view");
+ BLI_assert(!"3D stroke being sculpted in non-3D view");
}
}
else {
@@ -991,11 +991,11 @@ static void gp_brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customda
/* Inner Ring: Light color for action of the brush */
/* TODO: toggle between add and remove? */
immUniformColor4ub(255, 255, 255, 200);
- imm_draw_circle_wire(pos, x, y, brush->size, 40);
+ imm_draw_circle_wire_2d(pos, x, y, brush->size, 40);
/* Outer Ring: Dark color for contrast on light backgrounds (e.g. gray on white) */
immUniformColor3ub(30, 30, 30);
- imm_draw_circle_wire(pos, x, y, brush->size + 1, 40);
+ imm_draw_circle_wire_2d(pos, x, y, brush->size + 1, 40);
immUnbindProgram();
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 6310cab9e4e..4cd628b7fd3 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -79,6 +79,8 @@
#include "ED_view3d.h"
#include "ED_space_api.h"
+#include "DEG_depsgraph.h"
+
#include "gpencil_intern.h"
/* ************************************************ */
@@ -343,7 +345,7 @@ ListBase gp_strokes_copypastebuf = {NULL, NULL};
* This is needed to prevent dangling and unsafe pointers when pasting across datablocks,
* or after a color used by a stroke in the buffer gets deleted (via user action or undo).
*/
-GHash *gp_strokes_copypastebuf_colors = NULL;
+static GHash *gp_strokes_copypastebuf_colors = NULL;
/* Free copy/paste buffer data */
void ED_gpencil_strokes_copybuf_free(void)
@@ -2106,9 +2108,12 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
/* init autodist for geometry projection */
if (mode == GP_REPROJECT_SURFACE) {
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
struct Depsgraph *graph = CTX_data_depsgraph(C);
view3d_region_operator_needs_opengl(CTX_wm_window(C), gsc.ar);
- ED_view3d_autodist_init(graph, gsc.ar, CTX_wm_view3d(C), 0);
+ ED_view3d_autodist_init(&eval_ctx, graph, gsc.ar, CTX_wm_view3d(C), 0);
}
// TODO: For deforming geometry workflow, create new frames?
diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil/gpencil_interpolate.c
index 59b5b41f114..83e2a85db49 100644
--- a/source/blender/editors/gpencil/gpencil_interpolate.c
+++ b/source/blender/editors/gpencil/gpencil_interpolate.c
@@ -117,8 +117,8 @@ static void gp_interpolate_update_points(bGPDstroke *gps_from, bGPDstroke *gps_t
/* Interpolate all values */
interp_v3_v3v3(&pt->x, &prev->x, &next->x, factor);
- pt->pressure = interpf(prev->pressure, next->pressure, factor);
- pt->strength = interpf(prev->strength, next->strength, factor);
+ pt->pressure = interpf(prev->pressure, next->pressure, 1.0f - factor);
+ pt->strength = interpf(prev->strength, next->strength, 1.0f - factor);
CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f);
}
}
@@ -284,7 +284,9 @@ static void gp_interpolate_set_points(bContext *C, tGPDinterpolate *tgpi)
new_stroke = MEM_dupallocN(gps_from);
new_stroke->points = MEM_dupallocN(gps_from->points);
new_stroke->triangles = MEM_dupallocN(gps_from->triangles);
-
+ new_stroke->tot_triangles = 0;
+ new_stroke->flag |= GP_STROKE_RECALC_CACHES;
+
if (valid) {
/* if destination stroke is smaller, resize new_stroke to size of gps_to stroke */
if (gps_from->totpoints > gps_to->totpoints) {
@@ -302,6 +304,7 @@ static void gp_interpolate_set_points(bContext *C, tGPDinterpolate *tgpi)
new_stroke->points = MEM_recallocN(new_stroke->points, sizeof(*new_stroke->points));
new_stroke->tot_triangles = 0;
new_stroke->triangles = MEM_recallocN(new_stroke->triangles, sizeof(*new_stroke->triangles));
+ new_stroke->flag |= GP_STROKE_RECALC_CACHES;
}
/* add to strokes */
@@ -986,7 +989,9 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
new_stroke = MEM_dupallocN(gps_from);
new_stroke->points = MEM_dupallocN(gps_from->points);
new_stroke->triangles = MEM_dupallocN(gps_from->triangles);
-
+ new_stroke->tot_triangles = 0;
+ new_stroke->flag |= GP_STROKE_RECALC_CACHES;
+
/* if destination stroke is smaller, resize new_stroke to size of gps_to stroke */
if (gps_from->totpoints > gps_to->totpoints) {
new_stroke->points = MEM_recallocN(new_stroke->points, sizeof(*new_stroke->points) * gps_to->totpoints);
diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c
index 78e1a0dda36..3a2169798e5 100644
--- a/source/blender/editors/gpencil/gpencil_ops.c
+++ b/source/blender/editors/gpencil/gpencil_ops.c
@@ -99,8 +99,8 @@ static void ed_keymap_gpencil_general(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "GPENCIL_OT_editmode_toggle", TABKEY, KM_PRESS, 0, DKEY);
/* Pie Menu - For standard tools */
- WM_keymap_add_menu_pie(keymap, "GPENCIL_PIE_tool_palette", QKEY, KM_PRESS, 0, DKEY);
- WM_keymap_add_menu_pie(keymap, "GPENCIL_PIE_settings_palette", WKEY, KM_PRESS, 0, DKEY);
+ WM_keymap_add_menu_pie(keymap, "GPENCIL_MT_pie_tool_palette", QKEY, KM_PRESS, 0, DKEY);
+ WM_keymap_add_menu_pie(keymap, "GPENCIL_MT_pie_settings_palette", WKEY, KM_PRESS, 0, DKEY);
/* Add Blank Frame */
/* XXX: BKEY or NKEY? BKEY is easier to reach from DKEY, so we'll use that for now */
@@ -135,7 +135,7 @@ static void ed_keymap_gpencil_editing(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "GPENCIL_OT_editmode_toggle", TABKEY, KM_PRESS, 0, 0);
/* Pie Menu - For settings/tools easy access */
- WM_keymap_add_menu_pie(keymap, "GPENCIL_PIE_sculpt", EKEY, KM_PRESS, 0, DKEY);
+ WM_keymap_add_menu_pie(keymap, "GPENCIL_MT_pie_sculpt", EKEY, KM_PRESS, 0, DKEY);
/* Brush Settings */
/* NOTE: We cannot expose these in the standard keymap, as they will interfere with regular hotkeys
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index b46095d3abb..e0751985bcd 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -80,6 +80,8 @@
#include "WM_api.h"
#include "WM_types.h"
+#include "DEG_depsgraph.h"
+
#include "gpencil_intern.h"
/* ******************************************* */
@@ -114,6 +116,7 @@ typedef enum eGPencil_PaintFlags {
* "p" = op->customdata
*/
typedef struct tGPsdata {
+ EvaluationContext eval_ctx;
Scene *scene; /* current scene from context */
struct Depsgraph *graph;
@@ -484,7 +487,8 @@ static void gp_brush_angle(bGPdata *gpd, bGPDbrush *brush, tGPspoint *pt, const
}
/* add current stroke-point to buffer (returns whether point was successfully added) */
-static short gp_stroke_addpoint(tGPsdata *p, const int mval[2], float pressure, double curtime)
+static short gp_stroke_addpoint(
+ tGPsdata *p, const int mval[2], float pressure, double curtime)
{
bGPdata *gpd = p->gpd;
bGPDbrush *brush = p->brush;
@@ -643,7 +647,7 @@ static short gp_stroke_addpoint(tGPsdata *p, const int mval[2], float pressure,
view3d_region_operator_needs_opengl(p->win, p->ar);
ED_view3d_autodist_init(
- p->graph, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0);
+ &p->eval_ctx, p->graph, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0);
}
/* convert screen-coordinates to appropriate coordinates (and store them) */
@@ -739,7 +743,7 @@ static void gp_stroke_simplify(tGPsdata *p)
/* ignore return values on this... assume to be ok for now */
gp_stroke_addpoint(p, mco, pressure, p->inittime + (double)time);
-
+
j += 2;
}
}
@@ -1244,7 +1248,7 @@ static void gp_stroke_doeraser(tGPsdata *p)
if (p->flags & GP_PAINTFLAG_V3D_ERASER_DEPTH) {
View3D *v3d = p->sa->spacedata.first;
view3d_region_operator_needs_opengl(p->win, p->ar);
- ED_view3d_autodist_init(p->graph, p->ar, v3d, 0);
+ ED_view3d_autodist_init(&p->eval_ctx, p->graph, p->ar, v3d, 0);
}
}
@@ -1397,6 +1401,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
}
/* pass on current scene and window */
+ CTX_data_eval_ctx(C, &p->eval_ctx);
p->scene = CTX_data_scene(C);
p->graph = CTX_data_depsgraph(C);
p->win = CTX_wm_window(C);
@@ -1811,14 +1816,14 @@ static void gp_paint_strokeend(tGPsdata *p)
/* need to restore the original projection settings before packing up */
view3d_region_operator_needs_opengl(p->win, p->ar);
- ED_view3d_autodist_init(p->graph, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0);
+ ED_view3d_autodist_init(&p->eval_ctx, p->graph, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0);
}
/* check if doing eraser or not */
if ((p->gpd->sbuffer_sflag & GP_STROKE_ERASER) == 0) {
/* simplify stroke before transferring? */
gp_stroke_simplify(p);
-
+
/* transfer stroke to frame */
gp_stroke_newfrombuffer(p);
}
@@ -1860,11 +1865,11 @@ static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
immUniformColor4ub(255, 100, 100, 20);
- imm_draw_circle_fill(shdr_pos, x, y, p->radius, 40);
+ imm_draw_circle_fill_2d(shdr_pos, x, y, p->radius, 40);
immUnbindProgram();
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
@@ -1875,7 +1880,7 @@ static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr)
immUniform1f("dash_width", 12.0f);
immUniform1f("dash_factor", 0.5f);
- imm_draw_circle_wire(shdr_pos, x, y, p->radius,
+ imm_draw_circle_wire_2d(shdr_pos, x, y, p->radius,
/* XXX Dashed shader gives bad results with sets of small segments currently,
* temp hack around the issue. :( */
max_ii(8, p->radius / 2)); /* was fixed 40 */
@@ -2057,7 +2062,7 @@ static void gpencil_draw_apply(wmOperator *op, tGPsdata *p)
if (p->paintmode == GP_PAINTMODE_ERASER) {
/* do 'live' erasing now */
gp_stroke_doeraser(p);
-
+
/* store used values */
p->mvalo[0] = p->mval[0];
p->mvalo[1] = p->mval[1];
@@ -2067,7 +2072,7 @@ static void gpencil_draw_apply(wmOperator *op, tGPsdata *p)
else if (gp_stroke_filtermval(p, p->mval, p->mvalo)) {
/* try to add point */
short ok = gp_stroke_addpoint(p, p->mval, p->pressure, p->curtime);
-
+
/* handle errors while adding point */
if ((ok == GP_STROKEADD_FULL) || (ok == GP_STROKEADD_OVERFLOW)) {
/* finish off old stroke */
@@ -2212,7 +2217,7 @@ static void gpencil_draw_apply_event(wmOperator *op, const wmEvent *event)
/* apply the current latest drawing point */
gpencil_draw_apply(op, p);
-
+
/* force refresh */
ED_region_tag_redraw(p->ar); /* just active area for now, since doing whole screen is too slow */
}
@@ -2388,9 +2393,9 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op)
static void gpencil_stroke_end(wmOperator *op)
{
tGPsdata *p = op->customdata;
-
+
gp_paint_cleanup(p);
-
+
gpencil_undo_push(p->gpd);
gp_session_cleanup(p);
@@ -2524,7 +2529,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* end stroke only, and then wait to resume painting soon */
/* printf("\t\tGP - end stroke only\n"); */
gpencil_stroke_end(op);
-
+
/* If eraser mode is on, turn it off after the stroke finishes
* NOTE: This just makes it nicer to work with drawing sessions
*/
@@ -2667,7 +2672,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* handle drawing event */
/* printf("\t\tGP - add point\n"); */
gpencil_draw_apply_event(op, event);
-
+
/* finish painting operation if anything went wrong just now */
if (p->status == GP_STATUS_ERROR) {
printf("\t\t\t\tGP - add error done!\n");
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 82892561daa..fae08bd771e 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -65,6 +65,8 @@
#include "ED_clip.h"
#include "ED_view3d.h"
+#include "DEG_depsgraph.h"
+
#include "gpencil_intern.h"
/* ******************************************************** */
@@ -538,11 +540,14 @@ void gp_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc)
View3D *v3d = (View3D *)CTX_wm_space_data(C);
RegionView3D *rv3d = ar->regiondata;
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
/* init 3d depth buffers */
view3d_operator_needs_opengl(C);
view3d_region_operator_needs_opengl(win, ar);
- ED_view3d_autodist_init(graph, ar, v3d, 0);
+ ED_view3d_autodist_init(&eval_ctx, graph, ar, v3d, 0);
/* for camera view set the subrect */
if (rv3d->persp == RV3D_CAMOB) {
diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h
index a65c6eec6ae..797262c685b 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -125,6 +125,15 @@ typedef struct bAnimListElem {
void *key_data; /* motion data - mostly F-Curves, but can be other types too */
+ /* NOTE: id here is the "IdAdtTemplate"-style datablock (e.g. Object, Material, Texture, NodeTree)
+ * from which evaluation of the RNA-paths takes place. It's used to figure out how deep
+ * channels should be nested (e.g. for Textures/NodeTrees) in the tree, and allows property
+ * lookups (e.g. for sliders and for inserting keyframes) to work. If we had instead used
+ * bAction or something similar, none of this would be possible: although it's trivial
+ * to use an IdAdtTemplate type to find the source action a channel (e.g. F-Curve) comes from
+ * (i.e. in the AnimEditors, it *must* be the active action, as only that can be edited),
+ * it's impossible to go the other way (i.e. one action may be used in multiple places).
+ */
struct ID *id; /* ID block that channel is attached to */
struct AnimData *adt; /* source of the animation data attached to ID block (for convenience) */
@@ -257,7 +266,7 @@ typedef enum eAnimFilter_Flags {
ANIMFILTER_TMP_PEEK = (1 << 30),
/* ignore ONLYSEL flag from filterflag, (internal use only!) */
- ANIMFILTER_TMP_IGNORE_ONLYSEL = (1 << 31)
+ ANIMFILTER_TMP_IGNORE_ONLYSEL = (1u << 31)
} eAnimFilter_Flags;
/* ---------- Flag Checking Macros ------------ */
diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h
index 7866bed8666..d65ea8e79f0 100644
--- a/source/blender/editors/include/ED_armature.h
+++ b/source/blender/editors/include/ED_armature.h
@@ -39,6 +39,7 @@ struct BaseLegacy;
struct bContext;
struct Bone;
struct bPoseChannel;
+struct EvaluationContext;
struct IDProperty;
struct ListBase;
struct MeshDeformModifierData;
@@ -166,16 +167,17 @@ void ED_armature_ebone_from_mat4(EditBone *ebone, float mat[4][4]);
void transform_armature_mirror_update(struct Object *obedit);
void ED_armature_origin_set(struct Scene *scene, struct Object *ob, float cursor[3], int centermode, int around);
-void ED_armature_transform_bones(struct bArmature *arm, float mat[4][4]);
-void ED_armature_apply_transform(struct Object *ob, float mat[4][4]);
-void ED_armature_transform(struct bArmature *arm, float mat[4][4]);
+void ED_armature_transform_bones(struct bArmature *arm, float mat[4][4], const bool do_props);
+void ED_armature_apply_transform(struct Object *ob, float mat[4][4], const bool do_props);
+void ED_armature_transform(struct bArmature *arm, float mat[4][4], const bool do_props);
#define ARM_GROUPS_NAME 1
#define ARM_GROUPS_ENVELOPE 2
#define ARM_GROUPS_AUTO 3
-void create_vgroups_from_armature(struct ReportList *reports, struct Scene *scene, struct Object *ob,
- struct Object *par, const int mode, const bool mirror);
+void create_vgroups_from_armature(
+ struct ReportList *reports, const struct EvaluationContext *eval_ctx, struct Scene *scene,
+ struct Object *ob, struct Object *par, const int mode, const bool mirror);
/* if bone is already in list, pass it as param to ignore it */
void unique_editbone_name(struct ListBase *ebones, char *name, EditBone *bone);
@@ -196,7 +198,7 @@ void ED_armature_exit_posemode(struct bContext *C, struct Base *base);
void ED_armature_enter_posemode(struct bContext *C, struct Base *base);
void ED_pose_de_selectall(struct Object *ob, int select_mode, const bool ignore_visibility);
void ED_pose_bone_select(struct Object *ob, struct bPoseChannel *pchan, bool select);
-void ED_pose_recalculate_paths(struct Scene *scene, struct Object *ob);
+void ED_pose_recalculate_paths(struct bContext *C, struct Scene *scene, struct Object *ob);
struct Object *ED_pose_object_from_context(struct bContext *C);
/* sketch */
diff --git a/source/blender/editors/include/ED_manipulator_library.h b/source/blender/editors/include/ED_manipulator_library.h
index b1970a7bab3..14e28e18ced 100644
--- a/source/blender/editors/include/ED_manipulator_library.h
+++ b/source/blender/editors/include/ED_manipulator_library.h
@@ -57,7 +57,8 @@ void ED_manipulator_draw_preset_arrow(
void ED_manipulator_draw_preset_circle(
const struct wmManipulator *mpr, float mat[4][4], int axis, int select_id);
void ED_manipulator_draw_preset_facemap(
- const struct wmManipulator *mpr, struct Scene *scene, struct Object *ob, const int facemap, int select_id);
+ const struct bContext *C, const struct wmManipulator *mpr, struct Scene *scene,
+ struct Object *ob, const int facemap, int select_id);
/* -------------------------------------------------------------------- */
@@ -89,10 +90,40 @@ void ED_manipulator_arrow3d_set_range_fac(struct wmManipulator *mpr, const float
/* Cage Manipulator */
enum {
- ED_MANIPULATOR_RECT_TRANSFORM_FLAG_TRANSLATE = (1 << 0), /* Manipulator translates */
- ED_MANIPULATOR_RECT_TRANSFORM_FLAG_ROTATE = (1 << 1), /* Manipulator rotates */
- ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE = (1 << 2), /* Manipulator scales */
- ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM = (1 << 3), /* Manipulator scales uniformly */
+ ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE = (1 << 0), /* Translates */
+ ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE = (1 << 1), /* Rotates */
+ ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE = (1 << 2), /* Scales */
+ ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM = (1 << 3), /* Scales uniformly */
+ ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_SIGNED = (1 << 4), /* Negative scale allowed */
+};
+
+/* draw_style */
+enum {
+ ED_MANIPULATOR_CAGE2D_STYLE_BOX = 0,
+ ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE = 1,
+};
+
+/* draw_options */
+enum {
+ /** Draw a central handle (instead of having the entire area selectable)
+ * Needed for large rectangles that we don't want to swallow all events. */
+ ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE = (1 << 0),
+};
+
+/** #wmManipulator.highlight_part */
+enum {
+ ED_MANIPULATOR_CAGE2D_PART_TRANSLATE = 0,
+ ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X = 1,
+ ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X = 2,
+ ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y = 3,
+ ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y = 4,
+ /* Corners */
+ ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y = 5,
+ ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y = 6,
+ ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y = 7,
+ ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y = 8,
+
+ ED_MANIPULATOR_CAGE2D_PART_ROTATE = 9,
};
/* -------------------------------------------------------------------- */
@@ -113,11 +144,14 @@ enum {
/* draw_options */
enum {
ED_MANIPULATOR_GRAB_DRAW_FLAG_NOP = 0,
+ /* only for solid shapes */
ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL = (1 << 0),
+ ED_MANIPULATOR_GRAB_DRAW_FLAG_ALIGN_VIEW = (1 << 1),
};
enum {
- ED_MANIPULATOR_GRAB_STYLE_RING = 0,
+ ED_MANIPULATOR_GRAB_STYLE_RING_2D = 0,
+ ED_MANIPULATOR_GRAB_STYLE_CROSS_2D = 1,
};
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h
index 0ee60471357..1703ec6194f 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -36,6 +36,7 @@ extern "C" {
#endif
struct ID;
+struct EvaluationContext;
struct View3D;
struct ARegion;
struct bContext;
@@ -134,35 +135,36 @@ void EDBM_select_mirrored(
int *r_totmirr, int *r_totfail);
void EDBM_automerge(struct Scene *scene, struct Object *ob, bool update, const char hflag);
-bool EDBM_backbuf_border_init(struct ViewContext *vc, short xmin, short ymin, short xmax, short ymax);
+bool EDBM_backbuf_border_init(const struct EvaluationContext *eval_ctx, struct ViewContext *vc, short xmin, short ymin, short xmax, short ymax);
bool EDBM_backbuf_check(unsigned int index);
void EDBM_backbuf_free(void);
-bool EDBM_backbuf_border_mask_init(struct ViewContext *vc, const int mcords[][2], short tot,
- short xmin, short ymin, short xmax, short ymax);
-bool EDBM_backbuf_circle_init(struct ViewContext *vc, short xs, short ys, short rads);
+bool EDBM_backbuf_border_mask_init(
+ const struct EvaluationContext *eval_ctx, struct ViewContext *vc, const int mcords[][2], short tot,
+ short xmin, short ymin, short xmax, short ymax);
+bool EDBM_backbuf_circle_init(const struct EvaluationContext *eval_ctx, struct ViewContext *vc, short xs, short ys, short rads);
struct BMVert *EDBM_vert_find_nearest_ex(
- struct ViewContext *vc, float *r_dist,
+ const struct EvaluationContext *eval_ctx, struct ViewContext *vc, float *r_dist,
const bool use_select_bias, bool use_cycle);
struct BMVert *EDBM_vert_find_nearest(
- struct ViewContext *vc, float *r_dist);
+ const struct EvaluationContext *eval_ctx, struct ViewContext *vc, float *r_dist);
struct BMEdge *EDBM_edge_find_nearest_ex(
- struct ViewContext *vc, float *r_dist,
+ const struct EvaluationContext *eval_ctx, struct ViewContext *vc, float *r_dist,
float *r_dist_center,
const bool use_select_bias, const bool use_cycle,
struct BMEdge **r_eed_zbuf);
struct BMEdge *EDBM_edge_find_nearest(
- struct ViewContext *vc, float *r_dist);
+ const struct EvaluationContext *eval_ctx, struct ViewContext *vc, float *r_dist);
struct BMFace *EDBM_face_find_nearest_ex(
- struct ViewContext *vc, float *r_dist,
+ const struct EvaluationContext *eval_ctx, struct ViewContext *vc, float *r_dist,
float *r_dist_center,
const bool use_select_bias, const bool use_cycle,
struct BMFace **r_efa_zbuf);
struct BMFace *EDBM_face_find_nearest(
- struct ViewContext *vc, float *r_dist);
+ const struct EvaluationContext *eval_ctx, struct ViewContext *vc, float *r_dist);
bool EDBM_select_pick(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle);
@@ -199,7 +201,7 @@ void EMBM_project_snap_verts(struct bContext *C, struct ARegion *ar, struct BMEd
/* editface.c */
void paintface_flush_flags(struct Object *ob, short flag);
bool paintface_mouse_select(struct bContext *C, struct Object *ob, const int mval[2], bool extend, bool deselect, bool toggle);
-int do_paintface_box_select(struct ViewContext *vc, struct rcti *rect, bool select, bool extend);
+int do_paintface_box_select(const struct EvaluationContext *eval_ctx, struct ViewContext *vc, struct rcti *rect, bool select, bool extend);
void paintface_deselect_all_visible(struct Object *ob, int action, bool flush_flags);
void paintface_select_linked(struct bContext *C, struct Object *ob, const int mval[2], const bool select);
bool paintface_minmax(struct Object *ob, float r_min[3], float r_max[3]);
@@ -281,6 +283,7 @@ bool ED_mesh_uv_texture_remove_active(struct Mesh *me);
bool ED_mesh_uv_texture_remove_named(struct Mesh *me, const char *name);
void ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me);
void ED_mesh_uv_loop_reset_ex(struct Mesh *me, const int layernum);
+bool ED_mesh_color_ensure(struct Mesh *me, const char *name);
int ED_mesh_color_add(struct Mesh *me, const char *name, const bool active_set);
bool ED_mesh_color_remove_index(struct Mesh *me, const int n);
bool ED_mesh_color_remove_active(struct Mesh *me);
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index 9e5d55dd031..56a91d9846c 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -88,7 +88,7 @@ extern struct EnumPropertyItem prop_clear_parent_types[];
extern struct EnumPropertyItem prop_make_parent_types[];
#endif
-bool ED_object_parent_set(struct ReportList *reports, struct Main *bmain, struct Scene *scene, struct Object *ob,
+bool ED_object_parent_set(struct ReportList *reports, const struct bContext *C, struct Scene *scene, struct Object *ob,
struct Object *par, int partype, const bool xmirror, const bool keep_transform,
const int vert_par[3]);
void ED_object_parent_clear(struct Object *ob, const int type);
@@ -200,7 +200,7 @@ int ED_object_modifier_move_down(struct ReportList *reports, struct Object *ob,
int ED_object_modifier_move_up(struct ReportList *reports, struct Object *ob, struct ModifierData *md);
int ED_object_modifier_convert(struct ReportList *reports, struct Main *bmain, struct Scene *scene,
struct SceneLayer *sl, struct Object *ob, struct ModifierData *md);
-int ED_object_modifier_apply(struct ReportList *reports, struct Scene *scene,
+int ED_object_modifier_apply(struct ReportList *reports, const struct bContext *C, struct Scene *scene,
struct Object *ob, struct ModifierData *md, int mode);
int ED_object_modifier_copy(struct ReportList *reports, struct Object *ob, struct ModifierData *md);
diff --git a/source/blender/editors/include/ED_particle.h b/source/blender/editors/include/ED_particle.h
index 41c746aa421..f8bd8a22897 100644
--- a/source/blender/editors/include/ED_particle.h
+++ b/source/blender/editors/include/ED_particle.h
@@ -46,14 +46,16 @@ int PE_start_edit(struct PTCacheEdit *edit);
/* access */
struct PTCacheEdit *PE_get_current(struct Scene *scene, struct SceneLayer *sl, struct Object *ob);
-struct PTCacheEdit *PE_create_current(struct Scene *scene, struct Object *ob);
-void PE_current_changed(struct Scene *scene, struct Object *ob);
+struct PTCacheEdit *PE_create_current(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
+void PE_current_changed(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
int PE_minmax(struct Scene *scene, struct SceneLayer *sl, float min[3], float max[3]);
struct ParticleEditSettings *PE_settings(struct Scene *scene);
/* update calls */
void PE_hide_keys_time(struct Scene *scene, struct PTCacheEdit *edit, float cfra);
-void PE_update_object(struct Scene *scene, struct SceneLayer *sl, struct Object *ob, int useflag);
+void PE_update_object(
+ const struct EvaluationContext *eval_ctx, struct Scene *scene,
+ struct SceneLayer *sl, struct Object *ob, int useflag);
/* selection tools */
int PE_mouse_particles(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle);
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index 524ee01c30f..7ebf0e921ac 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -140,7 +140,7 @@ struct WorkSpace *ED_workspace_duplicate(
bool ED_workspace_delete(
struct WorkSpace *workspace,
struct Main *bmain, struct bContext *C,
- struct wmWindowManager *wm, struct wmWindow *win) ATTR_NONNULL();
+ struct wmWindowManager *wm) ATTR_NONNULL();
void ED_workspace_scene_data_sync(
struct WorkSpaceInstanceHook *hook, Scene *scene) ATTR_NONNULL();
void ED_workspace_render_layer_unset(
diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h
index 483caf7c475..c6702ae3eaf 100644
--- a/source/blender/editors/include/ED_transform.h
+++ b/source/blender/editors/include/ED_transform.h
@@ -151,7 +151,8 @@ int BIF_countTransformOrientation(const struct bContext *C);
#define P_CORRECT_UV (1 << 8)
#define P_NO_DEFAULTS (1 << 10)
#define P_NO_TEXSPACE (1 << 11)
-#define P_GPENCIL_EDIT (1 << 12)
+#define P_CENTER (1 << 12)
+#define P_GPENCIL_EDIT (1 << 13)
void Transform_Properties(struct wmOperatorType *ot, int flags);
@@ -167,12 +168,6 @@ void ED_widgetgroup_manipulator2d_draw_prepare(const struct bContext *C, struct
/* Snapping */
-typedef enum SnapSelect {
- SNAP_ALL = 0,
- SNAP_NOT_SELECTED = 1,
- SNAP_NOT_ACTIVE = 2,
-} SnapSelect;
-
#define SNAP_MIN_DISTANCE 30
bool peelObjectsTransform(
@@ -195,11 +190,7 @@ bool snapObjectsTransform(
/* return args */
float r_loc[3], float r_no[3]);
bool snapNodesTransform(
- struct TransInfo *t, const int mval[2], SnapSelect snap_select,
- /* return args */
- float r_loc[2], float *r_dist_px, char *r_node_border);
-bool snapNodesContext(
- struct bContext *C, const int mval[2], SnapSelect snap_select,
+ struct TransInfo *t, const int mval[2],
/* return args */
float r_loc[2], float *r_dist_px, char *r_node_border);
diff --git a/source/blender/editors/include/ED_transform_snap_object_context.h b/source/blender/editors/include/ED_transform_snap_object_context.h
index 010f7929e90..b802694444b 100644
--- a/source/blender/editors/include/ED_transform_snap_object_context.h
+++ b/source/blender/editors/include/ED_transform_snap_object_context.h
@@ -36,11 +36,18 @@ struct Main;
struct Object;
struct ARegion;
struct View3D;
+struct bContext;
/* transform_snap_object.c */
/* ED_transform_snap_object_*** API */
+typedef enum SnapSelect {
+ SNAP_ALL = 0,
+ SNAP_NOT_SELECTED = 1,
+ SNAP_NOT_ACTIVE = 2,
+} SnapSelect;
+
/** used for storing multiple hits */
struct SnapObjectHitDepth {
struct SnapObjectHitDepth *next, *prev;
@@ -85,7 +92,6 @@ void ED_transform_snap_object_context_set_editmesh_callbacks(
bool ED_transform_snap_object_project_ray_ex(
struct SnapObjectContext *sctx,
- const unsigned short snap_to,
const struct SnapObjectParams *params,
const float ray_start[3], const float ray_normal[3], float *ray_depth,
/* return args */
@@ -99,7 +105,6 @@ bool ED_transform_snap_object_project_ray(
bool ED_transform_snap_object_project_ray_all(
SnapObjectContext *sctx,
- const unsigned short snap_to,
const struct SnapObjectParams *params,
const float ray_start[3], const float ray_normal[3],
float ray_depth, bool sort,
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index 69d27e30b1f..0dcfd68c0f1 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -42,6 +42,7 @@ struct BezTriple;
struct BoundBox;
struct Depsgraph;
struct EditBone;
+struct EvaluationContext;
struct ImBuf;
struct MVert;
struct Main;
@@ -109,7 +110,14 @@ void ED_view3d_lastview_store(struct RegionView3D *rv3d);
/* Depth buffer */
void ED_view3d_depth_update(struct ARegion *ar);
-float ED_view3d_depth_read_cached(const struct ViewContext *vc, int x, int y);
+float ED_view3d_depth_read_cached(const struct ViewContext *vc, const int mval[2]);
+bool ED_view3d_depth_read_cached_normal(
+ const ViewContext *vc, const int mval[2],
+ float r_normal[3]);
+bool ED_view3d_depth_unproject(
+ const struct ARegion *ar,
+ const int mval[2], const double depth,
+ float r_location_world[3]);
void ED_view3d_depth_tag_update(struct RegionView3D *rv3d);
/* Projection */
@@ -144,20 +152,20 @@ typedef enum {
/* foreach iterators */
void meshobject_foreachScreenVert(
- struct ViewContext *vc,
+ const struct EvaluationContext *eval_ctx, struct ViewContext *vc,
void (*func)(void *userData, struct MVert *eve, const float screen_co[2], int index),
void *userData, const eV3DProjTest clip_flag);
void mesh_foreachScreenVert(
- struct ViewContext *vc,
+ const struct EvaluationContext *eval_ctx, struct ViewContext *vc,
void (*func)(void *userData, struct BMVert *eve, const float screen_co[2], int index),
void *userData, const eV3DProjTest clip_flag);
void mesh_foreachScreenEdge(
- struct ViewContext *vc,
+ const struct EvaluationContext *eval_ctx, struct ViewContext *vc,
void (*func)(void *userData, struct BMEdge *eed, const float screen_co_a[2], const float screen_co_b[2],
int index),
void *userData, const eV3DProjTest clip_flag);
void mesh_foreachScreenFace(
- struct ViewContext *vc,
+ const struct EvaluationContext *eval_ctx, struct ViewContext *vc,
void (*func)(void *userData, struct BMFace *efa, const float screen_co[2], int index),
void *userData, const eV3DProjTest clip_flag);
void nurbs_foreachScreenVert(
@@ -287,21 +295,23 @@ float ED_view3d_radius_to_dist(
void imm_drawcircball(const float cent[3], float rad, const float tmat[4][4], unsigned pos);
/* backbuffer select and draw support */
-void ED_view3d_backbuf_validate(struct ViewContext *vc);
-struct ImBuf *ED_view3d_backbuf_read(struct ViewContext *vc, int xmin, int ymin, int xmax, int ymax);
+void ED_view3d_backbuf_validate(const struct EvaluationContext *eval_ctx, struct ViewContext *vc);
+struct ImBuf *ED_view3d_backbuf_read(
+ const struct EvaluationContext *eval_ctx, struct ViewContext *vc, int xmin, int ymin, int xmax, int ymax);
unsigned int ED_view3d_backbuf_sample_rect(
- struct ViewContext *vc, const int mval[2], int size,
+ const struct EvaluationContext *eval_ctx, struct ViewContext *vc, const int mval[2], int size,
unsigned int min, unsigned int max, float *r_dist);
int ED_view3d_backbuf_sample_size_clamp(struct ARegion *ar, const float dist);
-unsigned int ED_view3d_backbuf_sample(struct ViewContext *vc, int x, int y);
+unsigned int ED_view3d_backbuf_sample(
+ const struct EvaluationContext *eval_ctx, struct ViewContext *vc, int x, int y);
bool ED_view3d_autodist(
- struct Depsgraph *graph, struct ARegion *ar, struct View3D *v3d,
+ const struct EvaluationContext *eval_ctx, struct Depsgraph *graph, struct ARegion *ar, struct View3D *v3d,
const int mval[2], float mouse_worldloc[3],
const bool alphaoverride, const float fallback_depth_pt[3]);
/* only draw so ED_view3d_autodist_simple can be called many times after */
-void ED_view3d_autodist_init(struct Depsgraph *graph, struct ARegion *ar, struct View3D *v3d, int mode);
+void ED_view3d_autodist_init(const struct EvaluationContext *eval_ctx, struct Depsgraph *graph, struct ARegion *ar, struct View3D *v3d, int mode);
bool ED_view3d_autodist_simple(struct ARegion *ar, const int mval[2], float mouse_worldloc[3], int margin, float *force_depth);
bool ED_view3d_autodist_depth(struct ARegion *ar, const int mval[2], int margin, float *depth);
bool ED_view3d_autodist_depth_seg(struct ARegion *ar, const int mval_sta[2], const int mval_end[2], int margin, float *depth);
@@ -323,7 +333,7 @@ void view3d_opengl_select_cache_begin(void);
void view3d_opengl_select_cache_end(void);
int view3d_opengl_select(
- struct ViewContext *vc, unsigned int *buffer, unsigned int bufsize, const struct rcti *input,
+ const struct EvaluationContext *eval_ctx, struct ViewContext *vc, unsigned int *buffer, unsigned int bufsize, const struct rcti *input,
eV3DSelectMode select_mode);
/* view3d_select.c */
@@ -355,26 +365,27 @@ int ED_view3d_scene_layer_set(int lay, const int *values, int *active);
struct RV3DMatrixStore *ED_view3d_mats_rv3d_backup(struct RegionView3D *rv3d);
void ED_view3d_mats_rv3d_restore(struct RegionView3D *rv3d, struct RV3DMatrixStore *rv3dmat);
-void ED_draw_object_facemap(struct Scene *scene, struct Object *ob, const float col[4], const int facemap);
+void ED_draw_object_facemap(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, const float col[4], const int facemap);
bool ED_view3d_context_activate(struct bContext *C);
-void ED_view3d_draw_offscreen_init(struct Scene *scene, struct SceneLayer *sl, struct View3D *v3d);
+void ED_view3d_draw_offscreen_init(
+ const struct EvaluationContext *eval_ctx, struct Scene *scene, struct SceneLayer *sl, struct View3D *v3d);
void ED_view3d_draw_offscreen(
- struct Scene *scene, struct View3D *v3d, struct ARegion *ar, int winx, int winy, float viewmat[4][4],
+ const struct EvaluationContext *eval_ctx, struct Scene *scene, struct SceneLayer *sl, struct View3D *v3d, struct ARegion *ar, int winx, int winy, float viewmat[4][4],
float winmat[4][4], bool do_bgpic, bool do_sky, bool is_persp, const char *viewname,
struct GPUFX *fx, struct GPUFXSettings *fx_settings,
struct GPUOffScreen *ofs);
void ED_view3d_draw_setup_view(
- struct wmWindow *win, struct Scene *scene, struct ARegion *ar, struct View3D *v3d,
+ struct wmWindow *win, const struct EvaluationContext *eval_ctx, struct Scene *scene, struct ARegion *ar, struct View3D *v3d,
float viewmat[4][4], float winmat[4][4], const struct rcti *rect);
struct ImBuf *ED_view3d_draw_offscreen_imbuf(
- struct Scene *scene, struct SceneLayer *sl, struct View3D *v3d, struct ARegion *ar, int sizex, int sizey,
- unsigned int flag, bool draw_background,
+ const struct EvaluationContext *eval_ctx, struct Scene *scene, struct SceneLayer *sl, struct View3D *v3d, struct ARegion *ar,
+ int sizex, int sizey, unsigned int flag, bool draw_background,
int alpha_mode, int samples, bool full_samples, const char *viewname,
struct GPUFX *fx, struct GPUOffScreen *ofs, char err_out[256]);
struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(
- struct Scene *scene, struct SceneLayer *sl, struct Object *camera, int width, int height,
+ const struct EvaluationContext *eval_ctx, struct Scene *scene, struct SceneLayer *sl, struct Object *camera, int width, int height,
unsigned int flag, int drawtype, bool use_solid_tex, bool use_gpencil, bool draw_background,
int alpha_mode, int samples, bool full_samples, const char *viewname,
struct GPUFX *fx, struct GPUOffScreen *ofs, char err_out[256]);
@@ -382,7 +393,7 @@ struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(
struct BaseLegacy *ED_view3d_give_base_under_cursor(struct bContext *C, const int mval[2]);
void ED_view3d_quadview_update(struct ScrArea *sa, struct ARegion *ar, bool do_clip);
void ED_view3d_update_viewmat(
- struct Scene *scene, struct View3D *v3d, struct ARegion *ar,
+ const struct EvaluationContext *eval_ctx, struct Scene *scene, struct View3D *v3d, struct ARegion *ar,
float viewmat[4][4], float winmat[4][4], const struct rcti *rect);
bool ED_view3d_quat_from_axis_view(const char view, float quat[4]);
char ED_view3d_quat_to_axis_view(const float quat[4], const float epsilon);
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index b3c95aa0712..f6826deaf3a 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -212,6 +212,8 @@ enum {
UI_BUT_ALIGN_STITCH_TOP = (1 << 18),
UI_BUT_ALIGN_STITCH_LEFT = (1 << 19),
UI_BUT_ALIGN_ALL = (UI_BUT_ALIGN | UI_BUT_ALIGN_STITCH_TOP | UI_BUT_ALIGN_STITCH_LEFT),
+
+ UI_BUT_BOX_ITEM = (1 << 20), /* This but is "inside" a box item (currently used to change theme colors). */
};
/* scale fixed button widths by this to account for DPI */
@@ -956,7 +958,11 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C);
void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C);
void uiTemplateReportsBanner(uiLayout *layout, struct bContext *C);
void uiTemplateKeymapItemProperties(uiLayout *layout, struct PointerRNA *ptr);
-void uiTemplateOverrideProperty(uiLayout *layout, struct PointerRNA *collection_props_ptr, struct PointerRNA *scene_props_ptr, const char *name, const char *custom_template);
+void uiTemplateOverrideProperty(
+ uiLayout *layout, struct PointerRNA *collection_props_ptr, struct PointerRNA *scene_props_ptr,
+ const char *propname,
+ const char *name, const char *text_ctxt, int translate, int icon,
+ const char *custom_template);
void uiTemplateComponentMenu(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name);
void uiTemplateNodeSocket(uiLayout *layout, struct bContext *C, float *color);
void uiTemplateCacheFile(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname);
@@ -1007,7 +1013,7 @@ void uiItemsFullEnumO(
struct IDProperty *properties, int context, int flag);
void uiItemsFullEnumO_items(
uiLayout *layout, struct wmOperatorType *ot, PointerRNA ptr, PropertyRNA *prop,
- IDProperty *properties, int context, int flag,
+ struct IDProperty *properties, int context, int flag,
const EnumPropertyItem *item_array, int totitem);
void uiItemL(uiLayout *layout, const char *name, int icon); /* label */
@@ -1097,7 +1103,7 @@ void UI_butstore_unregister(uiButStore *bs_handle, uiBut **but_p);
/* Float precision helpers */
-#define UI_PRECISION_FLOAT_MAX 7
+#define UI_PRECISION_FLOAT_MAX 6
/* For float buttons the 'step' (or a1), is scaled */
#define UI_PRECISION_FLOAT_SCALE 0.01f
diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h
index ac657a4ac73..7d2837ffe4e 100644
--- a/source/blender/editors/include/UI_resources.h
+++ b/source/blender/editors/include/UI_resources.h
@@ -279,6 +279,12 @@ enum {
TH_AXIS_Y,
TH_AXIS_Z,
+ TH_MANIPULATOR_HI,
+ TH_MANIPULATOR_PRIMARY,
+ TH_MANIPULATOR_SECONDARY,
+ TH_MANIPULATOR_A,
+ TH_MANIPULATOR_B,
+
TH_LOW_GRAD,
TH_HIGH_GRAD,
TH_SHOW_BACK_GRAD,
@@ -303,7 +309,6 @@ enum {
TH_EDGE_BEVEL,
TH_VERTEX_BEVEL
};
-/* XXX WARNING: previous is saved in file, so do not change order! */
/* specific defines per space should have higher define values */
diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h
index 4caacb65f5f..4c0493a881c 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -203,6 +203,7 @@ bool UI_view2d_view_to_region_clip(struct View2D *v2d, float x, float y, int *r
void UI_view2d_view_to_region(struct View2D *v2d, float x, float y, int *r_region_x, int *r_region_y) ATTR_NONNULL();
void UI_view2d_view_to_region_fl(struct View2D *v2d, float x, float y, float *r_region_x, float *r_region_y) ATTR_NONNULL();
+void UI_view2d_view_to_region_m4(struct View2D *v2d, float matrix[4][4]) ATTR_NONNULL();
void UI_view2d_view_to_region_rcti(struct View2D *v2d, const struct rctf *rect_src, struct rcti *rect_dst) ATTR_NONNULL();
bool UI_view2d_view_to_region_rcti_clip(struct View2D *v2d, const struct rctf *rect_src, struct rcti *rect_dst) ATTR_NONNULL();
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index d8812b85c19..5eb1d362394 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -56,6 +56,7 @@
#include "BKE_screen.h"
#include "BKE_idprop.h"
+#include "GPU_glew.h"
#include "GPU_matrix.h"
#include "BLF_api.h"
@@ -488,6 +489,9 @@ static int ui_but_calc_float_precision(uiBut *but, double value)
else if (prec == -1) {
prec = (but->hardmax < 10.001f) ? 3 : 2;
}
+ else {
+ CLAMP(prec, 0, UI_PRECISION_FLOAT_MAX);
+ }
return UI_calc_float_precision(prec, value);
}
@@ -685,7 +689,7 @@ static bool ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBu
if (oldbut->active) {
/* flags from the buttons we want to refresh, may want to add more here... */
- const int flag_copy = UI_BUT_REDALERT;
+ const int flag_copy = UI_BUT_REDALERT | UI_HAS_ICON;
found_active = true;
@@ -1166,6 +1170,8 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block)
uiBut *but;
char buf[128];
+ BLI_assert(block->flag & UI_BLOCK_LOOP);
+
/* only do it before bounding */
if (block->rect.xmin != block->rect.xmax)
return;
@@ -1180,6 +1186,9 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block)
}
else {
for (but = block->buttons.first; but; but = but->next) {
+ if (but->dt != UI_EMBOSS_PULLDOWN) {
+ continue;
+ }
if (ui_but_event_operator_string(C, but, buf, sizeof(buf))) {
ui_but_add_shortcut(but, buf, false);
@@ -1930,13 +1939,14 @@ void ui_but_value_set(uiBut *but, double value)
else {
/* first do rounding */
if (but->pointype == UI_BUT_POIN_CHAR) {
- value = (char)floor(value + 0.5);
+ value = round_db_to_uchar_clamp(value);
}
else if (but->pointype == UI_BUT_POIN_SHORT) {
- value = (short)floor(value + 0.5);
+ value = round_db_to_short_clamp(value);
+ }
+ else if (but->pointype == UI_BUT_POIN_INT) {
+ value = round_db_to_int_clamp(value);
}
- else if (but->pointype == UI_BUT_POIN_INT)
- value = (int)floor(value + 0.5);
else if (but->pointype == UI_BUT_POIN_FLOAT) {
float fval = (float)value;
if (fval >= -0.00001f && fval <= 0.00001f) fval = 0.0f; /* prevent negative zero */
@@ -2144,9 +2154,14 @@ static float ui_get_but_step_unit(uiBut *but, float step_default)
/**
* \param float_precision For number buttons the precision to use or -1 to fallback to the button default.
+ * \param use_exp_float Use exponent representation of floats when out of reasonable range (outside of 1e3/1e-3).
*/
-void ui_but_string_get_ex(uiBut *but, char *str, const size_t maxlen, const int float_precision)
+void ui_but_string_get_ex(uiBut *but, char *str, const size_t maxlen, const int float_precision, const bool use_exp_float, bool *r_use_exp_float)
{
+ if (r_use_exp_float) {
+ *r_use_exp_float = false;
+ }
+
if (but->rnaprop && ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) {
PropertyType type;
const char *buf = NULL;
@@ -2214,17 +2229,38 @@ void ui_but_string_get_ex(uiBut *but, char *str, const size_t maxlen, const int
ui_get_but_string_unit(but, str, maxlen, value, false, float_precision);
}
else {
- const int prec = (float_precision == -1) ? ui_but_calc_float_precision(but, value) : float_precision;
- BLI_snprintf(str, maxlen, "%.*f", prec, value);
+ int prec = (float_precision == -1) ? ui_but_calc_float_precision(but, value) : float_precision;
+ if (use_exp_float) {
+ const int int_digits_num = integer_digits_f(value);
+ if (int_digits_num < -6 || int_digits_num > 12) {
+ BLI_snprintf(str, maxlen, "%.*g", prec, value);
+ if (r_use_exp_float) {
+ *r_use_exp_float = true;
+ }
+ }
+ else {
+ prec -= int_digits_num;
+ CLAMP(prec, 0, UI_PRECISION_FLOAT_MAX);
+ BLI_snprintf(str, maxlen, "%.*f", prec, value);
+ }
+ }
+ else {
+#if 0 /* TODO, but will likely break some stuff, so better after 2.79 release. */
+ prec -= int_digits_num;
+ CLAMP(prec, 0, UI_PRECISION_FLOAT_MAX);
+#endif
+ BLI_snprintf(str, maxlen, "%.*f", prec, value);
+ }
}
}
- else
+ else {
BLI_snprintf(str, maxlen, "%d", (int)value);
+ }
}
}
void ui_but_string_get(uiBut *but, char *str, const size_t maxlen)
{
- ui_but_string_get_ex(but, str, maxlen, -1);
+ ui_but_string_get_ex(but, str, maxlen, -1, false, NULL);
}
/**
@@ -2453,7 +2489,9 @@ bool ui_but_string_set(bContext *C, uiBut *but, const char *str)
return false;
}
- if (!ui_but_is_float(but)) value = (int)floor(value + 0.5);
+ if (!ui_but_is_float(but)) {
+ value = floor(value + 0.5);
+ }
/* not that we use hard limits here */
if (value < (double)but->hardmin) value = but->hardmin;
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 1baf01b583f..e46c6a0e267 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -604,7 +604,7 @@ void UI_draw_safe_areas(
float maxx = x2 - margin_x;
float maxy = y2 - margin_y;
- imm_draw_line_box(pos, minx, miny, maxx, maxy);
+ imm_draw_box_wire_2d(pos, minx, miny, maxx, maxy);
}
}
}
@@ -771,12 +771,12 @@ static void waveform_draw_one(float *waveform, int nbr, const float col[3])
GWN_vertbuf_attr_fill(vbo, pos_id, waveform);
/* TODO store the Gwn_Batch inside the scope */
- Gwn_Batch *batch = GWN_batch_create(GWN_PRIM_POINTS, vbo, NULL);
- Batch_set_builtin_program(batch, GPU_SHADER_2D_UNIFORM_COLOR);
+ Gwn_Batch *batch = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_UNIFORM_COLOR);
GWN_batch_uniform_4f(batch, "color", col[0], col[1], col[2], 1.0f);
GWN_batch_draw(batch);
- GWN_batch_discard_all(batch);
+ GWN_batch_discard(batch);
}
void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti *recti)
@@ -1223,7 +1223,7 @@ static void ui_draw_colorband_handle(
if (active || half_width < min_width) {
immUnbindProgram();
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
@@ -1377,7 +1377,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti
/* layer: box outline */
immUniformColor4f(0.0f, 0.0f, 0.0f, 1.0f);
- imm_draw_line_box(position, x1, y1, x1 + sizex, rect->ymax);
+ imm_draw_box_wire_2d(position, x1, y1, x1 + sizex, rect->ymax);
/* layer: box outline */
glEnable(GL_BLEND);
@@ -1443,8 +1443,8 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect)
gpuTranslate2f(rect->xmin + 0.5f * BLI_rcti_size_x(rect), rect->ymin + 0.5f * BLI_rcti_size_y(rect));
gpuScaleUniform(size);
- Gwn_Batch *sphere = Batch_get_sphere(2);
- Batch_set_builtin_program(sphere, GPU_SHADER_SIMPLE_LIGHTING);
+ Gwn_Batch *sphere = GPU_batch_preset_sphere(2);
+ GWN_batch_program_set_builtin(sphere, GPU_SHADER_SIMPLE_LIGHTING);
GWN_batch_uniform_4f(sphere, "color", diffuse[0], diffuse[1], diffuse[2], 1.0f);
GWN_batch_uniform_3fv(sphere, "light", light);
GWN_batch_draw(sphere);
@@ -1460,7 +1460,7 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect)
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
- imm_draw_circle_wire(pos, 0.0f, 0.0f, 1.0f, 32);
+ imm_draw_circle_wire_2d(pos, 0.0f, 0.0f, 1.0f, 32);
glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH);
@@ -1650,7 +1650,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
immUniformColor3ubv((unsigned char *)wcol->item);
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
- immBegin(GWN_PRIM_LINE_STRIP, (CM_TABLE+1) + 2);
+ immBegin(GWN_PRIM_LINE_STRIP, (CM_TABLE + 1) + 2);
if (cuma->table == NULL)
curvemapping_changed(cumap, false);
@@ -1717,7 +1717,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3ubv((unsigned char *)wcol->outline);
- imm_draw_line_box(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
+ imm_draw_box_wire_2d(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
immUnbindProgram();
}
@@ -1812,14 +1812,14 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
UI_GetThemeColor4fv(TH_MARKER_OUTLINE, col_outline);
/* Do stipple cross with geometry */
- immBegin(GWN_PRIM_LINES, 7*2*2);
+ immBegin(GWN_PRIM_LINES, 7 * 2 * 2);
float pos_sel[8] = {-10.0f, -7.0f, -4.0f, -1.0f, 2.0f, 5.0f, 8.0f, 11.0f};
for (int axe = 0; axe < 2; ++axe) {
for (int i = 0; i < 7; ++i) {
float x1 = pos_sel[i] * (1 - axe);
float y1 = pos_sel[i] * axe;
- float x2 = pos_sel[i+1] * (1 - axe);
- float y2 = pos_sel[i+1] * axe;
+ float x2 = pos_sel[i + 1] * (1 - axe);
+ float y2 = pos_sel[i + 1] * axe;
if (i % 2 == 1)
immAttrib4fv(col, col_sel);
diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c
index a1ba937d925..2695d4c9dd9 100644
--- a/source/blender/editors/interface/interface_eyedropper.c
+++ b/source/blender/editors/interface/interface_eyedropper.c
@@ -913,6 +913,9 @@ static void depthdropper_depth_sample_pt(bContext *C, DepthDropper *ddr, int mx,
my - ar->winrct.ymin};
float co[3];
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
CTX_wm_area_set(C, sa);
CTX_wm_region_set(C, ar);
@@ -921,7 +924,7 @@ static void depthdropper_depth_sample_pt(bContext *C, DepthDropper *ddr, int mx,
view3d_operator_needs_opengl(C);
- if (ED_view3d_autodist(graph, ar, v3d, mval, co, true, NULL)) {
+ if (ED_view3d_autodist(&eval_ctx, graph, ar, v3d, mval, co, true, NULL)) {
const float mval_center_fl[2] = {
(float)ar->winx / 2,
(float)ar->winy / 2};
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 59064ec332e..9b3e98c2ace 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -1438,87 +1438,82 @@ static bool ui_selectcontext_begin(
const bool is_array = RNA_property_array_check(prop);
const int rna_type = RNA_property_type(prop);
- if (!UI_context_copy_to_selected_list(C, &ptr, prop, &lb, &use_path_from_id, &path)) {
- goto finally;
- }
-
- selctx_data->elems_len = BLI_listbase_count(&lb);
- if (selctx_data->elems_len == 0) {
- goto finally;
- }
-
- selctx_data->elems = MEM_mallocN(sizeof(uiSelectContextElem) * selctx_data->elems_len, __func__);
+ if (UI_context_copy_to_selected_list(C, &ptr, prop, &lb, &use_path_from_id, &path) &&
+ !BLI_listbase_is_empty(&lb))
+ {
+ selctx_data->elems_len = BLI_listbase_count(&lb);
+ selctx_data->elems = MEM_mallocN(sizeof(uiSelectContextElem) * selctx_data->elems_len, __func__);
- for (i = 0, link = lb.first; i < selctx_data->elems_len; i++, link = link->next) {
- uiSelectContextElem *other = &selctx_data->elems[i];
- /* TODO,. de-duplicate copy_to_selected_button */
- if (link->ptr.data != ptr.data) {
- if (use_path_from_id) {
- /* Path relative to ID. */
- lprop = NULL;
- RNA_id_pointer_create(link->ptr.id.data, &idptr);
- RNA_path_resolve_property(&idptr, path, &lptr, &lprop);
- }
- else if (path) {
- /* Path relative to elements from list. */
- lprop = NULL;
- RNA_path_resolve_property(&link->ptr, path, &lptr, &lprop);
- }
- else {
- lptr = link->ptr;
- lprop = prop;
- }
+ for (i = 0, link = lb.first; i < selctx_data->elems_len; i++, link = link->next) {
+ uiSelectContextElem *other = &selctx_data->elems[i];
+ /* TODO,. de-duplicate copy_to_selected_button */
+ if (link->ptr.data != ptr.data) {
+ if (use_path_from_id) {
+ /* Path relative to ID. */
+ lprop = NULL;
+ RNA_id_pointer_create(link->ptr.id.data, &idptr);
+ RNA_path_resolve_property(&idptr, path, &lptr, &lprop);
+ }
+ else if (path) {
+ /* Path relative to elements from list. */
+ lprop = NULL;
+ RNA_path_resolve_property(&link->ptr, path, &lptr, &lprop);
+ }
+ else {
+ lptr = link->ptr;
+ lprop = prop;
+ }
- /* lptr might not be the same as link->ptr! */
- if ((lptr.data != ptr.data) &&
- (lprop == prop) &&
- RNA_property_editable(&lptr, lprop))
- {
- other->ptr = lptr;
- if (is_array) {
- if (rna_type == PROP_FLOAT) {
- other->val_f = RNA_property_float_get_index(&lptr, lprop, index);
- }
- else if (rna_type == PROP_INT) {
- other->val_i = RNA_property_int_get_index(&lptr, lprop, index);
- }
- /* ignored for now */
+ /* lptr might not be the same as link->ptr! */
+ if ((lptr.data != ptr.data) &&
+ (lprop == prop) &&
+ RNA_property_editable(&lptr, lprop))
+ {
+ other->ptr = lptr;
+ if (is_array) {
+ if (rna_type == PROP_FLOAT) {
+ other->val_f = RNA_property_float_get_index(&lptr, lprop, index);
+ }
+ else if (rna_type == PROP_INT) {
+ other->val_i = RNA_property_int_get_index(&lptr, lprop, index);
+ }
+ /* ignored for now */
#if 0
- else if (rna_type == PROP_BOOLEAN) {
- other->val_b = RNA_property_boolean_get_index(&lptr, lprop, index);
- }
+ else if (rna_type == PROP_BOOLEAN) {
+ other->val_b = RNA_property_boolean_get_index(&lptr, lprop, index);
+ }
#endif
- }
- else {
- if (rna_type == PROP_FLOAT) {
- other->val_f = RNA_property_float_get(&lptr, lprop);
- }
- else if (rna_type == PROP_INT) {
- other->val_i = RNA_property_int_get(&lptr, lprop);
}
- /* ignored for now */
+ else {
+ if (rna_type == PROP_FLOAT) {
+ other->val_f = RNA_property_float_get(&lptr, lprop);
+ }
+ else if (rna_type == PROP_INT) {
+ other->val_i = RNA_property_int_get(&lptr, lprop);
+ }
+ /* ignored for now */
#if 0
- else if (rna_type == PROP_BOOLEAN) {
- other->val_b = RNA_property_boolean_get(&lptr, lprop);
- }
- else if (rna_type == PROP_ENUM) {
- other->val_i = RNA_property_enum_get(&lptr, lprop);
- }
+ else if (rna_type == PROP_BOOLEAN) {
+ other->val_b = RNA_property_boolean_get(&lptr, lprop);
+ }
+ else if (rna_type == PROP_ENUM) {
+ other->val_i = RNA_property_enum_get(&lptr, lprop);
+ }
#endif
- }
+ }
- continue;
+ continue;
+ }
}
+
+ selctx_data->elems_len -= 1;
+ i -= 1;
}
- selctx_data->elems_len -= 1;
- i -= 1;
+ success = (selctx_data->elems_len != 0);
}
}
- success = (selctx_data->elems_len != 0);
-
-finally:
if (selctx_data->elems_len == 0) {
MEM_SAFE_FREE(selctx_data->elems);
}
@@ -2313,7 +2308,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
/* Get many decimal places, then strip trailing zeros.
* note: too high values start to give strange results */
char buf_copy[UI_MAX_DRAW_STR];
- ui_but_string_get_ex(but, buf_copy, sizeof(buf_copy), UI_PRECISION_FLOAT_MAX);
+ ui_but_string_get_ex(but, buf_copy, sizeof(buf_copy), UI_PRECISION_FLOAT_MAX, false, NULL);
BLI_str_rstrip_float_zero(buf_copy, '\0');
WM_clipboard_text_set(buf_copy, 0);
@@ -3054,6 +3049,7 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
wmWindow *win = CTX_wm_window(C);
int len;
const bool is_num_but = ELEM(but->type, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER);
+ bool no_zero_strip = false;
if (data->str) {
MEM_freeN(data->str);
@@ -3082,14 +3078,16 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
data->maxlen = ui_but_string_get_max_length(but);
if (data->maxlen != 0) {
data->str = MEM_callocN(sizeof(char) * data->maxlen, "textedit str");
- ui_but_string_get(but, data->str, data->maxlen);
+ /* We do not want to truncate precision to default here, it's nice to show value,
+ * not to edit it - way too much precision is lost then. */
+ ui_but_string_get_ex(but, data->str, data->maxlen, UI_PRECISION_FLOAT_MAX, true, &no_zero_strip);
}
else {
data->is_str_dynamic = true;
data->str = ui_but_string_get_dynamic(but, &data->maxlen);
}
- if (ui_but_is_float(but) && !ui_but_is_unit(but) && !ui_but_anim_expression_get(but, NULL, 0)) {
+ if (ui_but_is_float(but) && !ui_but_is_unit(but) && !ui_but_anim_expression_get(but, NULL, 0) && !no_zero_strip) {
BLI_str_rstrip_float_zero(data->str, '\0');
}
@@ -4293,7 +4291,7 @@ static bool ui_numedit_but_NUM(
if (!is_float) {
- temp = iroundf(tempf);
+ temp = round_fl_to_int(tempf);
temp = ui_numedit_apply_snap(temp, softmin, softmax, snap);
@@ -4578,7 +4576,7 @@ static bool ui_numedit_but_SLI(
tempf = softmin + f * softrange;
- temp = iroundf(tempf);
+ temp = round_fl_to_int(tempf);
if (snap) {
if (tempf == softmin || tempf == softmax) {
@@ -6790,8 +6788,8 @@ static bool ui_but_menu(bContext *C, uiBut *but)
/* set the prop and pointer data for python access to the hovered ui element; TODO, index could be supported as well*/
PointerRNA temp_ptr;
RNA_pointer_create(NULL, &RNA_Property, but->rnaprop, &temp_ptr);
- uiLayoutSetContextPointer(layout,"button_prop", &temp_ptr);
- uiLayoutSetContextPointer(layout,"button_pointer", ptr);
+ uiLayoutSetContextPointer(layout, "button_prop", &temp_ptr);
+ uiLayoutSetContextPointer(layout, "button_pointer", ptr);
/* second slower test, saved people finding keyframe items in menus when its not possible */
if (is_anim)
@@ -7010,8 +7008,9 @@ static bool ui_but_menu(bContext *C, uiBut *but)
}
/* Set the operator pointer for python access */
- if (but->opptr)
- uiLayoutSetContextPointer(layout,"button_operator", but->opptr);
+ if (but->opptr) {
+ uiLayoutSetContextPointer(layout, "button_operator", but->opptr);
+ }
uiItemS(layout);
}
@@ -7059,7 +7058,7 @@ static bool ui_but_menu(bContext *C, uiBut *but)
}
uiItemFullO(layout, "UI_OT_edittranslation_init", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0);
- mt = WM_menutype_find("WM_MT_button_context", false);
+ mt = WM_menutype_find("WM_MT_button_context", true);
if (mt) {
Menu menu = {NULL};
menu.layout = uiLayoutColumn(layout, false);
@@ -9246,11 +9245,17 @@ static int ui_handle_menu_event(
doit = true;
}
}
- else if (count == act) {
+ else if (ELEM(but->type,
+ UI_BTYPE_BUT,
+ UI_BTYPE_BUT_MENU,
+ UI_BTYPE_MENU, UI_BTYPE_BLOCK,
+ UI_BTYPE_PULLDOWN) &&
+ count == act)
+ {
doit = true;
}
- if (doit) {
+ if (!(but->flag & UI_BUT_DISABLED) && doit) {
/* activate buttons but open menu's */
uiButtonActivateType activate;
if (but->type == UI_BTYPE_PULLDOWN) {
@@ -9304,8 +9309,7 @@ static int ui_handle_menu_event(
break;
for (but = block->buttons.first; but; but = but->next) {
-
- if (but->menu_key == event->type) {
+ if (!(but->flag & UI_BUT_DISABLED) && but->menu_key == event->type) {
if (ELEM(but->type, UI_BTYPE_BUT, UI_BTYPE_BUT_MENU)) {
/* mainly for operator buttons */
ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE_APPLY);
@@ -10226,9 +10230,9 @@ void UI_popup_handlers_remove(ListBase *handlers, uiPopupBlockHandle *popup)
handler->ui_userdata == popup)
{
/* tag refresh parent popup */
- if (handler->next &&
- handler->next->ui_handle == ui_popup_handler &&
- handler->next->ui_remove == ui_popup_handler_remove)
+ if (handler->next &&
+ handler->next->ui_handle == ui_popup_handler &&
+ handler->next->ui_remove == ui_popup_handler_remove)
{
uiPopupBlockHandle *parent_popup = handler->next->ui_userdata;
ED_region_tag_refresh_ui(parent_popup->region);
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index ace3bb5b4f8..2abb8dcf20f 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -475,7 +475,9 @@ extern void ui_hsvcircle_pos_from_vals(struct uiBut *but, const rcti *rect, floa
extern void ui_hsvcube_pos_from_vals(struct uiBut *but, const rcti *rect, float *hsv, float *xp, float *yp);
bool ui_but_is_colorpicker_display_space(struct uiBut *but);
-extern void ui_but_string_get_ex(uiBut *but, char *str, const size_t maxlen, const int float_precision) ATTR_NONNULL();
+extern void ui_but_string_get_ex(
+ uiBut *but, char *str, const size_t maxlen,
+ const int float_precision, const bool use_exp_float, bool *r_use_exp_float) ATTR_NONNULL(1, 2);
extern void ui_but_string_get(uiBut *but, char *str, const size_t maxlen) ATTR_NONNULL();
extern char *ui_but_string_get_dynamic(uiBut *but, int *r_str_size);
extern void ui_but_convert_to_unit_alt_name(uiBut *but, char *str, size_t maxlen) ATTR_NONNULL();
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 0b7f4b00c2d..d2e4cdf5453 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -128,6 +128,8 @@ typedef struct uiItem {
enum {
UI_ITEM_FIXED = 1 << 0,
UI_ITEM_MIN = 1 << 1,
+
+ UI_ITEM_BOX_ITEM = 1 << 2, /* The item is "inside" a box item */
};
typedef struct uiButtonItem {
@@ -192,8 +194,9 @@ static const char *ui_item_name_add_colon(const char *name, char namestr[UI_MAX_
static int ui_item_fit(int item, int pos, int all, int available, bool is_last, int alignment, float *extra_pixel)
{
/* available == 0 is unlimited */
- if (available == 0)
+ if (ELEM(0, available, all)) {
return item;
+ }
if (all > available) {
/* contents is bigger than available space */
@@ -216,8 +219,9 @@ static int ui_item_fit(int item, int pos, int all, int available, bool is_last,
return (int)width;
}
}
- else
+ else {
return item;
+ }
}
}
@@ -243,7 +247,9 @@ static int ui_text_icon_width(uiLayout *layout, const char *name, int icon, bool
variable = (ui_layout_vary_direction(layout) == UI_ITEM_VARY_X);
if (variable) {
- layout->item.flag |= UI_ITEM_MIN;
+ if (layout->alignment != UI_LAYOUT_ALIGN_EXPAND) {
+ layout->item.flag |= UI_ITEM_MIN;
+ }
const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
/* it may seem odd that the icon only adds (UI_UNIT_X / 4)
* but taking margins into account its fine */
@@ -700,7 +706,7 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *n
WM_OP_INVOKE_DEFAULT, ICON_FILESEL, x, y, UI_UNIT_X, h, NULL);
}
else if (flag & UI_ITEM_R_EVENT) {
- uiDefButR_prop(block, UI_BTYPE_KEY_EVENT, 0, name, x, y, w, h, ptr, prop, index, 0, 0, -1, -1, NULL);
+ but = uiDefButR_prop(block, UI_BTYPE_KEY_EVENT, 0, name, x, y, w, h, ptr, prop, index, 0, 0, -1, -1, NULL);
}
else if (flag & UI_ITEM_R_FULL_EVENT) {
if (RNA_struct_is_a(ptr->type, &RNA_KeyMapItem)) {
@@ -1642,6 +1648,10 @@ void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRN
coll_search, NULL, NULL);
but->free_search_arg = true;
}
+ else if (but->type == UI_BTYPE_SEARCH_MENU) {
+ /* In case we fail to find proper searchprop, so other code might have already set but->type to search menu... */
+ but->type = UI_BTYPE_LABEL;
+ }
}
void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *searchptr, const char *searchpropname, const char *name, int icon)
@@ -2228,6 +2238,10 @@ static void ui_litem_layout_column(uiLayout *litem, bool is_box)
if (item->next && (!is_box || item != litem->items.first))
y -= litem->space;
+
+ if (is_box) {
+ item->flag |= UI_ITEM_BOX_ITEM;
+ }
}
litem->h = litem->y - y;
@@ -2379,7 +2393,6 @@ static void ui_litem_estimate_box(uiLayout *litem)
uiStyle *style = litem->root->style;
ui_litem_estimate_column(litem, true);
- litem->item.flag &= ~UI_ITEM_MIN;
litem->w += 2 * style->boxspace;
litem->h += 2 * style->boxspace;
}
@@ -3051,8 +3064,11 @@ static void ui_item_estimate(uiItem *item)
for (subitem = litem->items.first; subitem; subitem = subitem->next)
ui_item_estimate(subitem);
- if (BLI_listbase_is_empty(&litem->items))
+ if (BLI_listbase_is_empty(&litem->items)) {
+ litem->w = 0;
+ litem->h = 0;
return;
+ }
if (litem->scale[0] != 0.0f || litem->scale[1] != 0.0f)
ui_item_scale(litem, litem->scale);
@@ -3188,8 +3204,18 @@ static void ui_item_layout(uiItem *item)
break;
}
- for (subitem = litem->items.first; subitem; subitem = subitem->next)
+ for (subitem = litem->items.first; subitem; subitem = subitem->next) {
+ if (item->flag & UI_ITEM_BOX_ITEM) {
+ subitem->flag |= UI_ITEM_BOX_ITEM;
+ }
ui_item_layout(subitem);
+ }
+ }
+ else {
+ if (item->flag & UI_ITEM_BOX_ITEM) {
+ uiButtonItem *bitem = (uiButtonItem *)item;
+ bitem->but->drawflag |= UI_BUT_BOX_ITEM;
+ }
}
}
@@ -3306,8 +3332,9 @@ void ui_layout_add_but(uiLayout *layout, uiBut *but)
ui_item_size((uiItem *)bitem, &w, &h);
/* XXX uiBut hasn't scaled yet
* we can flag the button as not expandable, depending on its size */
- if (w <= 2 * UI_UNIT_X)
+ if (w <= 2 * UI_UNIT_X && (!but->str || but->str[0] == '\0')) {
bitem->item.flag |= UI_ITEM_MIN;
+ }
BLI_addtail(&layout->items, bitem);
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index e47088d020e..40ca2d41372 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -484,6 +484,9 @@ bool UI_context_copy_to_selected_list(
else if (RNA_struct_is_a(ptr->type, &RNA_Sequence)) {
*r_lb = CTX_data_collection_get(C, "selected_editable_sequences");
}
+ else if (RNA_struct_is_a(ptr->type, &RNA_FCurve)) {
+ *r_lb = CTX_data_collection_get(C, "selected_editable_fcurves");
+ }
else if (RNA_struct_is_a(ptr->type, &RNA_Node) ||
RNA_struct_is_a(ptr->type, &RNA_NodeSocket))
{
@@ -618,51 +621,51 @@ static bool copy_to_selected_button(bContext *C, bool all, bool poll)
char *path = NULL;
bool use_path_from_id;
CollectionPointerLink *link;
- ListBase lb;
-
- if (!UI_context_copy_to_selected_list(C, &ptr, prop, &lb, &use_path_from_id, &path))
- return success;
+ ListBase lb = {NULL};
- for (link = lb.first; link; link = link->next) {
- if (link->ptr.data != ptr.data) {
- if (use_path_from_id) {
- /* Path relative to ID. */
- lprop = NULL;
- RNA_id_pointer_create(link->ptr.id.data, &idptr);
- RNA_path_resolve_property(&idptr, path, &lptr, &lprop);
- }
- else if (path) {
- /* Path relative to elements from list. */
- lprop = NULL;
- RNA_path_resolve_property(&link->ptr, path, &lptr, &lprop);
- }
- else {
- lptr = link->ptr;
- lprop = prop;
- }
+ if (UI_context_copy_to_selected_list(C, &ptr, prop, &lb, &use_path_from_id, &path) &&
+ !BLI_listbase_is_empty(&lb))
+ {
+ for (link = lb.first; link; link = link->next) {
+ if (link->ptr.data != ptr.data) {
+ if (use_path_from_id) {
+ /* Path relative to ID. */
+ lprop = NULL;
+ RNA_id_pointer_create(link->ptr.id.data, &idptr);
+ RNA_path_resolve_property(&idptr, path, &lptr, &lprop);
+ }
+ else if (path) {
+ /* Path relative to elements from list. */
+ lprop = NULL;
+ RNA_path_resolve_property(&link->ptr, path, &lptr, &lprop);
+ }
+ else {
+ lptr = link->ptr;
+ lprop = prop;
+ }
- if (lptr.data == ptr.data) {
- /* lptr might not be the same as link->ptr! */
- continue;
- }
+ if (lptr.data == ptr.data) {
+ /* lptr might not be the same as link->ptr! */
+ continue;
+ }
- if (lprop == prop) {
- if (RNA_property_editable(&lptr, lprop)) {
- if (poll) {
- success = true;
- break;
- }
- else {
- if (RNA_property_copy(&lptr, &ptr, prop, (all) ? -1 : index)) {
- RNA_property_update(C, &lptr, prop);
+ if (lprop == prop) {
+ if (RNA_property_editable(&lptr, lprop)) {
+ if (poll) {
success = true;
+ break;
+ }
+ else {
+ if (RNA_property_copy(&lptr, &ptr, prop, (all) ? -1 : index)) {
+ RNA_property_update(C, &lptr, prop);
+ success = true;
+ }
}
}
}
}
}
}
-
MEM_SAFE_FREE(path);
BLI_freelistN(&lb);
}
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index cc49eeb5b59..7770e45e2ba 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -507,14 +507,14 @@ static void ui_draw_panel_dragwidget(unsigned int pos, const rctf *rect)
const int col_tint = 84;
const int px = (int)U.pixelsize;
- const int px_zoom = max_ii(iroundf(BLI_rctf_size_y(rect) / 22.0f), 1);
+ const int px_zoom = max_ii(round_fl_to_int(BLI_rctf_size_y(rect) / 22.0f), 1);
- const int box_margin = max_ii(iroundf((float)(px_zoom * 2.0f)), px);
- const int box_size = max_ii(iroundf((BLI_rctf_size_y(rect) / 8.0f) - px), px);
+ const int box_margin = max_ii(round_fl_to_int((float)(px_zoom * 2.0f)), px);
+ const int box_size = max_ii(round_fl_to_int((BLI_rctf_size_y(rect) / 8.0f) - px), px);
const int x_min = rect->xmin;
const int y_min = rect->ymin;
- const int y_ofs = max_ii(iroundf(BLI_rctf_size_y(rect) / 3.0f), px);
+ const int y_ofs = max_ii(round_fl_to_int(BLI_rctf_size_y(rect) / 3.0f), px);
const int x_ofs = y_ofs;
int i_x, i_y;
@@ -917,8 +917,8 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bo
for (a = 0; a < tot; a++, ps++) {
if ((ps->pa->flag & PNL_SELECT) == 0) {
if ((ps->orig->ofsx != ps->pa->ofsx) || (ps->orig->ofsy != ps->pa->ofsy)) {
- ps->orig->ofsx = iroundf(fac * (float)ps->pa->ofsx + (1.0f - fac) * (float)ps->orig->ofsx);
- ps->orig->ofsy = iroundf(fac * (float)ps->pa->ofsy + (1.0f - fac) * (float)ps->orig->ofsy);
+ ps->orig->ofsx = round_fl_to_int(fac * (float)ps->pa->ofsx + (1.0f - fac) * (float)ps->orig->ofsx);
+ ps->orig->ofsy = round_fl_to_int(fac * (float)ps->pa->ofsy + (1.0f - fac) * (float)ps->orig->ofsy);
done = true;
}
}
@@ -1678,11 +1678,11 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active)
PanelCategoryDyn *pc_dyn;
const float aspect = ((uiBlock *)ar->uiblocks.first)->aspect;
const float zoom = 1.0f / aspect;
- const int px = max_ii(1, iroundf(U.pixelsize));
- const int category_tabs_width = iroundf(UI_PANEL_CATEGORY_MARGIN_WIDTH * zoom);
+ const int px = max_ii(1, round_fl_to_int(U.pixelsize));
+ const int category_tabs_width = round_fl_to_int(UI_PANEL_CATEGORY_MARGIN_WIDTH * zoom);
const float dpi_fac = UI_DPI_FAC;
- const int tab_v_pad_text = iroundf((2 + ((px * 3) * dpi_fac)) * zoom); /* pading of tabs around text */
- const int tab_v_pad = iroundf((4 + (2 * px * dpi_fac)) * zoom); /* padding between tabs */
+ const int tab_v_pad_text = round_fl_to_int((2 + ((px * 3) * dpi_fac)) * zoom); /* pading of tabs around text */
+ const int tab_v_pad = round_fl_to_int((4 + (2 * px * dpi_fac)) * zoom); /* padding between tabs */
const float tab_curve_radius = ((px * 3) * dpi_fac) * zoom;
const int roundboxtype = UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT;
bool is_alpha;
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index fd6d056f7d4..57290c47210 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -347,11 +347,13 @@ static uiTooltipData *ui_tooltip_data_from_button(bContext *C, uiBut *but)
/* Tip */
if (but_tip.strinfo) {
- BLI_strncpy(data->header, but_tip.strinfo, sizeof(data->lines[0]));
if (enum_label.strinfo) {
BLI_snprintf(data->header, sizeof(data->header), "%s: ", but_tip.strinfo);
BLI_strncpy(data->active_info, enum_label.strinfo, sizeof(data->lines[0]));
}
+ else {
+ BLI_snprintf(data->header, sizeof(data->header), "%s.", but_tip.strinfo);
+ }
data->format[data->totline].style = UI_TIP_STYLE_HEADER;
data->totline++;
@@ -2107,9 +2109,11 @@ static void ui_update_color_picker_buts_rgb(uiBlock *block, ColorPicker *cpicker
continue;
if (bt->rnaprop) {
-
ui_but_v3_set(bt, rgb);
+ /* original button that created the color picker already does undo
+ * push, so disable it on RNA buttons in the color picker block */
+ UI_but_flag_disable(bt, UI_BUT_UNDO);
}
else if (STREQ(bt->str, "Hex: ")) {
float rgb_gamma[3];
@@ -2446,7 +2450,7 @@ static void ui_block_colorpicker(uiBlock *block, float rgba[4], PointerRNA *ptr,
BLI_snprintf(hexcol, sizeof(hexcol), "%02X%02X%02X", UNPACK3_EX((unsigned int), rgb_gamma_uchar, ));
yco = -3.0f * UI_UNIT_Y;
- bt = uiDefBut(block, UI_BTYPE_TEXT, 0, IFACE_("Hex: "), 0, yco, butwidth, UI_UNIT_Y, hexcol, 0, 7, 0, 0, TIP_("Hex triplet for color (#RRGGBB)"));
+ bt = uiDefBut(block, UI_BTYPE_TEXT, 0, IFACE_("Hex: "), 0, yco, butwidth, UI_UNIT_Y, hexcol, 0, 8, 0, 0, TIP_("Hex triplet for color (#RRGGBB)"));
UI_but_func_set(bt, ui_colorpicker_hex_rna_cb, bt, hexcol);
bt->custom_data = cpicker;
uiDefBut(block, UI_BTYPE_LABEL, 0, IFACE_("(Gamma Corrected)"), 0, yco - UI_UNIT_Y, butwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
@@ -2958,8 +2962,8 @@ uiPieMenu *UI_pie_menu_begin(struct bContext *C, const char *title, int icon, co
pie->block_radial->puphash = ui_popup_menu_hash(title);
pie->block_radial->flag |= UI_BLOCK_RADIAL;
- /* if pie is spawned by a left click, it is always assumed to be click style */
- if (event->type == LEFTMOUSE) {
+ /* if pie is spawned by a left click, release or click event, it is always assumed to be click style */
+ if (event->type == LEFTMOUSE || ELEM(event->val, KM_RELEASE, KM_CLICK)) {
pie->block_radial->pie_data.flags |= UI_PIE_CLICK_STYLE;
pie->block_radial->pie_data.event = EVENT_NONE;
win->lock_pie_event = EVENT_NONE;
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 083e29ac28b..ebd4ce36bbe 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -121,7 +121,7 @@ static void template_add_button_search_menu(
/* Ugly exception for screens here, drawing their preview in icon size looks ugly/useless */
const bool use_preview_icon = use_big_size || (id && (GS(id->name) != ID_SCR));
const short width = UI_UNIT_X * (use_big_size ? 6 : 1.6f);
- const short height = UI_UNIT_Y * (use_big_size ? 6: 1);
+ const short height = UI_UNIT_Y * (use_big_size ? 6 : 1);
but = uiDefBlockButN(block, block_func, block_argN, "", 0, 0, width, height, tip);
if (use_preview_icon) {
@@ -3102,7 +3102,7 @@ static void uilist_resize_update_cb(bContext *C, void *arg1, void *UNUSED(arg2))
uiListDyn *dyn_data = ui_list->dyn_data;
/* This way we get diff in number of additional items to show (positive) or hide (negative). */
- const int diff = iroundf((float)(dyn_data->resize - dyn_data->resize_prev) / (float)UI_UNIT_Y);
+ const int diff = round_fl_to_int((float)(dyn_data->resize - dyn_data->resize_prev) / (float)UI_UNIT_Y);
if (diff != 0) {
ui_list->list_grip += diff;
@@ -4000,7 +4000,10 @@ void uiTemplateKeymapItemProperties(uiLayout *layout, PointerRNA *ptr)
/********************************* Overrides *************************************/
-void uiTemplateOverrideProperty(uiLayout *layout, struct PointerRNA *collection_props_ptr, struct PointerRNA *scene_props_ptr, const char *name, const char *custom_template)
+void uiTemplateOverrideProperty(
+ uiLayout *layout, PointerRNA *collection_props_ptr, PointerRNA *scene_props_ptr, const char *propname,
+ const char *name, const char *text_ctxt, int translate, int icon,
+ const char *custom_template)
{
bool is_set = false;
uiLayout *row, *col;
@@ -4010,27 +4013,30 @@ void uiTemplateOverrideProperty(uiLayout *layout, struct PointerRNA *collection_
IDProperty *collection_props = collection_props_ptr->data;
- if (IDP_GetPropertyFromGroup(collection_props, name)) {
- prop = RNA_struct_find_property(collection_props_ptr, name);
+ if (IDP_GetPropertyFromGroup(collection_props, propname)) {
+ prop = RNA_struct_find_property(collection_props_ptr, propname);
ptr = collection_props_ptr;
is_set = RNA_property_is_set(ptr, prop);
}
else {
/* property doesn't exist yet */
- prop = RNA_struct_find_property(scene_props_ptr, name);
+ prop = RNA_struct_find_property(scene_props_ptr, propname);
ptr = scene_props_ptr;
}
+ /* Get translated name (label). */
+ name = RNA_translate_ui_text(name, text_ctxt, NULL, prop, translate);
+
row = uiLayoutRow(layout, false);
col = uiLayoutColumn(row, false);
uiLayoutSetEnabled(col, is_set);
if (custom_template && STREQ(custom_template, "icon_view")) {
- uiTemplateIconView(col, ptr, name, false, 5.0f);
+ uiTemplateIconView(col, ptr, propname, false, 5.0f);
}
else {
- uiItemFullR(col, ptr, prop, -1, 0, 0, NULL, ICON_NONE);
+ uiItemFullR(col, ptr, prop, -1, 0, 0, name, icon);
}
col = uiLayoutColumn(row, false);
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c
index fd1569ae42e..f0317087ddc 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.c
@@ -347,7 +347,7 @@ int UI_icon_from_report_type(int type)
*/
int UI_calc_float_precision(int prec, double value)
{
- static const double pow10_neg[UI_PRECISION_FLOAT_MAX + 1] = {1e0, 1e-1, 1e-2, 1e-3, 1e-4, 1e-5, 1e-6, 1e-7};
+ static const double pow10_neg[UI_PRECISION_FLOAT_MAX + 1] = {1e0, 1e-1, 1e-2, 1e-3, 1e-4, 1e-5, 1e-6};
static const double max_pow = 10000000.0; /* pow(10, UI_PRECISION_FLOAT_MAX) */
BLI_assert(prec <= UI_PRECISION_FLOAT_MAX);
@@ -462,6 +462,17 @@ uiButStore *UI_butstore_create(uiBlock *block)
void UI_butstore_free(uiBlock *block, uiButStore *bs_handle)
{
+ /* Workaround for button store being moved into new block,
+ * which then can't use the previous buttons state ('ui_but_update_from_old_block' fails to find a match),
+ * keeping the active button in the old block holding a reference to the button-state in the new block: see T49034.
+ *
+ * Ideally we would manage moving the 'uiButStore', keeping a correct state.
+ * All things considered this is the most straightforward fix - Campbell.
+ */
+ if (block != bs_handle->block && bs_handle->block != NULL) {
+ block = bs_handle->block;
+ }
+
BLI_freelistN(&bs_handle->items);
BLI_remlink(&block->butstore, bs_handle);
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 8adcca8c7cd..e3977219eda 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -2272,12 +2272,12 @@ static void ui_hsv_cursor(float x, float y)
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3f(1.0f, 1.0f, 1.0f);
- imm_draw_circle_fill(pos, x, y, 3.0f * U.pixelsize, 8);
+ imm_draw_circle_fill_2d(pos, x, y, 3.0f * U.pixelsize, 8);
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
immUniformColor3f(0.0f, 0.0f, 0.0f);
- imm_draw_circle_wire(pos, x, y, 3.0f * U.pixelsize, 12);
+ imm_draw_circle_wire_2d(pos, x, y, 3.0f * U.pixelsize, 12);
glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH);
@@ -2397,7 +2397,7 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti *
glEnable(GL_LINE_SMOOTH);
immUniformColor3ubv((unsigned char *)wcol->outline);
- imm_draw_circle_wire(pos, centx, centy, radius, tot);
+ imm_draw_circle_wire_2d(pos, centx, centy, radius, tot);
immUnbindProgram();
@@ -2637,7 +2637,7 @@ static void ui_draw_but_HSVCUBE(uiBut *but, const rcti *rect)
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3ub(0, 0, 0);
- imm_draw_line_box(pos, (rect->xmin), (rect->ymin), (rect->xmax), (rect->ymax));
+ imm_draw_box_wire_2d(pos, (rect->xmin), (rect->ymin), (rect->xmax), (rect->ymax));
immUnbindProgram();
}
@@ -3811,11 +3811,15 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
switch (but->type) {
case UI_BTYPE_LABEL:
- if (but->block->flag & UI_BLOCK_LOOP)
- widget_draw_text_icon(&style->widgetlabel, &tui->wcol_menu_back, but, rect);
- else {
- wt = widget_type(UI_WTYPE_LABEL);
- fstyle = &style->widgetlabel;
+ wt = widget_type(UI_WTYPE_LABEL);
+ fstyle = &style->widgetlabel;
+ if (but->drawflag & UI_BUT_BOX_ITEM) {
+ wt->wcol_theme = &tui->wcol_box;
+ wt->state = widget_state;
+ }
+ else if (but->block->flag & UI_BLOCK_LOOP) {
+ wt->wcol_theme = &tui->wcol_menu_back;
+ wt->state = widget_state;
}
break;
@@ -4168,8 +4172,8 @@ void ui_draw_pie_center(uiBlock *block)
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4ubv((unsigned char *)btheme->tui.wcol_pie_menu.outline);
- imm_draw_circle_wire(pos, 0.0f, 0.0f, pie_radius_internal, subd);
- imm_draw_circle_wire(pos, 0.0f, 0.0f, pie_radius_external, subd);
+ imm_draw_circle_wire_2d(pos, 0.0f, 0.0f, pie_radius_internal, subd);
+ imm_draw_circle_wire_2d(pos, 0.0f, 0.0f, pie_radius_external, subd);
immUnbindProgram();
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index cf35f4d895b..bf42316289f 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -667,6 +667,17 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
case TH_AXIS_Z:
cp = btheme->tui.zaxis; break;
+ case TH_MANIPULATOR_HI:
+ cp = btheme->tui.manipulator_hi; break;
+ case TH_MANIPULATOR_PRIMARY:
+ cp = btheme->tui.manipulator_primary; break;
+ case TH_MANIPULATOR_SECONDARY:
+ cp = btheme->tui.manipulator_secondary; break;
+ case TH_MANIPULATOR_A:
+ cp = btheme->tui.manipulator_a; break;
+ case TH_MANIPULATOR_B:
+ cp = btheme->tui.manipulator_b; break;
+
case TH_INFO_SELECTED:
cp = ts->info_selected;
break;
@@ -837,6 +848,15 @@ static void ui_theme_space_init_handles_color(ThemeSpace *theme_space)
rgba_char_args_set(theme_space->act_spline, 0xdb, 0x25, 0x12, 255);
}
+static void ui_theme_space_init_manipulator_colors(bTheme *btheme)
+{
+ rgba_char_args_set(btheme->tui.manipulator_hi, 255, 255, 255, 255);
+ rgba_char_args_set(btheme->tui.manipulator_primary, 222, 255, 13, 255);
+ rgba_char_args_set(btheme->tui.manipulator_secondary, 0, 255, 255, 255);
+ rgba_char_args_set(btheme->tui.manipulator_a, 23, 127, 23, 255);
+ rgba_char_args_set(btheme->tui.manipulator_b, 127, 23, 23, 255);
+}
+
/**
* initialize default theme
* \note: when you add new colors, created & saved themes need initialized
@@ -877,6 +897,9 @@ void ui_theme_init_default(void)
/* common (new) variables */
ui_theme_init_new(btheme);
+ /* Manipulator. */
+ ui_theme_space_init_manipulator_colors(btheme);
+
/* space view3d */
rgba_char_args_set_fl(btheme->tv3d.back, 0.225, 0.225, 0.225, 1.0);
rgba_char_args_set(btheme->tv3d.text, 0, 0, 0, 255);
@@ -2892,6 +2915,25 @@ void init_userdef_do_versions(void)
btheme->ttime.time_keyframe[3] = btheme->ttime.time_gp_keyframe[3] = 255;
}
}
+
+ if (!USER_VERSION_ATLEAST(278, 6)) {
+ /* Clear preference flags for re-use. */
+ U.flag &= ~(
+ USER_FLAG_DEPRECATED_1 | USER_FLAG_DEPRECATED_2 | USER_FLAG_DEPRECATED_3 |
+ USER_FLAG_DEPRECATED_6 | USER_FLAG_DEPRECATED_7 |
+ USER_FLAG_DEPRECATED_9 | USER_FLAG_DEPRECATED_10);
+ U.uiflag &= ~(
+ USER_UIFLAG_DEPRECATED_7);
+ U.transopts &= ~(
+ USER_TR_DEPRECATED_2 | USER_TR_DEPRECATED_3 | USER_TR_DEPRECATED_4 |
+ USER_TR_DEPRECATED_6 | USER_TR_DEPRECATED_7);
+ U.gameflags &= ~(
+ USER_GL_RENDER_DEPRECATED_0 | USER_GL_RENDER_DEPRECATED_1 |
+ USER_GL_RENDER_DEPRECATED_3 | USER_GL_RENDER_DEPRECATED_4);
+
+ U.uiflag |= USER_LOCK_CURSOR_ADJUST;
+ }
+
if (!USER_VERSION_ATLEAST(280, 1)) {
/* interface_widgets.c */
struct uiWidgetColors wcol_tab = {
@@ -2917,8 +2959,10 @@ void init_userdef_do_versions(void)
*
* (keep this block even if it becomes empty).
*/
- {
-
+ if (((bTheme *)U.themes.first)->tui.manipulator_hi[3] == 0) {
+ for (bTheme *btheme = U.themes.first; btheme; btheme = btheme->next) {
+ ui_theme_space_init_manipulator_colors(btheme);
+ }
}
if (U.pixelsize == 0.0f)
@@ -2927,11 +2971,8 @@ void init_userdef_do_versions(void)
if (U.image_draw_method == 0)
U.image_draw_method = IMAGE_DRAW_METHOD_2DTEXTURE;
- // keep the following until the new audaspace is default to be built with
-#ifdef WITH_SYSTEM_AUDASPACE
// we default to the first audio device
U.audiodevice = 0;
-#endif
/* funny name, but it is GE stuff, moves userdef stuff to engine */
// XXX space_set_commmandline_options();
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index fb57902d258..bb625bc0ff8 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -1565,7 +1565,7 @@ void UI_view2d_multi_grid_draw(View2D *v2d, int colorid, float step, int level_s
}
/* X and Y axis */
- UI_GetThemeColorShade3ubv(colorid, -18 + ((totlevels - 1) * -6) , grid_line_color);
+ UI_GetThemeColorShade3ubv(colorid, -18 + ((totlevels - 1) * -6), grid_line_color);
immSkipAttrib(color);
immVertex2f(pos, 0.0f, v2d->cur.ymin);
@@ -2260,6 +2260,14 @@ void UI_view2d_view_to_region_rcti(View2D *v2d, const rctf *rect_src, rcti *rect
clamp_rctf_to_rcti(rect_dst, &rect_tmp);
}
+void UI_view2d_view_to_region_m4(View2D *v2d, float matrix[4][4])
+{
+ rctf mask;
+ unit_m4(matrix);
+ BLI_rctf_rcti_copy(&mask, &v2d->mask);
+ BLI_rctf_transform_calc_m4_pivot_min(&v2d->cur, &mask, matrix);
+}
+
bool UI_view2d_view_to_region_rcti_clip(View2D *v2d, const rctf *rect_src, rcti *rect_dst)
{
const float cur_size[2] = {BLI_rctf_size_x(&v2d->cur), BLI_rctf_size_y(&v2d->cur)};
diff --git a/source/blender/editors/io/CMakeLists.txt b/source/blender/editors/io/CMakeLists.txt
index b3bbce939a5..4d3f106a5d6 100644
--- a/source/blender/editors/io/CMakeLists.txt
+++ b/source/blender/editors/io/CMakeLists.txt
@@ -24,6 +24,7 @@ set(INC
../../blenlib
../../blentranslation
../../bmesh
+ ../../depsgraph
../../makesdna
../../makesrna
../../windowmanager
diff --git a/source/blender/editors/io/io_alembic.c b/source/blender/editors/io/io_alembic.c
index fb20d9f3caa..ca4ab30a08d 100644
--- a/source/blender/editors/io/io_alembic.c
+++ b/source/blender/editors/io/io_alembic.c
@@ -31,6 +31,9 @@
# include "BLI_winstuff.h"
#endif
+#include <string.h>
+#include <errno.h>
+
#include "MEM_guardedalloc.h"
#include "DNA_mesh_types.h"
@@ -417,9 +420,20 @@ static int get_sequence_len(char *filename, int *ofs)
}
char path[FILE_MAX];
+ BLI_path_abs(filename, G.main->name);
BLI_split_dir_part(filename, path, FILE_MAX);
+ if (path[0] == '\0') {
+ /* The filename had no path, so just use the blend file path. */
+ BLI_split_dir_part(G.main->name, path, FILE_MAX);
+ }
+
DIR *dir = opendir(path);
+ if (dir == NULL) {
+ fprintf(stderr, "Error opening directory '%s': %s\n",
+ path, errno ? strerror(errno) : "unknown error");
+ return -1;
+ }
const char *ext = ".abc";
const char *basename = BLI_path_basename(filename);
@@ -523,6 +537,10 @@ static int wm_alembic_import_exec(bContext *C, wmOperator *op)
if (is_sequence) {
sequence_len = get_sequence_len(filename, &offset);
+ if (sequence_len < 0) {
+ BKE_report(op->reports, RPT_ERROR, "Unable to determine ABC sequence length");
+ return OPERATOR_CANCELLED;
+ }
}
bool ok = ABC_import(C, filename, scale, is_sequence, set_frame_range,
diff --git a/source/blender/editors/io/io_cache.c b/source/blender/editors/io/io_cache.c
index af6f55d7a64..975bbddd893 100644
--- a/source/blender/editors/io/io_cache.c
+++ b/source/blender/editors/io/io_cache.c
@@ -93,26 +93,28 @@ static int cachefile_open_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
- CacheFile *cache_file = BKE_libblock_alloc(bmain, ID_CF, BLI_path_basename(filename));
+ CacheFile *cache_file = BKE_libblock_alloc(bmain, ID_CF, BLI_path_basename(filename), 0);
BLI_strncpy(cache_file->filepath, filename, FILE_MAX);
BKE_cachefile_reload(bmain, cache_file);
- /* hook into UI */
- PropertyPointerRNA *pprop = op->customdata;
-
- if (pprop->prop) {
- /* when creating new ID blocks, use is already 1, but RNA
- * pointer se also increases user, so this compensates it */
- id_us_min(&cache_file->id);
-
- PointerRNA idptr;
- RNA_id_pointer_create(&cache_file->id, &idptr);
- RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr);
- RNA_property_update(C, &pprop->ptr, pprop->prop);
+ /* Will be set when running invoke, not exec directly. */
+ if (op->customdata != NULL) {
+ /* hook into UI */
+ PropertyPointerRNA *pprop = op->customdata;
+ if (pprop->prop) {
+ /* when creating new ID blocks, use is already 1, but RNA
+ * pointer se also increases user, so this compensates it */
+ id_us_min(&cache_file->id);
+
+ PointerRNA idptr;
+ RNA_id_pointer_create(&cache_file->id, &idptr);
+ RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr);
+ RNA_property_update(C, &pprop->ptr, pprop->prop);
+ }
+
+ MEM_freeN(op->customdata);
}
- MEM_freeN(op->customdata);
-
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c
index ba3966d5af6..f9297c58cbb 100644
--- a/source/blender/editors/io/io_collada.c
+++ b/source/blender/editors/io/io_collada.c
@@ -56,6 +56,8 @@
#include "io_collada.h"
+#include "DEG_depsgraph.h"
+
static int wm_collada_export_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
@@ -78,6 +80,7 @@ static int wm_collada_export_invoke(bContext *C, wmOperator *op, const wmEvent *
/* function used for WM_OT_save_mainfile too */
static int wm_collada_export_exec(bContext *C, wmOperator *op)
{
+ EvaluationContext eval_ctx;
char filepath[FILE_MAX];
int apply_modifiers;
int export_mesh_type;
@@ -103,6 +106,8 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
int export_count;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
BKE_report(op->reports, RPT_ERROR, "No filename given");
return OPERATOR_CANCELLED;
@@ -156,7 +161,8 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
ED_object_editmode_load(CTX_data_edit_object(C));
- export_count = collada_export(CTX_data_scene(C),
+ export_count = collada_export(&eval_ctx,
+ CTX_data_scene(C),
CTX_data_scene_layer(C),
filepath,
apply_modifiers,
diff --git a/source/blender/editors/manipulator_library/manipulator_draw_utils.c b/source/blender/editors/manipulator_library/manipulator_draw_utils.c
index 26f9ebbe54e..f15cd9c9793 100644
--- a/source/blender/editors/manipulator_library/manipulator_draw_utils.c
+++ b/source/blender/editors/manipulator_library/manipulator_draw_utils.c
@@ -95,8 +95,8 @@ void wm_manipulator_geometryinfo_draw(const ManipulatorGeomInfo *info, const boo
GWN_vertbuf_attr_fill(vbo, nor_id, info->normals);
}
- batch = GWN_batch_create(GWN_PRIM_TRIS, vbo, el);
- Batch_set_builtin_program(batch, GPU_SHADER_3D_UNIFORM_COLOR);
+ batch = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, el, GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX);
+ GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR);
GWN_batch_uniform_4fv(batch, "color", color);
@@ -115,7 +115,7 @@ void wm_manipulator_geometryinfo_draw(const ManipulatorGeomInfo *info, const boo
#endif
- GWN_batch_discard_all(batch);
+ GWN_batch_discard(batch);
}
void wm_manipulator_vec_draw(
diff --git a/source/blender/editors/manipulator_library/manipulator_library_intern.h b/source/blender/editors/manipulator_library/manipulator_library_intern.h
index ce71017e7bc..92ca195f21d 100644
--- a/source/blender/editors/manipulator_library/manipulator_library_intern.h
+++ b/source/blender/editors/manipulator_library/manipulator_library_intern.h
@@ -50,10 +50,10 @@ typedef struct ManipulatorCommonData {
typedef struct ManipulatorInteraction {
float init_value; /* initial property value */
- float init_matrix[4][4];
float init_mval[2];
float init_offset;
- float init_scale;
+ float init_matrix_final[4][4];
+ float init_matrix_basis[4][4];
/* offset of last handling step */
float prev_offset;
@@ -87,8 +87,11 @@ void manipulator_property_value_reset(
void manipulator_color_get(
const struct wmManipulator *mpr, const bool highlight,
- float r_col[]);
+ float r_color[4]);
+bool manipulator_window_project_2d(
+ bContext *C, const struct wmManipulator *mpr, const float mval[2], int axis, bool use_offset,
+ float r_co[2]);
/* -------------------------------------------------------------------- */
/* Manipulator drawing */
diff --git a/source/blender/editors/manipulator_library/manipulator_library_presets.c b/source/blender/editors/manipulator_library/manipulator_library_presets.c
index d8e66f40be0..e552a7a6aa3 100644
--- a/source/blender/editors/manipulator_library/manipulator_library_presets.c
+++ b/source/blender/editors/manipulator_library/manipulator_library_presets.c
@@ -46,6 +46,7 @@
#include "MEM_guardedalloc.h"
+#include "DEG_depsgraph.h"
#include "RNA_access.h"
@@ -127,7 +128,7 @@ void ED_manipulator_draw_preset_circle(
}
void ED_manipulator_draw_preset_facemap(
- const struct wmManipulator *mpr, struct Scene *scene, Object *ob, const int facemap, int select_id)
+ const bContext *C, const struct wmManipulator *mpr, struct Scene *scene, Object *ob, const int facemap, int select_id)
{
const bool is_select = (select_id != -1);
const bool is_highlight = is_select && (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0;
@@ -139,9 +140,12 @@ void ED_manipulator_draw_preset_facemap(
GPU_select_load_id(select_id);
}
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
gpuPushMatrix();
gpuMultMatrix(ob->obmat);
- ED_draw_object_facemap(scene, ob, color, facemap);
+ ED_draw_object_facemap(&eval_ctx, scene, ob, color, facemap);
gpuPopMatrix();
if (is_select) {
diff --git a/source/blender/editors/manipulator_library/manipulator_library_utils.c b/source/blender/editors/manipulator_library/manipulator_library_utils.c
index 9c182fcf4bc..fb1d1f89626 100644
--- a/source/blender/editors/manipulator_library/manipulator_library_utils.c
+++ b/source/blender/editors/manipulator_library/manipulator_library_utils.c
@@ -36,6 +36,11 @@
#include "BLI_math.h"
#include "BLI_listbase.h"
+#include "DNA_view3d_types.h"
+#include "DNA_screen_types.h"
+
+#include "ED_view3d.h"
+
#include "RNA_access.h"
#include "WM_api.h"
@@ -121,9 +126,13 @@ void manipulator_property_data_update(
if (constrained) {
if ((data->flag & MANIPULATOR_CUSTOM_RANGE_SET) == 0) {
float range[2];
- WM_manipulator_target_property_range_get(mpr, mpr_prop, range);
- data->range = range[1] - range[0];
- data->min = range[0];
+ if (WM_manipulator_target_property_range_get(mpr, mpr_prop, range)) {
+ data->range = range[1] - range[0];
+ data->min = range[0];
+ }
+ else {
+ BLI_assert(0);
+ }
}
data->offset = manipulator_offset_from_value_constr(data->range_fac, data->min, data->range, value, inverted);
}
@@ -152,3 +161,61 @@ void manipulator_color_get(
copy_v4_v4(r_col, mpr->color);
}
}
+
+/* -------------------------------------------------------------------- */
+
+/**
+ * Takes mouse coordinates and returns them in relation to the manipulator.
+ * Both 2D & 3D supported, use so we can use 2D manipulators in the 3D view.
+ */
+bool manipulator_window_project_2d(
+ bContext *C, const struct wmManipulator *mpr, const float mval[2], int axis, bool use_offset,
+ float r_co[2])
+{
+ float mat[4][4];
+ {
+ float mat_identity[4][4];
+ struct WM_ManipulatorMatrixParams params = {NULL};
+ if (use_offset == false) {
+ unit_m4(mat_identity);
+ params.matrix_offset = mat_identity;
+ }
+ WM_manipulator_calc_matrix_final_params(mpr, &params, mat);
+ }
+
+ /* rotate mouse in relation to the center and relocate it */
+ if (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) {
+ /* For 3d views, transform 2D mouse pos onto plane. */
+ View3D *v3d = CTX_wm_view3d(C);
+ ARegion *ar = CTX_wm_region(C);
+
+ float plane[4];
+
+ plane_from_point_normal_v3(plane, mat[3], mat[2]);
+
+ float ray_origin[3], ray_direction[3];
+
+ if (ED_view3d_win_to_ray(ar, v3d, mval, ray_origin, ray_direction, false)) {
+ float lambda;
+ if (isect_ray_plane_v3(ray_origin, ray_direction, plane, &lambda, true)) {
+ float co[3];
+ madd_v3_v3v3fl(co, ray_origin, ray_direction, lambda);
+ float imat[4][4];
+ invert_m4_m4(imat, mat);
+ mul_m4_v3(imat, co);
+ r_co[0] = co[(axis + 1) % 3];
+ r_co[1] = co[(axis + 2) % 3];
+ return true;
+ }
+ }
+ return false;
+ }
+ else {
+ float co[3] = {mval[0], mval[1], 0.0f};
+ float imat[4][4];
+ invert_m4_m4(imat, mat);
+ mul_m4_v3(imat, co);
+ copy_v2_v2(r_co, co);
+ return true;
+ }
+}
diff --git a/source/blender/editors/manipulator_library/manipulator_types/arrow2d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/arrow2d_manipulator.c
index d402ab0b6f1..44dd5698a48 100644
--- a/source/blender/editors/manipulator_library/manipulator_types/arrow2d_manipulator.c
+++ b/source/blender/editors/manipulator_library/manipulator_types/arrow2d_manipulator.c
@@ -63,21 +63,17 @@
static void arrow2d_draw_geom(wmManipulator *mpr, const float matrix[4][4], const float color[4])
{
const float size = 0.11f;
- const float size_h = size / 2.0f;
- const float arrow_length = RNA_float_get(mpr->ptr, "length");
+ const float size_breadth = size / 2.0f;
+ const float size_length = size * 1.7f;
+ /* Subtract the length so the arrow fits in the hotspot. */
+ const float arrow_length = RNA_float_get(mpr->ptr, "length") - size_length;
const float arrow_angle = RNA_float_get(mpr->ptr, "angle");
- const float draw_line_ofs = (mpr->line_width * 0.5f) / mpr->scale_final;
uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
gpuPushMatrix();
gpuMultMatrix(matrix);
- gpuScaleUniform(mpr->scale_final);
gpuRotate2D(RAD2DEGF(arrow_angle));
- /* local offset */
- gpuTranslate2f(
- mpr->matrix_offset[3][0] + draw_line_ofs,
- mpr->matrix_offset[3][1]);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -89,9 +85,9 @@ static void arrow2d_draw_geom(wmManipulator *mpr, const float matrix[4][4], cons
immEnd();
immBegin(GWN_PRIM_TRIS, 3);
- immVertex2f(pos, size_h, arrow_length);
- immVertex2f(pos, -size_h, arrow_length);
- immVertex2f(pos, 0.0f, arrow_length + size * 1.7f);
+ immVertex2f(pos, size_breadth, arrow_length);
+ immVertex2f(pos, -size_breadth, arrow_length);
+ immVertex2f(pos, 0.0f, arrow_length + size_length);
immEnd();
immUnbindProgram();
@@ -101,36 +97,45 @@ static void arrow2d_draw_geom(wmManipulator *mpr, const float matrix[4][4], cons
static void manipulator_arrow2d_draw(const bContext *UNUSED(C), wmManipulator *mpr)
{
- float col[4];
+ float color[4];
+
+ float matrix_final[4][4];
- manipulator_color_get(mpr, mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT, col);
+ manipulator_color_get(mpr, mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT, color);
glLineWidth(mpr->line_width);
+
+ WM_manipulator_calc_matrix_final(mpr, matrix_final);
+
glEnable(GL_BLEND);
- arrow2d_draw_geom(mpr, mpr->matrix_basis, col);
+ arrow2d_draw_geom(mpr, matrix_final, color);
glDisable(GL_BLEND);
if (mpr->interaction_data) {
ManipulatorInteraction *inter = mpr->interaction_data;
glEnable(GL_BLEND);
- arrow2d_draw_geom(mpr, inter->init_matrix, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f});
+ arrow2d_draw_geom(mpr, inter->init_matrix_final, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f});
glDisable(GL_BLEND);
}
}
static void manipulator_arrow2d_setup(wmManipulator *mpr)
{
- mpr->flag |= WM_MANIPULATOR_DRAW_ACTIVE;
+ mpr->flag |= WM_MANIPULATOR_DRAW_MODAL;
}
-static void manipulator_arrow2d_invoke(
+static int manipulator_arrow2d_invoke(
bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *UNUSED(event))
{
ManipulatorInteraction *inter = MEM_callocN(sizeof(ManipulatorInteraction), __func__);
- copy_m4_m4(inter->init_matrix, mpr->matrix_basis);
+ copy_m4_m4(inter->init_matrix_basis, mpr->matrix_basis);
+ WM_manipulator_calc_matrix_final(mpr, inter->init_matrix_final);
+
mpr->interaction_data = inter;
+
+ return OPERATOR_RUNNING_MODAL;
}
static int manipulator_arrow2d_test_select(
@@ -170,16 +175,20 @@ static int manipulator_arrow2d_test_select(
const float lambda_1 = line_point_factor_v2(isect_1, line_ext[0], line_ext[1]);
if (isect == 1) {
- return IN_RANGE_INCL(lambda_1, 0.0f, 1.0f);
+ if (IN_RANGE_INCL(lambda_1, 0.0f, 1.0f)) {
+ return 0;
+ }
}
else {
BLI_assert(isect == 2);
const float lambda_2 = line_point_factor_v2(isect_2, line_ext[0], line_ext[1]);
- return IN_RANGE_INCL(lambda_1, 0.0f, 1.0f) && IN_RANGE_INCL(lambda_2, 0.0f, 1.0f);
+ if (IN_RANGE_INCL(lambda_1, 0.0f, 1.0f) && IN_RANGE_INCL(lambda_2, 0.0f, 1.0f)) {
+ return 0;
+ }
}
}
- return 0;
+ return -1;
}
/* -------------------------------------------------------------------- */
diff --git a/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c
index e95800f3db1..3bbcafb925a 100644
--- a/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c
+++ b/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c
@@ -79,7 +79,7 @@ typedef struct ArrowManipulator3D {
/* -------------------------------------------------------------------- */
-static void manipulator_arrow_matrix_world_get(wmManipulator *mpr, float r_matrix[4][4])
+static void manipulator_arrow_matrix_basis_get(const wmManipulator *mpr, float r_matrix[4][4])
{
ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
@@ -128,7 +128,7 @@ static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select,
const float vec[2][3] = {
{0.0f, 0.0f, 0.0f},
- {0.0f, 0.0f, RNA_float_get(arrow->manipulator.ptr, "length")},
+ {0.0f, 0.0f, arrow_length},
};
glLineWidth(arrow->manipulator.line_width);
@@ -182,33 +182,28 @@ static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select,
static void arrow_draw_intern(ArrowManipulator3D *arrow, const bool select, const bool highlight)
{
- float col[4];
- float final_matrix[4][4];
+ wmManipulator *mpr = &arrow->manipulator;
+ float color[4];
+ float matrix_final[4][4];
- manipulator_color_get(&arrow->manipulator, highlight, col);
- manipulator_arrow_matrix_world_get(&arrow->manipulator, final_matrix);
+ manipulator_color_get(mpr, highlight, color);
- mul_mat3_m4_fl(final_matrix, arrow->manipulator.scale_final);
- mul_m4_m4m4(final_matrix, final_matrix, arrow->manipulator.matrix_offset);
+ WM_manipulator_calc_matrix_final(mpr, matrix_final);
gpuPushMatrix();
- gpuMultMatrix(final_matrix);
+ gpuMultMatrix(matrix_final);
glEnable(GL_BLEND);
- arrow_draw_geom(arrow, select, col);
+ arrow_draw_geom(arrow, select, color);
glDisable(GL_BLEND);
gpuPopMatrix();
- if (arrow->manipulator.interaction_data) {
- ManipulatorInteraction *inter = arrow->manipulator.interaction_data;
- float offset_matrix[4][4];
-
- copy_m4_m4(offset_matrix, inter->init_matrix);
- mul_mat3_m4_fl(offset_matrix, inter->init_scale);
+ if (mpr->interaction_data) {
+ ManipulatorInteraction *inter = mpr->interaction_data;
gpuPushMatrix();
- gpuMultMatrix(offset_matrix);
- gpuMultMatrix(arrow->manipulator.matrix_offset);
+ gpuMultMatrix(inter->init_matrix_final);
+
glEnable(GL_BLEND);
arrow_draw_geom(arrow, select, (const float [4]){0.5f, 0.5f, 0.5f, 0.5f});
@@ -220,9 +215,9 @@ static void arrow_draw_intern(ArrowManipulator3D *arrow, const bool select, cons
static void manipulator_arrow_draw_select(
const bContext *UNUSED(C), wmManipulator *mpr,
- int selectionbase)
+ int select_id)
{
- GPU_select_load_id(selectionbase);
+ GPU_select_load_id(select_id);
arrow_draw_intern((ArrowManipulator3D *)mpr, true, false);
}
@@ -235,7 +230,9 @@ static void manipulator_arrow_draw(const bContext *UNUSED(C), wmManipulator *mpr
* Calculate arrow offset independent from prop min value,
* meaning the range will not be offset by min value first.
*/
-static void manipulator_arrow_modal(bContext *C, wmManipulator *mpr, const wmEvent *event, const int flag)
+static int manipulator_arrow_modal(
+ bContext *C, wmManipulator *mpr, const wmEvent *event,
+ eWM_ManipulatorTweak tweak_flag)
{
ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
ManipulatorInteraction *inter = mpr->interaction_data;
@@ -251,7 +248,7 @@ static void manipulator_arrow_modal(bContext *C, wmManipulator *mpr, const wmEve
bool use_vertical = false;
- copy_v3_v3(orig_origin, inter->init_matrix[3]);
+ copy_v3_v3(orig_origin, inter->init_matrix_basis[3]);
orig_origin[3] = 1.0f;
add_v3_v3v3(offset, orig_origin, arrow->manipulator.matrix_basis[2]);
offset[3] = 1.0f;
@@ -267,7 +264,7 @@ static void manipulator_arrow_modal(bContext *C, wmManipulator *mpr, const wmEve
/* first determine if view vector is really close to the direction. If it is, we use
* vertical movement to determine offset, just like transform system does */
- if (RAD2DEG(acos(dot_v3v3(viewvec, arrow->manipulator.matrix_basis[2]))) > 5.0f) {
+ if (RAD2DEGF(acosf(dot_v3v3(viewvec, arrow->manipulator.matrix_basis[2]))) > 5.0f) {
/* multiply to projection space */
mul_m4_v4(rv3d->persmat, orig_origin);
mul_v4_fl(orig_origin, 1.0f / orig_origin[3]);
@@ -295,7 +292,7 @@ static void manipulator_arrow_modal(bContext *C, wmManipulator *mpr, const wmEve
float zfac = ED_view3d_calc_zfac(rv3d, orig_origin, NULL);
ED_view3d_win_to_delta(ar, dir2d_final, offset, zfac);
- add_v3_v3v3(orig_origin, offset, inter->init_matrix[3]);
+ add_v3_v3v3(orig_origin, offset, inter->init_matrix_basis[3]);
/* calculate view vector for the new position */
if (rv3d->is_persp) {
@@ -314,13 +311,13 @@ static void manipulator_arrow_modal(bContext *C, wmManipulator *mpr, const wmEve
const float plane_offset = dot_v3v3(plane, offset);
const float plane_dir = dot_v3v3(plane, arrow->manipulator.matrix_basis[2]);
const float fac = (plane_dir != 0.0f) ? (plane_offset / plane_dir) : 0.0f;
- facdir = (fac < 0.0) ? -1.0 : 1.0;
+ facdir = (fac < 0.0f) ? -1.0f : 1.0f;
if (isfinite(fac)) {
mul_v3_v3fl(offset, arrow->manipulator.matrix_basis[2], fac);
}
}
else {
- facdir = (m_diff[1] < 0.0) ? -1.0 : 1.0;
+ facdir = (m_diff[1] < 0.0f) ? -1.0f : 1.0f;
}
@@ -334,7 +331,7 @@ static void manipulator_arrow_modal(bContext *C, wmManipulator *mpr, const wmEve
const int draw_options = RNA_enum_get(arrow->manipulator.ptr, "draw_options");
const bool constrained = (draw_options & ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED) != 0;
const bool inverted = (draw_options & ED_MANIPULATOR_ARROW_STYLE_INVERTED) != 0;
- const bool use_precision = (flag & WM_MANIPULATOR_TWEAK_PRECISE) != 0;
+ const bool use_precision = (tweak_flag & WM_MANIPULATOR_TWEAK_PRECISE) != 0;
float value = manipulator_value_from_offset(data, inter, ofs_new, constrained, inverted, use_precision);
WM_manipulator_target_property_value_set(C, mpr, mpr_prop, value);
@@ -350,18 +347,20 @@ static void manipulator_arrow_modal(bContext *C, wmManipulator *mpr, const wmEve
/* tag the region for redraw */
ED_region_tag_redraw(ar);
WM_event_add_mousemove(C);
+
+ return OPERATOR_RUNNING_MODAL;
}
static void manipulator_arrow_setup(wmManipulator *mpr)
{
ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
- arrow->manipulator.flag |= WM_MANIPULATOR_DRAW_ACTIVE;
+ arrow->manipulator.flag |= WM_MANIPULATOR_DRAW_MODAL;
arrow->data.range_fac = 1.0f;
}
-static void manipulator_arrow_invoke(
+static int manipulator_arrow_invoke(
bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event)
{
ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
@@ -378,11 +377,12 @@ static void manipulator_arrow_invoke(
inter->init_mval[0] = event->mval[0];
inter->init_mval[1] = event->mval[1];
- inter->init_scale = mpr->scale_final;
-
- manipulator_arrow_matrix_world_get(mpr, inter->init_matrix);
+ manipulator_arrow_matrix_basis_get(mpr, inter->init_matrix_basis);
+ WM_manipulator_calc_matrix_final(mpr, inter->init_matrix_final);
mpr->interaction_data = inter;
+
+ return OPERATOR_RUNNING_MODAL;
}
static void manipulator_arrow_property_update(wmManipulator *mpr, wmManipulatorProperty *mpr_prop)
@@ -396,15 +396,24 @@ static void manipulator_arrow_property_update(wmManipulator *mpr, wmManipulatorP
static void manipulator_arrow_exit(bContext *C, wmManipulator *mpr, const bool cancel)
{
- if (!cancel)
- return;
-
ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
ManipulatorCommonData *data = &arrow->data;
- ManipulatorInteraction *inter = mpr->interaction_data;
-
wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset");
- manipulator_property_value_reset(C, mpr, inter, mpr_prop);
+ const bool is_prop_valid = WM_manipulator_target_property_is_valid(mpr_prop);
+
+ if (!cancel) {
+ /* Assign incase applying the opetration needs an updated offset
+ * editmesh bisect needs this. */
+ if (is_prop_valid) {
+ data->offset = WM_manipulator_target_property_value_get(mpr, mpr_prop);
+ }
+ return;
+ }
+
+ ManipulatorInteraction *inter = mpr->interaction_data;
+ if (is_prop_valid) {
+ manipulator_property_value_reset(C, mpr, inter, mpr_prop);
+ }
data->offset = inter->init_offset;
}
@@ -454,7 +463,7 @@ static void MANIPULATOR_WT_arrow_3d(wmManipulatorType *wt)
/* api callbacks */
wt->draw = manipulator_arrow_draw;
wt->draw_select = manipulator_arrow_draw_select;
- wt->matrix_world_get = manipulator_arrow_matrix_world_get;
+ wt->matrix_basis_get = manipulator_arrow_matrix_basis_get;
wt->modal = manipulator_arrow_modal;
wt->setup = manipulator_arrow_setup;
wt->invoke = manipulator_arrow_invoke;
diff --git a/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c
index 973f487fd82..d1902864d57 100644
--- a/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c
+++ b/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c
@@ -39,14 +39,18 @@
#include "BKE_context.h"
#include "BLI_math.h"
+#include "BLI_dial.h"
#include "BLI_rect.h"
#include "ED_screen.h"
+#include "ED_view3d.h"
#include "ED_manipulator_library.h"
#include "GPU_matrix.h"
#include "GPU_shader.h"
#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
+#include "GPU_select.h"
#include "MEM_guardedalloc.h"
@@ -56,23 +60,90 @@
#include "WM_api.h"
#include "WM_types.h"
-/* wmManipulator->highlight_part */
-enum {
- ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_TRANSLATE = 1,
- ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEX_LEFT = 2,
- ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEX_RIGHT = 3,
- ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEY_UP = 4,
- ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEY_DOWN = 5,
-};
+/* own includes */
+#include "../manipulator_library_intern.h"
-#define MANIPULATOR_RECT_MIN_WIDTH 15.0f
-#define MANIPULATOR_RESIZER_WIDTH 20.0f
+#define MANIPULATOR_RESIZER_SIZE 10.0f
+#define MANIPULATOR_MARGIN_OFFSET_SCALE 1.5f
+static void manipulator_calc_matrix_final_no_offset(
+ const wmManipulator *mpr, float orig_matrix_final_no_offset[4][4])
+{
+ float mat_identity[4][4];
+ struct WM_ManipulatorMatrixParams params = {NULL};
+ unit_m4(mat_identity);
+ params.matrix_offset = mat_identity;
+ WM_manipulator_calc_matrix_final_params(mpr, &params, orig_matrix_final_no_offset);
+}
+
+static void manipulator_calc_rect_view_scale(
+ const wmManipulator *mpr, const float dims[2], float scale[2])
+{
+ float matrix_final_no_offset[4][4];
+ float asp[2] = {1.0f, 1.0f};
+ if (dims[0] > dims[1]) {
+ asp[0] = dims[1] / dims[0];
+ }
+ else {
+ asp[1] = dims[0] / dims[1];
+ }
+ float x_axis[3], y_axis[3];
+ manipulator_calc_matrix_final_no_offset(mpr, matrix_final_no_offset);
+ mul_v3_mat3_m4v3(x_axis, matrix_final_no_offset, mpr->matrix_offset[0]);
+ mul_v3_mat3_m4v3(y_axis, matrix_final_no_offset, mpr->matrix_offset[1]);
+
+ mul_v2_v2(x_axis, asp);
+ mul_v2_v2(y_axis, asp);
+
+ scale[0] = 1.0f / len_v3(x_axis);
+ scale[1] = 1.0f / len_v3(y_axis);
+}
+
+static void manipulator_calc_rect_view_margin(
+ const wmManipulator *mpr, const float dims[2], float margin[2])
+{
+ float handle_size;
+ if (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) {
+ handle_size = 0.15f;
+ }
+ else {
+ handle_size = MANIPULATOR_RESIZER_SIZE;
+ }
+ handle_size *= mpr->scale_final;
+ float scale_xy[2];
+ manipulator_calc_rect_view_scale(mpr, dims, scale_xy);
+ margin[0] = ((handle_size * scale_xy[0]));
+ margin[1] = ((handle_size * scale_xy[1]));
+}
/* -------------------------------------------------------------------- */
-static void rect_transform_draw_corners(
- const rctf *r, const float offsetx, const float offsety, const float color[3])
+static void manipulator_rect_pivot_from_scale_part(int part, float r_pt[2], bool r_constrain_axis[2])
+{
+ bool x = true, y = true;
+ switch (part) {
+ case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X: { ARRAY_SET_ITEMS(r_pt, 0.5, 0.0); x = false; break; }
+ case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X: { ARRAY_SET_ITEMS(r_pt, -0.5, 0.0); x = false; break; }
+ case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y: { ARRAY_SET_ITEMS(r_pt, 0.0, 0.5); y = false; break; }
+ case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y: { ARRAY_SET_ITEMS(r_pt, 0.0, -0.5); y = false; break; }
+ case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y: { ARRAY_SET_ITEMS(r_pt, 0.5, 0.5); x = y = false; break; }
+ case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y: { ARRAY_SET_ITEMS(r_pt, 0.5, -0.5); x = y = false; break; }
+ case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y: { ARRAY_SET_ITEMS(r_pt, -0.5, 0.5); x = y = false; break; }
+ case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y: { ARRAY_SET_ITEMS(r_pt, -0.5, -0.5); x = y = false; break; }
+ default: BLI_assert(0);
+ }
+ r_constrain_axis[0] = x;
+ r_constrain_axis[1] = y;
+}
+
+/* -------------------------------------------------------------------- */
+/** \name Box Draw Style
+ *
+ * Useful for 3D views, see: #ED_MANIPULATOR_CAGE2D_STYLE_BOX
+ * \{ */
+
+static void cage2d_draw_box_corners(
+ const rctf *r, const float margin[2], const float color[3])
{
uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -81,498 +152,901 @@ static void rect_transform_draw_corners(
immBegin(GWN_PRIM_LINES, 16);
- immVertex2f(pos, r->xmin, r->ymin + offsety);
+ immVertex2f(pos, r->xmin, r->ymin + margin[1]);
immVertex2f(pos, r->xmin, r->ymin);
immVertex2f(pos, r->xmin, r->ymin);
- immVertex2f(pos, r->xmin + offsetx, r->ymin);
+ immVertex2f(pos, r->xmin + margin[0], r->ymin);
- immVertex2f(pos, r->xmax, r->ymin + offsety);
+ immVertex2f(pos, r->xmax, r->ymin + margin[1]);
immVertex2f(pos, r->xmax, r->ymin);
immVertex2f(pos, r->xmax, r->ymin);
- immVertex2f(pos, r->xmax - offsetx, r->ymin);
+ immVertex2f(pos, r->xmax - margin[0], r->ymin);
- immVertex2f(pos, r->xmax, r->ymax - offsety);
+ immVertex2f(pos, r->xmax, r->ymax - margin[1]);
immVertex2f(pos, r->xmax, r->ymax);
immVertex2f(pos, r->xmax, r->ymax);
- immVertex2f(pos, r->xmax - offsetx, r->ymax);
+ immVertex2f(pos, r->xmax - margin[0], r->ymax);
- immVertex2f(pos, r->xmin, r->ymax - offsety);
+ immVertex2f(pos, r->xmin, r->ymax - margin[1]);
immVertex2f(pos, r->xmin, r->ymax);
immVertex2f(pos, r->xmin, r->ymax);
- immVertex2f(pos, r->xmin + offsetx, r->ymax);
+ immVertex2f(pos, r->xmin + margin[0], r->ymax);
immEnd();
immUnbindProgram();
}
-static void rect_transform_draw_interaction(
- const float col[4], const int highlighted,
- const float half_w, const float half_h,
- const float w, const float h, const float line_width)
+static void cage2d_draw_box_interaction(
+ const float color[4], const int highlighted,
+ const float size[2], const float margin[2],
+ const float line_width, const bool is_solid, const int draw_options)
{
- /* Why generate coordinates for 4 vertices, when we only use three? */
+ /* 4 verts for translate, otherwise only 3 are used. */
float verts[4][2];
+ uint verts_len = 0;
+ Gwn_PrimType prim_type = GWN_PRIM_NONE;
switch (highlighted) {
- case ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEX_LEFT:
- verts[0][0] = -half_w + w;
- verts[0][1] = -half_h;
- verts[1][0] = -half_w;
- verts[1][1] = -half_h;
- verts[2][0] = -half_w;
- verts[2][1] = half_h;
- verts[3][0] = -half_w + w;
- verts[3][1] = half_h;
+ case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X:
+ {
+ rctf r = {
+ .xmin = -size[0], .xmax = -size[0] + margin[0],
+ .ymin = -size[1] + margin[1], .ymax = size[1] - margin[1],
+ };
+ ARRAY_SET_ITEMS(verts[0], r.xmin, r.ymin);
+ ARRAY_SET_ITEMS(verts[1], r.xmin, r.ymax);
+ verts_len = 2;
+ if (is_solid) {
+ ARRAY_SET_ITEMS(verts[2], r.xmax, r.ymax);
+ ARRAY_SET_ITEMS(verts[3], r.xmax, r.ymin);
+ verts_len += 2;
+ prim_type = GWN_PRIM_TRI_FAN;
+ }
+ else {
+ prim_type = GWN_PRIM_LINE_STRIP;
+ }
break;
-
- case ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEX_RIGHT:
- verts[0][0] = half_w - w;
- verts[0][1] = -half_h;
- verts[1][0] = half_w;
- verts[1][1] = -half_h;
- verts[2][0] = half_w;
- verts[2][1] = half_h;
- verts[3][0] = half_w - w;
- verts[3][1] = half_h;
+ }
+ case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X:
+ {
+ rctf r = {
+ .xmin = size[0] - margin[0], .xmax = size[0],
+ .ymin = -size[1] + margin[1], .ymax = size[1] - margin[1],
+ };
+ ARRAY_SET_ITEMS(verts[0], r.xmax, r.ymin);
+ ARRAY_SET_ITEMS(verts[1], r.xmax, r.ymax);
+ verts_len = 2;
+ if (is_solid) {
+ ARRAY_SET_ITEMS(verts[2], r.xmin, r.ymax);
+ ARRAY_SET_ITEMS(verts[3], r.xmin, r.ymin);
+ verts_len += 2;
+ prim_type = GWN_PRIM_TRI_FAN;
+ }
+ else {
+ prim_type = GWN_PRIM_LINE_STRIP;
+ }
break;
-
- case ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEY_DOWN:
- verts[0][0] = -half_w;
- verts[0][1] = -half_h + h;
- verts[1][0] = -half_w;
- verts[1][1] = -half_h;
- verts[2][0] = half_w;
- verts[2][1] = -half_h;
- verts[3][0] = half_w;
- verts[3][1] = -half_h + h;
+ }
+ case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y:
+ {
+ rctf r = {
+ .xmin = -size[0] + margin[0], .xmax = size[0] - margin[0],
+ .ymin = -size[1], .ymax = -size[1] + margin[1],
+ };
+ ARRAY_SET_ITEMS(verts[0], r.xmin, r.ymin);
+ ARRAY_SET_ITEMS(verts[1], r.xmax, r.ymin);
+ verts_len = 2;
+ if (is_solid) {
+ ARRAY_SET_ITEMS(verts[2], r.xmax, r.ymax);
+ ARRAY_SET_ITEMS(verts[3], r.xmin, r.ymax);
+ verts_len += 2;
+ prim_type = GWN_PRIM_TRI_FAN;
+ }
+ else {
+ prim_type = GWN_PRIM_LINE_STRIP;
+ }
break;
-
- case ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEY_UP:
- verts[0][0] = -half_w;
- verts[0][1] = half_h - h;
- verts[1][0] = -half_w;
- verts[1][1] = half_h;
- verts[2][0] = half_w;
- verts[2][1] = half_h;
- verts[3][0] = half_w;
- verts[3][1] = half_h - h;
+ }
+ case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y:
+ {
+ rctf r = {
+ .xmin = -size[0] + margin[0], .xmax = size[0] - margin[0],
+ .ymin = size[1] - margin[1], .ymax = size[1],
+ };
+ ARRAY_SET_ITEMS(verts[0], r.xmin, r.ymax);
+ ARRAY_SET_ITEMS(verts[1], r.xmax, r.ymax);
+ verts_len = 2;
+ if (is_solid) {
+ ARRAY_SET_ITEMS(verts[2], r.xmax, r.ymin);
+ ARRAY_SET_ITEMS(verts[3], r.xmin, r.ymin);
+ verts_len += 2;
+ prim_type = GWN_PRIM_TRI_FAN;
+ }
+ else {
+ prim_type = GWN_PRIM_LINE_STRIP;
+ }
+ break;
+ }
+ case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y:
+ {
+ rctf r = {
+ .xmin = -size[0], .xmax = -size[0] + margin[0],
+ .ymin = -size[1], .ymax = -size[1] + margin[1],
+ };
+ ARRAY_SET_ITEMS(verts[0], r.xmax, r.ymin);
+ ARRAY_SET_ITEMS(verts[1], r.xmax, r.ymax);
+ ARRAY_SET_ITEMS(verts[2], r.xmin, r.ymax);
+ verts_len = 3;
+ if (is_solid) {
+ ARRAY_SET_ITEMS(verts[3], r.xmin, r.ymin);
+ verts_len += 1;
+ prim_type = GWN_PRIM_TRI_FAN;
+ }
+ else {
+ prim_type = GWN_PRIM_LINE_STRIP;
+ }
+ break;
+ }
+ case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y:
+ {
+ rctf r = {
+ .xmin = -size[0], .xmax = -size[0] + margin[0],
+ .ymin = size[1] - margin[1], .ymax = size[1],
+ };
+ ARRAY_SET_ITEMS(verts[0], r.xmax, r.ymax);
+ ARRAY_SET_ITEMS(verts[1], r.xmax, r.ymin);
+ ARRAY_SET_ITEMS(verts[2], r.xmin, r.ymin);
+ verts_len = 3;
+ if (is_solid) {
+ ARRAY_SET_ITEMS(verts[3], r.xmin, r.ymax);
+ verts_len += 1;
+ prim_type = GWN_PRIM_TRI_FAN;
+ }
+ else {
+ prim_type = GWN_PRIM_LINE_STRIP;
+ }
+ break;
+ }
+ case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y:
+ {
+ rctf r = {
+ .xmin = size[0] - margin[0], .xmax = size[0],
+ .ymin = -size[1], .ymax = -size[1] + margin[1],
+ };
+ ARRAY_SET_ITEMS(verts[0], r.xmin, r.ymin);
+ ARRAY_SET_ITEMS(verts[1], r.xmin, r.ymax);
+ ARRAY_SET_ITEMS(verts[2], r.xmax, r.ymax);
+ verts_len = 3;
+ if (is_solid) {
+ ARRAY_SET_ITEMS(verts[3], r.xmax, r.ymin);
+ verts_len += 1;
+ prim_type = GWN_PRIM_TRI_FAN;
+ }
+ else {
+ prim_type = GWN_PRIM_LINE_STRIP;
+ }
break;
+ }
+ case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y:
+ {
+ rctf r = {
+ .xmin = size[0] - margin[0], .xmax = size[0],
+ .ymin = size[1] - margin[1], .ymax = size[1],
+ };
+ ARRAY_SET_ITEMS(verts[0], r.xmin, r.ymax);
+ ARRAY_SET_ITEMS(verts[1], r.xmin, r.ymin);
+ ARRAY_SET_ITEMS(verts[2], r.xmax, r.ymin);
+ verts_len = 3;
+ if (is_solid) {
+ ARRAY_SET_ITEMS(verts[3], r.xmax, r.ymax);
+ verts_len += 1;
+ prim_type = GWN_PRIM_TRI_FAN;
+ }
+ else {
+ prim_type = GWN_PRIM_LINE_STRIP;
+ }
+ break;
+ }
+ case ED_MANIPULATOR_CAGE2D_PART_ROTATE:
+ {
+ const float rotate_pt[2] = {0.0f, size[1] + margin[1]};
+ const rctf r_rotate = {
+ .xmin = rotate_pt[0] - margin[0] / 2.0f,
+ .xmax = rotate_pt[0] + margin[0] / 2.0f,
+ .ymin = rotate_pt[1] - margin[1] / 2.0f,
+ .ymax = rotate_pt[1] + margin[1] / 2.0f,
+ };
+
+ ARRAY_SET_ITEMS(verts[0], r_rotate.xmin, r_rotate.ymin);
+ ARRAY_SET_ITEMS(verts[1], r_rotate.xmin, r_rotate.ymax);
+ ARRAY_SET_ITEMS(verts[2], r_rotate.xmax, r_rotate.ymax);
+ ARRAY_SET_ITEMS(verts[3], r_rotate.xmax, r_rotate.ymin);
+ verts_len = 4;
+ if (is_solid) {
+ prim_type = GWN_PRIM_TRI_FAN;
+ }
+ else {
+ prim_type = GWN_PRIM_LINE_STRIP;
+ }
+ break;
+ }
+ case ED_MANIPULATOR_CAGE2D_PART_TRANSLATE:
+ if (draw_options & ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) {
+ ARRAY_SET_ITEMS(verts[0], -margin[0] / 2, -margin[1] / 2);
+ ARRAY_SET_ITEMS(verts[1], margin[0] / 2, margin[1] / 2);
+ ARRAY_SET_ITEMS(verts[2], -margin[0] / 2, margin[1] / 2);
+ ARRAY_SET_ITEMS(verts[3], margin[0] / 2, -margin[1] / 2);
+ verts_len = 4;
+ if (is_solid) {
+ prim_type = GWN_PRIM_TRI_FAN;
+ }
+ else {
+ prim_type = GWN_PRIM_LINES;
+ }
+ }
+ else {
+ /* Only used for 3D view selection, never displayed to the user. */
+ ARRAY_SET_ITEMS(verts[0], -size[0], -size[1]);
+ ARRAY_SET_ITEMS(verts[1], -size[0], size[1]);
+ ARRAY_SET_ITEMS(verts[2], size[0], size[1]);
+ ARRAY_SET_ITEMS(verts[3], size[0], -size[1]);
+ verts_len = 4;
+ if (is_solid) {
+ prim_type = GWN_PRIM_TRI_FAN;
+ }
+ else {
+ /* unreachable */
+ BLI_assert(0);
+ prim_type = GWN_PRIM_LINE_STRIP;
+ }
+ }
+ break;
default:
return;
}
+ BLI_assert(prim_type != GWN_PRIM_NONE);
+
Gwn_VertFormat *format = immVertexFormat();
- uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ struct {
+ uint pos, col;
+ } attr_id = {
+ .pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT),
+ .col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT),
+ };
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
- glLineWidth(line_width + 3.0);
+ {
+ if (is_solid) {
+ BLI_assert(ELEM(prim_type, GWN_PRIM_TRI_FAN));
+ immBegin(prim_type, verts_len);
+ immAttrib3f(attr_id.col, 0.0f, 0.0f, 0.0f);
+ for (uint i = 0; i < verts_len; i++) {
+ immVertex2fv(attr_id.pos, verts[i]);
+ }
+ immEnd();
+ }
+ else {
+ BLI_assert(ELEM(prim_type, GWN_PRIM_LINE_STRIP, GWN_PRIM_LINES));
+ glLineWidth(line_width + 3.0f);
- immBegin(GWN_PRIM_LINE_STRIP, 3);
- immAttrib3f(color, 0.0f, 0.0f, 0.0f);
- immVertex2fv(pos, verts[0]);
- immVertex2fv(pos, verts[1]);
- immVertex2fv(pos, verts[2]);
- immEnd();
+ immBegin(prim_type, verts_len);
+ immAttrib3f(attr_id.col, 0.0f, 0.0f, 0.0f);
+ for (uint i = 0; i < verts_len; i++) {
+ immVertex2fv(attr_id.pos, verts[i]);
+ }
+ immEnd();
- glLineWidth(line_width);
+ glLineWidth(line_width);
- immBegin(GWN_PRIM_LINE_STRIP, 3);
- immAttrib3fv(color, col);
- immVertex2fv(pos, verts[0]);
- immVertex2fv(pos, verts[1]);
- immVertex2fv(pos, verts[2]);
- immEnd();
+ immBegin(prim_type, verts_len);
+ immAttrib3fv(attr_id.col, color);
+ for (uint i = 0; i < verts_len; i++) {
+ immVertex2fv(attr_id.pos, verts[i]);
+ }
+ immEnd();
+ }
+ }
immUnbindProgram();
}
-static void manipulator_rect_transform_draw(const bContext *UNUSED(C), wmManipulator *mpr)
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Circle Draw Style
+ *
+ * Useful for 2D views, see: #ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE
+ * \{ */
+
+static void imm_draw_point_aspect_2d(
+ uint pos, float x, float y, float rad_x, float rad_y, bool solid)
{
- float dims[2];
- RNA_float_get_array(mpr->ptr, "dimensions", dims);
- float w = dims[0];
- float h = dims[1];
+ immBegin(solid ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_LOOP, 4);
+ immVertex2f(pos, x - rad_x, y - rad_y);
+ immVertex2f(pos, x - rad_x, y + rad_y);
+ immVertex2f(pos, x + rad_x, y + rad_y);
+ immVertex2f(pos, x + rad_x, y - rad_y);
+ immEnd();
+}
- float scale[2];
- RNA_float_get_array(mpr->ptr, "scale", scale);
+static void cage2d_draw_circle_wire(
+ const rctf *r, const float margin[2], const float color[3],
+ const int transform_flag, const int draw_options)
+{
+ uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- const int transform_flag = RNA_enum_get(mpr->ptr, "transform");
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+ immUniformColor3fv(color);
- float aspx = 1.0f, aspy = 1.0f;
- const float half_w = w / 2.0f;
- const float half_h = h / 2.0f;
- const rctf r = {
- .xmin = -half_w,
- .ymin = -half_h,
- .xmax = half_w,
- .ymax = half_h,
- };
+ immBegin(GWN_PRIM_LINE_LOOP, 4);
+ immVertex2f(pos, r->xmin, r->ymin);
+ immVertex2f(pos, r->xmax, r->ymin);
+ immVertex2f(pos, r->xmax, r->ymax);
+ immVertex2f(pos, r->xmin, r->ymax);
+ immEnd();
- gpuPushMatrix();
- gpuMultMatrix(mpr->matrix_basis);
- gpuMultMatrix(mpr->matrix_offset);
- if (transform_flag & ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM) {
- gpuScaleUniform(scale[0]);
- }
- else {
- gpuScale2fv(scale);
+ if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE) {
+ immBegin(GWN_PRIM_LINE_LOOP, 2);
+ immVertex2f(pos, BLI_rctf_cent_x(r), r->ymax);
+ immVertex2f(pos, BLI_rctf_cent_x(r), r->ymax + margin[1]);
+ immEnd();
}
- if (w > h) {
- aspx = h / w;
- }
- else {
- aspy = w / h;
+ if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) {
+ if (draw_options & ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) {
+ const float rad[2] = {margin[0] / 2, margin[1] / 2};
+ const float center[2] = {BLI_rctf_cent_x(r), BLI_rctf_cent_y(r)};
+
+ immBegin(GWN_PRIM_LINES, 4);
+ immVertex2f(pos, center[0] - rad[0], center[1] - rad[1]);
+ immVertex2f(pos, center[0] + rad[0], center[1] + rad[1]);
+ immVertex2f(pos, center[0] + rad[0], center[1] - rad[1]);
+ immVertex2f(pos, center[0] - rad[0], center[1] + rad[1]);
+ immEnd();
+ }
}
- w = min_ff(aspx * w / MANIPULATOR_RESIZER_WIDTH, MANIPULATOR_RESIZER_WIDTH / scale[0]);
- h = min_ff(aspy * h / MANIPULATOR_RESIZER_WIDTH, MANIPULATOR_RESIZER_WIDTH /
- ((transform_flag & ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM) ? scale[0] : scale[1]));
- /* corner manipulators */
- glLineWidth(mpr->line_width + 3.0f);
-
- rect_transform_draw_corners(&r, w, h, (const float[3]){0, 0, 0});
+ immUnbindProgram();
+}
- /* corner manipulators */
- glLineWidth(mpr->line_width);
- rect_transform_draw_corners(&r, w, h, mpr->color);
+static void cage2d_draw_circle_handles(
+ const rctf *r, const float margin[2], const float color[3],
+ const int transform_flag,
+ bool solid)
+{
+ uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ void (*circle_fn)(uint, float, float, float, float, int) =
+ (solid) ? imm_draw_circle_fill_aspect_2d : imm_draw_circle_wire_aspect_2d;
+ const int resolu = 12;
+ const float rad[2] = {margin[0] / 3, margin[1] / 3};
- rect_transform_draw_interaction(
- mpr->color, mpr->highlight_part, half_w, half_h,
- w, h, mpr->line_width);
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+ immUniformColor3fv(color);
- glLineWidth(1.0);
- gpuPopMatrix();
-}
+ /* should really divide by two, but looks too bulky. */
+ {
+ imm_draw_point_aspect_2d(pos, r->xmin, r->ymin, rad[0], rad[1], solid);
+ imm_draw_point_aspect_2d(pos, r->xmax, r->ymin, rad[0], rad[1], solid);
+ imm_draw_point_aspect_2d(pos, r->xmax, r->ymax, rad[0], rad[1], solid);
+ imm_draw_point_aspect_2d(pos, r->xmin, r->ymax, rad[0], rad[1], solid);
+ }
-static int manipulator_rect_transform_get_cursor(wmManipulator *mpr)
-{
- switch (mpr->highlight_part) {
- case ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_TRANSLATE:
- return BC_HANDCURSOR;
- case ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEX_LEFT:
- case ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEX_RIGHT:
- return CURSOR_X_MOVE;
- case ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEY_DOWN:
- case ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEY_UP:
- return CURSOR_Y_MOVE;
- default:
- return CURSOR_STD;
+ if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE) {
+ const float handle[2] = {BLI_rctf_cent_x(r), r->ymax + (margin[1] * MANIPULATOR_MARGIN_OFFSET_SCALE)};
+ circle_fn(pos, handle[0], handle[1], rad[0], rad[1], resolu);
}
+
+ immUnbindProgram();
}
-static int manipulator_rect_transform_test_select(
- bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event)
+/** \} */
+
+static void manipulator_cage2d_draw_intern(
+ wmManipulator *mpr, const bool select, const bool highlight, const int select_id)
{
- const float mouse[2] = {event->mval[0], event->mval[1]};
- //float matrot[2][2];
- float point_local[2];
- float scale[2];
- RNA_float_get_array(mpr->ptr, "scale", scale);
+ // const bool use_clamp = (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) == 0;
float dims[2];
RNA_float_get_array(mpr->ptr, "dimensions", dims);
- float w = dims[0];
- float h = dims[1];
- float half_w = w / 2.0f;
- float half_h = h / 2.0f;
- float aspx = 1.0f, aspy = 1.0f;
+ float matrix_final[4][4];
const int transform_flag = RNA_enum_get(mpr->ptr, "transform");
+ const int draw_style = RNA_enum_get(mpr->ptr, "draw_style");
+ const int draw_options = RNA_enum_get(mpr->ptr, "draw_options");
- /* rotate mouse in relation to the center and relocate it */
- sub_v2_v2v2(point_local, mouse, mpr->matrix_basis[3]);
- point_local[0] -= mpr->matrix_offset[3][0];
- point_local[1] -= mpr->matrix_offset[3][1];
- //rotate_m2(matrot, -cage->transform.rotation);
+ const float size_real[2] = {dims[0] / 2.0f, dims[1] / 2.0f};
- if (transform_flag & ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM) {
- mul_v2_fl(point_local, 1.0f / scale[0]);
- }
- else {
- point_local[0] /= scale[0];
- point_local[1] /= scale[0];
+ WM_manipulator_calc_matrix_final(mpr, matrix_final);
+
+ gpuPushMatrix();
+ gpuMultMatrix(matrix_final);
+
+ float margin[2];
+ manipulator_calc_rect_view_margin(mpr, dims, margin);
+
+ /* Handy for quick testing draw (if it's outside bounds). */
+ if (false) {
+ glEnable(GL_BLEND);
+ uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+ immUniformColor4fv((const float[4]){1, 1, 1, 0.5f});
+ float s = 0.5f;
+ immRectf(pos, -s, -s, s, s);
+ immUnbindProgram();
+ glDisable(GL_BLEND);
}
- if (dims[0] > dims[1]) {
- aspx = h / w;
+ if (select) {
+ /* expand for hotspot */
+ const float size[2] = {size_real[0] + margin[0] / 2, size_real[1] + margin[1] / 2};
+
+ if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE) {
+ int scale_parts[] = {
+ ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X,
+ ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X,
+ ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y,
+ ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y,
+
+ ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y,
+ ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y,
+ ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y,
+ ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y,
+ };
+ for (int i = 0; i < ARRAY_SIZE(scale_parts); i++) {
+ GPU_select_load_id(select_id | scale_parts[i]);
+ cage2d_draw_box_interaction(
+ mpr->color, scale_parts[i], size, margin, mpr->line_width, true, draw_options);
+ }
+ }
+ if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) {
+ const int transform_part = ED_MANIPULATOR_CAGE2D_PART_TRANSLATE;
+ GPU_select_load_id(select_id | transform_part);
+ cage2d_draw_box_interaction(
+ mpr->color, transform_part, size, margin, mpr->line_width, true, draw_options);
+ }
+ if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE) {
+ cage2d_draw_box_interaction(
+ mpr->color, ED_MANIPULATOR_CAGE2D_PART_ROTATE, size_real, margin, mpr->line_width, true, draw_options);
+ }
}
else {
- aspy = w / h;
- }
- w = min_ff(aspx * w / MANIPULATOR_RESIZER_WIDTH, MANIPULATOR_RESIZER_WIDTH / scale[0]);
- h = min_ff(aspy * h / MANIPULATOR_RESIZER_WIDTH, MANIPULATOR_RESIZER_WIDTH /
- ((transform_flag & ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM) ? scale[0] : scale[1]));
-
-
- rctf r;
-
- r.xmin = -half_w + w;
- r.ymin = -half_h + h;
- r.xmax = half_w - w;
- r.ymax = half_h - h;
+ const rctf r = {
+ .xmin = -size_real[0],
+ .ymin = -size_real[1],
+ .xmax = size_real[0],
+ .ymax = size_real[1],
+ };
+ if (draw_style == ED_MANIPULATOR_CAGE2D_STYLE_BOX) {
+ /* corner manipulators */
+ glLineWidth(mpr->line_width + 3.0f);
+ cage2d_draw_box_corners(&r, margin, (const float[3]){0, 0, 0});
+
+ /* corner manipulators */
+ float color[4];
+ manipulator_color_get(mpr, highlight, color);
+ glLineWidth(mpr->line_width);
+ cage2d_draw_box_corners(&r, margin, color);
+
+ bool show = false;
+ if (mpr->highlight_part == ED_MANIPULATOR_CAGE2D_PART_TRANSLATE) {
+ /* Only show if we're drawing the center handle
+ * otherwise the entire rectangle is the hotspot. */
+ if (draw_options & ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) {
+ show = true;
+ }
+ }
+ else {
+ show = true;
+ }
- bool isect = BLI_rctf_isect_pt_v(&r, point_local);
+ if (show) {
+ cage2d_draw_box_interaction(
+ mpr->color, mpr->highlight_part, size_real, margin, mpr->line_width, false, draw_options);
+ }
- if (isect)
- return ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_TRANSLATE;
+ if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE) {
+ cage2d_draw_box_interaction(
+ mpr->color, ED_MANIPULATOR_CAGE2D_PART_ROTATE, size_real, margin, mpr->line_width, false, draw_options);
+ }
+ }
+ else if (draw_style == ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE) {
+ float color[4];
+ manipulator_color_get(mpr, highlight, color);
- /* if manipulator does not have a scale intersection, don't do it */
- if (transform_flag &
- (ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE | ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM))
- {
- r.xmin = -half_w;
- r.ymin = -half_h;
- r.xmax = -half_w + w;
- r.ymax = half_h;
+ glEnable(GL_LINE_SMOOTH);
+ glEnable(GL_BLEND);
- isect = BLI_rctf_isect_pt_v(&r, point_local);
+ glLineWidth(mpr->line_width + 3.0f);
+ cage2d_draw_circle_wire(&r, margin, (const float[3]){0, 0, 0}, transform_flag, draw_options);
+ glLineWidth(mpr->line_width);
+ cage2d_draw_circle_wire(&r, margin, color, transform_flag, draw_options);
- if (isect)
- return ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEX_LEFT;
- r.xmin = half_w - w;
- r.ymin = -half_h;
- r.xmax = half_w;
- r.ymax = half_h;
+ /* corner manipulators */
+ cage2d_draw_circle_handles(&r, margin, color, transform_flag, true);
+ cage2d_draw_circle_handles(&r, margin, (const float[3]){0, 0, 0}, transform_flag, false);
- isect = BLI_rctf_isect_pt_v(&r, point_local);
+ glDisable(GL_BLEND);
+ glDisable(GL_LINE_SMOOTH);
+ }
+ else {
+ BLI_assert(0);
+ }
+ }
- if (isect)
- return ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEX_RIGHT;
+ glLineWidth(1.0);
+ gpuPopMatrix();
+}
- r.xmin = -half_w;
- r.ymin = -half_h;
- r.xmax = half_w;
- r.ymax = -half_h + h;
+/**
+ * For when we want to draw 2d cage in 3d views.
+ */
+static void manipulator_cage2d_draw_select(const bContext *UNUSED(C), wmManipulator *mpr, int select_id)
+{
+ manipulator_cage2d_draw_intern(mpr, true, false, select_id);
+}
- isect = BLI_rctf_isect_pt_v(&r, point_local);
+static void manipulator_cage2d_draw(const bContext *UNUSED(C), wmManipulator *mpr)
+{
+ const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0;
+ manipulator_cage2d_draw_intern(mpr, false, is_highlight, -1);
+}
- if (isect)
- return ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEY_DOWN;
+static int manipulator_cage2d_get_cursor(wmManipulator *mpr)
+{
+ int highlight_part = mpr->highlight_part;
- r.xmin = -half_w;
- r.ymin = half_h - h;
- r.xmax = half_w;
- r.ymax = half_h;
+ if (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) {
+ return BC_NSEW_SCROLLCURSOR;
+ }
- isect = BLI_rctf_isect_pt_v(&r, point_local);
+ switch (highlight_part) {
+ case ED_MANIPULATOR_CAGE2D_PART_TRANSLATE:
+ return BC_HANDCURSOR;
+ case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X:
+ case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X:
+ return CURSOR_X_MOVE;
+ case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y:
+ case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y:
+ return CURSOR_Y_MOVE;
- if (isect)
- return ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEY_UP;
+ /* TODO diagonal cursor */
+ case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y:
+ case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y:
+ return BC_NSEW_SCROLLCURSOR;
+ case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y:
+ case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y:
+ return BC_NSEW_SCROLLCURSOR;
+ case ED_MANIPULATOR_CAGE2D_PART_ROTATE:
+ return BC_CROSSCURSOR;
+ default:
+ return CURSOR_STD;
}
-
- return 0;
}
-typedef struct RectTransformInteraction {
- float orig_mouse[2];
- float orig_offset[2];
- float orig_scale[2];
-} RectTransformInteraction;
-
-static bool manipulator_rect_transform_get_prop_value(
- wmManipulator *mpr, wmManipulatorProperty *mpr_prop, float *value)
+static int manipulator_cage2d_test_select(
+ bContext *C, wmManipulator *mpr, const wmEvent *event)
{
- PropertyType type = RNA_property_type(mpr_prop->prop);
+ float point_local[2];
+ float dims[2];
+ RNA_float_get_array(mpr->ptr, "dimensions", dims);
+ const float size_real[2] = {dims[0] / 2.0f, dims[1] / 2.0f};
+
+ if (manipulator_window_project_2d(
+ C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false)
+ {
+ return -1;
+ }
+
+ float margin[2];
+ manipulator_calc_rect_view_margin(mpr, dims, margin);
+ /* expand for hotspot */
+ const float size[2] = {size_real[0] + margin[0] / 2, size_real[1] + margin[1] / 2};
- if (type != PROP_FLOAT) {
- fprintf(stderr, "Rect Transform manipulator can only be bound to float properties");
- return false;
+ const int transform_flag = RNA_enum_get(mpr->ptr, "transform");
+ const int draw_options = RNA_enum_get(mpr->ptr, "draw_options");
+
+ if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) {
+ rctf r;
+ if (draw_options & ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) {
+ r.xmin = -margin[0] / 2;
+ r.ymin = -margin[1] / 2;
+ r.xmax = margin[0] / 2;
+ r.ymax = margin[1] / 2;
+ }
+ else {
+ r.xmin = -size[0] + margin[0];
+ r.ymin = -size[1] + margin[1];
+ r.xmax = size[0] - margin[0];
+ r.ymax = size[1] - margin[1];
+ };
+ bool isect = BLI_rctf_isect_pt_v(&r, point_local);
+ if (isect) {
+ return ED_MANIPULATOR_CAGE2D_PART_TRANSLATE;
+ }
}
- else {
- if (STREQ(mpr_prop->type->idname, "offset")) {
- if (RNA_property_array_length(&mpr_prop->ptr, mpr_prop->prop) != 2) {
- fprintf(stderr, "Rect Transform manipulator offset not only be bound to array float property");
- return false;
+
+ /* if manipulator does not have a scale intersection, don't do it */
+ if (transform_flag & (ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE | ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM)) {
+ const rctf r_xmin = {.xmin = -size[0], .ymin = -size[1], .xmax = -size[0] + margin[0], .ymax = size[1]};
+ const rctf r_xmax = {.xmin = size[0] - margin[0], .ymin = -size[1], .xmax = size[0], .ymax = size[1]};
+ const rctf r_ymin = {.xmin = -size[0], .ymin = -size[1], .xmax = size[0], .ymax = -size[1] + margin[1]};
+ const rctf r_ymax = {.xmin = -size[0], .ymin = size[1] - margin[1], .xmax = size[0], .ymax = size[1]};
+
+ if (BLI_rctf_isect_pt_v(&r_xmin, point_local)) {
+ if (BLI_rctf_isect_pt_v(&r_ymin, point_local)) {
+ return ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y;
+ }
+ if (BLI_rctf_isect_pt_v(&r_ymax, point_local)) {
+ return ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y;
}
- RNA_property_float_get_array(&mpr_prop->ptr, mpr_prop->prop, value);
+ return ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X;
}
- else if (STREQ(mpr_prop->type->idname, "scale")) {
- const int transform_flag = RNA_enum_get(mpr->ptr, "transform");
- if (transform_flag & ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM) {
- *value = RNA_property_float_get(&mpr_prop->ptr, mpr_prop->prop);
+ if (BLI_rctf_isect_pt_v(&r_xmax, point_local)) {
+ if (BLI_rctf_isect_pt_v(&r_ymin, point_local)) {
+ return ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y;
}
- else {
- if (RNA_property_array_length(&mpr_prop->ptr, mpr_prop->prop) != 2) {
- fprintf(stderr, "Rect Transform manipulator scale not only be bound to array float property");
- return false;
- }
- RNA_property_float_get_array(&mpr_prop->ptr, mpr_prop->prop, value);
+ if (BLI_rctf_isect_pt_v(&r_ymax, point_local)) {
+ return ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y;
}
+ return ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X;
}
- else {
- BLI_assert(0);
+ if (BLI_rctf_isect_pt_v(&r_ymin, point_local)) {
+ return ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y;
+ }
+ if (BLI_rctf_isect_pt_v(&r_ymax, point_local)) {
+ return ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y;
+ }
+ }
+
+ if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE) {
+ /* Rotate:
+ * (*) <-- hot spot is here!
+ * +---+
+ * | |
+ * +---+ */
+ const float r_rotate_pt[2] = {0.0f, size_real[1] + (margin[1] * MANIPULATOR_MARGIN_OFFSET_SCALE)};
+ const rctf r_rotate = {
+ .xmin = r_rotate_pt[0] - margin[0] / 2.0f,
+ .xmax = r_rotate_pt[0] + margin[0] / 2.0f,
+ .ymin = r_rotate_pt[1] - margin[1] / 2.0f,
+ .ymax = r_rotate_pt[1] + margin[1] / 2.0f,
+ };
+
+ if (BLI_rctf_isect_pt_v(&r_rotate, point_local)) {
+ return ED_MANIPULATOR_CAGE2D_PART_ROTATE;
}
}
- return true;
+ return -1;
}
-static void manipulator_rect_transform_setup(wmManipulator *mpr)
+typedef struct RectTransformInteraction {
+ float orig_mouse[2];
+ float orig_matrix_offset[4][4];
+ float orig_matrix_final_no_offset[4][4];
+ Dial *dial;
+} RectTransformInteraction;
+
+static void manipulator_cage2d_setup(wmManipulator *mpr)
{
- mpr->flag |= WM_MANIPULATOR_DRAW_ACTIVE;
+ mpr->flag |= WM_MANIPULATOR_DRAW_MODAL | WM_MANIPULATOR_DRAW_NO_SCALE;
}
-static void manipulator_rect_transform_invoke(
- bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event)
+static int manipulator_cage2d_invoke(
+ bContext *C, wmManipulator *mpr, const wmEvent *event)
{
RectTransformInteraction *data = MEM_callocN(sizeof(RectTransformInteraction), "cage_interaction");
- float scale[2];
- RNA_float_get_array(mpr->ptr, "scale", scale);
+ copy_m4_m4(data->orig_matrix_offset, mpr->matrix_offset);
+ manipulator_calc_matrix_final_no_offset(mpr, data->orig_matrix_final_no_offset);
- copy_v2_v2(data->orig_offset, mpr->matrix_offset[3]);
- copy_v2_v2(data->orig_scale, scale);
-
- data->orig_mouse[0] = event->mval[0];
- data->orig_mouse[1] = event->mval[1];
+ if (manipulator_window_project_2d(
+ C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, false, data->orig_mouse) == 0)
+ {
+ zero_v2(data->orig_mouse);
+ }
mpr->interaction_data = data;
+
+ return OPERATOR_RUNNING_MODAL;
}
-static void manipulator_rect_transform_modal(
+static int manipulator_cage2d_modal(
bContext *C, wmManipulator *mpr, const wmEvent *event,
- const int UNUSED(flag))
+ eWM_ManipulatorTweak UNUSED(tweak_flag))
{
+ /* For transform logic to be managable we operate in -0.5..0.5 2D space,
+ * no matter the size of the rectangle, mouse coorts are scaled to unit space.
+ * The mouse coords have been projected into the matrix so we don't need to worry about axis alignment.
+ *
+ * - The cursor offset are multiplied by 'dims'.
+ * - Matrix translation is also multiplied by 'dims'.
+ */
RectTransformInteraction *data = mpr->interaction_data;
- /* needed here as well in case clamping occurs */
- const float orig_ofx = mpr->matrix_offset[3][0], orig_ofy = mpr->matrix_offset[3][1];
-
- const float valuex = (event->mval[0] - data->orig_mouse[0]);
- const float valuey = (event->mval[1] - data->orig_mouse[1]);
-
- const int transform_flag = RNA_enum_get(mpr->ptr, "transform");
+ float point_local[2];
float dims[2];
RNA_float_get_array(mpr->ptr, "dimensions", dims);
- float scale[2];
- RNA_float_get_array(mpr->ptr, "scale", scale);
-
- if (mpr->highlight_part == ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_TRANSLATE) {
- mpr->matrix_offset[3][0] = data->orig_offset[0] + valuex;
- mpr->matrix_offset[3][1] = data->orig_offset[1] + valuey;
+ {
+ float matrix_back[4][4];
+ copy_m4_m4(matrix_back, mpr->matrix_offset);
+ copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset);
+
+ bool ok = manipulator_window_project_2d(
+ C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, false, point_local);
+ copy_m4_m4(mpr->matrix_offset, matrix_back);
+ if (!ok) {
+ return OPERATOR_RUNNING_MODAL;
+ }
}
- else if (mpr->highlight_part == ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEX_LEFT) {
- mpr->matrix_offset[3][0] = data->orig_offset[0] + valuex / 2.0;
- scale[0] = (dims[0] * data->orig_scale[0] - valuex) / dims[0];
+
+ const int transform_flag = RNA_enum_get(mpr->ptr, "transform");
+ wmManipulatorProperty *mpr_prop;
+
+ mpr_prop = WM_manipulator_target_property_find(mpr, "matrix");
+ if (mpr_prop->type != NULL) {
+ WM_manipulator_target_property_value_get_array(mpr, mpr_prop, &mpr->matrix_offset[0][0]);
}
- else if (mpr->highlight_part == ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEX_RIGHT) {
- mpr->matrix_offset[3][0] = data->orig_offset[0] + valuex / 2.0;
- scale[0] = (dims[0] * data->orig_scale[0] + valuex) / dims[0];
+
+ if (mpr->highlight_part == ED_MANIPULATOR_CAGE2D_PART_TRANSLATE) {
+ /* do this to prevent clamping from changing size */
+ copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset);
+ mpr->matrix_offset[3][0] = data->orig_matrix_offset[3][0] + (point_local[0] - data->orig_mouse[0]);
+ mpr->matrix_offset[3][1] = data->orig_matrix_offset[3][1] + (point_local[1] - data->orig_mouse[1]);
}
- else if (mpr->highlight_part == ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEY_DOWN) {
- mpr->matrix_offset[3][1] = data->orig_offset[1] + valuey / 2.0;
+ else if (mpr->highlight_part == ED_MANIPULATOR_CAGE2D_PART_ROTATE) {
- if (transform_flag & ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM) {
- scale[0] = (dims[1] * data->orig_scale[0] - valuey) / dims[1];
- }
- else {
- scale[1] = (dims[1] * data->orig_scale[1] - valuey) / dims[1];
+#define MUL_V2_V3_M4_FINAL(test_co, mouse_co) \
+ mul_v3_m4v3(test_co, data->orig_matrix_final_no_offset, ((const float[3]){UNPACK2(mouse_co), 0.0}))
+
+ float test_co[3];
+
+ if (data->dial == NULL) {
+ MUL_V2_V3_M4_FINAL(test_co, data->orig_matrix_offset[3]);
+
+ data->dial = BLI_dial_initialize(test_co, FLT_EPSILON);
+
+ MUL_V2_V3_M4_FINAL(test_co, data->orig_mouse);
+ BLI_dial_angle(data->dial, test_co);
}
+
+ /* rotate */
+ MUL_V2_V3_M4_FINAL(test_co, point_local);
+ const float angle = BLI_dial_angle(data->dial, test_co);
+
+ float matrix_space_inv[4][4];
+ float matrix_rotate[4][4];
+ float pivot[3];
+
+ copy_v3_v3(pivot, data->orig_matrix_offset[3]);
+
+ invert_m4_m4(matrix_space_inv, mpr->matrix_space);
+
+ unit_m4(matrix_rotate);
+ mul_m4_m4m4(matrix_rotate, matrix_rotate, matrix_space_inv);
+ rotate_m4(matrix_rotate, 'Z', -angle);
+ mul_m4_m4m4(matrix_rotate, matrix_rotate, mpr->matrix_space);
+
+ zero_v3(matrix_rotate[3]);
+ transform_pivot_set_m4(matrix_rotate, pivot);
+
+ mul_m4_m4m4(mpr->matrix_offset, matrix_rotate, data->orig_matrix_offset);
+
+#undef MUL_V2_V3_M4_FINAL
}
- else if (mpr->highlight_part == ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEY_UP) {
- mpr->matrix_offset[3][1] = data->orig_offset[1] + valuey / 2.0;
+ else {
+ /* scale */
+ copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset);
+ float pivot[2];
+ bool constrain_axis[2] = {false};
- if (transform_flag & ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM) {
- scale[0] = (dims[1] * data->orig_scale[0] + valuey) / dims[1];
+ if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) {
+ manipulator_rect_pivot_from_scale_part(mpr->highlight_part, pivot, constrain_axis);
}
else {
- scale[1] = (dims[1] * data->orig_scale[1] + valuey) / dims[1];
+ zero_v2(pivot);
}
- }
- /* clamping - make sure manipulator is at least 5 pixels wide */
- if (transform_flag & ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM) {
- if (scale[0] < MANIPULATOR_RECT_MIN_WIDTH / dims[1] ||
- scale[0] < MANIPULATOR_RECT_MIN_WIDTH / dims[0])
- {
- scale[0] = max_ff(MANIPULATOR_RECT_MIN_WIDTH / dims[1], MANIPULATOR_RECT_MIN_WIDTH / dims[0]);
- mpr->matrix_offset[3][0] = orig_ofx;
- mpr->matrix_offset[3][1] = orig_ofy;
+ /* Cursor deltas scaled to (-0.5..0.5). */
+ float delta_orig[2], delta_curr[2];
+ for (int i = 0; i < 2; i++) {
+ delta_orig[i] = ((data->orig_mouse[i] - data->orig_matrix_offset[3][i]) / dims[i]) - pivot[i];
+ delta_curr[i] = ((point_local[i] - data->orig_matrix_offset[3][i]) / dims[i]) - pivot[i];
}
- }
- else {
- if (scale[0] < MANIPULATOR_RECT_MIN_WIDTH / dims[0]) {
- scale[0] = MANIPULATOR_RECT_MIN_WIDTH / dims[0];
- mpr->matrix_offset[3][0] = orig_ofx;
+
+ float scale[2] = {1.0f, 1.0f};
+ for (int i = 0; i < 2; i++) {
+ if (constrain_axis[i] == false) {
+ if (delta_orig[i] < 0.0f) {
+ delta_orig[i] *= -1.0f;
+ delta_curr[i] *= -1.0f;
+ }
+ const int sign = signum_i(scale[i]);
+
+ scale[i] = 1.0f + ((delta_curr[i] - delta_orig[i]) / len_v3(data->orig_matrix_offset[i]));
+
+ if ((transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_SIGNED) == 0) {
+ if (sign != signum_i(scale[i])) {
+ scale[i] = 0.0f;
+ }
+ }
+ }
}
- if (scale[1] < MANIPULATOR_RECT_MIN_WIDTH / dims[1]) {
- scale[1] = MANIPULATOR_RECT_MIN_WIDTH / dims[1];
- mpr->matrix_offset[3][1] = orig_ofy;
+
+ if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM) {
+ if (constrain_axis[0] == false && constrain_axis[1] == false) {
+ scale[1] = scale[0] = (scale[1] + scale[0]) / 2.0f;
+ }
+ else if (constrain_axis[0] == false) {
+ scale[1] = scale[0];
+ }
+ else if (constrain_axis[1] == false) {
+ scale[0] = scale[1];
+ }
+ else {
+ BLI_assert(0);
+ }
}
- }
- RNA_float_set_array(mpr->ptr, "scale", scale);
+ /* scale around pivot */
+ float matrix_scale[4][4];
+ unit_m4(matrix_scale);
- wmManipulatorProperty *mpr_prop;
+ mul_v3_fl(matrix_scale[0], scale[0]);
+ mul_v3_fl(matrix_scale[1], scale[1]);
- mpr_prop = WM_manipulator_target_property_find(mpr, "offset");
- if (mpr_prop->prop != NULL) {
- RNA_property_float_set_array(&mpr_prop->ptr, mpr_prop->prop, mpr->matrix_offset[3]);
- RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop);
+ transform_pivot_set_m4(matrix_scale, (const float [3]){pivot[0] * dims[0], pivot[1] * dims[1], 0.0f});
+ mul_m4_m4m4(mpr->matrix_offset, data->orig_matrix_offset, matrix_scale);
}
- mpr_prop = WM_manipulator_target_property_find(mpr, "scale");
- if (mpr_prop->prop != NULL) {
- if (transform_flag & ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM) {
- RNA_property_float_set(&mpr_prop->ptr, mpr_prop->prop, scale[0]);
- }
- else {
- RNA_property_float_set_array(&mpr_prop->ptr, mpr_prop->prop, scale);
- }
- RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop);
+ if (mpr_prop->type != NULL) {
+ WM_manipulator_target_property_value_set_array(C, mpr, mpr_prop, &mpr->matrix_offset[0][0]);
}
/* tag the region for redraw */
ED_region_tag_redraw(CTX_wm_region(C));
+ WM_event_add_mousemove(C);
+
+ return OPERATOR_RUNNING_MODAL;
}
-static void manipulator_rect_transform_property_update(wmManipulator *mpr, wmManipulatorProperty *mpr_prop)
+static void manipulator_cage2d_property_update(wmManipulator *mpr, wmManipulatorProperty *mpr_prop)
{
- if (STREQ(mpr_prop->type->idname, "offset")) {
- manipulator_rect_transform_get_prop_value(mpr, mpr_prop, mpr->matrix_offset[3]);
- }
- else if (STREQ(mpr_prop->type->idname, "scale")) {
- float scale[2];
- RNA_float_get_array(mpr->ptr, "scale", scale);
- manipulator_rect_transform_get_prop_value(mpr, mpr_prop, scale);
+ if (STREQ(mpr_prop->type->idname, "matrix")) {
+ if (WM_manipulator_target_property_array_length(mpr, mpr_prop) == 16) {
+ WM_manipulator_target_property_value_get_array(mpr, mpr_prop, &mpr->matrix_offset[0][0]);
+ }
+ else {
+ BLI_assert(0);
+ }
}
else {
BLI_assert(0);
}
}
-static void manipulator_rect_transform_exit(bContext *C, wmManipulator *mpr, const bool cancel)
+static void manipulator_cage2d_exit(bContext *C, wmManipulator *mpr, const bool cancel)
{
RectTransformInteraction *data = mpr->interaction_data;
+ MEM_SAFE_FREE(data->dial);
+
if (!cancel)
return;
wmManipulatorProperty *mpr_prop;
/* reset properties */
- mpr_prop = WM_manipulator_target_property_find(mpr, "offset");
- if (mpr_prop->prop != NULL) {
- RNA_property_float_set_array(&mpr_prop->ptr, mpr_prop->prop, data->orig_offset);
- RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop);
+ mpr_prop = WM_manipulator_target_property_find(mpr, "matrix");
+ if (mpr_prop->type != NULL) {
+ WM_manipulator_target_property_value_set_array(C, mpr, mpr_prop, &data->orig_matrix_offset[0][0]);
}
- mpr_prop = WM_manipulator_target_property_find(mpr, "scale");
- if (mpr_prop->prop != NULL) {
- const int transform_flag = RNA_enum_get(mpr->ptr, "transform");
- if (transform_flag & ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM) {
- RNA_property_float_set(&mpr_prop->ptr, mpr_prop->prop, data->orig_scale[0]);
- }
- else {
- RNA_property_float_set_array(&mpr_prop->ptr, mpr_prop->prop, data->orig_scale);
- }
- RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop);
- }
+ copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset);
}
@@ -587,33 +1061,44 @@ static void MANIPULATOR_WT_cage_2d(wmManipulatorType *wt)
wt->idname = "MANIPULATOR_WT_cage_2d";
/* api callbacks */
- wt->draw = manipulator_rect_transform_draw;
- wt->setup = manipulator_rect_transform_setup;
- wt->invoke = manipulator_rect_transform_invoke;
- wt->property_update = manipulator_rect_transform_property_update;
- wt->modal = manipulator_rect_transform_modal;
- wt->test_select = manipulator_rect_transform_test_select;
- wt->exit = manipulator_rect_transform_exit;
- wt->cursor_get = manipulator_rect_transform_get_cursor;
+ wt->draw = manipulator_cage2d_draw;
+ wt->draw_select = manipulator_cage2d_draw_select;
+ wt->test_select = manipulator_cage2d_test_select;
+ wt->setup = manipulator_cage2d_setup;
+ wt->invoke = manipulator_cage2d_invoke;
+ wt->property_update = manipulator_cage2d_property_update;
+ wt->modal = manipulator_cage2d_modal;
+ wt->exit = manipulator_cage2d_exit;
+ wt->cursor_get = manipulator_cage2d_get_cursor;
wt->struct_size = sizeof(wmManipulator);
/* rna */
+ static EnumPropertyItem rna_enum_draw_style[] = {
+ {ED_MANIPULATOR_CAGE2D_STYLE_BOX, "BOX", 0, "Box", ""},
+ {ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE, "CIRCLE", 0, "Circle", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
static EnumPropertyItem rna_enum_transform[] = {
- {ED_MANIPULATOR_RECT_TRANSFORM_FLAG_TRANSLATE, "TRANSLATE", 0, "Translate", ""},
- {ED_MANIPULATOR_RECT_TRANSFORM_FLAG_ROTATE, "ROTATE", 0, "Rotate", ""},
- {ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE, "SCALE", 0, "Scale", ""},
- {ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM, "SCALE_UNIFORM", 0, "Scale Uniform", ""},
+ {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE, "TRANSLATE", 0, "Translate", ""},
+ {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE, "ROTATE", 0, "Rotate", ""},
+ {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE, "SCALE", 0, "Scale", ""},
+ {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM, "SCALE_UNIFORM", 0, "Scale Uniform", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+ static EnumPropertyItem rna_enum_draw_options[] = {
+ {ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE, "XFORM_CENTER_HANDLE", 0, "Center Handle", ""},
{0, NULL, 0, NULL, NULL}
};
- static float scale_default[2] = {1.0f, 1.0f};
- RNA_def_float_vector(wt->srna, "scale", 2, scale_default, 0, FLT_MAX, "Scale", "", 0.0f, FLT_MAX);
- RNA_def_float_vector(wt->srna, "dimensions", 2, NULL, 0, FLT_MAX, "Dimensions", "", 0.0f, FLT_MAX);
+ static float unit_v2[2] = {1.0f, 1.0f};
+ RNA_def_float_vector(wt->srna, "dimensions", 2, unit_v2, 0, FLT_MAX, "Dimensions", "", 0.0f, FLT_MAX);
RNA_def_enum_flag(wt->srna, "transform", rna_enum_transform, 0, "Transform Options", "");
+ RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE, "Draw Style", "");
+ RNA_def_enum_flag(
+ wt->srna, "draw_options", rna_enum_draw_options,
+ ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE, "Draw Options", "");
- WM_manipulatortype_target_property_def(wt, "offset", PROP_FLOAT, 1);
- WM_manipulatortype_target_property_def(wt, "scale", PROP_FLOAT, 2);
- WM_manipulatortype_target_property_def(wt, "scale_uniform", PROP_FLOAT, 1);
+ WM_manipulatortype_target_property_def(wt, "matrix", PROP_FLOAT, 16);
}
void ED_manipulatortypes_cage_2d(void)
diff --git a/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
index 485b42f9929..ec490a0d047 100644
--- a/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
+++ b/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
@@ -71,7 +71,9 @@
/* to use custom dials exported to geom_dial_manipulator.c */
// #define USE_MANIPULATOR_CUSTOM_DIAL
-static void manipulator_dial_modal(bContext *C, wmManipulator *mpr, const wmEvent *event, const int flag);
+static int manipulator_dial_modal(
+ bContext *C, wmManipulator *mpr, const wmEvent *event,
+ eWM_ManipulatorTweak tweak_flag);
typedef struct DialInteraction {
float init_mval[2];
@@ -94,7 +96,9 @@ typedef struct DialInteraction {
#define DIAL_WIDTH 1.0f
#define DIAL_RESOLUTION 32
-
+/**
+ * We can't use this for the #wmManipulatorType.matrix_basis_get callback, it conflicts with depth picking.
+ */
static void dial_calc_matrix(const wmManipulator *mpr, float mat[4][4])
{
float rot[3][3];
@@ -103,13 +107,12 @@ static void dial_calc_matrix(const wmManipulator *mpr, float mat[4][4])
rotation_between_vecs_to_mat3(rot, up, mpr->matrix_basis[2]);
copy_m4_m3(mat, rot);
copy_v3_v3(mat[3], mpr->matrix_basis[3]);
- mul_mat3_m4_fl(mat, mpr->scale_final);
}
/* -------------------------------------------------------------------- */
static void dial_geom_draw(
- const wmManipulator *mpr, const float col[4], const bool select,
+ const wmManipulator *mpr, const float color[4], const bool select,
float axis_modal_mat[4][4], float clip_plane[4])
{
#ifdef USE_MANIPULATOR_CUSTOM_DIAL
@@ -134,13 +137,13 @@ static void dial_geom_draw(
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
}
- immUniformColor4fv(col);
+ immUniformColor4fv(color);
if (filled) {
- imm_draw_circle_fill(pos, 0, 0, 1.0, DIAL_RESOLUTION);
+ imm_draw_circle_fill_2d(pos, 0, 0, 1.0, DIAL_RESOLUTION);
}
else {
- imm_draw_circle_wire(pos, 0, 0, 1.0, DIAL_RESOLUTION);
+ imm_draw_circle_wire_2d(pos, 0, 0, 1.0, DIAL_RESOLUTION);
}
immUnbindProgram();
@@ -152,7 +155,7 @@ static void dial_geom_draw(
/**
* Draws a line from (0, 0, 0) to \a co_outer, at \a angle.
*/
-static void dial_ghostarc_draw_helpline(const float angle, const float co_outer[3], const float col[4])
+static void dial_ghostarc_draw_helpline(const float angle, const float co_outer[3], const float color[4])
{
glLineWidth(1.0f);
@@ -163,7 +166,7 @@ static void dial_ghostarc_draw_helpline(const float angle, const float co_outer[
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- immUniformColor4fv(col);
+ immUniformColor4fv(color);
immBegin(GWN_PRIM_LINE_STRIP, 2);
immVertex3f(pos, 0.0f, 0.0f, 0.0f);
@@ -184,7 +187,7 @@ static void dial_ghostarc_draw(
uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
immUniformColor4fv(color);
- imm_draw_disk_partial_fill(
+ imm_draw_disk_partial_fill_2d(
pos, 0, 0, 0.0, width_inner, DIAL_RESOLUTION, RAD2DEGF(angle_ofs), RAD2DEGF(angle_delta));
immUnbindProgram();
}
@@ -218,7 +221,7 @@ static void dial_ghostarc_get_angles(
plane_from_point_normal_v3(dial_plane, mpr->matrix_basis[3], axis_vec);
if (!ED_view3d_win_to_ray(ar, v3d, inter->init_mval, ray_co, ray_no, false) ||
- !isect_ray_plane_v3(ray_co, ray_no, dial_plane, &ray_lambda, false))
+ !isect_ray_plane_v3(ray_co, ray_no, dial_plane, &ray_lambda, false))
{
goto fail;
}
@@ -226,7 +229,7 @@ static void dial_ghostarc_get_angles(
sub_v3_v3(proj_mval_init_rel, mpr->matrix_basis[3]);
if (!ED_view3d_win_to_ray(ar, v3d, mval, ray_co, ray_no, false) ||
- !isect_ray_plane_v3(ray_co, ray_no, dial_plane, &ray_lambda, false))
+ !isect_ray_plane_v3(ray_co, ray_no, dial_plane, &ray_lambda, false))
{
goto fail;
}
@@ -271,22 +274,27 @@ static void dial_draw_intern(
const bContext *C, wmManipulator *mpr,
const bool select, const bool highlight, float clip_plane[4])
{
- float mat[4][4];
- float col[4];
+ float matrix_basis_adjust[4][4];
+ float matrix_final[4][4];
+ float color[4];
BLI_assert(CTX_wm_area(C)->spacetype == SPACE_VIEW3D);
- manipulator_color_get(mpr, highlight, col);
+ manipulator_color_get(mpr, highlight, color);
+
+ dial_calc_matrix(mpr, matrix_basis_adjust);
- dial_calc_matrix(mpr, mat);
+ WM_manipulator_calc_matrix_final_params(
+ mpr, &((struct WM_ManipulatorMatrixParams) {
+ .matrix_basis = (void *)matrix_basis_adjust,
+ }), matrix_final);
gpuPushMatrix();
- gpuMultMatrix(mat);
- gpuMultMatrix(mpr->matrix_offset);
+ gpuMultMatrix(matrix_final);
/* draw rotation indicator arc first */
if ((mpr->flag & WM_MANIPULATOR_DRAW_VALUE) &&
- (mpr->state & WM_MANIPULATOR_STATE_ACTIVE))
+ (mpr->state & WM_MANIPULATOR_STATE_MODAL))
{
const float co_outer[4] = {0.0f, DIAL_WIDTH, 0.0f}; /* coordinate at which the arc drawing will be started */
@@ -305,8 +313,8 @@ static void dial_draw_intern(
for (int i = 0; i < 2; i++) {
dial_ghostarc_draw(mpr, angle_ofs, angle_delta, (const float [4]){0.8f, 0.8f, 0.8f, 0.4f});
- dial_ghostarc_draw_helpline(angle_ofs, co_outer, col); /* starting position */
- dial_ghostarc_draw_helpline(angle_ofs + angle_delta, co_outer, col); /* starting position + current value */
+ dial_ghostarc_draw_helpline(angle_ofs, co_outer, color); /* starting position */
+ dial_ghostarc_draw_helpline(angle_ofs + angle_delta, co_outer, color); /* starting position + current value */
if (i == 0) {
const int draw_options = RNA_enum_get(mpr->ptr, "draw_options");
@@ -315,17 +323,17 @@ static void dial_draw_intern(
}
}
- angle_ofs += M_PI;
+ angle_ofs += (float)M_PI;
}
}
/* draw actual dial manipulator */
- dial_geom_draw(mpr, col, select, mat, clip_plane);
+ dial_geom_draw(mpr, color, select, matrix_basis_adjust, clip_plane);
gpuPopMatrix();
}
-static void manipulator_dial_draw_select(const bContext *C, wmManipulator *mpr, int selectionbase)
+static void manipulator_dial_draw_select(const bContext *C, wmManipulator *mpr, int select_id)
{
float clip_plane_buf[4];
const int draw_options = RNA_enum_get(mpr->ptr, "draw_options");
@@ -341,7 +349,7 @@ static void manipulator_dial_draw_select(const bContext *C, wmManipulator *mpr,
glEnable(GL_CLIP_DISTANCE0);
}
- GPU_select_load_id(selectionbase);
+ GPU_select_load_id(select_id);
dial_draw_intern(C, mpr, true, false, clip_plane);
if (clip_plane) {
@@ -351,11 +359,11 @@ static void manipulator_dial_draw_select(const bContext *C, wmManipulator *mpr,
static void manipulator_dial_draw(const bContext *C, wmManipulator *mpr)
{
- const bool active = mpr->state & WM_MANIPULATOR_STATE_ACTIVE;
- const bool highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0;
+ const bool is_modal = mpr->state & WM_MANIPULATOR_STATE_MODAL;
+ const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0;
float clip_plane_buf[4];
const int draw_options = RNA_enum_get(mpr->ptr, "draw_options");
- float *clip_plane = (!active && (draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP)) ? clip_plane_buf : NULL;
+ float *clip_plane = (!is_modal && (draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP)) ? clip_plane_buf : NULL;
/* enable clipping if needed */
if (clip_plane) {
@@ -364,13 +372,13 @@ static void manipulator_dial_draw(const bContext *C, wmManipulator *mpr)
copy_v3_v3(clip_plane, rv3d->viewinv[2]);
clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], mpr->matrix_basis[3]);
- clip_plane[3] -= 0.02 * mpr->scale_final;
+ clip_plane[3] -= 0.02f * mpr->scale_final;
glEnable(GL_CLIP_DISTANCE0);
}
glEnable(GL_BLEND);
- dial_draw_intern(C, mpr, false, highlight, clip_plane);
+ dial_draw_intern(C, mpr, false, is_highlight, clip_plane);
glDisable(GL_BLEND);
if (clip_plane) {
@@ -378,7 +386,9 @@ static void manipulator_dial_draw(const bContext *C, wmManipulator *mpr)
}
}
-static void manipulator_dial_modal(bContext *C, wmManipulator *mpr, const wmEvent *event, const int UNUSED(flag))
+static int manipulator_dial_modal(
+ bContext *C, wmManipulator *mpr, const wmEvent *event,
+ eWM_ManipulatorTweak UNUSED(tweak_flag))
{
const float co_outer[4] = {0.0f, DIAL_WIDTH, 0.0f}; /* coordinate at which the arc drawing will be started */
float angle_ofs, angle_delta;
@@ -400,6 +410,7 @@ static void manipulator_dial_modal(bContext *C, wmManipulator *mpr, const wmEven
if (WM_manipulator_target_property_is_valid(mpr_prop)) {
WM_manipulator_target_property_value_set(C, mpr, mpr_prop, inter->init_prop_angle + angle_delta);
}
+ return OPERATOR_RUNNING_MODAL;
}
@@ -411,7 +422,7 @@ static void manipulator_dial_setup(wmManipulator *mpr)
copy_v3_v3(mpr->matrix_basis[2], dir_default);
}
-static void manipulator_dial_invoke(
+static int manipulator_dial_invoke(
bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event)
{
DialInteraction *inter = MEM_callocN(sizeof(DialInteraction), __func__);
@@ -425,6 +436,8 @@ static void manipulator_dial_invoke(
}
mpr->interaction_data = inter;
+
+ return OPERATOR_RUNNING_MODAL;
}
/* -------------------------------------------------------------------- */
@@ -432,8 +445,6 @@ static void manipulator_dial_invoke(
*
* \{ */
-#define ASSERT_TYPE_CHECK(mpr) BLI_assert(mpr->type->draw == manipulator_dial_draw)
-
static void MANIPULATOR_WT_dial_3d(wmManipulatorType *wt)
{
/* identifiers */
diff --git a/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c
index 9e563f6133b..5353104a1fd 100644
--- a/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c
+++ b/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c
@@ -23,7 +23,7 @@
*
* \name Grab Manipulator
*
- * 3D Manipulator
+ * 3D Manipulator, also works in 2D views.
*
* \brief Simple manipulator to grab and translate.
*
@@ -63,7 +63,23 @@
#include "../manipulator_geometry.h"
#include "../manipulator_library_intern.h"
-static void manipulator_grab_modal(bContext *C, wmManipulator *mpr, const wmEvent *event, const int flag);
+typedef struct GrabManipulator3D {
+ wmManipulator manipulator;
+ /* Added to 'matrix_basis' when calculating the matrix. */
+ float prop_co[3];
+} GrabManipulator3D;
+
+static void manipulator_grab_matrix_basis_get(const wmManipulator *mpr, float r_matrix[4][4])
+{
+ GrabManipulator3D *grab = (GrabManipulator3D *)mpr;
+
+ copy_m4_m4(r_matrix, grab->manipulator.matrix_basis);
+ add_v3_v3(r_matrix[3], grab->prop_co);
+}
+
+static int manipulator_grab_modal(
+ bContext *C, wmManipulator *mpr, const wmEvent *event,
+ eWM_ManipulatorTweak tweak_flag);
typedef struct GrabInteraction {
float init_mval[2];
@@ -71,26 +87,21 @@ typedef struct GrabInteraction {
/* only for when using properties */
float init_prop_co[3];
- /* final output values, used for drawing */
- struct {
- float co_ofs[3];
- float co_final[3];
- } output;
+ float init_matrix_final[4][4];
} GrabInteraction;
-#define DIAL_WIDTH 1.0f
#define DIAL_RESOLUTION 32
/* -------------------------------------------------------------------- */
static void grab_geom_draw(
- const wmManipulator *mpr, const float col[4], const bool select)
+ const wmManipulator *mpr, const float color[4], const bool select, const int draw_options)
{
#ifdef USE_MANIPULATOR_CUSTOM_DIAL
UNUSED_VARS(grab3d, col, axis_modal_mat);
wm_manipulator_geometryinfo_draw(&wm_manipulator_geom_data_grab3d, select);
#else
- const int draw_options = RNA_enum_get(mpr->ptr, "draw_options");
+ const int draw_style = RNA_enum_get(mpr->ptr, "draw_style");
const bool filled = (draw_options & ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL) != 0;
glLineWidth(mpr->line_width);
@@ -100,13 +111,27 @@ static void grab_geom_draw(
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- immUniformColor4fv(col);
+ immUniformColor4fv(color);
- if (filled) {
- imm_draw_circle_fill(pos, 0, 0, 1.0, DIAL_RESOLUTION);
+ if (draw_style == ED_MANIPULATOR_GRAB_STYLE_RING_2D) {
+ if (filled) {
+ imm_draw_circle_fill_2d(pos, 0, 0, 1.0f, DIAL_RESOLUTION);
+ }
+ else {
+ imm_draw_circle_wire_2d(pos, 0, 0, 1.0f, DIAL_RESOLUTION);
+ }
+ }
+ else if (draw_style == ED_MANIPULATOR_GRAB_STYLE_CROSS_2D) {
+ immBegin(GWN_PRIM_LINES, 4);
+ immVertex2f(pos, 1.0f, 1.0f);
+ immVertex2f(pos, -1.0f, -1.0f);
+
+ immVertex2f(pos, -1.0f, 1.0f);
+ immVertex2f(pos, 1.0f, -1.0f);
+ immEnd();
}
else {
- imm_draw_circle_wire(pos, 0, 0, 1.0, DIAL_RESOLUTION);
+ BLI_assert(0);
}
immUnbindProgram();
@@ -126,83 +151,124 @@ static void grab3d_get_translate(
};
RegionView3D *rv3d = ar->regiondata;
- const float *co_ref = inter->init_prop_co;
+ float co_ref[3];
+ mul_v3_mat3_m4v3(co_ref, mpr->matrix_space, inter->init_prop_co);
const float zfac = ED_view3d_calc_zfac(rv3d, co_ref, NULL);
ED_view3d_win_to_delta(ar, mval_delta, co_delta, zfac);
+
+ float matrix_space_inv[3][3];
+ copy_m3_m4(matrix_space_inv, mpr->matrix_space);
+ invert_m3(matrix_space_inv);
+ mul_m3_v3(matrix_space_inv, co_delta);
}
static void grab3d_draw_intern(
const bContext *C, wmManipulator *mpr,
const bool select, const bool highlight)
{
- float mat[4][4];
- float col[4];
-
- BLI_assert(CTX_wm_area(C)->spacetype == SPACE_VIEW3D);
-
- manipulator_color_get(mpr, highlight, col);
+ GrabInteraction *inter = mpr->interaction_data;
+ const int draw_options = RNA_enum_get(mpr->ptr, "draw_options");
+ const bool align_view = (draw_options & ED_MANIPULATOR_GRAB_DRAW_FLAG_ALIGN_VIEW) != 0;
+ float color[4];
+ float matrix_final[4][4];
+ float matrix_align[4][4];
- copy_m4_m4(mat, mpr->matrix_basis);
- mul_mat3_m4_fl(mat, mpr->scale_final);
+ manipulator_color_get(mpr, highlight, color);
+ WM_manipulator_calc_matrix_final(mpr, matrix_final);
gpuPushMatrix();
- if (mpr->interaction_data) {
- GrabInteraction *inter = mpr->interaction_data;
- gpuTranslate3fv(inter->output.co_ofs);
+ gpuMultMatrix(matrix_final);
+
+ if (align_view) {
+ float matrix_final_unit[4][4];
+ RegionView3D *rv3d = CTX_wm_region_view3d(C);
+ normalize_m4_m4(matrix_final_unit, matrix_final);
+ mul_m4_m4m4(matrix_align, rv3d->viewmat, matrix_final_unit);
+ zero_v3(matrix_align[3]);
+ transpose_m4(matrix_align);
+ gpuMultMatrix(matrix_align);
}
- gpuMultMatrix(mat);
- gpuMultMatrix(mpr->matrix_offset);
+
glEnable(GL_BLEND);
- grab_geom_draw(mpr, col, select);
+ grab_geom_draw(mpr, color, select, draw_options);
glDisable(GL_BLEND);
gpuPopMatrix();
if (mpr->interaction_data) {
gpuPushMatrix();
- gpuMultMatrix(mat);
- gpuMultMatrix(mpr->matrix_offset);
+ gpuMultMatrix(inter->init_matrix_final);
+
+ if (align_view) {
+ gpuMultMatrix(matrix_align);
+ }
+
glEnable(GL_BLEND);
- grab_geom_draw(mpr, (const float [4]){0.5f, 0.5f, 0.5f, 0.5f}, select);
+ grab_geom_draw(mpr, (const float [4]){0.5f, 0.5f, 0.5f, 0.5f}, select, draw_options);
glDisable(GL_BLEND);
gpuPopMatrix();
}
}
-static void manipulator_grab_draw_select(const bContext *C, wmManipulator *mpr, int selectionbase)
+static void manipulator_grab_draw_select(const bContext *C, wmManipulator *mpr, int select_id)
{
- GPU_select_load_id(selectionbase);
+ GPU_select_load_id(select_id);
grab3d_draw_intern(C, mpr, true, false);
}
static void manipulator_grab_draw(const bContext *C, wmManipulator *mpr)
{
- const bool active = mpr->state & WM_MANIPULATOR_STATE_ACTIVE;
- const bool highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0;
+ const bool is_modal = mpr->state & WM_MANIPULATOR_STATE_MODAL;
+ const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0;
- (void)active;
+ (void)is_modal;
glEnable(GL_BLEND);
- grab3d_draw_intern(C, mpr, false, highlight);
+ grab3d_draw_intern(C, mpr, false, is_highlight);
glDisable(GL_BLEND);
}
-static void manipulator_grab_modal(bContext *C, wmManipulator *mpr, const wmEvent *event, const int UNUSED(flag))
+static int manipulator_grab_modal(
+ bContext *C, wmManipulator *mpr, const wmEvent *event,
+ eWM_ManipulatorTweak UNUSED(tweak_flag))
{
+ GrabManipulator3D *grab = (GrabManipulator3D *)mpr;
GrabInteraction *inter = mpr->interaction_data;
+ ARegion *ar = CTX_wm_region(C);
- grab3d_get_translate(mpr, event, CTX_wm_region(C), inter->output.co_ofs);
-
- add_v3_v3v3(inter->output.co_final, inter->init_prop_co, inter->output.co_ofs);
+ float prop_delta[3];
+ if (CTX_wm_area(C)->spacetype == SPACE_VIEW3D) {
+ grab3d_get_translate(mpr, event, ar, prop_delta);
+ }
+ else {
+ float mval_proj_init[2], mval_proj_curr[2];
+ if ((manipulator_window_project_2d(
+ C, mpr, inter->init_mval, 2, false, mval_proj_init) == false) ||
+ (manipulator_window_project_2d(
+ C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, false, mval_proj_curr) == false))
+ {
+ return OPERATOR_RUNNING_MODAL;
+ }
+ sub_v2_v2v2(prop_delta, mval_proj_curr, mval_proj_init);
+ prop_delta[2] = 0.0f;
+ }
+ add_v3_v3v3(grab->prop_co, inter->init_prop_co, prop_delta);
/* set the property for the operator and call its modal function */
wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset");
if (WM_manipulator_target_property_is_valid(mpr_prop)) {
- WM_manipulator_target_property_value_set_array(C, mpr, mpr_prop, inter->output.co_final);
+ WM_manipulator_target_property_value_set_array(C, mpr, mpr_prop, grab->prop_co);
+ }
+ else {
+ zero_v3(grab->prop_co);
}
+
+ ED_region_tag_redraw(ar);
+
+ return OPERATOR_RUNNING_MODAL;
}
-static void manipulator_grab_invoke(
+static int manipulator_grab_invoke(
bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event)
{
GrabInteraction *inter = MEM_callocN(sizeof(GrabInteraction), __func__);
@@ -210,12 +276,55 @@ static void manipulator_grab_invoke(
inter->init_mval[0] = event->mval[0];
inter->init_mval[1] = event->mval[1];
+#if 0
+ copy_v3_v3(inter->init_prop_co, grab->prop_co);
+#else
wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset");
if (WM_manipulator_target_property_is_valid(mpr_prop)) {
WM_manipulator_target_property_value_get_array(mpr, mpr_prop, inter->init_prop_co);
}
+#endif
+
+ WM_manipulator_calc_matrix_final(mpr, inter->init_matrix_final);
mpr->interaction_data = inter;
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+
+static int manipulator_grab_test_select(
+ bContext *C, wmManipulator *mpr, const wmEvent *event)
+{
+ float point_local[2];
+
+ if (manipulator_window_project_2d(
+ C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false)
+ {
+ return -1;
+ }
+
+ if (len_squared_v2(point_local) < SQUARE(mpr->scale_final)) {
+ return 0;
+ }
+
+ return -1;
+}
+
+static void manipulator_grab_property_update(wmManipulator *mpr, wmManipulatorProperty *mpr_prop)
+{
+ GrabManipulator3D *grab = (GrabManipulator3D *)mpr;
+ if (WM_manipulator_target_property_is_valid(mpr_prop)) {
+ WM_manipulator_target_property_value_get_array(mpr, mpr_prop, grab->prop_co);
+ }
+ else {
+ zero_v3(grab->prop_co);
+ }
+}
+
+static int manipulator_grab_cursor_get(wmManipulator *UNUSED(mpr))
+{
+ return BC_HANDCURSOR;
}
/* -------------------------------------------------------------------- */
@@ -223,8 +332,6 @@ static void manipulator_grab_invoke(
*
* \{ */
-#define ASSERT_TYPE_CHECK(mpr) BLI_assert(mpr->type->draw == manipulator_grab_draw)
-
static void MANIPULATOR_WT_grab_3d(wmManipulatorType *wt)
{
/* identifiers */
@@ -233,22 +340,28 @@ static void MANIPULATOR_WT_grab_3d(wmManipulatorType *wt)
/* api callbacks */
wt->draw = manipulator_grab_draw;
wt->draw_select = manipulator_grab_draw_select;
+ wt->test_select = manipulator_grab_test_select;
+ wt->matrix_basis_get = manipulator_grab_matrix_basis_get;
wt->invoke = manipulator_grab_invoke;
+ wt->property_update = manipulator_grab_property_update;
wt->modal = manipulator_grab_modal;
+ wt->cursor_get = manipulator_grab_cursor_get;
- wt->struct_size = sizeof(wmManipulator);
+ wt->struct_size = sizeof(GrabManipulator3D);
/* rna */
static EnumPropertyItem rna_enum_draw_style[] = {
- {ED_MANIPULATOR_GRAB_STYLE_RING, "RING", 0, "Ring", ""},
+ {ED_MANIPULATOR_GRAB_STYLE_RING_2D, "RING_2D", 0, "Ring", ""},
+ {ED_MANIPULATOR_GRAB_STYLE_CROSS_2D, "CROSS_2D", 0, "Ring", ""},
{0, NULL, 0, NULL, NULL}
};
static EnumPropertyItem rna_enum_draw_options[] = {
{ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL, "FILL", 0, "Filled", ""},
+ {ED_MANIPULATOR_GRAB_DRAW_FLAG_ALIGN_VIEW, "ALIGN_VIEW", 0, "Align View", ""},
{0, NULL, 0, NULL, NULL}
};
- RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_MANIPULATOR_GRAB_STYLE_RING, "Draw Style", "");
+ RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_MANIPULATOR_GRAB_STYLE_RING_2D, "Draw Style", "");
RNA_def_enum_flag(wt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", "");
WM_manipulatortype_target_property_def(wt, "offset", PROP_FLOAT, 3);
diff --git a/source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c
index f6c83a4934c..eea14f2033f 100644
--- a/source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c
+++ b/source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c
@@ -88,23 +88,21 @@ static void manipulator_primitive_draw_intern(
wmManipulator *mpr, const bool UNUSED(select),
const bool highlight)
{
- float col_inner[4], col_outer[4];
- float mat[4][4];
+ float color_inner[4], color_outer[4];
+ float matrix_final[4][4];
const int draw_style = RNA_enum_get(mpr->ptr, "draw_style");
- manipulator_color_get(mpr, highlight, col_outer);
- copy_v4_v4(col_inner, col_outer);
- col_inner[3] *= 0.5f;
+ manipulator_color_get(mpr, highlight, color_outer);
+ copy_v4_v4(color_inner, color_outer);
+ color_inner[3] *= 0.5f;
- copy_m4_m4(mat, mpr->matrix_basis);
- mul_mat3_m4_fl(mat, mpr->scale_final);
+ WM_manipulator_calc_matrix_final(mpr, matrix_final);
gpuPushMatrix();
- gpuMultMatrix(mat);
+ gpuMultMatrix(matrix_final);
glEnable(GL_BLEND);
- gpuMultMatrix(mpr->matrix_offset);
- manipulator_primitive_draw_geom(col_inner, col_outer, draw_style);
+ manipulator_primitive_draw_geom(color_inner, color_outer, draw_style);
glDisable(GL_BLEND);
gpuPopMatrix();
@@ -112,19 +110,15 @@ static void manipulator_primitive_draw_intern(
if (mpr->interaction_data) {
ManipulatorInteraction *inter = mpr->interaction_data;
- copy_v4_fl(col_inner, 0.5f);
- copy_v3_fl(col_outer, 0.5f);
- col_outer[3] = 0.8f;
-
- copy_m4_m4(mat, inter->init_matrix);
- mul_mat3_m4_fl(mat, inter->init_scale);
+ copy_v4_fl(color_inner, 0.5f);
+ copy_v3_fl(color_outer, 0.5f);
+ color_outer[3] = 0.8f;
gpuPushMatrix();
- gpuMultMatrix(mat);
+ gpuMultMatrix(inter->init_matrix_final);
glEnable(GL_BLEND);
- gpuMultMatrix(mpr->matrix_offset);
- manipulator_primitive_draw_geom(col_inner, col_outer, draw_style);
+ manipulator_primitive_draw_geom(color_inner, color_outer, draw_style);
glDisable(GL_BLEND);
gpuPopMatrix();
@@ -133,9 +127,9 @@ static void manipulator_primitive_draw_intern(
static void manipulator_primitive_draw_select(
const bContext *UNUSED(C), wmManipulator *mpr,
- int selectionbase)
+ int select_id)
{
- GPU_select_load_id(selectionbase);
+ GPU_select_load_id(select_id);
manipulator_primitive_draw_intern(mpr, true, false);
}
@@ -148,18 +142,19 @@ static void manipulator_primitive_draw(const bContext *UNUSED(C), wmManipulator
static void manipulator_primitive_setup(wmManipulator *mpr)
{
- mpr->flag |= WM_MANIPULATOR_DRAW_ACTIVE;
+ mpr->flag |= WM_MANIPULATOR_DRAW_MODAL;
}
-static void manipulator_primitive_invoke(
+static int manipulator_primitive_invoke(
bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *UNUSED(event))
{
ManipulatorInteraction *inter = MEM_callocN(sizeof(ManipulatorInteraction), __func__);
- copy_m4_m4(inter->init_matrix, mpr->matrix_basis);
- inter->init_scale = mpr->scale_final;
+ WM_manipulator_calc_matrix_final(mpr, inter->init_matrix_final);
mpr->interaction_data = inter;
+
+ return OPERATOR_RUNNING_MODAL;
}
/* -------------------------------------------------------------------- */
diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c
index 72bc61139c6..6ed1c021c6c 100644
--- a/source/blender/editors/mask/mask_draw.c
+++ b/source/blender/editors/mask/mask_draw.c
@@ -823,8 +823,8 @@ void ED_mask_draw_frames(Mask *mask, ARegion *ar, const int cfra, const int sfra
immBegin(GWN_PRIM_LINES, 2 * num_lines);
for (MaskLayerShape *masklay_shape = masklay->splines_shapes.first;
- masklay_shape;
- masklay_shape = masklay_shape->next)
+ masklay_shape;
+ masklay_shape = masklay_shape->next)
{
int frame = masklay_shape->frame;
diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c
index 7bd8d9de278..d299bba93c3 100644
--- a/source/blender/editors/mask/mask_ops.c
+++ b/source/blender/editors/mask/mask_ops.c
@@ -1000,7 +1000,7 @@ static int slide_point_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (weight) {
sub_v2_v2v2(c, offco, p);
- project_v2_v2v2(vec, c, no);
+ project_v2_v2v2_normalized(vec, c, no);
w = len_v2(vec);
diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c
index 52ec22aaaf0..870eb68600a 100644
--- a/source/blender/editors/mesh/editface.c
+++ b/source/blender/editors/mesh/editface.c
@@ -107,7 +107,7 @@ void paintface_flush_flags(Object *ob, short flag)
GPU_drawobject_free(dm);
}
- BKE_mesh_batch_cache_dirty(me, BKE_MESH_BATCH_DIRTY_PAINT);
+ BKE_mesh_batch_cache_dirty(me, BKE_MESH_BATCH_DIRTY_ALL);
}
void paintface_hide(Object *ob, const bool unselected)
@@ -396,7 +396,7 @@ bool paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], b
return true;
}
-int do_paintface_box_select(ViewContext *vc, rcti *rect, bool select, bool extend)
+int do_paintface_box_select(const struct EvaluationContext *eval_ctx, ViewContext *vc, rcti *rect, bool select, bool extend)
{
Object *ob = vc->obact;
Mesh *me;
@@ -427,7 +427,7 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, bool select, bool exten
}
}
- ED_view3d_backbuf_validate(vc);
+ ED_view3d_backbuf_validate(eval_ctx, vc);
ibuf = IMB_allocImBuf(size[0], size[1], 32, IB_rect);
rt = ibuf->rect;
@@ -518,7 +518,7 @@ void paintvert_flush_flags(Object *ob)
}
}
- BKE_mesh_batch_cache_dirty(me, BKE_MESH_BATCH_DIRTY_PAINT);
+ BKE_mesh_batch_cache_dirty(me, BKE_MESH_BATCH_DIRTY_ALL);
}
/* note: if the caller passes false to flush_flags, then they will need to run paintvert_flush_flags(ob) themselves */
void paintvert_deselect_all_visible(Object *ob, int action, bool flush_flags)
@@ -801,25 +801,47 @@ void ED_mesh_mirrtopo_init(Mesh *me, DerivedMesh *dm, const int ob_mode, MirrTop
qsort(topo_pairs, totvert, sizeof(MirrTopoVert_t), mirrtopo_vert_sort);
- /* Since the loop starts at 2, we must define the last index where the hash's differ */
- last = ((totvert >= 2) && (topo_pairs[0].hash == topo_pairs[1].hash)) ? 0 : 1;
+ last = 0;
/* Get the pairs out of the sorted hashes, note, totvert+1 means we can use the previous 2,
* but you cant ever access the last 'a' index of MirrTopoPairs */
- for (a = 2; a <= totvert; a++) {
- /* printf("I %d %ld %d\n", (a-last), MirrTopoPairs[a ].hash, MirrTopoPairs[a ].v_index ); */
- if ((a == totvert) || (topo_pairs[a - 1].hash != topo_pairs[a].hash)) {
- if (a - last == 2) {
- if (em) {
- index_lookup[topo_pairs[a - 1].v_index] = (intptr_t)BM_vert_at_index(em->bm, topo_pairs[a - 2].v_index);
- index_lookup[topo_pairs[a - 2].v_index] = (intptr_t)BM_vert_at_index(em->bm, topo_pairs[a - 1].v_index);
+ if (em) {
+ BMVert **vtable = em->bm->vtable;
+ for (a = 1; a <= totvert; a++) {
+ /* printf("I %d %ld %d\n", (a - last), MirrTopoPairs[a].hash, MirrTopoPairs[a].v_indexs); */
+ if ((a == totvert) || (topo_pairs[a - 1].hash != topo_pairs[a].hash)) {
+ const int match_count = a - last;
+ if (match_count == 2) {
+ const int j = topo_pairs[a - 1].v_index, k = topo_pairs[a - 2].v_index;
+ index_lookup[j] = (intptr_t)vtable[k];
+ index_lookup[k] = (intptr_t)vtable[j];
+ }
+ else if (match_count == 1) {
+ /* Center vertex. */
+ const int j = topo_pairs[a - 1].v_index;
+ index_lookup[j] = (intptr_t)vtable[j];
+ }
+ last = a;
+ }
+ }
+ }
+ else {
+ /* same as above, for mesh */
+ for (a = 1; a <= totvert; a++) {
+ if ((a == totvert) || (topo_pairs[a - 1].hash != topo_pairs[a].hash)) {
+ const int match_count = a - last;
+ if (match_count == 2) {
+ const int j = topo_pairs[a - 1].v_index, k = topo_pairs[a - 2].v_index;
+ index_lookup[j] = k;
+ index_lookup[k] = j;
}
- else {
- index_lookup[topo_pairs[a - 1].v_index] = topo_pairs[a - 2].v_index;
- index_lookup[topo_pairs[a - 2].v_index] = topo_pairs[a - 1].v_index;
+ else if (match_count == 1) {
+ /* Center vertex. */
+ const int j = topo_pairs[a - 1].v_index;
+ index_lookup[j] = j;
}
+ last = a;
}
- last = a;
}
}
diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c
index 07fedffaf80..77772cfc8cc 100644
--- a/source/blender/editors/mesh/editmesh_add.c
+++ b/source/blender/editors/mesh/editmesh_add.c
@@ -233,7 +233,7 @@ static int add_primitive_circle_exec(bContext *C, wmOperator *op)
if (!EDBM_op_call_and_selectf(
em, op, "verts.out", false,
- "create_circle segments=%i diameter=%f cap_ends=%b cap_tris=%b matrix=%m4 calc_uvs=%b",
+ "create_circle segments=%i radius=%f cap_ends=%b cap_tris=%b matrix=%m4 calc_uvs=%b",
RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius"),
cap_end, cap_tri, mat, calc_uvs))
{
diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c
index a81add7a86e..6b4f3516338 100644
--- a/source/blender/editors/mesh/editmesh_bevel.c
+++ b/source/blender/editors/mesh/editmesh_bevel.c
@@ -150,6 +150,7 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal)
for (i = 0; i < NUM_VALUE_KINDS; i++) {
opdata->shift_value[i] = -1.0f;
+ opdata->initial_length[i] = -1.0f;
/* note: scale for OFFSET_VALUE will get overwritten in edbm_bevel_invoke */
opdata->scale[i] = value_scale_per_inch[i] / pixels_per_inch;
@@ -300,7 +301,7 @@ static void edbm_bevel_calc_initial_length(wmOperator *op, const wmEvent *event,
mlen[1] = opdata->mcenter[1] - event->mval[1];
len = len_v2(mlen);
vmode = opdata->value_mode;
- if (mode_changed) {
+ if (mode_changed || opdata->initial_length[vmode] == -1.0f) {
/* If current value is not default start value, adjust len so that
* the scaling and offset in edbm_bevel_mouse_set_value will
* start at current value */
@@ -506,6 +507,8 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
else if (opdata->value_mode == OFFSET_VALUE_PERCENT && type != BEVEL_AMT_PERCENT)
opdata->value_mode = OFFSET_VALUE;
RNA_property_enum_set(op->ptr, prop, type);
+ if (opdata->initial_length[opdata->value_mode] == -1.0f)
+ edbm_bevel_calc_initial_length(op, event, true);
}
/* Update offset accordingly to new offset_type. */
if (!has_numinput &&
diff --git a/source/blender/editors/mesh/editmesh_bisect.c b/source/blender/editors/mesh/editmesh_bisect.c
index 9b6df11d470..c9f083e2089 100644
--- a/source/blender/editors/mesh/editmesh_bisect.c
+++ b/source/blender/editors/mesh/editmesh_bisect.c
@@ -50,6 +50,8 @@
#include "ED_screen.h"
#include "ED_view3d.h"
+#include "UI_resources.h"
+
#include "mesh_intern.h" /* own include */
#define USE_MANIPULATOR
@@ -198,7 +200,7 @@ static int mesh_bisect_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
View3D *v3d = CTX_wm_view3d(C);
if (v3d && (v3d->twtype & V3D_MANIPULATOR_DRAW)) {
- WM_manipulator_group_add("MESH_WGT_bisect");
+ WM_manipulator_group_type_add("MESH_WGT_bisect");
}
}
#endif
@@ -426,8 +428,8 @@ static void manipulator_mesh_bisect_update_from_op(ManipulatorGroup *man)
RNA_property_float_get_array(op->ptr, man->data.prop_plane_no, plane_no);
WM_manipulator_set_matrix_location(man->translate_z, plane_co);
- WM_manipulator_set_matrix_location(man->translate_c, plane_co);
WM_manipulator_set_matrix_location(man->rotate_c, plane_co);
+ /* translate_c location comes from the property. */
WM_manipulator_set_matrix_rotation_from_z_axis(man->translate_z, plane_no);
@@ -594,7 +596,7 @@ static bool manipulator_mesh_bisect_poll(const bContext *C, wmManipulatorGroupTy
{
wmOperator *op = WM_operator_last_redo(C);
if (op == NULL || !STREQ(op->type->idname, "MESH_OT_bisect")) {
- WM_manipulator_group_remove_ptr_delayed(wgt);
+ WM_manipulator_group_type_remove_ptr_delayed(wgt);
return false;
}
return true;
@@ -615,12 +617,16 @@ static void manipulator_mesh_bisect_setup(const bContext *C, wmManipulatorGroup
const wmManipulatorType *wt_grab = WM_manipulatortype_find("MANIPULATOR_WT_grab_3d", true);
const wmManipulatorType *wt_dial = WM_manipulatortype_find("MANIPULATOR_WT_dial_3d", true);
- man->translate_z = WM_manipulator_new_ptr(wt_arrow, mgroup, "translate_z", NULL);
- man->translate_c = WM_manipulator_new_ptr(wt_grab, mgroup, "translate_c", NULL);
- man->rotate_c = WM_manipulator_new_ptr(wt_dial, mgroup, "rotate_c", NULL);
+ man->translate_z = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL);
+ man->translate_c = WM_manipulator_new_ptr(wt_grab, mgroup, NULL);
+ man->rotate_c = WM_manipulator_new_ptr(wt_dial, mgroup, NULL);
+
+ UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, man->translate_z->color);
+ UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, man->translate_c->color);
+ UI_GetThemeColor3fv(TH_MANIPULATOR_SECONDARY, man->rotate_c->color);
RNA_enum_set(man->translate_z->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_NORMAL);
- RNA_enum_set(man->translate_c->ptr, "draw_style", ED_MANIPULATOR_GRAB_STYLE_RING);
+ RNA_enum_set(man->translate_c->ptr, "draw_style", ED_MANIPULATOR_GRAB_STYLE_RING_2D);
WM_manipulator_set_flag(man->translate_c, WM_MANIPULATOR_DRAW_VALUE, true);
WM_manipulator_set_flag(man->rotate_c, WM_MANIPULATOR_DRAW_VALUE, true);
diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c
index d5b2a3d3b82..9bc01687122 100644
--- a/source/blender/editors/mesh/editmesh_extrude.c
+++ b/source/blender/editors/mesh/editmesh_extrude.c
@@ -53,6 +53,8 @@
#include "ED_transform.h"
#include "ED_view3d.h"
+#include "UI_resources.h"
+
#include "MEM_guardedalloc.h"
#include "mesh_intern.h" /* own include */
@@ -759,7 +761,7 @@ static int edbm_spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e
if (ret & OPERATOR_FINISHED) {
/* Setup manipulators */
if (v3d && (v3d->twtype & V3D_MANIPULATOR_DRAW)) {
- WM_manipulator_group_add("MESH_WGT_spin");
+ WM_manipulator_group_type_add("MESH_WGT_spin");
}
}
#endif
@@ -859,9 +861,9 @@ static void manipulator_mesh_spin_update_from_op(ManipulatorSpinGroup *man)
RNA_property_float_get_array(op->ptr, man->data.prop_axis_no, plane_no);
WM_manipulator_set_matrix_location(man->translate_z, plane_co);
- WM_manipulator_set_matrix_location(man->translate_c, plane_co);
WM_manipulator_set_matrix_location(man->rotate_c, plane_co);
WM_manipulator_set_matrix_location(man->angle_z, plane_co);
+ /* translate_c location comes from the property. */
WM_manipulator_set_matrix_rotation_from_z_axis(man->translate_z, plane_no);
WM_manipulator_set_matrix_rotation_from_z_axis(man->angle_z, plane_no);
@@ -878,7 +880,7 @@ static void manipulator_mesh_spin_update_from_op(ManipulatorSpinGroup *man)
normalize_v3(man->data.rotate_up);
WM_manipulator_set_matrix_rotation_from_z_axis(man->translate_c, plane_no);
- WM_manipulator_set_matrix_rotation_from_yz_axis(man->rotate_c, man->data.rotate_axis, plane_no);
+ WM_manipulator_set_matrix_rotation_from_yz_axis(man->rotate_c, plane_no, man->data.rotate_axis);
/* show the axis instead of mouse cursor */
RNA_enum_set(man->rotate_c->ptr, "draw_options",
@@ -1057,7 +1059,7 @@ static bool manipulator_mesh_spin_poll(const bContext *C, wmManipulatorGroupType
{
wmOperator *op = WM_operator_last_redo(C);
if (op == NULL || !STREQ(op->type->idname, "MESH_OT_spin")) {
- WM_manipulator_group_remove_ptr_delayed(wgt);
+ WM_manipulator_group_type_remove_ptr_delayed(wgt);
return false;
}
return true;
@@ -1078,13 +1080,19 @@ static void manipulator_mesh_spin_setup(const bContext *C, wmManipulatorGroup *m
const wmManipulatorType *wt_grab = WM_manipulatortype_find("MANIPULATOR_WT_grab_3d", true);
const wmManipulatorType *wt_dial = WM_manipulatortype_find("MANIPULATOR_WT_dial_3d", true);
- man->translate_z = WM_manipulator_new_ptr(wt_arrow, mgroup, "translate_z", NULL);
- man->translate_c = WM_manipulator_new_ptr(wt_grab, mgroup, "translate_c", NULL);
- man->rotate_c = WM_manipulator_new_ptr(wt_dial, mgroup, "rotate_c", NULL);
- man->angle_z = WM_manipulator_new_ptr(wt_dial, mgroup, "angle_z", NULL);
+ man->translate_z = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL);
+ man->translate_c = WM_manipulator_new_ptr(wt_grab, mgroup, NULL);
+ man->rotate_c = WM_manipulator_new_ptr(wt_dial, mgroup, NULL);
+ man->angle_z = WM_manipulator_new_ptr(wt_dial, mgroup, NULL);
+
+ UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, man->translate_z->color);
+ UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, man->translate_c->color);
+ UI_GetThemeColor3fv(TH_MANIPULATOR_SECONDARY, man->rotate_c->color);
+ UI_GetThemeColor3fv(TH_AXIS_Z, man->angle_z->color);
+
RNA_enum_set(man->translate_z->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_NORMAL);
- RNA_enum_set(man->translate_c->ptr, "draw_style", ED_MANIPULATOR_GRAB_STYLE_RING);
+ RNA_enum_set(man->translate_c->ptr, "draw_style", ED_MANIPULATOR_GRAB_STYLE_RING_2D);
WM_manipulator_set_flag(man->translate_c, WM_MANIPULATOR_DRAW_VALUE, true);
WM_manipulator_set_flag(man->rotate_c, WM_MANIPULATOR_DRAW_VALUE, true);
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index 3c974e4b3b9..433163b2fab 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -54,6 +54,8 @@
#include "BKE_editmesh_bvh.h"
#include "BKE_report.h"
+#include "DEG_depsgraph.h"
+
#include "GPU_immediate.h"
#include "GPU_matrix.h"
@@ -159,6 +161,7 @@ typedef struct KnifePosData {
typedef struct KnifeTool_OpData {
ARegion *ar; /* region that knifetool was activated in */
void *draw_handle; /* for drawing preview loop */
+ EvaluationContext eval_ctx;
ViewContext vc; /* note: _don't_ use 'mval', instead use the one we define below */
float mval[2]; /* mouse value with snapping applied */
//bContext *C;
@@ -1226,6 +1229,7 @@ static bool knife_ray_intersect_face(
for (; tri_i < tottri; tri_i++) {
const float *lv1, *lv2, *lv3;
+ float ray_tri_uv[2];
tri = kcd->em->looptris[tri_i];
if (tri[0]->f != f)
@@ -1237,7 +1241,7 @@ static bool knife_ray_intersect_face(
* tesselation edge and might not hit either tesselation tri with
* an exact test;
* we will exclude hits near real edges by a later test */
- if (isect_ray_tri_epsilon_v3(v1, raydir, lv1, lv2, lv3, &lambda, NULL, KNIFE_FLT_EPS)) {
+ if (isect_ray_tri_epsilon_v3(v1, raydir, lv1, lv2, lv3, &lambda, ray_tri_uv, KNIFE_FLT_EPS)) {
/* check if line coplanar with tri */
normal_tri_v3(tri_norm, lv1, lv2, lv3);
plane_from_point_normal_v3(tri_plane, lv1, tri_norm);
@@ -1246,8 +1250,7 @@ static bool knife_ray_intersect_face(
{
return false;
}
- copy_v3_v3(hit_cageco, v1);
- madd_v3_v3fl(hit_cageco, raydir, lambda);
+ interp_v3_v3v3v3_uv(hit_cageco, lv1, lv2, lv3, ray_tri_uv);
/* Now check that far enough away from verts and edges */
lst = knife_get_face_kedges(kcd, f);
for (ref = lst->first; ref; ref = ref->next) {
@@ -1259,11 +1262,7 @@ static bool knife_ray_intersect_face(
return false;
}
}
-
- transform_point_by_tri_v3(
- hit_co, hit_cageco,
- tri[0]->v->co, tri[1]->v->co, tri[2]->v->co,
- lv1, lv2, lv3);
+ interp_v3_v3v3v3_uv(hit_co, tri[0]->v->co, tri[1]->v->co, tri[2]->v->co, ray_tri_uv);
return true;
}
}
@@ -1837,7 +1836,7 @@ static BMFace *knife_find_closest_face(KnifeTool_OpData *kcd, float co[3], float
if (!f) {
if (kcd->is_interactive) {
/* try to use backbuffer selection method if ray casting failed */
- f = EDBM_face_find_nearest(&kcd->vc, &dist);
+ f = EDBM_face_find_nearest(&kcd->eval_ctx, &kcd->vc, &dist);
/* cheat for now; just put in the origin instead
* of a true coordinate on the face.
@@ -2589,7 +2588,7 @@ static void knifetool_init_bmbvh(KnifeTool_OpData *kcd)
{
BM_mesh_elem_index_ensure(kcd->em->bm, BM_VERT);
- kcd->cagecos = (const float (*)[3])BKE_editmesh_vertexCos_get(kcd->em, kcd->scene, NULL);
+ kcd->cagecos = (const float (*)[3])BKE_editmesh_vertexCos_get(&kcd->eval_ctx, kcd->em, kcd->scene, NULL);
kcd->bmbvh = BKE_bmbvh_new_from_editmesh(
kcd->em,
@@ -2623,6 +2622,7 @@ static void knifetool_init(bContext *C, KnifeTool_OpData *kcd,
kcd->ob = obedit;
kcd->ar = CTX_wm_region(C);
+ CTX_data_eval_ctx(C, &kcd->eval_ctx);
em_setup_viewcontext(C, &kcd->vc);
kcd->em = BKE_editmesh_from_object(kcd->ob);
@@ -2777,6 +2777,7 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_FINISHED;
}
+ CTX_data_eval_ctx(C, &kcd->eval_ctx);
em_setup_viewcontext(C, &kcd->vc);
kcd->ar = kcd->vc.ar;
diff --git a/source/blender/editors/mesh/editmesh_knife_project.c b/source/blender/editors/mesh/editmesh_knife_project.c
index 0d3cc07589b..c98d22503e1 100644
--- a/source/blender/editors/mesh/editmesh_knife_project.c
+++ b/source/blender/editors/mesh/editmesh_knife_project.c
@@ -42,6 +42,8 @@
#include "BKE_editmesh.h"
#include "BKE_report.h"
+#include "DEG_depsgraph.h"
+
#include "RNA_define.h"
#include "RNA_access.h"
@@ -56,13 +58,17 @@
#include "mesh_intern.h" /* own include */
-static LinkNode *knifeproject_poly_from_object(ARegion *ar, Scene *scene, Object *ob, LinkNode *polys)
+static LinkNode *knifeproject_poly_from_object(const bContext *C, Scene *scene, Object *ob, LinkNode *polys)
{
+ ARegion *ar = CTX_wm_region(C);
+ EvaluationContext eval_ctx;
DerivedMesh *dm;
bool dm_needsFree;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
if (ob->type == OB_MESH || ob->derivedFinal) {
- dm = ob->derivedFinal ? ob->derivedFinal : mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
+ dm = ob->derivedFinal ? ob->derivedFinal : mesh_get_derived_final(&eval_ctx, scene, ob, CD_MASK_BAREMESH);
dm_needsFree = false;
}
else if (ELEM(ob->type, OB_FONT, OB_CURVE, OB_SURF)) {
@@ -116,7 +122,6 @@ static LinkNode *knifeproject_poly_from_object(ARegion *ar, Scene *scene, Object
static int knifeproject_exec(bContext *C, wmOperator *op)
{
- ARegion *ar = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
Object *obedit = CTX_data_edit_object(C);
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -127,7 +132,7 @@ static int knifeproject_exec(bContext *C, wmOperator *op)
CTX_DATA_BEGIN (C, Object *, ob, selected_objects)
{
if (ob != obedit) {
- polys = knifeproject_poly_from_object(ar, scene, ob, polys);
+ polys = knifeproject_poly_from_object(C, scene, ob, polys);
}
}
CTX_DATA_END;
diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c
index 6a656ace09c..a4a6ad82dfb 100644
--- a/source/blender/editors/mesh/editmesh_loopcut.c
+++ b/source/blender/editors/mesh/editmesh_loopcut.c
@@ -63,6 +63,8 @@
#include "WM_api.h"
#include "WM_types.h"
+#include "DEG_depsgraph.h"
+
#include "mesh_intern.h" /* own include */
#define SUBD_SMOOTH_MAX 4.0f
@@ -556,20 +558,23 @@ static void loopcut_update_edge(RingSelOpData *lcd, BMEdge *e, const int preview
}
}
-static void loopcut_mouse_move(RingSelOpData *lcd, const int previewlines)
+static void loopcut_mouse_move(const struct EvaluationContext *eval_ctx, RingSelOpData *lcd, const int previewlines)
{
float dist = ED_view3d_select_dist_px();
- BMEdge *e = EDBM_edge_find_nearest(&lcd->vc, &dist);
+ BMEdge *e = EDBM_edge_find_nearest(eval_ctx, &lcd->vc, &dist);
loopcut_update_edge(lcd, e, previewlines);
}
/* called by both init() and exec() */
static int loopcut_init(bContext *C, wmOperator *op, const wmEvent *event)
{
+ EvaluationContext eval_ctx;
const bool is_interactive = (event != NULL);
Object *obedit = CTX_data_edit_object(C);
RingSelOpData *lcd;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
if (modifiers_isDeformedByLattice(obedit) || modifiers_isDeformedByArmature(obedit))
BKE_report(op->reports, RPT_WARNING, "Loop cut does not work well on deformed edit mesh display");
@@ -597,7 +602,7 @@ static int loopcut_init(bContext *C, wmOperator *op, const wmEvent *event)
if (is_interactive) {
copy_v2_v2_int(lcd->vc.mval, event->mval);
- loopcut_mouse_move(lcd, is_interactive ? 1 : 0);
+ loopcut_mouse_move(&eval_ctx, lcd, is_interactive ? 1 : 0);
}
else {
const int e_index = RNA_int_get(op->ptr, "edge_index");
@@ -670,12 +675,14 @@ static int loopcut_finish(RingSelOpData *lcd, bContext *C, wmOperator *op)
static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
+ EvaluationContext eval_ctx;
RingSelOpData *lcd = op->customdata;
float cuts = lcd->cuts;
float smoothness = lcd->smoothness;
bool show_cuts = false;
const bool has_numinput = hasNumInput(&lcd->num);
+ CTX_data_eval_ctx(C, &eval_ctx);
em_setup_viewcontext(C, &lcd->vc);
lcd->ar = lcd->vc.ar;
@@ -761,7 +768,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (!has_numinput) {
lcd->vc.mval[0] = event->mval[0];
lcd->vc.mval[1] = event->mval[1];
- loopcut_mouse_move(lcd, (int)lcd->cuts);
+ loopcut_mouse_move(&eval_ctx, lcd, (int)lcd->cuts);
ED_region_tag_redraw(lcd->ar);
handled = true;
diff --git a/source/blender/editors/mesh/editmesh_path.c b/source/blender/editors/mesh/editmesh_path.c
index 4431712e720..29bca00f1a9 100644
--- a/source/blender/editors/mesh/editmesh_path.c
+++ b/source/blender/editors/mesh/editmesh_path.c
@@ -59,6 +59,8 @@
#include "bmesh.h"
#include "bmesh_tools.h"
+#include "DEG_depsgraph.h"
+
#include "mesh_intern.h" /* own include */
struct PathSelectParams {
@@ -570,19 +572,19 @@ static bool edbm_shortest_path_pick_ex(
static int edbm_shortest_path_pick_exec(bContext *C, wmOperator *op);
-static BMElem *edbm_elem_find_nearest(ViewContext *vc, const char htype)
+static BMElem *edbm_elem_find_nearest(const struct EvaluationContext *eval_ctx, ViewContext *vc, const char htype)
{
BMEditMesh *em = vc->em;
float dist = ED_view3d_select_dist_px();
if ((em->selectmode & SCE_SELECT_VERTEX) && (htype == BM_VERT)) {
- return (BMElem *)EDBM_vert_find_nearest(vc, &dist);
+ return (BMElem *)EDBM_vert_find_nearest(eval_ctx, vc, &dist);
}
else if ((em->selectmode & SCE_SELECT_EDGE) && (htype == BM_EDGE)) {
- return (BMElem *)EDBM_edge_find_nearest(vc, &dist);
+ return (BMElem *)EDBM_edge_find_nearest(eval_ctx, vc, &dist);
}
else if ((em->selectmode & SCE_SELECT_FACE) && (htype == BM_FACE)) {
- return (BMElem *)EDBM_face_find_nearest(vc, &dist);
+ return (BMElem *)EDBM_face_find_nearest(eval_ctx, vc, &dist);
}
return NULL;
@@ -605,10 +607,12 @@ static int edbm_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmE
return edbm_shortest_path_pick_exec(C, op);
}
+ EvaluationContext eval_ctx;
ViewContext vc;
BMEditMesh *em;
bool track_active = true;
+ CTX_data_eval_ctx(C, &eval_ctx);
em_setup_viewcontext(C, &vc);
copy_v2_v2_int(vc.mval, event->mval);
em = vc.em;
@@ -617,14 +621,14 @@ static int edbm_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmE
BMElem *ele_src, *ele_dst;
if (!(ele_src = edbm_elem_active_elem_or_face_get(em->bm)) ||
- !(ele_dst = edbm_elem_find_nearest(&vc, ele_src->head.htype)))
+ !(ele_dst = edbm_elem_find_nearest(&eval_ctx, &vc, ele_src->head.htype)))
{
/* special case, toggle edge tags even when we don't have a path */
if (((em->selectmode & SCE_SELECT_EDGE) &&
(vc.scene->toolsettings->edge_mode != EDGE_MODE_SELECT)) &&
/* check if we only have a destination edge */
((ele_src == NULL) &&
- (ele_dst = edbm_elem_find_nearest(&vc, BM_EDGE))))
+ (ele_dst = edbm_elem_find_nearest(&eval_ctx, &vc, BM_EDGE))))
{
ele_src = ele_dst;
track_active = false;
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index 61891907050..7fe4e58d2e0 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -68,6 +68,8 @@
#include "bmesh_tools.h"
+#include "DEG_depsgraph.h"
+
#include "mesh_intern.h" /* own include */
/* use bmesh operator flags for a few operators */
@@ -194,7 +196,9 @@ static BLI_bitmap *edbm_backbuf_alloc(const int size)
/* reads rect, and builds selection array for quick lookup */
/* returns if all is OK */
-bool EDBM_backbuf_border_init(ViewContext *vc, short xmin, short ymin, short xmax, short ymax)
+bool EDBM_backbuf_border_init(
+ const struct EvaluationContext *eval_ctx, ViewContext *vc, short xmin,
+ short ymin, short xmax, short ymax)
{
struct ImBuf *buf;
unsigned int *dr;
@@ -204,7 +208,7 @@ bool EDBM_backbuf_border_init(ViewContext *vc, short xmin, short ymin, short xma
return false;
}
- buf = ED_view3d_backbuf_read(vc, xmin, ymin, xmax, ymax);
+ buf = ED_view3d_backbuf_read(eval_ctx, vc, xmin, ymin, xmax, ymax);
if ((buf == NULL) || (bm_vertoffs == 0)) {
return false;
}
@@ -267,7 +271,7 @@ static void edbm_mask_lasso_px_cb(int x, int x_end, int y, void *user_data)
* - grab again and compare
* returns 'OK'
*/
-bool EDBM_backbuf_border_mask_init(ViewContext *vc, const int mcords[][2], short tot, short xmin, short ymin, short xmax, short ymax)
+bool EDBM_backbuf_border_mask_init(const struct EvaluationContext *eval_ctx, ViewContext *vc, const int mcords[][2], short tot, short xmin, short ymin, short xmax, short ymax)
{
unsigned int *dr, *dr_mask, *dr_mask_arr;
struct ImBuf *buf;
@@ -284,7 +288,7 @@ bool EDBM_backbuf_border_mask_init(ViewContext *vc, const int mcords[][2], short
return false;
}
- buf = ED_view3d_backbuf_read(vc, xmin, ymin, xmax, ymax);
+ buf = ED_view3d_backbuf_read(eval_ctx, vc, xmin, ymin, xmax, ymax);
if ((buf == NULL) || (bm_vertoffs == 0)) {
return false;
}
@@ -317,7 +321,9 @@ bool EDBM_backbuf_border_mask_init(ViewContext *vc, const int mcords[][2], short
}
/* circle shaped sample area */
-bool EDBM_backbuf_circle_init(ViewContext *vc, short xs, short ys, short rads)
+bool EDBM_backbuf_circle_init(
+ const struct EvaluationContext *eval_ctx, ViewContext *vc,
+ short xs, short ys, short rads)
{
struct ImBuf *buf;
unsigned int *dr;
@@ -336,7 +342,7 @@ bool EDBM_backbuf_circle_init(ViewContext *vc, short xs, short ys, short rads)
xmin = xs - rads; xmax = xs + rads;
ymin = ys - rads; ymax = ys + rads;
- buf = ED_view3d_backbuf_read(vc, xmin, ymin, xmax, ymax);
+ buf = ED_view3d_backbuf_read(eval_ctx, vc, xmin, ymin, xmax, ymax);
if ((buf == NULL) || (bm_vertoffs == 0)) {
return false;
}
@@ -435,7 +441,7 @@ static void findnearestvert__doClosest(void *userData, BMVert *eve, const float
* \param use_cycle Cycle over elements within #FIND_NEAR_CYCLE_THRESHOLD_MIN in order of index.
*/
BMVert *EDBM_vert_find_nearest_ex(
- ViewContext *vc, float *r_dist,
+ const struct EvaluationContext *eval_ctx, ViewContext *vc, float *r_dist,
const bool use_select_bias, bool use_cycle)
{
BMesh *bm = vc->em->bm;
@@ -446,8 +452,11 @@ BMVert *EDBM_vert_find_nearest_ex(
unsigned int index;
BMVert *eve;
+ /* No afterqueue (yet), so we check it now, otherwise the bm_xxxofs indices are bad. */
+ ED_view3d_backbuf_validate(eval_ctx, vc);
+
index = ED_view3d_backbuf_sample_rect(
- vc, vc->mval, dist_px, bm_wireoffs, 0xFFFFFF, &dist_test);
+ eval_ctx, vc, vc->mval, dist_px, bm_wireoffs, 0xFFFFFF, &dist_test);
eve = index ? BM_vert_at_index_find_or_table(bm, index - 1) : NULL;
if (eve) {
@@ -482,7 +491,7 @@ BMVert *EDBM_vert_find_nearest_ex(
data.cycle_index_prev = prev_select_index;
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
- mesh_foreachScreenVert(vc, findnearestvert__doClosest, &data, clip_flag);
+ mesh_foreachScreenVert(eval_ctx, vc, findnearestvert__doClosest, &data, clip_flag);
hit = (data.use_cycle && data.hit_cycle.vert) ? &data.hit_cycle : &data.hit;
*r_dist = hit->dist;
@@ -494,9 +503,9 @@ BMVert *EDBM_vert_find_nearest_ex(
}
}
-BMVert *EDBM_vert_find_nearest(ViewContext *vc, float *r_dist)
+BMVert *EDBM_vert_find_nearest(const struct EvaluationContext *eval_ctx, ViewContext *vc, float *r_dist)
{
- return EDBM_vert_find_nearest_ex(vc, r_dist, false, false);
+ return EDBM_vert_find_nearest_ex(eval_ctx, vc, r_dist, false, false);
}
/* find the distance to the edge we already have */
@@ -618,7 +627,7 @@ static void find_nearest_edge__doClosest(
}
BMEdge *EDBM_edge_find_nearest_ex(
- ViewContext *vc, float *r_dist,
+ const struct EvaluationContext *eval_ctx, ViewContext *vc, float *r_dist,
float *r_dist_center,
const bool use_select_bias, const bool use_cycle,
BMEdge **r_eed_zbuf)
@@ -630,10 +639,11 @@ BMEdge *EDBM_edge_find_nearest_ex(
float dist_test = 0.0f;
unsigned int index;
BMEdge *eed;
-
- ED_view3d_backbuf_validate(vc);
- index = ED_view3d_backbuf_sample_rect(vc, vc->mval, dist_px, bm_solidoffs, bm_wireoffs, &dist_test);
+ /* No afterqueue (yet), so we check it now, otherwise the bm_xxxofs indices are bad. */
+ ED_view3d_backbuf_validate(eval_ctx, vc);
+
+ index = ED_view3d_backbuf_sample_rect(eval_ctx, vc, vc->mval, dist_px, bm_solidoffs, bm_wireoffs, &dist_test);
eed = index ? BM_edge_at_index_find_or_table(bm, index - 1) : NULL;
if (r_eed_zbuf) {
@@ -651,7 +661,7 @@ BMEdge *EDBM_edge_find_nearest_ex(
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
- mesh_foreachScreenEdge(vc, find_nearest_edge_center__doZBuf, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
+ mesh_foreachScreenEdge(eval_ctx, vc, find_nearest_edge_center__doZBuf, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
*r_dist_center = data.dist;
}
@@ -691,7 +701,7 @@ BMEdge *EDBM_edge_find_nearest_ex(
data.cycle_index_prev = prev_select_index;
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
- mesh_foreachScreenEdge(vc, find_nearest_edge__doClosest, &data, clip_flag);
+ mesh_foreachScreenEdge(eval_ctx, vc, find_nearest_edge__doClosest, &data, clip_flag);
hit = (data.use_cycle && data.hit_cycle.edge) ? &data.hit_cycle : &data.hit;
*r_dist = hit->dist;
@@ -707,9 +717,9 @@ BMEdge *EDBM_edge_find_nearest_ex(
}
BMEdge *EDBM_edge_find_nearest(
- ViewContext *vc, float *r_dist)
+ const struct EvaluationContext *eval_ctx, ViewContext *vc, float *r_dist)
{
- return EDBM_edge_find_nearest_ex(vc, r_dist, NULL, false, false, NULL);
+ return EDBM_edge_find_nearest_ex(eval_ctx, vc, r_dist, NULL, false, false, NULL);
}
/* find the distance to the face we already have */
@@ -783,7 +793,7 @@ static void findnearestface__doClosest(void *userData, BMFace *efa, const float
BMFace *EDBM_face_find_nearest_ex(
- ViewContext *vc, float *r_dist,
+ const struct EvaluationContext *eval_ctx, ViewContext *vc, float *r_dist,
float *r_dist_center,
const bool use_select_bias, const bool use_cycle,
BMFace **r_efa_zbuf)
@@ -795,9 +805,9 @@ BMFace *EDBM_face_find_nearest_ex(
unsigned int index;
BMFace *efa;
- ED_view3d_backbuf_validate(vc);
+ ED_view3d_backbuf_validate(eval_ctx, vc);
- index = ED_view3d_backbuf_sample(vc, vc->mval[0], vc->mval[1]);
+ index = ED_view3d_backbuf_sample(eval_ctx, vc, vc->mval[0], vc->mval[1]);
efa = index ? BM_face_at_index_find_or_table(bm, index - 1) : NULL;
if (r_efa_zbuf) {
@@ -815,7 +825,7 @@ BMFace *EDBM_face_find_nearest_ex(
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
- mesh_foreachScreenFace(vc, find_nearest_face_center__doZBuf, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
+ mesh_foreachScreenFace(eval_ctx, vc, find_nearest_face_center__doZBuf, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
*r_dist_center = data.dist;
}
@@ -853,7 +863,7 @@ BMFace *EDBM_face_find_nearest_ex(
data.cycle_index_prev = prev_select_index;
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
- mesh_foreachScreenFace(vc, findnearestface__doClosest, &data, clip_flag);
+ mesh_foreachScreenFace(eval_ctx, vc, findnearestface__doClosest, &data, clip_flag);
hit = (data.use_cycle && data.hit_cycle.face) ? &data.hit_cycle : &data.hit;
*r_dist = hit->dist;
@@ -868,9 +878,9 @@ BMFace *EDBM_face_find_nearest_ex(
}
}
-BMFace *EDBM_face_find_nearest(ViewContext *vc, float *r_dist)
+BMFace *EDBM_face_find_nearest(const struct EvaluationContext *eval_ctx, ViewContext *vc, float *r_dist)
{
- return EDBM_face_find_nearest_ex(vc, r_dist, NULL, false, false, NULL);
+ return EDBM_face_find_nearest_ex(eval_ctx, vc, r_dist, NULL, false, false, NULL);
}
#undef FIND_NEAR_SELECT_BIAS
@@ -882,7 +892,9 @@ BMFace *EDBM_face_find_nearest(ViewContext *vc, float *r_dist)
* selected vertices and edges get disadvantage
* return 1 if found one
*/
-static int unified_findnearest(ViewContext *vc, BMVert **r_eve, BMEdge **r_eed, BMFace **r_efa)
+static int unified_findnearest(
+ const struct EvaluationContext *eval_ctx, ViewContext *vc,
+ BMVert **r_eve, BMEdge **r_eed, BMFace **r_efa)
{
BMEditMesh *em = vc->em;
static short mval_prev[2] = {-1, -1};
@@ -901,12 +913,12 @@ static int unified_findnearest(ViewContext *vc, BMVert **r_eve, BMEdge **r_eed,
/* no afterqueue (yet), so we check it now, otherwise the em_xxxofs indices are bad */
- ED_view3d_backbuf_validate(vc);
+ ED_view3d_backbuf_validate(eval_ctx, vc);
if ((dist > 0.0f) && em->selectmode & SCE_SELECT_FACE) {
float dist_center = 0.0f;
float *dist_center_p = (em->selectmode & (SCE_SELECT_EDGE | SCE_SELECT_VERTEX)) ? &dist_center : NULL;
- efa = EDBM_face_find_nearest_ex(vc, &dist, dist_center_p, true, use_cycle, &efa_zbuf);
+ efa = EDBM_face_find_nearest_ex(eval_ctx, vc, &dist, dist_center_p, true, use_cycle, &efa_zbuf);
if (efa && dist_center_p) {
dist = min_ff(dist_margin, dist_center);
}
@@ -915,14 +927,14 @@ static int unified_findnearest(ViewContext *vc, BMVert **r_eve, BMEdge **r_eed,
if ((dist > 0.0f) && (em->selectmode & SCE_SELECT_EDGE)) {
float dist_center = 0.0f;
float *dist_center_p = (em->selectmode & SCE_SELECT_VERTEX) ? &dist_center : NULL;
- eed = EDBM_edge_find_nearest_ex(vc, &dist, dist_center_p, true, use_cycle, &eed_zbuf);
+ eed = EDBM_edge_find_nearest_ex(eval_ctx, vc, &dist, dist_center_p, true, use_cycle, &eed_zbuf);
if (eed && dist_center_p) {
dist = min_ff(dist_margin, dist_center);
}
}
if ((dist > 0.0f) && em->selectmode & SCE_SELECT_VERTEX) {
- eve = EDBM_vert_find_nearest_ex(vc, &dist, true, use_cycle);
+ eve = EDBM_vert_find_nearest_ex(eval_ctx, vc, &dist, true, use_cycle);
}
/* return only one of 3 pointers, for frontbuffer redraws */
@@ -1555,6 +1567,7 @@ static void mouse_mesh_loop_edge(BMEditMesh *em, BMEdge *eed, bool select, bool
static bool mouse_mesh_loop(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle, bool ring)
{
+ EvaluationContext eval_ctx;
ViewContext vc;
BMEditMesh *em;
BMEdge *eed;
@@ -1564,15 +1577,16 @@ static bool mouse_mesh_loop(bContext *C, const int mval[2], bool extend, bool de
float dist = ED_view3d_select_dist_px() * 0.6666f;
float mvalf[2];
+ CTX_data_eval_ctx(C, &eval_ctx);
em_setup_viewcontext(C, &vc);
mvalf[0] = (float)(vc.mval[0] = mval[0]);
mvalf[1] = (float)(vc.mval[1] = mval[1]);
em = vc.em;
/* no afterqueue (yet), so we check it now, otherwise the bm_xxxofs indices are bad */
- ED_view3d_backbuf_validate(&vc);
+ ED_view3d_backbuf_validate(&eval_ctx, &vc);
- eed = EDBM_edge_find_nearest_ex(&vc, &dist, NULL, true, true, NULL);
+ eed = EDBM_edge_find_nearest_ex(&eval_ctx, &vc, &dist, NULL, true, true, NULL);
if (eed == NULL) {
return false;
}
@@ -1815,17 +1829,19 @@ void MESH_OT_select_interior_faces(wmOperatorType *ot)
/* gets called via generic mouse select operator */
bool EDBM_select_pick(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle)
{
+ EvaluationContext eval_ctx;
ViewContext vc;
BMVert *eve = NULL;
BMEdge *eed = NULL;
BMFace *efa = NULL;
/* setup view context for argument to callbacks */
+ CTX_data_eval_ctx(C, &eval_ctx);
em_setup_viewcontext(C, &vc);
vc.mval[0] = mval[0];
vc.mval[1] = mval[1];
- if (unified_findnearest(&vc, &eve, &eed, &efa)) {
+ if (unified_findnearest(&eval_ctx, &vc, &eve, &eed, &efa)) {
/* Deselect everything */
if (extend == false && deselect == false && toggle == false)
@@ -1912,12 +1928,30 @@ bool EDBM_select_pick(bContext *C, const int mval[2], bool extend, bool deselect
EDBM_selectmode_flush(vc.em);
- /* change active material on object */
- if (efa && efa->mat_nr != vc.obedit->actcol - 1) {
- vc.obedit->actcol = efa->mat_nr + 1;
- vc.em->mat_nr = efa->mat_nr;
+ if (efa) {
+ /* Change active material on object. */
+ if (efa->mat_nr != vc.obedit->actcol - 1) {
+ vc.obedit->actcol = efa->mat_nr + 1;
+ vc.em->mat_nr = efa->mat_nr;
+ WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_LINKS, NULL);
+ }
- WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_LINKS, NULL);
+ /* Change active face-map on object. */
+ if (!BLI_listbase_is_empty(&vc.obedit->fmaps)) {
+ const int cd_fmap_offset = CustomData_get_offset(&vc.em->bm->pdata, CD_FACEMAP);
+ if (cd_fmap_offset != -1) {
+ int map = *((int *)BM_ELEM_CD_GET_VOID_P(efa, cd_fmap_offset));
+ if ((map < -1) || (map > BLI_listbase_count_ex(&vc.obedit->fmaps, map))) {
+ map = -1;
+ }
+ map += 1;
+ if (map != vc.obedit->actfmap) {
+ /* We may want to add notifiers later,
+ * currently select update handles redraw. */
+ vc.obedit->actfmap = map;
+ }
+ }
+ }
}
@@ -2771,6 +2805,7 @@ static void edbm_select_linked_pick_ex(BMEditMesh *em, BMElem *ele, bool sel, in
static int edbm_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
Object *obedit = CTX_data_edit_object(C);
+ EvaluationContext eval_ctx;
ViewContext vc;
BMEditMesh *em;
BMesh *bm;
@@ -2788,6 +2823,7 @@ static int edbm_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmE
view3d_operator_needs_opengl(C);
/* setup view context for argument to callbacks */
+ CTX_data_eval_ctx(C, &eval_ctx);
em_setup_viewcontext(C, &vc);
em = vc.em;
bm = em->bm;
@@ -2800,7 +2836,7 @@ static int edbm_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmE
vc.mval[1] = event->mval[1];
/* return warning! */
- if (unified_findnearest(&vc, &eve, &eed, &efa) == 0) {
+ if (unified_findnearest(&eval_ctx, &vc, &eve, &eed, &efa) == 0) {
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit);
return OPERATOR_CANCELLED;
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index cbed6a37c1f..b2a16d9373b 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -172,7 +172,7 @@ struct EdgeRingOpSubdProps {
};
-static void mesh_operator_edgering_props(wmOperatorType *ot, const int cuts_default)
+static void mesh_operator_edgering_props(wmOperatorType *ot, const int cuts_min, const int cuts_default)
{
/* Note, these values must match delete_mesh() event values */
static EnumPropertyItem prop_subd_edgering_types[] = {
@@ -184,7 +184,7 @@ static void mesh_operator_edgering_props(wmOperatorType *ot, const int cuts_defa
PropertyRNA *prop;
- prop = RNA_def_int(ot->srna, "number_cuts", cuts_default, 0, 1000, "Number of Cuts", "", 0, 64);
+ prop = RNA_def_int(ot->srna, "number_cuts", cuts_default, 0, 1000, "Number of Cuts", "", cuts_min, 64);
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
RNA_def_enum(ot->srna, "interpolation", prop_subd_edgering_types, SUBD_RING_INTERP_PATH,
@@ -251,7 +251,7 @@ void MESH_OT_subdivide_edgering(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
- mesh_operator_edgering_props(ot, 10);
+ mesh_operator_edgering_props(ot, 1, 10);
}
@@ -3303,13 +3303,13 @@ static int edbm_separate_exec(bContext *C, wmOperator *op)
/* editmode separate */
switch (type) {
case MESH_SEPARATE_SELECTED:
- retval = mesh_separate_selected(bmain, scene, sl, base, em->bm);
+ retval = mesh_separate_selected(bmain, scene, sl, base, em->bm);
break;
case MESH_SEPARATE_MATERIAL:
- retval = mesh_separate_material(bmain, scene, sl, base, em->bm);
+ retval = mesh_separate_material(bmain, scene, sl, base, em->bm);
break;
case MESH_SEPARATE_LOOSE:
- retval = mesh_separate_loose(bmain, scene, sl, base, em->bm);
+ retval = mesh_separate_loose(bmain, scene, sl, base, em->bm);
break;
default:
BLI_assert(0);
@@ -3344,10 +3344,10 @@ static int edbm_separate_exec(bContext *C, wmOperator *op)
switch (type) {
case MESH_SEPARATE_MATERIAL:
- retval_iter = mesh_separate_material(bmain, scene, sl, base_iter, bm_old);
+ retval_iter = mesh_separate_material(bmain, scene, sl, base_iter, bm_old);
break;
case MESH_SEPARATE_LOOSE:
- retval_iter = mesh_separate_loose(bmain, scene, sl, base_iter, bm_old);
+ retval_iter = mesh_separate_loose(bmain, scene, sl, base_iter, bm_old);
break;
default:
BLI_assert(0);
@@ -5063,7 +5063,7 @@ static void sort_bmelem_flag(Scene *scene, Object *ob,
}
BM_mesh_remap(em->bm, map[0], map[1], map[2]);
-/* DAG_id_tag_update(ob->data, 0);*/
+/* DEG_id_tag_update(ob->data, 0);*/
for (j = 3; j--; ) {
if (map[j])
@@ -5451,7 +5451,7 @@ void MESH_OT_bridge_edge_loops(wmOperatorType *ot)
RNA_def_float(ot->srna, "merge_factor", 0.5f, 0.0f, 1.0f, "Merge Factor", "", 0.0f, 1.0f);
RNA_def_int(ot->srna, "twist_offset", 0, -1000, 1000, "Twist", "Twist offset for closed loops", -1000, 1000);
- mesh_operator_edgering_props(ot, 0);
+ mesh_operator_edgering_props(ot, 0, 0);
}
static int edbm_wireframe_exec(bContext *C, wmOperator *op)
diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c
index 555fe6c917d..f24b7911e34 100644
--- a/source/blender/editors/mesh/editmesh_utils.c
+++ b/source/blender/editors/mesh/editmesh_utils.c
@@ -383,7 +383,7 @@ void EDBM_mesh_make(ToolSettings *ts, Object *ob, const bool add_key_index)
/**
* \warning This can invalidate the #DerivedMesh cache of other objects (for linked duplicates).
- * Most callers should run #DAG_id_tag_update on \a ob->data, see: T46738, T46913
+ * Most callers should run #DEG_id_tag_update on \a ob->data, see: T46738, T46913
*/
void EDBM_mesh_load(Object *ob)
{
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index 49755c75480..f2e60c55574 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -253,7 +253,7 @@ void ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me)
{
/* could be ldata or pdata */
CustomData *ldata = GET_CD_DATA(me, ldata);
- const int layernum = CustomData_get_active_layer_index(ldata, CD_MLOOPUV);
+ const int layernum = CustomData_get_active_layer(ldata, CD_MLOOPUV);
ED_mesh_uv_loop_reset_ex(me, layernum);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
@@ -440,6 +440,20 @@ int ED_mesh_color_add(Mesh *me, const char *name, const bool active_set)
return layernum;
}
+bool ED_mesh_color_ensure(struct Mesh *me, const char *name)
+{
+ BLI_assert(me->edit_btmesh == NULL);
+
+ if (!me->mloopcol && me->totloop) {
+ CustomData_add_layer_named(&me->ldata, CD_MLOOPCOL, CD_DEFAULT, NULL, me->totloop, name);
+ BKE_mesh_update_customdata_pointers(me, true);
+ }
+
+ DEG_id_tag_update(&me->id, 0);
+
+ return (me->mloopcol != NULL);
+}
+
bool ED_mesh_color_remove_index(Mesh *me, const int n)
{
CustomData *ldata = GET_CD_DATA(me, ldata);
diff --git a/source/blender/editors/mesh/mesh_navmesh.c b/source/blender/editors/mesh/mesh_navmesh.c
index 66c77593c75..e5705d2d3e7 100644
--- a/source/blender/editors/mesh/mesh_navmesh.c
+++ b/source/blender/editors/mesh/mesh_navmesh.c
@@ -73,18 +73,21 @@ static void createVertsTrisData(bContext *C, LinkNode *obs,
LinkNode *oblink, *dmlink;
DerivedMesh *dm;
Scene *scene = CTX_data_scene(C);
+ EvaluationContext eval_ctx;
LinkNode *dms = NULL;
int nverts, ntris, *tris;
float *verts;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
nverts = 0;
ntris = 0;
/* calculate number of verts and tris */
for (oblink = obs; oblink; oblink = oblink->next) {
ob = (Object *) oblink->link;
- dm = mesh_create_derived_no_virtual(scene, ob, NULL, CD_MASK_MESH);
+ dm = mesh_create_derived_no_virtual(&eval_ctx, scene, ob, NULL, CD_MASK_MESH);
DM_ensure_tessface(dm);
BLI_linklist_prepend(&dms, dm);
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index e7b1f925d5e..da0da05bb13 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -79,8 +79,8 @@
* return 0 if no join is made (error) and 1 if the join is done */
static void join_mesh_single(
- Main *bmain, Scene *scene,
- Object *ob_dst, Base *base_src, float imat[4][4],
+ bContext *C, Main *bmain, Scene *scene,
+ Object *ob_dst, Object *ob_src, float imat[4][4],
MVert **mvert_pp, MEdge **medge_pp, MLoop **mloop_pp, MPoly **mpoly_pp,
CustomData *vdata, CustomData *edata, CustomData *ldata, CustomData *pdata,
int totvert, int totedge, int totloop, int totpoly,
@@ -88,14 +88,17 @@ static void join_mesh_single(
Material **matar, int *matmap, int totcol,
int *vertofs, int *edgeofs, int *loopofs, int *polyofs)
{
+ EvaluationContext eval_ctx;
int a, b;
- Mesh *me = base_src->object->data;
+ Mesh *me = ob_src->data;
MVert *mvert = *mvert_pp;
MEdge *medge = *medge_pp;
MLoop *mloop = *mloop_pp;
MPoly *mpoly = *mpoly_pp;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
if (me->totvert) {
/* merge customdata flag */
((Mesh *)ob_dst->data)->cd_flag |= me->cd_flag;
@@ -114,10 +117,10 @@ static void join_mesh_single(
/* Build src to merged mapping of vgroup indices. */
bDeformGroup *dg_src;
- int *vgroup_index_map = alloca(sizeof(*vgroup_index_map) * BLI_listbase_count(&base_src->object->defbase));
+ int *vgroup_index_map = alloca(sizeof(*vgroup_index_map) * BLI_listbase_count(&ob_src->defbase));
bool is_vgroup_remap_needed = false;
- for (dg_src = base_src->object->defbase.first, b = 0; dg_src; dg_src = dg_src->next, b++) {
+ for (dg_src = ob_src->defbase.first, b = 0; dg_src; dg_src = dg_src->next, b++) {
vgroup_index_map[b] = defgroup_name_index(ob_dst, dg_src->name);
is_vgroup_remap_needed = is_vgroup_remap_needed || (vgroup_index_map[b] != b);
}
@@ -132,11 +135,11 @@ static void join_mesh_single(
}
/* if this is the object we're merging into, no need to do anything */
- if (base_src->object != ob_dst) {
+ if (ob_src != ob_dst) {
float cmat[4][4];
/* watch this: switch matmul order really goes wrong */
- mul_m4_m4m4(cmat, imat, base_src->object->obmat);
+ mul_m4_m4m4(cmat, imat, ob_src->obmat);
/* transform vertex coordinates into new space */
for (a = 0, mvert = *mvert_pp; a < me->totvert; a++, mvert++) {
@@ -213,13 +216,13 @@ static void join_mesh_single(
}
if (me->totloop) {
- if (base_src->object != ob_dst) {
+ if (ob_src != ob_dst) {
MultiresModifierData *mmd;
- multiresModifier_prepare_join(scene, base_src->object, ob_dst);
+ multiresModifier_prepare_join(&eval_ctx, scene, ob_src, ob_dst);
- if ((mmd = get_multires_modifier(scene, base_src->object, true))) {
- ED_object_iter_other(bmain, base_src->object, true,
+ if ((mmd = get_multires_modifier(scene, ob_src, true))) {
+ ED_object_iter_other(bmain, ob_src, true,
ED_object_multires_update_totlevels_cb,
&mmd->totlvl);
}
@@ -237,8 +240,8 @@ static void join_mesh_single(
if (me->totpoly) {
if (matmap) {
/* make mapping for materials */
- for (a = 1; a <= base_src->object->totcol; a++) {
- Material *ma = give_current_material(base_src->object, a);
+ for (a = 1; a <= ob_src->totcol; a++) {
+ Material *ma = give_current_material(ob_src, a);
for (b = 0; b < totcol; b++) {
if (ma == matar[b]) {
@@ -273,8 +276,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
- Base *ob_base = CTX_data_active_base(C);
- Object *ob = ob_base->object;
+ Object *ob = CTX_data_active_object(C);
Material **matar = NULL, *ma;
Mesh *me;
MVert *mvert = NULL;
@@ -451,15 +453,6 @@ int join_mesh_exec(bContext *C, wmOperator *op)
/* adjust settings to fit (allocate a new data-array) */
kbn->data = MEM_callocN(sizeof(float) * 3 * totvert, "joined_shapekey");
kbn->totelem = totvert;
-
- /* XXX 2.5 Animato */
-#if 0
- /* also, copy corresponding ipo-curve to ipo-block if applicable */
- if (me->key->ipo && key->ipo) {
- /* FIXME... this is a luxury item! */
- puts("FIXME: ignoring IPO's when joining shapekeys on Meshes for now...");
- }
-#endif
}
kb_map[i] = kbn;
@@ -505,8 +498,8 @@ int join_mesh_exec(bContext *C, wmOperator *op)
* active mesh will remain first ones in new result of the merge, in same order for CD layers, etc. See also T50084.
*/
join_mesh_single(
- bmain, scene,
- ob, ob_base, imat,
+ C, bmain, scene,
+ ob, ob, imat,
&mvert, &medge, &mloop, &mpoly,
&vdata, &edata, &ldata, &pdata,
totvert, totedge, totloop, totpoly,
@@ -522,8 +515,8 @@ int join_mesh_exec(bContext *C, wmOperator *op)
/* only join if this is a mesh */
if (base->object->type == OB_MESH) {
join_mesh_single(
- bmain, scene,
- ob, base, imat,
+ C, bmain, scene,
+ ob, base->object, imat,
&mvert, &medge, &mloop, &mpoly,
&vdata, &edata, &ldata, &pdata,
totvert, totedge, totloop, totpoly,
@@ -624,6 +617,7 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
+ EvaluationContext eval_ctx;
Mesh *me = (Mesh *)ob->data;
Mesh *selme = NULL;
DerivedMesh *dm = NULL;
@@ -631,6 +625,8 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op)
KeyBlock *kb;
bool ok = false, nonequal_verts = false;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases)
{
if (base->object == ob) continue;
@@ -672,7 +668,7 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op)
selme = (Mesh *)base->object->data;
if (selme->totvert == me->totvert) {
- dm = mesh_get_derived_deform(scene, base->object, CD_MASK_BAREMESH);
+ dm = mesh_get_derived_deform(&eval_ctx, scene, base->object, CD_MASK_BAREMESH);
if (!dm) continue;
@@ -1100,6 +1096,7 @@ int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, DerivedMesh *dm)
*/
bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], unsigned int *index, int size)
{
+ EvaluationContext eval_ctx;
ViewContext vc;
Mesh *me = ob->data;
@@ -1108,6 +1105,7 @@ bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], unsigned int
if (!me || me->totpoly == 0)
return false;
+ CTX_data_eval_ctx(C, &eval_ctx);
view3d_set_viewcontext(C, &vc);
if (size) {
@@ -1115,11 +1113,11 @@ bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], unsigned int
* on an edge in the backbuf, we can still select a face */
float dummy_dist;
- *index = ED_view3d_backbuf_sample_rect(&vc, mval, size, 1, me->totpoly + 1, &dummy_dist);
+ *index = ED_view3d_backbuf_sample_rect(&eval_ctx, &vc, mval, size, 1, me->totpoly + 1, &dummy_dist);
}
else {
/* sample only on the exact position */
- *index = ED_view3d_backbuf_sample(&vc, mval[0], mval[1]);
+ *index = ED_view3d_backbuf_sample(&eval_ctx, &vc, mval[0], mval[1]);
}
if ((*index) == 0 || (*index) > (unsigned int)me->totpoly)
@@ -1158,9 +1156,12 @@ static void ed_mesh_pick_face_vert__mpoly_find(
*/
bool ED_mesh_pick_face_vert(bContext *C, Object *ob, const int mval[2], unsigned int *index, int size)
{
+ EvaluationContext eval_ctx;
unsigned int poly_index;
Mesh *me = ob->data;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
BLI_assert(me && GS(me->id.name) == ID_ME);
if (ED_mesh_pick_face(C, ob, mval, &poly_index, size)) {
@@ -1168,7 +1169,7 @@ bool ED_mesh_pick_face_vert(bContext *C, Object *ob, const int mval[2], unsigned
struct ARegion *ar = CTX_wm_region(C);
/* derived mesh to find deformed locations */
- DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX);
+ DerivedMesh *dm = mesh_get_derived_final(&eval_ctx, scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX);
int v_idx_best = ORIGINDEX_NONE;
@@ -1265,9 +1266,12 @@ static void ed_mesh_pick_vert__mapFunc(void *userData, int index, const float co
}
bool ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], unsigned int *index, int size, bool use_zbuf)
{
+ EvaluationContext eval_ctx;
ViewContext vc;
Mesh *me = ob->data;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
BLI_assert(me && GS(me->id.name) == ID_ME);
if (!me || me->totvert == 0)
@@ -1281,11 +1285,11 @@ bool ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], unsigned int
* on an face in the backbuf, we can still select a vert */
float dummy_dist;
- *index = ED_view3d_backbuf_sample_rect(&vc, mval, size, 1, me->totvert + 1, &dummy_dist);
+ *index = ED_view3d_backbuf_sample_rect(&eval_ctx, &vc, mval, size, 1, me->totvert + 1, &dummy_dist);
}
else {
/* sample only on the exact position */
- *index = ED_view3d_backbuf_sample(&vc, mval[0], mval[1]);
+ *index = ED_view3d_backbuf_sample(&eval_ctx, &vc, mval[0], mval[1]);
}
if ((*index) == 0 || (*index) > (unsigned int)me->totvert)
@@ -1295,7 +1299,7 @@ bool ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], unsigned int
}
else {
/* derived mesh to find deformed locations */
- DerivedMesh *dm = mesh_get_derived_final(vc.scene, ob, CD_MASK_BAREMESH);
+ DerivedMesh *dm = mesh_get_derived_final(&eval_ctx, vc.scene, ob, CD_MASK_BAREMESH);
ARegion *ar = vc.ar;
RegionView3D *rv3d = ar->regiondata;
diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c
index bb0a3234b43..47d354ac72a 100644
--- a/source/blender/editors/metaball/mball_edit.c
+++ b/source/blender/editors/metaball/mball_edit.c
@@ -584,6 +584,7 @@ bool ED_mball_select_pick(bContext *C, const int mval[2], bool extend, bool dese
{
static MetaElem *startelem = NULL;
Object *obedit = CTX_data_edit_object(C);
+ EvaluationContext eval_ctx;
ViewContext vc;
MetaBall *mb = (MetaBall *)obedit->data;
MetaElem *ml, *ml_act = NULL;
@@ -591,11 +592,12 @@ bool ED_mball_select_pick(bContext *C, const int mval[2], bool extend, bool dese
unsigned int buffer[MAXPICKBUF];
rcti rect;
+ CTX_data_eval_ctx(C, &eval_ctx);
view3d_set_viewcontext(C, &vc);
BLI_rcti_init_pt_radius(&rect, mval, 12);
- hits = view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect, VIEW3D_SELECT_PICK_NEAREST);
+ hits = view3d_opengl_select(&eval_ctx, &vc, buffer, MAXPICKBUF, &rect, VIEW3D_SELECT_PICK_NEAREST);
/* does startelem exist? */
ml = mb->editelems->first;
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index daa76413b25..7451268eac9 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -224,16 +224,19 @@ void ED_object_base_init_transform(bContext *C, Base *base, const float loc[3],
{
Object *ob = base->object;
Scene *scene = CTX_data_scene(C);
+ EvaluationContext eval_ctx;
if (!scene) return;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
if (loc)
copy_v3_v3(ob->loc, loc);
if (rot)
copy_v3_v3(ob->rot, rot);
- BKE_object_where_is_calc(scene, ob);
+ BKE_object_where_is_calc(&eval_ctx, scene, ob);
}
/* Uses context to figure out transform for primitive.
@@ -542,6 +545,7 @@ static int lightprobe_add_exec(bContext *C, wmOperator *op)
case LIGHTPROBE_TYPE_GRID:
probe->distinf = 0.3f;
probe->falloff = 1.0f;
+ probe->clipsta = 0.01f;
break;
case LIGHTPROBE_TYPE_PLANAR:
probe->distinf = 0.1f;
@@ -1423,86 +1427,84 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
{
Main *bmain = CTX_data_main(C);
SceneLayer *sl = CTX_data_scene_layer(C);
- ListBase *lb;
+ ListBase *lb_duplis;
DupliObject *dob;
- GHash *dupli_gh = NULL, *parent_gh = NULL;
- Object *object;
+ GHash *dupli_gh, *parent_gh = NULL;
- if (!(base->object->transflag & OB_DUPLI))
+ if (!(base->object->transflag & OB_DUPLI)) {
return;
+ }
- lb = object_duplilist(bmain->eval_ctx, scene, base->object);
+ lb_duplis = object_duplilist(bmain->eval_ctx, scene, base->object);
- if (use_hierarchy || use_base_parent) {
- dupli_gh = BLI_ghash_ptr_new(__func__);
- if (use_hierarchy) {
- if (base->object->transflag & OB_DUPLIGROUP) {
- parent_gh = BLI_ghash_new(dupliobject_group_hash, dupliobject_group_cmp, __func__);
- }
- else {
- parent_gh = BLI_ghash_new(dupliobject_hash, dupliobject_cmp, __func__);
- }
+ dupli_gh = BLI_ghash_ptr_new(__func__);
+ if (use_hierarchy) {
+ if (base->object->transflag & OB_DUPLIGROUP) {
+ parent_gh = BLI_ghash_new(dupliobject_group_hash, dupliobject_group_cmp, __func__);
+ }
+ else {
+ parent_gh = BLI_ghash_new(dupliobject_hash, dupliobject_cmp, __func__);
}
}
- for (dob = lb->first; dob; dob = dob->next) {
- Base *basen;
- Object *ob = ID_NEW_SET(dob->ob, BKE_object_copy(bmain, dob->ob));
+ for (dob = lb_duplis->first; dob; dob = dob->next) {
+ Object *ob_src = dob->ob;
+ Object *ob_dst = ID_NEW_SET(dob->ob, BKE_object_copy(bmain, ob_src));
+ Base *base_dst;
/* font duplis can have a totcol without material, we get them from parent
* should be implemented better...
*/
- if (ob->mat == NULL) ob->totcol = 0;
+ if (ob_dst->mat == NULL) {
+ ob_dst->totcol = 0;
+ }
- BKE_collection_object_add_from(scene, dob->ob, ob);
- basen = BKE_scene_layer_base_find(sl, ob);
+ BKE_collection_object_add_from(scene, ob_src, ob_dst);
+ base_dst = BKE_scene_layer_base_find(sl, ob_dst);
- BKE_scene_object_base_flag_sync_from_base(basen);
+ BKE_scene_object_base_flag_sync_from_base(base_dst);
/* make sure apply works */
- BKE_animdata_free(&ob->id, true);
- ob->adt = NULL;
+ BKE_animdata_free(&ob_dst->id, true);
+ ob_dst->adt = NULL;
/* Proxies are not to be copied. */
- ob->proxy_from = NULL;
- ob->proxy_group = NULL;
- ob->proxy = NULL;
+ ob_dst->proxy_from = NULL;
+ ob_dst->proxy_group = NULL;
+ ob_dst->proxy = NULL;
- ob->parent = NULL;
- BKE_constraints_free(&ob->constraints);
- ob->curve_cache = NULL;
- ob->transflag &= ~OB_DUPLI;
+ ob_dst->parent = NULL;
+ BKE_constraints_free(&ob_dst->constraints);
+ ob_dst->curve_cache = NULL;
+ ob_dst->transflag &= ~OB_DUPLI;
- copy_m4_m4(ob->obmat, dob->mat);
- BKE_object_apply_mat4(ob, ob->obmat, false, false);
+ copy_m4_m4(ob_dst->obmat, dob->mat);
+ BKE_object_apply_mat4(ob_dst, ob_dst->obmat, false, false);
- if (dupli_gh) {
- BLI_ghash_insert(dupli_gh, dob, ob);
- }
+ BLI_ghash_insert(dupli_gh, dob, ob_dst);
if (parent_gh) {
void **val;
/* Due to nature of hash/comparison of this ghash, a lot of duplis may be considered as 'the same',
* this avoids trying to insert same key several time and raise asserts in debug builds... */
if (!BLI_ghash_ensure_p(parent_gh, dob, &val)) {
- *val = ob;
+ *val = ob_dst;
}
}
+ }
+
+ for (dob = lb_duplis->first; dob; dob = dob->next) {
+ Object *ob_src = dob->ob;
+ Object *ob_dst = BLI_ghash_lookup(dupli_gh, dob);
/* Remap new object to itself, and clear again newid pointer of orig object. */
- BKE_libblock_relink_to_newid(&ob->id);
- set_sca_new_poins_ob(ob);
- BKE_id_clear_newpoin(&dob->ob->id);
+ BKE_libblock_relink_to_newid(&ob_dst->id);
+ set_sca_new_poins_ob(ob_dst);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
- }
+ DEG_id_tag_update(&ob_dst->id, OB_RECALC_DATA);
- if (use_hierarchy) {
- for (dob = lb->first; dob; dob = dob->next) {
+ if (use_hierarchy) {
/* original parents */
- Object *ob_src = dob->ob;
Object *ob_src_par = ob_src->parent;
-
- Object *ob_dst = BLI_ghash_lookup(dupli_gh, dob);
Object *ob_dst_par = NULL;
/* find parent that was also made real */
@@ -1513,8 +1515,8 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
dob_key.ob = ob_src_par;
if (base->object->transflag & OB_DUPLIGROUP) {
memcpy(&dob_key.persistent_id[1],
- &dob->persistent_id[1],
- sizeof(dob->persistent_id[1]) * (MAX_DUPLI_RECUR - 1));
+ &dob->persistent_id[1],
+ sizeof(dob->persistent_id[1]) * (MAX_DUPLI_RECUR - 1));
}
else {
dob_key.persistent_id[0] = dob->persistent_id[0];
@@ -1538,52 +1540,42 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
ob_dst->parent = base->object;
ob_dst->partype = PAROBJECT;
}
-
- if (ob_dst->parent) {
- invert_m4_m4(ob_dst->parentinv, dob->mat);
-
- /* note, this may be the parent of other objects, but it should
- * still work out ok */
- BKE_object_apply_mat4(ob_dst, dob->mat, false, true);
-
- /* to set ob_dst->orig and in case theres any other discrepicies */
- DEG_id_tag_update(&ob_dst->id, OB_RECALC_OB);
- }
}
- }
- else if (use_base_parent) {
- /* since we are ignoring the internal hierarchy - parent all to the
- * base object */
- for (dob = lb->first; dob; dob = dob->next) {
- /* original parents */
- Object *ob_dst = BLI_ghash_lookup(dupli_gh, dob);
-
+ else if (use_base_parent) {
+ /* since we are ignoring the internal hierarchy - parent all to the
+ * base object */
ob_dst->parent = base->object;
ob_dst->partype = PAROBJECT;
+ }
- /* similer to the code above, see comments */
- invert_m4_m4(ob_dst->parentinv, dob->mat);
+ if (ob_dst->parent) {
+ /* note, this may be the parent of other objects, but it should
+ * still work out ok */
BKE_object_apply_mat4(ob_dst, dob->mat, false, true);
+
+ /* to set ob_dst->orig and in case theres any other discrepicies */
DEG_id_tag_update(&ob_dst->id, OB_RECALC_OB);
}
}
if (base->object->transflag & OB_DUPLIGROUP && base->object->dup_group) {
- for (object = bmain->object.first; object; object = object->id.next) {
- if (object->proxy_group == base->object) {
- object->proxy = NULL;
- object->proxy_from = NULL;
- DEG_id_tag_update(&object->id, OB_RECALC_OB);
+ for (Object *ob = bmain->object.first; ob; ob = ob->id.next) {
+ if (ob->proxy_group == base->object) {
+ ob->proxy = NULL;
+ ob->proxy_from = NULL;
+ DEG_id_tag_update(&ob->id, OB_RECALC_OB);
}
}
}
- if (dupli_gh)
- BLI_ghash_free(dupli_gh, NULL, NULL);
- if (parent_gh)
+ BLI_ghash_free(dupli_gh, NULL, NULL);
+ if (parent_gh) {
BLI_ghash_free(parent_gh, NULL, NULL);
+ }
+
+ free_object_duplilist(lb_duplis);
- free_object_duplilist(lb);
+ BKE_main_id_clear_newpoins(bmain);
base->object->transflag &= ~OB_DUPLI;
}
@@ -1641,14 +1633,14 @@ static EnumPropertyItem convert_target_items[] = {
{0, NULL, 0, NULL, NULL}
};
-static void convert_ensure_curve_cache(Main *bmain, Scene *scene, Object *ob)
+static void convert_ensure_curve_cache(EvaluationContext *eval_ctx, Main *bmain, Scene *scene, Object *ob)
{
if (ob->curve_cache == NULL) {
/* Force creation. This is normally not needed but on operator
* redo we might end up with an object which isn't evaluated yet.
*/
if (ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT)) {
- BKE_displist_make_curveTypes(scene, ob, false);
+ BKE_displist_make_curveTypes(eval_ctx, scene, ob, false);
}
else if (ob->type == OB_MBALL) {
BKE_displist_make_mball(bmain->eval_ctx, scene, ob);
@@ -1656,9 +1648,9 @@ static void convert_ensure_curve_cache(Main *bmain, Scene *scene, Object *ob)
}
}
-static void curvetomesh(Main *bmain, Scene *scene, Object *ob)
+static void curvetomesh(EvaluationContext *eval_ctx, Main *bmain, Scene *scene, Object *ob)
{
- convert_ensure_curve_cache(bmain, scene, ob);
+ convert_ensure_curve_cache(eval_ctx, bmain, scene, ob);
BKE_mesh_from_nurbs(ob); /* also does users */
if (ob->type == OB_MESH) {
@@ -1704,6 +1696,7 @@ static int convert_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
SceneLayer *sl = CTX_data_scene_layer(C);
+ EvaluationContext eval_ctx;
Base *basen = NULL, *basact = NULL;
Object *ob, *ob1, *newob, *obact = CTX_data_active_object(C);
DerivedMesh *dm;
@@ -1715,6 +1708,8 @@ static int convert_exec(bContext *C, wmOperator *op)
bool keep_original = RNA_boolean_get(op->ptr, "keep_original");
int a, mballConverted = 0;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
/* don't forget multiple users! */
{
@@ -1757,7 +1752,7 @@ static int convert_exec(bContext *C, wmOperator *op)
* However, changing this is more design than bugfix, not to mention convoluted code below,
* so that will be for later.
* But at the very least, do not do that with linked IDs! */
- if ((ID_IS_LINKED_DATABLOCK(ob) || ID_IS_LINKED_DATABLOCK(ob->data)) && !keep_original) {
+ if ((ID_IS_LINKED_DATABLOCK(ob) || (ob->data && ID_IS_LINKED_DATABLOCK(ob->data))) && !keep_original) {
keep_original = true;
BKE_reportf(op->reports, RPT_INFO,
"Converting some linked object/object data, enforcing 'Keep Original' option to True");
@@ -1809,7 +1804,7 @@ static int convert_exec(bContext *C, wmOperator *op)
newob = ob;
}
- BKE_mesh_to_curve(scene, newob);
+ BKE_mesh_to_curve(&eval_ctx, scene, newob);
if (newob->type == OB_CURVE) {
BKE_object_free_modifiers(newob); /* after derivedmesh calls! */
@@ -1839,7 +1834,7 @@ static int convert_exec(bContext *C, wmOperator *op)
/* note: get the mesh from the original, not from the copy in some
* cases this doesnt give correct results (when MDEF is used for eg)
*/
- dm = mesh_get_derived_final(scene, newob, CD_MASK_MESH);
+ dm = mesh_get_derived_final(&eval_ctx, scene, newob, CD_MASK_MESH);
DM_to_mesh(dm, newob->data, newob, CD_MASK_MESH, true);
@@ -1911,7 +1906,7 @@ static int convert_exec(bContext *C, wmOperator *op)
BKE_curve_curve_dimension_update(cu);
if (target == OB_MESH) {
- curvetomesh(bmain, scene, newob);
+ curvetomesh(&eval_ctx, bmain, scene, newob);
/* meshes doesn't use displist */
BKE_object_free_curve_cache(newob);
@@ -1935,7 +1930,7 @@ static int convert_exec(bContext *C, wmOperator *op)
newob = ob;
}
- curvetomesh(bmain, scene, newob);
+ curvetomesh(&eval_ctx, bmain, scene, newob);
/* meshes doesn't use displist */
BKE_object_free_curve_cache(newob);
@@ -1973,7 +1968,7 @@ static int convert_exec(bContext *C, wmOperator *op)
for (a = 0; a < newob->totcol; a++) id_us_plus((ID *)me->mat[a]);
}
- convert_ensure_curve_cache(bmain, scene, baseob);
+ convert_ensure_curve_cache(&eval_ctx, bmain, scene, baseob);
BKE_mesh_from_metaball(&baseob->curve_cache->disp, newob->data);
if (obact->type == OB_MBALL) {
@@ -2034,11 +2029,11 @@ static int convert_exec(bContext *C, wmOperator *op)
if (basact) {
/* active base was changed */
ED_object_base_activate(C, basact);
- BASACT_NEW = basact;
+ BASACT_NEW(sl) = basact;
}
- else if (BASACT_NEW->object->flag & OB_DONE) {
- WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, BASACT_NEW->object);
- WM_event_add_notifier(C, NC_OBJECT | ND_DATA, BASACT_NEW->object);
+ else if (BASACT_NEW(sl)->object->flag & OB_DONE) {
+ WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, BASACT_NEW(sl)->object);
+ WM_event_add_notifier(C, NC_OBJECT | ND_DATA, BASACT_NEW(sl)->object);
}
DEG_relations_tag_update(bmain);
@@ -2267,6 +2262,11 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, SceneLayer
if (didit) {
Key *key = BKE_key_from_object(obn);
+ Key *oldkey = BKE_key_from_object(ob);
+ if (oldkey != NULL) {
+ ID_NEW_SET(oldkey, key);
+ }
+
if (dupflag & USER_DUP_ACT) {
bActuator *act;
@@ -2371,7 +2371,7 @@ static int duplicate_exec(bContext *C, wmOperator *op)
}
/* new object becomes active */
- if (BASACT_NEW == base)
+ if (BASACT_NEW(sl) == base)
ED_object_base_activate(C, basen);
if (basen->object->data) {
diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c
index e3dd47295fe..b02cb3e02a8 100644
--- a/source/blender/editors/object/object_bake.c
+++ b/source/blender/editors/object/object_bake.c
@@ -625,7 +625,7 @@ static void init_bake_internal(BakeRender *bkr, bContext *C)
bkr->sa = sc ? BKE_screen_find_big_area(sc, SPACE_IMAGE, 10) : NULL; /* can be NULL */
bkr->main = CTX_data_main(C);
bkr->scene = scene;
- bkr->actob = (scene->r.bake_flag & R_BAKE_TO_ACTIVE) ? OBACT_NEW : NULL;
+ bkr->actob = (scene->r.bake_flag & R_BAKE_TO_ACTIVE) ? OBACT_NEW(sl) : NULL;
bkr->re = RE_NewRender("_Bake View_");
if (scene->r.bake_mode == RE_BAKE_AO) {
@@ -858,7 +858,7 @@ static int bake_image_exec(bContext *C, wmOperator *op)
RE_test_break_cb(bkr.re, NULL, thread_break);
G.is_break = false; /* BKE_blender_test_break uses this global */
- RE_Database_Baking(bkr.re, bmain, scene, scene->lay, scene->r.bake_mode, (scene->r.bake_flag & R_BAKE_TO_ACTIVE) ? OBACT_NEW : NULL);
+ RE_Database_Baking(bkr.re, bmain, scene, scene->lay, scene->r.bake_mode, (scene->r.bake_flag & R_BAKE_TO_ACTIVE) ? OBACT_NEW(sl) : NULL);
/* baking itself is threaded, cannot use test_break in threads */
BLI_init_threads(&threads, do_bake_render, 1);
diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c
index 990761e233a..1a4abec4d20 100644
--- a/source/blender/editors/object/object_bake_api.c
+++ b/source/blender/editors/object/object_bake_api.c
@@ -621,13 +621,15 @@ static size_t initialize_internal_images(BakeImages *bake_images, ReportList *re
}
/* create new mesh with edit mode changes and modifiers applied */
-static Mesh *bake_mesh_new_from_object(Main *bmain, Scene *scene, Object *ob)
+static Mesh *bake_mesh_new_from_object(EvaluationContext *eval_ctx, Main *bmain, Scene *scene, Object *ob)
{
if (ob->mode & OB_MODE_EDIT)
ED_object_editmode_load(ob);
- Mesh *me = BKE_mesh_new_from_object(bmain, scene, ob, 1, 2, 0, 0);
- BKE_mesh_split_faces(me, true);
+ Mesh *me = BKE_mesh_new_from_object(eval_ctx, bmain, scene, ob, 1, 2, 0, 0);
+ if (me->flag & ME_AUTOSMOOTH) {
+ BKE_mesh_split_faces(me, true);
+ }
return me;
}
@@ -783,7 +785,7 @@ static int bake(
}
/* get the mesh as it arrives in the renderer */
- me_low = bake_mesh_new_from_object(bmain, scene, ob_low);
+ me_low = bake_mesh_new_from_object(RE_GetEvalCtx(re), bmain, scene, ob_low);
/* populate the pixel array with the face data */
if ((is_selected_to_active && (ob_cage == NULL) && is_cage) == false)
@@ -798,7 +800,7 @@ static int bake(
/* prepare cage mesh */
if (ob_cage) {
- me_cage = bake_mesh_new_from_object(bmain, scene, ob_cage);
+ me_cage = bake_mesh_new_from_object(RE_GetEvalCtx(re), bmain, scene, ob_cage);
if ((me_low->totpoly != me_cage->totpoly) || (me_low->totloop != me_cage->totloop)) {
BKE_report(reports, RPT_ERROR,
"Invalid cage object, the cage mesh must have the same number "
@@ -830,7 +832,7 @@ static int bake(
ob_low->modifiers = modifiers_tmp;
/* get the cage mesh as it arrives in the renderer */
- me_cage = bake_mesh_new_from_object(bmain, scene, ob_low);
+ me_cage = bake_mesh_new_from_object(RE_GetEvalCtx(re), bmain, scene, ob_low);
RE_bake_pixels_populate(me_cage, pixel_array_low, num_pixels, &bake_images, uv_layer);
}
@@ -856,7 +858,7 @@ static int bake(
tmd->quad_method = MOD_TRIANGULATE_QUAD_FIXED;
tmd->ngon_method = MOD_TRIANGULATE_NGON_EARCLIP;
- highpoly[i].me = bake_mesh_new_from_object(bmain, scene, highpoly[i].ob);
+ highpoly[i].me = bake_mesh_new_from_object(RE_GetEvalCtx(re), bmain, scene, highpoly[i].ob);
highpoly[i].ob->restrictflag &= ~OB_RESTRICT_RENDER;
/* lowpoly to highpoly transformation matrix */
@@ -959,7 +961,7 @@ cage_cleanup:
md->mode &= ~eModifierMode_Render;
}
- me_nores = bake_mesh_new_from_object(bmain, scene, ob_low);
+ me_nores = bake_mesh_new_from_object(RE_GetEvalCtx(re), bmain, scene, ob_low);
RE_bake_pixels_populate(me_nores, pixel_array_low, num_pixels, &bake_images, uv_layer);
RE_bake_normal_world_to_tangent(pixel_array_low, num_pixels, depth, result, me_nores, normal_swizzle, ob_low->obmat);
@@ -1031,7 +1033,7 @@ cage_cleanup:
}
else {
/* if everything else fails, use the material index */
- char tmp[4];
+ char tmp[5];
sprintf(tmp, "%d", i % 1000);
BLI_path_suffix(name, FILE_MAX, tmp, "_");
}
@@ -1162,7 +1164,7 @@ static void bake_init_api_data(wmOperator *op, bContext *C, BakeAPIRender *bkr)
bkr->result = OPERATOR_CANCELLED;
- bkr->render = RE_NewRender(bkr->scene->id.name);
+ bkr->render = RE_NewSceneRender(bkr->scene);
/* XXX hack to force saving to always be internal. Whether (and how) to support
* external saving will be addressed later */
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index d110400de80..4e578906e07 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -775,8 +775,12 @@ void CONSTRAINT_OT_limitdistance_reset(wmOperatorType *ot)
/* ------------- Child-Of Constraint ------------------ */
-static void child_get_inverse_matrix(Scene *scene, Object *ob, bConstraint *con, float invmat[4][4], const int owner)
+static void child_get_inverse_matrix(const bContext *C, Scene *scene, Object *ob, bConstraint *con, float invmat[4][4], const int owner)
{
+ EvaluationContext eval_ctx;
+
+ CTX_data_eval_ctx(C, &eval_ctx);
+
/* nullify inverse matrix first */
unit_m4(invmat);
@@ -802,7 +806,7 @@ static void child_get_inverse_matrix(Scene *scene, Object *ob, bConstraint *con,
* to use as baseline ("pmat") to derive delta from. This extra calc saves users
* from having pressing "Clear Inverse" first
*/
- BKE_pose_where_is(scene, ob);
+ BKE_pose_where_is(&eval_ctx, scene, ob);
copy_m4_m4(pmat, pchan->pose_mat);
/* 2. knock out constraints starting from this one */
@@ -819,7 +823,7 @@ static void child_get_inverse_matrix(Scene *scene, Object *ob, bConstraint *con,
}
/* 3. solve pose without disabled constraints */
- BKE_pose_where_is(scene, ob);
+ BKE_pose_where_is(&eval_ctx, scene, ob);
/* 4. determine effect of constraint by removing the newly calculated
* pchan->pose_mat from the original pchan->pose_mat, thus determining
@@ -842,7 +846,7 @@ static void child_get_inverse_matrix(Scene *scene, Object *ob, bConstraint *con,
}
/* 6. recalculate pose with new inv-mat applied */
- BKE_pose_where_is(scene, ob);
+ BKE_pose_where_is(&eval_ctx, scene, ob);
}
}
if (owner == EDIT_CONSTRAINT_OWNER_OBJECT) {
@@ -853,7 +857,7 @@ static void child_get_inverse_matrix(Scene *scene, Object *ob, bConstraint *con,
BLI_assert(BLI_findindex(&ob->constraints, con) != -1);
/* use BKE_object_workob_calc_parent to find inverse - just like for normal parenting */
- BKE_object_workob_calc_parent(scene, ob, &workob);
+ BKE_object_workob_calc_parent(&eval_ctx, scene, ob, &workob);
invert_m4_m4(invmat, workob.obmat);
}
}
@@ -875,7 +879,7 @@ static int childof_set_inverse_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- child_get_inverse_matrix(scene, ob, con, data->invmat, owner);
+ child_get_inverse_matrix(C, scene, ob, con, data->invmat, owner);
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
@@ -1097,7 +1101,7 @@ static int objectsolver_set_inverse_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- child_get_inverse_matrix(scene, ob, con, data->invmat, owner);
+ child_get_inverse_matrix(C, scene, ob, con, data->invmat, owner);
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
@@ -1685,14 +1689,14 @@ static bool get_new_constraint_target(bContext *C, int con_type, Object **tar_ob
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
SceneLayer *sl = CTX_data_scene_layer(C);
- Base *base = BASACT_NEW, *newbase = NULL;
+ Base *base = BASACT_NEW(sl), *newbase = NULL;
Object *obt;
/* add new target object */
obt = BKE_object_add(bmain, scene, sl, OB_EMPTY, NULL);
/* set layers OK */
- newbase = BASACT_NEW;
+ newbase = BASACT_NEW(sl);
newbase->lay = base->lay;
obt->lay = newbase->lay;
@@ -1711,7 +1715,7 @@ static bool get_new_constraint_target(bContext *C, int con_type, Object **tar_ob
}
/* restore, BKE_object_add sets active */
- BASACT_NEW = base;
+ BASACT_NEW(sl) = base;
base->flag |= BASE_SELECTED;
/* make our new target the new object */
diff --git a/source/blender/editors/object/object_data_transfer.c b/source/blender/editors/object/object_data_transfer.c
index 9a89ec453fd..3647533eb8f 100644
--- a/source/blender/editors/object/object_data_transfer.c
+++ b/source/blender/editors/object/object_data_transfer.c
@@ -94,9 +94,12 @@ static EnumPropertyItem DT_layer_items[] = {
static EnumPropertyItem *dt_layers_select_src_itemf(
bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
{
+ EvaluationContext eval_ctx;
EnumPropertyItem *item = NULL, tmp_item = {0};
int totitem = 0;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
const int data_type = RNA_enum_get(ptr, "data_type");
if (!C) { /* needed for docs and i18n tools */
@@ -140,7 +143,7 @@ static EnumPropertyItem *dt_layers_select_src_itemf(
int num_data, i;
/* XXX Is this OK? */
- dm_src = mesh_get_derived_final(scene, ob_src, CD_MASK_BAREMESH | CD_MLOOPUV);
+ dm_src = mesh_get_derived_final(&eval_ctx, scene, ob_src, CD_MASK_BAREMESH | CD_MLOOPUV);
ldata = dm_src->getLoopDataLayout(dm_src);
num_data = CustomData_number_of_layers(ldata, CD_MLOOPUV);
@@ -163,7 +166,7 @@ static EnumPropertyItem *dt_layers_select_src_itemf(
int num_data, i;
/* XXX Is this OK? */
- dm_src = mesh_get_derived_final(scene, ob_src, CD_MASK_BAREMESH | CD_MLOOPCOL);
+ dm_src = mesh_get_derived_final(&eval_ctx, scene, ob_src, CD_MASK_BAREMESH | CD_MLOOPCOL);
ldata = dm_src->getLoopDataLayout(dm_src);
num_data = CustomData_number_of_layers(ldata, CD_MLOOPCOL);
@@ -345,6 +348,9 @@ static int data_transfer_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Object *ob_src = ED_object_active_context(C);
+ EvaluationContext eval_ctx;
+
+ CTX_data_eval_ctx(C, &eval_ctx);
ListBase ctx_objects;
CollectionPointerLink *ctx_ob_dst;
@@ -413,7 +419,7 @@ static int data_transfer_exec(bContext *C, wmOperator *op)
}
if (BKE_object_data_transfer_mesh(
- scene, ob_src, ob_dst, data_type, use_create,
+ &eval_ctx, scene, ob_src, ob_dst, data_type, use_create,
map_vert_mode, map_edge_mode, map_loop_mode, map_poly_mode,
space_transform, use_auto_transform,
max_distance, ray_radius, islands_precision,
@@ -623,8 +629,11 @@ static int datalayout_transfer_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Object *ob_act = ED_object_active_context(C);
+ EvaluationContext eval_ctx;
DataTransferModifierData *dtmd;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
dtmd = (DataTransferModifierData *)edit_modifier_property_get(op, ob_act, eModifierType_DataTransfer);
/* If we have a modifier, we transfer data layout from this modifier's source object to active one.
@@ -639,7 +648,7 @@ static int datalayout_transfer_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- BKE_object_data_transfer_layout(scene, ob_src, ob_dst, dtmd->data_types, use_delete,
+ BKE_object_data_transfer_layout(&eval_ctx, scene, ob_src, ob_dst, dtmd->data_types, use_delete,
dtmd->layers_select_src, dtmd->layers_select_dst);
DEG_id_tag_update(&ob_dst->id, OB_RECALC_DATA);
@@ -669,7 +678,7 @@ static int datalayout_transfer_exec(bContext *C, wmOperator *op)
for (ctx_ob_dst = ctx_objects.first; ctx_ob_dst; ctx_ob_dst = ctx_ob_dst->next) {
Object *ob_dst = ctx_ob_dst->ptr.data;
if (data_transfer_exec_is_object_valid(op, ob_src, ob_dst, false)) {
- BKE_object_data_transfer_layout(scene, ob_src, ob_dst, data_type, use_delete,
+ BKE_object_data_transfer_layout(&eval_ctx, scene, ob_src, ob_dst, data_type, use_delete,
layers_select_src, layers_select_dst);
}
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 2579b7db419..289d0bb586b 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -545,8 +545,8 @@ static void copymenu_properties(SceneLayer *sl, Object *ob)
nr = pupmenu(str);
if (nr == 1 || nr == 2) {
- for (base = FIRSTBASE_NEW; base; base = base->next) {
- if ((base != BASACT_NEW) && (TESTBASELIB_NEW(base))) {
+ for (base = FIRSTBASE_NEW(sl); base; base = base->next) {
+ if ((base != BASACT_NEW(sl)) && (TESTBASELIB_NEW(base))) {
if (nr == 1) { /* replace */
BKE_bproperty_copy_list(&base->object->prop, &ob->prop);
}
@@ -562,8 +562,8 @@ static void copymenu_properties(SceneLayer *sl, Object *ob)
prop = BLI_findlink(&ob->prop, nr - 4); /* account for first 3 menu items & menu index starting at 1*/
if (prop) {
- for (base = FIRSTBASE_NEW; base; base = base->next) {
- if ((base != BASACT_NEW) && (TESTBASELIB_NEW(base))) {
+ for (base = FIRSTBASE_NEW(sl); base; base = base->next) {
+ if ((base != BASACT_NEW(sl)) && (TESTBASELIB_NEW(base))) {
BKE_bproperty_object_set(base->object, prop);
}
}
@@ -578,7 +578,7 @@ static void copymenu_logicbricks(SceneLayer *sl, Object *ob)
//XXX no longer used - to be removed - replaced by logicbricks_copy_exec
Base *base;
- for (base = FIRSTBASE_NEW; base; base = base->next) {
+ for (base = FIRSTBASE_NEW(sl); base; base = base->next) {
if (base->object != ob) {
if (TESTBASELIB_NEW(base)) {
@@ -591,9 +591,9 @@ static void copymenu_logicbricks(SceneLayer *sl, Object *ob)
/* now copy it, this also works without logicbricks! */
clear_sca_new_poins_ob(ob);
- copy_sensors(&base->object->sensors, &ob->sensors);
- copy_controllers(&base->object->controllers, &ob->controllers);
- copy_actuators(&base->object->actuators, &ob->actuators);
+ copy_sensors(&base->object->sensors, &ob->sensors, 0);
+ copy_controllers(&base->object->controllers, &ob->controllers, 0);
+ copy_actuators(&base->object->actuators, &ob->actuators, 0);
set_sca_new_poins_ob(base->object);
/* some menu settings */
@@ -669,7 +669,7 @@ static void copy_attr(Main *bmain, Scene *scene, SceneLayer *sl, short event)
if (ID_IS_LINKED_DATABLOCK(scene)) return;
- if (!(ob = OBACT_NEW)) return;
+ if (!(ob = OBACT_NEW(sl))) return;
if (scene->obedit) { // XXX get from context
/* obedit_copymenu(); */
@@ -689,8 +689,8 @@ static void copy_attr(Main *bmain, Scene *scene, SceneLayer *sl, short event)
return;
}
- for (base = FIRSTBASE_NEW; base; base = base->next) {
- if (base != BASACT_NEW) {
+ for (base = FIRSTBASE_NEW(sl); base; base = base->next) {
+ if (base != BASACT_NEW(sl)) {
if (TESTBASELIB_NEW(base)) {
DEG_id_tag_update(&base->object->id, OB_RECALC_DATA);
@@ -752,7 +752,7 @@ static void copy_attr(Main *bmain, Scene *scene, SceneLayer *sl, short event)
base->object->collision_boundtype = ob->collision_boundtype;
}
base->object->margin = ob->margin;
- base->object->bsoft = copy_bulletsoftbody(ob->bsoft);
+ base->object->bsoft = copy_bulletsoftbody(ob->bsoft, 0);
}
else if (event == 17) { /* tex space */
@@ -860,7 +860,7 @@ static void copy_attr(Main *bmain, Scene *scene, SceneLayer *sl, short event)
base->object->softflag = ob->softflag;
if (base->object->soft) sbFree(base->object->soft);
- base->object->soft = copy_softbody(ob->soft, false);
+ base->object->soft = copy_softbody(ob->soft, 0);
if (!modifiers_findByType(base->object, eModifierType_Softbody)) {
BLI_addhead(&base->object->modifiers, modifier_new(eModifierType_Softbody));
@@ -916,7 +916,7 @@ static void UNUSED_FUNCTION(copy_attr_menu) (Main *bmain, Scene *scene, SceneLay
short event;
char str[512];
- if (!(ob = OBACT_NEW)) return;
+ if (!(ob = OBACT_NEW(sl))) return;
if (scene->obedit) { /* XXX get from context */
/* if (ob->type == OB_MESH) */
@@ -976,13 +976,16 @@ void ED_object_check_force_modifiers(Main *bmain, Scene *scene, Object *object)
/* add/remove modifier as needed */
if (!md) {
- if (pd && (pd->shape == PFIELD_SHAPE_SURFACE) && ELEM(pd->forcefield, PFIELD_GUIDE, PFIELD_TEXTURE) == 0)
- if (ELEM(object->type, OB_MESH, OB_SURF, OB_FONT, OB_CURVE))
+ if (pd && (pd->shape == PFIELD_SHAPE_SURFACE) && !ELEM(pd->forcefield, 0, PFIELD_GUIDE, PFIELD_TEXTURE)) {
+ if (ELEM(object->type, OB_MESH, OB_SURF, OB_FONT, OB_CURVE)) {
ED_object_modifier_add(NULL, bmain, scene, object, NULL, eModifierType_Surface);
+ }
+ }
}
else {
- if (!pd || pd->shape != PFIELD_SHAPE_SURFACE || pd->forcefield != PFIELD_FORCE)
+ if (!pd || (pd->shape != PFIELD_SHAPE_SURFACE) || ELEM(pd->forcefield, 0, PFIELD_GUIDE, PFIELD_TEXTURE)) {
ED_object_modifier_remove(NULL, bmain, object, md);
+ }
}
}
@@ -1042,7 +1045,7 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene)
CTX_DATA_END;
/* recalculate paths, then free */
- animviz_calc_motionpaths(scene, &targets);
+ animviz_calc_motionpaths(C, scene, &targets);
BLI_freelistN(&targets);
}
@@ -1263,6 +1266,7 @@ static int shade_smooth_exec(bContext *C, wmOperator *op)
if (ob->type == OB_MESH) {
BKE_mesh_smooth_flag_set(ob, !clear);
+ BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_ALL);
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
@@ -1340,7 +1344,7 @@ static void UNUSED_FUNCTION(image_aspect) (Scene *scene, SceneLayer *sl)
if (scene->obedit) return; // XXX get from context
if (ID_IS_LINKED_DATABLOCK(scene)) return;
- for (base = FIRSTBASE_NEW; base; base = base->next) {
+ for (base = FIRSTBASE_NEW(sl); base; base = base->next) {
if (TESTBASELIB_NEW(base)) {
ob = base->object;
done = false;
@@ -1941,9 +1945,9 @@ static int logicbricks_copy_exec(bContext *C, wmOperator *UNUSED(op))
/* now copy it, this also works without logicbricks! */
clear_sca_new_poins_ob(ob);
- copy_sensors(&ob_iter->sensors, &ob->sensors);
- copy_controllers(&ob_iter->controllers, &ob->controllers);
- copy_actuators(&ob_iter->actuators, &ob->actuators);
+ copy_sensors(&ob_iter->sensors, &ob->sensors, 0);
+ copy_controllers(&ob_iter->controllers, &ob->controllers, 0);
+ copy_actuators(&ob_iter->actuators, &ob->actuators, 0);
set_sca_new_poins_ob(ob_iter);
/* some menu settings */
@@ -2004,7 +2008,7 @@ static int game_physics_copy_exec(bContext *C, wmOperator *UNUSED(op))
copy_v3_v3(ob_iter->anisotropicFriction, ob->anisotropicFriction);
ob_iter->collision_boundtype = ob->collision_boundtype;
ob_iter->margin = ob->margin;
- ob_iter->bsoft = copy_bulletsoftbody(ob->bsoft);
+ ob_iter->bsoft = copy_bulletsoftbody(ob->bsoft, 0);
if (ob->restrictflag & OB_RESTRICT_RENDER)
ob_iter->restrictflag |= OB_RESTRICT_RENDER;
else
diff --git a/source/blender/editors/object/object_facemap_ops.c b/source/blender/editors/object/object_facemap_ops.c
index 87b59da6c62..d526ea93ffa 100644
--- a/source/blender/editors/object/object_facemap_ops.c
+++ b/source/blender/editors/object/object_facemap_ops.c
@@ -146,7 +146,7 @@ static void object_fmap_swap_object_mode(Object *ob, int num1, int num2)
if (num1 != -1) {
if (map[i] == num1)
map[i] = num2;
- else if (map[i]== num2)
+ else if (map[i] == num2)
map[i] = num1;
}
}
diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c
index 3064bf8af1a..b32fb975ea8 100644
--- a/source/blender/editors/object/object_group.c
+++ b/source/blender/editors/object/object_group.c
@@ -201,7 +201,7 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
SceneLayer *sl = CTX_data_scene_layer(C);
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
int single_group_index = RNA_enum_get(op->ptr, "group");
Group *single_group = group_object_active_find_index(ob, single_group_index);
Group *group;
diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c
index fce55689e9a..314019b4f76 100644
--- a/source/blender/editors/object/object_hook.c
+++ b/source/blender/editors/object/object_hook.c
@@ -467,15 +467,18 @@ static Object *add_hook_object_new(Main *bmain, Scene *scene, SceneLayer *sl, Ob
return ob;
}
-static int add_hook_object(Main *bmain, Scene *scene, SceneLayer *sl, Object *obedit, Object *ob, int mode, ReportList *reports)
+static int add_hook_object(const bContext *C, Main *bmain, Scene *scene, SceneLayer *sl, Object *obedit, Object *ob, int mode, ReportList *reports)
{
ModifierData *md = NULL;
HookModifierData *hmd = NULL;
+ EvaluationContext eval_ctx;
float cent[3];
float pose_mat[4][4];
int tot, ok, *indexar;
char name[MAX_NAME];
+ CTX_data_eval_ctx(C, &eval_ctx);
+
ok = object_hook_index_array(scene, obedit, &tot, &indexar, name, cent);
if (!ok) {
@@ -544,7 +547,7 @@ static int add_hook_object(Main *bmain, Scene *scene, SceneLayer *sl, Object *ob
/* matrix calculus */
/* vert x (obmat x hook->imat) x hook->obmat x ob->imat */
/* (parentinv ) */
- BKE_object_where_is_calc(scene, ob);
+ BKE_object_where_is_calc(&eval_ctx, scene, ob);
invert_m4_m4(ob->imat, ob->obmat);
/* apparently this call goes from right to left... */
@@ -584,7 +587,7 @@ static int object_add_hook_selob_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- if (add_hook_object(bmain, scene, sl, obedit, obsel, mode, op->reports)) {
+ if (add_hook_object(C, bmain, scene, sl, obedit, obsel, mode, op->reports)) {
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, obedit);
return OPERATOR_FINISHED;
}
@@ -618,7 +621,7 @@ static int object_add_hook_newob_exec(bContext *C, wmOperator *op)
SceneLayer *sl = CTX_data_scene_layer(C);
Object *obedit = CTX_data_edit_object(C);
- if (add_hook_object(bmain, scene, sl, obedit, NULL, OBJECT_ADDHOOK_NEWOB, op->reports)) {
+ if (add_hook_object(C, bmain, scene, sl, obedit, NULL, OBJECT_ADDHOOK_NEWOB, op->reports)) {
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, obedit);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h
index f6fb3cc75b8..3e655fa04a4 100644
--- a/source/blender/editors/object/object_intern.h
+++ b/source/blender/editors/object/object_intern.h
@@ -55,6 +55,7 @@ void OBJECT_OT_scale_clear(struct wmOperatorType *ot);
void OBJECT_OT_origin_clear(struct wmOperatorType *ot);
void OBJECT_OT_visual_transform_apply(struct wmOperatorType *ot);
void OBJECT_OT_transform_apply(struct wmOperatorType *ot);
+void OBJECT_OT_transform_axis_target(struct wmOperatorType *ot);
void OBJECT_OT_origin_set(struct wmOperatorType *ot);
/* object_relations.c */
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 85751fd64de..6e70734db19 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -522,9 +522,12 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene *
return 1;
}
-static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, ModifierData *md)
+static int modifier_apply_shape(ReportList *reports, const bContext *C, Scene *scene, Object *ob, ModifierData *md)
{
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
+ EvaluationContext eval_ctx;
+
+ CTX_data_eval_ctx(C, &eval_ctx);
md->scene = scene;
@@ -555,7 +558,7 @@ static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, M
return 0;
}
- dm = mesh_create_derived_for_modifier(scene, ob, md, 0);
+ dm = mesh_create_derived_for_modifier(&eval_ctx, scene, ob, md, 0);
if (!dm) {
BKE_report(reports, RPT_ERROR, "Modifier is disabled or returned error, skipping apply");
return 0;
@@ -582,9 +585,12 @@ static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, M
return 1;
}
-static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, ModifierData *md)
+static int modifier_apply_obdata(ReportList *reports, const bContext *C, Scene *scene, Object *ob, ModifierData *md)
{
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
+ EvaluationContext eval_ctx;
+
+ CTX_data_eval_ctx(C, &eval_ctx);
md->scene = scene;
@@ -608,13 +614,13 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob,
multires_force_update(ob);
if (mmd && mmd->totlvl && mti->type == eModifierTypeType_OnlyDeform) {
- if (!multiresModifier_reshapeFromDeformMod(scene, mmd, ob, md)) {
+ if (!multiresModifier_reshapeFromDeformMod(&eval_ctx, scene, mmd, ob, md)) {
BKE_report(reports, RPT_ERROR, "Multires modifier returned error, skipping apply");
return 0;
}
}
else {
- dm = mesh_create_derived_for_modifier(scene, ob, md, 1);
+ dm = mesh_create_derived_for_modifier(&eval_ctx, scene, ob, md, 1);
if (!dm) {
BKE_report(reports, RPT_ERROR, "Modifier returned error, skipping apply");
return 0;
@@ -640,7 +646,7 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob,
BKE_report(reports, RPT_INFO, "Applied modifier only changed CV points, not tessellated/bevel vertices");
vertexCos = BKE_curve_nurbs_vertexCos_get(&cu->nurb, &numVerts);
- mti->deformVerts(md, ob, NULL, vertexCos, numVerts, 0);
+ mti->deformVerts(md, &eval_ctx, ob, NULL, vertexCos, numVerts, 0);
BK_curve_nurbs_vertexCos_apply(&cu->nurb, vertexCos);
MEM_freeN(vertexCos);
@@ -662,14 +668,14 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob,
if (psys->part->type != PART_HAIR)
continue;
- psys_apply_hair_lattice(scene, ob, psys);
+ psys_apply_hair_lattice(&eval_ctx, scene, ob, psys);
}
}
return 1;
}
-int ED_object_modifier_apply(ReportList *reports, Scene *scene, Object *ob, ModifierData *md, int mode)
+int ED_object_modifier_apply(ReportList *reports, const bContext *C, Scene *scene, Object *ob, ModifierData *md, int mode)
{
int prev_mode;
@@ -697,13 +703,13 @@ int ED_object_modifier_apply(ReportList *reports, Scene *scene, Object *ob, Modi
md->mode |= eModifierMode_Realtime;
if (mode == MODIFIER_APPLY_SHAPE) {
- if (!modifier_apply_shape(reports, scene, ob, md)) {
+ if (!modifier_apply_shape(reports, C, scene, ob, md)) {
md->mode = prev_mode;
return 0;
}
}
else {
- if (!modifier_apply_obdata(reports, scene, ob, md)) {
+ if (!modifier_apply_obdata(reports, C, scene, ob, md)) {
md->mode = prev_mode;
return 0;
}
@@ -1003,7 +1009,7 @@ static int modifier_apply_exec(bContext *C, wmOperator *op)
ModifierData *md = edit_modifier_property_get(op, ob, 0);
int apply_as = RNA_enum_get(op->ptr, "apply_as");
- if (!md || !ED_object_modifier_apply(op->reports, scene, ob, md, apply_as)) {
+ if (!md || !ED_object_modifier_apply(op->reports, C, scene, ob, md, apply_as)) {
return OPERATOR_CANCELLED;
}
@@ -1230,8 +1236,11 @@ static int multires_reshape_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_active_context(C), *secondob = NULL;
Scene *scene = CTX_data_scene(C);
+ EvaluationContext eval_ctx;
MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires);
+ CTX_data_eval_ctx(C, &eval_ctx);
+
if (!mmd)
return OPERATOR_CANCELLED;
@@ -1254,7 +1263,7 @@ static int multires_reshape_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- if (!multiresModifier_reshape(scene, mmd, ob, secondob)) {
+ if (!multiresModifier_reshape(&eval_ctx, scene, mmd, ob, secondob)) {
BKE_report(op->reports, RPT_ERROR, "Objects do not have the same number of vertices");
return OPERATOR_CANCELLED;
}
@@ -1687,8 +1696,10 @@ static void skin_armature_bone_create(Object *skin_ob,
}
}
-static Object *modifier_skin_armature_create(Main *bmain, Scene *scene, SceneLayer *sl, Object *skin_ob)
+static Object *modifier_skin_armature_create(const bContext *C, Scene *scene, SceneLayer *sl, Object *skin_ob)
{
+ Main *bmain = CTX_data_main(C);
+ EvaluationContext eval_ctx;
BLI_bitmap *edges_visited;
DerivedMesh *deform_dm;
MVert *mvert;
@@ -1700,7 +1711,9 @@ static Object *modifier_skin_armature_create(Main *bmain, Scene *scene, SceneLay
int *emap_mem;
int v;
- deform_dm = mesh_get_derived_deform(scene, skin_ob, CD_MASK_BAREMESH);
+ CTX_data_eval_ctx(C, &eval_ctx);
+
+ deform_dm = mesh_get_derived_deform(&eval_ctx, scene, skin_ob, CD_MASK_BAREMESH);
mvert = deform_dm->getVertArray(deform_dm);
/* add vertex weights to original mesh */
@@ -1781,7 +1794,7 @@ static int skin_armature_create_exec(bContext *C, wmOperator *op)
}
/* create new armature */
- arm_ob = modifier_skin_armature_create(bmain, scene, sl, ob);
+ arm_ob = modifier_skin_armature_create(C, scene, sl, ob);
/* add a modifier to connect the new armature to the mesh */
arm_md = (ArmatureModifierData *)modifier_new(eModifierType_Armature);
@@ -1901,8 +1914,11 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Object *ob = ED_object_active_context(C);
+ EvaluationContext eval_ctx;
MeshDeformModifierData *mmd = (MeshDeformModifierData *)edit_modifier_property_get(op, ob, eModifierType_MeshDeform);
+ CTX_data_eval_ctx(C, &eval_ctx);
+
if (!mmd)
return OPERATOR_CANCELLED;
@@ -1940,17 +1956,17 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op)
mmd->modifier.mode |= eModifierMode_Realtime;
if (ob->type == OB_MESH) {
- dm = mesh_create_derived_view(scene, ob, 0);
+ dm = mesh_create_derived_view(&eval_ctx, scene, ob, 0);
dm->release(dm);
}
else if (ob->type == OB_LATTICE) {
- BKE_lattice_modifiers_calc(scene, ob);
+ BKE_lattice_modifiers_calc(&eval_ctx, scene, ob);
}
else if (ob->type == OB_MBALL) {
- BKE_displist_make_mball(CTX_data_main(C)->eval_ctx, scene, ob);
+ BKE_displist_make_mball(&eval_ctx, scene, ob);
}
else if (ELEM(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
- BKE_displist_make_curveTypes(scene, ob, 0);
+ BKE_displist_make_curveTypes(&eval_ctx, scene, ob, 0);
}
mmd->bindfunc = NULL;
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index ca02457ba39..07922f2d3b2 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -61,6 +61,7 @@ void ED_operatortypes_object(void)
WM_operatortype_append(OBJECT_OT_origin_clear);
WM_operatortype_append(OBJECT_OT_visual_transform_apply);
WM_operatortype_append(OBJECT_OT_transform_apply);
+ WM_operatortype_append(OBJECT_OT_transform_axis_target);
WM_operatortype_append(OBJECT_OT_origin_set);
WM_operatortype_append(OBJECT_OT_mode_set);
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 333bcf00a8c..c255ce4a45a 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -129,6 +129,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
SceneLayer *sl = CTX_data_scene_layer(C);
Object *obedit = CTX_data_edit_object(C);
+ EvaluationContext eval_ctx;
BMVert *eve;
BMIter iter;
Curve *cu;
@@ -138,6 +139,8 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
Object *par;
int a, v1 = 0, v2 = 0, v3 = 0, v4 = 0, nr = 1;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
/* we need 1 to 3 selected vertices */
if (obedit->type == OB_MESH) {
@@ -156,7 +159,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
/* derivedMesh might be needed for solving parenting,
* so re-create it here */
- makeDerivedMesh(scene, obedit, em, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX, false);
+ makeDerivedMesh(&eval_ctx, scene, obedit, em, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX, false);
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
@@ -244,7 +247,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
else {
Object workob;
- ob->parent = BASACT_NEW->object;
+ ob->parent = BASACT_NEW(sl)->object;
if (v3) {
ob->partype = PARVERT3;
ob->par1 = v1 - 1;
@@ -252,7 +255,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
ob->par3 = v3 - 1;
/* inverse parent matrix */
- BKE_object_workob_calc_parent(scene, ob, &workob);
+ BKE_object_workob_calc_parent(&eval_ctx, scene, ob, &workob);
invert_m4_m4(ob->parentinv, workob.obmat);
}
else {
@@ -260,7 +263,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
ob->par1 = v1 - 1;
/* inverse parent matrix */
- BKE_object_workob_calc_parent(scene, ob, &workob);
+ BKE_object_workob_calc_parent(&eval_ctx, scene, ob, &workob);
invert_m4_m4(ob->parentinv, workob.obmat);
}
}
@@ -351,7 +354,7 @@ static int make_proxy_exec(bContext *C, wmOperator *op)
if (ob) {
Object *newob;
- BaseLegacy *newbase, *oldbase = BASACT_NEW;
+ BaseLegacy *newbase, *oldbase = BASACT_NEW(sl);
char name[MAX_ID_NAME + 4];
BLI_snprintf(name, sizeof(name), "%s_proxy", ((ID *)(gob ? gob : ob))->name + 2);
@@ -360,7 +363,7 @@ static int make_proxy_exec(bContext *C, wmOperator *op)
newob = BKE_object_add(bmain, scene, sl, OB_EMPTY, name);
/* set layers OK */
- newbase = BASACT_NEW; /* BKE_object_add sets active... */
+ newbase = BASACT_NEW(sl); /* BKE_object_add sets active... */
newbase->lay = oldbase->lay;
newob->lay = newbase->lay;
@@ -612,12 +615,16 @@ EnumPropertyItem prop_make_parent_types[] = {
{0, NULL, 0, NULL, NULL}
};
-bool ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object *ob, Object *par,
+bool ED_object_parent_set(ReportList *reports, const bContext *C, Scene *scene, Object *ob, Object *par,
int partype, const bool xmirror, const bool keep_transform, const int vert_par[3])
{
+ Main *bmain = CTX_data_main(C);
+ EvaluationContext eval_ctx;
bPoseChannel *pchan = NULL;
const bool pararm = ELEM(partype, PAR_ARMATURE, PAR_ARMATURE_NAME, PAR_ARMATURE_ENVELOPE, PAR_ARMATURE_AUTO);
+ CTX_data_eval_ctx(C, &eval_ctx);
+
DEG_id_tag_update(&par->id, OB_RECALC_OB);
/* preconditions */
@@ -629,7 +636,7 @@ bool ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object
if ((cu->flag & CU_PATH) == 0) {
cu->flag |= CU_PATH | CU_FOLLOW;
- BKE_displist_make_curveTypes(scene, par, 0); /* force creation of path data */
+ BKE_displist_make_curveTypes(&eval_ctx, scene, par, 0); /* force creation of path data */
}
else {
cu->flag |= CU_FOLLOW;
@@ -771,30 +778,32 @@ bool ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object
data = con->data;
data->tar = par;
- BKE_constraint_target_matrix_get(scene, con, 0, CONSTRAINT_OBTYPE_OBJECT, NULL, cmat, scene->r.cfra);
+ BKE_constraint_target_matrix_get(&eval_ctx, scene, con, 0, CONSTRAINT_OBTYPE_OBJECT, NULL, cmat, scene->r.cfra);
sub_v3_v3v3(vec, ob->obmat[3], cmat[3]);
copy_v3_v3(ob->loc, vec);
}
else if (pararm && (ob->type == OB_MESH) && (par->type == OB_ARMATURE)) {
- if (partype == PAR_ARMATURE_NAME)
- create_vgroups_from_armature(reports, scene, ob, par, ARM_GROUPS_NAME, false);
- else if (partype == PAR_ARMATURE_ENVELOPE)
- create_vgroups_from_armature(reports, scene, ob, par, ARM_GROUPS_ENVELOPE, xmirror);
+ if (partype == PAR_ARMATURE_NAME) {
+ create_vgroups_from_armature(reports, &eval_ctx, scene, ob, par, ARM_GROUPS_NAME, false);
+ }
+ else if (partype == PAR_ARMATURE_ENVELOPE) {
+ create_vgroups_from_armature(reports, &eval_ctx, scene, ob, par, ARM_GROUPS_ENVELOPE, xmirror);
+ }
else if (partype == PAR_ARMATURE_AUTO) {
WM_cursor_wait(1);
- create_vgroups_from_armature(reports, scene, ob, par, ARM_GROUPS_AUTO, xmirror);
+ create_vgroups_from_armature(reports, &eval_ctx, scene, ob, par, ARM_GROUPS_AUTO, xmirror);
WM_cursor_wait(0);
}
/* get corrected inverse */
ob->partype = PAROBJECT;
- BKE_object_workob_calc_parent(scene, ob, &workob);
+ BKE_object_workob_calc_parent(&eval_ctx, scene, ob, &workob);
invert_m4_m4(ob->parentinv, workob.obmat);
}
else {
/* calculate inverse parent matrix */
- BKE_object_workob_calc_parent(scene, ob, &workob);
+ BKE_object_workob_calc_parent(&eval_ctx, scene, ob, &workob);
invert_m4_m4(ob->parentinv, workob.obmat);
}
@@ -869,7 +878,7 @@ static int parent_set_exec(bContext *C, wmOperator *op)
parent_set_vert_find(tree, ob, vert_par, is_tri);
}
- if (!ED_object_parent_set(op->reports, bmain, scene, ob, par, partype, xmirror, keep_transform, vert_par_p)) {
+ if (!ED_object_parent_set(op->reports, C, scene, ob, par, partype, xmirror, keep_transform, vert_par_p)) {
ok = false;
break;
}
@@ -1052,13 +1061,16 @@ void OBJECT_OT_parent_no_inverse_set(wmOperatorType *ot)
static int object_slow_parent_clear_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
+ EvaluationContext eval_ctx;
+
+ CTX_data_eval_ctx(C, &eval_ctx);
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
{
if (ob->parent) {
if (ob->partype & PARSLOW) {
ob->partype -= PARSLOW;
- BKE_object_where_is_calc(scene, ob);
+ BKE_object_where_is_calc(&eval_ctx, scene, ob);
ob->partype |= PARSLOW;
DEG_id_tag_update(&ob->id, OB_RECALC_OB);
}
@@ -1460,13 +1472,13 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
DEG_id_tag_update(&ob_dst->id, OB_RECALC_DATA);
break;
case MAKE_LINKS_ANIMDATA:
- BKE_animdata_copy_id((ID *)ob_dst, (ID *)ob_src, false);
+ BKE_animdata_copy_id(bmain, (ID *)ob_dst, (ID *)ob_src, false);
if (ob_dst->data && ob_src->data) {
if (ID_IS_LINKED_DATABLOCK(obdata_id)) {
is_lib = true;
break;
}
- BKE_animdata_copy_id((ID *)ob_dst->data, (ID *)ob_src->data, false);
+ BKE_animdata_copy_id(bmain, (ID *)ob_dst->data, (ID *)ob_src->data, false);
}
DEG_id_tag_update(&ob_dst->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
break;
@@ -2043,7 +2055,9 @@ void ED_object_single_users(Main *bmain, Scene *scene, const bool full, const bo
IDP_RelinkProperty(scene->gpd->id.properties);
}
- IDP_RelinkProperty(scene->world->id.properties);
+ if (scene->world) {
+ IDP_RelinkProperty(scene->world->id.properties);
+ }
if (scene->clip) {
IDP_RelinkProperty(scene->clip->id.properties);
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index 0a9b8b749f1..280294e714d 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -425,7 +425,7 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
}
- ob = OBACT_NEW;
+ ob = OBACT_NEW(sl);
if (ob == NULL) {
BKE_report(op->reports, RPT_ERROR, "No active object");
return OPERATOR_CANCELLED;
@@ -836,7 +836,7 @@ static int object_select_grouped_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
}
- ob = OBACT_NEW;
+ ob = OBACT_NEW(sl);
if (ob == NULL) {
BKE_report(op->reports, RPT_ERROR, "No active object");
return OPERATOR_CANCELLED;
@@ -940,13 +940,13 @@ static int object_select_all_exec(bContext *C, wmOperator *op)
{
switch (action) {
case SEL_SELECT:
- ED_object_base_select(base, BA_SELECT);
+ ED_object_base_select(base, BA_SELECT);
break;
case SEL_DESELECT:
- ED_object_base_select(base, BA_DESELECT);
+ ED_object_base_select(base, BA_DESELECT);
break;
case SEL_INVERT:
- if ((base->flag & BASE_SELECTED) != 0) {
+ if ((base->flag & BASE_SELECTED) != 0) {
ED_object_base_select(base, BA_DESELECT);
}
else {
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index 8733b3c1b06..944fbb0bbe1 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -39,10 +39,12 @@
#include "DNA_scene_types.h"
#include "DNA_group_types.h"
#include "DNA_lattice_types.h"
+#include "DNA_lamp_types.h"
#include "BLI_math.h"
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
+#include "BLI_array.h"
#include "BKE_context.h"
#include "BKE_curve.h"
@@ -72,6 +74,8 @@
#include "ED_screen.h"
#include "ED_view3d.h"
+#include "MEM_guardedalloc.h"
+
#include "object_intern.h"
/*************************** Clear Transformation ****************************/
@@ -400,27 +404,36 @@ void OBJECT_OT_origin_clear(wmOperatorType *ot)
/* use this when the loc/size/rot of the parent has changed but the children
* should stay in the same place, e.g. for apply-size-rot or object center */
-static void ignore_parent_tx(Main *bmain, Scene *scene, Object *ob)
+static void ignore_parent_tx(const bContext *C, Main *bmain, Scene *scene, Object *ob)
{
Object workob;
Object *ob_child;
+ EvaluationContext eval_ctx;
+
+ CTX_data_eval_ctx(C, &eval_ctx);
/* a change was made, adjust the children to compensate */
for (ob_child = bmain->object.first; ob_child; ob_child = ob_child->id.next) {
if (ob_child->parent == ob) {
BKE_object_apply_mat4(ob_child, ob_child->obmat, true, false);
- BKE_object_workob_calc_parent(scene, ob_child, &workob);
+ BKE_object_workob_calc_parent(&eval_ctx, scene, ob_child, &workob);
invert_m4_m4(ob_child->parentinv, workob.obmat);
}
}
}
-static int apply_objects_internal(bContext *C, ReportList *reports, bool apply_loc, bool apply_rot, bool apply_scale)
+static int apply_objects_internal(
+ bContext *C, ReportList *reports,
+ bool apply_loc, bool apply_rot, bool apply_scale,
+ bool do_props)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
+ EvaluationContext eval_ctx;
float rsmat[3][3], obmat[3][3], iobmat[3][3], mat[4][4], scale;
bool changed = true;
+
+ CTX_data_eval_ctx(C, &eval_ctx);
/* first check if we can execute */
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
@@ -523,7 +536,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, bool apply_l
Mesh *me = ob->data;
if (apply_scale)
- multiresModifier_scale_disp(scene, ob);
+ multiresModifier_scale_disp(&eval_ctx, scene, ob);
/* adjust data */
BKE_mesh_transform(me, mat, true);
@@ -532,7 +545,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, bool apply_l
BKE_mesh_calc_normals(me);
}
else if (ob->type == OB_ARMATURE) {
- ED_armature_apply_transform(ob, mat);
+ ED_armature_apply_transform(ob, mat, do_props);
}
else if (ob->type == OB_LATTICE) {
Lattice *lt = ob->data;
@@ -541,12 +554,12 @@ static int apply_objects_internal(bContext *C, ReportList *reports, bool apply_l
}
else if (ob->type == OB_MBALL) {
MetaBall *mb = ob->data;
- BKE_mball_transform(mb, mat);
+ BKE_mball_transform(mb, mat, do_props);
}
else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
Curve *cu = ob->data;
scale = mat3_to_scale(rsmat);
- BKE_curve_transform_ex(cu, mat, true, scale);
+ BKE_curve_transform_ex(cu, mat, true, do_props, scale);
}
else if (ob->type == OB_FONT) {
Curve *cu = ob->data;
@@ -562,7 +575,9 @@ static int apply_objects_internal(bContext *C, ReportList *reports, bool apply_l
tb->h *= scale;
}
- cu->fsize *= scale;
+ if (do_props) {
+ cu->fsize *= scale;
+ }
}
else if (ob->type == OB_CAMERA) {
MovieClip *clip = BKE_object_movieclip_get(scene, ob, false);
@@ -611,12 +626,12 @@ static int apply_objects_internal(bContext *C, ReportList *reports, bool apply_l
unit_axis_angle(ob->rotAxis, &ob->rotAngle);
}
- BKE_object_where_is_calc(scene, ob);
+ BKE_object_where_is_calc(&eval_ctx, scene, ob);
if (ob->type == OB_ARMATURE) {
- BKE_pose_where_is(scene, ob); /* needed for bone parents */
+ BKE_pose_where_is(&eval_ctx, scene, ob); /* needed for bone parents */
}
- ignore_parent_tx(bmain, scene, ob);
+ ignore_parent_tx(C, bmain, scene, ob);
DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA);
@@ -636,13 +651,16 @@ static int apply_objects_internal(bContext *C, ReportList *reports, bool apply_l
static int visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
+ EvaluationContext eval_ctx;
bool changed = false;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
{
- BKE_object_where_is_calc(scene, ob);
+ BKE_object_where_is_calc(&eval_ctx, scene, ob);
BKE_object_apply_mat4(ob, ob->obmat, true, true);
- BKE_object_where_is_calc(scene, ob);
+ BKE_object_where_is_calc(&eval_ctx, scene, ob);
/* update for any children that may get moved */
DEG_id_tag_update(&ob->id, OB_RECALC_OB);
@@ -678,9 +696,10 @@ static int object_transform_apply_exec(bContext *C, wmOperator *op)
const bool loc = RNA_boolean_get(op->ptr, "location");
const bool rot = RNA_boolean_get(op->ptr, "rotation");
const bool sca = RNA_boolean_get(op->ptr, "scale");
+ const bool do_props = RNA_boolean_get(op->ptr, "properties");
if (loc || rot || sca) {
- return apply_objects_internal(C, op->reports, loc, rot, sca);
+ return apply_objects_internal(C, op->reports, loc, rot, sca, do_props);
}
else {
/* allow for redo */
@@ -705,6 +724,8 @@ void OBJECT_OT_transform_apply(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "location", 0, "Location", "");
RNA_def_boolean(ot->srna, "rotation", 0, "Rotation", "");
RNA_def_boolean(ot->srna, "scale", 0, "Scale", "");
+ RNA_def_boolean(ot->srna, "properties", true, "Apply Properties",
+ "Modify properties such as curve vertex radius, font size and bone envelope");
}
/********************* Set Object Center ************************/
@@ -713,7 +734,8 @@ enum {
GEOMETRY_TO_ORIGIN = 0,
ORIGIN_TO_GEOMETRY,
ORIGIN_TO_CURSOR,
- ORIGIN_TO_CENTER_OF_MASS
+ ORIGIN_TO_CENTER_OF_MASS_SURFACE,
+ ORIGIN_TO_CENTER_OF_MASS_VOLUME,
};
static int object_origin_set_exec(bContext *C, wmOperator *op)
@@ -722,6 +744,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
Object *obact = CTX_data_active_object(C);
Object *obedit = CTX_data_edit_object(C);
+ EvaluationContext eval_ctx;
Object *tob;
float cursor[3], cent[3], cent_neg[3], centn[3];
int centermode = RNA_enum_get(op->ptr, "type");
@@ -731,6 +754,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
CollectionPointerLink *ctx_ob;
CollectionPointerLink *ctx_ob_act = NULL;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
/* keep track of what is changed */
int tot_change = 0, tot_lib_error = 0, tot_multiuser_arm_error = 0;
@@ -867,10 +892,21 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
if (obedit == NULL && ob->type == OB_MESH) {
Mesh *me = ob->data;
- if (centermode == ORIGIN_TO_CURSOR) { /* done */ }
- else if (centermode == ORIGIN_TO_CENTER_OF_MASS) { BKE_mesh_center_centroid(me, cent); }
- else if (around == V3D_AROUND_CENTER_MEAN) { BKE_mesh_center_median(me, cent); }
- else { BKE_mesh_center_bounds(me, cent); }
+ if (centermode == ORIGIN_TO_CURSOR) {
+ /* done */
+ }
+ else if (centermode == ORIGIN_TO_CENTER_OF_MASS_SURFACE) {
+ BKE_mesh_center_of_surface(me, cent);
+ }
+ else if (centermode == ORIGIN_TO_CENTER_OF_MASS_VOLUME) {
+ BKE_mesh_center_of_volume(me, cent);
+ }
+ else if (around == V3D_AROUND_CENTER_MEAN) {
+ BKE_mesh_center_median(me, cent);
+ }
+ else {
+ BKE_mesh_center_bounds(me, cent);
+ }
negate_v3_v3(cent_neg, cent);
BKE_mesh_translate(me, cent_neg, 1);
@@ -924,8 +960,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
cent[2] = 0.0f;
- cu->xof = cu->xof - (cent[0] / cu->fsize);
- cu->yof = cu->yof - (cent[1] / cu->fsize);
+ cu->xof = cu->xof - cent[0];
+ cu->yof = cu->yof - cent[1];
tot_change++;
cu->id.tag |= LIB_TAG_DOIT;
@@ -952,10 +988,10 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
arm->id.tag |= LIB_TAG_DOIT;
/* do_inverse_offset = true; */ /* docenter_armature() handles this */
- BKE_object_where_is_calc(scene, ob);
- BKE_pose_where_is(scene, ob); /* needed for bone parents */
+ BKE_object_where_is_calc(&eval_ctx, scene, ob);
+ BKE_pose_where_is(&eval_ctx, scene, ob); /* needed for bone parents */
- ignore_parent_tx(bmain, scene, ob);
+ ignore_parent_tx(C, bmain, scene, ob);
if (obedit)
break;
@@ -1011,12 +1047,12 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
add_v3_v3(ob->loc, centn);
- BKE_object_where_is_calc(scene, ob);
+ BKE_object_where_is_calc(&eval_ctx, scene, ob);
if (ob->type == OB_ARMATURE) {
- BKE_pose_where_is(scene, ob); /* needed for bone parents */
+ BKE_pose_where_is(&eval_ctx, scene, ob); /* needed for bone parents */
}
- ignore_parent_tx(bmain, scene, ob);
+ ignore_parent_tx(C, bmain, scene, ob);
/* other users? */
//CTX_DATA_BEGIN (C, Object *, ob_other, selected_editable_objects)
@@ -1040,11 +1076,11 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
mul_v3_mat3_m4v3(centn, ob_other->obmat, cent); /* omit translation part */
add_v3_v3(ob_other->loc, centn);
- BKE_object_where_is_calc(scene, ob_other);
+ BKE_object_where_is_calc(&eval_ctx, scene, ob_other);
if (ob_other->type == OB_ARMATURE) {
- BKE_pose_where_is(scene, ob_other); /* needed for bone parents */
+ BKE_pose_where_is(&eval_ctx, scene, ob_other); /* needed for bone parents */
}
- ignore_parent_tx(bmain, scene, ob_other);
+ ignore_parent_tx(C, bmain, scene, ob_other);
}
}
//CTX_DATA_END;
@@ -1053,9 +1089,12 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
}
BLI_freelistN(&ctx_data_list);
- for (tob = bmain->object.first; tob; tob = tob->id.next)
- if (tob->data && (((ID *)tob->data)->tag & LIB_TAG_DOIT))
+ for (tob = bmain->object.first; tob; tob = tob->id.next) {
+ if (tob->data && (((ID *)tob->data)->tag & LIB_TAG_DOIT)) {
+ BKE_mesh_batch_cache_dirty(tob->data, BKE_MESH_BATCH_DIRTY_ALL);
DEG_id_tag_update(&tob->id, OB_RECALC_OB | OB_RECALC_DATA);
+ }
+ }
if (tot_change) {
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
@@ -1078,11 +1117,14 @@ void OBJECT_OT_origin_set(wmOperatorType *ot)
static EnumPropertyItem prop_set_center_types[] = {
{GEOMETRY_TO_ORIGIN, "GEOMETRY_ORIGIN", 0, "Geometry to Origin", "Move object geometry to object origin"},
{ORIGIN_TO_GEOMETRY, "ORIGIN_GEOMETRY", 0, "Origin to Geometry",
- "Move object origin to center of object geometry"},
+ "Calculate the center of geometry based on the current pivot point (median, otherwise bounding-box)"},
{ORIGIN_TO_CURSOR, "ORIGIN_CURSOR", 0, "Origin to 3D Cursor",
- "Move object origin to position of the 3D cursor"},
- {ORIGIN_TO_CENTER_OF_MASS, "ORIGIN_CENTER_OF_MASS", 0, "Origin to Center of Mass",
- "Move object origin to the object center of mass (assuming uniform density)"},
+ "Move object origin to position of the 3D cursor"},
+ /* Intentional naming mismatch since some scripts refer to this. */
+ {ORIGIN_TO_CENTER_OF_MASS_SURFACE, "ORIGIN_CENTER_OF_MASS", 0, "Origin to Center of Mass (Surface)",
+ "Calculate the center of mass from the surface area"},
+ {ORIGIN_TO_CENTER_OF_MASS_VOLUME, "ORIGIN_CENTER_OF_VOLUME", 0, "Origin to Center of Mass (Volume)",
+ "Calculate the center of mass from the volume (must be manifold geometry with consistent normals)"},
{0, NULL, 0, NULL, NULL}
};
@@ -1109,3 +1151,389 @@ void OBJECT_OT_origin_set(wmOperatorType *ot)
ot->prop = RNA_def_enum(ot->srna, "type", prop_set_center_types, 0, "Type", "");
RNA_def_enum(ot->srna, "center", prop_set_bounds_types, V3D_AROUND_CENTER_MEAN, "Center", "");
}
+
+/* -------------------------------------------------------------------- */
+
+/** \name Transform Axis Target
+ *
+ * Note this is an experemental operator to point lamps/cameras at objects.
+ * We may re-work how this behaves based on user feedback.
+ * - campbell.
+ * \{ */
+
+/* When using multiple objects, apply their relative rotational offset to the active object. */
+#define USE_RELATIVE_ROTATION
+
+struct XFormAxisItem {
+ Object *ob;
+ float rot_mat[3][3];
+ void *obtfm;
+ float xform_dist;
+
+#ifdef USE_RELATIVE_ROTATION
+ /* use when translating multiple */
+ float xform_rot_offset[3][3];
+#endif
+};
+
+struct XFormAxisData {
+ ViewContext vc;
+ struct {
+ float depth;
+ float normal[3];
+ bool is_depth_valid;
+ bool is_normal_valid;
+ } prev;
+
+ struct XFormAxisItem *object_data;
+ uint object_data_len;
+ bool is_translate;
+
+ int init_event;
+};
+
+static bool object_is_target_compat(const Object *ob)
+{
+ if (ob->type == OB_LAMP) {
+ const Lamp *la = ob->data;
+ if (ELEM(la->type, LA_SUN, LA_SPOT, LA_HEMI, LA_AREA)) {
+ return true;
+ }
+ }
+ /* We might want to enable this later, for now just lamps */
+#if 0
+ else if (ob->type == OB_CAMERA) {
+ return true;
+ }
+#endif
+ return false;
+}
+
+static void object_transform_axis_target_free_data(wmOperator *op)
+{
+ struct XFormAxisData *xfd = op->customdata;
+ struct XFormAxisItem *item = xfd->object_data;
+ for (int i = 0; i < xfd->object_data_len; i++, item++) {
+ MEM_freeN(item->obtfm);
+ }
+ MEM_freeN(xfd->object_data);
+ MEM_freeN(xfd);
+ op->customdata = NULL;
+}
+
+/* We may want to expose as alternative to: BKE_object_apply_rotation */
+static void object_apply_rotation(Object *ob, const float rmat[3][3])
+{
+ float size[3];
+ float loc[3];
+ float rmat4[4][4];
+ copy_m4_m3(rmat4, rmat);
+
+ copy_v3_v3(size, ob->size);
+ copy_v3_v3(loc, ob->loc);
+ BKE_object_apply_mat4(ob, rmat4, true, true);
+ copy_v3_v3(ob->size, size);
+ copy_v3_v3(ob->loc, loc);
+}
+/* We may want to extract this to: BKE_object_apply_location */
+static void object_apply_location(Object *ob, const float loc[3])
+{
+ /* quick but weak */
+ Object ob_prev = *ob;
+ float mat[4][4];
+ copy_m4_m4(mat, ob->obmat);
+ copy_v3_v3(mat[3], loc);
+ BKE_object_apply_mat4(ob, mat, true, true);
+ copy_v3_v3(mat[3], ob->loc);
+ *ob = ob_prev;
+ copy_v3_v3(ob->loc, mat[3]);
+}
+
+static void object_orient_to_location(
+ Object *ob, float rot_orig[3][3], const float axis[3], const float location[3])
+{
+ float delta[3];
+ sub_v3_v3v3(delta, ob->obmat[3], location);
+ if (normalize_v3(delta) != 0.0f) {
+ if (len_squared_v3v3(delta, axis) > FLT_EPSILON) {
+ float delta_rot[3][3];
+ float final_rot[3][3];
+ rotation_between_vecs_to_mat3(delta_rot, axis, delta);
+
+ mul_m3_m3m3(final_rot, delta_rot, rot_orig);
+
+ object_apply_rotation(ob, final_rot);
+
+ DEG_id_tag_update(&ob->id, OB_RECALC_OB);
+ }
+ }
+}
+
+static void object_transform_axis_target_cancel(bContext *C, wmOperator *op)
+{
+ struct XFormAxisData *xfd = op->customdata;
+ struct XFormAxisItem *item = xfd->object_data;
+ for (int i = 0; i < xfd->object_data_len; i++, item++) {
+ BKE_object_tfm_restore(item->ob, item->obtfm);
+ DEG_id_tag_update(&item->ob->id, OB_RECALC_OB);
+ WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, item->ob);
+ }
+
+ object_transform_axis_target_free_data(op);
+}
+
+static int object_transform_axis_target_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ ViewContext vc;
+ view3d_set_viewcontext(C, &vc);
+
+ if (!object_is_target_compat(vc.obact)) {
+ /* Falls back to texture space transform. */
+ return OPERATOR_PASS_THROUGH;
+ }
+
+ EvaluationContext eval_ctx;
+
+ CTX_data_eval_ctx(C, &eval_ctx);
+
+ ED_view3d_autodist_init(&eval_ctx, vc.depsgraph, vc.ar, vc.v3d, 0);
+
+ if (vc.rv3d->depths != NULL) {
+ vc.rv3d->depths->damaged = true;
+ }
+ ED_view3d_depth_update(vc.ar);
+
+ if (vc.rv3d->depths == NULL) {
+ BKE_report(op->reports, RPT_WARNING, "Unable to access depth buffer, using view plane");
+ return OPERATOR_CANCELLED;
+ }
+
+ ED_region_tag_redraw(vc.ar);
+
+ struct XFormAxisData *xfd;
+ xfd = op->customdata = MEM_callocN(sizeof(struct XFormAxisData), __func__);
+
+ /* Don't change this at runtime. */
+ xfd->vc = vc;
+ xfd->vc.mval[0] = event->mval[0];
+ xfd->vc.mval[1] = event->mval[1];
+
+ xfd->prev.depth = 1.0f;
+ xfd->prev.is_depth_valid = false;
+ xfd->prev.is_normal_valid = false;
+ xfd->is_translate = false;
+
+ xfd->init_event = WM_userdef_event_type_from_keymap_type(event->type);
+
+ {
+ struct XFormAxisItem *object_data = NULL;
+ BLI_array_declare(object_data);
+
+ struct XFormAxisItem *item = BLI_array_append_ret(object_data);
+ item->ob = xfd->vc.obact;
+
+ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
+ {
+ if ((ob != xfd->vc.obact) && object_is_target_compat(ob)) {
+ item = BLI_array_append_ret(object_data);
+ item->ob = ob;
+ }
+ }
+ CTX_DATA_END;
+
+ xfd->object_data = object_data;
+ xfd->object_data_len = BLI_array_count(object_data);
+
+ if (xfd->object_data_len != BLI_array_count(object_data)) {
+ xfd->object_data = MEM_reallocN(xfd->object_data, xfd->object_data_len * sizeof(*xfd->object_data));
+ }
+ }
+
+ {
+ struct XFormAxisItem *item = xfd->object_data;
+ for (int i = 0; i < xfd->object_data_len; i++, item++) {
+ item->obtfm = BKE_object_tfm_backup(item->ob);
+ BKE_object_rot_to_mat3(item->ob, item->rot_mat, true);
+ }
+ }
+
+ WM_event_add_modal_handler(C, op);
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+static int object_transform_axis_target_modal(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ struct XFormAxisData *xfd = op->customdata;
+ ARegion *ar = xfd->vc.ar;
+
+ view3d_operator_needs_opengl(C);
+
+ const bool is_translate = (event->ctrl != 0);
+ const bool is_translate_init = is_translate && (xfd->is_translate != is_translate);
+
+ if (event->type == MOUSEMOVE || is_translate_init) {
+ const ViewDepths *depths = xfd->vc.rv3d->depths;
+ if (depths &&
+ ((unsigned int)event->mval[0] < depths->w) &&
+ ((unsigned int)event->mval[1] < depths->h))
+ {
+ double depth = (double)ED_view3d_depth_read_cached(&xfd->vc, event->mval);
+ float location_world[3];
+ if (depth == 1.0f) {
+ if (xfd->prev.is_depth_valid) {
+ depth = (double)xfd->prev.depth;
+ }
+ }
+ if ((depth > depths->depth_range[0]) && (depth < depths->depth_range[1])) {
+ xfd->prev.depth = depth;
+ xfd->prev.is_depth_valid = true;
+ if (ED_view3d_depth_unproject(ar, event->mval, depth, location_world)) {
+ if (is_translate) {
+
+ float normal[3];
+ bool normal_found = false;
+ if (ED_view3d_depth_read_cached_normal(&xfd->vc, event->mval, normal)) {
+ normal_found = true;
+
+ /* cheap attempt to smooth normals out a bit! */
+ const uint ofs = 2;
+ for (uint x = -ofs; x <= ofs; x += ofs / 2) {
+ for (uint y = -ofs; y <= ofs; y += ofs / 2) {
+ if (x != 0 && y != 0) {
+ int mval_ofs[2] = {event->mval[0] + x, event->mval[1] + y};
+ float n[3];
+ if (ED_view3d_depth_read_cached_normal(
+ &xfd->vc, mval_ofs, n))
+ {
+ add_v3_v3(normal, n);
+ }
+ }
+ }
+ }
+ normalize_v3(normal);
+ }
+ else if (xfd->prev.is_normal_valid) {
+ copy_v3_v3(normal, xfd->prev.normal);
+ normal_found = true;
+ }
+
+ if (normal_found) {
+#ifdef USE_RELATIVE_ROTATION
+ if (is_translate_init && xfd->object_data_len > 1) {
+ float xform_rot_offset_inv_first[3][3];
+ struct XFormAxisItem *item = xfd->object_data;
+ for (int i = 0; i < xfd->object_data_len; i++, item++) {
+ copy_m3_m4(item->xform_rot_offset, item->ob->obmat);
+ normalize_m3(item->xform_rot_offset);
+
+ if (i == 0) {
+ invert_m3_m3(xform_rot_offset_inv_first, xfd->object_data[0].xform_rot_offset);
+ }
+ else {
+ mul_m3_m3m3(item->xform_rot_offset,
+ item->xform_rot_offset,
+ xform_rot_offset_inv_first);
+ }
+ }
+ }
+
+#endif
+
+ struct XFormAxisItem *item = xfd->object_data;
+ for (int i = 0; i < xfd->object_data_len; i++, item++) {
+ if (is_translate_init) {
+ float ob_axis[3];
+ item->xform_dist = len_v3v3(item->ob->obmat[3], location_world);
+ normalize_v3_v3(ob_axis, item->ob->obmat[2]);
+ /* Scale to avoid adding distance when moving between surfaces. */
+ float scale = fabsf(dot_v3v3(ob_axis, normal));
+ item->xform_dist *= scale;
+ }
+
+ float target_normal[3];
+ copy_v3_v3(target_normal, normal);
+
+#ifdef USE_RELATIVE_ROTATION
+ if (i != 0) {
+ mul_m3_v3(item->xform_rot_offset, target_normal);
+ }
+#endif
+ {
+ float loc[3];
+
+ copy_v3_v3(loc, location_world);
+ madd_v3_v3fl(loc, target_normal, item->xform_dist);
+ object_apply_location(item->ob, loc);
+ copy_v3_v3(item->ob->obmat[3], loc); /* so orient behaves as expected */
+ }
+
+ object_orient_to_location(item->ob, item->rot_mat, item->rot_mat[2], location_world);
+ WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, item->ob);
+ }
+ copy_v3_v3(xfd->prev.normal, normal);
+ xfd->prev.is_normal_valid = true;
+ }
+ }
+ else {
+ struct XFormAxisItem *item = xfd->object_data;
+ for (int i = 0; i < xfd->object_data_len; i++, item++) {
+ object_orient_to_location(item->ob, item->rot_mat, item->rot_mat[2], location_world);
+ WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, item->ob);
+ }
+ xfd->prev.is_normal_valid = false;
+ }
+ }
+ }
+ }
+ xfd->is_translate = is_translate;
+
+ ED_region_tag_redraw(xfd->vc.ar);
+ }
+
+ bool is_finished = false;
+
+ if (ISMOUSE(xfd->init_event)) {
+ if ((event->type == xfd->init_event) && (event->val == KM_RELEASE)) {
+ is_finished = true;
+ }
+ }
+ else {
+ if (ELEM(event->type, LEFTMOUSE, RETKEY, PADENTER)) {
+ is_finished = true;
+ }
+ }
+
+ if (is_finished) {
+ object_transform_axis_target_free_data(op);
+ return OPERATOR_FINISHED;
+ }
+ else if (ELEM(event->type, ESCKEY, RIGHTMOUSE)) {
+ object_transform_axis_target_cancel(C, op);
+ return OPERATOR_CANCELLED;
+ }
+
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+void OBJECT_OT_transform_axis_target(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Interactive Lamp Track to Cursor";
+ ot->description = "Interactively point cameras and lamps to a location (Ctrl translates)";
+ ot->idname = "OBJECT_OT_transform_axis_target";
+
+ /* api callbacks */
+ ot->invoke = object_transform_axis_target_invoke;
+ ot->cancel = object_transform_axis_target_cancel;
+ ot->modal = object_transform_axis_target_modal;
+ ot->poll = ED_operator_region_view3d_active;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
+}
+
+#undef USE_RELATIVE_ROTATION
+
+/** \} */
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index 51723ac14d3..386c63d4095 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -50,7 +50,7 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "BLI_linklist_stack.h"
-#include "BLI_stackdefines.h"
+#include "BLI_utildefines_stack.h"
#include "BKE_context.h"
@@ -240,6 +240,9 @@ bool ED_vgroup_parray_alloc(ID *id, MDeformVert ***dvert_arr, int *dvert_tot, co
}
return false;
}
+
+ default:
+ break;
}
}
@@ -1257,9 +1260,9 @@ static void dm_deform_clear(DerivedMesh *dm, Object *ob)
}
/* recalculate the deformation */
-static DerivedMesh *dm_deform_recalc(Scene *scene, Object *ob)
+static DerivedMesh *dm_deform_recalc(EvaluationContext *eval_ctx, Scene *scene, Object *ob)
{
- return mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
+ return mesh_get_derived_deform(eval_ctx, scene, ob, CD_MASK_BAREMESH);
}
/* by changing nonzero weights, try to move a vertex in me->mverts with index 'index' to
@@ -1271,7 +1274,7 @@ static DerivedMesh *dm_deform_recalc(Scene *scene, Object *ob)
* norm and d are the plane's properties for the equation: ax + by + cz + d = 0
* coord is a point on the plane
*/
-static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, int index, float norm[3],
+static void moveCloserToDistanceFromPlane(EvaluationContext *eval_ctx, Scene *scene, Object *ob, Mesh *me, int index, float norm[3],
float coord[3], float d, float distToBe, float strength, float cp)
{
DerivedMesh *dm;
@@ -1298,7 +1301,7 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in
float originalDistToBe = distToBe;
do {
wasChange = false;
- dm = dm_deform_recalc(scene, ob);
+ dm = dm_deform_recalc(eval_ctx, scene, ob);
dm->getVert(dm, index, &m);
copy_v3_v3(oldPos, m.co);
distToStart = dot_v3v3(norm, oldPos) + d;
@@ -1336,7 +1339,7 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in
if (dw->weight > 1) {
dw->weight = 1;
}
- dm = dm_deform_recalc(scene, ob);
+ dm = dm_deform_recalc(eval_ctx, scene, ob);
dm->getVert(dm, index, &m);
getVerticalAndHorizontalChange(norm, d, coord, oldPos, distToStart, m.co, changes, dists, i);
dw->weight = oldw;
@@ -1446,10 +1449,13 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in
/* this is used to try to smooth a surface by only adjusting the nonzero weights of a vertex
* but it could be used to raise or lower an existing 'bump.' */
-static void vgroup_fix(Scene *scene, Object *ob, float distToBe, float strength, float cp)
+static void vgroup_fix(const bContext *C, Scene *scene, Object *ob, float distToBe, float strength, float cp)
{
+ EvaluationContext eval_ctx;
int i;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
Mesh *me = ob->data;
MVert *mvert = me->mvert;
int *verts = NULL;
@@ -1463,7 +1469,7 @@ static void vgroup_fix(Scene *scene, Object *ob, float distToBe, float strength,
MVert *p = MEM_callocN(sizeof(MVert) * (count), "deformedPoints");
int k;
- DerivedMesh *dm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
+ DerivedMesh *dm = mesh_get_derived_deform(&eval_ctx, scene, ob, CD_MASK_BAREMESH);
k = count;
while (k--) {
dm->getVert(dm, verts[k], &m);
@@ -1481,7 +1487,7 @@ static void vgroup_fix(Scene *scene, Object *ob, float distToBe, float strength,
if (mag) { /* zeros fix */
d = -dot_v3v3(norm, coord);
/* dist = (dot_v3v3(norm, m.co) + d); */ /* UNUSED */
- moveCloserToDistanceFromPlane(scene, ob, me, i, norm, coord, d, distToBe, strength, cp);
+ moveCloserToDistanceFromPlane(&eval_ctx, scene, ob, me, i, norm, coord, d, distToBe, strength, cp);
}
}
@@ -1714,17 +1720,11 @@ static void vgroup_invert_subset(Object *ob,
}
}
-enum {
- WEIGHT_SMOOTH_ALL = -1,
- WEIGHT_SMOOTH_DESELECT = false,
- WEIGHT_SMOOTH_SELECT = true,
-};
-
static void vgroup_smooth_subset(
Object *ob, const bool *vgroup_validmap, const int vgroup_tot,
const int subset_count,
const float fac, const int repeat,
- const float fac_expand, const int source)
+ const float fac_expand)
{
const float ifac = 1.0f - fac;
MDeformVert **dvert_array = NULL;
@@ -1732,6 +1732,8 @@ static void vgroup_smooth_subset(
int *vgroup_subset_map = BLI_array_alloca(vgroup_subset_map, subset_count);
float *vgroup_subset_weights = BLI_array_alloca(vgroup_subset_weights, subset_count);
const bool use_mirror = (ob->type == OB_MESH) ? (((Mesh *)ob->data)->editflag & ME_EDIT_MIRROR_X) != 0 : false;
+ const bool use_select = vertex_group_use_vert_sel(ob);
+ const bool use_hide = use_select;
const int expand_sign = signum_i(fac_expand);
const float expand = fabsf(fac_expand);
@@ -1775,19 +1777,26 @@ static void vgroup_smooth_subset(
verts_used = MEM_mallocN(sizeof(*verts_used) * dvert_tot, __func__);
STACK_INIT(verts_used, dvert_tot);
+#define IS_BM_VERT_READ(v) \
+ (use_hide ? (BM_elem_flag_test(v, BM_ELEM_HIDDEN) == 0) : true)
+#define IS_BM_VERT_WRITE(v) \
+ (use_select ? (BM_elem_flag_test(v, BM_ELEM_SELECT) != 0) : true)
+
+#define IS_ME_VERT_READ(v) \
+ (use_hide ? (((v)->flag & ME_HIDE) == 0) : true)
+#define IS_ME_VERT_WRITE(v) \
+ (use_select ? (((v)->flag & SELECT) != 0) : true)
/* initialize used verts */
if (bm) {
for (int i = 0; i < dvert_tot; i++) {
BMVert *v = BM_vert_at_index(bm, i);
- if (BM_elem_flag_test(v, BM_ELEM_SELECT)) {
+ if (IS_BM_VERT_WRITE(v)) {
BMIter eiter;
BMEdge *e;
BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
BMVert *v_other = BM_edge_other_vert(e, v);
- if ((source == WEIGHT_SMOOTH_ALL) ||
- (source == (BM_elem_flag_test(v_other, BM_ELEM_SELECT) != 0)))
- {
+ if (IS_BM_VERT_READ(v_other)) {
STACK_PUSH(verts_used, i);
break;
}
@@ -1797,13 +1806,12 @@ static void vgroup_smooth_subset(
}
else {
for (int i = 0; i < dvert_tot; i++) {
- MVert *v = &me->mvert[i];
- if (v->flag & SELECT) {
+ const MVert *v = &me->mvert[i];
+ if (IS_ME_VERT_WRITE(v)) {
for (int j = 0; j < emap[i].count; j++) {
- MVert *v_other = &me->mvert[emap[i].indices[j]];
- if ((source == WEIGHT_SMOOTH_ALL) ||
- (source == ((v_other->flag & SELECT) != 0)))
- {
+ const MEdge *e = &me->medge[emap[i].indices[j]];
+ const MVert *v_other = &me->mvert[(e->v1 == i) ? e->v2 : e->v1];
+ if (IS_ME_VERT_READ(v_other)) {
STACK_PUSH(verts_used, i);
break;
}
@@ -1856,13 +1864,11 @@ static void vgroup_smooth_subset(
BMEdge *e;
/* checked already */
- BLI_assert(BM_elem_flag_test(v, BM_ELEM_SELECT));
+ BLI_assert(IS_BM_VERT_WRITE(v));
BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
BMVert *v_other = BM_edge_other_vert(e, v);
- if ((source == WEIGHT_SMOOTH_ALL) ||
- (source == (BM_elem_flag_test(v_other, BM_ELEM_SELECT) != 0)))
- {
+ if (IS_BM_VERT_READ(v_other)) {
const int i_other = BM_elem_index_get(v_other);
WEIGHT_ACCUMULATE;
@@ -1873,16 +1879,14 @@ static void vgroup_smooth_subset(
int j;
/* checked already */
- BLI_assert(me->mvert[i].flag & SELECT);
+ BLI_assert(IS_ME_VERT_WRITE(&me->mvert[i]));
for (j = 0; j < emap[i].count; j++) {
MEdge *e = &me->medge[emap[i].indices[j]];
const int i_other = (e->v1 == i ? e->v2 : e->v1);
MVert *v_other = &me->mvert[i_other];
- if ((source == WEIGHT_SMOOTH_ALL) ||
- (source == ((v_other->flag & SELECT) != 0)))
- {
+ if (IS_ME_VERT_READ(v_other)) {
WEIGHT_ACCUMULATE;
}
}
@@ -1906,6 +1910,11 @@ static void vgroup_smooth_subset(
ED_vgroup_parray_from_weight_array(dvert_array, dvert_tot, weight_accum_prev, def_nr, true);
}
+#undef IS_BM_VERT_READ
+#undef IS_BM_VERT_WRITE
+#undef IS_ME_VERT_READ
+#undef IS_ME_VERT_WRITE
+
MEM_freeN(weight_accum_curr);
MEM_freeN(weight_accum_prev);
MEM_freeN(verts_used);
@@ -2499,7 +2508,7 @@ static int UNUSED_FUNCTION(vertex_group_poll_edit) (bContext *C)
}
/* editmode _or_ weight paint vertex sel */
-static int vertex_group_vert_select_poll_ex(bContext *C, const short ob_type_flag)
+static int vertex_group_vert_poll_ex(bContext *C, const bool needs_select, const short ob_type_flag)
{
Object *ob = ED_object_context(C);
ID *data = (ob) ? ob->data : NULL;
@@ -2515,12 +2524,17 @@ static int vertex_group_vert_select_poll_ex(bContext *C, const short ob_type_fla
return true;
}
else if (ob->mode & OB_MODE_WEIGHT_PAINT) {
- if (BKE_object_is_in_wpaint_select_vert(ob)) {
- return true;
+ if (needs_select) {
+ if (BKE_object_is_in_wpaint_select_vert(ob)) {
+ return true;
+ }
+ else {
+ CTX_wm_operator_poll_msg_set(C, "Vertex select needs to be enabled in weight paint mode");
+ return false;
+ }
}
else {
- CTX_wm_operator_poll_msg_set(C, "Vertex select needs to be enabled in weight paint mode");
- return false;
+ return true;
}
}
else {
@@ -2528,15 +2542,31 @@ static int vertex_group_vert_select_poll_ex(bContext *C, const short ob_type_fla
}
}
+#if 0
+static int vertex_group_vert_poll(bContext *C)
+{
+ return vertex_group_vert_poll_ex(C, false, 0);
+}
+#endif
+
+
+static int vertex_group_mesh_vert_poll(bContext *C)
+{
+ return vertex_group_vert_poll_ex(C, false, (1 << OB_MESH));
+}
+
static int vertex_group_vert_select_poll(bContext *C)
{
- return vertex_group_vert_select_poll_ex(C, 0);
+ return vertex_group_vert_poll_ex(C, true, 0);
}
+#if 0
static int vertex_group_mesh_vert_select_poll(bContext *C)
{
- return vertex_group_vert_select_poll_ex(C, (1 << OB_MESH));
+ return vertex_group_vert_poll_ex(C, true, (1 << OB_MESH));
}
+#endif
+
/* editmode _or_ weight paint vertex sel and active group unlocked */
static int vertex_group_vert_select_unlocked_poll(bContext *C)
@@ -2975,7 +3005,7 @@ static int vertex_group_fix_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR_INVALID_CONTEXT, "This operator does not support an active mirror modifier");
return OPERATOR_CANCELLED;
}
- vgroup_fix(scene, ob, distToBe, strength, cp);
+ vgroup_fix(C, scene, ob, distToBe, strength, cp);
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
@@ -3083,13 +3113,12 @@ static int vertex_group_smooth_exec(bContext *C, wmOperator *op)
const float fac = RNA_float_get(op->ptr, "factor");
const int repeat = RNA_int_get(op->ptr, "repeat");
eVGroupSelect subset_type = RNA_enum_get(op->ptr, "group_select_mode");
- const int source = RNA_enum_get(op->ptr, "source");
const float fac_expand = RNA_float_get(op->ptr, "expand");
int subset_count, vgroup_tot;
const bool *vgroup_validmap = BKE_object_defgroup_subset_from_select_type(ob, subset_type, &vgroup_tot, &subset_count);
- vgroup_smooth_subset(ob, vgroup_validmap, vgroup_tot, subset_count, fac, repeat, fac_expand, source);
+ vgroup_smooth_subset(ob, vgroup_validmap, vgroup_tot, subset_count, fac, repeat, fac_expand);
MEM_freeN((void *)vgroup_validmap);
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -3101,20 +3130,13 @@ static int vertex_group_smooth_exec(bContext *C, wmOperator *op)
void OBJECT_OT_vertex_group_smooth(wmOperatorType *ot)
{
- static EnumPropertyItem smooth_source_item[] = {
- {WEIGHT_SMOOTH_ALL, "ALL", 0, "All", ""},
- {WEIGHT_SMOOTH_SELECT, "SELECT", 0, "Only Selected", ""},
- {WEIGHT_SMOOTH_DESELECT, "DESELECT", 0, "Only Deselected", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
/* identifiers */
ot->name = "Smooth Vertex Weights";
ot->idname = "OBJECT_OT_vertex_group_smooth";
ot->description = "Smooth weights for selected vertices";
/* api callbacks */
- ot->poll = vertex_group_mesh_vert_select_poll;
+ ot->poll = vertex_group_mesh_vert_poll;
ot->exec = vertex_group_smooth_exec;
/* flags */
@@ -3125,7 +3147,6 @@ void OBJECT_OT_vertex_group_smooth(wmOperatorType *ot)
RNA_def_int(ot->srna, "repeat", 1, 1, 10000, "Iterations", "", 1, 200);
RNA_def_float(ot->srna, "expand", 0.0f, -1.0f, 1.0, "Expand/Contract", "Expand/contract weights", -1.0f, 1.0f);
- RNA_def_enum(ot->srna, "source", smooth_source_item, -1, "Source", "Vertices to mix with");
}
static int vertex_group_clean_exec(bContext *C, wmOperator *op)
diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c
index cd07b57577b..1f0ee6862d2 100644
--- a/source/blender/editors/physics/dynamicpaint_ops.c
+++ b/source/blender/editors/physics/dynamicpaint_ops.c
@@ -294,6 +294,8 @@ typedef struct DynamicPaintBakeJob {
DynamicPaintSurface *surface;
DynamicPaintCanvasSettings *canvas;
+ EvaluationContext *eval_ctx;
+
int success;
double start;
} DynamicPaintBakeJob;
@@ -313,6 +315,8 @@ static void dpaint_bake_endjob(void *customdata)
dynamicPaint_freeSurfaceData(job->surface);
+ MEM_freeN(job->eval_ctx);
+
G.is_rendering = false;
BKE_spacedata_draw_locks(false);
@@ -387,7 +391,7 @@ static void dynamicPaint_bakeImageSequence(DynamicPaintBakeJob *job)
/* calculate a frame */
scene->r.cfra = (int)frame;
ED_update_for_newframe(job->bmain, scene, 1);
- if (!dynamicPaint_calculateFrame(surface, scene, job->scene_layer, cObject, frame)) {
+ if (!dynamicPaint_calculateFrame(surface, job->eval_ctx, scene, cObject, frame)) {
job->success = 0;
return;
}
@@ -456,6 +460,9 @@ static int dynamicpaint_bake_exec(struct bContext *C, struct wmOperator *op)
Object *ob = ED_object_context(C);
Scene *scene = CTX_data_scene(C);
SceneLayer *sl = CTX_data_scene_layer(C);
+ EvaluationContext *eval_ctx = MEM_mallocN(sizeof(*eval_ctx), "EvaluationContext");
+
+ CTX_data_eval_ctx(C, eval_ctx);
DynamicPaintSurface *surface;
@@ -487,6 +494,7 @@ static int dynamicpaint_bake_exec(struct bContext *C, struct wmOperator *op)
job->ob = ob;
job->canvas = canvas;
job->surface = surface;
+ job->eval_ctx = eval_ctx;
wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene,
"Dynamic Paint Bake", WM_JOB_PROGRESS,
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index fb3cfdc86b2..6a5a3c73f81 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -86,7 +86,9 @@
#include "physics_intern.h"
-void PE_create_particle_edit(Scene *scene, SceneLayer *sl, Object *ob, PointCache *cache, ParticleSystem *psys);
+void PE_create_particle_edit(
+ const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, Object *ob,
+ PointCache *cache, ParticleSystem *psys);
void PTCacheUndo_clear(PTCacheEdit *edit);
void recalc_lengths(PTCacheEdit *edit);
void recalc_emitter_field(Object *ob, ParticleSystem *psys);
@@ -216,7 +218,8 @@ static float pe_brush_size_get(const Scene *UNUSED(scene), ParticleBrushData *br
*
* note: this function runs on poll, therefor it can runs many times a second
* keep it fast! */
-static PTCacheEdit *pe_get_current(Scene *scene, SceneLayer *sl, Object *ob, int create)
+static PTCacheEdit *pe_get_current(
+ const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, Object *ob, int create)
{
ParticleEditSettings *pset= PE_settings(scene);
PTCacheEdit *edit = NULL;
@@ -256,18 +259,18 @@ static PTCacheEdit *pe_get_current(Scene *scene, SceneLayer *sl, Object *ob, int
if (psys->part && psys->part->type == PART_HAIR) {
if (psys->flag & PSYS_HAIR_DYNAMICS && psys->pointcache->flag & PTCACHE_BAKED) {
if (create && !psys->pointcache->edit)
- PE_create_particle_edit(scene, sl, ob, pid->cache, NULL);
+ PE_create_particle_edit(eval_ctx, scene, sl, ob, pid->cache, NULL);
edit = pid->cache->edit;
}
else {
if (create && !psys->edit && psys->flag & PSYS_HAIR_DONE)
- PE_create_particle_edit(scene, sl, ob, NULL, psys);
+ PE_create_particle_edit(eval_ctx, scene, sl, ob, NULL, psys);
edit = psys->edit;
}
}
else {
if (create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit)
- PE_create_particle_edit(scene, sl, ob, pid->cache, psys);
+ PE_create_particle_edit(eval_ctx, scene, sl, ob, pid->cache, psys);
edit = pid->cache->edit;
}
@@ -278,7 +281,7 @@ static PTCacheEdit *pe_get_current(Scene *scene, SceneLayer *sl, Object *ob, int
if (create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit) {
pset->flag |= PE_FADE_TIME;
// NICE TO HAVE but doesn't work: pset->brushtype = PE_BRUSH_COMB;
- PE_create_particle_edit(scene, sl, ob, pid->cache, NULL);
+ PE_create_particle_edit(eval_ctx, scene, sl, ob, pid->cache, NULL);
}
edit = pid->cache->edit;
break;
@@ -287,7 +290,7 @@ static PTCacheEdit *pe_get_current(Scene *scene, SceneLayer *sl, Object *ob, int
if (create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit) {
pset->flag |= PE_FADE_TIME;
// NICE TO HAVE but doesn't work: pset->brushtype = PE_BRUSH_COMB;
- PE_create_particle_edit(scene, sl, ob, pid->cache, NULL);
+ PE_create_particle_edit(eval_ctx, scene, sl, ob, pid->cache, NULL);
}
edit = pid->cache->edit;
break;
@@ -304,18 +307,19 @@ static PTCacheEdit *pe_get_current(Scene *scene, SceneLayer *sl, Object *ob, int
PTCacheEdit *PE_get_current(Scene *scene, SceneLayer *sl, Object *ob)
{
- return pe_get_current(scene, sl, ob, 0);
+ return pe_get_current(NULL, scene, sl, ob, 0);
}
-PTCacheEdit *PE_create_current(Scene *scene, Object *ob)
+PTCacheEdit *PE_create_current(const EvaluationContext *eval_ctx, Scene *scene, Object *ob)
{
- return pe_get_current(scene, NULL, ob, 1);
+ return pe_get_current(eval_ctx, scene, NULL, ob, 1);
}
-void PE_current_changed(Scene *scene, Object *ob)
+void PE_current_changed(const EvaluationContext *eval_ctx, Scene *scene, Object *ob)
{
- if (ob->mode == OB_MODE_PARTICLE_EDIT)
- PE_create_current(scene, ob);
+ if (ob->mode == OB_MODE_PARTICLE_EDIT) {
+ PE_create_current(eval_ctx, scene, ob);
+ }
}
void PE_hide_keys_time(Scene *scene, PTCacheEdit *edit, float cfra)
@@ -358,6 +362,7 @@ static int pe_x_mirror(Object *ob)
typedef struct PEData {
ViewContext vc;
+ const bContext *context;
Scene *scene;
SceneLayer *scene_layer;
Object *ob;
@@ -393,10 +398,10 @@ static void PE_set_data(bContext *C, PEData *data)
{
memset(data, 0, sizeof(*data));
- data->scene= CTX_data_scene(C);
+ data->scene = CTX_data_scene(C);
data->scene_layer = CTX_data_scene_layer(C);
- data->ob= CTX_data_active_object(C);
- data->edit= PE_get_current(data->scene, data->scene_layer, data->ob);
+ data->ob = CTX_data_active_object(C);
+ data->edit = PE_get_current(data->scene, data->scene_layer, data->ob);
}
static void PE_set_view3d_data(bContext *C, PEData *data)
@@ -407,10 +412,13 @@ static void PE_set_view3d_data(bContext *C, PEData *data)
if (V3D_IS_ZBUF(data->vc.v3d)) {
if (data->vc.v3d->flag & V3D_INVALID_BACKBUF) {
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
/* needed or else the draw matrix can be incorrect */
view3d_operator_needs_opengl(C);
- ED_view3d_backbuf_validate(&data->vc);
+ ED_view3d_backbuf_validate(&eval_ctx, &data->vc);
/* we may need to force an update here by setting the rv3d as dirty
* for now it seems ok, but take care!:
* rv3d->depths->dirty = 1; */
@@ -429,7 +437,6 @@ static bool PE_create_shape_tree(PEData *data, Object *shapeob)
return false;
}
- DM_ensure_looptri(dm);
return (bvhtree_from_mesh_looptri(&data->shape_bvh, dm, 0.0f, 4, 8) != NULL);
}
@@ -1156,12 +1163,15 @@ void recalc_emitter_field(Object *ob, ParticleSystem *psys)
BLI_kdtree_balance(edit->emitter_field);
}
-static void PE_update_selection(Scene *scene, SceneLayer *sl, Object *ob, int useflag)
+static void PE_update_selection(const bContext *C, Scene *scene, SceneLayer *sl, Object *ob, int useflag)
{
- PTCacheEdit *edit= PE_get_current(scene, sl, ob);
+ PTCacheEdit *edit = PE_get_current(scene, sl, ob);
HairKey *hkey;
+ EvaluationContext eval_ctx;
POINT_P; KEY_K;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
/* flag all particles to be updated if not using flag */
if (!useflag)
LOOP_POINTS
@@ -1177,7 +1187,7 @@ static void PE_update_selection(Scene *scene, SceneLayer *sl, Object *ob, int us
}
}
- psys_cache_edit_paths(scene, ob, edit, CFRA, G.is_rendering);
+ psys_cache_edit_paths(&eval_ctx, scene, ob, edit, CFRA, G.is_rendering);
/* disable update flag */
@@ -1263,7 +1273,7 @@ static void update_velocities(PTCacheEdit *edit)
}
}
-void PE_update_object(Scene *scene, SceneLayer *sl, Object *ob, int useflag)
+void PE_update_object(const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, Object *ob, int useflag)
{
/* use this to do partial particle updates, not usable when adding or
* removing, then a full redo is necessary and calling this may crash */
@@ -1293,7 +1303,7 @@ void PE_update_object(Scene *scene, SceneLayer *sl, Object *ob, int useflag)
PE_hide_keys_time(scene, edit, CFRA);
/* regenerate path caches */
- psys_cache_edit_paths(scene, ob, edit, CFRA, G.is_rendering);
+ psys_cache_edit_paths(eval_ctx, scene, ob, edit, CFRA, G.is_rendering);
/* disable update flag */
LOOP_POINTS {
@@ -1428,7 +1438,7 @@ static int pe_select_all_exec(bContext *C, wmOperator *op)
}
}
- PE_update_selection(scene, sl, ob, 1);
+ PE_update_selection(C, scene, sl, ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob);
return OPERATOR_FINISHED;
@@ -1461,7 +1471,7 @@ int PE_mouse_particles(bContext *C, const int mval[2], bool extend, bool deselec
Object *ob= CTX_data_active_object(C);
PTCacheEdit *edit= PE_get_current(scene, sl, ob);
POINT_P; KEY_K;
-
+
if (!PE_start_edit(edit))
return OPERATOR_CANCELLED;
@@ -1486,7 +1496,7 @@ int PE_mouse_particles(bContext *C, const int mval[2], bool extend, bool deselec
else
for_mouse_hit_keys(&data, toggle_key_select, 1);
- PE_update_selection(scene, sl, ob, 1);
+ PE_update_selection(C, scene, sl, ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
@@ -1527,7 +1537,7 @@ static int select_roots_exec(bContext *C, wmOperator *op)
data.select_action = action;
foreach_point(&data, select_root);
- PE_update_selection(data.scene, data.scene_layer, data.ob, 1);
+ PE_update_selection(C, data.scene, data.scene_layer, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
@@ -1592,7 +1602,7 @@ static int select_tips_exec(bContext *C, wmOperator *op)
data.select_action = action;
foreach_point(&data, select_tip);
- PE_update_selection(data.scene, data.scene_layer, data.ob, 1);
+ PE_update_selection(C, data.scene, data.scene_layer, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
@@ -1678,7 +1688,7 @@ static int select_random_exec(bContext *C, wmOperator *op)
BLI_rng_free(rng);
- PE_update_selection(data.scene, data.scene_layer, data.ob, 1);
+ PE_update_selection(C, data.scene, data.scene_layer, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
@@ -1722,7 +1732,7 @@ static int select_linked_exec(bContext *C, wmOperator *op)
data.select= !RNA_boolean_get(op->ptr, "deselect");
for_mouse_hit_keys(&data, select_keys, 1); /* nearest only */
- PE_update_selection(data.scene, data.scene_layer, data.ob, 1);
+ PE_update_selection(C, data.scene, data.scene_layer, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
@@ -1787,7 +1797,7 @@ int PE_border_select(bContext *C, rcti *rect, bool select, bool extend)
for_mouse_hit_keys(&data, select_key, 0);
- PE_update_selection(scene, sl, ob, 1);
+ PE_update_selection(C, scene, sl, ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob);
return OPERATOR_FINISHED;
@@ -1813,7 +1823,7 @@ int PE_circle_select(bContext *C, int selecting, const int mval[2], float rad)
for_mouse_hit_keys(&data, select_key, 0);
- PE_update_selection(scene, sl, ob, 1);
+ PE_update_selection(C, scene, sl, ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob);
return OPERATOR_FINISHED;
@@ -1902,7 +1912,7 @@ int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, bool
}
}
- PE_update_selection(scene, sl, ob, 1);
+ PE_update_selection(C, scene, sl, ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob);
return OPERATOR_FINISHED;
@@ -1937,7 +1947,7 @@ static int hide_exec(bContext *C, wmOperator *op)
}
}
- PE_update_selection(scene, sl, ob, 1);
+ PE_update_selection(C, scene, sl, ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob);
return OPERATOR_FINISHED;
@@ -1981,7 +1991,7 @@ static int reveal_exec(bContext *C, wmOperator *UNUSED(op))
}
}
- PE_update_selection(scene, sl, ob, 1);
+ PE_update_selection(C, scene, sl, ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob);
return OPERATOR_FINISHED;
@@ -2040,7 +2050,7 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op))
PE_set_data(C, &data);
foreach_point(&data, select_less_keys);
- PE_update_selection(data.scene, data.scene_layer, data.ob, 1);
+ PE_update_selection(C, data.scene, data.scene_layer, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
@@ -2102,7 +2112,7 @@ static int select_more_exec(bContext *C, wmOperator *UNUSED(op))
PE_set_data(C, &data);
foreach_point(&data, select_more_keys);
- PE_update_selection(data.scene, data.scene_layer, data.ob, 1);
+ PE_update_selection(C, data.scene, data.scene_layer, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
@@ -2135,12 +2145,15 @@ static void rekey_particle(PEData *data, int pa_index)
ParticleKey state;
HairKey *key, *new_keys, *okey;
PTCacheEditKey *ekey;
+ EvaluationContext eval_ctx;
float dval, sta, end;
int k;
- sim.scene= data->scene;
- sim.ob= data->ob;
- sim.psys= edit->psys;
+ CTX_data_eval_ctx(data->context, &eval_ctx);
+ sim.eval_ctx = &eval_ctx;
+ sim.scene = data->scene;
+ sim.ob = data->ob;
+ sim.psys = edit->psys;
pa->flag |= PARS_REKEY;
@@ -2191,6 +2204,9 @@ static int rekey_exec(bContext *C, wmOperator *op)
{
PEData data;
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
PE_set_data(C, &data);
data.dval= 1.0f / (float)(data.totrekey-1);
@@ -2199,7 +2215,7 @@ static int rekey_exec(bContext *C, wmOperator *op)
foreach_selected_point(&data, rekey_particle);
recalc_lengths(data.edit);
- PE_update_object(data.scene, data.scene_layer, data.ob, 1);
+ PE_update_object(&eval_ctx, data.scene, data.scene_layer, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, data.ob);
return OPERATOR_FINISHED;
@@ -2224,24 +2240,28 @@ void PARTICLE_OT_rekey(wmOperatorType *ot)
RNA_def_int(ot->srna, "keys_number", 2, 2, INT_MAX, "Number of Keys", "", 2, 100);
}
-static void rekey_particle_to_time(Scene *scene, SceneLayer *sl, Object *ob, int pa_index, float path_time)
+static void rekey_particle_to_time(const bContext *C, Scene *scene, SceneLayer *sl, Object *ob, int pa_index, float path_time)
{
PTCacheEdit *edit= PE_get_current(scene, sl, ob);
ParticleSystem *psys;
- ParticleSimulationData sim= {0};
+ ParticleSimulationData sim = {0};
ParticleData *pa;
ParticleKey state;
HairKey *new_keys, *key;
PTCacheEditKey *ekey;
+ EvaluationContext eval_ctx;
int k;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
if (!edit || !edit->psys) return;
psys = edit->psys;
- sim.scene= scene;
- sim.ob= ob;
- sim.psys= psys;
+ sim.eval_ctx = &eval_ctx;
+ sim.scene = scene;
+ sim.ob = ob;
+ sim.psys = psys;
pa= psys->particles + pa_index;
@@ -2451,14 +2471,17 @@ static void subdivide_particle(PEData *data, int pa_index)
ParticleKey state;
HairKey *key, *nkey, *new_keys;
PTCacheEditKey *ekey, *nekey, *new_ekeys;
+ EvaluationContext eval_ctx;
int k;
short totnewkey=0;
float endtime;
- sim.scene= data->scene;
- sim.ob= data->ob;
- sim.psys= edit->psys;
+ CTX_data_eval_ctx(data->context, &eval_ctx);
+ sim.eval_ctx = &eval_ctx;
+ sim.scene = data->scene;
+ sim.ob = data->ob;
+ sim.psys = edit->psys;
for (k=0, ekey=point->keys; k<pa->totkey-1; k++, ekey++) {
if (ekey->flag&PEK_SELECT && (ekey+1)->flag&PEK_SELECT)
@@ -2526,11 +2549,14 @@ static int subdivide_exec(bContext *C, wmOperator *UNUSED(op))
{
PEData data;
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
PE_set_data(C, &data);
foreach_point(&data, subdivide_particle);
recalc_lengths(data.edit);
- PE_update_object(data.scene, data.scene_layer, data.ob, 1);
+ PE_update_object(&eval_ctx, data.scene, data.scene_layer, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, data.ob);
return OPERATOR_FINISHED;
@@ -2720,7 +2746,7 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata)
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
- imm_draw_circle_wire(pos, (float)x, (float)y, pe_brush_size_get(scene, brush), 40);
+ imm_draw_circle_wire_2d(pos, (float)x, (float)y, pe_brush_size_get(scene, brush), 40);
glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH);
@@ -2813,7 +2839,7 @@ static void PE_mirror_x(Scene *scene, SceneLayer *sl, Object *ob, int tagged)
{
Mesh *me= (Mesh *)(ob->data);
ParticleSystemModifierData *psmd;
- PTCacheEdit *edit= PE_get_current(scene, sl, ob);
+ PTCacheEdit *edit = PE_get_current(scene, sl, ob);
ParticleSystem *psys = edit->psys;
ParticleData *pa, *newpa, *new_pars;
PTCacheEditPoint *newpoint, *new_points;
@@ -3101,7 +3127,7 @@ static void brush_cut(PEData *data, int pa_index)
edit->points[pa_index].flag |= PEP_TAG;
}
else {
- rekey_particle_to_time(data->scene, data->scene_layer, ob, pa_index, cut_time);
+ rekey_particle_to_time(data->context, data->scene, data->scene_layer, ob, pa_index, cut_time);
edit->points[pa_index].flag |= PEP_EDIT_RECALC;
}
}
@@ -3349,25 +3375,28 @@ static void intersect_dm_quad_weights(const float v1[3], const float v2[3], cons
}
/* check intersection with a derivedmesh */
-static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm,
+static int particle_intersect_dm(const bContext *C, Scene *scene, Object *ob, DerivedMesh *dm,
float *vert_cos,
const float co1[3], const float co2[3],
float *min_d, int *min_face, float *min_w,
float *face_minmax, float *pa_minmax,
float radius, float *ipoint)
{
+ EvaluationContext eval_ctx;
MFace *mface= NULL;
MVert *mvert= NULL;
int i, totface, intersect=0;
float cur_d, cur_uv[2], v1[3], v2[3], v3[3], v4[3], min[3], max[3], p_min[3], p_max[3];
float cur_ipoint[3];
+ CTX_data_eval_ctx(C, &eval_ctx);
+
if (dm == NULL) {
psys_disable_all(ob);
- dm=mesh_get_derived_final(scene, ob, 0);
+ dm = mesh_get_derived_final(&eval_ctx, scene, ob, 0);
if (dm == NULL)
- dm=mesh_get_derived_deform(scene, ob, 0);
+ dm = mesh_get_derived_deform(&eval_ctx, scene, ob, 0);
psys_enable_all(ob);
@@ -3480,8 +3509,9 @@ static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm,
return intersect;
}
-static int brush_add(PEData *data, short number)
+static int brush_add(const bContext *C, PEData *data, short number)
{
+ EvaluationContext eval_ctx;
Scene *scene= data->scene;
Object *ob= data->ob;
DerivedMesh *dm;
@@ -3509,6 +3539,9 @@ static int brush_add(PEData *data, short number)
rng = BLI_rng_new_srandom(psys->seed+data->mval[0]+data->mval[1]);
+ CTX_data_eval_ctx(C, &eval_ctx);
+
+ sim.eval_ctx = &eval_ctx;
sim.scene= scene;
sim.ob= ob;
sim.psys= psys;
@@ -3549,7 +3582,7 @@ static int brush_add(PEData *data, short number)
min_d=2.0;
/* warning, returns the derived mesh face */
- if (particle_intersect_dm(scene, ob, dm, 0, co1, co2, &min_d, &add_pars[n].num_dmcache, add_pars[n].fuv, 0, 0, 0, 0)) {
+ if (particle_intersect_dm(C, scene, ob, dm, 0, co1, co2, &min_d, &add_pars[n].num_dmcache, add_pars[n].fuv, 0, 0, 0, 0)) {
if (psys->part->use_modifier_stack && !psmd->dm_final->deformedOnly) {
add_pars[n].num = add_pars[n].num_dmcache;
add_pars[n].num_dmcache = DMCACHE_ISCHILD;
@@ -3798,6 +3831,9 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
if (!PE_start_edit(edit))
return;
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
RNA_float_get_array(itemptr, "mouse", mousef);
mouse[0] = mousef[0];
mouse[1] = mousef[1];
@@ -3923,7 +3959,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
if (edit->psys && edit->psys->part->from==PART_FROM_FACE) {
data.mval= mval;
- added= brush_add(&data, brush->count);
+ added= brush_add(C, &data, brush->count);
if (pset->flag & PE_KEEP_LENGTHS)
recalc_lengths(edit);
@@ -3979,8 +4015,9 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
psys_free_path_cache(NULL, edit);
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
}
- else
- PE_update_object(scene, sl, ob, 1);
+ else {
+ PE_update_object(&eval_ctx, scene, sl, ob, 1);
+ }
}
if (edit->psys) {
@@ -4193,7 +4230,7 @@ static void shape_cut(PEData *data, int pa_index)
edit->points[pa_index].flag |= PEP_TAG;
}
else {
- rekey_particle_to_time(data->scene, data->scene_layer, ob, pa_index, cut_time);
+ rekey_particle_to_time(data->context, data->scene, data->scene_layer, ob, pa_index, cut_time);
edit->points[pa_index].flag |= PEP_EDIT_RECALC;
}
}
@@ -4213,6 +4250,9 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op))
if (!PE_start_edit(edit))
return OPERATOR_CANCELLED;
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
/* disable locking temporatily for disconnected hair */
if (edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR)
pset->flag &= ~PE_LOCK_FIRST;
@@ -4240,8 +4280,9 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op))
psys_free_path_cache(NULL, edit);
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
}
- else
- PE_update_object(scene, sl, ob, 1);
+ else {
+ PE_update_object(&eval_ctx, scene, sl, ob, 1);
+ }
if (edit->psys) {
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, ob);
@@ -4415,7 +4456,7 @@ static void get_PTCacheUndo(PTCacheEdit *edit, PTCacheUndo *undo)
void PE_undo_push(Scene *scene, SceneLayer *sl, const char *str)
{
- PTCacheEdit *edit= PE_get_current(scene, sl, OBACT_NEW);
+ PTCacheEdit *edit= PE_get_current(scene, sl, OBACT_NEW(sl));
PTCacheUndo *undo;
int nr;
@@ -4457,7 +4498,7 @@ void PE_undo_push(Scene *scene, SceneLayer *sl, const char *str)
void PE_undo_step(Scene *scene, SceneLayer *sl, int step)
{
- PTCacheEdit *edit= PE_get_current(scene, sl, OBACT_NEW);
+ PTCacheEdit *edit= PE_get_current(scene, sl, OBACT_NEW(sl));
if (!edit) return;
@@ -4488,12 +4529,12 @@ void PE_undo_step(Scene *scene, SceneLayer *sl, int step)
}
}
- DEG_id_tag_update(&OBACT_NEW->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&OBACT_NEW(sl)->id, OB_RECALC_DATA);
}
bool PE_undo_is_valid(Scene *scene, SceneLayer *sl)
{
- PTCacheEdit *edit= PE_get_current(scene, sl, OBACT_NEW);
+ PTCacheEdit *edit= PE_get_current(scene, sl, OBACT_NEW(sl));
if (edit) {
return (edit->undo.last != edit->undo.first);
@@ -4528,7 +4569,7 @@ void PE_redo(Scene *scene, SceneLayer *sl)
void PE_undo_number(Scene *scene, SceneLayer *sl, int nr)
{
- PTCacheEdit *edit= PE_get_current(scene, sl, OBACT_NEW);
+ PTCacheEdit *edit= PE_get_current(scene, sl, OBACT_NEW(sl));
PTCacheUndo *undo;
int a=0;
@@ -4544,7 +4585,7 @@ void PE_undo_number(Scene *scene, SceneLayer *sl, int nr)
/* if active pointer, set it to 1 if true */
const char *PE_undo_get_name(Scene *scene, SceneLayer *sl, int nr, bool *r_active)
{
- PTCacheEdit *edit= PE_get_current(scene, sl, OBACT_NEW);
+ PTCacheEdit *edit= PE_get_current(scene, sl, OBACT_NEW(sl));
PTCacheUndo *undo;
if (r_active) *r_active = false;
@@ -4565,7 +4606,7 @@ const char *PE_undo_get_name(Scene *scene, SceneLayer *sl, int nr, bool *r_activ
int PE_minmax(Scene *scene, SceneLayer *sl, float min[3], float max[3])
{
- Object *ob= OBACT_NEW;
+ Object *ob= OBACT_NEW(sl);
PTCacheEdit *edit= PE_get_current(scene, sl, ob);
ParticleSystem *psys;
ParticleSystemModifierData *psmd = NULL;
@@ -4603,7 +4644,8 @@ int PE_minmax(Scene *scene, SceneLayer *sl, float min[3], float max[3])
/************************ particle edit toggle operator ************************/
/* initialize needed data for bake edit */
-void PE_create_particle_edit(Scene *scene, SceneLayer *sl, Object *ob, PointCache *cache, ParticleSystem *psys)
+void PE_create_particle_edit(
+ const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, Object *ob, PointCache *cache, ParticleSystem *psys)
{
PTCacheEdit *edit;
ParticleSystemModifierData *psmd = (psys) ? psys_get_modifier(ob, psys) : NULL;
@@ -4704,7 +4746,7 @@ void PE_create_particle_edit(Scene *scene, SceneLayer *sl, Object *ob, PointCach
recalc_lengths(edit);
if (psys && !cache)
recalc_emitter_field(ob, psys);
- PE_update_object(scene, sl, ob, 1);
+ PE_update_object(eval_ctx, scene, sl, ob, 1);
PTCacheUndo_clear(edit);
PE_undo_push(scene, sl, "Original");
@@ -4745,8 +4787,11 @@ static int particle_edit_toggle_exec(bContext *C, wmOperator *op)
if (!is_mode_set) {
PTCacheEdit *edit;
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
ob->mode |= mode_flag;
- edit= PE_create_current(scene, ob);
+ edit= PE_create_current(&eval_ctx, scene, ob);
/* mesh may have changed since last entering editmode.
* note, this may have run before if the edit data was just created, so could avoid this and speed up a little */
@@ -4917,12 +4962,16 @@ static int unify_length_exec(bContext *C, wmOperator *UNUSED(op))
SceneLayer *sl = CTX_data_scene_layer(C);
PTCacheEdit *edit = PE_get_current(scene, sl, ob);
float average_length = calculate_average_length(edit);
+
if (average_length == 0.0f) {
return OPERATOR_CANCELLED;
}
scale_points_to_length(edit, average_length);
- PE_update_object(scene, sl, ob, 1);
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
+ PE_update_object(&eval_ctx, scene, sl, ob, 1);
if (edit->psys) {
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, ob);
}
diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c
index cd7bb8640b5..571a8ab18f0 100644
--- a/source/blender/editors/physics/particle_object.c
+++ b/source/blender/editors/physics/particle_object.c
@@ -71,7 +71,7 @@
#include "physics_intern.h"
-extern void PE_create_particle_edit(Scene *scene, SceneLayer *sl, Object *ob, PointCache *cache, ParticleSystem *psys);
+extern void PE_create_particle_edit(const bContext *C, Scene *scene, SceneLayer *sl, Object *ob, PointCache *cache, ParticleSystem *psys);
extern void PTCacheUndo_clear(PTCacheEdit *edit);
extern void recalc_lengths(PTCacheEdit *edit);
extern void recalc_emitter_field(Object *ob, ParticleSystem *psys);
@@ -568,7 +568,9 @@ void PARTICLE_OT_dupliob_move_down(wmOperatorType *ot)
/************************ connect/disconnect hair operators *********************/
-static void disconnect_hair(Scene *scene, SceneLayer *sl, Object *ob, ParticleSystem *psys)
+static void disconnect_hair(
+ const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl,
+ Object *ob, ParticleSystem *psys)
{
ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys);
ParticleEditSettings *pset= PE_settings(scene);
@@ -614,7 +616,7 @@ static void disconnect_hair(Scene *scene, SceneLayer *sl, Object *ob, ParticleSy
if (ELEM(pset->brushtype, PE_BRUSH_ADD, PE_BRUSH_PUFF))
pset->brushtype = PE_BRUSH_NONE;
- PE_update_object(scene, sl, ob, 0);
+ PE_update_object(eval_ctx, scene, sl, ob, 0);
}
static int disconnect_hair_exec(bContext *C, wmOperator *op)
@@ -625,17 +627,20 @@ static int disconnect_hair_exec(bContext *C, wmOperator *op)
ParticleSystem *psys= NULL;
const bool all = RNA_boolean_get(op->ptr, "all");
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
if (!ob)
return OPERATOR_CANCELLED;
if (all) {
for (psys=ob->particlesystem.first; psys; psys=psys->next) {
- disconnect_hair(scene, sl, ob, psys);
+ disconnect_hair(&eval_ctx, scene, sl, ob, psys);
}
}
else {
psys = psys_get_current(ob);
- disconnect_hair(scene, sl, ob, psys);
+ disconnect_hair(&eval_ctx, scene, sl, ob, psys);
}
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -661,9 +666,10 @@ void PARTICLE_OT_disconnect_hair(wmOperatorType *ot)
/* from/to_world_space : whether from/to particles are in world or hair space
* from/to_mat : additional transform for from/to particles (e.g. for using object space copying)
*/
-static bool remap_hair_emitter(Scene *scene, SceneLayer *sl, Object *ob, ParticleSystem *psys,
- Object *target_ob, ParticleSystem *target_psys, PTCacheEdit *target_edit,
- float from_mat[4][4], float to_mat[4][4], bool from_global, bool to_global)
+static bool remap_hair_emitter(
+ const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, Object *ob, ParticleSystem *psys,
+ Object *target_ob, ParticleSystem *target_psys, PTCacheEdit *target_edit,
+ float from_mat[4][4], float to_mat[4][4], bool from_global, bool to_global)
{
ParticleSystemModifierData *target_psmd = psys_get_modifier(target_ob, target_psys);
ParticleData *pa, *tpa;
@@ -847,19 +853,23 @@ static bool remap_hair_emitter(Scene *scene, SceneLayer *sl, Object *ob, Particl
psys_free_path_cache(target_psys, target_edit);
- PE_update_object(scene, sl, target_ob, 0);
+ PE_update_object(eval_ctx, scene, sl, target_ob, 0);
return true;
}
-static bool connect_hair(Scene *scene, SceneLayer *sl, Object *ob, ParticleSystem *psys)
+static bool connect_hair(
+ const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl,
+ Object *ob, ParticleSystem *psys)
{
bool ok;
if (!psys)
return false;
- ok = remap_hair_emitter(scene, sl, ob, psys, ob, psys, psys->edit, ob->obmat, ob->obmat, psys->flag & PSYS_GLOBAL_HAIR, false);
+ ok = remap_hair_emitter(
+ eval_ctx, scene, sl, ob, psys, ob, psys, psys->edit,
+ ob->obmat, ob->obmat, psys->flag & PSYS_GLOBAL_HAIR, false);
psys->flag &= ~PSYS_GLOBAL_HAIR;
return ok;
@@ -867,6 +877,7 @@ static bool connect_hair(Scene *scene, SceneLayer *sl, Object *ob, ParticleSyste
static int connect_hair_exec(bContext *C, wmOperator *op)
{
+ EvaluationContext eval_ctx;
Scene *scene= CTX_data_scene(C);
SceneLayer *sl = CTX_data_scene_layer(C);
Object *ob= ED_object_context(C);
@@ -877,14 +888,16 @@ static int connect_hair_exec(bContext *C, wmOperator *op)
if (!ob)
return OPERATOR_CANCELLED;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
if (all) {
for (psys=ob->particlesystem.first; psys; psys=psys->next) {
- any_connected |= connect_hair(scene, sl, ob, psys);
+ any_connected |= connect_hair(&eval_ctx, scene, sl, ob, psys);
}
}
else {
psys = psys_get_current(ob);
- any_connected |= connect_hair(scene, sl, ob, psys);
+ any_connected |= connect_hair(&eval_ctx, scene, sl, ob, psys);
}
if (!any_connected) {
@@ -920,7 +933,9 @@ typedef enum eCopyParticlesSpace {
PAR_COPY_SPACE_WORLD = 1,
} eCopyParticlesSpace;
-static void copy_particle_edit(Scene *scene, SceneLayer *sl, Object *ob, ParticleSystem *psys, ParticleSystem *psys_from)
+static void copy_particle_edit(
+ const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl,
+ Object *ob, ParticleSystem *psys, ParticleSystem *psys_from)
{
PTCacheEdit *edit_from = psys_from->edit, *edit;
ParticleData *pa;
@@ -970,7 +985,7 @@ static void copy_particle_edit(Scene *scene, SceneLayer *sl, Object *ob, Particl
recalc_lengths(edit);
recalc_emitter_field(ob, psys);
- PE_update_object(scene, sl, ob, true);
+ PE_update_object(eval_ctx, scene, sl, ob, true);
PTCacheUndo_clear(edit);
PE_undo_push(scene, sl, "Original");
@@ -1001,7 +1016,7 @@ static void remove_particle_systems_from_object(Object *ob_to)
}
/* single_psys_from is optional, if NULL all psys of ob_from are copied */
-static bool copy_particle_systems_to_object(Main *bmain,
+static bool copy_particle_systems_to_object(const bContext *C,
Scene *scene,
SceneLayer *sl,
Object *ob_from,
@@ -1010,6 +1025,8 @@ static bool copy_particle_systems_to_object(Main *bmain,
int space,
bool duplicate_settings)
{
+ Main *bmain = CTX_data_main(C);
+ EvaluationContext eval_ctx;
ModifierData *md;
ParticleSystem *psys_start = NULL, *psys, *psys_from;
ParticleSystem **tmp_psys;
@@ -1017,6 +1034,8 @@ static bool copy_particle_systems_to_object(Main *bmain,
CustomDataMask cdmask;
int i, totpsys;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
if (ob_to->type != OB_MESH)
return false;
if (!ob_to->data || ID_IS_LINKED_DATABLOCK(ob_to->data))
@@ -1041,7 +1060,7 @@ static bool copy_particle_systems_to_object(Main *bmain,
psys_from;
psys_from = PSYS_FROM_NEXT(psys_from), ++i) {
- psys = BKE_object_copy_particlesystem(psys_from);
+ psys = BKE_object_copy_particlesystem(psys_from, 0);
tmp_psys[i] = psys;
if (psys_start == NULL)
@@ -1055,7 +1074,7 @@ static bool copy_particle_systems_to_object(Main *bmain,
psys_start = totpsys > 0 ? tmp_psys[0] : NULL;
/* get the DM (psys and their modifiers have not been appended yet) */
- final_dm = mesh_get_derived_final(scene, ob_to, cdmask);
+ final_dm = mesh_get_derived_final(&eval_ctx, scene, ob_to, cdmask);
/* now append psys to the object and make modifiers */
for (i = 0, psys_from = PSYS_FROM_FIRST;
@@ -1083,8 +1102,9 @@ static bool copy_particle_systems_to_object(Main *bmain,
CDDM_calc_normals(psmd->dm_final);
DM_ensure_tessface(psmd->dm_final);
- if (psys_from->edit)
- copy_particle_edit(scene, sl, ob_to, psys, psys_from);
+ if (psys_from->edit) {
+ copy_particle_edit(&eval_ctx, scene, sl, ob_to, psys, psys_from);
+ }
if (duplicate_settings) {
id_us_min(&psys->part->id);
@@ -1118,7 +1138,9 @@ static bool copy_particle_systems_to_object(Main *bmain,
break;
}
if (ob_from != ob_to) {
- remap_hair_emitter(scene, sl, ob_from, psys_from, ob_to, psys, psys->edit, from_mat, to_mat, psys_from->flag & PSYS_GLOBAL_HAIR, psys->flag & PSYS_GLOBAL_HAIR);
+ remap_hair_emitter(
+ &eval_ctx, scene, sl, ob_from, psys_from, ob_to, psys, psys->edit,
+ from_mat, to_mat, psys_from->flag & PSYS_GLOBAL_HAIR, psys->flag & PSYS_GLOBAL_HAIR);
}
/* tag for recalc */
@@ -1151,7 +1173,6 @@ static int copy_particle_systems_exec(bContext *C, wmOperator *op)
const int space = RNA_enum_get(op->ptr, "space");
const bool remove_target_particles = RNA_boolean_get(op->ptr, "remove_target_particles");
const bool use_active = RNA_boolean_get(op->ptr, "use_active");
- Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
SceneLayer *sl = CTX_data_scene_layer(C);
Object *ob_from = ED_object_active_context(C);
@@ -1168,7 +1189,7 @@ static int copy_particle_systems_exec(bContext *C, wmOperator *op)
remove_particle_systems_from_object(ob_to);
changed = true;
}
- if (copy_particle_systems_to_object(bmain, scene, sl, ob_from, psys_from, ob_to, space, false))
+ if (copy_particle_systems_to_object(C, scene, sl, ob_from, psys_from, ob_to, space, false))
changed = true;
else
fail++;
@@ -1229,7 +1250,7 @@ static int duplicate_particle_systems_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
Object *ob = ED_object_active_context(C);
ParticleSystem *psys = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem).data;
- copy_particle_systems_to_object(CTX_data_main(C), scene, CTX_data_scene_layer(C), ob, psys, ob,
+ copy_particle_systems_to_object(C, scene, CTX_data_scene_layer(C), ob, psys, ob,
PAR_COPY_SPACE_OBJECT, duplicate_settings);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index 6e62dbabbca..b38b8640c8d 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -55,6 +55,8 @@
#include "BKE_report.h"
#include "BKE_scene.h"
+#include "DEG_depsgraph.h"
+
#include "LBM_fluidsim.h"
#include "ED_screen.h"
@@ -244,7 +246,7 @@ static void set_channel(float *channel, float time, float *value, int i, int siz
}
}
-static void set_vertex_channel(float *channel, float time, struct Scene *scene, struct FluidObject *fobj, int i)
+static void set_vertex_channel(EvaluationContext *eval_ctx, float *channel, float time, struct Scene *scene, struct FluidObject *fobj, int i)
{
Object *ob = fobj->object;
FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
@@ -257,7 +259,7 @@ static void set_vertex_channel(float *channel, float time, struct Scene *scene,
if (channel == NULL)
return;
- initElbeemMesh(scene, ob, &numVerts, &verts, &numTris, &tris, 1, modifierIndex);
+ initElbeemMesh(eval_ctx, scene, ob, &numVerts, &verts, &numTris, &tris, 1, modifierIndex);
/* don't allow mesh to change number of verts in anim sequence */
if (numVerts != fobj->numVerts) {
@@ -330,10 +332,13 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
{
Scene *scene = CTX_data_scene(C);
SceneLayer *sl = CTX_data_scene_layer(C);
+ EvaluationContext eval_ctx;
Base *base;
int i;
int length = channels->length;
float eval_time;
+
+ CTX_data_eval_ctx(C, &eval_ctx);
/* init time values (assuming that time moves at a constant speed; may be overridden later) */
init_time(domainSettings, channels);
@@ -344,7 +349,7 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
channels->DomainTime = MEM_callocN(length * (CHANNEL_FLOAT+1) * sizeof(float), "channel DomainTime");
/* allocate fluid objects */
- for (base = FIRSTBASE_NEW; base; base = base->next) {
+ for (base = FIRSTBASE_NEW(sl); base; base = base->next) {
Object *ob = base->object;
FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
@@ -374,7 +379,7 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
float *verts=NULL;
int *tris=NULL, modifierIndex = BLI_findindex(&ob->modifiers, (ModifierData *)fluidmd);
- initElbeemMesh(scene, ob, &fobj->numVerts, &verts, &fobj->numTris, &tris, 0, modifierIndex);
+ initElbeemMesh(&eval_ctx, scene, ob, &fobj->numVerts, &verts, &fobj->numTris, &tris, 0, modifierIndex);
fobj->VertexCache = MEM_callocN(length *((fobj->numVerts*CHANNEL_VEC)+1) * sizeof(float), "fluidobject VertexCache");
MEM_freeN(verts);
@@ -462,15 +467,18 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
}
if (fluid_is_animated_mesh(fluidmd->fss)) {
- set_vertex_channel(fobj->VertexCache, timeAtFrame, scene, fobj, i);
+ set_vertex_channel(&eval_ctx, fobj->VertexCache, timeAtFrame, scene, fobj, i);
}
}
}
}
-static void export_fluid_objects(ListBase *fobjects, Scene *scene, int length)
+static void export_fluid_objects(const bContext *C, ListBase *fobjects, Scene *scene, int length)
{
FluidObject *fobj;
+ EvaluationContext eval_ctx;
+
+ CTX_data_eval_ctx(C, &eval_ctx);
for (fobj=fobjects->first; fobj; fobj=fobj->next) {
Object *ob = fobj->object;
@@ -492,7 +500,7 @@ static void export_fluid_objects(ListBase *fobjects, Scene *scene, int length)
fsmesh.type = fluidmd->fss->type;
fsmesh.name = ob->id.name;
- initElbeemMesh(scene, ob, &numVerts, &verts, &numTris, &tris, 0, modifierIndex);
+ initElbeemMesh(&eval_ctx, scene, ob, &numVerts, &verts, &numTris, &tris, 0, modifierIndex);
fsmesh.numVertices = numVerts;
fsmesh.numTriangles = numTris;
@@ -578,7 +586,7 @@ static int fluid_validate_scene(ReportList *reports, SceneLayer *sl, Object *fsD
int channelObjCount = 0;
int fluidInputCount = 0;
- for (base = FIRSTBASE_NEW; base; base = base->next) {
+ for (base = FIRSTBASE_NEW(sl); base; base = base->next) {
Object *ob = base->object;
FluidsimModifierData *fluidmdtmp = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
@@ -1036,7 +1044,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
elbeemAddDomain(fsset);
/* ******** export all fluid objects to elbeem ******** */
- export_fluid_objects(fobjects, scene, channels->length);
+ export_fluid_objects(C, fobjects, scene, channels->length);
/* custom data for fluid bake job */
fb->settings = fsset;
diff --git a/source/blender/editors/physics/rigidbody_constraint.c b/source/blender/editors/physics/rigidbody_constraint.c
index d93eb95243e..1c9b59268e4 100644
--- a/source/blender/editors/physics/rigidbody_constraint.c
+++ b/source/blender/editors/physics/rigidbody_constraint.c
@@ -121,7 +121,7 @@ static int rigidbody_con_add_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
SceneLayer *sl = CTX_data_scene_layer(C);
RigidBodyWorld *rbw = BKE_rigidbody_get_world(scene);
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
int type = RNA_enum_get(op->ptr, "type");
bool changed;
@@ -170,7 +170,7 @@ static int rigidbody_con_remove_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
SceneLayer *sl = CTX_data_scene_layer(C);
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
/* apply to active object */
if (ELEM(NULL, ob, ob->rigidbody_constraint)) {
diff --git a/source/blender/editors/render/CMakeLists.txt b/source/blender/editors/render/CMakeLists.txt
index ec00a258ebb..ed2e9747d1c 100644
--- a/source/blender/editors/render/CMakeLists.txt
+++ b/source/blender/editors/render/CMakeLists.txt
@@ -25,6 +25,7 @@ set(INC
../../blenloader
../../blentranslation
../../depsgraph
+ ../../draw
../../gpu
../../imbuf
../../bmesh
@@ -52,16 +53,6 @@ set(SRC
render_intern.h
)
-if(WITH_CODEC_QUICKTIME)
- list(APPEND INC
- ../../quicktime
- )
- list(APPEND INC_SYS
- ${QUICKTIME_INCLUDE_DIRS}
- )
- add_definitions(-DWITH_QUICKTIME)
-endif()
-
if(WITH_HEADLESS)
add_definitions(-DWITH_HEADLESS)
endif()
diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c
index 193fac63050..ababd637e00 100644
--- a/source/blender/editors/render/render_internal.c
+++ b/source/blender/editors/render/render_internal.c
@@ -307,7 +307,7 @@ static int screen_render_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- re = RE_NewRender(scene->id.name);
+ re = RE_NewSceneRender(scene);
RE_SetDepsgraph(re, CTX_data_depsgraph(C));
lay_override = (v3d && v3d->lay != scene->lay) ? v3d->lay : 0;
@@ -967,7 +967,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
rj->image = ima;
/* setup new render */
- re = RE_NewRender(scene->id.name);
+ re = RE_NewSceneRender(scene);
RE_test_break_cb(re, rj, render_breakjob);
RE_draw_lock_cb(re, rj, render_drawlock);
RE_display_update_cb(re, rj, image_rect_update);
@@ -1175,7 +1175,7 @@ static void render_update_resolution(Render *re, const RenderPreview *rp,
}
if (rp->has_freestyle) {
- if (rp->resolution_divider == 1) {
+ if (rp->resolution_divider == BKE_render_preview_pixel_size(&rp->scene->r)) {
RE_ChangeModeFlag(re, R_EDGE_FRS, false);
}
else {
@@ -1241,7 +1241,7 @@ static void render_view3d_startjob(void *customdata, short *stop, short *do_upda
use_border = render_view3d_disprect(rp->scene, rp->ar, rp->v3d,
rp->rv3d, &cliprct);
- if ((update_flag & (PR_UPDATE_RENDERSIZE | PR_UPDATE_DATABASE)) || rstats->convertdone == 0) {
+ if ((update_flag & (PR_UPDATE_RENDERSIZE | PR_UPDATE_DATABASE | PR_UPDATE_VIEW)) || rstats->convertdone == 0) {
RenderData rdata;
/* no osa, blur, seq, layers, savebuffer etc for preview render */
@@ -1316,11 +1316,12 @@ static void render_view3d_startjob(void *customdata, short *stop, short *do_upda
RE_updateRenderInstances(re, ob_inst_update_flag);
for (;;) {
+ int pixel_size = BKE_render_preview_pixel_size(&rp->scene->r);
if (first_time == false) {
if (restore)
RE_DataBase_IncrementalView(re, rp->viewmat, 1);
- rp->resolution_divider /= 2;
+ rp->resolution_divider = MAX2(rp->resolution_divider / 2, pixel_size);
*do_update = 1;
render_update_resolution(re, rp, use_border, &cliprct);
@@ -1337,7 +1338,7 @@ static void render_view3d_startjob(void *customdata, short *stop, short *do_upda
first_time = false;
- if (*stop || rp->resolution_divider == 1) {
+ if (*stop || rp->resolution_divider == pixel_size) {
break;
}
}
@@ -1439,7 +1440,7 @@ static void render_view3d_do(RenderEngine *engine, const bContext *C)
Scene *scene = CTX_data_scene(C);
ARegion *ar = CTX_wm_region(C);
int width = ar->winx, height = ar->winy;
- int divider = 1;
+ int divider = BKE_render_preview_pixel_size(&scene->r);
int resolution_threshold = scene->r.preview_start_resolution *
scene->r.preview_start_resolution;
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index 93cc9f30868..af932c27c5e 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -55,6 +55,8 @@
#include "BKE_sequencer.h"
#include "BKE_writeavi.h"
+#include "DEG_depsgraph.h"
+
#include "WM_api.h"
#include "WM_types.h"
@@ -72,6 +74,7 @@
#include "GPU_compositing.h"
#include "GPU_framebuffer.h"
+#include "GPU_glew.h"
#include "GPU_matrix.h"
#include "render_intern.h"
@@ -261,7 +264,7 @@ static void screen_opengl_views_setup(OGLRender *oglrender)
RE_ReleaseResult(oglrender->re);
}
-static void screen_opengl_render_doit(OGLRender *oglrender, RenderResult *rr)
+static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, RenderResult *rr)
{
Scene *scene = oglrender->scene;
SceneLayer *sl = oglrender->scene_layer;
@@ -277,6 +280,9 @@ static void screen_opengl_render_doit(OGLRender *oglrender, RenderResult *rr)
unsigned char *rect = NULL;
const char *viewname = RE_GetActiveRenderView(oglrender->re);
ImBuf *ibuf_result = NULL;
+ EvaluationContext eval_ctx;
+
+ CTX_data_eval_ctx(C, &eval_ctx);
if (oglrender->is_sequencer) {
SpaceSeq *sseq = oglrender->sseq;
@@ -346,7 +352,7 @@ static void screen_opengl_render_doit(OGLRender *oglrender, RenderResult *rr)
if (view_context) {
ibuf_view = ED_view3d_draw_offscreen_imbuf(
- scene, sl, v3d, ar, sizex, sizey,
+ &eval_ctx, scene, sl, v3d, ar, sizex, sizey,
IB_rect, draw_bgpic,
alpha_mode, oglrender->ofs_samples, oglrender->ofs_full_samples, viewname,
oglrender->fx, oglrender->ofs, err_out);
@@ -358,7 +364,7 @@ static void screen_opengl_render_doit(OGLRender *oglrender, RenderResult *rr)
}
else {
ibuf_view = ED_view3d_draw_offscreen_imbuf_simple(
- scene, sl, scene->camera, oglrender->sizex, oglrender->sizey,
+ &eval_ctx, scene, sl, scene->camera, oglrender->sizex, oglrender->sizey,
IB_rect, OB_SOLID, false, true, true,
alpha_mode, oglrender->ofs_samples, oglrender->ofs_full_samples, viewname,
oglrender->fx, oglrender->ofs, err_out);
@@ -421,7 +427,7 @@ static void addAlphaOverFloat(float dest[4], const float source[4])
}
/* add renderlayer and renderpass for each grease pencil layer for using in composition */
-static void add_gpencil_renderpass(OGLRender *oglrender, RenderResult *rr, RenderView *rv)
+static void add_gpencil_renderpass(const bContext *C, OGLRender *oglrender, RenderResult *rr, RenderView *rv)
{
bGPdata *gpd = oglrender->scene->gpd;
Scene *scene = oglrender->scene;
@@ -465,7 +471,7 @@ static void add_gpencil_renderpass(OGLRender *oglrender, RenderResult *rr, Rende
}
/* render this gp layer */
- screen_opengl_render_doit(oglrender, rr);
+ screen_opengl_render_doit(C, oglrender, rr);
/* add RendePass composite */
RenderPass *rp = RE_create_gp_pass(rr, gpl->info, rv->name);
@@ -505,7 +511,7 @@ static void add_gpencil_renderpass(OGLRender *oglrender, RenderResult *rr, Rende
scene->r.alphamode = oldalphamode;
}
-static void screen_opengl_render_apply(OGLRender *oglrender)
+static void screen_opengl_render_apply(const bContext *C, OGLRender *oglrender)
{
RenderResult *rr;
RenderView *rv;
@@ -543,10 +549,10 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
/* add grease pencil passes. For sequencer, the render does not include renderpasses
* TODO: The sequencer render of grease pencil should be rethought */
if (!oglrender->is_sequencer) {
- add_gpencil_renderpass(oglrender, rr, rv);
+ add_gpencil_renderpass(C, oglrender, rr, rv);
}
/* render composite */
- screen_opengl_render_doit(oglrender, rr);
+ screen_opengl_render_doit(C, oglrender, rr);
}
RE_ReleaseResult(oglrender->re);
@@ -562,6 +568,24 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
}
}
+static bool screen_opengl_fullsample_enabled(Scene *scene)
+{
+ if (scene->r.scemode & R_FULL_SAMPLE) {
+ return true;
+ }
+ else {
+ /* XXX TODO:
+ * Technically if the hardware supports MSAA we could keep using Blender 2.7x approach.
+ * However anti-aliasing without full_sample is not playing well even in 2.7x.
+ *
+ * For example, if you enable depth of field, there is aliasing, even if the viewport is fine.
+ * For 2.8x this is more complicated because so many things rely on shader.
+ * So until we fix the gpu_framebuffer anti-aliasing suupport we need to force full sample.
+ */
+ return true;
+ }
+}
+
static bool screen_opengl_render_init(bContext *C, wmOperator *op)
{
/* new render clears all callbacks */
@@ -575,7 +599,7 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
OGLRender *oglrender;
int sizex, sizey;
const int samples = (scene->r.mode & R_OSA) ? scene->r.osa : 0;
- const bool full_samples = (samples != 0) && (scene->r.scemode & R_FULL_SAMPLE);
+ const bool full_samples = (samples != 0) && screen_opengl_fullsample_enabled(scene);
bool is_view_context = RNA_boolean_get(op->ptr, "view_context");
const bool is_animation = RNA_boolean_get(op->ptr, "animation");
const bool is_sequencer = RNA_boolean_get(op->ptr, "sequencer");
@@ -673,7 +697,7 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
}
/* create render */
- oglrender->re = RE_NewRender(scene->id.name);
+ oglrender->re = RE_NewSceneRender(scene);
/* create image and image user */
oglrender->ima = BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
@@ -1030,7 +1054,7 @@ static bool screen_opengl_render_anim_step(bContext *C, wmOperator *op)
}
/* render into offscreen buffer */
- screen_opengl_render_apply(oglrender);
+ screen_opengl_render_apply(C, oglrender);
/* save to disk */
rr = RE_AcquireResultRead(oglrender->re);
@@ -1080,7 +1104,7 @@ static int screen_opengl_render_modal(bContext *C, wmOperator *op, const wmEvent
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, oglrender->scene);
if (anim == 0) {
- screen_opengl_render_apply(op->customdata);
+ screen_opengl_render_apply(C, op->customdata);
screen_opengl_render_end(C, op->customdata);
return OPERATOR_FINISHED;
}
@@ -1131,7 +1155,7 @@ static int screen_opengl_render_exec(bContext *C, wmOperator *op)
if (!is_animation) { /* same as invoke */
/* render image */
- screen_opengl_render_apply(op->customdata);
+ screen_opengl_render_apply(C, op->customdata);
screen_opengl_render_end(C, op->customdata);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index ae938c3fa30..1261ff43854 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -313,11 +313,24 @@ static void set_preview_layer(SceneLayer *scene_layer, char pr_type)
lc->flag = COLLECTION_VISIBLE;
}
else {
- lc->flag = 0;
+ lc->flag = COLLECTION_DISABLED;
}
}
}
+static World *preview_get_localized_world(ShaderPreview *sp, World *world)
+{
+ if (world == NULL) {
+ return NULL;
+ }
+ if (sp->worldcopy != NULL) {
+ return sp->worldcopy;
+ }
+ sp->worldcopy = localize_world(world);
+ BLI_addtail(&sp->pr_main->world, sp->worldcopy);
+ return sp->worldcopy;
+}
+
/* 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(Main *bmain, Scene *scene, ID *id, int id_type, ShaderPreview *sp)
@@ -329,7 +342,7 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty
sce = preview_get_scene(pr_main);
if (sce) {
- SceneLayer *scene_layer = BKE_scene_layer_render_active(sce);
+ SceneLayer *scene_layer = BKE_scene_layer_from_scene_get(sce);
/* this flag tells render to not execute depsgraph or ipos etc */
sce->r.scemode |= R_BUTS_PREVIEW;
@@ -439,8 +452,9 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty
}
else {
/* use current scene world to light sphere */
- if (mat->pr_type == MA_SPHERE_A)
- sce->world = scene->world;
+ if (mat->pr_type == MA_SPHERE_A) {
+ sce->world = preview_get_localized_world(sp, scene->world);
+ }
}
if (sp->pr_method == PR_ICON_RENDER) {
@@ -452,7 +466,7 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty
/* same as above, use current scene world to light sphere */
if (BKE_scene_use_new_shading_nodes(scene))
- sce->world = scene->world;
+ sce->world = preview_get_localized_world(sp, scene->world);
}
}
else {
@@ -541,7 +555,7 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty
if (!BKE_scene_use_new_shading_nodes(scene)) {
if (la && la->type == LA_SUN && (la->sun_effect_type & LA_SUN_EFFECT_SKY)) {
set_preview_layer(scene_layer, MA_ATMOS);
- sce->world = scene->world;
+ sce->world = preview_get_localized_world(sp, scene->world);
sce->camera = (Object *)BLI_findstring(&pr_main->object, "CameraAtmo", offsetof(ID, name) + 2);
}
else {
@@ -1252,7 +1266,7 @@ void ED_preview_icon_render(Main *bmain, Scene *scene, ID *id, unsigned int *rec
ip.bmain = bmain;
ip.scene = scene;
- ip.owner = id;
+ ip.owner = BKE_previewimg_id_ensure(id);
ip.id = id;
icon_preview_add_size(&ip, rect, sizex, sizey);
diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index 43e66fae56c..58dd67f4923 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -656,7 +656,7 @@ static int render_layer_remove_exec(bContext *C, wmOperator *UNUSED(op))
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
- SceneLayer *sl = BKE_scene_layer_context_active(scene);
+ SceneLayer *sl = CTX_data_scene_layer(C);
if (!ED_scene_render_layer_delete(bmain, scene, sl, NULL)) {
return OPERATOR_CANCELLED;
@@ -1302,16 +1302,16 @@ static int freestyle_modifier_copy_exec(bContext *C, wmOperator *op)
switch (freestyle_get_modifier_type(&ptr)) {
case LS_MODIFIER_TYPE_COLOR:
- BKE_linestyle_color_modifier_copy(lineset->linestyle, modifier);
+ BKE_linestyle_color_modifier_copy(lineset->linestyle, modifier, 0);
break;
case LS_MODIFIER_TYPE_ALPHA:
- BKE_linestyle_alpha_modifier_copy(lineset->linestyle, modifier);
+ BKE_linestyle_alpha_modifier_copy(lineset->linestyle, modifier, 0);
break;
case LS_MODIFIER_TYPE_THICKNESS:
- BKE_linestyle_thickness_modifier_copy(lineset->linestyle, modifier);
+ BKE_linestyle_thickness_modifier_copy(lineset->linestyle, modifier, 0);
break;
case LS_MODIFIER_TYPE_GEOMETRY:
- BKE_linestyle_geometry_modifier_copy(lineset->linestyle, modifier);
+ BKE_linestyle_geometry_modifier_copy(lineset->linestyle, modifier, 0);
break;
default:
BKE_report(op->reports, RPT_ERROR, "The object the data pointer refers to is not a valid modifier");
@@ -1785,6 +1785,8 @@ static void copy_mtex_copybuf(ID *id)
case ID_LS:
mtex = &(((FreestyleLineStyle *)id)->mtex[(int)((FreestyleLineStyle *)id)->texact]);
break;
+ default:
+ break;
}
if (mtex && *mtex) {
@@ -1822,7 +1824,7 @@ static void paste_mtex_copybuf(ID *id)
mtex = &(((FreestyleLineStyle *)id)->mtex[(int)((FreestyleLineStyle *)id)->texact]);
break;
default:
- BLI_assert("invalid id type");
+ BLI_assert(!"invalid id type");
return;
}
diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c
index b8f64c1db58..ccea1e5930c 100644
--- a/source/blender/editors/render/render_update.c
+++ b/source/blender/editors/render/render_update.c
@@ -41,6 +41,8 @@
#include "DNA_world_types.h"
#include "DNA_windowmanager_types.h"
+#include "DRW_engine.h"
+
#include "BLI_listbase.h"
#include "BLI_threads.h"
#include "BLI_utildefines.h"
@@ -137,6 +139,16 @@ void ED_render_scene_update(Main *bmain, Scene *scene, int updated)
engine->flag &= ~RE_ENGINE_DO_UPDATE;
engine->type->view_update(engine, C);
+
+ }
+ else if ((RE_engines_find(scene->r.engine)->flag & RE_USE_LEGACY_PIPELINE) == 0) {
+ if (updated) {
+ CTX_wm_screen_set(C, sc);
+ CTX_wm_area_set(C, sa);
+ CTX_wm_region_set(C, ar);
+
+ DRW_notify_view_update(C);
+ }
}
}
}
@@ -202,7 +214,7 @@ void ED_render_engine_changed(Main *bmain)
}
/***************************** Updates ***********************************
- * ED_render_id_flush_update gets called from DAG_id_tag_update, to do *
+ * ED_render_id_flush_update gets called from DEG_id_tag_update, to do *
* editor level updates when the ID changes. when these ID blocks are in *
* the dependency graph, we can get rid of the manual dependency checks */
@@ -299,8 +311,11 @@ static void material_changed(Main *bmain, Material *ma)
BKE_icon_changed(BKE_icon_id_ensure(&ma->id));
/* glsl */
- if (ma->gpumaterial.first)
- GPU_material_free(&ma->gpumaterial);
+ if (ma->id.tag & LIB_TAG_ID_RECALC) {
+ if (!BLI_listbase_is_empty(&ma->gpumaterial)) {
+ GPU_material_free(&ma->gpumaterial);
+ }
+ }
/* find node materials using this */
for (parent = bmain->mat.first; parent; parent = parent->id.next) {
@@ -348,7 +363,6 @@ static void material_changed(Main *bmain, Material *ma)
static void lamp_changed(Main *bmain, Lamp *la)
{
Object *ob;
- Material *ma;
/* icons */
BKE_icon_changed(BKE_icon_id_ensure(&la->id));
@@ -358,10 +372,6 @@ static void lamp_changed(Main *bmain, Lamp *la)
if (ob->data == la && ob->gpulamp.first)
GPU_lamp_free(ob);
- for (ma = bmain->mat.first; ma; ma = ma->id.next)
- if (ma->gpumaterial.first)
- GPU_material_free(&ma->gpumaterial);
-
if (defmaterial.gpumaterial.first)
GPU_material_free(&defmaterial.gpumaterial);
}
@@ -476,26 +486,23 @@ static void texture_changed(Main *bmain, Tex *tex)
}
}
-static void world_changed(Main *bmain, World *wo)
+static void world_changed(Main *UNUSED(bmain), World *wo)
{
- Material *ma;
-
/* icons */
BKE_icon_changed(BKE_icon_id_ensure(&wo->id));
/* XXX temporary flag waiting for depsgraph proper tagging */
wo->update_flag = 1;
-
- /* glsl */
- for (ma = bmain->mat.first; ma; ma = ma->id.next)
- if (ma->gpumaterial.first)
- GPU_material_free(&ma->gpumaterial);
- if (defmaterial.gpumaterial.first)
- GPU_material_free(&defmaterial.gpumaterial);
-
- if (wo->gpumaterial.first)
- GPU_material_free(&wo->gpumaterial);
+ /* glsl */
+ if (wo->id.tag & LIB_TAG_ID_RECALC) {
+ if (!BLI_listbase_is_empty(&defmaterial.gpumaterial)) {
+ GPU_material_free(&defmaterial.gpumaterial);
+ }
+ if (!BLI_listbase_is_empty(&wo->gpumaterial)) {
+ GPU_material_free(&wo->gpumaterial);
+ }
+ }
}
static void image_changed(Main *bmain, Image *ima)
@@ -517,30 +524,12 @@ static void scene_changed(Main *bmain, Scene *scene)
/* glsl */
for (ob = bmain->object.first; ob; ob = ob->id.next) {
-#if 0 /* This was needed by old glsl where all lighting was statically linked into the shader. */
- if (ob->gpulamp.first)
- GPU_lamp_free(ob);
-#endif
-
if (ob->mode & OB_MODE_TEXTURE_PAINT) {
BKE_texpaint_slots_refresh_object(scene, ob);
BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
GPU_drawobject_free(ob->derivedFinal);
}
}
-
-#if 0 /* This was needed by old glsl where all lighting was statically linked into the shader. */
- for (Material *ma = bmain->mat.first; ma; ma = ma->id.next)
- if (ma->gpumaterial.first)
- GPU_material_free(&ma->gpumaterial);
-
- for (World *wo = bmain->world.first; wo; wo = wo->id.next)
- if (wo->gpumaterial.first)
- GPU_material_free(&wo->gpumaterial);
-
- if (defmaterial.gpumaterial.first)
- GPU_material_free(&defmaterial.gpumaterial);
-#endif
}
void ED_render_id_flush_update(Main *bmain, ID *id)
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 5eb51667988..0c8ca2a5b87 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -228,7 +228,7 @@ static void area_draw_azone_fullscreen(short x1, short y1, short x2, short y2, f
immAttrib4ub(color, 255, 0, 0, alpha_debug);
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
- imm_draw_line_box(pos, click_rect.xmin, click_rect.ymin, click_rect.xmax, click_rect.ymax);
+ imm_draw_box_wire_2d(pos, click_rect.xmin, click_rect.ymin, click_rect.xmax, click_rect.ymax);
immAttrib4ub(color, 0, 255, 255, alpha_debug);
immBegin(GWN_PRIM_LINES, 4);
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c
index 3c7ea9a0f7e..5813f317295 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -57,6 +57,7 @@
#include "ED_armature.h"
#include "ED_gpencil.h"
+#include "ED_anim_api.h"
#include "WM_api.h"
#include "UI_interface.h"
@@ -78,7 +79,7 @@ const char *screen_context_dir[] = {
"visible_gpencil_layers", "editable_gpencil_layers", "editable_gpencil_strokes",
"active_gpencil_layer", "active_gpencil_frame", "active_gpencil_palette",
"active_gpencil_palettecolor", "active_gpencil_brush",
- "active_operator",
+ "active_operator", "selected_editable_fcurves",
NULL};
int ed_screen_context(const bContext *C, const char *member, bContextDataResult *result)
@@ -87,9 +88,8 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
bScreen *sc = CTX_wm_screen(C);
ScrArea *sa = CTX_wm_area(C);
Scene *scene = WM_window_get_active_scene(win);
- /* can't call BKE_scene_layer_context_active here, it uses G.main->wm which might be NULL on file read. */
WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook);
- SceneLayer *sl = BKE_workspace_render_layer_get(workspace);
+ SceneLayer *sl = BKE_scene_layer_from_workspace_get(workspace);
Object *obedit = scene->obedit;
Object *obact = sl->basact ? sl->basact->object : NULL;
@@ -610,6 +610,29 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
return 1;
}
}
+ else if (CTX_data_equals(member, "selected_editable_fcurves")) {
+ bAnimContext ac;
+
+ if (ANIM_animdata_get_context(C, &ac) && ELEM(ac.spacetype, SPACE_ACTION, SPACE_IPO)) {
+ bAnimListElem *ale;
+ ListBase anim_data = {NULL, NULL};
+
+ int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS | ANIMFILTER_SEL) |
+ (ac.spacetype == SPACE_IPO ? ANIMFILTER_CURVE_VISIBLE : ANIMFILTER_LIST_VISIBLE);
+
+ ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+
+ for (ale = anim_data.first; ale; ale = ale->next) {
+ if (ale->type == ANIMTYPE_FCURVE)
+ CTX_data_list_add(result, ale->id, &RNA_FCurve, ale->data);
+ }
+
+ ANIM_animdata_freelist(&anim_data);
+
+ CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
+ return 1;
+ }
+ }
else {
return 0; /* not found */
}
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index c97b52ae1cd..fca2def644c 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -463,8 +463,8 @@ bScreen *screen_add(const char *name, const int winsize_x, const int winsize_y)
{
bScreen *sc;
ScrVert *sv1, *sv2, *sv3, *sv4;
-
- sc = BKE_libblock_alloc(G.main, ID_SCR, name);
+
+ sc = BKE_libblock_alloc(G.main, ID_SCR, name, 0);
sc->do_refresh = true;
sc->redraws_flag = TIME_ALL_3D_WIN | TIME_ALL_ANIM_WIN;
@@ -472,15 +472,15 @@ bScreen *screen_add(const char *name, const int winsize_x, const int winsize_y)
sv2 = screen_addvert(sc, 0, winsize_y - 1);
sv3 = screen_addvert(sc, winsize_x - 1, winsize_y - 1);
sv4 = screen_addvert(sc, winsize_x - 1, 0);
-
+
screen_addedge(sc, sv1, sv2);
screen_addedge(sc, sv2, sv3);
screen_addedge(sc, sv3, sv4);
screen_addedge(sc, sv4, sv1);
-
+
/* dummy type, no spacedata */
screen_addarea(sc, sv1, sv2, sv3, sv4, HEADERDOWN, SPACE_EMPTY);
-
+
return sc;
}
@@ -856,8 +856,10 @@ static void region_cursor_set(wmWindow *win, int swinid, int swin_changed)
for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->swinid == swinid) {
if (swin_changed || (ar->type && ar->type->event_cursor)) {
- if (WM_manipulatormap_cursor_set(ar->manipulator_map, win)) {
- return;
+ if (ar->manipulator_map != NULL) {
+ if (WM_manipulatormap_cursor_set(ar->manipulator_map, win)) {
+ return;
+ }
}
ED_region_cursor_set(win, sa, ar);
}
@@ -923,6 +925,7 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
winrct.ymax = winsize_y - 1;
/* header size depends on DPI, let's verify */
+ WM_window_set_dpi(win);
screen_refresh_headersizes();
screen_test_scale(screen, winsize_x, winsize_y);
@@ -989,7 +992,7 @@ void ED_region_exit(bContext *C, ARegion *ar)
wm_subwindow_close(win, ar->swinid);
ar->swinid = 0;
}
-
+
if (ar->headerstr) {
MEM_freeN(ar->headerstr);
ar->headerstr = NULL;
@@ -1469,17 +1472,28 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
if (sa && sa->full) {
WorkSpaceLayout *layout_old = WM_window_get_active_layout(win);
/* restoring back to SCREENNORMAL */
- ScrArea *old;
-
sc = sa->full; /* the old screen to restore */
oldscreen = WM_window_get_active_screen(win); /* the one disappearing */
sc->state = SCREENNORMAL;
- /* find old area */
- for (old = sc->areabase.first; old; old = old->next)
- if (old->full) break;
- if (old == NULL) {
+ /* find old area to restore from */
+ ScrArea *fullsa = NULL;
+ for (ScrArea *old = sc->areabase.first; old; old = old->next) {
+ /* area to restore from is always first */
+ if (old->full && !fullsa) {
+ fullsa = old;
+ }
+
+ /* clear full screen state */
+ old->full = NULL;
+ old->flag &= ~AREA_TEMP_INFO;
+ }
+
+ sa->flag &= ~AREA_TEMP_INFO;
+ sa->full = NULL;
+
+ if (fullsa == NULL) {
if (G.debug & G_DEBUG)
printf("%s: something wrong in areafullscreen\n", __func__);
return NULL;
@@ -1492,9 +1506,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
}
}
- ED_area_data_swap(old, sa);
- if (sa->flag & AREA_TEMP_INFO) sa->flag &= ~AREA_TEMP_INFO;
- old->full = NULL;
+ ED_area_data_swap(fullsa, sa);
/* animtimer back */
sc->animtimer = oldscreen->animtimer;
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index b8fa16117a9..326421cf166 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -2274,25 +2274,28 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
BLI_dlrbTree_linkedlist_sync(&keys);
/* find matching keyframe in the right direction */
- do {
- if (next)
- ak = (ActKeyColumn *)BLI_dlrbTree_search_next(&keys, compare_ak_cfraPtr, &cfra);
- else
- ak = (ActKeyColumn *)BLI_dlrbTree_search_prev(&keys, compare_ak_cfraPtr, &cfra);
-
- if (ak) {
- if (CFRA != (int)ak->cfra) {
- /* this changes the frame, so set the frame and we're done */
- CFRA = (int)ak->cfra;
- done = true;
+ if (next)
+ ak = (ActKeyColumn *)BLI_dlrbTree_search_next(&keys, compare_ak_cfraPtr, &cfra);
+ else
+ ak = (ActKeyColumn *)BLI_dlrbTree_search_prev(&keys, compare_ak_cfraPtr, &cfra);
+
+ while ((ak != NULL) && (done == false)) {
+ if (CFRA != (int)ak->cfra) {
+ /* this changes the frame, so set the frame and we're done */
+ CFRA = (int)ak->cfra;
+ done = true;
+ }
+ else {
+ /* take another step... */
+ if (next) {
+ ak = ak->next;
}
else {
- /* make this the new starting point for the search */
- cfra = ak->cfra;
+ ak = ak->prev;
}
}
- } while ((ak != NULL) && (done == false));
-
+ }
+
/* free temp stuff */
BLI_dlrbTree_free(&keys);
diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c
index 6fa8905293c..69891a727d4 100644
--- a/source/blender/editors/screen/screendump.c
+++ b/source/blender/editors/screen/screendump.c
@@ -462,10 +462,10 @@ static void screencast_draw_cursor(bContext *UNUSED(C), int x, int y, void *UNUS
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4ub(0, 0, 0, 32);
- imm_draw_circle_fill(pos, (float)x, (float)y, 20, 40);
+ imm_draw_circle_fill_2d(pos, (float)x, (float)y, 20, 40);
immUniformColor4ub(255, 255, 255, 128);
- imm_draw_circle_wire(pos, (float)x, (float)y, 20, 40);
+ imm_draw_circle_wire_2d(pos, (float)x, (float)y, 20, 40);
immUnbindProgram();
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c
index 34def82f16e..00a965beae7 100644
--- a/source/blender/editors/screen/workspace_edit.c
+++ b/source/blender/editors/screen/workspace_edit.c
@@ -239,7 +239,7 @@ WorkSpace *ED_workspace_duplicate(
* \return if succeeded.
*/
bool ED_workspace_delete(
- WorkSpace *workspace, Main *bmain, bContext *C, wmWindowManager *wm, wmWindow *win)
+ WorkSpace *workspace, Main *bmain, bContext *C, wmWindowManager *wm)
{
ID *workspace_id = (ID *)workspace;
@@ -247,7 +247,7 @@ bool ED_workspace_delete(
return false;
}
- if (WM_window_get_active_workspace(win) == workspace) {
+ for (wmWindow *win = wm->windows.first; win; win = win->next) {
WorkSpace *prev = workspace_id->prev;
WorkSpace *next = workspace_id->next;
@@ -315,7 +315,7 @@ static int workspace_delete_exec(bContext *C, wmOperator *UNUSED(op))
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
- ED_workspace_delete(WM_window_get_active_workspace(win), bmain, C, wm, win);
+ ED_workspace_delete(WM_window_get_active_workspace(win), bmain, C, wm);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt
index ead420b1faa..b3e125baae3 100644
--- a/source/blender/editors/sculpt_paint/CMakeLists.txt
+++ b/source/blender/editors/sculpt_paint/CMakeLists.txt
@@ -53,6 +53,10 @@ set(SRC
paint_undo.c
paint_utils.c
paint_vertex.c
+ paint_vertex_color_ops.c
+ paint_vertex_color_utils.c
+ paint_vertex_weight_ops.c
+ paint_vertex_weight_utils.c
paint_vertex_proj.c
sculpt.c
sculpt_undo.c
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index a9b4df81277..befb635cfc4 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -42,6 +42,7 @@
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_userdef_types.h"
+#include "DNA_view3d_types.h"
#include "BKE_brush.h"
#include "BKE_context.h"
@@ -849,12 +850,12 @@ BLI_INLINE void draw_rect_point(
float maxx = co[0] + w;
float maxy = co[1] + w;
- imm_draw_line_box(pos, minx, miny, maxx, maxy);
+ imm_draw_box_wire_2d(pos, minx, miny, maxx, maxy);
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.5f);
glLineWidth(1.0f);
- imm_draw_line_box(pos, minx, miny, maxx, maxy);
+ imm_draw_box_wire_2d(pos, minx, miny, maxx, maxy);
}
@@ -1024,9 +1025,9 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
ViewContext vc;
view3d_set_viewcontext(C, &vc);
- float zoomx, zoomy;
- get_imapaint_zoom(C, &zoomx, &zoomy);
- zoomx = max_ff(zoomx, zoomy);
+ if (vc.rv3d->rflag & RV3D_NAVIGATING) {
+ return;
+ }
/* skip everything and draw brush here */
if (brush->flag & BRUSH_CURVE) {
@@ -1034,6 +1035,10 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
return;
}
+ float zoomx, zoomy;
+ get_imapaint_zoom(C, &zoomx, &zoomy);
+ zoomx = max_ff(zoomx, zoomy);
+
/* set various defaults */
const float *outline_col = brush->add_col;
const float outline_alpha = 0.5f;
@@ -1064,11 +1069,8 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
/* check if brush is subtracting, use different color then */
/* TODO: no way currently to know state of pen flip or
* invert key modifier without starting a stroke */
- if (((ups->draw_inverted == 0) ^
- ((brush->flag & BRUSH_DIR_IN) == 0)) &&
- ELEM(brush->sculpt_tool, SCULPT_TOOL_DRAW,
- SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY,
- SCULPT_TOOL_PINCH, SCULPT_TOOL_CREASE))
+ if (((ups->draw_inverted == 0) ^ ((brush->flag & BRUSH_DIR_IN) == 0)) &&
+ BKE_brush_sculpt_has_secondary_color(brush))
{
outline_col = brush->sub_col;
}
@@ -1098,11 +1100,11 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
/* draw brush outline */
if (ups->stroke_active && BKE_brush_use_size_pressure(scene, brush)) {
/* inner at full alpha */
- imm_draw_circle_wire(pos, translation[0], translation[1], final_radius * ups->size_pressure_value, 40);
+ imm_draw_circle_wire_2d(pos, translation[0], translation[1], final_radius * ups->size_pressure_value, 40);
/* outer at half alpha */
immUniformColor3fvAlpha(outline_col, outline_alpha * 0.5f);
}
- imm_draw_circle_wire(pos, translation[0], translation[1], final_radius, 40);
+ imm_draw_circle_wire_2d(pos, translation[0], translation[1], final_radius, 40);
immUnbindProgram();
diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c
index d7c3b7377da..d2e2df01238 100644
--- a/source/blender/editors/sculpt_paint/paint_hide.c
+++ b/source/blender/editors/sculpt_paint/paint_hide.c
@@ -52,6 +52,8 @@
#include "BKE_paint.h"
#include "BKE_subsurf.h"
+#include "DEG_depsgraph.h"
+
#include "WM_api.h"
#include "WM_types.h"
@@ -360,6 +362,7 @@ static int hide_show_exec(bContext *C, wmOperator *op)
{
ARegion *ar = CTX_wm_region(C);
Object *ob = CTX_data_active_object(C);
+ EvaluationContext eval_ctx;
Mesh *me = ob->data;
PartialVisAction action;
PartialVisArea area;
@@ -371,6 +374,8 @@ static int hide_show_exec(bContext *C, wmOperator *op)
rcti rect;
int totnode, i;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
/* read operator properties */
action = RNA_enum_get(op->ptr, "action");
area = RNA_enum_get(op->ptr, "area");
@@ -378,7 +383,7 @@ static int hide_show_exec(bContext *C, wmOperator *op)
clip_planes_from_rect(C, clip_planes, &rect);
- dm = mesh_get_derived_final(CTX_data_scene(C), ob, CD_MASK_BAREMESH);
+ dm = mesh_get_derived_final(&eval_ctx, CTX_data_scene(C), ob, CD_MASK_BAREMESH);
pbvh = dm->getPBVH(ob, dm);
ob->sculpt->pbvh = pbvh;
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 8c6b3b0106c..e324f2b89f0 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -766,7 +766,7 @@ static PaintOperation *texture_paint_init(bContext *C, wmOperator *op, const flo
/* initialize from context */
if (CTX_wm_region_view3d(C)) {
SceneLayer *sl = CTX_data_scene_layer(C);
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
bool uvs, mat, tex, stencil;
if (!BKE_paint_proj_mesh_data_check(scene, ob, &uvs, &mat, &tex, &stencil)) {
BKE_paint_data_warning(op->reports, uvs, mat, tex, stencil);
@@ -1470,7 +1470,20 @@ void PAINT_OT_texture_paint_toggle(wmOperatorType *ot)
static int brush_colors_flip_exec(bContext *C, wmOperator *UNUSED(op))
{
UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings;
- Brush *br = image_paint_brush(C);
+
+ Brush *br;
+ Object *ob = CTX_data_active_object(C);
+ if (!(ob && (ob->mode & OB_MODE_VERTEX_PAINT))) {
+ br = image_paint_brush(C);
+ }
+ else {
+ /* At the moment, wpaint does not support the color flipper.
+ * So for now we're only handling vpaint */
+ ToolSettings *ts = CTX_data_tool_settings(C);
+ VPaint *vp = ts->vpaint;
+ br = BKE_paint_brush(&vp->paint);
+ }
+
if (ups->flag & UNIFIED_PAINT_COLOR) {
swap_v3_v3(ups->rgb, ups->secondary_rgb);
}
@@ -1489,7 +1502,12 @@ static int brush_colors_flip_poll(bContext *C)
if (br->imagepaint_tool == PAINT_TOOL_DRAW)
return 1;
}
-
+ else {
+ Object *ob = CTX_data_active_object(C);
+ if (ob && (ob->mode & OB_MODE_VERTEX_PAINT)) {
+ return 1;
+ }
+ }
return 0;
}
diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c
index eb6eebf3c54..30830e4e7bc 100644
--- a/source/blender/editors/sculpt_paint/paint_image_2d.c
+++ b/source/blender/editors/sculpt_paint/paint_image_2d.c
@@ -798,6 +798,7 @@ static void paint_2d_ibuf_rgb_set(ImBuf *ibuf, int x, int y, const bool is_torus
float map_alpha = (rgb[3] == 0.0f) ? rrgbf[3] : rrgbf[3] / rgb[3];
mul_v3_v3fl(rrgbf, rgb, map_alpha);
+ rrgbf[3] = rgb[3];
}
else {
unsigned char straight[4];
@@ -807,6 +808,7 @@ static void paint_2d_ibuf_rgb_set(ImBuf *ibuf, int x, int y, const bool is_torus
rrgb[0] = straight[0];
rrgb[1] = straight[1];
rrgb[2] = straight[2];
+ rrgb[3] = straight[3];
}
}
@@ -996,7 +998,7 @@ static void paint_2d_lift_smear(ImBuf *ibuf, ImBuf *ibufb, int *pos, short tile)
IMB_rectblend(ibufb, ibufb, ibuf, NULL, NULL, NULL, 0, region[a].destx, region[a].desty,
region[a].destx, region[a].desty,
region[a].srcx, region[a].srcy,
- region[a].width, region[a].height, IMB_BLEND_COPY_RGB, false);
+ region[a].width, region[a].height, IMB_BLEND_COPY, false);
}
static ImBuf *paint_2d_lift_clone(ImBuf *ibuf, ImBuf *ibufb, int *pos)
@@ -1097,6 +1099,7 @@ static int paint_2d_op(void *state, ImBuf *ibufb, unsigned short *curveb, unsign
/* lift from canvas */
if (s->tool == PAINT_TOOL_SOFTEN) {
paint_2d_lift_soften(s, s->canvas, ibufb, bpos, tile);
+ blend = IMB_BLEND_INTERPOLATE;
}
else if (s->tool == PAINT_TOOL_SMEAR) {
if (lastpos[0] == pos[0] && lastpos[1] == pos[1])
@@ -1104,6 +1107,7 @@ static int paint_2d_op(void *state, ImBuf *ibufb, unsigned short *curveb, unsign
paint_2d_convert_brushco(ibufb, lastpos, blastpos);
paint_2d_lift_smear(s->canvas, ibufb, blastpos, tile);
+ blend = IMB_BLEND_INTERPOLATE;
}
else if (s->tool == PAINT_TOOL_CLONE && s->clonecanvas) {
liftpos[0] = pos[0] - offset[0] * s->canvas->x;
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index d47c96bf22c..2ffd9757f92 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -3421,12 +3421,15 @@ static void project_paint_bleed_add_face_user(
#endif
/* Return true if DM can be painted on, false otherwise */
-static bool proj_paint_state_dm_init(ProjPaintState *ps)
+static bool proj_paint_state_dm_init(const bContext *C, ProjPaintState *ps)
{
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
/* Workaround for subsurf selection, try the display mesh first */
if (ps->source == PROJ_SRC_IMAGE_CAM) {
/* using render mesh, assume only camera was rendered from */
- ps->dm = mesh_create_derived_render(ps->scene, ps->ob, ps->scene->customdata_mask | CD_MASK_MTFACE);
+ ps->dm = mesh_create_derived_render(&eval_ctx, ps->scene, ps->ob, ps->scene->customdata_mask | CD_MASK_MTFACE);
ps->dm_release = true;
}
else if (ps->ob->derivedFinal &&
@@ -3438,7 +3441,7 @@ static bool proj_paint_state_dm_init(ProjPaintState *ps)
}
else {
ps->dm = mesh_get_derived_final(
- ps->scene, ps->ob,
+ &eval_ctx, ps->scene, ps->ob,
ps->scene->customdata_mask | CD_MASK_MTFACE | (ps->do_face_sel ? CD_ORIGINDEX : 0));
ps->dm_release = true;
}
@@ -3713,8 +3716,12 @@ static void project_paint_prepare_all_faces(
}
/* don't allow using the same inage for painting and stencilling */
- if (slot->ima == ps->stencil_ima)
+ if (slot->ima == ps->stencil_ima) {
+ /* While this shouldn't be used, face-winding reads all polys.
+ * It's less trouble to set all faces to valid UV's, avoiding NULL checks all over. */
+ ps->dm_mloopuv[lt->poly] = mloopuv_base;
continue;
+ }
tpage = slot->ima;
}
@@ -3814,7 +3821,7 @@ static void project_paint_prepare_all_faces(
/* run once per stroke before projection painting */
static void project_paint_begin(
- ProjPaintState *ps,
+ const bContext *C, ProjPaintState *ps,
const bool is_multi_view, const char symmetry_flag)
{
ProjPaintLayerClone layer_clone;
@@ -3837,7 +3844,7 @@ static void project_paint_begin(
/* paint onto the derived mesh */
if (ps->is_shared_user == false) {
- if (!proj_paint_state_dm_init(ps)) {
+ if (!proj_paint_state_dm_init(C, ps)) {
return;
}
}
@@ -4292,7 +4299,7 @@ static void do_projectpaint_soften_f(ProjPaintState *ps, ProjPixel *projPixel, f
return;
}
else {
- blend_color_interpolate_float(rgba, rgba, projPixel->pixel.f_pt, mask);
+ blend_color_interpolate_float(rgba, projPixel->pixel.f_pt, rgba, mask);
}
BLI_linklist_prepend_arena(softenPixels, (void *)projPixel, softenArena);
@@ -4751,6 +4758,9 @@ static void *do_projectpaint_thread(void *ph_v)
copy_v3_v3(texrgb, texrgba);
mask *= texrgba[3];
}
+ else {
+ zero_v3(texrgb);
+ }
/* extra mask for normal, layer stencil, .. */
mask *= ((float)projPixel->mask) * (1.0f / 65535.0f);
@@ -5017,6 +5027,7 @@ void paint_proj_stroke(
/* clone gets special treatment here to avoid going through image initialization */
if (ps_handle->is_clone_cursor_pick) {
+ EvaluationContext eval_ctx;
Scene *scene = ps_handle->scene;
struct Depsgraph *graph = CTX_data_depsgraph(C);
View3D *v3d = CTX_wm_view3d(C);
@@ -5026,7 +5037,9 @@ void paint_proj_stroke(
view3d_operator_needs_opengl(C);
- if (!ED_view3d_autodist(graph, ar, v3d, mval_i, cursor, false, NULL)) {
+ CTX_data_eval_ctx(C, &eval_ctx);
+
+ if (!ED_view3d_autodist(&eval_ctx, graph, ar, v3d, mval_i, cursor, false, NULL)) {
return;
}
@@ -5230,7 +5243,7 @@ void *paint_proj_new_stroke(bContext *C, Object *ob, const float mouse[2], int m
PROJ_PAINT_STATE_SHARED_MEMCPY(ps, ps_handle->ps_views[0]);
}
- project_paint_begin(ps, is_multi_view, symmetry_flag_views[i]);
+ project_paint_begin(C, ps, is_multi_view, symmetry_flag_views[i]);
paint_proj_begin_clone(ps, mouse);
@@ -5313,7 +5326,7 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op)
int orig_brush_size;
IDProperty *idgroup;
IDProperty *view_data = NULL;
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
bool uvs, mat, tex;
if (ob == NULL || ob->type != OB_MESH) {
@@ -5384,7 +5397,7 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op)
ED_image_undo_restore, ED_image_undo_free, NULL);
/* allocate and initialize spatial data structures */
- project_paint_begin(&ps, false, 0);
+ project_paint_begin(C, &ps, false, 0);
if (ps.dm == NULL) {
BKE_brush_size_set(scene, ps.brush, orig_brush_size);
@@ -5443,12 +5456,15 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
SceneLayer *sl = CTX_data_scene_layer(C);
+ EvaluationContext eval_ctx;
ToolSettings *settings = scene->toolsettings;
int w = settings->imapaint.screen_grab_size[0];
int h = settings->imapaint.screen_grab_size[1];
int maxsize;
char err_out[256] = "unknown";
+ CTX_data_eval_ctx(C, &eval_ctx);
+
RNA_string_get(op->ptr, "filepath", filename);
maxsize = GPU_max_texture_size();
@@ -5457,7 +5473,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
if (h > maxsize) h = maxsize;
ibuf = ED_view3d_draw_offscreen_imbuf(
- scene, sl, CTX_wm_view3d(C), CTX_wm_region(C),
+ &eval_ctx, scene, sl, CTX_wm_view3d(C), CTX_wm_region(C),
w, h, IB_rect, false, R_ALPHAPREMUL, 0, false, NULL,
NULL, NULL, err_out);
if (!ibuf) {
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index 69c4621945b..b3b7d40391a 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -96,21 +96,11 @@ int weight_paint_mode_poll(struct bContext *C);
int vertex_paint_poll(struct bContext *C);
int vertex_paint_mode_poll(struct bContext *C);
-bool ED_vpaint_fill(struct Object *ob, unsigned int paintcol);
-bool ED_wpaint_fill(struct VPaint *wp, struct Object *ob, float paintweight);
-
-bool ED_vpaint_smooth(struct Object *ob);
-
typedef void (*VPaintTransform_Callback)(const float col[3], const void *user_data, float r_col[3]);
-bool ED_vpaint_color_transform(struct Object *ob, VPaintTransform_Callback vpaint_tx_fn, const void *user_data);
-
void PAINT_OT_weight_paint_toggle(struct wmOperatorType *ot);
void PAINT_OT_weight_paint(struct wmOperatorType *ot);
void PAINT_OT_weight_set(struct wmOperatorType *ot);
-void PAINT_OT_weight_from_bones(struct wmOperatorType *ot);
-void PAINT_OT_weight_sample(struct wmOperatorType *ot);
-void PAINT_OT_weight_sample_group(struct wmOperatorType *ot);
enum {
WPAINT_GRADIENT_TYPE_LINEAR,
@@ -123,14 +113,52 @@ void PAINT_OT_vertex_paint(struct wmOperatorType *ot);
unsigned int vpaint_get_current_col(struct Scene *scene, struct VPaint *vp);
+/* paint_vertex_color_utils.c */
+unsigned int ED_vpaint_blend_tool(
+ const int tool, const uint col,
+ const uint paintcol, const int alpha_i);
+bool ED_vpaint_color_transform(
+ struct Object *ob, VPaintTransform_Callback vpaint_tx_fn, const void *user_data);
+
+/* paint_vertex_weight_utils.c */
+float ED_wpaint_blend_tool(
+ const int tool,
+ const float weight,
+ const float paintval, const float alpha);
+/* Utility for tools to ensure vertex groups exist before they begin. */
+enum eWPaintFlag {
+ WPAINT_ENSURE_MIRROR = (1 << 0),
+};
+struct WPaintVGroupIndex {
+ int active;
+ int mirror;
+};
+bool ED_wpaint_ensure_data(
+ struct bContext *C, struct ReportList *reports,
+ enum eWPaintFlag flag, struct WPaintVGroupIndex *vgroup_index);
+int ED_wpaint_mirror_vgroup_ensure(struct Object *ob, const int vgroup_active);
+
+/* paint_vertex_color_ops.c */
+void PAINT_OT_vertex_color_set(struct wmOperatorType *ot);
+void PAINT_OT_vertex_color_from_weight(struct wmOperatorType *ot);
+void PAINT_OT_vertex_color_smooth(struct wmOperatorType *ot);
+void PAINT_OT_vertex_color_brightness_contrast(struct wmOperatorType *ot);
+void PAINT_OT_vertex_color_hsv(struct wmOperatorType *ot);
+void PAINT_OT_vertex_color_invert(struct wmOperatorType *ot);
+void PAINT_OT_vertex_color_levels(struct wmOperatorType *ot);
+
+/* paint_vertex_weight_ops.c */
+void PAINT_OT_weight_from_bones(struct wmOperatorType *ot);
+void PAINT_OT_weight_sample(struct wmOperatorType *ot);
+void PAINT_OT_weight_sample_group(struct wmOperatorType *ot);
/* paint_vertex_proj.c */
struct VertProjHandle;
struct VertProjHandle *ED_vpaint_proj_handle_create(
- struct Scene *scene, struct Object *ob,
+ const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
struct DMCoNo **r_vcosnos);
void ED_vpaint_proj_handle_update(
- struct VertProjHandle *vp_handle,
+ const struct EvaluationContext *eval_ctx, struct VertProjHandle *vp_handle,
/* runtime vars */
struct ARegion *ar, const float mval_fl[2]);
void ED_vpaint_proj_handle_free(
@@ -160,7 +188,7 @@ void set_imapaintpartial(struct ImagePaintPartialRedraw *ippr);
void imapaint_region_tiles(struct ImBuf *ibuf, int x, int y, int w, int h, int *tx, int *ty, int *tw, int *th);
int get_imapaint_zoom(struct bContext *C, float *zoomx, float *zoomy);
void *paint_2d_new_stroke(struct bContext *, struct wmOperator *, int mode);
-void paint_2d_redraw(const bContext *C, void *ps, bool final);
+void paint_2d_redraw(const struct bContext *C, void *ps, bool final);
void paint_2d_stroke_done(void *ps);
void paint_2d_stroke(void *ps, const float prev_mval[2], const float mval[2], const bool eraser, float pressure, float distance, float size);
void paint_2d_bucket_fill(const struct bContext *C, const float color[3], struct Brush *br, const float mouse_init[2], void *ps);
@@ -213,10 +241,10 @@ void paint_calc_redraw_planes(float planes[4][4],
const struct rcti *screen_rect);
float paint_calc_object_space_radius(struct ViewContext *vc, const float center[3], float pixel_radius);
-float paint_get_tex_pixel(struct MTex *mtex, float u, float v, struct ImagePool *pool, int thread);
-void paint_get_tex_pixel_col(struct MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool, int thread, bool convert, struct ColorSpace *colorspace);
+float paint_get_tex_pixel(const struct MTex *mtex, float u, float v, struct ImagePool *pool, int thread);
+void paint_get_tex_pixel_col(const struct MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool, int thread, bool convert, struct ColorSpace *colorspace);
-void paint_sample_color(bContext *C, struct ARegion *ar, int x, int y, bool texpaint_proj, bool palette);
+void paint_sample_color(struct bContext *C, struct ARegion *ar, int x, int y, bool texpaint_proj, bool palette);
void paint_stroke_operator_properties(struct wmOperatorType *ot);
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c
index 1ac40b0354e..b7159c375cd 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -50,6 +50,8 @@
#include "BKE_paint.h"
#include "BKE_subsurf.h"
+#include "DEG_depsgraph.h"
+
#include "RNA_access.h"
#include "RNA_define.h"
@@ -129,6 +131,7 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op)
ARegion *ar = CTX_wm_region(C);
struct Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
+ EvaluationContext eval_ctx;
PaintMaskFloodMode mode;
float value;
PBVH *pbvh;
@@ -137,10 +140,12 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op)
bool multires;
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
mode = RNA_enum_get(op->ptr, "mode");
value = RNA_float_get(op->ptr, "value");
- BKE_sculpt_update_mesh_elements(scene, sd, ob, false, true);
+ BKE_sculpt_update_mesh_elements(&eval_ctx, scene, sd, ob, false, true);
pbvh = ob->sculpt->pbvh;
multires = (BKE_pbvh_type(pbvh) == PBVH_GRIDS);
@@ -247,6 +252,7 @@ static void mask_box_select_task_cb(void *userdata, const int i)
int ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *rect, bool select, bool UNUSED(extend))
{
+ EvaluationContext eval_ctx;
Sculpt *sd = vc->scene->toolsettings->sculpt;
BoundBox bb;
float clip_planes[4][4];
@@ -262,6 +268,8 @@ int ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *r
int totnode, symmpass;
int symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
mode = PAINT_MASK_FLOOD_VALUE;
value = select ? 1.0 : 0.0;
@@ -269,7 +277,7 @@ int ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *r
ED_view3d_clipping_calc(&bb, clip_planes, vc->ar, vc->obact, rect);
negate_m4(clip_planes);
- BKE_sculpt_update_mesh_elements(scene, sd, ob, false, true);
+ BKE_sculpt_update_mesh_elements(&eval_ctx, scene, sd, ob, false, true);
pbvh = ob->sculpt->pbvh;
multires = (BKE_pbvh_type(pbvh) == PBVH_GRIDS);
@@ -405,6 +413,7 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op)
const int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot);
if (mcords) {
+ EvaluationContext eval_ctx;
float clip_planes[4][4], clip_planes_final[4][4];
BoundBox bb;
Object *ob;
@@ -420,6 +429,8 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op)
PaintMaskFloodMode mode = RNA_enum_get(op->ptr, "mode");
float value = RNA_float_get(op->ptr, "value");
+ CTX_data_eval_ctx(C, &eval_ctx);
+
/* Calculations of individual vertices are done in 2D screen space to diminish the amount of
* calculations done. Bounding box PBVH collision is not computed against enclosing rectangle
* of lasso */
@@ -442,7 +453,7 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op)
ED_view3d_clipping_calc(&bb, clip_planes, vc.ar, vc.obact, &data.rect);
negate_m4(clip_planes);
- BKE_sculpt_update_mesh_elements(scene, sd, ob, false, true);
+ BKE_sculpt_update_mesh_elements(&eval_ctx, scene, sd, ob, false, true);
pbvh = ob->sculpt->pbvh;
multires = (BKE_pbvh_type(pbvh) == PBVH_GRIDS);
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index f88b64129e7..2899cfeedcf 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -256,300 +256,6 @@ static void PALETTE_OT_color_delete(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-
-
-static int vertex_color_set_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Scene *scene = CTX_data_scene(C);
- Object *obact = CTX_data_active_object(C);
- unsigned int paintcol = vpaint_get_current_col(scene, scene->toolsettings->vpaint);
-
- if (ED_vpaint_fill(obact, paintcol)) {
- ED_region_tag_redraw(CTX_wm_region(C)); // XXX - should redraw all 3D views
- return OPERATOR_FINISHED;
- }
- else {
- return OPERATOR_CANCELLED;
- }
-}
-
-static void PAINT_OT_vertex_color_set(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Set Vertex Colors";
- ot->idname = "PAINT_OT_vertex_color_set";
- ot->description = "Fill the active vertex color layer with the current paint color";
-
- /* api callbacks */
- ot->exec = vertex_color_set_exec;
- ot->poll = vertex_paint_mode_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
-static int vertex_color_smooth_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Object *obact = CTX_data_active_object(C);
- if (ED_vpaint_smooth(obact)) {
- ED_region_tag_redraw(CTX_wm_region(C)); // XXX - should redraw all 3D views
- return OPERATOR_FINISHED;
- }
- else {
- return OPERATOR_CANCELLED;
- }
-}
-
-static void PAINT_OT_vertex_color_smooth(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Smooth Vertex Colors";
- ot->idname = "PAINT_OT_vertex_color_smooth";
- ot->description = "Smooth colors across vertices";
-
- /* api callbacks */
- ot->exec = vertex_color_smooth_exec;
- ot->poll = vertex_paint_mode_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
-
-/** \name Vertex Color Transformations
- * \{ */
-
-struct VPaintTx_BrightContrastData {
- /* pre-calculated */
- float gain;
- float offset;
-};
-
-static void vpaint_tx_brightness_contrast(const float col[3], const void *user_data, float r_col[3])
-{
- const struct VPaintTx_BrightContrastData *data = user_data;
-
- for (int i = 0; i < 3; i++) {
- r_col[i] = data->gain * col[i] + data->offset;
- }
-}
-
-static int vertex_color_brightness_contrast_exec(bContext *C, wmOperator *op)
-{
- Object *obact = CTX_data_active_object(C);
-
- float gain, offset;
- {
- float brightness = RNA_float_get(op->ptr, "brightness");
- float contrast = RNA_float_get(op->ptr, "contrast");
- brightness /= 100.0f;
- float delta = contrast / 200.0f;
- gain = 1.0f - delta * 2.0f;
- /*
- * The algorithm is by Werner D. Streidt
- * (http://visca.com/ffactory/archives/5-99/msg00021.html)
- * Extracted of OpenCV demhist.c
- */
- if (contrast > 0) {
- gain = 1.0f / ((gain != 0.0f) ? gain : FLT_EPSILON);
- offset = gain * (brightness - delta);
- }
- else {
- delta *= -1;
- offset = gain * (brightness + delta);
- }
- }
-
- const struct VPaintTx_BrightContrastData user_data = {
- .gain = gain,
- .offset = offset,
- };
-
- if (ED_vpaint_color_transform(obact, vpaint_tx_brightness_contrast, &user_data)) {
- ED_region_tag_redraw(CTX_wm_region(C));
- return OPERATOR_FINISHED;
- }
- else {
- return OPERATOR_CANCELLED;
- }
-}
-
-static void PAINT_OT_vertex_color_brightness_contrast(wmOperatorType *ot)
-{
- PropertyRNA *prop;
-
- /* identifiers */
- ot->name = "Vertex Paint Bright/Contrast";
- ot->idname = "PAINT_OT_vertex_color_brightness_contrast";
- ot->description = "Adjust vertex color brightness/contrast";
-
- /* api callbacks */
- ot->exec = vertex_color_brightness_contrast_exec;
- ot->poll = vertex_paint_mode_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* params */
- const float min = -100, max = +100;
- prop = RNA_def_float(ot->srna, "brightness", 0.0f, min, max, "Brightness", "", min, max);
- prop = RNA_def_float(ot->srna, "contrast", 0.0f, min, max, "Contrast", "", min, max);
- RNA_def_property_ui_range(prop, min, max, 1, 1);
-}
-
-struct VPaintTx_HueSatData {
- float hue;
- float sat;
- float val;
-};
-
-static void vpaint_tx_hsv(const float col[3], const void *user_data, float r_col[3])
-{
- const struct VPaintTx_HueSatData *data = user_data;
- float hsv[3];
- rgb_to_hsv_v(col, hsv);
-
- hsv[0] += (data->hue - 0.5f);
- if (hsv[0] > 1.0f) {
- hsv[0] -= 1.0f;
- }
- else if (hsv[0] < 0.0f) {
- hsv[0] += 1.0f;
- }
- hsv[1] *= data->sat;
- hsv[2] *= data->val;
-
- hsv_to_rgb_v(hsv, r_col);
-}
-
-static int vertex_color_hsv_exec(bContext *C, wmOperator *op)
-{
- Object *obact = CTX_data_active_object(C);
-
- const struct VPaintTx_HueSatData user_data = {
- .hue = RNA_float_get(op->ptr, "h"),
- .sat = RNA_float_get(op->ptr, "s"),
- .val = RNA_float_get(op->ptr, "v"),
- };
-
- if (ED_vpaint_color_transform(obact, vpaint_tx_hsv, &user_data)) {
- ED_region_tag_redraw(CTX_wm_region(C));
- return OPERATOR_FINISHED;
- }
- else {
- return OPERATOR_CANCELLED;
- }
-}
-
-static void PAINT_OT_vertex_color_hsv(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Vertex Paint Hue Saturation Value";
- ot->idname = "PAINT_OT_vertex_color_hsv";
- ot->description = "Adjust vertex color HSV values";
-
- /* api callbacks */
- ot->exec = vertex_color_hsv_exec;
- ot->poll = vertex_paint_mode_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* params */
- RNA_def_float(ot->srna, "h", 0.5f, 0.0f, 1.0f, "Hue", "", 0.0f, 1.0f);
- RNA_def_float(ot->srna, "s", 1.0f, 0.0f, 2.0f, "Saturation", "", 0.0f, 2.0f);
- RNA_def_float(ot->srna, "v", 1.0f, 0.0f, 2.0f, "Value", "", 0.0f, 2.0f);
-}
-
-static void vpaint_tx_invert(const float col[3], const void *UNUSED(user_data), float r_col[3])
-{
- for (int i = 0; i < 3; i++) {
- r_col[i] = 1.0f - col[i];
- }
-}
-
-static int vertex_color_invert_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Object *obact = CTX_data_active_object(C);
-
- if (ED_vpaint_color_transform(obact, vpaint_tx_invert, NULL)) {
- ED_region_tag_redraw(CTX_wm_region(C));
- return OPERATOR_FINISHED;
- }
- else {
- return OPERATOR_CANCELLED;
- }
-}
-
-static void PAINT_OT_vertex_color_invert(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Vertex Paint Invert";
- ot->idname = "PAINT_OT_vertex_color_invert";
- ot->description = "Invert RGB values";
-
- /* api callbacks */
- ot->exec = vertex_color_invert_exec;
- ot->poll = vertex_paint_mode_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
-
-struct VPaintTx_LevelsData {
- float gain;
- float offset;
-};
-
-static void vpaint_tx_levels(const float col[3], const void *user_data, float r_col[3])
-{
- const struct VPaintTx_LevelsData *data = user_data;
- for (int i = 0; i < 3; i++) {
- r_col[i] = data->gain * (col[i] + data->offset);
- }
-}
-
-static int vertex_color_levels_exec(bContext *C, wmOperator *op)
-{
- Object *obact = CTX_data_active_object(C);
-
- const struct VPaintTx_LevelsData user_data = {
- .gain = RNA_float_get(op->ptr, "gain"),
- .offset = RNA_float_get(op->ptr, "offset"),
- };
-
- if (ED_vpaint_color_transform(obact, vpaint_tx_levels, &user_data)) {
- ED_region_tag_redraw(CTX_wm_region(C));
- return OPERATOR_FINISHED;
- }
- else {
- return OPERATOR_CANCELLED;
- }
-}
-
-static void PAINT_OT_vertex_color_levels(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Vertex Paint Levels";
- ot->idname = "PAINT_OT_vertex_color_levels";
- ot->description = "Adjust levels of vertex colors";
-
- /* api callbacks */
- ot->exec = vertex_color_levels_exec;
- ot->poll = vertex_paint_mode_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* params */
- RNA_def_float(ot->srna, "offset", 0.0f, -1.0f, 1.0f, "Offset", "Value to add to colors", -1.0f, 1.0f);
- RNA_def_float(ot->srna, "gain", 1.0f, 0.0f, FLT_MAX, "Gain", "Value to multiply colors by", 0.0f, 10.0f);
-}
-
-/** \} */
-
-
static int brush_reset_exec(bContext *C, wmOperator *UNUSED(op))
{
Paint *paint = BKE_paint_get_active_from_context(C);
@@ -558,9 +264,14 @@ static int brush_reset_exec(bContext *C, wmOperator *UNUSED(op))
if (!ob || !brush) return OPERATOR_CANCELLED;
- if (ob->mode & OB_MODE_SCULPT)
- BKE_brush_sculpt_reset(brush);
/* TODO: other modes */
+ if (ob->mode & OB_MODE_SCULPT) {
+ BKE_brush_sculpt_reset(brush);
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
+ WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, brush);
return OPERATOR_FINISHED;
}
@@ -821,8 +532,6 @@ static int brush_uv_sculpt_tool_set_exec(bContext *C, wmOperator *op)
static void BRUSH_OT_uv_sculpt_tool_set(wmOperatorType *ot)
{
- /* from rna_scene.c */
- extern EnumPropertyItem uv_sculpt_tool_items[];
/* identifiers */
ot->name = "UV Sculpt Tool Set";
ot->description = "Set the UV sculpt tool";
@@ -836,7 +545,7 @@ static void BRUSH_OT_uv_sculpt_tool_set(wmOperatorType *ot)
ot->flag = 0;
/* props */
- ot->prop = RNA_def_enum(ot->srna, "tool", uv_sculpt_tool_items, 0, "Tool", "");
+ ot->prop = RNA_def_enum(ot->srna, "tool", rna_enum_uv_sculpt_tool_items, 0, "Tool", "");
}
/***** Stencil Control *****/
@@ -1351,6 +1060,7 @@ void ED_operatortypes_paint(void)
WM_operatortype_append(PAINT_OT_vertex_color_hsv);
WM_operatortype_append(PAINT_OT_vertex_color_invert);
WM_operatortype_append(PAINT_OT_vertex_color_levels);
+ WM_operatortype_append(PAINT_OT_vertex_color_from_weight);
/* face-select */
WM_operatortype_append(PAINT_OT_face_select_linked);
@@ -1615,6 +1325,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
keymap->poll = vertex_paint_mode_poll;
WM_keymap_verify_item(keymap, "PAINT_OT_vertex_paint", LEFTMOUSE, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "PAINT_OT_brush_colors_flip", XKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "PAINT_OT_sample_color", SKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap,
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index 86008ec0308..d92afd414f8 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -172,7 +172,7 @@ static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata)
uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
@@ -589,7 +589,10 @@ static float paint_stroke_integrate_overlap(Brush *br, float factor)
max = overlap;
}
- return 1.0f / max;
+ if (max == 0.0f)
+ return 1.0f;
+ else
+ return 1.0f / max;
}
static float paint_space_stroke_spacing_variable(const Scene *scene, PaintStroke *stroke, float pressure, float dpressure, float length)
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index e36cc275ba9..bb69a5d3db9 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -56,9 +56,12 @@
#include "BKE_paint.h"
#include "BKE_report.h"
+#include "DEG_depsgraph.h"
+
#include "RNA_access.h"
#include "RNA_define.h"
+#include "GPU_glew.h"
#include "GPU_matrix.h"
#include "IMB_colormanagement.h"
@@ -165,7 +168,7 @@ float paint_calc_object_space_radius(ViewContext *vc, const float center[3],
return len_v3(delta) / scale;
}
-float paint_get_tex_pixel(MTex *mtex, float u, float v, struct ImagePool *pool, int thread)
+float paint_get_tex_pixel(const MTex *mtex, float u, float v, struct ImagePool *pool, int thread)
{
float intensity, rgba[4];
float co[3] = {u, v, 0.0f};
@@ -176,7 +179,7 @@ float paint_get_tex_pixel(MTex *mtex, float u, float v, struct ImagePool *pool,
return intensity;
}
-void paint_get_tex_pixel_col(MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool, int thread, bool convert_to_linear, struct ColorSpace *colorspace)
+void paint_get_tex_pixel_col(const MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool, int thread, bool convert_to_linear, struct ColorSpace *colorspace)
{
float co[3] = {u, v, 0.0f};
int hasrgb;
@@ -268,9 +271,9 @@ static void imapaint_tri_weights(float matrix[4][4], GLint view[4],
}
/* compute uv coordinates of mouse in face */
-static void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, const int xy[2], float uv[2])
+static void imapaint_pick_uv(EvaluationContext *eval_ctx, Scene *scene, Object *ob, unsigned int faceindex, const int xy[2], float uv[2])
{
- DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
+ DerivedMesh *dm = mesh_get_derived_final(eval_ctx, scene, ob, CD_MASK_BAREMESH);
const int tottri = dm->getNumLoopTri(dm);
int i, findex;
float p[2], w[3], absw, minabsw;
@@ -346,13 +349,15 @@ static void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, c
}
/* returns 0 if not found, otherwise 1 */
-static int imapaint_pick_face(ViewContext *vc, const int mval[2], unsigned int *r_index, unsigned int totpoly)
+static int imapaint_pick_face(
+ const struct EvaluationContext *eval_ctx, ViewContext *vc, const int mval[2],
+ unsigned int *r_index, unsigned int totpoly)
{
if (totpoly == 0)
return 0;
/* sample only on the exact position */
- *r_index = ED_view3d_backbuf_sample(vc, mval[0], mval[1]);
+ *r_index = ED_view3d_backbuf_sample(eval_ctx, vc, mval[0], mval[1]);
if ((*r_index) == 0 || (*r_index) > (unsigned int)totpoly) {
return 0;
@@ -418,13 +423,16 @@ void flip_qt_qt(float out[4], const float in[4], const char symm)
void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_proj, bool use_palette)
{
Scene *scene = CTX_data_scene(C);
+ EvaluationContext eval_ctx;
Paint *paint = BKE_paint_get_active_from_context(C);
Palette *palette = BKE_paint_palette(paint);
- PaletteColor *color;
+ PaletteColor *color = NULL;
Brush *br = BKE_paint_brush(BKE_paint_get_active_from_context(C));
unsigned int col;
const unsigned char *cp;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
CLAMP(x, 0, ar->winx);
CLAMP(y, 0, ar->winy);
@@ -442,14 +450,14 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr
if (CTX_wm_view3d(C) && texpaint_proj) {
/* first try getting a colour directly from the mesh faces if possible */
SceneLayer *sl = CTX_data_scene_layer(C);
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
bool sample_success = false;
ImagePaintSettings *imapaint = &scene->toolsettings->imapaint;
bool use_material = (imapaint->mode == IMAGEPAINT_MODE_MATERIAL);
if (ob) {
Mesh *me = (Mesh *)ob->data;
- DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
+ DerivedMesh *dm = mesh_get_derived_final(&eval_ctx, scene, ob, CD_MASK_BAREMESH);
ViewContext vc;
const int mval[2] = {x, y};
@@ -461,7 +469,7 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr
view3d_operator_needs_opengl(C);
- if (imapaint_pick_face(&vc, mval, &faceindex, totpoly)) {
+ if (imapaint_pick_face(&eval_ctx, &vc, mval, &faceindex, totpoly)) {
Image *image;
if (use_material)
@@ -474,7 +482,7 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr
if (ibuf && ibuf->rect) {
float uv[2];
float u, v;
- imapaint_pick_uv(scene, ob, faceindex, mval, uv);
+ imapaint_pick_uv(&eval_ctx, scene, ob, faceindex, mval, uv);
sample_success = true;
u = fmodf(uv[0], 1.0f);
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 98bf0aa0a66..fd88ea2d15f 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -27,20 +27,20 @@
/** \file blender/editors/sculpt_paint/paint_vertex.c
* \ingroup edsculpt
+ *
+ * Used for vertex color & weight paint and mode switching.
+ *
+ * \note This file is already big,
+ * use `paint_vertex_color_ops.c` & `paint_vertex_weight_ops.c` for general purpose operators.
*/
#include "MEM_guardedalloc.h"
-#include "BLI_blenlib.h"
+#include "BLI_listbase.h"
+#include "BLI_rect.h"
#include "BLI_math.h"
#include "BLI_array_utils.h"
-#include "BLI_bitmap.h"
-#include "BLI_stack.h"
-#include "BLI_string_utils.h"
-
-#include "IMB_imbuf.h"
-#include "IMB_imbuf_types.h"
-#include "IMB_colormanagement.h"
+#include "BLI_task.h"
#include "DNA_armature_types.h"
#include "DNA_mesh_types.h"
@@ -51,40 +51,116 @@
#include "RNA_access.h"
#include "RNA_define.h"
-#include "RNA_enum_types.h"
-#include "BKE_DerivedMesh.h"
-#include "BKE_action.h"
#include "BKE_brush.h"
#include "BKE_context.h"
#include "BKE_deform.h"
#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
-#include "BKE_modifier.h"
#include "BKE_object_deform.h"
#include "BKE_paint.h"
#include "BKE_report.h"
-#include "BKE_colortools.h"
+#include "BKE_subsurf.h"
#include "DEG_depsgraph.h"
#include "WM_api.h"
#include "WM_types.h"
-#include "ED_armature.h"
#include "ED_object.h"
#include "ED_mesh.h"
#include "ED_screen.h"
#include "ED_view3d.h"
+#include "bmesh.h"
+#include "BKE_ccg.h"
+
+#include "sculpt_intern.h"
#include "paint_intern.h" /* own include */
-/* small structure to defer applying weight-paint results */
-struct WPaintDefer {
- int index;
- float alpha, weight;
+/* Use for 'blur' brush, align with PBVH nodes, created and freed on each update. */
+struct VPaintAverageAccum {
+ uint len;
+ uint value[3];
+};
+
+struct WPaintAverageAccum {
+ uint len;
+ double value;
+};
+
+struct NormalAnglePrecalc {
+ bool do_mask_normal;
+ /* what angle to mask at */
+ float angle;
+ /* cos(angle), faster to compare */
+ float angle__cos;
+ float angle_inner;
+ float angle_inner__cos;
+ /* difference between angle and angle_inner, for easy access */
+ float angle_range;
};
+
+static void view_angle_limits_init(
+ struct NormalAnglePrecalc *a, float angle, bool do_mask_normal)
+{
+ angle = RAD2DEGF(angle);
+ a->do_mask_normal = do_mask_normal;
+ if (do_mask_normal) {
+ a->angle_inner = angle;
+ a->angle = (a->angle_inner + 90.0f) * 0.5f;
+ }
+ else {
+ a->angle_inner = a->angle = angle;
+ }
+
+ a->angle_inner *= (float)(M_PI_2 / 90);
+ a->angle *= (float)(M_PI_2 / 90);
+ a->angle_range = a->angle - a->angle_inner;
+
+ if (a->angle_range <= 0.0f) {
+ a->do_mask_normal = false; /* no need to do blending */
+ }
+
+ a->angle__cos = cosf(a->angle);
+ a->angle_inner__cos = cosf(a->angle_inner);
+}
+
+static float view_angle_limits_apply_falloff(
+ const struct NormalAnglePrecalc *a, float angle_cos, float *mask_p)
+{
+ if (angle_cos <= a->angle__cos) {
+ /* outsize the normal limit */
+ return false;
+ }
+ else if (angle_cos < a->angle_inner__cos) {
+ *mask_p *= (a->angle - acosf(angle_cos)) / a->angle_range;
+ return true;
+ }
+ else {
+ return true;
+ }
+}
+
+static bool vwpaint_use_normal(const VPaint *vp)
+{
+ return ((vp->paint.brush->flag & BRUSH_FRONTFACE) != 0) ||
+ ((vp->paint.brush->flag & BRUSH_FRONTFACE_FALLOFF) != 0);
+}
+
+
+static MDeformVert *defweight_prev_init(MDeformVert *dvert_prev, MDeformVert *dvert_curr, int index)
+{
+ MDeformVert *dv_curr = &dvert_curr[index];
+ MDeformVert *dv_prev = &dvert_prev[index];
+ if (dv_prev->flag == 1) {
+ dv_prev->flag = 0;
+ defvert_copy(dv_prev, dv_curr);
+ }
+ return dv_prev;
+}
+
/* check if we can do partial updates and have them draw realtime
* (without rebuilding the 'derivedFinal') */
static bool vertex_paint_use_fast_update_check(Object *ob)
@@ -126,7 +202,7 @@ int vertex_paint_mode_poll(bContext *C)
int vertex_paint_poll(bContext *C)
{
- if (vertex_paint_mode_poll(C) &&
+ if (vertex_paint_mode_poll(C) &&
BKE_paint_brush(&CTX_data_tool_settings(C)->vpaint->paint))
{
ScrArea *sa = CTX_wm_area(C);
@@ -165,639 +241,47 @@ int weight_paint_poll(bContext *C)
return 0;
}
-static VPaint *new_vpaint(int wpaint)
+static VPaint *new_vpaint(void)
{
VPaint *vp = MEM_callocN(sizeof(VPaint), "VPaint");
-
- vp->flag = (wpaint) ? 0 : VP_SPRAY;
+
vp->paint.flags |= PAINT_SHOW_BRUSH;
return vp;
}
-static int *get_indexarray(Mesh *me)
-{
- return MEM_mallocN(sizeof(int) * (me->totpoly + 1), "vertexpaint");
-}
-
-unsigned int vpaint_get_current_col(Scene *scene, VPaint *vp)
+uint vpaint_get_current_col(Scene *scene, VPaint *vp)
{
Brush *brush = BKE_paint_brush(&vp->paint);
- unsigned char col[4];
+ uchar col[4];
rgb_float_to_uchar(col, BKE_brush_color_get(scene, brush));
col[3] = 255; /* alpha isn't used, could even be removed to speedup paint a little */
- return *(unsigned int *)col;
-}
-
-static void do_shared_vertexcol(Mesh *me, bool *mlooptag)
-{
- const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
- MPoly *mp;
- int (*scol)[4];
- int i, j;
- bool has_shared = false;
-
- /* if no mloopcol: do not do */
- /* if mtexpoly: only the involved faces, otherwise all */
-
- if (me->mloopcol == NULL || me->totvert == 0 || me->totpoly == 0) return;
-
- scol = MEM_callocN(sizeof(int) * me->totvert * 5, "scol");
-
- for (i = 0, mp = me->mpoly; i < me->totpoly; i++, mp++) {
- if ((use_face_sel == false) || (mp->flag & ME_FACE_SEL)) {
- MLoop *ml = me->mloop + mp->loopstart;
- MLoopCol *lcol = me->mloopcol + mp->loopstart;
- for (j = 0; j < mp->totloop; j++, ml++, lcol++) {
- scol[ml->v][0] += lcol->r;
- scol[ml->v][1] += lcol->g;
- scol[ml->v][2] += lcol->b;
- scol[ml->v][3] += 1;
- has_shared = 1;
- }
- }
- }
-
- if (has_shared) {
- for (i = 0; i < me->totvert; i++) {
- if (scol[i][3] != 0) {
- scol[i][0] = divide_round_i(scol[i][0], scol[i][3]);
- scol[i][1] = divide_round_i(scol[i][1], scol[i][3]);
- scol[i][2] = divide_round_i(scol[i][2], scol[i][3]);
- }
- }
-
- for (i = 0, mp = me->mpoly; i < me->totpoly; i++, mp++) {
- if ((use_face_sel == false) || (mp->flag & ME_FACE_SEL)) {
- MLoop *ml = me->mloop + mp->loopstart;
- MLoopCol *lcol = me->mloopcol + mp->loopstart;
- for (j = 0; j < mp->totloop; j++, ml++, lcol++) {
- if (mlooptag[mp->loopstart + j]) {
- lcol->r = scol[ml->v][0];
- lcol->g = scol[ml->v][1];
- lcol->b = scol[ml->v][2];
- }
- }
- }
- }
- }
-
- MEM_freeN(scol);
-}
-
-static bool make_vertexcol(Object *ob) /* single ob */
-{
- Mesh *me;
-
- if (ID_IS_LINKED_DATABLOCK(ob) ||
- ((me = BKE_mesh_from_object(ob)) == NULL) ||
- (me->totpoly == 0) ||
- (me->edit_btmesh))
- {
- return false;
- }
-
- /* copies from shadedisplist to mcol */
- if (!me->mloopcol && me->totloop) {
- CustomData_add_layer(&me->ldata, CD_MLOOPCOL, CD_DEFAULT, NULL, me->totloop);
- BKE_mesh_update_customdata_pointers(me, true);
- }
-
- DEG_id_tag_update(&me->id, 0);
-
- return (me->mloopcol != NULL);
-}
-
-/* mirror_vgroup is set to -1 when invalid */
-static int wpaint_mirror_vgroup_ensure(Object *ob, const int vgroup_active)
-{
- bDeformGroup *defgroup = BLI_findlink(&ob->defbase, vgroup_active);
-
- if (defgroup) {
- int mirrdef;
- char name_flip[MAXBONENAME];
-
- BLI_string_flip_side_name(name_flip, defgroup->name, false, sizeof(name_flip));
- mirrdef = defgroup_name_index(ob, name_flip);
- if (mirrdef == -1) {
- if (BKE_defgroup_new(ob, name_flip)) {
- mirrdef = BLI_listbase_count(&ob->defbase) - 1;
- }
- }
-
- /* curdef should never be NULL unless this is
- * a lamp and BKE_object_defgroup_add_name fails */
- return mirrdef;
- }
-
- return -1;
-}
-
-static void free_vpaint_prev(VPaint *vp)
-{
- if (vp->vpaint_prev) {
- MEM_freeN(vp->vpaint_prev);
- vp->vpaint_prev = NULL;
- vp->tot = 0;
- }
-}
-
-static void free_wpaint_prev(VPaint *vp)
-{
- if (vp->wpaint_prev) {
- BKE_defvert_array_free(vp->wpaint_prev, vp->tot);
- vp->wpaint_prev = NULL;
- vp->tot = 0;
- }
-}
-
-static void copy_vpaint_prev(VPaint *vp, unsigned int *lcol, int tot)
-{
- free_vpaint_prev(vp);
-
- vp->tot = tot;
-
- if (lcol == NULL || tot == 0) return;
-
- vp->vpaint_prev = MEM_mallocN(sizeof(int) * tot, "vpaint_prev");
- memcpy(vp->vpaint_prev, lcol, sizeof(int) * tot);
-
-}
-
-static void copy_wpaint_prev(VPaint *wp, MDeformVert *dverts, int dcount)
-{
- free_wpaint_prev(wp);
-
- if (dverts && dcount) {
-
- wp->wpaint_prev = MEM_mallocN(sizeof(MDeformVert) * dcount, "wpaint prev");
- wp->tot = dcount;
- BKE_defvert_array_copy(wp->wpaint_prev, dverts, dcount);
- }
-}
-
-bool ED_vpaint_fill(Object *ob, unsigned int paintcol)
-{
- Mesh *me;
- MPoly *mp;
- int i, j;
- bool selected;
-
- if (((me = BKE_mesh_from_object(ob)) == NULL) ||
- (me->mloopcol == NULL && (make_vertexcol(ob) == false)))
- {
- return false;
- }
-
- selected = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
-
- mp = me->mpoly;
- for (i = 0; i < me->totpoly; i++, mp++) {
- MLoopCol *lcol = me->mloopcol + mp->loopstart;
-
- if (selected && !(mp->flag & ME_FACE_SEL))
- continue;
-
- for (j = 0; j < mp->totloop; j++, lcol++) {
- *(int *)lcol = paintcol;
- }
- }
-
- /* remove stale me->mcol, will be added later */
- BKE_mesh_tessface_clear(me);
-
- DEG_id_tag_update(&me->id, 0);
-
- return true;
-}
-
-
-/* fills in the selected faces with the current weight and vertex group */
-bool ED_wpaint_fill(VPaint *wp, Object *ob, float paintweight)
-{
- Mesh *me = ob->data;
- MPoly *mp;
- MDeformWeight *dw, *dw_prev;
- int vgroup_active, vgroup_mirror = -1;
- unsigned int index;
- const bool topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0;
-
- /* mutually exclusive, could be made into a */
- const short paint_selmode = ME_EDIT_PAINT_SEL_MODE(me);
-
- if (me->totpoly == 0 || me->dvert == NULL || !me->mpoly) {
- return false;
- }
-
- vgroup_active = ob->actdef - 1;
-
- /* if mirror painting, find the other group */
- if (me->editflag & ME_EDIT_MIRROR_X) {
- vgroup_mirror = wpaint_mirror_vgroup_ensure(ob, vgroup_active);
- }
-
- copy_wpaint_prev(wp, me->dvert, me->totvert);
-
- for (index = 0, mp = me->mpoly; index < me->totpoly; index++, mp++) {
- unsigned int fidx = mp->totloop - 1;
-
- if ((paint_selmode == SCE_SELECT_FACE) && !(mp->flag & ME_FACE_SEL)) {
- continue;
- }
-
- do {
- unsigned int vidx = me->mloop[mp->loopstart + fidx].v;
-
- if (!me->dvert[vidx].flag) {
- if ((paint_selmode == SCE_SELECT_VERTEX) && !(me->mvert[vidx].flag & SELECT)) {
- continue;
- }
-
- dw = defvert_verify_index(&me->dvert[vidx], vgroup_active);
- if (dw) {
- dw_prev = defvert_verify_index(wp->wpaint_prev + vidx, vgroup_active);
- dw_prev->weight = dw->weight; /* set the undo weight */
- dw->weight = paintweight;
-
- if (me->editflag & ME_EDIT_MIRROR_X) { /* x mirror painting */
- int j = mesh_get_x_mirror_vert(ob, NULL, vidx, topology);
- if (j >= 0) {
- /* copy, not paint again */
- if (vgroup_mirror != -1) {
- dw = defvert_verify_index(me->dvert + j, vgroup_mirror);
- dw_prev = defvert_verify_index(wp->wpaint_prev + j, vgroup_mirror);
- }
- else {
- dw = defvert_verify_index(me->dvert + j, vgroup_active);
- dw_prev = defvert_verify_index(wp->wpaint_prev + j, vgroup_active);
- }
- dw_prev->weight = dw->weight; /* set the undo weight */
- dw->weight = paintweight;
- }
- }
- }
- me->dvert[vidx].flag = 1;
- }
-
- } while (fidx--);
- }
-
- {
- MDeformVert *dv = me->dvert;
- for (index = me->totvert; index != 0; index--, dv++) {
- dv->flag = 0;
- }
- }
-
- copy_wpaint_prev(wp, NULL, 0);
-
- DEG_id_tag_update(&me->id, 0);
-
- return true;
-}
-
-bool ED_vpaint_smooth(Object *ob)
-{
- Mesh *me;
- MPoly *mp;
-
- int i, j;
-
- bool *mlooptag;
- bool selected;
-
- if (((me = BKE_mesh_from_object(ob)) == NULL) ||
- (me->mloopcol == NULL && (make_vertexcol(ob) == false)))
- {
- return false;
- }
-
- selected = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
-
- mlooptag = MEM_callocN(sizeof(bool) * me->totloop, "VPaintData mlooptag");
-
- /* simply tag loops of selected faces */
- mp = me->mpoly;
- for (i = 0; i < me->totpoly; i++, mp++) {
- MLoop *ml = me->mloop + mp->loopstart;
- int ml_index = mp->loopstart;
-
- if (selected && !(mp->flag & ME_FACE_SEL))
- continue;
-
- for (j = 0; j < mp->totloop; j++, ml_index++, ml++) {
- mlooptag[ml_index] = true;
- }
- }
-
- /* remove stale me->mcol, will be added later */
- BKE_mesh_tessface_clear(me);
-
- do_shared_vertexcol(me, mlooptag);
-
- MEM_freeN(mlooptag);
-
- DEG_id_tag_update(&me->id, 0);
-
- return true;
-}
-
-/**
- * Apply callback to each vertex of the active vertex color layer.
- */
-bool ED_vpaint_color_transform(
- struct Object *ob,
- VPaintTransform_Callback vpaint_tx_fn,
- const void *user_data)
-{
- Mesh *me;
- const MPoly *mp;
-
- if (((me = BKE_mesh_from_object(ob)) == NULL) ||
- (me->mloopcol == NULL && (make_vertexcol(ob) == false)))
- {
- return false;
- }
-
- const bool do_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
- mp = me->mpoly;
-
- for (int i = 0; i < me->totpoly; i++, mp++) {
- MLoopCol *lcol = &me->mloopcol[mp->loopstart];
-
- if (do_face_sel && !(mp->flag & ME_FACE_SEL)) {
- continue;
- }
-
- for (int j = 0; j < mp->totloop; j++, lcol++) {
- float col[3];
- rgb_uchar_to_float(col, &lcol->r);
-
- vpaint_tx_fn(col, user_data, col);
-
- rgb_float_to_uchar(&lcol->r, col);
- }
- }
-
- /* remove stale me->mcol, will be added later */
- BKE_mesh_tessface_clear(me);
-
- DEG_id_tag_update(&me->id, 0);
-
- return true;
-}
-
-/* XXX: should be re-implemented as a vertex/weight paint 'color correct' operator */
-#if 0
-void vpaint_dogamma(Scene *scene)
-{
- VPaint *vp = scene->toolsettings->vpaint;
- Mesh *me;
- Object *ob;
- float igam, fac;
- int a, temp;
- unsigned char *cp, gamtab[256];
-
- ob = OBACT;
- me = BKE_mesh_from_object(ob);
-
- if (!(ob->mode & OB_MODE_VERTEX_PAINT)) return;
- if (me == 0 || me->mcol == 0 || me->totface == 0) return;
-
- igam = 1.0 / vp->gamma;
- for (a = 0; a < 256; a++) {
-
- fac = ((float)a) / 255.0;
- fac = vp->mul * pow(fac, igam);
-
- temp = 255.9 * fac;
-
- if (temp <= 0) gamtab[a] = 0;
- else if (temp >= 255) gamtab[a] = 255;
- else gamtab[a] = temp;
- }
-
- a = 4 * me->totface;
- cp = (unsigned char *)me->mcol;
- while (a--) {
-
- cp[1] = gamtab[cp[1]];
- cp[2] = gamtab[cp[2]];
- cp[3] = gamtab[cp[3]];
-
- cp += 4;
- }
-}
-#endif
-
-BLI_INLINE unsigned int mcol_blend(unsigned int col1, unsigned int col2, int fac)
-{
- unsigned char *cp1, *cp2, *cp;
- int mfac;
- unsigned int col = 0;
-
- if (fac == 0) {
- return col1;
- }
-
- if (fac >= 255) {
- return col2;
- }
-
- mfac = 255 - fac;
-
- cp1 = (unsigned char *)&col1;
- cp2 = (unsigned char *)&col2;
- cp = (unsigned char *)&col;
-
- cp[0] = divide_round_i((mfac * cp1[0] + fac * cp2[0]), 255);
- cp[1] = divide_round_i((mfac * cp1[1] + fac * cp2[1]), 255);
- cp[2] = divide_round_i((mfac * cp1[2] + fac * cp2[2]), 255);
- cp[3] = 255;
-
- return col;
-}
-
-BLI_INLINE unsigned int mcol_add(unsigned int col1, unsigned int col2, int fac)
-{
- unsigned char *cp1, *cp2, *cp;
- int temp;
- unsigned int col = 0;
-
- if (fac == 0) {
- return col1;
- }
-
- cp1 = (unsigned char *)&col1;
- cp2 = (unsigned char *)&col2;
- cp = (unsigned char *)&col;
-
- temp = cp1[0] + divide_round_i((fac * cp2[0]), 255);
- cp[0] = (temp > 254) ? 255 : temp;
- temp = cp1[1] + divide_round_i((fac * cp2[1]), 255);
- cp[1] = (temp > 254) ? 255 : temp;
- temp = cp1[2] + divide_round_i((fac * cp2[2]), 255);
- cp[2] = (temp > 254) ? 255 : temp;
- cp[3] = 255;
-
- return col;
-}
-
-BLI_INLINE unsigned int mcol_sub(unsigned int col1, unsigned int col2, int fac)
-{
- unsigned char *cp1, *cp2, *cp;
- int temp;
- unsigned int col = 0;
-
- if (fac == 0) {
- return col1;
- }
-
- cp1 = (unsigned char *)&col1;
- cp2 = (unsigned char *)&col2;
- cp = (unsigned char *)&col;
-
- temp = cp1[0] - divide_round_i((fac * cp2[0]), 255);
- cp[0] = (temp < 0) ? 0 : temp;
- temp = cp1[1] - divide_round_i((fac * cp2[1]), 255);
- cp[1] = (temp < 0) ? 0 : temp;
- temp = cp1[2] - divide_round_i((fac * cp2[2]), 255);
- cp[2] = (temp < 0) ? 0 : temp;
- cp[3] = 255;
-
- return col;
-}
-
-BLI_INLINE unsigned int mcol_mul(unsigned int col1, unsigned int col2, int fac)
-{
- unsigned char *cp1, *cp2, *cp;
- int mfac;
- unsigned int col = 0;
-
- if (fac == 0) {
- return col1;
- }
-
- mfac = 255 - fac;
-
- cp1 = (unsigned char *)&col1;
- cp2 = (unsigned char *)&col2;
- cp = (unsigned char *)&col;
-
- /* first mul, then blend the fac */
- cp[0] = divide_round_i(mfac * cp1[0] * 255 + fac * cp2[0] * cp1[0], 255 * 255);
- cp[1] = divide_round_i(mfac * cp1[1] * 255 + fac * cp2[1] * cp1[1], 255 * 255);
- cp[2] = divide_round_i(mfac * cp1[2] * 255 + fac * cp2[2] * cp1[2], 255 * 255);
- cp[3] = 255;
-
- return col;
-}
-
-BLI_INLINE unsigned int mcol_lighten(unsigned int col1, unsigned int col2, int fac)
-{
- unsigned char *cp1, *cp2, *cp;
- int mfac;
- unsigned int col = 0;
-
- if (fac == 0) {
- return col1;
- }
- else if (fac >= 255) {
- return col2;
- }
-
- mfac = 255 - fac;
-
- cp1 = (unsigned char *)&col1;
- cp2 = (unsigned char *)&col2;
- cp = (unsigned char *)&col;
-
- /* See if are lighter, if so mix, else don't do anything.
- * if the paint col is darker then the original, then ignore */
- if (IMB_colormanagement_get_luminance_byte(cp1) > IMB_colormanagement_get_luminance_byte(cp2)) {
- return col1;
- }
-
- cp[0] = divide_round_i(mfac * cp1[0] + fac * cp2[0], 255);
- cp[1] = divide_round_i(mfac * cp1[1] + fac * cp2[1], 255);
- cp[2] = divide_round_i(mfac * cp1[2] + fac * cp2[2], 255);
- cp[3] = 255;
-
- return col;
-}
-
-BLI_INLINE unsigned int mcol_darken(unsigned int col1, unsigned int col2, int fac)
-{
- unsigned char *cp1, *cp2, *cp;
- int mfac;
- unsigned int col = 0;
-
- if (fac == 0) {
- return col1;
- }
- else if (fac >= 255) {
- return col2;
- }
-
- mfac = 255 - fac;
-
- cp1 = (unsigned char *)&col1;
- cp2 = (unsigned char *)&col2;
- cp = (unsigned char *)&col;
-
- /* See if were darker, if so mix, else don't do anything.
- * if the paint col is brighter then the original, then ignore */
- if (IMB_colormanagement_get_luminance_byte(cp1) < IMB_colormanagement_get_luminance_byte(cp2)) {
- return col1;
- }
-
- cp[0] = divide_round_i((mfac * cp1[0] + fac * cp2[0]), 255);
- cp[1] = divide_round_i((mfac * cp1[1] + fac * cp2[1]), 255);
- cp[2] = divide_round_i((mfac * cp1[2] + fac * cp2[2]), 255);
- cp[3] = 255;
- return col;
-}
-
-/* wpaint has 'wpaint_blend_tool' */
-static unsigned int vpaint_blend_tool(const int tool, const unsigned int col,
- const unsigned int paintcol, const int alpha_i)
-{
- switch (tool) {
- case PAINT_BLEND_MIX:
- case PAINT_BLEND_BLUR: return mcol_blend(col, paintcol, alpha_i);
- case PAINT_BLEND_ADD: return mcol_add(col, paintcol, alpha_i);
- case PAINT_BLEND_SUB: return mcol_sub(col, paintcol, alpha_i);
- case PAINT_BLEND_MUL: return mcol_mul(col, paintcol, alpha_i);
- case PAINT_BLEND_LIGHTEN: return mcol_lighten(col, paintcol, alpha_i);
- case PAINT_BLEND_DARKEN: return mcol_darken(col, paintcol, alpha_i);
- default:
- BLI_assert(0);
- return 0;
- }
+ return *(uint *)col;
}
/* wpaint has 'wpaint_blend' */
-static unsigned int vpaint_blend(VPaint *vp, unsigned int col, unsigned int colorig, const
- unsigned int paintcol, const int alpha_i,
- /* pre scaled from [0-1] --> [0-255] */
- const int brush_alpha_value_i)
+static uint vpaint_blend(
+ const VPaint *vp, uint color_curr, uint color_orig,
+ uint color_paint, const int alpha_i,
+ /* pre scaled from [0-1] --> [0-255] */
+ const int brush_alpha_value_i)
{
- Brush *brush = BKE_paint_brush(&vp->paint);
+ const Brush *brush = vp->paint.brush;
const int tool = brush->vertexpaint_tool;
- col = vpaint_blend_tool(tool, col, paintcol, alpha_i);
+ uint color_blend = ED_vpaint_blend_tool(tool, color_curr, color_paint, alpha_i);
- /* if no spray, clip color adding with colorig & orig alpha */
- if ((vp->flag & VP_SPRAY) == 0) {
- unsigned int testcol, a;
+ /* if no accumulate, clip color adding with colorig & orig alpha */
+ if ((brush->flag & BRUSH_ACCUMULATE) == 0) {
+ uint color_test, a;
char *cp, *ct, *co;
-
- testcol = vpaint_blend_tool(tool, colorig, paintcol, brush_alpha_value_i);
-
- cp = (char *)&col;
- ct = (char *)&testcol;
- co = (char *)&colorig;
-
+
+ color_test = ED_vpaint_blend_tool(tool, color_orig, color_paint, brush_alpha_value_i);
+
+ cp = (char *)&color_blend;
+ ct = (char *)&color_test;
+ co = (char *)&color_orig;
+
for (a = 0; a < 4; a++) {
if (ct[a] < co[a]) {
if (cp[a] < ct[a]) cp[a] = ct[a];
@@ -810,59 +294,30 @@ static unsigned int vpaint_blend(VPaint *vp, unsigned int col, unsigned int colo
}
}
- return col;
-}
-
-
-static int sample_backbuf_area(ViewContext *vc, int *indexar, int totpoly, int x, int y, float size)
-{
- struct ImBuf *ibuf;
- int a, tot = 0, index;
-
- /* brecht: disabled this because it obviously fails for
- * brushes with size > 64, why is this here? */
- /*if (size > 64.0) size = 64.0;*/
-
- ibuf = ED_view3d_backbuf_read(vc, x - size, y - size, x + size, y + size);
- if (ibuf) {
- unsigned int *rt = ibuf->rect;
-
- memset(indexar, 0, sizeof(int) * (totpoly + 1));
-
- size = ibuf->x * ibuf->y;
- while (size--) {
-
- if (*rt) {
- index = *rt;
- if (index > 0 && index <= totpoly) {
- indexar[index] = 1;
- }
- }
-
- rt++;
- }
-
- for (a = 1; a <= totpoly; a++) {
- if (indexar[a]) {
- indexar[tot++] = a;
- }
- }
-
- IMB_freeImBuf(ibuf);
+ if ((brush->flag & BRUSH_LOCK_ALPHA) &&
+ !ELEM(tool, PAINT_BLEND_ALPHA_SUB, PAINT_BLEND_ALPHA_ADD))
+ {
+ char *cp, *cc;
+ cp = (char *)&color_blend;
+ cc = (char *)&color_curr;
+ cp[3] = cc[3];
}
-
- return tot;
+
+ return color_blend;
}
+
/* whats _dl mean? */
-static float calc_vp_strength_col_dl(VPaint *vp, ViewContext *vc, const float co[3],
- const float mval[2], const float brush_size_pressure, float rgba[4])
+static float calc_vp_strength_col_dl(
+ VPaint *vp, const ViewContext *vc, const float co[3],
+ const float mval[2], const float brush_size_pressure, float rgba[4])
{
float co_ss[2]; /* screenspace */
- if (ED_view3d_project_float_object(vc->ar,
- co, co_ss,
- V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_NEAR) == V3D_PROJ_RET_OK)
+ if (ED_view3d_project_float_object(
+ vc->ar,
+ co, co_ss,
+ V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_NEAR) == V3D_PROJ_RET_OK)
{
const float dist_sq = len_squared_v2v2(mval, co_ss);
@@ -892,17 +347,18 @@ static float calc_vp_strength_col_dl(VPaint *vp, ViewContext *vc, const float co
return 0.0f;
}
-static float calc_vp_alpha_col_dl(VPaint *vp, ViewContext *vc,
- float vpimat[3][3], const DMCoNo *v_co_no,
- const float mval[2],
- const float brush_size_pressure, const float brush_alpha_pressure, float rgba[4])
+static float calc_vp_alpha_col_dl(
+ VPaint *vp, const ViewContext *vc,
+ float vpimat[3][3], const DMCoNo *v_co_no,
+ const float mval[2],
+ const float brush_size_pressure, const float brush_alpha_pressure, float rgba[4])
{
float strength = calc_vp_strength_col_dl(vp, vc, v_co_no->co, mval, brush_size_pressure, rgba);
if (strength > 0.0f) {
float alpha = brush_alpha_pressure * strength;
- if (vp->flag & VP_NORMALS) {
+ if ((vp->paint.brush->flag & BRUSH_FRONTFACE_FALLOFF) != 0) {
float dvec[3];
/* transpose ! */
@@ -924,62 +380,14 @@ static float calc_vp_alpha_col_dl(VPaint *vp, ViewContext *vc,
return 0.0f;
}
-
-BLI_INLINE float wval_blend(const float weight, const float paintval, const float alpha)
-{
- const float talpha = min_ff(alpha, 1.0f); /* blending with values over 1 doesn't make sense */
- return (paintval * talpha) + (weight * (1.0f - talpha));
-}
-BLI_INLINE float wval_add(const float weight, const float paintval, const float alpha)
-{
- return weight + (paintval * alpha);
-}
-BLI_INLINE float wval_sub(const float weight, const float paintval, const float alpha)
-{
- return weight - (paintval * alpha);
-}
-BLI_INLINE float wval_mul(const float weight, const float paintval, const float alpha)
-{ /* first mul, then blend the fac */
- return ((1.0f - alpha) + (alpha * paintval)) * weight;
-}
-BLI_INLINE float wval_lighten(const float weight, const float paintval, const float alpha)
-{
- return (weight < paintval) ? wval_blend(weight, paintval, alpha) : weight;
-}
-BLI_INLINE float wval_darken(const float weight, const float paintval, const float alpha)
-{
- return (weight > paintval) ? wval_blend(weight, paintval, alpha) : weight;
-}
-
-
-/* vpaint has 'vpaint_blend_tool' */
-/* result is not clamped from [0-1] */
-static float wpaint_blend_tool(const int tool,
- /* dw->weight */
- const float weight,
- const float paintval, const float alpha)
-{
- switch (tool) {
- case PAINT_BLEND_MIX:
- case PAINT_BLEND_BLUR: return wval_blend(weight, paintval, alpha);
- case PAINT_BLEND_ADD: return wval_add(weight, paintval, alpha);
- case PAINT_BLEND_SUB: return wval_sub(weight, paintval, alpha);
- case PAINT_BLEND_MUL: return wval_mul(weight, paintval, alpha);
- case PAINT_BLEND_LIGHTEN: return wval_lighten(weight, paintval, alpha);
- case PAINT_BLEND_DARKEN: return wval_darken(weight, paintval, alpha);
- default:
- BLI_assert(0);
- return 0.0f;
- }
-}
-
/* vpaint has 'vpaint_blend' */
-static float wpaint_blend(VPaint *wp, float weight, float weight_prev,
- const float alpha, float paintval,
- const float brush_alpha_value,
- const short do_flip)
+static float wpaint_blend(
+ const VPaint *wp, float weight,
+ const float alpha, float paintval,
+ const float UNUSED(brush_alpha_value),
+ const short do_flip)
{
- Brush *brush = BKE_paint_brush(&wp->paint);
+ const Brush *brush = wp->paint.brush;
int tool = brush->vertexpaint_tool;
if (do_flip) {
@@ -996,257 +404,30 @@ static float wpaint_blend(VPaint *wp, float weight, float weight_prev,
tool = PAINT_BLEND_LIGHTEN; break;
}
}
-
- weight = wpaint_blend_tool(tool, weight, paintval, alpha);
- CLAMP(weight, 0.0f, 1.0f);
-
- /* if no spray, clip result with orig weight & orig alpha */
- if ((wp->flag & VP_SPRAY) == 0) {
- float testw = wpaint_blend_tool(tool, weight_prev, paintval, brush_alpha_value);
+ weight = ED_wpaint_blend_tool(tool, weight, paintval, alpha);
- CLAMP(testw, 0.0f, 1.0f);
- if (testw < weight_prev) {
- if (weight < testw) weight = testw;
- else if (weight > weight_prev) weight = weight_prev;
- }
- else {
- if (weight > testw) weight = testw;
- else if (weight < weight_prev) weight = weight_prev;
- }
- }
+ CLAMP(weight, 0.0f, 1.0f);
return weight;
}
-/* ----------------------------------------------------- */
-
-
-/* sets wp->weight to the closest weight value to vertex */
-/* note: we cant sample frontbuf, weight colors are interpolated too unpredictable */
-static int weight_sample_invoke(bContext *C, wmOperator *op, const wmEvent *event)
-{
- ViewContext vc;
- Mesh *me;
- bool changed = false;
-
- view3d_set_viewcontext(C, &vc);
- me = BKE_mesh_from_object(vc.obact);
-
- if (me && me->dvert && vc.v3d && vc.rv3d && (vc.obact->actdef != 0)) {
- const bool use_vert_sel = (me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0;
- int v_idx_best = -1;
- unsigned int index;
-
- view3d_operator_needs_opengl(C);
- ED_view3d_init_mats_rv3d(vc.obact, vc.rv3d);
-
- if (use_vert_sel) {
- if (ED_mesh_pick_vert(C, vc.obact, event->mval, &index, ED_MESH_PICK_DEFAULT_VERT_SIZE, true)) {
- v_idx_best = index;
- }
- }
- else {
- if (ED_mesh_pick_face_vert(C, vc.obact, event->mval, &index, ED_MESH_PICK_DEFAULT_FACE_SIZE)) {
- v_idx_best = index;
- }
- else if (ED_mesh_pick_face(C, vc.obact, event->mval, &index, ED_MESH_PICK_DEFAULT_FACE_SIZE)) {
- /* this relies on knowning the internal worksings of ED_mesh_pick_face_vert() */
- BKE_report(op->reports, RPT_WARNING, "The modifier used does not support deformed locations");
- }
- }
-
- if (v_idx_best != -1) { /* should always be valid */
- ToolSettings *ts = vc.scene->toolsettings;
- Brush *brush = BKE_paint_brush(&ts->wpaint->paint);
- const int vgroup_active = vc.obact->actdef - 1;
- float vgroup_weight = defvert_find_weight(&me->dvert[v_idx_best], vgroup_active);
-
- /* use combined weight in multipaint mode, since that's what is displayed to the user in the colors */
- if (ts->multipaint) {
- int defbase_tot_sel;
- const int defbase_tot = BLI_listbase_count(&vc.obact->defbase);
- bool *defbase_sel = BKE_object_defgroup_selected_get(vc.obact, defbase_tot, &defbase_tot_sel);
-
- if (defbase_tot_sel > 1) {
- if (me->editflag & ME_EDIT_MIRROR_X) {
- BKE_object_defgroup_mirror_selection(
- vc.obact, defbase_tot, defbase_sel, defbase_sel, &defbase_tot_sel);
- }
-
- vgroup_weight = BKE_defvert_multipaint_collective_weight(
- &me->dvert[v_idx_best], defbase_tot, defbase_sel, defbase_tot_sel, ts->auto_normalize);
-
- /* if autonormalize is enabled, but weights are not normalized, the value can exceed 1 */
- CLAMP(vgroup_weight, 0.0f, 1.0f);
- }
-
- MEM_freeN(defbase_sel);
- }
-
- BKE_brush_weight_set(vc.scene, brush, vgroup_weight);
- changed = true;
- }
- }
-
- if (changed) {
- /* not really correct since the brush didnt change, but redraws the toolbar */
- WM_main_add_notifier(NC_BRUSH | NA_EDITED, NULL); /* ts->wpaint->paint.brush */
-
- return OPERATOR_FINISHED;
- }
- else {
- return OPERATOR_CANCELLED;
- }
-}
-
-void PAINT_OT_weight_sample(wmOperatorType *ot)
+static float wpaint_clamp_monotonic(float oldval, float curval, float newval)
{
- /* identifiers */
- ot->name = "Weight Paint Sample Weight";
- ot->idname = "PAINT_OT_weight_sample";
- ot->description = "Use the mouse to sample a weight in the 3D view";
-
- /* api callbacks */
- ot->invoke = weight_sample_invoke;
- ot->poll = weight_paint_mode_poll;
-
- /* flags */
- ot->flag = OPTYPE_UNDO;
+ if (newval < oldval)
+ return MIN2(newval, curval);
+ else if (newval > oldval)
+ return MAX2(newval, curval);
+ else
+ return newval;
}
-/* samples cursor location, and gives menu with vertex groups to activate */
-static bool weight_paint_sample_enum_itemf__helper(const MDeformVert *dvert, const int defbase_tot, int *groups)
-{
- /* this func fills in used vgroup's */
- bool found = false;
- int i = dvert->totweight;
- MDeformWeight *dw;
- for (dw = dvert->dw; i > 0; dw++, i--) {
- if (dw->def_nr < defbase_tot) {
- groups[dw->def_nr] = true;
- found = true;
- }
- }
- return found;
-}
-static EnumPropertyItem *weight_paint_sample_enum_itemf(
- bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
-{
- if (C) {
- wmWindow *win = CTX_wm_window(C);
- if (win && win->eventstate) {
- ViewContext vc;
- Mesh *me;
-
- view3d_set_viewcontext(C, &vc);
- me = BKE_mesh_from_object(vc.obact);
-
- if (me && me->dvert && vc.v3d && vc.rv3d && vc.obact->defbase.first) {
- const int defbase_tot = BLI_listbase_count(&vc.obact->defbase);
- const bool use_vert_sel = (me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0;
- int *groups = MEM_callocN(defbase_tot * sizeof(int), "groups");
- bool found = false;
- unsigned int index;
-
- const int mval[2] = {
- win->eventstate->x - vc.ar->winrct.xmin,
- win->eventstate->y - vc.ar->winrct.ymin,
- };
-
- view3d_operator_needs_opengl(C);
- ED_view3d_init_mats_rv3d(vc.obact, vc.rv3d);
-
- if (use_vert_sel) {
- if (ED_mesh_pick_vert(C, vc.obact, mval, &index, ED_MESH_PICK_DEFAULT_VERT_SIZE, true)) {
- MDeformVert *dvert = &me->dvert[index];
- found |= weight_paint_sample_enum_itemf__helper(dvert, defbase_tot, groups);
- }
- }
- else {
- if (ED_mesh_pick_face(C, vc.obact, mval, &index, ED_MESH_PICK_DEFAULT_FACE_SIZE)) {
- MPoly *mp = &me->mpoly[index];
- unsigned int fidx = mp->totloop - 1;
-
- do {
- MDeformVert *dvert = &me->dvert[me->mloop[mp->loopstart + fidx].v];
- found |= weight_paint_sample_enum_itemf__helper(dvert, defbase_tot, groups);
- } while (fidx--);
- }
- }
-
- if (found == false) {
- MEM_freeN(groups);
- }
- else {
- EnumPropertyItem *item = NULL, item_tmp = {0};
- int totitem = 0;
- int i = 0;
- bDeformGroup *dg;
- for (dg = vc.obact->defbase.first; dg && i < defbase_tot; i++, dg = dg->next) {
- if (groups[i]) {
- item_tmp.identifier = item_tmp.name = dg->name;
- item_tmp.value = i;
- RNA_enum_item_add(&item, &totitem, &item_tmp);
- }
- }
-
- RNA_enum_item_end(&item, &totitem);
- *r_free = true;
-
- MEM_freeN(groups);
- return item;
- }
- }
- }
- }
-
- return DummyRNA_NULL_items;
-}
-
-static int weight_sample_group_exec(bContext *C, wmOperator *op)
-{
- int type = RNA_enum_get(op->ptr, "group");
- ViewContext vc;
- view3d_set_viewcontext(C, &vc);
-
- BLI_assert(type + 1 >= 0);
- vc.obact->actdef = type + 1;
-
- DEG_id_tag_update(&vc.obact->id, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, vc.obact);
- return OPERATOR_FINISHED;
-}
-
-/* TODO, we could make this a menu into OBJECT_OT_vertex_group_set_active rather than its own operator */
-void PAINT_OT_weight_sample_group(wmOperatorType *ot)
-{
- PropertyRNA *prop = NULL;
-
- /* identifiers */
- ot->name = "Weight Paint Sample Group";
- ot->idname = "PAINT_OT_weight_sample_group";
- ot->description = "Select one of the vertex groups available under current mouse position";
-
- /* api callbacks */
- ot->exec = weight_sample_group_exec;
- ot->invoke = WM_menu_invoke;
- ot->poll = weight_paint_mode_poll;
-
- /* flags */
- ot->flag = OPTYPE_UNDO;
-
- /* keyingset to use (dynamic enum) */
- prop = RNA_def_enum(ot->srna, "group", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use");
- RNA_def_enum_funcs(prop, weight_paint_sample_enum_itemf);
- RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
- ot->prop = prop;
-}
+/* ----------------------------------------------------- */
static void do_weight_paint_normalize_all(MDeformVert *dvert, const int defbase_tot, const bool *vgroup_validmap)
{
float sum = 0.0f, fac;
- unsigned int i, tot = 0;
+ uint i, tot = 0;
MDeformWeight *dw;
for (i = dvert->totweight, dw = dvert->dw; i != 0; i--, dw++) {
@@ -1292,7 +473,7 @@ static bool do_weight_paint_normalize_all_locked(
float sum = 0.0f, fac;
float sum_unlock = 0.0f;
float lock_weight = 0.0f;
- unsigned int i, tot = 0;
+ uint i, tot = 0;
MDeformWeight *dw;
if (lock_flags == NULL) {
@@ -1392,8 +573,9 @@ static void do_weight_paint_normalize_all_locked_try_active(
}
#if 0 /* UNUSED */
-static bool has_unselected_unlocked_bone_group(int defbase_tot, bool *defbase_sel, int selected,
- const bool *lock_flags, const bool *vgroup_validmap)
+static bool has_unselected_unlocked_bone_group(
+ int defbase_tot, bool *defbase_sel, int selected,
+ const bool *lock_flags, const bool *vgroup_validmap)
{
int i;
if (defbase_tot == selected) {
@@ -1477,7 +659,7 @@ static void multipaint_apply_change(MDeformVert *dvert, const int defbase_tot, f
* Variables stored both for 'active' and 'mirror' sides.
*/
struct WeightPaintGroupData {
- /** index of active group or its mirror
+ /** index of active group or its mirror
*
* - 'active' is always `ob->actdef`.
* - 'mirror' is -1 when 'ME_EDIT_MIRROR_X' flag id disabled,
@@ -1506,13 +688,15 @@ typedef struct WeightPaintInfo {
struct WeightPaintGroupData active, mirror;
- const bool *lock_flags; /* boolean array for locked bones,
- * length of defbase_tot */
- const bool *defbase_sel; /* boolean array for selected bones,
- * length of defbase_tot, cant be const because of how its passed */
-
- const bool *vgroup_validmap; /* same as WeightPaintData.vgroup_validmap,
- * only added here for convenience */
+ /* boolean array for locked bones,
+ * length of defbase_tot */
+ const bool *lock_flags;
+ /* boolean array for selected bones,
+ * length of defbase_tot, cant be const because of how its passed */
+ const bool *defbase_sel;
+ /* same as WeightPaintData.vgroup_validmap,
+ * only added here for convenience */
+ const bool *vgroup_validmap;
bool do_flip;
bool do_multipaint;
@@ -1523,16 +707,16 @@ typedef struct WeightPaintInfo {
static void do_weight_paint_vertex_single(
/* vars which remain the same for every vert */
- VPaint *wp, Object *ob, const WeightPaintInfo *wpi,
+ const VPaint *wp, Object *ob, const WeightPaintInfo *wpi,
/* vars which change on each stroke */
- const unsigned int index, float alpha, float paintweight
- )
+ const uint index, float alpha, float paintweight)
{
Mesh *me = ob->data;
MDeformVert *dv = &me->dvert[index];
bool topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0;
-
- MDeformWeight *dw, *dw_prev;
+
+ MDeformWeight *dw;
+ float weight_prev;
/* mirror vars */
int index_mirr;
@@ -1541,20 +725,6 @@ static void do_weight_paint_vertex_single(
MDeformVert *dv_mirr;
MDeformWeight *dw_mirr;
- if (wp->flag & VP_ONLYVGROUP) {
- dw = defvert_find_index(dv, wpi->active.index);
- dw_prev = defvert_find_index(wp->wpaint_prev + index, wpi->active.index);
- }
- else {
- dw = defvert_verify_index(dv, wpi->active.index);
- dw_prev = defvert_verify_index(wp->wpaint_prev + index, wpi->active.index);
- }
-
- if (dw == NULL || dw_prev == NULL) {
- return;
- }
-
-
/* from now on we can check if mirrors enabled if this var is -1 and not bother with the flag */
if (me->editflag & ME_EDIT_MIRROR_X) {
index_mirr = mesh_get_x_mirror_vert(ob, NULL, index, topology);
@@ -1570,11 +740,21 @@ static void do_weight_paint_vertex_single(
index_mirr = vgroup_mirr = -1;
}
+ if (wp->flag & VP_FLAG_VGROUP_RESTRICT) {
+ dw = defvert_find_index(dv, wpi->active.index);
+ }
+ else {
+ dw = defvert_verify_index(dv, wpi->active.index);
+ }
+
+ if (dw == NULL) {
+ return;
+ }
/* get the mirror def vars */
if (index_mirr != -1) {
dv_mirr = &me->dvert[index_mirr];
- if (wp->flag & VP_ONLYVGROUP) {
+ if (wp->flag & VP_FLAG_VGROUP_RESTRICT) {
dw_mirr = defvert_find_index(dv_mirr, vgroup_mirr);
if (dw_mirr == NULL) {
@@ -1604,12 +784,28 @@ static void do_weight_paint_vertex_single(
dw_mirr = NULL;
}
+ if ((wp->paint.brush->flag & BRUSH_ACCUMULATE) == 0) {
+ MDeformVert *dvert_prev = ob->sculpt->mode.wpaint.dvert_prev;
+ MDeformVert *dv_prev = defweight_prev_init(dvert_prev, me->dvert, index);
+ if (index_mirr != -1) {
+ defweight_prev_init(dvert_prev, me->dvert, index_mirr);
+ }
+
+ weight_prev = defvert_find_weight(dv_prev, wpi->active.index);
+ }
+ else {
+ weight_prev = dw->weight;
+ }
+
/* If there are no normalize-locks or multipaint,
* then there is no need to run the more complicated checks */
{
- dw->weight = wpaint_blend(wp, dw->weight, dw_prev->weight, alpha, paintweight,
- wpi->brush_alpha_value, wpi->do_flip);
+ float new_weight = wpaint_blend(
+ wp, weight_prev, alpha, paintweight,
+ wpi->brush_alpha_value, wpi->do_flip);
+
+ dw->weight = wpaint_clamp_monotonic(weight_prev, dw->weight, new_weight);
/* WATCH IT: take care of the ordering of applying mirror -> normalize,
* can give wrong results [#26193], least confusing if normalize is done last */
@@ -1668,13 +864,12 @@ static void do_weight_paint_vertex_single(
static void do_weight_paint_vertex_multi(
/* vars which remain the same for every vert */
- VPaint *wp, Object *ob, const WeightPaintInfo *wpi,
+ const VPaint *wp, Object *ob, const WeightPaintInfo *wpi,
/* vars which change on each stroke */
- const unsigned int index, float alpha, float paintweight)
+ const uint index, float alpha, float paintweight)
{
Mesh *me = ob->data;
MDeformVert *dv = &me->dvert[index];
- MDeformVert *dv_prev = &wp->wpaint_prev[index];
bool topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0;
/* mirror vars */
@@ -1682,7 +877,7 @@ static void do_weight_paint_vertex_multi(
MDeformVert *dv_mirr = NULL;
/* weights */
- float oldw, curw, neww, change, curw_mirr, change_mirr;
+ float curw, oldw, neww, change, curw_mirr, change_mirr;
/* from now on we can check if mirrors enabled if this var is -1 and not bother with the flag */
if (me->editflag & ME_EDIT_MIRROR_X) {
@@ -1691,11 +886,12 @@ static void do_weight_paint_vertex_multi(
if (index_mirr != -1 && index_mirr != index) {
dv_mirr = &me->dvert[index_mirr];
}
+ else {
+ index_mirr = -1;
+ }
}
/* compute weight change by applying the brush to average or sum of group weights */
- oldw = BKE_defvert_multipaint_collective_weight(
- dv_prev, wpi->defbase_tot, wpi->defbase_sel, wpi->defbase_tot_sel, wpi->do_auto_normalize);
curw = BKE_defvert_multipaint_collective_weight(
dv, wpi->defbase_tot, wpi->defbase_sel, wpi->defbase_tot_sel, wpi->do_auto_normalize);
@@ -1704,7 +900,22 @@ static void do_weight_paint_vertex_multi(
return;
}
- neww = wpaint_blend(wp, curw, oldw, alpha, paintweight, wpi->brush_alpha_value, wpi->do_flip);
+ if ((wp->paint.brush->flag & BRUSH_ACCUMULATE) == 0) {
+ MDeformVert *dvert_prev = ob->sculpt->mode.wpaint.dvert_prev;
+ MDeformVert *dv_prev = defweight_prev_init(dvert_prev, me->dvert, index);
+ if (index_mirr != -1) {
+ defweight_prev_init(dvert_prev, me->dvert, index_mirr);
+ }
+
+ oldw = BKE_defvert_multipaint_collective_weight(
+ dv_prev, wpi->defbase_tot, wpi->defbase_sel, wpi->defbase_tot_sel, wpi->do_auto_normalize);
+ }
+ else {
+ oldw = curw;
+ }
+
+ neww = wpaint_blend(wp, oldw, alpha, paintweight, wpi->brush_alpha_value, wpi->do_flip);
+ neww = wpaint_clamp_monotonic(oldw, curw, neww);
change = neww / curw;
@@ -1758,9 +969,9 @@ static void do_weight_paint_vertex_multi(
static void do_weight_paint_vertex(
/* vars which remain the same for every vert */
- VPaint *wp, Object *ob, const WeightPaintInfo *wpi,
+ const VPaint *wp, Object *ob, const WeightPaintInfo *wpi,
/* vars which change on each stroke */
- const unsigned int index, float alpha, float paintweight)
+ const uint index, float alpha, float paintweight)
{
if (wpi->do_multipaint) {
do_weight_paint_vertex_multi(wp, ob, wpi, index, alpha, paintweight);
@@ -1770,13 +981,101 @@ static void do_weight_paint_vertex(
}
}
+
+/* Toggle operator for turning vertex paint mode on or off (copied from sculpt.c) */
+static void vertex_paint_init_session(const EvaluationContext *eval_ctx, Scene *scene, Object *ob)
+{
+ if (ob->sculpt == NULL) {
+ ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session");
+ BKE_sculpt_update_mesh_elements(eval_ctx, scene, scene->toolsettings->sculpt, ob, 0, false);
+ }
+}
+
+static void vertex_paint_init_session_data(const ToolSettings *ts, Object *ob)
+{
+ /* Create maps */
+ struct SculptVertexPaintGeomMap *gmap = NULL;
+ const Brush *brush = NULL;
+ if (ob->mode == OB_MODE_VERTEX_PAINT) {
+ gmap = &ob->sculpt->mode.vpaint.gmap;
+ brush = BKE_paint_brush(&ts->vpaint->paint);
+ ob->sculpt->mode_type = OB_MODE_VERTEX_PAINT;
+ }
+ else if (ob->mode == OB_MODE_WEIGHT_PAINT) {
+ gmap = &ob->sculpt->mode.wpaint.gmap;
+ brush = BKE_paint_brush(&ts->wpaint->paint);
+ ob->sculpt->mode_type = OB_MODE_WEIGHT_PAINT;
+ }
+ else {
+ ob->sculpt->mode_type = 0;
+ BLI_assert(0);
+ return;
+ }
+
+ Mesh *me = ob->data;
+
+ if (gmap->vert_to_loop == NULL) {
+ gmap->vert_map_mem = NULL;
+ gmap->vert_to_loop = NULL;
+ gmap->poly_map_mem = NULL;
+ gmap->vert_to_poly = NULL;
+ BKE_mesh_vert_loop_map_create(
+ &gmap->vert_to_loop,
+ &gmap->vert_map_mem,
+ me->mpoly, me->mloop, me->totvert, me->totpoly, me->totloop);
+ BKE_mesh_vert_poly_map_create(
+ &gmap->vert_to_poly,
+ &gmap->poly_map_mem,
+ me->mpoly, me->mloop, me->totvert, me->totpoly, me->totloop);
+ }
+
+ /* Create average brush arrays */
+ if (ob->mode == OB_MODE_VERTEX_PAINT) {
+ if ((brush->flag & BRUSH_ACCUMULATE) == 0) {
+ if (ob->sculpt->mode.vpaint.previous_color == NULL) {
+ ob->sculpt->mode.vpaint.previous_color =
+ MEM_callocN(me->totloop * sizeof(uint), __func__);
+ }
+ }
+ else {
+ MEM_SAFE_FREE(ob->sculpt->mode.vpaint.previous_color);
+ }
+ }
+ else if (ob->mode == OB_MODE_WEIGHT_PAINT) {
+ if ((brush->flag & BRUSH_ACCUMULATE) == 0) {
+ if (ob->sculpt->mode.wpaint.alpha_weight == NULL) {
+ ob->sculpt->mode.wpaint.alpha_weight =
+ MEM_callocN(me->totvert * sizeof(float), __func__);
+ }
+ if (ob->sculpt->mode.wpaint.dvert_prev == NULL) {
+ ob->sculpt->mode.wpaint.dvert_prev =
+ MEM_callocN(me->totvert * sizeof(MDeformVert), __func__);
+ MDeformVert *dv = ob->sculpt->mode.wpaint.dvert_prev;
+ for (int i = 0; i < me->totvert; i++, dv++) {
+ /* Use to show this isn't initialized, never apply to the mesh data. */
+ dv->flag = 1;
+ }
+ }
+ }
+ else {
+ MEM_SAFE_FREE(ob->sculpt->mode.wpaint.alpha_weight);
+ if (ob->sculpt->mode.wpaint.dvert_prev != NULL) {
+ BKE_defvert_array_free_elems(ob->sculpt->mode.wpaint.dvert_prev, me->totvert);
+ MEM_freeN(ob->sculpt->mode.wpaint.dvert_prev);
+ ob->sculpt->mode.wpaint.dvert_prev = NULL;
+ }
+ }
+ }
+
+}
+
/* *************** set wpaint operator ****************** */
/**
* \note Keep in sync with #vpaint_mode_toggle_exec
*/
static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op)
-{
+{
Object *ob = CTX_data_active_object(C);
const int mode_flag = OB_MODE_WEIGHT_PAINT;
const bool is_mode_set = (ob->mode & mode_flag) != 0;
@@ -1806,13 +1105,25 @@ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op)
ED_mesh_mirror_spatial_table(NULL, NULL, NULL, NULL, 'e');
ED_mesh_mirror_topo_table(NULL, NULL, 'e');
+ /* If the cache is not released by a cancel or a done, free it now. */
+ if (ob->sculpt->cache) {
+ sculpt_cache_free(ob->sculpt->cache);
+ ob->sculpt->cache = NULL;
+ }
+
+ BKE_sculptsession_free(ob);
+
paint_cursor_delete_textures();
}
else {
+ EvaluationContext eval_ctx;
+
+ CTX_data_eval_ctx(C, &eval_ctx);
+
ob->mode |= mode_flag;
if (wp == NULL)
- wp = scene->toolsettings->wpaint = new_vpaint(1);
+ wp = scene->toolsettings->wpaint = new_vpaint();
paint_cursor_start(C, weight_paint_poll);
@@ -1821,9 +1132,15 @@ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op)
/* weight paint specific */
ED_mesh_mirror_spatial_table(ob, NULL, NULL, NULL, 's');
ED_vgroup_sync_from_pose(ob);
+
+ /* Create vertex/weight paint mode session data */
+ if (ob->sculpt) {
+ BKE_sculptsession_free(ob);
+ }
+ vertex_paint_init_session(&eval_ctx, scene, ob);
}
-
- BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_PAINT);
+
+ BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_ALL);
/* Weightpaint works by overriding colors in mesh,
* so need to make sure we recalc on enter and
@@ -1852,41 +1169,28 @@ static int paint_poll_test(bContext *C)
void PAINT_OT_weight_paint_toggle(wmOperatorType *ot)
{
-
+
/* identifiers */
ot->name = "Weight Paint Mode";
ot->idname = "PAINT_OT_weight_paint_toggle";
ot->description = "Toggle weight paint mode in 3D view";
-
+
/* api callbacks */
ot->exec = wpaint_mode_toggle_exec;
ot->poll = paint_poll_test;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
}
/* ************ weight paint operator ********** */
-enum eWPaintFlag {
- WPAINT_ENSURE_MIRROR = (1 << 0),
-};
-
-struct WPaintVGroupIndex {
- int active;
- int mirror;
-};
-
struct WPaintData {
ViewContext vc;
- int *indexar;
+ struct NormalAnglePrecalc normal_angle_precalc;
struct WeightPaintGroupData active, mirror;
- void *vp_handle;
- DMCoNo *vertexcosnos;
-
float wpimat[3][3];
/* variables for auto normalize */
@@ -1898,113 +1202,148 @@ struct WPaintData {
int defbase_tot_sel; /* number of selected groups */
bool do_multipaint; /* true if multipaint enabled and multiple groups selected */
- /* variables for blur */
- struct {
- MeshElemMap *vmap;
- int *vmap_mem;
- } blur_data;
-
- BLI_Stack *accumulate_stack; /* for reuse (WPaintDefer) */
-
int defbase_tot;
+
+ /* Special storage for smear brush, avoid feedback loop - update each step and swap. */
+ struct {
+ float *weight_prev;
+ float *weight_curr;
+ } smear;
};
-/* ensure we have data on wpaint start, add if needed */
-static bool wpaint_ensure_data(
- bContext *C, wmOperator *op,
- enum eWPaintFlag flag, struct WPaintVGroupIndex *vgroup_index)
+/* Initialize the stroke cache invariants from operator properties */
+static void vwpaint_update_cache_invariants(
+ bContext *C, const VPaint *vp, SculptSession *ss, wmOperator *op, const float mouse[2])
{
+ StrokeCache *cache;
Scene *scene = CTX_data_scene(C);
+ UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings;
+ const Brush *brush = vp->paint.brush;
+ ViewContext *vc = paint_stroke_view_context(op->customdata);
Object *ob = CTX_data_active_object(C);
- Mesh *me = BKE_mesh_from_object(ob);
+ float mat[3][3];
+ float view_dir[3] = {0.0f, 0.0f, 1.0f};
+ int mode;
- if (vgroup_index) {
- vgroup_index->active = -1;
- vgroup_index->mirror = -1;
+ /* VW paint needs to allocate stroke cache before update is called. */
+ if (!ss->cache) {
+ cache = MEM_callocN(sizeof(StrokeCache), "stroke cache");
+ ss->cache = cache;
}
-
- if (scene->obedit) {
- return false;
+ else {
+ cache = ss->cache;
}
- if (me == NULL || me->totpoly == 0) {
- return false;
- }
+ /* Initial mouse location */
+ if (mouse)
+ copy_v2_v2(cache->initial_mouse, mouse);
+ else
+ zero_v2(cache->initial_mouse);
- /* if nothing was added yet, we make dverts and a vertex deform group */
- if (!me->dvert) {
- BKE_object_defgroup_data_create(&me->id);
- WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
- }
+ mode = RNA_enum_get(op->ptr, "mode");
+ cache->invert = mode == BRUSH_STROKE_INVERT;
+ cache->alt_smooth = mode == BRUSH_STROKE_SMOOTH;
+ /* not very nice, but with current events system implementation
+ * we can't handle brush appearance inversion hotkey separately (sergey) */
+ if (cache->invert) ups->draw_inverted = true;
+ else ups->draw_inverted = false;
- /* this happens on a Bone select, when no vgroup existed yet */
- if (ob->actdef <= 0) {
- Object *modob;
- if ((modob = modifiers_isDeformedByArmature(ob))) {
- Bone *actbone = ((bArmature *)modob->data)->act_bone;
- if (actbone) {
- bPoseChannel *pchan = BKE_pose_channel_find_name(modob->pose, actbone->name);
+ copy_v2_v2(cache->mouse, cache->initial_mouse);
+ /* Truly temporary data that isn't stored in properties */
+ cache->vc = vc;
+ cache->brush = brush;
+ cache->first_time = 1;
- if (pchan) {
- bDeformGroup *dg = defgroup_find_name(ob, pchan->name);
- if (dg == NULL) {
- dg = BKE_object_defgroup_add_name(ob, pchan->name); /* sets actdef */
- }
- else {
- int actdef = 1 + BLI_findindex(&ob->defbase, dg);
- BLI_assert(actdef >= 0);
- ob->actdef = actdef;
- }
- }
- }
- }
- }
- if (BLI_listbase_is_empty(&ob->defbase)) {
- BKE_object_defgroup_add(ob);
- }
+ /* cache projection matrix */
+ ED_view3d_ob_project_mat_get(cache->vc->rv3d, ob, cache->projection_mat);
- /* ensure we don't try paint onto an invalid group */
- if (ob->actdef <= 0) {
- BKE_report(op->reports, RPT_WARNING, "No active vertex group for painting, aborting");
- return false;
+ invert_m4_m4(ob->imat, ob->obmat);
+ copy_m3_m4(mat, cache->vc->rv3d->viewinv);
+ mul_m3_v3(mat, view_dir);
+ copy_m3_m4(mat, ob->imat);
+ mul_m3_v3(mat, view_dir);
+ normalize_v3_v3(cache->true_view_normal, view_dir);
+
+ copy_v3_v3(cache->view_normal, cache->true_view_normal);
+ cache->bstrength = BKE_brush_alpha_get(scene, brush);
+ cache->is_last_valid = false;
+}
+
+/* Initialize the stroke cache variants from operator properties */
+static void vwpaint_update_cache_variants(bContext *C, VPaint *vp, Object *ob, PointerRNA *ptr)
+{
+ Scene *scene = CTX_data_scene(C);
+ SculptSession *ss = ob->sculpt;
+ StrokeCache *cache = ss->cache;
+ Brush *brush = BKE_paint_brush(&vp->paint);
+
+ /* This effects the actual brush radius, so things farther away
+ * are compared with a larger radius and vise versa. */
+ if (cache->first_time) {
+ RNA_float_get_array(ptr, "location", cache->true_location);
}
- if (vgroup_index) {
- vgroup_index->active = ob->actdef - 1;
+ RNA_float_get_array(ptr, "mouse", cache->mouse);
+
+ /* XXX: Use pressure value from first brush step for brushes which don't
+ * support strokes (grab, thumb). They depends on initial state and
+ * brush coord/pressure/etc.
+ * It's more an events design issue, which doesn't split coordinate/pressure/angle
+ * changing events. We should avoid this after events system re-design */
+ if (paint_supports_dynamic_size(brush, ePaintSculpt) || cache->first_time) {
+ cache->pressure = RNA_float_get(ptr, "pressure");
}
- if (flag & WPAINT_ENSURE_MIRROR) {
- if (me->editflag & ME_EDIT_MIRROR_X) {
- int mirror = wpaint_mirror_vgroup_ensure(ob, ob->actdef - 1);
- if (vgroup_index) {
- vgroup_index->mirror = mirror;
- }
+ /* Truly temporary data that isn't stored in properties */
+ if (cache->first_time) {
+ if (!BKE_brush_use_locked_size(scene, brush)) {
+ cache->initial_radius = paint_calc_object_space_radius(
+ cache->vc, cache->true_location, BKE_brush_size_get(scene, brush));
+ BKE_brush_unprojected_radius_set(scene, brush, cache->initial_radius);
+ }
+ else {
+ cache->initial_radius = BKE_brush_unprojected_radius_get(scene, brush);
}
}
- return true;
+ if (BKE_brush_use_size_pressure(scene, brush) && paint_supports_dynamic_size(brush, ePaintSculpt)) {
+ cache->radius = cache->initial_radius * cache->pressure;
+ }
+ else {
+ cache->radius = cache->initial_radius;
+ }
+
+ cache->radius_squared = cache->radius * cache->radius;
+
+ if (ss->pbvh) {
+ BKE_pbvh_update(ss->pbvh, PBVH_UpdateRedraw, NULL);
+ BKE_pbvh_update(ss->pbvh, PBVH_UpdateBB, NULL);
+ }
}
-static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float UNUSED(mouse[2]))
+static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float mouse[2])
{
Scene *scene = CTX_data_scene(C);
struct PaintStroke *stroke = op->customdata;
ToolSettings *ts = scene->toolsettings;
- VPaint *wp = ts->wpaint;
Object *ob = CTX_data_active_object(C);
Mesh *me = BKE_mesh_from_object(ob);
struct WPaintData *wpd;
struct WPaintVGroupIndex vgroup_index;
int defbase_tot, defbase_tot_sel;
bool *defbase_sel;
- const Brush *brush = BKE_paint_brush(&wp->paint);
+ SculptSession *ss = ob->sculpt;
+ VPaint *vp = CTX_data_tool_settings(C)->wpaint;
+ EvaluationContext eval_ctx;
float mat[4][4], imat[4][4];
- if (wpaint_ensure_data(C, op, WPAINT_ENSURE_MIRROR, &vgroup_index) == false) {
+ if (ED_wpaint_ensure_data(C, op->reports, WPAINT_ENSURE_MIRROR, &vgroup_index) == false) {
return false;
}
+ CTX_data_eval_ctx(C, &eval_ctx);
+
{
/* check if we are attempting to paint onto a locked vertex group,
* and other options disallow it from doing anything useful */
@@ -2052,6 +1391,8 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float UN
wpd = MEM_callocN(sizeof(struct WPaintData), "WPaintData");
paint_stroke_set_mode_data(stroke, wpd);
view3d_set_viewcontext(C, &wpd->vc);
+ view_angle_limits_init(&wpd->normal_angle_precalc, vp->paint.brush->falloff_angle,
+ (vp->paint.brush->flag & BRUSH_FRONTFACE_FALLOFF) != 0);
wpd->active.index = vgroup_index.active;
wpd->mirror.index = vgroup_index.mirror;
@@ -2096,22 +1437,24 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float UN
wpd->mirror.lock = tmpflags;
}
- /* painting on subsurfs should give correct points too, this returns me->totvert amount */
- wpd->vp_handle = ED_vpaint_proj_handle_create(scene, ob, &wpd->vertexcosnos);
-
- wpd->indexar = get_indexarray(me);
- copy_wpaint_prev(wp, me->dvert, me->totvert);
-
- if (brush->vertexpaint_tool == PAINT_BLEND_BLUR) {
- BKE_mesh_vert_edge_vert_map_create(
- &wpd->blur_data.vmap, &wpd->blur_data.vmap_mem,
- me->medge, me->totvert, me->totedge);
- }
-
- if ((brush->vertexpaint_tool == PAINT_BLEND_BLUR) &&
- (brush->flag & BRUSH_ACCUMULATE))
- {
- wpd->accumulate_stack = BLI_stack_new(sizeof(struct WPaintDefer), __func__);
+ if (vp->paint.brush->vertexpaint_tool == PAINT_BLEND_SMEAR) {
+ wpd->smear.weight_prev = MEM_mallocN(sizeof(float) * me->totvert, __func__);
+ const MDeformVert *dv = me->dvert;
+ if (wpd->do_multipaint) {
+ const bool do_auto_normalize = ((ts->auto_normalize != 0) && (wpd->vgroup_validmap != NULL));
+ for (int i = 0; i < me->totvert; i++, dv++) {
+ float weight = BKE_defvert_multipaint_collective_weight(
+ dv, wpd->defbase_tot, wpd->defbase_sel, wpd->defbase_tot_sel, do_auto_normalize);
+ CLAMP(weight, 0.0f, 1.0f);
+ wpd->smear.weight_prev[i] = weight;
+ }
+ }
+ else {
+ for (int i = 0; i < me->totvert; i++, dv++) {
+ wpd->smear.weight_prev[i] = defvert_find_weight(dv, wpd->active.index);
+ }
+ }
+ wpd->smear.weight_curr = MEM_dupallocN(wpd->smear.weight_prev);
}
/* imat for normals */
@@ -2119,40 +1462,549 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float UN
invert_m4_m4(imat, mat);
copy_m3_m4(wpd->wpimat, imat);
+ /* If not previously created, create vertex/weight paint mode session data */
+ vertex_paint_init_session(&eval_ctx, scene, ob);
+ vwpaint_update_cache_invariants(C, vp, ss, op, mouse);
+ vertex_paint_init_session_data(ts, ob);
+
+ if (ob->sculpt->mode.wpaint.dvert_prev != NULL) {
+ MDeformVert *dv = ob->sculpt->mode.wpaint.dvert_prev;
+ for (int i = 0; i < me->totvert; i++, dv++) {
+ /* Use to show this isn't initialized, never apply to the mesh data. */
+ dv->flag = 1;
+ }
+ }
+
return true;
}
-static float wpaint_blur_weight_single(const MDeformVert *dv, const WeightPaintInfo *wpi)
+static float dot_vf3vs3(const float brushNormal[3], const short vertexNormal[3])
{
- return defvert_find_weight(dv, wpi->active.index);
+ float normal[3];
+ normal_short_to_float_v3(normal, vertexNormal);
+ return dot_v3v3(brushNormal, normal);
}
-static float wpaint_blur_weight_multi(const MDeformVert *dv, const WeightPaintInfo *wpi)
+static void get_brush_alpha_data(
+ const Scene *scene, const SculptSession *ss, const Brush *brush,
+ float *r_brush_size_pressure, float *r_brush_alpha_value, float *r_brush_alpha_pressure)
{
- float weight = BKE_defvert_multipaint_collective_weight(
- dv, wpi->defbase_tot, wpi->defbase_sel, wpi->defbase_tot_sel, wpi->do_auto_normalize);
- CLAMP(weight, 0.0f, 1.0f);
- return weight;
+ *r_brush_size_pressure =
+ BKE_brush_size_get(scene, brush) *
+ (BKE_brush_use_size_pressure(scene, brush) ? ss->cache->pressure : 1.0f);
+ *r_brush_alpha_value =
+ BKE_brush_alpha_get(scene, brush);
+ *r_brush_alpha_pressure =
+ (BKE_brush_use_alpha_pressure(scene, brush) ? ss->cache->pressure : 1.0f);
+}
+
+static float wpaint_get_active_weight(const MDeformVert *dv, const WeightPaintInfo *wpi)
+{
+ if (wpi->do_multipaint) {
+ float weight = BKE_defvert_multipaint_collective_weight(
+ dv, wpi->defbase_tot, wpi->defbase_sel, wpi->defbase_tot_sel, wpi->do_auto_normalize);
+
+ CLAMP(weight, 0.0f, 1.0f);
+ return weight;
+ }
+ else {
+ return defvert_find_weight(dv, wpi->active.index);
+ }
+}
+
+static void do_wpaint_brush_blur_task_cb_ex(
+ void *userdata, void *UNUSED(userdata_chunk), const int n, const int UNUSED(thread_id))
+{
+ SculptThreadedTaskData *data = userdata;
+ SculptSession *ss = data->ob->sculpt;
+ CCGDerivedMesh *ccgdm = BKE_pbvh_get_ccgdm(ss->pbvh);
+ const struct SculptVertexPaintGeomMap *gmap = &ss->mode.wpaint.gmap;
+
+ const Brush *brush = data->brush;
+ const StrokeCache *cache = ss->cache;
+ Scene *scene = CTX_data_scene(data->C);
+
+ float brush_size_pressure, brush_alpha_value, brush_alpha_pressure;
+ get_brush_alpha_data(scene, ss, brush, &brush_size_pressure, &brush_alpha_value, &brush_alpha_pressure);
+ const bool use_normal = vwpaint_use_normal(data->vp);
+ const bool use_face_sel = (data->me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
+ const bool use_vert_sel = (data->me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0;
+
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn =
+ sculpt_brush_test_init_with_falloff_shape(ss, &test, data->brush->falloff_shape);
+ const float *sculpt_normal_frontface =
+ sculpt_brush_frontface_normal_from_falloff_shape(ss, data->brush->falloff_shape);
+
+ /* For each vertex */
+ PBVHVertexIter vd;
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
+ {
+ /* Test to see if the vertex coordinates are within the spherical brush region. */
+ if (sculpt_brush_test_sq_fn(&test, vd.co)) {
+ /* For grid based pbvh, take the vert whose loop coopresponds to the current grid.
+ * Otherwise, take the current vert. */
+ const int v_index = ccgdm ? data->me->mloop[vd.grid_indices[vd.g]].v : vd.vert_indices[vd.i];
+ const float grid_alpha = ccgdm ? 1.0f / vd.gridsize : 1.0f;
+ const char v_flag = data->me->mvert[v_index].flag;
+ /* If the vertex is selected */
+ if (!(use_face_sel || use_vert_sel) || v_flag & SELECT) {
+ /* Get the average poly weight */
+ int total_hit_loops = 0;
+ float weight_final = 0.0f;
+ for (int j = 0; j < gmap->vert_to_poly[v_index].count; j++) {
+ const int p_index = gmap->vert_to_poly[v_index].indices[j];
+ const MPoly *mp = &data->me->mpoly[p_index];
+
+ total_hit_loops += mp->totloop;
+ for (int k = 0; k < mp->totloop; k++) {
+ const int l_index = mp->loopstart + k;
+ const MLoop *ml = &data->me->mloop[l_index];
+ const MDeformVert *dv = &data->me->dvert[ml->v];
+ weight_final += wpaint_get_active_weight(dv, data->wpi);
+ }
+ }
+
+ /* Apply the weight to the vertex. */
+ if (total_hit_loops != 0) {
+ float brush_strength = cache->bstrength;
+ const float angle_cos = (use_normal && vd.no) ?
+ dot_vf3vs3(sculpt_normal_frontface, vd.no) : 1.0f;
+ if (((brush->flag & BRUSH_FRONTFACE) == 0 ||
+ (angle_cos > 0.0f)) &&
+ ((brush->flag & BRUSH_FRONTFACE_FALLOFF) == 0 ||
+ view_angle_limits_apply_falloff(&data->wpd->normal_angle_precalc, angle_cos, &brush_strength)))
+ {
+ const float brush_fade = BKE_brush_curve_strength(brush, sqrtf(test.dist), cache->radius);
+ const float final_alpha =
+ brush_fade * brush_strength *
+ grid_alpha * brush_alpha_pressure;
+
+ if ((brush->flag & BRUSH_ACCUMULATE) == 0) {
+ if (ss->mode.wpaint.alpha_weight[v_index] < final_alpha) {
+ ss->mode.wpaint.alpha_weight[v_index] = final_alpha;
+ }
+ else {
+ continue;
+ }
+ }
+
+ weight_final /= total_hit_loops;
+ /* Only paint visable verts */
+ do_weight_paint_vertex(
+ data->vp, data->ob, data->wpi,
+ v_index, final_alpha, weight_final);
+ }
+ }
+ }
+ }
+ }
+ BKE_pbvh_vertex_iter_end;
+}
+
+static void do_wpaint_brush_smear_task_cb_ex(
+ void *userdata, void *UNUSED(userdata_chunk), const int n, const int UNUSED(thread_id))
+{
+ SculptThreadedTaskData *data = userdata;
+ SculptSession *ss = data->ob->sculpt;
+ CCGDerivedMesh *ccgdm = BKE_pbvh_get_ccgdm(ss->pbvh);
+ const struct SculptVertexPaintGeomMap *gmap = &ss->mode.wpaint.gmap;
+
+ const Brush *brush = data->brush;
+ const Scene *scene = CTX_data_scene(data->C);
+ const StrokeCache *cache = ss->cache;
+ float brush_size_pressure, brush_alpha_value, brush_alpha_pressure;
+ get_brush_alpha_data(scene, ss, brush, &brush_size_pressure, &brush_alpha_value, &brush_alpha_pressure);
+ const bool use_normal = vwpaint_use_normal(data->vp);
+ const bool use_face_sel = (data->me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
+ const bool use_vert_sel = (data->me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0;
+ float brush_dir[3];
+
+ sub_v3_v3v3(brush_dir, cache->location, cache->last_location);
+ project_plane_v3_v3v3(brush_dir, brush_dir, cache->view_normal);
+
+ if (cache->is_last_valid && (normalize_v3(brush_dir) != 0.0f)) {
+
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn =
+ sculpt_brush_test_init_with_falloff_shape(ss, &test, data->brush->falloff_shape);
+ const float *sculpt_normal_frontface =
+ sculpt_brush_frontface_normal_from_falloff_shape(ss, data->brush->falloff_shape);
+
+ /* For each vertex */
+ PBVHVertexIter vd;
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
+ {
+ /* Test to see if the vertex coordinates are within the spherical brush region. */
+ if (sculpt_brush_test_sq_fn(&test, vd.co)) {
+ /* For grid based pbvh, take the vert whose loop cooresponds to the current grid.
+ * Otherwise, take the current vert. */
+ const int v_index = ccgdm ? data->me->mloop[vd.grid_indices[vd.g]].v : vd.vert_indices[vd.i];
+ const float grid_alpha = ccgdm ? 1.0f / vd.gridsize : 1.0f;
+ const MVert *mv_curr = &data->me->mvert[v_index];
+
+ /* If the vertex is selected */
+ if (!(use_face_sel || use_vert_sel) || mv_curr->flag & SELECT) {
+ float brush_strength = cache->bstrength;
+ const float angle_cos = (use_normal && vd.no) ?
+ dot_vf3vs3(sculpt_normal_frontface, vd.no) : 1.0f;
+ if (((brush->flag & BRUSH_FRONTFACE) == 0 ||
+ (angle_cos > 0.0f)) &&
+ ((brush->flag & BRUSH_FRONTFACE_FALLOFF) == 0 ||
+ view_angle_limits_apply_falloff(&data->wpd->normal_angle_precalc, angle_cos, &brush_strength)))
+ {
+ bool do_color = false;
+ /* Minimum dot product between brush direction and current
+ * to neighbor direction is 0.0, meaning orthogonal. */
+ float stroke_dot_max = 0.0f;
+
+ /* Get the color of the loop in the opposite direction of the brush movement
+ * (this callback is specifically for smear.) */
+ float weight_final = 0.0;
+ for (int j = 0; j < gmap->vert_to_poly[v_index].count; j++) {
+ const int p_index = gmap->vert_to_poly[v_index].indices[j];
+ const MPoly *mp = &data->me->mpoly[p_index];
+ const MLoop *ml_other = &data->me->mloop[mp->loopstart];
+ for (int k = 0; k < mp->totloop; k++, ml_other++) {
+ const uint v_other_index = ml_other->v;
+ if (v_other_index != v_index) {
+ const MVert *mv_other = &data->me->mvert[v_other_index];
+
+ /* Get the direction from the selected vert to the neighbor. */
+ float other_dir[3];
+ sub_v3_v3v3(other_dir, mv_curr->co, mv_other->co);
+ project_plane_v3_v3v3(other_dir, other_dir, cache->view_normal);
+
+ normalize_v3(other_dir);
+
+ const float stroke_dot = dot_v3v3(other_dir, brush_dir);
+
+ if (stroke_dot > stroke_dot_max) {
+ stroke_dot_max = stroke_dot;
+ weight_final = data->wpd->smear.weight_prev[v_other_index];
+ do_color = true;
+ }
+ }
+ }
+ }
+ /* Apply weight to vertex */
+ if (do_color) {
+ const float brush_fade = BKE_brush_curve_strength(brush, sqrtf(test.dist), cache->radius);
+ const float final_alpha =
+ brush_fade * brush_strength *
+ grid_alpha * brush_alpha_pressure;
+ do_weight_paint_vertex(
+ data->vp, data->ob, data->wpi,
+ v_index, final_alpha, (float)weight_final);
+ /* Access the weight again because it might not have been applied completely. */
+ data->wpd->smear.weight_curr[v_index] =
+ wpaint_get_active_weight(&data->me->dvert[v_index], data->wpi);
+ }
+ }
+ }
+ }
+ }
+ BKE_pbvh_vertex_iter_end;
+ }
+}
+
+static void do_wpaint_brush_draw_task_cb_ex(
+ void *userdata, void *UNUSED(userdata_chunk), const int n, const int UNUSED(thread_id))
+{
+ SculptThreadedTaskData *data = userdata;
+ SculptSession *ss = data->ob->sculpt;
+ CCGDerivedMesh *ccgdm = BKE_pbvh_get_ccgdm(ss->pbvh);
+ const Scene *scene = CTX_data_scene(data->C);
+
+ const Brush *brush = data->brush;
+ const StrokeCache *cache = ss->cache;
+ /* note: normally `BKE_brush_weight_get(scene, brush)` is used,
+ * however in this case we calculate a new weight each time. */
+ const float paintweight = data->strength;
+ float brush_size_pressure, brush_alpha_value, brush_alpha_pressure;
+ get_brush_alpha_data(scene, ss, brush, &brush_size_pressure, &brush_alpha_value, &brush_alpha_pressure);
+ const bool use_normal = vwpaint_use_normal(data->vp);
+ const bool use_face_sel = (data->me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
+ const bool use_vert_sel = (data->me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0;
+
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn =
+ sculpt_brush_test_init_with_falloff_shape(ss, &test, data->brush->falloff_shape);
+ const float *sculpt_normal_frontface =
+ sculpt_brush_frontface_normal_from_falloff_shape(ss, data->brush->falloff_shape);
+
+ /* For each vertex */
+ PBVHVertexIter vd;
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
+ {
+ /* Test to see if the vertex coordinates are within the spherical brush region. */
+ if (sculpt_brush_test_sq_fn(&test, vd.co)) {
+ /* Note: grids are 1:1 with corners (aka loops).
+ * For multires, take the vert whose loop cooresponds to the current grid.
+ * Otherwise, take the current vert. */
+ const int v_index = ccgdm ? data->me->mloop[vd.grid_indices[vd.g]].v : vd.vert_indices[vd.i];
+ const float grid_alpha = ccgdm ? 1.0f / vd.gridsize : 1.0f;
+
+ const char v_flag = data->me->mvert[v_index].flag;
+ /* If the vertex is selected */
+ if (!(use_face_sel || use_vert_sel) || v_flag & SELECT) {
+ float brush_strength = cache->bstrength;
+ const float angle_cos = (use_normal && vd.no) ?
+ dot_vf3vs3(sculpt_normal_frontface, vd.no) : 1.0f;
+ if (((brush->flag & BRUSH_FRONTFACE) == 0 ||
+ (angle_cos > 0.0f)) &&
+ ((brush->flag & BRUSH_FRONTFACE_FALLOFF) == 0 ||
+ view_angle_limits_apply_falloff(&data->wpd->normal_angle_precalc, angle_cos, &brush_strength)))
+ {
+ const float brush_fade = BKE_brush_curve_strength(brush, sqrtf(test.dist), cache->radius);
+ const float final_alpha = brush_fade * brush_strength * grid_alpha * brush_alpha_pressure;
+
+ if ((brush->flag & BRUSH_ACCUMULATE) == 0) {
+ if (ss->mode.wpaint.alpha_weight[v_index] < final_alpha) {
+ ss->mode.wpaint.alpha_weight[v_index] = final_alpha;
+ }
+ else {
+ continue;
+ }
+ }
+
+ do_weight_paint_vertex(
+ data->vp, data->ob, data->wpi,
+ v_index, final_alpha, paintweight);
+ }
+ }
+ }
+ }
+ BKE_pbvh_vertex_iter_end;
+}
+
+static void do_wpaint_brush_calc_average_weight_cb_ex(
+ void *userdata, void *UNUSED(userdata_chunk), const int n, const int UNUSED(thread_id))
+{
+ SculptThreadedTaskData *data = userdata;
+ SculptSession *ss = data->ob->sculpt;
+ StrokeCache *cache = ss->cache;
+ CCGDerivedMesh *ccgdm = BKE_pbvh_get_ccgdm(ss->pbvh);
+
+ const bool use_normal = vwpaint_use_normal(data->vp);
+ const bool use_face_sel = (data->me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
+ const bool use_vert_sel = (data->me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0;
+
+ struct WPaintAverageAccum *accum = (struct WPaintAverageAccum *)data->custom_data + n;
+ accum->len = 0;
+ accum->value = 0.0;
+
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn =
+ sculpt_brush_test_init_with_falloff_shape(ss, &test, data->brush->falloff_shape);
+ const float *sculpt_normal_frontface =
+ sculpt_brush_frontface_normal_from_falloff_shape(ss, data->brush->falloff_shape);
+
+ /* For each vertex */
+ PBVHVertexIter vd;
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
+ {
+ /* Test to see if the vertex coordinates are within the spherical brush region. */
+ if (sculpt_brush_test_sq_fn(&test, vd.co)) {
+ const float angle_cos = (use_normal && vd.no) ?
+ dot_vf3vs3(sculpt_normal_frontface, vd.no) : 1.0f;
+ if (angle_cos > 0.0 && BKE_brush_curve_strength(data->brush, sqrtf(test.dist), cache->radius) > 0.0) {
+ const int v_index = ccgdm ? data->me->mloop[vd.grid_indices[vd.g]].v : vd.vert_indices[vd.i];
+ // const float grid_alpha = ccgdm ? 1.0f / vd.gridsize : 1.0f;
+ const char v_flag = data->me->mvert[v_index].flag;
+
+ /* If the vertex is selected. */
+ if (!(use_face_sel || use_vert_sel) || v_flag & SELECT) {
+ const MDeformVert *dv = &data->me->dvert[v_index];
+ accum->len += 1;
+ accum->value += wpaint_get_active_weight(dv, data->wpi);
+ }
+ }
+ }
+ }
+ BKE_pbvh_vertex_iter_end;
+}
+
+static void calculate_average_weight(SculptThreadedTaskData *data, PBVHNode **UNUSED(nodes), int totnode)
+{
+ struct WPaintAverageAccum *accum = MEM_mallocN(sizeof(*accum) * totnode, __func__);
+ data->custom_data = accum;
+
+ BLI_task_parallel_range_ex(
+ 0, totnode, data, NULL, 0, do_wpaint_brush_calc_average_weight_cb_ex,
+ ((data->sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT), false);
+
+ uint accum_len = 0;
+ double accum_weight = 0.0;
+ for (int i = 0; i < totnode; i++) {
+ accum_len += accum[i].len;
+ accum_weight += accum[i].value;
+ }
+ if (accum_len != 0) {
+ accum_weight /= accum_len;
+ data->strength = (float)accum_weight;
+ }
+
+ MEM_SAFE_FREE(data->custom_data); /* 'accum' */
+}
+
+
+static void wpaint_paint_leaves(
+ bContext *C, Object *ob, Sculpt *sd, VPaint *vp, struct WPaintData *wpd, WeightPaintInfo *wpi,
+ Mesh *me, PBVHNode **nodes, int totnode)
+{
+ Scene *scene = CTX_data_scene(C);
+ const Brush *brush = ob->sculpt->cache->brush;
+
+ /* threaded loop over nodes */
+ SculptThreadedTaskData data = {
+ .sd = sd, .ob = ob, .brush = brush, .nodes = nodes, .vp = vp, .wpd = wpd, .wpi = wpi, .me = me, .C = C,
+ };
+
+ /* Use this so average can modify its weight without touching the brush. */
+ data.strength = BKE_brush_weight_get(scene, brush);
+
+ /* current mirroring code cannot be run in parallel */
+ bool use_threading = !(me->editflag & ME_EDIT_MIRROR_X);
+
+ switch (brush->vertexpaint_tool) {
+ case PAINT_BLEND_AVERAGE:
+ calculate_average_weight(&data, nodes, totnode);
+ BLI_task_parallel_range_ex(
+ 0, totnode, &data, NULL, 0,
+ do_wpaint_brush_draw_task_cb_ex, use_threading, false);
+ break;
+ case PAINT_BLEND_SMEAR:
+ BLI_task_parallel_range_ex(
+ 0, totnode, &data, NULL, 0,
+ do_wpaint_brush_smear_task_cb_ex, use_threading, false);
+ break;
+ case PAINT_BLEND_BLUR:
+ BLI_task_parallel_range_ex(
+ 0, totnode, &data, NULL, 0,
+ do_wpaint_brush_blur_task_cb_ex, use_threading, false);
+ break;
+ default:
+ BLI_task_parallel_range_ex(
+ 0, totnode, &data, NULL, 0,
+ do_wpaint_brush_draw_task_cb_ex, use_threading, false);
+ break;
+ }
}
-static float wpaint_blur_weight_calc_from_connected(
- const MDeformVert *dvert, WeightPaintInfo *wpi, struct WPaintData *wpd, const unsigned int vidx,
- float (*blur_weight_func)(const MDeformVert *, const WeightPaintInfo *))
+static PBVHNode **vwpaint_pbvh_gather_generic(
+ Object *ob, VPaint *wp, Sculpt *sd, Brush *brush, int *r_totnode)
{
- const MeshElemMap *map = &wpd->blur_data.vmap[vidx];
- float paintweight;
- if (map->count != 0) {
- paintweight = 0.0f;
- for (int j = 0; j < map->count; j++) {
- paintweight += blur_weight_func(&dvert[map->indices[j]], wpi);
+ SculptSession *ss = ob->sculpt;
+ const bool use_normal = vwpaint_use_normal(wp);
+ PBVHNode **nodes = NULL;
+
+ /* Build a list of all nodes that are potentially within the brush's area of influence */
+ if (brush->falloff_shape == PAINT_FALLOFF_SHAPE_SPHERE) {
+ SculptSearchSphereData data = {
+ .ss = ss,
+ .sd = sd,
+ .radius_squared = ss->cache->radius_squared,
+ .original = true,
+ };
+ BKE_pbvh_search_gather(ss->pbvh, sculpt_search_sphere_cb, &data, &nodes, r_totnode);
+ if (use_normal) {
+ sculpt_pbvh_calc_area_normal(brush, ob, nodes, *r_totnode, true, ss->cache->sculpt_normal_symm);
+ }
+ else {
+ zero_v3(ss->cache->sculpt_normal_symm);
}
- paintweight /= map->count;
}
else {
- paintweight = blur_weight_func(&dvert[vidx], wpi);
+ struct DistRayAABB_Precalc dist_ray_to_aabb_precalc;
+ dist_squared_ray_to_aabb_v3_precalc(&dist_ray_to_aabb_precalc, ss->cache->location, ss->cache->view_normal);
+ SculptSearchCircleData data = {
+ .ss = ss,
+ .sd = sd,
+ .radius_squared = ss->cache->radius_squared,
+ .original = true,
+ .dist_ray_to_aabb_precalc = &dist_ray_to_aabb_precalc,
+ };
+ BKE_pbvh_search_gather(ss->pbvh, sculpt_search_circle_cb, &data, &nodes, r_totnode);
+ if (use_normal) {
+ copy_v3_v3(ss->cache->sculpt_normal_symm, ss->cache->view_normal);
+ }
+ else {
+ zero_v3(ss->cache->sculpt_normal_symm);
+ }
+ }
+ return nodes;
+}
+
+static void wpaint_do_paint(
+ bContext *C, Object *ob, VPaint *wp, Sculpt *sd, struct WPaintData *wpd, WeightPaintInfo *wpi,
+ Mesh *me, Brush *brush, const char symm, const int axis, const int i, const float angle)
+{
+ SculptSession *ss = ob->sculpt;
+ ss->cache->radial_symmetry_pass = i;
+ sculpt_cache_calc_brushdata_symm(ss->cache, symm, axis, angle);
+
+ int totnode;
+ PBVHNode **nodes = vwpaint_pbvh_gather_generic(ob, wp, sd, brush, &totnode);
+
+ wpaint_paint_leaves(C, ob, sd, wp, wpd, wpi, me, nodes, totnode);
+
+ if (nodes)
+ MEM_freeN(nodes);
+}
+
+static void wpaint_do_radial_symmetry(
+ bContext *C, Object *ob, VPaint *wp, Sculpt *sd, struct WPaintData *wpd, WeightPaintInfo *wpi,
+ Mesh *me, Brush *brush, const char symm, const int axis)
+{
+ for (int i = 1; i < wp->radial_symm[axis - 'X']; i++) {
+ const float angle = (2.0 * M_PI) * i / wp->radial_symm[axis - 'X'];
+ wpaint_do_paint(C, ob, wp, sd, wpd, wpi, me, brush, symm, axis, i, angle);
}
+}
- return paintweight;
+/* near duplicate of: sculpt.c's, 'do_symmetrical_brush_actions' and 'vpaint_do_symmetrical_brush_actions'. */
+static void wpaint_do_symmetrical_brush_actions(
+ bContext *C, Object *ob, VPaint *wp, Sculpt *sd, struct WPaintData *wpd, WeightPaintInfo *wpi)
+{
+ Brush *brush = BKE_paint_brush(&wp->paint);
+ Mesh *me = ob->data;
+ SculptSession *ss = ob->sculpt;
+ StrokeCache *cache = ss->cache;
+ const char symm = wp->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
+ int i = 0;
+
+ /* initial stroke */
+ wpaint_do_paint(C, ob, wp, sd, wpd, wpi, me, brush, 0, 'X', 0, 0);
+ wpaint_do_radial_symmetry(C, ob, wp, sd, wpd, wpi, me, brush, 0, 'X');
+ wpaint_do_radial_symmetry(C, ob, wp, sd, wpd, wpi, me, brush, 0, 'Y');
+ wpaint_do_radial_symmetry(C, ob, wp, sd, wpd, wpi, me, brush, 0, 'Z');
+
+ cache->symmetry = symm;
+
+ /* symm is a bit combination of XYZ - 1 is mirror X; 2 is Y; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ */
+ for (i = 1; i <= symm; i++) {
+ if ((symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5)))) {
+ cache->mirror_symmetry_pass = i;
+ cache->radial_symmetry_pass = 0;
+ sculpt_cache_calc_brushdata_symm(cache, i, 0, 0);
+
+ if (i & (1 << 0)) {
+ wpaint_do_paint(C, ob, wp, sd, wpd, wpi, me, brush, i, 'X', 0, 0);
+ wpaint_do_radial_symmetry(C, ob, wp, sd, wpd, wpi, me, brush, i, 'X');
+ }
+ if (i & (1 << 1)) {
+ wpaint_do_paint(C, ob, wp, sd, wpd, wpi, me, brush, i, 'Y', 0, 0);
+ wpaint_do_radial_symmetry(C, ob, wp, sd, wpd, wpi, me, brush, i, 'Y');
+ }
+ if (i & (1 << 2)) {
+ wpaint_do_paint(C, ob, wp, sd, wpd, wpi, me, brush, i, 'Z', 0, 0);
+ wpaint_do_radial_symmetry(C, ob, wp, sd, wpd, wpi, me, brush, i, 'Z');
+ }
+ }
+ }
+ copy_v3_v3(cache->true_last_location, cache->true_location);
+ cache->is_last_valid = true;
}
static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerRNA *itemptr)
@@ -2163,24 +2015,17 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
Brush *brush = BKE_paint_brush(&wp->paint);
struct WPaintData *wpd = paint_stroke_mode_data(stroke);
ViewContext *vc;
- Object *ob;
- Mesh *me;
+ Object *ob = CTX_data_active_object(C);
+
+ SculptSession *ss = ob->sculpt;
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+
+ vwpaint_update_cache_variants(C, wp, ob, itemptr);
+
float mat[4][4];
- float paintweight;
- int *indexar;
- unsigned int index, totindex;
float mval[2];
- const bool use_blur = (brush->vertexpaint_tool == PAINT_BLEND_BLUR);
- bool use_vert_sel;
- bool use_face_sel;
- bool use_depth;
-
- const float pressure = RNA_float_get(itemptr, "pressure");
- const float brush_size_pressure =
- BKE_brush_size_get(scene, brush) * (BKE_brush_use_size_pressure(scene, brush) ? pressure : 1.0f);
+
const float brush_alpha_value = BKE_brush_alpha_get(scene, brush);
- const float brush_alpha_pressure =
- brush_alpha_value * (BKE_brush_use_alpha_pressure(scene, brush) ? pressure : 1.0f);
/* intentionally don't initialize as NULL, make sure we initialize all members below */
WeightPaintInfo wpi;
@@ -2193,21 +2038,15 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
return;
}
- float (*blur_weight_func)(const MDeformVert *, const WeightPaintInfo *) =
- wpd->do_multipaint ? wpaint_blur_weight_multi : wpaint_blur_weight_single;
-
vc = &wpd->vc;
ob = vc->obact;
- me = ob->data;
- indexar = wpd->indexar;
-
+
view3d_operator_needs_opengl(C);
ED_view3d_init_mats_rv3d(ob, vc->rv3d);
/* load projection matrix */
mul_m4_m4m4(mat, vc->rv3d->persmat, ob->obmat);
- RNA_float_get_array(itemptr, "mouse", mval);
/* *** setup WeightPaintInfo - pass onto do_weight_paint_vertex *** */
wpi.defbase_tot = wpd->defbase_tot;
@@ -2225,182 +2064,53 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
wpi.brush_alpha_value = brush_alpha_value;
/* *** done setting up WeightPaintInfo *** */
+ wpaint_do_symmetrical_brush_actions(C, ob, wp, sd, wpd, &wpi);
+ swap_m4m4(vc->rv3d->persmat, mat);
- swap_m4m4(wpd->vc.rv3d->persmat, mat);
-
- use_vert_sel = (me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0;
- use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
- use_depth = (vc->v3d->flag & V3D_ZBUF_SELECT) != 0;
-
- /* which faces are involved */
- if (use_depth) {
- char editflag_prev = me->editflag;
-
- /* Ugly hack, to avoid drawing vertex index when getting the face index buffer - campbell */
- me->editflag &= ~ME_EDIT_PAINT_VERT_SEL;
- if (use_vert_sel) {
- /* Ugly x2, we need this so hidden faces don't draw */
- me->editflag |= ME_EDIT_PAINT_FACE_SEL;
- }
- totindex = sample_backbuf_area(vc, indexar, me->totpoly, mval[0], mval[1], brush_size_pressure);
- me->editflag = editflag_prev;
-
- if (use_face_sel && me->totpoly) {
- MPoly *mpoly = me->mpoly;
- for (index = 0; index < totindex; index++) {
- if (indexar[index] && indexar[index] <= me->totpoly) {
- MPoly *mp = &mpoly[indexar[index] - 1];
-
- if ((mp->flag & ME_FACE_SEL) == 0) {
- indexar[index] = 0;
- }
- }
- }
- }
- }
- else {
- indexar = NULL;
+ if (wp->paint.brush->vertexpaint_tool == PAINT_BLEND_SMEAR) {
+ SWAP(float *, wpd->smear.weight_curr, wpd->smear.weight_prev);
}
- /* incase we have modifiers */
- ED_vpaint_proj_handle_update(wpd->vp_handle, vc->ar, mval);
-
- /* make sure each vertex gets treated only once */
- /* and calculate filter weight */
- paintweight = BKE_brush_weight_get(scene, brush);
+ /* calculate pivot for rotation around seletion if needed */
+ /* also needed for "View Selected" on last stroke */
+ paint_last_stroke_update(scene, vc->ar, mval);
- if (use_depth) {
- for (index = 0; index < totindex; index++) {
- if (indexar[index] && indexar[index] <= me->totpoly) {
- MPoly *mpoly = me->mpoly + (indexar[index] - 1);
- MLoop *ml = me->mloop + mpoly->loopstart;
- int i;
+ BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_ALL);
- if (use_vert_sel) {
- for (i = 0; i < mpoly->totloop; i++, ml++) {
- me->dvert[ml->v].flag = (me->mvert[ml->v].flag & SELECT);
- }
- }
- else {
- for (i = 0; i < mpoly->totloop; i++, ml++) {
- me->dvert[ml->v].flag = 1;
- }
- }
- }
- }
- }
- else {
- const unsigned int totvert = me->totvert;
- unsigned int i;
+ DEG_id_tag_update(ob->data, 0);
+ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
+ swap_m4m4(wpd->vc.rv3d->persmat, mat);
- /* in the case of face selection we need to flush */
- if (use_vert_sel || use_face_sel) {
- for (i = 0; i < totvert; i++) {
- me->dvert[i].flag = me->mvert[i].flag & SELECT;
- }
+ rcti r;
+ if (sculpt_get_redraw_rect(vc->ar, CTX_wm_region_view3d(C), ob, &r)) {
+ if (ss->cache) {
+ ss->cache->current_r = r;
}
- else {
- for (i = 0; i < totvert; i++) {
- me->dvert[i].flag = SELECT;
- }
- }
- }
- /* accumulate means we refer to the previous,
- * which is either the last update, or when we started painting */
- BLI_Stack *accumulate_stack = wpd->accumulate_stack;
- const bool use_accumulate = (accumulate_stack != NULL);
- BLI_assert(accumulate_stack == NULL || BLI_stack_is_empty(accumulate_stack));
-
- const MDeformVert *dvert_prev = use_accumulate ? me->dvert : wp->wpaint_prev;
-
-#define WP_PAINT(v_idx_var) \
- { \
- unsigned int vidx = v_idx_var; \
- if (me->dvert[vidx].flag) { \
- const float alpha = calc_vp_alpha_col_dl( \
- wp, vc, wpd->wpimat, &wpd->vertexcosnos[vidx], \
- mval, brush_size_pressure, brush_alpha_pressure, NULL); \
- if (alpha) { \
- if (use_blur) { \
- paintweight = wpaint_blur_weight_calc_from_connected( \
- dvert_prev, &wpi, wpd, vidx, blur_weight_func); \
- } \
- if (use_accumulate) { \
- struct WPaintDefer *dweight = BLI_stack_push_r(accumulate_stack); \
- dweight->index = vidx; \
- dweight->alpha = alpha; \
- dweight->weight = paintweight; \
- } \
- else { \
- do_weight_paint_vertex(wp, ob, &wpi, vidx, alpha, paintweight); \
- } \
- } \
- me->dvert[vidx].flag = 0; \
- } \
- } (void)0
-
- if (use_depth) {
- for (index = 0; index < totindex; index++) {
-
- if (indexar[index] && indexar[index] <= me->totpoly) {
- MPoly *mpoly = me->mpoly + (indexar[index] - 1);
- MLoop *ml = me->mloop + mpoly->loopstart;
- int i;
-
- for (i = 0; i < mpoly->totloop; i++, ml++) {
- WP_PAINT(ml->v);
- }
- }
+ /* previous is not set in the current cache else
+ * the partial rect will always grow */
+ if (ss->cache) {
+ if (!BLI_rcti_is_empty(&ss->cache->previous_r))
+ BLI_rcti_union(&r, &ss->cache->previous_r);
}
- }
- else {
- const unsigned int totvert = me->totvert;
- unsigned int i;
- for (i = 0; i < totvert; i++) {
- WP_PAINT(i);
- }
- }
-#undef WP_PAINT
+ r.xmin += vc->ar->winrct.xmin - 2;
+ r.xmax += vc->ar->winrct.xmin + 2;
+ r.ymin += vc->ar->winrct.ymin - 2;
+ r.ymax += vc->ar->winrct.ymin + 2;
- if (use_accumulate) {
- unsigned int defer_count = BLI_stack_count(accumulate_stack);
- while (defer_count--) {
- struct WPaintDefer *dweight = BLI_stack_peek(accumulate_stack);
- do_weight_paint_vertex(wp, ob, &wpi, dweight->index, dweight->alpha, dweight->weight);
- BLI_stack_discard(accumulate_stack);
- }
+ ss->partial_redraw = 1;
}
-
-
- /* *** free wpi members */
- /* *** done freeing wpi members */
-
-
- swap_m4m4(vc->rv3d->persmat, mat);
-
- /* calculate pivot for rotation around seletion if needed */
- /* also needed for "View Selected" on last stroke */
- paint_last_stroke_update(scene, vc->ar, mval);
-
- BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_PAINT);
-
- DEG_id_tag_update(ob->data, 0);
- ED_region_tag_redraw(vc->ar);
+ ED_region_tag_redraw_partial(vc->ar, &r);
}
static void wpaint_stroke_done(const bContext *C, struct PaintStroke *stroke)
{
- ToolSettings *ts = CTX_data_tool_settings(C);
Object *ob = CTX_data_active_object(C);
struct WPaintData *wpd = paint_stroke_mode_data(stroke);
-
+
if (wpd) {
- ED_vpaint_proj_handle_free(wpd->vp_handle);
- MEM_freeN(wpd->indexar);
-
if (wpd->defbase_sel)
MEM_freeN((void *)wpd->defbase_sel);
if (wpd->vgroup_validmap)
@@ -2411,29 +2121,19 @@ static void wpaint_stroke_done(const bContext *C, struct PaintStroke *stroke)
MEM_freeN((void *)wpd->active.lock);
if (wpd->mirror.lock)
MEM_freeN((void *)wpd->mirror.lock);
-
- if (wpd->blur_data.vmap) {
- MEM_freeN(wpd->blur_data.vmap);
- }
- if (wpd->blur_data.vmap_mem) {
- MEM_freeN(wpd->blur_data.vmap_mem);
- }
-
- if (wpd->accumulate_stack) {
- BLI_stack_free(wpd->accumulate_stack);
- }
+ if (wpd->smear.weight_prev)
+ MEM_freeN(wpd->smear.weight_prev);
+ if (wpd->smear.weight_curr)
+ MEM_freeN(wpd->smear.weight_curr);
MEM_freeN(wpd);
}
-
- /* frees prev buffer */
- copy_wpaint_prev(ts->wpaint, NULL, 0);
-
+
/* and particles too */
if (ob->particlesystem.first) {
ParticleSystem *psys;
int i;
-
+
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
for (i = 0; i < PSYS_TOT_VG; i++) {
if (psys->vgroup[i] == ob->actdef) {
@@ -2447,6 +2147,9 @@ static void wpaint_stroke_done(const bContext *C, struct PaintStroke *stroke)
DEG_id_tag_update(ob->data, 0);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
+
+ sculpt_cache_free(ob->sculpt->cache);
+ ob->sculpt->cache = NULL;
}
@@ -2454,10 +2157,11 @@ static int wpaint_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
int retval;
- op->customdata = paint_stroke_new(C, op, NULL, wpaint_stroke_test_start,
- wpaint_stroke_update_step, NULL,
- wpaint_stroke_done, event->type);
-
+ op->customdata = paint_stroke_new(
+ C, op, sculpt_stroke_get_location, wpaint_stroke_test_start,
+ wpaint_stroke_update_step, NULL,
+ wpaint_stroke_done, event->type);
+
if ((retval = op->type->modal(C, op, event)) == OPERATOR_FINISHED) {
paint_stroke_data_free(op);
return OPERATOR_FINISHED;
@@ -2467,15 +2171,16 @@ static int wpaint_invoke(bContext *C, wmOperator *op, const wmEvent *event)
OPERATOR_RETVAL_CHECK(retval);
BLI_assert(retval == OPERATOR_RUNNING_MODAL);
-
+
return OPERATOR_RUNNING_MODAL;
}
static int wpaint_exec(bContext *C, wmOperator *op)
{
- op->customdata = paint_stroke_new(C, op, NULL, wpaint_stroke_test_start,
- wpaint_stroke_update_step, NULL,
- wpaint_stroke_done, 0);
+ op->customdata = paint_stroke_new(
+ C, op, sculpt_stroke_get_location, wpaint_stroke_test_start,
+ wpaint_stroke_update_step, NULL,
+ wpaint_stroke_done, 0);
/* frees op->customdata */
paint_stroke_exec(C, op);
@@ -2485,64 +2190,33 @@ static int wpaint_exec(bContext *C, wmOperator *op)
static void wpaint_cancel(bContext *C, wmOperator *op)
{
+ Object *ob = CTX_data_active_object(C);
+ if (ob->sculpt->cache) {
+ sculpt_cache_free(ob->sculpt->cache);
+ ob->sculpt->cache = NULL;
+ }
+
paint_stroke_cancel(C, op);
}
void PAINT_OT_weight_paint(wmOperatorType *ot)
{
-
/* identifiers */
ot->name = "Weight Paint";
ot->idname = "PAINT_OT_weight_paint";
ot->description = "Paint a stroke in the current vertex group's weights";
-
+
/* api callbacks */
ot->invoke = wpaint_invoke;
ot->modal = paint_stroke_modal;
ot->exec = wpaint_exec;
ot->poll = weight_paint_poll;
ot->cancel = wpaint_cancel;
-
+
/* flags */
ot->flag = OPTYPE_UNDO | OPTYPE_BLOCKING;
-
- paint_stroke_operator_properties(ot);
-}
-
-static int weight_paint_set_exec(bContext *C, wmOperator *op)
-{
- struct Scene *scene = CTX_data_scene(C);
- Object *obact = CTX_data_active_object(C);
- ToolSettings *ts = CTX_data_tool_settings(C);
- Brush *brush = BKE_paint_brush(&ts->wpaint->paint);
- float vgroup_weight = BKE_brush_weight_get(scene, brush);
-
- if (wpaint_ensure_data(C, op, WPAINT_ENSURE_MIRROR, NULL) == false) {
- return OPERATOR_CANCELLED;
- }
-
- if (ED_wpaint_fill(scene->toolsettings->wpaint, obact, vgroup_weight)) {
- ED_region_tag_redraw(CTX_wm_region(C)); /* XXX - should redraw all 3D views */
- return OPERATOR_FINISHED;
- }
- else {
- return OPERATOR_CANCELLED;
- }
-}
-void PAINT_OT_weight_set(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Set Weight";
- ot->idname = "PAINT_OT_weight_set";
- ot->description = "Fill the active vertex group with the current paint weight";
-
- /* api callbacks */
- ot->exec = weight_paint_set_exec;
- ot->poll = mask_paint_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ paint_stroke_operator_properties(ot);
}
/* ************ set / clear vertex paint mode ********** */
@@ -2551,7 +2225,7 @@ void PAINT_OT_weight_set(wmOperatorType *ot)
* \note Keep in sync with #wpaint_mode_toggle_exec
*/
static int vpaint_mode_toggle_exec(bContext *C, wmOperator *op)
-{
+{
Object *ob = CTX_data_active_object(C);
const int mode_flag = OB_MODE_VERTEX_PAINT;
const bool is_mode_set = (ob->mode & mode_flag) != 0;
@@ -2566,7 +2240,7 @@ static int vpaint_mode_toggle_exec(bContext *C, wmOperator *op)
}
me = BKE_mesh_from_object(ob);
-
+
/* toggle: end vpaint */
if (is_mode_set) {
ob->mode &= ~mode_flag;
@@ -2574,46 +2248,68 @@ static int vpaint_mode_toggle_exec(bContext *C, wmOperator *op)
if (me->editflag & ME_EDIT_PAINT_FACE_SEL) {
BKE_mesh_flush_select_from_polys(me);
}
+ else if (me->editflag & ME_EDIT_PAINT_VERT_SEL) {
+ BKE_mesh_flush_select_from_verts(me);
+ }
+
+ /* If the cache is not released by a cancel or a done, free it now. */
+ if (ob->sculpt->cache) {
+ sculpt_cache_free(ob->sculpt->cache);
+ ob->sculpt->cache = NULL;
+ }
+
+ BKE_sculptsession_free(ob);
paint_cursor_delete_textures();
}
else {
+ EvaluationContext eval_ctx;
+
+ CTX_data_eval_ctx(C, &eval_ctx);
+
ob->mode |= mode_flag;
- if (me->mloopcol == NULL) {
- make_vertexcol(ob);
- }
+ ED_mesh_color_ensure(me, NULL);
if (vp == NULL)
- vp = scene->toolsettings->vpaint = new_vpaint(0);
-
+ vp = scene->toolsettings->vpaint = new_vpaint();
+
paint_cursor_start(C, vertex_paint_poll);
BKE_paint_init(scene, ePaintVertex, PAINT_CURSOR_VERTEX_PAINT);
+
+ /* Create vertex/weight paint mode session data */
+ if (ob->sculpt) {
+ if (ob->sculpt->cache) {
+ sculpt_cache_free(ob->sculpt->cache);
+ ob->sculpt->cache = NULL;
+ }
+ BKE_sculptsession_free(ob);
+ }
+ vertex_paint_init_session(&eval_ctx, scene, ob);
}
-
- BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_PAINT);
+
+ BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_ALL);
/* update modifier stack for mapping requirements */
DEG_id_tag_update(&me->id, 0);
-
+
WM_event_add_notifier(C, NC_SCENE | ND_MODE, scene);
-
+
return OPERATOR_FINISHED;
}
void PAINT_OT_vertex_paint_toggle(wmOperatorType *ot)
{
-
/* identifiers */
ot->name = "Vertex Paint Mode";
ot->idname = "PAINT_OT_vertex_paint_toggle";
ot->description = "Toggle the vertex paint mode in 3D view";
-
+
/* api callbacks */
ot->exec = vpaint_mode_toggle_exec;
ot->poll = paint_poll_test;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -2628,7 +2324,7 @@ void PAINT_OT_vertex_paint_toggle(wmOperatorType *ot)
* - validate context (add mcol)
* - create customdata storage
* - call paint once (mouse click)
- * - add modal handler
+ * - add modal handler
*
* Operator->modal()
* - for every mousemove, apply vertex paint
@@ -2645,13 +2341,14 @@ typedef struct PolyFaceMap {
int facenr;
} PolyFaceMap;
-typedef struct VPaintData {
+struct VPaintData {
ViewContext vc;
- unsigned int paintcol;
- int *indexar;
+ struct NormalAnglePrecalc normal_angle_precalc;
+
+ uint paintcol;
struct VertProjHandle *vp_handle;
- DMCoNo *vertexcosnos;
+ struct DMCoNo *vertexcosnos;
float vpimat[3][3];
@@ -2664,9 +2361,15 @@ typedef struct VPaintData {
bool *mlooptag;
bool is_texbrush;
-} VPaintData;
-static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const float UNUSED(mouse[2]))
+ /* Special storage for smear brush, avoid feedback loop - update each step and swap. */
+ struct {
+ uint *color_prev;
+ uint *color_curr;
+ } smear;
+};
+
+static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const float mouse[2])
{
Scene *scene = CTX_data_scene(C);
ToolSettings *ts = scene->toolsettings;
@@ -2677,25 +2380,27 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f
Object *ob = CTX_data_active_object(C);
Mesh *me;
float mat[4][4], imat[4][4];
+ SculptSession *ss = ob->sculpt;
+ EvaluationContext eval_ctx;
+
+ CTX_data_eval_ctx(C, &eval_ctx);
/* context checks could be a poll() */
me = BKE_mesh_from_object(ob);
if (me == NULL || me->totpoly == 0)
return false;
-
- if (me->mloopcol == NULL)
- make_vertexcol(ob);
+
+ ED_mesh_color_ensure(me, NULL);
if (me->mloopcol == NULL)
return false;
/* make mode data storage */
- vpd = MEM_callocN(sizeof(struct VPaintData), "VPaintData");
+ vpd = MEM_callocN(sizeof(*vpd), "VPaintData");
paint_stroke_set_mode_data(stroke, vpd);
view3d_set_viewcontext(C, &vpd->vc);
-
- vpd->vp_handle = ED_vpaint_proj_handle_create(vpd->vc.scene, ob, &vpd->vertexcosnos);
+ view_angle_limits_init(&vpd->normal_angle_precalc, vp->paint.brush->falloff_angle,
+ (vp->paint.brush->flag & BRUSH_FRONTFACE_FALLOFF) != 0);
- vpd->indexar = get_indexarray(me);
vpd->paintcol = vpaint_get_current_col(scene, vp);
vpd->is_texbrush = !(brush->vertexpaint_tool == PAINT_BLEND_BLUR) &&
@@ -2717,84 +2422,574 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f
vpd->mlooptag = MEM_mallocN(sizeof(bool) * me->totloop, "VPaintData mlooptag");
}
- /* for filtering */
- copy_vpaint_prev(vp, (unsigned int *)me->mloopcol, me->totloop);
-
+ if (brush->vertexpaint_tool == PAINT_BLEND_SMEAR) {
+ vpd->smear.color_prev = MEM_mallocN(sizeof(uint) * me->totloop, __func__);
+ memcpy(vpd->smear.color_prev, me->mloopcol, sizeof(uint) * me->totloop);
+ vpd->smear.color_curr = MEM_dupallocN(vpd->smear.color_prev);
+ }
+
+ /* Create projection handle */
+ if (vpd->is_texbrush) {
+ ob->sculpt->building_vp_handle = true;
+ vpd->vp_handle = ED_vpaint_proj_handle_create(&eval_ctx, scene, ob, &vpd->vertexcosnos);
+ ob->sculpt->building_vp_handle = false;
+ }
+
/* some old cruft to sort out later */
mul_m4_m4m4(mat, vpd->vc.rv3d->viewmat, ob->obmat);
invert_m4_m4(imat, mat);
copy_m3_m4(vpd->vpimat, imat);
+ /* If not previously created, create vertex/weight paint mode session data */
+ vertex_paint_init_session(&eval_ctx, scene, ob);
+ vwpaint_update_cache_invariants(C, vp, ss, op, mouse);
+ vertex_paint_init_session_data(ts, ob);
+
+ if (ob->sculpt->mode.vpaint.previous_color != NULL) {
+ memset(ob->sculpt->mode.vpaint.previous_color, 0, sizeof(uint) * me->totloop);
+ }
+
return 1;
}
-static void vpaint_paint_poly(VPaint *vp, VPaintData *vpd, Mesh *me,
- const unsigned int index, const float mval[2],
- const float brush_size_pressure, const float brush_alpha_pressure)
+static void do_vpaint_brush_calc_average_color_cb_ex(
+ void *userdata, void *UNUSED(userdata_chunk), const int n, const int UNUSED(thread_id))
{
- ViewContext *vc = &vpd->vc;
- Brush *brush = BKE_paint_brush(&vp->paint);
- MPoly *mpoly = &me->mpoly[index];
- MLoop *ml;
- unsigned int *lcol = ((unsigned int *)me->mloopcol) + mpoly->loopstart;
- unsigned int *lcolorig = ((unsigned int *)vp->vpaint_prev) + mpoly->loopstart;
- bool *mlooptag = (vpd->mlooptag) ? vpd->mlooptag + mpoly->loopstart : NULL;
- float alpha;
- int i, j;
- int totloop = mpoly->totloop;
+ SculptThreadedTaskData *data = userdata;
+ SculptSession *ss = data->ob->sculpt;
+ CCGDerivedMesh *ccgdm = BKE_pbvh_get_ccgdm(ss->pbvh);
+ const struct SculptVertexPaintGeomMap *gmap = &ss->mode.vpaint.gmap;
- int brush_alpha_pressure_i = (int)(brush_alpha_pressure * 255.0f);
+ StrokeCache *cache = ss->cache;
+ uint *lcol = data->lcol;
+ char *col;
+ const bool use_vert_sel = (data->me->editflag & (ME_EDIT_PAINT_FACE_SEL | ME_EDIT_PAINT_VERT_SEL)) != 0;
- if (brush->vertexpaint_tool == PAINT_BLEND_BLUR) {
- unsigned int blend[4] = {0};
- unsigned int tcol;
- char *col;
+ struct VPaintAverageAccum *accum = (struct VPaintAverageAccum *)data->custom_data + n;
+ accum->len = 0;
+ memset(accum->value, 0, sizeof(accum->value));
+
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn =
+ sculpt_brush_test_init_with_falloff_shape(ss, &test, data->brush->falloff_shape);
- for (j = 0; j < totloop; j++) {
- col = (char *)(lcol + j);
- blend[0] += col[0];
- blend[1] += col[1];
- blend[2] += col[2];
- blend[3] += col[3];
+ /* For each vertex */
+ PBVHVertexIter vd;
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
+ {
+ /* Test to see if the vertex coordinates are within the spherical brush region. */
+ if (sculpt_brush_test_sq_fn(&test, vd.co)) {
+ const int v_index = ccgdm ? data->me->mloop[vd.grid_indices[vd.g]].v : vd.vert_indices[vd.i];
+ if (BKE_brush_curve_strength(data->brush, 0.0, cache->radius) > 0.0) {
+ /* If the vertex is selected for painting. */
+ const MVert *mv = &data->me->mvert[v_index];
+ if (!use_vert_sel || mv->flag & SELECT) {
+ accum->len += gmap->vert_to_loop[v_index].count;
+ /* if a vertex is within the brush region, then add it's color to the blend. */
+ for (int j = 0; j < gmap->vert_to_loop[v_index].count; j++) {
+ const int l_index = gmap->vert_to_loop[v_index].indices[j];
+ col = (char *)(&lcol[l_index]);
+ /* Color is squared to compensate the sqrt color encoding. */
+ accum->value[0] += col[0] * col[0];
+ accum->value[1] += col[1] * col[1];
+ accum->value[2] += col[2] * col[2];
+ }
+ }
+ }
}
+ }
+ BKE_pbvh_vertex_iter_end;
+}
+
+static void handle_texture_brush(
+ SculptThreadedTaskData *data, PBVHVertexIter vd, float size_pressure, float alpha_pressure,
+ float *r_alpha, uint *r_color)
+{
+ SculptSession *ss = data->ob->sculpt;
+ CCGDerivedMesh *ccgdm = BKE_pbvh_get_ccgdm(ss->pbvh);
+ const int v_index = ccgdm ? data->me->mloop[vd.grid_indices[vd.g]].v : vd.vert_indices[vd.i];
+
+ float rgba[4];
+ float rgba_br[3];
+
+ *r_alpha = calc_vp_alpha_col_dl(
+ data->vp, &data->vpd->vc, data->vpd->vpimat,
+ &data->vpd->vertexcosnos[v_index], ss->cache->mouse, size_pressure, alpha_pressure, rgba);
+ rgb_uchar_to_float(rgba_br, (const uchar *)&data->vpd->paintcol);
+ mul_v3_v3(rgba_br, rgba);
+ rgb_float_to_uchar((uchar *)r_color, rgba_br);
+}
+
+static void do_vpaint_brush_draw_task_cb_ex(
+ void *userdata, void *UNUSED(userdata_chunk), const int n, const int UNUSED(thread_id))
+{
+ SculptThreadedTaskData *data = userdata;
+ SculptSession *ss = data->ob->sculpt;
+ CCGDerivedMesh *ccgdm = BKE_pbvh_get_ccgdm(ss->pbvh);
+ const struct SculptVertexPaintGeomMap *gmap = &ss->mode.vpaint.gmap;
+
+ const Brush *brush = data->brush;
+ const StrokeCache *cache = ss->cache;
+ uint *lcol = data->lcol;
+ const Scene *scene = CTX_data_scene(data->C);
+ float brush_size_pressure, brush_alpha_value, brush_alpha_pressure;
+ get_brush_alpha_data(scene, ss, brush, &brush_size_pressure, &brush_alpha_value, &brush_alpha_pressure);
+ const bool use_normal = vwpaint_use_normal(data->vp);
+ const bool use_vert_sel = (data->me->editflag & (ME_EDIT_PAINT_FACE_SEL | ME_EDIT_PAINT_VERT_SEL)) != 0;
+ const bool use_face_sel = (data->me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
- blend[0] = divide_round_i(blend[0], totloop);
- blend[1] = divide_round_i(blend[1], totloop);
- blend[2] = divide_round_i(blend[2], totloop);
- blend[3] = divide_round_i(blend[3], totloop);
- col = (char *)&tcol;
- col[0] = blend[0];
- col[1] = blend[1];
- col[2] = blend[2];
- col[3] = blend[3];
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn =
+ sculpt_brush_test_init_with_falloff_shape(ss, &test, data->brush->falloff_shape);
+ const float *sculpt_normal_frontface =
+ sculpt_brush_frontface_normal_from_falloff_shape(ss, data->brush->falloff_shape);
- vpd->paintcol = *((unsigned int *)col);
+ /* For each vertex */
+ PBVHVertexIter vd;
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
+ {
+ /* Test to see if the vertex coordinates are within the spherical brush region. */
+ if (sculpt_brush_test_sq_fn(&test, vd.co)) {
+ /* Note: Grids are 1:1 with corners (aka loops).
+ * For grid based pbvh, take the vert whose loop cooresponds to the current grid.
+ * Otherwise, take the current vert. */
+ const int v_index = ccgdm ? data->me->mloop[vd.grid_indices[vd.g]].v : vd.vert_indices[vd.i];
+ const float grid_alpha = ccgdm ? 1.0f / vd.gridsize : 1.0f;
+ const MVert *mv = &data->me->mvert[v_index];
+
+ /* If the vertex is selected for painting. */
+ if (!use_vert_sel || mv->flag & SELECT) {
+ /* Calc the dot prod. between ray norm on surf and current vert
+ * (ie splash prevention factor), and only paint front facing verts. */
+ float brush_strength = cache->bstrength;
+ const float angle_cos = (use_normal && vd.no) ?
+ dot_vf3vs3(sculpt_normal_frontface, vd.no) : 1.0f;
+ if (((brush->flag & BRUSH_FRONTFACE) == 0 ||
+ (angle_cos > 0.0f)) &&
+ ((brush->flag & BRUSH_FRONTFACE_FALLOFF) == 0 ||
+ view_angle_limits_apply_falloff(&data->vpd->normal_angle_precalc, angle_cos, &brush_strength)))
+ {
+ const float brush_fade = BKE_brush_curve_strength(brush, sqrtf(test.dist), cache->radius);
+ uint color_final = data->vpd->paintcol;
+
+ /* If we're painting with a texture, sample the texture color and alpha. */
+ float tex_alpha = 1.0;
+ if (data->vpd->is_texbrush) {
+ handle_texture_brush(
+ data, vd, brush_size_pressure, brush_alpha_pressure,
+ &tex_alpha, &color_final);
+ }
+ /* For each poly owning this vert, paint each loop belonging to this vert. */
+ for (int j = 0; j < gmap->vert_to_poly[v_index].count; j++) {
+ const int p_index = gmap->vert_to_poly[v_index].indices[j];
+ const int l_index = gmap->vert_to_loop[v_index].indices[j];
+ BLI_assert(data->me->mloop[l_index].v == v_index);
+ const MPoly *mp = &data->me->mpoly[p_index];
+ if (!use_face_sel || mp->flag & ME_FACE_SEL) {
+ uint color_orig = 0; /* unused when array is NULL */
+ if (ss->mode.vpaint.previous_color != NULL) {
+ /* Get the previous loop color */
+ if (ss->mode.vpaint.previous_color[l_index] == 0) {
+ ss->mode.vpaint.previous_color[l_index] = lcol[l_index];
+ }
+ color_orig = ss->mode.vpaint.previous_color[l_index];
+ }
+ const float final_alpha =
+ 255 * brush_fade * brush_strength *
+ tex_alpha * brush_alpha_pressure * grid_alpha;
+
+ /* Mix the new color with the original based on final_alpha. */
+ lcol[l_index] = vpaint_blend(
+ data->vp, lcol[l_index], color_orig, color_final,
+ final_alpha, 255 * brush_strength);
+ }
+ }
+ }
+ }
+ }
}
+ BKE_pbvh_vertex_iter_end;
+}
- ml = me->mloop + mpoly->loopstart;
- for (i = 0; i < totloop; i++, ml++) {
- float rgba[4];
- unsigned int paintcol;
- alpha = calc_vp_alpha_col_dl(vp, vc, vpd->vpimat,
- &vpd->vertexcosnos[ml->v], mval,
- brush_size_pressure, brush_alpha_pressure, rgba);
+static void do_vpaint_brush_blur_task_cb_ex(
+ void *userdata, void *UNUSED(userdata_chunk), const int n, const int UNUSED(thread_id))
+{
+ SculptThreadedTaskData *data = userdata;
+ SculptSession *ss = data->ob->sculpt;
+ CCGDerivedMesh *ccgdm = BKE_pbvh_get_ccgdm(ss->pbvh);
+
+ Scene *scene = CTX_data_scene(data->C);
+ const struct SculptVertexPaintGeomMap *gmap = &ss->mode.vpaint.gmap;
+ const Brush *brush = data->brush;
+ const StrokeCache *cache = ss->cache;
+ uint *lcol = data->lcol;
+ float brush_size_pressure, brush_alpha_value, brush_alpha_pressure;
+ get_brush_alpha_data(scene, ss, brush, &brush_size_pressure, &brush_alpha_value, &brush_alpha_pressure);
+ const bool use_normal = vwpaint_use_normal(data->vp);
+ const bool use_vert_sel = (data->me->editflag & (ME_EDIT_PAINT_FACE_SEL | ME_EDIT_PAINT_VERT_SEL)) != 0;
+ const bool use_face_sel = (data->me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
- if (vpd->is_texbrush) {
- float rgba_br[3];
- rgb_uchar_to_float(rgba_br, (const unsigned char *)&vpd->paintcol);
- mul_v3_v3(rgba_br, rgba);
- rgb_float_to_uchar((unsigned char *)&paintcol, rgba_br);
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn =
+ sculpt_brush_test_init_with_falloff_shape(ss, &test, data->brush->falloff_shape);
+ const float *sculpt_normal_frontface =
+ sculpt_brush_frontface_normal_from_falloff_shape(ss, data->brush->falloff_shape);
+
+ /* For each vertex */
+ PBVHVertexIter vd;
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
+ {
+ /* Test to see if the vertex coordinates are within the spherical brush region. */
+ if (sculpt_brush_test_sq_fn(&test, vd.co)) {
+ /* For grid based pbvh, take the vert whose loop cooresponds to the current grid.
+ * Otherwise, take the current vert. */
+ const int v_index = ccgdm ? data->me->mloop[vd.grid_indices[vd.g]].v : vd.vert_indices[vd.i];
+ const float grid_alpha = ccgdm ? 1.0f / vd.gridsize : 1.0f;
+ const MVert *mv = &data->me->mvert[v_index];
+
+ /* If the vertex is selected for painting. */
+ if (!use_vert_sel || mv->flag & SELECT) {
+ float brush_strength = cache->bstrength;
+ const float angle_cos = (use_normal && vd.no) ?
+ dot_vf3vs3(sculpt_normal_frontface, vd.no) : 1.0f;
+ if (((brush->flag & BRUSH_FRONTFACE) == 0 ||
+ (angle_cos > 0.0f)) &&
+ ((brush->flag & BRUSH_FRONTFACE_FALLOFF) == 0 ||
+ view_angle_limits_apply_falloff(&data->vpd->normal_angle_precalc, angle_cos, &brush_strength)))
+ {
+ const float brush_fade = BKE_brush_curve_strength(brush, sqrtf(test.dist), cache->radius);
+
+ /* Get the average poly color */
+ uint color_final = 0;
+ int total_hit_loops = 0;
+ uint blend[4] = {0};
+ for (int j = 0; j < gmap->vert_to_poly[v_index].count; j++) {
+ int p_index = gmap->vert_to_poly[v_index].indices[j];
+ const MPoly *mp = &data->me->mpoly[p_index];
+ if (!use_face_sel || mp->flag & ME_FACE_SEL) {
+ total_hit_loops += mp->totloop;
+ for (int k = 0; k < mp->totloop; k++) {
+ const uint l_index = mp->loopstart + k;
+ const char *col = (const char *)(&lcol[l_index]);
+ /* Color is squared to compensate the sqrt color encoding. */
+ blend[0] += (uint)col[0] * (uint)col[0];
+ blend[1] += (uint)col[1] * (uint)col[1];
+ blend[2] += (uint)col[2] * (uint)col[2];
+ blend[3] += (uint)col[3] * (uint)col[3];
+ }
+ }
+ }
+ if (total_hit_loops != 0) {
+ /* Use rgb^2 color averaging. */
+ char *col = (char *)(&color_final);
+ col[0] = round_fl_to_uchar(sqrtf(divide_round_i(blend[0], total_hit_loops)));
+ col[1] = round_fl_to_uchar(sqrtf(divide_round_i(blend[1], total_hit_loops)));
+ col[2] = round_fl_to_uchar(sqrtf(divide_round_i(blend[2], total_hit_loops)));
+ col[3] = round_fl_to_uchar(sqrtf(divide_round_i(blend[3], total_hit_loops)));
+
+ /* For each poly owning this vert, paint each loop belonging to this vert. */
+ for (int j = 0; j < gmap->vert_to_poly[v_index].count; j++) {
+ const int p_index = gmap->vert_to_poly[v_index].indices[j];
+ const int l_index = gmap->vert_to_loop[v_index].indices[j];
+ BLI_assert(data->me->mloop[l_index].v == v_index);
+ const MPoly *mp = &data->me->mpoly[p_index];
+ if (!use_face_sel || mp->flag & ME_FACE_SEL) {
+ uint color_orig = 0; /* unused when array is NULL */
+ if (ss->mode.vpaint.previous_color != NULL) {
+ /* Get the previous loop color */
+ if (ss->mode.vpaint.previous_color[l_index] == 0) {
+ ss->mode.vpaint.previous_color[l_index] = lcol[l_index];
+ }
+ color_orig = ss->mode.vpaint.previous_color[l_index];
+ }
+ const float final_alpha =
+ 255 * brush_fade * brush_strength *
+ brush_alpha_pressure * grid_alpha;
+ /* Mix the new color with the original
+ * based on the brush strength and the curve. */
+ lcol[l_index] = vpaint_blend(
+ data->vp, lcol[l_index], color_orig, *((uint *)col),
+ final_alpha, 255 * brush_strength);
+ }
+ }
+ }
+ }
+ }
}
- else
- paintcol = vpd->paintcol;
+ }
+ BKE_pbvh_vertex_iter_end;
+}
+
+static void do_vpaint_brush_smear_task_cb_ex(
+ void *userdata, void *UNUSED(userdata_chunk), const int n, const int UNUSED(thread_id))
+{
+ SculptThreadedTaskData *data = userdata;
+ SculptSession *ss = data->ob->sculpt;
+ CCGDerivedMesh *ccgdm = BKE_pbvh_get_ccgdm(ss->pbvh);
+
+ Scene *scene = CTX_data_scene(data->C);
+ const struct SculptVertexPaintGeomMap *gmap = &ss->mode.vpaint.gmap;
+ const Brush *brush = data->brush;
+ const StrokeCache *cache = ss->cache;
+ uint *lcol = data->lcol;
+ float brush_size_pressure, brush_alpha_value, brush_alpha_pressure;
+ get_brush_alpha_data(scene, ss, brush, &brush_size_pressure, &brush_alpha_value, &brush_alpha_pressure);
+ float brush_dir[3];
+ const bool use_normal = vwpaint_use_normal(data->vp);
+ const bool use_vert_sel = (data->me->editflag & (ME_EDIT_PAINT_FACE_SEL | ME_EDIT_PAINT_VERT_SEL)) != 0;
+ const bool use_face_sel = (data->me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
+
+ sub_v3_v3v3(brush_dir, cache->location, cache->last_location);
+ project_plane_v3_v3v3(brush_dir, brush_dir, cache->view_normal);
+
+ if (cache->is_last_valid && (normalize_v3(brush_dir) != 0.0f)) {
+
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn =
+ sculpt_brush_test_init_with_falloff_shape(ss, &test, data->brush->falloff_shape);
+ const float *sculpt_normal_frontface =
+ sculpt_brush_frontface_normal_from_falloff_shape(ss, data->brush->falloff_shape);
+
+ /* For each vertex */
+ PBVHVertexIter vd;
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
+ {
+ /* Test to see if the vertex coordinates are within the spherical brush region. */
+ if (sculpt_brush_test_sq_fn(&test, vd.co)) {
+ /* For grid based pbvh, take the vert whose loop cooresponds to the current grid.
+ * Otherwise, take the current vert. */
+ const int v_index = ccgdm ? data->me->mloop[vd.grid_indices[vd.g]].v : vd.vert_indices[vd.i];
+ const float grid_alpha = ccgdm ? 1.0f / vd.gridsize : 1.0f;
+ const MVert *mv_curr = &data->me->mvert[v_index];
+
+ /* if the vertex is selected for painting. */
+ if (!use_vert_sel || mv_curr->flag & SELECT) {
+ /* Calc the dot prod. between ray norm on surf and current vert
+ * (ie splash prevention factor), and only paint front facing verts. */
+ float brush_strength = cache->bstrength;
+ const float angle_cos = (use_normal && vd.no) ?
+ dot_vf3vs3(sculpt_normal_frontface, vd.no) : 1.0f;
+ if (((brush->flag & BRUSH_FRONTFACE) == 0 ||
+ (angle_cos > 0.0f)) &&
+ ((brush->flag & BRUSH_FRONTFACE_FALLOFF) == 0 ||
+ view_angle_limits_apply_falloff(&data->vpd->normal_angle_precalc, angle_cos, &brush_strength)))
+ {
+ const float brush_fade = BKE_brush_curve_strength(brush, sqrtf(test.dist), cache->radius);
+
+ bool do_color = false;
+ /* Minimum dot product between brush direction and current
+ * to neighbor direction is 0.0, meaning orthogonal. */
+ float stroke_dot_max = 0.0f;
+
+ /* Get the color of the loop in the opposite direction of the brush movement */
+ uint color_final = 0;
+ for (int j = 0; j < gmap->vert_to_poly[v_index].count; j++) {
+ const int p_index = gmap->vert_to_poly[v_index].indices[j];
+ const int l_index = gmap->vert_to_loop[v_index].indices[j];
+ BLI_assert(data->me->mloop[l_index].v == v_index);
+ UNUSED_VARS_NDEBUG(l_index);
+ const MPoly *mp = &data->me->mpoly[p_index];
+ if (!use_face_sel || mp->flag & ME_FACE_SEL) {
+ const MLoop *ml_other = &data->me->mloop[mp->loopstart];
+ for (int k = 0; k < mp->totloop; k++, ml_other++) {
+ const uint v_other_index = ml_other->v;
+ if (v_other_index != v_index) {
+ const MVert *mv_other = &data->me->mvert[v_other_index];
+
+ /* Get the direction from the selected vert to the neighbor. */
+ float other_dir[3];
+ sub_v3_v3v3(other_dir, mv_curr->co, mv_other->co);
+ project_plane_v3_v3v3(other_dir, other_dir, cache->view_normal);
+
+ normalize_v3(other_dir);
+
+ const float stroke_dot = dot_v3v3(other_dir, brush_dir);
+
+ if (stroke_dot > stroke_dot_max) {
+ stroke_dot_max = stroke_dot;
+ color_final = data->vpd->smear.color_prev[mp->loopstart + k];
+ do_color = true;
+ }
+ }
+ }
+ }
+ }
+
+ if (do_color) {
+ const float final_alpha =
+ 255 * brush_fade * brush_strength *
+ brush_alpha_pressure * grid_alpha;
+
+ /* For each poly owning this vert, paint each loop belonging to this vert. */
+ for (int j = 0; j < gmap->vert_to_poly[v_index].count; j++) {
+ const int p_index = gmap->vert_to_poly[v_index].indices[j];
+ const int l_index = gmap->vert_to_loop[v_index].indices[j];
+ BLI_assert(data->me->mloop[l_index].v == v_index);
+ const MPoly *mp = &data->me->mpoly[p_index];
+ if (!use_face_sel || mp->flag & ME_FACE_SEL) {
+ /* Get the previous loop color */
+ uint color_orig = 0; /* unused when array is NULL */
+ if (ss->mode.vpaint.previous_color != NULL) {
+ /* Get the previous loop color */
+ if (ss->mode.vpaint.previous_color[l_index] == 0) {
+ ss->mode.vpaint.previous_color[l_index] = lcol[l_index];
+ }
+ color_orig = ss->mode.vpaint.previous_color[l_index];
+ }
+ /* Mix the new color with the original
+ * based on the brush strength and the curve. */
+ lcol[l_index] = vpaint_blend(
+ data->vp, lcol[l_index], color_orig, color_final,
+ final_alpha, 255 * brush_strength);
+
+ data->vpd->smear.color_curr[l_index] = lcol[l_index];
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ BKE_pbvh_vertex_iter_end;
+ }
+}
+
+static void calculate_average_color(SculptThreadedTaskData *data, PBVHNode **UNUSED(nodes), int totnode)
+{
+ struct VPaintAverageAccum *accum = MEM_mallocN(sizeof(*accum) * totnode, __func__);
+ data->custom_data = accum;
+
+ BLI_task_parallel_range_ex(
+ 0, totnode, data, NULL, 0, do_vpaint_brush_calc_average_color_cb_ex,
+ true, false);
+
+ uint accum_len = 0;
+ uint accum_value[3] = {0};
+ uchar blend[4] = {0};
+ for (int i = 0; i < totnode; i++) {
+ accum_len += accum[i].len;
+ accum_value[0] += accum[i].value[0];
+ accum_value[1] += accum[i].value[1];
+ accum_value[2] += accum[i].value[2];
+ }
+ if (accum_len != 0) {
+ blend[0] = round_fl_to_uchar(sqrtf(divide_round_i(accum_value[0], accum_len)));
+ blend[1] = round_fl_to_uchar(sqrtf(divide_round_i(accum_value[1], accum_len)));
+ blend[2] = round_fl_to_uchar(sqrtf(divide_round_i(accum_value[2], accum_len)));
+ blend[3] = 255;
+ data->vpd->paintcol = *((uint *)blend);
+ }
- if (alpha > 0.0f) {
- const int alpha_i = (int)(alpha * 255.0f);
- lcol[i] = vpaint_blend(vp, lcol[i], lcolorig[i], paintcol, alpha_i, brush_alpha_pressure_i);
+ MEM_SAFE_FREE(data->custom_data); /* 'accum' */
+}
+
+static void vpaint_paint_leaves(
+ bContext *C, Sculpt *sd, VPaint *vp, struct VPaintData *vpd,
+ Object *ob, Mesh *me, PBVHNode **nodes, int totnode)
+{
+ const Brush *brush = ob->sculpt->cache->brush;
+
+ SculptThreadedTaskData data = {
+ .sd = sd, .ob = ob, .brush = brush, .nodes = nodes, .vp = vp, .vpd = vpd,
+ .lcol = (uint *)me->mloopcol, .me = me, .C = C,
+ };
+ switch (brush->vertexpaint_tool) {
+ case PAINT_BLEND_AVERAGE:
+ calculate_average_color(&data, nodes, totnode);
+ BLI_task_parallel_range_ex(
+ 0, totnode, &data, NULL, 0,
+ do_vpaint_brush_draw_task_cb_ex, true, false);
+ break;
+ case PAINT_BLEND_BLUR:
+ BLI_task_parallel_range_ex(
+ 0, totnode, &data, NULL, 0,
+ do_vpaint_brush_blur_task_cb_ex, true, false);
+ break;
+ case PAINT_BLEND_SMEAR:
+ BLI_task_parallel_range_ex(
+ 0, totnode, &data, NULL, 0,
+ do_vpaint_brush_smear_task_cb_ex, true, false);
+ break;
+ default:
+ BLI_task_parallel_range_ex(
+ 0, totnode, &data, NULL, 0,
+ do_vpaint_brush_draw_task_cb_ex, true, false);
+ break;
+ }
+}
+
+static void vpaint_do_paint(
+ bContext *C, Sculpt *sd, VPaint *vp, struct VPaintData *vpd,
+ Object *ob, Mesh *me, Brush *brush, const char symm, const int axis, const int i, const float angle)
+{
+ SculptSession *ss = ob->sculpt;
+ ss->cache->radial_symmetry_pass = i;
+ sculpt_cache_calc_brushdata_symm(ss->cache, symm, axis, angle);
+
+ int totnode;
+ PBVHNode **nodes = vwpaint_pbvh_gather_generic(ob, vp, sd, brush, &totnode);
+
+ /* Paint those leaves. */
+ vpaint_paint_leaves(C, sd, vp, vpd, ob, me, nodes, totnode);
+
+ if (nodes) {
+ MEM_freeN(nodes);
+ }
+}
- if (mlooptag) mlooptag[i] = 1;
+static void vpaint_do_radial_symmetry(
+ bContext *C, Sculpt *sd, VPaint *vp, struct VPaintData *vpd, Object *ob, Mesh *me,
+ Brush *brush, const char symm, const int axis)
+{
+ for (int i = 1; i < vp->radial_symm[axis - 'X']; i++) {
+ const float angle = (2.0 * M_PI) * i / vp->radial_symm[axis - 'X'];
+ vpaint_do_paint(C, sd, vp, vpd, ob, me, brush, symm, axis, i, angle);
+ }
+}
+
+/* near duplicate of: sculpt.c's, 'do_symmetrical_brush_actions' and 'wpaint_do_symmetrical_brush_actions'. */
+static void vpaint_do_symmetrical_brush_actions(
+ bContext *C, Sculpt *sd, VPaint *vp, struct VPaintData *vpd, Object *ob)
+{
+ Brush *brush = BKE_paint_brush(&vp->paint);
+ Mesh *me = ob->data;
+ SculptSession *ss = ob->sculpt;
+ StrokeCache *cache = ss->cache;
+ const char symm = vp->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
+ int i = 0;
+
+ /* initial stroke */
+ vpaint_do_paint(C, sd, vp, vpd, ob, me, brush, i, 'X', 0, 0);
+ vpaint_do_radial_symmetry(C, sd, vp, vpd, ob, me, brush, i, 'X');
+ vpaint_do_radial_symmetry(C, sd, vp, vpd, ob, me, brush, i, 'Y');
+ vpaint_do_radial_symmetry(C, sd, vp, vpd, ob, me, brush, i, 'Z');
+
+ cache->symmetry = symm;
+
+ /* symm is a bit combination of XYZ - 1 is mirror X; 2 is Y; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ */
+ for (i = 1; i <= symm; i++) {
+ if (symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5))) {
+ cache->mirror_symmetry_pass = i;
+ cache->radial_symmetry_pass = 0;
+ sculpt_cache_calc_brushdata_symm(cache, i, 0, 0);
+
+ if (i & (1 << 0)) {
+ vpaint_do_paint(C, sd, vp, vpd, ob, me, brush, i, 'X', 0, 0);
+ vpaint_do_radial_symmetry(C, sd, vp, vpd, ob, me, brush, i, 'X');
+ }
+ if (i & (1 << 1)) {
+ vpaint_do_paint(C, sd, vp, vpd, ob, me, brush, i, 'Y', 0, 0);
+ vpaint_do_radial_symmetry(C, sd, vp, vpd, ob, me, brush, i, 'Y');
+ }
+ if (i & (1 << 2)) {
+ vpaint_do_paint(C, sd, vp, vpd, ob, me, brush, i, 'Z', 0, 0);
+ vpaint_do_radial_symmetry(C, sd, vp, vpd, ob, me, brush, i, 'Z');
+ }
}
}
+
+ copy_v3_v3(cache->true_last_location, cache->true_location);
+ cache->is_last_valid = true;
}
static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerRNA *itemptr)
@@ -2803,71 +2998,36 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
ToolSettings *ts = CTX_data_tool_settings(C);
struct VPaintData *vpd = paint_stroke_mode_data(stroke);
VPaint *vp = ts->vpaint;
- Brush *brush = BKE_paint_brush(&vp->paint);
ViewContext *vc = &vpd->vc;
Object *ob = vc->obact;
- Mesh *me = ob->data;
- float mat[4][4];
- int *indexar = vpd->indexar;
- int totindex, index;
- float mval[2];
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
- const float pressure = RNA_float_get(itemptr, "pressure");
- const float brush_size_pressure =
- BKE_brush_size_get(scene, brush) * (BKE_brush_use_size_pressure(scene, brush) ? pressure : 1.0f);
- const float brush_alpha_pressure =
- BKE_brush_alpha_get(scene, brush) * (BKE_brush_use_alpha_pressure(scene, brush) ? pressure : 1.0f);
+ vwpaint_update_cache_variants(C, vp, ob, itemptr);
- RNA_float_get_array(itemptr, "mouse", mval);
+ float mat[4][4];
+ float mval[2];
- view3d_operator_needs_opengl(C);
ED_view3d_init_mats_rv3d(ob, vc->rv3d);
/* load projection matrix */
mul_m4_m4m4(mat, vc->rv3d->persmat, ob->obmat);
- /* which faces are involved */
- totindex = sample_backbuf_area(vc, indexar, me->totpoly, mval[0], mval[1], brush_size_pressure);
-
- if ((me->editflag & ME_EDIT_PAINT_FACE_SEL) && me->mpoly) {
- for (index = 0; index < totindex; index++) {
- if (indexar[index] && indexar[index] <= me->totpoly) {
- const MPoly *mpoly = &me->mpoly[indexar[index] - 1];
-
- if ((mpoly->flag & ME_FACE_SEL) == 0)
- indexar[index] = 0;
- }
- }
- }
-
swap_m4m4(vc->rv3d->persmat, mat);
- /* incase we have modifiers */
- ED_vpaint_proj_handle_update(vpd->vp_handle, vc->ar, mval);
-
- /* clear modified tag for blur tool */
- if (vpd->mlooptag)
- memset(vpd->mlooptag, 0, sizeof(bool) * me->totloop);
+ vpaint_do_symmetrical_brush_actions(C, sd, vp, vpd, ob);
- for (index = 0; index < totindex; index++) {
- if (indexar[index] && indexar[index] <= me->totpoly) {
- vpaint_paint_poly(vp, vpd, me, indexar[index] - 1, mval, brush_size_pressure, brush_alpha_pressure);
- }
- }
-
swap_m4m4(vc->rv3d->persmat, mat);
- /* was disabled because it is slow, but necessary for blur */
- if (brush->vertexpaint_tool == PAINT_BLEND_BLUR) {
- do_shared_vertexcol(me, vpd->mlooptag);
+ BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_ALL);
+
+ if (vp->paint.brush->vertexpaint_tool == PAINT_BLEND_SMEAR) {
+ SWAP(uint *, vpd->smear.color_curr, vpd->smear.color_prev);
}
/* calculate pivot for rotation around seletion if needed */
/* also needed for "View Selected" on last stroke */
paint_last_stroke_update(scene, vc->ar, mval);
- BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_PAINT);
-
ED_region_tag_redraw(vc->ar);
if (vpd->use_fast_update == false) {
@@ -2883,35 +3043,34 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
static void vpaint_stroke_done(const bContext *C, struct PaintStroke *stroke)
{
- ToolSettings *ts = CTX_data_tool_settings(C);
struct VPaintData *vpd = paint_stroke_mode_data(stroke);
ViewContext *vc = &vpd->vc;
Object *ob = vc->obact;
- Mesh *me = ob->data;
-
- ED_vpaint_proj_handle_free(vpd->vp_handle);
- MEM_freeN(vpd->indexar);
-
- /* frees prev buffer */
- copy_vpaint_prev(ts->vpaint, NULL, 0);
if (vpd->mlooptag)
MEM_freeN(vpd->mlooptag);
+ if (vpd->smear.color_prev)
+ MEM_freeN(vpd->smear.color_prev);
+ if (vpd->smear.color_curr)
+ MEM_freeN(vpd->smear.color_curr);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
- DEG_id_tag_update(&me->id, 0);
MEM_freeN(vpd);
+
+ sculpt_cache_free(ob->sculpt->cache);
+ ob->sculpt->cache = NULL;
}
static int vpaint_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
int retval;
- op->customdata = paint_stroke_new(C, op, NULL, vpaint_stroke_test_start,
- vpaint_stroke_update_step, NULL,
- vpaint_stroke_done, event->type);
-
+ op->customdata = paint_stroke_new(
+ C, op, sculpt_stroke_get_location, vpaint_stroke_test_start,
+ vpaint_stroke_update_step, NULL,
+ vpaint_stroke_done, event->type);
+
if ((retval = op->type->modal(C, op, event)) == OPERATOR_FINISHED) {
paint_stroke_data_free(op);
return OPERATOR_FINISHED;
@@ -2922,15 +3081,16 @@ static int vpaint_invoke(bContext *C, wmOperator *op, const wmEvent *event)
OPERATOR_RETVAL_CHECK(retval);
BLI_assert(retval == OPERATOR_RUNNING_MODAL);
-
+
return OPERATOR_RUNNING_MODAL;
}
static int vpaint_exec(bContext *C, wmOperator *op)
{
- op->customdata = paint_stroke_new(C, op, NULL, vpaint_stroke_test_start,
- vpaint_stroke_update_step, NULL,
- vpaint_stroke_done, 0);
+ op->customdata = paint_stroke_new(
+ C, op, sculpt_stroke_get_location, vpaint_stroke_test_start,
+ vpaint_stroke_update_step, NULL,
+ vpaint_stroke_done, 0);
/* frees op->customdata */
paint_stroke_exec(C, op);
@@ -2940,6 +3100,12 @@ static int vpaint_exec(bContext *C, wmOperator *op)
static void vpaint_cancel(bContext *C, wmOperator *op)
{
+ Object *ob = CTX_data_active_object(C);
+ if (ob->sculpt->cache) {
+ sculpt_cache_free(ob->sculpt->cache);
+ ob->sculpt->cache = NULL;
+ }
+
paint_stroke_cancel(C, op);
}
@@ -2949,382 +3115,17 @@ void PAINT_OT_vertex_paint(wmOperatorType *ot)
ot->name = "Vertex Paint";
ot->idname = "PAINT_OT_vertex_paint";
ot->description = "Paint a stroke in the active vertex color layer";
-
+
/* api callbacks */
ot->invoke = vpaint_invoke;
ot->modal = paint_stroke_modal;
ot->exec = vpaint_exec;
ot->poll = vertex_paint_poll;
ot->cancel = vpaint_cancel;
-
+
/* flags */
ot->flag = OPTYPE_UNDO | OPTYPE_BLOCKING;
paint_stroke_operator_properties(ot);
}
-/* ********************** weight from bones operator ******************* */
-
-static int weight_from_bones_poll(bContext *C)
-{
- Object *ob = CTX_data_active_object(C);
-
- return (ob && (ob->mode & OB_MODE_WEIGHT_PAINT) && modifiers_isDeformedByArmature(ob));
-}
-
-static int weight_from_bones_exec(bContext *C, wmOperator *op)
-{
- Scene *scene = CTX_data_scene(C);
- Object *ob = CTX_data_active_object(C);
- Object *armob = modifiers_isDeformedByArmature(ob);
- Mesh *me = ob->data;
- int type = RNA_enum_get(op->ptr, "type");
-
- create_vgroups_from_armature(op->reports, scene, ob, armob, type, (me->editflag & ME_EDIT_MIRROR_X));
-
- DEG_id_tag_update(&me->id, 0);
- WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
-
- return OPERATOR_FINISHED;
-}
-
-void PAINT_OT_weight_from_bones(wmOperatorType *ot)
-{
- static EnumPropertyItem type_items[] = {
- {ARM_GROUPS_AUTO, "AUTOMATIC", 0, "Automatic", "Automatic weights from bones"},
- {ARM_GROUPS_ENVELOPE, "ENVELOPES", 0, "From Envelopes", "Weights from envelopes with user defined radius"},
- {0, NULL, 0, NULL, NULL}};
-
- /* identifiers */
- ot->name = "Weight from Bones";
- ot->idname = "PAINT_OT_weight_from_bones";
- ot->description = "Set the weights of the groups matching the attached armature's selected bones, "
- "using the distance between the vertices and the bones";
-
- /* api callbacks */
- ot->exec = weight_from_bones_exec;
- ot->invoke = WM_menu_invoke;
- ot->poll = weight_from_bones_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* properties */
- ot->prop = RNA_def_enum(ot->srna, "type", type_items, 0, "Type", "Method to use for assigning weights");
-}
-
-/* *** VGroups Gradient *** */
-typedef struct DMGradient_vertStore {
- float sco[2];
- float weight_orig;
- enum {
- VGRAD_STORE_NOP = 0,
- VGRAD_STORE_DW_EXIST = (1 << 0)
- } flag;
-} DMGradient_vertStore;
-
-typedef struct DMGradient_userData {
- struct ARegion *ar;
- Scene *scene;
- Mesh *me;
- Brush *brush;
- const float *sco_start; /* [2] */
- const float *sco_end; /* [2] */
- float sco_line_div; /* store (1.0f / len_v2v2(sco_start, sco_end)) */
- int def_nr;
- bool is_init;
- DMGradient_vertStore *vert_cache;
- /* only for init */
- BLI_bitmap *vert_visit;
-
- /* options */
- short use_select;
- short type;
- float weightpaint;
-} DMGradient_userData;
-
-static void gradientVert_update(DMGradient_userData *grad_data, int index)
-{
- Mesh *me = grad_data->me;
- DMGradient_vertStore *vs = &grad_data->vert_cache[index];
- float alpha;
-
- if (grad_data->type == WPAINT_GRADIENT_TYPE_LINEAR) {
- alpha = line_point_factor_v2(vs->sco, grad_data->sco_start, grad_data->sco_end);
- }
- else {
- BLI_assert(grad_data->type == WPAINT_GRADIENT_TYPE_RADIAL);
- alpha = len_v2v2(grad_data->sco_start, vs->sco) * grad_data->sco_line_div;
- }
- /* no need to clamp 'alpha' yet */
-
- /* adjust weight */
- alpha = BKE_brush_curve_strength_clamped(grad_data->brush, alpha, 1.0f);
-
- if (alpha != 0.0f) {
- MDeformVert *dv = &me->dvert[index];
- MDeformWeight *dw = defvert_verify_index(dv, grad_data->def_nr);
- // dw->weight = alpha; // testing
- int tool = grad_data->brush->vertexpaint_tool;
- float testw;
-
- /* init if we just added */
- testw = wpaint_blend_tool(tool, vs->weight_orig, grad_data->weightpaint, alpha * grad_data->brush->alpha);
- CLAMP(testw, 0.0f, 1.0f);
- dw->weight = testw;
- }
- else {
- MDeformVert *dv = &me->dvert[index];
- if (vs->flag & VGRAD_STORE_DW_EXIST) {
- /* normally we NULL check, but in this case we know it exists */
- MDeformWeight *dw = defvert_find_index(dv, grad_data->def_nr);
- dw->weight = vs->weight_orig;
- }
- else {
- /* wasn't originally existing, remove */
- MDeformWeight *dw = defvert_find_index(dv, grad_data->def_nr);
- if (dw) {
- defvert_remove_group(dv, dw);
- }
- }
- }
-}
-
-static void gradientVertUpdate__mapFunc(
- void *userData, int index, const float UNUSED(co[3]),
- const float UNUSED(no_f[3]), const short UNUSED(no_s[3]))
-{
- DMGradient_userData *grad_data = userData;
- Mesh *me = grad_data->me;
- if ((grad_data->use_select == false) || (me->mvert[index].flag & SELECT)) {
- DMGradient_vertStore *vs = &grad_data->vert_cache[index];
- if (vs->sco[0] != FLT_MAX) {
- gradientVert_update(grad_data, index);
- }
- }
-}
-
-static void gradientVertInit__mapFunc(
- void *userData, int index, const float co[3],
- const float UNUSED(no_f[3]), const short UNUSED(no_s[3]))
-{
- DMGradient_userData *grad_data = userData;
- Mesh *me = grad_data->me;
-
- if ((grad_data->use_select == false) || (me->mvert[index].flag & SELECT)) {
- /* run first pass only,
- * the screen coords of the verts need to be cached because
- * updating the mesh may move them about (entering feedback loop) */
-
- if (BLI_BITMAP_TEST(grad_data->vert_visit, index) == 0) {
- DMGradient_vertStore *vs = &grad_data->vert_cache[index];
- if (ED_view3d_project_float_object(grad_data->ar,
- co, vs->sco,
- V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_NEAR) == V3D_PROJ_RET_OK)
- {
- /* ok */
- MDeformVert *dv = &me->dvert[index];
- MDeformWeight *dw;
- dw = defvert_find_index(dv, grad_data->def_nr);
- if (dw) {
- vs->weight_orig = dw->weight;
- vs->flag = VGRAD_STORE_DW_EXIST;
- }
- else {
- vs->weight_orig = 0.0f;
- vs->flag = VGRAD_STORE_NOP;
- }
-
- BLI_BITMAP_ENABLE(grad_data->vert_visit, index);
-
- gradientVert_update(grad_data, index);
- }
- else {
- /* no go */
- copy_v2_fl(vs->sco, FLT_MAX);
- }
- }
- }
-}
-
-static int paint_weight_gradient_modal(bContext *C, wmOperator *op, const wmEvent *event)
-{
- int ret = WM_gesture_straightline_modal(C, op, event);
-
- if (ret & OPERATOR_RUNNING_MODAL) {
- if (event->type == LEFTMOUSE && event->val == KM_RELEASE) { /* XXX, hardcoded */
- /* generally crap! redo! */
- WM_gesture_straightline_cancel(C, op);
- ret &= ~OPERATOR_RUNNING_MODAL;
- ret |= OPERATOR_FINISHED;
- }
- }
-
- if (ret & OPERATOR_CANCELLED) {
- ToolSettings *ts = CTX_data_tool_settings(C);
- VPaint *wp = ts->wpaint;
- Object *ob = CTX_data_active_object(C);
- Mesh *me = ob->data;
- if (wp->wpaint_prev) {
- BKE_defvert_array_free_elems(me->dvert, me->totvert);
- BKE_defvert_array_copy(me->dvert, wp->wpaint_prev, me->totvert);
- free_wpaint_prev(wp);
- }
-
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
- }
- else if (ret & OPERATOR_FINISHED) {
- ToolSettings *ts = CTX_data_tool_settings(C);
- VPaint *wp = ts->wpaint;
- free_wpaint_prev(wp);
- }
-
- return ret;
-}
-
-static int paint_weight_gradient_exec(bContext *C, wmOperator *op)
-{
- wmGesture *gesture = op->customdata;
- DMGradient_vertStore *vert_cache;
- struct ARegion *ar = CTX_wm_region(C);
- Scene *scene = CTX_data_scene(C);
- Object *ob = CTX_data_active_object(C);
- Mesh *me = ob->data;
- int x_start = RNA_int_get(op->ptr, "xstart");
- int y_start = RNA_int_get(op->ptr, "ystart");
- int x_end = RNA_int_get(op->ptr, "xend");
- int y_end = RNA_int_get(op->ptr, "yend");
- float sco_start[2] = {x_start, y_start};
- float sco_end[2] = {x_end, y_end};
- const bool is_interactive = (gesture != NULL);
- DerivedMesh *dm = mesh_get_derived_final(scene, ob, scene->customdata_mask);
-
- DMGradient_userData data = {NULL};
-
- if (is_interactive) {
- if (gesture->userdata == NULL) {
- VPaint *wp = scene->toolsettings->wpaint;
-
- gesture->userdata = MEM_mallocN(sizeof(DMGradient_vertStore) * me->totvert, __func__);
- data.is_init = true;
-
- copy_wpaint_prev(wp, me->dvert, me->totvert);
-
- /* on init only, convert face -> vert sel */
- if (me->editflag & ME_EDIT_PAINT_FACE_SEL) {
- BKE_mesh_flush_select_from_polys(me);
- }
- }
-
- vert_cache = gesture->userdata;
- }
- else {
- if (wpaint_ensure_data(C, op, 0, NULL) == false) {
- return OPERATOR_CANCELLED;
- }
-
- data.is_init = true;
- vert_cache = MEM_mallocN(sizeof(DMGradient_vertStore) * me->totvert, __func__);
- }
-
- data.ar = ar;
- data.scene = scene;
- data.me = ob->data;
- data.sco_start = sco_start;
- data.sco_end = sco_end;
- data.sco_line_div = 1.0f / len_v2v2(sco_start, sco_end);
- data.def_nr = ob->actdef - 1;
- data.use_select = (me->editflag & (ME_EDIT_PAINT_FACE_SEL | ME_EDIT_PAINT_VERT_SEL));
- data.vert_cache = vert_cache;
- data.vert_visit = NULL;
- data.type = RNA_enum_get(op->ptr, "type");
-
- {
- ToolSettings *ts = CTX_data_tool_settings(C);
- VPaint *wp = ts->wpaint;
- struct Brush *brush = BKE_paint_brush(&wp->paint);
-
- curvemapping_initialize(brush->curve);
-
- data.brush = brush;
- data.weightpaint = BKE_brush_weight_get(scene, brush);
- }
-
- ED_view3d_init_mats_rv3d(ob, ar->regiondata);
-
- if (data.is_init) {
- data.vert_visit = BLI_BITMAP_NEW(me->totvert, __func__);
-
- dm->foreachMappedVert(dm, gradientVertInit__mapFunc, &data, DM_FOREACH_NOP);
-
- MEM_freeN(data.vert_visit);
- data.vert_visit = NULL;
- }
- else {
- dm->foreachMappedVert(dm, gradientVertUpdate__mapFunc, &data, DM_FOREACH_NOP);
- }
-
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
-
- if (is_interactive == false) {
- MEM_freeN(vert_cache);
- }
-
- return OPERATOR_FINISHED;
-}
-
-static int paint_weight_gradient_invoke(bContext *C, wmOperator *op, const wmEvent *event)
-{
- int ret;
-
- if (wpaint_ensure_data(C, op, 0, NULL) == false) {
- return OPERATOR_CANCELLED;
- }
-
- ret = WM_gesture_straightline_invoke(C, op, event);
- if (ret & OPERATOR_RUNNING_MODAL) {
- struct ARegion *ar = CTX_wm_region(C);
- if (ar->regiontype == RGN_TYPE_WINDOW) {
- /* TODO, hardcoded, extend WM_gesture_straightline_ */
- if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
- wmGesture *gesture = op->customdata;
- gesture->mode = 1;
- }
- }
- }
- return ret;
-}
-
-void PAINT_OT_weight_gradient(wmOperatorType *ot)
-{
- /* defined in DNA_space_types.h */
- static EnumPropertyItem gradient_types[] = {
- {WPAINT_GRADIENT_TYPE_LINEAR, "LINEAR", 0, "Linear", ""},
- {WPAINT_GRADIENT_TYPE_RADIAL, "RADIAL", 0, "Radial", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- PropertyRNA *prop;
-
- /* identifiers */
- ot->name = "Weight Gradient";
- ot->idname = "PAINT_OT_weight_gradient";
- ot->description = "Draw a line to apply a weight gradient to selected vertices";
-
- /* api callbacks */
- ot->invoke = paint_weight_gradient_invoke;
- ot->modal = paint_weight_gradient_modal;
- ot->exec = paint_weight_gradient_exec;
- ot->poll = weight_paint_poll;
- ot->cancel = WM_gesture_straightline_cancel;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- prop = RNA_def_enum(ot->srna, "type", gradient_types, 0, "Type", "");
- RNA_def_property_flag(prop, PROP_SKIP_SAVE);
-
- WM_operator_properties_gesture_straightline(ot, CURSOR_EDIT);
-}
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c
new file mode 100644
index 00000000000..d7668a48139
--- /dev/null
+++ b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c
@@ -0,0 +1,575 @@
+/*
+ * ***** 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/sculpt_paint/paint_vertex_color_ops.c
+ * \ingroup edsculpt
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+
+#include "BLI_math_base.h"
+#include "BLI_math_color.h"
+
+#include "BKE_context.h"
+#include "BKE_mesh.h"
+#include "BKE_deform.h"
+
+#include "DEG_depsgraph.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "ED_mesh.h"
+
+#include "paint_intern.h" /* own include */
+
+
+static int vertex_weight_paint_mode_poll(bContext *C)
+{
+ Object *ob = CTX_data_active_object(C);
+ Mesh *me = BKE_mesh_from_object(ob);
+ return (ob && (ob->mode == OB_MODE_VERTEX_PAINT || ob->mode == OB_MODE_WEIGHT_PAINT)) &&
+ (me && me->totpoly && me->dvert);
+}
+
+/* -------------------------------------------------------------------- */
+/** \name Set Vertex Colors Operator
+ * \{ */
+
+static bool vertex_color_set(Object *ob, uint paintcol)
+{
+ Mesh *me;
+ const MPoly *mp;
+ int i, j;
+
+ if (((me = BKE_mesh_from_object(ob)) == NULL) ||
+ (ED_mesh_color_ensure(me, NULL) == false))
+ {
+ return false;
+ }
+
+ const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
+ const bool use_vert_sel = (me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0;
+
+ mp = me->mpoly;
+ for (i = 0; i < me->totpoly; i++, mp++) {
+ MLoopCol *lcol = me->mloopcol + mp->loopstart;
+
+ if (use_face_sel && !(mp->flag & ME_FACE_SEL))
+ continue;
+
+ j = 0;
+ do {
+ uint vidx = me->mloop[mp->loopstart + j].v;
+ if (!(use_vert_sel && !(me->mvert[vidx].flag & SELECT))) {
+ *(int *)lcol = paintcol;
+ }
+ lcol++;
+ j++;
+ } while (j < mp->totloop);
+
+ }
+
+ /* remove stale me->mcol, will be added later */
+ BKE_mesh_tessface_clear(me);
+
+ DEG_id_tag_update(&me->id, 0);
+
+ return true;
+}
+
+static int vertex_color_set_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Scene *scene = CTX_data_scene(C);
+ Object *obact = CTX_data_active_object(C);
+ unsigned int paintcol = vpaint_get_current_col(scene, scene->toolsettings->vpaint);
+
+ if (vertex_color_set(obact, paintcol)) {
+ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obact);
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
+}
+
+void PAINT_OT_vertex_color_set(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Set Vertex Colors";
+ ot->idname = "PAINT_OT_vertex_color_set";
+ ot->description = "Fill the active vertex color layer with the current paint color";
+
+ /* api callbacks */
+ ot->exec = vertex_color_set_exec;
+ ot->poll = vertex_paint_mode_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Vertex Color from Weight Operator
+ * \{ */
+
+static bool vertex_paint_from_weight(Object *ob)
+{
+ Mesh *me;
+ const MPoly *mp;
+ int vgroup_active;
+
+ if (((me = BKE_mesh_from_object(ob)) == NULL ||
+ (ED_mesh_color_ensure(me, NULL)) == false))
+ {
+ return false;
+ }
+
+ /* TODO: respect selection. */
+ mp = me->mpoly;
+ vgroup_active = ob->actdef - 1;
+ for (int i = 0; i < me->totpoly; i++, mp++) {
+ MLoopCol *lcol = &me->mloopcol[mp->loopstart];
+ uint j = 0;
+ do {
+ uint vidx = me->mloop[mp->loopstart + j].v;
+ const float weight = defvert_find_weight(&me->dvert[vidx], vgroup_active);
+ const uchar grayscale = weight * 255;
+ lcol->r = grayscale;
+ lcol->b = grayscale;
+ lcol->g = grayscale;
+ lcol++;
+ j++;
+ } while (j < mp->totloop);
+ }
+
+ DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+
+ return true;
+}
+
+static int vertex_paint_from_weight_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Object *obact = CTX_data_active_object(C);
+ if (vertex_paint_from_weight(obact)) {
+ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obact);
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
+}
+
+void PAINT_OT_vertex_color_from_weight(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Vertex Color from Weight";
+ ot->idname = "PAINT_OT_vertex_color_from_weight";
+ ot->description = "Convert active weight into gray scale vertex colors";
+
+ /* api callback */
+ ot->exec = vertex_paint_from_weight_exec;
+ ot->poll = vertex_weight_paint_mode_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* TODO: invert, alpha */
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Smooth Vertex Colors Operator
+ * \{ */
+
+static void vertex_color_smooth_looptag(Mesh *me, bool *mlooptag)
+{
+ const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
+ const MPoly *mp;
+ int (*scol)[4];
+ int i, j;
+ bool has_shared = false;
+
+ /* if no mloopcol: do not do */
+ /* if mtexpoly: only the involved faces, otherwise all */
+
+ if (me->mloopcol == NULL || me->totvert == 0 || me->totpoly == 0) return;
+
+ scol = MEM_callocN(sizeof(int) * me->totvert * 5, "scol");
+
+ for (i = 0, mp = me->mpoly; i < me->totpoly; i++, mp++) {
+ if ((use_face_sel == false) || (mp->flag & ME_FACE_SEL)) {
+ const MLoop *ml = me->mloop + mp->loopstart;
+ MLoopCol *lcol = me->mloopcol + mp->loopstart;
+ for (j = 0; j < mp->totloop; j++, ml++, lcol++) {
+ scol[ml->v][0] += lcol->r;
+ scol[ml->v][1] += lcol->g;
+ scol[ml->v][2] += lcol->b;
+ scol[ml->v][3] += 1;
+ has_shared = 1;
+ }
+ }
+ }
+
+ if (has_shared) {
+ for (i = 0; i < me->totvert; i++) {
+ if (scol[i][3] != 0) {
+ scol[i][0] = divide_round_i(scol[i][0], scol[i][3]);
+ scol[i][1] = divide_round_i(scol[i][1], scol[i][3]);
+ scol[i][2] = divide_round_i(scol[i][2], scol[i][3]);
+ }
+ }
+
+ for (i = 0, mp = me->mpoly; i < me->totpoly; i++, mp++) {
+ if ((use_face_sel == false) || (mp->flag & ME_FACE_SEL)) {
+ const MLoop *ml = me->mloop + mp->loopstart;
+ MLoopCol *lcol = me->mloopcol + mp->loopstart;
+ for (j = 0; j < mp->totloop; j++, ml++, lcol++) {
+ if (mlooptag[mp->loopstart + j]) {
+ lcol->r = scol[ml->v][0];
+ lcol->g = scol[ml->v][1];
+ lcol->b = scol[ml->v][2];
+ }
+ }
+ }
+ }
+ }
+
+ MEM_freeN(scol);
+}
+
+static bool vertex_color_smooth(Object *ob)
+{
+ Mesh *me;
+ const MPoly *mp;
+
+ int i, j;
+
+ bool *mlooptag;
+
+ if (((me = BKE_mesh_from_object(ob)) == NULL) ||
+ (ED_mesh_color_ensure(me, NULL) == false))
+ {
+ return false;
+ }
+
+ const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
+
+ mlooptag = MEM_callocN(sizeof(bool) * me->totloop, "VPaintData mlooptag");
+
+ /* simply tag loops of selected faces */
+ mp = me->mpoly;
+ for (i = 0; i < me->totpoly; i++, mp++) {
+ const MLoop *ml = me->mloop + mp->loopstart;
+ int ml_index = mp->loopstart;
+
+ if (use_face_sel && !(mp->flag & ME_FACE_SEL))
+ continue;
+
+ for (j = 0; j < mp->totloop; j++, ml_index++, ml++) {
+ mlooptag[ml_index] = true;
+ }
+ }
+
+ /* remove stale me->mcol, will be added later */
+ BKE_mesh_tessface_clear(me);
+
+ vertex_color_smooth_looptag(me, mlooptag);
+
+ MEM_freeN(mlooptag);
+
+ DEG_id_tag_update(&me->id, 0);
+
+ return true;
+}
+
+
+static int vertex_color_smooth_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Object *obact = CTX_data_active_object(C);
+ if (vertex_color_smooth(obact)) {
+ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obact);
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
+}
+
+void PAINT_OT_vertex_color_smooth(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Smooth Vertex Colors";
+ ot->idname = "PAINT_OT_vertex_color_smooth";
+ ot->description = "Smooth colors across vertices";
+
+ /* api callbacks */
+ ot->exec = vertex_color_smooth_exec;
+ ot->poll = vertex_paint_mode_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Vertex Color Transformation Operators
+ * \{ */
+
+struct VPaintTx_BrightContrastData {
+ /* pre-calculated */
+ float gain;
+ float offset;
+};
+
+static void vpaint_tx_brightness_contrast(const float col[3], const void *user_data, float r_col[3])
+{
+ const struct VPaintTx_BrightContrastData *data = user_data;
+
+ for (int i = 0; i < 3; i++) {
+ r_col[i] = data->gain * col[i] + data->offset;
+ }
+}
+
+static int vertex_color_brightness_contrast_exec(bContext *C, wmOperator *op)
+{
+ Object *obact = CTX_data_active_object(C);
+
+ float gain, offset;
+ {
+ float brightness = RNA_float_get(op->ptr, "brightness");
+ float contrast = RNA_float_get(op->ptr, "contrast");
+ brightness /= 100.0f;
+ float delta = contrast / 200.0f;
+ gain = 1.0f - delta * 2.0f;
+ /*
+ * The algorithm is by Werner D. Streidt
+ * (http://visca.com/ffactory/archives/5-99/msg00021.html)
+ * Extracted of OpenCV demhist.c
+ */
+ if (contrast > 0) {
+ gain = 1.0f / ((gain != 0.0f) ? gain : FLT_EPSILON);
+ offset = gain * (brightness - delta);
+ }
+ else {
+ delta *= -1;
+ offset = gain * (brightness + delta);
+ }
+ }
+
+ const struct VPaintTx_BrightContrastData user_data = {
+ .gain = gain,
+ .offset = offset,
+ };
+
+ if (ED_vpaint_color_transform(obact, vpaint_tx_brightness_contrast, &user_data)) {
+ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obact);
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
+}
+
+void PAINT_OT_vertex_color_brightness_contrast(wmOperatorType *ot)
+{
+ PropertyRNA *prop;
+
+ /* identifiers */
+ ot->name = "Vertex Paint Bright/Contrast";
+ ot->idname = "PAINT_OT_vertex_color_brightness_contrast";
+ ot->description = "Adjust vertex color brightness/contrast";
+
+ /* api callbacks */
+ ot->exec = vertex_color_brightness_contrast_exec;
+ ot->poll = vertex_paint_mode_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* params */
+ const float min = -100, max = +100;
+ prop = RNA_def_float(ot->srna, "brightness", 0.0f, min, max, "Brightness", "", min, max);
+ prop = RNA_def_float(ot->srna, "contrast", 0.0f, min, max, "Contrast", "", min, max);
+ RNA_def_property_ui_range(prop, min, max, 1, 1);
+}
+
+struct VPaintTx_HueSatData {
+ float hue;
+ float sat;
+ float val;
+};
+
+static void vpaint_tx_hsv(const float col[3], const void *user_data, float r_col[3])
+{
+ const struct VPaintTx_HueSatData *data = user_data;
+ float hsv[3];
+ rgb_to_hsv_v(col, hsv);
+
+ hsv[0] += (data->hue - 0.5f);
+ if (hsv[0] > 1.0f) {
+ hsv[0] -= 1.0f;
+ }
+ else if (hsv[0] < 0.0f) {
+ hsv[0] += 1.0f;
+ }
+ hsv[1] *= data->sat;
+ hsv[2] *= data->val;
+
+ hsv_to_rgb_v(hsv, r_col);
+}
+
+static int vertex_color_hsv_exec(bContext *C, wmOperator *op)
+{
+ Object *obact = CTX_data_active_object(C);
+
+ const struct VPaintTx_HueSatData user_data = {
+ .hue = RNA_float_get(op->ptr, "h"),
+ .sat = RNA_float_get(op->ptr, "s"),
+ .val = RNA_float_get(op->ptr, "v"),
+ };
+
+ if (ED_vpaint_color_transform(obact, vpaint_tx_hsv, &user_data)) {
+ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obact);
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
+}
+
+void PAINT_OT_vertex_color_hsv(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Vertex Paint Hue Saturation Value";
+ ot->idname = "PAINT_OT_vertex_color_hsv";
+ ot->description = "Adjust vertex color HSV values";
+
+ /* api callbacks */
+ ot->exec = vertex_color_hsv_exec;
+ ot->poll = vertex_paint_mode_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* params */
+ RNA_def_float(ot->srna, "h", 0.5f, 0.0f, 1.0f, "Hue", "", 0.0f, 1.0f);
+ RNA_def_float(ot->srna, "s", 1.0f, 0.0f, 2.0f, "Saturation", "", 0.0f, 2.0f);
+ RNA_def_float(ot->srna, "v", 1.0f, 0.0f, 2.0f, "Value", "", 0.0f, 2.0f);
+}
+
+static void vpaint_tx_invert(const float col[3], const void *UNUSED(user_data), float r_col[3])
+{
+ for (int i = 0; i < 3; i++) {
+ r_col[i] = 1.0f - col[i];
+ }
+}
+
+static int vertex_color_invert_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Object *obact = CTX_data_active_object(C);
+
+ if (ED_vpaint_color_transform(obact, vpaint_tx_invert, NULL)) {
+ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obact);
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
+}
+
+void PAINT_OT_vertex_color_invert(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Vertex Paint Invert";
+ ot->idname = "PAINT_OT_vertex_color_invert";
+ ot->description = "Invert RGB values";
+
+ /* api callbacks */
+ ot->exec = vertex_color_invert_exec;
+ ot->poll = vertex_paint_mode_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+
+struct VPaintTx_LevelsData {
+ float gain;
+ float offset;
+};
+
+static void vpaint_tx_levels(const float col[3], const void *user_data, float r_col[3])
+{
+ const struct VPaintTx_LevelsData *data = user_data;
+ for (int i = 0; i < 3; i++) {
+ r_col[i] = data->gain * (col[i] + data->offset);
+ }
+}
+
+static int vertex_color_levels_exec(bContext *C, wmOperator *op)
+{
+ Object *obact = CTX_data_active_object(C);
+
+ const struct VPaintTx_LevelsData user_data = {
+ .gain = RNA_float_get(op->ptr, "gain"),
+ .offset = RNA_float_get(op->ptr, "offset"),
+ };
+
+ if (ED_vpaint_color_transform(obact, vpaint_tx_levels, &user_data)) {
+ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obact);
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
+}
+
+void PAINT_OT_vertex_color_levels(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Vertex Paint Levels";
+ ot->idname = "PAINT_OT_vertex_color_levels";
+ ot->description = "Adjust levels of vertex colors";
+
+ /* api callbacks */
+ ot->exec = vertex_color_levels_exec;
+ ot->poll = vertex_paint_mode_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* params */
+ RNA_def_float(ot->srna, "offset", 0.0f, -1.0f, 1.0f, "Offset", "Value to add to colors", -1.0f, 1.0f);
+ RNA_def_float(ot->srna, "gain", 1.0f, 0.0f, FLT_MAX, "Gain", "Value to multiply colors by", 0.0f, 10.0f);
+}
+
+/** \} */
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_color_utils.c b/source/blender/editors/sculpt_paint/paint_vertex_color_utils.c
new file mode 100644
index 00000000000..a8045232e05
--- /dev/null
+++ b/source/blender/editors/sculpt_paint/paint_vertex_color_utils.c
@@ -0,0 +1,649 @@
+/*
+ * ***** 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/sculpt_paint/paint_vertex_color_utils.c
+ * \ingroup edsculpt
+ *
+ * Intended for use by `paint_vertex.c` & `paint_vertex_color_ops.c`.
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_brush_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+
+#include "BLI_math_base.h"
+#include "BLI_math_color.h"
+
+#include "IMB_colormanagement.h"
+
+#include "BKE_context.h"
+#include "BKE_mesh.h"
+
+#include "DEG_depsgraph.h"
+
+#include "ED_mesh.h"
+
+#include "paint_intern.h" /* own include */
+
+#define EPS_SATURATION 0.0005f
+
+/**
+ * Apply callback to each vertex of the active vertex color layer.
+ */
+bool ED_vpaint_color_transform(
+ struct Object *ob,
+ VPaintTransform_Callback vpaint_tx_fn,
+ const void *user_data)
+{
+ Mesh *me;
+ const MPoly *mp;
+
+ if (((me = BKE_mesh_from_object(ob)) == NULL) ||
+ (ED_mesh_color_ensure(me, NULL) == false))
+ {
+ return false;
+ }
+
+ const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
+ mp = me->mpoly;
+
+ for (int i = 0; i < me->totpoly; i++, mp++) {
+ MLoopCol *lcol = &me->mloopcol[mp->loopstart];
+
+ if (use_face_sel && !(mp->flag & ME_FACE_SEL)) {
+ continue;
+ }
+
+ for (int j = 0; j < mp->totloop; j++, lcol++) {
+ float col[3];
+ rgb_uchar_to_float(col, &lcol->r);
+
+ vpaint_tx_fn(col, user_data, col);
+
+ rgb_float_to_uchar(&lcol->r, col);
+ }
+ }
+
+ /* remove stale me->mcol, will be added later */
+ BKE_mesh_tessface_clear(me);
+
+ DEG_id_tag_update(&me->id, 0);
+
+ return true;
+}
+
+/* -------------------------------------------------------------------- */
+/** \name Color Blending Modes
+ * \{ */
+
+BLI_INLINE uint mcol_blend(uint col1, uint col2, int fac)
+{
+ uchar *cp1, *cp2, *cp;
+ int mfac;
+ uint col = 0;
+
+ if (fac == 0) {
+ return col1;
+ }
+
+ if (fac >= 255) {
+ return col2;
+ }
+
+ mfac = 255 - fac;
+
+ cp1 = (uchar *)&col1;
+ cp2 = (uchar *)&col2;
+ cp = (uchar *)&col;
+
+ /* Updated to use the rgb squared color model which blends nicer. */
+ int r1 = cp1[0] * cp1[0];
+ int g1 = cp1[1] * cp1[1];
+ int b1 = cp1[2] * cp1[2];
+ int a1 = cp1[3] * cp1[3];
+
+ int r2 = cp2[0] * cp2[0];
+ int g2 = cp2[1] * cp2[1];
+ int b2 = cp2[2] * cp2[2];
+ int a2 = cp2[3] * cp2[3];
+
+ cp[0] = round_fl_to_uchar(sqrtf(divide_round_i((mfac * r1 + fac * r2), 255)));
+ cp[1] = round_fl_to_uchar(sqrtf(divide_round_i((mfac * g1 + fac * g2), 255)));
+ cp[2] = round_fl_to_uchar(sqrtf(divide_round_i((mfac * b1 + fac * b2), 255)));
+ cp[3] = round_fl_to_uchar(sqrtf(divide_round_i((mfac * a1 + fac * a2), 255)));
+
+ return col;
+}
+
+BLI_INLINE uint mcol_add(uint col1, uint col2, int fac)
+{
+ uchar *cp1, *cp2, *cp;
+ int temp;
+ uint col = 0;
+
+ if (fac == 0) {
+ return col1;
+ }
+
+ cp1 = (uchar *)&col1;
+ cp2 = (uchar *)&col2;
+ cp = (uchar *)&col;
+
+ temp = cp1[0] + divide_round_i((fac * cp2[0]), 255);
+ cp[0] = (temp > 254) ? 255 : temp;
+ temp = cp1[1] + divide_round_i((fac * cp2[1]), 255);
+ cp[1] = (temp > 254) ? 255 : temp;
+ temp = cp1[2] + divide_round_i((fac * cp2[2]), 255);
+ cp[2] = (temp > 254) ? 255 : temp;
+ temp = cp1[3] + divide_round_i((fac * cp2[3]), 255);
+ cp[3] = (temp > 254) ? 255 : temp;
+
+ return col;
+}
+
+BLI_INLINE uint mcol_sub(uint col1, uint col2, int fac)
+{
+ uchar *cp1, *cp2, *cp;
+ int temp;
+ uint col = 0;
+
+ if (fac == 0) {
+ return col1;
+ }
+
+ cp1 = (uchar *)&col1;
+ cp2 = (uchar *)&col2;
+ cp = (uchar *)&col;
+
+ temp = cp1[0] - divide_round_i((fac * cp2[0]), 255);
+ cp[0] = (temp < 0) ? 0 : temp;
+ temp = cp1[1] - divide_round_i((fac * cp2[1]), 255);
+ cp[1] = (temp < 0) ? 0 : temp;
+ temp = cp1[2] - divide_round_i((fac * cp2[2]), 255);
+ cp[2] = (temp < 0) ? 0 : temp;
+ temp = cp1[3] - divide_round_i((fac * cp2[3]), 255);
+ cp[3] = (temp < 0) ? 0 : temp;
+
+ return col;
+}
+
+BLI_INLINE uint mcol_mul(uint col1, uint col2, int fac)
+{
+ uchar *cp1, *cp2, *cp;
+ int mfac;
+ uint col = 0;
+
+ if (fac == 0) {
+ return col1;
+ }
+
+ mfac = 255 - fac;
+
+ cp1 = (uchar *)&col1;
+ cp2 = (uchar *)&col2;
+ cp = (uchar *)&col;
+
+ /* first mul, then blend the fac */
+ cp[0] = divide_round_i(mfac * cp1[0] * 255 + fac * cp2[0] * cp1[0], 255 * 255);
+ cp[1] = divide_round_i(mfac * cp1[1] * 255 + fac * cp2[1] * cp1[1], 255 * 255);
+ cp[2] = divide_round_i(mfac * cp1[2] * 255 + fac * cp2[2] * cp1[2], 255 * 255);
+ cp[3] = divide_round_i(mfac * cp1[3] * 255 + fac * cp2[3] * cp1[3], 255 * 255);
+
+ return col;
+}
+
+BLI_INLINE uint mcol_lighten(uint col1, uint col2, int fac)
+{
+ uchar *cp1, *cp2, *cp;
+ int mfac;
+ uint col = 0;
+
+ if (fac == 0) {
+ return col1;
+ }
+ else if (fac >= 255) {
+ return col2;
+ }
+
+ mfac = 255 - fac;
+
+ cp1 = (uchar *)&col1;
+ cp2 = (uchar *)&col2;
+ cp = (uchar *)&col;
+
+ /* See if are lighter, if so mix, else don't do anything.
+ * if the paint col is darker then the original, then ignore */
+ if (IMB_colormanagement_get_luminance_byte(cp1) > IMB_colormanagement_get_luminance_byte(cp2)) {
+ return col1;
+ }
+
+ cp[0] = divide_round_i(mfac * cp1[0] + fac * cp2[0], 255);
+ cp[1] = divide_round_i(mfac * cp1[1] + fac * cp2[1], 255);
+ cp[2] = divide_round_i(mfac * cp1[2] + fac * cp2[2], 255);
+ cp[3] = divide_round_i(mfac * cp1[3] + fac * cp2[3], 255);
+
+ return col;
+}
+
+BLI_INLINE uint mcol_darken(uint col1, uint col2, int fac)
+{
+ uchar *cp1, *cp2, *cp;
+ int mfac;
+ uint col = 0;
+
+ if (fac == 0) {
+ return col1;
+ }
+ else if (fac >= 255) {
+ return col2;
+ }
+
+ mfac = 255 - fac;
+
+ cp1 = (uchar *)&col1;
+ cp2 = (uchar *)&col2;
+ cp = (uchar *)&col;
+
+ /* See if were darker, if so mix, else don't do anything.
+ * if the paint col is brighter then the original, then ignore */
+ if (IMB_colormanagement_get_luminance_byte(cp1) < IMB_colormanagement_get_luminance_byte(cp2)) {
+ return col1;
+ }
+
+ cp[0] = divide_round_i((mfac * cp1[0] + fac * cp2[0]), 255);
+ cp[1] = divide_round_i((mfac * cp1[1] + fac * cp2[1]), 255);
+ cp[2] = divide_round_i((mfac * cp1[2] + fac * cp2[2]), 255);
+ cp[3] = divide_round_i((mfac * cp1[3] + fac * cp2[3]), 255);
+ return col;
+}
+
+BLI_INLINE uint mcol_colordodge(uint col1, uint col2, int fac)
+{
+ uchar *cp1, *cp2, *cp;
+ int mfac, temp;
+ uint col = 0;
+
+ if (fac == 0) {
+ return col1;
+ }
+
+ mfac = 255 - fac;
+
+ cp1 = (uchar *)&col1;
+ cp2 = (uchar *)&col2;
+ cp = (uchar *)&col;
+
+ temp = (cp2[0] == 255) ? 255 : min_ii((cp1[0] * 225) / (255 - cp2[0]), 255);
+ cp[0] = (mfac * cp1[0] + temp * fac) / 255;
+ temp = (cp2[1] == 255) ? 255 : min_ii((cp1[1] * 225) / (255 - cp2[1]), 255);
+ cp[1] = (mfac * cp1[1] + temp * fac) / 255;
+ temp = (cp2[2] == 255) ? 255 : min_ii((cp1[2] * 225) / (255 - cp2[2]), 255);
+ cp[2] = (mfac * cp1[2] + temp * fac) / 255;
+ temp = (cp2[3] == 255) ? 255 : min_ii((cp1[3] * 225) / (255 - cp2[3]), 255);
+ cp[3] = (mfac * cp1[3] + temp * fac) / 255;
+ return col;
+}
+
+BLI_INLINE uint mcol_difference(uint col1, uint col2, int fac)
+{
+ uchar *cp1, *cp2, *cp;
+ int mfac, temp;
+ uint col = 0;
+
+ if (fac == 0) {
+ return col1;
+ }
+
+ mfac = 255 - fac;
+
+ cp1 = (uchar *)&col1;
+ cp2 = (uchar *)&col2;
+ cp = (uchar *)&col;
+
+ temp = abs(cp1[0] - cp2[0]);
+ cp[0] = (mfac * cp1[0] + temp * fac) / 255;
+ temp = abs(cp1[1] - cp2[1]);
+ cp[1] = (mfac * cp1[1] + temp * fac) / 255;
+ temp = abs(cp1[2] - cp2[2]);
+ cp[2] = (mfac * cp1[2] + temp * fac) / 255;
+ temp = abs(cp1[3] - cp2[3]);
+ cp[3] = (mfac * cp1[3] + temp * fac) / 255;
+ return col;
+}
+
+BLI_INLINE uint mcol_screen(uint col1, uint col2, int fac)
+{
+ uchar *cp1, *cp2, *cp;
+ int mfac, temp;
+ uint col = 0;
+
+ if (fac == 0) {
+ return col1;
+ }
+
+ mfac = 255 - fac;
+
+ cp1 = (uchar *)&col1;
+ cp2 = (uchar *)&col2;
+ cp = (uchar *)&col;
+
+ temp = max_ii(255 - (((255 - cp1[0]) * (255 - cp2[0])) / 255), 0);
+ cp[0] = (mfac * cp1[0] + temp * fac) / 255;
+ temp = max_ii(255 - (((255 - cp1[1]) * (255 - cp2[1])) / 255), 0);
+ cp[1] = (mfac * cp1[1] + temp * fac) / 255;
+ temp = max_ii(255 - (((255 - cp1[2]) * (255 - cp2[2])) / 255), 0);
+ cp[2] = (mfac * cp1[2] + temp * fac) / 255;
+ temp = max_ii(255 - (((255 - cp1[3]) * (255 - cp2[3])) / 255), 0);
+ cp[3] = (mfac * cp1[3] + temp * fac) / 255;
+ return col;
+}
+
+BLI_INLINE uint mcol_hardlight(uint col1, uint col2, int fac)
+{
+ uchar *cp1, *cp2, *cp;
+ int mfac, temp;
+ uint col = 0;
+
+ if (fac == 0) {
+ return col1;
+ }
+
+ mfac = 255 - fac;
+
+ cp1 = (uchar *)&col1;
+ cp2 = (uchar *)&col2;
+ cp = (uchar *)&col;
+
+ int i = 0;
+
+ for (i = 0; i < 4; i++) {
+ if (cp2[i] > 127) {
+ temp = 255 - ((255 - 2 * (cp2[i] - 127)) * (255 - cp1[i]) / 255);
+ }
+ else {
+ temp = (2 * cp2[i] * cp1[i]) >> 8;
+ }
+ cp[i] = min_ii((mfac * cp1[i] + temp * fac) / 255, 255);
+ }
+ return col;
+}
+
+BLI_INLINE uint mcol_overlay(uint col1, uint col2, int fac)
+{
+ uchar *cp1, *cp2, *cp;
+ int mfac, temp;
+ uint col = 0;
+
+ if (fac == 0) {
+ return col1;
+ }
+
+ mfac = 255 - fac;
+
+ cp1 = (uchar *)&col1;
+ cp2 = (uchar *)&col2;
+ cp = (uchar *)&col;
+
+ int i = 0;
+
+ for (i = 0; i < 4; i++) {
+ if (cp1[i] > 127) {
+ temp = 255 - ((255 - 2 * (cp1[i] - 127)) * (255 - cp2[i]) / 255);
+ }
+ else {
+ temp = (2 * cp2[i] * cp1[i]) >> 8;
+ }
+ cp[i] = min_ii((mfac * cp1[i] + temp * fac) / 255, 255);
+ }
+ return col;
+}
+
+BLI_INLINE uint mcol_softlight(uint col1, uint col2, int fac)
+{
+ uchar *cp1, *cp2, *cp;
+ int mfac, temp;
+ uint col = 0;
+
+ if (fac == 0) {
+ return col1;
+ }
+
+ mfac = 255 - fac;
+
+ cp1 = (uchar *)&col1;
+ cp2 = (uchar *)&col2;
+ cp = (uchar *)&col;
+
+ int i = 0;
+
+ for (i = 0; i < 4; i++) {
+ if (cp1[i] < 127) {
+ temp = ((2 * ((cp2[i] / 2) + 64)) * cp1[i]) / 255;
+ }
+ else {
+ temp = 255 - (2 * (255 - ((cp2[i] / 2) + 64)) * (255 - cp1[i]) / 255);
+ }
+ cp[i] = (temp * fac + cp1[i] * mfac) / 255;
+ }
+ return col;
+}
+
+BLI_INLINE uint mcol_exclusion(uint col1, uint col2, int fac)
+{
+ uchar *cp1, *cp2, *cp;
+ int mfac, temp;
+ uint col = 0;
+
+ if (fac == 0) {
+ return col1;
+ }
+
+ mfac = 255 - fac;
+
+ cp1 = (uchar *)&col1;
+ cp2 = (uchar *)&col2;
+ cp = (uchar *)&col;
+
+ int i = 0;
+
+ for (i = 0; i < 4; i++) {
+ temp = 127 - ((2 * (cp1[i] - 127) * (cp2[i] - 127)) / 255);
+ cp[i] = (temp * fac + cp1[i] * mfac) / 255;
+ }
+ return col;
+}
+
+BLI_INLINE uint mcol_luminosity(uint col1, uint col2, int fac)
+{
+ uchar *cp1, *cp2, *cp;
+ int mfac;
+ uint col = 0;
+
+ if (fac == 0) {
+ return col1;
+ }
+
+ mfac = 255 - fac;
+
+ cp1 = (uchar *)&col1;
+ cp2 = (uchar *)&col2;
+ cp = (uchar *)&col;
+
+ float h1, s1, v1;
+ float h2, s2, v2;
+ float r, g, b;
+ rgb_to_hsv(cp1[0] / 255.0f, cp1[1] / 255.0f, cp1[2] / 255.0f, &h1, &s1, &v1);
+ rgb_to_hsv(cp2[0] / 255.0f, cp2[1] / 255.0f, cp2[2] / 255.0f, &h2, &s2, &v2);
+
+ v1 = v2;
+
+ hsv_to_rgb(h1, s1, v1, &r, &g, &b);
+
+ cp[0] = ((int)(r * 255.0f) * fac + mfac * cp1[0]) / 255;
+ cp[1] = ((int)(g * 255.0f) * fac + mfac * cp1[1]) / 255;
+ cp[2] = ((int)(b * 255.0f) * fac + mfac * cp1[2]) / 255;
+ cp[3] = ((int)(cp2[3]) * fac + mfac * cp1[3]) / 255;
+ return col;
+}
+
+BLI_INLINE uint mcol_saturation(uint col1, uint col2, int fac)
+{
+ uchar *cp1, *cp2, *cp;
+ int mfac;
+ uint col = 0;
+
+ if (fac == 0) {
+ return col1;
+ }
+
+ mfac = 255 - fac;
+
+ cp1 = (uchar *)&col1;
+ cp2 = (uchar *)&col2;
+ cp = (uchar *)&col;
+
+ float h1, s1, v1;
+ float h2, s2, v2;
+ float r, g, b;
+ rgb_to_hsv(cp1[0] / 255.0f, cp1[1] / 255.0f, cp1[2] / 255.0f, &h1, &s1, &v1);
+ rgb_to_hsv(cp2[0] / 255.0f, cp2[1] / 255.0f, cp2[2] / 255.0f, &h2, &s2, &v2);
+
+ if (s1 > EPS_SATURATION) {
+ s1 = s2;
+ }
+
+ hsv_to_rgb(h1, s1, v1, &r, &g, &b);
+
+ cp[0] = ((int)(r * 255.0f) * fac + mfac * cp1[0]) / 255;
+ cp[1] = ((int)(g * 255.0f) * fac + mfac * cp1[1]) / 255;
+ cp[2] = ((int)(b * 255.0f) * fac + mfac * cp1[2]) / 255;
+ return col;
+}
+
+BLI_INLINE uint mcol_hue(uint col1, uint col2, int fac)
+{
+ uchar *cp1, *cp2, *cp;
+ int mfac;
+ uint col = 0;
+
+ if (fac == 0) {
+ return col1;
+ }
+
+ mfac = 255 - fac;
+
+ cp1 = (uchar *)&col1;
+ cp2 = (uchar *)&col2;
+ cp = (uchar *)&col;
+
+ float h1, s1, v1;
+ float h2, s2, v2;
+ float r, g, b;
+ rgb_to_hsv(cp1[0] / 255.0f, cp1[1] / 255.0f, cp1[2] / 255.0f, &h1, &s1, &v1);
+ rgb_to_hsv(cp2[0] / 255.0f, cp2[1] / 255.0f, cp2[2] / 255.0f, &h2, &s2, &v2);
+
+ h1 = h2;
+
+ hsv_to_rgb(h1, s1, v1, &r, &g, &b);
+
+ cp[0] = ((int)(r * 255.0f) * fac + mfac * cp1[0]) / 255;
+ cp[1] = ((int)(g * 255.0f) * fac + mfac * cp1[1]) / 255;
+ cp[2] = ((int)(b * 255.0f) * fac + mfac * cp1[2]) / 255;
+ cp[3] = ((int)(cp2[3]) * fac + mfac * cp1[3]) / 255;
+ return col;
+}
+
+BLI_INLINE uint mcol_alpha_add(uint col1, int fac)
+{
+ uchar *cp1, *cp;
+ int temp;
+ uint col = 0;
+
+ if (fac == 0) {
+ return col1;
+ }
+
+ cp1 = (uchar *)&col1;
+ cp = (uchar *)&col;
+
+ temp = cp1[3] + fac;
+ cp[3] = (temp > 254) ? 255 : temp;
+
+ return col;
+}
+
+BLI_INLINE uint mcol_alpha_sub(uint col1, int fac)
+{
+ uchar *cp1, *cp;
+ int temp;
+ uint col = 0;
+
+ if (fac == 0) {
+ return col1;
+ }
+
+ cp1 = (uchar *)&col1;
+ cp = (uchar *)&col;
+
+ temp = cp1[3] - fac;
+ cp[3] = temp < 0 ? 0 : temp;
+
+ return col;
+}
+
+/* wpaint has 'ED_wpaint_blend_tool' */
+uint ED_vpaint_blend_tool(
+ const int tool, const uint col,
+ const uint paintcol, const int alpha_i)
+{
+ switch (tool) {
+ case PAINT_BLEND_MIX:
+ case PAINT_BLEND_BLUR: return mcol_blend(col, paintcol, alpha_i);
+ case PAINT_BLEND_AVERAGE: return mcol_blend(col, paintcol, alpha_i);
+ case PAINT_BLEND_SMEAR: return mcol_blend(col, paintcol, alpha_i);
+ case PAINT_BLEND_ADD: return mcol_add(col, paintcol, alpha_i);
+ case PAINT_BLEND_SUB: return mcol_sub(col, paintcol, alpha_i);
+ case PAINT_BLEND_MUL: return mcol_mul(col, paintcol, alpha_i);
+ case PAINT_BLEND_LIGHTEN: return mcol_lighten(col, paintcol, alpha_i);
+ case PAINT_BLEND_DARKEN: return mcol_darken(col, paintcol, alpha_i);
+ case PAINT_BLEND_COLORDODGE: return mcol_colordodge(col, paintcol, alpha_i);
+ case PAINT_BLEND_DIFFERENCE: return mcol_difference(col, paintcol, alpha_i);
+ case PAINT_BLEND_SCREEN: return mcol_screen(col, paintcol, alpha_i);
+ case PAINT_BLEND_HARDLIGHT: return mcol_hardlight(col, paintcol, alpha_i);
+ case PAINT_BLEND_OVERLAY: return mcol_overlay(col, paintcol, alpha_i);
+ case PAINT_BLEND_SOFTLIGHT: return mcol_softlight(col, paintcol, alpha_i);
+ case PAINT_BLEND_EXCLUSION: return mcol_exclusion(col, paintcol, alpha_i);
+ case PAINT_BLEND_LUMINOCITY: return mcol_luminosity(col, paintcol, alpha_i);
+ case PAINT_BLEND_SATURATION: return mcol_saturation(col, paintcol, alpha_i);
+ case PAINT_BLEND_HUE: return mcol_hue(col, paintcol, alpha_i);
+ /* non-color */
+ case PAINT_BLEND_ALPHA_SUB: return mcol_alpha_sub(col, alpha_i);
+ case PAINT_BLEND_ALPHA_ADD: return mcol_alpha_add(col, alpha_i);
+ default:
+ BLI_assert(0);
+ return 0;
+ }
+}
+
+/** \} */
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_proj.c b/source/blender/editors/sculpt_paint/paint_vertex_proj.c
index c939eb6df35..999c9dc7880 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_proj.c
@@ -42,6 +42,8 @@
#include "BKE_DerivedMesh.h"
#include "BKE_context.h"
+#include "DEG_depsgraph.h"
+
#include "ED_screen.h"
#include "ED_view3d.h"
@@ -98,13 +100,14 @@ static void vpaint_proj_dm_map_cosnos_init__map_cb(void *userData, int index, co
}
}
-static void vpaint_proj_dm_map_cosnos_init(Scene *scene, Object *ob,
- struct VertProjHandle *vp_handle)
+static void vpaint_proj_dm_map_cosnos_init(
+ const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob,
+ struct VertProjHandle *vp_handle)
{
Mesh *me = ob->data;
DerivedMesh *dm;
- dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX);
+ dm = mesh_get_derived_final(eval_ctx, scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX);
if (dm->foreachMappedVert) {
memset(vp_handle->vcosnos, 0, sizeof(DMCoNo) * me->totvert);
@@ -169,8 +172,9 @@ static void vpaint_proj_dm_map_cosnos_update__map_cb(void *userData, int index,
}
}
-static void vpaint_proj_dm_map_cosnos_update(struct VertProjHandle *vp_handle,
- ARegion *ar, const float mval_fl[2])
+static void vpaint_proj_dm_map_cosnos_update(
+ const struct EvaluationContext *eval_ctx, struct VertProjHandle *vp_handle,
+ ARegion *ar, const float mval_fl[2])
{
struct VertProjUpdate vp_update = {vp_handle, ar, mval_fl};
@@ -182,7 +186,7 @@ static void vpaint_proj_dm_map_cosnos_update(struct VertProjHandle *vp_handle,
/* quick sanity check - we shouldn't have to run this if there are no modifiers */
BLI_assert(BLI_listbase_is_empty(&ob->modifiers) == false);
- dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX);
+ dm = mesh_get_derived_final(eval_ctx, scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX);
/* highly unlikely this will become unavailable once painting starts (perhaps with animated modifiers) */
if (LIKELY(dm->foreachMappedVert)) {
@@ -198,8 +202,9 @@ static void vpaint_proj_dm_map_cosnos_update(struct VertProjHandle *vp_handle,
/* -------------------------------------------------------------------- */
/* Public Functions */
-struct VertProjHandle *ED_vpaint_proj_handle_create(Scene *scene, Object *ob,
- DMCoNo **r_vcosnos)
+struct VertProjHandle *ED_vpaint_proj_handle_create(
+ const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob,
+ DMCoNo **r_vcosnos)
{
struct VertProjHandle *vp_handle = MEM_mallocN(sizeof(struct VertProjHandle), __func__);
Mesh *me = ob->data;
@@ -209,7 +214,7 @@ struct VertProjHandle *ED_vpaint_proj_handle_create(Scene *scene, Object *ob,
vp_handle->use_update = false;
/* sets 'use_update' if needed */
- vpaint_proj_dm_map_cosnos_init(scene, ob, vp_handle);
+ vpaint_proj_dm_map_cosnos_init(eval_ctx, scene, ob, vp_handle);
if (vp_handle->use_update) {
vp_handle->dists_sq = MEM_mallocN(sizeof(float) * me->totvert, __func__);
@@ -228,11 +233,12 @@ struct VertProjHandle *ED_vpaint_proj_handle_create(Scene *scene, Object *ob,
return vp_handle;
}
-void ED_vpaint_proj_handle_update(struct VertProjHandle *vp_handle,
- ARegion *ar, const float mval_fl[2])
+void ED_vpaint_proj_handle_update(
+ const struct EvaluationContext *eval_ctx, struct VertProjHandle *vp_handle,
+ ARegion *ar, const float mval_fl[2])
{
if (vp_handle->use_update) {
- vpaint_proj_dm_map_cosnos_update(vp_handle, ar, mval_fl);
+ vpaint_proj_dm_map_cosnos_update(eval_ctx, vp_handle, ar, mval_fl);
}
}
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
new file mode 100644
index 00000000000..ef86f3c773d
--- /dev/null
+++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
@@ -0,0 +1,869 @@
+/*
+ * ***** 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/sculpt_paint/paint_vertex_weight_ops.c
+ * \ingroup edsculpt
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_math.h"
+#include "BLI_array_utils.h"
+#include "BLI_bitmap.h"
+#include "BLI_task.h"
+#include "BLI_string_utils.h"
+
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
+#include "IMB_colormanagement.h"
+
+//#include "DNA_armature_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_particle_types.h"
+#include "DNA_brush_types.h"
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+#include "RNA_enum_types.h"
+
+#include "BKE_DerivedMesh.h"
+#include "BKE_brush.h"
+#include "BKE_context.h"
+#include "BKE_deform.h"
+#include "BKE_mesh.h"
+#include "BKE_mesh_mapping.h"
+#include "BKE_modifier.h"
+#include "BKE_object_deform.h"
+#include "BKE_paint.h"
+#include "BKE_report.h"
+#include "BKE_colortools.h"
+
+#include "DEG_depsgraph.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "ED_armature.h"
+#include "ED_mesh.h"
+#include "ED_screen.h"
+#include "ED_view3d.h"
+
+#include "paint_intern.h" /* own include */
+
+/* -------------------------------------------------------------------- */
+/** \name Store Previous Weights
+ *
+ * Use to avoid feedback loop w/ mirrored edits.
+ * \{ */
+
+struct WPaintPrev {
+ /* previous vertex weights */
+ struct MDeformVert *wpaint_prev;
+ /* allocation size of prev buffers */
+ int tot;
+};
+
+
+static void wpaint_prev_init(struct WPaintPrev *wpp)
+{
+ wpp->wpaint_prev = NULL;
+ wpp->tot = 0;
+}
+
+static void wpaint_prev_create(struct WPaintPrev *wpp, MDeformVert *dverts, int dcount)
+{
+ wpaint_prev_init(wpp);
+
+ if (dverts && dcount) {
+ wpp->wpaint_prev = MEM_mallocN(sizeof(MDeformVert) * dcount, "wpaint prev");
+ wpp->tot = dcount;
+ BKE_defvert_array_copy(wpp->wpaint_prev, dverts, dcount);
+ }
+}
+
+static void wpaint_prev_destroy(struct WPaintPrev *wpp)
+{
+ if (wpp->wpaint_prev) {
+ BKE_defvert_array_free(wpp->wpaint_prev, wpp->tot);
+ }
+ wpp->wpaint_prev = NULL;
+ wpp->tot = 0;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Weight from Bones Operator
+ * \{ */
+
+static int weight_from_bones_poll(bContext *C)
+{
+ Object *ob = CTX_data_active_object(C);
+
+ return (ob && (ob->mode & OB_MODE_WEIGHT_PAINT) && modifiers_isDeformedByArmature(ob));
+}
+
+static int weight_from_bones_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene = CTX_data_scene(C);
+ Object *ob = CTX_data_active_object(C);
+ Object *armob = modifiers_isDeformedByArmature(ob);
+ Mesh *me = ob->data;
+ int type = RNA_enum_get(op->ptr, "type");
+
+ EvaluationContext eval_ctx;
+
+ CTX_data_eval_ctx(C, &eval_ctx);
+
+ create_vgroups_from_armature(op->reports, &eval_ctx, scene, ob, armob, type, (me->editflag & ME_EDIT_MIRROR_X));
+
+ DEG_id_tag_update(&me->id, 0);
+ WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
+
+ return OPERATOR_FINISHED;
+}
+
+void PAINT_OT_weight_from_bones(wmOperatorType *ot)
+{
+ static EnumPropertyItem type_items[] = {
+ {ARM_GROUPS_AUTO, "AUTOMATIC", 0, "Automatic", "Automatic weights from bones"},
+ {ARM_GROUPS_ENVELOPE, "ENVELOPES", 0, "From Envelopes", "Weights from envelopes with user defined radius"},
+ {0, NULL, 0, NULL, NULL}};
+
+ /* identifiers */
+ ot->name = "Weight from Bones";
+ ot->idname = "PAINT_OT_weight_from_bones";
+ ot->description = "Set the weights of the groups matching the attached armature's selected bones, "
+ "using the distance between the vertices and the bones";
+
+ /* api callbacks */
+ ot->exec = weight_from_bones_exec;
+ ot->invoke = WM_menu_invoke;
+ ot->poll = weight_from_bones_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* properties */
+ ot->prop = RNA_def_enum(ot->srna, "type", type_items, 0, "Type", "Method to use for assigning weights");
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Sample Weight Operator
+ * \{ */
+
+/* sets wp->weight to the closest weight value to vertex */
+/* note: we cant sample frontbuf, weight colors are interpolated too unpredictable */
+static int weight_sample_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ ViewContext vc;
+ Mesh *me;
+ bool changed = false;
+
+ view3d_set_viewcontext(C, &vc);
+ me = BKE_mesh_from_object(vc.obact);
+
+ if (me && me->dvert && vc.v3d && vc.rv3d && (vc.obact->actdef != 0)) {
+ const bool use_vert_sel = (me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0;
+ int v_idx_best = -1;
+ uint index;
+
+ view3d_operator_needs_opengl(C);
+ ED_view3d_init_mats_rv3d(vc.obact, vc.rv3d);
+
+ if (use_vert_sel) {
+ if (ED_mesh_pick_vert(C, vc.obact, event->mval, &index, ED_MESH_PICK_DEFAULT_VERT_SIZE, true)) {
+ v_idx_best = index;
+ }
+ }
+ else {
+ if (ED_mesh_pick_face_vert(C, vc.obact, event->mval, &index, ED_MESH_PICK_DEFAULT_FACE_SIZE)) {
+ v_idx_best = index;
+ }
+ else if (ED_mesh_pick_face(C, vc.obact, event->mval, &index, ED_MESH_PICK_DEFAULT_FACE_SIZE)) {
+ /* this relies on knowning the internal worksings of ED_mesh_pick_face_vert() */
+ BKE_report(op->reports, RPT_WARNING, "The modifier used does not support deformed locations");
+ }
+ }
+
+ if (v_idx_best != -1) { /* should always be valid */
+ ToolSettings *ts = vc.scene->toolsettings;
+ Brush *brush = BKE_paint_brush(&ts->wpaint->paint);
+ const int vgroup_active = vc.obact->actdef - 1;
+ float vgroup_weight = defvert_find_weight(&me->dvert[v_idx_best], vgroup_active);
+
+ /* use combined weight in multipaint mode, since that's what is displayed to the user in the colors */
+ if (ts->multipaint) {
+ int defbase_tot_sel;
+ const int defbase_tot = BLI_listbase_count(&vc.obact->defbase);
+ bool *defbase_sel = BKE_object_defgroup_selected_get(vc.obact, defbase_tot, &defbase_tot_sel);
+
+ if (defbase_tot_sel > 1) {
+ if (me->editflag & ME_EDIT_MIRROR_X) {
+ BKE_object_defgroup_mirror_selection(
+ vc.obact, defbase_tot, defbase_sel, defbase_sel, &defbase_tot_sel);
+ }
+
+ vgroup_weight = BKE_defvert_multipaint_collective_weight(
+ &me->dvert[v_idx_best], defbase_tot, defbase_sel, defbase_tot_sel, ts->auto_normalize);
+
+ /* if autonormalize is enabled, but weights are not normalized, the value can exceed 1 */
+ CLAMP(vgroup_weight, 0.0f, 1.0f);
+ }
+
+ MEM_freeN(defbase_sel);
+ }
+
+ BKE_brush_weight_set(vc.scene, brush, vgroup_weight);
+ changed = true;
+ }
+ }
+
+ if (changed) {
+ /* not really correct since the brush didnt change, but redraws the toolbar */
+ WM_main_add_notifier(NC_BRUSH | NA_EDITED, NULL); /* ts->wpaint->paint.brush */
+
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
+}
+
+void PAINT_OT_weight_sample(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Weight Paint Sample Weight";
+ ot->idname = "PAINT_OT_weight_sample";
+ ot->description = "Use the mouse to sample a weight in the 3D view";
+
+ /* api callbacks */
+ ot->invoke = weight_sample_invoke;
+ ot->poll = weight_paint_mode_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_UNDO;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Weight Paint Sample Group Operator
+ * \{ */
+
+/* samples cursor location, and gives menu with vertex groups to activate */
+static bool weight_paint_sample_enum_itemf__helper(const MDeformVert *dvert, const int defbase_tot, int *groups)
+{
+ /* this func fills in used vgroup's */
+ bool found = false;
+ int i = dvert->totweight;
+ MDeformWeight *dw;
+ for (dw = dvert->dw; i > 0; dw++, i--) {
+ if (dw->def_nr < defbase_tot) {
+ groups[dw->def_nr] = true;
+ found = true;
+ }
+ }
+ return found;
+}
+static EnumPropertyItem *weight_paint_sample_enum_itemf(
+ bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
+{
+ if (C) {
+ wmWindow *win = CTX_wm_window(C);
+ if (win && win->eventstate) {
+ ViewContext vc;
+ Mesh *me;
+
+ view3d_set_viewcontext(C, &vc);
+ me = BKE_mesh_from_object(vc.obact);
+
+ if (me && me->dvert && vc.v3d && vc.rv3d && vc.obact->defbase.first) {
+ const int defbase_tot = BLI_listbase_count(&vc.obact->defbase);
+ const bool use_vert_sel = (me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0;
+ int *groups = MEM_callocN(defbase_tot * sizeof(int), "groups");
+ bool found = false;
+ uint index;
+
+ const int mval[2] = {
+ win->eventstate->x - vc.ar->winrct.xmin,
+ win->eventstate->y - vc.ar->winrct.ymin,
+ };
+
+ view3d_operator_needs_opengl(C);
+ ED_view3d_init_mats_rv3d(vc.obact, vc.rv3d);
+
+ if (use_vert_sel) {
+ if (ED_mesh_pick_vert(C, vc.obact, mval, &index, ED_MESH_PICK_DEFAULT_VERT_SIZE, true)) {
+ MDeformVert *dvert = &me->dvert[index];
+ found |= weight_paint_sample_enum_itemf__helper(dvert, defbase_tot, groups);
+ }
+ }
+ else {
+ if (ED_mesh_pick_face(C, vc.obact, mval, &index, ED_MESH_PICK_DEFAULT_FACE_SIZE)) {
+ const MPoly *mp = &me->mpoly[index];
+ uint fidx = mp->totloop - 1;
+
+ do {
+ MDeformVert *dvert = &me->dvert[me->mloop[mp->loopstart + fidx].v];
+ found |= weight_paint_sample_enum_itemf__helper(dvert, defbase_tot, groups);
+ } while (fidx--);
+ }
+ }
+
+ if (found == false) {
+ MEM_freeN(groups);
+ }
+ else {
+ EnumPropertyItem *item = NULL, item_tmp = {0};
+ int totitem = 0;
+ int i = 0;
+ bDeformGroup *dg;
+ for (dg = vc.obact->defbase.first; dg && i < defbase_tot; i++, dg = dg->next) {
+ if (groups[i]) {
+ item_tmp.identifier = item_tmp.name = dg->name;
+ item_tmp.value = i;
+ RNA_enum_item_add(&item, &totitem, &item_tmp);
+ }
+ }
+
+ RNA_enum_item_end(&item, &totitem);
+ *r_free = true;
+
+ MEM_freeN(groups);
+ return item;
+ }
+ }
+ }
+ }
+
+ return DummyRNA_NULL_items;
+}
+
+static int weight_sample_group_exec(bContext *C, wmOperator *op)
+{
+ int type = RNA_enum_get(op->ptr, "group");
+ ViewContext vc;
+ view3d_set_viewcontext(C, &vc);
+
+ BLI_assert(type + 1 >= 0);
+ vc.obact->actdef = type + 1;
+
+ DEG_id_tag_update(&vc.obact->id, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, vc.obact);
+ return OPERATOR_FINISHED;
+}
+
+/* TODO, we could make this a menu into OBJECT_OT_vertex_group_set_active rather than its own operator */
+void PAINT_OT_weight_sample_group(wmOperatorType *ot)
+{
+ PropertyRNA *prop = NULL;
+
+ /* identifiers */
+ ot->name = "Weight Paint Sample Group";
+ ot->idname = "PAINT_OT_weight_sample_group";
+ ot->description = "Select one of the vertex groups available under current mouse position";
+
+ /* api callbacks */
+ ot->exec = weight_sample_group_exec;
+ ot->invoke = WM_menu_invoke;
+ ot->poll = weight_paint_mode_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_UNDO;
+
+ /* keyingset to use (dynamic enum) */
+ prop = RNA_def_enum(ot->srna, "group", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use");
+ RNA_def_enum_funcs(prop, weight_paint_sample_enum_itemf);
+ RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
+ ot->prop = prop;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Weight Set Operator
+ * \{ */
+
+/* fills in the selected faces with the current weight and vertex group */
+static bool weight_paint_set(Object *ob, float paintweight)
+{
+ Mesh *me = ob->data;
+ const MPoly *mp;
+ MDeformWeight *dw, *dw_prev;
+ int vgroup_active, vgroup_mirror = -1;
+ uint index;
+ const bool topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0;
+
+ /* mutually exclusive, could be made into a */
+ const short paint_selmode = ME_EDIT_PAINT_SEL_MODE(me);
+
+ if (me->totpoly == 0 || me->dvert == NULL || !me->mpoly) {
+ return false;
+ }
+
+ vgroup_active = ob->actdef - 1;
+
+ /* if mirror painting, find the other group */
+ if (me->editflag & ME_EDIT_MIRROR_X) {
+ vgroup_mirror = ED_wpaint_mirror_vgroup_ensure(ob, vgroup_active);
+ }
+
+ struct WPaintPrev wpp;
+ wpaint_prev_create(&wpp, me->dvert, me->totvert);
+
+ for (index = 0, mp = me->mpoly; index < me->totpoly; index++, mp++) {
+ uint fidx = mp->totloop - 1;
+
+ if ((paint_selmode == SCE_SELECT_FACE) && !(mp->flag & ME_FACE_SEL)) {
+ continue;
+ }
+
+ do {
+ uint vidx = me->mloop[mp->loopstart + fidx].v;
+
+ if (!me->dvert[vidx].flag) {
+ if ((paint_selmode == SCE_SELECT_VERTEX) && !(me->mvert[vidx].flag & SELECT)) {
+ continue;
+ }
+
+ dw = defvert_verify_index(&me->dvert[vidx], vgroup_active);
+ if (dw) {
+ dw_prev = defvert_verify_index(wpp.wpaint_prev + vidx, vgroup_active);
+ dw_prev->weight = dw->weight; /* set the undo weight */
+ dw->weight = paintweight;
+
+ if (me->editflag & ME_EDIT_MIRROR_X) { /* x mirror painting */
+ int j = mesh_get_x_mirror_vert(ob, NULL, vidx, topology);
+ if (j >= 0) {
+ /* copy, not paint again */
+ if (vgroup_mirror != -1) {
+ dw = defvert_verify_index(me->dvert + j, vgroup_mirror);
+ dw_prev = defvert_verify_index(wpp.wpaint_prev + j, vgroup_mirror);
+ }
+ else {
+ dw = defvert_verify_index(me->dvert + j, vgroup_active);
+ dw_prev = defvert_verify_index(wpp.wpaint_prev + j, vgroup_active);
+ }
+ dw_prev->weight = dw->weight; /* set the undo weight */
+ dw->weight = paintweight;
+ }
+ }
+ }
+ me->dvert[vidx].flag = 1;
+ }
+
+ } while (fidx--);
+ }
+
+ {
+ MDeformVert *dv = me->dvert;
+ for (index = me->totvert; index != 0; index--, dv++) {
+ dv->flag = 0;
+ }
+ }
+
+ wpaint_prev_destroy(&wpp);
+
+ DEG_id_tag_update(&me->id, 0);
+
+ return true;
+}
+
+
+static int weight_paint_set_exec(bContext *C, wmOperator *op)
+{
+ struct Scene *scene = CTX_data_scene(C);
+ Object *obact = CTX_data_active_object(C);
+ ToolSettings *ts = CTX_data_tool_settings(C);
+ Brush *brush = BKE_paint_brush(&ts->wpaint->paint);
+ float vgroup_weight = BKE_brush_weight_get(scene, brush);
+
+ if (ED_wpaint_ensure_data(C, op->reports, WPAINT_ENSURE_MIRROR, NULL) == false) {
+ return OPERATOR_CANCELLED;
+ }
+
+ if (weight_paint_set(obact, vgroup_weight)) {
+ ED_region_tag_redraw(CTX_wm_region(C)); /* XXX - should redraw all 3D views */
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
+}
+
+void PAINT_OT_weight_set(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Set Weight";
+ ot->idname = "PAINT_OT_weight_set";
+ ot->description = "Fill the active vertex group with the current paint weight";
+
+ /* api callbacks */
+ ot->exec = weight_paint_set_exec;
+ ot->poll = mask_paint_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Interactive Weight Gradient Operator
+ * \{ */
+
+/* *** VGroups Gradient *** */
+typedef struct DMGradient_vertStore {
+ float sco[2];
+ float weight_orig;
+ enum {
+ VGRAD_STORE_NOP = 0,
+ VGRAD_STORE_DW_EXIST = (1 << 0)
+ } flag;
+} DMGradient_vertStore;
+
+typedef struct DMGradient_vertStoreBase {
+ struct WPaintPrev wpp;
+ DMGradient_vertStore elem[0];
+} DMGradient_vertStoreBase;
+
+typedef struct DMGradient_userData {
+ struct ARegion *ar;
+ Scene *scene;
+ Mesh *me;
+ Brush *brush;
+ const float *sco_start; /* [2] */
+ const float *sco_end; /* [2] */
+ float sco_line_div; /* store (1.0f / len_v2v2(sco_start, sco_end)) */
+ int def_nr;
+ bool is_init;
+ DMGradient_vertStoreBase *vert_cache;
+ /* only for init */
+ BLI_bitmap *vert_visit;
+
+ /* options */
+ short use_select;
+ short type;
+ float weightpaint;
+} DMGradient_userData;
+
+static void gradientVert_update(DMGradient_userData *grad_data, int index)
+{
+ Mesh *me = grad_data->me;
+ DMGradient_vertStore *vs = &grad_data->vert_cache->elem[index];
+ float alpha;
+
+ if (grad_data->type == WPAINT_GRADIENT_TYPE_LINEAR) {
+ alpha = line_point_factor_v2(vs->sco, grad_data->sco_start, grad_data->sco_end);
+ }
+ else {
+ BLI_assert(grad_data->type == WPAINT_GRADIENT_TYPE_RADIAL);
+ alpha = len_v2v2(grad_data->sco_start, vs->sco) * grad_data->sco_line_div;
+ }
+ /* no need to clamp 'alpha' yet */
+
+ /* adjust weight */
+ alpha = BKE_brush_curve_strength_clamped(grad_data->brush, alpha, 1.0f);
+
+ if (alpha != 0.0f) {
+ MDeformVert *dv = &me->dvert[index];
+ MDeformWeight *dw = defvert_verify_index(dv, grad_data->def_nr);
+ // dw->weight = alpha; // testing
+ int tool = grad_data->brush->vertexpaint_tool;
+ float testw;
+
+ /* init if we just added */
+ testw = ED_wpaint_blend_tool(tool, vs->weight_orig, grad_data->weightpaint, alpha * grad_data->brush->alpha);
+ CLAMP(testw, 0.0f, 1.0f);
+ dw->weight = testw;
+ }
+ else {
+ MDeformVert *dv = &me->dvert[index];
+ if (vs->flag & VGRAD_STORE_DW_EXIST) {
+ /* normally we NULL check, but in this case we know it exists */
+ MDeformWeight *dw = defvert_find_index(dv, grad_data->def_nr);
+ dw->weight = vs->weight_orig;
+ }
+ else {
+ /* wasn't originally existing, remove */
+ MDeformWeight *dw = defvert_find_index(dv, grad_data->def_nr);
+ if (dw) {
+ defvert_remove_group(dv, dw);
+ }
+ }
+ }
+}
+
+static void gradientVertUpdate__mapFunc(
+ void *userData, int index, const float UNUSED(co[3]),
+ const float UNUSED(no_f[3]), const short UNUSED(no_s[3]))
+{
+ DMGradient_userData *grad_data = userData;
+ Mesh *me = grad_data->me;
+ if ((grad_data->use_select == false) || (me->mvert[index].flag & SELECT)) {
+ DMGradient_vertStore *vs = &grad_data->vert_cache->elem[index];
+ if (vs->sco[0] != FLT_MAX) {
+ gradientVert_update(grad_data, index);
+ }
+ }
+}
+
+static void gradientVertInit__mapFunc(
+ void *userData, int index, const float co[3],
+ const float UNUSED(no_f[3]), const short UNUSED(no_s[3]))
+{
+ DMGradient_userData *grad_data = userData;
+ Mesh *me = grad_data->me;
+
+ if ((grad_data->use_select == false) || (me->mvert[index].flag & SELECT)) {
+ /* run first pass only,
+ * the screen coords of the verts need to be cached because
+ * updating the mesh may move them about (entering feedback loop) */
+
+ if (BLI_BITMAP_TEST(grad_data->vert_visit, index) == 0) {
+ DMGradient_vertStore *vs = &grad_data->vert_cache->elem[index];
+ if (ED_view3d_project_float_object(grad_data->ar,
+ co, vs->sco,
+ V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_NEAR) == V3D_PROJ_RET_OK)
+ {
+ /* ok */
+ MDeformVert *dv = &me->dvert[index];
+ const MDeformWeight *dw;
+ dw = defvert_find_index(dv, grad_data->def_nr);
+ if (dw) {
+ vs->weight_orig = dw->weight;
+ vs->flag = VGRAD_STORE_DW_EXIST;
+ }
+ else {
+ vs->weight_orig = 0.0f;
+ vs->flag = VGRAD_STORE_NOP;
+ }
+
+ BLI_BITMAP_ENABLE(grad_data->vert_visit, index);
+
+ gradientVert_update(grad_data, index);
+ }
+ else {
+ /* no go */
+ copy_v2_fl(vs->sco, FLT_MAX);
+ }
+ }
+ }
+}
+
+static int paint_weight_gradient_modal(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ wmGesture *gesture = op->customdata;
+ DMGradient_vertStoreBase *vert_cache = gesture->userdata;
+ int ret = WM_gesture_straightline_modal(C, op, event);
+
+ if (ret & OPERATOR_RUNNING_MODAL) {
+ if (event->type == LEFTMOUSE && event->val == KM_RELEASE) { /* XXX, hardcoded */
+ /* generally crap! redo! */
+ WM_gesture_straightline_cancel(C, op);
+ ret &= ~OPERATOR_RUNNING_MODAL;
+ ret |= OPERATOR_FINISHED;
+ }
+ }
+
+ if (ret & OPERATOR_CANCELLED) {
+ Object *ob = CTX_data_active_object(C);
+ Mesh *me = ob->data;
+ if (vert_cache->wpp.wpaint_prev) {
+ BKE_defvert_array_free_elems(me->dvert, me->totvert);
+ BKE_defvert_array_copy(me->dvert, vert_cache->wpp.wpaint_prev, me->totvert);
+ wpaint_prev_destroy(&vert_cache->wpp);
+ }
+ MEM_freeN(vert_cache);
+
+ DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
+ }
+ else if (ret & OPERATOR_FINISHED) {
+ wpaint_prev_destroy(&vert_cache->wpp);
+ MEM_freeN(vert_cache);
+ }
+
+ return ret;
+}
+
+static int paint_weight_gradient_exec(bContext *C, wmOperator *op)
+{
+ wmGesture *gesture = op->customdata;
+ DMGradient_vertStoreBase *vert_cache;
+ struct ARegion *ar = CTX_wm_region(C);
+ Scene *scene = CTX_data_scene(C);
+ Object *ob = CTX_data_active_object(C);
+ Mesh *me = ob->data;
+ int x_start = RNA_int_get(op->ptr, "xstart");
+ int y_start = RNA_int_get(op->ptr, "ystart");
+ int x_end = RNA_int_get(op->ptr, "xend");
+ int y_end = RNA_int_get(op->ptr, "yend");
+ float sco_start[2] = {x_start, y_start};
+ float sco_end[2] = {x_end, y_end};
+ const bool is_interactive = (gesture != NULL);
+
+ EvaluationContext eval_ctx;
+
+ CTX_data_eval_ctx(C, &eval_ctx);
+
+ DerivedMesh *dm = mesh_get_derived_final(&eval_ctx, scene, ob, scene->customdata_mask);
+
+ DMGradient_userData data = {NULL};
+
+ if (is_interactive) {
+ if (gesture->userdata == NULL) {
+ gesture->userdata = MEM_mallocN(
+ sizeof(DMGradient_vertStoreBase) +
+ (sizeof(DMGradient_vertStore) * me->totvert),
+ __func__);
+ gesture->userdata_free = false;
+ data.is_init = true;
+
+ wpaint_prev_create(&((DMGradient_vertStoreBase *)gesture->userdata)->wpp, me->dvert, me->totvert);
+
+ /* on init only, convert face -> vert sel */
+ if (me->editflag & ME_EDIT_PAINT_FACE_SEL) {
+ BKE_mesh_flush_select_from_polys(me);
+ }
+ }
+
+ vert_cache = gesture->userdata;
+ }
+ else {
+ if (ED_wpaint_ensure_data(C, op->reports, 0, NULL) == false) {
+ return OPERATOR_CANCELLED;
+ }
+
+ data.is_init = true;
+ vert_cache = MEM_mallocN(
+ sizeof(DMGradient_vertStoreBase) +
+ (sizeof(DMGradient_vertStore) * me->totvert),
+ __func__);
+ }
+
+ data.ar = ar;
+ data.scene = scene;
+ data.me = ob->data;
+ data.sco_start = sco_start;
+ data.sco_end = sco_end;
+ data.sco_line_div = 1.0f / len_v2v2(sco_start, sco_end);
+ data.def_nr = ob->actdef - 1;
+ data.use_select = (me->editflag & (ME_EDIT_PAINT_FACE_SEL | ME_EDIT_PAINT_VERT_SEL));
+ data.vert_cache = vert_cache;
+ data.vert_visit = NULL;
+ data.type = RNA_enum_get(op->ptr, "type");
+
+ {
+ ToolSettings *ts = CTX_data_tool_settings(C);
+ VPaint *wp = ts->wpaint;
+ struct Brush *brush = BKE_paint_brush(&wp->paint);
+
+ curvemapping_initialize(brush->curve);
+
+ data.brush = brush;
+ data.weightpaint = BKE_brush_weight_get(scene, brush);
+ }
+
+ ED_view3d_init_mats_rv3d(ob, ar->regiondata);
+
+ if (data.is_init) {
+ data.vert_visit = BLI_BITMAP_NEW(me->totvert, __func__);
+
+ dm->foreachMappedVert(dm, gradientVertInit__mapFunc, &data, DM_FOREACH_NOP);
+
+ MEM_freeN(data.vert_visit);
+ data.vert_visit = NULL;
+ }
+ else {
+ dm->foreachMappedVert(dm, gradientVertUpdate__mapFunc, &data, DM_FOREACH_NOP);
+ }
+
+ DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
+
+ if (is_interactive == false) {
+ MEM_freeN(vert_cache);
+ }
+
+ return OPERATOR_FINISHED;
+}
+
+static int paint_weight_gradient_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ int ret;
+
+ if (ED_wpaint_ensure_data(C, op->reports, 0, NULL) == false) {
+ return OPERATOR_CANCELLED;
+ }
+
+ ret = WM_gesture_straightline_invoke(C, op, event);
+ if (ret & OPERATOR_RUNNING_MODAL) {
+ struct ARegion *ar = CTX_wm_region(C);
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ /* TODO, hardcoded, extend WM_gesture_straightline_ */
+ if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
+ wmGesture *gesture = op->customdata;
+ gesture->mode = 1;
+ }
+ }
+ }
+ return ret;
+}
+
+void PAINT_OT_weight_gradient(wmOperatorType *ot)
+{
+ /* defined in DNA_space_types.h */
+ static EnumPropertyItem gradient_types[] = {
+ {WPAINT_GRADIENT_TYPE_LINEAR, "LINEAR", 0, "Linear", ""},
+ {WPAINT_GRADIENT_TYPE_RADIAL, "RADIAL", 0, "Radial", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ PropertyRNA *prop;
+
+ /* identifiers */
+ ot->name = "Weight Gradient";
+ ot->idname = "PAINT_OT_weight_gradient";
+ ot->description = "Draw a line to apply a weight gradient to selected vertices";
+
+ /* api callbacks */
+ ot->invoke = paint_weight_gradient_invoke;
+ ot->modal = paint_weight_gradient_modal;
+ ot->exec = paint_weight_gradient_exec;
+ ot->poll = weight_paint_poll;
+ ot->cancel = WM_gesture_straightline_cancel;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ prop = RNA_def_enum(ot->srna, "type", gradient_types, 0, "Type", "");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+
+ WM_operator_properties_gesture_straightline(ot, CURSOR_EDIT);
+}
+
+/** \} */
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c
new file mode 100644
index 00000000000..4d70d82d5c6
--- /dev/null
+++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c
@@ -0,0 +1,311 @@
+/*
+ * ***** 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/sculpt_paint/paint_vertex_weight_utils.c
+ * \ingroup edsculpt
+ *
+ * Intended for use by `paint_vertex.c` & `paint_vertex_weight_ops.c`.
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_listbase.h"
+#include "BLI_math.h"
+#include "BLI_string_utils.h"
+
+#include "DNA_armature_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_brush_types.h"
+#include "DNA_object_types.h"
+
+#include "BKE_action.h"
+#include "BKE_context.h"
+#include "BKE_deform.h"
+#include "BKE_mesh.h"
+#include "BKE_modifier.h"
+#include "BKE_object_deform.h"
+#include "BKE_report.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "paint_intern.h" /* own include */
+
+/* -------------------------------------------------------------------- */
+/** \name Weight Paint Sanity Checks
+ * \{ */
+
+/* ensure we have data on wpaint start, add if needed */
+bool ED_wpaint_ensure_data(
+ bContext *C, struct ReportList *reports,
+ enum eWPaintFlag flag, struct WPaintVGroupIndex *vgroup_index)
+{
+ Scene *scene = CTX_data_scene(C);
+ Object *ob = CTX_data_active_object(C);
+ Mesh *me = BKE_mesh_from_object(ob);
+
+ if (vgroup_index) {
+ vgroup_index->active = -1;
+ vgroup_index->mirror = -1;
+ }
+
+ if (scene->obedit) {
+ return false;
+ }
+
+ if (me == NULL || me->totpoly == 0) {
+ return false;
+ }
+
+ /* if nothing was added yet, we make dverts and a vertex deform group */
+ if (!me->dvert) {
+ BKE_object_defgroup_data_create(&me->id);
+ WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
+ }
+
+ /* this happens on a Bone select, when no vgroup existed yet */
+ if (ob->actdef <= 0) {
+ Object *modob;
+ if ((modob = modifiers_isDeformedByArmature(ob))) {
+ Bone *actbone = ((bArmature *)modob->data)->act_bone;
+ if (actbone) {
+ bPoseChannel *pchan = BKE_pose_channel_find_name(modob->pose, actbone->name);
+
+ if (pchan) {
+ bDeformGroup *dg = defgroup_find_name(ob, pchan->name);
+ if (dg == NULL) {
+ dg = BKE_object_defgroup_add_name(ob, pchan->name); /* sets actdef */
+ }
+ else {
+ int actdef = 1 + BLI_findindex(&ob->defbase, dg);
+ BLI_assert(actdef >= 0);
+ ob->actdef = actdef;
+ }
+ }
+ }
+ }
+ }
+ if (BLI_listbase_is_empty(&ob->defbase)) {
+ BKE_object_defgroup_add(ob);
+ }
+
+ /* ensure we don't try paint onto an invalid group */
+ if (ob->actdef <= 0) {
+ BKE_report(reports, RPT_WARNING, "No active vertex group for painting, aborting");
+ return false;
+ }
+
+ if (vgroup_index) {
+ vgroup_index->active = ob->actdef - 1;
+ }
+
+ if (flag & WPAINT_ENSURE_MIRROR) {
+ if (me->editflag & ME_EDIT_MIRROR_X) {
+ int mirror = ED_wpaint_mirror_vgroup_ensure(ob, ob->actdef - 1);
+ if (vgroup_index) {
+ vgroup_index->mirror = mirror;
+ }
+ }
+ }
+
+ return true;
+}
+/** \} */
+
+/* mirror_vgroup is set to -1 when invalid */
+int ED_wpaint_mirror_vgroup_ensure(Object *ob, const int vgroup_active)
+{
+ bDeformGroup *defgroup = BLI_findlink(&ob->defbase, vgroup_active);
+
+ if (defgroup) {
+ int mirrdef;
+ char name_flip[MAXBONENAME];
+
+ BLI_string_flip_side_name(name_flip, defgroup->name, false, sizeof(name_flip));
+ mirrdef = defgroup_name_index(ob, name_flip);
+ if (mirrdef == -1) {
+ if (BKE_defgroup_new(ob, name_flip)) {
+ mirrdef = BLI_listbase_count(&ob->defbase) - 1;
+ }
+ }
+
+ /* curdef should never be NULL unless this is
+ * a lamp and BKE_object_defgroup_add_name fails */
+ return mirrdef;
+ }
+
+ return -1;
+}
+
+/* -------------------------------------------------------------------- */
+/** \name Weight Blending Modes
+ * \{ */
+
+BLI_INLINE float wval_blend(const float weight, const float paintval, const float alpha)
+{
+ const float talpha = min_ff(alpha, 1.0f); /* blending with values over 1 doesn't make sense */
+ return (paintval * talpha) + (weight * (1.0f - talpha));
+}
+BLI_INLINE float wval_add(const float weight, const float paintval, const float alpha)
+{
+ return weight + (paintval * alpha);
+}
+BLI_INLINE float wval_sub(const float weight, const float paintval, const float alpha)
+{
+ return weight - (paintval * alpha);
+}
+BLI_INLINE float wval_mul(const float weight, const float paintval, const float alpha)
+{ /* first mul, then blend the fac */
+ return ((1.0f - alpha) + (alpha * paintval)) * weight;
+}
+BLI_INLINE float wval_lighten(const float weight, const float paintval, const float alpha)
+{
+ return (weight < paintval) ? wval_blend(weight, paintval, alpha) : weight;
+}
+BLI_INLINE float wval_darken(const float weight, const float paintval, const float alpha)
+{
+ return (weight > paintval) ? wval_blend(weight, paintval, alpha) : weight;
+}
+
+/* mainly for color */
+BLI_INLINE float wval_colordodge(float weight, float paintval, float fac)
+{
+ float mfac, temp;
+ if (fac == 0.0f) {
+ return weight;
+ }
+ mfac = 1.0f - fac;
+ temp = (paintval == 1.0f) ? 1.0f : min_ff((weight * (225.0f / 255.0f)) / (1.0f - paintval), 1.0f);
+ return mfac * weight + temp * fac;
+}
+BLI_INLINE float wval_difference(float weight, float paintval, float fac)
+{
+ float mfac, temp;
+ if (fac == 0.0f) {
+ return weight;
+ }
+ mfac = 1.0f - fac;
+ temp = fabsf(weight - paintval);
+ return mfac * weight + temp * fac;
+}
+BLI_INLINE float wval_screen(float weight, float paintval, float fac)
+{
+ float mfac, temp;
+ if (fac == 0.0f) {
+ return weight;
+ }
+ mfac = 1.0f - fac;
+ temp = max_ff(1.0f - (((1.0f - weight) * (1.0f - paintval))), 0);
+ return mfac * weight + temp * fac;
+}
+BLI_INLINE float wval_hardlight(float weight, float paintval, float fac)
+{
+ float mfac, temp;
+ if (fac == 0.0f) {
+ return weight;
+ }
+ mfac = 1.0f - fac;
+ if (paintval > 0.5f) {
+ temp = 1.0f - ((1.0f - 2.0f * (paintval - 0.5f)) * (1.0f - weight));
+ }
+ else {
+ temp = (2.0f * paintval * weight);
+ }
+ return mfac * weight + temp * fac;
+}
+BLI_INLINE float wval_overlay(float weight, float paintval, float fac)
+{
+ float mfac, temp;
+ if (fac == 0.0f) {
+ return weight;
+ }
+ mfac = 1.0f - fac;
+ if (weight > 0.5f) {
+ temp = 1.0f - ((1.0f - 2.0f * (weight - 0.5f)) * (1.0f - paintval));
+ }
+ else {
+ temp = (2.0f * paintval * weight);
+ }
+ return mfac * weight + temp * fac;
+}
+BLI_INLINE float wval_softlight(float weight, float paintval, float fac)
+{
+ float mfac, temp;
+ if (fac == 0.0f) {
+ return weight;
+ }
+ mfac = 1.0f - fac;
+ if (weight < 0.5f) {
+ temp = ((2.0f * ((paintval / 2.0f) + 0.25f)) * weight);
+ }
+ else {
+ temp = 1.0f - (2.0f * (1.0f - ((paintval / 2.0f) + 0.25f)) * (1.0f - weight));
+ }
+ return temp * fac + weight * mfac;
+}
+BLI_INLINE float wval_exclusion(float weight, float paintval, float fac)
+{
+ float mfac, temp;
+ if (fac == 0.0f) {
+ return weight;
+ }
+ mfac = 1.0f - fac;
+ temp = 0.5f - ((2.0f * (weight - 0.5f) * (paintval - 0.5f)));
+ return temp * fac + weight * mfac;
+}
+
+/* vpaint has 'vpaint_blend_tool' */
+/* result is not clamped from [0-1] */
+float ED_wpaint_blend_tool(
+ const int tool,
+ /* dw->weight */
+ const float weight,
+ const float paintval, const float alpha)
+{
+ switch (tool) {
+ case PAINT_BLEND_MIX:
+ case PAINT_BLEND_AVERAGE:
+ case PAINT_BLEND_SMEAR:
+ case PAINT_BLEND_BLUR: return wval_blend(weight, paintval, alpha);
+ case PAINT_BLEND_ADD: return wval_add(weight, paintval, alpha);
+ case PAINT_BLEND_SUB: return wval_sub(weight, paintval, alpha);
+ case PAINT_BLEND_MUL: return wval_mul(weight, paintval, alpha);
+ case PAINT_BLEND_LIGHTEN: return wval_lighten(weight, paintval, alpha);
+ case PAINT_BLEND_DARKEN: return wval_darken(weight, paintval, alpha);
+ /* Mostly make sense for color: support anyway. */
+ case PAINT_BLEND_COLORDODGE: return wval_colordodge(weight, paintval, alpha);
+ case PAINT_BLEND_DIFFERENCE: return wval_difference(weight, paintval, alpha);
+ case PAINT_BLEND_SCREEN: return wval_screen(weight, paintval, alpha);
+ case PAINT_BLEND_HARDLIGHT: return wval_hardlight(weight, paintval, alpha);
+ case PAINT_BLEND_OVERLAY: return wval_overlay(weight, paintval, alpha);
+ case PAINT_BLEND_SOFTLIGHT: return wval_softlight(weight, paintval, alpha);
+ case PAINT_BLEND_EXCLUSION: return wval_exclusion(weight, paintval, alpha);
+ /* Only for color: just use blend. */
+ case PAINT_BLEND_LUMINOCITY:
+ case PAINT_BLEND_SATURATION:
+ case PAINT_BLEND_HUE:
+ case PAINT_BLEND_ALPHA_SUB:
+ case PAINT_BLEND_ALPHA_ADD:
+ default: return wval_blend(weight, paintval, alpha);
+ }
+}
+
+/** \} */ \ No newline at end of file
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index b8e2724f786..fb5192b8072 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -39,7 +39,6 @@
#include "BLI_blenlib.h"
#include "BLI_dial.h"
#include "BLI_task.h"
-#include "BLI_threads.h"
#include "BLI_utildefines.h"
#include "BLI_ghash.h"
@@ -166,111 +165,12 @@ static bool sculpt_brush_needs_rake_rotation(const Brush *brush)
return SCULPT_TOOL_HAS_RAKE(brush->sculpt_tool) && (brush->rake_factor != 0.0f);
}
-/* Factor of brush to have rake point following behind
- * (could be configurable but this is reasonable default). */
-#define SCULPT_RAKE_BRUSH_FACTOR 0.25f
-
-struct SculptRakeData {
- float follow_dist;
- float follow_co[3];
-};
-
typedef enum StrokeFlags {
CLIP_X = 1,
CLIP_Y = 2,
CLIP_Z = 4
} StrokeFlags;
-/* Cache stroke properties. Used because
- * RNA property lookup isn't particularly fast.
- *
- * For descriptions of these settings, check the operator properties.
- */
-typedef struct StrokeCache {
- /* Invariants */
- float initial_radius;
- float scale[3];
- int flag;
- float clip_tolerance[3];
- float initial_mouse[2];
-
- /* Variants */
- float radius;
- float radius_squared;
- float true_location[3];
- float location[3];
-
- bool pen_flip;
- bool invert;
- float pressure;
- float mouse[2];
- float bstrength;
- float normal_weight; /* from brush (with optional override) */
-
- /* The rest is temporary storage that isn't saved as a property */
-
- bool first_time; /* Beginning of stroke may do some things special */
-
- /* from ED_view3d_ob_project_mat_get() */
- float projection_mat[4][4];
-
- /* Clean this up! */
- ViewContext *vc;
- Brush *brush;
-
- float special_rotation;
- float grab_delta[3], grab_delta_symmetry[3];
- float old_grab_location[3], orig_grab_location[3];
-
- /* screen-space rotation defined by mouse motion */
- float rake_rotation[4], rake_rotation_symmetry[4];
- bool is_rake_rotation_valid;
- struct SculptRakeData rake_data;
-
- int symmetry; /* Symmetry index between 0 and 7 bit combo 0 is Brush only;
- * 1 is X mirror; 2 is Y mirror; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ */
- int mirror_symmetry_pass; /* the symmetry pass we are currently on between 0 and 7*/
- float true_view_normal[3];
- float view_normal[3];
-
- /* sculpt_normal gets calculated by calc_sculpt_normal(), then the
- * sculpt_normal_symm gets updated quickly with the usual symmetry
- * transforms */
- float sculpt_normal[3];
- float sculpt_normal_symm[3];
-
- /* Used for area texture mode, local_mat gets calculated by
- * calc_brush_local_mat() and used in tex_strength(). */
- float brush_local_mat[4][4];
-
- float plane_offset[3]; /* used to shift the plane around when doing tiled strokes */
- int tile_pass;
-
- float last_center[3];
- int radial_symmetry_pass;
- float symm_rot_mat[4][4];
- float symm_rot_mat_inv[4][4];
- bool original;
- float anchored_location[3];
-
- float vertex_rotation; /* amount to rotate the vertices when using rotate brush */
- Dial *dial;
-
- char saved_active_brush_name[MAX_ID_NAME];
- char saved_mask_brush_tool;
- int saved_smooth_size; /* smooth tool copies the size of the current tool */
- bool alt_smooth;
-
- float plane_trim_squared;
-
- bool supports_gravity;
- float true_gravity_direction[3];
- float gravity_direction[3];
-
- rcti previous_r; /* previous redraw rectangle */
- rcti current_r; /* current redraw rectangle */
-} StrokeCache;
-
/************** Access to original unmodified vertex data *************/
typedef struct {
@@ -477,41 +377,6 @@ static bool sculpt_stroke_is_dynamic_topology(
/*** paint mesh ***/
-/* Single struct used by all BLI_task threaded callbacks, let's avoid adding 10's of those... */
-typedef struct SculptThreadedTaskData {
- Sculpt *sd;
- Object *ob;
- Brush *brush;
- PBVHNode **nodes;
- int totnode;
-
- /* Data specific to some callbacks. */
- /* Note: even if only one or two of those are used at a time, keeping them separated, names help figuring out
- * what it is, and memory overhead is ridiculous anyway... */
- float flippedbstrength;
- float angle;
- float strength;
- bool smooth_mask;
- bool has_bm_orco;
-
- SculptProjectVector *spvc;
- float *offset;
- float *grab_delta;
- float *cono;
- float *area_no;
- float *area_no_sp;
- float *area_co;
- float (*mat)[4];
- float (*vertCos)[3];
-
- /* 0=towards view, 1=flipped */
- float (*area_cos)[3];
- float (*area_nos)[3];
- int *count;
-
- ThreadMutex mutex;
-} SculptThreadedTaskData;
-
static void paint_mesh_restore_co_task_cb(void *userdata, const int n)
{
SculptThreadedTaskData *data = userdata;
@@ -601,7 +466,7 @@ static void sculpt_extend_redraw_rect_previous(Object *ob, rcti *rect)
}
/* Get a screen-space rectangle of the modified area */
-static bool sculpt_get_redraw_rect(ARegion *ar, RegionView3D *rv3d,
+bool sculpt_get_redraw_rect(ARegion *ar, RegionView3D *rv3d,
Object *ob, rcti *rect)
{
PBVH *pbvh = ob->sculpt->pbvh;
@@ -650,17 +515,7 @@ void ED_sculpt_redraw_planes_get(float planes[4][4], ARegion *ar, Object *ob)
/************************ Brush Testing *******************/
-typedef struct SculptBrushTest {
- float radius_squared;
- float location[3];
- float dist;
- int mirror_symmetry_pass;
-
- /* View3d clipping - only set rv3d for clipping */
- RegionView3D *clip_rv3d;
-} SculptBrushTest;
-
-static void sculpt_brush_test_init(SculptSession *ss, SculptBrushTest *test)
+void sculpt_brush_test_init(SculptSession *ss, SculptBrushTest *test)
{
RegionView3D *rv3d = ss->cache->vc->rv3d;
@@ -668,6 +523,10 @@ static void sculpt_brush_test_init(SculptSession *ss, SculptBrushTest *test)
copy_v3_v3(test->location, ss->cache->location);
test->dist = 0.0f; /* just for initialize */
+ /* Only for 2D projection. */
+ zero_v4(test->plane_view);
+ zero_v4(test->plane_tool);
+
test->mirror_symmetry_pass = ss->cache->mirror_symmetry_pass;
if (rv3d->rflag & RV3D_CLIPPING) {
@@ -689,7 +548,7 @@ BLI_INLINE bool sculpt_brush_test_clipping(const SculptBrushTest *test, const fl
return ED_view3d_clipping_test(rv3d, symm_co, true);
}
-static bool sculpt_brush_test(SculptBrushTest *test, const float co[3])
+bool sculpt_brush_test_sphere(SculptBrushTest *test, const float co[3])
{
float distsq = len_squared_v3v3(co, test->location);
@@ -705,7 +564,7 @@ static bool sculpt_brush_test(SculptBrushTest *test, const float co[3])
}
}
-static bool sculpt_brush_test_sq(SculptBrushTest *test, const float co[3])
+bool sculpt_brush_test_sphere_sq(SculptBrushTest *test, const float co[3])
{
float distsq = len_squared_v3v3(co, test->location);
@@ -721,7 +580,7 @@ static bool sculpt_brush_test_sq(SculptBrushTest *test, const float co[3])
}
}
-static bool sculpt_brush_test_fast(const SculptBrushTest *test, const float co[3])
+bool sculpt_brush_test_sphere_fast(const SculptBrushTest *test, const float co[3])
{
if (sculpt_brush_test_clipping(test, co)) {
return 0;
@@ -729,7 +588,25 @@ static bool sculpt_brush_test_fast(const SculptBrushTest *test, const float co[3
return len_squared_v3v3(co, test->location) <= test->radius_squared;
}
-static bool sculpt_brush_test_cube(SculptBrushTest *test, const float co[3], float local[4][4])
+bool sculpt_brush_test_circle_sq(SculptBrushTest *test, const float co[3])
+{
+ float co_proj[3];
+ closest_to_plane_normalized_v3(co_proj, test->plane_view, co);
+ float distsq = len_squared_v3v3(co_proj, test->location);
+
+ if (distsq <= test->radius_squared) {
+ if (sculpt_brush_test_clipping(test, co)) {
+ return 0;
+ }
+ test->dist = distsq;
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+
+bool sculpt_brush_test_cube(SculptBrushTest *test, const float co[3], float local[4][4])
{
float side = M_SQRT1_2;
float local_co[3];
@@ -758,7 +635,36 @@ static bool sculpt_brush_test_cube(SculptBrushTest *test, const float co[3], flo
}
}
-static float frontface(Brush *br, const float sculpt_normal[3],
+SculptBrushTestFn sculpt_brush_test_init_with_falloff_shape(
+ SculptSession *ss, SculptBrushTest *test, char falloff_shape)
+{
+ sculpt_brush_test_init(ss, test);
+ SculptBrushTestFn sculpt_brush_test_sq_fn;
+ if (falloff_shape == PAINT_FALLOFF_SHAPE_SPHERE) {
+ sculpt_brush_test_sq_fn = sculpt_brush_test_sphere_sq;
+ }
+ else {
+ /* PAINT_FALLOFF_SHAPE_TUBE */
+ plane_from_point_normal_v3(test->plane_view, test->location, ss->cache->view_normal);
+ sculpt_brush_test_sq_fn = sculpt_brush_test_circle_sq;
+ }
+ return sculpt_brush_test_sq_fn;
+}
+
+const float *sculpt_brush_frontface_normal_from_falloff_shape(
+ SculptSession *ss, char falloff_shape)
+{
+ if (falloff_shape == PAINT_FALLOFF_SHAPE_SPHERE) {
+ return ss->cache->sculpt_normal_symm;
+ }
+ else {
+ /* PAINT_FALLOFF_SHAPE_TUBE */
+ return ss->cache->view_normal;
+ }
+}
+
+
+static float frontface(const Brush *br, const float sculpt_normal[3],
const short no[3], const float fno[3])
{
if (br->flag & BRUSH_FRONTFACE) {
@@ -784,7 +690,7 @@ static float frontface(Brush *br, const float sculpt_normal[3],
static bool sculpt_brush_test_cyl(SculptBrushTest *test, float co[3], float location[3], const float area_no[3])
{
- if (sculpt_brush_test_fast(test, co)) {
+ if (sculpt_brush_test_sphere_fast(test, co)) {
float t1[3], t2[3], t3[3], dist;
sub_v3_v3v3(t1, location, co);
@@ -896,18 +802,22 @@ static void calc_area_normal_and_center_task_cb(void *userdata, const int n)
float (*area_cos)[3] = data->area_cos;
PBVHVertexIter vd;
- SculptBrushTest test;
- SculptUndoNode *unode;
+ SculptUndoNode *unode = NULL;
float private_co[2][3] = {{0.0f}};
float private_no[2][3] = {{0.0f}};
int private_count[2] = {0};
- bool use_original;
+ bool use_original = false;
- unode = sculpt_undo_push_node(data->ob, data->nodes[n], SCULPT_UNDO_COORDS);
- sculpt_brush_test_init(ss, &test);
+ if (ss->cache->original) {
+ unode = sculpt_undo_push_node(data->ob, data->nodes[n], SCULPT_UNDO_COORDS);
+ use_original = (unode->co || unode->bm_entry);
+ }
+
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn =
+ sculpt_brush_test_init_with_falloff_shape(ss, &test, data->brush->falloff_shape);
- use_original = (ss->cache->original && (unode->co || unode->bm_entry));
/* when the mesh is edited we can't rely on original coords
* (original mesh may not even have verts in brush radius) */
@@ -929,7 +839,7 @@ static void calc_area_normal_and_center_task_cb(void *userdata, const int n)
closest_on_tri_to_point_v3(co, test.location, UNPACK3(co_tri));
- if (sculpt_brush_test_fast(&test, co)) {
+ if (sculpt_brush_test_sq_fn(&test, co)) {
float no[3];
int flip_index;
@@ -963,7 +873,7 @@ static void calc_area_normal_and_center_task_cb(void *userdata, const int n)
co = vd.co;
}
- if (sculpt_brush_test_fast(&test, co)) {
+ if (sculpt_brush_test_sq_fn(&test, co)) {
float no_buf[3];
const float *no;
int flip_index;
@@ -1029,8 +939,9 @@ static void calc_area_center(
int count[2] = {0};
+ /* Intentionally set 'sd' to NULL since we share logic with vertex paint. */
SculptThreadedTaskData data = {
- .sd = sd, .ob = ob, .nodes = nodes, .totnode = totnode,
+ .sd = NULL, .ob = ob, .nodes = nodes, .totnode = totnode,
.has_bm_orco = has_bm_orco, .area_cos = area_cos, .area_nos = NULL, .count = count,
};
BLI_mutex_init(&data.mutex);
@@ -1053,42 +964,53 @@ static void calc_area_center(
}
}
-
static void calc_area_normal(
Sculpt *sd, Object *ob,
PBVHNode **nodes, int totnode,
float r_area_no[3])
{
const Brush *brush = BKE_paint_brush(&sd->paint);
+ bool use_threading = (sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT;
+ sculpt_pbvh_calc_area_normal(brush, ob, nodes, totnode, use_threading, r_area_no);
+}
+
+/* expose 'calc_area_normal' externally. */
+void sculpt_pbvh_calc_area_normal(
+ const Brush *brush, Object *ob,
+ PBVHNode **nodes, int totnode,
+ bool use_threading,
+ float r_area_no[3])
+{
SculptSession *ss = ob->sculpt;
const bool has_bm_orco = ss->bm && sculpt_stroke_is_dynamic_topology(ss, brush);
- int n;
/* 0=towards view, 1=flipped */
float area_nos[2][3] = {{0.0f}};
int count[2] = {0};
+ /* Intentionally set 'sd' to NULL since this is used for vertex paint too. */
SculptThreadedTaskData data = {
- .sd = sd, .ob = ob, .nodes = nodes, .totnode = totnode,
+ .sd = NULL, .ob = ob, .brush = brush, .nodes = nodes, .totnode = totnode,
.has_bm_orco = has_bm_orco, .area_cos = NULL, .area_nos = area_nos, .count = count,
};
BLI_mutex_init(&data.mutex);
BLI_task_parallel_range(
0, totnode, &data, calc_area_normal_and_center_task_cb,
- ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT));
+ use_threading);
BLI_mutex_end(&data.mutex);
/* for area normal */
- for (n = 0; n < ARRAY_SIZE(area_nos); n++) {
- if (normalize_v3_v3(r_area_no, area_nos[n]) != 0.0f) {
+ for (int i = 0; i < ARRAY_SIZE(area_nos); i++) {
+ if (normalize_v3_v3(r_area_no, area_nos[i]) != 0.0f) {
break;
}
}
}
+
/* this calculates flatten center and area normal together,
* amortizing the memory bandwidth and loop overhead to calculate both at the same time */
static void calc_area_normal_and_center(
@@ -1107,8 +1029,9 @@ static void calc_area_normal_and_center(
int count[2] = {0};
+ /* Intentionally set 'sd' to NULL since this is used for vertex paint too. */
SculptThreadedTaskData data = {
- .sd = sd, .ob = ob, .nodes = nodes, .totnode = totnode,
+ .sd = NULL, .ob = ob, .brush = brush, .nodes = nodes, .totnode = totnode,
.has_bm_orco = has_bm_orco, .area_cos = area_cos, .area_nos = area_nos, .count = count,
};
BLI_mutex_init(&data.mutex);
@@ -1237,17 +1160,17 @@ static float brush_strength(
}
/* Return a multiplier for brush strength on a particular vertex. */
-static float tex_strength(SculptSession *ss, Brush *br,
- const float brush_point[3],
- const float len,
- const short vno[3],
- const float fno[3],
- const float mask,
- const int thread_id)
+float tex_strength(SculptSession *ss, const Brush *br,
+ const float brush_point[3],
+ const float len,
+ const short vno[3],
+ const float fno[3],
+ const float mask,
+ const int thread_id)
{
StrokeCache *cache = ss->cache;
const Scene *scene = cache->vc->scene;
- MTex *mtex = &br->mtex;
+ const MTex *mtex = &br->mtex;
float avg = 1;
float rgba[4];
float point[3];
@@ -1316,15 +1239,8 @@ static float tex_strength(SculptSession *ss, Brush *br,
return avg;
}
-typedef struct {
- Sculpt *sd;
- SculptSession *ss;
- float radius_squared;
- bool original;
-} SculptSearchSphereData;
-
/* Test AABB against sphere */
-static bool sculpt_search_sphere_cb(PBVHNode *node, void *data_v)
+bool sculpt_search_sphere_cb(PBVHNode *node, void *data_v)
{
SculptSearchSphereData *data = data_v;
float *center = data->ss->cache->location, nearest[3];
@@ -1350,6 +1266,24 @@ static bool sculpt_search_sphere_cb(PBVHNode *node, void *data_v)
return len_squared_v3(t) < data->radius_squared;
}
+/* 2D projection (distance to line). */
+bool sculpt_search_circle_cb(PBVHNode *node, void *data_v)
+{
+ SculptSearchCircleData *data = data_v;
+ float bb_min[3], bb_max[3];
+
+ if (data->original)
+ BKE_pbvh_node_get_original_BB(node, bb_min, bb_max);
+ else
+ BKE_pbvh_node_get_BB(node, bb_min, bb_min);
+
+ float dummy_co[3], dummy_depth;
+ const float dist_sq = dist_squared_ray_to_aabb_v3(
+ data->dist_ray_to_aabb_precalc, bb_min, bb_max, dummy_co, &dummy_depth);
+
+ return dist_sq < data->radius_squared || 1;
+}
+
/* Handles clipping against a mirror modifier and SCULPT_LOCK axis flags */
static void sculpt_clip(Sculpt *sd, SculptSession *ss, float co[3], const float val[3])
{
@@ -1366,6 +1300,37 @@ static void sculpt_clip(Sculpt *sd, SculptSession *ss, float co[3], const float
}
}
+static PBVHNode **sculpt_pbvh_gather_generic(
+ Object *ob, Sculpt *sd, const Brush *brush, bool use_original, float radius_scale, int *r_totnode)
+{
+ SculptSession *ss = ob->sculpt;
+ PBVHNode **nodes = NULL;
+
+ /* Build a list of all nodes that are potentially within the brush's area of influence */
+ if (brush->falloff_shape == PAINT_FALLOFF_SHAPE_SPHERE) {
+ SculptSearchSphereData data = {
+ .ss = ss,
+ .sd = sd,
+ .radius_squared = SQUARE(ss->cache->radius * radius_scale),
+ .original = use_original,
+ };
+ BKE_pbvh_search_gather(ss->pbvh, sculpt_search_sphere_cb, &data, &nodes, r_totnode);
+ }
+ else {
+ struct DistRayAABB_Precalc dist_ray_to_aabb_precalc;
+ dist_squared_ray_to_aabb_v3_precalc(&dist_ray_to_aabb_precalc, ss->cache->location, ss->cache->view_normal);
+ SculptSearchCircleData data = {
+ .ss = ss,
+ .sd = sd,
+ .radius_squared = SQUARE(ss->cache->radius * radius_scale),
+ .original = use_original,
+ .dist_ray_to_aabb_precalc = &dist_ray_to_aabb_precalc,
+ };
+ BKE_pbvh_search_gather(ss->pbvh, sculpt_search_circle_cb, &data, &nodes, r_totnode);
+ }
+ return nodes;
+}
+
/* Calculate primary direction of movement for many brushes */
static void calc_sculpt_normal(
Sculpt *sd, Object *ob,
@@ -1412,6 +1377,10 @@ static void update_sculpt_normal(Sculpt *sd, Object *ob,
(cache->first_time || !(brush->flag & BRUSH_ORIGINAL_NORMAL)))
{
calc_sculpt_normal(sd, ob, nodes, totnode, cache->sculpt_normal);
+ if (brush->falloff_shape == PAINT_FALLOFF_SHAPE_TUBE) {
+ project_plane_v3_v3v3(cache->sculpt_normal, cache->sculpt_normal, cache->view_normal);
+ normalize_v3(cache->sculpt_normal);
+ }
copy_v3_v3(cache->sculpt_normal_symm, cache->sculpt_normal);
}
else {
@@ -1632,30 +1601,54 @@ typedef struct SculptDoBrushSmoothGridDataChunk {
size_t tmpgrid_size;
} SculptDoBrushSmoothGridDataChunk;
+typedef struct {
+ SculptSession *ss;
+ const float *ray_start, *ray_normal;
+ bool hit;
+ float depth;
+ bool original;
+} SculptRaycastData;
+
+typedef struct {
+ const float *ray_start, *ray_normal;
+ bool hit;
+ float depth;
+ float detail;
+} SculptDetailRaycastData;
+
+typedef struct {
+ SculptSession *ss;
+ const float *ray_start, *ray_normal;
+ bool hit;
+ float depth;
+ float dist_sq_to_ray;
+ bool original;
+} SculptFindNearestToRayData;
+
static void do_smooth_brush_mesh_task_cb_ex(
void *userdata, void *UNUSED(userdata_chunk), const int n, const int thread_id)
{
SculptThreadedTaskData *data = userdata;
SculptSession *ss = data->ob->sculpt;
Sculpt *sd = data->sd;
- Brush *brush = data->brush;
+ const Brush *brush = data->brush;
const bool smooth_mask = data->smooth_mask;
float bstrength = data->strength;
PBVHVertexIter vd;
- SculptBrushTest test;
CLAMP(bstrength, 0.0f, 1.0f);
- sculpt_brush_test_init(ss, &test);
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn =
+ sculpt_brush_test_init_with_falloff_shape(ss, &test, data->brush->falloff_shape);
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
{
- if (sculpt_brush_test(&test, vd.co)) {
+ if (sculpt_brush_test_sq_fn(&test, vd.co)) {
const float fade = bstrength * tex_strength(
- ss, brush, vd.co, test.dist, vd.no, vd.fno,
- smooth_mask ? 0.0f : (vd.mask ? *vd.mask : 0.0f),
- thread_id);
+ ss, brush, vd.co, sqrtf(test.dist),
+ vd.no, vd.fno, smooth_mask ? 0.0f : (vd.mask ? *vd.mask : 0.0f), thread_id);
if (smooth_mask) {
float val = neighbor_average_mask(ss, vd.vert_indices[vd.i]) - *vd.mask;
val *= fade * bstrength;
@@ -1686,23 +1679,24 @@ static void do_smooth_brush_bmesh_task_cb_ex(
SculptThreadedTaskData *data = userdata;
SculptSession *ss = data->ob->sculpt;
Sculpt *sd = data->sd;
- Brush *brush = data->brush;
+ const Brush *brush = data->brush;
const bool smooth_mask = data->smooth_mask;
float bstrength = data->strength;
PBVHVertexIter vd;
- SculptBrushTest test;
CLAMP(bstrength, 0.0f, 1.0f);
- sculpt_brush_test_init(ss, &test);
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn =
+ sculpt_brush_test_init_with_falloff_shape(ss, &test, data->brush->falloff_shape);
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
{
- if (sculpt_brush_test(&test, vd.co)) {
+ if (sculpt_brush_test_sq_fn(&test, vd.co)) {
const float fade = bstrength * tex_strength(
- ss, brush, vd.co, test.dist, vd.no, vd.fno, smooth_mask ? 0.0f : *vd.mask,
- thread_id);
+ ss, brush, vd.co, sqrtf(test.dist),
+ vd.no, vd.fno, smooth_mask ? 0.0f : *vd.mask, thread_id);
if (smooth_mask) {
float val = bmesh_neighbor_average_mask(vd.bm_vert, vd.cd_vert_mask_offset) - *vd.mask;
val *= fade * bstrength;
@@ -1734,11 +1728,10 @@ static void do_smooth_brush_multires_task_cb_ex(
SculptDoBrushSmoothGridDataChunk *data_chunk = userdata_chunk;
SculptSession *ss = data->ob->sculpt;
Sculpt *sd = data->sd;
- Brush *brush = data->brush;
+ const Brush *brush = data->brush;
const bool smooth_mask = data->smooth_mask;
float bstrength = data->strength;
- SculptBrushTest test;
CCGElem **griddata, *gddata;
CCGKey key;
@@ -1751,7 +1744,9 @@ static void do_smooth_brush_multires_task_cb_ex(
int *grid_indices, totgrid, gridsize;
int i, x, y;
- sculpt_brush_test_init(ss, &test);
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn =
+ sculpt_brush_test_init_with_falloff_shape(ss, &test, data->brush->falloff_shape);
CLAMP(bstrength, 0.0f, 1.0f);
@@ -1838,10 +1833,11 @@ static void do_smooth_brush_multires_task_cb_ex(
fno = CCG_elem_offset_no(&key, gddata, index);
mask = CCG_elem_offset_mask(&key, gddata, index);
- if (sculpt_brush_test(&test, co)) {
+ if (sculpt_brush_test_sq_fn(&test, co)) {
const float strength_mask = (smooth_mask ? 0.0f : *mask);
const float fade = bstrength * tex_strength(
- ss, brush, co, test.dist, NULL, fno, strength_mask, thread_id);
+ ss, brush, co, sqrtf(test.dist),
+ NULL, fno, strength_mask, thread_id);
float f = 1.0f / 16.0f;
if (x == 0 || x == gridsize - 1)
@@ -1948,18 +1944,21 @@ static void do_mask_brush_draw_task_cb_ex(
{
SculptThreadedTaskData *data = userdata;
SculptSession *ss = data->ob->sculpt;
- Brush *brush = data->brush;
+ const Brush *brush = data->brush;
const float bstrength = ss->cache->bstrength;
PBVHVertexIter vd;
- SculptBrushTest test;
- sculpt_brush_test_init(ss, &test);
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn =
+ sculpt_brush_test_init_with_falloff_shape(ss, &test, data->brush->falloff_shape);
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
{
- if (sculpt_brush_test(&test, vd.co)) {
- const float fade = tex_strength(ss, brush, vd.co, test.dist, vd.no, vd.fno, 0.0f, thread_id);
+ if (sculpt_brush_test_sq_fn(&test, vd.co)) {
+ const float fade = tex_strength(
+ ss, brush, vd.co, sqrtf(test.dist),
+ vd.no, vd.fno, 0.0f, thread_id);
(*vd.mask) += fade * bstrength;
CLAMP(*vd.mask, 0, 1);
@@ -2005,23 +2004,25 @@ static void do_draw_brush_task_cb_ex(
{
SculptThreadedTaskData *data = userdata;
SculptSession *ss = data->ob->sculpt;
- Brush *brush = data->brush;
+ const Brush *brush = data->brush;
const float *offset = data->offset;
PBVHVertexIter vd;
- SculptBrushTest test;
float (*proxy)[3];
proxy = BKE_pbvh_node_add_proxy(ss->pbvh, data->nodes[n])->co;
- sculpt_brush_test_init(ss, &test);
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn =
+ sculpt_brush_test_init_with_falloff_shape(ss, &test, data->brush->falloff_shape);
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
{
- if (sculpt_brush_test(&test, vd.co)) {
+ if (sculpt_brush_test_sq_fn(&test, vd.co)) {
/* offset vertex */
const float fade = tex_strength(
- ss, brush, vd.co, test.dist, vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
+ ss, brush, vd.co, sqrtf(test.dist),
+ vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
mul_v3_v3fl(proxy[vd.i], offset, fade);
@@ -2059,35 +2060,44 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT), false);
}
+/**
+ * Used for 'SCULPT_TOOL_CREASE' and 'SCULPT_TOOL_BLOB'
+ */
static void do_crease_brush_task_cb_ex(
void *userdata, void *UNUSED(userdata_chunk), const int n, const int thread_id)
{
SculptThreadedTaskData *data = userdata;
SculptSession *ss = data->ob->sculpt;
- Brush *brush = data->brush;
+ const Brush *brush = data->brush;
SculptProjectVector *spvc = data->spvc;
const float flippedbstrength = data->flippedbstrength;
const float *offset = data->offset;
PBVHVertexIter vd;
- SculptBrushTest test;
float (*proxy)[3];
proxy = BKE_pbvh_node_add_proxy(ss->pbvh, data->nodes[n])->co;
- sculpt_brush_test_init(ss, &test);
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn =
+ sculpt_brush_test_init_with_falloff_shape(ss, &test, data->brush->falloff_shape);
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
{
- if (sculpt_brush_test(&test, vd.co)) {
+ if (sculpt_brush_test_sq_fn(&test, vd.co)) {
/* offset vertex */
const float fade = tex_strength(
- ss, brush, vd.co, test.dist, vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
+ ss, brush, vd.co, sqrtf(test.dist),
+ vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
float val1[3];
float val2[3];
/* first we pinch */
sub_v3_v3v3(val1, test.location, vd.co);
+ if (brush->falloff_shape == PAINT_FALLOFF_SHAPE_TUBE) {
+ project_plane_v3_v3v3(val1, val1, ss->cache->view_normal);
+ }
+
mul_v3_fl(val1, fade * flippedbstrength);
sculpt_project_v3(spvc, val1, val1);
@@ -2152,25 +2162,30 @@ static void do_pinch_brush_task_cb_ex(
{
SculptThreadedTaskData *data = userdata;
SculptSession *ss = data->ob->sculpt;
- Brush *brush = data->brush;
+ const Brush *brush = data->brush;
PBVHVertexIter vd;
- SculptBrushTest test;
float (*proxy)[3];
const float bstrength = ss->cache->bstrength;
proxy = BKE_pbvh_node_add_proxy(ss->pbvh, data->nodes[n])->co;
- sculpt_brush_test_init(ss, &test);
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn =
+ sculpt_brush_test_init_with_falloff_shape(ss, &test, data->brush->falloff_shape);
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
{
- if (sculpt_brush_test(&test, vd.co)) {
+ if (sculpt_brush_test_sq_fn(&test, vd.co)) {
const float fade = bstrength * tex_strength(
- ss, brush, vd.co, test.dist, vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
+ ss, brush, vd.co, sqrtf(test.dist),
+ vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
float val[3];
sub_v3_v3v3(val, test.location, vd.co);
+ if (brush->falloff_shape == PAINT_FALLOFF_SHAPE_TUBE) {
+ project_plane_v3_v3v3(val, val, ss->cache->view_normal);
+ }
mul_v3_v3fl(proxy[vd.i], val, fade);
if (vd.mvert)
@@ -2198,11 +2213,10 @@ static void do_grab_brush_task_cb_ex(
{
SculptThreadedTaskData *data = userdata;
SculptSession *ss = data->ob->sculpt;
- Brush *brush = data->brush;
+ const Brush *brush = data->brush;
const float *grab_delta = data->grab_delta;
PBVHVertexIter vd;
- SculptBrushTest test;
SculptOrigVertData orig_data;
float (*proxy)[3];
const float bstrength = ss->cache->bstrength;
@@ -2211,16 +2225,18 @@ static void do_grab_brush_task_cb_ex(
proxy = BKE_pbvh_node_add_proxy(ss->pbvh, data->nodes[n])->co;
- sculpt_brush_test_init(ss, &test);
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn =
+ sculpt_brush_test_init_with_falloff_shape(ss, &test, data->brush->falloff_shape);
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
{
sculpt_orig_vert_data_update(&orig_data, &vd);
- if (sculpt_brush_test(&test, orig_data.co)) {
+ if (sculpt_brush_test_sq_fn(&test, orig_data.co)) {
const float fade = bstrength * tex_strength(
- ss, brush, orig_data.co, test.dist, orig_data.no, NULL, vd.mask ? *vd.mask : 0.0f,
- thread_id);
+ ss, brush, orig_data.co, sqrtf(test.dist),
+ orig_data.no, NULL, vd.mask ? *vd.mask : 0.0f, thread_id);
mul_v3_v3fl(proxy[vd.i], grab_delta, fade);
@@ -2258,23 +2274,25 @@ static void do_nudge_brush_task_cb_ex(
{
SculptThreadedTaskData *data = userdata;
SculptSession *ss = data->ob->sculpt;
- Brush *brush = data->brush;
+ const Brush *brush = data->brush;
const float *cono = data->cono;
PBVHVertexIter vd;
- SculptBrushTest test;
float (*proxy)[3];
const float bstrength = ss->cache->bstrength;
proxy = BKE_pbvh_node_add_proxy(ss->pbvh, data->nodes[n])->co;
- sculpt_brush_test_init(ss, &test);
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn =
+ sculpt_brush_test_init_with_falloff_shape(ss, &test, data->brush->falloff_shape);
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
{
- if (sculpt_brush_test(&test, vd.co)) {
+ if (sculpt_brush_test_sq_fn(&test, vd.co)) {
const float fade = bstrength * tex_strength(
- ss, brush, vd.co, test.dist, vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
+ ss, brush, vd.co, sqrtf(test.dist),
+ vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
mul_v3_v3fl(proxy[vd.i], cono, fade);
@@ -2312,12 +2330,11 @@ static void do_snake_hook_brush_task_cb_ex(
{
SculptThreadedTaskData *data = userdata;
SculptSession *ss = data->ob->sculpt;
- Brush *brush = data->brush;
+ const Brush *brush = data->brush;
SculptProjectVector *spvc = data->spvc;
const float *grab_delta = data->grab_delta;
PBVHVertexIter vd;
- SculptBrushTest test;
float (*proxy)[3];
const float bstrength = ss->cache->bstrength;
const bool do_rake_rotation = ss->cache->is_rake_rotation_valid;
@@ -2327,13 +2344,16 @@ static void do_snake_hook_brush_task_cb_ex(
proxy = BKE_pbvh_node_add_proxy(ss->pbvh, data->nodes[n])->co;
- sculpt_brush_test_init(ss, &test);
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn =
+ sculpt_brush_test_init_with_falloff_shape(ss, &test, data->brush->falloff_shape);
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
{
- if (sculpt_brush_test(&test, vd.co)) {
+ if (sculpt_brush_test_sq_fn(&test, vd.co)) {
const float fade = bstrength * tex_strength(
- ss, brush, vd.co, test.dist, vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
+ ss, brush, vd.co, sqrtf(test.dist),
+ vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
mul_v3_v3fl(proxy[vd.i], grab_delta, fade);
@@ -2342,6 +2362,9 @@ static void do_snake_hook_brush_task_cb_ex(
float delta_pinch_init[3], delta_pinch[3];
sub_v3_v3v3(delta_pinch, vd.co, test.location);
+ if (brush->falloff_shape == PAINT_FALLOFF_SHAPE_TUBE) {
+ project_plane_v3_v3v3(delta_pinch, delta_pinch, ss->cache->true_view_normal);
+ }
/* important to calculate based on the grabbed location (intentionally ignore fade here). */
add_v3_v3(delta_pinch, grab_delta);
@@ -2413,11 +2436,10 @@ static void do_thumb_brush_task_cb_ex(
{
SculptThreadedTaskData *data = userdata;
SculptSession *ss = data->ob->sculpt;
- Brush *brush = data->brush;
+ const Brush *brush = data->brush;
const float *cono = data->cono;
PBVHVertexIter vd;
- SculptBrushTest test;
SculptOrigVertData orig_data;
float (*proxy)[3];
const float bstrength = ss->cache->bstrength;
@@ -2426,16 +2448,18 @@ static void do_thumb_brush_task_cb_ex(
proxy = BKE_pbvh_node_add_proxy(ss->pbvh, data->nodes[n])->co;
- sculpt_brush_test_init(ss, &test);
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn =
+ sculpt_brush_test_init_with_falloff_shape(ss, &test, data->brush->falloff_shape);
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
{
sculpt_orig_vert_data_update(&orig_data, &vd);
- if (sculpt_brush_test(&test, orig_data.co)) {
+ if (sculpt_brush_test_sq_fn(&test, orig_data.co)) {
const float fade = bstrength * tex_strength(
- ss, brush, orig_data.co, test.dist, orig_data.no, NULL, vd.mask ? *vd.mask : 0.0f,
- thread_id);
+ ss, brush, orig_data.co, sqrtf(test.dist),
+ orig_data.no, NULL, vd.mask ? *vd.mask : 0.0f, thread_id);
mul_v3_v3fl(proxy[vd.i], cono, fade);
@@ -2473,11 +2497,10 @@ static void do_rotate_brush_task_cb_ex(
{
SculptThreadedTaskData *data = userdata;
SculptSession *ss = data->ob->sculpt;
- Brush *brush = data->brush;
+ const Brush *brush = data->brush;
const float angle = data->angle;
PBVHVertexIter vd;
- SculptBrushTest test;
SculptOrigVertData orig_data;
float (*proxy)[3];
const float bstrength = ss->cache->bstrength;
@@ -2486,17 +2509,19 @@ static void do_rotate_brush_task_cb_ex(
proxy = BKE_pbvh_node_add_proxy(ss->pbvh, data->nodes[n])->co;
- sculpt_brush_test_init(ss, &test);
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn =
+ sculpt_brush_test_init_with_falloff_shape(ss, &test, data->brush->falloff_shape);
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
{
sculpt_orig_vert_data_update(&orig_data, &vd);
- if (sculpt_brush_test(&test, orig_data.co)) {
+ if (sculpt_brush_test_sq_fn(&test, orig_data.co)) {
float vec[3], rot[3][3];
const float fade = bstrength * tex_strength(
- ss, brush, orig_data.co, test.dist, orig_data.no, NULL, vd.mask ? *vd.mask : 0.0f,
- thread_id);
+ ss, brush, orig_data.co, sqrtf(test.dist),
+ orig_data.no, NULL, vd.mask ? *vd.mask : 0.0f, thread_id);
sub_v3_v3v3(vec, orig_data.co, ss->cache->location);
axis_angle_normalized_to_mat3(rot, ss->cache->sculpt_normal_symm, angle * fade);
@@ -2535,11 +2560,10 @@ static void do_layer_brush_task_cb_ex(
SculptThreadedTaskData *data = userdata;
SculptSession *ss = data->ob->sculpt;
Sculpt *sd = data->sd;
- Brush *brush = data->brush;
+ const Brush *brush = data->brush;
const float *offset = data->offset;
PBVHVertexIter vd;
- SculptBrushTest test;
SculptOrigVertData orig_data;
float *layer_disp;
const float bstrength = ss->cache->bstrength;
@@ -2554,15 +2578,18 @@ static void do_layer_brush_task_cb_ex(
layer_disp = BKE_pbvh_node_layer_disp_get(ss->pbvh, data->nodes[n]);
BLI_mutex_unlock(&data->mutex);
- sculpt_brush_test_init(ss, &test);
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn =
+ sculpt_brush_test_init_with_falloff_shape(ss, &test, data->brush->falloff_shape);
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
{
sculpt_orig_vert_data_update(&orig_data, &vd);
- if (sculpt_brush_test(&test, orig_data.co)) {
+ if (sculpt_brush_test_sq_fn(&test, orig_data.co)) {
const float fade = bstrength * tex_strength(
- ss, brush, vd.co, test.dist, vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
+ ss, brush, vd.co, sqrtf(test.dist),
+ vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
float *disp = &layer_disp[vd.i];
float val[3];
@@ -2619,22 +2646,24 @@ static void do_inflate_brush_task_cb_ex(
{
SculptThreadedTaskData *data = userdata;
SculptSession *ss = data->ob->sculpt;
- Brush *brush = data->brush;
+ const Brush *brush = data->brush;
PBVHVertexIter vd;
- SculptBrushTest test;
float (*proxy)[3];
const float bstrength = ss->cache->bstrength;
proxy = BKE_pbvh_node_add_proxy(ss->pbvh, data->nodes[n])->co;
- sculpt_brush_test_init(ss, &test);
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn =
+ sculpt_brush_test_init_with_falloff_shape(ss, &test, data->brush->falloff_shape);
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
{
- if (sculpt_brush_test(&test, vd.co)) {
+ if (sculpt_brush_test_sq_fn(&test, vd.co)) {
const float fade = bstrength * tex_strength(
- ss, brush, vd.co, test.dist, vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
+ ss, brush, vd.co, sqrtf(test.dist),
+ vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
float val[3];
if (vd.fno)
@@ -2697,6 +2726,10 @@ static void calc_sculpt_plane(
case SCULPT_DISP_DIR_AREA:
calc_area_normal_and_center(sd, ob, nodes, totnode, r_area_no, r_area_co);
+ if (brush->falloff_shape == PAINT_FALLOFF_SHAPE_TUBE) {
+ project_plane_v3_v3v3(r_area_no, r_area_no, ss->cache->view_normal);
+ normalize_v3(r_area_no);
+ }
break;
default:
@@ -2738,16 +2771,6 @@ static void calc_sculpt_plane(
}
}
-/* Projects a point onto a plane along the plane's normal */
-static void point_plane_project(
- float intr[3],
- const float co[3], const float plane_normal[3], const float plane_center[3])
-{
- sub_v3_v3v3(intr, co, plane_center);
- mul_v3_v3fl(intr, plane_normal, dot_v3v3(plane_normal, intr));
- sub_v3_v3v3(intr, co, intr);
-}
-
static int plane_trim(const StrokeCache *cache, const Brush *brush, const float val[3])
{
return (!(brush->flag & BRUSH_PLANE_TRIM) ||
@@ -2755,26 +2778,18 @@ static int plane_trim(const StrokeCache *cache, const Brush *brush, const float
}
static bool plane_point_side_flip(
- const float co[3], const float plane_normal[3], const float plane_center[3],
+ const float co[3], const float plane[4],
const bool flip)
{
- float delta[3];
- float d;
-
- sub_v3_v3v3(delta, co, plane_center);
- d = dot_v3v3(plane_normal, delta);
-
+ float d = plane_point_side_v3(plane, co);
if (flip) d = -d;
-
return d <= 0.0f;
}
-static int plane_point_side(const float co[3], const float plane_normal[3], const float plane_center[3])
+static int plane_point_side(const float co[3], const float plane[4])
{
- float delta[3];
-
- sub_v3_v3v3(delta, co, plane_center);
- return dot_v3v3(plane_normal, delta) <= 0.0f;
+ float d = plane_point_side_v3(plane, co);
+ return d <= 0.0f;
}
static float get_offset(Sculpt *sd, SculptSession *ss)
@@ -2795,33 +2810,36 @@ static void do_flatten_brush_task_cb_ex(
{
SculptThreadedTaskData *data = userdata;
SculptSession *ss = data->ob->sculpt;
- Brush *brush = data->brush;
+ const Brush *brush = data->brush;
const float *area_no = data->area_no;
const float *area_co = data->area_co;
PBVHVertexIter vd;
- SculptBrushTest test;
float (*proxy)[3];
const float bstrength = ss->cache->bstrength;
proxy = BKE_pbvh_node_add_proxy(ss->pbvh, data->nodes[n])->co;
- sculpt_brush_test_init(ss, &test);
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn =
+ sculpt_brush_test_init_with_falloff_shape(ss, &test, data->brush->falloff_shape);
+
+ plane_from_point_normal_v3(test.plane_tool, area_co, area_no);
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
{
- if (sculpt_brush_test_sq(&test, vd.co)) {
+ if (sculpt_brush_test_sq_fn(&test, vd.co)) {
float intr[3];
float val[3];
- point_plane_project(intr, vd.co, area_no, area_co);
+ closest_to_plane_normalized_v3(intr, test.plane_tool, vd.co);
sub_v3_v3v3(val, intr, vd.co);
if (plane_trim(ss->cache, brush, val)) {
const float fade = bstrength * tex_strength(
- ss, brush, vd.co, sqrtf(test.dist), vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f,
- thread_id);
+ ss, brush, vd.co, sqrtf(test.dist),
+ vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
mul_v3_v3fl(proxy[vd.i], val, fade);
@@ -2870,28 +2888,31 @@ static void do_clay_brush_task_cb_ex(
{
SculptThreadedTaskData *data = userdata;
SculptSession *ss = data->ob->sculpt;
- Brush *brush = data->brush;
+ const Brush *brush = data->brush;
const float *area_no = data->area_no;
const float *area_co = data->area_co;
PBVHVertexIter vd;
- SculptBrushTest test;
float (*proxy)[3];
const bool flip = (ss->cache->bstrength < 0);
const float bstrength = flip ? -ss->cache->bstrength : ss->cache->bstrength;
proxy = BKE_pbvh_node_add_proxy(ss->pbvh, data->nodes[n])->co;
- sculpt_brush_test_init(ss, &test);
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn =
+ sculpt_brush_test_init_with_falloff_shape(ss, &test, data->brush->falloff_shape);
+
+ plane_from_point_normal_v3(test.plane_tool, area_co, area_no);
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
{
- if (sculpt_brush_test_sq(&test, vd.co)) {
- if (plane_point_side_flip(vd.co, area_no, area_co, flip)) {
+ if (sculpt_brush_test_sq_fn(&test, vd.co)) {
+ if (plane_point_side_flip(vd.co, test.plane_tool, flip)) {
float intr[3];
float val[3];
- point_plane_project(intr, vd.co, area_no, area_co);
+ closest_to_plane_normalized_v3(intr, test.plane_tool, vd.co);
sub_v3_v3v3(val, intr, vd.co);
@@ -2899,8 +2920,8 @@ static void do_clay_brush_task_cb_ex(
/* note, the normal from the vertices is ignored,
* causes glitch with planes, see: T44390 */
const float fade = bstrength * tex_strength(
- ss, brush, vd.co, sqrtf(test.dist), vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f,
- thread_id);
+ ss, brush, vd.co, sqrtf(test.dist),
+ vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
mul_v3_v3fl(proxy[vd.i], val, fade);
@@ -2953,7 +2974,7 @@ static void do_clay_strips_brush_task_cb_ex(
{
SculptThreadedTaskData *data = userdata;
SculptSession *ss = data->ob->sculpt;
- Brush *brush = data->brush;
+ const Brush *brush = data->brush;
float (*mat)[4] = data->mat;
const float *area_no_sp = data->area_no_sp;
const float *area_co = data->area_co;
@@ -2967,15 +2988,16 @@ static void do_clay_strips_brush_task_cb_ex(
proxy = BKE_pbvh_node_add_proxy(ss->pbvh, data->nodes[n])->co;
sculpt_brush_test_init(ss, &test);
+ plane_from_point_normal_v3(test.plane_tool, area_co, area_no_sp);
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
{
if (sculpt_brush_test_cube(&test, vd.co, mat)) {
- if (plane_point_side_flip(vd.co, area_no_sp, area_co, flip)) {
+ if (plane_point_side_flip(vd.co, test.plane_tool, flip)) {
float intr[3];
float val[3];
- point_plane_project(intr, vd.co, area_no_sp, area_co);
+ closest_to_plane_normalized_v3(intr, test.plane_tool, vd.co);
sub_v3_v3v3(val, intr, vd.co);
@@ -2983,8 +3005,8 @@ static void do_clay_strips_brush_task_cb_ex(
/* note, the normal from the vertices is ignored,
* causes glitch with planes, see: T44390 */
const float fade = bstrength * tex_strength(
- ss, brush, vd.co, ss->cache->radius * test.dist,
- vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
+ ss, brush, vd.co, ss->cache->radius * test.dist,
+ vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
mul_v3_v3fl(proxy[vd.i], val, fade);
@@ -3062,34 +3084,37 @@ static void do_fill_brush_task_cb_ex(
{
SculptThreadedTaskData *data = userdata;
SculptSession *ss = data->ob->sculpt;
- Brush *brush = data->brush;
+ const Brush *brush = data->brush;
const float *area_no = data->area_no;
const float *area_co = data->area_co;
PBVHVertexIter vd;
- SculptBrushTest test;
float (*proxy)[3];
const float bstrength = ss->cache->bstrength;
proxy = BKE_pbvh_node_add_proxy(ss->pbvh, data->nodes[n])->co;
- sculpt_brush_test_init(ss, &test);
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn =
+ sculpt_brush_test_init_with_falloff_shape(ss, &test, data->brush->falloff_shape);
+
+ plane_from_point_normal_v3(test.plane_tool, area_co, area_no);
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
{
- if (sculpt_brush_test_sq(&test, vd.co)) {
- if (plane_point_side(vd.co, area_no, area_co)) {
+ if (sculpt_brush_test_sq_fn(&test, vd.co)) {
+ if (plane_point_side(vd.co, test.plane_tool)) {
float intr[3];
float val[3];
- point_plane_project(intr, vd.co, area_no, area_co);
+ closest_to_plane_normalized_v3(intr, test.plane_tool, vd.co);
sub_v3_v3v3(val, intr, vd.co);
if (plane_trim(ss->cache, brush, val)) {
const float fade = bstrength * tex_strength(
- ss, brush, vd.co, sqrtf(test.dist),
- vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
+ ss, brush, vd.co, sqrtf(test.dist),
+ vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
mul_v3_v3fl(proxy[vd.i], val, fade);
@@ -3140,34 +3165,36 @@ static void do_scrape_brush_task_cb_ex(
{
SculptThreadedTaskData *data = userdata;
SculptSession *ss = data->ob->sculpt;
- Brush *brush = data->brush;
+ const Brush *brush = data->brush;
const float *area_no = data->area_no;
const float *area_co = data->area_co;
PBVHVertexIter vd;
- SculptBrushTest test;
float (*proxy)[3];
const float bstrength = ss->cache->bstrength;
proxy = BKE_pbvh_node_add_proxy(ss->pbvh, data->nodes[n])->co;
- sculpt_brush_test_init(ss, &test);
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn =
+ sculpt_brush_test_init_with_falloff_shape(ss, &test, data->brush->falloff_shape);
+ plane_from_point_normal_v3(test.plane_tool, area_co, area_no);
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
{
- if (sculpt_brush_test_sq(&test, vd.co)) {
- if (!plane_point_side(vd.co, area_no, area_co)) {
+ if (sculpt_brush_test_sq_fn(&test, vd.co)) {
+ if (!plane_point_side(vd.co, test.plane_tool)) {
float intr[3];
float val[3];
- point_plane_project(intr, vd.co, area_no, area_co);
+ closest_to_plane_normalized_v3(intr, test.plane_tool, vd.co);
sub_v3_v3v3(val, intr, vd.co);
if (plane_trim(ss->cache, brush, val)) {
const float fade = bstrength * tex_strength(
- ss, brush, vd.co, sqrtf(test.dist), vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f,
- thread_id);
+ ss, brush, vd.co, sqrtf(test.dist),
+ vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
mul_v3_v3fl(proxy[vd.i], val, fade);
@@ -3218,22 +3245,23 @@ static void do_gravity_task_cb_ex(
{
SculptThreadedTaskData *data = userdata;
SculptSession *ss = data->ob->sculpt;
- Brush *brush = data->brush;
+ const Brush *brush = data->brush;
float *offset = data->offset;
PBVHVertexIter vd;
- SculptBrushTest test;
float (*proxy)[3];
proxy = BKE_pbvh_node_add_proxy(ss->pbvh, data->nodes[n])->co;
- sculpt_brush_test_init(ss, &test);
+ SculptBrushTest test;
+ SculptBrushTestFn sculpt_brush_test_sq_fn =
+ sculpt_brush_test_init_with_falloff_shape(ss, &test, data->brush->falloff_shape);
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) {
- if (sculpt_brush_test_sq(&test, vd.co)) {
+ if (sculpt_brush_test_sq_fn(&test, vd.co)) {
const float fade = tex_strength(
- ss, brush, vd.co, sqrtf(test.dist), vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f,
- thread_id);
+ ss, brush, vd.co, sqrtf(test.dist),
+ vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
mul_v3_v3fl(proxy[vd.i], offset, fade);
@@ -3317,22 +3345,12 @@ void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3])
static void sculpt_topology_update(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSettings *UNUSED(ups))
{
SculptSession *ss = ob->sculpt;
- SculptSearchSphereData data;
- PBVHNode **nodes = NULL;
- float radius;
- int n, totnode;
-
- /* Build a list of all nodes that are potentially within the
- * brush's area of influence */
- data.ss = ss;
- data.sd = sd;
-
- radius = ss->cache->radius * 1.25f;
- data.radius_squared = radius * radius;
- data.original = sculpt_tool_needs_original(brush->sculpt_tool) ? true : ss->cache->original;
-
- BKE_pbvh_search_gather(ss->pbvh, sculpt_search_sphere_cb, &data, &nodes, &totnode);
+ int n, totnode;
+ /* Build a list of all nodes that are potentially within the brush's area of influence */
+ const bool use_original = sculpt_tool_needs_original(brush->sculpt_tool) ? true : ss->cache->original;
+ const float radius_scale = 1.25f;
+ PBVHNode **nodes = sculpt_pbvh_gather_generic(ob, sd, brush, use_original, radius_scale, &totnode);
/* Only act if some verts are inside the brush area */
if (totnode) {
@@ -3364,8 +3382,10 @@ static void sculpt_topology_update(Sculpt *sd, Object *ob, Brush *brush, Unified
BKE_pbvh_bmesh_update_topology(
ss->pbvh, mode,
ss->cache->location,
- (brush->flag & BRUSH_FRONTFACE) ? ss->cache->view_normal : NULL,
- ss->cache->radius);
+ ss->cache->view_normal,
+ ss->cache->radius,
+ (brush->flag & BRUSH_FRONTFACE) != 0,
+ (brush->falloff_shape != PAINT_FALLOFF_SHAPE_SPHERE));
}
MEM_freeN(nodes);
@@ -3388,16 +3408,12 @@ static void do_brush_action_task_cb(void *userdata, const int n)
static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSettings *ups)
{
SculptSession *ss = ob->sculpt;
- SculptSearchSphereData data;
- PBVHNode **nodes = NULL;
int totnode;
/* Build a list of all nodes that are potentially within the brush's area of influence */
- data.ss = ss;
- data.sd = sd;
- data.radius_squared = ss->cache->radius_squared;
- data.original = sculpt_tool_needs_original(brush->sculpt_tool) ? true : ss->cache->original;
- BKE_pbvh_search_gather(ss->pbvh, sculpt_search_sphere_cb, &data, &nodes, &totnode);
+ const bool use_original = sculpt_tool_needs_original(brush->sculpt_tool) ? true : ss->cache->original;
+ const float radius_scale = 1.0f;
+ PBVHNode **nodes = sculpt_pbvh_gather_generic(ob, sd, brush, use_original, radius_scale, &totnode);
/* Only act if some verts are inside the brush area */
if (totnode) {
@@ -3692,13 +3708,12 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob)
/* Flip all the editdata across the axis/axes specified by symm. Used to
* calculate multiple modifications to the mesh when symmetry is enabled. */
-static void calc_brushdata_symm(Sculpt *sd, StrokeCache *cache, const char symm,
- const char axis, const float angle,
- const float UNUSED(feather))
+void sculpt_cache_calc_brushdata_symm(
+ StrokeCache *cache, const char symm,
+ const char axis, const float angle)
{
- (void)sd; /* unused */
-
flip_v3_v3(cache->location, cache->true_location, symm);
+ flip_v3_v3(cache->last_location, cache->true_last_location, symm);
flip_v3_v3(cache->grab_delta_symmetry, cache->grab_delta, symm);
flip_v3_v3(cache->view_normal, cache->true_view_normal, symm);
@@ -3795,7 +3810,7 @@ static void do_tiled(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSettings
static void do_radial_symmetry(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSettings *ups,
BrushActionFunc action,
const char symm, const int axis,
- const float feather)
+ const float UNUSED(feather))
{
SculptSession *ss = ob->sculpt;
int i;
@@ -3803,7 +3818,7 @@ static void do_radial_symmetry(Sculpt *sd, Object *ob, Brush *brush, UnifiedPain
for (i = 1; i < sd->radial_symm[axis - 'X']; ++i) {
const float angle = 2 * M_PI * i / sd->radial_symm[axis - 'X'];
ss->cache->radial_symmetry_pass = i;
- calc_brushdata_symm(sd, ss->cache, symm, axis, angle, feather);
+ sculpt_cache_calc_brushdata_symm(ss->cache, symm, axis, angle);
do_tiled(sd, ob, brush, ups, action);
}
}
@@ -3821,8 +3836,9 @@ static void sculpt_fix_noise_tear(Sculpt *sd, Object *ob)
multires_stitch_grids(ob);
}
-static void do_symmetrical_brush_actions(Sculpt *sd, Object *ob,
- BrushActionFunc action, UnifiedPaintSettings *ups)
+static void do_symmetrical_brush_actions(
+ Sculpt *sd, Object *ob,
+ BrushActionFunc action, UnifiedPaintSettings *ups)
{
Brush *brush = BKE_paint_brush(&sd->paint);
SculptSession *ss = ob->sculpt;
@@ -3841,7 +3857,7 @@ static void do_symmetrical_brush_actions(Sculpt *sd, Object *ob,
cache->mirror_symmetry_pass = i;
cache->radial_symmetry_pass = 0;
- calc_brushdata_symm(sd, cache, i, 0, 0, feather);
+ sculpt_cache_calc_brushdata_symm(cache, i, 0, 0);
do_tiled(sd, ob, brush, ups, action);
do_radial_symmetry(sd, ob, brush, ups, action, i, 'X', feather);
@@ -3952,7 +3968,7 @@ static const char *sculpt_tool_name(Sculpt *sd)
* Operator for applying a stroke (various attributes including mouse path)
* using the current brush. */
-static void sculpt_cache_free(StrokeCache *cache)
+void sculpt_cache_free(StrokeCache *cache)
{
if (cache->dial)
MEM_freeN(cache->dial);
@@ -4215,7 +4231,6 @@ static void sculpt_update_brush_delta(UnifiedPaintSettings *ups, Object *ob, Bru
sub_v3_v3v3(cache->grab_delta, grab_location,
cache->old_grab_location);
}
-
invert_m4_m4(imat, ob->obmat);
mul_mat3_m4_v3(imat, cache->grab_delta);
break;
@@ -4225,6 +4240,10 @@ static void sculpt_update_brush_delta(UnifiedPaintSettings *ups, Object *ob, Bru
zero_v3(cache->grab_delta);
}
+ if (brush->falloff_shape == PAINT_FALLOFF_SHAPE_TUBE) {
+ project_plane_v3_v3v3(cache->grab_delta, cache->grab_delta, ss->cache->true_view_normal);
+ }
+
copy_v3_v3(cache->old_grab_location, grab_location);
if (tool == SCULPT_TOOL_GRAB)
@@ -4394,29 +4413,17 @@ static void sculpt_stroke_modifiers_check(const bContext *C, Object *ob)
SculptSession *ss = ob->sculpt;
if (ss->kb || ss->modifiers_active) {
+ EvaluationContext eval_ctx;
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
Brush *brush = BKE_paint_brush(&sd->paint);
- BKE_sculpt_update_mesh_elements(CTX_data_scene(C), sd, ob,
+ CTX_data_eval_ctx(C, &eval_ctx);
+
+ BKE_sculpt_update_mesh_elements(&eval_ctx, CTX_data_scene(C), sd, ob,
sculpt_any_smooth_mode(brush, ss->cache, 0), false);
}
}
-typedef struct {
- SculptSession *ss;
- const float *ray_start, *ray_normal;
- bool hit;
- float dist;
- bool original;
-} SculptRaycastData;
-
-typedef struct {
- const float *ray_start, *ray_normal;
- bool hit;
- float dist;
- float detail;
-} SculptDetailRaycastData;
-
static void sculpt_raycast_cb(PBVHNode *node, void *data_v, float *tmin)
{
if (BKE_pbvh_node_get_tmin(node) < *tmin) {
@@ -4437,10 +4444,40 @@ static void sculpt_raycast_cb(PBVHNode *node, void *data_v, float *tmin)
}
if (BKE_pbvh_node_raycast(srd->ss->pbvh, node, origco, use_origco,
- srd->ray_start, srd->ray_normal, &srd->dist))
+ srd->ray_start, srd->ray_normal, &srd->depth))
+ {
+ srd->hit = 1;
+ *tmin = srd->depth;
+ }
+ }
+}
+
+static void sculpt_find_nearest_to_ray_cb(PBVHNode *node, void *data_v, float *tmin)
+{
+ if (BKE_pbvh_node_get_tmin(node) < *tmin) {
+ SculptFindNearestToRayData *srd = data_v;
+ float (*origco)[3] = NULL;
+ bool use_origco = false;
+
+ if (srd->original && srd->ss->cache) {
+ if (BKE_pbvh_type(srd->ss->pbvh) == PBVH_BMESH) {
+ use_origco = true;
+ }
+ else {
+ /* intersect with coordinates from before we started stroke */
+ SculptUndoNode *unode = sculpt_undo_get_node(node);
+ origco = (unode) ? unode->co : NULL;
+ use_origco = origco ? true : false;
+ }
+ }
+
+ if (BKE_pbvh_node_find_nearest_to_ray(
+ srd->ss->pbvh, node, origco, use_origco,
+ srd->ray_start, srd->ray_normal,
+ &srd->depth, &srd->dist_sq_to_ray))
{
srd->hit = 1;
- *tmin = srd->dist;
+ *tmin = srd->dist_sq_to_ray;
}
}
}
@@ -4450,10 +4487,10 @@ static void sculpt_raycast_detail_cb(PBVHNode *node, void *data_v, float *tmin)
if (BKE_pbvh_node_get_tmin(node) < *tmin) {
SculptDetailRaycastData *srd = data_v;
if (BKE_pbvh_bmesh_node_raycast_detail(node, srd->ray_start, srd->ray_normal,
- &srd->dist, &srd->detail))
+ &srd->depth, &srd->detail))
{
srd->hit = 1;
- *tmin = srd->dist;
+ *tmin = srd->depth;
}
}
}
@@ -4500,8 +4537,7 @@ bool sculpt_stroke_get_location(bContext *C, float out[3], const float mouse[2])
Object *ob;
SculptSession *ss;
StrokeCache *cache;
- float ray_start[3], ray_end[3], ray_normal[3], dist;
- SculptRaycastData srd;
+ float ray_start[3], ray_end[3], ray_normal[3], depth;
bool original;
ViewContext vc;
@@ -4515,23 +4551,58 @@ bool sculpt_stroke_get_location(bContext *C, float out[3], const float mouse[2])
sculpt_stroke_modifiers_check(C, ob);
- dist = sculpt_raycast_init(&vc, mouse, ray_start, ray_end, ray_normal, original);
+ depth = sculpt_raycast_init(&vc, mouse, ray_start, ray_end, ray_normal, original);
- srd.original = original;
- srd.ss = ob->sculpt;
- srd.hit = 0;
- srd.ray_start = ray_start;
- srd.ray_normal = ray_normal;
- srd.dist = dist;
+ bool hit = false;
+ {
+ SculptRaycastData srd = {
+ .original = original,
+ .ss = ob->sculpt,
+ .hit = 0,
+ .ray_start = ray_start,
+ .ray_normal = ray_normal,
+ .depth = depth,
+ };
+ BKE_pbvh_raycast(
+ ss->pbvh, sculpt_raycast_cb, &srd,
+ ray_start, ray_normal, srd.original);
+ if (srd.hit) {
+ hit = true;
+ copy_v3_v3(out, ray_normal);
+ mul_v3_fl(out, srd.depth);
+ add_v3_v3(out, ray_start);
+ }
+ }
- BKE_pbvh_raycast(ss->pbvh, sculpt_raycast_cb, &srd,
- ray_start, ray_normal, srd.original);
+ if (hit == false) {
+ const Brush *brush = BKE_paint_brush(BKE_paint_get_active_from_context(C));
+ if (ELEM(brush->falloff_shape, PAINT_FALLOFF_SHAPE_TUBE)) {
+ SculptFindNearestToRayData srd = {
+ .original = original,
+ .ss = ob->sculpt,
+ .hit = 0,
+ .ray_start = ray_start,
+ .ray_normal = ray_normal,
+ .depth = FLT_MAX,
+ .dist_sq_to_ray = FLT_MAX,
+ };
+ BKE_pbvh_find_nearest_to_ray(
+ ss->pbvh, sculpt_find_nearest_to_ray_cb, &srd,
+ ray_start, ray_normal, srd.original);
+ if (srd.hit) {
+ hit = true;
+ copy_v3_v3(out, ray_normal);
+ mul_v3_fl(out, srd.depth);
+ add_v3_v3(out, ray_start);
+ }
+ }
+ }
- copy_v3_v3(out, ray_normal);
- mul_v3_fl(out, srd.dist);
- add_v3_v3(out, ray_start);
+ if (cache && hit) {
+ copy_v3_v3(cache->true_location, out);
+ }
- return srd.hit;
+ return hit;
}
static void sculpt_brush_init_tex(const Scene *scene, Sculpt *sd, SculptSession *ss)
@@ -4554,12 +4625,15 @@ static bool sculpt_brush_stroke_init(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+ EvaluationContext eval_ctx;
SculptSession *ss = CTX_data_active_object(C)->sculpt;
Brush *brush = BKE_paint_brush(&sd->paint);
int mode = RNA_enum_get(op->ptr, "mode");
bool is_smooth;
bool need_mask = false;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
if (brush->sculpt_tool == SCULPT_TOOL_MASK) {
need_mask = true;
}
@@ -4568,7 +4642,7 @@ static bool sculpt_brush_stroke_init(bContext *C, wmOperator *op)
sculpt_brush_init_tex(scene, sd, ss);
is_smooth = sculpt_any_smooth_mode(brush, NULL, mode);
- BKE_sculpt_update_mesh_elements(scene, sd, ob, is_smooth, need_mask);
+ BKE_sculpt_update_mesh_elements(&eval_ctx, scene, sd, ob, is_smooth, need_mask);
return 1;
}
@@ -4642,6 +4716,9 @@ static void sculpt_flush_update(bContext *C)
ED_region_tag_redraw_partial(ar, &r);
}
}
+
+ /* 2.8x - avoid full mesh update! */
+ BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_SCULPT_COORDS);
}
/* Returns whether the mouse/stylus is over the mesh (1)
@@ -4660,8 +4737,11 @@ static bool sculpt_stroke_test_start(bContext *C, struct wmOperator *op,
const float mouse[2])
{
/* Don't start the stroke until mouse goes over the mesh.
- * note: mouse will only be null when re-executing the saved stroke. */
- if (!mouse || over_mesh(C, op, mouse[0], mouse[1])) {
+ * note: mouse will only be null when re-executing the saved stroke.
+ * We have exception for 'exec' strokes since they may not set 'mouse', only 'location', see: T52195. */
+ if (((op->flag & OP_IS_INVOKE) == 0) ||
+ (mouse == NULL) || over_mesh(C, op, mouse[0], mouse[1]))
+ {
Object *ob = CTX_data_active_object(C);
SculptSession *ss = ob->sculpt;
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
@@ -4722,7 +4802,7 @@ static void sculpt_stroke_update_step(bContext *C, struct PaintStroke *UNUSED(st
* Could be optimized later, but currently don't think it's so
* much common scenario.
*
- * Same applies to the DAG_id_tag_update() invoked from
+ * Same applies to the DEG_id_tag_update() invoked from
* sculpt_flush_update().
*/
if (ss->modifiers_active) {
@@ -4758,6 +4838,7 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str
if (ss->cache) {
UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings;
Brush *brush = BKE_paint_brush(&sd->paint);
+ BLI_assert(brush == ss->cache->brush); /* const, so we shouldn't change. */
ups->draw_inverted = false;
sculpt_stroke_modifiers_check(C, ob);
@@ -4768,11 +4849,10 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str
brush->mask_tool = ss->cache->saved_mask_brush_tool;
}
else {
- Paint *p = &sd->paint;
- BKE_brush_size_set(scene, ss->cache->brush, ss->cache->saved_smooth_size);
+ BKE_brush_size_set(scene, brush, ss->cache->saved_smooth_size);
brush = (Brush *)BKE_libblock_find_name(ID_BR, ss->cache->saved_active_brush_name);
if (brush) {
- BKE_paint_brush_set(p, brush);
+ BKE_paint_brush_set(&sd->paint, brush);
}
}
}
@@ -4992,10 +5072,13 @@ void sculpt_update_after_dynamic_topology_toggle(bContext *C)
{
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
+ EvaluationContext eval_ctx;
Sculpt *sd = scene->toolsettings->sculpt;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
/* Create the PBVH */
- BKE_sculpt_update_mesh_elements(scene, sd, ob, false, false);
+ BKE_sculpt_update_mesh_elements(&eval_ctx, scene, sd, ob, false, false);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
}
@@ -5329,11 +5412,15 @@ static void SCULPT_OT_symmetrize(wmOperatorType *ot)
/**** Toggle operator for turning sculpt mode on or off ****/
-static void sculpt_init_session(Scene *scene, Object *ob)
+static void sculpt_init_session(const bContext *C, Scene *scene, Object *ob)
{
+ EvaluationContext eval_ctx;
+
+ CTX_data_eval_ctx(C, &eval_ctx);
+
ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session");
- BKE_sculpt_update_mesh_elements(scene, scene->toolsettings->sculpt, ob, 0, false);
+ BKE_sculpt_update_mesh_elements(&eval_ctx, scene, scene->toolsettings->sculpt, ob, 0, false);
}
@@ -5425,7 +5512,7 @@ static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op)
if (ob->sculpt)
BKE_sculptsession_free(ob);
- sculpt_init_session(scene, ob);
+ sculpt_init_session(C, scene, ob);
/* Mask layer is required */
if (mmd) {
@@ -5531,7 +5618,7 @@ static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = CTX_data_active_object(C);
SculptSession *ss = ob->sculpt;
float size;
- float bb_min[3], bb_max[3];
+ float bb_min[3], bb_max[3], center[3], dim[3];
int i, totnodes;
PBVHNode **nodes;
@@ -5543,11 +5630,12 @@ static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *UNUSED(op))
for (i = 0; i < totnodes; i++) {
BKE_pbvh_node_mark_topology_update(nodes[i]);
}
- /* get the bounding box, store the size to bb_max and center (zero) to bb_min */
+ /* get the bounding box, it's center and size */
BKE_pbvh_bounding_box(ob->sculpt->pbvh, bb_min, bb_max);
- sub_v3_v3(bb_max, bb_min);
- zero_v3(bb_min);
- size = max_fff(bb_max[0], bb_max[1], bb_max[2]);
+ add_v3_v3v3(center, bb_min, bb_max);
+ mul_v3_fl(center, 0.5f);
+ sub_v3_v3v3(dim, bb_max, bb_min);
+ size = max_fff(dim[0], dim[1], dim[2]);
/* update topology size */
BKE_pbvh_bmesh_detail_size_set(ss->pbvh, 1.0f / sd->constant_detail);
@@ -5557,7 +5645,7 @@ static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *UNUSED(op))
while (BKE_pbvh_bmesh_update_topology(
ss->pbvh, PBVH_Collapse | PBVH_Subdivide,
- bb_min, NULL, size))
+ center, NULL, size, false, false))
{
for (i = 0; i < totnodes; i++)
BKE_pbvh_node_mark_topology_update(nodes[i]);
@@ -5593,7 +5681,7 @@ static void sample_detail(bContext *C, int ss_co[2])
ViewContext vc;
Object *ob;
Sculpt *sd;
- float ray_start[3], ray_end[3], ray_normal[3], dist;
+ float ray_start[3], ray_end[3], ray_normal[3], depth;
SculptDetailRaycastData srd;
float mouse[2] = {ss_co[0], ss_co[1]};
view3d_set_viewcontext(C, &vc);
@@ -5603,12 +5691,12 @@ static void sample_detail(bContext *C, int ss_co[2])
sculpt_stroke_modifiers_check(C, ob);
- dist = sculpt_raycast_init(&vc, mouse, ray_start, ray_end, ray_normal, false);
+ depth = sculpt_raycast_init(&vc, mouse, ray_start, ray_end, ray_normal, false);
srd.hit = 0;
srd.ray_start = ray_start;
srd.ray_normal = ray_normal;
- srd.dist = dist;
+ srd.depth = depth;
srd.detail = sd->constant_detail;
BKE_pbvh_raycast(ob->sculpt->pbvh, sculpt_raycast_detail_cb, &srd,
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 108fe3532e3..aaea13ce5d0 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -38,12 +38,15 @@
#include "DNA_key_types.h"
#include "BLI_bitmap.h"
+#include "BLI_threads.h"
+
#include "BKE_pbvh.h"
struct bContext;
struct KeyBlock;
struct Object;
struct SculptUndoNode;
+struct SculptOrigVertData;
int sculpt_mode_poll(struct bContext *C);
int sculpt_mode_poll_view3d(struct bContext *C);
@@ -52,12 +55,12 @@ int sculpt_poll(struct bContext *C);
int sculpt_poll_view3d(struct bContext *C);
/* Stroke */
-bool sculpt_stroke_get_location(bContext *C, float out[3], const float mouse[2]);
+bool sculpt_stroke_get_location(struct bContext *C, float out[3], const float mouse[2]);
/* Dynamic topology */
void sculpt_pbvh_clear(Object *ob);
void sculpt_dyntopo_node_layers_add(struct SculptSession *ss);
-void sculpt_update_after_dynamic_topology_toggle(bContext *C);
+void sculpt_update_after_dynamic_topology_toggle(struct bContext *C);
void sculpt_dynamic_topology_enable(struct bContext *C);
void sculpt_dynamic_topology_disable(struct bContext *C,
struct SculptUndoNode *unode);
@@ -115,6 +118,227 @@ typedef struct SculptUndoNode {
char shapeName[sizeof(((KeyBlock *)0))->name];
} SculptUndoNode;
+/* Factor of brush to have rake point following behind
+* (could be configurable but this is reasonable default). */
+#define SCULPT_RAKE_BRUSH_FACTOR 0.25f
+
+struct SculptRakeData {
+ float follow_dist;
+ float follow_co[3];
+};
+
+/* Single struct used by all BLI_task threaded callbacks, let's avoid adding 10's of those... */
+typedef struct SculptThreadedTaskData {
+ struct bContext *C;
+ struct Sculpt *sd;
+ struct Object *ob;
+ const struct Brush *brush;
+ struct PBVHNode **nodes;
+ int totnode;
+
+ struct VPaint *vp;
+ struct VPaintData *vpd;
+ struct WPaintData *wpd;
+ struct WeightPaintInfo *wpi;
+ unsigned int *lcol;
+ struct Mesh *me;
+ /* For passing generic params. */
+ void *custom_data;
+
+
+ /* Data specific to some callbacks. */
+ /* Note: even if only one or two of those are used at a time, keeping them separated, names help figuring out
+ * what it is, and memory overhead is ridiculous anyway... */
+ float flippedbstrength;
+ float angle;
+ float strength;
+ bool smooth_mask;
+ bool has_bm_orco;
+
+ struct SculptProjectVector *spvc;
+ float *offset;
+ float *grab_delta;
+ float *cono;
+ float *area_no;
+ float *area_no_sp;
+ float *area_co;
+ float(*mat)[4];
+ float(*vertCos)[3];
+
+ /* 0=towards view, 1=flipped */
+ float(*area_cos)[3];
+ float(*area_nos)[3];
+ int *count;
+
+ ThreadMutex mutex;
+
+} SculptThreadedTaskData;
+
+/*************** Brush testing declarations ****************/
+typedef struct SculptBrushTest {
+ float radius_squared;
+ float location[3];
+ float dist;
+ int mirror_symmetry_pass;
+
+ /* For circle (not sphere) projection. */
+ float plane_view[4];
+
+ /* Some tool code uses a plane for it's calculateions. */
+ float plane_tool[4];
+
+ /* View3d clipping - only set rv3d for clipping */
+ struct RegionView3D *clip_rv3d;
+} SculptBrushTest;
+
+typedef bool (*SculptBrushTestFn)(SculptBrushTest *test, const float co[3]);
+
+typedef struct {
+ struct Sculpt *sd;
+ struct SculptSession *ss;
+ float radius_squared;
+ bool original;
+} SculptSearchSphereData;
+
+typedef struct {
+ struct Sculpt *sd;
+ struct SculptSession *ss;
+ float radius_squared;
+ bool original;
+ struct DistRayAABB_Precalc *dist_ray_to_aabb_precalc;
+} SculptSearchCircleData;
+
+void sculpt_brush_test_init(struct SculptSession *ss, SculptBrushTest *test);
+bool sculpt_brush_test_sphere(SculptBrushTest *test, const float co[3]);
+bool sculpt_brush_test_sphere_sq(SculptBrushTest *test, const float co[3]);
+bool sculpt_brush_test_sphere_fast(const SculptBrushTest *test, const float co[3]);
+bool sculpt_brush_test_cube(SculptBrushTest *test, const float co[3], float local[4][4]);
+bool sculpt_brush_test_circle_sq(SculptBrushTest *test, const float co[3]);
+bool sculpt_search_sphere_cb(PBVHNode *node, void *data_v);
+bool sculpt_search_circle_cb(PBVHNode *node, void *data_v);
+
+SculptBrushTestFn sculpt_brush_test_init_with_falloff_shape(
+ SculptSession *ss, SculptBrushTest *test, char falloff_shape);
+const float *sculpt_brush_frontface_normal_from_falloff_shape(
+ SculptSession *ss, char falloff_shape);
+
+float tex_strength(
+ struct SculptSession *ss, const struct Brush *br,
+ const float point[3],
+ const float len,
+ const short vno[3],
+ const float fno[3],
+ const float mask,
+ const int thread_id);
+
+/* just for vertex paint. */
+void sculpt_pbvh_calc_area_normal(
+ const struct Brush *brush, Object *ob,
+ PBVHNode **nodes, int totnode,
+ bool use_threading,
+ float r_area_no[3]);
+
+/* Cache stroke properties. Used because
+* RNA property lookup isn't particularly fast.
+*
+* For descriptions of these settings, check the operator properties.
+*/
+
+typedef struct StrokeCache {
+ /* Invariants */
+ float initial_radius;
+ float scale[3];
+ int flag;
+ float clip_tolerance[3];
+ float initial_mouse[2];
+
+ /* Variants */
+ float radius;
+ float radius_squared;
+ float true_location[3];
+ float true_last_location[3];
+ float location[3];
+ float last_location[3];
+ bool is_last_valid;
+
+ bool pen_flip;
+ bool invert;
+ float pressure;
+ float mouse[2];
+ float bstrength;
+ float normal_weight; /* from brush (with optional override) */
+
+ /* The rest is temporary storage that isn't saved as a property */
+
+ bool first_time; /* Beginning of stroke may do some things special */
+
+ /* from ED_view3d_ob_project_mat_get() */
+ float projection_mat[4][4];
+
+ /* Clean this up! */
+ struct ViewContext *vc;
+ const struct Brush *brush;
+
+ float special_rotation;
+ float grab_delta[3], grab_delta_symmetry[3];
+ float old_grab_location[3], orig_grab_location[3];
+
+ /* screen-space rotation defined by mouse motion */
+ float rake_rotation[4], rake_rotation_symmetry[4];
+ bool is_rake_rotation_valid;
+ struct SculptRakeData rake_data;
+
+ /* Symmetry index between 0 and 7 bit combo 0 is Brush only;
+ * 1 is X mirror; 2 is Y mirror; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ */
+ int symmetry;
+ int mirror_symmetry_pass; /* the symmetry pass we are currently on between 0 and 7*/
+ float true_view_normal[3];
+ float view_normal[3];
+
+ /* sculpt_normal gets calculated by calc_sculpt_normal(), then the
+ * sculpt_normal_symm gets updated quickly with the usual symmetry
+ * transforms */
+ float sculpt_normal[3];
+ float sculpt_normal_symm[3];
+
+ /* Used for area texture mode, local_mat gets calculated by
+ * calc_brush_local_mat() and used in tex_strength(). */
+ float brush_local_mat[4][4];
+
+ float plane_offset[3]; /* used to shift the plane around when doing tiled strokes */
+ int tile_pass;
+
+ float last_center[3];
+ int radial_symmetry_pass;
+ float symm_rot_mat[4][4];
+ float symm_rot_mat_inv[4][4];
+ bool original;
+ float anchored_location[3];
+
+ float vertex_rotation; /* amount to rotate the vertices when using rotate brush */
+ struct Dial *dial;
+
+ char saved_active_brush_name[MAX_ID_NAME];
+ char saved_mask_brush_tool;
+ int saved_smooth_size; /* smooth tool copies the size of the current tool */
+ bool alt_smooth;
+
+ float plane_trim_squared;
+
+ bool supports_gravity;
+ float true_gravity_direction[3];
+ float gravity_direction[3];
+
+ rcti previous_r; /* previous redraw rectangle */
+ rcti current_r; /* current redraw rectangle */
+
+} StrokeCache;
+
+void sculpt_cache_calc_brushdata_symm(
+ StrokeCache *cache, const char symm,
+ const char axis, const float angle);
+void sculpt_cache_free(StrokeCache *cache);
+
SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType type);
SculptUndoNode *sculpt_undo_get_node(PBVHNode *node);
void sculpt_undo_push_begin(const char *name);
@@ -124,6 +348,8 @@ void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]);
void sculpt_update_object_bounding_box(struct Object *ob);
+bool sculpt_get_redraw_rect(struct ARegion *ar, struct RegionView3D *rv3d, Object *ob, rcti *rect);
+
#define SCULPT_THREADED_LIMIT 4
#endif
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index 9d55cc1369e..a10c7477dc6 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -127,9 +127,12 @@ static bool sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoN
Scene *scene = CTX_data_scene(C);
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
Object *ob = CTX_data_active_object(C);
+ EvaluationContext eval_ctx;
SculptSession *ss = ob->sculpt;
MVert *mvert;
int *index;
+
+ CTX_data_eval_ctx(C, &eval_ctx);
if (unode->maxvert) {
/* regular mesh restore */
@@ -143,7 +146,7 @@ static bool sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoN
if (kb) {
ob->shapenr = BLI_findindex(&key->block, kb) + 1;
- BKE_sculpt_update_mesh_elements(scene, sd, ob, 0, false);
+ BKE_sculpt_update_mesh_elements(&eval_ctx, scene, sd, ob, 0, false);
WM_event_add_notifier(C, NC_OBJECT | ND_DATA, ob);
}
else {
@@ -451,6 +454,7 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb)
Scene *scene = CTX_data_scene(C);
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
Object *ob = CTX_data_active_object(C);
+ EvaluationContext eval_ctx;
DerivedMesh *dm;
SculptSession *ss = ob->sculpt;
SculptUndoNode *unode;
@@ -458,6 +462,8 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb)
bool need_mask = false;
bool partial_update = true;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
for (unode = lb->first; unode; unode = unode->next) {
if (STREQ(unode->idname, ob->id.name)) {
if (unode->type == SCULPT_UNDO_MASK) {
@@ -469,10 +475,10 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb)
}
}
- BKE_sculpt_update_mesh_elements(scene, sd, ob, 0, need_mask);
+ BKE_sculpt_update_mesh_elements(&eval_ctx, scene, sd, ob, 0, need_mask);
/* call _after_ sculpt_update_mesh_elements() which may update 'ob->derivedFinal' */
- dm = mesh_get_derived_final(scene, ob, 0);
+ dm = mesh_get_derived_final(&eval_ctx, scene, ob, 0);
if (lb->first && sculpt_undo_bmesh_restore(C, lb->first, ob, ss))
return;
diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c
index ee6f25ee44e..14e82e94d30 100644
--- a/source/blender/editors/sculpt_paint/sculpt_uv.c
+++ b/source/blender/editors/sculpt_paint/sculpt_uv.c
@@ -219,7 +219,7 @@ static void brush_drawcursor_uvsculpt(bContext *C, int x, int y, void *UNUSED(cu
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
- imm_draw_circle_wire(pos, (float)x, (float)y, size, 40);
+ imm_draw_circle_wire_2d(pos, (float)x, (float)y, size, 40);
glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH);
diff --git a/source/blender/editors/sound/CMakeLists.txt b/source/blender/editors/sound/CMakeLists.txt
index 535cd579030..9efdf11e8d7 100644
--- a/source/blender/editors/sound/CMakeLists.txt
+++ b/source/blender/editors/sound/CMakeLists.txt
@@ -39,7 +39,7 @@ set(SRC
)
if(WITH_AUDASPACE)
- add_definitions(${AUDASPACE_DEFINITIONS})
+ add_definitions(-DWITH_AUDASPACE)
list(APPEND INC_SYS
${AUDASPACE_C_INCLUDE_DIRS}
diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c
index d103530fa81..ecc00f4b7e5 100644
--- a/source/blender/editors/sound/sound_ops.c
+++ b/source/blender/editors/sound/sound_ops.c
@@ -67,7 +67,7 @@
#include "WM_types.h"
#ifdef WITH_AUDASPACE
-# include AUD_SPECIAL_H
+# include <AUD_Special.h>
#endif
#include "ED_sound.h"
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index f8db35e2311..a9920389980 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -1522,7 +1522,7 @@ static int actkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
/* set the new current frame value, based on the average time */
if (ked.i1) {
Scene *scene = ac.scene;
- CFRA = iroundf(ked.f1 / ked.i1);
+ CFRA = round_fl_to_int(ked.f1 / ked.i1);
SUBFRA = 0.f;
}
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index 553be0ad290..17edbc6cc1d 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -262,6 +262,7 @@ static void borderselect_action(bAnimContext *ac, const rcti rect, short mode, s
{
/* loop over data selecting */
switch (ale->type) {
+#if 0 /* XXXX: Keyframes are not currently shown here */
case ANIMTYPE_GPDATABLOCK:
{
bGPdata *gpd = ale->data;
@@ -271,6 +272,7 @@ static void borderselect_action(bAnimContext *ac, const rcti rect, short mode, s
}
break;
}
+#endif
case ANIMTYPE_GPLAYER:
ED_gplayer_frames_select_border(ale->data, rectf.xmin, rectf.xmax, selectmode);
break;
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index fca54b282f8..f4affb90cc3 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -637,13 +637,17 @@ static void action_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, I
{
SpaceAction *sact = (SpaceAction *)slink;
- if (!ELEM(GS(old_id->name), ID_GR)) {
- return;
+ if ((ID *)sact->action == old_id) {
+ sact->action = (bAction *)new_id;
}
if ((ID *)sact->ads.filter_grp == old_id) {
sact->ads.filter_grp = (Group *)new_id;
}
+ if ((ID *)sact->ads.source == old_id) {
+ sact->ads.source = new_id;
+ }
+
}
/* only called once, from space/spacetypes.c */
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index 2460ba3fc9f..f6c15f4d030 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -182,7 +182,7 @@ static int buttons_context_path_object(ButsContextPath *path)
else if (buttons_context_path_scene(path)) {
scene = path->ptr[path->len - 1].data;
- SceneLayer *sl = BKE_scene_layer_context_active(scene);
+ SceneLayer *sl = BKE_scene_layer_context_active_PLACEHOLDER(scene);
ob = (sl->basact) ? sl->basact->object : NULL;
if (ob) {
diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c
index 72de7e5c81c..1d67ac620b0 100644
--- a/source/blender/editors/space_buttons/buttons_texture.c
+++ b/source/blender/editors/space_buttons/buttons_texture.c
@@ -470,7 +470,7 @@ void buttons_texture_context_compute(const bContext *C, SpaceButs *sbuts)
}
else {
/* set one user as active based on active index */
- if (ct->index == BLI_listbase_count_ex(&ct->users, ct->index + 1))
+ if (ct->index >= BLI_listbase_count_ex(&ct->users, ct->index + 1))
ct->index = 0;
ct->user = BLI_findlink(&ct->users, ct->index);
diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c
index 0f06d66d033..631d891ce02 100644
--- a/source/blender/editors/space_clip/clip_dopesheet_draw.c
+++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c
@@ -234,7 +234,7 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene)
/* check if visible */
if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
- IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax))
+ IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax))
{
MovieTrackingTrack *track = channel->track;
int i;
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index 15ec385fd09..09d225fc1b8 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -316,7 +316,7 @@ static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar,
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- imm_draw_checker_box(x, y, x + zoomx * ibuf->x, y + zoomy * ibuf->y);
+ imm_draw_box_checker_2d(x, y, x + zoomx * ibuf->x, y + zoomy * ibuf->y);
}
/* non-scaled proxy shouldn't use filtering */
@@ -361,7 +361,7 @@ static void draw_stabilization_border(SpaceClip *sc, ARegion *ar, int width, int
gpuScale2f(zoomx, zoomy);
gpuMultMatrix(sc->stabmat);
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
@@ -372,7 +372,7 @@ static void draw_stabilization_border(SpaceClip *sc, ARegion *ar, int width, int
immUniform1f("dash_width", 6.0f);
immUniform1f("dash_factor", 0.5f);
- imm_draw_line_box(shdr_pos, 0.0f, 0.0f, width, height);
+ imm_draw_box_wire_2d(shdr_pos, 0.0f, 0.0f, width, height);
immUnbindProgram();
@@ -384,9 +384,11 @@ static void draw_stabilization_border(SpaceClip *sc, ARegion *ar, int width, int
static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackingTrack *track)
{
+#define MAX_STATIC_PATH 64
int count = sc->path_length;
int i, a, b, curindex = -1;
- float path[102][2];
+ float path_static[(MAX_STATIC_PATH + 1) * 2][2];
+ float (*path)[2];
int tiny = sc->flag & SC_SHOW_TINY_MARKER, framenr, start_frame;
MovieTrackingMarker *marker;
@@ -399,6 +401,13 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
if (marker->framenr != framenr || marker->flag & MARKER_DISABLED)
return;
+ if (count < MAX_STATIC_PATH) {
+ path = path_static;
+ }
+ else {
+ path = MEM_mallocN(sizeof(*path) * (count + 1) * 2, "path");
+ }
+
a = count;
i = framenr - 1;
while (i >= framenr - count) {
@@ -533,6 +542,11 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
}
immUnbindProgram();
+
+ if (path != path_static) {
+ MEM_freeN(path);
+ }
+#undef MAX_STATIC_PATH
}
static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker,
@@ -604,7 +618,7 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT
((marker->flag & MARKER_DISABLED) == 0 || (sc->flag & SC_SHOW_MARKER_PATTERN) == 0)) != 0;
if (sc->flag & SC_SHOW_MARKER_SEARCH && show_search) {
- imm_draw_line_box(position, marker->search_min[0],
+ imm_draw_box_wire_2d(position, marker->search_min[0],
marker->search_min[1],
marker->search_max[0],
marker->search_max[1]);
@@ -651,7 +665,7 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
/* Since we are switching solid and dashed lines in rather complex logic here, just always go with dashed shader. */
immUnbindProgram();
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
@@ -781,7 +795,7 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
((marker->flag & MARKER_DISABLED) == 0 || (sc->flag & SC_SHOW_MARKER_PATTERN) == 0)) != 0;
if ((track->search_flag & SELECT) == sel && (sc->flag & SC_SHOW_MARKER_SEARCH) && show_search) {
- imm_draw_line_box(shdr_pos, marker->search_min[0], marker->search_min[1],
+ imm_draw_box_wire_2d(shdr_pos, marker->search_min[0], marker->search_min[1],
marker->search_max[0], marker->search_max[1]);
}
@@ -1192,7 +1206,7 @@ static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlane
if (draw_plane_quad || is_selected_track) {
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c
index 5c2782dc26d..1bd1ad69d64 100644
--- a/source/blender/editors/space_clip/clip_graph_draw.c
+++ b/source/blender/editors/space_clip/clip_graph_draw.c
@@ -122,7 +122,7 @@ static void tracking_segment_knot_cb(void *userdata, MovieTrackingTrack *track,
gpuTranslate2f(scene_framenr, val);
gpuScale2f(1.0f / data->xscale * data->hsize, 1.0f / data->yscale * data->hsize);
- imm_draw_circle_wire(data->pos, 0, 0, 0.7, 8);
+ imm_draw_circle_wire_2d(data->pos, 0, 0, 0.7, 8);
gpuPopMatrix();
}
diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c
index 9430ee626ba..970eae0ad14 100644
--- a/source/blender/editors/space_clip/clip_ops.c
+++ b/source/blender/editors/space_clip/clip_ops.c
@@ -941,7 +941,7 @@ static int frame_from_event(bContext *C, const wmEvent *event)
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &viewx, &viewy);
- framenr = iroundf(viewx);
+ framenr = round_fl_to_int(viewx);
}
return framenr;
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index eed2acbfc68..f185eea6d32 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -60,6 +60,7 @@
#include "IMB_imbuf.h"
+#include "GPU_glew.h"
#include "GPU_matrix.h"
#include "WM_api.h"
@@ -821,6 +822,7 @@ static void clip_keymap(struct wmKeyConfig *keyconf)
#endif
}
+/* DO NOT make this static, this hides the symbol and breaks API generation script. */
const char *clip_context_dir[] = {"edit_movieclip", "edit_mask", NULL};
static int clip_context(const bContext *C, const char *member, bContextDataResult *result)
diff --git a/source/blender/editors/space_clip/tracking_ops_orient.c b/source/blender/editors/space_clip/tracking_ops_orient.c
index 671825ef7c3..c411f64a88b 100644
--- a/source/blender/editors/space_clip/tracking_ops_orient.c
+++ b/source/blender/editors/space_clip/tracking_ops_orient.c
@@ -99,7 +99,7 @@ static Object *get_orientation_object(bContext *C)
object = get_camera_with_movieclip(scene, clip);
}
else {
- object = OBACT_NEW;
+ object = OBACT_NEW(sl);
}
if (object != NULL && object->parent != NULL) {
@@ -122,7 +122,7 @@ static int set_orientation_poll(bContext *C)
return true;
}
else {
- return OBACT_NEW != NULL;
+ return OBACT_NEW(sl) != NULL;
}
}
}
@@ -406,6 +406,7 @@ static int set_plane_exec(bContext *C, wmOperator *op)
ListBase *tracksbase;
Object *object;
Object *camera = get_camera_with_movieclip(scene, clip);
+ EvaluationContext eval_ctx;
int tot = 0;
float vec[3][3], mat[4][4], obmat[4][4], newmat[4][4], orig[3] = {0.0f, 0.0f, 0.0f};
int plane = RNA_enum_get(op->ptr, "plane");
@@ -430,6 +431,8 @@ static int set_plane_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
+ CTX_data_eval_ctx(C, &eval_ctx);
+
BKE_tracking_get_camera_object_matrix(scene, camera, mat);
/* Get 3 bundles to use as reference. */
@@ -492,7 +495,7 @@ static int set_plane_exec(bContext *C, wmOperator *op)
BKE_object_apply_mat4(object, mat, 0, 0);
}
- BKE_object_where_is_calc(scene, object);
+ BKE_object_where_is_calc(&eval_ctx, scene, object);
set_axis(scene, object, clip, tracking_object, axis_track, 'X');
DEG_id_tag_update(&clip->id, 0);
diff --git a/source/blender/editors/space_clip/tracking_ops_track.c b/source/blender/editors/space_clip/tracking_ops_track.c
index 368cbeaf955..0dd0ee8c7d4 100644
--- a/source/blender/editors/space_clip/tracking_ops_track.c
+++ b/source/blender/editors/space_clip/tracking_ops_track.c
@@ -165,7 +165,7 @@ static int track_markers_initjob(bContext *C,
track_init_markers(sc, clip, framenr, &frames_limit);
- tmj->sfra = ED_space_clip_get_clip_frame_number(sc);
+ tmj->sfra = framenr;
tmj->clip = clip;
tmj->backwards = backwards;
@@ -176,6 +176,7 @@ static int track_markers_initjob(bContext *C,
else {
tmj->efra = EFRA;
}
+ tmj->efra = BKE_movieclip_remap_scene_to_clip_frame(clip, tmj->efra);
}
else {
if (backwards) {
@@ -196,8 +197,6 @@ static int track_markers_initjob(bContext *C,
}
}
- tmj->efra = BKE_movieclip_remap_scene_to_clip_frame(clip, tmj->efra);
-
if (settings->speed != TRACKING_SPEED_FASTEST) {
tmj->delay = 1.0f / scene->r.frs_sec * 1000.0f;
@@ -212,7 +211,7 @@ static int track_markers_initjob(bContext *C,
}
}
- tmj->context = BKE_autotrack_context_new(clip, &sc->user, backwards, 1);
+ tmj->context = BKE_autotrack_context_new(clip, &sc->user, backwards, true);
clip->tracking_context = tmj->context;
@@ -310,6 +309,7 @@ static void track_markers_endjob(void *tmv)
static void track_markers_freejob(void *tmv)
{
TrackMarkersJob *tmj = (TrackMarkersJob *)tmv;
+ tmj->clip->tracking_context = NULL;
BKE_autotrack_context_free(tmj->context);
MEM_freeN(tmj);
}
diff --git a/source/blender/editors/space_console/console_intern.h b/source/blender/editors/space_console/console_intern.h
index 5b016b77e9f..f523cf0d476 100644
--- a/source/blender/editors/space_console/console_intern.h
+++ b/source/blender/editors/space_console/console_intern.h
@@ -70,6 +70,6 @@ void CONSOLE_OT_select_set(struct wmOperatorType *ot);
void CONSOLE_OT_select_word(struct wmOperatorType *ot);
enum { LINE_BEGIN, LINE_END, PREV_CHAR, NEXT_CHAR, PREV_WORD, NEXT_WORD };
-enum { DEL_ALL, DEL_NEXT_CHAR, DEL_PREV_CHAR, DEL_NEXT_WORD, DEL_PREV_WORD, DEL_SELECTION, DEL_NEXT_SEL, DEL_PREV_SEL };
+enum { DEL_NEXT_CHAR, DEL_PREV_CHAR, DEL_NEXT_WORD, DEL_PREV_WORD, DEL_SELECTION, DEL_NEXT_SEL, DEL_PREV_SEL };
#endif /* __CONSOLE_INTERN_H__ */
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index be873358931..c1e298c426f 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -400,11 +400,11 @@ static void file_draw_preview(
/* border */
if (use_dropshadow) {
Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2,GWN_FETCH_FLOAT);
+ unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4f(0.0f, 0.0f, 0.0f, 0.4f);
- imm_draw_line_box(pos, (float)xco, (float)yco, (float)(xco + ex), (float)(yco + ey));
+ imm_draw_box_wire_2d(pos, (float)xco, (float)yco, (float)(xco + ex), (float)(yco + ey));
immUnbindProgram();
}
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index b7228f634bf..ab1bcbaa8b5 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -1302,7 +1302,6 @@ void file_sfile_filepath_set(SpaceFile *sfile, const char *filepath)
if (BLI_is_dir(filepath)) {
BLI_strncpy(sfile->params->dir, filepath, sizeof(sfile->params->dir));
- sfile->params->file[0] = '\0';
}
else {
if ((sfile->params->flag & FILE_DIRSEL_ONLY) == 0) {
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 6c33091ff01..d670af59bc9 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -277,9 +277,10 @@ typedef struct FileListFilter {
/* FileListFilter.flags */
enum {
- FLF_HIDE_DOT = 1 << 0,
- FLF_HIDE_PARENT = 1 << 1,
- FLF_HIDE_LIB_DIR = 1 << 2,
+ FLF_DO_FILTER = 1 << 0,
+ FLF_HIDE_DOT = 1 << 1,
+ FLF_HIDE_PARENT = 1 << 2,
+ FLF_HIDE_LIB_DIR = 1 << 3,
};
typedef struct FileList {
@@ -594,24 +595,27 @@ static bool is_filtered_file(FileListInternEntry *file, const char *UNUSED(root)
{
bool is_filtered = !is_hidden_file(file->relpath, filter);
- if (is_filtered && filter->filter && !FILENAME_IS_CURRPAR(file->relpath)) {
- if (file->typeflag & FILE_TYPE_DIR) {
- if (file->typeflag & (FILE_TYPE_BLENDERLIB | FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP)) {
- if (!(filter->filter & (FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP))) {
- is_filtered = false;
+ if (is_filtered && (filter->flags & FLF_DO_FILTER) && !FILENAME_IS_CURRPAR(file->relpath)) {
+ /* We only check for types if some type are enabled in filtering. */
+ if (filter->filter) {
+ if (file->typeflag & FILE_TYPE_DIR) {
+ if (file->typeflag & (FILE_TYPE_BLENDERLIB | FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP)) {
+ if (!(filter->filter & (FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP))) {
+ is_filtered = false;
+ }
+ }
+ else {
+ if (!(filter->filter & FILE_TYPE_FOLDER)) {
+ is_filtered = false;
+ }
}
}
else {
- if (!(filter->filter & FILE_TYPE_FOLDER)) {
+ if (!(file->typeflag & filter->filter)) {
is_filtered = false;
}
}
}
- else {
- if (!(file->typeflag & filter->filter)) {
- is_filtered = false;
- }
- }
if (is_filtered && (filter->filter_search[0] != '\0')) {
if (fnmatch(filter->filter_search, file->relpath, FNM_CASEFOLD) != 0) {
is_filtered = false;
@@ -631,28 +635,31 @@ static bool is_filtered_lib(FileListInternEntry *file, const char *root, FileLis
if (BLO_library_path_explode(path, dir, &group, &name)) {
is_filtered = !is_hidden_file(file->relpath, filter);
- if (is_filtered && filter->filter && !FILENAME_IS_CURRPAR(file->relpath)) {
- if (file->typeflag & FILE_TYPE_DIR) {
- if (file->typeflag & (FILE_TYPE_BLENDERLIB | FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP)) {
- if (!(filter->filter & (FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP))) {
- is_filtered = false;
+ if (is_filtered && (filter->flags & FLF_DO_FILTER) && !FILENAME_IS_CURRPAR(file->relpath)) {
+ /* We only check for types if some type are enabled in filtering. */
+ if (filter->filter || filter->filter_id) {
+ if (file->typeflag & FILE_TYPE_DIR) {
+ if (file->typeflag & (FILE_TYPE_BLENDERLIB | FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP)) {
+ if (!(filter->filter & (FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP))) {
+ is_filtered = false;
+ }
}
- }
- else {
- if (!(filter->filter & FILE_TYPE_FOLDER)) {
- is_filtered = false;
+ else {
+ if (!(filter->filter & FILE_TYPE_FOLDER)) {
+ is_filtered = false;
+ }
}
}
- }
- if (is_filtered && group) {
- if (!name && (filter->flags & FLF_HIDE_LIB_DIR)) {
- is_filtered = false;
- }
- else {
- unsigned int filter_id = groupname_to_filter_id(group);
- if (!(filter_id & filter->filter_id)) {
+ if (is_filtered && group) {
+ if (!name && (filter->flags & FLF_HIDE_LIB_DIR)) {
is_filtered = false;
}
+ else {
+ unsigned int filter_id = groupname_to_filter_id(group);
+ if (!(filter_id & filter->filter_id)) {
+ is_filtered = false;
+ }
+ }
}
}
if (is_filtered && (filter->filter_search[0] != '\0')) {
@@ -729,12 +736,17 @@ void filelist_filter(FileList *filelist)
MEM_freeN(filtered_tmp);
}
-void filelist_setfilter_options(FileList *filelist, const bool hide_dot, const bool hide_parent,
+void filelist_setfilter_options(FileList *filelist, const bool do_filter,
+ const bool hide_dot, const bool hide_parent,
const unsigned int filter, const unsigned int filter_id,
const char *filter_glob, const char *filter_search)
{
bool update = false;
+ if (((filelist->filter_data.flags & FLF_DO_FILTER) != 0) != (do_filter != 0)) {
+ filelist->filter_data.flags ^= FLF_DO_FILTER;
+ update = true;
+ }
if (((filelist->filter_data.flags & FLF_HIDE_DOT) != 0) != (hide_dot != 0)) {
filelist->filter_data.flags ^= FLF_HIDE_DOT;
update = true;
@@ -1104,7 +1116,10 @@ static void filelist_cache_preview_runf(TaskPool *__restrict pool, void *taskdat
preview->img = IMB_thumb_manage(preview->path, THB_LARGE, source);
IMB_thumb_path_unlock(preview->path);
- preview->flags = 0; /* Used to tell free func to not free anything! */
+ /* Used to tell free func to not free anything.
+ * Note that we do not care about cas result here,
+ * we only want value attribution itself to be atomic (and memory barier).*/
+ atomic_cas_uint32(&preview->flags, preview->flags, 0);
BLI_thread_queue_push(cache->previews_done, preview);
// printf("%s: End (%d)...\n", __func__, threadid);
@@ -1979,9 +1994,7 @@ int ED_path_extension_type(const char *path)
else if (BLI_testextensie(path, ".abc")) {
return FILE_TYPE_ALEMBIC;
}
- else if (BLI_testextensie_array(path, imb_ext_image) ||
- (G.have_quicktime && BLI_testextensie_array(path, imb_ext_image_qt)))
- {
+ else if (BLI_testextensie_array(path, imb_ext_image)) {
return FILE_TYPE_IMAGE;
}
else if (BLI_testextensie(path, ".ogg")) {
diff --git a/source/blender/editors/space_file/filelist.h b/source/blender/editors/space_file/filelist.h
index f4304681780..4e9c1e0dd1d 100644
--- a/source/blender/editors/space_file/filelist.h
+++ b/source/blender/editors/space_file/filelist.h
@@ -68,7 +68,8 @@ int folderlist_clear_next(struct SpaceFile *sfile);
void filelist_setsorting(struct FileList *filelist, const short sort);
void filelist_sort(struct FileList *filelist);
-void filelist_setfilter_options(struct FileList *filelist, const bool hide_dot, const bool hide_parent,
+void filelist_setfilter_options(struct FileList *filelist, const bool do_filter,
+ const bool hide_dot, const bool hide_parent,
const unsigned int filter, const unsigned int filter_id,
const char *filter_glob, const char *filter_search);
void filelist_filter(struct FileList *filelist);
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 269b1146ba0..6e4815af032 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -223,9 +223,10 @@ static void file_refresh(const bContext *C, ScrArea *sa)
filelist_setdir(sfile->files, params->dir);
filelist_setrecursion(sfile->files, params->recursion_level);
filelist_setsorting(sfile->files, params->sort);
- filelist_setfilter_options(sfile->files, (params->flag & FILE_HIDE_DOT) != 0,
+ filelist_setfilter_options(sfile->files, (params->flag & FILE_FILTER) != 0,
+ (params->flag & FILE_HIDE_DOT) != 0,
false, /* TODO hide_parent, should be controllable? */
- (params->flag & FILE_FILTER) ? params->filter : 0,
+ params->filter,
params->filter_id,
params->filter_glob,
params->filter_search);
diff --git a/source/blender/editors/space_graph/CMakeLists.txt b/source/blender/editors/space_graph/CMakeLists.txt
index 64ce1704b07..2840324e65e 100644
--- a/source/blender/editors/space_graph/CMakeLists.txt
+++ b/source/blender/editors/space_graph/CMakeLists.txt
@@ -49,7 +49,7 @@ set(SRC
)
if(WITH_AUDASPACE)
- add_definitions(${AUDASPACE_DEFINITIONS})
+ add_definitions(-DWITH_AUDASPACE)
list(APPEND INC_SYS
${AUDASPACE_C_INCLUDE_DIRS}
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index 4a1707a3c63..d917e3b85a2 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -89,7 +89,7 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d)
glLineWidth(1.0f);
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
@@ -221,7 +221,7 @@ static void draw_fcurve_selected_handle_vertices(FCurve *fcu, View2D *v2d, bool
float hcolor[3];
UI_GetThemeColor3fv(sel ? TH_HANDLE_VERTEX_SELECT : TH_HANDLE_VERTEX, hcolor);
immUniform4f("outlineColor", hcolor[0], hcolor[1], hcolor[2], 1.0f);
- immUniformColor3fvAlpha(hcolor, 0.4f);
+ immUniformColor3fvAlpha(hcolor, 0.01f); /* almost invisible - only keep for smoothness */
immBeginAtMost(GWN_PRIM_POINTS, fcu->totvert * 2);
@@ -259,8 +259,8 @@ static void draw_fcurve_handle_vertices(FCurve *fcu, View2D *v2d, bool sel_handl
immBindBuiltinProgram(GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA);
/* set handle size */
- immUniform1f("size", (UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE) + 1.0f) * U.pixelsize);
- immUniform1f("outlineWidth", 1.0f * U.pixelsize);
+ immUniform1f("size", (1.4f * UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE)) * U.pixelsize);
+ immUniform1f("outlineWidth", 1.5f * U.pixelsize);
draw_fcurve_selected_handle_vertices(fcu, v2d, false, sel_handle_only, pos);
draw_fcurve_selected_handle_vertices(fcu, v2d, true, sel_handle_only, pos);
@@ -846,7 +846,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
// return;
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
@@ -967,7 +967,7 @@ void graph_draw_ghost_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
@@ -1039,7 +1039,7 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
/* set color/drawing style for curve itself */
/* draw active F-Curve thicker than the rest to make it stand out */
if (fcu->flag & FCURVE_ACTIVE) {
- glLineWidth(2.0);
+ glLineWidth(2.5);
}
else {
glLineWidth(1.0);
@@ -1053,7 +1053,7 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index 09e38579c21..12d872a3c8a 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -36,7 +36,7 @@
#include <float.h>
#ifdef WITH_AUDASPACE
-# include AUD_SPECIAL_H
+# include <AUD_Special.h>
#endif
#include "MEM_guardedalloc.h"
@@ -196,8 +196,8 @@ static int graphkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
/* set the range directly */
get_graph_keyframe_extents(&ac, &min, &max, NULL, NULL, false, false);
scene->r.flag |= SCER_PRV_RANGE;
- scene->r.psfra = iroundf(min);
- scene->r.pefra = iroundf(max);
+ scene->r.psfra = round_fl_to_int(min);
+ scene->r.pefra = round_fl_to_int(max);
/* set notifier that things have changed */
// XXX err... there's nothing for frame ranges yet, but this should do fine too
@@ -2037,7 +2037,7 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
}
else {
/* Animation Mode - Affects current frame (int) */
- CFRA = iroundf(ked.f1 / ked.i1);
+ CFRA = round_fl_to_int(ked.f1 / ked.i1);
SUBFRA = 0.f;
sipo->cursorVal = ked.f2 / (float)ked.i1;
}
diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c
index 75f0da83e77..5c670a216d8 100644
--- a/source/blender/editors/space_graph/graph_ops.c
+++ b/source/blender/editors/space_graph/graph_ops.c
@@ -94,7 +94,7 @@ static void graphview_cursor_apply(bContext *C, wmOperator *op)
* NOTE: sync this part of the code with ANIM_OT_change_frame
*/
/* 1) frame is rounded to the nearest int, since frames are ints */
- CFRA = iroundf(frame);
+ CFRA = round_fl_to_int(frame);
if (scene->r.flag & SCER_LOCK_FRAME_SELECTION) {
/* Clip to preview range
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index 733008ee478..23c4fbbe45e 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -90,7 +90,7 @@ static void draw_render_info(const bContext *C,
float zoomx,
float zoomy)
{
- Render *re = RE_GetRender(scene->id.name);
+ Render *re = RE_GetSceneRender(scene);
RenderData *rd = RE_engine_get_render_data(re);
Scene *stats_scene = ED_render_job_get_scene(C);
if (stats_scene == NULL) {
@@ -369,7 +369,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d
pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3ub(128, 128, 128);
- imm_draw_line_box(pos, color_rect.xmin, color_rect.ymin, color_rect.xmax, color_rect.ymax);
+ imm_draw_box_wire_2d(pos, color_rect.xmin, color_rect.ymin, color_rect.xmax, color_rect.ymax);
immUnbindProgram();
dx += 1.75f * UI_UNIT_X;
@@ -503,7 +503,7 @@ static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar,
&clip_max_x, &clip_max_y);
if (sima->flag & SI_USE_ALPHA) {
- imm_draw_checker_box(x, y, x + ibuf->x * zoomx, y + ibuf->y * zoomy);
+ imm_draw_box_checker_2d(x, y, x + ibuf->x * zoomx, y + ibuf->y * zoomy);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -689,7 +689,7 @@ void draw_image_sample_line(SpaceImage *sima)
Gwn_VertFormat *format = immVertexFormat();
unsigned int shdr_dashed_pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c
index a3a115b3e6a..fbc67ab8090 100644
--- a/source/blender/editors/space_image/image_edit.c
+++ b/source/blender/editors/space_image/image_edit.c
@@ -377,7 +377,7 @@ bool ED_space_image_show_uvedit(SpaceImage *sima, Object *obedit)
bool ED_space_image_check_show_maskedit(SceneLayer *sl, SpaceImage *sima)
{
/* check editmode - this is reserved for UV editing */
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
if (ob && ob->mode & OB_MODE_EDIT && ED_space_image_show_uvedit(sima, ob)) {
return false;
}
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 2962fa0f961..1dae5aeafa5 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -1101,6 +1101,7 @@ static void image_open_cancel(bContext *UNUSED(C), wmOperator *op)
static void image_sequence_get_frame_ranges(PointerRNA *ptr, ListBase *frames_all)
{
char dir[FILE_MAXDIR];
+ const bool do_frame_range = RNA_boolean_get(ptr, "use_sequence_detection");
ImageFrameRange *frame_range = NULL;
RNA_string_get(ptr, "directory", dir);
@@ -1116,7 +1117,8 @@ static void image_sequence_get_frame_ranges(PointerRNA *ptr, ListBase *frames_al
frame->framenr = BLI_stringdec(filename, head, tail, &digits);
/* still in the same sequence */
- if ((frame_range != NULL) &&
+ if (do_frame_range &&
+ (frame_range != NULL) &&
(STREQLEN(base_head, head, FILE_MAX)) &&
(STREQLEN(base_tail, tail, FILE_MAX)))
{
@@ -1170,6 +1172,7 @@ static int image_sequence_get_len(ListBase *frames, int *ofs)
}
return frame_curr - (*ofs);
}
+ *ofs = 0;
return 0;
}
@@ -1328,7 +1331,12 @@ static int image_open_exec(bContext *C, wmOperator *op)
iuser->frames = frame_seq_len;
iuser->sfra = 1;
iuser->framenr = 1;
- iuser->offset = frame_ofs - 1;
+ if (ima->source == IMA_SRC_MOVIE) {
+ iuser->offset = 0;
+ }
+ else {
+ iuser->offset = frame_ofs - 1;
+ }
iuser->fie_ima = 2;
iuser->scene = scene;
BKE_image_init_imageuser(ima, iuser);
@@ -1451,6 +1459,9 @@ void IMAGE_OT_open(wmOperatorType *ot)
ot, FILE_TYPE_FOLDER | FILE_TYPE_IMAGE | FILE_TYPE_MOVIE, FILE_SPECIAL, FILE_OPENFILE,
WM_FILESEL_FILEPATH | WM_FILESEL_DIRECTORY | WM_FILESEL_FILES | WM_FILESEL_RELPATH,
FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA);
+
+ RNA_def_boolean(ot->srna, "use_sequence_detection", true, "Detect Sequences",
+ "Automatically detect animated sequences in selected images (based on file names)");
}
/******************** Match movie length operator ********************/
@@ -2378,8 +2389,8 @@ static int image_new_exec(bContext *C, wmOperator *op)
Main *bmain;
PointerRNA ptr, idptr;
PropertyRNA *prop;
- char _name[MAX_ID_NAME - 2];
- char *name = _name;
+ char name_buffer[MAX_ID_NAME - 2];
+ const char *name;
float color[4];
int width, height, floatbuf, gen_type, alpha;
int gen_context;
@@ -2392,10 +2403,13 @@ static int image_new_exec(bContext *C, wmOperator *op)
bmain = CTX_data_main(C);
prop = RNA_struct_find_property(op->ptr, "name");
- RNA_property_string_get(op->ptr, prop, name);
+ RNA_property_string_get(op->ptr, prop, name_buffer);
if (!RNA_property_is_set(op->ptr, prop)) {
/* Default value, we can translate! */
- name = (char *)DATA_(name);
+ name = DATA_(name_buffer);
+ }
+ else {
+ name = name_buffer;
}
width = RNA_int_get(op->ptr, "width");
height = RNA_int_get(op->ptr, "height");
@@ -3519,7 +3533,7 @@ static int frame_from_event(bContext *C, const wmEvent *event)
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &viewx, &viewy);
- framenr = iroundf(viewx);
+ framenr = round_fl_to_int(viewx);
}
return framenr;
@@ -3625,7 +3639,7 @@ static int render_border_exec(bContext *C, wmOperator *op)
{
ARegion *ar = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
- Render *re = RE_GetRender(scene->id.name);
+ Render *re = RE_GetSceneRender(scene);
RenderData *rd;
rctf border;
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 4b06cbe6b33..514cb1ab97e 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -536,8 +536,8 @@ static void image_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, co
case ND_TRANSFORM:
case ND_MODIFIER:
{
- SceneLayer *sl = BKE_scene_layer_context_active(scene);
- Object *ob = OBACT_NEW;
+ SceneLayer *sl = BKE_scene_layer_context_active_PLACEHOLDER(scene);
+ Object *ob = OBACT_NEW(sl);
if (ob && (ob == wmn->reference) && (ob->mode & OB_MODE_EDIT)) {
if (sima->lock && (sima->flag & SI_DRAWSHADOW)) {
ED_area_tag_refresh(sa);
diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c
index 0e427623840..b87a0de23b9 100644
--- a/source/blender/editors/space_info/info_ops.c
+++ b/source/blender/editors/space_info/info_ops.c
@@ -162,7 +162,6 @@ static int pack_all_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
packAll(bmain, op->reports, true);
- G.fileflags |= G_AUTOPACK;
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c
index 04790f54057..3fd2805efe0 100644
--- a/source/blender/editors/space_logic/logic_window.c
+++ b/source/blender/editors/space_logic/logic_window.c
@@ -485,7 +485,7 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf
ob= ob->id.next;
}
- for (base = FIRSTBASE_NEW; base; base = base->next) {
+ for (base = FIRSTBASE_NEW(sl); base; base = base->next) {
if ((base->flag & BASE_VISIBLED) && (base->flag & SELECT)) {
if (scavisflag & BUTS_SENS_SEL) base->object->scavisflag |= OB_VIS_SENS;
if (scavisflag & BUTS_CONT_SEL) base->object->scavisflag |= OB_VIS_CONT;
diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c
index d87da323b97..cb20b76a3ee 100644
--- a/source/blender/editors/space_nla/nla_draw.c
+++ b/source/blender/editors/space_nla/nla_draw.c
@@ -56,6 +56,7 @@
#include "BIF_glutil.h"
#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
#include "GPU_draw.h"
#include "WM_types.h"
@@ -107,7 +108,7 @@ static void nla_action_draw_keyframes(AnimData *adt, bAction *act, float y, floa
action_to_keylist(adt, act, &keys, NULL);
BLI_dlrbTree_linkedlist_sync(&keys);
- if (!(act && keys.first))
+ if (ELEM(NULL, act, keys.first))
return;
/* draw a darkened region behind the strips
@@ -135,10 +136,8 @@ static void nla_action_draw_keyframes(AnimData *adt, bAction *act, float y, floa
immUnbindProgram();
/* count keys before drawing */
- unsigned int key_ct = 0;
- for (ActKeyColumn *ak = keys.first; ak; ak = ak->next) {
- key_ct++;
- }
+ /* Note: It's safe to cast DLRBT_Tree, as it's designed to degrade down to a ListBase */
+ unsigned int key_ct = BLI_listbase_count((ListBase *)&keys);
if (key_ct > 0) {
format = immVertexFormat();
@@ -174,12 +173,12 @@ static void nla_actionclip_draw_markers(NlaStrip *strip, float yminc, float ymax
{
const bAction *act = strip->act;
- if (!(act && act->markers.first))
+ if (ELEM(NULL, act, act->markers.first))
return;
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
if (dashed) {
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
@@ -232,6 +231,8 @@ static void nla_strip_draw_markers(NlaStrip *strip, float yminc, float ymaxc)
}
}
}
+
+ glLineWidth(1.0f);
}
/* Strips (Proper) ---------------------- */
@@ -301,9 +302,9 @@ static void nla_strip_get_color_inside(AnimData *adt, NlaStrip *strip, float col
/* helper call for drawing influence/time control curves for a given NLA-strip */
static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc, unsigned int pos)
{
- immUniformColor3f(0.7f, 0.7f, 0.7f);
-
const float yheight = ymaxc - yminc;
+
+ immUniformColor3f(0.7f, 0.7f, 0.7f);
/* draw with AA'd line */
glEnable(GL_LINE_SMOOTH);
@@ -358,18 +359,50 @@ static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc, uns
glDisable(GL_BLEND);
}
+/* helper call to setup dashed-lines for strip outlines */
+static uint nla_draw_use_dashed_outlines(float color[4], bool muted)
+{
+ /* Note that we use dashed shader here, and make it draw solid lines if not muted... */
+ uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
+
+ float viewport_size[4];
+ glGetFloatv(GL_VIEWPORT, viewport_size);
+ immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
+
+ immUniform1i("num_colors", 0); /* Simple dashes. */
+ immUniformColor3fv(color);
+
+ /* line style: dotted for muted */
+ if (muted) {
+ /* dotted - and slightly thicker for readability of the dashes */
+ immUniform1f("dash_width", 5.0f);
+ immUniform1f("dash_factor", 0.4f);
+ glLineWidth(1.5f);
+ }
+ else {
+ /* solid line */
+ immUniform1f("dash_factor", 2.0f);
+ glLineWidth(1.0f);
+ }
+
+ return shdr_pos;
+}
+
/* main call for drawing a single NLA-strip */
static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStrip *strip, View2D *v2d, float yminc, float ymaxc)
{
const bool non_solo = ((adt && (adt->flag & ADT_NLA_SOLO_TRACK)) && (nlt->flag & NLATRACK_SOLO) == 0);
+ const bool muted = ((nlt->flag & NLATRACK_MUTED) || (strip->flag & NLASTRIP_FLAG_MUTED));
float color[4] = {1.0f, 1.0f, 1.0f, 1.0f};
-
+ uint shdr_pos;
+
/* get color of strip */
nla_strip_get_color_inside(adt, strip, color);
-
- uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+
+ shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
-
+
/* draw extrapolation info first (as backdrop)
* - but this should only be drawn if track has some contribution
*/
@@ -459,29 +492,20 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri
color[0] = color[1] = color[2] = 0.0f; /* FIXME: or 1.0f ?? */
}
- /* draw outline */
- /* XXX TODO Was dashed like code below, not implemented for now so kept solid... */
- UI_draw_roundbox_shade_x(false, strip->start, yminc, strip->end, ymaxc, 0.0, 0.0, 0.1, color);
-
- /* restore current vertex format & program (roundbox trashes it) */
- /* Note that we use dahsed shader here, and make it draw solid lines if not muted... */
- shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
-
- float viewport_size[4];
- glGetFloatv(GL_VIEWPORT, viewport_size);
- immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
-
- immUniform1i("num_colors", 0); /* Simple dashes. */
- immUniformColor3fv(color);
-
- /* - line style: dotted for muted */
- if ((nlt->flag & NLATRACK_MUTED) || (strip->flag & NLASTRIP_FLAG_MUTED)) {
- immUniform1f("dash_width", 4.0f);
- immUniform1f("dash_factor", 0.5f);
+ /* draw outline
+ * - dashed-line shader is loaded after this block
+ */
+ if (muted) {
+ /* muted - draw dotted, squarish outline (for simplicity) */
+ shdr_pos = nla_draw_use_dashed_outlines(color, muted);
+ imm_draw_box_wire_2d(shdr_pos, strip->start, yminc, strip->end, ymaxc);
}
else {
- immUniform1f("dash_factor", 2.0f); /* solid line */
+ /* non-muted - draw solid, rounded outline */
+ UI_draw_roundbox_shade_x(false, strip->start, yminc, strip->end, ymaxc, 0.0, 0.0, 0.1, color);
+
+ /* restore current vertex format & program (roundbox trashes it) */
+ shdr_pos = nla_draw_use_dashed_outlines(color, muted);
}
/* if action-clip strip, draw lines delimiting repeats too (in the same color as outline) */
@@ -505,7 +529,7 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri
}
/* or if meta-strip, draw lines delimiting extents of sub-strips (in same color as outline, if more than 1 exists) */
else if ((strip->type == NLASTRIP_TYPE_META) && (strip->strips.first != strip->strips.last)) {
- float y = (ymaxc - yminc) * 0.5f + yminc;
+ const float y = (ymaxc - yminc) * 0.5f + yminc;
immBeginAtMost(GWN_PRIM_LINES, 4 * BLI_listbase_count(&strip->strips)); /* up to 2 lines per strip */
@@ -589,6 +613,7 @@ static void nla_draw_strip_frames_text(NlaTrack *UNUSED(nlt), NlaStrip *strip, V
const float ytol = 1.0f; /* small offset to vertical positioning of text, for legibility */
const char col[4] = {220, 220, 220, 255}; /* light gray */
char numstr[32];
+ size_t numstr_len;
/* Always draw times above the strip, whereas sequencer drew below + above.
* However, we should be fine having everything on top, since these tend to be
@@ -597,7 +622,7 @@ static void nla_draw_strip_frames_text(NlaTrack *UNUSED(nlt), NlaStrip *strip, V
* while also preserving some accuracy, since we do use floats
*/
/* start frame */
- size_t numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%.1f", strip->start);
+ numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%.1f", strip->start);
UI_view2d_text_cache_add(v2d, strip->start - 1.0f, ymaxc + ytol, numstr, numstr_len, col);
/* end frame */
@@ -625,6 +650,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar)
* start of list offset, and the second is as a correction for the scrollers.
*/
int height = ((items * NLACHANNEL_STEP(snla)) + (NLACHANNEL_HEIGHT(snla) * 2));
+
/* don't use totrect set, as the width stays the same
* (NOTE: this is ok here, the configuration is pretty straightforward)
*/
@@ -647,10 +673,11 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar)
{
AnimData *adt = ale->adt;
NlaTrack *nlt = (NlaTrack *)ale->data;
+ NlaStrip *strip;
+ int index;
/* draw each strip in the track (if visible) */
- int index = 1;
- for (NlaStrip *strip = nlt->strips.first; strip; strip = strip->next, index++) {
+ for (strip = nlt->strips.first, index = 1; strip; strip = strip->next, index++) {
if (BKE_nlastrip_within_bounds(strip, v2d->cur.xmin, v2d->cur.xmax)) {
const float xminc = strip->start + text_margin_x;
const float xmaxc = strip->end + text_margin_x;
@@ -744,14 +771,16 @@ void draw_nla_channel_list(const bContext *C, bAnimContext *ac, ARegion *ar)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
+ int filter;
SpaceNla *snla = (SpaceNla *)ac->sl;
View2D *v2d = &ar->v2d;
float y = 0.0f;
+ size_t items;
/* build list of channels to draw */
- int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
- size_t items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
+ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
+ items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
/* Update max-extent of channels here (taking into account scrollers):
* - this is done to allow the channel list to be scrollable, but must be done here
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c
index 1f298373a80..f7f7c82171d 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -365,8 +365,8 @@ static int nlaedit_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
/* set the range directly */
get_nlastrip_extents(&ac, &min, &max, true);
scene->r.flag |= SCER_PRV_RANGE;
- scene->r.psfra = iroundf(min);
- scene->r.pefra = iroundf(max);
+ scene->r.psfra = round_fl_to_int(min);
+ scene->r.pefra = round_fl_to_int(max);
/* set notifier that things have changed */
// XXX err... there's nothing for frame ranges yet, but this should do fine too
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index bee2379cd81..67584fbe1f1 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -2154,8 +2154,9 @@ static void node_composit_backdrop_viewer(SpaceNode *snode, ImBuf *backdrop, bNo
if (node->custom1 == 0) {
const float backdropWidth = backdrop->x;
const float backdropHeight = backdrop->y;
- const float cx = x + snode->zoom * backdropWidth * node->custom3;
+ const float cx = x + snode->zoom * backdropWidth * node->custom3;
const float cy = y + snode->zoom * backdropHeight * node->custom4;
+ const float cross_size = 12 * U.pixelsize;
Gwn_VertFormat *format = immVertexFormat();
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -2165,10 +2166,10 @@ static void node_composit_backdrop_viewer(SpaceNode *snode, ImBuf *backdrop, bNo
immUniformColor3f(1.0f, 1.0f, 1.0f);
immBegin(GWN_PRIM_LINES, 4);
- immVertex2f(pos, cx - 25, cy - 25);
- immVertex2f(pos, cx + 25, cy + 25);
- immVertex2f(pos, cx + 25, cy - 25);
- immVertex2f(pos, cx - 25, cy + 25);
+ immVertex2f(pos, cx - cross_size, cy - cross_size);
+ immVertex2f(pos, cx + cross_size, cy + cross_size);
+ immVertex2f(pos, cx + cross_size, cy - cross_size);
+ immVertex2f(pos, cx - cross_size, cy + cross_size);
immEnd();
immUnbindProgram();
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index d99d1c97653..231039b2e22 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -716,7 +716,7 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv)
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColorShadeAlpha(TH_BACK, -15, +100);
- imm_draw_line_box(pos, draw_rect.xmin, draw_rect.ymin, draw_rect.xmax, draw_rect.ymax);
+ imm_draw_box_wire_2d(pos, draw_rect.xmin, draw_rect.ymin, draw_rect.xmax, draw_rect.ymax);
immUnbindProgram();
}
@@ -1090,7 +1090,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
// BLI_snprintf(showname, sizeof(showname), "[%s]", showname); /* XXX - don't print into self! */
uiDefBut(node->block, UI_BTYPE_LABEL, 0, showname,
- iroundf(rct->xmin + NODE_MARGIN_X), iroundf(centy - NODE_DY * 0.5f),
+ round_fl_to_int(rct->xmin + NODE_MARGIN_X), round_fl_to_int(centy - NODE_DY * 0.5f),
(short)(BLI_rctf_size_x(rct) - 18.0f - 12.0f), (short)NODE_DY,
NULL, 0, 0, 0, 0, "");
}
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index 33382af9087..a8bf68d92e2 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -399,8 +399,8 @@ void ED_node_shader_default(const bContext *C, ID *id)
ma->nodetree = ntree;
if (BKE_scene_uses_blender_eevee(scene)) {
- output_type = SH_NODE_OUTPUT_EEVEE_MATERIAL;
- shader_type = SH_NODE_EEVEE_METALLIC;
+ output_type = SH_NODE_OUTPUT_MATERIAL;
+ shader_type = SH_NODE_BSDF_PRINCIPLED;
}
else if (BKE_scene_use_new_shading_nodes(scene)) {
output_type = SH_NODE_OUTPUT_MATERIAL;
@@ -1326,7 +1326,7 @@ static int node_read_fullsamplelayers_exec(bContext *C, wmOperator *UNUSED(op))
Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
Scene *curscene = CTX_data_scene(C);
- Render *re = RE_NewRender(curscene->id.name);
+ Render *re = RE_NewSceneRender(curscene);
WM_cursor_wait(1);
RE_MergeFullSample(re, bmain, curscene, snode->nodetree);
diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c
index 914f8ffbe10..9d750bfe348 100644
--- a/source/blender/editors/space_node/node_group.c
+++ b/source/blender/editors/space_node/node_group.c
@@ -37,6 +37,7 @@
#include "DNA_anim_types.h"
#include "BLI_listbase.h"
+#include "BLI_linklist.h"
#include "BLI_math.h"
#include "BLT_translation.h"
@@ -186,6 +187,7 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode)
bNode *node, *nextnode;
bNodeTree *ngroup, *wgroup;
ListBase anim_basepaths = {NULL, NULL};
+ LinkNode *nodes_delayed_free = NULL;
ngroup = (bNodeTree *)gnode->id;
@@ -208,8 +210,8 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode)
* This also removes remaining links to and from interface nodes.
*/
if (ELEM(node->type, NODE_GROUP_INPUT, NODE_GROUP_OUTPUT)) {
- nodeFreeNode(wgroup, node);
- continue;
+ /* We must delay removal since sockets will reference this node. see: T52092 */
+ BLI_linklist_prepend(&nodes_delayed_free, node);
}
/* keep track of this node's RNA "base" path (the part of the path identifying the node)
@@ -336,6 +338,11 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode)
}
}
+ while (nodes_delayed_free) {
+ node = BLI_linklist_pop(&nodes_delayed_free);
+ nodeFreeNode(ntree, node);
+ }
+
/* delete the group instance */
nodeFreeNode(ntree, gnode);
diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h
index b425a92f601..12e3c33007e 100644
--- a/source/blender/editors/space_node/node_intern.h
+++ b/source/blender/editors/space_node/node_intern.h
@@ -221,6 +221,9 @@ void NODE_OT_clear_viewer_border(struct wmOperatorType *ot);
/* node_widgets.c */
void NODE_WGT_backdrop_transform(struct wmManipulatorGroupType *wgt);
+void NODE_WGT_backdrop_crop(struct wmManipulatorGroupType *wgt);
+void NODE_WGT_backdrop_sun_beams(struct wmManipulatorGroupType *wgt);
+void NODE_WGT_backdrop_corner_pin(struct wmManipulatorGroupType *wgt);
extern const char *node_context_dir[];
diff --git a/source/blender/editors/space_node/node_manipulators.c b/source/blender/editors/space_node/node_manipulators.c
index 8b4ebd70874..8e736e47963 100644
--- a/source/blender/editors/space_node/node_manipulators.c
+++ b/source/blender/editors/space_node/node_manipulators.c
@@ -22,9 +22,14 @@
* \ingroup spnode
*/
+#include <math.h>
+
#include "BKE_context.h"
#include "BKE_image.h"
+#include "BLI_math_matrix.h"
+#include "BLI_math_vector.h"
+
#include "ED_screen.h"
#include "ED_manipulator_library.h"
@@ -40,6 +45,66 @@
#include "node_intern.h"
+/* -------------------------------------------------------------------- */
+
+/** \name Local Utilities
+ * \{ */
+
+static void node_manipulator_calc_matrix_space(
+ const SpaceNode *snode, const ARegion *ar, float matrix_space[4][4])
+{
+ unit_m4(matrix_space);
+ mul_v3_fl(matrix_space[0], snode->zoom);
+ mul_v3_fl(matrix_space[1], snode->zoom);
+ matrix_space[3][0] = (ar->winx / 2) + snode->xof;
+ matrix_space[3][1] = (ar->winy / 2) + snode->yof;
+}
+
+static void node_manipulator_calc_matrix_space_with_image_dims(
+ const SpaceNode *snode, const ARegion *ar, const float image_dims[2], float matrix_space[4][4])
+{
+ unit_m4(matrix_space);
+ mul_v3_fl(matrix_space[0], snode->zoom * image_dims[0]);
+ mul_v3_fl(matrix_space[1], snode->zoom * image_dims[1]);
+ matrix_space[3][0] = ((ar->winx / 2) + snode->xof) - ((image_dims[0] / 2.0f) * snode->zoom);
+ matrix_space[3][1] = ((ar->winy / 2) + snode->yof) - ((image_dims[1] / 2.0f) * snode->zoom);
+}
+
+/** \} */
+
+
+
+/* -------------------------------------------------------------------- */
+
+/** \name Backdrop Manipulator
+ * \{ */
+
+static void manipulator_node_backdrop_prop_matrix_get(
+ const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop,
+ void *value_p)
+{
+ float (*matrix)[4] = value_p;
+ BLI_assert(mpr_prop->type->array_length == 16);
+ const SpaceNode *snode = mpr_prop->custom_func.user_data;
+ matrix[0][0] = snode->zoom;
+ matrix[1][1] = snode->zoom;
+ matrix[3][0] = snode->xof;
+ matrix[3][1] = snode->yof;
+}
+
+static void manipulator_node_backdrop_prop_matrix_set(
+ const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop,
+ const void *value_p)
+{
+ const float (*matrix)[4] = value_p;
+ BLI_assert(mpr_prop->type->array_length == 16);
+ SpaceNode *snode = mpr_prop->custom_func.user_data;
+ snode->zoom = matrix[0][0];
+ snode->zoom = matrix[1][1];
+ snode->xof = matrix[3][0];
+ snode->yof = matrix[3][1];
+}
+
static bool WIDGETGROUP_node_transform_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
{
SpaceNode *snode = CTX_wm_space_node(C);
@@ -51,7 +116,7 @@ static bool WIDGETGROUP_node_transform_poll(const bContext *C, wmManipulatorGrou
if (snode && snode->edittree && snode->edittree->type == NTREE_COMPOSIT) {
bNode *node = nodeGetActive(snode->edittree);
- if (node && node->type == CMP_NODE_VIEWER) {
+ if (node && ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
return true;
}
}
@@ -63,10 +128,10 @@ static void WIDGETGROUP_node_transform_setup(const bContext *UNUSED(C), wmManipu
{
wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__);
- wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_cage_2d", mgroup, "backdrop_cage", NULL);
+ wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_cage_2d", mgroup, NULL);
RNA_enum_set(wwrapper->manipulator->ptr, "transform",
- ED_MANIPULATOR_RECT_TRANSFORM_FLAG_TRANSLATE | ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM);
+ ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE | ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM);
mgroup->customdata = wwrapper;
}
@@ -94,10 +159,21 @@ static void WIDGETGROUP_node_transform_refresh(const bContext *C, wmManipulatorG
/* need to set property here for undo. TODO would prefer to do this in _init */
SpaceNode *snode = CTX_wm_space_node(C);
+#if 0
PointerRNA nodeptr;
RNA_pointer_create(snode->id, &RNA_SpaceNodeEditor, snode, &nodeptr);
WM_manipulator_target_property_def_rna(cage, "offset", &nodeptr, "backdrop_offset", -1);
WM_manipulator_target_property_def_rna(cage, "scale", &nodeptr, "backdrop_zoom", -1);
+#endif
+
+ WM_manipulator_target_property_def_func(
+ cage, "matrix",
+ &(const struct wmManipulatorPropertyFnParams) {
+ .value_get_fn = manipulator_node_backdrop_prop_matrix_get,
+ .value_set_fn = manipulator_node_backdrop_prop_matrix_set,
+ .range_get_fn = NULL,
+ .user_data = snode,
+ });
}
else {
WM_manipulator_set_flag(cage, WM_MANIPULATOR_HIDDEN, true);
@@ -108,7 +184,7 @@ static void WIDGETGROUP_node_transform_refresh(const bContext *C, wmManipulatorG
void NODE_WGT_backdrop_transform(wmManipulatorGroupType *wgt)
{
- wgt->name = "Backdrop Transform Widgets";
+ wgt->name = "Backdrop Transform Widget";
wgt->idname = "NODE_WGT_backdrop_transform";
wgt->flag |= WM_MANIPULATORGROUPTYPE_PERSISTENT;
@@ -117,3 +193,422 @@ void NODE_WGT_backdrop_transform(wmManipulatorGroupType *wgt)
wgt->setup = WIDGETGROUP_node_transform_setup;
wgt->refresh = WIDGETGROUP_node_transform_refresh;
}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+
+/** \name Crop Manipulator
+ * \{ */
+
+struct NodeCropWidgetGroup {
+ wmManipulator *border;
+
+ struct {
+ float dims[2];
+ } state;
+
+ struct {
+ PointerRNA ptr;
+ PropertyRNA *prop;
+ bContext *context;
+ } update_data;
+};
+
+static void manipulator_node_crop_update(struct NodeCropWidgetGroup *crop_group)
+{
+ RNA_property_update(crop_group->update_data.context, &crop_group->update_data.ptr, crop_group->update_data.prop);
+}
+
+static void two_xy_to_rect(const NodeTwoXYs *nxy, rctf *rect, const float dims[2], bool is_relative)
+{
+ if (is_relative) {
+ rect->xmin = nxy->fac_x1;
+ rect->xmax = nxy->fac_x2;
+ rect->ymin = nxy->fac_y1;
+ rect->ymax = nxy->fac_y2;
+ }
+ else {
+ rect->xmin = nxy->x1 / dims[0];
+ rect->xmax = nxy->x2 / dims[0];
+ rect->ymin = nxy->y1 / dims[1];
+ rect->ymax = nxy->y2 / dims[1];
+ }
+}
+
+static void two_xy_from_rect(NodeTwoXYs *nxy, const rctf *rect, const float dims[2], bool is_relative)
+{
+ if (is_relative) {
+ nxy->fac_x1 = rect->xmin;
+ nxy->fac_x2 = rect->xmax;
+ nxy->fac_y1 = rect->ymin;
+ nxy->fac_y2 = rect->ymax;
+ }
+ else {
+ nxy->x1 = rect->xmin * dims[0];
+ nxy->x2 = rect->xmax * dims[0];
+ nxy->y1 = rect->ymin * dims[1];
+ nxy->y2 = rect->ymax * dims[1];
+ }
+}
+
+/* scale callbacks */
+static void manipulator_node_crop_prop_matrix_get(
+ const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
+ void *value_p)
+{
+ float (*matrix)[4] = value_p;
+ BLI_assert(mpr_prop->type->array_length == 16);
+ struct NodeCropWidgetGroup *crop_group = mpr->parent_mgroup->customdata;
+ const float *dims = crop_group->state.dims;
+ const bNode *node = mpr_prop->custom_func.user_data;
+ const NodeTwoXYs *nxy = node->storage;
+ bool is_relative = (bool)node->custom2;
+ rctf rct;
+ two_xy_to_rect(nxy, &rct, dims, is_relative);
+ matrix[0][0] = BLI_rctf_size_x(&rct);
+ matrix[1][1] = BLI_rctf_size_y(&rct);
+ matrix[3][0] = (BLI_rctf_cent_x(&rct) - 0.5f) * dims[0];
+ matrix[3][1] = (BLI_rctf_cent_y(&rct) - 0.5f) * dims[1];
+}
+
+static void manipulator_node_crop_prop_matrix_set(
+ const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
+ const void *value_p)
+{
+ const float (*matrix)[4] = value_p;
+ BLI_assert(mpr_prop->type->array_length == 16);
+ struct NodeCropWidgetGroup *crop_group = mpr->parent_mgroup->customdata;
+ const float *dims = crop_group->state.dims;
+ bNode *node = mpr_prop->custom_func.user_data;
+ NodeTwoXYs *nxy = node->storage;
+ bool is_relative = (bool)node->custom2;
+ rctf rct;
+ two_xy_to_rect(nxy, &rct, dims, is_relative);
+ BLI_rctf_resize(&rct, matrix[0][0], matrix[1][1]);
+ BLI_rctf_recenter(&rct, (matrix[3][0] / dims[0]) + 0.5f, (matrix[3][1] / dims[1]) + 0.5f);
+ BLI_rctf_isect(&(rctf){.xmin = 0, .ymin = 0, .xmax = 1, .ymax = 1}, &rct, &rct);
+ two_xy_from_rect(nxy, &rct, dims, is_relative);
+ manipulator_node_crop_update(crop_group);
+}
+
+static bool WIDGETGROUP_node_crop_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
+{
+ SpaceNode *snode = CTX_wm_space_node(C);
+
+ if ((snode->flag & SNODE_BACKDRAW) == 0) {
+ return false;
+ }
+
+ if (snode && snode->edittree && snode->edittree->type == NTREE_COMPOSIT) {
+ bNode *node = nodeGetActive(snode->edittree);
+
+ if (node && ELEM(node->type, CMP_NODE_CROP)) {
+ /* ignore 'use_crop_size', we can't usefully edit the crop in this case. */
+ if ((node->custom1 & (0 << 1)) == 0) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+static void WIDGETGROUP_node_crop_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
+{
+ struct NodeCropWidgetGroup *crop_group = MEM_mallocN(sizeof(struct NodeCropWidgetGroup), __func__);
+
+ crop_group->border = WM_manipulator_new("MANIPULATOR_WT_cage_2d", mgroup, NULL);
+
+ RNA_enum_set(crop_group->border->ptr, "transform",
+ ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE | ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE);
+
+ mgroup->customdata = crop_group;
+}
+
+static void WIDGETGROUP_node_crop_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup)
+{
+ ARegion *ar = CTX_wm_region(C);
+ wmManipulator *mpr = mgroup->manipulators.first;
+
+ SpaceNode *snode = CTX_wm_space_node(C);
+
+ node_manipulator_calc_matrix_space(snode, ar, mpr->matrix_space);
+}
+
+static void WIDGETGROUP_node_crop_refresh(const bContext *C, wmManipulatorGroup *mgroup)
+{
+ struct NodeCropWidgetGroup *crop_group = mgroup->customdata;
+ wmManipulator *mpr = crop_group->border;
+
+ void *lock;
+ Image *ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
+ ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
+
+ if (ibuf) {
+ crop_group->state.dims[0] = (ibuf->x > 0) ? ibuf->x : 64.0f;
+ crop_group->state.dims[1] = (ibuf->y > 0) ? ibuf->y : 64.0f;
+
+ RNA_float_set_array(mpr->ptr, "dimensions", crop_group->state.dims);
+ WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false);
+
+ SpaceNode *snode = CTX_wm_space_node(C);
+ bNode *node = nodeGetActive(snode->edittree);
+
+ crop_group->update_data.context = (bContext *)C;
+ RNA_pointer_create((ID *)snode->edittree, &RNA_CompositorNodeCrop, node, &crop_group->update_data.ptr);
+ crop_group->update_data.prop = RNA_struct_find_property(&crop_group->update_data.ptr, "relative");
+
+ WM_manipulator_target_property_def_func(
+ mpr, "matrix",
+ &(const struct wmManipulatorPropertyFnParams) {
+ .value_get_fn = manipulator_node_crop_prop_matrix_get,
+ .value_set_fn = manipulator_node_crop_prop_matrix_set,
+ .range_get_fn = NULL,
+ .user_data = node,
+ });
+ }
+ else {
+ WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true);
+ }
+
+ BKE_image_release_ibuf(ima, ibuf, lock);
+}
+
+void NODE_WGT_backdrop_crop(wmManipulatorGroupType *wgt)
+{
+ wgt->name = "Backdrop Crop Widget";
+ wgt->idname = "NODE_WGT_backdrop_crop";
+
+ wgt->flag |= WM_MANIPULATORGROUPTYPE_PERSISTENT;
+
+ wgt->poll = WIDGETGROUP_node_crop_poll;
+ wgt->setup = WIDGETGROUP_node_crop_setup;
+ wgt->draw_prepare = WIDGETGROUP_node_crop_draw_prepare;
+ wgt->refresh = WIDGETGROUP_node_crop_refresh;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+
+/** \name Sun Beams
+ * \{ */
+
+struct NodeSunBeamsWidgetGroup {
+ wmManipulator *manipulator;
+
+ struct {
+ float dims[2];
+ } state;
+};
+
+static bool WIDGETGROUP_node_sbeam_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
+{
+ SpaceNode *snode = CTX_wm_space_node(C);
+
+ if ((snode->flag & SNODE_BACKDRAW) == 0) {
+ return false;
+ }
+
+ if (snode && snode->edittree && snode->edittree->type == NTREE_COMPOSIT) {
+ bNode *node = nodeGetActive(snode->edittree);
+
+ if (node && ELEM(node->type, CMP_NODE_SUNBEAMS)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+static void WIDGETGROUP_node_sbeam_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
+{
+ struct NodeSunBeamsWidgetGroup *sbeam_group = MEM_mallocN(sizeof(struct NodeSunBeamsWidgetGroup), __func__);
+
+ sbeam_group->manipulator = WM_manipulator_new("MANIPULATOR_WT_grab_3d", mgroup, NULL);
+ wmManipulator *mpr = sbeam_group->manipulator;
+
+ RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_GRAB_STYLE_CROSS_2D);
+
+ mpr->scale_basis = 0.05f;
+
+ mgroup->customdata = sbeam_group;
+}
+
+static void WIDGETGROUP_node_sbeam_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup)
+{
+ struct NodeSunBeamsWidgetGroup *sbeam_group = mgroup->customdata;
+ ARegion *ar = CTX_wm_region(C);
+ wmManipulator *mpr = mgroup->manipulators.first;
+
+ SpaceNode *snode = CTX_wm_space_node(C);
+
+ node_manipulator_calc_matrix_space_with_image_dims(snode, ar, sbeam_group->state.dims, mpr->matrix_space);
+}
+
+static void WIDGETGROUP_node_sbeam_refresh(const bContext *C, wmManipulatorGroup *mgroup)
+{
+ struct NodeSunBeamsWidgetGroup *sbeam_group = mgroup->customdata;
+ wmManipulator *mpr = sbeam_group->manipulator;
+
+ void *lock;
+ Image *ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
+ ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
+
+ if (ibuf) {
+ sbeam_group->state.dims[0] = (ibuf->x > 0) ? ibuf->x : 64.0f;
+ sbeam_group->state.dims[1] = (ibuf->y > 0) ? ibuf->y : 64.0f;
+
+ SpaceNode *snode = CTX_wm_space_node(C);
+ bNode *node = nodeGetActive(snode->edittree);
+
+ /* need to set property here for undo. TODO would prefer to do this in _init */
+ PointerRNA nodeptr;
+ RNA_pointer_create((ID *)snode->edittree, &RNA_CompositorNodeSunBeams, node, &nodeptr);
+ WM_manipulator_target_property_def_rna(mpr, "offset", &nodeptr, "source", -1);
+
+ WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_MODAL, true);
+ }
+ else {
+ WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true);
+ }
+
+ BKE_image_release_ibuf(ima, ibuf, lock);
+}
+
+void NODE_WGT_backdrop_sun_beams(wmManipulatorGroupType *wgt)
+{
+ wgt->name = "Sun Beams Widget";
+ wgt->idname = "NODE_WGT_sbeam";
+
+ wgt->flag |= WM_MANIPULATORGROUPTYPE_PERSISTENT;
+
+ wgt->poll = WIDGETGROUP_node_sbeam_poll;
+ wgt->setup = WIDGETGROUP_node_sbeam_setup;
+ wgt->draw_prepare = WIDGETGROUP_node_sbeam_draw_prepare;
+ wgt->refresh = WIDGETGROUP_node_sbeam_refresh;
+}
+
+/** \} */
+
+
+
+/* -------------------------------------------------------------------- */
+
+/** \name Corner Pin
+ * \{ */
+
+struct NodeCornerPinWidgetGroup {
+ wmManipulator *manipulators[4];
+
+ struct {
+ float dims[2];
+ } state;
+};
+
+static bool WIDGETGROUP_node_corner_pin_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
+{
+ SpaceNode *snode = CTX_wm_space_node(C);
+
+ if ((snode->flag & SNODE_BACKDRAW) == 0) {
+ return false;
+ }
+
+ if (snode && snode->edittree && snode->edittree->type == NTREE_COMPOSIT) {
+ bNode *node = nodeGetActive(snode->edittree);
+
+ if (node && ELEM(node->type, CMP_NODE_CORNERPIN)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+static void WIDGETGROUP_node_corner_pin_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
+{
+ struct NodeCornerPinWidgetGroup *cpin_group = MEM_mallocN(sizeof(struct NodeCornerPinWidgetGroup), __func__);
+ const wmManipulatorType *wt_grab_3d = WM_manipulatortype_find("MANIPULATOR_WT_grab_3d", false);
+
+ for (int i = 0; i < 4; i++) {
+ cpin_group->manipulators[i] = WM_manipulator_new_ptr(wt_grab_3d, mgroup, NULL);
+ wmManipulator *mpr = cpin_group->manipulators[i];
+
+ RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_GRAB_STYLE_CROSS_2D);
+
+ mpr->scale_basis = 0.01f;
+ }
+
+ mgroup->customdata = cpin_group;
+}
+
+static void WIDGETGROUP_node_corner_pin_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup)
+{
+ struct NodeCornerPinWidgetGroup *cpin_group = mgroup->customdata;
+ ARegion *ar = CTX_wm_region(C);
+
+ SpaceNode *snode = CTX_wm_space_node(C);
+
+ float matrix_space[4][4];
+ node_manipulator_calc_matrix_space_with_image_dims(snode, ar, cpin_group->state.dims, matrix_space);
+
+ for (int i = 0; i < 4; i++) {
+ wmManipulator *mpr = cpin_group->manipulators[i];
+ copy_m4_m4(mpr->matrix_space, matrix_space);
+ }
+}
+
+static void WIDGETGROUP_node_corner_pin_refresh(const bContext *C, wmManipulatorGroup *mgroup)
+{
+ struct NodeCornerPinWidgetGroup *cpin_group = mgroup->customdata;
+
+ void *lock;
+ Image *ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
+ ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
+
+ if (ibuf) {
+ cpin_group->state.dims[0] = (ibuf->x > 0) ? ibuf->x : 64.0f;
+ cpin_group->state.dims[1] = (ibuf->y > 0) ? ibuf->y : 64.0f;
+
+ SpaceNode *snode = CTX_wm_space_node(C);
+ bNode *node = nodeGetActive(snode->edittree);
+
+ /* need to set property here for undo. TODO would prefer to do this in _init */
+ int i = 0;
+ for (bNodeSocket *sock = node->inputs.first; sock && i < 4; sock = sock->next) {
+ if (sock->type == SOCK_VECTOR) {
+ wmManipulator *mpr = cpin_group->manipulators[i++];
+
+ PointerRNA sockptr;
+ RNA_pointer_create((ID *)snode->edittree, &RNA_NodeSocket, sock, &sockptr);
+ WM_manipulator_target_property_def_rna(mpr, "offset", &sockptr, "default_value", -1);
+
+ WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_MODAL, true);
+ }
+ }
+ }
+ else {
+ for (int i = 0; i < 4; i++) {
+ wmManipulator *mpr = cpin_group->manipulators[i];
+ WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true);
+ }
+ }
+
+ BKE_image_release_ibuf(ima, ibuf, lock);
+}
+
+void NODE_WGT_backdrop_corner_pin(wmManipulatorGroupType *wgt)
+{
+ wgt->name = "Corner Pin Widget";
+ wgt->idname = "NODE_WGT_backdrop_corner_pin";
+
+ wgt->flag |= WM_MANIPULATORGROUPTYPE_PERSISTENT;
+
+ wgt->poll = WIDGETGROUP_node_corner_pin_poll;
+ wgt->setup = WIDGETGROUP_node_corner_pin_setup;
+ wgt->draw_prepare = WIDGETGROUP_node_corner_pin_draw_prepare;
+ wgt->refresh = WIDGETGROUP_node_corner_pin_refresh;
+}
+
+/** \} */
diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c
index 5f592431558..3b03399a5e7 100644
--- a/source/blender/editors/space_node/node_relationships.c
+++ b/source/blender/editors/space_node/node_relationships.c
@@ -567,7 +567,13 @@ static void node_link_exit(bContext *C, wmOperator *op, bool apply_links)
ntree->is_updating = true;
for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) {
bNodeLink *link = linkdata->data;
-
+
+ /* See note below, but basically TEST flag means that the link
+ * was connected to output (or to a node which affects the
+ * output).
+ */
+ do_tag_update |= (link->flag & NODE_LINK_TEST) != 0;
+
if (apply_links && link->tosock && link->fromsock) {
/* before actually adding the link,
* let nodes perform special link insertion handling
@@ -593,11 +599,6 @@ static void node_link_exit(bContext *C, wmOperator *op, bool apply_links)
}
}
else {
- /* See note below, but basically TEST flag means that the link
- * was connected to output (or to a node which affects the
- * output).
- */
- do_tag_update |= (link->flag & NODE_LINK_TEST) != 0;
nodeRemLink(ntree, link);
}
}
diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c
index ec525e684b0..5d0877a1eff 100644
--- a/source/blender/editors/space_node/node_templates.c
+++ b/source/blender/editors/space_node/node_templates.c
@@ -683,10 +683,11 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree,
RNA_pointer_create(&ntree->id, &RNA_Node, node, &nodeptr);
/* indented label */
- for (i = 0; i < indent; i++)
+ for (i = 0; i < indent; i++) {
label[i] = ' ';
+ }
label[indent] = '\0';
- BLI_snprintf(label, UI_MAX_NAME_STR, "%s%s:", label, IFACE_(input->name));
+ BLI_snprintf(label + indent, UI_MAX_NAME_STR - indent, "%s:", IFACE_(input->name));
/* split in label and value */
split = uiLayoutSplit(layout, 0.35f, false);
diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c
index c1099f38d92..7cb22dcc570 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -49,8 +49,6 @@
#include "ED_node.h"
#include "ED_render.h"
#include "ED_screen.h"
-#include "WM_api.h"
-#include "WM_types.h"
#include "UI_resources.h"
#include "UI_view2d.h"
@@ -58,6 +56,7 @@
#include "RNA_access.h"
#include "WM_api.h"
+#include "WM_types.h"
#include "node_intern.h" /* own include */
@@ -866,6 +865,9 @@ static void node_widgets(void)
wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(
&(const struct wmManipulatorMapType_Params){SPACE_NODE, RGN_TYPE_WINDOW});
WM_manipulatorgrouptype_append_and_link(mmap_type, NODE_WGT_backdrop_transform);
+ WM_manipulatorgrouptype_append_and_link(mmap_type, NODE_WGT_backdrop_crop);
+ WM_manipulatorgrouptype_append_and_link(mmap_type, NODE_WGT_backdrop_sun_beams);
+ WM_manipulatorgrouptype_append_and_link(mmap_type, NODE_WGT_backdrop_corner_pin);
}
static void node_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id)
diff --git a/source/blender/editors/space_outliner/outliner_collections.c b/source/blender/editors/space_outliner/outliner_collections.c
index 315a3af1898..092909cbcba 100644
--- a/source/blender/editors/space_outliner/outliner_collections.c
+++ b/source/blender/editors/space_outliner/outliner_collections.c
@@ -27,6 +27,7 @@
#include "BKE_context.h"
#include "BKE_collection.h"
#include "BKE_layer.h"
+#include "BKE_main.h"
#include "BKE_report.h"
#include "DEG_depsgraph.h"
@@ -216,6 +217,7 @@ static int collection_unlink_poll(bContext *C)
static int collection_unlink_exec(bContext *C, wmOperator *op)
{
LayerCollection *lc = outliner_collection_active(C);
+ SpaceOops *soops = CTX_wm_space_outliner(C);
if (lc == NULL) {
BKE_report(op->reports, RPT_ERROR, "Active element is not a collection");
@@ -225,6 +227,10 @@ static int collection_unlink_exec(bContext *C, wmOperator *op)
SceneLayer *sl = CTX_data_scene_layer(C);
BKE_collection_unlink(sl, lc);
+ if (soops) {
+ outliner_cleanup_tree(soops);
+ }
+
DEG_relations_tag_update(CTX_data_main(C));
/* TODO(sergey): Use proper flag for tagging here. */
@@ -398,6 +404,82 @@ void OUTLINER_OT_collection_select(wmOperatorType *ot)
"Index of collection to select", 0, INT_MAX);
}
+#define ACTION_DISABLE 0
+#define ACTION_ENABLE 1
+#define ACTION_TOGGLE 2
+
+static int collection_toggle_exec(bContext *C, wmOperator *op)
+{
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+ SceneLayer *scene_layer = CTX_data_scene_layer(C);
+ int action = RNA_enum_get(op->ptr, "action");
+ LayerCollection *layer_collection = CTX_data_layer_collection(C);
+
+ if (layer_collection->flag & COLLECTION_DISABLED) {
+ if (ELEM(action, ACTION_TOGGLE, ACTION_ENABLE)) {
+ BKE_collection_enable(scene_layer, layer_collection);
+ }
+ else { /* ACTION_DISABLE */
+ BKE_reportf(op->reports, RPT_ERROR, "Layer collection %s already disabled",
+ layer_collection->scene_collection->name);
+ return OPERATOR_CANCELLED;
+ }
+ }
+ else {
+ if (ELEM(action, ACTION_TOGGLE, ACTION_DISABLE)) {
+ BKE_collection_disable(scene_layer, layer_collection);
+ }
+ else { /* ACTION_ENABLE */
+ BKE_reportf(op->reports, RPT_ERROR, "Layer collection %s already enabled",
+ layer_collection->scene_collection->name);
+ return OPERATOR_CANCELLED;
+ }
+ }
+
+ DEG_relations_tag_update(bmain);
+ /* TODO(sergey): Use proper flag for tagging here. */
+ DEG_id_tag_update(&scene->id, 0);
+
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, scene);
+
+ return OPERATOR_FINISHED;
+}
+
+void OUTLINER_OT_collection_toggle(wmOperatorType *ot)
+{
+ PropertyRNA *prop;
+
+ static EnumPropertyItem actions_items[] = {
+ {ACTION_DISABLE, "DISABLE", 0, "Disable", "Disable selected markers"},
+ {ACTION_ENABLE, "ENABLE", 0, "Enable", "Enable selected markers"},
+ {ACTION_TOGGLE, "TOGGLE", 0, "Toggle", "Toggle disabled flag for selected markers"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ /* identifiers */
+ ot->name = "Toggle Collection";
+ ot->idname = "OUTLINER_OT_collection_toggle";
+ ot->description = "Deselect collection objects";
+
+ /* api callbacks */
+ ot->exec = collection_toggle_exec;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* properties */
+ prop = RNA_def_int(ot->srna, "collection_index", -1, -1, INT_MAX, "Collection Index", "Index of collection to toggle", 0, INT_MAX);
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+ prop = RNA_def_enum(ot->srna, "action", actions_items, ACTION_TOGGLE, "Action", "Selection action to execute");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+}
+
+#undef ACTION_TOGGLE
+#undef ACTION_ENABLE
+#undef ACTION_DISABLE
+
/* -------------------------------------------------------------------- */
static int stubs_invoke(bContext *UNUSED(C), wmOperator *op, const wmEvent *UNUSED(event))
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 7a1eca0f179..c2414ec6413 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -59,6 +59,7 @@
#include "BKE_object.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
#include "ED_armature.h"
#include "ED_keyframing.h"
@@ -246,6 +247,30 @@ static void restrictbutton_gp_layer_flag_cb(bContext *C, void *UNUSED(poin), voi
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
}
+static void enablebutton_collection_flag_cb(bContext *C, void *poin, void *poin2)
+{
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = poin;
+ LayerCollection *layer_collection = poin2;
+ SceneLayer *scene_layer = BKE_scene_layer_find_from_collection(scene, layer_collection);
+
+ /* We need to toggle the flag since this is called after the flag is already set. */
+ layer_collection->flag ^= COLLECTION_DISABLED;
+
+ if (layer_collection->flag & COLLECTION_DISABLED) {
+ BKE_collection_enable(scene_layer, layer_collection);
+ }
+ else {
+ BKE_collection_disable(scene_layer, layer_collection);
+ }
+
+ DEG_relations_tag_update(bmain);
+ /* TODO(sergey): Use proper flag for tagging here. */
+ DEG_id_tag_update(&scene->id, 0);
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, NULL);
+}
+
static void restrictbutton_collection_flag_cb(bContext *C, void *poin, void *UNUSED(poin2))
{
Scene *scene = poin;
@@ -337,7 +362,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
BLI_strncpy(newname, ebone->name, sizeof(ebone->name));
BLI_strncpy(ebone->name, oldname, sizeof(ebone->name));
ED_armature_bone_rename(obedit->data, oldname, newname);
- WM_event_add_notifier(C, NC_OBJECT | ND_POSE, OBACT_NEW);
+ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, OBACT_NEW(sl));
}
break;
}
@@ -350,7 +375,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
/* always make current object active */
tree_element_active(C, scene, sl, soops, te, OL_SETSEL_NORMAL, true);
- ob = OBACT_NEW;
+ ob = OBACT_NEW(sl);
/* restore bone name */
BLI_strncpy(newname, bone->name, sizeof(bone->name));
@@ -367,7 +392,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
/* always make current pose-bone active */
tree_element_active(C, scene, sl, soops, te, OL_SETSEL_NORMAL, true);
- ob = OBACT_NEW;
+ ob = OBACT_NEW(sl);
BLI_assert(ob->type == OB_ARMATURE);
@@ -559,8 +584,18 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
else if (tselem->type == TSE_LAYER_COLLECTION) {
LayerCollection *collection = te->directdata;
+ const bool is_enabled = (collection->flag & COLLECTION_DISABLED) == 0;
+
UI_block_emboss_set(block, UI_EMBOSS_NONE);
+ bt = uiDefIconButBitS(block, UI_BTYPE_BUT_TOGGLE, COLLECTION_DISABLED, 0,
+ is_enabled ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT,
+ (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_ENABLEX), te->ys, UI_UNIT_X,
+ UI_UNIT_Y, &collection->flag, 0, 0, 0, 0,
+ TIP_("Enable/Disable collection from depsgraph"));
+ UI_but_func_set(bt, enablebutton_collection_flag_cb, scene, collection);
+ UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
+
bt = uiDefIconButBitS(block, UI_BTYPE_ICON_TOGGLE_N, COLLECTION_VISIBLE, 0, ICON_RESTRICT_VIEW_OFF,
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X,
UI_UNIT_Y, &collection->flag, 0, 0, 0, 0,
@@ -1120,7 +1155,10 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto
}
}
else {
- switch (GS(tselem->id->name)) {
+ /* TODO(sergey): Casting to short here just to handle ID_NLA which is
+ * NOT inside of IDType enum.
+ */
+ switch ((short)GS(tselem->id->name)) {
case ID_SCE:
tselem_draw_icon_uibut(&arg, ICON_SCENE_DATA); break;
case ID_ME:
@@ -1190,6 +1228,8 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto
tselem_draw_icon_uibut(&arg, ICON_LINE_DATA); break;
case ID_GD:
tselem_draw_icon_uibut(&arg, ICON_GREASEPENCIL); break;
+ default:
+ break;
}
}
}
@@ -1217,7 +1257,7 @@ static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, Sce
/* active blocks get white circle */
if (tselem->type == 0) {
if (te->idcode == ID_OB) {
- active = (OBACT_NEW == (Object *)tselem->id) ? OL_DRAWSEL_NORMAL : OL_DRAWSEL_NONE;
+ active = (OBACT_NEW(sl) == (Object *)tselem->id) ? OL_DRAWSEL_NORMAL : OL_DRAWSEL_NONE;
}
else if (scene->obedit && scene->obedit->data == tselem->id) {
active = OL_DRAWSEL_NORMAL;
@@ -1323,13 +1363,13 @@ static void outliner_draw_tree_element(
else if (te->idcode == ID_OB) {
Object *ob = (Object *)tselem->id;
- if (ob == OBACT_NEW || (ob->flag & SELECT)) {
+ if (ob == OBACT_NEW(sl) || (ob->flag & SELECT)) {
char col[4] = {0, 0, 0, 0};
/* outliner active ob: always white text, circle color now similar to view3d */
active = OL_DRAWSEL_ACTIVE;
- if (ob == OBACT_NEW) {
+ if (ob == OBACT_NEW(sl)) {
if (ob->flag & SELECT) {
UI_GetThemeColorType4ubv(TH_ACTIVE, SPACE_VIEW3D, col);
col[3] = alpha;
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index 49d7c6856b9..98388ecb3ec 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -986,7 +986,7 @@ static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op))
TreeElement *te;
int xdelta, ytop;
- Object *obact = OBACT_NEW;
+ Object *obact = OBACT_NEW(sl);
if (!obact)
return OPERATOR_CANCELLED;
@@ -994,7 +994,7 @@ static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op))
te = outliner_find_id(so, &so->tree, &obact->id);
- if (obact->type == OB_ARMATURE) {
+ if (te != NULL && obact->type == OB_ARMATURE) {
/* traverse down the bone hierarchy in case of armature */
TreeElement *te_obact = te;
@@ -1846,7 +1846,7 @@ static int outliner_orphans_purge_invoke(bContext *C, wmOperator *op, const wmEv
{
/* present a prompt to informing users that this change is irreversible */
return WM_operator_confirm_message(C, op,
- "Purging unused data-blocks cannot be undone. "
+ "Purging unused data-blocks cannot be undone and saves to current .blend file. "
"Click here to proceed...");
}
@@ -1868,7 +1868,8 @@ void OUTLINER_OT_orphans_purge(wmOperatorType *ot)
/* identifiers */
ot->idname = "OUTLINER_OT_orphans_purge";
ot->name = "Purge All";
- ot->description = "Clear all orphaned data-blocks without any users from the file (cannot be undone)";
+ ot->description = "Clear all orphaned data-blocks without any users from the file "
+ "(cannot be undone, saves to current .blend file)";
/* callbacks */
ot->invoke = outliner_orphans_purge_invoke;
@@ -1903,7 +1904,7 @@ static int parent_drop_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- ED_object_parent_set(op->reports, bmain, scene, ob, par, partype, false, false, NULL);
+ ED_object_parent_set(op->reports, C, scene, ob, par, partype, false, false, NULL);
DEG_relations_tag_update(bmain);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
@@ -1977,7 +1978,7 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
}
if ((par->type != OB_ARMATURE) && (par->type != OB_CURVE) && (par->type != OB_LATTICE)) {
- if (ED_object_parent_set(op->reports, bmain, scene, ob, par, partype, false, false, NULL)) {
+ if (ED_object_parent_set(op->reports, C, scene, ob, par, partype, false, false, NULL)) {
DEG_relations_tag_update(bmain);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, NULL);
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index f046e1c3176..8d93f6bca55 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -144,11 +144,12 @@ typedef enum {
/* size constants */
#define OL_Y_OFFSET 2
-#define OL_TOG_RESTRICT_VIEWX (UI_UNIT_X * 3.0f)
-#define OL_TOG_RESTRICT_SELECTX (UI_UNIT_X * 2.0f)
+#define OL_TOG_RESTRICT_ENABLEX (UI_UNIT_X * 3.0f)
+#define OL_TOG_RESTRICT_VIEWX (UI_UNIT_X * 2.0f)
+#define OL_TOG_RESTRICT_SELECTX UI_UNIT_X
#define OL_TOG_RESTRICT_RENDERX UI_UNIT_X
-#define OL_TOGW OL_TOG_RESTRICT_VIEWX
+#define OL_TOGW OL_TOG_RESTRICT_ENABLEX
#define OL_RNA_COLX (UI_UNIT_X * 15)
#define OL_RNA_COL_SIZEX (UI_UNIT_X * 7.5f)
@@ -318,6 +319,7 @@ struct SceneCollection *outliner_scene_collection_from_tree_element(TreeElement
void OUTLINER_OT_collections_delete(struct wmOperatorType *ot);
void OUTLINER_OT_collection_select(struct wmOperatorType *ot);
+void OUTLINER_OT_collection_toggle(struct wmOperatorType *ot);
void OUTLINER_OT_collection_link(struct wmOperatorType *ot);
void OUTLINER_OT_collection_unlink(struct wmOperatorType *ot);
void OUTLINER_OT_collection_new(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c
index 5466ef1a9ed..6946993d630 100644
--- a/source/blender/editors/space_outliner/outliner_ops.c
+++ b/source/blender/editors/space_outliner/outliner_ops.c
@@ -328,6 +328,7 @@ void outliner_operatortypes(void)
/* collections */
WM_operatortype_append(OUTLINER_OT_collections_delete);
WM_operatortype_append(OUTLINER_OT_collection_select);
+ WM_operatortype_append(OUTLINER_OT_collection_toggle);
WM_operatortype_append(OUTLINER_OT_collection_link);
WM_operatortype_append(OUTLINER_OT_collection_unlink);
WM_operatortype_append(OUTLINER_OT_collection_new);
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 9bdc6cb59f3..a470711d9df 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -103,7 +103,7 @@ static void do_outliner_object_select_recursive(SceneLayer *sl, Object *ob_paren
{
Base *base;
- for (base = FIRSTBASE_NEW; base; base = base->next) {
+ for (base = FIRSTBASE_NEW(sl); base; base = base->next) {
Object *ob = base->object;
if ((((base->flag & BASE_VISIBLED) == 0) && BKE_object_is_child_recursive(ob_parent, ob))) {
ED_object_base_select(base, select ? BA_SELECT : BA_DESELECT);
@@ -151,7 +151,7 @@ static eOLDrawState tree_element_set_active_object(
}
else {
ob = (Object *)outliner_search_back(soops, te, ID_OB);
- if (ob == OBACT_NEW) {
+ if (ob == OBACT_NEW(sl)) {
return OL_DRAWSEL_NONE;
}
}
@@ -209,7 +209,7 @@ static eOLDrawState tree_element_active_material(
/* we search for the object parent */
ob = (Object *)outliner_search_back(soops, te, ID_OB);
// note: ob->matbits can be NULL when a local object points to a library mesh.
- if (ob == NULL || ob != OBACT_NEW || ob->matbits == NULL) {
+ if (ob == NULL || ob != OBACT_NEW(sl) || ob->matbits == NULL) {
return OL_DRAWSEL_NONE; /* just paranoia */
}
@@ -258,7 +258,7 @@ static eOLDrawState tree_element_active_texture(
{
TreeElement *tep;
TreeStoreElem /* *tselem,*/ *tselemp;
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
SpaceButs *sbuts = NULL;
if (ob == NULL) {
@@ -347,7 +347,7 @@ static eOLDrawState tree_element_active_lamp(
/* we search for the object parent */
ob = (Object *)outliner_search_back(soops, te, ID_OB);
- if (ob == NULL || ob != OBACT_NEW) {
+ if (ob == NULL || ob != OBACT_NEW(sl)) {
/* just paranoia */
return OL_DRAWSEL_NONE;
}
@@ -423,7 +423,7 @@ static eOLDrawState tree_element_active_defgroup(
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob);
}
else {
- if (ob == OBACT_NEW)
+ if (ob == OBACT_NEW(sl))
if (ob->actdef == te->index + 1) {
return OL_DRAWSEL_NORMAL;
}
@@ -443,7 +443,7 @@ static eOLDrawState tree_element_active_posegroup(
}
}
else {
- if (ob == OBACT_NEW && ob->pose) {
+ if (ob == OBACT_NEW(sl) && ob->pose) {
if (ob->pose->active_group == te->index + 1) {
return OL_DRAWSEL_NORMAL;
}
@@ -487,7 +487,7 @@ static eOLDrawState tree_element_active_posechannel(
}
}
else {
- if (ob == OBACT_NEW && ob->pose) {
+ if (ob == OBACT_NEW(sl) && ob->pose) {
if (pchan->bone->flag & BONE_SELECTED) {
return OL_DRAWSEL_NORMAL;
}
@@ -504,7 +504,7 @@ static eOLDrawState tree_element_active_bone(
if (set != OL_SETSEL_NONE) {
if (!(bone->flag & BONE_HIDDEN_P)) {
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
if (ob) {
if (set != OL_SETSEL_EXTEND) {
/* single select forces all other bones to get unselected */
@@ -533,7 +533,7 @@ static eOLDrawState tree_element_active_bone(
}
}
else {
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
if (ob && ob->data == arm) {
if (bone->flag & BONE_SELECTED) {
@@ -659,7 +659,12 @@ static eOLDrawState tree_element_active_pose(
{
Object *ob = (Object *)tselem->id;
Base *base = BKE_scene_layer_base_find(sl, ob);
-
+
+ if (base == NULL) {
+ /* Armature not instantiated in current scene (e.g. inside an appended group...). */
+ return OL_DRAWSEL_NONE;
+ }
+
if (set != OL_SETSEL_NONE) {
if (scene->obedit)
ED_object_editmode_exit(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO);
@@ -837,7 +842,7 @@ eOLDrawState tree_element_type_active(
if (set != OL_SETSEL_NONE) {
tree_element_set_active_object(C, scene, sl, soops, te, set, false);
}
- else if (tselem->id == (ID *)OBACT_NEW) {
+ else if (tselem->id == (ID *)OBACT_NEW(sl)) {
return OL_DRAWSEL_NORMAL;
}
break;
@@ -917,8 +922,11 @@ static void outliner_item_activate(
for (gob = gr->gobject.first; gob; gob = gob->next) {
Base *base = BKE_scene_layer_base_find(sl, gob->ob);
- if ((base->flag & BASE_SELECTED) == 0) {
- ED_object_base_select(base, BA_SELECT);
+ /* Object may not be in this scene */
+ if (base != NULL) {
+ if ((base->flag & BASE_SELECTED) == 0) {
+ ED_object_base_select(base, BA_SELECT);
+ }
}
}
}
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index b91ed13370d..f3a5af4b164 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -843,6 +843,8 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor
}
break;
}
+ default:
+ break;
}
}
@@ -1044,6 +1046,12 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
PointerRNA pptr, propptr, *ptr = (PointerRNA *)idv;
PropertyRNA *prop, *iterprop;
PropertyType proptype;
+
+ /* Don't display arrays larger, weak but index is stored as a short,
+ * also the outliner isn't intended for editing such large data-sets. */
+ BLI_STATIC_ASSERT(sizeof(te->index) == 2, "Index is no longer short!");
+ const int tot_limit = SHRT_MAX;
+
int a, tot;
/* we do lazy build, for speed and to avoid infinite recusion */
@@ -1065,6 +1073,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
iterprop = RNA_struct_iterator_property(ptr->type);
tot = RNA_property_collection_length(ptr, iterprop);
+ CLAMP_MAX(tot, tot_limit);
/* auto open these cases */
if (!parent || (RNA_property_type(parent->directdata)) == PROP_POINTER)
@@ -1111,6 +1120,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
}
else if (proptype == PROP_COLLECTION) {
tot = RNA_property_collection_length(ptr, prop);
+ CLAMP_MAX(tot, tot_limit);
if (TSELEM_OPEN(tselem, soops)) {
for (a = 0; a < tot; a++) {
@@ -1123,6 +1133,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
}
else if (ELEM(proptype, PROP_BOOLEAN, PROP_INT, PROP_FLOAT)) {
tot = RNA_property_array_length(ptr, prop);
+ CLAMP_MAX(tot, tot_limit);
if (TSELEM_OPEN(tselem, soops)) {
for (a = 0; a < tot; a++)
@@ -1289,7 +1300,7 @@ static void outliner_add_library_contents(Main *mainvar, SpaceOops *soops, TreeE
ten = outliner_add_element(soops, &te->subtree, lbarray[a], NULL, TSE_ID_BASE, 0);
ten->directdata = lbarray[a];
- ten->name = (char *)BKE_idcode_to_name_plural(GS(id->name));
+ ten->name = BKE_idcode_to_name_plural(GS(id->name));
if (ten->name == NULL)
ten->name = "UNKNOWN";
@@ -1329,7 +1340,7 @@ static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOops *soops)
ten = outliner_add_element(soops, &soops->tree, lbarray[a], NULL, TSE_ID_BASE, 0);
ten->directdata = lbarray[a];
- ten->name = (char *)BKE_idcode_to_name_plural(GS(id->name));
+ ten->name = BKE_idcode_to_name_plural(GS(id->name));
if (ten->name == NULL)
ten->name = "UNKNOWN";
@@ -1862,7 +1873,7 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SceneLayer *sl, SpaceOops
}
}
else if (soops->outlinevis == SO_SAME_TYPE) {
- Object *ob_active = OBACT_NEW;
+ Object *ob_active = OBACT_NEW(sl);
if (ob_active) {
FOREACH_SCENE_OBJECT(scene, ob)
{
@@ -1935,14 +1946,14 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SceneLayer *sl, SpaceOops
outliner_add_orphaned_datablocks(mainvar, soops);
}
else if (soops->outlinevis == SO_ACT_LAYER) {
- outliner_add_collections_act_layer(soops, BKE_scene_layer_context_active(scene));
+ outliner_add_collections_act_layer(soops, sl);
}
else if (soops->outlinevis == SO_COLLECTIONS) {
outliner_add_collections_master(soops, scene);
}
else {
- ten = outliner_add_element(soops, &soops->tree, OBACT_NEW, NULL, 0, 0);
- ten->directdata = BASACT_NEW;
+ ten = outliner_add_element(soops, &soops->tree, OBACT_NEW(sl), NULL, 0, 0);
+ ten->directdata = BASACT_NEW(sl);
}
if ((soops->flag & SO_SKIP_SORT_ALPHA) == 0) {
diff --git a/source/blender/editors/space_sequencer/CMakeLists.txt b/source/blender/editors/space_sequencer/CMakeLists.txt
index 6dce962ee02..6b8108a1265 100644
--- a/source/blender/editors/space_sequencer/CMakeLists.txt
+++ b/source/blender/editors/space_sequencer/CMakeLists.txt
@@ -54,7 +54,7 @@ set(SRC
)
if(WITH_AUDASPACE)
- add_definitions(${AUDASPACE_DEFINITIONS})
+ add_definitions(-DWITH_AUDASPACE)
list(APPEND INC_SYS
${AUDASPACE_C_INCLUDE_DIRS}
diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c
index 46f212e3679..49c687632f8 100644
--- a/source/blender/editors/space_sequencer/sequencer_add.c
+++ b/source/blender/editors/space_sequencer/sequencer_add.c
@@ -69,7 +69,7 @@
#include "BKE_sound.h"
#ifdef WITH_AUDASPACE
-# include AUD_SEQUENCE_H
+# include <AUD_Sequence.h>
#endif
/* own include */
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 9cdb74e02f9..c14e427b133 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -40,6 +40,7 @@
#include "DNA_scene_types.h"
#include "DNA_mask_types.h"
+#include "DNA_object_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "DNA_userdef_types.h"
@@ -643,7 +644,7 @@ static void draw_sequence_extensions(Scene *scene, ARegion *ar, Sequence *seq, u
immUniformColor3ubvAlpha(col, col[3] + 50);
- imm_draw_line_box(pos, (float)(seq->start), y1 - SEQ_STRIP_OFSBOTTOM, x1, y1); /* outline */
+ imm_draw_box_wire_2d(pos, (float)(seq->start), y1 - SEQ_STRIP_OFSBOTTOM, x1, y1); /* outline */
}
if (seq->endofs) {
immUniformColor4ubv(col);
@@ -651,7 +652,7 @@ static void draw_sequence_extensions(Scene *scene, ARegion *ar, Sequence *seq, u
immUniformColor3ubvAlpha(col, col[3] + 50);
- imm_draw_line_box(pos, x2, y2, (float)(seq->start + seq->len), y2 + SEQ_STRIP_OFSBOTTOM); /* outline */
+ imm_draw_box_wire_2d(pos, x2, y2, (float)(seq->start + seq->len), y2 + SEQ_STRIP_OFSBOTTOM); /* outline */
}
if (seq->startofs || seq->endofs) {
@@ -846,7 +847,7 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg
immUniformColor3ubv(col);
}
- imm_draw_line_box(pos, x1, y1, x2, y2); /* outline */
+ imm_draw_box_wire_2d(pos, x1, y1, x2, y2); /* outline */
immUnbindProgram();
@@ -1035,7 +1036,7 @@ static void sequencer_draw_borders(const SpaceSeq *sseq, const View2D *v2d, cons
/* border */
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
@@ -1046,7 +1047,7 @@ static void sequencer_draw_borders(const SpaceSeq *sseq, const View2D *v2d, cons
immUniform1f("dash_width", 6.0f);
immUniform1f("dash_factor", 0.5f);
- imm_draw_line_box(shdr_pos, x1 - 0.5f, y1 - 0.5f, x2 + 0.5f, y2 + 0.5f);
+ imm_draw_box_wire_2d(shdr_pos, x1 - 0.5f, y1 - 0.5f, x2 + 0.5f, y2 + 0.5f);
/* safety border */
if (sseq->flag & SEQ_SHOW_SAFE_MARGINS) {
@@ -1080,7 +1081,7 @@ static void sequencer_draw_background(
/* only draw alpha for main buffer */
if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
if ((sseq->flag & SEQ_USE_ALPHA) && !draw_overlay) {
- imm_draw_checker_box(v2d->tot.xmin, v2d->tot.ymin, v2d->tot.xmax, v2d->tot.ymax);
+ imm_draw_box_checker_2d(v2d->tot.xmin, v2d->tot.ymin, v2d->tot.xmax, v2d->tot.ymax);
}
}
}
@@ -1104,18 +1105,16 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME};
bool draw_metadata = false;
- if (G.is_rendering == false && (scene->r.seq_flag & R_SEQ_GL_PREV) == 0) {
+ if (G.is_rendering == false && (scene->r.seq_prev_type) == OB_RENDER) {
/* stop all running jobs, except screen one. currently previews frustrate Render
* needed to make so sequencer's rendering doesn't conflict with compositor
*/
WM_jobs_kill_type(CTX_wm_manager(C), NULL, WM_JOB_TYPE_COMPOSITE);
- if ((scene->r.seq_flag & R_SEQ_GL_PREV) == 0) {
- /* in case of final rendering used for preview, kill all previews,
- * otherwise threading conflict will happen in rendering module
- */
- WM_jobs_kill_type(CTX_wm_manager(C), NULL, WM_JOB_TYPE_RENDER_PREVIEW);
- }
+ /* in case of final rendering used for preview, kill all previews,
+ * otherwise threading conflict will happen in rendering module
+ */
+ WM_jobs_kill_type(CTX_wm_manager(C), NULL, WM_JOB_TYPE_RENDER_PREVIEW);
}
if ((!draw_overlay || sseq->overlay_type == SEQ_DRAW_OVERLAY_REFERENCE) && !draw_backdrop) {
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 35b54bfd097..407f4306fec 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -727,7 +727,7 @@ static Sequence *cut_seq_hard(Scene *scene, Sequence *seq, int cutframe)
if (!skip_dup) {
/* Duplicate AFTER the first change */
- seqn = BKE_sequence_dupli_recursive(scene, NULL, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM);
+ seqn = BKE_sequence_dupli_recursive(scene, scene, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM);
}
if (seqn) {
@@ -820,7 +820,7 @@ static Sequence *cut_seq_soft(Scene *scene, Sequence *seq, int cutframe)
if (!skip_dup) {
/* Duplicate AFTER the first change */
- seqn = BKE_sequence_dupli_recursive(scene, NULL, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM);
+ seqn = BKE_sequence_dupli_recursive(scene, scene, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM);
}
if (seqn) {
@@ -2139,7 +2139,7 @@ static int sequencer_add_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
if (ed == NULL)
return OPERATOR_CANCELLED;
- BKE_sequence_base_dupli_recursive(scene, NULL, &nseqbase, ed->seqbasep, SEQ_DUPE_CONTEXT);
+ BKE_sequence_base_dupli_recursive(scene, scene, &nseqbase, ed->seqbasep, SEQ_DUPE_CONTEXT, 0);
if (nseqbase.first) {
Sequence *seq = nseqbase.first;
@@ -3177,7 +3177,7 @@ static int sequencer_copy_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- BKE_sequence_base_dupli_recursive(scene, NULL, &nseqbase, ed->seqbasep, SEQ_DUPE_UNIQUE_NAME);
+ BKE_sequence_base_dupli_recursive(scene, scene, &nseqbase, ed->seqbasep, SEQ_DUPE_UNIQUE_NAME, 0);
/* To make sure the copied strips have unique names between each other add
* them temporarily to the end of the original seqbase. (bug 25932)
@@ -3244,7 +3244,7 @@ static int sequencer_paste_exec(bContext *C, wmOperator *UNUSED(op))
ED_sequencer_deselect_all(scene);
ofs = scene->r.cfra - seqbase_clipboard_frame;
- BKE_sequence_base_dupli_recursive(scene, NULL, &nseqbase, &seqbase_clipboard, SEQ_DUPE_UNIQUE_NAME);
+ BKE_sequence_base_dupli_recursive(scene, scene, &nseqbase, &seqbase_clipboard, SEQ_DUPE_UNIQUE_NAME, 0);
/* transform pasted strips before adding */
if (ofs) {
@@ -3489,7 +3489,7 @@ static int sequencer_enable_proxies_exec(bContext *C, wmOperator *op)
bool proxy_50 = RNA_boolean_get(op->ptr, "proxy_50");
bool proxy_75 = RNA_boolean_get(op->ptr, "proxy_75");
bool proxy_100 = RNA_boolean_get(op->ptr, "proxy_100");
- bool override = RNA_boolean_get(op->ptr, "override");
+ bool overwrite = RNA_boolean_get(op->ptr, "overwrite");
bool turnon = true;
if (ed == NULL || !(proxy_25 || proxy_50 || proxy_75 || proxy_100)) {
@@ -3525,7 +3525,7 @@ static int sequencer_enable_proxies_exec(bContext *C, wmOperator *op)
else
seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_100;
- if (!override)
+ if (!overwrite)
seq->strip->proxy->build_flags |= SEQ_PROXY_SKIP_EXISTING;
else
seq->strip->proxy->build_flags &= ~SEQ_PROXY_SKIP_EXISTING;
@@ -3557,7 +3557,7 @@ void SEQUENCER_OT_enable_proxies(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "proxy_50", false, "50%", "");
RNA_def_boolean(ot->srna, "proxy_75", false, "75%", "");
RNA_def_boolean(ot->srna, "proxy_100", false, "100%", "");
- RNA_def_boolean(ot->srna, "override", false, "Override", "");
+ RNA_def_boolean(ot->srna, "overwrite", false, "Overwrite", "");
}
/* change ops */
diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c
index b3ec2948c8c..3b04e6c80cd 100644
--- a/source/blender/editors/space_sequencer/space_sequencer.c
+++ b/source/blender/editors/space_sequencer/space_sequencer.c
@@ -436,6 +436,7 @@ static void sequencer_dropboxes(void)
/* ************* end drop *********** */
+/* DO NOT make this static, this hides the symbol and breaks API generation script. */
const char *sequencer_context_dir[] = {"edit_mask", NULL};
static int sequencer_context(const bContext *C, const char *member, bContextDataResult *result)
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c
index 7b4565d8b66..fcb675abcf2 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -1503,7 +1503,7 @@ void draw_text_main(SpaceText *st, ARegion *ar)
if (margin_column_x >= x) {
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
diff --git a/source/blender/editors/space_text/text_format_pov.c b/source/blender/editors/space_text/text_format_pov.c
index 0d19c503798..1ef3322711c 100644
--- a/source/blender/editors/space_text/text_format_pov.c
+++ b/source/blender/editors/space_text/text_format_pov.c
@@ -49,36 +49,38 @@ static int txtfmt_pov_find_keyword(const char *string)
{
int i, len;
/* Language Directives */
- if (STR_LITERAL_STARTSWITH(string, "append", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "break", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "case", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "debug", len)) i = len;
+ if (STR_LITERAL_STARTSWITH(string, "deprecated", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "persistent", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "statistics", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "version", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "warning", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "declare", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "default", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "deprecated", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "include", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "append", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "elseif", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "debug", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "break", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "else", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "end", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "error", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "fclose", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "fopen", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "for", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "ifndef", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "ifdef", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "if", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "include", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "patch", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "local", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "macro", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "range", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "read", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "render", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "statistics", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "switch", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "undef", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "version", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "warning", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "while", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "write", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "case", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "end", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "for", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "if", len)) i = len;
else i = 0;
/* If next source char is an identifier (eg. 'i' in "definate") no match */
@@ -92,221 +94,275 @@ static int txtfmt_pov_find_reserved_keywords(const char *string)
* list is from...
* http://www.povray.org/documentation/view/3.7.0/212/
*/
+
+ /* Float Functions */
+ if (STR_LITERAL_STARTSWITH(string, "conserve_energy", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "max_intersections", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "dimension_size", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "bitwise_and", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "bitwise_or", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "bitwise_xor", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "file_exists", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "precompute", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "dimensions", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "clipped_by", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "shadowless", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "turb_depth", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "reciprocal", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "quaternion", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "phong_size", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "tesselate", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "save_file", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "load_file", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "max_trace", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "transform", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "translate", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "direction", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "roughness", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "metallic", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "gts_load", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "gts_save", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "location", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "altitude", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "function", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "evaluate", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "inverse", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "collect", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "target", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "albedo", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "rotate", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "matrix", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "look_at", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "jitter", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "angle", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "right", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "scale", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "child", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "crand", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "blink", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "defined", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "degrees", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "inside", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "radians", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "vlength", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "select", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "floor", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "strcmp", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "strlen", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "tessel", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "sturm", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "abs", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "acosh", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "prod", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "with", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "acos", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "asc", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "asinh", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "asin", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "atan2", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "atand", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "atanh", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "atan", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "ceil", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "warp", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "cosh", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "log", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "max", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "min", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "mod", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "pow", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "rand", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "seed", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "form", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "sinh", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "sqrt", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "tanh", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "vdot", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "sin", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "sqr", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "sum", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "pwr", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "tan", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "val", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "cos", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "div", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "exp", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "int", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "sky", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "up", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "ln", len)) i = len;
+ /* Color Identifiers */
+ else if (STR_LITERAL_STARTSWITH(string, "transmit", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "filter", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "srgbft", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "srgbf", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "srgbt", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "rgbft", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "gamma", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "green", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "blue", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "gray", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "srgb", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "sRGB", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "SRGB", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "rgbf", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "rgbt", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "rgb", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "red", len)) i = len;
+ /* Color Spaces */
+ else if (STR_LITERAL_STARTSWITH(string, "pov", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "hsl", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "hsv", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "xyl", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "xyv", len)) i = len;
+ /* Vector Functions */
+ else if (STR_LITERAL_STARTSWITH(string, "vaxis_rotate", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "vturbulence", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "min_extent", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "vnormalize", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "max_extent", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "vrotate", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "vcross", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "trace", len)) i = len;
+ /* String Functions */
+ else if (STR_LITERAL_STARTSWITH(string, "file_time", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "datetime", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "concat", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "strlwr", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "strupr", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "substr", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "vstr", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "chr", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "str", len)) i = len;
+ else i = 0;
+
+ /* If next source char is an identifier (eg. 'i' in "definate") no match */
+ return (i == 0 || text_check_identifier(string[i])) ? -1 : i;
+}
+
+
+static int txtfmt_pov_find_reserved_builtins(const char *string)
+{
+ int i, len;
+
+ /* POV-Ray Built-in Variables
+ * list is from...
+ * http://www.povray.org/documentation/view/3.7.0/212/
+ */
/* Language Keywords */
- if (STR_LITERAL_STARTSWITH(string, "aa_level", len)) i = len;
+ if (STR_LITERAL_STARTSWITH(string, "reflection_exponent", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "area_illumination", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "all_intersections", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "cutaway_textures", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "smooth_triangle", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "lommel_seeliger", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "falloff_angle", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "aa_threshold", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "hypercomplex", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "major_radius", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "max_distance", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "max_iteration", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "colour_space", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "color_space", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "iridescence", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "subsurface", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "scattering", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "absorption", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "accuracy", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "adc_bailout", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "albedo", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "all_intersections", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "translucency", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "all", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "alpha", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "altitude", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "always_sample", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ambient_light", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ambient", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "angle", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "aperture", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "water_level", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "reflection", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "max_extent", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "oren_nayar", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "refraction", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "hierarchy", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "radiosity", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "tolerance", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "interior", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "toroidal", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "emission", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "material", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "internal", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "photons", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "arc_angle", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "area_light", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "area_illumination", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "minnaert", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "texture", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "array", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "assumed_gamma", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "autostop", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "black_hole", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "blur_samples", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "brightness", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "brilliance", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "caustics", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "charset", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "collect", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "component", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "composite", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "confidence", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "conserve_energy", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "contained_by", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "coords", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "count", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "crand", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "cube", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cutaway_textures", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "diffuse", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "direction", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "dispersion_samples", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "dispersion", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "dist_exp", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "distance", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "eccentricity", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "emission", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "error_bound", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "evaluate", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "expand_thresholds", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "exponent", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "exterior", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "extinction", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "face_indices", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "falloff_angle", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "falloff", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "file_gamma", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "flatness", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "planet", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "screw", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "keep", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "flip", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "focal_point", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fog_alt", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fog_offset", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fog_type", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "form", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fresnel", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "function", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "gamma", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "gather", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "global_settings", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "gray_threshold", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "hf_gray_16", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "hierarchy", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "hypercomplex", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "importance", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "inside_vector", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "internal", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "intervals", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ior", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "irid_wavelength", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "irid", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "load_file", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "location", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "move", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "roll", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "look_at", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "looks_like", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "low_error_factor", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "major_radius", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "max_distance", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "max_extent", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "max_gradient", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "max_intersections", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "max_iteration", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "max_sample", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "max_trace_level", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "max_trace", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "maximum_reuse", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "metallic", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "method", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "metric", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "minimum_reuse", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "nearest_count", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "normal_indices", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "normal_vectors", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "now", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "number_of_waves", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "offset", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "open", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "orientation", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pass_through", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "pattern", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "phong_size", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "phong", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "point_at", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pot", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "precision", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "precompute", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pretrace_end", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pretrace_start", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "prod", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pwr", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "quaternion", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "radiosity", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "radius", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ratio", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "reciprocal", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "recursion_limit", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "reflection_exponent", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "reflection", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "refraction", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "width", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "repeat", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "right", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "roughness", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "samples", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "save_file", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "scattering", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "bend", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "size", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sky", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "alpha", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "slice", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "smooth", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "solid", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "spacing", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "specular", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "split_union", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "spotlight", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "strength", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sturm", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sum", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "target", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "texture_list", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "thickness", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "threshold", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tightness", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tolerance", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "toroidal", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ttf", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "turb_depth", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "all", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "now", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "pot", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "type", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "u_steps", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "up", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "use_alpha", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "uv_indices", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "uv_vectors", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "v_steps", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "variance", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "vertex_vectors", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "water_level", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "width", len)) i = len;
-
- else i = 0;
-
- /* If next source char is an identifier (eg. 'i' in "definate") no match */
- return (i == 0 || text_check_identifier(string[i])) ? -1 : i;
-}
-
-
-static int txtfmt_pov_find_reserved_builtins(const char *string)
-{
- int i, len;
-
- /* POV-Ray Built-in Variables
- * list is from...
- * http://www.povray.org/documentation/view/3.7.0/212/
- */
- if (STR_LITERAL_STARTSWITH(string, "clock_delta", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "clock", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "clock_on", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "final_clock", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "final_frame", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "frame_number", len)) i = len;
+ /* Animation Options */
+ else if (STR_LITERAL_STARTSWITH(string, "global_settings", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "input_file_name", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "initial_clock", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "initial_frame", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "frame_number", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "image_height", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "image_width", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "input_file_name", len)) i = len;
- /* Color Identifiers */
- else if (STR_LITERAL_STARTSWITH(string, "blue", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "filter", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "gray", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "green", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "red", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "rgbft", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "rgbf", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "rgbt", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "rgb", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "srgb", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sRGB", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "SRGB", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "srgbft", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "srgbf", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "srgbt", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "transmit", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "final_clock", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "final_frame", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "clock_delta", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "clock_on", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "clock", len)) i = len;
+ /* Spline Identifiers */
+ else if (STR_LITERAL_STARTSWITH(string, "extended_x_spline", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "general_x_spline", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "quadratic_spline", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "basic_x_spline", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "natural_spline", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "linear_spline", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "bezier_spline", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "akima_spline", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "cubic_spline", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "sor_spline", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "tcb_spline", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "linear_sweep", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "conic_sweep", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "b_spline", len)) i = len;
/* Patterns */
- else if (STR_LITERAL_STARTSWITH(string, "agate", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "aoi", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "pigment_pattern", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "image_pattern", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "density_file", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "cylindrical", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "proportion", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "triangular", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "image_map", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "proximity", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "spherical", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "bump_map", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "wrinkles", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "average", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "voronoi", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "masonry", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "binary", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "boxed", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "bozo", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "brick", len)) i = len;
@@ -315,14 +371,11 @@ static int txtfmt_pov_find_reserved_builtins(const char *string)
else if (STR_LITERAL_STARTSWITH(string, "checker", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "crackle", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "cubic", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cylindrical", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "density_file", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "dents", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "facets", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "gradient", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "granite", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "hexagon", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "image_pattern", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "julia", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "leopard", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "magnet", len)) i = len;
@@ -330,13 +383,11 @@ static int txtfmt_pov_find_reserved_builtins(const char *string)
else if (STR_LITERAL_STARTSWITH(string, "marble", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "onion", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "pavement", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pigment_pattern", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "planar", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "quilted", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "radial", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "ripples", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "slope", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "spherical", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "spiral1", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "spiral2", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "spotted", len)) i = len;
@@ -344,97 +395,68 @@ static int txtfmt_pov_find_reserved_builtins(const char *string)
else if (STR_LITERAL_STARTSWITH(string, "tile2", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "tiling", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "tiles", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "triangular", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "waves", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "wood", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "wrinkles", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "agate", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "aoi", len)) i = len;
/* Objects */
- else if (STR_LITERAL_STARTSWITH(string, "background", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "superellipsoid", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "bicubic_patch", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "blob", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "box", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "camera", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cone", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cubic", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "julia_fractal", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "height_field", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "cubic_spline", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "sphere_sweep", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "light_group", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "light_source", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "intersection", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "isosurface", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "background", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "sky_sphere", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "cylinder", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "difference", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "brilliance", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "parametric", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "interunion", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "intermerge", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "polynomial", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "displace", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "specular", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "ambient", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "diffuse", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "polygon", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "quadric", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "quartic", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "rainbow", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "sphere", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "spline", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "prism", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "camera", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "galley", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "cubic", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "phong", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "cone", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "blob", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "box", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "disc", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "fog", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "height_field", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "intersection", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "isosurface", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "julia_fractal", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "lathe", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "light_group", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "light_source", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "merge", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "mesh2", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "mesh", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "object", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "ovus", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "lemon", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "parametric", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "plane", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "poly", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "polygon", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "polynomial", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "prism", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "quadric", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "quartic", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "rainbow", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sky_sphere", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "smooth_triangle", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cubic_spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sphere_sweep", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sphere", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "superellipsoid", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "irid", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "sor", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "text", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "torus", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "triangle", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "union", len)) i = len;
- /* Filetypes */
- else if (STR_LITERAL_STARTSWITH(string, "df3", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "exr", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "gif", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "hdr", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "iff", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "jpeg", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pgm", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "png", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ppm", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sys", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tga", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tiff", len)) i = len;
- /* Spline Identifiers */
- else if (STR_LITERAL_STARTSWITH(string, "b_spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bezier_spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "conic_sweep", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cubic_spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "linear_spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "linear_sweep", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "natural_spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "quadratic_spline", len)) i = len;
- /* Encodings */
- else if (STR_LITERAL_STARTSWITH(string, "ascii", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "utf8", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "uint8", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "uint16be", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "uint16le", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sint8", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sint16be", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sint16le", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sint32be", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sint32le", len)) i = len;
- /* Camera Types */
- else if (STR_LITERAL_STARTSWITH(string, "fisheye", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "mesh_camera", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "omnimax", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "orthographic", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "panoramic", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "perspective", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ultra_wide_angle", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "colour", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "color", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "media", len)) i = len;
/* Built-in Vectors */
else if (STR_LITERAL_STARTSWITH(string, "t", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "u", len)) i = len;
@@ -442,7 +464,6 @@ static int txtfmt_pov_find_reserved_builtins(const char *string)
else if (STR_LITERAL_STARTSWITH(string, "x", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "y", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "z", len)) i = len;
-
else i = 0;
/* If next source char is an identifier (eg. 'i' in "definate") no match */
@@ -465,156 +486,201 @@ static int txtfmt_pov_find_specialvar(const char *string)
{
int i, len;
/* Modifiers */
- if (STR_LITERAL_STARTSWITH(string, "interior_texture", len)) i = len;
+ if (STR_LITERAL_STARTSWITH(string, "dispersion_samples", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "projected_through", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "double_illuminate", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "expand_thresholds", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "media_interaction", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "media_attenuation", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "projected_through", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "low_error_factor", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "recursion_limit", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "interior_texture", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "max_trace_level", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "gray_threshold", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "pretrace_start", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "normal_indices", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "normal_vectors", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "vertex_vectors", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "noise_generator", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "irid_wavelength", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "number_of_waves", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "ambient_light", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "inside_vector", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "face_indices", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "texture_list", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "max_gradient", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "uv_indices", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "uv_vectors", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "fade_distance", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "global_lights", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "no_bump_scale", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "pretrace_end", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "no_radiosity", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "no_reflection", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "assumed_gamma", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "scallop_wave", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "triangle_wave", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "nearest_count", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "maximum_reuse", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "minimum_reuse", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "always_sample", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "translucency", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "eccentricity", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "contained_by", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "inside_point", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "adc_bailout", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "density_map", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "split_union", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "mm_per_unit", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "agate_turb", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "bounded_by", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "brick_size", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bump_map", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bump_size", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "circular", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "clipped_by", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cubic", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "hf_gray_16", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "dispersion", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "extinction", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "thickness", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "color_map", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "color", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "colour_map", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "colour", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "control0", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "control1", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "cubic_wave", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "density_map", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "density", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fade_color", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "fade_colour", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fade_distance", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "fade_power", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "frequency", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "global_lights", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "hollow", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "image_map", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "adaptive", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "interior", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "interpolate", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "inverse", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "jitter", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "lambda", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "map_type", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "material_map", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "material", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "matrix", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "media", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "mm_per_unit", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "mortar", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "no_bump_scale", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "no_image", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "no_radiosity", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "no_reflection", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "no_shadow", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "fade_color", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "normal_map", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "normal", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "octaves", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "omega", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "once", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "orient", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "parallel", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "phase", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "photons", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "pigment_map", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pigment", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "finish", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "poly_wave", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "quick_color", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "quick_colour", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ramp_wave", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "rotate", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "scale", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "scallop_wave", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "shadowless", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sine_wave", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "slope_map", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "subsurface", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "material_map", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "pass_through", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "interpolate", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "texture_map", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "texture", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "transform", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "translate", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "triangle_wave", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "turbulence", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "error_bound", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "brightness", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "use_color", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "use_alpha", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "use_colour", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "use_index", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "uv_mapping", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "warp", len)) i = len;
-
- /* Vector Functions */
- else if (STR_LITERAL_STARTSWITH(string, "max_extent", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "min_extent", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "trace", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "vaxis_rotate", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "vcross", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "vnormalize", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "vrotate", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "vturbulence", len)) i = len;
- /* String Functions */
- else if (STR_LITERAL_STARTSWITH(string, "chr", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "concat", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "datetime", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "str", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "strlwr", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "strupr", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "substr", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "vstr", len)) i = len;
- /* Float Functions */
- else if (STR_LITERAL_STARTSWITH(string, "abs", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "acosh", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "acos", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "asc", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "asinh", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "asin", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "atan2", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "atand", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "atanh", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "atan", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bitwise_and", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bitwise_or", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bitwise_xor", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ceil", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cosh", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cos", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "defined", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "degrees", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "dimension_size", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "dimensions", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "div", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "exp", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "file_exists", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "floor", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "inside", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "int", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ln", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "log", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "max", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "min", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "mod", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pow", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "radians", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "rand", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "seed", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "select", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sinh", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sin", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sqrt", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sqr", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "strcmp", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "strlen", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tanh", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tan", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "val", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "vdot", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "vlength", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "importance", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "max_sample", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "intervals", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "sine_wave", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "slope_map", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "poly_wave", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "no_shadow", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "ramp_wave", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "precision", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "original", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "accuracy", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "map_type", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "no_image", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "distance", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "autostop", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "caustics", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "octaves", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "aa_level", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "frequency", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "fog_offset", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "modulation", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "outbound", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "no_cache", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "pigment", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "charset", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "inbound", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "outside", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "inner", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "turbulence", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "threshold", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "accuracy", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "polarity", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "bump_size", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "circular", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "control0", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "control1", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "maximal", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "minimal", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "fog_type", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "fog_alt", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "samples", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "origin", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "amount", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "adaptive", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "exponent", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "strength", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "density", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "fresnel", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "albinos", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "finish", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "method", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "omega", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "fixed", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "spacing", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "u_steps", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "v_steps", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "offset", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "hollow", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "gather", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "lambda", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "mortar", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "cubic", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "count", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "once", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "orient", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "normal", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "phase", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "ratio", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "open", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "ior", len)) i = len;
+ /* Light Types and options*/
+ else if (STR_LITERAL_STARTSWITH(string, "area_light", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "looks_like", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "fade_power", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "tightness", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "spotlight", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "parallel", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "point_at", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "falloff", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "radius", len)) i = len;
+ /* Camera Types and options*/
+ else if (STR_LITERAL_STARTSWITH(string, "omni_directional_stereo", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "lambert_cylindrical", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "miller_cylindrical", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "lambert_azimuthal", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "ultra_wide_angle", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "camera_direction", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "camera_location ", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "van_der_grinten", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "aitoff_hammer", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "smyth_craster", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "orthographic", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "camera_right", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "blur_samples", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "plate_carree", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "camera_type", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "perspective", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "mesh_camera", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "focal_point", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "balthasart", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "confidence", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "parallaxe", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "hobo_dyer", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "camera_up", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "panoramic", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "eckert_vi", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "eckert_iv", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "mollweide", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "aperture", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "behrmann", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "variance", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "stereo", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "icosa", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "tetra", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "octa", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "mercator", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "omnimax", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "fisheye", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "edwards", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "peters", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "gall", len)) i = len;
else i = 0;
/* If next source char is an identifier (eg. 'i' in "definate") no match */
@@ -625,15 +691,43 @@ static int txtfmt_pov_find_bool(const char *string)
{
int i, len;
/*Built-in Constants*/
- if (STR_LITERAL_STARTSWITH(string, "false", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "no", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "off", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "true", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "yes", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "on", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pi", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tau", len)) i = len;
- else i = 0;
+ if (STR_LITERAL_STARTSWITH(string, "unofficial", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "false", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "no", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "off", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "true", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "yes", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "on", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "pi", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "tau", len)) i = len;
+ /* Encodings */
+ else if (STR_LITERAL_STARTSWITH(string, "sint16be", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "sint16le", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "sint32be", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "sint32le", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "uint16be", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "uint16le", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "bt2020", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "bt709", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "sint8", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "uint8", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "ascii", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "utf8", len)) i = len;
+ /* Filetypes */
+ else if (STR_LITERAL_STARTSWITH(string, "tiff", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "df3", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "exr", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "gif", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "hdr", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "iff", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "jpeg", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "pgm", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "png", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "ppm", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "sys", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "tga", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "ttf", len)) i = len;
+ else i = 0;
/* If next source char is an identifier (eg. 'i' in "Nonetheless") no match */
return (i == 0 || text_check_identifier(string[i])) ? -1 : i;
@@ -645,7 +739,7 @@ static char txtfmt_pov_format_identifier(const char *str)
if ((txtfmt_pov_find_specialvar(str)) != -1) fmt = FMT_TYPE_SPECIAL;
else if ((txtfmt_pov_find_keyword(str)) != -1) fmt = FMT_TYPE_KEYWORD;
else if ((txtfmt_pov_find_reserved_keywords(str)) != -1) fmt = FMT_TYPE_RESERVED;
- else if ((txtfmt_pov_find_reserved_builtins(str)) != -1) fmt = FMT_TYPE_RESERVED;
+ else if ((txtfmt_pov_find_reserved_builtins(str)) != -1) fmt = FMT_TYPE_DIRECTIVE;
else fmt = FMT_TYPE_DEFAULT;
return fmt;
}
@@ -770,7 +864,7 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_
if ((i = txtfmt_pov_find_specialvar(str)) != -1) prev = FMT_TYPE_SPECIAL;
else if ((i = txtfmt_pov_find_keyword(str)) != -1) prev = FMT_TYPE_KEYWORD;
else if ((i = txtfmt_pov_find_reserved_keywords(str)) != -1) prev = FMT_TYPE_RESERVED;
- else if ((i = txtfmt_pov_find_reserved_builtins(str)) != -1) prev = FMT_TYPE_RESERVED;
+ else if ((i = txtfmt_pov_find_reserved_builtins(str)) != -1) prev = FMT_TYPE_DIRECTIVE;
if (i > 0) {
text_format_fill_ascii(&str, &fmt, prev, i);
diff --git a/source/blender/editors/space_text/text_format_pov_ini.c b/source/blender/editors/space_text/text_format_pov_ini.c
index 719f4e3c036..453dd1d748c 100644
--- a/source/blender/editors/space_text/text_format_pov_ini.c
+++ b/source/blender/editors/space_text/text_format_pov_ini.c
@@ -49,36 +49,36 @@ static int txtfmt_ini_find_keyword(const char *string)
{
int i, len;
/* Language Directives */
- if (STR_LITERAL_STARTSWITH(string, "append", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "break", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "case", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "debug", len)) i = len;
+ if (STR_LITERAL_STARTSWITH(string, "deprecated", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "statistics", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "declare", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "default", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "deprecated", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "version", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "warning", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "include", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "fclose", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "ifndef", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "append", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "elseif", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "else", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "end", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "debug", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "error", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fclose", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "fopen", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "for", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "ifdef", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ifndef", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "if", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "include", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "local", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "macro", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "range", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "read", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "render", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "statistics", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "break", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "switch", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "undef", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "version", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "warning", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "while", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "write", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "case", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "else", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "read", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "end", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "for", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "if", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "I", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "S", len)) i = len;
@@ -104,29 +104,54 @@ static int txtfmt_ini_find_reserved(const char *string)
* list is from...
* http://www.povray.org/documentation/view/3.7.0/212/
*/
- if (STR_LITERAL_STARTSWITH(string, "Antialias_Threshold", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Bounding_Method", len)) i = len;
+ if (STR_LITERAL_STARTSWITH(string, "RenderCompleteSoundEnabled", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "Create_Continue_Trace_Log", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "ParseErrorSoundEnabled", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "RenderErrorSoundEnabled", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "HideWhenMainMinimized", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "Antialias_Confidence", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "RenderCompleteSound", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "ParseErrorSound", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "RenderErrorSound", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "UseExtensions", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "ReadWriteSourceDir", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "NormalPositionLeft", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "NormalPositionTop", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "NormalPositionRight", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "NormalPositionBottom", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "Pre_Scene_Command", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "Pre_Frame_Command", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "Post_Scene_Command", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "Post_Frame_Command", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "User_Abort_Command", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "Fatal_Error_Command", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "NormalPositionX", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "NormalPositionY", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "Pre_Scene_Return", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "Pre_Frame_Return", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "Post_Scene_Return", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "Post_Frame_Return", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "User_Abort_Return", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "Fatal_Error_Return", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "Antialias_Threshold", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Antialias_Gamma", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Antialias_Depth", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "clock_delta", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "clock_on", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "clock", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "final_clock", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "final_frame", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "frame_number", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "initial_clock", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "initial_frame", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "image_height", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "image_width", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "input_file_name", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Subset_Start_Frame", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Subset_End_Frame", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "UseToolbar", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "UseTooltips", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Frame_Step", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Cyclic_Animation", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Field_Render", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Odd_Field", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Height", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Width", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "final_clock", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "final_frame", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "frame_number", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "initial_clock", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "initial_frame", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "image_height", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "image_width", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Start_Column", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Start_Row", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "End_Column", len)) i = len;
@@ -134,7 +159,7 @@ static int txtfmt_ini_find_reserved(const char *string)
else if (STR_LITERAL_STARTSWITH(string, "Test_Abort_Count", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Test_Abort", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Continue_Trace", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Create_Continue_Trace_Log", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "Bounding_Method", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Create_Ini", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Display_Gamma", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Display", len)) i = len;
@@ -151,19 +176,6 @@ static int txtfmt_ini_find_reserved(const char *string)
else if (STR_LITERAL_STARTSWITH(string, "Bits_Per_Color", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Compression", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Dither_Method", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Dither", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Pre_Scene_Command", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Pre_Frame_Command", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Post_Scene_Command", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Post_Frame_Command", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "User_Abort_Command", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Fatal_Error_Command", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Pre_Scene_Return", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Pre_Frame_Return", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Post_Scene_Return", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Post_Frame_Return", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "User_Abort_Return", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Fatal_Error_Return", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Include_Header", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Library_Path", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Debug_Console", len)) i = len;
@@ -187,7 +199,9 @@ static int txtfmt_ini_find_reserved(const char *string)
else if (STR_LITERAL_STARTSWITH(string, "Remove_Bounds", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Split_Unions", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Antialias", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "Glare_Desaturation", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Sampling_Method", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "Stochastic_Seed", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Jitter_Amount", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Jitter", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Antialias_Depth", len)) i = len;
@@ -221,25 +235,14 @@ static int txtfmt_ini_find_reserved(const char *string)
else if (STR_LITERAL_STARTSWITH(string, "Band3Width", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Band4Width", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "ShowCmd", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "NormalPositionLeft", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "NormalPositionTop", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "NormalPositionRight", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "NormalPositionBottom", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "UseToolbar", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "UseTooltips", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "NormalPositionX", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "NormalPositionY", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Flags", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Transparency", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Use8BitMode", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "MakeActive", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "KeepAboveMain", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "HideWhenMainMinimized", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "AutoClose", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "PreserveBitmap", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "FontSize", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "FontWeight", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Font", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "KeepMessages", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "AlertSound", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Completion", len)) i = len;
@@ -250,14 +253,6 @@ static int txtfmt_ini_find_reserved(const char *string)
else if (STR_LITERAL_STARTSWITH(string, "PreventSleep", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "NoShelloutWait", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "SystemNoActive", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "RenderCompleteSoundEnabled", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ParseErrorSoundEnabled", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "RenderErrorSoundEnabled", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "RenderCompleteSound", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ParseErrorSound", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "RenderErrorSound", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "UseExtensions", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ReadWriteSourceDir", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "NoShellOuts", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "VideoSource", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "SceneFile", len)) i = len;
@@ -269,6 +264,14 @@ static int txtfmt_ini_find_reserved(const char *string)
else if (STR_LITERAL_STARTSWITH(string, "RenderwinClose", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Append_File", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "Warning Level", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "clock_delta", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "clock_on", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "clock", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "Height", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "Width", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "Dither", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "Flags", len)) i = len;
+ else if (STR_LITERAL_STARTSWITH(string, "Font", len)) i = len;
/* Filetypes */
else if (STR_LITERAL_STARTSWITH(string, "df3", len)) i = len;
else if (STR_LITERAL_STARTSWITH(string, "exr", len)) i = len;
diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c
index 4672cc073fc..7ecb5cb072d 100644
--- a/source/blender/editors/space_time/space_time.c
+++ b/source/blender/editors/space_time/space_time.c
@@ -301,6 +301,8 @@ static void time_draw_idblock_keyframes(View2D *v2d, ID *id, short onlysel, cons
case ID_CF:
cachefile_to_keylist(&ads, (CacheFile *)id, &keys, NULL);
break;
+ default:
+ break;
}
/* build linked-list for searching */
@@ -331,9 +333,7 @@ static void time_draw_idblock_keyframes(View2D *v2d, ID *id, short onlysel, cons
immBeginAtMost(GWN_PRIM_LINES, max_len * 2);
- for (; (ak) && (ak->cfra <= v2d->cur.xmax);
- ak = ak->next)
- {
+ for (; (ak) && (ak->cfra <= v2d->cur.xmax); ak = ak->next) {
immVertex2f(pos, ak->cfra, ymin);
immVertex2f(pos, ak->cfra, ymax);
}
diff --git a/source/blender/editors/space_view3d/CMakeLists.txt b/source/blender/editors/space_view3d/CMakeLists.txt
index af4c220ed46..db79d578b5d 100644
--- a/source/blender/editors/space_view3d/CMakeLists.txt
+++ b/source/blender/editors/space_view3d/CMakeLists.txt
@@ -59,7 +59,11 @@ set(SRC
view3d_walk.c
view3d_header.c
view3d_iterators.c
- view3d_manipulators.c
+ view3d_manipulator_armature.c
+ view3d_manipulator_camera.c
+ view3d_manipulator_empty.c
+ view3d_manipulator_forcefield.c
+ view3d_manipulator_lamp.c
view3d_ops.c
view3d_project.c
view3d_ruler.c
diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c
index 5845a53055c..b4bd425b038 100644
--- a/source/blender/editors/space_view3d/drawarmature.c
+++ b/source/blender/editors/space_view3d/drawarmature.c
@@ -54,6 +54,9 @@
#include "BKE_modifier.h"
#include "BKE_nla.h"
#include "BKE_curve.h"
+#include "BKE_context.h"
+
+#include "DEG_depsgraph.h"
#include "BIF_glutil.h"
@@ -408,11 +411,11 @@ static void drawsolidcube_size(float xsize, float ysize, float zsize)
gpuScale3f(xsize, ysize, zsize);
if (flat_color) {
- Batch_set_builtin_program(&batch, GPU_SHADER_3D_UNIFORM_COLOR);
+ GWN_batch_program_set_builtin(&batch, GPU_SHADER_3D_UNIFORM_COLOR);
}
else {
/* TODO replace with good default lighting shader ? */
- Batch_set_builtin_program(&batch, GPU_SHADER_SIMPLE_LIGHTING);
+ GWN_batch_program_set_builtin(&batch, GPU_SHADER_SIMPLE_LIGHTING);
GWN_batch_uniform_3fv(&batch, "light", light_vec);
}
GWN_batch_uniform_4fv(&batch, "color", fcolor);
@@ -436,7 +439,7 @@ static void drawcube_size(float xsize, float ysize, float zsize)
/* Elements */
GWN_indexbuf_init(&elb, GWN_PRIM_LINES, 12, 8);
for (int i = 0; i < 12; ++i) {
- GWN_indexbuf_add_line_verts(&elb, cube_wire[i*2], cube_wire[i*2+1]);
+ GWN_indexbuf_add_line_verts(&elb, cube_wire[i * 2], cube_wire[i * 2 + 1]);
}
GWN_indexbuf_build_in_place(&elb, &el);
@@ -448,7 +451,7 @@ static void drawcube_size(float xsize, float ysize, float zsize)
}
GWN_batch_init(&batch, GWN_PRIM_LINES, &vbo, &el);
- Batch_set_builtin_program(&batch, GPU_SHADER_3D_UNIFORM_COLOR);
+ GWN_batch_program_set_builtin(&batch, GPU_SHADER_3D_UNIFORM_COLOR);
}
gpuPushMatrix();
@@ -504,7 +507,7 @@ static void draw_bonevert(void)
}
GWN_batch_init(&batch, GWN_PRIM_LINES, &vbo, NULL);
- Batch_set_builtin_program(&batch, GPU_SHADER_3D_UNIFORM_COLOR);
+ GWN_batch_program_set_builtin(&batch, GPU_SHADER_3D_UNIFORM_COLOR);
}
GWN_batch_program_use_begin(&batch);
@@ -514,18 +517,18 @@ static void draw_bonevert(void)
static void draw_bonevert_solid(void)
{
- Gwn_Batch *batch = Batch_get_sphere(0);
+ Gwn_Batch *batch = GPU_batch_preset_sphere(0);
const float light_vec[3] = {0.0f, 0.0f, 1.0f};
gpuPushMatrix();
gpuScaleUniform(0.05);
if (flat_color) {
- Batch_set_builtin_program(batch, GPU_SHADER_3D_UNIFORM_COLOR);
+ GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR);
}
else {
/* TODO replace with good default lighting shader ? */
- Batch_set_builtin_program(batch, GPU_SHADER_SIMPLE_LIGHTING);
+ GWN_batch_program_set_builtin(batch, GPU_SHADER_SIMPLE_LIGHTING);
GWN_batch_uniform_3fv(batch, "light", light_vec);
}
GWN_batch_uniform_4fv(batch, "color", fcolor);
@@ -588,7 +591,7 @@ static void draw_bone_octahedral(void)
/* Elements */
GWN_indexbuf_init(&elb, GWN_PRIM_LINES, 12, 6);
for (int i = 0; i < 12; ++i) {
- GWN_indexbuf_add_line_verts(&elb, bone_octahedral_wire[i*2], bone_octahedral_wire[i*2+1]);
+ GWN_indexbuf_add_line_verts(&elb, bone_octahedral_wire[i * 2], bone_octahedral_wire[i * 2 + 1]);
}
GWN_indexbuf_build_in_place(&elb, &el);
@@ -600,7 +603,7 @@ static void draw_bone_octahedral(void)
}
GWN_batch_init(&batch, GWN_PRIM_LINES, &vbo, &el);
- Batch_set_builtin_program(&batch, GPU_SHADER_3D_UNIFORM_COLOR);
+ GWN_batch_program_set_builtin(&batch, GPU_SHADER_3D_UNIFORM_COLOR);
}
GWN_batch_program_use_begin(&batch);
@@ -637,11 +640,11 @@ static void draw_bone_solid_octahedral(void)
}
if (flat_color) {
- Batch_set_builtin_program(&batch, GPU_SHADER_3D_UNIFORM_COLOR);
+ GWN_batch_program_set_builtin(&batch, GPU_SHADER_3D_UNIFORM_COLOR);
}
else {
/* TODO replace with good default lighting shader ? */
- Batch_set_builtin_program(&batch, GPU_SHADER_SIMPLE_LIGHTING);
+ GWN_batch_program_set_builtin(&batch, GPU_SHADER_SIMPLE_LIGHTING);
GWN_batch_uniform_3fv(&batch, "light", light_vec);
}
GWN_batch_uniform_4fv(&batch, "color", fcolor);
@@ -935,7 +938,7 @@ static void draw_sphere_bone_wire(float smat[4][4], float imat[4][4],
/* base */
if (armflag & ARM_EDITMODE) {
- if (boneflag & BONE_SELECTED){
+ if (boneflag & BONE_SELECTED) {
UI_GetThemeColor4fv(TH_SELECT, fcolor);
}
else {
@@ -990,13 +993,13 @@ static void draw_sphere_bone_wire(float smat[4][4], float imat[4][4],
static void draw_sphere_bone(const short dt, int armflag, int boneflag, short constflag, unsigned int id,
bPoseChannel *pchan, EditBone *ebone)
{
- Gwn_Batch *sphere = Batch_get_sphere(1);
+ Gwn_Batch *sphere = GPU_batch_preset_sphere(1);
float head, tail, length;
float fac1, fac2, size1, size2;
const float light_vec[3] = {0.0f, 0.0f, 1.0f};
/* dt is always OB_SOlID */
- Batch_set_builtin_program(sphere, GPU_SHADER_SIMPLE_LIGHTING);
+ GWN_batch_program_set_builtin(sphere, GPU_SHADER_SIMPLE_LIGHTING);
GWN_batch_uniform_3fv(sphere, "light", light_vec);
gpuPushMatrix();
@@ -1607,8 +1610,10 @@ static void draw_bone(const short dt, int armflag, int boneflag, short constflag
}
}
-static void draw_custom_bone(Scene *scene, SceneLayer *sl, View3D *v3d, RegionView3D *rv3d, Object *ob,
- const short dt, int armflag, int boneflag, unsigned int id, float length)
+static void draw_custom_bone(
+ const struct EvaluationContext *eval_ctx,
+ Scene *scene, SceneLayer *sl, View3D *v3d, RegionView3D *rv3d, Object *ob,
+ const short dt, int armflag, int boneflag, unsigned int id, float length)
{
if (ob == NULL) return;
@@ -1623,7 +1628,7 @@ static void draw_custom_bone(Scene *scene, SceneLayer *sl, View3D *v3d, RegionVi
GPU_select_load_id((GLuint) id | BONESEL_BONE);
}
- draw_object_instance(scene, sl, v3d, rv3d, ob, dt, armflag & ARM_POSEMODE, fcolor);
+ draw_object_instance(eval_ctx, scene, sl, v3d, rv3d, ob, dt, armflag & ARM_POSEMODE, fcolor);
}
@@ -1634,7 +1639,7 @@ static void pchan_draw_IK_root_lines(bPoseChannel *pchan, short only_temp)
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
@@ -1733,7 +1738,7 @@ static void imm_sphere_project(unsigned int pos, float ax, float az)
static void draw_dof_ellipse(unsigned int pos, float ax, float az)
{
const int n = 16;
- const int tri = n*n - 2*n + 1; /* Yay fancy math ! */
+ const int tri = n * n - 2 * n + 1; /* Yay fancy math ! */
const float staticSine[16] = {
0.0f, 0.104528463268f, 0.207911690818f, 0.309016994375f,
0.406736643076f, 0.5f, 0.587785252292f, 0.669130606359f,
@@ -1750,7 +1755,7 @@ static void draw_dof_ellipse(unsigned int pos, float ax, float az)
immUniformColor4ub(70, 70, 70, 50);
- immBegin(GWN_PRIM_TRIS, tri*3);
+ immBegin(GWN_PRIM_TRIS, tri * 3);
pz = 0.0f;
for (i = 1; i < n; i++) {
z = staticSine[i];
@@ -1927,9 +1932,10 @@ static void bone_matrix_translate_y(float mat[4][4], float y)
}
/* assumes object is Armature with pose */
-static void draw_pose_bones(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, Base *base,
- const short dt, const unsigned char ob_wire_col[4],
- const bool do_const_color, const bool is_outline)
+static void draw_pose_bones(
+ const struct EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, Base *base,
+ const short dt, const unsigned char ob_wire_col[4],
+ const bool do_const_color, const bool is_outline)
{
RegionView3D *rv3d = ar->regiondata;
Object *ob = base->object;
@@ -2054,7 +2060,7 @@ static void draw_pose_bones(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *
glDisable(GL_CULL_FACE);
}
- draw_custom_bone(scene, sl, v3d, rv3d, pchan->custom,
+ draw_custom_bone(eval_ctx, scene, sl, v3d, rv3d, pchan->custom,
OB_SOLID, arm->flag, flag, index, PCHAN_CUSTOM_DRAW_SIZE(pchan));
}
}
@@ -2099,6 +2105,11 @@ static void draw_pose_bones(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *
}
}
+ /* custom bone may draw outline double-width */
+ if (arm->flag & ARM_POSEMODE) {
+ glLineWidth(1.0f);
+ }
+
/* draw custom bone shapes as wireframes */
if (!(arm->flag & ARM_NO_CUSTOM) &&
(draw_wire || (dt <= OB_WIRE)) )
@@ -2145,7 +2156,7 @@ static void draw_pose_bones(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *
if (bone == arm->act_bone)
flag |= BONE_DRAW_ACTIVE;
- draw_custom_bone(scene, sl, v3d, rv3d, pchan->custom,
+ draw_custom_bone(eval_ctx, scene, sl, v3d, rv3d, pchan->custom,
OB_WIRE, arm->flag, flag, index, PCHAN_CUSTOM_DRAW_SIZE(pchan));
gpuPopMatrix();
@@ -2164,11 +2175,6 @@ static void draw_pose_bones(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *
index = -1;
}
}
-
- /* custom bone may draw outline double-width */
- if (arm->flag & ARM_POSEMODE) {
- glLineWidth(1.0f);
- }
/* wire draw over solid only in posemode */
if ((dt <= OB_WIRE) || (arm->flag & ARM_POSEMODE) || ELEM(arm->drawtype, ARM_LINE, ARM_WIRE)) {
@@ -2209,7 +2215,7 @@ static void draw_pose_bones(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *
if ((do_dashed & DASH_HELP_LINES) && ((bone->flag & BONE_CONNECTED) == 0)) {
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
@@ -2239,8 +2245,11 @@ static void draw_pose_bones(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *
if (arm->flag & ARM_POSEMODE) {
if (constflag & PCHAN_HAS_IK) {
if (bone->flag & BONE_SELECTED) {
- if (constflag & PCHAN_HAS_TARGET) rgba_float_args_set(fcolor, 200.f/255.f, 120.f/255.f, 0.f/255.f, 1.0f);
- else rgba_float_args_set(fcolor, 200.f/255.f, 200.f/255.f, 50.f/255.f, 1.0f); /* add theme! */
+ if (constflag & PCHAN_HAS_TARGET) {
+ rgba_float_args_set(fcolor, 200.f / 255.f, 120.f / 255.f, 0.f / 255.f, 1.0f);
+ }
+ /* add theme! */
+ else rgba_float_args_set(fcolor, 200.f / 255.f, 200.f / 255.f, 50.f / 255.f, 1.0f);
GPU_select_load_id(index & 0xFFFF);
pchan_draw_IK_root_lines(pchan, !(do_dashed & DASH_HELP_LINES));
@@ -2248,8 +2257,9 @@ static void draw_pose_bones(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *
}
else if (constflag & PCHAN_HAS_SPLINEIK) {
if (bone->flag & BONE_SELECTED) {
- rgba_float_args_set(fcolor, 150.f/255.f, 200.f/255.f, 50.f/255.f, 1.0f); /* add theme! */
-
+ /* add theme! */
+ rgba_float_args_set(fcolor, 150.f / 255.f, 200.f / 255.f, 50.f / 255.f, 1.0f);
+
GPU_select_load_id(index & 0xFFFF);
pchan_draw_IK_root_lines(pchan, !(do_dashed & DASH_HELP_LINES));
}
@@ -2516,7 +2526,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt)
GPU_select_load_id(-1); /* -1 here is OK! */
- immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
@@ -2656,7 +2666,8 @@ static void ghost_poses_tag_unselected(Object *ob, short unset)
/* draw ghosts that occur within a frame range
* note: object should be in posemode
*/
-static void draw_ghost_poses_range(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, Base *base)
+static void draw_ghost_poses_range(
+ const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, Base *base)
{
Object *ob = base->object;
AnimData *adt = BKE_animdata_from_id(&ob->id);
@@ -2700,8 +2711,8 @@ static void draw_ghost_poses_range(Scene *scene, SceneLayer *sl, View3D *v3d, AR
UI_GetThemeColorShadeAlpha4ubv(TH_WIRE, 0, -128 - (int)(120.0f * sqrtf(colfac)), col);
BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL);
- BKE_pose_where_is(scene, ob);
- draw_pose_bones(scene, sl, v3d, ar, base, OB_WIRE, col, true, false);
+ BKE_pose_where_is(eval_ctx, scene, ob);
+ draw_pose_bones(eval_ctx, scene, sl, v3d, ar, base, OB_WIRE, col, true, false);
}
glDisable(GL_BLEND);
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
@@ -2723,7 +2734,9 @@ static void draw_ghost_poses_range(Scene *scene, SceneLayer *sl, View3D *v3d, AR
/* draw ghosts on keyframes in action within range
* - object should be in posemode
*/
-static void draw_ghost_poses_keys(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, BaseLegacy *base)
+static void draw_ghost_poses_keys(
+ const struct EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl,
+ View3D *v3d, ARegion *ar, BaseLegacy *base)
{
Object *ob = base->object;
AnimData *adt = BKE_animdata_from_id(&ob->id);
@@ -2781,8 +2794,8 @@ static void draw_ghost_poses_keys(Scene *scene, SceneLayer *sl, View3D *v3d, ARe
CFRA = (int)ak->cfra;
BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL);
- BKE_pose_where_is(scene, ob);
- draw_pose_bones(scene, sl, v3d, ar, base, OB_WIRE, col, true, false);
+ BKE_pose_where_is(eval_ctx, scene, ob);
+ draw_pose_bones(eval_ctx, scene, sl, v3d, ar, base, OB_WIRE, col, true, false);
}
glDisable(GL_BLEND);
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
@@ -2805,7 +2818,9 @@ static void draw_ghost_poses_keys(Scene *scene, SceneLayer *sl, View3D *v3d, ARe
/* draw ghosts around current frame
* - object is supposed to be armature in posemode
*/
-static void draw_ghost_poses(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, Base *base)
+static void draw_ghost_poses(
+ const struct EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl,
+ View3D *v3d, ARegion *ar, Base *base)
{
Object *ob = base->object;
AnimData *adt = BKE_animdata_from_id(&ob->id);
@@ -2814,7 +2829,7 @@ static void draw_ghost_poses(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion
float cur, start, end, stepsize, range, colfac, actframe, ctime;
int cfrao, flago;
unsigned char col[4];
-
+
/* pre conditions, get an action with sufficient frames */
if (ELEM(NULL, adt, adt->action))
return;
@@ -2859,8 +2874,8 @@ static void draw_ghost_poses(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion
if (CFRA != cfrao) {
BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL);
- BKE_pose_where_is(scene, ob);
- draw_pose_bones(scene, sl, v3d, ar, base, OB_WIRE, col, true, false);
+ BKE_pose_where_is(eval_ctx, scene, ob);
+ draw_pose_bones(eval_ctx, scene, sl, v3d, ar, base, OB_WIRE, col, true, false);
}
}
@@ -2874,8 +2889,8 @@ static void draw_ghost_poses(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion
if (CFRA != cfrao) {
BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL);
- BKE_pose_where_is(scene, ob);
- draw_pose_bones(scene, sl, v3d, ar, base, OB_WIRE, col, true, false);
+ BKE_pose_where_is(eval_ctx, scene, ob);
+ draw_pose_bones(eval_ctx, scene, sl, v3d, ar, base, OB_WIRE, col, true, false);
}
}
}
@@ -2900,9 +2915,10 @@ static void draw_ghost_poses(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion
/* called from drawobject.c, return true if nothing was drawn
* (ob_wire_col == NULL) when drawing ghost */
-bool draw_armature(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, Base *base,
- const short dt, const short dflag, const unsigned char ob_wire_col[4],
- const bool is_outline)
+bool draw_armature(
+ const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, Base *base,
+ const short dt, const short dflag, const unsigned char ob_wire_col[4],
+ const bool is_outline)
{
Object *ob = base->object;
bArmature *arm = ob->data;
@@ -2960,27 +2976,27 @@ bool draw_armature(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, Base
}
else if (ob->mode & OB_MODE_POSE) {
if (arm->ghosttype == ARM_GHOST_RANGE) {
- draw_ghost_poses_range(scene, sl, v3d, ar, base);
+ draw_ghost_poses_range(eval_ctx, scene, sl, v3d, ar, base);
}
else if (arm->ghosttype == ARM_GHOST_KEYS) {
- draw_ghost_poses_keys(scene, sl, v3d, ar, base);
+ draw_ghost_poses_keys(eval_ctx, scene, sl, v3d, ar, base);
}
else if (arm->ghosttype == ARM_GHOST_CUR) {
if (arm->ghostep)
- draw_ghost_poses(scene, sl, v3d, ar, base);
+ draw_ghost_poses(eval_ctx, scene, sl, v3d, ar, base);
}
if ((dflag & DRAW_SCENESET) == 0) {
- if (ob == OBACT_NEW)
+ if (ob == OBACT_NEW(sl))
arm->flag |= ARM_POSEMODE;
- else if (OBACT_NEW && (OBACT_NEW->mode & OB_MODE_WEIGHT_PAINT)) {
- if (ob == modifiers_isDeformedByArmature(OBACT_NEW))
+ else if (OBACT_NEW(sl) && (OBACT_NEW(sl)->mode & OB_MODE_WEIGHT_PAINT)) {
+ if (ob == modifiers_isDeformedByArmature(OBACT_NEW(sl)))
arm->flag |= ARM_POSEMODE;
}
draw_pose_paths(scene, v3d, ar, ob);
}
}
}
- draw_pose_bones(scene, sl, v3d, ar, base, dt, ob_wire_col, (dflag & DRAW_CONSTCOLOR), is_outline);
+ draw_pose_bones(eval_ctx, scene, sl, v3d, ar, base, dt, ob_wire_col, (dflag & DRAW_CONSTCOLOR), is_outline);
arm->flag &= ~ARM_POSEMODE;
}
else {
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index f41602f7899..07d072f0156 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -54,6 +54,7 @@
#include "BKE_camera.h"
#include "BKE_colortools.h"
#include "BKE_constraint.h" /* for the get_constraint_target function */
+#include "BKE_context.h"
#include "BKE_curve.h"
#include "BKE_DerivedMesh.h"
#include "BKE_deform.h"
@@ -81,6 +82,8 @@
#include "BKE_editmesh.h"
+#include "DEG_depsgraph.h"
+
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
@@ -115,6 +118,8 @@
/* prototypes */
static void imm_draw_box(const float vec[8][3], bool solid, unsigned pos);
+// #define USE_MESH_DM_SELECT
+
/* Workaround for sequencer scene render mode.
*
* Strips doesn't use DAG to update objects or so, which
@@ -315,7 +320,7 @@ bool draw_glsl_material(Scene *scene, SceneLayer *sl, Object *ob, View3D *v3d, c
return false;
if (!check_object_draw_texture(scene, v3d, dt))
return false;
- if (ob == OBACT_NEW && (ob && ob->mode & OB_MODE_WEIGHT_PAINT))
+ if (ob == OBACT_NEW(sl) && (ob && ob->mode & OB_MODE_WEIGHT_PAINT))
return false;
if (v3d->flag2 & V3D_SHOW_SOLID_MATCAP)
@@ -763,7 +768,7 @@ static void draw_empty_image(Object *ob, const short dflag, const unsigned char
glDisable(GL_BLEND);
}
- imm_draw_line_box(pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
+ imm_draw_box_wire_2d(pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
}
else {
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
@@ -775,7 +780,7 @@ static void draw_empty_image(Object *ob, const short dflag, const unsigned char
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
- imm_draw_line_box(pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
+ imm_draw_box_wire_2d(pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
glDisable(GL_LINE_SMOOTH);
glDisable(GL_BLEND);
@@ -818,7 +823,7 @@ static void drawcentercircle(View3D *v3d, RegionView3D *UNUSED(rv3d), const floa
const float outlineWidth = 1.0f * U.pixelsize;
const float size = U.obcenter_dia * U.pixelsize + outlineWidth;
- if (v3d->zbuf) {
+ if (v3d->zbuf) {
glDisable(GL_DEPTH_TEST);
/* TODO(merwin): fit things like this into plates/buffers design */
}
@@ -855,7 +860,7 @@ static void drawcentercircle(View3D *v3d, RegionView3D *UNUSED(rv3d), const floa
GPU_disable_program_point_size();
glDisable(GL_BLEND);
- if (v3d->zbuf) {
+ if (v3d->zbuf) {
glEnable(GL_DEPTH_TEST);
}
}
@@ -1473,7 +1478,7 @@ void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base,
* previously it adjusted to always to show it but that seems
* confusing because it doesn't show the actual blend size */
if (blend != 0.0f && blend != z_abs) {
- imm_draw_line_box_3d(pos, blend, -blend, -blend, blend);
+ imm_draw_box_wire_3d(pos, blend, -blend, -blend, blend);
}
}
}
@@ -1583,9 +1588,9 @@ void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base,
else if (la->type == LA_AREA) {
setlinestyle(3);
if (la->area_shape == LA_AREA_SQUARE)
- imm_draw_line_box_3d(pos, -la->area_size * 0.5f, -la->area_size * 0.5f, la->area_size * 0.5f, la->area_size * 0.5f);
+ imm_draw_box_wire_3d(pos, -la->area_size * 0.5f, -la->area_size * 0.5f, la->area_size * 0.5f, la->area_size * 0.5f);
else if (la->area_shape == LA_AREA_RECT)
- imm_draw_line_box_3d(pos, -la->area_size * 0.5f, -la->area_sizey * 0.5f, la->area_size * 0.5f, la->area_sizey * 0.5f);
+ imm_draw_box_wire_3d(pos, -la->area_size * 0.5f, -la->area_sizey * 0.5f, la->area_size * 0.5f, la->area_sizey * 0.5f);
immBegin(GWN_PRIM_LINES, 2);
immVertex3f(pos, 0.0f, 0.0f, -circrad);
@@ -1759,29 +1764,29 @@ static void draw_viewport_object_reconstruction(
/* selection outline */
if (selected) {
- batch = Batch_get_sphere_wire(1);
+ batch = GPU_batch_preset_sphere_wire(1);
if ((dflag & DRAW_CONSTCOLOR) == 0) {
- Batch_set_builtin_program(batch, GPU_SHADER_3D_UNIFORM_COLOR);
+ GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR);
GWN_batch_uniform_4f(batch, "color",
ob_wire_col[0] / 255.f,
ob_wire_col[1] / 255.f,
ob_wire_col[2] / 255.f, 1.0f);
}
else {
- Batch_set_builtin_program(batch, GPU_SHADER_3D_DEPTH_ONLY);
+ GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_DEPTH_ONLY);
}
glLineWidth(2.0f);
GWN_batch_draw(batch);
}
- batch = Batch_get_sphere(0);
+ batch = GPU_batch_preset_sphere(0);
if ((dflag & DRAW_CONSTCOLOR) == 0) {
const float light[3] = {0.0f, 0.0f, 1.0f};
float col[3];
- Batch_set_builtin_program(batch, GPU_SHADER_SIMPLE_LIGHTING);
+ GWN_batch_program_set_builtin(batch, GPU_SHADER_SIMPLE_LIGHTING);
GWN_batch_uniform_3fv(batch, "light", light);
if (track->flag & TRACK_CUSTOMCOLOR) copy_v3_v3(col, track->color);
@@ -1789,7 +1794,7 @@ static void draw_viewport_object_reconstruction(
GWN_batch_uniform_4f(batch, "color", col[0], col[1], col[2], 1.0f);
}
else {
- Batch_set_builtin_program(batch, GPU_SHADER_3D_DEPTH_ONLY);
+ GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_DEPTH_ONLY);
}
GWN_batch_draw(batch);
@@ -2392,7 +2397,8 @@ static void drawlattice__point(Lattice *lt, DispList *dl, int u, int v, int w, i
}
#ifdef SEQUENCER_DAG_WORKAROUND
-static void ensure_curve_cache(Scene *scene, Object *object)
+static void ensure_curve_cache(
+ const EvaluationContext *eval_ctx, Scene *scene, Object *object)
{
bool need_recalc = object->curve_cache == NULL;
/* Render thread might have freed the curve cache if the
@@ -2421,13 +2427,13 @@ static void ensure_curve_cache(Scene *scene, Object *object)
case OB_CURVE:
case OB_SURF:
case OB_FONT:
- BKE_displist_make_curveTypes(scene, object, false);
+ BKE_displist_make_curveTypes(eval_ctx, scene, object, false);
break;
case OB_MBALL:
- BKE_displist_make_mball(G.main->eval_ctx, scene, object);
+ BKE_displist_make_mball(eval_ctx, scene, object);
break;
case OB_LATTICE:
- BKE_lattice_modifiers_calc(scene, object);
+ BKE_lattice_modifiers_calc(eval_ctx, scene, object);
break;
}
}
@@ -4151,7 +4157,7 @@ static void draw_em_fancy_new(Scene *UNUSED(scene), ARegion *UNUSED(ar), View3D
/* disable depth writes for transparent surface, so it doesn't interfere with itself */
glDepthMask(GL_FALSE);
- Batch_set_builtin_program(surface, GPU_SHADER_3D_UNIFORM_COLOR);
+ GWN_batch_program_set_builtin(surface, GPU_SHADER_3D_UNIFORM_COLOR);
GWN_batch_uniform_4f(surface, "color", 1.0f, 0.5f, 0.0f, 0.5f);
GWN_batch_draw(surface);
@@ -4159,7 +4165,7 @@ static void draw_em_fancy_new(Scene *UNUSED(scene), ARegion *UNUSED(ar), View3D
if (finalDM != cageDM) {
puts("finalDM != cageDM");
Gwn_Batch *finalSurface = MBC_get_all_triangles(finalDM);
- Batch_set_builtin_program(finalSurface, GPU_SHADER_3D_UNIFORM_COLOR);
+ GWN_batch_program_set_builtin(finalSurface, GPU_SHADER_3D_UNIFORM_COLOR);
GWN_batch_uniform_4f(finalSurface, "color", 0.0f, 0.0f, 0.0f, 0.05f);
GWN_batch_draw(finalSurface);
}
@@ -4171,19 +4177,19 @@ static void draw_em_fancy_new(Scene *UNUSED(scene), ARegion *UNUSED(ar), View3D
* NOTE: does not help as much as desired
* TODO: draw edit object last to avoid this mess
*/
- Batch_set_builtin_program(surface, GPU_SHADER_3D_DEPTH_ONLY);
+ GWN_batch_program_set_builtin(surface, GPU_SHADER_3D_DEPTH_ONLY);
GWN_batch_draw(surface);
if (GLEW_VERSION_3_2) {
#if 0
Gwn_Batch *overlay = DRW_mesh_batch_cache_get_overlay_edges(me);
- Batch_set_builtin_program(overlay, GPU_SHADER_EDGES_OVERLAY);
+ GWN_batch_program_set_builtin(overlay, GPU_SHADER_EDGES_OVERLAY);
GWN_batch_uniform_2f(overlay, "viewportSize", ar->winx, ar->winy);
GWN_batch_draw(overlay);
#endif
#if 0 /* TODO: use this SIMPLE variant for pure triangle meshes */
- Batch_set_builtin_program(surface, GPU_SHADER_EDGES_OVERLAY_SIMPLE);
+ GWN_batch_program_set_builtin(surface, GPU_SHADER_EDGES_OVERLAY_SIMPLE);
/* use these defaults:
* const float edgeColor[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
* GWN_batch_uniform_4f(surface, "fillColor", edgeColor[0], edgeColor[1], edgeColor[2], 0.0f);
@@ -4196,7 +4202,7 @@ static void draw_em_fancy_new(Scene *UNUSED(scene), ARegion *UNUSED(ar), View3D
}
else {
Gwn_Batch *edges = DRW_mesh_batch_cache_get_all_edges(me);
- Batch_set_builtin_program(edges, GPU_SHADER_3D_UNIFORM_COLOR);
+ GWN_batch_program_set_builtin(edges, GPU_SHADER_3D_UNIFORM_COLOR);
GWN_batch_uniform_4f(edges, "color", 0.0f, 0.0f, 0.0f, 1.0f);
glEnable(GL_LINE_SMOOTH);
glLineWidth(1.5f);
@@ -4208,7 +4214,7 @@ static void draw_em_fancy_new(Scene *UNUSED(scene), ARegion *UNUSED(ar), View3D
Gwn_Batch *verts = MBC_get_all_verts(me);
glEnable(GL_BLEND);
- Batch_set_builtin_program(verts, GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA);
+ GWN_batch_program_set_builtin(verts, GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA);
GWN_batch_uniform_4f(verts, "color", 0.0f, 0.0f, 0.0f, 1.0f);
GWN_batch_uniform_1f(verts, "size", UI_GetThemeValuef(TH_VERTEX_SIZE) * 1.5f);
GWN_batch_draw(verts);
@@ -4260,14 +4266,14 @@ static void draw_mesh_object_outline_new(View3D *v3d, RegionView3D *rv3d, Object
Gwn_Batch *fancy_edges = DRW_mesh_batch_cache_get_fancy_edges(me);
if (rv3d->persp == RV3D_ORTHO) {
- Batch_set_builtin_program(fancy_edges, GPU_SHADER_EDGES_FRONT_BACK_ORTHO);
+ GWN_batch_program_set_builtin(fancy_edges, GPU_SHADER_EDGES_FRONT_BACK_ORTHO);
/* set eye vector, transformed to object coords */
float eye[3] = { 0.0f, 0.0f, 1.0f }; /* looking into the screen */
mul_m3_v3(gpuGetNormalMatrixInverse(NULL), eye);
GWN_batch_uniform_3fv(fancy_edges, "eye", eye);
}
else {
- Batch_set_builtin_program(fancy_edges, GPU_SHADER_EDGES_FRONT_BACK_PERSP);
+ GWN_batch_program_set_builtin(fancy_edges, GPU_SHADER_EDGES_FRONT_BACK_PERSP);
}
GWN_batch_uniform_1b(fancy_edges, "drawFront", false);
@@ -4278,7 +4284,7 @@ static void draw_mesh_object_outline_new(View3D *v3d, RegionView3D *rv3d, Object
GWN_batch_draw(fancy_edges);
#else /* alternate version that matches look of old viewport (but more efficient) */
Gwn_Batch *batch = MBC_get_all_edges(dm);
- Batch_set_builtin_program(batch, GPU_SHADER_3D_UNIFORM_COLOR);
+ GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR);
GWN_batch_uniform_4fv(batch, "color", outline_color);
GWN_batch_draw(batch);
#endif
@@ -4293,8 +4299,9 @@ static bool object_is_halo(Scene *scene, Object *ob)
return (ma && (ma->material_type == MA_TYPE_HALO) && !BKE_scene_use_new_shading_nodes(scene));
}
-static void draw_mesh_fancy(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base,
- const char dt, const unsigned char ob_wire_col[4], const short dflag)
+static void draw_mesh_fancy(
+ const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base,
+ const char dt, const unsigned char ob_wire_col[4], const short dflag)
{
#ifdef WITH_GAMEENGINE
Object *ob = (rv3d->rflag & RV3D_IS_GAME_ENGINE) ? BKE_object_lod_meshob_get(base->object, sl) : base->object;
@@ -4304,8 +4311,8 @@ static void draw_mesh_fancy(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v
Mesh *me = ob->data;
eWireDrawMode draw_wire = OBDRAW_WIRE_OFF;
bool /* no_verts,*/ no_edges, no_faces;
- DerivedMesh *dm = mesh_get_derived_final(scene, ob, scene->customdata_mask);
- const bool is_obact = (ob == OBACT_NEW);
+ DerivedMesh *dm = mesh_get_derived_final(eval_ctx, scene, ob, scene->customdata_mask);
+ const bool is_obact = (ob == OBACT_NEW(sl));
int draw_flags = (is_obact && BKE_paint_select_face_test(ob)) ? DRAW_FACE_SELECT : 0;
if (!dm)
@@ -4557,8 +4564,9 @@ static void draw_mesh_fancy(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v
}
/* returns true if nothing was drawn, for detecting to draw an object center */
-static bool draw_mesh_object(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, RegionView3D *rv3d, BaseLegacy *base,
- const char dt, const unsigned char ob_wire_col[4], const short dflag)
+static bool draw_mesh_object(
+ const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, RegionView3D *rv3d, BaseLegacy *base,
+ const char dt, const unsigned char ob_wire_col[4], const short dflag)
{
Object *ob = base->object;
Object *obedit = scene->obedit;
@@ -4598,7 +4606,7 @@ static bool draw_mesh_object(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *
}
else {
cageDM = editbmesh_get_derived_cage_and_final(
- scene, ob, em, scene->customdata_mask,
+ eval_ctx, scene, ob, em, scene->customdata_mask,
&finalDM);
}
@@ -4639,7 +4647,7 @@ static bool draw_mesh_object(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *
}
}
- draw_mesh_fancy(scene, sl, ar, v3d, rv3d, base, dt, ob_wire_col, dflag);
+ draw_mesh_fancy(eval_ctx, scene, sl, ar, v3d, rv3d, base, dt, ob_wire_col, dflag);
GPU_end_object_materials();
@@ -4701,13 +4709,13 @@ static void make_color_variations(const unsigned char base_ubyte[4], float low[4
high[3] = base[3];
}
-static void draw_mesh_fancy_new(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base,
+static void draw_mesh_fancy_new(EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base,
const char dt, const unsigned char ob_wire_col[4], const short dflag, const bool other_obedit)
{
if (dflag & (DRAW_PICKING | DRAW_CONSTCOLOR)) {
/* too complicated! use existing methods */
/* TODO: move this into a separate depth pre-pass */
- draw_mesh_fancy(scene, sl, ar, v3d, rv3d, base, dt, ob_wire_col, dflag);
+ draw_mesh_fancy(eval_ctx, scene, sl, ar, v3d, rv3d, base, dt, ob_wire_col, dflag);
return;
}
@@ -4719,8 +4727,8 @@ static void draw_mesh_fancy_new(Scene *scene, SceneLayer *sl, ARegion *ar, View3
Mesh *me = ob->data;
eWireDrawMode draw_wire = OBDRAW_WIRE_OFF; /* could be bool draw_wire_overlay */
bool no_edges, no_faces;
- DerivedMesh *dm = mesh_get_derived_final(scene, ob, scene->customdata_mask);
- const bool is_obact = (ob == OBACT_NEW);
+ DerivedMesh *dm = mesh_get_derived_final(eval_ctx, scene, ob, scene->customdata_mask);
+ const bool is_obact = (ob == OBACT_NEW(sl));
int draw_flags = (is_obact && BKE_paint_select_face_test(ob)) ? DRAW_FACE_SELECT : 0;
if (!dm)
@@ -4784,14 +4792,14 @@ static void draw_mesh_fancy_new(Scene *scene, SceneLayer *sl, ARegion *ar, View3
Gwn_Batch *fancy_edges = DRW_mesh_batch_cache_get_fancy_edges(me);
if (rv3d->persp == RV3D_ORTHO) {
- Batch_set_builtin_program(fancy_edges, GPU_SHADER_EDGES_FRONT_BACK_ORTHO);
+ GWN_batch_program_set_builtin(fancy_edges, GPU_SHADER_EDGES_FRONT_BACK_ORTHO);
/* set eye vector, transformed to object coords */
float eye[3] = { 0.0f, 0.0f, 1.0f }; /* looking into the screen */
mul_m3_v3(gpuGetNormalMatrixInverse(NULL), eye);
GWN_batch_uniform_3fv(fancy_edges, "eye", eye);
}
else {
- Batch_set_builtin_program(fancy_edges, GPU_SHADER_EDGES_FRONT_BACK_PERSP);
+ GWN_batch_program_set_builtin(fancy_edges, GPU_SHADER_EDGES_FRONT_BACK_PERSP);
}
float frontColor[4];
@@ -4820,7 +4828,7 @@ static void draw_mesh_fancy_new(Scene *scene, SceneLayer *sl, ARegion *ar, View3
#else /* simple wireframes */
Gwn_Batch *batch = MBC_get_all_edges(dm);
- Batch_set_builtin_program(batch, GPU_SHADER_3D_UNIFORM_COLOR);
+ GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR);
float color[4];
rgba_uchar_to_float(color, ob_wire_col);
@@ -4841,7 +4849,7 @@ static void draw_mesh_fancy_new(Scene *scene, SceneLayer *sl, ARegion *ar, View3
!(G.f & G_PICKSEL || (draw_flags & DRAW_FACE_SELECT)) &&
(draw_wire == OBDRAW_WIRE_OFF))
{
- draw_mesh_object_outline_new(v3d, rv3d, ob, me, (ob == OBACT_NEW));
+ draw_mesh_object_outline_new(v3d, rv3d, ob, me, (ob == OBACT_NEW(sl)));
}
if (draw_glsl_material(scene, sl, ob, v3d, dt) && !(draw_flags & DRAW_MODIFIERS_PREVIEW)) {
@@ -4908,7 +4916,7 @@ static void draw_mesh_fancy_new(Scene *scene, SceneLayer *sl, ARegion *ar, View3
(draw_wire == OBDRAW_WIRE_OFF) &&
(ob->sculpt == NULL))
{
- draw_mesh_object_outline_new(v3d, rv3d, ob, me, (ob == OBACT_NEW));
+ draw_mesh_object_outline_new(v3d, rv3d, ob, me, (ob == OBACT_NEW(sl)));
}
/* materials arent compatible with vertex colors */
@@ -4933,7 +4941,7 @@ static void draw_mesh_fancy_new(Scene *scene, SceneLayer *sl, ARegion *ar, View3
(ob->sculpt == NULL))
{
/* TODO: move this into a separate pass */
- draw_mesh_object_outline_new(v3d, rv3d, ob, me, (ob == OBACT_NEW));
+ draw_mesh_object_outline_new(v3d, rv3d, ob, me, (ob == OBACT_NEW(sl)));
}
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
@@ -5019,15 +5027,18 @@ static void draw_mesh_fancy_new(Scene *scene, SceneLayer *sl, ARegion *ar, View3
dm->release(dm);
}
-static bool UNUSED_FUNCTION(draw_mesh_object_new)(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, RegionView3D *rv3d, BaseLegacy *base,
+static bool UNUSED_FUNCTION(draw_mesh_object_new)(const bContext *C, Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, RegionView3D *rv3d, BaseLegacy *base,
const char dt, const unsigned char ob_wire_col[4], const short dflag)
{
+ EvaluationContext eval_ctx;
Object *ob = base->object;
Object *obedit = scene->obedit;
Mesh *me = ob->data;
BMEditMesh *em = me->edit_btmesh;
bool do_alpha_after = false, drawlinked = false, retval = false;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
if (v3d->flag2 & V3D_RENDER_SHADOW) {
/* TODO: handle shadow pass separately */
return true;
@@ -5057,7 +5068,7 @@ static bool UNUSED_FUNCTION(draw_mesh_object_new)(Scene *scene, SceneLayer *sl,
}
else {
cageDM = editbmesh_get_derived_cage_and_final(
- scene, ob, em, scene->customdata_mask,
+ &eval_ctx, scene, ob, em, scene->customdata_mask,
&finalDM);
}
@@ -5105,7 +5116,7 @@ static bool UNUSED_FUNCTION(draw_mesh_object_new)(Scene *scene, SceneLayer *sl,
const bool other_obedit = obedit && (obedit != ob);
- draw_mesh_fancy_new(scene, sl, ar, v3d, rv3d, base, dt, ob_wire_col, dflag, other_obedit);
+ draw_mesh_fancy_new(&eval_ctx, scene, sl, ar, v3d, rv3d, base, dt, ob_wire_col, dflag, other_obedit);
GPU_end_object_materials();
@@ -5131,13 +5142,13 @@ static void drawDispListVerts(Gwn_PrimType prim_type, const void *data, unsigned
GWN_vertbuf_attr_fill(vbo, pos_id, data);
- Gwn_Batch *batch = GWN_batch_create(prim_type, vbo, NULL);
- Batch_set_builtin_program(batch, GPU_SHADER_3D_UNIFORM_COLOR);
+ Gwn_Batch *batch = GWN_batch_create_ex(prim_type, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR);
if (wire_col) {
GWN_batch_uniform_4f(batch, "color", wire_col[0] / 255.0f, wire_col[1] / 255.0f, wire_col[2] / 255.0f, 1.0f);
}
GWN_batch_draw(batch);
- GWN_batch_discard_all(batch);
+ GWN_batch_discard(batch);
}
/* convert dispList with elem indices to batch, only support triangles and quads
@@ -5193,15 +5204,16 @@ static void drawDispListElem(
}
}
- Gwn_Batch *batch = GWN_batch_create(GWN_PRIM_TRIS, vbo, GWN_indexbuf_build(&elb));
- Batch_set_builtin_program(batch, GPU_SHADER_SIMPLE_LIGHTING);
+ Gwn_Batch *batch = GWN_batch_create_ex(
+ GWN_PRIM_TRIS, vbo, GWN_indexbuf_build(&elb), GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX);
+ GWN_batch_program_set_builtin(batch, GPU_SHADER_SIMPLE_LIGHTING);
if (wire_col) {
GWN_batch_uniform_4f(batch, "color", wire_col[0] / 255.0f, wire_col[1] / 255.0f, wire_col[2] / 255.0f, 1.0f);
}
GWN_batch_uniform_4f(batch, "color", 0.8f, 0.8f, 0.8f, 1.0f);
GWN_batch_uniform_3f(batch, "light", 0.0f, 0.0f, 1.0f);
GWN_batch_draw(batch);
- GWN_batch_discard_all(batch);
+ GWN_batch_discard(batch);
}
/**
@@ -5572,8 +5584,9 @@ static bool drawDispList_nobackface(Scene *scene, SceneLayer *sl, View3D *v3d, R
return false;
}
-static bool drawDispList(Scene *scene, SceneLayer *sl, View3D *v3d, RegionView3D *rv3d, Base *base,
- const char dt, const short dflag, const unsigned char ob_wire_col[4])
+static bool drawDispList(
+ const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, View3D *v3d, RegionView3D *rv3d, Base *base,
+ const char dt, const short dflag, const unsigned char ob_wire_col[4])
{
bool retval;
@@ -5585,7 +5598,7 @@ static bool drawDispList(Scene *scene, SceneLayer *sl, View3D *v3d, RegionView3D
}
#ifdef SEQUENCER_DAG_WORKAROUND
- ensure_curve_cache(scene, base->object);
+ ensure_curve_cache(eval_ctx, scene, base->object);
#endif
if (drawCurveDerivedMesh(scene, sl, v3d, rv3d, base, dt) == false) {
@@ -5643,25 +5656,25 @@ static void draw_vertex_array(Gwn_PrimType prim_type, const float *vert, const f
if (color) GWN_vertbuf_attr_fill_stride(vbo, col_id, stride, color);
}
- Gwn_Batch *batch = GWN_batch_create(prim_type, vbo, NULL);
+ Gwn_Batch *batch = GWN_batch_create_ex(prim_type, vbo, NULL, GWN_BATCH_OWNS_VBO);
if (nor && color) {
- Batch_set_builtin_program(batch, GPU_SHADER_SIMPLE_LIGHTING_SMOOTH_COLOR);
+ GWN_batch_program_set_builtin(batch, GPU_SHADER_SIMPLE_LIGHTING_SMOOTH_COLOR);
GWN_batch_uniform_3f(batch, "light", 0.0f, 0.0f, 1.0f);
}
else if (nor) {
- Batch_set_builtin_program(batch, GPU_SHADER_SIMPLE_LIGHTING);
+ GWN_batch_program_set_builtin(batch, GPU_SHADER_SIMPLE_LIGHTING);
GWN_batch_uniform_3f(batch, "light", 0.0f, 0.0f, 1.0f);
if (col) GWN_batch_uniform_4fv(batch, "color", col);
}
else if (color) {
- Batch_set_builtin_program(batch, GPU_SHADER_3D_SMOOTH_COLOR);
+ GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_SMOOTH_COLOR);
}
else {
- Batch_set_builtin_program(batch, GPU_SHADER_3D_UNIFORM_COLOR);
+ GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR);
if (col) GWN_batch_uniform_4fv(batch, "color", col);
}
GWN_batch_draw(batch);
- GWN_batch_discard_all(batch);
+ GWN_batch_discard(batch);
}
static void draw_particle_arrays_new(int draw_as, int ob_dt, int select,
@@ -5894,9 +5907,10 @@ static void draw_particle_data(ParticleSystem *psys, RegionView3D *rv3d,
* 6. draw the arrays
* 7. clean up
*/
-static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv3d,
- Base *base, ParticleSystem *psys,
- const char ob_dt, const short dflag)
+static void draw_new_particle_system(
+ const EvaluationContext *eval_ctx, Scene *scene, View3D *v3d, RegionView3D *rv3d,
+ Base *base, ParticleSystem *psys,
+ const char ob_dt, const short dflag)
{
Object *ob = base->object;
ParticleEditSettings *pset = PE_settings(scene);
@@ -5945,6 +5959,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
curvemapping_changed_all(psys->part->roughcurve);
/* 2. */
+ sim.eval_ctx = eval_ctx;
sim.scene = scene;
sim.ob = ob;
sim.psys = psys;
@@ -6579,14 +6594,16 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
}
}
-static void draw_update_ptcache_edit(Scene *scene, SceneLayer *sl, Object *ob, PTCacheEdit *edit)
+static void draw_update_ptcache_edit(
+ const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, Object *ob, PTCacheEdit *edit)
{
if (edit->psys && edit->psys->flag & PSYS_HAIR_UPDATED)
- PE_update_object(scene, sl, ob, 0);
+ PE_update_object(eval_ctx, scene, sl, ob, 0);
/* create path and child path cache if it doesn't exist already */
- if (edit->pathcache == NULL)
- psys_cache_edit_paths(scene, ob, edit, CFRA, G.is_rendering);
+ if (edit->pathcache == NULL) {
+ psys_cache_edit_paths(eval_ctx, scene, ob, edit, CFRA, G.is_rendering);
+ }
}
static void draw_ptcache_edit(Scene *scene, View3D *v3d, PTCacheEdit *edit)
@@ -6663,10 +6680,10 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, PTCacheEdit *edit)
GWN_vertbuf_attr_fill_stride(vbo, col_id, sizeof(ParticleCacheKey), path->col);
}
- Gwn_Batch *batch = GWN_batch_create(GWN_PRIM_LINE_STRIP, vbo, NULL);
- Batch_set_builtin_program(batch, GPU_SHADER_3D_SMOOTH_COLOR);
+ Gwn_Batch *batch = GWN_batch_create_ex(GWN_PRIM_LINE_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_SMOOTH_COLOR);
GWN_batch_draw(batch);
- GWN_batch_discard_all(batch);
+ GWN_batch_discard(batch);
}
if (pathcol) { MEM_freeN(pathcol); pathcol = NULL; }
@@ -6734,10 +6751,10 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, PTCacheEdit *edit)
GWN_vertbuf_attr_fill(vbo, col_id, cd);
- Gwn_Batch *batch = GWN_batch_create(GWN_PRIM_POINTS, vbo, NULL);
- Batch_set_builtin_program(batch, GPU_SHADER_3D_SMOOTH_COLOR);
+ Gwn_Batch *batch = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_SMOOTH_COLOR);
GWN_batch_draw(batch);
- GWN_batch_discard_all(batch);
+ GWN_batch_discard(batch);
pd += pd ? 3 * point->totkey : 0;
cd += (timed ? 4 : 3) * point->totkey;
@@ -7320,7 +7337,8 @@ static void draw_editnurb_splines(Object *ob, Nurb *nurb, const bool sel)
}
static void draw_editnurb(
- Scene *scene, SceneLayer *sl, View3D *v3d, RegionView3D *rv3d, Base *base, Nurb *nurb,
+ const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl,
+ View3D *v3d, RegionView3D *rv3d, Base *base, Nurb *nurb,
const char dt, const short dflag, const unsigned char UNUSED(ob_wire_col[4]))
{
ToolSettings *ts = scene->toolsettings;
@@ -7334,7 +7352,7 @@ static void draw_editnurb(
/* DispList */
UI_GetThemeColor3ubv(TH_WIRE_EDIT, wire_col);
- drawDispList(scene, sl, v3d, rv3d, base, dt, dflag, wire_col);
+ drawDispList(eval_ctx, scene, sl, v3d, rv3d, base, dt, dflag, wire_col);
/* for shadows only show solid faces */
if (v3d->flag2 & V3D_RENDER_SHADOW)
@@ -7459,8 +7477,9 @@ static void draw_editfont_textcurs(RegionView3D *rv3d, float textcurs[4][2])
immUnbindProgram();
}
-static void draw_editfont(Scene *scene, SceneLayer *sl, View3D *v3d, RegionView3D *rv3d, Base *base,
- const char dt, const short dflag, const unsigned char ob_wire_col[4])
+static void draw_editfont(
+ const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, View3D *v3d, RegionView3D *rv3d, Base *base,
+ const char dt, const short dflag, const unsigned char ob_wire_col[4])
{
Object *ob = base->object;
Curve *cu = ob->data;
@@ -7472,11 +7491,11 @@ static void draw_editfont(Scene *scene, SceneLayer *sl, View3D *v3d, RegionView3
if (cu->flag & CU_FAST) {
imm_cpack(0xFFFFFF);
set_inverted_drawing(1);
- drawDispList(scene, sl, v3d, rv3d, base, OB_WIRE, dflag, ob_wire_col);
+ drawDispList(eval_ctx, scene, sl, v3d, rv3d, base, OB_WIRE, dflag, ob_wire_col);
set_inverted_drawing(0);
}
else {
- drawDispList(scene, sl, v3d, rv3d, base, dt, dflag, ob_wire_col);
+ drawDispList(eval_ctx, scene, sl, v3d, rv3d, base, dt, dflag, ob_wire_col);
}
if (cu->linewidth != 0.0f) {
@@ -7778,8 +7797,9 @@ static void imm_drawcone(const float vec[3], float radius, float height, float t
}
/* return true if nothing was drawn */
-static bool drawmball(Scene *scene, SceneLayer *sl, View3D *v3d, RegionView3D *rv3d, Base *base,
- const char dt, const short dflag, const unsigned char ob_wire_col[4])
+static bool drawmball(
+ const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, View3D *v3d, RegionView3D *rv3d, Base *base,
+ const char dt, const short dflag, const unsigned char ob_wire_col[4])
{
Object *ob = base->object;
MetaElem *ml;
@@ -7792,13 +7812,13 @@ static bool drawmball(Scene *scene, SceneLayer *sl, View3D *v3d, RegionView3D *r
if ((G.f & G_PICKSEL) == 0) {
unsigned char wire_col[4];
UI_GetThemeColor4ubv(TH_WIRE_EDIT, wire_col);
- drawDispList(scene, sl, v3d, rv3d, base, dt, dflag, wire_col);
+ drawDispList(eval_ctx, scene, sl, v3d, rv3d, base, dt, dflag, wire_col);
}
ml = mb->editelems->first;
}
else {
if ((base->flag_legacy & OB_FROMDUPLI) == 0) {
- drawDispList(scene, sl, v3d, rv3d, base, dt, dflag, ob_wire_col);
+ drawDispList(eval_ctx, scene, sl, v3d, rv3d, base, dt, dflag, ob_wire_col);
}
ml = mb->elems.first;
}
@@ -8067,8 +8087,8 @@ static void imm_draw_box(const float vec[8][3], bool solid, unsigned pos)
static void imm_draw_bb(BoundBox *bb, char type, bool around_origin, const unsigned char ob_wire_col[4])
{
float size[3], cent[3];
- Gwn_Batch *sphere = Batch_get_sphere_wire(0);
- Batch_set_builtin_program(sphere, GPU_SHADER_3D_UNIFORM_COLOR);
+ Gwn_Batch *sphere = GPU_batch_preset_sphere_wire(0);
+ GWN_batch_program_set_builtin(sphere, GPU_SHADER_3D_UNIFORM_COLOR);
if (ob_wire_col) GWN_batch_uniform_4f(sphere, "color", ob_wire_col[0] / 255.0f, ob_wire_col[1] / 255.0f, ob_wire_col[2] / 255.0f, 1.0f);
BKE_boundbox_calc_size_aabb(bb, size);
@@ -8246,7 +8266,7 @@ static void drawtexspace(Object *ob, const unsigned char ob_wire_col[3])
/* draws wire outline */
static void draw_object_selected_outline(
- Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, Base *base,
+ const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, Base *base,
const unsigned char ob_wire_col[4])
{
RegionView3D *rv3d = ar->regiondata;
@@ -8258,7 +8278,7 @@ static void draw_object_selected_outline(
bool has_faces = false;
#ifdef SEQUENCER_DAG_WORKAROUND
- ensure_curve_cache(scene, ob);
+ ensure_curve_cache(eval_ctx, scene, ob);
#endif
DerivedMesh *dm = ob->derivedFinal;
@@ -8295,7 +8315,7 @@ static void draw_object_selected_outline(
else if (ob->type == OB_ARMATURE) {
if (!(ob->mode & OB_MODE_POSE && base == sl->basact)) {
glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f);
- draw_armature(scene, sl, v3d, ar, base, OB_WIRE, 0, ob_wire_col, true);
+ draw_armature(eval_ctx, scene, sl, v3d, ar, base, OB_WIRE, 0, ob_wire_col, true);
}
}
@@ -8434,7 +8454,7 @@ void draw_object_wire_color(Scene *scene, SceneLayer *sl, Base *base, unsigned c
theme_id = TH_GROUP_ACTIVE;
if (sl->basact != base) {
- theme_shade = -16;
+ theme_shade = -32;
}
}
else {
@@ -8547,7 +8567,9 @@ void draw_rigidbody_shape(Object *ob, const unsigned char ob_wire_col[4])
* main object drawing function, draws in selection
* \param dflag (draw flag) can be DRAW_PICKING and/or DRAW_CONSTCOLOR, DRAW_SCENESET
*/
-void draw_object(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, Base *base, const short dflag)
+void draw_object(
+ const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d,
+ Base *base, const short dflag)
{
ModifierData *md = NULL;
Object *ob = base->object;
@@ -8556,7 +8578,7 @@ void draw_object(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, Base *b
unsigned char _ob_wire_col[4]; /* dont initialize this */
const unsigned char *ob_wire_col = NULL; /* dont initialize this, use NULL crashes as a way to find invalid use */
bool zbufoff = false, is_paint = false, empty_object = false;
- const bool is_obact = (ob == OBACT_NEW);
+ const bool is_obact = (ob == OBACT_NEW(sl));
const bool render_override = (v3d->flag2 & V3D_RENDER_OVERRIDE) != 0;
const bool is_picking = (G.f & G_PICKSEL) != 0;
const bool has_particles = (ob->particlesystem.first != NULL);
@@ -8729,7 +8751,7 @@ void draw_object(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, Base *b
if ((v3d->flag & V3D_SELECT_OUTLINE) && !render_override && ob->type != OB_MESH) {
if (dt > OB_WIRE && (ob->mode & OB_MODE_EDIT) == 0 && (dflag & DRAW_SCENESET) == 0) {
if (!(ob->dtx & OB_DRAWWIRE) && (base->flag & BASE_SELECTED) && !(dflag & (DRAW_PICKING | DRAW_CONSTCOLOR))) {
- draw_object_selected_outline(scene, sl, v3d, ar, base, ob_wire_col);
+ draw_object_selected_outline(eval_ctx, scene, sl, v3d, ar, base, ob_wire_col);
}
}
}
@@ -8738,12 +8760,12 @@ void draw_object(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, Base *b
if ((dflag & DRAW_PICKING) == 0) {
if ((dt == OB_BOUNDBOX) || ELEM(ob->type, OB_EMPTY, OB_LAMP, OB_CAMERA, OB_SPEAKER)) {
goto afterdraw;
- }
+ }
}
switch (ob->type) {
case OB_MESH:
- empty_object = draw_mesh_object(scene, sl, ar, v3d, rv3d, base, dt, ob_wire_col, dflag);
+ empty_object = draw_mesh_object(eval_ctx, scene, sl, ar, v3d, rv3d, base, dt, ob_wire_col, dflag);
if ((dflag & DRAW_CONSTCOLOR) == 0) {
/* mesh draws wire itself */
dtx &= ~OB_DRAWWIRE;
@@ -8753,18 +8775,18 @@ void draw_object(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, Base *b
case OB_FONT:
cu = ob->data;
if (cu->editfont) {
- draw_editfont(scene, sl, v3d, rv3d, base, dt, dflag, ob_wire_col);
+ draw_editfont(eval_ctx, scene, sl, v3d, rv3d, base, dt, dflag, ob_wire_col);
}
else if (dt == OB_BOUNDBOX) {
if ((render_override && v3d->drawtype >= OB_WIRE) == 0) {
#ifdef SEQUENCER_DAG_WORKAROUND
- ensure_curve_cache(scene, base->object);
+ ensure_curve_cache(eval_ctx, scene, base->object);
#endif
draw_bounding_volume(ob, ob->boundtype, ob_wire_col);
}
}
else if (ED_view3d_boundbox_clip(rv3d, ob->bb)) {
- empty_object = drawDispList(scene, sl, v3d, rv3d, base, dt, dflag, ob_wire_col);
+ empty_object = drawDispList(eval_ctx, scene, sl, v3d, rv3d, base, dt, dflag, ob_wire_col);
}
break;
@@ -8774,18 +8796,18 @@ void draw_object(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, Base *b
if (cu->editnurb) {
ListBase *nurbs = BKE_curve_editNurbs_get(cu);
- draw_editnurb(scene, sl, v3d, rv3d, base, nurbs->first, dt, dflag, ob_wire_col);
+ draw_editnurb(eval_ctx, scene, sl, v3d, rv3d, base, nurbs->first, dt, dflag, ob_wire_col);
}
else if (dt == OB_BOUNDBOX) {
if ((render_override && (v3d->drawtype >= OB_WIRE)) == 0) {
#ifdef SEQUENCER_DAG_WORKAROUND
- ensure_curve_cache(scene, base->object);
+ ensure_curve_cache(eval_ctx, scene, base->object);
#endif
draw_bounding_volume(ob, ob->boundtype, ob_wire_col);
}
}
else if (ED_view3d_boundbox_clip(rv3d, ob->bb)) {
- empty_object = drawDispList(scene, sl, v3d, rv3d, base, dt, dflag, ob_wire_col);
+ empty_object = drawDispList(eval_ctx, scene, sl, v3d, rv3d, base, dt, dflag, ob_wire_col);
}
break;
case OB_MBALL:
@@ -8793,17 +8815,17 @@ void draw_object(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, Base *b
MetaBall *mb = ob->data;
if (mb->editelems)
- drawmball(scene, sl, v3d, rv3d, base, dt, dflag, ob_wire_col);
+ drawmball(eval_ctx, scene, sl, v3d, rv3d, base, dt, dflag, ob_wire_col);
else if (dt == OB_BOUNDBOX) {
if ((render_override && (v3d->drawtype >= OB_WIRE)) == 0) {
#ifdef SEQUENCER_DAG_WORKAROUND
- ensure_curve_cache(scene, base->object);
+ ensure_curve_cache(eval_ctx, scene, base->object);
#endif
draw_bounding_volume(ob, ob->boundtype, ob_wire_col);
}
}
else
- empty_object = drawmball(scene, sl, v3d, rv3d, base, dt, dflag, ob_wire_col);
+ empty_object = drawmball(eval_ctx, scene, sl, v3d, rv3d, base, dt, dflag, ob_wire_col);
break;
}
case OB_EMPTY:
@@ -8842,7 +8864,7 @@ void draw_object(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, Base *b
}
else {
#ifdef SEQUENCER_DAG_WORKAROUND
- ensure_curve_cache(scene, ob);
+ ensure_curve_cache(eval_ctx, scene, ob);
#endif
drawlattice(v3d, ob, dflag, ob_wire_col);
}
@@ -8867,7 +8889,7 @@ void draw_object(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, Base *b
else
copy_v4_v4_uchar(arm_col, ob_wire_col);
- empty_object = draw_armature(scene, sl, v3d, ar, base, dt, dflag, arm_col, false);
+ empty_object = draw_armature(eval_ctx, scene, sl, v3d, ar, base, dt, dflag, arm_col, false);
}
}
break;
@@ -8920,12 +8942,12 @@ afterdraw:
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
/* run this so that possible child particles get cached */
if (ob->mode & OB_MODE_PARTICLE_EDIT && is_obact) {
- PTCacheEdit *edit = PE_create_current(scene, ob);
+ PTCacheEdit *edit = PE_create_current(eval_ctx, scene, ob);
if (edit && edit->psys == psys)
- draw_update_ptcache_edit(scene, sl, ob, edit);
+ draw_update_ptcache_edit(eval_ctx, scene, sl, ob, edit);
}
- draw_new_particle_system(scene, v3d, rv3d, base, psys, dt, dflag);
+ draw_new_particle_system(eval_ctx, scene, v3d, rv3d, base, psys, dt, dflag);
}
invert_m4_m4(ob->imat, ob->obmat);
view3d_cached_text_draw_end(v3d, ar, 0);
@@ -8941,10 +8963,10 @@ afterdraw:
{
if (ob->mode & OB_MODE_PARTICLE_EDIT && is_obact) {
- PTCacheEdit *edit = PE_create_current(scene, ob);
+ PTCacheEdit *edit = PE_create_current(eval_ctx, scene, ob);
if (edit) {
gpuLoadMatrix(rv3d->viewmat);
- draw_update_ptcache_edit(scene, sl, ob, edit);
+ draw_update_ptcache_edit(eval_ctx, scene, sl, ob, edit);
draw_ptcache_edit(scene, v3d, edit);
gpuMultMatrix(ob->obmat);
}
@@ -9195,8 +9217,7 @@ afterdraw:
/* help lines and so */
if (ob != scene->obedit && ob->parent) {
- Base *base_parent = BKE_scene_layer_base_find(sl, ob->parent);
- if ((base_parent->flag & BASE_VISIBLED) != 0) {
+ if (BKE_object_is_visible(ob->parent)) {
setlinestyle(3);
immBegin(GWN_PRIM_LINES, 2);
immVertex3fv(pos, ob->obmat[3]);
@@ -9260,7 +9281,7 @@ afterdraw:
for (ct = targets.first; ct; ct = ct->next) {
/* calculate target's matrix */
if (cti->get_target_matrix)
- cti->get_target_matrix(curcon, cob, ct, BKE_scene_frame_get(scene));
+ cti->get_target_matrix(eval_ctx, curcon, cob, ct, BKE_scene_frame_get(scene));
else
unit_m4(ct->matrix);
@@ -9309,10 +9330,12 @@ afterdraw:
* Drawing for selection picking,
* caller must have called 'GPU_select_load_id(base->selcode)' first.
*/
-void draw_object_select(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, Base *base, const short dflag)
+void draw_object_select(
+ const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d,
+ Base *base, const short dflag)
{
BLI_assert(dflag & DRAW_PICKING && dflag & DRAW_CONSTCOLOR);
- draw_object(scene, sl, ar, v3d, base, dflag);
+ draw_object(eval_ctx, scene, sl, ar, v3d, base, dflag);
/* we draw duplicators for selection too */
if ((base->object->transflag & OB_DUPLI)) {
@@ -9321,7 +9344,7 @@ void draw_object_select(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d,
Base tbase;
tbase.flag_legacy = OB_FROMDUPLI;
- lb = object_duplilist(G.main->eval_ctx, scene, base->object);
+ lb = object_duplilist(eval_ctx, scene, base->object);
for (dob = lb->first; dob; dob = dob->next) {
float omat[4][4];
@@ -9335,7 +9358,7 @@ void draw_object_select(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d,
char dt = tbase.object->dt; tbase.object->dt = MIN2(tbase.object->dt, base->object->dt);
short dtx = tbase.object->dtx; tbase.object->dtx = base->object->dtx;
- draw_object(scene, sl, ar, v3d, &tbase, dflag);
+ draw_object(eval_ctx, scene, sl, ar, v3d, &tbase, dflag);
tbase.object->dt = dt;
tbase.object->dtx = dtx;
@@ -9348,6 +9371,7 @@ void draw_object_select(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d,
/* ***************** BACKBUF SEL (BBS) ********* */
+#ifdef USE_MESH_DM_SELECT
static void bbs_obmode_mesh_verts__mapFunc(void *userData, int index, const float co[3],
const float UNUSED(no_f[3]), const short UNUSED(no_s[3]))
{
@@ -9388,7 +9412,17 @@ static void bbs_obmode_mesh_verts(Object *ob, DerivedMesh *dm, int offset)
immUnbindProgram();
}
+#else
+static void bbs_obmode_mesh_verts(Object *ob, DerivedMesh *UNUSED(dm), int offset)
+{
+ Mesh *me = ob->data;
+ Gwn_Batch *batch = DRW_mesh_batch_cache_get_verts_with_select_id(me, offset);
+ GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32);
+ GWN_batch_draw(batch);
+}
+#endif
+#ifdef USE_MESH_DM_SELECT
static void bbs_mesh_verts__mapFunc(void *userData, int index, const float co[3],
const float UNUSED(no_f[3]), const short UNUSED(no_s[3]))
{
@@ -9421,7 +9455,17 @@ static void bbs_mesh_verts(BMEditMesh *em, DerivedMesh *dm, int offset)
immUnbindProgram();
}
+#else
+static void bbs_mesh_verts(BMEditMesh *em, DerivedMesh *UNUSED(dm), int offset)
+{
+ Mesh *me = em->ob->data;
+ Gwn_Batch *batch = DRW_mesh_batch_cache_get_verts_with_select_id(me, offset);
+ GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32);
+ GWN_batch_draw(batch);
+}
+#endif
+#ifdef USE_MESH_DM_SELECT
static void bbs_mesh_wire__mapFunc(void *userData, int index, const float v0co[3], const float v1co[3])
{
drawBMOffset_userData *data = userData;
@@ -9461,7 +9505,19 @@ static void bbs_mesh_wire(BMEditMesh *em, DerivedMesh *dm, int offset)
immUnbindProgram();
}
+#else
+static void bbs_mesh_wire(BMEditMesh *em, DerivedMesh *UNUSED(dm), int offset)
+{
+ glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
+ Mesh *me = em->ob->data;
+ Gwn_Batch *batch = DRW_mesh_batch_cache_get_edges_with_select_id(me, offset);
+ GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32);
+ GWN_batch_draw(batch);
+}
+#endif
+
+#ifdef USE_MESH_DM_SELECT
static void bbs_mesh_face(BMEditMesh *em, DerivedMesh *dm, const bool use_select)
{
UNUSED_VARS(dm);
@@ -9514,7 +9570,29 @@ static void bbs_mesh_face(BMEditMesh *em, DerivedMesh *dm, const bool use_select
immUnbindProgram();
}
+#else
+static void bbs_mesh_face(BMEditMesh *em, DerivedMesh *UNUSED(dm), const bool use_select)
+{
+ Mesh *me = em->ob->data;
+ Gwn_Batch *batch;
+
+ if (use_select) {
+ batch = DRW_mesh_batch_cache_get_triangles_with_select_id(me, true, 1);
+ GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32);
+ GWN_batch_draw(batch);
+ }
+ else {
+ int selcol;
+ GPU_select_index_get(0, &selcol);
+ batch = DRW_mesh_batch_cache_get_triangles_with_select_mask(me, true);
+ GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR_U32);
+ GWN_batch_uniform_1i(batch, "color", selcol);
+ GWN_batch_draw(batch);
+ }
+}
+#endif
+#ifdef USE_MESH_DM_SELECT
static void bbs_mesh_solid__drawCenter(void *userData, int index, const float cent[3], const float UNUSED(no[3]))
{
drawBMOffset_userData *data = (drawBMOffset_userData *)userData;
@@ -9546,6 +9624,15 @@ static void bbs_mesh_face_dot(BMEditMesh *em, DerivedMesh *dm)
immUnbindProgram();
}
+#else
+static void bbs_mesh_face_dot(BMEditMesh *em, DerivedMesh *UNUSED(dm))
+{
+ Mesh *me = em->ob->data;
+ Gwn_Batch *batch = DRW_mesh_batch_cache_get_facedots_with_select_id(me, 1);
+ GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32);
+ GWN_batch_draw(batch);
+}
+#endif
/* two options, facecolors or black */
static void bbs_mesh_solid_EM(BMEditMesh *em, Scene *scene, View3D *v3d,
@@ -9581,6 +9668,7 @@ static DMDrawOption bbs_mesh_solid_hide__setDrawOpts(void *userData, int index)
}
}
+#ifdef USE_MESH_DM_SELECT
/* must have called GPU_framebuffer_index_set beforehand */
static DMDrawOption bbs_mesh_solid_hide2__setDrawOpts(void *userData, int index)
{
@@ -9594,21 +9682,50 @@ static DMDrawOption bbs_mesh_solid_hide2__setDrawOpts(void *userData, int index)
}
}
-static void bbs_mesh_solid_verts(Scene *scene, Object *ob)
+static void bbs_mesh_solid_verts(const EvaluationContext *eval_ctx, Scene *scene, Object *ob)
{
Mesh *me = ob->data;
- DerivedMesh *dm = mesh_get_derived_final(scene, ob, scene->customdata_mask);
+ DerivedMesh *dm = mesh_get_derived_final(eval_ctx, scene, ob, scene->customdata_mask);
DM_update_materials(dm, ob);
- dm->drawMappedFaces(dm, bbs_mesh_solid_hide2__setDrawOpts, GPU_object_material_bind, NULL, me, DM_DRAW_SKIP_HIDDEN);
+ /* Only draw faces to mask out verts, we don't want their selection ID's. */
+ const int G_f_orig = G.f;
+ G.f &= ~G_BACKBUFSEL;
- GPU_object_material_unbind();
+ dm->drawMappedFaces(dm, bbs_mesh_solid_hide2__setDrawOpts, NULL, NULL, me, DM_DRAW_SKIP_HIDDEN);
+
+ G.f |= (G_f_orig & G_BACKBUFSEL);
bbs_obmode_mesh_verts(ob, dm, 1);
bm_vertoffs = me->totvert + 1;
dm->release(dm);
}
+#else
+static void bbs_mesh_solid_verts(const EvaluationContext *UNUSED(eval_ctx), Scene *UNUSED(scene), Object *ob)
+{
+ Mesh *me = ob->data;
+
+ /* Only draw faces to mask out verts, we don't want their selection ID's. */
+ const int G_f_orig = G.f;
+ G.f &= ~G_BACKBUFSEL;
+
+ {
+ int selcol;
+ Gwn_Batch *batch;
+ GPU_select_index_get(0, &selcol);
+ batch = DRW_mesh_batch_cache_get_triangles_with_select_mask(me, true);
+ GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR_U32);
+ GWN_batch_uniform_1i(batch, "color", selcol);
+ GWN_batch_draw(batch);
+ }
+
+ G.f |= (G_f_orig & G_BACKBUFSEL);
+
+ bbs_obmode_mesh_verts(ob, NULL, 1);
+ bm_vertoffs = me->totvert + 1;
+}
+#endif
static void bbs_mesh_solid_faces(Scene *scene, Object *ob)
{
@@ -9616,16 +9733,17 @@ static void bbs_mesh_solid_faces(Scene *scene, Object *ob)
UNUSED_VARS(scene, bbs_mesh_solid_hide__setDrawOpts, bbs_mesh_solid__setDrawOpts);
Gwn_Batch *batch;
if ((me->editflag & ME_EDIT_PAINT_FACE_SEL)) {
- batch = DRW_mesh_batch_cache_get_triangles_with_select_id(me, true);
+ batch = DRW_mesh_batch_cache_get_triangles_with_select_id(me, true, 1);
}
else {
- batch = DRW_mesh_batch_cache_get_triangles_with_select_id(me, false);
+ batch = DRW_mesh_batch_cache_get_triangles_with_select_id(me, false, 1);
}
- Batch_set_builtin_program(batch, GPU_SHADER_3D_FLAT_COLOR_U32);
+ GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32);
GWN_batch_draw(batch);
}
-void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob)
+void draw_object_backbufsel(
+ const EvaluationContext *eval_ctx, Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob)
{
ToolSettings *ts = scene->toolsettings;
@@ -9640,7 +9758,7 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec
Mesh *me = ob->data;
BMEditMesh *em = me->edit_btmesh;
- DerivedMesh *dm = editbmesh_get_derived_cage(scene, ob, em, CD_MASK_BAREMESH);
+ DerivedMesh *dm = editbmesh_get_derived_cage(eval_ctx, scene, ob, em, CD_MASK_BAREMESH);
BM_mesh_elem_table_ensure(em->bm, BM_VERT | BM_EDGE | BM_FACE);
@@ -9674,10 +9792,10 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec
else {
Mesh *me = ob->data;
if ((me->editflag & ME_EDIT_PAINT_VERT_SEL) &&
- /* currently vertex select only supports weight paint */
- (ob->mode & OB_MODE_WEIGHT_PAINT))
+ /* currently vertex select supports weight paint and vertex paint*/
+ ((ob->mode & OB_MODE_WEIGHT_PAINT) || (ob->mode & OB_MODE_VERTEX_PAINT)))
{
- bbs_mesh_solid_verts(scene, ob);
+ bbs_mesh_solid_verts(eval_ctx, scene, ob);
}
else {
bbs_mesh_solid_faces(scene, ob);
@@ -9697,8 +9815,9 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec
/* assumes all matrices/etc set OK */
/* helper function for drawing object instances - meshes */
-static void draw_object_mesh_instance(Scene *scene, SceneLayer *sl, View3D *v3d, RegionView3D *rv3d,
- Object *ob, const short dt, int outline, const unsigned char ob_wire_col[4])
+static void draw_object_mesh_instance(
+ const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, View3D *v3d, RegionView3D *rv3d,
+ Object *ob, const short dt, int outline, const unsigned char ob_wire_col[4])
{
Mesh *me = ob->data;
DerivedMesh *dm = NULL, *edm = NULL;
@@ -9708,7 +9827,7 @@ static void draw_object_mesh_instance(Scene *scene, SceneLayer *sl, View3D *v3d,
DM_update_materials(edm, ob);
}
else {
- dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
+ dm = mesh_get_derived_final(eval_ctx, scene, ob, CD_MASK_BAREMESH);
DM_update_materials(dm, ob);
}
@@ -9744,7 +9863,7 @@ static void draw_object_mesh_instance(Scene *scene, SceneLayer *sl, View3D *v3d,
if (dm) dm->release(dm);
}
-void draw_object_instance(Scene *scene, SceneLayer *sl, View3D *v3d, RegionView3D *rv3d, Object *ob, const char dt, int outline, const float wire_col[4])
+void draw_object_instance(const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, View3D *v3d, RegionView3D *rv3d, Object *ob, const char dt, int outline, const float wire_col[4])
{
if (ob == NULL)
return;
@@ -9754,7 +9873,7 @@ void draw_object_instance(Scene *scene, SceneLayer *sl, View3D *v3d, RegionView3
switch (ob->type) {
case OB_MESH:
- draw_object_mesh_instance(scene, sl, v3d, rv3d, ob, dt, outline, bcol);
+ draw_object_mesh_instance(eval_ctx, scene, sl, v3d, rv3d, ob, dt, outline, bcol);
break;
case OB_EMPTY:
if (ob->empty_drawtype == OB_EMPTY_IMAGE) {
@@ -9767,7 +9886,8 @@ void draw_object_instance(Scene *scene, SceneLayer *sl, View3D *v3d, RegionView3
}
}
-void ED_draw_object_facemap(Scene *scene, Object *ob, const float col[4], const int facemap)
+void ED_draw_object_facemap(
+ const EvaluationContext *eval_ctx, Scene *scene, Object *ob, const float col[4], const int facemap)
{
DerivedMesh *dm = NULL;
@@ -9775,7 +9895,12 @@ void ED_draw_object_facemap(Scene *scene, Object *ob, const float col[4], const
if (ob->type != OB_MESH || !ob->data)
return;
- dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
+ /* Temporary, happens on undo, would resolve but will eventually move away from DM. */
+ if (ob->derivedFinal == NULL) {
+ return;
+ }
+
+ dm = mesh_get_derived_final(eval_ctx, scene, ob, CD_MASK_BAREMESH);
if (!dm || !CustomData_has_layer(&dm->polyData, CD_FACEMAP))
return;
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index b3ac62e9885..9654ff74f54 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -735,9 +735,14 @@ static void view3d_widgets(void)
&(const struct wmManipulatorMapType_Params){SPACE_VIEW3D, RGN_TYPE_WINDOW});
WM_manipulatorgrouptype_append_and_link(mmap_type, TRANSFORM_WGT_manipulator);
- WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_lamp);
+ WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_lamp_spot);
+ WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_lamp_area);
+ WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_lamp_target);
WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_force_field);
WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_camera);
+ WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_camera_view);
+ WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_empty_image);
+ WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_armature_spline);
}
@@ -877,6 +882,7 @@ static void view3d_main_region_listener(
BKE_screen_view3d_sync(v3d, wmn->reference);
}
ED_region_tag_redraw(ar);
+ WM_manipulatormap_tag_refresh(mmap);
break;
case ND_OB_ACTIVE:
case ND_OB_SELECT:
@@ -1016,6 +1022,10 @@ static void view3d_main_region_listener(
case ND_WORLD_DRAW:
/* handled by space_view3d_listener() for v3d access */
break;
+ case ND_WORLD:
+ /* Needed for updating world materials */
+ ED_region_tag_redraw(ar);
+ break;
}
break;
case NC_LAMP:
@@ -1394,33 +1404,31 @@ static void view3d_id_remap(ScrArea *sa, SpaceLink *slink, ID *old_id, ID *new_i
}
}
}
- if ((ID *)v3d->ob_centre == old_id) {
- v3d->ob_centre = (Object *)new_id;
- if (new_id == NULL) { /* Otherwise, bonename may remain valid... We could be smart and check this, too? */
- v3d->ob_centre_bone[0] = '\0';
- }
- }
- if ((ID *)v3d->defmaterial == old_id) {
- v3d->defmaterial = (Material *)new_id;
- }
-#if 0 /* XXX Deprecated? */
- if ((ID *)v3d->gpd == old_id) {
- v3d->gpd = (bGPData *)new_id;
- }
-#endif
+ /* Values in local-view aren't used, see: T52663 */
+ if (is_local == false) {
+ /* Skip 'v3d->defmaterial', it's not library data. */
- if (ELEM(GS(old_id->name), ID_IM, ID_MC)) {
- for (BGpic *bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) {
- if ((ID *)bgpic->ima == old_id) {
- bgpic->ima = (Image *)new_id;
- id_us_min(old_id);
- id_us_plus(new_id);
+ if ((ID *)v3d->ob_centre == old_id) {
+ v3d->ob_centre = (Object *)new_id;
+ /* Otherwise, bonename may remain valid... We could be smart and check this, too? */
+ if (new_id == NULL) {
+ v3d->ob_centre_bone[0] = '\0';
}
- if ((ID *)bgpic->clip == old_id) {
- bgpic->clip = (MovieClip *)new_id;
- id_us_min(old_id);
- id_us_plus(new_id);
+ }
+
+ if (ELEM(GS(old_id->name), ID_IM, ID_MC)) {
+ for (BGpic *bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) {
+ if ((ID *)bgpic->ima == old_id) {
+ bgpic->ima = (Image *)new_id;
+ id_us_min(old_id);
+ id_us_plus(new_id);
+ }
+ if ((ID *)bgpic->clip == old_id) {
+ bgpic->clip = (MovieClip *)new_id;
+ id_us_min(old_id);
+ id_us_plus(new_id);
+ }
}
}
}
diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c
index a8e5e1ad536..ddb87d96ec1 100644
--- a/source/blender/editors/space_view3d/view3d_buttons.c
+++ b/source/blender/editors/space_view3d/view3d_buttons.c
@@ -788,7 +788,7 @@ static void do_view3d_vgroup_buttons(bContext *C, void *UNUSED(arg), int event)
static int view3d_panel_vgroup_poll(const bContext *C, PanelType *UNUSED(pt))
{
SceneLayer *sl = CTX_data_scene_layer(C);
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
if (ob && (BKE_object_is_in_editmode_vgroup(ob) ||
BKE_object_is_in_wpaint_select_vert(ob)))
{
@@ -1099,7 +1099,7 @@ static void do_view3d_region_buttons(bContext *C, void *UNUSED(index), int event
{
SceneLayer *sl = CTX_data_scene_layer(C);
View3D *v3d = CTX_wm_view3d(C);
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
switch (event) {
diff --git a/source/blender/editors/space_view3d/view3d_camera_control.c b/source/blender/editors/space_view3d/view3d_camera_control.c
index 8beb0ff84b0..9b07593e576 100644
--- a/source/blender/editors/space_view3d/view3d_camera_control.c
+++ b/source/blender/editors/space_view3d/view3d_camera_control.c
@@ -54,6 +54,7 @@
#include "BLI_utildefines.h"
#include "BKE_object.h"
+#include "BKE_context.h"
#include "DEG_depsgraph.h"
@@ -137,10 +138,13 @@ Object *ED_view3d_cameracontrol_object_get(View3DCameraControl *vctrl)
* the view for first-person style navigation.
*/
struct View3DCameraControl *ED_view3d_cameracontrol_acquire(
- Scene *scene, View3D *v3d, RegionView3D *rv3d,
+ const bContext *C, Scene *scene, View3D *v3d, RegionView3D *rv3d,
const bool use_parent_root)
{
View3DCameraControl *vctrl;
+ EvaluationContext eval_ctx;
+
+ CTX_data_eval_ctx(C, &eval_ctx);
vctrl = MEM_callocN(sizeof(View3DCameraControl), __func__);
@@ -177,7 +181,7 @@ struct View3DCameraControl *ED_view3d_cameracontrol_acquire(
/* store the original camera loc and rot */
vctrl->obtfm = BKE_object_tfm_backup(ob_back);
- BKE_object_where_is_calc(scene, v3d->camera);
+ BKE_object_where_is_calc(&eval_ctx, scene, v3d->camera);
negate_v3_v3(rv3d->ofs, v3d->camera->obmat[3]);
rv3d->dist = 0.0;
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 0cfc11f22b8..ed4d7861d6d 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -64,13 +64,11 @@
#include "DRW_engine.h"
-#include "ED_keyframing.h"
#include "ED_armature.h"
#include "ED_keyframing.h"
#include "ED_gpencil.h"
#include "ED_screen.h"
#include "ED_transform.h"
-#include "ED_gpencil.h"
#include "DEG_depsgraph_query.h"
@@ -119,7 +117,9 @@ static bool use_depth_doit(Scene *scene, View3D *v3d)
/**
* \note keep this synced with #ED_view3d_mats_rv3d_backup/#ED_view3d_mats_rv3d_restore
*/
-void ED_view3d_update_viewmat(Scene *scene, View3D *v3d, ARegion *ar, float viewmat[4][4], float winmat[4][4], const rcti *rect)
+void ED_view3d_update_viewmat(
+ const EvaluationContext *eval_ctx, Scene *scene, View3D *v3d, ARegion *ar,
+ float viewmat[4][4], float winmat[4][4], const rcti *rect)
{
RegionView3D *rv3d = ar->regiondata;
@@ -134,7 +134,7 @@ void ED_view3d_update_viewmat(Scene *scene, View3D *v3d, ARegion *ar, float view
if (viewmat)
copy_m4_m4(rv3d->viewmat, viewmat);
else
- view3d_viewmatrix_set(scene, v3d, rv3d); /* note: calls BKE_object_where_is_calc for camera... */
+ view3d_viewmatrix_set(eval_ctx, scene, v3d, rv3d); /* note: calls BKE_object_where_is_calc for camera... */
/* update utility matrices */
mul_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat);
@@ -181,11 +181,12 @@ void ED_view3d_update_viewmat(Scene *scene, View3D *v3d, ARegion *ar, float view
}
static void view3d_main_region_setup_view(
- Scene *scene, View3D *v3d, ARegion *ar, float viewmat[4][4], float winmat[4][4], const rcti *rect)
+ const EvaluationContext *eval_ctx, Scene *scene,
+ View3D *v3d, ARegion *ar, float viewmat[4][4], float winmat[4][4], const rcti *rect)
{
RegionView3D *rv3d = ar->regiondata;
- ED_view3d_update_viewmat(scene, v3d, ar, viewmat, winmat, rect);
+ ED_view3d_update_viewmat(eval_ctx, scene, v3d, ar, viewmat, winmat, rect);
/* set for opengl */
gpuLoadProjectionMatrix(rv3d->winmat);
@@ -235,7 +236,8 @@ static bool view3d_stereo3d_active(wmWindow *win, Scene *scene, View3D *v3d, Reg
* we do a small hack to replace it temporarily so we don't need to change the
* view3d)main_region_setup_view() code to account for that.
*/
-static void view3d_stereo3d_setup(Scene *scene, View3D *v3d, ARegion *ar, const rcti *rect)
+static void view3d_stereo3d_setup(
+ const EvaluationContext *eval_ctx, Scene *scene, View3D *v3d, ARegion *ar, const rcti *rect)
{
bool is_left;
const char *names[2] = { STEREO_LEFT_NAME, STEREO_RIGHT_NAME };
@@ -261,7 +263,7 @@ static void view3d_stereo3d_setup(Scene *scene, View3D *v3d, ARegion *ar, const
data->shiftx = BKE_camera_multiview_shift_x(&scene->r, v3d->camera, viewname);
BKE_camera_multiview_view_matrix(&scene->r, v3d->camera, is_left, viewmat);
- view3d_main_region_setup_view(scene, v3d, ar, viewmat, NULL, rect);
+ view3d_main_region_setup_view(eval_ctx, scene, v3d, ar, viewmat, NULL, rect);
data->shiftx = shiftx;
BLI_unlock_thread(LOCK_VIEW3D);
@@ -275,7 +277,7 @@ static void view3d_stereo3d_setup(Scene *scene, View3D *v3d, ARegion *ar, const
v3d->camera = camera;
BKE_camera_multiview_view_matrix(&scene->r, camera, false, viewmat);
- view3d_main_region_setup_view(scene, v3d, ar, viewmat, NULL, rect);
+ view3d_main_region_setup_view(eval_ctx, scene, v3d, ar, viewmat, NULL, rect);
v3d->camera = view_ob;
BLI_unlock_thread(LOCK_VIEW3D);
@@ -286,17 +288,17 @@ static void view3d_stereo3d_setup(Scene *scene, View3D *v3d, ARegion *ar, const
* Set the correct matrices
*/
void ED_view3d_draw_setup_view(
- wmWindow *win, Scene *scene, ARegion *ar, View3D *v3d,
+ wmWindow *win, const EvaluationContext *eval_ctx, Scene *scene, ARegion *ar, View3D *v3d,
float viewmat[4][4], float winmat[4][4], const rcti *rect)
{
RegionView3D *rv3d = ar->regiondata;
/* Setup the view matrix. */
if (view3d_stereo3d_active(win, scene, v3d, rv3d)) {
- view3d_stereo3d_setup(scene, v3d, ar, rect);
+ view3d_stereo3d_setup(eval_ctx, scene, v3d, ar, rect);
}
else {
- view3d_main_region_setup_view(scene, v3d, ar, viewmat, winmat, rect);
+ view3d_main_region_setup_view(eval_ctx, scene, v3d, ar, viewmat, winmat, rect);
}
}
@@ -500,12 +502,12 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
}
immUniformThemeColor(TH_BACK);
- imm_draw_line_box(shdr_pos, x1i, y1i, x2i, y2i);
+ imm_draw_box_wire_2d(shdr_pos, x1i, y1i, x2i, y2i);
#ifdef VIEW3D_CAMERA_BORDER_HACK
if (view3d_camera_border_hack_test == true) {
immUniformColor3ubv(view3d_camera_border_hack_col);
- imm_draw_line_box(shdr_pos, x1i + 1, y1i + 1, x2i - 1, y2i - 1);
+ imm_draw_box_wire_2d(shdr_pos, x1i + 1, y1i + 1, x2i - 1, y2i - 1);
view3d_camera_border_hack_test = false;
}
#endif
@@ -514,7 +516,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
}
/* And now, the dashed lines! */
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
{
float viewport_size[4];
@@ -528,11 +530,11 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
/* outer line not to confuse with object selection */
if (v3d->flag2 & V3D_LOCK_CAMERA) {
immUniformThemeColor(TH_REDALERT);
- imm_draw_line_box(shdr_pos, x1i - 1, y1i - 1, x2i + 1, y2i + 1);
+ imm_draw_box_wire_2d(shdr_pos, x1i - 1, y1i - 1, x2i + 1, y2i + 1);
}
immUniformThemeColor(TH_VIEW_OVERLAY);
- imm_draw_line_box(shdr_pos, x1i, y1i, x2i, y2i);
+ imm_draw_box_wire_2d(shdr_pos, x1i, y1i, x2i, y2i);
}
/* border */
@@ -545,7 +547,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
y4 = floorf(y1 + (scene->r.border.ymax * (y2 - y1))) + (U.pixelsize - 1);
immUniformColor3f(1.0f, 0.25f, 0.25f);
- imm_draw_line_box(shdr_pos, x3, y3, x4, y4);
+ imm_draw_box_wire_2d(shdr_pos, x3, y3, x4, y4);
}
/* safety border */
@@ -654,7 +656,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
/* TODO Was using UI_draw_roundbox_4fv(false, rect.xmin, rect.ymin, rect.xmax, rect.ymax, 2.0f, color).
* We'll probably need a new imm_draw_line_roundbox_dashed dor that - though in practice the
* 2.0f round corner effect was nearly not visible anyway... */
- imm_draw_line_box(shdr_pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
+ imm_draw_box_wire_2d(shdr_pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
}
}
@@ -677,7 +679,7 @@ static void drawrenderborder(ARegion *ar, View3D *v3d)
glLineWidth(1.0f);
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
@@ -688,7 +690,7 @@ static void drawrenderborder(ARegion *ar, View3D *v3d)
immUniform1f("dash_width", 6.0f);
immUniform1f("dash_factor", 0.5f);
- imm_draw_line_box(shdr_pos,
+ imm_draw_box_wire_2d(shdr_pos,
v3d->render_border.xmin * ar->winx, v3d->render_border.ymin * ar->winy,
v3d->render_border.xmax * ar->winx, v3d->render_border.ymax * ar->winy);
@@ -696,10 +698,11 @@ static void drawrenderborder(ARegion *ar, View3D *v3d)
}
void ED_view3d_draw_depth(
- struct Depsgraph *graph,
+ const EvaluationContext *eval_ctx, struct Depsgraph *graph,
ARegion *ar, View3D *v3d, bool alphaoverride)
{
- Scene *scene = DEG_get_scene(graph);
+ struct bThemeState theme_state;
+ Scene *scene = DEG_get_evaluated_scene(graph);
RegionView3D *rv3d = ar->regiondata;
short zbuf = v3d->zbuf;
@@ -712,7 +715,11 @@ void ED_view3d_draw_depth(
U.glalphaclip = alphaoverride ? 0.5f : glalphaclip; /* not that nice but means we wont zoom into billboards */
U.obcenter_dia = 0;
- ED_view3d_draw_setup_view(NULL, scene, ar, v3d, NULL, NULL, NULL);
+ /* Tools may request depth outside of regular drawing code. */
+ UI_Theme_Store(&theme_state);
+ UI_SetTheme(SPACE_VIEW3D, RGN_TYPE_WINDOW);
+
+ ED_view3d_draw_setup_view(NULL, eval_ctx, scene, ar, v3d, NULL, NULL, NULL);
glClear(GL_DEPTH_BUFFER_BIT);
@@ -747,6 +754,8 @@ void ED_view3d_draw_depth(
U.glalphaclip = glalphaclip;
v3d->flag = flag;
U.obcenter_dia = obcenter_dia;
+
+ UI_Theme_Restore(&theme_state);
}
/* ******************** background plates ***************** */
@@ -1307,7 +1316,7 @@ float ED_view3d_grid_scale(Scene *scene, View3D *v3d, const char **grid_unit)
static bool is_cursor_visible(Scene *scene, SceneLayer *sl)
{
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
/* don't draw cursor in paint modes, but with a few exceptions */
if (ob && ob->mode & OB_MODE_ALL_PAINT) {
@@ -1838,7 +1847,7 @@ void view3d_draw_region_info(const bContext *C, ARegion *ar, const int offset)
if (U.uiflag & USER_DRAWVIEWINFO) {
SceneLayer *sl = CTX_data_scene_layer(C);
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
draw_selected_name(scene, ob, &rect);
}
#if 0 /* TODO */
@@ -1859,7 +1868,10 @@ void view3d_draw_region_info(const bContext *C, ARegion *ar, const int offset)
static void view3d_draw_view(const bContext *C, ARegion *ar)
{
- ED_view3d_draw_setup_view(CTX_wm_window(C), CTX_data_scene(C), ar, CTX_wm_view3d(C), NULL, NULL, NULL);
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
+ ED_view3d_draw_setup_view(CTX_wm_window(C), &eval_ctx, CTX_data_scene(C), ar, CTX_wm_view3d(C), NULL, NULL, NULL);
/* Only 100% compliant on new spec goes bellow */
DRW_draw_view(C);
@@ -1897,7 +1909,7 @@ void view3d_main_region_draw(const bContext *C, ARegion *ar)
* \{ */
static void view3d_stereo3d_setup_offscreen(
- Scene *scene, View3D *v3d, ARegion *ar,
+ const EvaluationContext *eval_ctx, Scene *scene, View3D *v3d, ARegion *ar,
float winmat[4][4], const char *viewname)
{
/* update the viewport matrices with the new camera */
@@ -1906,24 +1918,24 @@ static void view3d_stereo3d_setup_offscreen(
const bool is_left = STREQ(viewname, STEREO_LEFT_NAME);
BKE_camera_multiview_view_matrix(&scene->r, v3d->camera, is_left, viewmat);
- view3d_main_region_setup_view(scene, v3d, ar, viewmat, winmat, NULL);
+ view3d_main_region_setup_view(eval_ctx, scene, v3d, ar, viewmat, winmat, NULL);
}
else { /* SCE_VIEWS_FORMAT_MULTIVIEW */
float viewmat[4][4];
Object *camera = BKE_camera_multiview_render(scene, v3d->camera, viewname);
BKE_camera_multiview_view_matrix(&scene->r, camera, false, viewmat);
- view3d_main_region_setup_view(scene, v3d, ar, viewmat, winmat, NULL);
+ view3d_main_region_setup_view(eval_ctx, scene, v3d, ar, viewmat, winmat, NULL);
}
}
-void ED_view3d_draw_offscreen_init(Scene *scene, SceneLayer *sl, View3D *v3d)
+void ED_view3d_draw_offscreen_init(const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, View3D *v3d)
{
RenderEngineType *type = RE_engines_find(scene->r.engine);
if (type->flag & RE_USE_LEGACY_PIPELINE) {
/* shadow buffers, before we setup matrices */
if (draw_glsl_material(scene, sl, NULL, v3d, v3d->drawtype)) {
- VP_deprecated_gpu_update_lamps_shadows_world(scene, v3d);
+ VP_deprecated_gpu_update_lamps_shadows_world(eval_ctx, scene, v3d);
}
}
}
@@ -1947,7 +1959,7 @@ static void view3d_main_region_clear(Scene *scene, View3D *v3d, ARegion *ar)
* stuff like shadow buffers
*/
void ED_view3d_draw_offscreen(
- Scene *scene, View3D *v3d, ARegion *ar, int winx, int winy,
+ const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, int winx, int winy,
float viewmat[4][4], float winmat[4][4],
bool do_bgpic, bool do_sky, bool is_persp, const char *viewname,
GPUFX *fx, GPUFXSettings *fx_settings,
@@ -1996,9 +2008,9 @@ void ED_view3d_draw_offscreen(
}
if ((viewname != NULL && viewname[0] != '\0') && (viewmat == NULL) && rv3d->persp == RV3D_CAMOB && v3d->camera)
- view3d_stereo3d_setup_offscreen(scene, v3d, ar, winmat, viewname);
+ view3d_stereo3d_setup_offscreen(eval_ctx, scene, v3d, ar, winmat, viewname);
else
- view3d_main_region_setup_view(scene, v3d, ar, viewmat, winmat, NULL);
+ view3d_main_region_setup_view(eval_ctx, scene, v3d, ar, viewmat, winmat, NULL);
/* main drawing call */
RenderEngineType *type = RE_engines_find(scene->r.engine);
@@ -2019,7 +2031,7 @@ void ED_view3d_draw_offscreen(
v3d->fx_settings.ssao = ssao;
}
- VP_deprecated_view3d_draw_objects(NULL, scene, v3d, ar, NULL, do_bgpic, true, do_compositing ? fx : NULL);
+ VP_deprecated_view3d_draw_objects(NULL, eval_ctx, scene, v3d, ar, NULL, do_bgpic, true, do_compositing ? fx : NULL);
/* post process */
if (do_compositing) {
@@ -2043,7 +2055,8 @@ void ED_view3d_draw_offscreen(
}
else {
/* XXX, should take depsgraph as arg */
- DRW_draw_render_loop_offscreen(scene->depsgraph, ar, v3d, ofs);
+ Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, sl);
+ DRW_draw_render_loop_offscreen(depsgraph, ar, v3d, ofs);
}
/* restore size */
@@ -2066,7 +2079,7 @@ void ED_view3d_draw_offscreen(
* (avoids re-creating when doing multiple GL renders).
*/
ImBuf *ED_view3d_draw_offscreen_imbuf(
- Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, int sizex, int sizey,
+ const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, int sizex, int sizey,
unsigned int flag, bool draw_background,
int alpha_mode, int samples, bool full_samples, const char *viewname,
/* output vars */
@@ -2095,7 +2108,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
}
}
- ED_view3d_draw_offscreen_init(scene, sl, v3d);
+ ED_view3d_draw_offscreen_init(eval_ctx, scene, sl, v3d);
GPU_offscreen_bind(ofs, true);
@@ -2137,7 +2150,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
if ((samples && full_samples) == 0) {
/* Single-pass render, common case */
ED_view3d_draw_offscreen(
- scene, v3d, ar, sizex, sizey, NULL, winmat,
+ eval_ctx, scene, sl, v3d, ar, sizex, sizey, NULL, winmat,
draw_background, draw_sky, !is_ortho, viewname,
fx, &fx_settings, ofs);
@@ -2161,7 +2174,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
/* first sample buffer, also initializes 'rv3d->persmat' */
ED_view3d_draw_offscreen(
- scene, v3d, ar, sizex, sizey, NULL, winmat,
+ eval_ctx, scene, sl, v3d, ar, sizex, sizey, NULL, winmat,
draw_background, draw_sky, !is_ortho, viewname,
fx, &fx_settings, ofs);
GPU_offscreen_read_pixels(ofs, GL_UNSIGNED_BYTE, rect_temp);
@@ -2180,7 +2193,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
(jit_ofs[j][1] * 2.0f) / sizey);
ED_view3d_draw_offscreen(
- scene, v3d, ar, sizex, sizey, NULL, winmat_jitter,
+ eval_ctx, scene, sl, v3d, ar, sizex, sizey, NULL, winmat_jitter,
draw_background, draw_sky, !is_ortho, viewname,
fx, &fx_settings, ofs);
GPU_offscreen_read_pixels(ofs, GL_UNSIGNED_BYTE, rect_temp);
@@ -2231,7 +2244,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
* \note used by the sequencer
*/
ImBuf *ED_view3d_draw_offscreen_imbuf_simple(
- Scene *scene, SceneLayer *sl, Object *camera, int width, int height,
+ const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, Object *camera, int width, int height,
unsigned int flag, int drawtype, bool use_solid_tex, bool use_gpencil, bool draw_background,
int alpha_mode, int samples, bool full_samples, const char *viewname,
GPUFX *fx, GPUOffScreen *ofs, char err_out[256])
@@ -2285,7 +2298,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(
invert_m4_m4(rv3d.persinv, rv3d.viewinv);
return ED_view3d_draw_offscreen_imbuf(
- scene, sl, &v3d, &ar, width, height, flag,
+ eval_ctx, scene, sl, &v3d, &ar, width, height, flag,
draw_background, alpha_mode, samples, full_samples, viewname,
fx, ofs, err_out);
}
@@ -2334,19 +2347,21 @@ void VP_legacy_drawfloor(Scene *scene, View3D *v3d, const char **grid_unit, bool
drawfloor(scene, v3d, grid_unit, write_depth);
}
-void VP_legacy_view3d_main_region_setup_view(Scene *scene, View3D *v3d, ARegion *ar, float viewmat[4][4], float winmat[4][4])
+void VP_legacy_view3d_main_region_setup_view(
+ const EvaluationContext *eval_ctx, Scene *scene, View3D *v3d,
+ ARegion *ar, float viewmat[4][4], float winmat[4][4])
{
- view3d_main_region_setup_view(scene, v3d, ar, viewmat, winmat, NULL);
+ view3d_main_region_setup_view(eval_ctx, scene, v3d, ar, viewmat, winmat, NULL);
}
-bool VP_legacy_view3d_stereo3d_active(const bContext *C, Scene *scene, View3D *v3d, RegionView3D *rv3d)
+bool VP_legacy_view3d_stereo3d_active(wmWindow *win, Scene *scene, View3D *v3d, RegionView3D *rv3d)
{
- return view3d_stereo3d_active(CTX_wm_window(C), scene, v3d, rv3d);
+ return view3d_stereo3d_active(win, scene, v3d, rv3d);
}
-void VP_legacy_view3d_stereo3d_setup(Scene *scene, View3D *v3d, ARegion *ar)
+void VP_legacy_view3d_stereo3d_setup(const EvaluationContext *eval_ctx, Scene *scene, View3D *v3d, ARegion *ar)
{
- view3d_stereo3d_setup(scene, v3d, ar, NULL);
+ view3d_stereo3d_setup(eval_ctx, scene, v3d, ar, NULL);
}
bool VP_legacy_use_depth(Scene *scene, View3D *v3d)
diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c
index 4c15a291c9c..d24c8241855 100644
--- a/source/blender/editors/space_view3d/view3d_draw_legacy.c
+++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c
@@ -70,7 +70,7 @@
#include "BKE_unit.h"
#include "BKE_movieclip.h"
-#include "RE_engine.h"
+#include "DEG_depsgraph.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
@@ -211,7 +211,7 @@ static void draw_view_icon(RegionView3D *rv3d, rcti *rect)
/* *********************** backdraw for selection *************** */
-static void backdrawview3d(Scene *scene, SceneLayer *sl, wmWindow *win, ARegion *ar, View3D *v3d)
+static void backdrawview3d(const struct EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, wmWindow *win, ARegion *ar, View3D *v3d)
{
RegionView3D *rv3d = ar->regiondata;
struct Base *base = sl->basact;
@@ -312,7 +312,7 @@ static void backdrawview3d(Scene *scene, SceneLayer *sl, wmWindow *win, ARegion
G.f |= G_BACKBUFSEL;
if (base && ((base->flag & BASE_VISIBLED) != 0))
- draw_object_backbufsel(scene, v3d, rv3d, base->object);
+ draw_object_backbufsel(eval_ctx, scene, v3d, rv3d, base->object);
if (rv3d->gpuoffscreen)
GPU_offscreen_unbind(rv3d->gpuoffscreen, true);
@@ -353,10 +353,11 @@ static void view3d_opengl_read_Z_pixels(ARegion *ar, int x, int y, int w, int h,
glReadPixels(ar->winrct.xmin + x, ar->winrct.ymin + y, w, h, format, type, data);
}
-void ED_view3d_backbuf_validate(ViewContext *vc)
+void ED_view3d_backbuf_validate(const struct EvaluationContext *eval_ctx, ViewContext *vc)
{
- if (vc->v3d->flag & V3D_INVALID_BACKBUF)
- backdrawview3d(vc->scene, vc->scene_layer, vc->win, vc->ar, vc->v3d);
+ if (vc->v3d->flag & V3D_INVALID_BACKBUF) {
+ backdrawview3d(eval_ctx, vc->scene, vc->scene_layer, vc->win, vc->ar, vc->v3d);
+ }
}
/**
@@ -369,13 +370,14 @@ int ED_view3d_backbuf_sample_size_clamp(ARegion *ar, const float dist)
}
/* samples a single pixel (copied from vpaint) */
-unsigned int ED_view3d_backbuf_sample(ViewContext *vc, int x, int y)
+unsigned int ED_view3d_backbuf_sample(
+ const EvaluationContext *eval_ctx, ViewContext *vc, int x, int y)
{
if (x >= vc->ar->winx || y >= vc->ar->winy) {
return 0;
}
- ED_view3d_backbuf_validate(vc);
+ ED_view3d_backbuf_validate(eval_ctx, vc);
unsigned int col;
view3d_opengl_read_pixels(vc->ar, x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &col);
@@ -389,7 +391,8 @@ unsigned int ED_view3d_backbuf_sample(ViewContext *vc, int x, int y)
}
/* reads full rect, converts indices */
-ImBuf *ED_view3d_backbuf_read(ViewContext *vc, int xmin, int ymin, int xmax, int ymax)
+ImBuf *ED_view3d_backbuf_read(
+ const EvaluationContext *eval_ctx, ViewContext *vc, int xmin, int ymin, int xmax, int ymax)
{
/* clip */
const rcti clip = {
@@ -407,7 +410,7 @@ ImBuf *ED_view3d_backbuf_read(ViewContext *vc, int xmin, int ymin, int xmax, int
ImBuf *ibuf_clip = IMB_allocImBuf(size_clip[0], size_clip[1], 32, IB_rect);
- ED_view3d_backbuf_validate(vc);
+ ED_view3d_backbuf_validate(eval_ctx, vc);
view3d_opengl_read_pixels(vc->ar, clip.xmin, clip.ymin, size_clip[0], size_clip[1], GL_RGBA, GL_UNSIGNED_BYTE, ibuf_clip->rect);
@@ -446,7 +449,7 @@ ImBuf *ED_view3d_backbuf_read(ViewContext *vc, int xmin, int ymin, int xmax, int
/* smart function to sample a rect spiralling outside, nice for backbuf selection */
unsigned int ED_view3d_backbuf_sample_rect(
- ViewContext *vc, const int mval[2], int size,
+ const EvaluationContext *eval_ctx, ViewContext *vc, const int mval[2], int size,
unsigned int min, unsigned int max, float *r_dist)
{
int dirvec[4][2];
@@ -455,7 +458,7 @@ unsigned int ED_view3d_backbuf_sample_rect(
const int minx = mval[0] - (amount + 1);
const int miny = mval[1] - (amount + 1);
- ImBuf *buf = ED_view3d_backbuf_read(vc, minx, miny, minx + size - 1, miny + size - 1);
+ ImBuf *buf = ED_view3d_backbuf_read(eval_ctx, vc, minx, miny, minx + size - 1, miny + size - 1);
if (!buf) return 0;
unsigned index = 0;
@@ -835,7 +838,8 @@ void ED_view3d_after_add(ListBase *lb, BaseLegacy *base, const short dflag)
}
/* disables write in zbuffer and draws it over */
-static void view3d_draw_transp(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d)
+static void view3d_draw_transp(
+ const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d)
{
View3DAfter *v3da;
@@ -843,7 +847,7 @@ static void view3d_draw_transp(Scene *scene, SceneLayer *sl, ARegion *ar, View3D
v3d->transp = true;
while ((v3da = BLI_pophead(&v3d->afterdraw_transp))) {
- draw_object(scene, sl, ar, v3d, v3da->base, v3da->dflag);
+ draw_object(eval_ctx, scene, sl, ar, v3d, v3da->base, v3da->dflag);
MEM_freeN(v3da);
}
v3d->transp = false;
@@ -853,7 +857,8 @@ static void view3d_draw_transp(Scene *scene, SceneLayer *sl, ARegion *ar, View3D
}
/* clears zbuffer and draws it over */
-static void view3d_draw_xray(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, bool *clear)
+static void view3d_draw_xray(
+ const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, bool *clear)
{
if (*clear && v3d->zbuf) {
glClear(GL_DEPTH_BUFFER_BIT);
@@ -863,7 +868,7 @@ static void view3d_draw_xray(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *
v3d->xray = true;
View3DAfter *v3da;
while ((v3da = BLI_pophead(&v3d->afterdraw_xray))) {
- draw_object(scene, sl, ar, v3d, v3da->base, v3da->dflag);
+ draw_object(eval_ctx, scene, sl, ar, v3d, v3da->base, v3da->dflag);
MEM_freeN(v3da);
}
v3d->xray = false;
@@ -871,7 +876,8 @@ static void view3d_draw_xray(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *
/* clears zbuffer and draws it over */
-static void view3d_draw_xraytransp(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, const bool clear)
+static void view3d_draw_xraytransp(
+ const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, const bool clear)
{
if (clear && v3d->zbuf)
glClear(GL_DEPTH_BUFFER_BIT);
@@ -883,7 +889,7 @@ static void view3d_draw_xraytransp(Scene *scene, SceneLayer *sl, ARegion *ar, Vi
View3DAfter *v3da;
while ((v3da = BLI_pophead(&v3d->afterdraw_xraytransp))) {
- draw_object(scene, sl, ar, v3d, v3da->base, v3da->dflag);
+ draw_object(eval_ctx, scene, sl, ar, v3d, v3da->base, v3da->dflag);
MEM_freeN(v3da);
}
@@ -895,7 +901,8 @@ static void view3d_draw_xraytransp(Scene *scene, SceneLayer *sl, ARegion *ar, Vi
/* clears zbuffer and draws it over,
* note that in the select version we don't care about transparent flag as with regular drawing */
-static void view3d_draw_xray_select(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, bool *clear)
+static void view3d_draw_xray_select(
+ const struct EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, bool *clear)
{
/* Not ideal, but we need to read from the previous depths before clearing
* otherwise we could have a function to load the depths after drawing.
@@ -915,7 +922,7 @@ static void view3d_draw_xray_select(Scene *scene, SceneLayer *sl, ARegion *ar, V
v3d->xray = true;
while ((v3da = BLI_pophead(&v3d->afterdraw_xray))) {
if (GPU_select_load_id(v3da->base->object->select_color)) {
- draw_object_select(scene, sl, ar, v3d, v3da->base, v3da->dflag);
+ draw_object_select(eval_ctx, scene, sl, ar, v3d, v3da->base, v3da->dflag);
}
MEM_freeN(v3da);
}
@@ -951,7 +958,7 @@ static DupliObject *dupli_step(DupliObject *dob)
}
static void draw_dupli_objects_color(
- Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, BaseLegacy *base,
+ const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, BaseLegacy *base,
const short dflag, const int color)
{
RegionView3D *rv3d = ar->regiondata;
@@ -978,10 +985,10 @@ static void draw_dupli_objects_color(
tbase.flag_legacy = OB_FROMDUPLI | base->flag_legacy;
tbase.flag = base->flag;
- lb = object_duplilist(G.main->eval_ctx, scene, base->object);
+ lb = object_duplilist(eval_ctx, scene, base->object);
// BLI_listbase_sort(lb, dupli_ob_sort); /* might be nice to have if we have a dupli list with mixed objects. */
- apply_data = duplilist_apply(base->object, scene, lb);
+ apply_data = duplilist_apply(eval_ctx, base->object, scene, lb);
DupliObject *dob_next = NULL;
DupliObject *dob = dupli_step(lb->first);
@@ -1034,7 +1041,7 @@ static void draw_dupli_objects_color(
if (!testbb || ED_view3d_boundbox_clip_ex(rv3d, &bb, dob->mat)) {
copy_m4_m4(dob->ob->obmat, dob->mat);
GPU_begin_dupli_object(dob);
- draw_object(scene, sl, ar, v3d, &tbase, dflag_dupli);
+ draw_object(eval_ctx, scene, sl, ar, v3d, &tbase, dflag_dupli);
GPU_end_dupli_object();
}
@@ -1052,7 +1059,7 @@ static void draw_dupli_objects_color(
free_object_duplilist(lb);
}
-void draw_dupli_objects(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, BaseLegacy *base)
+void draw_dupli_objects(const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, BaseLegacy *base)
{
/* define the color here so draw_dupli_objects_color can be called
* from the set loop */
@@ -1062,7 +1069,7 @@ void draw_dupli_objects(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d,
if (base->object->dup_group && base->object->dup_group->id.us < 1)
color = TH_REDALERT;
- draw_dupli_objects_color(scene, sl, ar, v3d, base, 0, color);
+ draw_dupli_objects_color(eval_ctx, scene, sl, ar, v3d, base, 0, color);
}
/* XXX warning, not using gpu offscreen here */
@@ -1175,12 +1182,13 @@ float view3d_depth_near(ViewDepths *d)
return far == far_real ? FLT_MAX : far;
}
-void ED_view3d_draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d)
+void ED_view3d_draw_depth_gpencil(
+ const EvaluationContext *eval_ctx, Scene *scene, ARegion *ar, View3D *v3d)
{
bool zbuf = v3d->zbuf;
/* Setup view matrix. */
- ED_view3d_draw_setup_view(NULL, scene, ar, v3d, NULL, NULL, NULL);
+ ED_view3d_draw_setup_view(NULL, eval_ctx, scene, ar, v3d, NULL, NULL, NULL);
glClear(GL_DEPTH_BUFFER_BIT);
@@ -1195,10 +1203,10 @@ void ED_view3d_draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d)
if (!zbuf) glDisable(GL_DEPTH_TEST);
}
-void ED_view3d_draw_depth_loop(Scene *scene, ARegion *ar, View3D *v3d)
+void ED_view3d_draw_depth_loop(const EvaluationContext *eval_ctx, Scene *scene, ARegion *ar, View3D *v3d)
{
Base *base;
- SceneLayer *sl = BKE_scene_layer_context_active(scene);
+ SceneLayer *sl = eval_ctx->scene_layer;
/* no need for color when drawing depth buffer */
const short dflag_depth = DRAW_CONSTCOLOR;
@@ -1207,9 +1215,9 @@ void ED_view3d_draw_depth_loop(Scene *scene, ARegion *ar, View3D *v3d)
Scene *sce_iter;
for (SETLOOPER(scene->set, sce_iter, base)) {
if ((base->flag & BASE_VISIBLED) != 0) {
- draw_object(scene, sl, ar, v3d, base, 0);
+ draw_object(eval_ctx, scene, sl, ar, v3d, base, 0);
if (base->object->transflag & OB_DUPLI) {
- draw_dupli_objects_color(scene, sl, ar, v3d, base, dflag_depth, TH_UNDEFINED);
+ draw_dupli_objects_color(eval_ctx, scene, sl, ar, v3d, base, dflag_depth, TH_UNDEFINED);
}
}
}
@@ -1219,9 +1227,9 @@ void ED_view3d_draw_depth_loop(Scene *scene, ARegion *ar, View3D *v3d)
if ((base->flag & BASE_VISIBLED) != 0) {
/* dupli drawing */
if (base->object->transflag & OB_DUPLI) {
- draw_dupli_objects_color(scene, sl, ar, v3d, base, dflag_depth, TH_UNDEFINED);
+ draw_dupli_objects_color(eval_ctx, scene, sl, ar, v3d, base, dflag_depth, TH_UNDEFINED);
}
- draw_object(scene, sl, ar, v3d, base, dflag_depth);
+ draw_object(eval_ctx, scene, sl, ar, v3d, base, dflag_depth);
}
}
@@ -1242,7 +1250,7 @@ void ED_view3d_draw_depth_loop(Scene *scene, ARegion *ar, View3D *v3d)
if (v3d->afterdraw_xray.first || v3d->afterdraw_xraytransp.first) {
glDepthFunc(GL_ALWAYS); /* always write into the depth bufer, overwriting front z values */
for (v3da = v3d->afterdraw_xray.first; v3da; v3da = v3da->next) {
- draw_object(scene, sl, ar, v3d, v3da->base, dflag_depth);
+ draw_object(eval_ctx, scene, sl, ar, v3d, v3da->base, dflag_depth);
}
glDepthFunc(GL_LEQUAL); /* Now write the depth buffer normally */
}
@@ -1251,21 +1259,21 @@ void ED_view3d_draw_depth_loop(Scene *scene, ARegion *ar, View3D *v3d)
v3d->xray = false;
v3d->transp = true;
while ((v3da = BLI_pophead(&v3d->afterdraw_transp))) {
- draw_object(scene, sl, ar, v3d, v3da->base, dflag_depth);
+ draw_object(eval_ctx, scene, sl, ar, v3d, v3da->base, dflag_depth);
MEM_freeN(v3da);
}
v3d->xray = true;
v3d->transp = false;
while ((v3da = BLI_pophead(&v3d->afterdraw_xray))) {
- draw_object(scene, sl, ar, v3d, v3da->base, dflag_depth);
+ draw_object(eval_ctx, scene, sl, ar, v3d, v3da->base, dflag_depth);
MEM_freeN(v3da);
}
v3d->xray = true;
v3d->transp = true;
while ((v3da = BLI_pophead(&v3d->afterdraw_xraytransp))) {
- draw_object(scene, sl, ar, v3d, v3da->base, dflag_depth);
+ draw_object(eval_ctx, scene, sl, ar, v3d, v3da->base, dflag_depth);
MEM_freeN(v3da);
}
@@ -1278,19 +1286,25 @@ void ED_view3d_draw_depth_loop(Scene *scene, ARegion *ar, View3D *v3d)
}
void ED_view3d_draw_select_loop(
- ViewContext *vc, Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar,
- bool use_obedit_skip, bool use_nearest)
+ const struct EvaluationContext *eval_ctx, ViewContext *vc, Scene *scene, SceneLayer *sl,
+ View3D *v3d, ARegion *ar, bool use_obedit_skip, bool use_nearest)
{
+ struct bThemeState theme_state;
+
short code = 1;
const short dflag = DRAW_PICKING | DRAW_CONSTCOLOR;
+ /* Tools may request depth outside of regular drawing code. */
+ UI_Theme_Store(&theme_state);
+ UI_SetTheme(SPACE_VIEW3D, RGN_TYPE_WINDOW);
+
if (vc->obedit && vc->obedit->type == OB_MBALL) {
- draw_object(scene, sl, ar, v3d, BASACT_NEW, dflag);
+ draw_object(eval_ctx, scene, sl, ar, v3d, BASACT_NEW(sl), dflag);
}
else if ((vc->obedit && vc->obedit->type == OB_ARMATURE)) {
/* if not drawing sketch, draw bones */
if (!BDR_drawSketchNames(vc)) {
- draw_object(scene, sl, ar, v3d, BASACT_NEW, dflag);
+ draw_object(eval_ctx, scene, sl, ar, v3d, BASACT_NEW(sl), dflag);
}
}
else {
@@ -1311,7 +1325,7 @@ void ED_view3d_draw_select_loop(
}
else {
if (GPU_select_load_id(code)) {
- draw_object(scene, sl, ar, v3d, base, dflag);
+ draw_object(eval_ctx, scene, sl, ar, v3d, base, dflag);
}
}
code++;
@@ -1322,10 +1336,12 @@ void ED_view3d_draw_select_loop(
if (use_nearest) {
bool xrayclear = true;
if (v3d->afterdraw_xray.first) {
- view3d_draw_xray_select(scene, sl, ar, v3d, &xrayclear);
+ view3d_draw_xray_select(eval_ctx, scene, sl, ar, v3d, &xrayclear);
}
}
}
+
+ UI_Theme_Restore(&theme_state);
}
typedef struct View3DShadow {
@@ -1353,7 +1369,7 @@ static void gpu_render_lamp_update(Scene *scene, View3D *v3d,
if (layers &&
GPU_lamp_has_shadow_buffer(lamp) &&
/* keep last, may do string lookup */
- GPU_lamp_override_visible(lamp, srl, NULL))
+ GPU_lamp_visible(lamp, srl, NULL))
{
View3DShadow *shadow = MEM_callocN(sizeof(View3DShadow), "View3DShadow");
shadow->lamp = lamp;
@@ -1362,7 +1378,7 @@ static void gpu_render_lamp_update(Scene *scene, View3D *v3d,
}
}
-static void gpu_update_lamps_shadows_world(Scene *scene, View3D *v3d)
+static void gpu_update_lamps_shadows_world(const EvaluationContext *eval_ctx, Scene *scene, View3D *v3d)
{
ListBase shadows;
Scene *sce_iter;
@@ -1422,7 +1438,7 @@ static void gpu_update_lamps_shadows_world(Scene *scene, View3D *v3d)
/* no need to call ED_view3d_draw_offscreen_init since shadow buffers were already updated */
ED_view3d_draw_offscreen(
- scene, v3d, &ar, winsize, winsize, viewmat, winmat,
+ eval_ctx, scene, eval_ctx->scene_layer, v3d, &ar, winsize, winsize, viewmat, winmat,
false, false, true,
NULL, NULL, NULL, NULL);
GPU_lamp_shadow_buffer_unbind(shadow->lamp);
@@ -1495,11 +1511,12 @@ CustomDataMask ED_view3d_screen_datamask(const Scene *scene, const bScreen *scre
*/
static void view3d_draw_objects(
const bContext *C,
+ const EvaluationContext *eval_ctx,
Scene *scene, View3D *v3d, ARegion *ar,
const char **grid_unit,
const bool do_bgpic, const bool draw_offscreen, GPUFX *fx)
{
- SceneLayer *sl = C ? CTX_data_scene_layer(C) : BKE_scene_layer_render_active(scene);
+ SceneLayer *sl = C ? CTX_data_scene_layer(C) : BKE_scene_layer_from_scene_get(scene);
RegionView3D *rv3d = ar->regiondata;
Base *base;
const bool do_camera_frame = !draw_offscreen;
@@ -1558,10 +1575,10 @@ static void view3d_draw_objects(
for (SETLOOPER(scene->set, sce_iter, base)) {
if ((base->flag & BASE_VISIBLED) != 0) {
UI_ThemeColorBlend(TH_WIRE, TH_BACK, 0.6f);
- draw_object(scene, sl, ar, v3d, base, dflag);
+ draw_object(eval_ctx, scene, sl, ar, v3d, base, dflag);
if (base->object->transflag & OB_DUPLI) {
- draw_dupli_objects_color(scene, sl, ar, v3d, base, dflag, TH_UNDEFINED);
+ draw_dupli_objects_color(eval_ctx, scene, sl, ar, v3d, base, dflag, TH_UNDEFINED);
}
}
}
@@ -1573,10 +1590,11 @@ static void view3d_draw_objects(
for (base = sl->object_bases.first; base; base = base->next) {
if ((base->flag & BASE_VISIBLED) != 0) {
/* dupli drawing */
- if (base->object->transflag & OB_DUPLI)
- draw_dupli_objects(scene, sl, ar, v3d, base);
+ if (base->object->transflag & OB_DUPLI) {
+ draw_dupli_objects(eval_ctx, scene, sl, ar, v3d, base);
+ }
- draw_object(scene, sl, ar, v3d, base, 0);
+ draw_object(eval_ctx, scene, sl, ar, v3d, base, 0);
}
}
}
@@ -1591,11 +1609,11 @@ static void view3d_draw_objects(
/* dupli drawing */
if (base->object->transflag & OB_DUPLI) {
- draw_dupli_objects(scene, sl, ar, v3d, base);
+ draw_dupli_objects(eval_ctx, scene, sl, ar, v3d, base);
}
if ((base->flag & BASE_SELECTED) == 0) {
if (base->object != scene->obedit)
- draw_object(scene, sl, ar, v3d, base, 0);
+ draw_object(eval_ctx, scene, sl, ar, v3d, base, 0);
}
}
}
@@ -1607,7 +1625,7 @@ static void view3d_draw_objects(
for (base = sl->object_bases.first; base; base = base->next) {
if ((base->flag & BASE_VISIBLED) != 0) {
if (base->object == scene->obedit || (base->flag & BASE_SELECTED)) {
- draw_object(scene, sl, ar, v3d, base, 0);
+ draw_object(eval_ctx, scene, sl, ar, v3d, base, 0);
}
}
}
@@ -1629,7 +1647,7 @@ static void view3d_draw_objects(
}
/* transp and X-ray afterdraw stuff */
- if (v3d->afterdraw_transp.first) view3d_draw_transp(scene, sl, ar, v3d);
+ if (v3d->afterdraw_transp.first) view3d_draw_transp(eval_ctx, scene, sl, ar, v3d);
/* always do that here to cleanup depth buffers if none needed */
if (fx) {
@@ -1637,8 +1655,8 @@ static void view3d_draw_objects(
GPU_fx_compositor_setup_XRay_pass(fx, do_composite_xray);
}
- if (v3d->afterdraw_xray.first) view3d_draw_xray(scene, sl, ar, v3d, &xrayclear);
- if (v3d->afterdraw_xraytransp.first) view3d_draw_xraytransp(scene, sl, ar, v3d, xrayclear);
+ if (v3d->afterdraw_xray.first) view3d_draw_xray(eval_ctx, scene, sl, ar, v3d, &xrayclear);
+ if (v3d->afterdraw_xraytransp.first) view3d_draw_xraytransp(eval_ctx, scene, sl, ar, v3d, xrayclear);
if (fx && do_composite_xray) {
GPU_fx_compositor_XRay_resolve(fx);
@@ -1818,14 +1836,16 @@ bool ED_view3d_calc_render_border(const Scene *scene, View3D *v3d, ARegion *ar,
* IMPORTANT: this is deprecated, any changes made in this function should
* be mirrored in view3d_draw_render_draw() in view3d_draw.c
*/
-static bool view3d_main_region_draw_engine(const bContext *C, Scene *scene,
- ARegion *ar, View3D *v3d,
- bool clip_border, const rcti *border_rect)
+static bool view3d_main_region_draw_engine(
+ const bContext *C, const EvaluationContext *eval_ctx, Scene *scene,
+ ARegion *ar, View3D *v3d,
+ bool clip_border, const rcti *border_rect)
{
RegionView3D *rv3d = ar->regiondata;
RenderEngineType *type;
GLint scissor[4];
+
/* create render engine */
if (!rv3d->render_engine) {
RenderEngine *engine;
@@ -1846,7 +1866,7 @@ static bool view3d_main_region_draw_engine(const bContext *C, Scene *scene,
}
/* setup view matrices */
- VP_legacy_view3d_main_region_setup_view(scene, v3d, ar, NULL, NULL);
+ VP_legacy_view3d_main_region_setup_view(eval_ctx, scene, v3d, ar, NULL, NULL);
/* background draw */
ED_region_pixelspace(ar);
@@ -1869,7 +1889,7 @@ static bool view3d_main_region_draw_engine(const bContext *C, Scene *scene,
if (v3d->flag & V3D_DISPBGPICS)
view3d_draw_bgpic_test(scene, ar, v3d, false, true);
else
- imm_draw_checker_box(0, 0, ar->winx, ar->winy);
+ imm_draw_box_checker_2d(0, 0, ar->winx, ar->winy);
/* render result draw */
type = rv3d->render_engine->type;
@@ -1930,15 +1950,18 @@ static void view3d_main_region_draw_objects(const bContext *C, Scene *scene, Sce
ARegion *ar, const char **grid_unit)
{
wmWindow *win = CTX_wm_window(C);
+ EvaluationContext eval_ctx;
RegionView3D *rv3d = ar->regiondata;
unsigned int lay_used = v3d->lay_used;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
/* post processing */
bool do_compositing = false;
/* shadow buffers, before we setup matrices */
if (draw_glsl_material(scene, sl, NULL, v3d, v3d->drawtype))
- gpu_update_lamps_shadows_world(scene, v3d);
+ gpu_update_lamps_shadows_world(&eval_ctx, scene, v3d);
/* reset default OpenGL lights if needed (i.e. after preferences have been altered) */
if (rv3d->rflag & RV3D_GPULIGHT_UPDATE) {
@@ -1947,10 +1970,12 @@ static void view3d_main_region_draw_objects(const bContext *C, Scene *scene, Sce
}
/* setup the view matrix */
- if (VP_legacy_view3d_stereo3d_active(C, scene, v3d, rv3d))
- VP_legacy_view3d_stereo3d_setup(scene, v3d, ar);
- else
- VP_legacy_view3d_main_region_setup_view(scene, v3d, ar, NULL, NULL);
+ if (VP_legacy_view3d_stereo3d_active(win, scene, v3d, rv3d)) {
+ VP_legacy_view3d_stereo3d_setup(&eval_ctx, scene, v3d, ar);
+ }
+ else {
+ VP_legacy_view3d_main_region_setup_view(&eval_ctx, scene, v3d, ar, NULL, NULL);
+ }
rv3d->rflag &= ~RV3D_IS_GAME_ENGINE;
#ifdef WITH_GAMEENGINE
@@ -1984,7 +2009,7 @@ static void view3d_main_region_draw_objects(const bContext *C, Scene *scene, Sce
}
/* main drawing call */
- view3d_draw_objects(C, scene, v3d, ar, grid_unit, true, false, do_compositing ? rv3d->compositor : NULL);
+ view3d_draw_objects(C, &eval_ctx, scene, v3d, ar, grid_unit, true, false, do_compositing ? rv3d->compositor : NULL);
/* draw depth culled manipulators - manipulators need to be updated *after* view matrix was set up */
/* TODO depth culling manipulators is not yet supported, just drawing _3D here, should
@@ -2046,7 +2071,7 @@ static void view3d_main_region_draw_info(const bContext *C, Scene *scene,
draw_view_icon(rv3d, &rect);
if (U.uiflag & USER_DRAWVIEWINFO) {
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
VP_legacy_draw_selected_name(scene, ob, &rect);
}
}
@@ -2081,6 +2106,7 @@ static void view3d_main_region_draw_info(const bContext *C, Scene *scene,
void view3d_main_region_draw_legacy(const bContext *C, ARegion *ar)
{
+ EvaluationContext eval_ctx;
Scene *scene = CTX_data_scene(C);
SceneLayer *sl = CTX_data_scene_layer(C);
View3D *v3d = CTX_wm_view3d(C);
@@ -2097,6 +2123,8 @@ void view3d_main_region_draw_legacy(const bContext *C, ARegion *ar)
gpuPushMatrix();
gpuLoadIdentity();
+ CTX_data_eval_ctx(C, &eval_ctx);
+
/* draw viewport using opengl */
if (v3d->drawtype != OB_RENDER || !view3d_main_region_do_render_draw(scene) || clip_border) {
VP_view3d_main_region_clear(scene, v3d, ar); /* background */
@@ -2110,16 +2138,17 @@ void view3d_main_region_draw_legacy(const bContext *C, ARegion *ar)
}
/* draw viewport using external renderer */
- if (v3d->drawtype == OB_RENDER)
- view3d_main_region_draw_engine(C, scene, ar, v3d, clip_border, &border_rect);
+ if (v3d->drawtype == OB_RENDER) {
+ view3d_main_region_draw_engine(C, &eval_ctx, scene, ar, v3d, clip_border, &border_rect);
+ }
- VP_legacy_view3d_main_region_setup_view(scene, v3d, ar, NULL, NULL);
+ VP_legacy_view3d_main_region_setup_view(&eval_ctx, scene, v3d, ar, NULL, NULL);
glClear(GL_DEPTH_BUFFER_BIT);
- WM_manipulatormap_draw(ar->manipulator_map, C, WM_MANIPULATORMAP_DRAWSTEP_2D);
-
ED_region_pixelspace(ar);
+ WM_manipulatormap_draw(ar->manipulator_map, C, WM_MANIPULATORMAP_DRAWSTEP_2D);
+
view3d_main_region_draw_info(C, scene, ar, v3d, grid_unit, render_border);
gpuPopProjectionMatrix();
@@ -2145,16 +2174,17 @@ void view3d_main_region_draw_legacy(const bContext *C, ARegion *ar)
void VP_deprecated_view3d_draw_objects(
const bContext *C,
+ const EvaluationContext *eval_ctx,
Scene *scene, View3D *v3d, ARegion *ar,
const char **grid_unit,
const bool do_bgpic, const bool draw_offscreen, GPUFX *fx)
{
- view3d_draw_objects(C, scene, v3d, ar, grid_unit, do_bgpic, draw_offscreen, fx);
+ view3d_draw_objects(C, eval_ctx, scene, v3d, ar, grid_unit, do_bgpic, draw_offscreen, fx);
}
-void VP_deprecated_gpu_update_lamps_shadows_world(Scene *scene, View3D *v3d)
+void VP_deprecated_gpu_update_lamps_shadows_world(const EvaluationContext *eval_ctx, Scene *scene, View3D *v3d)
{
- gpu_update_lamps_shadows_world(scene, v3d);
+ gpu_update_lamps_shadows_world(eval_ctx, scene, v3d);
}
/** \} */
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 9ac86d4e13a..b54d1254293 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -623,7 +623,7 @@ static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3])
Scene *scene = CTX_data_scene(C);
SceneLayer *sl = CTX_data_scene_layer(C);
- Object *ob_act = OBACT_NEW;
+ Object *ob_act = OBACT_NEW(sl);
if (ob_act && (ob_act->mode & OB_MODE_ALL_PAINT) &&
/* with weight-paint + pose-mode, fall through to using calculateTransformCenter */
@@ -665,7 +665,7 @@ static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3])
float select_center[3];
zero_v3(select_center);
- for (base = FIRSTBASE_NEW; base; base = base->next) {
+ for (base = FIRSTBASE_NEW(sl); base; base = base->next) {
if (TESTBASE_NEW(base)) {
/* use the boundbox if we can */
Object *ob = base->object;
@@ -727,33 +727,40 @@ static enum eViewOpsOrbit viewops_orbit_mode(void)
/**
* Calculate the values for #ViewOpsData
+ *
+ * \param use_ensure_persp: When enabled run #view3d_ensure_persp this may switch out of
+ * camera view when orbiting or switch from ortho to perspective when auto-persp is enabled.
+ * Some operations don't require this (view zoom/pan or ndof where subtle rotation is common
+ * so we don't want it to trigger auto-perspective).
*/
static void viewops_data_create_ex(
bContext *C, wmOperator *op, const wmEvent *event,
- bool switch_from_camera, enum eViewOpsOrbit orbit_mode)
+ bool use_ensure_persp, enum eViewOpsOrbit orbit_mode)
{
ViewOpsData *vod = op->customdata;
RegionView3D *rv3d = vod->rv3d;
/* we need the depth info before changing any viewport options */
if (orbit_mode & VIEWOPS_ORBIT_DEPTH) {
+ EvaluationContext eval_ctx;
struct Depsgraph *graph = CTX_data_depsgraph(C);
float fallback_depth_pt[3];
+ CTX_data_eval_ctx(C, &eval_ctx);
+
view3d_operator_needs_opengl(C); /* needed for zbuf drawing */
negate_v3_v3(fallback_depth_pt, rv3d->ofs);
vod->use_dyn_ofs = ED_view3d_autodist(
- graph, vod->ar, vod->v3d,
+ &eval_ctx, graph, vod->ar, vod->v3d,
event->mval, vod->dyn_ofs, true, fallback_depth_pt);
}
else {
vod->use_dyn_ofs = false;
}
- if (switch_from_camera) {
- /* switch from camera view when: */
+ if (use_ensure_persp) {
if (view3d_ensure_persp(vod->v3d, vod->ar)) {
/* If we're switching from camera view to the perspective one,
* need to tag viewport update, so camera vuew and borders
@@ -855,10 +862,10 @@ static void viewops_data_create_ex(
rv3d->rflag |= RV3D_NAVIGATING;
}
-static void viewops_data_create(bContext *C, wmOperator *op, const wmEvent *event, bool switch_from_camera)
+static void viewops_data_create(bContext *C, wmOperator *op, const wmEvent *event, bool use_ensure_persp)
{
enum eViewOpsOrbit orbit_mode = viewops_orbit_mode();
- viewops_data_create_ex(C, op, event, switch_from_camera, orbit_mode);
+ viewops_data_create_ex(C, op, event, use_ensure_persp, orbit_mode);
}
static void viewops_data_free(bContext *C, wmOperator *op)
@@ -1678,7 +1685,7 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *op, const wmEvent *event)
viewops_data_alloc(C, op);
viewops_data_create_ex(
C, op, event,
- viewops_orbit_mode_ex((U.uiflag & USER_ORBIT_SELECTION) != 0, false), false);
+ false, viewops_orbit_mode_ex((U.uiflag & USER_ORBIT_SELECTION) != 0, false));
vod = op->customdata;
ED_view3d_smooth_view_force_finish(C, vod->v3d, vod->ar);
@@ -1747,7 +1754,7 @@ static int ndof_orbit_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *ev
viewops_data_alloc(C, op);
viewops_data_create_ex(
C, op, event,
- viewops_orbit_mode_ex((U.uiflag & USER_ORBIT_SELECTION) != 0, false), false);
+ false, viewops_orbit_mode_ex((U.uiflag & USER_ORBIT_SELECTION) != 0, false));
vod = op->customdata;
@@ -3069,7 +3076,9 @@ static int viewselected_exec(bContext *C, wmOperator *op)
SceneLayer *sl = CTX_data_scene_layer(C);
bGPdata *gpd = CTX_data_gpencil_data(C);
const bool is_gp_edit = ((gpd) && (gpd->flag & GP_DATA_STROKE_EDITMODE));
- Object *ob = OBACT_NEW;
+ const bool is_face_map = ((is_gp_edit == false) && ar->manipulator_map &&
+ WM_manipulatormap_is_any_selected(ar->manipulator_map));
+ Object *ob = OBACT_NEW(sl);
Object *obedit = CTX_data_edit_object(C);
float min[3], max[3];
bool ok = false, ok_dist = true;
@@ -3080,8 +3089,7 @@ static int viewselected_exec(bContext *C, wmOperator *op)
const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
INIT_MINMAX(min, max);
-
- if (is_gp_edit) {
+ if (is_gp_edit || is_face_map) {
ob = NULL;
}
@@ -3113,6 +3121,9 @@ static int viewselected_exec(bContext *C, wmOperator *op)
}
CTX_DATA_END;
}
+ else if (is_face_map) {
+ ok = WM_manipulatormap_minmax(ar->manipulator_map, true, true, min, max);
+ }
else if (obedit) {
ok = ED_view3d_minmax_verts(obedit, min, max); /* only selected */
}
@@ -3135,7 +3146,7 @@ static int viewselected_exec(bContext *C, wmOperator *op)
}
else {
Base *base;
- for (base = FIRSTBASE_NEW; base; base = base->next) {
+ for (base = FIRSTBASE_NEW(sl); base; base = base->next) {
if (TESTBASE_NEW(base)) {
if (skip_camera && base->object == v3d->camera) {
@@ -3316,15 +3327,18 @@ static int viewcenter_pick_invoke(bContext *C, wmOperator *op, const wmEvent *ev
ARegion *ar = CTX_wm_region(C);
if (rv3d) {
+ EvaluationContext eval_ctx;
struct Depsgraph *graph = CTX_data_depsgraph(C);
float new_ofs[3];
const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
+ CTX_data_eval_ctx(C, &eval_ctx);
+
ED_view3d_smooth_view_force_finish(C, v3d, ar);
view3d_operator_needs_opengl(C);
- if (ED_view3d_autodist(graph, ar, v3d, event->mval, new_ofs, false, NULL)) {
+ if (ED_view3d_autodist(&eval_ctx, graph, ar, v3d, event->mval, new_ofs, false, NULL)) {
/* pass */
}
else {
@@ -3579,6 +3593,7 @@ void VIEW3D_OT_clear_render_border(wmOperatorType *ot)
static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
{
+ EvaluationContext eval_ctx;
ARegion *ar = CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = CTX_wm_region_view3d(C);
@@ -3601,6 +3616,8 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
/* note; otherwise opengl won't work */
view3d_operator_needs_opengl(C);
+ CTX_data_eval_ctx(C, &eval_ctx);
+
/* get border select values using rna */
WM_operator_properties_border_to_rcti(op, &rect);
@@ -3610,7 +3627,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
ED_view3d_dist_range_get(v3d, dist_range);
/* Get Z Depths, needed for perspective, nice for ortho */
- ED_view3d_draw_depth(CTX_data_depsgraph(C), ar, v3d, true);
+ ED_view3d_draw_depth(&eval_ctx, CTX_data_depsgraph(C), ar, v3d, true);
{
/* avoid allocating the whole depth buffer */
@@ -3659,8 +3676,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
new_dist = rv3d->dist;
/* convert the drawn rectangle into 3d space */
- if (depth_close != FLT_MAX && ED_view3d_unproject(ar, centx, centy, depth_close, p))
- {
+ if (depth_close != FLT_MAX && ED_view3d_unproject(ar, centx, centy, depth_close, p)) {
negate_v3_v3(new_ofs, p);
}
else {
@@ -3933,7 +3949,7 @@ static int viewnumpad_exec(bContext *C, wmOperator *op)
/* lastview - */
if (rv3d->persp != RV3D_CAMOB) {
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
if (!rv3d->smooth_timer) {
/* store settings of current view before allowing overwriting with camera view
@@ -4710,9 +4726,13 @@ void ED_view3d_cursor3d_position(bContext *C, float fp[3], const int mval[2])
}
if (U.uiflag & USER_ZBUF_CURSOR) { /* maybe this should be accessed some other way */
+ EvaluationContext eval_ctx;
struct Depsgraph *graph = CTX_data_depsgraph(C);
+
+ CTX_data_eval_ctx(C, &eval_ctx);
+
view3d_operator_needs_opengl(C);
- if (ED_view3d_autodist(graph, ar, v3d, mval, fp, true, NULL)) {
+ if (ED_view3d_autodist(&eval_ctx, graph, ar, v3d, mval, fp, true, NULL)) {
depth_used = true;
}
}
@@ -4741,13 +4761,20 @@ void ED_view3d_cursor3d_update(bContext *C, const int mval[2])
ARegion *ar = CTX_wm_region(C);
RegionView3D *rv3d = ar->regiondata;
- float co_curr[2], co_prev[2];
+ if (U.uiflag & USER_LOCK_CURSOR_ADJUST) {
- if ((ED_view3d_project_float_global(ar, fp_prev, co_prev, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) &&
- (ED_view3d_project_float_global(ar, fp_curr, co_curr, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK))
- {
- rv3d->ofs_lock[0] += (co_curr[0] - co_prev[0]) / (ar->winx * 0.5f);
- rv3d->ofs_lock[1] += (co_curr[1] - co_prev[1]) / (ar->winy * 0.5f);
+ float co_curr[2], co_prev[2];
+
+ if ((ED_view3d_project_float_global(ar, fp_prev, co_prev, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) &&
+ (ED_view3d_project_float_global(ar, fp_curr, co_curr, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK))
+ {
+ rv3d->ofs_lock[0] += (co_curr[0] - co_prev[0]) / (ar->winx * 0.5f);
+ rv3d->ofs_lock[1] += (co_curr[1] - co_prev[1]) / (ar->winy * 0.5f);
+ }
+ }
+ else {
+ /* Cursor may be outside of the view, prevent it getting 'lost', see: T40353 & T45301 */
+ zero_v2(rv3d->ofs_lock);
}
}
@@ -4889,7 +4916,7 @@ static float view_autodist_depth_margin(ARegion *ar, const int mval[2], int marg
* \param fallback_depth_pt: Use this points depth when no depth can be found.
*/
bool ED_view3d_autodist(
- struct Depsgraph *graph, ARegion *ar, View3D *v3d,
+ const EvaluationContext *eval_ctx, struct Depsgraph *graph, ARegion *ar, View3D *v3d,
const int mval[2], float mouse_worldloc[3],
const bool alphaoverride, const float fallback_depth_pt[3])
{
@@ -4899,7 +4926,7 @@ bool ED_view3d_autodist(
bool depth_ok = false;
/* Get Z Depths, needed for perspective, nice for ortho */
- ED_view3d_draw_depth(graph, ar, v3d, alphaoverride);
+ ED_view3d_draw_depth(eval_ctx, graph, ar, v3d, alphaoverride);
/* Attempt with low margin's first */
i = 0;
@@ -4912,8 +4939,7 @@ bool ED_view3d_autodist(
float centx = (float)mval[0] + 0.5f;
float centy = (float)mval[1] + 0.5f;
- if (ED_view3d_unproject(ar, centx, centy, depth_close, mouse_worldloc))
- {
+ if (ED_view3d_unproject(ar, centx, centy, depth_close, mouse_worldloc)) {
return true;
}
}
@@ -4928,18 +4954,18 @@ bool ED_view3d_autodist(
}
void ED_view3d_autodist_init(
- struct Depsgraph *graph,
+ const EvaluationContext *eval_ctx, struct Depsgraph *graph,
ARegion *ar, View3D *v3d, int mode)
{
/* Get Z Depths, needed for perspective, nice for ortho */
switch (mode) {
case 0:
- ED_view3d_draw_depth(graph, ar, v3d, true);
+ ED_view3d_draw_depth(eval_ctx, graph, ar, v3d, true);
break;
case 1:
{
- Scene *scene = DEG_get_scene(graph);
- ED_view3d_draw_depth_gpencil(scene, ar, v3d);
+ Scene *scene = DEG_get_evaluated_scene(graph);
+ ED_view3d_draw_depth_gpencil(eval_ctx, scene, ar, v3d);
break;
}
}
@@ -5144,6 +5170,7 @@ void ED_view3d_from_object(Object *ob, float ofs[3], float quat[4], float *dist,
void ED_view3d_to_object(Object *ob, const float ofs[3], const float quat[4], const float dist)
{
float mat[4][4];
+
ED_view3d_to_m4(mat, ofs, quat, dist);
BKE_object_apply_mat4(ob, mat, true, true);
}
diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c
index 85f44b528bc..bce27fc5c92 100644
--- a/source/blender/editors/space_view3d/view3d_fly.c
+++ b/source/blender/editors/space_view3d/view3d_fly.c
@@ -417,7 +417,7 @@ static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent
}
fly->v3d_camera_control = ED_view3d_cameracontrol_acquire(
- fly->scene, fly->v3d, fly->rv3d,
+ C, fly->scene, fly->v3d, fly->rv3d,
(U.uiflag & USER_CAM_LOCK_NO_PARENT) == 0);
/* calculate center */
diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c
index bb86b0a991f..d8599610197 100644
--- a/source/blender/editors/space_view3d/view3d_header.c
+++ b/source/blender/editors/space_view3d/view3d_header.c
@@ -283,7 +283,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
SceneLayer *sl = CTX_data_scene_layer(C);
ToolSettings *ts = CTX_data_tool_settings(C);
PointerRNA v3dptr, toolsptr, sceneptr;
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
Object *obedit = CTX_data_edit_object(C);
bGPdata *gpd = CTX_data_gpencil_data(C);
uiBlock *block;
@@ -314,7 +314,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
PointerRNA meshptr;
RNA_pointer_create(ob->data, &RNA_Mesh, ob->data, &meshptr);
- if (ob->mode & (OB_MODE_TEXTURE_PAINT | OB_MODE_VERTEX_PAINT)) {
+ if (ob->mode & (OB_MODE_TEXTURE_PAINT)) {
uiItemR(layout, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
}
else {
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index 3428af3f560..cdba5ce8b81 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -144,14 +144,18 @@ void draw_motion_paths_cleanup(View3D *v3d);
/* drawobject.c */
-void draw_object(Scene *scene, struct SceneLayer *sl, struct ARegion *ar, View3D *v3d, BaseLegacy *base, const short dflag);
-void draw_object_select(Scene *scene, struct SceneLayer *sl, struct ARegion *ar, View3D *v3d, Base *base, const short dflag);
+void draw_object(
+ const struct EvaluationContext *eval_ctx, Scene *scene, struct SceneLayer *sl, struct ARegion *ar, View3D *v3d,
+ BaseLegacy *base, const short dflag);
+void draw_object_select(
+ const struct EvaluationContext *eval_ctx, Scene *scene, struct SceneLayer *sl, struct ARegion *ar, View3D *v3d,
+ Base *base, const short dflag);
void draw_mesh_object_outline(View3D *v3d, Object *ob, struct DerivedMesh *dm, const unsigned char ob_wire_col[4]);
bool draw_glsl_material(Scene *scene, struct SceneLayer *sl, struct Object *ob, View3D *v3d, const char dt);
-void draw_object_instance(Scene *scene, struct SceneLayer *sl, View3D *v3d, RegionView3D *rv3d, struct Object *ob, const char dt, int outline, const float wire_col[4]);
-void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, struct Object *ob);
+void draw_object_instance(const struct EvaluationContext *eval_ctx, Scene *scene, struct SceneLayer *sl, View3D *v3d, RegionView3D *rv3d, struct Object *ob, const char dt, int outline, const float wire_col[4]);
+void draw_object_backbufsel(const struct EvaluationContext *eval_ctx, Scene *scene, View3D *v3d, RegionView3D *rv3d, struct Object *ob);
void draw_object_wire_color(Scene *scene, struct SceneLayer *, Base *base, unsigned char r_ob_wire_col[4]);
void drawaxes(const float viewmat_local[4][4], float size, char drawtype, const unsigned char color[4]);
@@ -183,9 +187,10 @@ enum {
int view3d_effective_drawtype(const struct View3D *v3d);
/* drawarmature.c */
-bool draw_armature(Scene *scene, struct SceneLayer *sl, View3D *v3d, ARegion *ar, Base *base,
- const short dt, const short dflag, const unsigned char ob_wire_col[4],
- const bool is_outline);
+bool draw_armature(
+ const struct EvaluationContext *eval_ctx, Scene *scene, struct SceneLayer *sl, View3D *v3d, ARegion *ar, Base *base,
+ const short dt, const short dflag, const unsigned char ob_wire_col[4],
+ const bool is_outline);
/* drawmesh.c */
void draw_mesh_textured(Scene *scene, struct SceneLayer *sl, View3D *v3d, RegionView3D *rv3d,
@@ -212,18 +217,19 @@ void view3d_main_region_draw(const struct bContext *C, struct ARegion *ar);
void view3d_draw_region_info(const struct bContext *C, struct ARegion *ar, const int offset);
void ED_view3d_draw_depth(
- struct Depsgraph *graph,
+ const struct EvaluationContext *eval_ctx, struct Depsgraph *graph,
struct ARegion *ar, View3D *v3d, bool alphaoverride);
/* view3d_draw_legacy.c */
void view3d_main_region_draw_legacy(const struct bContext *C, struct ARegion *ar);
-void ED_view3d_draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d);
+void ED_view3d_draw_depth_gpencil(const struct EvaluationContext *eval_ctx, Scene *scene, ARegion *ar, View3D *v3d);
void ED_view3d_draw_select_loop(
- ViewContext *vc, Scene *scene, struct SceneLayer *sl, View3D *v3d, ARegion *ar,
+ const struct EvaluationContext *eval_ctx, ViewContext *vc, Scene *scene, struct SceneLayer *sl, View3D *v3d, ARegion *ar,
bool use_obedit_skip, bool use_nearest);
-void ED_view3d_draw_depth_loop(Scene *scene, ARegion *ar, View3D *v3d);
+void ED_view3d_draw_depth_loop(
+ const struct EvaluationContext *eval_ctx, Scene *scene, ARegion *ar, View3D *v3d);
void ED_view3d_after_add(ListBase *lb, BaseLegacy *base, const short dflag);
@@ -269,7 +275,7 @@ void ED_view3d_smooth_view_force_finish(
struct View3D *v3d, struct ARegion *ar);
void view3d_winmatrix_set(ARegion *ar, const View3D *v3d, const rcti *rect);
-void view3d_viewmatrix_set(Scene *scene, const View3D *v3d, RegionView3D *rv3d);
+void view3d_viewmatrix_set(const struct EvaluationContext *eval_ctx, Scene *scene, const View3D *v3d, RegionView3D *rv3d);
void fly_modal_keymap(struct wmKeyConfig *keyconf);
void walk_modal_keymap(struct wmKeyConfig *keyconf);
@@ -284,7 +290,7 @@ void view3d_buttons_register(struct ARegionType *art);
/* view3d_camera_control.c */
struct View3DCameraControl *ED_view3d_cameracontrol_acquire(
- Scene *scene, View3D *v3d, RegionView3D *rv3d,
+ const struct bContext *C, Scene *scene, View3D *v3d, RegionView3D *rv3d,
const bool use_parent_root);
void ED_view3d_cameracontrol_update(
struct View3DCameraControl *vctrl,
@@ -319,10 +325,14 @@ ARegion *view3d_has_tools_region(ScrArea *sa);
extern const char *view3d_context_dir[]; /* doc access */
/* view3d_widgets.c */
-void VIEW3D_WGT_lamp (struct wmManipulatorGroupType *wgt);
-void VIEW3D_WGT_camera (struct wmManipulatorGroupType *wgt);
-void VIEW3D_WGT_force_field (struct wmManipulatorGroupType *wgt);
-void VIEW3D_WGT_armature_facemaps(struct wmManipulatorGroupType *wgt);
+void VIEW3D_WGT_lamp_spot(struct wmManipulatorGroupType *wgt);
+void VIEW3D_WGT_lamp_area(struct wmManipulatorGroupType *wgt);
+void VIEW3D_WGT_lamp_target(struct wmManipulatorGroupType *wgt);
+void VIEW3D_WGT_camera(struct wmManipulatorGroupType *wgt);
+void VIEW3D_WGT_camera_view(struct wmManipulatorGroupType *wgt);
+void VIEW3D_WGT_force_field(struct wmManipulatorGroupType *wgt);
+void VIEW3D_WGT_empty_image(struct wmManipulatorGroupType *wgt);
+void VIEW3D_WGT_armature_spline(struct wmManipulatorGroupType *wgt);
/* draw_volume.c */
void draw_smoke_volume(struct SmokeDomainSettings *sds, struct Object *ob,
@@ -349,10 +359,10 @@ void VP_legacy_draw_viewport_name(ARegion *ar, View3D *v3d, rcti *rect);
void VP_legacy_draw_selected_name(Scene *scene, Object *ob, rcti *rect);
void VP_legacy_drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **grid_unit);
void VP_legacy_drawfloor(Scene *scene, View3D *v3d, const char **grid_unit, bool write_depth);
-void VP_legacy_view3d_main_region_setup_view(Scene *scene, View3D *v3d, ARegion *ar, float viewmat[4][4], float winmat[4][4]);
-bool VP_legacy_view3d_stereo3d_active(const struct bContext *C, Scene *scene, View3D *v3d, RegionView3D *rv3d);
-void VP_legacy_view3d_stereo3d_setup(Scene *scene, View3D *v3d, ARegion *ar);
-void draw_dupli_objects(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, BaseLegacy *base);
+void VP_legacy_view3d_main_region_setup_view(const struct EvaluationContext *eval_ctx, Scene *scene, View3D *v3d, ARegion *ar, float viewmat[4][4], float winmat[4][4]);
+bool VP_legacy_view3d_stereo3d_active(struct wmWindow *win, Scene *scene, View3D *v3d, RegionView3D *rv3d);
+void VP_legacy_view3d_stereo3d_setup(const struct EvaluationContext *eval_ctx, Scene *scene, View3D *v3d, ARegion *ar);
+void draw_dupli_objects(const struct EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, BaseLegacy *base);
bool VP_legacy_use_depth(Scene *scene, View3D *v3d);
void VP_drawviewborder(Scene *scene, ARegion *ar, View3D *v3d);
void VP_drawrenderborder(ARegion *ar, View3D *v3d);
@@ -361,9 +371,10 @@ void VP_view3d_draw_background_world(Scene *scene, View3D *v3d, RegionView3D *rv
void VP_view3d_main_region_clear(Scene *scene, View3D *v3d, ARegion *ar);
/* temporary legacy calls, only when there is a switch between new/old draw calls */
-void VP_deprecated_gpu_update_lamps_shadows_world(Scene *scene, View3D *v3d);
+void VP_deprecated_gpu_update_lamps_shadows_world(const struct EvaluationContext *eval_ctx, Scene *scene, View3D *v3d);
void VP_deprecated_view3d_draw_objects(
const struct bContext *C,
+ const struct EvaluationContext *eval_ctx,
Scene *scene, View3D *v3d, ARegion *ar,
const char **grid_unit,
const bool do_bgpic, const bool draw_offscreen, struct GPUFX *fx);
diff --git a/source/blender/editors/space_view3d/view3d_iterators.c b/source/blender/editors/space_view3d/view3d_iterators.c
index ef7b01f7a21..4f80270e1e7 100644
--- a/source/blender/editors/space_view3d/view3d_iterators.c
+++ b/source/blender/editors/space_view3d/view3d_iterators.c
@@ -40,6 +40,9 @@
#include "BKE_DerivedMesh.h"
#include "BKE_displist.h"
#include "BKE_editmesh.h"
+#include "BKE_context.h"
+
+#include "DEG_depsgraph.h"
#include "bmesh.h"
@@ -104,12 +107,14 @@ static void meshobject_foreachScreenVert__mapFunc(void *userData, int index, con
}
void meshobject_foreachScreenVert(
- ViewContext *vc,
+ const EvaluationContext *eval_ctx, ViewContext *vc,
void (*func)(void *userData, MVert *eve, const float screen_co[2], int index),
void *userData, eV3DProjTest clip_flag)
{
foreachScreenObjectVert_userData data;
- DerivedMesh *dm = mesh_get_derived_deform(vc->scene, vc->obact, CD_MASK_BAREMESH);
+ DerivedMesh *dm;
+
+ dm = mesh_get_derived_deform(eval_ctx, vc->scene, vc->obact, CD_MASK_BAREMESH);
ED_view3d_check_mats_rv3d(vc->rv3d);
@@ -145,12 +150,14 @@ static void mesh_foreachScreenVert__mapFunc(void *userData, int index, const flo
}
void mesh_foreachScreenVert(
- ViewContext *vc,
+ const EvaluationContext *eval_ctx, ViewContext *vc,
void (*func)(void *userData, BMVert *eve, const float screen_co[2], int index),
void *userData, eV3DProjTest clip_flag)
{
foreachScreenVert_userData data;
- DerivedMesh *dm = editbmesh_get_derived_cage(vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
+ DerivedMesh *dm;
+
+ dm = editbmesh_get_derived_cage(eval_ctx, vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
ED_view3d_check_mats_rv3d(vc->rv3d);
@@ -199,12 +206,14 @@ static void mesh_foreachScreenEdge__mapFunc(void *userData, int index, const flo
}
void mesh_foreachScreenEdge(
- ViewContext *vc,
+ const EvaluationContext *eval_ctx, ViewContext *vc,
void (*func)(void *userData, BMEdge *eed, const float screen_co_a[2], const float screen_co_b[2], int index),
void *userData, eV3DProjTest clip_flag)
{
foreachScreenEdge_userData data;
- DerivedMesh *dm = editbmesh_get_derived_cage(vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
+ DerivedMesh *dm;
+
+ dm = editbmesh_get_derived_cage(eval_ctx, vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
ED_view3d_check_mats_rv3d(vc->rv3d);
@@ -245,12 +254,14 @@ static void mesh_foreachScreenFace__mapFunc(void *userData, int index, const flo
}
void mesh_foreachScreenFace(
- ViewContext *vc,
+ const EvaluationContext *eval_ctx, ViewContext *vc,
void (*func)(void *userData, BMFace *efa, const float screen_co_b[2], int index),
void *userData, const eV3DProjTest clip_flag)
{
foreachScreenFace_userData data;
- DerivedMesh *dm = editbmesh_get_derived_cage(vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
+ DerivedMesh *dm;
+
+ dm = editbmesh_get_derived_cage(eval_ctx, vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
ED_view3d_check_mats_rv3d(vc->rv3d);
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_armature.c b/source/blender/editors/space_view3d/view3d_manipulator_armature.c
new file mode 100644
index 00000000000..5d3d88ff2a2
--- /dev/null
+++ b/source/blender/editors/space_view3d/view3d_manipulator_armature.c
@@ -0,0 +1,220 @@
+/*
+ * ***** 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/space_view3d/view3d_manipulator_armature.c
+ * \ingroup spview3d
+ */
+
+#include "BLI_blenlib.h"
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+
+#include "BKE_armature.h"
+#include "BKE_action.h"
+#include "BKE_context.h"
+#include "BKE_object.h"
+
+#include "DNA_object_types.h"
+#include "DNA_armature_types.h"
+
+#include "ED_armature.h"
+#include "ED_screen.h"
+#include "ED_manipulator_library.h"
+
+#include "UI_resources.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "RNA_access.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "view3d_intern.h" /* own include */
+
+
+/* -------------------------------------------------------------------- */
+
+/** \name Armature Spline Manipulator
+ *
+ * \{ */
+
+/*
+ * TODO(campbell): Current conversion is a approximation (usable not correct),
+ * we'll need to take the next/previous bones into account to get the tangent directions.
+ * First last matrices from 'b_bone_spline_setup' are close but also not quite accurate
+ * since they're not at either end-points on the curve.
+ *
+ * Likely we'll need a function especially to get the first/last orientations.
+ */
+
+#define BBONE_SCALE_Y 3.0f
+
+struct BoneSplineHandle {
+ wmManipulator *manipulator;
+ bPoseChannel *pchan;
+ /* We could remove, keep since at the moment for checking the conversion. */
+ float co[3];
+ int index;
+};
+
+struct BoneSplineWidgetGroup {
+ struct BoneSplineHandle handles[2];
+};
+
+static void manipulator_bbone_offset_get(
+ const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop,
+ void *value_p)
+{
+ struct BoneSplineHandle *bh = mpr_prop->custom_func.user_data;
+ bPoseChannel *pchan = bh->pchan;
+
+ float *value = value_p;
+ BLI_assert(mpr_prop->type->array_length == 3);
+
+ if (bh->index == 0) {
+ bh->co[1] = pchan->bone->ease1 / BBONE_SCALE_Y;
+ bh->co[0] = pchan->curveInX;
+ bh->co[2] = pchan->curveInY;
+ }
+ else {
+ bh->co[1] = -pchan->bone->ease2 / BBONE_SCALE_Y;
+ bh->co[0] = pchan->curveOutX;
+ bh->co[2] = pchan->curveOutY;
+ }
+ copy_v3_v3(value, bh->co);
+}
+
+static void manipulator_bbone_offset_set(
+ const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop,
+ const void *value_p)
+{
+ struct BoneSplineHandle *bh = mpr_prop->custom_func.user_data;
+ bPoseChannel *pchan = bh->pchan;
+
+ const float *value = value_p;
+
+ BLI_assert(mpr_prop->type->array_length == 3);
+ copy_v3_v3(bh->co, value);
+
+ if (bh->index == 0) {
+ pchan->bone->ease1 = max_ff(0.0f, bh->co[1] * BBONE_SCALE_Y);
+ pchan->curveInX = bh->co[0];
+ pchan->curveInY = bh->co[2];
+ }
+ else {
+ pchan->bone->ease2 = max_ff(0.0f, -bh->co[1] * BBONE_SCALE_Y);
+ pchan->curveOutX = bh->co[0];
+ pchan->curveOutY = bh->co[2];
+ }
+
+}
+
+static bool WIDGETGROUP_armature_spline_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
+{
+ Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
+ if (ob != NULL) {
+ const bArmature *arm = ob->data;
+ if (arm->drawtype == ARM_B_BONE) {
+ if (arm->act_bone && arm->act_bone->segments > 1) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+
+static void WIDGETGROUP_armature_spline_setup(const bContext *C, wmManipulatorGroup *mgroup)
+{
+ Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
+ bPoseChannel *pchan = BKE_pose_channel_active(ob);
+
+ const wmManipulatorType *wt_grab = WM_manipulatortype_find("MANIPULATOR_WT_grab_3d", true);
+
+ struct BoneSplineWidgetGroup *bspline_group = MEM_callocN(sizeof(struct BoneSplineWidgetGroup), __func__);
+ mgroup->customdata = bspline_group;
+
+ /* Handles */
+ for (int i = 0; i < ARRAY_SIZE(bspline_group->handles); i++) {
+ wmManipulator *mpr;
+ mpr = bspline_group->handles[i].manipulator = WM_manipulator_new_ptr(wt_grab, mgroup, NULL);
+ RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_GRAB_STYLE_RING_2D);
+ RNA_enum_set(mpr->ptr, "draw_options",
+ ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL | ED_MANIPULATOR_GRAB_DRAW_FLAG_ALIGN_VIEW);
+ WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_VALUE, true);
+
+ UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color);
+ UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi);
+
+ mpr->scale_basis = 0.06f;
+
+ if (i == 0) {
+ copy_v3_v3(mpr->matrix_basis[3], pchan->loc);
+ }
+ }
+}
+
+static void WIDGETGROUP_armature_spline_refresh(const bContext *C, wmManipulatorGroup *mgroup)
+{
+ Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
+
+ if (!mgroup->customdata)
+ return;
+
+ struct BoneSplineWidgetGroup *bspline_group = mgroup->customdata;
+ bPoseChannel *pchan = BKE_pose_channel_active(ob);
+
+ /* Handles */
+ for (int i = 0; i < ARRAY_SIZE(bspline_group->handles); i++) {
+ wmManipulator *mpr = bspline_group->handles[i].manipulator;
+ bspline_group->handles[i].pchan = pchan;
+ bspline_group->handles[i].index = i;
+
+ float mat[4][4];
+ mul_m4_m4m4(mat, ob->obmat, (i == 0) ? pchan->disp_mat : pchan->disp_tail_mat);
+ copy_m4_m4(mpr->matrix_space, mat);
+
+ /* need to set property here for undo. TODO would prefer to do this in _init */
+ WM_manipulator_target_property_def_func(
+ mpr, "offset",
+ &(const struct wmManipulatorPropertyFnParams) {
+ .value_get_fn = manipulator_bbone_offset_get,
+ .value_set_fn = manipulator_bbone_offset_set,
+ .range_get_fn = NULL,
+ .user_data = &bspline_group->handles[i],
+ });
+ }
+}
+
+void VIEW3D_WGT_armature_spline(wmManipulatorGroupType *wgt)
+{
+ wgt->name = "Armature Spline Widgets";
+ wgt->idname = "VIEW3D_WGT_armature_spline";
+
+ wgt->flag = (WM_MANIPULATORGROUPTYPE_PERSISTENT |
+ WM_MANIPULATORGROUPTYPE_3D);
+
+ wgt->poll = WIDGETGROUP_armature_spline_poll;
+ wgt->setup = WIDGETGROUP_armature_spline_setup;
+ wgt->refresh = WIDGETGROUP_armature_spline_refresh;
+}
+
+/** \} */
diff --git a/source/blender/editors/space_view3d/view3d_manipulators.c b/source/blender/editors/space_view3d/view3d_manipulator_camera.c
index 3a12fc31ba2..cac849bcb09 100644
--- a/source/blender/editors/space_view3d/view3d_manipulators.c
+++ b/source/blender/editors/space_view3d/view3d_manipulator_camera.c
@@ -15,12 +15,10 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor(s): none yet.
- *
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/editors/space_view3d/view3d_manipulators.c
+/** \file blender/editors/space_view3d/view3d_manipulator_camera.c
* \ingroup spview3d
*/
@@ -29,21 +27,18 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
-#include "BKE_armature.h"
#include "BKE_camera.h"
#include "BKE_context.h"
-#include "BKE_object.h"
-#include "DNA_armature_types.h"
-#include "DNA_camera_types.h"
-#include "DNA_lamp_types.h"
#include "DNA_object_types.h"
-#include "DNA_object_force.h"
+#include "DNA_camera_types.h"
#include "ED_armature.h"
#include "ED_screen.h"
#include "ED_manipulator_library.h"
+#include "UI_resources.h"
+
#include "MEM_guardedalloc.h"
#include "RNA_access.h"
@@ -53,76 +48,6 @@
#include "view3d_intern.h" /* own include */
-/* -------------------------------------------------------------------- */
-
-/** \name Lamp Manipulators
- * \{ */
-
-static bool WIDGETGROUP_lamp_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
-{
- Object *ob = CTX_data_active_object(C);
-
- if (ob && ob->type == OB_LAMP) {
- Lamp *la = ob->data;
- return (la->type == LA_SPOT);
- }
- return false;
-}
-
-static void WIDGETGROUP_lamp_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
-{
- const char *propname = "spot_size";
-
- const float color[4] = {0.5f, 0.5f, 1.0f, 1.0f};
- const float color_hi[4] = {0.8f, 0.8f, 0.45f, 1.0f};
-
- wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__);
-
- wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_arrow_3d", mgroup, propname, NULL);
- RNA_enum_set(wwrapper->manipulator->ptr, "draw_options", ED_MANIPULATOR_ARROW_STYLE_INVERTED);
-
- mgroup->customdata = wwrapper;
-
- ED_manipulator_arrow3d_set_range_fac(wwrapper->manipulator, 4.0f);
- WM_manipulator_set_color(wwrapper->manipulator, color);
- WM_manipulator_set_color_highlight(wwrapper->manipulator, color_hi);
-}
-
-static void WIDGETGROUP_lamp_refresh(const bContext *C, wmManipulatorGroup *mgroup)
-{
- wmManipulatorWrapper *wwrapper = mgroup->customdata;
- Object *ob = CTX_data_active_object(C);
- Lamp *la = ob->data;
- float dir[3];
-
- negate_v3_v3(dir, ob->obmat[2]);
-
- WM_manipulator_set_matrix_rotation_from_z_axis(wwrapper->manipulator, dir);
- WM_manipulator_set_matrix_location(wwrapper->manipulator, ob->obmat[3]);
-
- /* need to set property here for undo. TODO would prefer to do this in _init */
- PointerRNA lamp_ptr;
- const char *propname = "spot_size";
- RNA_pointer_create(&la->id, &RNA_Lamp, la, &lamp_ptr);
- WM_manipulator_target_property_def_rna(wwrapper->manipulator, "offset", &lamp_ptr, propname, -1);
-}
-
-void VIEW3D_WGT_lamp(wmManipulatorGroupType *wgt)
-{
- wgt->name = "Lamp Widgets";
- wgt->idname = "VIEW3D_WGT_lamp";
-
- wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT |
- WM_MANIPULATORGROUPTYPE_3D |
- WM_MANIPULATORGROUPTYPE_DEPTH_3D);
-
- wgt->poll = WIDGETGROUP_lamp_poll;
- wgt->setup = WIDGETGROUP_lamp_setup;
- wgt->refresh = WIDGETGROUP_lamp_refresh;
-}
-
-/** \} */
-
/* -------------------------------------------------------------------- */
@@ -181,37 +106,36 @@ static void WIDGETGROUP_camera_setup(const bContext *C, wmManipulatorGroup *mgro
/* dof distance */
{
- const float color[4] = {1.0f, 0.3f, 0.0f, 1.0f};
- const float color_hi[4] = {1.0f, 0.3f, 0.0f, 1.0f};
-
- camgroup->dop_dist = WM_manipulator_new_ptr(wt_arrow, mgroup, "dof_distance", NULL);
- RNA_enum_set(camgroup->dop_dist->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_CROSS);
- WM_manipulator_set_flag(camgroup->dop_dist, WM_MANIPULATOR_DRAW_HOVER, true);
- WM_manipulator_set_color(camgroup->dop_dist, color);
- WM_manipulator_set_color_highlight(camgroup->dop_dist, color_hi);
+ wmManipulator *mpr;
+ mpr = camgroup->dop_dist = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL);
+ RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_CROSS);
+ WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_HOVER, true);
+
+ UI_GetThemeColor3fv(TH_MANIPULATOR_A, mpr->color);
+ UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi);
}
/* focal length
* - logic/calculations are similar to BKE_camera_view_frame_ex, better keep in sync */
{
- const float color[4] = {1.0f, 1.0, 0.27f, 0.5f};
- const float color_hi[4] = {1.0f, 1.0, 0.27f, 1.0f};
-
- camgroup->focal_len = WM_manipulator_new_ptr(wt_arrow, mgroup, "focal_len", NULL);
- RNA_enum_set(camgroup->focal_len->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_CONE);
- RNA_enum_set(camgroup->focal_len->ptr, "draw_options", ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED);
-
- WM_manipulator_set_color(camgroup->focal_len, color);
- WM_manipulator_set_color_highlight(camgroup->focal_len, color_hi);
- cameragroup_property_setup(camgroup->focal_len, ob, ca, false);
-
- camgroup->ortho_scale = WM_manipulator_new_ptr(wt_arrow, mgroup, "ortho_scale", NULL);
- RNA_enum_set(camgroup->ortho_scale->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_CONE);
- RNA_enum_set(camgroup->ortho_scale->ptr, "draw_options", ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED);
-
- WM_manipulator_set_color(camgroup->ortho_scale, color);
- WM_manipulator_set_color_highlight(camgroup->ortho_scale, color_hi);
- cameragroup_property_setup(camgroup->ortho_scale, ob, ca, true);
+ wmManipulator *mpr;
+ mpr = camgroup->focal_len = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL);
+ mpr->flag |= WM_MANIPULATOR_DRAW_NO_SCALE;
+ RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_CONE);
+ RNA_enum_set(mpr->ptr, "draw_options", ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED);
+
+ UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color);
+ UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi);
+ cameragroup_property_setup(mpr, ob, ca, false);
+
+ mpr = camgroup->ortho_scale = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL);
+ mpr->flag |= WM_MANIPULATOR_DRAW_NO_SCALE;
+ RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_CONE);
+ RNA_enum_set(mpr->ptr, "draw_options", ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED);
+
+ UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color);
+ UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi);
+ cameragroup_property_setup(mpr, ob, ca, true);
}
}
@@ -269,7 +193,7 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmManipulatorGroup *mg
const float aspx = (float)scene->r.xsch * scene->r.xasp;
const float aspy = (float)scene->r.ysch * scene->r.yasp;
const int sensor_fit = BKE_camera_sensor_fit(ca->sensor_fit, aspx, aspy);
- aspect[0] = (sensor_fit == CAMERA_SENSOR_FIT_HOR) ? 1.0 : aspx / aspy;
+ aspect[0] = (sensor_fit == CAMERA_SENSOR_FIT_HOR) ? 1.0f : aspx / aspy;
aspect[1] = (sensor_fit == CAMERA_SENSOR_FIT_HOR) ? aspy / aspx : 1.0f;
WM_manipulator_set_matrix_location(widget, ob->obmat[3]);
@@ -303,73 +227,164 @@ void VIEW3D_WGT_camera(wmManipulatorGroupType *wgt)
/** \} */
-
/* -------------------------------------------------------------------- */
-/** \name Force Field Manipulators
+/** \name CameraView Manipulators
* \{ */
-static bool WIDGETGROUP_forcefield_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
+struct CameraViewWidgetGroup {
+ wmManipulator *border;
+
+ struct {
+ rctf *edit_border;
+ rctf view_border;
+ } state;
+};
+
+/* scale callbacks */
+static void manipulator_render_border_prop_matrix_get(
+ const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop,
+ void *value_p)
{
- Object *ob = CTX_data_active_object(C);
+ float (*matrix)[4] = value_p;
+ BLI_assert(mpr_prop->type->array_length == 16);
+ struct CameraViewWidgetGroup *viewgroup = mpr_prop->custom_func.user_data;
+ const rctf *border = viewgroup->state.edit_border;
+
+ unit_m4(matrix);
+ matrix[0][0] = BLI_rctf_size_x(border);
+ matrix[1][1] = BLI_rctf_size_y(border);
+ matrix[3][0] = BLI_rctf_cent_x(border);
+ matrix[3][1] = BLI_rctf_cent_y(border);
+}
+
+static void manipulator_render_border_prop_matrix_set(
+ const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop,
+ const void *value_p)
+{
+ const float (*matrix)[4] = value_p;
+ struct CameraViewWidgetGroup *viewgroup = mpr_prop->custom_func.user_data;
+ rctf *border = viewgroup->state.edit_border;
+ BLI_assert(mpr_prop->type->array_length == 16);
+
+ BLI_rctf_resize(border, len_v3(matrix[0]), len_v3(matrix[1]));
+ BLI_rctf_recenter(border, matrix[3][0], matrix[3][1]);
+ BLI_rctf_isect(&(rctf){.xmin = 0, .ymin = 0, .xmax = 1, .ymax = 1}, border, border);
+}
+
+static bool WIDGETGROUP_camera_view_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
+{
+ ARegion *ar = CTX_wm_region(C);
+ RegionView3D *rv3d = ar->regiondata;
+ Scene *scene = CTX_data_scene(C);
+ View3D *v3d = CTX_wm_view3d(C);
+
+ /* This is just so the border isn't always in the way,
+ * stealing mouse clicks from regular usage.
+ * We could change the rules for when to show. */
+ {
+ SceneLayer *sl = CTX_data_scene_layer(C);
+ if (scene->camera != OBACT_NEW(sl)) {
+ return false;
+ }
+ }
- return (ob && ob->pd && ob->pd->forcefield);
+ if (rv3d->persp == RV3D_CAMOB) {
+ if (scene->r.mode & R_BORDER) {
+ return true;
+ }
+ }
+ else if (v3d->flag2 & V3D_RENDER_BORDER) {
+ return true;
+ }
+ return false;
}
-static void WIDGETGROUP_forcefield_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_camera_view_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
{
- const float col[4] = {0.8f, 0.8f, 0.45f, 0.5f};
- const float col_hi[4] = {0.8f, 0.8f, 0.45f, 1.0f};
-
- /* only wind effector for now */
- wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__);
- mgroup->customdata = wwrapper;
-
- wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_arrow_3d", mgroup, "field_strength", NULL);
- RNA_enum_set(wwrapper->manipulator->ptr, "draw_options", ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED);
- ED_manipulator_arrow3d_set_ui_range(wwrapper->manipulator, -200.0f, 200.0f);
- ED_manipulator_arrow3d_set_range_fac(wwrapper->manipulator, 6.0f);
- WM_manipulator_set_color(wwrapper->manipulator, col);
- WM_manipulator_set_color_highlight(wwrapper->manipulator, col_hi);
+ struct CameraViewWidgetGroup *viewgroup = MEM_mallocN(sizeof(struct CameraViewWidgetGroup), __func__);
+
+ viewgroup->border = WM_manipulator_new("MANIPULATOR_WT_cage_2d", mgroup, NULL);
+
+ RNA_enum_set(viewgroup->border->ptr, "transform",
+ ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE | ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE);
+ /* Box style is more subtle in this case. */
+ RNA_enum_set(viewgroup->border->ptr, "draw_style", ED_MANIPULATOR_CAGE2D_STYLE_BOX);
+
+
+ mgroup->customdata = viewgroup;
}
-static void WIDGETGROUP_forcefield_refresh(const bContext *C, wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_camera_view_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup)
{
- wmManipulatorWrapper *wwrapper = mgroup->customdata;
- Object *ob = CTX_data_active_object(C);
- PartDeflect *pd = ob->pd;
-
- if (pd->forcefield == PFIELD_WIND) {
- const float size = (ob->type == OB_EMPTY) ? ob->empty_drawsize : 1.0f;
- const float ofs[3] = {0.0f, -size, 0.0f};
- PointerRNA field_ptr;
-
- RNA_pointer_create(&ob->id, &RNA_FieldSettings, pd, &field_ptr);
- WM_manipulator_set_matrix_location(wwrapper->manipulator, ob->obmat[3]);
- WM_manipulator_set_matrix_rotation_from_z_axis(wwrapper->manipulator, ob->obmat[2]);
- WM_manipulator_set_matrix_offset_location(wwrapper->manipulator, ofs);
- WM_manipulator_set_flag(wwrapper->manipulator, WM_MANIPULATOR_HIDDEN, false);
- WM_manipulator_target_property_def_rna(wwrapper->manipulator, "offset", &field_ptr, "strength", -1);
+ struct CameraViewWidgetGroup *viewgroup = mgroup->customdata;
+
+ ARegion *ar = CTX_wm_region(C);
+ RegionView3D *rv3d = ar->regiondata;
+ if (rv3d->persp == RV3D_CAMOB) {
+ Scene *scene = CTX_data_scene(C);
+ View3D *v3d = CTX_wm_view3d(C);
+ ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &viewgroup->state.view_border, false);
}
else {
- WM_manipulator_set_flag(wwrapper->manipulator, WM_MANIPULATOR_HIDDEN, true);
+ viewgroup->state.view_border = (rctf){.xmin = 0, .ymin = 0, .xmax = ar->winx, .ymax = ar->winy};
}
+
+ wmManipulator *mpr = viewgroup->border;
+ unit_m4(mpr->matrix_space);
+ mul_v3_fl(mpr->matrix_space[0], BLI_rctf_size_x(&viewgroup->state.view_border));
+ mul_v3_fl(mpr->matrix_space[1], BLI_rctf_size_y(&viewgroup->state.view_border));
+ mpr->matrix_space[3][0] = viewgroup->state.view_border.xmin;
+ mpr->matrix_space[3][1] = viewgroup->state.view_border.ymin;
}
-void VIEW3D_WGT_force_field(wmManipulatorGroupType *wgt)
+static void WIDGETGROUP_camera_view_refresh(const bContext *C, wmManipulatorGroup *mgroup)
{
- wgt->name = "Force Field Widgets";
- wgt->idname = "VIEW3D_WGT_force_field";
+ struct CameraViewWidgetGroup *viewgroup = mgroup->customdata;
- wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT |
- WM_MANIPULATORGROUPTYPE_3D |
- WM_MANIPULATORGROUPTYPE_SCALE |
- WM_MANIPULATORGROUPTYPE_DEPTH_3D);
+ View3D *v3d = CTX_wm_view3d(C);
+ ARegion *ar = CTX_wm_region(C);
+ RegionView3D *rv3d = ar->regiondata;
+ Scene *scene = CTX_data_scene(C);
+
+ {
+ wmManipulator *mpr = viewgroup->border;
+ WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false);
+
+ RNA_enum_set(viewgroup->border->ptr, "transform",
+ ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE | ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE);
+
+ if (rv3d->persp == RV3D_CAMOB) {
+ viewgroup->state.edit_border = &scene->r.border;
+ }
+ else {
+ viewgroup->state.edit_border = &v3d->render_border;
+ }
+
+ WM_manipulator_target_property_def_func(
+ mpr, "matrix",
+ &(const struct wmManipulatorPropertyFnParams) {
+ .value_get_fn = manipulator_render_border_prop_matrix_get,
+ .value_set_fn = manipulator_render_border_prop_matrix_set,
+ .range_get_fn = NULL,
+ .user_data = viewgroup,
+ });
+ }
- wgt->poll = WIDGETGROUP_forcefield_poll;
- wgt->setup = WIDGETGROUP_forcefield_setup;
- wgt->refresh = WIDGETGROUP_forcefield_refresh;
}
-/** \} */
+void VIEW3D_WGT_camera_view(wmManipulatorGroupType *wgt)
+{
+ wgt->name = "Camera View Widgets";
+ wgt->idname = "VIEW3D_WGT_camera_view";
+ wgt->flag = (WM_MANIPULATORGROUPTYPE_PERSISTENT |
+ WM_MANIPULATORGROUPTYPE_SCALE);
+
+ wgt->poll = WIDGETGROUP_camera_view_poll;
+ wgt->setup = WIDGETGROUP_camera_view_setup;
+ wgt->draw_prepare = WIDGETGROUP_camera_view_draw_prepare;
+ wgt->refresh = WIDGETGROUP_camera_view_refresh;
+}
+
+/** \} */
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_empty.c b/source/blender/editors/space_view3d/view3d_manipulator_empty.c
new file mode 100644
index 00000000000..1d56c5ee7f4
--- /dev/null
+++ b/source/blender/editors/space_view3d/view3d_manipulator_empty.c
@@ -0,0 +1,196 @@
+/*
+ * ***** 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/space_view3d/view3d_manipulator_empty.c
+ * \ingroup spview3d
+ */
+
+
+#include "BLI_blenlib.h"
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+
+#include "BKE_context.h"
+#include "BKE_object.h"
+#include "BKE_image.h"
+
+#include "DNA_object_types.h"
+#include "DNA_lamp_types.h"
+
+#include "ED_screen.h"
+#include "ED_manipulator_library.h"
+
+#include "UI_resources.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "RNA_access.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "view3d_intern.h" /* own include */
+
+/* -------------------------------------------------------------------- */
+
+/** \name Empty Image Manipulators
+ * \{ */
+
+struct EmptyImageWidgetGroup {
+ wmManipulator *manipulator;
+ struct {
+ Object *ob;
+ float dims[2];
+ } state;
+};
+
+/* translate callbacks */
+static void manipulator_empty_image_prop_matrix_get(
+ const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
+ void *value_p)
+{
+ float (*matrix)[4] = value_p;
+ BLI_assert(mpr_prop->type->array_length == 16);
+ struct EmptyImageWidgetGroup *imgroup = mpr_prop->custom_func.user_data;
+ const Object *ob = imgroup->state.ob;
+
+ unit_m4(matrix);
+ matrix[0][0] = ob->empty_drawsize;
+ matrix[1][1] = ob->empty_drawsize;
+
+ float dims[2] = {0.0f, 0.0f};
+ RNA_float_get_array(mpr->ptr, "dimensions", dims);
+ dims[0] *= ob->empty_drawsize;
+ dims[1] *= ob->empty_drawsize;
+
+ matrix[3][0] = (ob->ima_ofs[0] * dims[0]) + (0.5f * dims[0]);
+ matrix[3][1] = (ob->ima_ofs[1] * dims[1]) + (0.5f * dims[1]);
+}
+
+static void manipulator_empty_image_prop_matrix_set(
+ const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
+ const void *value_p)
+{
+ const float (*matrix)[4] = value_p;
+ BLI_assert(mpr_prop->type->array_length == 16);
+ struct EmptyImageWidgetGroup *imgroup = mpr_prop->custom_func.user_data;
+ Object *ob = imgroup->state.ob;
+
+ ob->empty_drawsize = matrix[0][0];
+
+ float dims[2];
+ RNA_float_get_array(mpr->ptr, "dimensions", dims);
+ dims[0] *= ob->empty_drawsize;
+ dims[1] *= ob->empty_drawsize;
+
+ ob->ima_ofs[0] = (matrix[3][0] - (0.5f * dims[0])) / dims[0];
+ ob->ima_ofs[1] = (matrix[3][1] - (0.5f * dims[1])) / dims[1];
+}
+
+static bool WIDGETGROUP_empty_image_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
+{
+ Object *ob = CTX_data_active_object(C);
+
+ if (ob && ob->type == OB_EMPTY) {
+ return (ob->empty_drawtype == OB_EMPTY_IMAGE);
+ }
+ return false;
+}
+
+static void WIDGETGROUP_empty_image_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
+{
+ struct EmptyImageWidgetGroup *imgroup = MEM_mallocN(sizeof(struct EmptyImageWidgetGroup), __func__);
+ imgroup->manipulator = WM_manipulator_new("MANIPULATOR_WT_cage_2d", mgroup, NULL);
+ wmManipulator *mpr = imgroup->manipulator;
+ RNA_enum_set(mpr->ptr, "transform",
+ ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE);
+
+ mgroup->customdata = imgroup;
+
+ WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_HOVER, true);
+
+ UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color);
+ UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi);
+}
+
+static void WIDGETGROUP_empty_image_refresh(const bContext *C, wmManipulatorGroup *mgroup)
+{
+ struct EmptyImageWidgetGroup *imgroup = mgroup->customdata;
+ Object *ob = CTX_data_active_object(C);
+ wmManipulator *mpr = imgroup->manipulator;
+
+ copy_m4_m4(mpr->matrix_basis, ob->obmat);
+
+ RNA_enum_set(mpr->ptr, "transform",
+ ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE |
+ ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE |
+ ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM);
+
+ imgroup->state.ob = ob;
+
+ /* Use dimensions for aspect. */
+ if (ob->data != NULL) {
+ const Image *image = ob->data;
+ ImageUser iuser = *ob->iuser;
+ float size[2];
+ BKE_image_get_size_fl(ob->data, &iuser, size);
+
+ /* Get the image aspect even if the buffer is invalid */
+ if (image->aspx > image->aspy) {
+ size[1] *= image->aspy / image->aspx;
+ }
+ else if (image->aspx < image->aspy) {
+ size[0] *= image->aspx / image->aspy;
+ }
+
+ const float dims_max = max_ff(size[0], size[1]);
+ imgroup->state.dims[0] = size[0] / dims_max;
+ imgroup->state.dims[1] = size[1] / dims_max;
+ }
+ else {
+ copy_v2_fl(imgroup->state.dims, 1.0f);
+ }
+ RNA_float_set_array(mpr->ptr, "dimensions", imgroup->state.dims);
+
+ WM_manipulator_target_property_def_func(
+ mpr, "matrix",
+ &(const struct wmManipulatorPropertyFnParams) {
+ .value_get_fn = manipulator_empty_image_prop_matrix_get,
+ .value_set_fn = manipulator_empty_image_prop_matrix_set,
+ .range_get_fn = NULL,
+ .user_data = imgroup,
+ });
+}
+
+void VIEW3D_WGT_empty_image(wmManipulatorGroupType *wgt)
+{
+ wgt->name = "Area Lamp Widgets";
+ wgt->idname = "VIEW3D_WGT_empty_image";
+
+ wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT |
+ WM_MANIPULATORGROUPTYPE_3D |
+ WM_MANIPULATORGROUPTYPE_DEPTH_3D);
+
+ wgt->poll = WIDGETGROUP_empty_image_poll;
+ wgt->setup = WIDGETGROUP_empty_image_setup;
+ wgt->refresh = WIDGETGROUP_empty_image_refresh;
+}
+
+/** \} */
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_forcefield.c b/source/blender/editors/space_view3d/view3d_manipulator_forcefield.c
new file mode 100644
index 00000000000..6a34f493caf
--- /dev/null
+++ b/source/blender/editors/space_view3d/view3d_manipulator_forcefield.c
@@ -0,0 +1,118 @@
+/*
+ * ***** 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/space_view3d/view3d_manipulator_forcefield.c
+ * \ingroup spview3d
+ */
+
+
+#include "BLI_blenlib.h"
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+
+#include "BKE_context.h"
+#include "BKE_object.h"
+
+#include "DNA_object_types.h"
+#include "DNA_object_force.h"
+
+#include "ED_screen.h"
+#include "ED_manipulator_library.h"
+
+#include "UI_resources.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "RNA_access.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "view3d_intern.h" /* own include */
+
+/* -------------------------------------------------------------------- */
+
+/** \name Force Field Manipulators
+ * \{ */
+
+static bool WIDGETGROUP_forcefield_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
+{
+ Object *ob = CTX_data_active_object(C);
+
+ return (ob && ob->pd && ob->pd->forcefield);
+}
+
+static void WIDGETGROUP_forcefield_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
+{
+ /* only wind effector for now */
+ wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__);
+ mgroup->customdata = wwrapper;
+
+ wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_arrow_3d", mgroup, NULL);
+ wmManipulator *mpr = wwrapper->manipulator;
+ RNA_enum_set(mpr->ptr, "draw_options", ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED);
+ ED_manipulator_arrow3d_set_ui_range(mpr, -200.0f, 200.0f);
+ ED_manipulator_arrow3d_set_range_fac(mpr, 6.0f);
+
+ UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color);
+ UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi);
+}
+
+static void WIDGETGROUP_forcefield_refresh(const bContext *C, wmManipulatorGroup *mgroup)
+{
+ wmManipulatorWrapper *wwrapper = mgroup->customdata;
+ wmManipulator *mpr = wwrapper->manipulator;
+ Object *ob = CTX_data_active_object(C);
+ PartDeflect *pd = ob->pd;
+
+ if (pd->forcefield == PFIELD_WIND) {
+ const float size = (ob->type == OB_EMPTY) ? ob->empty_drawsize : 1.0f;
+ const float ofs[3] = {0.0f, -size, 0.0f};
+ PointerRNA field_ptr;
+
+ RNA_pointer_create(&ob->id, &RNA_FieldSettings, pd, &field_ptr);
+ WM_manipulator_set_matrix_location(mpr, ob->obmat[3]);
+ WM_manipulator_set_matrix_rotation_from_z_axis(mpr, ob->obmat[2]);
+ WM_manipulator_set_matrix_offset_location(mpr, ofs);
+ WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false);
+ WM_manipulator_target_property_def_rna(mpr, "offset", &field_ptr, "strength", -1);
+ }
+ else {
+ WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true);
+ }
+}
+
+void VIEW3D_WGT_force_field(wmManipulatorGroupType *wgt)
+{
+ wgt->name = "Force Field Widgets";
+ wgt->idname = "VIEW3D_WGT_force_field";
+
+ wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT |
+ WM_MANIPULATORGROUPTYPE_3D |
+ WM_MANIPULATORGROUPTYPE_SCALE |
+ WM_MANIPULATORGROUPTYPE_DEPTH_3D);
+
+ wgt->poll = WIDGETGROUP_forcefield_poll;
+ wgt->setup = WIDGETGROUP_forcefield_setup;
+ wgt->refresh = WIDGETGROUP_forcefield_refresh;
+}
+
+/** \} */
+
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_lamp.c b/source/blender/editors/space_view3d/view3d_manipulator_lamp.c
new file mode 100644
index 00000000000..93b6b69a105
--- /dev/null
+++ b/source/blender/editors/space_view3d/view3d_manipulator_lamp.c
@@ -0,0 +1,289 @@
+/*
+ * ***** 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/space_view3d/view3d_manipulator_lamp.c
+ * \ingroup spview3d
+ */
+
+
+#include "BLI_blenlib.h"
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+
+#include "BKE_context.h"
+#include "BKE_object.h"
+
+#include "DNA_object_types.h"
+#include "DNA_lamp_types.h"
+
+#include "ED_screen.h"
+#include "ED_manipulator_library.h"
+
+#include "UI_resources.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "RNA_access.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "view3d_intern.h" /* own include */
+
+/* -------------------------------------------------------------------- */
+
+/** \name Spot Lamp Manipulators
+ * \{ */
+
+static bool WIDGETGROUP_lamp_spot_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
+{
+ Object *ob = CTX_data_active_object(C);
+
+ if (ob && ob->type == OB_LAMP) {
+ Lamp *la = ob->data;
+ return (la->type == LA_SPOT);
+ }
+ return false;
+}
+
+static void WIDGETGROUP_lamp_spot_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
+{
+ wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__);
+
+ wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_arrow_3d", mgroup, NULL);
+ wmManipulator *mpr = wwrapper->manipulator;
+ RNA_enum_set(mpr->ptr, "draw_options", ED_MANIPULATOR_ARROW_STYLE_INVERTED);
+
+ mgroup->customdata = wwrapper;
+
+ ED_manipulator_arrow3d_set_range_fac(mpr, 4.0f);
+
+ UI_GetThemeColor3fv(TH_MANIPULATOR_SECONDARY, mpr->color);
+}
+
+static void WIDGETGROUP_lamp_spot_refresh(const bContext *C, wmManipulatorGroup *mgroup)
+{
+ wmManipulatorWrapper *wwrapper = mgroup->customdata;
+ wmManipulator *mpr = wwrapper->manipulator;
+ Object *ob = CTX_data_active_object(C);
+ Lamp *la = ob->data;
+ float dir[3];
+
+ negate_v3_v3(dir, ob->obmat[2]);
+
+ WM_manipulator_set_matrix_rotation_from_z_axis(mpr, dir);
+ WM_manipulator_set_matrix_location(mpr, ob->obmat[3]);
+
+ /* need to set property here for undo. TODO would prefer to do this in _init */
+ PointerRNA lamp_ptr;
+ const char *propname = "spot_size";
+ RNA_pointer_create(&la->id, &RNA_Lamp, la, &lamp_ptr);
+ WM_manipulator_target_property_def_rna(mpr, "offset", &lamp_ptr, propname, -1);
+}
+
+void VIEW3D_WGT_lamp_spot(wmManipulatorGroupType *wgt)
+{
+ wgt->name = "Spot Lamp Widgets";
+ wgt->idname = "VIEW3D_WGT_lamp_spot";
+
+ wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT |
+ WM_MANIPULATORGROUPTYPE_3D |
+ WM_MANIPULATORGROUPTYPE_DEPTH_3D);
+
+ wgt->poll = WIDGETGROUP_lamp_spot_poll;
+ wgt->setup = WIDGETGROUP_lamp_spot_setup;
+ wgt->refresh = WIDGETGROUP_lamp_spot_refresh;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+
+/** \name Area Lamp Manipulators
+ * \{ */
+
+/* scale callbacks */
+static void manipulator_area_lamp_prop_matrix_get(
+ const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop,
+ void *value_p)
+{
+ BLI_assert(mpr_prop->type->array_length == 16);
+ float (*matrix)[4] = value_p;
+ const Lamp *la = mpr_prop->custom_func.user_data;
+
+ matrix[0][0] = la->area_size;
+ matrix[1][1] = (la->area_shape == LA_AREA_RECT) ? la->area_sizey : la->area_size;
+}
+
+static void manipulator_area_lamp_prop_matrix_set(
+ const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop,
+ const void *value_p)
+{
+ const float (*matrix)[4] = value_p;
+ BLI_assert(mpr_prop->type->array_length == 16);
+ Lamp *la = mpr_prop->custom_func.user_data;
+
+ if (la->area_shape == LA_AREA_RECT) {
+ la->area_size = len_v3(matrix[0]);
+ la->area_sizey = len_v3(matrix[1]);
+ }
+ else {
+ la->area_size = len_v3(matrix[0]);
+ }
+}
+
+static bool WIDGETGROUP_lamp_area_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
+{
+ Object *ob = CTX_data_active_object(C);
+
+ if (ob && ob->type == OB_LAMP) {
+ Lamp *la = ob->data;
+ return (la->type == LA_AREA);
+ }
+ return false;
+}
+
+static void WIDGETGROUP_lamp_area_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
+{
+ wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__);
+ wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_cage_2d", mgroup, NULL);
+ wmManipulator *mpr = wwrapper->manipulator;
+ RNA_enum_set(mpr->ptr, "transform",
+ ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE);
+
+ mgroup->customdata = wwrapper;
+
+ WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_HOVER, true);
+
+ UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color);
+ UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi);
+}
+
+static void WIDGETGROUP_lamp_area_refresh(const bContext *C, wmManipulatorGroup *mgroup)
+{
+ wmManipulatorWrapper *wwrapper = mgroup->customdata;
+ Object *ob = CTX_data_active_object(C);
+ Lamp *la = ob->data;
+ wmManipulator *mpr = wwrapper->manipulator;
+
+ copy_m4_m4(mpr->matrix_basis, ob->obmat);
+
+ RNA_enum_set(mpr->ptr, "transform",
+ ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE |
+ ((la->area_shape == LA_AREA_SQUARE) ? ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM : 0));
+
+ /* need to set property here for undo. TODO would prefer to do this in _init */
+ WM_manipulator_target_property_def_func(
+ mpr, "matrix",
+ &(const struct wmManipulatorPropertyFnParams) {
+ .value_get_fn = manipulator_area_lamp_prop_matrix_get,
+ .value_set_fn = manipulator_area_lamp_prop_matrix_set,
+ .range_get_fn = NULL,
+ .user_data = la,
+ });
+}
+
+void VIEW3D_WGT_lamp_area(wmManipulatorGroupType *wgt)
+{
+ wgt->name = "Area Lamp Widgets";
+ wgt->idname = "VIEW3D_WGT_lamp_area";
+
+ wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT |
+ WM_MANIPULATORGROUPTYPE_3D |
+ WM_MANIPULATORGROUPTYPE_DEPTH_3D);
+
+ wgt->poll = WIDGETGROUP_lamp_area_poll;
+ wgt->setup = WIDGETGROUP_lamp_area_setup;
+ wgt->refresh = WIDGETGROUP_lamp_area_refresh;
+}
+
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+
+/** \name Lamp Target Manipulator
+ * \{ */
+
+static bool WIDGETGROUP_lamp_target_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
+{
+ Object *ob = CTX_data_active_object(C);
+
+ if (ob != NULL) {
+ if (ob->type == OB_LAMP) {
+ Lamp *la = ob->data;
+ return (ELEM(la->type, LA_SUN, LA_SPOT, LA_HEMI, LA_AREA));
+ }
+#if 0
+ else if (ob->type == OB_CAMERA) {
+ return true;
+ }
+#endif
+ }
+ return false;
+}
+
+static void WIDGETGROUP_lamp_target_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
+{
+ wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__);
+ wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_grab_3d", mgroup, NULL);
+ wmManipulator *mpr = wwrapper->manipulator;
+
+ mgroup->customdata = wwrapper;
+
+ UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color);
+ UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi);
+
+ mpr->scale_basis = 0.06f;
+
+ wmOperatorType *ot = WM_operatortype_find("OBJECT_OT_transform_axis_target", true);
+
+ RNA_enum_set(mpr->ptr, "draw_options",
+ ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL | ED_MANIPULATOR_GRAB_DRAW_FLAG_ALIGN_VIEW);
+
+ WM_manipulator_operator_set(mpr, 0, ot, NULL);
+}
+
+static void WIDGETGROUP_lamp_target_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup)
+{
+ wmManipulatorWrapper *wwrapper = mgroup->customdata;
+ Object *ob = CTX_data_active_object(C);
+ wmManipulator *mpr = wwrapper->manipulator;
+
+ copy_m4_m4(mpr->matrix_basis, ob->obmat);
+ unit_m4(mpr->matrix_offset);
+ mpr->matrix_offset[3][2] = -2.4f / mpr->scale_basis;
+ WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_OFFSET_SCALE, true);
+}
+
+void VIEW3D_WGT_lamp_target(wmManipulatorGroupType *wgt)
+{
+ wgt->name = "Target Lamp Widgets";
+ wgt->idname = "VIEW3D_WGT_lamp_target";
+
+ wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT |
+ WM_MANIPULATORGROUPTYPE_3D);
+
+ wgt->poll = WIDGETGROUP_lamp_target_poll;
+ wgt->setup = WIDGETGROUP_lamp_target_setup;
+ wgt->draw_prepare = WIDGETGROUP_lamp_target_draw_prepare;
+}
+
+/** \} */
diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c
index 550a0ee4186..60e90121ad1 100644
--- a/source/blender/editors/space_view3d/view3d_ruler.c
+++ b/source/blender/editors/space_view3d/view3d_ruler.c
@@ -51,7 +51,6 @@
#include "ED_screen.h"
#include "ED_view3d.h"
-#include "ED_transform.h"
#include "ED_transform_snap_object_context.h"
#include "ED_space_api.h"
@@ -461,7 +460,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
if (ruler_item->flag & RULERITEM_USE_ANGLE) {
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
@@ -600,7 +599,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
}
}
else {
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
@@ -705,7 +704,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4fv(color_act);
- imm_draw_circle_wire(pos, co_ss[0], co_ss[1], size * U.pixelsize, 32);
+ imm_draw_circle_wire_2d(pos, co_ss[0], co_ss[1], size * U.pixelsize, 32);
immUnbindProgram();
}
@@ -1042,9 +1041,12 @@ static int view3d_ruler_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
case RETKEY:
{
- view3d_ruler_to_gpencil(C, ruler_info);
- do_draw = true;
- exit_code = OPERATOR_FINISHED;
+ /* Enter may be used to invoke from search. */
+ if (event->val == KM_PRESS) {
+ view3d_ruler_to_gpencil(C, ruler_info);
+ do_draw = true;
+ exit_code = OPERATOR_FINISHED;
+ }
break;
}
case DELKEY:
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 049c0367ce6..5ac3aa15d4c 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -94,6 +94,7 @@
#include "UI_interface.h"
#include "GPU_draw.h"
+#include "GPU_glew.h"
#include "GPU_matrix.h"
#include "view3d_intern.h" /* own include */
@@ -456,7 +457,9 @@ static void do_lasso_select_mesh__doSelectFace(void *userData, BMFace *efa, cons
}
}
-static void do_lasso_select_mesh(ViewContext *vc, const int mcords[][2], short moves, bool extend, bool select)
+static void do_lasso_select_mesh(
+ const struct EvaluationContext *eval_ctx, ViewContext *vc,
+ const int mcords[][2], short moves, bool extend, bool select)
{
LassoSelectUserData data;
ToolSettings *ts = vc->scene->toolsettings;
@@ -477,24 +480,24 @@ static void do_lasso_select_mesh(ViewContext *vc, const int mcords[][2], short m
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
gpuLoadMatrix(vc->rv3d->viewmat);
- bbsel = EDBM_backbuf_border_mask_init(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
+ bbsel = EDBM_backbuf_border_mask_init(eval_ctx, vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
if (ts->selectmode & SCE_SELECT_VERTEX) {
if (bbsel) {
edbm_backbuf_check_and_select_verts(vc->em, select);
}
else {
- mesh_foreachScreenVert(vc, do_lasso_select_mesh__doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
+ mesh_foreachScreenVert(eval_ctx, vc, do_lasso_select_mesh__doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
}
if (ts->selectmode & SCE_SELECT_EDGE) {
/* Does both bbsel and non-bbsel versions (need screen cos for both) */
data.pass = 0;
- mesh_foreachScreenEdge(vc, do_lasso_select_mesh__doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR);
+ mesh_foreachScreenEdge(eval_ctx, vc, do_lasso_select_mesh__doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR);
if (data.is_done == false) {
data.pass = 1;
- mesh_foreachScreenEdge(vc, do_lasso_select_mesh__doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR);
+ mesh_foreachScreenEdge(eval_ctx, vc, do_lasso_select_mesh__doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR);
}
}
@@ -503,7 +506,7 @@ static void do_lasso_select_mesh(ViewContext *vc, const int mcords[][2], short m
edbm_backbuf_check_and_select_faces(vc->em, select);
}
else {
- mesh_foreachScreenFace(vc, do_lasso_select_mesh__doSelectFace, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
+ mesh_foreachScreenFace(eval_ctx, vc, do_lasso_select_mesh__doSelectFace, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
}
@@ -702,7 +705,7 @@ static void do_lasso_select_meshobject__doSelectVert(void *userData, MVert *mv,
BKE_BIT_TEST_SET(mv->flag, data->select, SELECT);
}
}
-static void do_lasso_select_paintvert(ViewContext *vc, const int mcords[][2], short moves, bool extend, bool select)
+static void do_lasso_select_paintvert(const struct EvaluationContext *eval_ctx, ViewContext *vc, const int mcords[][2], short moves, bool extend, bool select)
{
const bool use_zbuf = (vc->v3d->flag & V3D_ZBUF_SELECT) != 0;
Object *ob = vc->obact;
@@ -720,7 +723,7 @@ static void do_lasso_select_paintvert(ViewContext *vc, const int mcords[][2], sh
if (use_zbuf) {
bm_vertoffs = me->totvert + 1; /* max index array */
- EDBM_backbuf_border_mask_init(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
+ EDBM_backbuf_border_mask_init(eval_ctx, vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
edbm_backbuf_check_and_select_verts_obmode(me, select);
@@ -733,7 +736,7 @@ static void do_lasso_select_paintvert(ViewContext *vc, const int mcords[][2], sh
ED_view3d_init_mats_rv3d(vc->obact, vc->rv3d);
- meshobject_foreachScreenVert(vc, do_lasso_select_meshobject__doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
+ meshobject_foreachScreenVert(eval_ctx, vc, do_lasso_select_meshobject__doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
@@ -742,7 +745,7 @@ static void do_lasso_select_paintvert(ViewContext *vc, const int mcords[][2], sh
}
paintvert_flush_flags(ob);
}
-static void do_lasso_select_paintface(ViewContext *vc, const int mcords[][2], short moves, bool extend, bool select)
+static void do_lasso_select_paintface(const struct EvaluationContext *eval_ctx, ViewContext *vc, const int mcords[][2], short moves, bool extend, bool select)
{
Object *ob = vc->obact;
Mesh *me = ob->data;
@@ -757,7 +760,7 @@ static void do_lasso_select_paintface(ViewContext *vc, const int mcords[][2], sh
bm_vertoffs = me->totpoly + 1; /* max index array */
BLI_lasso_boundbox(&rect, mcords, moves);
- EDBM_backbuf_border_mask_init(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
+ EDBM_backbuf_border_mask_init(eval_ctx, vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
edbm_backbuf_check_and_select_tfaces(me, select);
@@ -803,16 +806,22 @@ static void view3d_lasso_select(bContext *C, ViewContext *vc,
{
Object *ob = CTX_data_active_object(C);
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
if (vc->obedit == NULL) { /* Object Mode */
- if (BKE_paint_select_face_test(ob))
- do_lasso_select_paintface(vc, mcords, moves, extend, select);
- else if (BKE_paint_select_vert_test(ob))
- do_lasso_select_paintvert(vc, mcords, moves, extend, select);
+ if (BKE_paint_select_face_test(ob)) {
+ do_lasso_select_paintface(&eval_ctx, vc, mcords, moves, extend, select);
+ }
+ else if (BKE_paint_select_vert_test(ob)) {
+ do_lasso_select_paintvert(&eval_ctx, vc, mcords, moves, extend, select);
+ }
else if (ob && (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))) {
/* pass */
}
- else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT))
+ else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT)) {
PE_lasso_select(C, mcords, moves, extend, select);
+ }
else {
do_lasso_select_objects(vc, mcords, moves, extend, select);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, vc->scene);
@@ -821,7 +830,7 @@ static void view3d_lasso_select(bContext *C, ViewContext *vc,
else { /* Edit Mode */
switch (vc->obedit->type) {
case OB_MESH:
- do_lasso_select_mesh(vc, mcords, moves, extend, select);
+ do_lasso_select_mesh(&eval_ctx, vc, mcords, moves, extend, select);
break;
case OB_CURVE:
case OB_SURF:
@@ -1176,7 +1185,7 @@ static int selectbuffer_ret_hits_5(unsigned int *buffer, const int hits15, const
/* we want a select buffer with bones, if there are... */
/* so check three selection levels and compare */
static int mixed_bones_object_selectbuffer(
- ViewContext *vc, unsigned int *buffer, const int mval[2],
+ const EvaluationContext *eval_ctx, ViewContext *vc, unsigned int *buffer, const int mval[2],
bool use_cycle, bool enumerate,
bool *r_do_nearest)
{
@@ -1216,7 +1225,7 @@ static int mixed_bones_object_selectbuffer(
view3d_opengl_select_cache_begin();
BLI_rcti_init_pt_radius(&rect, mval, 14);
- hits15 = view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect, select_mode);
+ hits15 = view3d_opengl_select(eval_ctx, vc, buffer, MAXPICKBUF, &rect, select_mode);
if (hits15 == 1) {
hits = selectbuffer_ret_hits_15(buffer, hits15);
goto finally;
@@ -1227,7 +1236,7 @@ static int mixed_bones_object_selectbuffer(
offs = 4 * hits15;
BLI_rcti_init_pt_radius(&rect, mval, 9);
- hits9 = view3d_opengl_select(vc, buffer + offs, MAXPICKBUF - offs, &rect, select_mode);
+ hits9 = view3d_opengl_select(eval_ctx, vc, buffer + offs, MAXPICKBUF - offs, &rect, select_mode);
if (hits9 == 1) {
hits = selectbuffer_ret_hits_9(buffer, hits15, hits9);
goto finally;
@@ -1237,7 +1246,7 @@ static int mixed_bones_object_selectbuffer(
offs += 4 * hits9;
BLI_rcti_init_pt_radius(&rect, mval, 5);
- hits5 = view3d_opengl_select(vc, buffer + offs, MAXPICKBUF - offs, &rect, select_mode);
+ hits5 = view3d_opengl_select(eval_ctx, vc, buffer + offs, MAXPICKBUF - offs, &rect, select_mode);
if (hits5 == 1) {
hits = selectbuffer_ret_hits_5(buffer, hits15, hits9, hits5);
goto finally;
@@ -1286,8 +1295,8 @@ static Base *mouse_select_eval_buffer(ViewContext *vc, unsigned int *buffer, int
}
else {
/* only exclude active object when it is selected... */
- if (BASACT_NEW && (BASACT_NEW->flag & BASE_SELECTED) && hits > 1) {
- notcol = BASACT_NEW->object->select_color;
+ if (BASACT_NEW(sl) && (BASACT_NEW(sl)->flag & BASE_SELECTED) && hits > 1) {
+ notcol = BASACT_NEW(sl)->object->select_color;
}
for (a = 0; a < hits; a++) {
@@ -1298,7 +1307,7 @@ static Base *mouse_select_eval_buffer(ViewContext *vc, unsigned int *buffer, int
}
}
- base = FIRSTBASE_NEW;
+ base = FIRSTBASE_NEW(sl);
while (base) {
if (BASE_SELECTABLE_NEW(base)) {
if (base->object->select_color == selcol) break;
@@ -1315,7 +1324,7 @@ static Base *mouse_select_eval_buffer(ViewContext *vc, unsigned int *buffer, int
* with an un-selectable choice */
if ((base->flag & BASE_SELECTABLED) == 0) {
base = base->next;
- if (base == NULL) base = FIRSTBASE_NEW;
+ if (base == NULL) base = FIRSTBASE_NEW(sl);
if (base == startbase) break;
}
@@ -1338,7 +1347,7 @@ static Base *mouse_select_eval_buffer(ViewContext *vc, unsigned int *buffer, int
if (basact) break;
base = base->next;
- if (base == NULL) base = FIRSTBASE_NEW;
+ if (base == NULL) base = FIRSTBASE_NEW(sl);
if (base == startbase) break;
}
}
@@ -1349,6 +1358,7 @@ static Base *mouse_select_eval_buffer(ViewContext *vc, unsigned int *buffer, int
/* mval comes from event->mval, only use within region handlers */
Base *ED_view3d_give_base_under_cursor(bContext *C, const int mval[2])
{
+ EvaluationContext eval_ctx;
ViewContext vc;
Base *basact = NULL;
unsigned int buffer[MAXPICKBUF];
@@ -1357,9 +1367,11 @@ Base *ED_view3d_give_base_under_cursor(bContext *C, const int mval[2])
/* setup view context for argument to callbacks */
view3d_operator_needs_opengl(C);
+
+ CTX_data_eval_ctx(C, &eval_ctx);
view3d_set_viewcontext(C, &vc);
- hits = mixed_bones_object_selectbuffer(&vc, buffer, mval, false, false, &do_nearest);
+ hits = mixed_bones_object_selectbuffer(&eval_ctx, &vc, buffer, mval, false, false, &do_nearest);
if (hits > 0) {
const bool has_bones = selectbuffer_has_bones(buffer, hits);
@@ -1393,6 +1405,7 @@ static bool ed_object_select_pick(
bContext *C, const int mval[2],
bool extend, bool deselect, bool toggle, bool obcenter, bool enumerate, bool object)
{
+ EvaluationContext eval_ctx;
ViewContext vc;
ARegion *ar = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
@@ -1406,6 +1419,7 @@ static bool ed_object_select_pick(
/* setup view context for argument to callbacks */
+ CTX_data_eval_ctx(C, &eval_ctx);
view3d_set_viewcontext(C, &vc);
is_obedit = (vc.obedit != NULL);
@@ -1415,8 +1429,8 @@ static bool ed_object_select_pick(
}
/* always start list from basact in wire mode */
- startbase = FIRSTBASE_NEW;
- if (BASACT_NEW && BASACT_NEW->next) startbase = BASACT_NEW->next;
+ startbase = FIRSTBASE_NEW(sl);
+ if (BASACT_NEW(sl) && BASACT_NEW(sl)->next) startbase = BASACT_NEW(sl)->next;
/* This block uses the control key to make the object selected by its center point rather than its contents */
/* in editmode do not activate */
@@ -1435,7 +1449,7 @@ static bool ed_object_select_pick(
V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN | V3D_PROJ_TEST_CLIP_NEAR) == V3D_PROJ_RET_OK)
{
float dist_temp = len_manhattan_v2v2(mval_fl, screen_co);
- if (base == BASACT_NEW) dist_temp += 10.0f;
+ if (base == BASACT_NEW(sl)) dist_temp += 10.0f;
if (dist_temp < dist) {
dist = dist_temp;
basact = base;
@@ -1444,7 +1458,7 @@ static bool ed_object_select_pick(
}
base = base->next;
- if (base == NULL) base = FIRSTBASE_NEW;
+ if (base == NULL) base = FIRSTBASE_NEW(sl);
if (base == startbase) break;
}
}
@@ -1456,7 +1470,7 @@ static bool ed_object_select_pick(
// TIMEIT_START(select_time);
/* if objects have posemode set, the bones are in the same selection buffer */
- hits = mixed_bones_object_selectbuffer(&vc, buffer, mval, true, enumerate, &do_nearest);
+ hits = mixed_bones_object_selectbuffer(&eval_ctx, &vc, buffer, mval, true, enumerate, &do_nearest);
// TIMEIT_END(select_time);
@@ -1474,7 +1488,7 @@ static bool ed_object_select_pick(
if (has_bones && basact) {
if (basact->object->type == OB_CAMERA) {
- if (BASACT_NEW == basact) {
+ if (BASACT_NEW(sl) == basact) {
int i, hitresult;
bool changed = false;
@@ -1544,14 +1558,14 @@ static bool ed_object_select_pick(
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, basact->object);
/* in weightpaint, we use selected bone to select vertexgroup, so no switch to new active object */
- if (BASACT_NEW && (BASACT_NEW->object->mode & OB_MODE_WEIGHT_PAINT)) {
+ if (BASACT_NEW(sl) && (BASACT_NEW(sl)->object->mode & OB_MODE_WEIGHT_PAINT)) {
/* prevent activating */
basact = NULL;
}
}
/* prevent bone selecting to pass on to object selecting */
- if (basact == BASACT_NEW)
+ if (basact == BASACT_NEW(sl))
basact = NULL;
}
}
@@ -1569,7 +1583,7 @@ static bool ed_object_select_pick(
/* also prevent making it active on mouse selection */
else if (BASE_SELECTABLE_NEW(basact)) {
- oldbasact = BASACT_NEW;
+ oldbasact = BASACT_NEW(sl);
if (extend) {
ED_object_base_select(basact, BA_SELECT);
@@ -1649,7 +1663,8 @@ static void do_paintvert_box_select__doSelectVert(void *userData, MVert *mv, con
BKE_BIT_TEST_SET(mv->flag, data->select, SELECT);
}
}
-static int do_paintvert_box_select(ViewContext *vc, rcti *rect, bool select, bool extend)
+static int do_paintvert_box_select(
+ const EvaluationContext *eval_ctx, ViewContext *vc, rcti *rect, bool select, bool extend)
{
const bool use_zbuf = (vc->v3d->flag & V3D_ZBUF_SELECT) != 0;
Mesh *me;
@@ -1673,7 +1688,7 @@ static int do_paintvert_box_select(ViewContext *vc, rcti *rect, bool select, boo
if (use_zbuf) {
selar = MEM_callocN(me->totvert + 1, "selar");
- ED_view3d_backbuf_validate(vc);
+ ED_view3d_backbuf_validate(eval_ctx, vc);
ibuf = IMB_allocImBuf(size[0], size[1], 32, IB_rect);
rt = ibuf->rect;
@@ -1721,7 +1736,7 @@ static int do_paintvert_box_select(ViewContext *vc, rcti *rect, bool select, boo
ED_view3d_init_mats_rv3d(vc->obact, vc->rv3d);
- meshobject_foreachScreenVert(vc, do_paintvert_box_select__doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
+ meshobject_foreachScreenVert(eval_ctx, vc, do_paintvert_box_select__doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
if (select == false) {
@@ -1836,7 +1851,8 @@ static void do_mesh_box_select__doSelectFace(void *userData, BMFace *efa, const
BM_face_select_set(data->vc->em->bm, efa, data->select);
}
}
-static int do_mesh_box_select(ViewContext *vc, rcti *rect, bool select, bool extend)
+static int do_mesh_box_select(
+ const struct EvaluationContext *eval_ctx, ViewContext *vc, rcti *rect, bool select, bool extend)
{
BoxSelectUserData data;
ToolSettings *ts = vc->scene->toolsettings;
@@ -1851,25 +1867,25 @@ static int do_mesh_box_select(ViewContext *vc, rcti *rect, bool select, bool ext
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
gpuLoadMatrix(vc->rv3d->viewmat);
- bbsel = EDBM_backbuf_border_init(vc, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
+ bbsel = EDBM_backbuf_border_init(eval_ctx, vc, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
if (ts->selectmode & SCE_SELECT_VERTEX) {
if (bbsel) {
edbm_backbuf_check_and_select_verts(vc->em, select);
}
else {
- mesh_foreachScreenVert(vc, do_mesh_box_select__doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
+ mesh_foreachScreenVert(eval_ctx, vc, do_mesh_box_select__doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
}
if (ts->selectmode & SCE_SELECT_EDGE) {
/* Does both bbsel and non-bbsel versions (need screen cos for both) */
data.pass = 0;
- mesh_foreachScreenEdge(vc, do_mesh_box_select__doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR);
+ mesh_foreachScreenEdge(eval_ctx, vc, do_mesh_box_select__doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR);
if (data.is_done == 0) {
data.pass = 1;
- mesh_foreachScreenEdge(vc, do_mesh_box_select__doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR);
+ mesh_foreachScreenEdge(eval_ctx, vc, do_mesh_box_select__doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR);
}
}
@@ -1878,7 +1894,7 @@ static int do_mesh_box_select(ViewContext *vc, rcti *rect, bool select, bool ext
edbm_backbuf_check_and_select_faces(vc->em, select);
}
else {
- mesh_foreachScreenFace(vc, do_mesh_box_select__doSelectFace, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
+ mesh_foreachScreenFace(eval_ctx, vc, do_mesh_box_select__doSelectFace, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
}
@@ -1889,7 +1905,9 @@ static int do_mesh_box_select(ViewContext *vc, rcti *rect, bool select, bool ext
return OPERATOR_FINISHED;
}
-static int do_meta_box_select(ViewContext *vc, rcti *rect, bool select, bool extend)
+static int do_meta_box_select(
+ const struct EvaluationContext *eval_ctx, ViewContext *vc,
+ const rcti *rect, bool select, bool extend)
{
MetaBall *mb = (MetaBall *)vc->obedit->data;
MetaElem *ml;
@@ -1898,7 +1916,7 @@ static int do_meta_box_select(ViewContext *vc, rcti *rect, bool select, bool ext
unsigned int buffer[MAXPICKBUF];
int hits;
- hits = view3d_opengl_select(vc, buffer, MAXPICKBUF, rect, VIEW3D_SELECT_ALL);
+ hits = view3d_opengl_select(eval_ctx, vc, buffer, MAXPICKBUF, rect, VIEW3D_SELECT_ALL);
if (extend == false && select)
BKE_mball_deselect_all(mb);
@@ -1923,7 +1941,9 @@ static int do_meta_box_select(ViewContext *vc, rcti *rect, bool select, bool ext
return OPERATOR_FINISHED;
}
-static int do_armature_box_select(ViewContext *vc, rcti *rect, bool select, bool extend)
+static int do_armature_box_select(
+ const struct EvaluationContext *eval_ctx, ViewContext *vc,
+ const rcti *rect, bool select, bool extend)
{
bArmature *arm = vc->obedit->data;
EditBone *ebone;
@@ -1932,7 +1952,7 @@ static int do_armature_box_select(ViewContext *vc, rcti *rect, bool select, bool
unsigned int buffer[MAXPICKBUF];
int hits;
- hits = view3d_opengl_select(vc, buffer, MAXPICKBUF, rect, VIEW3D_SELECT_ALL);
+ hits = view3d_opengl_select(eval_ctx, vc, buffer, MAXPICKBUF, rect, VIEW3D_SELECT_ALL);
/* clear flag we use to detect point was affected */
for (ebone = arm->edbo->first; ebone; ebone = ebone->next)
@@ -2019,6 +2039,7 @@ static int opengl_select_buffer_cmp(const void *sel_a_p, const void *sel_b_p)
static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, bool select, bool extend)
{
+ EvaluationContext eval_ctx;
Bone *bone;
Object *ob = vc->obact;
unsigned int *vbuffer = NULL; /* selection buffer */
@@ -2028,6 +2049,8 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, b
int totobj = MAXPICKBUF; /* XXX solve later */
int hits;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
if ((ob) && (ob->mode & OB_MODE_POSE))
bone_only = 1;
else
@@ -2050,7 +2073,7 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, b
/* selection buffer now has bones potentially too, so we add MAXPICKBUF */
vbuffer = MEM_mallocN(4 * (totobj + MAXPICKELEMS) * sizeof(unsigned int), "selection buffer");
- hits = view3d_opengl_select(vc, vbuffer, 4 * (totobj + MAXPICKELEMS), rect, VIEW3D_SELECT_ALL);
+ hits = view3d_opengl_select(&eval_ctx, vc, vbuffer, 4 * (totobj + MAXPICKELEMS), rect, VIEW3D_SELECT_ALL);
/*
* LOGIC NOTES (theeth):
* The buffer and ListBase have the same relative order, which makes the selection
@@ -2124,6 +2147,7 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, b
static int view3d_borderselect_exec(bContext *C, wmOperator *op)
{
+ EvaluationContext eval_ctx;
ViewContext vc;
rcti rect;
bool extend;
@@ -2134,6 +2158,7 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
view3d_operator_needs_opengl(C);
/* setup view context for argument to callbacks */
+ CTX_data_eval_ctx(C, &eval_ctx);
view3d_set_viewcontext(C, &vc);
select = (RNA_int_get(op->ptr, "gesture_mode") == GESTURE_MODAL_SELECT);
@@ -2144,7 +2169,7 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
switch (vc.obedit->type) {
case OB_MESH:
vc.em = BKE_editmesh_from_object(vc.obedit);
- ret = do_mesh_box_select(&vc, &rect, select, extend);
+ ret = do_mesh_box_select(&eval_ctx, &vc, &rect, select, extend);
// if (EM_texFaceCheck())
if (ret & OPERATOR_FINISHED) {
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data);
@@ -2158,13 +2183,13 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
}
break;
case OB_MBALL:
- ret = do_meta_box_select(&vc, &rect, select, extend);
+ ret = do_meta_box_select(&eval_ctx, &vc, &rect, select, extend);
if (ret & OPERATOR_FINISHED) {
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data);
}
break;
case OB_ARMATURE:
- ret = do_armature_box_select(&vc, &rect, select, extend);
+ ret = do_armature_box_select(&eval_ctx, &vc, &rect, select, extend);
if (ret & OPERATOR_FINISHED) {
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, vc.obedit);
}
@@ -2185,10 +2210,10 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
ret = ED_sculpt_mask_box_select(C, &vc, &rect, select, extend);
}
else if (vc.obact && BKE_paint_select_face_test(vc.obact)) {
- ret = do_paintface_box_select(&vc, &rect, select, extend);
+ ret = do_paintface_box_select(&eval_ctx, &vc, &rect, select, extend);
}
else if (vc.obact && BKE_paint_select_vert_test(vc.obact)) {
- ret = do_paintvert_box_select(&vc, &rect, select, extend);
+ ret = do_paintvert_box_select(&eval_ctx, &vc, &rect, select, extend);
}
else if (vc.obact && vc.obact->mode & OB_MODE_PARTICLE_EDIT) {
ret = PE_border_select(C, &rect, select, extend);
@@ -2432,13 +2457,13 @@ static void mesh_circle_doSelectFace(void *userData, BMFace *efa, const float sc
}
}
-static void mesh_circle_select(ViewContext *vc, const bool select, const int mval[2], float rad)
+static void mesh_circle_select(const struct EvaluationContext *eval_ctx, ViewContext *vc, const bool select, const int mval[2], float rad)
{
ToolSettings *ts = vc->scene->toolsettings;
int bbsel;
CircleSelectUserData data;
- bbsel = EDBM_backbuf_circle_init(vc, mval[0], mval[1], (short)(rad + 1.0f));
+ bbsel = EDBM_backbuf_circle_init(eval_ctx, vc, mval[0], mval[1], (short)(rad + 1.0f));
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */
vc->em = BKE_editmesh_from_object(vc->obedit);
@@ -2450,7 +2475,7 @@ static void mesh_circle_select(ViewContext *vc, const bool select, const int mva
edbm_backbuf_check_and_select_verts(vc->em, select);
}
else {
- mesh_foreachScreenVert(vc, mesh_circle_doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
+ mesh_foreachScreenVert(eval_ctx, vc, mesh_circle_doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
}
@@ -2459,7 +2484,7 @@ static void mesh_circle_select(ViewContext *vc, const bool select, const int mva
edbm_backbuf_check_and_select_edges(vc->em, select);
}
else {
- mesh_foreachScreenEdge(vc, mesh_circle_doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR);
+ mesh_foreachScreenEdge(eval_ctx, vc, mesh_circle_doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR);
}
}
@@ -2468,7 +2493,7 @@ static void mesh_circle_select(ViewContext *vc, const bool select, const int mva
edbm_backbuf_check_and_select_faces(vc->em, select);
}
else {
- mesh_foreachScreenFace(vc, mesh_circle_doSelectFace, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
+ mesh_foreachScreenFace(eval_ctx, vc, mesh_circle_doSelectFace, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
}
@@ -2476,7 +2501,7 @@ static void mesh_circle_select(ViewContext *vc, const bool select, const int mva
EDBM_selectmode_flush(vc->em);
}
-static void paint_facesel_circle_select(ViewContext *vc, const bool select, const int mval[2], float rad)
+static void paint_facesel_circle_select(const struct EvaluationContext *eval_ctx, ViewContext *vc, const bool select, const int mval[2], float rad)
{
Object *ob = vc->obact;
Mesh *me = ob->data;
@@ -2484,7 +2509,7 @@ static void paint_facesel_circle_select(ViewContext *vc, const bool select, cons
bm_vertoffs = me->totpoly + 1; /* max index array */
- bbsel = EDBM_backbuf_circle_init(vc, mval[0], mval[1], (short)(rad + 1.0f));
+ bbsel = EDBM_backbuf_circle_init(eval_ctx, vc, mval[0], mval[1], (short)(rad + 1.0f));
if (bbsel) {
edbm_backbuf_check_and_select_tfaces(me, select);
EDBM_backbuf_free();
@@ -2500,7 +2525,7 @@ static void paint_vertsel_circle_select_doSelectVert(void *userData, MVert *mv,
BKE_BIT_TEST_SET(mv->flag, data->select, SELECT);
}
}
-static void paint_vertsel_circle_select(ViewContext *vc, const bool select, const int mval[2], float rad)
+static void paint_vertsel_circle_select(const struct EvaluationContext *eval_ctx, ViewContext *vc, const bool select, const int mval[2], float rad)
{
const bool use_zbuf = (vc->v3d->flag & V3D_ZBUF_SELECT) != 0;
Object *ob = vc->obact;
@@ -2511,7 +2536,7 @@ static void paint_vertsel_circle_select(ViewContext *vc, const bool select, cons
if (use_zbuf) {
bm_vertoffs = me->totvert + 1; /* max index array */
- bbsel = EDBM_backbuf_circle_init(vc, mval[0], mval[1], (short)(rad + 1.0f));
+ bbsel = EDBM_backbuf_circle_init(eval_ctx, vc, mval[0], mval[1], (short)(rad + 1.0f));
if (bbsel) {
edbm_backbuf_check_and_select_verts_obmode(me, select);
EDBM_backbuf_free();
@@ -2523,7 +2548,7 @@ static void paint_vertsel_circle_select(ViewContext *vc, const bool select, cons
ED_view3d_init_mats_rv3d(vc->obact, vc->rv3d); /* for foreach's screen/vert projection */
view3d_userdata_circleselect_init(&data, vc, select, mval, rad);
- meshobject_foreachScreenVert(vc, paint_vertsel_circle_select_doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
+ meshobject_foreachScreenVert(eval_ctx, vc, paint_vertsel_circle_select_doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
if (select != LEFTMOUSE) {
@@ -2777,11 +2802,12 @@ static void mball_circle_select(ViewContext *vc, const bool select, const int mv
/** Callbacks for circle selection in Editmode */
-static void obedit_circle_select(ViewContext *vc, const bool select, const int mval[2], float rad)
+static void obedit_circle_select(
+ const struct EvaluationContext *eval_ctx, ViewContext *vc, const bool select, const int mval[2], float rad)
{
switch (vc->obedit->type) {
case OB_MESH:
- mesh_circle_select(vc, select, mval, rad);
+ mesh_circle_select(eval_ctx, vc, select, mval, rad);
break;
case OB_CURVE:
case OB_SURF:
@@ -2811,7 +2837,7 @@ static bool object_circle_select(ViewContext *vc, const bool select, const int m
Base *base;
- for (base = FIRSTBASE_NEW; base; base = base->next) {
+ for (base = FIRSTBASE_NEW(sl); base; base = base->next) {
if (BASE_SELECTABLE_NEW(base) && ((base->flag & BASE_SELECTED) != select_flag)) {
float screen_co[2];
if (ED_view3d_project_float_global(vc->ar, base->object->obmat[3], screen_co,
@@ -2842,22 +2868,24 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op)
if (CTX_data_edit_object(C) || BKE_paint_select_elem_test(obact) ||
(obact && (obact->mode & (OB_MODE_PARTICLE_EDIT | OB_MODE_POSE))) )
{
+ EvaluationContext eval_ctx;
ViewContext vc;
view3d_operator_needs_opengl(C);
+ CTX_data_eval_ctx(C, &eval_ctx);
view3d_set_viewcontext(C, &vc);
if (CTX_data_edit_object(C)) {
- obedit_circle_select(&vc, select, mval, (float)radius);
+ obedit_circle_select(&eval_ctx, &vc, select, mval, (float)radius);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data);
}
else if (BKE_paint_select_face_test(obact)) {
- paint_facesel_circle_select(&vc, select, mval, (float)radius);
+ paint_facesel_circle_select(&eval_ctx, &vc, select, mval, (float)radius);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data);
}
else if (BKE_paint_select_vert_test(obact)) {
- paint_vertsel_circle_select(&vc, select, mval, (float)radius);
+ paint_vertsel_circle_select(&eval_ctx, &vc, select, mval, (float)radius);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data);
}
else if (obact->mode & OB_MODE_POSE)
diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c
index 8e566b8da1a..1df29201bf6 100644
--- a/source/blender/editors/space_view3d/view3d_snap.c
+++ b/source/blender/editors/space_view3d/view3d_snap.c
@@ -74,9 +74,12 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
RegionView3D *rv3d = CTX_wm_region_data(C);
TransVertStore tvs = {NULL};
TransVert *tv;
+ EvaluationContext eval_ctx;
float gridf, imat[3][3], bmat[3][3], vec[3];
int a;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
gridf = rv3d->gridview;
if (obedit) {
@@ -163,7 +166,7 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
if (ob->parent) {
float originmat[3][3];
- BKE_object_where_is_calc_ex(scene, NULL, ob, originmat);
+ BKE_object_where_is_calc_ex(&eval_ctx, scene, NULL, ob, originmat);
invert_m3_m3(imat, originmat);
mul_m3_v3(imat, vec);
@@ -214,11 +217,14 @@ static int snap_selected_to_location(bContext *C, const float snap_target_global
View3D *v3d = CTX_wm_view3d(C);
TransVertStore tvs = {NULL};
TransVert *tv;
+ EvaluationContext eval_ctx;
float imat[3][3], bmat[3][3];
float center_global[3];
float offset_global[3];
int a;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
if (use_offset) {
if ((v3d && v3d->around == V3D_AROUND_ACTIVE) &&
snap_calc_active_center(C, true, center_global))
@@ -371,7 +377,7 @@ static int snap_selected_to_location(bContext *C, const float snap_target_global
if (ob->parent) {
float originmat[3][3];
- BKE_object_where_is_calc_ex(scene, NULL, ob, originmat);
+ BKE_object_where_is_calc_ex(&eval_ctx, scene, NULL, ob, originmat);
invert_m3_m3(imat, originmat);
mul_m3_v3(imat, cursor_parent);
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 854f71b17b3..991c61a77cc 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -54,6 +54,9 @@
#include "BIF_glutil.h"
+#include "UI_resources.h"
+
+#include "GPU_glew.h"
#include "GPU_select.h"
#include "GPU_matrix.h"
@@ -442,6 +445,9 @@ void ED_view3d_smooth_view_force_finish(
View3D *v3d, ARegion *ar)
{
RegionView3D *rv3d = ar->regiondata;
+ EvaluationContext eval_ctx;
+
+ CTX_data_eval_ctx(C, &eval_ctx);
if (rv3d && rv3d->sms) {
rv3d->sms->time_allowed = 0.0; /* force finishing */
@@ -450,7 +456,7 @@ void ED_view3d_smooth_view_force_finish(
/* force update of view matrix so tools that run immediately after
* can use them without redrawing first */
Scene *scene = CTX_data_scene(C);
- ED_view3d_update_viewmat(scene, v3d, ar, NULL, NULL, NULL);
+ ED_view3d_update_viewmat(&eval_ctx, scene, v3d, ar, NULL, NULL, NULL);
}
}
@@ -809,19 +815,100 @@ bool ED_view3d_boundbox_clip(RegionView3D *rv3d, const BoundBox *bb)
return view3d_boundbox_clip_m4(bb, rv3d->persmatob);
}
-float ED_view3d_depth_read_cached(const ViewContext *vc, int x, int y)
+/* -------------------------------------------------------------------- */
+
+/** \name Depth Utilities
+ * \{ */
+
+float ED_view3d_depth_read_cached(const ViewContext *vc, const int mval[2])
{
ViewDepths *vd = vc->rv3d->depths;
- x -= vc->ar->winrct.xmin;
- y -= vc->ar->winrct.ymin;
+ int x = mval[0];
+ int y = mval[1];
- if (vd && vd->depths && x > 0 && y > 0 && x < vd->w && y < vd->h)
+ if (vd && vd->depths && x > 0 && y > 0 && x < vd->w && y < vd->h) {
return vd->depths[y * vd->w + x];
- else
- return 1;
+ }
+ else {
+ BLI_assert(1.0 <= vd->depth_range[1]);
+ return 1.0f;
+ }
}
+bool ED_view3d_depth_read_cached_normal(
+ const ViewContext *vc, const int mval[2],
+ float r_normal[3])
+{
+ /* Note: we could support passing in a radius.
+ * For now just read 9 pixels. */
+
+ /* pixels surrounding */
+ bool depths_valid[9] = {false};
+ float coords[9][3] = {{0}};
+
+ ARegion *ar = vc->ar;
+ const ViewDepths *depths = vc->rv3d->depths;
+
+ for (int x = 0, i = 0; x < 2; x++) {
+ for (int y = 0; y < 2; y++) {
+ const int mval_ofs[2] = {mval[0] + (x - 1), mval[1] + (y - 1)};
+
+ const double depth = (double)ED_view3d_depth_read_cached(vc, mval_ofs);
+ if ((depth > depths->depth_range[0]) && (depth < depths->depth_range[1])) {
+ if (ED_view3d_depth_unproject(ar, mval_ofs, depth, coords[i])) {
+ depths_valid[i] = true;
+ }
+ }
+ i++;
+ }
+ }
+
+ const int edges[2][6][2] = {
+ /* x edges */
+ {{0, 1}, {1, 2},
+ {3, 4}, {4, 5},
+ {6, 7}, {7, 8}},
+ /* y edges */
+ {{0, 3}, {3, 6},
+ {1, 4}, {4, 7},
+ {2, 5}, {5, 8}},
+ };
+
+ float cross[2][3] = {{0.0f}};
+
+ for (int i = 0; i < 6; i++) {
+ for (int axis = 0; axis < 2; axis++) {
+ if (depths_valid[edges[axis][i][0]] && depths_valid[edges[axis][i][1]]) {
+ float delta[3];
+ sub_v3_v3v3(delta, coords[edges[axis][i][0]], coords[edges[axis][i][1]]);
+ add_v3_v3(cross[axis], delta);
+ }
+ }
+ }
+
+ cross_v3_v3v3(r_normal, cross[0], cross[1]);
+
+ if (normalize_v3(r_normal) != 0.0f) {
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
+bool ED_view3d_depth_unproject(
+ const ARegion *ar,
+ const int mval[2], const double depth,
+ float r_location_world[3])
+{
+ float centx = (float)mval[0] + 0.5f;
+ float centy = (float)mval[1] + 0.5f;
+ return ED_view3d_unproject(ar, centx, centy, depth, r_location_world);
+}
+
+/** \} */
+
void ED_view3d_depth_tag_update(RegionView3D *rv3d)
{
if (rv3d->depths)
@@ -1022,11 +1109,11 @@ bool ED_view3d_lock(RegionView3D *rv3d)
}
/* don't set windows active in here, is used by renderwin too */
-void view3d_viewmatrix_set(Scene *scene, const View3D *v3d, RegionView3D *rv3d)
+void view3d_viewmatrix_set(const EvaluationContext *eval_ctx, Scene *scene, const View3D *v3d, RegionView3D *rv3d)
{
if (rv3d->persp == RV3D_CAMOB) { /* obs/camera */
if (v3d->camera) {
- BKE_object_where_is_calc(scene, v3d->camera);
+ BKE_object_where_is_calc(eval_ctx, scene, v3d->camera);
obmat_to_viewmat(rv3d, v3d->camera);
}
else {
@@ -1111,9 +1198,10 @@ void view3d_opengl_select_cache_end(void)
* \note (vc->obedit == NULL) can be set to explicitly skip edit-object selection.
*/
int view3d_opengl_select(
- ViewContext *vc, unsigned int *buffer, unsigned int bufsize, const rcti *input,
+ const EvaluationContext *eval_ctx, ViewContext *vc, unsigned int *buffer, unsigned int bufsize, const rcti *input,
eV3DSelectMode select_mode)
{
+ struct bThemeState theme_state;
Depsgraph *graph = vc->depsgraph;
Scene *scene = vc->scene;
View3D *v3d = vc->v3d;
@@ -1159,6 +1247,10 @@ int view3d_opengl_select(
}
}
+ /* Tools may request depth outside of regular drawing code. */
+ UI_Theme_Store(&theme_state);
+ UI_SetTheme(SPACE_VIEW3D, RGN_TYPE_WINDOW);
+
/* Re-use cache (rect must be smaller then the cached)
* other context is assumed to be unchanged */
if (GPU_select_is_cached()) {
@@ -1172,7 +1264,7 @@ int view3d_opengl_select(
/* Important we use the 'viewmat' and don't re-calculate since
* the object & bone view locking takes 'rect' into account, see: T51629. */
- ED_view3d_draw_setup_view(vc->win, scene, ar, v3d, vc->rv3d->viewmat, NULL, &rect);
+ ED_view3d_draw_setup_view(vc->win, eval_ctx, scene, ar, v3d, vc->rv3d->viewmat, NULL, &rect);
if (v3d->drawtype > OB_WIRE) {
v3d->zbuf = true;
@@ -1216,7 +1308,7 @@ int view3d_opengl_select(
}
G.f &= ~G_PICKSEL;
- ED_view3d_draw_setup_view(vc->win, scene, ar, v3d, vc->rv3d->viewmat, NULL, NULL);
+ ED_view3d_draw_setup_view(vc->win, eval_ctx, scene, ar, v3d, vc->rv3d->viewmat, NULL, NULL);
if (v3d->drawtype > OB_WIRE) {
v3d->zbuf = 0;
@@ -1229,6 +1321,8 @@ int view3d_opengl_select(
finally:
if (hits < 0) printf("Too many objects in select buffer\n"); /* XXX make error message */
+ UI_Theme_Restore(&theme_state);
+
return hits;
}
diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c
index 71a4980d4a6..44b7fadd29f 100644
--- a/source/blender/editors/space_view3d/view3d_walk.c
+++ b/source/blender/editors/space_view3d/view3d_walk.c
@@ -49,7 +49,6 @@
#include "ED_screen.h"
#include "ED_space_api.h"
-#include "ED_transform.h"
#include "ED_transform_snap_object_context.h"
#include "PIL_time.h" /* smoothview */
@@ -605,7 +604,7 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op)
walk->ar, walk->v3d);
walk->v3d_camera_control = ED_view3d_cameracontrol_acquire(
- walk->scene, walk->v3d, walk->rv3d,
+ C, walk->scene, walk->v3d, walk->rv3d,
(U.uiflag & USER_CAM_LOCK_NO_PARENT) == 0);
/* center the mouse */
@@ -687,16 +686,6 @@ static int walkEnd(bContext *C, WalkInfo *walk)
return OPERATOR_CANCELLED;
}
-static bool wm_event_is_last_mousemove(const wmEvent *event)
-{
- while ((event = event->next)) {
- if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
- return false;
- }
- }
- return true;
-}
-
static void walkEvent(bContext *C, wmOperator *op, WalkInfo *walk, const wmEvent *event)
{
if (event->type == TIMER && event->customdata == walk->timer) {
@@ -749,7 +738,7 @@ static void walkEvent(bContext *C, wmOperator *op, WalkInfo *walk, const wmEvent
}
else
#endif
- if (wm_event_is_last_mousemove(event)) {
+ if (WM_event_is_last_mousemove(event)) {
wmWindow *win = CTX_wm_window(C);
#ifdef __APPLE__
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 81d8f64045f..4745631e85c 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -52,7 +52,7 @@
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_ghash.h"
-#include "BLI_stackdefines.h"
+#include "BLI_utildefines_stack.h"
#include "BLI_memarena.h"
#include "BKE_nla.h"
@@ -66,6 +66,8 @@
#include "BKE_report.h"
#include "BKE_workspace.h"
+#include "DEG_depsgraph.h"
+
#include "BIF_glutil.h"
#include "GPU_immediate.h"
@@ -1731,7 +1733,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
glLineWidth(1.0f);
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
@@ -1904,7 +1906,7 @@ static void drawTransformPixel(const struct bContext *UNUSED(C), ARegion *ar, vo
TransInfo *t = arg;
Scene *scene = t->scene;
SceneLayer *sl = t->scene_layer;
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
/* draw autokeyframing hint in the corner
* - only draw if enabled (advanced users may be distracted/annoyed),
@@ -2015,8 +2017,10 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
View3D *v3d = t->view;
v3d->twmode = t->current_orientation;
- BLI_assert(BKE_workspace_transform_orientation_get_index(CTX_wm_workspace(C), t->custom_orientation)
- == v3d->custom_orientation_index);
+
+ BLI_assert(((v3d->custom_orientation_index == -1) && (t->custom_orientation == NULL)) ||
+ (BKE_workspace_transform_orientation_get_index(
+ CTX_wm_workspace(C), t->custom_orientation) == v3d->custom_orientation_index));
}
}
}
@@ -2621,6 +2625,9 @@ static void constraintTransLim(TransInfo *t, TransData *td)
if (td->con) {
const bConstraintTypeInfo *ctiLoc = BKE_constraint_typeinfo_from_type(CONSTRAINT_TYPE_LOCLIMIT);
const bConstraintTypeInfo *ctiDist = BKE_constraint_typeinfo_from_type(CONSTRAINT_TYPE_DISTLIMIT);
+ EvaluationContext eval_ctx;
+
+ CTX_data_eval_ctx(t->context, &eval_ctx);
bConstraintOb cob = {NULL};
bConstraint *con;
@@ -2670,7 +2677,7 @@ static void constraintTransLim(TransInfo *t, TransData *td)
}
/* get constraint targets if needed */
- BKE_constraint_targets_for_solving_get(con, &cob, &targets, ctime);
+ BKE_constraint_targets_for_solving_get(&eval_ctx, con, &cob, &targets, ctime);
/* do constraint */
cti->evaluate_constraint(con, &cob, &targets);
@@ -2916,7 +2923,9 @@ static void initBend(TransInfo *t)
t->flag |= T_NO_CONSTRAINT;
//copy_v3_v3(t->center, ED_view3d_cursor3d_get(t->scene, t->view));
- calculateCenterCursor(t, t->center);
+ if ((t->flag & T_OVERRIDE_CENTER) == 0) {
+ calculateCenterCursor(t, t->center);
+ }
calculateCenterGlobal(t, t->center, t->center_global);
t->val = 0.0f;
@@ -4097,13 +4106,15 @@ static void initTrackball(TransInfo *t)
static void applyTrackballValue(TransInfo *t, const float axis1[3], const float axis2[3], float angles[2])
{
TransData *td = t->data;
- float mat[3][3], smat[3][3], totmat[3][3];
+ float mat[3][3];
+ float axis[3];
+ float angle;
int i;
- axis_angle_normalized_to_mat3(smat, axis1, angles[0]);
- axis_angle_normalized_to_mat3(totmat, axis2, angles[1]);
-
- mul_m3_m3m3(mat, smat, totmat);
+ mul_v3_v3fl(axis, axis1, angles[0]);
+ madd_v3_v3fl(axis, axis2, angles[1]);
+ angle = normalize_v3(axis);
+ axis_angle_normalized_to_mat3(mat, axis, angle);
for (i = 0; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
@@ -4113,10 +4124,7 @@ static void applyTrackballValue(TransInfo *t, const float axis1[3], const float
continue;
if (t->flag & T_PROP_EDIT) {
- axis_angle_normalized_to_mat3(smat, axis1, td->factor * angles[0]);
- axis_angle_normalized_to_mat3(totmat, axis2, td->factor * angles[1]);
-
- mul_m3_m3m3(mat, smat, totmat);
+ axis_angle_normalized_to_mat3(mat, axis, td->factor * angle);
}
ElementRotation(t, td, mat, t->around);
@@ -7556,7 +7564,7 @@ static void drawVertSlide(TransInfo *t)
glLineWidth(1.0f);
- immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
@@ -8393,8 +8401,15 @@ static void initTimeSlide(TransInfo *t)
TransData *td = t->data;
for (i = 0; i < t->total; i++, td++) {
- if (min > *(td->val)) min = *(td->val);
- if (max < *(td->val)) max = *(td->val);
+ AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL;
+ float val = *(td->val);
+
+ /* strip/action time to global (mapped) time */
+ if (adt)
+ val = BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_MAP);
+
+ if (min > val) min = val;
+ if (max < val) max = val;
}
if (min == max) {
@@ -8469,25 +8484,38 @@ static void applyTimeSlideValue(TransInfo *t, float sval)
*/
AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL;
float cval = t->values[0];
-
- /* apply NLA-mapping to necessary values */
- if (adt)
- cval = BKE_nla_tweakedit_remap(adt, cval, NLATIME_CONVERT_UNMAP);
-
+
/* only apply to data if in range */
if ((sval > minx) && (sval < maxx)) {
float cvalc = CLAMPIS(cval, minx, maxx);
+ float ival = td->ival;
float timefac;
-
+
+ /* NLA mapping magic here works as follows:
+ * - "ival" goes from strip time to global time
+ * - calculation is performed into td->val in global time
+ * (since sval and min/max are all in global time)
+ * - "td->val" then gets put back into strip time
+ */
+ if (adt) {
+ /* strip to global */
+ ival = BKE_nla_tweakedit_remap(adt, ival, NLATIME_CONVERT_MAP);
+ }
+
/* left half? */
- if (td->ival < sval) {
- timefac = (sval - td->ival) / (sval - minx);
+ if (ival < sval) {
+ timefac = (sval - ival) / (sval - minx);
*(td->val) = cvalc - timefac * (cvalc - minx);
}
else {
- timefac = (td->ival - sval) / (maxx - sval);
+ timefac = (ival - sval) / (maxx - sval);
*(td->val) = cvalc + timefac * (maxx - cvalc);
}
+
+ if (adt) {
+ /* global to strip */
+ *(td->val) = BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_UNMAP);
+ }
}
}
}
@@ -8546,9 +8574,11 @@ static void initTimeScale(TransInfo *t)
/* recalculate center2d to use CFRA and mouse Y, since that's
* what is used in time scale */
- t->center[0] = t->scene->r.cfra;
- projectFloatView(t, t->center, center);
- center[1] = t->mouse.imval[1];
+ if ((t->flag & T_OVERRIDE_CENTER) == 0) {
+ t->center[0] = t->scene->r.cfra;
+ projectFloatView(t, t->center, center);
+ center[1] = t->mouse.imval[1];
+ }
/* force a reinit with the center2d used here */
initMouseInput(t, &t->mouse, center, t->mouse.imval, false);
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index d415b3eabeb..92eb31aabe6 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -535,6 +535,9 @@ typedef struct TransInfo {
/* alternative transformation. used to add offset to tracking markers */
#define T_ALT_TRANSFORM (1 << 24)
+ /** #TransInfo.center has been set, don't change it. */
+#define T_OVERRIDE_CENTER (1 << 25)
+
/* TransInfo->modifiers */
#define MOD_CONSTRAINT_SELECT 0x01
#define MOD_PRECISION 0x02
@@ -638,7 +641,7 @@ void restoreBones(TransInfo *t);
/*********************** transform_manipulator.c ********** */
-#define MANIPULATOR_AXIS_LINE_WIDTH 2.0
+#define MANIPULATOR_AXIS_LINE_WIDTH 2.0f
bool gimbal_axis(struct Object *ob, float gmat[3][3]); /* return 0 when no gimbal for selection */
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 654072766a8..4e409e7f77f 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -735,7 +735,7 @@ void drawConstraint(TransInfo *t)
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
@@ -851,6 +851,13 @@ static void drawObjectConstraint(TransInfo *t)
}
}
+ if (t->options & CTX_GPENCIL_STROKES) {
+ /* only draw a constraint line for one point, otherwise we can't see anything */
+ if ((options & DRAWLIGHT) == 0) {
+ break;
+ }
+ }
+
if (t->flag & T_OBJECT) {
copy_v3_v3(co, td->ob->obmat[3]);
axismtx = td->axismtx;
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 243788c20b3..166a5805fa1 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -292,7 +292,7 @@ static void createTransTexspace(TransInfo *t)
ID *id;
short *texflag;
- ob = OBACT_NEW;
+ ob = OBACT_NEW(sl);
if (ob == NULL) { // Shouldn't logically happen, but still...
t->total = 0;
@@ -772,29 +772,37 @@ int count_set_pose_transflags(int *out_mode, short around, Object *ob)
/* -------- Auto-IK ---------- */
/* adjust pose-channel's auto-ik chainlen */
-static void pchan_autoik_adjust(bPoseChannel *pchan, short chainlen)
+static bool pchan_autoik_adjust(bPoseChannel *pchan, short chainlen)
{
bConstraint *con;
+ bool changed = false;
/* don't bother to search if no valid constraints */
- if ((pchan->constflag & (PCHAN_HAS_IK | PCHAN_HAS_TARGET)) == 0)
- return;
+ if ((pchan->constflag & (PCHAN_HAS_IK | PCHAN_HAS_TARGET)) == 0) {
+ return changed;
+ }
/* check if pchan has ik-constraint */
for (con = pchan->constraints.first; con; con = con->next) {
if (con->type == CONSTRAINT_TYPE_KINEMATIC && (con->enforce != 0.0f)) {
bKinematicConstraint *data = con->data;
-
+
/* only accept if a temporary one (for auto-ik) */
if (data->flag & CONSTRAINT_IK_TEMP) {
/* chainlen is new chainlen, but is limited by maximum chainlen */
- if ((chainlen == 0) || (chainlen > data->max_rootbone))
+ const int old_rootbone = data->rootbone;
+ if ((chainlen == 0) || (chainlen > data->max_rootbone)) {
data->rootbone = data->max_rootbone;
- else
+ }
+ else {
data->rootbone = chainlen;
+ }
+ changed |= (data->rootbone != old_rootbone);
}
}
}
+
+ return changed;
}
/* change the chain-length of auto-ik */
@@ -810,7 +818,13 @@ void transform_autoik_update(TransInfo *t, short mode)
}
else if (mode == -1) {
/* mode==-1 is from WHEELMOUSEUP... decreases len */
- if (*chainlen > 0) (*chainlen)--;
+ if (*chainlen > 0) {
+ (*chainlen)--;
+ }
+ else {
+ /* IK length did not change, skip updates. */
+ return;
+ }
}
/* sanity checks (don't assume t->poseobj is set, or that it is an armature) */
@@ -818,8 +832,14 @@ void transform_autoik_update(TransInfo *t, short mode)
return;
/* apply to all pose-channels */
+ bool changed = false;
for (pchan = t->poseobj->pose->chanbase.first; pchan; pchan = pchan->next) {
- pchan_autoik_adjust(pchan, *chainlen);
+ changed |= pchan_autoik_adjust(pchan, *chainlen);
+ }
+
+ if (changed) {
+ /* TODO(sergey): Consider doing partial update only. */
+ DEG_relations_tag_update(G.main);
}
}
@@ -829,6 +849,7 @@ static void pose_grab_with_ik_clear(Object *ob)
bKinematicConstraint *data;
bPoseChannel *pchan;
bConstraint *con, *next;
+ bool relations_changed = false;
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
/* clear all temporary lock flags */
@@ -842,6 +863,8 @@ static void pose_grab_with_ik_clear(Object *ob)
if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
data = con->data;
if (data->flag & CONSTRAINT_IK_TEMP) {
+ relations_changed = true;
+
/* iTaSC needs clear for removed constraints */
BIK_clear_data(ob->pose);
@@ -857,8 +880,10 @@ static void pose_grab_with_ik_clear(Object *ob)
}
}
- /* TODO(sergey): Consider doing partial update only. */
- DEG_relations_tag_update(G.main);
+ if (relations_changed) {
+ /* TODO(sergey): Consider doing partial update only. */
+ DEG_relations_tag_update(G.main);
+ }
}
/* adds the IK to pchan - returns if added */
@@ -1485,6 +1510,48 @@ static TransDataCurveHandleFlags *initTransDataCurveHandles(TransData *td, struc
return hdata;
}
+/**
+ * For the purpose of transform code we need to behave as if handles are selected,
+ * even when they aren't (see special case below).
+ */
+static int bezt_select_to_transform_triple_flag(
+ const BezTriple *bezt, const bool hide_handles)
+{
+ int flag = 0;
+
+ if (hide_handles) {
+ if (bezt->f2 & SELECT) {
+ flag = (1 << 0) | (1 << 1) | (1 << 2);
+ }
+ }
+ else {
+ flag = (
+ ((bezt->f1 & SELECT) ? (1 << 0) : 0) |
+ ((bezt->f2 & SELECT) ? (1 << 1) : 0) |
+ ((bezt->f3 & SELECT) ? (1 << 2) : 0)
+ );
+ }
+
+ /* Special case for auto & aligned handles:
+ * When a center point is being moved without the handles,
+ * leaving the handles stationary makes no sense and only causes strange behavior,
+ * where one handle is arbitrarily anchored, the other one is aligned and lengthened
+ * based on where the center point is moved. Also a bug when cancelling, see: T52007.
+ *
+ * A more 'correct' solution could be to store handle locations in 'TransDataCurveHandleFlags'.
+ * However that doesn't resolve odd behavior, so best transform the handles in this case.
+ */
+ if ((flag != ((1 << 0) | (1 << 1) | (1 << 2))) && (flag & (1 << 1))) {
+ if (ELEM(bezt->h1, HD_AUTO, HD_ALIGN) &&
+ ELEM(bezt->h2, HD_AUTO, HD_ALIGN))
+ {
+ flag = (1 << 0) | (1 << 1) | (1 << 2);
+ }
+ }
+
+ return flag;
+}
+
static void createTransCurveVerts(TransInfo *t)
{
Curve *cu = t->obedit->data;
@@ -1502,22 +1569,22 @@ static void createTransCurveVerts(TransInfo *t)
/* to be sure */
if (cu->editnurb == NULL) return;
+#define SEL_F1 (1 << 0)
+#define SEL_F2 (1 << 1)
+#define SEL_F3 (1 << 2)
+
/* count total of vertices, check identical as in 2nd loop for making transdata! */
nurbs = BKE_curve_editNurbs_get(cu);
for (nu = nurbs->first; nu; nu = nu->next) {
if (nu->type == CU_BEZIER) {
for (a = 0, bezt = nu->bezt; a < nu->pntsu; a++, bezt++) {
if (bezt->hide == 0) {
- if (hide_handles) {
- if (bezt->f2 & SELECT) countsel += 3;
- if (is_prop_edit) count += 3;
- }
- else {
- if (bezt->f1 & SELECT) countsel++;
- if (bezt->f2 & SELECT) countsel++;
- if (bezt->f3 & SELECT) countsel++;
- if (is_prop_edit) count += 3;
- }
+ const int bezt_tx = bezt_select_to_transform_triple_flag(bezt, hide_handles);
+ if (bezt_tx & SEL_F1) { countsel++; }
+ if (bezt_tx & SEL_F2) { countsel++; }
+ if (bezt_tx & SEL_F3) { countsel++; }
+ if (is_prop_edit) count += 3;
+
}
}
}
@@ -1568,10 +1635,10 @@ static void createTransCurveVerts(TransInfo *t)
}
}
- if (is_prop_edit ||
- ((bezt->f2 & SELECT) && hide_handles) ||
- ((bezt->f1 & SELECT) && hide_handles == 0))
- {
+ /* Elements that will be transform (not always a match to selection). */
+ const int bezt_tx = bezt_select_to_transform_triple_flag(bezt, hide_handles);
+
+ if (is_prop_edit || bezt_tx & SEL_F1) {
copy_v3_v3(td->iloc, bezt->vec[0]);
td->loc = bezt->vec[0];
copy_v3_v3(td->center, bezt->vec[(hide_handles ||
@@ -1602,7 +1669,7 @@ static void createTransCurveVerts(TransInfo *t)
}
/* This is the Curve Point, the other two are handles */
- if (is_prop_edit || (bezt->f2 & SELECT)) {
+ if (is_prop_edit || bezt_tx & SEL_F2) {
copy_v3_v3(td->iloc, bezt->vec[1]);
td->loc = bezt->vec[1];
copy_v3_v3(td->center, td->loc);
@@ -1628,7 +1695,7 @@ static void createTransCurveVerts(TransInfo *t)
copy_m3_m3(td->axismtx, axismtx);
}
- if ((bezt->f1 & SELECT) == 0 && (bezt->f3 & SELECT) == 0)
+ if ((bezt_tx & SEL_F1) == 0 && (bezt_tx & SEL_F3) == 0)
/* If the middle is selected but the sides arnt, this is needed */
if (hdata == NULL) { /* if the handle was not saved by the previous handle */
hdata = initTransDataCurveHandles(td, bezt);
@@ -1638,10 +1705,7 @@ static void createTransCurveVerts(TransInfo *t)
count++;
tail++;
}
- if (is_prop_edit ||
- ((bezt->f2 & SELECT) && hide_handles) ||
- ((bezt->f3 & SELECT) && hide_handles == 0))
- {
+ if (is_prop_edit || bezt_tx & SEL_F3) {
copy_v3_v3(td->iloc, bezt->vec[2]);
td->loc = bezt->vec[2];
copy_v3_v3(td->center, bezt->vec[(hide_handles ||
@@ -1696,6 +1760,26 @@ static void createTransCurveVerts(TransInfo *t)
for (a = nu->pntsu * nu->pntsv, bp = nu->bp; a > 0; a--, bp++) {
if (bp->hide == 0) {
if (is_prop_edit || (bp->f1 & SELECT)) {
+ float axismtx[3][3];
+
+ if (t->around == V3D_AROUND_LOCAL_ORIGINS) {
+ if (nu->pntsv == 1) {
+ float normal[3], plane[3];
+
+ BKE_nurb_bpoint_calc_normal(nu, bp, normal);
+ BKE_nurb_bpoint_calc_plane(nu, bp, plane);
+
+ if (createSpaceNormalTangent(axismtx, normal, plane)) {
+ /* pass */
+ }
+ else {
+ normalize_v3(normal);
+ axis_dominant_v3_to_m3(axismtx, normal);
+ invert_m3(axismtx);
+ }
+ }
+ }
+
copy_v3_v3(td->iloc, bp->vec);
td->loc = bp->vec;
copy_v3_v3(td->center, td->loc);
@@ -1714,6 +1798,11 @@ static void createTransCurveVerts(TransInfo *t)
copy_m3_m3(td->smtx, smtx);
copy_m3_m3(td->mtx, mtx);
+ if (t->around == V3D_AROUND_LOCAL_ORIGINS) {
+ if (nu->pntsv == 1) {
+ copy_m3_m3(td->axismtx, axismtx);
+ }
+ }
td++;
count++;
@@ -1729,6 +1818,10 @@ static void createTransCurveVerts(TransInfo *t)
calc_distanceCurveVerts(head, tail - 1);
}
}
+
+#undef SEL_F1
+#undef SEL_F2
+#undef SEL_F3
}
/* ********************* lattice *************** */
@@ -1918,7 +2011,7 @@ void flushTransParticles(TransInfo *t)
{
Scene *scene = t->scene;
SceneLayer *sl = t->scene_layer;
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
PTCacheEdit *edit = PE_get_current(scene, sl, ob);
ParticleSystem *psys = edit->psys;
ParticleSystemModifierData *psmd = NULL;
@@ -1958,7 +2051,9 @@ void flushTransParticles(TransInfo *t)
point->flag |= PEP_EDIT_RECALC;
}
- PE_update_object(scene, sl, OBACT_NEW, 1);
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(t->context, &eval_ctx);
+ PE_update_object(&eval_ctx, scene, sl, OBACT_NEW(sl), 1);
}
/* ********************* mesh ****************** */
@@ -2370,6 +2465,7 @@ static void createTransEditVerts(TransInfo *t)
{
TransData *tob = NULL;
TransDataExtension *tx = NULL;
+ EvaluationContext eval_ctx;
BMEditMesh *em = BKE_editmesh_from_object(t->obedit);
Mesh *me = t->obedit->data;
BMesh *bm = em->bm;
@@ -2388,6 +2484,10 @@ static void createTransEditVerts(TransInfo *t)
int island_info_tot;
int *island_vert_map = NULL;
+ DEG_evaluation_context_init_from_scene(&eval_ctx,
+ t->scene, t->scene_layer,
+ DAG_EVAL_VIEWPORT);
+
/* Even for translation this is needed because of island-orientation, see: T51651. */
const bool is_island_center = (t->around == V3D_AROUND_LOCAL_ORIGINS);
/* Original index of our connected vertex when connected distances are calculated.
@@ -2471,7 +2571,7 @@ static void createTransEditVerts(TransInfo *t)
if (modifiers_isCorrectableDeformed(t->scene, t->obedit)) {
/* check if we can use deform matrices for modifier from the
* start up to stack, they are more accurate than quats */
- totleft = BKE_crazyspace_get_first_deform_matrices_editbmesh(t->scene, t->obedit, em, &defmats, &defcos);
+ totleft = BKE_crazyspace_get_first_deform_matrices_editbmesh(&eval_ctx, t->scene, t->obedit, em, &defmats, &defcos);
}
/* if we still have more modifiers, also do crazyspace
@@ -2484,7 +2584,7 @@ static void createTransEditVerts(TransInfo *t)
if (totleft > 0)
#endif
{
- mappedcos = BKE_crazyspace_get_mapped_editverts(t->scene, t->obedit);
+ mappedcos = BKE_crazyspace_get_mapped_editverts(&eval_ctx, t->scene, t->obedit);
quats = MEM_mallocN(em->bm->totvert * sizeof(*quats), "crazy quats");
BKE_crazyspace_set_quats_editmesh(em, defcos, mappedcos, quats, !prop_mode);
if (mappedcos)
@@ -2694,7 +2794,7 @@ void flushTransSeq(TransInfo *t)
tdsq = (TransDataSeq *)td->extra;
seq = tdsq->seq;
old_start = seq->start;
- new_frame = iroundf(td2d->loc[0]);
+ new_frame = round_fl_to_int(td2d->loc[0]);
switch (tdsq->sel_flag) {
case SELECT:
@@ -2706,7 +2806,7 @@ void flushTransSeq(TransInfo *t)
seq->start = new_frame - tdsq->start_offset;
#endif
if (seq->depth == 0) {
- seq->machine = iroundf(td2d->loc[1]);
+ seq->machine = round_fl_to_int(td2d->loc[1]);
CLAMP(seq->machine, 1, MAXSEQ);
}
break;
@@ -3652,7 +3752,7 @@ void flushTransIntFrameActionData(TransInfo *t)
/* flush data! */
for (i = 0; i < t->total; i++, tfd++) {
- *(tfd->sdata) = iroundf(tfd->val);
+ *(tfd->sdata) = round_fl_to_int(tfd->val);
}
}
@@ -4680,7 +4780,7 @@ void flushTransGraphData(TransInfo *t)
/* if int-values only, truncate to integers */
if (td->flag & TD_INTVALUES)
- td2d->loc2d[1] = floorf(td2d->loc[1] + 0.5f);
+ td2d->loc2d[1] = floorf(td2d->loc[1] * inv_unit_scale - tdg->offset + 0.5f);
else
td2d->loc2d[1] = td2d->loc[1] * inv_unit_scale - tdg->offset;
@@ -5310,6 +5410,9 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
Scene *scene = t->scene;
bool constinv;
bool skip_invert = false;
+ EvaluationContext eval_ctx;
+
+ CTX_data_eval_ctx(t->context, &eval_ctx);
if (t->mode != TFM_DUMMY && ob->rigidbody_object) {
float rot[3][3], scale[3];
@@ -5333,7 +5436,8 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
}
/* update object's loc/rot to get current rigid body transform */
mat4_to_loc_rot_size(ob->loc, rot, scale, ob->obmat);
- BKE_object_mat3_to_rot(ob, rot, false);
+ sub_v3_v3(ob->loc, ob->dloc);
+ BKE_object_mat3_to_rot(ob, rot, false); /* drot is already corrected here */
}
}
@@ -5356,11 +5460,11 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
if (skip_invert == false && constinv == false) {
ob->transflag |= OB_NO_CONSTRAINTS; /* BKE_object_where_is_calc_time checks this */
- BKE_object_where_is_calc(t->scene, ob);
+ BKE_object_where_is_calc(&eval_ctx, t->scene, ob);
ob->transflag &= ~OB_NO_CONSTRAINTS;
}
else
- BKE_object_where_is_calc(t->scene, ob);
+ BKE_object_where_is_calc(&eval_ctx, t->scene, ob);
td->ob = ob;
@@ -5451,10 +5555,14 @@ static void set_trans_object_base_flags(TransInfo *t)
DEG_scene_relations_update(G.main, t->scene);
/* handle pending update events, otherwise they got copied below */
+ EvaluationContext eval_ctx;
+ DEG_evaluation_context_init_from_scene(&eval_ctx,
+ t->scene, t->scene_layer,
+ DAG_EVAL_VIEWPORT);
for (base = sl->object_bases.first; base; base = base->next) {
if (base->object->recalc & OB_RECALC_ALL) {
/* TODO(sergey): Ideally, it's not needed. */
- BKE_object_handle_update(G.main->eval_ctx, t->scene, base->object);
+ BKE_object_handle_update(&eval_ctx, t->scene, base->object);
}
}
@@ -5467,8 +5575,8 @@ static void set_trans_object_base_flags(TransInfo *t)
/* if parent selected, deselect */
while (parsel) {
- Base *parbase = BKE_scene_layer_base_find(sl, parsel);
- if (parbase->flag & BASE_SELECTED) {
+ if (parsel->base_flag & BASE_SELECTED) {
+ Base *parbase = BKE_scene_layer_base_find(sl, parsel);
if (parbase) { /* in rare cases this can fail */
if (TESTBASELIB_BGMODE_NEW(parbase)) {
break;
@@ -5494,6 +5602,9 @@ static void set_trans_object_base_flags(TransInfo *t)
}
}
+ /* all recalc flags get flushed to all layers, so a layer flip later on works fine */
+ DEG_scene_flush_update(G.main, t->scene);
+
/* and we store them temporal in base (only used for transform code) */
/* this because after doing updates, the object->recalc is cleared */
for (base = sl->object_bases.first; base; base = base->next) {
@@ -5572,6 +5683,7 @@ static int count_proportional_objects(TransInfo *t)
/* all recalc flags get flushed to all layers, so a layer flip later on works fine */
DEG_scene_relations_update(G.main, t->scene);
+ DEG_scene_flush_update(G.main, t->scene);
/* and we store them temporal in base (only used for transform code) */
/* this because after doing updates, the object->recalc is cleared */
@@ -5652,7 +5764,7 @@ void autokeyframe_ob_cb_func(bContext *C, Scene *scene, SceneLayer *sl, View3D *
}
else if (ELEM(tmode, TFM_ROTATION, TFM_TRACKBALL)) {
if (v3d->around == V3D_AROUND_ACTIVE) {
- if (ob != OBACT_NEW)
+ if (ob != OBACT_NEW(sl))
do_loc = true;
}
else if (v3d->around == V3D_AROUND_CURSOR)
@@ -5663,7 +5775,7 @@ void autokeyframe_ob_cb_func(bContext *C, Scene *scene, SceneLayer *sl, View3D *
}
else if (tmode == TFM_RESIZE) {
if (v3d->around == V3D_AROUND_ACTIVE) {
- if (ob != OBACT_NEW)
+ if (ob != OBACT_NEW(sl))
do_loc = true;
}
else if (v3d->around == V3D_AROUND_CURSOR)
@@ -5841,7 +5953,7 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *o
*/
if (C && (ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS)) {
//ED_pose_clear_paths(C, ob); // XXX for now, don't need to clear
- ED_pose_recalculate_paths(scene, ob);
+ ED_pose_recalculate_paths(C, scene, ob);
}
}
else {
@@ -5859,27 +5971,23 @@ static void special_aftertrans_update__movieclip(bContext *C, TransInfo *t)
{
SpaceClip *sc = t->sa->spacedata.first;
MovieClip *clip = ED_space_clip_get_clip(sc);
- MovieTrackingPlaneTrack *plane_track;
ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(&clip->tracking);
- int framenr = ED_space_clip_get_clip_frame_number(sc);
-
- for (plane_track = plane_tracks_base->first;
+ const int framenr = ED_space_clip_get_clip_frame_number(sc);
+ /* Update coordinates of modified plane tracks. */
+ for (MovieTrackingPlaneTrack *plane_track = plane_tracks_base->first;
plane_track;
plane_track = plane_track->next)
{
bool do_update = false;
-
if (plane_track->flag & PLANE_TRACK_HIDDEN) {
continue;
}
-
do_update |= PLANE_TRACK_VIEW_SELECTED(plane_track) != 0;
if (do_update == false) {
if ((plane_track->flag & PLANE_TRACK_AUTOKEY) == 0) {
int i;
for (i = 0; i < plane_track->point_tracksnr; i++) {
MovieTrackingTrack *track = plane_track->point_tracks[i];
-
if (TRACK_VIEW_SELECTED(sc, track)) {
do_update = true;
break;
@@ -5887,15 +5995,14 @@ static void special_aftertrans_update__movieclip(bContext *C, TransInfo *t)
}
}
}
-
if (do_update) {
BKE_tracking_track_plane_from_existing_motion(plane_track, framenr);
}
}
-
- if (t->scene->nodetree) {
- /* tracks can be used for stabilization nodes,
- * flush update for such nodes */
+ if (t->scene->nodetree != NULL) {
+ /* Tracks can be used for stabilization nodes,
+ * flush update for such nodes.
+ */
nodeUpdateID(t->scene->nodetree, &clip->id);
WM_event_add_notifier(C, NC_SCENE | ND_NODES, NULL);
}
@@ -6001,10 +6108,13 @@ static void special_aftertrans_update__mesh(bContext *UNUSED(C), TransInfo *t)
* */
void special_aftertrans_update(bContext *C, TransInfo *t)
{
+ EvaluationContext eval_ctx;
Object *ob;
// short redrawipo=0, resetslowpar=1;
const bool canceled = (t->state == TRANS_CANCEL);
const bool duplicate = (t->mode == TFM_TIME_DUPLICATE);
+
+ CTX_data_eval_ctx(C, &eval_ctx);
/* early out when nothing happened */
if (t->total == 0 || t->mode == TFM_DUMMY)
@@ -6344,7 +6454,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
* we need to update the pose otherwise no updates get called during
* transform and the auto-ik is not applied. see [#26164] */
struct Object *pose_ob = t->poseobj;
- BKE_pose_where_is(t->scene, pose_ob);
+ BKE_pose_where_is(&eval_ctx, t->scene, pose_ob);
}
/* set BONE_TRANSFORM flags for autokey, manipulator draw might have changed them */
@@ -7722,7 +7832,7 @@ static void createTransGPencil(bContext *C, TransInfo *t)
float mtx[3][3], smtx[3][3];
const Scene *scene = CTX_data_scene(C);
- const int cfra = CFRA;
+ const int cfra_scene = CFRA;
const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
const bool is_prop_edit_connected = (t->flag & T_PROP_CONNECTED) != 0;
@@ -7747,7 +7857,7 @@ static void createTransGPencil(bContext *C, TransInfo *t)
if (gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) {
bGPDframe *gpf = gpl->actframe;
bGPDstroke *gps;
-
+
for (gps = gpf->strokes.first; gps; gps = gps->next) {
/* skip strokes that are invalid for current view */
if (ED_gpencil_stroke_can_use(C, gps) == false) {
@@ -7803,6 +7913,7 @@ static void createTransGPencil(bContext *C, TransInfo *t)
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
/* only editable and visible layers are considered */
if (gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) {
+ const int cfra = (gpl->flag & GP_LAYER_FRAMELOCK) ? gpl->actframe->framenum : cfra_scene;
bGPDframe *gpf = gpl->actframe;
bGPDstroke *gps;
float diff_mat[4][4];
@@ -7819,7 +7930,6 @@ static void createTransGPencil(bContext *C, TransInfo *t)
* - This is useful when animating as it saves that "uh-oh" moment when you realize you've
* spent too much time editing the wrong frame...
*/
- // XXX: should this be allowed when framelock is enabled?
if (gpf->framenum != cfra) {
gpf = BKE_gpencil_frame_addcopy(gpl, cfra);
/* in some weird situations (framelock enabled) return NULL */
@@ -7967,7 +8077,7 @@ void createTransData(bContext *C, TransInfo *t)
{
Scene *scene = t->scene;
SceneLayer *sl = t->scene_layer;
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
/* if tests must match recalcData for correct updates */
if (t->options & CTX_TEXTURE) {
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index ca9e15f5de4..2bed1dd28f2 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -317,7 +317,7 @@ static bool fcu_test_selected(FCurve *fcu)
/* helper for recalcData() - for Action Editor transforms */
static void recalcData_actedit(TransInfo *t)
{
- SceneLayer *sl= t->scene_layer;
+ SceneLayer *sl = t->scene_layer;
SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first;
bAnimContext ac = {NULL};
@@ -329,7 +329,7 @@ static void recalcData_actedit(TransInfo *t)
/* NOTE: sync this with the code in ANIM_animdata_get_context() */
ac.scene = t->scene;
ac.scene_layer = t->scene_layer;
- ac.obact = OBACT_NEW;
+ ac.obact = OBACT_NEW(sl);
ac.sa = t->sa;
ac.ar = t->ar;
ac.sl = (t->sa) ? t->sa->spacedata.first : NULL;
@@ -379,7 +379,7 @@ static void recalcData_graphedit(TransInfo *t)
/* NOTE: sync this with the code in ANIM_animdata_get_context() */
ac.scene = t->scene;
ac.scene_layer = t->scene_layer;
- ac.obact = OBACT_NEW;
+ ac.obact = OBACT_NEW(sl);
ac.sa = t->sa;
ac.ar = t->ar;
ac.sl = (t->sa) ? t->sa->spacedata.first : NULL;
@@ -714,6 +714,9 @@ static void recalcData_spaceclip(TransInfo *t)
static void recalcData_objects(TransInfo *t)
{
Base *base = t->scene_layer->basact;
+ EvaluationContext eval_ctx;
+
+ CTX_data_eval_ctx(t->context, &eval_ctx);
if (t->obedit) {
if (ELEM(t->obedit->type, OB_CURVE, OB_SURF)) {
@@ -898,7 +901,7 @@ static void recalcData_objects(TransInfo *t)
BIK_clear_data(ob->pose);
}
else
- BKE_pose_where_is(t->scene, ob);
+ BKE_pose_where_is(&eval_ctx, t->scene, ob);
}
else if (base && (base->object->mode & OB_MODE_PARTICLE_EDIT) && PE_get_current(t->scene, t->scene_layer, base->object)) {
if (t->state != TRANS_CANCEL) {
@@ -1457,6 +1460,13 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
#endif
setTransformViewAspect(t, t->aspect);
+
+ if (op && (prop = RNA_struct_find_property(op->ptr, "center_override")) && RNA_property_is_set(op->ptr, prop)) {
+ RNA_property_float_get_array(op->ptr, prop, t->center);
+ mul_v3_v3(t->center, t->aspect);
+ t->flag |= T_OVERRIDE_CENTER;
+ }
+
setTransformViewMatrices(t);
initNumInput(&t->num);
}
@@ -1790,7 +1800,7 @@ bool calculateCenterActive(TransInfo *t, bool select_only, float r_center[3])
}
else if (t->flag & T_POSE) {
SceneLayer *sl = t->scene_layer;
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
if (ob) {
bPoseChannel *pchan = BKE_pose_channel_active(ob);
if (pchan && (!select_only || (pchan->bone->flag & BONE_SELECTED))) {
@@ -1810,8 +1820,8 @@ bool calculateCenterActive(TransInfo *t, bool select_only, float r_center[3])
else {
/* object mode */
SceneLayer *sl = t->scene_layer;
- Object *ob = OBACT_NEW;
- Base *base = BASACT_NEW;
+ Object *ob = OBACT_NEW(sl);
+ Base *base = BASACT_NEW(sl);
if (ob && ((!select_only) || ((base->flag & BASE_SELECTED) != 0))) {
copy_v3_v3(r_center, ob->obmat[3]);
ok = true;
@@ -1858,7 +1868,9 @@ static void calculateCenter_FromAround(TransInfo *t, int around, float r_center[
void calculateCenter(TransInfo *t)
{
- calculateCenter_FromAround(t, t->around, t->center);
+ if ((t->flag & T_OVERRIDE_CENTER) == 0) {
+ calculateCenter_FromAround(t, t->around, t->center);
+ }
calculateCenterGlobal(t, t->center, t->center_global);
/* avoid calculating again */
@@ -1872,7 +1884,7 @@ void calculateCenter(TransInfo *t)
calculateCenter2D(t);
/* for panning from cameraview */
- if (t->flag & T_OBJECT) {
+ if ((t->flag & T_OBJECT) && (t->flag & T_OVERRIDE_CENTER) == 0) {
if (t->spacetype == SPACE_VIEW3D && t->ar && t->ar->regiontype == RGN_TYPE_WINDOW) {
if (t->flag & T_CAMERA) {
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index 0f5f2f02e84..c0c7c922061 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -86,6 +86,8 @@
#include "GPU_immediate.h"
#include "GPU_matrix.h"
+// #define USE_AXIS_BOUNDS
+
/* return codes for select, and drawing flags */
#define MAN_TRANS_X (1 << 0)
@@ -114,27 +116,31 @@ enum {
MAN_AXIS_TRANS_Z,
MAN_AXIS_TRANS_C,
+ MAN_AXIS_TRANS_XY,
+ MAN_AXIS_TRANS_YZ,
+ MAN_AXIS_TRANS_ZX,
+#define MAN_AXIS_RANGE_TRANS_START MAN_AXIS_TRANS_X
+#define MAN_AXIS_RANGE_TRANS_END (MAN_AXIS_TRANS_ZX + 1)
+
MAN_AXIS_ROT_X,
MAN_AXIS_ROT_Y,
MAN_AXIS_ROT_Z,
MAN_AXIS_ROT_C,
MAN_AXIS_ROT_T, /* trackball rotation */
+#define MAN_AXIS_RANGE_ROT_START MAN_AXIS_ROT_X
+#define MAN_AXIS_RANGE_ROT_END (MAN_AXIS_ROT_T + 1)
MAN_AXIS_SCALE_X,
MAN_AXIS_SCALE_Y,
MAN_AXIS_SCALE_Z,
MAN_AXIS_SCALE_C,
-
- /* special */
- MAN_AXIS_TRANS_XY,
- MAN_AXIS_TRANS_YZ,
- MAN_AXIS_TRANS_ZX,
-
MAN_AXIS_SCALE_XY,
MAN_AXIS_SCALE_YZ,
MAN_AXIS_SCALE_ZX,
+#define MAN_AXIS_RANGE_SCALE_START MAN_AXIS_SCALE_X
+#define MAN_AXIS_RANGE_SCALE_END (MAN_AXIS_SCALE_ZX + 1)
- MAN_AXIS_LAST,
+ MAN_AXIS_LAST = MAN_AXIS_RANGE_SCALE_END,
};
/* axis types */
@@ -148,29 +154,19 @@ enum {
typedef struct ManipulatorGroup {
bool all_hidden;
- struct wmManipulator *translate_x,
- *translate_y,
- *translate_z,
- *translate_xy,
- *translate_yz,
- *translate_zx,
- *translate_c,
-
- *rotate_x,
- *rotate_y,
- *rotate_z,
- *rotate_c,
- *rotate_t, /* trackball rotation */
-
- *scale_x,
- *scale_y,
- *scale_z,
- *scale_xy,
- *scale_yz,
- *scale_zx,
- *scale_c;
+ struct wmManipulator *manipulators[MAN_AXIS_LAST];
} ManipulatorGroup;
+struct TransformBounds {
+ float center[3]; /* Center for transform widget. */
+ float min[3], max[3]; /* Boundbox of selection for transform widget. */
+
+#ifdef USE_AXIS_BOUNDS
+ /* Normalized axis */
+ float axis[3][3];
+ float axis_min[3], axis_max[3];
+#endif
+};
/* **************** Utilities **************** */
@@ -189,93 +185,78 @@ typedef struct ManipulatorGroup {
static wmManipulator *manipulator_get_axis_from_index(const ManipulatorGroup *man, const short axis_idx)
{
BLI_assert(IN_RANGE_INCL(axis_idx, (float)MAN_AXIS_TRANS_X, (float)MAN_AXIS_LAST));
-
- switch (axis_idx) {
- case MAN_AXIS_TRANS_X:
- return man->translate_x;
- case MAN_AXIS_TRANS_Y:
- return man->translate_y;
- case MAN_AXIS_TRANS_Z:
- return man->translate_z;
- case MAN_AXIS_TRANS_XY:
- return man->translate_xy;
- case MAN_AXIS_TRANS_YZ:
- return man->translate_yz;
- case MAN_AXIS_TRANS_ZX:
- return man->translate_zx;
- case MAN_AXIS_TRANS_C:
- return man->translate_c;
- case MAN_AXIS_ROT_X:
- return man->rotate_x;
- case MAN_AXIS_ROT_Y:
- return man->rotate_y;
- case MAN_AXIS_ROT_Z:
- return man->rotate_z;
- case MAN_AXIS_ROT_C:
- return man->rotate_c;
- case MAN_AXIS_ROT_T:
- return man->rotate_t;
- case MAN_AXIS_SCALE_X:
- return man->scale_x;
- case MAN_AXIS_SCALE_Y:
- return man->scale_y;
- case MAN_AXIS_SCALE_Z:
- return man->scale_z;
- case MAN_AXIS_SCALE_XY:
- return man->scale_xy;
- case MAN_AXIS_SCALE_YZ:
- return man->scale_yz;
- case MAN_AXIS_SCALE_ZX:
- return man->scale_zx;
- case MAN_AXIS_SCALE_C:
- return man->scale_c;
- }
-
- return NULL;
+ return man->manipulators[axis_idx];
}
-static short manipulator_get_axis_type(const ManipulatorGroup *man, const wmManipulator *axis)
+static short manipulator_get_axis_type(const int axis_idx)
{
- if (ELEM(axis, man->translate_x, man->translate_y, man->translate_z, man->translate_c,
- man->translate_xy, man->translate_yz, man->translate_zx))
- {
+ if (axis_idx >= MAN_AXIS_RANGE_TRANS_START && axis_idx < MAN_AXIS_RANGE_TRANS_END) {
return MAN_AXES_TRANSLATE;
}
- else if (ELEM(axis, man->rotate_x, man->rotate_y, man->rotate_z, man->rotate_c, man->rotate_t)) {
+ if (axis_idx >= MAN_AXIS_RANGE_ROT_START && axis_idx < MAN_AXIS_RANGE_ROT_END) {
return MAN_AXES_ROTATE;
}
- else {
+ if (axis_idx >= MAN_AXIS_RANGE_SCALE_START && axis_idx < MAN_AXIS_RANGE_SCALE_END) {
return MAN_AXES_SCALE;
}
+ BLI_assert(0);
+ return -1;
}
-/* get index within axis type, so that x == 0, y == 1 and z == 2, no matter which axis type */
-static uint manipulator_index_normalize(const int axis_idx)
+static uint manipulator_orientation_axis(const int axis_idx, bool *r_is_plane)
{
- if (axis_idx > MAN_AXIS_TRANS_ZX) {
- return axis_idx - 16;
- }
- else if (axis_idx > MAN_AXIS_SCALE_C) {
- return axis_idx - 13;
- }
- else if (axis_idx > MAN_AXIS_ROT_T) {
- return axis_idx - 9;
- }
- else if (axis_idx > MAN_AXIS_TRANS_C) {
- return axis_idx - 4;
- }
+ switch (axis_idx) {
+ case MAN_AXIS_TRANS_YZ:
+ case MAN_AXIS_SCALE_YZ:
+ if (r_is_plane) {
+ *r_is_plane = true;
+ }
+ ATTR_FALLTHROUGH;
+ case MAN_AXIS_TRANS_X:
+ case MAN_AXIS_ROT_X:
+ case MAN_AXIS_SCALE_X:
+ return 0;
+
+ case MAN_AXIS_TRANS_ZX:
+ case MAN_AXIS_SCALE_ZX:
+ if (r_is_plane) {
+ *r_is_plane = true;
+ }
+ ATTR_FALLTHROUGH;
+ case MAN_AXIS_TRANS_Y:
+ case MAN_AXIS_ROT_Y:
+ case MAN_AXIS_SCALE_Y:
+ return 1;
- return axis_idx;
+ case MAN_AXIS_TRANS_XY:
+ case MAN_AXIS_SCALE_XY:
+ if (r_is_plane) {
+ *r_is_plane = true;
+ }
+ ATTR_FALLTHROUGH;
+ case MAN_AXIS_TRANS_Z:
+ case MAN_AXIS_ROT_Z:
+ case MAN_AXIS_SCALE_Z:
+ return 2;
+ }
+ return 3;
}
static bool manipulator_is_axis_visible(
const View3D *v3d, const RegionView3D *rv3d,
const float idot[3], const int axis_type, const int axis_idx)
{
- const uint aidx_norm = manipulator_index_normalize(axis_idx);
+ bool is_plane = false;
+ const uint aidx_norm = manipulator_orientation_axis(axis_idx, &is_plane);
/* don't draw axis perpendicular to the view */
- if (aidx_norm < 3 && idot[aidx_norm] < TW_AXIS_DOT_MIN) {
- return false;
+ if (aidx_norm < 3) {
+ float idot_axis = idot[aidx_norm];
+ if (is_plane) {
+ idot_axis = 1.0f - idot_axis;
+ }
+ if (idot_axis < TW_AXIS_DOT_MIN) {
+ return false;
+ }
}
if ((axis_type == MAN_AXES_TRANSLATE && !(v3d->twtype & V3D_MANIP_TRANSLATE)) ||
@@ -351,10 +332,14 @@ static void manipulator_get_axis_color(
const float alpha_hi = 1.0f;
float alpha_fac;
- const int axis_idx_norm = manipulator_index_normalize(axis_idx);
+ bool is_plane = false;
+ const int axis_idx_norm = manipulator_orientation_axis(axis_idx, &is_plane);
/* get alpha fac based on axis angle, to fade axis out when hiding it because it points towards view */
if (axis_idx_norm < 3) {
- const float idot_axis = idot[axis_idx_norm];
+ float idot_axis = idot[axis_idx_norm];
+ if (is_plane) {
+ idot_axis = 1.0f - idot_axis;
+ }
alpha_fac = (idot_axis > TW_AXIS_DOT_MAX) ?
1.0f : (idot_axis < TW_AXIS_DOT_MIN) ?
0.0f : ((idot_axis - TW_AXIS_DOT_MIN) / (TW_AXIS_DOT_MAX - TW_AXIS_DOT_MIN));
@@ -441,14 +426,18 @@ static void manipulator_get_axis_constraint(const int axis_idx, int r_axis[3])
/* **************** Preparation Stuff **************** */
/* transform widget center calc helper for below */
-static void calc_tw_center(Scene *scene, const float co[3])
+static void calc_tw_center(struct TransformBounds *tbounds, const float co[3])
{
- float *twcent = scene->twcent;
- float *min = scene->twmin;
- float *max = scene->twmax;
+ minmax_v3v3_v3(tbounds->min, tbounds->max, co);
+ add_v3_v3(tbounds->center, co);
- minmax_v3v3_v3(min, max, co);
- add_v3_v3(twcent, co);
+#ifdef USE_AXIS_BOUNDS
+ for (int i = 0; i < 3; i++) {
+ const float d = dot_v3v3(tbounds->axis[i], co);
+ tbounds->axis_min[i] = min_ff(d, tbounds->axis_min[i]);
+ tbounds->axis_max[i] = max_ff(d, tbounds->axis_max[i]);
+ }
+#endif
}
static void protectflag_to_drawflags(short protectflag, short *drawflags)
@@ -593,7 +582,7 @@ bool gimbal_axis(Object *ob, float gmat[3][3])
/* centroid, boundbox, of selection */
/* returns total items selected */
-static int calc_manipulator_stats(const bContext *C)
+static int calc_manipulator_stats(const bContext *C, struct TransformBounds *tbounds)
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
@@ -603,7 +592,7 @@ static int calc_manipulator_stats(const bContext *C)
View3D *v3d = sa->spacedata.first;
RegionView3D *rv3d = ar->regiondata;
Base *base;
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
bGPdata *gpd = CTX_data_gpencil_data(C);
const bool is_gp_edit = ((gpd) && (gpd->flag & GP_DATA_STROKE_EDITMODE));
int a, totsel = 0;
@@ -613,10 +602,88 @@ static int calc_manipulator_stats(const bContext *C)
rv3d->twdrawflag = 0xFFFF;
+
+ /* global, local or normal orientation?
+ * if we could check 'totsel' now, this should be skipped with no selection. */
+ if (ob && !is_gp_edit) {
+
+ switch (v3d->twmode) {
+
+ case V3D_MANIP_GLOBAL:
+ {
+ break; /* nothing to do */
+ }
+ case V3D_MANIP_GIMBAL:
+ {
+ float mat[3][3];
+ if (gimbal_axis(ob, mat)) {
+ copy_m4_m3(rv3d->twmat, mat);
+ break;
+ }
+ /* if not gimbal, fall through to normal */
+ ATTR_FALLTHROUGH;
+ }
+ case V3D_MANIP_NORMAL:
+ {
+ if (obedit || ob->mode & OB_MODE_POSE) {
+ float mat[3][3];
+ ED_getTransformOrientationMatrix(C, mat, v3d->around);
+ copy_m4_m3(rv3d->twmat, mat);
+ break;
+ }
+ /* no break we define 'normal' as 'local' in Object mode */
+ ATTR_FALLTHROUGH;
+ }
+ case V3D_MANIP_LOCAL:
+ {
+ if (ob->mode & OB_MODE_POSE) {
+ /* each bone moves on its own local axis, but to avoid confusion,
+ * use the active pones axis for display [#33575], this works as expected on a single bone
+ * and users who select many bones will understand whats going on and what local means
+ * when they start transforming */
+ float mat[3][3];
+ ED_getTransformOrientationMatrix(C, mat, v3d->around);
+ copy_m4_m3(rv3d->twmat, mat);
+ break;
+ }
+ copy_m4_m4(rv3d->twmat, ob->obmat);
+ normalize_m4(rv3d->twmat);
+ break;
+ }
+ case V3D_MANIP_VIEW:
+ {
+ float mat[3][3];
+ copy_m3_m4(mat, rv3d->viewinv);
+ normalize_m3(mat);
+ copy_m4_m3(rv3d->twmat, mat);
+ break;
+ }
+ case V3D_MANIP_CUSTOM:
+ {
+ TransformOrientation *custom_orientation = BKE_workspace_transform_orientation_find(
+ CTX_wm_workspace(C), v3d->custom_orientation_index);
+ float mat[3][3];
+
+ if (applyTransformOrientation(custom_orientation, mat, NULL)) {
+ copy_m4_m3(rv3d->twmat, mat);
+ }
+ break;
+ }
+ }
+ }
+
/* transform widget centroid/center */
- INIT_MINMAX(scene->twmin, scene->twmax);
- zero_v3(scene->twcent);
-
+ INIT_MINMAX(tbounds->min, tbounds->max);
+ zero_v3(tbounds->center);
+
+#ifdef USE_AXIS_BOUNDS
+ copy_m3_m4(tbounds->axis, rv3d->twmat);
+ for (int i = 0; i < 3; i++) {
+ tbounds->axis_min[i] = +FLT_MAX;
+ tbounds->axis_max[i] = -FLT_MAX;
+ }
+#endif
+
if (is_gp_edit) {
float diff_mat[4][4];
float fpt[3];
@@ -645,12 +712,12 @@ static int calc_manipulator_stats(const bContext *C)
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
if (pt->flag & GP_SPOINT_SELECT) {
if (gpl->parent == NULL) {
- calc_tw_center(scene, &pt->x);
+ calc_tw_center(tbounds, &pt->x);
totsel++;
}
else {
mul_v3_m4v3(fpt, diff_mat, &pt->x);
- calc_tw_center(scene, fpt);
+ calc_tw_center(tbounds, fpt);
totsel++;
}
}
@@ -663,7 +730,7 @@ static int calc_manipulator_stats(const bContext *C)
/* selection center */
if (totsel) {
- mul_v3_fl(scene->twcent, 1.0f / (float)totsel); /* centroid! */
+ mul_v3_fl(tbounds->center, 1.0f / (float)totsel); /* centroid! */
}
}
else if (obedit) {
@@ -676,7 +743,7 @@ static int calc_manipulator_stats(const bContext *C)
/* USE LAST SELECTE WITH ACTIVE */
if ((v3d->around == V3D_AROUND_ACTIVE) && BM_select_history_active_get(em->bm, &ese)) {
BM_editselection_center(&ese, vec);
- calc_tw_center(scene, vec);
+ calc_tw_center(tbounds, vec);
totsel = 1;
}
else {
@@ -689,7 +756,7 @@ static int calc_manipulator_stats(const bContext *C)
if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
totsel++;
- calc_tw_center(scene, eve->co);
+ calc_tw_center(tbounds, eve->co);
}
}
}
@@ -702,13 +769,13 @@ static int calc_manipulator_stats(const bContext *C)
if ((v3d->around == V3D_AROUND_ACTIVE) && (ebo = arm->act_edbone)) {
/* doesn't check selection or visibility intentionally */
if (ebo->flag & BONE_TIPSEL) {
- calc_tw_center(scene, ebo->tail);
+ calc_tw_center(tbounds, ebo->tail);
totsel++;
}
if ((ebo->flag & BONE_ROOTSEL) ||
((ebo->flag & BONE_TIPSEL) == false)) /* ensure we get at least one point */
{
- calc_tw_center(scene, ebo->head);
+ calc_tw_center(tbounds, ebo->head);
totsel++;
}
protectflag_to_drawflags_ebone(rv3d, ebo);
@@ -717,7 +784,7 @@ static int calc_manipulator_stats(const bContext *C)
for (ebo = arm->edbo->first; ebo; ebo = ebo->next) {
if (EBONE_VISIBLE(arm, ebo)) {
if (ebo->flag & BONE_TIPSEL) {
- calc_tw_center(scene, ebo->tail);
+ calc_tw_center(tbounds, ebo->tail);
totsel++;
}
if ((ebo->flag & BONE_ROOTSEL) &&
@@ -727,7 +794,7 @@ static int calc_manipulator_stats(const bContext *C)
(ebo->parent->flag & BONE_TIPSEL) &&
EBONE_VISIBLE(arm, ebo->parent)) == 0)
{
- calc_tw_center(scene, ebo->head);
+ calc_tw_center(tbounds, ebo->head);
totsel++;
}
if (ebo->flag & BONE_SELECTED) {
@@ -742,7 +809,7 @@ static int calc_manipulator_stats(const bContext *C)
float center[3];
if (v3d->around == V3D_AROUND_ACTIVE && ED_curve_active_center(cu, center)) {
- calc_tw_center(scene, center);
+ calc_tw_center(tbounds, center);
totsel++;
}
else {
@@ -763,21 +830,21 @@ static int calc_manipulator_stats(const bContext *C)
*/
if (cu->drawflag & CU_HIDE_HANDLES) {
if (bezt->f2 & SELECT) {
- calc_tw_center(scene, bezt->vec[1]);
+ calc_tw_center(tbounds, bezt->vec[1]);
totsel++;
}
}
else if (bezt->f2 & SELECT) {
- calc_tw_center(scene, bezt->vec[1]);
+ calc_tw_center(tbounds, bezt->vec[1]);
totsel++;
}
else {
if (bezt->f1 & SELECT) {
- calc_tw_center(scene, bezt->vec[(v3d->around == V3D_AROUND_LOCAL_ORIGINS) ? 1 : 0]);
+ calc_tw_center(tbounds, bezt->vec[(v3d->around == V3D_AROUND_LOCAL_ORIGINS) ? 1 : 0]);
totsel++;
}
if (bezt->f3 & SELECT) {
- calc_tw_center(scene, bezt->vec[(v3d->around == V3D_AROUND_LOCAL_ORIGINS) ? 1 : 2]);
+ calc_tw_center(tbounds, bezt->vec[(v3d->around == V3D_AROUND_LOCAL_ORIGINS) ? 1 : 2]);
totsel++;
}
}
@@ -789,7 +856,7 @@ static int calc_manipulator_stats(const bContext *C)
a = nu->pntsu * nu->pntsv;
while (a--) {
if (bp->f1 & SELECT) {
- calc_tw_center(scene, bp->vec);
+ calc_tw_center(tbounds, bp->vec);
totsel++;
}
bp++;
@@ -804,13 +871,13 @@ static int calc_manipulator_stats(const bContext *C)
MetaElem *ml;
if ((v3d->around == V3D_AROUND_ACTIVE) && (ml = mb->lastelem)) {
- calc_tw_center(scene, &ml->x);
+ calc_tw_center(tbounds, &ml->x);
totsel++;
}
else {
for (ml = mb->editelems->first; ml; ml = ml->next) {
if (ml->flag & SELECT) {
- calc_tw_center(scene, &ml->x);
+ calc_tw_center(tbounds, &ml->x);
totsel++;
}
}
@@ -821,7 +888,7 @@ static int calc_manipulator_stats(const bContext *C)
BPoint *bp;
if ((v3d->around == V3D_AROUND_ACTIVE) && (bp = BKE_lattice_active_point_get(lt))) {
- calc_tw_center(scene, bp->vec);
+ calc_tw_center(tbounds, bp->vec);
totsel++;
}
else {
@@ -829,7 +896,7 @@ static int calc_manipulator_stats(const bContext *C)
a = lt->pntsu * lt->pntsv * lt->pntsw;
while (a--) {
if (bp->f1 & SELECT) {
- calc_tw_center(scene, bp->vec);
+ calc_tw_center(tbounds, bp->vec);
totsel++;
}
bp++;
@@ -839,10 +906,10 @@ static int calc_manipulator_stats(const bContext *C)
/* selection center */
if (totsel) {
- mul_v3_fl(scene->twcent, 1.0f / (float)totsel); // centroid!
- mul_m4_v3(obedit->obmat, scene->twcent);
- mul_m4_v3(obedit->obmat, scene->twmin);
- mul_m4_v3(obedit->obmat, scene->twmax);
+ mul_v3_fl(tbounds->center, 1.0f / (float)totsel); // centroid!
+ mul_m4_v3(obedit->obmat, tbounds->center);
+ mul_m4_v3(obedit->obmat, tbounds->min);
+ mul_m4_v3(obedit->obmat, tbounds->max);
}
}
else if (ob && (ob->mode & OB_MODE_POSE)) {
@@ -854,7 +921,7 @@ static int calc_manipulator_stats(const bContext *C)
/* doesn't check selection or visibility intentionally */
Bone *bone = pchan->bone;
if (bone) {
- calc_tw_center(scene, pchan->pose_head);
+ calc_tw_center(tbounds, pchan->pose_head);
protectflag_to_drawflags_pchan(rv3d, pchan);
totsel = 1;
ok = true;
@@ -868,7 +935,7 @@ static int calc_manipulator_stats(const bContext *C)
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
Bone *bone = pchan->bone;
if (bone && (bone->flag & BONE_TRANSFORM)) {
- calc_tw_center(scene, pchan->pose_head);
+ calc_tw_center(tbounds, pchan->pose_head);
protectflag_to_drawflags_pchan(rv3d, pchan);
}
}
@@ -877,10 +944,10 @@ static int calc_manipulator_stats(const bContext *C)
}
if (ok) {
- mul_v3_fl(scene->twcent, 1.0f / (float)totsel); // centroid!
- mul_m4_v3(ob->obmat, scene->twcent);
- mul_m4_v3(ob->obmat, scene->twmin);
- mul_m4_v3(ob->obmat, scene->twmax);
+ mul_v3_fl(tbounds->center, 1.0f / (float)totsel); // centroid!
+ mul_m4_v3(ob->obmat, tbounds->center);
+ mul_m4_v3(ob->obmat, tbounds->min);
+ mul_m4_v3(ob->obmat, tbounds->max);
}
}
else if (ob && (ob->mode & OB_MODE_ALL_PAINT)) {
@@ -899,7 +966,7 @@ static int calc_manipulator_stats(const bContext *C)
for (k = 0, ek = point->keys; k < point->totkey; k++, ek++) {
if (ek->flag & PEK_SELECT) {
- calc_tw_center(scene, (ek->flag & PEK_USE_WCO) ? ek->world_co : ek->co);
+ calc_tw_center(tbounds, (ek->flag & PEK_USE_WCO) ? ek->world_co : ek->co);
totsel++;
}
}
@@ -907,21 +974,21 @@ static int calc_manipulator_stats(const bContext *C)
/* selection center */
if (totsel)
- mul_v3_fl(scene->twcent, 1.0f / (float)totsel); // centroid!
+ mul_v3_fl(tbounds->center, 1.0f / (float)totsel); // centroid!
}
}
else {
/* we need the one selected object, if its not active */
- base = BASACT_NEW;
- ob = OBACT_NEW;
+ base = BASACT_NEW(sl);
+ ob = OBACT_NEW(sl);
if (base && ((base->flag & BASE_SELECTED) == 0)) ob = NULL;
for (base = sl->object_bases.first; base; base = base->next) {
if (TESTBASELIB_NEW(base)) {
if (ob == NULL)
ob = base->object;
- calc_tw_center(scene, base->object->obmat[3]);
+ calc_tw_center(tbounds, base->object->obmat[3]);
protectflag_to_drawflags(base->object->protectflag, &rv3d->twdrawflag);
totsel++;
}
@@ -929,77 +996,12 @@ static int calc_manipulator_stats(const bContext *C)
/* selection center */
if (totsel) {
- mul_v3_fl(scene->twcent, 1.0f / (float)totsel); // centroid!
+ mul_v3_fl(tbounds->center, 1.0f / (float)totsel); // centroid!
}
}
- /* global, local or normal orientation? */
- if (ob && totsel && !is_gp_edit) {
-
- switch (v3d->twmode) {
-
- case V3D_MANIP_GLOBAL:
- {
- break; /* nothing to do */
- }
- case V3D_MANIP_GIMBAL:
- {
- float mat[3][3];
- if (gimbal_axis(ob, mat)) {
- copy_m4_m3(rv3d->twmat, mat);
- break;
- }
- /* if not gimbal, fall through to normal */
- ATTR_FALLTHROUGH;
- }
- case V3D_MANIP_NORMAL:
- {
- if (obedit || ob->mode & OB_MODE_POSE) {
- float mat[3][3];
- ED_getTransformOrientationMatrix(C, mat, v3d->around);
- copy_m4_m3(rv3d->twmat, mat);
- break;
- }
- /* no break we define 'normal' as 'local' in Object mode */
- ATTR_FALLTHROUGH;
- }
- case V3D_MANIP_LOCAL:
- {
- if (ob->mode & OB_MODE_POSE) {
- /* each bone moves on its own local axis, but to avoid confusion,
- * use the active pones axis for display [#33575], this works as expected on a single bone
- * and users who select many bones will understand whats going on and what local means
- * when they start transforming */
- float mat[3][3];
- ED_getTransformOrientationMatrix(C, mat, v3d->around);
- copy_m4_m3(rv3d->twmat, mat);
- break;
- }
- copy_m4_m4(rv3d->twmat, ob->obmat);
- normalize_m4(rv3d->twmat);
- break;
- }
- case V3D_MANIP_VIEW:
- {
- float mat[3][3];
- copy_m3_m4(mat, rv3d->viewinv);
- normalize_m3(mat);
- copy_m4_m3(rv3d->twmat, mat);
- break;
- }
- case V3D_MANIP_CUSTOM:
- {
- TransformOrientation *custom_orientation = BKE_workspace_transform_orientation_find(
- CTX_wm_workspace(C), v3d->custom_orientation_index);
- float mat[3][3];
-
- if (applyTransformOrientation(custom_orientation, mat, NULL)) {
- copy_m4_m3(rv3d->twmat, mat);
- }
- break;
- }
- }
-
+ if (totsel == 0) {
+ unit_m4(rv3d->twmat);
}
return totsel;
@@ -1015,7 +1017,8 @@ static void manipulator_get_idot(RegionView3D *rv3d, float r_idot[3])
}
}
-static void manipulator_prepare_mat(const bContext *C, View3D *v3d, RegionView3D *rv3d)
+static void manipulator_prepare_mat(
+ const bContext *C, View3D *v3d, RegionView3D *rv3d, const struct TransformBounds *tbounds)
{
Scene *scene = CTX_data_scene(C);
SceneLayer *sl = CTX_data_scene_layer(C);
@@ -1024,23 +1027,23 @@ static void manipulator_prepare_mat(const bContext *C, View3D *v3d, RegionView3D
case V3D_AROUND_CENTER_BOUNDS:
case V3D_AROUND_ACTIVE:
{
- bGPdata *gpd = CTX_data_gpencil_data(C);
- Object *ob = OBACT_NEW;
+ bGPdata *gpd = CTX_data_gpencil_data(C);
+ Object *ob = OBACT_NEW(sl);
- if (((v3d->around == V3D_AROUND_ACTIVE) && (scene->obedit == NULL)) &&
- ((gpd == NULL) || !(gpd->flag & GP_DATA_STROKE_EDITMODE)) &&
- (!(ob->mode & OB_MODE_POSE)))
- {
- copy_v3_v3(rv3d->twmat[3], ob->obmat[3]);
- }
- else {
- mid_v3_v3v3(rv3d->twmat[3], scene->twmin, scene->twmax);
- }
- break;
+ if (((v3d->around == V3D_AROUND_ACTIVE) && (scene->obedit == NULL)) &&
+ ((gpd == NULL) || !(gpd->flag & GP_DATA_STROKE_EDITMODE)) &&
+ (!(ob->mode & OB_MODE_POSE)))
+ {
+ copy_v3_v3(rv3d->twmat[3], ob->obmat[3]);
+ }
+ else {
+ mid_v3_v3v3(rv3d->twmat[3], tbounds->min, tbounds->max);
+ }
+ break;
}
case V3D_AROUND_LOCAL_ORIGINS:
case V3D_AROUND_CENTER_MEAN:
- copy_v3_v3(rv3d->twmat[3], scene->twcent);
+ copy_v3_v3(rv3d->twmat[3], tbounds->center);
break;
case V3D_AROUND_CURSOR:
copy_v3_v3(rv3d->twmat[3], ED_view3d_cursor3d_get(scene, v3d));
@@ -1090,48 +1093,48 @@ static ManipulatorGroup *manipulatorgroup_init(wmManipulatorGroup *mgroup)
const wmManipulatorType *wt_dial = WM_manipulatortype_find("MANIPULATOR_WT_dial_3d", true);
const wmManipulatorType *wt_prim = WM_manipulatortype_find("MANIPULATOR_WT_primitive_3d", true);
-#define MANIPULATOR_NEW_ARROW(v, name, draw_style) { \
- v = WM_manipulator_new_ptr(wt_arrow, mgroup, name, NULL); \
- RNA_enum_set((v)->ptr, "draw_style", draw_style); \
+#define MANIPULATOR_NEW_ARROW(v, draw_style) { \
+ man->manipulators[v] = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL); \
+ RNA_enum_set(man->manipulators[v]->ptr, "draw_style", draw_style); \
} ((void)0)
-#define MANIPULATOR_NEW_DIAL(v, name, draw_options) { \
- v = WM_manipulator_new_ptr(wt_dial, mgroup, name, NULL); \
- RNA_enum_set((v)->ptr, "draw_options", draw_options); \
+#define MANIPULATOR_NEW_DIAL(v, draw_options) { \
+ man->manipulators[v] = WM_manipulator_new_ptr(wt_dial, mgroup, NULL); \
+ RNA_enum_set(man->manipulators[v]->ptr, "draw_options", draw_options); \
} ((void)0)
-#define MANIPULATOR_NEW_PRIM(v, name, draw_style) { \
- v = WM_manipulator_new_ptr(wt_prim, mgroup, name, NULL); \
- RNA_enum_set((v)->ptr, "draw_style", draw_style); \
+#define MANIPULATOR_NEW_PRIM(v, draw_style) { \
+ man->manipulators[v] = WM_manipulator_new_ptr(wt_prim, mgroup, NULL); \
+ RNA_enum_set(man->manipulators[v]->ptr, "draw_style", draw_style); \
} ((void)0)
/* add/init widgets - order matters! */
- MANIPULATOR_NEW_DIAL(man->rotate_t, "rotate_t", ED_MANIPULATOR_DIAL_DRAW_FLAG_FILL);
+ MANIPULATOR_NEW_DIAL(MAN_AXIS_ROT_T, ED_MANIPULATOR_DIAL_DRAW_FLAG_FILL);
- MANIPULATOR_NEW_DIAL(man->scale_c, "scale_c", ED_MANIPULATOR_DIAL_DRAW_FLAG_NOP);
+ MANIPULATOR_NEW_DIAL(MAN_AXIS_SCALE_C, ED_MANIPULATOR_DIAL_DRAW_FLAG_NOP);
- MANIPULATOR_NEW_ARROW(man->scale_x, "scale_x", ED_MANIPULATOR_ARROW_STYLE_BOX);
- MANIPULATOR_NEW_ARROW(man->scale_y, "scale_y", ED_MANIPULATOR_ARROW_STYLE_BOX);
- MANIPULATOR_NEW_ARROW(man->scale_z, "scale_z", ED_MANIPULATOR_ARROW_STYLE_BOX);
+ MANIPULATOR_NEW_ARROW(MAN_AXIS_SCALE_X, ED_MANIPULATOR_ARROW_STYLE_BOX);
+ MANIPULATOR_NEW_ARROW(MAN_AXIS_SCALE_Y, ED_MANIPULATOR_ARROW_STYLE_BOX);
+ MANIPULATOR_NEW_ARROW(MAN_AXIS_SCALE_Z, ED_MANIPULATOR_ARROW_STYLE_BOX);
- MANIPULATOR_NEW_PRIM(man->scale_xy, "scale_xy", ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE);
- MANIPULATOR_NEW_PRIM(man->scale_yz, "scale_yz", ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE);
- MANIPULATOR_NEW_PRIM(man->scale_zx, "scale_zx", ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE);
+ MANIPULATOR_NEW_PRIM(MAN_AXIS_SCALE_XY, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE);
+ MANIPULATOR_NEW_PRIM(MAN_AXIS_SCALE_YZ, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE);
+ MANIPULATOR_NEW_PRIM(MAN_AXIS_SCALE_ZX, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE);
- MANIPULATOR_NEW_DIAL(man->rotate_x, "rotate_x", ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP);
- MANIPULATOR_NEW_DIAL(man->rotate_y, "rotate_y", ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP);
- MANIPULATOR_NEW_DIAL(man->rotate_z, "rotate_z", ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP);
+ MANIPULATOR_NEW_DIAL(MAN_AXIS_ROT_X, ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP);
+ MANIPULATOR_NEW_DIAL(MAN_AXIS_ROT_Y, ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP);
+ MANIPULATOR_NEW_DIAL(MAN_AXIS_ROT_Z, ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP);
/* init screen aligned widget last here, looks better, behaves better */
- MANIPULATOR_NEW_DIAL(man->rotate_c, "rotate_c", ED_MANIPULATOR_DIAL_DRAW_FLAG_NOP);
+ MANIPULATOR_NEW_DIAL(MAN_AXIS_ROT_C, ED_MANIPULATOR_DIAL_DRAW_FLAG_NOP);
- MANIPULATOR_NEW_DIAL(man->translate_c, "translate_c", ED_MANIPULATOR_DIAL_DRAW_FLAG_NOP);
+ MANIPULATOR_NEW_DIAL(MAN_AXIS_TRANS_C, ED_MANIPULATOR_DIAL_DRAW_FLAG_NOP);
- MANIPULATOR_NEW_ARROW(man->translate_x, "translate_x", ED_MANIPULATOR_ARROW_STYLE_NORMAL);
- MANIPULATOR_NEW_ARROW(man->translate_y, "translate_y", ED_MANIPULATOR_ARROW_STYLE_NORMAL);
- MANIPULATOR_NEW_ARROW(man->translate_z, "translate_z", ED_MANIPULATOR_ARROW_STYLE_NORMAL);
+ MANIPULATOR_NEW_ARROW(MAN_AXIS_TRANS_X, ED_MANIPULATOR_ARROW_STYLE_NORMAL);
+ MANIPULATOR_NEW_ARROW(MAN_AXIS_TRANS_Y, ED_MANIPULATOR_ARROW_STYLE_NORMAL);
+ MANIPULATOR_NEW_ARROW(MAN_AXIS_TRANS_Z, ED_MANIPULATOR_ARROW_STYLE_NORMAL);
- MANIPULATOR_NEW_PRIM(man->translate_xy, "translate_xy", ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE);
- MANIPULATOR_NEW_PRIM(man->translate_yz, "translate_yz", ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE);
- MANIPULATOR_NEW_PRIM(man->translate_zx, "translate_zx", ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE);
+ MANIPULATOR_NEW_PRIM(MAN_AXIS_TRANS_XY, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE);
+ MANIPULATOR_NEW_PRIM(MAN_AXIS_TRANS_YZ, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE);
+ MANIPULATOR_NEW_PRIM(MAN_AXIS_TRANS_ZX, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE);
return man;
}
@@ -1139,20 +1142,25 @@ static ManipulatorGroup *manipulatorgroup_init(wmManipulatorGroup *mgroup)
/**
* Custom handler for manipulator widgets
*/
-static void manipulator_modal(
- bContext *C, wmManipulator *widget, const wmEvent *UNUSED(event), const int UNUSED(flag))
+static int manipulator_modal(
+ bContext *C, wmManipulator *widget, const wmEvent *UNUSED(event),
+ eWM_ManipulatorTweak UNUSED(tweak_flag))
{
const ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
View3D *v3d = sa->spacedata.first;
RegionView3D *rv3d = ar->regiondata;
+ struct TransformBounds tbounds;
- if (calc_manipulator_stats(C)) {
- manipulator_prepare_mat(C, v3d, rv3d);
+
+ if (calc_manipulator_stats(C, &tbounds)) {
+ manipulator_prepare_mat(C, v3d, rv3d, &tbounds);
WM_manipulator_set_matrix_location(widget, rv3d->twmat[3]);
}
ED_region_tag_redraw(ar);
+
+ return OPERATOR_RUNNING_MODAL;
}
static void WIDGETGROUP_manipulator_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
@@ -1168,7 +1176,7 @@ static void WIDGETGROUP_manipulator_setup(const bContext *UNUSED(C), wmManipulat
MAN_ITER_AXES_BEGIN(axis, axis_idx)
{
- const short axis_type = manipulator_get_axis_type(man, axis);
+ const short axis_type = manipulator_get_axis_type(axis_idx);
int constraint_axis[3] = {1, 0, 0};
PointerRNA *ptr;
@@ -1177,7 +1185,7 @@ static void WIDGETGROUP_manipulator_setup(const bContext *UNUSED(C), wmManipulat
/* custom handler! */
WM_manipulator_set_fn_custom_modal(axis, manipulator_modal);
- switch(axis_idx) {
+ switch (axis_idx) {
case MAN_AXIS_TRANS_X:
case MAN_AXIS_TRANS_Y:
case MAN_AXIS_TRANS_Z:
@@ -1204,6 +1212,7 @@ static void WIDGETGROUP_manipulator_setup(const bContext *UNUSED(C), wmManipulat
const float ofs[3] = {ofs_ax, ofs_ax, 0.0f};
WM_manipulator_set_scale(axis, 0.07f);
WM_manipulator_set_matrix_offset_location(axis, ofs);
+ WM_manipulator_set_flag(axis, WM_MANIPULATOR_DRAW_OFFSET_SCALE, true);
break;
}
case MAN_AXIS_TRANS_C:
@@ -1228,7 +1237,7 @@ static void WIDGETGROUP_manipulator_setup(const bContext *UNUSED(C), wmManipulat
if (ot_store.translate == NULL) {
ot_store.translate = WM_operatortype_find("TRANSFORM_OT_translate", true);
}
- ptr = WM_manipulator_set_operator(axis, ot_store.translate, NULL);
+ ptr = WM_manipulator_operator_set(axis, 0, ot_store.translate, NULL);
break;
case MAN_AXES_ROTATE:
{
@@ -1245,7 +1254,7 @@ static void WIDGETGROUP_manipulator_setup(const bContext *UNUSED(C), wmManipulat
}
ot_rotate = ot_store.rotate;
}
- ptr = WM_manipulator_set_operator(axis, ot_rotate, NULL);
+ ptr = WM_manipulator_operator_set(axis, 0, ot_rotate, NULL);
break;
}
case MAN_AXES_SCALE:
@@ -1253,7 +1262,7 @@ static void WIDGETGROUP_manipulator_setup(const bContext *UNUSED(C), wmManipulat
if (ot_store.resize == NULL) {
ot_store.resize = WM_operatortype_find("TRANSFORM_OT_resize", true);
}
- ptr = WM_manipulator_set_operator(axis, ot_store.resize, NULL);
+ ptr = WM_manipulator_operator_set(axis, 0, ot_store.resize, NULL);
break;
}
}
@@ -1277,19 +1286,20 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou
ARegion *ar = CTX_wm_region(C);
View3D *v3d = sa->spacedata.first;
RegionView3D *rv3d = ar->regiondata;
+ struct TransformBounds tbounds;
/* skip, we don't draw anything anyway */
- if ((man->all_hidden = (calc_manipulator_stats(C) == 0)))
+ if ((man->all_hidden = (calc_manipulator_stats(C, &tbounds) == 0)))
return;
- manipulator_prepare_mat(C, v3d, rv3d);
+ manipulator_prepare_mat(C, v3d, rv3d, &tbounds);
/* *** set properties for axes *** */
MAN_ITER_AXES_BEGIN(axis, axis_idx)
{
- const short axis_type = manipulator_get_axis_type(man, axis);
- const int aidx_norm = manipulator_index_normalize(axis_idx);
+ const short axis_type = manipulator_get_axis_type(axis_idx);
+ const int aidx_norm = manipulator_orientation_axis(axis_idx, NULL);
WM_manipulator_set_matrix_location(axis, rv3d->twmat[3]);
@@ -1309,6 +1319,7 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou
WM_manipulator_set_matrix_rotation_from_z_axis(axis, rv3d->twmat[aidx_norm]);
RNA_float_set(axis->ptr, "length", len);
WM_manipulator_set_matrix_offset_location(axis, start_co);
+ WM_manipulator_set_flag(axis, WM_MANIPULATOR_DRAW_OFFSET_SCALE, true);
break;
}
case MAN_AXIS_ROT_X:
@@ -1323,8 +1334,8 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou
case MAN_AXIS_SCALE_YZ:
case MAN_AXIS_SCALE_ZX:
{
- const float *y_axis = rv3d->twmat[aidx_norm + 1 > 2 ? 0 : aidx_norm + 1];
- const float *z_axis = rv3d->twmat[aidx_norm - 1 < 0 ? 2 : aidx_norm - 1];
+ const float *y_axis = rv3d->twmat[aidx_norm - 1 < 0 ? 2 : aidx_norm - 1];
+ const float *z_axis = rv3d->twmat[aidx_norm];
WM_manipulator_set_matrix_rotation_from_yz_axis(axis, y_axis, z_axis);
break;
}
@@ -1358,7 +1369,7 @@ static void WIDGETGROUP_manipulator_draw_prepare(const bContext *C, wmManipulato
MAN_ITER_AXES_BEGIN(axis, axis_idx)
{
- const short axis_type = manipulator_get_axis_type(man, axis);
+ const short axis_type = manipulator_get_axis_type(axis_idx);
/* XXX maybe unset _HIDDEN flag on redraw? */
if (manipulator_is_axis_visible(v3d, rv3d, idot, axis_type, axis_idx)) {
WM_manipulator_set_flag(axis, WM_MANIPULATOR_HIDDEN, false);
@@ -1368,10 +1379,10 @@ static void WIDGETGROUP_manipulator_draw_prepare(const bContext *C, wmManipulato
continue;
}
- float col[4], col_hi[4];
- manipulator_get_axis_color(axis_idx, idot, col, col_hi);
- WM_manipulator_set_color(axis, col);
- WM_manipulator_set_color_highlight(axis, col_hi);
+ float color[4], color_hi[4];
+ manipulator_get_axis_color(axis_idx, idot, color, color_hi);
+ WM_manipulator_set_color(axis, color);
+ WM_manipulator_set_color_highlight(axis, color_hi);
switch (axis_idx) {
case MAN_AXIS_TRANS_C:
diff --git a/source/blender/editors/transform/transform_manipulator2d.c b/source/blender/editors/transform/transform_manipulator2d.c
index 104675cb1a8..94f425eb9f0 100644
--- a/source/blender/editors/transform/transform_manipulator2d.c
+++ b/source/blender/editors/transform/transform_manipulator2d.c
@@ -73,8 +73,13 @@ typedef struct ManipulatorGroup2D {
wmManipulator *translate_x,
*translate_y;
+ wmManipulator *cage;
+
/* Current origin in view space, used to update widget origin for possible view changes */
float origin[2];
+ float min[2];
+ float max[2];
+
} ManipulatorGroup2D;
@@ -131,11 +136,18 @@ static void manipulator2d_get_axis_color(const int axis_idx, float *r_col, float
static ManipulatorGroup2D *manipulatorgroup2d_init(wmManipulatorGroup *mgroup)
{
const wmManipulatorType *wt_arrow = WM_manipulatortype_find("MANIPULATOR_WT_arrow_2d", true);
+ const wmManipulatorType *wt_cage = WM_manipulatortype_find("MANIPULATOR_WT_cage_2d", true);
ManipulatorGroup2D *man = MEM_callocN(sizeof(ManipulatorGroup2D), __func__);
- man->translate_x = WM_manipulator_new_ptr(wt_arrow, mgroup, "translate_x", NULL);
- man->translate_y = WM_manipulator_new_ptr(wt_arrow, mgroup, "translate_y", NULL);
+ man->translate_x = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL);
+ man->translate_y = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL);
+ man->cage = WM_manipulator_new_ptr(wt_cage, mgroup, NULL);
+
+ RNA_enum_set(man->cage->ptr, "transform",
+ ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE |
+ ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE |
+ ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE);
return man;
}
@@ -143,17 +155,24 @@ static ManipulatorGroup2D *manipulatorgroup2d_init(wmManipulatorGroup *mgroup)
/**
* Calculates origin in view space, use with #manipulator2d_origin_to_region.
*/
-static void manipulator2d_calc_origin(const bContext *C, float *r_origin)
+static void manipulator2d_calc_bounds(const bContext *C, float *r_center, float *r_min, float *r_max)
{
SpaceImage *sima = CTX_wm_space_image(C);
Image *ima = ED_space_image(sima);
- if (sima->around == V3D_AROUND_CURSOR) {
- copy_v2_v2(r_origin, sima->cursor);
+ float min_buf[2], max_buf[2];
+ if (r_min == NULL) {
+ r_min = min_buf;
}
- else {
- ED_uvedit_center(CTX_data_scene(C), ima, CTX_data_edit_object(C), r_origin, sima->around);
+ if (r_max == NULL) {
+ r_max = max_buf;
+ }
+
+ if (!ED_uvedit_minmax(CTX_data_scene(C), ima, CTX_data_edit_object(C), r_min, r_max)) {
+ zero_v2(r_min);
+ zero_v2(r_max);
}
+ mid_v2_v2v2(r_center, r_min, r_max);
}
/**
@@ -167,17 +186,20 @@ BLI_INLINE void manipulator2d_origin_to_region(ARegion *ar, float *r_origin)
/**
* Custom handler for manipulator widgets
*/
-static void manipulator2d_modal(
- bContext *C, wmManipulator *widget, const wmEvent *UNUSED(event), const int UNUSED(flag))
+static int manipulator2d_modal(
+ bContext *C, wmManipulator *widget, const wmEvent *UNUSED(event),
+ eWM_ManipulatorTweak UNUSED(tweak_flag))
{
ARegion *ar = CTX_wm_region(C);
float origin[3];
- manipulator2d_calc_origin(C, origin);
+ manipulator2d_calc_bounds(C, origin, NULL, NULL);
manipulator2d_origin_to_region(ar, origin);
WM_manipulator_set_matrix_location(widget, origin);
ED_region_tag_redraw(ar);
+
+ return OPERATOR_RUNNING_MODAL;
}
void ED_widgetgroup_manipulator2d_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
@@ -190,8 +212,8 @@ void ED_widgetgroup_manipulator2d_setup(const bContext *UNUSED(C), wmManipulator
{
const float offset[3] = {0.0f, 0.2f};
- float col[4], col_hi[4];
- manipulator2d_get_axis_color(axis_idx, col, col_hi);
+ float color[4], color_hi[4];
+ manipulator2d_get_axis_color(axis_idx, color, color_hi);
/* custom handler! */
WM_manipulator_set_fn_custom_modal(axis, manipulator2d_modal);
@@ -201,41 +223,128 @@ void ED_widgetgroup_manipulator2d_setup(const bContext *UNUSED(C), wmManipulator
WM_manipulator_set_matrix_offset_location(axis, offset);
WM_manipulator_set_line_width(axis, MANIPULATOR_AXIS_LINE_WIDTH);
WM_manipulator_set_scale(axis, U.manipulator_size);
- WM_manipulator_set_color(axis, col);
- WM_manipulator_set_color_highlight(axis, col_hi);
+ WM_manipulator_set_color(axis, color);
+ WM_manipulator_set_color_highlight(axis, color_hi);
/* assign operator */
- PointerRNA *ptr = WM_manipulator_set_operator(axis, ot_translate, NULL);
- int constraint[3] = {0.0f};
+ PointerRNA *ptr = WM_manipulator_operator_set(axis, 0, ot_translate, NULL);
+ int constraint[3] = {0};
constraint[(axis_idx + 1) % 2] = 1;
if (RNA_struct_find_property(ptr, "constraint_axis"))
RNA_boolean_set_array(ptr, "constraint_axis", constraint);
RNA_boolean_set(ptr, "release_confirm", 1);
}
MAN2D_ITER_AXES_END;
+
+ {
+ wmOperatorType *ot_resize = WM_operatortype_find("TRANSFORM_OT_resize", true);
+ wmOperatorType *ot_rotate = WM_operatortype_find("TRANSFORM_OT_rotate", true);
+ PointerRNA *ptr;
+
+ /* assign operator */
+ ptr = WM_manipulator_operator_set(man->cage, 0, ot_translate, NULL);
+ RNA_boolean_set(ptr, "release_confirm", 1);
+
+ int constraint_x[3] = {1, 0, 0};
+ int constraint_y[3] = {0, 1, 0};
+
+ ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X, ot_resize, NULL);
+ PropertyRNA *prop_release_confirm = RNA_struct_find_property(ptr, "release_confirm");
+ PropertyRNA *prop_constraint_axis = RNA_struct_find_property(ptr, "constraint_axis");
+ RNA_property_boolean_set_array(ptr, prop_constraint_axis, constraint_x);
+ RNA_property_boolean_set(ptr, prop_release_confirm, true);
+ ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X, ot_resize, NULL);
+ RNA_property_boolean_set_array(ptr, prop_constraint_axis, constraint_x);
+ RNA_property_boolean_set(ptr, prop_release_confirm, true);
+ ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y, ot_resize, NULL);
+ RNA_property_boolean_set_array(ptr, prop_constraint_axis, constraint_y);
+ RNA_property_boolean_set(ptr, prop_release_confirm, true);
+ ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y, ot_resize, NULL);
+ RNA_property_boolean_set_array(ptr, prop_constraint_axis, constraint_y);
+ RNA_property_boolean_set(ptr, prop_release_confirm, true);
+
+ ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y, ot_resize, NULL);
+ RNA_property_boolean_set(ptr, prop_release_confirm, true);
+ ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y, ot_resize, NULL);
+ RNA_property_boolean_set(ptr, prop_release_confirm, true);
+ ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y, ot_resize, NULL);
+ RNA_property_boolean_set(ptr, prop_release_confirm, true);
+ ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y, ot_resize, NULL);
+ RNA_property_boolean_set(ptr, prop_release_confirm, true);
+ ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_ROTATE, ot_rotate, NULL);
+ RNA_property_boolean_set(ptr, prop_release_confirm, true);
+ }
}
void ED_widgetgroup_manipulator2d_refresh(const bContext *C, wmManipulatorGroup *mgroup)
{
ManipulatorGroup2D *man = mgroup->customdata;
float origin[3];
-
- manipulator2d_calc_origin(C, origin);
+ manipulator2d_calc_bounds(C, origin, man->min, man->max);
copy_v2_v2(man->origin, origin);
+ bool show_cage = !equals_v2v2(man->min, man->max);
+
+ if (show_cage) {
+ man->cage->flag &= ~WM_MANIPULATOR_HIDDEN;
+ man->translate_x->flag |= WM_MANIPULATOR_HIDDEN;
+ man->translate_y->flag |= WM_MANIPULATOR_HIDDEN;
+ }
+ else {
+ man->cage->flag |= WM_MANIPULATOR_HIDDEN;
+ man->translate_x->flag &= ~WM_MANIPULATOR_HIDDEN;
+ man->translate_y->flag &= ~WM_MANIPULATOR_HIDDEN;
+ }
+
+ if (show_cage) {
+ wmManipulatorOpElem *mpop;
+ float mid[2];
+ const float *min = man->min;
+ const float *max = man->max;
+ mid_v2_v2v2(mid, min, max);
+
+ mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X);
+ PropertyRNA *prop_center_override = RNA_struct_find_property(&mpop->ptr, "center_override");
+ RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){max[0], mid[1], 0.0f});
+ mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X);
+ RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){min[0], mid[1], 0.0f});
+ mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y);
+ RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){mid[0], max[1], 0.0f});
+ mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y);
+ RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){mid[0], min[1], 0.0f});
+
+ mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y);
+ RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){max[0], max[1], 0.0f});
+ mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y);
+ RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){max[0], min[1], 0.0f});
+ mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y);
+ RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){min[0], max[1], 0.0f});
+ mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y);
+ RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){min[0], min[1], 0.0f});
+
+ mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_ROTATE);
+ RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){mid[0], mid[1], 0.0f});
+ }
}
void ED_widgetgroup_manipulator2d_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup)
{
+ ARegion *ar = CTX_wm_region(C);
ManipulatorGroup2D *man = mgroup->customdata;
float origin[3] = {UNPACK2(man->origin), 0.0f};
+ float origin_aa[3] = {UNPACK2(man->origin), 0.0f};
- manipulator2d_origin_to_region(CTX_wm_region(C), origin);
+ manipulator2d_origin_to_region(ar, origin);
MAN2D_ITER_AXES_BEGIN(axis, axis_idx)
{
WM_manipulator_set_matrix_location(axis, origin);
}
MAN2D_ITER_AXES_END;
+
+ UI_view2d_view_to_region_m4(&ar->v2d, man->cage->matrix_space);
+ WM_manipulator_set_matrix_offset_location(man->cage, origin_aa);
+ man->cage->matrix_offset[0][0] = (man->max[0] - man->min[0]);
+ man->cage->matrix_offset[1][1] = (man->max[1] - man->min[1]);
}
/* TODO (Julian)
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index dba442259d1..d7ed80841da 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -559,6 +559,14 @@ void Transform_Properties(struct wmOperatorType *ot, int flags)
RNA_def_boolean(ot->srna, "correct_uv", 0, "Correct UVs", "Correct UV coordinates when transforming");
}
+ if (flags & P_CENTER) {
+ /* For manipulators that define their own center. */
+ prop = RNA_def_property(ot->srna, "center_override", PROP_FLOAT, PROP_XYZ);
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
+ RNA_def_property_ui_text(prop, "Center Override", "Force using this center value (when set)");
+ }
+
if ((flags & P_NO_DEFAULTS) == 0) {
// Add confirm method all the time. At the end because it's not really that important and should be hidden only in log, not in keymap edit
/*prop =*/ RNA_def_boolean(ot->srna, "release_confirm", 0, "Confirm on Release", "Always confirm operation when releasing button");
@@ -606,7 +614,8 @@ static void TRANSFORM_OT_resize(struct wmOperatorType *ot)
RNA_def_float_vector(ot->srna, "value", 3, VecOne, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX);
- Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_GEO_SNAP | P_OPTIONS | P_GPENCIL_EDIT);
+ Transform_Properties(
+ ot, P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_GEO_SNAP | P_OPTIONS | P_GPENCIL_EDIT | P_CENTER);
}
static int skin_resize_poll(bContext *C)
@@ -657,7 +666,7 @@ static void TRANSFORM_OT_trackball(struct wmOperatorType *ot)
/* Maybe we could use float_vector_xyz here too? */
RNA_def_float_rotation(ot->srna, "value", 2, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -FLT_MAX, FLT_MAX);
- Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_GPENCIL_EDIT);
+ Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_GPENCIL_EDIT | P_CENTER);
}
static void TRANSFORM_OT_rotate(struct wmOperatorType *ot)
@@ -677,7 +686,8 @@ static void TRANSFORM_OT_rotate(struct wmOperatorType *ot)
RNA_def_float_rotation(ot->srna, "value", 0, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2);
- Transform_Properties(ot, P_AXIS | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_GEO_SNAP | P_GPENCIL_EDIT);
+ Transform_Properties(
+ ot, P_AXIS | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_GEO_SNAP | P_GPENCIL_EDIT | P_CENTER);
}
static void TRANSFORM_OT_tilt(struct wmOperatorType *ot)
@@ -720,7 +730,7 @@ static void TRANSFORM_OT_bend(struct wmOperatorType *ot)
RNA_def_float_rotation(ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2);
- Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_GPENCIL_EDIT);
+ Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_GPENCIL_EDIT | P_CENTER);
}
static void TRANSFORM_OT_shear(struct wmOperatorType *ot)
@@ -761,7 +771,7 @@ static void TRANSFORM_OT_push_pull(struct wmOperatorType *ot)
RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Distance", "", -FLT_MAX, FLT_MAX);
- Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP);
+ Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_CENTER);
}
static void TRANSFORM_OT_shrink_fatten(struct wmOperatorType *ot)
@@ -804,7 +814,7 @@ static void TRANSFORM_OT_tosphere(struct wmOperatorType *ot)
RNA_def_float_factor(ot->srna, "value", 0, 0, 1, "Factor", "", 0, 1);
- Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_GPENCIL_EDIT);
+ Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_GPENCIL_EDIT | P_CENTER);
}
static void TRANSFORM_OT_mirror(struct wmOperatorType *ot)
@@ -822,7 +832,7 @@ static void TRANSFORM_OT_mirror(struct wmOperatorType *ot)
ot->cancel = transform_cancel;
ot->poll = ED_operator_screenactive;
- Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL | P_GPENCIL_EDIT);
+ Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL | P_GPENCIL_EDIT | P_CENTER);
}
static void TRANSFORM_OT_edge_slide(struct wmOperatorType *ot)
@@ -985,7 +995,8 @@ static void TRANSFORM_OT_transform(struct wmOperatorType *ot)
RNA_def_float_vector(ot->srna, "value", 4, NULL, -FLT_MAX, FLT_MAX, "Values", "", -FLT_MAX, FLT_MAX);
- Transform_Properties(ot, P_AXIS | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_ALIGN_SNAP | P_GPENCIL_EDIT);
+ Transform_Properties(
+ ot, P_AXIS | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_ALIGN_SNAP | P_GPENCIL_EDIT | P_CENTER);
}
void transform_operatortypes(void)
@@ -1050,6 +1061,8 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac
kmi = WM_keymap_add_item(keymap, "WM_OT_context_menu_enum", TABKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
RNA_string_set(kmi->ptr, "data_path", "tool_settings.snap_element");
+ /* Will fall-through to texture-space transform. */
+ kmi = WM_keymap_add_item(keymap, "OBJECT_OT_transform_axis_target", TKEY, KM_PRESS, KM_SHIFT, 0);
kmi = WM_keymap_add_item(keymap, OP_TRANSLATION, TKEY, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "texture_space", true);
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index c0db83ffa5e..e91db762eb1 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -581,7 +581,7 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3
SceneLayer *sl = CTX_data_scene_layer(C);
Object *obedit = CTX_data_edit_object(C);
Base *base;
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
int result = ORIENTATION_NONE;
const bool activeOnly = (around == V3D_AROUND_ACTIVE);
@@ -809,15 +809,21 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3
else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
Curve *cu = obedit->data;
Nurb *nu = NULL;
- BezTriple *bezt = NULL;
int a;
ListBase *nurbs = BKE_curve_editNurbs_get(cu);
- if (activeOnly && BKE_curve_nurb_vert_active_get(cu, &nu, (void *)&bezt)) {
+ void *vert_act = NULL;
+ if (activeOnly && BKE_curve_nurb_vert_active_get(cu, &nu, &vert_act)) {
if (nu->type == CU_BEZIER) {
+ BezTriple *bezt = vert_act;
BKE_nurb_bezt_calc_normal(nu, bezt, normal);
BKE_nurb_bezt_calc_plane(nu, bezt, plane);
}
+ else {
+ BPoint *bp = vert_act;
+ BKE_nurb_bpoint_calc_normal(nu, bp, normal);
+ BKE_nurb_bpoint_calc_plane(nu, bp, plane);
+ }
}
else {
const bool use_handle = (cu->drawflag & CU_HIDE_HANDLES) == 0;
@@ -825,7 +831,7 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3
for (nu = nurbs->first; nu; nu = nu->next) {
/* only bezier has a normal */
if (nu->type == CU_BEZIER) {
- bezt = nu->bezt;
+ BezTriple *bezt = nu->bezt;
a = nu->pntsu;
while (a--) {
short flag = 0;
@@ -877,6 +883,36 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3
bezt++;
}
}
+ else if (nu->bp && (nu->pntsv == 1)) {
+ BPoint *bp = nu->bp;
+ a = nu->pntsu;
+ while (a--) {
+ if (bp->f1 & SELECT) {
+ float tvec[3];
+
+ BPoint *bp_prev = BKE_nurb_bpoint_get_prev(nu, bp);
+ BPoint *bp_next = BKE_nurb_bpoint_get_next(nu, bp);
+
+ const bool is_prev_sel = bp_prev && (bp_prev->f1 & SELECT);
+ const bool is_next_sel = bp_next && (bp_next->f1 & SELECT);
+ if (is_prev_sel == false && is_next_sel == false) {
+ /* Isolated, add based on surrounding */
+ BKE_nurb_bpoint_calc_normal(nu, bp, tvec);
+ add_v3_v3(normal, tvec);
+ }
+ else if (is_next_sel) {
+ /* A segment, add the edge normal */
+ sub_v3_v3v3(tvec, bp->vec, bp_next->vec );
+ normalize_v3(tvec);
+ add_v3_v3(normal, tvec);
+ }
+
+ BKE_nurb_bpoint_calc_plane(nu, bp, tvec);
+ add_v3_v3(plane, tvec);
+ }
+ bp++;
+ }
+ }
}
}
@@ -1008,8 +1044,8 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3
}
else {
/* we need the one selected object, if its not active */
- base = BASACT_NEW;
- ob = OBACT_NEW;
+ base = BASACT_NEW(sl);
+ ob = OBACT_NEW(sl);
if (base && ((base->flag & BASE_SELECTED) != 0)) {
/* pass */
}
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index 1181f584313..e3ea8a51c6d 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -1001,7 +1001,7 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
float dist_px = SNAP_MIN_DISTANCE; // Use a user defined value here
char node_border;
- if (snapNodesTransform(t, t->mval, t->tsnap.modeSelect, loc, &dist_px, &node_border)) {
+ if (snapNodesTransform(t, t->mval, loc, &dist_px, &node_border)) {
copy_v2_v2(t->tsnap.snapPoint, loc);
t->tsnap.snapNodeBorder = node_border;
@@ -1397,22 +1397,11 @@ static bool snapNodes(
}
bool snapNodesTransform(
- TransInfo *t, const int mval[2], SnapSelect snap_select,
+ TransInfo *t, const int mval[2],
float r_loc[2], float *r_dist_px, char *r_node_border)
{
return snapNodes(
- t->settings, t->sa->spacedata.first, t->ar, mval, snap_select,
- r_loc, r_dist_px, r_node_border);
-}
-
-bool snapNodesContext(
- bContext *C, const int mval[2], SnapSelect snap_select,
- float r_loc[2], float *r_dist_px, char *r_node_border)
-{
- Scene *scene = CTX_data_scene(C);
- ARegion *ar = CTX_wm_region(C);
- return snapNodes(
- scene->toolsettings, CTX_wm_space_node(C), ar, mval, snap_select,
+ t->settings, t->sa->spacedata.first, t->ar, mval, t->tsnap.modeSelect,
r_loc, r_dist_px, r_node_border);
}
@@ -1462,7 +1451,7 @@ void snapSequenceBounds(TransInfo *t, const int mval[2])
/* convert to frame range */
UI_view2d_region_to_view(&t->ar->v2d, mval[0], mval[1], &xmouse, &ymouse);
- mframe = iroundf(xmouse);
+ mframe = round_fl_to_int(xmouse);
/* now find the closest sequence */
frame = BKE_sequencer_find_next_prev_edit(t->scene, mframe, SEQ_SIDE_BOTH, true, false, true);
diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c
index cd33e18ce3e..e72bfa40480 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -51,6 +51,9 @@
#include "BKE_editmesh.h"
#include "BKE_main.h"
#include "BKE_tracking.h"
+#include "BKE_context.h"
+
+#include "DEG_depsgraph.h"
#include "ED_transform.h"
#include "ED_transform_snap_object_context.h"
@@ -101,7 +104,8 @@ typedef struct SnapObjectData_EditMesh {
struct SnapObjectContext {
Main *bmain;
Scene *scene;
- SceneLayer *scene_layer;
+ EvaluationContext eval_ctx;
+
int flag;
/* Optional: when performing screen-space projection.
@@ -131,18 +135,149 @@ struct SnapObjectContext {
};
-static int dm_looptri_to_poly_index(DerivedMesh *dm, const MLoopTri *lt);
+/** \} */
/* -------------------------------------------------------------------- */
-/** \name Support for storing all depths, not just the first (raycast 'all')
+/** Common utilities
+* \{ */
+
+
+typedef void(*IterSnapObjsCallback)(SnapObjectContext *sctx, bool is_obedit, Object *ob, float obmat[4][4], void *data);
+
+/**
+ * Walks through all objects in the scene to create the list of objets to snap.
*
- * This uses a list of #SnapObjectHitDepth structs.
+ * \param sctx: Snap context to store data.
+ * \param snap_select : from enum SnapSelect.
+ * \param obedit : Object Edited to use its coordinates of BMesh(if any) to do the snapping.
+ */
+static void iter_snap_objects(
+ SnapObjectContext *sctx,
+ const SnapSelect snap_select,
+ Object *obedit,
+ IterSnapObjsCallback sob_callback,
+ void *data)
+{
+ Base *base_act = sctx->eval_ctx.scene_layer->basact;
+ /* Need an exception for particle edit because the base is flagged with BA_HAS_RECALC_DATA
+ * which makes the loop skip it, even the derived mesh will never change
+ *
+ * To solve that problem, we do it first as an exception.
+ * */
+ if (base_act && base_act->object && base_act->object->mode & OB_MODE_PARTICLE_EDIT) {
+ sob_callback(sctx, false, base_act->object, base_act->object->obmat, data);
+ }
+
+ for (Base *base = sctx->eval_ctx.scene_layer->object_bases.first; base != NULL; base = base->next) {
+ if ((BASE_VISIBLE_NEW(base)) && (base->flag_legacy & (BA_HAS_RECALC_OB | BA_HAS_RECALC_DATA)) == 0 &&
+ !((snap_select == SNAP_NOT_SELECTED && ((base->flag & BASE_SELECTED) || (base->flag_legacy & BA_WAS_SEL))) ||
+ (snap_select == SNAP_NOT_ACTIVE && base == base_act)))
+ {
+ bool use_obedit;
+ Object *obj = base->object;
+ if (obj->transflag & OB_DUPLI) {
+ DupliObject *dupli_ob;
+ ListBase *lb = object_duplilist(&sctx->eval_ctx, sctx->scene, obj);
+ for (dupli_ob = lb->first; dupli_ob; dupli_ob = dupli_ob->next) {
+ use_obedit = obedit && dupli_ob->ob->data == obedit->data;
+ sob_callback(sctx, use_obedit, use_obedit ? obedit : dupli_ob->ob, dupli_ob->mat, data);
+ }
+ free_object_duplilist(lb);
+ }
+
+ use_obedit = obedit && obj->data == obedit->data;
+ sob_callback(sctx, use_obedit, use_obedit ? obedit : obj, obj->obmat, data);
+ }
+ }
+}
+
+
+/**
+ * Generates a struct with the immutable parameters that will be used on all objects.
*
- * \{ */
+ * \param snap_to: Element to snap, Vertice, Edge or Face.
+ * \param view_proj: ORTHO or PERSP.
+ * Currently only works one at a time, but can eventually operate as flag.
+ *
+ * \param mval: Mouse coords.
+ * (When NULL, ray-casting is handled without any projection matrix correction.)
+ * \param ray_origin: ray_start before being moved toward the ray_normal at the distance from vew3d clip_min.
+ * \param ray_start: ray_origin moved for the start clipping plane (clip_min).
+ * \param ray_direction: Unit length direction of the ray.
+ * \param depth_range: distances of clipe plane min and clip plane max;
+ */
+static void snap_data_set(
+ SnapData *snapdata,
+ const ARegion *ar, const unsigned short snap_to, const enum eViewProj view_proj,
+ const float mval[2], const float ray_origin[3], const float ray_start[3],
+ const float ray_direction[3], const float depth_range[2])
+{
+ copy_m4_m4(snapdata->pmat, ((RegionView3D *)ar->regiondata)->persmat);
+ snapdata->win_half[0] = ar->winx / 2;
+ snapdata->win_half[1] = ar->winy / 2;
+ copy_v2_v2(snapdata->mval, mval);
+ snapdata->snap_to = snap_to;
+ copy_v3_v3(snapdata->ray_origin, ray_origin);
+ copy_v3_v3(snapdata->ray_start, ray_start);
+ copy_v3_v3(snapdata->ray_dir, ray_direction);
+ snapdata->view_proj = view_proj;
+ copy_v2_v2(snapdata->depth_range, depth_range);
+}
+
+
+MINLINE float depth_get(const float co[3], const float ray_start[3], const float ray_dir[3])
+{
+ float dvec[3];
+ sub_v3_v3v3(dvec, co, ray_start);
+ return dot_v3v3(dvec, ray_dir);
+}
+
+
+static bool walk_parent_bvhroot_cb(const BVHTreeAxisRange *bounds, void *userdata)
+{
+ BVHTreeRay *ray = userdata;
+ const float bbmin[3] = {bounds[0].min, bounds[1].min, bounds[2].min};
+ const float bbmax[3] = {bounds[0].max, bounds[1].max, bounds[2].max};
+ if (!isect_ray_aabb_v3_simple(ray->origin, ray->direction, bbmin, bbmax, &ray->radius, NULL)) {
+ ray->radius = -1;
+ }
+ return false;
+}
+
+
+static bool isect_ray_bvhroot_v3(struct BVHTree *tree, const float ray_start[3], const float ray_dir[3], float *depth)
+{
+ BVHTreeRay ray;
+ copy_v3_v3(ray.origin, ray_start);
+ copy_v3_v3(ray.direction, ray_dir);
+
+ BLI_bvhtree_walk_dfs(tree, walk_parent_bvhroot_cb, NULL, NULL, &ray);
+
+ if (ray.radius > 0) {
+ *depth = ray.radius;
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
+
+static int dm_looptri_to_poly_index(DerivedMesh *dm, const MLoopTri *lt);
+
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+
+/** \name Ray Cast Funcs
+* \{ */
+
+/* Store all ray-hits
+ * Support for storing all depths, not just the first (raycast 'all') */
-/* Store all ray-hits */
struct RayCastAll_Data {
void *bvhdata;
@@ -163,6 +298,7 @@ struct RayCastAll_Data {
bool retval;
};
+
static struct SnapObjectHitDepth *hit_depth_create(
const float depth, const float co[3], const float no[3], int index,
Object *ob, const float obmat[4][4], unsigned int ob_uuid)
@@ -230,57 +366,501 @@ static void raycast_all_cb(void *userdata, int index, const BVHTreeRay *ray, BVH
}
}
-/** \} */
+static bool raycastDerivedMesh(
+ SnapObjectContext *sctx,
+ const float ray_start[3], const float ray_dir[3],
+ Object *ob, DerivedMesh *dm, float obmat[4][4], const unsigned int ob_index,
+ /* read/write args */
+ float *ray_depth,
+ /* return args */
+ float r_loc[3], float r_no[3], int *r_index,
+ ListBase *r_hit_list)
+{
+ bool retval = false;
-/* -------------------------------------------------------------------- */
+ if (dm->getNumPolys(dm) == 0) {
+ return retval;
+ }
+
+ float imat[4][4];
+ float timat[3][3]; /* transpose inverse matrix for normals */
+ float ray_start_local[3], ray_normal_local[3];
+ float local_scale, local_depth, len_diff = 0.0f;
+
+ invert_m4_m4(imat, obmat);
+ transpose_m3_m4(timat, imat);
+
+ copy_v3_v3(ray_start_local, ray_start);
+ copy_v3_v3(ray_normal_local, ray_dir);
+
+ mul_m4_v3(imat, ray_start_local);
+ mul_mat3_m4_v3(imat, ray_normal_local);
+
+ /* local scale in normal direction */
+ local_scale = normalize_v3(ray_normal_local);
+ local_depth = *ray_depth;
+ if (local_depth != BVH_RAYCAST_DIST_MAX) {
+ local_depth *= local_scale;
+ }
+
+ /* Test BoundBox */
+ BoundBox *bb = BKE_object_boundbox_get(ob);
+ if (bb) {
+ /* was BKE_boundbox_ray_hit_check, see: cf6ca226fa58 */
+ if (!isect_ray_aabb_v3_simple(
+ ray_start_local, ray_normal_local, bb->vec[0], bb->vec[6], &len_diff, NULL))
+ {
+ return retval;
+ }
+ }
+
+ SnapObjectData_Mesh *sod = NULL;
+ BVHTreeFromMesh *treedata;
+
+ void **sod_p;
+ if (BLI_ghash_ensure_p(sctx->cache.object_map, ob, &sod_p)) {
+ sod = *sod_p;
+ }
+ else {
+ sod = *sod_p = BLI_memarena_calloc(sctx->cache.mem_arena, sizeof(*sod));
+ sod->sd.type = SNAP_MESH;
+ }
+
+ if (sod->bvh_trees[2] == NULL) {
+ sod->bvh_trees[2] = BLI_memarena_calloc(sctx->cache.mem_arena, sizeof(*treedata));
+ }
+
+ treedata = sod->bvh_trees[2];
+
+ if (treedata) {
+ /* the tree is owned by the DM and may have been freed since we last used! */
+ if (treedata->tree) {
+ if (treedata->cached && !bvhcache_has_tree(dm->bvhCache, treedata->tree)) {
+ free_bvhtree_from_mesh(treedata);
+ }
+ else {
+ if (treedata->vert == NULL) {
+ treedata->vert = DM_get_vert_array(dm, &treedata->vert_allocated);
+ }
+ if (treedata->loop == NULL) {
+ treedata->loop = DM_get_loop_array(dm, &treedata->loop_allocated);
+ }
+ if (treedata->looptri == NULL) {
+ if (sod->mpoly == NULL) {
+ sod->mpoly = DM_get_poly_array(dm, &sod->poly_allocated);
+ }
+ treedata->looptri = dm->getLoopTriArray(dm);
+ treedata->looptri_allocated = false;
+ }
+ }
+ }
+
+ if (treedata->tree == NULL) {
+ bvhtree_from_mesh_looptri(treedata, dm, 0.0f, 4, 6);
+
+ if (treedata->tree == NULL) {
+ return retval;
+ }
+ }
+ }
+ else {
+ return retval;
+ }
+
+ /* Only use closer ray_start in case of ortho view! In perspective one, ray_start may already
+ * been *inside* boundbox, leading to snap failures (see T38409).
+ * Note also ar might be null (see T38435), in this case we assume ray_start is ok!
+ */
+ if (len_diff == 0.0f) { /* do_ray_start_correction */
+ /* We *need* a reasonably valid len_diff in this case.
+ * Get the distance to bvhtree root */
+ if (!isect_ray_bvhroot_v3(treedata->tree, ray_start_local, ray_normal_local, &len_diff)) {
+ return retval;
+ }
+ }
+ /* You need to make sure that ray_start is really far away,
+ * because even in the Orthografic view, in some cases,
+ * the ray can start inside the object (see T50486) */
+ if (len_diff > 400.0f) {
+ /* We pass a temp ray_start, set from object's boundbox, to avoid precision issues with
+ * very far away ray_start values (as returned in case of ortho view3d), see T38358.
+ */
+ len_diff -= local_scale; /* make temp start point a bit away from bbox hit point. */
+ madd_v3_v3fl(ray_start_local, ray_normal_local, len_diff);
+ local_depth -= len_diff;
+ }
+ else {
+ len_diff = 0.0f;
+ }
+ if (r_hit_list) {
+ struct RayCastAll_Data data;
+
+ data.bvhdata = treedata;
+ data.raycast_callback = treedata->raycast_callback;
+ data.obmat = obmat;
+ data.timat = timat;
+ data.len_diff = len_diff;
+ data.local_scale = local_scale;
+ data.ob = ob;
+ data.ob_uuid = ob_index;
+ data.hit_list = r_hit_list;
+ data.retval = retval;
+
+ BLI_bvhtree_ray_cast_all(
+ treedata->tree, ray_start_local, ray_normal_local, 0.0f,
+ *ray_depth, raycast_all_cb, &data);
+
+ retval = data.retval;
+ }
+ else {
+ BVHTreeRayHit hit = {.index = -1, .dist = local_depth};
+
+ if (BLI_bvhtree_ray_cast(
+ treedata->tree, ray_start_local, ray_normal_local, 0.0f,
+ &hit, treedata->raycast_callback, treedata) != -1)
+ {
+ hit.dist += len_diff;
+ hit.dist /= local_scale;
+ if (hit.dist <= *ray_depth) {
+ *ray_depth = hit.dist;
+ copy_v3_v3(r_loc, hit.co);
+
+ /* back to worldspace */
+ mul_m4_v3(obmat, r_loc);
+
+ if (r_no) {
+ copy_v3_v3(r_no, hit.no);
+ mul_m3_v3(timat, r_no);
+ normalize_v3(r_no);
+ }
+
+ retval = true;
+
+ if (r_index) {
+ *r_index = dm_looptri_to_poly_index(dm, &treedata->looptri[hit.index]);
+ }
+ }
+ }
+ }
+
+ return retval;
+}
+
+static bool raycastEditMesh(
+ SnapObjectContext *sctx,
+ const float ray_start[3], const float ray_dir[3],
+ Object *ob, BMEditMesh *em, float obmat[4][4], const unsigned int ob_index,
+ /* read/write args */
+ float *ray_depth,
+ /* return args */
+ float r_loc[3], float r_no[3], int *r_index,
+ ListBase *r_hit_list)
+{
+ bool retval = false;
+ if (em->bm->totface == 0) {
+ return retval;
+ }
+
+ SnapObjectData_EditMesh *sod = NULL;
+ BVHTreeFromEditMesh *treedata = NULL;
+
+ void **sod_p;
+ if (BLI_ghash_ensure_p(sctx->cache.object_map, ob, &sod_p)) {
+ sod = *sod_p;
+ }
+ else {
+ sod = *sod_p = BLI_memarena_calloc(sctx->cache.mem_arena, sizeof(*sod));
+ sod->sd.type = SNAP_EDIT_MESH;
+ }
+
+ if (sod->bvh_trees[2] == NULL) {
+ sod->bvh_trees[2] = BLI_memarena_calloc(sctx->cache.mem_arena, sizeof(*treedata));
+ }
+ treedata = sod->bvh_trees[2];
+
+ if (treedata) {
+ if (treedata->tree == NULL) {
+ BLI_bitmap *elem_mask = NULL;
+ int looptri_num_active = -1;
+
+ if (sctx->callbacks.edit_mesh.test_face_fn) {
+ elem_mask = BLI_BITMAP_NEW(em->tottri, __func__);
+ looptri_num_active = BM_iter_mesh_bitmap_from_filter_tessface(
+ em->bm, elem_mask,
+ sctx->callbacks.edit_mesh.test_face_fn, sctx->callbacks.edit_mesh.user_data);
+ }
+ bvhtree_from_editmesh_looptri_ex(treedata, em, elem_mask, looptri_num_active, 0.0f, 4, 6, NULL);
+
+ if (elem_mask) {
+ MEM_freeN(elem_mask);
+ }
+ }
+ if (treedata->tree == NULL) {
+ return retval;
+ }
+ }
+ else {
+ return retval;
+ }
+
+ float imat[4][4];
+ float timat[3][3]; /* transpose inverse matrix for normals */
+ float ray_normal_local[3], ray_start_local[3], len_diff = 0.0f;
+
+ invert_m4_m4(imat, obmat);
+ transpose_m3_m4(timat, imat);
+
+ copy_v3_v3(ray_normal_local, ray_dir);
+ mul_mat3_m4_v3(imat, ray_normal_local);
+
+ copy_v3_v3(ray_start_local, ray_start);
+ mul_m4_v3(imat, ray_start_local);
+
+ /* local scale in normal direction */
+ float local_scale = normalize_v3(ray_normal_local);
+ float local_depth = *ray_depth;
+ if (local_depth != BVH_RAYCAST_DIST_MAX) {
+ local_depth *= local_scale;
+ }
+
+ /* Only use closer ray_start in case of ortho view! In perspective one, ray_start
+ * may already been *inside* boundbox, leading to snap failures (see T38409).
+ * Note also ar might be null (see T38435), in this case we assume ray_start is ok!
+ */
+ if (sctx->use_v3d && !((RegionView3D *)sctx->v3d_data.ar->regiondata)->is_persp) { /* do_ray_start_correction */
+ /* We *need* a reasonably valid len_diff in this case.
+ * Get the distance to bvhtree root */
+ if (!isect_ray_bvhroot_v3(treedata->tree, ray_start_local, ray_normal_local, &len_diff)) {
+ return retval;
+ }
+ /* You need to make sure that ray_start is really far away,
+ * because even in the Orthografic view, in some cases,
+ * the ray can start inside the object (see T50486) */
+ if (len_diff > 400.0f) {
+ /* We pass a temp ray_start, set from object's boundbox, to avoid precision issues with
+ * very far away ray_start values (as returned in case of ortho view3d), see T38358.
+ */
+ len_diff -= local_scale; /* make temp start point a bit away from bbox hit point. */
+ madd_v3_v3fl(ray_start_local, ray_normal_local, len_diff);
+ local_depth -= len_diff;
+ }
+ else len_diff = 0.0f;
+ }
+ if (r_hit_list) {
+ struct RayCastAll_Data data;
+
+ data.bvhdata = treedata;
+ data.raycast_callback = treedata->raycast_callback;
+ data.obmat = obmat;
+ data.timat = timat;
+ data.len_diff = len_diff;
+ data.local_scale = local_scale;
+ data.ob = ob;
+ data.ob_uuid = ob_index;
+ data.hit_list = r_hit_list;
+ data.retval = retval;
+
+ BLI_bvhtree_ray_cast_all(
+ treedata->tree, ray_start_local, ray_normal_local, 0.0f,
+ *ray_depth, raycast_all_cb, &data);
+
+ retval = data.retval;
+ }
+ else {
+ BVHTreeRayHit hit = {.index = -1, .dist = local_depth};
+
+ if (BLI_bvhtree_ray_cast(
+ treedata->tree, ray_start_local, ray_normal_local, 0.0f,
+ &hit, treedata->raycast_callback, treedata) != -1)
+ {
+ hit.dist += len_diff;
+ hit.dist /= local_scale;
+ if (hit.dist <= *ray_depth) {
+ *ray_depth = hit.dist;
+ copy_v3_v3(r_loc, hit.co);
+
+ /* back to worldspace */
+ mul_m4_v3(obmat, r_loc);
+
+ if (r_no) {
+ copy_v3_v3(r_no, hit.no);
+ mul_m3_v3(timat, r_no);
+ normalize_v3(r_no);
+ }
+
+ retval = true;
+
+ if (r_index) {
+ *r_index = hit.index;
+ }
+ }
+ }
+ }
+
+ return retval;
+}
-/** Common utilities
- * \{ */
/**
- * Generates a struct with the immutable parameters that will be used on all objects.
- *
- * \param snap_to: Element to snap, Vertice, Edge or Face.
- * \param view_proj: ORTHO or PERSP.
- * Currently only works one at a time, but can eventually operate as flag.
+ * \param use_obedit: Uses the coordinates of BMesh (if any) to do the snapping;
*
- * \param mval: Mouse coords.
- * (When NULL, ray-casting is handled without any projection matrix correction.)
- * \param ray_origin: ray_start before being moved toward the ray_normal at the distance from vew3d clip_min.
- * \param ray_start: ray_origin moved for the start clipping plane (clip_min).
- * \param ray_direction: Unit length direction of the ray.
- * \param depth_range: distances of clipe plane min and clip plane max;
+ * \note Duplicate args here are documented at #snapObjectsRay
*/
-static void snap_data_set(
- SnapData *snapdata,
- const ARegion *ar, const unsigned short snap_to, const enum eViewProj view_proj,
- const float mval[2], const float ray_origin[3], const float ray_start[3],
- const float ray_direction[3], const float depth_range[2])
+static bool raycastObj(
+ SnapObjectContext *sctx,
+ const float ray_start[3], const float ray_dir[3],
+ Object *ob, float obmat[4][4], const unsigned int ob_index,
+ bool use_obedit,
+ /* read/write args */
+ float *ray_depth,
+ /* return args */
+ float r_loc[3], float r_no[3], int *r_index,
+ Object **r_ob, float r_obmat[4][4],
+ ListBase *r_hit_list)
{
- if (ar) {
- copy_m4_m4(snapdata->pmat, ((RegionView3D *)ar->regiondata)->persmat);
- snapdata->win_half[0] = ar->winx / 2;
- snapdata->win_half[1] = ar->winy / 2;
+ bool retval = false;
+
+ if (ob->type == OB_MESH) {
+ BMEditMesh *em;
+
+ if (use_obedit) {
+ em = BKE_editmesh_from_object(ob);
+ retval = raycastEditMesh(
+ sctx,
+ ray_start, ray_dir,
+ ob, em, obmat, ob_index,
+ ray_depth, r_loc, r_no, r_index, r_hit_list);
+ }
+ else {
+ /* in this case we want the mesh from the editmesh, avoids stale data. see: T45978.
+ * still set the 'em' to NULL, since we only want the 'dm'. */
+ DerivedMesh *dm;
+ em = BKE_editmesh_from_object(ob);
+ if (em) {
+ editbmesh_get_derived_cage_and_final(&sctx->eval_ctx, sctx->scene, ob, em, CD_MASK_BAREMESH, &dm);
+ }
+ else {
+ dm = mesh_get_derived_final(&sctx->eval_ctx, sctx->scene, ob, CD_MASK_BAREMESH);
+ }
+ retval = raycastDerivedMesh(
+ sctx,
+ ray_start, ray_dir,
+ ob, dm, obmat, ob_index,
+ ray_depth, r_loc, r_no, r_index, r_hit_list);
+ }
}
- if (mval) {
- copy_v2_v2(snapdata->mval, mval);
+
+ if (retval) {
+ if (r_ob) {
+ *r_ob = ob;
+ copy_m4_m4(r_obmat, obmat);
+ }
}
- snapdata->snap_to = snap_to;
- copy_v3_v3(snapdata->ray_origin, ray_origin);
- copy_v3_v3(snapdata->ray_start, ray_start);
- copy_v3_v3(snapdata->ray_dir, ray_direction);
- snapdata->view_proj = view_proj;
- copy_v2_v2(snapdata->depth_range, depth_range);
+
+ return retval;
}
-MINLINE float depth_get(const float co[3], const float ray_start[3], const float ray_dir[3])
+
+struct RaycastObjUserData {
+ const float *ray_start;
+ const float *ray_dir;
+ unsigned int ob_index;
+ /* read/write args */
+ float *ray_depth;
+ /* return args */
+ float *r_loc;
+ float *r_no;
+ int *r_index;
+ Object **r_ob;
+ float (*r_obmat)[4];
+ ListBase *r_hit_list;
+ bool ret;
+};
+
+static void raycast_obj_cb(SnapObjectContext *sctx, bool is_obedit, Object *ob, float obmat[4][4], void *data)
{
- float dvec[3];
- sub_v3_v3v3(dvec, co, ray_start);
- return dot_v3v3(dvec, ray_dir);
+ struct RaycastObjUserData *dt = data;
+ dt->ret |= raycastObj(
+ sctx,
+ dt->ray_start, dt->ray_dir,
+ ob, obmat, dt->ob_index++, is_obedit,
+ dt->ray_depth,
+ dt->r_loc, dt->r_no, dt->r_index,
+ dt->r_ob, dt->r_obmat,
+ dt->r_hit_list);
+}
+
+/**
+ * Main RayCast Function
+ * ======================
+ *
+ * Walks through all objects in the scene to find the `hit` on object surface.
+ *
+ * \param sctx: Snap context to store data.
+ * \param snapdata: struct generated in `set_snapdata`.
+ * \param snap_select : from enum SnapSelect.
+ * \param use_object_edit_cage : Uses the coordinates of BMesh(if any) to do the snapping.
+ * \param obj_list: List with objects to snap (created in `create_object_list`).
+ *
+ * Read/Write Args
+ * ---------------
+ *
+ * \param ray_depth: maximum depth allowed for r_co, elements deeper than this value will be ignored.
+ *
+ * Output Args
+ * -----------
+ *
+ * \param r_loc: Hit location.
+ * \param r_no: Hit normal (optional).
+ * \param r_index: Hit index or -1 when no valid index is found.
+ * (currently only set to the polygon index when when using ``snap_to == SCE_SNAP_MODE_FACE``).
+ * \param r_ob: Hit object.
+ * \param r_obmat: Object matrix (may not be #Object.obmat with dupli-instances).
+ * \param r_hit_list: List of #SnapObjectHitDepth (caller must free).
+ *
+ */
+static bool raycastObjects(
+ SnapObjectContext *sctx,
+ const float ray_start[3], const float ray_dir[3],
+ const SnapSelect snap_select, const bool use_object_edit_cage,
+ /* read/write args */
+ float *ray_depth,
+ /* return args */
+ float r_loc[3], float r_no[3], int *r_index,
+ Object **r_ob, float r_obmat[4][4],
+ ListBase *r_hit_list)
+{
+ Object *obedit = use_object_edit_cage ? sctx->scene->obedit : NULL;
+
+ struct RaycastObjUserData data = {
+ .ray_start = ray_start,
+ .ray_dir = ray_dir,
+ .ob_index = 0,
+ .ray_depth = ray_depth,
+ .r_loc = r_loc,
+ .r_no = r_no,
+ .r_index = r_index,
+ .r_ob = r_ob,
+ .r_obmat = r_obmat,
+ .r_hit_list = r_hit_list,
+ .ret = false,
+ };
+
+ iter_snap_objects(sctx, snap_select, obedit, raycast_obj_cb, &data);
+
+ return data.ret;
}
+
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+
+/** Snap Nearest utilities
+ * \{ */
+
static void copy_dm_vert_no(const int index, float r_no[3], const BVHTreeFromMesh *data)
{
const MVert *vert = data->vert + index;
@@ -489,36 +1069,20 @@ static float dist_squared_to_projected_aabb(
main_axis += 3;
}
- /* if rtmin < rtmax, ray intersect `AABB` */
- if (rtmin <= rtmax) {
#define IGNORE_BEHIND_RAY
#ifdef IGNORE_BEHIND_RAY
- /* `if rtmax < depth_min`, the hit is behind us */
- if (rtmax < data->ray_min_dist) {
- /* Test if the entire AABB is behind us */
- float depth = depth_get(
- local_bvmax, data->ray_origin_local, data->ray_direction_local);
- if (depth < (data->ray_min_dist)) {
- return FLT_MAX;
- }
- }
-#endif
- const float proj = rtmin * data->ray_direction_local[main_axis];
- r_axis_closest[main_axis] = (proj - va[main_axis]) < (vb[main_axis] - proj);
- return 0.0f;
- }
-#ifdef IGNORE_BEHIND_RAY
- /* `if rtmin < depth_min`, the hit is behing us */
- else if (rtmin < data->ray_min_dist) {
- /* Test if the entire AABB is behind us */
- float depth = depth_get(
- local_bvmax, data->ray_origin_local, data->ray_direction_local);
- if (depth < (data->ray_min_dist)) {
- return FLT_MAX;
- }
+ float depth_max = depth_get(local_bvmax, data->ray_origin_local, data->ray_direction_local);
+ if (depth_max < data->ray_min_dist) {
+ return FLT_MAX;
}
#endif
#undef IGNORE_BEHIND_RAY
+
+ /* if rtmin <= rtmax, ray intersect `AABB` */
+ if (rtmin <= rtmax) {
+ return 0;
+ }
+
if (data->sign[main_axis]) {
va[main_axis] = local_bvmax[main_axis];
vb[main_axis] = local_bvmin[main_axis];
@@ -559,15 +1123,12 @@ static float dist_squared_to_projected_aabb(
vb2d[0] *= data->win_half[0];
vb2d[1] *= data->win_half[1];
- //float dvec[2], edge[2], rdist;
- //sub_v2_v2v2(dvec, data->mval, va2d);
- //sub_v2_v2v2(edge, vb2d, va2d);
- float rdist;
- short dvec[2] = {data->mval[0] - va2d[0], data->mval[1] - va2d[1]};
- short edge[2] = {vb2d[0] - va2d[0], vb2d[1] - va2d[1]};
- float lambda = dvec[0] * edge[0] + dvec[1] * edge[1];
+ float dvec[2], edge[2], lambda, rdist;
+ sub_v2_v2v2(dvec, data->mval, va2d);
+ sub_v2_v2v2(edge, vb2d, va2d);
+ lambda = dot_v2v2(dvec, edge);
if (lambda != 0.0f) {
- lambda /= edge[0] * edge[0] + edge[1] * edge[1];
+ lambda /= len_squared_v2(edge);
if (lambda <= 0.0f) {
rdist = len_squared_v2v2(data->mval, va2d);
r_axis_closest[main_axis] = true;
@@ -604,18 +1165,6 @@ static float dist_squared_to_projected_aabb_simple(
return dist_squared_to_projected_aabb(&data, bbmin, bbmax, dummy);
}
-static float dist_aabb_to_plane(
- const float bbmin[3], const float bbmax[3],
- const float plane_co[3], const float plane_no[3])
-{
- const float local_bvmin[3] = {
- (plane_no[0] < 0) ? bbmax[0] : bbmin[0],
- (plane_no[1] < 0) ? bbmax[1] : bbmin[1],
- (plane_no[2] < 0) ? bbmax[2] : bbmin[2],
- };
- return depth_get(local_bvmin, plane_co, plane_no);
-}
-
/** \} */
@@ -1054,21 +1603,15 @@ static int dm_looptri_to_poly_index(DerivedMesh *dm, const MLoopTri *lt)
static bool snapDerivedMesh(
SnapObjectContext *sctx, SnapData *snapdata,
- Object *ob, DerivedMesh *dm, float obmat[4][4], const unsigned int ob_index,
+ Object *ob, DerivedMesh *dm, float obmat[4][4],
/* read/write args */
float *ray_depth, float *dist_px,
/* return args */
- float r_loc[3], float r_no[3], int *r_index,
- ListBase *r_hit_list)
+ float r_loc[3], float r_no[3])
{
bool retval = false;
- if (snapdata->snap_to == SCE_SNAP_MODE_FACE) {
- if (dm->getNumPolys(dm) == 0) {
- return retval;
- }
- }
- else if (snapdata->snap_to == SCE_SNAP_MODE_EDGE) {
+ if (snapdata->snap_to == SCE_SNAP_MODE_EDGE) {
if (dm->getNumEdges(dm) == 0) {
return retval;
}
@@ -1079,38 +1622,27 @@ static bool snapDerivedMesh(
}
}
- bool need_ray_start_correction_init =
- (snapdata->snap_to == SCE_SNAP_MODE_FACE) &&
- (snapdata->view_proj == VIEW_PROJ_ORTHO);
-
float imat[4][4];
float timat[3][3]; /* transpose inverse matrix for normals */
- float ray_start_local[3], ray_normal_local[3];
- float local_scale, local_depth, len_diff;
+ float ray_normal_local[3];
+ float local_scale;
invert_m4_m4(imat, obmat);
transpose_m3_m4(timat, imat);
- copy_v3_v3(ray_start_local, snapdata->ray_start);
copy_v3_v3(ray_normal_local, snapdata->ray_dir);
- mul_m4_v3(imat, ray_start_local);
mul_mat3_m4_v3(imat, ray_normal_local);
/* local scale in normal direction */
local_scale = normalize_v3(ray_normal_local);
- local_depth = *ray_depth;
- if (local_depth != BVH_RAYCAST_DIST_MAX) {
- local_depth *= local_scale;
- }
float lpmat[4][4];
float ray_org_local[3];
float ray_min_dist;
- if (ELEM(snapdata->snap_to, SCE_SNAP_MODE_VERTEX, SCE_SNAP_MODE_EDGE)) {
- mul_m4_m4m4(lpmat, snapdata->pmat, obmat);
- ray_min_dist = snapdata->depth_range[0] * local_scale;
- }
+
+ mul_m4_m4m4(lpmat, snapdata->pmat, obmat);
+ ray_min_dist = snapdata->depth_range[0] * local_scale;
copy_v3_v3(ray_org_local, snapdata->ray_origin);
mul_m4_v3(imat, ray_org_local);
@@ -1119,26 +1651,12 @@ static bool snapDerivedMesh(
BoundBox *bb = BKE_object_boundbox_get(ob);
if (bb) {
/* In vertex and edges you need to get the pixel distance from ray to BoundBox, see: T46099, T46816 */
- if (ELEM(snapdata->snap_to, SCE_SNAP_MODE_VERTEX, SCE_SNAP_MODE_EDGE)) {
- float dist_px_sq = dist_squared_to_projected_aabb_simple(
- lpmat, snapdata->win_half, ray_min_dist, snapdata->mval,
- ray_org_local, ray_normal_local, bb->vec[0], bb->vec[6]);
- if (dist_px_sq > SQUARE(*dist_px)) {
- return retval;
- }
- }
- else {
- /* was BKE_boundbox_ray_hit_check, see: cf6ca226fa58 */
- if (!isect_ray_aabb_v3_simple(
- ray_start_local, ray_normal_local, bb->vec[0], bb->vec[6], NULL, NULL))
- {
- return retval;
- }
+ float dist_px_sq = dist_squared_to_projected_aabb_simple(
+ lpmat, snapdata->win_half, ray_min_dist, snapdata->mval,
+ ray_org_local, ray_normal_local, bb->vec[0], bb->vec[6]);
+ if (dist_px_sq > SQUARE(*dist_px)) {
+ return retval;
}
- /* was local_depth, see: T47838 */
- len_diff = dist_aabb_to_plane(bb->vec[0], bb->vec[6], ray_start_local, ray_normal_local);
- if (len_diff < 0) len_diff = 0.0f;
- need_ray_start_correction_init = false;
}
SnapObjectData_Mesh *sod = NULL;
@@ -1155,9 +1673,6 @@ static bool snapDerivedMesh(
int tree_index = -1;
switch (snapdata->snap_to) {
- case SCE_SNAP_MODE_FACE:
- tree_index = 2;
- break;
case SCE_SNAP_MODE_EDGE:
tree_index = 1;
break;
@@ -1177,183 +1692,75 @@ static bool snapDerivedMesh(
free_bvhtree_from_mesh(treedata);
}
else {
- if (!treedata->vert_allocated) {
+ if (treedata->vert == NULL) {
treedata->vert = DM_get_vert_array(dm, &treedata->vert_allocated);
}
- if ((tree_index == 1) && !treedata->edge_allocated) {
- treedata->edge = DM_get_edge_array(dm, &treedata->vert_allocated);
- }
- if (tree_index == 2) {
- if (!treedata->loop_allocated) {
- treedata->loop = DM_get_loop_array(dm, &treedata->loop_allocated);
- }
- if (!treedata->looptri_allocated) {
- if (!sod->poly_allocated) {
- sod->mpoly = DM_get_poly_array(dm, &sod->poly_allocated);
- }
- treedata->looptri = DM_get_looptri_array(
- dm, treedata->vert,
- sod->mpoly, dm->getNumPolys(dm),
- treedata->loop, dm->getNumLoops(dm),
- &treedata->looptri_allocated);
- }
+ if ((tree_index == 1) && (treedata->edge == NULL)) {
+ treedata->edge = DM_get_edge_array(dm, &treedata->edge_allocated);
}
}
}
}
- if (treedata && treedata->tree == NULL) {
- switch (snapdata->snap_to) {
- case SCE_SNAP_MODE_FACE:
- bvhtree_from_mesh_looptri(treedata, dm, 0.0f, 4, 6);
- break;
- case SCE_SNAP_MODE_EDGE:
- bvhtree_from_mesh_edges(treedata, dm, 0.0f, 2, 6);
- break;
- case SCE_SNAP_MODE_VERTEX:
- bvhtree_from_mesh_verts(treedata, dm, 0.0f, 2, 6);
- break;
+ if (treedata) {
+ if (treedata->tree == NULL) {
+ switch (snapdata->snap_to) {
+ case SCE_SNAP_MODE_EDGE:
+ bvhtree_from_mesh_edges(treedata, dm, 0.0f, 2, 6);
+ break;
+ case SCE_SNAP_MODE_VERTEX:
+ bvhtree_from_mesh_verts(treedata, dm, 0.0f, 2, 6);
+ break;
+ }
+ }
+ if (treedata->tree == NULL) {
+ return retval;
}
}
- if (!treedata || !treedata->tree) {
+ else {
return retval;
}
- if (snapdata->snap_to == SCE_SNAP_MODE_FACE) {
- /* Only use closer ray_start in case of ortho view! In perspective one, ray_start may already
- * been *inside* boundbox, leading to snap failures (see T38409).
- * Note also ar might be null (see T38435), in this case we assume ray_start is ok!
- */
- if (snapdata->view_proj == VIEW_PROJ_ORTHO) { /* do_ray_start_correction */
- if (need_ray_start_correction_init) {
- /* We *need* a reasonably valid len_diff in this case.
- * Use BHVTree to find the closest face from ray_start_local.
- */
- BVHTreeNearest nearest;
- nearest.index = -1;
- nearest.dist_sq = FLT_MAX;
- /* Compute and store result. */
- BLI_bvhtree_find_nearest(
- treedata->tree, ray_start_local, &nearest, treedata->nearest_callback, treedata);
- if (nearest.index != -1) {
- float dvec[3];
- sub_v3_v3v3(dvec, nearest.co, ray_start_local);
- len_diff = dot_v3v3(dvec, ray_normal_local);
- }
- }
- /* You need to make sure that ray_start is really far away,
- * because even in the Orthografic view, in some cases,
- * the ray can start inside the object (see T50486) */
- if (len_diff > 400.0f) {
- /* We pass a temp ray_start, set from object's boundbox, to avoid precision issues with
- * very far away ray_start values (as returned in case of ortho view3d), see T38358.
- */
- len_diff -= local_scale; /* make temp start point a bit away from bbox hit point. */
- madd_v3_v3v3fl(
- ray_start_local, ray_org_local, ray_normal_local,
- len_diff + snapdata->depth_range[0] * local_scale);
- local_depth -= len_diff;
- }
- else len_diff = 0.0f;
- }
- else {
- len_diff = 0.0f;
- }
- if (r_hit_list) {
- struct RayCastAll_Data data;
-
- data.bvhdata = treedata;
- data.raycast_callback = treedata->raycast_callback;
- data.obmat = obmat;
- data.timat = timat;
- data.len_diff = len_diff;
- data.local_scale = local_scale;
- data.ob = ob;
- data.ob_uuid = ob_index;
- data.hit_list = r_hit_list;
- data.retval = retval;
-
- BLI_bvhtree_ray_cast_all(
- treedata->tree, ray_start_local, ray_normal_local, 0.0f,
- *ray_depth, raycast_all_cb, &data);
-
- retval = data.retval;
- }
- else {
- BVHTreeRayHit hit = {.index = -1, .dist = local_depth};
+ /* Warning: the depth_max is currently being used only in perspective view.
+ * It is not correct to limit the maximum depth for elements obtained with nearest
+ * since this limitation depends on the normal and the size of the occlusion face.
+ * And more... ray_depth is being confused with Z-depth here... (varies only the precision) */
+ const float ray_depth_max_global = *ray_depth + snapdata->depth_range[0];
- if (BLI_bvhtree_ray_cast(
- treedata->tree, ray_start_local, ray_normal_local, 0.0f,
- &hit, treedata->raycast_callback, treedata) != -1)
- {
- hit.dist += len_diff;
- hit.dist /= local_scale;
- if (hit.dist <= *ray_depth) {
- *ray_depth = hit.dist;
- copy_v3_v3(r_loc, hit.co);
-
- /* back to worldspace */
- mul_m4_v3(obmat, r_loc);
-
- if (r_no) {
- copy_v3_v3(r_no, hit.no);
- mul_m3_v3(timat, r_no);
- normalize_v3(r_no);
- }
+ Nearest2dUserData neasrest2d = {
+ .dist_px_sq = SQUARE(*dist_px),
+ .r_axis_closest = {1.0f, 1.0f, 1.0f},
+ .depth_range = {snapdata->depth_range[0], ray_depth_max_global},
+ .userdata = treedata,
+ .get_edge_verts = (Nearest2DGetEdgeVertsCallback)get_dm_edge_verts,
+ .copy_vert_no = (Nearest2DCopyVertNoCallback)copy_dm_vert_no,
+ .index = -1};
- retval = true;
+ dist_squared_to_projected_aabb_precalc(
+ &neasrest2d.data_precalc, lpmat,
+ snapdata->view_proj == VIEW_PROJ_PERSP, snapdata->win_half,
+ ray_min_dist, snapdata->mval, ray_org_local, ray_normal_local);
- if (r_index) {
- *r_index = dm_looptri_to_poly_index(dm, &treedata->looptri[hit.index]);
- }
- }
- }
- }
- }
- /* SCE_SNAP_MODE_VERTEX or SCE_SNAP_MODE_EDGE */
- else {
+ BVHTree_WalkLeafCallback cb_walk_leaf =
+ (snapdata->snap_to == SCE_SNAP_MODE_VERTEX) ?
+ cb_walk_leaf_snap_vert : cb_walk_leaf_snap_edge;
- /* Warning: the depth_max is currently being used only in perspective view.
- * It is not correct to limit the maximum depth for elements obtained with nearest
- * since this limitation depends on the normal and the size of the occlusion face.
- * And more... ray_depth is being confused with Z-depth here... (varies only the precision) */
- const float ray_depth_max_global = *ray_depth + snapdata->depth_range[0];
-
- Nearest2dUserData neasrest2d = {
- .dist_px_sq = SQUARE(*dist_px),
- .r_axis_closest = {1.0f, 1.0f, 1.0f},
- .depth_range = {snapdata->depth_range[0], ray_depth_max_global},
- .userdata = treedata,
- .get_edge_verts = (Nearest2DGetEdgeVertsCallback)get_dm_edge_verts,
- .copy_vert_no = (Nearest2DCopyVertNoCallback)copy_dm_vert_no,
- .index = -1};
-
- dist_squared_to_projected_aabb_precalc(
- &neasrest2d.data_precalc, lpmat,
- snapdata->view_proj == VIEW_PROJ_PERSP, snapdata->win_half,
- ray_min_dist, snapdata->mval, ray_org_local, ray_normal_local);
-
- BVHTree_WalkLeafCallback cb_walk_leaf =
- (snapdata->snap_to == SCE_SNAP_MODE_VERTEX) ?
- cb_walk_leaf_snap_vert : cb_walk_leaf_snap_edge;
-
- BLI_bvhtree_walk_dfs(
- treedata->tree,
- cb_walk_parent_snap_project, cb_walk_leaf, cb_nearest_walk_order, &neasrest2d);
-
- if (neasrest2d.index != -1) {
- copy_v3_v3(r_loc, neasrest2d.co);
- mul_m4_v3(obmat, r_loc);
- if (r_no) {
- copy_v3_v3(r_no, neasrest2d.no);
- mul_m3_v3(timat, r_no);
- normalize_v3(r_no);
- }
- *dist_px = sqrtf(neasrest2d.dist_px_sq);
- *ray_depth = depth_get(r_loc, snapdata->ray_start, snapdata->ray_dir);
+ BLI_bvhtree_walk_dfs(
+ treedata->tree,
+ cb_walk_parent_snap_project, cb_walk_leaf, cb_nearest_walk_order, &neasrest2d);
- retval = true;
+ if (neasrest2d.index != -1) {
+ copy_v3_v3(r_loc, neasrest2d.co);
+ mul_m4_v3(obmat, r_loc);
+ if (r_no) {
+ copy_v3_v3(r_no, neasrest2d.no);
+ mul_m3_v3(timat, r_no);
+ normalize_v3(r_no);
}
+ *dist_px = sqrtf(neasrest2d.dist_px_sq);
+ *ray_depth = depth_get(r_loc, snapdata->ray_start, snapdata->ray_dir);
+
+ retval = true;
}
return retval;
@@ -1361,20 +1768,14 @@ static bool snapDerivedMesh(
static bool snapEditMesh(
SnapObjectContext *sctx, SnapData *snapdata,
- Object *ob, BMEditMesh *em, float obmat[4][4], const unsigned int ob_index,
+ Object *ob, BMEditMesh *em, float obmat[4][4],
/* read/write args */
float *ray_depth, float *dist_px,
/* return args */
- float r_loc[3], float r_no[3], int *r_index,
- ListBase *r_hit_list)
+ float r_loc[3], float r_no[3])
{
bool retval = false;
- if (snapdata->snap_to == SCE_SNAP_MODE_FACE) {
- if (em->bm->totface == 0) {
- return retval;
- }
- }
if (snapdata->snap_to == SCE_SNAP_MODE_EDGE) {
if (em->bm->totedge == 0) {
return retval;
@@ -1399,13 +1800,8 @@ static bool snapEditMesh(
/* local scale in normal direction */
float local_scale = normalize_v3(ray_normal_local);
- float local_depth = *ray_depth;
- if (local_depth != BVH_RAYCAST_DIST_MAX) {
- local_depth *= local_scale;
- }
SnapObjectData_EditMesh *sod = NULL;
-
BVHTreeFromEditMesh *treedata = NULL;
void **sod_p;
@@ -1419,9 +1815,6 @@ static bool snapEditMesh(
int tree_index = -1;
switch (snapdata->snap_to) {
- case SCE_SNAP_MODE_FACE:
- tree_index = 2;
- break;
case SCE_SNAP_MODE_EDGE:
tree_index = 1;
break;
@@ -1436,197 +1829,90 @@ static bool snapEditMesh(
treedata = sod->bvh_trees[tree_index];
}
- if (treedata && treedata->tree == NULL) {
- BLI_bitmap *elem_mask = NULL;
- switch (snapdata->snap_to) {
- case SCE_SNAP_MODE_FACE:
- {
- int looptri_num_active = -1;
- if (sctx->callbacks.edit_mesh.test_face_fn) {
- elem_mask = BLI_BITMAP_NEW(em->tottri, __func__);
- looptri_num_active = BM_iter_mesh_bitmap_from_filter_tessface(
- em->bm, elem_mask,
- sctx->callbacks.edit_mesh.test_face_fn, sctx->callbacks.edit_mesh.user_data);
+ if (treedata) {
+ if (treedata->tree == NULL) {
+ BLI_bitmap *elem_mask = NULL;
+ switch (snapdata->snap_to) {
+ case SCE_SNAP_MODE_EDGE:
+ {
+ int edges_num_active = -1;
+ if (sctx->callbacks.edit_mesh.test_edge_fn) {
+ elem_mask = BLI_BITMAP_NEW(em->bm->totedge, __func__);
+ edges_num_active = BM_iter_mesh_bitmap_from_filter(
+ BM_EDGES_OF_MESH, em->bm, elem_mask,
+ (bool (*)(BMElem *, void *))sctx->callbacks.edit_mesh.test_edge_fn,
+ sctx->callbacks.edit_mesh.user_data);
+ }
+ bvhtree_from_editmesh_edges_ex(treedata, em, elem_mask, edges_num_active, 0.0f, 2, 6);
+ break;
}
- bvhtree_from_editmesh_looptri_ex(treedata, em, elem_mask, looptri_num_active, 0.0f, 4, 6, NULL);
- break;
- }
- case SCE_SNAP_MODE_EDGE:
- {
- int edges_num_active = -1;
- if (sctx->callbacks.edit_mesh.test_edge_fn) {
- elem_mask = BLI_BITMAP_NEW(em->bm->totedge, __func__);
- edges_num_active = BM_iter_mesh_bitmap_from_filter(
- BM_EDGES_OF_MESH, em->bm, elem_mask,
- (bool (*)(BMElem *, void *))sctx->callbacks.edit_mesh.test_edge_fn,
- sctx->callbacks.edit_mesh.user_data);
+ case SCE_SNAP_MODE_VERTEX:
+ {
+ int verts_num_active = -1;
+ if (sctx->callbacks.edit_mesh.test_vert_fn) {
+ elem_mask = BLI_BITMAP_NEW(em->bm->totvert, __func__);
+ verts_num_active = BM_iter_mesh_bitmap_from_filter(
+ BM_VERTS_OF_MESH, em->bm, elem_mask,
+ (bool (*)(BMElem *, void *))sctx->callbacks.edit_mesh.test_vert_fn,
+ sctx->callbacks.edit_mesh.user_data);
+ }
+ bvhtree_from_editmesh_verts_ex(treedata, em, elem_mask, verts_num_active, 0.0f, 2, 6);
+ break;
}
- bvhtree_from_editmesh_edges_ex(treedata, em, elem_mask, edges_num_active, 0.0f, 2, 6);
- break;
}
- case SCE_SNAP_MODE_VERTEX:
- {
- int verts_num_active = -1;
- if (sctx->callbacks.edit_mesh.test_vert_fn) {
- elem_mask = BLI_BITMAP_NEW(em->bm->totvert, __func__);
- verts_num_active = BM_iter_mesh_bitmap_from_filter(
- BM_VERTS_OF_MESH, em->bm, elem_mask,
- (bool (*)(BMElem *, void *))sctx->callbacks.edit_mesh.test_vert_fn,
- sctx->callbacks.edit_mesh.user_data);
- }
- bvhtree_from_editmesh_verts_ex(treedata, em, elem_mask, verts_num_active, 0.0f, 2, 6);
- break;
+ if (elem_mask) {
+ MEM_freeN(elem_mask);
}
}
- if (elem_mask) {
- MEM_freeN(elem_mask);
+ if (treedata->tree == NULL) {
+ return retval;
}
}
-
- if (!treedata || !treedata->tree) {
+ else {
return retval;
}
- if (snapdata->snap_to == SCE_SNAP_MODE_FACE) {
- float ray_start_local[3];
- copy_v3_v3(ray_start_local, snapdata->ray_start);
- mul_m4_v3(imat, ray_start_local);
+ float ray_org_local[3];
+ copy_v3_v3(ray_org_local, snapdata->ray_origin);
+ mul_m4_v3(imat, ray_org_local);
- /* Only use closer ray_start in case of ortho view! In perspective one, ray_start
- * may already been *inside* boundbox, leading to snap failures (see T38409).
- * Note also ar might be null (see T38435), in this case we assume ray_start is ok!
- */
- float len_diff = 0.0f;
- if (snapdata->view_proj == VIEW_PROJ_ORTHO) { /* do_ray_start_correction */
- /* We *need* a reasonably valid len_diff in this case.
- * Use BHVTree to find the closest face from ray_start_local.
- */
- BVHTreeNearest nearest;
- nearest.index = -1;
- nearest.dist_sq = FLT_MAX;
- /* Compute and store result. */
- if (BLI_bvhtree_find_nearest(
- treedata->tree, ray_start_local, &nearest, NULL, NULL) != -1)
- {
- float dvec[3];
- sub_v3_v3v3(dvec, nearest.co, ray_start_local);
- len_diff = dot_v3v3(dvec, ray_normal_local);
- /* You need to make sure that ray_start is really far away,
- * because even in the Orthografic view, in some cases,
- * the ray can start inside the object (see T50486) */
- if (len_diff > 400.0f) {
- float ray_org_local[3];
-
- copy_v3_v3(ray_org_local, snapdata->ray_origin);
- mul_m4_v3(imat, ray_org_local);
-
- /* We pass a temp ray_start, set from object's boundbox,
- * to avoid precision issues with very far away ray_start values
- * (as returned in case of ortho view3d), see T38358.
- */
- len_diff -= local_scale; /* make temp start point a bit away from bbox hit point. */
- madd_v3_v3v3fl(
- ray_start_local, ray_org_local, ray_normal_local,
- len_diff + snapdata->depth_range[0] * local_scale);
- local_depth -= len_diff;
- }
- else len_diff = 0.0f;
- }
- }
- if (r_hit_list) {
- struct RayCastAll_Data data;
-
- data.bvhdata = treedata;
- data.raycast_callback = treedata->raycast_callback;
- data.obmat = obmat;
- data.timat = timat;
- data.len_diff = len_diff;
- data.local_scale = local_scale;
- data.ob = ob;
- data.ob_uuid = ob_index;
- data.hit_list = r_hit_list;
- data.retval = retval;
-
- BLI_bvhtree_ray_cast_all(
- treedata->tree, ray_start_local, ray_normal_local, 0.0f,
- *ray_depth, raycast_all_cb, &data);
-
- retval = data.retval;
- }
- else {
- BVHTreeRayHit hit = {.index = -1, .dist = local_depth};
+ Nearest2dUserData neasrest2d = {
+ .dist_px_sq = SQUARE(*dist_px),
+ .r_axis_closest = {1.0f, 1.0f, 1.0f},
+ .depth_range = {snapdata->depth_range[0], *ray_depth + snapdata->depth_range[0]},
+ .userdata = treedata,
+ .get_edge_verts = (Nearest2DGetEdgeVertsCallback)get_bedge_verts,
+ .copy_vert_no = (Nearest2DCopyVertNoCallback)copy_bvert_no,
+ .index = -1};
- if (BLI_bvhtree_ray_cast(
- treedata->tree, ray_start_local, ray_normal_local, 0.0f,
- &hit, treedata->raycast_callback, treedata) != -1)
- {
- hit.dist += len_diff;
- hit.dist /= local_scale;
- if (hit.dist <= *ray_depth) {
- *ray_depth = hit.dist;
- copy_v3_v3(r_loc, hit.co);
-
- /* back to worldspace */
- mul_m4_v3(obmat, r_loc);
-
- if (r_no) {
- copy_v3_v3(r_no, hit.no);
- mul_m3_v3(timat, r_no);
- normalize_v3(r_no);
- }
+ float lpmat[4][4];
+ mul_m4_m4m4(lpmat, snapdata->pmat, obmat);
+ dist_squared_to_projected_aabb_precalc(
+ &neasrest2d.data_precalc, lpmat,
+ snapdata->view_proj == VIEW_PROJ_PERSP, snapdata->win_half,
+ (snapdata->depth_range[0] * local_scale), snapdata->mval,
+ ray_org_local, ray_normal_local);
- retval = true;
+ BVHTree_WalkLeafCallback cb_walk_leaf =
+ (snapdata->snap_to == SCE_SNAP_MODE_VERTEX) ?
+ cb_walk_leaf_snap_vert : cb_walk_leaf_snap_edge;
- if (r_index) {
- *r_index = hit.index;
- }
- }
- }
- }
- }
- else {
- float ray_org_local[3];
- copy_v3_v3(ray_org_local, snapdata->ray_origin);
- mul_m4_v3(imat, ray_org_local);
-
- Nearest2dUserData neasrest2d = {
- .dist_px_sq = SQUARE(*dist_px),
- .r_axis_closest = {1.0f, 1.0f, 1.0f},
- .depth_range = {snapdata->depth_range[0], *ray_depth + snapdata->depth_range[0]},
- .userdata = treedata,
- .get_edge_verts = (Nearest2DGetEdgeVertsCallback)get_bedge_verts,
- .copy_vert_no = (Nearest2DCopyVertNoCallback)copy_bvert_no,
- .index = -1};
-
- float lpmat[4][4];
- mul_m4_m4m4(lpmat, snapdata->pmat, obmat);
- dist_squared_to_projected_aabb_precalc(
- &neasrest2d.data_precalc, lpmat,
- snapdata->view_proj == VIEW_PROJ_PERSP, snapdata->win_half,
- (snapdata->depth_range[0] * local_scale), snapdata->mval,
- ray_org_local, ray_normal_local);
-
- BVHTree_WalkLeafCallback cb_walk_leaf =
- (snapdata->snap_to == SCE_SNAP_MODE_VERTEX) ?
- cb_walk_leaf_snap_vert : cb_walk_leaf_snap_edge;
-
- BLI_bvhtree_walk_dfs(
- treedata->tree,
- cb_walk_parent_snap_project, cb_walk_leaf, cb_nearest_walk_order, &neasrest2d);
-
- if (neasrest2d.index != -1) {
- copy_v3_v3(r_loc, neasrest2d.co);
- mul_m4_v3(obmat, r_loc);
- if (r_no) {
- copy_v3_v3(r_no, neasrest2d.no);
- mul_m3_v3(timat, r_no);
- normalize_v3(r_no);
- }
- *dist_px = sqrtf(neasrest2d.dist_px_sq);
- *ray_depth = depth_get(r_loc, snapdata->ray_start, snapdata->ray_dir);
+ BLI_bvhtree_walk_dfs(
+ treedata->tree,
+ cb_walk_parent_snap_project, cb_walk_leaf, cb_nearest_walk_order, &neasrest2d);
- retval = true;
+ if (neasrest2d.index != -1) {
+ copy_v3_v3(r_loc, neasrest2d.co);
+ mul_m4_v3(obmat, r_loc);
+ if (r_no) {
+ copy_v3_v3(r_no, neasrest2d.no);
+ mul_m3_v3(timat, r_no);
+ normalize_v3(r_no);
}
+ *dist_px = sqrtf(neasrest2d.dist_px_sq);
+ *ray_depth = depth_get(r_loc, snapdata->ray_start, snapdata->ray_dir);
+
+ retval = true;
}
return retval;
@@ -1639,14 +1925,13 @@ static bool snapEditMesh(
*/
static bool snapObject(
SnapObjectContext *sctx, SnapData *snapdata,
- Object *ob, float obmat[4][4], const unsigned int ob_index,
+ Object *ob, float obmat[4][4],
bool use_obedit,
/* read/write args */
float *ray_depth, float *dist_px,
/* return args */
- float r_loc[3], float r_no[3], int *r_index,
- Object **r_ob, float r_obmat[4][4],
- ListBase *r_hit_list)
+ float r_loc[3], float r_no[3],
+ Object **r_ob, float r_obmat[4][4])
{
bool retval = false;
@@ -1656,10 +1941,9 @@ static bool snapObject(
if (use_obedit) {
em = BKE_editmesh_from_object(ob);
retval = snapEditMesh(
- sctx, snapdata, ob, em, obmat, ob_index,
+ sctx, snapdata, ob, em, obmat,
ray_depth, dist_px,
- r_loc, r_no, r_index,
- r_hit_list);
+ r_loc, r_no);
}
else {
/* in this case we want the mesh from the editmesh, avoids stale data. see: T45978.
@@ -1667,16 +1951,15 @@ static bool snapObject(
DerivedMesh *dm;
em = BKE_editmesh_from_object(ob);
if (em) {
- editbmesh_get_derived_cage_and_final(sctx->scene, ob, em, CD_MASK_BAREMESH, &dm);
+ editbmesh_get_derived_cage_and_final(&sctx->eval_ctx, sctx->scene, ob, em, CD_MASK_BAREMESH, &dm);
}
else {
- dm = mesh_get_derived_final(sctx->scene, ob, CD_MASK_BAREMESH);
+ dm = mesh_get_derived_final(&sctx->eval_ctx, sctx->scene, ob, CD_MASK_BAREMESH);
}
retval = snapDerivedMesh(
- sctx, snapdata, ob, dm, obmat, ob_index,
+ sctx, snapdata, ob, dm, obmat,
ray_depth, dist_px,
- r_loc, r_no,
- r_index, r_hit_list);
+ r_loc, r_no);
dm->release(dm);
}
@@ -1721,6 +2004,34 @@ static bool snapObject(
return retval;
}
+
+struct SnapObjUserData {
+ SnapData *snapdata;
+ /* read/write args */
+ float *ray_depth;
+ float *dist_px;
+ /* return args */
+ float *r_loc;
+ float *r_no;
+ Object **r_ob;
+ float (*r_obmat)[4];
+ bool ret;
+};
+
+static void sanp_obj_cb(SnapObjectContext *sctx, bool is_obedit, Object *ob, float obmat[4][4], void *data)
+{
+ struct SnapObjUserData *dt = data;
+ dt->ret |= snapObject(
+ sctx, dt->snapdata,
+ ob, obmat, is_obedit,
+ /* read/write args */
+ dt->ray_depth, dt->dist_px,
+ /* return args */
+ dt->r_loc, dt->r_no,
+ dt->r_ob, dt->r_obmat);
+}
+
+
/**
* Main Snapping Function
* ======================
@@ -1729,8 +2040,8 @@ static bool snapObject(
*
* \param sctx: Snap context to store data.
* \param snapdata: struct generated in `get_snapdata`.
- * \param snap_select: from enum SnapSelect.
- * \param use_object_edit_cage: Uses the coordinates of BMesh (if any) to do the snapping.
+ * \param snap_select : from enum SnapSelect.
+ * \param use_object_edit_cage : Uses the coordinates of BMesh(if any) to do the snapping.
*
* Read/Write Args
* ---------------
@@ -1747,89 +2058,33 @@ static bool snapObject(
* (currently only set to the polygon index when when using ``snap_to == SCE_SNAP_MODE_FACE``).
* \param r_ob: Hit object.
* \param r_obmat: Object matrix (may not be #Object.obmat with dupli-instances).
- * \param r_hit_list: List of #SnapObjectHitDepth (caller must free).
*
*/
static bool snapObjectsRay(
SnapObjectContext *sctx, SnapData *snapdata,
- const SnapSelect snap_select,
- const bool use_object_edit_cage,
+ const SnapSelect snap_select, const bool use_object_edit_cage,
/* read/write args */
float *ray_depth, float *dist_px,
/* return args */
- float r_loc[3], float r_no[3], int *r_index,
- Object **r_ob, float r_obmat[4][4],
- ListBase *r_hit_list)
+ float r_loc[3], float r_no[3],
+ Object **r_ob, float r_obmat[4][4])
{
- bool retval = false;
-
- unsigned int ob_index = 0;
Object *obedit = use_object_edit_cage ? sctx->scene->obedit : NULL;
- /* Need an exception for particle edit because the base is flagged with BA_HAS_RECALC_DATA
- * which makes the loop skip it, even the derived mesh will never change
- *
- * To solve that problem, we do it first as an exception.
- * */
- Base *base_act = sctx->scene_layer->basact;
- if (base_act && base_act->object && base_act->object->mode & OB_MODE_PARTICLE_EDIT) {
- Object *ob = base_act->object;
-
- retval |= snapObject(
- sctx, snapdata, ob, ob->obmat, ob_index++, false,
- ray_depth, dist_px,
- r_loc, r_no, r_index, r_ob, r_obmat, r_hit_list);
- }
-
- bool ignore_object_selected = false, ignore_object_active = false;
- switch (snap_select) {
- case SNAP_ALL:
- break;
- case SNAP_NOT_SELECTED:
- ignore_object_selected = true;
- break;
- case SNAP_NOT_ACTIVE:
- ignore_object_active = true;
- break;
- }
- for (Base *base = sctx->scene_layer->object_bases.first; base != NULL; base = base->next) {
- if ((BASE_VISIBLE_NEW(base)) &&
- (base->flag_legacy & (BA_HAS_RECALC_OB | BA_HAS_RECALC_DATA)) == 0 &&
-
- !((ignore_object_selected && (((base->flag & BASE_SELECTED) != 0) || ((base->flag_legacy & BA_WAS_SEL)))) ||
- (ignore_object_active && base == base_act)))
- {
- Object *ob = base->object;
-
- if (ob->transflag & OB_DUPLI) {
- DupliObject *dupli_ob;
- ListBase *lb = object_duplilist(sctx->bmain->eval_ctx, sctx->scene, ob);
-
- for (dupli_ob = lb->first; dupli_ob; dupli_ob = dupli_ob->next) {
- bool use_obedit_dupli = (obedit && dupli_ob->ob->data == obedit->data);
- Object *dupli_snap = (use_obedit_dupli) ? obedit : dupli_ob->ob;
-
- retval |= snapObject(
- sctx, snapdata, dupli_snap, dupli_ob->mat,
- ob_index++, use_obedit_dupli,
- ray_depth, dist_px,
- r_loc, r_no, r_index, r_ob, r_obmat, r_hit_list);
- }
-
- free_object_duplilist(lb);
- }
-
- bool use_obedit = (obedit != NULL) && (ob->data == obedit->data);
- Object *ob_snap = use_obedit ? obedit : ob;
+ struct SnapObjUserData data = {
+ .snapdata = snapdata,
+ .ray_depth = ray_depth,
+ .dist_px = dist_px,
+ .r_loc = r_loc,
+ .r_no = r_no,
+ .r_ob = r_ob,
+ .r_obmat = r_obmat,
+ .ret = false,
+ };
- retval |= snapObject(
- sctx, snapdata, ob_snap, ob->obmat, ob_index++, use_obedit,
- ray_depth, dist_px,
- r_loc, r_no, r_index, r_ob, r_obmat, r_hit_list);
- }
- }
+ iter_snap_objects(sctx, snap_select, obedit, sanp_obj_cb, &data);
- return retval;
+ return data.ret;
}
/** \} */
@@ -1849,7 +2104,8 @@ SnapObjectContext *ED_transform_snap_object_context_create(
sctx->bmain = bmain;
sctx->scene = scene;
- sctx->scene_layer = sl;
+
+ DEG_evaluation_context_init_from_scene(&sctx->eval_ctx, scene, sl, DAG_EVAL_VIEWPORT);
sctx->cache.object_map = BLI_ghash_ptr_new(__func__);
sctx->cache.mem_arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);
@@ -1924,25 +2180,17 @@ void ED_transform_snap_object_context_set_editmesh_callbacks(
bool ED_transform_snap_object_project_ray_ex(
SnapObjectContext *sctx,
- const unsigned short snap_to,
const struct SnapObjectParams *params,
const float ray_start[3], const float ray_normal[3],
float *ray_depth,
float r_loc[3], float r_no[3], int *r_index,
Object **r_ob, float r_obmat[4][4])
{
- const float depth_range[2] = {0.0f, FLT_MAX};
-
- SnapData snapdata;
- snap_data_set(
- &snapdata, sctx->v3d_data.ar, snap_to, VIEW_PROJ_NONE,
- NULL, ray_start, ray_start, ray_normal, depth_range);
-
- return snapObjectsRay(
- sctx, &snapdata,
+ return raycastObjects(
+ sctx,
+ ray_start, ray_normal,
params->snap_select, params->use_object_edit_cage,
- ray_depth, NULL,
- r_loc, r_no, r_index, r_ob, r_obmat, NULL);
+ ray_depth, r_loc, r_no, r_index, r_ob, r_obmat, NULL);
}
/**
@@ -1954,13 +2202,11 @@ bool ED_transform_snap_object_project_ray_ex(
*/
bool ED_transform_snap_object_project_ray_all(
SnapObjectContext *sctx,
- const unsigned short snap_to,
const struct SnapObjectParams *params,
const float ray_start[3], const float ray_normal[3],
float ray_depth, bool sort,
ListBase *r_hit_list)
{
- const float depth_range[2] = {0.0f, FLT_MAX};
if (ray_depth == -1.0f) {
ray_depth = BVH_RAYCAST_DIST_MAX;
}
@@ -1969,15 +2215,11 @@ bool ED_transform_snap_object_project_ray_all(
float ray_depth_prev = ray_depth;
#endif
- SnapData snapdata;
- snap_data_set(&snapdata, sctx->v3d_data.ar, snap_to, VIEW_PROJ_NONE, NULL,
- ray_start, ray_start, ray_normal, depth_range);
-
- bool retval = snapObjectsRay(
- sctx, &snapdata,
+ bool retval = raycastObjects(
+ sctx,
+ ray_start, ray_normal,
params->snap_select, params->use_object_edit_cage,
- &ray_depth, NULL,
- NULL, NULL, NULL, NULL, NULL,
+ &ray_depth, NULL, NULL, NULL, NULL, NULL,
r_hit_list);
/* meant to be readonly for 'all' hits, ensure it is */
@@ -2010,7 +2252,6 @@ static bool transform_snap_context_project_ray_impl(
/* try snap edge, then face if it fails */
ret = ED_transform_snap_object_project_ray_ex(
sctx,
- SCE_SNAP_MODE_FACE,
params,
ray_start, ray_normal, ray_depth,
r_co, r_no, NULL,
@@ -2156,16 +2397,24 @@ bool ED_transform_snap_object_project_view3d_ex(
ray_depth = &ray_depth_fallback;
}
- SnapData snapdata;
- const enum eViewProj view_proj = ((RegionView3D *)ar->regiondata)->is_persp ? VIEW_PROJ_PERSP : VIEW_PROJ_ORTHO;
- snap_data_set(&snapdata, ar, snap_to, view_proj, mval,
- ray_origin, ray_start, ray_normal, depth_range);
+ if (snap_to == SCE_SNAP_MODE_FACE) {
+ return raycastObjects(
+ sctx,
+ ray_start, ray_normal,
+ params->snap_select, params->use_object_edit_cage,
+ ray_depth, r_loc, r_no, r_index, NULL, NULL, NULL);
+ }
+ else {
+ SnapData snapdata;
+ const enum eViewProj view_proj = ((RegionView3D *)ar->regiondata)->is_persp ? VIEW_PROJ_PERSP : VIEW_PROJ_ORTHO;
+ snap_data_set(&snapdata, ar, snap_to, view_proj, mval,
+ ray_origin, ray_start, ray_normal, depth_range);
- return snapObjectsRay(
- sctx, &snapdata,
- params->snap_select, params->use_object_edit_cage,
- ray_depth, dist_px,
- r_loc, r_no, r_index, NULL, NULL, NULL);
+ return snapObjectsRay(
+ sctx, &snapdata,
+ params->snap_select, params->use_object_edit_cage,
+ ray_depth, dist_px, r_loc, r_no, NULL, NULL);
+ }
}
bool ED_transform_snap_object_project_view3d(
@@ -2206,7 +2455,6 @@ bool ED_transform_snap_object_project_all_view3d_ex(
return ED_transform_snap_object_project_ray_all(
sctx,
- SCE_SNAP_MODE_FACE,
params,
ray_start, ray_normal, ray_depth, sort,
r_hit_list);
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index f028293d219..8178079eb19 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -323,7 +323,7 @@ void ED_region_draw_mouse_line_cb(const bContext *C, ARegion *ar, void *arg_info
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c
index f5830e451e3..ff328a28ee9 100644
--- a/source/blender/editors/util/undo.c
+++ b/source/blender/editors/util/undo.c
@@ -335,6 +335,12 @@ static int ed_undo_redo_exec(bContext *C, wmOperator *UNUSED(op))
return ret ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
+static int ed_undo_redo_poll(bContext *C)
+{
+ wmOperator *last_op = WM_operator_last_redo(C);
+ return last_op && ED_operator_screenactive(C) &&
+ WM_operator_check_ui_enabled(C, last_op->type->name);
+}
/* ********************** */
@@ -386,7 +392,7 @@ void ED_OT_undo_redo(wmOperatorType *ot)
/* api callbacks */
ot->exec = ed_undo_redo_exec;
- ot->poll = ED_operator_screenactive;
+ ot->poll = ed_undo_redo_poll;
}
/* ui callbacks should call this rather than calling WM_operator_repeat() themselves */
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index f8c0e24c061..1e557236bfd 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -89,7 +89,7 @@ void ED_image_draw_cursor(ARegion *ar, const float cursor[2])
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
@@ -655,7 +655,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, SceneLayer *sl, Object *obe
/* 1. draw shadow mesh */
if (sima->flag & SI_DRAWSHADOW) {
- Object *ob_cage = DEG_get_object(depsgraph, obedit);
+ Object *ob_cage = DEG_get_evaluated_object(depsgraph, obedit);
/* XXX TODO: Need to check if shadow mesh is different than original mesh. */
bool is_cage_like_final_meshes = (ob_cage == obedit);
@@ -743,7 +743,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, SceneLayer *sl, Object *obe
{
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 0e33525ceff..2a0eed6f438 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -222,7 +222,7 @@ void ED_uvedit_assign_image(Main *UNUSED(bmain), Scene *scene, Object *obedit, I
if (!CustomData_has_layer(&em->bm->ldata, CD_MLOOPUV)) {
BM_data_layer_add(em->bm, &em->bm->ldata, CD_MLOOPUV);
/* make UVs all nice 0-1 */
- ED_mesh_uv_loop_reset_ex(obedit->data, CustomData_get_active_layer_index(&em->bm->ldata, CD_MLOOPUV));
+ ED_mesh_uv_loop_reset_ex(obedit->data, CustomData_get_active_layer(&em->bm->ldata, CD_MLOOPUV));
update = true;
}
@@ -1062,8 +1062,13 @@ static void uv_select_linked(Scene *scene, Image *ima, BMEditMesh *em, const flo
BM_mesh_elem_table_ensure(em->bm, BM_FACE); /* we can use this too */
- /* use winding so we don't consider overlapping islands as connected, see T44320 */
- vmap = BM_uv_vert_map_create(em->bm, limit, !select_faces, true);
+ /* Note, we had 'use winding' so we don't consider overlapping islands as connected, see T44320
+ * this made *every* projection split the island into front/back islands.
+ * Keep 'use_winding' to false, see: T50970.
+ *
+ * Better solve this by having a delimit option for select-linked operator,
+ * keeping island-select working as is. */
+ vmap = BM_uv_vert_map_create(em->bm, limit, !select_faces, false);
if (vmap == NULL)
return;
diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c
index 55c439924cd..4ff4c3223f0 100644
--- a/source/blender/editors/uvedit/uvedit_smart_stitch.c
+++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c
@@ -1541,13 +1541,15 @@ static void stitch_calculate_edge_normal(BMEditMesh *em, UvEdge *edge, float *no
normalize_v2(normal);
}
+/**
+ */
static void stitch_draw_vbo(Gwn_VertBuf *vbo, Gwn_PrimType prim_type, const float col[4])
{
- Gwn_Batch *batch = GWN_batch_create(prim_type, vbo, NULL);
- Batch_set_builtin_program(batch, GPU_SHADER_2D_UNIFORM_COLOR);
+ Gwn_Batch *batch = GWN_batch_create_ex(prim_type, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_UNIFORM_COLOR);
GWN_batch_uniform_4fv(batch, "color", col);
GWN_batch_draw(batch);
- GWN_batch_discard_all(batch);
+ GWN_batch_discard(batch);
}
/* TODO make things pretier : store batches inside StitchPreviewer instead of the bare verts pos */
@@ -1572,8 +1574,9 @@ static void stitch_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *ar
UI_GetThemeColor4fv(TH_STITCH_PREVIEW_ACTIVE, col);
vbo = GWN_vertbuf_create_with_format(&format);
GWN_vertbuf_data_alloc(vbo, stitch_preview->num_static_tris * 3);
- for (int i = 0; i < stitch_preview->num_static_tris * 3; i++)
- GWN_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->static_tris[i*2]);
+ for (int i = 0; i < stitch_preview->num_static_tris * 3; i++) {
+ GWN_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->static_tris[i * 2]);
+ }
stitch_draw_vbo(vbo, GWN_PRIM_TRIS, col);
@@ -1599,16 +1602,17 @@ static void stitch_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *ar
for (j = 1; j < stitch_preview->uvs_per_polygon[i] - 1; ++j) {
GWN_vertbuf_attr_set(vbo, pos_id, tri_idx++, &stitch_preview->preview_polys[index]);
- GWN_vertbuf_attr_set(vbo, pos_id, tri_idx++, &stitch_preview->preview_polys[index + (j+0)*2]);
- GWN_vertbuf_attr_set(vbo, pos_id, tri_idx++, &stitch_preview->preview_polys[index + (j+1)*2]);
+ GWN_vertbuf_attr_set(vbo, pos_id, tri_idx++, &stitch_preview->preview_polys[index + (j + 0) * 2]);
+ GWN_vertbuf_attr_set(vbo, pos_id, tri_idx++, &stitch_preview->preview_polys[index + (j + 1) * 2]);
- GWN_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index + (j+0)*2]);
- GWN_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index + (j+1)*2]);
+ GWN_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index + (j + 0) * 2]);
+ GWN_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index + (j + 1) * 2]);
}
/* Closing line */
GWN_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index]);
- GWN_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index + j*2]); /* j = uvs_per_polygon[i] - 1*/
+ /* j = uvs_per_polygon[i] - 1*/
+ GWN_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index + j * 2]);
index += stitch_preview->uvs_per_polygon[i] * 2;
}
@@ -1627,30 +1631,34 @@ static void stitch_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *ar
UI_GetThemeColor4fv(TH_STITCH_PREVIEW_STITCHABLE, col);
vbo = GWN_vertbuf_create_with_format(&format);
GWN_vertbuf_data_alloc(vbo, stitch_preview->num_stitchable);
- for (int i = 0; i < stitch_preview->num_stitchable; i++)
- GWN_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_stitchable[i*2]);
+ for (int i = 0; i < stitch_preview->num_stitchable; i++) {
+ GWN_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_stitchable[i * 2]);
+ }
stitch_draw_vbo(vbo, GWN_PRIM_POINTS, col);
UI_GetThemeColor4fv(TH_STITCH_PREVIEW_UNSTITCHABLE, col);
vbo = GWN_vertbuf_create_with_format(&format);
GWN_vertbuf_data_alloc(vbo, stitch_preview->num_unstitchable);
- for (int i = 0; i < stitch_preview->num_unstitchable; i++)
- GWN_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_unstitchable[i*2]);
+ for (int i = 0; i < stitch_preview->num_unstitchable; i++) {
+ GWN_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_unstitchable[i * 2]);
+ }
stitch_draw_vbo(vbo, GWN_PRIM_POINTS, col);
}
else {
UI_GetThemeColor4fv(TH_STITCH_PREVIEW_STITCHABLE, col);
vbo = GWN_vertbuf_create_with_format(&format);
GWN_vertbuf_data_alloc(vbo, stitch_preview->num_stitchable * 2);
- for (int i = 0; i < stitch_preview->num_stitchable * 2; i++)
- GWN_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_stitchable[i*2]);
+ for (int i = 0; i < stitch_preview->num_stitchable * 2; i++) {
+ GWN_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_stitchable[i * 2]);
+ }
stitch_draw_vbo(vbo, GWN_PRIM_LINES, col);
UI_GetThemeColor4fv(TH_STITCH_PREVIEW_UNSTITCHABLE, col);
vbo = GWN_vertbuf_create_with_format(&format);
GWN_vertbuf_data_alloc(vbo, stitch_preview->num_unstitchable * 2);
- for (int i = 0; i < stitch_preview->num_unstitchable * 2; i++)
- GWN_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_unstitchable[i*2]);
+ for (int i = 0; i < stitch_preview->num_unstitchable * 2; i++) {
+ GWN_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_unstitchable[i * 2]);
+ }
stitch_draw_vbo(vbo, GWN_PRIM_LINES, col);
}
}
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
index 6191461a5d6..322acd9966c 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
+++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
@@ -951,9 +951,9 @@ Render *BlenderStrokeRenderer::RenderScene(Render * /*re*/, bool render)
}
#endif
- Render *freestyle_render = RE_NewRender(freestyle_scene->id.name);
+ Render *freestyle_render = RE_NewSceneRender(freestyle_scene);
DEG_scene_relations_update(freestyle_bmain, freestyle_scene);
- freestyle_render->depsgraph = freestyle_scene->depsgraph;
+ freestyle_render->depsgraph = freestyle_scene->depsgraph_legacy;
RE_RenderFreestyleStrokes(freestyle_render, freestyle_bmain, freestyle_scene,
render && get_stroke_count() > 0);
diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt
index a754d5b92b0..ec623554567 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -135,7 +135,7 @@ data_to_c_simple(shaders/gpu_shader_flat_color_frag.glsl SRC)
data_to_c_simple(shaders/gpu_shader_flat_color_alpha_test_0_frag.glsl SRC)
data_to_c_simple(shaders/gpu_shader_2D_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_2D_flat_color_vert.glsl SRC)
-data_to_c_simple(shaders/gpu_shader_2D_line_dashed_vert.glsl SRC)
+data_to_c_simple(shaders/gpu_shader_2D_line_dashed_uniform_color_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_2D_line_dashed_frag.glsl SRC)
data_to_c_simple(shaders/gpu_shader_2D_line_dashed_geom.glsl SRC)
data_to_c_simple(shaders/gpu_shader_2D_smooth_color_vert.glsl SRC)
@@ -154,8 +154,8 @@ data_to_c_simple(shaders/gpu_shader_3D_image_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_3D_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_3D_normal_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_3D_flat_color_vert.glsl SRC)
-data_to_c_simple(shaders/gpu_shader_3D_line_dashed_legacy_vert.glsl SRC)
-data_to_c_simple(shaders/gpu_shader_3D_line_dashed_vert.glsl SRC)
+data_to_c_simple(shaders/gpu_shader_3D_line_dashed_uniform_color_legacy_vert.glsl SRC)
+data_to_c_simple(shaders/gpu_shader_3D_line_dashed_uniform_color_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_3D_smooth_color_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_3D_normal_smooth_color_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_3D_smooth_color_frag.glsl SRC)
diff --git a/source/blender/gpu/GPU_batch.h b/source/blender/gpu/GPU_batch.h
index d052a2d831f..6d16092996e 100644
--- a/source/blender/gpu/GPU_batch.h
+++ b/source/blender/gpu/GPU_batch.h
@@ -31,7 +31,7 @@
#ifndef __GPU_BATCH_H__
#define __GPU_BATCH_H__
-#include "../../../intern/gawain/gawain/batch.h"
+#include "../../../intern/gawain/gawain/gwn_batch.h"
// TODO: CMake magic to do this:
// #include "gawain/batch.h"
@@ -39,11 +39,11 @@
#include "GPU_shader.h"
/* Extend GWN_batch_program_set to use Blender’s library of built-in shader programs. */
-void Batch_set_builtin_program(Gwn_Batch*, GPUBuiltinShader);
+void GWN_batch_program_set_builtin(Gwn_Batch *, GPUBuiltinShader);
/* Replacement for gluSphere */
-Gwn_Batch *Batch_get_sphere(int lod);
-Gwn_Batch *Batch_get_sphere_wire(int lod);
+Gwn_Batch *GPU_batch_preset_sphere(int lod);
+Gwn_Batch *GPU_batch_preset_sphere_wire(int lod);
void gpu_batch_init(void);
void gpu_batch_exit(void);
diff --git a/source/blender/gpu/GPU_immediate.h b/source/blender/gpu/GPU_immediate.h
index 2eb4eb94f48..6206e973908 100644
--- a/source/blender/gpu/GPU_immediate.h
+++ b/source/blender/gpu/GPU_immediate.h
@@ -31,12 +31,12 @@
#ifndef __GPU_IMMEDIATE_H__
#define __GPU_IMMEDIATE_H__
-#include "../../../intern/gawain/gawain/immediate.h"
-#include "../../../intern/gawain/gawain/imm_util.h"
+#include "../../../intern/gawain/gawain/gwn_immediate.h"
+#include "../../../intern/gawain/gawain/gwn_imm_util.h"
// TODO: CMake magic to do this:
-// #include "gawain/immediate.h"
-// #include "gawain/imm_util.h"
+// #include "gawain/gwn_immediate.h"
+// #include "gawain/gwn_imm_util.h"
#include "GPU_shader.h"
diff --git a/source/blender/gpu/GPU_immediate_util.h b/source/blender/gpu/GPU_immediate_util.h
index f91dd6147a0..c31d477ff5b 100644
--- a/source/blender/gpu/GPU_immediate_util.h
+++ b/source/blender/gpu/GPU_immediate_util.h
@@ -27,33 +27,38 @@
#ifndef __GPU_IMMEDIATE_UTIL_H__
#define __GPU_IMMEDIATE_UTIL_H__
-void imm_cpack(unsigned int x);
+void imm_cpack(uint x);
-void imm_draw_circle_wire(uint shdr_pos, float x, float y, float radius, int nsegments);
-void imm_draw_circle_fill(uint shdr_pos, float x, float y, float radius, int nsegments);
+void imm_draw_circle_wire_2d(uint shdr_pos, float x, float y, float radius, int nsegments);
+void imm_draw_circle_fill_2d(uint shdr_pos, float x, float y, float radius, int nsegments);
+
+void imm_draw_circle_wire_aspect_2d(uint shdr_pos, float x, float y, float radius_x, float radius_y, int nsegments);
+void imm_draw_circle_fill_aspect_2d(uint shdr_pos, float x, float y, float radius_x, float radius_y, int nsegments);
/* use this version when Gwn_VertFormat has a vec3 position */
-void imm_draw_circle_wire_3d(unsigned pos, float x, float y, float radius, int nsegments);
-void imm_draw_circle_fill_3d(unsigned pos, float x, float y, float radius, int nsegments);
+void imm_draw_circle_wire_3d(uint pos, float x, float y, float radius, int nsegments);
+void imm_draw_circle_fill_3d(uint pos, float x, float y, float radius, int nsegments);
-void imm_draw_disk_partial_fill(
- unsigned pos, float x, float y,
+void imm_draw_disk_partial_fill_2d(
+ uint pos, float x, float y,
float radius_inner, float radius_outer, int nsegments, float start, float sweep);
-void imm_draw_line_box(unsigned pos, float x1, float y1, float x2, float y2);
+void imm_draw_box_wire_2d(uint pos, float x1, float y1, float x2, float y2);
+void imm_draw_box_wire_3d(uint pos, float x1, float y1, float x2, float y2);
-void imm_draw_line_box_3d(unsigned pos, float x1, float y1, float x2, float y2);
+void imm_draw_box_checker_2d(float x1, float y1, float x2, float y2);
-void imm_draw_checker_box(float x1, float y1, float x2, float y2);
+void imm_draw_cube_fill_3d(uint pos, const float co[3], const float aspect[3]);
+void imm_draw_cube_wire_3d(uint pos, const float co[3], const float aspect[3]);
void imm_draw_cylinder_fill_normal_3d(
- unsigned int pos, unsigned int nor, float base, float top, float height,
+ uint pos, uint nor, float base, float top, float height,
int slices, int stacks);
void imm_draw_cylinder_wire_3d(
- unsigned int pos, float base, float top, float height,
+ uint pos, float base, float top, float height,
int slices, int stacks);
void imm_draw_cylinder_fill_3d(
- unsigned int pos, float base, float top, float height,
+ uint pos, float base, float top, float height,
int slices, int stacks);
#endif /* __GPU_IMMEDIATE_UTIL_H__ */
diff --git a/source/blender/gpu/GPU_lamp.h b/source/blender/gpu/GPU_lamp.h
index e08fbede80a..f6fd817cc3f 100644
--- a/source/blender/gpu/GPU_lamp.h
+++ b/source/blender/gpu/GPU_lamp.h
@@ -54,7 +54,7 @@ GPULamp *GPU_lamp_from_blender(struct Scene *scene, struct Object *ob, struct Ob
void GPU_lamp_free(struct Object *ob);
void GPU_lamp_engine_data_free(LampEngineData *led);
-bool GPU_lamp_override_visible(GPULamp *lamp, struct SceneRenderLayer *srl, struct Material *ma);
+bool GPU_lamp_visible(GPULamp *lamp, struct SceneRenderLayer *srl, struct Material *ma);
bool GPU_lamp_has_shadow_buffer(GPULamp *lamp);
void GPU_lamp_update_buffer_mats(GPULamp *lamp);
void GPU_lamp_shadow_buffer_bind(GPULamp *lamp, float viewmat[4][4], int *winsize, float winmat[4][4]);
diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h
index 4345a31839a..7bc256a70fa 100644
--- a/source/blender/gpu/GPU_material.h
+++ b/source/blender/gpu/GPU_material.h
@@ -43,6 +43,7 @@ extern "C" {
struct Image;
struct ImageUser;
+struct ListBase;
struct Material;
struct Object;
struct Scene;
@@ -53,9 +54,11 @@ struct GPUNodeLink;
struct GPUNodeStack;
struct GPUMaterial;
struct GPUTexture;
+struct GPUUniformBuffer;
struct GPULamp;
struct PreviewImage;
struct World;
+struct bNode;
struct bNodeTree;
typedef struct GPUNode GPUNode;
@@ -67,6 +70,7 @@ typedef struct GPUParticleInfo GPUParticleInfo;
/* Functions to create GPU Materials nodes */
typedef enum GPUType {
+ /* Keep in sync with GPU_DATATYPE_STR */
/* The value indicates the number of elements in each type */
GPU_NONE = 0,
GPU_FLOAT = 1,
@@ -76,9 +80,15 @@ typedef enum GPUType {
GPU_MAT3 = 9,
GPU_MAT4 = 16,
+ /* Values not in GPU_DATATYPE_STR */
GPU_TEX2D = 1002,
GPU_SHADOW2D = 1003,
GPU_TEXCUBE = 1004,
+
+ /* GLSL Struct types */
+ GPU_CLOSURE = 1005,
+
+ /* Opengl Attributes */
GPU_ATTRIB = 3001
} GPUType;
@@ -141,6 +151,7 @@ typedef struct GPUNodeStack {
#define GPU_DYNAMIC_GROUP_MIST 0x00050000
#define GPU_DYNAMIC_GROUP_WORLD 0x00060000
#define GPU_DYNAMIC_GROUP_MAT 0x00070000
+#define GPU_DYNAMIC_UBO 0x00080000
typedef enum GPUDynamicType {
@@ -200,6 +211,7 @@ typedef enum GPUDynamicType {
GPUNodeLink *GPU_attribute(CustomDataType type, const char *name);
GPUNodeLink *GPU_uniform(float *num);
GPUNodeLink *GPU_dynamic_uniform(float *num, GPUDynamicType dynamictype, void *data);
+GPUNodeLink *GPU_uniform_buffer(float *num, GPUType gputype);
GPUNodeLink *GPU_image(struct Image *ima, struct ImageUser *iuser, bool is_data);
GPUNodeLink *GPU_cube_map(struct Image *ima, struct ImageUser *iuser, bool is_data);
GPUNodeLink *GPU_image_preview(struct PreviewImage *prv);
@@ -210,7 +222,10 @@ GPUNodeLink *GPU_opengl_builtin(GPUOpenGLBuiltin builtin);
void GPU_node_link_set_type(GPUNodeLink *link, GPUType type);
bool GPU_link(GPUMaterial *mat, const char *name, ...);
-bool GPU_stack_link(GPUMaterial *mat, const char *name, GPUNodeStack *in, GPUNodeStack *out, ...);
+bool GPU_stack_link(GPUMaterial *mat, struct bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out, ...);
+GPUNodeLink *GPU_uniformbuffer_link_out(
+ struct GPUMaterial *mat, struct bNode *node,
+ struct GPUNodeStack *stack, const int index);
void GPU_material_output_link(GPUMaterial *material, GPUNodeLink *link);
void GPU_material_enable_alpha(GPUMaterial *material);
@@ -219,8 +234,10 @@ GPUBlendMode GPU_material_alpha_blend(GPUMaterial *material, float obcol[4]);
/* High level functions to create and use GPU materials */
GPUMaterial *GPU_material_world(struct Scene *scene, struct World *wo);
+GPUMaterial *GPU_material_from_nodetree_find(
+ struct ListBase *gpumaterials, const void *engine_type, int options);
GPUMaterial *GPU_material_from_nodetree(
- struct Scene *scene, struct bNodeTree *ntree, struct ListBase *gpumaterials, void *engine_type, int options,
+ struct Scene *scene, struct bNodeTree *ntree, struct ListBase *gpumaterials, const void *engine_type, int options,
const char *vert_code, const char *geom_code, const char *frag_lib, const char *defines);
GPUMaterial *GPU_material_from_blender(struct Scene *scene, struct Material *ma, bool use_opensubdiv);
GPUMaterial *GPU_material_matcap(struct Scene *scene, struct Material *ma, bool use_opensubdiv);
@@ -240,6 +257,10 @@ struct Scene *GPU_material_scene(GPUMaterial *material);
GPUMatType GPU_Material_get_type(GPUMaterial *material);
struct GPUPass *GPU_material_get_pass(GPUMaterial *material);
+struct GPUUniformBuffer *GPU_material_get_uniform_buffer(GPUMaterial *material);
+void GPU_material_create_uniform_buffer(GPUMaterial *material, struct ListBase *inputs);
+void GPU_material_uniform_buffer_tag_dirty(struct ListBase *gpumaterials);
+
void GPU_material_vertex_attributes(GPUMaterial *material,
struct GPUVertexAttribs *attrib);
diff --git a/source/blender/gpu/GPU_matrix.h b/source/blender/gpu/GPU_matrix.h
index a3fd75b662b..f22c0cd5c4d 100644
--- a/source/blender/gpu/GPU_matrix.h
+++ b/source/blender/gpu/GPU_matrix.h
@@ -33,13 +33,13 @@
#define __GPU_MATRIX_H__
#include "BLI_sys_types.h"
-#include "GPU_glew.h"
-#include "../../../intern/gawain/gawain/shader_interface.h"
#ifdef __cplusplus
extern "C" {
#endif
+struct Gwn_ShaderInterface;
+
void gpuMatrixReset(void); /* to Identity transform & empty stack */
/* ModelView Matrix (2D or 3D) */
@@ -111,9 +111,19 @@ const float (*gpuGetNormalMatrixInverse(float m[3][3]))[3];
/* set uniform values for currently bound shader */
-void gpuBindMatrices(const Gwn_ShaderInterface*);
+void gpuBindMatrices(const struct Gwn_ShaderInterface *);
bool gpuMatricesDirty(void); /* since last bind */
+
+/* Python API needs to be able to inspect the stack so errors raise exceptions instead of crashing. */
+#ifdef USE_GPU_PY_MATRIX_API
+int GPU_matrix_stack_level_get_model_view(void);
+int GPU_matrix_stack_level_get_projection(void);
+/* static assert ensures this doesn't change! */
+#define GPU_PY_MATRIX_STACK_LEN 31
+#endif /* USE_GPU_PY_MATRIX_API */
+
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/gpu/GPU_select.h b/source/blender/gpu/GPU_select.h
index cf5b8bf7d8f..0617d58f3b6 100644
--- a/source/blender/gpu/GPU_select.h
+++ b/source/blender/gpu/GPU_select.h
@@ -56,4 +56,7 @@ void GPU_select_cache_begin(void);
void GPU_select_cache_load_id(void);
void GPU_select_cache_end(void);
+/* utilities */
+const uint *GPU_select_buffer_near(const uint *buffer, int hits);
+
#endif
diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h
index 05949d759a4..f3de3240c26 100644
--- a/source/blender/gpu/GPU_shader.h
+++ b/source/blender/gpu/GPU_shader.h
@@ -76,6 +76,7 @@ void *GPU_fx_shader_get_interface(GPUShader *shader);
void GPU_fx_shader_set_interface(GPUShader *shader, void *interface);
int GPU_shader_get_uniform(GPUShader *shader, const char *name);
+int GPU_shader_get_builtin_uniform(GPUShader *shader, int builtin);
int GPU_shader_get_uniform_block(GPUShader *shader, const char *name);
void GPU_shader_uniform_vector(GPUShader *shader, int location, int length,
int arraysize, const float *value);
@@ -118,6 +119,7 @@ typedef enum GPUBuiltinShader {
GPU_SHADER_2D_DIAG_STRIPES,
/* for simple 3D drawing */
GPU_SHADER_3D_UNIFORM_COLOR,
+ GPU_SHADER_3D_UNIFORM_COLOR_U32,
GPU_SHADER_3D_UNIFORM_COLOR_INSTANCE,
GPU_SHADER_3D_FLAT_COLOR,
GPU_SHADER_3D_FLAT_COLOR_U32, /* use for select-id's */
@@ -146,8 +148,8 @@ typedef enum GPUBuiltinShader {
GPU_SHADER_3D_POINT_VARYING_SIZE_UNIFORM_COLOR,
GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR,
/* lines */
- GPU_SHADER_2D_LINE_DASHED_COLOR,
- GPU_SHADER_3D_LINE_DASHED_COLOR,
+ GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR,
+ GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR,
/* lamp drawing */
GPU_SHADER_3D_GROUNDPOINT,
GPU_SHADER_3D_GROUNDLINE,
diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h
index 6d6c195c175..fa8ed992c72 100644
--- a/source/blender/gpu/GPU_texture.h
+++ b/source/blender/gpu/GPU_texture.h
@@ -69,6 +69,7 @@ typedef enum GPUTextureFormat {
GPU_RG16F,
GPU_R32F,
GPU_R16F,
+ GPU_RG8,
GPU_R8,
#if 0
GPU_RGBA32I,
@@ -83,7 +84,6 @@ typedef enum GPUTextureFormat {
GPU_RG16,
GPU_RG16I,
GPU_RG16UI,
- GPU_RG8,
GPU_RG8I,
GPU_RG8UI,
GPU_R32I,
@@ -167,6 +167,8 @@ GPUTexture *GPU_texture_from_blender(
struct Image *ima, struct ImageUser *iuser, int textarget, bool is_data, double time, int mipmap);
GPUTexture *GPU_texture_from_preview(struct PreviewImage *prv, int mipmap);
+void GPU_texture_update(GPUTexture *tex, const float *pixels);
+
void GPU_invalid_tex_init(void);
void GPU_invalid_tex_bind(int mode);
void GPU_invalid_tex_free(void);
diff --git a/source/blender/gpu/GPU_uniformbuffer.h b/source/blender/gpu/GPU_uniformbuffer.h
index 36b659e30b1..c2480f8ba03 100644
--- a/source/blender/gpu/GPU_uniformbuffer.h
+++ b/source/blender/gpu/GPU_uniformbuffer.h
@@ -32,18 +32,28 @@
#ifndef __GPU_UNIFORMBUFFER_H__
#define __GPU_UNIFORMBUFFER_H__
+struct ListBase;
+
typedef struct GPUUniformBuffer GPUUniformBuffer;
+typedef struct GPUUniformBufferDynamicItem GPUUniformBufferDynamicItem;
GPUUniformBuffer *GPU_uniformbuffer_create(int size, const void *data, char err_out[256]);
+GPUUniformBuffer *GPU_uniformbuffer_dynamic_create(struct ListBase *inputs, char err_out[256]);
+
void GPU_uniformbuffer_free(GPUUniformBuffer *ubo);
void GPU_uniformbuffer_update(GPUUniformBuffer *ubo, const void *data);
+void GPU_uniformbuffer_dynamic_update(GPUUniformBuffer *ubo_);
void GPU_uniformbuffer_bind(GPUUniformBuffer *ubo, int number);
-#if 0
void GPU_uniformbuffer_unbind(GPUUniformBuffer *ubo);
-#endif
int GPU_uniformbuffer_bindpoint(GPUUniformBuffer *ubo);
+bool GPU_uniformbuffer_is_empty(GPUUniformBuffer *ubo);
+bool GPU_uniformbuffer_is_dirty(GPUUniformBuffer *ubo);
+void GPU_uniformbuffer_tag_dirty(GPUUniformBuffer *ubo);
+
+#define GPU_UBO_BLOCK_NAME "nodeTree"
+
#endif /* __GPU_UNIFORMBUFFER_H__ */
diff --git a/source/blender/gpu/GPU_viewport.h b/source/blender/gpu/GPU_viewport.h
index 2b2a07f50b7..622b3b301e4 100644
--- a/source/blender/gpu/GPU_viewport.h
+++ b/source/blender/gpu/GPU_viewport.h
@@ -101,6 +101,9 @@ void *GPU_viewport_texture_list_get(GPUViewport *viewport);
void GPU_viewport_size_get(const GPUViewport *viewport, int size[2]);
void GPU_viewport_size_set(GPUViewport *viewport, const int size[2]);
+void GPU_viewport_tag_update(GPUViewport *viewport);
+bool GPU_viewport_do_update(GPUViewport *viewport);
+
/* Texture pool */
GPUTexture *GPU_viewport_texture_pool_query(GPUViewport *viewport, void *engine, int width, int height, int channels, int format);
diff --git a/source/blender/gpu/intern/gpu_batch.c b/source/blender/gpu/intern/gpu_batch.c
index 92bab13dcb5..5d347fc80e8 100644
--- a/source/blender/gpu/intern/gpu_batch.c
+++ b/source/blender/gpu/intern/gpu_batch.c
@@ -31,7 +31,7 @@
#include "GPU_batch.h"
#include "gpu_shader_private.h"
-void Batch_set_builtin_program(Gwn_Batch *batch, GPUBuiltinShader shader_id)
+void GWN_batch_program_set_builtin(Gwn_Batch *batch, GPUBuiltinShader shader_id)
{
GPUShader *shader = GPU_shader_get_builtin_shader(shader_id);
GWN_batch_program_set(batch, shader->program, shader->interface);
@@ -93,7 +93,7 @@ static Gwn_Batch *batch_sphere(int lat_res, int lon_res)
}
}
- return GWN_batch_create(GWN_PRIM_TRIS, vbo, NULL);
+ return GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
static Gwn_Batch *batch_sphere_wire(int lat_res, int lon_res)
@@ -125,10 +125,10 @@ static Gwn_Batch *batch_sphere_wire(int lat_res, int lon_res)
}
}
- return GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
+ return GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
}
-Gwn_Batch *Batch_get_sphere(int lod)
+Gwn_Batch *GPU_batch_preset_sphere(int lod)
{
BLI_assert(lod >= 0 && lod <= 2);
@@ -140,7 +140,7 @@ Gwn_Batch *Batch_get_sphere(int lod)
return sphere_high;
}
-Gwn_Batch *Batch_get_sphere_wire(int lod)
+Gwn_Batch *GPU_batch_preset_sphere_wire(int lod)
{
BLI_assert(lod >= 0 && lod <= 1);
@@ -163,9 +163,9 @@ void gpu_batch_init(void)
void gpu_batch_exit(void)
{
- GWN_batch_discard_all(sphere_low);
- GWN_batch_discard_all(sphere_med);
- GWN_batch_discard_all(sphere_high);
- GWN_batch_discard_all(sphere_wire_low);
- GWN_batch_discard_all(sphere_wire_med);
+ GWN_batch_discard(sphere_low);
+ GWN_batch_discard(sphere_med);
+ GWN_batch_discard(sphere_high);
+ GWN_batch_discard(sphere_wire_low);
+ GWN_batch_discard(sphere_wire_med);
}
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index fb2e271f9a2..3a6b0a2a72d 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -78,13 +78,13 @@ typedef struct {
static size_t gpu_buffer_size_from_type(DerivedMesh *dm, GPUBufferType type);
-const GPUBufferTypeSettings gpu_buffer_type_settings[] = {
+static const GPUBufferTypeSettings gpu_buffer_type_settings[] = {
/* vertex */
{GL_ARRAY_BUFFER, 3},
/* normal */
{GL_ARRAY_BUFFER, 4}, /* we copy 3 shorts per normal but we add a fourth for alignment */
/* mcol */
- {GL_ARRAY_BUFFER, 3},
+ {GL_ARRAY_BUFFER, 4},
/* uv */
{GL_ARRAY_BUFFER, 2},
/* uv for texpaint */
@@ -691,7 +691,7 @@ void GPU_color_setup(DerivedMesh *dm, int colType)
glEnableClientState(GL_COLOR_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, dm->drawObject->colors->id);
- glColorPointer(3, GL_UNSIGNED_BYTE, 0, 0);
+ glColorPointer(4, GL_UNSIGNED_BYTE, 0, 0);
GLStates |= GPU_BUFFER_COLOR_STATE;
}
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index 1f0f5e375ce..b5a7d751f2a 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -36,6 +36,7 @@
#include "DNA_customdata_types.h"
#include "DNA_image_types.h"
#include "DNA_material_types.h"
+#include "DNA_node_types.h"
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
@@ -47,6 +48,7 @@
#include "GPU_material.h"
#include "GPU_shader.h"
#include "GPU_texture.h"
+#include "GPU_uniformbuffer.h"
#include "BLI_sys_types.h" /* for intptr_t support */
@@ -88,7 +90,7 @@ typedef struct GPUFunction {
/* Indices match the GPUType enum */
static const char *GPU_DATATYPE_STR[17] = {
"", "float", "vec2", "vec3", "vec4",
- NULL, NULL, NULL, NULL, "mat3", NULL, NULL, NULL, NULL, NULL, NULL, "mat4",
+ NULL, NULL, NULL, NULL, "mat3", NULL, NULL, NULL, NULL, NULL, NULL, "mat4"
};
/* GLSL code parsing for finding function definitions.
@@ -172,7 +174,7 @@ static void gpu_parse_functions_string(GHash *hash, char *code)
/* test for type */
type = GPU_NONE;
- for (i = 1; i <= 16; i++) {
+ for (i = 1; i < ARRAY_SIZE(GPU_DATATYPE_STR); i++) {
if (GPU_DATATYPE_STR[i] && gpu_str_prefix(code, GPU_DATATYPE_STR[i])) {
type = i;
break;
@@ -189,6 +191,10 @@ static void gpu_parse_functions_string(GHash *hash, char *code)
type = GPU_TEX2D;
}
+ if (!type && gpu_str_prefix(code, "Closure")) {
+ type = GPU_CLOSURE;
+ }
+
if (type) {
/* add parameter */
code = gpu_str_skip_token(code, NULL, 0);
@@ -350,6 +356,8 @@ static void codegen_convert_datatype(DynStr *ds, int from, int to, const char *t
BLI_dynstr_appendf(ds, "vec4(%s.r, %s.r, %s.r, %s.g)", name, name, name, name);
else if (from == GPU_FLOAT)
BLI_dynstr_appendf(ds, "vec4(%s, %s, %s, 1.0)", name, name, name);
+ else /* can happen with closure */
+ BLI_dynstr_append(ds, name);
}
}
@@ -500,12 +508,16 @@ static void codegen_set_unique_ids(ListBase *nodes)
BLI_ghash_free(definehash, NULL, NULL);
}
-static int codegen_print_uniforms_functions(DynStr *ds, ListBase *nodes)
+/**
+ * It will create an UBO for GPUMaterial if there is any GPU_DYNAMIC_UBO.
+ */
+static int codegen_process_uniforms_functions(GPUMaterial *material, DynStr *ds, ListBase *nodes)
{
GPUNode *node;
GPUInput *input;
const char *name;
int builtins = 0;
+ ListBase ubo_inputs = {NULL, NULL};
/* print uniforms */
for (node = nodes->first; node; node = node->next) {
@@ -536,14 +548,23 @@ static int codegen_print_uniforms_functions(DynStr *ds, ListBase *nodes)
}
}
}
+ else if (input->source == GPU_SOURCE_STRUCT) {
+ /* Add other struct here if needed. */
+ BLI_dynstr_appendf(ds, "Closure strct%d = CLOSURE_DEFAULT;\n", input->id);
+ }
else if (input->source == GPU_SOURCE_VEC_UNIFORM) {
- if (input->dynamicvec) {
+ if (input->dynamictype == GPU_DYNAMIC_UBO) {
+ if (!input->link) {
+ /* We handle the UBOuniforms separately. */
+ BLI_addtail(&ubo_inputs, BLI_genericNodeN(input));
+ }
+ }
+ else if (input->dynamicvec) {
/* only create uniforms for dynamic vectors */
BLI_dynstr_appendf(ds, "uniform %s unf%d;\n",
GPU_DATATYPE_STR[input->type], input->id);
}
else {
- /* for others use const so the compiler can do folding */
BLI_dynstr_appendf(ds, "const %s cons%d = ",
GPU_DATATYPE_STR[input->type], input->id);
codegen_print_datatype(ds, input->type, input->vec);
@@ -569,6 +590,22 @@ static int codegen_print_uniforms_functions(DynStr *ds, ListBase *nodes)
}
}
+ /* Handle the UBO block separately. */
+ if ((material != NULL) && !BLI_listbase_is_empty(&ubo_inputs)) {
+ GPU_material_create_uniform_buffer(material, &ubo_inputs);
+
+ /* Inputs are sorted */
+ BLI_dynstr_appendf(ds, "\nlayout (std140) uniform %s {\n", GPU_UBO_BLOCK_NAME);
+
+ for (LinkData *link = ubo_inputs.first; link; link = link->next) {
+ input = link->data;
+ BLI_dynstr_appendf(ds, "\t%s unf%d;\n",
+ GPU_DATATYPE_STR[input->type], input->id);
+ }
+ BLI_dynstr_append(ds, "};\n");
+ BLI_freelistN(&ubo_inputs);
+ }
+
BLI_dynstr_append(ds, "\n");
return builtins;
@@ -594,8 +631,13 @@ static void codegen_declare_tmps(DynStr *ds, ListBase *nodes)
/* declare temporary variables for node output storage */
for (output = node->outputs.first; output; output = output->next) {
- BLI_dynstr_appendf(ds, "\t%s tmp%d;\n",
- GPU_DATATYPE_STR[output->type], output->id);
+ if (output->type == GPU_CLOSURE) {
+ BLI_dynstr_appendf(ds, "\tClosure tmp%d;\n", output->id);
+ }
+ else {
+ BLI_dynstr_appendf(ds, "\t%s tmp%d;\n",
+ GPU_DATATYPE_STR[output->type], output->id);
+ }
}
}
@@ -639,6 +681,9 @@ static void codegen_call_functions(DynStr *ds, ListBase *nodes, GPUOutput *final
else
BLI_dynstr_append(ds, GPU_builtin_name(input->builtin));
}
+ else if (input->source == GPU_SOURCE_STRUCT) {
+ BLI_dynstr_appendf(ds, "strct%d", input->id);
+ }
else if (input->source == GPU_SOURCE_VEC_UNIFORM) {
if (input->dynamicvec)
BLI_dynstr_appendf(ds, "unf%d", input->id);
@@ -667,12 +712,11 @@ static void codegen_call_functions(DynStr *ds, ListBase *nodes, GPUOutput *final
BLI_dynstr_append(ds, ");\n");
}
- BLI_dynstr_append(ds, "\n\tfragColor = ");
- codegen_convert_datatype(ds, finaloutput->type, GPU_VEC4, "tmp", finaloutput->id);
+ BLI_dynstr_appendf(ds, "\n\treturn tmp%d", finaloutput->id);
BLI_dynstr_append(ds, ";\n");
}
-static char *code_generate_fragment(ListBase *nodes, GPUOutput *output, bool use_new_shading)
+static char *code_generate_fragment(GPUMaterial *material, ListBase *nodes, GPUOutput *output, bool use_new_shading)
{
DynStr *ds = BLI_dynstr_new();
char *code;
@@ -689,14 +733,14 @@ static char *code_generate_fragment(ListBase *nodes, GPUOutput *output, bool use
#endif
codegen_set_unique_ids(nodes);
- builtins = codegen_print_uniforms_functions(ds, nodes);
+ builtins = codegen_process_uniforms_functions(material, ds, nodes);
#if 0
if (G.debug & G_DEBUG)
BLI_dynstr_appendf(ds, "/* %s */\n", name);
#endif
- BLI_dynstr_append(ds, "void main()\n{\n");
+ BLI_dynstr_append(ds, "Closure nodetree_exec(void)\n{\n");
if (use_new_shading) {
if (builtins & GPU_VIEW_MATRIX)
@@ -764,6 +808,17 @@ static char *code_generate_fragment(ListBase *nodes, GPUOutput *output, bool use
BLI_dynstr_append(ds, "}\n");
+ /* XXX This cannot go into gpu_shader_material.glsl because main() would be parsed and generate error */
+ /* Old glsl mode compat. */
+ BLI_dynstr_append(ds, "#ifndef NODETREE_EXEC\n");
+ BLI_dynstr_append(ds, "out vec4 fragColor;\n");
+ BLI_dynstr_append(ds, "void main()\n");
+ BLI_dynstr_append(ds, "{\n");
+ BLI_dynstr_append(ds, "\tClosure cl = nodetree_exec();\n");
+ BLI_dynstr_append(ds, "\tfragColor = vec4(cl.radiance, cl.opacity);\n");
+ BLI_dynstr_append(ds, "}\n");
+ BLI_dynstr_append(ds, "#endif\n\n");
+
/* create shader */
code = BLI_dynstr_get_cstring(ds);
BLI_dynstr_free(ds);
@@ -787,7 +842,7 @@ static const char *attrib_prefix_get(CustomDataType type)
}
}
-static char *code_generate_vertex_new(ListBase *nodes, const char *vert_code)
+static char *code_generate_vertex_new(ListBase *nodes, const char *vert_code, bool use_geom)
{
DynStr *ds = BLI_dynstr_new();
GPUNode *node;
@@ -814,8 +869,8 @@ static char *code_generate_vertex_new(ListBase *nodes, const char *vert_code)
BLI_dynstr_appendf(ds, "#define att%d %s%u\n",
input->attribid, attrib_prefix_get(input->attribtype), hash);
}
- BLI_dynstr_appendf(ds, "out %s var%d;\n",
- GPU_DATATYPE_STR[input->type], input->attribid);
+ BLI_dynstr_appendf(ds, "out %s var%d%s;\n",
+ GPU_DATATYPE_STR[input->type], input->attribid, use_geom ? "g" : "");
}
}
}
@@ -831,19 +886,19 @@ static char *code_generate_vertex_new(ListBase *nodes, const char *vert_code)
if (input->source == GPU_SOURCE_ATTRIB && input->attribfirst) {
if (input->attribtype == CD_TANGENT) { /* silly exception */
BLI_dynstr_appendf(
- ds, "\tvar%d.xyz = normalize(NormalMatrix * att%d.xyz);\n",
- input->attribid, input->attribid);
+ ds, "\tvar%d%s.xyz = normalize(NormalMatrix * att%d.xyz);\n",
+ input->attribid, use_geom ? "g" : "", input->attribid);
BLI_dynstr_appendf(
- ds, "\tvar%d.w = att%d.w;\n",
- input->attribid, input->attribid);
+ ds, "\tvar%d%s.w = att%d.w;\n",
+ input->attribid, use_geom ? "g" : "", input->attribid);
}
else if (input->attribtype == CD_ORCO) {
- BLI_dynstr_appendf(ds, "\tvar%d = OrcoTexCoFactors[0] + position * OrcoTexCoFactors[1];\n",
- input->attribid);
+ BLI_dynstr_appendf(ds, "\tvar%d%s = OrcoTexCoFactors[0] + position * OrcoTexCoFactors[1];\n",
+ input->attribid, use_geom ? "g" : "");
}
else {
- BLI_dynstr_appendf(ds, "\tvar%d = att%d;\n",
- input->attribid, input->attribid);
+ BLI_dynstr_appendf(ds, "\tvar%d%s = att%d;\n",
+ input->attribid, use_geom ? "g" : "", input->attribid);
}
}
}
@@ -972,6 +1027,51 @@ static char *code_generate_vertex(ListBase *nodes, const GPUMatType type)
return code;
}
+static char *code_generate_geometry_new(ListBase *nodes, const char *geom_code)
+{
+ DynStr *ds = BLI_dynstr_new();
+ GPUNode *node;
+ GPUInput *input;
+ char *code;
+
+ /* Create prototype because attributes cannot be declared before layout. */
+ BLI_dynstr_appendf(ds, "void pass_attrib(in int vert);\n");
+ BLI_dynstr_append(ds, "#define ATTRIB\n");
+
+ BLI_dynstr_append(ds, geom_code);
+
+ /* Generate varying declarations. */
+ for (node = nodes->first; node; node = node->next) {
+ for (input = node->inputs.first; input; input = input->next) {
+ if (input->source == GPU_SOURCE_ATTRIB && input->attribfirst) {
+ BLI_dynstr_appendf(ds, "in %s var%dg[];\n",
+ GPU_DATATYPE_STR[input->type],
+ input->attribid);
+ BLI_dynstr_appendf(ds, "out %s var%d;\n",
+ GPU_DATATYPE_STR[input->type],
+ input->attribid);
+ }
+ }
+ }
+
+ /* Generate varying assignments. */
+ BLI_dynstr_appendf(ds, "void pass_attrib(in int vert) {\n");
+ for (node = nodes->first; node; node = node->next) {
+ for (input = node->inputs.first; input; input = input->next) {
+ if (input->source == GPU_SOURCE_ATTRIB && input->attribfirst) {
+ /* TODO let shader choose what to do depending on what the attrib is. */
+ BLI_dynstr_appendf(ds, "\tvar%d = var%dg[vert];\n", input->attribid, input->attribid);
+ }
+ }
+ }
+ BLI_dynstr_append(ds, "}\n");
+
+ code = BLI_dynstr_get_cstring(ds);
+ BLI_dynstr_free(ds);
+
+ return code;
+}
+
static char *code_generate_geometry(ListBase *nodes, bool use_opensubdiv)
{
#ifdef WITH_OPENSUBDIV
@@ -1327,7 +1427,7 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, const GPUType
name = outnode->name;
input = outnode->inputs.first;
- if ((STREQ(name, "set_value") || STREQ(name, "set_rgb")) &&
+ if ((STREQ(name, "set_value") || STREQ(name, "set_rgb") || STREQ(name, "set_rgba")) &&
(input->type == type))
{
input = MEM_dupallocN(outnode->inputs.first);
@@ -1427,6 +1527,12 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, const GPUType
BLI_strncpy(input->attribname, link->attribname, sizeof(input->attribname));
MEM_freeN(link);
}
+ else if (type == GPU_CLOSURE) {
+ input->type = type;
+ input->source = GPU_SOURCE_STRUCT;
+
+ MEM_freeN(link);
+ }
else {
/* uniform vector */
input->type = type;
@@ -1438,21 +1544,91 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, const GPUType
input->dynamictype = link->dynamictype;
input->dynamicdata = link->ptr2;
}
+
MEM_freeN(link);
}
BLI_addtail(&node->inputs, input);
}
-static void gpu_node_input_socket(GPUNode *node, GPUNodeStack *sock)
+
+static const char *gpu_uniform_set_function_from_type(eNodeSocketDatatype type)
{
- GPUNodeLink *link;
+ switch (type) {
+ case SOCK_FLOAT:
+ return "set_value";
+ case SOCK_VECTOR:
+ return "set_rgb";
+ case SOCK_RGBA:
+ return "set_rgba";
+ default:
+ BLI_assert(!"No gpu function for non-supported eNodeSocketDatatype");
+ return NULL;
+ }
+}
+/**
+ * Link stack uniform buffer.
+ * This is called for the input/output sockets that are note connected.
+ */
+static GPUNodeLink *gpu_uniformbuffer_link(
+ GPUMaterial *mat, bNode *node, GPUNodeStack *stack, const int index, const eNodeSocketInOut in_out)
+{
+ bNodeSocket *socket;
+ if (in_out == SOCK_IN) {
+ socket = BLI_findlink(&node->original->inputs, index);
+ }
+ else {
+ socket = BLI_findlink(&node->original->outputs, index);
+ }
+
+ BLI_assert(socket != NULL);
+ BLI_assert(socket->in_out == in_out);
+
+ if ((socket->flag & SOCK_HIDE_VALUE) == 0) {
+ GPUNodeLink *link;
+ switch (socket->type) {
+ case SOCK_FLOAT:
+ {
+ bNodeSocketValueFloat *socket_data = socket->default_value;
+ link = GPU_uniform_buffer(&socket_data->value, GPU_FLOAT);
+ break;
+ }
+ case SOCK_VECTOR:
+ {
+ bNodeSocketValueRGBA *socket_data = socket->default_value;
+ link = GPU_uniform_buffer(socket_data->value, GPU_VEC3);
+ break;
+ }
+ case SOCK_RGBA:
+ {
+ bNodeSocketValueRGBA *socket_data = socket->default_value;
+ link = GPU_uniform_buffer(socket_data->value, GPU_VEC4);
+ break;
+ }
+ default:
+ return NULL;
+ break;
+ }
+
+ if (in_out == SOCK_IN) {
+ GPU_link(mat, gpu_uniform_set_function_from_type(socket->type), link, &stack->link);
+ }
+ return link;
+ }
+ return NULL;
+}
+
+static void gpu_node_input_socket(GPUMaterial *material, bNode *bnode, GPUNode *node, GPUNodeStack *sock, const int index)
+{
if (sock->link) {
gpu_node_input_link(node, sock->link, sock->type);
}
+ else if ((material != NULL) && (gpu_uniformbuffer_link(material, bnode, sock, index, SOCK_IN) != NULL)) {
+ gpu_node_input_link(node, sock->link, sock->type);
+ }
else {
- link = GPU_node_link_create();
+ GPUNodeLink *link = GPU_node_link_create();
link->ptr1 = sock->vec;
gpu_node_input_link(node, link, sock->type);
}
@@ -1615,6 +1791,21 @@ GPUNodeLink *GPU_dynamic_uniform(float *num, GPUDynamicType dynamictype, void *d
return link;
}
+/**
+ * Add uniform to UBO struct of GPUMaterial.
+ */
+GPUNodeLink *GPU_uniform_buffer(float *num, GPUType gputype)
+{
+ GPUNodeLink *link = GPU_node_link_create();
+ link->ptr1 = num;
+ link->ptr2 = NULL;
+ link->dynamic = true;
+ link->dynamictype = GPU_DYNAMIC_UBO;
+ link->type = gputype;
+
+ return link;
+}
+
GPUNodeLink *GPU_image(Image *ima, ImageUser *iuser, bool is_data)
{
GPUNodeLink *link = GPU_node_link_create();
@@ -1725,7 +1916,7 @@ bool GPU_link(GPUMaterial *mat, const char *name, ...)
return true;
}
-bool GPU_stack_link(GPUMaterial *mat, const char *name, GPUNodeStack *in, GPUNodeStack *out, ...)
+bool GPU_stack_link(GPUMaterial *material, bNode *bnode, const char *name, GPUNodeStack *in, GPUNodeStack *out, ...)
{
GPUNode *node;
GPUFunction *function;
@@ -1745,11 +1936,11 @@ bool GPU_stack_link(GPUMaterial *mat, const char *name, GPUNodeStack *in, GPUNod
if (in) {
for (i = 0; in[i].type != GPU_NONE; i++) {
- gpu_node_input_socket(node, &in[i]);
+ gpu_node_input_socket(material, bnode, node, &in[i], i);
totin++;
}
}
-
+
if (out) {
for (i = 0; out[i].type != GPU_NONE; i++) {
gpu_node_output(node, out[i].type, &out[i].link);
@@ -1771,7 +1962,7 @@ bool GPU_stack_link(GPUMaterial *mat, const char *name, GPUNodeStack *in, GPUNod
if (totin == 0) {
link = va_arg(params, GPUNodeLink *);
if (link->socket)
- gpu_node_input_socket(node, link->socket);
+ gpu_node_input_socket(NULL, NULL, node, link->socket, -1);
else
gpu_node_input_link(node, link, function->paramtype[i]);
}
@@ -1781,8 +1972,8 @@ bool GPU_stack_link(GPUMaterial *mat, const char *name, GPUNodeStack *in, GPUNod
}
va_end(params);
- gpu_material_add_node(mat, node);
-
+ gpu_material_add_node(material, node);
+
return true;
}
@@ -1807,6 +1998,11 @@ int GPU_link_changed(GPUNodeLink *link)
return 0;
}
+GPUNodeLink *GPU_uniformbuffer_link_out(GPUMaterial *mat, bNode *node, GPUNodeStack *stack, const int index)
+{
+ return gpu_uniformbuffer_link(mat, node, stack, index, SOCK_OUT);
+}
+
/* Pass create/free */
static void gpu_nodes_tag(GPUNodeLink *link)
@@ -1846,32 +2042,37 @@ static void gpu_nodes_prune(ListBase *nodes, GPUNodeLink *outlink)
}
}
-GPUPass *GPU_generate_pass_new(ListBase *nodes, struct GPUNodeLink *frag_outlink,
- const char *vert_code, const char *geom_code,
- const char *frag_lib, const char *defines)
+GPUPass *GPU_generate_pass_new(
+ struct GPUMaterial *material,
+ ListBase *nodes, struct GPUNodeLink *frag_outlink,
+ GPUVertexAttribs *attribs,
+ const char *vert_code, const char *geom_code,
+ const char *frag_lib, const char *defines)
{
GPUShader *shader;
GPUPass *pass;
- char *vertexgen, *geometrygen, *fragmentgen, *tmp;
+ char *vertexgen, *fragmentgen, *tmp;
char *vertexcode, *geometrycode, *fragmentcode;
/* prune unused nodes */
gpu_nodes_prune(nodes, frag_outlink);
- /* Hacky */
- GPUVertexAttribs attribs;
- gpu_nodes_get_vertex_attributes(nodes, &attribs);
+ gpu_nodes_get_vertex_attributes(nodes, attribs);
/* generate code and compile with opengl */
- fragmentgen = code_generate_fragment(nodes, frag_outlink->output, true);
- vertexgen = code_generate_vertex_new(nodes, vert_code);
- // geometrygen = code_generate_geometry(nodes, false);
- UNUSED_VARS(geometrygen);
+ fragmentgen = code_generate_fragment(material, nodes, frag_outlink->output, true);
+ vertexgen = code_generate_vertex_new(nodes, vert_code, (geom_code != NULL));
tmp = BLI_strdupcat(frag_lib, glsl_material_library);
fragmentcode = BLI_strdupcat(tmp, fragmentgen);
vertexcode = BLI_strdup(vertexgen);
- geometrycode = (geom_code) ? BLI_strdup(geom_code) : NULL;
+
+ if (geom_code) {
+ geometrycode = code_generate_geometry_new(nodes, geom_code);
+ }
+ else {
+ geometrycode = NULL;
+ }
shader = GPU_shader_create(vertexcode,
fragmentcode,
@@ -1938,7 +2139,7 @@ GPUPass *GPU_generate_pass(
gpu_nodes_get_builtin_flag(nodes, builtins);
/* generate code and compile with opengl */
- fragmentcode = code_generate_fragment(nodes, outlink->output, false);
+ fragmentcode = code_generate_fragment(NULL, nodes, outlink->output, false);
vertexcode = code_generate_vertex(nodes, type);
geometrycode = code_generate_geometry(nodes, use_opensubdiv);
diff --git a/source/blender/gpu/intern/gpu_codegen.h b/source/blender/gpu/intern/gpu_codegen.h
index 9263fe3bc3f..14e07a6e012 100644
--- a/source/blender/gpu/intern/gpu_codegen.h
+++ b/source/blender/gpu/intern/gpu_codegen.h
@@ -57,7 +57,8 @@ typedef enum GPUDataSource {
GPU_SOURCE_OPENGL_BUILTIN,
GPU_SOURCE_TEX_PIXEL,
GPU_SOURCE_TEX,
- GPU_SOURCE_ATTRIB
+ GPU_SOURCE_ATTRIB,
+ GPU_SOURCE_STRUCT
} GPUDataSource;
typedef enum {
@@ -167,14 +168,18 @@ struct GPUPass {
typedef struct GPUPass GPUPass;
-GPUPass *GPU_generate_pass_new(ListBase *nodes, struct GPUNodeLink *frag_outlink,
- const char *vert_code, const char *geom_code,
- const char *frag_lib, const char *defines);
-GPUPass *GPU_generate_pass(ListBase *nodes, struct GPUNodeLink *outlink,
- struct GPUVertexAttribs *attribs, int *builtin,
- const GPUMatType type, const char *name,
- const bool use_opensubdiv,
- const bool use_new_shading);
+GPUPass *GPU_generate_pass_new(
+ struct GPUMaterial *material,
+ ListBase *nodes, struct GPUNodeLink *frag_outlink,
+ struct GPUVertexAttribs *attribs,
+ const char *vert_code, const char *geom_code,
+ const char *frag_lib, const char *defines);
+GPUPass *GPU_generate_pass(
+ ListBase *nodes, struct GPUNodeLink *outlink,
+ struct GPUVertexAttribs *attribs, int *builtin,
+ const GPUMatType type, const char *name,
+ const bool use_opensubdiv,
+ const bool use_new_shading);
struct GPUShader *GPU_pass_shader(GPUPass *pass);
diff --git a/source/blender/gpu/intern/gpu_compositing.c b/source/blender/gpu/intern/gpu_compositing.c
index afd28aece12..12ed67cdf4e 100644
--- a/source/blender/gpu/intern/gpu_compositing.c
+++ b/source/blender/gpu/intern/gpu_compositing.c
@@ -281,11 +281,11 @@ GPUFX *GPU_fx_compositor_create(void)
}
Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
GWN_vertbuf_data_alloc(vbo, 4);
- for (int i = 0; i < 4; ++i) {
+ for (int i = 0; i < 4; ++i) {
GWN_vertbuf_attr_set(vbo, pos, i, fullscreencos[i]);
GWN_vertbuf_attr_set(vbo, uvs, i, fullscreenuvs[i]);
}
- fx->quad_batch = GWN_batch_create(GWN_PRIM_TRI_STRIP, vbo, NULL);
+ fx->quad_batch = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO);
/* Point Buffer */
static Gwn_VertFormat format_point = {0};
@@ -297,7 +297,7 @@ GPUFX *GPU_fx_compositor_create(void)
Gwn_VertBuf *vbo_point = GWN_vertbuf_create_with_format(&format_point);
GWN_vertbuf_data_alloc(vbo_point, 1);
GWN_vertbuf_attr_set(vbo_point, dummy_attrib, 0, &dummy);
- fx->point_batch = GWN_batch_create(GWN_PRIM_POINTS, vbo_point, NULL);
+ fx->point_batch = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo_point, NULL, GWN_BATCH_OWNS_VBO);
return fx;
}
@@ -387,8 +387,8 @@ static void cleanup_fx_gl_data(GPUFX *fx, bool do_fbo)
void GPU_fx_compositor_destroy(GPUFX *fx)
{
cleanup_fx_gl_data(fx, true);
- GWN_batch_discard_all(fx->quad_batch);
- GWN_batch_discard_all(fx->point_batch);
+ GWN_batch_discard(fx->quad_batch);
+ GWN_batch_discard(fx->point_batch);
MEM_freeN(fx);
}
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index 9ed6f387e90..cc6afe983ca 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -446,8 +446,6 @@ static void gpu_verify_high_bit_srgb_buffer_slice(float *srgb_frect,
ibuf->x, height,
ibuf->x, ibuf->x);
IMB_buffer_float_unpremultiply(current_srgb_frect, ibuf->x, height);
- /* Clamp buffer colors to 1.0 to avoid artifacts due to glu for hdr images. */
- IMB_buffer_float_clamp(current_srgb_frect, ibuf->x, height);
}
static void verify_thread_do(void *data_v,
@@ -581,10 +579,10 @@ int GPU_verify_image(
if (do_color_management) {
srgb_frect = MEM_mallocN(ibuf->x * ibuf->y * sizeof(float) * 4, "floar_buf_col_cor");
gpu_verify_high_bit_srgb_buffer(srgb_frect, ibuf);
- frect = srgb_frect + texwinsy * ibuf->x + texwinsx;
+ frect = srgb_frect + (4 * (texwinsy * ibuf->x + texwinsx));
}
else {
- frect = ibuf->rect_float + texwinsy * ibuf->x + texwinsx;
+ frect = ibuf->rect_float + (ibuf->channels * (texwinsy * ibuf->x + texwinsx));
}
}
else {
@@ -1282,7 +1280,7 @@ void GPU_create_smoke(SmokeModifierData *smd, int highres)
}
sds->tex_flame = (smoke_turbulence_has_fuel(sds->wt)) ?
GPU_texture_create_3D_custom(sds->res_wt[0], sds->res_wt[1], sds->res_wt[2], 1,
- GPU_R8, smoke_turbulence_get_flame(sds->wt), NULL):
+ GPU_R8, smoke_turbulence_get_flame(sds->wt), NULL) :
NULL;
}
@@ -2025,7 +2023,7 @@ int GPU_scene_object_lights(SceneLayer *sl, float viewmat[4][4], int ortho)
int count = 0;
- for (Base *base = FIRSTBASE_NEW; base; base = base->next) {
+ for (Base *base = FIRSTBASE_NEW(sl); base; base = base->next) {
if (base->object->type != OB_LAMP)
continue;
@@ -2427,7 +2425,8 @@ void gpuPushAttrib(eGPUAttribMask mask)
AttribStack.top++;
}
-static void restore_mask(GLenum cap, const bool value) {
+static void restore_mask(GLenum cap, const bool value)
+{
if (value) {
glEnable(cap);
}
diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c
index ddf0e83309c..6b19cea464b 100644
--- a/source/blender/gpu/intern/gpu_framebuffer.c
+++ b/source/blender/gpu/intern/gpu_framebuffer.c
@@ -348,6 +348,10 @@ void GPU_framebuffer_bind(GPUFrameBuffer *fb)
glReadBuffer(readattachement);
}
+ if (GPU_texture_target(tex) == GL_TEXTURE_2D_MULTISAMPLE) {
+ glEnable(GL_MULTISAMPLE);
+ }
+
glViewport(0, 0, GPU_texture_width(tex), GPU_texture_height(tex));
GG.currentfb = fb->object;
}
@@ -480,7 +484,7 @@ void GPU_framebuffer_blur(
GPU_texture_bind(tex, 0);
- Batch_set_builtin_program(&batch, GPU_SHADER_SEP_GAUSSIAN_BLUR);
+ GWN_batch_program_set_builtin(&batch, GPU_SHADER_SEP_GAUSSIAN_BLUR);
GWN_batch_uniform_2f(&batch, "ScaleU", scaleh[0], scaleh[1]);
GWN_batch_uniform_1i(&batch, "textureSource", GL_TEXTURE0);
GWN_batch_draw(&batch);
@@ -496,7 +500,7 @@ void GPU_framebuffer_blur(
GPU_texture_bind(blurtex, 0);
/* Hack to make the following uniform stick */
- Batch_set_builtin_program(&batch, GPU_SHADER_SEP_GAUSSIAN_BLUR);
+ GWN_batch_program_set_builtin(&batch, GPU_SHADER_SEP_GAUSSIAN_BLUR);
GWN_batch_uniform_2f(&batch, "ScaleU", scalev[0], scalev[1]);
GWN_batch_uniform_1i(&batch, "textureSource", GL_TEXTURE0);
GWN_batch_draw(&batch);
@@ -519,16 +523,17 @@ void GPU_framebuffer_blit(GPUFrameBuffer *fb_read, int read_slot, GPUFrameBuffer
glBindFramebuffer(GL_READ_FRAMEBUFFER, fb_read->object);
glFramebufferTexture2D(
GL_READ_FRAMEBUFFER, read_attach,
- GL_TEXTURE_2D, read_bind, 0);
+ GPU_texture_target(read_tex), read_bind, 0);
BLI_assert(glCheckFramebufferStatus(GL_READ_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
/* write into new single-sample buffer */
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fb_write->object);
glFramebufferTexture2D(
GL_DRAW_FRAMEBUFFER, write_attach,
- GL_TEXTURE_2D, write_bind, 0);
+ GPU_texture_target(write_tex), write_bind, 0);
BLI_assert(glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
+ glDrawBuffer((use_depth) ? GL_COLOR_ATTACHMENT0 : read_attach);
glBlitFramebuffer(0, 0, read_w, read_h, 0, 0, write_w, write_h, (use_depth) ? GL_DEPTH_BUFFER_BIT : GL_COLOR_BUFFER_BIT, GL_NEAREST);
/* Restore previous framebuffer */
@@ -543,6 +548,7 @@ void GPU_framebuffer_blit(GPUFrameBuffer *fb_read, int read_slot, GPUFrameBuffer
void GPU_framebuffer_recursive_downsample(
GPUFrameBuffer *fb, GPUTexture *tex, int num_iter, void (*callback)(void *userData, int level), void *userData)
{
+ int i;
int current_dim[2] = {GPU_texture_width(tex), GPU_texture_height(tex)};
GLenum attachment;
@@ -558,10 +564,16 @@ void GPU_framebuffer_recursive_downsample(
attachment = GL_COLOR_ATTACHMENT0;
/* last bound prevails here, better allow explicit control here too */
- glDrawBuffer(GL_COLOR_ATTACHMENT0);
- glReadBuffer(GL_COLOR_ATTACHMENT0);
+ if (GPU_texture_depth(tex)) {
+ glDrawBuffer(GL_NONE);
+ glReadBuffer(GL_NONE);
+ }
+ else {
+ glDrawBuffer(GL_COLOR_ATTACHMENT0);
+ glReadBuffer(GL_COLOR_ATTACHMENT0);
+ }
- for (int i=1; i < num_iter+1 && (current_dim[0] > 1 && current_dim[1] > 1); i++) {
+ for (i = 1; i < num_iter + 1 && (current_dim[0] > 4 && current_dim[1] > 4); i++) {
/* calculate next viewport size */
current_dim[0] /= 2;
@@ -575,11 +587,11 @@ void GPU_framebuffer_recursive_downsample(
/* bind next level for rendering but first restrict fetches only to previous level */
GPU_texture_bind(tex, 0);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, i-1);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, i-1);
+ glTexParameteri(GPU_texture_target(tex), GL_TEXTURE_BASE_LEVEL, i - 1);
+ glTexParameteri(GPU_texture_target(tex), GL_TEXTURE_MAX_LEVEL, i - 1);
GPU_texture_unbind(tex);
- glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, GPU_texture_opengl_bindcode(tex), i);
+ glFramebufferTexture(GL_FRAMEBUFFER, attachment, GPU_texture_opengl_bindcode(tex), i);
callback(userData, i);
}
@@ -588,8 +600,8 @@ void GPU_framebuffer_recursive_downsample(
/* reset mipmap level range for the depth image */
GPU_texture_bind(tex, 0);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, num_iter - 1);
+ glTexParameteri(GPU_texture_target(tex), GL_TEXTURE_BASE_LEVEL, 0);
+ glTexParameteri(GPU_texture_target(tex), GL_TEXTURE_MAX_LEVEL, i - 1);
GPU_texture_unbind(tex);
}
diff --git a/source/blender/gpu/intern/gpu_immediate_util.c b/source/blender/gpu/intern/gpu_immediate_util.c
index a4e54d15034..bad878ef4bf 100644
--- a/source/blender/gpu/intern/gpu_immediate_util.c
+++ b/source/blender/gpu/intern/gpu_immediate_util.c
@@ -33,6 +33,39 @@
#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
+static const float cube_coords[8][3] = {
+ {-1, -1, -1},
+ {-1, -1, +1},
+ {-1, +1, -1},
+ {-1, +1, +1},
+ {+1, -1, -1},
+ {+1, -1, +1},
+ {+1, +1, -1},
+ {+1, +1, +1},
+};
+static const int cube_quad_index[6][4] = {
+ {0, 1, 3, 2},
+ {0, 2, 6, 4},
+ {0, 4, 5, 1},
+ {1, 5, 7, 3},
+ {2, 3, 7, 6},
+ {4, 6, 7, 5},
+};
+static const int cube_line_index[12][2] = {
+ {0, 1},
+ {0, 2},
+ {0, 4},
+ {1, 3},
+ {1, 5},
+ {2, 3},
+ {2, 6},
+ {3, 7},
+ {4, 5},
+ {4, 6},
+ {5, 7},
+ {6, 7},
+};
+
/**
* Pack color into 3 bytes
*
@@ -51,12 +84,13 @@ void imm_cpack(unsigned int x)
(((x) >> 16) & 0xFF));
}
-static void imm_draw_circle(Gwn_PrimType prim_type, const uint shdr_pos, float x, float y, float rad, int nsegments)
+static void imm_draw_circle(
+ Gwn_PrimType prim_type, const uint shdr_pos, float x, float y, float rad_x, float rad_y, int nsegments)
{
immBegin(prim_type, nsegments);
for (int i = 0; i < nsegments; ++i) {
- const float angle = 2 * M_PI * ((float)i / (float)nsegments);
- immVertex2f(shdr_pos, x + rad * cosf(angle), y + rad * sinf(angle));
+ const float angle = (float)(2 * M_PI) * ((float)i / (float)nsegments);
+ immVertex2f(shdr_pos, x + (rad_x * cosf(angle)), y + (rad_y * sinf(angle)));
}
immEnd();
}
@@ -71,9 +105,9 @@ static void imm_draw_circle(Gwn_PrimType prim_type, const uint shdr_pos, float x
* \param radius The circle's radius.
* \param nsegments The number of segments to use in drawing (more = smoother).
*/
-void imm_draw_circle_wire(uint shdr_pos, float x, float y, float rad, int nsegments)
+void imm_draw_circle_wire_2d(uint shdr_pos, float x, float y, float rad, int nsegments)
{
- imm_draw_circle(GWN_PRIM_LINE_LOOP, shdr_pos, x, y, rad, nsegments);
+ imm_draw_circle(GWN_PRIM_LINE_LOOP, shdr_pos, x, y, rad, rad, nsegments);
}
/**
@@ -86,9 +120,18 @@ void imm_draw_circle_wire(uint shdr_pos, float x, float y, float rad, int nsegme
* \param radius The circle's radius.
* \param nsegments The number of segments to use in drawing (more = smoother).
*/
-void imm_draw_circle_fill(uint shdr_pos, float x, float y, float rad, int nsegments)
+void imm_draw_circle_fill_2d(uint shdr_pos, float x, float y, float rad, int nsegments)
+{
+ imm_draw_circle(GWN_PRIM_TRI_FAN, shdr_pos, x, y, rad, rad, nsegments);
+}
+
+void imm_draw_circle_wire_aspect_2d(uint shdr_pos, float x, float y, float rad_x, float rad_y, int nsegments)
+{
+ imm_draw_circle(GWN_PRIM_LINE_LOOP, shdr_pos, x, y, rad_x, rad_y, nsegments);
+}
+void imm_draw_circle_fill_aspect_2d(uint shdr_pos, float x, float y, float rad_x, float rad_y, int nsegments)
{
- imm_draw_circle(GWN_PRIM_TRI_FAN, shdr_pos, x, y, rad, nsegments);
+ imm_draw_circle(GWN_PRIM_TRI_FAN, shdr_pos, x, y, rad_x, rad_y, nsegments);
}
/**
@@ -99,7 +142,7 @@ static void imm_draw_disk_partial(
float rad_inner, float rad_outer, int nsegments, float start, float sweep)
{
/* shift & reverse angle, increase 'nsegments' to match gluPartialDisk */
- const float angle_start = -(DEG2RADF(start)) + (M_PI / 2);
+ const float angle_start = -(DEG2RADF(start)) + (float)(M_PI / 2);
const float angle_end = -(DEG2RADF(sweep) - angle_start);
nsegments += 1;
immBegin(prim_type, nsegments * 2);
@@ -128,7 +171,7 @@ static void imm_draw_disk_partial(
* \param start: Specifies the starting angle, in degrees, of the disk portion.
* \param sweep: Specifies the sweep angle, in degrees, of the disk portion.
*/
-void imm_draw_disk_partial_fill(
+void imm_draw_disk_partial_fill_2d(
unsigned pos, float x, float y,
float rad_inner, float rad_outer, int nsegments, float start, float sweep)
{
@@ -141,7 +184,7 @@ static void imm_draw_circle_3D(
{
immBegin(prim_type, nsegments);
for (int i = 0; i < nsegments; ++i) {
- float angle = 2 * M_PI * ((float)i / (float)nsegments);
+ float angle = (float)(2 * M_PI) * ((float)i / (float)nsegments);
immVertex3f(pos, x + rad * cosf(angle), y + rad * sinf(angle), 0.0f);
}
immEnd();
@@ -166,7 +209,7 @@ void imm_draw_circle_fill_3d(unsigned pos, float x, float y, float rad, int nseg
* \param x2 right.
* \param y2 top.
*/
-void imm_draw_line_box(unsigned pos, float x1, float y1, float x2, float y2)
+void imm_draw_box_wire_2d(unsigned pos, float x1, float y1, float x2, float y2)
{
immBegin(GWN_PRIM_LINE_LOOP, 4);
immVertex2f(pos, x1, y1);
@@ -176,7 +219,7 @@ void imm_draw_line_box(unsigned pos, float x1, float y1, float x2, float y2)
immEnd();
}
-void imm_draw_line_box_3d(unsigned pos, float x1, float y1, float x2, float y2)
+void imm_draw_box_wire_3d(unsigned pos, float x1, float y1, float x2, float y2)
{
/* use this version when Gwn_VertFormat has a vec3 position */
immBegin(GWN_PRIM_LINE_LOOP, 4);
@@ -190,7 +233,7 @@ void imm_draw_line_box_3d(unsigned pos, float x1, float y1, float x2, float y2)
/**
* Draw a standard checkerboard to indicate transparent backgrounds.
*/
-void imm_draw_checker_box(float x1, float y1, float x2, float y2)
+void imm_draw_box_checker_2d(float x1, float y1, float x2, float y2)
{
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_CHECKER);
@@ -204,6 +247,43 @@ void imm_draw_checker_box(float x1, float y1, float x2, float y2)
immUnbindProgram();
}
+void imm_draw_cube_fill_3d(uint pos, const float co[3], const float aspect[3])
+{
+ float coords[ARRAY_SIZE(cube_coords)][3];
+
+ for (int i = 0; i < ARRAY_SIZE(cube_coords); i++) {
+ madd_v3_v3v3v3(coords[i], co, cube_coords[i], aspect);
+ }
+
+ immBegin(GWN_PRIM_TRIS, ARRAY_SIZE(cube_quad_index) * 3 * 2);
+ for (int i = 0; i < ARRAY_SIZE(cube_quad_index); i++) {
+ immVertex3fv(pos, coords[cube_quad_index[i][0]]);
+ immVertex3fv(pos, coords[cube_quad_index[i][1]]);
+ immVertex3fv(pos, coords[cube_quad_index[i][2]]);
+
+ immVertex3fv(pos, coords[cube_quad_index[i][0]]);
+ immVertex3fv(pos, coords[cube_quad_index[i][2]]);
+ immVertex3fv(pos, coords[cube_quad_index[i][3]]);
+ }
+ immEnd();
+}
+
+void imm_draw_cube_wire_3d(uint pos, const float co[3], const float aspect[3])
+{
+ float coords[ARRAY_SIZE(cube_coords)][3];
+
+ for (int i = 0; i < ARRAY_SIZE(cube_coords); i++) {
+ madd_v3_v3v3v3(coords[i], co, cube_coords[i], aspect);
+ }
+
+ immBegin(GWN_PRIM_LINES, ARRAY_SIZE(cube_line_index) * 2);
+ for (int i = 0; i < ARRAY_SIZE(cube_line_index); i++) {
+ immVertex3fv(pos, coords[cube_line_index[i][0]]);
+ immVertex3fv(pos, coords[cube_line_index[i][1]]);
+ }
+ immEnd();
+}
+
/**
* Draw a cylinder. Replacement for gluCylinder.
* _warning_ : Slow, better use it only if you no other choices.
@@ -221,8 +301,8 @@ void imm_draw_cylinder_fill_normal_3d(
{
immBegin(GWN_PRIM_TRIS, 6 * slices * stacks);
for (int i = 0; i < slices; ++i) {
- const float angle1 = 2 * M_PI * ((float)i / (float)slices);
- const float angle2 = 2 * M_PI * ((float)(i + 1) / (float)slices);
+ const float angle1 = (float)(2 * M_PI) * ((float)i / (float)slices);
+ const float angle2 = (float)(2 * M_PI) * ((float)(i + 1) / (float)slices);
const float cos1 = cosf(angle1);
const float sin1 = sinf(angle1);
const float cos2 = cosf(angle2);
@@ -272,8 +352,8 @@ void imm_draw_cylinder_wire_3d(unsigned int pos, float base, float top, float he
{
immBegin(GWN_PRIM_LINES, 6 * slices * stacks);
for (int i = 0; i < slices; ++i) {
- const float angle1 = 2 * M_PI * ((float)i / (float)slices);
- const float angle2 = 2 * M_PI * ((float)(i + 1) / (float)slices);
+ const float angle1 = (float)(2 * M_PI) * ((float)i / (float)slices);
+ const float angle2 = (float)(2 * M_PI) * ((float)(i + 1) / (float)slices);
const float cos1 = cosf(angle1);
const float sin1 = sinf(angle1);
const float cos2 = cosf(angle2);
@@ -309,8 +389,8 @@ void imm_draw_cylinder_fill_3d(unsigned int pos, float base, float top, float he
{
immBegin(GWN_PRIM_TRIS, 6 * slices * stacks);
for (int i = 0; i < slices; ++i) {
- const float angle1 = 2 * M_PI * ((float)i / (float)slices);
- const float angle2 = 2 * M_PI * ((float)(i + 1) / (float)slices);
+ const float angle1 = (float)(2 * M_PI) * ((float)i / (float)slices);
+ const float angle2 = (float)(2 * M_PI) * ((float)(i + 1) / (float)slices);
const float cos1 = cosf(angle1);
const float sin1 = sinf(angle1);
const float cos2 = cosf(angle2);
diff --git a/source/blender/gpu/intern/gpu_lamp.c b/source/blender/gpu/intern/gpu_lamp.c
index 86c40baf5cc..fbc1ace1292 100644
--- a/source/blender/gpu/intern/gpu_lamp.c
+++ b/source/blender/gpu/intern/gpu_lamp.c
@@ -52,9 +52,11 @@
#include "gpu_lamp_private.h"
-bool GPU_lamp_override_visible(GPULamp *lamp, SceneRenderLayer *srl, Material *ma)
+bool GPU_lamp_visible(GPULamp *lamp, SceneRenderLayer *srl, Material *ma)
{
- if (srl && srl->light_override)
+ if (lamp->hide)
+ return false;
+ else if (srl && srl->light_override)
return BKE_group_object_exists(srl->light_override, lamp->ob);
else if (ma && ma->group)
return BKE_group_object_exists(ma->group, lamp->ob);
@@ -281,6 +283,10 @@ GPULamp *GPU_lamp_from_blender(Scene *scene, Object *ob, Object *par)
return lamp;
}
+ GPU_texture_bind(lamp->depthtex, 0);
+ GPU_texture_compare_mode(lamp->depthtex, true);
+ GPU_texture_unbind(lamp->depthtex);
+
if (!GPU_framebuffer_texture_attach(lamp->fb, lamp->depthtex, 0, 0)) {
gpu_lamp_shadow_free(lamp);
return lamp;
@@ -338,6 +344,10 @@ GPULamp *GPU_lamp_from_blender(Scene *scene, Object *ob, Object *par)
return lamp;
}
+ GPU_texture_bind(lamp->tex, 0);
+ GPU_texture_compare_mode(lamp->tex, true);
+ GPU_texture_unbind(lamp->tex);
+
if (!GPU_framebuffer_texture_attach(lamp->fb, lamp->tex, 0, 0)) {
gpu_lamp_shadow_free(lamp);
return lamp;
@@ -366,7 +376,7 @@ GPULamp *GPU_lamp_from_blender(Scene *scene, Object *ob, Object *par)
void GPU_lamp_engine_data_free(LampEngineData *led)
{
- for (int i = 0; i < MAX_LAMP_DATA; ++i) {
+ for (int i = 0; i < MAX_LAMP_DATA; ++i) {
if (led->storage[i]) {
MEM_freeN(led->storage[i]);
led->storage[i] = NULL;
@@ -378,21 +388,10 @@ void GPU_lamp_free(Object *ob)
{
GPULamp *lamp;
LinkData *link;
- LinkData *nlink;
- Material *ma;
for (link = ob->gpulamp.first; link; link = link->next) {
lamp = link->data;
- while (lamp->materials.first) {
- nlink = lamp->materials.first;
- ma = nlink->data;
- BLI_freelinkN(&lamp->materials, nlink);
-
- if (ma->gpumaterial.first)
- GPU_material_free(&ma->gpumaterial);
- }
-
gpu_lamp_shadow_free(lamp);
GPU_lamp_engine_data_free(&lamp->data);
diff --git a/source/blender/gpu/intern/gpu_lamp_private.h b/source/blender/gpu/intern/gpu_lamp_private.h
index ef71385e66d..f227ce74e7e 100644
--- a/source/blender/gpu/intern/gpu_lamp_private.h
+++ b/source/blender/gpu/intern/gpu_lamp_private.h
@@ -77,8 +77,6 @@ struct GPULamp {
GPUTexture *depthtex;
GPUTexture *blurtex;
- ListBase materials;
-
/* New viewport */
struct LampEngineData data;
};
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index c00baef2856..a08bef4472a 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -64,6 +64,7 @@
#include "GPU_material.h"
#include "GPU_shader.h"
#include "GPU_texture.h"
+#include "GPU_uniformbuffer.h"
#include "gpu_codegen.h"
#include "gpu_lamp_private.h"
@@ -101,7 +102,7 @@ struct GPUMaterial {
* some code generation is done differently depending on the use case */
int type; /* DEPRECATED */
- void *engine; /* attached engine type */
+ const void *engine_type; /* attached engine type */
int options; /* to identify shader variations (shadow, probe, world background...) */
/* for creating the material */
@@ -133,6 +134,7 @@ struct GPUMaterial {
bool bound;
bool is_opensubdiv;
+ GPUUniformBuffer *ubo; /* UBOs for shader uniforms. */
};
/* Forward declaration so shade_light_textures() can use this, while still keeping the code somewhat organized */
@@ -250,21 +252,10 @@ void GPU_material_free(ListBase *gpumaterial)
if (material->pass)
GPU_pass_free(material->pass);
- for (LinkData *nlink = material->lamps.first; nlink; nlink = nlink->next) {
- GPULamp *lamp = nlink->data;
-
- if (material->ma) {
- Material *ma = material->ma;
-
- LinkData *next = NULL;
- for (LinkData *mlink = lamp->materials.first; mlink; mlink = next) {
- next = mlink->next;
- if (mlink->data == ma)
- BLI_freelinkN(&lamp->materials, mlink);
- }
- }
+ if (material->ubo != NULL) {
+ GPU_uniformbuffer_free(material->ubo);
}
-
+
BLI_freelistN(&material->lamps);
MEM_freeN(material);
@@ -289,8 +280,8 @@ void GPU_material_bind(
for (LinkData *nlink = material->lamps.first; nlink; nlink = nlink->next) {
GPULamp *lamp = nlink->data;
- if (!lamp->hide && (lamp->lay & viewlay) && (!(lamp->mode & LA_LAYER) || (lamp->lay & oblay)) &&
- GPU_lamp_override_visible(lamp, srl, material->ma))
+ if ((lamp->lay & viewlay) && (!(lamp->mode & LA_LAYER) || (lamp->lay & oblay)) &&
+ GPU_lamp_visible(lamp, srl, material->ma))
{
lamp->dynenergy = lamp->energy;
copy_v3_v3(lamp->dyncol, lamp->col);
@@ -444,6 +435,30 @@ GPUPass *GPU_material_get_pass(GPUMaterial *material)
return material->pass;
}
+GPUUniformBuffer *GPU_material_get_uniform_buffer(GPUMaterial *material)
+{
+ return material->ubo;
+}
+
+/**
+ * Create dynamic UBO from parameters
+ * \param ListBase of BLI_genericNodeN(GPUInput)
+ */
+void GPU_material_create_uniform_buffer(GPUMaterial *material, ListBase *inputs)
+{
+ material->ubo = GPU_uniformbuffer_dynamic_create(inputs, NULL);
+}
+
+void GPU_material_uniform_buffer_tag_dirty(ListBase *gpumaterials)
+{
+ for (LinkData *link = gpumaterials->first; link; link = link->next) {
+ GPUMaterial *material = link->data;
+ if (material->ubo != NULL) {
+ GPU_uniformbuffer_tag_dirty(material->ubo);
+ }
+ }
+}
+
void GPU_material_vertex_attributes(GPUMaterial *material, GPUVertexAttribs *attribs)
{
*attribs = material->attribs;
@@ -904,14 +919,12 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la
}
add_user_list(&mat->lamps, lamp);
- add_user_list(&lamp->materials, shi->gpumat->ma);
return;
}
}
}
else if ((mat->scene->gm.flag & GAME_GLSL_NO_SHADOWS) && (lamp->mode & LA_ONLYSHADOW)) {
add_user_list(&mat->lamps, lamp);
- add_user_list(&lamp->materials, shi->gpumat->ma);
return;
}
else
@@ -978,7 +991,6 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la
}
add_user_list(&mat->lamps, lamp);
- add_user_list(&lamp->materials, shi->gpumat->ma);
}
static void material_lights(GPUShadeInput *shi, GPUShadeResult *shr)
@@ -2103,28 +2115,43 @@ GPUMaterial *GPU_material_world(struct Scene *scene, struct World *wo)
return mat;
}
-/* TODO : This is supposed to replace GPU_material_from_blender/_world in the future */
-GPUMaterial *GPU_material_from_nodetree(
- Scene *scene, struct bNodeTree *ntree, ListBase *gpumaterials, void *engine_type, int options,
- const char *vert_code, const char *geom_code, const char *frag_lib, const char *defines)
+GPUMaterial *GPU_material_from_nodetree_find(
+ ListBase *gpumaterials, const void *engine_type, int options)
{
- GPUMaterial *mat;
- GPUNodeLink *outlink;
- LinkData *link;
-
- for (link = gpumaterials->first; link; link = link->next) {
+ for (LinkData *link = gpumaterials->first; link; link = link->next) {
GPUMaterial *current_material = (GPUMaterial *)link->data;
- if (current_material->engine == engine_type &&
+ if (current_material->engine_type == engine_type &&
current_material->options == options)
{
return current_material;
}
}
+ return NULL;
+}
+
+/**
+ * TODO: This is supposed to replace GPU_material_from_blender/_world in the future
+ *
+ * \note Caller must use #GPU_material_from_nodetree_find to re-use existing materials,
+ * This is enforced since constructing other arguments to this function may be expensive
+ * so only do this when they are needed.
+ */
+GPUMaterial *GPU_material_from_nodetree(
+ Scene *scene, struct bNodeTree *ntree, ListBase *gpumaterials, const void *engine_type, int options,
+ const char *vert_code, const char *geom_code, const char *frag_lib, const char *defines)
+{
+ GPUMaterial *mat;
+ GPUNodeLink *outlink;
+ LinkData *link;
+
+ /* Caller must re-use materials. */
+ BLI_assert(GPU_material_from_nodetree_find(gpumaterials, engine_type, options) == NULL);
+
/* allocate material */
mat = GPU_material_construct_begin(NULL); /* TODO remove GPU_material_construct_begin */
mat->scene = scene;
- mat->engine = engine_type;
+ mat->engine_type = engine_type;
mat->options = options;
ntreeGPUMaterialNodes(ntree, mat, NODE_NEWER_SHADING);
@@ -2132,7 +2159,8 @@ GPUMaterial *GPU_material_from_nodetree(
/* Let Draw manager finish the construction. */
if (mat->outlink) {
outlink = mat->outlink;
- mat->pass = GPU_generate_pass_new(&mat->nodes, outlink, vert_code, geom_code, frag_lib, defines);
+ mat->pass = GPU_generate_pass_new(
+ mat, &mat->nodes, outlink, &mat->attribs, vert_code, geom_code, frag_lib, defines);
}
/* note that even if building the shader fails in some way, we still keep
@@ -2273,7 +2301,6 @@ GPUNodeLink *GPU_lamp_get_data(
/* ensure shadow buffer and lamp textures will be updated */
add_user_list(&mat->lamps, lamp);
- add_user_list(&lamp->materials, mat->ma);
return visifac;
}
@@ -2350,6 +2377,7 @@ GPUShaderExport *GPU_shader_export(struct Scene *scene, struct Material *ma)
case GPU_VEC4:
case GPU_MAT3:
case GPU_MAT4:
+ case GPU_CLOSURE:
case GPU_ATTRIB:
break;
}
@@ -2378,6 +2406,7 @@ GPUShaderExport *GPU_shader_export(struct Scene *scene, struct Material *ma)
break;
case GPU_NONE:
+ case GPU_CLOSURE:
case GPU_TEX2D:
case GPU_TEXCUBE:
case GPU_SHADOW2D:
diff --git a/source/blender/gpu/intern/gpu_matrix.c b/source/blender/gpu/intern/gpu_matrix.c
index f03a076a9fd..b6214f2778b 100644
--- a/source/blender/gpu/intern/gpu_matrix.c
+++ b/source/blender/gpu/intern/gpu_matrix.c
@@ -29,8 +29,12 @@
* \ingroup gpu
*/
+#include "../../../intern/gawain/gawain/gwn_shader_interface.h"
+
#define SUPPRESS_GENERIC_MATRIX_API
+#define USE_GPU_PY_MATRIX_API /* only so values are declared */
#include "GPU_matrix.h"
+#undef USE_GPU_PY_MATRIX_API
#include "BLI_math_matrix.h"
#include "BLI_math_rotation.h"
@@ -117,7 +121,7 @@ static void checkmat(cosnt float *m)
void gpuPushMatrix(void)
{
- BLI_assert(ModelViewStack.top < MATRIX_STACK_DEPTH);
+ BLI_assert(ModelViewStack.top + 1 < MATRIX_STACK_DEPTH);
ModelViewStack.top++;
copy_m4_m4(ModelView, ModelViewStack.stack[ModelViewStack.top - 1]);
}
@@ -131,7 +135,7 @@ void gpuPopMatrix(void)
void gpuPushProjectionMatrix(void)
{
- BLI_assert(ProjectionStack.top < MATRIX_STACK_DEPTH);
+ BLI_assert(ProjectionStack.top + 1 < MATRIX_STACK_DEPTH);
ProjectionStack.top++;
copy_m4_m4(Projection, ProjectionStack.stack[ProjectionStack.top - 1]);
}
@@ -554,7 +558,7 @@ const float (*gpuGetNormalMatrixInverse(float m[3][3]))[3]
return m;
}
-void gpuBindMatrices(const Gwn_ShaderInterface* shaderface)
+void gpuBindMatrices(const Gwn_ShaderInterface *shaderface)
{
/* set uniform values to matrix stack values
* call this before a draw call if desired matrices are dirty
@@ -570,33 +574,33 @@ void gpuBindMatrices(const Gwn_ShaderInterface* shaderface)
const Gwn_ShaderInput *P_inv = GWN_shaderinterface_uniform_builtin(shaderface, GWN_UNIFORM_PROJECTION_INV);
if (MV) {
- #if DEBUG_MATRIX_BIND
+#if DEBUG_MATRIX_BIND
puts("setting MV matrix");
- #endif
+#endif
glUniformMatrix4fv(MV->location, 1, GL_FALSE, (const float *)gpuGetModelViewMatrix(NULL));
}
if (P) {
- #if DEBUG_MATRIX_BIND
+#if DEBUG_MATRIX_BIND
puts("setting P matrix");
- #endif
+#endif
glUniformMatrix4fv(P->location, 1, GL_FALSE, (const float *)gpuGetProjectionMatrix(NULL));
}
if (MVP) {
- #if DEBUG_MATRIX_BIND
+#if DEBUG_MATRIX_BIND
puts("setting MVP matrix");
- #endif
+#endif
glUniformMatrix4fv(MVP->location, 1, GL_FALSE, (const float *)gpuGetModelViewProjectionMatrix(NULL));
}
if (N) {
- #if DEBUG_MATRIX_BIND
+#if DEBUG_MATRIX_BIND
puts("setting normal matrix");
- #endif
+#endif
glUniformMatrix3fv(N->location, 1, GL_FALSE, (const float *)gpuGetNormalMatrix(NULL));
}
@@ -605,14 +609,14 @@ void gpuBindMatrices(const Gwn_ShaderInterface* shaderface)
Mat4 m;
gpuGetModelViewMatrix(m);
invert_m4(m);
- glUniformMatrix4fv(MV_inv->location, 1, GL_FALSE, (const float*) m);
+ glUniformMatrix4fv(MV_inv->location, 1, GL_FALSE, (const float *)m);
}
if (P_inv) {
Mat4 m;
gpuGetProjectionMatrix(m);
invert_m4(m);
- glUniformMatrix4fv(P_inv->location, 1, GL_FALSE, (const float*) m);
+ glUniformMatrix4fv(P_inv->location, 1, GL_FALSE, (const float *)m);
}
state.dirty = false;
@@ -622,3 +626,24 @@ bool gpuMatricesDirty(void)
{
return state.dirty;
}
+
+
+/* -------------------------------------------------------------------- */
+
+/** \name Python API Helpers
+ * \{ */
+BLI_STATIC_ASSERT(GPU_PY_MATRIX_STACK_LEN + 1 == MATRIX_STACK_DEPTH, "define mismatch");
+
+/* Return int since caller is may subtract. */
+
+int GPU_matrix_stack_level_get_model_view(void)
+{
+ return (int)state.model_view_stack.top;
+}
+
+int GPU_matrix_stack_level_get_projection(void)
+{
+ return (int)state.projection_stack.top;
+}
+
+/** \} */
diff --git a/source/blender/gpu/intern/gpu_select.c b/source/blender/gpu/intern/gpu_select.c
index 162a605ef3d..153cf5f1e97 100644
--- a/source/blender/gpu/intern/gpu_select.c
+++ b/source/blender/gpu/intern/gpu_select.c
@@ -227,3 +227,29 @@ bool GPU_select_is_cached(void)
{
return g_select_state.use_cache && gpu_select_pick_is_cached();
}
+
+
+/* ----------------------------------------------------------------------------
+ * Utilities
+ */
+
+/**
+ * Helper function, nothing special but avoids doing inline since hit's aren't sorted by depth
+ * and purpose of 4x buffer indices isn't so clear.
+ *
+ * Note that comparing depth as uint is fine.
+ */
+const uint *GPU_select_buffer_near(const uint *buffer, int hits)
+{
+ const uint *buffer_near = NULL;
+ uint depth_min = (uint)-1;
+ for (int i = 0; i < hits; i++) {
+ if (buffer[1] < depth_min) {
+ BLI_assert(buffer[3] != -1);
+ depth_min = buffer[1];
+ buffer_near = buffer;
+ }
+ buffer += 4;
+ }
+ return buffer_near;
+}
diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c
index f0a1c182713..cc1e1e8bb14 100644
--- a/source/blender/gpu/intern/gpu_shader.c
+++ b/source/blender/gpu/intern/gpu_shader.c
@@ -30,9 +30,13 @@
#include "BLI_utildefines.h"
#include "BLI_math_base.h"
#include "BLI_math_vector.h"
+#include "BLI_path_util.h"
+#include "BKE_appdir.h"
#include "BKE_global.h"
+#include "DNA_space_types.h"
+
#include "GPU_compositing.h"
#include "GPU_extensions.h"
#include "GPU_matrix.h"
@@ -113,11 +117,11 @@ extern char datatoc_gpu_shader_2D_point_uniform_size_aa_vert_glsl[];
extern char datatoc_gpu_shader_2D_point_uniform_size_outline_aa_vert_glsl[];
extern char datatoc_gpu_shader_2D_point_uniform_size_varying_color_outline_aa_vert_glsl[];
-extern char datatoc_gpu_shader_2D_line_dashed_vert_glsl[];
+extern char datatoc_gpu_shader_2D_line_dashed_uniform_color_vert_glsl[];
extern char datatoc_gpu_shader_2D_line_dashed_frag_glsl[];
extern char datatoc_gpu_shader_2D_line_dashed_geom_glsl[];
-extern char datatoc_gpu_shader_3D_line_dashed_legacy_vert_glsl[];
-extern char datatoc_gpu_shader_3D_line_dashed_vert_glsl[];
+extern char datatoc_gpu_shader_3D_line_dashed_uniform_color_legacy_vert_glsl[];
+extern char datatoc_gpu_shader_3D_line_dashed_uniform_color_vert_glsl[];
extern char datatoc_gpu_shader_edges_front_back_persp_vert_glsl[];
extern char datatoc_gpu_shader_edges_front_back_persp_geom_glsl[];
@@ -267,6 +271,53 @@ GPUShader *GPU_shader_create(const char *vertexcode,
GPU_SHADER_FLAGS_NONE);
}
+#define DEBUG_SHADER_NONE ""
+#define DEBUG_SHADER_VERTEX "vert"
+#define DEBUG_SHADER_FRAGMENT "frag"
+#define DEBUG_SHADER_GEOMETRY "geom"
+
+/**
+ * Dump GLSL shaders to disk
+ *
+ * This is used for profiling shader performance externally and debug if shader code is correct.
+ * If called with no code, it simply bumps the shader index, so different shaders for the same
+ * program share the same index.
+ */
+static void gpu_dump_shaders(const char **code, const int num_shaders, const char *extension)
+{
+ if ((G.debug & G_DEBUG_GPU_SHADERS) == 0) {
+ return;
+ }
+
+ /* We use the same shader index for shaders in the same program.
+ * So we call this function once before calling for the invidual shaders. */
+ static int shader_index = 0;
+ if (code == NULL) {
+ shader_index++;
+ BLI_assert(STREQ(DEBUG_SHADER_NONE, extension));
+ return;
+ }
+
+ /* Determine the full path of the new shader. */
+ char shader_path[FILE_MAX];
+
+ char file_name[512] = {'\0'};
+ sprintf(file_name, "%04d.%s", shader_index, extension);
+
+ BLI_join_dirfile(shader_path, sizeof(shader_path), BKE_tempdir_session(), file_name);
+
+ /* Write shader to disk. */
+ FILE *f = fopen(shader_path, "w");
+ if (f == NULL) {
+ printf("Error writing to file: %s\n", shader_path);
+ }
+ for (int j = 0; j < num_shaders; j++) {
+ fprintf(f, "%s", code[j]);
+ }
+ fclose(f);
+ printf("Shader file written to disk: %s\n", shader_path);
+}
+
GPUShader *GPU_shader_create_ex(const char *vertexcode,
const char *fragcode,
const char *geocode,
@@ -288,6 +339,7 @@ GPUShader *GPU_shader_create_ex(const char *vertexcode,
char standard_extensions[MAX_EXT_DEFINE_LENGTH] = "";
shader = MEM_callocN(sizeof(GPUShader), "GPUShader");
+ gpu_dump_shaders(NULL, 0, DEBUG_SHADER_NONE);
if (vertexcode)
shader->vertex = glCreateShader(GL_VERTEX_SHADER);
@@ -325,6 +377,8 @@ GPUShader *GPU_shader_create_ex(const char *vertexcode,
if (defines) source[num_source++] = defines;
source[num_source++] = vertexcode;
+ gpu_dump_shaders(source, num_source, DEBUG_SHADER_VERTEX);
+
glAttachShader(shader->program, shader->vertex);
glShaderSource(shader->vertex, num_source, source, NULL);
@@ -364,6 +418,8 @@ GPUShader *GPU_shader_create_ex(const char *vertexcode,
if (libcode) source[num_source++] = libcode;
source[num_source++] = fragcode;
+ gpu_dump_shaders(source, num_source, DEBUG_SHADER_FRAGMENT);
+
glAttachShader(shader->program, shader->fragment);
glShaderSource(shader->fragment, num_source, source, NULL);
@@ -390,6 +446,8 @@ GPUShader *GPU_shader_create_ex(const char *vertexcode,
if (defines) source[num_source++] = defines;
source[num_source++] = geocode;
+ gpu_dump_shaders(source, num_source, DEBUG_SHADER_GEOMETRY);
+
glAttachShader(shader->program, shader->geometry);
glShaderSource(shader->geometry, num_source, source, NULL);
@@ -452,6 +510,11 @@ GPUShader *GPU_shader_create_ex(const char *vertexcode,
return shader;
}
+#undef DEBUG_SHADER_GEOMETRY
+#undef DEBUG_SHADER_FRAGMENT
+#undef DEBUG_SHADER_VERTEX
+#undef DEBUG_SHADER_NONE
+
void GPU_shader_bind(GPUShader *shader)
{
BLI_assert(shader && shader->program);
@@ -494,11 +557,19 @@ int GPU_shader_get_uniform(GPUShader *shader, const char *name)
return uniform ? uniform->location : -1;
}
+int GPU_shader_get_builtin_uniform(GPUShader *shader, int builtin)
+{
+ BLI_assert(shader && shader->program);
+ const Gwn_ShaderInput *uniform = GWN_shaderinterface_uniform_builtin(shader->interface, builtin);
+ return uniform ? uniform->location : -1;
+}
+
int GPU_shader_get_uniform_block(GPUShader *shader, const char *name)
{
BLI_assert(shader && shader->program);
- return glGetUniformBlockIndex(shader->program, name);
+ const Gwn_ShaderInput *ubo = GWN_shaderinterface_ubo(shader->interface, name);
+ return ubo ? ubo->location : -1;
}
void *GPU_fx_shader_get_interface(GPUShader *shader)
@@ -663,6 +734,7 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
[GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR] = { datatoc_gpu_shader_2D_image_vert_glsl,
datatoc_gpu_shader_image_shuffle_color_frag_glsl },
[GPU_SHADER_3D_UNIFORM_COLOR] = { datatoc_gpu_shader_3D_vert_glsl, datatoc_gpu_shader_uniform_color_frag_glsl },
+ [GPU_SHADER_3D_UNIFORM_COLOR_U32] = { datatoc_gpu_shader_3D_vert_glsl, datatoc_gpu_shader_uniform_color_frag_glsl },
[GPU_SHADER_3D_FLAT_COLOR] = { datatoc_gpu_shader_3D_flat_color_vert_glsl,
datatoc_gpu_shader_flat_color_frag_glsl },
[GPU_SHADER_3D_FLAT_COLOR_U32] = { datatoc_gpu_shader_3D_flat_color_vert_glsl,
@@ -678,12 +750,12 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
datatoc_gpu_shader_uniform_color_frag_glsl,
datatoc_gpu_shader_3D_groundline_geom_glsl },
- [GPU_SHADER_2D_LINE_DASHED_COLOR] = { datatoc_gpu_shader_2D_line_dashed_vert_glsl,
- datatoc_gpu_shader_2D_line_dashed_frag_glsl,
- datatoc_gpu_shader_2D_line_dashed_geom_glsl },
- [GPU_SHADER_3D_LINE_DASHED_COLOR] = { datatoc_gpu_shader_3D_line_dashed_vert_glsl,
- datatoc_gpu_shader_2D_line_dashed_frag_glsl,
- datatoc_gpu_shader_2D_line_dashed_geom_glsl },
+ [GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR] = { datatoc_gpu_shader_2D_line_dashed_uniform_color_vert_glsl,
+ datatoc_gpu_shader_2D_line_dashed_frag_glsl,
+ datatoc_gpu_shader_2D_line_dashed_geom_glsl },
+ [GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR] = { datatoc_gpu_shader_3D_line_dashed_uniform_color_vert_glsl,
+ datatoc_gpu_shader_2D_line_dashed_frag_glsl,
+ datatoc_gpu_shader_2D_line_dashed_geom_glsl },
[GPU_SHADER_3D_OBJECTSPACE_SIMPLE_LIGHTING_VARIYING_COLOR] =
{ datatoc_gpu_shader_instance_objectspace_variying_color_vert_glsl,
@@ -744,7 +816,7 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
datatoc_gpu_shader_instance_edges_variying_color_geom_glsl},
[GPU_SHADER_3D_INSTANCE_BONE_ENVELOPE_SOLID] = { datatoc_gpu_shader_instance_bone_envelope_solid_vert_glsl,
- datatoc_gpu_shader_simple_lighting_frag_glsl },
+ datatoc_gpu_shader_simple_lighting_frag_glsl },
[GPU_SHADER_3D_INSTANCE_BONE_ENVELOPE_WIRE] = { datatoc_gpu_shader_instance_bone_envelope_wire_vert_glsl,
datatoc_gpu_shader_flat_color_frag_glsl },
};
@@ -767,6 +839,7 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
defines = "#define USE_INSTANCE_COLOR;\n";
break;
case GPU_SHADER_3D_FLAT_COLOR_U32:
+ case GPU_SHADER_3D_UNIFORM_COLOR_U32:
defines = "#define USE_COLOR_U32;\n";
break;
case GPU_SHADER_SIMPLE_LIGHTING_FLAT_COLOR:
@@ -786,10 +859,10 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
stages = &legacy_fancy_edges;
}
- if (shader == GPU_SHADER_3D_LINE_DASHED_COLOR && !GLEW_VERSION_3_2) {
+ if (shader == GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR && !GLEW_VERSION_3_2) {
/* Dashed need geometry shader, which are not supported by legacy OpenGL, fallback to solid lines. */
/* TODO: remove after switch to core profile (maybe) */
- static const GPUShaderStages legacy_dashed_lines = { datatoc_gpu_shader_3D_line_dashed_legacy_vert_glsl,
+ static const GPUShaderStages legacy_dashed_lines = { datatoc_gpu_shader_3D_line_dashed_uniform_color_legacy_vert_glsl,
datatoc_gpu_shader_2D_line_dashed_frag_glsl };
stages = &legacy_dashed_lines;
}
diff --git a/source/blender/gpu/intern/gpu_shader_private.h b/source/blender/gpu/intern/gpu_shader_private.h
index 2de05b5746b..f883773df17 100644
--- a/source/blender/gpu/intern/gpu_shader_private.h
+++ b/source/blender/gpu/intern/gpu_shader_private.h
@@ -26,7 +26,7 @@
#define __GPU_SHADER_PRIVATE_H__
#include "GPU_glew.h"
-#include "gawain/shader_interface.h"
+#include "gawain/gwn_shader_interface.h"
struct GPUShader {
GLuint program; /* handle for full program (links shader stages below) */
diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c
index a8d0dccb896..ac8c8bacac1 100644
--- a/source/blender/gpu/intern/gpu_texture.c
+++ b/source/blender/gpu/intern/gpu_texture.c
@@ -66,6 +66,7 @@ struct GPUTexture {
unsigned int bytesize; /* number of byte for one pixel */
int format; /* GPUTextureFormat */
+ int components; /* number of color/alpha channels */
};
/* ------ Memory Management ------- */
@@ -167,6 +168,7 @@ static GLenum gpu_texture_get_format(
break;
case GPU_DEPTH_COMPONENT16:
case GPU_R16F:
+ case GPU_RG8:
*bytesize = 2;
break;
case GPU_R8:
@@ -189,6 +191,7 @@ static GLenum gpu_texture_get_format(
case GPU_RGBA8: return GL_RGBA8;
case GPU_R32F: return GL_R32F;
case GPU_R16F: return GL_R16F;
+ case GPU_RG8: return GL_RG8;
case GPU_R8: return GL_R8;
/* Special formats texture & renderbuffer */
case GPU_R11F_G11F_B10F: return GL_R11F_G11F_B10F;
@@ -324,6 +327,7 @@ static GPUTexture *GPU_texture_create_nD(
tex->refcount = 1;
tex->fb_attachment = -1;
tex->format = data_type;
+ tex->components = components;
if (n == 2) {
if (d == 0)
@@ -428,7 +432,7 @@ static GPUTexture *GPU_texture_create_nD(
if (tex->depth) {
glTexParameteri(tex->target_base, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(tex->target_base, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(tex->target_base, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
+ glTexParameteri(tex->target_base, GL_TEXTURE_COMPARE_MODE, GL_NONE);
glTexParameteri(tex->target_base, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
}
else {
@@ -466,6 +470,7 @@ static GPUTexture *GPU_texture_cube_create(
tex->refcount = 1;
tex->fb_attachment = -1;
tex->format = data_type;
+ tex->components = components;
if (d == 0) {
tex->target_base = tex->target = GL_TEXTURE_CUBE_MAP;
@@ -506,7 +511,7 @@ static GPUTexture *GPU_texture_cube_create(
if (tex->depth) {
glTexParameteri(tex->target_base, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(tex->target_base, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(tex->target_base, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
+ glTexParameteri(tex->target_base, GL_TEXTURE_COMPARE_MODE, GL_NONE);
glTexParameteri(tex->target_base, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
}
else {
@@ -553,6 +558,7 @@ GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, int textarget
tex->target_base = textarget;
tex->fromblender = 1;
tex->format = -1;
+ tex->components = -1;
ima->gputexture[gputt] = tex;
@@ -606,6 +612,7 @@ GPUTexture *GPU_texture_from_preview(PreviewImage *prv, int mipmap)
tex->target = GL_TEXTURE_2D;
tex->target_base = GL_TEXTURE_2D;
tex->format = -1;
+ tex->components = -1;
prv->gputexture[0] = tex;
@@ -704,6 +711,36 @@ GPUTexture *GPU_texture_create_depth_multisample(int w, int h, int samples, char
return GPU_texture_create_nD(w, h, 0, 2, NULL, GPU_DEPTH_COMPONENT24, 1, samples, false, err_out);
}
+void GPU_texture_update(GPUTexture *tex, const float *pixels)
+{
+ BLI_assert(tex->format > -1);
+ BLI_assert(tex->components > -1);
+
+ GLenum format, data_format;
+ gpu_texture_get_format(tex->components, tex->format, &format, &data_format, &tex->depth, &tex->stencil, &tex->bytesize);
+
+ glBindTexture(tex->target, tex->bindcode);
+
+ switch (tex->target) {
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_2D_MULTISAMPLE:
+ case GL_TEXTURE_1D_ARRAY:
+ glTexSubImage2D(tex->target, 0, 0, 0, tex->w, tex->h, format, data_format, pixels);
+ break;
+ case GL_TEXTURE_1D:
+ glTexSubImage1D(tex->target, 0, 0, tex->w, format, data_format, pixels);
+ break;
+ case GL_TEXTURE_3D:
+ case GL_TEXTURE_2D_ARRAY:
+ glTexSubImage3D(tex->target, 0, 0, 0, 0, tex->w, tex->h, tex->d, format, data_format, pixels);
+ break;
+ default:
+ BLI_assert(!"tex->target mode not supported");
+ }
+
+ glBindTexture(tex->target, 0);
+}
+
void GPU_invalid_tex_init(void)
{
memory_usage = 0;
@@ -759,7 +796,7 @@ void GPU_texture_bind(GPUTexture *tex, int number)
glActiveTexture(GL_TEXTURE0 + number);
if (tex->bindcode != 0)
- glBindTexture(tex->target_base, tex->bindcode);
+ glBindTexture(tex->target, tex->bindcode);
else
GPU_invalid_tex_bind(tex->target_base);
@@ -782,7 +819,7 @@ void GPU_texture_unbind(GPUTexture *tex)
if (tex->number != 0)
glActiveTexture(GL_TEXTURE0 + tex->number);
- glBindTexture(tex->target_base, 0);
+ glBindTexture(tex->target, 0);
if (tex->number != 0)
glActiveTexture(GL_TEXTURE0);
@@ -874,6 +911,9 @@ void GPU_texture_mipmap_mode(GPUTexture *tex, bool use_mipmap, bool use_filter)
: use_mipmap ? GL_NEAREST_MIPMAP_LINEAR : GL_NEAREST;
glTexParameteri(tex->target_base, GL_TEXTURE_MIN_FILTER, mipmap);
+ GLenum filter = use_filter ? GL_LINEAR : GL_NEAREST;
+ glTexParameteri(tex->target_base, GL_TEXTURE_MAG_FILTER, filter);
+
if (tex->number != 0)
glActiveTexture(GL_TEXTURE0);
}
diff --git a/source/blender/gpu/intern/gpu_uniformbuffer.c b/source/blender/gpu/intern/gpu_uniformbuffer.c
index 76aa1a8226f..6d52dab5a1f 100644
--- a/source/blender/gpu/intern/gpu_uniformbuffer.c
+++ b/source/blender/gpu/intern/gpu_uniformbuffer.c
@@ -29,24 +29,75 @@
* \ingroup gpu
*/
+#include <string.h>
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
+#include "gpu_codegen.h"
+
#include "GPU_extensions.h"
#include "GPU_glew.h"
+#include "GPU_material.h"
#include "GPU_uniformbuffer.h"
+typedef enum GPUUniformBufferFlag {
+ GPU_UBO_FLAG_INITIALIZED = (1 << 0),
+ GPU_UBO_FLAG_DIRTY = (1 << 1),
+} GPUUniformBufferFlag;
+
+typedef enum GPUUniformBufferType {
+ GPU_UBO_STATIC = 0,
+ GPU_UBO_DYNAMIC = 1,
+} GPUUniformBufferType;
+
struct GPUUniformBuffer {
int size; /* in bytes */
GLuint bindcode; /* opengl identifier for UBO */
int bindpoint; /* current binding point */
+ GPUUniformBufferType type;
+};
+
+#define GPUUniformBufferStatic GPUUniformBuffer
+
+typedef struct GPUUniformBufferDynamic {
+ GPUUniformBuffer buffer;
+ ListBase items; /* GPUUniformBufferDynamicItem */
+ void *data;
+ char flag;
+} GPUUniformBufferDynamic;
+
+struct GPUUniformBufferDynamicItem {
+ struct GPUUniformBufferDynamicItem *next, *prev;
+ GPUType gputype;
+ float *data;
+ int size;
};
+
+/* Prototypes */
+static GPUType get_padded_gpu_type(struct LinkData *link);
+static void gpu_uniformbuffer_inputs_sort(struct ListBase *inputs);
+
+static GPUUniformBufferDynamicItem *gpu_uniformbuffer_populate(
+ GPUUniformBufferDynamic *ubo, const GPUType gputype, float *num);
+
+/* Only support up to this type, if you want to extend it, make sure the
+ * padding logic is correct for the new types. */
+#define MAX_UBO_GPU_TYPE GPU_VEC4
+
+static void gpu_uniformbuffer_initialize(GPUUniformBuffer *ubo, const void *data)
+{
+ glBindBuffer(GL_UNIFORM_BUFFER, ubo->bindcode);
+ glBufferData(GL_UNIFORM_BUFFER, ubo->size, data, GL_DYNAMIC_DRAW);
+ glBindBuffer(GL_UNIFORM_BUFFER, 0);
+}
+
GPUUniformBuffer *GPU_uniformbuffer_create(int size, const void *data, char err_out[256])
{
- GPUUniformBuffer *ubo = MEM_callocN(sizeof(GPUUniformBuffer), "GPUUniformBuffer");
+ GPUUniformBuffer *ubo = MEM_callocN(sizeof(GPUUniformBufferStatic), "GPUUniformBufferStatic");
ubo->size = size;
+ ubo->bindpoint = -1;
/* Generate Buffer object */
glGenBuffers(1, &ubo->bindcode);
@@ -65,26 +116,227 @@ GPUUniformBuffer *GPU_uniformbuffer_create(int size, const void *data, char err_
return NULL;
}
- glBindBuffer(GL_UNIFORM_BUFFER, ubo->bindcode);
- glBufferData(GL_UNIFORM_BUFFER, ubo->size, data, GL_DYNAMIC_DRAW);
- glBindBuffer(GL_UNIFORM_BUFFER, 0);
-
+ gpu_uniformbuffer_initialize(ubo, data);
return ubo;
}
+/**
+ * Create dynamic UBO from parameters
+ * Return NULL if failed to create or if \param inputs is empty.
+ *
+ * \param inputs ListBase of BLI_genericNodeN(GPUInput)
+ */
+GPUUniformBuffer *GPU_uniformbuffer_dynamic_create(ListBase *inputs, char err_out[256])
+{
+ /* There is no point on creating an UBO if there is no arguments. */
+ if (BLI_listbase_is_empty(inputs)) {
+ return NULL;
+ }
+
+ GPUUniformBufferDynamic *ubo = MEM_callocN(sizeof(GPUUniformBufferDynamic), "GPUUniformBufferDynamic");
+ ubo->buffer.type = GPU_UBO_DYNAMIC;
+ ubo->buffer.bindpoint = -1;
+ ubo->flag = GPU_UBO_FLAG_DIRTY;
+
+ /* Generate Buffer object. */
+ glGenBuffers(1, &ubo->buffer.bindcode);
+
+ if (!ubo->buffer.bindcode) {
+ if (err_out)
+ BLI_snprintf(err_out, 256, "GPUUniformBuffer: UBO create failed");
+ GPU_uniformbuffer_free(&ubo->buffer);
+ return NULL;
+ }
+
+ if (ubo->buffer.size > GPU_max_ubo_size()) {
+ if (err_out)
+ BLI_snprintf(err_out, 256, "GPUUniformBuffer: UBO too big");
+ GPU_uniformbuffer_free(&ubo->buffer);
+ return NULL;
+ }
+
+ /* Make sure we comply to the ubo alignment requirements. */
+ gpu_uniformbuffer_inputs_sort(inputs);
+
+ for (LinkData *link = inputs->first; link; link = link->next) {
+ GPUInput *input = link->data;
+ GPUType gputype = get_padded_gpu_type(link);
+ gpu_uniformbuffer_populate(ubo, gputype, input->dynamicvec);
+ }
+
+ ubo->data = MEM_mallocN(ubo->buffer.size, __func__);
+
+ /* Initialize buffer data. */
+ GPU_uniformbuffer_dynamic_update(&ubo->buffer);
+ return &ubo->buffer;
+}
+
+/**
+ * Free the data, and clean the items list.
+ */
+static void gpu_uniformbuffer_dynamic_reset(GPUUniformBufferDynamic *ubo)
+{
+ ubo->buffer.size = 0;
+ if (ubo->data) {
+ MEM_freeN(ubo->data);
+ }
+ BLI_freelistN(&ubo->items);
+}
+
void GPU_uniformbuffer_free(GPUUniformBuffer *ubo)
{
+ if (ubo->type == GPU_UBO_DYNAMIC) {
+ gpu_uniformbuffer_dynamic_reset((GPUUniformBufferDynamic *)ubo);
+ }
+
glDeleteBuffers(1, &ubo->bindcode);
MEM_freeN(ubo);
}
-void GPU_uniformbuffer_update(GPUUniformBuffer *ubo, const void *data)
+static void gpu_uniformbuffer_update(GPUUniformBuffer *ubo, const void *data)
{
glBindBuffer(GL_UNIFORM_BUFFER, ubo->bindcode);
glBufferSubData(GL_UNIFORM_BUFFER, 0, ubo->size, data);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
}
+void GPU_uniformbuffer_update(GPUUniformBuffer *ubo, const void *data)
+{
+ BLI_assert(ubo->type == GPU_UBO_STATIC);
+ gpu_uniformbuffer_update(ubo, data);
+}
+
+/**
+ * We need to recalculate the internal data, and re-generate it
+ * from its populated items.
+ */
+void GPU_uniformbuffer_dynamic_update(GPUUniformBuffer *ubo_)
+{
+ BLI_assert(ubo_->type == GPU_UBO_DYNAMIC);
+ GPUUniformBufferDynamic *ubo = (GPUUniformBufferDynamic *)ubo_;
+
+ float *offset = ubo->data;
+ for (GPUUniformBufferDynamicItem *item = ubo->items.first; item; item = item->next) {
+ memcpy(offset, item->data, item->size);
+ offset += item->gputype;
+ }
+
+ if (ubo->flag & GPU_UBO_FLAG_INITIALIZED) {
+ gpu_uniformbuffer_update(ubo_, ubo->data);
+ }
+ else {
+ ubo->flag |= GPU_UBO_FLAG_INITIALIZED;
+ gpu_uniformbuffer_initialize(ubo_, ubo->data);
+ }
+
+ ubo->flag &= ~GPU_UBO_FLAG_DIRTY;
+}
+
+/**
+ * We need to pad some data types (vec3) on the C side
+ * To match the GPU expected memory block alignment.
+ */
+static GPUType get_padded_gpu_type(LinkData *link)
+{
+ GPUInput *input = link->data;
+ GPUType gputype = input->type;
+
+ /* Unless the vec3 is followed by a float we need to treat it as a vec4. */
+ if (gputype == GPU_VEC3 &&
+ (link->next != NULL) &&
+ (((GPUInput *)link->next->data)->type != GPU_FLOAT))
+ {
+ gputype = GPU_VEC4;
+ }
+
+ return gputype;
+}
+
+/**
+ * Returns 1 if the first item shold be after second item.
+ * We make sure the vec4 uniforms come first.
+ */
+static int inputs_cmp(const void *a, const void *b)
+{
+ const LinkData *link_a = a, *link_b = b;
+ const GPUInput *input_a = link_a->data, *input_b = link_b->data;
+ return input_a->type < input_b->type ? 1 : 0;
+}
+
+/**
+ * Make sure we respect the expected alignment of UBOs.
+ * vec4, pad vec3 as vec4, then vec2, then floats.
+ */
+static void gpu_uniformbuffer_inputs_sort(ListBase *inputs)
+{
+ /* Order them as vec4, vec3, vec2, float. */
+ BLI_listbase_sort(inputs, inputs_cmp);
+
+ /* Creates a lookup table for the different types; */
+ LinkData *inputs_lookup[MAX_UBO_GPU_TYPE + 1] = {NULL};
+ GPUType cur_type = MAX_UBO_GPU_TYPE + 1;
+
+ for (LinkData *link = inputs->first; link; link = link->next) {
+ GPUInput *input = link->data;
+ if (input->type == cur_type) {
+ continue;
+ }
+ else {
+ inputs_lookup[input->type] = link;
+ cur_type = input->type;
+ }
+ }
+
+ /* If there is no GPU_VEC3 there is no need for alignment. */
+ if (inputs_lookup[GPU_VEC3] == NULL) {
+ return;
+ }
+
+ LinkData *link = inputs_lookup[GPU_VEC3];
+ while (link != NULL && ((GPUInput *)link->data)->type == GPU_VEC3) {
+ LinkData *link_next = link->next;
+
+ /* If GPU_VEC3 is followed by nothing or a GPU_FLOAT, no need for aligment. */
+ if ((link_next == NULL) ||
+ ((GPUInput *)link_next->data)->type == GPU_FLOAT)
+ {
+ break;
+ }
+
+ /* If there is a float, move it next to current vec3. */
+ if (inputs_lookup[GPU_FLOAT] != NULL) {
+ LinkData *float_input = inputs_lookup[GPU_FLOAT];
+ inputs_lookup[GPU_FLOAT] = float_input->next;
+
+ BLI_remlink(inputs, float_input);
+ BLI_insertlinkafter(inputs, link, float_input);
+ }
+
+ link = link_next;
+ }
+}
+
+/**
+ * This may now happen from the main thread, so we can't update the UBO
+ * We simply flag it as dirty
+ */
+static GPUUniformBufferDynamicItem *gpu_uniformbuffer_populate(
+ GPUUniformBufferDynamic *ubo, const GPUType gputype, float *num)
+{
+ BLI_assert(gputype <= MAX_UBO_GPU_TYPE);
+ GPUUniformBufferDynamicItem *item = MEM_callocN(sizeof(GPUUniformBufferDynamicItem), __func__);
+
+ item->gputype = gputype;
+ item->data = num;
+ item->size = gputype * sizeof(float);
+ ubo->buffer.size += item->size;
+
+ ubo->flag |= GPU_UBO_FLAG_DIRTY;
+ BLI_addtail(&ubo->items, item);
+
+ return item;
+}
+
void GPU_uniformbuffer_bind(GPUUniformBuffer *ubo, int number)
{
if (number >= GPU_max_ubo_binds()) {
@@ -92,6 +344,13 @@ void GPU_uniformbuffer_bind(GPUUniformBuffer *ubo, int number)
return;
}
+ if (ubo->type == GPU_UBO_DYNAMIC) {
+ GPUUniformBufferDynamic *ubo_dynamic = (GPUUniformBufferDynamic *)ubo;
+ if (ubo_dynamic->flag & GPU_UBO_FLAG_DIRTY) {
+ GPU_uniformbuffer_dynamic_update(ubo);
+ }
+ }
+
if (ubo->bindcode != 0) {
glBindBufferBase(GL_UNIFORM_BUFFER, number, ubo->bindcode);
}
@@ -99,7 +358,21 @@ void GPU_uniformbuffer_bind(GPUUniformBuffer *ubo, int number)
ubo->bindpoint = number;
}
+void GPU_uniformbuffer_unbind(GPUUniformBuffer *ubo)
+{
+ ubo->bindpoint = -1;
+}
+
int GPU_uniformbuffer_bindpoint(GPUUniformBuffer *ubo)
{
return ubo->bindpoint;
-} \ No newline at end of file
+}
+
+void GPU_uniformbuffer_tag_dirty(GPUUniformBuffer *ubo_)
+{
+ BLI_assert(ubo_->type == GPU_UBO_DYNAMIC);
+ GPUUniformBufferDynamic *ubo = (GPUUniformBufferDynamic *)ubo_;
+ ubo->flag |= GPU_UBO_FLAG_DIRTY;
+}
+
+#undef MAX_UBO_GPU_TYPE
diff --git a/source/blender/gpu/intern/gpu_viewport.c b/source/blender/gpu/intern/gpu_viewport.c
index 9bd990e9796..058f6ced40b 100644
--- a/source/blender/gpu/intern/gpu_viewport.c
+++ b/source/blender/gpu/intern/gpu_viewport.c
@@ -38,6 +38,7 @@
#include "BLI_string.h"
#include "DNA_vec_types.h"
+#include "DNA_userdef_types.h"
#include "BKE_global.h"
@@ -72,6 +73,9 @@ struct GPUViewport {
GPUTexture *debug_depth;
int size[2];
+ int samples;
+ int flag;
+
ListBase data; /* ViewportEngineData wrapped in LinkData */
unsigned int data_hash; /* If hash mismatch we free all ViewportEngineData in this viewport */
@@ -81,11 +85,27 @@ struct GPUViewport {
ListBase tex_pool; /* ViewportTempTexture list : Temporary textures shared across draw engines */
};
+enum {
+ DO_UPDATE = (1 << 0),
+};
+
static void gpu_viewport_buffers_free(FramebufferList *fbl, int fbl_len, TextureList *txl, int txl_len);
static void gpu_viewport_storage_free(StorageList *stl, int stl_len);
static void gpu_viewport_passes_free(PassList *psl, int psl_len);
static void gpu_viewport_texture_pool_free(GPUViewport *viewport);
+void GPU_viewport_tag_update(GPUViewport *viewport)
+{
+ viewport->flag |= DO_UPDATE;
+}
+
+bool GPU_viewport_do_update(GPUViewport *viewport)
+{
+ bool ret = (viewport->flag & DO_UPDATE);
+ viewport->flag &= ~DO_UPDATE;
+ return ret;
+}
+
GPUViewport *GPU_viewport_create(void)
{
GPUViewport *viewport = MEM_callocN(sizeof(GPUViewport), "GPUViewport");
@@ -218,8 +238,8 @@ GPUTexture *GPU_viewport_texture_pool_query(GPUViewport *viewport, void *engine,
for (ViewportTempTexture *tmp_tex = viewport->tex_pool.first; tmp_tex; tmp_tex = tmp_tex->next) {
if ((GPU_texture_width(tmp_tex->texture) == width) &&
- (GPU_texture_height(tmp_tex->texture) == height) &&
- (GPU_texture_format(tmp_tex->texture) == format))
+ (GPU_texture_height(tmp_tex->texture) == height) &&
+ (GPU_texture_format(tmp_tex->texture) == format))
{
/* Search if the engine is not already using this texture */
for (int i = 0; i < MAX_ENGINE_BUFFER_SHARING; ++i) {
@@ -312,7 +332,7 @@ void GPU_viewport_bind(GPUViewport *viewport, const rcti *rect)
int rect_h = BLI_rcti_size_y(rect) + 1;
if (dfbl->default_fb) {
- if (rect_w != viewport->size[0] || rect_h != viewport->size[1]) {
+ if (rect_w != viewport->size[0] || rect_h != viewport->size[1] || U.ogl_multisamples != viewport->samples) {
gpu_viewport_buffers_free(
(FramebufferList *)viewport->fbl, default_fbl_len,
(TextureList *)viewport->txl, default_txl_len);
@@ -329,6 +349,56 @@ void GPU_viewport_bind(GPUViewport *viewport, const rcti *rect)
gpu_viewport_texture_pool_clear_users(viewport);
+ /* Multisample Buffer */
+ if (U.ogl_multisamples > 0) {
+ if (!dfbl->default_fb) {
+ bool ok = true;
+ viewport->samples = U.ogl_multisamples;
+
+ dfbl->multisample_fb = GPU_framebuffer_create();
+ if (!dfbl->multisample_fb) {
+ ok = false;
+ goto cleanup_multisample;
+ }
+
+ /* Color */
+ dtxl->multisample_color = GPU_texture_create_2D_multisample(rect_w, rect_h, NULL, U.ogl_multisamples, NULL);
+ if (!dtxl->multisample_color) {
+ ok = false;
+ goto cleanup_multisample;
+ }
+
+ if (!GPU_framebuffer_texture_attach(dfbl->multisample_fb, dtxl->multisample_color, 0, 0)) {
+ ok = false;
+ goto cleanup_multisample;
+ }
+
+ /* Depth */
+ dtxl->multisample_depth = GPU_texture_create_depth_multisample(rect_w, rect_h, U.ogl_multisamples, NULL);
+
+ if (!dtxl->multisample_depth) {
+ ok = false;
+ goto cleanup_multisample;
+ }
+
+ if (!GPU_framebuffer_texture_attach(dfbl->multisample_fb, dtxl->multisample_depth, 0, 0)) {
+ ok = false;
+ goto cleanup_multisample;
+ }
+ else if (!GPU_framebuffer_check_valid(dfbl->multisample_fb, NULL)) {
+ ok = false;
+ goto cleanup_multisample;
+ }
+
+cleanup_multisample:
+ if (!ok) {
+ GPU_viewport_free(viewport);
+ MEM_freeN(viewport);
+ return;
+ }
+ }
+ }
+
if (!dfbl->default_fb) {
bool ok = true;
viewport->size[0] = rect_w;
@@ -341,7 +411,6 @@ void GPU_viewport_bind(GPUViewport *viewport, const rcti *rect)
}
/* Color */
- /* No multi samples for now */
dtxl->color = GPU_texture_create_2D(rect_w, rect_h, NULL, NULL);
if (!dtxl->color) {
ok = false;
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_frag.glsl b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_frag.glsl
index 346d3b3c6d9..7caf00f58fd 100644
--- a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_frag.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_frag.glsl
@@ -1,38 +1,50 @@
-// Draw dashed lines, perforated in screen space.
-
-noperspective in float distance_along_line;
-out vec4 fragColor;
+/*
+ * Fragment Shader for dashed lines, with uniform multi-color(s), or any single-color, and any thickness.
+ *
+ * Dashed is performed in screen space.
+ */
uniform float dash_width;
/* Simple mode, discarding non-dash parts (so no need for blending at all). */
uniform float dash_factor; /* if > 1.0, solid line. */
-uniform vec4 color;
/* More advanced mode, allowing for complex, multi-colored patterns. Enabled when num_colors > 0. */
/* Note: max number of steps/colors in pattern is 32! */
uniform int num_colors; /* Enabled if > 0, 1 for solid line. */
uniform vec4 colors[32];
+noperspective in float distance_along_line;
+noperspective in vec4 color_geom;
+
+out vec4 fragColor;
+
void main()
{
- /* Solid line cases, simple. */
- if (num_colors == 1) {
- fragColor = colors[0];
- }
- else if (dash_factor >= 1.0f) {
- fragColor = color;
- }
- else {
+ /* Multi-color option. */
+ if (num_colors > 0) {
+ /* Solid line case, simple. */
+ if (num_colors == 1) {
+ fragColor = colors[0];
+ }
/* Actually dashed line... */
- float normalized_distance = fract(distance_along_line / dash_width);
- if (num_colors > 0) {
+ else {
+ float normalized_distance = fract(distance_along_line / dash_width);
fragColor = colors[int(normalized_distance * num_colors)];
}
+ }
+ /* Single color option. */
+ else {
+ /* Solid line case, simple. */
+ if (dash_factor >= 1.0f) {
+ fragColor = color_geom;
+ }
+ /* Actually dashed line... */
else {
+ float normalized_distance = fract(distance_along_line / dash_width);
if (normalized_distance <= dash_factor) {
- fragColor = color;
+ fragColor = color_geom;
}
else {
discard;
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_geom.glsl b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_geom.glsl
index e0b618e0b1a..db4bdf0a9f0 100644
--- a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_geom.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_geom.glsl
@@ -1,5 +1,10 @@
-// Draw dashed lines, perforated in screen space.
+/*
+ * Geometry Shader for dashed lines, with uniform multi-color(s), or any single-color, and unary thickness.
+ *
+ * Dashed is performed in screen space.
+ */
+
/* Make to be used with dynamic batching so no Model Matrix needed */
uniform mat4 ModelViewProjectionMatrix;
@@ -11,8 +16,11 @@ uniform int num_colors; /* Enabled if > 0, 1 for solid line. */
layout(lines) in;
+in vec4 color_vert[];
+
layout(line_strip, max_vertices = 2) out;
noperspective out float distance_along_line;
+noperspective out vec4 color_geom;
void main()
{
@@ -20,12 +28,14 @@ void main()
vec4 v2 = gl_in[1].gl_Position;
gl_Position = v1;
+ color_geom = color_vert[0];
distance_along_line = 0.0f;
EmitVertex();
gl_Position = v2;
+ color_geom = color_vert[1];
if ((num_colors == 1) || (dash_factor >= 1.0f)) {
- /* Solid line, optimise out distance computation! */
+ /* Solid line, optimize out distance computation! */
distance_along_line = 0.0f;
}
else {
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_uniform_color_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_uniform_color_vert.glsl
new file mode 100644
index 00000000000..f5c611586aa
--- /dev/null
+++ b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_uniform_color_vert.glsl
@@ -0,0 +1,21 @@
+
+/*
+ * Vertex Shader for dashed lines with 2D coordinates, with uniform multi-colors or uniform single-color,
+ * and unary thickness.
+ *
+ * Dashed is performed in screen space.
+ */
+
+uniform mat4 ModelViewProjectionMatrix;
+
+uniform vec4 color;
+
+in vec2 pos;
+
+out vec4 color_vert;
+
+void main()
+{
+ gl_Position = ModelViewProjectionMatrix * vec4(pos, 0.0, 1.0);
+ color_vert = color;
+}
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_vert.glsl
deleted file mode 100644
index 14f56d7e0dd..00000000000
--- a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_vert.glsl
+++ /dev/null
@@ -1,11 +0,0 @@
-
-// Draw dashed lines, perforated in screen space.
-
-uniform mat4 ModelViewProjectionMatrix;
-
-in vec2 pos;
-
-void main()
-{
- gl_Position = ModelViewProjectionMatrix * vec4(pos, 0.0, 1.0);
-}
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_width_geom.glsl b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_width_geom.glsl
new file mode 100644
index 00000000000..20c72f4407d
--- /dev/null
+++ b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_width_geom.glsl
@@ -0,0 +1,59 @@
+
+// Draw dashed lines, perforated in screen space, with non-unary width.
+
+/* Make to be used with dynamic batching so no Model Matrix needed */
+uniform mat4 ModelViewProjectionMatrix;
+uniform vec2 viewport_size;
+
+/* Width of the generated 'line'. */
+uniform float width; /* in pixels, screen space. */
+
+/* Uniforms from fragment shader, used here to optimize out useless computation in case of solid line. */
+uniform float dash_factor; /* if > 1.0, solid line. */
+uniform int num_colors; /* Enabled if > 0, 1 for solid line. */
+
+layout(lines) in;
+
+layout(triangle_strip, max_vertices = 4) out;
+noperspective out float distance_along_line;
+
+void main()
+{
+ vec4 v1 = gl_in[0].gl_Position;
+ vec4 v2 = gl_in[1].gl_Position;
+
+ /* Width, from 2D screen space in pixels, to ModelViewProjection space of each input vertices. */
+ float w1 = (width / viewport_size) * v1.w * 2.0;
+ float w2 = (width / viewport_size) * v2.w * 2.0;
+
+ /* Normalized vector parallel to screen and orthogonal to line. */
+ vec4 wdir = normalize(vec4(v1.y - v2.y, v2.x - v1.x, 0.0, 0.0))
+
+ distance_along_line = 0.0f;
+ gl_Position = v1 + (wdir * w1);
+ EmitVertex();
+
+ gl_Position = v1 - (wdir * w1);
+ EmitVertex();
+
+ if ((num_colors == 1) || (dash_factor >= 1.0f)) {
+ /* Solid line, optimize out distance computation! */
+ distance_along_line = 0.0f;
+ }
+ else {
+ vec2 p1 = (v1.xy / v1.w) * 0.5 + 0.5; // <- device coordinates in [0..1] range.
+ p1 = p1 * viewport_size; // <- 'virtual' screen coordinates.
+
+ vec2 p2 = (v2.xy / v2.w) * 0.5 + 0.5; // <- device coordinates in [0..1] range.
+ p2 = p2 * viewport_size; // <- 'virtual' screen coordinates.
+
+ distance_along_line = distance(p1, p2);
+ }
+ gl_Position = v2 + (wdir * w2);
+ EmitVertex();
+
+ gl_Position = v2 - (wdir * w2);
+ EmitVertex();
+
+ EndPrimitive();
+}
diff --git a/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_legacy_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_legacy_vert.glsl
index eab4c1b4543..84fbf977846 100644
--- a/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_legacy_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_legacy_vert.glsl
@@ -1,11 +1,19 @@
-/* Note: nearly the same code as for 2D version... Maybe we could deduplicate? */
+/*
+ * Vertex Shader for dashed lines with 3D coordinates, with uniform multi-colors or uniform single-color,
+ * and unary thickness.
+ *
+ * Legacy version, without geometry shader support, always produce solid lines!
+ */
uniform mat4 ModelViewProjectionMatrix;
uniform vec2 viewport_size;
+uniform vec4 color;
+
in vec3 pos;
noperspective out float distance_along_line;
+noperspective out vec4 color_geom;
void main()
{
@@ -13,4 +21,6 @@ void main()
/* Hack - prevent stupid GLSL compiler to optimize out unused viewport_size uniform, which gives crash! */
distance_along_line = viewport_size.x * 0.000001f - viewport_size.x * 0.0000009f;
+
+ color_geom = color;
}
diff --git a/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_vert.glsl
new file mode 100644
index 00000000000..2fe08896585
--- /dev/null
+++ b/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_vert.glsl
@@ -0,0 +1,21 @@
+
+/*
+ * Vertex Shader for dashed lines with 3D coordinates, with uniform multi-colors or uniform single-color,
+ * and unary thickness.
+ *
+ * Dashed is performed in screen space.
+ */
+
+uniform mat4 ModelViewProjectionMatrix;
+
+uniform vec4 color;
+
+in vec3 pos;
+
+out vec4 color_vert;
+
+void main()
+{
+ gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
+ color_vert = color;
+}
diff --git a/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_vert.glsl
deleted file mode 100644
index a02b0d219fb..00000000000
--- a/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_vert.glsl
+++ /dev/null
@@ -1,11 +0,0 @@
-
-// Draw dashed lines, perforated in screen space.
-
-uniform mat4 ModelViewProjectionMatrix;
-
-in vec3 pos;
-
-void main()
-{
- gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
-}
diff --git a/source/blender/gpu/shaders/gpu_shader_instance_edges_variying_color_vert.glsl b/source/blender/gpu/shaders/gpu_shader_instance_edges_variying_color_vert.glsl
index 94cd960872a..fa30c9fb1ed 100644
--- a/source/blender/gpu/shaders/gpu_shader_instance_edges_variying_color_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_instance_edges_variying_color_vert.glsl
@@ -26,9 +26,7 @@ out vec3 fCol;
// TODO: in float angle; // [-pi .. +pi], + peak, 0 flat, - valley
-mat3 NormalMatrix;
-
-bool front(vec3 N, vec3 eye)
+bool front(mat3 NormalMatrix, vec3 N, vec3 eye)
{
return dot(NormalMatrix * N, eye) > 0.0;
}
@@ -41,7 +39,7 @@ void main()
MV_pos = ModelViewMatrix * vec4(pos, 1.0);
- NormalMatrix = transpose(inverse(mat3(ModelViewMatrix)));
+ mat3 NormalMatrix = transpose(inverse(mat3(ModelViewMatrix)));
/* if persp */
if (ProjectionMatrix[3][3] == 0.0) {
@@ -51,8 +49,8 @@ void main()
eye = vec3(0.0, 0.0, 1.0);
}
- bool face_1_front = front(N1, eye);
- bool face_2_front = front(N2, eye);
+ bool face_1_front = front(NormalMatrix, N1, eye);
+ bool face_2_front = front(NormalMatrix, N2, eye);
if (face_1_front && face_2_front)
edgeClass = 1.0; // front-facing edge
diff --git a/source/blender/gpu/shaders/gpu_shader_keyframe_diamond_vert.glsl b/source/blender/gpu/shaders/gpu_shader_keyframe_diamond_vert.glsl
index b86d6fd70fe..c49832bf9b4 100644
--- a/source/blender/gpu/shaders/gpu_shader_keyframe_diamond_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_keyframe_diamond_vert.glsl
@@ -2,7 +2,7 @@
uniform mat4 ModelViewProjectionMatrix;
const float pixel_fudge = sqrt(2.0);
-const float outline_width = 1.25 * pixel_fudge;
+const float outline_width = 1.15 * pixel_fudge;
in vec2 pos;
in float size;
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl
index 88974148505..fb89c554775 100644
--- a/source/blender/gpu/shaders/gpu_shader_material.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material.glsl
@@ -12,7 +12,37 @@ uniform mat4 ProjectionMatrixInverse;
uniform mat3 NormalMatrix;
uniform vec4 CameraTexCoFactors;
-out vec4 fragColor;
+/* Old glsl mode compat. */
+
+#ifndef CLOSURE_DEFAULT
+
+struct Closure {
+ vec3 radiance;
+ float opacity;
+};
+
+#define CLOSURE_DEFAULT Closure(vec3(0.0), 1.0)
+
+Closure closure_mix(Closure cl1, Closure cl2, float fac)
+{
+ Closure cl;
+ cl.radiance = mix(cl1.radiance, cl2.radiance, fac);
+ cl.opacity = mix(cl1.opacity, cl2.opacity, fac);
+ return cl;
+}
+
+Closure closure_add(Closure cl1, Closure cl2)
+{
+ Closure cl;
+ cl.radiance = cl1.radiance + cl2.radiance;
+ cl.opacity = cl1.opacity + cl2.opacity;
+ return cl;
+}
+
+Closure nodetree_exec(void); /* Prototype */
+
+#endif /* CLOSURE_DEFAULT */
+
/* Converters */
@@ -2439,7 +2469,11 @@ float hypot(float x, float y)
void generated_from_orco(vec3 orco, out vec3 generated)
{
+#ifdef VOLUMETRICS
+ generated = worldPosition;
+#else
generated = orco;
+#endif
}
int floor_to_int(float x)
@@ -2573,6 +2607,40 @@ vec3 rotate_vector(vec3 p, vec3 n, float theta) {
);
}
+void prepare_tangent(
+ float anisotropic, float anisotropic_rotation, float roughness, vec3 N, vec3 T,
+ out vec3 X, out vec3 Y, out float ax, out float ay)
+{
+ /* rotate tangent */
+ if (anisotropic_rotation != 0.0) {
+ T = rotate_vector(T, N, anisotropic_rotation * 2.0 * M_PI);
+ }
+
+ Y = normalize(cross(T, N));
+
+ float aspect = sqrt(1.0 - anisotropic * 0.9);
+ float a = sqr(roughness);
+ ax = max(0.001, a / aspect);
+ ay = max(0.001, a * aspect);
+}
+
+void convert_metallic_to_specular(vec3 basecol, float metallic, float specular_fac, out vec3 diffuse, out vec3 f0)
+{
+ vec3 dielectric = vec3(0.034) * specular_fac * 2.0;
+ diffuse = mix(basecol, vec3(0.0), metallic);
+ f0 = mix(dielectric, basecol, metallic);
+}
+
+void convert_metallic_to_specular_tinted(
+ vec3 basecol, float metallic, float specular_fac, float specular_tint,
+ out vec3 diffuse, out vec3 f0)
+{
+ vec3 dielectric = vec3(0.034) * specular_fac * 2.0;
+ float lum = dot(basecol, vec3(0.3, 0.6, 0.1)); /* luminance approx. */
+ vec3 tint = lum > 0 ? basecol / lum : vec3(1.0); /* normalize lum. to isolate hue+sat */
+ f0 = mix(dielectric * mix(vec3(1.0), tint, specular_tint), basecol, metallic);
+ diffuse = mix(basecol, vec3(0.0), metallic);
+}
/*********** NEW SHADER NODES ***************/
@@ -2589,10 +2657,15 @@ layout(std140) uniform lightSource {
glLight glLightSource[NUM_LIGHTS];
};
+#ifndef VOLUMETRICS
/* bsdfs */
-
-void node_bsdf_diffuse(vec4 color, float roughness, vec3 N, out vec4 result)
+void node_bsdf_diffuse(vec4 color, float roughness, vec3 N, out Closure result)
{
+#ifdef EEVEE_ENGINE
+ vec3 L = eevee_surface_diffuse_lit(N, vec3(1.0), 1.0);
+ vec3 vN = normalize(mat3(ViewMatrix) * N);
+ result = Closure(L * color.rgb, 1.0, vec4(0.0), normal_encode(vN, viewCameraVec), -1);
+#else
/* ambient light */
vec3 L = vec3(0.2);
@@ -2605,14 +2678,24 @@ void node_bsdf_diffuse(vec4 color, float roughness, vec3 N, out vec4 result)
L += light_diffuse * bsdf;
}
- result = vec4(L * color.rgb, 1.0);
+ result = Closure(L * color.rgb, 1.0);
+#endif
}
-void node_bsdf_glossy(vec4 color, float roughness, vec3 N, out vec4 result)
+void node_bsdf_glossy(vec4 color, float roughness, vec3 N, float ssr_id, out Closure result)
{
+#ifdef EEVEE_ENGINE
+ vec3 ssr_spec;
+ roughness = sqrt(roughness);
+ vec3 L = eevee_surface_glossy_lit(N, vec3(1.0), roughness, 1.0, int(ssr_id), ssr_spec);
+ vec3 vN = normalize(mat3(ViewMatrix) * N);
+ result = Closure(L * color.rgb, 1.0, vec4(ssr_spec * color.rgb, roughness), normal_encode(vN, viewCameraVec), int(ssr_id));
+#else
/* ambient light */
vec3 L = vec3(0.2);
+ direction_transform_m4v3(N, ViewMatrix, N);
+
/* directional lights */
for (int i = 0; i < NUM_LIGHTS; i++) {
vec3 light_position = glLightSource[i].position.xyz;
@@ -2626,62 +2709,52 @@ void node_bsdf_glossy(vec4 color, float roughness, vec3 N, out vec4 result)
L += light_specular * bsdf;
}
- result = vec4(L * color.rgb, 1.0);
+ result = Closure(L * color.rgb, 1.0);
+#endif
}
void node_bsdf_anisotropic(
vec4 color, float roughness, float anisotropy, float rotation, vec3 N, vec3 T,
- out vec4 result)
+ out Closure result)
{
node_bsdf_diffuse(color, 0.0, N, result);
}
-void node_bsdf_glass(vec4 color, float roughness, float ior, vec3 N, out vec4 result)
+void node_bsdf_glass(vec4 color, float roughness, float ior, vec3 N, float ssr_id, out Closure result)
{
+#ifdef EEVEE_ENGINE
+ vec3 ssr_spec;
+ roughness = sqrt(roughness);
+ vec3 L = eevee_surface_glass(N, (refractionDepth > 0.0) ? color.rgb : vec3(1.0), roughness, ior, int(ssr_id), ssr_spec);
+ vec3 vN = normalize(mat3(ViewMatrix) * N);
+ result = Closure(L * color.rgb, 1.0, vec4(ssr_spec * color.rgb, roughness), normal_encode(vN, viewCameraVec), int(ssr_id));
+#else
node_bsdf_diffuse(color, 0.0, N, result);
+#endif
}
-void node_bsdf_toon(vec4 color, float size, float tsmooth, vec3 N, out vec4 result)
+void node_bsdf_toon(vec4 color, float size, float tsmooth, vec3 N, out Closure result)
{
node_bsdf_diffuse(color, 0.0, N, result);
}
+#ifndef EEVEE_ENGINE
void node_bsdf_principled(vec4 base_color, float subsurface, vec3 subsurface_radius, vec4 subsurface_color, float metallic, float specular,
float specular_tint, float roughness, float anisotropic, float anisotropic_rotation, float sheen, float sheen_tint, float clearcoat,
- float clearcoat_roughness, float ior, float transmission, float transmission_roughness, vec3 N, vec3 CN, vec3 T, vec3 I, out vec4 result)
+ float clearcoat_roughness, float ior, float transmission, float transmission_roughness, vec3 N, vec3 CN, vec3 T, vec3 I, out Closure result)
{
+ vec3 X, Y;
+ float ax, ay;
+ prepare_tangent(anisotropic, anisotropic_rotation, roughness, N, T, X, Y, ax, ay);
+
/* ambient light */
// TODO: set ambient light to an appropriate value
- vec3 L = vec3(mix(0.1, 0.03, metallic)) * base_color.rgb;
+ vec3 L = mix(0.1, 0.03, metallic) * mix(base_color.rgb, subsurface_color.rgb, subsurface * (1.0 - metallic));
float eta = (2.0 / (1.0 - sqrt(0.08 * specular))) - 1.0;
/* set the viewing vector */
- vec3 V = (gl_ProjectionMatrix[3][3] == 0.0) ? -normalize(I) : vec3(0.0, 0.0, 1.0);
-
- /* get the tangent */
- vec3 Tangent = T;
- if (T == vec3(0.0)) {
- // if no tangent is set, use a default tangent
- Tangent = vec3(1.0, 0.0, 0.0);
- if (N.x != 0.0 || N.y != 0.0) {
- vec3 N_xz = normalize(vec3(N.x, 0.0, N.z));
-
- vec3 axis = normalize(cross(vec3(0.0, 0.0, 1.0), N_xz));
- float angle = acos(dot(vec3(0.0, 0.0, 1.0), N_xz));
-
- Tangent = normalize(rotate_vector(vec3(1.0, 0.0, 0.0), axis, angle));
- }
- }
-
- /* rotate tangent */
- if (anisotropic_rotation != 0.0) {
- Tangent = rotate_vector(Tangent, N, anisotropic_rotation * 2.0 * M_PI);
- }
-
- /* calculate the tangent and bitangent */
- vec3 Y = normalize(cross(N, Tangent));
- vec3 X = cross(Y, N);
+ vec3 V = (ProjectionMatrix[3][3] == 0.0) ? -normalize(I) : vec3(0.0, 0.0, 1.0);
/* fresnel normalization parameters */
float F0 = fresnel_dielectric_0(eta);
@@ -2690,10 +2763,11 @@ void node_bsdf_principled(vec4 base_color, float subsurface, vec3 subsurface_rad
/* directional lights */
for (int i = 0; i < NUM_LIGHTS; i++) {
vec3 light_position_world = glLightSource[i].position.xyz;
- vec3 light_position = normalize(NormalMatrix * light_position_world);
+ vec3 light_position = normalize(light_position_world);
vec3 H = normalize(light_position + V);
+ vec3 light_diffuse = glLightSource[i].diffuse.rgb;
vec3 light_specular = glLightSource[i].specular.rgb;
float NdotL = dot(N, light_position);
@@ -2725,10 +2799,6 @@ void node_bsdf_principled(vec4 base_color, float subsurface, vec3 subsurface_rad
float ss = 1.25 * (Fss * (1.0 / (NdotL + NdotV) - 0.5) + 0.5);
// specular
- float aspect = sqrt(1.0 - anisotropic * 0.9);
- float a = sqr(roughness);
- float ax = max(0.001, a / aspect);
- float ay = max(0.001, a * aspect);
float Ds = GTR2_aniso(NdotH, dot(H, X), dot(H, Y), ax, ay); //GTR2(NdotH, a);
float FH = (fresnel_dielectric_cos(LdotH, eta) - F0) * F0_norm;
vec3 Fs = mix(Cspec0, vec3(1.0), FH);
@@ -2738,8 +2808,9 @@ void node_bsdf_principled(vec4 base_color, float subsurface, vec3 subsurface_rad
// sheen
vec3 Fsheen = schlick_fresnel(LdotH) * sheen * Csheen;
- diffuse_and_specular_bsdf = (M_1_PI * mix(Fd, ss, subsurface) * base_color.rgb + Fsheen)
- * (1.0 - metallic) + Gs * Fs * Ds;
+ vec3 diffuse_bsdf = (mix(Fd * base_color.rgb, ss * subsurface_color.rgb, subsurface) + Fsheen) * light_diffuse;
+ vec3 specular_bsdf = Gs * Fs * Ds * light_specular;
+ diffuse_and_specular_bsdf = diffuse_bsdf * (1.0 - metallic) + specular_bsdf;
}
diffuse_and_specular_bsdf *= max(NdotL, 0.0);
@@ -2756,62 +2827,158 @@ void node_bsdf_principled(vec4 base_color, float subsurface, vec3 subsurface_rad
float Fr = fresnel_dielectric_cos(LdotH, 1.5); //mix(0.04, 1.0, FH);
float Gr = smithG_GGX(CNdotL, 0.25) * smithG_GGX(CNdotV, 0.25);
- clearcoat_bsdf = clearcoat * Gr * Fr * Dr * vec3(0.25);
+ clearcoat_bsdf = clearcoat * Gr * Fr * Dr * vec3(0.25) * light_specular;
}
clearcoat_bsdf *= max(CNdotL, 0.0);
- L += light_specular * (diffuse_and_specular_bsdf + clearcoat_bsdf);
+ L += diffuse_and_specular_bsdf + clearcoat_bsdf;
}
- result = vec4(L, 1.0);
+ result = Closure(L, 1.0);
}
+#endif
-void node_bsdf_translucent(vec4 color, vec3 N, out vec4 result)
+void node_bsdf_principled_simple(vec4 base_color, float subsurface, vec3 subsurface_radius, vec4 subsurface_color, float metallic, float specular,
+ float specular_tint, float roughness, float anisotropic, float anisotropic_rotation, float sheen, float sheen_tint, float clearcoat,
+ float clearcoat_roughness, float ior, float transmission, float transmission_roughness, vec3 N, vec3 CN, vec3 T, vec3 I, float ssr_id, out Closure result)
{
- node_bsdf_diffuse(color, 0.0, N, result);
+#ifdef EEVEE_ENGINE
+ vec3 diffuse, f0, ssr_spec;
+ convert_metallic_to_specular_tinted(base_color.rgb, metallic, specular, specular_tint, diffuse, f0);
+
+ vec3 L = eevee_surface_lit(N, diffuse, f0, roughness, 1.0, int(ssr_id), ssr_spec);
+ vec3 vN = normalize(mat3(ViewMatrix) * N);
+ result = Closure(L, 1.0, vec4(ssr_spec, roughness), normal_encode(vN, viewCameraVec), int(ssr_id));
+#else
+ node_bsdf_principled(base_color, subsurface, subsurface_radius, subsurface_color, metallic, specular,
+ specular_tint, roughness, anisotropic, anisotropic_rotation, sheen, sheen_tint, clearcoat,
+ clearcoat_roughness, ior, transmission, transmission_roughness, N, CN, T, I, result);
+#endif
+}
+
+void node_bsdf_principled_clearcoat(vec4 base_color, float subsurface, vec3 subsurface_radius, vec4 subsurface_color, float metallic, float specular,
+ float specular_tint, float roughness, float anisotropic, float anisotropic_rotation, float sheen, float sheen_tint, float clearcoat,
+ float clearcoat_roughness, float ior, float transmission, float transmission_roughness, vec3 N, vec3 CN, vec3 T, vec3 I, float ssr_id, out Closure result)
+{
+#ifdef EEVEE_ENGINE
+ if (clearcoat == 0.0) {
+ node_bsdf_principled_simple(
+ base_color, subsurface, subsurface_radius, subsurface_color, metallic, specular,
+ specular_tint, roughness, anisotropic, anisotropic_rotation, sheen, sheen_tint, clearcoat,
+ clearcoat_roughness, ior, transmission, transmission_roughness, N, CN, T, I, ssr_id, result);
+ return;
+ }
+
+ vec3 diffuse, f0, ssr_spec;
+ convert_metallic_to_specular_tinted(base_color.rgb, metallic, specular, specular_tint, diffuse, f0);
+
+ clearcoat *= 0.25;
+#if 0 /* Wait until temporal AA (aka. denoising) */
+
+ vec3 X, Y;
+ float ax, ay;
+ prepare_tangent(anisotropic, anisotropic_rotation, roughness, N, T, X, Y, ax, ay);
+
+ /* Distribute N in anisotropy direction. */
+ vec4 surface_color = vec4(0.0);
+ for (float i = 0.0; i < 5.0; ++i) {
+ vec4 rand = texture(utilTex, vec3((gl_FragCoord.xy + i) / LUT_SIZE, 2.0));
+
+ float tmp = sqrt( rand.x / (1.0 - rand.x) );
+ float x = (ax > ay ? ax : 0.0) * tmp * rand.z;
+ float y = (ay > ax ? ay : 0.0) * tmp * rand.w;
+ vec3 Ht = normalize(vec3(x, y, 1.0));
+ N = tangent_to_world(Ht, N, Y, X);
+
+ if (dot(N, cameraVec) > 0) {
+ surface_color.rgb += eevee_surface_clearcoat_lit(N, diffuse, f0, sqrt(min(ax, ay)), CN, clearcoat, clearcoat_roughness, 1.0, ssr_id);
+ surface_color.a += 1.0;
+ }
+ }
+ result = Closure(surface_color.rgb / surface_color.a, 1.0);
+#else
+ vec3 L_trans = (transmission <= 0.0) ? vec3(0.0) : eevee_surface_glass(N, base_color.rgb * ((refractionDepth > 0.0) ? base_color.rgb : vec3(1.0)), roughness, ior, REFRACT_CLOSURE_FLAG, ssr_spec);
+ vec3 L = eevee_surface_clearcoat_lit(N, diffuse, f0, roughness, CN, clearcoat, clearcoat_roughness, 1.0, int(ssr_id), ssr_spec);
+ L = mix(L, L_trans, transmission);
+ vec3 vN = normalize(mat3(ViewMatrix) * N);
+ result = Closure(L, 1.0, vec4(ssr_spec, roughness), normal_encode(vN, viewCameraVec), int(ssr_id));
+#endif
+
+#else
+ node_bsdf_principled(base_color, subsurface, subsurface_radius, subsurface_color, metallic, specular,
+ specular_tint, roughness, anisotropic, anisotropic_rotation, sheen, sheen_tint, clearcoat,
+ clearcoat_roughness, ior, transmission, transmission_roughness, N, CN, T, I, result);
+#endif
+}
+
+void node_bsdf_translucent(vec4 color, vec3 N, out Closure result)
+{
+ node_bsdf_diffuse(color, 0.0, -N, result);
}
-void node_bsdf_transparent(vec4 color, out vec4 result)
+void node_bsdf_transparent(vec4 color, out Closure result)
{
/* this isn't right */
- result.r = color.r;
- result.g = color.g;
- result.b = color.b;
- result.a = 0.0;
+ result.radiance = vec3(0.0);
+ result.opacity = 0.0;
+#ifdef EEVEE_ENGINE
+ result.ssr_id = TRANSPARENT_CLOSURE_FLAG;
+#endif
}
-void node_bsdf_velvet(vec4 color, float sigma, vec3 N, out vec4 result)
+void node_bsdf_velvet(vec4 color, float sigma, vec3 N, out Closure result)
{
node_bsdf_diffuse(color, 0.0, N, result);
}
void node_subsurface_scattering(
vec4 color, float scale, vec3 radius, float sharpen, float texture_blur, vec3 N,
- out vec4 result)
+ out Closure result)
{
node_bsdf_diffuse(color, 0.0, N, result);
}
-void node_bsdf_hair(vec4 color, float offset, float roughnessu, float roughnessv, vec3 tangent, out vec4 result)
+void node_bsdf_refraction(vec4 color, float roughness, float ior, vec3 N, out Closure result)
{
- result = color;
+#ifdef EEVEE_ENGINE
+ color.rgb *= (refractionDepth > 0.0) ? color.rgb : vec3(1.0); /* Simulate 2 absorption event. */
+ roughness = sqrt(roughness);
+ vec3 L = eevee_surface_refraction(N, vec3(1.0), roughness, ior);
+ result = Closure(L * color.rgb, 1.0, vec4(0.0), vec2(0.0), REFRACT_CLOSURE_FLAG);
+#else
+ node_bsdf_diffuse(color, 0.0, N, result);
+#endif /* EEVEE_ENGINE */
}
-void node_bsdf_refraction(vec4 color, float roughness, float ior, vec3 N, out vec4 result)
+/* Unsupported for now */
+#ifndef EEVEE_ENGINE
+void node_bsdf_hair(vec4 color, float offset, float roughnessu, float roughnessv, vec3 tangent, out Closure result)
{
- node_bsdf_diffuse(color, 0.0, N, result);
+ result = Closure(color.rgb, color.a);
}
-void node_ambient_occlusion(vec4 color, out vec4 result)
+void node_ambient_occlusion(vec4 color, out Closure result)
{
- result = color;
+ result = Closure(color.rgb, color.a);
}
+#endif /* EEVEE_ENGINE */
+
+#endif /* VOLUMETRICS */
/* emission */
-void node_emission(vec4 color, float strength, vec3 N, out vec4 result)
+void node_emission(vec4 color, float strength, vec3 N, out Closure result)
{
- result = color * strength;
+#ifndef VOLUMETRICS
+ color *= strength;
+#ifdef EEVEE_ENGINE
+ result = Closure(color.rgb, color.a, vec4(0.0), normal_encode(N, viewCameraVec), -1);
+#else
+ result = Closure(color.rgb, color.a);
+#endif
+#else
+ result = Closure(vec3(0.0), vec3(0.0), color.rgb * strength, 0.0);
+#endif
}
/* background */
@@ -2822,39 +2989,57 @@ void background_transform_to_world(vec3 viewvec, out vec3 worldvec)
vec4 co_homogenous = (ProjectionMatrixInverse * v);
vec4 co = vec4(co_homogenous.xyz / co_homogenous.w, 0.0);
-#ifdef WORLD_BACKGROUND
+#if defined(WORLD_BACKGROUND) || defined(PROBE_CAPTURE)
worldvec = (ViewMatrixInverse * co).xyz;
#else
worldvec = (ModelViewMatrixInverse * co).xyz;
#endif
}
-#if defined(PROBE_CAPTURE) || defined(WORLD_BACKGROUND)
-void environment_default_vector(out vec3 worldvec)
+void node_background(vec4 color, float strength, out Closure result)
{
-#ifdef WORLD_BACKGROUND
- background_transform_to_world(viewPosition, worldvec);
+#ifndef VOLUMETRICS
+ color *= strength;
+#ifdef EEVEE_ENGINE
+ result = Closure(color.rgb, color.a, vec4(0.0), vec2(0.0), -1);
#else
- worldvec = normalize(worldPosition);
+ result = Closure(color.rgb, color.a);
+#endif
+#else
+ result = CLOSURE_DEFAULT;
#endif
}
+
+/* volumes */
+
+void node_volume_scatter(vec4 color, float density, float anisotropy, out Closure result)
+{
+#ifdef VOLUMETRICS
+ result = Closure(vec3(0.0), color.rgb * density, vec3(0.0), anisotropy);
+#else
+ result = CLOSURE_DEFAULT;
#endif
+}
-void node_background(vec4 color, float strength, out vec4 result)
+void node_volume_absorption(vec4 color, float density, out Closure result)
{
- result = color * strength;
+#ifdef VOLUMETRICS
+ result = Closure((1.0 - color.rgb) * density, vec3(0.0), vec3(0.0), 0.0);
+#else
+ result = CLOSURE_DEFAULT;
+#endif
}
/* closures */
-void node_mix_shader(float fac, vec4 shader1, vec4 shader2, out vec4 shader)
+void node_mix_shader(float fac, Closure shader1, Closure shader2, out Closure shader)
{
- shader = mix(shader1, shader2, fac);
+ shader = closure_mix(shader1, shader2, fac);
}
-void node_add_shader(vec4 shader1, vec4 shader2, out vec4 shader)
+void node_add_shader(Closure shader1, Closure shader2, out Closure shader)
{
- shader = shader1 + shader2;
+ shader = closure_add(shader1, shader2);
}
/* fresnel */
@@ -2949,7 +3134,11 @@ void node_geometry(
out vec3 true_normal, out vec3 incoming, out vec3 parametric,
out float backfacing, out float pointiness)
{
+#ifdef EEVEE_ENGINE
+ position = worldPosition;
+#else
position = (toworld * vec4(I, 1.0)).xyz;
+#endif
normal = (toworld * vec4(N, 0.0)).xyz;
tangent_orco_z(orco, orco);
node_tangent(N, orco, objmat, toworld, tangent);
@@ -2997,9 +3186,7 @@ void node_tex_coord_background(
co = normalize(co);
-#ifdef PROBE_CAPTURE
- vec3 coords = normalize(worldPosition);
-#elif defined(WORLD_BACKGROUND)
+#if defined(WORLD_BACKGROUND) || defined(PROBE_CAPTURE)
vec3 coords = (ViewMatrixInverse * co).xyz;
#else
vec3 coords = (ModelViewMatrixInverse * co).xyz;
@@ -3199,15 +3386,17 @@ void node_tex_image(vec3 co, sampler2D ima, out vec4 color, out float alpha)
}
void node_tex_image_box(vec3 texco,
- vec3 nob,
+ vec3 N,
sampler2D ima,
float blend,
out vec4 color,
out float alpha)
{
+ vec3 signed_N = N;
+
/* project from direction vector to barycentric coordinates in triangles */
- nob = vec3(abs(nob.x), abs(nob.y), abs(nob.z));
- nob /= (nob.x + nob.y + nob.z);
+ N = vec3(abs(N.x), abs(N.y), abs(N.z));
+ N /= (N.x + N.y + N.z);
/* basic idea is to think of this as a triangle, each corner representing
* one of the 3 faces of the cube. in the corners we have single textures,
@@ -3223,37 +3412,37 @@ void node_tex_image_box(vec3 texco,
float limit = 0.5 * (1.0 + blend);
/* first test for corners with single texture */
- if (nob.x > limit * (nob.x + nob.y) && nob.x > limit * (nob.x + nob.z)) {
+ if (N.x > limit * (N.x + N.y) && N.x > limit * (N.x + N.z)) {
weight.x = 1.0;
}
- else if (nob.y > limit * (nob.x + nob.y) && nob.y > limit * (nob.y + nob.z)) {
+ else if (N.y > limit * (N.x + N.y) && N.y > limit * (N.y + N.z)) {
weight.y = 1.0;
}
- else if (nob.z > limit * (nob.x + nob.z) && nob.z > limit * (nob.y + nob.z)) {
+ else if (N.z > limit * (N.x + N.z) && N.z > limit * (N.y + N.z)) {
weight.z = 1.0;
}
else if (blend > 0.0) {
/* in case of blending, test for mixes between two textures */
- if (nob.z < (1.0 - limit) * (nob.y + nob.x)) {
- weight.x = nob.x / (nob.x + nob.y);
+ if (N.z < (1.0 - limit) * (N.y + N.x)) {
+ weight.x = N.x / (N.x + N.y);
weight.x = clamp((weight.x - 0.5 * (1.0 - blend)) / blend, 0.0, 1.0);
weight.y = 1.0 - weight.x;
}
- else if (nob.x < (1.0 - limit) * (nob.y + nob.z)) {
- weight.y = nob.y / (nob.y + nob.z);
+ else if (N.x < (1.0 - limit) * (N.y + N.z)) {
+ weight.y = N.y / (N.y + N.z);
weight.y = clamp((weight.y - 0.5 * (1.0 - blend)) / blend, 0.0, 1.0);
weight.z = 1.0 - weight.y;
}
- else if (nob.y < (1.0 - limit) * (nob.x + nob.z)) {
- weight.x = nob.x / (nob.x + nob.z);
+ else if (N.y < (1.0 - limit) * (N.x + N.z)) {
+ weight.x = N.x / (N.x + N.z);
weight.x = clamp((weight.x - 0.5 * (1.0 - blend)) / blend, 0.0, 1.0);
weight.z = 1.0 - weight.x;
}
else {
/* last case, we have a mix between three */
- weight.x = ((2.0 - limit) * nob.x + (limit - 1.0)) / (2.0 * limit - 1.0);
- weight.y = ((2.0 - limit) * nob.y + (limit - 1.0)) / (2.0 * limit - 1.0);
- weight.z = ((2.0 - limit) * nob.z + (limit - 1.0)) / (2.0 * limit - 1.0);
+ weight.x = ((2.0 - limit) * N.x + (limit - 1.0)) / (2.0 * limit - 1.0);
+ weight.y = ((2.0 - limit) * N.y + (limit - 1.0)) / (2.0 * limit - 1.0);
+ weight.z = ((2.0 - limit) * N.z + (limit - 1.0)) / (2.0 * limit - 1.0);
}
}
else {
@@ -3262,13 +3451,25 @@ void node_tex_image_box(vec3 texco,
}
color = vec4(0);
if (weight.x > 0.0) {
- color += weight.x * texture(ima, texco.yz);
+ vec2 uv = texco.yz;
+ if(signed_N.x < 0.0) {
+ uv.x = 1.0 - uv.x;
+ }
+ color += weight.x * texture(ima, uv);
}
if (weight.y > 0.0) {
- color += weight.y * texture(ima, texco.xz);
+ vec2 uv = texco.xz;
+ if(signed_N.y > 0.0) {
+ uv.x = 1.0 - uv.x;
+ }
+ color += weight.y * texture(ima, uv);
}
if (weight.z > 0.0) {
- color += weight.z * texture(ima, texco.yx);
+ vec2 uv = texco.yx;
+ if(signed_N.z > 0.0) {
+ uv.x = 1.0 - uv.x;
+ }
+ color += weight.z * texture(ima, uv);
}
alpha = color.a;
@@ -3850,25 +4051,27 @@ void node_bump(float strength, float dist, float height, vec3 N, vec3 surf_pos,
/* output */
-void node_output_material(vec4 surface, vec4 volume, float displacement, out vec4 result)
+void node_output_material(Closure surface, Closure volume, float displacement, out Closure result)
{
result = surface;
}
uniform float backgroundAlpha;
-void node_output_world(vec4 surface, vec4 volume, out vec4 result)
+void node_output_world(Closure surface, Closure volume, out Closure result)
{
- result = vec4(surface.rgb, backgroundAlpha);
-}
-
-void convert_metallic_to_specular(vec4 basecol, float metallic, float specular_fac, out vec4 diffuse, out vec4 f0)
-{
- vec4 dielectric = vec4(0.034) * specular_fac * 2.0;
- diffuse = mix(basecol, vec4(0.0), metallic);
- f0 = mix(dielectric, basecol, metallic);
+#ifndef VOLUMETRICS
+#ifdef EEVEE_ENGINE
+ result = Closure(surface.radiance, backgroundAlpha, vec4(0.0), vec2(0.0), -1);
+#else
+ result = Closure(surface.radiance, backgroundAlpha);
+#endif
+#else
+ result = volume;
+#endif /* VOLUMETRICS */
}
+#ifndef VOLUMETRICS
/* TODO : clean this ifdef mess */
/* EEVEE output */
#ifdef EEVEE_ENGINE
@@ -3877,31 +4080,20 @@ void world_normals_get(out vec3 N)
N = gl_FrontFacing ? worldNormal : -worldNormal;
}
-void node_eevee_metallic(
- vec4 basecol, float metallic, float specular, float roughness, vec4 emissive, float transp, vec3 normal,
- float clearcoat, float clearcoat_roughness, vec3 clearcoat_normal,
- float occlusion, out vec4 result)
-{
- vec4 diffuse, f0;
- convert_metallic_to_specular(basecol, metallic, specular, diffuse, f0);
-
- result = vec4(eevee_surface_lit(normal, diffuse.rgb, f0.rgb, roughness, occlusion) + emissive.rgb, 1.0 - transp);
-}
-
void node_eevee_specular(
vec4 diffuse, vec4 specular, float roughness, vec4 emissive, float transp, vec3 normal,
float clearcoat, float clearcoat_roughness, vec3 clearcoat_normal,
- float occlusion, out vec4 result)
+ float occlusion, float ssr_id, out Closure result)
{
- result = vec4(eevee_surface_lit(normal, diffuse.rgb, specular.rgb, roughness, occlusion) + emissive.rgb, 1.0 - transp);
-}
+ vec3 ssr_spec;
-void node_output_eevee_material(vec4 surface, out vec4 result)
-{
- result = vec4(surface.rgb, length(viewPosition));
+ vec3 L = eevee_surface_lit(normal, diffuse.rgb, specular.rgb, roughness, occlusion, int(ssr_id), ssr_spec);
+ vec3 vN = normalize(mat3(ViewMatrix) * normal);
+ result = Closure(L + emissive.rgb, 1.0 - transp, vec4(ssr_spec, roughness), normal_encode(vN, viewCameraVec), int(ssr_id));
}
-#endif
+#endif /* EEVEE_ENGINE */
+#endif /* VOLUMETRICS */
/* ********************** matcap style render ******************** */
diff --git a/source/blender/gpu/shaders/gpu_shader_uniform_color_frag.glsl b/source/blender/gpu/shaders/gpu_shader_uniform_color_frag.glsl
index 5dd1352adc5..118a661863d 100644
--- a/source/blender/gpu/shaders/gpu_shader_uniform_color_frag.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_uniform_color_frag.glsl
@@ -1,9 +1,21 @@
+#if defined(USE_COLOR_U32)
+uniform uint color;
+#else
uniform vec4 color;
+#endif
out vec4 fragColor;
void main()
{
+#if defined(USE_COLOR_U32)
+ fragColor = vec4(
+ ((color ) & uint(0xFF)) * (1.0f / 255.0f),
+ ((color >> 8) & uint(0xFF)) * (1.0f / 255.0f),
+ ((color >> 16) & uint(0xFF)) * (1.0f / 255.0f),
+ ((color >> 24) ) * (1.0f / 255.0f));
+#else
fragColor = color;
+#endif
}
diff --git a/source/blender/ikplugin/BIK_api.h b/source/blender/ikplugin/BIK_api.h
index 177be074897..ad842029941 100644
--- a/source/blender/ikplugin/BIK_api.h
+++ b/source/blender/ikplugin/BIK_api.h
@@ -43,6 +43,7 @@ struct bPoseChannel;
struct bPose;
struct Scene;
struct bConstraint;
+struct EvaluationContext;
enum BIK_ParamType {
BIK_PARAM_TYPE_FLOAT = 0,
@@ -61,8 +62,8 @@ struct BIK_ParamValue {
};
typedef struct BIK_ParamValue BIK_ParamValue;
-void BIK_initialize_tree(struct Scene *scene, struct Object *ob, float ctime);
-void BIK_execute_tree(struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime);
+void BIK_initialize_tree(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, float ctime);
+void BIK_execute_tree(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime);
void BIK_release_tree(struct Scene *scene, struct Object *ob, float ctime);
void BIK_clear_data(struct bPose *pose);
void BIK_clear_cache(struct bPose *pose);
diff --git a/source/blender/ikplugin/intern/ikplugin_api.c b/source/blender/ikplugin/intern/ikplugin_api.c
index 0f81fb34a63..0ee26ff45f1 100644
--- a/source/blender/ikplugin/intern/ikplugin_api.c
+++ b/source/blender/ikplugin/intern/ikplugin_api.c
@@ -89,20 +89,20 @@ static IKPlugin *get_plugin(bPose *pose)
/*----------------------------------------*/
/* Plugin API */
-void BIK_initialize_tree(Scene *scene, Object *ob, float ctime)
+void BIK_initialize_tree(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float ctime)
{
IKPlugin *plugin = get_plugin(ob->pose);
if (plugin && plugin->initialize_tree_func)
- plugin->initialize_tree_func(scene, ob, ctime);
+ plugin->initialize_tree_func(eval_ctx, scene, ob, ctime);
}
-void BIK_execute_tree(struct Scene *scene, Object *ob, bPoseChannel *pchan, float ctime)
+void BIK_execute_tree(const struct EvaluationContext *eval_ctx, struct Scene *scene, Object *ob, bPoseChannel *pchan, float ctime)
{
IKPlugin *plugin = get_plugin(ob->pose);
if (plugin && plugin->execute_tree_func)
- plugin->execute_tree_func(scene, ob, pchan, ctime);
+ plugin->execute_tree_func(eval_ctx, scene, ob, pchan, ctime);
}
void BIK_release_tree(struct Scene *scene, Object *ob, float ctime)
diff --git a/source/blender/ikplugin/intern/ikplugin_api.h b/source/blender/ikplugin/intern/ikplugin_api.h
index cd32bf26242..9a71463ede4 100644
--- a/source/blender/ikplugin/intern/ikplugin_api.h
+++ b/source/blender/ikplugin/intern/ikplugin_api.h
@@ -41,11 +41,12 @@ extern "C" {
struct Object;
struct bPoseChannel;
struct Scene;
+struct EvaluationContext;
struct IKPlugin {
- void (*initialize_tree_func)(struct Scene *scene, struct Object *ob, float ctime);
- void (*execute_tree_func)(struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime);
+ void (*initialize_tree_func)(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, float ctime);
+ void (*execute_tree_func)(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime);
void (*release_tree_func)(struct Scene *scene, struct Object *ob, float ctime);
void (*remove_armature_func)(struct bPose *pose);
void (*clear_cache)(struct bPose *pose);
diff --git a/source/blender/ikplugin/intern/iksolver_plugin.c b/source/blender/ikplugin/intern/iksolver_plugin.c
index 6ea311b2c7b..5169b72590c 100644
--- a/source/blender/ikplugin/intern/iksolver_plugin.c
+++ b/source/blender/ikplugin/intern/iksolver_plugin.c
@@ -217,9 +217,27 @@ static void where_is_ik_bone(bPoseChannel *pchan, float ik_mat[3][3]) // nr =
copy_m4_m3(ikmat, ik_mat);
if (pchan->parent)
- mul_m4_series(pchan->pose_mat, pchan->parent->pose_mat, pchan->chan_mat, ikmat);
+ mul_m4_m4m4(pchan->pose_mat, pchan->parent->pose_mat, pchan->chan_mat);
else
- mul_m4_m4m4(pchan->pose_mat, pchan->chan_mat, ikmat);
+ copy_m4_m4(pchan->pose_mat, pchan->chan_mat);
+
+#ifdef USE_NONUNIFORM_SCALE
+ /* apply IK mat, but as if the bones have uniform scale since the IK solver
+ * is not aware of non-uniform scale */
+ float scale[3];
+ mat4_to_size(scale, pchan->pose_mat);
+ normalize_v3_length(pchan->pose_mat[0], scale[1]);
+ normalize_v3_length(pchan->pose_mat[2], scale[1]);
+#endif
+
+ mul_m4_m4m4(pchan->pose_mat, pchan->pose_mat, ikmat);
+
+#ifdef USE_NONUNIFORM_SCALE
+ float ik_scale[3];
+ mat3_to_size(ik_scale, ik_mat);
+ normalize_v3_length(pchan->pose_mat[0], scale[0] * ik_scale[0]);
+ normalize_v3_length(pchan->pose_mat[2], scale[2] * ik_scale[2]);
+#endif
/* calculate head */
copy_v3_v3(pchan->pose_head, pchan->pose_mat[3]);
@@ -234,7 +252,7 @@ static void where_is_ik_bone(bPoseChannel *pchan, float ik_mat[3][3]) // nr =
/* called from within the core BKE_pose_where_is loop, all animsystems and constraints
* were executed & assigned. Now as last we do an IK pass */
-static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
+static void execute_posetree(const struct EvaluationContext *eval_ctx, struct Scene *scene, Object *ob, PoseTree *tree)
{
float R_parmat[3][3], identity[3][3];
float iR_parmat[3][3];
@@ -308,6 +326,10 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
/* change length based on bone size */
length = bone->length * len_v3(R_bonemat[1]);
+ /* basis must be pure rotation */
+ normalize_m3(R_bonemat);
+ normalize_m3(R_parmat);
+
/* compute rest basis and its inverse */
copy_m3_m3(rest_basis, bone->bone_mat);
transpose_m3_m3(irest_basis, bone->bone_mat);
@@ -317,11 +339,7 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
mul_m3_m3m3(full_basis, iR_parmat, R_bonemat);
mul_m3_m3m3(basis, irest_basis, full_basis);
- /* basis must be pure rotation */
- normalize_m3(basis);
-
/* transform offset into local bone space */
- normalize_m3(iR_parmat);
mul_m3_v3(iR_parmat, start);
IK_SetTransform(seg, start, rest_basis, basis, length);
@@ -376,7 +394,7 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
/* 1.0=ctime, we pass on object for auto-ik (owner-type here is object, even though
* strictly speaking, it is a posechannel)
*/
- BKE_constraint_target_matrix_get(scene, target->con, 0, CONSTRAINT_OBTYPE_OBJECT, ob, rootmat, 1.0);
+ BKE_constraint_target_matrix_get(eval_ctx, scene, target->con, 0, CONSTRAINT_OBTYPE_OBJECT, ob, rootmat, 1.0);
/* and set and transform goal */
mul_m4_m4m4(goal, goalinv, rootmat);
@@ -387,7 +405,7 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
/* same for pole vector target */
if (data->poletar) {
- BKE_constraint_target_matrix_get(scene, target->con, 1, CONSTRAINT_OBTYPE_OBJECT, ob, rootmat, 1.0);
+ BKE_constraint_target_matrix_get(eval_ctx, scene, target->con, 1, CONSTRAINT_OBTYPE_OBJECT, ob, rootmat, 1.0);
if (data->flag & CONSTRAINT_IK_SETANGLE) {
/* don't solve IK when we are setting the pole angle */
@@ -516,7 +534,7 @@ static void free_posetree(PoseTree *tree)
///----------------------------------------
/// Plugin API for legacy iksolver
-void iksolver_initialize_tree(struct Scene *UNUSED(scene), struct Object *ob, float UNUSED(ctime))
+void iksolver_initialize_tree(const struct EvaluationContext *UNUSED(eval_ctx), struct Scene *UNUSED(scene), struct Object *ob, float UNUSED(ctime))
{
bPoseChannel *pchan;
@@ -527,7 +545,7 @@ void iksolver_initialize_tree(struct Scene *UNUSED(scene), struct Object *ob, fl
ob->pose->flag &= ~POSE_WAS_REBUILT;
}
-void iksolver_execute_tree(struct Scene *scene, Object *ob, bPoseChannel *pchan_root, float ctime)
+void iksolver_execute_tree(const struct EvaluationContext *eval_ctx, struct Scene *scene, Object *ob, bPoseChannel *pchan_root, float ctime)
{
while (pchan_root->iktree.first) {
PoseTree *tree = pchan_root->iktree.first;
@@ -540,25 +558,13 @@ void iksolver_execute_tree(struct Scene *scene, Object *ob, bPoseChannel *pchan
/* 4. walk over the tree for regular solving */
for (a = 0; a < tree->totchannel; a++) {
if (!(tree->pchan[a]->flag & POSE_DONE)) // successive trees can set the flag
- BKE_pose_where_is_bone(scene, ob, tree->pchan[a], ctime, 1);
+ BKE_pose_where_is_bone(eval_ctx, scene, ob, tree->pchan[a], ctime, 1);
/* tell blender that this channel was controlled by IK, it's cleared on each BKE_pose_where_is() */
tree->pchan[a]->flag |= POSE_CHAIN;
}
-#ifdef USE_NONUNIFORM_SCALE
- float (*pchan_scale_data)[3] = MEM_mallocN(sizeof(float[3]) * tree->totchannel, __func__);
-
- for (a = 0; a < tree->totchannel; a++) {
- mat4_to_size(pchan_scale_data[a], tree->pchan[a]->pose_mat);
-
- /* make uniform at y scale since this controls the length */
- normalize_v3_length(tree->pchan[a]->pose_mat[0], pchan_scale_data[a][1]);
- normalize_v3_length(tree->pchan[a]->pose_mat[2], pchan_scale_data[a][1]);
- }
-#endif
-
/* 5. execute the IK solver */
- execute_posetree(scene, ob, tree);
+ execute_posetree(eval_ctx, scene, ob, tree);
/* 6. apply the differences to the channels,
* we need to calculate the original differences first */
@@ -571,14 +577,6 @@ void iksolver_execute_tree(struct Scene *scene, Object *ob, bPoseChannel *pchan
where_is_ik_bone(tree->pchan[a], tree->basis_change[a]);
}
-#ifdef USE_NONUNIFORM_SCALE
- for (a = 0; a < tree->totchannel; a++) {
- normalize_v3_length(tree->pchan[a]->pose_mat[0], pchan_scale_data[a][0]);
- normalize_v3_length(tree->pchan[a]->pose_mat[2], pchan_scale_data[a][2]);
- }
- MEM_freeN(pchan_scale_data);
-#endif
-
/* 7. and free */
BLI_remlink(&pchan_root->iktree, tree);
free_posetree(tree);
diff --git a/source/blender/ikplugin/intern/iksolver_plugin.h b/source/blender/ikplugin/intern/iksolver_plugin.h
index 07264280a25..f1ca91ebb49 100644
--- a/source/blender/ikplugin/intern/iksolver_plugin.h
+++ b/source/blender/ikplugin/intern/iksolver_plugin.h
@@ -40,8 +40,11 @@
extern "C" {
#endif
-void iksolver_initialize_tree(struct Scene *scene, struct Object *ob, float ctime);
-void iksolver_execute_tree(struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan_root, float ctime);
+void iksolver_initialize_tree(
+ const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, float ctime);
+void iksolver_execute_tree(
+ const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
+ struct bPoseChannel *pchan_root, float ctime);
#ifdef __cplusplus
}
diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp
index d58340965a7..93460559067 100644
--- a/source/blender/ikplugin/intern/itasc_plugin.cpp
+++ b/source/blender/ikplugin/intern/itasc_plugin.cpp
@@ -542,7 +542,7 @@ static void GetJointRotation(KDL::Rotation& boneRot, int type, double *rot)
}
}
-static bool target_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Frame& current, iTaSC::Frame& next, void *param)
+static bool target_callback(const struct EvaluationContext *eval_ctx, const iTaSC::Timestamp& timestamp, const iTaSC::Frame& current, iTaSC::Frame& next, void *param)
{
IK_Target *target = (IK_Target *)param;
// compute next target position
@@ -550,7 +550,7 @@ static bool target_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Fram
bConstraint *constraint = (bConstraint *)target->blenderConstraint;
float tarmat[4][4];
- BKE_constraint_target_matrix_get(target->blscene, constraint, 0, CONSTRAINT_OBTYPE_OBJECT, target->owner, tarmat, 1.0);
+ BKE_constraint_target_matrix_get(eval_ctx, target->blscene, constraint, 0, CONSTRAINT_OBTYPE_OBJECT, target->owner, tarmat, 1.0);
// rootmat contains the target pose in world coordinate
// if enforce is != 1.0, blend the target position with the end effector position
@@ -577,7 +577,7 @@ static bool target_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Fram
return true;
}
-static bool base_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Frame& current, iTaSC::Frame& next, void *param)
+static bool base_callback(const struct EvaluationContext *eval_ctx, const iTaSC::Timestamp& timestamp, const iTaSC::Frame& current, iTaSC::Frame& next, void *param)
{
IK_Scene *ikscene = (IK_Scene *)param;
// compute next armature base pose
@@ -619,7 +619,7 @@ static bool base_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Frame&
IK_Channel &rootchan = ikscene->channels[0];
// get polar target matrix in world space
- BKE_constraint_target_matrix_get(ikscene->blscene, ikscene->polarConstraint, 1, CONSTRAINT_OBTYPE_OBJECT, ikscene->blArmature, mat, 1.0);
+ BKE_constraint_target_matrix_get(eval_ctx, ikscene->blscene, ikscene->polarConstraint, 1, CONSTRAINT_OBTYPE_OBJECT, ikscene->blArmature, mat, 1.0);
// convert to armature space
mul_m4_m4m4(polemat, imat, mat);
// get the target in world space (was computed before as target object are defined before base object)
@@ -863,7 +863,7 @@ static bool joint_callback(const iTaSC::Timestamp& timestamp, iTaSC::ConstraintV
}
// build array of joint corresponding to IK chain
-static int convert_channels(IK_Scene *ikscene, PoseTree *tree, float ctime)
+static int convert_channels(const struct EvaluationContext *eval_ctx, IK_Scene *ikscene, PoseTree *tree, float ctime)
{
IK_Channel *ikchan;
bPoseChannel *pchan;
@@ -880,7 +880,7 @@ static int convert_channels(IK_Scene *ikscene, PoseTree *tree, float ctime)
// this is because some of the pose data (e.g. pose head) don't have corresponding
// joint angles and can't be applied to the iTaSC armature dynamically
if (!(pchan->flag & POSE_DONE))
- BKE_pose_where_is_bone(ikscene->blscene, ikscene->blArmature, pchan, ctime, 1);
+ BKE_pose_where_is_bone(eval_ctx, ikscene->blscene, ikscene->blArmature, pchan, ctime, 1);
// tell blender that this channel was controlled by IK, it's cleared on each BKE_pose_where_is()
pchan->flag |= (POSE_DONE | POSE_CHAIN);
@@ -1056,7 +1056,7 @@ static void BKE_pose_rest(IK_Scene *ikscene)
}
}
-static IK_Scene *convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan, float ctime)
+static IK_Scene *convert_tree(const struct EvaluationContext *eval_ctx, Scene *blscene, Object *ob, bPoseChannel *pchan, float ctime)
{
PoseTree *tree = (PoseTree *)pchan->iktree.first;
PoseTarget *target;
@@ -1134,7 +1134,7 @@ static IK_Scene *convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan, f
std::vector<double> weights;
double weight[3];
// build the array of joints corresponding to the IK chain
- convert_channels(ikscene, tree, ctime);
+ convert_channels(eval_ctx, ikscene, tree, ctime);
if (ingame) {
// in the GE, set the initial joint angle to match the current pose
// this will update the jointArray in ikscene
@@ -1397,7 +1397,7 @@ static IK_Scene *convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan, f
// we can now add the armature
// the armature is based on a moving frame.
// initialize with the correct position in case there is no cache
- base_callback(iTaSC::Timestamp(), iTaSC::F_identity, initPose, ikscene);
+ base_callback(eval_ctx, iTaSC::Timestamp(), iTaSC::F_identity, initPose, ikscene);
ikscene->base = new iTaSC::MovingFrame(initPose);
ikscene->base->setCallback(base_callback, ikscene);
std::string armname;
@@ -1458,7 +1458,7 @@ static IK_Scene *convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan, f
mul_m4_m4m4(iktarget->eeRest, invBaseFrame, mat);
iktarget->eeBlend = (!ikscene->polarConstraint && condata->type == CONSTRAINT_IK_COPYPOSE) ? true : false;
// use target_callback to make sure the initPose includes enforce coefficient
- target_callback(iTaSC::Timestamp(), iTaSC::F_identity, initPose, iktarget);
+ target_callback(eval_ctx, iTaSC::Timestamp(), iTaSC::F_identity, initPose, iktarget);
iktarget->target = new iTaSC::MovingFrame(initPose);
iktarget->target->setCallback(target_callback, iktarget);
ret = scene->addObject(iktarget->targetName, iktarget->target);
@@ -1526,7 +1526,7 @@ static IK_Scene *convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan, f
return ikscene;
}
-static void create_scene(Scene *scene, Object *ob, float ctime)
+static void create_scene(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float ctime)
{
bPoseChannel *pchan;
@@ -1537,7 +1537,7 @@ static void create_scene(Scene *scene, Object *ob, float ctime)
if (tree) {
IK_Data *ikdata = get_ikdata(ob->pose);
// convert tree in iTaSC::Scene
- IK_Scene *ikscene = convert_tree(scene, ob, pchan, ctime);
+ IK_Scene *ikscene = convert_tree(eval_ctx, scene, ob, pchan, ctime);
if (ikscene) {
ikscene->next = ikdata->first;
ikdata->first = ikscene;
@@ -1576,7 +1576,7 @@ static int init_scene(Object *ob)
return 0;
}
-static void execute_scene(Scene *blscene, IK_Scene *ikscene, bItasc *ikparam, float ctime, float frtime)
+static void execute_scene(const struct EvaluationContext *eval_ctx, Scene *blscene, IK_Scene *ikscene, bItasc *ikparam, float ctime, float frtime)
{
int i;
IK_Channel *ikchan;
@@ -1592,7 +1592,7 @@ static void execute_scene(Scene *blscene, IK_Scene *ikscene, bItasc *ikparam, fl
// in animation mode, we must get the bone position from action and constraints
for (i = 0, ikchan = ikscene->channels; i < ikscene->numchan; i++, ++ikchan) {
if (!(ikchan->pchan->flag & POSE_DONE))
- BKE_pose_where_is_bone(blscene, ikscene->blArmature, ikchan->pchan, ctime, 1);
+ BKE_pose_where_is_bone(eval_ctx, blscene, ikscene->blArmature, ikchan->pchan, ctime, 1);
// tell blender that this channel was controlled by IK, it's cleared on each BKE_pose_where_is()
ikchan->pchan->flag |= (POSE_DONE | POSE_CHAIN);
ikchan->jointValid = 0;
@@ -1647,7 +1647,7 @@ static void execute_scene(Scene *blscene, IK_Scene *ikscene, bItasc *ikparam, fl
}
}
// don't cache if we are reiterating because we don't want to destroy the cache unnecessarily
- ikscene->scene->update(timestamp, timestep, numstep, false, !reiterate, simulation);
+ ikscene->scene->update(eval_ctx, timestamp, timestep, numstep, false, !reiterate, simulation);
if (reiterate) {
// how many times do we reiterate?
for (i = 0; i < ikparam->numiter; i++) {
@@ -1656,11 +1656,11 @@ static void execute_scene(Scene *blscene, IK_Scene *ikscene, bItasc *ikparam, fl
{
break;
}
- ikscene->scene->update(timestamp, timestep, numstep, true, false, simulation);
+ ikscene->scene->update(eval_ctx, timestamp, timestep, numstep, true, false, simulation);
}
if (simulation) {
// one more fake iteration to cache
- ikscene->scene->update(timestamp, 0.0, 1, true, true, true);
+ ikscene->scene->update(eval_ctx, timestamp, 0.0, 1, true, true, true);
}
}
// compute constraint error
@@ -1744,7 +1744,7 @@ static void execute_scene(Scene *blscene, IK_Scene *ikscene, bItasc *ikparam, fl
//---------------------------------------------------
// plugin interface
//
-void itasc_initialize_tree(struct Scene *scene, Object *ob, float ctime)
+void itasc_initialize_tree(const struct EvaluationContext *eval_ctx, struct Scene *scene, Object *ob, float ctime)
{
bPoseChannel *pchan;
int count = 0;
@@ -1764,13 +1764,13 @@ void itasc_initialize_tree(struct Scene *scene, Object *ob, float ctime)
// if at least one tree, create the scenes from the PoseTree stored in the channels
// postpone until execute_tree: this way the pose constraint are included
if (count)
- create_scene(scene, ob, ctime);
+ create_scene(eval_ctx, scene, ob, ctime);
itasc_update_param(ob->pose);
// make sure we don't rebuilt until the user changes something important
ob->pose->flag &= ~POSE_WAS_REBUILT;
}
-void itasc_execute_tree(struct Scene *scene, Object *ob, bPoseChannel *pchan_root, float ctime)
+void itasc_execute_tree(const struct EvaluationContext *eval_ctx, struct Scene *scene, Object *ob, bPoseChannel *pchan_root, float ctime)
{
if (ob->pose->ikdata) {
IK_Data *ikdata = (IK_Data *)ob->pose->ikdata;
@@ -1787,7 +1787,7 @@ void itasc_execute_tree(struct Scene *scene, Object *ob, bPoseChannel *pchan_ro
if (timestep > 0.2f)
timestep = 0.2f;
}
- execute_scene(scene, ikscene, ikparam, ctime, timestep);
+ execute_scene(eval_ctx, scene, ikscene, ikparam, ctime, timestep);
break;
}
}
diff --git a/source/blender/ikplugin/intern/itasc_plugin.h b/source/blender/ikplugin/intern/itasc_plugin.h
index bcd95bc31ca..2f4e4036d76 100644
--- a/source/blender/ikplugin/intern/itasc_plugin.h
+++ b/source/blender/ikplugin/intern/itasc_plugin.h
@@ -40,8 +40,8 @@
extern "C" {
#endif
-void itasc_initialize_tree(struct Scene *scene, struct Object *ob, float ctime);
-void itasc_execute_tree(struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan_root, float ctime);
+void itasc_initialize_tree(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, float ctime);
+void itasc_execute_tree(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan_root, float ctime);
void itasc_release_tree(struct Scene *scene, struct Object *ob, float ctime);
void itasc_clear_data(struct bPose *pose);
void itasc_clear_cache(struct bPose *pose);
diff --git a/source/blender/imbuf/CMakeLists.txt b/source/blender/imbuf/CMakeLists.txt
index b32f8c54cd6..c3950d8eb83 100644
--- a/source/blender/imbuf/CMakeLists.txt
+++ b/source/blender/imbuf/CMakeLists.txt
@@ -130,16 +130,6 @@ if(WITH_CODEC_AVI)
add_definitions(-DWITH_AVI)
endif()
-if(WITH_CODEC_QUICKTIME)
- list(APPEND INC
- ../quicktime
- )
- list(APPEND INC_SYS
- ${QUICKTIME_INCLUDE_DIRS}
- )
- add_definitions(-DWITH_QUICKTIME)
-endif()
-
if(WITH_CODEC_FFMPEG)
list(APPEND INC
../../../intern/ffmpeg
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index e7abfdc7d67..f1f36351e79 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -205,6 +205,7 @@ typedef enum IMB_BlendMode {
IMB_BLEND_SATURATION = 21,
IMB_BLEND_LUMINOSITY = 22,
IMB_BLEND_COLOR = 23,
+ IMB_BLEND_INTERPOLATE = 24,
IMB_BLEND_COPY = 1000,
IMB_BLEND_COPY_RGB = 1001,
diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h
index 1701c2ba307..ee51854d7ed 100644
--- a/source/blender/imbuf/IMB_imbuf_types.h
+++ b/source/blender/imbuf/IMB_imbuf_types.h
@@ -295,7 +295,6 @@ typedef struct ImBuf {
#endif /* DDS */
extern const char *imb_ext_image[];
-extern const char *imb_ext_image_qt[];
extern const char *imb_ext_movie[];
extern const char *imb_ext_audio[];
diff --git a/source/blender/imbuf/intern/IMB_anim.h b/source/blender/imbuf/intern/IMB_anim.h
index 6d7ad7985f9..b10ae4f6fe9 100644
--- a/source/blender/imbuf/intern/IMB_anim.h
+++ b/source/blender/imbuf/intern/IMB_anim.h
@@ -63,12 +63,6 @@
# include "AVI_avi.h"
#endif
-#ifdef WITH_QUICKTIME
-# if defined(_WIN32) || defined(__APPLE__)
-# include "quicktime_import.h"
-# endif /* _WIN32 || __APPLE__ */
-#endif /* WITH_QUICKTIME */
-
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
@@ -137,11 +131,6 @@ struct anim {
PGETFRAME pgf;
#endif
-#ifdef WITH_QUICKTIME
- /* quicktime */
- struct _QuicktimeMovie *qtime;
-#endif /* WITH_QUICKTIME */
-
#ifdef WITH_FFMPEG
AVFormatContext *pFormatCtx;
AVCodecContext *pCodecCtx;
diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c
index 9806ff006d7..25b0c0d7b1a 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -73,12 +73,6 @@
# include "AVI_avi.h"
#endif
-#ifdef WITH_QUICKTIME
-#if defined(_WIN32) || defined(__APPLE__)
-#include "quicktime_import.h"
-#endif /* _WIN32 || __APPLE__ */
-#endif /* WITH_QUICKTIME */
-
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
@@ -221,9 +215,6 @@ void IMB_free_anim(struct anim *anim)
free_anim_avi(anim);
#endif
-#ifdef WITH_QUICKTIME
- free_anim_quicktime(anim);
-#endif
#ifdef WITH_FFMPEG
free_anim_ffmpeg(anim);
#endif
@@ -513,6 +504,11 @@ static int startffmpeg(struct anim *anim)
avformat_close_input(&pFormatCtx);
return -1;
}
+ if (pCodecCtx->pix_fmt == AV_PIX_FMT_NONE) {
+ avcodec_close(anim->pCodecCtx);
+ avformat_close_input(&pFormatCtx);
+ return -1;
+ }
frame_rate = av_get_r_frame_rate_compat(pFormatCtx->streams[videoStream]);
if (pFormatCtx->streams[videoStream]->nb_frames != 0) {
@@ -1214,9 +1210,6 @@ static ImBuf *anim_getnew(struct anim *anim)
free_anim_avi(anim);
#endif
-#ifdef WITH_QUICKTIME
- free_anim_quicktime(anim);
-#endif
#ifdef WITH_FFMPEG
free_anim_ffmpeg(anim);
#endif
@@ -1245,12 +1238,6 @@ static ImBuf *anim_getnew(struct anim *anim)
ibuf = IMB_allocImBuf(anim->x, anim->y, 24, 0);
break;
#endif
-#ifdef WITH_QUICKTIME
- case ANIM_QTIME:
- if (startquicktime(anim)) return (0);
- ibuf = IMB_allocImBuf(anim->x, anim->y, 24, 0);
- break;
-#endif
#ifdef WITH_FFMPEG
case ANIM_FFMPEG:
if (startffmpeg(anim)) return (0);
@@ -1340,21 +1327,6 @@ struct ImBuf *IMB_anim_absolute(struct anim *anim, int position,
anim->curposition = position;
break;
#endif
-#ifdef WITH_QUICKTIME
- case ANIM_QTIME:
- ibuf = qtime_fetchibuf(anim, position);
- if (ibuf) {
- if (ibuf->rect) {
- /* OCIO_TODO: should happen in quicktime module, but it currently doesn't have access
- * to color management's internals
- */
- ibuf->rect_colorspace = colormanage_colorspace_get_named(anim->colorspace);
- }
-
- anim->curposition = position;
- }
- break;
-#endif
#ifdef WITH_FFMPEG
case ANIM_FFMPEG:
ibuf = ffmpeg_fetchibuf(anim, position, tc);
diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c
index ff19a14dbff..863bce125c5 100644
--- a/source/blender/imbuf/intern/colormanagement.c
+++ b/source/blender/imbuf/intern/colormanagement.c
@@ -47,6 +47,7 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "IMB_filetype.h"
+#include "IMB_filter.h"
#include "IMB_moviecache.h"
#include "MEM_guardedalloc.h"
@@ -63,6 +64,7 @@
#include "BKE_context.h"
#include "BKE_image.h"
#include "BKE_main.h"
+#include "BKE_sequencer.h"
#include "RNA_define.h"
@@ -1112,6 +1114,7 @@ void IMB_colormanagement_check_file_config(Main *bmain)
for (scene = bmain->scene.first; scene; scene = scene->id.next) {
ColorManagedColorspaceSettings *sequencer_colorspace_settings;
+ /* check scene color management settings */
colormanage_check_display_settings(&scene->display_settings, "scene", default_display);
colormanage_check_view_settings(&scene->display_settings, &scene->view_settings, "scene");
@@ -1122,6 +1125,15 @@ void IMB_colormanagement_check_file_config(Main *bmain)
if (sequencer_colorspace_settings->name[0] == '\0') {
BLI_strncpy(sequencer_colorspace_settings->name, global_role_default_sequencer, MAX_COLORSPACE_NAME);
}
+
+ /* check sequencer strip input color space settings */
+ Sequence *seq;
+ SEQ_BEGIN (scene->ed, seq) {
+ if (seq->strip) {
+ colormanage_check_colorspace_settings(&seq->strip->colorspace_settings, "sequencer strip");
+ }
+ }
+ SEQ_END
}
/* ** check input color space settings ** */
@@ -1510,6 +1522,10 @@ static bool is_ibuf_rect_in_display_space(ImBuf *ibuf, const ColorManagedViewSet
{
const char *from_colorspace = ibuf->rect_colorspace->name;
const char *to_colorspace = IMB_colormanagement_get_display_colorspace_name(view_settings, display_settings);
+ ColorManagedLook *look_descr = colormanage_look_get_named(view_settings->look);
+ if (look_descr != NULL && !STREQ(look_descr->process_space, "")) {
+ return false;
+ }
if (to_colorspace && STREQ(from_colorspace, to_colorspace))
return true;
@@ -1624,12 +1640,13 @@ static void *do_processor_transform_thread(void *handle_v)
if (float_from_byte) {
IMB_buffer_float_from_byte(float_buffer, byte_buffer,
IB_PROFILE_SRGB, IB_PROFILE_SRGB,
- true,
+ false,
width, height, width, width);
- IMB_colormanagement_processor_apply(handle->cm_processor,
- float_buffer,
- width, height, channels,
- predivide);
+ IMB_colormanagement_processor_apply(handle->cm_processor,
+ float_buffer,
+ width, height, channels,
+ predivide);
+ IMB_premultiply_rect_float(float_buffer, 4, width, height);
}
else {
if (byte_buffer != NULL) {
@@ -1765,14 +1782,15 @@ void IMB_colormanagement_transform_from_byte_threaded(float *float_buffer, unsig
*/
IMB_buffer_float_from_byte(float_buffer, byte_buffer,
IB_PROFILE_SRGB, IB_PROFILE_SRGB,
- true,
+ false,
width, height, width, width);
+ IMB_premultiply_rect_float(float_buffer, 4, width, height);
return;
}
cm_processor = IMB_colormanagement_colorspace_processor_new(from_colorspace, to_colorspace);
processor_transform_apply_threaded(byte_buffer, float_buffer,
width, height, channels,
- cm_processor, true, true);
+ cm_processor, false, true);
IMB_colormanagement_processor_free(cm_processor);
}
@@ -2554,6 +2572,14 @@ const char *IMB_colormanagement_colorspace_get_indexed_name(int index)
void IMB_colormanagment_colorspace_from_ibuf_ftype(ColorManagedColorspaceSettings *colorspace_settings, ImBuf *ibuf)
{
+ /* Don't modify non-color data space, it does not change with file type. */
+ ColorSpace *colorspace = colormanage_colorspace_get_named(colorspace_settings->name);
+
+ if (colorspace && colorspace->is_data) {
+ return;
+ }
+
+ /* Get color space from file type. */
const ImFileType *type;
for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) {
diff --git a/source/blender/imbuf/intern/filetype.c b/source/blender/imbuf/intern/filetype.c
index 3d3e8a0646a..7ed5c8ffbcb 100644
--- a/source/blender/imbuf/intern/filetype.c
+++ b/source/blender/imbuf/intern/filetype.c
@@ -47,10 +47,6 @@
#include "dds/dds_api.h"
#endif
-#ifdef WITH_QUICKTIME
-#include "quicktime_import.h"
-#endif
-
static int imb_ftype_default(const ImFileType *type, ImBuf *ibuf)
{
return (ibuf->ftype == type->filetype);
@@ -101,10 +97,6 @@ void imb_filetypes_init(void)
for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++)
if (type->init)
type->init();
-
-#ifdef WITH_QUICKTIME
- quicktime_init();
-#endif
}
void imb_filetypes_exit(void)
@@ -114,9 +106,5 @@ void imb_filetypes_exit(void)
for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++)
if (type->exit)
type->exit();
-
-#ifdef WITH_QUICKTIME
- quicktime_exit();
-#endif
}
diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c
index 7a9fa2b9768..6c0849358a5 100644
--- a/source/blender/imbuf/intern/iris.c
+++ b/source/blender/imbuf/intern/iris.c
@@ -48,36 +48,24 @@
#define IMAGIC 0732
typedef struct {
- unsigned short imagic; /* stuff saved on disk . . */
- unsigned short type;
- unsigned short dim;
- unsigned short xsize;
- unsigned short ysize;
- unsigned short zsize;
- unsigned int min;
- unsigned int max;
- unsigned int wastebytes;
- char name[80];
- unsigned int colormap;
-
- int file; /* stuff used in core only */
- unsigned short flags;
- short dorev;
- short x;
- short y;
- short z;
- short cnt;
- unsigned short *ptr;
- unsigned short *base;
- unsigned short *tmpbuf;
- unsigned int offset;
- unsigned int rleend; /* for rle images */
- unsigned int *rowstart; /* for rle images */
- const int *rowsize; /* for rle images */
+ ushort imagic; /* stuff saved on disk . . */
+ ushort type;
+ ushort dim;
+ ushort xsize;
+ ushort ysize;
+ ushort zsize;
+ uint min;
+ uint max;
+ uchar _pad1[4];
+ char name[80];
+ uint colormap;
+ uchar _pad2[404];
} IMAGE;
#define HEADER_SIZE 512
+BLI_STATIC_ASSERT(sizeof(IMAGE) == HEADER_SIZE, "Invalid header size");
+
#define RINTLUM (79)
#define GINTLUM (156)
#define BINTLUM (21)
@@ -106,68 +94,72 @@ typedef struct {
/* local struct for mem access */
typedef struct MFileOffset {
const uchar *_file_data;
- unsigned int _file_offset;
+ uint _file_offset;
} MFileOffset;
-#define MFILE_DATA(inf) ((void)0, (inf)->_file_data + (inf)->_file_offset)
+#define MFILE_DATA(inf) ((void)0, ((inf)->_file_data + (inf)->_file_offset))
#define MFILE_STEP(inf, step) { (inf)->_file_offset += step; } ((void)0)
#define MFILE_SEEK(inf, pos) { (inf)->_file_offset = pos; } ((void)0)
+/* error flags */
+#define DIRTY_FLAG_EOF (1 << 0)
+#define DIRTY_FLAG_ENCODING (1 << 1)
+
/* funcs */
static void readheader(MFileOffset *inf, IMAGE *image);
static int writeheader(FILE *outf, IMAGE *image);
-static unsigned short getshort(MFileOffset *inf);
-static unsigned int getlong(MFileOffset *inf);
-static void putshort(FILE *outf, unsigned short val);
-static int putlong(FILE *outf, unsigned int val);
-static int writetab(FILE *outf, unsigned int *tab, int len);
-static void readtab(MFileOffset *inf, unsigned int *tab, int len);
+static ushort getshort(MFileOffset *inf);
+static uint getlong(MFileOffset *inf);
+static void putshort(FILE *outf, ushort val);
+static int putlong(FILE *outf, uint val);
+static int writetab(FILE *outf, uint *tab, int len);
+static void readtab(MFileOffset *inf, uint *tab, int len);
-static void expandrow(unsigned char *optr, const unsigned char *iptr, int z);
-static void expandrow2(float *optr, const unsigned char *iptr, int z);
-static void interleaverow(unsigned char *lptr, const unsigned char *cptr, int z, int n);
-static void interleaverow2(float *lptr, const unsigned char *cptr, int z, int n);
-static int compressrow(unsigned char *lbuf, unsigned char *rlebuf, int z, int cnt);
-static void lumrow(unsigned char *rgbptr, unsigned char *lumptr, int n);
+static int expandrow(uchar *optr, const uchar *optr_end, const uchar *iptr, const uchar *iptr_end, int z);
+static int expandrow2(float *optr, const float *optr_end, const uchar *iptr, const uchar *iptr_end, int z);
+static void interleaverow(uchar *lptr, const uchar *cptr, int z, int n);
+static void interleaverow2(float *lptr, const uchar *cptr, int z, int n);
+static int compressrow(uchar *lbuf, uchar *rlebuf, int z, int cnt);
+static void lumrow(uchar *rgbptr, uchar *lumptr, int n);
/*
* byte order independent read/write of shorts and ints.
*
*/
-static unsigned short getshort(MFileOffset *inf)
+static ushort getshort(MFileOffset *inf)
{
- const unsigned char *buf;
+ const uchar *buf;
buf = MFILE_DATA(inf);
MFILE_STEP(inf, 2);
-
- return (buf[0] << 8) + (buf[1] << 0);
+
+ return ((ushort)buf[0] << 8) + ((ushort)buf[1] << 0);
}
-static unsigned int getlong(MFileOffset *mofs)
+static uint getlong(MFileOffset *mofs)
{
- const unsigned char *buf;
+ const uchar *buf;
buf = MFILE_DATA(mofs);
MFILE_STEP(mofs, 4);
-
- return (buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + (buf[3] << 0);
+
+ return ((uint)buf[0] << 24) + ((uint)buf[1] << 16) + ((uint)buf[2] << 8) + ((uint)buf[3] << 0);
}
-static void putshort(FILE *outf, unsigned short val)
+static void putshort(FILE *outf, ushort val)
{
- unsigned char buf[2];
+ uchar buf[2];
buf[0] = (val >> 8);
buf[1] = (val >> 0);
fwrite(buf, 2, 1, outf);
}
-static int putlong(FILE *outf, unsigned int val)
+static int putlong(FILE *outf, uint val)
{
- unsigned char buf[4];
+ uchar buf[4];
buf[0] = (val >> 24);
buf[1] = (val >> 16);
@@ -205,7 +197,7 @@ static int writeheader(FILE *outf, IMAGE *image)
return fwrite("no name", 8, 1, outf);
}
-static int writetab(FILE *outf, unsigned int *tab, int len)
+static int writetab(FILE *outf, uint *tab, int len)
{
int r = 0;
@@ -216,7 +208,7 @@ static int writetab(FILE *outf, unsigned int *tab, int len)
return r;
}
-static void readtab(MFileOffset *inf, unsigned int *tab, int len)
+static void readtab(MFileOffset *inf, uint *tab, int len)
{
while (len) {
*tab++ = getlong(inf);
@@ -242,12 +234,12 @@ static void test_endian_zbuf(struct ImBuf *ibuf)
}
/* from misc_util: flip the bytes from x */
-#define GS(x) (((unsigned char *)(x))[0] << 8 | ((unsigned char *)(x))[1])
+#define GS(x) (((uchar *)(x))[0] << 8 | ((uchar *)(x))[1])
/* this one is only def-ed once, strangely... */
#define GSS(x) (((uchar *)(x))[1] << 8 | ((uchar *)(x))[0])
-int imb_is_a_iris(const unsigned char *mem)
+int imb_is_a_iris(const uchar *mem)
{
return ((GS(mem) == IMAGIC) || (GSS(mem) == IMAGIC));
}
@@ -259,46 +251,52 @@ int imb_is_a_iris(const unsigned char *mem)
*
*/
-struct ImBuf *imb_loadiris(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
+struct ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
{
- unsigned int *base, *lptr = NULL;
+ uint *base, *lptr = NULL;
float *fbase, *fptr = NULL;
- unsigned int *zbase, *zptr;
- const unsigned char *rledat;
- unsigned int *starttab, *lengthtab;
+ uint *zbase, *zptr;
+ const uchar *rledat;
+ const uchar *mem_end = mem + size;
MFileOffset _inf_data = {mem, 0}, *inf = &_inf_data;
IMAGE image;
int x, y, z, tablen;
- int xsize, ysize, zsize;
int bpp, rle, cur, badorder;
ImBuf *ibuf;
+ uchar dirty_flag = 0;
- (void)size; /* unused */
-
- if (!imb_is_a_iris(mem)) return NULL;
+ if (size < HEADER_SIZE) {
+ return NULL;
+ }
+
+ if (!imb_is_a_iris(mem)) {
+ return NULL;
+ }
/* OCIO_TODO: only tested with 1 byte per pixel, not sure how to test with other settings */
colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);
- /*printf("new iris\n");*/
-
readheader(inf, &image);
if (image.imagic != IMAGIC) {
fprintf(stderr, "longimagedata: bad magic number in image file\n");
return(NULL);
}
-
+
rle = ISRLE(image.type);
bpp = BPP(image.type);
if (bpp != 1 && bpp != 2) {
fprintf(stderr, "longimagedata: image must have 1 or 2 byte per pix chan\n");
return(NULL);
}
-
- xsize = image.xsize;
- ysize = image.ysize;
- zsize = image.zsize;
-
+ if ((uint)image.zsize > 8) {
+ fprintf(stderr, "longimagedata: channels over 8 not supported\n");
+ return(NULL);
+ }
+
+ const int xsize = image.xsize;
+ const int ysize = image.ysize;
+ const int zsize = image.zsize;
+
if (flags & IB_test) {
ibuf = IMB_allocImBuf(image.xsize, image.ysize, 8 * image.zsize, 0);
if (ibuf) ibuf->ftype = IMB_FTYPE_IMAGIC;
@@ -306,12 +304,17 @@ struct ImBuf *imb_loadiris(const unsigned char *mem, size_t size, int flags, cha
}
if (rle) {
-
tablen = ysize * zsize * sizeof(int);
- starttab = (unsigned int *)MEM_mallocN(tablen, "iris starttab");
- lengthtab = (unsigned int *)MEM_mallocN(tablen, "iris endtab");
MFILE_SEEK(inf, HEADER_SIZE);
-
+
+ uint *starttab = MEM_mallocN(tablen, "iris starttab");
+ uint *lengthtab = MEM_mallocN(tablen, "iris endtab");
+
+#define MFILE_CAPACITY_AT_PTR_OK_OR_FAIL(p) \
+ if (UNLIKELY((p) > mem_end)) { dirty_flag |= DIRTY_FLAG_EOF; goto fail_rle; } ((void)0)
+
+ MFILE_CAPACITY_AT_PTR_OK_OR_FAIL(MFILE_DATA(inf) + ((4 * 2) * tablen));
+
readtab(inf, starttab, tablen);
readtab(inf, lengthtab, tablen);
@@ -335,7 +338,7 @@ struct ImBuf *imb_loadiris(const unsigned char *mem, size_t size, int flags, cha
ibuf = IMB_allocImBuf(xsize, ysize, 8 * zsize, IB_rect);
if (ibuf->planes > 32) ibuf->planes = 32;
base = ibuf->rect;
- zbase = (unsigned int *)ibuf->zbuf;
+ zbase = (uint *)ibuf->zbuf;
if (badorder) {
for (z = 0; z < zsize; z++) {
@@ -344,9 +347,11 @@ struct ImBuf *imb_loadiris(const unsigned char *mem, size_t size, int flags, cha
MFILE_SEEK(inf, starttab[y + z * ysize]);
rledat = MFILE_DATA(inf);
MFILE_STEP(inf, lengthtab[y + z * ysize]);
-
- expandrow((uchar *)lptr, rledat, 3 - z);
- lptr += xsize;
+ const uchar *rledat_next = MFILE_DATA(inf);
+ uint *lptr_next = lptr + xsize;
+ MFILE_CAPACITY_AT_PTR_OK_OR_FAIL(rledat_next);
+ dirty_flag |= expandrow((uchar *)lptr, (uchar *)lptr_next, rledat, rledat_next, 3 - z);
+ lptr = lptr_next;
}
}
}
@@ -354,17 +359,25 @@ struct ImBuf *imb_loadiris(const unsigned char *mem, size_t size, int flags, cha
lptr = base;
zptr = zbase;
for (y = 0; y < ysize; y++) {
-
+
+ uint *lptr_next = lptr + xsize;
+ uint *zptr_next = zptr + xsize;
+
for (z = 0; z < zsize; z++) {
MFILE_SEEK(inf, starttab[y + z * ysize]);
rledat = MFILE_DATA(inf);
MFILE_STEP(inf, lengthtab[y + z * ysize]);
-
- if (z < 4) expandrow((uchar *)lptr, rledat, 3 - z);
- else if (z < 8) expandrow((uchar *)zptr, rledat, 7 - z);
+ const uchar *rledat_next = MFILE_DATA(inf);
+ MFILE_CAPACITY_AT_PTR_OK_OR_FAIL(rledat_next);
+ if (z < 4) {
+ dirty_flag |= expandrow((uchar *)lptr, (uchar *)lptr_next, rledat, rledat_next, 3 - z);
+ }
+ else if (z < 8) {
+ dirty_flag |= expandrow((uchar *)zptr, (uchar *)zptr_next, rledat, rledat_next, 7 - z);
+ }
}
- lptr += xsize;
- zptr += xsize;
+ lptr = lptr_next;
+ zptr = zptr_next;
}
}
@@ -383,14 +396,17 @@ struct ImBuf *imb_loadiris(const unsigned char *mem, size_t size, int flags, cha
MFILE_SEEK(inf, starttab[y + z * ysize]);
rledat = MFILE_DATA(inf);
MFILE_STEP(inf, lengthtab[y + z * ysize]);
-
- expandrow2(fptr, rledat, 3 - z);
- fptr += xsize * 4;
+ const uchar *rledat_next = MFILE_DATA(inf);
+ MFILE_CAPACITY_AT_PTR_OK_OR_FAIL(rledat_next);
+ float *fptr_next = fptr + (xsize * 4);
+ dirty_flag |= expandrow2(fptr, fptr_next, rledat, rledat_next, 3 - z);
+ fptr = fptr_next;
}
}
}
else {
fptr = fbase;
+ float *fptr_next = fptr + (xsize * 4);
for (y = 0; y < ysize; y++) {
@@ -398,27 +414,31 @@ struct ImBuf *imb_loadiris(const unsigned char *mem, size_t size, int flags, cha
MFILE_SEEK(inf, starttab[y + z * ysize]);
rledat = MFILE_DATA(inf);
MFILE_STEP(inf, lengthtab[y + z * ysize]);
-
- expandrow2(fptr, rledat, 3 - z);
-
+ const uchar *rledat_next = MFILE_DATA(inf);
+ MFILE_CAPACITY_AT_PTR_OK_OR_FAIL(rledat_next);
+ dirty_flag |= expandrow2(fptr, fptr_next, rledat, rledat_next, 3 - z);
}
- fptr += xsize * 4;
+ fptr = fptr_next;
}
}
}
-
+#undef MFILE_CAPACITY_AT_PTR_OK_OR_FAIL
+fail_rle:
MEM_freeN(starttab);
MEM_freeN(lengthtab);
-
}
else {
+
+#define MFILE_CAPACITY_AT_PTR_OK_OR_FAIL(p) \
+ if (UNLIKELY((p) > mem_end)) { dirty_flag |= DIRTY_FLAG_EOF; goto fail_uncompressed; } ((void)0)
+
if (bpp == 1) {
ibuf = IMB_allocImBuf(xsize, ysize, 8 * zsize, IB_rect);
if (ibuf->planes > 32) ibuf->planes = 32;
base = ibuf->rect;
- zbase = (unsigned int *)ibuf->zbuf;
+ zbase = (uint *)ibuf->zbuf;
MFILE_SEEK(inf, HEADER_SIZE);
rledat = MFILE_DATA(inf);
@@ -427,12 +447,13 @@ struct ImBuf *imb_loadiris(const unsigned char *mem, size_t size, int flags, cha
if (z < 4) lptr = base;
else if (z < 8) lptr = zbase;
-
- for (y = 0; y < ysize; y++) {
- interleaverow((uchar *)lptr, rledat, 3 - z, xsize);
- rledat += xsize;
-
+ for (y = 0; y < ysize; y++) {
+ const uchar *rledat_next = rledat + xsize;
+ const int z_ofs = 3 - z;
+ MFILE_CAPACITY_AT_PTR_OK_OR_FAIL(rledat_next + z_ofs);
+ interleaverow((uchar *)lptr, rledat, z_ofs, xsize);
+ rledat = rledat_next;
lptr += xsize;
}
}
@@ -450,20 +471,23 @@ struct ImBuf *imb_loadiris(const unsigned char *mem, size_t size, int flags, cha
for (z = 0; z < zsize; z++) {
fptr = fbase;
-
- for (y = 0; y < ysize; y++) {
- interleaverow2(fptr, rledat, 3 - z, xsize);
- rledat += xsize * 2;
-
+ for (y = 0; y < ysize; y++) {
+ const uchar *rledat_next = rledat + xsize * 2;
+ const int z_ofs = 3 - z;
+ MFILE_CAPACITY_AT_PTR_OK_OR_FAIL(rledat_next + z_ofs);
+ interleaverow2(fptr, rledat, z_ofs, xsize);
+ rledat = rledat_next;
fptr += xsize * 4;
}
}
}
+#undef MFILE_CAPACITY_AT_PTR_OK_OR_FAIL
+fail_uncompressed:
+ (void)0;
}
-
-
+
if (bpp == 1) {
uchar *rect;
@@ -528,6 +552,9 @@ struct ImBuf *imb_loadiris(const unsigned char *mem, size_t size, int flags, cha
}
+ if (dirty_flag) {
+ fprintf(stderr, "longimagedata: corrupt file content (%d)\n", dirty_flag);
+ }
ibuf->ftype = IMB_FTYPE_IMAGIC;
test_endian_zbuf(ibuf);
@@ -541,7 +568,7 @@ struct ImBuf *imb_loadiris(const unsigned char *mem, size_t size, int flags, cha
/* static utility functions for longimagedata */
-static void interleaverow(unsigned char *lptr, const unsigned char *cptr, int z, int n)
+static void interleaverow(uchar *lptr, const uchar *cptr, int z, int n)
{
lptr += z;
while (n--) {
@@ -550,7 +577,7 @@ static void interleaverow(unsigned char *lptr, const unsigned char *cptr, int z,
}
}
-static void interleaverow2(float *lptr, const unsigned char *cptr, int z, int n)
+static void interleaverow2(float *lptr, const uchar *cptr, int z, int n)
{
lptr += z;
while (n--) {
@@ -560,19 +587,34 @@ static void interleaverow2(float *lptr, const unsigned char *cptr, int z, int n)
}
}
-static void expandrow2(float *optr, const unsigned char *iptr, int z)
+static int expandrow2(
+ float *optr, const float *optr_end,
+ const uchar *iptr, const uchar *iptr_end, int z)
{
- unsigned short pixel, count;
+ ushort pixel, count;
float pixel_f;
+#define EXPAND_CAPACITY_AT_INPUT_OK_OR_FAIL(iptr_next) \
+ if (UNLIKELY(iptr_next > iptr_end)) { goto fail; }
+
+#define EXPAND_CAPACITY_AT_OUTPUT_OK_OR_FAIL(optr_next) \
+ if (UNLIKELY(optr_next > optr_end)) { goto fail; }
+
optr += z;
+ optr_end += z;
while (1) {
+ const uchar *iptr_next = iptr + 2;
+ EXPAND_CAPACITY_AT_INPUT_OK_OR_FAIL(iptr_next);
pixel = (iptr[0] << 8) | (iptr[1] << 0);
- iptr += 2;
-
+ iptr = iptr_next;
+
if (!(count = (pixel & 0x7f)) )
- return;
+ return false;
+ const float *optr_next = optr + count;
+ EXPAND_CAPACITY_AT_OUTPUT_OK_OR_FAIL(optr_next);
if (pixel & 0x80) {
+ iptr_next = iptr + (count * 2);
+ EXPAND_CAPACITY_AT_INPUT_OK_OR_FAIL(iptr_next);
while (count >= 8) {
optr[0 * 4] = ((iptr[0] << 8) | (iptr[1] << 0)) / (float)0xFFFF;
optr[1 * 4] = ((iptr[2] << 8) | (iptr[3] << 0)) / (float)0xFFFF;
@@ -591,10 +633,13 @@ static void expandrow2(float *optr, const unsigned char *iptr, int z)
iptr += 2;
optr += 4;
}
+ BLI_assert(iptr == iptr_next);
}
else {
+ iptr_next = iptr + 2;
+ EXPAND_CAPACITY_AT_INPUT_OK_OR_FAIL(iptr_next);
pixel_f = ((iptr[0] << 8) | (iptr[1] << 0)) / (float)0xFFFF;
- iptr += 2;
+ iptr = iptr_next;
while (count >= 8) {
optr[0 * 4] = pixel_f;
@@ -612,20 +657,45 @@ static void expandrow2(float *optr, const unsigned char *iptr, int z)
*optr = pixel_f;
optr += 4;
}
+ BLI_assert(iptr == iptr_next);
}
+ BLI_assert(optr == optr_next);
}
+ return false;
+
+#undef EXPAND_CAPACITY_AT_INPUT_OK_OR_FAIL
+#undef EXPAND_CAPACITY_AT_OUTPUT_OK_OR_FAIL
+fail:
+ return DIRTY_FLAG_ENCODING;
}
-static void expandrow(unsigned char *optr, const unsigned char *iptr, int z)
+static int expandrow(
+ uchar *optr, const uchar *optr_end,
+ const uchar *iptr, const uchar *iptr_end, int z)
{
- unsigned char pixel, count;
+ uchar pixel, count;
+
+#define EXPAND_CAPACITY_AT_INPUT_OK_OR_FAIL(iptr_next) \
+ if (UNLIKELY(iptr_next > iptr_end)) { goto fail; }
+
+#define EXPAND_CAPACITY_AT_OUTPUT_OK_OR_FAIL(optr_next) \
+ if (UNLIKELY(optr_next > optr_end)) { goto fail; }
optr += z;
+ optr_end += z;
while (1) {
- pixel = *iptr++;
+ const uchar *iptr_next = iptr + 1;
+ EXPAND_CAPACITY_AT_INPUT_OK_OR_FAIL(iptr_next);
+ pixel = *iptr;
+ iptr = iptr_next;
if (!(count = (pixel & 0x7f)) )
- return;
+ return false;
+ const uchar *optr_next = optr + ((int)count * 4);
+ EXPAND_CAPACITY_AT_OUTPUT_OK_OR_FAIL(optr_next);
+
if (pixel & 0x80) {
+ iptr_next = iptr + count;
+ EXPAND_CAPACITY_AT_INPUT_OK_OR_FAIL(iptr_next);
while (count >= 8) {
optr[0 * 4] = iptr[0];
optr[1 * 4] = iptr[1];
@@ -643,8 +713,11 @@ static void expandrow(unsigned char *optr, const unsigned char *iptr, int z)
*optr = *iptr++;
optr += 4;
}
+ BLI_assert(iptr == iptr_next);
}
else {
+ iptr_next = iptr + 1;
+ EXPAND_CAPACITY_AT_INPUT_OK_OR_FAIL(iptr_next);
pixel = *iptr++;
while (count >= 8) {
optr[0 * 4] = pixel;
@@ -662,8 +735,17 @@ static void expandrow(unsigned char *optr, const unsigned char *iptr, int z)
*optr = pixel;
optr += 4;
}
+ BLI_assert(iptr == iptr_next);
}
+ BLI_assert(optr == optr_next);
}
+
+ return false;
+
+#undef EXPAND_CAPACITY_AT_INPUT_OK_OR_FAIL
+#undef EXPAND_CAPACITY_AT_OUTPUT_OK_OR_FAIL
+fail:
+ return DIRTY_FLAG_ENCODING;
}
/*
@@ -679,14 +761,14 @@ static void expandrow(unsigned char *optr, const unsigned char *iptr, int z)
* Added: zbuf write
*/
-static int output_iris(unsigned int *lptr, int xsize, int ysize, int zsize, const char *name, int *zptr)
+static int output_iris(uint *lptr, int xsize, int ysize, int zsize, const char *name, int *zptr)
{
FILE *outf;
IMAGE *image;
int tablen, y, z, pos, len = 0;
- unsigned int *starttab, *lengthtab;
- unsigned char *rlebuf;
- unsigned int *lumbuf;
+ uint *starttab, *lengthtab;
+ uchar *rlebuf;
+ uint *lumbuf;
int rlebuflen, goodwrite;
goodwrite = 1;
@@ -696,14 +778,14 @@ static int output_iris(unsigned int *lptr, int xsize, int ysize, int zsize, cons
tablen = ysize * zsize * sizeof(int);
image = (IMAGE *)MEM_mallocN(sizeof(IMAGE), "iris image");
- starttab = (unsigned int *)MEM_mallocN(tablen, "iris starttab");
- lengthtab = (unsigned int *)MEM_mallocN(tablen, "iris lengthtab");
+ starttab = (uint *)MEM_mallocN(tablen, "iris starttab");
+ lengthtab = (uint *)MEM_mallocN(tablen, "iris lengthtab");
rlebuflen = 1.05 * xsize + 10;
- rlebuf = (unsigned char *)MEM_mallocN(rlebuflen, "iris rlebuf");
- lumbuf = (unsigned int *)MEM_mallocN(xsize * sizeof(int), "iris lumbuf");
+ rlebuf = (uchar *)MEM_mallocN(rlebuflen, "iris rlebuf");
+ lumbuf = (uint *)MEM_mallocN(xsize * sizeof(int), "iris lumbuf");
memset(image, 0, sizeof(IMAGE));
- image->imagic = IMB_FTYPE_IMAGIC;
+ image->imagic = IMAGIC;
image->type = RLE(1);
if (zsize > 1)
image->dim = 3;
@@ -765,7 +847,7 @@ static int output_iris(unsigned int *lptr, int xsize, int ysize, int zsize, cons
/* static utility functions for output_iris */
-static void lumrow(unsigned char *rgbptr, unsigned char *lumptr, int n)
+static void lumrow(uchar *rgbptr, uchar *lumptr, int n)
{
lumptr += CHANOFFSET(0);
while (n--) {
@@ -775,9 +857,9 @@ static void lumrow(unsigned char *rgbptr, unsigned char *lumptr, int n)
}
}
-static int compressrow(unsigned char *lbuf, unsigned char *rlebuf, int z, int cnt)
+static int compressrow(uchar *lbuf, uchar *rlebuf, int z, int cnt)
{
- unsigned char *iptr, *ibufend, *sptr, *optr;
+ uchar *iptr, *ibufend, *sptr, *optr;
short todo, cc;
int count;
@@ -830,7 +912,7 @@ static int compressrow(unsigned char *lbuf, unsigned char *rlebuf, int z, int cn
}
}
*optr++ = 0;
- return optr - (unsigned char *)rlebuf;
+ return optr - (uchar *)rlebuf;
}
int imb_saveiris(struct ImBuf *ibuf, const char *name, int flags)
diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c
index 390f2502ee7..388c2734fe9 100644
--- a/source/blender/imbuf/intern/jp2.c
+++ b/source/blender/imbuf/intern/jp2.c
@@ -588,7 +588,7 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
img_fol_t img_fol; /* only needed for cinema presets */
memset(&img_fol, 0, sizeof(img_fol_t));
- if (ibuf->float_colorspace) {
+ if (ibuf->float_colorspace || (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA)) {
/* float buffer was managed already, no need in color space conversion */
chanel_colormanage_cb = channel_colormanage_noop;
}
diff --git a/source/blender/imbuf/intern/moviecache.c b/source/blender/imbuf/intern/moviecache.c
index 4b49076dcd6..89955711384 100644
--- a/source/blender/imbuf/intern/moviecache.c
+++ b/source/blender/imbuf/intern/moviecache.c
@@ -49,7 +49,7 @@
#include "IMB_imbuf.h"
#ifdef DEBUG_MESSAGES
-# if defined __GNUC__ || defined __sun
+# if defined __GNUC__
# define PRINT(format, args ...) printf(format, ##args)
# else
# define PRINT(format, ...) printf(__VA_ARGS__)
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp
index ec544e65355..1fa3b943524 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.cpp
+++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp
@@ -1104,7 +1104,7 @@ void IMB_exr_write_channels(void *handle)
if (data->channels.first) {
const size_t num_pixels = ((size_t)data->width) * data->height;
- half *rect_half = NULL, *current_rect_half;
+ half *rect_half = NULL, *current_rect_half = NULL;
/* We allocate teporary storage for half pixels for all the channels at once. */
if (data->num_half_channels != 0) {
diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c
index 503e63a3fb1..dded0f7aecf 100644
--- a/source/blender/imbuf/intern/png.c
+++ b/source/blender/imbuf/intern/png.c
@@ -152,7 +152,7 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags)
compression = (int)(((float)(ibuf->foptions.quality) / 11.1111f));
compression = compression < 0 ? 0 : (compression > 9 ? 9 : compression);
- if (ibuf->float_colorspace) {
+ if (ibuf->float_colorspace || (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA)) {
/* float buffer was managed already, no need in color space conversion */
chanel_colormanage_cb = channel_colormanage_noop;
}
diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c
index 3360fd7548e..c4325caac91 100644
--- a/source/blender/imbuf/intern/rectop.c
+++ b/source/blender/imbuf/intern/rectop.c
@@ -301,8 +301,8 @@ void IMB_rectblend(ImBuf *dbuf, ImBuf *obuf, ImBuf *sbuf, unsigned short *dmask,
int destx, int desty, int origx, int origy, int srcx, int srcy, int width, int height,
IMB_BlendMode mode, bool accumulate)
{
- unsigned int *drect = NULL, *orect, *srect = NULL, *dr, *or, *sr;
- float *drectf = NULL, *orectf, *srectf = NULL, *drf, *orf, *srf;
+ unsigned int *drect = NULL, *orect = NULL, *srect = NULL, *dr, *or, *sr;
+ float *drectf = NULL, *orectf = NULL, *srectf = NULL, *drf, *orf, *srf;
unsigned short *cmaskrect = curvemask, *cmr;
unsigned short *dmaskrect = dmask, *dmr;
unsigned short *texmaskrect = texmask, *tmr;
@@ -424,6 +424,7 @@ void IMB_rectblend(ImBuf *dbuf, ImBuf *obuf, ImBuf *sbuf, unsigned short *dmask,
else {
switch (mode) {
case IMB_BLEND_MIX:
+ case IMB_BLEND_INTERPOLATE:
func = blend_color_mix_byte;
func_float = blend_color_mix_float;
break;
@@ -563,9 +564,15 @@ void IMB_rectblend(ImBuf *dbuf, ImBuf *obuf, ImBuf *sbuf, unsigned short *dmask,
mask_src[0] = src[0];
mask_src[1] = src[1];
mask_src[2] = src[2];
- mask_src[3] = divide_round_i(src[3] * mask, 65535);
- func((unsigned char *)dr, (unsigned char *)or, mask_src);
+ if (mode == IMB_BLEND_INTERPOLATE) {
+ mask_src[3] = src[3];
+ blend_color_interpolate_byte((unsigned char *)dr, (unsigned char *)or, mask_src, mask / 65535.0f);
+ }
+ else {
+ mask_src[3] = divide_round_i(src[3] * mask, 65535);
+ func((unsigned char *)dr, (unsigned char *)or, mask_src);
+ }
}
}
}
@@ -588,9 +595,15 @@ void IMB_rectblend(ImBuf *dbuf, ImBuf *obuf, ImBuf *sbuf, unsigned short *dmask,
mask_src[0] = src[0];
mask_src[1] = src[1];
mask_src[2] = src[2];
- mask_src[3] = divide_round_i(src[3] * mask, 65535);
- func((unsigned char *)dr, (unsigned char *)or, mask_src);
+ if (mode == IMB_BLEND_INTERPOLATE) {
+ mask_src[3] = src[3];
+ blend_color_interpolate_byte((unsigned char *)dr, (unsigned char *)or, mask_src, mask / 65535.0f);
+ }
+ else {
+ mask_src[3] = divide_round_i(src[3] * mask, 65535);
+ func((unsigned char *)dr, (unsigned char *)or, mask_src);
+ }
}
}
}
@@ -642,12 +655,16 @@ void IMB_rectblend(ImBuf *dbuf, ImBuf *obuf, ImBuf *sbuf, unsigned short *dmask,
mask = min_ff(mask, 65535.0);
if (mask > *dmr) {
- float mask_srf[4];
-
*dmr = mask;
- mul_v4_v4fl(mask_srf, srf, mask / 65535.0f);
- func_float(drf, orf, mask_srf);
+ if (mode == IMB_BLEND_INTERPOLATE) {
+ blend_color_interpolate_float(drf, orf, srf, mask / 65535.0f);
+ }
+ else {
+ float mask_srf[4];
+ mul_v4_v4fl(mask_srf, srf, mask / 65535.0f);
+ func_float(drf, orf, mask_srf);
+ }
}
}
}
@@ -664,11 +681,15 @@ void IMB_rectblend(ImBuf *dbuf, ImBuf *obuf, ImBuf *sbuf, unsigned short *dmask,
mask = min_ff(mask, 65535.0);
if (srf[3] && (mask > 0.0f)) {
- float mask_srf[4];
-
- mul_v4_v4fl(mask_srf, srf, mask / 65535.0f);
+ if (mode == IMB_BLEND_INTERPOLATE) {
+ blend_color_interpolate_float(drf, orf, srf, mask / 65535.0f);
+ }
+ else {
+ float mask_srf[4];
+ mul_v4_v4fl(mask_srf, srf, mask / 65535.0f);
+ func_float(drf, orf, mask_srf);
+ }
- func_float(drf, orf, mask_srf);
}
}
}
diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c
index 4368a428186..98aa7c5353b 100644
--- a/source/blender/imbuf/intern/tiff.c
+++ b/source/blender/imbuf/intern/tiff.c
@@ -813,26 +813,51 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags)
}
/* copy pixel data. While copying, we flip the image vertically. */
+ const int channels_in_float = ibuf->channels ? ibuf->channels : 4;
for (x = 0; x < ibuf->x; x++) {
for (y = 0; y < ibuf->y; y++) {
- from_i = 4 * (y * ibuf->x + x);
+ from_i = ((size_t)channels_in_float) * (y * ibuf->x + x);
to_i = samplesperpixel * ((ibuf->y - y - 1) * ibuf->x + x);
if (pixels16) {
/* convert from float source */
float rgb[4];
-
- if (ibuf->float_colorspace) {
- /* float buffer was managed already, no need in color space conversion */
- copy_v3_v3(rgb, &fromf[from_i]);
+
+ if (channels_in_float == 3 || channels_in_float == 4) {
+ if (ibuf->float_colorspace ||
+ (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA))
+ {
+ /* Float buffer was managed already, no need in color
+ * space conversion.
+ */
+ copy_v3_v3(rgb, &fromf[from_i]);
+ }
+ else {
+ /* Standard linear-to-srgb conversion if float buffer
+ * wasn't managed.
+ */
+ linearrgb_to_srgb_v3_v3(rgb, &fromf[from_i]);
+ }
+ if (channels_in_float == 4) {
+ rgb[3] = fromf[from_i + 3];
+ }
+ else {
+ rgb[3] = 1.0f;
+ }
}
else {
- /* standard linear-to-srgb conversion if float buffer wasn't managed */
- linearrgb_to_srgb_v3_v3(rgb, &fromf[from_i]);
+ if (ibuf->float_colorspace ||
+ (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA))
+ {
+ rgb[0] = fromf[from_i];
+ }
+ else {
+ rgb[0] = linearrgb_to_srgb(fromf[from_i]);
+ }
+ rgb[1] = rgb[2] = rgb[0];
+ rgb[3] = 1.0f;
}
- rgb[3] = fromf[from_i + 3];
-
for (i = 0; i < samplesperpixel; i++, to_i++)
to16[to_i] = FTOUSHORT(rgb[i]);
}
diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c
index ba8480b636f..76a44aa81f7 100644
--- a/source/blender/imbuf/intern/util.c
+++ b/source/blender/imbuf/intern/util.c
@@ -52,10 +52,6 @@
#include "IMB_anim.h"
-#ifdef WITH_QUICKTIME
-#include "quicktime_import.h"
-#endif
-
#ifdef WITH_FFMPEG
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
@@ -107,28 +103,6 @@ const char *imb_ext_image_filepath_only[] = {
NULL
};
-const char *imb_ext_image_qt[] = {
- ".gif",
- ".psd",
- ".pct", ".pict",
- ".pntg",
- ".qtif",
- NULL
-};
-
-#if 0 /* UNUSED */
-const char *imb_ext_movie_qt[] = {
- ".avi",
- ".flc",
- ".dv",
- ".r3d",
- ".mov",
- ".movie",
- ".mv",
- NULL
-};
-#endif
-
const char *imb_ext_movie[] = {
".avi",
".flc",
@@ -247,13 +221,6 @@ static int isavi(const char *name)
#endif
}
-#ifdef WITH_QUICKTIME
-static int isqtime(const char *name)
-{
- return anim_is_quicktime(name);
-}
-#endif
-
#ifdef WITH_FFMPEG
/* BLI_vsnprintf in ffmpeg_log_callback() causes invalid warning */
@@ -383,9 +350,6 @@ int imb_get_anim_type(const char *name)
if (UTIL_DEBUG) printf("%s: %s\n", __func__, name);
#ifndef _WIN32
-# ifdef WITH_QUICKTIME
- if (isqtime(name)) return (ANIM_QTIME);
-# endif
# ifdef WITH_FFMPEG
/* stat test below fails on large files > 4GB */
if (isffmpeg(name)) return (ANIM_FFMPEG);
@@ -401,9 +365,6 @@ int imb_get_anim_type(const char *name)
if (((st.st_mode) & S_IFMT) != S_IFREG) return(0);
if (ismovie(name)) return (ANIM_MOVIE);
-# ifdef WITH_QUICKTIME
- if (isqtime(name)) return (ANIM_QTIME);
-# endif
# ifdef WITH_FFMPEG
if (isffmpeg(name)) return (ANIM_FFMPEG);
# endif
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index ed29f2336de..4ea5b8761b9 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -138,11 +138,11 @@ typedef struct ID {
/**
* LIB_TAG_... tags (runtime only, cleared at read time).
*/
- short tag;
- short pad_s1;
+ int tag;
int us;
int icon_id;
IDProperty *properties;
+ void *py_instance;
} ID;
/**
@@ -301,7 +301,7 @@ typedef enum ID_Type {
#ifdef GS
# undef GS
#endif
-#define GS(a) (CHECK_TYPE_ANY(a, char *, const char *, char [66], const char[66]), (*((const short *)(a))))
+#define GS(a) (CHECK_TYPE_ANY(a, char *, const char *, char [66], const char[66]), (ID_Type)(*((const short *)(a))))
#define ID_NEW_SET(_id, _idn) \
(((ID *)(_id))->newid = (ID *)(_idn), ((ID *)(_id))->newid->tag |= LIB_TAG_NEW, (void *)((ID *)(_id))->newid)
@@ -363,6 +363,16 @@ enum {
LIB_TAG_ID_RECALC_DATA = 1 << 13,
LIB_TAG_ANIM_NO_RECALC = 1 << 14,
LIB_TAG_ID_RECALC_ALL = (LIB_TAG_ID_RECALC | LIB_TAG_ID_RECALC_DATA),
+
+ /* The datablock is a copy-on-write version. */
+ LIB_TAG_COPY_ON_WRITE = 1 << 15,
+
+ /* RESET_NEVER tag datablock for freeing etc. behavior (usually set when copying real one into temp/runtime one). */
+ LIB_TAG_NO_MAIN = 1 << 16, /* Datablock is not listed in Main database. */
+ LIB_TAG_NO_USER_REFCOUNT = 1 << 17, /* Datablock does not refcount usages of other IDs. */
+ /* Datablock was not allocated by standard system (BKE_libblock_alloc), do not free its memory
+ * (usual type-specific freeing is called though). */
+ LIB_TAG_NOT_ALLOCATED = 1 << 18,
};
/* To filter ID types (filter_id) */
@@ -401,7 +411,7 @@ enum {
FILTER_ID_PA = (1 << 27),
FILTER_ID_CF = (1 << 28),
FILTER_ID_WS = (1 << 29),
- FILTER_ID_LP = (1 << 31),
+ FILTER_ID_LP = (1u << 31),
};
/* IMPORTANT: this enum matches the order currently use in set_listbasepointers,
diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h
index 90d6bbb4f1e..7809d2d1c4a 100644
--- a/source/blender/makesdna/DNA_action_types.h
+++ b/source/blender/makesdna/DNA_action_types.h
@@ -530,7 +530,7 @@ typedef enum eActionGroup_Flag {
AGRP_MODIFIERS_OFF = (1 << 7),
AGRP_TEMP = (1 << 30),
- AGRP_MOVED = (1 << 31)
+ AGRP_MOVED = (1u << 31)
} eActionGroup_Flag;
@@ -773,7 +773,7 @@ typedef enum ACHAN_FLAG {
ACHAN_EXPANDED = (1 << 4),
ACHAN_SHOWIPO = (1 << 5),
ACHAN_SHOWCONS = (1 << 6),
- ACHAN_MOVED = (1 << 31)
+ ACHAN_MOVED = (1u << 31)
} ACHAN_FLAG;
#endif /* __DNA_ACTION_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h
index e50a2637fff..935a893f689 100644
--- a/source/blender/makesdna/DNA_anim_types.h
+++ b/source/blender/makesdna/DNA_anim_types.h
@@ -685,7 +685,7 @@ typedef enum eNlaStrip_Flag {
/* temporary editing flags */
/* NLA-Strip is really just a temporary meta used to facilitate easier transform code */
NLASTRIP_FLAG_TEMP_META = (1<<30),
- NLASTRIP_FLAG_EDIT_TOUCHED = (1<<31)
+ NLASTRIP_FLAG_EDIT_TOUCHED = (1u << 31)
} eNlaStrip_Flag;
/* NLA Strip Type */
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index f4a1677efc4..c285b44c939 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -95,8 +95,12 @@ typedef struct Brush {
float plane_offset; /* offset for plane brushes (clay, flatten, fill, scrape) */
int gradient_spacing;
- int gradient_stroke_mode; /* source for stroke color gradient application */
- int gradient_fill_mode; /* source for fill tool color gradient application */
+ char gradient_stroke_mode; /* source for stroke color gradient application */
+ char gradient_fill_mode; /* source for fill tool color gradient application */
+
+ char pad;
+ char falloff_shape; /* Projection shape (sphere, circle) */
+ float falloff_angle;
char sculpt_tool; /* active sculpt tool */
char vertexpaint_tool; /* active vertex/weight paint blend mode (poorly named) */
@@ -181,13 +185,13 @@ typedef enum BrushGradientSourceFill {
/* Brush.flag */
typedef enum BrushFlags {
BRUSH_AIRBRUSH = (1 << 0),
-// BRUSH_TORUS = (1 << 1), deprecated, use paint->symmetry_flags & PAINT_TILE_*
+ BRUSH_FLAG_DEPRECATED_1 = (1 << 1),
BRUSH_ALPHA_PRESSURE = (1 << 2),
BRUSH_SIZE_PRESSURE = (1 << 3),
BRUSH_JITTER_PRESSURE = (1 << 4),
BRUSH_SPACING_PRESSURE = (1 << 5),
- BRUSH_UNUSED = (1 << 6),
-// BRUSH_RAKE = (1 << 7), deprecated, use brush_angle_mode
+ BRUSH_FLAG_DEPRECATED_2 = (1 << 6),
+ BRUSH_FLAG_DEPRECATED_3 = (1 << 7),
BRUSH_ANCHORED = (1 << 8),
BRUSH_DIR_IN = (1 << 9),
BRUSH_SPACE = (1 << 10),
@@ -197,6 +201,7 @@ typedef enum BrushFlags {
BRUSH_LOCK_ALPHA = (1 << 14),
BRUSH_ORIGINAL_NORMAL = (1 << 15),
BRUSH_OFFSET_PRESSURE = (1 << 16),
+ BRUSH_FLAG_DEPRECATED_4 = (1 << 17),
BRUSH_SPACE_ATTEN = (1 << 18),
BRUSH_ADAPTIVE_SPACE = (1 << 19),
BRUSH_LOCK_SIZE = (1 << 20),
@@ -204,13 +209,13 @@ typedef enum BrushFlags {
BRUSH_EDGE_TO_EDGE = (1 << 22),
BRUSH_DRAG_DOT = (1 << 23),
BRUSH_INVERSE_SMOOTH_PRESSURE = (1 << 24),
-// BRUSH_RANDOM_ROTATION = (1 << 25), deprecated, use brush_angle_mode
+ BRUSH_FRONTFACE_FALLOFF = (1 << 25),
BRUSH_PLANE_TRIM = (1 << 26),
BRUSH_FRONTFACE = (1 << 27),
BRUSH_CUSTOM_ICON = (1 << 28),
BRUSH_LINE = (1 << 29),
BRUSH_ABSOLUTE_JITTER = (1 << 30),
- BRUSH_CURVE = (1 << 31)
+ BRUSH_CURVE = (1u << 31)
} BrushFlags;
typedef enum {
@@ -315,7 +320,21 @@ enum {
PAINT_BLEND_MUL = 3,
PAINT_BLEND_BLUR = 4,
PAINT_BLEND_LIGHTEN = 5,
- PAINT_BLEND_DARKEN = 6
+ PAINT_BLEND_DARKEN = 6,
+ PAINT_BLEND_AVERAGE = 7,
+ PAINT_BLEND_SMEAR = 8,
+ PAINT_BLEND_COLORDODGE = 9,
+ PAINT_BLEND_DIFFERENCE = 10,
+ PAINT_BLEND_SCREEN = 11,
+ PAINT_BLEND_HARDLIGHT = 12,
+ PAINT_BLEND_OVERLAY = 13,
+ PAINT_BLEND_SOFTLIGHT = 14,
+ PAINT_BLEND_EXCLUSION = 15,
+ PAINT_BLEND_LUMINOCITY = 16,
+ PAINT_BLEND_SATURATION = 17,
+ PAINT_BLEND_HUE = 18,
+ PAINT_BLEND_ALPHA_SUB = 19,
+ PAINT_BLEND_ALPHA_ADD = 20,
};
typedef enum {
@@ -329,6 +348,12 @@ typedef enum BlurKernelType {
KERNEL_BOX
} BlurKernelType;
+/* Brush.falloff_shape */
+enum {
+ PAINT_FALLOFF_SHAPE_SPHERE = 0,
+ PAINT_FALLOFF_SHAPE_TUBE = 1,
+};
+
#define MAX_BRUSH_PIXEL_RADIUS 500
#endif /* __DNA_BRUSH_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_lamp_types.h b/source/blender/makesdna/DNA_lamp_types.h
index cb5b44f3268..92703fa2d3b 100644
--- a/source/blender/makesdna/DNA_lamp_types.h
+++ b/source/blender/makesdna/DNA_lamp_types.h
@@ -106,6 +106,14 @@ typedef struct Lamp {
short pr_texture, use_nodes;
char pad6[4];
+ /* Eevee */
+ float cascade_max_dist;
+ float cascade_exponent;
+ float cascade_fade;
+ int cascade_count;
+
+ float contact_dist, contact_bias, contact_spread, contact_thickness;
+
/* preview */
struct PreviewImage *preview;
@@ -151,6 +159,7 @@ typedef struct Lamp {
#define LA_SHAD_TEX (1 << 16)
#define LA_SHOW_CONE (1 << 17)
#define LA_SHOW_SHADOW_BOX (1 << 18)
+#define LA_SHAD_CONTACT (1 << 19)
/* layer_shadow */
#define LA_LAYER_SHADOW_BOTH 0
diff --git a/source/blender/makesdna/DNA_layer_types.h b/source/blender/makesdna/DNA_layer_types.h
index 03ca6cd8c5c..7ef6e8c34dd 100644
--- a/source/blender/makesdna/DNA_layer_types.h
+++ b/source/blender/makesdna/DNA_layer_types.h
@@ -114,6 +114,7 @@ enum {
enum {
COLLECTION_VISIBLE = (1 << 0),
COLLECTION_SELECTABLE = (1 << 1),
+ COLLECTION_DISABLED = (1 << 2),
};
/* SceneLayer->flag */
diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h
index 09a4e42cb8f..220326fb01d 100644
--- a/source/blender/makesdna/DNA_material_types.h
+++ b/source/blender/makesdna/DNA_material_types.h
@@ -211,6 +211,14 @@ typedef struct Material {
char nmap_tangent_names[9][64]; /* [MAX_MTFACE+1][MAX_NAME]; +1 for empty name */
int nmap_tangent_names_count, pad5;
+ /* Transparency */
+ float alpha_threshold;
+ float refract_depth;
+ char blend_method;
+ char blend_shadow;
+ char blend_flag;
+ char pad6[5];
+
/* image to use for image/uv space, also bake target
* (not to be used shading/rendering pipeline, this is editor featyure only!). */
struct Image *edit_image;
@@ -491,5 +499,29 @@ typedef struct Material {
#define MA_VOL_SHADE_MULTIPLE 3
#define MA_VOL_SHADE_SHADEDPLUSMULTIPLE 4
+/* blend_method */
+enum {
+ MA_BM_SOLID,
+ MA_BM_ADD,
+ MA_BM_MULTIPLY,
+ MA_BM_CLIP,
+ MA_BM_HASHED,
+ MA_BM_BLEND,
+};
+
+/* blend_flag */
+enum {
+ MA_BL_HIDE_BACKSIDE = (1 << 0),
+ MA_BL_SS_REFRACTION = (1 << 1),
+};
+
+/* blend_shadow */
+enum {
+ MA_BS_NONE = 0,
+ MA_BS_SOLID,
+ MA_BS_CLIP,
+ MA_BS_HASHED,
+};
+
#endif
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 4959055ed10..eaacee0d595 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -98,7 +98,7 @@ typedef enum ModifierMode {
eModifierMode_Expanded = (1 << 4),
eModifierMode_Virtual = (1 << 5),
eModifierMode_ApplyOnSpline = (1 << 6),
- eModifierMode_DisableTemporary = (1 << 31)
+ eModifierMode_DisableTemporary = (1u << 31)
} ModifierMode;
typedef struct ModifierData {
@@ -278,6 +278,7 @@ typedef struct MirrorModifierData {
short flag;
float tolerance;
float uv_offset[2];
+ float uv_offset_copy[2];
struct Object *mirror_ob;
} MirrorModifierData;
@@ -654,7 +655,8 @@ typedef struct BooleanModifierData {
struct Object *object;
char operation;
char solver;
- char pad[2];
+ char pad;
+ char bm_flag;
float double_threshold;
} BooleanModifierData;
@@ -669,6 +671,13 @@ typedef enum {
eBooleanModifierSolver_BMesh = 1,
} BooleanSolver;
+/* bm_flag (only used when G_DEBUG) */
+enum {
+ eBooleanModifierBMeshFlag_BMesh_Separate = (1 << 0),
+ eBooleanModifierBMeshFlag_BMesh_NoDissolve = (1 << 1),
+ eBooleanModifierBMeshFlag_BMesh_NoConnectRegions = (1 << 2),
+};
+
typedef struct MDefInfluence {
int vertex;
float weight;
@@ -924,9 +933,10 @@ typedef struct ScrewModifierData {
unsigned int iter;
float screw_ofs;
float angle;
- char axis;
- char pad;
+ float merge_dist;
short flag;
+ char axis;
+ char pad[5];
} ScrewModifierData;
enum {
@@ -937,6 +947,7 @@ enum {
MOD_SCREW_SMOOTH_SHADING = (1 << 5),
MOD_SCREW_UV_STRETCH_U = (1 << 6),
MOD_SCREW_UV_STRETCH_V = (1 << 7),
+ MOD_SCREW_MERGE = (1 << 8),
};
typedef struct OceanModifierData {
@@ -1515,7 +1526,7 @@ enum {
MOD_DATATRANSFER_USE_VERT = 1 << 28,
MOD_DATATRANSFER_USE_EDGE = 1 << 29,
MOD_DATATRANSFER_USE_LOOP = 1 << 30,
- MOD_DATATRANSFER_USE_POLY = 1 << 31,
+ MOD_DATATRANSFER_USE_POLY = 1u << 31,
};
/* Set Split Normals modifier */
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index b922ac072b0..016de0f1cc9 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -111,7 +111,7 @@ typedef struct bNodeSocket {
short stack_index; /* local stack index */
/* XXX deprecated, kept for forward compatibility */
short stack_type DNA_DEPRECATED;
- int pad;
+ char draw_shape, pad[3];
void *cache; /* cached data from execution */
@@ -143,6 +143,13 @@ typedef enum eNodeSocketDatatype {
SOCK_STRING = 7
} eNodeSocketDatatype;
+/* socket shape */
+typedef enum eNodeSocketDrawShape {
+ SOCK_DRAW_SHAPE_CIRCLE = 0,
+ SOCK_DRAW_SHAPE_SQUARE = 1,
+ SOCK_DRAW_SHAPE_DIAMOND = 2
+} eNodeSocketDrawShape;
+
/* socket side (input/output) */
typedef enum eNodeSocketInOut {
SOCK_IN = 1,
@@ -214,8 +221,11 @@ typedef struct bNode {
* and replacing all uses with per-instance data.
*/
short preview_xsize, preview_ysize; /* reserved size of the preview rect */
- int pad2;
+ short pad2[2];
struct uiBlock *block; /* runtime during drawing */
+
+ float ssr_id; /* XXX: eevee only, id of screen space reflection layer, needs to be a float to feed GPU_uniform. */
+ float pad3;
} bNode;
/* node->flag */
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index 160f7f7feff..529fcad21d4 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -70,6 +70,8 @@ typedef struct bDeformGroup {
typedef struct bFaceMap {
struct bFaceMap *next, *prev;
char name[64]; /* MAX_VGROUP_NAME */
+ char flag;
+ char pad[7];
} bFaceMap;
/* Object Runtime display data */
@@ -297,15 +299,15 @@ typedef struct Object {
struct FluidsimSettings *fluidsimSettings; /* if fluidsim enabled, store additional settings */
- /* Runtime valuated curve-specific data, not stored in the file */
- struct CurveCache *curve_cache;
-
struct DerivedMesh *derivedDeform, *derivedFinal;
uint64_t lastDataMask; /* the custom data layer mask that was last used to calculate derivedDeform and derivedFinal */
uint64_t customdata_mask; /* (extra) custom data layer mask to use for creating derivedmesh, set by depsgraph */
unsigned int state; /* bit masks of game controllers that are active */
unsigned int init_state; /* bit masks of initial state as recorded by the users */
+ /* Runtime valuated curve-specific data, not stored in the file */
+ struct CurveCache *curve_cache;
+
ListBase gpulamp; /* runtime, for glsl lamp display only */
ListBase pc_ids;
ListBase *duplilist; /* for temporary dupli list storage, only for use by RNA API */
@@ -721,6 +723,9 @@ typedef enum ObjectMode {
/* any mode where the brush system is used */
#define OB_MODE_ALL_PAINT (OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)
+/* any mode that uses ob->sculpt */
+#define OB_MODE_ALL_SCULPT (OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)
+
#define MAX_DUPLI_RECUR 8
#ifdef __cplusplus
diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h
index cde8eef6ef3..ea7905eb2ad 100644
--- a/source/blender/makesdna/DNA_particle_types.h
+++ b/source/blender/makesdna/DNA_particle_types.h
@@ -260,8 +260,9 @@ typedef struct ParticleSettings {
/* modified dm support */
short use_modifier_stack;
- short pad5[3];
+ short pad5;
+ int recalc;
} ParticleSettings;
typedef struct ParticleSystem {
@@ -324,7 +325,7 @@ typedef struct ParticleSystem {
struct ParticleDrawData *pdd;
float dt_frac; /* current time step, as a fraction of a frame */
- float _pad; /* spare capacity */
+ float lattice_strength; /* influence of the lattice modifier */
void *batch_cache;
} ParticleSystem;
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index f21cee80f80..d81a4625144 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -96,42 +96,6 @@ typedef struct AviCodecData {
char avicodecname[128];
} AviCodecData;
-typedef struct QuicktimeCodecData {
- /*Old quicktime implementation compatibility fields, read only in 2.5 - deprecated*/
- void *cdParms; /* codec/compressor options */
- void *pad; /* padding */
-
- unsigned int cdSize; /* size of cdParms buffer */
- unsigned int pad2; /* padding */
-
- char qtcodecname[128];
-} QuicktimeCodecData;
-
-typedef struct QuicktimeCodecSettings {
- /* Codec settings detailed for 2.5 implementation*/
- int codecType; /* Types defined in quicktime_export.h */
- int codecSpatialQuality; /* in 0-100 scale, to be translated in 0-1024 for qt use */
-
- /* Settings not available in current QTKit API */
- int codec;
- int codecFlags;
- int colorDepth;
- int codecTemporalQuality; /* in 0-100 scale, to be translated in 0-1024 for qt use */
- int minSpatialQuality; /* in 0-100 scale, to be translated in 0-1024 for qt use */
- int minTemporalQuality; /* in 0-100 scale, to be translated in 0-1024 for qt use */
- int keyFrameRate;
- int bitRate; /* bitrate in bps */
-
- /* Audio Codec settings */
- int audiocodecType;
- int audioSampleRate;
- short audioBitDepth;
- short audioChannels;
- int audioCodecFlags;
- int audioBitRate;
- int pad1;
-} QuicktimeCodecSettings;
-
typedef enum FFMpegPreset {
FFM_PRESET_NONE,
FFM_PRESET_ULTRAFAST,
@@ -453,7 +417,7 @@ typedef struct ImageFormatData {
#define R_IMF_IMTYPE_AVIJPEG 16
#define R_IMF_IMTYPE_PNG 17
/* #define R_IMF_IMTYPE_AVICODEC 18 */ /* avicodec is nomore */
-#define R_IMF_IMTYPE_QUICKTIME 19
+/* #define R_IMF_IMTYPE_QUICKTIME 19 */ /* quicktime is nomore */
#define R_IMF_IMTYPE_BMP 20
#define R_IMF_IMTYPE_RADHDR 21
#define R_IMF_IMTYPE_TIFF 22
@@ -588,8 +552,6 @@ typedef struct RenderData {
struct ImageFormatData im_format;
struct AviCodecData *avicodecdata;
- struct QuicktimeCodecData *qtcodecdata;
- struct QuicktimeCodecSettings qtcodecsettings;
struct FFMpegCodecData ffcodecdata;
int cfra, sfra, efra; /* frames as in 'images' */
@@ -754,7 +716,7 @@ typedef struct RenderData {
/* sequencer options */
char seq_prev_type;
- char seq_rend_type;
+ char seq_rend_type; /* UNUSED! */
char seq_flag; /* flag use for sequence render/draw */
char pad5[5];
@@ -793,14 +755,13 @@ typedef struct RenderData {
struct BakeData bake;
int preview_start_resolution;
+ short preview_pixel_size;
/* Type of the debug pass to use.
* Only used when built with debug passes support.
*/
short debug_pass_type;
- short pad;
-
/* MultiView */
ListBase views; /* SceneRenderView */
short actview;
@@ -1160,23 +1121,15 @@ typedef struct UvSculpt {
/* Vertex Paint */
typedef struct VPaint {
Paint paint;
-
- short flag, pad;
- int tot; /* allocation size of prev buffers */
- unsigned int *vpaint_prev; /* previous mesh colors */
- struct MDeformVert *wpaint_prev; /* previous vertex weights */
-
- void *paintcursor; /* wm handle */
+ char flag;
+ char pad[3];
+ int radial_symm[3]; /* For mirrored painting */
} VPaint;
/* VPaint.flag */
enum {
- // VP_COLINDEX = (1 << 0), /* only paint onto active material*/ /* deprecated since before 2.49 */
- // VP_AREA = (1 << 1), /* deprecated since 2.70 */
- VP_NORMALS = (1 << 3),
- VP_SPRAY = (1 << 4),
- // VP_MIRROR_X = (1 << 5), /* deprecated in 2.5x use (me->editflag & ME_EDIT_MIRROR_X) */
- VP_ONLYVGROUP = (1 << 7) /* weight paint only */
+ /* weight paint only */
+ VP_FLAG_VGROUP_RESTRICT = (1 << 7)
};
/* ------------------------------------------- */
@@ -1661,8 +1614,7 @@ typedef struct Scene {
struct Object *obedit; /* name replaces old G.obedit */
float cursor[3]; /* 3d cursor location */
- float twcent[3]; /* center for transform widget */
- float twmin[3], twmax[3]; /* boundbox of selection for transform widget */
+ char _pad[4];
unsigned int lay; /* bitflags for layer visibility */
int layact; /* active layer */
@@ -1697,7 +1649,7 @@ typedef struct Scene {
void *fps_info; /* (runtime) info/cache used for presenting playback framerate info to the user */
/* none of the dependency graph vars is mean to be saved */
- struct Depsgraph *depsgraph;
+ struct Depsgraph *depsgraph_legacy;
void *pad1;
struct DagForest *theDag;
short dagflags;
@@ -1720,12 +1672,14 @@ typedef struct Scene {
/* Physics simulation settings */
struct PhysicsSettings physics_settings;
- /* Movie Tracking */
- struct MovieClip *clip; /* active movie clip */
+ void *pad6;
uint64_t customdata_mask; /* XXX. runtime flag for drawing, actually belongs in the window, only used by BKE_object_handle_update() */
uint64_t customdata_mask_modal; /* XXX. same as above but for temp operator use (gl renders) */
+ /* Movie Tracking */
+ struct MovieClip *clip; /* active movie clip */
+
/* Color Management */
ColorManagedViewSettings view_settings;
ColorManagedDisplaySettings display_settings;
@@ -1753,8 +1707,7 @@ typedef struct Scene {
/* use preview range */
#define SCER_PRV_RANGE (1<<0)
#define SCER_LOCK_FRAME_SELECTION (1<<1)
- /* timeline/keyframe jumping - only selected items (on by default) */
-#define SCE_KEYS_NO_SELONLY (1<<2)
+ /* show/use subframes (for checking motion blur) */
#define SCER_SHOW_SUBFRAME (1<<3)
/* mode (int now) */
@@ -1794,7 +1747,7 @@ typedef struct Scene {
#define R_USE_WS_SHADING 0x8000000 /* use world space interpretation of lighting data */
/* seq_flag */
-#define R_SEQ_GL_PREV 1
+// #define R_SEQ_GL_PREV 1 // UNUSED, we just use setting from seq_prev_type now.
// #define R_SEQ_GL_REND 2 // UNUSED, opengl render has its own operator now.
#define R_SEQ_SOLID_TEX 4
@@ -1941,16 +1894,18 @@ extern const char *RE_engine_id_CYCLES;
/* **************** SCENE ********************* */
/* note that much higher maxframes give imprecise sub-frames, see: T46859 */
+/* Current precision is 16 for the sub-frames closer to MAXFRAME. */
+
/* for general use */
-#define MAXFRAME 500000
-#define MAXFRAMEF 500000.0f
+#define MAXFRAME 1048574
+#define MAXFRAMEF 1048574.0f
#define MINFRAME 0
#define MINFRAMEF 0.0f
/* (minimum frame number for current-frame) */
-#define MINAFRAME -500000
-#define MINAFRAMEF -500000.0f
+#define MINAFRAME -1048574
+#define MINAFRAMEF -1048574.0f
/* depricate this! */
#define TESTBASE(v3d, base) ( \
@@ -1982,10 +1937,10 @@ extern const char *RE_engine_id_CYCLES;
#define BASACT (scene->basact)
#define OBACT (BASACT ? BASACT->object: NULL)
-#define FIRSTBASE_NEW (sl)->object_bases.first
-#define LASTBASE_NEW (sl)->object_bases.last
-#define BASACT_NEW ((sl)->basact)
-#define OBACT_NEW (BASACT_NEW ? BASACT_NEW->object: NULL)
+#define FIRSTBASE_NEW(_sl) ((_sl)->object_bases.first)
+#define LASTBASE_NEW(_sl) ((_sl)->object_bases.last)
+#define BASACT_NEW(_sl) ((_sl)->basact)
+#define OBACT_NEW(_sl) (BASACT_NEW(_sl) ? BASACT_NEW(_sl)->object: NULL)
#define V3D_CAMERA_LOCAL(v3d) ((!(v3d)->scenelock && (v3d)->camera) ? (v3d)->camera : NULL)
#define V3D_CAMERA_SCENE(scene, v3d) ((!(v3d)->scenelock && (v3d)->camera) ? (v3d)->camera : (scene)->camera)
@@ -2091,6 +2046,7 @@ typedef enum eVGroupSelect {
#define SCE_DS_COLLAPSED (1<<1)
#define SCE_NLA_EDIT_ON (1<<2)
#define SCE_FRAME_DROP (1<<3)
+#define SCE_KEYS_NO_SELONLY (1<<4)
/* return flag BKE_scene_base_iter_next functions */
diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h
index 75ae1cdab95..e3e5aaf8ca4 100644
--- a/source/blender/makesdna/DNA_screen_types.h
+++ b/source/blender/makesdna/DNA_screen_types.h
@@ -376,7 +376,7 @@ enum {
/* uiList filter orderby type */
enum {
UILST_FLT_SORT_ALPHA = 1 << 0,
- UILST_FLT_SORT_REVERSE = 1 << 31 /* Special value, bitflag used to reverse order! */
+ UILST_FLT_SORT_REVERSE = 1u << 31 /* Special value, bitflag used to reverse order! */
};
#define UILST_FLT_SORT_MASK (((unsigned int)UILST_FLT_SORT_REVERSE) - 1)
diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h
index 1f4e4df4660..74a1a13c2eb 100644
--- a/source/blender/makesdna/DNA_sequence_types.h
+++ b/source/blender/makesdna/DNA_sequence_types.h
@@ -442,7 +442,7 @@ enum {
/* access scene strips directly (like a metastrip) */
SEQ_SCENE_STRIPS = (1 << 30),
- SEQ_INVALID_EFFECT = (1 << 31),
+ SEQ_INVALID_EFFECT = (1u << 31),
};
/* StripProxy->storage */
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 833db376191..68cc5c2d79e 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -744,7 +744,7 @@ typedef enum eFileSel_File_Types {
FILE_TYPE_ALEMBIC = (1 << 16),
FILE_TYPE_DIR = (1 << 30), /* An FS directory (i.e. S_ISDIR on its path is true). */
- FILE_TYPE_BLENDERLIB = (1 << 31),
+ FILE_TYPE_BLENDERLIB = (1u << 31),
} eFileSel_File_Types;
/* Selection Flags in filesel: struct direntry, unsigned char selflag */
diff --git a/source/blender/makesdna/DNA_text_types.h b/source/blender/makesdna/DNA_text_types.h
index 8d1bba6ca4f..c7969cd30e7 100644
--- a/source/blender/makesdna/DNA_text_types.h
+++ b/source/blender/makesdna/DNA_text_types.h
@@ -61,8 +61,8 @@ typedef struct Text {
char *undo_buf;
int undo_pos, undo_len;
- void *compiled;
double mtime;
+ void *compiled;
} Text;
#define TXT_TABSIZE 4
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 01ad818d0f1..ab3fe1b51b9 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -48,7 +48,8 @@ struct ColorBand;
#define MAX_STYLE_NAME 64
-/* default uifont_id offered by Blender */
+/* default offered by Blender.
+ * uiFont.uifont_id */
typedef enum eUIFont_ID {
UIFONT_DEFAULT = 0,
/* UIFONT_BITMAP = 1 */ /* UNUSED */
@@ -64,7 +65,7 @@ typedef struct uiFont {
struct uiFont *next, *prev;
char filename[1024];/* 1024 = FILE_MAX */
short blf_id; /* from blfont lib */
- short uifont_id; /* own id */
+ short uifont_id; /* own id (eUIFont_ID) */
short r_to_l; /* fonts that read from left to right */
short hinting;
} uiFont;
@@ -84,7 +85,7 @@ typedef struct uiFontStyle {
float shadowcolor; /* 1 value, typically white or black anyway */
} uiFontStyle;
-/* uiFontStyle->align */
+/* uiFontStyle.align */
typedef enum eFontStyle_Align {
UI_STYLE_TEXT_LEFT = 0,
UI_STYLE_TEXT_CENTER = 1,
@@ -182,6 +183,14 @@ typedef struct ThemeUI {
/* Axis Colors */
char xaxis[4], yaxis[4], zaxis[4];
+
+ /* Manipulator Colors. */
+ char manipulator_hi[4];
+ char manipulator_primary[4];
+ char manipulator_secondary[4];
+ char manipulator_a[4];
+ char manipulator_b[4];
+ char pad2[4];
} ThemeUI;
/* try to put them all in one, if needed a special struct can be created as well
@@ -354,11 +363,11 @@ typedef struct ThemeWireColor {
char select[4];
char active[4];
- short flag;
+ short flag; /* eWireColor_Flags */
short pad;
} ThemeWireColor;
-/* flags for ThemeWireColor */
+/* ThemeWireColor.flag */
typedef enum eWireColor_Flags {
TH_WIRECOLOR_CONSTCOLS = (1 << 0),
TH_WIRECOLOR_TEXTCOLS = (1 << 1),
@@ -434,7 +443,8 @@ typedef struct UserDef {
/* UserDef has separate do-version handling, and can be read from other files */
int versionfile, subversionfile;
- int flag, dupflag;
+ int flag; /* eUserPref_Flag */
+ int dupflag; /* eDupli_ID_Flags */
int savetime;
char tempdir[768]; /* FILE_MAXDIR length */
char fontdir[768];
@@ -450,14 +460,15 @@ typedef struct UserDef {
int anim_player_preset;
short v2d_min_gridsize; /* minimum spacing between gridlines in View2D grids */
- short timecode_style; /* style of timecode display */
+ short timecode_style; /* eTimecodeStyles, style of timecode display */
short versions;
short dbl_click_time;
short gameflags;
short wheellinescroll;
- int uiflag, uiflag2;
+ int uiflag; /* eUserpref_UI_Flag */
+ int uiflag2; /* eUserpref_UI_Flag2 */
int language;
short userpref, viewzoom;
@@ -470,10 +481,10 @@ typedef struct UserDef {
int scrollback; /* console scrollback limit */
int dpi; /* range 48-128? */
float ui_scale; /* interface scale */
- int pad1;
+ int ui_line_width; /* interface line width */
char node_margin; /* node insert offset (aka auto-offset) margin, but might be useful for later stuff as well */
char pad2;
- short transopts;
+ short transopts; /* eUserpref_Translation_Flags */
short menuthreshold1, menuthreshold2;
/* startup template */
@@ -491,13 +502,13 @@ typedef struct UserDef {
short undosteps;
short undomemory;
short gp_manhattendist, gp_euclideandist, gp_eraser;
- short gp_settings;
+ short gp_settings; /* eGP_UserdefSettings */
short tb_leftmouse, tb_rightmouse;
struct SolidLight light[3];
short manipulator_flag, manipulator_size;
int pad3;
short textimeout, texcollectrate;
- short wmdrawmethod; /* removed wmpad */
+ short wmdrawmethod; /* eWM_DrawMethod */
short dragthreshold;
int memcachelimit;
int prefetchframes;
@@ -510,13 +521,13 @@ typedef struct UserDef {
short smooth_viewtx; /* miliseconds to spend spinning the view */
short glreslimit;
short curssize;
- short color_picker_type;
+ short color_picker_type; /* eColorPicker_Types */
char ipo_new; /* interpolation mode for newly added F-Curves */
char keyhandles_new; /* handle types for newly added keyframes */
char gpu_select_method;
char gpu_select_pick_deph;
char pad4;
- char view_frame_type;
+ char view_frame_type; /* eZoomFrame_Mode */
int view_frame_keyframes; /* number of keyframes to zoom around current frame */
float view_frame_seconds; /* seconds to zoom around current frame */
@@ -531,15 +542,16 @@ typedef struct UserDef {
float ndof_sensitivity; /* overall sensitivity of 3D mouse */
float ndof_orbit_sensitivity;
float ndof_deadzone; /* deadzone of 3D mouse */
- int ndof_flag; /* flags for 3D mouse */
+ int ndof_flag; /* eNdof_Flag, flags for 3D mouse */
- short ogl_multisamples; /* amount of samples for OpenGL FSA, if zero no FSA */
+ short ogl_multisamples; /* eMultiSample_Type, amount of samples for OpenGL FSA, if zero no FSA */
- short image_draw_method; /* Method to be used to draw the images (AUTO, GLSL, Textures or DrawPixels) */
+ /* eImageDrawMethod, Method to be used to draw the images (AUTO, GLSL, Textures or DrawPixels) */
+ short image_draw_method;
float glalphaclip;
- short autokey_mode; /* autokeying mode */
+ short autokey_mode; /* eAutokey_Mode, autokeying mode */
short autokey_flag; /* flags for autokeying */
short text_render, pad9; /* options for text rendering */
@@ -583,7 +595,7 @@ extern UserDef U; /* from blenkernel blender.c */
/* ***************** USERDEF ****************** */
-/* userpref/section */
+/* UserDef.userpref (UI active_section) */
typedef enum eUserPref_Section {
USER_SECTION_INTERFACE = 0,
USER_SECTION_EDIT = 1,
@@ -594,19 +606,19 @@ typedef enum eUserPref_Section {
USER_SECTION_ADDONS = 6,
} eUserPref_Section;
-/* flag */
+/* UserDef.flag */
typedef enum eUserPref_Flag {
USER_AUTOSAVE = (1 << 0),
-/* USER_AUTOGRABGRID = (1 << 1), deprecated */
-/* USER_AUTOROTGRID = (1 << 2), deprecated */
-/* USER_AUTOSIZEGRID = (1 << 3), deprecated */
+ USER_FLAG_DEPRECATED_1 = (1 << 1), /* cleared */
+ USER_FLAG_DEPRECATED_2 = (1 << 2), /* cleared */
+ USER_FLAG_DEPRECATED_3 = (1 << 3), /* cleared */
/* USER_SCENEGLOBAL = (1 << 4), deprecated */
USER_TRACKBALL = (1 << 5),
-/* USER_DUPLILINK = (1 << 6), deprecated */
-/* USER_FSCOLLUM = (1 << 7), deprecated */
+ USER_FLAG_DEPRECATED_6 = (1 << 6), /* cleared */
+ USER_FLAG_DEPRECATED_7 = (1 << 7), /* cleared */
USER_MAT_ON_OB = (1 << 8),
-/* USER_NO_CAPSLOCK = (1 << 9), */ /* not used anywhere */
-/* USER_VIEWMOVE = (1 << 10), */ /* not used anywhere */
+ USER_FLAG_DEPRECATED_9 = (1 << 9), /* cleared */
+ USER_FLAG_DEPRECATED_10 = (1 << 10), /* cleared */
USER_TOOLTIPS = (1 << 11),
USER_TWOBUTTONMOUSE = (1 << 12),
USER_NONUMPAD = (1 << 13),
@@ -625,7 +637,7 @@ typedef enum eUserPref_Flag {
USER_TOOLTIPS_PYTHON = (1 << 26),
} eUserPref_Flag;
-/* flag */
+/* bPathCompare.flag */
typedef enum ePathCompare_Flag {
USER_PATHCMP_GLOB = (1 << 0),
} ePathCompare_Flag;
@@ -636,33 +648,34 @@ typedef enum ePathCompare_Flag {
cfra = 0; \
} (void)0
-/* viewzoom */
+/* UserDef.viewzoom */
typedef enum eViewZoom_Style {
USER_ZOOM_CONT = 0,
USER_ZOOM_SCALE = 1,
USER_ZOOM_DOLLY = 2
} eViewZoom_Style;
-/* navigation_mode */
+/* UserDef.navigation_mode */
typedef enum eViewNavigation_Method {
VIEW_NAVIGATION_WALK = 0,
VIEW_NAVIGATION_FLY = 1,
} eViewNavigation_Method;
-/* flag */
+/* UserDef.flag */
typedef enum eWalkNavigation_Flag {
USER_WALK_GRAVITY = (1 << 0),
USER_WALK_MOUSE_REVERSE = (1 << 1),
} eWalkNavigation_Flag;
-/* uiflag */
+/* UserDef.uiflag */
typedef enum eUserpref_UI_Flag {
/* flags 0 and 1 were old flags (for autokeying) that aren't used anymore */
USER_WHEELZOOMDIR = (1 << 2),
USER_FILTERFILEEXTS = (1 << 3),
USER_DRAWVIEWINFO = (1 << 4),
USER_PLAINMENUS = (1 << 5),
- /* flags 6 and 7 were old flags that are no-longer used */
+ USER_LOCK_CURSOR_ADJUST = (1 << 6),
+ USER_UIFLAG_DEPRECATED_7 = (1 << 7), /* cleared */
USER_ALLWINCODECS = (1 << 8),
USER_MENUOPENAUTO = (1 << 9),
USER_ZBUF_CURSOR = (1 << 10),
@@ -686,17 +699,18 @@ typedef enum eUserpref_UI_Flag {
USER_HIDE_RECENT = (1 << 28),
USER_SHOW_THUMBNAILS = (1 << 29),
USER_QUIT_PROMPT = (1 << 30),
- USER_HIDE_SYSTEM_BOOKMARKS = (1 << 31)
+ USER_HIDE_SYSTEM_BOOKMARKS = (1u << 31)
} eUserpref_UI_Flag;
-/* uiflag2 */
+/* UserDef.uiflag2 */
typedef enum eUserpref_UI_Flag2 {
USER_KEEP_SESSION = (1 << 0),
USER_REGION_OVERLAP = (1 << 1),
USER_TRACKPAD_NATURAL = (1 << 2),
} eUserpref_UI_Flag2;
-/* Auto-Keying mode */
+/* Auto-Keying mode.
+ * UserDef.autokey_mode */
typedef enum eAutokey_Mode {
/* AUTOKEY_ON is a bitflag */
AUTOKEY_ON = 1,
@@ -706,7 +720,8 @@ typedef enum eAutokey_Mode {
AUTOKEY_MODE_EDITKEYS = 5
} eAutokey_Mode;
-/* Zoom to frame mode */
+/* Zoom to frame mode.
+ * UserDef.view_frame_type */
typedef enum eZoomFrame_Mode {
ZOOM_FRAME_MODE_KEEP_RANGE = 0,
ZOOM_FRAME_MODE_SECONDS = 1,
@@ -729,20 +744,20 @@ typedef enum eAutokey_Flag {
ANIMRECORD_FLAG_WITHNLA = (1 << 10),
} eAutokey_Flag;
-/* transopts */
+/* UserDef.transopts */
typedef enum eUserpref_Translation_Flags {
USER_TR_TOOLTIPS = (1 << 0),
USER_TR_IFACE = (1 << 1),
-/* USER_TR_MENUS = (1 << 2), deprecated */
-/* USER_TR_FILESELECT = (1 << 3), deprecated */
-/* USER_TR_TEXTEDIT = (1 << 4), deprecated */
+ USER_TR_DEPRECATED_2 = (1 << 2), /* cleared */
+ USER_TR_DEPRECATED_3 = (1 << 3), /* cleared */
+ USER_TR_DEPRECATED_4 = (1 << 4), /* cleared */
USER_DOTRANSLATE = (1 << 5),
- USER_USETEXTUREFONT = (1 << 6),
-/* CONVERT_TO_UTF8 = (1 << 7), deprecated */
+ USER_TR_DEPRECATED_6 = (1 << 6), /* cleared */
+ USER_TR_DEPRECATED_7 = (1 << 7), /* cleared */
USER_TR_NEWDATANAME = (1 << 8),
} eUserpref_Translation_Flags;
-/* dupflag */
+/* UserDef.dupflag */
typedef enum eDupli_ID_Flags {
USER_DUP_MESH = (1 << 0),
USER_DUP_CURVE = (1 << 1),
@@ -758,14 +773,13 @@ typedef enum eDupli_ID_Flags {
USER_DUP_PSYS = (1 << 11)
} eDupli_ID_Flags;
-/* gameflags */
+/* UserDef.gameflags */
typedef enum eOpenGL_RenderingOptions {
- /* USER_DEPRECATED_FLAG = (1 << 0), */
- /* USER_DISABLE_SOUND = (1 << 1), */ /* deprecated, don't use without checking for */
- /* backwards compatibilty in do_versions! */
- USER_DISABLE_MIPMAP = (1 << 2),
- /* USER_DISABLE_VBO = (1 << 3), */ /* DEPRECATED we always use vertex buffers now */
- /* USER_DISABLE_AA = (1 << 4), */ /* DEPRECATED */
+ USER_GL_RENDER_DEPRECATED_0 = (1 << 0),
+ USER_GL_RENDER_DEPRECATED_1 = (1 << 1),
+ USER_DISABLE_MIPMAP = (1 << 2),
+ USER_GL_RENDER_DEPRECATED_3 = (1 << 3),
+ USER_GL_RENDER_DEPRECATED_4 = (1 << 4),
} eOpenGL_RenderingOptions;
/* selection method for opengl gpu_select_method */
@@ -775,7 +789,8 @@ typedef enum eOpenGL_SelectOptions {
USER_SELECT_USE_SELECT_RENDERMODE = 2
} eOpenGL_SelectOptions;
-/* wm draw method */
+/* wm draw method.
+ * UserDef.wmdrawmethod */
typedef enum eWM_DrawMethod {
USER_DRAW_TRIPLE = 0,
USER_DRAW_OVERLAP = 1,
@@ -784,12 +799,16 @@ typedef enum eWM_DrawMethod {
USER_DRAW_OVERLAP_FLIP = 4,
} eWM_DrawMethod;
-/* text draw options */
+/* text draw options
+ * UserDef.text_render */
typedef enum eText_Draw_Options {
USER_TEXT_DISABLE_AA = (1 << 0),
} eText_Draw_Options;
-/* gp_settings (Grease Pencil Settings) */
+/* tw_flag (transform widget) */
+
+/* Grease Pencil Settings.
+ * UserDef.gp_settings */
typedef enum eGP_UserdefSettings {
GP_PAINT_DOSMOOTH = (1 << 0),
GP_PAINT_DOSIMPLIFY = (1 << 1),
@@ -800,7 +819,8 @@ enum {
USER_MANIPULATOR_SHADED = (1 << 1),
};
-/* color picker types */
+/* Color Picker Types.
+ * UserDef.color_picker_type */
typedef enum eColorPicker_Types {
USER_CP_CIRCLE_HSV = 0,
USER_CP_SQUARE_SV = 1,
@@ -809,7 +829,8 @@ typedef enum eColorPicker_Types {
USER_CP_CIRCLE_HSL = 4,
} eColorPicker_Types;
-/* timecode display styles */
+/* timecode display styles
+ * UserDef.timecode_style */
typedef enum eTimecodeStyles {
/* as little info as is necessary to show relevant info
* with '+' to denote the frames
@@ -844,7 +865,7 @@ typedef enum eTheme_DrawTypes {
TH_SHADED = 4
} eTheme_DrawTypes;
-/* ndof_flag (3D mouse options) */
+/* UserDef.ndof_flag (3D mouse options) */
typedef enum eNdof_Flag {
NDOF_SHOW_GUIDE = (1 << 0),
NDOF_FLY_HELICOPTER = (1 << 1),
@@ -877,6 +898,7 @@ typedef enum eNdof_Flag {
#define NDOF_PIXELS_PER_SECOND 600.0f
+/* UserDef.ogl_multisamples */
typedef enum eMultiSample_Type {
USER_MULTISAMPLE_NONE = 0,
USER_MULTISAMPLE_2 = 2,
@@ -884,7 +906,8 @@ typedef enum eMultiSample_Type {
USER_MULTISAMPLE_8 = 8,
USER_MULTISAMPLE_16 = 16,
} eMultiSample_Type;
-
+
+/* UserDef.image_draw_method */
typedef enum eImageDrawMethod {
/* IMAGE_DRAW_METHOD_AUTO = 0, */ /* Currently unused */
IMAGE_DRAW_METHOD_GLSL = 1,
@@ -892,6 +915,7 @@ typedef enum eImageDrawMethod {
IMAGE_DRAW_METHOD_DRAWPIXELS = 3,
} eImageDrawMethod;
+/* UserDef.virtual_pixel */
typedef enum eUserpref_VirtualPixel {
VIRTUAL_PIXEL_NATIVE = 0,
VIRTUAL_PIXEL_DOUBLE = 1,
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 22bb3cd5add..2af89a8eff0 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -234,7 +234,8 @@ typedef struct View3D {
struct GPUFXSettings fx_settings;
void *properties_storage; /* Nkey panel stores stuff here (runtime only!) */
- struct Material *defmaterial; /* used by matcap now */
+ /* Allocated per view, not library data (used by matcap). */
+ struct Material *defmaterial;
/* XXX deprecated? */
struct bGPdata *gpd DNA_DEPRECATED; /* Grease-Pencil Data (annotation layers) */
@@ -324,7 +325,7 @@ typedef struct View3D {
#define V3D_SOLID_MATCAP (1 << 12) /* user flag */
#define V3D_SHOW_SOLID_MATCAP (1 << 13) /* runtime flag */
#define V3D_OCCLUDE_WIRE (1 << 14)
-#define V3D_SHADELESS_TEX (1 << 15)
+#define V3D_SHOW_MODE_SHADE_OVERRIDE (1 << 15)
/* View3d->flag3 (short) */
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index 76be857b1af..182a026df94 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -56,9 +56,6 @@
#include "../blenlib/BLI_sys_types.h" // for intptr_t support
-/* Allow includinsg DNA files for specially guarded namespaces */
-#define DNA_NAMESPACE
-
#define SDNA_MAX_FILENAME_LENGTH 255
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index d1a76d8b216..114b0c32c15 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -132,6 +132,7 @@ extern StructRNA RNA_CompositorNodeCombRGBA;
extern StructRNA RNA_CompositorNodeCombYCCA;
extern StructRNA RNA_CompositorNodeCombYUVA;
extern StructRNA RNA_CompositorNodeComposite;
+extern StructRNA RNA_CompositorNodeCornerPin;
extern StructRNA RNA_CompositorNodeCrop;
extern StructRNA RNA_CompositorNodeCurveRGB;
extern StructRNA RNA_CompositorNodeCurveVec;
@@ -175,6 +176,7 @@ extern StructRNA RNA_CompositorNodeSepYCCA;
extern StructRNA RNA_CompositorNodeSepYUVA;
extern StructRNA RNA_CompositorNodeSetAlpha;
extern StructRNA RNA_CompositorNodeSplitViewer;
+extern StructRNA RNA_CompositorNodeSunBeams;
extern StructRNA RNA_CompositorNodeSwitchView;
extern StructRNA RNA_CompositorNodeTexture;
extern StructRNA RNA_CompositorNodeTime;
@@ -497,7 +499,6 @@ extern StructRNA RNA_PropertyGroupItem;
extern StructRNA RNA_PropertySensor;
extern StructRNA RNA_PythonConstraint;
extern StructRNA RNA_PythonController;
-extern StructRNA RNA_QuickTimeSettings;
extern StructRNA RNA_RadarSensor;
extern StructRNA RNA_RandomSensor;
extern StructRNA RNA_RaySensor;
@@ -797,6 +798,9 @@ const struct ListBase *RNA_struct_type_functions(StructRNA *srna);
char *RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen, int *r_len);
+bool RNA_struct_available_or_report(struct ReportList *reports, const char *identifier);
+bool RNA_struct_bl_idname_ok_or_report(struct ReportList *reports, const char *identifier, const char *sep);
+
/* Properties
*
* Access to struct properties. All this works with RNA pointers rather than
@@ -1197,6 +1201,10 @@ int RNA_function_call_direct_va(struct bContext *C, struct ReportList *reports,
int RNA_function_call_direct_va_lookup(struct bContext *C, struct ReportList *reports, PointerRNA *ptr,
const char *identifier, const char *format, va_list args);
+const char *RNA_translate_ui_text(const char *text, const char *text_ctxt,
+ struct StructRNA *type, struct PropertyRNA *prop,
+ int translate);
+
/* ID */
short RNA_type_to_ID_code(const StructRNA *type);
@@ -1211,7 +1219,7 @@ StructRNA *ID_code_to_RNA_type(short idcode);
} (void)0
/* macro which inserts the function name */
-#if defined __GNUC__ || defined __sun
+#if defined __GNUC__
# define RNA_warning(format, args ...) _RNA_warning("%s: " format "\n", __func__, ##args)
#else
# define RNA_warning(format, ...) _RNA_warning("%s: " format "\n", __FUNCTION__, __VA_ARGS__)
diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h
index 54938b236d5..7a61b3ec489 100644
--- a/source/blender/makesrna/RNA_define.h
+++ b/source/blender/makesrna/RNA_define.h
@@ -70,7 +70,8 @@ void RNA_def_struct_refine_func(StructRNA *srna, const char *refine);
void RNA_def_struct_idprops_func(StructRNA *srna, const char *refine);
void RNA_def_struct_register_funcs(StructRNA *srna, const char *reg, const char *unreg, const char *instance);
void RNA_def_struct_path_func(StructRNA *srna, const char *path);
-void RNA_def_struct_identifier(StructRNA *srna, const char *identifier);
+void RNA_def_struct_identifier_no_struct_map(StructRNA *srna, const char *identifier);
+void RNA_def_struct_identifier(BlenderRNA *brna, StructRNA *srna, const char *identifier);
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description);
void RNA_def_struct_ui_icon(StructRNA *srna, int icon);
void RNA_struct_free_extension(StructRNA *srna, ExtensionRNA *ext);
@@ -224,8 +225,8 @@ void RNA_enum_item_end(EnumPropertyItem **items, int *totitem);
/* Memory management */
-void RNA_def_struct_duplicate_pointers(StructRNA *srna);
-void RNA_def_struct_free_pointers(StructRNA *srna);
+void RNA_def_struct_duplicate_pointers(BlenderRNA *brna, StructRNA *srna);
+void RNA_def_struct_free_pointers(BlenderRNA *brna, StructRNA *srna);
void RNA_def_func_duplicate_pointers(FunctionRNA *func);
void RNA_def_func_free_pointers(FunctionRNA *func);
void RNA_def_property_duplicate_pointers(StructOrFunctionRNA *cont_, PropertyRNA *prop);
diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h
index b9bb741bcde..301c6fae3ca 100644
--- a/source/blender/makesrna/RNA_enum_types.h
+++ b/source/blender/makesrna/RNA_enum_types.h
@@ -115,6 +115,8 @@ extern EnumPropertyItem rna_enum_brush_image_tool_items[];
extern EnumPropertyItem rna_enum_gpencil_sculpt_brush_items[];
+extern EnumPropertyItem rna_enum_uv_sculpt_tool_items[];
+
extern EnumPropertyItem rna_enum_axis_xy_items[];
extern EnumPropertyItem rna_enum_axis_xyz_items[];
diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h
index 99ef0f9c8c4..2ec25bc8e46 100644
--- a/source/blender/makesrna/RNA_types.h
+++ b/source/blender/makesrna/RNA_types.h
@@ -178,7 +178,7 @@ typedef enum PropertyFlag {
* after every typed char, instead of waiting final validation. Used e.g. for text searchbox.
* It will also cause UI_BUT_VALUE_CLEAR to be set for text buttons. We could add an own flag
* for search/filter properties, but this works just fine for now. */
- PROP_TEXTEDIT_UPDATE = (1 << 31),
+ PROP_TEXTEDIT_UPDATE = (1u << 31),
/* icon */
PROP_ICONS_CONSECUTIVE = (1 << 12),
@@ -437,6 +437,8 @@ typedef enum StructFlag {
STRUCT_NO_IDPROPERTIES = (1 << 6), /* Menus and Panels don't need properties */
STRUCT_NO_DATABLOCK_IDPROPERTIES = (1 << 7), /* e.g. for Operator */
STRUCT_CONTAINS_DATABLOCK_IDPROPERTIES = (1 << 8), /* for PropertyGroup which contains pointers to datablocks */
+ STRUCT_PUBLIC_NAMESPACE = (1 << 9), /* Added to type-map #BlenderRNA.structs_map */
+ STRUCT_PUBLIC_NAMESPACE_INHERIT = (1 << 10), /* All subtypes are added too. */
} StructFlag;
typedef int (*StructValidateFunc)(struct PointerRNA *ptr, void *data, int *have_function);
diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt
index 75d127079b9..bf537ea67c6 100644
--- a/source/blender/makesrna/intern/CMakeLists.txt
+++ b/source/blender/makesrna/intern/CMakeLists.txt
@@ -144,6 +144,9 @@ set(GENSRC_CFLAGS)
if(CMAKE_COMPILER_IS_GNUCC OR (CMAKE_C_COMPILER_ID MATCHES "Clang"))
set(GENSRC_CFLAGS "-Wno-missing-prototypes")
endif()
+if(CMAKE_C_COMPILER_ID MATCHES "Clang")
+ set(GENSRC_CFLAGS "${GENSRC_CFLAGS} -Wno-missing-variable-declarations")
+endif()
if(GENSRC_CFLAGS)
set_source_files_properties(${GENSRC} PROPERTIES COMPILE_FLAGS "${GENSRC_CFLAGS}")
@@ -230,20 +233,13 @@ if(WITH_IMAGE_FRAMESERVER)
endif()
if(WITH_AUDASPACE)
- add_definitions(${AUDASPACE_DEFINITIONS})
+ add_definitions(-DWITH_AUDASPACE)
list(APPEND INC_SYS
${AUDASPACE_C_INCLUDE_DIRS}
)
endif()
-if(WITH_CODEC_QUICKTIME)
- list(APPEND INC
- ../../quicktime
- )
- add_definitions(-DWITH_QUICKTIME)
-endif()
-
if(WITH_CODEC_FFMPEG)
list(APPEND INC
../../../../intern/ffmpeg
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 7d2ce4cb3b2..f232a1aef48 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -2583,17 +2583,23 @@ static void rna_generate_blender(BlenderRNA *brna, FILE *f)
{
StructRNA *srna;
- fprintf(f, "BlenderRNA BLENDER_RNA = {");
-
+ fprintf(f,
+ "BlenderRNA BLENDER_RNA = {\n"
+ "\t.structs = {"
+ );
srna = brna->structs.first;
- if (srna) fprintf(f, "{&RNA_%s, ", srna->identifier);
- else fprintf(f, "{NULL, ");
+ if (srna) fprintf(f, "&RNA_%s, ", srna->identifier);
+ else fprintf(f, "NULL, ");
srna = brna->structs.last;
- if (srna) fprintf(f, "&RNA_%s}", srna->identifier);
- else fprintf(f, "NULL}");
+ if (srna) fprintf(f, "&RNA_%s},\n", srna->identifier);
+ else fprintf(f, "NULL},\n");
- fprintf(f, "};\n\n");
+ fprintf(f,
+ "\t.structs_map = NULL,\n"
+ "\t.structs_len = 0,\n"
+ "};\n\n"
+ );
}
static void rna_generate_property_prototypes(BlenderRNA *UNUSED(brna), StructRNA *srna, FILE *f)
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index 3d162137bd1..90b7ffd71bb 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -267,9 +267,10 @@ void rna_PropertyGroup_unregister(Main *UNUSED(bmain), StructRNA *type)
RNA_struct_free(&BLENDER_RNA, type);
}
-StructRNA *rna_PropertyGroup_register(Main *UNUSED(bmain), ReportList *reports, void *data, const char *identifier,
- StructValidateFunc validate, StructCallbackFunc UNUSED(call),
- StructFreeFunc UNUSED(free))
+StructRNA *rna_PropertyGroup_register(
+ Main *UNUSED(bmain), ReportList *reports, void *data, const char *identifier,
+ StructValidateFunc validate, StructCallbackFunc UNUSED(call),
+ StructFreeFunc UNUSED(free))
{
PointerRNA dummyptr;
@@ -394,6 +395,14 @@ static void rna_ID_animation_data_free(ID *id, Main *bmain)
DEG_relations_tag_update(bmain);
}
+#ifdef WITH_PYTHON
+void **rna_ID_instance(PointerRNA *ptr)
+{
+ ID *id = (ID *)ptr->data;
+ return &id->py_instance;
+}
+#endif
+
static void rna_IDPArray_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
IDProperty *prop = (IDProperty *)ptr->data;
@@ -1071,6 +1080,10 @@ static void rna_def_ID(BlenderRNA *brna)
"Tag the ID to update its display data, "
"e.g. when calling :class:`bpy.types.Scene.update`");
RNA_def_enum_flag(func, "refresh", update_flag_items, 0, "", "Type of updates to perform");
+
+#ifdef WITH_PYTHON
+ RNA_def_struct_register_funcs(srna, NULL, NULL, "rna_ID_instance");
+#endif
}
static void rna_def_library(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 8f333b3af15..114ded9b0c0 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -77,6 +77,9 @@ void RNA_init(void)
StructRNA *srna;
PropertyRNA *prop;
+ BLENDER_RNA.structs_map = BLI_ghash_str_new_ex(__func__, 2048);
+ BLENDER_RNA.structs_len = 0;
+
for (srna = BLENDER_RNA.structs.first; srna; srna = srna->cont.next) {
if (!srna->cont.prophash) {
srna->cont.prophash = BLI_ghash_str_new("RNA_init gh");
@@ -87,6 +90,9 @@ void RNA_init(void)
}
}
}
+ BLI_assert(srna->flag & STRUCT_PUBLIC_NAMESPACE);
+ BLI_ghash_insert(BLENDER_RNA.structs_map, (void *)srna->identifier, srna);
+ BLENDER_RNA.structs_len += 1;
}
}
@@ -514,13 +520,7 @@ static const char *rna_ensure_property_name(const PropertyRNA *prop)
StructRNA *RNA_struct_find(const char *identifier)
{
- StructRNA *type;
- if (identifier) {
- for (type = BLENDER_RNA.structs.first; type; type = type->cont.next)
- if (STREQ(type->identifier, identifier))
- return type;
- }
- return NULL;
+ return BLI_ghash_lookup(BLENDER_RNA.structs_map, identifier);
}
const char *RNA_struct_identifier(const StructRNA *type)
@@ -832,6 +832,89 @@ char *RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen, i
return NULL;
}
+/**
+ * Use when registering structs with the #STRUCT_PUBLIC_NAMESPACE flag.
+ */
+bool RNA_struct_available_or_report(ReportList *reports, const char *identifier)
+{
+ const StructRNA *srna_exists = RNA_struct_find(identifier);
+ if (UNLIKELY(srna_exists != NULL)) {
+ /* Use comprehensive string construction since this is such a rare occurrence
+ * and information here may cut down time troubleshooting. */
+ DynStr *dynstr = BLI_dynstr_new();
+ BLI_dynstr_appendf(dynstr, "Type identifier '%s' is already in use: '", identifier);
+ BLI_dynstr_append(dynstr, srna_exists->identifier);
+ int i = 0;
+ if (srna_exists->base) {
+ for (const StructRNA *base = srna_exists->base; base; base = base->base) {
+ BLI_dynstr_append(dynstr, "(");
+ BLI_dynstr_append(dynstr, base->identifier);
+ i += 1;
+ }
+ while (i--) {
+ BLI_dynstr_append(dynstr, ")");
+ }
+ }
+ BLI_dynstr_append(dynstr, "'.");
+ char *result = BLI_dynstr_get_cstring(dynstr);
+ BLI_dynstr_free(dynstr);
+ BKE_report(reports, RPT_ERROR, result);
+ MEM_freeN(result);
+ return false;
+ }
+ else {
+ return true;
+ }
+}
+
+bool RNA_struct_bl_idname_ok_or_report(ReportList *reports, const char *identifier, const char *sep)
+{
+ const int len_sep = strlen(sep);
+ const int len_id = strlen(identifier);
+ const char *p = strstr(identifier, sep);
+ /* TODO: make error, for now warning until add-ons update. */
+#if 1
+ const int report_level = RPT_WARNING;
+ const bool failure = true;
+#else
+ const int report_level = RPT_ERROR;
+ const bool failure = false;
+#endif
+ if (p == NULL || p == identifier || p + len_sep >= identifier + len_id) {
+ BKE_reportf(reports, report_level, "'%s' doesn't contain '%s' with prefix & suffix", identifier, sep);
+ return failure;
+ }
+
+ const char *c, *start, *end, *last;
+ start = identifier;
+ end = p;
+ last = end - 1;
+ for (c = start; c != end; c++) {
+ if (((*c >= 'A' && *c <= 'Z') ||
+ ((c != start) && (*c >= '0' && *c <= '9')) ||
+ ((c != start) && (c != last) && (*c == '_'))) == 0)
+ {
+ BKE_reportf(reports, report_level, "'%s' doesn't have upper case alpha-numeric prefix", identifier);
+ return failure;
+ }
+ }
+
+ start = p + len_sep;
+ end = identifier + len_id;
+ last = end - 1;
+ for (c = start; c != end; c++) {
+ if (((*c >= 'A' && *c <= 'Z') ||
+ (*c >= 'a' && *c <= 'z') ||
+ (*c >= '0' && *c <= '9') ||
+ ((c != start) && (c != last) && (*c == '_'))) == 0)
+ {
+ BKE_reportf(reports, report_level, "'%s' doesn't have an alpha-numeric suffix", identifier);
+ return failure;
+ }
+ }
+ return true;
+}
+
/* Property Information */
const char *RNA_property_identifier(PropertyRNA *prop)
@@ -6720,6 +6803,13 @@ int RNA_function_call_direct_va_lookup(bContext *C, ReportList *reports, Pointer
return 0;
}
+const char *RNA_translate_ui_text(
+ const char *text, const char *text_ctxt, StructRNA *type, PropertyRNA *prop,
+ int translate)
+{
+ return rna_translate_ui_text(text, text_ctxt, type, prop, translate);
+}
+
bool RNA_property_reset(PointerRNA *ptr, PropertyRNA *prop, int index)
{
int len;
diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c
index f49d4717ad6..1f5ddddb74f 100644
--- a/source/blender/makesrna/intern/rna_animation.c
+++ b/source/blender/makesrna/intern/rna_animation.c
@@ -247,8 +247,9 @@ static void rna_KeyingSetInfo_unregister(Main *bmain, StructRNA *type)
ANIM_keyingset_info_unregister(bmain, ksi);
}
-static StructRNA *rna_KeyingSetInfo_register(Main *bmain, ReportList *reports, void *data, const char *identifier,
- StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
+static StructRNA *rna_KeyingSetInfo_register(
+ Main *bmain, ReportList *reports, void *data, const char *identifier,
+ StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
{
KeyingSetInfo dummyksi = {NULL};
KeyingSetInfo *ksi;
@@ -271,9 +272,10 @@ static StructRNA *rna_KeyingSetInfo_register(Main *bmain, ReportList *reports, v
/* check if we have registered this info before, and remove it */
ksi = ANIM_keyingset_info_find_name(dummyksi.idname);
- if (ksi && ksi->ext.srna)
+ if (ksi && ksi->ext.srna) {
rna_KeyingSetInfo_unregister(bmain, ksi->ext.srna);
-
+ }
+
/* create a new KeyingSetInfo type */
ksi = MEM_callocN(sizeof(KeyingSetInfo), "python keying set info");
memcpy(ksi, &dummyksi, sizeof(KeyingSetInfo));
diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c
index 014a08b70ce..a2c5d90b91e 100644
--- a/source/blender/makesrna/intern/rna_armature.c
+++ b/source/blender/makesrna/intern/rna_armature.c
@@ -481,7 +481,7 @@ static int rna_Armature_is_editmode_get(PointerRNA *ptr)
static void rna_Armature_transform(struct bArmature *arm, float *mat)
{
- ED_armature_transform(arm, (float (*)[4])mat);
+ ED_armature_transform(arm, (float (*)[4])mat, true);
}
#else
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 1948f425083..f79ff4486dd 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -94,6 +94,21 @@ EnumPropertyItem rna_enum_brush_vertex_tool_items[] = {
{PAINT_BLEND_BLUR, "BLUR", ICON_BRUSH_BLUR, "Blur", "Blur the color with surrounding values"},
{PAINT_BLEND_LIGHTEN, "LIGHTEN", ICON_BRUSH_LIGHTEN, "Lighten", "Use lighten blending mode while painting"},
{PAINT_BLEND_DARKEN, "DARKEN", ICON_BRUSH_DARKEN, "Darken", "Use darken blending mode while painting"},
+ {PAINT_BLEND_AVERAGE, "AVERAGE", ICON_BRUSH_BLUR, "Average", "Use average blending mode while painting"},
+ {PAINT_BLEND_SMEAR, "SMEAR", ICON_BRUSH_BLUR, "Smear", "Use smear blending mode while painting"},
+ {PAINT_BLEND_COLORDODGE, "COLORDODGE", ICON_BRUSH_BLUR, "Color Dodge", "Use color dodge blending mode while painting" },
+ {PAINT_BLEND_DIFFERENCE, "DIFFERENCE", ICON_BRUSH_BLUR, "Difference", "Use difference blending mode while painting"},
+ {PAINT_BLEND_SCREEN, "SCREEN", ICON_BRUSH_BLUR, "Screen", "Use screen blending mode while painting"},
+ {PAINT_BLEND_HARDLIGHT, "HARDLIGHT", ICON_BRUSH_BLUR, "Hardlight", "Use hardlight blending mode while painting"},
+ {PAINT_BLEND_OVERLAY, "OVERLAY", ICON_BRUSH_BLUR, "Overlay", "Use overlay blending mode while painting"},
+ {PAINT_BLEND_SOFTLIGHT, "SOFTLIGHT", ICON_BRUSH_BLUR, "Softlight", "Use softlight blending mode while painting"},
+ {PAINT_BLEND_EXCLUSION, "EXCLUSION", ICON_BRUSH_BLUR, "Exclusion", "Use exclusion blending mode while painting"},
+ {PAINT_BLEND_LUMINOCITY, "LUMINOCITY", ICON_BRUSH_BLUR, "Luminocity", "Use luminocity blending mode while painting"},
+ {PAINT_BLEND_SATURATION, "SATURATION", ICON_BRUSH_BLUR, "Saturation", "Use saturation blending mode while painting"},
+ {PAINT_BLEND_HUE, "HUE", ICON_BRUSH_BLUR, "Hue", "Use hue blending mode while painting"},
+ {PAINT_BLEND_ALPHA_SUB, "ERASE_ALPHA", 0, "Erase Alpha", "Erase alpha while painting"},
+ {PAINT_BLEND_ALPHA_ADD, "ADD_ALPHA", 0, "Add Alpha", "Add alpha while painting"},
+
{0, NULL, 0, NULL, NULL}
};
@@ -223,11 +238,7 @@ static int rna_SculptToolCapabilities_has_sculpt_plane_get(PointerRNA *ptr)
static int rna_SculptToolCapabilities_has_secondary_color_get(PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
- return ELEM(br->sculpt_tool,
- SCULPT_TOOL_BLOB, SCULPT_TOOL_CLAY, SCULPT_TOOL_CLAY_STRIPS,
- SCULPT_TOOL_CREASE, SCULPT_TOOL_DRAW, SCULPT_TOOL_FILL,
- SCULPT_TOOL_FLATTEN, SCULPT_TOOL_INFLATE, SCULPT_TOOL_PINCH,
- SCULPT_TOOL_SCRAPE);
+ return BKE_brush_sculpt_has_secondary_color(br);
}
static int rna_SculptToolCapabilities_has_smooth_stroke_get(PointerRNA *ptr)
@@ -1121,7 +1132,20 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Blur Mode", "");
RNA_def_property_update(prop, 0, "rna_Brush_update");
+ prop = RNA_def_property(srna, "falloff_angle", PROP_FLOAT, PROP_ANGLE);
+ RNA_def_property_float_sdna(prop, NULL, "falloff_angle");
+ RNA_def_property_range(prop, 0, M_PI / 2);
+ RNA_def_property_ui_text(prop, "Falloff Angle",
+ "Paint most on faces pointing towards the view according to this angle");
+ RNA_def_property_update(prop, 0, "rna_Brush_update");
+
/* flag */
+ /* This is an enum but its unlikely we add other shapes, so expose as a boolean. */
+ prop = RNA_def_property(srna, "use_projected", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "falloff_shape", BRUSH_AIRBRUSH);
+ RNA_def_property_ui_text(prop, "2D Falloff", "Apply brush influence in 2D circle instead of a sphere");
+ RNA_def_property_update(prop, 0, "rna_Brush_update");
+
prop = RNA_def_property(srna, "use_airbrush", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_AIRBRUSH);
RNA_def_property_ui_text(prop, "Airbrush", "Keep applying paint effect while holding mouse (spray)");
@@ -1198,6 +1222,11 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Use Front-Face", "Brush only affects vertexes that face the viewer");
RNA_def_property_update(prop, 0, "rna_Brush_update");
+ prop = RNA_def_property(srna, "use_frontface_falloff", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_FRONTFACE_FALLOFF);
+ RNA_def_property_ui_text(prop, "Use Front-Face Falloff", "Blend brush influence by how much they face the front");
+ RNA_def_property_update(prop, 0, "rna_Brush_update");
+
prop = RNA_def_property(srna, "use_anchor", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_ANCHORED);
RNA_def_property_ui_text(prop, "Anchored", "Keep the brush anchored to the initial location");
@@ -1264,7 +1293,7 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Restore Mesh", "Allow a single dot to be carefully positioned");
RNA_def_property_update(prop, 0, "rna_Brush_update");
- /* only for projection paint, TODO, other paint modes */
+ /* only for projection paint & vertex paint, TODO, other paint modes */
prop = RNA_def_property(srna, "use_alpha", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BRUSH_LOCK_ALPHA);
RNA_def_property_ui_text(prop, "Alpha", "When this is disabled, lock alpha while painting");
diff --git a/source/blender/makesrna/intern/rna_context.c b/source/blender/makesrna/intern/rna_context.c
index a0b46a447ae..5701150b1bf 100644
--- a/source/blender/makesrna/intern/rna_context.c
+++ b/source/blender/makesrna/intern/rna_context.c
@@ -101,6 +101,14 @@ static PointerRNA rna_Context_region_data_get(PointerRNA *ptr)
return PointerRNA_NULL;
}
+static PointerRNA rna_Context_manipulator_group_get(PointerRNA *ptr)
+{
+ bContext *C = (bContext *)ptr->data;
+ PointerRNA newptr;
+ RNA_pointer_create(NULL, &RNA_ManipulatorGroup, CTX_wm_manipulator_group(C), &newptr);
+ return newptr;
+}
+
static PointerRNA rna_Context_main_get(PointerRNA *ptr)
{
bContext *C = (bContext *)ptr->data;
@@ -229,6 +237,11 @@ void RNA_def_context(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "RegionView3D");
RNA_def_property_pointer_funcs(prop, "rna_Context_region_data_get", NULL, NULL, NULL);
+ prop = RNA_def_property(srna, "manipulator_group", PROP_POINTER, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_struct_type(prop, "ManipulatorGroup");
+ RNA_def_property_pointer_funcs(prop, "rna_Context_manipulator_group_get", NULL, NULL, NULL);
+
/* Data */
prop = RNA_def_property(srna, "blend_data", PROP_POINTER, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
diff --git a/source/blender/makesrna/intern/rna_curve_api.c b/source/blender/makesrna/intern/rna_curve_api.c
index 5a123603ed5..b518b0cb5b0 100644
--- a/source/blender/makesrna/intern/rna_curve_api.c
+++ b/source/blender/makesrna/intern/rna_curve_api.c
@@ -45,10 +45,16 @@
#ifdef RNA_RUNTIME
static void rna_Curve_transform(Curve *cu, float *mat, int shape_keys)
{
- BKE_curve_transform(cu, (float (*)[4])mat, shape_keys);
+ BKE_curve_transform(cu, (float (*)[4])mat, shape_keys, true);
DEG_id_tag_update(&cu->id, 0);
}
+
+static void rna_Curve_update_gpu_tag(Curve *cu)
+{
+ BKE_curve_batch_cache_dirty(cu, BKE_CURVE_BATCH_DIRTY_ALL);
+}
+
#else
void RNA_api_curve(StructRNA *srna)
@@ -67,6 +73,8 @@ void RNA_api_curve(StructRNA *srna)
"has had invalid indices corrected (to default 0)");
parm = RNA_def_boolean(func, "result", 0, "Result", "");
RNA_def_function_return(func, parm);
+
+ RNA_def_function(srna, "update_gpu_tag", "rna_Curve_update_gpu_tag");
}
#endif
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index 42c0344f46e..118dd0b15de 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -44,6 +44,8 @@
#include "BLT_translation.h"
+#include "UI_interface.h" /* For things like UI_PRECISION_FLOAT_MAX... */
+
#include "RNA_define.h"
#include "rna_internal.h"
@@ -135,6 +137,38 @@ void rna_freelistN(ListBase *listbase)
listbase->first = listbase->last = NULL;
}
+static void rna_brna_structs_add(BlenderRNA *brna, StructRNA *srna)
+{
+ rna_addtail(&brna->structs, srna);
+ brna->structs_len += 1;
+
+ /* This exception is only needed for pre-processing.
+ * otherwise we don't allow empty names. */
+ if ((srna->flag & STRUCT_PUBLIC_NAMESPACE) &&
+ (srna->identifier[0] != '\0'))
+ {
+ BLI_ghash_insert(brna->structs_map, (void *)srna->identifier, srna);
+ }
+}
+
+#ifdef RNA_RUNTIME
+static void rna_brna_structs_remove_and_free(BlenderRNA *brna, StructRNA *srna)
+{
+ if ((srna->flag & STRUCT_PUBLIC_NAMESPACE) && brna->structs_map) {
+ if (srna->identifier[0] != '\0') {
+ BLI_ghash_remove(brna->structs_map, (void *)srna->identifier, NULL, NULL);
+ }
+ }
+
+ RNA_def_struct_free_pointers(NULL, srna);
+
+ if (srna->flag & STRUCT_RUNTIME) {
+ rna_freelinkN(&brna->structs, srna);
+ }
+ brna->structs_len -= 1;
+}
+#endif
+
StructDefRNA *rna_find_struct_def(StructRNA *srna)
{
StructDefRNA *dsrna;
@@ -534,6 +568,8 @@ BlenderRNA *RNA_create(void)
const char *error_message = NULL;
BLI_listbase_clear(&DefRNA.structs);
+ brna->structs_map = BLI_ghash_str_new_ex(__func__, 2048);
+
DefRNA.error = 0;
DefRNA.preprocess = 1;
@@ -640,10 +676,8 @@ void RNA_struct_free(BlenderRNA *brna, StructRNA *srna)
rna_freelinkN(&srna->functions, func);
}
- RNA_def_struct_free_pointers(srna);
- if (srna->flag & STRUCT_RUNTIME)
- rna_freelinkN(&brna->structs, srna);
+ rna_brna_structs_remove_and_free(brna, srna);
#else
UNUSED_VARS(brna, srna);
#endif
@@ -654,6 +688,9 @@ void RNA_free(BlenderRNA *brna)
StructRNA *srna, *nextsrna;
FunctionRNA *func;
+ BLI_ghash_free(brna->structs_map, NULL, NULL);
+ brna->structs_map = NULL;
+
if (DefRNA.preprocess) {
RNA_define_free(brna);
@@ -730,12 +767,19 @@ StructRNA *RNA_def_struct_ptr(BlenderRNA *brna, const char *identifier, StructRN
BLI_listbase_clear(&srna->functions);
srna->py_type = NULL;
+ srna->base = srnafrom;
+
if (DefRNA.preprocess) {
- srna->base = srnafrom;
dsfrom = rna_find_def_struct(srnafrom);
}
- else
- srna->base = srnafrom;
+ else {
+ if (srnafrom->flag & STRUCT_PUBLIC_NAMESPACE_INHERIT) {
+ srna->flag |= STRUCT_PUBLIC_NAMESPACE | STRUCT_PUBLIC_NAMESPACE_INHERIT;
+ }
+ else {
+ srna->flag &= ~(STRUCT_PUBLIC_NAMESPACE | STRUCT_PUBLIC_NAMESPACE_INHERIT);
+ }
+ }
}
srna->identifier = identifier;
@@ -747,7 +791,11 @@ StructRNA *RNA_def_struct_ptr(BlenderRNA *brna, const char *identifier, StructRN
if (!srnafrom)
srna->icon = ICON_DOT;
- rna_addtail(&brna->structs, srna);
+ if (DefRNA.preprocess) {
+ srna->flag |= STRUCT_PUBLIC_NAMESPACE;
+ }
+
+ rna_brna_structs_add(brna, srna);
if (DefRNA.preprocess) {
ds = MEM_callocN(sizeof(StructDefRNA), "StructDefRNA");
@@ -819,10 +867,8 @@ StructRNA *RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *
if (from) {
/* find struct to derive from */
- for (srnafrom = brna->structs.first; srnafrom; srnafrom = srnafrom->cont.next)
- if (STREQ(srnafrom->identifier, from))
- break;
-
+ /* Inline RNA_struct_find(...) because it wont link from here. */
+ srnafrom = BLI_ghash_lookup(brna->structs_map, from);
if (!srnafrom) {
fprintf(stderr, "%s: struct %s not found to define %s.\n", __func__, from, identifier);
DefRNA.error = 1;
@@ -901,10 +947,7 @@ void RNA_def_struct_nested(BlenderRNA *brna, StructRNA *srna, const char *struct
StructRNA *srnafrom;
/* find struct to derive from */
- for (srnafrom = brna->structs.first; srnafrom; srnafrom = srnafrom->cont.next)
- if (STREQ(srnafrom->identifier, structname))
- break;
-
+ srnafrom = BLI_ghash_lookup(brna->structs_map, structname);
if (!srnafrom) {
fprintf(stderr, "%s: struct %s not found for %s.\n", __func__, structname, srna->identifier);
DefRNA.error = 1;
@@ -965,7 +1008,32 @@ void RNA_def_struct_path_func(StructRNA *srna, const char *path)
if (path) srna->path = (StructPathFunc)path;
}
-void RNA_def_struct_identifier(StructRNA *srna, const char *identifier)
+void RNA_def_struct_identifier(BlenderRNA *brna, StructRNA *srna, const char *identifier)
+{
+ if (DefRNA.preprocess) {
+ fprintf(stderr, "%s: only at runtime.\n", __func__);
+ return;
+ }
+
+ /* Operator registration may set twice, see: operator_properties_init */
+ if (srna->flag & STRUCT_PUBLIC_NAMESPACE) {
+ if (identifier != srna->identifier) {
+ if (srna->identifier[0] != '\0') {
+ BLI_ghash_remove(brna->structs_map, (void *)srna->identifier, NULL, NULL);
+ }
+ if (identifier[0] != '\0') {
+ BLI_ghash_insert(brna->structs_map, (void *)identifier, srna);
+ }
+ }
+ }
+
+ srna->identifier = identifier;
+}
+
+/**
+ * Only used in one case when we name the struct for the purpose of useful error messages.
+ */
+void RNA_def_struct_identifier_no_struct_map(StructRNA *srna, const char *identifier)
{
if (DefRNA.preprocess) {
fprintf(stderr, "%s: only at runtime.\n", __func__);
@@ -1339,13 +1407,13 @@ void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, bool consecutive)
* For ints, whole values are used.
*
* \param precision The number of zeros to show
- * (as a whole number - common range is 1 - 6), see PRECISION_FLOAT_MAX
+ * (as a whole number - common range is 1 - 6), see UI_PRECISION_FLOAT_MAX
*/
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
{
StructRNA *srna = DefRNA.laststruct;
-#ifdef DEBUG
+#ifndef NDEBUG
if (min > max) {
fprintf(stderr, "%s: \"%s.%s\", min > max.\n",
__func__, srna->identifier, prop->identifier);
@@ -1358,8 +1426,8 @@ void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double
DefRNA.error = 1;
}
- if (precision < -1 || precision > 10) {
- fprintf(stderr, "%s: \"%s.%s\", step outside range.\n",
+ if (precision < -1 || precision > UI_PRECISION_FLOAT_MAX) {
+ fprintf(stderr, "%s: \"%s.%s\", precision outside range.\n",
__func__, srna->identifier, prop->identifier);
DefRNA.error = 1;
}
@@ -1381,21 +1449,6 @@ void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double
fprop->softmax = (float)max;
fprop->step = (float)step;
fprop->precision = (int)precision;
-#if 0 /* handy but annoying */
- if (DefRNA.preprocess) {
- /* check we're not over PRECISION_FLOAT_MAX */
- if (fprop->precision > 6) {
- fprintf(stderr, "%s: \"%s.%s\", precision value over maximum.\n",
- __func__, srna->identifier, prop->identifier);
- DefRNA.error = 1;
- }
- else if (fprop->precision < 1) {
- fprintf(stderr, "%s: \"%s.%s\", precision value under minimum.\n",
- __func__, srna->identifier, prop->identifier);
- DefRNA.error = 1;
- }
- }
-#endif
break;
}
default:
@@ -3262,21 +3315,41 @@ void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
/* Memory management */
#ifdef RNA_RUNTIME
-void RNA_def_struct_duplicate_pointers(StructRNA *srna)
+void RNA_def_struct_duplicate_pointers(BlenderRNA *brna, StructRNA *srna)
{
- if (srna->identifier) srna->identifier = BLI_strdup(srna->identifier);
- if (srna->name) srna->name = BLI_strdup(srna->name);
- if (srna->description) srna->description = BLI_strdup(srna->description);
+ if (srna->identifier) {
+ srna->identifier = BLI_strdup(srna->identifier);
+ if (srna->flag & STRUCT_PUBLIC_NAMESPACE) {
+ BLI_ghash_replace_key(brna->structs_map, (void *)srna->identifier);
+ }
+ }
+ if (srna->name) {
+ srna->name = BLI_strdup(srna->name);
+ }
+ if (srna->description) {
+ srna->description = BLI_strdup(srna->description);
+ }
srna->flag |= STRUCT_FREE_POINTERS;
}
-void RNA_def_struct_free_pointers(StructRNA *srna)
+void RNA_def_struct_free_pointers(BlenderRNA *brna, StructRNA *srna)
{
if (srna->flag & STRUCT_FREE_POINTERS) {
- if (srna->identifier) MEM_freeN((void *)srna->identifier);
- if (srna->name) MEM_freeN((void *)srna->name);
- if (srna->description) MEM_freeN((void *)srna->description);
+ if (srna->identifier) {
+ if (srna->flag & STRUCT_PUBLIC_NAMESPACE) {
+ if (brna != NULL) {
+ BLI_ghash_remove(brna->structs_map, (void *)srna->identifier, NULL, NULL);
+ }
+ }
+ MEM_freeN((void *)srna->identifier);
+ }
+ if (srna->name) {
+ MEM_freeN((void *)srna->name);
+ }
+ if (srna->description) {
+ MEM_freeN((void *)srna->description);
+ }
}
}
diff --git a/source/blender/makesrna/intern/rna_depsgraph.c b/source/blender/makesrna/intern/rna_depsgraph.c
index 9ea12e3befa..88a1873c17f 100644
--- a/source/blender/makesrna/intern/rna_depsgraph.c
+++ b/source/blender/makesrna/intern/rna_depsgraph.c
@@ -42,7 +42,6 @@
#include "BLI_iterator.h"
#include "BKE_report.h"
-#include "DNA_object_types.h"
#include "DEG_depsgraph_build.h"
#include "DEG_depsgraph_debug.h"
@@ -131,9 +130,14 @@ static void rna_Depsgraph_debug_graphviz(Depsgraph *graph, const char *filename)
fclose(f);
}
-static void rna_Depsgraph_debug_rebuild(Depsgraph *UNUSED(graph), Main *bmain)
+static void rna_Depsgraph_debug_rebuild(Depsgraph *UNUSED(graph), bContext *C)
{
+ Main *bmain = CTX_data_main(C);
+ EvaluationContext eval_ctx;
Scene *sce;
+
+ CTX_data_eval_ctx(C, &eval_ctx);
+
DEG_relations_tag_update(bmain);
for (sce = bmain->scene.first; sce; sce = sce->id.next) {
DEG_scene_relations_rebuild(bmain, sce);
@@ -261,7 +265,7 @@ static void rna_def_depsgraph_iter(BlenderRNA *brna)
prop = RNA_def_property(srna, "persistent_id", PROP_INT, PROP_NONE);
RNA_def_property_ui_text(prop, "Persistent ID",
"Persistent identifier for inter-frame matching of objects with motion blur");
- RNA_def_property_array(prop, 2*MAX_DUPLI_RECUR);
+ RNA_def_property_array(prop, 2 * MAX_DUPLI_RECUR);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
RNA_def_property_int_funcs(prop, "rna_DepsgraphIter_persistent_id_get", NULL, NULL);
@@ -307,7 +311,7 @@ static void rna_def_depsgraph(BlenderRNA *brna)
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
func = RNA_def_function(srna, "debug_rebuild", "rna_Depsgraph_debug_rebuild");
- RNA_def_function_flag(func, FUNC_USE_MAIN);
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT);
func = RNA_def_function(srna, "debug_stats", "rna_Depsgraph_debug_stats");
RNA_def_function_ui_description(func, "Report the number of elements in the Dependency Graph");
diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c
index 476008f5b04..e951e15ca8c 100644
--- a/source/blender/makesrna/intern/rna_fcurve.c
+++ b/source/blender/makesrna/intern/rna_fcurve.c
@@ -767,6 +767,38 @@ static void rna_FModifierStepped_end_frame_range(PointerRNA *ptr, float *min, fl
*max = MAXFRAMEF;
}
+static void rna_FModifierStepped_frame_start_set(PointerRNA *ptr, float value)
+{
+ FModifier *fcm = (FModifier *)ptr->data;
+ FMod_Stepped *data = fcm->data;
+
+ float prop_clamp_min = -FLT_MAX, prop_clamp_max = FLT_MAX, prop_soft_min, prop_soft_max;
+ rna_FModifierStepped_start_frame_range(ptr, &prop_clamp_min, &prop_clamp_max, &prop_soft_min, &prop_soft_max);
+ value = CLAMPIS(value, prop_clamp_min, prop_clamp_max);
+
+ /* Need to set both step-data's start/end and the start/end on the base-data,
+ * or else Restrict-Range doesn't work due to RNA-property shadowing (T52009)
+ */
+ data->start_frame = value;
+ fcm->sfra = value;
+}
+
+static void rna_FModifierStepped_frame_end_set(PointerRNA *ptr, float value)
+{
+ FModifier *fcm = (FModifier *)ptr->data;
+ FMod_Stepped *data = fcm->data;
+
+ float prop_clamp_min = -FLT_MAX, prop_clamp_max = FLT_MAX, prop_soft_min, prop_soft_max;
+ rna_FModifierStepped_end_frame_range(ptr, &prop_clamp_min, &prop_clamp_max, &prop_soft_min, &prop_soft_max);
+ value = CLAMPIS(value, prop_clamp_min, prop_clamp_max);
+
+ /* Need to set both step-data's start/end and the start/end on the base-data,
+ * or else Restrict-Range doesn't work due to RNA-property shadowing (T52009)
+ */
+ data->end_frame = value;
+ fcm->efra = value;
+}
+
static BezTriple *rna_FKeyframe_points_insert(FCurve *fcu, float frame, float value, int keyframe_type, int flag)
{
int index = insert_vert_fcurve(fcu, frame, value, (char)keyframe_type, flag | INSERTKEY_NO_USERPREF);
@@ -1286,13 +1318,13 @@ static void rna_def_fmodifier_stepped(BlenderRNA *brna)
prop = RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "start_frame");
- RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierStepped_start_frame_range");
+ RNA_def_property_float_funcs(prop, NULL, "rna_FModifierStepped_frame_start_set", "rna_FModifierStepped_start_frame_range");
RNA_def_property_ui_text(prop, "Start Frame", "Frame that modifier's influence starts (if applicable)");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
prop = RNA_def_property(srna, "frame_end", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "end_frame");
- RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierStepped_end_frame_range");
+ RNA_def_property_float_funcs(prop, NULL, "rna_FModifierStepped_frame_end_set", "rna_FModifierStepped_end_frame_range");
RNA_def_property_ui_text(prop, "End Frame", "Frame that modifier's influence ends (if applicable)");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
}
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index 6e0d6ad2bcd..79e1e95b27a 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -74,7 +74,7 @@ static void rna_GPencil_editmode_update(Main *UNUSED(bmain), Scene *UNUSED(scene
{
/* Notify all places where GPencil data lives that the editing state is different */
WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
- WM_main_add_notifier(NC_SCENE | ND_MODE, NULL);
+ WM_main_add_notifier(NC_SCENE | ND_MODE | NC_MOVIECLIP, NULL);
}
static void rna_GPencil_onion_skinning_update(Main *bmain, Scene *scene, PointerRNA *ptr)
diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c
index 686e830f1ba..b51a4258a2d 100644
--- a/source/blender/makesrna/intern/rna_image.c
+++ b/source/blender/makesrna/intern/rna_image.c
@@ -193,6 +193,8 @@ static char *rna_ImageUser_path(PointerRNA *ptr)
{
return rna_Node_ImageUser_path(ptr);
}
+ default:
+ break;
}
}
diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c
index 936674a1e96..7f0ddf04724 100644
--- a/source/blender/makesrna/intern/rna_image_api.c
+++ b/source/blender/makesrna/intern/rna_image_api.c
@@ -64,7 +64,7 @@
static void rna_ImagePackedFile_save(ImagePackedFile *imapf, ReportList *reports)
{
if (writePackedFile(reports, imapf->filepath, imapf->packedfile, 0) != RET_OK) {
- BKE_reportf(reports, RPT_ERROR, "Image could not save packed file to '%s'",
+ BKE_reportf(reports, RPT_ERROR, "Could not save packed file to disk as '%s'",
imapf->filepath);
}
}
@@ -290,7 +290,7 @@ static void rna_Image_filepath_from_user(Image *image, ImageUser *image_user, ch
static void rna_Image_buffers_free(Image *image)
{
- BKE_image_free_buffers(image);
+ BKE_image_free_buffers_ex(image, true);
}
#else
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index 7b8073d80b8..00b1b53ad71 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -42,6 +42,7 @@ struct Mesh;
struct Object;
struct ReportList;
struct SDNA;
+struct SceneLayer;
/* Data structures used during define */
@@ -220,6 +221,7 @@ void rna_ID_name_set(struct PointerRNA *ptr, const char *value);
struct StructRNA *rna_ID_refine(struct PointerRNA *ptr);
struct IDProperty *rna_ID_idprops(struct PointerRNA *ptr, bool create);
void rna_ID_fake_user_set(struct PointerRNA *ptr, int value);
+void **rna_ID_instance(PointerRNA *ptr);
struct IDProperty *rna_PropertyGroup_idprops(struct PointerRNA *ptr, bool create);
void rna_PropertyGroup_unregister(struct Main *bmain, struct StructRNA *type);
struct StructRNA *rna_PropertyGroup_register(struct Main *bmain, struct ReportList *reports, void *data,
@@ -409,7 +411,7 @@ PointerRNA rna_pointer_inherit_refine(struct PointerRNA *ptr, struct StructRNA *
int rna_parameter_size(struct PropertyRNA *parm);
struct Mesh *rna_Main_meshes_new_from_object(
- struct Main *bmain, struct ReportList *reports, struct Scene *sce,
+ struct Main *bmain, struct ReportList *reports, struct Scene *sce, struct SceneLayer *sl,
struct Object *ob, int apply_modifiers, int settings, int calc_tessface, int calc_undeformed);
/* XXX, these should not need to be defined here~! */
@@ -420,6 +422,8 @@ void rna_mtex_texture_slots_clear(struct ID *self, struct bContext *C, struct Re
int rna_IDMaterials_assign_int(struct PointerRNA *ptr, int key, const struct PointerRNA *assign_ptr);
+const char *rna_translate_ui_text(
+ const char *text, const char *text_ctxt, struct StructRNA *type, struct PropertyRNA *prop, int translate);
/* Internal functions that cycles uses so we need to declare (tsk tsk) */
void rna_RenderLayer_rect_set(PointerRNA *ptr, const float *values);
diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h
index c412d110e5e..cc6443e2154 100644
--- a/source/blender/makesrna/intern/rna_internal_types.h
+++ b/source/blender/makesrna/intern/rna_internal_types.h
@@ -404,6 +404,11 @@ struct StructRNA {
struct BlenderRNA {
ListBase structs;
+ /* A map of structs: {StructRNA.identifier -> StructRNA}
+ * These are ensured to have unique names (with STRUCT_PUBLIC_NAMESPACE enabled). */
+ struct GHash *structs_map;
+ /* Needed because types with an empty identifier aren't included in 'structs_map'. */
+ unsigned int structs_len;
};
#define CONTAINER_RNA_ID(cont) (*(const char **)(((ContainerRNA *)(cont))+1))
diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c
index 5cf7e7238e0..f28c02bf20d 100644
--- a/source/blender/makesrna/intern/rna_key.c
+++ b/source/blender/makesrna/intern/rna_key.c
@@ -179,6 +179,8 @@ static Mesh *rna_KeyBlock_normals_get_mesh(PointerRNA *ptr, ID *id)
return ob->data;
}
}
+ default:
+ break;
}
}
diff --git a/source/blender/makesrna/intern/rna_lamp.c b/source/blender/makesrna/intern/rna_lamp.c
index 76f5044a95c..e40183e40b5 100644
--- a/source/blender/makesrna/intern/rna_lamp.c
+++ b/source/blender/makesrna/intern/rna_lamp.c
@@ -476,7 +476,7 @@ static void rna_def_lamp_falloff(StructRNA *srna)
RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
}
-static void rna_def_lamp_shadow(StructRNA *srna, int spot, int area)
+static void rna_def_lamp_shadow(StructRNA *srna, int spot, int area, int sun)
{
PropertyRNA *prop;
@@ -587,7 +587,8 @@ static void rna_def_lamp_shadow(StructRNA *srna, int spot, int area)
prop = RNA_def_property(srna, "shadow_buffer_bias", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "bias");
- RNA_def_property_range(prop, 0.001f, 5.0f);
+ RNA_def_property_range(prop, 0.001f, 9999.0f);
+ RNA_def_property_ui_range(prop, 0.001f, 5.0f, 1.0, 3);
RNA_def_property_ui_text(prop, "Shadow Buffer Bias", "Bias for reducing self shadowing");
RNA_def_property_update(prop, 0, "rna_Lamp_update");
@@ -697,6 +698,67 @@ static void rna_def_lamp_shadow(StructRNA *srna, int spot, int area)
RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_LAYER_SHADOW);
RNA_def_property_ui_text(prop, "Shadow Layer", "Objects on the same layers only cast shadows");
RNA_def_property_update(prop, 0, "rna_Lamp_update");
+
+ /* Eevee */
+ prop = RNA_def_property(srna, "use_contact_shadow", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_SHAD_CONTACT);
+ RNA_def_property_ui_text(prop, "Contact Shadow", "Use screen space raytracing to have correct shadowing "
+ "near occluder, or for small features that does not appear "
+ "in shadow maps");
+ RNA_def_property_update(prop, 0, "rna_Lamp_update");
+
+ prop = RNA_def_property(srna, "contact_shadow_distance", PROP_FLOAT, PROP_DISTANCE);
+ RNA_def_property_float_sdna(prop, NULL, "contact_dist");
+ RNA_def_property_range(prop, 0.0f, 9999.0f);
+ RNA_def_property_ui_text(prop, "Contact Shadow Distance", "World space distance in which to search for "
+ "screen space occluder");
+ RNA_def_property_update(prop, 0, "rna_Lamp_update");
+
+ prop = RNA_def_property(srna, "contact_shadow_bias", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "contact_bias");
+ RNA_def_property_range(prop, 0.001f, 9999.0f);
+ RNA_def_property_ui_range(prop, 0.001f, 5.0f, 1.0, 3);
+ RNA_def_property_ui_text(prop, "Contact Shadow Bias", "Bias to avoid self shadowing");
+ RNA_def_property_update(prop, 0, "rna_Lamp_update");
+
+ prop = RNA_def_property(srna, "contact_shadow_soft_size", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "contact_spread");
+ RNA_def_property_range(prop, 0.0f, 9999.0f);
+ RNA_def_property_ui_text(prop, "Contact Shadow Soft", "Control how soft the contact shadows will be");
+ RNA_def_property_update(prop, 0, "rna_Lamp_update");
+
+ prop = RNA_def_property(srna, "contact_shadow_thickness", PROP_FLOAT, PROP_DISTANCE);
+ RNA_def_property_float_sdna(prop, NULL, "contact_thickness");
+ RNA_def_property_range(prop, 0.0f, 9999.0f);
+ RNA_def_property_ui_range(prop, 0, 100, 0.1, 3);
+ RNA_def_property_ui_text(prop, "Contact Shadow Thickness", "Pixel thickness used to detect occlusion");
+ RNA_def_property_update(prop, 0, "rna_Lamp_update");
+
+ if (sun) {
+ prop = RNA_def_property(srna, "shadow_cascade_max_distance", PROP_FLOAT, PROP_DISTANCE);
+ RNA_def_property_float_sdna(prop, NULL, "cascade_max_dist");
+ RNA_def_property_range(prop, 0.0f, 9999.0f);
+ RNA_def_property_ui_text(prop, "Cascade Max Distance", "End distance of the cascaded shadow map (only in perspective view)");
+ RNA_def_property_update(prop, 0, "rna_Lamp_update");
+
+ prop = RNA_def_property(srna, "shadow_cascade_count", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "cascade_count");
+ RNA_def_property_range(prop, 1, 4);
+ RNA_def_property_ui_text(prop, "Cascade Count", "Number of texture used by the cascaded shadow map");
+ RNA_def_property_update(prop, 0, "rna_Lamp_update");
+
+ prop = RNA_def_property(srna, "shadow_cascade_exponent", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "cascade_exponent");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Exponential Distribution", "Higher value increase resolution towards the viewpoint");
+ RNA_def_property_update(prop, 0, "rna_Lamp_update");
+
+ prop = RNA_def_property(srna, "shadow_cascade_fade", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "cascade_fade");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Cascade Fade", "How smooth is the transition between each cascade");
+ RNA_def_property_update(prop, 0, "rna_Lamp_update");
+ }
}
static void rna_def_point_lamp(BlenderRNA *brna)
@@ -709,7 +771,7 @@ static void rna_def_point_lamp(BlenderRNA *brna)
RNA_def_struct_ui_icon(srna, ICON_LAMP_POINT);
rna_def_lamp_falloff(srna);
- rna_def_lamp_shadow(srna, 0, 0);
+ rna_def_lamp_shadow(srna, 0, 0, 0);
}
static void rna_def_area_lamp(BlenderRNA *brna)
@@ -728,7 +790,7 @@ static void rna_def_area_lamp(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "Area Lamp", "Directional area lamp");
RNA_def_struct_ui_icon(srna, ICON_LAMP_AREA);
- rna_def_lamp_shadow(srna, 0, 1);
+ rna_def_lamp_shadow(srna, 0, 1, 0);
rna_def_lamp_falloff(srna);
prop = RNA_def_property(srna, "use_umbra", PROP_BOOLEAN, PROP_NONE);
@@ -785,7 +847,7 @@ static void rna_def_spot_lamp(BlenderRNA *brna)
RNA_def_struct_ui_icon(srna, ICON_LAMP_SPOT);
rna_def_lamp_falloff(srna);
- rna_def_lamp_shadow(srna, 1, 0);
+ rna_def_lamp_shadow(srna, 1, 0, 0);
prop = RNA_def_property(srna, "use_square", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_SQUARE);
@@ -838,7 +900,7 @@ static void rna_def_sun_lamp(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "Sun Lamp", "Constant direction parallel ray lamp");
RNA_def_struct_ui_icon(srna, ICON_LAMP_SUN);
- rna_def_lamp_shadow(srna, 0, 0);
+ rna_def_lamp_shadow(srna, 0, 0, 1);
/* sky */
prop = RNA_def_property(srna, "sky", PROP_POINTER, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_lattice_api.c b/source/blender/makesrna/intern/rna_lattice_api.c
index 4784332db3f..5637f8d9248 100644
--- a/source/blender/makesrna/intern/rna_lattice_api.c
+++ b/source/blender/makesrna/intern/rna_lattice_api.c
@@ -47,6 +47,12 @@ static void rna_Lattice_transform(Lattice *lt, float *mat, int shape_keys)
DEG_id_tag_update(&lt->id, 0);
}
+
+static void rna_Lattice_update_gpu_tag(Lattice *lt)
+{
+ BKE_lattice_batch_cache_dirty(lt, BKE_LATTICE_BATCH_DIRTY_ALL);
+}
+
#else
void RNA_api_lattice(StructRNA *srna)
@@ -59,6 +65,8 @@ void RNA_api_lattice(StructRNA *srna)
parm = RNA_def_float_matrix(func, "matrix", 4, 4, NULL, 0.0f, 0.0f, "", "Matrix", 0.0f, 0.0f);
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
RNA_def_boolean(func, "shape_keys", 0, "", "Transform Shape Keys");
+
+ RNA_def_function(srna, "update_gpu_tag", "rna_Lattice_update_gpu_tag");
}
#endif
diff --git a/source/blender/makesrna/intern/rna_lightprobe.c b/source/blender/makesrna/intern/rna_lightprobe.c
index a628dade59b..448d847a959 100644
--- a/source/blender/makesrna/intern/rna_lightprobe.c
+++ b/source/blender/makesrna/intern/rna_lightprobe.c
@@ -37,8 +37,6 @@
#ifdef RNA_RUNTIME
-#include "DNA_object_types.h"
-
#include "MEM_guardedalloc.h"
#include "BKE_main.h"
@@ -47,7 +45,6 @@
#include "DNA_object_types.h"
#include "WM_api.h"
-#include "WM_types.h"
static void rna_LightProbe_recalc(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c
index 5b898d7fd40..c8c1c7be280 100644
--- a/source/blender/makesrna/intern/rna_main_api.c
+++ b/source/blender/makesrna/intern/rna_main_api.c
@@ -129,7 +129,8 @@ static void rna_idname_validate(const char *name, char *r_name)
}
-static void rna_Main_ID_remove(Main *bmain, ReportList *reports, PointerRNA *id_ptr, int do_unlink)
+static void rna_Main_ID_remove(Main *bmain, ReportList *reports, PointerRNA *id_ptr,
+ int do_unlink, int do_id_user, int do_ui_user)
{
ID *id = id_ptr->data;
if (do_unlink) {
@@ -137,7 +138,7 @@ static void rna_Main_ID_remove(Main *bmain, ReportList *reports, PointerRNA *id_
RNA_POINTER_INVALIDATE(id_ptr);
}
else if (ID_REAL_USERS(id) <= 0) {
- BKE_libblock_free(bmain, id);
+ BKE_libblock_free_ex(bmain, id, do_id_user, do_ui_user);
RNA_POINTER_INVALIDATE(id_ptr);
}
else {
@@ -191,7 +192,7 @@ static void rna_Main_scenes_remove(Main *bmain, bContext *C, ReportList *reports
}
}
- rna_Main_ID_remove(bmain, reports, scene_ptr, do_unlink);
+ rna_Main_ID_remove(bmain, reports, scene_ptr, do_unlink, true, true);
}
else {
BKE_reportf(reports, RPT_ERROR, "Scene '%s' is the last, cannot be removed", scene->id.name + 2);
@@ -299,9 +300,15 @@ static Mesh *rna_Main_meshes_new(Main *bmain, const char *name)
/* copied from Mesh_getFromObject and adapted to RNA interface */
/* settings: 1 - preview, 2 - render */
Mesh *rna_Main_meshes_new_from_object(
- Main *bmain, ReportList *reports, Scene *sce,
+ Main *bmain, ReportList *reports, Scene *sce, SceneLayer *sl,
Object *ob, int apply_modifiers, int settings, int calc_tessface, int calc_undeformed)
{
+ EvaluationContext eval_ctx;
+
+ DEG_evaluation_context_init(&eval_ctx, settings);
+ eval_ctx.ctime = (float)sce->r.cfra + sce->r.subframe;
+ eval_ctx.scene_layer = sl;
+
switch (ob->type) {
case OB_FONT:
case OB_CURVE:
@@ -314,7 +321,7 @@ Mesh *rna_Main_meshes_new_from_object(
return NULL;
}
- return BKE_mesh_new_from_object(bmain, sce, ob, apply_modifiers, settings, calc_tessface, calc_undeformed);
+ return BKE_mesh_new_from_object(&eval_ctx, bmain, sce, ob, apply_modifiers, settings, calc_tessface, calc_undeformed);
}
static Lamp *rna_Main_lamps_new(Main *bmain, const char *name, int type)
@@ -680,6 +687,10 @@ void RNA_def_main_cameras(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_boolean(func, "do_unlink", true, "",
"Unlink all usages of this camera before deleting it "
"(WARNING: will also delete objects instancing that camera data)");
+ RNA_def_boolean(func, "do_id_user", true, "",
+ "Decrement user counter of all datablocks used by this camera");
+ RNA_def_boolean(func, "do_ui_user", true, "",
+ "Make sure interface does not reference this camera");
func = RNA_def_function(srna, "tag", "rna_Main_cameras_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -758,6 +769,10 @@ void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
RNA_def_boolean(func, "do_unlink", true, "", "Unlink all usages of this object before deleting it");
+ RNA_def_boolean(func, "do_id_user", true, "",
+ "Decrement user counter of all datablocks used by this object");
+ RNA_def_boolean(func, "do_ui_user", true, "",
+ "Make sure interface does not reference this object");
func = RNA_def_function(srna, "tag", "rna_Main_objects_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -795,6 +810,10 @@ void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
RNA_def_boolean(func, "do_unlink", true, "", "Unlink all usages of this material before deleting it");
+ RNA_def_boolean(func, "do_id_user", true, "",
+ "Decrement user counter of all datablocks used by this material");
+ RNA_def_boolean(func, "do_ui_user", true, "",
+ "Make sure interface does not reference this material");
func = RNA_def_function(srna, "tag", "rna_Main_materials_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -839,6 +858,10 @@ void RNA_def_main_node_groups(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
RNA_def_boolean(func, "do_unlink", true, "", "Unlink all usages of this node tree before deleting it");
+ RNA_def_boolean(func, "do_id_user", true, "",
+ "Decrement user counter of all datablocks used by this node tree");
+ RNA_def_boolean(func, "do_ui_user", true, "",
+ "Make sure interface does not reference this node tree");
func = RNA_def_function(srna, "tag", "rna_Main_node_groups_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -879,6 +902,8 @@ void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene within which to evaluate modifiers");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ parm = RNA_def_pointer(func, "scene_layer", "SceneLayer", "", "Scene layer within which to evaluate modifiers");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
parm = RNA_def_pointer(func, "object", "Object", "", "Object to create mesh from");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
parm = RNA_def_boolean(func, "apply_modifiers", 0, "", "Apply modifiers");
@@ -900,6 +925,10 @@ void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_boolean(func, "do_unlink", true, "",
"Unlink all usages of this mesh before deleting it "
"(WARNING: will also delete objects instancing that mesh data)");
+ RNA_def_boolean(func, "do_id_user", true, "",
+ "Decrement user counter of all datablocks used by this mesh data");
+ RNA_def_boolean(func, "do_ui_user", true, "",
+ "Make sure interface does not reference this mesh data");
func = RNA_def_function(srna, "tag", "rna_Main_meshes_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -940,6 +969,10 @@ void RNA_def_main_lamps(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_boolean(func, "do_unlink", true, "",
"Unlink all usages of this lamp before deleting it "
"(WARNING: will also delete objects instancing that lamp data)");
+ RNA_def_boolean(func, "do_id_user", true, "",
+ "Decrement user counter of all datablocks used by this lamp data");
+ RNA_def_boolean(func, "do_ui_user", true, "",
+ "Make sure interface does not reference this lamp data");
func = RNA_def_function(srna, "tag", "rna_Main_lamps_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -1056,6 +1089,10 @@ void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
RNA_def_boolean(func, "do_unlink", true, "", "Unlink all usages of this image before deleting it");
+ RNA_def_boolean(func, "do_id_user", true, "",
+ "Decrement user counter of all datablocks used by this image");
+ RNA_def_boolean(func, "do_ui_user", true, "",
+ "Make sure interface does not reference this image");
func = RNA_def_function(srna, "tag", "rna_Main_images_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -1095,6 +1132,10 @@ void RNA_def_main_lattices(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_boolean(func, "do_unlink", true, "",
"Unlink all usages of this lattice before deleting it "
"(WARNING: will also delete objects instancing that lattice data)");
+ RNA_def_boolean(func, "do_id_user", true, "",
+ "Decrement user counter of all datablocks used by this lattice data");
+ RNA_def_boolean(func, "do_ui_user", true, "",
+ "Make sure interface does not reference this lattice data");
func = RNA_def_function(srna, "tag", "rna_Main_lattices_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -1135,6 +1176,10 @@ void RNA_def_main_curves(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_boolean(func, "do_unlink", true, "",
"Unlink all usages of this curve before deleting it "
"(WARNING: will also delete objects instancing that curve data)");
+ RNA_def_boolean(func, "do_id_user", true, "",
+ "Decrement user counter of all datablocks used by this curve data");
+ RNA_def_boolean(func, "do_ui_user", true, "",
+ "Make sure interface does not reference this curve data");
func = RNA_def_function(srna, "tag", "rna_Main_curves_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -1173,6 +1218,10 @@ void RNA_def_main_metaballs(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_boolean(func, "do_unlink", true, "",
"Unlink all usages of this metaball before deleting it "
"(WARNING: will also delete objects instancing that metaball data)");
+ RNA_def_boolean(func, "do_id_user", true, "",
+ "Decrement user counter of all datablocks used by this metaball data");
+ RNA_def_boolean(func, "do_ui_user", true, "",
+ "Make sure interface does not reference this metaball data");
func = RNA_def_function(srna, "tag", "rna_Main_metaballs_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -1211,6 +1260,10 @@ void RNA_def_main_fonts(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
RNA_def_boolean(func, "do_unlink", true, "", "Unlink all usages of this font before deleting it");
+ RNA_def_boolean(func, "do_id_user", true, "",
+ "Decrement user counter of all datablocks used by this font");
+ RNA_def_boolean(func, "do_ui_user", true, "",
+ "Make sure interface does not reference this font");
func = RNA_def_function(srna, "tag", "rna_Main_fonts_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -1249,6 +1302,10 @@ void RNA_def_main_textures(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
RNA_def_boolean(func, "do_unlink", true, "", "Unlink all usages of this texture before deleting it");
+ RNA_def_boolean(func, "do_id_user", true, "",
+ "Decrement user counter of all datablocks used by this texture");
+ RNA_def_boolean(func, "do_ui_user", true, "",
+ "Make sure interface does not reference this texture");
func = RNA_def_function(srna, "tag", "rna_Main_textures_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -1286,6 +1343,10 @@ void RNA_def_main_brushes(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
RNA_def_boolean(func, "do_unlink", true, "", "Unlink all usages of this brush before deleting it");
+ RNA_def_boolean(func, "do_id_user", true, "",
+ "Decrement user counter of all datablocks used by this brush");
+ RNA_def_boolean(func, "do_ui_user", true, "",
+ "Make sure interface does not reference this brush");
func = RNA_def_function(srna, "tag", "rna_Main_brushes_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -1323,6 +1384,10 @@ void RNA_def_main_worlds(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
RNA_def_boolean(func, "do_unlink", true, "", "Unlink all usages of this world before deleting it");
+ RNA_def_boolean(func, "do_id_user", true, "",
+ "Decrement user counter of all datablocks used by this world");
+ RNA_def_boolean(func, "do_ui_user", true, "",
+ "Make sure interface does not reference this world");
func = RNA_def_function(srna, "tag", "rna_Main_worlds_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -1360,6 +1425,10 @@ void RNA_def_main_groups(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
RNA_def_boolean(func, "do_unlink", true, "", "Unlink all usages of this group before deleting it");
+ RNA_def_boolean(func, "do_id_user", true, "",
+ "Decrement user counter of all datablocks used by this group");
+ RNA_def_boolean(func, "do_ui_user", true, "",
+ "Make sure interface does not reference this group");
func = RNA_def_function(srna, "tag", "rna_Main_groups_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -1399,6 +1468,10 @@ void RNA_def_main_speakers(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_boolean(func, "do_unlink", true, "",
"Unlink all usages of this speaker before deleting it "
"(WARNING: will also delete objects instancing that speaker data)");
+ RNA_def_boolean(func, "do_id_user", true, "",
+ "Decrement user counter of all datablocks used by this speaker data");
+ RNA_def_boolean(func, "do_ui_user", true, "",
+ "Make sure interface does not reference this speaker data");
func = RNA_def_function(srna, "tag", "rna_Main_speakers_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -1436,6 +1509,10 @@ void RNA_def_main_texts(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
RNA_def_boolean(func, "do_unlink", true, "", "Unlink all usages of this text before deleting it");
+ RNA_def_boolean(func, "do_id_user", true, "",
+ "Decrement user counter of all datablocks used by this text");
+ RNA_def_boolean(func, "do_ui_user", true, "",
+ "Make sure interface does not reference this text");
/* load func */
func = RNA_def_function(srna, "load", "rna_Main_texts_load");
@@ -1486,6 +1563,10 @@ void RNA_def_main_sounds(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
RNA_def_boolean(func, "do_unlink", true, "", "Unlink all usages of this sound before deleting it");
+ RNA_def_boolean(func, "do_id_user", true, "",
+ "Decrement user counter of all datablocks used by this sound");
+ RNA_def_boolean(func, "do_ui_user", true, "",
+ "Make sure interface does not reference this sound");
func = RNA_def_function(srna, "tag", "rna_Main_sounds_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -1525,6 +1606,10 @@ void RNA_def_main_armatures(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_boolean(func, "do_unlink", true, "",
"Unlink all usages of this armature before deleting it "
"(WARNING: will also delete objects instancing that armature data)");
+ RNA_def_boolean(func, "do_id_user", true, "",
+ "Decrement user counter of all datablocks used by this armature data");
+ RNA_def_boolean(func, "do_ui_user", true, "",
+ "Make sure interface does not reference this armature data");
func = RNA_def_function(srna, "tag", "rna_Main_armatures_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -1561,6 +1646,10 @@ void RNA_def_main_actions(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
RNA_def_boolean(func, "do_unlink", true, "", "Unlink all usages of this action before deleting it");
+ RNA_def_boolean(func, "do_id_user", true, "",
+ "Decrement user counter of all datablocks used by this action");
+ RNA_def_boolean(func, "do_ui_user", true, "",
+ "Make sure interface does not reference this action");
func = RNA_def_function(srna, "tag", "rna_Main_actions_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -1597,6 +1686,10 @@ void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
RNA_def_boolean(func, "do_unlink", true, "", "Unlink all usages of those particle settings before deleting them");
+ RNA_def_boolean(func, "do_id_user", true, "",
+ "Decrement user counter of all datablocks used by this particle settings");
+ RNA_def_boolean(func, "do_ui_user", true, "",
+ "Make sure interface does not reference this particle settings");
func = RNA_def_function(srna, "tag", "rna_Main_particles_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -1634,6 +1727,10 @@ void RNA_def_main_palettes(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
RNA_def_boolean(func, "do_unlink", true, "", "Unlink all usages of this palette before deleting it");
+ RNA_def_boolean(func, "do_id_user", true, "",
+ "Decrement user counter of all datablocks used by this palette");
+ RNA_def_boolean(func, "do_ui_user", true, "",
+ "Make sure interface does not reference this palette");
func = RNA_def_function(srna, "tag", "rna_Main_palettes_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -1714,6 +1811,10 @@ void RNA_def_main_gpencil(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
RNA_def_boolean(func, "do_unlink", true, "", "Unlink all usages of this grease pencil before deleting it");
+ RNA_def_boolean(func, "do_id_user", true, "",
+ "Decrement user counter of all datablocks used by this grease pencil");
+ RNA_def_boolean(func, "do_ui_user", true, "",
+ "Make sure interface does not reference this grease pencil");
prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
@@ -1743,6 +1844,10 @@ void RNA_def_main_movieclips(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
RNA_def_boolean(func, "do_unlink", true, "", "Unlink all usages of this movie clip before deleting it");
+ RNA_def_boolean(func, "do_id_user", true, "",
+ "Decrement user counter of all datablocks used by this movie clip");
+ RNA_def_boolean(func, "do_ui_user", true, "",
+ "Make sure interface does not reference this movie clip");
/* load func */
func = RNA_def_function(srna, "load", "rna_Main_movieclip_load");
@@ -1795,6 +1900,10 @@ void RNA_def_main_masks(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
RNA_def_boolean(func, "do_unlink", true, "", "Unlink all usages of this mask before deleting it");
+ RNA_def_boolean(func, "do_id_user", true, "",
+ "Decrement user counter of all datablocks used by this mask");
+ RNA_def_boolean(func, "do_ui_user", true, "",
+ "Make sure interface does not reference this mask");
prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
@@ -1832,6 +1941,10 @@ void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
RNA_def_boolean(func, "do_unlink", true, "", "Unlink all usages of this line style before deleting it");
+ RNA_def_boolean(func, "do_id_user", true, "",
+ "Decrement user counter of all datablocks used by this line style");
+ RNA_def_boolean(func, "do_ui_user", true, "",
+ "Make sure interface does not reference this line style");
prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
@@ -1888,6 +2001,10 @@ void RNA_def_main_lightprobes(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_boolean(func, "do_unlink", true, "",
"Unlink all usages of this probe before deleting it "
"(WARNING: will also delete objects instancing that light probe data)");
+ RNA_def_boolean(func, "do_id_user", true, "",
+ "Decrement user counter of all datablocks used by this light probe");
+ RNA_def_boolean(func, "do_ui_user", true, "",
+ "Make sure interface does not reference this light probe");
func = RNA_def_function(srna, "tag", "rna_Main_lightprobes_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c
index e60832d86e6..c31b70c57ed 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -1805,6 +1805,24 @@ void RNA_def_material(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}
};
+ static EnumPropertyItem prop_eevee_blend_items[] = {
+ {MA_BM_SOLID, "OPAQUE", 0, "Opaque", "Render surface without transparency"},
+ {MA_BM_ADD, "ADD", 0, "Additive", "Render surface and blend the result with additive blending"},
+ {MA_BM_MULTIPLY, "MULTIPLY", 0, "Multiply", "Render surface and blend the result with multiplicative blending"},
+ {MA_BM_CLIP, "CLIP", 0, "Alpha Clip", "Use the alpha threshold to clip the visibility (binary visibility)"},
+ {MA_BM_HASHED, "HASHED", 0, "Alpha Hashed", "Use noise to dither the binary visibility (works well with multi-samples)"},
+ {MA_BM_BLEND, "BLEND", 0, "Alpha Blend", "Render polygon transparent, depending on alpha channel of the texture"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ static EnumPropertyItem prop_eevee_blend_shadow_items[] = {
+ {MA_BS_NONE, "NONE", 0, "None", "Material will cast no shadow"},
+ {MA_BS_SOLID, "OPAQUE", 0, "Opaque", "Material will cast shadows without transparency"},
+ {MA_BS_CLIP, "CLIP", 0, "Clip", "Use the alpha threshold to clip the visibility (binary visibility)"},
+ {MA_BS_HASHED, "HASHED", 0, "Hashed", "Use noise to dither the binary visibility and use filtering to reduce the noise"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
srna = RNA_def_struct(brna, "Material", "ID");
RNA_def_struct_ui_text(srna, "Material",
"Material data-block to define the appearance of geometric objects for rendering");
@@ -1827,7 +1845,42 @@ void RNA_def_material(BlenderRNA *brna)
RNA_def_property_enum_items(prop, transparency_items);
RNA_def_property_ui_text(prop, "Transparency Method", "Method to use for rendering transparency");
RNA_def_property_update(prop, 0, "rna_Material_update");
-
+
+ /* Blending (only Eevee for now) */
+ prop = RNA_def_property(srna, "blend_method", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, prop_eevee_blend_items);
+ RNA_def_property_ui_text(prop, "Blend Mode", "Blend Mode for Transparent Faces");
+ RNA_def_property_update(prop, 0, "rna_Material_draw_update");
+
+ prop = RNA_def_property(srna, "transparent_shadow_method", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "blend_shadow");
+ RNA_def_property_enum_items(prop, prop_eevee_blend_shadow_items);
+ RNA_def_property_ui_text(prop, "Transparent Shadow", "Shadow method for transparent material");
+ RNA_def_property_update(prop, 0, "rna_Material_draw_update");
+
+ prop = RNA_def_property(srna, "alpha_threshold", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_range(prop, 0, 1);
+ RNA_def_property_ui_text(prop, "Clip Threshold", "A pixel is rendered only if its alpha value is above this threshold");
+ RNA_def_property_update(prop, 0, "rna_Material_draw_update");
+
+ prop = RNA_def_property(srna, "transparent_hide_backside", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "blend_flag", MA_BL_HIDE_BACKSIDE);
+ RNA_def_property_ui_text(prop, "Hide Backside", "Limit transparency to a single layer "
+ "(avoids transparency sorting problems)");
+ RNA_def_property_update(prop, 0, "rna_Material_draw_update");
+
+ prop = RNA_def_property(srna, "use_screen_refraction", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "blend_flag", MA_BL_SS_REFRACTION);
+ RNA_def_property_ui_text(prop, "Screen Space Refraction", "Use raytraced screen space refractions");
+ RNA_def_property_update(prop, 0, "rna_Material_draw_update");
+
+ prop = RNA_def_property(srna, "refraction_depth", PROP_FLOAT, PROP_DISTANCE);
+ RNA_def_property_float_sdna(prop, NULL, "refract_depth");
+ RNA_def_property_range(prop, 0.0f, FLT_MAX);
+ RNA_def_property_ui_text(prop, "Refraction Depth", "Approximate the thickness of the object to compute two refraction "
+ "event (0 is disabled)");
+ RNA_def_property_update(prop, 0, "rna_Material_draw_update");
+
/* For Preview Render */
prop = RNA_def_property(srna, "preview_render_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "pr_type");
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index e78bdb7520f..beb5430b63b 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -46,6 +46,7 @@
#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_types.h"
+#include "RNA_enum_types.h"
#include "rna_internal.h"
@@ -186,12 +187,10 @@ static void rna_MeshEdgeLayer_name_set(PointerRNA *ptr, const char *value)
rna_cd_layer_name_set(rna_mesh_edata(ptr), (CustomDataLayer *)ptr->data, value);
}
#endif
-#if 0
static void rna_MeshPolyLayer_name_set(PointerRNA *ptr, const char *value)
{
rna_cd_layer_name_set(rna_mesh_pdata(ptr), (CustomDataLayer *)ptr->data, value);
}
-#endif
static void rna_MeshLoopLayer_name_set(PointerRNA *ptr, const char *value)
{
rna_cd_layer_name_set(rna_mesh_ldata(ptr), (CustomDataLayer *)ptr->data, value);
@@ -240,7 +239,7 @@ static void rna_Mesh_update_data_edit_color(Main *bmain, Scene *scene, PointerRN
static void rna_Mesh_update_data_edit_weight(Main *bmain, Scene *scene, PointerRNA *ptr)
{
- BKE_mesh_batch_cache_dirty(rna_mesh(ptr), BKE_MESH_BATCH_DIRTY_PAINT);
+ BKE_mesh_batch_cache_dirty(rna_mesh(ptr), BKE_MESH_BATCH_DIRTY_ALL);
rna_Mesh_update_data(bmain, scene, ptr);
}
@@ -248,7 +247,7 @@ static void rna_Mesh_update_data_edit_weight(Main *bmain, Scene *scene, PointerR
static void rna_Mesh_update_data_edit_active_color(Main *bmain, Scene *scene, PointerRNA *ptr)
{
- BKE_mesh_batch_cache_dirty(rna_mesh(ptr), BKE_MESH_BATCH_DIRTY_PAINT);
+ BKE_mesh_batch_cache_dirty(rna_mesh(ptr), BKE_MESH_BATCH_DIRTY_ALL);
rna_Mesh_update_data(bmain, scene, ptr);
}
@@ -278,7 +277,7 @@ static void rna_Mesh_update_vertmask(Main *bmain, Scene *scene, PointerRNA *ptr)
me->editflag &= ~ME_EDIT_PAINT_FACE_SEL;
}
- BKE_mesh_batch_cache_dirty(me, BKE_MESH_BATCH_DIRTY_PAINT);
+ BKE_mesh_batch_cache_dirty(me, BKE_MESH_BATCH_DIRTY_ALL);
rna_Mesh_update_draw(bmain, scene, ptr);
}
@@ -290,7 +289,7 @@ static void rna_Mesh_update_facemask(Main *bmain, Scene *scene, PointerRNA *ptr)
me->editflag &= ~ME_EDIT_PAINT_VERT_SEL;
}
- BKE_mesh_batch_cache_dirty(me, BKE_MESH_BATCH_DIRTY_PAINT);
+ BKE_mesh_batch_cache_dirty(me, BKE_MESH_BATCH_DIRTY_ALL);
rna_Mesh_update_draw(bmain, scene, ptr);
}
@@ -324,7 +323,7 @@ static float rna_MeshVertex_bevel_weight_get(PointerRNA *ptr)
static void rna_MeshVertex_bevel_weight_set(PointerRNA *ptr, float value)
{
MVert *mvert = (MVert *)ptr->data;
- mvert->bweight = (char)(CLAMPIS(value * 255.0f, 0, 255));
+ mvert->bweight = round_fl_to_uchar_clamp(value * 255.0f);
}
static float rna_MEdge_bevel_weight_get(PointerRNA *ptr)
@@ -336,7 +335,7 @@ static float rna_MEdge_bevel_weight_get(PointerRNA *ptr)
static void rna_MEdge_bevel_weight_set(PointerRNA *ptr, float value)
{
MEdge *medge = (MEdge *)ptr->data;
- medge->bweight = (char)(CLAMPIS(value * 255.0f, 0, 255));
+ medge->bweight = round_fl_to_uchar_clamp(value * 255.0f);
}
static float rna_MEdge_crease_get(PointerRNA *ptr)
@@ -348,7 +347,7 @@ static float rna_MEdge_crease_get(PointerRNA *ptr)
static void rna_MEdge_crease_set(PointerRNA *ptr, float value)
{
MEdge *medge = (MEdge *)ptr->data;
- medge->crease = (char)(CLAMPIS(value * 255.0f, 0, 255));
+ medge->crease = round_fl_to_uchar_clamp(value * 255.0f);
}
static void rna_MeshLoop_normal_get(PointerRNA *ptr, float *values)
@@ -606,15 +605,17 @@ static void rna_MeshColor_color1_set(PointerRNA *ptr, const float *values)
{
MCol *mcol = (MCol *)ptr->data;
- (&mcol[0].r)[2] = (char)(CLAMPIS(values[0] * 255.0f, 0, 255));
- (&mcol[0].r)[1] = (char)(CLAMPIS(values[1] * 255.0f, 0, 255));
- (&mcol[0].r)[0] = (char)(CLAMPIS(values[2] * 255.0f, 0, 255));
+ (&mcol[0].r)[2] = round_fl_to_uchar_clamp(values[0] * 255.0f);
+ (&mcol[0].r)[1] = round_fl_to_uchar_clamp(values[1] * 255.0f);
+ (&mcol[0].r)[0] = round_fl_to_uchar_clamp(values[2] * 255.0f);
+ (&mcol[0].r)[3] = round_fl_to_uchar_clamp(values[3] * 255.0f);
}
static void rna_MeshColor_color2_get(PointerRNA *ptr, float *values)
{
MCol *mcol = (MCol *)ptr->data;
+ values[3] = (&mcol[1].r)[3] / 255.0f;
values[2] = (&mcol[1].r)[0] / 255.0f;
values[1] = (&mcol[1].r)[1] / 255.0f;
values[0] = (&mcol[1].r)[2] / 255.0f;
@@ -624,15 +625,17 @@ static void rna_MeshColor_color2_set(PointerRNA *ptr, const float *values)
{
MCol *mcol = (MCol *)ptr->data;
- (&mcol[1].r)[2] = (char)(CLAMPIS(values[0] * 255.0f, 0, 255));
- (&mcol[1].r)[1] = (char)(CLAMPIS(values[1] * 255.0f, 0, 255));
- (&mcol[1].r)[0] = (char)(CLAMPIS(values[2] * 255.0f, 0, 255));
+ (&mcol[1].r)[2] = round_fl_to_uchar_clamp(values[0] * 255.0f);
+ (&mcol[1].r)[1] = round_fl_to_uchar_clamp(values[1] * 255.0f);
+ (&mcol[1].r)[0] = round_fl_to_uchar_clamp(values[2] * 255.0f);
+ (&mcol[1].r)[3] = round_fl_to_uchar_clamp(values[3] * 255.0f);
}
static void rna_MeshColor_color3_get(PointerRNA *ptr, float *values)
{
MCol *mcol = (MCol *)ptr->data;
+ values[3] = (&mcol[2].r)[3] / 255.0f;
values[2] = (&mcol[2].r)[0] / 255.0f;
values[1] = (&mcol[2].r)[1] / 255.0f;
values[0] = (&mcol[2].r)[2] / 255.0f;
@@ -642,9 +645,10 @@ static void rna_MeshColor_color3_set(PointerRNA *ptr, const float *values)
{
MCol *mcol = (MCol *)ptr->data;
- (&mcol[2].r)[2] = (char)(CLAMPIS(values[0] * 255.0f, 0, 255));
- (&mcol[2].r)[1] = (char)(CLAMPIS(values[1] * 255.0f, 0, 255));
- (&mcol[2].r)[0] = (char)(CLAMPIS(values[2] * 255.0f, 0, 255));
+ (&mcol[2].r)[2] = round_fl_to_uchar_clamp(values[0] * 255.0f);
+ (&mcol[2].r)[1] = round_fl_to_uchar_clamp(values[1] * 255.0f);
+ (&mcol[2].r)[0] = round_fl_to_uchar_clamp(values[2] * 255.0f);
+ (&mcol[2].r)[3] = round_fl_to_uchar_clamp(values[3] * 255.0f);
}
static void rna_MeshColor_color4_get(PointerRNA *ptr, float *values)
@@ -654,15 +658,17 @@ static void rna_MeshColor_color4_get(PointerRNA *ptr, float *values)
values[2] = (&mcol[3].r)[0] / 255.0f;
values[1] = (&mcol[3].r)[1] / 255.0f;
values[0] = (&mcol[3].r)[2] / 255.0f;
+ values[3] = (&mcol[3].r)[3] / 255.0f;
}
static void rna_MeshColor_color4_set(PointerRNA *ptr, const float *values)
{
MCol *mcol = (MCol *)ptr->data;
- (&mcol[3].r)[2] = (char)(CLAMPIS(values[0] * 255.0f, 0, 255));
- (&mcol[3].r)[1] = (char)(CLAMPIS(values[1] * 255.0f, 0, 255));
- (&mcol[3].r)[0] = (char)(CLAMPIS(values[2] * 255.0f, 0, 255));
+ (&mcol[3].r)[2] = round_fl_to_uchar_clamp(values[0] * 255.0f);
+ (&mcol[3].r)[1] = round_fl_to_uchar_clamp(values[1] * 255.0f);
+ (&mcol[3].r)[0] = round_fl_to_uchar_clamp(values[2] * 255.0f);
+ (&mcol[3].r)[3] = round_fl_to_uchar_clamp(values[3] * 255.0f);
}
static void rna_MeshLoopColor_color_get(PointerRNA *ptr, float *values)
@@ -672,15 +678,17 @@ static void rna_MeshLoopColor_color_get(PointerRNA *ptr, float *values)
values[0] = (&mcol->r)[0] / 255.0f;
values[1] = (&mcol->r)[1] / 255.0f;
values[2] = (&mcol->r)[2] / 255.0f;
+ values[3] = (&mcol->r)[3] / 255.0f;
}
static void rna_MeshLoopColor_color_set(PointerRNA *ptr, const float *values)
{
MLoopCol *mcol = (MLoopCol *)ptr->data;
- (&mcol->r)[0] = (char)(CLAMPIS(values[0] * 255.0f, 0, 255));
- (&mcol->r)[1] = (char)(CLAMPIS(values[1] * 255.0f, 0, 255));
- (&mcol->r)[2] = (char)(CLAMPIS(values[2] * 255.0f, 0, 255));
+ (&mcol->r)[0] = round_fl_to_uchar_clamp(values[0] * 255.0f);
+ (&mcol->r)[1] = round_fl_to_uchar_clamp(values[1] * 255.0f);
+ (&mcol->r)[2] = round_fl_to_uchar_clamp(values[2] * 255.0f);
+ (&mcol->r)[3] = round_fl_to_uchar_clamp(values[3] * 255.0f);
}
static int rna_Mesh_texspace_editable(PointerRNA *ptr, const char **UNUSED(r_info))
@@ -1176,6 +1184,75 @@ static int rna_MeshPaintMaskLayer_data_length(PointerRNA *ptr)
/* End paint mask */
+/* Face maps */
+
+DEFINE_CUSTOMDATA_LAYER_COLLECTION(face_map, pdata, CD_FACEMAP)
+DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM(face_map, pdata, CD_FACEMAP, active, MeshFaceMapLayer)
+
+static char *rna_MeshFaceMapLayer_path(PointerRNA *ptr)
+{
+ CustomDataLayer *cdl = ptr->data;
+ char name_esc[sizeof(cdl->name) * 2];
+ BLI_strescape(name_esc, cdl->name, sizeof(name_esc));
+ return BLI_sprintfN("face_maps[\"%s\"]", name_esc);
+}
+
+static void rna_MeshFaceMapLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+{
+ Mesh *me = rna_mesh(ptr);
+ CustomDataLayer *layer = (CustomDataLayer *)ptr->data;
+ rna_iterator_array_begin(iter, layer->data, sizeof(int), me->totpoly, 0, NULL);
+}
+
+static int rna_MeshFaceMapLayer_data_length(PointerRNA *ptr)
+{
+ Mesh *me = rna_mesh(ptr);
+ return me->totpoly;
+}
+
+static PointerRNA rna_Mesh_face_map_new(struct Mesh *me, ReportList *reports, const char *name)
+{
+ if (BKE_mesh_ensure_facemap_customdata(me) == false) {
+ BKE_report(reports, RPT_ERROR, "Currently only single face-map layers are supported");
+ return PointerRNA_NULL;
+ }
+
+ CustomData *pdata = rna_mesh_pdata_helper(me);
+
+ int index = CustomData_get_layer_index(pdata, CD_FACEMAP);
+ BLI_assert(index != -1);
+ CustomDataLayer *cdl = &pdata->layers[index];
+ rna_cd_layer_name_set(pdata, cdl, name);
+
+ PointerRNA ptr;
+ RNA_pointer_create(&me->id, &RNA_MeshFaceMapLayer, cdl, &ptr);
+ return ptr;
+}
+
+static void rna_Mesh_face_map_remove(struct Mesh *me, ReportList *reports, struct CustomDataLayer *layer)
+{
+ /* just for sanity check */
+ {
+ CustomData *pdata = rna_mesh_pdata_helper(me);
+ int index = CustomData_get_layer_index(pdata, CD_FACEMAP);
+ if (index != -1) {
+ CustomDataLayer *layer_test = &pdata->layers[index];
+ if (layer != layer_test) {
+ /* don't show name, its likely freed memory */
+ BKE_report(reports, RPT_ERROR, "FaceMap not in mesh");
+ return;
+ }
+ }
+ }
+
+ if (BKE_mesh_clear_facemap_customdata(me) == false) {
+ BKE_reportf(reports, RPT_ERROR, "Error removing face-map");
+ }
+}
+
+/* End face maps */
+
+
static int rna_MeshTessFace_verts_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
{
MFace *face = (MFace *)ptr->data;
@@ -1608,6 +1685,12 @@ void rna_MeshStringProperty_s_set(PointerRNA *ptr, const char *value)
MStringProperty *ms = (MStringProperty *)ptr->data;
BLI_strncpy(ms->s, value, sizeof(ms->s));
}
+
+static char *rna_MeshFaceMap_path(PointerRNA *ptr)
+{
+ return rna_PolyCustomData_data_path(ptr, "face_maps", CD_FACEMAP);
+}
+
/***************************************/
static int rna_Mesh_tot_vert_get(PointerRNA *ptr)
@@ -1796,6 +1879,10 @@ static void UNUSED_FUNCTION(rna_mesh_unused)(void)
(void)rna_Mesh_vertex_color_render_index_get;
(void)rna_Mesh_vertex_color_render_index_set;
(void)rna_Mesh_vertex_color_render_set;
+ (void)rna_Mesh_face_map_index_range;
+ (void)rna_Mesh_face_map_active_index_set;
+ (void)rna_Mesh_face_map_active_index_get;
+ (void)rna_Mesh_face_map_active_set;
/* end unused function block */
}
@@ -2376,28 +2463,28 @@ static void rna_def_mcol(BlenderRNA *brna)
RNA_def_struct_path_func(srna, "rna_MeshColor_path");
prop = RNA_def_property(srna, "color1", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_array(prop, 3);
+ RNA_def_property_array(prop, 4);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_float_funcs(prop, "rna_MeshColor_color1_get", "rna_MeshColor_color1_set", NULL);
RNA_def_property_ui_text(prop, "Color 1", "");
RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
prop = RNA_def_property(srna, "color2", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_array(prop, 3);
+ RNA_def_property_array(prop, 4);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_float_funcs(prop, "rna_MeshColor_color2_get", "rna_MeshColor_color2_set", NULL);
RNA_def_property_ui_text(prop, "Color 2", "");
RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
prop = RNA_def_property(srna, "color3", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_array(prop, 3);
+ RNA_def_property_array(prop, 4);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_float_funcs(prop, "rna_MeshColor_color3_get", "rna_MeshColor_color3_set", NULL);
RNA_def_property_ui_text(prop, "Color 3", "");
RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
prop = RNA_def_property(srna, "color4", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_array(prop, 3);
+ RNA_def_property_array(prop, 4);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_float_funcs(prop, "rna_MeshColor_color4_get", "rna_MeshColor_color4_set", NULL);
RNA_def_property_ui_text(prop, "Color 4", "");
@@ -2447,7 +2534,7 @@ static void rna_def_mloopcol(BlenderRNA *brna)
RNA_def_struct_path_func(srna, "rna_MeshColor_path");
prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_array(prop, 3);
+ RNA_def_property_array(prop, 4);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_float_funcs(prop, "rna_MeshLoopColor_color_get", "rna_MeshLoopColor_color_set", NULL);
RNA_def_property_ui_text(prop, "Color", "");
@@ -3091,6 +3178,79 @@ static void rna_def_paint_mask(BlenderRNA *brna, PropertyRNA *UNUSED(cprop))
RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
}
+static void rna_def_face_map(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "MeshFaceMapLayer", NULL);
+ RNA_def_struct_ui_text(srna, "Mesh Face Map Layer", "Per-face map index");
+ RNA_def_struct_sdna(srna, "CustomDataLayer");
+ RNA_def_struct_path_func(srna, "rna_MeshFaceMapLayer_path");
+
+ prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+ RNA_def_struct_name_property(srna, prop);
+ RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MeshPolyLayer_name_set");
+ RNA_def_property_ui_text(prop, "Name", "Name of face-map layer");
+ RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
+
+ prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_struct_type(prop, "MeshFaceMap");
+ RNA_def_property_ui_text(prop, "Data", "");
+ RNA_def_property_collection_funcs(prop, "rna_MeshFaceMapLayer_data_begin", "rna_iterator_array_next",
+ "rna_iterator_array_end", "rna_iterator_array_get",
+ "rna_MeshFaceMapLayer_data_length", NULL, NULL, NULL);
+
+ /* FaceMap struct */
+ srna = RNA_def_struct(brna, "MeshFaceMap", NULL);
+ RNA_def_struct_sdna(srna, "MIntProperty");
+ RNA_def_struct_ui_text(srna, "Int Property", "");
+ RNA_def_struct_path_func(srna, "rna_MeshFaceMap_path");
+
+ prop = RNA_def_property(srna, "value", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "i");
+ RNA_def_property_ui_text(prop, "Value", "");
+ RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
+}
+
+static void rna_def_face_maps(BlenderRNA *brna, PropertyRNA *cprop)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ RNA_def_property_srna(cprop, "MeshFaceMapLayers");
+ srna = RNA_def_struct(brna, "MeshFaceMapLayers", NULL);
+ RNA_def_struct_ui_text(srna, "Mesh Face Map Layer", "Per-face map index");
+ RNA_def_struct_sdna(srna, "Mesh");
+ RNA_def_struct_ui_text(srna, "Mesh FaceMaps", "Collection of mesh face-maps");
+
+ /* add this since we only ever have one layer anyway, don't bother with active_index */
+ prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "MeshFaceMapLayer");
+ RNA_def_property_pointer_funcs(prop, "rna_Mesh_face_map_active_get",
+ NULL, NULL, NULL);
+ RNA_def_property_ui_text(prop, "Active FaceMap Layer", "");
+ RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
+
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ func = RNA_def_function(srna, "new", "rna_Mesh_face_map_new");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ RNA_def_function_ui_description(func, "Add a float property layer to Mesh");
+ RNA_def_string(func, "name", "Face Map", 0, "", "Face map name");
+ parm = RNA_def_pointer(func, "layer", "MeshFaceMapLayer", "", "The newly created layer");
+ RNA_def_parameter_flags(parm, 0, PARM_RNAPTR);
+ RNA_def_function_return(func, parm);
+
+ func = RNA_def_function(srna, "remove", "rna_Mesh_face_map_remove");
+ RNA_def_function_ui_description(func, "Remove a face map layer");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ parm = RNA_def_pointer(func, "layer", "MeshFaceMapLayer", "", "The layer to remove");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
+}
+
static void rna_def_mesh(BlenderRNA *brna)
{
StructRNA *srna;
@@ -3250,6 +3410,15 @@ static void rna_def_mesh(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "String Property Layers", "");
rna_def_polygon_string_layers(brna, prop);
+ /* face-maps */
+ prop = RNA_def_property(srna, "face_maps", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_collection_sdna(prop, NULL, "pdata.layers", "pdata.totlayer");
+ RNA_def_property_collection_funcs(prop, "rna_Mesh_face_maps_begin", NULL, NULL, NULL,
+ "rna_Mesh_face_maps_length", NULL, NULL, NULL);
+ RNA_def_property_struct_type(prop, "MeshFaceMapLayer");
+ RNA_def_property_ui_text(prop, "FaceMap", "");
+ rna_def_face_maps(brna, prop);
+
/* Skin vertices */
prop = RNA_def_property(srna, "skin_vertices", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "vdata.layers", "vdata.totlayer");
@@ -3523,6 +3692,7 @@ void RNA_def_mesh(BlenderRNA *brna)
rna_def_mcol(brna);
rna_def_mloopcol(brna);
rna_def_mproperties(brna);
+ rna_def_face_map(brna);
}
#endif
diff --git a/source/blender/makesrna/intern/rna_mesh_api.c b/source/blender/makesrna/intern/rna_mesh_api.c
index 5dbb7cb0d29..f1f7c9a3b99 100644
--- a/source/blender/makesrna/intern/rna_mesh_api.c
+++ b/source/blender/makesrna/intern/rna_mesh_api.c
@@ -215,6 +215,12 @@ static void rna_Mesh_split_faces(Mesh *mesh, int free_loop_normals)
BKE_mesh_split_faces(mesh, free_loop_normals != 0);
}
+static void rna_Mesh_update_gpu_tag(Mesh *mesh)
+{
+ BKE_mesh_batch_cache_dirty(mesh, BKE_MESH_BATCH_DIRTY_ALL);
+}
+
+
#else
void RNA_api_mesh(StructRNA *srna)
@@ -305,6 +311,8 @@ void RNA_api_mesh(StructRNA *srna)
RNA_def_boolean(func, "calc_tessface", 0, "Calculate Tessellation", "Force recalculation of tessellation faces");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
+ RNA_def_function(srna, "update_gpu_tag", "rna_Mesh_update_gpu_tag");
+
func = RNA_def_function(srna, "unit_test_compare", "rna_Mesh_unit_test_compare");
RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh to compare to");
/* return value */
diff --git a/source/blender/makesrna/intern/rna_meta_api.c b/source/blender/makesrna/intern/rna_meta_api.c
index 117162babd5..46547677dfd 100644
--- a/source/blender/makesrna/intern/rna_meta_api.c
+++ b/source/blender/makesrna/intern/rna_meta_api.c
@@ -45,7 +45,7 @@
#ifdef RNA_RUNTIME
static void rna_Meta_transform(struct MetaBall *mb, float *mat)
{
- BKE_mball_transform(mb, (float (*)[4])mat);
+ BKE_mball_transform(mb, (float (*)[4])mat, true);
DEG_id_tag_update(&mb->id, 0);
}
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 03340c6c356..0dc5ab5d6bf 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -1520,26 +1520,40 @@ static void rna_def_modifier_mirror(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_mirror_u", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_MIR_MIRROR_U);
- RNA_def_property_ui_text(prop, "Mirror U", "Mirror the U texture coordinate around the 0.5 point");
+ RNA_def_property_ui_text(prop, "Mirror U", "Mirror the U texture coordinate around the flip offset point");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop = RNA_def_property(srna, "use_mirror_v", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_MIR_MIRROR_V);
- RNA_def_property_ui_text(prop, "Mirror V", "Mirror the V texture coordinate around the 0.5 point");
+ RNA_def_property_ui_text(prop, "Mirror V", "Mirror the V texture coordinate around the flip offset point");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop = RNA_def_property(srna, "mirror_offset_u", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "uv_offset[0]");
RNA_def_property_range(prop, -1, 1);
RNA_def_property_ui_range(prop, -1, 1, 2, 4);
- RNA_def_property_ui_text(prop, "U Offset", "Amount to offset mirrored UVs from the 0.5 point on the U axis");
+ RNA_def_property_ui_text(prop, "Flip U Offset", "Amount to offset mirrored UVs flipping point from the 0.5 on the U axis");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop = RNA_def_property(srna, "mirror_offset_v", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "uv_offset[1]");
RNA_def_property_range(prop, -1, 1);
RNA_def_property_ui_range(prop, -1, 1, 2, 4);
- RNA_def_property_ui_text(prop, "V Offset", "Amount to offset mirrored UVs from the 0.5 point on the V axis");
+ RNA_def_property_ui_text(prop, "Flip V Offset", "Amount to offset mirrored UVs flipping point from the 0.5 point on the V axis");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "offset_u", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "uv_offset_copy[0]");
+ RNA_def_property_range(prop, -10000.0f, 10000.0f);
+ RNA_def_property_ui_range(prop, -1, 1, 2, 4);
+ RNA_def_property_ui_text(prop, "U Offset", "Mirrored UV offset on the U axis");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "offset_v", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "uv_offset_copy[1]");
+ RNA_def_property_range(prop, -10000.0f, 10000.0f);
+ RNA_def_property_ui_range(prop, -1, 1, 2, 4);
+ RNA_def_property_ui_text(prop, "V Offset", "Mirrored UV offset on the V axis");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop = RNA_def_property(srna, "merge_threshold", PROP_FLOAT, PROP_DISTANCE);
@@ -1976,9 +1990,26 @@ static void rna_def_modifier_boolean(BlenderRNA *brna)
prop = RNA_def_property(srna, "double_threshold", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "double_threshold");
RNA_def_property_range(prop, 0, 1.0f);
- RNA_def_property_ui_range(prop, 0, 1, 0.0001, 7);
+ RNA_def_property_ui_range(prop, 0, 1, 0.0001, 6);
RNA_def_property_ui_text(prop, "Overlap Threshold", "Threshold for checking overlapping geometry");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ /* BMesh debugging options, only used when G_DEBUG is set */
+
+ /* BMesh intersection options */
+ static EnumPropertyItem debug_items[] = {
+ {eBooleanModifierBMeshFlag_BMesh_Separate, "SEPARATE", 0, "Separate", ""},
+ {eBooleanModifierBMeshFlag_BMesh_NoDissolve, "NO_DISSOLVE", 0, "No Dissolve", ""},
+ {eBooleanModifierBMeshFlag_BMesh_NoConnectRegions, "NO_CONNECT_REGIONS", 0, "No Connect Regions", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ prop = RNA_def_property(srna, "debug_options", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, debug_items);
+ RNA_def_property_enum_sdna(prop, NULL, "bm_flag");
+ RNA_def_property_flag(prop, PROP_ENUM_FLAG);
+ RNA_def_property_ui_text(prop, "Debug", "Debugging options, only when started with '-d'");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
}
static void rna_def_modifier_array(BlenderRNA *brna)
@@ -3410,6 +3441,13 @@ static void rna_def_modifier_screw(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Screw", "Offset the revolution along its axis");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
+ prop = RNA_def_property(srna, "merge_threshold", PROP_FLOAT, PROP_DISTANCE);
+ RNA_def_property_float_sdna(prop, NULL, "merge_dist");
+ RNA_def_property_range(prop, 0, FLT_MAX);
+ RNA_def_property_ui_range(prop, 0, 1, 1, 4);
+ RNA_def_property_ui_text(prop, "Merge Distance", "Limit below which to merge vertices");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
prop = RNA_def_property(srna, "use_normal_flip", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SCREW_NORMAL_FLIP);
RNA_def_property_ui_text(prop, "Flip", "Flip normals of lathed faces");
@@ -3425,6 +3463,12 @@ static void rna_def_modifier_screw(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Object Screw", "Use the distance between the objects to make a screw");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
+ /* Vertex merging parameters */
+ prop = RNA_def_property(srna, "use_merge_vertices", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SCREW_MERGE);
+ RNA_def_property_ui_text(prop, "Merge Vertices", "Merge adjacent vertices (screw offset must be zero)");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
prop = RNA_def_property(srna, "use_smooth_shade", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SCREW_SMOOTH_SHADING);
RNA_def_property_ui_text(prop, "Smooth Shading", "Output faces with smooth shading rather than flat shaded");
diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c
index 62e3bd5cacb..0e43f12b64b 100644
--- a/source/blender/makesrna/intern/rna_nla.c
+++ b/source/blender/makesrna/intern/rna_nla.c
@@ -658,7 +658,10 @@ static void rna_def_nlastrip(BlenderRNA *brna)
prop = RNA_def_property(srna, "influence", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Influence", "Amount the strip contributes to the current result");
- RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_update");
+ /* XXX: Update temporarily disabled so that the property can be edited at all!
+ * Even autokey only applies after the curves have been re-evaluated, causing the unkeyed values to be lost
+ */
+ RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, /*"rna_NlaStrip_update"*/ NULL);
prop = RNA_def_property(srna, "strip_time", PROP_FLOAT, PROP_TIME);
RNA_def_property_ui_text(prop, "Strip Time", "Frame of referenced Action to evaluate");
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 10422c85579..55ac8a32d80 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -66,6 +66,8 @@
#include "NOD_composite.h"
+#include "DEG_depsgraph.h"
+
EnumPropertyItem rna_enum_node_socket_in_out_items[] = {
{ SOCK_IN, "IN", 0, "Input", "" },
{ SOCK_OUT, "OUT", 0, "Output", "" },
@@ -73,6 +75,13 @@ EnumPropertyItem rna_enum_node_socket_in_out_items[] = {
};
#ifndef RNA_RUNTIME
+static EnumPropertyItem rna_enum_node_socket_draw_shape_items[] = {
+ {SOCK_DRAW_SHAPE_CIRCLE, "CIRCLE", 0, "Circle", ""},
+ {SOCK_DRAW_SHAPE_SQUARE, "SQUARE", 0, "Square", ""},
+ {SOCK_DRAW_SHAPE_DIAMOND, "DIAMOND", 0, "Diamond", ""},
+ {0, NULL, 0, NULL, NULL }
+};
+
static EnumPropertyItem node_socket_type_items[] = {
{SOCK_CUSTOM, "CUSTOM", 0, "Custom", ""},
{SOCK_FLOAT, "VALUE", 0, "Value", ""},
@@ -180,6 +189,8 @@ static EnumPropertyItem node_sampler_type_items[] = {
#include "ED_node.h"
#include "ED_render.h"
+#include "GPU_material.h"
+
#include "NOD_common.h"
#include "NOD_socket.h"
@@ -238,10 +249,10 @@ bNodeTreeType *rna_node_tree_type_from_enum(int value)
EnumPropertyItem *rna_node_tree_type_itemf(void *data, int (*poll)(void *data, bNodeTreeType *), bool *r_free)
{
- EnumPropertyItem tmp = {0, "", 0, "", ""};
+ EnumPropertyItem tmp = {0};
EnumPropertyItem *item = NULL;
int totitem = 0, i = 0;
-
+
NODE_TREE_TYPES_BEGIN (nt)
{
if (poll && !poll(data, nt)) {
@@ -261,9 +272,14 @@ EnumPropertyItem *rna_node_tree_type_itemf(void *data, int (*poll)(void *data, b
}
NODE_TREE_TYPES_END;
+ if (totitem == 0) {
+ *r_free = false;
+ return DummyRNA_NULL_items;
+ }
+
RNA_enum_item_end(&item, &totitem);
*r_free = true;
-
+
return item;
}
@@ -310,9 +326,9 @@ bNodeType *rna_node_type_from_enum(int value)
EnumPropertyItem *rna_node_type_itemf(void *data, int (*poll)(void *data, bNodeType *), bool *r_free)
{
EnumPropertyItem *item = NULL;
- EnumPropertyItem tmp = {0, "", 0, "", ""};
+ EnumPropertyItem tmp = {0};
int totitem = 0, i = 0;
-
+
NODE_TYPES_BEGIN(ntype)
if (poll && !poll(data, ntype)) {
++i;
@@ -329,9 +345,15 @@ EnumPropertyItem *rna_node_type_itemf(void *data, int (*poll)(void *data, bNodeT
++i;
NODE_TYPES_END
+
+ if (totitem == 0) {
+ *r_free = false;
+ return DummyRNA_NULL_items;
+ }
+
RNA_enum_item_end(&item, &totitem);
*r_free = true;
-
+
return item;
}
@@ -378,10 +400,10 @@ bNodeSocketType *rna_node_socket_type_from_enum(int value)
EnumPropertyItem *rna_node_socket_type_itemf(void *data, int (*poll)(void *data, bNodeSocketType *), bool *r_free)
{
EnumPropertyItem *item = NULL;
- EnumPropertyItem tmp = {0, "", 0, "", ""};
+ EnumPropertyItem tmp = {0};
int totitem = 0, i = 0;
StructRNA *srna;
-
+
NODE_SOCKET_TYPES_BEGIN(stype)
if (poll && !poll(data, stype)) {
++i;
@@ -399,9 +421,15 @@ EnumPropertyItem *rna_node_socket_type_itemf(void *data, int (*poll)(void *data,
++i;
NODE_SOCKET_TYPES_END
+
+ if (totitem == 0) {
+ *r_free = false;
+ return DummyRNA_NULL_items;
+ }
+
RNA_enum_item_end(&item, &totitem);
*r_free = true;
-
+
return item;
}
@@ -410,25 +438,25 @@ static EnumPropertyItem *rna_node_static_type_itemf(bContext *UNUSED(C), Pointer
EnumPropertyItem *item = NULL;
EnumPropertyItem tmp;
int totitem = 0;
-
+
/* hack, don't want to add include path to RNA just for this, since in the future RNA types
* for nodes should be defined locally at runtime anyway ...
*/
-
+
tmp.value = NODE_CUSTOM;
tmp.identifier = "CUSTOM";
tmp.name = "Custom";
tmp.description = "Custom Node";
tmp.icon = ICON_NONE;
RNA_enum_item_add(&item, &totitem, &tmp);
-
+
tmp.value = NODE_UNDEFINED;
tmp.identifier = "UNDEFINED";
tmp.name = "UNDEFINED";
tmp.description = "";
tmp.icon = ICON_NONE;
RNA_enum_item_add(&item, &totitem, &tmp);
-
+
#define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \
if (STREQ(#Category, "Node")) { \
tmp.value = ID; \
@@ -440,7 +468,7 @@ static EnumPropertyItem *rna_node_static_type_itemf(bContext *UNUSED(C), Pointer
}
#include "../../nodes/NOD_static_types.h"
#undef DefNode
-
+
if (RNA_struct_is_a(ptr->type, &RNA_ShaderNode)) {
#define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \
if (STREQ(#Category, "ShaderNode")) { \
@@ -468,7 +496,7 @@ static EnumPropertyItem *rna_node_static_type_itemf(bContext *UNUSED(C), Pointer
#include "../../nodes/NOD_static_types.h"
#undef DefNode
}
-
+
if (RNA_struct_is_a(ptr->type, &RNA_TextureNode)) {
#define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \
if (STREQ(#Category, "TextureNode")) { \
@@ -485,7 +513,7 @@ static EnumPropertyItem *rna_node_static_type_itemf(bContext *UNUSED(C), Pointer
RNA_enum_item_end(&item, &totitem);
*r_free = true;
-
+
return item;
}
@@ -578,11 +606,10 @@ static void rna_NodeTree_unregister(Main *UNUSED(bmain), StructRNA *type)
return;
RNA_struct_free_extension(type, &nt->ext);
+ RNA_struct_free(&BLENDER_RNA, type);
ntreeTypeFreeLink(nt);
- RNA_struct_free(&BLENDER_RNA, type);
-
/* update while blender is running */
WM_main_add_notifier(NC_NODE | NA_EDITED, NULL);
}
@@ -614,9 +641,10 @@ static StructRNA *rna_NodeTree_register(
/* check if we have registered this tree type before, and remove it */
nt = ntreeTypeFind(dummynt.idname);
- if (nt)
+ if (nt) {
rna_NodeTree_unregister(bmain, nt->ext.srna);
-
+ }
+
/* create a new node tree type */
nt = MEM_callocN(sizeof(bNodeTreeType), "node tree type");
memcpy(nt, &dummynt, sizeof(dummynt));
@@ -1331,11 +1359,11 @@ static void rna_Node_unregister(Main *UNUSED(bmain), StructRNA *type)
return;
RNA_struct_free_extension(type, &nt->ext);
+ RNA_struct_free(&BLENDER_RNA, type);
/* this also frees the allocated nt pointer, no MEM_free call needed! */
nodeUnregisterType(nt);
- RNA_struct_free(&BLENDER_RNA, type);
/* update while blender is running */
WM_main_add_notifier(NC_NODE | NA_EDITED, NULL);
@@ -1376,8 +1404,9 @@ static bNodeType *rna_Node_register_base(Main *bmain, ReportList *reports, Struc
/* check if we have registered this node type before, and remove it */
nt = nodeTypeFind(dummynt.idname);
- if (nt)
+ if (nt) {
rna_Node_unregister(bmain, nt->ext.srna);
+ }
/* create a new node type */
nt = MEM_callocN(sizeof(bNodeType), "node type");
@@ -1793,10 +1822,10 @@ static void rna_NodeSocket_unregister(Main *UNUSED(bmain), StructRNA *type)
return;
RNA_struct_free_extension(type, &st->ext_socket);
+ RNA_struct_free(&BLENDER_RNA, type);
nodeUnregisterSocketType(st);
- RNA_struct_free(&BLENDER_RNA, type);
/* update while blender is running */
WM_main_add_notifier(NC_NODE | NA_EDITED, NULL);
@@ -2273,13 +2302,25 @@ static void rna_NodeSocketStandard_vector_range(PointerRNA *ptr, float *min, flo
*softmax = dval->max;
}
+static void rna_NodeSocket_value_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ bNodeTree *ntree = (bNodeTree *)ptr->id.data;
+ if (ntree->type == NTREE_SHADER) {
+ DEG_id_tag_update_ex(bmain, ptr->id.data, DEG_TAG_SHADING_UPDATE);
+ WM_main_add_notifier(NC_MATERIAL | ND_SHADING, NULL);
+ }
+ else {
+ rna_NodeSocket_update(bmain, scene, ptr);
+ }
+}
+
/* using a context update function here, to avoid searching the node if possible */
static void rna_NodeSocketStandard_value_update(struct bContext *C, PointerRNA *ptr)
{
bNode *node;
/* default update */
- rna_NodeSocket_update(CTX_data_main(C), CTX_data_scene(C), ptr);
+ rna_NodeSocket_value_update(CTX_data_main(C), CTX_data_scene(C), ptr);
/* try to use node from context, faster */
node = CTX_data_pointer_get(C, "node").data;
@@ -2617,9 +2658,9 @@ static void rna_Node_image_layer_update(Main *bmain, Scene *scene, PointerRNA *p
static EnumPropertyItem *renderresult_layers_add_enum(RenderLayer *rl)
{
EnumPropertyItem *item = NULL;
- EnumPropertyItem tmp = {0, "", 0, "", ""};
+ EnumPropertyItem tmp = {0};
int i = 0, totitem = 0;
-
+
while (rl) {
tmp.identifier = rl->name;
/* little trick: using space char instead empty string makes the item selectable in the dropdown */
@@ -2631,7 +2672,7 @@ static EnumPropertyItem *renderresult_layers_add_enum(RenderLayer *rl)
RNA_enum_item_add(&item, &totitem, &tmp);
rl = rl->next;
}
-
+
RNA_enum_item_end(&item, &totitem);
return item;
@@ -2644,18 +2685,17 @@ static EnumPropertyItem *rna_Node_image_layer_itemf(bContext *UNUSED(C), Pointer
Image *ima = (Image *)node->id;
EnumPropertyItem *item = NULL;
RenderLayer *rl;
-
- if (ima && ima->rr) {
- rl = ima->rr->layers.first;
- item = renderresult_layers_add_enum(rl);
- }
- else {
- int totitem = 0;
- RNA_enum_item_end(&item, &totitem);
+
+ if (ima == NULL || ima->rr == NULL) {
+ *r_free = false;
+ return DummyRNA_NULL_items;
}
-
+
+ rl = ima->rr->layers.first;
+ item = renderresult_layers_add_enum(rl);
+
*r_free = true;
-
+
return item;
}
@@ -2706,19 +2746,22 @@ static EnumPropertyItem *renderresult_views_add_enum(RenderView *rv)
}
static EnumPropertyItem *rna_Node_image_view_itemf(bContext *UNUSED(C), PointerRNA *ptr,
- PropertyRNA *UNUSED(prop), bool *free)
+ PropertyRNA *UNUSED(prop), bool *r_free)
{
bNode *node = (bNode *)ptr->data;
Image *ima = (Image *)node->id;
EnumPropertyItem *item = NULL;
RenderView *rv;
- if (!ima || !(ima->rr)) return NULL;
+ if (ima == NULL || ima->rr == NULL) {
+ *r_free = false;
+ return DummyRNA_NULL_items;
+ }
rv = ima->rr->views.first;
item = renderresult_views_add_enum(rv);
- *free = true;
+ *r_free = true;
return item;
}
@@ -2730,18 +2773,17 @@ static EnumPropertyItem *rna_Node_scene_layer_itemf(bContext *UNUSED(C), Pointer
Scene *sce = (Scene *)node->id;
EnumPropertyItem *item = NULL;
RenderLayer *rl;
-
- if (sce) {
- rl = sce->r.layers.first;
- item = renderresult_layers_add_enum(rl);
- }
- else {
- int totitem = 0;
- RNA_enum_item_end(&item, &totitem);
+
+ if (sce == NULL) {
+ *r_free = false;
+ return DummyRNA_NULL_items;
}
-
+
+ rl = sce->r.layers.first;
+ item = renderresult_layers_add_enum(rl);
+
*r_free = true;
-
+
return item;
}
@@ -2758,7 +2800,7 @@ static EnumPropertyItem *rna_Node_channel_itemf(bContext *UNUSED(C), PointerRNA
{
bNode *node = (bNode *)ptr->data;
EnumPropertyItem *item = NULL;
- EnumPropertyItem tmp = {0, "", 0, "", ""};
+ EnumPropertyItem tmp = {0};
int totitem = 0;
switch (node->custom1) {
@@ -2795,7 +2837,7 @@ static EnumPropertyItem *rna_Node_channel_itemf(bContext *UNUSED(C), PointerRNA
RNA_enum_item_add(&item, &totitem, &tmp);
break;
default:
- break;
+ return DummyRNA_NULL_items;
}
RNA_enum_item_end(&item, &totitem);
@@ -3086,6 +3128,7 @@ static int point_density_vertex_color_source_from_shader(NodeShaderTexPointDensi
void rna_ShaderNodePointDensity_density_cache(bNode *self,
Scene *scene,
+ SceneLayer *sl,
int settings)
{
NodeShaderTexPointDensity *shader_point_density = self->storage;
@@ -3123,12 +3166,13 @@ void rna_ShaderNodePointDensity_density_cache(bNode *self,
/* Single-threaded sampling of the voxel domain. */
RE_point_density_cache(scene,
- pd,
+ sl, pd,
settings == 1);
}
void rna_ShaderNodePointDensity_density_calc(bNode *self,
Scene *scene,
+ SceneLayer *sl,
int settings,
int *length,
float **values)
@@ -3150,7 +3194,7 @@ void rna_ShaderNodePointDensity_density_calc(bNode *self,
}
/* Single-threaded sampling of the voxel domain. */
- RE_point_density_sample(scene, pd,
+ RE_point_density_sample(scene, sl, pd,
resolution,
settings == 1,
*values);
@@ -3163,6 +3207,7 @@ void rna_ShaderNodePointDensity_density_calc(bNode *self,
void rna_ShaderNodePointDensity_density_minmax(bNode *self,
Scene *scene,
+ SceneLayer *sl,
int settings,
float r_min[3],
float r_max[3])
@@ -3174,7 +3219,7 @@ void rna_ShaderNodePointDensity_density_minmax(bNode *self,
zero_v3(r_max);
return;
}
- RE_point_density_minmax(scene, pd, settings == 1, r_min, r_max);
+ RE_point_density_minmax(scene, sl, pd, settings == 1, r_min, r_max);
}
#else
@@ -3339,7 +3384,7 @@ static void def_frame(StructRNA *srna)
prop = RNA_def_property(srna, "text", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "id");
RNA_def_property_struct_type(prop, "Text");
- RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
RNA_def_property_ui_text(prop, "Text", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
@@ -3609,7 +3654,7 @@ static void def_sh_lamp(StructRNA *srna)
prop = RNA_def_property(srna, "lamp_object", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "id");
RNA_def_property_struct_type(prop, "Object");
- RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Lamp_object_poll");
RNA_def_property_ui_text(prop, "Lamp Object", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
@@ -3983,7 +4028,7 @@ static void def_sh_tex_coord(StructRNA *srna)
prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "id");
RNA_def_property_struct_type(prop, "Object");
- RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
RNA_def_property_ui_text(prop, "Object", "Use coordinates from this object (for object texture coordinates output)");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
@@ -4099,7 +4144,7 @@ static void def_sh_tex_pointdensity(StructRNA *srna)
prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "id");
RNA_def_property_struct_type(prop, "Object");
- RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
RNA_def_property_ui_text(prop, "Object", "Object to take point data from");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
@@ -4158,11 +4203,13 @@ static void def_sh_tex_pointdensity(StructRNA *srna)
func = RNA_def_function(srna, "cache_point_density", "rna_ShaderNodePointDensity_density_cache");
RNA_def_function_ui_description(func, "Cache point density data for later calculation");
RNA_def_pointer(func, "scene", "Scene", "", "");
+ RNA_def_pointer(func, "sl", "SceneLayer", "", "");
RNA_def_enum(func, "settings", calc_mode_items, 1, "", "Calculate density for rendering");
func = RNA_def_function(srna, "calc_point_density", "rna_ShaderNodePointDensity_density_calc");
RNA_def_function_ui_description(func, "Calculate point density");
RNA_def_pointer(func, "scene", "Scene", "", "");
+ RNA_def_pointer(func, "sl", "SceneLayer", "", "");
RNA_def_enum(func, "settings", calc_mode_items, 1, "", "Calculate density for rendering");
/* TODO, See how array size of 0 works, this shouldnt be used. */
parm = RNA_def_float_array(func, "rgba_values", 1, NULL, 0, 0, "", "RGBA Values", 0, 0);
@@ -4172,6 +4219,7 @@ static void def_sh_tex_pointdensity(StructRNA *srna)
func = RNA_def_function(srna, "calc_point_density_minmax", "rna_ShaderNodePointDensity_density_minmax");
RNA_def_function_ui_description(func, "Calculate point density");
RNA_def_pointer(func, "scene", "Scene", "", "");
+ RNA_def_pointer(func, "sl", "SceneLayer", "", "");
RNA_def_enum(func, "settings", calc_mode_items, 1, "", "Calculate density for rendering");
parm = RNA_def_property(func, "min", PROP_FLOAT, PROP_COORDS);
RNA_def_property_array(parm, 3);
@@ -4796,7 +4844,7 @@ static void def_cmp_render_layers(StructRNA *srna)
RNA_def_property_pointer_sdna(prop, NULL, "id");
RNA_def_property_pointer_funcs(prop, NULL, "rna_Node_scene_set", NULL, NULL);
RNA_def_property_struct_type(prop, "Scene");
- RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
RNA_def_property_ui_text(prop, "Scene", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_scene_layer_update");
@@ -5453,7 +5501,7 @@ static void def_cmp_defocus(StructRNA *srna)
RNA_def_property_pointer_sdna(prop, NULL, "id");
RNA_def_property_pointer_funcs(prop, NULL, "rna_Node_scene_set", NULL, NULL);
RNA_def_property_struct_type(prop, "Scene");
- RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
RNA_def_property_ui_text(prop, "Scene", "Scene from which to select the active camera (render scene if undefined)");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
@@ -6968,6 +7016,13 @@ static void rna_def_node_socket(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Type", "Data type");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocket_update");
+ prop = RNA_def_property(srna, "draw_shape", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "draw_shape");
+ RNA_def_property_enum_items(prop, rna_enum_node_socket_draw_shape_items);
+ RNA_def_property_enum_default(prop, SOCK_DRAW_SHAPE_CIRCLE);
+ RNA_def_property_ui_text(prop, "Shape", "Socket shape");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocket_update");
+
/* registration */
prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "typeinfo->idname");
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index ea55b5e3083..e57333fb8a7 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -97,16 +97,27 @@ static EnumPropertyItem parent_type_items[] = {
{0, NULL, 0, NULL, NULL}
};
-#ifndef RNA_RUNTIME
+#define DUPLI_ITEMS_SHARED \
+ {0, "NONE", 0, "None", ""}, \
+ {OB_DUPLIFRAMES, "FRAMES", 0, "Frames", "Make copy of object for every frame"}, \
+ {OB_DUPLIVERTS, "VERTS", 0, "Verts", "Duplicate child objects on all vertices"}, \
+ {OB_DUPLIFACES, "FACES", 0, "Faces", "Duplicate child objects on all faces"}
+
+#define DUPLI_ITEM_GROUP \
+ {OB_DUPLIGROUP, "GROUP", 0, "Group", "Enable group instancing"}
static EnumPropertyItem dupli_items[] = {
- {0, "NONE", 0, "None", ""},
- {OB_DUPLIFRAMES, "FRAMES", 0, "Frames", "Make copy of object for every frame"},
- {OB_DUPLIVERTS, "VERTS", 0, "Verts", "Duplicate child objects on all vertices"},
- {OB_DUPLIFACES, "FACES", 0, "Faces", "Duplicate child objects on all faces"},
- {OB_DUPLIGROUP, "GROUP", 0, "Group", "Enable group instancing"},
+ DUPLI_ITEMS_SHARED,
+ DUPLI_ITEM_GROUP,
+ {0, NULL, 0, NULL, NULL}
+};
+#ifdef RNA_RUNTIME
+static EnumPropertyItem dupli_items_nogroup[] = {
+ DUPLI_ITEMS_SHARED,
{0, NULL, 0, NULL, NULL}
};
#endif
+#undef DUPLI_ITEMS_SHARED
+#undef DUPLI_ITEM_GROUP
static EnumPropertyItem collision_bounds_items[] = {
{OB_BOUND_BOX, "BOX", ICON_MESH_CUBE, "Box", ""},
@@ -515,6 +526,23 @@ static void rna_Object_parent_bone_set(PointerRNA *ptr, const char *value)
ED_object_parent(ob, ob->parent, ob->partype, value);
}
+static EnumPropertyItem *rna_Object_dupli_type_itemf(
+ bContext *UNUSED(C), PointerRNA *ptr,
+ PropertyRNA *UNUSED(prop), bool *UNUSED(r_free))
+{
+ Object *ob = (Object *)ptr->data;
+ EnumPropertyItem *item;
+
+ if (ob->type == OB_EMPTY) {
+ item = dupli_items;
+ }
+ else {
+ item = dupli_items_nogroup;
+ }
+
+ return item;
+}
+
static void rna_Object_dup_group_set(PointerRNA *ptr, PointerRNA value)
{
Object *ob = (Object *)ptr->data;
@@ -524,9 +552,15 @@ static void rna_Object_dup_group_set(PointerRNA *ptr, PointerRNA value)
* thus causing a cycle/infinite-recursion leading to crashes on load [#25298]
*/
if (BKE_group_object_exists(grp, ob) == 0) {
- id_us_min(&ob->dup_group->id);
- ob->dup_group = grp;
- id_us_plus(&ob->dup_group->id);
+ if (ob->type == OB_EMPTY) {
+ id_us_min(&ob->dup_group->id);
+ ob->dup_group = grp;
+ id_us_plus(&ob->dup_group->id);
+ }
+ else {
+ BKE_report(NULL, RPT_ERROR,
+ "Only empty objects support group instances");
+ }
}
else {
BKE_report(NULL, RPT_ERROR,
@@ -824,9 +858,14 @@ static void rna_Object_active_particle_system_index_set(PointerRNA *ptr, int val
static void rna_Object_particle_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
{
+ /* TODO: Disabled for now, because bContext is not available. */
+#if 0
Object *ob = (Object *)ptr->id.data;
-
- PE_current_changed(scene, ob);
+ PE_current_changed(NULL, scene, ob);
+#else
+ (void) scene;
+ (void) ptr;
+#endif
}
/* rotation - axis-angle */
@@ -1739,6 +1778,11 @@ static void rna_def_face_map(BlenderRNA *brna)
/* update data because modifiers may use [#24761] */
RNA_def_property_update(prop, NC_GEOM | ND_DATA | NA_RENAME, "rna_Object_internal_update_data");
+ prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT);
+ RNA_def_property_ui_text(prop, "Select", "Face-map selection state (for tools to use)");
+ /* important not to use a notifier here, creates a feedback loop! */
+
prop = RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_int_funcs(prop, "rna_FaceMap_index_get", NULL, NULL);
@@ -2613,7 +2657,7 @@ static void rna_def_object(BlenderRNA *brna)
/* only for the transform-panel and conflicts with animating scale */
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_float_funcs(prop, "rna_Object_dimensions_get", "rna_Object_dimensions_set", NULL);
- RNA_def_property_ui_range(prop, 0.0f, FLT_MAX, 1, 3);
+ RNA_def_property_ui_range(prop, 0.0f, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
RNA_def_property_ui_text(prop, "Dimensions", "Absolute bounding box dimensions of the object");
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
@@ -2853,6 +2897,12 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1);
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update");
+ /* Keep it in sync with BKE_object_is_visible. */
+ prop = RNA_def_property(srna, "is_visible", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "base_flag", BASE_VISIBLED);
+ RNA_def_property_ui_text(prop, "Visible", "Visible to camera rays, set only on objects evaluated by depsgraph");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
prop = RNA_def_property(srna, "collection_properties", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "base_collection_properties->data.group", NULL);
RNA_def_property_struct_type(prop, "LayerCollectionSettings");
@@ -2893,6 +2943,7 @@ static void rna_def_object(BlenderRNA *brna)
prop = RNA_def_property(srna, "dupli_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "transflag");
RNA_def_property_enum_items(prop, dupli_items);
+ RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Object_dupli_type_itemf");
RNA_def_property_ui_text(prop, "Dupli Type", "If not None, object duplication method to use");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c
index 1e2d4d6ab18..d1dcfa41e28 100644
--- a/source/blender/makesrna/intern/rna_object_api.c
+++ b/source/blender/makesrna/intern/rna_object_api.c
@@ -111,13 +111,13 @@ static void rna_Object_select_set(Object *ob, bContext *C, ReportList *reports,
}
switch (action) {
- case 1: /* DESELECT */
- base->flag &= ~BASE_SELECTED;
- break;
- case 0: /* SELECT */
- default:
- BKE_scene_layer_base_select(sl, base);
- break;
+ case 1: /* DESELECT */
+ base->flag &= ~BASE_SELECTED;
+ break;
+ case 0: /* SELECT */
+ default:
+ BKE_scene_layer_base_select(sl, base);
+ break;
}
}
@@ -197,14 +197,16 @@ static void rna_Object_camera_fit_coords(
/* copied from Mesh_getFromObject and adapted to RNA interface */
/* settings: 0 - preview, 1 - render */
static Mesh *rna_Object_to_mesh(
- Object *ob, ReportList *reports, Scene *sce,
+ Object *ob, bContext *C, ReportList *reports, Scene *sce, SceneLayer *sl,
int apply_modifiers, int settings, int calc_tessface, int calc_undeformed)
{
- return rna_Main_meshes_new_from_object(G.main, reports, sce, ob, apply_modifiers, settings, calc_tessface, calc_undeformed);
+ Main *bmain = CTX_data_main(C);
+
+ return rna_Main_meshes_new_from_object(bmain, reports, sce, sl, ob, apply_modifiers, settings, calc_tessface, calc_undeformed);
}
/* mostly a copy from convertblender.c */
-static void dupli_render_particle_set(Scene *scene, Object *ob, int level, int enable)
+static void dupli_render_particle_set(EvaluationContext *eval_ctx, Scene *scene, Object *ob, int level, int enable)
{
/* ugly function, but we need to set particle systems to their render
* settings before calling object_duplilist, to get render level duplis */
@@ -233,7 +235,7 @@ static void dupli_render_particle_set(Scene *scene, Object *ob, int level, int e
/* this is to make sure we get render level duplis in groups:
* the derivedmesh must be created before init_render_mesh,
* since object_duplilist does dupliparticles before that */
- dm = mesh_create_derived_render(scene, ob, CD_MASK_BAREMESH | CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL);
+ dm = mesh_create_derived_render(eval_ctx, scene, ob, CD_MASK_BAREMESH | CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL);
dm->release(dm);
for (psys = ob->particlesystem.first; psys; psys = psys->next)
@@ -245,14 +247,17 @@ static void dupli_render_particle_set(Scene *scene, Object *ob, int level, int e
group = ob->dup_group;
for (go = group->gobject.first; go; go = go->next)
- dupli_render_particle_set(scene, go->ob, level + 1, enable);
+ dupli_render_particle_set(eval_ctx, scene, go->ob, level + 1, enable);
}
/* When no longer needed, duplilist should be freed with Object.free_duplilist */
-static void rna_Object_create_duplilist(Object *ob, ReportList *reports, Scene *sce, int settings)
+static void rna_Object_create_duplilist(Object *ob, bContext *C, ReportList *reports, Scene *sce, int settings)
{
bool for_render = (settings == DAG_EVAL_RENDER);
EvaluationContext eval_ctx;
- DEG_evaluation_context_init(&eval_ctx, settings);
+
+ CTX_data_eval_ctx(C, &eval_ctx);
+
+ eval_ctx.mode = settings;
if (!(ob->transflag & OB_DUPLI)) {
BKE_report(reports, RPT_ERROR, "Object does not have duplis");
@@ -267,10 +272,10 @@ static void rna_Object_create_duplilist(Object *ob, ReportList *reports, Scene *
ob->duplilist = NULL;
}
if (for_render)
- dupli_render_particle_set(sce, ob, 0, 1);
+ dupli_render_particle_set(&eval_ctx, sce, ob, 0, 1);
ob->duplilist = object_duplilist(&eval_ctx, sce, ob);
if (for_render)
- dupli_render_particle_set(sce, ob, 0, 0);
+ dupli_render_particle_set(&eval_ctx, sce, ob, 0, 0);
/* ob->duplilist should now be freed with Object.free_duplilist */
}
@@ -324,11 +329,6 @@ static void rna_Object_shape_key_remove(
RNA_POINTER_INVALIDATE(kb_ptr);
}
-static int rna_Object_is_visible(Object *ob, Scene *sce)
-{
- return !(ob->restrictflag & OB_RESTRICT_VIEW) && (ob->lay & sce->lay);
-}
-
#if 0
static void rna_Mesh_assign_verts_to_group(Object *ob, bDeformGroup *group, int *indices, int totindex,
float weight, int assignmode)
@@ -644,9 +644,11 @@ void RNA_api_object(StructRNA *srna)
/* mesh */
func = RNA_def_function(srna, "to_mesh", "rna_Object_to_mesh");
RNA_def_function_ui_description(func, "Create a Mesh data-block with modifiers applied");
- RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_CONTEXT);
parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene within which to evaluate modifiers");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ parm = RNA_def_pointer(func, "scene_layer", "SceneLayer", "", "Scene layer within which to evaluate modifiers");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
parm = RNA_def_boolean(func, "apply_modifiers", 0, "", "Apply modifiers");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
parm = RNA_def_enum(func, "settings", mesh_type_items, 0, "", "Modifier settings to apply");
@@ -665,7 +667,7 @@ void RNA_api_object(StructRNA *srna)
parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene within which to evaluate duplis");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
RNA_def_enum(func, "settings", dupli_eval_mode_items, 0, "", "Generate texture coordinates for rendering");
- RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_CONTEXT);
func = RNA_def_function(srna, "dupli_list_clear", "rna_Object_free_duplilist");
RNA_def_function_ui_description(func, "Free the list of dupli objects");
@@ -747,12 +749,6 @@ void RNA_api_object(StructRNA *srna)
RNA_def_function_output(func, parm);
/* View */
- func = RNA_def_function(srna, "is_visible", "rna_Object_is_visible");
- RNA_def_function_ui_description(func, "Determine if object is visible in a given scene");
- parm = RNA_def_pointer(func, "scene", "Scene", "", "");
- RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
- parm = RNA_def_boolean(func, "result", 0, "", "Object visibility");
- RNA_def_function_return(func, parm);
/* utility function for checking if the object is modified */
func = RNA_def_function(srna, "is_modified", "rna_Object_is_modified");
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index 29f33907d39..93801a508c5 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -448,10 +448,12 @@ static int rna_ParticleSystem_tessfaceidx_on_emitter(ParticleSystem *particlesys
int totpart;
int totchild = 0;
int totface;
+ int totvert;
int num = -1;
DM_ensure_tessface(modifier->dm_final); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */
totface = modifier->dm_final->getNumTessFaces(modifier->dm_final);
+ totvert = modifier->dm_final->getNumVerts(modifier->dm_final);
/* 1. check that everything is ok & updated */
if (!particlesystem || !totface) {
@@ -486,13 +488,29 @@ static int rna_ParticleSystem_tessfaceidx_on_emitter(ParticleSystem *particlesys
return num;
}
}
+ else if (part->from == PART_FROM_VERT) {
+ if (num != DMCACHE_NOTFOUND && num < totvert) {
+ MFace *mface = modifier->dm_final->getTessFaceDataArray(modifier->dm_final, CD_MFACE);
+
+ *r_fuv = &particle->fuv;
+
+ /* This finds the first face to contain the emitting vertex,
+ * this is not ideal, but is mostly fine as UV seams generally
+ * map to equal-colored parts of a texture */
+ for (int i = 0; i < totface; i++, mface++) {
+ if (ELEM(num, mface->v1, mface->v2, mface->v3, mface->v4)) {
+ return i;
+ }
+ }
+ }
+ }
}
else {
ChildParticle *cpa = particlesystem->child + particle_no - totpart;
num = cpa->num;
if (part->childtype == PART_CHILD_FACES) {
- if (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME)) {
+ if (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME, PART_FROM_VERT)) {
if (num != DMCACHE_NOTFOUND && num < totface) {
*r_fuv = &cpa->fuv;
return num;
@@ -512,6 +530,22 @@ static int rna_ParticleSystem_tessfaceidx_on_emitter(ParticleSystem *particlesys
return num;
}
}
+ else if (part->from == PART_FROM_VERT) {
+ if (num != DMCACHE_NOTFOUND && num < totvert) {
+ MFace *mface = modifier->dm_final->getTessFaceDataArray(modifier->dm_final, CD_MFACE);
+
+ *r_fuv = &parent->fuv;
+
+ /* This finds the first face to contain the emitting vertex,
+ * this is not ideal, but is mostly fine as UV seams generally
+ * map to equal-colored parts of a texture */
+ for (int i = 0; i < totface; i++, mface++) {
+ if (ELEM(num, mface->v1, mface->v2, mface->v3, mface->v4)) {
+ return i;
+ }
+ }
+ }
+ }
}
}
@@ -580,8 +614,14 @@ static void rna_ParticleSystem_mcol_on_emitter(ParticleSystem *particlesystem, R
}
}
-static void rna_ParticleSystem_set_resolution(ParticleSystem *particlesystem, Scene *scene, Object *object, int resolution)
+static void rna_ParticleSystem_set_resolution(ParticleSystem *particlesystem, Scene *scene, SceneLayer *sl, Object *object, int resolution)
{
+ EvaluationContext eval_ctx;
+
+ DEG_evaluation_context_init(&eval_ctx, resolution);
+ eval_ctx.ctime = (float)scene->r.cfra + scene->r.subframe;
+ eval_ctx.scene_layer = sl;
+
if (resolution == eModifierMode_Render) {
ParticleSystemModifierData *psmd = psys_get_modifier(object, particlesystem);
float mat[4][4];
@@ -590,7 +630,7 @@ static void rna_ParticleSystem_set_resolution(ParticleSystem *particlesystem, Sc
psys_render_set(object, particlesystem, mat, mat, 1, 1, 0.f);
psmd->flag &= ~eParticleSystemFlag_psys_updated;
- particle_system_update(scene, object, particlesystem, true);
+ particle_system_update(&eval_ctx, scene, object, particlesystem, true);
}
else {
ParticleSystemModifierData *psmd = psys_get_modifier(object, particlesystem);
@@ -600,7 +640,7 @@ static void rna_ParticleSystem_set_resolution(ParticleSystem *particlesystem, Sc
}
psmd->flag &= ~eParticleSystemFlag_psys_updated;
- particle_system_update(scene, object, particlesystem, false);
+ particle_system_update(&eval_ctx, scene, object, particlesystem, false);
}
}
@@ -3513,6 +3553,7 @@ static void rna_def_particle_system(BlenderRNA *brna)
func = RNA_def_function(srna, "set_resolution", "rna_ParticleSystem_set_resolution");
RNA_def_function_ui_description(func, "Set the resolution to use for the number of particles");
RNA_def_pointer(func, "scene", "Scene", "", "Scene");
+ RNA_def_pointer(func, "scene_layer", "SceneLayer", "", "SceneLayer");
RNA_def_pointer(func, "object", "Object", "", "Object");
RNA_def_enum(func, "resolution", resolution_items, 0, "", "Resolution settings to apply");
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c
index d8ed9800b4c..d9e7d3f6a84 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -673,7 +673,7 @@ static void rna_PoseChannel_matrix_set(PointerRNA *ptr, const float *values)
Object *ob = (Object *)ptr->id.data;
float tmat[4][4];
- BKE_armature_mat_pose_to_bone_ex(ob, pchan, (float (*)[4])values, tmat);
+ BKE_armature_mat_pose_to_bone_ex(NULL, ob, pchan, (float (*)[4])values, tmat);
BKE_pchan_apply_mat4(pchan, tmat, false); /* no compat for predictable result */
}
diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c
index 267a81c81af..8304fa452e4 100644
--- a/source/blender/makesrna/intern/rna_render.c
+++ b/source/blender/makesrna/intern/rna_render.c
@@ -35,6 +35,8 @@
#include "DEG_depsgraph.h"
+#include "BKE_scene.h"
+
#include "RNA_define.h"
#include "RNA_enum_types.h"
@@ -43,6 +45,7 @@
#include "RE_engine.h"
#include "RE_pipeline.h"
+#include "ED_render.h"
/* Deprecated, only provided for API compatibility. */
EnumPropertyItem rna_enum_render_pass_type_items[] = {
@@ -125,6 +128,11 @@ static int engine_support_display_space_shader(RenderEngine *UNUSED(engine), Sce
return IMB_colormanagement_support_glsl_draw(&scene->view_settings);
}
+static int engine_get_preview_pixel_size(RenderEngine *UNUSED(engine), Scene *scene)
+{
+ return BKE_render_preview_pixel_size(&scene->r);
+}
+
static void engine_bind_display_space_shader(RenderEngine *UNUSED(engine), Scene *scene)
{
IMB_colormanagement_setup_glsl_draw(&scene->view_settings,
@@ -291,7 +299,7 @@ static void engine_update_render_passes(RenderEngine *engine, struct Scene *scen
/* RenderEngine registration */
-static void rna_RenderEngine_unregister(Main *UNUSED(bmain), StructRNA *type)
+static void rna_RenderEngine_unregister(Main *bmain, StructRNA *type)
{
RenderEngineType *et = RNA_struct_blender_type_get(type);
@@ -299,12 +307,16 @@ static void rna_RenderEngine_unregister(Main *UNUSED(bmain), StructRNA *type)
return;
RNA_struct_free_extension(type, &et->ext);
- BLI_freelinkN(&R_engines, et);
RNA_struct_free(&BLENDER_RNA, type);
+ BLI_freelinkN(&R_engines, et);
+
+ /* Stop all renders in case we were using this one. */
+ ED_render_engine_changed(bmain);
}
-static StructRNA *rna_RenderEngine_register(Main *bmain, ReportList *reports, void *data, const char *identifier,
- StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
+static StructRNA *rna_RenderEngine_register(
+ Main *bmain, ReportList *reports, void *data, const char *identifier,
+ StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
{
RenderEngineType *et, dummyet = {NULL};
RenderEngine dummyengine = {NULL};
@@ -385,6 +397,16 @@ static PointerRNA rna_RenderEngine_render_get(PointerRNA *ptr)
}
}
+static PointerRNA rna_RenderEngine_scene_layer_get(PointerRNA *ptr)
+{
+ RenderEngine *engine = (RenderEngine *)ptr->data;
+ if (engine->re != NULL) {
+ SceneLayer *scene_layer = RE_engine_get_scene_layer(engine->re);
+ return rna_pointer_inherit_refine(ptr, &RNA_SceneLayer, scene_layer);
+ }
+ return rna_pointer_inherit_refine(ptr, &RNA_SceneLayer, NULL);
+}
+
static PointerRNA rna_RenderEngine_camera_override_get(PointerRNA *ptr)
{
RenderEngine *engine = (RenderEngine *)ptr->data;
@@ -676,6 +698,13 @@ static void rna_def_render_engine(BlenderRNA *brna)
parm = RNA_def_boolean(func, "supported", 0, "Supported", "");
RNA_def_function_return(func, parm);
+ func = RNA_def_function(srna, "get_preview_pixel_size", "engine_get_preview_pixel_size");
+ RNA_def_function_ui_description(func, "Get the pixel size that should be used for preview rendering");
+ parm = RNA_def_pointer(func, "scene", "Scene", "", "");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ parm = RNA_def_int(func, "pixel_size", 0, 1, 8, "Pixel Size", "", 1, 8);
+ RNA_def_function_return(func, parm);
+
RNA_define_verify_sdna(0);
prop = RNA_def_property(srna, "is_animation", PROP_BOOLEAN, PROP_NONE);
@@ -729,6 +758,11 @@ static void rna_def_render_engine(BlenderRNA *brna)
prop = RNA_def_enum(func, "type", render_pass_type_items, SOCK_FLOAT, "Type", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ prop = RNA_def_property(srna, "scene_layer", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "SceneLayer");
+ RNA_def_property_pointer_funcs(prop, "rna_RenderEngine_scene_layer_get", NULL, NULL, NULL);
+ RNA_def_property_ui_text(prop, "Scene layer", "");
+
/* registration */
prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c
index abded187b33..502a9c42363 100644
--- a/source/blender/makesrna/intern/rna_rna.c
+++ b/source/blender/makesrna/intern/rna_rna.c
@@ -610,6 +610,22 @@ static int rna_Property_array_length_get(PointerRNA *ptr)
return prop->totarraylength;
}
+static void rna_Property_array_dimensions_get(PointerRNA *ptr, int dimensions[RNA_MAX_ARRAY_DIMENSION])
+{
+ PropertyRNA *prop = (PropertyRNA *)ptr->data;
+ rna_idproperty_check(&prop, ptr);
+
+ if (prop->arraydimension > 1) {
+ for (int i = RNA_MAX_ARRAY_DIMENSION; i--; ) {
+ dimensions[i] = (i >= prop->arraydimension) ? 0 : prop->arraylength[i];
+ }
+ }
+ else {
+ memset(dimensions, 0, sizeof(*dimensions) * RNA_MAX_ARRAY_DIMENSION);
+ dimensions[0] = prop->totarraylength;
+ }
+}
+
static int rna_Property_is_registered_get(PointerRNA *ptr)
{
PropertyRNA *prop = (PropertyRNA *)ptr->data;
@@ -983,21 +999,32 @@ static int rna_Function_use_self_type_get(PointerRNA *ptr)
/* Blender RNA */
+static int rna_struct_is_publc(CollectionPropertyIterator *UNUSED(iter), void *data)
+{
+ StructRNA *srna = data;
+
+ return !(srna->flag & STRUCT_PUBLIC_NAMESPACE);
+}
+
+
static void rna_BlenderRNA_structs_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
- rna_iterator_listbase_begin(iter, &((BlenderRNA *)ptr->data)->structs, NULL);
+ BlenderRNA *brna = ptr->data;
+ rna_iterator_listbase_begin(iter, &brna->structs, rna_struct_is_publc);
}
/* optional, for faster lookups */
static int rna_BlenderRNA_structs_length(PointerRNA *ptr)
{
- return BLI_listbase_count(&((BlenderRNA *)ptr->data)->structs);
+ BlenderRNA *brna = ptr->data;
+ BLI_assert(brna->structs_len == BLI_listbase_count(&brna->structs));
+ return brna->structs_len;
}
static int rna_BlenderRNA_structs_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr)
{
- StructRNA *srna = BLI_findlink(&((BlenderRNA *)ptr->data)->structs, index);
-
- if (srna) {
+ BlenderRNA *brna = ptr->data;
+ StructRNA *srna = index < brna->structs_len ? BLI_findlink(&brna->structs, index) : NULL;
+ if (srna != NULL) {
RNA_pointer_create(NULL, &RNA_Struct, srna, r_ptr);
return true;
}
@@ -1007,12 +1034,11 @@ static int rna_BlenderRNA_structs_lookup_int(PointerRNA *ptr, int index, Pointer
}
static int rna_BlenderRNA_structs_lookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr)
{
- StructRNA *srna = ((BlenderRNA *)ptr->data)->structs.first;
- for (; srna; srna = srna->cont.next) {
- if (key[0] == srna->identifier[0] && STREQ(key, srna->identifier)) {
- RNA_pointer_create(NULL, &RNA_Struct, srna, r_ptr);
- return true;
- }
+ BlenderRNA *brna = ptr->data;
+ StructRNA *srna = BLI_ghash_lookup(brna->structs_map, (void *)key);
+ if (srna != NULL) {
+ RNA_pointer_create(NULL, &RNA_Struct, srna, r_ptr);
+ return true;
}
return false;
@@ -1344,6 +1370,12 @@ static void rna_def_number_property(StructRNA *srna, PropertyType type)
RNA_def_property_int_funcs(prop, "rna_Property_array_length_get", NULL, NULL);
RNA_def_property_ui_text(prop, "Array Length", "Maximum length of the array, 0 means unlimited");
+ prop = RNA_def_property(srna, "array_dimensions", PROP_INT, PROP_UNSIGNED);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_array(prop, RNA_MAX_ARRAY_DIMENSION);
+ RNA_def_property_int_funcs(prop, "rna_Property_array_dimensions_get", NULL, NULL);
+ RNA_def_property_ui_text(prop, "Array Dimensions", "Length of each dimension of the array");
+
prop = RNA_def_property(srna, "is_array", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_boolean_funcs(prop, "rna_NumberProperty_is_array_get", NULL);
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 22e5833b20f..59d0792eb1e 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -63,11 +63,6 @@
#include "RE_engine.h"
#include "RE_pipeline.h"
-#ifdef WITH_QUICKTIME
-# include "quicktime_export.h"
-# include AUD_TYPES_H
-#endif
-
#ifdef WITH_FFMPEG
# include "BKE_writeffmpeg.h"
# include <libavcodec/avcodec.h>
@@ -99,13 +94,15 @@ EnumPropertyItem rna_enum_exr_codec_items[] = {
};
#endif
-EnumPropertyItem uv_sculpt_relaxation_items[] = {
+#ifndef RNA_RUNTIME
+static EnumPropertyItem uv_sculpt_relaxation_items[] = {
{UV_SCULPT_TOOL_RELAX_LAPLACIAN, "LAPLACIAN", 0, "Laplacian", "Use Laplacian method for relaxation"},
{UV_SCULPT_TOOL_RELAX_HC, "HC", 0, "HC", "Use HC method for relaxation"},
{0, NULL, 0, NULL, NULL}
};
+#endif
-EnumPropertyItem uv_sculpt_tool_items[] = {
+EnumPropertyItem rna_enum_uv_sculpt_tool_items[] = {
{UV_SCULPT_TOOL_PINCH, "PINCH", 0, "Pinch", "Pinch UVs"},
{UV_SCULPT_TOOL_RELAX, "RELAX", 0, "Relax", "Relax UVs"},
{UV_SCULPT_TOOL_GRAB, "GRAB", 0, "Grab", "Grab UVs"},
@@ -180,11 +177,13 @@ EnumPropertyItem rna_enum_snap_node_element_items[] = {
{0, NULL, 0, NULL, NULL}
};
-EnumPropertyItem snap_uv_element_items[] = {
+#ifndef RNA_RUNTIME
+static EnumPropertyItem snap_uv_element_items[] = {
{SCE_SNAP_MODE_INCREMENT, "INCREMENT", ICON_SNAP_INCREMENT, "Increment", "Snap to increments of grid"},
{SCE_SNAP_MODE_VERTEX, "VERTEX", ICON_SNAP_VERTEX, "Vertex", "Snap to vertices"},
{0, NULL, 0, NULL, NULL}
};
+#endif
EnumPropertyItem rna_enum_curve_fit_method_items[] = {
{CURVE_PAINT_FIT_METHOD_REFIT, "REFIT", 0, "Refit", "Incrementally re-fit the curve (high quality)"},
@@ -270,12 +269,14 @@ EnumPropertyItem rna_enum_curve_fit_method_items[] = {
R_IMF_ENUM_TIFF \
-EnumPropertyItem image_only_type_items[] = {
+#ifdef RNA_RUNTIME
+static EnumPropertyItem image_only_type_items[] = {
IMAGE_TYPE_ITEMS_IMAGE_ONLY
{0, NULL, 0, NULL, NULL}
};
+#endif
EnumPropertyItem rna_enum_image_type_items[] = {
{0, "", 0, N_("Image"), NULL},
@@ -291,9 +292,6 @@ EnumPropertyItem rna_enum_image_type_items[] = {
#ifdef WITH_FFMPEG
{R_IMF_IMTYPE_FFMPEG, "FFMPEG", ICON_FILE_MOVIE, "FFmpeg video", "The most versatile way to output video files"},
#endif
-#ifdef WITH_QUICKTIME
- {R_IMF_IMTYPE_QUICKTIME, "QUICKTIME", ICON_FILE_MOVIE, "QuickTime", "Output video in Quicktime format"},
-#endif
{0, NULL, 0, NULL, NULL}
};
@@ -413,7 +411,8 @@ EnumPropertyItem rna_enum_bake_pass_filter_type_items[] = {
{0, NULL, 0, NULL, NULL}
};
-EnumPropertyItem rna_enum_gpencil_interpolation_mode_items[] = {
+#ifndef RNA_RUNTIME
+static EnumPropertyItem rna_enum_gpencil_interpolation_mode_items[] = {
/* interpolation */
{0, "", 0, N_("Interpolation"), "Standard transitions between keyframes"},
{GP_IPO_LINEAR, "LINEAR", ICON_IPO_LINEAR, "Linear", "Straight-line interpolation between A and B (i.e. no ease in/out)"},
@@ -437,6 +436,8 @@ EnumPropertyItem rna_enum_gpencil_interpolation_mode_items[] = {
{0, NULL, 0, NULL, NULL}
};
+#endif
+
EnumPropertyItem rna_enum_layer_collection_mode_settings_type_items[] = {
{COLLECTION_MODE_OBJECT, "OBJECT", 0, "Object", ""},
{COLLECTION_MODE_EDIT, "EDIT", 0, "Edit", ""},
@@ -470,7 +471,6 @@ EnumPropertyItem rna_enum_layer_collection_mode_settings_type_items[] = {
#include "BKE_node.h"
#include "BKE_pointcache.h"
#include "BKE_scene.h"
-#include "BKE_idprop.h"
#include "BKE_mesh.h"
#include "BKE_sound.h"
#include "BKE_screen.h"
@@ -479,9 +479,6 @@ EnumPropertyItem rna_enum_layer_collection_mode_settings_type_items[] = {
#include "BKE_freestyle.h"
#include "BKE_gpencil.h"
-#include "DEG_depsgraph.h"
-#include "DEG_depsgraph_build.h"
-
#include "ED_info.h"
#include "ED_node.h"
#include "ED_view3d.h"
@@ -491,6 +488,7 @@ EnumPropertyItem rna_enum_layer_collection_mode_settings_type_items[] = {
#include "ED_scene.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
#include "DEG_depsgraph_query.h"
#ifdef WITH_FREESTYLE
@@ -1142,9 +1140,6 @@ static void rna_ImageFormatSettings_file_format_set(PointerRNA *ptr, int value)
#ifdef WITH_FFMPEG
BKE_ffmpeg_image_type_verify(rd, imf);
#endif
-#ifdef WITH_QUICKTIME
- quicktime_verify_image_type(rd, imf);
-#endif
(void)rd;
}
}
@@ -1333,84 +1328,6 @@ static void rna_SceneRender_file_ext_get(PointerRNA *ptr, char *str)
BKE_image_path_ensure_ext_from_imformat(str, &rd->im_format);
}
-#ifdef WITH_QUICKTIME
-static int rna_RenderSettings_qtcodecsettings_codecType_get(PointerRNA *ptr)
-{
- QuicktimeCodecSettings *settings = (QuicktimeCodecSettings *)ptr->data;
-
- return quicktime_rnatmpvalue_from_videocodectype(settings->codecType);
-}
-
-static void rna_RenderSettings_qtcodecsettings_codecType_set(PointerRNA *ptr, int value)
-{
- QuicktimeCodecSettings *settings = (QuicktimeCodecSettings *)ptr->data;
-
- settings->codecType = quicktime_videocodecType_from_rnatmpvalue(value);
-}
-
-static EnumPropertyItem *rna_RenderSettings_qtcodecsettings_codecType_itemf(
- bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
-{
- EnumPropertyItem *item = NULL;
- EnumPropertyItem tmp = {0, "", 0, "", ""};
- QuicktimeCodecTypeDesc *codecTypeDesc;
- int i = 1, totitem = 0;
-
- for (i = 0; i < quicktime_get_num_videocodecs(); i++) {
- codecTypeDesc = quicktime_get_videocodecType_desc(i);
- if (!codecTypeDesc) break;
-
- tmp.value = codecTypeDesc->rnatmpvalue;
- tmp.identifier = codecTypeDesc->codecName;
- tmp.name = codecTypeDesc->codecName;
- RNA_enum_item_add(&item, &totitem, &tmp);
- }
-
- RNA_enum_item_end(&item, &totitem);
- *r_free = true;
-
- return item;
-}
-
-static int rna_RenderSettings_qtcodecsettings_audiocodecType_get(PointerRNA *ptr)
-{
- QuicktimeCodecSettings *settings = (QuicktimeCodecSettings *)ptr->data;
-
- return quicktime_rnatmpvalue_from_audiocodectype(settings->audiocodecType);
-}
-
-static void rna_RenderSettings_qtcodecsettings_audiocodecType_set(PointerRNA *ptr, int value)
-{
- QuicktimeCodecSettings *settings = (QuicktimeCodecSettings *)ptr->data;
-
- settings->audiocodecType = quicktime_audiocodecType_from_rnatmpvalue(value);
-}
-
-static EnumPropertyItem *rna_RenderSettings_qtcodecsettings_audiocodecType_itemf(
- bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
-{
- EnumPropertyItem *item = NULL;
- EnumPropertyItem tmp = {0, "", 0, "", ""};
- QuicktimeCodecTypeDesc *codecTypeDesc;
- int i = 1, totitem = 0;
-
- for (i = 0; i < quicktime_get_num_audiocodecs(); i++) {
- codecTypeDesc = quicktime_get_audiocodecType_desc(i);
- if (!codecTypeDesc) break;
-
- tmp.value = codecTypeDesc->rnatmpvalue;
- tmp.identifier = codecTypeDesc->codecName;
- tmp.name = codecTypeDesc->codecName;
- RNA_enum_item_add(&item, &totitem, &tmp);
- }
-
- RNA_enum_item_end(&item, &totitem);
- *r_free = true;
-
- return item;
-}
-#endif
-
#ifdef WITH_FFMPEG
static void rna_FFmpegSettings_lossless_output_set(PointerRNA *ptr, int value)
{
@@ -1569,9 +1486,12 @@ static void rna_RenderSettings_engine_set(PointerRNA *ptr, int value)
{
RenderData *rd = (RenderData *)ptr->data;
RenderEngineType *type = BLI_findlink(&R_engines, value);
+ Scene *scene = (Scene *)ptr->id.data;
if (type)
BLI_strncpy_utf8(rd->engine, type->idname, sizeof(rd->engine));
+
+ DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
}
static EnumPropertyItem *rna_RenderSettings_engine_itemf(
@@ -1620,6 +1540,14 @@ static void rna_Scene_glsl_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Poi
DEG_id_tag_update(&scene->id, 0);
}
+static void rna_Scene_world_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ Scene *sc = (Scene *)ptr->id.data;
+
+ rna_Scene_glsl_update(bmain, scene, ptr);
+ WM_main_add_notifier(NC_WORLD | ND_WORLD, &sc->id);
+}
+
static void rna_Scene_freestyle_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
Scene *scene = (Scene *)ptr->id.data;
@@ -1783,7 +1711,7 @@ static void rna_Physics_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Pointe
static void rna_Scene_editmesh_select_mode_set(PointerRNA *ptr, const int *value)
{
Scene *scene = (Scene *)ptr->id.data;
- SceneLayer *sl = BKE_scene_layer_context_active(scene);
+ SceneLayer *sl = BKE_scene_layer_context_active_PLACEHOLDER(scene);
ToolSettings *ts = (ToolSettings *)ptr->data;
int flag = (value[0] ? SCE_SELECT_VERTEX : 0) | (value[1] ? SCE_SELECT_EDGE : 0) | (value[2] ? SCE_SELECT_FACE : 0);
@@ -1865,6 +1793,13 @@ static void rna_Scene_simplify_update(Main *bmain, Scene *UNUSED(scene), Pointer
rna_Scene_use_simplify_update(bmain, sce, ptr);
}
+static void rna_SceneRenderData_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
+{
+ Scene *sce = ptr->id.data;
+
+ DEG_id_tag_update(&sce->id, 0);
+}
+
static void rna_Scene_use_persistent_data_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
Scene *sce = ptr->id.data;
@@ -2132,7 +2067,7 @@ static char *rna_MeshStatVis_path(PointerRNA *UNUSED(ptr))
static void rna_Scene_update_active_object_data(bContext *C, PointerRNA *UNUSED(ptr))
{
SceneLayer *sl = CTX_data_scene_layer(C);
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
if (ob) {
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -2536,6 +2471,9 @@ static void rna_LayerEngineSettings_##_ENGINE_##_##_NAME_##_set(PointerRNA *ptr,
#define RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(_NAME_) \
RNA_LAYER_ENGINE_GET_SET(float, Eevee, COLLECTION_MODE_NONE, _NAME_)
+#define RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT_ARRAY(_NAME_, _LEN_) \
+ RNA_LAYER_ENGINE_GET_SET_ARRAY(float, Eevee, COLLECTION_MODE_NONE, _NAME_, _LEN_)
+
#define RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(_NAME_) \
RNA_LAYER_ENGINE_GET_SET(int, Eevee, COLLECTION_MODE_NONE, _NAME_)
@@ -2590,7 +2528,10 @@ RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(hair_brightness_randomness)
/* SceneLayer settings. */
RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(gtao_enable)
RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(gtao_use_bent_normals)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(gtao_denoise)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(gtao_bounce)
RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(gtao_factor)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(gtao_quality)
RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(gtao_distance)
RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(gtao_samples)
RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(dof_enable)
@@ -2598,12 +2539,38 @@ RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(bokeh_max_size)
RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(bokeh_threshold)
RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(bloom_enable)
RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(bloom_threshold)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT_ARRAY(bloom_color, 3)
RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(bloom_knee)
RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(bloom_radius)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(bloom_clamp)
RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(bloom_intensity)
RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(motion_blur_enable)
RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(motion_blur_samples)
RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(motion_blur_shutter)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(volumetric_enable)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(volumetric_start)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(volumetric_end)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(volumetric_samples)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(volumetric_sample_distribution)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(volumetric_lights)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(volumetric_light_clamp)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(volumetric_shadows)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(volumetric_shadow_samples)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(volumetric_colored_transmittance)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(ssr_refraction)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(ssr_enable)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(ssr_halfres)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(ssr_ray_count)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(ssr_quality)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(ssr_max_roughness)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(ssr_thickness)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(ssr_border_fade)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(ssr_firefly_fac)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(shadow_method)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(shadow_size)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(shadow_high_bitdepth)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(taa_samples)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(gi_diffuse_bounces)
/* object engine */
RNA_LAYER_MODE_OBJECT_GET_SET_BOOL(show_wire)
@@ -2646,10 +2613,10 @@ static void rna_LayerCollectionEngineSettings_wire_update(bContext *C, PointerRN
{
Scene *scene = CTX_data_scene(C);
SceneLayer *sl = CTX_data_scene_layer(C);
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
if (ob != NULL && ob->type == OB_MESH) {
- BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_PAINT);
+ BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_ALL);
}
/* TODO(sergey): Use proper flag for tagging here. */
@@ -2842,6 +2809,39 @@ static void rna_LayerCollection_flag_update(bContext *C, PointerRNA *UNUSED(ptr)
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
}
+static void rna_LayerCollection_enable_set(
+ ID *id, LayerCollection *layer_collection, Main *bmain, bContext *C, ReportList *reports, int value)
+{
+ Scene *scene = (Scene *)id;
+ SceneLayer *scene_layer = BKE_scene_layer_find_from_collection(scene, layer_collection);
+
+ if (layer_collection->flag & COLLECTION_DISABLED) {
+ if (value == 1) {
+ BKE_collection_enable(scene_layer, layer_collection);
+ }
+ else {
+ BKE_reportf(reports, RPT_ERROR, "Layer collection '%s' is already disabled",
+ layer_collection->scene_collection->name);
+ return;
+ }
+ }
+ else {
+ if (value == 0) {
+ BKE_collection_disable(scene_layer, layer_collection);
+ }
+ else {
+ BKE_reportf(reports, RPT_ERROR, "Layer collection '%s' is already enabled",
+ layer_collection->scene_collection->name);
+ }
+ }
+
+ DEG_relations_tag_update(bmain);
+ /* TODO(sergey): Use proper flag for tagging here. */
+ DEG_id_tag_update(&scene->id, 0);
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, scene);
+}
+
static int rna_LayerCollections_active_collection_index_get(PointerRNA *ptr)
{
SceneLayer *sl = (SceneLayer *)ptr->data;
@@ -2964,7 +2964,7 @@ static int rna_SceneLayer_objects_selected_skip(CollectionPropertyIterator *iter
Base *base = (Base *)internal->link;
if ((base->flag & BASE_SELECTED) != 0) {
- return 0;
+ return 0;
}
return 1;
@@ -3532,7 +3532,7 @@ static void rna_def_tool_settings(BlenderRNA *brna)
prop = RNA_def_property(srna, "uv_sculpt_tool", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "uv_sculpt_tool");
- RNA_def_property_enum_items(prop, uv_sculpt_tool_items);
+ RNA_def_property_enum_items(prop, rna_enum_uv_sculpt_tool_items);
RNA_def_property_ui_text(prop, "UV Sculpt Tools", "Select Tools for the UV sculpt brushes");
prop = RNA_def_property(srna, "uv_relax_method", PROP_ENUM, PROP_NONE);
@@ -6151,6 +6151,25 @@ static void rna_def_scene_layer_engine_settings_eevee(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
+ /* Keep in sync with eevee_private.h */
+ static EnumPropertyItem eevee_shadow_method_items[] = {
+ {1, "ESM", 0, "ESM", "Exponential Shadow Mapping"},
+ {2, "VSM", 0, "VSM", "Variance Shadow Mapping"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ static EnumPropertyItem eevee_shadow_size_items[] = {
+ {64, "64", 0, "64px", ""},
+ {128, "128", 0, "128px", ""},
+ {256, "256", 0, "256px", ""},
+ {512, "512", 0, "512px", ""},
+ {1024, "1024", 0, "1024px", ""},
+ {2048, "2048", 0, "2048px", ""},
+ {4096, "4096", 0, "4096px", ""},
+ {8192, "8192", 0, "8192px", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
srna = RNA_def_struct(brna, "SceneLayerEngineSettingsEevee", "SceneLayerSettings");
RNA_def_struct_ui_text(srna, "Eevee Scene Layer Settings", "Eevee Engine settings");
@@ -6158,6 +6177,175 @@ static void rna_def_scene_layer_engine_settings_eevee(BlenderRNA *brna)
/* see RNA_LAYER_ENGINE_GET_SET macro */
+ /* Indirect Lighting */
+ prop = RNA_def_property(srna, "gi_diffuse_bounces", PROP_INT, PROP_NONE);
+ RNA_def_property_int_funcs(prop, "rna_LayerEngineSettings_Eevee_gi_diffuse_bounces_get",
+ "rna_LayerEngineSettings_Eevee_gi_diffuse_bounces_set", NULL);
+ RNA_def_property_ui_text(prop, "Diffuse Bounces", "Number of time the light is reinjected inside light grids, "
+ "0 disable indirect diffuse light");
+ RNA_def_property_range(prop, 0, INT_MAX);
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+
+ /* Temporal Anti-Aliasing (super sampling) */
+ prop = RNA_def_property(srna, "taa_samples", PROP_INT, PROP_NONE);
+ RNA_def_property_int_funcs(prop, "rna_LayerEngineSettings_Eevee_taa_samples_get",
+ "rna_LayerEngineSettings_Eevee_taa_samples_set", NULL);
+ RNA_def_property_ui_text(prop, "Viewport Samples", "Number of temporal samples, unlimited if 0, "
+ "disabled if 1");
+ RNA_def_property_range(prop, 0, INT_MAX);
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+
+ /* Screen Space Reflection */
+ prop = RNA_def_property(srna, "ssr_enable", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_enable_get",
+ "rna_LayerEngineSettings_Eevee_ssr_enable_set");
+ RNA_def_property_ui_text(prop, "Screen Space Reflections", "Enable screen space reflection");
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+
+ prop = RNA_def_property(srna, "ssr_refraction", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_refraction_get",
+ "rna_LayerEngineSettings_Eevee_ssr_refraction_set");
+ RNA_def_property_ui_text(prop, "Screen Space Refractions", "Enable screen space Refractions");
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+
+ prop = RNA_def_property(srna, "ssr_halfres", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_halfres_get",
+ "rna_LayerEngineSettings_Eevee_ssr_halfres_set");
+ RNA_def_property_ui_text(prop, "Half Res Trace", "Raytrace at a lower resolution");
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+
+ prop = RNA_def_property(srna, "ssr_quality", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_quality_get",
+ "rna_LayerEngineSettings_Eevee_ssr_quality_set", NULL);
+ RNA_def_property_ui_text(prop, "Trace Quality", "Quality of the screen space raytracing");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+
+ prop = RNA_def_property(srna, "ssr_max_roughness", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_max_roughness_get",
+ "rna_LayerEngineSettings_Eevee_ssr_max_roughness_set", NULL);
+ RNA_def_property_ui_text(prop, "Max Roughness", "Do not raytrace reflections for roughness above this value");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+
+ prop = RNA_def_property(srna, "ssr_ray_count", PROP_INT, PROP_NONE);
+ RNA_def_property_int_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_ray_count_get",
+ "rna_LayerEngineSettings_Eevee_ssr_ray_count_set", NULL);
+ RNA_def_property_ui_text(prop, "Samples", "Number of rays to trace per pixels");
+ RNA_def_property_range(prop, 1, 4);
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+
+ prop = RNA_def_property(srna, "ssr_thickness", PROP_FLOAT, PROP_DISTANCE);
+ RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_thickness_get",
+ "rna_LayerEngineSettings_Eevee_ssr_thickness_set", NULL);
+ RNA_def_property_ui_text(prop, "Thickness", "Pixel thickness used to detect intersection");
+ RNA_def_property_range(prop, 1e-6f, FLT_MAX);
+ RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 5, 3);
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+
+ prop = RNA_def_property(srna, "ssr_border_fade", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_border_fade_get",
+ "rna_LayerEngineSettings_Eevee_ssr_border_fade_set", NULL);
+ RNA_def_property_ui_text(prop, "Edge Fading", "Screen percentage used to fade the SSR");
+ RNA_def_property_range(prop, 0.0f, 0.5f);
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+
+ prop = RNA_def_property(srna, "ssr_firefly_fac", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_firefly_fac_get",
+ "rna_LayerEngineSettings_Eevee_ssr_firefly_fac_set", NULL);
+ RNA_def_property_ui_text(prop, "Clamp", "Clamp pixel intensity to remove noise (0 to disabled)");
+ RNA_def_property_range(prop, 0.0f, FLT_MAX);
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+
+ /* Volumetrics */
+ prop = RNA_def_property(srna, "volumetric_enable", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_enable_get",
+ "rna_LayerEngineSettings_Eevee_volumetric_enable_set");
+ RNA_def_property_ui_text(prop, "Volumetrics", "Enable scattering and absorbance of volumetric material");
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+
+ prop = RNA_def_property(srna, "volumetric_start", PROP_FLOAT, PROP_DISTANCE);
+ RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_start_get",
+ "rna_LayerEngineSettings_Eevee_volumetric_start_set", NULL);
+ RNA_def_property_ui_text(prop, "Start", "Start distance of the volumetric effect");
+ RNA_def_property_range(prop, 1e-6f, FLT_MAX);
+ RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3);
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+
+ prop = RNA_def_property(srna, "volumetric_end", PROP_FLOAT, PROP_DISTANCE);
+ RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_end_get",
+ "rna_LayerEngineSettings_Eevee_volumetric_end_set", NULL);
+ RNA_def_property_ui_text(prop, "End", "End distance of the volumetric effect");
+ RNA_def_property_range(prop, 1e-6f, FLT_MAX);
+ RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3);
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+
+ prop = RNA_def_property(srna, "volumetric_samples", PROP_INT, PROP_NONE);
+ RNA_def_property_int_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_samples_get",
+ "rna_LayerEngineSettings_Eevee_volumetric_samples_set", NULL);
+ RNA_def_property_ui_text(prop, "Samples", "Number of samples to compute volumetric effects");
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_range(prop, 1, 256);
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+
+ prop = RNA_def_property(srna, "volumetric_sample_distribution", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_sample_distribution_get",
+ "rna_LayerEngineSettings_Eevee_volumetric_sample_distribution_set", NULL);
+ RNA_def_property_ui_text(prop, "Exponential Sampling", "Distribute more samples closer to the camera");
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+
+ prop = RNA_def_property(srna, "volumetric_lights", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_lights_get",
+ "rna_LayerEngineSettings_Eevee_volumetric_lights_set");
+ RNA_def_property_ui_text(prop, "Volumetric Lighting", "Enable scene lamps interactions with volumetrics");
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+
+ prop = RNA_def_property(srna, "volumetric_light_clamp", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_light_clamp_get",
+ "rna_LayerEngineSettings_Eevee_volumetric_light_clamp_set", NULL);
+ RNA_def_property_range(prop, 0.0f, FLT_MAX);
+ RNA_def_property_ui_text(prop, "Clamp", "Maximum light contribution, reducing noise");
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+
+ prop = RNA_def_property(srna, "volumetric_shadows", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_shadows_get",
+ "rna_LayerEngineSettings_Eevee_volumetric_shadows_set");
+ RNA_def_property_ui_text(prop, "Volumetric Shadows", "Generate shadows from volumetric material (Very expensive)");
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+
+ prop = RNA_def_property(srna, "volumetric_shadow_samples", PROP_INT, PROP_NONE);
+ RNA_def_property_int_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_shadow_samples_get",
+ "rna_LayerEngineSettings_Eevee_volumetric_shadow_samples_set", NULL);
+ RNA_def_property_range(prop, 1, 128);
+ RNA_def_property_ui_text(prop, "Volumetric Shadow Samples", "Number of samples to compute volumetric shadowing");
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+
+ prop = RNA_def_property(srna, "volumetric_colored_transmittance", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_colored_transmittance_get",
+ "rna_LayerEngineSettings_Eevee_volumetric_colored_transmittance_set");
+ RNA_def_property_ui_text(prop, "Colored Transmittance", "Enable wavelength dependent volumetric transmittance");
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+
/* Ambient Occlusion */
prop = RNA_def_property(srna, "gtao_enable", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_gtao_enable_get",
@@ -6173,11 +6361,33 @@ static void rna_def_scene_layer_engine_settings_eevee(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+ prop = RNA_def_property(srna, "gtao_denoise", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_gtao_denoise_get",
+ "rna_LayerEngineSettings_Eevee_gtao_denoise_set");
+ RNA_def_property_ui_text(prop, "Denoise", "Use denoising to filter the resulting occlusion and bent normal but exhibit 2x2 pixel blocks");
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+
+ prop = RNA_def_property(srna, "gtao_bounce", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_gtao_bounce_get",
+ "rna_LayerEngineSettings_Eevee_gtao_bounce_set");
+ RNA_def_property_ui_text(prop, "Bounces Approximation", "An approximation to simulate light bounces "
+ "giving less occlusion on brighter objects");
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+
prop = RNA_def_property(srna, "gtao_factor", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_gtao_factor_get", "rna_LayerEngineSettings_Eevee_gtao_factor_set", NULL);
RNA_def_property_ui_text(prop, "Factor", "Factor for ambient occlusion blending");
- RNA_def_property_range(prop, 0, FLT_MAX);
- RNA_def_property_ui_range(prop, 0.0, 1.0, 0.1, 2);
+ RNA_def_property_range(prop, 0.0f, FLT_MAX);
+ RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1f, 2);
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update");
+
+ prop = RNA_def_property(srna, "gtao_quality", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_gtao_quality_get", "rna_LayerEngineSettings_Eevee_gtao_quality_set", NULL);
+ RNA_def_property_ui_text(prop, "Trace Quality", "Quality of the horizon search");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update");
@@ -6240,6 +6450,14 @@ static void rna_def_scene_layer_engine_settings_eevee(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+ prop = RNA_def_property(srna, "bloom_color", PROP_FLOAT, PROP_COLOR);
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_bloom_color_get",
+ "rna_LayerEngineSettings_Eevee_bloom_color_set", NULL);
+ RNA_def_property_ui_text(prop, "Color", "Color applied to the bloom effect");
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+
prop = RNA_def_property(srna, "bloom_knee", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_bloom_knee_get",
"rna_LayerEngineSettings_Eevee_bloom_knee_set", NULL);
@@ -6257,6 +6475,15 @@ static void rna_def_scene_layer_engine_settings_eevee(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+ prop = RNA_def_property(srna, "bloom_clamp", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_bloom_clamp_get",
+ "rna_LayerEngineSettings_Eevee_bloom_clamp_set", NULL);
+ RNA_def_property_ui_text(prop, "Clamp", "Maximum intensity a bloom pixel can have");
+ RNA_def_property_range(prop, 0.0f, 1000.0f);
+ RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+
prop = RNA_def_property(srna, "bloom_intensity", PROP_FLOAT, PROP_UNSIGNED);
RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_bloom_intensity_get",
"rna_LayerEngineSettings_Eevee_bloom_intensity_set", NULL);
@@ -6290,6 +6517,27 @@ static void rna_def_scene_layer_engine_settings_eevee(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+ /* Shadows */
+ prop = RNA_def_property(srna, "shadow_method", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_funcs(prop, "rna_LayerEngineSettings_Eevee_shadow_method_get", "rna_LayerEngineSettings_Eevee_shadow_method_set", NULL);
+ RNA_def_property_enum_items(prop, eevee_shadow_method_items);
+ RNA_def_property_ui_text(prop, "Method", "Technique use to compute the shadows");
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+
+ prop = RNA_def_property(srna, "shadow_size", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_funcs(prop, "rna_LayerEngineSettings_Eevee_shadow_size_get", "rna_LayerEngineSettings_Eevee_shadow_size_set", NULL);
+ RNA_def_property_enum_items(prop, eevee_shadow_size_items);
+ RNA_def_property_ui_text(prop, "Size", "Size of every shadow maps");
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+
+ prop = RNA_def_property(srna, "shadow_high_bitdepth", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_shadow_high_bitdepth_get", "rna_LayerEngineSettings_Eevee_shadow_high_bitdepth_set");
+ RNA_def_property_ui_text(prop, "High Bitdepth", "Use 32bit shadows");
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+
RNA_define_verify_sdna(1); /* not in sdna */
}
@@ -6706,7 +6954,17 @@ static void rna_def_layer_collection(BlenderRNA *brna)
parm = RNA_def_boolean(func, "result", false, "Result", "Whether the operation succeded");
RNA_def_function_return(func, parm);
+ func = RNA_def_function(srna, "enable_set", "rna_LayerCollection_enable_set");
+ RNA_def_function_ui_description(func, "Enable or disable a collection");
+ parm = RNA_def_boolean(func, "value", 1, "Enable", "");
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
+
/* Flags */
+ prop = RNA_def_property(srna, "is_enabled", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", COLLECTION_DISABLED);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Enabled", "Enable or disable collection from depsgraph");
+
prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", COLLECTION_VISIBLE);
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
@@ -7561,106 +7819,6 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Audio Channels", "Audio channel count");
}
-#ifdef WITH_QUICKTIME
-static void rna_def_scene_quicktime_settings(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static EnumPropertyItem quicktime_codec_type_items[] = {
- {0, "codec", 0, "codec", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static EnumPropertyItem quicktime_audio_samplerate_items[] = {
- {22050, "22050", 0, "22kHz", ""},
- {44100, "44100", 0, "44.1kHz", ""},
- {48000, "48000", 0, "48kHz", ""},
- {88200, "88200", 0, "88.2kHz", ""},
- {96000, "96000", 0, "96kHz", ""},
- {192000, "192000", 0, "192kHz", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static EnumPropertyItem quicktime_audio_bitdepth_items[] = {
- {AUD_FORMAT_U8, "8BIT", 0, "8bit", ""},
- {AUD_FORMAT_S16, "16BIT", 0, "16bit", ""},
- {AUD_FORMAT_S24, "24BIT", 0, "24bit", ""},
- {AUD_FORMAT_S32, "32BIT", 0, "32bit", ""},
- {AUD_FORMAT_FLOAT32, "FLOAT32", 0, "float32", ""},
- {AUD_FORMAT_FLOAT64, "FLOAT64", 0, "float64", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static EnumPropertyItem quicktime_audio_bitrate_items[] = {
- {64000, "64000", 0, "64kbps", ""},
- {112000, "112000", 0, "112kpbs", ""},
- {128000, "128000", 0, "128kbps", ""},
- {192000, "192000", 0, "192kbps", ""},
- {256000, "256000", 0, "256kbps", ""},
- {320000, "320000", 0, "320kbps", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- /* QuickTime */
- srna = RNA_def_struct(brna, "QuickTimeSettings", NULL);
- RNA_def_struct_sdna(srna, "QuicktimeCodecSettings");
- RNA_def_struct_ui_text(srna, "QuickTime Settings", "QuickTime related settings for the scene");
-
- prop = RNA_def_property(srna, "codec_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_bitflag_sdna(prop, NULL, "codecType");
- RNA_def_property_enum_items(prop, quicktime_codec_type_items);
- RNA_def_property_enum_funcs(prop, "rna_RenderSettings_qtcodecsettings_codecType_get",
- "rna_RenderSettings_qtcodecsettings_codecType_set",
- "rna_RenderSettings_qtcodecsettings_codecType_itemf");
- RNA_def_property_ui_text(prop, "Codec", "QuickTime codec type");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
- prop = RNA_def_property(srna, "codec_spatial_quality", PROP_INT, PROP_PERCENTAGE);
- RNA_def_property_int_sdna(prop, NULL, "codecSpatialQuality");
- RNA_def_property_range(prop, 0, 100);
- RNA_def_property_ui_text(prop, "Spatial quality", "Intra-frame spatial quality level");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
- prop = RNA_def_property(srna, "audiocodec_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_bitflag_sdna(prop, NULL, "audiocodecType");
- RNA_def_property_enum_items(prop, quicktime_codec_type_items);
- RNA_def_property_enum_funcs(prop, "rna_RenderSettings_qtcodecsettings_audiocodecType_get",
- "rna_RenderSettings_qtcodecsettings_audiocodecType_set",
- "rna_RenderSettings_qtcodecsettings_audiocodecType_itemf");
- RNA_def_property_ui_text(prop, "Audio Codec", "QuickTime audio codec type");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
- prop = RNA_def_property(srna, "audio_samplerate", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_bitflag_sdna(prop, NULL, "audioSampleRate");
- RNA_def_property_enum_items(prop, quicktime_audio_samplerate_items);
- RNA_def_property_ui_text(prop, "Smp Rate", "Sample Rate");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
- prop = RNA_def_property(srna, "audio_bitdepth", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_bitflag_sdna(prop, NULL, "audioBitDepth");
- RNA_def_property_enum_items(prop, quicktime_audio_bitdepth_items);
- RNA_def_property_ui_text(prop, "Bit Depth", "Bit Depth");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
- prop = RNA_def_property(srna, "audio_resampling_hq", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "audioCodecFlags", QTAUDIO_FLAG_RESAMPLE_NOHQ);
- RNA_def_property_ui_text(prop, "HQ", "Use High Quality resampling algorithm");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
- prop = RNA_def_property(srna, "audio_codec_isvbr", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "audioCodecFlags", QTAUDIO_FLAG_CODEC_ISCBR);
- RNA_def_property_ui_text(prop, "VBR", "Use Variable Bit Rate compression (improves quality at same bitrate)");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
- prop = RNA_def_property(srna, "audio_bitrate", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_bitflag_sdna(prop, NULL, "audioBitRate");
- RNA_def_property_enum_items(prop, quicktime_audio_bitrate_items);
- RNA_def_property_ui_text(prop, "Bitrate", "Compressed audio bitrate");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-}
-#endif
-
static void rna_def_scene_render_data(BlenderRNA *brna)
{
StructRNA *srna;
@@ -7725,6 +7883,15 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}
};
+ static EnumPropertyItem pixel_size_items[] = {
+ {0, "AUTO", 0, "Automatic", "Automatic pixel size, depends on the UI scale"},
+ {1, "1", 0, "1x", "Render at full resolution"},
+ {2, "2", 0, "2x", "Render at 50% resolution"},
+ {4, "4", 0, "4x", "Render at 25% resolution"},
+ {8, "8", 0, "8x", "Render at 12.5% resolution"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
static EnumPropertyItem octree_resolution_items[] = {
{64, "64", 0, "64", ""},
{128, "128", 0, "128", ""},
@@ -7785,9 +7952,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
rna_def_scene_ffmpeg_settings(brna);
-#ifdef WITH_QUICKTIME
- rna_def_scene_quicktime_settings(brna);
-#endif
srna = RNA_def_struct(brna, "RenderSettings", NULL);
RNA_def_struct_sdna(srna, "RenderData");
@@ -7848,6 +8012,12 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
"progressively increasing it to the full viewport size");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+ prop = RNA_def_property(srna, "preview_pixel_size", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "preview_pixel_size");
+ RNA_def_property_enum_items(prop, pixel_size_items);
+ RNA_def_property_ui_text(prop, "Pixel Size", "Pixel size for viewport rendering");
+ RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderData_update");
+
prop = RNA_def_property(srna, "pixel_aspect_x", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "xasp");
RNA_def_property_flag(prop, PROP_PROPORTIONAL);
@@ -7866,14 +8036,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
"Vertical aspect ratio - for anamorphic or non-square pixel output");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneCamera_update");
-#ifdef WITH_QUICKTIME
- prop = RNA_def_property(srna, "quicktime", PROP_POINTER, PROP_NONE);
- RNA_def_property_struct_type(prop, "QuickTimeSettings");
- RNA_def_property_pointer_sdna(prop, NULL, "qtcodecsettings");
- RNA_def_property_flag(prop, PROP_NEVER_UNLINK);
- RNA_def_property_ui_text(prop, "QuickTime Settings", "QuickTime related settings for the scene");
-#endif
-
prop = RNA_def_property(srna, "ffmpeg", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "FFmpegSettings");
RNA_def_property_pointer_sdna(prop, NULL, "ffcodecdata");
@@ -8080,8 +8242,8 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
prop = RNA_def_property(srna, "motion_blur_shutter", PROP_FLOAT, PROP_UNSIGNED);
RNA_def_property_float_sdna(prop, NULL, "blurfac");
RNA_def_property_ui_range(prop, 0.01f, 2.0f, 1, 2);
- RNA_def_property_ui_text(prop, "Shutter", "Time taken in frames between shutter open and close");
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Shutter", "Time taken in frames between shutter open and close "
+ "(NOTE: Blender Internal does not support animated shutter)");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
prop = RNA_def_property(srna, "motion_blur_shutter_curve", PROP_POINTER, PROP_NONE);
@@ -8443,11 +8605,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
/* sequencer draw options */
- prop = RNA_def_property(srna, "use_sequencer_gl_preview", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "seq_flag", R_SEQ_GL_PREV);
- RNA_def_property_ui_text(prop, "Sequencer OpenGL", "");
- RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SceneSequencer_update");
-
#if 0 /* see R_SEQ_GL_REND comment */
prop = RNA_def_property(srna, "use_sequencer_gl_render", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "seq_flag", R_SEQ_GL_REND);
@@ -8460,10 +8617,13 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Sequencer Preview Shading", "Method to draw in the sequencer view");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SceneSequencer_update");
+#if 0 /* UNUSED, see R_SEQ_GL_REND comment */
prop = RNA_def_property(srna, "sequencer_gl_render", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "seq_rend_type");
RNA_def_property_enum_items(prop, rna_enum_viewport_shade_items);
+ /* XXX Label and tooltips are obviously wrong! */
RNA_def_property_ui_text(prop, "Sequencer Preview Shading", "Method to draw in the sequencer view");
+#endif
prop = RNA_def_property(srna, "use_sequencer_gl_textured_solid", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "seq_flag", R_SEQ_SOLID_TEX);
@@ -8906,7 +9066,7 @@ void RNA_def_scene(BlenderRNA *brna)
prop = RNA_def_property(srna, "world", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "World", "World used for rendering the scene");
- RNA_def_property_update(prop, NC_SCENE | ND_WORLD, "rna_Scene_glsl_update");
+ RNA_def_property_update(prop, NC_SCENE | ND_WORLD, "rna_Scene_world_update");
prop = RNA_def_property(srna, "cursor_location", PROP_FLOAT, PROP_XYZ_LENGTH);
RNA_def_property_float_sdna(prop, NULL, "cursor");
@@ -9288,6 +9448,7 @@ void RNA_def_scene(BlenderRNA *brna)
/* Dependency Graph */
prop = RNA_def_property(srna, "depsgraph", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "depsgraph_legacy");
RNA_def_property_struct_type(prop, "Depsgraph");
RNA_def_property_ui_text(prop, "Dependency Graph", "Dependencies in the scene data");
diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c
index 921e751fef6..a1ef3f17bd6 100644
--- a/source/blender/makesrna/intern/rna_scene_api.c
+++ b/source/blender/makesrna/intern/rna_scene_api.c
@@ -162,7 +162,6 @@ static void rna_Scene_ray_cast(
bool ret = ED_transform_snap_object_project_ray_ex(
sctx,
- SCE_SNAP_MODE_FACE,
&(const struct SnapObjectParams){
.snap_select = SNAP_ALL,
},
@@ -290,7 +289,12 @@ static void rna_Scene_collada_export(
int limit_precision,
int keep_bind_info)
{
- collada_export(scene,
+ EvaluationContext eval_ctx;
+
+ CTX_data_eval_ctx(C, &eval_ctx);
+
+ collada_export(&eval_ctx,
+ scene,
CTX_data_scene_layer(C),
filepath,
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index ec719d90ef6..cfe8670b0f5 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -28,6 +28,7 @@
#include <stdlib.h>
#include "RNA_define.h"
+#include "RNA_enum_types.h"
#include "rna_internal.h"
@@ -75,13 +76,15 @@ EnumPropertyItem rna_enum_gpencil_sculpt_brush_items[] = {
{ 0, NULL, 0, NULL, NULL }
};
-EnumPropertyItem rna_enum_gpencil_lockaxis_items[] = {
+#ifndef RNA_RUNTIME
+static EnumPropertyItem rna_enum_gpencil_lockaxis_items[] = {
{ GP_LOCKAXIS_NONE, "GP_LOCKAXIS_NONE", 0, "None", "" },
{ GP_LOCKAXIS_X, "GP_LOCKAXIS_X", 0, "X", "Project strokes to plane locked to X" },
{ GP_LOCKAXIS_Y, "GP_LOCKAXIS_Y", 0, "Y", "Project strokes to plane locked to Y" },
{ GP_LOCKAXIS_Z, "GP_LOCKAXIS_Z", 0, "Z", "Project strokes to plane locked to Z" },
{ 0, NULL, 0, NULL, NULL }
};
+#endif
EnumPropertyItem rna_enum_symmetrize_direction_items[] = {
{BMO_SYMMETRIZE_NEGATIVE_X, "NEGATIVE_X", 0, "-X to +X", ""},
@@ -153,7 +156,7 @@ static void rna_ParticleEdit_redo(bContext *C, PointerRNA *UNUSED(ptr))
{
Scene *scene = CTX_data_scene(C);
SceneLayer *sl = CTX_data_scene_layer(C);
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
PTCacheEdit *edit = PE_get_current(scene, sl, ob);
if (!edit)
@@ -165,7 +168,7 @@ static void rna_ParticleEdit_redo(bContext *C, PointerRNA *UNUSED(ptr))
static void rna_ParticleEdit_update(Main *UNUSED(bmain), Scene *UNUSED(scene), bContext *C, PointerRNA *UNUSED(ptr))
{
SceneLayer *sl = CTX_data_scene_layer(C);
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
if (ob) DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
}
@@ -189,7 +192,7 @@ static EnumPropertyItem *rna_ParticleEdit_tool_itemf(bContext *C, PointerRNA *UN
PropertyRNA *UNUSED(prop), bool *UNUSED(r_free))
{
SceneLayer *sl = CTX_data_scene_layer(C);
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
#if 0
Scene *scene = CTX_data_scene(C);
PTCacheEdit *edit = PE_get_current(scene, ob);
@@ -263,7 +266,7 @@ static void rna_Sculpt_update(bContext *C, PointerRNA *UNUSED(ptr))
{
Scene *scene = CTX_data_scene(C);
SceneLayer *sl = CTX_data_scene_layer(C);
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
if (ob) {
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -279,7 +282,7 @@ static void rna_Sculpt_update(bContext *C, PointerRNA *UNUSED(ptr))
static void rna_Sculpt_ShowDiffuseColor_update(bContext *C, Scene *scene, PointerRNA *UNUSED(ptr))
{
SceneLayer *sl = CTX_data_scene_layer(C);
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
if (ob && ob->sculpt) {
Sculpt *sd = scene->toolsettings->sculpt;
@@ -342,7 +345,7 @@ static void rna_ImaPaint_mode_update(bContext *C, PointerRNA *UNUSED(ptr))
{
Scene *scene = CTX_data_scene(C);\
SceneLayer *sl = CTX_data_scene_layer(C);
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
if (ob && ob->type == OB_MESH) {
/* of course we need to invalidate here */
@@ -359,7 +362,7 @@ static void rna_ImaPaint_stencil_update(bContext *C, PointerRNA *UNUSED(ptr))
{
Scene *scene = CTX_data_scene(C);
SceneLayer *sl = CTX_data_scene_layer(C);
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
if (ob && ob->type == OB_MESH) {
GPU_drawobject_free(ob->derivedFinal);
@@ -373,7 +376,7 @@ static void rna_ImaPaint_canvas_update(bContext *C, PointerRNA *UNUSED(ptr))
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
SceneLayer *sl = CTX_data_scene_layer(C);
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
bScreen *sc;
Image *ima = scene->toolsettings->imapaint.canvas;
@@ -687,22 +690,20 @@ static void rna_def_vertex_paint(BlenderRNA *brna)
RNA_def_struct_path_func(srna, "rna_VertexPaint_path");
RNA_def_struct_ui_text(srna, "Vertex Paint", "Properties of vertex and weight paint mode");
- /* vertex paint only */
- prop = RNA_def_property(srna, "use_normal", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", VP_NORMALS);
- RNA_def_property_ui_text(prop, "Normals", "Apply the vertex normal before painting");
- RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
-
- prop = RNA_def_property(srna, "use_spray", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", VP_SPRAY);
- RNA_def_property_ui_text(prop, "Spray", "Keep applying paint effect while holding mouse");
- RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
-
/* weight paint only */
prop = RNA_def_property(srna, "use_group_restrict", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", VP_ONLYVGROUP);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", VP_FLAG_VGROUP_RESTRICT);
RNA_def_property_ui_text(prop, "Restrict", "Restrict painting to vertices in the group");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
+
+ /* Mirroring */
+ prop = RNA_def_property(srna, "radial_symmetry", PROP_INT, PROP_XYZ);
+ RNA_def_property_int_sdna(prop, NULL, "radial_symm");
+ RNA_def_property_int_default(prop, 1);
+ RNA_def_property_range(prop, 1, 64);
+ RNA_def_property_ui_range(prop, 1, 32, 1, 1);
+ RNA_def_property_ui_text(prop, "Radial Symmetry Count X Axis",
+ "Number of times to copy strokes across the surface");
}
static void rna_def_image_paint(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c
index 6f8aa32da86..520a1c2f730 100644
--- a/source/blender/makesrna/intern/rna_sequencer.c
+++ b/source/blender/makesrna/intern/rna_sequencer.c
@@ -341,7 +341,7 @@ static void rna_Sequence_use_translation_set(PointerRNA *ptr, int value)
}
}
else {
- seq->flag ^= SEQ_USE_TRANSFORM;
+ seq->flag &= ~SEQ_USE_TRANSFORM;
}
}
@@ -355,7 +355,7 @@ static void rna_Sequence_use_crop_set(PointerRNA *ptr, int value)
}
}
else {
- seq->flag ^= SEQ_USE_CROP;
+ seq->flag &= ~SEQ_USE_CROP;
}
}
@@ -725,8 +725,9 @@ static void rna_Sequence_filepath_update(Main *bmain, Scene *UNUSED(scene), Poin
static void rna_Sequence_sound_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
Sequence *seq = (Sequence *) ptr->data;
-
- BKE_sound_update_scene_sound(seq->scene_sound, seq->sound);
+ if (seq->sound != NULL) {
+ BKE_sound_update_scene_sound(seq->scene_sound, seq->sound);
+ }
rna_Sequence_update(bmain, scene, ptr);
}
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 2af13103805..bf583654fc6 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -852,7 +852,7 @@ static int rna_SpaceImageEditor_show_maskedit_get(PointerRNA *ptr)
SpaceImage *sima = (SpaceImage *)(ptr->data);
bScreen *sc = (bScreen *)ptr->id.data;
Scene *scene = ED_screen_scene_find(sc, G.main->wm.first);
- SceneLayer *sl = BKE_scene_layer_context_active(scene);
+ SceneLayer *sl = BKE_scene_layer_context_active_PLACEHOLDER(scene);
return ED_space_image_check_show_maskedit(sl, sima);
}
@@ -1084,6 +1084,8 @@ static void rna_SpaceProperties_pin_id_update(Main *UNUSED(bmain), Scene *UNUSED
case ID_LA:
WM_main_add_notifier(NC_LAMP, NULL);
break;
+ default:
+ break;
}
}
@@ -1304,11 +1306,12 @@ static void rna_SpaceDopeSheetEditor_action_set(PointerRNA *ptr, PointerRNA valu
}
}
-static void rna_SpaceDopeSheetEditor_action_update(Main *bmain, bContext *C, Scene *UNUSED(scene), PointerRNA *ptr)
+static void rna_SpaceDopeSheetEditor_action_update(bContext *C, PointerRNA *ptr)
{
SpaceAction *saction = (SpaceAction *)(ptr->data);
SceneLayer *sl = CTX_data_scene_layer(C);
- Object *obact = OBACT_NEW;
+ Main *bmain = CTX_data_main(C);
+ Object *obact = OBACT_NEW(sl);
/* we must set this action to be the one used by active object (if not pinned) */
if (obact /* && saction->pin == 0*/) {
@@ -1384,7 +1387,7 @@ static void rna_SpaceDopeSheetEditor_mode_update(bContext *C, PointerRNA *ptr)
{
SpaceAction *saction = (SpaceAction *)(ptr->data);
SceneLayer *sl = CTX_data_scene_layer(C);
- Object *obact = OBACT_NEW;
+ Object *obact = OBACT_NEW(sl);
/* special exceptions for ShapeKey Editor mode */
if (saction->mode == SACTCONT_SHAPEKEY) {
@@ -2621,9 +2624,9 @@ static void rna_def_space_view3d(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Backface Culling", "Use back face culling to hide the back side of faces");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
- prop = RNA_def_property(srna, "show_textured_shadeless", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_SHADELESS_TEX);
- RNA_def_property_ui_text(prop, "Shadeless", "Show shadeless texture without lighting in textured draw mode");
+ prop = RNA_def_property(srna, "show_mode_shade_override", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_SHOW_MODE_SHADE_OVERRIDE);
+ RNA_def_property_ui_text(prop, "Full Shading", "Use full shading for mode drawing (to view final result)");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "show_occlude_wire", PROP_BOOLEAN, PROP_NONE);
@@ -2885,6 +2888,16 @@ static void rna_def_space_view3d(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Is Perspective", "");
RNA_def_property_flag(prop, PROP_EDITABLE);
+ /* This isn't directly accessible from the UI, only an operator. */
+ prop = RNA_def_property(srna, "use_clip_planes", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "rflag", RV3D_CLIPPING);
+ RNA_def_property_ui_text(prop, "Use Clip Planes", "");
+
+ prop = RNA_def_property(srna, "clip_planes", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "clip");
+ RNA_def_property_multi_array(prop, 2, (int[]){6, 4});
+ RNA_def_property_ui_text(prop, "Clip Planes", "");
+
prop = RNA_def_property(srna, "view_location", PROP_FLOAT, PROP_TRANSLATION);
#if 0
RNA_def_property_float_sdna(prop, NULL, "ofs"); /* cant use because its negated */
@@ -4654,7 +4667,7 @@ static void rna_def_space_clip(BlenderRNA *brna)
/* path length */
prop = RNA_def_property(srna, "path_length", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "path_length");
- RNA_def_property_range(prop, 0, 50);
+ RNA_def_property_range(prop, 0, INT_MAX);
RNA_def_property_ui_text(prop, "Path Length", "Length of displaying path, in frames");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
diff --git a/source/blender/makesrna/intern/rna_space_api.c b/source/blender/makesrna/intern/rna_space_api.c
index aabe421b872..822f5cbb4b6 100644
--- a/source/blender/makesrna/intern/rna_space_api.c
+++ b/source/blender/makesrna/intern/rna_space_api.c
@@ -36,20 +36,23 @@
#include "ED_screen.h"
#include "ED_text.h"
-static void rna_RegionView3D_update(ID *id, RegionView3D *rv3d)
+static void rna_RegionView3D_update(ID *id, RegionView3D *rv3d, bContext *C)
{
bScreen *sc = (bScreen *)id;
+ EvaluationContext eval_ctx;
ScrArea *sa;
ARegion *ar;
+ CTX_data_eval_ctx(C, &eval_ctx);
+
area_region_from_regiondata(sc, rv3d, &sa, &ar);
if (sa && ar && sa->spacetype == SPACE_VIEW3D) {
View3D *v3d = sa->spacedata.first;
Scene *scene = ED_screen_scene_find(sc, G.main->wm.first);
- ED_view3d_update_viewmat(scene, v3d, ar, NULL, NULL, NULL);
+ ED_view3d_update_viewmat(&eval_ctx, scene, v3d, ar, NULL, NULL, NULL);
}
}
@@ -73,7 +76,7 @@ void RNA_api_region_view3d(StructRNA *srna)
FunctionRNA *func;
func = RNA_def_function(srna, "update", "rna_RegionView3D_update");
- RNA_def_function_flag(func, FUNC_USE_SELF_ID);
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_CONTEXT);
RNA_def_function_ui_description(func, "Recalculate the view matrices");
}
diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c
index 1c7b750fbe1..9490dfd0478 100644
--- a/source/blender/makesrna/intern/rna_texture.c
+++ b/source/blender/makesrna/intern/rna_texture.c
@@ -270,6 +270,8 @@ void rna_TextureSlot_update(bContext *C, PointerRNA *ptr)
WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL);
break;
}
+ default:
+ break;
}
}
diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c
index 54b82fc89d6..08038b0b1ff 100644
--- a/source/blender/makesrna/intern/rna_ui.c
+++ b/source/blender/makesrna/intern/rna_ui.c
@@ -177,16 +177,17 @@ static void rna_Panel_unregister(Main *UNUSED(bmain), StructRNA *type)
return;
RNA_struct_free_extension(type, &pt->ext);
+ RNA_struct_free(&BLENDER_RNA, type);
BLI_freelinkN(&art->paneltypes, pt);
- RNA_struct_free(&BLENDER_RNA, type);
/* update while blender is running */
WM_main_add_notifier(NC_WINDOW, NULL);
}
-static StructRNA *rna_Panel_register(Main *bmain, ReportList *reports, void *data, const char *identifier,
- StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
+static StructRNA *rna_Panel_register(
+ Main *bmain, ReportList *reports, void *data, const char *identifier,
+ StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
{
ARegionType *art;
PanelType *pt, dummypt = {NULL};
@@ -229,6 +230,12 @@ static StructRNA *rna_Panel_register(Main *bmain, ReportList *reports, void *dat
break;
}
}
+ if (!RNA_struct_available_or_report(reports, dummypt.idname)) {
+ return NULL;
+ }
+ if (!RNA_struct_bl_idname_ok_or_report(reports, dummypt.idname, "_PT_")) {
+ return NULL;
+ }
/* create a new panel type */
pt = MEM_callocN(sizeof(PanelType), "python buttons panel");
@@ -455,17 +462,17 @@ static void rna_UIList_unregister(Main *UNUSED(bmain), StructRNA *type)
return;
RNA_struct_free_extension(type, &ult->ext);
+ RNA_struct_free(&BLENDER_RNA, type);
WM_uilisttype_freelink(ult);
- RNA_struct_free(&BLENDER_RNA, type);
-
/* update while blender is running */
WM_main_add_notifier(NC_WINDOW, NULL);
}
-static StructRNA *rna_UIList_register(Main *bmain, ReportList *reports, void *data, const char *identifier,
- StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
+static StructRNA *rna_UIList_register(
+ Main *bmain, ReportList *reports, void *data, const char *identifier,
+ StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
{
uiListType *ult, dummyult = {NULL};
uiList dummyuilist = {NULL};
@@ -489,8 +496,15 @@ static StructRNA *rna_UIList_register(Main *bmain, ReportList *reports, void *da
/* check if we have registered this uilist type before, and remove it */
ult = WM_uilisttype_find(dummyult.idname, true);
- if (ult && ult->ext.srna)
+ if (ult && ult->ext.srna) {
rna_UIList_unregister(bmain, ult->ext.srna);
+ }
+ if (!RNA_struct_available_or_report(reports, dummyult.idname)) {
+ return NULL;
+ }
+ if (!RNA_struct_bl_idname_ok_or_report(reports, dummyult.idname, "_UL_")) {
+ return NULL;
+ }
/* create a new menu type */
ult = MEM_callocN(sizeof(uiListType) + over_alloc, "python uilist");
@@ -551,16 +565,17 @@ static void rna_Header_unregister(Main *UNUSED(bmain), StructRNA *type)
return;
RNA_struct_free_extension(type, &ht->ext);
+ RNA_struct_free(&BLENDER_RNA, type);
BLI_freelinkN(&art->headertypes, ht);
- RNA_struct_free(&BLENDER_RNA, type);
/* update while blender is running */
WM_main_add_notifier(NC_WINDOW, NULL);
}
-static StructRNA *rna_Header_register(Main *bmain, ReportList *reports, void *data, const char *identifier,
- StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
+static StructRNA *rna_Header_register(
+ Main *bmain, ReportList *reports, void *data, const char *identifier,
+ StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
{
ARegionType *art;
HeaderType *ht, dummyht = {NULL};
@@ -593,6 +608,12 @@ static StructRNA *rna_Header_register(Main *bmain, ReportList *reports, void *da
break;
}
}
+ if (!RNA_struct_available_or_report(reports, dummyht.idname)) {
+ return NULL;
+ }
+ if (!RNA_struct_bl_idname_ok_or_report(reports, dummyht.idname, "_HT_")) {
+ return NULL;
+ }
/* create a new header type */
ht = MEM_callocN(sizeof(HeaderType), "python buttons header");
@@ -673,17 +694,17 @@ static void rna_Menu_unregister(Main *UNUSED(bmain), StructRNA *type)
return;
RNA_struct_free_extension(type, &mt->ext);
+ RNA_struct_free(&BLENDER_RNA, type);
WM_menutype_freelink(mt);
- RNA_struct_free(&BLENDER_RNA, type);
-
/* update while blender is running */
WM_main_add_notifier(NC_WINDOW, NULL);
}
-static StructRNA *rna_Menu_register(Main *bmain, ReportList *reports, void *data, const char *identifier,
- StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
+static StructRNA *rna_Menu_register(
+ Main *bmain, ReportList *reports, void *data, const char *identifier,
+ StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
{
MenuType *mt, dummymt = {NULL};
Menu dummymenu = {NULL};
@@ -714,8 +735,15 @@ static StructRNA *rna_Menu_register(Main *bmain, ReportList *reports, void *data
/* check if we have registered this menu type before, and remove it */
mt = WM_menutype_find(dummymt.idname, true);
- if (mt && mt->ext.srna)
+ if (mt && mt->ext.srna) {
rna_Menu_unregister(bmain, mt->ext.srna);
+ }
+ if (!RNA_struct_available_or_report(reports, dummymt.idname)) {
+ return NULL;
+ }
+ if (!RNA_struct_bl_idname_ok_or_report(reports, dummymt.idname, "_MT_")) {
+ return NULL;
+ }
/* create a new menu type */
if (_menu_descr[0]) {
@@ -937,6 +965,7 @@ static void rna_def_panel(BlenderRNA *brna)
RNA_def_struct_refine_func(srna, "rna_Panel_refine");
RNA_def_struct_register_funcs(srna, "rna_Panel_register", "rna_Panel_unregister", NULL);
RNA_def_struct_translation_context(srna, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
+ RNA_def_struct_flag(srna, STRUCT_PUBLIC_NAMESPACE_INHERIT);
/* poll */
func = RNA_def_function(srna, "poll", NULL);
@@ -1039,7 +1068,7 @@ static void rna_def_uilist(BlenderRNA *brna)
RNA_def_struct_refine_func(srna, "rna_UIList_refine");
RNA_def_struct_register_funcs(srna, "rna_UIList_register", "rna_UIList_unregister", NULL);
RNA_def_struct_idprops_func(srna, "rna_UIList_idprops");
- RNA_def_struct_flag(srna, STRUCT_NO_DATABLOCK_IDPROPERTIES);
+ RNA_def_struct_flag(srna, STRUCT_NO_DATABLOCK_IDPROPERTIES | STRUCT_PUBLIC_NAMESPACE_INHERIT);
/* Registration */
prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
@@ -1161,6 +1190,7 @@ static void rna_def_header(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "Header");
RNA_def_struct_refine_func(srna, "rna_Header_refine");
RNA_def_struct_register_funcs(srna, "rna_Header_register", "rna_Header_unregister", NULL);
+ RNA_def_struct_flag(srna, STRUCT_PUBLIC_NAMESPACE_INHERIT);
/* draw */
func = RNA_def_function(srna, "draw", NULL);
@@ -1208,6 +1238,7 @@ static void rna_def_menu(BlenderRNA *brna)
RNA_def_struct_refine_func(srna, "rna_Menu_refine");
RNA_def_struct_register_funcs(srna, "rna_Menu_register", "rna_Menu_unregister", NULL);
RNA_def_struct_translation_context(srna, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
+ RNA_def_struct_flag(srna, STRUCT_PUBLIC_NAMESPACE_INHERIT);
/* poll */
func = RNA_def_function(srna, "poll", NULL);
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c
index b6abc417651..fd7346379a1 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -60,7 +60,7 @@ EnumPropertyItem rna_enum_icon_items[] = {
#ifdef RNA_RUNTIME
-static const char *rna_translate_ui_text(const char *text, const char *text_ctxt, StructRNA *type, PropertyRNA *prop,
+const char *rna_translate_ui_text(const char *text, const char *text_ctxt, StructRNA *type, PropertyRNA *prop,
int translate)
{
/* Also return text if UI labels translation is disabled. */
@@ -918,6 +918,7 @@ void RNA_api_ui_layout(StructRNA *srna)
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
parm = RNA_def_string(func, "property", NULL, 0, "", "Identifier of property in collection_properties");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ api_ui_item_common(func);
parm = RNA_def_string(func, "custom_template", NULL, 0, "", "Optional template to use for property");
func = RNA_def_function(srna, "template_component_menu", "uiTemplateComponentMenu");
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index af77d037b69..d5f488d549e 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -66,16 +66,7 @@ static EnumPropertyItem opensubdiv_compute_type_items[] = {
#endif
static EnumPropertyItem audio_device_items[] = {
- {0, "NONE", 0, "None", "Null device - there will be no audio output"},
-#ifdef WITH_SDL
- {1, "SDL", 0, "SDL", "SDL device - simple direct media layer, recommended for sequencer usage"},
-#endif
-#ifdef WITH_OPENAL
- {2, "OPENAL", 0, "OpenAL", "OpenAL device - supports 3D audio, recommended for game engine usage"},
-#endif
-#ifdef WITH_JACK
- {3, "JACK", 0, "JACK", "JACK Audio Connection Kit, recommended for pro audio users"},
-#endif
+ {0, "Null", 0, "None", "Null device - there will be no audio output"},
{0, NULL, 0, NULL, NULL}
};
@@ -519,7 +510,6 @@ static EnumPropertyItem *rna_userdef_audio_device_itemf(bContext *UNUSED(C), Poi
int totitem = 0;
EnumPropertyItem *item = NULL;
-#ifdef WITH_SYSTEM_AUDASPACE
int i;
char **names = BKE_sound_get_device_names();
@@ -528,31 +518,6 @@ static EnumPropertyItem *rna_userdef_audio_device_itemf(bContext *UNUSED(C), Poi
EnumPropertyItem new_item = {i, names[i], 0, names[i], names[i]};
RNA_enum_item_add(&item, &totitem, &new_item);
}
-#else
- /* NONE */
- RNA_enum_item_add(&item, &totitem, &audio_device_items[index++]);
-
-#ifdef WITH_SDL
-# ifdef WITH_SDL_DYNLOAD
- if (sdlewInit() == SDLEW_SUCCESS)
-# endif
- {
- RNA_enum_item_add(&item, &totitem, &audio_device_items[index]);
- }
- index++;
-#endif
-
-#ifdef WITH_OPENAL
- RNA_enum_item_add(&item, &totitem, &audio_device_items[index++]);
-#endif
-
-#ifdef WITH_JACK
- if (BKE_sound_is_jack_supported()) {
- RNA_enum_item_add(&item, &totitem, &audio_device_items[index]);
- }
- index++;
-#endif
-#endif
/* may be unused */
UNUSED_VARS(index, audio_device_items);
@@ -609,16 +574,17 @@ static void rna_AddonPref_unregister(Main *UNUSED(bmain), StructRNA *type)
return;
RNA_struct_free_extension(type, &apt->ext);
+ RNA_struct_free(&BLENDER_RNA, type);
BKE_addon_pref_type_remove(apt);
- RNA_struct_free(&BLENDER_RNA, type);
/* update while blender is running */
WM_main_add_notifier(NC_WINDOW, NULL);
}
-static StructRNA *rna_AddonPref_register(Main *bmain, ReportList *reports, void *data, const char *identifier,
- StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
+static StructRNA *rna_AddonPref_register(
+ Main *bmain, ReportList *reports, void *data, const char *identifier,
+ StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
{
bAddonPrefType *apt, dummyapt = {{'\0'}};
bAddon dummyaddon = {NULL};
@@ -641,10 +607,8 @@ static StructRNA *rna_AddonPref_register(Main *bmain, ReportList *reports, void
/* check if we have registered this header type before, and remove it */
apt = BKE_addon_pref_type_find(dummyaddon.module, true);
- if (apt) {
- if (apt->ext.srna) {
- rna_AddonPref_unregister(bmain, apt->ext.srna);
- }
+ if (apt && apt->ext.srna) {
+ rna_AddonPref_unregister(bmain, apt->ext.srna);
}
/* create a new header type */
@@ -1074,6 +1038,37 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna)
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Z Axis", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
+
+ /* Generic manipulator colors. */
+ prop = RNA_def_property(srna, "manipulator_hi", PROP_FLOAT, PROP_COLOR_GAMMA);
+ RNA_def_property_float_sdna(prop, NULL, "manipulator_hi");
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_ui_text(prop, "Manipulator Highlight", "");
+ RNA_def_property_update(prop, 0, "rna_userdef_update");
+
+ prop = RNA_def_property(srna, "manipulator_primary", PROP_FLOAT, PROP_COLOR_GAMMA);
+ RNA_def_property_float_sdna(prop, NULL, "manipulator_primary");
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_ui_text(prop, "Manipulator Primary", "");
+ RNA_def_property_update(prop, 0, "rna_userdef_update");
+
+ prop = RNA_def_property(srna, "manipulator_secondary", PROP_FLOAT, PROP_COLOR_GAMMA);
+ RNA_def_property_float_sdna(prop, NULL, "manipulator_secondary");
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_ui_text(prop, "Manipulator Secondary", "");
+ RNA_def_property_update(prop, 0, "rna_userdef_update");
+
+ prop = RNA_def_property(srna, "manipulator_a", PROP_FLOAT, PROP_COLOR_GAMMA);
+ RNA_def_property_float_sdna(prop, NULL, "manipulator_a");
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_ui_text(prop, "Manipulator A", "");
+ RNA_def_property_update(prop, 0, "rna_userdef_update");
+
+ prop = RNA_def_property(srna, "manipulator_b", PROP_FLOAT, PROP_COLOR_GAMMA);
+ RNA_def_property_float_sdna(prop, NULL, "manipulator_b");
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_ui_text(prop, "Manipulator B", "");
+ RNA_def_property_update(prop, 0, "rna_userdef_update");
}
static void rna_def_userdef_theme_space_common(StructRNA *srna)
@@ -1277,7 +1272,7 @@ static void rna_def_userdef_theme_spaces_vertex(StructRNA *srna)
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop = RNA_def_property(srna, "vertex_size", PROP_INT, PROP_NONE);
- RNA_def_property_range(prop, 1, 10);
+ RNA_def_property_range(prop, 1, 32);
RNA_def_property_ui_text(prop, "Vertex Size", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
@@ -1499,7 +1494,7 @@ static void rna_def_userdef_theme_spaces_curves(StructRNA *srna, bool incl_nurbs
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop = RNA_def_property(srna, "handle_vertex_size", PROP_INT, PROP_NONE);
- RNA_def_property_range(prop, 0, 255);
+ RNA_def_property_range(prop, 1, 100);
RNA_def_property_ui_text(prop, "Handle Vertex Size", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
}
@@ -3307,6 +3302,13 @@ static void rna_def_userdef_view(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}
};
+ static EnumPropertyItem line_width[] = {
+ {-1, "THIN", 0, "Thin", "Thinner lines than the default"},
+ { 0, "AUTO", 0, "Auto", "Automatic line width based on UI scale"},
+ { 1, "THICK", 0, "Thick", "Thicker lines than the default"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
PropertyRNA *prop;
StructRNA *srna;
@@ -3324,6 +3326,12 @@ static void rna_def_userdef_view(BlenderRNA *brna)
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_update(prop, 0, "rna_userdef_dpi_update");
+ prop = RNA_def_property(srna, "ui_line_width", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, line_width);
+ RNA_def_property_ui_text(prop, "UI Line Width",
+ "Changes the thickness of lines and points in the interface");
+ RNA_def_property_update(prop, 0, "rna_userdef_dpi_update");
+
/* display */
prop = RNA_def_property(srna, "show_tooltips", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_TOOLTIPS);
@@ -3443,6 +3451,11 @@ static void rna_def_userdef_view(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Cursor Depth",
"Use the depth under the mouse when placing the cursor");
+ prop = RNA_def_property(srna, "use_cursor_lock_adjust", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_LOCK_CURSOR_ADJUST);
+ RNA_def_property_ui_text(prop, "Cursor Lock Adjust",
+ "Place the cursor without 'jumping' to the new location (when lock-to-cursor is used)");
+
prop = RNA_def_property(srna, "use_camera_lock_parent", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "uiflag", USER_CAM_LOCK_NO_PARENT);
RNA_def_property_ui_text(prop, "Camera Parent Lock",
@@ -3919,12 +3932,18 @@ static void rna_def_userdef_system(BlenderRNA *brna)
prop = RNA_def_property(srna, "dpi", PROP_INT, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "DPI", "Font size and resolution for display");
+ RNA_def_property_ui_text(prop, "DPI",
+ "DPI for add-ons to use when drawing custom user interface elements, controlled by "
+ "operating system settings and Blender UI scale, with a reference value of 72 DPI "
+ "(note that since this value includes a user defined scale, it is not always the "
+ "actual monitor DPI)");
prop = RNA_def_property(srna, "pixel_size", PROP_FLOAT, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_float_sdna(prop, NULL, "pixelsize");
- RNA_def_property_ui_text(prop, "Pixel Size", "");
+ RNA_def_property_ui_text(prop, "Pixel Size",
+ "Suggested line thickness and point size in pixels, for add-ons drawing custom user "
+ "interface elements, controlled by operating system settings and Blender UI scale");
prop = RNA_def_property(srna, "font_path_ui", PROP_STRING, PROP_FILEPATH);
RNA_def_property_string_sdna(prop, NULL, "font_path_ui");
@@ -3972,11 +3991,6 @@ static void rna_def_userdef_system(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Translate New Names", "Translate new data names (when adding/creating some)");
RNA_def_property_update(prop, 0, "rna_userdef_update");
- prop = RNA_def_property(srna, "use_textured_fonts", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "transopts", USER_USETEXTUREFONT);
- RNA_def_property_ui_text(prop, "Textured Fonts", "Use textures for drawing international fonts");
- RNA_def_property_update(prop, 0, "rna_userdef_update");
-
/* System & OpenGL */
prop = RNA_def_property(srna, "solid_lights", PROP_COLLECTION, PROP_NONE);
@@ -4164,6 +4178,7 @@ static void rna_def_userdef_system(BlenderRNA *brna)
RNA_def_property_enum_items(prop, multi_sample_levels);
RNA_def_property_ui_text(prop, "MultiSample",
"Enable OpenGL multi-sampling, only for systems that support it, requires restart");
+ RNA_def_property_update(prop, 0, "rna_userdef_dpi_update");
prop = RNA_def_property(srna, "use_region_overlap", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "uiflag2", USER_REGION_OVERLAP);
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index fe30890d5ba..689a6406375 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -32,6 +32,7 @@
#include "DNA_windowmanager_types.h"
#include "BLI_utildefines.h"
+#include "BLI_string_utils.h"
#include "BLT_translation.h"
@@ -1216,8 +1217,8 @@ static StructRNA *rna_Operator_register(
struct {
char idname[OP_MAX_TYPENAME];
char name[OP_MAX_TYPENAME];
- char descr[RNA_DYN_DESCR_MAX];
- char ctxt[RNA_DYN_DESCR_MAX];
+ char description[RNA_DYN_DESCR_MAX];
+ char translation_context[RNA_DYN_DESCR_MAX];
char undo_group[OP_MAX_TYPENAME];
} temp_buffers;
@@ -1225,92 +1226,57 @@ static StructRNA *rna_Operator_register(
dummyop.type = &dummyot;
dummyot.idname = temp_buffers.idname; /* only assigne the pointer, string is NULL'd */
dummyot.name = temp_buffers.name; /* only assigne the pointer, string is NULL'd */
- dummyot.description = temp_buffers.descr; /* only assigne the pointer, string is NULL'd */
- dummyot.translation_context = temp_buffers.ctxt; /* only assigne the pointer, string is NULL'd */
+ dummyot.description = temp_buffers.description; /* only assigne the pointer, string is NULL'd */
+ dummyot.translation_context = temp_buffers.translation_context; /* only assigne the pointer, string is NULL'd */
dummyot.undo_group = temp_buffers.undo_group; /* only assigne the pointer, string is NULL'd */
RNA_pointer_create(NULL, &RNA_Operator, &dummyop, &dummyotr);
/* clear in case they are left unset */
- temp_buffers.idname[0] = temp_buffers.name[0] = temp_buffers.descr[0] = temp_buffers.undo_group[0] = '\0';
+ temp_buffers.idname[0] = temp_buffers.name[0] = temp_buffers.description[0] = temp_buffers.undo_group[0] = '\0';
/* We have to set default op context! */
- strcpy(temp_buffers.ctxt, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
+ strcpy(temp_buffers.translation_context, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
/* validate the python class */
if (validate(&dummyotr, data, have_function) != 0)
return NULL;
- { /* convert foo.bar to FOO_OT_bar
- * allocate the description and the idname in 1 go */
-
- /* inconveniently long name sanity check */
- {
- char *ch = temp_buffers.idname;
- int i;
- int dot = 0;
- for (i = 0; *ch; i++) {
- if ((*ch >= 'a' && *ch <= 'z') || (*ch >= '0' && *ch <= '9') || *ch == '_') {
- /* pass */
- }
- else if (*ch == '.') {
- dot++;
- }
- else {
- BKE_reportf(reports, RPT_ERROR,
- "Registering operator class: '%s', invalid bl_idname '%s', at position %d",
- identifier, temp_buffers.idname, i);
- return NULL;
- }
+ /* check if we have registered this operator type before, and remove it */
+ {
+ wmOperatorType *ot = WM_operatortype_find(dummyot.idname, true);
+ if (ot && ot->ext.srna)
+ rna_Operator_unregister(bmain, ot->ext.srna);
+ }
- ch++;
- }
+ if (!WM_operator_py_idname_ok_or_report(reports, identifier, dummyot.idname)) {
+ return NULL;
+ }
- if (i > ((int)sizeof(dummyop.idname)) - 3) {
- BKE_reportf(reports, RPT_ERROR, "Registering operator class: '%s', invalid bl_idname '%s', "
- "is too long, maximum length is %d", identifier, temp_buffers.idname,
- (int)sizeof(dummyop.idname) - 3);
- return NULL;
- }
+ char idname_conv[sizeof(dummyop.idname)];
+ WM_operator_bl_idname(idname_conv, dummyot.idname); /* convert the idname from python */
- if (dot != 1) {
- BKE_reportf(reports, RPT_ERROR,
- "Registering operator class: '%s', invalid bl_idname '%s', must contain 1 '.' character",
- identifier, temp_buffers.idname);
- return NULL;
- }
- }
- /* end sanity check */
-
- {
- const uint idname_len = strlen(temp_buffers.idname) + 4;
- const uint name_len = strlen(temp_buffers.name) + 1;
- const uint desc_len = strlen(temp_buffers.descr) + 1;
- const uint ctxt_len = strlen(temp_buffers.ctxt) + 1;
- const uint undo_group_len = strlen(temp_buffers.undo_group) + 1;
- /* 2 terminators and 3 to convert a.b -> A_OT_b */
- char *ch = MEM_mallocN(
- sizeof(char) * (idname_len + name_len + desc_len + ctxt_len + undo_group_len), __func__);
- WM_operator_bl_idname(ch, temp_buffers.idname); /* convert the idname from python */
- dummyot.idname = ch;
- ch += idname_len;
- memcpy(ch, temp_buffers.name, name_len);
- dummyot.name = ch;
- ch += name_len;
- memcpy(ch, temp_buffers.descr, desc_len);
- dummyot.description = ch;
- ch += desc_len;
- memcpy(ch, temp_buffers.ctxt, ctxt_len);
- dummyot.translation_context = ch;
- ch += ctxt_len;
- memcpy(ch, temp_buffers.undo_group, undo_group_len);
- dummyot.undo_group = ch;
- }
+ if (!RNA_struct_available_or_report(reports, idname_conv)) {
+ return NULL;
}
- /* check if we have registered this operator type before, and remove it */
+ /* Convert foo.bar to FOO_OT_bar
+ * allocate all strings at once. */
{
- wmOperatorType *ot = WM_operatortype_find(dummyot.idname, true);
- if (ot && ot->ext.srna)
- rna_Operator_unregister(bmain, ot->ext.srna);
+ const char *strings[] = {
+ idname_conv,
+ temp_buffers.name,
+ temp_buffers.description,
+ temp_buffers.translation_context,
+ temp_buffers.undo_group,
+ };
+ char *strings_table[ARRAY_SIZE(strings)];
+ BLI_string_join_array_by_sep_char_with_tableN('\0', strings_table, strings, ARRAY_SIZE(strings));
+
+ dummyot.idname = strings_table[0]; /* allocated string stored here */
+ dummyot.name = strings_table[1];
+ dummyot.description = strings_table[2];
+ dummyot.translation_context = strings_table[3];
+ dummyot.undo_group = strings_table[4];
+ BLI_assert(ARRAY_SIZE(strings) == 5);
}
/* XXX, this doubles up with the operator name [#29666]
@@ -1361,10 +1327,11 @@ static void rna_Operator_unregister(struct Main *bmain, StructRNA *type)
idname = ot->idname;
WM_operatortype_remove_ptr(ot);
- MEM_freeN((void *)idname);
/* not to be confused with the RNA_struct_free that WM_operatortype_remove calls, they are 2 different srna's */
RNA_struct_free(&BLENDER_RNA, type);
+
+ MEM_freeN((void *)idname);
}
static void **rna_Operator_instance(PointerRNA *ptr)
@@ -1385,8 +1352,8 @@ static StructRNA *rna_MacroOperator_register(
struct {
char idname[OP_MAX_TYPENAME];
char name[OP_MAX_TYPENAME];
- char descr[RNA_DYN_DESCR_MAX];
- char ctxt[RNA_DYN_DESCR_MAX];
+ char description[RNA_DYN_DESCR_MAX];
+ char translation_context[RNA_DYN_DESCR_MAX];
char undo_group[OP_MAX_TYPENAME];
} temp_buffers;
@@ -1394,15 +1361,15 @@ static StructRNA *rna_MacroOperator_register(
dummyop.type = &dummyot;
dummyot.idname = temp_buffers.idname; /* only assigne the pointer, string is NULL'd */
dummyot.name = temp_buffers.name; /* only assigne the pointer, string is NULL'd */
- dummyot.description = temp_buffers.descr; /* only assigne the pointer, string is NULL'd */
- dummyot.translation_context = temp_buffers.ctxt; /* only assigne the pointer, string is NULL'd */
+ dummyot.description = temp_buffers.description; /* only assigne the pointer, string is NULL'd */
+ dummyot.translation_context = temp_buffers.translation_context; /* only assigne the pointer, string is NULL'd */
dummyot.undo_group = temp_buffers.undo_group; /* only assigne the pointer, string is NULL'd */
RNA_pointer_create(NULL, &RNA_Macro, &dummyop, &dummyotr);
/* clear in case they are left unset */
- temp_buffers.idname[0] = temp_buffers.name[0] = temp_buffers.descr[0] = temp_buffers.undo_group[0] = '\0';
+ temp_buffers.idname[0] = temp_buffers.name[0] = temp_buffers.description[0] = temp_buffers.undo_group[0] = '\0';
/* We have to set default op context! */
- strcpy(temp_buffers.ctxt, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
+ strcpy(temp_buffers.translation_context, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
/* validate the python class */
if (validate(&dummyotr, data, have_function) != 0)
@@ -1414,32 +1381,6 @@ static StructRNA *rna_MacroOperator_register(
return NULL;
}
- { /* convert foo.bar to FOO_OT_bar
- * allocate the description and the idname in 1 go */
- const uint idname_len = strlen(temp_buffers.idname) + 4;
- const uint name_len = strlen(temp_buffers.name) + 1;
- const uint desc_len = strlen(temp_buffers.descr) + 1;
- const uint ctxt_len = strlen(temp_buffers.ctxt) + 1;
- const uint undo_group_len = strlen(temp_buffers.undo_group) + 1;
- /* 2 terminators and 3 to convert a.b -> A_OT_b */
- char *ch = MEM_mallocN(
- sizeof(char) * (idname_len + name_len + desc_len + ctxt_len + undo_group_len), __func__);
- WM_operator_bl_idname(ch, temp_buffers.idname); /* convert the idname from python */
- dummyot.idname = ch;
- ch += idname_len;
- memcpy(ch, temp_buffers.name, name_len);
- dummyot.name = ch;
- ch += name_len;
- memcpy(ch, temp_buffers.descr, desc_len);
- dummyot.description = ch;
- ch += desc_len;
- memcpy(ch, temp_buffers.ctxt, ctxt_len);
- dummyot.translation_context = ch;
- ch += ctxt_len;
- memcpy(ch, temp_buffers.undo_group, undo_group_len);
- dummyot.undo_group = ch;
- }
-
/* check if we have registered this operator type before, and remove it */
{
wmOperatorType *ot = WM_operatortype_find(dummyot.idname, true);
@@ -1447,6 +1388,38 @@ static StructRNA *rna_MacroOperator_register(
rna_Operator_unregister(bmain, ot->ext.srna);
}
+ if (!WM_operator_py_idname_ok_or_report(reports, identifier, dummyot.idname)) {
+ return NULL;
+ }
+
+ char idname_conv[sizeof(dummyop.idname)];
+ WM_operator_bl_idname(idname_conv, dummyot.idname); /* convert the idname from python */
+
+ if (!RNA_struct_available_or_report(reports, idname_conv)) {
+ return NULL;
+ }
+
+ /* Convert foo.bar to FOO_OT_bar
+ * allocate all strings at once. */
+ {
+ const char *strings[] = {
+ idname_conv,
+ temp_buffers.name,
+ temp_buffers.description,
+ temp_buffers.translation_context,
+ temp_buffers.undo_group,
+ };
+ char *strings_table[ARRAY_SIZE(strings)];
+ BLI_string_join_array_by_sep_char_with_tableN('\0', strings_table, strings, ARRAY_SIZE(strings));
+
+ dummyot.idname = strings_table[0]; /* allocated string stored here */
+ dummyot.name = strings_table[1];
+ dummyot.description = strings_table[2];
+ dummyot.translation_context = strings_table[3];
+ dummyot.undo_group = strings_table[4];
+ BLI_assert(ARRAY_SIZE(strings) == 5);
+ }
+
/* XXX, this doubles up with the operator name [#29666]
* for now just remove from dir(bpy.types) */
@@ -1580,6 +1553,7 @@ static void rna_def_operator(BlenderRNA *brna)
RNA_def_struct_register_funcs(srna, "rna_Operator_register", "rna_Operator_unregister", "rna_Operator_instance");
#endif
RNA_def_struct_translation_context(srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
+ RNA_def_struct_flag(srna, STRUCT_PUBLIC_NAMESPACE_INHERIT);
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
@@ -1683,6 +1657,7 @@ static void rna_def_macro_operator(BlenderRNA *brna)
"rna_Operator_instance");
#endif
RNA_def_struct_translation_context(srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
+ RNA_def_struct_flag(srna, STRUCT_PUBLIC_NAMESPACE_INHERIT);
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c
index 166b6f96956..b9f0ae22fd2 100644
--- a/source/blender/makesrna/intern/rna_wm_api.c
+++ b/source/blender/makesrna/intern/rna_wm_api.c
@@ -136,7 +136,7 @@ static void rna_manipulator_group_type_add(ReportList *reports, const char *idna
{
wmManipulatorGroupType *wgt = wm_manipulatorgrouptype_find_for_add_remove(reports, idname);
if (wgt != NULL) {
- WM_manipulator_group_add_ptr(wgt);
+ WM_manipulator_group_type_add_ptr(wgt);
}
}
@@ -144,7 +144,7 @@ static void rna_manipulator_group_type_remove(Main *bmain, ReportList *reports,
{
wmManipulatorGroupType *wgt = wm_manipulatorgrouptype_find_for_add_remove(reports, idname);
if (wgt != NULL) {
- WM_manipulator_group_remove_ptr(bmain, wgt);
+ WM_manipulator_group_type_remove_ptr(bmain, wgt);
}
}
diff --git a/source/blender/makesrna/intern/rna_wm_manipulator.c b/source/blender/makesrna/intern/rna_wm_manipulator.c
index 030f1a1628c..a8dcd563ed3 100644
--- a/source/blender/makesrna/intern/rna_wm_manipulator.c
+++ b/source/blender/makesrna/intern/rna_wm_manipulator.c
@@ -31,6 +31,7 @@
#include "DNA_windowmanager_types.h"
#include "BLI_utildefines.h"
+#include "BLI_string_utils.h"
#include "BLT_translation.h"
@@ -40,7 +41,6 @@
#include "rna_internal.h"
-#include "WM_api.h"
#include "WM_types.h"
#ifdef RNA_RUNTIME
@@ -52,7 +52,6 @@
#include <assert.h>
#include "WM_api.h"
-#include "WM_types.h"
#include "DNA_workspace_types.h"
@@ -135,23 +134,31 @@ static int rna_manipulator_test_select_cb(
return intersect_id;
}
-static void rna_manipulator_modal_cb(
- struct bContext *C, struct wmManipulator *mpr, const struct wmEvent *event, int tweak)
+static int rna_manipulator_modal_cb(
+ struct bContext *C, struct wmManipulator *mpr, const struct wmEvent *event,
+ eWM_ManipulatorTweak tweak_flag)
{
extern FunctionRNA rna_Manipulator_modal_func;
wmManipulatorGroup *mgroup = mpr->parent_mgroup;
PointerRNA mpr_ptr;
ParameterList list;
FunctionRNA *func;
+ const int tweak_flag_int = tweak_flag;
RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr);
/* RNA_struct_find_function(&mpr_ptr, "modal"); */
func = &rna_Manipulator_modal_func;
RNA_parameter_list_create(&list, &mpr_ptr, func);
RNA_parameter_set_lookup(&list, "context", &C);
RNA_parameter_set_lookup(&list, "event", &event);
- RNA_parameter_set_lookup(&list, "tweak", &tweak);
+ RNA_parameter_set_lookup(&list, "tweak", &tweak_flag_int);
mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list);
+
+ void *ret;
+ RNA_parameter_get_lookup(&list, "result", &ret);
+ int ret_enum = *(int *)ret;
+
RNA_parameter_list_free(&list);
+ return ret_enum;
}
static void rna_manipulator_setup_cb(
@@ -171,7 +178,7 @@ static void rna_manipulator_setup_cb(
}
-static void rna_manipulator_invoke_cb(
+static int rna_manipulator_invoke_cb(
struct bContext *C, struct wmManipulator *mpr, const struct wmEvent *event)
{
extern FunctionRNA rna_Manipulator_invoke_func;
@@ -186,7 +193,13 @@ static void rna_manipulator_invoke_cb(
RNA_parameter_set_lookup(&list, "context", &C);
RNA_parameter_set_lookup(&list, "event", &event);
mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list);
+
+ void *ret;
+ RNA_parameter_get_lookup(&list, "result", &ret);
+ int ret_enum = *(int *)ret;
+
RNA_parameter_list_free(&list);
+ return ret_enum;
}
static void rna_manipulator_exit_cb(
@@ -210,21 +223,19 @@ static void rna_manipulator_exit_cb(
RNA_parameter_list_free(&list);
}
-static void rna_manipulator_select_cb(
- struct bContext *C, struct wmManipulator *mpr, int action)
+static void rna_manipulator_select_refresh_cb(
+ struct wmManipulator *mpr)
{
- extern FunctionRNA rna_Manipulator_select_func;
+ extern FunctionRNA rna_Manipulator_select_refresh_func;
wmManipulatorGroup *mgroup = mpr->parent_mgroup;
PointerRNA mpr_ptr;
ParameterList list;
FunctionRNA *func;
RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr);
- /* RNA_struct_find_function(&mpr_ptr, "select"); */
- func = &rna_Manipulator_select_func;
+ /* RNA_struct_find_function(&mpr_ptr, "select_refresh"); */
+ func = &rna_Manipulator_select_refresh_func;
RNA_parameter_list_create(&list, &mpr_ptr, func);
- RNA_parameter_set_lookup(&list, "context", &C);
- RNA_parameter_set_lookup(&list, "action", &action);
- mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list);
+ mgroup->type->ext.call((bContext *)NULL, &mpr_ptr, func, &list);
RNA_parameter_list_free(&list);
}
@@ -309,6 +320,17 @@ static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, float value) \
wmManipulator *mpr = ptr->data; \
mpr->member_id = value; \
}
+#define RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(func_id, member_id, index) \
+static float rna_Manipulator_##func_id##_get(PointerRNA *ptr) \
+{ \
+ wmManipulator *mpr = ptr->data; \
+ return mpr->member_id[index]; \
+} \
+static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, float value) \
+{ \
+ wmManipulator *mpr = ptr->data; \
+ mpr->member_id[index] = value; \
+}
/* wmManipulator.float[len] */
#define RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(func_id, member_id, len) \
static void rna_Manipulator_##func_id##_get(PointerRNA *ptr, float value[len]) \
@@ -335,6 +357,19 @@ static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, int value) \
BKE_BIT_TEST_SET(mpr->member_id, value, flag_value); \
}
+/* wmManipulator.flag (negative) */
+#define RNA_MANIPULATOR_GENERIC_FLAG_NEG_RW_DEF(func_id, member_id, flag_value) \
+static int rna_Manipulator_##func_id##_get(PointerRNA *ptr) \
+{ \
+ wmManipulator *mpr = ptr->data; \
+ return (mpr->member_id & flag_value) == 0; \
+} \
+static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, int value) \
+{ \
+ wmManipulator *mpr = ptr->data; \
+ BKE_BIT_TEST_SET(mpr->member_id, !value, flag_value); \
+}
+
#define RNA_MANIPULATOR_FLAG_RO_DEF(func_id, member_id, flag_value) \
static int rna_Manipulator_##func_id##_get(PointerRNA *ptr) \
{ \
@@ -342,41 +377,48 @@ static int rna_Manipulator_##func_id##_get(PointerRNA *ptr) \
return (mpr->member_id & flag_value) != 0; \
}
-RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(color, color, 4);
-RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(color_hi, color_hi, 4);
+RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(color, color, 3);
+RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(color_hi, color_hi, 3);
+
+RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(alpha, color, 3);
+RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(alpha_hi, color_hi, 3);
+RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_space, matrix_space, 16);
RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_basis, matrix_basis, 16);
RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_offset, matrix_offset, 16);
+static void rna_Manipulator_matrix_world_get(PointerRNA *ptr, float value[16])
+{
+ wmManipulator *mpr = ptr->data;
+ WM_manipulator_calc_matrix_final(mpr, (float (*)[4])value);
+}
+
RNA_MANIPULATOR_GENERIC_FLOAT_RW_DEF(scale_basis, scale_basis);
RNA_MANIPULATOR_GENERIC_FLOAT_RW_DEF(line_width, line_width);
RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_hover, flag, WM_MANIPULATOR_DRAW_HOVER);
-RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_active, flag, WM_MANIPULATOR_DRAW_ACTIVE);
+RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_modal, flag, WM_MANIPULATOR_DRAW_MODAL);
RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_value, flag, WM_MANIPULATOR_DRAW_VALUE);
+RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_offset_scale, flag, WM_MANIPULATOR_DRAW_OFFSET_SCALE);
+RNA_MANIPULATOR_GENERIC_FLAG_NEG_RW_DEF(flag_use_draw_scale, flag, WM_MANIPULATOR_DRAW_OFFSET_SCALE);
RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_hide, flag, WM_MANIPULATOR_HIDDEN);
/* wmManipulator.state */
RNA_MANIPULATOR_FLAG_RO_DEF(state_is_highlight, state, WM_MANIPULATOR_STATE_HIGHLIGHT);
-RNA_MANIPULATOR_FLAG_RO_DEF(state_is_active, state, WM_MANIPULATOR_STATE_ACTIVE);
+RNA_MANIPULATOR_FLAG_RO_DEF(state_is_modal, state, WM_MANIPULATOR_STATE_MODAL);
RNA_MANIPULATOR_FLAG_RO_DEF(state_select, state, WM_MANIPULATOR_STATE_SELECT);
-static void rna_Manipulator_name_get(PointerRNA *ptr, char *value)
-{
- wmManipulator *mpr = ptr->data;
- strcpy(value, mpr->name);
-}
-
-static void rna_Manipulator_name_set(PointerRNA *ptr, const char *value)
+static void rna_Manipulator_state_select_set(struct PointerRNA *ptr, int value)
{
wmManipulator *mpr = ptr->data;
- WM_manipulator_name_set(mpr->parent_mgroup, mpr, value);
+ wmManipulatorGroup *mgroup = mpr->parent_mgroup;
+ WM_manipulator_select_set(mgroup->parent_mmap, mpr, value);
}
-static int rna_Manipulator_name_length(PointerRNA *ptr)
+static PointerRNA rna_Manipulator_group_get(PointerRNA *ptr)
{
wmManipulator *mpr = ptr->data;
- return strlen(mpr->name);
+ return rna_pointer_inherit_refine(ptr, &RNA_ManipulatorGroup, mpr->parent_mgroup);
}
#ifdef WITH_PYTHON
@@ -424,6 +466,14 @@ static StructRNA *rna_Manipulator_register(
rna_Manipulator_unregister(bmain, wt->ext.srna);
}
}
+ if (!RNA_struct_available_or_report(reports, dummywt.idname)) {
+ return NULL;
+ }
+
+ { /* allocate the idname */
+ /* For multiple strings see ManipulatorGroup. */
+ dummywt.idname = BLI_strdup(temp_buffers.idname);
+ }
/* create a new manipulator type */
dummywt.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummywt.idname, &RNA_Manipulator);
@@ -444,16 +494,11 @@ static StructRNA *rna_Manipulator_register(
dummywt.setup = (have_function[i++]) ? rna_manipulator_setup_cb : NULL;
dummywt.invoke = (have_function[i++]) ? rna_manipulator_invoke_cb : NULL;
dummywt.exit = (have_function[i++]) ? rna_manipulator_exit_cb : NULL;
- dummywt.select = (have_function[i++]) ? rna_manipulator_select_cb : NULL;
+ dummywt.select_refresh = (have_function[i++]) ? rna_manipulator_select_refresh_cb : NULL;
BLI_assert(i == ARRAY_SIZE(have_function));
}
- RNA_def_struct_duplicate_pointers(dummywt.ext.srna);
-
- /* use duplicated string */
- dummywt.idname = dummywt.ext.srna->identifier;
-
WM_manipulatortype_append_ptr(BPY_RNA_manipulator_wrapper, (void *)&dummywt);
/* update while blender is running */
@@ -462,22 +507,19 @@ static StructRNA *rna_Manipulator_register(
return dummywt.ext.srna;
}
-static void rna_Manipulator_unregister(struct Main *UNUSED(bmain), StructRNA *type)
+static void rna_Manipulator_unregister(struct Main *bmain, StructRNA *type)
{
wmManipulatorType *wt = RNA_struct_blender_type_get(type);
- /* TODO, remove widgets from interface! */
-
if (!wt)
return;
- WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
-
RNA_struct_free_extension(type, &wt->ext);
+ RNA_struct_free(&BLENDER_RNA, type);
- WM_manipulatortype_remove_ptr(wt);
+ WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
- RNA_struct_free(&BLENDER_RNA, type);
+ WM_manipulatortype_remove_ptr(NULL, bmain, wt);
}
static void **rna_Manipulator_instance(PointerRNA *ptr)
@@ -501,28 +543,28 @@ static StructRNA *rna_Manipulator_refine(PointerRNA *mnp_ptr)
* \{ */
static wmManipulator *rna_ManipulatorGroup_manipulator_new(
- wmManipulatorGroup *mgroup, ReportList *reports, const char *idname, const char *name)
+ wmManipulatorGroup *mgroup, ReportList *reports, const char *idname)
{
const wmManipulatorType *wt = WM_manipulatortype_find(idname, true);
if (wt == NULL) {
BKE_reportf(reports, RPT_ERROR, "ManipulatorType '%s' not known", idname);
return NULL;
}
- wmManipulator *mpr = WM_manipulator_new_ptr(wt, mgroup, name, NULL);
+ wmManipulator *mpr = WM_manipulator_new_ptr(wt, mgroup, NULL);
return mpr;
}
static void rna_ManipulatorGroup_manipulator_remove(
wmManipulatorGroup *mgroup, bContext *C, wmManipulator *mpr)
{
- WM_manipulator_free(&mgroup->manipulators, mgroup->parent_mmap, mpr, C);
+ WM_manipulator_unlink(&mgroup->manipulators, mgroup->parent_mmap, mpr, C);
}
static void rna_ManipulatorGroup_manipulator_clear(
wmManipulatorGroup *mgroup, bContext *C)
{
while (mgroup->manipulators.first) {
- WM_manipulator_free(&mgroup->manipulators, mgroup->parent_mmap, mgroup->manipulators.first, C);
+ WM_manipulator_unlink(&mgroup->manipulators, mgroup->parent_mmap, mgroup->manipulators.first, C);
}
}
@@ -614,7 +656,6 @@ static void rna_manipulatorgroup_setup_cb(const bContext *C, wmManipulatorGroup
static wmKeyMap *rna_manipulatorgroup_setup_keymap_cb(const wmManipulatorGroupType *wgt, wmKeyConfig *config)
{
extern FunctionRNA rna_ManipulatorGroup_setup_keymap_func;
- const char *wgroupname = wgt->name;
void *ret;
PointerRNA ptr;
@@ -626,7 +667,6 @@ static wmKeyMap *rna_manipulatorgroup_setup_keymap_cb(const wmManipulatorGroupTy
RNA_parameter_list_create(&list, &ptr, func);
RNA_parameter_set_lookup(&list, "keyconfig", &config);
- RNA_parameter_set_lookup(&list, "manipulator_group", &wgroupname);
wgt->ext.call(NULL, &ptr, func, &list);
RNA_parameter_get_lookup(&list, "keymap", &ret);
@@ -674,6 +714,7 @@ static void rna_manipulatorgroup_draw_prepare_cb(const bContext *C, wmManipulato
}
void BPY_RNA_manipulatorgroup_wrapper(wmManipulatorGroupType *wgt, void *userdata);
+static void rna_ManipulatorGroup_unregister(struct Main *bmain, StructRNA *type);
static StructRNA *rna_ManipulatorGroup_register(
Main *bmain, ReportList *reports, void *data, const char *identifier,
@@ -727,12 +768,25 @@ static StructRNA *rna_ManipulatorGroup_register(
{
wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(dummywgt.idname, true);
if (wgt && wgt->ext.srna) {
- WM_manipulatormaptype_group_unlink(NULL, bmain, mmap_type, wgt);
- WM_manipulatorgrouptype_remove_ptr(wgt);
-
- WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
+ rna_ManipulatorGroup_unregister(bmain, wgt->ext.srna);
}
}
+ if (!RNA_struct_available_or_report(reports, dummywgt.idname)) {
+ return NULL;
+ }
+
+ { /* allocate the idname */
+ const char *strings[] = {
+ temp_buffers.idname,
+ temp_buffers.name,
+ };
+ char *strings_table[ARRAY_SIZE(strings)];
+ BLI_string_join_array_by_sep_char_with_tableN('\0', strings_table, strings, ARRAY_SIZE(strings));
+
+ dummywgt.idname = strings_table[0]; /* allocated string stored here */
+ dummywgt.name = strings_table[1];
+ BLI_assert(ARRAY_SIZE(strings) == 2);
+ }
/* create a new manipulatorgroup type */
dummywgt.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummywgt.idname, &RNA_ManipulatorGroup);
@@ -749,15 +803,11 @@ static StructRNA *rna_ManipulatorGroup_register(
dummywgt.refresh = (have_function[3]) ? rna_manipulatorgroup_refresh_cb : NULL;
dummywgt.draw_prepare = (have_function[4]) ? rna_manipulatorgroup_draw_prepare_cb : NULL;
- RNA_def_struct_duplicate_pointers(dummywgt.ext.srna);
- dummywgt.idname = dummywgt.ext.srna->identifier;
- dummywgt.name = dummywgt.ext.srna->name;
-
wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_append_ptr(
BPY_RNA_manipulatorgroup_wrapper, (void *)&dummywgt);
if (wgt->flag & WM_MANIPULATORGROUPTYPE_PERSISTENT) {
- WM_manipulator_group_add_ptr_ex(wgt, mmap_type);
+ WM_manipulator_group_type_add_ptr_ex(wgt, mmap_type);
/* update while blender is running */
WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
@@ -773,13 +823,12 @@ static void rna_ManipulatorGroup_unregister(struct Main *bmain, StructRNA *type)
if (!wgt)
return;
- WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
-
RNA_struct_free_extension(type, &wgt->ext);
+ RNA_struct_free(&BLENDER_RNA, type);
- WM_manipulator_group_remove_ptr(bmain, wgt);
+ WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
- RNA_struct_free(&BLENDER_RNA, type);
+ WM_manipulator_group_type_remove_ptr(bmain, wgt);
}
static void **rna_ManipulatorGroup_instance(PointerRNA *ptr)
@@ -825,7 +874,6 @@ static void rna_def_manipulators(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Add manipulator");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_string(func, "type", "Type", 0, "", "Manipulator identifier"); /* optional */
- RNA_def_string(func, "name", "Name", 0, "", "Manipulator name"); /* optional */
parm = RNA_def_pointer(func, "manipulator", "Manipulator", "", "New manipulator");
RNA_def_function_return(func, parm);
@@ -914,41 +962,44 @@ static void rna_def_manipulator(BlenderRNA *brna, PropertyRNA *cprop)
/* wmManipulator.handler */
static EnumPropertyItem tweak_actions[] = {
{WM_MANIPULATOR_TWEAK_PRECISE, "PRECISE", 0, "Precise", ""},
+ {WM_MANIPULATOR_TWEAK_SNAP, "SNAP", 0, "Snap", ""},
{0, NULL, 0, NULL, NULL}
};
func = RNA_def_function(srna, "modal", NULL);
RNA_def_function_ui_description(func, "");
- RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
parm = RNA_def_pointer(func, "context", "Context", "", "");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
parm = RNA_def_pointer(func, "event", "Event", "", "");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
/* TODO, shuold be a enum-flag */
- parm = RNA_def_enum(func, "tweak", tweak_actions, 0, "Tweak", "");
+ parm = RNA_def_enum_flag(func, "tweak", tweak_actions, 0, "Tweak", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
- RNA_def_property_flag(parm, PROP_ENUM_FLAG);
-
+ parm = RNA_def_enum_flag(func, "result", rna_enum_operator_return_items, OPERATOR_CANCELLED, "result", "");
+ RNA_def_function_return(func, parm);
/* wmManipulator.property_update */
/* TODO */
/* wmManipulator.setup */
func = RNA_def_function(srna, "setup", NULL);
RNA_def_function_ui_description(func, "");
- RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
/* wmManipulator.invoke */
func = RNA_def_function(srna, "invoke", NULL);
RNA_def_function_ui_description(func, "");
- RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
parm = RNA_def_pointer(func, "context", "Context", "", "");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
parm = RNA_def_pointer(func, "event", "Event", "", "");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ parm = RNA_def_enum_flag(func, "result", rna_enum_operator_return_items, OPERATOR_CANCELLED, "result", "");
+ RNA_def_function_return(func, parm);
/* wmManipulator.exit */
func = RNA_def_function(srna, "exit", NULL);
RNA_def_function_ui_description(func, "");
- RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
parm = RNA_def_pointer(func, "context", "Context", "", "");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
parm = RNA_def_boolean(func, "cancel", 0, "Cancel, otherwise confirm", "");
@@ -957,42 +1008,48 @@ static void rna_def_manipulator(BlenderRNA *brna, PropertyRNA *cprop)
/* wmManipulator.cursor_get */
/* TODO */
- /* wmManipulator.select */
- /* TODO, de-duplicate! */
- static EnumPropertyItem select_actions[] = {
- {SEL_TOGGLE, "TOGGLE", 0, "Toggle", "Toggle selection for all elements"},
- {SEL_SELECT, "SELECT", 0, "Select", "Select all elements"},
- {SEL_DESELECT, "DESELECT", 0, "Deselect", "Deselect all elements"},
- {SEL_INVERT, "INVERT", 0, "Invert", "Invert selection of all elements"},
- {0, NULL, 0, NULL, NULL}
- };
- func = RNA_def_function(srna, "select", NULL);
+ /* wmManipulator.select_refresh */
+ func = RNA_def_function(srna, "select_refresh", NULL);
RNA_def_function_ui_description(func, "");
- RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
- parm = RNA_def_pointer(func, "context", "Context", "", "");
- RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
- parm = RNA_def_enum(func, "action", select_actions, 0, "Action", "Selection action to execute");
- RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
/* -------------------------------------------------------------------- */
/* Instance Variables */
- prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
- RNA_def_property_string_funcs(
- prop, "rna_Manipulator_name_get", "rna_Manipulator_name_length", "rna_Manipulator_name_set");
- RNA_def_property_ui_text(prop, "Name", "");
- RNA_def_struct_name_property(srna, prop);
- RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
+ prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_struct_type(prop, "ManipulatorGroup");
+ RNA_def_property_pointer_funcs(prop, "rna_Manipulator_group_get", NULL, NULL, NULL);
+ RNA_def_property_ui_text(prop, "", "Manipulator group this manipulator is a member of");
+ /* Color & Alpha */
prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_array(prop, 4);
+ RNA_def_property_array(prop, 3);
RNA_def_property_float_funcs(prop, "rna_Manipulator_color_get", "rna_Manipulator_color_set", NULL);
+ prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Alpha", "");
+ RNA_def_property_float_funcs(prop, "rna_Manipulator_alpha_get", "rna_Manipulator_alpha_set", NULL);
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
+
+ /* Color & Alpha (highlight) */
prop = RNA_def_property(srna, "color_highlight", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_array(prop, 4);
+ RNA_def_property_array(prop, 3);
RNA_def_property_float_funcs(prop, "rna_Manipulator_color_hi_get", "rna_Manipulator_color_hi_set", NULL);
- RNA_def_property_ui_text(prop, "Color", "");
+
+ prop = RNA_def_property(srna, "alpha_highlight", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Alpha", "");
+ RNA_def_property_float_funcs(prop, "rna_Manipulator_alpha_hi_get", "rna_Manipulator_alpha_hi_set", NULL);
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
+
+ prop = RNA_def_property(srna, "matrix_space", PROP_FLOAT, PROP_MATRIX);
+ RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
+ RNA_def_property_ui_text(prop, "Space Matrix", "");
+ RNA_def_property_float_funcs(prop, "rna_Manipulator_matrix_space_get", "rna_Manipulator_matrix_space_set", NULL);
+ RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
prop = RNA_def_property(srna, "matrix_basis", PROP_FLOAT, PROP_MATRIX);
RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
@@ -1006,13 +1063,19 @@ static void rna_def_manipulator(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_property_float_funcs(prop, "rna_Manipulator_matrix_offset_get", "rna_Manipulator_matrix_offset_set", NULL);
RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
- prop = RNA_def_property(srna, "scale_basis", PROP_FLOAT, PROP_MATRIX);
+ prop = RNA_def_property(srna, "matrix_world", PROP_FLOAT, PROP_MATRIX);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
+ RNA_def_property_ui_text(prop, "Final World Matrix", "");
+ RNA_def_property_float_funcs(prop, "rna_Manipulator_matrix_world_get", NULL, NULL);
+
+ prop = RNA_def_property(srna, "scale_basis", PROP_FLOAT, PROP_NONE);
RNA_def_property_ui_text(prop, "Scale Basis", "");
RNA_def_property_float_funcs(prop, "rna_Manipulator_scale_basis_get", "rna_Manipulator_scale_basis_set", NULL);
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
- prop = RNA_def_property(srna, "line_width", PROP_FLOAT, PROP_MATRIX);
+ prop = RNA_def_property(srna, "line_width", PROP_FLOAT, PROP_PIXEL);
RNA_def_property_ui_text(prop, "Line Width", "");
RNA_def_property_float_funcs(prop, "rna_Manipulator_line_width_get", "rna_Manipulator_line_width_set", NULL);
RNA_def_property_range(prop, 0.0f, FLT_MAX);
@@ -1031,10 +1094,10 @@ static void rna_def_manipulator(BlenderRNA *brna, PropertyRNA *cprop)
prop, "rna_Manipulator_flag_use_draw_hover_get", "rna_Manipulator_flag_use_draw_hover_set");
RNA_def_property_ui_text(prop, "Draw Hover", "");
RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
- /* WM_MANIPULATOR_DRAW_ACTIVE */
- prop = RNA_def_property(srna, "use_draw_active", PROP_BOOLEAN, PROP_NONE);
+ /* WM_MANIPULATOR_DRAW_MODAL */
+ prop = RNA_def_property(srna, "use_draw_modal", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(
- prop, "rna_Manipulator_flag_use_draw_active_get", "rna_Manipulator_flag_use_draw_active_set");
+ prop, "rna_Manipulator_flag_use_draw_modal_get", "rna_Manipulator_flag_use_draw_modal_set");
RNA_def_property_ui_text(prop, "Draw Active", "Draw while dragging");
RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
/* WM_MANIPULATOR_DRAW_VALUE */
@@ -1043,6 +1106,18 @@ static void rna_def_manipulator(BlenderRNA *brna, PropertyRNA *cprop)
prop, "rna_Manipulator_flag_use_draw_value_get", "rna_Manipulator_flag_use_draw_value_set");
RNA_def_property_ui_text(prop, "Draw Value", "Show an indicator for the current value while dragging");
RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
+ /* WM_MANIPULATOR_DRAW_OFFSET_SCALE */
+ prop = RNA_def_property(srna, "use_draw_offset_scale", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(
+ prop, "rna_Manipulator_flag_use_draw_offset_scale_get", "rna_Manipulator_flag_use_draw_offset_scale_set");
+ RNA_def_property_ui_text(prop, "Scale Offset", "Scale the offset matrix (use to apply screen-space offset)");
+ RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
+ /* WM_MANIPULATOR_DRAW_NO_SCALE (negated) */
+ prop = RNA_def_property(srna, "use_draw_scale", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(
+ prop, "rna_Manipulator_flag_use_draw_scale_get", "rna_Manipulator_flag_use_draw_scale_set");
+ RNA_def_property_ui_text(prop, "Scale", "Use scale when calculating the matrix");
+ RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
/* wmManipulator.state (readonly) */
/* WM_MANIPULATOR_STATE_HIGHLIGHT */
@@ -1050,16 +1125,16 @@ static void rna_def_manipulator(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_property_boolean_funcs(prop, "rna_Manipulator_state_is_highlight_get", NULL);
RNA_def_property_ui_text(prop, "Highlight", "");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- /* WM_MANIPULATOR_STATE_ACTIVE */
- prop = RNA_def_property(srna, "is_active", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_funcs(prop, "rna_Manipulator_state_is_active_get", NULL);
+ /* WM_MANIPULATOR_STATE_MODAL */
+ prop = RNA_def_property(srna, "is_modal", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_Manipulator_state_is_modal_get", NULL);
RNA_def_property_ui_text(prop, "Highlight", "");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
/* WM_MANIPULATOR_STATE_SELECT */
+ /* (note that setting is involved, needs to handle array) */
prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_funcs(prop, "rna_Manipulator_state_select_get", NULL);
+ RNA_def_property_boolean_funcs(prop, "rna_Manipulator_state_select_get", "rna_Manipulator_state_select_set");
RNA_def_property_ui_text(prop, "Select", "");
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_api_manipulator(srna);
@@ -1134,6 +1209,8 @@ static void rna_def_manipulatorgroup(BlenderRNA *brna)
"Supports selection"},
{WM_MANIPULATORGROUPTYPE_PERSISTENT, "PERSISTENT", 0, "Persistent",
""},
+ {WM_MANIPULATORGROUPTYPE_DRAW_MODAL_ALL, "SHOW_MODAL_ALL", 0, "Show Modal All",
+ "Show all while interacting"},
{0, NULL, 0, NULL, NULL}
};
prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE);
@@ -1155,18 +1232,14 @@ static void rna_def_manipulatorgroup(BlenderRNA *brna)
parm = RNA_def_pointer(func, "context", "Context", "", "");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
- /* keymap_init */
+ /* setup_keymap */
func = RNA_def_function(srna, "setup_keymap", NULL);
RNA_def_function_ui_description(
func,
"Initialize keymaps for this manipulator group, use fallback keymap when not present");
RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_REGISTER_OPTIONAL);
- parm = RNA_def_pointer(func, "keyconf", "KeyConfig", "", "");
+ parm = RNA_def_pointer(func, "keyconfig", "KeyConfig", "", "");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
- parm = RNA_def_property(func, "manipulator_group", PROP_STRING, PROP_NONE);
- RNA_def_property_ui_text(parm, "Manipulator Group", "Manipulator Group ID");
- // RNA_def_property_string_default(parm, "");
- RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
/* return */
parm = RNA_def_pointer(func, "keymap", "KeyMap", "", "");
RNA_def_property_flag(parm, PROP_NEVER_NULL);
diff --git a/source/blender/makesrna/intern/rna_wm_manipulator_api.c b/source/blender/makesrna/intern/rna_wm_manipulator_api.c
index 9f011ad7b7d..c948f84e087 100644
--- a/source/blender/makesrna/intern/rna_wm_manipulator_api.c
+++ b/source/blender/makesrna/intern/rna_wm_manipulator_api.c
@@ -68,9 +68,13 @@ static void rna_manipulator_draw_preset_facemap(
wmManipulator *mpr, struct bContext *C, struct Object *ob, int facemap, int select_id)
{
struct Scene *scene = CTX_data_scene(C);
- ED_manipulator_draw_preset_facemap(mpr, scene, ob, facemap, select_id);
+ ED_manipulator_draw_preset_facemap(C, mpr, scene, ob, facemap, select_id);
}
+/* -------------------------------------------------------------------- */
+/** \name Manipulator Property Define
+ * \{ */
+
static void rna_manipulator_target_set_prop(
wmManipulator *mpr, ReportList *reports, const char *target_propname,
PointerRNA *ptr, const char *propname, int index)
@@ -136,7 +140,7 @@ static void rna_manipulator_target_set_prop(
}
static PointerRNA rna_manipulator_target_set_operator(
- wmManipulator *mpr, ReportList *reports, const char *opname)
+ wmManipulator *mpr, ReportList *reports, const char *opname, int part_index)
{
wmOperatorType *ot;
@@ -153,11 +157,30 @@ static PointerRNA rna_manipulator_target_set_operator(
properties = IDP_New(IDP_GROUP, &val, "wmManipulatorProperties");
}
- WM_manipulator_set_operator(mpr, ot, properties);
+ return *WM_manipulator_operator_set(mpr, part_index, ot, properties);
+}
+
+/** \} */
- return mpr->op_data.ptr;
+/* -------------------------------------------------------------------- */
+/** \name Manipulator Property Access
+ * \{ */
+
+static int rna_manipulator_target_is_valid(
+ wmManipulator *mpr, ReportList *reports, const char *target_propname)
+{
+ wmManipulatorProperty *mpr_prop =
+ WM_manipulator_target_property_find(mpr, target_propname);
+ if (mpr_prop == NULL) {
+ BKE_reportf(reports, RPT_ERROR, "Manipulator target property '%s.%s' not found",
+ mpr->type->idname, target_propname);
+ return false;
+ }
+ return WM_manipulator_target_property_is_valid(mpr_prop);
}
+/** \} */
+
#else
void RNA_api_manipulator(StructRNA *srna)
@@ -178,7 +201,7 @@ void RNA_api_manipulator(StructRNA *srna)
func = RNA_def_function(srna, "draw_preset_box", "rna_manipulator_draw_preset_box");
RNA_def_function_ui_description(func, "Draw a box");
parm = RNA_def_property(func, "matrix", PROP_FLOAT, PROP_MATRIX);
- RNA_def_property_flag(parm, PARM_REQUIRED);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
RNA_def_property_multi_array(parm, 2, rna_matrix_dimsize_4x4);
RNA_def_property_ui_text(parm, "", "The matrix to transform");
RNA_def_int(func, "select_id", -1, -1, INT_MAX, "Zero when not selecting", "", -1, INT_MAX);
@@ -187,7 +210,7 @@ void RNA_api_manipulator(StructRNA *srna)
func = RNA_def_function(srna, "draw_preset_arrow", "rna_manipulator_draw_preset_arrow");
RNA_def_function_ui_description(func, "Draw a box");
parm = RNA_def_property(func, "matrix", PROP_FLOAT, PROP_MATRIX);
- RNA_def_property_flag(parm, PARM_REQUIRED);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
RNA_def_property_multi_array(parm, 2, rna_matrix_dimsize_4x4);
RNA_def_property_ui_text(parm, "", "The matrix to transform");
RNA_def_enum(func, "axis", rna_enum_object_axis_items, 2, "", "Arrow Orientation");
@@ -196,7 +219,7 @@ void RNA_api_manipulator(StructRNA *srna)
func = RNA_def_function(srna, "draw_preset_circle", "rna_manipulator_draw_preset_circle");
RNA_def_function_ui_description(func, "Draw a box");
parm = RNA_def_property(func, "matrix", PROP_FLOAT, PROP_MATRIX);
- RNA_def_property_flag(parm, PARM_REQUIRED);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
RNA_def_property_multi_array(parm, 2, rna_matrix_dimsize_4x4);
RNA_def_property_ui_text(parm, "", "The matrix to transform");
RNA_def_enum(func, "axis", rna_enum_object_axis_items, 2, "", "Arrow Orientation");
@@ -218,6 +241,7 @@ void RNA_api_manipulator(StructRNA *srna)
/* -------------------------------------------------------------------- */
/* Property API */
+ /* Define Properties */
/* note, 'target_set_handler' is defined in 'bpy_rna_manipulator.c' */
func = RNA_def_function(srna, "target_set_prop", "rna_manipulator_target_set_prop");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
@@ -234,15 +258,27 @@ void RNA_api_manipulator(StructRNA *srna)
func = RNA_def_function(srna, "target_set_operator", "rna_manipulator_target_set_operator");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(
- func,"Operator to run when activating the manipulator "
+ func, "Operator to run when activating the manipulator "
"(overrides property targets)");
parm = RNA_def_string(func, "operator", NULL, 0, "", "Target operator");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ RNA_def_int(func, "index", 0, 0, 255, "Part index", "", 0, 255);
+
/* similar to UILayout.operator */
parm = RNA_def_pointer(func, "properties", "OperatorProperties", "", "Operator properties to fill in");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED | PARM_RNAPTR);
RNA_def_function_return(func, parm);
+ /* Access Properties */
+ /* note, 'target_get', 'target_set' is defined in 'bpy_rna_manipulator.c' */
+ func = RNA_def_function(srna, "target_is_valid", "rna_manipulator_target_is_valid");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ parm = RNA_def_string(func, "property", NULL, 0, "", "Property identifier");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ RNA_def_function_ui_description(func, "");
+ parm = RNA_def_boolean(func, "result", 0, "", "");
+ RNA_def_function_return(func, parm);
+
}
diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c
index 8f26077ea82..60c7998853e 100644
--- a/source/blender/modifiers/intern/MOD_armature.c
+++ b/source/blender/modifiers/intern/MOD_armature.c
@@ -62,13 +62,13 @@ static void initData(ModifierData *md)
static void copyData(ModifierData *md, ModifierData *target)
{
+#if 0
ArmatureModifierData *amd = (ArmatureModifierData *) md;
+#endif
ArmatureModifierData *tamd = (ArmatureModifierData *) target;
- tamd->object = amd->object;
- tamd->deformflag = amd->deformflag;
- tamd->multi = amd->multi;
- BLI_strncpy(tamd->defgrp_name, amd->defgrp_name, sizeof(tamd->defgrp_name));
+ modifier_copyData_generic(md, target);
+ tamd->prevCos = NULL;
}
static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(md))
@@ -110,8 +110,8 @@ static void updateDepsgraph(ModifierData *md,
}
}
-static void deformVerts(ModifierData *md, Object *ob,
- DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3],
int numVerts,
ModifierApplyFlag UNUSED(flag))
@@ -131,7 +131,7 @@ static void deformVerts(ModifierData *md, Object *ob,
}
static void deformVertsEM(
- ModifierData *md, Object *ob, struct BMEditMesh *em,
+ ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, struct BMEditMesh *em,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
ArmatureModifierData *amd = (ArmatureModifierData *) md;
@@ -154,7 +154,7 @@ static void deformVertsEM(
}
static void deformMatricesEM(
- ModifierData *md, Object *ob, struct BMEditMesh *em,
+ ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, struct BMEditMesh *em,
DerivedMesh *derivedData, float (*vertexCos)[3],
float (*defMats)[3][3], int numVerts)
{
@@ -169,7 +169,7 @@ static void deformMatricesEM(
if (!derivedData) dm->release(dm);
}
-static void deformMatrices(ModifierData *md, Object *ob, DerivedMesh *derivedData,
+static void deformMatrices(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3], float (*defMats)[3][3], int numVerts)
{
ArmatureModifierData *amd = (ArmatureModifierData *) md;
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index 57f90fb4b51..66ff1fe0a85 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -356,7 +356,7 @@ static void dm_merge_transform(
}
static DerivedMesh *arrayModifier_doArray(
- ArrayModifierData *amd,
+ ArrayModifierData *amd, const EvaluationContext *eval_ctx,
Scene *scene, Object *ob, DerivedMesh *dm,
ModifierApplyFlag flag)
{
@@ -462,7 +462,7 @@ static DerivedMesh *arrayModifier_doArray(
if (cu) {
#ifdef CYCLIC_DEPENDENCY_WORKAROUND
if (amd->curve_ob->curve_cache == NULL) {
- BKE_displist_make_curveTypes(scene, amd->curve_ob, false);
+ BKE_displist_make_curveTypes(eval_ctx, scene, amd->curve_ob, false);
}
#endif
@@ -725,12 +725,12 @@ static DerivedMesh *arrayModifier_doArray(
}
-static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
- DerivedMesh *dm,
+static DerivedMesh *applyModifier(ModifierData *md, const EvaluationContext *eval_ctx,
+ Object *ob, DerivedMesh *dm,
ModifierApplyFlag flag)
{
ArrayModifierData *amd = (ArrayModifierData *) md;
- return arrayModifier_doArray(amd, md->scene, ob, dm, flag);
+ return arrayModifier_doArray(amd, eval_ctx, md->scene, ob, dm, flag);
}
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c
index 17b0cd4d7f5..35b8a3fd9cb 100644
--- a/source/blender/modifiers/intern/MOD_bevel.c
+++ b/source/blender/modifiers/intern/MOD_bevel.c
@@ -65,19 +65,11 @@ static void initData(ModifierData *md)
static void copyData(ModifierData *md, ModifierData *target)
{
+#if 0
BevelModifierData *bmd = (BevelModifierData *) md;
BevelModifierData *tbmd = (BevelModifierData *) target;
-
- tbmd->value = bmd->value;
- tbmd->res = bmd->res;
- tbmd->flags = bmd->flags;
- tbmd->val_flags = bmd->val_flags;
- tbmd->lim_flags = bmd->lim_flags;
- tbmd->e_flags = bmd->e_flags;
- tbmd->mat = bmd->mat;
- tbmd->profile = bmd->profile;
- tbmd->bevel_angle = bmd->bevel_angle;
- BLI_strncpy(tbmd->defgrp_name, bmd->defgrp_name, sizeof(tbmd->defgrp_name));
+#endif
+ modifier_copyData_generic(md, target);
}
static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
@@ -94,8 +86,8 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
/*
* This calls the new bevel code (added since 2.64)
*/
-static DerivedMesh *applyModifier(ModifierData *md, struct Object *ob,
- DerivedMesh *dm,
+static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ struct Object *ob, DerivedMesh *dm,
ModifierApplyFlag UNUSED(flag))
{
DerivedMesh *result;
diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c
index e649c8821fa..5811017f745 100644
--- a/source/blender/modifiers/intern/MOD_boolean.c
+++ b/source/blender/modifiers/intern/MOD_boolean.c
@@ -57,6 +57,7 @@
#include "BLI_alloca.h"
#include "BLI_math_geom.h"
#include "BKE_material.h"
+#include "BKE_global.h" /* only to check G.debug */
#include "MEM_guardedalloc.h"
#include "bmesh.h"
@@ -206,6 +207,8 @@ static DerivedMesh *applyModifier_bmesh(
result = get_quick_derivedMesh(ob, dm, bmd->object, dm_other, bmd->operation);
if (result == NULL) {
+ const bool is_flip = (is_negative_m4(ob->obmat) != is_negative_m4(bmd->object->obmat));
+
BMesh *bm;
const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_DM(dm, dm_other);
@@ -217,6 +220,16 @@ static DerivedMesh *applyModifier_bmesh(
&((struct BMeshCreateParams){.use_toolflags = false,}));
DM_to_bmesh_ex(dm_other, bm, true);
+
+ if (UNLIKELY(is_flip)) {
+ const int cd_loop_mdisp_offset = CustomData_get_offset(&bm->ldata, CD_MDISPS);
+ BMIter iter;
+ BMFace *efa;
+ BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
+ BM_face_normal_flip_ex(bm, efa, cd_loop_mdisp_offset, true);
+ }
+ }
+
DM_to_bmesh_ex(dm, bm, true);
/* main bmesh intersection setup */
@@ -228,7 +241,7 @@ static DerivedMesh *applyModifier_bmesh(
looptris = MEM_mallocN(sizeof(*looptris) * looptris_tot, __func__);
- BM_mesh_calc_tessellation(bm, looptris, &tottri);
+ BM_mesh_calc_tessellation_beauty(bm, looptris, &tottri);
/* postpone this until after tessellating
* so we can use the original normals before the vertex are moved */
@@ -244,7 +257,6 @@ static DerivedMesh *applyModifier_bmesh(
invert_m4_m4(imat, ob->obmat);
mul_m4_m4m4(omat, imat, bmd->object->obmat);
-
BMVert *eve;
i = 0;
BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
@@ -257,8 +269,13 @@ static DerivedMesh *applyModifier_bmesh(
/* we need face normals because of 'BM_face_split_edgenet'
* we could calculate on the fly too (before calling split). */
{
- float nmat[4][4];
- invert_m4_m4(nmat, omat);
+ float nmat[3][3];
+ copy_m3_m4(nmat, omat);
+ invert_m3(nmat);
+
+ if (UNLIKELY(is_flip)) {
+ negate_m3(nmat);
+ }
const short ob_src_totcol = bmd->object->totcol;
short *material_remap = BLI_array_alloca(material_remap, ob_src_totcol ? ob_src_totcol : 1);
@@ -268,7 +285,7 @@ static DerivedMesh *applyModifier_bmesh(
BMFace *efa;
i = 0;
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
- mul_transposed_mat3_m4_v3(nmat, efa->no);
+ mul_transposed_m3_v3(nmat, efa->no);
normalize_v3(efa->no);
BM_elem_flag_enable(efa, BM_FACE_TAG); /* temp tag to test which side split faces are from */
@@ -288,11 +305,17 @@ static DerivedMesh *applyModifier_bmesh(
* currently this is ok for 'BM_mesh_intersect' */
// BM_mesh_normals_update(bm);
- /* change for testing */
bool use_separate = false;
bool use_dissolve = true;
bool use_island_connect = true;
+ /* change for testing */
+ if (G.debug & G_DEBUG) {
+ use_separate = (bmd->bm_flag & eBooleanModifierBMeshFlag_BMesh_Separate) != 0;
+ use_dissolve = (bmd->bm_flag & eBooleanModifierBMeshFlag_BMesh_NoDissolve) == 0;
+ use_island_connect = (bmd->bm_flag & eBooleanModifierBMeshFlag_BMesh_NoConnectRegions) == 0;
+ }
+
BM_mesh_intersect(
bm,
looptris, tottri,
@@ -402,8 +425,8 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(
}
static DerivedMesh *applyModifier(
- ModifierData *md, Object *ob,
- DerivedMesh *derivedData,
+ ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ Object *ob, DerivedMesh *derivedData,
ModifierApplyFlag flag)
{
BooleanModifierData *bmd = (BooleanModifierData *)md;
diff --git a/source/blender/modifiers/intern/MOD_boolean_util.c b/source/blender/modifiers/intern/MOD_boolean_util.c
index 061b1198f7e..49010664aa8 100644
--- a/source/blender/modifiers/intern/MOD_boolean_util.c
+++ b/source/blender/modifiers/intern/MOD_boolean_util.c
@@ -390,6 +390,9 @@ static void exporter_InitGeomArrays(ExportMeshData *export_data,
* the operand. Data for those layers will not be allocated or initialized.
*/
+ CustomData_merge(&dm_left->vertData, &dm->vertData, merge_mask, CD_DEFAULT, num_verts);
+ CustomData_merge(&dm_right->vertData, &dm->vertData, merge_mask, CD_DEFAULT, num_verts);
+
CustomData_merge(&dm_left->loopData, &dm->loopData, merge_mask, CD_DEFAULT, num_loops);
CustomData_merge(&dm_right->loopData, &dm->loopData, merge_mask, CD_DEFAULT, num_loops);
diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c
index d2467a8fc4a..0a0ad11fe16 100644
--- a/source/blender/modifiers/intern/MOD_build.c
+++ b/source/blender/modifiers/intern/MOD_build.c
@@ -47,6 +47,8 @@
#include "BKE_particle.h"
#include "BKE_scene.h"
+
+
#ifdef _OPENMP
# include "BKE_mesh.h" /* BKE_MESH_OMP_LIMIT */
#endif
@@ -73,8 +75,8 @@ static bool dependsOnTime(ModifierData *UNUSED(md))
return true;
}
-static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob),
- DerivedMesh *derivedData,
+static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ Object *UNUSED(ob), DerivedMesh *derivedData,
ModifierApplyFlag UNUSED(flag))
{
DerivedMesh *dm = derivedData;
diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c
index 2dcc01b89d9..93a5b9607bf 100644
--- a/source/blender/modifiers/intern/MOD_cast.c
+++ b/source/blender/modifiers/intern/MOD_cast.c
@@ -433,8 +433,8 @@ static void cuboid_do(
}
}
-static void deformVerts(ModifierData *md, Object *ob,
- DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3],
int numVerts,
ModifierApplyFlag UNUSED(flag))
@@ -456,7 +456,8 @@ static void deformVerts(ModifierData *md, Object *ob,
}
static void deformVertsEM(
- ModifierData *md, Object *ob, struct BMEditMesh *editData,
+ ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ Object *ob, struct BMEditMesh *editData,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
DerivedMesh *dm = get_dm(ob, editData, derivedData, NULL, false, false);
diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c
index 00161366b93..b234cc63228 100644
--- a/source/blender/modifiers/intern/MOD_cloth.c
+++ b/source/blender/modifiers/intern/MOD_cloth.c
@@ -43,7 +43,6 @@
#include "BLI_utildefines.h"
-
#include "BKE_cloth.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_effect.h"
@@ -70,7 +69,7 @@ static void initData(ModifierData *md)
cloth_init(clmd);
}
-static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData, float (*vertexCos)[3],
+static void deformVerts(ModifierData *md, const struct EvaluationContext *eval_ctx, Object *ob, DerivedMesh *derivedData, float (*vertexCos)[3],
int numVerts, ModifierApplyFlag UNUSED(flag))
{
DerivedMesh *dm;
@@ -110,7 +109,7 @@ static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData,
CDDM_apply_vert_coords(dm, vertexCos);
- clothModifier_do(clmd, md->scene, ob, dm, vertexCos);
+ clothModifier_do(clmd, eval_ctx, md->scene, ob, dm, vertexCos);
dm->release(dm);
}
diff --git a/source/blender/modifiers/intern/MOD_collision.c b/source/blender/modifiers/intern/MOD_collision.c
index a2a4b2e1274..b9a2310366a 100644
--- a/source/blender/modifiers/intern/MOD_collision.c
+++ b/source/blender/modifiers/intern/MOD_collision.c
@@ -40,7 +40,6 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
-
#include "BKE_collision.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_global.h"
@@ -48,6 +47,8 @@
#include "BKE_pointcache.h"
#include "BKE_scene.h"
+#include "MOD_modifiertypes.h"
+
static void initData(ModifierData *md)
{
CollisionModifierData *collmd = (CollisionModifierData *) md;
@@ -97,8 +98,8 @@ static bool dependsOnTime(ModifierData *UNUSED(md))
return true;
}
-static void deformVerts(ModifierData *md, Object *ob,
- DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3],
int UNUSED(numVerts),
ModifierApplyFlag UNUSED(flag))
@@ -152,8 +153,6 @@ static void deformVerts(ModifierData *md, Object *ob,
collmd->current_v = MEM_dupallocN(collmd->x); // inter-frame
collmd->mvert_num = mvert_num;
-
- DM_ensure_looptri(dm);
collmd->tri_num = dm->getNumLoopTri(dm);
{
diff --git a/source/blender/modifiers/intern/MOD_correctivesmooth.c b/source/blender/modifiers/intern/MOD_correctivesmooth.c
index 0718b0f85fa..716b918d0f0 100644
--- a/source/blender/modifiers/intern/MOD_correctivesmooth.c
+++ b/source/blender/modifiers/intern/MOD_correctivesmooth.c
@@ -713,7 +713,7 @@ error:
static void deformVerts(
- ModifierData *md, Object *ob, DerivedMesh *derivedData,
+ ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3], int numVerts, ModifierApplyFlag UNUSED(flag))
{
DerivedMesh *dm = get_dm(ob, NULL, derivedData, NULL, false, false);
@@ -727,7 +727,7 @@ static void deformVerts(
static void deformVertsEM(
- ModifierData *md, Object *ob, struct BMEditMesh *editData,
+ ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, struct BMEditMesh *editData,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
DerivedMesh *dm = get_dm(ob, editData, derivedData, NULL, false, false);
diff --git a/source/blender/modifiers/intern/MOD_curve.c b/source/blender/modifiers/intern/MOD_curve.c
index 3200caedc32..198f08334f0 100644
--- a/source/blender/modifiers/intern/MOD_curve.c
+++ b/source/blender/modifiers/intern/MOD_curve.c
@@ -48,6 +48,8 @@
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
+#include "MOD_modifiertypes.h"
+
static void initData(ModifierData *md)
{
CurveModifierData *cmd = (CurveModifierData *) md;
@@ -113,8 +115,8 @@ static void updateDepsgraph(ModifierData *md,
DEG_add_object_relation(node, object, DEG_OB_COMP_TRANSFORM, "Curve Modifier");
}
-static void deformVerts(ModifierData *md, Object *ob,
- DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, const struct EvaluationContext *eval_ctx,
+ Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3],
int numVerts,
ModifierApplyFlag UNUSED(flag))
@@ -123,19 +125,19 @@ static void deformVerts(ModifierData *md, Object *ob,
/* silly that defaxis and curve_deform_verts are off by 1
* but leave for now to save having to call do_versions */
- curve_deform_verts(md->scene, cmd->object, ob, derivedData, vertexCos, numVerts,
+ curve_deform_verts(eval_ctx, md->scene, cmd->object, ob, derivedData, vertexCos, numVerts,
cmd->name, cmd->defaxis - 1);
}
static void deformVertsEM(
- ModifierData *md, Object *ob, struct BMEditMesh *em,
+ ModifierData *md, const struct EvaluationContext *eval_ctx, Object *ob, struct BMEditMesh *em,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
DerivedMesh *dm = derivedData;
if (!derivedData) dm = CDDM_from_editbmesh(em, false, false);
- deformVerts(md, ob, dm, vertexCos, numVerts, 0);
+ deformVerts(md, eval_ctx, ob, dm, vertexCos, numVerts, 0);
if (!derivedData) dm->release(dm);
}
diff --git a/source/blender/modifiers/intern/MOD_datatransfer.c b/source/blender/modifiers/intern/MOD_datatransfer.c
index 9fd23598cb6..e7069937868 100644
--- a/source/blender/modifiers/intern/MOD_datatransfer.c
+++ b/source/blender/modifiers/intern/MOD_datatransfer.c
@@ -152,7 +152,7 @@ static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams))
DT_TYPE_SHARP_FACE \
)
-static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *derivedData,
+static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *eval_ctx, Object *ob, DerivedMesh *derivedData,
ModifierApplyFlag UNUSED(flag))
{
DataTransferModifierData *dtmd = (DataTransferModifierData *) md;
@@ -184,7 +184,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
BKE_reports_init(&reports, RPT_STORE);
/* Note: no islands precision for now here. */
- BKE_object_data_transfer_dm(md->scene, dtmd->ob_source, ob, dm, dtmd->data_types, false,
+ BKE_object_data_transfer_dm(eval_ctx, md->scene, dtmd->ob_source, ob, dm, dtmd->data_types, false,
dtmd->vmap_mode, dtmd->emap_mode, dtmd->lmap_mode, dtmd->pmap_mode,
space_transform, false, max_dist, dtmd->map_ray_radius, 0.0f,
dtmd->layers_select_src, dtmd->layers_select_dst,
diff --git a/source/blender/modifiers/intern/MOD_decimate.c b/source/blender/modifiers/intern/MOD_decimate.c
index bcb52e4e0ca..078a3085fc7 100644
--- a/source/blender/modifiers/intern/MOD_decimate.c
+++ b/source/blender/modifiers/intern/MOD_decimate.c
@@ -86,8 +86,8 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
return dataMask;
}
-static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
- DerivedMesh *derivedData,
+static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ Object *ob, DerivedMesh *derivedData,
ModifierApplyFlag UNUSED(flag))
{
DecimateModifierData *dmd = (DecimateModifierData *) md;
diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c
index c422aa05b12..c9ccdc3b8c2 100644
--- a/source/blender/modifiers/intern/MOD_displace.c
+++ b/source/blender/modifiers/intern/MOD_displace.c
@@ -74,14 +74,10 @@ static void copyData(ModifierData *md, ModifierData *target)
{
#if 0
DisplaceModifierData *dmd = (DisplaceModifierData *) md;
-#endif
DisplaceModifierData *tdmd = (DisplaceModifierData *) target;
+#endif
modifier_copyData_generic(md, target);
-
- if (tdmd->texture) {
- id_us_plus(&tdmd->texture->id);
- }
}
static void freeData(ModifierData *md)
@@ -375,8 +371,8 @@ static void displaceModifier_do(
}
}
-static void deformVerts(ModifierData *md, Object *ob,
- DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3],
int numVerts,
ModifierApplyFlag UNUSED(flag))
@@ -391,7 +387,7 @@ static void deformVerts(ModifierData *md, Object *ob,
}
static void deformVertsEM(
- ModifierData *md, Object *ob, struct BMEditMesh *editData,
+ ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, struct BMEditMesh *editData,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
DerivedMesh *dm = get_cddm(ob, editData, derivedData, vertexCos, dependsOnNormals(md));
diff --git a/source/blender/modifiers/intern/MOD_dynamicpaint.c b/source/blender/modifiers/intern/MOD_dynamicpaint.c
index b1fe3535154..cf3f84364ea 100644
--- a/source/blender/modifiers/intern/MOD_dynamicpaint.c
+++ b/source/blender/modifiers/intern/MOD_dynamicpaint.c
@@ -41,8 +41,11 @@
#include "BKE_library_query.h"
#include "BKE_modifier.h"
+#include "DEG_depsgraph.h"
+
#include "DEG_depsgraph_build.h"
+#include "MOD_modifiertypes.h"
static void initData(ModifierData *md)
{
@@ -111,15 +114,15 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
return dataMask;
}
-static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
- DerivedMesh *dm,
+static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *eval_ctx,
+ Object *ob, DerivedMesh *dm,
ModifierApplyFlag flag)
{
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *) md;
/* dont apply dynamic paint on orco dm stack */
if (!(flag & MOD_APPLY_ORCO)) {
- return dynamicPaint_Modifier_do(pmd, md->scene, BKE_scene_layer_context_active(md->scene), ob, dm);
+ return dynamicPaint_Modifier_do(pmd, eval_ctx, md->scene, ob, dm);
}
return dm;
}
diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c
index f239807a7d3..0e344a851f2 100644
--- a/source/blender/modifiers/intern/MOD_edgesplit.c
+++ b/source/blender/modifiers/intern/MOD_edgesplit.c
@@ -48,6 +48,7 @@
#include "DNA_object_types.h"
+#include "MOD_modifiertypes.h"
static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd)
{
@@ -120,7 +121,8 @@ static void copyData(ModifierData *md, ModifierData *target)
modifier_copyData_generic(md, target);
}
-static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), DerivedMesh *dm,
+static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ Object *UNUSED(ob), DerivedMesh *dm,
ModifierApplyFlag UNUSED(flag))
{
DerivedMesh *result;
diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c
index 24ce2e3cc8e..38785abbc19 100644
--- a/source/blender/modifiers/intern/MOD_explode.c
+++ b/source/blender/modifiers/intern/MOD_explode.c
@@ -51,9 +51,9 @@
#include "BKE_particle.h"
#include "BKE_scene.h"
-
#include "MEM_guardedalloc.h"
+#include "MOD_modifiertypes.h"
static void initData(ModifierData *md)
{
@@ -785,9 +785,10 @@ static DerivedMesh *cutEdges(ExplodeModifierData *emd, DerivedMesh *dm)
return splitdm;
}
-static DerivedMesh *explodeMesh(ExplodeModifierData *emd,
- ParticleSystemModifierData *psmd, Scene *scene, Object *ob,
- DerivedMesh *to_explode)
+static DerivedMesh *explodeMesh(
+ ExplodeModifierData *emd,
+ ParticleSystemModifierData *psmd, const struct EvaluationContext *eval_ctx, Scene *scene,
+ Object *ob, DerivedMesh *to_explode)
{
DerivedMesh *explode, *dm = to_explode;
MFace *mf = NULL, *mface;
@@ -812,6 +813,7 @@ static DerivedMesh *explodeMesh(ExplodeModifierData *emd,
mface = dm->getTessFaceArray(dm);
totpart = psmd->psys->totpart;
+ sim.eval_ctx = eval_ctx;
sim.scene = scene;
sim.ob = ob;
sim.psys = psmd->psys;
@@ -993,8 +995,8 @@ static ParticleSystemModifierData *findPrecedingParticlesystem(Object *ob, Modif
}
return psmd;
}
-static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
- DerivedMesh *derivedData,
+static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *eval_ctx,
+ Object *ob, DerivedMesh *derivedData,
ModifierApplyFlag UNUSED(flag))
{
DerivedMesh *dm = derivedData;
@@ -1028,7 +1030,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
if (emd->flag & eExplodeFlag_EdgeCut) {
int *facepa = emd->facepa;
DerivedMesh *splitdm = cutEdges(emd, dm);
- DerivedMesh *explode = explodeMesh(emd, psmd, md->scene, ob, splitdm);
+ DerivedMesh *explode = explodeMesh(emd, psmd, eval_ctx, md->scene, ob, splitdm);
MEM_freeN(emd->facepa);
emd->facepa = facepa;
@@ -1036,7 +1038,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
return explode;
}
else
- return explodeMesh(emd, psmd, md->scene, ob, derivedData);
+ return explodeMesh(emd, psmd, eval_ctx, md->scene, ob, derivedData);
}
return derivedData;
}
diff --git a/source/blender/modifiers/intern/MOD_fluidsim.c b/source/blender/modifiers/intern/MOD_fluidsim.c
index 85eb7b2ffc9..f9e7f10653b 100644
--- a/source/blender/modifiers/intern/MOD_fluidsim.c
+++ b/source/blender/modifiers/intern/MOD_fluidsim.c
@@ -47,6 +47,8 @@
#include "DEG_depsgraph_build.h"
#include "MOD_fluidsim_util.h"
+#include "MOD_modifiertypes.h"
+
#include "MEM_guardedalloc.h"
/* Fluidsim */
@@ -80,8 +82,8 @@ static void copyData(ModifierData *md, ModifierData *target)
-static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
- DerivedMesh *dm,
+static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ Object *ob, DerivedMesh *dm,
ModifierApplyFlag flag)
{
FluidsimModifierData *fluidmd = (FluidsimModifierData *) md;
diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c
index 08103292a8b..25617c84dac 100644
--- a/source/blender/modifiers/intern/MOD_hook.c
+++ b/source/blender/modifiers/intern/MOD_hook.c
@@ -46,7 +46,6 @@
#include "BKE_deform.h"
#include "BKE_colortools.h"
-
#include "MEM_guardedalloc.h"
#include "MOD_util.h"
@@ -357,7 +356,7 @@ static void deformVerts_do(HookModifierData *hmd, Object *ob, DerivedMesh *dm,
}
}
-static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3], int numVerts,
ModifierApplyFlag UNUSED(flag))
{
@@ -373,7 +372,7 @@ static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData,
dm->release(dm);
}
-static void deformVertsEM(ModifierData *md, Object *ob, struct BMEditMesh *editData,
+static void deformVertsEM(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, struct BMEditMesh *editData,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
HookModifierData *hmd = (HookModifierData *) md;
diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.c b/source/blender/modifiers/intern/MOD_laplaciandeform.c
index 56a2e217a2a..d322b8631d2 100644
--- a/source/blender/modifiers/intern/MOD_laplaciandeform.c
+++ b/source/blender/modifiers/intern/MOD_laplaciandeform.c
@@ -29,7 +29,7 @@
*/
#include "BLI_utildefines.h"
-#include "BLI_stackdefines.h"
+#include "BLI_utildefines_stack.h"
#include "BLI_math.h"
#include "BLI_string.h"
@@ -539,7 +539,7 @@ static void initSystem(LaplacianDeformModifierData *lmd, Object *ob, DerivedMesh
STACK_PUSH(index_anchors, i);
}
}
- DM_ensure_looptri(dm);
+
total_anchors = STACK_SIZE(index_anchors);
lmd->cache_system = initLaplacianSystem(numVerts, dm->getNumEdges(dm), dm->getNumLoopTri(dm),
total_anchors, lmd->anchor_grp_name, lmd->repeat);
@@ -724,7 +724,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
return dataMask;
}
-static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3], int numVerts, ModifierApplyFlag UNUSED(flag))
{
DerivedMesh *dm = get_dm(ob, NULL, derivedData, NULL, false, false);
@@ -736,7 +736,7 @@ static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData,
}
static void deformVertsEM(
- ModifierData *md, Object *ob, struct BMEditMesh *editData,
+ ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, struct BMEditMesh *editData,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
DerivedMesh *dm = get_dm(ob, editData, derivedData, NULL, false, false);
diff --git a/source/blender/modifiers/intern/MOD_laplaciansmooth.c b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
index 1295a75d9e7..d7bc7b6c427 100644
--- a/source/blender/modifiers/intern/MOD_laplaciansmooth.c
+++ b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
@@ -506,7 +506,7 @@ static CustomDataMask required_data_mask(Object *UNUSED(ob), ModifierData *md)
return dataMask;
}
-static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3], int numVerts, ModifierApplyFlag UNUSED(flag))
{
DerivedMesh *dm;
@@ -524,7 +524,7 @@ static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData,
}
static void deformVertsEM(
- ModifierData *md, Object *ob, struct BMEditMesh *editData,
+ ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, struct BMEditMesh *editData,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
DerivedMesh *dm;
diff --git a/source/blender/modifiers/intern/MOD_lattice.c b/source/blender/modifiers/intern/MOD_lattice.c
index 8c723f1c4be..cd8b6139d75 100644
--- a/source/blender/modifiers/intern/MOD_lattice.c
+++ b/source/blender/modifiers/intern/MOD_lattice.c
@@ -103,8 +103,8 @@ static void updateDepsgraph(ModifierData *md,
DEG_add_object_relation(node, object, DEG_OB_COMP_TRANSFORM, "Lattice Modifier");
}
-static void deformVerts(ModifierData *md, Object *ob,
- DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3],
int numVerts,
ModifierApplyFlag UNUSED(flag))
@@ -119,14 +119,14 @@ static void deformVerts(ModifierData *md, Object *ob,
}
static void deformVertsEM(
- ModifierData *md, Object *ob, struct BMEditMesh *em,
+ ModifierData *md, const struct EvaluationContext *eval_ctx, Object *ob, struct BMEditMesh *em,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
DerivedMesh *dm = derivedData;
if (!derivedData) dm = CDDM_from_editbmesh(em, false, false);
- deformVerts(md, ob, dm, vertexCos, numVerts, 0);
+ deformVerts(md, eval_ctx, ob, dm, vertexCos, numVerts, 0);
if (!derivedData) dm->release(dm);
}
diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c
index 11c0fae9a75..d942b23b216 100644
--- a/source/blender/modifiers/intern/MOD_mask.c
+++ b/source/blender/modifiers/intern/MOD_mask.c
@@ -52,6 +52,8 @@
#include "DEG_depsgraph_build.h"
+#include "MOD_modifiertypes.h"
+
#include "BLI_strict_flags.h"
static void copyData(ModifierData *md, ModifierData *target)
@@ -92,8 +94,8 @@ static void updateDepsgraph(ModifierData *md,
}
}
-static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
- DerivedMesh *dm,
+static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ Object *ob, DerivedMesh *dm,
ModifierApplyFlag UNUSED(flag))
{
MaskModifierData *mmd = (MaskModifierData *)md;
diff --git a/source/blender/modifiers/intern/MOD_meshcache.c b/source/blender/modifiers/intern/MOD_meshcache.c
index 0d96032c515..c990951c578 100644
--- a/source/blender/modifiers/intern/MOD_meshcache.c
+++ b/source/blender/modifiers/intern/MOD_meshcache.c
@@ -272,8 +272,8 @@ static void meshcache_do(
}
}
-static void deformVerts(ModifierData *md, Object *ob,
- DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3],
int numVerts,
ModifierApplyFlag UNUSED(flag))
@@ -284,7 +284,7 @@ static void deformVerts(ModifierData *md, Object *ob,
}
static void deformVertsEM(
- ModifierData *md, Object *ob, struct BMEditMesh *UNUSED(editData),
+ ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, struct BMEditMesh *UNUSED(editData),
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
MeshCacheModifierData *mcmd = (MeshCacheModifierData *)md;
diff --git a/source/blender/modifiers/intern/MOD_meshcache_pc2.c b/source/blender/modifiers/intern/MOD_meshcache_pc2.c
index 8360c8ffda7..4b2b3f17d18 100644
--- a/source/blender/modifiers/intern/MOD_meshcache_pc2.c
+++ b/source/blender/modifiers/intern/MOD_meshcache_pc2.c
@@ -146,7 +146,7 @@ bool MOD_meshcache_read_pc2_index(FILE *fp,
return false;
}
- if (fseek(fp, sizeof(float) * 3 * index * pc2_head.verts_tot , SEEK_CUR) != 0) {
+ if (fseek(fp, sizeof(float) * 3 * index * pc2_head.verts_tot, SEEK_CUR) != 0) {
*err_str = "Failed to seek frame";
return false;
}
diff --git a/source/blender/modifiers/intern/MOD_meshcache_util.c b/source/blender/modifiers/intern/MOD_meshcache_util.c
index c263c4810e4..10861f5b02b 100644
--- a/source/blender/modifiers/intern/MOD_meshcache_util.c
+++ b/source/blender/modifiers/intern/MOD_meshcache_util.c
@@ -36,7 +36,7 @@ void MOD_meshcache_calc_range(const float frame, const char interp,
int r_index_range[2], float *r_factor)
{
if (interp == MOD_MESHCACHE_INTERP_NONE) {
- r_index_range[0] = r_index_range[1] = max_ii(0, min_ii(frame_tot - 1, iroundf(frame)));
+ r_index_range[0] = r_index_range[1] = max_ii(0, min_ii(frame_tot - 1, round_fl_to_int(frame)));
*r_factor = 1.0f; /* dummy */
}
else {
diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c
index 3c05f8266f0..ab43204365d 100644
--- a/source/blender/modifiers/intern/MOD_meshdeform.c
+++ b/source/blender/modifiers/intern/MOD_meshdeform.c
@@ -272,7 +272,7 @@ static void meshdeform_vert_task(void *userdata, const int iter)
}
static void meshdeformModifier_do(
- ModifierData *md, Object *ob, DerivedMesh *dm,
+ ModifierData *md, const struct EvaluationContext *eval_ctx, Object *ob, DerivedMesh *dm,
float (*vertexCos)[3], int numVerts)
{
MeshDeformModifierData *mmd = (MeshDeformModifierData *) md;
@@ -299,7 +299,7 @@ static void meshdeformModifier_do(
*/
if (mmd->object == md->scene->obedit) {
BMEditMesh *em = BKE_editmesh_from_object(mmd->object);
- tmpdm = editbmesh_get_derived_cage_and_final(md->scene, mmd->object, em, 0, &cagedm);
+ tmpdm = editbmesh_get_derived_cage_and_final(eval_ctx, md->scene, mmd->object, em, 0, &cagedm);
if (tmpdm)
tmpdm->release(tmpdm);
}
@@ -402,7 +402,7 @@ static void meshdeformModifier_do(
cagedm->release(cagedm);
}
-static void deformVerts(ModifierData *md, Object *ob,
+static void deformVerts(ModifierData *md, const struct EvaluationContext *eval_ctx, Object *ob,
DerivedMesh *derivedData,
float (*vertexCos)[3],
int numVerts,
@@ -412,13 +412,13 @@ static void deformVerts(ModifierData *md, Object *ob,
modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */
- meshdeformModifier_do(md, ob, dm, vertexCos, numVerts);
+ meshdeformModifier_do(md, eval_ctx, ob, dm, vertexCos, numVerts);
if (dm && dm != derivedData)
dm->release(dm);
}
-static void deformVertsEM(ModifierData *md, Object *ob,
+static void deformVertsEM(ModifierData *md, const struct EvaluationContext *eval_ctx, Object *ob,
struct BMEditMesh *UNUSED(editData),
DerivedMesh *derivedData,
float (*vertexCos)[3],
@@ -426,7 +426,7 @@ static void deformVertsEM(ModifierData *md, Object *ob,
{
DerivedMesh *dm = get_dm(ob, NULL, derivedData, NULL, false, false);
- meshdeformModifier_do(md, ob, dm, vertexCos, numVerts);
+ meshdeformModifier_do(md, eval_ctx, ob, dm, vertexCos, numVerts);
if (dm && dm != derivedData)
dm->release(dm);
diff --git a/source/blender/modifiers/intern/MOD_meshsequencecache.c b/source/blender/modifiers/intern/MOD_meshsequencecache.c
index df13cadd184..86c2a24eddf 100644
--- a/source/blender/modifiers/intern/MOD_meshsequencecache.c
+++ b/source/blender/modifiers/intern/MOD_meshsequencecache.c
@@ -25,12 +25,14 @@
*/
#include "DNA_cachefile_types.h"
+#include "DNA_mesh_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BKE_cachefile.h"
#include "BKE_DerivedMesh.h"
+#include "BKE_cdderivedmesh.h"
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_library_query.h"
@@ -92,13 +94,17 @@ static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams))
return (mcmd->cache_file == NULL) || (mcmd->object_path[0] == '\0');
}
-static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
- DerivedMesh *dm,
- ModifierApplyFlag flag)
+static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ Object *ob, DerivedMesh *dm,
+ ModifierApplyFlag UNUSED(flag))
{
#ifdef WITH_ALEMBIC
MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *) md;
+ /* Only used to check whether we are operating on org data or not... */
+ Mesh *me = (ob->type == OB_MESH) ? ob->data : NULL;
+ DerivedMesh *org_dm = dm;
+
Scene *scene = md->scene;
const float frame = BKE_scene_frame_get(scene);
const float time = BKE_cachefile_time_offset(mcmd->cache_file, frame, FPS);
@@ -120,6 +126,16 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
}
}
+ if (me != NULL) {
+ MVert *mvert = dm->getVertArray(dm);
+ MEdge *medge = dm->getEdgeArray(dm);
+ MPoly *mpoly = dm->getPolyArray(dm);
+ if ((me->mvert == mvert) || (me->medge == medge) || (me->mpoly == mpoly)) {
+ /* We need to duplicate data here, otherwise we'll modify org mesh, see T51701. */
+ dm = CDDM_copy(dm);
+ }
+ }
+
DerivedMesh *result = ABC_read_mesh(mcmd->reader,
ob,
dm,
@@ -131,11 +147,15 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
modifier_setError(md, "%s", err_str);
}
+ if (!ELEM(result, NULL, dm) && (dm != org_dm)) {
+ dm->release(dm);
+ dm = org_dm;
+ }
+
return result ? result : dm;
- UNUSED_VARS(flag);
#else
return dm;
- UNUSED_VARS(md, ob, flag);
+ UNUSED_VARS(md, ob);
#endif
}
diff --git a/source/blender/modifiers/intern/MOD_mirror.c b/source/blender/modifiers/intern/MOD_mirror.c
index e0c37e8a0ce..db06dc43b8e 100644
--- a/source/blender/modifiers/intern/MOD_mirror.c
+++ b/source/blender/modifiers/intern/MOD_mirror.c
@@ -47,6 +47,8 @@
#include "DEG_depsgraph_build.h"
+#include "MOD_modifiertypes.h"
+
static void initData(ModifierData *md)
{
MirrorModifierData *mmd = (MirrorModifierData *) md;
@@ -247,7 +249,7 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd,
/* handle uvs,
* let tessface recalc handle updating the MTFace data */
- if (mmd->flag & (MOD_MIR_MIRROR_U | MOD_MIR_MIRROR_V)) {
+ if (mmd->flag & (MOD_MIR_MIRROR_U | MOD_MIR_MIRROR_V) || (is_zero_v2(mmd->uv_offset_copy) == false)) {
const bool do_mirr_u = (mmd->flag & MOD_MIR_MIRROR_U) != 0;
const bool do_mirr_v = (mmd->flag & MOD_MIR_MIRROR_V) != 0;
@@ -260,6 +262,8 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd,
for (; j-- > 0; dmloopuv++) {
if (do_mirr_u) dmloopuv->uv[0] = 1.0f - dmloopuv->uv[0] + mmd->uv_offset[0];
if (do_mirr_v) dmloopuv->uv[1] = 1.0f - dmloopuv->uv[1] + mmd->uv_offset[1];
+ dmloopuv->uv[0] += mmd->uv_offset_copy[0];
+ dmloopuv->uv[1] += mmd->uv_offset_copy[1];
}
}
}
@@ -319,8 +323,8 @@ static DerivedMesh *mirrorModifier__doMirror(MirrorModifierData *mmd,
return result;
}
-static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
- DerivedMesh *derivedData,
+static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ Object *ob, DerivedMesh *derivedData,
ModifierApplyFlag UNUSED(flag))
{
DerivedMesh *result;
diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c
index aba184b7d40..2b675d36140 100644
--- a/source/blender/modifiers/intern/MOD_multires.c
+++ b/source/blender/modifiers/intern/MOD_multires.c
@@ -46,6 +46,8 @@
#include "BKE_modifier.h"
#include "BKE_subsurf.h"
+#include "MOD_modifiertypes.h"
+
static void initData(ModifierData *md)
{
MultiresModifierData *mmd = (MultiresModifierData *)md;
@@ -65,8 +67,8 @@ static void copyData(ModifierData *md, ModifierData *target)
modifier_copyData_generic(md, target);
}
-static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm,
- ModifierApplyFlag flag)
+static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob,
+ DerivedMesh *dm, ModifierApplyFlag flag)
{
MultiresModifierData *mmd = (MultiresModifierData *)md;
DerivedMesh *result;
diff --git a/source/blender/modifiers/intern/MOD_normal_edit.c b/source/blender/modifiers/intern/MOD_normal_edit.c
index fa4d33f2e95..1c7c640b971 100644
--- a/source/blender/modifiers/intern/MOD_normal_edit.c
+++ b/source/blender/modifiers/intern/MOD_normal_edit.c
@@ -521,7 +521,8 @@ static void updateDepsgraph(ModifierData *md,
}
}
-static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm, ModifierApplyFlag UNUSED(flag))
+static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob,
+ DerivedMesh *dm, ModifierApplyFlag UNUSED(flag))
{
return normalEditModifier_do((NormalEditModifierData *)md, ob, dm);
}
diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c
index 120337eb2ea..189cfb8553e 100644
--- a/source/blender/modifiers/intern/MOD_ocean.c
+++ b/source/blender/modifiers/intern/MOD_ocean.c
@@ -44,6 +44,8 @@
#include "BKE_modifier.h"
#include "BKE_ocean.h"
+#include "MOD_modifiertypes.h"
+
#ifdef WITH_OCEANSIM
static void init_cache_data(Object *ob, struct OceanModifierData *omd)
{
@@ -540,8 +542,8 @@ static DerivedMesh *doOcean(ModifierData *md, Object *UNUSED(ob),
}
#endif /* WITH_OCEANSIM */
-static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
- DerivedMesh *derivedData,
+static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ Object *ob, DerivedMesh *derivedData,
ModifierApplyFlag UNUSED(flag))
{
DerivedMesh *result;
diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c b/source/blender/modifiers/intern/MOD_particleinstance.c
index 316d51b9581..de59635f335 100644
--- a/source/blender/modifiers/intern/MOD_particleinstance.c
+++ b/source/blender/modifiers/intern/MOD_particleinstance.c
@@ -53,6 +53,8 @@
#include "DEG_depsgraph_build.h"
+#include "MOD_modifiertypes.h"
+
static void initData(ModifierData *md)
{
ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *) md;
@@ -164,8 +166,8 @@ static int particle_skip(ParticleInstanceModifierData *pimd, ParticleSystem *psy
return 0;
}
-static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
- DerivedMesh *derivedData,
+static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *eval_ctx,
+ Object *ob, DerivedMesh *derivedData,
ModifierApplyFlag UNUSED(flag))
{
DerivedMesh *dm = derivedData, *result;
@@ -210,6 +212,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
if (totpart == 0)
return derivedData;
+ sim.eval_ctx = eval_ctx;
sim.scene = md->scene;
sim.ob = pimd->ob;
sim.psys = psys;
diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c
index a3b9d808b17..9cc6e5f56b5 100644
--- a/source/blender/modifiers/intern/MOD_particlesystem.c
+++ b/source/blender/modifiers/intern/MOD_particlesystem.c
@@ -97,8 +97,8 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
}
/* saves the current emitter state for a particle system and calculates particles */
-static void deformVerts(ModifierData *md, Object *ob,
- DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, const struct EvaluationContext *eval_ctx,
+ Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3],
int UNUSED(numVerts),
ModifierApplyFlag flag)
@@ -186,7 +186,7 @@ static void deformVerts(ModifierData *md, Object *ob,
if (!(ob->transflag & OB_NO_PSYS_UPDATE)) {
psmd->flag &= ~eParticleSystemFlag_psys_updated;
- particle_system_update(md->scene, ob, psys, (flag & MOD_APPLY_RENDER) != 0);
+ particle_system_update(eval_ctx, md->scene, ob, psys, (flag & MOD_APPLY_RENDER) != 0);
psmd->flag |= eParticleSystemFlag_psys_updated;
}
}
diff --git a/source/blender/modifiers/intern/MOD_remesh.c b/source/blender/modifiers/intern/MOD_remesh.c
index fb5c12399a4..c9070cced7e 100644
--- a/source/blender/modifiers/intern/MOD_remesh.c
+++ b/source/blender/modifiers/intern/MOD_remesh.c
@@ -143,6 +143,7 @@ static void dualcon_add_quad(void *output_v, const int vert_indices[4])
}
static DerivedMesh *applyModifier(ModifierData *md,
+ const struct EvaluationContext *UNUSED(eval_ctx),
Object *UNUSED(ob),
DerivedMesh *dm,
ModifierApplyFlag UNUSED(flag))
@@ -203,7 +204,9 @@ static DerivedMesh *applyModifier(ModifierData *md,
#else /* !WITH_MOD_REMESH */
-static DerivedMesh *applyModifier(ModifierData *UNUSED(md), Object *UNUSED(ob),
+static DerivedMesh *applyModifier(ModifierData *UNUSED(md),
+ const struct EvaluationContext *UNUSED(eval_ctx),
+ Object *UNUSED(ob),
DerivedMesh *derivedData,
ModifierApplyFlag UNUSED(flag))
{
diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c
index f62c68b56c9..010bf8bf092 100644
--- a/source/blender/modifiers/intern/MOD_screw.c
+++ b/source/blender/modifiers/intern/MOD_screw.c
@@ -111,6 +111,56 @@ static void screwvert_iter_step(ScrewVertIter *iter)
}
}
+static DerivedMesh *dm_remove_doubles_on_axis(
+ DerivedMesh *result, MVert *mvert_new, const uint totvert, const uint step_tot,
+ const float axis_vec[3], const float axis_offset[3], const float merge_threshold)
+{
+ const float merge_threshold_sq = SQUARE(merge_threshold);
+ const bool use_offset = axis_offset != NULL;
+ uint tot_doubles = 0;
+ for (uint i = 0; i < totvert; i += 1) {
+ float axis_co[3];
+ if (use_offset) {
+ float offset_co[3];
+ sub_v3_v3v3(offset_co, mvert_new[i].co, axis_offset);
+ project_v3_v3v3_normalized(axis_co, offset_co, axis_vec);
+ add_v3_v3(axis_co, axis_offset);
+ }
+ else {
+ project_v3_v3v3_normalized(axis_co, mvert_new[i].co, axis_vec);
+ }
+ const float dist_sq = len_squared_v3v3(axis_co, mvert_new[i].co);
+ if (dist_sq <= merge_threshold_sq) {
+ mvert_new[i].flag |= ME_VERT_TMP_TAG;
+ tot_doubles += 1;
+ copy_v3_v3(mvert_new[i].co, axis_co);
+ }
+ }
+
+ if (tot_doubles != 0) {
+ uint tot = totvert * step_tot;
+ int *full_doubles_map = MEM_mallocN(sizeof(int) * tot, __func__);
+ copy_vn_i(full_doubles_map, (int)tot, -1);
+
+ uint tot_doubles_left = tot_doubles;
+ for (uint i = 0; i < totvert; i += 1) {
+ if (mvert_new[i].flag & ME_VERT_TMP_TAG) {
+ int *doubles_map = &full_doubles_map[totvert + i] ;
+ for (uint step = 1; step < step_tot; step += 1) {
+ *doubles_map = (int)i;
+ doubles_map += totvert;
+ }
+ tot_doubles_left -= 1;
+ if (tot_doubles_left == 0) {
+ break;
+ }
+ }
+ }
+ result = CDDM_merge_verts(result, full_doubles_map, (int)(tot_doubles * (step_tot - 1)), CDDM_MERGE_VERTS_DUMP_IF_MAPPED);
+ MEM_freeN(full_doubles_map);
+ }
+ return result;
+}
static void initData(ModifierData *md)
{
@@ -122,6 +172,7 @@ static void initData(ModifierData *md)
ltmd->steps = 16;
ltmd->render_steps = 16;
ltmd->iter = 1;
+ ltmd->merge_dist = 0.01f;
}
static void copyData(ModifierData *md, ModifierData *target)
@@ -133,8 +184,8 @@ static void copyData(ModifierData *md, ModifierData *target)
modifier_copyData_generic(md, target);
}
-static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
- DerivedMesh *derivedData,
+static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ Object *ob, DerivedMesh *derivedData,
ModifierApplyFlag flag)
{
DerivedMesh *dm = derivedData;
@@ -1049,6 +1100,16 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
MEM_freeN(vert_loop_map);
}
+ if ((ltmd->flag & MOD_SCREW_MERGE) && (screw_ofs == 0.0f)) {
+ DerivedMesh *result_prev = result;
+ result = dm_remove_doubles_on_axis(
+ result, mvert_new, totvert, step_tot,
+ axis_vec, ltmd->ob_axis ? mtx_tx[3] : NULL, ltmd->merge_dist);
+ if (result != result_prev) {
+ result->dirty |= DM_DIRTY_NORMALS;
+ }
+ }
+
if ((ltmd->flag & MOD_SCREW_NORMAL_CALC) == 0) {
result->dirty |= DM_DIRTY_NORMALS;
}
diff --git a/source/blender/modifiers/intern/MOD_shapekey.c b/source/blender/modifiers/intern/MOD_shapekey.c
index 6c8bd06c196..822decea423 100644
--- a/source/blender/modifiers/intern/MOD_shapekey.c
+++ b/source/blender/modifiers/intern/MOD_shapekey.c
@@ -44,8 +44,8 @@
#include "MOD_modifiertypes.h"
-static void deformVerts(ModifierData *UNUSED(md), Object *ob,
- DerivedMesh *UNUSED(derivedData),
+static void deformVerts(ModifierData *UNUSED(md), const struct EvaluationContext *UNUSED(eval_ctx),
+ Object *ob, DerivedMesh *UNUSED(derivedData),
float (*vertexCos)[3],
int numVerts,
ModifierApplyFlag UNUSED(flag))
@@ -61,7 +61,7 @@ static void deformVerts(ModifierData *UNUSED(md), Object *ob,
}
}
-static void deformMatrices(ModifierData *md, Object *ob, DerivedMesh *derivedData,
+static void deformMatrices(ModifierData *md, const struct EvaluationContext *eval_ctx, Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3], float (*defMats)[3][3], int numVerts)
{
Key *key = BKE_key_from_object(ob);
@@ -80,10 +80,10 @@ static void deformMatrices(ModifierData *md, Object *ob, DerivedMesh *derivedDat
copy_m3_m3(defMats[a], scale);
}
- deformVerts(md, ob, derivedData, vertexCos, numVerts, 0);
+ deformVerts(md, eval_ctx, ob, derivedData, vertexCos, numVerts, 0);
}
-static void deformVertsEM(ModifierData *md, Object *ob,
+static void deformVertsEM(ModifierData *md, const struct EvaluationContext *eval_ctx, Object *ob,
struct BMEditMesh *UNUSED(editData),
DerivedMesh *derivedData,
float (*vertexCos)[3],
@@ -92,11 +92,11 @@ static void deformVertsEM(ModifierData *md, Object *ob,
Key *key = BKE_key_from_object(ob);
if (key && key->type == KEY_RELATIVE)
- deformVerts(md, ob, derivedData, vertexCos, numVerts, 0);
+ deformVerts(md, eval_ctx, ob, derivedData, vertexCos, numVerts, 0);
}
-static void deformMatricesEM(ModifierData *UNUSED(md), Object *ob,
- struct BMEditMesh *UNUSED(editData),
+static void deformMatricesEM(ModifierData *UNUSED(md), const struct EvaluationContext *UNUSED(eval_ctx),
+ Object *ob, struct BMEditMesh *UNUSED(editData),
DerivedMesh *UNUSED(derivedData),
float (*vertexCos)[3],
float (*defMats)[3][3],
diff --git a/source/blender/modifiers/intern/MOD_shrinkwrap.c b/source/blender/modifiers/intern/MOD_shrinkwrap.c
index 32241d8390a..c87fdd321ab 100644
--- a/source/blender/modifiers/intern/MOD_shrinkwrap.c
+++ b/source/blender/modifiers/intern/MOD_shrinkwrap.c
@@ -103,8 +103,8 @@ static void foreachObjectLink(ModifierData *md, Object *ob, ObjectWalkFunc walk,
walk(userData, ob, &smd->auxTarget, IDWALK_CB_NOP);
}
-static void deformVerts(ModifierData *md, Object *ob,
- DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3],
int numVerts,
ModifierApplyFlag flag)
@@ -124,7 +124,8 @@ static void deformVerts(ModifierData *md, Object *ob,
dm->release(dm);
}
-static void deformVertsEM(ModifierData *md, Object *ob, struct BMEditMesh *editData, DerivedMesh *derivedData,
+static void deformVertsEM(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob,
+ struct BMEditMesh *editData, DerivedMesh *derivedData,
float (*vertexCos)[3], int numVerts)
{
DerivedMesh *dm = derivedData;
diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c
index 4660afc0977..146e882a6b6 100644
--- a/source/blender/modifiers/intern/MOD_simpledeform.c
+++ b/source/blender/modifiers/intern/MOD_simpledeform.c
@@ -302,8 +302,8 @@ static void updateDepsgraph(ModifierData *md,
}
}
-static void deformVerts(ModifierData *md, Object *ob,
- DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3],
int numVerts,
ModifierApplyFlag UNUSED(flag))
@@ -322,8 +322,8 @@ static void deformVerts(ModifierData *md, Object *ob,
dm->release(dm);
}
-static void deformVertsEM(ModifierData *md, Object *ob,
- struct BMEditMesh *editData,
+static void deformVertsEM(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ Object *ob, struct BMEditMesh *editData,
DerivedMesh *derivedData,
float (*vertexCos)[3],
int numVerts)
diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c
index 4b84aeb335a..9d1c6913c1c 100644
--- a/source/blender/modifiers/intern/MOD_skin.c
+++ b/source/blender/modifiers/intern/MOD_skin.c
@@ -77,6 +77,8 @@
#include "BKE_mesh_mapping.h"
#include "BKE_modifier.h"
+#include "MOD_modifiertypes.h"
+
#include "bmesh.h"
typedef struct {
@@ -1915,6 +1917,7 @@ static void copyData(ModifierData *md, ModifierData *target)
}
static DerivedMesh *applyModifier(ModifierData *md,
+ const struct EvaluationContext *UNUSED(eval_ctx),
Object *UNUSED(ob),
DerivedMesh *dm,
ModifierApplyFlag UNUSED(flag))
diff --git a/source/blender/modifiers/intern/MOD_smoke.c b/source/blender/modifiers/intern/MOD_smoke.c
index a11b0f887ea..e66afe07841 100644
--- a/source/blender/modifiers/intern/MOD_smoke.c
+++ b/source/blender/modifiers/intern/MOD_smoke.c
@@ -45,7 +45,6 @@
#include "BLI_utildefines.h"
-
#include "BKE_cdderivedmesh.h"
#include "BKE_layer.h"
#include "BKE_library.h"
@@ -54,8 +53,11 @@
#include "BKE_modifier.h"
#include "BKE_smoke.h"
+#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
+#include "MOD_modifiertypes.h"
+
static void initData(ModifierData *md)
{
SmokeModifierData *smd = (SmokeModifierData *) md;
@@ -100,8 +102,8 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
return dataMask;
}
-static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
- DerivedMesh *dm,
+static DerivedMesh *applyModifier(ModifierData *md, const EvaluationContext *eval_ctx,
+ Object *ob, DerivedMesh *dm,
ModifierApplyFlag flag)
{
SmokeModifierData *smd = (SmokeModifierData *) md;
@@ -109,7 +111,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
if (flag & MOD_APPLY_ORCO)
return dm;
- return smokeModifier_do(smd, md->scene, BKE_scene_layer_context_active(md->scene), ob, dm);
+ return smokeModifier_do(smd, eval_ctx, md->scene, ob, dm);
}
static bool dependsOnTime(ModifierData *UNUSED(md))
diff --git a/source/blender/modifiers/intern/MOD_smooth.c b/source/blender/modifiers/intern/MOD_smooth.c
index f0f20acb8ea..be55030e18a 100644
--- a/source/blender/modifiers/intern/MOD_smooth.c
+++ b/source/blender/modifiers/intern/MOD_smooth.c
@@ -215,7 +215,7 @@ static void smoothModifier_do(
MEM_freeN(uctmp);
}
-static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3], int numVerts, ModifierApplyFlag UNUSED(flag))
{
DerivedMesh *dm = get_dm(ob, NULL, derivedData, NULL, false, false);
@@ -228,7 +228,7 @@ static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData,
}
static void deformVertsEM(
- ModifierData *md, Object *ob, struct BMEditMesh *editData,
+ ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, struct BMEditMesh *editData,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
DerivedMesh *dm = get_dm(ob, editData, derivedData, NULL, false, false);
diff --git a/source/blender/modifiers/intern/MOD_softbody.c b/source/blender/modifiers/intern/MOD_softbody.c
index 5468b8a61f0..020dd3da6a5 100644
--- a/source/blender/modifiers/intern/MOD_softbody.c
+++ b/source/blender/modifiers/intern/MOD_softbody.c
@@ -44,17 +44,18 @@
#include "BKE_particle.h"
#include "BKE_softbody.h"
+#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
#include "MOD_modifiertypes.h"
-static void deformVerts(ModifierData *md, Object *ob,
+static void deformVerts(ModifierData *md, const EvaluationContext *eval_ctx, Object *ob,
DerivedMesh *UNUSED(derivedData),
float (*vertexCos)[3],
int numVerts,
ModifierApplyFlag UNUSED(flag))
{
- sbObjectStep(md->scene, BKE_scene_layer_context_active(md->scene), ob, (float)md->scene->r.cfra, vertexCos, numVerts);
+ sbObjectStep(eval_ctx, md->scene, ob, (float)md->scene->r.cfra, vertexCos, numVerts);
}
static bool dependsOnTime(ModifierData *UNUSED(md))
diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c
index e589cb7d713..14b29855728 100644
--- a/source/blender/modifiers/intern/MOD_solidify.c
+++ b/source/blender/modifiers/intern/MOD_solidify.c
@@ -36,7 +36,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
-#include "BLI_stackdefines.h"
+#include "BLI_utildefines_stack.h"
#include "BLI_bitmap.h"
#include "BLI_math.h"
@@ -205,8 +205,8 @@ BLI_INLINE void madd_v3v3short_fl(float r[3], const short a[3], const float f)
}
static DerivedMesh *applyModifier(
- ModifierData *md, Object *ob,
- DerivedMesh *dm,
+ ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ Object *ob, DerivedMesh *dm,
ModifierApplyFlag UNUSED(flag))
{
DerivedMesh *result;
diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c
index 407fd63d5c3..6a07f842cf3 100644
--- a/source/blender/modifiers/intern/MOD_subsurf.c
+++ b/source/blender/modifiers/intern/MOD_subsurf.c
@@ -98,8 +98,8 @@ static bool isDisabled(ModifierData *md, int useRenderParams)
return get_render_subsurf_level(&md->scene->r, levels, useRenderParams != 0) == 0;
}
-static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
- DerivedMesh *derivedData,
+static DerivedMesh *applyModifier(ModifierData *md, const EvaluationContext *UNUSED(eval_ctx),
+ Object *ob, DerivedMesh *derivedData,
ModifierApplyFlag flag)
{
SubsurfModifierData *smd = (SubsurfModifierData *) md;
@@ -135,7 +135,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
else if ((ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) != 0) {
modifier_setError(md, "OpenSubdiv is not supported in paint modes");
}
- else if ((DEG_get_eval_flags_for_id(md->scene->depsgraph, &ob->id) & DAG_EVAL_NEED_CPU) == 0) {
+ /* TODO(sergey): How do we get depsgraph here? */
+ else if ((DEG_get_eval_flags_for_id(md->scene->depsgraph_legacy, &ob->id) & DAG_EVAL_NEED_CPU) == 0) {
subsurf_flags |= SUBSURF_USE_GPU_BACKEND;
do_cddm_convert = false;
}
@@ -161,10 +162,11 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
return result;
}
-static DerivedMesh *applyModifierEM(ModifierData *md, Object *UNUSED(ob),
- struct BMEditMesh *UNUSED(editData),
- DerivedMesh *derivedData,
- ModifierApplyFlag flag)
+static DerivedMesh *applyModifierEM(
+ ModifierData *md, const EvaluationContext *UNUSED(eval_ctx),
+ Object *UNUSED(ob), struct BMEditMesh *UNUSED(editData),
+ DerivedMesh *derivedData,
+ ModifierApplyFlag flag)
{
SubsurfModifierData *smd = (SubsurfModifierData *) md;
DerivedMesh *result;
diff --git a/source/blender/modifiers/intern/MOD_surface.c b/source/blender/modifiers/intern/MOD_surface.c
index ea68f540236..c408b4fbd63 100644
--- a/source/blender/modifiers/intern/MOD_surface.c
+++ b/source/blender/modifiers/intern/MOD_surface.c
@@ -85,8 +85,8 @@ static bool dependsOnTime(ModifierData *UNUSED(md))
return true;
}
-static void deformVerts(ModifierData *md, Object *ob,
- DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3],
int UNUSED(numVerts),
ModifierApplyFlag UNUSED(flag))
diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c
index 9339d71524f..b623293ed5c 100644
--- a/source/blender/modifiers/intern/MOD_surfacedeform.c
+++ b/source/blender/modifiers/intern/MOD_surfacedeform.c
@@ -1162,16 +1162,16 @@ static void surfacedeformModifier_do(ModifierData *md, float (*vertexCos)[3], un
}
}
-static void deformVerts(ModifierData *md, Object *ob,
- DerivedMesh *UNUSED(derivedData),
+static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ Object *ob, DerivedMesh *UNUSED(derivedData),
float (*vertexCos)[3], int numVerts,
ModifierApplyFlag UNUSED(flag))
{
surfacedeformModifier_do(md, vertexCos, numVerts, ob);
}
-static void deformVertsEM(ModifierData *md, Object *ob,
- struct BMEditMesh *UNUSED(editData),
+static void deformVertsEM(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ Object *ob, struct BMEditMesh *UNUSED(editData),
DerivedMesh *UNUSED(derivedData),
float (*vertexCos)[3], int numVerts)
{
diff --git a/source/blender/modifiers/intern/MOD_triangulate.c b/source/blender/modifiers/intern/MOD_triangulate.c
index a5d826a69ba..5dd7e3dfda4 100644
--- a/source/blender/modifiers/intern/MOD_triangulate.c
+++ b/source/blender/modifiers/intern/MOD_triangulate.c
@@ -35,6 +35,8 @@
#include "bmesh.h"
#include "bmesh_tools.h"
+#include "MOD_modifiertypes.h"
+
static DerivedMesh *triangulate_dm(DerivedMesh *dm, const int quad_method, const int ngon_method)
{
DerivedMesh *result;
@@ -83,6 +85,7 @@ static void copyData(ModifierData *md, ModifierData *target)
}
static DerivedMesh *applyModifier(ModifierData *md,
+ const struct EvaluationContext *UNUSED(eval_ctx),
Object *UNUSED(ob),
DerivedMesh *dm,
ModifierApplyFlag UNUSED(flag))
diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c
index cae83282238..c9a842621b6 100644
--- a/source/blender/modifiers/intern/MOD_uvproject.c
+++ b/source/blender/modifiers/intern/MOD_uvproject.c
@@ -335,8 +335,8 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
return dm;
}
-static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
- DerivedMesh *derivedData,
+static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ Object *ob, DerivedMesh *derivedData,
ModifierApplyFlag UNUSED(flag))
{
DerivedMesh *result;
diff --git a/source/blender/modifiers/intern/MOD_uvwarp.c b/source/blender/modifiers/intern/MOD_uvwarp.c
index 7ee0a7e3108..3773eed26dc 100644
--- a/source/blender/modifiers/intern/MOD_uvwarp.c
+++ b/source/blender/modifiers/intern/MOD_uvwarp.c
@@ -143,8 +143,8 @@ static void uv_warp_compute(void *userdata, const int i)
}
}
-static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
- DerivedMesh *dm,
+static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ Object *ob, DerivedMesh *dm,
ModifierApplyFlag UNUSED(flag))
{
UVWarpModifierData *umd = (UVWarpModifierData *) md;
diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c
index c9a9e20df23..566ee5b2d24 100644
--- a/source/blender/modifiers/intern/MOD_warp.c
+++ b/source/blender/modifiers/intern/MOD_warp.c
@@ -313,7 +313,7 @@ static int warp_needs_dm(WarpModifierData *wmd)
return wmd->texture || wmd->defgrp_name[0];
}
-static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3], int numVerts, ModifierApplyFlag UNUSED(flag))
{
DerivedMesh *dm = NULL;
@@ -330,7 +330,7 @@ static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData,
}
}
-static void deformVertsEM(ModifierData *md, Object *ob, struct BMEditMesh *em,
+static void deformVertsEM(ModifierData *md, const struct EvaluationContext *eval_ctx, Object *ob, struct BMEditMesh *em,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
DerivedMesh *dm = derivedData;
@@ -341,7 +341,7 @@ static void deformVertsEM(ModifierData *md, Object *ob, struct BMEditMesh *em,
dm = CDDM_from_editbmesh(em, false, false);
}
- deformVerts(md, ob, dm, vertexCos, numVerts, 0);
+ deformVerts(md, eval_ctx, ob, dm, vertexCos, numVerts, 0);
if (use_dm) {
if (!derivedData) dm->release(dm);
diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c
index 73e96f87c66..8b7af867b7d 100644
--- a/source/blender/modifiers/intern/MOD_wave.c
+++ b/source/blender/modifiers/intern/MOD_wave.c
@@ -88,14 +88,10 @@ static void copyData(ModifierData *md, ModifierData *target)
{
#if 0
WaveModifierData *wmd = (WaveModifierData *) md;
-#endif
WaveModifierData *twmd = (WaveModifierData *) target;
+#endif
modifier_copyData_generic(md, target);
-
- if (twmd->texture) {
- id_us_plus(&twmd->texture->id);
- }
}
static bool dependsOnTime(ModifierData *UNUSED(md))
@@ -314,8 +310,8 @@ static void waveModifier_do(WaveModifierData *md,
if (wmd->texture) MEM_freeN(tex_co);
}
-static void deformVerts(ModifierData *md, Object *ob,
- DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3],
int numVerts,
ModifierApplyFlag UNUSED(flag))
@@ -335,7 +331,7 @@ static void deformVerts(ModifierData *md, Object *ob,
}
static void deformVertsEM(
- ModifierData *md, Object *ob, struct BMEditMesh *editData,
+ ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, struct BMEditMesh *editData,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
DerivedMesh *dm = derivedData;
diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c
index e6603b81bfd..dbdaafaa5a7 100644
--- a/source/blender/modifiers/intern/MOD_weightvgedit.c
+++ b/source/blender/modifiers/intern/MOD_weightvgedit.c
@@ -49,7 +49,9 @@
#include "DEG_depsgraph_build.h"
#include "MEM_guardedalloc.h"
+
#include "MOD_weightvg_util.h"
+#include "MOD_modifiertypes.h"
/**************************************
* Modifiers functions. *
@@ -90,10 +92,6 @@ static void copyData(ModifierData *md, ModifierData *target)
modifier_copyData_generic(md, target);
twmd->cmap_curve = curvemapping_copy(wmd->cmap_curve);
-
- if (twmd->mask_texture) {
- id_us_plus(&twmd->mask_texture->id);
- }
}
static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
@@ -164,7 +162,10 @@ static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams))
return (wmd->defgrp_name[0] == '\0');
}
-static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *derivedData,
+static DerivedMesh *applyModifier(ModifierData *md,
+ const struct EvaluationContext *UNUSED(eval_ctx),
+ Object *ob,
+ DerivedMesh *derivedData,
ModifierApplyFlag UNUSED(flag))
{
WeightVGEditModifierData *wmd = (WeightVGEditModifierData *) md;
diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c
index df07cffe63f..5f30d4ca72a 100644
--- a/source/blender/modifiers/intern/MOD_weightvgmix.c
+++ b/source/blender/modifiers/intern/MOD_weightvgmix.c
@@ -46,7 +46,9 @@
#include "DEG_depsgraph_build.h"
#include "MEM_guardedalloc.h"
+
#include "MOD_weightvg_util.h"
+#include "MOD_modifiertypes.h"
/**
@@ -135,14 +137,10 @@ static void copyData(ModifierData *md, ModifierData *target)
{
#if 0
WeightVGMixModifierData *wmd = (WeightVGMixModifierData *) md;
-#endif
WeightVGMixModifierData *twmd = (WeightVGMixModifierData *) target;
+#endif
modifier_copyData_generic(md, target);
-
- if (twmd->mask_texture) {
- id_us_plus(&twmd->mask_texture->id);
- }
}
static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
@@ -215,8 +213,8 @@ static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams))
return (wmd->defgrp_name_a[0] == '\0');
}
-static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *derivedData,
- ModifierApplyFlag UNUSED(flag))
+static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob,
+ DerivedMesh *derivedData, ModifierApplyFlag UNUSED(flag))
{
WeightVGMixModifierData *wmd = (WeightVGMixModifierData *) md;
DerivedMesh *dm = derivedData;
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c
index 70b413ca685..c8bbbfe44b2 100644
--- a/source/blender/modifiers/intern/MOD_weightvgproximity.c
+++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c
@@ -50,7 +50,9 @@
#include "DEG_depsgraph_build.h"
#include "MEM_guardedalloc.h"
+
#include "MOD_weightvg_util.h"
+#include "MOD_modifiertypes.h"
//#define USE_TIMEIT
@@ -285,14 +287,10 @@ static void copyData(ModifierData *md, ModifierData *target)
{
#if 0
WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *) md;
-#endif
WeightVGProximityModifierData *twmd = (WeightVGProximityModifierData *) target;
+#endif
modifier_copyData_generic(md, target);
-
- if (twmd->mask_texture) {
- id_us_plus(&twmd->mask_texture->id);
- }
}
static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
@@ -372,8 +370,8 @@ static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams))
return (wmd->proximity_ob_target == NULL);
}
-static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *derivedData,
- ModifierApplyFlag UNUSED(flag))
+static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob,
+ DerivedMesh *derivedData, ModifierApplyFlag UNUSED(flag))
{
WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *) md;
DerivedMesh *dm = derivedData;
diff --git a/source/blender/modifiers/intern/MOD_wireframe.c b/source/blender/modifiers/intern/MOD_wireframe.c
index 0c295f91012..6fc1907ba0a 100644
--- a/source/blender/modifiers/intern/MOD_wireframe.c
+++ b/source/blender/modifiers/intern/MOD_wireframe.c
@@ -107,7 +107,8 @@ static DerivedMesh *WireframeModifier_do(WireframeModifierData *wmd, Object *ob,
}
-static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm, ModifierApplyFlag UNUSED(flag))
+static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob,
+ DerivedMesh *dm, ModifierApplyFlag UNUSED(flag))
{
return WireframeModifier_do((WireframeModifierData *)md, ob, dm);
}
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index 2c46791ae18..d65b71a35e5 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -184,11 +184,9 @@ set(SRC
shader/nodes/node_shader_normal_map.c
shader/nodes/node_shader_object_info.c
shader/nodes/node_shader_hair_info.c
- shader/nodes/node_shader_eevee_metallic.c
shader/nodes/node_shader_eevee_specular.c
shader/nodes/node_shader_output_lamp.c
shader/nodes/node_shader_output_material.c
- shader/nodes/node_shader_output_eevee_material.c
shader/nodes/node_shader_output_world.c
shader/nodes/node_shader_output_linestyle.c
shader/nodes/node_shader_particle_info.c
diff --git a/source/blender/nodes/NOD_socket.h b/source/blender/nodes/NOD_socket.h
index 5c8875593e7..e311adc45eb 100644
--- a/source/blender/nodes/NOD_socket.h
+++ b/source/blender/nodes/NOD_socket.h
@@ -49,7 +49,7 @@ struct bNodeSocket *node_add_socket_from_template(struct bNodeTree *ntree, struc
void node_verify_socket_templates(struct bNodeTree *ntree, struct bNode *node);
void node_socket_init_default_value(struct bNodeSocket *sock);
-void node_socket_copy_default_value(struct bNodeSocket *to, struct bNodeSocket *from);
+void node_socket_copy_default_value(struct bNodeSocket *to, const struct bNodeSocket *from);
void register_standard_node_socket_types(void);
#endif
diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h
index d8944776cbb..783e1a388c1 100644
--- a/source/blender/nodes/NOD_static_types.h
+++ b/source/blender/nodes/NOD_static_types.h
@@ -67,9 +67,7 @@ DefNode( ShaderNode, SH_NODE_COMBRGB, 0, "COMBR
DefNode( ShaderNode, SH_NODE_HUE_SAT, 0, "HUE_SAT", HueSaturation, "Hue/Saturation", "" )
DefNode( ShaderNode, SH_NODE_OUTPUT_MATERIAL, def_sh_output, "OUTPUT_MATERIAL", OutputMaterial, "Material Output", "" )
-DefNode( ShaderNode, SH_NODE_EEVEE_METALLIC, 0, "EEVEE_METALLIC", EeveeMetallic, "Metallic", "")
DefNode( ShaderNode, SH_NODE_EEVEE_SPECULAR, 0, "EEVEE_SPECULAR", EeveeSpecular, "Specular", "")
-DefNode( ShaderNode, SH_NODE_OUTPUT_EEVEE_MATERIAL, def_sh_output, "OUTPUT_EEVEE_MATERIAL", OutputEeveeMaterial, "Material Output", "")
DefNode( ShaderNode, SH_NODE_OUTPUT_LAMP, def_sh_output, "OUTPUT_LAMP", OutputLamp, "Lamp Output", "" )
DefNode( ShaderNode, SH_NODE_OUTPUT_WORLD, def_sh_output, "OUTPUT_WORLD", OutputWorld, "World Output", "" )
DefNode( ShaderNode, SH_NODE_OUTPUT_LINESTYLE, def_sh_output_linestyle,"OUTPUT_LINESTYLE", OutputLineStyle, "Line Style Output", "" )
diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c
index 8139e29bade..a95c3233132 100644
--- a/source/blender/nodes/composite/nodes/node_composite_image.c
+++ b/source/blender/nodes/composite/nodes/node_composite_image.c
@@ -178,6 +178,9 @@ static void cmp_node_image_create_outputs(bNodeTree *ntree, bNode *node, LinkNod
cmp_node_image_add_pass_output(ntree, node, "Alpha", RE_PASSNAME_COMBINED, -1, SOCK_FLOAT, false, available_sockets, &prev_index);
if (ima) {
+ if (!ima->rr) {
+ cmp_node_image_add_pass_output(ntree, node, RE_PASSNAME_Z, RE_PASSNAME_Z, -1, SOCK_FLOAT, false, available_sockets, &prev_index);
+ }
BKE_image_release_ibuf(ima, ibuf, NULL);
}
}
diff --git a/source/blender/nodes/intern/node_socket.c b/source/blender/nodes/intern/node_socket.c
index 01c642b063d..ddd25b237a0 100644
--- a/source/blender/nodes/intern/node_socket.c
+++ b/source/blender/nodes/intern/node_socket.c
@@ -267,7 +267,7 @@ void node_socket_init_default_value(bNodeSocket *sock)
}
}
-void node_socket_copy_default_value(bNodeSocket *to, bNodeSocket *from)
+void node_socket_copy_default_value(bNodeSocket *to, const bNodeSocket *from)
{
/* sanity check */
if (to->type != from->type)
diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c
index b5d77e99328..35a8c712905 100644
--- a/source/blender/nodes/shader/node_shader_tree.c
+++ b/source/blender/nodes/shader/node_shader_tree.c
@@ -80,7 +80,7 @@ static void shader_get_from_context(const bContext *C, bNodeTreeType *UNUSED(tre
SpaceNode *snode = CTX_wm_space_node(C);
Scene *scene = CTX_data_scene(C);
SceneLayer *sl = CTX_data_scene_layer(C);
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
if ((snode->shaderfrom == SNODE_SHADER_OBJECT) ||
(BKE_scene_use_new_shading_nodes(scene) == false))
@@ -214,6 +214,9 @@ static void ntree_shader_link_builtin_normal(bNodeTree *ntree,
* render engines works but it's how the GPU shader compilation works. This we
* can change in the future and make it a generic function, but for now it stays
* private here.
+ *
+ * It also does not yet take into account render engine specific output nodes,
+ * it should give priority to e.g. the Eevee material output node for Eevee.
*/
static bNode *ntree_shader_output_node(bNodeTree *ntree)
{
@@ -475,6 +478,48 @@ static void ntree_shader_relink_displacement(bNodeTree *ntree,
ntreeUpdateTree(G.main, ntree);
}
+static bool ntree_tag_ssr_bsdf_cb(bNode *fromnode, bNode *UNUSED(tonode), void *userdata, const bool UNUSED(reversed))
+{
+ switch (fromnode->type) {
+ case SH_NODE_BSDF_ANISOTROPIC:
+ case SH_NODE_EEVEE_SPECULAR:
+ case SH_NODE_BSDF_PRINCIPLED:
+ case SH_NODE_BSDF_GLOSSY:
+ case SH_NODE_BSDF_GLASS:
+ fromnode->ssr_id = (*(float *)userdata);
+ (*(float *)userdata) += 1;
+ break;
+ default:
+ /* We could return false here but since we (will)
+ * allow the use of Closure as RGBA, we can have
+ * Bsdf nodes linked to other Bsdf nodes. */
+ break;
+ }
+
+ return true;
+}
+
+/* EEVEE: Scan the ntree to set the Screen Space Reflection
+ * layer id of every specular node.
+ */
+static void ntree_shader_tag_ssr_node(bNodeTree *ntree, short compatibility)
+{
+ if (compatibility != NODE_NEWER_SHADING) {
+ /* We can only deal with new shading system here. */
+ return;
+ }
+
+ bNode *output_node = ntree_shader_output_node(ntree);
+ if (output_node == NULL) {
+ return;
+ }
+ /* Make sure sockets links pointers are correct. */
+ ntreeUpdateTree(G.main, ntree);
+
+ int lobe_count = 0;
+ nodeChainIter(ntree, output_node, ntree_tag_ssr_bsdf_cb, &lobe_count, true);
+}
+
void ntreeGPUMaterialNodes(bNodeTree *ntree, GPUMaterial *mat, short compatibility)
{
/* localize tree to create links for reroute and mute */
@@ -486,6 +531,8 @@ void ntreeGPUMaterialNodes(bNodeTree *ntree, GPUMaterial *mat, short compatibili
*/
ntree_shader_relink_displacement(localtree, compatibility);
+ ntree_shader_tag_ssr_node(localtree, compatibility);
+
exec = ntreeShaderBeginExecTree(localtree);
ntreeExecGPUNodes(exec, mat, 1, compatibility);
ntreeShaderEndExecTree(exec);
diff --git a/source/blender/nodes/shader/node_shader_util.c b/source/blender/nodes/shader/node_shader_util.c
index 5bc97f13b41..8559765e315 100644
--- a/source/blender/nodes/shader/node_shader_util.c
+++ b/source/blender/nodes/shader/node_shader_util.c
@@ -163,7 +163,7 @@ void node_gpu_stack_from_data(struct GPUNodeStack *gs, int type, bNodeStack *ns)
else if (type == SOCK_RGBA)
gs->type = GPU_VEC4;
else if (type == SOCK_SHADER)
- gs->type = GPU_VEC4;
+ gs->type = GPU_CLOSURE;
else
gs->type = GPU_NONE;
diff --git a/source/blender/nodes/shader/node_shader_util.h b/source/blender/nodes/shader/node_shader_util.h
index 79c58cb5715..148888f7693 100644
--- a/source/blender/nodes/shader/node_shader_util.h
+++ b/source/blender/nodes/shader/node_shader_util.h
@@ -78,6 +78,7 @@
#include "GPU_lamp.h"
#include "GPU_material.h"
+#include "GPU_uniformbuffer.h"
int sh_node_poll_default(struct bNodeType *ntype, struct bNodeTree *ntree);
diff --git a/source/blender/nodes/shader/nodes/node_shader_add_shader.c b/source/blender/nodes/shader/nodes/node_shader_add_shader.c
index 1edac62438e..d3bb8fccf71 100644
--- a/source/blender/nodes/shader/nodes/node_shader_add_shader.c
+++ b/source/blender/nodes/shader/nodes/node_shader_add_shader.c
@@ -40,9 +40,9 @@ static bNodeSocketTemplate sh_node_add_shader_out[] = {
{ -1, 0, "" }
};
-static int node_shader_gpu_add_shader(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_add_shader(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- return GPU_stack_link(mat, "node_add_shader", in, out);
+ return GPU_stack_link(mat, node, "node_add_shader", in, out);
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c b/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c
index 878f8562619..cb4335ca9a7 100644
--- a/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c
+++ b/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c
@@ -39,9 +39,9 @@ static bNodeSocketTemplate sh_node_ambient_occlusion_out[] = {
{ -1, 0, "" }
};
-static int node_shader_gpu_ambient_occlusion(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_ambient_occlusion(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- return GPU_stack_link(mat, "node_ambient_occlusion", in, out, GPU_builtin(GPU_VIEW_NORMAL));
+ return GPU_stack_link(mat, node, "node_ambient_occlusion", in, out, GPU_builtin(GPU_VIEW_NORMAL));
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_attribute.c b/source/blender/nodes/shader/nodes/node_shader_attribute.c
index 0a69593cf07..3c9b21a4198 100644
--- a/source/blender/nodes/shader/nodes/node_shader_attribute.c
+++ b/source/blender/nodes/shader/nodes/node_shader_attribute.c
@@ -47,7 +47,7 @@ static int node_shader_gpu_attribute(GPUMaterial *mat, bNode *node, bNodeExecDat
NodeShaderAttribute *attr = node->storage;
GPUNodeLink *cd_attr = GPU_attribute(CD_AUTO_FROM_NAME, attr->name);
- return GPU_stack_link(mat, "node_attribute", in, out, cd_attr);
+ return GPU_stack_link(mat, node, "node_attribute", in, out, cd_attr);
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_background.c b/source/blender/nodes/shader/nodes/node_shader_background.c
index e4d635994b4..4ea675f9e0c 100644
--- a/source/blender/nodes/shader/nodes/node_shader_background.c
+++ b/source/blender/nodes/shader/nodes/node_shader_background.c
@@ -40,9 +40,9 @@ static bNodeSocketTemplate sh_node_background_out[] = {
{ -1, 0, "" }
};
-static int node_shader_gpu_background(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_background(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- return GPU_stack_link(mat, "node_background", in, out);
+ return GPU_stack_link(mat, node, "node_background", in, out);
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_brightness.c b/source/blender/nodes/shader/nodes/node_shader_brightness.c
index e992c0773c2..457708405af 100644
--- a/source/blender/nodes/shader/nodes/node_shader_brightness.c
+++ b/source/blender/nodes/shader/nodes/node_shader_brightness.c
@@ -42,9 +42,9 @@ static bNodeSocketTemplate sh_node_brightcontrast_out[] = {
{ -1, 0, "" }
};
-static int gpu_shader_brightcontrast(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int gpu_shader_brightcontrast(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- return GPU_stack_link(mat, "brightness_contrast", in, out);
+ return GPU_stack_link(mat, node, "brightness_contrast", in, out);
}
void register_node_type_sh_brightcontrast(void)
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 01ca0bd6512..13e8ac67f63 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c
@@ -49,14 +49,12 @@ static void node_shader_init_anisotropic(bNodeTree *UNUSED(ntree), bNode *node)
node->custom1 = SHD_GLOSSY_GGX;
}
-static int node_shader_gpu_bsdf_anisotropic(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_bsdf_anisotropic(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
if (!in[4].link)
- in[4].link = GPU_builtin(GPU_VIEW_NORMAL);
- else
- GPU_link(mat, "direction_transform_m4v3", in[4].link, GPU_builtin(GPU_VIEW_MATRIX), &in[4].link);
+ GPU_link(mat, "world_normals_get", &in[4].link);
- return GPU_stack_link(mat, "node_bsdf_anisotropic", in, out);
+ return GPU_stack_link(mat, node, "node_bsdf_anisotropic", in, out);
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c
index e86d2677a61..be7012712cc 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c
@@ -41,14 +41,12 @@ static bNodeSocketTemplate sh_node_bsdf_diffuse_out[] = {
{ -1, 0, "" }
};
-static int node_shader_gpu_bsdf_diffuse(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_bsdf_diffuse(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
if (!in[2].link)
- in[2].link = GPU_builtin(GPU_VIEW_NORMAL);
- else
- GPU_link(mat, "direction_transform_m4v3", in[2].link, GPU_builtin(GPU_VIEW_MATRIX), &in[2].link);
+ GPU_link(mat, "world_normals_get", &in[2].link);
- return GPU_stack_link(mat, "node_bsdf_diffuse", in, out);
+ return GPU_stack_link(mat, node, "node_bsdf_diffuse", in, out);
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c
index 5569fe85489..1537e07ca16 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c
@@ -47,14 +47,12 @@ static void node_shader_init_glass(bNodeTree *UNUSED(ntree), bNode *node)
node->custom1 = SHD_GLOSSY_BECKMANN;
}
-static int node_shader_gpu_bsdf_glass(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_bsdf_glass(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
if (!in[3].link)
- in[3].link = GPU_builtin(GPU_VIEW_NORMAL);
- else
- GPU_link(mat, "direction_transform_m4v3", in[3].link, GPU_builtin(GPU_VIEW_MATRIX), &in[3].link);
+ GPU_link(mat, "world_normals_get", &in[3].link);
- return GPU_stack_link(mat, "node_bsdf_glass", in, out);
+ return GPU_stack_link(mat, node, "node_bsdf_glass", in, out, GPU_uniform(&node->ssr_id));
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c
index 7e1bc971c73..35121b2afed 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c
@@ -46,14 +46,12 @@ static void node_shader_init_glossy(bNodeTree *UNUSED(ntree), bNode *node)
node->custom1 = SHD_GLOSSY_GGX;
}
-static int node_shader_gpu_bsdf_glossy(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_bsdf_glossy(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
if (!in[2].link)
- in[2].link = GPU_builtin(GPU_VIEW_NORMAL);
- else
- GPU_link(mat, "direction_transform_m4v3", in[2].link, GPU_builtin(GPU_VIEW_MATRIX), &in[2].link);
+ GPU_link(mat, "world_normals_get", &in[2].link);
- return GPU_stack_link(mat, "node_bsdf_glossy", in, out);
+ return GPU_stack_link(mat, node, "node_bsdf_glossy", in, out, GPU_uniform(&node->ssr_id));
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.c
index 25be59f091d..b8078ac60ac 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.c
@@ -43,9 +43,9 @@ static bNodeSocketTemplate sh_node_bsdf_hair_out[] = {
{ -1, 0, "" }
};
-static int node_shader_gpu_bsdf_hair(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_bsdf_hair(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- return GPU_stack_link(mat, "node_bsdf_hair", in, out);
+ return GPU_stack_link(mat, node, "node_bsdf_hair", in, out);
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
index e0330d110ca..29a6d062947 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
@@ -63,8 +63,9 @@ static void node_shader_init_principled(bNodeTree *UNUSED(ntree), bNode *node)
node->custom1 = SHD_GLOSSY_MULTI_GGX;
}
-static int node_shader_gpu_bsdf_principled(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_bsdf_principled(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
+#if 0 /* Old 2.7 glsl viewport */
// normal
if (!in[17].link)
in[17].link = GPU_builtin(GPU_VIEW_NORMAL);
@@ -76,8 +77,28 @@ static int node_shader_gpu_bsdf_principled(GPUMaterial *mat, bNode *UNUSED(node)
in[18].link = GPU_builtin(GPU_VIEW_NORMAL);
else
GPU_link(mat, "direction_transform_m4v3", in[18].link, GPU_builtin(GPU_VIEW_MATRIX), &in[18].link);
+#endif
- return GPU_stack_link(mat, "node_bsdf_principled", in, out, GPU_builtin(GPU_VIEW_POSITION));
+ /* Normals */
+ if (!in[17].link) {
+ GPU_link(mat, "world_normals_get", &in[17].link);
+ }
+
+ /* Clearcoat Normals */
+ if (!in[18].link) {
+ GPU_link(mat, "world_normals_get", &in[18].link);
+ }
+
+ /* Tangents */
+ if (!in[19].link) {
+ GPUNodeLink *orco = GPU_attribute(CD_ORCO, "");
+ GPU_link(mat, "tangent_orco_z", orco, &in[19].link);
+ GPU_link(mat, "node_tangent",
+ GPU_builtin(GPU_VIEW_NORMAL), in[19].link, GPU_builtin(GPU_OBJECT_MATRIX), GPU_builtin(GPU_INVERSE_VIEW_MATRIX),
+ &in[19].link);
+ }
+
+ return GPU_stack_link(mat, node, "node_bsdf_principled_clearcoat", in, out, GPU_builtin(GPU_VIEW_POSITION), GPU_uniform(&node->ssr_id));
}
static void node_shader_update_principled(bNodeTree *UNUSED(ntree), bNode *node)
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c
index c447f5de219..9dbe3361e8b 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c
@@ -47,14 +47,12 @@ static void node_shader_init_refraction(bNodeTree *UNUSED(ntree), bNode *node)
node->custom1 = SHD_GLOSSY_BECKMANN;
}
-static int node_shader_gpu_bsdf_refraction(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_bsdf_refraction(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
if (!in[3].link)
- in[3].link = GPU_builtin(GPU_VIEW_NORMAL);
- else
- GPU_link(mat, "direction_transform_m4v3", in[3].link, GPU_builtin(GPU_VIEW_MATRIX), &in[3].link);
+ GPU_link(mat, "world_normals_get", &in[3].link);
- return GPU_stack_link(mat, "node_bsdf_refraction", in, out);
+ return GPU_stack_link(mat, node, "node_bsdf_refraction", in, out);
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c
index c3510beb470..28941fbd662 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c
@@ -42,14 +42,14 @@ static bNodeSocketTemplate sh_node_bsdf_toon_out[] = {
{ -1, 0, "" }
};
-static int node_shader_gpu_bsdf_toon(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_bsdf_toon(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
if (!in[3].link)
in[3].link = GPU_builtin(GPU_VIEW_NORMAL);
else
GPU_link(mat, "direction_transform_m4v3", in[3].link, GPU_builtin(GPU_VIEW_MATRIX), &in[3].link);
- return GPU_stack_link(mat, "node_bsdf_toon", in, out);
+ return GPU_stack_link(mat, node, "node_bsdf_toon", in, out);
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c
index 3b88d609cdb..f6f6da524d5 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c
@@ -40,14 +40,12 @@ static bNodeSocketTemplate sh_node_bsdf_translucent_out[] = {
{ -1, 0, "" }
};
-static int node_shader_gpu_bsdf_translucent(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_bsdf_translucent(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
if (!in[1].link)
- in[1].link = GPU_builtin(GPU_VIEW_NORMAL);
- else
- GPU_link(mat, "direction_transform_m4v3", in[1].link, GPU_builtin(GPU_VIEW_MATRIX), &in[1].link);
+ GPU_link(mat, "world_normals_get", &in[1].link);
- return GPU_stack_link(mat, "node_bsdf_translucent", in, out);
+ return GPU_stack_link(mat, node, "node_bsdf_translucent", in, out);
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c
index 5cb50b00e1a..76afe935433 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c
@@ -39,9 +39,9 @@ static bNodeSocketTemplate sh_node_bsdf_transparent_out[] = {
{ -1, 0, "" }
};
-static int node_shader_gpu_bsdf_transparent(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_bsdf_transparent(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- return GPU_stack_link(mat, "node_bsdf_transparent", in, out);
+ return GPU_stack_link(mat, node, "node_bsdf_transparent", in, out);
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c
index ef3d52ecbce..6d61f3f7473 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c
@@ -41,14 +41,12 @@ static bNodeSocketTemplate sh_node_bsdf_velvet_out[] = {
{ -1, 0, "" }
};
-static int node_shader_gpu_bsdf_velvet(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_bsdf_velvet(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
if (!in[2].link)
- in[2].link = GPU_builtin(GPU_VIEW_NORMAL);
- else
- GPU_link(mat, "direction_transform_m4v3", in[2].link, GPU_builtin(GPU_VIEW_MATRIX), &in[2].link);
+ GPU_link(mat, "world_normals_get", &in[2].link);
- return GPU_stack_link(mat, "node_bsdf_velvet", in, out);
+ return GPU_stack_link(mat, node, "node_bsdf_velvet", in, out);
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_bump.c b/source/blender/nodes/shader/nodes/node_shader_bump.c
index b39ca5d90ee..15a8c47db7a 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bump.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bump.c
@@ -52,7 +52,7 @@ static int gpu_shader_bump(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(
else
GPU_link(mat, "direction_transform_m4v3", in[3].link, GPU_builtin(GPU_VIEW_MATRIX), &in[3].link);
float invert = node->custom1;
- GPU_stack_link(mat, "node_bump", in, out, GPU_builtin(GPU_VIEW_POSITION), GPU_uniform(&invert));
+ GPU_stack_link(mat, node, "node_bump", in, out, GPU_builtin(GPU_VIEW_POSITION), GPU_uniform(&invert));
/* Other nodes are applying view matrix if the input Normal has a link.
* We don't want normal to have view matrix applied twice, so we cancel it here.
*
diff --git a/source/blender/nodes/shader/nodes/node_shader_camera.c b/source/blender/nodes/shader/nodes/node_shader_camera.c
index 3bdb5c36d69..ac0880d22ba 100644
--- a/source/blender/nodes/shader/nodes/node_shader_camera.c
+++ b/source/blender/nodes/shader/nodes/node_shader_camera.c
@@ -52,7 +52,7 @@ static void node_shader_exec_camera(void *data, int UNUSED(thread), bNode *UNUSE
}
}
-static int gpu_shader_camera(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int gpu_shader_camera(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
GPUNodeLink *viewvec;
@@ -62,7 +62,7 @@ static int gpu_shader_camera(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecDat
if (GPU_material_use_new_shading_nodes(mat))
GPU_link(mat, "invert_z", viewvec, &viewvec);
- return GPU_stack_link(mat, "camera", in, out, viewvec);
+ return GPU_stack_link(mat, node, "camera", in, out, viewvec);
}
void register_node_type_sh_camera(void)
diff --git a/source/blender/nodes/shader/nodes/node_shader_curves.c b/source/blender/nodes/shader/nodes/node_shader_curves.c
index 5e067e6c630..ceba8fd1248 100644
--- a/source/blender/nodes/shader/nodes/node_shader_curves.c
+++ b/source/blender/nodes/shader/nodes/node_shader_curves.c
@@ -66,7 +66,7 @@ static int gpu_shader_curve_vec(GPUMaterial *mat, bNode *node, bNodeExecData *UN
int size;
curvemapping_table_RGBA(node->storage, &array, &size);
- return GPU_stack_link(mat, "curves_vec", in, out, GPU_texture(size, array));
+ return GPU_stack_link(mat, node, "curves_vec", in, out, GPU_texture(size, array));
}
void register_node_type_sh_curve_vec(void)
@@ -125,7 +125,7 @@ static int gpu_shader_curve_rgb(GPUMaterial *mat, bNode *node, bNodeExecData *UN
curvemapping_initialize(node->storage);
curvemapping_table_RGBA(node->storage, &array, &size);
- return GPU_stack_link(mat, "curves_rgb", in, out, GPU_texture(size, array));
+ return GPU_stack_link(mat, node, "curves_rgb", in, out, GPU_texture(size, array));
}
void register_node_type_sh_curve_rgb(void)
diff --git a/source/blender/nodes/shader/nodes/node_shader_eevee_metallic.c b/source/blender/nodes/shader/nodes/node_shader_eevee_metallic.c
deleted file mode 100644
index 23e927fa99b..00000000000
--- a/source/blender/nodes/shader/nodes/node_shader_eevee_metallic.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * ***** 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): Clément Foucault.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#include "../node_shader_util.h"
-
-/* **************** OUTPUT ******************** */
-
-static bNodeSocketTemplate sh_node_eevee_metallic_in[] = {
- { SOCK_RGBA, 1, N_("Base Color"), 0.8f, 0.8f, 0.8f, 1.0f},
- { SOCK_FLOAT, 1, N_("Metallic"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
- { SOCK_FLOAT, 1, N_("Specular"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
- { SOCK_FLOAT, 1, N_("Roughness"), 0.2f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
- { SOCK_RGBA, 1, N_("Emissive Color"), 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_FLOAT, 1, N_("Transparency"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
- { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
- { SOCK_FLOAT, 1, N_("Clear Coat"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
- { SOCK_FLOAT, 1, N_("Clear Coat Roughness"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
- { SOCK_VECTOR, 1, N_("Clear Coat Normal"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
- { SOCK_FLOAT, 1, N_("Ambient Occlusion"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
- { -1, 0, "" }
-};
-
-static bNodeSocketTemplate sh_node_eevee_metallic_out[] = {
- { SOCK_SHADER, 0, N_("BSDF")},
- { -1, 0, "" }
-};
-
-static int node_shader_gpu_eevee_metallic(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
-{
- static float one = 1.0f;
-
- /* Normals */
- if (!in[6].link) {
- GPU_link(mat, "world_normals_get", &in[6].link);
- }
-
- /* Clearcoat Normals */
- if (!in[9].link) {
- GPU_link(mat, "world_normals_get", &in[9].link);
- }
-
- /* Occlusion */
- if (!in[10].link) {
- GPU_link(mat, "set_value", GPU_uniform(&one), &in[10].link);
- }
-
- return GPU_stack_link(mat, "node_eevee_metallic", in, out);
-}
-
-
-/* node type definition */
-void register_node_type_sh_eevee_metallic(void)
-{
- static bNodeType ntype;
-
- sh_node_type_base(&ntype, SH_NODE_EEVEE_METALLIC, "Metallic", NODE_CLASS_SHADER, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
- node_type_socket_templates(&ntype, sh_node_eevee_metallic_in, sh_node_eevee_metallic_out);
- node_type_init(&ntype, NULL);
- node_type_storage(&ntype, "", NULL, NULL);
- node_type_gpu(&ntype, node_shader_gpu_eevee_metallic);
-
- nodeRegisterType(&ntype);
-}
diff --git a/source/blender/nodes/shader/nodes/node_shader_eevee_specular.c b/source/blender/nodes/shader/nodes/node_shader_eevee_specular.c
index b8389814027..c249e77c17a 100644
--- a/source/blender/nodes/shader/nodes/node_shader_eevee_specular.c
+++ b/source/blender/nodes/shader/nodes/node_shader_eevee_specular.c
@@ -48,7 +48,7 @@ static bNodeSocketTemplate sh_node_eevee_specular_out[] = {
{ -1, 0, "" }
};
-static int node_shader_gpu_eevee_specular(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_eevee_specular(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
static float one = 1.0f;
@@ -67,7 +67,7 @@ static int node_shader_gpu_eevee_specular(GPUMaterial *mat, bNode *UNUSED(node),
GPU_link(mat, "set_value", GPU_uniform(&one), &in[9].link);
}
- return GPU_stack_link(mat, "node_eevee_specular", in, out);
+ return GPU_stack_link(mat, node, "node_eevee_specular", in, out, GPU_uniform(&node->ssr_id));
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_emission.c b/source/blender/nodes/shader/nodes/node_shader_emission.c
index 51b3d5740a7..0901e8204f8 100644
--- a/source/blender/nodes/shader/nodes/node_shader_emission.c
+++ b/source/blender/nodes/shader/nodes/node_shader_emission.c
@@ -40,9 +40,9 @@ static bNodeSocketTemplate sh_node_emission_out[] = {
{ -1, 0, "" }
};
-static int node_shader_gpu_emission(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_emission(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- return GPU_stack_link(mat, "node_emission", in, out, GPU_builtin(GPU_VIEW_NORMAL));
+ return GPU_stack_link(mat, node, "node_emission", in, out, GPU_builtin(GPU_VIEW_NORMAL));
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_fresnel.c b/source/blender/nodes/shader/nodes/node_shader_fresnel.c
index 5a9e33a4053..b285f1a8a3e 100644
--- a/source/blender/nodes/shader/nodes/node_shader_fresnel.c
+++ b/source/blender/nodes/shader/nodes/node_shader_fresnel.c
@@ -39,7 +39,7 @@ static bNodeSocketTemplate sh_node_fresnel_out[] = {
{ -1, 0, "" }
};
-static int node_shader_gpu_fresnel(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_fresnel(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
if (!in[1].link) {
in[1].link = GPU_builtin(GPU_VIEW_NORMAL);
@@ -48,17 +48,26 @@ static int node_shader_gpu_fresnel(GPUMaterial *mat, bNode *UNUSED(node), bNodeE
GPU_link(mat, "direction_transform_m4v3", in[1].link, GPU_builtin(GPU_VIEW_MATRIX), &in[1].link);
}
- return GPU_stack_link(mat, "node_fresnel", in, out, GPU_builtin(GPU_VIEW_POSITION));
+ return GPU_stack_link(mat, node, "node_fresnel", in, out, GPU_builtin(GPU_VIEW_POSITION));
}
-static void node_shader_exec_fresnel(void *data, int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out)
+static void node_shader_exec_fresnel(void *data, int UNUSED(thread), bNode *node, bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out)
{
ShadeInput *shi = ((ShaderCallData *)data)->shi;
- float eta = max_ff(in[0]->vec[0], 0.00001);
+
+ /* Compute IOR. */
+ float eta;
+ nodestack_get_vec(&eta, SOCK_FLOAT, in[0]);
+ eta = max_ff(eta, 0.00001);
+ eta = shi->flippednor ? 1 / eta : eta;
+
+ /* Get normal from socket, but only if linked. */
+ bNodeSocket *sock_normal = node->inputs.first;
+ sock_normal = sock_normal->next;
float n[3];
- if (in[1]->hasinput) {
- copy_v3_v3(n, in[1]->vec);
+ if (sock_normal->link) {
+ nodestack_get_vec(n, SOCK_VECTOR, in[1]);
}
else {
copy_v3_v3(n, shi->vn);
@@ -68,7 +77,7 @@ static void node_shader_exec_fresnel(void *data, int UNUSED(thread), bNode *UNUS
mul_mat3_m4_v3((float (*)[4])RE_render_current_get_matrix(RE_VIEW_MATRIX), n);
}
- out[0]->vec[0] = RE_fresnel_dielectric(shi->view, n, shi->flippednor ? 1 / eta : eta);
+ out[0]->vec[0] = RE_fresnel_dielectric(shi->view, n, eta);
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_gamma.c b/source/blender/nodes/shader/nodes/node_shader_gamma.c
index 37439569f77..1aebfbe5888 100644
--- a/source/blender/nodes/shader/nodes/node_shader_gamma.c
+++ b/source/blender/nodes/shader/nodes/node_shader_gamma.c
@@ -52,9 +52,9 @@ static void node_shader_exec_gamma(void *UNUSED(data), int UNUSED(thread), bNode
out[0]->vec[2] = col[2] > 0.0f ? powf(col[2], gamma) : col[2];
}
-static int node_shader_gpu_gamma(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_gamma(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- return GPU_stack_link(mat, "node_gamma", in, out);
+ return GPU_stack_link(mat, node, "node_gamma", in, out);
}
void register_node_type_sh_gamma(void)
diff --git a/source/blender/nodes/shader/nodes/node_shader_geom.c b/source/blender/nodes/shader/nodes/node_shader_geom.c
index b289d66efc3..57bef4a6784 100644
--- a/source/blender/nodes/shader/nodes/node_shader_geom.c
+++ b/source/blender/nodes/shader/nodes/node_shader_geom.c
@@ -136,7 +136,7 @@ static int gpu_shader_geom(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(
GPUNodeLink *mtface = GPU_attribute(CD_MTFACE, ngeo->uvname);
GPUNodeLink *mcol = GPU_attribute(CD_MCOL, ngeo->colname);
- bool ret = GPU_stack_link(mat, "geom", in, out,
+ bool ret = GPU_stack_link(mat, node, "geom", in, out,
GPU_builtin(GPU_VIEW_POSITION), GPU_builtin(GPU_VIEW_NORMAL),
GPU_builtin(GPU_INVERSE_VIEW_MATRIX), orco, mtface, mcol);
if (GPU_material_use_world_space_shading(mat)) {
diff --git a/source/blender/nodes/shader/nodes/node_shader_geometry.c b/source/blender/nodes/shader/nodes/node_shader_geometry.c
index 79833034498..6647f27e5c9 100644
--- a/source/blender/nodes/shader/nodes/node_shader_geometry.c
+++ b/source/blender/nodes/shader/nodes/node_shader_geometry.c
@@ -41,9 +41,9 @@ static bNodeSocketTemplate sh_node_geometry_out[] = {
{ -1, 0, "" }
};
-static int node_shader_gpu_geometry(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_geometry(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- return GPU_stack_link(mat, "node_geometry", in, out,
+ return GPU_stack_link(mat, node, "node_geometry", in, out,
GPU_builtin(GPU_VIEW_POSITION), GPU_builtin(GPU_VIEW_NORMAL),
GPU_attribute(CD_ORCO, ""), GPU_builtin(GPU_OBJECT_MATRIX),
GPU_builtin(GPU_INVERSE_VIEW_MATRIX));
diff --git a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c
index 6fe6a33010a..9eaa0c9f91c 100644
--- a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c
+++ b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c
@@ -82,9 +82,9 @@ static void node_shader_exec_hue_sat(void *UNUSED(data), int UNUSED(thread), bNo
}
-static int gpu_shader_hue_sat(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int gpu_shader_hue_sat(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- return GPU_stack_link(mat, "hue_sat", in, out);
+ return GPU_stack_link(mat, node, "hue_sat", in, out);
}
void register_node_type_sh_hue_sat(void)
diff --git a/source/blender/nodes/shader/nodes/node_shader_invert.c b/source/blender/nodes/shader/nodes/node_shader_invert.c
index 27450ba0fe6..6a54733006d 100644
--- a/source/blender/nodes/shader/nodes/node_shader_invert.c
+++ b/source/blender/nodes/shader/nodes/node_shader_invert.c
@@ -65,9 +65,9 @@ static void node_shader_exec_invert(void *UNUSED(data), int UNUSED(thread), bNod
copy_v3_v3(out[0]->vec, icol);
}
-static int gpu_shader_invert(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int gpu_shader_invert(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- return GPU_stack_link(mat, "invert", in, out);
+ return GPU_stack_link(mat, node, "invert", in, out);
}
void register_node_type_sh_invert(void)
diff --git a/source/blender/nodes/shader/nodes/node_shader_lamp.c b/source/blender/nodes/shader/nodes/node_shader_lamp.c
index 2c96c91958e..3c41227ab8b 100644
--- a/source/blender/nodes/shader/nodes/node_shader_lamp.c
+++ b/source/blender/nodes/shader/nodes/node_shader_lamp.c
@@ -68,7 +68,7 @@ static int gpu_shader_lamp(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(
visifac = GPU_lamp_get_data(mat, lamp, &col, &lv, &dist, &shadow, &energy);
- bool ret = GPU_stack_link(mat, "lamp", in, out, col, energy, lv, dist, shadow, visifac);
+ bool ret = GPU_stack_link(mat, node, "lamp", in, out, col, energy, lv, dist, shadow, visifac);
if (GPU_material_use_world_space_shading(mat))
ret &= GPU_link(mat, "direction_transform_m4v3", out[1].link, GPU_builtin(GPU_INVERSE_VIEW_MATRIX), &out[1].link);
return ret;
diff --git a/source/blender/nodes/shader/nodes/node_shader_layer_weight.c b/source/blender/nodes/shader/nodes/node_shader_layer_weight.c
index a0b2408a7bb..3ab73fdde18 100644
--- a/source/blender/nodes/shader/nodes/node_shader_layer_weight.c
+++ b/source/blender/nodes/shader/nodes/node_shader_layer_weight.c
@@ -41,7 +41,7 @@ static bNodeSocketTemplate sh_node_layer_weight_out[] = {
{ -1, 0, "" }
};
-static int node_shader_gpu_layer_weight(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_layer_weight(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
if (!in[1].link)
in[1].link = GPU_builtin(GPU_VIEW_NORMAL);
@@ -49,27 +49,36 @@ static int node_shader_gpu_layer_weight(GPUMaterial *mat, bNode *UNUSED(node), b
GPU_link(mat, "direction_transform_m4v3", in[1].link, GPU_builtin(GPU_VIEW_MATRIX), &in[1].link);
}
- return GPU_stack_link(mat, "node_layer_weight", in, out, GPU_builtin(GPU_VIEW_POSITION));
+ return GPU_stack_link(mat, node, "node_layer_weight", in, out, GPU_builtin(GPU_VIEW_POSITION));
}
-static void node_shader_exec_layer_weight(void *data, int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out)
+static void node_shader_exec_layer_weight(void *data, int UNUSED(thread), bNode *node, bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out)
{
ShadeInput *shi = ((ShaderCallData *)data)->shi;
- float blend = in[0]->vec[0];
+
+ /* Compute IOR. */
+ float blend;
+ nodestack_get_vec(&blend, SOCK_FLOAT, in[0]);
float eta = max_ff(1 - blend, 0.00001);
+ eta = shi->flippednor ? eta : 1 / eta;
+
+ /* Get normal from socket, but only if linked. */
+ bNodeSocket *sock_normal = node->inputs.first;
+ sock_normal = sock_normal->next;
float n[3];
- if (in[1]->hasinput) {
- copy_v3_v3(n, in[1]->vec);
+ if (sock_normal->link) {
+ nodestack_get_vec(n, SOCK_VECTOR, in[1]);
}
else {
copy_v3_v3(n, shi->vn);
}
+
if (shi->use_world_space_shading)
mul_mat3_m4_v3((float (*)[4])RE_render_current_get_matrix(RE_VIEW_MATRIX), n);
- out[0]->vec[0] = RE_fresnel_dielectric(shi->view, n, shi->flippednor ? eta : 1 / eta);
+ out[0]->vec[0] = RE_fresnel_dielectric(shi->view, n, eta);
float facing = fabs(dot_v3v3(shi->view, n));
if (blend != 0.5) {
diff --git a/source/blender/nodes/shader/nodes/node_shader_light_falloff.c b/source/blender/nodes/shader/nodes/node_shader_light_falloff.c
index 3aad476ea05..a51e4dc720f 100644
--- a/source/blender/nodes/shader/nodes/node_shader_light_falloff.c
+++ b/source/blender/nodes/shader/nodes/node_shader_light_falloff.c
@@ -44,9 +44,9 @@ static bNodeSocketTemplate sh_node_light_falloff_out[] = {
{ -1, 0, "" }
};
-static int node_shader_gpu_light_falloff(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_light_falloff(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- return GPU_stack_link(mat, "node_light_falloff", in, out);
+ return GPU_stack_link(mat, node, "node_light_falloff", in, out);
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_light_path.c b/source/blender/nodes/shader/nodes/node_shader_light_path.c
index 052f2a66ec8..be6db9c8269 100644
--- a/source/blender/nodes/shader/nodes/node_shader_light_path.c
+++ b/source/blender/nodes/shader/nodes/node_shader_light_path.c
@@ -46,9 +46,9 @@ static bNodeSocketTemplate sh_node_light_path_out[] = {
{ -1, 0, "" }
};
-static int node_shader_gpu_light_path(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_light_path(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- return GPU_stack_link(mat, "node_light_path", in, out);
+ return GPU_stack_link(mat, node, "node_light_path", in, out);
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_mapping.c b/source/blender/nodes/shader/nodes/node_shader_mapping.c
index 2044f5390cc..7f25b298cb2 100644
--- a/source/blender/nodes/shader/nodes/node_shader_mapping.c
+++ b/source/blender/nodes/shader/nodes/node_shader_mapping.c
@@ -94,7 +94,7 @@ static int gpu_shader_mapping(GPUMaterial *mat, bNode *node, bNodeExecData *UNUS
GPUNodeLink *tdomin = GPU_uniform(&domin);
GPUNodeLink *tdomax = GPU_uniform(&domax);
- GPU_stack_link(mat, "mapping", in, out, tmat, tmin, tmax, tdomin, tdomax);
+ GPU_stack_link(mat, node, "mapping", in, out, tmat, tmin, tmax, tdomin, tdomax);
if (texmap->type == TEXMAP_TYPE_NORMAL)
GPU_link(mat, "texco_norm", out[0].link, &out[0].link);
diff --git a/source/blender/nodes/shader/nodes/node_shader_math.c b/source/blender/nodes/shader/nodes/node_shader_math.c
index 2a1e936570d..6cd58d2fb85 100644
--- a/source/blender/nodes/shader/nodes/node_shader_math.c
+++ b/source/blender/nodes/shader/nodes/node_shader_math.c
@@ -249,7 +249,7 @@ static int gpu_shader_math(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(
case NODE_MATH_LESS:
case NODE_MATH_GREATER:
case NODE_MATH_MOD:
- GPU_stack_link(mat, names[node->custom1], in, out);
+ GPU_stack_link(mat, node, names[node->custom1], in, out);
break;
case NODE_MATH_SIN:
case NODE_MATH_COS:
@@ -264,14 +264,14 @@ static int gpu_shader_math(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(
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);
+ GPU_stack_link(mat, node, 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);
+ GPU_stack_link(mat, node, names[node->custom1], tmp_in, out);
}
break;
default:
diff --git a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c
index f911fa058dc..cca0a1e0561 100644
--- a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c
+++ b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c
@@ -71,7 +71,8 @@ static int gpu_shader_mix_rgb(GPUMaterial *mat, bNode *node, bNodeExecData *UNUS
"mix_screen", "mix_div", "mix_diff", "mix_dark", "mix_light",
"mix_overlay", "mix_dodge", "mix_burn", "mix_hue", "mix_sat",
"mix_val", "mix_color", "mix_soft", "mix_linear"};
- int ret = GPU_stack_link(mat, names[node->custom1], in, out);
+
+ int ret = GPU_stack_link(mat, node, names[node->custom1], in, out);
if (ret && node->custom2 & SHD_MIXRGB_CLAMP) {
float min[3] = {0.0f, 0.0f, 0.0f};
float max[3] = {1.0f, 1.0f, 1.0f};
diff --git a/source/blender/nodes/shader/nodes/node_shader_mix_shader.c b/source/blender/nodes/shader/nodes/node_shader_mix_shader.c
index 7c5362a8969..5ac576004be 100644
--- a/source/blender/nodes/shader/nodes/node_shader_mix_shader.c
+++ b/source/blender/nodes/shader/nodes/node_shader_mix_shader.c
@@ -41,9 +41,9 @@ static bNodeSocketTemplate sh_node_mix_shader_out[] = {
{ -1, 0, "" }
};
-static int node_shader_gpu_mix_shader(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_mix_shader(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- return GPU_stack_link(mat, "node_mix_shader", in, out);
+ return GPU_stack_link(mat, node, "node_mix_shader", in, out);
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_normal.c b/source/blender/nodes/shader/nodes/node_shader_normal.c
index 092fc201aa7..64f3ec94369 100644
--- a/source/blender/nodes/shader/nodes/node_shader_normal.c
+++ b/source/blender/nodes/shader/nodes/node_shader_normal.c
@@ -58,14 +58,14 @@ static void node_shader_exec_normal(void *UNUSED(data), int UNUSED(thread), bNod
out[1]->vec[0] = -dot_v3v3(vec, out[0]->vec);
}
-static int gpu_shader_normal(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int gpu_shader_normal(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
GPUNodeLink *vec = GPU_uniform(out[0].vec);
if (GPU_material_use_new_shading_nodes(mat)) {
- return GPU_stack_link(mat, "normal_new_shading", in, out, vec);
+ return GPU_stack_link(mat, node, "normal_new_shading", in, out, vec);
}
else {
- return GPU_stack_link(mat, "normal", in, out, vec);
+ return GPU_stack_link(mat, node, "normal", in, out, vec);
}
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_object_info.c b/source/blender/nodes/shader/nodes/node_shader_object_info.c
index 63d3bac88a0..471331beae3 100644
--- a/source/blender/nodes/shader/nodes/node_shader_object_info.c
+++ b/source/blender/nodes/shader/nodes/node_shader_object_info.c
@@ -37,9 +37,9 @@ static bNodeSocketTemplate sh_node_object_info_out[] = {
{ -1, 0, "" }
};
-static int node_shader_gpu_object_info(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_object_info(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- return GPU_stack_link(mat, "node_object_info", in, out, GPU_builtin(GPU_OBJECT_MATRIX), GPU_builtin(GPU_OBJECT_INFO));
+ return GPU_stack_link(mat, node, "node_object_info", in, out, GPU_builtin(GPU_OBJECT_MATRIX), GPU_builtin(GPU_OBJECT_INFO));
}
static void node_shader_exec_object_info(void *data, int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), bNodeStack **UNUSED(in), bNodeStack **out)
diff --git a/source/blender/nodes/shader/nodes/node_shader_output.c b/source/blender/nodes/shader/nodes/node_shader_output.c
index ad6b4acdd48..dcf6fec41a4 100644
--- a/source/blender/nodes/shader/nodes/node_shader_output.c
+++ b/source/blender/nodes/shader/nodes/node_shader_output.c
@@ -67,7 +67,7 @@ static void node_shader_exec_output(void *data, int UNUSED(thread), bNode *node,
}
}
-static int gpu_shader_output(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int gpu_shader_output(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
GPUNodeLink *outlink;
@@ -80,7 +80,7 @@ static int gpu_shader_output(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecDat
return false;
}
- GPU_stack_link(mat, "output_node", in, out, &outlink);
+ GPU_stack_link(mat, node, "output_node", in, out, &outlink);
GPU_material_output_link(mat, outlink);
return 1;
diff --git a/source/blender/nodes/shader/nodes/node_shader_output_eevee_material.c b/source/blender/nodes/shader/nodes/node_shader_output_eevee_material.c
deleted file mode 100644
index ef3bf0e28d5..00000000000
--- a/source/blender/nodes/shader/nodes/node_shader_output_eevee_material.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * ***** 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"
-
-#include "BKE_scene.h"
-
-/* **************** OUTPUT ******************** */
-
-static bNodeSocketTemplate sh_node_output_eevee_material_in[] = {
- { SOCK_SHADER, 1, N_("Surface")},
- { -1, 0, "" }
-};
-
-static int node_shader_gpu_output_eevee_material(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
-{
- GPUNodeLink *outlink;
-
- GPU_stack_link(mat, "node_output_eevee_material", in, out, &outlink);
- GPU_material_output_link(mat, outlink);
-
- return true;
-}
-
-
-/* node type definition */
-void register_node_type_sh_output_eevee_material(void)
-{
- static bNodeType ntype;
-
- sh_node_type_base(&ntype, SH_NODE_OUTPUT_EEVEE_MATERIAL, "Material Output", NODE_CLASS_OUTPUT, 0);
- node_type_compatibility(&ntype, NODE_NEW_SHADING);
- node_type_socket_templates(&ntype, sh_node_output_eevee_material_in, NULL);
- node_type_init(&ntype, NULL);
- node_type_storage(&ntype, "", NULL, NULL);
- node_type_gpu(&ntype, node_shader_gpu_output_eevee_material);
-
- /* Do not allow muting output node. */
- node_type_internal_links(&ntype, NULL);
-
- nodeRegisterType(&ntype);
-}
diff --git a/source/blender/nodes/shader/nodes/node_shader_output_material.c b/source/blender/nodes/shader/nodes/node_shader_output_material.c
index bbb72651ee5..0418b039337 100644
--- a/source/blender/nodes/shader/nodes/node_shader_output_material.c
+++ b/source/blender/nodes/shader/nodes/node_shader_output_material.c
@@ -38,15 +38,11 @@ static bNodeSocketTemplate sh_node_output_material_in[] = {
{ -1, 0, "" }
};
-static int node_shader_gpu_output_material(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_output_material(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
GPUNodeLink *outlink;
- if (BKE_scene_uses_blender_eevee(GPU_material_scene(mat))) {
- return false;
- }
-
- GPU_stack_link(mat, "node_output_material", in, out, &outlink);
+ GPU_stack_link(mat, node, "node_output_material", in, out, &outlink);
GPU_material_output_link(mat, outlink);
return true;
diff --git a/source/blender/nodes/shader/nodes/node_shader_output_world.c b/source/blender/nodes/shader/nodes/node_shader_output_world.c
index f95cc842720..abab4fc351a 100644
--- a/source/blender/nodes/shader/nodes/node_shader_output_world.c
+++ b/source/blender/nodes/shader/nodes/node_shader_output_world.c
@@ -35,11 +35,11 @@ static bNodeSocketTemplate sh_node_output_world_in[] = {
{ -1, 0, "" }
};
-static int node_shader_gpu_output_world(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_output_world(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
GPUNodeLink *outlink;
- GPU_stack_link(mat, "node_output_world", in, out, &outlink);
+ GPU_stack_link(mat, node, "node_output_world", in, out, &outlink);
GPU_material_output_link(mat, outlink);
return true;
diff --git a/source/blender/nodes/shader/nodes/node_shader_particle_info.c b/source/blender/nodes/shader/nodes/node_shader_particle_info.c
index 5f0d81e98c9..8bdc88292e7 100644
--- a/source/blender/nodes/shader/nodes/node_shader_particle_info.c
+++ b/source/blender/nodes/shader/nodes/node_shader_particle_info.c
@@ -48,10 +48,10 @@ static void node_shader_exec_particle_info(void *data, int UNUSED(thread), bNode
RE_instance_get_particle_info(shi->obi, out[0]->vec, out[1]->vec, out[2]->vec, out[3]->vec, out[4]->vec, out[5]->vec, out[6]->vec);
}
-static int gpu_shader_particle_info(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int gpu_shader_particle_info(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- return GPU_stack_link(mat, "particle_info", in, out,
+ return GPU_stack_link(mat, node, "particle_info", in, out,
GPU_builtin(GPU_PARTICLE_SCALAR_PROPS),
GPU_builtin(GPU_PARTICLE_LOCATION),
GPU_builtin(GPU_PARTICLE_VELOCITY),
diff --git a/source/blender/nodes/shader/nodes/node_shader_rgb.c b/source/blender/nodes/shader/nodes/node_shader_rgb.c
index 4f345bf2067..b9c051c0441 100644
--- a/source/blender/nodes/shader/nodes/node_shader_rgb.c
+++ b/source/blender/nodes/shader/nodes/node_shader_rgb.c
@@ -38,10 +38,10 @@ static bNodeSocketTemplate sh_node_rgb_out[] = {
{ -1, 0, "" }
};
-static int gpu_shader_rgb(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int gpu_shader_rgb(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- GPUNodeLink *vec = GPU_uniform(out[0].vec);
- return GPU_stack_link(mat, "set_rgba", in, out, vec);
+ GPUNodeLink *link = GPU_uniformbuffer_link_out(mat, node, out, 0);
+ return GPU_stack_link(mat, node, "set_rgba", in, out, link);
}
void register_node_type_sh_rgb(void)
diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c b/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c
index b5b15397595..d031a2e412f 100644
--- a/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c
+++ b/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c
@@ -53,9 +53,9 @@ static void node_shader_exec_sephsv(void *UNUSED(data), int UNUSED(thread), bNod
&out[0]->vec[0], &out[1]->vec[0], &out[2]->vec[0]);
}
-static int gpu_shader_sephsv(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int gpu_shader_sephsv(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- return GPU_stack_link(mat, "separate_hsv", in, out);
+ return GPU_stack_link(mat, node, "separate_hsv", in, out);
}
void register_node_type_sh_sephsv(void)
@@ -94,9 +94,9 @@ static void node_shader_exec_combhsv(void *UNUSED(data), int UNUSED(thread), bNo
hsv_to_rgb(h, s, v, &out[0]->vec[0], &out[0]->vec[1], &out[0]->vec[2]);
}
-static int gpu_shader_combhsv(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int gpu_shader_combhsv(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- return GPU_stack_link(mat, "combine_hsv", in, out);
+ return GPU_stack_link(mat, node, "combine_hsv", in, out);
}
void register_node_type_sh_combhsv(void)
diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c b/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c
index 006ba34c3f3..682909edb0e 100644
--- a/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c
+++ b/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c
@@ -54,9 +54,9 @@ static void node_shader_exec_seprgb(void *UNUSED(data), int UNUSED(thread), bNod
out[2]->vec[0] = col[2];
}
-static int gpu_shader_seprgb(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int gpu_shader_seprgb(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- return GPU_stack_link(mat, "separate_rgb", in, out);
+ return GPU_stack_link(mat, node, "separate_rgb", in, out);
}
void register_node_type_sh_seprgb(void)
@@ -98,9 +98,9 @@ static void node_shader_exec_combrgb(void *UNUSED(data), int UNUSED(thread), bNo
out[0]->vec[2] = b;
}
-static int gpu_shader_combrgb(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int gpu_shader_combrgb(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- return GPU_stack_link(mat, "combine_rgb", in, out);
+ return GPU_stack_link(mat, node, "combine_rgb", in, out);
}
void register_node_type_sh_combrgb(void)
diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.c b/source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.c
index 6375dcc8782..fce62f730b9 100644
--- a/source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.c
+++ b/source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.c
@@ -44,9 +44,9 @@ static bNodeSocketTemplate sh_node_sepxyz_out[] = {
{ -1, 0, "" }
};
-static int gpu_shader_sepxyz(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int gpu_shader_sepxyz(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- return GPU_stack_link(mat, "separate_xyz", in, out);
+ return GPU_stack_link(mat, node, "separate_xyz", in, out);
}
void register_node_type_sh_sepxyz(void)
@@ -75,9 +75,9 @@ static bNodeSocketTemplate sh_node_combxyz_out[] = {
{ -1, 0, "" }
};
-static int gpu_shader_combxyz(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int gpu_shader_combxyz(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- return GPU_stack_link(mat, "combine_xyz", in, out);
+ return GPU_stack_link(mat, node, "combine_xyz", in, out);
}
void register_node_type_sh_combxyz(void)
diff --git a/source/blender/nodes/shader/nodes/node_shader_squeeze.c b/source/blender/nodes/shader/nodes/node_shader_squeeze.c
index a4c995748d9..2a1fbc2d02d 100644
--- a/source/blender/nodes/shader/nodes/node_shader_squeeze.c
+++ b/source/blender/nodes/shader/nodes/node_shader_squeeze.c
@@ -56,9 +56,9 @@ static void node_shader_exec_squeeze(void *UNUSED(data), int UNUSED(thread), bNo
out[0]->vec[0] = 1.0f / (1.0f + powf(M_E, -((vec[0] - vec[2]) * vec[1])));
}
-static int gpu_shader_squeeze(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int gpu_shader_squeeze(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- return GPU_stack_link(mat, "squeeze", in, out);
+ return GPU_stack_link(mat, node, "squeeze", in, out);
}
void register_node_type_sh_squeeze(void)
diff --git a/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c b/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c
index 7dfac32e85b..e34ff0aa420 100644
--- a/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c
+++ b/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c
@@ -49,14 +49,12 @@ static void node_shader_init_subsurface_scattering(bNodeTree *UNUSED(ntree), bNo
node->custom1 = SHD_SUBSURFACE_BURLEY;
}
-static int node_shader_gpu_subsurface_scattering(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_subsurface_scattering(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
if (!in[5].link)
- in[5].link = GPU_builtin(GPU_VIEW_NORMAL);
- else
- GPU_link(mat, "direction_transform_m4v3", in[5].link, GPU_builtin(GPU_VIEW_MATRIX), &in[5].link);
+ GPU_link(mat, "world_normals_get", &in[5].link);
- return GPU_stack_link(mat, "node_subsurface_scattering", in, out);
+ return GPU_stack_link(mat, node, "node_subsurface_scattering", in, out);
}
static void node_shader_update_subsurface_scattering(bNodeTree *UNUSED(ntree), bNode *node)
diff --git a/source/blender/nodes/shader/nodes/node_shader_tangent.c b/source/blender/nodes/shader/nodes/node_shader_tangent.c
index 9c853f9d86f..f2c59ec8fd8 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tangent.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tangent.c
@@ -46,7 +46,7 @@ static int node_shader_gpu_tangent(GPUMaterial *mat, bNode *node, bNodeExecData
NodeShaderTangent *attr = node->storage;
if (attr->direction_type == SHD_TANGENT_UVMAP) {
- return GPU_stack_link(mat, "node_tangentmap", in, out, GPU_attribute(CD_TANGENT, ""), GPU_builtin(GPU_INVERSE_VIEW_MATRIX));
+ return GPU_stack_link(mat, node, "node_tangentmap", in, out, GPU_attribute(CD_TANGENT, ""), GPU_builtin(GPU_INVERSE_VIEW_MATRIX));
}
else {
GPUNodeLink *orco = GPU_attribute(CD_ORCO, "");
@@ -58,7 +58,7 @@ static int node_shader_gpu_tangent(GPUMaterial *mat, bNode *node, bNodeExecData
else
GPU_link(mat, "tangent_orco_z", orco, &orco);
- return GPU_stack_link(mat, "node_tangent", in, out, GPU_builtin(GPU_VIEW_NORMAL), orco,
+ return GPU_stack_link(mat, node, "node_tangent", in, out, GPU_builtin(GPU_VIEW_NORMAL), orco,
GPU_builtin(GPU_OBJECT_MATRIX), GPU_builtin(GPU_INVERSE_VIEW_MATRIX));
}
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_brick.c b/source/blender/nodes/shader/nodes/node_shader_tex_brick.c
index 1dfebc45d60..20ea162d98f 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_brick.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_brick.c
@@ -80,7 +80,7 @@ static int node_shader_gpu_tex_brick(GPUMaterial *mat, bNode *node, bNodeExecDat
NodeTexBrick *tex = (NodeTexBrick *)node->storage;
float offset_freq = tex->offset_freq;
float squash_freq = tex->squash_freq;
- return GPU_stack_link(mat, "node_tex_brick",
+ return GPU_stack_link(mat, node, "node_tex_brick",
in, out,
GPU_uniform(&tex->offset), GPU_uniform(&offset_freq),
GPU_uniform(&tex->squash), GPU_uniform(&squash_freq));
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_checker.c b/source/blender/nodes/shader/nodes/node_shader_tex_checker.c
index 77edd0e115e..3dbf98a929c 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_checker.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_checker.c
@@ -61,7 +61,7 @@ static int node_shader_gpu_tex_checker(GPUMaterial *mat, bNode *node, bNodeExecD
node_shader_gpu_tex_mapping(mat, node, in, out);
- return GPU_stack_link(mat, "node_tex_checker", in, out);
+ return GPU_stack_link(mat, node, "node_tex_checker", in, out);
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_coord.c b/source/blender/nodes/shader/nodes/node_shader_tex_coord.c
index 23571e24501..99ab4ad2c20 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_coord.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_coord.c
@@ -42,20 +42,20 @@ static bNodeSocketTemplate sh_node_tex_coord_out[] = {
{ -1, 0, "" }
};
-static int node_shader_gpu_tex_coord(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_tex_coord(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
GPUNodeLink *orco = GPU_attribute(CD_ORCO, "");
GPUNodeLink *mtface = GPU_attribute(CD_MTFACE, "");
GPUMatType type = GPU_Material_get_type(mat);
if (type == GPU_MATERIAL_TYPE_WORLD) {
- return GPU_stack_link(mat, "node_tex_coord_background", in, out,
+ return GPU_stack_link(mat, node, "node_tex_coord_background", in, out,
GPU_builtin(GPU_VIEW_POSITION), GPU_builtin(GPU_VIEW_NORMAL),
GPU_builtin(GPU_INVERSE_VIEW_MATRIX), GPU_builtin(GPU_INVERSE_OBJECT_MATRIX),
GPU_builtin(GPU_CAMERA_TEXCO_FACTORS), orco, mtface);
}
else {
- return GPU_stack_link(mat, "node_tex_coord", in, out,
+ return GPU_stack_link(mat, node, "node_tex_coord", in, out,
GPU_builtin(GPU_VIEW_POSITION), GPU_builtin(GPU_VIEW_NORMAL),
GPU_builtin(GPU_INVERSE_VIEW_MATRIX), GPU_builtin(GPU_INVERSE_OBJECT_MATRIX),
GPU_builtin(GPU_CAMERA_TEXCO_FACTORS), orco, mtface);
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c
index e090f26ab6b..4d98b142f37 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c
@@ -62,25 +62,23 @@ static int node_shader_gpu_tex_environment(GPUMaterial *mat, bNode *node, bNodeE
int isdata = tex->color_space == SHD_COLORSPACE_NONE;
if (!ima)
- return GPU_stack_link(mat, "node_tex_environment_empty", in, out);
+ return GPU_stack_link(mat, node, "node_tex_environment_empty", in, out);
if (!in[0].link) {
GPUMatType type = GPU_Material_get_type(mat);
if (type == GPU_MATERIAL_TYPE_MESH)
in[0].link = GPU_builtin(GPU_VIEW_POSITION);
- else if (type == GPU_MATERIAL_TYPE_WORLD)
- GPU_link(mat, "background_transform_to_world", GPU_builtin(GPU_VIEW_POSITION), &in[0].link);
else
- GPU_link(mat, "environment_default_vector", &in[0].link);
+ GPU_link(mat, "background_transform_to_world", GPU_builtin(GPU_VIEW_POSITION), &in[0].link);
}
node_shader_gpu_tex_mapping(mat, node, in, out);
if (tex->projection == SHD_PROJ_EQUIRECTANGULAR)
- GPU_stack_link(mat, "node_tex_environment_equirectangular", in, out, GPU_image(ima, iuser, isdata));
+ GPU_stack_link(mat, node, "node_tex_environment_equirectangular", in, out, GPU_image(ima, iuser, isdata));
else
- GPU_stack_link(mat, "node_tex_environment_mirror_ball", in, out, GPU_image(ima, iuser, isdata));
+ GPU_stack_link(mat, node, "node_tex_environment_mirror_ball", in, out, GPU_image(ima, iuser, isdata));
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL);
if (ibuf && (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) == 0 &&
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c b/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c
index 18a8065fb57..13d3438587c 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c
@@ -61,7 +61,7 @@ static int node_shader_gpu_tex_gradient(GPUMaterial *mat, bNode *node, bNodeExec
NodeTexGradient *tex = (NodeTexGradient *)node->storage;
float gradient_type = tex->gradient_type;
- return GPU_stack_link(mat, "node_tex_gradient", in, out, GPU_uniform(&gradient_type));
+ return GPU_stack_link(mat, node, "node_tex_gradient", in, out, GPU_uniform(&gradient_type));
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.c b/source/blender/nodes/shader/nodes/node_shader_tex_image.c
index 71200dfe9d3..c86a502b666 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_image.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.c
@@ -66,7 +66,7 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, bNodeExecDat
float blend = tex->projection_blend;
if (!ima)
- return GPU_stack_link(mat, "node_tex_image_empty", in, out);
+ return GPU_stack_link(mat, node, "node_tex_image_empty", in, out);
if (!in[0].link)
in[0].link = GPU_attribute(CD_MTFACE, "");
@@ -75,7 +75,7 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, bNodeExecDat
switch (tex->projection) {
case SHD_PROJ_FLAT:
- GPU_stack_link(mat, "node_tex_image", in, out, GPU_image(ima, iuser, isdata));
+ GPU_stack_link(mat, node, "node_tex_image", in, out, GPU_image(ima, iuser, isdata));
break;
case SHD_PROJ_BOX:
GPU_link(mat, "direction_transform_m4v3", GPU_builtin(GPU_VIEW_NORMAL),
@@ -94,12 +94,12 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, bNodeExecDat
case SHD_PROJ_SPHERE:
GPU_link(mat, "point_texco_remap_square", in[0].link, &in[0].link);
GPU_link(mat, "point_map_to_sphere", in[0].link, &in[0].link);
- GPU_stack_link(mat, "node_tex_image", in, out, GPU_image(ima, iuser, isdata));
+ GPU_stack_link(mat, node, "node_tex_image", in, out, GPU_image(ima, iuser, isdata));
break;
case SHD_PROJ_TUBE:
GPU_link(mat, "point_texco_remap_square", in[0].link, &in[0].link);
GPU_link(mat, "point_map_to_tube", in[0].link, &in[0].link);
- GPU_stack_link(mat, "node_tex_image", in, out, GPU_image(ima, iuser, isdata));
+ GPU_stack_link(mat, node, "node_tex_image", in, out, GPU_image(ima, iuser, isdata));
break;
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_magic.c b/source/blender/nodes/shader/nodes/node_shader_tex_magic.c
index 8700d7954e7..7cd79067693 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_magic.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_magic.c
@@ -64,7 +64,7 @@ static int node_shader_gpu_tex_magic(GPUMaterial *mat, bNode *node, bNodeExecDat
node_shader_gpu_tex_mapping(mat, node, in, out);
- return GPU_stack_link(mat, "node_tex_magic", in, out, GPU_uniform(&depth));
+ return GPU_stack_link(mat, node, "node_tex_magic", in, out, GPU_uniform(&depth));
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c
index 51d6699fadd..e36b2d5b95b 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c
@@ -68,7 +68,7 @@ static int node_shader_gpu_tex_musgrave(GPUMaterial *mat, bNode *node, bNodeExec
NodeTexMusgrave *tex = (NodeTexMusgrave *)node->storage;
float type = tex->musgrave_type;
- return GPU_stack_link(mat, "node_tex_musgrave", in, out, GPU_uniform(&type));
+ return GPU_stack_link(mat, node, "node_tex_musgrave", in, out, GPU_uniform(&type));
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_noise.c b/source/blender/nodes/shader/nodes/node_shader_tex_noise.c
index 91015b3db25..38b208fc876 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_noise.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_noise.c
@@ -61,7 +61,7 @@ static int node_shader_gpu_tex_noise(GPUMaterial *mat, bNode *node, bNodeExecDat
node_shader_gpu_tex_mapping(mat, node, in, out);
- return GPU_stack_link(mat, "node_tex_noise", in, out);
+ return GPU_stack_link(mat, node, "node_tex_noise", in, out);
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c
index 495c78ca929..7df6d34b756 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c
@@ -61,7 +61,7 @@ static int node_shader_gpu_tex_sky(GPUMaterial *mat, bNode *node, bNodeExecData
node_shader_gpu_tex_mapping(mat, node, in, out);
- return GPU_stack_link(mat, "node_tex_sky", in, out);
+ return GPU_stack_link(mat, node, "node_tex_sky", in, out);
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c
index c994798e2da..30deb422e58 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c
@@ -63,7 +63,7 @@ static int node_shader_gpu_tex_voronoi(GPUMaterial *mat, bNode *node, bNodeExecD
NodeTexVoronoi *tex = (NodeTexVoronoi *)node->storage;
float coloring = tex->coloring;
- return GPU_stack_link(mat, "node_tex_voronoi", in, out, GPU_uniform(&coloring));
+ return GPU_stack_link(mat, node, "node_tex_voronoi", in, out, GPU_uniform(&coloring));
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_wave.c b/source/blender/nodes/shader/nodes/node_shader_tex_wave.c
index 1194874e06c..356d2a78139 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_wave.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_wave.c
@@ -67,7 +67,7 @@ static int node_shader_gpu_tex_wave(GPUMaterial *mat, bNode *node, bNodeExecData
float wave_type = tex->wave_type;
float wave_profile = tex->wave_profile;
- return GPU_stack_link(mat, "node_tex_wave", in, out, GPU_uniform(&wave_type), GPU_uniform(&wave_profile));
+ return GPU_stack_link(mat, node, "node_tex_wave", in, out, GPU_uniform(&wave_type), GPU_uniform(&wave_profile));
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_texture.c b/source/blender/nodes/shader/nodes/node_shader_texture.c
index b0b25a4878b..755ef106ade 100644
--- a/source/blender/nodes/shader/nodes/node_shader_texture.c
+++ b/source/blender/nodes/shader/nodes/node_shader_texture.c
@@ -126,7 +126,7 @@ static int gpu_shader_texture(GPUMaterial *mat, bNode *node, bNodeExecData *UNUS
if (tex && tex->ima && (tex->type == TEX_IMAGE || tex->type == TEX_ENVMAP)) {
if (tex->type == TEX_IMAGE) {
GPUNodeLink *texlink = GPU_image(tex->ima, &tex->iuser, false);
- GPU_stack_link(mat, "texture_image", in, out, texlink);
+ GPU_stack_link(mat, node, "texture_image", in, out, texlink);
}
else { /* TEX_ENVMAP */
if (!in[0].link)
diff --git a/source/blender/nodes/shader/nodes/node_shader_uvmap.c b/source/blender/nodes/shader/nodes/node_shader_uvmap.c
index 0f96cb45fe0..c47bb9022b6 100644
--- a/source/blender/nodes/shader/nodes/node_shader_uvmap.c
+++ b/source/blender/nodes/shader/nodes/node_shader_uvmap.c
@@ -47,7 +47,7 @@ static int node_shader_gpu_uvmap(GPUMaterial *mat, bNode *node, bNodeExecData *U
NodeShaderUVMap *attr = node->storage;
GPUNodeLink *mtface = GPU_attribute(CD_MTFACE, attr->uv_map);
- return GPU_stack_link(mat, "node_uvmap", in, out, mtface);
+ return GPU_stack_link(mat, node, "node_uvmap", in, out, mtface);
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c b/source/blender/nodes/shader/nodes/node_shader_valToRgb.c
index 72942cce9c5..b5e32e294bf 100644
--- a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c
+++ b/source/blender/nodes/shader/nodes/node_shader_valToRgb.c
@@ -69,7 +69,7 @@ static int gpu_shader_valtorgb(GPUMaterial *mat, bNode *node, bNodeExecData *UNU
int size;
colorband_table_RGBA(node->storage, &array, &size);
- return GPU_stack_link(mat, "valtorgb", in, out, GPU_texture(size, array));
+ return GPU_stack_link(mat, node, "valtorgb", in, out, GPU_texture(size, array));
}
void register_node_type_sh_valtorgb(void)
@@ -110,9 +110,9 @@ static void node_shader_exec_rgbtobw(void *UNUSED(data), int UNUSED(thread), bNo
out[0]->vec[0] = IMB_colormanagement_get_luminance(col);
}
-static int gpu_shader_rgbtobw(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int gpu_shader_rgbtobw(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- return GPU_stack_link(mat, "rgbtobw", in, out);
+ return GPU_stack_link(mat, node, "rgbtobw", in, out);
}
void register_node_type_sh_rgbtobw(void)
diff --git a/source/blender/nodes/shader/nodes/node_shader_value.c b/source/blender/nodes/shader/nodes/node_shader_value.c
index 3a9582a6a7c..1e5bd8c5bff 100644
--- a/source/blender/nodes/shader/nodes/node_shader_value.c
+++ b/source/blender/nodes/shader/nodes/node_shader_value.c
@@ -38,10 +38,10 @@ static bNodeSocketTemplate sh_node_value_out[] = {
{ -1, 0, "" }
};
-static int gpu_shader_value(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
+static int gpu_shader_value(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- GPUNodeLink *vec = GPU_uniform(out[0].vec);
- return GPU_stack_link(mat, "set_value", in, out, vec);
+ GPUNodeLink *link = GPU_uniformbuffer_link_out(mat, node, out, 0);
+ return GPU_stack_link(mat, node, "set_value", in, out, link);
}
void register_node_type_sh_value(void)
diff --git a/source/blender/nodes/shader/nodes/node_shader_vectMath.c b/source/blender/nodes/shader/nodes/node_shader_vectMath.c
index 26045dfca04..f117adde98c 100644
--- a/source/blender/nodes/shader/nodes/node_shader_vectMath.c
+++ b/source/blender/nodes/shader/nodes/node_shader_vectMath.c
@@ -111,7 +111,7 @@ static int gpu_shader_vect_math(GPUMaterial *mat, bNode *node, bNodeExecData *UN
case 2:
case 3:
case 4:
- GPU_stack_link(mat, names[node->custom1], in, out);
+ GPU_stack_link(mat, node, names[node->custom1], in, out);
break;
case 5:
if (in[0].hasinput || !in[1].hasinput) {
@@ -119,14 +119,14 @@ static int gpu_shader_vect_math(GPUMaterial *mat, bNode *node, bNodeExecData *UN
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);
+ GPU_stack_link(mat, node, 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);
+ GPU_stack_link(mat, node, names[node->custom1], tmp_in, out);
}
break;
default:
diff --git a/source/blender/nodes/shader/nodes/node_shader_volume_absorption.c b/source/blender/nodes/shader/nodes/node_shader_volume_absorption.c
index 4861871e8d3..518ab6587b2 100644
--- a/source/blender/nodes/shader/nodes/node_shader_volume_absorption.c
+++ b/source/blender/nodes/shader/nodes/node_shader_volume_absorption.c
@@ -40,9 +40,9 @@ static bNodeSocketTemplate sh_node_volume_absorption_out[] = {
{ -1, 0, "" }
};
-static int node_shader_gpu_volume_absorption(GPUMaterial *UNUSED(mat), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *UNUSED(in), GPUNodeStack *UNUSED(out))
+static int node_shader_gpu_volume_absorption(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- return false;
+ return GPU_stack_link(mat, node, "node_volume_absorption", in, out);
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_volume_scatter.c b/source/blender/nodes/shader/nodes/node_shader_volume_scatter.c
index 0c5647b4ba8..bce4695af10 100644
--- a/source/blender/nodes/shader/nodes/node_shader_volume_scatter.c
+++ b/source/blender/nodes/shader/nodes/node_shader_volume_scatter.c
@@ -41,9 +41,9 @@ static bNodeSocketTemplate sh_node_volume_scatter_out[] = {
{ -1, 0, "" }
};
-static int node_shader_gpu_volume_scatter(GPUMaterial *UNUSED(mat), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *UNUSED(in), GPUNodeStack *UNUSED(out))
+static int node_shader_gpu_volume_scatter(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- return false;
+ return GPU_stack_link(mat, node, "node_volume_scatter", in, out);
}
/* node type definition */
diff --git a/source/blender/nodes/texture/node_texture_tree.c b/source/blender/nodes/texture/node_texture_tree.c
index 3b53d29d147..2ac4ce2f48c 100644
--- a/source/blender/nodes/texture/node_texture_tree.c
+++ b/source/blender/nodes/texture/node_texture_tree.c
@@ -63,7 +63,7 @@ static void texture_get_from_context(const bContext *C, bNodeTreeType *UNUSED(tr
SpaceNode *snode = CTX_wm_space_node(C);
Scene *scene = CTX_data_scene(C);
SceneLayer *sl = CTX_data_scene_layer(C);
- Object *ob = OBACT_NEW;
+ Object *ob = OBACT_NEW(sl);
Tex *tx = NULL;
if (snode->texfrom == SNODE_TEX_OBJECT) {
diff --git a/source/blender/python/CMakeLists.txt b/source/blender/python/CMakeLists.txt
index e855f3a3756..8d26fee0abd 100644
--- a/source/blender/python/CMakeLists.txt
+++ b/source/blender/python/CMakeLists.txt
@@ -17,6 +17,7 @@
# ***** END GPL LICENSE BLOCK *****
add_subdirectory(intern)
+add_subdirectory(gawain)
add_subdirectory(generic)
add_subdirectory(mathutils)
add_subdirectory(bmesh)
diff --git a/source/blender/python/bmesh/bmesh_py_ops_call.c b/source/blender/python/bmesh/bmesh_py_ops_call.c
index 8f287918a4a..6598d402f72 100644
--- a/source/blender/python/bmesh/bmesh_py_ops_call.c
+++ b/source/blender/python/bmesh/bmesh_py_ops_call.c
@@ -44,6 +44,7 @@
#include "bmesh_py_types.h"
#include "../generic/python_utildefines.h"
+#include "../generic/py_capi_utils.h"
static int bpy_bm_op_as_py_error(BMesh *bm)
{
@@ -152,11 +153,9 @@ static int bpy_slot_from_py(
switch (slot->slot_type) {
case BMO_OP_SLOT_BOOL:
{
- int param;
+ const int param = PyC_Long_AsBool(value);
- param = PyLong_AsLong(value);
-
- if (param < 0) {
+ if (param == -1) {
PyErr_Format(PyExc_TypeError,
"%.200s: keyword \"%.200s\" expected True/False or 0/1, not %.200s",
opname, slot_name, Py_TYPE(value)->tp_name);
@@ -170,23 +169,16 @@ static int bpy_slot_from_py(
}
case BMO_OP_SLOT_INT:
{
- int overflow;
- long param = PyLong_AsLongAndOverflow(value, &overflow);
- if (overflow || (param > INT_MAX) || (param < INT_MIN)) {
- PyErr_Format(PyExc_ValueError,
- "%.200s: keyword \"%.200s\" value not in 'int' range "
- "(" STRINGIFY(INT_MIN) ", " STRINGIFY(INT_MAX) ")",
- opname, slot_name, Py_TYPE(value)->tp_name);
- return -1;
- }
- else if (param == -1 && PyErr_Occurred()) {
+ const int param = PyC_Long_AsI32(value);
+
+ if (param == -1 && PyErr_Occurred()) {
PyErr_Format(PyExc_TypeError,
"%.200s: keyword \"%.200s\" expected an int, not %.200s",
opname, slot_name, Py_TYPE(value)->tp_name);
return -1;
}
else {
- BMO_SLOT_AS_INT(slot) = (int)param;
+ BMO_SLOT_AS_INT(slot) = param;
}
break;
}
@@ -208,26 +200,19 @@ static int bpy_slot_from_py(
{
/* XXX - BMesh operator design is crappy here, operator slot should define matrix size,
* not the caller! */
- unsigned short size;
- if (!MatrixObject_Check(value)) {
- PyErr_Format(PyExc_TypeError,
- "%.200s: keyword \"%.200s\" expected a Matrix, not %.200s",
- opname, slot_name, Py_TYPE(value)->tp_name);
+ MatrixObject *pymat;
+ if (!Matrix_ParseAny(value, &pymat)) {
return -1;
}
- else if (BaseMath_ReadCallback((MatrixObject *)value) == -1) {
- return -1;
- }
- else if (((size = ((MatrixObject *)value)->num_col) != ((MatrixObject *)value)->num_row) ||
- (ELEM(size, 3, 4) == false))
- {
+ const ushort size = pymat->num_col;
+ if ((size != pymat->num_row) || (!ELEM(size, 3, 4))) {
PyErr_Format(PyExc_TypeError,
"%.200s: keyword \"%.200s\" expected a 3x3 or 4x4 matrix Matrix",
opname, slot_name);
return -1;
}
- BMO_slot_mat_set(bmop, bmop->slots_in, slot_name, ((MatrixObject *)value)->matrix, size);
+ BMO_slot_mat_set(bmop, bmop->slots_in, slot_name, pymat->matrix, size);
break;
}
case BMO_OP_SLOT_VEC:
@@ -436,7 +421,7 @@ static int bpy_slot_from_py(
return -1; /* error is set in bpy_slot_from_py_elem_check() */
}
- value_i = PyLong_AsLong(arg_value);
+ value_i = PyC_Long_AsI32(arg_value);
if (value_i == -1 && PyErr_Occurred()) {
PyErr_Format(PyExc_TypeError,
@@ -466,7 +451,7 @@ static int bpy_slot_from_py(
return -1; /* error is set in bpy_slot_from_py_elem_check() */
}
- value_i = PyLong_AsLong(arg_value);
+ value_i = PyC_Long_AsI32(arg_value);
if (value_i == -1 && PyErr_Occurred()) {
PyErr_Format(PyExc_TypeError,
diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c
index 88445cfd62b..caf836fa5b8 100644
--- a/source/blender/python/bmesh/bmesh_py_types.c
+++ b/source/blender/python/bmesh/bmesh_py_types.c
@@ -125,25 +125,19 @@ static int bpy_bm_elem_hflag_set(BPy_BMElem *self, PyObject *value, void *flag)
BPY_BM_CHECK_INT(self);
- param = PyLong_AsLong(value);
-
- if ((unsigned int)param <= 1) {
- if (hflag == BM_ELEM_SELECT)
- BM_elem_select_set(self->bm, self->ele, param);
- else
- BM_elem_flag_set(self->ele, hflag, param);
+ if ((param = PyC_Long_AsBool(value)) == -1) {
+ return -1;
+ }
- return 0;
+ if (hflag == BM_ELEM_SELECT) {
+ BM_elem_select_set(self->bm, self->ele, param);
}
else {
- PyErr_Format(PyExc_TypeError,
- "expected True/False or 0/1, not %.200s",
- Py_TYPE(value)->tp_name);
- return -1;
+ BM_elem_flag_set(self->ele, hflag, param);
}
+ return 0;
}
-
PyDoc_STRVAR(bpy_bm_elem_index_doc,
"Index of this element.\n"
"\n"
@@ -170,21 +164,17 @@ static int bpy_bm_elem_index_set(BPy_BMElem *self, PyObject *value, void *UNUSED
BPY_BM_CHECK_INT(self);
- param = PyLong_AsLong(value);
-
- if (param == -1 && PyErr_Occurred()) {
- PyErr_SetString(PyExc_TypeError,
- "expected an int type");
+ if (((param = PyC_Long_AsI32(value)) == -1) && PyErr_Occurred()) {
+ /* error is set */
return -1;
}
- else {
- BM_elem_index_set(self->ele, param); /* set_dirty! */
- /* when setting the index assume its set invalid */
- self->bm->elem_index_dirty |= self->ele->head.htype;
+ BM_elem_index_set(self->ele, param); /* set_dirty! */
- return 0;
- }
+ /* when setting the index assume its set invalid */
+ self->bm->elem_index_dirty |= self->ele->head.htype;
+
+ return 0;
}
/* type specific get/sets
@@ -507,14 +497,12 @@ static int bpy_bmface_material_index_set(BPy_BMFace *self, PyObject *value)
BPY_BM_CHECK_INT(self);
- param = PyLong_AsLong(value);
-
- if (param == -1 && PyErr_Occurred()) {
- PyErr_SetString(PyExc_TypeError,
- "expected an int type");
+ if (((param = PyC_Long_AsI32(value)) == -1) && PyErr_Occurred()) {
+ /* error is set */
return -1;
}
- else if ((param < 0) || (param > MAXMAT)) {
+
+ if ((param < 0) || (param > MAXMAT)) {
/* normally we clamp but in this case raise an error */
PyErr_SetString(PyExc_ValueError,
"material index outside of usable range (0 - 32766)");
@@ -941,6 +929,8 @@ PyDoc_STRVAR(bpy_bmesh_from_object_doc,
);
static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject *kw)
{
+ /* TODO: This doesn't work currently because of eval_ctx. */
+#if 0
static const char *kwlist[] = {"object", "scene", "deform", "render", "cage", "face_normals", NULL};
PyObject *py_object;
PyObject *py_scene;
@@ -1033,6 +1023,10 @@ static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject
dm->release(dm);
Py_RETURN_NONE;
+#else
+ UNUSED_VARS(self, args, kw);
+#endif
+ return NULL;
}
@@ -1047,6 +1041,13 @@ PyDoc_STRVAR(bpy_bmesh_from_mesh_doc,
" :type use_shape_key: boolean\n"
" :arg shape_key_index: The shape key index to use.\n"
" :type shape_key_index: int\n"
+"\n"
+" .. note::\n"
+"\n"
+" Multiple calls can be used to join multiple meshes.\n"
+"\n"
+" Custom-data layers are only copied from ``mesh`` on initialization.\n"
+" Further calls will copy custom-data to matching layers, layers missing on the target mesh wont be added.\n"
);
static PyObject *bpy_bmesh_from_mesh(BPy_BMesh *self, PyObject *args, PyObject *kw)
{
@@ -1111,15 +1112,16 @@ static PyObject *bpy_bmesh_select_flush(BPy_BMesh *self, PyObject *value)
BPY_BM_CHECK_OBJ(self);
- param = PyLong_AsLong(value);
- if (param != false && param != true) {
- PyErr_SetString(PyExc_TypeError,
- "expected a boolean type 0/1");
+ if ((param = PyC_Long_AsBool(value)) == -1) {
return NULL;
}
- if (param) BM_mesh_select_flush(self->bm);
- else BM_mesh_deselect_flush(self->bm);
+ if (param) {
+ BM_mesh_select_flush(self->bm);
+ }
+ else {
+ BM_mesh_deselect_flush(self->bm);
+ }
Py_RETURN_NONE;
}
@@ -1299,10 +1301,7 @@ static PyObject *bpy_bm_elem_select_set(BPy_BMElem *self, PyObject *value)
BPY_BM_CHECK_OBJ(self);
- param = PyLong_AsLong(value);
- if (param != false && param != true) {
- PyErr_SetString(PyExc_TypeError,
- "expected a boolean type 0/1");
+ if ((param = PyC_Long_AsBool(value)) == -1) {
return NULL;
}
@@ -1327,10 +1326,7 @@ static PyObject *bpy_bm_elem_hide_set(BPy_BMElem *self, PyObject *value)
BPY_BM_CHECK_OBJ(self);
- param = PyLong_AsLong(value);
- if (param != false && param != true) {
- PyErr_SetString(PyExc_TypeError,
- "expected a boolean type 0/1");
+ if ((param = PyC_Long_AsBool(value)) == -1) {
return NULL;
}
diff --git a/source/blender/python/bmesh/bmesh_py_types_customdata.c b/source/blender/python/bmesh/bmesh_py_types_customdata.c
index 47dead028a4..e2241ade7f0 100644
--- a/source/blender/python/bmesh/bmesh_py_types_customdata.c
+++ b/source/blender/python/bmesh/bmesh_py_types_customdata.c
@@ -43,6 +43,7 @@
#include "../mathutils/mathutils.h"
#include "../generic/python_utildefines.h"
+#include "../generic/py_capi_utils.h"
#include "BKE_customdata.h"
@@ -116,6 +117,9 @@ PyDoc_STRVAR(bpy_bmlayeraccess_collection__skin_doc,
PyDoc_STRVAR(bpy_bmlayeraccess_collection__paint_mask_doc,
"Accessor for paint mask layer.\n\ntype: :class:`BMLayerCollection`"
);
+PyDoc_STRVAR(bpy_bmlayeraccess_collection__face_map_doc,
+"FaceMap custom-data layer.\n\ntype: :class:`BMLayerCollection`"
+);
#ifdef WITH_FREESTYLE
PyDoc_STRVAR(bpy_bmlayeraccess_collection__freestyle_edge_doc,
"Accessor for Freestyle edge layer.\n\ntype: :class:`BMLayerCollection`"
@@ -218,6 +222,7 @@ static PyGetSetDef bpy_bmlayeraccess_face_getseters[] = {
{(char *)"float", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__float_doc, (void *)CD_PROP_FLT},
{(char *)"int", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__int_doc, (void *)CD_PROP_INT},
{(char *)"string", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__string_doc, (void *)CD_PROP_STR},
+ {(char *)"face_map", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__face_map_doc, (void *)CD_FACEMAP},
#ifdef WITH_FREESTYLE
{(char *)"freestyle", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__freestyle_face_doc, (void *)CD_FREESTYLE_FACE},
@@ -983,6 +988,7 @@ PyObject *BPy_BMLayerItem_GetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer)
break;
}
case CD_PROP_INT:
+ case CD_FACEMAP:
{
ret = PyLong_FromLong(*(int *)value);
break;
@@ -1063,10 +1069,11 @@ int BPy_BMLayerItem_SetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer, PyObj
break;
}
case CD_PROP_INT:
+ case CD_FACEMAP:
{
- int tmp_val = PyLong_AsLong(py_value);
+ int tmp_val = PyC_Long_AsI32(py_value);
if (UNLIKELY(tmp_val == -1 && PyErr_Occurred())) {
- PyErr_Format(PyExc_TypeError, "expected an int, not a %.200s", Py_TYPE(py_value)->tp_name);
+ /* error is set */
ret = -1;
}
else {
diff --git a/source/blender/python/bmesh/bmesh_py_types_meshdata.c b/source/blender/python/bmesh/bmesh_py_types_meshdata.c
index f6926e8437d..574aef3d54f 100644
--- a/source/blender/python/bmesh/bmesh_py_types_meshdata.c
+++ b/source/blender/python/bmesh/bmesh_py_types_meshdata.c
@@ -45,6 +45,7 @@
#include "bmesh_py_types_meshdata.h"
+#include "../generic/py_capi_utils.h"
#include "../generic/python_utildefines.h"
/* Mesh Loop UV
@@ -98,7 +99,7 @@ static int bpy_bmloopuv_flag_set(BPy_BMLoopUV *self, PyObject *value, void *flag
{
const int flag = GET_INT_FROM_POINTER(flag_p);
- switch (PyLong_AsLong(value)) {
+ switch (PyC_Long_AsBool(value)) {
case true:
self->data->flag |= flag;
return 0;
@@ -106,8 +107,7 @@ static int bpy_bmloopuv_flag_set(BPy_BMLoopUV *self, PyObject *value, void *flag
self->data->flag &= ~flag;
return 0;
default:
- PyErr_SetString(PyExc_TypeError,
- "expected a boolean type 0/1");
+ /* error is set */
return -1;
}
}
@@ -207,7 +207,7 @@ static int bpy_bmvertskin_flag_set(BPy_BMVertSkin *self, PyObject *value, void *
{
const int flag = GET_INT_FROM_POINTER(flag_p);
- switch (PyLong_AsLong(value)) {
+ switch (PyC_Long_AsBool(value)) {
case true:
self->data->flag |= flag;
return 0;
@@ -215,8 +215,7 @@ static int bpy_bmvertskin_flag_set(BPy_BMVertSkin *self, PyObject *value, void *
self->data->flag &= ~flag;
return 0;
default:
- PyErr_SetString(PyExc_TypeError,
- "expected a boolean type 0/1");
+ /* error is set */
return -1;
}
}
diff --git a/source/blender/python/gawain/CMakeLists.txt b/source/blender/python/gawain/CMakeLists.txt
new file mode 100644
index 00000000000..6b6c902f48a
--- /dev/null
+++ b/source/blender/python/gawain/CMakeLists.txt
@@ -0,0 +1,47 @@
+# ***** 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.
+#
+# Contributor(s): Campbell Barton
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(INC
+ .
+ ../../blenkernel
+ ../../blenlib
+ ../../gpu
+ ../../makesdna
+ ../../../../intern/gawain
+ ../../../../intern/guardedalloc
+ ../../../../intern/glew-mx
+)
+
+set(INC_SYS
+ ${GLEW_INCLUDE_PATH}
+ ${PYTHON_INCLUDE_DIRS}
+)
+
+set(SRC
+ gwn_py_api.c
+ gwn_py_types.c
+
+ gwn_py_api.h
+ gwn_py_types.h
+)
+
+add_definitions(${GL_DEFINITIONS})
+
+blender_add_lib(bf_python_gawain "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/python/gawain/gwn_py_api.c b/source/blender/python/gawain/gwn_py_api.c
new file mode 100644
index 00000000000..d79ef070649
--- /dev/null
+++ b/source/blender/python/gawain/gwn_py_api.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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/python/gawain/gwn_py_api.c
+ * \ingroup pygawain
+ *
+ * Experimental Python API, not considered public yet (called '_gawain'),
+ * we may re-expose as public later.
+ */
+
+#include <Python.h>
+
+#include "gawain/gwn_batch.h"
+#include "gawain/gwn_vertex_format.h"
+
+#include "gwn_py_api.h"
+#include "gwn_py_types.h"
+
+#include "BLI_utildefines.h"
+
+#include "../generic/python_utildefines.h"
+
+PyDoc_STRVAR(GWN_doc,
+"This module provides access to gawain drawing functions."
+);
+static struct PyModuleDef GWN_module_def = {
+ PyModuleDef_HEAD_INIT,
+ .m_name = "_gawain", /* m_name */
+ .m_doc = GWN_doc, /* m_doc */
+};
+
+PyObject *BPyInit_gawain(void)
+{
+ PyObject *sys_modules = PyThreadState_GET()->interp->modules;
+ PyObject *submodule;
+ PyObject *mod;
+
+ mod = PyModule_Create(&GWN_module_def);
+
+ /* _gawain.types */
+ PyModule_AddObject(mod, "types", (submodule = BPyInit_gawain_types()));
+ PyDict_SetItem(sys_modules, PyModule_GetNameObject(submodule), submodule);
+ Py_INCREF(submodule);
+
+ return mod;
+}
diff --git a/source/blender/python/gawain/gwn_py_api.h b/source/blender/python/gawain/gwn_py_api.h
new file mode 100644
index 00000000000..3ef85e8ae0f
--- /dev/null
+++ b/source/blender/python/gawain/gwn_py_api.h
@@ -0,0 +1,30 @@
+/*
+ * ***** 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __GWN_PY_API_H__
+#define __GWN_PY_API_H__
+
+/** \file blender/python/gawain/gwn_py_api.h
+ * \ingroup pygawain
+ */
+
+PyObject *BPyInit_gawain(void);
+
+#endif /* __GWN_PY_API_H__ */
diff --git a/source/blender/python/gawain/gwn_py_types.c b/source/blender/python/gawain/gwn_py_types.c
new file mode 100644
index 00000000000..cc448d9ed90
--- /dev/null
+++ b/source/blender/python/gawain/gwn_py_types.c
@@ -0,0 +1,823 @@
+/*
+ * ***** 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/python/gawain/gwn_py_types.c
+ * \ingroup pygawain
+ *
+ * - Use ``bpygwn_`` for local API.
+ * - Use ``BPyGwn_`` for public API.
+ */
+
+#include <Python.h>
+
+#include "gawain/gwn_batch.h"
+#include "gawain/gwn_vertex_format.h"
+
+#include "BLI_math.h"
+
+#include "GPU_batch.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "../generic/py_capi_utils.h"
+#include "../generic/python_utildefines.h"
+
+#include "gwn_py_types.h" /* own include */
+
+#ifdef __BIG_ENDIAN__
+ /* big endian */
+# define MAKE_ID2(c, d) ((c) << 8 | (d))
+# define MAKE_ID3(a, b, c) ( (int)(a) << 24 | (int)(b) << 16 | (c) << 8 )
+# define MAKE_ID4(a, b, c, d) ( (int)(a) << 24 | (int)(b) << 16 | (c) << 8 | (d) )
+#else
+ /* little endian */
+# define MAKE_ID2(c, d) ((d) << 8 | (c))
+# define MAKE_ID3(a, b, c) ( (int)(c) << 16 | (b) << 8 | (a) )
+# define MAKE_ID4(a, b, c, d) ( (int)(d) << 24 | (int)(c) << 16 | (b) << 8 | (a) )
+#endif
+
+/* -------------------------------------------------------------------- */
+
+/** \name Enum Conversion
+ *
+ * Use with PyArg_ParseTuple's "O&" formatting.
+ * \{ */
+
+static int bpygwn_ParseVertCompType(PyObject *o, void *p)
+{
+ Py_ssize_t comp_type_id_len;
+ const char *comp_type_id = _PyUnicode_AsStringAndSize(o, &comp_type_id_len);
+ if (comp_type_id == NULL) {
+ PyErr_Format(PyExc_ValueError,
+ "expected a string, got %s",
+ Py_TYPE(o)->tp_name);
+ return 0;
+ }
+
+ Gwn_VertCompType comp_type;
+ if (comp_type_id_len == 2) {
+ switch (*((ushort *)comp_type_id)) {
+ case MAKE_ID2('I', '8'): { comp_type = GWN_COMP_I8; goto success; }
+ case MAKE_ID2('U', '8'): { comp_type = GWN_COMP_U8; goto success; }
+ }
+ }
+ else if (comp_type_id_len == 3) {
+ switch (*((uint *)comp_type_id)) {
+ case MAKE_ID3('I', '1', '6'): { comp_type = GWN_COMP_I16; goto success; }
+ case MAKE_ID3('U', '1', '6'): { comp_type = GWN_COMP_U16; goto success; }
+ case MAKE_ID3('I', '3', '2'): { comp_type = GWN_COMP_I32; goto success; }
+ case MAKE_ID3('U', '3', '2'): { comp_type = GWN_COMP_U32; goto success; }
+ case MAKE_ID3('F', '3', '2'): { comp_type = GWN_COMP_F32; goto success; }
+ case MAKE_ID3('I', '1', '0'): { comp_type = GWN_COMP_I10; goto success; }
+ }
+ }
+
+ PyErr_Format(PyExc_ValueError,
+ "unknown type literal: '%s'",
+ comp_type_id);
+ return 0;
+
+success:
+ *((Gwn_VertCompType *)p) = comp_type;
+ return 1;
+}
+
+static int bpygwn_ParseVertFetchMode(PyObject *o, void *p)
+{
+ Py_ssize_t mode_id_len;
+ const char *mode_id = _PyUnicode_AsStringAndSize(o, &mode_id_len);
+ if (mode_id == NULL) {
+ PyErr_Format(PyExc_ValueError,
+ "expected a string, got %s",
+ Py_TYPE(o)->tp_name);
+ return 0;
+ }
+#define MATCH_ID(id) \
+ if (mode_id_len == strlen(STRINGIFY(id))) { \
+ if (STREQ(mode_id, STRINGIFY(id))) { \
+ mode = GWN_FETCH_##id; \
+ goto success; \
+ } \
+ } ((void)0)
+
+ Gwn_VertCompType mode;
+ MATCH_ID(FLOAT);
+ MATCH_ID(INT);
+ MATCH_ID(INT_TO_FLOAT_UNIT);
+ MATCH_ID(INT_TO_FLOAT);
+#undef MATCH_ID
+ PyErr_Format(PyExc_ValueError,
+ "unknown type literal: '%s'",
+ mode_id);
+ return 0;
+
+success:
+ (*(Gwn_VertFetchMode *)p) = mode;
+ return 1;
+}
+
+static int bpygwn_ParsePrimType(PyObject *o, void *p)
+{
+ Py_ssize_t mode_id_len;
+ const char *mode_id = _PyUnicode_AsStringAndSize(o, &mode_id_len);
+ if (mode_id == NULL) {
+ PyErr_Format(PyExc_ValueError,
+ "expected a string, got %s",
+ Py_TYPE(o)->tp_name);
+ return 0;
+ }
+#define MATCH_ID(id) \
+ if (mode_id_len == strlen(STRINGIFY(id))) { \
+ if (STREQ(mode_id, STRINGIFY(id))) { \
+ mode = GWN_PRIM_##id; \
+ goto success; \
+ } \
+ } ((void)0)
+
+ Gwn_PrimType mode;
+ MATCH_ID(POINTS);
+ MATCH_ID(LINES);
+ MATCH_ID(TRIS);
+ MATCH_ID(LINE_STRIP);
+ MATCH_ID(LINE_LOOP);
+ MATCH_ID(TRI_STRIP);
+ MATCH_ID(TRI_FAN);
+ MATCH_ID(LINE_STRIP_ADJ);
+
+#undef MATCH_ID
+ PyErr_Format(PyExc_ValueError,
+ "unknown type literal: '%s'",
+ mode_id);
+ return 0;
+
+success:
+ (*(Gwn_VertFetchMode *)p) = mode;
+ return 1;
+}
+
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+
+/** \name Utility Functions
+ * \{ */
+
+#define PY_AS_NATIVE_SWITCH(attr) \
+ switch (attr->comp_type) { \
+ case GWN_COMP_I8: { PY_AS_NATIVE(int8_t, PyC_Long_AsI8); break; } \
+ case GWN_COMP_U8: { PY_AS_NATIVE(uint8_t, PyC_Long_AsU8); break; } \
+ case GWN_COMP_I16: { PY_AS_NATIVE(int16_t, PyC_Long_AsI16); break; } \
+ case GWN_COMP_U16: { PY_AS_NATIVE(uint16_t, PyC_Long_AsU16); break; } \
+ case GWN_COMP_I32: { PY_AS_NATIVE(int32_t, PyC_Long_AsI32); break; } \
+ case GWN_COMP_U32: { PY_AS_NATIVE(uint32_t, PyC_Long_AsU32); break; } \
+ case GWN_COMP_F32: { PY_AS_NATIVE(float, PyFloat_AsDouble); break; } \
+ default: \
+ BLI_assert(0); \
+ } ((void)0)
+
+/* No error checking, callers must run PyErr_Occurred */
+static void fill_format_elem(void *data_dst_void, PyObject *py_src, const Gwn_VertAttr *attr)
+{
+#define PY_AS_NATIVE(ty_dst, py_as_native) \
+{ \
+ ty_dst *data_dst = data_dst_void; \
+ *data_dst = py_as_native(py_src); \
+} ((void)0)
+
+ PY_AS_NATIVE_SWITCH(attr);
+
+#undef PY_AS_NATIVE
+}
+
+/* No error checking, callers must run PyErr_Occurred */
+static void fill_format_tuple(void *data_dst_void, PyObject *py_src, const Gwn_VertAttr *attr)
+{
+ const uint len = attr->comp_ct;
+
+/**
+ * Args are constants, so range checks will be optimized out if they're nop's.
+ */
+#define PY_AS_NATIVE(ty_dst, py_as_native) \
+ ty_dst *data_dst = data_dst_void; \
+ for (uint i = 0; i < len; i++) { \
+ data_dst[i] = py_as_native(PyTuple_GET_ITEM(py_src, i)); \
+ } ((void)0)
+
+ PY_AS_NATIVE_SWITCH(attr);
+
+#undef PY_AS_NATIVE
+}
+
+#undef PY_AS_NATIVE_SWITCH
+#undef WARN_TYPE_LIMIT_PUSH
+#undef WARN_TYPE_LIMIT_POP
+
+static bool bpygwn_vertbuf_fill_impl(
+ Gwn_VertBuf *vbo,
+ uint data_id, PyObject *seq)
+{
+ bool ok = true;
+ const Gwn_VertAttr *attr = &vbo->format.attribs[data_id];
+
+ Gwn_VertBufRaw data_step;
+ GWN_vertbuf_attr_get_raw_data(vbo, data_id, &data_step);
+
+ PyObject *seq_fast = PySequence_Fast(seq, "Vertex buffer fill");
+ if (seq_fast == NULL) {
+ goto finally;
+ }
+
+ const uint seq_len = PySequence_Fast_GET_SIZE(seq_fast);
+
+ if (seq_len != vbo->vertex_ct) {
+ PyErr_Format(PyExc_ValueError,
+ "Expected a sequence of size %d, got %d",
+ vbo->vertex_ct, seq_len);
+ }
+
+ PyObject **seq_items = PySequence_Fast_ITEMS(seq_fast);
+
+ if (attr->comp_ct == 1) {
+ for (uint i = 0; i < seq_len; i++) {
+ uchar *data = (uchar *)GWN_vertbuf_raw_step(&data_step);
+ PyObject *item = seq_items[i];
+ fill_format_elem(data, item, attr);
+ }
+ }
+ else {
+ for (uint i = 0; i < seq_len; i++) {
+ uchar *data = (uchar *)GWN_vertbuf_raw_step(&data_step);
+ PyObject *item = seq_items[i];
+ if (!PyTuple_CheckExact(item)) {
+ PyErr_Format(PyExc_ValueError,
+ "expected a tuple, got %s",
+ Py_TYPE(item)->tp_name);
+ ok = false;
+ goto finally;
+ }
+ if (PyTuple_GET_SIZE(item) != attr->comp_ct) {
+ PyErr_Format(PyExc_ValueError,
+ "expected a tuple of size %d, got %d",
+ attr->comp_ct, PyTuple_GET_SIZE(item));
+ ok = false;
+ goto finally;
+ }
+
+ /* May trigger error, check below */
+ fill_format_tuple(data, item, attr);
+ }
+ }
+
+ if (PyErr_Occurred()) {
+ ok = false;
+ }
+
+finally:
+
+ Py_DECREF(seq_fast);
+ return ok;
+}
+
+/* handy, but not used just now */
+#if 0
+static int bpygwn_find_id(const Gwn_VertFormat *fmt, const char *id)
+{
+ for (int i = 0; i < fmt->attrib_ct; i++) {
+ for (uint j = 0; j < fmt->name_ct; j++) {
+ if (STREQ(fmt->attribs[i].name[j], id)) {
+ return i;
+ }
+ }
+ }
+ return -1;
+}
+#endif
+
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+
+/** \name VertFormat Type
+ * \{ */
+
+static PyObject *bpygwn_VertFormat_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
+{
+ if (PyTuple_GET_SIZE(args) || (kwds && PyDict_Size(kwds))) {
+ PyErr_SetString(PyExc_TypeError,
+ "VertFormat(): takes no arguments");
+ return NULL;
+ }
+
+ BPyGwn_VertFormat *ret = (BPyGwn_VertFormat *)BPyGwn_VertFormat_CreatePyObject(NULL);
+
+ return (PyObject *)ret;
+}
+
+PyDoc_STRVAR(bpygwn_VertFormat_attr_add_doc,
+"TODO"
+);
+static PyObject *bpygwn_VertFormat_attr_add(BPyGwn_VertFormat *self, PyObject *args, PyObject *kwds)
+{
+ static const char *kwlist[] = {"id", "comp_type", "len", "fetch_mode", NULL};
+
+ struct {
+ const char *id;
+ Gwn_VertCompType comp_type;
+ uint len;
+ Gwn_VertFetchMode fetch_mode;
+ } params;
+
+ if (self->fmt.attrib_ct == GWN_VERT_ATTR_MAX_LEN) {
+ PyErr_SetString(PyExc_ValueError, "Maxumum attr reached " STRINGIFY(GWN_VERT_ATTR_MAX_LEN));
+ return NULL;
+ }
+
+ if (!PyArg_ParseTupleAndKeywords(
+ args, kwds, "$sO&IO&:attr_add", (char **)kwlist,
+ &params.id,
+ bpygwn_ParseVertCompType, &params.comp_type,
+ &params.len,
+ bpygwn_ParseVertFetchMode, &params.fetch_mode))
+ {
+ return NULL;
+ }
+
+ uint attr_id = GWN_vertformat_attr_add(&self->fmt, params.id, params.comp_type, params.len, params.fetch_mode);
+ return PyLong_FromLong(attr_id);
+}
+
+static struct PyMethodDef bpygwn_VertFormat_methods[] = {
+ {"attr_add", (PyCFunction)bpygwn_VertFormat_attr_add,
+ METH_VARARGS | METH_KEYWORDS, bpygwn_VertFormat_attr_add_doc},
+ {NULL, NULL, 0, NULL}
+};
+
+
+static void bpygwn_VertFormat_dealloc(BPyGwn_VertFormat *self)
+{
+ Py_TYPE(self)->tp_free(self);
+}
+
+PyTypeObject BPyGwn_VertFormat_Type = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ .tp_name = "Gwn_VertFormat",
+ .tp_basicsize = sizeof(BPyGwn_VertFormat),
+ .tp_dealloc = (destructor)bpygwn_VertFormat_dealloc,
+ .tp_flags = Py_TPFLAGS_DEFAULT,
+ .tp_methods = bpygwn_VertFormat_methods,
+ .tp_new = bpygwn_VertFormat_new,
+};
+
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+
+/** \name VertBuf Type
+ * \{ */
+
+static PyObject *bpygwn_VertBuf_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
+{
+ const char * const keywords[] = {"len", "format", NULL};
+
+ struct {
+ BPyGwn_VertFormat *py_fmt;
+ uint len;
+ } params;
+
+ if (!PyArg_ParseTupleAndKeywords(
+ args, kwds,
+ "$IO!:Gwn_VertBuf.__new__", (char **)keywords,
+ &params.len,
+ &BPyGwn_VertFormat_Type, &params.py_fmt))
+ {
+ return NULL;
+ }
+
+ struct Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&params.py_fmt->fmt);
+
+ GWN_vertbuf_data_alloc(vbo, params.len);
+
+ return BPyGwn_VertBuf_CreatePyObject(vbo);
+}
+
+PyDoc_STRVAR(bpygwn_VertBuf_fill_doc,
+"TODO"
+);
+static PyObject *bpygwn_VertBuf_fill(BPyGwn_VertBuf *self, PyObject *args, PyObject *kwds)
+{
+ static const char *kwlist[] = {"id", "data", NULL};
+
+ struct {
+ uint id;
+ PyObject *py_seq_data;
+ } params;
+
+ if (!PyArg_ParseTupleAndKeywords(
+ args, kwds, "$IO:fill", (char **)kwlist,
+ &params.id,
+ &params.py_seq_data))
+ {
+ return NULL;
+ }
+
+ if (params.id >= self->buf->format.attrib_ct) {
+ PyErr_Format(PyExc_ValueError,
+ "Format id %d out of range",
+ params.id);
+ return NULL;
+ }
+
+ if (self->buf->vbo_id != 0) {
+ PyErr_SetString(PyExc_ValueError,
+ "Can't fill, buffer already in use");
+ return NULL;
+ }
+
+ if (!bpygwn_vertbuf_fill_impl(self->buf, params.id, params.py_seq_data)) {
+ return NULL;
+ }
+ Py_RETURN_NONE;
+}
+
+static struct PyMethodDef bpygwn_VertBuf_methods[] = {
+ {"fill", (PyCFunction) bpygwn_VertBuf_fill,
+ METH_VARARGS | METH_KEYWORDS, bpygwn_VertBuf_fill_doc},
+ {NULL, NULL, 0, NULL}
+};
+
+static void bpygwn_VertBuf_dealloc(BPyGwn_VertBuf *self)
+{
+ GWN_vertbuf_discard(self->buf);
+ Py_TYPE(self)->tp_free(self);
+}
+
+PyTypeObject BPyGwn_VertBuf_Type = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ .tp_name = "Gwn_VertBuf",
+ .tp_basicsize = sizeof(BPyGwn_VertBuf),
+ .tp_dealloc = (destructor)bpygwn_VertBuf_dealloc,
+ .tp_flags = Py_TPFLAGS_DEFAULT,
+ .tp_methods = bpygwn_VertBuf_methods,
+ .tp_new = bpygwn_VertBuf_new,
+};
+
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+
+/** \name VertBatch Type
+ * \{ */
+
+static PyObject *bpygwn_Batch_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
+{
+ const char * const keywords[] = {"type", "buf", NULL};
+
+ struct {
+ Gwn_PrimType type_id;
+ BPyGwn_VertBuf *py_buf;
+ } params;
+
+ if (!PyArg_ParseTupleAndKeywords(
+ args, kwds,
+ "$O&O!:Gwn_Batch.__new__", (char **)keywords,
+ bpygwn_ParsePrimType, &params.type_id,
+ &BPyGwn_VertBuf_Type, &params.py_buf))
+ {
+ return NULL;
+ }
+
+ Gwn_Batch *batch = GWN_batch_create(params.type_id, params.py_buf->buf, NULL);
+ BPyGwn_Batch *ret = (BPyGwn_Batch *)BPyGwn_Batch_CreatePyObject(batch);
+
+#ifdef USE_GWN_PY_REFERENCES
+ ret->references = PyList_New(1);
+ PyList_SET_ITEM(ret->references, 0, (PyObject *)params.py_buf);
+ Py_INCREF(params.py_buf);
+ PyObject_GC_Track(ret);
+#endif
+
+ return (PyObject *)ret;
+}
+
+PyDoc_STRVAR(bpygwn_VertBatch_vertbuf_add_doc,
+"TODO"
+);
+static PyObject *bpygwn_VertBatch_vertbuf_add(BPyGwn_Batch *self, BPyGwn_VertBuf *py_buf)
+{
+ if (!BPyGwn_VertBuf_Check(py_buf)) {
+ PyErr_Format(PyExc_TypeError,
+ "Expected a Gwn_VertBuf, got %s",
+ Py_TYPE(py_buf)->tp_name);
+ return NULL;
+ }
+
+ if (self->batch->verts[0]->vertex_ct != py_buf->buf->vertex_ct) {
+ PyErr_Format(PyExc_TypeError,
+ "Expected %d length, got %d",
+ self->batch->verts[0]->vertex_ct, py_buf->buf->vertex_ct);
+ return NULL;
+ }
+
+#ifdef USE_GWN_PY_REFERENCES
+ /* Hold user */
+ PyList_Append(self->references, (PyObject *)py_buf);
+#endif
+
+ GWN_batch_vertbuf_add(self->batch, py_buf->buf);
+ Py_RETURN_NONE;
+}
+
+/* Currently magic number from Py perspective. */
+PyDoc_STRVAR(bpygwn_VertBatch_program_set_builtin_doc,
+"TODO"
+);
+static PyObject *bpygwn_VertBatch_program_set_builtin(BPyGwn_Batch *self, PyObject *args, PyObject *kwds)
+{
+ static const char *kwlist[] = {"id", NULL};
+
+ struct {
+ const char *shader;
+ } params;
+
+ if (!PyArg_ParseTupleAndKeywords(
+ args, kwds, "s:program_set_builtin", (char **)kwlist,
+ &params.shader))
+ {
+ return NULL;
+ }
+
+ GPUBuiltinShader shader;
+
+#define MATCH_ID(id) \
+ if (STREQ(params.shader, STRINGIFY(id))) { \
+ shader = GPU_SHADER_##id; \
+ goto success; \
+ } ((void)0)
+
+ MATCH_ID(2D_FLAT_COLOR);
+ MATCH_ID(2D_SMOOTH_COLOR);
+ MATCH_ID(2D_UNIFORM_COLOR);
+
+ MATCH_ID(3D_FLAT_COLOR);
+ MATCH_ID(3D_SMOOTH_COLOR);
+ MATCH_ID(3D_UNIFORM_COLOR);
+
+#undef MATCH_ID
+
+ PyErr_SetString(PyExc_ValueError,
+ "shader name not known");
+ return NULL;
+
+success:
+ GWN_batch_program_set_builtin(self->batch, shader);
+ Py_RETURN_NONE;
+}
+
+static PyObject *bpygwn_VertBatch_uniform_bool(BPyGwn_Batch *self, PyObject *args)
+{
+ struct {
+ const char *id;
+ bool values[1];
+ } params;
+
+ if (!PyArg_ParseTuple(
+ args, "sO&:uniform_bool",
+ &params.id,
+ PyC_ParseBool, &params.values[0]))
+ {
+ return NULL;
+ }
+
+ GWN_batch_uniform_1b(self->batch, params.id, params.values[0]);
+ Py_RETURN_NONE;
+}
+
+static PyObject *bpygwn_VertBatch_uniform_i32(BPyGwn_Batch *self, PyObject *args)
+{
+ struct {
+ const char *id;
+ int values[1];
+ } params;
+
+ if (!PyArg_ParseTuple(
+ args, "si:uniform_i32",
+ &params.id,
+ &params.values[0]))
+ {
+ return NULL;
+ }
+
+ GWN_batch_uniform_1i(self->batch, params.id, params.values[0]);
+ Py_RETURN_NONE;
+}
+
+static PyObject *bpygwn_VertBatch_uniform_f32(BPyGwn_Batch *self, PyObject *args)
+{
+ static struct {
+ const char *id;
+ float values[4];
+ } params;
+
+ if (!PyArg_ParseTuple(
+ args, "sf|fff:uniform_f32",
+ &params.id,
+ &params.values[0], &params.values[1], &params.values[2], &params.values[3]))
+ {
+ return NULL;
+ }
+
+ switch (PyTuple_GET_SIZE(args)) {
+ case 2: GWN_batch_uniform_1f(self->batch, params.id, params.values[0]); break;
+ case 3: GWN_batch_uniform_2fv(self->batch, params.id, params.values); break;
+ case 4: GWN_batch_uniform_3fv(self->batch, params.id, params.values); break;
+ case 5: GWN_batch_uniform_4fv(self->batch, params.id, params.values); break;
+ default:
+ BLI_assert(0);
+ }
+ Py_RETURN_NONE;
+}
+
+PyDoc_STRVAR(bpygwn_VertBatch_draw_doc,
+"TODO"
+);
+static PyObject *bpygwn_VertBatch_draw(BPyGwn_Batch *self)
+{
+ if (!glIsProgram(self->batch->program)) {
+ PyErr_SetString(PyExc_ValueError,
+ "batch program has not not set");
+ }
+ GWN_batch_draw(self->batch);
+ Py_RETURN_NONE;
+}
+
+static struct PyMethodDef bpygwn_VertBatch_methods[] = {
+ {"vertbuf_add", (PyCFunction)bpygwn_VertBatch_vertbuf_add,
+ METH_O, bpygwn_VertBatch_vertbuf_add_doc},
+ {"program_set_builtin", (PyCFunction)bpygwn_VertBatch_program_set_builtin,
+ METH_VARARGS | METH_KEYWORDS, bpygwn_VertBatch_program_set_builtin_doc},
+ {"uniform_bool", (PyCFunction)bpygwn_VertBatch_uniform_bool,
+ METH_VARARGS, NULL},
+ {"uniform_i32", (PyCFunction)bpygwn_VertBatch_uniform_i32,
+ METH_VARARGS, NULL},
+ {"uniform_f32", (PyCFunction)bpygwn_VertBatch_uniform_f32,
+ METH_VARARGS, NULL},
+ {"draw", (PyCFunction) bpygwn_VertBatch_draw,
+ METH_NOARGS, bpygwn_VertBatch_draw_doc},
+ {NULL, NULL, 0, NULL}
+};
+
+#ifdef USE_GWN_PY_REFERENCES
+
+static int bpygwn_Batch_traverse(BPyGwn_Batch *self, visitproc visit, void *arg)
+{
+ Py_VISIT(self->references);
+ return 0;
+}
+
+static int bpygwn_Batch_clear(BPyGwn_Batch *self)
+{
+ Py_CLEAR(self->references);
+ return 0;
+}
+
+#endif
+
+static void bpygwn_Batch_dealloc(BPyGwn_Batch *self)
+{
+ GWN_batch_discard(self->batch);
+
+#ifdef USE_GWN_PY_REFERENCES
+ if (self->references) {
+ PyObject_GC_UnTrack(self);
+ bpygwn_Batch_clear(self);
+ Py_XDECREF(self->references);
+ }
+#endif
+
+ Py_TYPE(self)->tp_free(self);
+}
+
+PyTypeObject BPyGwn_Batch_Type = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ .tp_name = "Gwn_Batch",
+ .tp_basicsize = sizeof(BPyGwn_Batch),
+ .tp_dealloc = (destructor)bpygwn_Batch_dealloc,
+#ifdef USE_GWN_PY_REFERENCES
+ .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
+ .tp_traverse = (traverseproc)bpygwn_Batch_traverse,
+ .tp_clear = (inquiry)bpygwn_Batch_clear,
+#else
+ .tp_flags = Py_TPFLAGS_DEFAULT,
+#endif
+ .tp_methods = bpygwn_VertBatch_methods,
+ .tp_new = bpygwn_Batch_new,
+};
+
+/* -------------------------------------------------------------------- */
+
+
+/** \name Gawain Types Module
+ * \{ */
+
+static struct PyModuleDef BPy_BM_types_module_def = {
+ PyModuleDef_HEAD_INIT,
+ .m_name = "_gawain.types",
+};
+
+PyObject *BPyInit_gawain_types(void)
+{
+ PyObject *submodule;
+
+ submodule = PyModule_Create(&BPy_BM_types_module_def);
+
+ if (PyType_Ready(&BPyGwn_VertFormat_Type) < 0)
+ return NULL;
+ if (PyType_Ready(&BPyGwn_VertBuf_Type) < 0)
+ return NULL;
+ if (PyType_Ready(&BPyGwn_Batch_Type) < 0)
+ return NULL;
+
+#define MODULE_TYPE_ADD(s, t) \
+ PyModule_AddObject(s, t.tp_name, (PyObject *)&t); Py_INCREF((PyObject *)&t)
+
+ MODULE_TYPE_ADD(submodule, BPyGwn_VertFormat_Type);
+ MODULE_TYPE_ADD(submodule, BPyGwn_VertBuf_Type);
+ MODULE_TYPE_ADD(submodule, BPyGwn_Batch_Type);
+
+#undef MODULE_TYPE_ADD
+
+ return submodule;
+}
+
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+
+/** \name Public API
+ * \{ */
+
+PyObject *BPyGwn_VertFormat_CreatePyObject(Gwn_VertFormat *fmt)
+{
+ BPyGwn_VertFormat *self;
+
+ self = PyObject_New(BPyGwn_VertFormat, &BPyGwn_VertFormat_Type);
+ if (fmt) {
+ self->fmt = *fmt;
+ }
+ else {
+ memset(&self->fmt, 0, sizeof(self->fmt));
+ }
+
+ return (PyObject *)self;
+}
+
+PyObject *BPyGwn_VertBuf_CreatePyObject(Gwn_VertBuf *buf)
+{
+ BPyGwn_VertBuf *self;
+
+ self = PyObject_New(BPyGwn_VertBuf, &BPyGwn_VertBuf_Type);
+ self->buf = buf;
+
+ return (PyObject *)self;
+}
+
+
+PyObject *BPyGwn_Batch_CreatePyObject(Gwn_Batch *batch)
+{
+ BPyGwn_Batch *self;
+
+#ifdef USE_GWN_PY_REFERENCES
+ self = (BPyGwn_Batch *)_PyObject_GC_New(&BPyGwn_Batch_Type);
+ self->references = NULL;
+#else
+ self = PyObject_New(BPyGwn_Batch, &BPyGwn_Batch_Type);
+#endif
+
+ self->batch = batch;
+
+ return (PyObject *)self;
+}
+
+/** \} */
diff --git a/source/blender/python/gawain/gwn_py_types.h b/source/blender/python/gawain/gwn_py_types.h
new file mode 100644
index 00000000000..dde6cf98827
--- /dev/null
+++ b/source/blender/python/gawain/gwn_py_types.h
@@ -0,0 +1,67 @@
+/*
+ * ***** 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/python/gawain/gwn_py_types.h
+ * \ingroup pygawain
+ */
+
+#ifndef __GWN_PY_TYPES_H__
+#define __GWN_PY_TYPES_H__
+
+#include "BLI_compiler_attrs.h"
+
+#define USE_GWN_PY_REFERENCES
+
+extern PyTypeObject BPyGwn_VertFormat_Type;
+extern PyTypeObject BPyGwn_VertBuf_Type;
+extern PyTypeObject BPyGwn_Batch_Type;
+
+#define BPyGwn_VertFormat_Check(v) (Py_TYPE(v) == &BPyGwn_VertFormat_Type)
+#define BPyGwn_VertBuf_Check(v) (Py_TYPE(v) == &BPyGwn_VertBuf_Type)
+#define BPyGwn_Batch_Check(v) (Py_TYPE(v) == &BPyGwn_Batch_Type)
+
+typedef struct BPyGwn_VertFormat {
+ PyObject_VAR_HEAD
+ struct Gwn_VertFormat fmt;
+} BPyGwn_VertFormat;
+
+typedef struct BPyGwn_VertBuf {
+ PyObject_VAR_HEAD
+ /* The buf is owned, we may support thin wrapped batches later. */
+ struct Gwn_VertBuf *buf;
+} BPyGwn_VertBuf;
+
+typedef struct BPyGwn_Batch {
+ PyObject_VAR_HEAD
+ /* The batch is owned, we may support thin wrapped batches later. */
+ struct Gwn_Batch *batch;
+#ifdef USE_GWN_PY_REFERENCES
+ /* Just to keep a user to prevent freeing buf's we're using */
+ PyObject *references;
+#endif
+} BPyGwn_Batch;
+
+PyObject *BPyInit_gawain_types(void);
+
+PyObject *BPyGwn_VertFormat_CreatePyObject(struct Gwn_VertFormat *fmt);
+PyObject *BPyGwn_VertBuf_CreatePyObject(struct Gwn_VertBuf *vbo) ATTR_NONNULL(1);
+PyObject *BPyGwn_Batch_CreatePyObject(struct Gwn_Batch *batch) ATTR_NONNULL(1);
+
+#endif /* __GWN_PY_TYPES_H__ */
diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c
index ed4726e2ab7..5c938ef2ee3 100644
--- a/source/blender/python/generic/bgl.c
+++ b/source/blender/python/generic/bgl.c
@@ -476,6 +476,49 @@ int BGL_typeSize(int type)
return -1;
}
+static int gl_buffer_type_from_py_format_char(char *typestr)
+{
+ if (ELEM(typestr[0], '<', '>', '|')) {
+ typestr += 1;
+ }
+ char format = typestr[0];
+ char byte_num = typestr[1];
+
+ switch (format) {
+ case 't':
+ case 'b':
+ case 'h':
+ if (!byte_num) return GL_BYTE;
+ ATTR_FALLTHROUGH;
+ case 'i':
+ if (!byte_num) return GL_SHORT;
+ ATTR_FALLTHROUGH;
+ case 'l':
+ if (!byte_num || byte_num == '4') return GL_INT;
+ if (byte_num == '1') return GL_BYTE;
+ if (byte_num == '2') return GL_SHORT;
+ break;
+ case 'f':
+ if (!byte_num) return GL_FLOAT;
+ ATTR_FALLTHROUGH;
+ case 'd':
+ if (!byte_num || byte_num == '8') return GL_DOUBLE;
+ if (byte_num == '4') return GL_FLOAT;
+ break;
+ }
+ return -1; /* UNKNOWN */
+}
+
+static bool compare_dimensions(int ndim, int *dim1, Py_ssize_t *dim2)
+{
+ for (int i = 0; i < ndim; i++) {
+ if (dim1[i] != dim2[i]) {
+ return false;
+ }
+ }
+ return true;
+}
+
/** \} */
@@ -634,6 +677,22 @@ PyTypeObject BGL_bufferType = {
NULL /*tp_del*/
};
+
+static Buffer *BGL_MakeBuffer_FromData(PyObject *parent, int type, int ndimensions, int *dimensions, void *buf)
+{
+ Buffer *buffer = (Buffer *)PyObject_NEW(Buffer, &BGL_bufferType);
+
+ Py_XINCREF(parent);
+ buffer->parent = parent;
+ buffer->ndimensions = ndimensions;
+ buffer->dimensions = MEM_mallocN(ndimensions * sizeof(int), "Buffer dimensions");
+ memcpy(buffer->dimensions, dimensions, ndimensions * sizeof(int));
+ buffer->type = type;
+ buffer->buf.asvoid = buf;
+
+ return buffer;
+}
+
/**
* Create a buffer object
*
@@ -645,30 +704,21 @@ Buffer *BGL_MakeBuffer(int type, int ndimensions, int *dimensions, void *initbuf
{
Buffer *buffer;
void *buf = NULL;
- int i, size, length;
+ int i, size = BGL_typeSize(type);
- length = 1;
for (i = 0; i < ndimensions; i++) {
- length *= dimensions[i];
+ size *= dimensions[i];
}
- size = BGL_typeSize(type);
+ buf = MEM_mallocN(size, "Buffer buffer");
- buf = MEM_mallocN(length * size, "Buffer buffer");
-
- buffer = (Buffer *)PyObject_NEW(Buffer, &BGL_bufferType);
- buffer->parent = NULL;
- buffer->ndimensions = ndimensions;
- buffer->dimensions = MEM_mallocN(ndimensions * sizeof(int), "Buffer dimensions");
- memcpy(buffer->dimensions, dimensions, ndimensions * sizeof(int));
- buffer->type = type;
- buffer->buf.asvoid = buf;
+ buffer = BGL_MakeBuffer_FromData(NULL, type, ndimensions, dimensions, buf);
if (initbuffer) {
- memcpy(buffer->buf.asvoid, initbuffer, length * size);
+ memcpy(buffer->buf.asvoid, initbuffer, size);
}
else {
- memset(buffer->buf.asvoid, 0, length * size);
+ memset(buffer->buf.asvoid, 0, size);
}
return buffer;
}
@@ -678,7 +728,7 @@ Buffer *BGL_MakeBuffer(int type, int ndimensions, int *dimensions, void *initbuf
static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
{
PyObject *length_ob = NULL, *init = NULL;
- Buffer *buffer;
+ Buffer *buffer = NULL;
int dimensions[MAX_DIMENSIONS];
int type;
@@ -743,9 +793,32 @@ static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject
return NULL;
}
- buffer = BGL_MakeBuffer(type, ndimensions, dimensions, NULL);
- if (init && ndimensions) {
- if (Buffer_ass_slice(buffer, 0, dimensions[0], init)) {
+ if (init && PyObject_CheckBuffer(init)) {
+ Py_buffer pybuffer;
+
+ if (PyObject_GetBuffer(init, &pybuffer, PyBUF_ND | PyBUF_FORMAT) == -1) {
+ /* PyObject_GetBuffer raise a PyExc_BufferError */
+ return NULL;
+ }
+
+ if (type != gl_buffer_type_from_py_format_char(pybuffer.format)) {
+ PyErr_Format(PyExc_TypeError,
+ "`GL_TYPE` and `typestr` of object with buffer interface do not match. '%s'", pybuffer.format);
+ }
+ else if (ndimensions != pybuffer.ndim ||
+ !compare_dimensions(ndimensions, dimensions, pybuffer.shape))
+ {
+ PyErr_Format(PyExc_TypeError, "array size does not match");
+ }
+ else {
+ buffer = BGL_MakeBuffer_FromData(init, type, pybuffer.ndim, dimensions, pybuffer.buf);
+ }
+
+ PyBuffer_Release(&pybuffer);
+ }
+ else {
+ buffer = BGL_MakeBuffer(type, ndimensions, dimensions, NULL);
+ if (init && Buffer_ass_slice(buffer, 0, dimensions[0], init)) {
Py_DECREF(buffer);
return NULL;
}
@@ -778,27 +851,17 @@ static PyObject *Buffer_item(Buffer *self, int i)
}
}
else {
- Buffer *newbuf;
- int j, length, size;
+ int j, offset = i * BGL_typeSize(self->type);
- length = 1;
for (j = 1; j < self->ndimensions; j++) {
- length *= self->dimensions[j];
+ offset *= self->dimensions[j];
}
- size = BGL_typeSize(self->type);
-
- newbuf = (Buffer *)PyObject_NEW(Buffer, &BGL_bufferType);
-
- Py_INCREF(self);
- newbuf->parent = (PyObject *)self;
-
- newbuf->ndimensions = self->ndimensions - 1;
- newbuf->type = self->type;
- newbuf->buf.asvoid = self->buf.asbyte + i * length * size;
- newbuf->dimensions = MEM_mallocN(newbuf->ndimensions * sizeof(int), "Buffer dimensions");
- memcpy(newbuf->dimensions, self->dimensions + 1, newbuf->ndimensions * sizeof(int));
- return (PyObject *)newbuf;
+ return (PyObject *)BGL_MakeBuffer_FromData(
+ (PyObject *)self, self->type,
+ self->ndimensions - 1,
+ self->dimensions + 1,
+ self->buf.asbyte + offset);
}
return NULL;
diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c
index ed2752d8372..ffac09efdde 100644
--- a/source/blender/python/generic/bpy_internal_import.c
+++ b/source/blender/python/generic/bpy_internal_import.c
@@ -248,8 +248,17 @@ PyObject *bpy_text_reimport(PyObject *module, int *found)
if ((name = PyModule_GetName(module)) == NULL)
return NULL;
- if ((filepath = (char *)PyModule_GetFilename(module)) == NULL)
- return NULL;
+ {
+ PyObject *module_file = PyModule_GetFilenameObject(module);
+ if (module_file == NULL) {
+ return NULL;
+ }
+ filepath = _PyUnicode_AsString(module_file);
+ Py_DECREF(module_file);
+ if (filepath == NULL) {
+ return NULL;
+ }
+ }
/* look up the text object */
text = BLI_findstring(&maggie->text, BLI_path_basename(filepath), offsetof(ID, name) + 2);
@@ -276,13 +285,13 @@ static PyObject *blender_import(PyObject *UNUSED(self), PyObject *args, PyObject
int found = 0;
PyObject *globals = NULL, *locals = NULL, *fromlist = NULL;
int level = 0; /* relative imports */
-
PyObject *newmodule;
- //PyObject_Print(args, stderr, 0);
- static const char *kwlist[] = {"name", "globals", "locals", "fromlist", "level", NULL};
-
- if (!PyArg_ParseTupleAndKeywords(args, kw, "s|OOOi:bpy_import_meth", (char **)kwlist,
- &name, &globals, &locals, &fromlist, &level))
+
+ static const char *_keywords[] = {"name", "globals", "locals", "fromlist", "level", NULL};
+ static _PyArg_Parser _parser = {"s|OOOi:bpy_import_meth", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(
+ args, kw, &_parser,
+ &name, &globals, &locals, &fromlist, &level))
{
return NULL;
}
diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c
index 5d6a7c578a2..1153e0176df 100644
--- a/source/blender/python/generic/idprop_py_api.c
+++ b/source/blender/python/generic/idprop_py_api.c
@@ -386,7 +386,7 @@ static IDProperty *idp_from_PyFloat(const char *name, PyObject *ob)
static IDProperty *idp_from_PyLong(const char *name, PyObject *ob)
{
IDPropertyTemplate val = {0};
- val.i = _PyLong_AsInt(ob);
+ val.i = PyC_Long_AsI32(ob);
if (val.i == -1 && PyErr_Occurred()) {
return NULL;
}
@@ -499,7 +499,7 @@ static IDProperty *idp_from_PySequence_Fast(const char *name, PyObject *ob)
prop_data = IDP_Array(prop);
for (i = 0; i < val.array.len; i++) {
item = ob_seq_fast_items[i];
- if (((prop_data[i] = _PyLong_AsInt(item)) == -1) && PyErr_Occurred()) {
+ if (((prop_data[i] = PyC_Long_AsI32(item)) == -1) && PyErr_Occurred()) {
return NULL;
}
}
@@ -1337,7 +1337,7 @@ static int BPy_IDArray_SetItem(BPy_IDArray *self, int index, PyObject *value)
}
case IDP_INT:
{
- const int i = _PyLong_AsInt(value);
+ const int i = PyC_Long_AsI32(value);
if (i == -1 && PyErr_Occurred()) {
return -1;
}
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c
index 2e789d6d4b3..d49f9514b8c 100644
--- a/source/blender/python/generic/py_capi_utils.c
+++ b/source/blender/python/generic/py_capi_utils.c
@@ -85,7 +85,7 @@ int PyC_AsArray_FAST(
/* could use is_double for 'long int' but no use now */
int *array_int = array;
for (i = 0; i < length; i++) {
- array_int[i] = PyLong_AsLong(value_fast_items[i]);
+ array_int[i] = PyC_Long_AsI32(value_fast_items[i]);
}
}
else if (type == &PyBool_Type) {
@@ -127,54 +127,52 @@ int PyC_AsArray(
return ret;
}
+/* -------------------------------------------------------------------- */
+/** \name Typed Tuple Packing
+ *
+ * \note See #PyC_Tuple_Pack_* macros that take multiple arguments.
+ *
+ * \{ */
+
/* array utility function */
-PyObject *PyC_FromArray(const void *array, int length, const PyTypeObject *type,
- const bool is_double, const char *error_prefix)
+PyObject *PyC_Tuple_PackArray_F32(const float *array, uint len)
{
- PyObject *tuple;
- int i;
-
- tuple = PyTuple_New(length);
-
- /* for each type */
- if (type == &PyFloat_Type) {
- if (is_double) {
- const double *array_double = array;
- for (i = 0; i < length; ++i) {
- PyTuple_SET_ITEM(tuple, i, PyFloat_FromDouble(array_double[i]));
- }
- }
- else {
- const float *array_float = array;
- for (i = 0; i < length; ++i) {
- PyTuple_SET_ITEM(tuple, i, PyFloat_FromDouble(array_float[i]));
- }
- }
- }
- else if (type == &PyLong_Type) {
- /* could use is_double for 'long int' but no use now */
- const int *array_int = array;
- for (i = 0; i < length; ++i) {
- PyTuple_SET_ITEM(tuple, i, PyLong_FromLong(array_int[i]));
- }
+ PyObject *tuple = PyTuple_New(len);
+ for (uint i = 0; i < len; i++) {
+ PyTuple_SET_ITEM(tuple, i, PyFloat_FromDouble(array[i]));
}
- else if (type == &PyBool_Type) {
- const int *array_bool = array;
- for (i = 0; i < length; ++i) {
- PyTuple_SET_ITEM(tuple, i, PyBool_FromLong(array_bool[i]));
- }
+ return tuple;
+}
+
+PyObject *PyC_Tuple_PackArray_I32(const int *array, uint len)
+{
+ PyObject *tuple = PyTuple_New(len);
+ for (uint i = 0; i < len; i++) {
+ PyTuple_SET_ITEM(tuple, i, PyLong_FromLong(array[i]));
}
- else {
- Py_DECREF(tuple);
- PyErr_Format(PyExc_TypeError,
- "%s: internal error %s is invalid",
- error_prefix, type->tp_name);
- return NULL;
+ return tuple;
+}
+
+PyObject *PyC_Tuple_PackArray_I32FromBool(const int *array, uint len)
+{
+ PyObject *tuple = PyTuple_New(len);
+ for (uint i = 0; i < len; i++) {
+ PyTuple_SET_ITEM(tuple, i, PyBool_FromLong(array[i]));
}
+ return tuple;
+}
+PyObject *PyC_Tuple_PackArray_Bool(const bool *array, uint len)
+{
+ PyObject *tuple = PyTuple_New(len);
+ for (uint i = 0; i < len; i++) {
+ PyTuple_SET_ITEM(tuple, i, PyBool_FromLong(array[i]));
+ }
return tuple;
}
+/** \} */
+
/**
* Caller needs to ensure tuple is uninitialized.
* Handy for filling a tuple with None for eg.
@@ -203,6 +201,8 @@ void PyC_List_Fill(PyObject *list, PyObject *value)
/**
* Use with PyArg_ParseTuple's "O&" formatting.
+ *
+ * \see #PyC_Long_AsBool for a similar function to use outside of argument parsing.
*/
int PyC_ParseBool(PyObject *o, void *p)
{
@@ -300,7 +300,14 @@ void PyC_FileAndNum(const char **filename, int *lineno)
if (mod_name) {
PyObject *mod = PyDict_GetItem(PyImport_GetModuleDict(), mod_name);
if (mod) {
- *filename = PyModule_GetFilename(mod);
+ PyObject *mod_file = PyModule_GetFilenameObject(mod);
+ if (mod_file) {
+ *filename = _PyUnicode_AsString(mod_name);
+ Py_DECREF(mod_file);
+ }
+ else {
+ PyErr_Clear();
+ }
}
/* unlikely, fallback */
@@ -1108,3 +1115,101 @@ bool PyC_RunString_AsString(const char *expr, const char *filename, char **r_val
}
#endif /* #ifndef MATH_STANDALONE */
+
+/* -------------------------------------------------------------------- */
+
+/** \name Int Conversion
+ *
+ * \note Python doesn't provide overflow checks for specific bit-widths.
+ *
+ * \{ */
+
+/* Compiler optimizes out redundant checks. */
+#ifdef __GNUC__
+# pragma warning(push)
+# pragma GCC diagnostic ignored "-Wtype-limits"
+#endif
+
+/**
+ * Don't use `bool` return type, so -1 can be used as an error value.
+ */
+int PyC_Long_AsBool(PyObject *value)
+{
+ int test = _PyLong_AsInt(value);
+ if (UNLIKELY((uint)test > 1)) {
+ PyErr_SetString(PyExc_TypeError,
+ "Python number not a bool (0/1)");
+ return -1;
+ }
+ return test;
+}
+
+int8_t PyC_Long_AsI8(PyObject *value)
+{
+ int test = _PyLong_AsInt(value);
+ if (UNLIKELY(test < INT8_MIN || test > INT8_MAX)) {
+ PyErr_SetString(PyExc_OverflowError,
+ "Python int too large to convert to C int8");
+ return -1;
+ }
+ return (int8_t)test;
+}
+
+int16_t PyC_Long_AsI16(PyObject *value)
+{
+ int test = _PyLong_AsInt(value);
+ if (UNLIKELY(test < INT16_MIN || test > INT16_MAX)) {
+ PyErr_SetString(PyExc_OverflowError,
+ "Python int too large to convert to C int16");
+ return -1;
+ }
+ return (int16_t)test;
+}
+
+/* Inlined in header:
+ * PyC_Long_AsI32
+ * PyC_Long_AsI64
+ */
+
+uint8_t PyC_Long_AsU8(PyObject *value)
+{
+ ulong test = PyLong_AsUnsignedLong(value);
+ if (UNLIKELY(test > UINT8_MAX)) {
+ PyErr_SetString(PyExc_OverflowError,
+ "Python int too large to convert to C uint8");
+ return (uint8_t)-1;
+ }
+ return (uint8_t)test;
+}
+
+uint16_t PyC_Long_AsU16(PyObject *value)
+{
+ ulong test = PyLong_AsUnsignedLong(value);
+ if (UNLIKELY(test > UINT16_MAX)) {
+ PyErr_SetString(PyExc_OverflowError,
+ "Python int too large to convert to C uint16");
+ return (uint16_t)-1;
+ }
+ return (uint16_t)test;
+}
+
+uint32_t PyC_Long_AsU32(PyObject *value)
+{
+ ulong test = PyLong_AsUnsignedLong(value);
+ if (UNLIKELY(test > UINT32_MAX)) {
+ PyErr_SetString(PyExc_OverflowError,
+ "Python int too large to convert to C uint32");
+ return (uint32_t)-1;
+ }
+ return (uint32_t)test;
+}
+
+/* Inlined in header:
+ * PyC_Long_AsU64
+ */
+
+#ifdef __GNUC__
+# pragma warning(pop)
+#endif
+
+/** \} */
diff --git a/source/blender/python/generic/py_capi_utils.h b/source/blender/python/generic/py_capi_utils.h
index 3f89e1d82a0..327d4e60954 100644
--- a/source/blender/python/generic/py_capi_utils.h
+++ b/source/blender/python/generic/py_capi_utils.h
@@ -24,10 +24,12 @@
* \ingroup pygen
*/
-
#ifndef __PY_CAPI_UTILS_H__
#define __PY_CAPI_UTILS_H__
+#include "BLI_sys_types.h"
+#include "BLI_utildefines_variadic.h"
+
void PyC_ObSpit(const char *name, PyObject *var);
void PyC_LineSpit(void);
void PyC_StackSpit(void);
@@ -44,8 +46,21 @@ int PyC_AsArray_FAST(
int PyC_AsArray(
void *array, PyObject *value, const Py_ssize_t length,
const PyTypeObject *type, const bool is_double, const char *error_prefix);
-PyObject * PyC_FromArray(const void *array, int length, const PyTypeObject *type,
- const bool is_double, const char *error_prefix);
+
+PyObject *PyC_Tuple_PackArray_F32(const float *array, uint len);
+PyObject *PyC_Tuple_PackArray_I32(const int *array, uint len);
+PyObject *PyC_Tuple_PackArray_I32FromBool(const int *array, uint len);
+PyObject *PyC_Tuple_PackArray_Bool(const bool *array, uint len);
+
+#define PyC_Tuple_Pack_F32(...) \
+ PyC_Tuple_PackArray_F32(((const float []){__VA_ARGS__}), VA_NARGS_COUNT(__VA_ARGS__))
+#define PyC_Tuple_Pack_I32(...) \
+ PyC_Tuple_PackArray_I32(((const int []){__VA_ARGS__}), VA_NARGS_COUNT(__VA_ARGS__))
+#define PyC_Tuple_Pack_I32FromBool(...) \
+ PyC_Tuple_PackArray_I32FromBool(((const int []){__VA_ARGS__}), VA_NARGS_COUNT(__VA_ARGS__))
+#define PyC_Tuple_Pack_Bool(...) \
+ PyC_Tuple_PackArray_Bool(((const bool []){__VA_ARGS__}), VA_NARGS_COUNT(__VA_ARGS__))
+
void PyC_Tuple_Fill(PyObject *tuple, PyObject *value);
void PyC_List_Fill(PyObject *list, PyObject *value);
@@ -85,4 +100,26 @@ bool PyC_RunString_AsString(const char *expr, const char *filename, char **r_val
int PyC_ParseBool(PyObject *o, void *p);
+
+/* Integer parsing (with overflow checks), -1 on error. */
+int PyC_Long_AsBool(PyObject *value);
+int8_t PyC_Long_AsI8(PyObject *value);
+int16_t PyC_Long_AsI16(PyObject *value);
+#if 0 /* inline */
+int32_t PyC_Long_AsI32(PyObject *value);
+int64_t PyC_Long_AsI64(PyObject *value);
+#endif
+
+uint8_t PyC_Long_AsU8(PyObject *value);
+uint16_t PyC_Long_AsU16(PyObject *value);
+uint32_t PyC_Long_AsU32(PyObject *value);
+#if 0 /* inline */
+uint64_t PyC_Long_AsU64(PyObject *value);
+#endif
+
+/* inline so type signatures match as expected */
+Py_LOCAL_INLINE(int32_t) PyC_Long_AsI32(PyObject *value) { return (int32_t)_PyLong_AsInt(value); }
+Py_LOCAL_INLINE(int64_t) PyC_Long_AsI64(PyObject *value) { return (int64_t)PyLong_AsLongLong(value); }
+Py_LOCAL_INLINE(uint64_t) PyC_Long_AsU64(PyObject *value) { return (uint64_t)PyLong_AsUnsignedLongLong(value); }
+
#endif /* __PY_CAPI_UTILS_H__ */
diff --git a/source/blender/python/generic/python_utildefines.h b/source/blender/python/generic/python_utildefines.h
index f7d3e7a8b4a..2d2d19c05f5 100644
--- a/source/blender/python/generic/python_utildefines.h
+++ b/source/blender/python/generic/python_utildefines.h
@@ -36,16 +36,16 @@ extern "C" {
PyTupleObject *op = (PyTupleObject *)op_arg; \
PyObject **ob_items = op->ob_item; \
CHECK_TYPE_ANY(op_arg, PyObject *, PyTupleObject *); \
- BLI_assert(_VA_NARGS_COUNT(__VA_ARGS__) == PyTuple_GET_SIZE(op)); \
+ BLI_assert(VA_NARGS_COUNT(__VA_ARGS__) == PyTuple_GET_SIZE(op)); \
ARRAY_SET_ITEMS(ob_items, __VA_ARGS__); \
} (void)0
/* wrap Py_INCREF & return the result,
* use sparingly to avoid comma operator or temp var assignment */
-BLI_INLINE PyObject *Py_INCREF_RET(PyObject *op) { Py_INCREF(op); return op; }
+Py_LOCAL_INLINE(PyObject *)Py_INCREF_RET(PyObject *op) { Py_INCREF(op); return op; }
/* append & transfer ownership to the list, avoids inline Py_DECREF all over (which is quite a large macro) */
-BLI_INLINE int PyList_APPEND(PyObject *op, PyObject *v)
+Py_LOCAL_INLINE(int) PyList_APPEND(PyObject *op, PyObject *v)
{
int ret = PyList_Append(op, v);
Py_DecRef(v);
diff --git a/source/blender/python/intern/CMakeLists.txt b/source/blender/python/intern/CMakeLists.txt
index 967e90d22cb..26fbc5d9eb2 100644
--- a/source/blender/python/intern/CMakeLists.txt
+++ b/source/blender/python/intern/CMakeLists.txt
@@ -47,6 +47,8 @@ set(INC_SYS
set(SRC
gpu.c
gpu_offscreen.c
+ gpu_py_matrix.c
+ gpu_py_select.c
bpy.c
bpy_app.c
bpy_app_alembic.c
@@ -151,10 +153,6 @@ if(WITH_CODEC_FFMPEG)
add_definitions(-DWITH_FFMPEG)
endif()
-if(WITH_CODEC_QUICKTIME)
- add_definitions(-DWITH_QUICKTIME)
-endif()
-
if(WITH_CODEC_SNDFILE)
add_definitions(-DWITH_SNDFILE)
endif()
diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c
index 4a29d4f8da1..c576786a54c 100644
--- a/source/blender/python/intern/bpy.c
+++ b/source/blender/python/intern/bpy.c
@@ -119,10 +119,11 @@ static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObjec
bool absolute = false;
bool packed = false;
bool local = false;
- static const char *kwlist[] = {"absolute", "packed", "local", NULL};
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "|O&O&O&:blend_paths", (char **)kwlist,
+ static const char *_keywords[] = {"absolute", "packed", "local", NULL};
+ static _PyArg_Parser _parser = {"|O&O&O&:blend_paths", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(
+ args, kw, &_parser,
PyC_ParseBool, &absolute,
PyC_ParseBool, &packed,
PyC_ParseBool, &local))
@@ -148,13 +149,18 @@ static PyObject *bpy_user_resource(PyObject *UNUSED(self), PyObject *args, PyObj
const char *type;
const char *subdir = NULL;
int folder_id;
- static const char *kwlist[] = {"type", "subdir", NULL};
const char *path;
- if (!PyArg_ParseTupleAndKeywords(args, kw, "s|s:user_resource", (char **)kwlist, &type, &subdir))
+ static const char *_keywords[] = {"type", "subdir", NULL};
+ static _PyArg_Parser _parser = {"s|s:user_resource", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(
+ args, kw, &_parser,
+ &type, &subdir))
+ {
return NULL;
-
+ }
+
/* stupid string compare */
if (STREQ(type, "DATAFILES")) folder_id = BLENDER_USER_DATAFILES;
else if (STREQ(type, "CONFIG")) folder_id = BLENDER_USER_CONFIG;
@@ -192,12 +198,17 @@ static PyObject *bpy_resource_path(PyObject *UNUSED(self), PyObject *args, PyObj
{
const char *type;
int major = BLENDER_VERSION / 100, minor = BLENDER_VERSION % 100;
- static const char *kwlist[] = {"type", "major", "minor", NULL};
int folder_id;
const char *path;
- if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ii:resource_path", (char **)kwlist, &type, &major, &minor))
+ static const char *_keywords[] = {"type", "major", "minor", NULL};
+ static _PyArg_Parser _parser = {"s|ii:resource_path", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(
+ args, kw, &_parser,
+ &type, &major, &minor))
+ {
return NULL;
+ }
/* stupid string compare */
if (STREQ(type, "USER")) folder_id = BLENDER_RESOURCE_PATH_USER;
diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c
index 8b3464173d2..f44401afd7d 100644
--- a/source/blender/python/intern/bpy_app.c
+++ b/source/blender/python/intern/bpy_app.c
@@ -89,6 +89,7 @@ static PyStructSequence_Field app_info_fields[] = {
{(char *)"version_cycle", (char *)"The release status of this build alpha/beta/rc/release"},
{(char *)"binary_path", (char *)"The location of blenders executable, useful for utilities that spawn new instances"},
{(char *)"background", (char *)"Boolean, True when blender is running without a user interface (started with -b)"},
+ {(char *)"factory_startup", (char *)"Boolean, True when blender is running with --factory-startup)"},
/* buildinfo */
{(char *)"build_date", (char *)"The date this blender instance was built"},
@@ -156,8 +157,7 @@ static PyObject *make_app_info(void)
#define SetObjItem(obj) \
PyStructSequence_SET_ITEM(app_info, pos++, obj)
- SetObjItem(Py_BuildValue("(iii)",
- BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION));
+ SetObjItem(PyC_Tuple_Pack_I32(BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION));
SetObjItem(PyUnicode_FromFormat("%d.%02d (sub %d)",
BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION));
@@ -165,6 +165,7 @@ static PyObject *make_app_info(void)
SetStrItem(STRINGIFY(BLENDER_VERSION_CYCLE));
SetStrItem(BKE_appdir_program_path());
SetObjItem(PyBool_FromLong(G.background));
+ SetObjItem(PyBool_FromLong(G.factory_startup));
/* build info, use bytes since we can't assume _any_ encoding:
* see patch [#30154] for issue */
@@ -290,7 +291,7 @@ static PyObject *bpy_app_debug_value_get(PyObject *UNUSED(self), void *UNUSED(cl
static int bpy_app_debug_value_set(PyObject *UNUSED(self), PyObject *value, void *UNUSED(closure))
{
- int param = PyLong_AsLong(value);
+ int param = PyC_Long_AsI32(value);
if (param == -1 && PyErr_Occurred()) {
PyErr_SetString(PyExc_TypeError, "bpy.app.debug_value can only be set to a whole number");
diff --git a/source/blender/python/intern/bpy_app_alembic.c b/source/blender/python/intern/bpy_app_alembic.c
index 90e6a02b418..2a1a031a629 100644
--- a/source/blender/python/intern/bpy_app_alembic.c
+++ b/source/blender/python/intern/bpy_app_alembic.c
@@ -34,6 +34,8 @@
#include "bpy_app_alembic.h"
+#include "../generic/py_capi_utils.h"
+
#ifdef WITH_ALEMBIC
# include "ABC_alembic.h"
#endif
@@ -79,11 +81,11 @@ static PyObject *make_alembic_info(void)
const int patch = curversion - ((curversion / 100 ) * 100);
SetObjItem(PyBool_FromLong(1));
- SetObjItem(Py_BuildValue("(iii)", major, minor, patch));
+ SetObjItem(PyC_Tuple_Pack_I32(major, minor, patch));
SetObjItem(PyUnicode_FromFormat("%2d, %2d, %2d", major, minor, patch));
#else
SetObjItem(PyBool_FromLong(0));
- SetObjItem(Py_BuildValue("(iii)", 0, 0, 0));
+ SetObjItem(PyC_Tuple_Pack_I32(0, 0, 0));
SetStrItem("Unknown");
#endif
diff --git a/source/blender/python/intern/bpy_app_build_options.c b/source/blender/python/intern/bpy_app_build_options.c
index a6b98567a9a..501e09dd6ad 100644
--- a/source/blender/python/intern/bpy_app_build_options.c
+++ b/source/blender/python/intern/bpy_app_build_options.c
@@ -37,7 +37,6 @@ static PyStructSequence_Field app_builtopts_info_fields[] = {
{(char *)"bullet", NULL},
{(char *)"codec_avi", NULL},
{(char *)"codec_ffmpeg", NULL},
- {(char *)"codec_quicktime", NULL},
{(char *)"codec_sndfile", NULL},
{(char *)"compositor", NULL},
{(char *)"cycles", NULL},
@@ -112,12 +111,6 @@ static PyObject *make_builtopts_info(void)
SetObjIncref(Py_False);
#endif
-#ifdef WITH_QUICKTIME
- SetObjIncref(Py_True);
-#else
- SetObjIncref(Py_False);
-#endif
-
#ifdef WITH_SNDFILE
SetObjIncref(Py_True);
#else
diff --git a/source/blender/python/intern/bpy_app_ffmpeg.c b/source/blender/python/intern/bpy_app_ffmpeg.c
index fd516e4547f..9f8355db72b 100644
--- a/source/blender/python/intern/bpy_app_ffmpeg.c
+++ b/source/blender/python/intern/bpy_app_ffmpeg.c
@@ -29,6 +29,8 @@
#include "bpy_app_ffmpeg.h"
+#include "../generic/py_capi_utils.h"
+
#ifdef WITH_FFMPEG
#include <libavcodec/avcodec.h>
#include <libavdevice/avdevice.h>
@@ -91,8 +93,7 @@ static PyObject *make_ffmpeg_info(void)
#ifdef WITH_FFMPEG
# define FFMPEG_LIB_VERSION(lib) { \
curversion = lib ## _version(); \
- SetObjItem(Py_BuildValue("(iii)", \
- curversion >> 16, (curversion >> 8) % 256, curversion % 256)); \
+ SetObjItem(PyC_Tuple_Pack_I32(curversion >> 16, (curversion >> 8) % 256, curversion % 256)); \
SetObjItem(PyUnicode_FromFormat("%2d, %2d, %2d", \
curversion >> 16, (curversion >> 8) % 256, curversion % 256)); \
} (void)0
diff --git a/source/blender/python/intern/bpy_app_ocio.c b/source/blender/python/intern/bpy_app_ocio.c
index 02e4044219a..9997e6b87f1 100644
--- a/source/blender/python/intern/bpy_app_ocio.c
+++ b/source/blender/python/intern/bpy_app_ocio.c
@@ -29,6 +29,8 @@
#include "bpy_app_ocio.h"
+#include "../generic/py_capi_utils.h"
+
#ifdef WITH_OCIO
# include "ocio_capi.h"
#endif
@@ -74,13 +76,12 @@ static PyObject *make_ocio_info(void)
#ifdef WITH_OCIO
curversion = OCIO_getVersionHex();
SetObjItem(PyBool_FromLong(1));
- SetObjItem(Py_BuildValue("(iii)",
- curversion >> 24, (curversion >> 16) % 256, (curversion >> 8) % 256));
+ SetObjItem(PyC_Tuple_Pack_I32(curversion >> 24, (curversion >> 16) % 256, (curversion >> 8) % 256));
SetObjItem(PyUnicode_FromFormat("%2d, %2d, %2d",
curversion >> 24, (curversion >> 16) % 256, (curversion >> 8) % 256));
#else
SetObjItem(PyBool_FromLong(0));
- SetObjItem(Py_BuildValue("(iii)", 0, 0, 0));
+ SetObjItem(PyC_Tuple_Pack_I32(0, 0, 0));
SetStrItem("Unknown");
#endif
diff --git a/source/blender/python/intern/bpy_app_oiio.c b/source/blender/python/intern/bpy_app_oiio.c
index 60daf3ddd8b..e14b48ff7cf 100644
--- a/source/blender/python/intern/bpy_app_oiio.c
+++ b/source/blender/python/intern/bpy_app_oiio.c
@@ -29,6 +29,8 @@
#include "bpy_app_oiio.h"
+#include "../generic/py_capi_utils.h"
+
#ifdef WITH_OPENIMAGEIO
# include "openimageio_api.h"
#endif
@@ -74,13 +76,12 @@ static PyObject *make_oiio_info(void)
#ifdef WITH_OPENIMAGEIO
curversion = OIIO_getVersionHex();
SetObjItem(PyBool_FromLong(1));
- SetObjItem(Py_BuildValue("(iii)",
- curversion / 10000, (curversion / 100) % 100, curversion % 100));
+ SetObjItem(PyC_Tuple_Pack_I32(curversion / 10000, (curversion / 100) % 100, curversion % 100));
SetObjItem(PyUnicode_FromFormat("%2d, %2d, %2d",
curversion / 10000, (curversion / 100) % 100, curversion % 100));
#else
SetObjItem(PyBool_FromLong(0));
- SetObjItem(Py_BuildValue("(iii)", 0, 0, 0));
+ SetObjItem(PyC_Tuple_Pack_I32(0, 0, 0));
SetStrItem("Unknown");
#endif
diff --git a/source/blender/python/intern/bpy_app_opensubdiv.c b/source/blender/python/intern/bpy_app_opensubdiv.c
index 7f269baf2b0..096374794c9 100644
--- a/source/blender/python/intern/bpy_app_opensubdiv.c
+++ b/source/blender/python/intern/bpy_app_opensubdiv.c
@@ -29,6 +29,8 @@
#include "bpy_app_opensubdiv.h"
+#include "../generic/py_capi_utils.h"
+
#ifdef WITH_OPENSUBDIV
# include "opensubdiv_capi.h"
#endif
@@ -70,13 +72,12 @@ static PyObject *make_opensubdiv_info(void)
#ifdef WITH_OPENSUBDIV
int curversion = openSubdiv_getVersionHex();
SetObjItem(PyBool_FromLong(1));
- SetObjItem(Py_BuildValue("(iii)",
- curversion / 10000, (curversion / 100) % 100, curversion % 100));
+ SetObjItem(PyC_Tuple_Pack_I32(curversion / 10000, (curversion / 100) % 100, curversion % 100));
SetObjItem(PyUnicode_FromFormat("%2d, %2d, %2d",
curversion / 10000, (curversion / 100) % 100, curversion % 100));
#else
SetObjItem(PyBool_FromLong(0));
- SetObjItem(Py_BuildValue("(iii)", 0, 0, 0));
+ SetObjItem(PyC_Tuple_Pack_I32(0, 0, 0));
SetStrItem("Unknown");
#endif
diff --git a/source/blender/python/intern/bpy_app_openvdb.c b/source/blender/python/intern/bpy_app_openvdb.c
index 8a24aaf0555..0b385206d7b 100644
--- a/source/blender/python/intern/bpy_app_openvdb.c
+++ b/source/blender/python/intern/bpy_app_openvdb.c
@@ -34,6 +34,8 @@
#include "bpy_app_openvdb.h"
+#include "../generic/py_capi_utils.h"
+
#ifdef WITH_OPENVDB
# include "openvdb_capi.h"
#endif
@@ -79,13 +81,12 @@ static PyObject *make_openvdb_info(void)
#ifdef WITH_OPENVDB
curversion = OpenVDB_getVersionHex();
SetObjItem(PyBool_FromLong(1));
- SetObjItem(Py_BuildValue("(iii)",
- curversion >> 24, (curversion >> 16) % 256, (curversion >> 8) % 256));
+ SetObjItem(PyC_Tuple_Pack_I32(curversion >> 24, (curversion >> 16) % 256, (curversion >> 8) % 256));
SetObjItem(PyUnicode_FromFormat("%2d, %2d, %2d",
curversion >> 24, (curversion >> 16) % 256, (curversion >> 8) % 256));
#else
SetObjItem(PyBool_FromLong(0));
- SetObjItem(Py_BuildValue("(iii)", 0, 0, 0));
+ SetObjItem(PyC_Tuple_Pack_I32(0, 0, 0));
SetStrItem("Unknown");
#endif
diff --git a/source/blender/python/intern/bpy_app_sdl.c b/source/blender/python/intern/bpy_app_sdl.c
index 76dab775953..816ad2833cc 100644
--- a/source/blender/python/intern/bpy_app_sdl.c
+++ b/source/blender/python/intern/bpy_app_sdl.c
@@ -29,6 +29,8 @@
#include "bpy_app_sdl.h"
+#include "../generic/py_capi_utils.h"
+
#ifdef WITH_SDL
/* SDL force defines __SSE__ and __SSE2__ flags, which generates warnings
* because we pass those defines via command line as well. For until there's
@@ -103,7 +105,7 @@ static PyObject *make_sdl_info(void)
# endif
# endif
- SetObjItem(Py_BuildValue("(iii)", version.major, version.minor, version.patch));
+ SetObjItem(PyC_Tuple_Pack_I32(version.major, version.minor, version.patch));
if (sdl_available) {
SetObjItem(PyUnicode_FromFormat("%d.%d.%d", version.major, version.minor, version.patch));
}
@@ -114,7 +116,7 @@ static PyObject *make_sdl_info(void)
#else // WITH_SDL=OFF
SetObjItem(PyBool_FromLong(0));
- SetObjItem(Py_BuildValue("(iii)", 0, 0, 0));
+ SetObjItem(PyC_Tuple_Pack_I32(0, 0, 0));
SetStrItem("Unknown");
SetObjItem(PyBool_FromLong(0));
#endif
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index cd4d2f7a1c2..7ddb41c3b0d 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -72,6 +72,7 @@
#include "../generic/bgl.h"
#include "../generic/blf_py_api.h"
#include "../generic/idprop_py_api.h"
+#include "../gawain/gwn_py_api.h"
#include "../bmesh/bmesh_py_api.h"
#include "../mathutils/mathutils.h"
@@ -212,6 +213,7 @@ static struct _inittab bpy_internal_modules[] = {
{"mathutils.kdtree", PyInit_mathutils_kdtree},
#endif
{"_bpy_path", BPyInit__bpy_path},
+ {"_gawain", BPyInit_gawain},
{"bgl", BPyInit_bgl},
{"blf", BPyInit_blf},
{"bmesh", BPyInit_bmesh},
@@ -870,6 +872,7 @@ static void bpy_module_delay_init(PyObject *bpy_proxy)
BLI_strncpy(filename_abs, filename_rel, sizeof(filename_abs));
BLI_path_cwd(filename_abs, sizeof(filename_abs));
+ Py_DECREF(filename_obj);
argv[0] = filename_abs;
argv[1] = NULL;
diff --git a/source/blender/python/intern/bpy_library_load.c b/source/blender/python/intern/bpy_library_load.c
index 73265d28a93..79081e47e27 100644
--- a/source/blender/python/intern/bpy_library_load.c
+++ b/source/blender/python/intern/bpy_library_load.c
@@ -73,7 +73,7 @@ typedef struct {
} BPy_Library;
static PyObject *bpy_lib_load(PyObject *self, PyObject *args, PyObject *kwds);
-static PyObject *bpy_lib_enter(BPy_Library *self, PyObject *args);
+static PyObject *bpy_lib_enter(BPy_Library *self);
static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *args);
static PyObject *bpy_lib_dir(BPy_Library *self);
@@ -183,17 +183,17 @@ PyDoc_STRVAR(bpy_lib_load_doc,
" :arg relative: When True the path is stored relative to the open blend file.\n"
" :type relative: bool\n"
);
-static PyObject *bpy_lib_load(PyObject *UNUSED(self), PyObject *args, PyObject *kwds)
+static PyObject *bpy_lib_load(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
{
- static const char *kwlist[] = {"filepath", "link", "relative", NULL};
Main *bmain = CTX_data_main(BPy_GetContext());
BPy_Library *ret;
const char *filename = NULL;
bool is_rel = false, is_link = false;
- if (!PyArg_ParseTupleAndKeywords(
- args, kwds,
- "s|O&O&:load", (char **)kwlist,
+ static const char *_keywords[] = {"filepath", "link", "relative", NULL};
+ static _PyArg_Parser _parser = {"s|O&O&:load", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(
+ args, kw, &_parser,
&filename,
PyC_ParseBool, &is_link,
PyC_ParseBool, &is_rel))
@@ -237,7 +237,7 @@ static PyObject *_bpy_names(BPy_Library *self, int blocktype)
return list;
}
-static PyObject *bpy_lib_enter(BPy_Library *self, PyObject *UNUSED(args))
+static PyObject *bpy_lib_enter(BPy_Library *self)
{
PyObject *ret;
BPy_Library *self_from;
diff --git a/source/blender/python/intern/bpy_library_write.c b/source/blender/python/intern/bpy_library_write.c
index bf91253141a..c054183034a 100644
--- a/source/blender/python/intern/bpy_library_write.c
+++ b/source/blender/python/intern/bpy_library_write.c
@@ -69,24 +69,23 @@ PyDoc_STRVAR(bpy_lib_write_doc,
" :arg compress: When True, write a compressed blend file.\n"
" :type compress: bool\n"
);
-static PyObject *bpy_lib_write(PyObject *UNUSED(self), PyObject *args, PyObject *kwds)
+static PyObject *bpy_lib_write(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
{
- static const char *kwlist[] = {
- "filepath", "datablocks",
- /* optional */
- "relative_remap", "fake_user", "compress",
- NULL,
- };
-
/* args */
const char *filepath;
char filepath_abs[FILE_MAX];
PyObject *datablocks = NULL;
bool use_relative_remap = false, use_fake_user = false, use_compress = false;
- if (!PyArg_ParseTupleAndKeywords(
- args, kwds,
- "sO!|$O&O&O&:write", (char **)kwlist,
+ static const char *_keywords[] = {
+ "filepath", "datablocks",
+ /* optional */
+ "relative_remap", "fake_user", "compress",
+ NULL,
+ };
+ static _PyArg_Parser _parser = {"sO!|$O&O&O&:write", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(
+ args, kw, &_parser,
&filepath,
&PySet_Type, &datablocks,
PyC_ParseBool, &use_relative_remap,
diff --git a/source/blender/python/intern/bpy_manipulator_wrap.c b/source/blender/python/intern/bpy_manipulator_wrap.c
index 53b6285e880..9df4e81ec55 100644
--- a/source/blender/python/intern/bpy_manipulator_wrap.c
+++ b/source/blender/python/intern/bpy_manipulator_wrap.c
@@ -58,8 +58,6 @@ static bool bpy_manipulatortype_target_property_def(
{
/* Note: names based on 'rna_rna.c' */
PyObject *empty_tuple = PyTuple_New(0);
- static const char * const _keywords[] = {"id", "type", "array_length", NULL};
- static _PyArg_Parser _parser = {"|$ssi:register_class", _keywords, 0};
struct {
char *id;
@@ -72,6 +70,8 @@ static bool bpy_manipulatortype_target_property_def(
.array_length = 1,
};
+ static const char * const _keywords[] = {"id", "type", "array_length", NULL};
+ static _PyArg_Parser _parser = {"|$ssi:register_class", _keywords, 0};
if (!_PyArg_ParseTupleAndKeywordsFast(
empty_tuple, item,
&_parser,
@@ -119,7 +119,7 @@ static void manipulator_properties_init(wmManipulatorType *wt)
/* only call this so pyrna_deferred_register_class gives a useful error
* WM_operatortype_append_ptr will call RNA_def_struct_identifier
* later */
- RNA_def_struct_identifier(wt->srna, wt->idname);
+ RNA_def_struct_identifier_no_struct_map(wt->srna, wt->idname);
if (pyrna_deferred_register_class(wt->srna, py_class) != 0) {
PyErr_Print(); /* failed to register operator props */
@@ -132,27 +132,32 @@ static void manipulator_properties_init(wmManipulatorType *wt)
* get direct from the dict to avoid raising a load of attribute errors (yes this isnt ideal) - campbell */
PyObject *py_class_dict = py_class->tp_dict;
PyObject *bl_target_properties = PyDict_GetItem(py_class_dict, bpy_intern_str_bl_target_properties);
- PyObject *bl_target_properties_fast;
-
- if (!(bl_target_properties_fast = PySequence_Fast(bl_target_properties, "bl_target_properties sequence"))) {
- /* PySequence_Fast sets the error */
- PyErr_Print();
- PyErr_Clear();
- return;
- }
- const uint items_len = PySequence_Fast_GET_SIZE(bl_target_properties_fast);
- PyObject **items = PySequence_Fast_ITEMS(bl_target_properties_fast);
-
- for (uint i = 0; i < items_len; i++) {
- if (!bpy_manipulatortype_target_property_def(wt, items[i])) {
+ /* Some widgets may only exist to activate operators. */
+ if (bl_target_properties != NULL) {
+ PyObject *bl_target_properties_fast;
+ if (!(bl_target_properties_fast = PySequence_Fast(
+ bl_target_properties, "bl_target_properties sequence")))
+ {
+ /* PySequence_Fast sets the error */
PyErr_Print();
PyErr_Clear();
- break;
+ return;
}
- }
- Py_DECREF(bl_target_properties_fast);
+ const uint items_len = PySequence_Fast_GET_SIZE(bl_target_properties_fast);
+ PyObject **items = PySequence_Fast_ITEMS(bl_target_properties_fast);
+
+ for (uint i = 0; i < items_len; i++) {
+ if (!bpy_manipulatortype_target_property_def(wt, items[i])) {
+ PyErr_Print();
+ PyErr_Clear();
+ break;
+ }
+ }
+
+ Py_DECREF(bl_target_properties_fast);
+ }
}
}
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index bd3e5736c6c..c1fcb0792af 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -450,7 +450,7 @@ static PyObject *pyop_getinstance(PyObject *UNUSED(self), PyObject *value)
op = PyMem_MALLOC(sizeof(wmOperator));
memset(op, 0, sizeof(wmOperator));
#endif
- BLI_strncpy(op->idname, op->idname, sizeof(op->idname)); /* in case its needed */
+ BLI_strncpy(op->idname, ot->idname, sizeof(op->idname)); /* in case its needed */
op->type = ot;
RNA_pointer_create(NULL, &RNA_Operator, op, &ptr);
diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.c
index 90719905a79..9d57adca946 100644
--- a/source/blender/python/intern/bpy_operator_wrap.c
+++ b/source/blender/python/intern/bpy_operator_wrap.c
@@ -48,10 +48,12 @@ static void operator_properties_init(wmOperatorType *ot)
PyTypeObject *py_class = ot->ext.data;
RNA_struct_blender_type_set(ot->ext.srna, ot);
- /* only call this so pyrna_deferred_register_class gives a useful error
- * WM_operatortype_append_ptr will call RNA_def_struct_identifier
- * later */
- RNA_def_struct_identifier(ot->srna, ot->idname);
+ /* Only call this so pyrna_deferred_register_class gives a useful error
+ * WM_operatortype_append_ptr will call RNA_def_struct_identifier later.
+ *
+ * Note the 'no_struct_map' function is used since the actual struct name is already used by the operator.
+ */
+ RNA_def_struct_identifier_no_struct_map(ot->srna, ot->idname);
if (pyrna_deferred_register_class(ot->srna, py_class) != 0) {
PyErr_Print(); /* failed to register operator props */
diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c
index c7787ba9682..a46fda7ea63 100644
--- a/source/blender/python/intern/bpy_props.c
+++ b/source/blender/python/intern/bpy_props.c
@@ -320,7 +320,7 @@ static int bpy_prop_boolean_get_cb(struct PointerRNA *ptr, struct PropertyRNA *p
value = false;
}
else {
- value = PyLong_AsLong(ret);
+ value = PyC_Long_AsI32(ret);
if (value == -1 && PyErr_Occurred()) {
printf_func_error(py_func);
@@ -530,12 +530,8 @@ static void bpy_prop_boolean_array_set_cb(struct PointerRNA *ptr, struct Propert
self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEM(args, 0, self);
- py_values = PyC_FromArray(values, len, &PyBool_Type, false, "BoolVectorProperty set");
- if (!py_values) {
- printf_func_error(py_func);
- }
- else
- PyTuple_SET_ITEM(args, 1, py_values);
+ py_values = PyC_Tuple_PackArray_I32FromBool(values, len);
+ PyTuple_SET_ITEM(args, 1, py_values);
ret = PyObject_CallObject(py_func, args);
@@ -599,7 +595,7 @@ static int bpy_prop_int_get_cb(struct PointerRNA *ptr, struct PropertyRNA *prop)
value = 0.0f;
}
else {
- value = PyLong_AsLong(ret);
+ value = PyC_Long_AsI32(ret);
if (value == -1 && PyErr_Occurred()) {
printf_func_error(py_func);
@@ -764,12 +760,8 @@ static void bpy_prop_int_array_set_cb(struct PointerRNA *ptr, struct PropertyRNA
self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEM(args, 0, self);
- py_values = PyC_FromArray(values, len, &PyLong_Type, false, "IntVectorProperty set");
- if (!py_values) {
- printf_func_error(py_func);
- }
- else
- PyTuple_SET_ITEM(args, 1, py_values);
+ py_values = PyC_Tuple_PackArray_I32(values, len);
+ PyTuple_SET_ITEM(args, 1, py_values);
ret = PyObject_CallObject(py_func, args);
@@ -998,12 +990,8 @@ static void bpy_prop_float_array_set_cb(struct PointerRNA *ptr, struct PropertyR
self = pyrna_struct_as_instance(ptr);
PyTuple_SET_ITEM(args, 0, self);
- py_values = PyC_FromArray(values, len, &PyFloat_Type, false, "FloatVectorProperty set");
- if (!py_values) {
- printf_func_error(py_func);
- }
- else
- PyTuple_SET_ITEM(args, 1, py_values);
+ py_values = PyC_Tuple_PackArray_F32(values, len);
+ PyTuple_SET_ITEM(args, 1, py_values);
ret = PyObject_CallObject(py_func, args);
@@ -1249,7 +1237,7 @@ static int bpy_prop_enum_get_cb(struct PointerRNA *ptr, struct PropertyRNA *prop
value = RNA_property_enum_get_default(ptr, prop);
}
else {
- value = PyLong_AsLong(ret);
+ value = PyC_Long_AsI32(ret);
if (value == -1 && PyErr_Occurred()) {
printf_func_error(py_func);
@@ -2007,8 +1995,6 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
BPY_PROPDEF_HEAD(BoolProperty);
if (srna) {
- static const char *kwlist[] = {"attr", "name", "description", "default",
- "options", "subtype", "update", "get", "set", NULL};
const char *id = NULL, *name = NULL, *description = "";
int id_len;
bool def = false;
@@ -2021,12 +2007,17 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
PyObject *get_cb = NULL;
PyObject *set_cb = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kw,
- "s#|ssO&O!sOOO:BoolProperty",
- (char **)kwlist, &id, &id_len,
- &name, &description, PyC_ParseBool, &def,
- &PySet_Type, &pyopts, &pysubtype,
- &update_cb, &get_cb, &set_cb))
+ static const char *_keywords[] = {
+ "attr", "name", "description", "default",
+ "options", "subtype", "update", "get", "set", NULL,
+ };
+ static _PyArg_Parser _parser = {"s#|ssO&O!sOOO:BoolProperty", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(
+ args, kw, &_parser,
+ &id, &id_len,
+ &name, &description, PyC_ParseBool, &def,
+ &PySet_Type, &pyopts, &pysubtype,
+ &update_cb, &get_cb, &set_cb))
{
return NULL;
}
@@ -2089,8 +2080,6 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
BPY_PROPDEF_HEAD(BoolVectorProperty);
if (srna) {
- static const char *kwlist[] = {"attr", "name", "description", "default",
- "options", "subtype", "size", "update", "get", "set", NULL};
const char *id = NULL, *name = NULL, *description = "";
int id_len;
int def[PYRNA_STACK_ARRAY] = {0};
@@ -2105,12 +2094,17 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
PyObject *get_cb = NULL;
PyObject *set_cb = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kw,
- "s#|ssOO!siOOO:BoolVectorProperty",
- (char **)kwlist, &id, &id_len,
- &name, &description, &pydef,
- &PySet_Type, &pyopts, &pysubtype, &size,
- &update_cb, &get_cb, &set_cb))
+ static const char *_keywords[] = {
+ "attr", "name", "description", "default",
+ "options", "subtype", "size", "update", "get", "set", NULL,
+ };
+ static _PyArg_Parser _parser = {"s#|ssOO!siOOO:BoolVectorProperty", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(
+ args, kw, &_parser,
+ &id, &id_len,
+ &name, &description, &pydef,
+ &PySet_Type, &pyopts, &pysubtype, &size,
+ &update_cb, &get_cb, &set_cb))
{
return NULL;
}
@@ -2193,9 +2187,6 @@ static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw)
BPY_PROPDEF_HEAD(IntProperty);
if (srna) {
- static const char *kwlist[] = {"attr", "name", "description", "default",
- "min", "max", "soft_min", "soft_max",
- "step", "options", "subtype", "update", "get", "set", NULL};
const char *id = NULL, *name = NULL, *description = "";
int id_len;
int min = INT_MIN, max = INT_MAX, soft_min = INT_MIN, soft_max = INT_MAX, step = 1, def = 0;
@@ -2208,13 +2199,19 @@ static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw)
PyObject *get_cb = NULL;
PyObject *set_cb = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kw,
- "s#|ssiiiiiiO!sOOO:IntProperty",
- (char **)kwlist, &id, &id_len,
- &name, &description, &def,
- &min, &max, &soft_min, &soft_max,
- &step, &PySet_Type, &pyopts, &pysubtype,
- &update_cb, &get_cb, &set_cb))
+ static const char *_keywords[] = {
+ "attr", "name", "description", "default",
+ "min", "max", "soft_min", "soft_max",
+ "step", "options", "subtype", "update", "get", "set", NULL,
+ };
+ static _PyArg_Parser _parser = {"s#|ssiiiiiiO!sOOO:IntProperty", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(
+ args, kw, &_parser,
+ &id, &id_len,
+ &name, &description, &def,
+ &min, &max, &soft_min, &soft_max,
+ &step, &PySet_Type, &pyopts, &pysubtype,
+ &update_cb, &get_cb, &set_cb))
{
return NULL;
}
@@ -2290,9 +2287,6 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject
BPY_PROPDEF_HEAD(IntVectorProperty);
if (srna) {
- static const char *kwlist[] = {"attr", "name", "description", "default",
- "min", "max", "soft_min", "soft_max",
- "step", "options", "subtype", "size", "update", "get", "set", NULL};
const char *id = NULL, *name = NULL, *description = "";
int id_len;
int min = INT_MIN, max = INT_MAX, soft_min = INT_MIN, soft_max = INT_MAX, step = 1;
@@ -2308,14 +2302,20 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject
PyObject *get_cb = NULL;
PyObject *set_cb = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kw,
- "s#|ssOiiiiiO!siOOO:IntVectorProperty",
- (char **)kwlist, &id, &id_len,
- &name, &description, &pydef,
- &min, &max, &soft_min, &soft_max,
- &step, &PySet_Type, &pyopts,
- &pysubtype, &size,
- &update_cb, &get_cb, &set_cb))
+ static const char *_keywords[] = {
+ "attr", "name", "description", "default",
+ "min", "max", "soft_min", "soft_max",
+ "step", "options", "subtype", "size", "update", "get", "set", NULL,
+ };
+ static _PyArg_Parser _parser = {"s#|ssOiiiiiO!siOOO:IntVectorProperty", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(
+ args, kw, &_parser,
+ &id, &id_len,
+ &name, &description, &pydef,
+ &min, &max, &soft_min, &soft_max,
+ &step, &PySet_Type, &pyopts,
+ &pysubtype, &size,
+ &update_cb, &get_cb, &set_cb))
{
return NULL;
}
@@ -2403,10 +2403,6 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
BPY_PROPDEF_HEAD(FloatProperty);
if (srna) {
- static const char *kwlist[] = {"attr", "name", "description", "default",
- "min", "max", "soft_min", "soft_max",
- "step", "precision", "options", "subtype",
- "unit", "update", "get", "set", NULL};
const char *id = NULL, *name = NULL, *description = "";
int id_len;
float min = -FLT_MAX, max = FLT_MAX, soft_min = -FLT_MAX, soft_max = FLT_MAX, step = 3, def = 0.0f;
@@ -2422,14 +2418,21 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
PyObject *get_cb = NULL;
PyObject *set_cb = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kw,
- "s#|ssffffffiO!ssOOO:FloatProperty",
- (char **)kwlist, &id, &id_len,
- &name, &description, &def,
- &min, &max, &soft_min, &soft_max,
- &step, &precision, &PySet_Type,
- &pyopts, &pysubtype, &pyunit,
- &update_cb, &get_cb, &set_cb))
+ static const char *_keywords[] = {
+ "attr", "name", "description", "default",
+ "min", "max", "soft_min", "soft_max",
+ "step", "precision", "options", "subtype",
+ "unit", "update", "get", "set", NULL,
+ };
+ static _PyArg_Parser _parser = {"s#|ssffffffiO!ssOOO:FloatProperty", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(
+ args, kw, &_parser,
+ &id, &id_len,
+ &name, &description, &def,
+ &min, &max, &soft_min, &soft_max,
+ &step, &precision, &PySet_Type,
+ &pyopts, &pysubtype, &pyunit,
+ &update_cb, &get_cb, &set_cb))
{
return NULL;
}
@@ -2514,10 +2517,6 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec
BPY_PROPDEF_HEAD(FloatVectorProperty);
if (srna) {
- static const char *kwlist[] = {"attr", "name", "description", "default",
- "min", "max", "soft_min", "soft_max",
- "step", "precision", "options", "subtype",
- "unit", "size", "update", "get", "set", NULL};
const char *id = NULL, *name = NULL, *description = "";
int id_len;
float min = -FLT_MAX, max = FLT_MAX, soft_min = -FLT_MAX, soft_max = FLT_MAX, step = 3;
@@ -2535,14 +2534,21 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec
PyObject *get_cb = NULL;
PyObject *set_cb = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kw,
- "s#|ssOfffffiO!ssiOOO:FloatVectorProperty",
- (char **)kwlist, &id, &id_len,
- &name, &description, &pydef,
- &min, &max, &soft_min, &soft_max,
- &step, &precision, &PySet_Type,
- &pyopts, &pysubtype, &pyunit, &size,
- &update_cb, &get_cb, &set_cb))
+ static const char *_keywords[] = {
+ "attr", "name", "description", "default",
+ "min", "max", "soft_min", "soft_max",
+ "step", "precision", "options", "subtype",
+ "unit", "size", "update", "get", "set", NULL,
+ };
+ static _PyArg_Parser _parser = {"s#|ssOfffffiO!ssiOOO:FloatVectorProperty", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(
+ args, kw, &_parser,
+ &id, &id_len,
+ &name, &description, &pydef,
+ &min, &max, &soft_min, &soft_max,
+ &step, &precision, &PySet_Type,
+ &pyopts, &pysubtype, &pyunit, &size,
+ &update_cb, &get_cb, &set_cb))
{
return NULL;
}
@@ -2623,8 +2629,6 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw
BPY_PROPDEF_HEAD(StringProperty);
if (srna) {
- static const char *kwlist[] = {"attr", "name", "description", "default",
- "maxlen", "options", "subtype", "update", "get", "set", NULL};
const char *id = NULL, *name = NULL, *description = "", *def = "";
int id_len;
int maxlen = 0;
@@ -2637,12 +2641,17 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw
PyObject *get_cb = NULL;
PyObject *set_cb = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kw,
- "s#|sssiO!sOOO:StringProperty",
- (char **)kwlist, &id, &id_len,
- &name, &description, &def,
- &maxlen, &PySet_Type, &pyopts, &pysubtype,
- &update_cb, &get_cb, &set_cb))
+ static const char *_keywords[] = {
+ "attr", "name", "description", "default",
+ "maxlen", "options", "subtype", "update", "get", "set", NULL,
+ };
+ static _PyArg_Parser _parser = {"s#|sssiO!sOOO:StringProperty", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(
+ args, kw, &_parser,
+ &id, &id_len,
+ &name, &description, &def,
+ &maxlen, &PySet_Type, &pyopts, &pysubtype,
+ &update_cb, &get_cb, &set_cb))
{
return NULL;
}
@@ -2697,7 +2706,8 @@ PyDoc_STRVAR(BPy_EnumProperty_doc,
" :icon: An icon string identifier or integer icon value\n"
" (e.g. returned by :class:`bpy.types.UILayout.icon`)\n"
" :number: Unique value used as the identifier for this item (stored in file data).\n"
-" Use when the identifier may need to change.\n"
+" Use when the identifier may need to change. If the *ENUM_FLAG* option is used,\n"
+" the values are bitmasks and should be powers of two.\n"
"\n"
" When an item only contains 4 items they define ``(identifier, name, description, number)``.\n"
"\n"
@@ -2731,8 +2741,6 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
BPY_PROPDEF_HEAD(EnumProperty);
if (srna) {
- static const char *kwlist[] = {"attr", "items", "name", "description", "default",
- "options", "update", "get", "set", NULL};
const char *id = NULL, *name = NULL, *description = "";
PyObject *def = NULL;
int id_len;
@@ -2747,12 +2755,17 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
PyObject *get_cb = NULL;
PyObject *set_cb = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kw,
- "s#O|ssOO!OOO:EnumProperty",
- (char **)kwlist, &id, &id_len,
- &items, &name, &description,
- &def, &PySet_Type, &pyopts,
- &update_cb, &get_cb, &set_cb))
+ static const char *_keywords[] = {
+ "attr", "items", "name", "description", "default",
+ "options", "update", "get", "set", NULL,
+ };
+ static _PyArg_Parser _parser = {"s#O|ssOO!OOO:EnumProperty", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(
+ args, kw, &_parser,
+ &id, &id_len,
+ &items, &name, &description,
+ &def, &PySet_Type, &pyopts,
+ &update_cb, &get_cb, &set_cb))
{
return NULL;
}
@@ -2880,7 +2893,6 @@ PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw)
BPY_PROPDEF_HEAD(PointerProperty);
if (srna) {
- static const char *kwlist[] = {"attr", "type", "name", "description", "options", "poll", "update", NULL};
const char *id = NULL, *name = NULL, *description = "";
int id_len;
PropertyRNA *prop;
@@ -2890,12 +2902,16 @@ PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw)
int opts = 0;
PyObject *update_cb = NULL, *poll_cb = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kw,
- "s#O|ssO!OOO:PointerProperty",
- (char **)kwlist, &id, &id_len,
- &type, &name, &description,
- &PySet_Type, &pyopts,
- &poll_cb, &update_cb))
+ static const char *_keywords[] = {
+ "attr", "type", "name", "description", "options", "poll", "update", NULL,
+ };
+ static _PyArg_Parser _parser = {"s#O|ssO!OO:PointerProperty", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(
+ args, kw, &_parser,
+ &id, &id_len,
+ &type, &name, &description,
+ &PySet_Type, &pyopts,
+ &poll_cb, &update_cb))
{
return NULL;
}
@@ -2954,20 +2970,23 @@ PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw)
BPY_PROPDEF_HEAD(CollectionProperty);
if (srna) {
- static const char *kwlist[] = {"attr", "type", "name", "description", "options", NULL};
- const char *id = NULL, *name = NULL, *description = "";
int id_len;
+ const char *id = NULL, *name = NULL, *description = "";
PropertyRNA *prop;
StructRNA *ptype;
PyObject *type = Py_None;
PyObject *pyopts = NULL;
int opts = 0;
- if (!PyArg_ParseTupleAndKeywords(args, kw,
- "s#O|ssO!:CollectionProperty",
- (char **)kwlist, &id, &id_len,
- &type, &name, &description,
- &PySet_Type, &pyopts))
+ static const char *_keywords[] = {
+ "attr", "type", "name", "description", "options", NULL,
+ };
+ static _PyArg_Parser _parser = {"s#O|ssO!:CollectionProperty", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(
+ args, kw, &_parser,
+ &id, &id_len,
+ &type, &name, &description,
+ &PySet_Type, &pyopts))
{
return NULL;
}
@@ -3039,13 +3058,15 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw
return NULL;
}
else {
- static const char *kwlist[] = {"attr", NULL};
-
const char *id = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kw,
- "s:RemoveProperty",
- (char **)kwlist, &id))
+ static const char *_keywords[] = {
+ "attr", NULL,
+ };
+ static _PyArg_Parser _parser = {"s:RemoveProperty", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(
+ args, kw, &_parser,
+ &id))
{
return NULL;
}
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 51e179fb317..02cb5233166 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -70,6 +70,8 @@
#include "BKE_report.h"
#include "BKE_idprop.h"
+/* only for types */
+#include "BKE_node.h"
#include "../generic/idprop_py_api.h" /* for IDprop lookups */
#include "../generic/py_capi_utils.h"
@@ -1395,7 +1397,7 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
}
else {
EnumPropertyItem *enum_item;
- bool free = false;
+ bool free;
/* don't throw error here, can't trust blender 100% to give the
* right values, python code should not generate error for that */
@@ -1404,6 +1406,9 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
ret = PyUnicode_FromString(enum_item->identifier);
}
else {
+ if (free) {
+ MEM_freeN(enum_item);
+ }
RNA_property_enum_items(NULL, ptr, prop, &enum_item, NULL, &free);
/* Do not print warning in case of DummyRNA_NULL_items, this one will never match any value... */
@@ -1640,7 +1645,7 @@ static int pyrna_py_to_prop(
param = PyObject_IsTrue(value);
}
else {
- param = PyLong_AsLong(value);
+ param = PyC_Long_AsI32(value);
if (UNLIKELY(param & ~1)) { /* only accept 0/1 */
param = -1; /* error out below */
@@ -2085,10 +2090,10 @@ static int pyrna_py_to_prop_array_index(BPy_PropertyArrayRNA *self, int index, P
switch (RNA_property_type(prop)) {
case PROP_BOOLEAN:
{
- int param = PyLong_AsLong(value);
+ int param = PyC_Long_AsBool(value);
- if (param < 0 || param > 1) {
- PyErr_SetString(PyExc_TypeError, "expected True/False or 0/1");
+ if (param == -1) {
+ /* error is set */
ret = -1;
}
else {
@@ -2098,7 +2103,7 @@ static int pyrna_py_to_prop_array_index(BPy_PropertyArrayRNA *self, int index, P
}
case PROP_INT:
{
- int param = PyLong_AsLong(value);
+ int param = PyC_Long_AsI32(value);
if (param == -1 && PyErr_Occurred()) {
PyErr_SetString(PyExc_TypeError, "expected an int type");
ret = -1;
@@ -2718,7 +2723,7 @@ static PyObject *pyrna_prop_array_subscript(BPy_PropertyArrayRNA *self, PyObject
Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_IndexError);
if (i == -1 && PyErr_Occurred())
return NULL;
- return pyrna_prop_array_subscript_int(self, PyLong_AsLong(key));
+ return pyrna_prop_array_subscript_int(self, i);
}
else if (PySlice_Check(key)) {
Py_ssize_t step = 1;
@@ -3713,6 +3718,110 @@ static PyObject *pyrna_struct_type_recast(BPy_StructRNA *self)
return pyrna_struct_CreatePyObject(&r_ptr);
}
+/**
+ * \note Return value is borrowed, caller must incref.
+ */
+static PyObject *pyrna_struct_bl_rna_find_subclass_recursive(PyObject *cls, const char *id)
+{
+ PyObject *ret_test = NULL;
+ PyObject *subclasses = ((PyTypeObject *)cls)->tp_subclasses;
+ if (subclasses) {
+ /* Unfortunately we can't use the dict key because Python class names
+ * don't match the bl_idname used internally. */
+ BLI_assert(PyDict_CheckExact(subclasses));
+ PyObject *key = NULL;
+ Py_ssize_t pos = 0;
+ PyObject *value = NULL;
+ while (PyDict_Next(subclasses, &pos, &key, &value)) {
+ BLI_assert(PyWeakref_CheckRef(value));
+ PyObject *subcls = PyWeakref_GET_OBJECT(value);
+ if (subcls != Py_None) {
+ BPy_StructRNA *py_srna = (BPy_StructRNA *)PyDict_GetItem(
+ ((PyTypeObject *)subcls)->tp_dict, bpy_intern_str_bl_rna);
+ if (py_srna) {
+ StructRNA *srna = py_srna->ptr.data;
+ if (STREQ(id, RNA_struct_identifier(srna))) {
+ ret_test = subcls;
+ break;
+ }
+ }
+ ret_test = pyrna_struct_bl_rna_find_subclass_recursive(subcls, id);
+ if (ret_test) {
+ break;
+ }
+ }
+ }
+ }
+ return ret_test;
+}
+
+PyDoc_STRVAR(pyrna_struct_bl_rna_get_subclass_py_doc,
+".. classmethod:: bl_rna_get_subclass_py(id, default=None)\n"
+"\n"
+" :arg id: The RNA type identifier.\n"
+" :type id: string\n"
+" :return: The class or default when not found.\n"
+" :rtype: type\n"
+);
+static PyObject *pyrna_struct_bl_rna_get_subclass_py(PyObject *cls, PyObject *args)
+{
+ char *id;
+ PyObject *ret_default = Py_None;
+
+ if (!PyArg_ParseTuple(args, "s|O:bl_rna_get_subclass_py", &id, &ret_default)) {
+ return NULL;
+ }
+ PyObject *ret = pyrna_struct_bl_rna_find_subclass_recursive(cls, id);
+ if (ret == NULL) {
+ ret = ret_default;
+ }
+ return Py_INCREF_RET(ret);
+}
+
+PyDoc_STRVAR(pyrna_struct_bl_rna_get_subclass_doc,
+".. classmethod:: bl_rna_get_subclass(id, default=None)\n"
+"\n"
+" :arg id: The RNA type identifier.\n"
+" :type id: string\n"
+" :return: The RNA type or default when not found.\n"
+" :rtype: :class:`bpy.types.Struct` subclass\n"
+);
+static PyObject *pyrna_struct_bl_rna_get_subclass(PyObject *cls, PyObject *args)
+{
+ char *id;
+ PyObject *ret_default = Py_None;
+
+ if (!PyArg_ParseTuple(args, "s|O:bl_rna_get_subclass", &id, &ret_default)) {
+ return NULL;
+ }
+
+
+ const BPy_StructRNA *py_srna = (BPy_StructRNA *)PyDict_GetItem(((PyTypeObject *)cls)->tp_dict, bpy_intern_str_bl_rna);
+ if (py_srna == NULL) {
+ PyErr_SetString(PyExc_ValueError, "Not a registered class");
+ return NULL;
+
+ }
+ const StructRNA *srna_base = py_srna->ptr.data;
+
+ PointerRNA ptr;
+ if (srna_base == &RNA_Node) {
+ bNodeType *nt = nodeTypeFind(id);
+ if (nt) {
+ RNA_pointer_create(NULL, &RNA_Struct, nt->ext.srna, &ptr);
+ return pyrna_struct_CreatePyObject(&ptr);
+ }
+ }
+ else {
+ /* TODO, panels, menus etc. */
+ PyErr_Format(PyExc_ValueError, "Class type \"%.200s\" not supported",
+ RNA_struct_identifier(srna_base));
+ return NULL;
+ }
+
+ return Py_INCREF_RET(ret_default);
+}
+
static void pyrna_dir_members_py__add_keys(PyObject *list, PyObject *dict)
{
PyObject *list_tmp;
@@ -5011,6 +5120,8 @@ static struct PyMethodDef pyrna_struct_methods[] = {
{"path_resolve", (PyCFunction)pyrna_struct_path_resolve, METH_VARARGS, pyrna_struct_path_resolve_doc},
{"path_from_id", (PyCFunction)pyrna_struct_path_from_id, METH_VARARGS, pyrna_struct_path_from_id_doc},
{"type_recast", (PyCFunction)pyrna_struct_type_recast, METH_NOARGS, pyrna_struct_type_recast_doc},
+ {"bl_rna_get_subclass_py", (PyCFunction) pyrna_struct_bl_rna_get_subclass_py, METH_VARARGS | METH_CLASS, pyrna_struct_bl_rna_get_subclass_py_doc},
+ {"bl_rna_get_subclass", (PyCFunction) pyrna_struct_bl_rna_get_subclass, METH_VARARGS | METH_CLASS, pyrna_struct_bl_rna_get_subclass_doc},
{"__dir__", (PyCFunction)pyrna_struct_dir, METH_NOARGS, NULL},
/* experimental */
@@ -6657,7 +6768,30 @@ PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr)
if (ptr->data == NULL && ptr->type == NULL) { /* Operator RNA has NULL data */
Py_RETURN_NONE;
}
- else {
+
+ /* New in 2.8x, since not many types support instancing
+ * we may want to use a flag to avoid looping over all classes. - campbell */
+ void **instance = ptr->data ? RNA_struct_instance(ptr) : NULL;
+ if (instance && *instance) {
+ pyrna = *instance;
+
+ /* Refine may have changed types after the first instance was created. */
+ if (ptr->type == pyrna->ptr.type) {
+ Py_INCREF(pyrna);
+ return (PyObject *)pyrna;
+ }
+ else {
+ /* Existing users will need to use 'type_recast' method. */
+ Py_DECREF(pyrna);
+ *instance = NULL;
+ /* Continue as if no instance was made */
+#if 0 /* no need to assign, will be written to next... */
+ pyrna = NULL;
+#endif
+ }
+ }
+
+ {
PyTypeObject *tp = (PyTypeObject *)pyrna_struct_Subtype(ptr);
if (tp) {
@@ -6678,6 +6812,12 @@ PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr)
return NULL;
}
+ /* Blender's instance owns a reference (to avoid Python freeing it). */
+ if (instance) {
+ *instance = pyrna;
+ Py_INCREF(pyrna);
+ }
+
pyrna->ptr = *ptr;
#ifdef PYRNA_FREE_SUPPORT
pyrna->freeptr = false;
@@ -6933,15 +7073,7 @@ static PyObject *pyrna_basetype_dir(BPy_BaseTypeRNA *self)
RNA_PROP_BEGIN (&self->ptr, itemptr, self->prop)
{
StructRNA *srna = itemptr.data;
- StructRNA *srna_base = RNA_struct_base(itemptr.data);
- /* skip own operators, these double up [#29666] */
- if (ELEM(srna_base, &RNA_Operator, &RNA_Manipulator)) {
- /* do nothing */
- }
- else {
- /* add to python list */
- PyList_APPEND(ret, PyUnicode_FromString(RNA_struct_identifier(srna)));
- }
+ PyList_APPEND(ret, PyUnicode_FromString(RNA_struct_identifier(srna)));
}
RNA_PROP_END;
@@ -7450,7 +7582,6 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
PyObject *args;
PyObject *ret = NULL, *py_srna = NULL, *py_class_instance = NULL, *parmitem;
PyTypeObject *py_class;
- void **py_class_instance_store = NULL;
PropertyRNA *parm;
ParameterIterator iter;
PointerRNA funcptr;
@@ -7501,10 +7632,6 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
py_class_instance = *instance;
Py_INCREF(py_class_instance);
}
- else {
- /* store the instance here once its created */
- py_class_instance_store = instance;
- }
}
}
/* end exception */
@@ -7575,10 +7702,6 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
if (py_class_instance == NULL) {
err = -1; /* so the error is not overridden below */
}
- else if (py_class_instance_store) {
- *py_class_instance_store = py_class_instance;
- Py_INCREF(py_class_instance);
- }
}
}
diff --git a/source/blender/python/intern/bpy_rna_array.c b/source/blender/python/intern/bpy_rna_array.c
index 38931cd85de..3e147d29c90 100644
--- a/source/blender/python/intern/bpy_rna_array.c
+++ b/source/blender/python/intern/bpy_rna_array.c
@@ -38,6 +38,8 @@
#include "RNA_access.h"
+#include "../generic/py_capi_utils.h"
+
#define USE_MATHUTILS
#ifdef USE_MATHUTILS
@@ -550,7 +552,7 @@ static void py_to_float(const struct ItemConvertArgData *arg, PyObject *py, char
static void py_to_int(const struct ItemConvertArgData *arg, PyObject *py, char *data)
{
const int *range = arg->int_data.range;
- int value = (int)PyLong_AsLong(py);
+ int value = PyC_Long_AsI32(py);
CLAMP(value, range[0], range[1]);
*(int *)data = value;
}
diff --git a/source/blender/python/intern/bpy_rna_driver.c b/source/blender/python/intern/bpy_rna_driver.c
index b4c0de51c04..1135ba121e3 100644
--- a/source/blender/python/intern/bpy_rna_driver.c
+++ b/source/blender/python/intern/bpy_rna_driver.c
@@ -63,7 +63,15 @@ PyObject *pyrna_driver_get_variable_value(
}
else {
/* object & property */
- driver_arg = pyrna_prop_to_py(&ptr, prop);
+ PropertyType type = RNA_property_type(prop);
+ if (type == PROP_ENUM) {
+ /* Note that enum's are converted to strings by default,
+ * we want to avoid that, see: T52213 */
+ driver_arg = PyLong_FromLong(RNA_property_enum_get(&ptr, prop));
+ }
+ else {
+ driver_arg = pyrna_prop_to_py(&ptr, prop);
+ }
}
}
else {
diff --git a/source/blender/python/intern/bpy_rna_id_collection.c b/source/blender/python/intern/bpy_rna_id_collection.c
index 72705ffb3fb..8def52dc8fb 100644
--- a/source/blender/python/intern/bpy_rna_id_collection.c
+++ b/source/blender/python/intern/bpy_rna_id_collection.c
@@ -163,7 +163,6 @@ static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject *
Main *bmain = G.main; /* XXX Ugly, but should work! */
#endif
- static const char *kwlist[] = {"subset", "key_types", "value_types", NULL};
PyObject *subset = NULL;
PyObject *key_types = NULL;
@@ -173,9 +172,10 @@ static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject *
PyObject *ret = NULL;
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kwds, "|O$O!O!:user_map", (char **)kwlist,
+ static const char *_keywords[] = {"subset", "key_types", "value_types", NULL};
+ static _PyArg_Parser _parser = {"|O$O!O!:user_map", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(
+ args, kwds, &_parser,
&subset,
&PySet_Type, &key_types,
&PySet_Type, &val_types))
diff --git a/source/blender/python/intern/bpy_rna_manipulator.c b/source/blender/python/intern/bpy_rna_manipulator.c
index 245735f679e..4a326ae657b 100644
--- a/source/blender/python/intern/bpy_rna_manipulator.c
+++ b/source/blender/python/intern/bpy_rna_manipulator.c
@@ -30,6 +30,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
+#include "BLI_alloca.h"
#include "BKE_main.h"
@@ -48,6 +49,11 @@
#include "bpy_rna.h"
+
+/* -------------------------------------------------------------------- */
+/** \name Manipulator Target Property Define API
+ * \{ */
+
enum {
BPY_MANIPULATOR_FN_SLOT_GET = 0,
BPY_MANIPULATOR_FN_SLOT_SET,
@@ -75,7 +81,7 @@ static void py_rna_manipulator_handler_get_cb(
if (mpr_prop->type->data_type == PROP_FLOAT) {
float *value = value_p;
if (mpr_prop->type->array_length == 1) {
- if (((*value = PyFloat_AsDouble(ret)) == -1.0f && PyErr_Occurred()) == 0) {
+ if ((*value = PyFloat_AsDouble(ret)) == -1.0f && PyErr_Occurred()) {
goto fail;
}
}
@@ -121,8 +127,7 @@ static void py_rna_manipulator_handler_set_cb(
py_value = PyFloat_FromDouble(*value);
}
else {
- py_value = PyC_FromArray((void *)value, mpr_prop->type->array_length, &PyFloat_Type, false,
- "Manipulator set callback: ");
+ py_value = PyC_Tuple_PackArray_F32(value, mpr_prop->type->array_length);
}
if (py_value == NULL) {
goto fail;
@@ -236,14 +241,8 @@ PyDoc_STRVAR(bpy_manipulator_target_set_handler_doc,
" :arg range: Function that returns a (min, max) tuple for manipulators that use a range.\n"
" :type range: callable\n"
);
-static PyObject *bpy_manipulator_target_set_handler(PyObject *UNUSED(self), PyObject *args, PyObject *kwds)
+static PyObject *bpy_manipulator_target_set_handler(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
{
- /* Note: this is a counter-part to functions:
- * 'Manipulator.target_set_prop & target_set_operator'
- * (see: rna_wm_manipulator_api.c). conventions should match. */
- static const char * const _keywords[] = {"self", "target", "get", "set", "range", NULL};
- static _PyArg_Parser _parser = {"Os|$OOO:target_set_handler", _keywords, 0};
-
PyGILState_STATE gilstate = PyGILState_Ensure();
struct {
@@ -256,9 +255,13 @@ static PyObject *bpy_manipulator_target_set_handler(PyObject *UNUSED(self), PyOb
.py_fn_slots = {NULL},
};
+ /* Note: this is a counter-part to functions:
+ * 'Manipulator.target_set_prop & target_set_operator'
+ * (see: rna_wm_manipulator_api.c). conventions should match. */
+ static const char * const _keywords[] = {"self", "target", "get", "set", "range", NULL};
+ static _PyArg_Parser _parser = {"Os|$OOO:target_set_handler", _keywords, 0};
if (!_PyArg_ParseTupleAndKeywordsFast(
- args, kwds,
- &_parser,
+ args, kw, &_parser,
&params.self,
&params.target,
&params.py_fn_slots[BPY_MANIPULATOR_FN_SLOT_GET],
@@ -322,20 +325,241 @@ fail:
return NULL;
}
-int BPY_rna_manipulator_module(PyObject *mod_par)
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Manipulator Target Property Access API
+ * \{ */
+
+PyDoc_STRVAR(bpy_manipulator_target_get_value_doc,
+".. method:: target_get_value(target):\n"
+"\n"
+" Get the value of this target property.\n"
+"\n"
+" :arg target: Target property name.\n"
+" :type target: string\n"
+" :return: The value of the target property.\n"
+" :rtype: Single value or array based on the target type\n"
+);
+static PyObject *bpy_manipulator_target_get_value(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
{
- static PyMethodDef method_def = {
- "target_set_handler", (PyCFunction)bpy_manipulator_target_set_handler, METH_VARARGS | METH_KEYWORDS,
- bpy_manipulator_target_set_handler_doc};
+ struct {
+ PyObject *self;
+ char *target;
+ } params = {
+ .self = NULL,
+ .target = NULL,
+ };
- PyObject *func = PyCFunction_New(&method_def, NULL);
- PyObject *func_inst = PyInstanceMethod_New(func);
+ static const char * const _keywords[] = {"self", "target", NULL};
+ static _PyArg_Parser _parser = {"Os:target_get_value", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(
+ args, kw, &_parser,
+ &params.self,
+ &params.target))
+ {
+ goto fail;
+ }
+
+ wmManipulator *mpr = ((BPy_StructRNA *)params.self)->ptr.data;
+ wmManipulatorProperty *mpr_prop =
+ WM_manipulator_target_property_find(mpr, params.target);
+ if (mpr_prop == NULL) {
+ PyErr_Format(PyExc_ValueError,
+ "Manipulator target property '%s.%s' not found",
+ mpr->type->idname, params.target);
+ goto fail;
+ }
- /* TODO, return a type that binds nearly to a method. */
- PyModule_AddObject(mod_par, "_rna_manipulator_target_set_handler", func_inst);
+ const int array_len = WM_manipulator_target_property_array_length(mpr, mpr_prop);
+ switch (mpr_prop->type->data_type) {
+ case PROP_FLOAT:
+ {
+ if (array_len != 0) {
+ float *value = BLI_array_alloca(value, array_len);
+ WM_manipulator_target_property_value_get_array(mpr, mpr_prop, value);
+ return PyC_Tuple_PackArray_F32(value, array_len);
+ }
+ else {
+ float value = WM_manipulator_target_property_value_get(mpr, mpr_prop);
+ return PyFloat_FromDouble(value);
+ }
+ break;
+ }
+ default:
+ {
+ PyErr_SetString(PyExc_RuntimeError, "Not yet supported type");
+ goto fail;
+ }
+ }
- return 0;
+fail:
+ return NULL;
}
+PyDoc_STRVAR(bpy_manipulator_target_set_value_doc,
+".. method:: target_set_value(target):\n"
+"\n"
+" Set the value of this target property.\n"
+"\n"
+" :arg target: Target property name.\n"
+" :type target: string\n"
+);
+static PyObject *bpy_manipulator_target_set_value(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
+{
+ struct {
+ PyObject *self;
+ char *target;
+ PyObject *value;
+ } params = {
+ .self = NULL,
+ .target = NULL,
+ .value = NULL,
+ };
+
+ static const char * const _keywords[] = {"self", "target", "value", NULL};
+ static _PyArg_Parser _parser = {"OsO:target_set_value", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(
+ args, kw, &_parser,
+ &params.self,
+ &params.target,
+ &params.value))
+ {
+ goto fail;
+ }
+
+ wmManipulator *mpr = ((BPy_StructRNA *)params.self)->ptr.data;
+ wmManipulatorProperty *mpr_prop =
+ WM_manipulator_target_property_find(mpr, params.target);
+ if (mpr_prop == NULL) {
+ PyErr_Format(PyExc_ValueError,
+ "Manipulator target property '%s.%s' not found",
+ mpr->type->idname, params.target);
+ goto fail;
+ }
+
+ const int array_len = WM_manipulator_target_property_array_length(mpr, mpr_prop);
+ switch (mpr_prop->type->data_type) {
+ case PROP_FLOAT:
+ {
+ if (array_len != 0) {
+ float *value = BLI_array_alloca(value, array_len);
+ if (PyC_AsArray(value, params.value, mpr_prop->type->array_length, &PyFloat_Type, false,
+ "Manipulator target property array") == -1)
+ {
+ goto fail;
+ }
+ WM_manipulator_target_property_value_set_array(BPy_GetContext(), mpr, mpr_prop, value);
+ }
+ else {
+ float value;
+ if ((value = PyFloat_AsDouble(params.value)) == -1.0f && PyErr_Occurred()) {
+ goto fail;
+ }
+ WM_manipulator_target_property_value_set(BPy_GetContext(), mpr, mpr_prop, value);
+ }
+ Py_RETURN_NONE;
+ }
+ default:
+ {
+ PyErr_SetString(PyExc_RuntimeError, "Not yet supported type");
+ goto fail;
+ }
+ }
+
+fail:
+ return NULL;
+}
+
+
+PyDoc_STRVAR(bpy_manipulator_target_get_range_doc,
+".. method:: target_get_range(target):\n"
+"\n"
+" Get the range for this target property.\n"
+"\n"
+" :arg target: Target property name.\n"
+" :Get the range for this target property"
+" :return: The range of this property (min, max).\n"
+" :rtype: tuple pair.\n"
+);
+static PyObject *bpy_manipulator_target_get_range(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
+{
+ struct {
+ PyObject *self;
+ char *target;
+ } params = {
+ .self = NULL,
+ .target = NULL,
+ };
+
+ static const char * const _keywords[] = {"self", "target", NULL};
+ static _PyArg_Parser _parser = {"Os:target_get_range", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(
+ args, kw, &_parser,
+ &params.self,
+ &params.target))
+ {
+ goto fail;
+ }
+
+ wmManipulator *mpr = ((BPy_StructRNA *)params.self)->ptr.data;
+
+ wmManipulatorProperty *mpr_prop =
+ WM_manipulator_target_property_find(mpr, params.target);
+ if (mpr_prop == NULL) {
+ PyErr_Format(PyExc_ValueError,
+ "Manipulator target property '%s.%s' not found",
+ mpr->type->idname, params.target);
+ goto fail;
+ }
+
+ switch (mpr_prop->type->data_type) {
+ case PROP_FLOAT:
+ {
+ float range[2];
+ WM_manipulator_target_property_range_get(mpr, mpr_prop, range);
+ return PyC_Tuple_PackArray_F32(range, 2);
+ }
+ default:
+ {
+ PyErr_SetString(PyExc_RuntimeError, "Not yet supported type");
+ goto fail;
+ }
+ }
+
+fail:
+ return NULL;
+}
+
+/** \} */
+
+int BPY_rna_manipulator_module(PyObject *mod_par)
+{
+ static PyMethodDef method_def_array[] = {
+ /* Manipulator Target Property Define API */
+ {"target_set_handler", (PyCFunction)bpy_manipulator_target_set_handler,
+ METH_VARARGS | METH_KEYWORDS, bpy_manipulator_target_set_handler_doc},
+ /* Manipulator Target Property Access API */
+ {"target_get_value", (PyCFunction)bpy_manipulator_target_get_value,
+ METH_VARARGS | METH_KEYWORDS, bpy_manipulator_target_get_value_doc},
+ {"target_set_value", (PyCFunction)bpy_manipulator_target_set_value,
+ METH_VARARGS | METH_KEYWORDS, bpy_manipulator_target_set_value_doc},
+ {"target_get_range", (PyCFunction)bpy_manipulator_target_get_range,
+ METH_VARARGS | METH_KEYWORDS, bpy_manipulator_target_get_range_doc},
+ /* no sentinel needed. */
+ };
+
+ for (int i = 0; i < ARRAY_SIZE(method_def_array); i++) {
+ PyMethodDef *m = &method_def_array[i];
+ PyObject *func = PyCFunction_New(m, NULL);
+ PyObject *func_inst = PyInstanceMethod_New(func);
+ char name_prefix[128];
+ PyOS_snprintf(name_prefix, sizeof(name_prefix), "_rna_manipulator_%s", m->ml_name);
+ /* TODO, return a type that binds nearly to a method. */
+ PyModule_AddObject(mod_par, name_prefix, func_inst);
+ }
+
+ return 0;
+}
diff --git a/source/blender/python/intern/bpy_util.h b/source/blender/python/intern/bpy_util.h
index 63cb7920bd1..6000bf94aef 100644
--- a/source/blender/python/intern/bpy_util.h
+++ b/source/blender/python/intern/bpy_util.h
@@ -27,8 +27,8 @@
#ifndef __BPY_UTIL_H__
#define __BPY_UTIL_H__
-#if PY_VERSION_HEX < 0x03050000
-# error "Python 3.5 or greater is required, you'll need to update your python."
+#if PY_VERSION_HEX < 0x03060000
+# error "Python 3.6 or greater is required, you'll need to update your python."
#endif
struct EnumPropertyItem;
diff --git a/source/blender/python/intern/bpy_utils_units.c b/source/blender/python/intern/bpy_utils_units.c
index e0c70483e3c..0ef689d1a5a 100644
--- a/source/blender/python/intern/bpy_utils_units.c
+++ b/source/blender/python/intern/bpy_utils_units.c
@@ -174,8 +174,6 @@ PyDoc_STRVAR(bpyunits_to_value_doc,
);
static PyObject *bpyunits_to_value(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
{
- static const char *kwlist[] = {"unit_system", "unit_category", "str_input", "str_ref_unit", NULL};
-
char *usys_str = NULL, *ucat_str = NULL, *inpt = NULL, *uref = NULL;
const float scale = 1.0f;
@@ -185,8 +183,13 @@ static PyObject *bpyunits_to_value(PyObject *UNUSED(self), PyObject *args, PyObj
int usys, ucat;
PyObject *ret;
- if (!PyArg_ParseTupleAndKeywords(args, kw, "sss#|z:bpy.utils.units.to_value", (char **)kwlist,
- &usys_str, &ucat_str, &inpt, &str_len, &uref))
+ static const char *_keywords[] = {
+ "unit_system", "unit_category", "str_input", "str_ref_unit", NULL,
+ };
+ static _PyArg_Parser _parser = {"sss#|z:to_value", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(
+ args, kw, &_parser,
+ &usys_str, &ucat_str, &inpt, &str_len, &uref))
{
return NULL;
}
@@ -244,9 +247,6 @@ PyDoc_STRVAR(bpyunits_to_string_doc,
);
static PyObject *bpyunits_to_string(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
{
- static const char *kwlist[] = {"unit_system", "unit_category", "value",
- "precision", "split_unit", "compatible_unit", NULL};
-
char *usys_str = NULL, *ucat_str = NULL;
double value = 0.0;
int precision = 3;
@@ -254,9 +254,13 @@ static PyObject *bpyunits_to_string(PyObject *UNUSED(self), PyObject *args, PyOb
int usys, ucat;
- if (!PyArg_ParseTupleAndKeywords(
- args, kw,
- "ssd|iO&O&:bpy.utils.units.to_string", (char **)kwlist,
+ static const char *_keywords[] = {
+ "unit_system", "unit_category", "value",
+ "precision", "split_unit", "compatible_unit", NULL,
+ };
+ static _PyArg_Parser _parser = {"ssd|iO&O&:to_string", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(
+ args, kw, &_parser,
&usys_str, &ucat_str, &value, &precision,
PyC_ParseBool, &split_unit,
PyC_ParseBool, &compatible_unit))
diff --git a/source/blender/python/intern/gpu.c b/source/blender/python/intern/gpu.c
index 48230a723d2..a7a0ae78f26 100644
--- a/source/blender/python/intern/gpu.c
+++ b/source/blender/python/intern/gpu.c
@@ -207,7 +207,7 @@ PyDoc_STRVAR(GPU_export_shader_doc,
" :return: Dictionary defining the shader, uniforms and attributes.\n"
" :rtype: Dict"
);
-static PyObject *GPU_export_shader(PyObject *UNUSED(self), PyObject *args, PyObject *kwds)
+static PyObject *GPU_export_shader(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
{
PyObject *pyscene;
PyObject *pymat;
@@ -224,11 +224,14 @@ static PyObject *GPU_export_shader(PyObject *UNUSED(self), PyObject *args, PyObj
GPUInputUniform *uniform;
GPUInputAttribute *attribute;
- static const char *kwlist[] = {"scene", "material", NULL};
-
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO:export_shader", (char **)(kwlist), &pyscene, &pymat))
+ static const char *_keywords[] = {"scene", "material", NULL};
+ static _PyArg_Parser _parser = {"OO:export_shader", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(
+ args, kw, &_parser,
+ &pyscene, &pymat))
+ {
return NULL;
-
+ }
scene = (Scene *)PyC_RNA_AsPointer(pyscene, "Scene");
if (scene == NULL) {
return NULL;
@@ -334,6 +337,14 @@ PyObject *GPU_initPython(void)
PyDict_SetItem(sys_modules, PyModule_GetNameObject(submodule), submodule);
Py_INCREF(submodule);
+ PyModule_AddObject(module, "matrix", (submodule = BPyInit_gpu_matrix()));
+ PyDict_SetItem(sys_modules, PyModule_GetNameObject(submodule), submodule);
+ Py_INCREF(submodule);
+
+ PyModule_AddObject(module, "select", (submodule = BPyInit_gpu_select()));
+ PyDict_SetItem(sys_modules, PyModule_GetNameObject(submodule), submodule);
+ Py_INCREF(submodule);
+
PyDict_SetItem(PyImport_GetModuleDict(), PyModule_GetNameObject(module), module);
return module;
}
diff --git a/source/blender/python/intern/gpu.h b/source/blender/python/intern/gpu.h
index 0da44a4eb87..92841db9027 100644
--- a/source/blender/python/intern/gpu.h
+++ b/source/blender/python/intern/gpu.h
@@ -37,5 +37,7 @@
PyObject *GPU_initPython(void);
PyObject *BPyInit_gpu_offscreen(void);
+PyObject *BPyInit_gpu_matrix(void);
+PyObject *BPyInit_gpu_select(void);
#endif /* __GPU_H__ */
diff --git a/source/blender/python/intern/gpu_offscreen.c b/source/blender/python/intern/gpu_offscreen.c
index da8e5d69f02..6c16c274234 100644
--- a/source/blender/python/intern/gpu_offscreen.c
+++ b/source/blender/python/intern/gpu_offscreen.c
@@ -144,36 +144,6 @@ static PyObject *pygpu_offscreen_unbind(BPy_GPUOffScreen *self, PyObject *args,
Py_RETURN_NONE;
}
-/**
- * Use with PyArg_ParseTuple's "O&" formatting.
- */
-static int pygpu_offscreen_check_matrix(PyObject *o, void *p)
-{
- MatrixObject **pymat_p = p;
- MatrixObject *pymat = (MatrixObject *)o;
-
- if (!MatrixObject_Check(pymat)) {
- PyErr_Format(PyExc_TypeError,
- "expected a mathutils.Matrix, not a %.200s",
- Py_TYPE(o)->tp_name);
- return 0;
- }
-
- if (BaseMath_ReadCallback(pymat) == -1) {
- return 0;
- }
-
- if ((pymat->num_col != 4) ||
- (pymat->num_row != 4))
- {
- PyErr_SetString(PyExc_ValueError, "matrix must be 4x4");
- return 0;
- }
-
- *pymat_p = pymat;
- return 1;
-}
-
PyDoc_STRVAR(pygpu_offscreen_draw_view3d_doc,
"draw_view3d(scene, view3d, region, modelview_matrix, projection_matrix)\n"
"\n"
@@ -192,6 +162,8 @@ PyDoc_STRVAR(pygpu_offscreen_draw_view3d_doc,
);
static PyObject *pygpu_offscreen_draw_view3d(BPy_GPUOffScreen *self, PyObject *args, PyObject *kwds)
{
+ /* TODO: This doesn't work currently because of eval_ctx. */
+#if 0
static const char *kwlist[] = {"scene", "render_layer", "view3d", "region", "projection_matrix", "modelview_matrix", NULL};
MatrixObject *py_mat_modelview, *py_mat_projection;
@@ -210,8 +182,8 @@ static PyObject *pygpu_offscreen_draw_view3d(BPy_GPUOffScreen *self, PyObject *a
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "OOOOO&O&:draw_view3d", (char **)(kwlist),
&py_scene, &py_scene_layer, &py_view3d, &py_region,
- pygpu_offscreen_check_matrix, &py_mat_projection,
- pygpu_offscreen_check_matrix, &py_mat_modelview) ||
+ Matrix_Parse4x4, &py_mat_projection,
+ Matrix_Parse4x4, &py_mat_modelview) ||
(!(scene = PyC_RNA_AsPointer(py_scene, "Scene")) ||
!(sl = PyC_RNA_AsPointer(py_scene_layer, "SceneLayer")) ||
!(v3d = PyC_RNA_AsPointer(py_view3d, "SpaceView3D")) ||
@@ -231,7 +203,7 @@ static PyObject *pygpu_offscreen_draw_view3d(BPy_GPUOffScreen *self, PyObject *a
GPU_offscreen_bind(self->ofs, true); /* bind */
ED_view3d_draw_offscreen(
- scene, v3d, ar, GPU_offscreen_width(self->ofs), GPU_offscreen_height(self->ofs),
+ scene, sl, v3d, ar, GPU_offscreen_width(self->ofs), GPU_offscreen_height(self->ofs),
(float(*)[4])py_mat_modelview->matrix, (float(*)[4])py_mat_projection->matrix,
false, true, true, "",
fx, &fx_settings,
@@ -244,6 +216,10 @@ static PyObject *pygpu_offscreen_draw_view3d(BPy_GPUOffScreen *self, PyObject *a
MEM_freeN(rv3d_mats);
Py_RETURN_NONE;
+#else
+ UNUSED_VARS(self, args, kwds);
+#endif
+ return NULL;
}
PyDoc_STRVAR(pygpu_offscreen_free_doc,
diff --git a/source/blender/python/intern/gpu_py_matrix.c b/source/blender/python/intern/gpu_py_matrix.c
new file mode 100644
index 00000000000..68b08dfb324
--- /dev/null
+++ b/source/blender/python/intern/gpu_py_matrix.c
@@ -0,0 +1,552 @@
+/*
+ * ***** 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/python/intern/gpu_py_matrix.c
+ * \ingroup pythonintern
+ *
+ * This file defines the gpu.matrix stack API.
+ *
+ * \warning While these functions attempt to ensure correct stack usage.
+ * Mixing Python and C functions may still crash on invalid use.
+ */
+
+#include <Python.h>
+
+
+#include "BLI_utildefines.h"
+
+#include "../mathutils/mathutils.h"
+
+#include "../generic/py_capi_utils.h"
+
+#include "gpu.h"
+
+#define USE_GPU_PY_MATRIX_API
+#include "GPU_matrix.h"
+#undef USE_GPU_PY_MATRIX_API
+
+/* -------------------------------------------------------------------- */
+/** \name Helper Functions
+ * \{ */
+
+static bool pygpu_stack_is_push_model_view_ok_or_error(void)
+{
+ if (GPU_matrix_stack_level_get_model_view() >= GPU_PY_MATRIX_STACK_LEN) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Maximum model-view stack depth " STRINGIFY(GPU_PY_MATRIX_STACK_DEPTH) " reached");
+ return false;
+ }
+ return true;
+}
+
+static bool pygpu_stack_is_push_projection_ok_or_error(void)
+{
+ if (GPU_matrix_stack_level_get_projection() >= GPU_PY_MATRIX_STACK_LEN) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Maximum projection stack depth " STRINGIFY(GPU_PY_MATRIX_STACK_DEPTH) " reached");
+ return false;
+ }
+ return true;
+}
+
+static bool pygpu_stack_is_pop_model_view_ok_or_error(void)
+{
+ if (GPU_matrix_stack_level_get_model_view() == 0) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Minimum model-view stack depth reached");
+ return false;
+ }
+ return true;
+}
+
+static bool pygpu_stack_is_pop_projection_ok_or_error(void)
+{
+ if (GPU_matrix_stack_level_get_projection() == 0) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Minimum projection stack depth reached");
+ return false;
+ }
+ return true;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Manage Stack
+ * \{ */
+
+PyDoc_STRVAR(pygpu_matrix_push_doc,
+"push()\n"
+"\n"
+" Add to the model-view matrix stack.\n"
+);
+static PyObject *pygpu_matrix_push(PyObject *UNUSED(self))
+{
+ if (!pygpu_stack_is_push_model_view_ok_or_error()) {
+ return NULL;
+ }
+ gpuPushMatrix();
+ Py_RETURN_NONE;
+}
+
+PyDoc_STRVAR(pygpu_matrix_pop_doc,
+"pop()\n"
+"\n"
+" Remove the last model-view matrix from the stack.\n"
+);
+static PyObject *pygpu_matrix_pop(PyObject *UNUSED(self))
+{
+ if (!pygpu_stack_is_pop_model_view_ok_or_error()) {
+ return NULL;
+ }
+ gpuPopMatrix();
+ Py_RETURN_NONE;
+}
+
+PyDoc_STRVAR(pygpu_matrix_push_projection_doc,
+"push_projection()\n"
+"\n"
+" Add to the projection matrix stack.\n"
+);
+static PyObject *pygpu_matrix_push_projection(PyObject *UNUSED(self))
+{
+ if (!pygpu_stack_is_push_projection_ok_or_error()) {
+ return NULL;
+ }
+ gpuPushProjectionMatrix();
+ Py_RETURN_NONE;
+}
+
+PyDoc_STRVAR(pygpu_matrix_pop_projection_doc,
+"pop_projection()\n"
+"\n"
+" Remove the last projection matrix from the stack.\n"
+);
+static PyObject *pygpu_matrix_pop_projection(PyObject *UNUSED(self))
+{
+ if (!pygpu_stack_is_pop_projection_ok_or_error()) {
+ return NULL;
+ }
+ gpuPopProjectionMatrix();
+ Py_RETURN_NONE;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Stack (Context Manager)
+ *
+ * Safer alternative to ensure balanced push/pop calls.
+ *
+ * \{ */
+
+typedef struct {
+ PyObject_HEAD /* required python macro */
+ int type;
+ int level;
+} BPy_GPU_MatrixStackContext;
+
+enum {
+ PYGPU_MATRIX_TYPE_MODEL_VIEW = 1,
+ PYGPU_MATRIX_TYPE_PROJECTION = 2,
+};
+
+static PyObject *pygpu_matrix_stack_context_enter(BPy_GPU_MatrixStackContext *self);
+static PyObject *pygpu_matrix_stack_context_exit(BPy_GPU_MatrixStackContext *self, PyObject *args);
+
+static PyMethodDef pygpu_matrix_stack_context_methods[] = {
+ {"__enter__", (PyCFunction)pygpu_matrix_stack_context_enter, METH_NOARGS},
+ {"__exit__", (PyCFunction)pygpu_matrix_stack_context_exit, METH_VARARGS},
+ {NULL}
+};
+
+static PyTypeObject pygpu_matrix_stack_context_Type = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ .tp_name = "GPUMatrixStackContext",
+ .tp_basicsize = sizeof(BPy_GPU_MatrixStackContext),
+ .tp_flags = Py_TPFLAGS_DEFAULT,
+ .tp_methods = pygpu_matrix_stack_context_methods,
+};
+
+static PyObject *pygpu_matrix_stack_context_enter(BPy_GPU_MatrixStackContext *self)
+{
+ /* sanity - should never happen */
+ if (self->level != -1) {
+ PyErr_SetString(PyExc_RuntimeError, "Already in use");
+ return NULL;
+ }
+
+ if (self->type == PYGPU_MATRIX_TYPE_MODEL_VIEW) {
+ if (!pygpu_stack_is_push_model_view_ok_or_error()) {
+ return NULL;
+ }
+ gpuPushMatrix();
+ self->level = GPU_matrix_stack_level_get_model_view();
+ }
+ else if (self->type == PYGPU_MATRIX_TYPE_PROJECTION) {
+ if (!pygpu_stack_is_push_projection_ok_or_error()) {
+ return NULL;
+ }
+ gpuPushProjectionMatrix();
+ self->level = GPU_matrix_stack_level_get_projection();
+ }
+ else {
+ BLI_assert(0);
+ }
+ Py_RETURN_NONE;
+}
+
+static PyObject *pygpu_matrix_stack_context_exit(BPy_GPU_MatrixStackContext *self, PyObject *UNUSED(args))
+{
+ /* sanity - should never happen */
+ if (self->level == -1) {
+ fprintf(stderr, "Not yet in use\n");
+ goto finally;
+ }
+
+ if (self->type == PYGPU_MATRIX_TYPE_MODEL_VIEW) {
+ const int level = GPU_matrix_stack_level_get_model_view();
+ if (level != self->level) {
+ fprintf(stderr, "Level push/pop mismatch, expected %d, got %d\n", self->level, level);
+ }
+ if (level != 0) {
+ gpuPopMatrix();
+ }
+ }
+ else if (self->type == PYGPU_MATRIX_TYPE_PROJECTION) {
+ const int level = GPU_matrix_stack_level_get_projection();
+ if (level != self->level) {
+ fprintf(stderr, "Level push/pop mismatch, expected %d, got %d", self->level, level);
+ }
+ if (level != 0) {
+ gpuPopProjectionMatrix();
+ }
+ }
+ else {
+ BLI_assert(0);
+ }
+finally:
+ Py_RETURN_NONE;
+}
+
+static PyObject *pygpu_matrix_push_pop_impl(int type)
+{
+ BPy_GPU_MatrixStackContext *ret = PyObject_New(BPy_GPU_MatrixStackContext, &pygpu_matrix_stack_context_Type);
+ ret->type = type;
+ ret->level = -1;
+ return (PyObject *)ret;
+}
+
+PyDoc_STRVAR(pygpu_matrix_push_pop_doc,
+"push_pop()\n"
+"\n"
+" Context manager to ensure balanced push/pop calls, even in the case of an error.\n"
+);
+static PyObject *pygpu_matrix_push_pop(PyObject *UNUSED(self))
+{
+ return pygpu_matrix_push_pop_impl(PYGPU_MATRIX_TYPE_MODEL_VIEW);
+}
+
+PyDoc_STRVAR(pygpu_matrix_push_pop_projection_doc,
+"push_pop_projection()\n"
+"\n"
+" Context manager to ensure balanced push/pop calls, even in the case of an error.\n"
+);
+static PyObject *pygpu_matrix_push_pop_projection(PyObject *UNUSED(self))
+{
+ return pygpu_matrix_push_pop_impl(PYGPU_MATRIX_TYPE_PROJECTION);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Manipulate State
+ * \{ */
+
+PyDoc_STRVAR(pygpu_matrix_multiply_matrix_doc,
+"multiply_matrix(matrix)\n"
+"\n"
+" Multiply the current stack matrix.\n"
+"\n"
+" :param matrix: A 4x4 matrix.\n"
+" :type matrix: :class:`mathutils.Matrix`\n"
+);
+static PyObject *pygpu_matrix_multiply_matrix(PyObject *UNUSED(self), PyObject *value)
+{
+ MatrixObject *pymat;
+ if (!Matrix_Parse4x4(value, &pymat)) {
+ return NULL;
+ }
+ gpuMultMatrix(pymat->matrix);
+ Py_RETURN_NONE;
+}
+
+PyDoc_STRVAR(pygpu_matrix_scale_doc,
+"scale(scale)\n"
+"\n"
+" Scale the current stack matrix.\n"
+"\n"
+" :param scale: Scale the current stack matrix.\n"
+" :type scale: sequence of 2 or 3 floats\n"
+);
+static PyObject *pygpu_matrix_scale(PyObject *UNUSED(self), PyObject *value)
+{
+ float scale[3];
+ int len;
+ if ((len = mathutils_array_parse(scale, 2, 3, value, "gpu.matrix.scale(): invalid vector arg")) == -1) {
+ return NULL;
+ }
+ if (len == 2) {
+ gpuScale2fv(scale);
+ }
+ else {
+ gpuScale3fv(scale);
+ }
+ Py_RETURN_NONE;
+}
+
+PyDoc_STRVAR(pygpu_matrix_scale_uniform_doc,
+"scale_uniform(scale)\n"
+"\n"
+" :param scale: Scale the current stack matrix.\n"
+" :type scale: sequence of 2 or 3 floats\n"
+);
+static PyObject *pygpu_matrix_scale_uniform(PyObject *UNUSED(self), PyObject *value)
+{
+ float scalar;
+ if ((scalar = PyFloat_AsDouble(value)) == -1.0f && PyErr_Occurred()) {
+ PyErr_Format(PyExc_TypeError,
+ "expected a number, not %.200s",
+ Py_TYPE(value)->tp_name);
+ return NULL;
+ }
+ gpuScaleUniform(scalar);
+ Py_RETURN_NONE;
+}
+
+PyDoc_STRVAR(pygpu_matrix_translate_doc,
+"translate(offset)\n"
+"\n"
+" Scale the current stack matrix.\n"
+"\n"
+" :param offset: Translate the current stack matrix.\n"
+" :type offset: sequence of 2 or 3 floats\n"
+);
+static PyObject *pygpu_matrix_translate(PyObject *UNUSED(self), PyObject *value)
+{
+ float offset[3];
+ int len;
+ if ((len = mathutils_array_parse(offset, 2, 3, value, "gpu.matrix.translate(): invalid vector arg")) == -1) {
+ return NULL;
+ }
+ if (len == 2) {
+ gpuTranslate2fv(offset);
+ }
+ else {
+ gpuTranslate3fv(offset);
+ }
+ Py_RETURN_NONE;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Write State
+ * \{ */
+
+PyDoc_STRVAR(pygpu_matrix_reset_doc,
+"reset()\n"
+"\n"
+" Empty stack and set to identity.\n"
+);
+static PyObject *pygpu_matrix_reset(PyObject *UNUSED(self))
+{
+ gpuMatrixReset();
+ Py_RETURN_NONE;
+}
+
+PyDoc_STRVAR(pygpu_matrix_load_identity_doc,
+"load_identity()\n"
+"\n"
+" Empty stack and set to identity.\n"
+);
+static PyObject *pygpu_matrix_load_identity(PyObject *UNUSED(self))
+{
+ gpuLoadIdentity();
+ Py_RETURN_NONE;
+}
+
+PyDoc_STRVAR(pygpu_matrix_load_matrix_doc,
+"load_matrix(matrix)\n"
+"\n"
+" Load a matrix into the stack.\n"
+"\n"
+" :param matrix: A 4x4 matrix.\n"
+" :type matrix: :class:`mathutils.Matrix`\n"
+);
+static PyObject *pygpu_matrix_load_matrix(PyObject *UNUSED(self), PyObject *value)
+{
+ MatrixObject *pymat;
+ if (!Matrix_Parse4x4(value, &pymat)) {
+ return NULL;
+ }
+ gpuLoadMatrix(pymat->matrix);
+ Py_RETURN_NONE;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Read State
+ * \{ */
+
+PyDoc_STRVAR(pygpu_matrix_get_projection_matrix_doc,
+"get_projection_matrix()\n"
+"\n"
+" Return a copy of the projection matrix.\n"
+"\n"
+" :return: A 4x4 projection matrix.\n"
+" :rtype: :class:`mathutils.Matrix`\n"
+);
+static PyObject *pygpu_matrix_get_projection_matrix(PyObject *UNUSED(self))
+{
+ float matrix[4][4];
+ gpuGetModelViewMatrix(matrix);
+ return Matrix_CreatePyObject(&matrix[0][0], 4, 4, NULL);
+}
+
+
+PyDoc_STRVAR(pygpu_matrix_get_modal_view_matrix_doc,
+"get_view_matrix()\n"
+"\n"
+" Return a copy of the view matrix.\n"
+"\n"
+" :return: A 4x4 view matrix.\n"
+" :rtype: :class:`mathutils.Matrix`\n"
+);
+static PyObject *pygpu_matrix_get_modal_view_matrix(PyObject *UNUSED(self))
+{
+ float matrix[4][4];
+ gpuGetProjectionMatrix(matrix);
+ return Matrix_CreatePyObject(&matrix[0][0], 4, 4, NULL);
+}
+
+PyDoc_STRVAR(pygpu_matrix_get_normal_matrix_doc,
+"get_normal_matrix()\n"
+"\n"
+" Return a copy of the normal matrix.\n"
+"\n"
+" :return: A 3x3 normal matrix.\n"
+" :rtype: :class:`mathutils.Matrix`\n"
+);
+static PyObject *pygpu_matrix_get_normal_matrix(PyObject *UNUSED(self))
+{
+ float matrix[3][3];
+ gpuGetNormalMatrix(matrix);
+ return Matrix_CreatePyObject(&matrix[0][0], 3, 3, NULL);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Module
+ * \{ */
+
+static struct PyMethodDef BPy_GPU_matrix_methods[] = {
+ /* Manage Stack */
+ {"push", (PyCFunction)pygpu_matrix_push,
+ METH_NOARGS, pygpu_matrix_push_doc},
+ {"pop", (PyCFunction)pygpu_matrix_pop,
+ METH_NOARGS, pygpu_matrix_pop_doc},
+
+ {"push_projection", (PyCFunction)pygpu_matrix_push_projection,
+ METH_NOARGS, pygpu_matrix_push_projection_doc},
+ {"pop_projection", (PyCFunction)pygpu_matrix_pop_projection,
+ METH_NOARGS, pygpu_matrix_pop_projection_doc},
+
+ /* Stack (Context Manager) */
+ {"push_pop", (PyCFunction)pygpu_matrix_push_pop,
+ METH_NOARGS, pygpu_matrix_push_pop_doc},
+ {"push_pop_projection", (PyCFunction)pygpu_matrix_push_pop_projection,
+ METH_NOARGS, pygpu_matrix_push_pop_projection_doc},
+
+ /* Manipulate State */
+ {"multiply_matrix", (PyCFunction)pygpu_matrix_multiply_matrix,
+ METH_O, pygpu_matrix_multiply_matrix_doc},
+ {"scale", (PyCFunction)pygpu_matrix_scale,
+ METH_O, pygpu_matrix_scale_doc},
+ {"scale_uniform", (PyCFunction)pygpu_matrix_scale_uniform,
+ METH_O, pygpu_matrix_scale_uniform_doc},
+ {"translate", (PyCFunction)pygpu_matrix_translate,
+ METH_O, pygpu_matrix_translate_doc},
+
+ /* TODO */
+#if 0
+ {"rotate", (PyCFunction)pygpu_matrix_rotate,
+ METH_O, pygpu_matrix_rotate_doc},
+ {"rotate_axis", (PyCFunction)pygpu_matrix_rotate_axis,
+ METH_O, pygpu_matrix_rotate_axis_doc},
+ {"look_at", (PyCFunction)pygpu_matrix_look_at,
+ METH_O, pygpu_matrix_look_at_doc},
+#endif
+
+ /* Write State */
+ {"reset", (PyCFunction)pygpu_matrix_reset,
+ METH_NOARGS, pygpu_matrix_reset_doc},
+ {"load_identity", (PyCFunction)pygpu_matrix_load_identity,
+ METH_NOARGS, pygpu_matrix_load_identity_doc},
+ {"load_matrix", (PyCFunction)pygpu_matrix_load_matrix,
+ METH_O, pygpu_matrix_load_matrix_doc},
+
+ /* Read State */
+ {"get_projection_matrix", (PyCFunction)pygpu_matrix_get_projection_matrix,
+ METH_NOARGS, pygpu_matrix_get_projection_matrix_doc},
+ {"get_model_view_matrix", (PyCFunction)pygpu_matrix_get_modal_view_matrix,
+ METH_NOARGS, pygpu_matrix_get_modal_view_matrix_doc},
+ {"get_normal_matrix", (PyCFunction)pygpu_matrix_get_normal_matrix,
+ METH_NOARGS, pygpu_matrix_get_normal_matrix_doc},
+
+ {NULL, NULL, 0, NULL}
+};
+
+PyDoc_STRVAR(BPy_GPU_matrix_doc,
+"This module provides access to the matrix stack."
+);
+static PyModuleDef BPy_GPU_matrix_module_def = {
+ PyModuleDef_HEAD_INIT,
+ .m_name = "gpu.matrix",
+ .m_doc = BPy_GPU_matrix_doc,
+ .m_methods = BPy_GPU_matrix_methods,
+};
+
+PyObject *BPyInit_gpu_matrix(void)
+{
+ PyObject *submodule;
+
+ submodule = PyModule_Create(&BPy_GPU_matrix_module_def);
+
+ if (PyType_Ready(&pygpu_matrix_stack_context_Type) < 0) {
+ return NULL;
+ }
+
+ return submodule;
+}
+
+/** \} */
diff --git a/source/blender/python/intern/gpu_py_select.c b/source/blender/python/intern/gpu_py_select.c
new file mode 100644
index 00000000000..f570c4cdae2
--- /dev/null
+++ b/source/blender/python/intern/gpu_py_select.c
@@ -0,0 +1,92 @@
+/*
+ * ***** 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/python/intern/gpu_py_select.c
+ * \ingroup pythonintern
+ *
+ * This file defines the gpu.select API.
+ *
+ * \note Currently only used for manipulator selection,
+ * will need to add begin/end and a way to access the hits.
+ */
+
+#include <Python.h>
+
+#include "BLI_utildefines.h"
+
+#include "../generic/py_capi_utils.h"
+
+#include "gpu.h"
+
+#include "GPU_select.h"
+
+/* -------------------------------------------------------------------- */
+/** \name Methods
+ * \{ */
+
+PyDoc_STRVAR(pygpu_select_load_id_doc,
+"load_id(id)\n"
+"\n"
+" Set the selection ID.\n"
+"\n"
+" :param id: Number (32-bit unsigned int).\n"
+" :type select: int\n"
+);
+static PyObject *pygpu_select_load_id(PyObject *UNUSED(self), PyObject *value)
+{
+ uint id;
+ if ((id = PyC_Long_AsU32(value)) == (uint)-1) {
+ return NULL;
+ }
+ GPU_select_load_id(id);
+ Py_RETURN_NONE;
+}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Module
+ * \{ */
+
+static struct PyMethodDef BPy_GPU_select_methods[] = {
+ /* Manage Stack */
+ {"load_id", (PyCFunction)pygpu_select_load_id, METH_O, pygpu_select_load_id_doc},
+ {NULL, NULL, 0, NULL}
+};
+
+PyDoc_STRVAR(BPy_GPU_select_doc,
+"This module provides access to selection."
+);
+static PyModuleDef BPy_GPU_select_module_def = {
+ PyModuleDef_HEAD_INIT,
+ .m_name = "gpu.select",
+ .m_doc = BPy_GPU_select_doc,
+ .m_methods = BPy_GPU_select_methods,
+};
+
+PyObject *BPyInit_gpu_select(void)
+{
+ PyObject *submodule;
+
+ submodule = PyModule_Create(&BPy_GPU_select_module_def);
+
+ return submodule;
+}
+
+/** \} */
diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c
index 1afb1d7be90..96ae0a9e50f 100644
--- a/source/blender/python/mathutils/mathutils.c
+++ b/source/blender/python/mathutils/mathutils.c
@@ -554,8 +554,8 @@ char BaseMathObject_freeze_doc[] =
;
PyObject *BaseMathObject_freeze(BaseMathObject *self)
{
- if (self->flag & BASE_MATH_FLAG_IS_WRAP) {
- PyErr_SetString(PyExc_TypeError, "Cannot freeze wrapped data");
+ if ((self->flag & BASE_MATH_FLAG_IS_WRAP) || (self->cb_user != NULL)) {
+ PyErr_SetString(PyExc_TypeError, "Cannot freeze wrapped/owned data");
return NULL;
}
diff --git a/source/blender/python/mathutils/mathutils.h b/source/blender/python/mathutils/mathutils.h
index 6ac75565c66..d1fb6dcdb82 100644
--- a/source/blender/python/mathutils/mathutils.h
+++ b/source/blender/python/mathutils/mathutils.h
@@ -41,9 +41,18 @@ extern char BaseMathObject_owner_doc[];
(struct_name *)((base_type ? (base_type)->tp_alloc(base_type, 0) : _PyObject_GC_New(&(root_type))));
-/* BaseMathObject.flag */
+/** BaseMathObject.flag */
enum {
+ /**
+ * Do not own the memory used in this vector,
+ * \note This is error prone if the memory may be freed while this vector is in use.
+ * Prefer using callbacks where possible, see: #Mathutils_RegisterCallback
+ */
BASE_MATH_FLAG_IS_WRAP = (1 << 0),
+ /**
+ * Prevent changes to the vector so it can be used as a set or dictionary key for example.
+ * (typical use cases for tuple).
+ */
BASE_MATH_FLAG_IS_FROZEN = (1 << 1),
};
#define BASE_MATH_FLAG_DEFAULT 0
diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c
index e368e8871f3..2578b19d5ec 100644
--- a/source/blender/python/mathutils/mathutils_Matrix.c
+++ b/source/blender/python/mathutils/mathutils_Matrix.c
@@ -2914,6 +2914,73 @@ PyObject *Matrix_CreatePyObject_cb(PyObject *cb_user,
return (PyObject *) self;
}
+/**
+ * Use with PyArg_ParseTuple's "O&" formatting.
+ */
+static bool Matrix_ParseCheck(MatrixObject *pymat)
+{
+ if (!MatrixObject_Check(pymat)) {
+ PyErr_Format(PyExc_TypeError,
+ "expected a mathutils.Matrix, not a %.200s",
+ Py_TYPE(pymat)->tp_name);
+ return 0;
+ }
+ /* sets error */
+ if (BaseMath_ReadCallback(pymat) == -1) {
+ return 0;
+ }
+ return 1;
+}
+
+int Matrix_ParseAny(PyObject *o, void *p)
+{
+ MatrixObject **pymat_p = p;
+ MatrixObject *pymat = (MatrixObject *)o;
+
+ if (!Matrix_ParseCheck(pymat)) {
+ return 0;
+ }
+ *pymat_p = pymat;
+ return 1;
+}
+
+int Matrix_Parse3x3(PyObject *o, void *p)
+{
+ MatrixObject **pymat_p = p;
+ MatrixObject *pymat = (MatrixObject *)o;
+
+ if (!Matrix_ParseCheck(pymat)) {
+ return 0;
+ }
+ if ((pymat->num_col != 3) ||
+ (pymat->num_row != 3))
+ {
+ PyErr_SetString(PyExc_ValueError, "matrix must be 3x3");
+ return 0;
+ }
+
+ *pymat_p = pymat;
+ return 1;
+}
+
+int Matrix_Parse4x4(PyObject *o, void *p)
+{
+ MatrixObject **pymat_p = p;
+ MatrixObject *pymat = (MatrixObject *)o;
+
+ if (!Matrix_ParseCheck(pymat)) {
+ return 0;
+ }
+ if ((pymat->num_col != 4) ||
+ (pymat->num_row != 4))
+ {
+ PyErr_SetString(PyExc_ValueError, "matrix must be 4x4");
+ return 0;
+ }
+
+ *pymat_p = pymat;
+ return 1;
+}
/* ----------------------------------------------------------------------------
* special type for alternate access */
diff --git a/source/blender/python/mathutils/mathutils_Matrix.h b/source/blender/python/mathutils/mathutils_Matrix.h
index 542a0e349c7..9c84716d307 100644
--- a/source/blender/python/mathutils/mathutils_Matrix.h
+++ b/source/blender/python/mathutils/mathutils_Matrix.h
@@ -77,6 +77,11 @@ PyObject *Matrix_CreatePyObject_cb(
unsigned char cb_type, unsigned char cb_subtype
) ATTR_WARN_UNUSED_RESULT;
+/* PyArg_ParseTuple's "O&" formatting helpers. */
+int Matrix_ParseAny(PyObject *o, void *p);
+int Matrix_Parse3x3(PyObject *o, void *p);
+int Matrix_Parse4x4(PyObject *o, void *p);
+
extern unsigned char mathutils_matrix_row_cb_index; /* default */
extern unsigned char mathutils_matrix_col_cb_index;
extern unsigned char mathutils_matrix_translation_cb_index;
diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c
index afc8a30a6b5..65450505e08 100644
--- a/source/blender/python/mathutils/mathutils_Vector.c
+++ b/source/blender/python/mathutils/mathutils_Vector.c
@@ -32,10 +32,17 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
+#include "../generic/py_capi_utils.h"
+
#ifndef MATH_STANDALONE
# include "BLI_dynstr.h"
#endif
+/**
+ * Higher dimensions are supported, for many common operations
+ * (dealing with vector/matrix multiply or handling as 3D locations)
+ * stack memory is used with a fixed size - defined here.
+ */
#define MAX_DIMENSIONS 4
/* Swizzle axes get packed into a single value that is used as a closure. Each
@@ -50,7 +57,8 @@ static PyObject *Vector_deepcopy(VectorObject *self, PyObject *args);
static PyObject *Vector_to_tuple_ext(VectorObject *self, int ndigits);
static int row_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject *vec, MatrixObject *mat);
-/* Supports 2D, 3D, and 4D vector objects both int and float values
+/**
+ * Supports 2D, 3D, and 4D vector objects both int and float values
* accepted. Mixed float and int values accepted. Ints are parsed to float
*/
static PyObject *Vector_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
@@ -403,7 +411,7 @@ static PyObject *Vector_resize(VectorObject *self, PyObject *value)
return NULL;
}
- if ((size = PyLong_AsLong(value)) == -1) {
+ if ((size = PyC_Long_AsI32(value)) == -1) {
PyErr_SetString(PyExc_TypeError,
"Vector.resize(size): "
"expected size argument to be an integer");
@@ -836,9 +844,11 @@ static PyObject *Vector_orthogonal(VectorObject *self)
}
-/*
- * Vector.reflect(mirror): return a reflected vector on the mirror normal
- * vec - ((2 * DotVecs(vec, mirror)) * mirror)
+/**
+ * Vector.reflect(mirror): return a reflected vector on the mirror normal.
+ * <pre>
+ * vec - ((2 * dot(vec, mirror)) * mirror)
+ * </pre>
*/
PyDoc_STRVAR(Vector_reflect_doc,
".. method:: reflect(mirror)\n"
@@ -1644,13 +1654,16 @@ static PyObject *Vector_isub(PyObject *v1, PyObject *v2)
* multiplication */
-/* COLUMN VECTOR Multiplication (Matrix X Vector)
+/**
+ * column vector multiplication (Matrix * Vector)
+ * <pre>
* [1][4][7] [a]
* [2][5][8] * [b]
* [3][6][9] [c]
+ * </pre>
*
- * note: vector/matrix multiplication IS NOT COMMUTATIVE!!!!
- * note: assume read callbacks have been done first.
+ * \note Vector/Matrix multiplication is not commutative.
+ * \note Assume read callbacks have been done first.
*/
int column_vector_multiplication(float r_vec[MAX_DIMENSIONS], VectorObject *vec, MatrixObject *mat)
{
@@ -2199,9 +2212,67 @@ static PyObject *Vector_length_squared_get(VectorObject *self, void *UNUSED(clos
return PyFloat_FromDouble(dot_vn_vn(self->vec, self->vec, self->size));
}
-/* Get a new Vector according to the provided swizzle. This function has little
- * error checking, as we are in control of the inputs: the closure is set by us
- * in Vector_createSwizzleGetSeter. */
+
+/**
+ * Python script used to make swizzle array:
+ *
+ * \code{.py}
+ * SWIZZLE_BITS_PER_AXIS = 3
+ * SWIZZLE_VALID_AXIS = 0x4
+ *
+ * axis_dict = {}
+ * axis_pos = {'x': 0, 'y': 1, 'z': 2, 'w': 3}
+ * axises = 'xyzw'
+ * while len(axises) >= 2:
+ * for axis_0 in axises:
+ * axis_0_pos = axis_pos[axis_0]
+ * for axis_1 in axises:
+ * axis_1_pos = axis_pos[axis_1]
+ * axis_dict[axis_0 + axis_1] = (
+ * '((%s | SWIZZLE_VALID_AXIS) | '
+ * '((%s | SWIZZLE_VALID_AXIS) << SWIZZLE_BITS_PER_AXIS))' %
+ * (axis_0_pos, axis_1_pos))
+ * if len(axises) > 2:
+ * for axis_2 in axises:
+ * axis_2_pos = axis_pos[axis_2]
+ * axis_dict[axis_0 + axis_1 + axis_2] = (
+ * '((%s | SWIZZLE_VALID_AXIS) | '
+ * '((%s | SWIZZLE_VALID_AXIS) << SWIZZLE_BITS_PER_AXIS) | '
+ * '((%s | SWIZZLE_VALID_AXIS) << (SWIZZLE_BITS_PER_AXIS * 2)))' %
+ * (axis_0_pos, axis_1_pos, axis_2_pos))
+ * if len(axises) > 3:
+ * for axis_3 in axises:
+ * axis_3_pos = axis_pos[axis_3]
+ * axis_dict[axis_0 + axis_1 + axis_2 + axis_3] = (
+ * '((%s | SWIZZLE_VALID_AXIS) | '
+ * '((%s | SWIZZLE_VALID_AXIS) << SWIZZLE_BITS_PER_AXIS) | '
+ * '((%s | SWIZZLE_VALID_AXIS) << (SWIZZLE_BITS_PER_AXIS * 2)) | '
+ * '((%s | SWIZZLE_VALID_AXIS) << (SWIZZLE_BITS_PER_AXIS * 3))) ' %
+ * (axis_0_pos, axis_1_pos, axis_2_pos, axis_3_pos))
+ *
+ * axises = axises[:-1]
+ *
+ *
+ * items = list(axis_dict.items())
+ * items.sort(key=lambda a: a[0].replace('x', '0').replace('y', '1').replace('z', '2').replace('w', '3'))
+ *
+ * unique = set()
+ * for key, val in items:
+ * num = eval(val)
+ * set_str = 'Vector_swizzle_set' if (len(set(key)) == len(key)) else 'NULL'
+ * key_args = ', '.join(["'%s'" % c for c in key.upper()])
+ * print('\t{(char *)"%s", %s(getter)Vector_swizzle_get, (setter)%s, NULL, SWIZZLE%d(%s)},' %
+ * (key, (' ' * (4 - len(key))), set_str, len(key), key_args))
+ * unique.add(num)
+ *
+ * if len(unique) != len(items):
+ * print("ERROR, duplicate values found")
+ * \endcode
+ */
+
+/**
+ * Get a new Vector according to the provided swizzle bits.
+ */
static PyObject *Vector_swizzle_get(VectorObject *self, void *closure)
{
size_t axis_to;
@@ -2232,7 +2303,8 @@ static PyObject *Vector_swizzle_get(VectorObject *self, void *closure)
return Vector_CreatePyObject(vec, axis_to, Py_TYPE(self));
}
-/* Set the items of this vector using a swizzle.
+/**
+ * Set the items of this vector using a swizzle.
* - If value is a vector or list this operates like an array copy, except that
* the destination is effectively re-ordered as defined by the swizzle. At
* most min(len(source), len(dest)) values will be copied.
@@ -2240,8 +2312,8 @@ static PyObject *Vector_swizzle_get(VectorObject *self, void *closure)
* - If an axis appears more than once in the swizzle, the final occurrence is
* the one that determines its value.
*
- * Returns 0 on success and -1 on failure. On failure, the vector will be
- * unchanged. */
+ * \return 0 on success and -1 on failure. On failure, the vector will be unchanged.
+ */
static int Vector_swizzle_set(VectorObject *self, PyObject *value, void *closure)
{
size_t size_from;
@@ -2324,19 +2396,14 @@ static int Vector_swizzle_set(VectorObject *self, PyObject *value, void *closure
return 0;
}
-/* XYZW -> 0123 */
-#define AXIS_FROM_CHAR(a) (((a) != 'W') ? ((a) - 'X') : 3)
-
-#define _VA_SWIZZLE_1(a) ( \
- ((AXIS_FROM_CHAR(a) | SWIZZLE_VALID_AXIS)))
-#define _VA_SWIZZLE_2(a, b) (_VA_SWIZZLE_1(a) | \
- ((AXIS_FROM_CHAR(b) | SWIZZLE_VALID_AXIS) << (SWIZZLE_BITS_PER_AXIS)))
-#define _VA_SWIZZLE_3(a, b, c) (_VA_SWIZZLE_2(a, b) | \
- ((AXIS_FROM_CHAR(c) | SWIZZLE_VALID_AXIS) << (SWIZZLE_BITS_PER_AXIS * 2)))
-#define _VA_SWIZZLE_4(a, b, c, d) (_VA_SWIZZLE_3(a, b, c) | \
- ((AXIS_FROM_CHAR(d) | SWIZZLE_VALID_AXIS) << (SWIZZLE_BITS_PER_AXIS * 3)))
+#define _SWIZZLE1(a) ((a) | SWIZZLE_VALID_AXIS)
+#define _SWIZZLE2(a, b) (_SWIZZLE1(a) | (((b) | SWIZZLE_VALID_AXIS) << (SWIZZLE_BITS_PER_AXIS)))
+#define _SWIZZLE3(a, b, c) (_SWIZZLE2(a, b) | (((c) | SWIZZLE_VALID_AXIS) << (SWIZZLE_BITS_PER_AXIS * 2)))
+#define _SWIZZLE4(a, b, c, d) (_SWIZZLE3(a, b, c) | (((d) | SWIZZLE_VALID_AXIS) << (SWIZZLE_BITS_PER_AXIS * 3)))
-#define SWIZZLE(...) SET_INT_IN_POINTER(VA_NARGS_CALL_OVERLOAD(_VA_SWIZZLE_, __VA_ARGS__))
+#define SWIZZLE2(a, b) SET_INT_IN_POINTER(_SWIZZLE2(a, b))
+#define SWIZZLE3(a, b, c) SET_INT_IN_POINTER(_SWIZZLE3(a, b, c))
+#define SWIZZLE4(a, b, c, d) SET_INT_IN_POINTER(_SWIZZLE4(a, b, c, d))
/*****************************************************************************/
/* Python attributes get/set structure: */
@@ -2353,416 +2420,366 @@ static PyGetSetDef Vector_getseters[] = {
{(char *)"is_frozen", (getter)BaseMathObject_is_frozen_get, (setter)NULL, BaseMathObject_is_frozen_doc, NULL},
{(char *)"owner", (getter)BaseMathObject_owner_get, (setter)NULL, BaseMathObject_owner_doc, NULL},
- /* autogenerated swizzle attrs, see python script below */
- {(char *)"xx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'X')},
- {(char *)"xxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'X', 'X')},
- {(char *)"xxxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'X', 'X', 'X')},
- {(char *)"xxxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'X', 'X', 'Y')},
- {(char *)"xxxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'X', 'X', 'Z')},
- {(char *)"xxxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'X', 'X', 'W')},
- {(char *)"xxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'X', 'Y')},
- {(char *)"xxyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'X', 'Y', 'X')},
- {(char *)"xxyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'X', 'Y', 'Y')},
- {(char *)"xxyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'X', 'Y', 'Z')},
- {(char *)"xxyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'X', 'Y', 'W')},
- {(char *)"xxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'X', 'Z')},
- {(char *)"xxzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'X', 'Z', 'X')},
- {(char *)"xxzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'X', 'Z', 'Y')},
- {(char *)"xxzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'X', 'Z', 'Z')},
- {(char *)"xxzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'X', 'Z', 'W')},
- {(char *)"xxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'X', 'W')},
- {(char *)"xxwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'X', 'W', 'X')},
- {(char *)"xxwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'X', 'W', 'Y')},
- {(char *)"xxwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'X', 'W', 'Z')},
- {(char *)"xxww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'X', 'W', 'W')},
- {(char *)"xy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('X', 'Y')},
- {(char *)"xyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Y', 'X')},
- {(char *)"xyxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Y', 'X', 'X')},
- {(char *)"xyxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Y', 'X', 'Y')},
- {(char *)"xyxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Y', 'X', 'Z')},
- {(char *)"xyxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Y', 'X', 'W')},
- {(char *)"xyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Y', 'Y')},
- {(char *)"xyyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Y', 'Y', 'X')},
- {(char *)"xyyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Y', 'Y', 'Y')},
- {(char *)"xyyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Y', 'Y', 'Z')},
- {(char *)"xyyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Y', 'Y', 'W')},
- {(char *)"xyz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('X', 'Y', 'Z')},
- {(char *)"xyzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Y', 'Z', 'X')},
- {(char *)"xyzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Y', 'Z', 'Y')},
- {(char *)"xyzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Y', 'Z', 'Z')},
- {(char *)"xyzw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('X', 'Y', 'Z', 'W')},
- {(char *)"xyw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('X', 'Y', 'W')},
- {(char *)"xywx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Y', 'W', 'X')},
- {(char *)"xywy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Y', 'W', 'Y')},
- {(char *)"xywz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('X', 'Y', 'W', 'Z')},
- {(char *)"xyww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Y', 'W', 'W')},
- {(char *)"xz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('X', 'Z')},
- {(char *)"xzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Z', 'X')},
- {(char *)"xzxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Z', 'X', 'X')},
- {(char *)"xzxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Z', 'X', 'Y')},
- {(char *)"xzxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Z', 'X', 'Z')},
- {(char *)"xzxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Z', 'X', 'W')},
- {(char *)"xzy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('X', 'Z', 'Y')},
- {(char *)"xzyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Z', 'Y', 'X')},
- {(char *)"xzyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Z', 'Y', 'Y')},
- {(char *)"xzyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Z', 'Y', 'Z')},
- {(char *)"xzyw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('X', 'Z', 'Y', 'W')},
- {(char *)"xzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Z', 'Z')},
- {(char *)"xzzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Z', 'Z', 'X')},
- {(char *)"xzzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Z', 'Z', 'Y')},
- {(char *)"xzzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Z', 'Z', 'Z')},
- {(char *)"xzzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Z', 'Z', 'W')},
- {(char *)"xzw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('X', 'Z', 'W')},
- {(char *)"xzwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Z', 'W', 'X')},
- {(char *)"xzwy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('X', 'Z', 'W', 'Y')},
- {(char *)"xzwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Z', 'W', 'Z')},
- {(char *)"xzww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'Z', 'W', 'W')},
- {(char *)"xw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('X', 'W')},
- {(char *)"xwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'W', 'X')},
- {(char *)"xwxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'W', 'X', 'X')},
- {(char *)"xwxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'W', 'X', 'Y')},
- {(char *)"xwxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'W', 'X', 'Z')},
- {(char *)"xwxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'W', 'X', 'W')},
- {(char *)"xwy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('X', 'W', 'Y')},
- {(char *)"xwyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'W', 'Y', 'X')},
- {(char *)"xwyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'W', 'Y', 'Y')},
- {(char *)"xwyz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('X', 'W', 'Y', 'Z')},
- {(char *)"xwyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'W', 'Y', 'W')},
- {(char *)"xwz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('X', 'W', 'Z')},
- {(char *)"xwzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'W', 'Z', 'X')},
- {(char *)"xwzy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('X', 'W', 'Z', 'Y')},
- {(char *)"xwzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'W', 'Z', 'Z')},
- {(char *)"xwzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'W', 'Z', 'W')},
- {(char *)"xww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'W', 'W')},
- {(char *)"xwwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'W', 'W', 'X')},
- {(char *)"xwwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'W', 'W', 'Y')},
- {(char *)"xwwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'W', 'W', 'Z')},
- {(char *)"xwww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('X', 'W', 'W', 'W')},
- {(char *)"yx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('Y', 'X')},
- {(char *)"yxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'X', 'X')},
- {(char *)"yxxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'X', 'X', 'X')},
- {(char *)"yxxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'X', 'X', 'Y')},
- {(char *)"yxxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'X', 'X', 'Z')},
- {(char *)"yxxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'X', 'X', 'W')},
- {(char *)"yxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'X', 'Y')},
- {(char *)"yxyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'X', 'Y', 'X')},
- {(char *)"yxyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'X', 'Y', 'Y')},
- {(char *)"yxyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'X', 'Y', 'Z')},
- {(char *)"yxyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'X', 'Y', 'W')},
- {(char *)"yxz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('Y', 'X', 'Z')},
- {(char *)"yxzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'X', 'Z', 'X')},
- {(char *)"yxzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'X', 'Z', 'Y')},
- {(char *)"yxzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'X', 'Z', 'Z')},
- {(char *)"yxzw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('Y', 'X', 'Z', 'W')},
- {(char *)"yxw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('Y', 'X', 'W')},
- {(char *)"yxwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'X', 'W', 'X')},
- {(char *)"yxwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'X', 'W', 'Y')},
- {(char *)"yxwz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('Y', 'X', 'W', 'Z')},
- {(char *)"yxww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'X', 'W', 'W')},
- {(char *)"yy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Y')},
- {(char *)"yyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Y', 'X')},
- {(char *)"yyxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Y', 'X', 'X')},
- {(char *)"yyxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Y', 'X', 'Y')},
- {(char *)"yyxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Y', 'X', 'Z')},
- {(char *)"yyxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Y', 'X', 'W')},
- {(char *)"yyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Y', 'Y')},
- {(char *)"yyyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Y', 'Y', 'X')},
- {(char *)"yyyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Y', 'Y', 'Y')},
- {(char *)"yyyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Y', 'Y', 'Z')},
- {(char *)"yyyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Y', 'Y', 'W')},
- {(char *)"yyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Y', 'Z')},
- {(char *)"yyzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Y', 'Z', 'X')},
- {(char *)"yyzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Y', 'Z', 'Y')},
- {(char *)"yyzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Y', 'Z', 'Z')},
- {(char *)"yyzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Y', 'Z', 'W')},
- {(char *)"yyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Y', 'W')},
- {(char *)"yywx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Y', 'W', 'X')},
- {(char *)"yywy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Y', 'W', 'Y')},
- {(char *)"yywz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Y', 'W', 'Z')},
- {(char *)"yyww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Y', 'W', 'W')},
- {(char *)"yz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('Y', 'Z')},
- {(char *)"yzx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('Y', 'Z', 'X')},
- {(char *)"yzxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Z', 'X', 'X')},
- {(char *)"yzxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Z', 'X', 'Y')},
- {(char *)"yzxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Z', 'X', 'Z')},
- {(char *)"yzxw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('Y', 'Z', 'X', 'W')},
- {(char *)"yzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Z', 'Y')},
- {(char *)"yzyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Z', 'Y', 'X')},
- {(char *)"yzyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Z', 'Y', 'Y')},
- {(char *)"yzyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Z', 'Y', 'Z')},
- {(char *)"yzyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Z', 'Y', 'W')},
- {(char *)"yzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Z', 'Z')},
- {(char *)"yzzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Z', 'Z', 'X')},
- {(char *)"yzzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Z', 'Z', 'Y')},
- {(char *)"yzzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Z', 'Z', 'Z')},
- {(char *)"yzzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Z', 'Z', 'W')},
- {(char *)"yzw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('Y', 'Z', 'W')},
- {(char *)"yzwx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('Y', 'Z', 'W', 'X')},
- {(char *)"yzwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Z', 'W', 'Y')},
- {(char *)"yzwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Z', 'W', 'Z')},
- {(char *)"yzww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'Z', 'W', 'W')},
- {(char *)"yw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('Y', 'W')},
- {(char *)"ywx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('Y', 'W', 'X')},
- {(char *)"ywxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'W', 'X', 'X')},
- {(char *)"ywxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'W', 'X', 'Y')},
- {(char *)"ywxz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('Y', 'W', 'X', 'Z')},
- {(char *)"ywxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'W', 'X', 'W')},
- {(char *)"ywy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'W', 'Y')},
- {(char *)"ywyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'W', 'Y', 'X')},
- {(char *)"ywyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'W', 'Y', 'Y')},
- {(char *)"ywyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'W', 'Y', 'Z')},
- {(char *)"ywyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'W', 'Y', 'W')},
- {(char *)"ywz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('Y', 'W', 'Z')},
- {(char *)"ywzx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('Y', 'W', 'Z', 'X')},
- {(char *)"ywzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'W', 'Z', 'Y')},
- {(char *)"ywzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'W', 'Z', 'Z')},
- {(char *)"ywzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'W', 'Z', 'W')},
- {(char *)"yww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'W', 'W')},
- {(char *)"ywwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'W', 'W', 'X')},
- {(char *)"ywwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'W', 'W', 'Y')},
- {(char *)"ywwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'W', 'W', 'Z')},
- {(char *)"ywww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Y', 'W', 'W', 'W')},
- {(char *)"zx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('Z', 'X')},
- {(char *)"zxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'X', 'X')},
- {(char *)"zxxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'X', 'X', 'X')},
- {(char *)"zxxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'X', 'X', 'Y')},
- {(char *)"zxxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'X', 'X', 'Z')},
- {(char *)"zxxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'X', 'X', 'W')},
- {(char *)"zxy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('Z', 'X', 'Y')},
- {(char *)"zxyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'X', 'Y', 'X')},
- {(char *)"zxyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'X', 'Y', 'Y')},
- {(char *)"zxyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'X', 'Y', 'Z')},
- {(char *)"zxyw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('Z', 'X', 'Y', 'W')},
- {(char *)"zxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'X', 'Z')},
- {(char *)"zxzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'X', 'Z', 'X')},
- {(char *)"zxzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'X', 'Z', 'Y')},
- {(char *)"zxzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'X', 'Z', 'Z')},
- {(char *)"zxzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'X', 'Z', 'W')},
- {(char *)"zxw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('Z', 'X', 'W')},
- {(char *)"zxwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'X', 'W', 'X')},
- {(char *)"zxwy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('Z', 'X', 'W', 'Y')},
- {(char *)"zxwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'X', 'W', 'Z')},
- {(char *)"zxww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'X', 'W', 'W')},
- {(char *)"zy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('Z', 'Y')},
- {(char *)"zyx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('Z', 'Y', 'X')},
- {(char *)"zyxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Y', 'X', 'X')},
- {(char *)"zyxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Y', 'X', 'Y')},
- {(char *)"zyxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Y', 'X', 'Z')},
- {(char *)"zyxw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('Z', 'Y', 'X', 'W')},
- {(char *)"zyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Y', 'Y')},
- {(char *)"zyyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Y', 'Y', 'X')},
- {(char *)"zyyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Y', 'Y', 'Y')},
- {(char *)"zyyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Y', 'Y', 'Z')},
- {(char *)"zyyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Y', 'Y', 'W')},
- {(char *)"zyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Y', 'Z')},
- {(char *)"zyzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Y', 'Z', 'X')},
- {(char *)"zyzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Y', 'Z', 'Y')},
- {(char *)"zyzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Y', 'Z', 'Z')},
- {(char *)"zyzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Y', 'Z', 'W')},
- {(char *)"zyw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('Z', 'Y', 'W')},
- {(char *)"zywx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('Z', 'Y', 'W', 'X')},
- {(char *)"zywy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Y', 'W', 'Y')},
- {(char *)"zywz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Y', 'W', 'Z')},
- {(char *)"zyww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Y', 'W', 'W')},
- {(char *)"zz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Z')},
- {(char *)"zzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Z', 'X')},
- {(char *)"zzxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Z', 'X', 'X')},
- {(char *)"zzxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Z', 'X', 'Y')},
- {(char *)"zzxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Z', 'X', 'Z')},
- {(char *)"zzxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Z', 'X', 'W')},
- {(char *)"zzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Z', 'Y')},
- {(char *)"zzyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Z', 'Y', 'X')},
- {(char *)"zzyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Z', 'Y', 'Y')},
- {(char *)"zzyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Z', 'Y', 'Z')},
- {(char *)"zzyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Z', 'Y', 'W')},
- {(char *)"zzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Z', 'Z')},
- {(char *)"zzzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Z', 'Z', 'X')},
- {(char *)"zzzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Z', 'Z', 'Y')},
- {(char *)"zzzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Z', 'Z', 'Z')},
- {(char *)"zzzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Z', 'Z', 'W')},
- {(char *)"zzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Z', 'W')},
- {(char *)"zzwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Z', 'W', 'X')},
- {(char *)"zzwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Z', 'W', 'Y')},
- {(char *)"zzwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Z', 'W', 'Z')},
- {(char *)"zzww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'Z', 'W', 'W')},
- {(char *)"zw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('Z', 'W')},
- {(char *)"zwx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('Z', 'W', 'X')},
- {(char *)"zwxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'W', 'X', 'X')},
- {(char *)"zwxy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('Z', 'W', 'X', 'Y')},
- {(char *)"zwxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'W', 'X', 'Z')},
- {(char *)"zwxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'W', 'X', 'W')},
- {(char *)"zwy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('Z', 'W', 'Y')},
- {(char *)"zwyx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('Z', 'W', 'Y', 'X')},
- {(char *)"zwyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'W', 'Y', 'Y')},
- {(char *)"zwyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'W', 'Y', 'Z')},
- {(char *)"zwyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'W', 'Y', 'W')},
- {(char *)"zwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'W', 'Z')},
- {(char *)"zwzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'W', 'Z', 'X')},
- {(char *)"zwzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'W', 'Z', 'Y')},
- {(char *)"zwzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'W', 'Z', 'Z')},
- {(char *)"zwzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'W', 'Z', 'W')},
- {(char *)"zww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'W', 'W')},
- {(char *)"zwwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'W', 'W', 'X')},
- {(char *)"zwwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'W', 'W', 'Y')},
- {(char *)"zwwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'W', 'W', 'Z')},
- {(char *)"zwww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('Z', 'W', 'W', 'W')},
- {(char *)"wx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('W', 'X')},
- {(char *)"wxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'X', 'X')},
- {(char *)"wxxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'X', 'X', 'X')},
- {(char *)"wxxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'X', 'X', 'Y')},
- {(char *)"wxxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'X', 'X', 'Z')},
- {(char *)"wxxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'X', 'X', 'W')},
- {(char *)"wxy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('W', 'X', 'Y')},
- {(char *)"wxyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'X', 'Y', 'X')},
- {(char *)"wxyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'X', 'Y', 'Y')},
- {(char *)"wxyz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('W', 'X', 'Y', 'Z')},
- {(char *)"wxyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'X', 'Y', 'W')},
- {(char *)"wxz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('W', 'X', 'Z')},
- {(char *)"wxzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'X', 'Z', 'X')},
- {(char *)"wxzy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('W', 'X', 'Z', 'Y')},
- {(char *)"wxzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'X', 'Z', 'Z')},
- {(char *)"wxzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'X', 'Z', 'W')},
- {(char *)"wxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'X', 'W')},
- {(char *)"wxwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'X', 'W', 'X')},
- {(char *)"wxwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'X', 'W', 'Y')},
- {(char *)"wxwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'X', 'W', 'Z')},
- {(char *)"wxww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'X', 'W', 'W')},
- {(char *)"wy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('W', 'Y')},
- {(char *)"wyx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('W', 'Y', 'X')},
- {(char *)"wyxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Y', 'X', 'X')},
- {(char *)"wyxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Y', 'X', 'Y')},
- {(char *)"wyxz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('W', 'Y', 'X', 'Z')},
- {(char *)"wyxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Y', 'X', 'W')},
- {(char *)"wyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Y', 'Y')},
- {(char *)"wyyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Y', 'Y', 'X')},
- {(char *)"wyyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Y', 'Y', 'Y')},
- {(char *)"wyyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Y', 'Y', 'Z')},
- {(char *)"wyyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Y', 'Y', 'W')},
- {(char *)"wyz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('W', 'Y', 'Z')},
- {(char *)"wyzx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('W', 'Y', 'Z', 'X')},
- {(char *)"wyzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Y', 'Z', 'Y')},
- {(char *)"wyzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Y', 'Z', 'Z')},
- {(char *)"wyzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Y', 'Z', 'W')},
- {(char *)"wyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Y', 'W')},
- {(char *)"wywx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Y', 'W', 'X')},
- {(char *)"wywy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Y', 'W', 'Y')},
- {(char *)"wywz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Y', 'W', 'Z')},
- {(char *)"wyww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Y', 'W', 'W')},
- {(char *)"wz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('W', 'Z')},
- {(char *)"wzx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('W', 'Z', 'X')},
- {(char *)"wzxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Z', 'X', 'X')},
- {(char *)"wzxy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('W', 'Z', 'X', 'Y')},
- {(char *)"wzxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Z', 'X', 'Z')},
- {(char *)"wzxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Z', 'X', 'W')},
- {(char *)"wzy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('W', 'Z', 'Y')},
- {(char *)"wzyx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE('W', 'Z', 'Y', 'X')},
- {(char *)"wzyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Z', 'Y', 'Y')},
- {(char *)"wzyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Z', 'Y', 'Z')},
- {(char *)"wzyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Z', 'Y', 'W')},
- {(char *)"wzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Z', 'Z')},
- {(char *)"wzzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Z', 'Z', 'X')},
- {(char *)"wzzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Z', 'Z', 'Y')},
- {(char *)"wzzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Z', 'Z', 'Z')},
- {(char *)"wzzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Z', 'Z', 'W')},
- {(char *)"wzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Z', 'W')},
- {(char *)"wzwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Z', 'W', 'X')},
- {(char *)"wzwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Z', 'W', 'Y')},
- {(char *)"wzwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Z', 'W', 'Z')},
- {(char *)"wzww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'Z', 'W', 'W')},
- {(char *)"ww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'W')},
- {(char *)"wwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'W', 'X')},
- {(char *)"wwxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'W', 'X', 'X')},
- {(char *)"wwxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'W', 'X', 'Y')},
- {(char *)"wwxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'W', 'X', 'Z')},
- {(char *)"wwxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'W', 'X', 'W')},
- {(char *)"wwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'W', 'Y')},
- {(char *)"wwyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'W', 'Y', 'X')},
- {(char *)"wwyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'W', 'Y', 'Y')},
- {(char *)"wwyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'W', 'Y', 'Z')},
- {(char *)"wwyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'W', 'Y', 'W')},
- {(char *)"wwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'W', 'Z')},
- {(char *)"wwzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'W', 'Z', 'X')},
- {(char *)"wwzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'W', 'Z', 'Y')},
- {(char *)"wwzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'W', 'Z', 'Z')},
- {(char *)"wwzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'W', 'Z', 'W')},
- {(char *)"www", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'W', 'W')},
- {(char *)"wwwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'W', 'W', 'X')},
- {(char *)"wwwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'W', 'W', 'Y')},
- {(char *)"wwwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'W', 'W', 'Z')},
- {(char *)"wwww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE('W', 'W', 'W', 'W')},
+ /* autogenerated swizzle attrs, see Python script above */
+ {(char *)"xx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE2(0, 0)},
+ {(char *)"xxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(0, 0, 0)},
+ {(char *)"xxxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 0, 0)},
+ {(char *)"xxxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 0, 1)},
+ {(char *)"xxxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 0, 2)},
+ {(char *)"xxxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 0, 3)},
+ {(char *)"xxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(0, 0, 1)},
+ {(char *)"xxyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 1, 0)},
+ {(char *)"xxyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 1, 1)},
+ {(char *)"xxyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 1, 2)},
+ {(char *)"xxyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 1, 3)},
+ {(char *)"xxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(0, 0, 2)},
+ {(char *)"xxzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 2, 0)},
+ {(char *)"xxzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 2, 1)},
+ {(char *)"xxzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 2, 2)},
+ {(char *)"xxzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 2, 3)},
+ {(char *)"xxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(0, 0, 3)},
+ {(char *)"xxwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 3, 0)},
+ {(char *)"xxwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 3, 1)},
+ {(char *)"xxwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 3, 2)},
+ {(char *)"xxww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 0, 3, 3)},
+ {(char *)"xy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE2(0, 1)},
+ {(char *)"xyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(0, 1, 0)},
+ {(char *)"xyxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 1, 0, 0)},
+ {(char *)"xyxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 1, 0, 1)},
+ {(char *)"xyxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 1, 0, 2)},
+ {(char *)"xyxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 1, 0, 3)},
+ {(char *)"xyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(0, 1, 1)},
+ {(char *)"xyyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 1, 1, 0)},
+ {(char *)"xyyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 1, 1, 1)},
+ {(char *)"xyyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 1, 1, 2)},
+ {(char *)"xyyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 1, 1, 3)},
+ {(char *)"xyz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(0, 1, 2)},
+ {(char *)"xyzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 1, 2, 0)},
+ {(char *)"xyzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 1, 2, 1)},
+ {(char *)"xyzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 1, 2, 2)},
+ {(char *)"xyzw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(0, 1, 2, 3)},
+ {(char *)"xyw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(0, 1, 3)},
+ {(char *)"xywx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 1, 3, 0)},
+ {(char *)"xywy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 1, 3, 1)},
+ {(char *)"xywz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(0, 1, 3, 2)},
+ {(char *)"xyww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 1, 3, 3)},
+ {(char *)"xz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE2(0, 2)},
+ {(char *)"xzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(0, 2, 0)},
+ {(char *)"xzxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 2, 0, 0)},
+ {(char *)"xzxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 2, 0, 1)},
+ {(char *)"xzxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 2, 0, 2)},
+ {(char *)"xzxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 2, 0, 3)},
+ {(char *)"xzy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(0, 2, 1)},
+ {(char *)"xzyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 2, 1, 0)},
+ {(char *)"xzyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 2, 1, 1)},
+ {(char *)"xzyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 2, 1, 2)},
+ {(char *)"xzyw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(0, 2, 1, 3)},
+ {(char *)"xzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(0, 2, 2)},
+ {(char *)"xzzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 2, 2, 0)},
+ {(char *)"xzzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 2, 2, 1)},
+ {(char *)"xzzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 2, 2, 2)},
+ {(char *)"xzzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 2, 2, 3)},
+ {(char *)"xzw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(0, 2, 3)},
+ {(char *)"xzwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 2, 3, 0)},
+ {(char *)"xzwy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(0, 2, 3, 1)},
+ {(char *)"xzwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 2, 3, 2)},
+ {(char *)"xzww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 2, 3, 3)},
+ {(char *)"xw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE2(0, 3)},
+ {(char *)"xwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(0, 3, 0)},
+ {(char *)"xwxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 3, 0, 0)},
+ {(char *)"xwxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 3, 0, 1)},
+ {(char *)"xwxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 3, 0, 2)},
+ {(char *)"xwxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 3, 0, 3)},
+ {(char *)"xwy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(0, 3, 1)},
+ {(char *)"xwyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 3, 1, 0)},
+ {(char *)"xwyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 3, 1, 1)},
+ {(char *)"xwyz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(0, 3, 1, 2)},
+ {(char *)"xwyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 3, 1, 3)},
+ {(char *)"xwz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(0, 3, 2)},
+ {(char *)"xwzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 3, 2, 0)},
+ {(char *)"xwzy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(0, 3, 2, 1)},
+ {(char *)"xwzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 3, 2, 2)},
+ {(char *)"xwzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 3, 2, 3)},
+ {(char *)"xww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(0, 3, 3)},
+ {(char *)"xwwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 3, 3, 0)},
+ {(char *)"xwwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 3, 3, 1)},
+ {(char *)"xwwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 3, 3, 2)},
+ {(char *)"xwww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(0, 3, 3, 3)},
+ {(char *)"yx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE2(1, 0)},
+ {(char *)"yxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(1, 0, 0)},
+ {(char *)"yxxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 0, 0, 0)},
+ {(char *)"yxxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 0, 0, 1)},
+ {(char *)"yxxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 0, 0, 2)},
+ {(char *)"yxxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 0, 0, 3)},
+ {(char *)"yxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(1, 0, 1)},
+ {(char *)"yxyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 0, 1, 0)},
+ {(char *)"yxyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 0, 1, 1)},
+ {(char *)"yxyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 0, 1, 2)},
+ {(char *)"yxyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 0, 1, 3)},
+ {(char *)"yxz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(1, 0, 2)},
+ {(char *)"yxzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 0, 2, 0)},
+ {(char *)"yxzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 0, 2, 1)},
+ {(char *)"yxzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 0, 2, 2)},
+ {(char *)"yxzw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(1, 0, 2, 3)},
+ {(char *)"yxw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(1, 0, 3)},
+ {(char *)"yxwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 0, 3, 0)},
+ {(char *)"yxwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 0, 3, 1)},
+ {(char *)"yxwz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(1, 0, 3, 2)},
+ {(char *)"yxww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 0, 3, 3)},
+ {(char *)"yy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE2(1, 1)},
+ {(char *)"yyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(1, 1, 0)},
+ {(char *)"yyxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 0, 0)},
+ {(char *)"yyxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 0, 1)},
+ {(char *)"yyxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 0, 2)},
+ {(char *)"yyxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 0, 3)},
+ {(char *)"yyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(1, 1, 1)},
+ {(char *)"yyyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 1, 0)},
+ {(char *)"yyyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 1, 1)},
+ {(char *)"yyyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 1, 2)},
+ {(char *)"yyyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 1, 3)},
+ {(char *)"yyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(1, 1, 2)},
+ {(char *)"yyzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 2, 0)},
+ {(char *)"yyzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 2, 1)},
+ {(char *)"yyzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 2, 2)},
+ {(char *)"yyzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 2, 3)},
+ {(char *)"yyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(1, 1, 3)},
+ {(char *)"yywx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 3, 0)},
+ {(char *)"yywy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 3, 1)},
+ {(char *)"yywz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 3, 2)},
+ {(char *)"yyww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 1, 3, 3)},
+ {(char *)"yz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE2(1, 2)},
+ {(char *)"yzx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(1, 2, 0)},
+ {(char *)"yzxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 2, 0, 0)},
+ {(char *)"yzxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 2, 0, 1)},
+ {(char *)"yzxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 2, 0, 2)},
+ {(char *)"yzxw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(1, 2, 0, 3)},
+ {(char *)"yzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(1, 2, 1)},
+ {(char *)"yzyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 2, 1, 0)},
+ {(char *)"yzyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 2, 1, 1)},
+ {(char *)"yzyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 2, 1, 2)},
+ {(char *)"yzyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 2, 1, 3)},
+ {(char *)"yzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(1, 2, 2)},
+ {(char *)"yzzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 2, 2, 0)},
+ {(char *)"yzzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 2, 2, 1)},
+ {(char *)"yzzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 2, 2, 2)},
+ {(char *)"yzzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 2, 2, 3)},
+ {(char *)"yzw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(1, 2, 3)},
+ {(char *)"yzwx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(1, 2, 3, 0)},
+ {(char *)"yzwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 2, 3, 1)},
+ {(char *)"yzwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 2, 3, 2)},
+ {(char *)"yzww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 2, 3, 3)},
+ {(char *)"yw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE2(1, 3)},
+ {(char *)"ywx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(1, 3, 0)},
+ {(char *)"ywxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 3, 0, 0)},
+ {(char *)"ywxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 3, 0, 1)},
+ {(char *)"ywxz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(1, 3, 0, 2)},
+ {(char *)"ywxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 3, 0, 3)},
+ {(char *)"ywy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(1, 3, 1)},
+ {(char *)"ywyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 3, 1, 0)},
+ {(char *)"ywyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 3, 1, 1)},
+ {(char *)"ywyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 3, 1, 2)},
+ {(char *)"ywyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 3, 1, 3)},
+ {(char *)"ywz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(1, 3, 2)},
+ {(char *)"ywzx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(1, 3, 2, 0)},
+ {(char *)"ywzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 3, 2, 1)},
+ {(char *)"ywzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 3, 2, 2)},
+ {(char *)"ywzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 3, 2, 3)},
+ {(char *)"yww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(1, 3, 3)},
+ {(char *)"ywwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 3, 3, 0)},
+ {(char *)"ywwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 3, 3, 1)},
+ {(char *)"ywwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 3, 3, 2)},
+ {(char *)"ywww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(1, 3, 3, 3)},
+ {(char *)"zx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE2(2, 0)},
+ {(char *)"zxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(2, 0, 0)},
+ {(char *)"zxxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 0, 0, 0)},
+ {(char *)"zxxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 0, 0, 1)},
+ {(char *)"zxxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 0, 0, 2)},
+ {(char *)"zxxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 0, 0, 3)},
+ {(char *)"zxy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(2, 0, 1)},
+ {(char *)"zxyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 0, 1, 0)},
+ {(char *)"zxyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 0, 1, 1)},
+ {(char *)"zxyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 0, 1, 2)},
+ {(char *)"zxyw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(2, 0, 1, 3)},
+ {(char *)"zxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(2, 0, 2)},
+ {(char *)"zxzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 0, 2, 0)},
+ {(char *)"zxzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 0, 2, 1)},
+ {(char *)"zxzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 0, 2, 2)},
+ {(char *)"zxzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 0, 2, 3)},
+ {(char *)"zxw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(2, 0, 3)},
+ {(char *)"zxwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 0, 3, 0)},
+ {(char *)"zxwy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(2, 0, 3, 1)},
+ {(char *)"zxwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 0, 3, 2)},
+ {(char *)"zxww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 0, 3, 3)},
+ {(char *)"zy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE2(2, 1)},
+ {(char *)"zyx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(2, 1, 0)},
+ {(char *)"zyxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 1, 0, 0)},
+ {(char *)"zyxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 1, 0, 1)},
+ {(char *)"zyxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 1, 0, 2)},
+ {(char *)"zyxw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(2, 1, 0, 3)},
+ {(char *)"zyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(2, 1, 1)},
+ {(char *)"zyyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 1, 1, 0)},
+ {(char *)"zyyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 1, 1, 1)},
+ {(char *)"zyyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 1, 1, 2)},
+ {(char *)"zyyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 1, 1, 3)},
+ {(char *)"zyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(2, 1, 2)},
+ {(char *)"zyzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 1, 2, 0)},
+ {(char *)"zyzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 1, 2, 1)},
+ {(char *)"zyzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 1, 2, 2)},
+ {(char *)"zyzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 1, 2, 3)},
+ {(char *)"zyw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(2, 1, 3)},
+ {(char *)"zywx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(2, 1, 3, 0)},
+ {(char *)"zywy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 1, 3, 1)},
+ {(char *)"zywz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 1, 3, 2)},
+ {(char *)"zyww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 1, 3, 3)},
+ {(char *)"zz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE2(2, 2)},
+ {(char *)"zzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(2, 2, 0)},
+ {(char *)"zzxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 0, 0)},
+ {(char *)"zzxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 0, 1)},
+ {(char *)"zzxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 0, 2)},
+ {(char *)"zzxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 0, 3)},
+ {(char *)"zzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(2, 2, 1)},
+ {(char *)"zzyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 1, 0)},
+ {(char *)"zzyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 1, 1)},
+ {(char *)"zzyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 1, 2)},
+ {(char *)"zzyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 1, 3)},
+ {(char *)"zzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(2, 2, 2)},
+ {(char *)"zzzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 2, 0)},
+ {(char *)"zzzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 2, 1)},
+ {(char *)"zzzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 2, 2)},
+ {(char *)"zzzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 2, 3)},
+ {(char *)"zzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(2, 2, 3)},
+ {(char *)"zzwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 3, 0)},
+ {(char *)"zzwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 3, 1)},
+ {(char *)"zzwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 3, 2)},
+ {(char *)"zzww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 2, 3, 3)},
+ {(char *)"zw", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE2(2, 3)},
+ {(char *)"zwx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(2, 3, 0)},
+ {(char *)"zwxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 3, 0, 0)},
+ {(char *)"zwxy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(2, 3, 0, 1)},
+ {(char *)"zwxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 3, 0, 2)},
+ {(char *)"zwxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 3, 0, 3)},
+ {(char *)"zwy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(2, 3, 1)},
+ {(char *)"zwyx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(2, 3, 1, 0)},
+ {(char *)"zwyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 3, 1, 1)},
+ {(char *)"zwyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 3, 1, 2)},
+ {(char *)"zwyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 3, 1, 3)},
+ {(char *)"zwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(2, 3, 2)},
+ {(char *)"zwzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 3, 2, 0)},
+ {(char *)"zwzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 3, 2, 1)},
+ {(char *)"zwzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 3, 2, 2)},
+ {(char *)"zwzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 3, 2, 3)},
+ {(char *)"zww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(2, 3, 3)},
+ {(char *)"zwwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 3, 3, 0)},
+ {(char *)"zwwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 3, 3, 1)},
+ {(char *)"zwwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 3, 3, 2)},
+ {(char *)"zwww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(2, 3, 3, 3)},
+ {(char *)"wx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE2(3, 0)},
+ {(char *)"wxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(3, 0, 0)},
+ {(char *)"wxxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 0, 0, 0)},
+ {(char *)"wxxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 0, 0, 1)},
+ {(char *)"wxxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 0, 0, 2)},
+ {(char *)"wxxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 0, 0, 3)},
+ {(char *)"wxy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(3, 0, 1)},
+ {(char *)"wxyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 0, 1, 0)},
+ {(char *)"wxyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 0, 1, 1)},
+ {(char *)"wxyz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(3, 0, 1, 2)},
+ {(char *)"wxyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 0, 1, 3)},
+ {(char *)"wxz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(3, 0, 2)},
+ {(char *)"wxzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 0, 2, 0)},
+ {(char *)"wxzy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(3, 0, 2, 1)},
+ {(char *)"wxzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 0, 2, 2)},
+ {(char *)"wxzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 0, 2, 3)},
+ {(char *)"wxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(3, 0, 3)},
+ {(char *)"wxwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 0, 3, 0)},
+ {(char *)"wxwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 0, 3, 1)},
+ {(char *)"wxwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 0, 3, 2)},
+ {(char *)"wxww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 0, 3, 3)},
+ {(char *)"wy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE2(3, 1)},
+ {(char *)"wyx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(3, 1, 0)},
+ {(char *)"wyxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 1, 0, 0)},
+ {(char *)"wyxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 1, 0, 1)},
+ {(char *)"wyxz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(3, 1, 0, 2)},
+ {(char *)"wyxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 1, 0, 3)},
+ {(char *)"wyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(3, 1, 1)},
+ {(char *)"wyyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 1, 1, 0)},
+ {(char *)"wyyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 1, 1, 1)},
+ {(char *)"wyyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 1, 1, 2)},
+ {(char *)"wyyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 1, 1, 3)},
+ {(char *)"wyz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(3, 1, 2)},
+ {(char *)"wyzx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(3, 1, 2, 0)},
+ {(char *)"wyzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 1, 2, 1)},
+ {(char *)"wyzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 1, 2, 2)},
+ {(char *)"wyzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 1, 2, 3)},
+ {(char *)"wyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(3, 1, 3)},
+ {(char *)"wywx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 1, 3, 0)},
+ {(char *)"wywy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 1, 3, 1)},
+ {(char *)"wywz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 1, 3, 2)},
+ {(char *)"wyww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 1, 3, 3)},
+ {(char *)"wz", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE2(3, 2)},
+ {(char *)"wzx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(3, 2, 0)},
+ {(char *)"wzxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 2, 0, 0)},
+ {(char *)"wzxy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(3, 2, 0, 1)},
+ {(char *)"wzxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 2, 0, 2)},
+ {(char *)"wzxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 2, 0, 3)},
+ {(char *)"wzy", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE3(3, 2, 1)},
+ {(char *)"wzyx", (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, NULL, SWIZZLE4(3, 2, 1, 0)},
+ {(char *)"wzyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 2, 1, 1)},
+ {(char *)"wzyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 2, 1, 2)},
+ {(char *)"wzyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 2, 1, 3)},
+ {(char *)"wzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(3, 2, 2)},
+ {(char *)"wzzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 2, 2, 0)},
+ {(char *)"wzzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 2, 2, 1)},
+ {(char *)"wzzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 2, 2, 2)},
+ {(char *)"wzzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 2, 2, 3)},
+ {(char *)"wzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(3, 2, 3)},
+ {(char *)"wzwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 2, 3, 0)},
+ {(char *)"wzwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 2, 3, 1)},
+ {(char *)"wzwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 2, 3, 2)},
+ {(char *)"wzww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 2, 3, 3)},
+ {(char *)"ww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE2(3, 3)},
+ {(char *)"wwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(3, 3, 0)},
+ {(char *)"wwxx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 0, 0)},
+ {(char *)"wwxy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 0, 1)},
+ {(char *)"wwxz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 0, 2)},
+ {(char *)"wwxw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 0, 3)},
+ {(char *)"wwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(3, 3, 1)},
+ {(char *)"wwyx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 1, 0)},
+ {(char *)"wwyy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 1, 1)},
+ {(char *)"wwyz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 1, 2)},
+ {(char *)"wwyw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 1, 3)},
+ {(char *)"wwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(3, 3, 2)},
+ {(char *)"wwzx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 2, 0)},
+ {(char *)"wwzy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 2, 1)},
+ {(char *)"wwzz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 2, 2)},
+ {(char *)"wwzw", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 2, 3)},
+ {(char *)"www", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE3(3, 3, 3)},
+ {(char *)"wwwx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 3, 0)},
+ {(char *)"wwwy", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 3, 1)},
+ {(char *)"wwwz", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 3, 2)},
+ {(char *)"wwww", (getter)Vector_swizzle_get, (setter)NULL, NULL, SWIZZLE4(3, 3, 3, 3)},
#undef AXIS_FROM_CHAR
-#undef SWIZZLE
-#undef _VA_SWIZZLE_1
-#undef _VA_SWIZZLE_2
-#undef _VA_SWIZZLE_3
-#undef _VA_SWIZZLE_4
+#undef SWIZZLE1
+#undef SWIZZLE2
+#undef SWIZZLE3
+#undef SWIZZLE4
+#undef _SWIZZLE1
+#undef _SWIZZLE2
+#undef _SWIZZLE3
+#undef _SWIZZLE4
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
};
/**
- * Python script used to make swizzle array:
- *
- * \code{.py}
- * SWIZZLE_BITS_PER_AXIS = 3
- * SWIZZLE_VALID_AXIS = 0x4
- *
- * axis_dict = {}
- * axis_pos = {'x': 0, 'y': 1, 'z': 2, 'w': 3}
- * axises = 'xyzw'
- * while len(axises) >= 2:
- * for axis_0 in axises:
- * axis_0_pos = axis_pos[axis_0]
- * for axis_1 in axises:
- * axis_1_pos = axis_pos[axis_1]
- * axis_dict[axis_0 + axis_1] = (
- * '((%s | SWIZZLE_VALID_AXIS) | '
- * '((%s | SWIZZLE_VALID_AXIS) << SWIZZLE_BITS_PER_AXIS))' %
- * (axis_0_pos, axis_1_pos))
- * if len(axises) > 2:
- * for axis_2 in axises:
- * axis_2_pos = axis_pos[axis_2]
- * axis_dict[axis_0 + axis_1 + axis_2] = (
- * '((%s | SWIZZLE_VALID_AXIS) | '
- * '((%s | SWIZZLE_VALID_AXIS) << SWIZZLE_BITS_PER_AXIS) | '
- * '((%s | SWIZZLE_VALID_AXIS) << (SWIZZLE_BITS_PER_AXIS * 2)))' %
- * (axis_0_pos, axis_1_pos, axis_2_pos))
- * if len(axises) > 3:
- * for axis_3 in axises:
- * axis_3_pos = axis_pos[axis_3]
- * axis_dict[axis_0 + axis_1 + axis_2 + axis_3] = (
- * '((%s | SWIZZLE_VALID_AXIS) | '
- * '((%s | SWIZZLE_VALID_AXIS) << SWIZZLE_BITS_PER_AXIS) | '
- * '((%s | SWIZZLE_VALID_AXIS) << (SWIZZLE_BITS_PER_AXIS * 2)) | '
- * '((%s | SWIZZLE_VALID_AXIS) << (SWIZZLE_BITS_PER_AXIS * 3))) ' %
- * (axis_0_pos, axis_1_pos, axis_2_pos, axis_3_pos))
- *
- * axises = axises[:-1]
- *
- *
- * items = list(axis_dict.items())
- * items.sort(key=lambda a: a[0].replace('x', '0').replace('y', '1').replace('z', '2').replace('w', '3'))
- *
- * unique = set()
- * for key, val in items:
- * num = eval(val)
- * set_str = 'Vector_swizzle_set' if (len(set(key)) == len(key)) else 'NULL'
- * key_args = ', '.join(["'%s'" % c for c in key.upper()])
- * print('\t{(char *)"%s", %s(getter)Vector_swizzle_get, (setter)%s, NULL, SWIZZLE(%s)},' %
- * (key, (' ' * (4 - len(key))), set_str, key_args))
- * unique.add(num)
- *
- * if len(unique) != len(items):
- * print("ERROR, duplicate values found")
- * \endcode
- */
-
-/* ROW VECTOR Multiplication - Vector X Matrix
+ * Row vector multiplication - (Vector * Matrix)
+ * <pre>
* [x][y][z] * [1][4][7]
* [2][5][8]
* [3][6][9]
- * vector/matrix multiplication IS NOT COMMUTATIVE!!!! */
+ * </pre>
+ * \note vector/matrix multiplication is not commutative.
+ */
static int row_vector_multiplication(float r_vec[MAX_DIMENSIONS], VectorObject *vec, MatrixObject *mat)
{
float vec_cpy[MAX_DIMENSIONS];
@@ -2863,10 +2880,11 @@ static struct PyMethodDef Vector_methods[] = {
};
-/* Note
- * Py_TPFLAGS_CHECKTYPES allows us to avoid casting all types to Vector when coercing
- * but this means for eg that
- * (vec * mat) and (mat * vec) both get sent to Vector_mul and it needs to sort out the order
+/**
+ * Note:
+ * #Py_TPFLAGS_CHECKTYPES allows us to avoid casting all types to Vector when coercing
+ * but this means for eg that (vec * mat) and (mat * vec)
+ * both get sent to Vector_mul and it needs to sort out the order
*/
PyDoc_STRVAR(vector_doc,
@@ -3010,6 +3028,11 @@ PyObject *Vector_CreatePyObject(
return (PyObject *)self;
}
+/**
+ * Create a vector that wraps existing memory.
+ *
+ * \param vec: Use this vector in-place.
+ */
PyObject *Vector_CreatePyObject_wrap(
float *vec, const int size,
PyTypeObject *base_type)
@@ -3036,6 +3059,10 @@ PyObject *Vector_CreatePyObject_wrap(
return (PyObject *) self;
}
+/**
+ * Create a vector where the value is defined by registered callbacks,
+ * see: #Mathutils_RegisterCallback
+ */
PyObject *Vector_CreatePyObject_cb(
PyObject *cb_user, int size,
unsigned char cb_type, unsigned char cb_subtype)
@@ -3052,6 +3079,9 @@ PyObject *Vector_CreatePyObject_cb(
return (PyObject *)self;
}
+/**
+ * \param vec: Initialized vector value to use in-place, allocated with: PyMem_Malloc
+ */
PyObject *Vector_CreatePyObject_alloc(
float *vec, const int size,
PyTypeObject *base_type)
diff --git a/source/blender/python/mathutils/mathutils_bvhtree.c b/source/blender/python/mathutils/mathutils_bvhtree.c
index 1eb8644a9a6..8162f8e9d0c 100644
--- a/source/blender/python/mathutils/mathutils_bvhtree.c
+++ b/source/blender/python/mathutils/mathutils_bvhtree.c
@@ -761,7 +761,7 @@ static PyObject *C_BVHTree_FromPolygons(PyObject *UNUSED(cls), PyObject *args, P
py_tricoords_fast_items = PySequence_Fast_ITEMS(py_tricoords_fast);
for (j = 0; j < 3; j++) {
- tri[j] = (unsigned int)_PyLong_AsInt(py_tricoords_fast_items[j]);
+ tri[j] = PyC_Long_AsU32(py_tricoords_fast_items[j]);
if (UNLIKELY(tri[j] >= (unsigned int)coords_len)) {
PyErr_Format(PyExc_ValueError,
"%s: index %d must be less than %d",
@@ -812,7 +812,7 @@ static PyObject *C_BVHTree_FromPolygons(PyObject *UNUSED(cls), PyObject *args, P
p_plink_prev = &plink->next;
for (j = 0; j < py_tricoords_len; j++) {
- plink->poly[j] = (unsigned int)_PyLong_AsInt(py_tricoords_fast_items[j]);
+ plink->poly[j] = PyC_Long_AsU32(py_tricoords_fast_items[j]);
if (UNLIKELY(plink->poly[j] >= (unsigned int)coords_len)) {
PyErr_Format(PyExc_ValueError,
"%s: index %d must be less than %d",
@@ -1049,6 +1049,8 @@ static DerivedMesh *bvh_get_derived_mesh(
const char *funcname, struct Scene *scene, Object *ob,
bool use_deform, bool use_render, bool use_cage)
{
+ /* TODO: This doesn't work currently because of eval_ctx. */
+#if 0
/* we only need minimum mesh data for topology and vertex locations */
CustomDataMask mask = CD_MASK_BAREMESH;
@@ -1096,6 +1098,11 @@ static DerivedMesh *bvh_get_derived_mesh(
}
}
}
+#else
+ UNUSED_VARS(funcname, scene, ob, use_deform, use_render, use_cage);
+#endif
+
+ return NULL;
}
PyDoc_STRVAR(C_BVHTree_FromObject_doc,
@@ -1156,7 +1163,6 @@ static PyObject *C_BVHTree_FromObject(PyObject *UNUSED(cls), PyObject *args, PyO
/* Get data for tessellation */
{
- DM_ensure_looptri(dm);
lt = dm->getLoopTriArray(dm);
tris_len = (unsigned int)dm->getNumLoopTri(dm);
diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c
index 868e4b38408..1dc18dbe509 100644
--- a/source/blender/python/mathutils/mathutils_geometry.c
+++ b/source/blender/python/mathutils/mathutils_geometry.c
@@ -1279,7 +1279,7 @@ static PyObject *M_Geometry_tessellate_polygon(PyObject *UNUSED(self), PyObject
index = 0;
dl_face = dl->index;
while (index < dl->parts) {
- PyList_SET_ITEM(tri_list, index, Py_BuildValue("iii", dl_face[0], dl_face[1], dl_face[2]));
+ PyList_SET_ITEM(tri_list, index, PyC_Tuple_Pack_I32(dl_face[0], dl_face[1], dl_face[2]));
dl_face += 3;
index++;
}
diff --git a/source/blender/quicktime/apple/qtkit_export.m b/source/blender/quicktime/apple/qtkit_export.m
deleted file mode 100644
index 1ac3c58f888..00000000000
--- a/source/blender/quicktime/apple/qtkit_export.m
+++ /dev/null
@@ -1,884 +0,0 @@
-/*
- * Code to create QuickTime Movies with Blender
- *
- * ***** 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 written by Rob Haarsma (phase)
- *
- * Contributor(s): Stefan Gartner (sgefant)
- * Damien Plisson 11/2009
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#ifdef WITH_QUICKTIME
-#if defined(_WIN32) || defined(__APPLE__)
-
-#include <stdio.h>
-#include <string.h>
-
-#include "DNA_scene_types.h"
-#include "DNA_userdef_types.h"
-
-#ifdef WITH_AUDASPACE
-# include AUD_DEVICE_H
-#endif
-
-#include "BLI_utildefines.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_scene.h"
-#include "BKE_report.h"
-
-#include "BLI_blenlib.h"
-
-#include "BLI_sys_types.h"
-
-#include "IMB_imbuf.h"
-#include "IMB_imbuf_types.h"
-
-#include "MEM_guardedalloc.h"
-
-#ifdef __APPLE__
-/* evil */
-#ifndef __AIFF__
-#define __AIFF__
-#endif
-#import <Cocoa/Cocoa.h>
-#import <QTKit/QTKit.h>
-#include <AudioToolbox/AudioToolbox.h>
-
-#include "quicktime_import.h"
-#include "quicktime_export.h"
-
-#endif /* __APPLE__ */
-
-typedef struct QuicktimeExport {
- QTMovie *movie;
-
- NSString *filename;
-
- QTTime frameDuration;
- NSDictionary *frameAttributes;
-
- NSString *videoTempFileName;
- /* Audio section */
- AUD_Device *audioInputDevice;
- AudioFileID audioFile;
- NSString *audioFileName;
- AudioConverterRef audioConverter;
- AudioBufferList audioBufferList;
- AudioStreamBasicDescription audioInputFormat, audioOutputFormat;
- AudioStreamPacketDescription *audioOutputPktDesc;
- SInt64 audioFilePos;
- char *audioInputBuffer;
- char *audioOutputBuffer;
- UInt32 audioCodecMaxOutputPacketSize;
- UInt64 audioTotalExportedFrames, audioTotalSavedFrames;
- UInt64 audioLastFrame;
- SInt64 audioOutputPktPos;
-
-} QuicktimeExport;
-
-#define AUDIOOUTPUTBUFFERSIZE 65536
-
-#pragma mark rna helper functions
-
-/* Video codec */
-static QuicktimeCodecTypeDesc qtVideoCodecList[] = {
- {kRawCodecType, 1, "Uncompressed"},
- {k422YpCbCr8CodecType, 2, "Uncompressed 8-bit 4:2:2"},
- {k422YpCbCr10CodecType, 3, "Uncompressed 10-bit 4:2:2"},
- {kComponentVideoCodecType, 4, "Component Video"},
- {kPixletCodecType, 5, "Pixlet"},
- {kPNGCodecType, 6, "PNG"},
- {kJPEGCodecType, 7, "JPEG"},
- {kMotionJPEGACodecType, 8, "M-JPEG A"},
- {kMotionJPEGBCodecType, 9, "M-JPEG B"},
- {kDVCPALCodecType, 10, "DV PAL"},
- {kDVCNTSCCodecType, 11, "DV/DVCPRO NTSC"},
- {kDVCPROHD720pCodecType, 12, "DVCPRO HD 720p"},
- {kDVCPROHD1080i50CodecType, 13, "DVCPRO HD 1080i50"},
- {kDVCPROHD1080i60CodecType, 14, "DVCPRO HD 1080i60"},
- {kMPEG4VisualCodecType, 15, "MPEG4"},
- {kH263CodecType, 16, "H.263"},
- {kH264CodecType, 17, "H.264"},
- {kAnimationCodecType, 18, "Animation"},
- {0,0,NULL}};
-
-static int qtVideoCodecCount = 18;
-
-int quicktime_get_num_videocodecs()
-{
- return qtVideoCodecCount;
-}
-
-QuicktimeCodecTypeDesc* quicktime_get_videocodecType_desc(int indexValue)
-{
- if ((indexValue>=0) && (indexValue < qtVideoCodecCount))
- return &qtVideoCodecList[indexValue];
- else
- return NULL;
-}
-
-int quicktime_rnatmpvalue_from_videocodectype(int codecType)
-{
- int i;
- for (i = 0; i < qtVideoCodecCount; i++) {
- if (qtVideoCodecList[i].codecType == codecType)
- return qtVideoCodecList[i].rnatmpvalue;
- }
-
- return 0;
-}
-
-int quicktime_videocodecType_from_rnatmpvalue(int rnatmpvalue)
-{
- int i;
- for (i = 0; i < qtVideoCodecCount; i++) {
- if (qtVideoCodecList[i].rnatmpvalue == rnatmpvalue)
- return qtVideoCodecList[i].codecType;
- }
-
- return 0;
-}
-
-/* Audio codec */
-static QuicktimeCodecTypeDesc qtAudioCodecList[] = {
- {0, 0, "No audio"},
- {kAudioFormatLinearPCM, 1, "LPCM"},
- {kAudioFormatAppleLossless, 2, "Apple Lossless"},
- {kAudioFormatMPEG4AAC, 3, "AAC"},
- {0,0,NULL}};
-
-static int qtAudioCodecCount = 4;
-
-int quicktime_get_num_audiocodecs()
-{
- return qtAudioCodecCount;
-}
-
-QuicktimeCodecTypeDesc* quicktime_get_audiocodecType_desc(int indexValue)
-{
- if ((indexValue>=0) && (indexValue < qtAudioCodecCount))
- return &qtAudioCodecList[indexValue];
- else
- return NULL;
-}
-
-int quicktime_rnatmpvalue_from_audiocodectype(int codecType)
-{
- int i;
- for (i = 0; i < qtAudioCodecCount; i++) {
- if (qtAudioCodecList[i].codecType == codecType)
- return qtAudioCodecList[i].rnatmpvalue;
- }
-
- return 0;
-}
-
-int quicktime_audiocodecType_from_rnatmpvalue(int rnatmpvalue)
-{
- int i;
- for (i = 0; i < qtAudioCodecCount; i++) {
- if (qtAudioCodecList[i].rnatmpvalue == rnatmpvalue)
- return qtAudioCodecList[i].codecType;
- }
-
- return 0;
-}
-
-
-static NSString *stringWithCodecType(int codecType)
-{
- char str[5];
-
- *((int *)str) = EndianU32_NtoB(codecType);
- str[4] = 0;
-
- return [NSString stringWithCString:str encoding:NSASCIIStringEncoding];
-}
-
-void makeqtstring(RenderData *rd, char *string, bool preview)
-{
- int sfra, efra;
-
- char txt[64];
-
- if (preview) {
- sfra = rd->psfra;
- efra = rd->pefra;
- }
- else {
- sfra = rd->sfra;
- efra = rd->efra;
- }
-
- strcpy(string, rd->pic);
- BLI_path_abs(string, G.main->name);
-
- BLI_make_existing_file(string);
-
- if (BLI_strcasecmp(string + strlen(string) - 4, ".mov")) {
- sprintf(txt, "%04d-%04d.mov", (rd->sfra) , (rd->efra) );
- strcat(string, txt);
- }
-}
-
-void filepath_qt(char *string, RenderData *rd, bool preview, const char *suffix)
-{
- int sfra, efra;
-
- if (string == NULL) return;
-
- if (preview) {
- sfra = rd->psfra;
- efra = rd->pefra;
- }
- else {
- sfra = rd->sfra;
- efra = rd->efra;
- }
-
- strcpy(string, rd->pic);
- BLI_path_abs(string, G.main->name);
-
- BLI_make_existing_file(string);
-
- if (rd->scemode & R_EXTENSION) {
- if (!BLI_testextensie(string, ".mov")) {
- BLI_path_frame_range(string, sfra, efra, 4);
- strcat(string, ".mov");
- }
- }
- else {
- if (BLI_path_frame_check_chars(string)) {
- BLI_path_frame_range(string, sfra, efra, 4);
- }
- }
-
- BLI_path_suffix(string, FILE_MAX, suffix, "");
-}
-
-void *context_create_qt(void)
-{
- QuicktimeExport *qtexport = MEM_callocN(sizeof(QuicktimeExport), "QuicktimeExport");
- return qtexport;
-}
-
-void context_free_qt(void *context_v)
-{
- QuicktimeExport *qtexport = context_v;
- if (qtexport) {
- MEM_freeN(qtexport);
- }
-}
-
-#pragma mark audio export functions
-
-static OSStatus write_cookie(AudioConverterRef converter, AudioFileID outfile)
-{
- // grab the cookie from the converter and write it to the file
- UInt32 cookieSize = 0;
- OSStatus err = AudioConverterGetPropertyInfo(converter, kAudioConverterCompressionMagicCookie, &cookieSize, NULL);
- // if there is an error here, then the format doesn't have a cookie, so on we go
- if (!err && cookieSize) {
- char* cookie = malloc(cookieSize);
-
- err = AudioConverterGetProperty(converter, kAudioConverterCompressionMagicCookie, &cookieSize, cookie);
-
- if (!err)
- err = AudioFileSetProperty (outfile, kAudioFilePropertyMagicCookieData, cookieSize, cookie);
- // even though some formats have cookies, some files don't take them
-
- free(cookie);
- }
- return err;
-}
-
-/* AudioConverter input stream callback */
-static OSStatus AudioConverterInputCallback(AudioConverterRef inAudioConverter,
- UInt32* ioNumberDataPackets,
- AudioBufferList* ioData,
- AudioStreamPacketDescription** outDataPacketDescription,
- void* inUserData)
-{
- QuicktimeExport *qtexport = inUserData;
- if (qtexport->audioTotalExportedFrames >= qtexport->audioLastFrame) { /* EOF */
- *ioNumberDataPackets = 0;
- return noErr;
- }
-
- if (qtexport->audioInputFormat.mBytesPerPacket * *ioNumberDataPackets > AUDIOOUTPUTBUFFERSIZE)
- *ioNumberDataPackets = AUDIOOUTPUTBUFFERSIZE / qtexport->audioInputFormat.mBytesPerPacket;
-
- if ((qtexport->audioTotalExportedFrames + *ioNumberDataPackets) > qtexport->audioLastFrame)
- *ioNumberDataPackets = (qtexport->audioLastFrame - qtexport->audioTotalExportedFrames) / qtexport->audioInputFormat.mFramesPerPacket;
-
- qtexport->audioTotalExportedFrames += *ioNumberDataPackets;
-
- AUD_Device_read(qtexport->audioInputDevice, (UInt8 *)qtexport->audioInputBuffer,
- qtexport->audioInputFormat.mFramesPerPacket * *ioNumberDataPackets);
-
- ioData->mBuffers[0].mDataByteSize = qtexport->audioInputFormat.mBytesPerPacket * *ioNumberDataPackets;
- ioData->mBuffers[0].mData = qtexport->audioInputBuffer;
- ioData->mBuffers[0].mNumberChannels = qtexport->audioInputFormat.mChannelsPerFrame;
-
- return noErr;
-}
-
-
-#pragma mark export functions
-
-int start_qt(
- void *context_v, struct Scene *scene, struct RenderData *rd, int UNUSED(rectx), int UNUSED(recty),
- ReportList *reports, bool preview, const char *UNUSED(suffix))
-{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- NSError *error;
- char name[1024];
- int success = 1;
- OSStatus err = noErr;
- int sfra, efra;
- QuicktimeExport *qtexport = context_v;
-
- if (preview) {
- sfra = rd->psfra;
- efra = rd->pefra;
- }
- else {
- sfra = rd->sfra;
- efra = rd->efra;
- }
-
- [QTMovie enterQTKitOnThread];
-
- /* Check first if the QuickTime 7.2.1 initToWritableFile: method is available */
- if ([[[[QTMovie alloc] init] autorelease] respondsToSelector:@selector(initToWritableFile:error:)] != YES) {
- BKE_report(reports, RPT_ERROR, "\nUnable to create quicktime movie, need Quicktime rev 7.2.1 or later");
- success = 0;
- }
- else {
- makeqtstring(rd, name, preview);
- qtexport->filename = [[NSString alloc] initWithUTF8String:name];
- qtexport->movie = nil;
- qtexport->audioFile = NULL;
-
- if (rd->qtcodecsettings.audiocodecType) {
- // generate a name for our video & audio files
- /* Init audio file */
- CFURLRef outputFileURL;
- char extension[32];
- AudioFileTypeID audioFileType;
-
- switch (rd->qtcodecsettings.audiocodecType) {
- case kAudioFormatLinearPCM:
- audioFileType = kAudioFileWAVEType;
- strcpy(extension,".wav");
- break;
- case kAudioFormatMPEG4AAC:
- case kAudioFormatAppleLossless:
- audioFileType = kAudioFileM4AType;
- strcpy(extension, ".m4a");
- break;
- default:
- audioFileType = kAudioFileAIFFType;
- strcpy(extension,".aiff");
- break;
- }
-
- tmpnam(name);
- strcat(name, extension);
- outputFileURL = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault,(UInt8 *)name, strlen(name), false);
-
- if (outputFileURL) {
-
- qtexport->audioFileName = [[NSString alloc] initWithCString:name
- encoding:[NSString defaultCStringEncoding]];
-
- qtexport->audioInputFormat.mSampleRate = U.audiorate;
- qtexport->audioInputFormat.mFormatID = kAudioFormatLinearPCM;
- qtexport->audioInputFormat.mChannelsPerFrame = U.audiochannels;
- switch (U.audioformat) {
- case AUD_FORMAT_U8:
- qtexport->audioInputFormat.mBitsPerChannel = 8;
- qtexport->audioInputFormat.mFormatFlags = 0;
- break;
- case AUD_FORMAT_S24:
- qtexport->audioInputFormat.mBitsPerChannel = 24;
- qtexport->audioInputFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger;
- break;
- case AUD_FORMAT_S32:
- qtexport->audioInputFormat.mBitsPerChannel = 32;
- qtexport->audioInputFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger;
- break;
- case AUD_FORMAT_FLOAT32:
- qtexport->audioInputFormat.mBitsPerChannel = 32;
- qtexport->audioInputFormat.mFormatFlags = kLinearPCMFormatFlagIsFloat;
- break;
- case AUD_FORMAT_FLOAT64:
- qtexport->audioInputFormat.mBitsPerChannel = 64;
- qtexport->audioInputFormat.mFormatFlags = kLinearPCMFormatFlagIsFloat;
- break;
- case AUD_FORMAT_S16:
- default:
- qtexport->audioInputFormat.mBitsPerChannel = 16;
- qtexport->audioInputFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger;
- break;
- }
- qtexport->audioInputFormat.mBytesPerFrame = qtexport->audioInputFormat.mChannelsPerFrame * qtexport->audioInputFormat.mBitsPerChannel / 8;
- qtexport->audioInputFormat.mFramesPerPacket = 1; /*If not ==1, then need to check input callback for "rounding" issues"*/
- qtexport->audioInputFormat.mBytesPerPacket = qtexport->audioInputFormat.mBytesPerFrame;
- qtexport->audioInputFormat.mFormatFlags |= kLinearPCMFormatFlagIsPacked;
-
-
- /*Output format*/
- qtexport->audioOutputFormat.mFormatID = rd->qtcodecsettings.audiocodecType;
- //TODO: set audio channels
- qtexport->audioOutputFormat.mChannelsPerFrame = 2;
- qtexport->audioOutputFormat.mSampleRate = rd->qtcodecsettings.audioSampleRate;
-
- /* Default value for compressed formats, overridden after if not the case */
- qtexport->audioOutputFormat.mFramesPerPacket = 0;
- qtexport->audioOutputFormat.mBytesPerFrame = 0;
- qtexport->audioOutputFormat.mBytesPerPacket = 0;
- qtexport->audioOutputFormat.mBitsPerChannel = 0;
-
- switch (rd->qtcodecsettings.audiocodecType) {
- case kAudioFormatMPEG4AAC:
- qtexport->audioOutputFormat.mFormatFlags = kMPEG4Object_AAC_Main;
- /* AAC codec does not handle sample rates above 48kHz, force this limit instead of getting an error afterwards */
- if (qtexport->audioOutputFormat.mSampleRate > 48000) qtexport->audioOutputFormat.mSampleRate = 48000;
- break;
- case kAudioFormatAppleLossless:
- switch (U.audioformat) {
- case AUD_FORMAT_S16:
- qtexport->audioOutputFormat.mFormatFlags = kAppleLosslessFormatFlag_16BitSourceData;
- break;
- case AUD_FORMAT_S24:
- qtexport->audioOutputFormat.mFormatFlags = kAppleLosslessFormatFlag_24BitSourceData;
- break;
- case AUD_FORMAT_S32:
- qtexport->audioOutputFormat.mFormatFlags = kAppleLosslessFormatFlag_32BitSourceData;
- break;
- case AUD_FORMAT_U8:
- case AUD_FORMAT_FLOAT32:
- case AUD_FORMAT_FLOAT64:
- default:
- break;
- }
- break;
- case kAudioFormatLinearPCM:
- default:
- switch (rd->qtcodecsettings.audioBitDepth) {
- case AUD_FORMAT_U8:
- qtexport->audioOutputFormat.mBitsPerChannel = 8;
- qtexport->audioOutputFormat.mFormatFlags = 0;
- break;
- case AUD_FORMAT_S24:
- qtexport->audioOutputFormat.mBitsPerChannel = 24;
- qtexport->audioOutputFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger;
- break;
- case AUD_FORMAT_S32:
- qtexport->audioOutputFormat.mBitsPerChannel = 32;
- qtexport->audioOutputFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger;
- break;
- case AUD_FORMAT_FLOAT32:
- qtexport->audioOutputFormat.mBitsPerChannel = 32;
- qtexport->audioOutputFormat.mFormatFlags = kLinearPCMFormatFlagIsFloat;
- break;
- case AUD_FORMAT_FLOAT64:
- qtexport->audioOutputFormat.mBitsPerChannel = 64;
- qtexport->audioOutputFormat.mFormatFlags = kLinearPCMFormatFlagIsFloat;
- break;
- case AUD_FORMAT_S16:
- default:
- qtexport->audioOutputFormat.mBitsPerChannel = 16;
- qtexport->audioOutputFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger;
- break;
- }
- qtexport->audioOutputFormat.mFormatFlags |= kLinearPCMFormatFlagIsPacked;
- qtexport->audioOutputFormat.mBytesPerPacket = qtexport->audioOutputFormat.mChannelsPerFrame * (qtexport->audioOutputFormat.mBitsPerChannel / 8);
- qtexport->audioOutputFormat.mFramesPerPacket = 1;
- qtexport->audioOutputFormat.mBytesPerFrame = qtexport->audioOutputFormat.mBytesPerPacket;
- break;
- }
-
- err = AudioFileCreateWithURL(outputFileURL, audioFileType, &qtexport->audioOutputFormat, kAudioFileFlags_EraseFile, &qtexport->audioFile);
- CFRelease(outputFileURL);
-
- if (err)
- BKE_report(reports, RPT_ERROR, "\nQuicktime: unable to create temporary audio file. Format error ?");
- else {
- err = AudioConverterNew(&qtexport->audioInputFormat, &qtexport->audioOutputFormat, &qtexport->audioConverter);
- if (err) {
- BKE_report(reports, RPT_ERROR, "\nQuicktime: unable to initialize audio codec converter. Format error ?");
- AudioFileClose(qtexport->audioFile);
- qtexport->audioFile = NULL;
- [qtexport->audioFileName release];
- qtexport->audioFileName = nil;
- }
- else {
- UInt32 prop,propSize;
- /* Set up codec properties */
- if (rd->qtcodecsettings.audiocodecType == kAudioFormatMPEG4AAC) { /* Lossy compressed format */
- prop = rd->qtcodecsettings.audioBitRate;
- AudioConverterSetProperty(qtexport->audioConverter, kAudioConverterEncodeBitRate,
- sizeof(prop), &prop);
-
- if (rd->qtcodecsettings.audioCodecFlags & QTAUDIO_FLAG_CODEC_ISCBR)
- prop = kAudioCodecBitRateControlMode_Constant;
- else
- prop = kAudioCodecBitRateControlMode_LongTermAverage;
- AudioConverterSetProperty(qtexport->audioConverter, kAudioCodecPropertyBitRateControlMode,
- sizeof(prop), &prop);
- }
- /* Conversion quality : if performance impact then offer degraded option */
- if ((rd->qtcodecsettings.audioCodecFlags & QTAUDIO_FLAG_RESAMPLE_NOHQ) == 0) {
- prop = kAudioConverterSampleRateConverterComplexity_Mastering;
- AudioConverterSetProperty(qtexport->audioConverter, kAudioConverterSampleRateConverterComplexity,
- sizeof(prop), &prop);
-
- prop = kAudioConverterQuality_Max;
- AudioConverterSetProperty(qtexport->audioConverter, kAudioConverterSampleRateConverterQuality,
- sizeof(prop), &prop);
- }
-
- write_cookie(qtexport->audioConverter, qtexport->audioFile);
-
- /* Allocate output buffer */
- if (qtexport->audioOutputFormat.mBytesPerPacket ==0) /* VBR */
- AudioConverterGetProperty(qtexport->audioConverter, kAudioConverterPropertyMaximumOutputPacketSize,
- &propSize, &qtexport->audioCodecMaxOutputPacketSize);
- else
- qtexport->audioCodecMaxOutputPacketSize = qtexport->audioOutputFormat.mBytesPerPacket;
-
- qtexport->audioInputBuffer = MEM_mallocN(AUDIOOUTPUTBUFFERSIZE, "qt_audio_inputPacket");
- qtexport->audioOutputBuffer = MEM_mallocN(AUDIOOUTPUTBUFFERSIZE, "qt_audio_outputPacket");
- qtexport->audioOutputPktDesc = MEM_mallocN(sizeof(AudioStreamPacketDescription) * AUDIOOUTPUTBUFFERSIZE / qtexport->audioCodecMaxOutputPacketSize,
- "qt_audio_pktdesc");
- }
- }
- }
-
- if (err == noErr) {
- qtexport->videoTempFileName = [[NSString alloc] initWithCString:tmpnam(nil)
- encoding:[NSString defaultCStringEncoding]];
- if (qtexport->videoTempFileName) {
- qtexport->movie = [[QTMovie alloc] initToWritableFile:qtexport->videoTempFileName error:&error];
- }
-
- }
- }
- else
- qtexport->movie = [[QTMovie alloc] initToWritableFile:qtexport->filename error:&error];
-
- if (qtexport->movie == nil) {
- BKE_report(reports, RPT_ERROR, "Unable to create quicktime movie.");
- success = 0;
- if (qtexport->filename) [qtexport->filename release];
- qtexport->filename = nil;
- if (qtexport->audioFileName) [qtexport->audioFileName release];
- qtexport->audioFileName = nil;
- if (qtexport->videoTempFileName) [qtexport->videoTempFileName release];
- qtexport->videoTempFileName = nil;
- [QTMovie exitQTKitOnThread];
- }
- else {
- [qtexport->movie retain];
- [qtexport->movie setAttribute:[NSNumber numberWithBool:YES] forKey:QTMovieEditableAttribute];
- [qtexport->movie setAttribute:@"Made with Blender" forKey:QTMovieCopyrightAttribute];
-
- qtexport->frameDuration = QTMakeTime(rd->frs_sec_base * 1000, rd->frs_sec * 1000);
-
- /* specifying the codec attributes : try to retrieve them from render data first*/
- if (rd->qtcodecsettings.codecType) {
- qtexport->frameAttributes = [
- NSDictionary dictionaryWithObjectsAndKeys:
- stringWithCodecType(rd->qtcodecsettings.codecType),
- QTAddImageCodecType,
- [NSNumber numberWithLong:((rd->qtcodecsettings.codecSpatialQuality)*codecLosslessQuality)/100],
- QTAddImageCodecQuality,
- nil];
- }
- else {
- qtexport->frameAttributes = [
- NSDictionary dictionaryWithObjectsAndKeys:@"jpeg",
- QTAddImageCodecType,
- [NSNumber numberWithLong:codecHighQuality],
- QTAddImageCodecQuality,
- nil];
- }
- [qtexport->frameAttributes retain];
-
- if (qtexport->audioFile) {
- /* Init audio input stream */
- AUD_DeviceSpecs specs;
-
- specs.channels = U.audiochannels;
- specs.format = U.audioformat;
- specs.rate = U.audiorate;
- qtexport->audioInputDevice = AUD_openReadDevice(specs);
- AUD_playDevice(qtexport->audioInputDevice, scene->sound_scene, sfra * rd->frs_sec_base / rd->frs_sec);
-
- qtexport->audioOutputPktPos = 0;
- qtexport->audioTotalExportedFrames = 0;
- qtexport->audioTotalSavedFrames = 0;
-
- qtexport->audioLastFrame = (efra - sfra) * qtexport->audioInputFormat.mSampleRate * rd->frs_sec_base / rd->frs_sec;
- }
- }
- }
-
- [pool drain];
-
- return success;
-}
-
-int append_qt(
- void *context_v, struct RenderData *rd, int start_frame, int frame, int *pixels, int rectx, int recty,
- const char *UNUSED(suffix), ReportList *reports)
-{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- NSBitmapImageRep *blBitmapFormatImage;
- NSImage *frameImage;
- OSStatus err = noErr;
- unsigned char *from_Ptr,*to_Ptr;
- int y,from_i,to_i;
- QuicktimeExport *qtexport = context_v;
-
- /* Create bitmap image rep in blender format (32bit RGBA) */
- blBitmapFormatImage = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
- pixelsWide:rectx
- pixelsHigh:recty
- bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES isPlanar:NO
- colorSpaceName:NSCalibratedRGBColorSpace
- bitmapFormat:NSAlphaNonpremultipliedBitmapFormat
- bytesPerRow:rectx*4
- bitsPerPixel:32];
- if (!blBitmapFormatImage) {
- [pool drain];
- return 0;
- }
-
- from_Ptr = (unsigned char *)pixels;
- to_Ptr = (unsigned char *)[blBitmapFormatImage bitmapData];
- for (y = 0; y < recty; y++) {
- to_i = (recty-y-1)*rectx;
- from_i = y*rectx;
- memcpy(to_Ptr+4*to_i, from_Ptr+4*from_i, 4*rectx);
- }
-
- frameImage = [[NSImage alloc] initWithSize:NSMakeSize(rectx, recty)];
- [frameImage addRepresentation:blBitmapFormatImage];
-
- /* Add the image to the movie clip */
- [qtexport->movie addImage:frameImage
- forDuration:qtexport->frameDuration
- withAttributes:qtexport->frameAttributes];
-
- [blBitmapFormatImage release];
- [frameImage release];
-
-
- if (qtexport->audioFile) {
- UInt32 audioPacketsConverted;
-
- // Upper limit on total exported audio frames for this particular video frame
- const UInt64 exportedAudioFrameLimit = (frame - start_frame) * qtexport->audioInputFormat.mSampleRate * rd->frs_sec_base / rd->frs_sec;
-
- /* Append audio */
- while (qtexport->audioTotalExportedFrames < exportedAudioFrameLimit) {
-
- qtexport->audioBufferList.mNumberBuffers = 1;
- qtexport->audioBufferList.mBuffers[0].mNumberChannels = qtexport->audioOutputFormat.mChannelsPerFrame;
- qtexport->audioBufferList.mBuffers[0].mDataByteSize = AUDIOOUTPUTBUFFERSIZE;
- qtexport->audioBufferList.mBuffers[0].mData = qtexport->audioOutputBuffer;
-
- // Convert one audio packet at a time so that enclosing while loop can
- // keep audio processing in sync with video frames.
- // Previously, this was set to (AUDIOOUTPUTBUFFERSIZE / qtexport->audioCodecMaxOutputPacketSize),
- // however this may cause AudioConverterFillComplexBuffer to convert audio spanning multiple
- // video frames, which breaks animation of audio parameters such as volume for fade-in/out.
- audioPacketsConverted = 1;
-
- err = AudioConverterFillComplexBuffer(qtexport->audioConverter, AudioConverterInputCallback,
- qtexport, &audioPacketsConverted, &qtexport->audioBufferList, qtexport->audioOutputPktDesc);
- if (audioPacketsConverted) {
- AudioFileWritePackets(qtexport->audioFile, false, qtexport->audioBufferList.mBuffers[0].mDataByteSize,
- qtexport->audioOutputPktDesc, qtexport->audioOutputPktPos, &audioPacketsConverted, qtexport->audioOutputBuffer);
- qtexport->audioOutputPktPos += audioPacketsConverted;
-
- if (qtexport->audioOutputFormat.mFramesPerPacket) {
- // this is the common case: format has constant frames per packet
- qtexport->audioTotalSavedFrames += (audioPacketsConverted * qtexport->audioOutputFormat.mFramesPerPacket);
- }
- else {
- unsigned int i;
- // if there are variable frames per packet, then we have to do this for each packeet
- for (i = 0; i < audioPacketsConverted; ++i)
- qtexport->audioTotalSavedFrames += qtexport->audioOutputPktDesc[i].mVariableFramesInPacket;
- }
-
-
- }
- else {
- //Error getting audio packets
- BKE_reportf(reports, RPT_ERROR, "Unable to get further audio packets from frame %i, error = 0x%x",(int)qtexport->audioTotalExportedFrames,err);
- break;
- }
-
- }
- }
- [pool drain];
-
- return 1;
-}
-
-
-void end_qt(void *context_v)
-{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- QuicktimeExport *qtexport = context_v;
-
- if (qtexport->movie) {
-
- if (qtexport->audioFile)
- {
- NSDictionary *dict = nil;
- QTMovie *audioTmpMovie = nil;
- NSError *error;
- NSFileManager *fileManager;
-
- /* Mux video and audio then save file */
-
- /* Write last frames for VBR files */
- if (qtexport->audioOutputFormat.mBitsPerChannel == 0) {
- OSStatus err = noErr;
- AudioConverterPrimeInfo primeInfo;
- UInt32 primeSize = sizeof(primeInfo);
-
- err = AudioConverterGetProperty(qtexport->audioConverter, kAudioConverterPrimeInfo, &primeSize, &primeInfo);
- if (err == noErr) {
- // there's priming to write out to the file
- AudioFilePacketTableInfo pti;
- pti.mPrimingFrames = primeInfo.leadingFrames;
- pti.mRemainderFrames = primeInfo.trailingFrames;
- pti.mNumberValidFrames = qtexport->audioTotalSavedFrames - pti.mPrimingFrames - pti.mRemainderFrames;
- AudioFileSetProperty(qtexport->audioFile, kAudioFilePropertyPacketTableInfo, sizeof(pti), &pti);
- }
-
- }
-
- write_cookie(qtexport->audioConverter, qtexport->audioFile);
- AudioConverterDispose(qtexport->audioConverter);
- AudioFileClose(qtexport->audioFile);
- AUD_Device_free(qtexport->audioInputDevice);
- qtexport->audioFile = NULL;
- qtexport->audioInputDevice = NULL;
- MEM_freeN(qtexport->audioInputBuffer);
- MEM_freeN(qtexport->audioOutputBuffer);
- MEM_freeN(qtexport->audioOutputPktDesc);
-
- /* Reopen audio file and merge it */
- audioTmpMovie = [QTMovie movieWithFile:qtexport->audioFileName error:&error];
- if (audioTmpMovie) {
- NSArray *audioTracks = [audioTmpMovie tracksOfMediaType:QTMediaTypeSound];
- QTTrack *audioTrack = nil;
- if ( [audioTracks count] > 0 ) {
- audioTrack = [audioTracks objectAtIndex:0];
- }
-
- if (audioTrack) {
- QTTimeRange totalRange;
- totalRange.time = QTZeroTime;
- totalRange.duration = [[audioTmpMovie attributeForKey:QTMovieDurationAttribute] QTTimeValue];
-
- [qtexport->movie insertSegmentOfTrack:audioTrack timeRange:totalRange atTime:QTZeroTime];
- }
- }
-
- /* Save file */
- dict = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES]
- forKey:QTMovieFlatten];
-
- if (dict) {
- [qtexport->movie writeToFile:qtexport->filename withAttributes:dict];
- }
-
- /* Delete temp files */
- fileManager = [[NSFileManager alloc] init];
- [fileManager removeItemAtPath:qtexport->audioFileName error:&error];
- [fileManager removeItemAtPath:qtexport->videoTempFileName error:&error];
- [fileManager release];
- }
- else {
- /* Flush update of the movie file */
- [qtexport->movie updateMovieFile];
-
- [qtexport->movie invalidate];
- }
-
- /* Clean up movie structure */
- if (qtexport->filename) [qtexport->filename release];
- qtexport->filename = nil;
- if (qtexport->audioFileName) [qtexport->audioFileName release];
- qtexport->audioFileName = nil;
- if (qtexport->videoTempFileName) [qtexport->videoTempFileName release];
- qtexport->videoTempFileName = nil;
- [qtexport->frameAttributes release];
- [qtexport->movie release];
- }
-
- [QTMovie exitQTKitOnThread];
- [pool drain];
-}
-
-
-void free_qtcomponentdata(void)
-{
-}
-
-void quicktime_verify_image_type(RenderData *rd, ImageFormatData *imf)
-{
- if (imf->imtype == R_IMF_IMTYPE_QUICKTIME) {
- if ((rd->qtcodecsettings.codecType <= 0) ||
- (rd->qtcodecsettings.codecSpatialQuality < 0) ||
- (rd->qtcodecsettings.codecSpatialQuality > 100))
- {
- rd->qtcodecsettings.codecType = kJPEGCodecType;
- rd->qtcodecsettings.codecSpatialQuality = (codecHighQuality * 100) / codecLosslessQuality;
- }
- if ((rd->qtcodecsettings.audioSampleRate < 21000) ||
- (rd->qtcodecsettings.audioSampleRate > 193000))
- {
- rd->qtcodecsettings.audioSampleRate = 48000;
- }
-
- if (rd->qtcodecsettings.audioBitDepth == 0) {
- rd->qtcodecsettings.audioBitDepth = AUD_FORMAT_S16;
- }
-
- if (rd->qtcodecsettings.audioBitRate == 0) {
- rd->qtcodecsettings.audioBitRate = 256000;
- }
- }
-}
-
-#endif /* _WIN32 || __APPLE__ */
-#endif /* WITH_QUICKTIME */
-
diff --git a/source/blender/quicktime/apple/qtkit_import.m b/source/blender/quicktime/apple/qtkit_import.m
deleted file mode 100644
index ba7ee0a8936..00000000000
--- a/source/blender/quicktime/apple/qtkit_import.m
+++ /dev/null
@@ -1,400 +0,0 @@
-/*
- * Code to use Quicktime to load images/movies as texture.
- *
- * ***** 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 written by Rob Haarsma (phase)
- *
- * Contributor(s): Stefan Gartner (sgefant)
- * Damien Plisson 11/2009
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#ifdef WITH_QUICKTIME
-
-#include "MEM_guardedalloc.h"
-
-#include "IMB_anim.h"
-#include "BLI_sys_types.h"
-#include "BLI_utildefines.h"
-#include "BKE_global.h"
-
-#include "BLI_dynstr.h"
-#include "BLI_path_util.h"
-
-#import <Cocoa/Cocoa.h>
-#import <QTKit/QTKit.h>
-
-#include "quicktime_import.h"
-#include "quicktime_export.h"
-
-// quicktime structure definition
-// this structure is part of the anim struct
-
-typedef struct _QuicktimeMovie {
- QTMovie *movie;
- QTMedia *media;
-
- long durationTime;
- long durationScale;
- long framecount;
-
-
- ImBuf *ibuf;
-
- long previousPosition;
-
-} QuicktimeMovie;
-
-
-#define QTIME_DEBUG 0
-
-
-void quicktime_init(void)
-{
- G.have_quicktime = true;
-}
-
-void quicktime_exit(void)
-{
- if (G.have_quicktime) {
- free_qtcomponentdata();
- }
-}
-
-
-int anim_is_quicktime(const char *name)
-{
- NSAutoreleasePool *pool;
-
- // don't let quicktime movie import handle these
-
- if (BLI_testextensie_n(
- name,
- ".swf",
- ".txt",
- ".mpg",
- ".vob", /* disabled, vob is essential .mpg, don't handle */
- ".avi", /* wouldn't be appropriate ;) */
- ".mov", /* disabled, suboptimal decoding speed */
- ".mp4", /* disabled, suboptimal decoding speed */
- ".m4v", /* disabled, suboptimal decoding speed */
- ".tga",
- ".png",
- ".bmp",
- ".jpg",
- ".tif",
- ".exr",
- ".wav",
- ".zip",
- ".mp3",
- NULL))
- {
- return 0;
- }
-
- if (QTIME_DEBUG) printf("qt: checking as movie: %s\n", name);
-
- pool = [[NSAutoreleasePool alloc] init];
-
- if ([QTMovie canInitWithFile:[NSString stringWithCString:name
- encoding:[NSString defaultCStringEncoding]]])
- {
- [pool drain];
- return true;
- }
- else
- {
- [pool drain];
- return false;
- }
-}
-
-
-void free_anim_quicktime(struct anim *anim)
-{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- if (anim == NULL) return;
- if (anim->qtime == NULL) return;
-
- if (anim->qtime->ibuf)
- IMB_freeImBuf(anim->qtime->ibuf);
-
- [anim->qtime->media release];
- [anim->qtime->movie release];
-
- [QTMovie exitQTKitOnThread];
-
- if (anim->qtime) MEM_freeN (anim->qtime);
-
- anim->qtime = NULL;
-
- anim->duration = 0;
-
- [pool drain];
-}
-
-static ImBuf *nsImageToiBuf(NSImage *sourceImage, int width, int height)
-{
- ImBuf *ibuf = NULL;
- uchar *rasterRGB = NULL;
- uchar *rasterRGBA = NULL;
- uchar *toIBuf = NULL;
- int x, y, to_i, from_i;
- NSSize bitmapSize;
- NSBitmapImageRep *blBitmapFormatImageRGB,*blBitmapFormatImageRGBA, *bitmapImage = nil;
- NSEnumerator *enumerator;
- NSImageRep *representation;
-
- ibuf = IMB_allocImBuf(width, height, 32, IB_rect);
- if (!ibuf) {
- if (QTIME_DEBUG) {
- printf("quicktime_import: could not allocate memory for the image.\n");
- }
- return NULL;
- }
-
- /*Get the bitmap of the image*/
- enumerator = [[sourceImage representations] objectEnumerator];
- while ((representation = [enumerator nextObject])) {
- if ([representation isKindOfClass:[NSBitmapImageRep class]]) {
- bitmapImage = (NSBitmapImageRep *)representation;
- break;
- }
- }
- if (bitmapImage == nil) return NULL;
-
- if (([bitmapImage bitsPerPixel] == 32) && (([bitmapImage bitmapFormat] & 0x5) == 0)
- && ![bitmapImage isPlanar]) {
- /* Try a fast copy if the image is a meshed RGBA 32bit bitmap*/
- toIBuf = (uchar *)ibuf->rect;
- rasterRGB = (uchar *)[bitmapImage bitmapData];
- for (y = 0; y < height; y++) {
- to_i = (height-y-1)*width;
- from_i = y*width;
- memcpy(toIBuf+4*to_i, rasterRGB+4*from_i, 4*width);
- }
- }
- else {
-
- bitmapSize.width = width;
- bitmapSize.height = height;
-
- /* Tell cocoa image resolution is same as current system one */
- [bitmapImage setSize:bitmapSize];
-
- /* Convert the image in a RGBA 32bit format */
- /* As Core Graphics does not support contextes with non premutliplied alpha,
- * we need to get alpha key values in a separate batch */
-
- /* First get RGB values w/o Alpha to avoid pre-multiplication, 32bit but last byte is unused */
- blBitmapFormatImageRGB = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
- pixelsWide:width
- pixelsHigh:height
- bitsPerSample:8 samplesPerPixel:3 hasAlpha:NO isPlanar:NO
- colorSpaceName:NSDeviceRGBColorSpace
- bitmapFormat:0
- bytesPerRow:4*width
- bitsPerPixel:32/*RGB format padded to 32bits*/];
-
- [NSGraphicsContext saveGraphicsState];
- [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithBitmapImageRep:blBitmapFormatImageRGB]];
- [bitmapImage draw];
- [NSGraphicsContext restoreGraphicsState];
-
- rasterRGB = (uchar *)[blBitmapFormatImageRGB bitmapData];
- if (rasterRGB == NULL) {
- [blBitmapFormatImageRGB release];
- return NULL;
- }
-
- /* Then get Alpha values by getting the RGBA image (that is premultiplied btw) */
- blBitmapFormatImageRGBA = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
- pixelsWide:width
- pixelsHigh:height
- bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES isPlanar:NO
- colorSpaceName:NSDeviceRGBColorSpace
- bitmapFormat:0
- bytesPerRow:4*width
- bitsPerPixel:32/* RGBA */];
-
- [NSGraphicsContext saveGraphicsState];
- [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithBitmapImageRep:blBitmapFormatImageRGBA]];
- [bitmapImage draw];
- [NSGraphicsContext restoreGraphicsState];
-
- rasterRGBA = (uchar *)[blBitmapFormatImageRGBA bitmapData];
- if (rasterRGBA == NULL) {
- [blBitmapFormatImageRGB release];
- [blBitmapFormatImageRGBA release];
- return NULL;
- }
-
- /*Copy the image to ibuf, flipping it vertically*/
- toIBuf = (uchar *)ibuf->rect;
- for (y = 0; y < height; y++) {
- for (x = 0; x < width; x++) {
- to_i = (height-y-1)*width + x;
- from_i = y*width + x;
-
- toIBuf[4*to_i] = rasterRGB[4*from_i]; /* R */
- toIBuf[4*to_i+1] = rasterRGB[4*from_i+1]; /* G */
- toIBuf[4*to_i+2] = rasterRGB[4*from_i+2]; /* B */
- toIBuf[4*to_i+3] = rasterRGBA[4*from_i+3]; /* A */
- }
- }
-
- [blBitmapFormatImageRGB release];
- [blBitmapFormatImageRGBA release];
- }
-
- return ibuf;
-}
-
-ImBuf *qtime_fetchibuf (struct anim *anim, int position)
-{
- NSImage *frameImage;
- QTTime time;
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- ImBuf *ibuf;
-
- if (anim == NULL) {
- return (NULL);
- }
-
- if (position == anim->qtime->previousPosition+1) { //Optimize sequential read
- [anim->qtime->movie stepForward];
- frameImage = [anim->qtime->movie currentFrameImage];
- anim->qtime->previousPosition++;
- }
- else {
- time.timeScale = anim->qtime->durationScale;
- time.timeValue = (anim->qtime->durationTime * position) / anim->qtime->framecount;
-
- [anim->qtime->movie setCurrentTime:time];
- frameImage = [anim->qtime->movie currentFrameImage];
-
- anim->qtime->previousPosition = position;
- }
-
- if (frameImage == nil) {
- if (QTIME_DEBUG) printf ("Error reading frame from Quicktime");
- [pool drain];
- return NULL;
- }
-
- ibuf = nsImageToiBuf(frameImage,anim->x, anim->y);
- [pool drain];
-
- return ibuf;
-}
-
-
-int startquicktime(struct anim *anim)
-{
- NSAutoreleasePool *pool;
- NSArray* videoTracks;
- NSSize frameSize;
- QTTime qtTimeDuration;
- NSDictionary *attributes;
-
- anim->qtime = MEM_callocN(sizeof(QuicktimeMovie),"animqt");
-
- if (anim->qtime == NULL) {
- if (QTIME_DEBUG) printf("Can't alloc qtime: %s\n", anim->name);
- return -1;
- }
-
- pool = [[NSAutoreleasePool alloc] init];
-
- [QTMovie enterQTKitOnThread];
-
- attributes = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSString stringWithCString:anim->name
- encoding:[NSString defaultCStringEncoding]], QTMovieFileNameAttribute,
- [NSNumber numberWithBool:NO], QTMovieEditableAttribute,
- nil];
-
- anim->qtime->movie = [QTMovie movieWithAttributes:attributes error:NULL];
-
- if (!anim->qtime->movie) {
- if (QTIME_DEBUG) printf("qt: bad movie %s\n", anim->name);
- MEM_freeN(anim->qtime);
- if (QTIME_DEBUG) printf("qt: can't load %s\n", anim->name);
- [QTMovie exitQTKitOnThread];
- [pool drain];
- return -1;
- }
- [anim->qtime->movie retain];
-
- // sets Media and Track!
-
- videoTracks = [anim->qtime->movie tracksOfMediaType:QTMediaTypeVideo];
-
- if ([videoTracks count] == 0) {
- if (QTIME_DEBUG) printf("qt: no video tracks for movie %s\n", anim->name);
- [anim->qtime->movie release];
- MEM_freeN(anim->qtime);
- if (QTIME_DEBUG) printf("qt: can't load %s\n", anim->name);
- [QTMovie exitQTKitOnThread];
- [pool drain];
- return -1;
- }
-
- anim->qtime->media = [[videoTracks objectAtIndex:0] media];
- [anim->qtime->media retain];
-
-
- frameSize = [[anim->qtime->movie attributeForKey:QTMovieNaturalSizeAttribute] sizeValue];
- anim->x = frameSize.width;
- anim->y = frameSize.height;
-
- if (anim->x == 0 && anim->y == 0) {
- if (QTIME_DEBUG) printf("qt: error, no dimensions\n");
- free_anim_quicktime(anim);
- [pool drain];
- return -1;
- }
-
- anim->qtime->ibuf = IMB_allocImBuf(anim->x, anim->y, 32, IB_rect);
-
- qtTimeDuration = [[anim->qtime->media attributeForKey:QTMediaDurationAttribute] QTTimeValue];
- anim->qtime->durationTime = qtTimeDuration.timeValue;
- anim->qtime->durationScale = qtTimeDuration.timeScale;
-
- anim->qtime->framecount = [[anim->qtime->media attributeForKey:QTMediaSampleCountAttribute] longValue];
- anim->qtime->previousPosition = -2; //Force seeking for first read
-
- //fill blender's anim struct
-
- anim->duration = anim->qtime->framecount;
- anim->params = 0;
-
- anim->interlacing = 0;
- anim->orientation = 0;
- anim->framesize = anim->x * anim->y * 4;
-
- anim->curposition = 0;
-
- [pool drain];
-
- return 0;
-}
-
-#endif /* WITH_QUICKTIME */
-
diff --git a/source/blender/quicktime/quicktime_export.h b/source/blender/quicktime/quicktime_export.h
deleted file mode 100644
index aaa3f5c9070..00000000000
--- a/source/blender/quicktime/quicktime_export.h
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/quicktime/quicktime_export.h
- * \ingroup quicktime
- */
-
-
-#ifndef __QUICKTIME_EXPORT_H__
-#define __QUICKTIME_EXPORT_H__
-
-#if defined (_WIN32) || (__APPLE__)
-
-#define __AIFF__
-
-
-#define QTAUDIO_FLAG_RESAMPLE_NOHQ 1
-#define QTAUDIO_FLAG_CODEC_ISCBR 2
-
-
-/*Codec list*/
-typedef struct QuicktimeCodecTypeDesc {
- int codecType;
- int rnatmpvalue;
- const char *codecName;
-} QuicktimeCodecTypeDesc;
-
-// quicktime movie output functions
-struct ImageFormatData;
-struct RenderData;
-struct ReportList;
-struct Scene;
-
-int start_qt(void *context_v, struct Scene *scene, struct RenderData *rd, int rectx, int recty, struct ReportList *reports, bool preview, const char *suffix); //for movie handle (BKE writeavi.c now)
-int append_qt(void *context_v, struct RenderData *rd, int start_frame, int frame, int *pixels, int rectx, int recty, const char *suffix, struct ReportList *reports);
-void end_qt(void *context_v);
-void filepath_qt(char *string, struct RenderData *rd, bool preview, const char *suffix);
-void *context_create_qt(void);
-void context_free_qt(void *context_v);
-
-/*RNA helper functions */
-void quicktime_verify_image_type(struct RenderData *rd, struct ImageFormatData *imf); //used by RNA for defaults values init, if needed
-/*Video codec type*/
-int quicktime_get_num_videocodecs(void);
-QuicktimeCodecTypeDesc *quicktime_get_videocodecType_desc(int indexValue);
-int quicktime_rnatmpvalue_from_videocodectype(int codecType);
-int quicktime_videocodecType_from_rnatmpvalue(int rnatmpvalue);
-
-/*Audio codec type*/
-int quicktime_get_num_audiocodecs(void);
-QuicktimeCodecTypeDesc *quicktime_get_audiocodecType_desc(int indexValue);
-int quicktime_rnatmpvalue_from_audiocodectype(int codecType);
-int quicktime_audiocodecType_from_rnatmpvalue(int rnatmpvalue);
-
-void free_qtcomponentdata(void);
-void makeqtstring(struct RenderData *rd, char *string, bool preview); //for playanim.c
-
-
-#ifdef __APPLE__
-//Include the quicktime codec types constants that are missing in QTKitDefines.h
-enum {
- kRawCodecType = 'raw ',
- kCinepakCodecType = 'cvid',
- kGraphicsCodecType = 'smc ',
- kAnimationCodecType = 'rle ',
- kVideoCodecType = 'rpza',
- kComponentVideoCodecType = 'yuv2',
- kJPEGCodecType = 'jpeg',
- kMotionJPEGACodecType = 'mjpa',
- kMotionJPEGBCodecType = 'mjpb',
- kSGICodecType = '.SGI',
- kPlanarRGBCodecType = '8BPS',
- kMacPaintCodecType = 'PNTG',
- kGIFCodecType = 'gif ',
- kPhotoCDCodecType = 'kpcd',
- kQuickDrawGXCodecType = 'qdgx',
- kAVRJPEGCodecType = 'avr ',
- kOpenDMLJPEGCodecType = 'dmb1',
- kBMPCodecType = 'WRLE',
- kWindowsRawCodecType = 'WRAW',
- kVectorCodecType = 'path',
- kQuickDrawCodecType = 'qdrw',
- kWaterRippleCodecType = 'ripl',
- kFireCodecType = 'fire',
- kCloudCodecType = 'clou',
- kH261CodecType = 'h261',
- kH263CodecType = 'h263',
- kDVCNTSCCodecType = 'dvc ', /* DV - NTSC and DVCPRO NTSC (available in QuickTime 6.0 or later)*/
- /* NOTE: kDVCProNTSCCodecType is deprecated. */
- /* Use kDVCNTSCCodecType instead -- as far as the codecs are concerned, */
- /* the two data formats are identical.*/
- kDVCPALCodecType = 'dvcp',
- kDVCProPALCodecType = 'dvpp', /* available in QuickTime 6.0 or later*/
- kDVCPro50NTSCCodecType = 'dv5n',
- kDVCPro50PALCodecType = 'dv5p',
- kDVCPro100NTSCCodecType = 'dv1n',
- kDVCPro100PALCodecType = 'dv1p',
- kDVCPROHD720pCodecType = 'dvhp',
- kDVCPROHD1080i60CodecType = 'dvh6',
- kDVCPROHD1080i50CodecType = 'dvh5',
- kBaseCodecType = 'base',
- kFLCCodecType = 'flic',
- kTargaCodecType = 'tga ',
- kPNGCodecType = 'png ',
- kTIFFCodecType = 'tiff', /* NOTE: despite what might seem obvious from the two constants*/
- /* below and their names, they really are correct. 'yuvu' really */
- /* does mean signed, and 'yuvs' really does mean unsigned. Really. */
- kComponentVideoSigned = 'yuvu',
- kComponentVideoUnsigned = 'yuvs',
- kCMYKCodecType = 'cmyk',
- kMicrosoftVideo1CodecType = 'msvc',
- kSorensonCodecType = 'SVQ1',
- kSorenson3CodecType = 'SVQ3', /* available in QuickTime 5 and later*/
- kIndeo4CodecType = 'IV41',
- kMPEG4VisualCodecType = 'mp4v',
- k64ARGBCodecType = 'b64a',
- k48RGBCodecType = 'b48r',
- k32AlphaGrayCodecType = 'b32a',
- k16GrayCodecType = 'b16g',
- kMpegYUV420CodecType = 'myuv',
- kYUV420CodecType = 'y420',
- kSorensonYUV9CodecType = 'syv9',
- k422YpCbCr8CodecType = '2vuy', /* Component Y'CbCr 8-bit 4:2:2 */
- k444YpCbCr8CodecType = 'v308', /* Component Y'CbCr 8-bit 4:4:4 */
- k4444YpCbCrA8CodecType = 'v408', /* Component Y'CbCrA 8-bit 4:4:4:4 */
- k422YpCbCr16CodecType = 'v216', /* Component Y'CbCr 10,12,14,16-bit 4:2:2*/
- k422YpCbCr10CodecType = 'v210', /* Component Y'CbCr 10-bit 4:2:2 */
- k444YpCbCr10CodecType = 'v410', /* Component Y'CbCr 10-bit 4:4:4 */
- k4444YpCbCrA8RCodecType = 'r408', /* Component Y'CbCrA 8-bit 4:4:4:4, rendering format. full range alpha, zero biased yuv*/
- kJPEG2000CodecType = 'mjp2',
- kPixletCodecType = 'pxlt',
- kH264CodecType = 'avc1'
-};
-#endif
-
-#endif /* (_WIN32) || (__APPLE__) */
-
-#endif /* __QUICKTIME_IMP_H__ */
diff --git a/source/blender/quicktime/quicktime_import.h b/source/blender/quicktime/quicktime_import.h
deleted file mode 100644
index 3c6b2028031..00000000000
--- a/source/blender/quicktime/quicktime_import.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Quicktime_import.h
- *
- *
- * ***** 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) 2002-2003 by TNCCI Inc.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/quicktime/quicktime_import.h
- * \ingroup quicktime
- */
-
-
-
-#ifndef __QUICKTIME_IMPORT_H__
-#define __QUICKTIME_IMPORT_H__
-
-#define __AIFF__
-
-#include "../imbuf/IMB_imbuf.h"
-#include "../imbuf/IMB_imbuf_types.h"
-
-#ifdef _WIN32
-# ifndef __FIXMATH__
-# include <FixMath.h>
-# endif /* __FIXMATH__ */
-#endif /* _WIN32 _ */
-
-/* init/exit */
-
-void quicktime_init(void);
-void quicktime_exit(void);
-
-/* quicktime movie import functions */
-
-int anim_is_quicktime(const char *name);
-int startquicktime(struct anim *anim);
-void free_anim_quicktime(struct anim *anim);
-ImBuf *qtime_fetchibuf(struct anim *anim, int position);
-
-#endif /* __QUICKTIME_IMPORT_H__ */
diff --git a/source/blender/render/CMakeLists.txt b/source/blender/render/CMakeLists.txt
index 282942709f0..5cbc907d9c6 100644
--- a/source/blender/render/CMakeLists.txt
+++ b/source/blender/render/CMakeLists.txt
@@ -149,16 +149,6 @@ if(WITH_FREESTYLE)
add_definitions(-DWITH_FREESTYLE)
endif()
-if(WITH_CODEC_QUICKTIME)
- list(APPEND INC
- ../quicktime
- )
- list(APPEND INC_SYS
- ${QUICKTIME_INCLUDE_DIRS}
- )
- add_definitions(-DWITH_QUICKTIME)
-endif()
-
if(WITH_GAMEENGINE)
add_definitions(-DWITH_GAMEENGINE)
endif()
diff --git a/source/blender/render/extern/include/RE_engine.h b/source/blender/render/extern/include/RE_engine.h
index 3086c9d4fad..a4de7104071 100644
--- a/source/blender/render/extern/include/RE_engine.h
+++ b/source/blender/render/extern/include/RE_engine.h
@@ -189,5 +189,7 @@ struct RenderData *RE_engine_get_render_data(struct Render *re);
void RE_bake_engine_set_engine_parameters(
struct Render *re, struct Main *bmain, struct Depsgraph *graph, struct Scene *scene);
+struct SceneLayer *RE_engine_get_scene_layer(struct Render *re);
+
#endif /* __RE_ENGINE_H__ */
diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h
index 145186548e6..09f308da10a 100644
--- a/source/blender/render/extern/include/RE_pipeline.h
+++ b/source/blender/render/extern/include/RE_pipeline.h
@@ -38,6 +38,7 @@
struct bMovieHandle;
struct bNodeTree;
struct Depsgraph;
+struct EvaluationContext;
struct Image;
struct ImageFormatData;
struct Main;
@@ -195,6 +196,10 @@ typedef struct RenderStats {
struct Render *RE_NewRender(const char *name);
struct Render *RE_GetRender(const char *name);
+struct Scene;
+struct Render *RE_NewSceneRender(const struct Scene *scene);
+struct Render *RE_GetSceneRender(const struct Scene *scene);
+
/* assign default dummy callbacks */
void RE_InitRenderCB(struct Render *re);
@@ -369,6 +374,7 @@ void RE_DataBase_GetView(struct Render *re, float mat[4][4]);
void RE_GetCameraWindow(struct Render *re, struct Object *camera, int frame, float mat[4][4]);
void RE_GetCameraModelMatrix(struct Render *re, struct Object *camera, float r_mat[4][4]);
struct Scene *RE_GetScene(struct Render *re);
+struct EvaluationContext *RE_GetEvalCtx(struct Render *re);
bool RE_force_single_renderlayer(struct Scene *scene);
bool RE_is_rendering_allowed(struct Scene *scene, struct Object *camera_override, struct ReportList *reports);
diff --git a/source/blender/render/extern/include/RE_render_ext.h b/source/blender/render/extern/include/RE_render_ext.h
index 2b5d0ca4e14..82bb265e20c 100644
--- a/source/blender/render/extern/include/RE_render_ext.h
+++ b/source/blender/render/extern/include/RE_render_ext.h
@@ -41,11 +41,13 @@ struct DerivedMesh;
struct ImagePool;
struct MTex;
struct Scene;
+struct SceneLayer;
+struct Render;
/* render_texture.c */
/* used by particle.c, effect.c, editmesh_modes.c and brush.c, returns 1 if rgb, 0 otherwise */
int externtex(
- struct MTex *mtex, const float vec[3], float *tin, float *tr, float *tg, float *tb, float *ta,
+ const struct MTex *mtex, const float vec[3], float *tin, float *tr, float *tg, float *tb, float *ta,
const int thread, struct ImagePool *pool, const bool skip_load_image, const bool texnode_preview);
void texture_rgb_blend(float in[3], const float tex[3], const float out[3], float fact, float facg, int blendtype);
float texture_value_blend(float tex, float out, float fact, float facg, int blendtype);
@@ -70,17 +72,20 @@ struct PointDensity;
void RE_point_density_cache(
struct Scene *scene,
+ struct SceneLayer *sl,
struct PointDensity *pd,
const bool use_render_params);
void RE_point_density_minmax(
struct Scene *scene,
+ struct SceneLayer *sl,
struct PointDensity *pd,
const bool use_render_params,
float r_min[3], float r_max[3]);
void RE_point_density_sample(
struct Scene *scene,
+ struct SceneLayer *sl,
struct PointDensity *pd,
const int resolution,
const bool use_render_params,
diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h
index b1b95933584..1de1f23f351 100644
--- a/source/blender/render/intern/include/render_types.h
+++ b/source/blender/render/intern/include/render_types.h
@@ -337,7 +337,7 @@ typedef struct ObjectRen {
char (*mcol)[MAX_CUSTOMDATA_LAYER_NAME];
int actmtface, actmcol, bakemtface;
- char tangent_mask; /* which tangent layer should be calculated */
+ short tangent_mask; /* which tangent layer should be calculated */
float obmat[4][4]; /* only used in convertblender.c, for instancing */
diff --git a/source/blender/render/intern/include/shading.h b/source/blender/render/intern/include/shading.h
index 13f16ce0bd7..3ef6e9d7476 100644
--- a/source/blender/render/intern/include/shading.h
+++ b/source/blender/render/intern/include/shading.h
@@ -57,7 +57,7 @@ typedef struct ShadeSample {
void shade_material_loop(struct ShadeInput *shi, struct ShadeResult *shr);
void shade_input_set_triangle_i(struct ShadeInput *shi, struct ObjectInstanceRen *obi, struct VlakRen *vlr, short i1, short i2, short i3);
-void shade_input_set_triangle(struct ShadeInput *shi, volatile int obi, volatile int facenr, int normal_flip);
+void shade_input_set_triangle(struct ShadeInput *shi, int obi, int facenr, int normal_flip);
void shade_input_copy_triangle(struct ShadeInput *shi, struct ShadeInput *from);
void shade_input_calc_viewco(struct ShadeInput *shi, float x, float y, float z, float view[3], float dxyview[2], float co[3], float dxco[3], float dyco[3]);
void shade_input_set_viewco(struct ShadeInput *shi, float x, float y, float sx, float sy, float z);
diff --git a/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp b/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp
index 81e41a20f2e..103fa3e6034 100644
--- a/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp
+++ b/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp
@@ -59,6 +59,7 @@ static void rtbuild_init(RTBuilder *b)
b->primitives.begin = NULL;
b->primitives.end = NULL;
b->primitives.maxsize = 0;
+ b->depth = 0;
for (int i = 0; i < RTBUILD_MAX_CHILDS; i++)
b->child_offset[i] = 0;
@@ -178,6 +179,8 @@ RTBuilder *rtbuild_get_child(RTBuilder *b, int child, RTBuilder *tmp)
{
rtbuild_init(tmp);
+ tmp->depth = b->depth + 1;
+
for (int i = 0; i < 3; i++)
if (b->sorted_begin[i]) {
tmp->sorted_begin[i] = b->sorted_begin[i] + b->child_offset[child];
@@ -336,6 +339,15 @@ int rtbuild_heuristic_object_split(RTBuilder *b, int nchilds)
int baxis = -1, boffset = 0;
if (size > nchilds) {
+ if (b->depth > RTBUILD_MAX_SAH_DEPTH) {
+ // for degenerate cases we avoid running out of stack space
+ // by simply splitting the children in the middle
+ b->child_offset[0] = 0;
+ b->child_offset[1] = (size+1)/2;
+ b->child_offset[2] = size;
+ return 2;
+ }
+
float bcost = FLT_MAX;
baxis = -1;
boffset = size / 2;
diff --git a/source/blender/render/intern/raytrace/rayobject_rtbuild.h b/source/blender/render/intern/raytrace/rayobject_rtbuild.h
index 9e296da144b..83042ef3d7e 100644
--- a/source/blender/render/intern/raytrace/rayobject_rtbuild.h
+++ b/source/blender/render/intern/raytrace/rayobject_rtbuild.h
@@ -49,7 +49,8 @@ extern "C" {
* generate with simple calls, and then convert to the theirs
* specific structure on the fly.
*/
-#define RTBUILD_MAX_CHILDS 32
+#define RTBUILD_MAX_CHILDS 32
+#define RTBUILD_MAX_SAH_DEPTH 256
typedef struct RTBuilder {
@@ -79,6 +80,8 @@ typedef struct RTBuilder {
float bb[6];
+ /* current depth */
+ int depth;
} RTBuilder;
/* used during creation */
diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c
index 803244cdd63..1329ad484ea 100644
--- a/source/blender/render/intern/source/convertblender.c
+++ b/source/blender/render/intern/source/convertblender.c
@@ -272,7 +272,7 @@ static void calc_tangent_vector(ObjectRen *obr, VlakRen *vlr, int do_tangent)
}
else return;
- tangent_from_uv(uv1, uv2, uv3, v1->co, v2->co, v3->co, vlr->n, tang);
+ tangent_from_uv_v3(uv1, uv2, uv3, v1->co, v2->co, v3->co, vlr->n, tang);
if (do_tangent) {
tav= RE_vertren_get_tangent(obr, v1, 1);
@@ -284,7 +284,7 @@ static void calc_tangent_vector(ObjectRen *obr, VlakRen *vlr, int do_tangent)
}
if (v4) {
- tangent_from_uv(uv1, uv3, uv4, v1->co, v3->co, v4->co, vlr->n, tang);
+ tangent_from_uv_v3(uv1, uv3, uv4, v1->co, v3->co, v4->co, vlr->n, tang);
if (do_tangent) {
tav= RE_vertren_get_tangent(obr, v1, 1);
@@ -399,7 +399,7 @@ static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, bool do_verte
float *n4= (vlr->v4)? vlr->v4->n: NULL;
const float *c4= (vlr->v4)? vlr->v4->co: NULL;
- accumulate_vertex_normals(vlr->v1->n, vlr->v2->n, vlr->v3->n, n4,
+ accumulate_vertex_normals_v3(vlr->v1->n, vlr->v2->n, vlr->v3->n, n4,
vlr->n, vlr->v1->co, vlr->v2->co, vlr->v3->co, c4);
}
if (do_tangent) {
@@ -1350,10 +1350,11 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
if (!(psmd->modifier.mode & eModifierMode_Render))
return 0;
- sim.scene= re->scene;
- sim.ob= ob;
- sim.psys= psys;
- sim.psmd= psmd;
+ sim.eval_ctx = re->eval_ctx;
+ sim.scene = re->scene;
+ sim.ob = ob;
+ sim.psys = psys;
+ sim.psmd = psmd;
if (part->phystype==PART_PHYS_KEYED)
psys_count_keyed_targets(&sim);
@@ -2600,13 +2601,13 @@ static void init_render_surf(Render *re, ObjectRen *obr, int timeoffset)
if (ob->parent && (ob->parent->type==OB_LATTICE)) need_orco= 1;
- BKE_displist_make_surf(re->scene, ob, &displist, &dm, 1, 0, 1);
+ BKE_displist_make_surf(re->eval_ctx, re->scene, ob, &displist, &dm, 1, 0, 1);
if (dm) {
if (need_orco) {
orco = get_object_orco(re, ob);
if (!orco) {
- orco= BKE_displist_make_orco(re->scene, ob, dm, true, true);
+ orco= BKE_displist_make_orco(re->eval_ctx, re->scene, ob, dm, true, true);
if (orco) {
set_object_orco(re, ob, orco);
}
@@ -2658,7 +2659,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset)
if (ob->type==OB_FONT && cu->str==NULL) return;
else if (ob->type==OB_CURVE && cu->nurb.first==NULL) return;
- BKE_displist_make_curveTypes_forRender(re->scene, ob, &disp, &dm, false, true);
+ BKE_displist_make_curveTypes_forRender(re->eval_ctx, re->scene, ob, &disp, &dm, false, true);
dl= disp.first;
if (dl==NULL) return;
@@ -2685,7 +2686,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset)
if (need_orco) {
orco = get_object_orco(re, ob);
if (!orco) {
- orco = BKE_displist_make_orco(re->scene, ob, dm, true, true);
+ orco = BKE_displist_make_orco(re->eval_ctx, re->scene, ob, dm, true, true);
if (orco) {
set_object_orco(re, ob, orco);
}
@@ -2699,7 +2700,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset)
if (need_orco) {
orco = get_object_orco(re, ob);
if (!orco) {
- orco = BKE_curve_make_orco(re->scene, ob, NULL);
+ orco = BKE_curve_make_orco(re->eval_ctx, re->scene, ob, NULL);
set_object_orco(re, ob, orco);
}
}
@@ -3199,9 +3200,9 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset)
#endif
if (re->r.scemode & R_VIEWPORT_PREVIEW)
- dm= mesh_create_derived_view(re->scene, ob, mask);
+ dm= mesh_create_derived_view(re->eval_ctx, re->scene, ob, mask);
else
- dm= mesh_create_derived_render(re->scene, ob, mask);
+ dm= mesh_create_derived_render(re->eval_ctx, re->scene, ob, mask);
if (dm==NULL) return; /* in case duplicated object fails? */
mvert= dm->getVertArray(dm);
@@ -3440,10 +3441,9 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset)
if (need_nmap_tangent_concrete || need_tangent) {
int uv_start = CustomData_get_layer_index(&dm->faceData, CD_MTFACE);
int uv_index = CustomData_get_named_layer_index(&dm->faceData, CD_MTFACE, layer->name);
- BLI_assert(uv_start >= 0 && uv_index >= 0);
- if ((uv_start < 0 || uv_index < 0))
- continue;
- int n = uv_index - uv_start;
+
+ /* if there are no UVs, orco tangents are in first slot */
+ int n = (uv_start >= 0 && uv_index >= 0) ? uv_index - uv_start : 0;
const float *tangent = (const float *) layer->data;
float *ftang = RE_vlakren_get_nmap_tangent(obr, vlr, n, true);
@@ -4620,9 +4620,9 @@ static void init_render_object_data(Render *re, ObjectRen *obr, int timeoffset)
const CustomDataMask mask = CD_MASK_RENDER_INTERNAL;
if (re->r.scemode & R_VIEWPORT_PREVIEW)
- dm = mesh_create_derived_view(re->scene, ob, mask);
+ dm = mesh_create_derived_view(re->eval_ctx, re->scene, ob, mask);
else
- dm = mesh_create_derived_render(re->scene, ob, mask);
+ dm = mesh_create_derived_render(re->eval_ctx, re->scene, ob, mask);
dm->release(dm);
}
@@ -4659,14 +4659,22 @@ static void add_render_object(Render *re, Object *ob, Object *par, DupliObject *
index= (dob)? dob->persistent_id[0]: 0;
+ /* It seems that we may generate psys->renderdata recursively in some nasty intricated cases of
+ * several levels of bupliobject (see T51524).
+ * For now, basic rule is, do not restore psys if it was already in 'render state'.
+ * Another, more robust solution could be to add some reference counting to that renderdata... */
+ bool psys_has_renderdata = false;
+
/* the emitter has to be processed first (render levels of modifiers) */
/* so here we only check if the emitter should be rendered */
if (ob->particlesystem.first) {
show_emitter= 0;
for (psys=ob->particlesystem.first; psys; psys=psys->next) {
show_emitter += psys->part->draw & PART_DRAW_EMITTER;
- if (!(re->r.scemode & R_VIEWPORT_PREVIEW))
+ if (!(re->r.scemode & R_VIEWPORT_PREVIEW)) {
+ psys_has_renderdata |= (psys->renderdata != NULL);
psys_render_set(ob, psys, re->viewmat, re->winmat, re->winx, re->winy, timeoffset);
+ }
}
/* if no psys has "show emitter" selected don't render emitter */
@@ -4702,12 +4710,6 @@ static void add_render_object(Render *re, Object *ob, Object *par, DupliObject *
if (ob->particlesystem.first) {
psysindex= 1;
for (psys=ob->particlesystem.first; psys; psys=psys->next, psysindex++) {
- /* It seems that we may generate psys->renderdata recursively in some nasty intricated cases of
- * several levels of bupliobject (see T51524).
- * For now, basic rule is, do not restore psys if it was already in 'render state'.
- * Another, more robust solution could be to add some reference counting to that renderdata... */
- const bool psys_has_renderdata = (psys->renderdata != NULL);
-
if (!psys_check_enabled(ob, psys, G.is_rendering))
continue;
@@ -4929,7 +4931,7 @@ static void dupli_render_particle_set(Render *re, Object *ob, int timeoffset, in
/* this is to make sure we get render level duplis in groups:
* the derivedmesh must be created before init_render_mesh,
* since object_duplilist does dupliparticles before that */
- dm = mesh_create_derived_render(re->scene, ob, CD_MASK_RENDER_INTERNAL);
+ dm = mesh_create_derived_render(re->eval_ctx, re->scene, ob, CD_MASK_RENDER_INTERNAL);
dm->release(dm);
for (psys=ob->particlesystem.first; psys; psys=psys->next)
@@ -5052,7 +5054,7 @@ static void database_init_objects(Render *re, unsigned int UNUSED(renderlay), in
* system need to have render settings set for dupli particles */
dupli_render_particle_set(re, ob, timeoffset, 0, 1);
duplilist = object_duplilist(re->eval_ctx, re->scene, ob);
- duplilist_apply_data = duplilist_apply(ob, NULL, duplilist);
+ duplilist_apply_data = duplilist_apply(re->eval_ctx, ob, NULL, duplilist);
/* postpone 'dupli_render_particle_set', since RE_addRenderInstance reads
* index values from 'dob->persistent_id[0]', referencing 'psys->child' which
* may be smaller once the particle system is restored, see: T45563. */
diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/source/external_engine.c
index be6d6459b2f..c2e6d540ad8 100644
--- a/source/blender/render/intern/source/external_engine.c
+++ b/source/blender/render/intern/source/external_engine.c
@@ -791,3 +791,8 @@ void RE_engine_register_pass(struct RenderEngine *engine, struct Scene *scene, s
}
}
}
+
+SceneLayer *RE_engine_get_scene_layer(Render *re)
+{
+ return re->eval_ctx->scene_layer;
+}
diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c
index 04010522c12..ae02cf56b88 100644
--- a/source/blender/render/intern/source/imagetexture.c
+++ b/source/blender/render/intern/source/imagetexture.c
@@ -1172,7 +1172,7 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
a = max_ff(a, 1.0f);
b = max_ff(b, 1.0f);
fProbes = 2.f*(a / b) - 1.f;
- AFD.iProbes = iroundf(fProbes);
+ AFD.iProbes = round_fl_to_int(fProbes);
AFD.iProbes = MIN2(AFD.iProbes, tex->afmax);
if (AFD.iProbes < fProbes)
b = 2.f*a / (float)(AFD.iProbes + 1);
@@ -1277,7 +1277,7 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
b = max_ff(b, 1.0f);
fProbes = 2.f*(a / b) - 1.f;
/* no limit to number of Probes here */
- AFD.iProbes = iroundf(fProbes);
+ AFD.iProbes = round_fl_to_int(fProbes);
if (AFD.iProbes < fProbes) b = 2.f*a / (float)(AFD.iProbes + 1);
AFD.majrad = a/ff;
AFD.minrad = b/ff;
diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c
index 4ac44671871..731a5ec4e22 100644
--- a/source/blender/render/intern/source/initrender.c
+++ b/source/blender/render/intern/source/initrender.c
@@ -50,10 +50,6 @@
#include "DEG_depsgraph.h"
-#ifdef WITH_QUICKTIME
-#include "quicktime_export.h"
-#endif
-
/* this module */
#include "renderpipeline.h"
#include "render_types.h"
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index ecbb9fbee0b..2a390c5fb97 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -64,6 +64,7 @@
#include "BKE_colortools.h"
#include "BKE_global.h"
#include "BKE_image.h"
+#include "BKE_layer.h"
#include "BKE_library.h"
#include "BKE_library_remap.h"
#include "BKE_main.h"
@@ -308,7 +309,6 @@ Render *RE_GetRender(const char *name)
return re;
}
-
/* if you want to know exactly what has been done */
RenderResult *RE_AcquireResultRead(Render *re)
{
@@ -353,6 +353,15 @@ Scene *RE_GetScene(Render *re)
return NULL;
}
+EvaluationContext *RE_GetEvalCtx(Render *re)
+{
+ if (re) {
+ return re->eval_ctx;
+ }
+
+ return NULL;
+}
+
/**
* Same as #RE_AcquireResultImage but creating the necessary views to store the result
* fill provided result struct with a copy of thew views of what is done so far the
@@ -515,6 +524,36 @@ Render *RE_NewRender(const char *name)
return re;
}
+/* MAX_ID_NAME + sizeof(Library->name) + space + null-terminator. */
+#define MAX_SCENE_RENDER_NAME (MAX_ID_NAME + 1024 + 2)
+
+static void scene_render_name_get(const Scene *scene,
+ const size_t max_size,
+ char *render_name)
+{
+ if (ID_IS_LINKED_DATABLOCK(scene)) {
+ BLI_snprintf(render_name, max_size, "%s %s",
+ scene->id.lib->id.name, scene->id.name);
+ }
+ else {
+ BLI_snprintf(render_name, max_size, "%s", scene->id.name);
+ }
+}
+
+Render *RE_GetSceneRender(const Scene *scene)
+{
+ char render_name[MAX_SCENE_RENDER_NAME];
+ scene_render_name_get(scene, sizeof(render_name), render_name);
+ return RE_GetRender(render_name);
+}
+
+Render *RE_NewSceneRender(const Scene *scene)
+{
+ char render_name[MAX_SCENE_RENDER_NAME];
+ scene_render_name_get(scene, sizeof(render_name), render_name);
+ return RE_NewRender(render_name);
+}
+
/* called for new renders and when finishing rendering so
* we always have valid callbacks on a render */
void RE_InitRenderCB(Render *re)
@@ -725,6 +764,8 @@ void RE_InitState(Render *re, Render *source, RenderData *rd,
re->r.size = source->r.size;
}
+ re_init_resolution(re, source, winx, winy, disprect);
+
/* disable border if it's a full render anyway */
if (re->r.border.xmin == 0.0f && re->r.border.xmax == 1.0f &&
re->r.border.ymin == 0.0f && re->r.border.ymax == 1.0f)
@@ -732,8 +773,6 @@ void RE_InitState(Render *re, Render *source, RenderData *rd,
re->r.mode &= ~R_BORDER;
}
- re_init_resolution(re, source, winx, winy, disprect);
-
if (re->rectx < 1 || re->recty < 1 || (BKE_imtype_is_movie(rd->im_format.imtype) &&
(re->rectx < 16 || re->recty < 16) ))
{
@@ -1915,7 +1954,7 @@ static void do_render_fields_blur_3d(Render *re)
*/
static void render_scene(Render *re, Scene *sce, int cfra)
{
- Render *resc = RE_NewRender(sce->id.name);
+ Render *resc = RE_NewSceneRender(sce);
int winx = re->winx, winy = re->winy;
sce->r.cfra = cfra;
@@ -2351,7 +2390,7 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree)
tag_scenes_for_render(re);
for (sce = re->main->scene.first; sce; sce = sce->id.next) {
if (sce->id.tag & LIB_TAG_DOIT) {
- re1 = RE_GetRender(sce->id.name);
+ re1 = RE_GetSceneRender(sce);
if (re1 && (re1->r.scemode & R_FULL_SAMPLE)) {
if (sample) {
@@ -3795,6 +3834,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
void RE_PreviewRender(Render *re, Main *bmain, Scene *sce)
{
Object *camera;
+ SceneLayer *scene_layer = BKE_scene_layer_from_scene_get(sce);
int winx, winy;
winx = (sce->r.size * sce->r.xsch) / 100;
@@ -3808,7 +3848,8 @@ void RE_PreviewRender(Render *re, Main *bmain, Scene *sce)
re->scene = sce;
re->scene_color_manage = BKE_scene_check_color_management_enabled(sce);
re->lay = sce->lay;
- re->depsgraph = sce->depsgraph;
+ re->depsgraph = BKE_scene_get_depsgraph(sce, scene_layer);
+ re->eval_ctx->scene_layer = scene_layer;
camera = RE_GetCamera(re);
RE_SetCamera(re, camera);
@@ -3851,9 +3892,9 @@ bool RE_ReadRenderResult(Scene *scene, Scene *scenode)
scene = scenode;
/* get render: it can be called from UI with draw callbacks */
- re = RE_GetRender(scene->id.name);
+ re = RE_GetSceneRender(scene);
if (re == NULL)
- re = RE_NewRender(scene->id.name);
+ re = RE_NewSceneRender(scene);
RE_InitState(re, NULL, &scene->r, NULL, winx, winy, &disprect);
re->scene = scene;
re->scene_color_manage = BKE_scene_check_color_management_enabled(scene);
diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c
index fb047aad897..63fe7e4471a 100644
--- a/source/blender/render/intern/source/pointdensity.c
+++ b/source/blender/render/intern/source/pointdensity.c
@@ -58,6 +58,8 @@
#include "BKE_texture.h"
#include "BKE_colortools.h"
+#include "DEG_depsgraph.h"
+
#include "render_types.h"
#include "texture.h"
#include "pointdensity.h"
@@ -167,7 +169,7 @@ static void alloc_point_data(PointDensity *pd)
}
}
-static void pointdensity_cache_psys(Scene *scene,
+static void pointdensity_cache_psys(EvaluationContext *eval_ctx, Scene *scene,
PointDensity *pd,
Object *ob,
ParticleSystem *psys,
@@ -201,12 +203,12 @@ static void pointdensity_cache_psys(Scene *scene,
}
if (use_render_params) {
- dm = mesh_create_derived_render(scene,
+ dm = mesh_create_derived_render(eval_ctx, scene,
ob,
CD_MASK_BAREMESH | CD_MASK_MTFACE | CD_MASK_MCOL);
}
else {
- dm = mesh_get_derived_final(scene,
+ dm = mesh_get_derived_final(eval_ctx, scene,
ob,
CD_MASK_BAREMESH | CD_MASK_MTFACE | CD_MASK_MCOL);
}
@@ -216,6 +218,7 @@ static void pointdensity_cache_psys(Scene *scene,
return;
}
+ sim.eval_ctx = eval_ctx;
sim.scene = scene;
sim.ob = ob;
sim.psys = psys;
@@ -400,7 +403,7 @@ static void pointdensity_cache_vertex_normal(PointDensity *pd, Object *UNUSED(ob
}
}
-static void pointdensity_cache_object(Scene *scene,
+static void pointdensity_cache_object(EvaluationContext *eval_ctx, Scene *scene,
PointDensity *pd,
Object *ob,
const bool use_render_params)
@@ -421,10 +424,10 @@ static void pointdensity_cache_object(Scene *scene,
}
if (use_render_params) {
- dm = mesh_create_derived_render(scene, ob, mask);
+ dm = mesh_create_derived_render(eval_ctx, scene, ob, mask);
}
else {
- dm = mesh_get_derived_final(scene, ob, mask);
+ dm = mesh_get_derived_final(eval_ctx, scene, ob, mask);
}
mvert = dm->getVertArray(dm); /* local object space */
@@ -475,7 +478,7 @@ static void pointdensity_cache_object(Scene *scene,
}
-static void cache_pointdensity_ex(Scene *scene,
+static void cache_pointdensity_ex(EvaluationContext *eval_ctx, Scene *scene,
PointDensity *pd,
float viewmat[4][4],
float winmat[4][4],
@@ -504,7 +507,8 @@ static void cache_pointdensity_ex(Scene *scene,
return;
}
- pointdensity_cache_psys(scene,
+ pointdensity_cache_psys(eval_ctx,
+ scene,
pd,
ob,
psys,
@@ -515,13 +519,14 @@ static void cache_pointdensity_ex(Scene *scene,
else if (pd->source == TEX_PD_OBJECT) {
Object *ob = pd->object;
if (ob && ob->type == OB_MESH)
- pointdensity_cache_object(scene, pd, ob, use_render_params);
+ pointdensity_cache_object(eval_ctx, scene, pd, ob, use_render_params);
}
}
void cache_pointdensity(Render *re, PointDensity *pd)
{
- cache_pointdensity_ex(re->scene,
+ cache_pointdensity_ex(re->eval_ctx,
+ re->scene,
pd,
re->viewmat, re->winmat,
re->winx, re->winy,
@@ -876,7 +881,8 @@ static void sample_dummy_point_density(int resolution, float *values)
memset(values, 0, sizeof(float) * 4 * resolution * resolution * resolution);
}
-static void particle_system_minmax(Scene *scene,
+static void particle_system_minmax(EvaluationContext *eval_ctx,
+ Scene *scene,
Object *object,
ParticleSystem *psys,
float radius,
@@ -903,6 +909,7 @@ static void particle_system_minmax(Scene *scene,
psys_render_set(object, psys, mat, mat, 1, 1, 0);
}
+ sim.eval_ctx = eval_ctx;
sim.scene = scene;
sim.ob = object;
sim.psys = psys;
@@ -938,19 +945,28 @@ static void particle_system_minmax(Scene *scene,
void RE_point_density_cache(
Scene *scene,
+ SceneLayer *sl,
PointDensity *pd,
const bool use_render_params)
{
+ EvaluationContext eval_ctx = {0};
float mat[4][4];
+
+ DEG_evaluation_context_init(&eval_ctx, use_render_params ? DAG_EVAL_RENDER
+ : DAG_EVAL_VIEWPORT);
+
+ eval_ctx.scene_layer = sl;
+
/* Same matricies/resolution as dupli_render_particle_set(). */
unit_m4(mat);
BLI_mutex_lock(&sample_mutex);
- cache_pointdensity_ex(scene, pd, mat, mat, 1, 1, use_render_params);
+ cache_pointdensity_ex(&eval_ctx, scene, pd, mat, mat, 1, 1, use_render_params);
BLI_mutex_unlock(&sample_mutex);
}
void RE_point_density_minmax(
struct Scene *scene,
+ SceneLayer *sl,
struct PointDensity *pd,
const bool use_render_params,
float r_min[3], float r_max[3])
@@ -963,6 +979,8 @@ void RE_point_density_minmax(
}
if (pd->source == TEX_PD_PSYS) {
ParticleSystem *psys;
+ EvaluationContext eval_ctx = {0};
+
if (pd->psys == 0) {
zero_v3(r_min);
zero_v3(r_max);
@@ -974,7 +992,15 @@ void RE_point_density_minmax(
zero_v3(r_max);
return;
}
- particle_system_minmax(scene,
+
+ DEG_evaluation_context_init(&eval_ctx, use_render_params ? DAG_EVAL_RENDER :
+ DAG_EVAL_VIEWPORT);
+
+ eval_ctx.ctime = (float)scene->r.cfra + scene->r.subframe;
+ eval_ctx.scene_layer = sl;
+
+ particle_system_minmax(&eval_ctx,
+ scene,
object,
psys,
pd->radius,
@@ -1044,6 +1070,7 @@ static void point_density_sample_func(void *data_v, const int iter)
*/
void RE_point_density_sample(
Scene *scene,
+ SceneLayer *sl,
PointDensity *pd,
const int resolution,
const bool use_render_params,
@@ -1063,6 +1090,7 @@ void RE_point_density_sample(
BLI_mutex_lock(&sample_mutex);
RE_point_density_minmax(scene,
+ sl,
pd,
use_render_params,
min,
diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c
index 26a0b0c71b4..2eb2e95308a 100644
--- a/source/blender/render/intern/source/rayshade.c
+++ b/source/blender/render/intern/source/rayshade.c
@@ -995,7 +995,7 @@ static float *give_jitter_plane(LampRen *lar, int thread, int xs, int ys)
/* **************** QMC sampling *************** */
-static void halton_sample(double *ht_invprimes, double *ht_nums, double *v)
+static void UNUSED_FUNCTION(halton_sample)(double *ht_invprimes, double *ht_nums, double *v)
{
/* incremental halton sequence generator, from:
* "Instant Radiosity", Keller A. */
@@ -1022,26 +1022,6 @@ static void halton_sample(double *ht_invprimes, double *ht_nums, double *v)
}
}
-/* Generate Hammersley points in [0,1)^2
- * From Lucille renderer */
-static void hammersley_create(double *out, int n)
-{
- double p, t;
- int k, kk;
-
- for (k = 0; k < n; k++) {
- t = 0;
- for (p = 0.5, kk = k; kk; p *= 0.5, kk >>= 1) {
- if (kk & 1) { /* kk mod 2 = 1 */
- t += p;
- }
- }
-
- out[2 * k + 0] = (double)k / (double)n;
- out[2 * k + 1] = t;
- }
-}
-
static struct QMCSampler *QMC_initSampler(int type, int tot)
{
QMCSampler *qsa = MEM_callocN(sizeof(QMCSampler), "qmc sampler");
@@ -1051,7 +1031,7 @@ static struct QMCSampler *QMC_initSampler(int type, int tot)
qsa->type = type;
if (qsa->type==SAMP_TYPE_HAMMERSLEY)
- hammersley_create(qsa->samp2d, qsa->tot);
+ BLI_hammersley_2D_sequence(qsa->tot, qsa->samp2d);
return qsa;
}
@@ -1069,20 +1049,13 @@ static void QMC_initPixel(QMCSampler *qsa, int thread)
/* generate a new randomized halton sequence per pixel
* to alleviate qmc artifacts and make it reproducible
* between threads/frames */
- double ht_invprimes[2], ht_nums[2];
- double r[2];
- int i;
+ double ht_offset[2];
+ unsigned int ht_primes[2] = {2, 3};
- ht_nums[0] = BLI_thread_frand(thread);
- ht_nums[1] = BLI_thread_frand(thread);
- ht_invprimes[0] = 0.5;
- ht_invprimes[1] = 1.0/3.0;
+ ht_offset[0] = BLI_thread_frand(thread);
+ ht_offset[1] = BLI_thread_frand(thread);
- for (i=0; i< qsa->tot; i++) {
- halton_sample(ht_invprimes, ht_nums, r);
- qsa->samp2d[2*i+0] = r[0];
- qsa->samp2d[2*i+1] = r[1];
- }
+ BLI_halton_2D_sequence(ht_primes, ht_offset, qsa->tot, qsa->samp2d);
}
}
diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c
index 22dc2b28900..91d1f63a1be 100644
--- a/source/blender/render/intern/source/render_texture.c
+++ b/source/blender/render/intern/source/render_texture.c
@@ -781,7 +781,8 @@ static int cubemap_glob(const float n[3], float x, float y, float z, float *adr1
/* ------------------------------------------------------------------------- */
/* mtex argument only for projection switches */
-static int cubemap(MTex *mtex, VlakRen *vlr, const float n[3], float x, float y, float z, float *adr1, float *adr2)
+static int cubemap(
+ const MTex *mtex, VlakRen *vlr, const float n[3], float x, float y, float z, float *adr1, float *adr2)
{
int proj[4]={0, ME_PROJXY, ME_PROJXZ, ME_PROJYZ}, ret= 0;
@@ -873,7 +874,8 @@ static int cubemap_ob(Object *ob, const float n[3], float x, float y, float z, f
/* ------------------------------------------------------------------------- */
-static void do_2d_mapping(MTex *mtex, float texvec[3], VlakRen *vlr, const float n[3], float dxt[3], float dyt[3])
+static void do_2d_mapping(
+ const MTex *mtex, float texvec[3], VlakRen *vlr, const float n[3], float dxt[3], float dyt[3])
{
Tex *tex;
Object *ob= NULL;
@@ -3594,7 +3596,7 @@ void do_lamp_tex(LampRen *la, const float lavec[3], ShadeInput *shi, float col_r
/* ------------------------------------------------------------------------- */
-int externtex(MTex *mtex,
+int externtex(const MTex *mtex,
const float vec[3],
float *tin, float *tr, float *tg, float *tb, float *ta,
const int thread,
diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c
index 597a2338fe7..660b82b884d 100644
--- a/source/blender/render/intern/source/shadeinput.c
+++ b/source/blender/render/intern/source/shadeinput.c
@@ -292,12 +292,8 @@ void shade_input_set_triangle_i(ShadeInput *shi, ObjectInstanceRen *obi, VlakRen
}
}
-/* note, facenr declared volatile due to over-eager -O2 optimization's
- * on cygwin (particularly -frerun-cse-after-loop)
- */
-
/* copy data from face to ShadeInput, scanline case */
-void shade_input_set_triangle(ShadeInput *shi, volatile int obi, volatile int facenr, int UNUSED(normal_flip))
+void shade_input_set_triangle(ShadeInput *shi, int obi, int facenr, int UNUSED(normal_flip))
{
if (facenr > 0) {
shi->obi = &R.objectinstance[obi];
diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c
index 68707f163af..1481e7a8059 100644
--- a/source/blender/render/intern/source/zbuf.c
+++ b/source/blender/render/intern/source/zbuf.c
@@ -393,7 +393,7 @@ static void zbuffillAc4(ZSpan *zspan, int obi, int zvlnr,
zverg-= zspan->polygon_offset;
while (x>=0) {
- intzverg= (int)CLAMPIS(zverg, INT_MIN, INT_MAX);
+ intzverg = round_db_to_int_clamp(zverg);
if ( intzverg < *rz) {
if (!zspan->rectmask || intzverg > *rm) {
@@ -1137,7 +1137,7 @@ static void zbuffillGLinv4(ZSpan *zspan, int obi, int zvlnr,
x= sn2-sn1;
while (x>=0) {
- intzverg= (int)CLAMPIS(zverg, INT_MIN, INT_MAX);
+ intzverg = round_db_to_int_clamp(zverg);
if ( intzverg > *rz || *rz==0x7FFFFFFF) { /* UNIQUE LINE: see comment above */
if (!zspan->rectmask || intzverg > *rm) {
@@ -1260,7 +1260,7 @@ static void zbuffillGL4(ZSpan *zspan, int obi, int zvlnr,
x= sn2-sn1;
while (x>=0) {
- intzverg= (int)CLAMPIS(zverg, INT_MIN, INT_MAX);
+ intzverg = round_db_to_int_clamp(zverg);
if (intzverg < *rz) { /* ONLY UNIQUE LINE: see comment above */
if (!zspan->rectmask || intzverg > *rm) {
@@ -1383,7 +1383,7 @@ static void zbuffillGL_onlyZ(ZSpan *zspan, int UNUSED(obi), int UNUSED(zvlnr),
x= sn2-sn1;
while (x>=0) {
- int zvergi= (int)CLAMPIS(zverg, INT_MIN, INT_MAX);
+ int zvergi = round_db_to_int_clamp(zverg);
/* option: maintain two depth values, closest and 2nd closest */
if (zvergi < *rz) {
@@ -1564,20 +1564,13 @@ void zspan_scanconvert(ZSpan *zspan, void *handle, float *v1, float *v2, float *
vy0= ((double)my2)*vyd + (double)xx1;
/* correct span */
- sn1= (my0 + my2)/2;
- if (zspan->span1[sn1] < zspan->span2[sn1]) {
- span1= zspan->span1+my2;
- span2= zspan->span2+my2;
- }
- else {
- span1= zspan->span2+my2;
- span2= zspan->span1+my2;
- }
+ span1= zspan->span1+my2;
+ span2= zspan->span2+my2;
for (i = 0, y = my2; y >= my0; i++, y--, span1--, span2--) {
- sn1= floor(*span1);
- sn2= floor(*span2);
+ sn1= floor(min_ff(*span1, *span2));
+ sn2= floor(max_ff(*span1, *span2));
sn1++;
if (sn2>=rectx) sn2= rectx-1;
diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt
index cfa97a9e177..8a6d4bc95c7 100644
--- a/source/blender/windowmanager/CMakeLists.txt
+++ b/source/blender/windowmanager/CMakeLists.txt
@@ -97,7 +97,7 @@ set(SRC
)
if(WITH_AUDASPACE)
- add_definitions(${AUDASPACE_DEFINITIONS})
+ add_definitions(-DWITH_AUDASPACE)
list(APPEND INC_SYS
${AUDASPACE_C_INCLUDE_DIRS}
@@ -114,16 +114,6 @@ if(WITH_OPENCOLLADA)
add_definitions(-DWITH_COLLADA)
endif()
-if(WITH_CODEC_QUICKTIME)
- list(APPEND INC
- ../quicktime
- )
- list(APPEND INC_SYS
- ${QUICKTIME_INCLUDE_DIRS}
- )
- add_definitions(-DWITH_QUICKTIME)
-endif()
-
if(WITH_CODEC_FFMPEG)
list(APPEND INC_SYS
${FFMPEG_INCLUDE_DIRS}
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 3501105d404..762a6f8e8d2 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -42,9 +42,6 @@
#include "WM_keymap.h"
#include "BLI_compiler_attrs.h"
-/* Include external manipulator API's */
-#include "manipulators/WM_manipulator_api.h"
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -68,6 +65,7 @@ struct ImBuf;
struct ImageFormatData;
struct ARegion;
struct ScrArea;
+struct Main;
#ifdef WITH_INPUT_NDOF
struct wmNDOFMotionData;
@@ -125,6 +123,7 @@ enum {
struct wmWindow *WM_window_open(struct bContext *C, const struct rcti *rect);
struct wmWindow *WM_window_open_temp(struct bContext *C, int x, int y, int sizex, int sizey, int type);
+void WM_window_set_dpi(wmWindow *win);
/* returns true if draw method is triple buffer */
bool WM_is_draw_triple(struct wmWindow *win);
@@ -164,6 +163,7 @@ float WM_cursor_pressure (const struct wmWindow *win);
/* event map */
int WM_userdef_event_map(int kmitype);
+int WM_userdef_event_type_from_keymap_type(int kmitype);
/* handlers */
@@ -211,8 +211,9 @@ struct wmEventHandler *WM_event_add_dropbox_handler(ListBase *handlers, ListBase
/* mouse */
void WM_event_add_mousemove(struct bContext *C);
-bool WM_modal_tweak_exit(const struct wmEvent *event, int tweak_event);
+bool WM_event_is_modal_tweak_exit(const struct wmEvent *event, int tweak_event);
bool WM_event_is_absolute(const struct wmEvent *event);
+bool WM_event_is_last_mousemove(const struct wmEvent *event);
#ifdef WITH_INPUT_NDOF
/* 3D mouse */
@@ -378,6 +379,7 @@ bool WM_operator_pystring_abbreviate(char *str, int str_len_max);
char *WM_prop_pystring_assign(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, int index);
void WM_operator_bl_idname(char *to, const char *from);
void WM_operator_py_idname(char *to, const char *from);
+bool WM_operator_py_idname_ok_or_report(struct ReportList *reports, const char *classname, const char *idname);
/* *************** uilist types ******************** */
void WM_uilisttype_init(void);
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index ad8df014902..9df9afcb064 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -121,6 +121,9 @@ struct ImBuf;
#include "wm_event_types.h"
#include "manipulators/WM_manipulator_types.h"
+/* Include external manipulator API's */
+#include "manipulators/WM_manipulator_api.h"
+
/* ************** wmOperatorType ************************ */
/* flag */
@@ -425,6 +428,7 @@ typedef struct wmGesture {
/* free pointer to use for operator allocs (if set, its freed on exit)*/
void *userdata;
+ bool userdata_free;
} wmGesture;
/* ************** wmEvent ************************ */
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c
index da1b5feea3d..e953f0c1712 100644
--- a/source/blender/windowmanager/intern/wm.c
+++ b/source/blender/windowmanager/intern/wm.c
@@ -430,7 +430,7 @@ void wm_clear_default_size(bContext *C)
/* on startup, it adds all data, for matching */
void wm_add_default(bContext *C)
{
- wmWindowManager *wm = BKE_libblock_alloc(CTX_data_main(C), ID_WM, "WinMan");
+ wmWindowManager *wm = BKE_libblock_alloc(CTX_data_main(C), ID_WM, "WinMan", 0);
wmWindow *win;
bScreen *screen = CTX_wm_screen(C); /* XXX from file read hrmf */
struct WorkSpace *workspace = G.main->workspaces.last;
@@ -497,6 +497,10 @@ void wm_close_and_free_all(bContext *C, ListBase *wmlist)
void WM_main(bContext *C)
{
+ /* Single refresh before handling events.
+ * This ensures we don't run operators before the depsgraph has been evaluated. */
+ wm_event_do_refresh_wm_and_depsgraph(C);
+
while (1) {
/* get events from ghost, handle window events, add to window queues */
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c
index 7cff598e6ad..b4db8a8b3ac 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -58,6 +58,7 @@
#include "GPU_draw.h"
#include "GPU_extensions.h"
#include "GPU_immediate.h"
+#include "GPU_viewport.h"
#include "RE_engine.h"
@@ -136,6 +137,7 @@ static void wm_region_test_render_do_draw(const Scene *scene, ScrArea *sa, ARegi
if (sa->spacetype == SPACE_VIEW3D) {
RegionView3D *rv3d = ar->regiondata;
RenderEngine *engine = (rv3d) ? rv3d->render_engine : NULL;
+ GPUViewport *viewport = (rv3d) ? rv3d->viewport : NULL;
if (engine && (engine->flag & RE_ENGINE_DO_DRAW)) {
View3D *v3d = sa->spacedata.first;
@@ -149,6 +151,9 @@ static void wm_region_test_render_do_draw(const Scene *scene, ScrArea *sa, ARegi
engine->flag &= ~RE_ENGINE_DO_DRAW;
}
+ else if (viewport && GPU_viewport_do_update(viewport)) {
+ ED_region_tag_redraw(ar);
+ }
}
}
@@ -869,25 +874,13 @@ static bool wm_draw_update_test_window(wmWindow *win)
static int wm_automatic_draw_method(wmWindow *win)
{
- /* Ideally all cards would work well with triple buffer, since if it works
- * well gives the least redraws and is considerably faster at partial redraw
- * for sculpting or drawing overlapping menus. For typically lower end cards
- * copy to texture is slow though and so we use overlap instead there. */
-
+ /* We assume all supported GPUs now support triple buffer well. */
if (win->drawmethod == USER_DRAW_AUTOMATIC) {
- /* Windows software driver darkens color on each redraw */
- if (GPU_type_matches(GPU_DEVICE_SOFTWARE, GPU_OS_WIN, GPU_DRIVER_SOFTWARE))
- return USER_DRAW_OVERLAP_FLIP;
- else if (GPU_type_matches(GPU_DEVICE_SOFTWARE, GPU_OS_UNIX, GPU_DRIVER_SOFTWARE))
- return USER_DRAW_OVERLAP;
- /* drawing lower color depth again degrades colors each time */
- else if (GPU_color_depth() < 24)
- return USER_DRAW_OVERLAP;
- else
- return USER_DRAW_TRIPLE;
+ return USER_DRAW_TRIPLE;
}
- else
+ else {
return win->drawmethod;
+ }
}
bool WM_is_draw_triple(wmWindow *win)
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 06bf6ff2482..f3864f7ed97 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -264,13 +264,61 @@ static void wm_notifier_clear(wmNotifier *note)
memset(((char *)note) + sizeof(Link), 0, sizeof(*note) - sizeof(Link));
}
+/**
+ * Was part of #wm_event_do_notifiers, split out so it can be called once before entering the #WM_main loop.
+ * This ensures operators don't run before the UI and depsgraph are initialized.
+ */
+void wm_event_do_refresh_wm_and_depsgraph(bContext *C)
+{
+ wmWindowManager *wm = CTX_wm_manager(C);
+ uint64_t win_combine_v3d_datamask = 0;
+
+ /* combine datamasks so 1 win doesn't disable UV's in another [#26448] */
+ for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ const Scene *scene = WM_window_get_active_scene(win);
+ const bScreen *screen = WM_window_get_active_screen(win);
+
+ win_combine_v3d_datamask |= ED_view3d_screen_datamask(scene, screen);
+ }
+
+ /* cached: editor refresh callbacks now, they get context */
+ for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ const bScreen *screen = WM_window_get_active_screen(win);
+ Scene *scene = WM_window_get_active_scene(win);
+ ScrArea *sa;
+
+ CTX_wm_window_set(C, win);
+ for (sa = screen->areabase.first; sa; sa = sa->next) {
+ if (sa->do_refresh) {
+ CTX_wm_area_set(C, sa);
+ ED_area_do_refresh(C, sa);
+ }
+ }
+
+ /* XXX make lock in future, or separated derivedmesh users in scene */
+ if (G.is_rendering == false) {
+ /* depsgraph & animation: update tagged datablocks */
+ Main *bmain = CTX_data_main(C);
+
+ /* copied to set's in scene_update_tagged_recursive() */
+ scene->customdata_mask = win_combine_v3d_datamask;
+
+ /* XXX, hack so operators can enforce datamasks [#26482], gl render */
+ scene->customdata_mask |= scene->customdata_mask_modal;
+
+ BKE_scene_update_tagged(bmain->eval_ctx, bmain, scene);
+ }
+ }
+
+ CTX_wm_window_set(C, NULL);
+}
+
/* called in mainloop */
void wm_event_do_notifiers(bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
wmNotifier *note, *next;
wmWindow *win;
- uint64_t win_combine_v3d_datamask = 0;
if (wm == NULL)
return;
@@ -335,7 +383,7 @@ void wm_event_do_notifiers(bContext *C)
}
}
if (ELEM(note->category, NC_SCENE, NC_OBJECT, NC_GEOM, NC_WM)) {
- SceneLayer *sl = BKE_scene_layer_context_active(scene);
+ SceneLayer *sl = CTX_data_scene_layer(C);
ED_info_stats_clear(sl);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO, NULL);
}
@@ -397,44 +445,7 @@ void wm_event_do_notifiers(bContext *C)
MEM_freeN(note);
}
- /* combine datamasks so 1 win doesn't disable UV's in another [#26448] */
- for (win = wm->windows.first; win; win = win->next) {
- const Scene *scene = WM_window_get_active_scene(win);
- const bScreen *screen = WM_window_get_active_screen(win);
-
- win_combine_v3d_datamask |= ED_view3d_screen_datamask(scene, screen);
- }
-
- /* cached: editor refresh callbacks now, they get context */
- for (win = wm->windows.first; win; win = win->next) {
- const bScreen *screen = WM_window_get_active_screen(win);
- Scene *scene = WM_window_get_active_scene(win);
- ScrArea *sa;
-
- CTX_wm_window_set(C, win);
- for (sa = screen->areabase.first; sa; sa = sa->next) {
- if (sa->do_refresh) {
- CTX_wm_area_set(C, sa);
- ED_area_do_refresh(C, sa);
- }
- }
-
- /* XXX make lock in future, or separated derivedmesh users in scene */
- if (G.is_rendering == false) {
- /* depsgraph & animation: update tagged datablocks */
- Main *bmain = CTX_data_main(C);
-
- /* copied to set's in scene_update_tagged_recursive() */
- scene->customdata_mask = win_combine_v3d_datamask;
-
- /* XXX, hack so operators can enforce datamasks [#26482], gl render */
- scene->customdata_mask |= scene->customdata_mask_modal;
-
- BKE_scene_update_tagged(bmain->eval_ctx, bmain, scene);
- }
- }
-
- CTX_wm_window_set(C, NULL);
+ wm_event_do_refresh_wm_and_depsgraph(C);
}
static int wm_event_always_pass(const wmEvent *event)
@@ -644,6 +655,16 @@ bool WM_event_is_absolute(const wmEvent *event)
return (event->tablet_data != NULL);
}
+bool WM_event_is_last_mousemove(const wmEvent *event)
+{
+ while ((event = event->next)) {
+ if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
+ return false;
+ }
+ }
+ return true;
+}
+
#ifdef WITH_INPUT_NDOF
void WM_ndof_deadzone_set(float deadzone)
{
@@ -1108,6 +1129,9 @@ bool WM_operator_last_properties_store(wmOperator *UNUSED(op))
#endif
+/**
+ * Also used for exec when 'event' is NULL.
+ */
static int wm_operator_invoke(
bContext *C, wmOperatorType *ot, wmEvent *event,
PointerRNA *properties, ReportList *reports, const bool poll_only)
@@ -1123,7 +1147,9 @@ static int wm_operator_invoke(
wmOperator *op = wm_operator_create(wm, ot, properties, reports); /* if reports == NULL, they'll be initialized */
const bool is_nested_call = (wm->op_undo_depth != 0);
- op->flag |= OP_IS_INVOKE;
+ if (event != NULL) {
+ op->flag |= OP_IS_INVOKE;
+ }
/* initialize setting from previous run */
if (!is_nested_call) { /* not called by py script */
@@ -1574,6 +1600,36 @@ int WM_userdef_event_map(int kmitype)
return kmitype;
}
+/**
+ * Use so we can check if 'wmEvent.type' is released in modal operators.
+ *
+ * An alternative would be to add a 'wmEvent.type_nokeymap'... or similar.
+ */
+int WM_userdef_event_type_from_keymap_type(int kmitype)
+{
+ switch (kmitype) {
+ case SELECTMOUSE:
+ return (U.flag & USER_LMOUSESELECT) ? LEFTMOUSE : RIGHTMOUSE;
+ case ACTIONMOUSE:
+ return (U.flag & USER_LMOUSESELECT) ? RIGHTMOUSE : LEFTMOUSE;
+ case EVT_TWEAK_S:
+ return (U.flag & USER_LMOUSESELECT) ? LEFTMOUSE : RIGHTMOUSE;
+ case EVT_TWEAK_A:
+ return (U.flag & USER_LMOUSESELECT) ? RIGHTMOUSE : LEFTMOUSE;
+ case EVT_TWEAK_L:
+ return LEFTMOUSE;
+ case EVT_TWEAK_M:
+ return MIDDLEMOUSE;
+ case EVT_TWEAK_R:
+ return RIGHTMOUSE;
+ case WHEELOUTMOUSE:
+ return (U.uiflag & USER_WHEELZOOMDIR) ? WHEELUPMOUSE : WHEELDOWNMOUSE;
+ case WHEELINMOUSE:
+ return (U.uiflag & USER_WHEELZOOMDIR) ? WHEELDOWNMOUSE : WHEELUPMOUSE;
+ }
+
+ return kmitype;
+}
static int wm_eventmatch(const wmEvent *winevent, wmKeyMapItem *kmi)
{
@@ -2152,54 +2208,120 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
wmManipulatorMap *mmap = handler->manipulator_map;
wmManipulator *mpr = wm_manipulatormap_highlight_get(mmap);
+ if (region->manipulator_map != handler->manipulator_map) {
+ WM_manipulatormap_tag_refresh(handler->manipulator_map);
+ }
+
wm_manipulatormap_handler_context(C, handler);
wm_region_mouse_co(C, event);
/* handle manipulator highlighting */
- if (event->type == MOUSEMOVE && !wm_manipulatormap_active_get(mmap)) {
+ if (event->type == MOUSEMOVE && !wm_manipulatormap_modal_get(mmap)) {
int part;
mpr = wm_manipulatormap_highlight_find(mmap, C, event, &part);
wm_manipulatormap_highlight_set(mmap, C, mpr, part);
}
/* handle user configurable manipulator-map keymap */
- else if (mpr) {
- /* get user customized keymap from default one */
- const wmManipulatorGroup *highlightgroup = mpr->parent_mgroup;
- const wmKeyMap *keymap = WM_keymap_active(wm, highlightgroup->type->keymap);
- wmKeyMapItem *kmi;
-
- PRINT("%s: checking '%s' ...", __func__, keymap->idname);
-
- if (!keymap->poll || keymap->poll(C)) {
- PRINT("pass\n");
- for (kmi = keymap->items.first; kmi; kmi = kmi->next) {
- if (wm_eventmatch(event, kmi)) {
- wmOperator *op = handler->op;
-
- PRINT("%s: item matched '%s'\n", __func__, kmi->idname);
-
- /* weak, but allows interactive callback to not use rawkey */
- event->keymap_idname = kmi->idname;
-
- /* handler->op is called later, we want keymap op to be triggered here */
- handler->op = NULL;
- action |= wm_handler_operator_call(C, handlers, handler, event, kmi->ptr);
- handler->op = op;
-
- if (action & WM_HANDLER_BREAK) {
- if (action & WM_HANDLER_HANDLED) {
- if (G.debug & (G_DEBUG_EVENTS | G_DEBUG_HANDLERS))
- printf("%s: handled - and pass on! '%s'\n", __func__, kmi->idname);
+ else {
+ /* Either we operate on a single highlighted item
+ * or groups attached to the selected manipulators.
+ * To simplify things both cases loop over an array of items. */
+ wmManipulatorGroup *mgroup_first;
+ bool is_mgroup_single;
+
+ if (ISMOUSE(event->type)) {
+ /* Keep mpr set as-is, just fake single selection. */
+ if (mpr) {
+ mgroup_first = mpr->parent_mgroup;
+ }
+ else {
+ mgroup_first = NULL;
+ }
+ is_mgroup_single = true;
+ }
+ else {
+ if (WM_manipulatormap_is_any_selected(mmap)) {
+ const ListBase *groups = WM_manipulatormap_group_list(mmap);
+ mgroup_first = groups->first;
+ }
+ else {
+ mgroup_first = NULL;
+ }
+ is_mgroup_single = false;
+ }
+
+ /* Don't use from now on. */
+ mpr = NULL;
+
+ for (wmManipulatorGroup *mgroup = mgroup_first; mgroup; mgroup = mgroup->next) {
+ /* get user customized keymap from default one */
+
+ if ((is_mgroup_single == false) &&
+ /* We might want to change the logic here and use some kind of manipulator edit-mode.
+ * For now just use keymap when a selection exists. */
+ wm_manipulatorgroup_is_any_selected(mgroup) == false)
+ {
+ continue;
+ }
+
+ const wmKeyMap *keymap = WM_keymap_active(wm, mgroup->type->keymap);
+ wmKeyMapItem *kmi;
+
+ PRINT("%s: checking '%s' ...", __func__, keymap->idname);
+
+ if (!keymap->poll || keymap->poll(C)) {
+ PRINT("pass\n");
+ for (kmi = keymap->items.first; kmi; kmi = kmi->next) {
+ if (wm_eventmatch(event, kmi)) {
+ wmOperator *op = handler->op;
+
+ PRINT("%s: item matched '%s'\n", __func__, kmi->idname);
+
+ /* weak, but allows interactive callback to not use rawkey */
+ event->keymap_idname = kmi->idname;
+
+ CTX_wm_manipulator_group_set(C, mgroup);
+
+ /* handler->op is called later, we want keymap op to be triggered here */
+ handler->op = NULL;
+ action |= wm_handler_operator_call(C, handlers, handler, event, kmi->ptr);
+ handler->op = op;
+
+ CTX_wm_manipulator_group_set(C, NULL);
+
+ if (action & WM_HANDLER_BREAK) {
+ if (G.debug & (G_DEBUG_EVENTS | G_DEBUG_HANDLERS)) {
+ printf("%s: handled - and pass on! '%s'\n",
+ __func__, kmi->idname);
+ }
+ break;
}
else {
- PRINT("%s: un-handled '%s'\n", __func__, kmi->idname);
+ if (action & WM_HANDLER_HANDLED) {
+ if (G.debug & (G_DEBUG_EVENTS | G_DEBUG_HANDLERS)) {
+ printf("%s: handled - and pass on! '%s'\n",
+ __func__, kmi->idname);
+ }
+ }
+ else {
+ PRINT("%s: un-handled '%s'\n",
+ __func__, kmi->idname);
+ }
}
}
}
}
- }
- else {
- PRINT("fail\n");
+ else {
+ PRINT("fail\n");
+ }
+
+ if (action & WM_HANDLER_BREAK) {
+ break;
+ }
+
+ if (is_mgroup_single) {
+ break;
+ }
}
}
@@ -2701,7 +2823,7 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op)
wmWindow *win = CTX_wm_window(C);
/* only allow 1 file selector open per window */
- for (handler = win->handlers.first; handler; handler = handlernext) {
+ for (handler = win->modalhandlers.first; handler; handler = handlernext) {
handlernext = handler->next;
if (handler->type == WM_HANDLER_FILESELECT) {
@@ -2715,7 +2837,7 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op)
if (sfile->op == handler->op) {
CTX_wm_area_set(C, sa);
- wm_handler_fileselect_do(C, &win->handlers, handler, EVT_FILESELECT_CANCEL);
+ wm_handler_fileselect_do(C, &win->modalhandlers, handler, EVT_FILESELECT_CANCEL);
break;
}
}
@@ -2723,7 +2845,7 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op)
/* if not found we stop the handler without changing the screen */
if (!sa)
- wm_handler_fileselect_do(C, &win->handlers, handler, EVT_FILESELECT_EXTERNAL_CANCEL);
+ wm_handler_fileselect_do(C, &win->modalhandlers, handler, EVT_FILESELECT_EXTERNAL_CANCEL);
}
}
@@ -2734,7 +2856,7 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op)
handler->op_area = CTX_wm_area(C);
handler->op_region = CTX_wm_region(C);
- BLI_addhead(&win->handlers, handler);
+ BLI_addhead(&win->modalhandlers, handler);
/* check props once before invoking if check is available
* ensures initial properties are valid */
@@ -2784,7 +2906,8 @@ wmEventHandler *WM_event_add_modal_handler(bContext *C, wmOperator *op)
void WM_event_modal_handler_area_replace(wmWindow *win, const ScrArea *old_area, ScrArea *new_area)
{
for (wmEventHandler *handler = win->modalhandlers.first; handler; handler = handler->next) {
- if (handler->op_area == old_area) {
+ /* fileselect handler is quite special... it needs to keep old area stored in handler, so don't change it */
+ if ((handler->op_area == old_area) && (handler->type != WM_HANDLER_FILESELECT)) {
handler->op_area = new_area;
}
}
@@ -2986,7 +3109,7 @@ void WM_event_add_mousemove(bContext *C)
/* for modal callbacks, check configuration for how to interpret exit with tweaks */
-bool WM_modal_tweak_exit(const wmEvent *event, int tweak_event)
+bool WM_event_is_modal_tweak_exit(const wmEvent *event, int tweak_event)
{
/* if the release-confirm userpref setting is enabled,
* tweak events can be canceled when mouse is released
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 251952f6907..3de6824c23d 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -326,7 +326,7 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
}
/* in case UserDef was read, we re-initialize all, and do versioning */
-static void wm_init_userdef(Main *bmain, const bool use_factory_settings)
+static void wm_init_userdef(Main *bmain, const bool read_userdef_from_memory)
{
/* versioning is here */
UI_init_userdef();
@@ -344,14 +344,12 @@ static void wm_init_userdef(Main *bmain, const bool use_factory_settings)
}
/* avoid re-saving for every small change to our prefs, allow overrides */
- if (use_factory_settings) {
+ if (read_userdef_from_memory) {
BLO_update_defaults_userpref_blend();
}
/* update tempdir from user preferences */
BKE_tempdir_init(U.tempdir);
-
- BKE_blender_userdef_refresh();
}
@@ -459,7 +457,7 @@ void wm_file_read_report(bContext *C)
* Logic shared between #WM_file_read & #wm_homefile_read,
* updates to make after reading a file.
*/
-static void wm_file_read_post(bContext *C, bool is_startup_file)
+static void wm_file_read_post(bContext *C, const bool is_startup_file, const bool use_userdef)
{
bool addons_loaded = false;
wmWindowManager *wm = CTX_wm_manager(C);
@@ -478,13 +476,14 @@ static void wm_file_read_post(bContext *C, bool is_startup_file)
if (is_startup_file) {
/* possible python hasn't been initialized */
if (CTX_py_init_get(C)) {
- /* Only run when we have a template path found. */
- if (BKE_appdir_app_template_any()) {
- BPY_execute_string(C, "__import__('bl_app_template_utils').reset()");
+ if (use_userdef) {
+ /* Only run when we have a template path found. */
+ if (BKE_appdir_app_template_any()) {
+ BPY_execute_string(C, "__import__('bl_app_template_utils').reset()");
+ }
+ /* sync addons, these may have changed from the defaults */
+ BPY_execute_string(C, "__import__('addon_utils').reset_all()");
}
- /* sync addons, these may have changed from the defaults */
- BPY_execute_string(C, "__import__('addon_utils').reset_all()");
-
BPY_python_reset(C);
addons_loaded = true;
}
@@ -598,7 +597,7 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
}
}
- wm_file_read_post(C, false);
+ wm_file_read_post(C, false, false);
success = true;
}
@@ -646,13 +645,15 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
*
* \param use_factory_settings: Ignore on-disk startup file, use bundled ``datatoc_startup_blend`` instead.
* Used for "Restore Factory Settings".
+ * \param use_userdef: Load factory settings as well as startup file.
+ * Disabled for "File New" we don't want to reload preferences.
* \param filepath_startup_override: Optional path pointing to an alternative blend file (may be NULL).
* \param app_template_override: Template to use instead of the template defined in user-preferences.
* When not-null, this is written into the user preferences.
*/
int wm_homefile_read(
bContext *C, ReportList *reports,
- bool use_factory_settings, bool use_empty_data,
+ bool use_factory_settings, bool use_empty_data, bool use_userdef,
const char *filepath_startup_override, const char *app_template_override)
{
ListBase wmbase;
@@ -675,8 +676,8 @@ int wm_homefile_read(
*
* And in this case versioning code is to be run.
*/
- bool read_userdef_from_memory = true;
- eBLOReadSkip skip_flags = 0;
+ bool read_userdef_from_memory = false;
+ eBLOReadSkip skip_flags = use_userdef ? 0 : BLO_READ_SKIP_USERDEF;
/* options exclude eachother */
BLI_assert((use_factory_settings && filepath_startup_override) == 0);
@@ -703,7 +704,9 @@ int wm_homefile_read(
if (!use_factory_settings) {
if (cfgdir) {
BLI_path_join(filepath_startup, sizeof(filepath_startup), cfgdir, BLENDER_STARTUP_FILE, NULL);
- BLI_path_join(filepath_userdef, sizeof(filepath_startup), cfgdir, BLENDER_USERPREF_FILE, NULL);
+ if (use_userdef) {
+ BLI_path_join(filepath_userdef, sizeof(filepath_startup), cfgdir, BLENDER_USERPREF_FILE, NULL);
+ }
}
else {
use_factory_settings = true;
@@ -715,15 +718,16 @@ int wm_homefile_read(
}
/* load preferences before startup.blend */
- if (!use_factory_settings && BLI_exists(filepath_userdef)) {
- UserDef *userdef = BKE_blendfile_userdef_read(filepath_userdef, NULL);
- if (userdef != NULL) {
- BKE_blender_userdef_set_data(userdef);
- MEM_freeN(userdef);
-
- read_userdef_from_memory = false;
- skip_flags |= BLO_READ_SKIP_USERDEF;
- printf("Read prefs: %s\n", filepath_userdef);
+ if (use_userdef) {
+ if (!use_factory_settings && BLI_exists(filepath_userdef)) {
+ UserDef *userdef = BKE_blendfile_userdef_read(filepath_userdef, NULL);
+ if (userdef != NULL) {
+ BKE_blender_userdef_set_data(userdef);
+ MEM_freeN(userdef);
+
+ skip_flags |= BLO_READ_SKIP_USERDEF;
+ printf("Read prefs: %s\n", filepath_userdef);
+ }
}
}
@@ -732,23 +736,23 @@ int wm_homefile_read(
if (filepath_startup_override != NULL) {
/* pass */
}
- else if (app_template_override && app_template_override[0]) {
+ else if (app_template_override) {
+ /* This may be clearing the current template by setting to an empty string. */
app_template = app_template_override;
}
else if (!use_factory_settings && U.app_template[0]) {
app_template = U.app_template;
}
- if (app_template != NULL) {
+ if ((app_template != NULL) && (app_template[0] != '\0')) {
BKE_appdir_app_template_id_search(app_template, app_template_system, sizeof(app_template_system));
- BLI_path_join(app_template_config, sizeof(app_template_config), cfgdir, app_template, NULL);
- }
- /* insert template name into startup file */
- if (app_template != NULL) {
+ /* Insert template name into startup file. */
+
/* note that the path is being set even when 'use_factory_settings == true'
* this is done so we can load a templates factory-settings */
if (!use_factory_settings) {
+ BLI_path_join(app_template_config, sizeof(app_template_config), cfgdir, app_template, NULL);
BLI_path_join(filepath_startup, sizeof(filepath_startup), app_template_config, BLENDER_STARTUP_FILE, NULL);
if (BLI_access(filepath_startup, R_OK) != 0) {
filepath_startup[0] = '\0';
@@ -783,6 +787,13 @@ int wm_homefile_read(
success = BKE_blendfile_read_from_memory(
C, datatoc_startup_blend, datatoc_startup_blend_size,
NULL, skip_flags, true);
+ if (success) {
+ if (use_userdef) {
+ if ((skip_flags & BLO_READ_SKIP_USERDEF) == 0) {
+ read_userdef_from_memory = true;
+ }
+ }
+ }
if (BLI_listbase_is_empty(&wmbase)) {
wm_clear_default_size(C);
}
@@ -809,20 +820,23 @@ int wm_homefile_read(
BLI_path_join(temp_path, sizeof(temp_path), app_template_system, BLENDER_USERPREF_FILE, NULL);
}
- UserDef *userdef_template = NULL;
- /* just avoids missing file warning */
- if (BLI_exists(temp_path)) {
- userdef_template = BKE_blendfile_userdef_read(temp_path, NULL);
- }
- if (userdef_template == NULL) {
- /* we need to have preferences load to overwrite preferences from previous template */
- userdef_template = BKE_blendfile_userdef_read_from_memory(
- datatoc_startup_blend, datatoc_startup_blend_size, NULL);
- }
- if (userdef_template) {
- BKE_blender_userdef_set_app_template(userdef_template);
- BKE_blender_userdef_free_data(userdef_template);
- MEM_freeN(userdef_template);
+ if (use_userdef) {
+ UserDef *userdef_template = NULL;
+ /* just avoids missing file warning */
+ if (BLI_exists(temp_path)) {
+ userdef_template = BKE_blendfile_userdef_read(temp_path, NULL);
+ }
+ if (userdef_template == NULL) {
+ /* we need to have preferences load to overwrite preferences from previous template */
+ userdef_template = BKE_blendfile_userdef_read_from_memory(
+ datatoc_startup_blend, datatoc_startup_blend_size, NULL);
+ read_userdef_from_memory = true;
+ }
+ if (userdef_template) {
+ BKE_blender_userdef_set_app_template(userdef_template);
+ BKE_blender_userdef_free_data(userdef_template);
+ MEM_freeN(userdef_template);
+ }
}
}
@@ -833,9 +847,11 @@ int wm_homefile_read(
/* prevent buggy files that had G_FILE_RELATIVE_REMAP written out by mistake. Screws up autosaves otherwise
* can remove this eventually, only in a 2.53 and older, now its not written */
G.fileflags &= ~G_FILE_RELATIVE_REMAP;
-
- /* check userdef before open window, keymaps etc */
- wm_init_userdef(CTX_data_main(C), read_userdef_from_memory);
+
+ if (use_userdef) {
+ /* check userdef before open window, keymaps etc */
+ wm_init_userdef(CTX_data_main(C), read_userdef_from_memory);
+ }
/* match the read WM with current WM */
wm_window_match_do(C, &wmbase);
@@ -843,9 +859,11 @@ int wm_homefile_read(
G.main->name[0] = '\0';
- /* When loading factory settings, the reset solid OpenGL lights need to be applied. */
- if (!G.background) {
- GPU_default_lights();
+ if (use_userdef) {
+ /* When loading factory settings, the reset solid OpenGL lights need to be applied. */
+ if (!G.background) {
+ GPU_default_lights();
+ }
}
/* start with save preference untitled.blend */
@@ -853,7 +871,7 @@ int wm_homefile_read(
/* disable auto-play in startup.blend... */
G.fileflags &= ~G_FILE_AUTOPLAY;
- wm_file_read_post(C, true);
+ wm_file_read_post(C, true, use_userdef);
return true;
}
@@ -982,7 +1000,7 @@ static void wm_history_file_update(void)
/* screen can be NULL */
-static ImBuf *blend_file_thumb(Scene *scene, SceneLayer *sl, bScreen *screen, BlendThumbnail **thumb_pt)
+static ImBuf *blend_file_thumb(const bContext *C, Scene *scene, SceneLayer *sl, bScreen *screen, BlendThumbnail **thumb_pt)
{
/* will be scaled down, but gives some nice oversampling */
ImBuf *ibuf;
@@ -994,6 +1012,10 @@ static ImBuf *blend_file_thumb(Scene *scene, SceneLayer *sl, bScreen *screen, Bl
ARegion *ar = NULL;
View3D *v3d = NULL;
+ EvaluationContext eval_ctx;
+
+ CTX_data_eval_ctx(C, &eval_ctx);
+
/* In case we are given a valid thumbnail data, just generate image from it. */
if (*thumb_pt) {
thumb = *thumb_pt;
@@ -1019,14 +1041,14 @@ static ImBuf *blend_file_thumb(Scene *scene, SceneLayer *sl, bScreen *screen, Bl
/* gets scaled to BLEN_THUMB_SIZE */
if (scene->camera) {
ibuf = ED_view3d_draw_offscreen_imbuf_simple(
- scene, sl, scene->camera,
+ &eval_ctx, scene, sl, scene->camera,
BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2,
IB_rect, OB_SOLID, false, false, false, R_ALPHAPREMUL, 0, false, NULL,
NULL, NULL, err_out);
}
else {
ibuf = ED_view3d_draw_offscreen_imbuf(
- scene, sl, v3d, ar,
+ &eval_ctx, scene, sl, v3d, ar,
BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2,
IB_rect, false, R_ALPHAPREMUL, 0, false, NULL,
NULL, NULL, err_out);
@@ -1122,7 +1144,7 @@ static int wm_file_write(bContext *C, const char *filepath, int fileflags, Repor
/* Main now can store a .blend thumbnail, usefull for background mode or thumbnail customization. */
main_thumb = thumb = CTX_data_main(C)->blen_thumb;
if ((U.flag & USER_SAVE_PREVIEWS) && BLI_thread_is_main()) {
- ibuf_thumb = blend_file_thumb(CTX_data_scene(C), CTX_data_scene_layer(C), CTX_wm_screen(C), &thumb);
+ ibuf_thumb = blend_file_thumb(C, CTX_data_scene(C), CTX_data_scene_layer(C), CTX_wm_screen(C), &thumb);
}
/* operator now handles overwrite checks */
@@ -1571,6 +1593,7 @@ void WM_OT_read_history(wmOperatorType *ot)
static int wm_homefile_read_exec(bContext *C, wmOperator *op)
{
const bool use_factory_settings = (STREQ(op->type->idname, "WM_OT_read_factory_settings"));
+ bool use_userdef = false;
char filepath_buf[FILE_MAX];
const char *filepath = NULL;
@@ -1594,6 +1617,8 @@ static int wm_homefile_read_exec(bContext *C, wmOperator *op)
else {
/* always load UI for factory settings (prefs will re-init) */
G.fileflags &= ~G_FILE_NO_UI;
+ /* Always load preferences with factory settings. */
+ use_userdef = true;
}
char app_template_buf[sizeof(U.app_template)];
@@ -1605,17 +1630,15 @@ static int wm_homefile_read_exec(bContext *C, wmOperator *op)
if (prop_app_template && RNA_property_is_set(op->ptr, prop_app_template)) {
RNA_property_string_get(op->ptr, prop_app_template, app_template_buf);
app_template = app_template_buf;
- }
- else if (!use_factory_settings) {
- /* TODO: dont reset prefs on 'New File' */
- BLI_strncpy(app_template_buf, U.app_template, sizeof(app_template_buf));
- app_template = app_template_buf;
+
+ /* Always load preferences when switching templates. */
+ use_userdef = true;
}
else {
app_template = NULL;
}
- if (wm_homefile_read(C, op->reports, use_factory_settings, use_empty_data, filepath, app_template)) {
+ if (wm_homefile_read(C, op->reports, use_factory_settings, use_empty_data, use_userdef, filepath, app_template)) {
if (use_splash) {
WM_init_splash(C);
}
diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c
index 3c7a48662f8..af0d2be8097 100644
--- a/source/blender/windowmanager/intern/wm_files_link.c
+++ b/source/blender/windowmanager/intern/wm_files_link.c
@@ -504,9 +504,6 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
/* recreate dependency graph to include new objects */
DEG_scene_relations_rebuild(bmain, scene);
-
- /* free gpu materials, some materials depend on existing objects, such as lamps so freeing correctly refreshes */
- GPU_materials_free();
/* XXX TODO: align G.lib with other directory storage (like last opened image etc...) */
BLI_strncpy(G.lib, root, FILE_MAX);
@@ -672,7 +669,8 @@ static void lib_relocate_do(
}
/* Note that in reload case, we also want to replace indirect usages. */
- const short remap_flags = ID_REMAP_SKIP_NEVER_NULL_USAGE | (do_reload ? 0 : ID_REMAP_SKIP_INDIRECT_USAGE);
+ const short remap_flags = ID_REMAP_SKIP_NEVER_NULL_USAGE | ID_REMAP_NO_INDIRECT_PROXY_DATA_USAGE |
+ (do_reload ? 0 : ID_REMAP_SKIP_INDIRECT_USAGE);
for (item_idx = 0, itemlink = lapp_data->items.list; itemlink; item_idx++, itemlink = itemlink->next) {
WMLinkAppendDataItem *item = itemlink->link;
ID *old_id = item->customdata;
@@ -801,9 +799,6 @@ static void lib_relocate_do(
/* recreate dependency graph to include new objects */
DEG_scene_relations_rebuild(bmain, scene);
-
- /* free gpu materials, some materials depend on existing objects, such as lamps so freeing correctly refreshes */
- GPU_materials_free();
}
void WM_lib_reload(Library *lib, bContext *C, ReportList *reports)
diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c
index 1ffe96181f0..77030fac5ea 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -71,6 +71,7 @@ wmGesture *WM_gesture_new(bContext *C, const wmEvent *event, int type)
gesture->type = type;
gesture->event_type = event->type;
gesture->swinid = ar->swinid; /* means only in area-region context! */
+ gesture->userdata_free = true; /* Free if userdata is set. */
wm_subwindow_origin_get(window, gesture->swinid, &sx, &sy);
@@ -114,7 +115,7 @@ void WM_gesture_end(bContext *C, wmGesture *gesture)
win->tweak = NULL;
BLI_remlink(&win->gesture, gesture);
MEM_freeN(gesture->customdata);
- if (gesture->userdata) {
+ if (gesture->userdata && gesture->userdata_free) {
MEM_freeN(gesture->userdata);
}
MEM_freeN(gesture);
@@ -137,7 +138,7 @@ int wm_gesture_evaluate(wmGesture *gesture)
int dx = BLI_rcti_size_x(rect);
int dy = BLI_rcti_size_y(rect);
if (abs(dx) + abs(dy) > U.tweak_threshold) {
- int theta = iroundf(4.0f * atan2f((float)dy, (float)dx) / (float)M_PI);
+ int theta = round_fl_to_int(4.0f * atan2f((float)dy, (float)dx) / (float)M_PI);
int val = EVT_GESTURE_W;
if (theta == 0) val = EVT_GESTURE_E;
@@ -174,7 +175,7 @@ static void wm_gesture_draw_line(wmGesture *gt)
uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
@@ -214,7 +215,7 @@ static void wm_gesture_draw_rect(wmGesture *gt)
shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
@@ -224,7 +225,7 @@ static void wm_gesture_draw_rect(wmGesture *gt)
immUniformArray4fv("colors", (float *)(float[][4]){{0.4f, 0.4f, 0.4f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, 2);
immUniform1f("dash_width", 8.0f);
- imm_draw_line_box(shdr_pos, (float)rect->xmin, (float)rect->ymin, (float)rect->xmax, (float)rect->ymax);
+ imm_draw_box_wire_2d(shdr_pos, (float)rect->xmin, (float)rect->ymin, (float)rect->xmax, (float)rect->ymax);
immUnbindProgram();
@@ -242,13 +243,13 @@ static void wm_gesture_draw_circle(wmGesture *gt)
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.05f);
- imm_draw_circle_fill(shdr_pos, (float)rect->xmin, (float)rect->ymin, (float)rect->xmax, 40);
+ imm_draw_circle_fill_2d(shdr_pos, (float)rect->xmin, (float)rect->ymin, (float)rect->xmax, 40);
immUnbindProgram();
glDisable(GL_BLEND);
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
@@ -258,7 +259,7 @@ static void wm_gesture_draw_circle(wmGesture *gt)
immUniformArray4fv("colors", (float *)(float[][4]){{0.4f, 0.4f, 0.4f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, 2);
immUniform1f("dash_width", 4.0f);
- imm_draw_circle_wire(shdr_pos, (float)rect->xmin, (float)rect->ymin, (float)rect->xmax, 40);
+ imm_draw_circle_wire_2d(shdr_pos, (float)rect->xmin, (float)rect->ymin, (float)rect->xmax, 40);
immUnbindProgram();
}
@@ -355,7 +356,7 @@ static void wm_gesture_draw_lasso(wmWindow *win, wmGesture *gt, bool filled)
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
@@ -386,7 +387,7 @@ static void wm_gesture_draw_cross(wmWindow *win, wmGesture *gt)
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
glGetFloatv(GL_VIEWPORT, viewport_size);
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index 6ae41ab3917..8346535cd6a 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -173,6 +173,7 @@ void WM_init(bContext *C, int argc, const char **argv)
BKE_library_callback_free_window_manager_set(wm_close_and_free); /* library.c */
BKE_library_callback_free_notifier_reference_set(WM_main_remove_notifier_reference); /* library.c */
BKE_region_callback_free_manipulatormap_set(wm_manipulatormap_remove); /* screen.c */
+ BKE_region_callback_refresh_tag_manipulatormap_set(WM_manipulatormap_tag_refresh);
BKE_library_callback_remap_editor_id_reference_set(WM_main_remap_editor_id_reference); /* library.c */
BKE_blender_callback_test_break_set(wm_window_testbreak); /* blender.c */
BKE_spacedata_callback_id_remap_set(ED_spacedata_id_remap); /* screen.c */
@@ -185,18 +186,15 @@ void WM_init(bContext *C, int argc, const char **argv)
ED_file_init(); /* for fsmenu */
ED_node_init_butfuncs();
- BLF_init(11, U.dpi); /* Please update source/gamengine/GamePlayer/GPG_ghost.cpp if you change this */
+ BLF_init(); /* Please update source/gamengine/GamePlayer/GPG_ghost.cpp if you change this */
BLT_lang_init();
- /* Enforce loading the UI for the initial homefile */
- G.fileflags &= ~G_FILE_NO_UI;
-
/* reports cant be initialized before the wm,
* but keep before file reading, since that may report errors */
wm_init_reports(C);
/* get the default database, plus a wm */
- wm_homefile_read(C, NULL, G.factory_startup, false, NULL, NULL);
+ wm_homefile_read(C, NULL, G.factory_startup, false, true, NULL, NULL);
BLT_lang_set(NULL);
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 5001fc7817f..2f12dd5b672 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -179,7 +179,7 @@ static void wm_operatortype_append__end(wmOperatorType *ot)
/* XXX All ops should have a description but for now allow them not to. */
RNA_def_struct_ui_text(ot->srna, ot->name, ot->description ? ot->description : UNDOCUMENTED_OPERATOR_TIP);
- RNA_def_struct_identifier(ot->srna, ot->idname);
+ RNA_def_struct_identifier(&BLENDER_RNA, ot->srna, ot->idname);
BLI_ghash_insert(global_ops_hash, (void *)ot->idname, ot);
}
@@ -401,7 +401,7 @@ wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *nam
ot->description = UNDOCUMENTED_OPERATOR_TIP;
RNA_def_struct_ui_text(ot->srna, ot->name, ot->description);
- RNA_def_struct_identifier(ot->srna, ot->idname);
+ RNA_def_struct_identifier(&BLENDER_RNA, ot->srna, ot->idname);
/* Use i18n context from ext.srna if possible (py operators). */
i18n_context = ot->ext.srna ? RNA_struct_translation_context(ot->ext.srna) : BLT_I18NCONTEXT_OPERATOR_DEFAULT;
RNA_def_struct_translation_context(ot->srna, i18n_context);
@@ -435,7 +435,7 @@ void WM_operatortype_append_macro_ptr(void (*opfunc)(wmOperatorType *, void *),
opfunc(ot, userdata);
RNA_def_struct_ui_text(ot->srna, ot->name, ot->description);
- RNA_def_struct_identifier(ot->srna, ot->idname);
+ RNA_def_struct_identifier(&BLENDER_RNA, ot->srna, ot->idname);
BLI_ghash_insert(global_ops_hash, (void *)ot->idname, ot);
}
@@ -576,6 +576,46 @@ void WM_operator_bl_idname(char *to, const char *from)
}
/**
+ * Sanity check to ensure #WM_operator_bl_idname won't fail.
+ * \returns true when there are no problems with \a idname, otherwise report an error.
+ */
+bool WM_operator_py_idname_ok_or_report(ReportList *reports, const char *classname, const char *idname)
+{
+ const char *ch = idname;
+ int dot = 0;
+ int i;
+ for (i = 0; *ch; i++, ch++) {
+ if ((*ch >= 'a' && *ch <= 'z') || (*ch >= '0' && *ch <= '9') || *ch == '_') {
+ /* pass */
+ }
+ else if (*ch == '.') {
+ dot++;
+ }
+ else {
+ BKE_reportf(reports, RPT_ERROR,
+ "Registering operator class: '%s', invalid bl_idname '%s', at position %d",
+ classname, idname, i);
+ return false;
+ }
+ }
+
+ if (i > (MAX_NAME - 3)) {
+ BKE_reportf(reports, RPT_ERROR, "Registering operator class: '%s', invalid bl_idname '%s', "
+ "is too long, maximum length is %d", classname, idname,
+ MAX_NAME - 3);
+ return false;
+ }
+
+ if (dot != 1) {
+ BKE_reportf(reports, RPT_ERROR,
+ "Registering operator class: '%s', invalid bl_idname '%s', must contain 1 '.' character",
+ classname, idname);
+ return false;
+ }
+ return true;
+}
+
+/**
* Print a string representation of the operator, with the args that it runs so python can run it again.
*
* When calling from an existing wmOperator, better to use simple version:
@@ -809,9 +849,19 @@ static char *wm_prop_pystring_from_context(bContext *C, PointerRNA *ptr, Propert
} \
} (void)0
+#define CTX_TEST_SPACE_TYPE(space_data_type, member_full, dataptr_cmp) \
+ { \
+ const char *ctx_member_full = member_full; \
+ if (space_data->spacetype == space_data_type && ptr->data == dataptr_cmp) { \
+ member_id = ctx_member_full; \
+ break; \
+ } \
+ } (void)0
+
switch (GS(((ID *)ptr->id.data)->name)) {
case ID_SCE:
{
+ CTX_TEST_PTR_DATA_TYPE(C, "active_gpencil_brush", RNA_GPencilBrush, ptr, CTX_data_active_gpencil_brush(C));
CTX_TEST_PTR_ID(C, "scene", ptr->id.data);
break;
}
@@ -846,12 +896,22 @@ static char *wm_prop_pystring_from_context(bContext *C, PointerRNA *ptr, Propert
{
CTX_TEST_PTR_ID(C, "screen", ptr->id.data);
- CTX_TEST_PTR_DATA_TYPE(C, "space_data", RNA_Space, ptr, CTX_wm_space_data(C));
+ SpaceLink *space_data = CTX_wm_space_data(C);
+
+ CTX_TEST_PTR_DATA_TYPE(C, "space_data", RNA_Space, ptr, space_data);
CTX_TEST_PTR_DATA_TYPE(C, "area", RNA_Area, ptr, CTX_wm_area(C));
CTX_TEST_PTR_DATA_TYPE(C, "region", RNA_Region, ptr, CTX_wm_region(C));
+ CTX_TEST_SPACE_TYPE(SPACE_IMAGE, "space_data.uv_editor", space_data);
+ CTX_TEST_SPACE_TYPE(SPACE_VIEW3D, "space_data.fx_settings", &(CTX_wm_view3d(C)->fx_settings));
+ CTX_TEST_SPACE_TYPE(SPACE_NLA, "space_data.dopesheet", CTX_wm_space_nla(C)->ads);
+ CTX_TEST_SPACE_TYPE(SPACE_IPO, "space_data.dopesheet", CTX_wm_space_graph(C)->ads);
+ CTX_TEST_SPACE_TYPE(SPACE_ACTION, "space_data.dopesheet", &(CTX_wm_space_action(C)->ads));
+ CTX_TEST_SPACE_TYPE(SPACE_FILE, "space_data.params", CTX_wm_space_file(C)->params);
break;
}
+ default:
+ break;
}
if (member_id) {
@@ -863,6 +923,7 @@ static char *wm_prop_pystring_from_context(bContext *C, PointerRNA *ptr, Propert
}
#undef CTX_TEST_PTR_ID
#undef CTX_TEST_PTR_ID_CAST
+#undef CTX_TEST_SPACE_TYPE
}
return ret;
@@ -1826,8 +1887,8 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
if (version_suffix != NULL && version_suffix[0]) {
/* placed after the version number in the image,
* placing y is tricky to match baseline */
- int x = 260 * U.pixelsize - (2 * UI_DPI_FAC);
- int y = 242 * U.pixelsize + (4 * UI_DPI_FAC);
+ int x = 236 * U.pixelsize - (2 * UI_DPI_FAC);
+ int y = 231 * U.pixelsize + (4 * UI_DPI_FAC);
int w = 240 * U.pixelsize;
/* hack to have text draw 'text_sel' */
@@ -1840,17 +1901,32 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
#ifdef WITH_BUILDINFO
if (build_commit_timestamp != 0) {
- uiDefBut(block, UI_BTYPE_LABEL, 0, date_buf, U.pixelsize * 494 - date_width, U.pixelsize * 270, date_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
+ but = uiDefBut(
+ block, UI_BTYPE_LABEL, 0, date_buf,
+ U.pixelsize * 502 - date_width, U.pixelsize * 267,
+ date_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
+ /* XXX, set internal flag - UI_SELECT */
+ UI_but_flag_enable(but, 1);
label_delta = 12;
}
- uiDefBut(block, UI_BTYPE_LABEL, 0, hash_buf, U.pixelsize * 494 - hash_width, U.pixelsize * (270 - label_delta), hash_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
+ but = uiDefBut(
+ block, UI_BTYPE_LABEL, 0, hash_buf,
+ U.pixelsize * 502 - hash_width, U.pixelsize * (267 - label_delta),
+ hash_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
+ /* XXX, set internal flag - UI_SELECT */
+ UI_but_flag_enable(but, 1);
if (!STREQ(build_branch, "master")) {
char branch_buf[128] = "\0";
int branch_width;
BLI_snprintf(branch_buf, sizeof(branch_buf), "Branch: %s", build_branch);
branch_width = (int)BLF_width(style->widgetlabel.uifont_id, branch_buf, sizeof(branch_buf)) + U.widget_unit;
- uiDefBut(block, UI_BTYPE_LABEL, 0, branch_buf, U.pixelsize * 494 - branch_width, U.pixelsize * (258 - label_delta), branch_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
+ but = uiDefBut(
+ block, UI_BTYPE_LABEL, 0, branch_buf,
+ U.pixelsize * 502 - branch_width, U.pixelsize * (255 - label_delta),
+ branch_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
+ /* XXX, set internal flag - UI_SELECT */
+ UI_but_flag_enable(but, 1);
}
#endif /* WITH_BUILDINFO */
@@ -3123,7 +3199,7 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph
/* flat color if no texture available */
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3fvAlpha(col, alpha);
- imm_draw_circle_fill(pos, 0.0f, 0.0f, radius, 40);
+ imm_draw_circle_fill_2d(pos, 0.0f, 0.0f, radius, 40);
}
immUnbindProgram();
@@ -3230,10 +3306,10 @@ static void radial_control_paint_cursor(bContext *C, int x, int y, void *customd
}
/* draw circles on top */
- imm_draw_circle_wire(pos, 0.0f, 0.0f, r1, 40);
- imm_draw_circle_wire(pos, 0.0f, 0.0f, r2, 40);
+ imm_draw_circle_wire_2d(pos, 0.0f, 0.0f, r1, 40);
+ imm_draw_circle_wire_2d(pos, 0.0f, 0.0f, r2, 40);
if (rmin > 0.0f)
- imm_draw_circle_wire(pos, 0.0, 0.0f, rmin, 40);
+ imm_draw_circle_wire_2d(pos, 0.0, 0.0f, rmin, 40);
immUnbindProgram();
BLF_size(fontid, 1.5 * fstyle_points * U.pixelsize, U.dpi);
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c
index 445516ffda7..fcb471530e0 100644
--- a/source/blender/windowmanager/intern/wm_playanim.c
+++ b/source/blender/windowmanager/intern/wm_playanim.c
@@ -77,10 +77,10 @@
#include "WM_api.h" /* only for WM_main_playanim */
#ifdef WITH_AUDASPACE
-# include AUD_DEVICE_H
-# include AUD_HANDLE_H
-# include AUD_SOUND_H
-# include AUD_SPECIAL_H
+# include <AUD_Device.h>
+# include <AUD_Handle.h>
+# include <AUD_Sound.h>
+# include <AUD_Special.h>
static AUD_Sound *source = NULL;
static AUD_Handle *playback_handle = NULL;
@@ -319,7 +319,7 @@ static void playanim_toscreen(PlayState *ps, PlayAnimPict *picture, struct ImBuf
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- imm_draw_checker_box(offs_x, offs_y, offs_x + span_x, offs_y + span_y);
+ imm_draw_box_checker_2d(offs_x, offs_y, offs_x + span_x, offs_y + span_y);
}
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
@@ -1265,7 +1265,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
immInit();
/* initialize the font */
- BLF_init(11, 72);
+ BLF_init();
ps.fontid = BLF_load_mem("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size);
BLF_size(ps.fontid, 11, 72);
@@ -1437,8 +1437,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
ps.next_frame = ps.direction;
-
- while ((hasevent = GHOST_ProcessEvents(g_WS.ghost_system, 0)) || ps.wait2) {
+ while ((hasevent = GHOST_ProcessEvents(g_WS.ghost_system, ps.wait2))) {
if (hasevent) {
GHOST_DispatchEvents(g_WS.ghost_system);
}
diff --git a/source/blender/windowmanager/intern/wm_stereo.c b/source/blender/windowmanager/intern/wm_stereo.c
index 1e63a0e4483..c0800705b28 100644
--- a/source/blender/windowmanager/intern/wm_stereo.c
+++ b/source/blender/windowmanager/intern/wm_stereo.c
@@ -85,13 +85,13 @@ static void wm_method_draw_stereo3d_pageflip(wmWindow *win)
static GPUInterlaceShader interlace_gpu_id_from_type(eStereo3dInterlaceType interlace_type)
{
switch (interlace_type) {
- case S3D_INTERLACE_ROW:
- return GPU_SHADER_INTERLACE_ROW;
- case S3D_INTERLACE_COLUMN:
- return GPU_SHADER_INTERLACE_COLUMN;
- case S3D_INTERLACE_CHECKERBOARD:
- default:
- return GPU_SHADER_INTERLACE_CHECKER;
+ case S3D_INTERLACE_ROW:
+ return GPU_SHADER_INTERLACE_ROW;
+ case S3D_INTERLACE_COLUMN:
+ return GPU_SHADER_INTERLACE_COLUMN;
+ case S3D_INTERLACE_CHECKERBOARD:
+ default:
+ return GPU_SHADER_INTERLACE_CHECKER;
}
}
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 66df41e5b84..09b2b50687a 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -414,9 +414,14 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win)
}
}
-static void wm_window_set_dpi(wmWindow *win)
+void WM_window_set_dpi(wmWindow *win)
{
- int auto_dpi = GHOST_GetDPIHint(win->ghostwin);
+ float auto_dpi = GHOST_GetDPIHint(win->ghostwin);
+
+ /* Clamp auto DPI to 96, since our font/interface drawing does not work well
+ * with lower sizes. The main case we are interested in supporting is higher
+ * DPI. If a smaller UI is desired it is still possible to adjust UI scale. */
+ auto_dpi = max_ff(auto_dpi, 96.0f);
/* Lazily init UI scale size, preserving backwards compatibility by
* computing UI scale from ratio of previous DPI and auto DPI */
@@ -436,17 +441,22 @@ static void wm_window_set_dpi(wmWindow *win)
/* Blender's UI drawing assumes DPI 72 as a good default following macOS
* while Windows and Linux use DPI 96. GHOST assumes a default 96 so we
* remap the DPI to Blender's convention. */
+ auto_dpi *= GHOST_GetNativePixelSize(win->ghostwin);
int dpi = auto_dpi * U.ui_scale * (72.0 / 96.0f);
/* Automatically set larger pixel size for high DPI. */
- int pixelsize = MAX2(1, dpi / 54);
+ int pixelsize = max_ii(1, (int)(dpi / 64));
+ /* User adjustment for pixel size. */
+ pixelsize = max_ii(1, pixelsize + U.ui_line_width);
/* Set user preferences globals for drawing, and for forward compatibility. */
- U.pixelsize = GHOST_GetNativePixelSize(win->ghostwin) * pixelsize;
+ U.pixelsize = pixelsize;
U.dpi = dpi / pixelsize;
U.virtual_pixel = (pixelsize == 1) ? VIRTUAL_PIXEL_NATIVE : VIRTUAL_PIXEL_DOUBLE;
+ U.widget_unit = (U.pixelsize * U.dpi * 20 + 36) / 72;
- BKE_blender_userdef_refresh();
+ /* update font drawing */
+ BLF_default_dpi(U.pixelsize * U.dpi);
}
/* belongs to below */
@@ -506,8 +516,12 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, const char *title, wm
/* store actual window size in blender window */
bounds = GHOST_GetClientBounds(win->ghostwin);
- win->sizex = GHOST_GetWidthRectangle(bounds);
- win->sizey = GHOST_GetHeightRectangle(bounds);
+
+ /* win32: gives undefined window size when minimized */
+ if (GHOST_GetWindowState(win->ghostwin) != GHOST_kWindowStateMinimized) {
+ win->sizex = GHOST_GetWidthRectangle(bounds);
+ win->sizey = GHOST_GetHeightRectangle(bounds);
+ }
GHOST_DisposeRectangle(bounds);
#ifndef __APPLE__
@@ -522,7 +536,7 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, const char *title, wm
}
/* needed here, because it's used before it reads userdef */
- wm_window_set_dpi(win);
+ WM_window_set_dpi(win);
wm_window_swap_buffers(win);
@@ -1011,7 +1025,7 @@ void wm_window_make_drawable(wmWindowManager *wm, wmWindow *win)
immActivate();
/* this can change per window */
- wm_window_set_dpi(win);
+ WM_window_set_dpi(win);
}
}
@@ -1211,7 +1225,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
WM_jobs_stop(wm, WM_window_get_active_screen(win), NULL);
}
- wm_window_set_dpi(win);
+ WM_window_set_dpi(win);
/* win32: gives undefined window size when minimized */
if (state != GHOST_kWindowStateMinimized) {
@@ -1301,11 +1315,10 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
case GHOST_kEventWindowDPIHintChanged:
{
- wm_window_set_dpi(win);
+ WM_window_set_dpi(win);
/* font's are stored at each DPI level, without this we can easy load 100's of fonts */
BLF_cache_clear();
- BKE_blender_userdef_refresh();
WM_main_add_notifier(NC_WINDOW, NULL); /* full redraw */
WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); /* refresh region sizes */
break;
@@ -1391,7 +1404,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
{
// only update if the actual pixel size changes
float prev_pixelsize = U.pixelsize;
- wm_window_set_dpi(win);
+ WM_window_set_dpi(win);
if (U.pixelsize != prev_pixelsize) {
BKE_icon_changed(WM_window_get_active_screen(win)->id.icon_id);
@@ -1954,7 +1967,7 @@ void WM_window_set_active_workspace(wmWindow *win, WorkSpace *workspace)
WorkSpaceLayout *WM_window_get_active_layout(const wmWindow *win)
{
const WorkSpace *workspace = WM_window_get_active_workspace(win);
- return (LIKELY(workspace != NULL) ? BKE_workspace_active_layout_get(win->workspace_hook): NULL);
+ return (LIKELY(workspace != NULL) ? BKE_workspace_active_layout_get(win->workspace_hook) : NULL);
}
void WM_window_set_active_layout(wmWindow *win, WorkSpace *workspace, WorkSpaceLayout *layout)
{
diff --git a/source/blender/windowmanager/manipulators/WM_manipulator_api.h b/source/blender/windowmanager/manipulators/WM_manipulator_api.h
index d6774333ba4..726e560a061 100644
--- a/source/blender/windowmanager/manipulators/WM_manipulator_api.h
+++ b/source/blender/windowmanager/manipulators/WM_manipulator_api.h
@@ -59,18 +59,25 @@ struct wmManipulatorMapType_Params;
struct wmManipulator *WM_manipulator_new_ptr(
const struct wmManipulatorType *wt, struct wmManipulatorGroup *mgroup,
- const char *name, struct PointerRNA *properties);
+ struct PointerRNA *properties);
struct wmManipulator *WM_manipulator_new(
const char *idname, struct wmManipulatorGroup *mgroup,
- const char *name, struct PointerRNA *properties);
-void WM_manipulator_free(
+ struct PointerRNA *properties);
+void WM_manipulator_free(struct wmManipulator *mpr);
+void WM_manipulator_unlink(
ListBase *manipulatorlist, struct wmManipulatorMap *mmap, struct wmManipulator *mpr,
struct bContext *C);
void WM_manipulator_name_set(struct wmManipulatorGroup *mgroup, struct wmManipulator *mpr, const char *name);
-struct PointerRNA *WM_manipulator_set_operator(
- struct wmManipulator *, struct wmOperatorType *ot, struct IDProperty *properties);
+bool WM_manipulator_select_unlink(struct wmManipulatorMap *mmap, struct wmManipulator *mpr);
+bool WM_manipulator_select_set(struct wmManipulatorMap *mmap, struct wmManipulator *mpr, bool select);
+
+struct wmManipulatorOpElem *WM_manipulator_operator_get(
+ struct wmManipulator *mpr, int part_index);
+struct PointerRNA *WM_manipulator_operator_set(
+ struct wmManipulator *mpr, int part_index,
+ struct wmOperatorType *ot, struct IDProperty *properties);
/* callbacks */
void WM_manipulator_set_fn_custom_modal(struct wmManipulator *mpr, wmManipulatorFnModal fn);
@@ -93,10 +100,26 @@ void WM_manipulator_set_flag(struct wmManipulator *mpr, const int flag, const bo
void WM_manipulator_set_scale(struct wmManipulator *mpr, float scale);
void WM_manipulator_set_line_width(struct wmManipulator *mpr, const float line_width);
-void WM_manipulator_get_color(const struct wmManipulator *mpr, float col[4]);
-void WM_manipulator_set_color(struct wmManipulator *mpr, const float col[4]);
-void WM_manipulator_get_color_highlight(const struct wmManipulator *mpr, float col_hi[4]);
-void WM_manipulator_set_color_highlight(struct wmManipulator *mpr, const float col[4]);
+void WM_manipulator_get_color(const struct wmManipulator *mpr, float color[4]);
+void WM_manipulator_set_color(struct wmManipulator *mpr, const float color[4]);
+void WM_manipulator_get_color_highlight(const struct wmManipulator *mpr, float color_hi[4]);
+void WM_manipulator_set_color_highlight(struct wmManipulator *mpr, const float color[4]);
+
+/**
+ * Leaving values NULL use values from #wmManipulator.
+ */
+struct WM_ManipulatorMatrixParams {
+ const float(*matrix_space)[4];
+ const float(*matrix_basis)[4];
+ const float(*matrix_offset)[4];
+ const float *scale_final;
+};
+
+void WM_manipulator_calc_matrix_final_params(
+ const struct wmManipulator *mpr, const struct WM_ManipulatorMatrixParams *params,
+ float r_mat[4][4]);
+
+void WM_manipulator_calc_matrix_final(const struct wmManipulator *mpr, float r_mat[4][4]);
/* properties */
void WM_manipulator_properties_create_ptr(struct PointerRNA *ptr, struct wmManipulatorType *wt);
@@ -113,16 +136,16 @@ void WM_manipulator_properties_free(struct PointerRNA *ptr);
const struct wmManipulatorType *WM_manipulatortype_find(const char *idname, bool quiet);
void WM_manipulatortype_append(void (*wtfunc)(struct wmManipulatorType *));
void WM_manipulatortype_append_ptr(void (*mnpfunc)(struct wmManipulatorType *, void *), void *userdata);
-bool WM_manipulatortype_remove(const char *idname);
-void WM_manipulatortype_remove_ptr(struct wmManipulatorType *wt);
+bool WM_manipulatortype_remove(struct bContext *C, struct Main *bmain, const char *idname);
+void WM_manipulatortype_remove_ptr(struct bContext *C, struct Main *bmain, struct wmManipulatorType *wt);
void WM_manipulatortype_iter(struct GHashIterator *ghi);
/* wm_manipulator_group_type.c */
struct wmManipulatorGroupType *WM_manipulatorgrouptype_find(const char *idname, bool quiet);
struct wmManipulatorGroupType *WM_manipulatorgrouptype_append(void (*wtfunc)(struct wmManipulatorGroupType *));
struct wmManipulatorGroupType *WM_manipulatorgrouptype_append_ptr(void (*mnpfunc)(struct wmManipulatorGroupType *, void *), void *userdata);
-bool WM_manipulatorgrouptype_remove(const char *idname);
-void WM_manipulatorgrouptype_remove_ptr(struct wmManipulatorGroupType *wt);
+bool WM_manipulatorgrouptype_free(const char *idname);
+void WM_manipulatorgrouptype_free_ptr(struct wmManipulatorGroupType *wt);
void WM_manipulatorgrouptype_iter(struct GHashIterator *ghi);
struct wmManipulatorGroupTypeRef *WM_manipulatorgrouptype_append_and_link(
@@ -174,10 +197,13 @@ void WM_manipulator_target_property_value_set_array(
struct bContext *C, const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop,
const float *value);
-void WM_manipulator_target_property_range_get(
+bool WM_manipulator_target_property_range_get(
const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop,
float range[2]);
+int WM_manipulator_target_property_array_length(
+ const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop);
+
/* definitions */
const struct wmManipulatorPropertyType *WM_manipulatortype_target_property_find(
const struct wmManipulatorType *wt, const char *idname);
@@ -202,10 +228,15 @@ struct wmManipulatorMap *WM_manipulatormap_new_from_type(
const struct wmManipulatorMapType_Params *mmap_params);
const struct ListBase *WM_manipulatormap_group_list(struct wmManipulatorMap *mmap);
void WM_manipulatormap_tag_refresh(struct wmManipulatorMap *mmap);
-void WM_manipulatormap_draw(struct wmManipulatorMap *mmap, const struct bContext *C, const int drawstep);
+void WM_manipulatormap_draw(
+ struct wmManipulatorMap *mmap, const struct bContext *C, const eWM_ManipulatorMapDrawStep drawstep);
void WM_manipulatormap_add_handlers(struct ARegion *ar, struct wmManipulatorMap *mmap);
bool WM_manipulatormap_select_all(struct bContext *C, struct wmManipulatorMap *mmap, const int action);
bool WM_manipulatormap_cursor_set(const struct wmManipulatorMap *mmap, struct wmWindow *win);
+bool WM_manipulatormap_is_any_selected(const struct wmManipulatorMap *mmap);
+bool WM_manipulatormap_minmax(
+ const struct wmManipulatorMap *mmap, bool use_hidden, bool use_select,
+ float r_min[3], float r_max[3]);
/* -------------------------------------------------------------------- */
/* wmManipulatorMapType */
@@ -228,6 +259,9 @@ struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_link_ptr(
struct wmManipulatorMapType *mmap_type,
struct wmManipulatorGroupType *wgt);
+void WM_manipulatormaptype_group_init_runtime_keymap(
+ const struct Main *bmain,
+ struct wmManipulatorGroupType *wgt);
void WM_manipulatormaptype_group_init_runtime(
const struct Main *bmain, struct wmManipulatorMapType *mmap_type,
struct wmManipulatorGroupType *wgt);
@@ -238,27 +272,32 @@ void WM_manipulatormaptype_group_unlink(
void WM_manipulatormaptype_group_free(struct wmManipulatorGroupTypeRef *wgt);
/* -------------------------------------------------------------------- */
-/* Manipulator Add/Remove (High level API) */
+/* ManipulatorGroup */
-void WM_manipulator_group_add_ptr_ex(
+/* Add/Remove (High level API) */
+
+void WM_manipulator_group_type_add_ptr_ex(
struct wmManipulatorGroupType *wgt,
struct wmManipulatorMapType *mmap_type);
-void WM_manipulator_group_add_ptr(
+void WM_manipulator_group_type_add_ptr(
struct wmManipulatorGroupType *wgt);
-void WM_manipulator_group_add(const char *idname);
+void WM_manipulator_group_type_add(const char *idname);
-void WM_manipulator_group_remove_ptr_ex(
+void WM_manipulator_group_type_remove_ptr_ex(
struct Main *bmain, struct wmManipulatorGroupType *wgt,
struct wmManipulatorMapType *mmap_type);
-void WM_manipulator_group_remove_ptr(
+void WM_manipulator_group_type_remove_ptr(
struct Main *bmain, struct wmManipulatorGroupType *wgt);
-void WM_manipulator_group_remove(struct Main *bmain, const char *idname);
+void WM_manipulator_group_type_remove(struct Main *bmain, const char *idname);
-void WM_manipulator_group_remove_ptr_delayed_ex(
+void WM_manipulator_group_type_remove_ptr_delayed_ex(
struct wmManipulatorGroupType *wgt,
struct wmManipulatorMapType *mmap_type);
-void WM_manipulator_group_remove_ptr_delayed(
+void WM_manipulator_group_type_remove_ptr_delayed(
struct wmManipulatorGroupType *wgt);
-void WM_manipulator_group_remove_delayed(const char *idname);
+void WM_manipulator_group_type_remove_delayed(const char *idname);
+
+/* Utilities */
+void WM_manipulator_group_type_is_any_selected(const char *idname);
#endif /* __WM_MANIPULATOR_API_H__ */
diff --git a/source/blender/windowmanager/manipulators/WM_manipulator_types.h b/source/blender/windowmanager/manipulators/WM_manipulator_types.h
index b1b6c5b1c0f..22f1eb68181 100644
--- a/source/blender/windowmanager/manipulators/WM_manipulator_types.h
+++ b/source/blender/windowmanager/manipulators/WM_manipulator_types.h
@@ -45,19 +45,115 @@ struct wmManipulator;
struct wmManipulatorProperty;
struct wmKeyConfig;
-#include "wm_manipulator_fn.h"
-
#include "DNA_listBase.h"
+
+/* -------------------------------------------------------------------- */
+/* Enum Typedef's */
+
+
+/**
+ * #wmManipulator.state
+ */
+typedef enum eWM_ManipulatorState {
+ WM_MANIPULATOR_STATE_HIGHLIGHT = (1 << 0), /* while hovered */
+ WM_MANIPULATOR_STATE_MODAL = (1 << 1), /* while dragging */
+ WM_MANIPULATOR_STATE_SELECT = (1 << 2),
+} eWM_ManipulatorState;
+
+
+/**
+ * #wmManipulator.flag
+ * Flags for individual manipulators.
+ */
+typedef enum eWM_ManipulatorFlag {
+ WM_MANIPULATOR_DRAW_HOVER = (1 << 0), /* draw *only* while hovering */
+ WM_MANIPULATOR_DRAW_MODAL = (1 << 1), /* draw while dragging */
+ WM_MANIPULATOR_DRAW_VALUE = (1 << 2), /* draw an indicator for the current value while dragging */
+ WM_MANIPULATOR_HIDDEN = (1 << 3),
+ /**
+ * When set 'scale_final' value also scales the offset.
+ * Use when offset is to avoid screen-space overlap instead of absolute positioning. */
+ WM_MANIPULATOR_DRAW_OFFSET_SCALE = (1 << 4),
+ /**
+ * User should still use 'scale_final' for any handles and UI elements.
+ * This simply skips scale when calculating the final matrix.
+ * Needed when the manipulator needs to align with the interface underneath it. */
+ WM_MANIPULATOR_DRAW_NO_SCALE = (1 << 5),
+} eWM_ManipulatorFlag;
+
+/**
+ * #wmManipulatorGroupType.flag
+ * Flags that influence the behavior of all manipulators in the group.
+ */
+typedef enum eWM_ManipulatorGroupTypeFlag {
+ /* Mark manipulator-group as being 3D */
+ WM_MANIPULATORGROUPTYPE_3D = (1 << 0),
+ /* Scale manipulators as 3D object that respects zoom (otherwise zoom independent draw size).
+ * note: currently only for 3D views, 2D support needs adding. */
+ WM_MANIPULATORGROUPTYPE_SCALE = (1 << 1),
+ /* Manipulators can be depth culled with scene objects (covered by other geometry - TODO) */
+ WM_MANIPULATORGROUPTYPE_DEPTH_3D = (1 << 2),
+ /* Manipulators can be selected */
+ WM_MANIPULATORGROUPTYPE_SELECT = (1 << 3),
+ /* The manipulator group is to be kept (not removed on loading a new file for eg). */
+ WM_MANIPULATORGROUPTYPE_PERSISTENT = (1 << 4),
+ /* Show all other manipulators when interacting. */
+ WM_MANIPULATORGROUPTYPE_DRAW_MODAL_ALL = (1 << 5),
+} eWM_ManipulatorGroupTypeFlag;
+
+
+/**
+ * #wmManipulatorGroup.init_flag
+ */
+typedef enum eWM_ManipulatorGroupInitFlag {
+ /* mgroup has been initialized */
+ WM_MANIPULATORGROUP_INIT_SETUP = (1 << 0),
+} eWM_ManipulatorGroupInitFlag;
+
+/**
+ * #wmManipulatorMapType.type_update_flag
+ * Manipulator-map type update flag
+ */
+typedef enum eWM_ManipulatorMapTypeUpdateFlag {
+ /* A new type has been added, needs to be initialized for all views. */
+ WM_MANIPULATORMAPTYPE_UPDATE_INIT = (1 << 0),
+ WM_MANIPULATORMAPTYPE_UPDATE_REMOVE = (1 << 1),
+
+ /* Needed because keymap may be registered before and after window initialization.
+ * So we need to keep track of keymap initialization separately. */
+ WM_MANIPULATORMAPTYPE_KEYMAP_INIT = (1 << 2),
+} eWM_ManipulatorMapTypeUpdateFlag;
+
/* -------------------------------------------------------------------- */
/* wmManipulator */
+/**
+ * \brief Manipulator tweak flag.
+ * Bitflag passed to manipulator while tweaking.
+ *
+ * \note Manipulators are responsible for handling this #wmManipulator.modal callback!.
+ */
+typedef enum {
+ /* Drag with extra precision (Shift). */
+ WM_MANIPULATOR_TWEAK_PRECISE = (1 << 0),
+ /* Drag with snap enabled (Ctrl). */
+ WM_MANIPULATOR_TWEAK_SNAP = (1 << 1),
+} eWM_ManipulatorTweak;
+
+#include "wm_manipulator_fn.h"
+
+typedef struct wmManipulatorOpElem {
+ struct wmOperatorType *type;
+ /* operator properties if manipulator spawns and controls an operator,
+ * or owner pointer if manipulator spawns and controls a property */
+ PointerRNA ptr;
+} wmManipulatorOpElem;
+
/* manipulators are set per region by registering them on manipulator-maps */
struct wmManipulator {
struct wmManipulator *next, *prev;
- char name[64 + 4]; /* MAX_NAME + 4 for unique '.001', '.002', etc suffix */
-
/* While we don't have a real type, use this to put type-like vars. */
const struct wmManipulatorType *type;
@@ -73,10 +169,13 @@ struct wmManipulator {
/* rna pointer to access properties */
struct PointerRNA *ptr;
- int flag; /* flags that influence the behavior or how the manipulators are drawn */
- short state; /* state flags (active, highlighted, selected) */
+ /* flags that influence the behavior or how the manipulators are drawn */
+ eWM_ManipulatorFlag flag;
+ /* state flags (active, highlighted, selected) */
+ eWM_ManipulatorState state;
- /* Optional ID for highlighting different parts of this manipulator. */
+ /* Optional ID for highlighting different parts of this manipulator.
+ * -1 when unset, otherwise a valid index. (Used as index to 'op_data'). */
int highlight_part;
/* Transformation of the manipulator in 2d or 3d space.
@@ -87,6 +186,10 @@ struct wmManipulator {
* besides this it's up to the manipulators internal code how the
* rotation components are used for drawing and interaction.
*/
+
+ /* The space this manipulator is being modified in. */
+ float matrix_space[4][4];
+ /* Transformation of this manipulator. */
float matrix_basis[4][4];
/* custom offset from origin */
float matrix_offset[4][4];
@@ -102,22 +205,16 @@ struct wmManipulator {
/* data used during interaction */
void *interaction_data;
- /* name of operator to spawn when activating the manipulator */
- struct {
- struct wmOperatorType *type;
- /* operator properties if manipulator spawns and controls an operator,
- * or owner pointer if manipulator spawns and controls a property */
- PointerRNA ptr;
- } op_data;
+ /* Operator to spawn when activating the manipulator (overrides property editing),
+ * an array of items (aligned with #wmManipulator.highlight_part). */
+ wmManipulatorOpElem *op_data;
+ int op_data_len;
struct IDProperty *properties;
/* over alloc target_properties after 'wmManipulatorType.struct_size' */
};
-typedef void (*wmManipulatorGroupFnInit)(
- const struct bContext *, struct wmManipulatorGroup *);
-
/* Similar to PropertyElemRNA, but has an identifier. */
typedef struct wmManipulatorProperty {
const struct wmManipulatorPropertyType *type;
@@ -133,7 +230,6 @@ typedef struct wmManipulatorProperty {
wmManipulatorPropertyFnSet value_set_fn;
wmManipulatorPropertyFnRangeGet range_get_fn;
wmManipulatorPropertyFnFree free_fn;
- const struct bContext *context;
void *user_data;
} custom_func;
} wmManipulatorProperty;
@@ -152,7 +248,6 @@ typedef struct wmManipulatorPropertyType {
} wmManipulatorPropertyType;
-
/**
* Simple utility wrapper for storing a single manipulator as wmManipulatorGroup.customdata (which gets freed).
*/
@@ -165,36 +260,6 @@ struct wmManipulatorMapType_Params {
short regionid;
};
-
-/* wmManipulator.flag
- * Flags for individual manipulators. */
-enum {
- WM_MANIPULATOR_DRAW_HOVER = (1 << 0), /* draw *only* while hovering */
- WM_MANIPULATOR_DRAW_ACTIVE = (1 << 1), /* draw while dragging */
- WM_MANIPULATOR_DRAW_VALUE = (1 << 2), /* draw an indicator for the current value while dragging */
- WM_MANIPULATOR_HIDDEN = (1 << 3),
-};
-
-/* wmManipulator.state */
-enum {
- WM_MANIPULATOR_STATE_HIGHLIGHT = (1 << 0), /* while hovered */
- WM_MANIPULATOR_STATE_ACTIVE = (1 << 1), /* while dragging */
- WM_MANIPULATOR_STATE_SELECT = (1 << 2),
-};
-
-/**
- * \brief Manipulator tweak flag.
- * Bitflag passed to manipulator while tweaking.
- *
- * \note Manipulators are responsible for handling this #wmManipulator.modal callback!.
- */
-enum {
- /* Drag with extra precision (Shift). */
- WM_MANIPULATOR_TWEAK_PRECISE = (1 << 0),
- /* Drag with snap enabled (Ctrl). */
- WM_MANIPULATOR_TWEAK_SNAP = (1 << 1),
-};
-
typedef struct wmManipulatorType {
const char *idname; /* MAX_NAME */
@@ -212,7 +277,8 @@ typedef struct wmManipulatorType {
/* determines 3d intersection by rendering the manipulator in a selection routine. */
wmManipulatorFnDrawSelect draw_select;
- /* determine if the mouse intersects with the manipulator. The calculation should be done in the callback itself */
+ /* Determine if the mouse intersects with the manipulator.
+ * The calculation should be done in the callback itself, -1 for no seleciton. */
wmManipulatorFnTestSelect test_select;
/* handler used by the manipulator. Usually handles interaction tied to a manipulator type */
@@ -227,7 +293,7 @@ typedef struct wmManipulatorType {
* - Scale isn't applied (wmManipulator.scale/user_scale).
* - Offset isn't applied (wmManipulator.matrix_offset).
*/
- wmManipulatorFnMatrixWorldGet matrix_world_get;
+ wmManipulatorFnMatrixBasisGet matrix_basis_get;
/* activate a manipulator state when the user clicks on it */
wmManipulatorFnInvoke invoke;
@@ -238,7 +304,7 @@ typedef struct wmManipulatorType {
wmManipulatorFnCursorGet cursor_get;
/* called when manipulator selection state changes */
- wmManipulatorFnSelect select;
+ wmManipulatorFnSelectRefresh select_refresh;
/* RNA for properties */
struct StructRNA *srna;
@@ -293,10 +359,10 @@ typedef struct wmManipulatorGroupType {
/* RNA integration */
ExtensionRNA ext;
- int flag;
+ eWM_ManipulatorGroupTypeFlag flag;
- /* eManipulatorMapTypeUpdateFlags (so we know which group type to update) */
- uchar type_update_flag;
+ /* So we know which group type to update. */
+ eWM_ManipulatorMapTypeUpdateFlag type_update_flag;
/* same as manipulator-maps, so registering/unregistering goes to the correct region */
struct wmManipulatorMapType_Params mmap_params;
@@ -316,52 +382,21 @@ typedef struct wmManipulatorGroup {
void *customdata;
void (*customdata_free)(void *); /* for freeing customdata from above */
- int flag; /* private */
- int pad;
+ eWM_ManipulatorGroupInitFlag init_flag;
} wmManipulatorGroup;
-/**
- * Manipulator-map type update flag: `wmManipulatorMapType.type_update_flag`
- */
-enum eManipulatorMapTypeUpdateFlags {
- /* A new type has been added, needs to be initialized for all views. */
- WM_MANIPULATORMAPTYPE_UPDATE_INIT = (1 << 0),
- WM_MANIPULATORMAPTYPE_UPDATE_REMOVE = (1 << 1),
-};
-
-/**
- * wmManipulatorGroupType.flag
- * Flags that influence the behavior of all manipulators in the group.
- */
-enum {
- /* Mark manipulator-group as being 3D */
- WM_MANIPULATORGROUPTYPE_3D = (1 << 0),
- /* Scale manipulators as 3D object that respects zoom (otherwise zoom independent draw size).
- * note: currently only for 3D views, 2D support needs adding. */
- WM_MANIPULATORGROUPTYPE_SCALE = (1 << 1),
- /* Manipulators can be depth culled with scene objects (covered by other geometry - TODO) */
- WM_MANIPULATORGROUPTYPE_DEPTH_3D = (1 << 2),
- /* Manipulators can be selected */
- WM_MANIPULATORGROUPTYPE_SELECT = (1 << 3),
- /* The manipulator group is to be kept (not removed on loading a new file for eg). */
- WM_MANIPULATORGROUPTYPE_PERSISTENT = (1 << 4),
-};
-
-
/* -------------------------------------------------------------------- */
/* wmManipulatorMap */
/**
* Pass a value of this enum to #WM_manipulatormap_draw to tell it what to draw.
*/
-enum {
- /* Draw 2D manipulator-groups (ManipulatorGroupType.is_3d == false) */
+typedef enum eWM_ManipulatorMapDrawStep {
+ /** Draw 2D manipulator-groups (#WM_MANIPULATORGROUPTYPE_3D not set). */
WM_MANIPULATORMAP_DRAWSTEP_2D = 0,
- /* Draw 3D manipulator-groups (ManipulatorGroupType.is_3d == true) */
+ /** Draw 3D manipulator-groups (#WM_MANIPULATORGROUPTYPE_3D set). */
WM_MANIPULATORMAP_DRAWSTEP_3D,
- /* Draw only depth culled manipulators (WM_MANIPULATOR_SCENE_DEPTH flag).
- * Note that these are expected to be 3D manipulators too. */
- WM_MANIPULATORMAP_DRAWSTEP_IN_SCENE,
-};
+} eWM_ManipulatorMapDrawStep;
+#define WM_MANIPULATORMAP_DRAWSTEP_MAX 2
#endif /* __WM_MANIPULATOR_TYPES_H__ */
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
index d8d530a4db9..3df4124ba65 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
@@ -65,7 +65,7 @@
#include "wm_manipulator_intern.h"
static void wm_manipulator_register(
- wmManipulatorGroup *mgroup, wmManipulator *mpr, const char *name);
+ wmManipulatorGroup *mgroup, wmManipulator *mpr);
/**
* \note Follow #wm_operator_create convention.
@@ -94,6 +94,7 @@ static wmManipulator *wm_manipulator_create(
WM_manipulator_properties_sanitize(mpr->ptr, 0);
+ unit_m4(mpr->matrix_space);
unit_m4(mpr->matrix_basis);
unit_m4(mpr->matrix_offset);
@@ -102,11 +103,11 @@ static wmManipulator *wm_manipulator_create(
wmManipulator *WM_manipulator_new_ptr(
const wmManipulatorType *wt, wmManipulatorGroup *mgroup,
- const char *name, PointerRNA *properties)
+ PointerRNA *properties)
{
wmManipulator *mpr = wm_manipulator_create(wt, properties);
- wm_manipulator_register(mgroup, mpr, name);
+ wm_manipulator_register(mgroup, mpr);
if (mpr->type->setup != NULL) {
mpr->type->setup(mpr);
@@ -122,33 +123,10 @@ wmManipulator *WM_manipulator_new_ptr(
*/
wmManipulator *WM_manipulator_new(
const char *idname, wmManipulatorGroup *mgroup,
- const char *name, PointerRNA *properties)
+ PointerRNA *properties)
{
const wmManipulatorType *wt = WM_manipulatortype_find(idname, false);
- return WM_manipulator_new_ptr(wt, mgroup, name, properties);
-}
-
-/**
- * Assign an idname that is unique in \a mgroup to \a manipulator.
- *
- * \param rawname: Name used as basis to define final unique idname.
- */
-static void manipulator_unique_idname_set(wmManipulatorGroup *mgroup, wmManipulator *mpr, const char *rawname)
-{
- BLI_snprintf(mpr->name, sizeof(mpr->name), "%s_%s", mgroup->type->idname, rawname);
-
- /* ensure name is unique, append '.001', '.002', etc if not */
- BLI_uniquename(&mgroup->manipulators, mpr, "Manipulator", '.',
- offsetof(wmManipulator, name), sizeof(mpr->name));
-}
-
-void WM_manipulator_name_set(wmManipulatorGroup *mgroup, wmManipulator *mpr, const char *name)
-{
- BLI_strncpy(mpr->name, name, sizeof(mpr->name));
-
- /* ensure name is unique, append '.001', '.002', etc if not */
- BLI_uniquename(&mgroup->manipulators, mpr, "Manipulator", '.',
- offsetof(wmManipulator, name), sizeof(mpr->name));
+ return WM_manipulator_new_ptr(wt, mgroup, properties);
}
/**
@@ -173,18 +151,18 @@ static void manipulator_init(wmManipulator *mpr)
*
* \note Not to be confused with type registration from RNA.
*/
-static void wm_manipulator_register(wmManipulatorGroup *mgroup, wmManipulator *mpr, const char *name)
+static void wm_manipulator_register(wmManipulatorGroup *mgroup, wmManipulator *mpr)
{
manipulator_init(mpr);
- manipulator_unique_idname_set(mgroup, mpr, name);
wm_manipulatorgroup_manipulator_register(mgroup, mpr);
}
/**
- * Free \a manipulator and unlink from \a manipulatorlist.
- * \a manipulatorlist is allowed to be NULL.
+ * \warning this doesn't check #wmManipulatorMap (highlight, selection etc).
+ * Typical use is when freeing the windowing data,
+ * where caller can manage clearing selection, highlight... etc.
*/
-void WM_manipulator_free(ListBase *manipulatorlist, wmManipulatorMap *mmap, wmManipulator *mpr, bContext *C)
+void WM_manipulator_free(wmManipulator *mpr)
{
#ifdef WITH_PYTHON
if (mpr->py_instance) {
@@ -194,18 +172,11 @@ void WM_manipulator_free(ListBase *manipulatorlist, wmManipulatorMap *mmap, wmMa
}
#endif
- if (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) {
- wm_manipulatormap_highlight_set(mmap, C, NULL, 0);
- }
- if (mpr->state & WM_MANIPULATOR_STATE_ACTIVE) {
- wm_manipulatormap_active_set(mmap, C, NULL, NULL);
- }
- if (mpr->state & WM_MANIPULATOR_STATE_SELECT) {
- wm_manipulator_deselect(mmap, mpr);
- }
-
- if (mpr->op_data.ptr.data) {
- WM_operator_properties_free(&mpr->op_data.ptr);
+ if (mpr->op_data) {
+ for (int i = 0; i < mpr->op_data_len; i++) {
+ WM_operator_properties_free(&mpr->op_data[i].ptr);
+ }
+ MEM_freeN(mpr->op_data);
}
if (mpr->ptr != NULL) {
@@ -223,14 +194,34 @@ void WM_manipulator_free(ListBase *manipulatorlist, wmManipulatorMap *mmap, wmMa
}
}
+ MEM_freeN(mpr);
+}
+
+/**
+ * Free \a manipulator and unlink from \a manipulatorlist.
+ * \a manipulatorlist is allowed to be NULL.
+ */
+void WM_manipulator_unlink(ListBase *manipulatorlist, wmManipulatorMap *mmap, wmManipulator *mpr, bContext *C)
+{
+ if (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) {
+ wm_manipulatormap_highlight_set(mmap, C, NULL, 0);
+ }
+ if (mpr->state & WM_MANIPULATOR_STATE_MODAL) {
+ wm_manipulatormap_modal_set(mmap, C, mpr, NULL, false);
+ }
+ /* Unlink instead of setting so we don't run callbacks. */
+ if (mpr->state & WM_MANIPULATOR_STATE_SELECT) {
+ WM_manipulator_select_unlink(mmap, mpr);
+ }
+
if (manipulatorlist) {
BLI_remlink(manipulatorlist, mpr);
}
BLI_assert(mmap->mmap_context.highlight != mpr);
- BLI_assert(mmap->mmap_context.active != mpr);
+ BLI_assert(mmap->mmap_context.modal != mpr);
- MEM_freeN(mpr);
+ WM_manipulator_free(mpr);
}
/* -------------------------------------------------------------------- */
@@ -240,22 +231,38 @@ void WM_manipulator_free(ListBase *manipulatorlist, wmManipulatorMap *mmap, wmMa
*
* \{ */
+struct wmManipulatorOpElem *WM_manipulator_operator_get(
+ wmManipulator *mpr, int part_index)
+{
+ if (mpr->op_data && ((part_index >= 0) && (part_index < mpr->op_data_len))) {
+ return &mpr->op_data[part_index];
+ }
+ return NULL;
+}
-PointerRNA *WM_manipulator_set_operator(
- wmManipulator *mpr, wmOperatorType *ot, IDProperty *properties)
+PointerRNA *WM_manipulator_operator_set(
+ wmManipulator *mpr, int part_index,
+ wmOperatorType *ot, IDProperty *properties)
{
- mpr->op_data.type = ot;
+ BLI_assert(part_index < 255);
+ /* We could pre-allocate these but using multiple is such a rare thing. */
+ if (part_index >= mpr->op_data_len) {
+ mpr->op_data_len = part_index + 1;
+ mpr->op_data = MEM_recallocN(mpr->op_data, sizeof(*mpr->op_data) * mpr->op_data_len);
+ }
+ wmManipulatorOpElem *mpop = &mpr->op_data[part_index];
+ mpop->type = ot;
- if (mpr->op_data.ptr.data) {
- WM_operator_properties_free(&mpr->op_data.ptr);
+ if (mpop->ptr.data) {
+ WM_operator_properties_free(&mpop->ptr);
}
- WM_operator_properties_create_ptr(&mpr->op_data.ptr, ot);
+ WM_operator_properties_create_ptr(&mpop->ptr, ot);
if (properties) {
- mpr->op_data.ptr.data = properties;
+ mpop->ptr.data = properties;
}
- return &mpr->op_data.ptr;
+ return &mpop->ptr;
}
static void wm_manipulator_set_matrix_rotation_from_z_axis__internal(
@@ -348,13 +355,13 @@ void WM_manipulator_set_line_width(wmManipulator *mpr, const float line_width)
* \param col Normal state color.
* \param col_hi Highlighted state color.
*/
-void WM_manipulator_get_color(const wmManipulator *mpr, float col[4])
+void WM_manipulator_get_color(const wmManipulator *mpr, float color[4])
{
- copy_v4_v4(col, mpr->color);
+ copy_v4_v4(color, mpr->color);
}
-void WM_manipulator_set_color(wmManipulator *mpr, const float col[4])
+void WM_manipulator_set_color(wmManipulator *mpr, const float color[4])
{
- copy_v4_v4(mpr->color, col);
+ copy_v4_v4(mpr->color, color);
}
void WM_manipulator_get_color_highlight(const wmManipulator *mpr, float color_hi[4])
@@ -386,73 +393,67 @@ void WM_manipulator_set_fn_custom_modal(struct wmManipulator *mpr, wmManipulator
/* -------------------------------------------------------------------- */
/**
- * Remove \a manipulator from selection.
+ * Add/Remove \a manipulator to selection.
* Reallocates memory for selected manipulators so better not call for selecting multiple ones.
*
* \return if the selection has changed.
*/
-bool wm_manipulator_deselect(wmManipulatorMap *mmap, wmManipulator *mpr)
+bool wm_manipulator_select_set_ex(
+ wmManipulatorMap *mmap, wmManipulator *mpr, bool select,
+ bool use_array, bool use_callback)
{
- if (!mmap->mmap_context.selected)
- return false;
-
- wmManipulator ***sel = &mmap->mmap_context.selected;
- int *selected_len = &mmap->mmap_context.selected_len;
bool changed = false;
- /* caller should check! */
- BLI_assert(mpr->state & WM_MANIPULATOR_STATE_SELECT);
-
- /* remove manipulator from selected_manipulators array */
- for (int i = 0; i < (*selected_len); i++) {
- if ((*sel)[i] == mpr) {
- for (int j = i; j < ((*selected_len) - 1); j++) {
- (*sel)[j] = (*sel)[j + 1];
+ if (select) {
+ if ((mpr->state & WM_MANIPULATOR_STATE_SELECT) == 0) {
+ if (use_array) {
+ wm_manipulatormap_select_array_push_back(mmap, mpr);
}
+ mpr->state |= WM_MANIPULATOR_STATE_SELECT;
changed = true;
- break;
}
}
-
- /* update array data */
- if ((*selected_len) <= 1) {
- wm_manipulatormap_selected_clear(mmap);
- }
else {
- *sel = MEM_reallocN(*sel, sizeof(**sel) * (*selected_len));
- (*selected_len)--;
+ if (mpr->state & WM_MANIPULATOR_STATE_SELECT) {
+ if (use_array) {
+ wm_manipulatormap_select_array_remove(mmap, mpr);
+ }
+ mpr->state &= ~WM_MANIPULATOR_STATE_SELECT;
+ changed = true;
+ }
+ }
+
+ /* In the case of unlinking we only want to remove from the array
+ * and not write to the external state */
+ if (use_callback && changed) {
+ if (mpr->type->select_refresh) {
+ mpr->type->select_refresh(mpr);
+ }
}
- mpr->state &= ~WM_MANIPULATOR_STATE_SELECT;
return changed;
}
-/**
- * Add \a manipulator to selection.
- * Reallocates memory for selected manipulators so better not call for selecting multiple ones.
- *
- * \return if the selection has changed.
- */
-bool wm_manipulator_select(bContext *C, wmManipulatorMap *mmap, wmManipulator *mpr)
+/* Remove from selection array without running callbacks. */
+bool WM_manipulator_select_unlink(wmManipulatorMap *mmap, wmManipulator *mpr)
{
- wmManipulator ***sel = &mmap->mmap_context.selected;
- int *selected_len = &mmap->mmap_context.selected_len;
-
- if (!mpr || (mpr->state & WM_MANIPULATOR_STATE_SELECT))
- return false;
-
- (*selected_len)++;
+ return wm_manipulator_select_set_ex(mmap, mpr, false, true, false);
+}
- *sel = MEM_reallocN(*sel, sizeof(wmManipulator *) * (*selected_len));
- (*sel)[(*selected_len) - 1] = mpr;
+bool WM_manipulator_select_set(wmManipulatorMap *mmap, wmManipulator *mpr, bool select)
+{
+ return wm_manipulator_select_set_ex(mmap, mpr, select, true, true);
+}
- mpr->state |= WM_MANIPULATOR_STATE_SELECT;
- if (mpr->type->select) {
- mpr->type->select(C, mpr, SEL_SELECT);
+bool wm_manipulator_select_and_highlight(bContext *C, wmManipulatorMap *mmap, wmManipulator *mpr)
+{
+ if (WM_manipulator_select_set(mmap, mpr, true)) {
+ wm_manipulatormap_highlight_set(mmap, C, mpr, mpr->highlight_part);
+ return true;
+ }
+ else {
+ return false;
}
- wm_manipulatormap_highlight_set(mmap, C, mpr, mpr->highlight_part);
-
- return true;
}
void wm_manipulator_calculate_scale(wmManipulator *mpr, const bContext *C)
@@ -464,15 +465,18 @@ void wm_manipulator_calculate_scale(wmManipulator *mpr, const bContext *C)
scale *= U.manipulator_size;
if (rv3d) {
/* 'ED_view3d_pixel_size' includes 'U.pixelsize', remove it. */
- if (mpr->type->matrix_world_get) {
- float matrix_world[4][4];
-
- mpr->type->matrix_world_get(mpr, matrix_world);
- scale *= ED_view3d_pixel_size(rv3d, matrix_world[3]) / U.pixelsize;
+ float matrix_world[4][4];
+ if (mpr->type->matrix_basis_get) {
+ float matrix_basis[4][4];
+ mpr->type->matrix_basis_get(mpr, matrix_basis);
+ mul_m4_m4m4(matrix_world, mpr->matrix_space, matrix_basis);
}
else {
- scale *= ED_view3d_pixel_size(rv3d, mpr->matrix_basis[3]) / U.pixelsize;
+ mul_m4_m4m4(matrix_world, mpr->matrix_space, mpr->matrix_basis);
}
+
+ /* Exclude matrix_offset from scale. */
+ scale *= ED_view3d_pixel_size(rv3d, matrix_world[3]) / U.pixelsize;
}
else {
scale *= 0.02f;
@@ -509,10 +513,10 @@ int wm_manipulator_is_visible(wmManipulator *mpr)
if (mpr->flag & WM_MANIPULATOR_HIDDEN) {
return 0;
}
- if ((mpr->state & WM_MANIPULATOR_STATE_ACTIVE) &&
- !(mpr->flag & (WM_MANIPULATOR_DRAW_ACTIVE | WM_MANIPULATOR_DRAW_VALUE)))
+ if ((mpr->state & WM_MANIPULATOR_STATE_MODAL) &&
+ !(mpr->flag & (WM_MANIPULATOR_DRAW_MODAL | WM_MANIPULATOR_DRAW_VALUE)))
{
- /* don't draw while active (while dragging) */
+ /* don't draw while modal (dragging) */
return 0;
}
if ((mpr->flag & WM_MANIPULATOR_DRAW_HOVER) &&
@@ -526,6 +530,53 @@ int wm_manipulator_is_visible(wmManipulator *mpr)
return WM_MANIPULATOR_IS_VISIBLE_UPDATE | WM_MANIPULATOR_IS_VISIBLE_DRAW;
}
+void WM_manipulator_calc_matrix_final_params(
+ const wmManipulator *mpr,
+ const struct WM_ManipulatorMatrixParams *params,
+ float r_mat[4][4])
+{
+ const float (* const matrix_space)[4] = params->matrix_space ? params->matrix_space : mpr->matrix_space;
+ const float (* const matrix_basis)[4] = params->matrix_basis ? params->matrix_basis : mpr->matrix_basis;
+ const float (* const matrix_offset)[4] = params->matrix_offset ? params->matrix_offset : mpr->matrix_offset;
+ const float *scale_final = params->scale_final ? params->scale_final : &mpr->scale_final;
+
+ float final_matrix[4][4];
+ if (params->matrix_basis == NULL && mpr->type->matrix_basis_get) {
+ mpr->type->matrix_basis_get(mpr, final_matrix);
+ }
+ else {
+ copy_m4_m4(final_matrix, matrix_basis);
+ }
+
+ if (mpr->flag & WM_MANIPULATOR_DRAW_NO_SCALE) {
+ mul_m4_m4m4(final_matrix, final_matrix, matrix_offset);
+ }
+ else {
+ if (mpr->flag & WM_MANIPULATOR_DRAW_OFFSET_SCALE) {
+ mul_mat3_m4_fl(final_matrix, *scale_final);
+ mul_m4_m4m4(final_matrix, final_matrix, matrix_offset);
+ }
+ else {
+ mul_m4_m4m4(final_matrix, final_matrix, matrix_offset);
+ mul_mat3_m4_fl(final_matrix, *scale_final);
+ }
+ }
+
+ mul_m4_m4m4(r_mat, matrix_space, final_matrix);
+}
+
+void WM_manipulator_calc_matrix_final(const wmManipulator *mpr, float r_mat[4][4])
+{
+ WM_manipulator_calc_matrix_final_params(
+ mpr,
+ &((struct WM_ManipulatorMatrixParams) {
+ .matrix_space = NULL,
+ .matrix_basis = NULL,
+ .matrix_offset = NULL,
+ .scale_final = NULL,
+ }), r_mat
+ );
+}
/** \name Manipulator Propery Access
*
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c
index f338a14dfbc..1675be861d6 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c
@@ -66,11 +66,6 @@
*
* \{ */
-/* wmManipulatorGroup.flag */
-enum {
- WM_MANIPULATORGROUP_INITIALIZED = (1 << 2), /* mgroup has been initialized */
-};
-
/**
* Create a new manipulator-group from \a wgt.
*/
@@ -91,11 +86,24 @@ wmManipulatorGroup *wm_manipulatorgroup_new_from_type(
void wm_manipulatorgroup_free(bContext *C, wmManipulatorGroup *mgroup)
{
wmManipulatorMap *mmap = mgroup->parent_mmap;
+
+ /* Similar to WM_manipulator_unlink, but only to keep mmap state correct,
+ * we don't want to run callbacks. */
+ if (mmap->mmap_context.highlight && mmap->mmap_context.highlight->parent_mgroup == mgroup) {
+ wm_manipulatormap_highlight_set(mmap, C, NULL, 0);
+ }
+ if (mmap->mmap_context.modal && mmap->mmap_context.modal->parent_mgroup == mgroup) {
+ wm_manipulatormap_modal_set(mmap, C, mmap->mmap_context.modal, NULL, false);
+ }
+
for (wmManipulator *mpr = mgroup->manipulators.first, *mpr_next; mpr; mpr = mpr_next) {
mpr_next = mpr->next;
- WM_manipulator_free(&mgroup->manipulators, mmap, mpr, C);
+ if (mmap->mmap_context.select.len) {
+ WM_manipulator_select_unlink(mmap, mpr);
+ }
+ WM_manipulator_free(mpr);
}
- BLI_assert(BLI_listbase_is_empty(&mgroup->manipulators));
+ BLI_listbase_clear(&mgroup->manipulators);
#ifdef WITH_PYTHON
if (mgroup->py_instance) {
@@ -127,7 +135,7 @@ void wm_manipulatorgroup_free(bContext *C, wmManipulatorGroup *mgroup)
*/
void wm_manipulatorgroup_manipulator_register(wmManipulatorGroup *mgroup, wmManipulator *mpr)
{
- BLI_assert(!BLI_findstring(&mgroup->manipulators, mpr->name, offsetof(wmManipulator, name)));
+ BLI_assert(BLI_findindex(&mgroup->manipulators, mpr) == -1);
BLI_addtail(&mgroup->manipulators, mpr);
mpr->parent_mgroup = mgroup;
}
@@ -138,7 +146,7 @@ wmManipulator *wm_manipulatorgroup_find_intersected_mainpulator(
{
for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) {
if (mpr->type->test_select && (mpr->flag & WM_MANIPULATOR_HIDDEN) == 0) {
- if ((*r_part = mpr->type->test_select(C, mpr, event))) {
+ if ((*r_part = mpr->type->test_select(C, mpr, event)) != -1) {
return mpr;
}
}
@@ -166,7 +174,7 @@ void wm_manipulatorgroup_intersectable_manipulators_to_list(const wmManipulatorG
void wm_manipulatorgroup_ensure_initialized(wmManipulatorGroup *mgroup, const bContext *C)
{
/* prepare for first draw */
- if (UNLIKELY((mgroup->flag & WM_MANIPULATORGROUP_INITIALIZED) == 0)) {
+ if (UNLIKELY((mgroup->init_flag & WM_MANIPULATORGROUP_INIT_SETUP) == 0)) {
mgroup->type->setup(C, mgroup);
/* Not ideal, initialize keymap here, needed for RNA runtime generated manipulators. */
@@ -177,7 +185,7 @@ void wm_manipulatorgroup_ensure_initialized(wmManipulatorGroup *mgroup, const bC
BLI_assert(wgt->keymap != NULL);
}
- mgroup->flag |= WM_MANIPULATORGROUP_INITIALIZED;
+ mgroup->init_flag |= WM_MANIPULATORGROUP_INIT_SETUP;
}
}
@@ -187,21 +195,34 @@ bool wm_manipulatorgroup_is_visible(const wmManipulatorGroup *mgroup, const bCon
return (!mgroup->type->poll || mgroup->type->poll(C, mgroup->type));
}
-bool wm_manipulatorgroup_is_visible_in_drawstep(const wmManipulatorGroup *mgroup, const int drawstep)
+bool wm_manipulatorgroup_is_visible_in_drawstep(
+ const wmManipulatorGroup *mgroup, const eWM_ManipulatorMapDrawStep drawstep)
{
switch (drawstep) {
case WM_MANIPULATORMAP_DRAWSTEP_2D:
return (mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) == 0;
case WM_MANIPULATORMAP_DRAWSTEP_3D:
return (mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D);
- case WM_MANIPULATORMAP_DRAWSTEP_IN_SCENE:
- return (mgroup->type->flag & WM_MANIPULATORGROUPTYPE_DEPTH_3D);
default:
BLI_assert(0);
return false;
}
}
+bool wm_manipulatorgroup_is_any_selected(const wmManipulatorGroup *mgroup)
+{
+ if (mgroup->type->flag & WM_MANIPULATORGROUPTYPE_SELECT) {
+ for (const wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) {
+ if (mpr->state & WM_MANIPULATOR_STATE_SELECT) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+/** \} */
+
/** \name Manipulator operators
*
* Basic operators for manipulator interaction with user configurable keymaps.
@@ -212,7 +233,7 @@ static int manipulator_select_invoke(bContext *C, wmOperator *op, const wmEvent
{
ARegion *ar = CTX_wm_region(C);
wmManipulatorMap *mmap = ar->manipulator_map;
- wmManipulator ***sel = &mmap->mmap_context.selected;
+ wmManipulatorMapSelectState *msel = &mmap->mmap_context.select;
wmManipulator *highlight = mmap->mmap_context.highlight;
bool extend = RNA_boolean_get(op->ptr, "extend");
@@ -221,8 +242,9 @@ static int manipulator_select_invoke(bContext *C, wmOperator *op, const wmEvent
/* deselect all first */
if (extend == false && deselect == false && toggle == false) {
- wm_manipulatormap_deselect_all(mmap, sel);
- BLI_assert(*sel == NULL && mmap->mmap_context.selected_len == 0);
+ wm_manipulatormap_deselect_all(mmap);
+ BLI_assert(msel->items == NULL && msel->len == 0);
+ UNUSED_VARS_NDEBUG(msel);
}
if (highlight) {
@@ -235,11 +257,11 @@ static int manipulator_select_invoke(bContext *C, wmOperator *op, const wmEvent
}
if (deselect) {
- if (is_selected && wm_manipulator_deselect(mmap, highlight)) {
+ if (is_selected && WM_manipulator_select_set(mmap, highlight, false)) {
redraw = true;
}
}
- else if (wm_manipulator_select(C, mmap, highlight)) {
+ else if (wm_manipulator_select_and_highlight(C, mmap, highlight)) {
redraw = true;
}
@@ -274,7 +296,7 @@ void MANIPULATORGROUP_OT_manipulator_select(wmOperatorType *ot)
typedef struct ManipulatorTweakData {
wmManipulatorMap *mmap;
- wmManipulator *active;
+ wmManipulator *mpr_modal;
int init_event; /* initial event type */
int flag; /* tweak flags */
@@ -283,17 +305,17 @@ typedef struct ManipulatorTweakData {
static void manipulator_tweak_finish(bContext *C, wmOperator *op, const bool cancel)
{
ManipulatorTweakData *mtweak = op->customdata;
- if (mtweak->active->type->exit) {
- mtweak->active->type->exit(C, mtweak->active, cancel);
+ if (mtweak->mpr_modal->type->exit) {
+ mtweak->mpr_modal->type->exit(C, mtweak->mpr_modal, cancel);
}
- wm_manipulatormap_active_set(mtweak->mmap, C, NULL, NULL);
+ wm_manipulatormap_modal_set(mtweak->mmap, C, mtweak->mpr_modal, NULL, false);
MEM_freeN(mtweak);
}
static int manipulator_tweak_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
ManipulatorTweakData *mtweak = op->customdata;
- wmManipulator *mpr = mtweak->active;
+ wmManipulator *mpr = mtweak->mpr_modal;
if (mpr == NULL) {
BLI_assert(0);
@@ -332,11 +354,12 @@ static int manipulator_tweak_modal(bContext *C, wmOperator *op, const wmEvent *e
}
/* handle manipulator */
- if (mpr->custom_modal) {
- mpr->custom_modal(C, mpr, event, mtweak->flag);
- }
- else if (mpr->type->modal) {
- mpr->type->modal(C, mpr, event, mtweak->flag);
+ wmManipulatorFnModal modal_fn = mpr->custom_modal ? mpr->custom_modal : mpr->type->modal;
+ int retval = modal_fn(C, mpr, event, mtweak->flag);
+
+ if ((retval & OPERATOR_RUNNING_MODAL) == 0) {
+ manipulator_tweak_finish(C, op, (retval & OPERATOR_CANCELLED) != 0);
+ return OPERATOR_FINISHED;
}
/* Ugly hack to send manipulator events */
@@ -361,21 +384,26 @@ static int manipulator_tweak_invoke(bContext *C, wmOperator *op, const wmEvent *
/* activate highlighted manipulator */
- wm_manipulatormap_active_set(mmap, C, event, mpr);
+ wm_manipulatormap_modal_set(mmap, C, mpr, event, true);
/* XXX temporary workaround for modal manipulator operator
* conflicting with modal operator attached to manipulator */
- if (mpr->op_data.type) {
- if (mpr->op_data.type->modal) {
+ wmManipulatorOpElem *mpop = WM_manipulator_operator_get(mpr, mpr->highlight_part);
+ if (mpop && mpop->type) {
+ if (mpop->type->modal) {
return OPERATOR_FINISHED;
}
}
+ /* Couldn't start the manipulator. */
+ if ((mpr->state & WM_MANIPULATOR_STATE_MODAL) == 0) {
+ return OPERATOR_PASS_THROUGH;
+ }
ManipulatorTweakData *mtweak = MEM_mallocN(sizeof(ManipulatorTweakData), __func__);
- mtweak->init_event = event->type;
- mtweak->active = mmap->mmap_context.highlight;
+ mtweak->init_event = WM_userdef_event_type_from_keymap_type(event->type);
+ mtweak->mpr_modal = mmap->mmap_context.highlight;
mtweak->mmap = mmap;
mtweak->flag = 0;
@@ -464,7 +492,7 @@ wmKeyMap *WM_manipulatorgroup_keymap_common(
/* Use area and region id since we might have multiple manipulators with the same name in different areas/regions */
wmKeyMap *km = WM_keymap_find(config, wgt->name, wgt->mmap_params.spaceid, wgt->mmap_params.regionid);
- WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_tweak", ACTIONMOUSE, KM_PRESS, KM_ANY, 0);
+ WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_tweak", LEFTMOUSE, KM_PRESS, KM_ANY, 0);
manipulatorgroup_tweak_modal_keymap(config, wgt->name);
return km;
@@ -480,6 +508,7 @@ wmKeyMap *WM_manipulatorgroup_keymap_common_select(
wmKeyMap *km = WM_keymap_find(config, wgt->name, wgt->mmap_params.spaceid, wgt->mmap_params.regionid);
WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_tweak", ACTIONMOUSE, KM_PRESS, KM_ANY, 0);
+ WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_tweak", EVT_TWEAK_S, KM_ANY, 0, 0);
manipulatorgroup_tweak_modal_keymap(config, wgt->name);
wmKeyMapItem *kmi = WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_select", SELECTMOUSE, KM_PRESS, 0, 0);
@@ -553,13 +582,18 @@ wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_link_ptr(
return wgt_ref;
}
-void WM_manipulatormaptype_group_init_runtime(
- const Main *bmain, wmManipulatorMapType *mmap_type,
+void WM_manipulatormaptype_group_init_runtime_keymap(
+ const Main *bmain,
wmManipulatorGroupType *wgt)
{
/* init keymap - on startup there's an extra call to init keymaps for 'permanent' manipulator-groups */
wm_manipulatorgrouptype_setup_keymap(wgt, ((wmWindowManager *)bmain->wm.first)->defaultconf);
+}
+void WM_manipulatormaptype_group_init_runtime(
+ const Main *bmain, wmManipulatorMapType *mmap_type,
+ wmManipulatorGroupType *wgt)
+{
/* now create a manipulator for all existing areas */
for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) {
for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
@@ -632,8 +666,13 @@ void WM_manipulatormaptype_group_unlink(
void wm_manipulatorgrouptype_setup_keymap(
wmManipulatorGroupType *wgt, wmKeyConfig *keyconf)
{
- wgt->keymap = wgt->setup_keymap(wgt, keyconf);
- wgt->keyconf = keyconf;
+ /* Use flag since setup_keymap may return NULL,
+ * in that case we better not keep calling it. */
+ if (wgt->type_update_flag & WM_MANIPULATORMAPTYPE_KEYMAP_INIT) {
+ wgt->keymap = wgt->setup_keymap(wgt, keyconf);
+ wgt->keyconf = keyconf;
+ wgt->type_update_flag &= ~WM_MANIPULATORMAPTYPE_KEYMAP_INIT;
+ }
}
/** \} */ /* wmManipulatorGroupType */
@@ -645,7 +684,7 @@ void wm_manipulatorgrouptype_setup_keymap(
*
* \note In context of manipulator API these names are a bit misleading,
* but for general use terms its OK.
- * `WM_manipulator_group_add` would be more correctly called:
+ * `WM_manipulator_group_type_add` would be more correctly called:
* `WM_manipulatormaptype_grouptype_reference_link`
* but for general purpose API this is too detailed & annoying.
*
@@ -653,7 +692,7 @@ void wm_manipulatorgrouptype_setup_keymap(
*
* \{ */
-void WM_manipulator_group_add_ptr_ex(
+void WM_manipulator_group_type_add_ptr_ex(
wmManipulatorGroupType *wgt,
wmManipulatorMapType *mmap_type)
{
@@ -662,62 +701,64 @@ void WM_manipulator_group_add_ptr_ex(
WM_manipulatorconfig_update_tag_init(mmap_type, wgt);
}
-void WM_manipulator_group_add_ptr(
+void WM_manipulator_group_type_add_ptr(
wmManipulatorGroupType *wgt)
{
wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params);
- WM_manipulator_group_add_ptr_ex(wgt, mmap_type);
+ WM_manipulator_group_type_add_ptr_ex(wgt, mmap_type);
}
-void WM_manipulator_group_add(const char *idname)
+void WM_manipulator_group_type_add(const char *idname)
{
wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false);
BLI_assert(wgt != NULL);
- WM_manipulator_group_add_ptr(wgt);
+ WM_manipulator_group_type_add_ptr(wgt);
}
-void WM_manipulator_group_remove_ptr_ex(
+
+void WM_manipulator_group_type_remove_ptr_ex(
struct Main *bmain, wmManipulatorGroupType *wgt,
wmManipulatorMapType *mmap_type)
{
WM_manipulatormaptype_group_unlink(NULL, bmain, mmap_type, wgt);
+ WM_manipulatorgrouptype_free_ptr(wgt);
}
-void WM_manipulator_group_remove_ptr(
+void WM_manipulator_group_type_remove_ptr(
struct Main *bmain, wmManipulatorGroupType *wgt)
{
wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params);
- WM_manipulator_group_remove_ptr_ex(bmain, wgt, mmap_type);
+ WM_manipulator_group_type_remove_ptr_ex(bmain, wgt, mmap_type);
}
-void WM_manipulator_group_remove(struct Main *bmain, const char *idname)
+void WM_manipulator_group_type_remove(struct Main *bmain, const char *idname)
{
wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false);
BLI_assert(wgt != NULL);
- WM_manipulator_group_remove_ptr(bmain, wgt);
+ WM_manipulator_group_type_remove_ptr(bmain, wgt);
}
/* delayed versions */
-void WM_manipulator_group_remove_ptr_delayed_ex(
+void WM_manipulator_group_type_remove_ptr_delayed_ex(
wmManipulatorGroupType *wgt,
wmManipulatorMapType *mmap_type)
{
WM_manipulatorconfig_update_tag_remove(mmap_type, wgt);
}
-void WM_manipulator_group_remove_ptr_delayed(
+void WM_manipulator_group_type_remove_ptr_delayed(
wmManipulatorGroupType *wgt)
{
wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params);
- WM_manipulator_group_remove_ptr_delayed_ex(wgt, mmap_type);
+ WM_manipulator_group_type_remove_ptr_delayed_ex(wgt, mmap_type);
}
-void WM_manipulator_group_remove_delayed(const char *idname)
+void WM_manipulator_group_type_remove_delayed(const char *idname)
{
wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false);
BLI_assert(wgt != NULL);
- WM_manipulator_group_remove_ptr_delayed(wgt);
+ WM_manipulator_group_type_remove_ptr_delayed(wgt);
}
/** \} */
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_group_type.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_group_type.c
index 0f21a7448b5..4c17ffda09c 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_group_type.c
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_group_type.c
@@ -90,9 +90,16 @@ static void wm_manipulatorgrouptype_append__end(wmManipulatorGroupType *wgt)
BLI_assert(wgt->name != NULL);
BLI_assert(wgt->idname != NULL);
+ wgt->type_update_flag |= WM_MANIPULATORMAPTYPE_KEYMAP_INIT;
+
/* if not set, use default */
if (wgt->setup_keymap == NULL) {
- wgt->setup_keymap = WM_manipulatorgroup_keymap_common;
+ if (wgt->flag & WM_MANIPULATORGROUPTYPE_SELECT) {
+ wgt->setup_keymap = WM_manipulatorgroup_keymap_common_select;
+ }
+ else {
+ wgt->setup_keymap = WM_manipulatorgroup_keymap_common;
+ }
}
BLI_ghash_insert(global_manipulatorgrouptype_hash, (void *)wgt->idname, wgt);
@@ -137,10 +144,14 @@ wmManipulatorGroupTypeRef *WM_manipulatorgrouptype_append_and_link(
*/
static void manipulatorgrouptype_free(wmManipulatorGroupType *wgt)
{
+ if (wgt->ext.srna) { /* python manipulator group, allocs own string */
+ MEM_freeN((void *)wgt->idname);
+ }
+
MEM_freeN(wgt);
}
-void WM_manipulatorgrouptype_remove_ptr(wmManipulatorGroupType *wgt)
+void WM_manipulatorgrouptype_free_ptr(wmManipulatorGroupType *wgt)
{
BLI_assert(wgt == WM_manipulatorgrouptype_find(wgt->idname, false));
@@ -151,7 +162,7 @@ void WM_manipulatorgrouptype_remove_ptr(wmManipulatorGroupType *wgt)
/* XXX, TODO, update the world! */
}
-bool WM_manipulatorgrouptype_remove(const char *idname)
+bool WM_manipulatorgrouptype_free(const char *idname)
{
wmManipulatorGroupType *wgt = BLI_ghash_lookup(global_manipulatorgrouptype_hash, idname);
@@ -159,7 +170,7 @@ bool WM_manipulatorgrouptype_remove(const char *idname)
return false;
}
- WM_manipulatorgrouptype_remove_ptr(wgt);
+ WM_manipulatorgrouptype_free_ptr(wgt);
return true;
}
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h b/source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h
index 6ddde1df9de..bf5c38b9e39 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h
@@ -38,8 +38,11 @@ struct GHashIterator;
/* -------------------------------------------------------------------- */
/* wmManipulator */
-bool wm_manipulator_deselect(struct wmManipulatorMap *mmap, struct wmManipulator *mpr);
-bool wm_manipulator_select(bContext *C, struct wmManipulatorMap *mmap, struct wmManipulator *mpr);
+
+bool wm_manipulator_select_set_ex(
+ struct wmManipulatorMap *mmap, struct wmManipulator *mpr, bool select,
+ bool use_array, bool use_callback);
+bool wm_manipulator_select_and_highlight(bContext *C, struct wmManipulatorMap *mmap, struct wmManipulator *mpr);
void wm_manipulator_calculate_scale(struct wmManipulator *mpr, const bContext *C);
void wm_manipulator_update(struct wmManipulator *mpr, const bContext *C, const bool refresh_map);
@@ -73,7 +76,8 @@ void wm_manipulatorgroup_intersectable_manipulators_to_list(
const struct wmManipulatorGroup *mgroup, struct ListBase *listbase);
void wm_manipulatorgroup_ensure_initialized(struct wmManipulatorGroup *mgroup, const struct bContext *C);
bool wm_manipulatorgroup_is_visible(const struct wmManipulatorGroup *mgroup, const struct bContext *C);
-bool wm_manipulatorgroup_is_visible_in_drawstep(const struct wmManipulatorGroup *mgroup, const int drawstep);
+bool wm_manipulatorgroup_is_visible_in_drawstep(
+ const struct wmManipulatorGroup *mgroup, const eWM_ManipulatorMapDrawStep drawstep);
void wm_manipulatorgrouptype_setup_keymap(
struct wmManipulatorGroupType *wgt, struct wmKeyConfig *keyconf);
@@ -82,13 +86,18 @@ void wm_manipulatorgrouptype_setup_keymap(
/* -------------------------------------------------------------------- */
/* wmManipulatorMap */
+typedef struct wmManipulatorMapSelectState {
+ struct wmManipulator **items;
+ int len, len_alloc;
+} wmManipulatorMapSelectState;
+
struct wmManipulatorMap {
- struct wmManipulatorMap *next, *prev;
struct wmManipulatorMapType *type;
ListBase groups; /* wmManipulatorGroup */
- char update_flag; /* private, update tagging */
+ /* private, update tagging (enum defined in C source). */
+ char update_flag[WM_MANIPULATORMAP_DRAWSTEP_MAX];
/**
* \brief Manipulator map runtime context
@@ -99,12 +108,10 @@ struct wmManipulatorMap {
struct {
/* we redraw the manipulator-map when this changes */
struct wmManipulator *highlight;
- /* user has clicked this manipulator and it gets all input */
- struct wmManipulator *active;
- /* array for all selected manipulators
- * TODO check on using BLI_array */
- struct wmManipulator **selected;
- int selected_len;
+ /* User has clicked this manipulator and it gets all input. */
+ struct wmManipulator *modal;
+ /* array for all selected manipulators */
+ struct wmManipulatorMapSelectState select;
} mmap_context;
};
@@ -121,10 +128,13 @@ struct wmManipulatorMapType {
ListBase grouptype_refs;
/* eManipulatorMapTypeUpdateFlags */
- uchar type_update_flag;
+ eWM_ManipulatorMapTypeUpdateFlag type_update_flag;
};
-void wm_manipulatormap_selected_clear(struct wmManipulatorMap *mmap);
-bool wm_manipulatormap_deselect_all(struct wmManipulatorMap *mmap, struct wmManipulator ***sel);
+void wm_manipulatormap_select_array_clear(struct wmManipulatorMap *mmap);
+bool wm_manipulatormap_deselect_all(struct wmManipulatorMap *mmap);
+void wm_manipulatormap_select_array_shrink(struct wmManipulatorMap *mmap, int len_subtract);
+void wm_manipulatormap_select_array_push_back(struct wmManipulatorMap *mmap, wmManipulator *mpr);
+void wm_manipulatormap_select_array_remove(struct wmManipulatorMap *mmap, wmManipulator *mpr);
-#endif \ No newline at end of file
+#endif
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c
index f5ef5572fd4..0d2a8f7dcc5 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c
@@ -50,6 +50,8 @@
#include "WM_types.h"
#include "wm_event_system.h"
+#include "DEG_depsgraph.h"
+
/* own includes */
#include "wm_manipulator_wmapi.h"
#include "wm_manipulator_intern.h"
@@ -64,23 +66,94 @@ static ListBase manipulatormaptypes = {NULL, NULL};
* Update when manipulator-map types change.
*/
/* so operator removal can trigger update */
-enum {
+typedef enum eWM_ManipulatorGroupTypeGlobalFlag {
WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_INIT = (1 << 0),
WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_REMOVE = (1 << 1),
-};
+} eWM_ManipulatorGroupTypeGlobalFlag;
-static char wm_mmap_type_update_flag = 0;
+static eWM_ManipulatorGroupTypeGlobalFlag wm_mmap_type_update_flag = 0;
/**
* Manipulator-map update tagging.
*/
-enum eManipulatorMapUpdateFlags {
- /* Tag manipulator-map for refresh. */
- MANIPULATORMAP_REFRESH = (1 << 0),
+enum {
+ /** #manipulatormap_prepare_drawing has run */
+ MANIPULATORMAP_IS_PREPARE_DRAW = (1 << 0),
+ MANIPULATORMAP_IS_REFRESH_CALLBACK = (1 << 1),
};
/* -------------------------------------------------------------------- */
+/** \name wmManipulatorMap Selection Array API
+ *
+ * Just handle ``wm_manipulatormap_select_array_*``, not flags or callbacks.
+ *
+ * \{ */
+
+static void wm_manipulatormap_select_array_ensure_len_alloc(wmManipulatorMap *mmap, int len)
+{
+ wmManipulatorMapSelectState *msel = &mmap->mmap_context.select;
+ if (len <= msel->len_alloc) {
+ return;
+ }
+ msel->items = MEM_reallocN(msel->items, sizeof(*msel->items) * len);
+ msel->len_alloc = len;
+}
+
+void wm_manipulatormap_select_array_clear(wmManipulatorMap *mmap)
+{
+ wmManipulatorMapSelectState *msel = &mmap->mmap_context.select;
+ MEM_SAFE_FREE(msel->items);
+ msel->len = 0;
+ msel->len_alloc = 0;
+}
+
+void wm_manipulatormap_select_array_shrink(wmManipulatorMap *mmap, int len_subtract)
+{
+ wmManipulatorMapSelectState *msel = &mmap->mmap_context.select;
+ msel->len -= len_subtract;
+ if (msel->len <= 0) {
+ wm_manipulatormap_select_array_clear(mmap);
+ }
+ else {
+ if (msel->len < msel->len_alloc / 2) {
+ msel->items = MEM_reallocN(msel->items, sizeof(*msel->items) * msel->len);
+ msel->len_alloc = msel->len;
+ }
+ }
+}
+
+void wm_manipulatormap_select_array_push_back(wmManipulatorMap *mmap, wmManipulator *mpr)
+{
+ wmManipulatorMapSelectState *msel = &mmap->mmap_context.select;
+ BLI_assert(msel->len <= msel->len_alloc);
+ if (msel->len == msel->len_alloc) {
+ msel->len_alloc = (msel->len + 1) * 2;
+ msel->items = MEM_reallocN(msel->items, sizeof(*msel->items) * msel->len_alloc);
+ }
+ msel->items[msel->len++] = mpr;
+}
+
+void wm_manipulatormap_select_array_remove(wmManipulatorMap *mmap, wmManipulator *mpr)
+{
+ wmManipulatorMapSelectState *msel = &mmap->mmap_context.select;
+ /* remove manipulator from selected_manipulators array */
+ for (int i = 0; i < msel->len; i++) {
+ if (msel->items[i] == mpr) {
+ for (int j = i; j < (msel->len - 1); j++) {
+ msel->items[j] = msel->items[j + 1];
+ }
+ wm_manipulatormap_select_array_shrink(mmap, 1);
+ break;
+ }
+ }
+
+}
+
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
/** \name wmManipulatorMap
*
* \{ */
@@ -96,7 +169,7 @@ wmManipulatorMap *WM_manipulatormap_new_from_type(
mmap = MEM_callocN(sizeof(wmManipulatorMap), "ManipulatorMap");
mmap->type = mmap_type;
- mmap->update_flag = MANIPULATORMAP_REFRESH;
+ WM_manipulatormap_tag_refresh(mmap);
/* create all manipulator-groups for this manipulator-map. We may create an empty one
* too in anticipation of manipulators from operators etc */
@@ -107,16 +180,10 @@ wmManipulatorMap *WM_manipulatormap_new_from_type(
return mmap;
}
-void wm_manipulatormap_selected_clear(wmManipulatorMap *mmap)
-{
- MEM_SAFE_FREE(mmap->mmap_context.selected);
- mmap->mmap_context.selected_len = 0;
-}
-
void wm_manipulatormap_remove(wmManipulatorMap *mmap)
{
- if (!mmap)
- return;
+ /* Clear first so further calls don't waste time trying to maintain correct array state. */
+ wm_manipulatormap_select_array_clear(mmap);
for (wmManipulatorGroup *mgroup = mmap->groups.first, *mgroup_next; mgroup; mgroup = mgroup_next) {
mgroup_next = mgroup->next;
@@ -125,8 +192,6 @@ void wm_manipulatormap_remove(wmManipulatorMap *mmap)
}
BLI_assert(BLI_listbase_is_empty(&mmap->groups));
- wm_manipulatormap_selected_clear(mmap);
-
MEM_freeN(mmap);
}
@@ -135,18 +200,47 @@ const ListBase *WM_manipulatormap_group_list(wmManipulatorMap *mmap)
return &mmap->groups;
}
+bool WM_manipulatormap_is_any_selected(const wmManipulatorMap *mmap)
+{
+ return mmap->mmap_context.select.len != 0;
+}
+
+/**
+ * \note We could use a callback to define bounds, for now just use matrix location.
+ */
+bool WM_manipulatormap_minmax(
+ const wmManipulatorMap *mmap, bool UNUSED(use_hidden), bool use_select,
+ float r_min[3], float r_max[3])
+{
+ if (use_select) {
+ int i;
+ for (i = 0; i < mmap->mmap_context.select.len; i++) {
+ minmax_v3v3_v3(r_min, r_max, mmap->mmap_context.select.items[i]->matrix_basis[3]);
+ }
+ return i != 0;
+ }
+ else {
+ bool ok = false;
+ BLI_assert(!"TODO");
+ return ok;
+ }
+}
+
/**
* Creates and returns idname hash table for (visible) manipulators in \a mmap
*
* \param poll Polling function for excluding manipulators.
* \param data Custom data passed to \a poll
+ *
+ * TODO(campbell): this uses unreliable order,
+ * best we use an iterator function instead of a hash.
*/
static GHash *WM_manipulatormap_manipulator_hash_new(
const bContext *C, wmManipulatorMap *mmap,
bool (*poll)(const wmManipulator *, void *),
void *data, const bool include_hidden)
{
- GHash *hash = BLI_ghash_str_new(__func__);
+ GHash *hash = BLI_ghash_ptr_new(__func__);
/* collect manipulators */
for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) {
@@ -155,7 +249,7 @@ static GHash *WM_manipulatormap_manipulator_hash_new(
if ((include_hidden || (mpr->flag & WM_MANIPULATOR_HIDDEN) == 0) &&
(!poll || poll(mpr, data)))
{
- BLI_ghash_insert(hash, mpr->name, mpr);
+ BLI_ghash_insert(hash, mpr, mpr);
}
}
}
@@ -167,18 +261,19 @@ static GHash *WM_manipulatormap_manipulator_hash_new(
void WM_manipulatormap_tag_refresh(wmManipulatorMap *mmap)
{
if (mmap) {
- mmap->update_flag |= MANIPULATORMAP_REFRESH;
+ /* We might want only to refresh some, for tag all steps. */
+ for (int i = 0; i < WM_MANIPULATORMAP_DRAWSTEP_MAX; i++) {
+ mmap->update_flag[i] |= (
+ MANIPULATORMAP_IS_PREPARE_DRAW |
+ MANIPULATORMAP_IS_REFRESH_CALLBACK);
+ }
}
}
-static void manipulatormap_tag_updated(wmManipulatorMap *mmap)
-{
- mmap->update_flag = 0;
-}
-
static bool manipulator_prepare_drawing(
wmManipulatorMap *mmap, wmManipulator *mpr,
- const bContext *C, ListBase *draw_manipulators)
+ const bContext *C, ListBase *draw_manipulators,
+ const eWM_ManipulatorMapDrawStep drawstep)
{
int do_draw = wm_manipulator_is_visible(mpr);
if (do_draw == 0) {
@@ -187,7 +282,7 @@ static bool manipulator_prepare_drawing(
else {
if (do_draw & WM_MANIPULATOR_IS_VISIBLE_UPDATE) {
/* hover manipulators need updating, even if we don't draw them */
- wm_manipulator_update(mpr, C, (mmap->update_flag & MANIPULATORMAP_REFRESH) != 0);
+ wm_manipulator_update(mpr, C, (mmap->update_flag[drawstep] & MANIPULATORMAP_IS_PREPARE_DRAW) != 0);
}
if (do_draw & WM_MANIPULATOR_IS_VISIBLE_DRAW) {
BLI_addhead(draw_manipulators, BLI_genericNodeN(mpr));
@@ -203,19 +298,24 @@ static bool manipulator_prepare_drawing(
* should be drawn to list \a draw_manipulators, note that added items need freeing.
*/
static void manipulatormap_prepare_drawing(
- wmManipulatorMap *mmap, const bContext *C, ListBase *draw_manipulators, const int drawstep)
+ wmManipulatorMap *mmap, const bContext *C, ListBase *draw_manipulators,
+ const eWM_ManipulatorMapDrawStep drawstep)
{
if (!mmap || BLI_listbase_is_empty(&mmap->groups))
return;
- wmManipulator *active_manipulator = mmap->mmap_context.active;
+ wmManipulator *mpr_modal = mmap->mmap_context.modal;
/* only active manipulator needs updating */
- if (active_manipulator) {
- if (manipulator_prepare_drawing(mmap, active_manipulator, C, draw_manipulators)) {
- manipulatormap_tag_updated(mmap);
+ if (mpr_modal) {
+ if ((mpr_modal->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_DRAW_MODAL_ALL) == 0) {
+ if (wm_manipulatorgroup_is_visible_in_drawstep(mpr_modal->parent_mgroup, drawstep)) {
+ if (manipulator_prepare_drawing(mmap, mpr_modal, C, draw_manipulators, drawstep)) {
+ mmap->update_flag[drawstep] &= ~MANIPULATORMAP_IS_PREPARE_DRAW;
+ }
+ }
+ /* don't draw any other manipulators */
+ return;
}
- /* don't draw any other manipulators */
- return;
}
for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) {
@@ -230,8 +330,9 @@ static void manipulatormap_prepare_drawing(
wm_manipulatorgroup_ensure_initialized(mgroup, C);
/* update data if needed */
/* XXX weak: Manipulator-group may skip refreshing if it's invisible (map gets untagged nevertheless) */
- if (mmap->update_flag & MANIPULATORMAP_REFRESH && mgroup->type->refresh) {
+ if ((mmap->update_flag[drawstep] & MANIPULATORMAP_IS_REFRESH_CALLBACK) && mgroup->type->refresh) {
mgroup->type->refresh(C, mgroup);
+ /* cleared below */
}
/* prepare drawing */
if (mgroup->type->draw_prepare) {
@@ -239,11 +340,13 @@ static void manipulatormap_prepare_drawing(
}
for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) {
- manipulator_prepare_drawing(mmap, mpr, C, draw_manipulators);
+ manipulator_prepare_drawing(mmap, mpr, C, draw_manipulators, drawstep);
}
}
- manipulatormap_tag_updated(mmap);
+ mmap->update_flag[drawstep] &=
+ ~(MANIPULATORMAP_IS_REFRESH_CALLBACK |
+ MANIPULATORMAP_IS_PREPARE_DRAW);
}
/**
@@ -308,7 +411,9 @@ static void manipulators_draw_list(const wmManipulatorMap *mmap, const bContext
}
}
-void WM_manipulatormap_draw(wmManipulatorMap *mmap, const bContext *C, const int drawstep)
+void WM_manipulatormap_draw(
+ wmManipulatorMap *mmap, const bContext *C,
+ const eWM_ManipulatorMapDrawStep drawstep)
{
ListBase draw_manipulators = {NULL};
@@ -317,9 +422,9 @@ void WM_manipulatormap_draw(wmManipulatorMap *mmap, const bContext *C, const int
BLI_assert(BLI_listbase_is_empty(&draw_manipulators));
}
-static void manipulator_find_active_3D_loop(const bContext *C, ListBase *visible_manipulators)
+static void manipulator_draw_select_3D_loop(const bContext *C, ListBase *visible_manipulators)
{
- int selectionbase = 0;
+ int select_id = 0;
wmManipulator *mpr;
/* TODO(campbell): this depends on depth buffer being written to, currently broken for the 3D view. */
@@ -327,7 +432,7 @@ static void manipulator_find_active_3D_loop(const bContext *C, ListBase *visible
for (LinkData *link = visible_manipulators->first; link; link = link->next) {
mpr = link->data;
-
+
bool is_depth = (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_DEPTH_3D) != 0;
if (is_depth == is_depth_prev) {
/* pass */
@@ -344,10 +449,10 @@ static void manipulator_find_active_3D_loop(const bContext *C, ListBase *visible
/* pass the selection id shifted by 8 bits. Last 8 bits are used for selected manipulator part id */
- mpr->type->draw_select(C, mpr, selectionbase << 8);
+ mpr->type->draw_select(C, mpr, select_id << 8);
- selectionbase++;
+ select_id++;
}
if (is_depth_prev) {
@@ -357,8 +462,9 @@ static void manipulator_find_active_3D_loop(const bContext *C, ListBase *visible
static int manipulator_find_intersected_3d_intern(
ListBase *visible_manipulators, const bContext *C, const int co[2],
- const float hotspot)
+ const int hotspot)
{
+ EvaluationContext eval_ctx;
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
View3D *v3d = sa->spacedata.first;
@@ -368,31 +474,32 @@ static int manipulator_find_intersected_3d_intern(
short hits;
const bool do_passes = GPU_select_query_check_active();
- rect.xmin = co[0] - hotspot;
- rect.xmax = co[0] + hotspot;
- rect.ymin = co[1] - hotspot;
- rect.ymax = co[1] + hotspot;
+ BLI_rcti_init_pt_radius(&rect, co, hotspot);
+
+ CTX_data_eval_ctx(C, &eval_ctx);
- ED_view3d_draw_setup_view(CTX_wm_window(C), CTX_data_scene(C), ar, v3d, NULL, NULL, &rect);
+ ED_view3d_draw_setup_view(CTX_wm_window(C), &eval_ctx, CTX_data_scene(C), ar, v3d, NULL, NULL, &rect);
if (do_passes)
GPU_select_begin(buffer, ARRAY_SIZE(buffer), &rect, GPU_SELECT_NEAREST_FIRST_PASS, 0);
else
GPU_select_begin(buffer, ARRAY_SIZE(buffer), &rect, GPU_SELECT_ALL, 0);
/* do the drawing */
- manipulator_find_active_3D_loop(C, visible_manipulators);
+ manipulator_draw_select_3D_loop(C, visible_manipulators);
hits = GPU_select_end();
if (do_passes && (hits > 0)) {
GPU_select_begin(buffer, ARRAY_SIZE(buffer), &rect, GPU_SELECT_NEAREST_SECOND_PASS, hits);
- manipulator_find_active_3D_loop(C, visible_manipulators);
+ manipulator_draw_select_3D_loop(C, visible_manipulators);
GPU_select_end();
}
- ED_view3d_draw_setup_view(CTX_wm_window(C), CTX_data_scene(C), ar, v3d, NULL, NULL, NULL);
+ ED_view3d_draw_setup_view(CTX_wm_window(C), &eval_ctx, CTX_data_scene(C), ar, v3d, NULL, NULL, NULL);
+
+ const GLuint *hit_near = GPU_select_buffer_near(buffer, hits);
- return hits > 0 ? buffer[3] : -1;
+ return hit_near ? hit_near[3] : -1;
}
/**
@@ -403,26 +510,39 @@ static wmManipulator *manipulator_find_intersected_3d(
int *r_part)
{
wmManipulator *result = NULL;
- const float hotspot = 14.0f;
- int ret;
+ int hit = -1;
+
+ int hotspot_radii[] = {
+ 3 * U.pixelsize,
+#if 0 /* We may want to enable when selection doesn't run on mousemove! */
+ 7 * U.pixelsize,
+#endif
+ };
*r_part = 0;
/* set up view matrices */
view3d_operator_needs_opengl(C);
- ret = manipulator_find_intersected_3d_intern(visible_manipulators, C, co, 0.5f * hotspot);
-
- if (ret != -1) {
- LinkData *link;
- int retsec;
- retsec = manipulator_find_intersected_3d_intern(visible_manipulators, C, co, 0.2f * hotspot);
+ hit = -1;
- if (retsec != -1)
- ret = retsec;
+ for (int i = 0; i < ARRAY_SIZE(hotspot_radii); i++) {
+ hit = manipulator_find_intersected_3d_intern(visible_manipulators, C, co, hotspot_radii[i]);
+ if (hit != -1) {
+ break;
+ }
+ }
- link = BLI_findlink(visible_manipulators, ret >> 8);
- *r_part = ret & 255;
- result = link->data;
+ if (hit != -1) {
+ LinkData *link = BLI_findlink(visible_manipulators, hit >> 8);
+ if (link != NULL) {
+ *r_part = hit & 255;
+ result = link->data;
+ }
+ else {
+ /* All manipulators should use selection ID they're given as part of the callback,
+ * if they don't it will attempt tp lookup non-existing index. */
+ BLI_assert(0);
+ }
}
return result;
@@ -440,27 +560,64 @@ wmManipulator *wm_manipulatormap_highlight_find(
ListBase visible_3d_manipulators = {NULL};
for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) {
+
+ /* If it were important we could initialize here,
+ * but this only happens when events are handled before drawing,
+ * just skip to keep code-path for initializing manipulators simple. */
+ if ((mgroup->init_flag & WM_MANIPULATORGROUP_INIT_SETUP) == 0) {
+ continue;
+ }
+
if (wm_manipulatorgroup_is_visible(mgroup, C)) {
if (mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) {
+ if ((mmap->update_flag[WM_MANIPULATORMAP_DRAWSTEP_3D] & MANIPULATORMAP_IS_REFRESH_CALLBACK) &&
+ mgroup->type->refresh)
+ {
+ mgroup->type->refresh(C, mgroup);
+ /* cleared below */
+ }
wm_manipulatorgroup_intersectable_manipulators_to_list(mgroup, &visible_3d_manipulators);
}
- else if ((mpr = wm_manipulatorgroup_find_intersected_mainpulator(mgroup, C, event, r_part))) {
- break;
+ else {
+ if ((mmap->update_flag[WM_MANIPULATORMAP_DRAWSTEP_2D] & MANIPULATORMAP_IS_REFRESH_CALLBACK) &&
+ mgroup->type->refresh)
+ {
+ mgroup->type->refresh(C, mgroup);
+ /* cleared below */
+ }
+
+ if ((mpr = wm_manipulatorgroup_find_intersected_mainpulator(mgroup, C, event, r_part))) {
+ break;
+ }
}
}
}
if (!BLI_listbase_is_empty(&visible_3d_manipulators)) {
- mpr = manipulator_find_intersected_3d(C, event->mval, &visible_3d_manipulators, r_part);
+ /* 2D manipulators get priority. */
+ if (mpr == NULL) {
+ mpr = manipulator_find_intersected_3d(C, event->mval, &visible_3d_manipulators, r_part);
+ }
BLI_freelistN(&visible_3d_manipulators);
}
+ mmap->update_flag[WM_MANIPULATORMAP_DRAWSTEP_3D] &= ~MANIPULATORMAP_IS_REFRESH_CALLBACK;
+ mmap->update_flag[WM_MANIPULATORMAP_DRAWSTEP_2D] &= ~MANIPULATORMAP_IS_REFRESH_CALLBACK;
+
return mpr;
}
void WM_manipulatormap_add_handlers(ARegion *ar, wmManipulatorMap *mmap)
{
- wmEventHandler *handler = MEM_callocN(sizeof(wmEventHandler), "manipulator handler");
+ wmEventHandler *handler;
+
+ for (handler = ar->handlers.first; handler; handler = handler->next) {
+ if (handler->manipulator_map == mmap) {
+ return;
+ }
+ }
+
+ handler = MEM_callocN(sizeof(wmEventHandler), "manipulator handler");
BLI_assert(mmap == ar->manipulator_map);
handler->manipulator_map = mmap;
@@ -478,7 +635,7 @@ void wm_manipulatormaps_handled_modal_update(
}
wmManipulatorMap *mmap = handler->op_region->manipulator_map;
- wmManipulator *mpr = wm_manipulatormap_active_get(mmap);
+ wmManipulator *mpr = wm_manipulatormap_modal_get(mmap);
ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
@@ -486,21 +643,28 @@ void wm_manipulatormaps_handled_modal_update(
/* regular update for running operator */
if (modal_running) {
- if (mpr && (mpr->op_data.type != NULL) &&
- (mpr->op_data.type == handler->op->type))
- {
- if (mpr->custom_modal) {
- mpr->custom_modal(C, mpr, event, 0);
- }
- else if (mpr->type->modal) {
- mpr->type->modal(C, mpr, event, 0);
+ wmManipulatorOpElem *mpop = mpr ? WM_manipulator_operator_get(mpr, mpr->highlight_part) : NULL;
+ if (mpr && mpop && (mpop->type != NULL) && (mpop->type == handler->op->type)) {
+ wmManipulatorFnModal modal_fn = mpr->custom_modal ? mpr->custom_modal : mpr->type->modal;
+ if (modal_fn != NULL) {
+ int retval = modal_fn(C, mpr, event, 0);
+ /* The manipulator is tried to the operator, we can't choose when to exit. */
+ BLI_assert(retval & OPERATOR_RUNNING_MODAL);
+ UNUSED_VARS_NDEBUG(retval);
}
}
}
/* operator not running anymore */
else {
wm_manipulatormap_highlight_set(mmap, C, NULL, 0);
- wm_manipulatormap_active_set(mmap, C, event, NULL);
+ if (mpr) {
+ /* This isn't defined if it ends because of success of cancel, we may want to change. */
+ bool cancel = true;
+ if (mpr->type->exit) {
+ mpr->type->exit(C, mpr, cancel);
+ }
+ wm_manipulatormap_modal_set(mmap, C, mpr, NULL, false);
+ }
}
/* restore the area */
@@ -512,16 +676,19 @@ void wm_manipulatormaps_handled_modal_update(
* Deselect all selected manipulators in \a mmap.
* \return if selection has changed.
*/
-bool wm_manipulatormap_deselect_all(wmManipulatorMap *mmap, wmManipulator ***sel)
+bool wm_manipulatormap_deselect_all(wmManipulatorMap *mmap)
{
- if (*sel == NULL || mmap->mmap_context.selected_len == 0)
+ wmManipulatorMapSelectState *msel = &mmap->mmap_context.select;
+
+ if (msel->items == NULL || msel->len == 0) {
return false;
+ }
- for (int i = 0; i < mmap->mmap_context.selected_len; i++) {
- (*sel)[i]->state &= ~WM_MANIPULATOR_STATE_SELECT;
- (*sel)[i] = NULL;
+ for (int i = 0; i < msel->len; i++) {
+ wm_manipulator_select_set_ex(mmap, msel->items[i], false, false, true);
}
- wm_manipulatormap_selected_clear(mmap);
+
+ wm_manipulatormap_select_array_clear(mmap);
/* always return true, we already checked
* if there's anything to deselect */
@@ -538,36 +705,28 @@ BLI_INLINE bool manipulator_selectable_poll(const wmManipulator *mpr, void *UNUS
* \return if selection has changed.
*/
static bool wm_manipulatormap_select_all_intern(
- bContext *C, wmManipulatorMap *mmap, wmManipulator ***sel,
- const int action)
+ bContext *C, wmManipulatorMap *mmap)
{
+ wmManipulatorMapSelectState *msel = &mmap->mmap_context.select;
/* GHash is used here to avoid having to loop over all manipulators twice (once to
* get tot_sel for allocating, once for actually selecting). Instead we collect
* selectable manipulators in hash table and use this to get tot_sel and do selection */
GHash *hash = WM_manipulatormap_manipulator_hash_new(C, mmap, manipulator_selectable_poll, NULL, true);
GHashIterator gh_iter;
- int i, *selected_len = &mmap->mmap_context.selected_len;
+ int i;
bool changed = false;
- *selected_len = BLI_ghash_size(hash);
- *sel = MEM_reallocN(*sel, sizeof(**sel) * (*selected_len));
+ wm_manipulatormap_select_array_ensure_len_alloc(mmap, BLI_ghash_size(hash));
GHASH_ITER_INDEX (gh_iter, hash, i) {
wmManipulator *mpr_iter = BLI_ghashIterator_getValue(&gh_iter);
-
- if ((mpr_iter->state & WM_MANIPULATOR_STATE_SELECT) == 0) {
- changed = true;
- }
- mpr_iter->state |= WM_MANIPULATOR_STATE_SELECT;
- if (mpr_iter->type->select) {
- mpr_iter->type->select(C, mpr_iter, action);
- }
- (*sel)[i] = mpr_iter;
- BLI_assert(i < (*selected_len));
+ WM_manipulator_select_set(mmap, mpr_iter, true);
}
/* highlight first manipulator */
- wm_manipulatormap_highlight_set(mmap, C, (*sel)[0], (*sel)[0]->highlight_part);
+ wm_manipulatormap_highlight_set(mmap, C, msel->items[0], msel->items[0]->highlight_part);
+
+ BLI_assert(BLI_ghash_size(hash) == msel->len);
BLI_ghash_free(hash, NULL, NULL);
return changed;
@@ -581,15 +740,14 @@ static bool wm_manipulatormap_select_all_intern(
*/
bool WM_manipulatormap_select_all(bContext *C, wmManipulatorMap *mmap, const int action)
{
- wmManipulator ***sel = &mmap->mmap_context.selected;
bool changed = false;
switch (action) {
case SEL_SELECT:
- changed = wm_manipulatormap_select_all_intern(C, mmap, sel, action);
+ changed = wm_manipulatormap_select_all_intern(C, mmap);
break;
case SEL_DESELECT:
- changed = wm_manipulatormap_deselect_all(mmap, sel);
+ changed = wm_manipulatormap_deselect_all(mmap);
break;
default:
BLI_assert(0);
@@ -642,12 +800,10 @@ void wm_manipulatormap_handler_context(bContext *C, wmEventHandler *handler)
bool WM_manipulatormap_cursor_set(const wmManipulatorMap *mmap, wmWindow *win)
{
- for (; mmap; mmap = mmap->next) {
- wmManipulator *mpr = mmap->mmap_context.highlight;
- if (mpr && mpr->type->cursor_get) {
- WM_cursor_set(win, mpr->type->cursor_get(mpr));
- return true;
- }
+ wmManipulator *mpr = mmap->mmap_context.highlight;
+ if (mpr && mpr->type->cursor_get) {
+ WM_cursor_set(win, mpr->type->cursor_get(mpr));
+ return true;
}
return false;
@@ -661,7 +817,7 @@ void wm_manipulatormap_highlight_set(
{
if (mmap->mmap_context.highlight) {
mmap->mmap_context.highlight->state &= ~WM_MANIPULATOR_STATE_HIGHLIGHT;
- mmap->mmap_context.highlight->highlight_part = 0;
+ mmap->mmap_context.highlight->highlight_part = -1;
}
mmap->mmap_context.highlight = mpr;
@@ -695,50 +851,57 @@ wmManipulator *wm_manipulatormap_highlight_get(wmManipulatorMap *mmap)
return mmap->mmap_context.highlight;
}
-void wm_manipulatormap_active_set(
- wmManipulatorMap *mmap, bContext *C, const wmEvent *event, wmManipulator *mpr)
+/**
+ * Caller should call exit when (enable == False).
+ */
+void wm_manipulatormap_modal_set(
+ wmManipulatorMap *mmap, bContext *C, wmManipulator *mpr, const wmEvent *event, bool enable)
{
- if (mpr && C) {
- mpr->state |= WM_MANIPULATOR_STATE_ACTIVE;
- mmap->mmap_context.active = mpr;
+ if (enable) {
+ BLI_assert(mmap->mmap_context.modal == NULL);
- if (mpr->op_data.type) {
- /* first activate the manipulator itself */
- if (mpr->type->invoke &&
- (mpr->type->modal || mpr->custom_modal))
- {
- mpr->type->invoke(C, mpr, event);
- }
+ /* For now only grab cursor for 3D manipulators. */
+ bool grab_cursor = (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) != 0;
+ int retval = OPERATOR_RUNNING_MODAL;
+
+ if (mpr->type->invoke &&
+ (mpr->type->modal || mpr->custom_modal))
+ {
+ retval = mpr->type->invoke(C, mpr, event);
+ }
+
+ if ((retval & OPERATOR_RUNNING_MODAL) == 0) {
+ return;
+ }
+
+ mpr->state |= WM_MANIPULATOR_STATE_MODAL;
+ mmap->mmap_context.modal = mpr;
- WM_operator_name_call_ptr(C, mpr->op_data.type, WM_OP_INVOKE_DEFAULT, &mpr->op_data.ptr);
+ struct wmManipulatorOpElem *mpop = WM_manipulator_operator_get(mpr, mpr->highlight_part);
+ if (mpop && mpop->type) {
+ WM_operator_name_call_ptr(C, mpop->type, WM_OP_INVOKE_DEFAULT, &mpop->ptr);
/* we failed to hook the manipulator to the operator handler or operator was cancelled, return */
- if (!mmap->mmap_context.active) {
- mpr->state &= ~WM_MANIPULATOR_STATE_ACTIVE;
- /* first activate the manipulator itself */
+ if (!mmap->mmap_context.modal) {
+ mpr->state &= ~WM_MANIPULATOR_STATE_MODAL;
MEM_SAFE_FREE(mpr->interaction_data);
}
return;
}
- else {
- if (mpr->type->invoke &&
- (mpr->type->modal || mpr->custom_modal))
- {
- mpr->type->invoke(C, mpr, event);
- }
+
+ if (grab_cursor) {
+ WM_cursor_grab_enable(CTX_wm_window(C), true, true, NULL);
}
- WM_cursor_grab_enable(CTX_wm_window(C), true, true, NULL);
}
else {
- mpr = mmap->mmap_context.active;
+ BLI_assert(ELEM(mmap->mmap_context.modal, NULL, mpr));
/* deactivate, manipulator but first take care of some stuff */
if (mpr) {
- mpr->state &= ~WM_MANIPULATOR_STATE_ACTIVE;
- /* first activate the manipulator itself */
+ mpr->state &= ~WM_MANIPULATOR_STATE_MODAL;
MEM_SAFE_FREE(mpr->interaction_data);
}
- mmap->mmap_context.active = NULL;
+ mmap->mmap_context.modal = NULL;
if (C) {
WM_cursor_grab_disable(CTX_wm_window(C), NULL);
@@ -748,9 +911,20 @@ void wm_manipulatormap_active_set(
}
}
-wmManipulator *wm_manipulatormap_active_get(wmManipulatorMap *mmap)
+wmManipulator *wm_manipulatormap_modal_get(wmManipulatorMap *mmap)
+{
+ return mmap->mmap_context.modal;
+}
+
+wmManipulator **wm_manipulatormap_selected_get(wmManipulatorMap *mmap, int *r_selected_len)
{
- return mmap->mmap_context.active;
+ *r_selected_len = mmap->mmap_context.select.len;
+ return mmap->mmap_context.select.items;
+}
+
+ListBase *wm_manipulatormap_groups_get(wmManipulatorMap *mmap)
+{
+ return &mmap->groups;
}
/** \} */ /* wmManipulatorMap */
@@ -837,8 +1011,8 @@ void WM_manipulatorconfig_update_tag_init(
wmManipulatorMapType *mmap_type, wmManipulatorGroupType *wgt)
{
/* tag for update on next use */
- mmap_type->type_update_flag |= WM_MANIPULATORMAPTYPE_UPDATE_INIT;
- wgt->type_update_flag |= WM_MANIPULATORMAPTYPE_UPDATE_INIT;
+ mmap_type->type_update_flag |= (WM_MANIPULATORMAPTYPE_UPDATE_INIT | WM_MANIPULATORMAPTYPE_KEYMAP_INIT);
+ wgt->type_update_flag |= (WM_MANIPULATORMAPTYPE_UPDATE_INIT | WM_MANIPULATORMAPTYPE_KEYMAP_INIT);
wm_mmap_type_update_flag |= WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_INIT;
}
@@ -877,7 +1051,9 @@ void WM_manipulatorconfig_update(struct Main *bmain)
wgt_ref = wgt_ref_next)
{
wgt_ref_next = wgt_ref->next;
- WM_manipulatormaptype_group_unlink(NULL, bmain, mmap_type, wgt_ref->type);
+ if (wgt_ref->type->type_update_flag & WM_MANIPULATORMAPTYPE_UPDATE_REMOVE) {
+ WM_manipulatormaptype_group_unlink(NULL, bmain, mmap_type, wgt_ref->type);
+ }
}
}
}
@@ -890,14 +1066,22 @@ void WM_manipulatorconfig_update(struct Main *bmain)
mmap_type;
mmap_type = mmap_type->next)
{
- if (mmap_type->type_update_flag & WM_MANIPULATORMAPTYPE_UPDATE_INIT) {
- mmap_type->type_update_flag &= ~WM_MANIPULATORMAPTYPE_UPDATE_INIT;
+ const uchar type_update_all = WM_MANIPULATORMAPTYPE_UPDATE_INIT | WM_MANIPULATORMAPTYPE_KEYMAP_INIT;
+ if (mmap_type->type_update_flag & type_update_all) {
+ mmap_type->type_update_flag &= ~type_update_all;
for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first;
wgt_ref;
wgt_ref = wgt_ref->next)
{
- wgt_ref->type->type_update_flag &= ~WM_MANIPULATORMAPTYPE_UPDATE_INIT;
- WM_manipulatormaptype_group_init_runtime(bmain, mmap_type, wgt_ref->type);
+ if (wgt_ref->type->type_update_flag & WM_MANIPULATORMAPTYPE_KEYMAP_INIT) {
+ WM_manipulatormaptype_group_init_runtime_keymap(bmain, wgt_ref->type);
+ wgt_ref->type->type_update_flag &= ~WM_MANIPULATORMAPTYPE_KEYMAP_INIT;
+ }
+
+ if (wgt_ref->type->type_update_flag & WM_MANIPULATORMAPTYPE_UPDATE_INIT) {
+ WM_manipulatormaptype_group_init_runtime(bmain, mmap_type, wgt_ref->type);
+ wgt_ref->type->type_update_flag &= ~WM_MANIPULATORMAPTYPE_UPDATE_INIT;
+ }
}
}
}
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_target_props.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_target_props.c
index 4a022c06613..b4f65807341 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_target_props.c
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_target_props.c
@@ -45,9 +45,6 @@
#include "wm_manipulator_wmapi.h"
#include "wm_manipulator_intern.h"
-/* factor for precision tweaking */
-#define MANIPULATOR_PRECISION_FAC 0.05f
-
/* -------------------------------------------------------------------- */
/** \name Property Definition
@@ -90,7 +87,7 @@ void WM_manipulator_target_property_def_rna_ptr(
wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_at_index(mpr, mpr_prop_type->index_in_type);
/* if manipulator evokes an operator we cannot use it for property manipulation */
- mpr->op_data.type = NULL;
+ BLI_assert(mpr->op_data == NULL);
mpr_prop->type = mpr_prop_type;
@@ -119,7 +116,7 @@ void WM_manipulator_target_property_def_func_ptr(
wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_at_index(mpr, mpr_prop_type->index_in_type);
/* if manipulator evokes an operator we cannot use it for property manipulation */
- mpr->op_data.type = NULL;
+ BLI_assert(mpr->op_data == NULL);
mpr_prop->type = mpr_prop_type;
@@ -214,7 +211,7 @@ void WM_manipulator_target_property_value_get_array(
mpr_prop->custom_func.value_get_fn(mpr, mpr_prop, value);
return;
}
- return RNA_property_float_get_array(&mpr_prop->ptr, mpr_prop->prop, value);
+ RNA_property_float_get_array(&mpr_prop->ptr, mpr_prop->prop, value);
}
void WM_manipulator_target_property_value_set_array(
@@ -230,17 +227,33 @@ void WM_manipulator_target_property_value_set_array(
RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop);
}
-void WM_manipulator_target_property_range_get(
+bool WM_manipulator_target_property_range_get(
const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
float range[2])
{
- if (mpr_prop->custom_func.range_get_fn) {
- mpr_prop->custom_func.range_get_fn(mpr, mpr_prop, range);
- return;
+ if (mpr_prop->custom_func.value_get_fn) {
+ if (mpr_prop->custom_func.range_get_fn) {
+ mpr_prop->custom_func.range_get_fn(mpr, mpr_prop, range);
+ return true;
+ }
+ else {
+ return false;
+
+ }
}
float step, precision;
RNA_property_float_ui_range(&mpr_prop->ptr, mpr_prop->prop, &range[0], &range[1], &step, &precision);
+ return true;
+}
+
+int WM_manipulator_target_property_array_length(
+ const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop)
+{
+ if (mpr_prop->custom_func.value_get_fn) {
+ return mpr_prop->type->array_length;
+ }
+ return RNA_property_array_length(&mpr_prop->ptr, mpr_prop->prop);
}
/** \} */
@@ -274,4 +287,4 @@ void WM_manipulatortype_target_property_def(
BLI_addtail(&wt->target_property_defs, mpt);
}
-/** \} */ \ No newline at end of file
+/** \} */
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_type.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_type.c
index 7dabc70d69d..18944a9ab9d 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_type.c
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_type.c
@@ -28,6 +28,11 @@
#include "BLI_string.h"
#include "BLI_string_utils.h"
+#include "BKE_main.h"
+
+#include "DNA_screen_types.h"
+#include "DNA_space_types.h"
+
#include "MEM_guardedalloc.h"
#include "RNA_access.h"
@@ -36,6 +41,8 @@
#include "WM_api.h"
#include "WM_types.h"
+#include "ED_screen.h"
+
/* only for own init/exit calls (wm_manipulatortype_init/wm_manipulatortype_free) */
#include "wm.h"
@@ -95,7 +102,7 @@ static void wm_manipulatortype_append__end(wmManipulatorType *wt)
{
BLI_assert(wt->struct_size >= sizeof(wmManipulator));
- RNA_def_struct_identifier(wt->srna, wt->idname);
+ RNA_def_struct_identifier(&BLENDER_RNA, wt->srna, wt->idname);
BLI_ghash_insert(global_manipulatortype_hash, (void *)wt->idname, wt);
}
@@ -119,20 +126,58 @@ void WM_manipulatortype_append_ptr(void (*wtfunc)(struct wmManipulatorType *, vo
*/
static void manipulatortype_free(wmManipulatorType *wt)
{
+ if (wt->ext.srna) { /* python manipulator, allocs own string */
+ MEM_freeN((void *)wt->idname);
+ }
+
BLI_freelistN(&wt->target_property_defs);
MEM_freeN(wt);
}
-void WM_manipulatortype_remove_ptr(wmManipulatorType *wt)
+/**
+ * \param C: May be NULL.
+ */
+static void manipulatortype_unlink(
+ bContext *C, Main *bmain, wmManipulatorType *wt)
+{
+ /* Free instances. */
+ for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) {
+ for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
+ for (ARegion *ar = lb->first; ar; ar = ar->next) {
+ wmManipulatorMap *mmap = ar->manipulator_map;
+ if (mmap) {
+ wmManipulatorGroup *mgroup;
+ for (mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) {
+ for (wmManipulator *mpr = mgroup->manipulators.first, *mpr_next; mpr; mpr = mpr_next) {
+ mpr_next = mpr->next;
+ BLI_assert(mgroup->parent_mmap == mmap);
+ if (mpr->type == wt) {
+ WM_manipulator_unlink(&mgroup->manipulators, mgroup->parent_mmap, mpr, C);
+ ED_region_tag_redraw(ar);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+void WM_manipulatortype_remove_ptr(bContext *C, Main *bmain, wmManipulatorType *wt)
{
BLI_assert(wt == WM_manipulatortype_find(wt->idname, false));
BLI_ghash_remove(global_manipulatortype_hash, wt->idname, NULL, NULL);
+ manipulatortype_unlink(C, bmain, wt);
+
manipulatortype_free(wt);
}
-bool WM_manipulatortype_remove(const char *idname)
+bool WM_manipulatortype_remove(bContext *C, Main *bmain, const char *idname)
{
wmManipulatorType *wt = BLI_ghash_lookup(global_manipulatortype_hash, idname);
@@ -140,7 +185,7 @@ bool WM_manipulatortype_remove(const char *idname)
return false;
}
- WM_manipulatortype_remove_ptr(wt);
+ WM_manipulatortype_remove_ptr(C, bmain, wt);
return true;
}
diff --git a/source/blender/windowmanager/manipulators/wm_manipulator_fn.h b/source/blender/windowmanager/manipulators/wm_manipulator_fn.h
index ae72e04e1c3..c54024529c3 100644
--- a/source/blender/windowmanager/manipulators/wm_manipulator_fn.h
+++ b/source/blender/windowmanager/manipulators/wm_manipulator_fn.h
@@ -50,13 +50,13 @@ typedef void (*wmManipulatorFnSetup)(struct wmManipulator *);
typedef void (*wmManipulatorFnDraw)(const struct bContext *, struct wmManipulator *);
typedef void (*wmManipulatorFnDrawSelect)(const struct bContext *, struct wmManipulator *, int);
typedef int (*wmManipulatorFnTestSelect)(struct bContext *, struct wmManipulator *, const struct wmEvent *);
-typedef void (*wmManipulatorFnModal)(struct bContext *, struct wmManipulator *, const struct wmEvent *, const int);
+typedef int (*wmManipulatorFnModal)(struct bContext *, struct wmManipulator *, const struct wmEvent *, eWM_ManipulatorTweak);
typedef void (*wmManipulatorFnPropertyUpdate)(struct wmManipulator *, struct wmManipulatorProperty *);
-typedef void (*wmManipulatorFnMatrixWorldGet)(struct wmManipulator *, float[4][4]);
-typedef void (*wmManipulatorFnInvoke)(struct bContext *, struct wmManipulator *, const struct wmEvent *);
+typedef void (*wmManipulatorFnMatrixBasisGet)(const struct wmManipulator *, float[4][4]);
+typedef int (*wmManipulatorFnInvoke)(struct bContext *, struct wmManipulator *, const struct wmEvent *);
typedef void (*wmManipulatorFnExit)(struct bContext *, struct wmManipulator *, const bool);
typedef int (*wmManipulatorFnCursorGet)(struct wmManipulator *);
-typedef void (*wmManipulatorFnSelect)(struct bContext *, struct wmManipulator *, const int);
+typedef void (*wmManipulatorFnSelectRefresh)(struct wmManipulator *);
/* wmManipulatorProperty ('value' type defined by 'wmManipulatorProperty.data_type') */
typedef void (*wmManipulatorPropertyFnGet)(
diff --git a/source/blender/windowmanager/manipulators/wm_manipulator_wmapi.h b/source/blender/windowmanager/manipulators/wm_manipulator_wmapi.h
index 61489b6a730..87cf711a60b 100644
--- a/source/blender/windowmanager/manipulators/wm_manipulator_wmapi.h
+++ b/source/blender/windowmanager/manipulators/wm_manipulator_wmapi.h
@@ -61,6 +61,8 @@ void wm_manipulatorgrouptype_init(void);
void MANIPULATORGROUP_OT_manipulator_select(struct wmOperatorType *ot);
void MANIPULATORGROUP_OT_manipulator_tweak(struct wmOperatorType *ot);
+bool wm_manipulatorgroup_is_any_selected(const struct wmManipulatorGroup *mgroup);
+
/* -------------------------------------------------------------------- */
/* wmManipulatorMap */
@@ -79,10 +81,13 @@ void wm_manipulatormap_highlight_set(
struct wmManipulatorMap *mmap, const bContext *C,
struct wmManipulator *mpr, int part);
struct wmManipulator *wm_manipulatormap_highlight_get(struct wmManipulatorMap *mmap);
-void wm_manipulatormap_active_set(
- struct wmManipulatorMap *mmap, bContext *C,
- const struct wmEvent *event, struct wmManipulator *mpr);
-struct wmManipulator *wm_manipulatormap_active_get(struct wmManipulatorMap *mmap);
+void wm_manipulatormap_modal_set(
+ struct wmManipulatorMap *mmap, bContext *C, struct wmManipulator *mpr,
+ const struct wmEvent *event, bool enable);
+
+struct wmManipulator *wm_manipulatormap_modal_get(struct wmManipulatorMap *mmap);
+struct wmManipulator **wm_manipulatormap_selected_get(wmManipulatorMap *mmap, int *r_selected_len);
+struct ListBase *wm_manipulatormap_groups_get(wmManipulatorMap *mmap);
/* -------------------------------------------------------------------- */
/* wmManipulatorMapType */
diff --git a/source/blender/windowmanager/wm_event_system.h b/source/blender/windowmanager/wm_event_system.h
index 2f7ebbc1def..af72a1542f2 100644
--- a/source/blender/windowmanager/wm_event_system.h
+++ b/source/blender/windowmanager/wm_event_system.h
@@ -52,7 +52,7 @@ typedef struct wmEventHandler {
wmKeyMap *keymap; /* pointer to builtin/custom keymaps */
const rcti *bblocal, *bbwin; /* optional local and windowspace bb */
- /* modal operator handler and WM_HANDLER_FILESELECT */
+ /* modal operator handler */
wmOperator *op; /* for derived/modal handlers */
struct ScrArea *op_area; /* for derived/modal handlers */
struct ARegion *op_region; /* for derived/modal handlers */
@@ -88,7 +88,8 @@ void wm_event_do_handlers (bContext *C);
void wm_event_add_ghostevent (wmWindowManager *wm, wmWindow *win, int type, int time, void *customdata);
-void wm_event_do_notifiers (bContext *C);
+void wm_event_do_refresh_wm_and_depsgraph(bContext *C);
+void wm_event_do_notifiers(bContext *C);
/* wm_keymap.c */
diff --git a/source/blender/windowmanager/wm_files.h b/source/blender/windowmanager/wm_files.h
index 4fbbe3d2879..6f63e55e8ab 100644
--- a/source/blender/windowmanager/wm_files.h
+++ b/source/blender/windowmanager/wm_files.h
@@ -37,7 +37,7 @@ struct wmOperatorType;
void wm_history_file_read(void);
int wm_homefile_read(
struct bContext *C, struct ReportList *reports,
- bool use_factory_settings, bool use_empty_data,
+ bool use_factory_settings, bool use_empty_data, bool use_userdef,
const char *filepath_startup_override, const char *app_template_override);
void wm_file_read_report(bContext *C);
diff --git a/source/blenderplayer/CMakeLists.txt b/source/blenderplayer/CMakeLists.txt
index 4f0e64b0955..328453df118 100644
--- a/source/blenderplayer/CMakeLists.txt
+++ b/source/blenderplayer/CMakeLists.txt
@@ -27,10 +27,6 @@
setup_libdirs()
-if(WITH_CODEC_QUICKTIME)
- add_definitions(-DWITH_QUICKTIME)
-endif()
-
if(WIN32 AND NOT UNIX)
string(SUBSTRING ${BLENDER_VERSION} 0 1 bver1)
string(SUBSTRING ${BLENDER_VERSION} 2 1 bver2)
@@ -91,6 +87,12 @@ list(APPEND BLENDER_LINK_LIBS
blenkernel_blc
)
+if(WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE)
+ list(APPEND BLENDER_LINK_LIBS
+ audaspace
+ audaspace-py)
+endif()
+
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
list(APPEND BLENDER_LINK_LIBS extern_binreloc)
endif()
@@ -150,6 +152,8 @@ endif()
bf_blenfont
bf_blentranslation
bf_intern_audaspace
+ audaspace
+ audaspace-py
blenkernel_blc
bf_bmesh
bf_blenlib
@@ -201,10 +205,6 @@ endif()
list(APPEND BLENDER_SORTED_LIBS extern_xdnd)
endif()
- if(WITH_CODEC_QUICKTIME)
- list(APPEND BLENDER_SORTED_LIBS bf_quicktime)
- endif()
-
if(WITH_CXX_GUARDEDALLOC)
list(APPEND BLENDER_SORTED_LIBS bf_intern_guardedalloc_cpp)
endif()
diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c
index ea0a28d57f7..560dc0963ce 100644
--- a/source/blenderplayer/bad_level_call_stubs/stubs.c
+++ b/source/blenderplayer/bad_level_call_stubs/stubs.c
@@ -195,6 +195,7 @@ struct wmManipulatorMap;
#include "../blender/render/extern/include/RE_shader_ext.h"
#include "../blender/draw/DRW_engine.h"
#include "../blender/windowmanager/WM_api.h"
+#include "../blender/windowmanager/WM_types.h"
/* -------------------------------------------------------------------- */
@@ -286,6 +287,7 @@ void RE_sample_material_color(
int tri_index, struct DerivedMesh *orcoDm, struct Object *ob) RET_NONE
/* nodes */
struct Render *RE_GetRender(const char *name) RET_NULL
+struct Render *RE_GetSceneRender(const struct Scene *scene) RET_NULL
struct Object *RE_GetCamera(struct Render *re) RET_NULL
float RE_lamp_get_data(struct ShadeInput *shi, struct Object *lamp_obj, float col[4], float lv[3], float *dist, float shadow[4]) RET_ZERO
const float (*RE_object_instance_get_matrix(struct ObjectInstanceRen *obi, int matrix_id))[4] RET_NULL
@@ -305,12 +307,13 @@ void RE_Database_Free(struct Render *re) RET_NONE
void RE_FreeRender(struct Render *re) RET_NONE
void RE_DataBase_GetView(struct Render *re, float mat[4][4]) RET_NONE
int externtex(
- struct MTex *mtex, const float vec[3], float *tin, float *tr, float *tg, float *tb, float *ta,
+ const struct MTex *mtex, const float vec[3], float *tin, float *tr, float *tg, float *tb, float *ta,
const int thread, struct ImagePool *pool, const bool skip_load_image, const bool texnode_preview) RET_ZERO
float texture_value_blend(float tex, float out, float fact, float facg, int blendtype) RET_ZERO
void texture_rgb_blend(float in[3], const float tex[3], const float out[3], float fact, float facg, int blendtype) RET_NONE
double elbeemEstimateMemreq(int res, float sx, float sy, float sz, int refine, char *retstr) RET_ZERO
struct Render *RE_NewRender(const char *name) RET_NULL
+struct Render *RE_NewSceneRender(const struct Scene *scene) RET_NULL
void RE_SwapResult(struct Render *re, struct RenderResult **rr) RET_NONE
void RE_BlenderFrame(struct Render *re, struct Main *bmain, struct Scene *scene, struct SceneRenderLayer *srl, struct Object *camera_override, unsigned int lay_override, int frame, const bool write_still) RET_NONE
bool RE_WriteEnvmapResult(struct ReportList *reports, struct Scene *scene, struct EnvMap *env, const char *relpath, const char imtype, float layout[12]) RET_ZERO
@@ -364,27 +367,28 @@ void WM_report(ReportType type, const char *message) RET_NONE
void BPY_RNA_manipulatorgroup_wrapper(struct wmManipulatorGroupType *wgt, void *userdata) RET_NONE
void BPY_RNA_manipulator_wrapper(struct wmManipulatorType *wgt, void *userdata) RET_NONE
-PointerRNA *WM_manipulator_set_operator(struct wmManipulator *mpr, struct wmOperatorType *ot, struct IDProperty *properties) RET_NULL
+struct PointerRNA *WM_manipulator_operator_set(struct wmManipulator *mpr, int part_index, struct wmOperatorType *ot, struct IDProperty *properties) RET_NULL
const struct wmManipulatorPropertyType *WM_manipulatortype_target_property_find(const struct wmManipulatorType *wt, const char *idname) RET_NULL
const struct wmManipulatorType *WM_manipulatortype_find(const char *idname, bool quiet) RET_NULL
-struct wmManipulator *WM_manipulator_new_ptr(const struct wmManipulatorType *wt, struct wmManipulatorGroup *mgroup, const char *name, struct PointerRNA *properties) RET_NULL
+struct wmManipulator *WM_manipulator_new_ptr(const struct wmManipulatorType *wt, struct wmManipulatorGroup *mgroup, struct PointerRNA *properties) RET_NULL
struct wmManipulatorGroupType *WM_manipulatorgrouptype_append_ptr(void (*mnpfunc)(struct wmManipulatorGroupType *, void *), void *userdata) RET_NULL
struct wmManipulatorGroupType *WM_manipulatorgrouptype_find(const char *idname, bool quiet) RET_NULL
-void WM_manipulator_free(ListBase *manipulatorlist, struct wmManipulatorMap *mmap, struct wmManipulator *mpr, struct bContext *C) RET_NONE
-void WM_manipulator_group_add_ptr(struct wmManipulatorGroupType *wgt) RET_NONE
-void WM_manipulator_group_add_ptr_ex(struct wmManipulatorGroupType *wgt, struct wmManipulatorMapType *mmap_type) RET_NONE
-void WM_manipulator_group_remove_ptr(struct Main *bmain, struct wmManipulatorGroupType *wgt) RET_NONE
+void WM_manipulator_unlink(ListBase *manipulatorlist, struct wmManipulatorMap *mmap, struct wmManipulator *mpr, struct bContext *C) RET_NONE
+void WM_manipulator_group_type_add_ptr(struct wmManipulatorGroupType *wgt) RET_NONE
+void WM_manipulator_group_type_add_ptr_ex(struct wmManipulatorGroupType *wgt, struct wmManipulatorMapType *mmap_type) RET_NONE
+void WM_manipulator_group_type_remove_ptr(struct Main *bmain, struct wmManipulatorGroupType *wgt) RET_NONE
void WM_manipulator_name_set(struct wmManipulatorGroup *mgroup, struct wmManipulator *mpr, const char *name) RET_NONE
+bool WM_manipulator_select_set(struct wmManipulatorMap *mmap, struct wmManipulator *mpr, bool select) RET_ZERO
void WM_manipulator_target_property_def_rna_ptr(struct wmManipulator *mpr, const struct wmManipulatorPropertyType *mpr_prop_type, struct PointerRNA *ptr, struct PropertyRNA *prop, int index) RET_NONE
-void WM_manipulatorgrouptype_remove_ptr(struct wmManipulatorGroupType *wt) RET_NONE
+void WM_manipulatorgrouptype_free_ptr(struct wmManipulatorGroupType *wt) RET_NONE
void WM_manipulatormaptype_group_unlink(struct bContext *C, struct Main *bmain, struct wmManipulatorMapType *mmap_type, const struct wmManipulatorGroupType *wgt) RET_NONE
void WM_manipulatortype_append_ptr(void (*mnpfunc)(struct wmManipulatorType *, void *), void *userdata) RET_NONE
-void WM_manipulatortype_remove_ptr(struct wmManipulatorType *wt) RET_NONE
+void WM_manipulatortype_remove_ptr(struct bContext *C, struct Main *bmain, struct wmManipulatorType *wt) RET_NONE
void ED_manipulator_draw_preset_box(const struct wmManipulator *mpr, float mat[4][4], int select_id) RET_NONE
void ED_manipulator_draw_preset_arrow(const struct wmManipulator *mpr, float mat[4][4], int axis, int select_id) RET_NONE
void ED_manipulator_draw_preset_circle(const struct wmManipulator *mpr, float mat[4][4], int axis, int select_id) RET_NONE
-void ED_manipulator_draw_preset_facemap(const struct wmManipulator *mpr, struct Scene *scene, struct Object *ob, const int facemap, int select_id) RET_NONE
+void ED_manipulator_draw_preset_facemap(const struct bContext *C, const struct wmManipulator *mpr, struct Scene *scene, struct Object *ob, const int facemap, int select_id) RET_NONE
struct wmManipulatorMapType *WM_manipulatormaptype_find(const struct wmManipulatorMapType_Params *wmap_params) RET_NULL
struct wmManipulatorMapType *WM_manipulatormaptype_ensure(const struct wmManipulatorMapType_Params *wmap_params) RET_NULL
@@ -392,6 +396,9 @@ struct wmManipulatorMap *WM_manipulatormap_new_from_type(const struct wmManipula
void WM_manipulatormaptype_group_init_runtime(
const struct Main *bmain, struct wmManipulatorMapType *mmap_type, struct wmManipulatorGroupType *wgt) RET_NONE
const struct ListBase *WM_manipulatormap_group_list(struct wmManipulatorMap *mmap) RET_NULL
+void WM_manipulator_calc_matrix_final(const struct wmManipulator *mpr, float r_mat[4][4]) RET_NONE
+struct wmManipulatorProperty *WM_manipulator_target_property_find(struct wmManipulator *mpr, const char *idname) RET_NULL
+bool WM_manipulator_target_property_is_valid(const struct wmManipulatorProperty *mpr_prop) RET_ZERO
#ifdef WITH_INPUT_NDOF
void WM_ndof_deadzone_set(float deadzone) RET_NONE
@@ -408,7 +415,7 @@ int WM_enum_search_invoke(struct bContext *C, struct wmOperator *op, const struc
void WM_event_add_notifier(const struct bContext *C, unsigned int type, void *reference) RET_NONE
void WM_main_add_notifier(unsigned int type, void *reference) RET_NONE
void ED_armature_bone_rename(struct bArmature *arm, const char *oldnamep, const char *newnamep) RET_NONE
-void ED_armature_transform(struct bArmature *arm, float mat[4][4]) RET_NONE
+void ED_armature_transform(struct bArmature *arm, float mat[4][4], const bool do_props) RET_NONE
struct wmEventHandler *WM_event_add_modal_handler(struct bContext *C, struct wmOperator *op) RET_NULL
struct wmTimer *WM_event_add_timer(struct wmWindowManager *wm, struct wmWindow *win, int event_type, double timestep) RET_NULL
void WM_event_remove_timer(struct wmWindowManager *wm, struct wmWindow *win, struct wmTimer *timer) RET_NONE
@@ -469,7 +476,7 @@ char *ED_fsmenu_entry_get_name(struct FSMenuEntry *fsentry) RET_NULL
void ED_fsmenu_entry_set_name(struct FSMenuEntry *fsentry, const char *name) RET_NONE
struct PTCacheEdit *PE_get_current(struct Scene *scene, struct SceneLayer *sl, struct Object *ob) RET_NULL
-void PE_current_changed(struct Scene *scene, struct Object *ob) RET_NONE
+void PE_current_changed(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob) RET_NONE
/* rna keymap */
struct wmKeyMap *WM_keymap_active(struct wmWindowManager *wm, struct wmKeyMap *keymap) RET_NULL
@@ -536,7 +543,7 @@ void ED_view3d_from_m4(float mat[4][4], float ofs[3], float quat[4], float *dist
struct BGpic *ED_view3D_background_image_new(struct View3D *v3d) RET_NULL
void ED_view3D_background_image_remove(struct View3D *v3d, struct BGpic *bgpic) RET_NONE
void ED_view3D_background_image_clear(struct View3D *v3d) RET_NONE
-void ED_view3d_update_viewmat(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, float viewmat[4][4], float winmat[4][4], const struct rcti *rect) RET_NONE
+void ED_view3d_update_viewmat(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct View3D *v3d, struct ARegion *ar, float viewmat[4][4], float winmat[4][4], const struct rcti *rect) RET_NONE
float ED_view3d_grid_scale(struct Scene *scene, struct View3D *v3d, const char **grid_unit) RET_ZERO
void ED_view3d_shade_update(struct Main *bmain, struct Scene *scene, struct View3D *v3d, struct ScrArea *sa) RET_NONE
void ED_node_shader_default(const struct bContext *C, struct ID *id) RET_NONE
@@ -610,7 +617,6 @@ SnapObjectContext *ED_transform_snap_object_context_create_view3d(
void ED_transform_snap_object_context_destroy(SnapObjectContext *sctx) RET_NONE
bool ED_transform_snap_object_project_ray_ex(
struct SnapObjectContext *sctx,
- const unsigned short snap_to,
const struct SnapObjectParams *params,
const float ray_start[3], const float ray_normal[3], float *ray_depth,
/* return args */
@@ -709,7 +715,7 @@ void uiTemplateNodeView(struct uiLayout *layout, struct bContext *C, struct bNod
void uiTemplateTextureUser(struct uiLayout *layout, struct bContext *C) RET_NONE
void uiTemplateTextureShow(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop) RET_NONE
void uiTemplateKeymapItemProperties(struct uiLayout *layout, struct PointerRNA *ptr) RET_NONE
-void uiTemplateOverrideProperty(struct uiLayout *layout, struct PointerRNA *collection_props_ptr, struct PointerRNA *scene_props_ptr, const char *name, const char *custom_template) RET_NONE
+void uiTemplateOverrideProperty(struct uiLayout *layout, struct PointerRNA *collection_props_ptr, struct PointerRNA *scene_props_ptr, const char *propname, const char *name, const char *text_ctxt, int translate, int icon, const char *custom_template) RET_NONE
void uiTemplateMovieClip(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, int compact) RET_NONE
void uiTemplateMovieclipInformation(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr) RET_NONE
void uiTemplateTrack(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname) RET_NONE
@@ -752,14 +758,15 @@ void RE_engine_update_memory_stats(struct RenderEngine *engine, float mem_used,
struct RenderEngine *RE_engine_create(struct RenderEngineType *type) RET_NULL
void RE_engine_frame_set(struct RenderEngine *engine, int frame, float subframe) RET_NONE
void RE_FreePersistentData(void) RET_NONE
-void RE_point_density_cache(struct Scene *scene, struct PointDensity *pd, const bool use_render_params) RET_NONE
-void RE_point_density_minmax(struct Scene *scene, struct PointDensity *pd, const bool use_render_params, float r_min[3], float r_max[3]) RET_NONE
-void RE_point_density_sample(struct Scene *scene, struct PointDensity *pd, const int resolution, const bool use_render_params, float *values) RET_NONE
+void RE_point_density_cache(struct Scene *scene, struct SceneLayer *sl, struct PointDensity *pd, const bool use_render_params) RET_NONE
+void RE_point_density_minmax(struct Scene *scene, struct SceneLayer *sl, struct PointDensity *pd, const bool use_render_params, float r_min[3], float r_max[3]) RET_NONE
+void RE_point_density_sample(struct Scene *scene, struct SceneLayer *sl, struct PointDensity *pd, const int resolution, const bool use_render_params, float *values) RET_NONE
void RE_point_density_free(struct PointDensity *pd) RET_NONE
void RE_instance_get_particle_info(struct ObjectInstanceRen *obi, float *index, float *age, float *lifetime, float co[3], float *size, float vel[3], float angvel[3]) RET_NONE
void RE_FreeAllPersistentData(void) RET_NONE
float RE_fresnel_dielectric(float incoming[3], float normal[3], float eta) RET_ZERO
void RE_engine_register_pass(struct RenderEngine *engine, struct Scene *scene, struct SceneRenderLayer *srl, const char *name, int channels, const char *chanid, int type) RET_NONE
+struct SceneLayer *RE_engine_get_scene_layer(struct Render *re) RET_NULL
/* Draw */
void OBJECT_collection_settings_create(struct IDProperty *properties) RET_NONE
@@ -786,6 +793,7 @@ void WM_operatortype_append_ptr(void (*opfunc)(struct wmOperatorType *, void *),
void WM_operatortype_append_macro_ptr(void (*opfunc)(struct wmOperatorType *, void *), void *userdata) RET_NONE
void WM_operator_bl_idname(char *to, const char *from) RET_NONE
void WM_operator_py_idname(char *to, const char *from) RET_NONE
+bool WM_operator_py_idname_ok_or_report(struct ReportList *reports, const char *classname, const char *idname) RET_ZERO
int WM_operator_ui_popup(struct bContext *C, struct wmOperator *op, int width, int height) RET_ZERO
void update_autoflags_fcurve(struct FCurve *fcu, struct bContext *C, struct ReportList *reports, struct PointerRNA *ptr) RET_NONE
short insert_keyframe(struct ReportList *reports, struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, char keytype, short flag) RET_ZERO
@@ -808,7 +816,8 @@ int UI_pie_menu_invoke_from_operator_enum(struct bContext *C, const char *title,
const char *propname, const struct wmEvent *event) RET_ZERO
/* RNA COLLADA dependency */
-int collada_export(struct Scene *sce,
+int collada_export(const struct EvaluationContext *eval_ctx,
+ struct Scene *sce,
struct SceneLayer *scene_layer,
const char *filepath,
int apply_modifiers,
@@ -842,6 +851,7 @@ void BPY_RNA_operator_wrapper(struct wmOperatorType *ot, void *userdata) RET_NON
void BPY_RNA_operator_macro_wrapper(struct wmOperatorType *ot, void *userdata) RET_NONE
void BPY_text_free_code(struct Text *text) RET_NONE
void BPY_id_release(struct ID *id) RET_NONE
+void BPY_DECREF_RNA_INVALIDATE(void *pyob_ptr) RET_NONE
int BPY_context_member_get(struct bContext *C, const char *member, struct bContextDataResult *result) RET_ZERO
void BPY_pyconstraint_target(struct bPythonConstraint *con, struct bConstraintTarget *ct) RET_NONE
float BPY_driver_exec(PathResolvedRNA *anim_rna, struct ChannelDriver *driver, const float evaltime) RET_ZERO /* might need this one! */
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index 11e22fffa4d..78257cb7d1e 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -613,7 +613,7 @@ if(UNIX AND NOT APPLE)
PATTERN "*.pyo" EXCLUDE # * any cache *
)
# On some platforms requests does have extra dependencies.
- set(_requests_deps "chardet" "urllib3")
+ set(_requests_deps "certifi" "chardet" "idna" "urllib3")
foreach(_requests_dep ${_requests_deps})
if(EXISTS ${PYTHON_REQUESTS_PATH}/${_requests_dep})
install(
@@ -707,7 +707,7 @@ elseif(WIN32)
)
if(WITH_PYTHON_INSTALL_NUMPY)
- set(PYTHON_NUMPY_VERSION 1.10)
+ set(PYTHON_NUMPY_VERSION 1.13)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages
COMMAND ${CMAKE_COMMAND} -E
make_directory ${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages)
@@ -851,6 +851,13 @@ elseif(APPLE)
PATTERN "__MACOSX" EXCLUDE
PATTERN ".DS_Store" EXCLUDE
PATTERN "config-${PYTHON_VERSION}m/*.a" EXCLUDE # static lib
+ PATTERN "lib2to3" EXCLUDE # ./lib2to3
+ PATTERN "tkinter" EXCLUDE # ./tkinter
+ PATTERN "lib-dynload/_tkinter.*" EXCLUDE # ./lib-dynload/_tkinter.co
+ PATTERN "idlelib" EXCLUDE # ./idlelib
+ PATTERN "test" EXCLUDE # ./test
+ PATTERN "turtledemo" EXCLUDE # ./turtledemo
+ PATTERN "turtle.py" EXCLUDE # ./turtle.py
)
endmacro()
@@ -914,40 +921,10 @@ elseif(APPLE)
# python
if(WITH_PYTHON AND NOT WITH_PYTHON_MODULE AND NOT WITH_PYTHON_FRAMEWORK)
- # the python zip is first extracted as part of the build process,
- # and then later installed as part of make install. this is much
- # quicker, and means we can easily exclude files on copy
- # Not needed for PYTHON_MODULE or WEB_PLUGIN due uses Pyhon framework
- # use a hash of the .zip path to handle switching between different
- # lib directories without needing a clean build
- string(SHA1 PYTHON_ZIP_HASH ${LIBDIR}/release/${PYTHON_ZIP})
- set(PYTHON_EXTRACT_DIR ${CMAKE_CURRENT_BINARY_DIR}/${PYTHON_ZIP_HASH}/python)
-
- add_custom_target(
- extractpyzip
- DEPENDS ${PYTHON_EXTRACT_DIR})
-
- set(PYTHON_ZIP "python_${CMAKE_OSX_ARCHITECTURES}.zip")
-
- add_custom_command(
- OUTPUT ${PYTHON_EXTRACT_DIR}
- COMMAND ${CMAKE_COMMAND} -E remove_directory "${PYTHON_EXTRACT_DIR}/"
- COMMAND ${CMAKE_COMMAND} -E make_directory "${PYTHON_EXTRACT_DIR}/"
- COMMAND ${CMAKE_COMMAND} -E chdir "${PYTHON_EXTRACT_DIR}/"
- ${CMAKE_COMMAND} -E tar xzfv "${LIBDIR}/release/${PYTHON_ZIP}"
- DEPENDS ${LIBDIR}/release/${PYTHON_ZIP})
-
- add_dependencies(blender extractpyzip)
-
- # copy extracted python files
+ # Copy the python libs into the install directory
install_dir(
- ${PYTHON_EXTRACT_DIR}
- \${TARGETDIR_VER}
- )
- # copy site-packages files
- install_dir(
- ${LIBDIR}/release/site-packages
- \${TARGETDIR_VER}/python/lib/python${PYTHON_VERSION}
+ ${PYTHON_LIBPATH}
+ ${TARGETDIR_VER}/python/lib
)
install(DIRECTORY ${LIBDIR}/python/bin
@@ -1003,18 +980,10 @@ elseif(APPLE)
# python
if(WITH_PYTHON AND NOT WITH_PYTHON_FRAMEWORK)
- add_custom_command(
- OUTPUT ${PYTHON_EXTRACT_DIR}
- COMMAND ${CMAKE_COMMAND} -E remove_directory "${PYTHON_EXTRACT_DIR}/"
- COMMAND ${CMAKE_COMMAND} -E make_directory "${PYTHON_EXTRACT_DIR}/"
- COMMAND ${CMAKE_COMMAND} -E chdir "${PYTHON_EXTRACT_DIR}/"
- ${CMAKE_COMMAND} -E tar xzfv "${LIBDIR}/release/${PYTHON_ZIP}"
- DEPENDS ${LIBDIR}/release/${PYTHON_ZIP})
-
- # copy extracted python files
+ # Copy the python libs into the install directory
install_dir(
- ${PYTHON_EXTRACT_DIR}
- \${PLAYER_TARGETDIR_VER}
+ ${PYTHON_LIBPATH}
+ ${PLAYER_TARGETDIR_VER}/python/lib
)
endif()
diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c
index f25efbf72e9..c38f19397c3 100644
--- a/source/creator/creator_args.c
+++ b/source/creator/creator_args.c
@@ -548,6 +548,7 @@ static int arg_handle_print_help(int UNUSED(argc), const char **UNUSED(argv), vo
BLI_argsPrintArgDoc(ba, "--debug-depsgraph-no-threads");
BLI_argsPrintArgDoc(ba, "--debug-gpumem");
+ BLI_argsPrintArgDoc(ba, "--debug-gpu-shaders");
BLI_argsPrintArgDoc(ba, "--debug-wm");
BLI_argsPrintArgDoc(ba, "--debug-all");
BLI_argsPrintArgDoc(ba, "--debug-io");
@@ -1016,7 +1017,7 @@ static int arg_handle_audio_disable(int UNUSED(argc), const char **UNUSED(argv),
}
static const char arg_handle_audio_set_doc[] =
-"\n\tForce sound system to a specific device\n\tNULL SDL OPENAL JACK"
+"\n\tForce sound system to a specific device\n\tThe name is the same as found in the user preferences, e.g. OpenAL."
;
static int arg_handle_audio_set(int argc, const char **argv, void *UNUSED(data))
{
@@ -1113,7 +1114,7 @@ static const char arg_handle_image_type_set_doc[] =
"\t\tTGA RAWTGA JPEG IRIS IRIZ\n"
"\t\tAVIRAW AVIJPEG PNG BMP\n"
"\t(formats that can be compiled into blender, not available on all systems)\n"
-"\t\tHDR TIFF EXR MULTILAYER MPEG FRAMESERVER QUICKTIME CINEON DPX DDS JP2"
+"\t\tHDR TIFF EXR MULTILAYER MPEG FRAMESERVER CINEON DPX DDS JP2"
;
static int arg_handle_image_type_set(int argc, const char **argv, void *data)
{
@@ -1326,7 +1327,7 @@ static int arg_handle_render_frame(int argc, const char **argv, void *data)
return 1;
}
- re = RE_NewRender(scene->id.name);
+ re = RE_NewSceneRender(scene);
BLI_begin_threaded_malloc();
BKE_reports_init(&reports, RPT_STORE);
@@ -1368,7 +1369,7 @@ static int arg_handle_render_animation(int UNUSED(argc), const char **UNUSED(arg
Scene *scene = CTX_data_scene(C);
if (scene) {
Main *bmain = CTX_data_main(C);
- Render *re = RE_NewRender(scene->id.name);
+ Render *re = RE_NewSceneRender(scene);
ReportList reports;
BLI_begin_threaded_malloc();
BKE_reports_init(&reports, RPT_STORE);
@@ -1805,6 +1806,8 @@ void main_args_setup(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle)
CB_EX(arg_handle_debug_mode_generic_set, depsgraph_no_threads), (void *)G_DEBUG_DEPSGRAPH_NO_THREADS);
BLI_argsAdd(ba, 1, NULL, "--debug-gpumem",
CB_EX(arg_handle_debug_mode_generic_set, gpumem), (void *)G_DEBUG_GPU_MEM);
+ BLI_argsAdd(ba, 1, NULL, "--debug-gpu-shaders",
+ CB_EX(arg_handle_debug_mode_generic_set, gpumem), (void *)G_DEBUG_GPU_SHADERS);
BLI_argsAdd(ba, 1, NULL, "--verbose", CB(arg_handle_verbosity_set), NULL);
diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
index 99f3d0639f3..4e8f0eba9b7 100644
--- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
+++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
@@ -101,7 +101,7 @@ typedef void * wmUIHandlerRemoveFunc;
}
#ifdef WITH_AUDASPACE
-# include AUD_DEVICE_H
+# include <AUD_Device.h>
#endif
static BlendFileData *load_game_data(const char *filename)
diff --git a/source/gameengine/BlenderRoutines/CMakeLists.txt b/source/gameengine/BlenderRoutines/CMakeLists.txt
index aaeb2e10462..42293050753 100644
--- a/source/gameengine/BlenderRoutines/CMakeLists.txt
+++ b/source/gameengine/BlenderRoutines/CMakeLists.txt
@@ -56,7 +56,7 @@ set(SRC
add_definitions(${GL_DEFINITIONS})
if(WITH_AUDASPACE)
- add_definitions(${AUDASPACE_DEFINITIONS})
+ add_definitions(-DWITH_AUDASPACE)
list(APPEND INC_SYS
${AUDASPACE_C_INCLUDE_DIRS}
diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp
index 1f6687c2b67..049fd49cab9 100644
--- a/source/gameengine/Converter/BL_ArmatureObject.cpp
+++ b/source/gameengine/Converter/BL_ArmatureObject.cpp
@@ -470,6 +470,8 @@ bool BL_ArmatureObject::UnlinkObject(SCA_IObject* clientobj)
void BL_ArmatureObject::ApplyPose()
{
+ /* TODO: This doesn't work currently because of eval_ctx. */
+#if 0
m_armpose = m_objArma->pose;
m_objArma->pose = m_pose;
// in the GE, we use ctime to store the timestep
@@ -492,6 +494,7 @@ void BL_ArmatureObject::ApplyPose()
}
m_lastapplyframe = m_lastframe;
}
+#endif
}
void BL_ArmatureObject::RestorePose()
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
index 6667e6a44c2..71ac6f4fdb1 100644
--- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp
+++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
@@ -45,7 +45,9 @@
* This workaround will make sure that curve_cache for curves
* is up-to-date.
*/
-#define THREADED_DAG_WORKAROUND
+
+/* TODO: Disabled for now, because of eval_ctx. */
+//#define THREADED_DAG_WORKAROUND
#include <math.h>
#include <vector>
diff --git a/source/gameengine/Converter/BL_ModifierDeformer.cpp b/source/gameengine/Converter/BL_ModifierDeformer.cpp
index b40fb7a9f47..3be2c1aff43 100644
--- a/source/gameengine/Converter/BL_ModifierDeformer.cpp
+++ b/source/gameengine/Converter/BL_ModifierDeformer.cpp
@@ -133,6 +133,8 @@ bool BL_ModifierDeformer::HasArmatureDeformer(Object *ob)
// return a deformed mesh that supports mapping (with a valid CD_ORIGINDEX layer)
struct DerivedMesh* BL_ModifierDeformer::GetPhysicsMesh()
{
+ /* TODO: This doesn't work currently because of eval_ctx. */
+#if 0
/* we need to compute the deformed mesh taking into account the current
* shape and skin deformers, we cannot just call mesh_create_derived_physics()
* because that would use the m_transvers already deformed previously by BL_ModifierDeformer::Update(),
@@ -152,10 +154,14 @@ struct DerivedMesh* BL_ModifierDeformer::GetPhysicsMesh()
/* m_transverts is correct here (takes into account deform only modifiers) */
/* the derived mesh returned by this function must be released by the caller !!! */
return dm;
+#endif
+ return NULL;
}
bool BL_ModifierDeformer::Update(void)
{
+ /* TODO: This doesn't work currently because of eval_ctx. */
+#if 0
bool bShapeUpdate = BL_ShapeDeformer::Update();
if (bShapeUpdate || m_lastModifierUpdate != m_gameobj->GetLastFrame()) {
@@ -208,6 +214,8 @@ bool BL_ModifierDeformer::Update(void)
}
}
return bShapeUpdate;
+#endif
+ return false;
}
bool BL_ModifierDeformer::Apply(RAS_IPolyMaterial *mat)
diff --git a/source/gameengine/Converter/CMakeLists.txt b/source/gameengine/Converter/CMakeLists.txt
index 4db9fcebd06..7d6195e3c38 100644
--- a/source/gameengine/Converter/CMakeLists.txt
+++ b/source/gameengine/Converter/CMakeLists.txt
@@ -113,7 +113,7 @@ if(WITH_BULLET)
endif()
if(WITH_AUDASPACE)
- add_definitions(${AUDASPACE_DEFINITIONS})
+ add_definitions(-DWITH_AUDASPACE)
list(APPEND INC_SYS
${AUDASPACE_C_INCLUDE_DIRS}
diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp
index 974dcbca95b..d78ea4eed54 100644
--- a/source/gameengine/Converter/KX_ConvertActuators.cpp
+++ b/source/gameengine/Converter/KX_ConvertActuators.cpp
@@ -42,7 +42,7 @@
#include "KX_ConvertActuators.h"
#ifdef WITH_AUDASPACE
-# include AUD_SOUND_H
+# include <AUD_Sound.h>
#endif
// Actuators
diff --git a/source/gameengine/GameLogic/CMakeLists.txt b/source/gameengine/GameLogic/CMakeLists.txt
index 05071f59707..b9eec74f6f4 100644
--- a/source/gameengine/GameLogic/CMakeLists.txt
+++ b/source/gameengine/GameLogic/CMakeLists.txt
@@ -139,6 +139,9 @@ if(WITH_SDL)
if(WITH_GHOST_SDL)
add_definitions(-DWITH_GHOST_SDL)
endif()
+ if(WITH_SDL_DYNLOAD)
+ add_definitions(-DWITH_SDL_DYNLOAD)
+ endif()
endif()
blender_add_lib(ge_logic "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp
index 1a66b2aee52..9f532527a80 100644
--- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp
+++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp
@@ -38,7 +38,11 @@
#include "BLI_path_util.h"
#ifdef WITH_SDL
-# define SDL_CHECK(x) ((x) != (void *)0)
+# ifdef WITH_SDL_DYNLOAD
+# define SDL_CHECK(x) ((x) != (void *)0)
+# else
+# define SDL_CHECK(x) true
+# endif
#endif
SCA_Joystick::SCA_Joystick(short int index)
diff --git a/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp b/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp
index fd3d713b3d2..1dee1de9de2 100644
--- a/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp
+++ b/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp
@@ -82,9 +82,11 @@ void SCA_Joystick::HandleEvents(void)
{
SDL_Event sdl_event;
+#ifdef WITH_SDL_DYNLOAD
if (SDL_PollEvent == (void*)0) {
return;
}
+#endif
int i;
for (i=0; i<m_joynum; i++) { /* could use JOYINDEX_MAX but no reason to */
diff --git a/source/gameengine/GamePlayer/ghost/CMakeLists.txt b/source/gameengine/GamePlayer/ghost/CMakeLists.txt
index 6d6d53b1e17..5bce9fcd248 100644
--- a/source/gameengine/GamePlayer/ghost/CMakeLists.txt
+++ b/source/gameengine/GamePlayer/ghost/CMakeLists.txt
@@ -95,7 +95,7 @@ if(WITH_INTERNATIONAL)
endif()
if(WITH_AUDASPACE)
- add_definitions(${AUDASPACE_DEFINITIONS})
+ add_definitions(-DWITH_AUDASPACE)
list(APPEND INC_SYS
${AUDASPACE_C_INCLUDE_DIRS}
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
index ddb04e9f84d..1b6b6defdf9 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
@@ -99,7 +99,7 @@ extern "C"
#include "GHOST_Rect.h"
#ifdef WITH_AUDASPACE
-# include AUD_DEVICE_H
+# include <AUD_Device.h>
#endif
static void frameTimerProc(GHOST_ITimerTask* task, GHOST_TUns64 time);
diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
index 72ab06009b6..998058193bb 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
@@ -517,7 +517,7 @@ int main(
#endif
// Setup builtin font for BLF (mostly copied from creator.c, wm_init_exit.c and interface_style.c)
- BLF_init(11, U.dpi);
+ BLF_init();
BLT_lang_init();
BLT_lang_set("");
diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt
index 417f54cc8b9..cb7c0180f30 100644
--- a/source/gameengine/Ketsji/CMakeLists.txt
+++ b/source/gameengine/Ketsji/CMakeLists.txt
@@ -244,7 +244,7 @@ if(WITH_CODEC_FFMPEG)
endif()
if(WITH_AUDASPACE)
- add_definitions(${AUDASPACE_DEFINITIONS})
+ add_definitions(-DWITH_AUDASPACE)
list(APPEND INC_SYS
${AUDASPACE_C_INCLUDE_DIRS}
diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp
index 4a97dc09f62..b22873aa862 100644
--- a/source/gameengine/Ketsji/KX_Camera.cpp
+++ b/source/gameengine/Ketsji/KX_Camera.cpp
@@ -30,7 +30,7 @@
* \ingroup ketsji
*/
-
+#include "GPU_glew.h"
#include "GPU_matrix.h"
#include "KX_Camera.h"
#include "KX_Scene.h"
diff --git a/source/gameengine/Ketsji/KX_FontObject.cpp b/source/gameengine/Ketsji/KX_FontObject.cpp
index 364f8d4bfc6..91e8e4fd42b 100644
--- a/source/gameengine/Ketsji/KX_FontObject.cpp
+++ b/source/gameengine/Ketsji/KX_FontObject.cpp
@@ -281,7 +281,7 @@ int KX_FontObject::pyattr_set_text(void *self_v, const KX_PYATTRIBUTE_DEF *attrd
KX_FontObject* self = static_cast<KX_FontObject*>(self_v);
if (!PyUnicode_Check(value))
return PY_SET_ATTR_FAIL;
- char* chars = _PyUnicode_AsString(value);
+ const char *chars = _PyUnicode_AsString(value);
/* Allow for some logic brick control */
CValue* tprop = self->GetProperty("Text");
diff --git a/source/gameengine/Ketsji/KX_NavMeshObject.cpp b/source/gameengine/Ketsji/KX_NavMeshObject.cpp
index 5beda2e038a..83accb1d7a5 100644
--- a/source/gameengine/Ketsji/KX_NavMeshObject.cpp
+++ b/source/gameengine/Ketsji/KX_NavMeshObject.cpp
@@ -113,6 +113,8 @@ bool KX_NavMeshObject::BuildVertIndArrays(float *&vertices, int& nverts,
float *&dvertices, int &ndvertsuniq, unsigned short *&dtris,
int& ndtris, int &vertsPerPoly)
{
+ /* TODO: This doesn't work currently because of eval_ctx. */
+#if 0
DerivedMesh* dm = mesh_create_derived_no_virtual(GetScene()->GetBlenderScene(), GetBlenderObject(),
NULL, CD_MASK_MESH);
CustomData *pdata = dm->getPolyDataLayout(dm);
@@ -280,6 +282,8 @@ bool KX_NavMeshObject::BuildVertIndArrays(float *&vertices, int& nverts,
dm->release(dm);
return true;
+#endif
+ return false;
}
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp
index 97a7e161e9f..5540aad7a3f 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInit.cpp
@@ -40,11 +40,6 @@
# ifdef _XOPEN_SOURCE
# undef _XOPEN_SOURCE
# endif
-# if defined(__sun) || defined(sun)
-# if defined(_XPG4)
-# undef _XPG4
-# endif
-# endif
# include <Python.h>
extern "C" {
diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp
index d858097abef..04ec3f9cd04 100644
--- a/source/gameengine/Ketsji/KX_SoundActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp
@@ -37,14 +37,12 @@
#include "KX_SoundActuator.h"
#ifdef WITH_AUDASPACE
-# ifdef WITH_SYSTEM_AUDASPACE
typedef float sample_t;
-# include AUD_PYTHON_H
-# endif
-# include AUD_SOUND_H
-# include AUD_SPECIAL_H
-# include AUD_DEVICE_H
-# include AUD_HANDLE_H
+# include <python/PyAPI.h>
+# include <AUD_Sound.h>
+# include <AUD_Special.h>
+# include <AUD_Device.h>
+# include <AUD_Handle.h>
#endif
#include "KX_GameObject.h"
diff --git a/source/gameengine/Ketsji/KX_SoundActuator.h b/source/gameengine/Ketsji/KX_SoundActuator.h
index 5ec2fda722f..4f3e6f707e0 100644
--- a/source/gameengine/Ketsji/KX_SoundActuator.h
+++ b/source/gameengine/Ketsji/KX_SoundActuator.h
@@ -35,8 +35,8 @@
#include "SCA_IActuator.h"
#ifdef WITH_AUDASPACE
-# include AUD_SOUND_H
-# include AUD_HANDLE_H
+# include <AUD_Sound.h>
+# include <AUD_Handle.h>
#endif
#include "BKE_sound.h"
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
index 80c399fb256..d1c3162f752 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
@@ -770,7 +770,6 @@ static RAS_MeshSlot *current_ms;
static RAS_MeshObject *current_mesh;
static int current_blmat_nr;
static GPUVertexAttribs current_gpu_attribs;
-static Image *current_image;
static int CheckMaterialDM(int matnr, void *attribs)
{
// only draw the current material
diff --git a/source/gameengine/VideoTexture/FilterBase.cpp b/source/gameengine/VideoTexture/FilterBase.cpp
index 5717a1edbcb..b41a2095890 100644
--- a/source/gameengine/VideoTexture/FilterBase.cpp
+++ b/source/gameengine/VideoTexture/FilterBase.cpp
@@ -114,6 +114,7 @@ void Filter_dealloc(PyFilter *self)
delete self->m_filter;
self->m_filter = NULL;
}
+ Py_TYPE((PyObject *)self)->tp_free((PyObject *)self);
}
diff --git a/source/gameengine/VideoTexture/ImageBase.cpp b/source/gameengine/VideoTexture/ImageBase.cpp
index b91a312a5d7..a547d2a7a85 100644
--- a/source/gameengine/VideoTexture/ImageBase.cpp
+++ b/source/gameengine/VideoTexture/ImageBase.cpp
@@ -427,6 +427,7 @@ void Image_dealloc(PyImage *self)
delete self->m_image;
self->m_image = NULL;
}
+ Py_TYPE((PyObject *)self)->tp_free((PyObject *)self);
}
// get image data
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index fa0b86a2637..64326f34377 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,7 +1,8 @@
# Python CTests
-add_subdirectory(python)
+if(WITH_BLENDER)
+ add_subdirectory(python)
+endif()
# GTest
add_subdirectory(gtests)
-
diff --git a/tests/check_deprecated.py b/tests/check_deprecated.py
index cf8f8e0cc35..6e07f8fdb31 100644
--- a/tests/check_deprecated.py
+++ b/tests/check_deprecated.py
@@ -53,10 +53,8 @@ def is_source_any(filename):
def source_list(path, filename_check=None):
for dirpath, dirnames, filenames in os.walk(path):
-
- # skip '.svn'
- if dirpath.startswith("."):
- continue
+ # skip '.git'
+ dirnames[:] = [d for d in dirnames if not d.startswith(".")]
for filename in filenames:
if filename_check is None or filename_check(filename):
diff --git a/tests/gtests/alembic/CMakeLists.txt b/tests/gtests/alembic/CMakeLists.txt
index fadf549e212..924e7bbb1b6 100644
--- a/tests/gtests/alembic/CMakeLists.txt
+++ b/tests/gtests/alembic/CMakeLists.txt
@@ -27,6 +27,7 @@ set(INC
../../../source/blender/blenlib
../../../source/blender/alembic
../../../source/blender/makesdna
+ ../../../source/blender/depsgraph
${ALEMBIC_INCLUDE_DIRS}
${BOOST_INCLUDE_DIR}
${HDF5_INCLUDE_DIRS}
diff --git a/tests/gtests/alembic/abc_export_test.cc b/tests/gtests/alembic/abc_export_test.cc
index 63c1d179e51..52ccbc1b93f 100644
--- a/tests/gtests/alembic/abc_export_test.cc
+++ b/tests/gtests/alembic/abc_export_test.cc
@@ -10,11 +10,16 @@ extern "C" {
#include "DNA_scene_types.h"
}
+#include "DEG_depsgraph.h"
+
class TestableAbcExporter : public AbcExporter {
public:
TestableAbcExporter(Scene *scene, const char *filename, ExportSettings &settings)
- : AbcExporter(scene, filename, settings)
- {}
+ : AbcExporter(&eval_ctx, scene, filename, settings)
+ {
+ /* TODO(sergey): Pass scene layer somehow? */
+ DEG_evaluation_context_init(&eval_ctx, DAG_EVAL_VIEWPORT);
+ }
void getShutterSamples(unsigned int nr_of_samples,
bool time_relative,
@@ -28,6 +33,7 @@ public:
AbcExporter::getFrameSet(nr_of_samples, frames);
}
+ EvaluationContext eval_ctx;
};
diff --git a/tests/gtests/blenlib/BLI_array_utils_test.cc b/tests/gtests/blenlib/BLI_array_utils_test.cc
index 518cd097326..c4601e00fbd 100644
--- a/tests/gtests/blenlib/BLI_array_utils_test.cc
+++ b/tests/gtests/blenlib/BLI_array_utils_test.cc
@@ -5,7 +5,7 @@
extern "C" {
#include "BLI_utildefines.h"
#include "BLI_array_utils.h"
-#include "BLI_stackdefines.h"
+#include "BLI_utildefines_stack.h"
}
/* -------------------------------------------------------------------- */
diff --git a/tests/gtests/blenlib/BLI_kdopbvh_test.cc b/tests/gtests/blenlib/BLI_kdopbvh_test.cc
index bc8cf58d69d..74db7cf20a0 100644
--- a/tests/gtests/blenlib/BLI_kdopbvh_test.cc
+++ b/tests/gtests/blenlib/BLI_kdopbvh_test.cc
@@ -12,6 +12,8 @@ extern "C" {
#include "MEM_guardedalloc.h"
}
+#include "stubs/bf_intern_eigen_stubs.h"
+
/* -------------------------------------------------------------------- */
/* Helper Functions */
@@ -58,7 +60,10 @@ static void find_nearest_points_test(int points_len, float scale, int round, int
{
struct RNG *rng = BLI_rng_new(random_seed);
BVHTree *tree = BLI_bvhtree_new(points_len, 0.0, 8, 8);
- float (*points)[3] = (float (*)[3])MEM_mallocN(sizeof(float[3]) * points_len, __func__);
+
+ void *mem = MEM_mallocN(sizeof(float[3]) * points_len, __func__);
+ float (*points)[3] = (float (*)[3])mem;
+
for (int i = 0; i < points_len; i++) {
rng_v3_round(points[i], 3, rng, round, scale);
BLI_bvhtree_insert(tree, i, points[i], 1);
diff --git a/tests/gtests/blenlib/BLI_math_geom_test.cc b/tests/gtests/blenlib/BLI_math_geom_test.cc
index cd15a4eb8ff..92e2532392e 100644
--- a/tests/gtests/blenlib/BLI_math_geom_test.cc
+++ b/tests/gtests/blenlib/BLI_math_geom_test.cc
@@ -4,6 +4,8 @@
#include "BLI_math.h"
+#include "stubs/bf_intern_eigen_stubs.h"
+
TEST(math_geom, DistToLine2DSimple)
{
float p[2] = {5.0f, 1.0f},
diff --git a/tests/gtests/blenlib/BLI_memiter_test.cc b/tests/gtests/blenlib/BLI_memiter_test.cc
new file mode 100644
index 00000000000..601eadea267
--- /dev/null
+++ b/tests/gtests/blenlib/BLI_memiter_test.cc
@@ -0,0 +1,206 @@
+/* Apache License, Version 2.0 */
+
+#include "testing/testing.h"
+
+extern "C" {
+#include "BLI_array_utils.h"
+#include "BLI_memiter.h"
+#include "MEM_guardedalloc.h"
+
+#include "BLI_string.h"
+#include "BLI_ressource_strings.h"
+}
+
+TEST(memiter, Nop)
+{
+ BLI_memiter *mi = BLI_memiter_create(64);
+ BLI_memiter_destroy(mi);
+}
+
+void memiter_empty_test(int num_elems, const int chunk_size)
+{
+ BLI_memiter *mi = BLI_memiter_create(chunk_size);
+ void *data;
+ for (int index = 0; index < num_elems; index++) {
+ data = BLI_memiter_alloc(mi, 0);
+ }
+ int index = 0, total_size = 0;
+ BLI_memiter_handle it;
+ BLI_memiter_iter_init(mi, &it);
+ uint elem_size;
+ while ((data = BLI_memiter_iter_step_size(&it, &elem_size))) {
+ index += 1;
+ total_size += elem_size;
+ }
+ EXPECT_EQ(0, total_size);
+ EXPECT_EQ(num_elems, index);
+
+ BLI_memiter_destroy(mi);
+}
+
+#define MEMITER_NUMBER_TEST_FN(fn, number_type) \
+void fn(int num_elems, const int chunk_size) \
+{ \
+ BLI_memiter *mi = BLI_memiter_create(chunk_size); \
+ number_type *data; \
+ for (int index = 0; index < num_elems; index++) { \
+ data = (number_type *)BLI_memiter_alloc(mi, sizeof(number_type)); \
+ *data = index; \
+ } \
+ BLI_memiter_handle it; \
+ BLI_memiter_iter_init(mi, &it); \
+ uint elem_size; \
+ int index = 0; \
+ while ((data = (number_type *)BLI_memiter_iter_step_size(&it, &elem_size))) { \
+ EXPECT_EQ(sizeof(number_type), elem_size); \
+ EXPECT_EQ(index, *data); \
+ index += 1; \
+ } \
+ BLI_memiter_destroy(mi); \
+}
+
+/* generate number functions */
+MEMITER_NUMBER_TEST_FN(memiter_char_test, char)
+MEMITER_NUMBER_TEST_FN(memiter_short_test, short)
+MEMITER_NUMBER_TEST_FN(memiter_int_test, int)
+MEMITER_NUMBER_TEST_FN(memiter_long_test, int64_t)
+
+void memiter_string_test(const char *strings[], const int chunk_size)
+{
+ BLI_memiter *mi = BLI_memiter_create(chunk_size);
+ char *data;
+ int index = 0;
+ int total_size_expect = 0;
+ while (strings[index]) {
+ const int size = strlen(strings[index]) + 1;
+ BLI_memiter_alloc_from(mi, size, strings[index]);
+ total_size_expect += size;
+ index += 1;
+ }
+ const int strings_len = index;
+ int total_size = 0;
+ BLI_memiter_handle it;
+ BLI_memiter_iter_init(mi, &it);
+ uint elem_size;
+ index = 0;
+ while ((data = (char *)BLI_memiter_iter_step_size(&it, &elem_size))) {
+ EXPECT_EQ(strlen(strings[index]) + 1, elem_size);
+ EXPECT_STREQ(strings[index], data);
+ total_size += elem_size;
+ index += 1;
+ }
+ EXPECT_EQ(total_size_expect, total_size);
+ EXPECT_EQ(strings_len, index);
+
+ BLI_memiter_destroy(mi);
+}
+
+void memiter_words10k_test(const char split_char, const int chunk_size)
+{
+ const int words_len = sizeof(words10k) - 1;
+ char *words = BLI_strdupn(words10k, words_len);
+ BLI_str_replace_char(words, split_char, '\0');
+
+ BLI_memiter *mi = BLI_memiter_create(chunk_size);
+
+ char *data;
+ int index;
+ char *c_end, *c;
+ c_end = words + words_len;
+ c = words;
+ index = 0;
+ while (c < c_end) {
+ int elem_size = strlen(c) + 1;
+ data = (char *)BLI_memiter_alloc(mi, elem_size);
+ memcpy(data, c, elem_size);
+ c += elem_size;
+ index += 1;
+ }
+ const int len_expect = index;
+ c = words;
+ uint size;
+ BLI_memiter_handle it;
+ BLI_memiter_iter_init(mi, &it);
+ index = 0;
+ while ((data = (char *)BLI_memiter_iter_step_size(&it, &size))) {
+ int size_expect = strlen(c) + 1;
+ EXPECT_EQ(size_expect, size);
+ EXPECT_STREQ(c, data);
+ c += size;
+ index += 1;
+ }
+ EXPECT_EQ(len_expect, index);
+ BLI_memiter_destroy(mi);
+ MEM_freeN(words);
+}
+
+
+#define TEST_EMPTY_AT_CHUNK_SIZE(chunk_size) \
+TEST(memiter, Empty0_##chunk_size) { memiter_empty_test(0, chunk_size); } \
+TEST(memiter, Empty1_##chunk_size) { memiter_empty_test(1, chunk_size); } \
+TEST(memiter, Empty2_##chunk_size) { memiter_empty_test(2, chunk_size); } \
+TEST(memiter, Empty3_##chunk_size) { memiter_empty_test(3, chunk_size); } \
+TEST(memiter, Empty13_##chunk_size) { memiter_empty_test(13, chunk_size); } \
+TEST(memiter, Empty256_##chunk_size) { memiter_empty_test(256, chunk_size); } \
+
+TEST_EMPTY_AT_CHUNK_SIZE(1)
+TEST_EMPTY_AT_CHUNK_SIZE(2)
+TEST_EMPTY_AT_CHUNK_SIZE(3)
+TEST_EMPTY_AT_CHUNK_SIZE(13)
+TEST_EMPTY_AT_CHUNK_SIZE(256)
+
+#define TEST_NUMBER_AT_CHUNK_SIZE(chunk_size) \
+TEST(memiter, Char1_##chunk_size) { memiter_char_test(1, chunk_size); } \
+TEST(memiter, Short1_##chunk_size) { memiter_short_test(1, chunk_size); } \
+TEST(memiter, Int1_##chunk_size) { memiter_int_test(1, chunk_size); } \
+TEST(memiter, Long1_##chunk_size) { memiter_long_test(1, chunk_size); } \
+\
+TEST(memiter, Char2_##chunk_size) { memiter_char_test(2, chunk_size); } \
+TEST(memiter, Short2_##chunk_size) { memiter_short_test(2, chunk_size); } \
+TEST(memiter, Int2_##chunk_size) { memiter_int_test(2, chunk_size); } \
+TEST(memiter, Long2_##chunk_size) { memiter_long_test(2, chunk_size); } \
+\
+TEST(memiter, Char3_##chunk_size) { memiter_char_test(3, chunk_size); } \
+TEST(memiter, Short3_##chunk_size) { memiter_short_test(3, chunk_size); } \
+TEST(memiter, Int3_##chunk_size) { memiter_int_test(3, chunk_size); } \
+TEST(memiter, Long3_##chunk_size) { memiter_long_test(3, chunk_size); } \
+\
+TEST(memiter, Char256_##chunk_size) { memiter_char_test(256, chunk_size); } \
+TEST(memiter, Short256_##chunk_size) { memiter_short_test(256, chunk_size); } \
+TEST(memiter, Int256_##chunk_size) { memiter_int_test(256, chunk_size); } \
+TEST(memiter, Long256_##chunk_size) { memiter_long_test(256, chunk_size); } \
+
+TEST_NUMBER_AT_CHUNK_SIZE(1)
+TEST_NUMBER_AT_CHUNK_SIZE(2)
+TEST_NUMBER_AT_CHUNK_SIZE(3)
+TEST_NUMBER_AT_CHUNK_SIZE(13)
+TEST_NUMBER_AT_CHUNK_SIZE(256)
+
+#define STRINGS_TEST(chunk_size, ...) { \
+ const char *data[] = {__VA_ARGS__, NULL}; \
+ memiter_string_test(data, chunk_size); \
+}
+
+#define TEST_STRINGS_AT_CHUNK_SIZE(chunk_size) \
+TEST(memiter, Strings_##chunk_size) { \
+ STRINGS_TEST(chunk_size, ""); \
+ STRINGS_TEST(chunk_size, "test", "me"); \
+ STRINGS_TEST(chunk_size, "more", "test", "data", "to", "follow"); \
+}
+
+TEST_STRINGS_AT_CHUNK_SIZE(1)
+TEST_STRINGS_AT_CHUNK_SIZE(2)
+TEST_STRINGS_AT_CHUNK_SIZE(3)
+TEST_STRINGS_AT_CHUNK_SIZE(13)
+TEST_STRINGS_AT_CHUNK_SIZE(256)
+
+
+#define TEST_WORDS10K_AT_CHUNK_SIZE(chunk_size) \
+TEST(memiter, Words10kSentence_##chunk_size) { memiter_words10k_test('.', chunk_size); } \
+TEST(memiter, Words10kWords_##chunk_size) { memiter_words10k_test(' ', chunk_size); } \
+
+TEST_WORDS10K_AT_CHUNK_SIZE(1)
+TEST_WORDS10K_AT_CHUNK_SIZE(2)
+TEST_WORDS10K_AT_CHUNK_SIZE(3)
+TEST_WORDS10K_AT_CHUNK_SIZE(13)
+TEST_WORDS10K_AT_CHUNK_SIZE(256)
diff --git a/tests/gtests/blenlib/BLI_polyfill2d_test.cc b/tests/gtests/blenlib/BLI_polyfill2d_test.cc
index 5d112751fa0..df98ead4cb9 100644
--- a/tests/gtests/blenlib/BLI_polyfill2d_test.cc
+++ b/tests/gtests/blenlib/BLI_polyfill2d_test.cc
@@ -27,6 +27,8 @@ extern "C" {
#endif
}
+#include "stubs/bf_intern_eigen_stubs.h"
+
static void polyfill_to_obj(
const char *id,
const float poly[][2], const unsigned int poly_tot,
@@ -208,6 +210,26 @@ static void test_polyfill_template(
#endif
}
+static void test_polyfill_template_flip_sign(
+ const char *id, bool is_degenerate,
+ const float poly[][2], const unsigned int poly_tot,
+ unsigned int tris[][3], const unsigned int tris_tot)
+{
+ float (*poly_copy)[2] = (float (*)[2])MEM_mallocN(sizeof(float[2]) * poly_tot, id);
+ for (int flip_x = 0; flip_x < 2; flip_x++) {
+ for (int flip_y = 0; flip_y < 2; flip_y++) {
+ float sign_x = flip_x ? -1.0f : 1.0f;
+ float sign_y = flip_y ? -1.0f : 1.0f;
+ for (int i = 0; i < poly_tot; i++) {
+ poly_copy[i][0] = poly[i][0] * sign_x;
+ poly_copy[i][1] = poly[i][1] * sign_y;
+ }
+ test_polyfill_template(id, is_degenerate, poly_copy, poly_tot, tris, tris_tot);
+ }
+ }
+ MEM_freeN(poly_copy);
+}
+
#ifdef USE_COMBINATIONS_ALL
static void test_polyfill_template_main(
const char *id, bool is_degenerate,
@@ -230,7 +252,7 @@ static void test_polyfill_template_main(
for (poly_cycle = 0; poly_cycle < poly_tot; poly_cycle++) {
// printf("polytest %s ofs=%d, reverse=%d\n", id, poly_cycle, poly_reverse);
- test_polyfill_template(id, is_degenerate, poly, poly_tot, tris, tris_tot);
+ test_polyfill_template_flip_sign(id, is_degenerate, poly, poly_tot, tris, tris_tot);
/* cycle */
copy_v2_v2(tmp, poly_copy[0]);
@@ -247,7 +269,7 @@ static void test_polyfill_template_main(
const float poly[][2], const unsigned int poly_tot,
unsigned int tris[][3], const unsigned int tris_tot)
{
- test_polyfill_template(id, is_degenerate, poly, poly_tot, tris, tris_tot);
+ test_polyfill_template_flip_sign(id, is_degenerate, poly, poly_tot, tris, tris_tot);
}
#endif /* USE_COMBINATIONS_ALL */
@@ -307,6 +329,43 @@ static void polyfill_to_obj(
/* -------------------------------------------------------------------- */
/* tests */
+/**
+ * Script to generate the data below:
+ *
+ * \code{.py}
+ * # This example assumes we have a mesh object in edit-mode
+ *
+ * import bpy
+ * import bmesh
+ *
+ * obj = bpy.context.edit_object
+ * me = obj.data
+ * bm = bmesh.from_edit_mesh(me)
+ *
+ * def clean_float(num):
+ * if int(num) == num:
+ * return str(int(num))
+ * prec = 1
+ * while True:
+ * text = f"{num:.{prec}f}"
+ * if float(text) == num:
+ * return text
+ * prec += 1
+ *
+ * for f in bm.faces:
+ * if f.select:
+ * print(f"\t// data for face: {f.index}")
+ * print("\tconst float poly[][2] = {", end="")
+ * coords = [[clean_float(num) for num in l.vert.co[0:2]] for l in f.loops]
+ * print("\t ", end="")
+ * for i, (x, y) in enumerate(coords):
+ * if (i % 2) == 0:
+ * print("\n\t ", end="")
+ * print(f"{{{x}, {y}}}", end=",")
+ * print("\n\t};")
+ * \endcode
+ */
+
#define POLY_TRI_COUNT(len) ((len) - 2)
@@ -517,3 +576,17 @@ TEST(polyfill2d, IssueT41986_axis_align)
TEST_POLYFILL_TEMPLATE_STATIC(poly, false);
}
+
+/* Blender bug T52834 */
+TEST(polyfill2d, IssueT52834_axis_align_co_linear)
+{
+ const float poly[][2] = {
+ {40, 0}, {36, 0}, {36, 5}, {35, 5}, {35, 0}, {30, 0}, {30, 5}, {29, 5}, {29, 0}, {24, 0}, {24, 3},
+ {23, 4}, {23, 0}, {18, 0}, {18, 5}, {17, 5}, {17, 0}, {12, 0}, {12, 5}, {11, 5}, {11, 0}, {6, 0},
+ {6, 5}, {5, 5}, {5, 0}, {0, 0}, {0, 5}, {-1, 5}, {-1, 0}, {-6, 0}, {-9, -3}, {-6, -3}, {-6, -2},
+ {-1, -2}, {0, -2}, {5, -2}, {6, -2}, {11, -2}, {12, -2}, {17, -2}, {18, -2}, {23, -2}, {24, -2},
+ {29, -2}, {30, -2}, {35, -2}, {36, -2}, {40, -2},
+ };
+
+ TEST_POLYFILL_TEMPLATE_STATIC(poly, false);
+}
diff --git a/tests/gtests/blenlib/CMakeLists.txt b/tests/gtests/blenlib/CMakeLists.txt
index 8b013e7a7a6..e64bcf821de 100644
--- a/tests/gtests/blenlib/CMakeLists.txt
+++ b/tests/gtests/blenlib/CMakeLists.txt
@@ -34,24 +34,28 @@ include_directories(${INC})
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PLATFORM_LINKFLAGS}")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${PLATFORM_LINKFLAGS_DEBUG}")
+if(WIN32)
+ set(BLI_path_util_extra_libs "bf_blenlib;bf_intern_utfconv;extern_wcwidth;${ZLIB_LIBRARIES}")
+else()
+ set(BLI_path_util_extra_libs "bf_blenlib;extern_wcwidth;${ZLIB_LIBRARIES}")
+endif()
BLENDER_TEST(BLI_array_store "bf_blenlib")
BLENDER_TEST(BLI_array_utils "bf_blenlib")
-BLENDER_TEST(BLI_kdopbvh "bf_blenlib;bf_intern_eigen")
-BLENDER_TEST(BLI_stack "bf_blenlib")
-BLENDER_TEST(BLI_math_color "bf_blenlib")
-BLENDER_TEST(BLI_math_geom "bf_blenlib;bf_intern_eigen")
+BLENDER_TEST(BLI_ghash "bf_blenlib")
+BLENDER_TEST(BLI_hash_mm2a "bf_blenlib")
+BLENDER_TEST(BLI_kdopbvh "bf_blenlib")
+BLENDER_TEST(BLI_listbase "bf_blenlib")
BLENDER_TEST(BLI_math_base "bf_blenlib")
+BLENDER_TEST(BLI_math_color "bf_blenlib")
+BLENDER_TEST(BLI_math_geom "bf_blenlib")
+BLENDER_TEST(BLI_memiter "bf_blenlib")
+BLENDER_TEST(BLI_path_util "${BLI_path_util_extra_libs}")
+BLENDER_TEST(BLI_polyfill2d "bf_blenlib")
+BLENDER_TEST(BLI_stack "bf_blenlib")
BLENDER_TEST(BLI_string "bf_blenlib")
BLENDER_TEST(BLI_string_utf8 "bf_blenlib")
-if(WIN32)
- BLENDER_TEST(BLI_path_util "bf_blenlib;bf_intern_utfconv;extern_wcwidth;${ZLIB_LIBRARIES}")
-else()
- BLENDER_TEST(BLI_path_util "bf_blenlib;extern_wcwidth;${ZLIB_LIBRARIES}")
-endif()
-BLENDER_TEST(BLI_polyfill2d "bf_blenlib;bf_intern_eigen")
-BLENDER_TEST(BLI_listbase "bf_blenlib")
-BLENDER_TEST(BLI_hash_mm2a "bf_blenlib")
-BLENDER_TEST(BLI_ghash "bf_blenlib")
BLENDER_TEST_PERFORMANCE(BLI_ghash_performance "bf_blenlib")
+
+unset(BLI_path_util_extra_libs)
diff --git a/tests/gtests/blenlib/stubs/bf_intern_eigen_stubs.h b/tests/gtests/blenlib/stubs/bf_intern_eigen_stubs.h
new file mode 100644
index 00000000000..dad77a257d5
--- /dev/null
+++ b/tests/gtests/blenlib/stubs/bf_intern_eigen_stubs.h
@@ -0,0 +1,18 @@
+/* Apache License, Version 2.0 */
+
+extern "C" {
+
+bool EIG_self_adjoint_eigen_solve(const int size, const float *matrix, float *r_eigen_values, float *r_eigen_vectors)
+{
+ BLI_assert(0);
+ UNUSED_VARS(size, matrix, r_eigen_values, r_eigen_vectors);
+ return false;
+}
+
+void EIG_svd_square_matrix(const int size, const float *matrix, float *r_U, float *r_S, float *r_V)
+{
+ BLI_assert(0);
+ UNUSED_VARS(size, matrix, r_U, r_S, r_V);
+}
+
+}
diff --git a/tests/python/CMakeLists.txt b/tests/python/CMakeLists.txt
index 20fa8257a32..a3460823e69 100644
--- a/tests/python/CMakeLists.txt
+++ b/tests/python/CMakeLists.txt
@@ -39,78 +39,101 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_OUT_DIR})
# all calls to blender use this
if(APPLE)
if(${CMAKE_GENERATOR} MATCHES "Xcode")
- set(TEST_BLENDER_EXE ${EXECUTABLE_OUTPUT_PATH}/Debug/blender.app/Contents/MacOS/blender)
+ set(TEST_BLENDER_EXE_PARAMS --background -noaudio --factory-startup)
else()
- set(TEST_BLENDER_EXE ${EXECUTABLE_OUTPUT_PATH}/blender.app/Contents/MacOS/blender)
+ set(TEST_BLENDER_EXE_PARAMS --background -noaudio --factory-startup --env-system-scripts ${CMAKE_SOURCE_DIR}/release/scripts)
endif()
else()
- set(TEST_BLENDER_EXE ${EXECUTABLE_OUTPUT_PATH}/blender)
+ set(TEST_BLENDER_EXE_PARAMS --background -noaudio --factory-startup --env-system-scripts ${CMAKE_SOURCE_DIR}/release/scripts)
endif()
# for testing with valgrind prefix: valgrind --track-origins=yes --error-limit=no
-set(TEST_BLENDER_EXE_BARE ${TEST_BLENDER_EXE})
-set(TEST_BLENDER_EXE_PARAMS --background -noaudio --factory-startup --env-system-scripts ${CMAKE_SOURCE_DIR}/release/scripts)
-set(TEST_BLENDER_EXE ${TEST_BLENDER_EXE} ${TEST_BLENDER_EXE_PARAMS} )
+# set(TEST_BLENDER_EXE_BARE ${TEST_BLENDER_EXE})
+# set(TEST_BLENDER_EXE ${TEST_BLENDER_EXE} ${TEST_BLENDER_EXE_PARAMS} )
# ------------------------------------------------------------------------------
# GENERAL PYTHON CORRECTNESS TESTS
-add_test(script_load_keymap ${TEST_BLENDER_EXE}
+add_test(
+ NAME script_load_keymap
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
--python ${CMAKE_CURRENT_LIST_DIR}/bl_keymap_completeness.py
)
-add_test(script_load_addons ${TEST_BLENDER_EXE}
+add_test(
+ NAME script_load_addons
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
--python ${CMAKE_CURRENT_LIST_DIR}/bl_load_addons.py
)
-add_test(script_load_modules ${TEST_BLENDER_EXE}
+add_test(
+ NAME script_load_modules
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
--python ${CMAKE_CURRENT_LIST_DIR}/bl_load_py_modules.py
)
# test running operators doesn't segfault under various conditions
if(USE_EXPERIMENTAL_TESTS)
- add_test(script_run_operators ${TEST_BLENDER_EXE}
+ add_test(
+ NAME script_run_operators
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
--python ${CMAKE_CURRENT_LIST_DIR}/bl_run_operators.py
)
endif()
# ------------------------------------------------------------------------------
# PY API TESTS
-add_test(script_pyapi_bpy_path ${TEST_BLENDER_EXE}
+add_test(
+ NAME script_pyapi_bpy_path
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
--python ${CMAKE_CURRENT_LIST_DIR}/bl_pyapi_bpy_path.py
)
-add_test(script_pyapi_bpy_utils_units ${TEST_BLENDER_EXE}
+add_test(
+ NAME script_pyapi_bpy_utils_units
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
--python ${CMAKE_CURRENT_LIST_DIR}/bl_pyapi_bpy_utils_units.py
)
-add_test(script_pyapi_mathutils ${TEST_BLENDER_EXE}
+add_test(
+ NAME script_pyapi_mathutils
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
--python ${CMAKE_CURRENT_LIST_DIR}/bl_pyapi_mathutils.py
)
-add_test(script_pyapi_idprop ${TEST_BLENDER_EXE}
+add_test(
+ NAME script_pyapi_idprop
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
--python ${CMAKE_CURRENT_LIST_DIR}/bl_pyapi_idprop.py
)
-add_test(script_pyapi_idprop_datablock ${TEST_BLENDER_EXE}
+add_test(
+ NAME script_pyapi_idprop_datablock
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
--python ${CMAKE_CURRENT_LIST_DIR}/bl_pyapi_idprop_datablock.py
)
# ------------------------------------------------------------------------------
# MODELING TESTS
-add_test(bevel ${TEST_BLENDER_EXE}
+add_test(
+ NAME bevel
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
${TEST_SRC_DIR}/modeling/bevel_regression.blend
--python-text run_tests
)
-add_test(split_faces ${TEST_BLENDER_EXE}
+add_test(
+ NAME split_faces
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
${TEST_SRC_DIR}/modeling/split_faces_test.blend
--python-text run_tests
)
# ------------------------------------------------------------------------------
# MODIFIERS TESTS
-add_test(modifier_array ${TEST_BLENDER_EXE}
+add_test(
+ NAME modifier_array
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
${TEST_SRC_DIR}/modifier_stack/array_test.blend
--python-text run_tests
)
@@ -121,21 +144,27 @@ add_test(modifier_array ${TEST_BLENDER_EXE}
# OBJ Import tests
# disabled until updated & working
if(FALSE)
-add_test(import_obj_cube ${TEST_BLENDER_EXE}
+add_test(
+ NAME import_obj_cube
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.import_scene.obj\(filepath='${TEST_SRC_DIR}/io_tests/obj/cube.obj'\)
--md5=39cce4bacac2d1b18fc470380279bc15 --md5_method=SCENE
--write-blend=${TEST_OUT_DIR}/import_obj_cube.blend
)
-add_test(import_obj_nurbs_cyclic ${TEST_BLENDER_EXE}
+add_test(
+ NAME import_obj_nurbs_cyclic
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.import_scene.obj\(filepath='${TEST_SRC_DIR}/io_tests/obj/nurbs_cyclic.obj'\)
--md5=ad3c307e5883224a0492378cd32691ab --md5_method=SCENE
--write-blend=${TEST_OUT_DIR}/import_obj_nurbs_cyclic.blend
)
-add_test(import_obj_makehuman ${TEST_BLENDER_EXE}
+add_test(
+ NAME import_obj_makehuman
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.import_scene.obj\(filepath='${TEST_SRC_DIR}/io_tests/obj/makehuman.obj'\)
--md5=c9f78b185e58358daa4ecaecfa75464e --md5_method=SCENE
@@ -144,7 +173,9 @@ add_test(import_obj_makehuman ${TEST_BLENDER_EXE}
endif()
# OBJ Export tests
-add_test(export_obj_cube ${TEST_BLENDER_EXE}
+add_test(
+ NAME export_obj_cube
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
${TEST_SRC_DIR}/io_tests/blend_geometry/all_quads.blend
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.export_scene.obj\(filepath='${TEST_OUT_DIR}/export_obj_cube.obj',use_selection=False\)
@@ -153,7 +184,9 @@ add_test(export_obj_cube ${TEST_BLENDER_EXE}
--md5=e80660437ad9bfe082849641c361a233 --md5_method=FILE
)
-add_test(export_obj_nurbs ${TEST_BLENDER_EXE}
+add_test(
+ NAME export_obj_nurbs
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
${TEST_SRC_DIR}/io_tests/blend_geometry/nurbs.blend
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.export_scene.obj\(filepath='${TEST_OUT_DIR}/export_obj_nurbs.obj',use_selection=False,use_nurbs=True\)
@@ -164,7 +197,9 @@ add_test(export_obj_nurbs ${TEST_BLENDER_EXE}
# disabled until updated & working
if(FALSE)
-add_test(export_obj_all_objects ${TEST_BLENDER_EXE}
+add_test(
+ NAME export_obj_all_objects
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
${TEST_SRC_DIR}/io_tests/blend_scene/all_objects.blend
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.export_scene.obj\(filepath='${TEST_OUT_DIR}/export_obj_all_objects.obj',use_selection=False,use_nurbs=True\)
@@ -177,21 +212,27 @@ endif()
# PLY Import tests
-add_test(import_ply_cube ${TEST_BLENDER_EXE}
+add_test(
+ NAME import_ply_cube
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.import_mesh.ply\(filepath='${TEST_SRC_DIR}/io_tests/ply/cube_ascii.ply'\)
--md5=527134343c27fc0ea73115b85fbfd3ac --md5_method=SCENE
--write-blend=${TEST_OUT_DIR}/import_ply_cube.blend
)
-add_test(import_ply_bunny ${TEST_BLENDER_EXE}
+add_test(
+ NAME import_ply_bunny
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.import_mesh.ply\(filepath='${TEST_SRC_DIR}/io_tests/ply/bunny2.ply'\)
--md5=6ea5b8533400a17accf928b8fd024eaa --md5_method=SCENE
--write-blend=${TEST_OUT_DIR}/import_ply_bunny.blend
)
-add_test(import_ply_small_holes ${TEST_BLENDER_EXE}
+add_test(
+ NAME import_ply_small_holes
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.import_mesh.ply\(filepath='${TEST_SRC_DIR}/io_tests/ply/many_small_holes.ply'\)
--md5=c3093e26ecae5b6d59fbbcf2a0d0b39f --md5_method=SCENE
@@ -201,7 +242,9 @@ add_test(import_ply_small_holes ${TEST_BLENDER_EXE}
# PLY Export
# disabled until updated & working
if(FALSE)
-add_test(export_ply_cube_all_data ${TEST_BLENDER_EXE}
+add_test(
+ NAME export_ply_cube_all_data
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
${TEST_SRC_DIR}/io_tests/blend_geometry/cube_all_data.blend
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.export_mesh.ply\(filepath='${TEST_OUT_DIR}/export_ply_cube_all_data.ply'\)
@@ -209,7 +252,9 @@ add_test(export_ply_cube_all_data ${TEST_BLENDER_EXE}
--md5=6adc3748ceae8298496f99d0e7e76c15 --md5_method=FILE
)
-add_test(export_ply_suzanne_all_data ${TEST_BLENDER_EXE}
+add_test(
+ NAME export_ply_suzanne_all_data
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
${TEST_SRC_DIR}/io_tests/blend_geometry/suzanne_all_data.blend
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.export_mesh.ply\(filepath='${TEST_OUT_DIR}/export_ply_suzanne_all_data.ply'\)
@@ -218,7 +263,9 @@ add_test(export_ply_suzanne_all_data ${TEST_BLENDER_EXE}
)
endif()
-add_test(export_ply_vertices ${TEST_BLENDER_EXE} # lame, add a better one
+add_test(
+ NAME export_ply_vertices # lame, add a better one
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
${TEST_SRC_DIR}/io_tests/blend_geometry/vertices.blend
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.export_mesh.ply\(filepath='${TEST_OUT_DIR}/export_ply_vertices.ply'\)
@@ -230,21 +277,27 @@ add_test(export_ply_vertices ${TEST_BLENDER_EXE} # lame, add a better one
# STL Import tests
# disabled until updated & working
if(FALSE)
-add_test(import_stl_cube ${TEST_BLENDER_EXE}
+add_test(
+ NAME import_stl_cube
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.import_mesh.stl\(filepath='${TEST_SRC_DIR}/io_tests/stl/cube.stl'\)
--md5=8ceb5bb7e1cb5f4342fa1669988c66b4 --md5_method=SCENE
--write-blend=${TEST_OUT_DIR}/import_stl_cube.blend
)
-add_test(import_stl_conrod ${TEST_BLENDER_EXE}
+add_test(
+ NAME import_stl_conrod
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.import_mesh.stl\(filepath='${TEST_SRC_DIR}/io_tests/stl/conrod.stl'\)
--md5=690a4b8eb9002dcd8631c5a575ea7348 --md5_method=SCENE
--write-blend=${TEST_OUT_DIR}/import_stl_conrod.blend
)
-add_test(import_stl_knot_max_simplified ${TEST_BLENDER_EXE}
+add_test(
+ NAME import_stl_knot_max_simplified
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.import_mesh.stl\(filepath='${TEST_SRC_DIR}/io_tests/stl/knot_max_simplified.stl'\)
--md5=baf82803f45a84ec4ddbad9cef57dd3e --md5_method=SCENE
@@ -255,7 +308,9 @@ endif()
# STL Export
# disabled until updated & working
if(FALSE)
-add_test(export_stl_cube_all_data ${TEST_BLENDER_EXE}
+add_test(
+ NAME export_stl_cube_all_data
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
${TEST_SRC_DIR}/io_tests/blend_geometry/cube_all_data.blend
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.export_mesh.stl\(filepath='${TEST_OUT_DIR}/export_stl_cube_all_data.stl'\)
@@ -263,7 +318,9 @@ add_test(export_stl_cube_all_data ${TEST_BLENDER_EXE}
--md5=64cb97c0cabb015e1c3f76369835075a --md5_method=FILE
)
-add_test(export_stl_suzanne_all_data ${TEST_BLENDER_EXE}
+add_test(
+ NAME export_stl_suzanne_all_data
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
${TEST_SRC_DIR}/io_tests/blend_geometry/suzanne_all_data.blend
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.export_mesh.stl\(filepath='${TEST_OUT_DIR}/export_stl_suzanne_all_data.stl'\)
@@ -271,7 +328,9 @@ add_test(export_stl_suzanne_all_data ${TEST_BLENDER_EXE}
--md5=e9b23c97c139ad64961c635105bb9192 --md5_method=FILE
)
-add_test(export_stl_vertices ${TEST_BLENDER_EXE} # lame, add a better one
+add_test(
+ NAME export_stl_vertices # lame, add a better one
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
${TEST_SRC_DIR}/io_tests/blend_geometry/vertices.blend
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.export_mesh.stl\(filepath='${TEST_OUT_DIR}/export_stl_vertices.stl'\)
@@ -284,21 +343,27 @@ endif()
# X3D Import
# disabled until updated & working
if(FALSE)
-add_test(import_x3d_cube ${TEST_BLENDER_EXE}
+add_test(
+ NAME import_x3d_cube
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.import_scene.x3d\(filepath='${TEST_SRC_DIR}/io_tests/x3d/color_cube.x3d'\)
--md5=3fae9be004199c145941cd3f9f80ad7b --md5_method=SCENE
--write-blend=${TEST_OUT_DIR}/import_x3d_cube.blend
)
-add_test(import_x3d_teapot ${TEST_BLENDER_EXE}
+add_test(
+ NAME import_x3d_teapot
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.import_scene.x3d\(filepath='${TEST_SRC_DIR}/io_tests/x3d/teapot.x3d'\)
--md5=8ee196c71947dce4199d55698501691e --md5_method=SCENE
--write-blend=${TEST_OUT_DIR}/import_x3d_teapot.blend
)
-add_test(import_x3d_suzanne_material ${TEST_BLENDER_EXE}
+add_test(
+ NAME import_x3d_suzanne_material
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.import_scene.x3d\(filepath='${TEST_SRC_DIR}/io_tests/x3d/suzanne_material.x3d'\)
--md5=3edea1353257d8b5a5f071942f417be6 --md5_method=SCENE
@@ -306,7 +371,9 @@ add_test(import_x3d_suzanne_material ${TEST_BLENDER_EXE}
)
# X3D Export
-add_test(export_x3d_cube ${TEST_BLENDER_EXE}
+add_test(
+ NAME export_x3d_cube
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
${TEST_SRC_DIR}/io_tests/blend_geometry/all_quads.blend
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.export_scene.x3d\(filepath='${TEST_OUT_DIR}/export_x3d_cube.x3d',use_selection=False\)
@@ -314,7 +381,9 @@ add_test(export_x3d_cube ${TEST_BLENDER_EXE}
--md5=05312d278fe41da33560fdfb9bdb268f --md5_method=FILE
)
-add_test(export_x3d_nurbs ${TEST_BLENDER_EXE}
+add_test(
+ NAME export_x3d_nurbs
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
${TEST_SRC_DIR}/io_tests/blend_geometry/nurbs.blend
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.export_scene.x3d\(filepath='${TEST_OUT_DIR}/export_x3d_nurbs.x3d',use_selection=False\)
@@ -322,7 +391,9 @@ add_test(export_x3d_nurbs ${TEST_BLENDER_EXE}
--md5=4286d4a2aa507ef78b22ddcbdcc88481 --md5_method=FILE
)
-add_test(export_x3d_all_objects ${TEST_BLENDER_EXE}
+add_test(
+ NAME export_x3d_all_objects
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
${TEST_SRC_DIR}/io_tests/blend_scene/all_objects.blend
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.export_scene.x3d\(filepath='${TEST_OUT_DIR}/export_x3d_all_objects.x3d',use_selection=False\)
@@ -336,21 +407,27 @@ endif()
# 3DS Import
# disabled until updated & working
if(FALSE)
-add_test(import_3ds_cube ${TEST_BLENDER_EXE}
+add_test(
+ NAME import_3ds_cube
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.import_scene.autodesk_3ds\(filepath='${TEST_SRC_DIR}/io_tests/3ds/cube.3ds'\)
--md5=cb5a45c35a343c3f5beca2a918472951 --md5_method=SCENE
--write-blend=${TEST_OUT_DIR}/import_3ds_cube.blend
)
-add_test(import_3ds_hierarchy_lara ${TEST_BLENDER_EXE}
+add_test(
+ NAME import_3ds_hierarchy_lara
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.import_scene.autodesk_3ds\(filepath='${TEST_SRC_DIR}/io_tests/3ds/hierarchy_lara.3ds'\)
--md5=766c873d9fdb5f190e43796cfbae63b6 --md5_method=SCENE
--write-blend=${TEST_OUT_DIR}/import_3ds_hierarchy_lara.blend
)
-add_test(import_3ds_hierarchy_greek_trireme ${TEST_BLENDER_EXE}
+add_test(
+ NAME import_3ds_hierarchy_greek_trireme
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.import_scene.autodesk_3ds\(filepath='${TEST_SRC_DIR}/io_tests/3ds/hierarchy_greek_trireme.3ds'\)
--md5=b62ee30101e8999cb91ef4f8a8760056 --md5_method=SCENE
@@ -361,7 +438,9 @@ endif()
# 3DS Export
# disabled until updated & working
if(FALSE)
-add_test(export_3ds_cube ${TEST_BLENDER_EXE}
+add_test(
+ NAME export_3ds_cube
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
${TEST_SRC_DIR}/io_tests/blend_geometry/all_quads.blend
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.export_scene.autodesk_3ds\(filepath='${TEST_OUT_DIR}/export_3ds_cube.3ds',use_selection=False\)
@@ -369,7 +448,9 @@ add_test(export_3ds_cube ${TEST_BLENDER_EXE}
--md5=a31f5071b6c6dc7445b9099cdc7f63b3 --md5_method=FILE
)
-add_test(export_3ds_nurbs ${TEST_BLENDER_EXE}
+add_test(
+ NAME export_3ds_nurbs
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
${TEST_SRC_DIR}/io_tests/blend_geometry/nurbs.blend
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.export_scene.autodesk_3ds\(filepath='${TEST_OUT_DIR}/export_3ds_nurbs.3ds',use_selection=False\)
@@ -377,7 +458,9 @@ add_test(export_3ds_nurbs ${TEST_BLENDER_EXE}
--md5=5bdd21be3c80d814fbc83cb25edb08c2 --md5_method=FILE
)
-add_test(export_3ds_all_objects ${TEST_BLENDER_EXE}
+add_test(
+ NAME export_3ds_all_objects
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
${TEST_SRC_DIR}/io_tests/blend_scene/all_objects.blend
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.export_scene.autodesk_3ds\(filepath='${TEST_OUT_DIR}/export_3ds_all_objects.3ds',use_selection=False\)
@@ -392,7 +475,9 @@ endif()
# 'use_metadata=False' for reliable md5's
# disabled until updated & working
if(FALSE)
-add_test(export_fbx_cube ${TEST_BLENDER_EXE}
+add_test(
+ NAME export_fbx_cube
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
${TEST_SRC_DIR}/io_tests/blend_geometry/all_quads.blend
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.export_scene.fbx\(filepath='${TEST_OUT_DIR}/export_fbx_cube.fbx',use_selection=False,use_metadata=False\)
@@ -400,7 +485,9 @@ add_test(export_fbx_cube ${TEST_BLENDER_EXE}
--md5=59a35577462f95f9a0b4e6035226ce9b --md5_method=FILE
)
-add_test(export_fbx_nurbs ${TEST_BLENDER_EXE}
+add_test(
+ NAME export_fbx_nurbs
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
${TEST_SRC_DIR}/io_tests/blend_geometry/nurbs.blend
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.export_scene.fbx\(filepath='${TEST_OUT_DIR}/export_fbx_nurbs.fbx',use_selection=False,use_metadata=False\)
@@ -408,7 +495,9 @@ add_test(export_fbx_nurbs ${TEST_BLENDER_EXE}
--md5=d31875f18f613fa0c3b16e978f87f6f8 --md5_method=FILE
)
-add_test(export_fbx_all_objects ${TEST_BLENDER_EXE}
+add_test(
+ NAME export_fbx_all_objects
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
${TEST_SRC_DIR}/io_tests/blend_scene/all_objects.blend
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.export_scene.fbx\(filepath='${TEST_OUT_DIR}/export_fbx_all_objects.fbx',use_selection=False,use_metadata=False\)
@@ -421,31 +510,44 @@ if(WITH_CYCLES)
if(OPENIMAGEIO_IDIFF AND EXISTS "${TEST_SRC_DIR}/cycles/ctests/shader")
macro(add_cycles_render_test subject)
if(MSVC)
- add_test(NAME cycles_${subject}_test
+ add_test(
+ NAME cycles_${subject}_test
COMMAND
"$<TARGET_FILE_DIR:blender>/${BLENDER_VERSION_MAJOR}.${BLENDER_VERSION_MINOR}/python/bin/python$<$<CONFIG:Debug>:_d>"
${CMAKE_CURRENT_LIST_DIR}/cycles_render_tests.py
-blender "$<TARGET_FILE:blender>"
-testdir "${TEST_SRC_DIR}/cycles/ctests/${subject}"
-idiff "${OPENIMAGEIO_IDIFF}"
+ -outdir "${TEST_OUT_DIR}/cycles"
)
else()
- add_test(cycles_${subject}_test
- ${CMAKE_CURRENT_LIST_DIR}/cycles_render_tests.py
- -blender "${TEST_BLENDER_EXE_BARE}"
+ add_test(
+ NAME cycles_${subject}_test
+ COMMAND ${CMAKE_CURRENT_LIST_DIR}/cycles_render_tests.py
+ -blender "$<TARGET_FILE:blender>"
-testdir "${TEST_SRC_DIR}/cycles/ctests/${subject}"
-idiff "${OPENIMAGEIO_IDIFF}"
+ -outdir "${TEST_OUT_DIR}/cycles"
)
endif()
endmacro()
if(WITH_OPENGL_TESTS)
add_cycles_render_test(opengl)
endif()
- add_cycles_render_test(image)
+ add_cycles_render_test(bake)
+ add_cycles_render_test(denoise)
+ add_cycles_render_test(displacement)
+ add_cycles_render_test(image_data_types)
+ add_cycles_render_test(image_mapping)
+ add_cycles_render_test(image_texture_limit)
+ add_cycles_render_test(light)
add_cycles_render_test(mblur)
add_cycles_render_test(reports)
add_cycles_render_test(render)
add_cycles_render_test(shader)
+ add_cycles_render_test(shader_tangent)
+ add_cycles_render_test(shadow_catcher)
+ add_cycles_render_test(volume)
else()
MESSAGE(STATUS "Disabling Cycles tests because tests folder does not exist")
endif()
@@ -460,7 +562,9 @@ if(WITH_ALEMBIC)
get_filename_component(ALEMBIC_ROOT_DIR ${real_include_dir} DIRECTORY)
if(MSVC)
- add_test(NAME alembic_tests
+ # FIXME, de-duplicate.
+ add_test(
+ NAME alembic_tests
COMMAND
"$<TARGET_FILE_DIR:blender>/${BLENDER_VERSION_MAJOR}.${BLENDER_VERSION_MINOR}/python/bin/python$<$<CONFIG:Debug>:_d>"
${CMAKE_CURRENT_LIST_DIR}/alembic_tests.py
@@ -468,30 +572,24 @@ if(WITH_ALEMBIC)
--testdir "${TEST_SRC_DIR}/alembic"
--alembic-root "${ALEMBIC_ROOT_DIR}"
)
- add_test(NAME script_alembic_import
- COMMAND
- "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
- --python ${CMAKE_CURRENT_LIST_DIR}/bl_alembic_import_test.py
- --
- --testdir "${TEST_SRC_DIR}/alembic"
- --with-legacy-depsgraph=${WITH_LEGACY_DEPSGRAPH}
- )
-
else()
- add_test(alembic_tests
- ${CMAKE_CURRENT_LIST_DIR}/alembic_tests.py
- --blender "${TEST_BLENDER_EXE_BARE}"
+ add_test(
+ NAME alembic_tests
+ COMMAND ${CMAKE_CURRENT_LIST_DIR}/alembic_tests.py
+ --blender "$<TARGET_FILE:blender>"
--testdir "${TEST_SRC_DIR}/alembic"
--alembic-root "${ALEMBIC_ROOT_DIR}"
)
- add_test(script_alembic_import ${TEST_BLENDER_EXE}
+ endif()
+
+ add_test(
+ NAME script_alembic_import
+ COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS}
--python ${CMAKE_CURRENT_LIST_DIR}/bl_alembic_import_test.py
--
--testdir "${TEST_SRC_DIR}/alembic"
--with-legacy-depsgraph=${WITH_LEGACY_DEPSGRAPH}
- )
-
- endif()
+ )
endif()
add_subdirectory(render_layer)
diff --git a/tests/python/batch_import.py b/tests/python/batch_import.py
index bbe3a70327f..a6e2469349b 100644
--- a/tests/python/batch_import.py
+++ b/tests/python/batch_import.py
@@ -72,10 +72,8 @@ def batch_import(
def file_generator(path):
for dirpath, dirnames, filenames in os.walk(path):
-
- # skip '.svn'
- if dirpath.startswith("."):
- continue
+ # skip '.git'
+ dirnames[:] = [d for d in dirnames if not d.startswith(".")]
for filename in filenames:
if pattern_match(filename):
diff --git a/tests/python/bl_alembic_import_test.py b/tests/python/bl_alembic_import_test.py
index 2f3daaefd44..e64da2fe540 100644
--- a/tests/python/bl_alembic_import_test.py
+++ b/tests/python/bl_alembic_import_test.py
@@ -75,6 +75,39 @@ class SimpleImportTest(AbstractAlembicTest):
self.assertEqual(objects['Cube_003'], objects['Cube_005'].parent)
self.assertEqual(objects['Cube_003'], objects['Cube_006'].parent)
+ def test_inherit_or_not(self):
+ res = bpy.ops.wm.alembic_import(
+ filepath=str(self.testdir / "T52022-inheritance.abc"),
+ as_background_job=False)
+ self.assertEqual({'FINISHED'}, res)
+
+ # The objects should be linked to scene_collection in Blender 2.8,
+ # and to scene in Blender 2.7x.
+ objects = bpy.context.scene_collection.objects
+
+ # ABC parent is top-level object, which translates to nothing in Blender
+ self.assertIsNone(objects['locator1'].parent)
+
+ # ABC parent is locator1, but locator2 has "inherits Xforms" = false, which
+ # translates to "no parent" in Blender.
+ self.assertIsNone(objects['locator2'].parent)
+
+ # Shouldn't have inherited the ABC parent's transform.
+ x, y, z = objects['locator2'].matrix_world.to_translation()
+ self.assertAlmostEqual(0, x)
+ self.assertAlmostEqual(0, y)
+ self.assertAlmostEqual(2, z)
+
+ # ABC parent is inherited and translates to normal parent in Blender.
+ self.assertEqual(objects['locator2'], objects['locatorShape2'].parent)
+
+ # Should have inherited its ABC parent's transform.
+ x, y, z = objects['locatorShape2'].matrix_world.to_translation()
+ self.assertAlmostEqual(0, x)
+ self.assertAlmostEqual(0, y)
+ self.assertAlmostEqual(2, z)
+
+
def test_select_after_import(self):
# Add a sphere, so that there is something in the scene, selected, and active,
# before we do the Alembic import.
@@ -146,22 +179,26 @@ class SimpleImportTest(AbstractAlembicTest):
res = bpy.ops.wm.alembic_import(filepath=str(abc), as_background_job=False)
self.assertEqual({'FINISHED'}, res)
- cube = bpy.context.active_object
+ plane = bpy.context.active_object
# Check that the file loaded ok.
bpy.context.scene.frame_set(6)
- self.assertAlmostEqual(-1, cube.data.vertices[0].co.x)
- self.assertAlmostEqual(-1, cube.data.vertices[0].co.y)
- self.assertAlmostEqual(0.5905638933181763, cube.data.vertices[0].co.z)
+ scene = bpy.context.scene
+ layer = scene.render_layers[scene.active_layer]
+ mesh = plane.to_mesh(scene, layer, True, 'RENDER')
+ self.assertAlmostEqual(-1, mesh.vertices[0].co.x)
+ self.assertAlmostEqual(-1, mesh.vertices[0].co.y)
+ self.assertAlmostEqual(0.5905638933181763, mesh.vertices[0].co.z)
# Change path from absolute to relative. This should not break the animation.
- bpy.context.scene.frame_set(1)
+ scene.frame_set(1)
bpy.data.cache_files[fname].filepath = relpath
- bpy.context.scene.frame_set(6)
+ scene.frame_set(6)
- self.assertAlmostEqual(1, cube.data.vertices[3].co.x)
- self.assertAlmostEqual(1, cube.data.vertices[3].co.y)
- self.assertAlmostEqual(0.5905638933181763, cube.data.vertices[3].co.z)
+ mesh = plane.to_mesh(scene, layer, True, 'RENDER')
+ self.assertAlmostEqual(1, mesh.vertices[3].co.x)
+ self.assertAlmostEqual(1, mesh.vertices[3].co.y)
+ self.assertAlmostEqual(0.5905638933181763, mesh.vertices[3].co.z)
def test_import_long_names(self):
# This file contains very long names. The longest name is 4047 chars.
diff --git a/tests/python/bl_load_py_modules.py b/tests/python/bl_load_py_modules.py
index 4935491a6be..39e7bd33d44 100644
--- a/tests/python/bl_load_py_modules.py
+++ b/tests/python/bl_load_py_modules.py
@@ -38,7 +38,7 @@ BLACKLIST = {
'io_import_dxf', # Because of cydxfentity.so dependency
# The unpacked wheel is only loaded when actually used, not directly on import:
- "io_blend_utils/blender_bam-unpacked.whl",
+ os.path.join("io_blend_utils", "blender_bam-unpacked.whl"),
}
# Some modules need to add to the `sys.path`.
@@ -93,9 +93,8 @@ def addon_modules_sorted():
def source_list(path, filename_check=None):
from os.path import join
for dirpath, dirnames, filenames in os.walk(path):
- # skip '.svn'
- if dirpath.startswith("."):
- continue
+ # skip '.git'
+ dirnames[:] = [d for d in dirnames if not d.startswith(".")]
for filename in filenames:
filepath = join(dirpath, filename)
@@ -123,6 +122,8 @@ def load_addons():
def load_modules():
+ VERBOSE = os.environ.get("BLENDER_VERBOSE") is not None
+
modules = []
module_paths = []
@@ -162,6 +163,14 @@ def load_modules():
del module_names
#
+ # test we tested all files except for presets and templates
+ ignore_paths = [
+ os.sep + "presets" + os.sep,
+ os.sep + "templates" + os.sep,
+ ] + ([(os.sep + f + os.sep) for f in BLACKLIST] +
+ [(os.sep + f + ".py") for f in BLACKLIST])
+
+ #
# now submodules
for m in modules:
filepath = m.__file__
@@ -178,15 +187,35 @@ def load_modules():
for f in MODULE_SYS_PATHS.get(mod_name_full, ())
])
- __import__(mod_name_full)
- mod_imp = sys.modules[mod_name_full]
-
- sys.path[:] = sys_path_back
-
- # check we load what we ask for.
- assert(os.path.samefile(mod_imp.__file__, submod_full))
-
- modules.append(mod_imp)
+ try:
+ __import__(mod_name_full)
+ mod_imp = sys.modules[mod_name_full]
+
+ sys.path[:] = sys_path_back
+
+ # check we load what we ask for.
+ assert(os.path.samefile(mod_imp.__file__, submod_full))
+
+ modules.append(mod_imp)
+ except Exception as e:
+ import traceback
+ # Module might fail to import, but we don't want whole test to fail here.
+ # Reasoning:
+ # - This module might be in ignored list (for example, preset or template),
+ # so failing here will cause false-positive test failure.
+ # - If this is module which should not be ignored, it is not added to list
+ # of successfully loaded modules, meaning the test will catch this
+ # import failure.
+ # - We want to catch all failures of this script instead of stopping on
+ # a first big failure.
+ do_print = True
+ if not VERBOSE:
+ for ignore in ignore_paths:
+ if ignore in submod_full:
+ do_print = False
+ break
+ if do_print:
+ traceback.print_exc()
#
# check which filepaths we didn't load
@@ -205,14 +234,6 @@ def load_modules():
for f in loaded_files:
source_files.remove(f)
- #
- # test we tested all files except for presets and templates
- ignore_paths = [
- os.sep + "presets" + os.sep,
- os.sep + "templates" + os.sep,
- ] + ([(os.sep + f + os.sep) for f in BLACKLIST] +
- [(os.sep + f + ".py") for f in BLACKLIST])
-
for f in source_files:
for ignore in ignore_paths:
if ignore in f:
diff --git a/tests/python/bl_pyapi_bpy_utils_units.py b/tests/python/bl_pyapi_bpy_utils_units.py
index f40dab4b5eb..251419cb9ef 100644
--- a/tests/python/bl_pyapi_bpy_utils_units.py
+++ b/tests/python/bl_pyapi_bpy_utils_units.py
@@ -32,18 +32,17 @@ class UnitsTesting(unittest.TestCase):
OUTPUT_TESTS = (
# system, type, prec, sep, compat, value, output
##### LENGTH
+ # Note: precision handling is a bit complicated when using multi-units...
('IMPERIAL', 'LENGTH', 3, False, False, 0.3048, "1'"),
('IMPERIAL', 'LENGTH', 3, False, True, 0.3048, "1ft"),
- ('IMPERIAL', 'LENGTH', 3, True, False, 0.3048 * 2 + 0.0254 * 5.5, "2' 5.5\""),
- # Those next two fail, here again because precision ignores order magnitude :/
- #('IMPERIAL', 'LENGTH', 3, False, False, 1609.344 * 1e6, "1000000mi"), # == 1000000.004mi!!!
- #('IMPERIAL', 'LENGTH', 6, False, False, 1609.344 * 1e6, "1000000mi"), # == 1000000.003641mi!!!
- ('METRIC', 'LENGTH', 3, True, False, 1000 * 2 + 0.001 * 15, "2km 1.5cm"),
- ('METRIC', 'LENGTH', 3, True, False, 1234.56789, "1km 234.6m"),
- # Note: precision seems basically unused when using multi units!
- ('METRIC', 'LENGTH', 9, True, False, 1234.56789, "1km 234.6m"),
- ('METRIC', 'LENGTH', 9, False, False, 1234.56789, "1.23456789km"),
- ('METRIC', 'LENGTH', 9, True, False, 1000.000123456789, "1km 0.1mm"),
+ ('IMPERIAL', 'LENGTH', 4, True, False, 0.3048 * 2 + 0.0254 * 5.5, "2' 5.5\""),
+ ('IMPERIAL', 'LENGTH', 3, False, False, 1609.344 * 1e6, "1000000mi"),
+ ('IMPERIAL', 'LENGTH', 6, False, False, 1609.344 * 1e6, "1000000mi"),
+ ('METRIC', 'LENGTH', 3, True, False, 1000 * 2 + 0.001 * 15, "2km 2cm"),
+ ('METRIC', 'LENGTH', 5, True, False, 1234.56789, "1km 234.6m"),
+ ('METRIC', 'LENGTH', 6, True, False, 1234.56789, "1km 234.57m"),
+ ('METRIC', 'LENGTH', 9, False, False, 1234.56789, "1.234568km"),
+ ('METRIC', 'LENGTH', 9, True, False, 1000.000123456789, "1km 0.123mm"),
)
def test_units_inputs(self):
diff --git a/tests/python/bl_run_operators.py b/tests/python/bl_run_operators.py
index 7d5f4127378..7b6b97e5ad1 100644
--- a/tests/python/bl_run_operators.py
+++ b/tests/python/bl_run_operators.py
@@ -100,10 +100,8 @@ def blend_list(mainpath):
def file_list(path, filename_check=None):
for dirpath, dirnames, filenames in os.walk(path):
-
- # skip '.svn'
- if dirpath.startswith("."):
- continue
+ # skip '.git'
+ dirnames[:] = [d for d in dirnames if not d.startswith(".")]
for filename in filenames:
filepath = join(dirpath, filename)
diff --git a/tests/python/cycles_render_tests.py b/tests/python/cycles_render_tests.py
index a030cc5e0de..2122150467c 100755
--- a/tests/python/cycles_render_tests.py
+++ b/tests/python/cycles_render_tests.py
@@ -2,7 +2,10 @@
# Apache License, Version 2.0
import argparse
+import glob
import os
+import pathlib
+import shlex
import shutil
import subprocess
import sys
@@ -24,7 +27,7 @@ class COLORS_DUMMY:
COLORS = COLORS_DUMMY
-def printMessage(type, status, message):
+def print_message(message, type=None, status=''):
if type == 'SUCCESS':
print(COLORS.GREEN, end="")
elif type == 'FAILURE':
@@ -50,38 +53,60 @@ def render_file(filepath):
dirname = os.path.dirname(filepath)
basedir = os.path.dirname(dirname)
subject = os.path.basename(dirname)
+
+ custom_args = os.getenv('CYCLESTEST_ARGS')
+ custom_args = shlex.split(custom_args) if custom_args else []
+
+ # OSL and GPU examples
+ # custom_args += ["--python-expr", "import bpy; bpy.context.scene.cycles.shading_system = True"]
+ # custom_args += ["--python-expr", "import bpy; bpy.context.scene.cycles.device = 'GPU'"]
+
if subject == 'opengl':
- command = (
+ command = [
BLENDER,
"--window-geometry", "0", "0", "1", "1",
"-noaudio",
"--factory-startup",
"--enable-autoexec",
filepath,
- "-E", "CYCLES",
- # Run with OSL enabled
- # "--python-expr", "import bpy; bpy.context.scene.cycles.shading_system = True",
+ "-E", "CYCLES"]
+ command += custom_args
+ command += [
"-o", TEMP_FILE_MASK,
"-F", "PNG",
'--python', os.path.join(basedir,
"util",
- "render_opengl.py")
- )
+ "render_opengl.py")]
+ elif subject == 'bake':
+ command = [
+ BLENDER,
+ "-b",
+ "-noaudio",
+ "--factory-startup",
+ "--enable-autoexec",
+ filepath,
+ "-E", "CYCLES"]
+ command += custom_args
+ command += [
+ "-o", TEMP_FILE_MASK,
+ "-F", "PNG",
+ '--python', os.path.join(basedir,
+ "util",
+ "render_bake.py")]
else:
- command = (
+ command = [
BLENDER,
"--background",
"-noaudio",
"--factory-startup",
"--enable-autoexec",
filepath,
- "-E", "CYCLES",
- # Run with OSL enabled
- # "--python-expr", "import bpy; bpy.context.scene.cycles.shading_system = True",
+ "-E", "CYCLES"]
+ command += custom_args
+ command += [
"-o", TEMP_FILE_MASK,
"-F", "PNG",
- "-f", "1",
- )
+ "-f", "1"]
try:
output = subprocess.check_output(command)
if VERBOSE:
@@ -109,68 +134,241 @@ def test_get_name(filepath):
filename = os.path.basename(filepath)
return os.path.splitext(filename)[0]
-
-def verify_output(filepath):
+def test_get_images(filepath):
testname = test_get_name(filepath)
dirpath = os.path.dirname(filepath)
- reference_dirpath = os.path.join(dirpath, "reference_renders")
- reference_image = os.path.join(reference_dirpath, testname + ".png")
- failed_image = os.path.join(reference_dirpath, testname + ".fail.png")
- if not os.path.exists(reference_image):
- return False
+
+ old_dirpath = os.path.join(dirpath, "reference_renders")
+ old_img = os.path.join(old_dirpath, testname + ".png")
+
+ ref_dirpath = os.path.join(OUTDIR, os.path.basename(dirpath), "ref")
+ ref_img = os.path.join(ref_dirpath, testname + ".png")
+ if not os.path.exists(ref_dirpath):
+ os.makedirs(ref_dirpath)
+ if os.path.exists(old_img):
+ shutil.copy(old_img, ref_img)
+
+ new_dirpath = os.path.join(OUTDIR, os.path.basename(dirpath))
+ if not os.path.exists(new_dirpath):
+ os.makedirs(new_dirpath)
+ new_img = os.path.join(new_dirpath, testname + ".png")
+
+ diff_dirpath = os.path.join(OUTDIR, os.path.basename(dirpath), "diff")
+ if not os.path.exists(diff_dirpath):
+ os.makedirs(diff_dirpath)
+ diff_img = os.path.join(diff_dirpath, testname + ".diff.png")
+
+ return old_img, ref_img, new_img, diff_img
+
+
+class Report:
+ def __init__(self, testname):
+ self.failed_tests = ""
+ self.passed_tests = ""
+ self.testname = testname
+
+ def output(self):
+ # write intermediate data for single test
+ outdir = os.path.join(OUTDIR, self.testname)
+ if not os.path.exists(outdir):
+ os.makedirs(outdir)
+
+ filepath = os.path.join(outdir, "failed.data")
+ pathlib.Path(filepath).write_text(self.failed_tests)
+
+ filepath = os.path.join(outdir, "passed.data")
+ pathlib.Path(filepath).write_text(self.passed_tests)
+
+ # gather intermediate data for all tests
+ failed_data = sorted(glob.glob(os.path.join(OUTDIR, "*/failed.data")))
+ passed_data = sorted(glob.glob(os.path.join(OUTDIR, "*/passed.data")))
+
+ failed_tests = ""
+ passed_tests = ""
+
+ for filename in failed_data:
+ filepath = os.path.join(OUTDIR, filename)
+ failed_tests += pathlib.Path(filepath).read_text()
+ for filename in passed_data:
+ filepath = os.path.join(OUTDIR, filename)
+ passed_tests += pathlib.Path(filepath).read_text()
+
+ # write html for all tests
+ self.html = """
+<html>
+<head>
+ <title>Cycles Test Report</title>
+ <style>
+ img {{ image-rendering: pixelated; width: 256px; background-color: #000; }}
+ img.render {{
+ background-color: #fff;
+ background-image:
+ -moz-linear-gradient(45deg, #eee 25%, transparent 25%),
+ -moz-linear-gradient(-45deg, #eee 25%, transparent 25%),
+ -moz-linear-gradient(45deg, transparent 75%, #eee 75%),
+ -moz-linear-gradient(-45deg, transparent 75%, #eee 75%);
+ background-image:
+ -webkit-gradient(linear, 0 100%, 100% 0, color-stop(.25, #eee), color-stop(.25, transparent)),
+ -webkit-gradient(linear, 0 0, 100% 100%, color-stop(.25, #eee), color-stop(.25, transparent)),
+ -webkit-gradient(linear, 0 100%, 100% 0, color-stop(.75, transparent), color-stop(.75, #eee)),
+ -webkit-gradient(linear, 0 0, 100% 100%, color-stop(.75, transparent), color-stop(.75, #eee));
+
+ -moz-background-size:50px 50px;
+ background-size:50px 50px;
+ -webkit-background-size:50px 51px; /* override value for shitty webkit */
+
+ background-position:0 0, 25px 0, 25px -25px, 0px 25px;
+ }}
+ table td:first-child {{ width: 256px; }}
+ </style>
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css">
+</head>
+<body>
+ <div class="container">
+ <br/>
+ <h1>Cycles Test Report</h1>
+ <br/>
+ <table class="table table-striped">
+ <thead class="thead-default">
+ <tr><th>Name</th><th>New</th><th>Reference</th><th>Diff</th>
+ </thead>
+ {}{}
+ </table>
+ <br/>
+ </div>
+</body>
+</html>
+ """ . format(failed_tests, passed_tests)
+
+ filepath = os.path.join(OUTDIR, "report.html")
+ pathlib.Path(filepath).write_text(self.html)
+
+ print_message("Report saved to: " + pathlib.Path(filepath).as_uri())
+
+ def relative_url(self, filepath):
+ relpath = os.path.relpath(filepath, OUTDIR)
+ return pathlib.Path(relpath).as_posix()
+
+ def add_test(self, filepath, error):
+ name = test_get_name(filepath)
+ name = name.replace('_', ' ')
+
+ old_img, ref_img, new_img, diff_img = test_get_images(filepath)
+
+ status = error if error else ""
+ style = """ style="background-color: #f99;" """ if error else ""
+
+ new_url = self.relative_url(new_img)
+ ref_url = self.relative_url(ref_img)
+ diff_url = self.relative_url(diff_img)
+
+ test_html = """
+ <tr{}>
+ <td><b>{}</b><br/>{}<br/>{}</td>
+ <td><img src="{}" onmouseover="this.src='{}';" onmouseout="this.src='{}';" class="render"></td>
+ <td><img src="{}" onmouseover="this.src='{}';" onmouseout="this.src='{}';" class="render"></td>
+ <td><img src="{}"></td>
+ </tr>""" . format(style, name, self.testname, status,
+ new_url, ref_url, new_url,
+ ref_url, new_url, ref_url,
+ diff_url)
+
+ if error:
+ self.failed_tests += test_html
+ else:
+ self.passed_tests += test_html
+
+
+def verify_output(report, filepath):
+ old_img, ref_img, new_img, diff_img = test_get_images(filepath)
+
+ # copy new image
+ if os.path.exists(new_img):
+ os.remove(new_img)
+ if os.path.exists(TEMP_FILE):
+ shutil.copy(TEMP_FILE, new_img)
+
+ update = os.getenv('CYCLESTEST_UPDATE')
+
+ if os.path.exists(ref_img):
+ # diff test with threshold
+ command = (
+ IDIFF,
+ "-fail", "0.016",
+ "-failpercent", "1",
+ ref_img,
+ TEMP_FILE,
+ )
+ try:
+ subprocess.check_output(command)
+ failed = False
+ except subprocess.CalledProcessError as e:
+ if VERBOSE:
+ print_message(e.output.decode("utf-8"))
+ failed = e.returncode != 1
+ else:
+ if not update:
+ return False
+
+ failed = True
+
+ if failed and update:
+ # update reference
+ shutil.copy(new_img, ref_img)
+ shutil.copy(new_img, old_img)
+ failed = False
+
+ # generate diff image
command = (
IDIFF,
- "-fail", "0.015",
- "-failpercent", "1",
- reference_image,
- TEMP_FILE,
+ "-o", diff_img,
+ "-abs", "-scale", "16",
+ ref_img,
+ TEMP_FILE
)
+
try:
subprocess.check_output(command)
- failed = False
except subprocess.CalledProcessError as e:
if VERBOSE:
- print(e.output.decode("utf-8"))
- failed = e.returncode != 1
- if failed:
- shutil.copy(TEMP_FILE, failed_image)
- elif os.path.exists(failed_image):
- os.remove(failed_image)
+ print_message(e.output.decode("utf-8"))
+
return not failed
-def run_test(filepath):
+def run_test(report, filepath):
testname = test_get_name(filepath)
spacer = "." * (32 - len(testname))
- printMessage('SUCCESS', 'RUN', testname)
+ print_message(testname, 'SUCCESS', 'RUN')
time_start = time.time()
error = render_file(filepath)
status = "FAIL"
if not error:
- if not verify_output(filepath):
+ if not verify_output(report, filepath):
error = "VERIFY"
time_end = time.time()
elapsed_ms = int((time_end - time_start) * 1000)
if not error:
- printMessage('SUCCESS', 'OK', "{} ({} ms)" .
- format(testname, elapsed_ms))
+ print_message("{} ({} ms)" . format(testname, elapsed_ms),
+ 'SUCCESS', 'OK')
else:
if error == "NO_CYCLES":
- print("Can't perform tests because Cycles failed to load!")
- return False
+ print_message("Can't perform tests because Cycles failed to load!")
+ return error
elif error == "NO_START":
- print('Can not perform tests because blender fails to start.',
+ print_message('Can not perform tests because blender fails to start.',
'Make sure INSTALL target was run.')
- return False
+ return error
elif error == 'VERIFY':
- print("Rendered result is different from reference image")
+ print_message("Rendered result is different from reference image")
else:
- print("Unknown error %r" % error)
- printMessage('FAILURE', 'FAILED', "{} ({} ms)" .
- format(testname, elapsed_ms))
+ print_message("Unknown error %r" % error)
+ print_message("{} ({} ms)" . format(testname, elapsed_ms),
+ 'FAILURE', 'FAILED')
return error
+
def blend_list(path):
for dirpath, dirnames, filenames in os.walk(path):
for filename in filenames:
@@ -178,17 +376,18 @@ def blend_list(path):
filepath = os.path.join(dirpath, filename)
yield filepath
-
def run_all_tests(dirpath):
passed_tests = []
failed_tests = []
all_files = list(blend_list(dirpath))
all_files.sort()
- printMessage('SUCCESS', "==========",
- "Running {} tests from 1 test case." . format(len(all_files)))
+ report = Report(os.path.basename(dirpath))
+ print_message("Running {} tests from 1 test case." .
+ format(len(all_files)),
+ 'SUCCESS', "==========")
time_start = time.time()
for filepath in all_files:
- error = run_test(filepath)
+ error = run_test(report, filepath)
testname = test_get_name(filepath)
if error:
if error == "NO_CYCLES":
@@ -198,28 +397,33 @@ def run_all_tests(dirpath):
failed_tests.append(testname)
else:
passed_tests.append(testname)
+ report.add_test(filepath, error)
time_end = time.time()
elapsed_ms = int((time_end - time_start) * 1000)
- print("")
- printMessage('SUCCESS', "==========",
- "{} tests from 1 test case ran. ({} ms total)" .
- format(len(all_files), elapsed_ms))
- printMessage('SUCCESS', 'PASSED', "{} tests." .
- format(len(passed_tests)))
+ print_message("")
+ print_message("{} tests from 1 test case ran. ({} ms total)" .
+ format(len(all_files), elapsed_ms),
+ 'SUCCESS', "==========")
+ print_message("{} tests." .
+ format(len(passed_tests)),
+ 'SUCCESS', 'PASSED')
if failed_tests:
- printMessage('FAILURE', 'FAILED', "{} tests, listed below:" .
- format(len(failed_tests)))
+ print_message("{} tests, listed below:" .
+ format(len(failed_tests)),
+ 'FAILURE', 'FAILED')
failed_tests.sort()
for test in failed_tests:
- printMessage('FAILURE', "FAILED", "{}" . format(test))
- return False
- return True
+ print_message("{}" . format(test), 'FAILURE', "FAILED")
+
+ report.output()
+ return not bool(failed_tests)
def create_argparse():
parser = argparse.ArgumentParser()
parser.add_argument("-blender", nargs="+")
parser.add_argument("-testdir", nargs=1)
+ parser.add_argument("-outdir", nargs=1)
parser.add_argument("-idiff", nargs=1)
return parser
@@ -229,7 +433,7 @@ def main():
args = parser.parse_args()
global COLORS
- global BLENDER, ROOT, IDIFF
+ global BLENDER, TESTDIR, IDIFF, OUTDIR
global TEMP_FILE, TEMP_FILE_MASK, TEST_SCRIPT
global VERBOSE
@@ -237,8 +441,12 @@ def main():
COLORS = COLORS_ANSI
BLENDER = args.blender[0]
- ROOT = args.testdir[0]
+ TESTDIR = args.testdir[0]
IDIFF = args.idiff[0]
+ OUTDIR = args.outdir[0]
+
+ if not os.path.exists(OUTDIR):
+ os.makedirs(OUTDIR)
TEMP = tempfile.mkdtemp()
TEMP_FILE_MASK = os.path.join(TEMP, "test")
@@ -248,7 +456,7 @@ def main():
VERBOSE = os.environ.get("BLENDER_VERBOSE") is not None
- ok = run_all_tests(ROOT)
+ ok = run_all_tests(TESTDIR)
# Cleanup temp files and folders
if os.path.exists(TEMP_FILE):
diff --git a/tests/python/render_layer/CMakeLists.txt b/tests/python/render_layer/CMakeLists.txt
index 526b169bc3d..5ff985073e3 100644
--- a/tests/python/render_layer/CMakeLists.txt
+++ b/tests/python/render_layer/CMakeLists.txt
@@ -170,4 +170,6 @@ RENDER_LAYER_TEST(scene_copy_b)
RENDER_LAYER_TEST(scene_copy_c)
RENDER_LAYER_TEST(scene_copy_d)
RENDER_LAYER_TEST(scene_copy_e)
+RENDER_LAYER_TEST(scene_copy_f)
+RENDER_LAYER_TEST(scene_delete)
RENDER_LAYER_TEST(scene_write_read)
diff --git a/tests/python/render_layer/render_layer_common.py b/tests/python/render_layer/render_layer_common.py
index f6e16459ed3..adc32f062ea 100644
--- a/tests/python/render_layer/render_layer_common.py
+++ b/tests/python/render_layer/render_layer_common.py
@@ -55,9 +55,15 @@ def get_layer(layer):
name = layer.get(b'name')
data['name'] = name
- data['active_object'] = layer.get((b'basact', b'object', b'id', b'name'))[2:]
data['engine'] = layer.get(b'engine')
+ active_base = layer.get_pointer(b'basact')
+ if active_base:
+ ob = active_base.get_pointer(b'object')
+ data['active_object'] = ob.get((b'id', b'name'))[2:]
+ else:
+ data['active_object'] = ""
+
objects = []
for link in linkdata_iter(layer, b'object_bases'):
ob = link.get_pointer(b'object')
@@ -747,6 +753,7 @@ class Clay:
layer = self._scene.render_layers.new('Evaluation Test')
layer.collections.unlink(layer.collections[0])
+ self._scene.render_layers.active = layer
bpy.context.workspace.render_layer = layer
# remove all other layers
diff --git a/tests/python/render_layer/test_evaluation_selectability_a.py b/tests/python/render_layer/test_evaluation_selectability_a.py
index 6faebac79aa..393f406eefc 100644
--- a/tests/python/render_layer/test_evaluation_selectability_a.py
+++ b/tests/python/render_layer/test_evaluation_selectability_a.py
@@ -26,6 +26,7 @@ class UnitTesting(RenderLayerTesting):
layer = scene.render_layers.new('Selectability Test')
layer.collections.unlink(layer.collections[0])
+ scene.render_layers.active = layer
workspace.render_layer = layer
scene_collection_mom = scene.master_collection.collections.new("Mom")
diff --git a/tests/python/render_layer/test_evaluation_selectability_b.py b/tests/python/render_layer/test_evaluation_selectability_b.py
index f2a11865d09..ea05710ebcf 100644
--- a/tests/python/render_layer/test_evaluation_selectability_b.py
+++ b/tests/python/render_layer/test_evaluation_selectability_b.py
@@ -26,6 +26,7 @@ class UnitTesting(RenderLayerTesting):
layer = scene.render_layers.new('Selectability Test')
layer.collections.unlink(layer.collections[0])
+ scene.render_layers.active = layer
workspace.render_layer = layer
scene_collection_mom = scene.master_collection.collections.new("Mom")
diff --git a/tests/python/render_layer/test_evaluation_selectability_c.py b/tests/python/render_layer/test_evaluation_selectability_c.py
index 5ec6d6e7d9c..8487ee1a8af 100644
--- a/tests/python/render_layer/test_evaluation_selectability_c.py
+++ b/tests/python/render_layer/test_evaluation_selectability_c.py
@@ -26,6 +26,7 @@ class UnitTesting(RenderLayerTesting):
layer = scene.render_layers.new('Selectability Test')
layer.collections.unlink(layer.collections[0])
+ scene.render_layers.active = layer
workspace.render_layer = layer
scene_collection_mom = scene.master_collection.collections.new("Mom")
diff --git a/tests/python/render_layer/test_evaluation_selectability_d.py b/tests/python/render_layer/test_evaluation_selectability_d.py
index 3ce9c07c907..b2a924dd6bc 100644
--- a/tests/python/render_layer/test_evaluation_selectability_d.py
+++ b/tests/python/render_layer/test_evaluation_selectability_d.py
@@ -26,6 +26,7 @@ class UnitTesting(RenderLayerTesting):
layer = scene.render_layers.new('Selectability Test')
layer.collections.unlink(layer.collections[0])
+ scene.render_layers.active = layer
workspace.render_layer = layer
scene_collection_mom = scene.master_collection.collections.new("Mom")
diff --git a/tests/python/render_layer/test_evaluation_selectability_e.py b/tests/python/render_layer/test_evaluation_selectability_e.py
index df308845292..70ede58cb9e 100644
--- a/tests/python/render_layer/test_evaluation_selectability_e.py
+++ b/tests/python/render_layer/test_evaluation_selectability_e.py
@@ -26,6 +26,7 @@ class UnitTesting(RenderLayerTesting):
layer = scene.render_layers.new('Selectability Test')
layer.collections.unlink(layer.collections[0])
+ scene.render_layers.active = layer
workspace.render_layer = layer
scene_collection_mom = scene.master_collection.collections.new("Mom")
diff --git a/tests/python/render_layer/test_evaluation_visibility_a.py b/tests/python/render_layer/test_evaluation_visibility_a.py
index a3a6bb261f5..b9f57539330 100644
--- a/tests/python/render_layer/test_evaluation_visibility_a.py
+++ b/tests/python/render_layer/test_evaluation_visibility_a.py
@@ -26,6 +26,7 @@ class UnitTesting(RenderLayerTesting):
layer = scene.render_layers.new('Visibility Test')
layer.collections.unlink(layer.collections[0])
+ scene.render_layers.active = layer
workspace.render_layer = layer
scene_collection_mom = scene.master_collection.collections.new("Mom")
diff --git a/tests/python/render_layer/test_evaluation_visibility_b.py b/tests/python/render_layer/test_evaluation_visibility_b.py
index 4f81cd540e2..712cc9bd277 100644
--- a/tests/python/render_layer/test_evaluation_visibility_b.py
+++ b/tests/python/render_layer/test_evaluation_visibility_b.py
@@ -26,6 +26,7 @@ class UnitTesting(RenderLayerTesting):
layer = scene.render_layers.new('Visibility Test')
layer.collections.unlink(layer.collections[0])
+ scene.render_layers.active = layer
workspace.render_layer = layer
scene_collection_mom = scene.master_collection.collections.new("Mom")
diff --git a/tests/python/render_layer/test_evaluation_visibility_c.py b/tests/python/render_layer/test_evaluation_visibility_c.py
index 6b88f6e3c3a..5e378fb07e3 100644
--- a/tests/python/render_layer/test_evaluation_visibility_c.py
+++ b/tests/python/render_layer/test_evaluation_visibility_c.py
@@ -26,6 +26,7 @@ class UnitTesting(RenderLayerTesting):
layer = scene.render_layers.new('Visibility Test')
layer.collections.unlink(layer.collections[0])
+ scene.render_layers.active = layer
workspace.render_layer = layer
scene_collection_mom = scene.master_collection.collections.new("Mom")
diff --git a/tests/python/render_layer/test_evaluation_visibility_d.py b/tests/python/render_layer/test_evaluation_visibility_d.py
index b19166bd750..e4f0957bd26 100644
--- a/tests/python/render_layer/test_evaluation_visibility_d.py
+++ b/tests/python/render_layer/test_evaluation_visibility_d.py
@@ -26,6 +26,7 @@ class UnitTesting(RenderLayerTesting):
layer = scene.render_layers.new('Visibility Test')
layer.collections.unlink(layer.collections[0])
+ scene.render_layers.active = layer
workspace.render_layer = layer
scene_collection_mom = scene.master_collection.collections.new("Mom")
diff --git a/tests/python/render_layer/test_evaluation_visibility_e.py b/tests/python/render_layer/test_evaluation_visibility_e.py
index f9f11cb8f23..33c6d7be111 100644
--- a/tests/python/render_layer/test_evaluation_visibility_e.py
+++ b/tests/python/render_layer/test_evaluation_visibility_e.py
@@ -26,6 +26,7 @@ class UnitTesting(RenderLayerTesting):
layer = scene.render_layers.new('Visibility Test')
layer.collections.unlink(layer.collections[0])
+ scene.render_layers.active = layer
workspace.render_layer = layer
scene_collection_mom = scene.master_collection.collections.new("Mom")
diff --git a/tests/python/render_layer/test_evaluation_visibility_f.py b/tests/python/render_layer/test_evaluation_visibility_f.py
index 497087cb9ca..66948b343cb 100644
--- a/tests/python/render_layer/test_evaluation_visibility_f.py
+++ b/tests/python/render_layer/test_evaluation_visibility_f.py
@@ -26,6 +26,7 @@ class UnitTesting(RenderLayerTesting):
layer = scene.render_layers.new('Visibility Test')
layer.collections.unlink(layer.collections[0])
+ scene.render_layers.active = layer
workspace.render_layer = layer
scene_collection_mom = scene.master_collection.collections.new("Mom")
diff --git a/tests/python/render_layer/test_object_copy.py b/tests/python/render_layer/test_object_copy.py
index 69e05d46140..1e6e9e5b889 100644
--- a/tests/python/render_layer/test_object_copy.py
+++ b/tests/python/render_layer/test_object_copy.py
@@ -42,6 +42,7 @@ class UnitTesting(RenderLayerTesting):
layer.collections.link(subzero)
scene.render_layers.active_index = len(scene.render_layers) - 1
+ bpy.context.workspace.render_layer = bpy.context.scene.render_layers['Fresh new Layer']
if mode == 'DUPLICATE':
# assuming the latest layer is the active layer
diff --git a/tests/python/render_layer/test_object_link_b.py b/tests/python/render_layer/test_object_link_b.py
index e0228594be7..b18eb844fc4 100644
--- a/tests/python/render_layer/test_object_link_b.py
+++ b/tests/python/render_layer/test_object_link_b.py
@@ -19,6 +19,7 @@ class UnitTesting(RenderLayerTesting):
See if we can link objects via bpy.context.scene_collection
"""
import bpy
+ bpy.context.scene.render_layers.active_index = len(bpy.context.scene.render_layers) - 1
bpy.context.workspace.render_layer = bpy.context.scene.render_layers['Viewport']
master_collection = bpy.context.scene_collection
self.do_object_link(master_collection)
diff --git a/tests/python/render_layer/test_operator_context.py b/tests/python/render_layer/test_operator_context.py
index 05a8957fa20..5055d957551 100644
--- a/tests/python/render_layer/test_operator_context.py
+++ b/tests/python/render_layer/test_operator_context.py
@@ -88,6 +88,10 @@ class UnitTesting(RenderLayerTesting):
layer.collections.active_index = 3
self.assertEqual(layer.collections.active.name, 'scorpion')
+ # Change active scene layer (do it for workspace too just to don't get mangled in workspace bugs)
+ scene = bpy.context.scene
+ scene.render_layers.active_index = len(scene.render_layers) - 2
+ self.assertEqual(scene.render_layers.active.name, "Viewport")
bpy.context.workspace.render_layer = bpy.context.scene.render_layers['Viewport']
# old layer
diff --git a/tests/python/render_layer/test_scene_copy_d.py b/tests/python/render_layer/test_scene_copy_d.py
index 54988f49036..f398650eade 100644
--- a/tests/python/render_layer/test_scene_copy_d.py
+++ b/tests/python/render_layer/test_scene_copy_d.py
@@ -16,7 +16,7 @@ from render_layer_common import *
class UnitTesting(RenderLayerTesting):
def test_scene_layers_link(self):
"""
- See if scene copying 'FULL_COPY' is working for scene layers
+ See if scene copying 'LINK_OBJECTS' is working for scene layers
"""
import os
ROOT = self.get_root()
diff --git a/tests/python/render_layer/test_scene_copy_f.py b/tests/python/render_layer/test_scene_copy_f.py
new file mode 100644
index 00000000000..fd4298675f2
--- /dev/null
+++ b/tests/python/render_layer/test_scene_copy_f.py
@@ -0,0 +1,94 @@
+# ############################################################
+# Importing - Same For All Render Layer Tests
+# ############################################################
+
+import unittest
+import os
+import sys
+
+from render_layer_common import *
+
+
+# ############################################################
+# Testing
+# ############################################################
+
+class UnitTesting(RenderLayerTesting):
+ def test_shared_layer_collections_copy_full(self):
+ """
+ See if scene copying 'FULL_COPY' is keeping collections visibility
+ and selectability.
+ """
+ import os
+ import bpy
+
+ scene = bpy.context.scene
+
+ hide_lookup = [0, 1, 1, 0]
+ hide_lookup_sub = [1, 0, 1]
+
+ hide_select_lookup = [0, 0, 1, 1]
+ hide_select_lookup_sub = [1, 0, 1, 0]
+ new_collections = []
+
+ # clean everything
+ for layer in scene.render_layers:
+ while layer.collections:
+ layer.collections.unlink(layer.collections[0])
+
+ # create new collections
+ for i in range(4):
+ collection = scene.master_collection.collections.new(str(i))
+ new_collections.append(collection)
+
+ for j in range(3):
+ sub_collection = collection.collections.new("{0}:{1}".format(i, j))
+
+ # link to the original scene
+ for layer in scene.render_layers:
+ for i, collection in enumerate(new_collections):
+ layer.collections.link(collection)
+ self.assertEqual(layer.collections[-1], layer.collections[i])
+
+ layer.collections[i].hide = hide_lookup[i]
+ layer.collections[i].hide_select = hide_select_lookup[i]
+
+ for j, sub_collection in enumerate(layer.collections[i].collections):
+ sub_collection.hide = hide_lookup_sub[j]
+ sub_collection.hide_select = hide_select_lookup_sub[j]
+
+ # copy scene
+ bpy.ops.scene.new(type='FULL_COPY')
+ new_scene = bpy.context.scene
+ self.assertNotEqual(scene, new_scene)
+
+ # update depsgrah
+ scene.update() # update depsgraph
+
+ # compare scenes
+ for h, layer in enumerate(scene.render_layers):
+ new_layer = new_scene.render_layers[h]
+
+ for i, collection in enumerate(layer.collections):
+ new_collection = new_layer.collections[i]
+ self.assertEqual(collection.hide, new_collection.hide)
+ self.assertEqual(collection.hide_select, new_collection.hide_select)
+
+ for j, sub_collection in enumerate(layer.collections[i].collections):
+ new_sub_collection = new_collection.collections[j]
+ self.assertEqual(sub_collection.hide, new_sub_collection.hide)
+ self.assertEqual(sub_collection.hide_select, new_sub_collection.hide_select)
+
+
+# ############################################################
+# Main - Same For All Render Layer Tests
+# ############################################################
+
+if __name__ == '__main__':
+ import sys
+
+ extra_arguments = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
+ sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 2:] if "--" in sys.argv else [])
+
+ UnitTesting._extra_arguments = extra_arguments
+ unittest.main()
diff --git a/tests/python/render_layer/test_scene_delete.py b/tests/python/render_layer/test_scene_delete.py
new file mode 100644
index 00000000000..cd59a446c9a
--- /dev/null
+++ b/tests/python/render_layer/test_scene_delete.py
@@ -0,0 +1,39 @@
+# ############################################################
+# Importing - Same For All Render Layer Tests
+# ############################################################
+
+import unittest
+import os
+import sys
+
+from render_layer_common import *
+
+
+# ############################################################
+# Testing
+# ############################################################
+
+class UnitTesting(RenderLayerTesting):
+ def test_scene_delete(self):
+ """
+ See if a scene can be properly deleted
+ """
+ import bpy
+
+ scene = bpy.context.scene
+ bpy.data.scenes.new('New')
+ bpy.data.scenes.remove(scene)
+
+
+# ############################################################
+# Main - Same For All Render Layer Tests
+# ############################################################
+
+if __name__ == '__main__':
+ import sys
+
+ extra_arguments = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
+ sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 2:] if "--" in sys.argv else [])
+
+ UnitTesting._extra_arguments = extra_arguments
+ unittest.main()